@futdevpro/nts-dynamo 1.5.77 → 1.5.83

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 (227) hide show
  1. package/LICENSE +2 -2
  2. package/lib/_constants/dynamo-nts-global-settings.d.ts +2 -2
  3. package/lib/_constants/dynamo-nts-global-settings.js +17 -17
  4. package/lib/_constants/index.d.ts +1 -1
  5. package/lib/_constants/index.js +4 -4
  6. package/lib/_enums/data-model-type.enum.d.ts +12 -12
  7. package/lib/_enums/data-model-type.enum.js +16 -16
  8. package/lib/_enums/data-model-type.enum.js.map +1 -1
  9. package/lib/_enums/dynamo-nts-data-service-function.enum.d.ts +12 -12
  10. package/lib/_enums/dynamo-nts-data-service-function.enum.js +18 -18
  11. package/lib/_enums/dynamo-nts-data-service-function.enum.js.map +1 -1
  12. package/lib/_enums/dynamo-nts-route-security.enum.d.ts +11 -11
  13. package/lib/_enums/dynamo-nts-route-security.enum.js +15 -15
  14. package/lib/_enums/dynamo-nts-route-security.enum.js.map +1 -1
  15. package/lib/_enums/dynamo-nts-socket-security.enum.d.ts +10 -10
  16. package/lib/_enums/dynamo-nts-socket-security.enum.js +14 -14
  17. package/lib/_enums/dynamo-nts-socket-security.enum.js.map +1 -1
  18. package/lib/_enums/http/http-call-type.enum.d.ts +11 -11
  19. package/lib/_enums/http/http-call-type.enum.js +15 -15
  20. package/lib/_enums/http/http-call-type.enum.js.map +1 -1
  21. package/lib/_enums/http/http-response-type.enum.d.ts +6 -6
  22. package/lib/_enums/http/http-response-type.enum.js +10 -10
  23. package/lib/_enums/http/http-response-type.enum.js.map +1 -1
  24. package/lib/_enums/http/socket-event.enum.d.ts +9 -8
  25. package/lib/_enums/http/socket-event.enum.d.ts.map +1 -1
  26. package/lib/_enums/http/socket-event.enum.js +13 -12
  27. package/lib/_enums/http/socket-event.enum.js.map +1 -1
  28. package/lib/_enums/index.d.ts +8 -8
  29. package/lib/_enums/index.js +13 -13
  30. package/lib/_enums/predefined-data-types.enum.d.ts +10 -10
  31. package/lib/_enums/predefined-data-types.enum.js +14 -14
  32. package/lib/_enums/predefined-data-types.enum.js.map +1 -1
  33. package/lib/_interfaces/certification-settings.interface.d.ts +7 -0
  34. package/lib/_interfaces/certification-settings.interface.d.ts.map +1 -0
  35. package/lib/_interfaces/certification-settings.interface.js +3 -0
  36. package/lib/_interfaces/certification-settings.interface.js.map +1 -0
  37. package/lib/_interfaces/global-service-settings.interface.d.ts +18 -0
  38. package/lib/_interfaces/global-service-settings.interface.d.ts.map +1 -0
  39. package/lib/_interfaces/global-service-settings.interface.js +3 -0
  40. package/lib/_interfaces/global-service-settings.interface.js.map +1 -0
  41. package/lib/_interfaces/index.d.ts +1 -0
  42. package/lib/_interfaces/index.d.ts.map +1 -0
  43. package/lib/_interfaces/index.js +4 -0
  44. package/lib/_interfaces/index.js.map +1 -0
  45. package/lib/_interfaces/port-settings.interface.d.ts +5 -0
  46. package/lib/_interfaces/port-settings.interface.d.ts.map +1 -0
  47. package/lib/_interfaces/port-settings.interface.js +3 -0
  48. package/lib/_interfaces/port-settings.interface.js.map +1 -0
  49. package/lib/_models/dynamo-nts-api-call-params.d.ts +95 -95
  50. package/lib/_models/dynamo-nts-api-call-params.js +47 -47
  51. package/lib/_models/dynamo-nts-app-params.d.ts +49 -49
  52. package/lib/_models/dynamo-nts-app-params.js +17 -17
  53. package/lib/_models/dynamo-nts-endpoint-params.d.ts +80 -80
  54. package/lib/_models/dynamo-nts-endpoint-params.js +139 -139
  55. package/lib/_models/dynamo-nts-global-settings.d.ts +53 -53
  56. package/lib/_models/dynamo-nts-global-settings.js +2 -2
  57. package/lib/_models/dynamo-nts-routing-module-settings.d.ts +19 -19
  58. package/lib/_models/dynamo-nts-routing-module-settings.js +2 -2
  59. package/lib/_models/dynamo-nts-socket-event-params.d.ts +32 -30
  60. package/lib/_models/dynamo-nts-socket-event-params.d.ts.map +1 -1
  61. package/lib/_models/dynamo-nts-socket-event-params.js +80 -79
  62. package/lib/_models/dynamo-nts-socket-event-params.js.map +1 -1
  63. package/lib/_models/dynamo-nts-socket-presence.d.ts +21 -0
  64. package/lib/_models/dynamo-nts-socket-presence.d.ts.map +1 -0
  65. package/lib/_models/dynamo-nts-socket-presence.js +45 -0
  66. package/lib/_models/dynamo-nts-socket-presence.js.map +1 -0
  67. package/lib/_models/dynamo-nts-socket-service-params.d.ts +18 -18
  68. package/lib/_models/dynamo-nts-socket-service-params.d.ts.map +1 -1
  69. package/lib/_models/dynamo-nts-socket-service-params.js +26 -26
  70. package/lib/_models/dynamo-nts-socket-service-params.js.map +1 -1
  71. package/lib/_models/index.d.ts +7 -8
  72. package/lib/_models/index.d.ts.map +1 -1
  73. package/lib/_models/index.js +12 -12
  74. package/lib/_models/index.js.map +1 -1
  75. package/lib/_modules/api-service.index.d.ts +5 -5
  76. package/lib/_modules/api-service.index.js +11 -11
  77. package/lib/_modules/app-extended.index.d.ts +15 -12
  78. package/lib/_modules/app-extended.index.d.ts.map +1 -1
  79. package/lib/_modules/app-extended.index.js +23 -19
  80. package/lib/_modules/app-extended.index.js.map +1 -1
  81. package/lib/_modules/app.index.d.ts +13 -10
  82. package/lib/_modules/app.index.d.ts.map +1 -1
  83. package/lib/_modules/app.index.js +21 -17
  84. package/lib/_modules/app.index.js.map +1 -1
  85. package/lib/_modules/auth.index.d.ts +3 -3
  86. package/lib/_modules/auth.index.js +8 -8
  87. package/lib/_modules/constants.index.d.ts +1 -1
  88. package/lib/_modules/constants.index.js +4 -4
  89. package/lib/_modules/controller.index.d.ts +4 -4
  90. package/lib/_modules/controller.index.js +10 -10
  91. package/lib/_modules/custom-data/custom-data.controller.d.ts +5 -5
  92. package/lib/_modules/custom-data/custom-data.controller.js +55 -55
  93. package/lib/_modules/custom-data/custom-data.service.d.ts +5 -5
  94. package/lib/_modules/custom-data/custom-data.service.js +11 -11
  95. package/lib/_modules/custom-data/get-custom-data-routing-module.d.ts +3 -3
  96. package/lib/_modules/custom-data/get-custom-data-routing-module.js +17 -17
  97. package/lib/_modules/custom-data/index.d.ts +4 -4
  98. package/lib/_modules/custom-data/index.js +8 -8
  99. package/lib/_modules/custom-data-module.index.d.ts +1 -1
  100. package/lib/_modules/custom-data-module.index.js +4 -4
  101. package/lib/_modules/data-service.index.d.ts +5 -5
  102. package/lib/_modules/data-service.index.js +10 -10
  103. package/lib/_modules/email.index.d.ts +3 -3
  104. package/lib/_modules/email.index.js +8 -8
  105. package/lib/_modules/enums.index.d.ts +1 -1
  106. package/lib/_modules/enums.index.js +4 -4
  107. package/lib/_modules/models.index.d.ts +1 -1
  108. package/lib/_modules/models.index.js +4 -4
  109. package/lib/_modules/services.index.d.ts +1 -1
  110. package/lib/_modules/services.index.js +4 -4
  111. package/lib/_modules/test/get-test-routing-module.d.ts +3 -3
  112. package/lib/_modules/test/get-test-routing-module.js +17 -17
  113. package/lib/_modules/test/index.d.ts +3 -3
  114. package/lib/_modules/test/index.js +7 -7
  115. package/lib/_modules/test/test.controller.d.ts +5 -5
  116. package/lib/_modules/test/test.controller.js +104 -104
  117. package/lib/_modules/test-module.index.d.ts +1 -1
  118. package/lib/_modules/test-module.index.js +4 -4
  119. package/lib/_modules/usage/get-usage-routing-module.d.ts +3 -3
  120. package/lib/_modules/usage/get-usage-routing-module.js +17 -17
  121. package/lib/_modules/usage/index.d.ts +4 -4
  122. package/lib/_modules/usage/index.js +8 -8
  123. package/lib/_modules/usage/usage-controller.d.ts +6 -6
  124. package/lib/_modules/usage/usage-controller.js +88 -88
  125. package/lib/_modules/usage/usage.service.d.ts +16 -16
  126. package/lib/_modules/usage/usage.service.js +132 -132
  127. package/lib/_modules/usage-module.index.d.ts +1 -1
  128. package/lib/_modules/usage-module.index.js +4 -4
  129. package/lib/_services/dynamo-nts-api.service.d.ts +34 -34
  130. package/lib/_services/dynamo-nts-api.service.js +188 -188
  131. package/lib/_services/dynamo-nts-app-extended.d.ts +128 -128
  132. package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -1
  133. package/lib/_services/dynamo-nts-app-extended.js +212 -212
  134. package/lib/_services/dynamo-nts-app-extended.js.map +1 -1
  135. package/lib/_services/dynamo-nts-app.d.ts +270 -278
  136. package/lib/_services/dynamo-nts-app.d.ts.map +1 -1
  137. package/lib/_services/dynamo-nts-app.js +371 -371
  138. package/lib/_services/dynamo-nts-app.js.map +1 -1
  139. package/lib/_services/dynamo-nts-app.spec.d.ts +1 -0
  140. package/lib/_services/dynamo-nts-app.spec.d.ts.map +1 -0
  141. package/lib/_services/dynamo-nts-app.spec.js +10 -0
  142. package/lib/_services/dynamo-nts-app.spec.js.map +1 -0
  143. package/lib/_services/dynamo-nts-auth.service.d.ts +127 -127
  144. package/lib/_services/dynamo-nts-auth.service.d.ts.map +1 -1
  145. package/lib/_services/dynamo-nts-auth.service.js +53 -53
  146. package/lib/_services/dynamo-nts-auth.service.js.map +1 -1
  147. package/lib/_services/dynamo-nts-controller.service.d.ts +105 -105
  148. package/lib/_services/dynamo-nts-controller.service.d.ts.map +1 -1
  149. package/lib/_services/dynamo-nts-controller.service.js +57 -57
  150. package/lib/_services/dynamo-nts-controller.service.js.map +1 -1
  151. package/lib/_services/dynamo-nts-data.service.d.ts +230 -230
  152. package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -1
  153. package/lib/_services/dynamo-nts-data.service.js +689 -689
  154. package/lib/_services/dynamo-nts-data.service.js.map +1 -1
  155. package/lib/_services/dynamo-nts-db-service-collection.service.d.ts +8 -8
  156. package/lib/_services/dynamo-nts-db-service-collection.service.js +10 -10
  157. package/lib/_services/dynamo-nts-db.service.d.ts +386 -312
  158. package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -1
  159. package/lib/_services/dynamo-nts-db.service.js +856 -856
  160. package/lib/_services/dynamo-nts-db.service.js.map +1 -1
  161. package/lib/_services/dynamo-nts-email-service-collection.service.d.ts +18 -18
  162. package/lib/_services/dynamo-nts-email-service-collection.service.js +20 -20
  163. package/lib/_services/dynamo-nts-email.service.d.ts +56 -56
  164. package/lib/_services/dynamo-nts-email.service.d.ts.map +1 -1
  165. package/lib/_services/dynamo-nts-email.service.js +203 -203
  166. package/lib/_services/dynamo-nts-email.service.js.map +1 -1
  167. package/lib/_services/dynamo-nts-global.service.d.ts +71 -84
  168. package/lib/_services/dynamo-nts-global.service.d.ts.map +1 -1
  169. package/lib/_services/dynamo-nts-global.service.js +156 -156
  170. package/lib/_services/dynamo-nts-global.service.js.map +1 -1
  171. package/lib/_services/dynamo-nts-routing-module.service.d.ts +76 -76
  172. package/lib/_services/dynamo-nts-routing-module.service.d.ts.map +1 -1
  173. package/lib/_services/dynamo-nts-routing-module.service.js +191 -191
  174. package/lib/_services/dynamo-nts-routing-module.service.js.map +1 -1
  175. package/lib/_services/dynamo-nts-shared.service.d.ts +31 -31
  176. package/lib/_services/dynamo-nts-shared.service.d.ts.map +1 -1
  177. package/lib/_services/dynamo-nts-shared.service.js +70 -70
  178. package/lib/_services/dynamo-nts-shared.service.js.map +1 -1
  179. package/lib/_services/dynamo-nts-shared.service.spec.d.ts +2 -0
  180. package/lib/_services/dynamo-nts-shared.service.spec.d.ts.map +1 -0
  181. package/lib/_services/dynamo-nts-shared.service.spec.js +12 -0
  182. package/lib/_services/dynamo-nts-shared.service.spec.js.map +1 -0
  183. package/lib/_services/dynamo-nts-singleton.service.d.ts +8 -8
  184. package/lib/_services/dynamo-nts-singleton.service.js +18 -18
  185. package/lib/_services/dynamo-nts-singleton.service.js.map +1 -1
  186. package/lib/_services/dynamo-nts-socket-service-collection.service.d.ts +9 -9
  187. package/lib/_services/dynamo-nts-socket-service-collection.service.js +13 -13
  188. package/lib/_services/dynamo-nts-socket.service.d.ts +57 -45
  189. package/lib/_services/dynamo-nts-socket.service.d.ts.map +1 -1
  190. package/lib/_services/dynamo-nts-socket.service.js +188 -165
  191. package/lib/_services/dynamo-nts-socket.service.js.map +1 -1
  192. package/lib/_services/index.d.ts +14 -16
  193. package/lib/_services/index.d.ts.map +1 -1
  194. package/lib/_services/index.js +20 -20
  195. package/lib/_services/index.js.map +1 -1
  196. package/lib/index.d.ts +6 -6
  197. package/lib/index.js +14 -14
  198. package/lib/tsconfig.tsbuildinfo +1 -1
  199. package/package SAVE.json +216 -0
  200. package/package-NEW with test but not working.json +228 -0
  201. package/package.json +14 -8
  202. package/spec/support/jasmine.json +14 -0
  203. package/src/_enums/http/socket-event.enum.ts +2 -1
  204. package/src/_interfaces/certification-settings.interface.ts +7 -0
  205. package/src/_interfaces/global-service-settings.interface.ts +23 -0
  206. package/src/_interfaces/index.ts +5 -0
  207. package/src/_interfaces/port-settings.interface.ts +5 -0
  208. package/src/_models/dynamo-nts-socket-event-params.ts +23 -21
  209. package/src/_models/{dynamo-nts-socket-dictionary.ts → dynamo-nts-socket-presence.ts} +21 -5
  210. package/src/_models/dynamo-nts-socket-service-params.ts +1 -0
  211. package/src/_models/index.ts +2 -2
  212. package/src/_modules/app-extended.index.ts +7 -2
  213. package/src/_modules/app.index.ts +5 -0
  214. package/src/_services/dynamo-nts-app-extended.ts +6 -2
  215. package/src/_services/dynamo-nts-app.spec.ts +14 -0
  216. package/src/_services/dynamo-nts-app.ts +8 -14
  217. package/src/_services/dynamo-nts-auth.service.ts +1 -0
  218. package/src/_services/dynamo-nts-controller.service.ts +2 -1
  219. package/src/_services/dynamo-nts-data.service.ts +19 -19
  220. package/src/_services/dynamo-nts-db.service.ts +195 -115
  221. package/src/_services/dynamo-nts-email.service.ts +1 -0
  222. package/src/_services/dynamo-nts-global.service.ts +3 -18
  223. package/src/_services/dynamo-nts-routing-module.service.ts +1 -0
  224. package/src/_services/dynamo-nts-shared.service.spec.ts +10 -0
  225. package/src/_services/dynamo-nts-shared.service.ts +2 -1
  226. package/src/_services/dynamo-nts-socket.service.ts +80 -41
  227. package/src/_services/index.ts +2 -2
