@futdevpro/nts-dynamo 1.10.9 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"app-params.control-model.d.ts","sourceRoot":"","sources":["../../../src/_models/control-models/app-params.control-model.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,qBAAa,gBAAgB;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;gBAG3B,GAAG,EAAE,gBAAgB;CAUxB"}
1
+ {"version":3,"file":"app-params.control-model.d.ts","sourceRoot":"","sources":["../../../src/_models/control-models/app-params.control-model.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,gBAAgB;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;gBAG3B,GAAG,EAAE,gBAAgB;CA0BxB"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DyNTS_App_Params = void 0;
4
+ const fsm_dynamo_1 = require("@futdevpro/fsm-dynamo");
4
5
  /**
5
6
  * This will hold and set the basic settings of an application
6
7
  */
@@ -45,6 +46,16 @@ class DyNTS_App_Params {
45
46
  this.dbUri = set.dbUri ?? `mongodb://localhost:27017/${this.dbName}`;
46
47
  this.systemName = set.systemName ?? this.name.replace(' ', '-');
47
48
  this.systemShortCodeName = set.systemShortCodeName ?? this.systemName.replace(/[^A-Z]/g, '');
49
+ if (RegExp(/[A-Z]/).exec(this.dbName)) {
50
+ fsm_dynamo_1.DyFM_Log.warn('DyNTS_App_Params.constructor: ' +
51
+ `dbName should be in snake_case in "${this.dbName}" model.` +
52
+ 'For future compatibility.');
53
+ }
54
+ if (this.dbName.includes('-')) {
55
+ fsm_dynamo_1.DyFM_Log.warn('DyNTS_App_Params.constructor: ' +
56
+ `dbName should not contain "-" in "${this.dbName}" model.` +
57
+ 'For future compatibility.');
58
+ }
48
59
  }
49
60
  }
50
61
  exports.DyNTS_App_Params = DyNTS_App_Params;
@@ -1 +1 @@
1
- {"version":3,"file":"app-params.control-model.js","sourceRoot":"","sources":["../../../src/_models/control-models/app-params.control-model.ts"],"names":[],"mappings":";;;AACA;;GAEG;AACH,MAAa,gBAAgB;IAC3B;;OAEG;IACH,IAAI,CAAS;IACb;;OAEG;IACH,KAAK,CAAU;IACf;;;;;OAKG;IACH,OAAO,CAAS;IAChB;;;OAGG;IACH,KAAK,CAAU;IACf;;OAEG;IACH,MAAM,CAAU;IAChB;;OAEG;IACH,UAAU,CAAU;IACpB;;OAEG;IACH,mBAAmB,CAAU;IAE7B,YACE,GAAqB;QAErB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,6BAA6B,IAAI,CAAC,MAAM,EAAE,CAAC;QACrE,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAChE,IAAI,CAAC,mBAAmB,GAAG,GAAG,CAAC,mBAAmB,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAC/F,CAAC;CACF;AA7CD,4CA6CC"}
1
+ {"version":3,"file":"app-params.control-model.js","sourceRoot":"","sources":["../../../src/_models/control-models/app-params.control-model.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AAEjD;;GAEG;AACH,MAAa,gBAAgB;IAC3B;;OAEG;IACH,IAAI,CAAS;IACb;;OAEG;IACH,KAAK,CAAU;IACf;;;;;OAKG;IACH,OAAO,CAAS;IAChB;;;OAGG;IACH,KAAK,CAAU;IACf;;OAEG;IACH,MAAM,CAAU;IAChB;;OAEG;IACH,UAAU,CAAU;IACpB;;OAEG;IACH,mBAAmB,CAAU;IAE7B,YACE,GAAqB;QAErB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,6BAA6B,IAAI,CAAC,MAAM,EAAE,CAAC;QACrE,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAChE,IAAI,CAAC,mBAAmB,GAAG,GAAG,CAAC,mBAAmB,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAE7F,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACtC,qBAAQ,CAAC,IAAI,CACX,gCAAgC;gBAChC,sCAAsC,IAAI,CAAC,MAAM,UAAU;gBAC3D,2BAA2B,CAC5B,CAAC;QACJ,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9B,qBAAQ,CAAC,IAAI,CACX,gCAAgC;gBAChC,qCAAqC,IAAI,CAAC,MAAM,UAAU;gBAC1D,2BAA2B,CAC5B,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA7DD,4CA6DC"}
@@ -28,10 +28,12 @@ export declare class DyNTS_DataService<T extends DyFM_Metadata> {
28
28
  data: T;
29
29
  dataList: T[];
30
30
  issuer: string;
31
- depKey?: string;
32
- depDBServiceKey?: string;
33
- depKeyIsUnique?: boolean;
34
- depKeyIsRequired?: boolean;
31
+ readonly depSettings: {
32
+ key: string;
33
+ dbServiceKey: string;
34
+ keyIsUnique: boolean;
35
+ keyIsRequired: boolean;
36
+ }[];
35
37
  private depDataDBService;
36
38
  dataParams: DyFM_DataModel_Params<T>;
37
39
  readonly defaultErrorUserMsg: string;
@@ -75,18 +77,23 @@ export declare class DyNTS_DataService<T extends DyFM_Metadata> {
75
77
  */
76
78
  getDataById(id?: string, dontSetToService?: boolean, skipArchiveLoad?: boolean): Promise<T>;
77
79
  getDataByIds(ids: string[], dontSetToService?: boolean): Promise<T[]>;
80
+ private getDependencyIdsFilter;
78
81
  /**
79
82
  * returns data from database by dependencyId to the service
80
83
  * (using id from service.data, if not provided)
81
- * @param dependencyId
84
+ * @param dependencyIds
82
85
  */
83
- getDataByDependencyId(dependencyId?: string, dontSetToService?: boolean): Promise<T>;
84
- getDataListByDependencyIds(dependencyIds: string[], dontSetToService?: boolean): Promise<T[]>;
86
+ getDataByDependencyId(dependencyIds?: string | {
87
+ [key: string]: string;
88
+ }, dontSetToService?: boolean): Promise<T>;
89
+ getDataListByDependencyIds(dependencyIds: string[], dontSetToService?: boolean, dependencyKey?: string): Promise<T[]>;
85
90
  /**
86
91
  * returns dataList from database by dependencyId to the service
87
- * @param dependencyId
92
+ * @param dependencyIds
88
93
  */
89
- getDataListByDependencyId(dependencyId?: string, dontSetToService?: boolean): Promise<T[]>;
94
+ getDataListByDependencyId(dependencyIds?: string | {
95
+ [key: string]: string;
96
+ }, dontSetToService?: boolean): Promise<T[]>;
90
97
  /**
91
98
  *
92
99
  * // findOne desc:
@@ -246,7 +253,7 @@ export declare class DyNTS_DataService<T extends DyFM_Metadata> {
246
253
  *
247
254
  * @returns
248
255
  */
249
- getDependencyDataDBService(): DyNTS_DBService<any>;
256
+ getDependencyDataDBService(dBServiceKey: string): DyNTS_DBService<any>;
250
257
  private _getDefaultErrorSettings;
251
258
  protected getDefaultErrorSettings(fnName: string, error: DyFM_AnyError): DyFM_Error_Settings;
252
259
  }
@@ -1 +1 @@
1
- {"version":3,"file":"data.service.d.ts","sourceRoot":"","sources":["../../../src/_services/base/data.service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAEb,uBAAuB,EACvB,gBAAgB,EAChB,qBAAqB,EAErB,aAAa,EAGb,YAAY,EAEZ,mBAAmB,EAGnB,aAAa,EAEb,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAI/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,iBAAiB,CAAC,CAAC,SAAS,aAAa;IAEpD,WAAW,EAAE,MAAM,CAAC;IAEpB,aAAa,E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C,GAAG,kBAAkB,CAAC,CAAC,CAAC,EACjE,YAAY,CAAC,EAAE,uBAAuB,GACrC,CAAC,YAAY,KAAA,KAAK,OAAO;IA6P5B,OAAO,CAAC,cAAc;IAoCtB,SAAS,CAAC,qBAAqB,CAAC,CAAC,EAAE,YAAY,EAAE,YAAY,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM;IAqMtF;;OAEG;IACH,OAAO,CAAC,6BAA6B;IAerC;;;OAGG;IACH,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,eAAe,CAAC,GAAG,CAAC;IA0BtE,OAAO,CAAC,wBAAwB;IAiBhC,SAAS,CAAC,uBAAuB,CAC/B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,aAAa,GACnB,mBAAmB;CAavB"}
@@ -32,10 +32,11 @@ class DyNTS_DataService {
32
32
  data;
33
33
  dataList = [];
34
34
  issuer;
35
- depKey;
36
- depDBServiceKey;
37
- depKeyIsUnique;
38
- depKeyIsRequired;
35
+ depSettings = [];
36
+ /* depKeys: string[] = [];
37
+ depDBServiceKeys: string[] = [];
38
+ depKeyIsUnique: boolean[] = [];
39
+ depKeyIsRequired: boolean[] = []; */
39
40
  depDataDBService;
40
41
  dataParams;
41
42
  defaultErrorUserMsg = `We encountered an unhandled Data Service Error, ` +
@@ -193,37 +194,57 @@ class DyNTS_DataService {
193
194
  });
194
195
  }
195
196
  }
196
- /**
197
- * returns data from database by dependencyId to the service
198
- * (using id from service.data, if not provided)
199
- * @param dependencyId
200
- */
201
- async getDataByDependencyId(dependencyId, dontSetToService) {
202
- try {
203
- if (!this.depKey) {
197
+ getDependencyIdsFilter(dependencyIds) {
198
+ if (!this.depSettings.length) {
199
+ throw new fsm_dynamo_1.DyFM_Error({
200
+ ...this._getDefaultErrorSettings('getDataByDependencyId', new Error(`getDataByDependencyId failed, dependencyKey is missing from service! ` +
201
+ `(${this.dataParams.dataName})`)),
202
+ errorCode: 'NTS-DS0-GD1',
203
+ });
204
+ }
205
+ if (typeof dependencyIds === 'string') {
206
+ if (this.depSettings.length === 1) {
207
+ dependencyIds = { [this.depSettings[0].key]: dependencyIds };
208
+ }
209
+ else if (this.depSettings.length > 1) {
204
210
  throw new fsm_dynamo_1.DyFM_Error({
205
- ...this._getDefaultErrorSettings('getDataByDependencyId', new Error(`getDataByDependencyId failed, dependencyKey is missing from service! ` +
211
+ ...this._getDefaultErrorSettings('getDataByDependencyId', new Error(`getDataByDependencyId failed, there are multiple dependencyKeys, ` +
212
+ `so you need to provide a map of dependencyKeys! ` +
206
213
  `(${this.dataParams.dataName})`)),
207
- errorCode: 'NTS-DS0-GD1',
214
+ errorCode: 'NTS-DS0-GD2',
208
215
  });
209
216
  }
210
- if (!dependencyId) {
211
- dependencyId = this.data?.[this.depKey];
212
- if (!dependencyId) {
213
- throw new fsm_dynamo_1.DyFM_Error({
214
- ...this._getDefaultErrorSettings('getDataByDependencyId', new Error(`getDataByDependencyId failed, "${this.depKey}" is missing! ` +
215
- `(${this.dataParams.dataName})`)),
216
- errorCode: 'NTS-DS0-GD2',
217
- additionalContent: {
218
- data: this.data,
219
- },
220
- });
217
+ }
218
+ else if (!dependencyIds) {
219
+ dependencyIds = {};
220
+ this.depSettings.forEach((depSetting) => {
221
+ if (this.data?.[depSetting.key]) {
222
+ dependencyIds[depSetting.key] = this.data?.[depSetting.key];
221
223
  }
222
- }
223
- const dataExists = await this.dataDBService.getDataByDependencyId(dependencyId).catch((error) => {
224
+ });
225
+ }
226
+ if (!dependencyIds ||
227
+ this.depSettings.every((depSetting) => !dependencyIds[depSetting.key])) {
228
+ throw new fsm_dynamo_1.DyFM_Error({
229
+ ...this._getDefaultErrorSettings('getDataByDependencyId', new Error(`getDataByDependencyId failed, dependencyId is missing! ` +
230
+ `(${this.dataParams.dataName})`)),
231
+ errorCode: 'NTS-DS0-GD3',
232
+ });
233
+ }
234
+ return dependencyIds;
235
+ }
236
+ /**
237
+ * returns data from database by dependencyId to the service
238
+ * (using id from service.data, if not provided)
239
+ * @param dependencyIds
240
+ */
241
+ async getDataByDependencyId(dependencyIds, dontSetToService) {
242
+ try {
243
+ const dependencyIdsFilter = this.getDependencyIdsFilter(dependencyIds);
244
+ const dataExists = await this.dataDBService.getDataByDependencyId(dependencyIdsFilter).catch((error) => {
224
245
  if (error?.errorCode === 'NTS-DBS-GD2') {
225
246
  fsm_dynamo_1.DyFM_Log.warn(`getDataByDependencyId failed; "${this.dataParams.dataName}" ` +
226
- `(${this.depKey}: ${dependencyId ?? this.data[this.depKey]}) didn't found any.`);
247
+ `(${JSON.stringify(dependencyIds)}) didn't found any.`);
227
248
  return null;
228
249
  }
229
250
  else {
@@ -247,26 +268,39 @@ class DyNTS_DataService {
247
268
  }
248
269
  }
249
270
  }
250
- async getDataListByDependencyIds(dependencyIds, dontSetToService) {
271
+ async getDataListByDependencyIds(dependencyIds, dontSetToService, dependencyKey) {
251
272
  try {
252
- if (!this.depKey) {
273
+ if (!this.depSettings.length) {
253
274
  throw new fsm_dynamo_1.DyFM_Error({
254
275
  ...this._getDefaultErrorSettings('getDataListByDependencyIds', new Error(`getDataListByDependencyIds failed, dependencyKey is missing from service! ` +
255
276
  `(${this.dataParams.dataName})`)),
256
277
  errorCode: 'NTS-DS0-GDS1',
257
278
  });
258
279
  }
280
+ if (!dependencyKey) {
281
+ if (this.depSettings.length === 1) {
282
+ dependencyKey = this.depSettings[0].key;
283
+ }
284
+ else {
285
+ throw new fsm_dynamo_1.DyFM_Error({
286
+ ...this._getDefaultErrorSettings('getDataListByDependencyIds', new Error(`getDataListByDependencyIds failed, dependencyKey is missing! ` +
287
+ `since there are multiple dependencyKeys, you need to provide one! ` +
288
+ `(${this.dataParams.dataName})`)),
289
+ errorCode: 'NTS-DS0-GDS2',
290
+ });
291
+ }
292
+ }
259
293
  if (!dependencyIds) {
260
294
  throw new fsm_dynamo_1.DyFM_Error({
261
295
  ...this._getDefaultErrorSettings('getDataListByDependencyIds', new Error(`getDataListByDependencyIds failed, dependencyIds is missing! ` +
262
296
  `(${this.dataParams.dataName})`)),
263
- errorCode: 'NTS-DS0-GDS2',
297
+ errorCode: 'NTS-DS0-GDS3',
264
298
  });
265
299
  }
266
300
  if (dependencyIds.length === 0) {
267
301
  return [];
268
302
  }
269
- const dataList = await this.dataDBService.getDataListByDependencyIds(dependencyIds);
303
+ const dataList = await this.dataDBService.getDataListByDependencyIds(dependencyKey, dependencyIds);
270
304
  if (!dontSetToService) {
271
305
  this.dataList = dataList;
272
306
  }
@@ -286,31 +320,15 @@ class DyNTS_DataService {
286
320
  }
287
321
  /**
288
322
  * returns dataList from database by dependencyId to the service
289
- * @param dependencyId
323
+ * @param dependencyIds
290
324
  */
291
- async getDataListByDependencyId(dependencyId, dontSetToService) {
325
+ async getDataListByDependencyId(dependencyIds, dontSetToService) {
292
326
  try {
293
- if (!this.depKey) {
294
- throw new fsm_dynamo_1.DyFM_Error({
295
- ...this._getDefaultErrorSettings('getDataListByDependencyId', new Error(`getDataListByDependencyId failed, dependencyKey is missing from service! ` +
296
- `(${this.dataParams.dataName})`)),
297
- errorCode: 'NTS-DS0-GLD1',
298
- });
299
- }
300
- if (!dependencyId && !this.data[this.depKey]) {
301
- throw new fsm_dynamo_1.DyFM_Error({
302
- ...this._getDefaultErrorSettings('getDataListByDependencyId', new Error(`getDataListByDependencyId failed, "${this.depKey}" is missing! ` +
303
- `(${this.dataParams.dataName})`)),
304
- errorCode: 'NTS-DS0-GLD2',
305
- additionalContent: {
306
- data: this.data,
307
- },
308
- });
309
- }
310
- const dataListExists = await this.dataDBService.getDataListByDependencyId(dependencyId ?? this.data[this.depKey]).catch((error) => {
327
+ const dependencyIdsFilter = this.getDependencyIdsFilter(dependencyIds);
328
+ const dataListExists = await this.dataDBService.getDataListByDependencyId(dependencyIdsFilter).catch((error) => {
311
329
  if (error?.errorCode === 'NTS-DBS-GLD2') {
312
330
  fsm_dynamo_1.DyFM_Log.warn(`getDataListByDependencyId "${this.dataParams.dataName}" ` +
313
- `(${this.depKey}: "${dependencyId ?? this.data[this.depKey]}") didn't found any.`);
331
+ `(${JSON.stringify(dependencyIdsFilter)}) didn't found any.`);
314
332
  return [];
315
333
  }
316
334
  else {
@@ -504,8 +522,15 @@ class DyNTS_DataService {
504
522
  else if (this.data._id) {
505
523
  await this.dataDBService.updateOne({ _id: this.data._id }, set.update, this.issuer, dontUpdateModified);
506
524
  }
507
- else if (this.depKey && this.data[this.depKey]) {
508
- await this.dataDBService.updateOne({ [this.depKey]: this.data[this.depKey] }, set.update, this.issuer, dontUpdateModified);
525
+ else if (this.depSettings.length &&
526
+ this.depSettings.some((depSetting) => this.data[depSetting.key])) {
527
+ const dependencyIdsFilter = {};
528
+ this.depSettings.forEach((depSetting) => {
529
+ if (this.data[depSetting.key]) {
530
+ dependencyIdsFilter[depSetting.key] = this.data[depSetting.key];
531
+ }
532
+ });
533
+ await this.dataDBService.updateOne(dependencyIdsFilter, set.update, this.issuer, dontUpdateModified);
509
534
  }
510
535
  else {
511
536
  throw new fsm_dynamo_1.DyFM_Error({
@@ -559,10 +584,12 @@ class DyNTS_DataService {
559
584
  data = this.ensureData(data);
560
585
  await this.validateForSave(data);
561
586
  if (!data._id) {
562
- if (this.depKey && !data[this.depKey]) {
587
+ if (this.depSettings.length &&
588
+ this.depSettings.some((depSetting) => !data[depSetting.key])) {
563
589
  throw new fsm_dynamo_1.DyFM_Error({
564
590
  ...this._getDefaultErrorSettings('saveData', new Error(`saveData was unsuccessful: dependency data id missing from data ` +
565
- `(key: ${this.depKey}, ${this.dataParams.dataName})`)),
591
+ `(key: ${this.depSettings.map((depSetting) => depSetting.key).join(', ')}, ` +
592
+ `${this.dataParams.dataName})`)),
566
593
  errorCode: 'NTS-DS0-SD1',
567
594
  additionalContent: {
568
595
  data: data,
@@ -597,42 +624,58 @@ class DyNTS_DataService {
597
624
  }
598
625
  return data;
599
626
  }
600
- if (this.depKey) {
601
- if (!data[this.depKey]) {
627
+ if (this.depSettings.length) {
628
+ if (this.depSettings.some((depSetting) => !data[depSetting.key])) {
602
629
  throw new fsm_dynamo_1.DyFM_Error({
603
630
  ...this._getDefaultErrorSettings('saveData', new Error(`saveData was unsuccessful: dependency data id missing from data ` +
604
- `(key: ${this.depKey}, ${this.dataParams.dataName})`)),
631
+ `(key: ${this.depSettings.map((depSetting) => depSetting.key).join(', ')}, ` +
632
+ `${this.dataParams.dataName})`)),
605
633
  errorCode: 'NTS-DS0-SD3',
606
634
  additionalContent: {
607
635
  data: data,
608
636
  },
609
637
  });
610
638
  }
611
- if (this.depKeyIsUnique) {
612
- dataExists = await this.getDataByDependencyId(data[this.depKey], true);
613
- if (dataExists) {
614
- // if data exists do modify
615
- data = await this.dataDBService.modifyData(data, this.issuer, dontUpdateModified);
616
- if (!dontSetToService) {
617
- this.data = data;
618
- }
619
- return data;
620
- }
621
- else if (this.depKeyIsRequired) {
622
- // if data not exists check that dependency already exists for this
623
- const dependencyExists = await this.getDependencyDataDBService()
624
- .getDataById(data[this.depKey])
625
- .catch();
626
- if (!dependencyExists) {
627
- throw new fsm_dynamo_1.DyFM_Error({
628
- ...this._getDefaultErrorSettings('saveData', new Error(`saveData was unsuccessful: dependency data not exists ` +
629
- `(key: ${this.depKey}, id: "${data[this.depKey]}", ` +
630
- `${this.dataParams.dataName})`)),
631
- errorCode: 'NTS-DS0-SD4',
632
- });
639
+ if (this.depSettings.some((depSetting) => depSetting.keyIsRequired)) {
640
+ await fsm_dynamo_1.DyFM_Array.asyncForEach(this.depSettings, async (depSetting) => {
641
+ if (depSetting.keyIsRequired) {
642
+ if (!data[depSetting.key]) {
643
+ throw new fsm_dynamo_1.DyFM_Error({
644
+ ...this._getDefaultErrorSettings('saveData', new Error(`saveData was unsuccessful: dependency data id missing from data ` +
645
+ `(key: ${depSetting.key}, ${this.dataParams.dataName})`)),
646
+ errorCode: 'NTS-DS0-SD4',
647
+ });
648
+ }
649
+ const dependencyExists = await this.getDependencyDataDBService(depSetting.dbServiceKey)
650
+ .getDataById(data[depSetting.key])
651
+ .catch();
652
+ if (!dependencyExists) {
653
+ throw new fsm_dynamo_1.DyFM_Error({
654
+ ...this._getDefaultErrorSettings('saveData', new Error(`saveData was unsuccessful: dependency data not exists ` +
655
+ `(key: ${depSetting.key}, id: "${data[depSetting.key]}", ` +
656
+ `${this.dataParams.dataName})`)),
657
+ errorCode: 'NTS-DS0-SD4',
658
+ });
659
+ }
633
660
  }
634
- }
661
+ });
635
662
  }
663
+ /* the db is handling the unique key, so no need to check it here
664
+ if (this.depKeyIsUnique) {
665
+ dataExists = await this.getDataByDependencyId(data[this.depKeys], true);
666
+
667
+ if (dataExists) {
668
+ // if data exists do modify
669
+ data = await this.dataDBService.modifyData(data, this.issuer, dontUpdateModified);
670
+
671
+ if (!dontSetToService) {
672
+ this.data = data;
673
+ }
674
+
675
+ return data;
676
+
677
+ }
678
+ } */
636
679
  }
637
680
  // if data not exists create new data
638
681
  data = await this.dataDBService.createData(data, this.issuer);
@@ -1311,36 +1354,23 @@ class DyNTS_DataService {
1311
1354
  * setting up dependency dataHook by DynamoBEDataModelParams
1312
1355
  */
1313
1356
  lookForDependencyDataSettings() {
1314
- const dependencyParam = Object.values(this.dataParams.properties).find((modelParams) => Boolean(modelParams.dependencyDataName));
1315
- if (Object.values(this.dataParams.properties).filter((modelParams) => Boolean(modelParams.dependencyDataName)).length > 1) {
1316
- throw new fsm_dynamo_1.DyFM_Error({
1317
- ...this._getDefaultErrorSettings('lookForDependencyDataSettings', new Error(`Multiple "dependencyDataName" found for this dataModel (${this.dataParams.dataName}) ` +
1318
- `(NTS DataService)` +
1319
- `\nSorry, but this is not supported yet! (Donate to Dynamo to get this feature!)`)),
1320
- errorCode: 'NTS-DS0-LFDD0',
1321
- });
1322
- }
1323
- if (dependencyParam) {
1324
- this.depKey = dependencyParam.key;
1325
- if (dependencyParam.dependencyDataName) {
1326
- this.depDBServiceKey = dependencyParam.dependencyDataName;
1327
- }
1328
- if (dependencyParam.unique) {
1329
- this.depKeyIsUnique = true;
1330
- }
1331
- if (dependencyParam.required) {
1332
- this.depKeyIsRequired = true;
1333
- }
1334
- }
1357
+ const dependencyParams = Object.values(this.dataParams.properties).filter((modelParams) => Boolean(modelParams.dependencyDataName));
1358
+ this.depSettings.push(...dependencyParams.map((dependencyParams) => ({
1359
+ key: dependencyParams.key,
1360
+ dbServiceKey: dependencyParams.dependencyDataName,
1361
+ keyIsUnique: dependencyParams.unique,
1362
+ keyIsRequired: dependencyParams.required,
1363
+ })));
1335
1364
  }
1336
1365
  /**
1337
1366
  *
1338
1367
  * @returns
1339
1368
  */
1340
- getDependencyDataDBService() {
1341
- if (!this.depDBServiceKey) {
1369
+ getDependencyDataDBService(dBServiceKey) {
1370
+ if (!dBServiceKey) {
1342
1371
  throw new fsm_dynamo_1.DyFM_Error({
1343
1372
  ...this._getDefaultErrorSettings('getDependencyDataDBService', new Error(`getDependencyDataDBService was unsuccessful, service key not setted up! ` +
1373
+ `(key: ${this.depSettings.map((depSetting) => depSetting.key).join(', ')}, ` +
1344
1374
  `(${this.dataParams.dataName})`)),
1345
1375
  status: 500,
1346
1376
  errorCode: 'NTS-DS0-GDDB0',
@@ -1350,7 +1380,7 @@ class DyNTS_DataService {
1350
1380
  return this.depDataDBService;
1351
1381
  }
1352
1382
  else {
1353
- this.depDataDBService = global_service_1.DyNTS_GlobalService.getDBServiceByKey(this.depDBServiceKey);
1383
+ this.depDataDBService = global_service_1.DyNTS_GlobalService.getDBServiceByKey(dBServiceKey);
1354
1384
  return this.depDataDBService;
1355
1385
  }
1356
1386
  }