@punks/backend-entity-manager 0.0.487 → 0.0.488
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.
|
@@ -20,6 +20,7 @@ export declare abstract class EntitySerializer<TEntity, TEntityId, TEntitySearch
|
|
|
20
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
|
+
protected importItems(items: TSheetItem[], context: TContext, payload?: TPayload): Promise<void>;
|
|
23
24
|
private parseCsv;
|
|
24
25
|
private parseXlsx;
|
|
25
26
|
private convertSheetRecord;
|
package/dist/esm/index.js
CHANGED
|
@@ -244,10 +244,7 @@ class EntitySerializer {
|
|
|
244
244
|
async import(items, payload) {
|
|
245
245
|
this.logger.info(`Entities import -> started (${items.length} items)`);
|
|
246
246
|
const context = await this.getContext();
|
|
247
|
-
|
|
248
|
-
await this.importItem(item, context, payload);
|
|
249
|
-
this.logger.info(`Entity imported -> ${index + 1}/${items.length}`);
|
|
250
|
-
}
|
|
247
|
+
await this.importItems(items, context, payload);
|
|
251
248
|
this.logger.info(`Entities import -> completed (${items.length} items)`);
|
|
252
249
|
}
|
|
253
250
|
async parse(data, format, payload) {
|
|
@@ -262,6 +259,12 @@ class EntitySerializer {
|
|
|
262
259
|
throw new Error(`Format ${format} not supported`);
|
|
263
260
|
}
|
|
264
261
|
}
|
|
262
|
+
async importItems(items, context, payload) {
|
|
263
|
+
for (const [index, item] of items.entries()) {
|
|
264
|
+
await this.importItem(item, context, payload);
|
|
265
|
+
this.logger.info(`Entity imported -> ${index + 1}/${items.length}`);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
265
268
|
parseCsv(data, definition) {
|
|
266
269
|
const records = csvParse(data, DEFAULT_DELIMITER$1);
|
|
267
270
|
return records.map((x, i) => this.convertSheetRecord(x, definition, i));
|