@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.
- package/LICENSE +2 -2
- package/lib/_constants/dynamo-nts-global-settings.d.ts +2 -2
- package/lib/_constants/dynamo-nts-global-settings.js +17 -17
- package/lib/_constants/index.d.ts +1 -1
- package/lib/_constants/index.js +4 -4
- package/lib/_enums/data-model-type.enum.d.ts +12 -12
- package/lib/_enums/data-model-type.enum.js +16 -16
- package/lib/_enums/data-model-type.enum.js.map +1 -1
- package/lib/_enums/dynamo-nts-data-service-function.enum.d.ts +12 -12
- package/lib/_enums/dynamo-nts-data-service-function.enum.js +18 -18
- package/lib/_enums/dynamo-nts-data-service-function.enum.js.map +1 -1
- package/lib/_enums/dynamo-nts-route-security.enum.d.ts +11 -11
- package/lib/_enums/dynamo-nts-route-security.enum.js +15 -15
- package/lib/_enums/dynamo-nts-route-security.enum.js.map +1 -1
- package/lib/_enums/dynamo-nts-socket-security.enum.d.ts +10 -10
- package/lib/_enums/dynamo-nts-socket-security.enum.js +14 -14
- package/lib/_enums/dynamo-nts-socket-security.enum.js.map +1 -1
- package/lib/_enums/http/http-call-type.enum.d.ts +11 -11
- package/lib/_enums/http/http-call-type.enum.js +15 -15
- package/lib/_enums/http/http-call-type.enum.js.map +1 -1
- package/lib/_enums/http/http-response-type.enum.d.ts +6 -6
- package/lib/_enums/http/http-response-type.enum.js +10 -10
- package/lib/_enums/http/http-response-type.enum.js.map +1 -1
- package/lib/_enums/http/socket-event.enum.d.ts +9 -8
- package/lib/_enums/http/socket-event.enum.d.ts.map +1 -1
- package/lib/_enums/http/socket-event.enum.js +13 -12
- package/lib/_enums/http/socket-event.enum.js.map +1 -1
- package/lib/_enums/index.d.ts +8 -8
- package/lib/_enums/index.js +13 -13
- package/lib/_enums/predefined-data-types.enum.d.ts +10 -10
- package/lib/_enums/predefined-data-types.enum.js +14 -14
- package/lib/_enums/predefined-data-types.enum.js.map +1 -1
- package/lib/_interfaces/certification-settings.interface.d.ts +7 -0
- package/lib/_interfaces/certification-settings.interface.d.ts.map +1 -0
- package/lib/_interfaces/certification-settings.interface.js +3 -0
- package/lib/_interfaces/certification-settings.interface.js.map +1 -0
- package/lib/_interfaces/global-service-settings.interface.d.ts +18 -0
- package/lib/_interfaces/global-service-settings.interface.d.ts.map +1 -0
- package/lib/_interfaces/global-service-settings.interface.js +3 -0
- package/lib/_interfaces/global-service-settings.interface.js.map +1 -0
- package/lib/_interfaces/index.d.ts +1 -0
- package/lib/_interfaces/index.d.ts.map +1 -0
- package/lib/_interfaces/index.js +4 -0
- package/lib/_interfaces/index.js.map +1 -0
- package/lib/_interfaces/port-settings.interface.d.ts +5 -0
- package/lib/_interfaces/port-settings.interface.d.ts.map +1 -0
- package/lib/_interfaces/port-settings.interface.js +3 -0
- package/lib/_interfaces/port-settings.interface.js.map +1 -0
- package/lib/_models/dynamo-nts-api-call-params.d.ts +95 -95
- package/lib/_models/dynamo-nts-api-call-params.js +47 -47
- package/lib/_models/dynamo-nts-app-params.d.ts +49 -49
- package/lib/_models/dynamo-nts-app-params.js +17 -17
- package/lib/_models/dynamo-nts-endpoint-params.d.ts +80 -80
- package/lib/_models/dynamo-nts-endpoint-params.js +139 -139
- package/lib/_models/dynamo-nts-global-settings.d.ts +53 -53
- package/lib/_models/dynamo-nts-global-settings.js +2 -2
- package/lib/_models/dynamo-nts-routing-module-settings.d.ts +19 -19
- package/lib/_models/dynamo-nts-routing-module-settings.js +2 -2
- package/lib/_models/dynamo-nts-socket-event-params.d.ts +32 -30
- package/lib/_models/dynamo-nts-socket-event-params.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-socket-event-params.js +80 -79
- package/lib/_models/dynamo-nts-socket-event-params.js.map +1 -1
- package/lib/_models/dynamo-nts-socket-presence.d.ts +21 -0
- package/lib/_models/dynamo-nts-socket-presence.d.ts.map +1 -0
- package/lib/_models/dynamo-nts-socket-presence.js +45 -0
- package/lib/_models/dynamo-nts-socket-presence.js.map +1 -0
- package/lib/_models/dynamo-nts-socket-service-params.d.ts +18 -18
- package/lib/_models/dynamo-nts-socket-service-params.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-socket-service-params.js +26 -26
- package/lib/_models/dynamo-nts-socket-service-params.js.map +1 -1
- package/lib/_models/index.d.ts +7 -8
- package/lib/_models/index.d.ts.map +1 -1
- package/lib/_models/index.js +12 -12
- package/lib/_models/index.js.map +1 -1
- package/lib/_modules/api-service.index.d.ts +5 -5
- package/lib/_modules/api-service.index.js +11 -11
- package/lib/_modules/app-extended.index.d.ts +15 -12
- package/lib/_modules/app-extended.index.d.ts.map +1 -1
- package/lib/_modules/app-extended.index.js +23 -19
- package/lib/_modules/app-extended.index.js.map +1 -1
- package/lib/_modules/app.index.d.ts +13 -10
- package/lib/_modules/app.index.d.ts.map +1 -1
- package/lib/_modules/app.index.js +21 -17
- package/lib/_modules/app.index.js.map +1 -1
- package/lib/_modules/auth.index.d.ts +3 -3
- package/lib/_modules/auth.index.js +8 -8
- package/lib/_modules/constants.index.d.ts +1 -1
- package/lib/_modules/constants.index.js +4 -4
- package/lib/_modules/controller.index.d.ts +4 -4
- package/lib/_modules/controller.index.js +10 -10
- package/lib/_modules/custom-data/custom-data.controller.d.ts +5 -5
- package/lib/_modules/custom-data/custom-data.controller.js +55 -55
- package/lib/_modules/custom-data/custom-data.service.d.ts +5 -5
- package/lib/_modules/custom-data/custom-data.service.js +11 -11
- package/lib/_modules/custom-data/get-custom-data-routing-module.d.ts +3 -3
- package/lib/_modules/custom-data/get-custom-data-routing-module.js +17 -17
- package/lib/_modules/custom-data/index.d.ts +4 -4
- package/lib/_modules/custom-data/index.js +8 -8
- package/lib/_modules/custom-data-module.index.d.ts +1 -1
- package/lib/_modules/custom-data-module.index.js +4 -4
- package/lib/_modules/data-service.index.d.ts +5 -5
- package/lib/_modules/data-service.index.js +10 -10
- package/lib/_modules/email.index.d.ts +3 -3
- package/lib/_modules/email.index.js +8 -8
- package/lib/_modules/enums.index.d.ts +1 -1
- package/lib/_modules/enums.index.js +4 -4
- package/lib/_modules/models.index.d.ts +1 -1
- package/lib/_modules/models.index.js +4 -4
- package/lib/_modules/services.index.d.ts +1 -1
- package/lib/_modules/services.index.js +4 -4
- package/lib/_modules/test/get-test-routing-module.d.ts +3 -3
- package/lib/_modules/test/get-test-routing-module.js +17 -17
- package/lib/_modules/test/index.d.ts +3 -3
- package/lib/_modules/test/index.js +7 -7
- package/lib/_modules/test/test.controller.d.ts +5 -5
- package/lib/_modules/test/test.controller.js +104 -104
- package/lib/_modules/test-module.index.d.ts +1 -1
- package/lib/_modules/test-module.index.js +4 -4
- package/lib/_modules/usage/get-usage-routing-module.d.ts +3 -3
- package/lib/_modules/usage/get-usage-routing-module.js +17 -17
- package/lib/_modules/usage/index.d.ts +4 -4
- package/lib/_modules/usage/index.js +8 -8
- package/lib/_modules/usage/usage-controller.d.ts +6 -6
- package/lib/_modules/usage/usage-controller.js +88 -88
- package/lib/_modules/usage/usage.service.d.ts +16 -16
- package/lib/_modules/usage/usage.service.js +132 -132
- package/lib/_modules/usage-module.index.d.ts +1 -1
- package/lib/_modules/usage-module.index.js +4 -4
- package/lib/_services/dynamo-nts-api.service.d.ts +34 -34
- package/lib/_services/dynamo-nts-api.service.js +188 -188
- package/lib/_services/dynamo-nts-app-extended.d.ts +128 -128
- package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-app-extended.js +212 -212
- package/lib/_services/dynamo-nts-app-extended.js.map +1 -1
- package/lib/_services/dynamo-nts-app.d.ts +270 -278
- package/lib/_services/dynamo-nts-app.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-app.js +371 -371
- package/lib/_services/dynamo-nts-app.js.map +1 -1
- package/lib/_services/dynamo-nts-app.spec.d.ts +1 -0
- package/lib/_services/dynamo-nts-app.spec.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-app.spec.js +10 -0
- package/lib/_services/dynamo-nts-app.spec.js.map +1 -0
- package/lib/_services/dynamo-nts-auth.service.d.ts +127 -127
- package/lib/_services/dynamo-nts-auth.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-auth.service.js +53 -53
- package/lib/_services/dynamo-nts-auth.service.js.map +1 -1
- package/lib/_services/dynamo-nts-controller.service.d.ts +105 -105
- package/lib/_services/dynamo-nts-controller.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-controller.service.js +57 -57
- package/lib/_services/dynamo-nts-controller.service.js.map +1 -1
- package/lib/_services/dynamo-nts-data.service.d.ts +230 -229
- package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-data.service.js +689 -686
- package/lib/_services/dynamo-nts-data.service.js.map +1 -1
- package/lib/_services/dynamo-nts-db-service-collection.service.d.ts +8 -8
- package/lib/_services/dynamo-nts-db-service-collection.service.js +10 -10
- package/lib/_services/dynamo-nts-db.service.d.ts +312 -312
- package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-db.service.js +856 -856
- package/lib/_services/dynamo-nts-db.service.js.map +1 -1
- package/lib/_services/dynamo-nts-email-service-collection.service.d.ts +18 -18
- package/lib/_services/dynamo-nts-email-service-collection.service.js +20 -20
- package/lib/_services/dynamo-nts-email.service.d.ts +56 -56
- package/lib/_services/dynamo-nts-email.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-email.service.js +203 -203
- package/lib/_services/dynamo-nts-email.service.js.map +1 -1
- package/lib/_services/dynamo-nts-global.service.d.ts +71 -84
- package/lib/_services/dynamo-nts-global.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-global.service.js +156 -156
- package/lib/_services/dynamo-nts-global.service.js.map +1 -1
- package/lib/_services/dynamo-nts-routing-module.service.d.ts +76 -76
- package/lib/_services/dynamo-nts-routing-module.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-routing-module.service.js +191 -191
- package/lib/_services/dynamo-nts-routing-module.service.js.map +1 -1
- package/lib/_services/dynamo-nts-shared.service.d.ts +31 -31
- package/lib/_services/dynamo-nts-shared.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-shared.service.js +70 -70
- package/lib/_services/dynamo-nts-shared.service.js.map +1 -1
- package/lib/_services/dynamo-nts-shared.service.spec.d.ts +2 -0
- package/lib/_services/dynamo-nts-shared.service.spec.d.ts.map +1 -0
- package/lib/_services/dynamo-nts-shared.service.spec.js +12 -0
- package/lib/_services/dynamo-nts-shared.service.spec.js.map +1 -0
- package/lib/_services/dynamo-nts-singleton.service.d.ts +8 -8
- package/lib/_services/dynamo-nts-singleton.service.js +18 -18
- package/lib/_services/dynamo-nts-singleton.service.js.map +1 -1
- package/lib/_services/dynamo-nts-socket-service-collection.service.d.ts +9 -9
- package/lib/_services/dynamo-nts-socket-service-collection.service.js +13 -13
- package/lib/_services/dynamo-nts-socket.service.d.ts +57 -45
- package/lib/_services/dynamo-nts-socket.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-socket.service.js +188 -165
- package/lib/_services/dynamo-nts-socket.service.js.map +1 -1
- package/lib/_services/index.d.ts +14 -16
- package/lib/_services/index.d.ts.map +1 -1
- package/lib/_services/index.js +20 -20
- package/lib/_services/index.js.map +1 -1
- package/lib/index.d.ts +6 -6
- package/lib/index.js +14 -14
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package SAVE.json +216 -0
- package/package-NEW with test but not working.json +228 -0
- package/package.json +15 -8
- package/spec/support/jasmine.json +14 -0
- package/src/_enums/http/socket-event.enum.ts +2 -1
- package/src/_interfaces/certification-settings.interface.ts +7 -0
- package/src/_interfaces/global-service-settings.interface.ts +23 -0
- package/src/_interfaces/index.ts +5 -0
- package/src/_interfaces/port-settings.interface.ts +5 -0
- package/src/_models/dynamo-nts-socket-event-params.ts +23 -21
- package/src/_models/{dynamo-nts-socket-dictionary.ts → dynamo-nts-socket-presence.ts} +21 -5
- package/src/_models/dynamo-nts-socket-service-params.ts +1 -0
- package/src/_models/index.ts +2 -2
- package/src/_modules/app-extended.index.ts +7 -2
- package/src/_modules/app.index.ts +5 -0
- package/src/_services/dynamo-nts-app-extended.ts +6 -2
- package/src/_services/dynamo-nts-app.spec.ts +14 -0
- package/src/_services/dynamo-nts-app.ts +8 -14
- package/src/_services/dynamo-nts-auth.service.ts +1 -0
- package/src/_services/dynamo-nts-controller.service.ts +2 -1
- package/src/_services/dynamo-nts-data.service.ts +16 -10
- package/src/_services/dynamo-nts-db.service.ts +8 -5
- package/src/_services/dynamo-nts-email.service.ts +1 -0
- package/src/_services/dynamo-nts-global.service.ts +3 -18
- package/src/_services/dynamo-nts-routing-module.service.ts +1 -0
- package/src/_services/dynamo-nts-shared.service.spec.ts +10 -0
- package/src/_services/dynamo-nts-shared.service.ts +2 -1
- package/src/_services/dynamo-nts-socket.service.ts +80 -41
- 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
|