@@ -1,12 +1,92 @@
1
1
 
2
2
  import * as mongoose from 'mongoose';
3
3
  import { Schema } from 'mongoose';
4
- import { Dynamo_Metadata, Dynamo_DataParams, Dynamo_DataPropertyParams, Dynamo_Error } from '@futdevpro/fsm-dynamo';
4
+
5
+ import {
6
+ Dynamo_Metadata, Dynamo_DataParams, Dynamo_DataPropertyParams, Dynamo_Error
7
+ } from '@futdevpro/fsm-dynamo';
8
+
9
+ /**
10
+ * @example
11
+ * // by email:
12
+ * { email: email }
13
+ * //
14
+ * @example
15
+ * // or by id that is in list:
16
+ * { userIds: { $in: this.userId } }
17
+ * //
18
+ * @example
19
+ * // or by number or Date that is Greater Than AND Less Than:
20
+ * { points: { $gt: 2, $lt: 14 } }
21
+ * // further tools (syntax matches with $gt):
22
+ * $eq: // Matches values that are EQual to a specified value.
23
+ * $gte: // Matches values that are Greater Than OR Equal to a specified value.
24
+ * $lte: // Matches values that are Less Than or Equal to a specified value.
25
+ * $ne: // Matches all values that are Not Equal to a specified value.
26
+ * $nin: // Matches None of the values specified IN an array.
27
+ * //
28
+ * @returns {T} data: T
29
+ */
30
+ export type DynamoNTS_DBFilter<T> = {
31
+ [K in keyof T]?: T[K] | {
32
+ $in?: any, // Matches values that are includes the value; This works only when T[K] is an array!
33
+ $eq?: T[K], // Matches values that are EQual to a specified value.
34
+ $gt?: number | Date, // Matches values that are Greater Than a specified value.
35
+ $gte?: number | Date, // Matches values that are Greater Than OR Equal to a specified value.
36
+ $lt?: number | Date, // Matches values that are Less Than a specified value.
37
+ $lte?: number | Date, // Matches values that are Less Than or Equal to a specified value.
38
+ $ne?: T[K], // Matches all values that are Not Equal to a specified value.
39
+ $nin?: T[K], // Matches None of the values specified IN an array.
40
+ };
41
+ };
42
+
43
+ /**
44
+ * @param update this uses the basic Mongoose updateOne
45
+ * @example
46
+ * // increase a specific value (here by 15):
47
+ * { $inc: { popularity: 15 } }
48
+ * //
49
+ * @example
50
+ * // or add element to a list:
51
+ * { $push: { reactions: this.newReaction }
52
+ * // or add multiple elements to a list
53
+ * { $push: { schedule: {$each: [ monday, tuesday, wednesday ] } } }
54
+ * //
55
+ * @example
56
+ * // or all at once
57
+ * {
58
+ * $inc: { popularity: this.newVote.amount },
59
+ * emailVerified: true,
60
+ * $push: { reactions: this.newReaction }
61
+ * }
62
+ * // further tools (syntax matches with $inc):
63
+ * $currentDate: // Sets the value of a field to current date, either as a Date or a Timestamp.
64
+ * $min: // Only updates the field if the specified value is less than the existing field value.
65
+ * $max: // Only updates the field if the specified value is greater than the existing field value.
66
+ * $mul: // Multiplies the value of the field by the specified amount.
67
+ * $rename: // Renames a field.
68
+ * $unset: // Removes the specified field from a document. (set: "" to value)
69
+ * //
70
+ */
71
+ export type DynamoNTS_DBUpdate<T> = {
72
+ [K in keyof T]?: T[K] | {
73
+ $inc?: number, // Increments the value of the field by the specified amount.
74
+ $push?: any | { // Adds an item to an array.
75
+ $each?: T[K], // Adds multiple items to an array.
76
+ }, // or add multiple elements to a list
77
+ // { $push: { schedule: {$each: [ monday, tuesday, wednesday ] } } }
78
+ $min?: number, // Only updates the field if the specified value is less than the existing field value.
79
+ $max?: number, // Only updates the field if the specified value is greater than the existing field value.
80
+ $mul?: number, // Multiplies the value of the field by the specified amount.
81
+ $rename?: string, // Renames a field.
82
+ $unset?: string, // Removes the specified field from a document. (set: "" to value)
83
+ };
84
+ };
5
85
 
