@futdevpro/nts-dynamo 1.7.27 → 1.8.5

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 (222) hide show
  1. package/lib/_constants/global-settings.const.d.ts +2 -2
  2. package/lib/_constants/global-settings.const.d.ts.map +1 -1
  3. package/lib/_constants/global-settings.const.js +2 -2
  4. package/lib/_constants/global-settings.const.js.map +1 -1
  5. package/lib/_constants/mocks/app-extended-server.mock.d.ts +12 -12
  6. package/lib/_constants/mocks/app-extended-server.mock.d.ts.map +1 -1
  7. package/lib/_constants/mocks/app-extended-server.mock.js +16 -16
  8. package/lib/_constants/mocks/app-extended-server.mock.js.map +1 -1
  9. package/lib/_constants/mocks/app-params.mock.d.ts +2 -2
  10. package/lib/_constants/mocks/app-params.mock.d.ts.map +1 -1
  11. package/lib/_constants/mocks/app-params.mock.js +1 -1
  12. package/lib/_constants/mocks/app-params.mock.js.map +1 -1
  13. package/lib/_constants/mocks/app-server.mock.d.ts +15 -15
  14. package/lib/_constants/mocks/app-server.mock.d.ts.map +1 -1
  15. package/lib/_constants/mocks/app-server.mock.js +10 -10
  16. package/lib/_constants/mocks/app-server.mock.js.map +1 -1
  17. package/lib/_constants/mocks/data-model.mock.d.ts +3 -3
  18. package/lib/_constants/mocks/data-model.mock.d.ts.map +1 -1
  19. package/lib/_constants/mocks/data-model.mock.js +22 -22
  20. package/lib/_constants/mocks/data-model.mock.js.map +1 -1
  21. package/lib/_constants/mocks/email-service-collection.mock.d.ts +2 -2
  22. package/lib/_constants/mocks/email-service-collection.mock.d.ts.map +1 -1
  23. package/lib/_constants/mocks/email-service-collection.mock.js +1 -1
  24. package/lib/_constants/mocks/email-service-collection.mock.js.map +1 -1
  25. package/lib/_constants/mocks/endpoint.mock.d.ts +8 -8
  26. package/lib/_constants/mocks/endpoint.mock.d.ts.map +1 -1
  27. package/lib/_constants/mocks/endpoint.mock.js +18 -18
  28. package/lib/_constants/mocks/endpoint.mock.js.map +1 -1
  29. package/lib/_constants/mocks/socket-client.mock.d.ts +2 -2
  30. package/lib/_constants/mocks/socket-client.mock.d.ts.map +1 -1
  31. package/lib/_constants/mocks/socket-client.mock.js +1 -1
  32. package/lib/_constants/mocks/socket-client.mock.js.map +1 -1
  33. package/lib/_constants/mocks/socket-server.mock.d.ts +2 -2
  34. package/lib/_constants/mocks/socket-server.mock.d.ts.map +1 -1
  35. package/lib/_constants/mocks/socket-server.mock.js +1 -1
  36. package/lib/_constants/mocks/socket-server.mock.js.map +1 -1
  37. package/lib/_enums/data-model-type.enum.d.ts +1 -0
  38. package/lib/_enums/data-model-type.enum.d.ts.map +1 -1
  39. package/lib/_enums/data-model-type.enum.js +1 -0
  40. package/lib/_enums/data-model-type.enum.js.map +1 -1
  41. package/lib/_models/control-models/api-call-params.control-model.d.ts +3 -3
  42. package/lib/_models/control-models/api-call-params.control-model.d.ts.map +1 -1
  43. package/lib/_models/control-models/api-call-params.control-model.js +5 -5
  44. package/lib/_models/control-models/api-call-params.control-model.js.map +1 -1
  45. package/lib/_models/control-models/{app-system-controls.control-model copy.d.ts → app-ext-system-controls.control-model.d.ts} +1 -1
  46. package/lib/_models/control-models/app-ext-system-controls.control-model.d.ts.map +1 -0
  47. package/lib/_models/control-models/{app-system-controls.control-model copy.js → app-ext-system-controls.control-model.js} +1 -1
  48. package/lib/_models/control-models/app-ext-system-controls.control-model.js.map +1 -0
  49. package/lib/_models/control-models/app-params.control-model.d.ts +2 -2
  50. package/lib/_models/control-models/app-params.control-model.d.ts.map +1 -1
  51. package/lib/_models/control-models/app-params.control-model.js +3 -3
  52. package/lib/_models/control-models/app-params.control-model.js.map +1 -1
  53. package/lib/_models/control-models/endpoint-params.control-model.d.ts +1 -1
  54. package/lib/_models/control-models/endpoint-params.control-model.d.ts.map +1 -1
  55. package/lib/_models/control-models/endpoint-params.control-model.js +8 -8
  56. package/lib/_models/control-models/endpoint-params.control-model.js.map +1 -1
  57. package/lib/_models/control-models/http-settings.control-model.d.ts +2 -2
  58. package/lib/_models/control-models/http-settings.control-model.d.ts.map +1 -1
  59. package/lib/_models/control-models/http-settings.control-model.js +3 -3
  60. package/lib/_models/control-models/http-settings.control-model.js.map +1 -1
  61. package/lib/_models/control-models/socket-client-service-params.control-model.d.ts +2 -2
  62. package/lib/_models/control-models/socket-client-service-params.control-model.d.ts.map +1 -1
  63. package/lib/_models/control-models/socket-client-service-params.control-model.js +3 -3
  64. package/lib/_models/control-models/socket-client-service-params.control-model.js.map +1 -1
  65. package/lib/_models/control-models/socket-event.control-model.js +4 -4
  66. package/lib/_models/control-models/socket-presence.control-model.d.ts +12 -0
  67. package/lib/_models/control-models/socket-presence.control-model.d.ts.map +1 -1
  68. package/lib/_models/control-models/socket-presence.control-model.js +14 -3
  69. package/lib/_models/control-models/socket-presence.control-model.js.map +1 -1
  70. package/lib/_models/control-models/socket-server-service-params.control-model.d.ts +2 -2
  71. package/lib/_models/control-models/socket-server-service-params.control-model.d.ts.map +1 -1
  72. package/lib/_models/control-models/socket-server-service-params.control-model.js +4 -4
  73. package/lib/_models/control-models/socket-server-service-params.control-model.js.map +1 -1
  74. package/lib/_models/interfaces/certification-settings.interface.d.ts +1 -1
  75. package/lib/_models/interfaces/certification-settings.interface.d.ts.map +1 -1
  76. package/lib/_models/interfaces/global-service-settings.interface.d.ts +6 -6
  77. package/lib/_models/interfaces/global-service-settings.interface.d.ts.map +1 -1
  78. package/lib/_models/interfaces/global-settings.interface.d.ts +1 -1
  79. package/lib/_models/interfaces/global-settings.interface.d.ts.map +1 -1
  80. package/lib/_models/interfaces/routing-module-settings.interface.d.ts +1 -1
  81. package/lib/_models/interfaces/routing-module-settings.interface.d.ts.map +1 -1
  82. package/lib/_models/types/db-filter.type.d.ts.map +1 -1
  83. package/lib/_models/types/db-update.type.d.ts +2 -1
  84. package/lib/_models/types/db-update.type.d.ts.map +1 -1
  85. package/lib/_modules/custom-data/custom-data.controller.d.ts +2 -2
  86. package/lib/_modules/custom-data/custom-data.controller.d.ts.map +1 -1
  87. package/lib/_modules/custom-data/custom-data.controller.js +18 -16
  88. package/lib/_modules/custom-data/custom-data.controller.js.map +1 -1
  89. package/lib/_modules/custom-data/custom-data.data-service.d.ts +1 -1
  90. package/lib/_modules/custom-data/custom-data.data-service.d.ts.map +1 -1
  91. package/lib/_modules/custom-data/custom-data.data-service.js +4 -4
  92. package/lib/_modules/custom-data/custom-data.data-service.js.map +1 -1
  93. package/lib/_modules/custom-data/get-custom-data-routing-module.util.d.ts +1 -1
  94. package/lib/_modules/custom-data/get-custom-data-routing-module.util.d.ts.map +1 -1
  95. package/lib/_modules/custom-data/get-custom-data-routing-module.util.js +5 -5
  96. package/lib/_modules/custom-data/get-custom-data-routing-module.util.js.map +1 -1
  97. package/lib/_modules/test/get-test-routing-module.util.d.ts +1 -1
  98. package/lib/_modules/test/get-test-routing-module.util.d.ts.map +1 -1
  99. package/lib/_modules/test/get-test-routing-module.util.js +5 -5
  100. package/lib/_modules/test/get-test-routing-module.util.js.map +1 -1
  101. package/lib/_modules/test/test.controller.d.ts +2 -2
  102. package/lib/_modules/test/test.controller.d.ts.map +1 -1
  103. package/lib/_modules/test/test.controller.js +33 -33
  104. package/lib/_modules/test/test.controller.js.map +1 -1
  105. package/lib/_modules/usage/get-usage-routing-module.util.d.ts +1 -1
  106. package/lib/_modules/usage/get-usage-routing-module.util.d.ts.map +1 -1
  107. package/lib/_modules/usage/get-usage-routing-module.util.js +5 -5
  108. package/lib/_modules/usage/get-usage-routing-module.util.js.map +1 -1
  109. package/lib/_modules/usage/usage.controller.d.ts +2 -2
  110. package/lib/_modules/usage/usage.controller.d.ts.map +1 -1
  111. package/lib/_modules/usage/usage.controller.js +16 -16
  112. package/lib/_modules/usage/usage.controller.js.map +1 -1
  113. package/lib/_modules/usage/usage.data-service.d.ts +1 -1
  114. package/lib/_modules/usage/usage.data-service.d.ts.map +1 -1
  115. package/lib/_modules/usage/usage.data-service.js +4 -4
  116. package/lib/_modules/usage/usage.data-service.js.map +1 -1
  117. package/lib/_services/base/data.service.d.ts +4 -3
  118. package/lib/_services/base/data.service.d.ts.map +1 -1
  119. package/lib/_services/base/data.service.js +22 -18
  120. package/lib/_services/base/data.service.js.map +1 -1
  121. package/lib/_services/base/db.service.d.ts +3 -3
  122. package/lib/_services/base/db.service.d.ts.map +1 -1
  123. package/lib/_services/base/db.service.js +11 -7
  124. package/lib/_services/base/db.service.js.map +1 -1
  125. package/lib/_services/core/api.service.d.ts +4 -4
  126. package/lib/_services/core/api.service.d.ts.map +1 -1
  127. package/lib/_services/core/api.service.js +9 -9
  128. package/lib/_services/core/api.service.js.map +1 -1
  129. package/lib/_services/core/email.service.d.ts +4 -4
  130. package/lib/_services/core/email.service.d.ts.map +1 -1
  131. package/lib/_services/core/email.service.js.map +1 -1
  132. package/lib/_services/core/global.service.d.ts +12 -12
  133. package/lib/_services/core/global.service.d.ts.map +1 -1
  134. package/lib/_services/core/global.service.js +14 -1
  135. package/lib/_services/core/global.service.js.map +1 -1
  136. package/lib/_services/core/service-collection.service.d.ts +1 -1
  137. package/lib/_services/core/service-collection.service.d.ts.map +1 -1
  138. package/lib/_services/core/service-collection.service.js +3 -3
  139. package/lib/_services/core/service-collection.service.js.map +1 -1
  140. package/lib/_services/route/controller.service.d.ts +2 -2
  141. package/lib/_services/route/controller.service.d.ts.map +1 -1
  142. package/lib/_services/route/controller.service.js.map +1 -1
  143. package/lib/_services/route/routing-module.service.d.ts +4 -4
  144. package/lib/_services/route/routing-module.service.d.ts.map +1 -1
  145. package/lib/_services/route/routing-module.service.js +2 -2
  146. package/lib/_services/route/routing-module.service.js.map +1 -1
  147. package/lib/_services/server/app-extended.server.d.ts +2 -2
  148. package/lib/_services/server/app-extended.server.js +5 -5
  149. package/lib/_services/server/app-extended.server.js.map +1 -1
  150. package/lib/_services/server/app-extended.server.spec.js +3 -3
  151. package/lib/_services/server/app-extended.server.spec.js.map +1 -1
  152. package/lib/_services/server/app.server.d.ts +14 -14
  153. package/lib/_services/server/app.server.d.ts.map +1 -1
  154. package/lib/_services/server/app.server.js +8 -8
  155. package/lib/_services/server/app.server.js.map +1 -1
  156. package/lib/_services/server/app.server.spec.js +3 -3
  157. package/lib/_services/server/app.server.spec.js.map +1 -1
  158. package/lib/_services/shared.static-service.d.ts +3 -3
  159. package/lib/_services/shared.static-service.d.ts.map +1 -1
  160. package/lib/_services/shared.static-service.js +1 -1
  161. package/lib/_services/shared.static-service.js.map +1 -1
  162. package/lib/_services/socket/socket-client.service.d.ts +3 -3
  163. package/lib/_services/socket/socket-client.service.d.ts.map +1 -1
  164. package/lib/_services/socket/socket-client.service.js +24 -18
  165. package/lib/_services/socket/socket-client.service.js.map +1 -1
  166. package/lib/_services/socket/socket-server.service.d.ts +3 -3
  167. package/lib/_services/socket/socket-server.service.d.ts.map +1 -1
  168. package/lib/_services/socket/socket-server.service.js +5 -5
  169. package/lib/_services/socket/socket-server.service.js.map +1 -1
  170. package/lib/tsconfig.tsbuildinfo +1 -1
  171. package/package.json +2 -2
  172. package/src/_constants/global-settings.const.ts +2 -2
  173. package/src/_constants/mocks/app-extended-server.mock.ts +34 -35
  174. package/src/_constants/mocks/app-params.mock.ts +2 -2
  175. package/src/_constants/mocks/app-server.mock.ts +30 -30
  176. package/src/_constants/mocks/data-model.mock.ts +23 -23
  177. package/src/_constants/mocks/email-service-collection.mock.ts +2 -2
  178. package/src/_constants/mocks/endpoint.mock.ts +22 -22
  179. package/src/_constants/mocks/socket-client.mock.ts +3 -3
  180. package/src/_constants/mocks/socket-server.mock.ts +3 -3
  181. package/src/_enums/data-model-type.enum.ts +1 -0
  182. package/src/_models/control-models/api-call-params.control-model.ts +3 -3
  183. package/src/_models/control-models/app-params.control-model.ts +2 -2
  184. package/src/_models/control-models/endpoint-params.control-model.ts +7 -7
  185. package/src/_models/control-models/http-settings.control-model.ts +2 -2
  186. package/src/_models/control-models/socket-client-service-params.control-model.ts +2 -2
  187. package/src/_models/control-models/socket-event.control-model.ts +5 -5
  188. package/src/_models/control-models/socket-presence.control-model.ts +24 -4
  189. package/src/_models/control-models/socket-server-service-params.control-model.ts +4 -4
  190. package/src/_models/interfaces/certification-settings.interface.ts +1 -1
  191. package/src/_models/interfaces/global-service-settings.interface.ts +6 -6
  192. package/src/_models/interfaces/global-settings.interface.ts +1 -1
  193. package/src/_models/interfaces/routing-module-settings.interface.ts +1 -1
  194. package/src/_models/types/db-filter.type.ts +5 -2
  195. package/src/_models/types/db-update.type.ts +3 -2
  196. package/src/_modules/custom-data/custom-data.controller.ts +20 -18
  197. package/src/_modules/custom-data/custom-data.data-service.ts +6 -4
  198. package/src/_modules/custom-data/get-custom-data-routing-module.util.ts +7 -7
  199. package/src/_modules/test/get-test-routing-module.util.ts +7 -7
  200. package/src/_modules/test/test.controller.ts +34 -34
  201. package/src/_modules/usage/get-usage-routing-module.util.ts +7 -7
  202. package/src/_modules/usage/usage.controller.ts +18 -19
  203. package/src/_modules/usage/usage.data-service.ts +3 -3
  204. package/src/_services/base/data.service.ts +32 -25
  205. package/src/_services/base/db.service.ts +17 -14
  206. package/src/_services/core/api.service.ts +22 -22
  207. package/src/_services/core/email.service.ts +4 -4
  208. package/src/_services/core/global.service.ts +29 -15
  209. package/src/_services/core/service-collection.service.ts +1 -1
  210. package/src/_services/route/controller.service.ts +2 -2
  211. package/src/_services/route/routing-module.service.ts +12 -12
  212. package/src/_services/server/app-extended.server.spec.ts +4 -4
  213. package/src/_services/server/app-extended.server.ts +5 -5
  214. package/src/_services/server/app.server.spec.ts +4 -4
  215. package/src/_services/server/app.server.ts +27 -27
  216. package/src/_services/shared.static-service.ts +7 -4
  217. package/src/_services/socket/socket-client.service.ts +69 -37
  218. package/src/_services/socket/socket-server.service.ts +9 -9
  219. package/tsconfig.json +1 -0
  220. package/lib/_models/control-models/app-system-controls.control-model copy.d.ts.map +0 -1
  221. package/lib/_models/control-models/app-system-controls.control-model copy.js.map +0 -1
  222. /package/src/_models/control-models/{app-system-controls.control-model copy.ts → app-ext-system-controls.control-model.ts} +0 -0
