@futdevpro/nts-dynamo 1.5.40 → 1.5.47

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 (118) hide show
  1. package/futdevpro-nts-dynamo-01.05.41.tgz +0 -0
  2. package/futdevpro-nts-dynamo-01.05.42.tgz +0 -0
  3. package/futdevpro-nts-dynamo-01.05.43.tgz +0 -0
  4. package/futdevpro-nts-dynamo-01.05.44.tgz +0 -0
  5. package/futdevpro-nts-dynamo-01.05.45.tgz +0 -0
  6. package/lib/_enums/http/socket-event.enum.d.ts +2 -0
  7. package/lib/_enums/http/socket-event.enum.d.ts.map +1 -1
  8. package/lib/_enums/http/socket-event.enum.js +2 -0
  9. package/lib/_enums/http/socket-event.enum.js.map +1 -1
  10. package/lib/_models/dynamo-nts-endpoint-params.js +1 -1
  11. package/lib/_models/dynamo-nts-endpoint-params.js.map +1 -1
  12. package/lib/_models/dynamo-nts-socket-dictionary.d.ts +16 -0
  13. package/lib/_models/dynamo-nts-socket-dictionary.d.ts.map +1 -0
  14. package/lib/_models/dynamo-nts-socket-dictionary.js +31 -0
  15. package/lib/_models/dynamo-nts-socket-dictionary.js.map +1 -0
  16. package/lib/_models/dynamo-nts-socket-event-params.d.ts +2 -0
  17. package/lib/_models/dynamo-nts-socket-event-params.d.ts.map +1 -1
  18. package/lib/_models/dynamo-nts-socket-event-params.js +6 -5
  19. package/lib/_models/dynamo-nts-socket-event-params.js.map +1 -1
  20. package/lib/_models/index.d.ts +1 -0
  21. package/lib/_models/index.d.ts.map +1 -1
  22. package/lib/_models/index.js +1 -0
  23. package/lib/_models/index.js.map +1 -1
  24. package/lib/_modules/app-extended.index.d.ts +1 -0
  25. package/lib/_modules/app-extended.index.d.ts.map +1 -1
  26. package/lib/_modules/app-extended.index.js +1 -0
  27. package/lib/_modules/app-extended.index.js.map +1 -1
  28. package/lib/_modules/test/custom-data.service.d.ts +3 -3
  29. package/lib/_modules/test/custom-data.service.d.ts.map +1 -1
  30. package/lib/_modules/test/custom-data.service.js +4 -4
  31. package/lib/_modules/test/custom-data.service.js.map +1 -1
  32. package/lib/_modules/test/test-controller.js +6 -6
  33. package/lib/_modules/test/test-controller.js.map +1 -1
  34. package/lib/_modules/usage/usage-controller.js +1 -1
  35. package/lib/_modules/usage/usage-controller.js.map +1 -1
  36. package/lib/_modules/usage/usage.service.d.ts +6 -6
  37. package/lib/_modules/usage/usage.service.d.ts.map +1 -1
  38. package/lib/_modules/usage/usage.service.js +18 -10
  39. package/lib/_modules/usage/usage.service.js.map +1 -1
  40. package/lib/_services/dynamo-nts-api.service.d.ts.map +1 -1
  41. package/lib/_services/dynamo-nts-api.service.js +19 -8
  42. package/lib/_services/dynamo-nts-api.service.js.map +1 -1
  43. package/lib/_services/dynamo-nts-app-extended.d.ts +1 -1
  44. package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -1
  45. package/lib/_services/dynamo-nts-app-extended.js +2 -4
  46. package/lib/_services/dynamo-nts-app-extended.js.map +1 -1
  47. package/lib/_services/dynamo-nts-app.d.ts +1 -0
  48. package/lib/_services/dynamo-nts-app.d.ts.map +1 -1
  49. package/lib/_services/dynamo-nts-app.js +4 -1
  50. package/lib/_services/dynamo-nts-app.js.map +1 -1
  51. package/lib/_services/dynamo-nts-auth.service.d.ts.map +1 -1
  52. package/lib/_services/dynamo-nts-auth.service.js +10 -4
  53. package/lib/_services/dynamo-nts-auth.service.js.map +1 -1
  54. package/lib/_services/dynamo-nts-controller.service.d.ts +37 -0
  55. package/lib/_services/dynamo-nts-controller.service.d.ts.map +1 -1
  56. package/lib/_services/dynamo-nts-controller.service.js +37 -0
  57. package/lib/_services/dynamo-nts-controller.service.js.map +1 -1
  58. package/lib/_services/dynamo-nts-data.service.d.ts +21 -2
  59. package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -1
  60. package/lib/_services/dynamo-nts-data.service.js +121 -53
  61. package/lib/_services/dynamo-nts-data.service.js.map +1 -1
  62. package/lib/_services/dynamo-nts-db.service.d.ts +4 -4
  63. package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -1
  64. package/lib/_services/dynamo-nts-db.service.js +148 -84
  65. package/lib/_services/dynamo-nts-db.service.js.map +1 -1
  66. package/lib/_services/dynamo-nts-email.service.d.ts.map +1 -1
  67. package/lib/_services/dynamo-nts-email.service.js +20 -16
  68. package/lib/_services/dynamo-nts-email.service.js.map +1 -1
  69. package/lib/_services/dynamo-nts-global.service.d.ts +5 -5
  70. package/lib/_services/dynamo-nts-global.service.d.ts.map +1 -1
  71. package/lib/_services/dynamo-nts-global.service.js.map +1 -1
  72. package/lib/_services/dynamo-nts-routing-module.service.d.ts.map +1 -1
  73. package/lib/_services/dynamo-nts-routing-module.service.js +17 -11
  74. package/lib/_services/dynamo-nts-routing-module.service.js.map +1 -1
  75. package/lib/_services/dynamo-nts-shared.service.d.ts +6 -0
  76. package/lib/_services/dynamo-nts-shared.service.d.ts.map +1 -1
  77. package/lib/_services/dynamo-nts-shared.service.js +8 -0
  78. package/lib/_services/dynamo-nts-shared.service.js.map +1 -1
  79. package/lib/_services/dynamo-nts-socket-service-collection.service.d.ts +1 -1
  80. package/lib/_services/dynamo-nts-socket-service-collection.service.d.ts.map +1 -1
  81. package/lib/_services/dynamo-nts-socket.service.d.ts +6 -9
  82. package/lib/_services/dynamo-nts-socket.service.d.ts.map +1 -1
  83. package/lib/_services/dynamo-nts-socket.service.js +25 -20
  84. package/lib/_services/dynamo-nts-socket.service.js.map +1 -1
  85. package/lib/_services/dynamobe-api.service.js +2 -2
  86. package/lib/_services/dynamobe-auth.service.js +2 -2
  87. package/lib/_services/dynamobe-data.service.d.ts +2 -2
  88. package/lib/_services/dynamobe-data.service.js +15 -15
  89. package/lib/_services/dynamobe-db.service.d.ts +4 -4
  90. package/lib/_services/dynamobe-db.service.js +28 -28
  91. package/lib/_services/dynamobe-email.service.js +4 -4
  92. package/lib/_services/dynamobe-global.service.d.ts +3 -3
  93. package/lib/_services/dynamobe-routing-module.service.js +3 -3
  94. package/lib/tsconfig.tsbuildinfo +1 -5564
  95. package/package.json +22 -12
  96. package/src/_enums/http/socket-event.enum.ts +2 -0
  97. package/src/_models/dynamo-nts-endpoint-params.ts +1 -1
  98. package/src/_models/dynamo-nts-socket-dictionary.ts +39 -0
  99. package/src/_models/dynamo-nts-socket-event-params.ts +8 -5
  100. package/src/_models/index.ts +1 -0
  101. package/src/_modules/app-extended.index.ts +1 -0
  102. package/src/_modules/test/custom-data.service.ts +4 -4
  103. package/src/_modules/test/test-controller.ts +7 -7
  104. package/src/_modules/usage/usage-controller.ts +2 -2
  105. package/src/_modules/usage/usage.service.ts +34 -26
  106. package/src/_services/dynamo-nts-api.service.ts +26 -9
  107. package/src/_services/dynamo-nts-app-extended.ts +9 -9
  108. package/src/_services/dynamo-nts-app.ts +2 -2
  109. package/src/_services/dynamo-nts-auth.service.ts +13 -5
  110. package/src/_services/dynamo-nts-controller.service.ts +37 -0
  111. package/src/_services/dynamo-nts-data.service.ts +123 -55
  112. package/src/_services/dynamo-nts-db.service.ts +181 -87
  113. package/src/_services/dynamo-nts-email.service.ts +21 -17
  114. package/src/_services/dynamo-nts-global.service.ts +12 -5
  115. package/src/_services/dynamo-nts-routing-module.service.ts +16 -10
  116. package/src/_services/dynamo-nts-shared.service.ts +9 -0
  117. package/src/_services/dynamo-nts-socket-service-collection.service.ts +1 -1
  118. package/src/_services/dynamo-nts-socket.service.ts +33 -29
