@futdevpro/nts-dynamo 1.5.50 → 1.5.52

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.
Files changed (167) hide show
  1. package/lib/_models/dynamo-nts-endpoint-params.js +3 -2
  2. package/lib/_models/dynamo-nts-endpoint-params.js.map +1 -1
  3. package/lib/_services/dynamo-nts-api.service.d.ts +1 -0
  4. package/lib/_services/dynamo-nts-api.service.d.ts.map +1 -1
  5. package/lib/_services/dynamo-nts-api.service.js +6 -5
  6. package/lib/_services/dynamo-nts-api.service.js.map +1 -1
  7. package/lib/_services/dynamo-nts-app-extended.d.ts +87 -7
  8. package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -1
  9. package/lib/_services/dynamo-nts-app-extended.js +87 -7
  10. package/lib/_services/dynamo-nts-app-extended.js.map +1 -1
  11. package/lib/_services/dynamo-nts-app.d.ts +131 -22
  12. package/lib/_services/dynamo-nts-app.d.ts.map +1 -1
  13. package/lib/_services/dynamo-nts-app.js +104 -1
  14. package/lib/_services/dynamo-nts-app.js.map +1 -1
  15. package/lib/_services/dynamo-nts-auth.service.d.ts +79 -5
  16. package/lib/_services/dynamo-nts-auth.service.d.ts.map +1 -1
  17. package/lib/_services/dynamo-nts-auth.service.js +3 -2
  18. package/lib/_services/dynamo-nts-auth.service.js.map +1 -1
  19. package/lib/_services/dynamo-nts-data.service.d.ts +25 -1
  20. package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -1
  21. package/lib/_services/dynamo-nts-data.service.js +98 -70
  22. package/lib/_services/dynamo-nts-data.service.js.map +1 -1
  23. package/lib/_services/dynamo-nts-db.service.d.ts +165 -119
  24. package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -1
  25. package/lib/_services/dynamo-nts-db.service.js +348 -293
  26. package/lib/_services/dynamo-nts-db.service.js.map +1 -1
  27. package/lib/_services/dynamo-nts-email.service.d.ts +1 -0
  28. package/lib/_services/dynamo-nts-email.service.d.ts.map +1 -1
  29. package/lib/_services/dynamo-nts-email.service.js +5 -4
  30. package/lib/_services/dynamo-nts-email.service.js.map +1 -1
  31. package/lib/_services/dynamo-nts-routing-module.service.d.ts +40 -0
  32. package/lib/_services/dynamo-nts-routing-module.service.d.ts.map +1 -1
  33. package/lib/_services/dynamo-nts-routing-module.service.js +43 -3
  34. package/lib/_services/dynamo-nts-routing-module.service.js.map +1 -1
  35. package/lib/_services/dynamo-nts-socket.service.d.ts +1 -0
  36. package/lib/_services/dynamo-nts-socket.service.d.ts.map +1 -1
  37. package/lib/_services/dynamo-nts-socket.service.js +6 -2
  38. package/lib/_services/dynamo-nts-socket.service.js.map +1 -1
  39. package/lib/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +16 -12
  41. package/src/_models/dynamo-nts-endpoint-params.ts +2 -2
  42. package/src/_services/dynamo-nts-api.service.ts +7 -5
  43. package/src/_services/dynamo-nts-app-extended.ts +87 -7
  44. package/src/_services/dynamo-nts-app.ts +131 -22
  45. package/src/_services/dynamo-nts-auth.service.ts +83 -7
  46. package/src/_services/dynamo-nts-data.service.ts +100 -71
  47. package/src/_services/dynamo-nts-db.service.ts +377 -297
  48. package/src/_services/dynamo-nts-email.service.ts +6 -4
  49. package/src/_services/dynamo-nts-routing-module.service.ts +44 -3
  50. package/src/_services/dynamo-nts-socket.service.ts +13 -7
  51. package/futdevpro-nts-dynamo-01.05.40.tgz +0 -0
  52. package/futdevpro-nts-dynamo-01.05.41.tgz +0 -0
  53. package/futdevpro-nts-dynamo-01.05.42.tgz +0 -0
  54. package/futdevpro-nts-dynamo-01.05.43.tgz +0 -0
  55. package/futdevpro-nts-dynamo-01.05.44.tgz +0 -0
  56. package/futdevpro-nts-dynamo-01.05.45.tgz +0 -0
  57. package/futdevpro-nts-dynamo-01.05.47.tgz +0 -0
  58. package/futdevpro-nts-dynamo-01.05.49.tgz +0 -0
  59. package/futdevpro-nts-dynamo-01.05.50.tgz +0 -0
  60. package/lib/_constants/dynamo-nts-global.settings.d.ts +0 -3
  61. package/lib/_constants/dynamo-nts-global.settings.d.ts.map +0 -1
  62. package/lib/_constants/dynamo-nts-global.settings.js +0 -18
  63. package/lib/_constants/dynamo-nts-global.settings.js.map +0 -1
  64. package/lib/_constants/dynamobe-global.settings.d.ts +0 -3
  65. package/lib/_constants/dynamobe-global.settings.d.ts.map +0 -1
  66. package/lib/_constants/dynamobe-global.settings.js +0 -13
  67. package/lib/_constants/dynamobe-global.settings.js.map +0 -1
  68. package/lib/_enums/dynamobe-data-service-function.enum.d.ts +0 -8
  69. package/lib/_enums/dynamobe-data-service-function.enum.d.ts.map +0 -1
  70. package/lib/_enums/dynamobe-data-service-function.enum.js +0 -15
  71. package/lib/_enums/dynamobe-data-service-function.enum.js.map +0 -1
  72. package/lib/_enums/dynamobe-route-security.enum.d.ts +0 -6
  73. package/lib/_enums/dynamobe-route-security.enum.d.ts.map +0 -1
  74. package/lib/_enums/dynamobe-route-security.enum.js +0 -10
  75. package/lib/_enums/dynamobe-route-security.enum.js.map +0 -1
  76. package/lib/_enums/log-style.enum.d.ts +0 -26
  77. package/lib/_enums/log-style.enum.d.ts.map +0 -1
  78. package/lib/_enums/log-style.enum.js +0 -30
  79. package/lib/_enums/log-style.enum.js.map +0 -1
  80. package/lib/_models/dynamo-module-settings.d.ts +0 -4
  81. package/lib/_models/dynamo-module-settings.d.ts.map +0 -1
  82. package/lib/_models/dynamo-module-settings.js +0 -10
  83. package/lib/_models/dynamo-module-settings.js.map +0 -1
  84. package/lib/_models/dynamo-nts-socket-module-settings.d.ts +0 -19
  85. package/lib/_models/dynamo-nts-socket-module-settings.d.ts.map +0 -1
  86. package/lib/_models/dynamo-nts-socket-module-settings.js +0 -27
  87. package/lib/_models/dynamo-nts-socket-module-settings.js.map +0 -1
  88. package/lib/_models/dynamobe-api-call-params.d.ts +0 -37
  89. package/lib/_models/dynamobe-api-call-params.d.ts.map +0 -1
  90. package/lib/_models/dynamobe-api-call-params.js +0 -29
  91. package/lib/_models/dynamobe-api-call-params.js.map +0 -1
  92. package/lib/_models/dynamobe-app-params.d.ts +0 -18
  93. package/lib/_models/dynamobe-app-params.d.ts.map +0 -1
  94. package/lib/_models/dynamobe-app-params.js +0 -17
  95. package/lib/_models/dynamobe-app-params.js.map +0 -1
  96. package/lib/_models/dynamobe-data-model-params.d.ts +0 -1
  97. package/lib/_models/dynamobe-data-model-params.d.ts.map +0 -1
  98. package/lib/_models/dynamobe-data-model-params.js +0 -25
  99. package/lib/_models/dynamobe-data-model-params.js.map +0 -1
  100. package/lib/_models/dynamobe-endpoint-params.d.ts +0 -46
  101. package/lib/_models/dynamobe-endpoint-params.d.ts.map +0 -1
  102. package/lib/_models/dynamobe-endpoint-params.js +0 -117
  103. package/lib/_models/dynamobe-endpoint-params.js.map +0 -1
  104. package/lib/_models/dynamobe-global-settings.d.ts +0 -13
  105. package/lib/_models/dynamobe-global-settings.d.ts.map +0 -1
  106. package/lib/_models/dynamobe-global-settings.js +0 -3
  107. package/lib/_models/dynamobe-global-settings.js.map +0 -1
  108. package/lib/_modules/data-models.index.d.ts +0 -3
  109. package/lib/_modules/data-models.index.d.ts.map +0 -1
  110. package/lib/_modules/data-models.index.js +0 -6
  111. package/lib/_modules/data-models.index.js.map +0 -1
  112. package/lib/_services/dynamobe-api.service.d.ts +0 -19
  113. package/lib/_services/dynamobe-api.service.d.ts.map +0 -1
  114. package/lib/_services/dynamobe-api.service.js +0 -167
  115. package/lib/_services/dynamobe-api.service.js.map +0 -1
  116. package/lib/_services/dynamobe-app.d.ts +0 -129
  117. package/lib/_services/dynamobe-app.d.ts.map +0 -1
  118. package/lib/_services/dynamobe-app.js +0 -238
  119. package/lib/_services/dynamobe-app.js.map +0 -1
  120. package/lib/_services/dynamobe-auth.service.d.ts +0 -54
  121. package/lib/_services/dynamobe-auth.service.d.ts.map +0 -1
  122. package/lib/_services/dynamobe-auth.service.js +0 -46
  123. package/lib/_services/dynamobe-auth.service.js.map +0 -1
  124. package/lib/_services/dynamobe-controller.service.d.ts +0 -14
  125. package/lib/_services/dynamobe-controller.service.d.ts.map +0 -1
  126. package/lib/_services/dynamobe-controller.service.js +0 -21
  127. package/lib/_services/dynamobe-controller.service.js.map +0 -1
  128. package/lib/_services/dynamobe-data.service.d.ts +0 -54
  129. package/lib/_services/dynamobe-data.service.d.ts.map +0 -1
  130. package/lib/_services/dynamobe-data.service.js +0 -301
  131. package/lib/_services/dynamobe-data.service.js.map +0 -1
  132. package/lib/_services/dynamobe-db-service-collection.service.d.ts +0 -9
  133. package/lib/_services/dynamobe-db-service-collection.service.d.ts.map +0 -1
  134. package/lib/_services/dynamobe-db-service-collection.service.js +0 -11
  135. package/lib/_services/dynamobe-db-service-collection.service.js.map +0 -1
  136. package/lib/_services/dynamobe-db.service.d.ts +0 -244
  137. package/lib/_services/dynamobe-db.service.d.ts.map +0 -1
  138. package/lib/_services/dynamobe-db.service.js +0 -759
  139. package/lib/_services/dynamobe-db.service.js.map +0 -1
  140. package/lib/_services/dynamobe-email-service-collection.service.d.ts +0 -19
  141. package/lib/_services/dynamobe-email-service-collection.service.d.ts.map +0 -1
  142. package/lib/_services/dynamobe-email-service-collection.service.js +0 -21
  143. package/lib/_services/dynamobe-email-service-collection.service.js.map +0 -1
  144. package/lib/_services/dynamobe-email.service.d.ts +0 -56
  145. package/lib/_services/dynamobe-email.service.d.ts.map +0 -1
  146. package/lib/_services/dynamobe-email.service.js +0 -194
  147. package/lib/_services/dynamobe-email.service.js.map +0 -1
  148. package/lib/_services/dynamobe-global.service.d.ts +0 -62
  149. package/lib/_services/dynamobe-global.service.d.ts.map +0 -1
  150. package/lib/_services/dynamobe-global.service.js +0 -107
  151. package/lib/_services/dynamobe-global.service.js.map +0 -1
  152. package/lib/_services/dynamobe-routing-module.service.d.ts +0 -42
  153. package/lib/_services/dynamobe-routing-module.service.d.ts.map +0 -1
  154. package/lib/_services/dynamobe-routing-module.service.js +0 -146
  155. package/lib/_services/dynamobe-routing-module.service.js.map +0 -1
  156. package/lib/_services/dynamobe-shared-be.service.d.ts +0 -8
  157. package/lib/_services/dynamobe-shared-be.service.d.ts.map +0 -1
  158. package/lib/_services/dynamobe-shared-be.service.js +0 -45
  159. package/lib/_services/dynamobe-shared-be.service.js.map +0 -1
  160. package/lib/_services/dynamobe-shared.service.d.ts +0 -26
  161. package/lib/_services/dynamobe-shared.service.d.ts.map +0 -1
  162. package/lib/_services/dynamobe-shared.service.js +0 -63
  163. package/lib/_services/dynamobe-shared.service.js.map +0 -1
  164. package/lib/_services/dynamobe-singleton.service.d.ts +0 -9
  165. package/lib/_services/dynamobe-singleton.service.d.ts.map +0 -1
  166. package/lib/_services/dynamobe-singleton.service.js +0 -19
  167. package/lib/_services/dynamobe-singleton.service.js.map +0 -1
