@solidstarters/solid-core 1.2.118 → 1.2.120
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 +9 -0
- package/dist/services/import-transaction.service.d.ts.map +1 -1
- package/dist/services/import-transaction.service.js +18 -9
- 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 +19 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidstarters/solid-core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.120",
|
|
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",
|
|
@@ -65,11 +65,20 @@ interface ImportMapping {
|
|
|
65
65
|
fieldName: string; // The name of the field in the model metadata to which the imported field is mapped
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
export enum ImportTransactionStatus {
|
|
69
|
+
draft = 'draft',
|
|
70
|
+
mapping_created = 'mapping_created',
|
|
71
|
+
import_started = 'import_started',
|
|
72
|
+
import_succeeded = 'import_succeeded',
|
|
73
|
+
import_failed = 'import_failed',
|
|
74
|
+
}
|
|
75
|
+
|
|
68
76
|
export interface ImportSyncResult {
|
|
69
77
|
status: string; // The status of the import transaction
|
|
70
78
|
importedIds: Array<number>; // The IDs of the records created during the import
|
|
79
|
+
importedCount: number; // The number of records created during the import
|
|
80
|
+
failedCount: number; // The number of records that failed to import
|
|
71
81
|
}
|
|
72
|
-
|
|
73
82
|
interface ImportRecordsResult {
|
|
74
83
|
ids: Array<number>; // The IDs of the records created during the import
|
|
75
84
|
errorLogIds: Array<number>; // The IDs of the error log entries created during the import
|
|
@@ -261,11 +270,15 @@ export class ImportTransactionService extends CRUDService<ImportTransaction> {
|
|
|
261
270
|
);
|
|
262
271
|
|
|
263
272
|
// Update the import transaction status to 'completed'
|
|
264
|
-
(errorLogIds.length > 0) ? importTransaction.status =
|
|
273
|
+
(errorLogIds.length > 0) ? importTransaction.status = ImportTransactionStatus.import_failed : importTransaction.status = ImportTransactionStatus.import_failed; //FIXME: We can probably have import_partially_failed status to differentiate
|
|
265
274
|
// Save the import transaction
|
|
266
275
|
await this.repo.save(importTransaction);
|
|
267
|
-
|
|
268
|
-
|
|
276
|
+
return {
|
|
277
|
+
status: importTransaction.status,
|
|
278
|
+
importedIds: ids, // The IDs of the records created during the import
|
|
279
|
+
importedCount: ids.length, // The number of records created during the import
|
|
280
|
+
failedCount: errorLogIds.length, // The number of records that failed to import
|
|
281
|
+
};
|
|
269
282
|
}
|
|
270
283
|
|
|
271
284
|
startImportAsync(importTransactionId: number): Promise<void> {
|
|
@@ -286,10 +299,8 @@ export class ImportTransactionService extends CRUDService<ImportTransaction> {
|
|
|
286
299
|
|
|
287
300
|
// Create the headers for the export file
|
|
288
301
|
const headers = [
|
|
289
|
-
'rowNumber', // Row number in the import file
|
|
290
|
-
'errorMessage', // Error message for the failed record
|
|
291
|
-
'errorTrace', // Error trace for debugging
|
|
292
302
|
...Object.keys(firstErrorLogEntry.rowData ? JSON.parse(firstErrorLogEntry.rowData) : {}), // Include all keys from the rowData JSON
|
|
303
|
+
'Error', // Error message for the failed record
|
|
293
304
|
];
|
|
294
305
|
|
|
295
306
|
|
|
@@ -316,10 +327,8 @@ export class ImportTransactionService extends CRUDService<ImportTransaction> {
|
|
|
316
327
|
return errorLogEntries.map(entry => {
|
|
317
328
|
const rowData = entry.rowData ? JSON.parse(entry.rowData) : {};
|
|
318
329
|
return {
|
|
319
|
-
rowNumber: entry.rowNumber,
|
|
320
|
-
errorMessage: entry.errorMessage,
|
|
321
|
-
errorTrace: entry.errorTrace,
|
|
322
330
|
...rowData, // Spread the row data into the record
|
|
331
|
+
Error: entry.errorMessage,
|
|
323
332
|
};
|
|
324
333
|
});
|
|
325
334
|
};
|