@solidstarters/solid-core 1.2.113 → 1.2.114
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/services/import-transaction.service.d.ts.map +1 -1
- package/dist/services/import-transaction.service.js +8 -2
- package/dist/services/import-transaction.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/services/import-transaction.service.ts +13 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidstarters/solid-core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.114",
|
|
4
4
|
"description": "This module is a NestJS module containing all the required core providers required by a Solid application",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -248,6 +248,12 @@ export class ImportTransactionService extends CRUDService<ImportTransaction> {
|
|
|
248
248
|
JSON.parse(importTransaction.mapping) as ImportMapping[], // Parse the mapping from the import transaction
|
|
249
249
|
importTransaction.modelMetadata,
|
|
250
250
|
);
|
|
251
|
+
|
|
252
|
+
// Update the import transaction status to 'completed'
|
|
253
|
+
importTransaction.status = 'import_succeeded';
|
|
254
|
+
// Save the import transaction
|
|
255
|
+
await this.repo.save(importTransaction);
|
|
256
|
+
|
|
251
257
|
return {status: importTransaction.status, importedIds: ids}; // Return the IDs of the created records
|
|
252
258
|
}
|
|
253
259
|
|
|
@@ -331,7 +337,7 @@ export class ImportTransactionService extends CRUDService<ImportTransaction> {
|
|
|
331
337
|
): Promise<Array<number>> {
|
|
332
338
|
// Get the model service for the model metadata name
|
|
333
339
|
const modelService = this.getModelService(modelMetadataWithFields.singularName);
|
|
334
|
-
|
|
340
|
+
const createdRecordIds = [];
|
|
335
341
|
// Depending upon the mime type of the file, read the file in pages
|
|
336
342
|
// For CSV files, use the csvService to read the file in pages
|
|
337
343
|
// For Excel files, use the excelService to read the file in pages
|
|
@@ -344,7 +350,9 @@ export class ImportTransactionService extends CRUDService<ImportTransaction> {
|
|
|
344
350
|
const createdRecords = await modelService.insertMany(dtos, [], {});
|
|
345
351
|
// Set the solidRequestContext to null, as this is a background job;
|
|
346
352
|
// Return the IDs of the created records
|
|
347
|
-
|
|
353
|
+
const newIds = createdRecords.map(record => record.id);
|
|
354
|
+
// Add the new IDs to the createdRecordIds array
|
|
355
|
+
createdRecordIds.push(...newIds);
|
|
348
356
|
}
|
|
349
357
|
}
|
|
350
358
|
else if (mimeType === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {
|
|
@@ -356,11 +364,13 @@ export class ImportTransactionService extends CRUDService<ImportTransaction> {
|
|
|
356
364
|
const createdRecords = await modelService.insertMany(dtos, [], {});
|
|
357
365
|
// Set the solidRequestContext to null, as this is a background job;
|
|
358
366
|
// Return the IDs of the created records
|
|
359
|
-
|
|
367
|
+
const newIds = createdRecords.map(record => record.id);
|
|
368
|
+
createdRecordIds.push(...newIds);
|
|
360
369
|
}
|
|
361
370
|
} else { // If the file is neither CSV nor Excel, throw an error
|
|
362
371
|
throw new Error(`Unsupported file type: ${mimeType}`);
|
|
363
372
|
}
|
|
373
|
+
return createdRecordIds; // Return the IDs of the created records
|
|
364
374
|
}
|
|
365
375
|
|
|
366
376
|
private getModelService(modelSingularName: string): CRUDService<any> {
|