@@ -31,10 +31,14 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
31
31
 
32
32
  depKey?: string;
33
33
  depDBServiceKey?: string;
34
+ private depDataDBService: DynamoNTS_DBService<any>;
34
35
 
35
36
  // dataModelParams?: DynamoBEDataPropertyParams[] = [];
36
37
  dataParams: DynamoNTS_DataParams;
37
38
 
39
+ defaultErrorUserMsg = 'We encountered an unhandled Data Error, please contact the responsible development team.';
40
+ defaultValidationErrorUserMsg = `We encountered an unhandled Validation Error, please contact the responsible development team.`;
41
+
38
42
  constructor(
39
43
  data: T,
40
44
  dataParams: DynamoNTS_DataParams,
@@ -53,42 +57,49 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
53
57
  */
54
58
  async getAll(): Promise<void> {
55
59
  try {
56
- await this.dataDBService.getAll().then((dataList: T[]) => {
57
- this.dataList = dataList;
58
- });
60
+ this.dataList = await this.dataDBService.getAll();
59
61
  } catch (error) {
60
62
  throw new Dynamo_Error({
61
63
  status: 417,
62
64
  errorCode: 'NTS-DS0-GA0',
63
65
  addECToUserMsg: true,
64
- message: 'getAll was unsuccessful',
65
- userMessage: `We encountered an unhandled Data Error, please contact the responsible development team.`,
66
+ message: `getAll was unsuccessful (${this.dataParams.dataName})`,
67
+ userMessage: this.defaultErrorUserMsg,
66
68
  error: error
67
69
  });
68
70
  }
69
71
  }
70
72
 
71
73
  /**
74
+ * @description
72
75
  * returns data from database by id
76
+ * also if dontSetToService is false or not setted,
77
+ * the data will be saved to the service
78
+ *
79
+ * @remarks
80
+ * If you need to get-save a data, if possible,
81
+ * use db-service update instead.
82
+ *
83
+ * @param {string} id
84
+ * @param dontSetToService
85
+ *
86
+ * @return {T} data: T
73
87
  */
74
88
  async getDataById(id?: string, dontSetToService?: boolean): Promise<T> {
75
89
  try {
76
90
  if (id || this.data._id) {
77
- let dataExists: T;
78
- await this.dataDBService.getDataById(id ? id : this.data._id).then((data: T) => {
79
- if (!dontSetToService) {
80
- this.data = data;
81
- }
82
- dataExists = data;
83
- });
91
+ let dataExists: T = await this.dataDBService.getDataById(id ? id : this.data._id);
92
+ if (!dontSetToService && dataExists) {
93
+ this.data = dataExists;
94
+ }
84
95
  return dataExists;
85
96
  } else {
86
97
  throw new Dynamo_Error({
87
98
  status: 417,
88
99
  errorCode: 'NTS-DS0-GI1',
89
100
  addECToUserMsg: true,
90
- message: `ID is missing! (maybe you wanted to use getDataByDependencyId instead...)`,
91
- userMessage: `We encountered an unhandled Data Error, please contact the responsible development team.`
101
+ message: `ID is missing! (maybe you wanted to use getDataByDependencyId() instead...) (${this.dataParams.dataName})`,
102
+ userMessage: this.defaultErrorUserMsg
92
103
  });
93
104
  }
94
105
  } catch (error) {
@@ -96,8 +107,8 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
96
107
  status: 417,
97
108
  errorCode: 'NTS-DS0-GI0',
98
109
  addECToUserMsg: true,
99
- message: 'getDataById was unsuccessful',
100
- userMessage: `We encountered an unhandled Data Error, please contact the responsible development team.`,
110
+ message: `getDataById was unsuccessful (${this.dataParams.dataName})`,
111
+ userMessage: this.defaultErrorUserMsg,
101
112
  error: error
102
113
  });
103
114
  }
