@futdevpro/nts-dynamo 1.10.8 → 1.10.10
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/build/_models/control-models/app-params.control-model.d.ts.map +1 -1
- package/build/_models/control-models/app-params.control-model.js +11 -0
- package/build/_models/control-models/app-params.control-model.js.map +1 -1
- package/build/_modules/mock/data-model.mock.js +2 -2
- package/build/_modules/mock/data-model.mock.js.map +1 -1
- package/build/_modules/mock/socket-client.mock.js +1 -1
- package/build/_modules/mock/socket-client.mock.js.map +1 -1
- package/build/_modules/mock/socket-client.mock.spec.js +1 -1
- package/build/_modules/mock/socket-client.mock.spec.js.map +1 -1
- package/build/_modules/socket/_models/socket-client-service-params.control-model.d.ts.map +1 -1
- package/build/_modules/socket/_models/socket-client-service-params.control-model.js +1 -1
- package/build/_modules/socket/_models/socket-client-service-params.control-model.js.map +1 -1
- package/build/_modules/socket/_models/socket-client-service-params.control-model.spec.js +1 -1
- package/build/_modules/socket/_models/socket-client-service-params.control-model.spec.js.map +1 -1
- package/build/_modules/socket/_services/socket-client.service.d.ts +1 -1
- package/build/_modules/socket/_services/socket-client.service.d.ts.map +1 -1
- package/build/_modules/socket/_services/socket-client.service.js +7 -2
- package/build/_modules/socket/_services/socket-client.service.js.map +1 -1
- package/build/_modules/socket/_services/socket-server.service.d.ts +9 -11
- package/build/_modules/socket/_services/socket-server.service.d.ts.map +1 -1
- package/build/_modules/socket/_services/socket-server.service.js +198 -100
- package/build/_modules/socket/_services/socket-server.service.js.map +1 -1
- package/build/_services/base/data.service.d.ts +17 -10
- package/build/_services/base/data.service.d.ts.map +1 -1
- package/build/_services/base/data.service.js +137 -107
- package/build/_services/base/data.service.js.map +1 -1
- package/build/_services/base/db.service.d.ts +20 -10
- package/build/_services/base/db.service.d.ts.map +1 -1
- package/build/_services/base/db.service.js +66 -47
- package/build/_services/base/db.service.js.map +1 -1
- package/build/_services/core/api.service.d.ts.map +1 -1
- package/build/_services/core/api.service.js +18 -2
- package/build/_services/core/api.service.js.map +1 -1
- package/build/_services/server/app.server.d.ts.map +1 -1
- package/build/_services/server/app.server.js +8 -1
- package/build/_services/server/app.server.js.map +1 -1
- package/package.json +3 -3
- package/src/_models/control-models/app-params.control-model.ts +17 -0
- package/src/_modules/mock/data-model.mock.ts +2 -2
- package/src/_modules/mock/socket-client.mock.spec.ts +1 -1
- package/src/_modules/mock/socket-client.mock.ts +1 -1
- package/src/_modules/socket/_models/socket-client-service-params.control-model.spec.ts +1 -2
- package/src/_modules/socket/_models/socket-client-service-params.control-model.ts +2 -1
- package/src/_modules/socket/_services/socket-client.service.ts +7 -3
- package/src/_modules/socket/_services/socket-server.service.ts +271 -125
- package/src/_services/base/data.service.ts +216 -165
- package/src/_services/base/db.service.ts +86 -60
- package/src/_services/core/api.service.ts +23 -2
- package/src/_services/server/app.server.ts +13 -4
|
@@ -61,10 +61,16 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
61
61
|
dataList: T[] = [];
|
|
62
62
|
issuer: string;
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
readonly depSettings: {
|
|
65
|
+
key: string;
|
|
66
|
+
dbServiceKey: string;
|
|
67
|
+
keyIsUnique: boolean;
|
|
68
|
+
keyIsRequired: boolean;
|
|
69
|
+
}[] = [];
|
|
70
|
+
/* depKeys: string[] = [];
|
|
71
|
+
depDBServiceKeys: string[] = [];
|
|
72
|
+
depKeyIsUnique: boolean[] = [];
|
|
73
|
+
depKeyIsRequired: boolean[] = []; */
|
|
68
74
|
private depDataDBService: DyNTS_DBService<any>;
|
|
69
75
|
|
|
70
76
|
dataParams: DyFM_DataModel_Params<T>;
|
|
@@ -261,63 +267,98 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
261
267
|
});
|
|
262
268
|
}
|
|
263
269
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
270
|
+
|
|
271
|
+
private getDependencyIdsFilter(
|
|
272
|
+
dependencyIds?: string | { [key: string]: string }
|
|
273
|
+
): { [key: string]: string } {
|
|
274
|
+
if (!this.depSettings.length) {
|
|
275
|
+
throw new DyFM_Error({
|
|
276
|
+
...this._getDefaultErrorSettings(
|
|
277
|
+
'getDataByDependencyId',
|
|
278
|
+
new Error(
|
|
279
|
+
`getDataByDependencyId failed, dependencyKey is missing from service! ` +
|
|
280
|
+
`(${this.dataParams.dataName})`
|
|
281
|
+
)
|
|
282
|
+
),
|
|
283
|
+
|
|
284
|
+
errorCode: 'NTS-DS0-GD1',
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (typeof dependencyIds === 'string') {
|
|
289
|
+
if (this.depSettings.length === 1) {
|
|
290
|
+
dependencyIds = { [this.depSettings[0].key]: dependencyIds };
|
|
291
|
+
} else if (this.depSettings.length > 1) {
|
|
273
292
|
throw new DyFM_Error({
|
|
274
293
|
...this._getDefaultErrorSettings(
|
|
275
294
|
'getDataByDependencyId',
|
|
276
295
|
new Error(
|
|
277
|
-
`getDataByDependencyId failed,
|
|
296
|
+
`getDataByDependencyId failed, there are multiple dependencyKeys, ` +
|
|
297
|
+
`so you need to provide a map of dependencyKeys! ` +
|
|
278
298
|
`(${this.dataParams.dataName})`
|
|
279
299
|
)
|
|
280
300
|
),
|
|
281
|
-
|
|
282
|
-
errorCode: 'NTS-DS0-
|
|
301
|
+
|
|
302
|
+
errorCode: 'NTS-DS0-GD2',
|
|
283
303
|
});
|
|
284
304
|
}
|
|
305
|
+
} else if (!dependencyIds) {
|
|
306
|
+
dependencyIds = {};
|
|
307
|
+
this.depSettings.forEach((depSetting) => {
|
|
308
|
+
if (this.data?.[depSetting.key]) {
|
|
309
|
+
dependencyIds[depSetting.key] = this.data?.[depSetting.key];
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
}
|
|
285
313
|
|
|
286
|
-
|
|
287
|
-
|
|
314
|
+
if (
|
|
315
|
+
!dependencyIds ||
|
|
316
|
+
this.depSettings.every((depSetting) => !dependencyIds[depSetting.key])
|
|
317
|
+
) {
|
|
318
|
+
throw new DyFM_Error({
|
|
319
|
+
...this._getDefaultErrorSettings(
|
|
320
|
+
'getDataByDependencyId',
|
|
321
|
+
new Error(
|
|
322
|
+
`getDataByDependencyId failed, dependencyId is missing! ` +
|
|
323
|
+
`(${this.dataParams.dataName})`
|
|
324
|
+
)
|
|
325
|
+
),
|
|
288
326
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
'getDataByDependencyId',
|
|
293
|
-
new Error(
|
|
294
|
-
`getDataByDependencyId failed, "${this.depKey}" is missing! ` +
|
|
295
|
-
`(${this.dataParams.dataName})`
|
|
296
|
-
)
|
|
297
|
-
),
|
|
298
|
-
|
|
299
|
-
errorCode: 'NTS-DS0-GD2',
|
|
300
|
-
additionalContent: {
|
|
301
|
-
data: this.data,
|
|
302
|
-
},
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
}
|
|
327
|
+
errorCode: 'NTS-DS0-GD3',
|
|
328
|
+
});
|
|
329
|
+
}
|
|
306
330
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
331
|
+
return dependencyIds as { [key: string]: string };
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* returns data from database by dependencyId to the service
|
|
336
|
+
* (using id from service.data, if not provided)
|
|
337
|
+
* @param dependencyIds
|
|
338
|
+
*/
|
|
339
|
+
async getDataByDependencyId(
|
|
340
|
+
dependencyIds?: string | { [key: string]: string },
|
|
341
|
+
dontSetToService?: boolean
|
|
342
|
+
): Promise<T> {
|
|
343
|
+
try {
|
|
344
|
+
const dependencyIdsFilter: { [key: string]: string } =
|
|
345
|
+
this.getDependencyIdsFilter(dependencyIds);
|
|
346
|
+
|
|
347
|
+
const dataExists: T =
|
|
348
|
+
await this.dataDBService.getDataByDependencyId(dependencyIdsFilter).catch(
|
|
349
|
+
(error): null => {
|
|
350
|
+
if (error?.errorCode === 'NTS-DBS-GD2') {
|
|
351
|
+
DyFM_Log.warn(
|
|
352
|
+
`getDataByDependencyId failed; "${this.dataParams.dataName}" ` +
|
|
353
|
+
`(${JSON.stringify(dependencyIds)}) didn't found any.`
|
|
354
|
+
);
|
|
314
355
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
356
|
+
return null;
|
|
357
|
+
} else {
|
|
358
|
+
throw error;
|
|
359
|
+
}
|
|
318
360
|
}
|
|
319
|
-
|
|
320
|
-
);
|
|
361
|
+
);
|
|
321
362
|
|
|
322
363
|
if (!dontSetToService) {
|
|
323
364
|
this.data = dataExists;
|
|
@@ -339,10 +380,11 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
339
380
|
|
|
340
381
|
async getDataListByDependencyIds(
|
|
341
382
|
dependencyIds: string[],
|
|
342
|
-
dontSetToService?: boolean
|
|
383
|
+
dontSetToService?: boolean,
|
|
384
|
+
dependencyKey?: string,
|
|
343
385
|
): Promise<T[]> {
|
|
344
386
|
try {
|
|
345
|
-
if (!this.
|
|
387
|
+
if (!this.depSettings.length) {
|
|
346
388
|
throw new DyFM_Error({
|
|
347
389
|
...this._getDefaultErrorSettings(
|
|
348
390
|
'getDataListByDependencyIds',
|
|
@@ -356,6 +398,25 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
356
398
|
});
|
|
357
399
|
}
|
|
358
400
|
|
|
401
|
+
if (!dependencyKey) {
|
|
402
|
+
if (this.depSettings.length === 1) {
|
|
403
|
+
dependencyKey = this.depSettings[0].key;
|
|
404
|
+
} else {
|
|
405
|
+
throw new DyFM_Error({
|
|
406
|
+
...this._getDefaultErrorSettings(
|
|
407
|
+
'getDataListByDependencyIds',
|
|
408
|
+
new Error(
|
|
409
|
+
`getDataListByDependencyIds failed, dependencyKey is missing! ` +
|
|
410
|
+
`since there are multiple dependencyKeys, you need to provide one! ` +
|
|
411
|
+
`(${this.dataParams.dataName})`
|
|
412
|
+
)
|
|
413
|
+
),
|
|
414
|
+
|
|
415
|
+
errorCode: 'NTS-DS0-GDS2',
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
359
420
|
if (!dependencyIds) {
|
|
360
421
|
throw new DyFM_Error({
|
|
361
422
|
...this._getDefaultErrorSettings(
|
|
@@ -366,7 +427,7 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
366
427
|
)
|
|
367
428
|
),
|
|
368
429
|
|
|
369
|
-
errorCode: 'NTS-DS0-
|
|
430
|
+
errorCode: 'NTS-DS0-GDS3',
|
|
370
431
|
});
|
|
371
432
|
}
|
|
372
433
|
|
|
@@ -374,7 +435,9 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
374
435
|
return [];
|
|
375
436
|
}
|
|
376
437
|
|
|
377
|
-
const dataList: T[] = await this.dataDBService.getDataListByDependencyIds(
|
|
438
|
+
const dataList: T[] = await this.dataDBService.getDataListByDependencyIds(
|
|
439
|
+
dependencyKey, dependencyIds
|
|
440
|
+
);
|
|
378
441
|
|
|
379
442
|
if (!dontSetToService) {
|
|
380
443
|
this.dataList = dataList;
|
|
@@ -396,55 +459,31 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
396
459
|
|
|
397
460
|
/**
|
|
398
461
|
* returns dataList from database by dependencyId to the service
|
|
399
|
-
* @param
|
|
462
|
+
* @param dependencyIds
|
|
400
463
|
*/
|
|
401
|
-
async getDataListByDependencyId(
|
|
464
|
+
async getDataListByDependencyId(
|
|
465
|
+
dependencyIds?: string | { [key: string]: string },
|
|
466
|
+
dontSetToService?: boolean
|
|
467
|
+
): Promise<T[]> {
|
|
402
468
|
try {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
if (!dependencyId && !this.data[this.depKey]) {
|
|
418
|
-
throw new DyFM_Error({
|
|
419
|
-
...this._getDefaultErrorSettings(
|
|
420
|
-
'getDataListByDependencyId',
|
|
421
|
-
new Error(
|
|
422
|
-
`getDataListByDependencyId failed, "${this.depKey}" is missing! ` +
|
|
423
|
-
`(${this.dataParams.dataName})`
|
|
424
|
-
)
|
|
425
|
-
),
|
|
426
|
-
|
|
427
|
-
errorCode: 'NTS-DS0-GLD2',
|
|
428
|
-
additionalContent: {
|
|
429
|
-
data: this.data,
|
|
430
|
-
},
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
const dataListExists: T[] = await this.dataDBService.getDataListByDependencyId(
|
|
435
|
-
dependencyId ?? this.data[this.depKey]
|
|
436
|
-
).catch((error): T[] => {
|
|
437
|
-
if (error?.errorCode === 'NTS-DBS-GLD2') {
|
|
438
|
-
DyFM_Log.warn(
|
|
439
|
-
`getDataListByDependencyId "${this.dataParams.dataName}" ` +
|
|
440
|
-
`(${this.depKey}: "${dependencyId ?? this.data[this.depKey]}") didn't found any.`
|
|
441
|
-
);
|
|
469
|
+
const dependencyIdsFilter: { [key: string]: string } =
|
|
470
|
+
this.getDependencyIdsFilter(dependencyIds);
|
|
471
|
+
|
|
472
|
+
const dataListExists: T[] =
|
|
473
|
+
await this.dataDBService.getDataListByDependencyId(dependencyIdsFilter).catch(
|
|
474
|
+
(error): T[] => {
|
|
475
|
+
if (error?.errorCode === 'NTS-DBS-GLD2') {
|
|
476
|
+
DyFM_Log.warn(
|
|
477
|
+
`getDataListByDependencyId "${this.dataParams.dataName}" ` +
|
|
478
|
+
`(${JSON.stringify(dependencyIdsFilter)}) didn't found any.`
|
|
479
|
+
);
|
|
442
480
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
481
|
+
return [];
|
|
482
|
+
} else {
|
|
483
|
+
throw error;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
);
|
|
448
487
|
|
|
449
488
|
if (!dontSetToService) {
|
|
450
489
|
this.dataList = dataListExists;
|
|
@@ -654,9 +693,20 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
654
693
|
dontUpdateModified
|
|
655
694
|
);
|
|
656
695
|
|
|
657
|
-
} else if (
|
|
696
|
+
} else if (
|
|
697
|
+
this.depSettings.length &&
|
|
698
|
+
this.depSettings.some((depSetting) => this.data[depSetting.key])
|
|
699
|
+
) {
|
|
700
|
+
const dependencyIdsFilter: { [key: string]: string } = {};
|
|
701
|
+
|
|
702
|
+
this.depSettings.forEach((depSetting) => {
|
|
703
|
+
if (this.data[depSetting.key]) {
|
|
704
|
+
dependencyIdsFilter[depSetting.key] = this.data[depSetting.key];
|
|
705
|
+
}
|
|
706
|
+
});
|
|
707
|
+
|
|
658
708
|
await this.dataDBService.updateOne(
|
|
659
|
-
|
|
709
|
+
dependencyIdsFilter as DyFM_DBFilter<T>,
|
|
660
710
|
set.update,
|
|
661
711
|
this.issuer,
|
|
662
712
|
dontUpdateModified
|
|
@@ -729,13 +779,17 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
729
779
|
await this.validateForSave(data);
|
|
730
780
|
|
|
731
781
|
if (!data._id) {
|
|
732
|
-
if (
|
|
782
|
+
if (
|
|
783
|
+
this.depSettings.length &&
|
|
784
|
+
this.depSettings.some((depSetting) => !data[depSetting.key])
|
|
785
|
+
) {
|
|
733
786
|
throw new DyFM_Error({
|
|
734
787
|
...this._getDefaultErrorSettings(
|
|
735
788
|
'saveData',
|
|
736
789
|
new Error(
|
|
737
790
|
`saveData was unsuccessful: dependency data id missing from data ` +
|
|
738
|
-
`(key: ${this.
|
|
791
|
+
`(key: ${this.depSettings.map((depSetting) => depSetting.key).join(', ')}, ` +
|
|
792
|
+
`${this.dataParams.dataName})`
|
|
739
793
|
)
|
|
740
794
|
),
|
|
741
795
|
|
|
@@ -789,14 +843,15 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
789
843
|
return data;
|
|
790
844
|
}
|
|
791
845
|
|
|
792
|
-
if (this.
|
|
793
|
-
if (!data[
|
|
846
|
+
if (this.depSettings.length) {
|
|
847
|
+
if (this.depSettings.some((depSetting) => !data[depSetting.key])) {
|
|
794
848
|
throw new DyFM_Error({
|
|
795
849
|
...this._getDefaultErrorSettings(
|
|
796
850
|
'saveData',
|
|
797
851
|
new Error(
|
|
798
852
|
`saveData was unsuccessful: dependency data id missing from data ` +
|
|
799
|
-
`(key: ${this.
|
|
853
|
+
`(key: ${this.depSettings.map((depSetting) => depSetting.key).join(', ')}, ` +
|
|
854
|
+
`${this.dataParams.dataName})`
|
|
800
855
|
)
|
|
801
856
|
),
|
|
802
857
|
|
|
@@ -807,8 +862,51 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
807
862
|
});
|
|
808
863
|
}
|
|
809
864
|
|
|
865
|
+
if (this.depSettings.some((depSetting) => depSetting.keyIsRequired)) {
|
|
866
|
+
await DyFM_Array.asyncForEach(
|
|
867
|
+
this.depSettings,
|
|
868
|
+
async (depSetting) => {
|
|
869
|
+
if (depSetting.keyIsRequired) {
|
|
870
|
+
if (!data[depSetting.key]) {
|
|
871
|
+
throw new DyFM_Error({
|
|
872
|
+
...this._getDefaultErrorSettings(
|
|
873
|
+
'saveData',
|
|
874
|
+
new Error(
|
|
875
|
+
`saveData was unsuccessful: dependency data id missing from data ` +
|
|
876
|
+
`(key: ${depSetting.key}, ${this.dataParams.dataName})`
|
|
877
|
+
)
|
|
878
|
+
),
|
|
879
|
+
|
|
880
|
+
errorCode: 'NTS-DS0-SD4',
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
const dependencyExists = await this.getDependencyDataDBService(depSetting.dbServiceKey)
|
|
885
|
+
.getDataById(data[depSetting.key])
|
|
886
|
+
.catch();
|
|
887
|
+
|
|
888
|
+
if (!dependencyExists) {
|
|
889
|
+
throw new DyFM_Error({
|
|
890
|
+
...this._getDefaultErrorSettings(
|
|
891
|
+
'saveData',
|
|
892
|
+
new Error(
|
|
893
|
+
`saveData was unsuccessful: dependency data not exists ` +
|
|
894
|
+
`(key: ${depSetting.key}, id: "${data[depSetting.key]}", ` +
|
|
895
|
+
`${this.dataParams.dataName})`
|
|
896
|
+
)
|
|
897
|
+
),
|
|
898
|
+
|
|
899
|
+
errorCode: 'NTS-DS0-SD4',
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
);
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
/* the db is handling the unique key, so no need to check it here
|
|
810
908
|
if (this.depKeyIsUnique) {
|
|
811
|
-
dataExists = await this.getDataByDependencyId(data[this.
|
|
909
|
+
dataExists = await this.getDataByDependencyId(data[this.depKeys], true);
|
|
812
910
|
|
|
813
911
|
if (dataExists) {
|
|
814
912
|
// if data exists do modify
|
|
@@ -820,28 +918,8 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
820
918
|
|
|
821
919
|
return data;
|
|
822
920
|
|
|
823
|
-
} else if (this.depKeyIsRequired) {
|
|
824
|
-
// if data not exists check that dependency already exists for this
|
|
825
|
-
const dependencyExists = await this.getDependencyDataDBService()
|
|
826
|
-
.getDataById(data[this.depKey])
|
|
827
|
-
.catch();
|
|
828
|
-
|
|
829
|
-
if (!dependencyExists) {
|
|
830
|
-
throw new DyFM_Error({
|
|
831
|
-
...this._getDefaultErrorSettings(
|
|
832
|
-
'saveData',
|
|
833
|
-
new Error(
|
|
834
|
-
`saveData was unsuccessful: dependency data not exists ` +
|
|
835
|
-
`(key: ${this.depKey}, id: "${data[this.depKey]}", ` +
|
|
836
|
-
`${this.dataParams.dataName})`
|
|
837
|
-
)
|
|
838
|
-
),
|
|
839
|
-
|
|
840
|
-
errorCode: 'NTS-DS0-SD4',
|
|
841
|
-
});
|
|
842
|
-
}
|
|
843
921
|
}
|
|
844
|
-
}
|
|
922
|
+
} */
|
|
845
923
|
}
|
|
846
924
|
|
|
847
925
|
// if data not exists create new data
|
|
@@ -1785,59 +1863,32 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
1785
1863
|
* setting up dependency dataHook by DynamoBEDataModelParams
|
|
1786
1864
|
*/
|
|
1787
1865
|
private lookForDependencyDataSettings(): void {
|
|
1788
|
-
const
|
|
1789
|
-
Object.values(this.dataParams.properties).find(
|
|
1790
|
-
(modelParams: DyFM_DataProperty_Params<any>): boolean =>
|
|
1791
|
-
Boolean(modelParams.dependencyDataName)
|
|
1792
|
-
);
|
|
1793
|
-
|
|
1794
|
-
if (
|
|
1866
|
+
const dependencyParams: DyFM_DataProperty_Params<any>[] =
|
|
1795
1867
|
Object.values(this.dataParams.properties).filter(
|
|
1796
1868
|
(modelParams: DyFM_DataProperty_Params<any>): boolean =>
|
|
1797
1869
|
Boolean(modelParams.dependencyDataName)
|
|
1798
|
-
)
|
|
1799
|
-
) {
|
|
1800
|
-
throw new DyFM_Error({
|
|
1801
|
-
...this._getDefaultErrorSettings(
|
|
1802
|
-
'lookForDependencyDataSettings',
|
|
1803
|
-
new Error(
|
|
1804
|
-
`Multiple "dependencyDataName" found for this dataModel (${this.dataParams.dataName}) ` +
|
|
1805
|
-
`(NTS DataService)` +
|
|
1806
|
-
`\nSorry, but this is not supported yet! (Donate to Dynamo to get this feature!)`
|
|
1807
|
-
)
|
|
1808
|
-
),
|
|
1809
|
-
errorCode: 'NTS-DS0-LFDD0',
|
|
1810
|
-
});
|
|
1811
|
-
}
|
|
1812
|
-
|
|
1813
|
-
if (dependencyParam) {
|
|
1814
|
-
this.depKey = dependencyParam.key;
|
|
1815
|
-
|
|
1816
|
-
if (dependencyParam.dependencyDataName) {
|
|
1817
|
-
this.depDBServiceKey = dependencyParam.dependencyDataName;
|
|
1818
|
-
}
|
|
1819
|
-
|
|
1820
|
-
if (dependencyParam.unique) {
|
|
1821
|
-
this.depKeyIsUnique = true;
|
|
1822
|
-
}
|
|
1870
|
+
);
|
|
1823
1871
|
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1872
|
+
this.depSettings.push(...dependencyParams.map((dependencyParams) => ({
|
|
1873
|
+
key: dependencyParams.key,
|
|
1874
|
+
dbServiceKey: dependencyParams.dependencyDataName,
|
|
1875
|
+
keyIsUnique: dependencyParams.unique,
|
|
1876
|
+
keyIsRequired: dependencyParams.required,
|
|
1877
|
+
})));
|
|
1828
1878
|
}
|
|
1829
1879
|
|
|
1830
1880
|
/**
|
|
1831
1881
|
*
|
|
1832
1882
|
* @returns
|
|
1833
1883
|
*/
|
|
1834
|
-
getDependencyDataDBService(): DyNTS_DBService<any> {
|
|
1835
|
-
if (!
|
|
1884
|
+
getDependencyDataDBService(dBServiceKey: string): DyNTS_DBService<any> {
|
|
1885
|
+
if (!dBServiceKey) {
|
|
1836
1886
|
throw new DyFM_Error({
|
|
1837
1887
|
...this._getDefaultErrorSettings(
|
|
1838
1888
|
'getDependencyDataDBService',
|
|
1839
1889
|
new Error(
|
|
1840
1890
|
`getDependencyDataDBService was unsuccessful, service key not setted up! ` +
|
|
1891
|
+
`(key: ${this.depSettings.map((depSetting) => depSetting.key).join(', ')}, ` +
|
|
1841
1892
|
`(${this.dataParams.dataName})`
|
|
1842
1893
|
)
|
|
1843
1894
|
),
|
|
@@ -1850,7 +1901,7 @@ export class DyNTS_DataService<T extends DyFM_Metadata> {
|
|
|
1850
1901
|
if (this.depDataDBService) {
|
|
1851
1902
|
return this.depDataDBService;
|
|
1852
1903
|
} else {
|
|
1853
|
-
this.depDataDBService = DyNTS_GlobalService.getDBServiceByKey(
|
|
1904
|
+
this.depDataDBService = DyNTS_GlobalService.getDBServiceByKey(dBServiceKey);
|
|
1854
1905
|
|
|
1855
1906
|
return this.depDataDBService;
|
|
1856
1907
|
}
|