@punks/backend-entity-manager 0.0.441 → 0.0.443
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.
- package/dist/cjs/index.js +6 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/serializer.d.ts +1 -1
- package/dist/cjs/types/commands/import.d.ts +1 -1
- package/dist/esm/index.js +6 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/serializer.d.ts +1 -1
- package/dist/esm/types/commands/import.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -77,6 +77,6 @@ export interface IEntitySerializer<TEntity, TEntityId, TEntitySearchParameters,
|
|
|
77
77
|
export(filters?: TEntitySearchParameters): Promise<TSheetItem[]>;
|
|
78
78
|
import(items: TSheetItem[], payload?: TPayload): Promise<void>;
|
|
79
79
|
serialize(items: TSheetItem[], format: EntitySerializationFormat): Promise<EntityExportFile>;
|
|
80
|
-
parse(data: Buffer, format: EntitySerializationFormat): Promise<ImportEntry<TSheetItem, TEntityId>[]>;
|
|
80
|
+
parse<TPayload>(data: Buffer, format: EntitySerializationFormat, payload?: TPayload): Promise<ImportEntry<TSheetItem, TEntityId>[]>;
|
|
81
81
|
createSample(format: EntitySerializationFormat): Promise<EntityExportFile>;
|
|
82
82
|
}
|
|
@@ -6,7 +6,7 @@ export declare class EntitiesImportCommand<TEntity> implements IEntitiesImportCo
|
|
|
6
6
|
private readonly services;
|
|
7
7
|
private readonly settings;
|
|
8
8
|
constructor(services: EntityServiceLocator<TEntity, unknown>, settings: EntitiesImportExportSettings);
|
|
9
|
-
execute(input: EntitiesImportInput<
|
|
9
|
+
execute<TPayload = unknown>(input: EntitiesImportInput<TPayload>): Promise<EntitiesImportResult>;
|
|
10
10
|
private parseImportFile;
|
|
11
11
|
private uploadImportFile;
|
|
12
12
|
private buildAbsoluteBucketPath;
|
package/dist/esm/index.js
CHANGED
|
@@ -265,7 +265,6 @@ class EntitySerializer {
|
|
|
265
265
|
dateColumns: dateColumns.map((x) => x.name),
|
|
266
266
|
...(definition?.options ? definition.options : {}),
|
|
267
267
|
});
|
|
268
|
-
console.log("records", records);
|
|
269
268
|
return records.map((x, i) => this.convertSheetRecord(x, definition, i));
|
|
270
269
|
}
|
|
271
270
|
convertSheetRecord(record, definition, rowIndex) {
|
|
@@ -951,7 +950,7 @@ class EntitiesImportCommand {
|
|
|
951
950
|
contentType: input.file.contentType,
|
|
952
951
|
fileName: input.file.fileName,
|
|
953
952
|
});
|
|
954
|
-
const importEntities = await this.parseImportFile(input.file.content, input.format);
|
|
953
|
+
const importEntities = await this.parseImportFile(input.file.content, input.format, input?.payload);
|
|
955
954
|
const validEntities = importEntities.filter((x) => x.status.isValid);
|
|
956
955
|
const invalidEntities = importEntities.filter((x) => !x.status.isValid);
|
|
957
956
|
if (invalidEntities.length > 0 &&
|
|
@@ -960,7 +959,7 @@ class EntitiesImportCommand {
|
|
|
960
959
|
.map((x) => x.id)
|
|
961
960
|
.join(", ")}`);
|
|
962
961
|
}
|
|
963
|
-
await this.services.resolveSerializer().import(validEntities.map((x) => x.item), input
|
|
962
|
+
await this.services.resolveSerializer().import(validEntities.map((x) => x.item), input?.payload);
|
|
964
963
|
return {
|
|
965
964
|
statistics: {
|
|
966
965
|
importedCount: validEntities.length,
|
|
@@ -971,8 +970,10 @@ class EntitiesImportCommand {
|
|
|
971
970
|
},
|
|
972
971
|
};
|
|
973
972
|
}
|
|
974
|
-
async parseImportFile(content, format) {
|
|
975
|
-
return await this.services
|
|
973
|
+
async parseImportFile(content, format, payload) {
|
|
974
|
+
return await this.services
|
|
975
|
+
.resolveSerializer()
|
|
976
|
+
.parse(content, format, payload);
|
|
976
977
|
}
|
|
977
978
|
async uploadImportFile(file) {
|
|
978
979
|
await this.bucket.fileUpload({
|