@@ -111,21 +122,18 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
111
122
  try {
112
123
  if (this.depKey) {
113
124
  if (dependencyId || this.data[this.depKey]) {
114
- let dataExists: T;
115
- await this.dataDBService.getDataByDependencyId(dependencyId ? dependencyId : this.data[this.depKey]).then((data: T) => {
116
- if (!dontSetToService) {
117
- this.data = data;
118
- }
119
- dataExists = data;
120
- });
125
+ let dataExists: T = await this.dataDBService.getDataByDependencyId(dependencyId ? dependencyId : this.data[this.depKey]);
126
+ if (!dontSetToService && dataExists) {
127
+ this.data = dataExists;
128
+ }
121
129
  return dataExists;
122
130
  } else {
123
131
  throw new Dynamo_Error({
124
132
  status: 417,
125
133
  errorCode: 'NTS-DS0-GD3',
126
134
  addECToUserMsg: true,
127
- message: `${this.depKey} is missing!`,
128
- userMessage: `We encountered an unhandled Data Error, please contact the responsible development team.`
135
+ message: `${this.depKey} is missing! (${this.dataParams.dataName})`,
136
+ userMessage: this.defaultErrorUserMsg
129
137
  });
130
138
  }
131
139
  } else {
@@ -133,8 +141,8 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
133
141
  status: 417,
134
142
  errorCode: 'NTS-DS0-GD2',
135
143
  addECToUserMsg: true,
136
- message: 'dependencyDataIdKey is missing from service!',
137
- userMessage: `We encountered an unhandled Data Error, please contact the responsible development team.`
144
+ message: `'dependencyDataIdKey is missing from service! (${this.dataParams.dataName})`,
145
+ userMessage: this.defaultErrorUserMsg
138
146
  });