@@ -2,7 +2,7 @@
2
2
  import { Request, Response } from 'express';
3
3
 
4
4
  import {
5
- usageModuleSettings, Dynamo_UsageSession, Dynamo_RelativeDate
5
+ Dynamo_usageModule_settings, Dynamo_UsageSession, Dynamo_RelativeDate
6
6
  } from '@futdevpro/fsm-dynamo/usage-module';
7
7
 
8
8
  import { DynamoNTS_HttpCallType } from '../../_enums/http/http-call-type.enum';
@@ -10,14 +10,14 @@ import { DynamoNTS_AuthService } from '../../_services/core/auth.service';
10
10
  import { DynamoNTS_Controller } from '../../_services/route/controller.service';
11
11
  import { DynamoNTS_GlobalService } from '../../_services/core/global.service';
12
12
  import {
13
- DynamoNTS_EndpointParams
13
+ DynamoNTS_Endpoint_Params
14
14
  } from '../../_models/control-models/endpoint-params.control-model';
15
- import { UsageService } from './usage.data-service';
15
+ import { DynamoNTS_Usage_DataService } from './usage.data-service';
16
16
 
17
- export class UsageController extends DynamoNTS_Controller {
17
+ export class DynamoNTS_Usage_Controller extends DynamoNTS_Controller {
18
18
 
19
- static getInstance(): UsageController {
20
- return UsageController.getSingletonInstance();
19
+ static getInstance(): DynamoNTS_Usage_Controller {
20
+ return DynamoNTS_Usage_Controller.getSingletonInstance();
21
21
  }
22
22
 
23
23
  // SERVICES
@@ -27,15 +27,15 @@ export class UsageController extends DynamoNTS_Controller {
27
27
  this.authService = DynamoNTS_GlobalService.getAuthService();
28
28
 
29
29
  this.endpoints = [
30
- new DynamoNTS_EndpointParams({
30
+ new DynamoNTS_Endpoint_Params({
31
31
  name: 'newSession',
32
32
  type: DynamoNTS_HttpCallType.get,
33
- endpoint: usageModuleSettings.endPoints.newSession,
33
+ endpoint: Dynamo_usageModule_settings.endPoints.newSession,
34
34
  tasks: [
35
35
  async (req: Request, res: Response, issuer: string): Promise<void> => {
36
36
  const authService = DynamoNTS_GlobalService.getAuthService();
37
37
  const username = authService.getUsernameFromRequest(req);
38
- const usageService = new UsageService({
38
+ const usageService = new DynamoNTS_Usage_DataService({
39
39
  usageSession: new Dynamo_UsageSession({
40
40
  sessionStart: new Date(),
41
41
  issuer: username,
@@ -53,14 +53,14 @@ export class UsageController extends DynamoNTS_Controller {
53
53
  ],
54
54
  }),
55
55
 
56
- new DynamoNTS_EndpointParams({
56
+ new DynamoNTS_Endpoint_Params({
57
57
  name: 'updateUsage',
58
58
  type: DynamoNTS_HttpCallType.post,
59
- endpoint: usageModuleSettings.endPoints.updateUsage,
59
+ endpoint: Dynamo_usageModule_settings.endPoints.updateUsage,
60
60
  logRequestsContent: false,
61
61
  tasks: [
62
62
  async (req: Request, res: Response, issuer: string): Promise<void> => {
63
- const usageService = new UsageService({
63
+ const usageService = new DynamoNTS_Usage_DataService({
64
64
  usageSession: { _id: req.params.sessionId },
65
65
  usageData: req.body,
66
66
  issuer,
@@ -75,13 +75,13 @@ export class UsageController extends DynamoNTS_Controller {
75
75
  ],
76
76
  }),
77
77
 
78
- new DynamoNTS_EndpointParams({
78
+ new DynamoNTS_Endpoint_Params({
79
79
  name: 'closeSession',
80
80
  type: DynamoNTS_HttpCallType.get,
81
- endpoint: usageModuleSettings.endPoints.closeSession,
81
+ endpoint: Dynamo_usageModule_settings.endPoints.closeSession,
82
82
  tasks: [
83
83
  async (req: Request, res: Response, issuer: string): Promise<void> => {
84
- const usageService = new UsageService({
84
+ const usageService = new DynamoNTS_Usage_DataService({
85
85
  usageSession: { _id: req.params.sessionId },
86
86
  issuer,
87
87
  });
@@ -95,16 +95,16 @@ export class UsageController extends DynamoNTS_Controller {
95
95
  ],
96
96
  }),
97
97
 
98
- new DynamoNTS_EndpointParams({
98
+ new DynamoNTS_Endpoint_Params({
99
99
  name: 'getUsageData',
100
100
  type: DynamoNTS_HttpCallType.get,
101
- endpoint: usageModuleSettings.endPoints.getUsageData,
101
+ endpoint: Dynamo_usageModule_settings.endPoints.getUsageData,
102
102
  preProcessess: [this.authService.authTokenPermAccUsageData],
103
103
  tasks: [
104
104
  async (req: Request, res: Response): Promise<void> => {
105
105
  const range: Dynamo_RelativeDate = req.params.range as Dynamo_RelativeDate;
106
106
 
107
- const usageService = new UsageService();
107
+ const usageService = new DynamoNTS_Usage_DataService();
108
108
 
109
109
  await usageService.getUsage(range);
110
110
 
@@ -114,7 +114,6 @@ export class UsageController extends DynamoNTS_Controller {
114
114
  },
115
115
  ],
116
116
  }),
117
-
118
117
  ];
119
118
  }
120
119
  }
@@ -1,13 +1,13 @@
1
1
 
2
2
  import { Request } from 'express';
3
3
  import { Dynamo_Error, Dynamo_Time, Dynamo_RelativeDate } from '@futdevpro/fsm-dynamo';
4
- import { Dynamo_UsageSession, usageSessionModelParams, Dynamo_UsageData,
4
+ import { Dynamo_UsageSession, Dynamo_usageSessionModel_params, Dynamo_UsageData,
5
5
  Dynamo_DailyUsageData } from '@futdevpro/fsm-dynamo/usage-module';
6
6
 
7
7
  import { DynamoNTS_DataService } from '../../_services/base/data.service';
8
8
  import { DynamoNTS_Shared } from '../../_services/shared.static-service';
9
9
 
10
- export class UsageService extends DynamoNTS_DataService<Dynamo_UsageSession> {
10
+ export class DynamoNTS_Usage_DataService extends DynamoNTS_DataService<Dynamo_UsageSession> {
11
11
  usageData: Dynamo_UsageData[] = [];
12
12
  simplifiedDailyUsage: Dynamo_DailyUsageData[] = [];
13
13
 
@@ -20,7 +20,7 @@ export class UsageService extends DynamoNTS_DataService<Dynamo_UsageSession> {
20
20
  ) {
21
21
  super(
22
22
  new Dynamo_UsageSession(set?.usageSession),
23
- usageSessionModelParams,
23
+ Dynamo_usageSessionModel_params,
24
24
  set?.issuer
25
25
  );
26
26
  this.usageData = set?.usageData ? set?.usageData : [];
@@ -1,6 +1,7 @@
1
1
 
2
2
  import {
3
- Dynamo_Metadata, Dynamo_DataParams, Dynamo_DataPropertyParams, Dynamo_Error, Dynamo_Log, Dynamo_AnyError, Dynamo_Error_Settings
3
+ Dynamo_Metadata, Dynamo_DataModel_Params, Dynamo_DataProperty_Params, Dynamo_Error,
4
+ Dynamo_Log, Dynamo_AnyError, Dynamo_Error_Settings
4
5
  } from '@futdevpro/fsm-dynamo';
5
6
  import { DynamoNTS_DBFilter } from '../../_models/types/db-filter.type';
6
7
  import { DynamoNTS_DBUpdate } from '../../_models/types/db-update.type';
@@ -39,9 +40,10 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
39
40
  depKey?: string;
40
41
  depDBServiceKey?: string;
41
42
  depKeyIsUnique?: boolean;
43
+ depKeyIsRequired?: boolean;
42
44
  private depDataDBService: DynamoNTS_DBService<any>;
43
45
 
44
- dataParams: Dynamo_DataParams;
46
+ dataParams: Dynamo_DataModel_Params;
45
47
 
46
48
  defaultErrorUserMsg: string =
47
49
  `We encountered an unhandled Data Service Error, ` +
@@ -58,11 +60,11 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
58
60
  /**
59
61
  * DB data prams will be used to connect to usable dbService on GlobalService
60
62
  */
61
- dataParams: Dynamo_DataParams,
63
+ dataParams: Dynamo_DataModel_Params,
62
64
  /**
63
65
  * Initial set for issuer to be able to follow the issuer's activity
64
66
  */
65
- issuer: string,
67
+ issuer: string
66
68
  ) {
67
69
  try {
68
70
  this.serviceName = this.constructor?.name;
@@ -181,7 +183,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
181
183
  return [];
182
184
  }
183
185
 
184
- const datas: T[] = await this.dataDBService.find({ _id: { $in: ids, }, });
186
+ const datas: T[] = await this.dataDBService.find({ _id: { $in: ids } });
185
187
 
186
188
  if (!dontSetToService) {
187
189
  this.dataList = datas;
@@ -381,6 +383,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
381
383
  ...this._getDefaultErrorSettings('getDataListByDependencyId', error),
382
384
 
383
385
  errorCode: 'NTS-DS0-GLD0',
386
+
384
387
  });
385
388
  }
386
389
  }
@@ -685,13 +688,13 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
685
688
 
686
689
  return this.data;
687
690
 
688
- } else {
691
+ } else if (this.depKeyIsRequired) {
689
692
  // if data not exists check that dependency already exists for this
690
693
  const dependencyExists = await this.getDependencyDataDBService()
691
694
  .getDataById(this.data[this.depKey])
692
- .catch((error): null => null);
695
+ .catch();
693
696
 
694
- if(!dependencyExists) {
697
+ if (!dependencyExists) {
695
698
  throw new Dynamo_Error({
696
699
  ...this._getDefaultErrorSettings(
697
700
  'saveData',
@@ -763,17 +766,17 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
763
766
  */
764
767
  async validateForSave(): Promise<void> {
765
768
  try {
766
- for (let i = 0; i < this.dataParams.modelParams.length; i++) {
769
+ for (let i = 0; i < this.dataParams.properties.length; i++) {
767
770
  // basic required validations
768
771
  if (
769
- (this.dataParams.modelParams[i].required &&
770
- (this.data[this.dataParams.modelParams[i].key] === null ||
771
- this.data[this.dataParams.modelParams[i].key] === undefined
772
+ (this.dataParams.properties[i].required &&
773
+ (this.data[this.dataParams.properties[i].key] === null ||
774
+ this.data[this.dataParams.properties[i].key] === undefined
772
775
  )
773
776
  ) ||
774
- (this.dataParams.modelParams[i].index &&
775
- (this.data[this.dataParams.modelParams[i].key] === null ||
776
- this.data[this.dataParams.modelParams[i].key] === undefined
777
+ (this.dataParams.properties[i].index &&
778
+ (this.data[this.dataParams.properties[i].key] === null ||
779
+ this.data[this.dataParams.properties[i].key] === undefined
777
780
  )
778
781
  )
779
782
  ) {
@@ -781,7 +784,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
781
784
  ...this._getDefaultErrorSettings(
782
785
  'validateForSave',
783
786
  new Error(
784
- `validateForSave failed, ${this.dataParams.modelParams[i].key} is missing! ` +
787
+ `validateForSave failed, ${this.dataParams.properties[i].key} is missing! ` +
785
788
  `(${this.dataParams.dataName})`
786
789
  )
787
790
  ),
@@ -793,14 +796,14 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
793
796
  }
794
797
 
795
798
  // specific Date validation
796
- if (this.dataParams.modelParams[i].type === 'Date' &&
797
- !(new Date(this.data[this.dataParams.modelParams[i].key]) instanceof Date)
799
+ if (this.dataParams.properties[i].type === 'Date' &&
800
+ !(new Date(this.data[this.dataParams.properties[i].key]) instanceof Date)
798
801
  ) {
799
802
  throw new Dynamo_Error({
800
803
  ...this._getDefaultErrorSettings(
801
804
  'validateForSave',
802
805
  new Error(
803
- `validateForSave failed, ${this.dataParams.modelParams[i].key} is not a date! ` +
806
+ `validateForSave failed, ${this.dataParams.properties[i].key} is not a date! ` +
804
807
  `(${this.dataParams.dataName})`
805
808
  )
806
809
  ),
@@ -812,10 +815,10 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
812
815
  }
813
816
 
814
817
  // call additional validators
815
- if (this.dataParams.modelParams[i].additionalValidators) {
816
- for (let j = 0; j < this.dataParams.modelParams[i].additionalValidators.length; j++) {
817
- this.dataParams.modelParams[i].additionalValidators[j](
818
- this.data[this.dataParams.modelParams[i].key]
818
+ if (this.dataParams.properties[i].additionalValidators) {
819
+ for (let j = 0; j < this.dataParams.properties[i].additionalValidators.length; j++) {
820
+ this.dataParams.properties[i].additionalValidators[j](
821
+ this.data[this.dataParams.properties[i].key]
819
822
  );
820
823
  }
821
824
  }
@@ -838,8 +841,8 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
838
841
  * setting up dependency dataHook by DynamoBEDataModelParams
839
842
  */
840
843
  private lookForDependencyDataSettings(): void {
841
- const dependencyParam: Dynamo_DataPropertyParams = this.dataParams.modelParams.find(
842
- (modelParams: Dynamo_DataPropertyParams): boolean => modelParams.isDependencyHook
844
+ const dependencyParam: Dynamo_DataProperty_Params = this.dataParams.properties.find(
845
+ (modelParams: Dynamo_DataProperty_Params): boolean => modelParams.isDependencyHook
843
846
  );
844
847
 
845
848
  if (dependencyParam) {
@@ -852,6 +855,10 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
852
855
  if (dependencyParam.unique) {
853
856
  this.depKeyIsUnique = true;
854
857
  }
858
+
859
+ if (dependencyParam.required) {
860
+ this.depKeyIsRequired = true;
861
+ }
855
862
  }
856
863
  }
857
864
 
@@ -3,7 +3,7 @@ import * as mongoose from 'mongoose';
3
3
  import { Schema } from 'mongoose';
4
4
 
5
5
  import {
6
- Dynamo_Metadata, Dynamo_DataParams, Dynamo_DataPropertyParams, Dynamo_Error,
6
+ Dynamo_Metadata, Dynamo_DataModel_Params, Dynamo_DataProperty_Params, Dynamo_Error,
7
7
  Dynamo_Log, Dynamo_AnyError, Dynamo_Error_Settings
8
8
  } from '@futdevpro/fsm-dynamo';
9
9
  import { DynamoNTS_DBFilter } from '../../_models/types/db-filter.type';
@@ -31,7 +31,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
31
31
  * schemaSettings also MUST contain specific types that differs from the listed above (Array, Date)
32
32
  */
33
33
  constructor(
34
- public dataParams: Dynamo_DataParams
34
+ public dataParams: Dynamo_DataModel_Params
35
35
  ){
36
36
  try {
37
37
  this.serviceName = this.constructor?.name;
@@ -50,8 +50,8 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
50
50
  } catch (error) {
51
51
  Dynamo_Log.error(
52
52
  `\nDynamoNTS_DBService ERROR, ` +
53
- `The dbService construction failed for ${dataParams.dataName}. ${this.serviceName}`,
54
- error,
53
+ `The dbService construction failed for ${dataParams.dataName}. ${this.serviceName}` +
54
+ `\nERROR: `, error,
55
55
  new Error()
56
56
  );
57
57
  }
@@ -80,7 +80,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
80
80
  new Error(
81
81
  `createData failed, save ${this.dataParams.dbName} result not found! (NTS DB)`
82
82
  ),
83
- issuer,
83
+ issuer
84
84
  ),
85
85
 
86
86
  status: 204,
@@ -99,7 +99,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
99
99
 
100
100
  status: 422,
101
101
  errorCode: 'NTS-DBS-CD0',
102
- additionalContent: { data, dataModel, newData },
102
+ additionalContent: { data, dataModel },
103
103
  message:
104
104
  `createData failed, Create new ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
105
105
  issuer,
@@ -246,13 +246,16 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
246
246
  ...this._getDefaultErrorSettings(
247
247
  'getDataListByDependencyId',
248
248
  new Error(
249
- `dependencyDataIdKey not setted up for this db-service (${this.dataParams.dbName}) ` +
249
+ `isDependencyHook not setted up for this dataModel (${this.dataParams.dbName}) ` +
250
250
  `(NTS DB)`
251
251
  )
252
252
  ),
253
253
 
254
254
  status: 501,
255
255
  errorCode: 'NTS-DBS-GLD0',
256
+ additionalContent: {
257
+ dataModel: this.dataModel,
258
+ },
256
259
  });
257
260
  }
258
261
 
@@ -468,7 +471,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
468
471
  filter[this.depDataName] = { $in: narrowByDependencyIds };
469
472
  }
470
473
 
471
- await this.dataParams.modelParams.forEach((modelParam: Dynamo_DataPropertyParams): void => {
474
+ await this.dataParams.properties.forEach((modelParam: Dynamo_DataProperty_Params): void => {
472
475
  if (
473
476
  (filterBy[modelParam.key] !== null && filterBy[modelParam.key] !== undefined) ||
474
477
  filterBy[modelParam.key + 'Range']
@@ -944,14 +947,14 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
944
947
  * @param params DynamoBEDataPropertyParams
945
948
  * @returns mongoose schema object
946
949
  */
947
- private buildMongooseSchemaByModelParams(params?: Dynamo_DataPropertyParams[]): any {
950
+ private buildMongooseSchemaByModelParams(params?: Dynamo_DataProperty_Params[]): any {
948
951
  const schemaSettingsObj = {};
949
952
 
950
953
  if (!params) {
951
- params = this.dataParams.modelParams;
954
+ params = this.dataParams.properties;
952
955
  }
953
956
 
954
- params.forEach((property: Dynamo_DataPropertyParams): void => {
957
+ params.forEach((property: Dynamo_DataProperty_Params): void => {
955
958
  const beType = this.getBEType(property.type);
956
959
 
957
960
  if (
@@ -960,7 +963,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
960
963
  property?.subObjectParams?.length == 0
961
964
  ) {
962
965
  schemaSettingsObj[property.key] = {
963
- type: beType
966
+ type: beType,
964
967
  };
965
968
 
966
969
  if (property.index) {
@@ -1041,8 +1044,8 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
1041
1044
  * sets depDataKey
1042
1045
  */
1043
1046
  private lookForDependencyDataSettings(): void {
1044
- const dependencyParam: Dynamo_DataPropertyParams = this.dataParams.modelParams.find(
1045
- (modelParams: Dynamo_DataPropertyParams): boolean => modelParams.isDependencyHook
1047
+ const dependencyParam: Dynamo_DataProperty_Params = this.dataParams.properties.find(
1048
+ (modelParams: Dynamo_DataProperty_Params): boolean => modelParams.isDependencyHook
1046
1049
  );
1047
1050
 
1048
1051
  if (dependencyParam) {
@@ -7,11 +7,11 @@ import {
7
7
  import { DynamoNTS_HttpCallType } from '../../_enums/http/http-call-type.enum';
8
8
  import { DynamoNTS_HttpResponseType } from '../../_enums/http/http-response-type.enum';
9
9
  import {
10
- DynamoNTS_ApiCallParams
10
+ DynamoNTS_ApiCall_Params
11
11
  } from '../../_models/control-models/api-call-params.control-model';
12
- import { dynamoNTS_globalSettings } from '../../_constants';
12
+ import { DynamoNTS_globalSettings } from '../../_constants';
13
13
 
14
- export interface DynamoNTS_ApiCallInputParams<T_Body = any> {
14
+ export interface DynamoNTS_ApiCallInput_Params<T_Body = any> {
15
15
  pathParams?: {
16
16
  /**
17
17
  * path params setted in endpoint
@@ -47,11 +47,11 @@ export class DynamoNTS_ApiService {
47
47
  * you must setup the basic api call params with this.
48
48
  * follow the instructions in the constructor: new DynamoNTS_ApiCallParams({ ... })
49
49
  */
50
- callParams: DynamoNTS_ApiCallParams,
50
+ callParams: DynamoNTS_ApiCall_Params,
51
51
  /**
52
52
  * you can pass data and other inputs in this section
53
53
  */
54
- inputParams?: DynamoNTS_ApiCallInputParams<T_Body>
54
+ inputParams?: DynamoNTS_ApiCallInput_Params<T_Body>
55
55
  ): Promise<T_Response /* | Axios.AxiosResponse */> {
56
56
  try {
57
57
  let a: T_Response;
@@ -70,7 +70,7 @@ export class DynamoNTS_ApiService {
70
70
  this.setupQueryParams<T_Body>(inputParams, callParams);
71
71
  } */
72
72
 
73
- if (dynamoNTS_globalSettings.logApiEvents) {
73
+ if (DynamoNTS_globalSettings.logApiEvents) {
74
74
  this.logEvent(url, inputParams, callParams);
75
75
  }
76
76
 
@@ -146,7 +146,7 @@ export class DynamoNTS_ApiService {
146
146
  } */
147
147
 
148
148
  private static handleError<T_Body>(
149
- callParams: DynamoNTS_ApiCallParams,
149
+ callParams: DynamoNTS_ApiCall_Params,
150
150
  error: any,
151
151
  inputParams: {
152
152
  pathParams?: { [param: string]: string; };
@@ -243,17 +243,17 @@ export class DynamoNTS_ApiService {
243
243
 
244
244
  private static async postPutPatch<T_Response, T_Body>(
245
245
  axios: Axios.AxiosInstance,
246
- callParams: DynamoNTS_ApiCallParams,
246
+ callParams: DynamoNTS_ApiCall_Params,
247
247
  url: string,
248
- inputParams: DynamoNTS_ApiCallInputParams<T_Body>
248
+ inputParams: DynamoNTS_ApiCallInput_Params<T_Body>
249
249
  ): Promise<T_Response> {
250
250
  return await axios[callParams.type]<T_Response>(
251
251
  url,
252
252
  inputParams.body,
253
253
  callParams.httpOptions
254
254
  ).then((res: Axios.AxiosResponse): T_Response => {
255
- if (dynamoNTS_globalSettings.logApiEvents) {
256
- if (dynamoNTS_globalSettings.logApiResponseContents) {
255
+ if (DynamoNTS_globalSettings.logApiEvents) {
256
+ if (DynamoNTS_globalSettings.logApiResponseContents) {
257
257
  Dynamo_Log.success(`> ${callParams.name} api call was successful`, res.data);
258
258
 
259
259
  } else {
@@ -272,12 +272,12 @@ export class DynamoNTS_ApiService {
272
272
  private static async delete<T_Response>(
273
273
  axios: Axios.AxiosInstance,
274
274
  url: string,
275
- callParams: DynamoNTS_ApiCallParams
275
+ callParams: DynamoNTS_ApiCall_Params
276
276
  ): Promise<T_Response> {
277
277
  return await axios.delete<T_Response>(url, callParams.httpOptions).then(
278
278
  (res: Axios.AxiosResponse): T_Response => {
279
- if (dynamoNTS_globalSettings.logApiEvents) {
280
- if (dynamoNTS_globalSettings.logApiResponseContents) {
279
+ if (DynamoNTS_globalSettings.logApiEvents) {
280
+ if (DynamoNTS_globalSettings.logApiResponseContents) {
281
281
  Dynamo_Log.success(`${callParams.name} was successful`, res.data);
282
282
  } else {
283
283
  Dynamo_Log.success(`${callParams.name} was successful`);
@@ -294,12 +294,12 @@ export class DynamoNTS_ApiService {
294
294
  private static async get<T_Response>(
295
295
  axios: Axios.AxiosInstance,
296
296
  url: string,
297
- callParams: DynamoNTS_ApiCallParams
297
+ callParams: DynamoNTS_ApiCall_Params
298
298
  ): Promise<T_Response> {
299
299
  return await axios.get<T_Response>(url, callParams.httpOptions).then(
300
300
  (res: Axios.AxiosResponse): T_Response => {
301
- if (dynamoNTS_globalSettings.logApiEvents) {
302
- if (dynamoNTS_globalSettings.logApiResponseContents) {
301
+ if (DynamoNTS_globalSettings.logApiEvents) {
302
+ if (DynamoNTS_globalSettings.logApiResponseContents) {
303
303
  Dynamo_Log.success(`${callParams.name} was successful`, res.data);
304
304
  } else {
305
305
  Dynamo_Log.success(`${callParams.name} was successful`);
@@ -317,17 +317,17 @@ export class DynamoNTS_ApiService {
317
317
 
318
318
  private static logEvent<T_Body>(
319
319
  url: string,
320
- inputParams: DynamoNTS_ApiCallInputParams<T_Body>,
321
- callParams: DynamoNTS_ApiCallParams
320
+ inputParams: DynamoNTS_ApiCallInput_Params<T_Body>,
321
+ callParams: DynamoNTS_ApiCall_Params
322
322
  ): void {
323
- if (dynamoNTS_globalSettings.logApiRequestContents) {
323
+ if (DynamoNTS_globalSettings.logApiRequestContents) {
324
324
  Dynamo_Log.log(`< outgoing API call: ${url} \nbody:`, inputParams?.body);
325
325
 
326
326
  } else {
327
327
  Dynamo_Log.log(`< outgoing API call: ${url}`);
328
328
  }
329
329
 
330
- if (dynamoNTS_globalSettings.logApiRequestSettings) {
330
+ if (DynamoNTS_globalSettings.logApiRequestSettings) {
331
331
  Dynamo_Log.log(`callParams:`, callParams);
332
332
  Dynamo_Log.log('inputParams:', {
333
333
  pathParams: inputParams.pathParams ?? {},
@@ -337,7 +337,7 @@ export class DynamoNTS_ApiService {
337
337
  }
338
338
 
339
339
  private static setupHeaders(
340
- callParams: DynamoNTS_ApiCallParams,
340
+ callParams: DynamoNTS_ApiCall_Params,
341
341
  axios: Axios.AxiosInstance
342
342
  ): void {
343
343
  for (const headerKey in callParams.httpOptions.headers) {
@@ -7,7 +7,7 @@ import { Options as MailOptions, Attachment } from 'nodemailer/lib/mailer';
7
7
 
8
8
  import { Dynamo_AnyError, Dynamo_Array, Dynamo_Error, Dynamo_Error_Settings, Dynamo_Log } from '@futdevpro/fsm-dynamo';
9
9
 
10
- export interface DynamoNTS_EmailServiceSettings {
10
+ export interface DynamoNTS_EmailService_Settings {
11
11
  host: string,
12
12
  port: number,
13
13
  email: string,
@@ -41,7 +41,7 @@ export class DynamoNTS_EmailTemplateComponent {
41
41
  }
42
42
  }
43
43
 
44
- export interface DynamoNTS_SendEmailSettings<T = { [propertyKey: string]: string; }> {
44
+ export interface DynamoNTS_SendEmail_Settings<T = { [propertyKey: string]: string; }> {
45
45
  to: string;
46
46
  subject: string;
47
47
  /** direct email content, if provided, this will be used */
@@ -78,7 +78,7 @@ export class DynamoNTS_EmailService {
78
78
  `\nplease contact the responsible development team.`;
79
79
 
80
80
  constructor (
81
- set: DynamoNTS_EmailServiceSettings
81
+ set: DynamoNTS_EmailService_Settings
82
82
  ) {
83
83
  this.serviceName = this.constructor?.name;
84
84
  this.senderName = set.senderName;
@@ -126,7 +126,7 @@ export class DynamoNTS_EmailService {
126
126
  * @param set
127
127
  */
128
128
  public async sendEmail<T>(
129
- set: DynamoNTS_SendEmailSettings<T>,
129
+ set: DynamoNTS_SendEmail_Settings<T>,
130
130
  issuer: string
131
131
  ): Promise<void> {
132
132
  try {