@solidstarters/solid-core 1.2.106 → 1.2.109
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/controllers/import-transaction.controller.d.ts +1 -1
- package/dist/controllers/import-transaction.controller.js +1 -1
- package/dist/services/import-transaction.service.d.ts +5 -1
- package/dist/services/import-transaction.service.d.ts.map +1 -1
- package/dist/services/import-transaction.service.js +7 -2
- package/dist/services/import-transaction.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/import_fix +37 -0
- package/package.json +1 -1
- package/src/services/import-transaction.service.ts +14 -4
package/import_fix
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
commit 0ee811cd5c23efc2f3762436b89cc3d50f82ceae
|
|
2
|
+
Author: Oswald Rodrigues <oswald@logicloop.io>
|
|
3
|
+
Date: Wed Jun 11 14:58:16 2025 +0530
|
|
4
|
+
|
|
5
|
+
import related records fix
|
|
6
|
+
|
|
7
|
+
diff --git a/src/services/import-transaction.service.ts b/src/services/import-transaction.service.ts
|
|
8
|
+
index 6b3d167..515e52c 100644
|
|
9
|
+
--- a/src/services/import-transaction.service.ts
|
|
10
|
+
+++ b/src/services/import-transaction.service.ts
|
|
11
|
+
@@ -434,6 +434,9 @@ export class ImportTransactionService extends CRUDService<ImportTransaction> {
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const relatedRecordsIds = await this.getRelatedEntityIdsFromUserKeys(fieldMetadata, record, key);
|
|
15
|
+
+ if (relatedRecordsIds.length === 0) {
|
|
16
|
+
+ return dtoRecord; // If no related records found, return the dtoRecord as is
|
|
17
|
+
+ }
|
|
18
|
+
|
|
19
|
+
if (fieldMetadata.relationType === RelationType.manyTomany || fieldMetadata.relationType === RelationType.oneToMany) {
|
|
20
|
+
dtoRecord[`${fieldMetadata.name}Ids`] = relatedRecordsIds;
|
|
21
|
+
@@ -446,12 +449,14 @@ export class ImportTransactionService extends CRUDService<ImportTransaction> {
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private async getRelatedEntityIdsFromUserKeys(fieldMetadata: FieldMetadata, record: Record<string, any>, key: string): Promise<Array<number>> {
|
|
25
|
+
+ // For many-to-many or one-to-many relations, we expect the record cell to contains a comma-separated list of userKeys
|
|
26
|
+
+ const relationUserKeys = record[key] ? String(record[key]).split(',').map((userKey: string) => userKey.trim()) : [];
|
|
27
|
+
+ if (relationUserKeys.length === 0) return [];
|
|
28
|
+
+
|
|
29
|
+
const coModelService = this.getModelService(fieldMetadata.relationCoModelSingularName);
|
|
30
|
+
const coModelWithUserKeyField = await this.modelMetadataService.findOneBySingularName(fieldMetadata.relationCoModelSingularName, ['userKeyField']);
|
|
31
|
+
const coModelUserKeyFieldName = coModelWithUserKeyField?.userKeyField?.name || 'id'; // Default to 'id' if not found
|
|
32
|
+
|
|
33
|
+
- // For many-to-many or one-to-many relations, we expect the record cell to contains a comma-separated list of userKeys
|
|
34
|
+
- const relationUserKeys = record[key] ? String(record[key]).split(',').map((userKey: string) => userKey.trim()) : [];
|
|
35
|
+
|
|
36
|
+
// Set the relation basic filter dto filters with the userkeys and call the find method of the model service to get the related records
|
|
37
|
+
const relationFilterDto = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidstarters/solid-core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.109",
|
|
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",
|
|
@@ -58,6 +58,11 @@ interface ImportMapping {
|
|
|
58
58
|
fieldName: string; // The name of the field in the model metadata to which the imported field is mapped
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
export interface ImportSyncResult {
|
|
62
|
+
status: string; // The status of the import transaction
|
|
63
|
+
importedIds: Array<number>; // The IDs of the records created during the import
|
|
64
|
+
}
|
|
65
|
+
|
|
61
66
|
@Injectable()
|
|
62
67
|
export class ImportTransactionService extends CRUDService<ImportTransaction> {
|
|
63
68
|
constructor(
|
|
@@ -227,7 +232,7 @@ export class ImportTransactionService extends CRUDService<ImportTransaction> {
|
|
|
227
232
|
};
|
|
228
233
|
}
|
|
229
234
|
|
|
230
|
-
async startImportSync(importTransactionId: number): Promise<
|
|
235
|
+
async startImportSync(importTransactionId: number): Promise<ImportSyncResult> {
|
|
231
236
|
// Load the import transaction for the given ID
|
|
232
237
|
const importTransaction = await this.loadImportTransaction(importTransactionId);
|
|
233
238
|
|
|
@@ -243,7 +248,7 @@ export class ImportTransactionService extends CRUDService<ImportTransaction> {
|
|
|
243
248
|
JSON.parse(importTransaction.mapping) as ImportMapping[], // Parse the mapping from the import transaction
|
|
244
249
|
importTransaction.modelMetadata,
|
|
245
250
|
);
|
|
246
|
-
return ids; // Return the IDs of the created records
|
|
251
|
+
return {status: importTransaction.status, importedIds: ids}; // Return the IDs of the created records
|
|
247
252
|
}
|
|
248
253
|
|
|
249
254
|
startImportAsync(importTransactionId: number): Promise<void> {
|
|
@@ -435,6 +440,9 @@ export class ImportTransactionService extends CRUDService<ImportTransaction> {
|
|
|
435
440
|
}
|
|
436
441
|
|
|
437
442
|
const relatedRecordsIds = await this.getRelatedEntityIdsFromUserKeys(fieldMetadata, record, key);
|
|
443
|
+
if (relatedRecordsIds.length === 0) {
|
|
444
|
+
return dtoRecord; // If no related records found, return the dtoRecord as is
|
|
445
|
+
}
|
|
438
446
|
|
|
439
447
|
if (fieldMetadata.relationType === RelationType.manyTomany || fieldMetadata.relationType === RelationType.oneToMany) {
|
|
440
448
|
dtoRecord[`${fieldMetadata.name}Ids`] = relatedRecordsIds;
|
|
@@ -447,12 +455,14 @@ export class ImportTransactionService extends CRUDService<ImportTransaction> {
|
|
|
447
455
|
}
|
|
448
456
|
|
|
449
457
|
private async getRelatedEntityIdsFromUserKeys(fieldMetadata: FieldMetadata, record: Record<string, any>, key: string): Promise<Array<number>> {
|
|
458
|
+
// For many-to-many or one-to-many relations, we expect the record cell to contains a comma-separated list of userKeys
|
|
459
|
+
const relationUserKeys = record[key] ? String(record[key]).split(',').map((userKey: string) => userKey.trim()) : [];
|
|
460
|
+
if (relationUserKeys.length === 0) return [];
|
|
461
|
+
|
|
450
462
|
const coModelService = this.getModelService(fieldMetadata.relationCoModelSingularName);
|
|
451
463
|
const coModelWithUserKeyField = await this.modelMetadataService.findOneBySingularName(fieldMetadata.relationCoModelSingularName, ['userKeyField']);
|
|
452
464
|
const coModelUserKeyFieldName = coModelWithUserKeyField?.userKeyField?.name || 'id'; // Default to 'id' if not found
|
|
453
465
|
|
|
454
|
-
// For many-to-many or one-to-many relations, we expect the record cell to contains a comma-separated list of userKeys
|
|
455
|
-
const relationUserKeys = record[key] ? String(record[key]).split(',').map((userKey: string) => userKey.trim()) : [];
|
|
456
466
|
|
|
457
467
|
// Set the relation basic filter dto filters with the userkeys and call the find method of the model service to get the related records
|
|
458
468
|
const relationFilterDto = {
|