139
147
  }
140
148
  } catch (error) {
@@ -142,8 +150,8 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
142
150
  status: 417,
143
151
  errorCode: 'NTS-DS0-GD0',
144
152
  addECToUserMsg: true,
145
- message: 'getDataByDependencyId was unsuccessful',
146
- userMessage: `We encountered an unhandled Data Error, please contact the responsible development team.`,
153
+ message: `getDataByDependencyId was unsuccessful (${this.dataParams.dataName})`,
154
+ userMessage: this.defaultErrorUserMsg,
147
155
  error: error
148
156
  });
149
157
  }
@@ -157,16 +165,14 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
157
165
  try {
158
166
  if (this.depKey) {
159
167
  if (dependencyId || this.data[this.depKey]) {
160
- await this.dataDBService.getDataListByDependencyId(dependencyId ? dependencyId : this.data[this.depKey]).then((data: T[]) => {
161
- this.dataList = data;
162
- });
168
+ this.dataList = await this.dataDBService.getDataListByDependencyId(dependencyId ? dependencyId : this.data[this.depKey]);
163
169
  } else {
164
170
  throw new Dynamo_Error({
165
171
  status: 417,
166
172
  errorCode: 'NTS-DS0-GLD3',
167
173
  addECToUserMsg: true,
168
- message: `${this.depKey} is missing!`,
169
- userMessage: `We encountered an unhandled Data Error, please contact the responsible development team.`
174
+ message: `${this.depKey} is missing (${this.dataParams.dataName})`,
175
+ userMessage: this.defaultErrorUserMsg
170
176
  });
171
177
  }
172
178
  } else {
@@ -174,8 +180,8 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
174
180
  status: 417,
175
181
  errorCode: 'NTS-DS0-GLD2',
176
182
  addECToUserMsg: true,
177
- message: 'dependencyDataIdKey is missing from service!',
178
- userMessage: `We encountered an unhandled Data Error, please contact the responsible development team.`
183
+ message: `dependencyDataIdKey is missing from service! (${this.dataParams.dataName})`,
184
+ userMessage: this.defaultErrorUserMsg
179
185
  });
