@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,133 +1,133 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UsageService = void 0;
4
- const tslib_1 = require("tslib");
5
- const fsm_dynamo_1 = require("@futdevpro/fsm-dynamo");
6
- const usage_module_1 = require("@futdevpro/fsm-dynamo/usage-module");
7
- const dynamo_nts_data_service_1 = require("../../_services/dynamo-nts-data.service");
8
- const dynamo_nts_shared_service_1 = require("../../_services/dynamo-nts-shared.service");
9
- class UsageService extends dynamo_nts_data_service_1.DynamoNTS_DataService {
10
- constructor(set) {
11
- super(new usage_module_1.Dynamo_UsageSession(set === null || set === void 0 ? void 0 : set.usageSession), usage_module_1.usageSessionModelParams, set === null || set === void 0 ? void 0 : set.issuer);
12
- this.usageData = [];
13
- this.simplifiedDailyUsage = [];
14
- this.usageData = (set === null || set === void 0 ? void 0 : set.usageData) ? set === null || set === void 0 ? void 0 : set.usageData : [];
15
- }
16
- getLocationDataFromRequest(req) {
17
- try {
18
- this.data.address = dynamo_nts_shared_service_1.DynamoNTS_Shared.getIpFromRequest(req);
19
- this.data.locationData = dynamo_nts_shared_service_1.DynamoNTS_Shared.getLocationDataByRequest(req);
20
- /* console.log(`...getLocationDataFromRequest... ip: ${this.data.address}`, this.data.locationData); */
21
- }
22
- catch (error) {
23
- throw new fsm_dynamo_1.Dynamo_Error({
24
- status: 417,
25
- errorCode: 'NTS-US0-GLD',
26
- message: 'getLocationDataFromRequest was unsuccessful',
27
- userMessage: `We were unable to deep analyze your request.`,
28
- error
29
- });
30
- }
31
- }
32
- getLastWeekUsage() {
33
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
34
- try {
35
- yield this.dataDBService.find({
36
- sessionStart: { $gte: fsm_dynamo_1.Dynamo_Time.oneWeekAgo() }
37
- }).then((res) => {
38
- this.dataList = res;
39
- });
40
- this.simplifiedDailyUsage = [];
41
- this.dataList.forEach((session) => {
42
- var _a;
43
- let dateIndex = this.simplifiedDailyUsage.findIndex((dailyData) => dailyData.date === session.date);
44
- if (-1 < dateIndex) {
45
- this.simplifiedDailyUsage[dateIndex].visitations.push(session);
46
- }
47
- else {
48
- const newUsageSimple = new usage_module_1.Dynamo_DailyUsageData({ date: session.date, visitations: [session] });
49
- this.simplifiedDailyUsage.push(newUsageSimple);
50
- dateIndex = this.simplifiedDailyUsage.length - 1;
51
- }
52
- if ((_a = session === null || session === void 0 ? void 0 : session.locationData) === null || _a === void 0 ? void 0 : _a.country) {
53
- if (session.locationData.country === 'HU') {
54
- this.simplifiedDailyUsage[dateIndex].visitorsHun++;
55
- }
56
- else {
57
- this.simplifiedDailyUsage[dateIndex].visitorsElse++;
58
- }
59
- }
60
- this.simplifiedDailyUsage[dateIndex].totalVisitTime += session.totalSessionTime;
61
- this.simplifiedDailyUsage[dateIndex].averageVisitTime = Math.round((this.simplifiedDailyUsage[dateIndex].totalVisitTime /
62
- this.simplifiedDailyUsage[dateIndex].visitations.length) * 100) / 100;
63
- });
64
- this.simplifiedDailyUsage.sort((a, b) => +new Date(b.date) - +new Date(a.date));
65
- this.simplifiedDailyUsage.forEach((daily) => {
66
- daily.visitations.sort((a, b) => +a.sessionStart - +b.sessionStart);
67
- });
68
- }
69
- catch (error) {
70
- throw new fsm_dynamo_1.Dynamo_Error({
71
- status: 417,
72
- errorCode: 'NTS-US0-GLW',
73
- message: 'getDailyUsage was unsuccessful',
74
- userMessage: `We've failed to collect last week's usage data.`,
75
- error
76
- });
77
- }
78
- });
79
- }
80
- updateUsageData(req) {
81
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
82
- try {
83
- yield this.getDataById();
84
- this.data.usageData = this.usageData;
85
- let totalTime = 0;
86
- this.data.usageData.forEach((data) => {
87
- totalTime += data.timeSpentOnPage;
88
- });
89
- if (!this.data.locationData) {
90
- this.getLocationDataFromRequest(req);
91
- }
92
- this.data.totalSessionTime = totalTime;
93
- yield this.saveData();
94
- }
95
- catch (error) {
96
- throw new fsm_dynamo_1.Dynamo_Error({
97
- status: 417,
98
- errorCode: 'NTS-US0-UU0',
99
- message: 'updateSessionData was unsuccessful',
100
- userMessage: `The attempt to update Usage Data was unsuccessful.`,
101
- error
102
- });
103
- }
104
- });
105
- }
106
- closeSession(req) {
107
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
108
- try {
109
- yield this.getDataById();
110
- this.data.sessionEnd = new Date();
111
- const newTotalSessionTime = +this.data.sessionEnd - +this.data.sessionStart;
112
- this.data.usageData[this.data.usageData.length - 1].timeSpentOnPage = newTotalSessionTime - this.data.totalSessionTime;
113
- if (!this.data.locationData) {
114
- this.getLocationDataFromRequest(req);
115
- }
116
- this.data.usageData.sort((a, b) => +a.opened - +b.opened);
117
- this.data.totalSessionTime = newTotalSessionTime;
118
- yield this.saveData();
119
- }
120
- catch (error) {
121
- throw new fsm_dynamo_1.Dynamo_Error({
122
- status: 417,
123
- errorCode: 'NTS-US0-CS0',
124
- message: 'closeSession was unsuccessful',
125
- userMessage: `The attempt to close Usage Session was unsuccessful.`,
126
- error
127
- });
128
- }
129
- });
130
- }
131
- }
132
- exports.UsageService = UsageService;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UsageService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fsm_dynamo_1 = require("@futdevpro/fsm-dynamo");
6
+ const usage_module_1 = require("@futdevpro/fsm-dynamo/usage-module");
7
+ const dynamo_nts_data_service_1 = require("../../_services/dynamo-nts-data.service");
8
+ const dynamo_nts_shared_service_1 = require("../../_services/dynamo-nts-shared.service");
9
+ class UsageService extends dynamo_nts_data_service_1.DynamoNTS_DataService {
10
+ constructor(set) {
11
+ super(new usage_module_1.Dynamo_UsageSession(set === null || set === void 0 ? void 0 : set.usageSession), usage_module_1.usageSessionModelParams, set === null || set === void 0 ? void 0 : set.issuer);
12
+ this.usageData = [];
13
+ this.simplifiedDailyUsage = [];
14
+ this.usageData = (set === null || set === void 0 ? void 0 : set.usageData) ? set === null || set === void 0 ? void 0 : set.usageData : [];
15
+ }
16
+ getLocationDataFromRequest(req) {
17
+ try {
18
+ this.data.address = dynamo_nts_shared_service_1.DynamoNTS_Shared.getIpFromRequest(req);
19
+ this.data.locationData = dynamo_nts_shared_service_1.DynamoNTS_Shared.getLocationDataByRequest(req);
20
+ /* console.log(`...getLocationDataFromRequest... ip: ${this.data.address}`, this.data.locationData); */
21
+ }
22
+ catch (error) {
23
+ throw new fsm_dynamo_1.Dynamo_Error({
24
+ status: 417,
25
+ errorCode: 'NTS-US0-GLD',
26
+ message: 'getLocationDataFromRequest was unsuccessful',
27
+ userMessage: `We were unable to deep analyze your request.`,
28
+ error
29
+ });
30
+ }
31
+ }
32
+ getLastWeekUsage() {
33
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
34
+ try {
35
+ yield this.dataDBService.find({
36
+ sessionStart: { $gte: fsm_dynamo_1.Dynamo_Time.oneWeekAgo() }
37
+ }).then((res) => {
38
+ this.dataList = res;
39
+ });
40
+ this.simplifiedDailyUsage = [];
41
+ this.dataList.forEach((session) => {
42
+ var _a;
43
+ let dateIndex = this.simplifiedDailyUsage.findIndex((dailyData) => dailyData.date === session.date);
44
+ if (-1 < dateIndex) {
45
+ this.simplifiedDailyUsage[dateIndex].visitations.push(session);
46
+ }
47
+ else {
48
+ const newUsageSimple = new usage_module_1.Dynamo_DailyUsageData({ date: session.date, visitations: [session] });
49
+ this.simplifiedDailyUsage.push(newUsageSimple);
50
+ dateIndex = this.simplifiedDailyUsage.length - 1;
51
+ }
52
+ if ((_a = session === null || session === void 0 ? void 0 : session.locationData) === null || _a === void 0 ? void 0 : _a.country) {
53
+ if (session.locationData.country === 'HU') {
54
+ this.simplifiedDailyUsage[dateIndex].visitorsHun++;
55
+ }
56
+ else {
57
+ this.simplifiedDailyUsage[dateIndex].visitorsElse++;
58
+ }
59
+ }
60
+ this.simplifiedDailyUsage[dateIndex].totalVisitTime += session.totalSessionTime;
61
+ this.simplifiedDailyUsage[dateIndex].averageVisitTime = Math.round((this.simplifiedDailyUsage[dateIndex].totalVisitTime /
62
+ this.simplifiedDailyUsage[dateIndex].visitations.length) * 100) / 100;
63
+ });
64
+ this.simplifiedDailyUsage.sort((a, b) => +new Date(b.date) - +new Date(a.date));
65
+ this.simplifiedDailyUsage.forEach((daily) => {
66
+ daily.visitations.sort((a, b) => +a.sessionStart - +b.sessionStart);
67
+ });
68
+ }
69
+ catch (error) {
70
+ throw new fsm_dynamo_1.Dynamo_Error({
71
+ status: 417,
72
+ errorCode: 'NTS-US0-GLW',
73
+ message: 'getDailyUsage was unsuccessful',
74
+ userMessage: `We've failed to collect last week's usage data.`,
75
+ error
76
+ });
77
+ }
78
+ });
79
+ }
80
+ updateUsageData(req) {
81
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
82
+ try {
83
+ yield this.getDataById();
84
+ this.data.usageData = this.usageData;
85
+ let totalTime = 0;
86
+ this.data.usageData.forEach((data) => {
87
+ totalTime += data.timeSpentOnPage;
88
+ });
89
+ if (!this.data.locationData) {
90
+ this.getLocationDataFromRequest(req);
91
+ }
92
+ this.data.totalSessionTime = totalTime;
93
+ yield this.saveData();
94
+ }
95
+ catch (error) {
96
+ throw new fsm_dynamo_1.Dynamo_Error({
97
+ status: 417,
98
+ errorCode: 'NTS-US0-UU0',
99
+ message: 'updateSessionData was unsuccessful',
100
+ userMessage: `The attempt to update Usage Data was unsuccessful.`,
101
+ error
102
+ });
103
+ }
104
+ });
105
+ }
106
+ closeSession(req) {
107
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
108
+ try {
109
+ yield this.getDataById();
110
+ this.data.sessionEnd = new Date();
111
+ const newTotalSessionTime = +this.data.sessionEnd - +this.data.sessionStart;
112
+ this.data.usageData[this.data.usageData.length - 1].timeSpentOnPage = newTotalSessionTime - this.data.totalSessionTime;
113
+ if (!this.data.locationData) {
114
+ this.getLocationDataFromRequest(req);
115
+ }
116
+ this.data.usageData.sort((a, b) => +a.opened - +b.opened);
117
+ this.data.totalSessionTime = newTotalSessionTime;
118
+ yield this.saveData();
119
+ }
120
+ catch (error) {
121
+ throw new fsm_dynamo_1.Dynamo_Error({
122
+ status: 417,
123
+ errorCode: 'NTS-US0-CS0',
124
+ message: 'closeSession was unsuccessful',
125
+ userMessage: `The attempt to close Usage Session was unsuccessful.`,
126
+ error
127
+ });
128
+ }
129
+ });
130
+ }
131
+ }
132
+ exports.UsageService = UsageService;
133
133
  //# sourceMappingURL=usage.service.js.map