6
86
  /**
7
87
  *
8
88
  */
9
- export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U extends T = any> {
89
+ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
10
90
  dataModel = mongoose.model(this.dataParams.dbName, this.getSchema());
11
91
 
12
92
  private depDataName: string;
@@ -47,7 +127,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
47
127
  status: 204,
48
128
  errorCode: 'NTS-DBS-CD1',
49
129
  addECToUserMsg: true,
50
- message: `save ${this.dataParams.dbName} result not found! (NTS DB)`,
130
+ message: `createData failed, save ${this.dataParams.dbName} result not found! (NTS DB)`,
51
131
  userMessage: this.defaultErrorUserMsg
52
132
  });
53
133
  }
@@ -59,7 +139,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
59
139
  status: 422,
60
140
  errorCode: 'NTS-DBS-CD0',
61
141
  addECToUserMsg: true,
62
- message: `Create new ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
142
+ message: `createData failed, Create new ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
63
143
  userMessage: this.defaultErrorUserMsg,
64
144
  error
65
145
  });
@@ -93,7 +173,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
93
173
  status: 204,
94
174
  errorCode: 'NTS-DBS-FU1',
95
175
  addECToUserMsg: true,
96
- message: `modify ${this.dataParams.dbName} result not found! (NTS DB)`,
176
+ message: `modifyData failed, modify ${this.dataParams.dbName} result not found! (NTS DB)`,
97
177
  userMessage: this.defaultErrorUserMsg,
