@futdevpro/nts-dynamo 1.5.76 → 1.5.81

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 -229
  152. package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -1
  153. package/lib/_services/dynamo-nts-data.service.js +689 -686
  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 +312 -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 +15 -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 +16 -10
  220. package/src/_services/dynamo-nts-db.service.ts +8 -5
  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,189 +1,189 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DynamoNTS_ApiService = void 0;
4
- const tslib_1 = require("tslib");
5
- const Axios = tslib_1.__importStar(require("axios"));
6
- const fsm_dynamo_1 = require("@futdevpro/fsm-dynamo");
7
- const http_call_type_enum_1 = require("../_enums/http/http-call-type.enum");
8
- const http_response_type_enum_1 = require("../_enums/http/http-response-type.enum");
9
- /**
10
- * This predefined Api service contains the basic API call function which can be used in various ways
11
- */
12
- class DynamoNTS_ApiService {
13
- /**
14
- *
15
- * @param callParams
16
- * @param inputParams
17
- * @returns
18
- */
19
- static startApiCall(
20
- /**
21
- * you must setup the basic api call params with this.
22
- * follow the instructions in the constructor: new DynamoNTS_ApiCallParams({ ... })
23
- */
24
- callParams,
25
- /**
26
- * you can pass data and other inputs in this section
27
- */
28
- inputParams) {
29
- var _a, _b, _c, _d;
30
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
31
- try {
32
- let a;
33
- let url = callParams.baseUrl + callParams.endPoint;
34
- const privateAxiosInstance = Axios.default.create();
35
- if ((_a = callParams === null || callParams === void 0 ? void 0 : callParams.httpOptions) === null || _a === void 0 ? void 0 : _a.headers) {
36
- for (const headerKey in callParams.httpOptions.headers) {
37
- if (callParams.httpOptions.headers[headerKey]) {
38
- privateAxiosInstance.defaults.headers.common[headerKey] = callParams.httpOptions.headers[headerKey];
39
- }
40
- else {
41
- fsm_dynamo_1.Dynamo_Log.error('DYNAMOBE ERROR: \n missing header:', headerKey, '\n\n', new Error());
42
- }
43
- }
44
- }
45
- if (inputParams === null || inputParams === void 0 ? void 0 : inputParams.pathParams) {
46
- for (const pathParamKey in inputParams.pathParams) {
47
- if (inputParams.pathParams[pathParamKey]) {
48
- const paramType = typeof inputParams.pathParams[pathParamKey];
49
- switch (paramType) {
50
- case 'number':
51
- url = url.replace(`:${pathParamKey}`, inputParams.pathParams[pathParamKey].toString());
52
- break;
53
- case 'string':
54
- url = url.replace(`:${pathParamKey}`, inputParams.pathParams[pathParamKey]);
55
- break;
56
- default:
57
- fsm_dynamo_1.Dynamo_Log.error(`DYNAMOBE ERROR: \n wrong path param type: (${pathParamKey}): ${paramType} \n${inputParams.pathParams[pathParamKey]}\nMUST BE string or number\n\n`, new Error());
58
- break;
59
- }
60
- }
61
- else {
62
- fsm_dynamo_1.Dynamo_Log.error('DYNAMOBE ERROR: \n missing pathParam:', pathParamKey, '\n\n', new Error());
63
- }
64
- }
65
- }
66
- /* if (inputParams?.queryParams) {
67
- const httpParams = new HttpParams();
68
- for (const queryParamKey in inputParams.queryParams) {
69
- if (inputParams.queryParams[queryParamKey]) {
70
- switch (typeof inputParams.queryParams[queryParamKey]) {
71
- case 'number':
72
- httpParams.set(queryParamKey, inputParams.queryParams[queryParamKey].toString());
73
- break;
74
- case 'string':
75
- httpParams.set(queryParamKey, inputParams.queryParams[queryParamKey]);
76
- break;
77
- default:
78
- console.error('DYNAMOBE ERROR: \n wrong query param type', '\n\n', new Error());
79
- break;
80
- }
81
- }
82
- }
83
- callParams.httpOptions.params = httpParams;
84
- } */
85
- switch (callParams.type) {
86
- case http_call_type_enum_1.HttpCallType.get:
87
- if (inputParams === null || inputParams === void 0 ? void 0 : inputParams.body) {
88
- console.log('WARNING you cant send body in get calls');
89
- }
90
- yield privateAxiosInstance.get(url, callParams.httpOptions).then((res) => {
91
- if (callParams.getFullResponse) {
92
- a = res;
93
- }
94
- else {
95
- a = res.data;
96
- }
97
- console.log(`${callParams.name} was successful`, res.data);
98
- });
99
- break;
100
- case http_call_type_enum_1.HttpCallType.delete:
101
- if (inputParams === null || inputParams === void 0 ? void 0 : inputParams.body) {
102
- console.log('WARNING you cant send body in delete calls');
103
- }
104
- yield privateAxiosInstance.delete(url, callParams.httpOptions).then((res) => {
105
- if (callParams.getFullResponse) {
106
- a = res;
107
- }
108
- console.log(`${callParams.name} was successful`, res.data);
109
- });
110
- break;
111
- case http_call_type_enum_1.HttpCallType.post:
112
- case http_call_type_enum_1.HttpCallType.put:
113
- case http_call_type_enum_1.HttpCallType.patch:
114
- if (!(inputParams === null || inputParams === void 0 ? void 0 : inputParams.body)) {
115
- if (!inputParams) {
116
- inputParams = {};
117
- }
118
- inputParams.body = {};
119
- }
120
- yield privateAxiosInstance[callParams.type](url, inputParams.body, callParams.httpOptions).then((res) => {
121
- if (callParams.getFullResponse) {
122
- a = res;
123
- }
124
- else {
125
- a = res.data;
126
- }
127
- console.log(`${callParams.name} api call was successful`, res.data);
128
- });
129
- break;
130
- default:
131
- fsm_dynamo_1.Dynamo_Log.error('DYNAMOBE ERROR: \n wrong api call type', '\n\n', new Error());
132
- break;
133
- }
134
- if (callParams.getFullResponse) {
135
- return a;
136
- }
137
- else {
138
- return a;
139
- }
140
- }
141
- catch (error) {
142
- fsm_dynamo_1.Dynamo_Log.error(`\nAPI ERROR: ${callParams === null || callParams === void 0 ? void 0 : callParams.name} failed...` +
143
- `\n${callParams === null || callParams === void 0 ? void 0 : callParams.baseUrl}${callParams === null || callParams === void 0 ? void 0 : callParams.endPoint}\n`, callParams);
144
- if (((_b = callParams === null || callParams === void 0 ? void 0 : callParams.httpOptions) === null || _b === void 0 ? void 0 : _b.responseType) === http_response_type_enum_1.HttpResponseType.text) {
145
- error.error = JSON.parse(error.error);
146
- }
147
- if (((_d = (_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.flag) === 'DYNAMO ERROR OBJECT') {
148
- fsm_dynamo_1.Dynamo_Log.error(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
149
- throw new fsm_dynamo_1.Dynamo_Error({
150
- errorCode: 'NTS-API-002',
151
- addECToUserMsg: true,
152
- message: 'API call failed on the other end! error response found...',
153
- userMessage: this.defaultErrorUserMsg,
154
- error: error.response.data
155
- });
156
- }
157
- else if (error.code === 'ENOTFOUND') {
158
- fsm_dynamo_1.Dynamo_Log.error(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
159
- throw new fsm_dynamo_1.Dynamo_Error({
160
- status: 404,
161
- errorCode: 'NTS-API-000',
162
- addECToUserMsg: true,
163
- message: 'DNS error; address cannot be resolved!',
164
- userMessage: this.defaultErrorUserMsg,
165
- error
166
- });
167
- }
168
- else if (error.config && error.message) {
169
- throw new fsm_dynamo_1.Dynamo_Error({
170
- status: +error.message.substring(error.message.length - 4, 3),
171
- errorCode: 'NTS-API-003',
172
- addECToUserMsg: true,
173
- userMessage: this.defaultErrorUserMsg,
174
- error
175
- });
176
- }
177
- else {
178
- fsm_dynamo_1.Dynamo_Log.error(`\n${callParams.name} was UNSUCCESSFUL`, error, '\n\n', new Error());
179
- throw error;
180
- }
181
- }
182
- });
183
- }
184
- }
185
- exports.DynamoNTS_ApiService = DynamoNTS_ApiService;
186
- DynamoNTS_ApiService.defaultErrorUserMsg = `We encountered a BackEnd API Error, ` +
187
- `\nplease contact the responsible development team.\n` +
188
- `\n(Internal BE to BE error)`;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DynamoNTS_ApiService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const Axios = tslib_1.__importStar(require("axios"));
6
+ const fsm_dynamo_1 = require("@futdevpro/fsm-dynamo");
7
+ const http_call_type_enum_1 = require("../_enums/http/http-call-type.enum");
8
+ const http_response_type_enum_1 = require("../_enums/http/http-response-type.enum");
9
+ /**
10
+ * This predefined Api service contains the basic API call function which can be used in various ways
11
+ */
12
+ class DynamoNTS_ApiService {
13
+ /**
14
+ *
15
+ * @param callParams
16
+ * @param inputParams
17
+ * @returns
18
+ */
19
+ static startApiCall(
20
+ /**
21
+ * you must setup the basic api call params with this.
22
+ * follow the instructions in the constructor: new DynamoNTS_ApiCallParams({ ... })
23
+ */
24
+ callParams,
25
+ /**
26
+ * you can pass data and other inputs in this section
27
+ */
28
+ inputParams) {
29
+ var _a, _b, _c, _d;
30
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
31
+ try {
32
+ let a;
33
+ let url = callParams.baseUrl + callParams.endPoint;
34
+ const privateAxiosInstance = Axios.default.create();
35
+ if ((_a = callParams === null || callParams === void 0 ? void 0 : callParams.httpOptions) === null || _a === void 0 ? void 0 : _a.headers) {
36
+ for (const headerKey in callParams.httpOptions.headers) {
37
+ if (callParams.httpOptions.headers[headerKey]) {
38
+ privateAxiosInstance.defaults.headers.common[headerKey] = callParams.httpOptions.headers[headerKey];
39
+ }
40
+ else {
41
+ fsm_dynamo_1.Dynamo_Log.error('DYNAMOBE ERROR: \n missing header:', headerKey, '\n\n', new Error());
42
+ }
43
+ }
44
+ }
45
+ if (inputParams === null || inputParams === void 0 ? void 0 : inputParams.pathParams) {
46
+ for (const pathParamKey in inputParams.pathParams) {
47
+ if (inputParams.pathParams[pathParamKey]) {
48
+ const paramType = typeof inputParams.pathParams[pathParamKey];
49
+ switch (paramType) {
50
+ case 'number':
51
+ url = url.replace(`:${pathParamKey}`, inputParams.pathParams[pathParamKey].toString());
52
+ break;
53
+ case 'string':
54
+ url = url.replace(`:${pathParamKey}`, inputParams.pathParams[pathParamKey]);
55
+ break;
56
+ default:
57
+ fsm_dynamo_1.Dynamo_Log.error(`DYNAMOBE ERROR: \n wrong path param type: (${pathParamKey}): ${paramType} \n${inputParams.pathParams[pathParamKey]}\nMUST BE string or number\n\n`, new Error());
58
+ break;
59
+ }
60
+ }
61
+ else {
62
+ fsm_dynamo_1.Dynamo_Log.error('DYNAMOBE ERROR: \n missing pathParam:', pathParamKey, '\n\n', new Error());
63
+ }
64
+ }
65
+ }
66
+ /* if (inputParams?.queryParams) {
67
+ const httpParams = new HttpParams();
68
+ for (const queryParamKey in inputParams.queryParams) {
69
+ if (inputParams.queryParams[queryParamKey]) {
70
+ switch (typeof inputParams.queryParams[queryParamKey]) {
71
+ case 'number':
72
+ httpParams.set(queryParamKey, inputParams.queryParams[queryParamKey].toString());
73
+ break;
74
+ case 'string':
75
+ httpParams.set(queryParamKey, inputParams.queryParams[queryParamKey]);
76
+ break;
77
+ default:
78
+ console.error('DYNAMOBE ERROR: \n wrong query param type', '\n\n', new Error());
79
+ break;
80
+ }
81
+ }
82
+ }
83
+ callParams.httpOptions.params = httpParams;
84
+ } */
85
+ switch (callParams.type) {
86
+ case http_call_type_enum_1.HttpCallType.get:
87
+ if (inputParams === null || inputParams === void 0 ? void 0 : inputParams.body) {
88
+ console.log('WARNING you cant send body in get calls');
89
+ }
90
+ yield privateAxiosInstance.get(url, callParams.httpOptions).then((res) => {
91
+ if (callParams.getFullResponse) {
92
+ a = res;
93
+ }
94
+ else {
95
+ a = res.data;
96
+ }
97
+ console.log(`${callParams.name} was successful`, res.data);
98
+ });
99
+ break;
100
+ case http_call_type_enum_1.HttpCallType.delete:
101
+ if (inputParams === null || inputParams === void 0 ? void 0 : inputParams.body) {
102
+ console.log('WARNING you cant send body in delete calls');
103
+ }
104
+ yield privateAxiosInstance.delete(url, callParams.httpOptions).then((res) => {
105
+ if (callParams.getFullResponse) {
106
+ a = res;
107
+ }
108
+ console.log(`${callParams.name} was successful`, res.data);
109
+ });
110
+ break;
111
+ case http_call_type_enum_1.HttpCallType.post:
112
+ case http_call_type_enum_1.HttpCallType.put:
113
+ case http_call_type_enum_1.HttpCallType.patch:
114
+ if (!(inputParams === null || inputParams === void 0 ? void 0 : inputParams.body)) {
115
+ if (!inputParams) {
116
+ inputParams = {};
117
+ }
118
+ inputParams.body = {};
119
+ }
120
+ yield privateAxiosInstance[callParams.type](url, inputParams.body, callParams.httpOptions).then((res) => {
121
+ if (callParams.getFullResponse) {
122
+ a = res;
123
+ }
124
+ else {
125
+ a = res.data;
126
+ }
127
+ console.log(`${callParams.name} api call was successful`, res.data);
128
+ });
129
+ break;
130
+ default:
131
+ fsm_dynamo_1.Dynamo_Log.error('DYNAMOBE ERROR: \n wrong api call type', '\n\n', new Error());
132
+ break;
133
+ }
134
+ if (callParams.getFullResponse) {
135
+ return a;
136
+ }
137
+ else {
138
+ return a;
139
+ }
140
+ }
141
+ catch (error) {
142
+ fsm_dynamo_1.Dynamo_Log.error(`\nAPI ERROR: ${callParams === null || callParams === void 0 ? void 0 : callParams.name} failed...` +
143
+ `\n${callParams === null || callParams === void 0 ? void 0 : callParams.baseUrl}${callParams === null || callParams === void 0 ? void 0 : callParams.endPoint}\n`, callParams);
144
+ if (((_b = callParams === null || callParams === void 0 ? void 0 : callParams.httpOptions) === null || _b === void 0 ? void 0 : _b.responseType) === http_response_type_enum_1.HttpResponseType.text) {
145
+ error.error = JSON.parse(error.error);
146
+ }
147
+ if (((_d = (_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.flag) === 'DYNAMO ERROR OBJECT') {
148
+ fsm_dynamo_1.Dynamo_Log.error(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
149
+ throw new fsm_dynamo_1.Dynamo_Error({
150
+ errorCode: 'NTS-API-002',
151
+ addECToUserMsg: true,
152
+ message: 'API call failed on the other end! error response found...',
153
+ userMessage: this.defaultErrorUserMsg,
154
+ error: error.response.data
155
+ });
156
+ }
157
+ else if (error.code === 'ENOTFOUND') {
158
+ fsm_dynamo_1.Dynamo_Log.error(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
159
+ throw new fsm_dynamo_1.Dynamo_Error({
160
+ status: 404,
161
+ errorCode: 'NTS-API-000',
162
+ addECToUserMsg: true,
163
+ message: 'DNS error; address cannot be resolved!',
164
+ userMessage: this.defaultErrorUserMsg,
165
+ error
166
+ });
167
+ }
168
+ else if (error.config && error.message) {
169
+ throw new fsm_dynamo_1.Dynamo_Error({
170
+ status: +error.message.substring(error.message.length - 4, 3),
171
+ errorCode: 'NTS-API-003',
172
+ addECToUserMsg: true,
173
+ userMessage: this.defaultErrorUserMsg,
174
+ error
175
+ });
176
+ }
177
+ else {
178
+ fsm_dynamo_1.Dynamo_Log.error(`\n${callParams.name} was UNSUCCESSFUL`, error, '\n\n', new Error());
179
+ throw error;
180
+ }
181
+ }
182
+ });
183
+ }
184
+ }
185
+ exports.DynamoNTS_ApiService = DynamoNTS_ApiService;
186
+ DynamoNTS_ApiService.defaultErrorUserMsg = `We encountered a BackEnd API Error, ` +
187
+ `\nplease contact the responsible development team.\n` +
188
+ `\n(Internal BE to BE error)`;
189
189
  //# sourceMappingURL=dynamo-nts-api.service.js.map
@@ -1,129 +1,129 @@
1
- import { DynamoNTS_App } from './dynamo-nts-app';
2
- import { DynamoNTS_SocketService } from './dynamo-nts-socket.service';
3
- /**
4
- * This will be the MAIN service of our server project,
5
- * follow the types and type instructions while setting up your project
6
- *
7
- * In this service, there are abstract functions that you will need to implement,
8
- * where you need to set up the main params for your application.
9
- *
10
- * The extended App is containing socket server tools
11
- *
12
- * You need to add socketService definitions to setupRoutingModules
13
- *
14
- * @example
15
- * export class App extends DynamoNTS_AppExtended {
16
- *
17
- * ...
18
- *
19
- * // Setting up App params, and preparing project global settings
20
- * setupAppParams(): void {
21
- * this.params = new DynamoNTS_AppParams({
22
- * name: 'Warbots Server',
23
- * title: warbotsTitleLog,
24
- * version: version,
25
- * dbName: 'warbots',
26
- * });
27
- *
28
- * // dynamoNTS_GlobalSettings.logRequestsContent = false;
29
- * }
30
- *
31
- * ...
32
- *
33
- * // Setting up DBServices
34
- * setGlobalServiceCollection(): void {
35
- * DynamoNTS_GlobalService.setServices({
36
- * authService: AuthService.getInstance(),
37
- * emailServiceCollection: EmailServiceCollectionService.getInstance(),
38
- * dbModels: [
39
- * userModelParams,
40
- * userDataModelParams,
41
- * userOptionsModelParams,
42
- * userStatisticsModelParams,
43
- * userAchievementsModelParams,
44
- * userNotificationsModelParams,
45
- *
46
- * matchStatisticsModelParams,
47
- * matchDataModelParams,
48
-
49
- * usageSessionModelParams,
50
- * customDataModelParams,
51
- * ]
52
- * });
53
- * }
54
- *
55
- * ...
56
- *
57
- * // Setting up Routes
58
- * setupRoutingModules(): void {
59
- * this.httpPort = env.port;
60
-
61
- * this.routingModules = [
62
- * new DynamoNTS_RoutingModule({
63
- * route: '/user',
64
- * controllers: [
65
- * UserController.getInstance(),
66
- * UserDataController.getInstance(),
67
- * UserOptionsController.getInstance(),
68
- * UserStatisticsController.getInstance(),
69
- * UserAchievementsController.getInstance(),
70
- * UserNotificationsController.getInstance()
71
- * ]
72
- * }),
73
- * new DynamoNTS_RoutingModule({
74
- * route: '/match',
75
- * controllers: [
76
- * MatchController.getInstance(),
77
- * MatchDistributionController.getInstance(),
78
- * MatchStatisticsController.getInstance(),
79
- * ]
80
- * }),
81
- * new DynamoNTS_RoutingModule({
82
- * route: '/server',
83
- * controllers: [
84
- * ServerController.getInstance(),
85
- * ]
86
- * }),
87
-
88
- * getTestRoutingModule(),
89
- * getUsageRoutingModule()
90
- * ];
91
- *
92
- * ...
93
- *
94
- * // Setting up Sockets
95
- * this.socketServices = [
96
- * NotificationService.getInstance(),
97
- * ChatService.getInstance(),
98
- * ...
99
- * ];
100
- * }
101
- * }
102
- */
103
- export declare abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
104
- private socketSecurity;
105
- /**
106
- * @example
107
- * // Setting up Sockets
108
- * this.socketServices = [
109
- * NotificationService.getInstance(),
110
- * ChatService.getInstance(),
111
- * ...
112
- * ];
113
- */
114
- protected socketServices: DynamoNTS_SocketService<any>[];
115
- constructor();
116
- /**
117
- *
118
- */
119
- private setSocketSecurity;
120
- /**
121
- *
122
- */
123
- private mountSocketServices;
124
- /**
125
- * MISSING Description (TODO)
126
- */
127
- abstract getSocketServices(): DynamoNTS_SocketService<any>[];
128
- }
1
+ import { DynamoNTS_App } from './dynamo-nts-app';
2
+ import { DynamoNTS_SocketService } from './dynamo-nts-socket.service';
3
+ /**
4
+ * This will be the MAIN service of our server project,
5
+ * follow the types and type instructions while setting up your project
6
+ *
7
+ * In this service, there are abstract functions that you will need to implement,
8
+ * where you need to set up the main params for your application.
9
+ *
10
+ * The extended App is containing socket server tools
11
+ *
12
+ * You need to add socketService definitions to setupRoutingModules
13
+ *
14
+ * @example
15
+ * export class App extends DynamoNTS_AppExtended {
16
+ *
17
+ * ...
18
+ *
19
+ * // Setting up App params, and preparing project global settings
20
+ * setupAppParams(): void {
21
+ * this.params = new DynamoNTS_AppParams({
22
+ * name: 'Warbots Server',
23
+ * title: warbotsTitleLog,
24
+ * version: version,
25
+ * dbName: 'warbots',
26
+ * });
27
+ *
28
+ * // dynamoNTS_GlobalSettings.logRequestsContent = false;
29
+ * }
30
+ *
31
+ * ...
32
+ *
33
+ * // Setting up DBServices
34
+ * setGlobalServiceCollection(): void {
35
+ * DynamoNTS_GlobalService.setServices({
36
+ * authService: AuthService.getInstance(),
37
+ * emailServiceCollection: EmailServiceCollectionService.getInstance(),
38
+ * dbModels: [
39
+ * userModelParams,
40
+ * userDataModelParams,
41
+ * userOptionsModelParams,
42
+ * userStatisticsModelParams,
43
+ * userAchievementsModelParams,
44
+ * userNotificationsModelParams,
45
+ *
46
+ * matchStatisticsModelParams,
47
+ * matchDataModelParams,
48
+
49
+ * usageSessionModelParams,
50
+ * customDataModelParams,
51
+ * ]
52
+ * });
53
+ * }
54
+ *
55
+ * ...
56
+ *
57
+ * // Setting up Routes
58
+ * setupRoutingModules(): void {
59
+ * this.httpPort = env.port;
60
+
61
+ * this.routingModules = [
62
+ * new DynamoNTS_RoutingModule({
63
+ * route: '/user',
64
+ * controllers: [
65
+ * UserController.getInstance(),
66
+ * UserDataController.getInstance(),
67
+ * UserOptionsController.getInstance(),
68
+ * UserStatisticsController.getInstance(),
69
+ * UserAchievementsController.getInstance(),
70
+ * UserNotificationsController.getInstance()
71
+ * ]
72
+ * }),
73
+ * new DynamoNTS_RoutingModule({
74
+ * route: '/match',
75
+ * controllers: [
76
+ * MatchController.getInstance(),
77
+ * MatchDistributionController.getInstance(),
78
+ * MatchStatisticsController.getInstance(),
79
+ * ]
80
+ * }),
81
+ * new DynamoNTS_RoutingModule({
82
+ * route: '/server',
83
+ * controllers: [
84
+ * ServerController.getInstance(),
85
+ * ]
86
+ * }),
87
+
88
+ * getTestRoutingModule(),
89
+ * getUsageRoutingModule()
90
+ * ];
91
+ *
92
+ * ...
93
+ *
94
+ * // Setting up Sockets
95
+ * this.socketServices = [
96
+ * NotificationService.getInstance(),
97
+ * ChatService.getInstance(),
98
+ * ...
99
+ * ];
100
+ * }
101
+ * }
102
+ */
103
+ export declare abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
104
+ private socketSecurity;
105
+ /**
106
+ * @example
107
+ * // Setting up Sockets
108
+ * this.socketServices = [
109
+ * NotificationService.getInstance(),
110
+ * ChatService.getInstance(),
111
+ * ...
112
+ * ];
113
+ */
114
+ protected socketServices: DynamoNTS_SocketService<any>[];
115
+ constructor();
116
+ /**
117
+ *
118
+ */
119
+ private setSocketSecurity;
120
+ /**
121
+ *
122
+ */
123
+ private mountSocketServices;
124
+ /**
125
+ * MISSING Description (TODO)
126
+ */
127
+ abstract getSocketServices(): DynamoNTS_SocketService<any>[];
128
+ }
129
129
  //# sourceMappingURL=dynamo-nts-app-extended.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dynamo-nts-app-extended.d.ts","sourceRoot":"","sources":["../../src/_services/dynamo-nts-app-extended.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAItE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmGG;AACH,8BAAsB,qBAAsB,SAAQ,aAAa;IAE/D,OAAO,CAAC,cAAc,CAA0B;IAEhD;;;;;;;;OAQG;IACH,SAAS,CAAC,cAAc,EAAE,uBAAuB,CAAC,GAAG,CAAC,EAAE,CAAC;;IAyBzD;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAUzB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAuE3B;;OAEG;IACH,QAAQ,CAAC,iBAAiB,IAAI,uBAAuB,CAAC,GAAG,CAAC,EAAE;CAC7D"}
1
+ {"version":3,"file":"dynamo-nts-app-extended.d.ts","sourceRoot":"","sources":["../../src/_services/dynamo-nts-app-extended.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAGtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmGG;AACH,8BAAsB,qBAAsB,SAAQ,aAAa;IAE/D,OAAO,CAAC,cAAc,CAA0B;IAEhD;;;;;;;;OAQG;IACH,SAAS,CAAC,cAAc,EAAE,uBAAuB,CAAC,GAAG,CAAC,EAAE,CAAC;;IAyBzD;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAUzB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA0E3B;;OAEG;IACH,QAAQ,CAAC,iBAAiB,IAAI,uBAAuB,CAAC,GAAG,CAAC,EAAE;CAC7D"}