@punks/backend-entity-manager 0.0.462 → 0.0.464

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -74,7 +74,7 @@ export type ImportEntry<TSheetItem, TEntityId> = {
74
74
  status: ImportEntryValidationResult;
75
75
  };
76
76
  export interface IEntitySerializer<TEntity, TEntityId, TEntitySearchParameters, TSheetItem, TPayload = unknown> {
77
- export(filters?: TEntitySearchParameters): Promise<TSheetItem[]>;
77
+ export(filters?: TEntitySearchParameters, payload?: TPayload): Promise<TSheetItem[]>;
78
78
  import(items: TSheetItem[], payload?: TPayload): Promise<void>;
79
79
  serialize(items: TSheetItem[], format: EntitySerializationFormat, payload?: TPayload): Promise<EntityExportFile>;
80
80
  parse<TPayload>(data: Buffer, format: EntitySerializationFormat, payload?: TPayload): Promise<ImportEntry<TSheetItem, TEntityId>[]>;
@@ -17,7 +17,7 @@ export declare abstract class EntitySerializer<TEntity, TEntityId, TEntitySearch
17
17
  private readonly logger;
18
18
  protected readonly entityName: string;
19
19
  constructor(services: EntityServiceLocator<TEntity, TEntityId>, options?: EntitySerializerOptions | undefined);
20
- export(filters?: TEntitySearchParameters): Promise<TSheetItem[]>;
20
+ export(filters?: TEntitySearchParameters, payload?: TPayload): Promise<TSheetItem[]>;
21
21
  import(items: TSheetItem[], payload?: TPayload): Promise<void>;
22
22
  parse<TPayload>(data: Buffer, format: EntitySerializationFormat, payload?: TPayload): Promise<ImportEntry<TSheetItem, TEntityId>[]>;
23
23
  private parseCsv;
@@ -29,7 +29,7 @@ export declare abstract class EntitySerializer<TEntity, TEntityId, TEntitySearch
29
29
  serialize(data: TSheetItem[], format: EntitySerializationFormat, payload?: TPayload): Promise<EntityExportFile>;
30
30
  protected abstract getDefinition(context: TContext, payload?: TPayload): Promise<EntitySerializerSheetDefinition<TSheetItem>>;
31
31
  protected abstract loadEntities(filters?: TEntitySearchParameters): Promise<TEntity[]>;
32
- protected abstract convertToSheetItems(entities: TEntity[]): Promise<TSheetItem[]>;
32
+ protected abstract convertToSheetItems(entities: TEntity[], payload?: TPayload): Promise<TSheetItem[]>;
33
33
  protected validateSheetItem(item: TSheetItem, allItems: TSheetItem[], context: TContext): void;
34
34
  protected abstract importItem(item: TSheetItem, context: TContext, payload?: TPayload): Promise<EntityReference<TEntityId>>;
35
35
  protected getContext(): Promise<TContext>;
package/dist/esm/index.js CHANGED
@@ -235,9 +235,9 @@ class EntitySerializer {
235
235
  this.entityName = services.getEntityName();
236
236
  this.logger = Log.getLogger(`${services.getEntityName()} -> Serializer`);
237
237
  }
238
- async export(filters) {
238
+ async export(filters, payload) {
239
239
  const entities = await this.loadEntities(filters ?? {});
240
- return await this.convertToSheetItems(entities);
240
+ return await this.convertToSheetItems(entities, payload);
241
241
  }
242
242
  async import(items, payload) {
243
243
  this.logger.info(`Entities import -> started (${items.length} items)`);
@@ -906,7 +906,7 @@ class EntitiesExportCommand {
906
906
  this.settings = settings;
907
907
  }
908
908
  async execute(input) {
909
- const sheetItems = await this.getExportSheetItems(input.filter);
909
+ const sheetItems = await this.getExportSheetItems(input.filter, input.payload);
910
910
  const outputFile = await this.buildExportFile(sheetItems, input.options.format, input.payload);
911
911
  const downloadUrl = await this.uploadExportFile(outputFile);
912
912
  return {
@@ -939,8 +939,8 @@ class EntitiesExportCommand {
939
939
  buildAbsoluteBucketPath(relativePath) {
940
940
  return `${this.settings.exportBucket.rootFolderPath ?? ""}/exports/${createDayPath$1(new Date())}/${relativePath}`;
941
941
  }
942
- async getExportSheetItems(filters) {
943
- return await this.services.resolveSerializer().export(filters);
942
+ async getExportSheetItems(filters, payload) {
943
+ return await this.services.resolveSerializer().export(filters, payload);
944
944
  }
945
945
  get bucket() {
946
946
  return this.services.getRootServices().resolveDefaultBucketProvider();