98
178
  });
99
179
  }
@@ -102,7 +182,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
102
182
  status: 417,
103
183
  errorCode: 'NTS-DBS-FU0',
104
184
  addECToUserMsg: true,
105
- message: `modify ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
185
+ message: `modifyData ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
106
186
  userMessage: this.defaultErrorUserMsg,
107
187
  error
108
188
  });
@@ -266,15 +346,89 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
266
346
  return dataList;
267
347
  }
268
348
 
349
+ /**
350
+ * returns all data from database,
351
+ * !!!: throws error if not found (errorCode on not found: NTS-DBS-GA1)
352
+ *
353
+ * @returns dataList
354
+ */
355
+ async getAll(): Promise<T[]> {
356
+ let dataList: T[] = await this.dataModel.find({})
357
+ .then(res => {
358
+ return res as T[] ?? [];
359
+ }).catch(error => {
360
+ throw new Dynamo_Error({
361
+ status: 417,
362
+ errorCode: 'NTS-DBS-GA0',
363
+ addECToUserMsg: true,
364
+ message: `get all ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
365
+ userMessage: this.defaultErrorUserMsg,
366
+ error
367
+ });
368
+ });
369
+
370
+ if (0 < dataList.length && typeof dataList[0]._id === 'object') {
371
+ dataList.forEach((data: T) => {
372
+ data._id = `˙${data._id}`;
373
+ });
374
+ }
375
+
376
+ return dataList as T[];
377
+ }
378
+
379
+ /**
380
+ * deleted data by id
381
+ * @param id id
382
+ */
383
+ async deleteDataById(id: string): Promise<void> {
384
+ await this.dataModel.findByIdAndDelete(id).catch(error => {
385
+ throw new Dynamo_Error({
386
+ status: 417,
387
+ errorCode: 'NTS-DBS-DD0',
388
+ addECToUserMsg: true,
389
+ message: `delete ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
390
+ userMessage: this.defaultErrorUserMsg,
391
+ error
392
+ });
393
+ });
394
+ }
395
+
396
+ /**
397
+ * deleted data by id
398
+ * @param dependencyId id
399
+ */
400
+ async deleteDataByDependencyId(dependencyId: string): Promise<void> {
401
+ if (!this.depDataName) {
402
+ throw new Dynamo_Error({
403
+ status: 501,
404
+ errorCode: 'NTS-DBS-DDD0',
405
+ addECToUserMsg: true,
406
+ message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (NTS DB)`,
407
+ userMessage: this.defaultErrorUserMsg
408
+ });
409
+ }
410
+
411
+ await this.dataModel.deleteMany({ [this.depDataName]: dependencyId }).catch(error => {
412
+ throw new Dynamo_Error({
413
+ status: 417,
414
+ errorCode: 'NTS-DBS-DDD1',
415
+ addECToUserMsg: true,
416
+ message: `delete ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
417
+ userMessage: this.defaultErrorUserMsg,
418
+ error
419
+ });
420
+ });
421
+ }
422
+
269
423
  /**
270
424
  * returns search result for searchBy object params
271
425
  * can use lists or xRange values for searchBy obj properties
272
426
  *
273
- * @param searchBy filter
427
+ * @param filterBy filter
274
428
  * @param narrowByDependencyIds id
275
429
  * @returns dataList
276
430
  */
