@punks/backend-entity-manager 0.0.449 → 0.0.451

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.
@@ -76,7 +76,7 @@ export type ImportEntry<TSheetItem, TEntityId> = {
76
76
  export interface IEntitySerializer<TEntity, TEntityId, TEntitySearchParameters, TSheetItem, TPayload = unknown> {
77
77
  export(filters?: TEntitySearchParameters): Promise<TSheetItem[]>;
78
78
  import(items: TSheetItem[], payload?: TPayload): Promise<void>;
79
- serialize(items: TSheetItem[], format: EntitySerializationFormat): Promise<EntityExportFile>;
79
+ serialize(items: TSheetItem[], format: EntitySerializationFormat, payload?: TPayload): Promise<EntityExportFile>;
80
80
  parse<TPayload>(data: Buffer, format: EntitySerializationFormat, payload?: TPayload): Promise<ImportEntry<TSheetItem, TEntityId>[]>;
81
81
  createSample(format: EntitySerializationFormat): Promise<EntityExportFile>;
82
82
  }
@@ -26,7 +26,7 @@ export declare abstract class EntitySerializer<TEntity, TEntityId, TEntitySearch
26
26
  private parseColumnValue;
27
27
  createSample(format: EntitySerializationFormat): Promise<EntityExportFile>;
28
28
  private buildSampleFile;
29
- serialize(data: TSheetItem[], format: EntitySerializationFormat): Promise<EntityExportFile>;
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
32
  protected abstract convertToSheetItems(entities: TEntity[]): Promise<TSheetItem[]>;
package/dist/esm/index.js CHANGED
@@ -391,8 +391,8 @@ class EntitySerializer {
391
391
  throw new Error("Json sample not implemented");
392
392
  }
393
393
  }
394
- async serialize(data, format) {
395
- return await this.buildExportFile(data, format);
394
+ async serialize(data, format, payload) {
395
+ return await this.buildExportFile(data, format, payload);
396
396
  }
397
397
  validateSheetItem(item, allItems, context) { }
398
398
  async getContext() {
@@ -400,13 +400,13 @@ class EntitySerializer {
400
400
  .resolveAuthenticationContextProvider()
401
401
  ?.getContext());
402
402
  }
403
- async buildExportFile(data, format) {
403
+ async buildExportFile(data, format, payload) {
404
404
  const fileName = this.buildExportFileName({
405
405
  format,
406
406
  refDate: new Date(),
407
407
  });
408
408
  const context = await this.getContext();
409
- const definition = await this.getDefinition(context);
409
+ const definition = await this.getDefinition(context, payload);
410
410
  switch (format) {
411
411
  case EntitySerializationFormat.Csv:
412
412
  return {
@@ -906,8 +906,10 @@ class EntitiesExportCommand {
906
906
  },
907
907
  };
908
908
  }
909
- async buildExportFile(data, format) {
910
- return await this.services.resolveSerializer().serialize(data, format);
909
+ async buildExportFile(data, format, payload) {
910
+ return await this.services
911
+ .resolveSerializer()
912
+ .serialize(data, format, payload);
911
913
  }
912
914
  async uploadExportFile(file) {
913
915
  await this.bucket.fileUpload({