UNPKG

@strapi/data-transfer

Version:

Data transfer capabilities for Strapi

50 lines 3 kB
import type { Modules, UID, Data, Schema, Core } from '@strapi/types'; type LoadedComponents<TUID extends UID.Schema> = Data.Entity<TUID, Schema.AttributeNamesByType<TUID, 'component' | 'dynamiczone'>>; type ComponentBody = { [key: string]: Schema.Attribute.Value<Schema.Attribute.Component<UID.Component, false> | Schema.Attribute.Component<UID.Component, true> | Schema.Attribute.DynamicZone>; }; declare function omitComponentData(contentType: Schema.ContentType, data: Modules.EntityService.Params.Data.Input<Schema.ContentType['uid']>): Partial<Modules.EntityService.Params.Data.Input<Schema.ContentType['uid']>>; declare function omitComponentData(contentType: Schema.Component, data: Modules.EntityService.Params.Data.Input<Schema.Component['uid']>): Partial<Modules.EntityService.Params.Data.Input<Schema.Component['uid']>>; declare const createComponents: <TUID extends UID.Schema, TData extends Modules.EntityService.Params.Data.Input<TUID>>(uid: TUID, data: TData) => Promise<ComponentBody>; declare const getComponents: <TUID extends UID.Schema>(uid: TUID, entity: { id: Modules.EntityService.Params.Attribute.ID; }) => Promise<LoadedComponents<TUID>>; declare const updateComponents: <TUID extends UID.Schema, TData extends Partial<Modules.EntityService.Params.Data.Input<TUID>>>(uid: TUID, entityToUpdate: { id: Modules.EntityService.Params.Attribute.ID; }, data: TData) => Promise<ComponentBody>; declare const deleteComponents: <TUID extends UID.Schema, TEntity extends Data.Entity<TUID>>(uid: TUID, entityToDelete: TEntity, { loadComponents }?: { loadComponents?: boolean | undefined; }) => Promise<void>; declare const deleteComponent: <TUID extends UID.Component>(uid: TUID, componentToDelete: Data.Component<TUID>) => Promise<void>; interface IComponentIdMapping { uid: UID.Component; oldID: number; newID: number; } /** * Walk the source data and the newly created entity in parallel and collect * the [old ID, new ID] couple of every component instance found in both trees * (components & dynamic zones, including nested ones). * * Unlike a JSON diff, couples are also collected when the ID did not change, * so the result is an exhaustive map of every component instance that was * re-created with the entity. */ declare const collectComponentIdMappings: ({ data, created, schema, strapi, }: { data: any; created: any; schema: Schema.Schema; strapi: Core.Strapi; }) => IComponentIdMapping[]; /** * Resolve the component UID of an entity's attribute based * on a given path (components & dynamic zones only) */ declare const resolveComponentUID: ({ paths, strapi, data, contentType, }: { paths: string[]; strapi: Core.Strapi; data: any; contentType: Schema.ContentType; }) => UID.Schema | undefined; export { omitComponentData, getComponents, createComponents, updateComponents, deleteComponents, deleteComponent, collectComponentIdMappings, resolveComponentUID, }; //# sourceMappingURL=components.d.ts.map