@@ -1,19 +1,19 @@
1
1
 
2
2
  import * as mongoose from 'mongoose';
3
3
  import { Schema } from 'mongoose';
4
- import { Metadata, DynamoNTS_DataParams, DynamoNTS_DataPropertyParams, DynamoNTS_Error } from '@futdevpro/fsm-dynamo';
4
+ import { Dynamo_Metadata, DynamoNTS_DataParams, DynamoNTS_DataPropertyParams, Dynamo_Error } from '@futdevpro/fsm-dynamo';
5
5
 
6
6
  /**
7
7
  *
8
8
  */
9
- export class DynamoNTS_DBService<T extends Metadata> {
9
+ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
10
10
  dataModel = mongoose.model(this.dataParams.dbName, this.getSchema());
11
11
 
12
12
  private depDataName: string;
13
13
 
14
14
  /**
15
15
  * @param dataName name the model
16
- * @param typeSample sample data for scheme creation (dont include Metadata!)
16
+ * @param typeSample sample data for scheme creation (dont include Dynamo_Metadata!)
17
17
  * @param schemaSettings additional settings for specific parameters as unique, required, minlength or maxlength
18
18
  * schemaSettings also MUST contain specific types that differs from the listed above (Array, Date)
19
19
  */
@@ -33,30 +33,39 @@ export class DynamoNTS_DBService<T extends Metadata> {
33
33
  data.__lastModified = new Date();
34
34
  data.__createdBy = creator;
35
35
  data.__lastModifiedBy = creator;
36
+
36
37
  const dataModel = new this.dataModel(data);
37
38
  let newData: T;
39
+
38
40
  await dataModel.save().then(res => {
39
41
  if (res) {
40
42
  newData = res.toObject() as T;
41
43
  } else {
42
- throw new DynamoNTS_Error({
43
- status: 204, message: `${this.dataParams.dbName} not found! (BD)`,
44
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-401`,
45
- error: new Error()
44
+ throw new Dynamo_Error({
45
+ status: 204,
46
+ errorCode: 'NTS-DBS-CD1',
47
+ addECToUserMsg: true,
48
+ message: `save ${this.dataParams.dbName} result not found! (NTS DB)`,
49
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`
46
50
  });
47
51
  }
48
52
  }).catch(error => {
49
- throw new DynamoNTS_Error({
50
- status: 422, message: `Create new ${this.dataParams.dbName} was unsuccessful (BD)`,
51
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-400`,
53
+ throw new Dynamo_Error({
54
+ status: 422,
55
+ errorCode: 'NTS-DBS-CD0',
56
+ addECToUserMsg: true,
57
+ message: `Create new ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
58
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
52
59
  error
53
60
  });
54
61
  });
62
+
55
63
  if (typeof newData._id === 'object') {
56
64
  newData._id = `${newData._id}`;
57
65
  }
58
66
  data._id = newData._id;
59
67
  data.__v = newData.__v;
68
+
60
69
  return data;
61
70
  }
62
71
 
@@ -68,26 +77,35 @@ export class DynamoNTS_DBService<T extends Metadata> {
68
77
  async modifyData(data: T, modifier: string): Promise<T> {
69
78
  data.__lastModified = new Date();
70
79
  data.__lastModifiedBy = modifier;
80
+
71
81
  const dataModel = new this.dataModel(data);
72
82
  let newData: T;
83
+
73
84
  await this.dataModel.findByIdAndUpdate(data._id, dataModel).then(res => {
74
85
  if (res) {
75
86
  newData = res.toObject() as T;
76
87
  } else {
77
- throw new DynamoNTS_Error({
78
- status: 204, message: `${this.dataParams.dbName} not found! (BD)`,
79
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-411`,
80
- error: new Error()
88
+ throw new Dynamo_Error({
89
+ status: 204,
90
+ errorCode: 'NTS-DBS-FU1',
91
+ addECToUserMsg: true,
92
+ message: `update ${this.dataParams.dbName} result not found! (NTS DB)`,
93
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`
81
94
  });
82
95
  }
83
96
  }).catch(error => {
84
- throw new DynamoNTS_Error({
85
- status: 417, message: `modify ${this.dataParams.dbName} was unsuccessful (DB)`,
86
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-410`,
97
+ throw new Dynamo_Error({
98
+ status: 417,
99
+ errorCode: 'NTS-DBS-FU0',
100
+ addECToUserMsg: true,
101
+ message: `modify ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
102
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
87
103
  error
88
104
  });
89
105
  });
106
+
90
107
  data.__v = newData.__v;
108
+
91
109
  return data;
92
110
  }
93
111
 
@@ -98,6 +116,7 @@ export class DynamoNTS_DBService<T extends Metadata> {
98
116
  */
99
117
  async getDataById(id: string): Promise<T> {
100
118
  let data: T;
119
+
101
120
  await this.dataModel.findById(id).then(res => {
102
121
  if (res) {
103
122
  data = res.toObject() as T;
@@ -105,15 +124,20 @@ export class DynamoNTS_DBService<T extends Metadata> {
105
124
  data = null;
106
125
  }
107
126
  }).catch(error => {
108
- throw new DynamoNTS_Error({
109
- status: 417, message: `get ${this.dataParams.dbName} by ID was unsuccessful (DB)`,
110
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-430`,
127
+ throw new Dynamo_Error({
128
+ status: 417,
129
+ errorCode: 'NTS-DBS-GI0',
130
+ addECToUserMsg: true,
131
+ message: `get ${this.dataParams.dbName} by ID was unsuccessful (NTS DB)`,
132
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
111
133
  error
112
134
  });
113
135
  });
136
+
114
137
  if (data && typeof data._id === 'object') {
115
138
  data._id = `${data._id}`;
116
139
  }
140
+
117
141
  return data;
118
142
  }
119
143
 
@@ -132,9 +156,12 @@ export class DynamoNTS_DBService<T extends Metadata> {
132
156
  data = null;
133
157
  }
134
158
  }).catch(error => {
135
- throw new DynamoNTS_Error({
136
- status: 417, message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (DB)`,
137
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-441`,
159
+ throw new Dynamo_Error({
160
+ status: 417,
161
+ errorCode: 'NTS-DBS-GD1',
162
+ addECToUserMsg: true,
163
+ message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
164
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
138
165
  error
139
166
  });
140
167
  });
@@ -143,10 +170,12 @@ export class DynamoNTS_DBService<T extends Metadata> {
143
170
  }
144
171
  return data;
145
172
  } else {
146
- throw new DynamoNTS_Error({
147
- status: 501, message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (BD)`,
148
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-440`,
149
- error: new Error()
173
+ throw new Dynamo_Error({
174
+ status: 501,
175
+ errorCode: 'NTS-DBS-GD0',
176
+ addECToUserMsg: true,
177
+ message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (NTS DB)`,
178
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`
150
179
  });
151
180
  }
152
181
  }
@@ -164,9 +193,12 @@ export class DynamoNTS_DBService<T extends Metadata> {
164
193
  dataList = res;
165
194
  }
166
195
  }).catch(error => {
167
- throw new DynamoNTS_Error({
168
- status: 417, message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (DB)`,
169
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-451`,
196
+ throw new Dynamo_Error({
197
+ status: 417,
198
+ errorCode: 'NTS-DBS-GLD1',
199
+ addECToUserMsg: true,
200
+ message: `get ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
201
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
170
202
  error
171
203
  });
172
204
  });
@@ -177,10 +209,12 @@ export class DynamoNTS_DBService<T extends Metadata> {
177
209
  }
178
210
  return dataList;
179
211
  } else {
180
- throw new DynamoNTS_Error({
181
- status: 501, message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (BD)`,
182
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-450`,
183
- error: new Error()
212
+ throw new Dynamo_Error({
213
+ status: 501,
214
+ errorCode: 'NTS-DBS-GLD0',
215
+ addECToUserMsg: true,
216
+ message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (NTS DB)`,
217
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`
184
218
  });
185
219
  }
186
220
  }
@@ -198,18 +232,23 @@ export class DynamoNTS_DBService<T extends Metadata> {
198
232
  dataList = res;
199
233
  }
200
234
  }).catch(error => {
201
- throw new DynamoNTS_Error({
202
- status: 417, message: `get ${this.dataParams.dbName}s by ${this.depDataName}s was unsuccessful (DB)`,
203
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-461`,
235
+ throw new Dynamo_Error({
236
+ status: 417,
237
+ errorCode: 'NTS-DBS-GLDS1',
238
+ addECToUserMsg: true,
239
+ message: `get ${this.dataParams.dbName}s by ${this.depDataName}s was unsuccessful (NTS DB)`,
240
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
204
241
  error
205
242
  });
206
243
  });
207
244
  return dataList;
208
245
  } else {
209
- throw new DynamoNTS_Error({
210
- status: 501, message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (BD)`,
211
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-460`,
212
- error: new Error()
246
+ throw new Dynamo_Error({
247
+ status: 501,
248
+ errorCode: 'NTS-DBS-GLDS0',
249
+ addECToUserMsg: true,
250
+ message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (NTS DB)`,
251
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`
213
252
  });
214
253
  }
215
254
  }
@@ -228,13 +267,16 @@ export class DynamoNTS_DBService<T extends Metadata> {
228
267
  if (this.depDataName) {
229
268
  filter[this.depDataName] = { $in: narrowByDependencyIds };
230
269
  } else {
231
- throw new DynamoNTS_Error({
232
- status: 501, message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (BD)`,
233
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-470`,
234
- error: new Error()
270
+ throw new Dynamo_Error({
271
+ status: 501,
272
+ errorCode: 'NTS-DBS-SD0',
273
+ addECToUserMsg: true,
274
+ message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (NTS DB)`,
275
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`
235
276
  });
236
277
  }
237
278
  }
279
+
238
280
  await this.dataParams.modelParams.forEach((modelParam: DynamoNTS_DataPropertyParams) => {
239
281
  if ((searchBy[modelParam.key] !== null && searchBy[modelParam.key] !== undefined) || searchBy[modelParam.key + 'Range']) {
240
282
  if (modelParam.key.includes('Range') || modelParam.type.includes('[]')) {
@@ -279,17 +321,22 @@ export class DynamoNTS_DBService<T extends Metadata> {
279
321
  dataList = res;
280
322
  }
281
323
  }).catch(error => {
282
- throw new DynamoNTS_Error({
283
- status: 417, message: `search ${this.dataParams.dbName} was unsuccessful (DB)`,
284
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-471`,
324
+ throw new Dynamo_Error({
325
+ status: 417,
326
+ errorCode: 'NTS-DBS-SD1',
327
+ addECToUserMsg: true,
328
+ message: `search ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
329
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
285
330
  error
286
331
  });
287
332
  });
333
+
288
334
  if (0 < dataList.length && typeof dataList[0]._id === 'object') {
289
335
  dataList.forEach((data: T) => {
290
336
  data._id = `˙${data._id}`;
291
337
  });
292
338
  }
339
+
293
340
  return dataList as T[];
294
341
  }
295
342
 
@@ -313,7 +360,7 @@ export class DynamoNTS_DBService<T extends Metadata> {
313
360
  data = null;
314
361
  }
315
362
  }).catch(error => {
316
- throw new DynamoNTS_Error({ status: 417, message: `find ${this.dataParams.dbName} was unsuccessful (DB)`, error });
363
+ throw new Dynamo_Error({ status: 417, message: `find ${this.dataParams.dbName} was unsuccessful (NTS DB)`, error });
317
364
  });
318
365
  if (data && typeof data._id === 'object') {
319
366
  data._id = `${data._id}`;
@@ -327,22 +374,28 @@ export class DynamoNTS_DBService<T extends Metadata> {
327
374
  */
328
375
  async getAll(): Promise<T[]> {
329
376
  let dataList = [];
377
+
330
378
  await this.dataModel.find({}).then(res => {
331
379
  if (res) {
332
380
  dataList = res;
333
381
  }
334
382
  }).catch(error => {
335
- throw new DynamoNTS_Error({
336
- status: 417, message: `get all ${this.dataParams.dbName} was unsuccessful (DB)`,
337
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-480`,
383
+ throw new Dynamo_Error({
384
+ status: 417,
385
+ errorCode: 'NTS-DBS-GA0',
386
+ addECToUserMsg: true,
387
+ message: `get all ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
388
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
338
389
  error
339
390
  });
340
391
  });
392
+
341
393
  if (0 < dataList.length && typeof dataList[0]._id === 'object') {
342
394
  dataList.forEach((data: T) => {
343
395
  data._id = `˙${data._id}`;
344
396
  });
345
397
  }
398
+
346
399
  return dataList as T[];
347
400
  }
348
401
 
@@ -352,9 +405,12 @@ export class DynamoNTS_DBService<T extends Metadata> {
352
405
  */
353
406
  async deleteDataById(id: string): Promise<void> {
354
407
  await this.dataModel.findByIdAndDelete(id).catch(error => {
355
- throw new DynamoNTS_Error({
356
- status: 417, message: `delete ${this.dataParams.dbName} was unsuccessful (DB)`,
357
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-490`,
408
+ throw new Dynamo_Error({
409
+ status: 417,
410
+ errorCode: 'NTS-DBS-DD0',
411
+ addECToUserMsg: true,
412
+ message: `delete ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
413
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
358
414
  error
359
415
  });
360
416
  });
@@ -367,17 +423,22 @@ export class DynamoNTS_DBService<T extends Metadata> {
367
423
  async deleteDataByDependencyId(dependencyId: string): Promise<void> {
368
424
  if (this.depDataName) {
369
425
  await this.dataModel.deleteMany({ [this.depDataName]: dependencyId }).catch(error => {
370
- throw new DynamoNTS_Error({
371
- status: 417, message: `delete ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (DB)`,
372
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-591`,
426
+ throw new Dynamo_Error({
427
+ status: 417,
428
+ errorCode: 'NTS-DBS-DDD1',
429
+ addECToUserMsg: true,
430
+ message: `delete ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
431
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
373
432
  error
374
433
  });
375
434
  });
376
435
  } else {
377
- throw new DynamoNTS_Error({
378
- status: 501, message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (BD)`,
379
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-590`,
380
- error: new Error()
436
+ throw new Dynamo_Error({
437
+ status: 501,
438
+ errorCode: 'NTS-DBS-DDD0',
439
+ addECToUserMsg: true,
440
+ message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (NTS DB)`,
441
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`
381
442
  });
382
443
  }
383
444
  }
@@ -415,9 +476,12 @@ export class DynamoNTS_DBService<T extends Metadata> {
415
476
  data = null;
416
477
  }
417
478
  }).catch(error => {
418
- throw new DynamoNTS_Error({
419
- status: 417, message: `findOne ${this.dataParams.dbName} was unsuccessful (DB)`,
420
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-510`,
479
+ throw new Dynamo_Error({
480
+ status: 417,
481
+ errorCode: 'NTS-DBS-FO0',
482
+ addECToUserMsg: true,
483
+ message: `findOne ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
484
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
421
485
  error
422
486
  });
423
487
  });
@@ -447,22 +511,28 @@ export class DynamoNTS_DBService<T extends Metadata> {
447
511
  */
448
512
  async find(filter: any): Promise<T[]> {
449
513
  let dataList = [];
514
+
450
515
  await this.dataModel.find(filter).then(res => {
451
516
  if (res) {
452
517
  dataList = res;
453
518
  }
454
519
  }).catch(error => {
455
- throw new DynamoNTS_Error({
456
- status: 417, message: `find ${this.dataParams.dbName} was unsuccessful (DB)`,
457
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-520`,
520
+ throw new Dynamo_Error({
521
+ status: 417,
522
+ errorCode: 'NTS-DBS-F0',
523
+ addECToUserMsg: true,
524
+ message: `find ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
525
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
458
526
  error
459
527
  });
460
528
  });
529
+
461
530
  if (0 < dataList.length && typeof dataList[0]._id === 'object') {
462
531
  dataList.forEach((data: T) => {
463
532
  data._id = `˙${data._id}`;
464
533
  });
465
534
  }
535
+
466
536
  return dataList as T[];
467
537
  }
468
538
 
@@ -498,17 +568,22 @@ export class DynamoNTS_DBService<T extends Metadata> {
498
568
  dataList = res;
499
569
  }
500
570
  }).catch(error => {
501
- throw new DynamoNTS_Error({
502
- status: 417, message: `findWithPaging ${this.dataParams.dbName} was unsuccessful (DB)`,
503
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-530`,
571
+ throw new Dynamo_Error({
572
+ status: 417,
573
+ errorCode: 'NTS-DBS-WP0',
574
+ addECToUserMsg: true,
575
+ message: `findWithPaging ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
576
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
504
577
  error
505
578
  });
506
579
  });
580
+
507
581
  if (0 < dataList.length && typeof dataList[0]._id === 'object') {
508
582
  dataList.forEach((data: T) => {
509
583
  data._id = `˙${data._id}`;
510
584
  });
511
585
  }
586
+
512
587
  return dataList;
513
588
  }
514
589
 
@@ -522,21 +597,27 @@ export class DynamoNTS_DBService<T extends Metadata> {
522
597
  let data: T;
523
598
  update.__lastModified = new Date();
524
599
  update.__lastModifiedBy = modifier;
600
+
525
601
  await this.dataModel.findByIdAndUpdate(id, update).then(res => {
526
602
  if (res) {
527
603
  data = res.toObject() as T;
528
604
  } else {
529
- throw new DynamoNTS_Error({
530
- status: 204, message: `${this.dataParams.dbName} not found! (BD)`,
531
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-541`,
532
- error: new Error()
605
+ throw new Dynamo_Error({
606
+ status: 204,
607
+ errorCode: 'NTS-DBS-FIU1',
608
+ addECToUserMsg: true,
609
+ message: `${this.dataParams.dbName} not found! (NTS DB)`,
610
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`
533
611
  });
534
612
  }
535
613
  }).catch(error => {
536
- throw new DynamoNTS_Error({
537
- status: 417, message: `findByIdAndUpdate ${this.dataParams.dbName} was unsuccessful (DB)`,
538
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-540`,
539
- error
614
+ throw new Dynamo_Error({
615
+ status: 417,
616
+ errorCode: 'NTS-DBS-FIU0',
617
+ addECToUserMsg: true,
618
+ message: `findByIdAndUpdate ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
619
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
620
+ error
540
621
  });
541
622
  });
542
623
  update.__v = data.__v;
@@ -579,9 +660,12 @@ export class DynamoNTS_DBService<T extends Metadata> {
579
660
  update.__lastModified = new Date();
580
661
  update.__lastModifiedBy = modifier;
581
662
  await this.dataModel.updateOne(updateBy, update).catch(error => {
582
- throw new DynamoNTS_Error({
583
- status: 417, message: `updateOne ${this.dataParams.dbName} was unsuccessful (DB)`,
584
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-550`,
663
+ throw new Dynamo_Error({
664
+ status: 417,
665
+ errorCode: 'NTS-DBS-UO0',
666
+ addECToUserMsg: true,
667
+ message: `updateOne ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
668
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
585
669
  error
586
670
  });
587
671
  });
@@ -621,10 +705,14 @@ export class DynamoNTS_DBService<T extends Metadata> {
621
705
  async updateMany(updateBy: any, update: any, modifier: string): Promise<void> {
622
706
  update.__lastModified = new Date();
623
707
  update.__lastModifiedBy = modifier;
708
+
624
709
  await this.dataModel.updateMany(updateBy, update).catch(error => {
625
- throw new DynamoNTS_Error({
626
- status: 417, message: `updateMany ${this.dataParams.dbName} was unsuccessful (DB)`,
627
- userMessage: `We encountered an uncought DB Error, please contact the responsible development team. errorcode: 505-223-560`,
710
+ throw new Dynamo_Error({
711
+ status: 417,
712
+ errorCode: 'NTS-DBS-UM0',
713
+ addECToUserMsg: true,
714
+ message: `updateMany ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
715
+ userMessage: `We encountered an unhandled DB Error, please contact the responsible development team.`,
628
716
  error
629
717
  });
630
718
  });
@@ -641,12 +729,14 @@ export class DynamoNTS_DBService<T extends Metadata> {
641
729
  */
642
730
  private getSchema(): mongoose.Schema {
643
731
  let schema: any = this.buildMongooseSchemaByModelParams();
644
- schema = this.addMetadataToSchema(schema);
732
+ schema = this.addDynamo_MetadataToSchema(schema);
733
+
645
734
  // tslint:disable-next-line: no-string-literal
646
735
  if (schema['_id']) {
647
736
  // tslint:disable-next-line: no-string-literal
648
737
  delete schema['_id'];
649
738
  }
739
+
650
740
  return new Schema(schema);
651
741
  }
652
742
 
@@ -657,9 +747,11 @@ export class DynamoNTS_DBService<T extends Metadata> {
657
747
  */
658
748
  private buildMongooseSchemaByModelParams(params?: DynamoNTS_DataPropertyParams[]): any {
659
749
  const schemaSettingsObj = {};
750
+
660
751
  if (!params) {
661
752
  params = this.dataParams.modelParams;
662
753
  }
754
+
663
755
  params.forEach((property: DynamoNTS_DataPropertyParams) => {
664
756
  const beType = this.getBEType(property.type);
665
757
  if (beType !== Object || !property.subObjectParams) {
@@ -685,6 +777,7 @@ export class DynamoNTS_DBService<T extends Metadata> {
685
777
  schemaSettingsObj[property.key] = this.buildMongooseSchemaByModelParams(property.subObjectParams);
686
778
  }
687
779
  });
780
+
688
781
  return schemaSettingsObj;
689
782
  }
690
783
 
@@ -716,11 +809,12 @@ export class DynamoNTS_DBService<T extends Metadata> {
716
809
  * @param schema schema to update
717
810
  * @returns updated schema
718
811
  */
719
- private addMetadataToSchema(schema: any): any {
812
+ private addDynamo_MetadataToSchema(schema: any): any {
720
813
  schema.__created = { type: Date };
721
814
  schema.__createdBy = { type: String };
722
815
  schema.__lastModified = { type: Date };
723
816
  schema.__lastModifiedBy = { type: String };
817
+
724
818
  return schema;
725
819
  }
726
820
 
@@ -3,7 +3,7 @@ import * as FileSystem from 'fs';
3
3
  import * as Path from 'path';
4
4
  import * as NodeMailer from 'nodemailer';
5
5
  import { Options as MailOptions, Attachment } from 'nodemailer/lib/mailer';
6
- import { DynamoNTS_Error } from '@futdevpro/fsm-dynamo';
6
+ import { Dynamo_Error } from '@futdevpro/fsm-dynamo';
7
7
 
8
8
  import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
9
9
 
@@ -87,10 +87,11 @@ export class DynamoNTS_EmailService {
87
87
  content = set.content
88
88
  } else if (set.useTemplate) {
89
89
  if (!this.templates[set.useTemplate]) {
90
- throw new DynamoNTS_Error({
91
- message: `no template found with this parameter! (${set.useTemplate})`,
92
- userMessage: `We encountered an uncought BackEnd Email Service Error, please contact the responsible development team. errorcode: 701-114-101`,
93
- error: new Error()
90
+ throw new Dynamo_Error({
91
+ errorCode: 'NTS-ES4-101',
92
+ addECToUserMsg: true,
93
+ message: `No email template found with this parameter! (${set.useTemplate})`,
94
+ userMessage: `We encountered an uncought BackEnd Email Service Error, please contact the responsible development team.`
94
95
  });
95
96
  }
96
97
  content = this.templates[set.useTemplate];
@@ -102,25 +103,27 @@ export class DynamoNTS_EmailService {
102
103
  props += `${key}${index != this.templatePropertyKeys[set.useTemplate].length - 1 ? ', ' : ''}`;
103
104
  });
104
105
  DynamoNTS_Shared.logError('\nDynamoBEEmailService ERROR: INVALID sendEmail settings', set);
105
- throw new DynamoNTS_Error({
106
- message: `templateProperties missing! properties needed: ${props}`,
107
- userMessage: `We encountered an uncought BackEnd Email Service Error, please contact the responsible development team. errorcode: 701-114-102`,
108
- error: new Error()
106
+ throw new Dynamo_Error({
107
+ errorCode: 'NTS-ES4-102',
108
+ addECToUserMsg: true,
109
+ message: `TemplateProperties missing! properties needed: ${props}`,
110
+ userMessage: `We encountered an uncought BackEnd Email Service Error, please contact the responsible development team.`
109
111
  });
110
112
  }
111
113
  this.templatePropertyKeys[set.useTemplate].forEach((propertyKey: string) => {
112
114
  if (!set.templateProperties[propertyKey]) {
113
- DynamoNTS_Shared.logError(`templateProperty missing! (${propertyKey})`);
115
+ DynamoNTS_Shared.logError(`TemplateProperty missing! (${propertyKey})`);
114
116
  }
115
117
  const reg = new RegExp(`{{${propertyKey}}}`, 'g')
116
118
  content = content.replace(reg, set.templateProperties[propertyKey]);
117
119
  });
118
120
  }
119
121
  } else {
120
- throw new DynamoNTS_Error({
121
- message: 'no content setting passsed to emailSending!',
122
- userMessage: `We encountered an uncought BackEnd Email Service Error, please contact the responsible development team. errorcode: 701-114-100`,
123
- error: new Error()
122
+ throw new Dynamo_Error({
123
+ errorCode: 'NTS-ES4-100',
124
+ addECToUserMsg: true,
125
+ message: 'No content setting passsed to emailSending!',
126
+ userMessage: `We encountered an uncought BackEnd Email Service Error, please contact the responsible development team.`,
124
127
  });
125
128
  }
126
129
 
@@ -195,10 +198,11 @@ export class DynamoNTS_EmailService {
195
198
  while (propertyOpenTagIndex >= 0) {
196
199
  if (propertyCloseTagIndex === -1) {
197
200
  DynamoNTS_Shared.logError(`\nDynamoBEEmailService ERROR, missing closing tag from email template! (${propertyOpenTagIndex} -)`, propertyKeys);
198
- throw new DynamoNTS_Error({
201
+ throw new Dynamo_Error({
202
+ errorCode: 'NTS-ES4-200',
203
+ addECToUserMsg: true,
199
204
  message: `ERROR, missing closing tag from email template! (${propertyOpenTagIndex} -)`,
200
- userMessage: `We encountered an uncought BackEnd Email Service Error, please contact the responsible development team. errorcode: 701-114-200`,
201
- error: new Error()
205
+ userMessage: `We encountered an uncought BackEnd Email Service Error, please contact the responsible development team.`
202
206
  });
203
207
  }
204
208
  const newKey: string = template.substring(propertyOpenTagIndex + 2, propertyCloseTagIndex);