@diia-inhouse/utils 3.6.0 → 4.0.0
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/dist/publicService.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PublicServiceUtils = void 0;
|
|
4
|
-
const compare_versions_1 = require("compare-versions");
|
|
5
|
-
const types_1 = require("@diia-inhouse/types");
|
|
6
4
|
const applicationUtils_1 = require("./applicationUtils");
|
|
7
5
|
const publicService_1 = require("./interfaces/publicService");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
static serviceAvailabilityStrategies = {
|
|
11
|
-
['officeOfficialWorkspace']: (features) => features[types_1.ProfileFeature.office]?.googleWorkspace === 'true',
|
|
12
|
-
};
|
|
13
|
-
static getContacts(user) {
|
|
6
|
+
exports.PublicServiceUtils = {
|
|
7
|
+
getContacts(user) {
|
|
14
8
|
const { phoneNumber, email } = user;
|
|
15
9
|
return {
|
|
16
10
|
title: 'Контактні дані',
|
|
@@ -19,8 +13,8 @@ class PublicServiceUtils {
|
|
|
19
13
|
email,
|
|
20
14
|
attentionMessage: undefined,
|
|
21
15
|
};
|
|
22
|
-
}
|
|
23
|
-
|
|
16
|
+
},
|
|
17
|
+
getContactsText(user) {
|
|
24
18
|
const { phoneNumber, email, authEntryPoint } = user;
|
|
25
19
|
const { isBankId, target } = authEntryPoint || {};
|
|
26
20
|
const isBankApp = [publicService_1.AuthProviderName.PrivatBank, publicService_1.AuthProviderName.Monobank].includes(target);
|
|
@@ -31,50 +25,21 @@ class PublicServiceUtils {
|
|
|
31
25
|
: 'Дані заповнені з вашого банку. Перевірте їх та виправте за потреби.';
|
|
32
26
|
}
|
|
33
27
|
return 'Будь ласка, заповніть контактні дані.';
|
|
34
|
-
}
|
|
35
|
-
|
|
28
|
+
},
|
|
29
|
+
extractContextMenu(settings, appVersion) {
|
|
36
30
|
const { contextMenu } = settings;
|
|
37
31
|
if (!contextMenu) {
|
|
38
32
|
return contextMenu;
|
|
39
33
|
}
|
|
40
34
|
return applicationUtils_1.ApplicationUtils.filterByAppVersions(contextMenu, appVersion);
|
|
41
|
-
}
|
|
42
|
-
|
|
35
|
+
},
|
|
36
|
+
extractNavigationPanel(settings, appVersion, header) {
|
|
43
37
|
const { name } = settings;
|
|
44
38
|
const contextMenu = this.extractContextMenu(settings, appVersion) ?? [];
|
|
45
39
|
return {
|
|
46
40
|
header: header || name,
|
|
47
41
|
contextMenu,
|
|
48
42
|
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const { code, status, sessionTypes, profileFeature, platformMinVersion, appVersions } = settings;
|
|
52
|
-
const { sessionType } = user;
|
|
53
|
-
const { platformType, platformVersion, appVersion } = platformAppVersion;
|
|
54
|
-
if (status !== types_1.PublicServiceStatus.active) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
if (!sessionTypes.includes(sessionType)) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
const featuresList = (0, session_1.profileFeaturesToList)(userFeatures);
|
|
61
|
-
if (profileFeature && !featuresList?.includes(profileFeature)) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
const strategy = this.serviceAvailabilityStrategies[code];
|
|
65
|
-
if (strategy && !strategy(userFeatures)) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
const platformMinVersionValue = platformMinVersion?.[platformType];
|
|
69
|
-
if (platformMinVersionValue && (0, compare_versions_1.compare)(platformVersion, platformMinVersionValue, '<')) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
const appVersionsBySession = appVersions?.[sessionType];
|
|
73
|
-
if (!appVersionsBySession) {
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
return applicationUtils_1.ApplicationUtils.isAppVersionMatch(appVersion, platformType, appVersionsBySession);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.PublicServiceUtils = PublicServiceUtils;
|
|
43
|
+
},
|
|
44
|
+
};
|
|
80
45
|
//# sourceMappingURL=publicService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicService.js","sourceRoot":"","sources":["../src/publicService.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"publicService.js","sourceRoot":"","sources":["../src/publicService.ts"],"names":[],"mappings":";;;AASA,yDAAqD;AACrD,8DAA6D;AAEhD,QAAA,kBAAkB,GAAG;IAC9B,WAAW,CAAC,IAAmB;QAC3B,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,IAAI,CAAA;QAEnC,OAAO;YACH,KAAK,EAAE,gBAAgB;YACvB,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;YAChC,WAAW;YACX,KAAK;YACL,gBAAgB,EAAE,SAAS;SAC9B,CAAA;IACL,CAAC;IACD,eAAe,CAAC,IAAmB;QAC/B,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,IAAI,CAAA;QACnD,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,cAAc,IAAI,EAAE,CAAA;QAEjD,MAAM,SAAS,GAAG,CAAC,gCAAgB,CAAC,UAAU,EAAE,gCAAgB,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAmB,MAAM,CAAC,CAAA;QAC7G,MAAM,oBAAoB,GAAG,QAAQ,IAAI,SAAS,CAAA;QAElD,IAAI,oBAAoB,IAAI,WAAW,IAAI,KAAK,EAAE;YAC9C,OAAO,QAAQ;gBACX,CAAC,CAAC,sEAAsE;gBACxE,CAAC,CAAC,qEAAqE,CAAA;SAC9E;QAED,OAAO,uCAAuC,CAAA;IAClD,CAAC;IACD,kBAAkB,CACd,QAA+B,EAC/B,UAA0C;QAE1C,MAAM,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAA;QAChC,IAAI,CAAC,WAAW,EAAE;YACd,OAAO,WAAW,CAAA;SACrB;QAED,OAAO,mCAAgB,CAAC,mBAAmB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAA;IACxE,CAAC;IACD,sBAAsB,CAClB,QAA+B,EAC/B,UAA0C,EAC1C,MAAe;QAEf,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAA;QACzB,MAAM,WAAW,GAAG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE,UAAU,CAAC,IAAI,EAAE,CAAA;QAEvE,OAAO;YACH,MAAM,EAAE,MAAM,IAAI,IAAI;YACtB,WAAW;SACd,CAAA;IACL,CAAC;CACJ,CAAA"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
static isAvailable(settings: PublicServiceSettings, user: AppUser, platformAppVersion: PlatformAppVersion, userFeatures?: UserFeatures): boolean;
|
|
9
|
-
}
|
|
1
|
+
import { ContactsResponse, NavigationPanel, PlatformAppVersion, PublicServiceContextMenu, PublicServiceSettings, UserTokenData } from '@diia-inhouse/types';
|
|
2
|
+
export declare const PublicServiceUtils: {
|
|
3
|
+
getContacts(user: UserTokenData): ContactsResponse;
|
|
4
|
+
getContactsText(user: UserTokenData): string;
|
|
5
|
+
extractContextMenu(settings: PublicServiceSettings, appVersion: PlatformAppVersion | undefined): PublicServiceContextMenu[] | undefined;
|
|
6
|
+
extractNavigationPanel(settings: PublicServiceSettings, appVersion: PlatformAppVersion | undefined, header?: string): NavigationPanel | undefined;
|
|
7
|
+
};
|