@solidstarters/solid-core 1.2.106 → 1.2.107
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 +6 -1
- 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 +7 -2
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.107",
|
|
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",
|
|
@@ -435,6 +435,9 @@ export class ImportTransactionService extends CRUDService<ImportTransaction> {
|
|
|
435
435
|
}
|
|
436
436
|
|
|
437
437
|
const relatedRecordsIds = await this.getRelatedEntityIdsFromUserKeys(fieldMetadata, record, key);
|
|
438
|
+
if (relatedRecordsIds.length === 0) {
|
|
439
|
+
return dtoRecord; // If no related records found, return the dtoRecord as is
|
|
440
|
+
}
|
|
438
441
|
|
|
439
442
|
if (fieldMetadata.relationType === RelationType.manyTomany || fieldMetadata.relationType === RelationType.oneToMany) {
|
|
440
443
|
dtoRecord[`${fieldMetadata.name}Ids`] = relatedRecordsIds;
|
|
@@ -447,12 +450,14 @@ export class ImportTransactionService extends CRUDService<ImportTransaction> {
|
|
|
447
450
|
}
|
|
448
451
|
|
|
449
452
|
private async getRelatedEntityIdsFromUserKeys(fieldMetadata: FieldMetadata, record: Record<string, any>, key: string): Promise<Array<number>> {
|
|
453
|
+
// For many-to-many or one-to-many relations, we expect the record cell to contains a comma-separated list of userKeys
|
|
454
|
+
const relationUserKeys = record[key] ? String(record[key]).split(',').map((userKey: string) => userKey.trim()) : [];
|
|
455
|
+
if (relationUserKeys.length === 0) return [];
|
|
456
|
+
|
|
450
457
|
const coModelService = this.getModelService(fieldMetadata.relationCoModelSingularName);
|
|
451
458
|
const coModelWithUserKeyField = await this.modelMetadataService.findOneBySingularName(fieldMetadata.relationCoModelSingularName, ['userKeyField']);
|
|
452
459
|
const coModelUserKeyFieldName = coModelWithUserKeyField?.userKeyField?.name || 'id'; // Default to 'id' if not found
|
|
453
460
|
|
|
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
461
|
|
|
457
462
|
// 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
463
|
const relationFilterDto = {
|