180
186
  }
181
187
  } catch (error) {
@@ -183,8 +189,27 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
183
189
  status: 417,
184
190
  errorCode: 'NTS-DS0-GLD0',
185
191
  addECToUserMsg: true,
186
- message: 'getDataListByDependencyId was unsuccessful',
187
- userMessage: `We encountered an unhandled Data Error, please contact the responsible development team.`,
192
+ message: `getDataListByDependencyId was unsuccessful (${this.dataParams.dataName})`,
193
+ userMessage: this.defaultErrorUserMsg,
194
+ error: error
195
+ });
196
+ }
197
+ }
198
+
199
+
200
+ async updateData(set: { updateBy?: any, update: any }): Promise<void> {
201
+ try {
202
+ if (set.updateBy) {
203
+ this.data = await this.dataDBService.updateOne(set.updateBy, set.update, this.issuer);
204
+ }
205
+
206
+ } catch (error) {
207
+ throw new Dynamo_Error({
208
+ status: 417,
209
+ errorCode: 'NTS-DS0-UD0',
210
+ addECToUserMsg: true,
211
+ message: `updateData was unsuccessful (${this.dataParams.dataName})`,
212
+ userMessage: this.defaultErrorUserMsg,
188
213
  error: error
189
214
  });
190
215
  }
@@ -193,31 +218,30 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
193
218
  /**
194
219
  * modifies data if the data have ID and already exists in the DB,
195
220
  * creates new if the ID is not present or cant find in DB,
196
- * and if dependency data setted up, will check before creation
221
+ * and if dependency data setted up, will check before creation,
222
+ * @warning
223
+ * but the proper way to update data, if you use update method instead,
224
+ * this way, you can avoid data override errors
225
+ * (when you simultaneously trying to change the same data's
226
+ * different values from different flows)
197
227
  */
198
228
  async saveData(): Promise<void> {
199
229
  try {
200
230
  if (this.data._id) {
201
231
  // check if already exists
202
- let dataExists: T;
203
- await this.getDataById(null, true).then((data: T) => {
204
- dataExists = data;
205
- }).catch(() => {});
232
+ let dataExists: T = await this.getDataById(null, true).catch(() => null);
206
233
  if (!dataExists) {
207
234
  // if data not exists check that dependency already exists for this
208
235
  if (this.depKey) {
209
236
  if (this.data[this.depKey]) {
210
- let dependencyExists = false;
211
- await this.getDependencyDataDBService().getDataById(this.data[this.depKey]).then((dep) => {
212
- dependencyExists = !!dep;
213
- });
237
+ let dependencyExists = await this.getDependencyDataDBService().getDataById(this.data[this.depKey]);
214
238
  if (!dependencyExists) {
215
239
  throw new Dynamo_Error({
216
240
  status: 417,
217
241
  errorCode: 'NTS-DS0-SD1',
218
242
  addECToUserMsg: true,
219
243
  message: `saveData was unsuccessful: dependency data not exists (key: ${this.depKey}, id: ${this.data[this.depKey]})`,
220
- userMessage: `We encountered an unhandled Data Error, please contact the responsible development team.`
244
+ userMessage: this.defaultErrorUserMsg
221
245
  });
222
246
  }
223
247
  } else {
@@ -226,25 +250,19 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
226
250
  errorCode: 'NTS-DS0-SD2',
227
251
  addECToUserMsg: true,
228
252
  message: `saveData was unsuccessful: dependency data id missing from data (key: ${this.depKey})`,
229
- userMessage: `We encountered an unhandled Data Error, please contact the responsible development team.`
253
+ userMessage: this.defaultErrorUserMsg
230
254
  });
231
255
  }
232
256
  }
233
257
  // if data not exists create new data
234
- await this.dataDBService.createData(this.data, this.issuer).then((data: T) => {
235
- this.data = data;
236
- });
258
+ this.data = await this.dataDBService.createData(this.data, this.issuer);
237
259
  } else {
238
260
  // if data exists do modify
239
- await this.dataDBService.modifyData(this.data, this.issuer).then((data: T) => {
240
- this.data = data;
241
- });
261
+ this.data = await this.dataDBService.modifyData(this.data, this.issuer);
242
262
  }
243
263
  } else {
244
264
  // if ID is not present, data not exists, create new data
245
- await this.dataDBService.createData(this.data, this.issuer).then((data: T) => {
246
- this.data = data;
247
- });
265
+ this.data = await this.dataDBService.createData(this.data, this.issuer);
248
266
  }
249
267
  } catch (error) {
250
268
  throw new Dynamo_Error({
@@ -252,7 +270,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
252
270
  errorCode: 'NTS-DS0-SD0',
253
271
  addECToUserMsg: true,
254
272
  message: `modifyData was unsuccessful (${this.dataParams.dataName})`,
255
- userMessage: `We encountered an unhandled Data Error, please contact the responsible development team.`,
273
+ userMessage: this.defaultErrorUserMsg,
256
274
  error: error
257
275
  });
258
276
  }