@@ -1,2 +1,2 @@
1
- export * from './usage';
1
+ export * from './usage';
2
2
  //# sourceMappingURL=usage-module.index.d.ts.map
@@ -1,5 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./usage"), exports);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./usage"), exports);
5
5
  //# sourceMappingURL=usage-module.index.js.map
@@ -1,35 +1,35 @@
1
- import { DynamoNTS_ApiCallParams } from '../_models/dynamo-nts-api-call-params';
2
- /**
3
- * This predefined Api service contains the basic API call function which can be used in various ways
4
- */
5
- export declare class DynamoNTS_ApiService {
6
- static defaultErrorUserMsg: string;
7
- /**
8
- *
9
- * @param callParams
10
- * @param inputParams
11
- * @returns
12
- */
13
- static startApiCall<T>(
14
- /**
15
- * you must setup the basic api call params with this.
16
- * follow the instructions in the constructor: new DynamoNTS_ApiCallParams({ ... })
17
- */
18
- callParams: DynamoNTS_ApiCallParams,
19
- /**
20
- * you can pass data and other inputs in this section
21
- */
22
- inputParams?: {
23
- pathParams?: {
24
- /**
25
- * path params setted in endpoint
26
- */
27
- [param: string]: string;
28
- };
29
- /**
30
- * api call's body
31
- */
32
- body?: any;
33
- }): Promise<any>;
34
- }
1
+ import { DynamoNTS_ApiCallParams } from '../_models/dynamo-nts-api-call-params';
2
+ /**
3
+ * This predefined Api service contains the basic API call function which can be used in various ways
4
+ */
5
+ export declare class DynamoNTS_ApiService {
6
+ static defaultErrorUserMsg: string;
7
+ /**
8
+ *
9
+ * @param callParams
10
+ * @param inputParams
11
+ * @returns
12
+ */
13
+ static startApiCall<T>(
14
+ /**
15
+ * you must setup the basic api call params with this.
16
+ * follow the instructions in the constructor: new DynamoNTS_ApiCallParams({ ... })
17
+ */
18
+ callParams: DynamoNTS_ApiCallParams,
19
+ /**
20
+ * you can pass data and other inputs in this section
21
+ */
22
+ inputParams?: {
23
+ pathParams?: {
24
+ /**
25
+ * path params setted in endpoint
26
+ */
27
+ [param: string]: string;
28
+ };
29
+ /**
30
+ * api call's body
31
+ */
32
+ body?: any;
33
+ }): Promise<any>;
34
+ }
35
35
  //# sourceMappingURL=dynamo-nts-api.service.d.ts.map