277
- async searchData(searchBy: F, narrowByDependencyIds?: string[]): Promise<T[]> {
431
+ async searchData(filterBy: DynamoNTS_DBFilter<T>, narrowByDependencyIds?: string[]): Promise<T[]> {
278
432
  const filter = {};
279
433
 
280
434
  if (0 < narrowByDependencyIds.length) {
@@ -293,45 +447,45 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
293
447
 
294
448
  await this.dataParams.modelParams.forEach((modelParam: Dynamo_DataPropertyParams) => {
295
449
  if (
296
- (searchBy[modelParam.key] !== null && searchBy[modelParam.key] !== undefined) ||
297
- searchBy[modelParam.key + 'Range']
450
+ (filterBy[modelParam.key] !== null && filterBy[modelParam.key] !== undefined) ||
451
+ filterBy[modelParam.key + 'Range']
298
452
  ) {
299
453
  if (modelParam.key.includes('Range') || modelParam.type.includes('[]')) {
300
454
  // inverz search filter (for Range and Array functions)
301
455
  if (modelParam.key.includes('Range')) {
302
456
  const searchParamKeyWithoutRange = modelParam.key.split('Range')[0];
303
457
  if (
304
- searchBy[searchParamKeyWithoutRange] !== null &&
305
- searchBy[searchParamKeyWithoutRange] !== undefined
458
+ filterBy[searchParamKeyWithoutRange] !== null &&
459
+ filterBy[searchParamKeyWithoutRange] !== undefined
306
460
  ) {
307
461
  filter[modelParam.key] = {
308
- from: { $lte: searchBy[searchParamKeyWithoutRange] },
309
- to: { $gte: searchBy[searchParamKeyWithoutRange] }
462
+ from: { $lte: filterBy[searchParamKeyWithoutRange] },
463
+ to: { $gte: filterBy[searchParamKeyWithoutRange] }
310
464
  };
311
465
  }
312
466
  } else {
313
467
  if (
314
- searchBy[modelParam.key] !== null &&
315
- searchBy[modelParam.key] !== undefined
468
+ filterBy[modelParam.key] !== null &&
469
+ filterBy[modelParam.key] !== undefined
316
470
  ) {
317
- filter[modelParam.key] = { $in: searchBy[modelParam.key] };
471
+ filter[modelParam.key] = { $in: filterBy[modelParam.key] };
318
472
  }
319
473
  }
320
474
  } else {
321
475
  // basic search filter
322
- if (searchBy[modelParam.key + 'Range']) {
323
- if (searchBy[modelParam.key + 'Range'].from || searchBy[modelParam.key + 'Range'].to) {
476
+ if (filterBy[modelParam.key + 'Range']) {
477
+ if (filterBy[modelParam.key + 'Range'].from || filterBy[modelParam.key + 'Range'].to) {
324
478
  filter[modelParam.key] = {};
325
- if (searchBy[modelParam.key + 'Range'].from) {
326
- filter[modelParam.key].$gte = searchBy[modelParam.key + 'Range'].from;
479
+ if (filterBy[modelParam.key + 'Range'].from) {
480
+ filter[modelParam.key].$gte = filterBy[modelParam.key + 'Range'].from;
327
481
  }
328
- if (searchBy[modelParam.key + 'Range'].to) {
329
- filter[modelParam.key].$lte = searchBy[modelParam.key + 'Range'].to;
482
+ if (filterBy[modelParam.key + 'Range'].to) {
483
+ filter[modelParam.key].$lte = filterBy[modelParam.key + 'Range'].to;
330
484
  }
331
485
  }
332
- } else if (searchBy[modelParam.key] !== null && searchBy[modelParam.key] !== undefined) {
333
- if (searchBy[modelParam.key].lenght > 0) {
334
- filter[modelParam.key] = { $in: searchBy[modelParam.key] };
486
+ } else if (filterBy[modelParam.key] !== null && filterBy[modelParam.key] !== undefined) {
487
+ if (filterBy[modelParam.key].lenght > 0) {
488
+ filter[modelParam.key] = { $in: filterBy[modelParam.key] };
335
489
  }
336
490
  }
337
491
  }
@@ -362,80 +516,6 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
362
516
  return dataList;
363
517
  }
364
518
 
365
- /**
366
- * returns all data from database,
367
- * !!!: throws error if not found (errorCode on not found: NTS-DBS-GA1)
368
- *
369
- * @returns dataList
370
- */
371
- async getAll(): Promise<T[]> {
372
- let dataList: T[] = await this.dataModel.find({})
373
- .then(res => {
374
- return res as T[] ?? [];
375
- }).catch(error => {
376
- throw new Dynamo_Error({
377
- status: 417,
378
- errorCode: 'NTS-DBS-GA0',
379
- addECToUserMsg: true,
380
- message: `get all ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
381
- userMessage: this.defaultErrorUserMsg,
382
- error
383
- });
384
- });
385
-
386
- if (0 < dataList.length && typeof dataList[0]._id === 'object') {
387
- dataList.forEach((data: T) => {
388
- data._id = `˙${data._id}`;
389
- });
390
- }
391
-
392
- return dataList as T[];
393
- }
394
-
395
- /**
396
- * deleted data by id
397
- * @param id id
398
- */
399
- async deleteDataById(id: string): Promise<void> {
400
- await this.dataModel.findByIdAndDelete(id).catch(error => {
401
- throw new Dynamo_Error({
402
- status: 417,
403
- errorCode: 'NTS-DBS-DD0',
404
- addECToUserMsg: true,
405
- message: `delete ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
406
- userMessage: this.defaultErrorUserMsg,
407
- error
408
- });
409
- });
410
- }
411
-
412
- /**
413
- * deleted data by id
414
- * @param dependencyId id
415
- */
416
- async deleteDataByDependencyId(dependencyId: string): Promise<void> {
417
- if (!this.depDataName) {
418
- throw new Dynamo_Error({
419
- status: 501,
420
- errorCode: 'NTS-DBS-DDD0',
421
- addECToUserMsg: true,
422
- message: `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) (NTS DB)`,
423
- userMessage: this.defaultErrorUserMsg
424
- });
425
- }
426
-
427
- await this.dataModel.deleteMany({ [this.depDataName]: dependencyId }).catch(error => {
428
- throw new Dynamo_Error({
429
- status: 417,
430
- errorCode: 'NTS-DBS-DDD1',
431
- addECToUserMsg: true,
432
- message: `delete ${this.dataParams.dbName} by ${this.depDataName} was unsuccessful (NTS DB)`,
433
- userMessage: this.defaultErrorUserMsg,
434
- error
435
- });
436
- });
437
- }
438
-
439
519
  // ----------------------------------------------------------------------------------
440
520
  // ----------------------------------------------------------------------------------
441
521
  // ----------------------------------------------------------------------------------
@@ -445,7 +525,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
445
525
  * Find the data first by any of its parameters,
446
526
  * !!!: throws error if not found (errorCode on not found: NTS-DBS-FO1)
447
527
  *
448
- * @param filter if you can, use unique parameters for find!
528
+ * @param filterBy if you can, use unique parameters for find!
449
529
  *
450
530
  * @example
451
531
  * // by email:
@@ -467,15 +547,15 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
467
547
  * //
468
548
  * @returns {T} data: T
469
549
  */
470
- async findOne(filter: F): Promise<T> {
471
- let data: T = await this.dataModel.findOne(filter).then(res => {
550
+ async findOne(filterBy: DynamoNTS_DBFilter<T>): Promise<T> {
551
+ let data: T = await this.dataModel.findOne(filterBy).then(res => {
472
552
  return res as T ?? null;
473
553
  }).catch(error => {
474
554
  throw new Dynamo_Error({
475
555
  status: 417,
476
556
  errorCode: 'NTS-DBS-FO0',
477
557
  addECToUserMsg: true,
478
- message: `findOne ${this.dataParams.dbName} was unsuccessful (NTS DB) fliter: ${filter}`,
558
+ message: `findOne ${this.dataParams.dbName} was unsuccessful (NTS DB) fliter: ${filterBy}`,
479
559
  userMessage: this.defaultErrorUserMsg,
480
560
  error
481
561
  });
@@ -493,7 +573,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
493
573
  * Find the data first by any of its parameters,
494
574
  * !!!: throws error if not found (errorCode on not found: NTS-DBS-F1)
495
575
  *
496
- * @param filter if you can, use unique parameters for find!
576
+ * @param filterBy if you can, use unique parameters for find!
497
577
  *
498
578
  * @example
499
579
  * // by email:
@@ -515,8 +595,8 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
515
595
  * //
516
596
  * @returns {T[]} dataList: T[]
517
597
  */
518
- async find(filter: F): Promise<T[]> {
519
- let dataList: T[] = await this.dataModel.find(filter)
598
+ async find(filterBy: DynamoNTS_DBFilter<T>): Promise<T[]> {
599
+ let dataList: T[] = await this.dataModel.find(filterBy)
520
600
  .then(res => {
521
601
  return res as T[] ?? [];
522
602
  }).catch(error => {
@@ -545,7 +625,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
545
625
  * #MONGOOSE FUNCTION
546
626
  * Find the data first by any of its parameters
547
627
  *
548
- * @param filter if you can, use unique parameters for find!
628
+ * @param filterBy if you can, use unique parameters for find!
549
629
  *
550
630
  * @example
551
631
  * // by email:
@@ -574,8 +654,8 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
574
654
  * //
575
655
  * @returns {T[]} dataList: T[]
576
656
  */
577
- async findWithPaging(filter: F, page: number, pageSize: number, sort?: any): Promise<T[]> {
578
- let dataList: T[] = await this.dataModel.find(filter)
657
+ async findWithPaging(filterBy: DynamoNTS_DBFilter<T>, page: number, pageSize: number, sort?: any): Promise<T[]> {
658
+ let dataList: T[] = await this.dataModel.find(filterBy)
579
659
  .sort(sort)
580
660
  .skip(page * pageSize)
581
661
  .limit(pageSize)
@@ -611,7 +691,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
611
691
  * @param update update
612
692
  * @returns data
613
693
  */
614
- async findByIdAndUpdate(id: string, update: U, modifier: string): Promise<T> {
694
+ async findByIdAndUpdate(id: string, update: DynamoNTS_DBUpdate<T>, modifier: string): Promise<T> {
615
695
  update.__lastModified = new Date();
616
696
  update.__lastModifiedBy = modifier;
617
697
 
@@ -687,11 +767,11 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
687
767
  * $unset: // Removes the specified field from a document. (set: "" to value)
688
768
  * //
689
769
  */
690
- async updateOne(updateBy: F, update: U, issuer: string): Promise<void> {
770
+ async updateOne(filterBy: DynamoNTS_DBFilter<T>, update: DynamoNTS_DBUpdate<T>, issuer: string): Promise<void> {
691
771
  update.__lastModified = new Date();
692
772
  update.__lastModifiedBy = issuer;
693
773
 
694
- await this.dataModel.updateOne(updateBy, update).catch(error => {
774
+ await this.dataModel.updateOne(filterBy, update).catch(error => {
695
775
  throw new Dynamo_Error({
696
776
  status: 417,
697
777
  errorCode: 'NTS-DBS-UO0',
@@ -754,11 +834,11 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata, F extends T = any, U
754
834
  * $unset: // Removes the specified field from a document. (set: "" to value)
755
835
  * //
756
836
  */
757
- async updateMany(updateBy: F, update: U, issuer: string): Promise<void> {
837
+ async updateMany(filterBy: DynamoNTS_DBFilter<T>, update: DynamoNTS_DBUpdate<T>, issuer: string): Promise<void> {
758
838
  update.__lastModified = new Date();
759
839
  update.__lastModifiedBy = issuer;
760
840
 
761
- await this.dataModel.updateMany(updateBy, update).catch(error => {
841
+ await this.dataModel.updateMany(filterBy, update).catch(error => {
762
842
  throw new Dynamo_Error({
763
843
  status: 417,
764
844
  errorCode: 'NTS-DBS-UM0',
@@ -3,6 +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
+
6
7
  import { Dynamo_Error, Dynamo_Log } from '@futdevpro/fsm-dynamo';
7
8
 
8
9
  /**
@@ -1,7 +1,9 @@
1
1
 
2
2
 
3
3
  import { Dynamo_Metadata, Dynamo_DataParams, Dynamo_Log } from '@futdevpro/fsm-dynamo';
4
- import { DynamoNTS_AppParams } from '../_models';
4
+
5
+ import { DynamoNTS_GlobalServiceSettings } from '../_interfaces/global-service-settings.interface';
6
+ import { DynamoNTS_AppParams } from '../_models/dynamo-nts-app-params';
5
7
 
6
8
  import { DynamoNTS_AuthService } from './dynamo-nts-auth.service';
7
9
  import { DynamoNTS_DBServiceCollection } from './dynamo-nts-db-service-collection.service';
@@ -11,23 +13,6 @@ import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
11
13
  import { DynamoNTS_SocketServiceCollection } from './dynamo-nts-socket-service-collection.service';
12
14
  import { DynamoNTS_SocketService } from './dynamo-nts-socket.service';
13
15
 
14
- export interface DynamoNTS_GlobalServiceSettings {
15
- /**
16
- * You need to setup your Own Auth Service extending the DynamoBEAuthService class
17
- */
18
- authService?: DynamoNTS_AuthService,
19
-
20
- /**
21
- * You can setup your Own Email Service extending the DynamoBEEmailServiceCollection class
22
- */
23
- emailServiceCollection?: DynamoNTS_EmailServiceCollection,
24
-
25
- /**
26
- * you can setup data tables by passing a DynamoBEDataParams list at this point
27
- */
28
- dbModels: Dynamo_DataParams[],
29
- }
30
-
31
16
  /**
32
17
  * This is the main Global/Core Service Collection used by DynamoBE,
33
18
  * you also can use this to access main services as
@@ -1,5 +1,6 @@
1
1
 
2
2
  import { Router } from 'express';
3
+
3
4
  import { Dynamo_Error, Dynamo_Log } from '@futdevpro/fsm-dynamo';
4
5
 
5
6
  import { dynamoNTS_GlobalSettings } from '../_constants/dynamo-nts-global-settings';
@@ -0,0 +1,10 @@
1
+ import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
2
+
3
+ describe('DynamoNTS_Shared', () => {
4
+ it('fns should be accessible', () => {
5
+ expect(DynamoNTS_Shared.getIpFromRequest).toBeTruthy();
6
+ expect(DynamoNTS_Shared.getLocationDataByRequest).toBeTruthy();
7
+ expect(DynamoNTS_Shared.getLocationByIp).toBeTruthy();
8
+ expect(DynamoNTS_Shared.prompt).toBeTruthy();
9
+ });
10
+ });
@@ -1,7 +1,8 @@
1
1
 
2
2
  import * as ReadLine from 'readline';
3
- import { Request } from 'express';
4
3
  import * as GeoIp from 'geoip-lite';
4
+ import { Request } from 'express';
5
+
5
6
  import { GeoIpLocation, Dynamo_Shared } from '@futdevpro/fsm-dynamo/shared-service';
6
7
 
7
8
  /**