@@ -266,15 +284,21 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
266
284
  if (this.data._id) {
267
285
  await this.dataDBService.deleteDataById(this.data._id);
268
286
  } else {
269
- throw new Dynamo_Error({ status: 417, message: 'ID is missing!' });
287
+ throw new Dynamo_Error({
288
+ status: 417,
289
+ errorCode: 'NTS-DS0-DD1',
290
+ addECToUserMsg: true,
291
+ message: `ID is missing! (${this.dataParams.dataName})` ,
292
+ userMessage: this.defaultErrorUserMsg,
293
+ });
270
294
  }
271
295
  } catch (error) {
272
296
  throw new Dynamo_Error({
273
297
  status: 417,
274
298
  errorCode: 'NTS-DS0-DD0',
275
299
  addECToUserMsg: true,
276
- message: 'deleteData was unsuccessful',
277
- userMessage: `We encountered an unhandled Data Error, please contact the responsible development team.`,
300
+ message: `deleteData was unsuccessful (${this.dataParams.dataName})`,
301
+ userMessage: this.defaultErrorUserMsg,
278
302
  error: error
279
303
  });
280
304
  }
@@ -294,17 +318,17 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
294
318
  errorCode: 'NTS-DS0-VD1',
295
319
  addECToUserMsg: true,
