@punks/backend-entity-manager 0.0.440 → 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 -6
- 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 -6
- 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
|
@@ -275,8 +275,6 @@ class EntitySerializer {
|
|
|
275
275
|
const entity = (definition.autoColumns ? { ...record } : {});
|
|
276
276
|
for (const column of definition.columns) {
|
|
277
277
|
const columnName = [column.name, ...(column?.aliases ?? [])].find((x) => normalizeSheetColumn(x) in record) ?? null;
|
|
278
|
-
console.log("name", columnName);
|
|
279
|
-
console.log("record", entity);
|
|
280
278
|
if (!columnName)
|
|
281
279
|
continue;
|
|
282
280
|
if (column.parseAction) {
|
|
@@ -952,7 +950,7 @@ class EntitiesImportCommand {
|
|
|
952
950
|
contentType: input.file.contentType,
|
|
953
951
|
fileName: input.file.fileName,
|
|
954
952
|
});
|
|
955
|
-
const importEntities = await this.parseImportFile(input.file.content, input.format);
|
|
953
|
+
const importEntities = await this.parseImportFile(input.file.content, input.format, input?.payload);
|
|
956
954
|
const validEntities = importEntities.filter((x) => x.status.isValid);
|
|
957
955
|
const invalidEntities = importEntities.filter((x) => !x.status.isValid);
|
|
958
956
|
if (invalidEntities.length > 0 &&
|
|
@@ -961,7 +959,7 @@ class EntitiesImportCommand {
|
|
|
961
959
|
.map((x) => x.id)
|
|
962
960
|
.join(", ")}`);
|
|
963
961
|
}
|
|
964
|
-
await this.services.resolveSerializer().import(validEntities.map((x) => x.item), input
|
|
962
|
+
await this.services.resolveSerializer().import(validEntities.map((x) => x.item), input?.payload);
|
|
965
963
|
return {
|
|
966
964
|
statistics: {
|
|
967
965
|
importedCount: validEntities.length,
|
|
@@ -972,8 +970,10 @@ class EntitiesImportCommand {
|
|
|
972
970
|
},
|
|
973
971
|
};
|
|
974
972
|
}
|
|
975
|
-
async parseImportFile(content, format) {
|
|
976
|
-
return await this.services
|
|
973
|
+
async parseImportFile(content, format, payload) {
|
|
974
|
+
return await this.services
|
|
975
|
+
.resolveSerializer()
|
|
976
|
+
.parse(content, format, payload);
|
|
977
977
|
}
|
|
978
978
|
async uploadImportFile(file) {
|
|
979
979
|
await this.bucket.fileUpload({
|