296
320
  message: `${this.dataParams.modelParams[i].key} is missing! (${this.dataParams.modelParams[i].required ? 'required' : 'index'})`,
297
- userMessage: `We encountered an unhandled Validation Error, please contact the responsible development team.`
321
+ userMessage: this.defaultValidationErrorUserMsg
298
322
  });
299
323
  }
300
324
  // specific Date validation
301
325
  if (this.dataParams.modelParams[i].type === 'Date' && !(new Date(this.data[this.dataParams.modelParams[i].key]) instanceof Date)) {
302
- throw new Dynamo_Error({
326
+ throw new Dynamo_Error({
303
327
  status: 422,
304
328
  errorCode: 'NTS-DS0-VD2',
305
329
  addECToUserMsg: true,
306
330
  message: `${this.dataParams.modelParams[i].key} is not a date!`,
307
- userMessage: `We encountered an unhandled Validation Error, please contact the responsible development team.`
331
+ userMessage: this.defaultValidationErrorUserMsg
308
332
  });
309
333
  }
310
334
  // call additional validators
@@ -319,8 +343,8 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
319
343
  status: 422,
320
344
  errorCode: 'NTS-DS0-VD0',
321
345
  addECToUserMsg: true,
322
- message: 'validateForSave was unsuccessful',
323
- userMessage: `We encountered an unhandled Data Error, please contact the responsible development team.`,
346
+ message: `validateForSave was unsuccessful (${this.dataParams.dataName})`,
347
+ userMessage: this.defaultErrorUserMsg,
324
348
  error: error
325
349
  });
326
350
  }
@@ -333,8 +357,8 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
333
357
  const dependencyParam: DynamoNTS_DataPropertyParams = this.dataParams.modelParams.find((modelParams: DynamoNTS_DataPropertyParams) => modelParams.isDependencyHook);
334
358
  if (dependencyParam) {
335
359
  this.depKey = dependencyParam.key;
336
- if (dependencyParam.dependencyName) {
337
- this.depDBServiceKey = dependencyParam.dependencyName;
360
+ if (dependencyParam.dependencyDataName) {
361
+ this.depDBServiceKey = dependencyParam.dependencyDataName;
338
362
  }
339
363
  }
340
364
  }
@@ -345,14 +369,19 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
345
369
  */
346
370
  getDependencyDataDBService(): DynamoNTS_DBService<any> {
347
371
  if (this.depDBServiceKey) {
348
- return DynamoNTS_GlobalService.getDBService(this.dataParams);
372
+ if (this.depDataDBService) {
373
+ return this.depDataDBService;
374
+ } else {
375
+ this.depDataDBService = DynamoNTS_GlobalService.getDBServiceByKey(this.depDBServiceKey);
376
+ return this.depDataDBService;
377
+ }
349
378
  } else {
350
379
  throw new Dynamo_Error({
351
380
  status: 501,
352
381
  errorCode: 'NTS-DS0-GDDB0',
353
382
  addECToUserMsg: true,
354
383
  message: 'getDependencyDataDBService was unsuccessful, service key not setted up!',
355
- userMessage: `We encountered an unhandled Data Error, please contact the responsible development team.`
384
+ userMessage: this.defaultErrorUserMsg
356
385
  });
357
386
  }
358
387
  }