@diia-inhouse/utils 5.3.29 → 6.0.8
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/address.d.ts +7 -0
- package/dist/address.js +38 -41
- package/dist/applicationUtils.d.ts +225 -0
- package/dist/applicationUtils.js +576 -678
- package/dist/asserts.d.ts +6 -0
- package/dist/asserts.js +12 -19
- package/dist/dictionaries/phoneCodes.js +2435 -2442
- package/dist/guards.d.ts +22 -0
- package/dist/guards.js +58 -74
- package/dist/index.d.ts +36 -0
- package/dist/index.js +34 -70
- package/dist/integration.d.ts +6 -0
- package/dist/integration.js +7 -10
- package/dist/interfaces/asserts.d.ts +9 -0
- package/dist/interfaces/publicService.d.ts +11 -0
- package/dist/interfaces/slack.d.ts +6 -0
- package/dist/network.d.ts +17 -0
- package/dist/network.js +64 -72
- package/dist/payment.d.ts +8 -0
- package/dist/payment.js +19 -22
- package/dist/pdfUtils.d.ts +6 -0
- package/dist/pdfUtils.js +7 -10
- package/dist/phoneticChecker/index.d.ts +9 -0
- package/dist/phoneticChecker/index.js +18 -23
- package/dist/phoneticChecker/metaphone.js +38 -41
- package/dist/publicService.d.ts +59 -0
- package/dist/publicService.js +137 -150
- package/dist/random.d.ts +7 -0
- package/dist/random.js +11 -10
- package/dist/session.d.ts +7 -0
- package/dist/session.js +10 -19
- package/dist/slackFormatting.d.ts +13 -0
- package/dist/slackFormatting.js +41 -24
- package/dist/typeUtils.d.ts +8 -0
- package/dist/typeUtils.js +13 -15
- package/package.json +42 -27
- package/dist/address.js.map +0 -1
- package/dist/applicationUtils.js.map +0 -1
- package/dist/asserts.js.map +0 -1
- package/dist/dictionaries/phoneCodes.js.map +0 -1
- package/dist/guards.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/integration.js.map +0 -1
- package/dist/interfaces/applicationUtils.js +0 -3
- package/dist/interfaces/applicationUtils.js.map +0 -1
- package/dist/interfaces/asserts.js +0 -3
- package/dist/interfaces/asserts.js.map +0 -1
- package/dist/interfaces/error.js +0 -3
- package/dist/interfaces/error.js.map +0 -1
- package/dist/interfaces/publicService.js +0 -12
- package/dist/interfaces/publicService.js.map +0 -1
- package/dist/interfaces/slack.js +0 -3
- package/dist/interfaces/slack.js.map +0 -1
- package/dist/network.js.map +0 -1
- package/dist/payment.js.map +0 -1
- package/dist/pdfUtils.js.map +0 -1
- package/dist/phoneticChecker/index.js.map +0 -1
- package/dist/phoneticChecker/metaphone.js.map +0 -1
- package/dist/publicService.js.map +0 -1
- package/dist/random.js.map +0 -1
- package/dist/session.js.map +0 -1
- package/dist/slackFormatting.js.map +0 -1
- package/dist/typeUtils.js.map +0 -1
- package/dist/types/address.d.ts +0 -4
- package/dist/types/applicationUtils.d.ts +0 -212
- package/dist/types/asserts.d.ts +0 -2
- package/dist/types/dictionaries/phoneCodes.d.ts +0 -2
- package/dist/types/guards.d.ts +0 -18
- package/dist/types/index.d.ts +0 -86
- package/dist/types/integration.d.ts +0 -3
- package/dist/types/interfaces/applicationUtils.d.ts +0 -1
- package/dist/types/interfaces/asserts.d.ts +0 -5
- package/dist/types/interfaces/error.d.ts +0 -7
- package/dist/types/interfaces/publicService.d.ts +0 -15
- package/dist/types/interfaces/slack.d.ts +0 -3
- package/dist/types/network.d.ts +0 -13
- package/dist/types/payment.d.ts +0 -5
- package/dist/types/pdfUtils.d.ts +0 -3
- package/dist/types/phoneticChecker/index.d.ts +0 -7
- package/dist/types/phoneticChecker/metaphone.d.ts +0 -6
- package/dist/types/publicService.d.ts +0 -55
- package/dist/types/random.d.ts +0 -5
- package/dist/types/session.d.ts +0 -3
- package/dist/types/slackFormatting.d.ts +0 -7
- package/dist/types/typeUtils.d.ts +0 -5
package/dist/guards.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ApiError } from "@diia-inhouse/errors";
|
|
2
|
+
import { AcquirerSession, ActionSession, AppUser, EResidentSession, EResidentTokenData, OnBeforeApplicationShutdown, OnDestroy, OnHealthCheck, OnInit, OnRegistrationsFinished, ServiceEntranceSession, UserSession, UserTokenData } from "@diia-inhouse/types";
|
|
3
|
+
|
|
4
|
+
//#region src/guards.d.ts
|
|
5
|
+
declare const Guards: {
|
|
6
|
+
isError(value: unknown): value is Error;
|
|
7
|
+
apiError(err: Error): err is ApiError;
|
|
8
|
+
isUserSession(session: ActionSession | undefined): session is UserSession;
|
|
9
|
+
isUser(user: AppUser | undefined): user is UserTokenData;
|
|
10
|
+
isEResidentSession(session: ActionSession | undefined): session is EResidentSession;
|
|
11
|
+
isEResident(user: AppUser | undefined): user is EResidentTokenData;
|
|
12
|
+
isAcquirerSession(session: ActionSession | undefined): session is AcquirerSession;
|
|
13
|
+
isServiceEntranceSession(session: ActionSession | undefined): session is ServiceEntranceSession;
|
|
14
|
+
hasOnInitHook(instance: unknown): instance is OnInit;
|
|
15
|
+
hasOnHealthCheckHook(instance: unknown): instance is OnHealthCheck;
|
|
16
|
+
hasOnDestroyHook(instance: unknown): instance is OnDestroy;
|
|
17
|
+
hasOnRegistrationsFinishedHook(instance: unknown): instance is OnRegistrationsFinished;
|
|
18
|
+
hasOnBeforeApplicationShutdownHook(instance: unknown): instance is OnBeforeApplicationShutdown;
|
|
19
|
+
isSettledError(value: PromiseSettledResult<unknown>): value is PromiseRejectedResult;
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Guards };
|
package/dist/guards.js
CHANGED
|
@@ -1,75 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return (0, lodash_1.isFunction)(instance?.onInit);
|
|
58
|
-
},
|
|
59
|
-
hasOnHealthCheckHook(instance) {
|
|
60
|
-
return (0, lodash_1.isFunction)(instance?.onHealthCheck);
|
|
61
|
-
},
|
|
62
|
-
hasOnDestroyHook(instance) {
|
|
63
|
-
return (0, lodash_1.isFunction)(instance?.onDestroy);
|
|
64
|
-
},
|
|
65
|
-
hasOnRegistrationsFinishedHook(instance) {
|
|
66
|
-
return (0, lodash_1.isFunction)(instance?.onRegistrationsFinished);
|
|
67
|
-
},
|
|
68
|
-
hasOnBeforeApplicationShutdownHook(instance) {
|
|
69
|
-
return (0, lodash_1.isFunction)(instance?.onBeforeApplicationShutdown);
|
|
70
|
-
},
|
|
71
|
-
isSettledError(value) {
|
|
72
|
-
return value.status === 'rejected';
|
|
73
|
-
},
|
|
1
|
+
import lodash from "lodash";
|
|
2
|
+
import { ApiError } from "@diia-inhouse/errors";
|
|
3
|
+
import { SessionType } from "@diia-inhouse/types";
|
|
4
|
+
//#region src/guards.ts
|
|
5
|
+
const { isFunction } = lodash;
|
|
6
|
+
const Guards = {
|
|
7
|
+
isError(value) {
|
|
8
|
+
return value instanceof Error;
|
|
9
|
+
},
|
|
10
|
+
apiError(err) {
|
|
11
|
+
return err instanceof ApiError;
|
|
12
|
+
},
|
|
13
|
+
isUserSession(session) {
|
|
14
|
+
if (!session) return false;
|
|
15
|
+
if (session.sessionType !== SessionType.User) return false;
|
|
16
|
+
return session.user !== void 0;
|
|
17
|
+
},
|
|
18
|
+
isUser(user) {
|
|
19
|
+
return user !== void 0 && user.sessionType === SessionType.User;
|
|
20
|
+
},
|
|
21
|
+
isEResidentSession(session) {
|
|
22
|
+
if (!session) return false;
|
|
23
|
+
if (session.sessionType !== SessionType.EResident) return false;
|
|
24
|
+
return session.user !== void 0;
|
|
25
|
+
},
|
|
26
|
+
isEResident(user) {
|
|
27
|
+
return user !== void 0 && user.sessionType === SessionType.EResident;
|
|
28
|
+
},
|
|
29
|
+
isAcquirerSession(session) {
|
|
30
|
+
if (!session) return false;
|
|
31
|
+
if (session.sessionType !== SessionType.Acquirer) return false;
|
|
32
|
+
return session.acquirer !== void 0;
|
|
33
|
+
},
|
|
34
|
+
isServiceEntranceSession(session) {
|
|
35
|
+
if (!session) return false;
|
|
36
|
+
if (session.sessionType !== SessionType.ServiceEntrance) return false;
|
|
37
|
+
return session.entrance !== void 0;
|
|
38
|
+
},
|
|
39
|
+
hasOnInitHook(instance) {
|
|
40
|
+
return isFunction(instance?.onInit);
|
|
41
|
+
},
|
|
42
|
+
hasOnHealthCheckHook(instance) {
|
|
43
|
+
return isFunction(instance?.onHealthCheck);
|
|
44
|
+
},
|
|
45
|
+
hasOnDestroyHook(instance) {
|
|
46
|
+
return isFunction(instance?.onDestroy);
|
|
47
|
+
},
|
|
48
|
+
hasOnRegistrationsFinishedHook(instance) {
|
|
49
|
+
return isFunction(instance?.onRegistrationsFinished);
|
|
50
|
+
},
|
|
51
|
+
hasOnBeforeApplicationShutdownHook(instance) {
|
|
52
|
+
return isFunction(instance?.onBeforeApplicationShutdown);
|
|
53
|
+
},
|
|
54
|
+
isSettledError(value) {
|
|
55
|
+
return value.status === "rejected";
|
|
56
|
+
}
|
|
74
57
|
};
|
|
75
|
-
//#
|
|
58
|
+
//#endregion
|
|
59
|
+
export { Guards };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AddressUtils } from "./address.js";
|
|
2
|
+
import { ApplicationUtils } from "./applicationUtils.js";
|
|
3
|
+
import { Asserts } from "./asserts.js";
|
|
4
|
+
import { Guards } from "./guards.js";
|
|
5
|
+
import { IntegrationUtils } from "./integration.js";
|
|
6
|
+
import { NetworkUtils } from "./network.js";
|
|
7
|
+
import { PaymentUtils } from "./payment.js";
|
|
8
|
+
import { PdfUtils } from "./pdfUtils.js";
|
|
9
|
+
import { PublicServiceUtils } from "./publicService.js";
|
|
10
|
+
import { RandomUtils } from "./random.js";
|
|
11
|
+
import { SlackFormattingUtils } from "./slackFormatting.js";
|
|
12
|
+
import { TypeUtils } from "./typeUtils.js";
|
|
13
|
+
import { phoneticChecker } from "./phoneticChecker/index.js";
|
|
14
|
+
import { extractProfileFeatures, profileFeaturesToList } from "./session.js";
|
|
15
|
+
|
|
16
|
+
//#region src/index.d.ts
|
|
17
|
+
declare const asserts: typeof Asserts;
|
|
18
|
+
declare const guards: typeof Guards;
|
|
19
|
+
declare const utils: typeof ApplicationUtils;
|
|
20
|
+
declare const pdfUtils: typeof PdfUtils;
|
|
21
|
+
declare class Utils {
|
|
22
|
+
address: typeof AddressUtils;
|
|
23
|
+
application: typeof ApplicationUtils;
|
|
24
|
+
network: typeof NetworkUtils;
|
|
25
|
+
payment: typeof PaymentUtils;
|
|
26
|
+
slackFormatting: typeof SlackFormattingUtils;
|
|
27
|
+
asserts: typeof Asserts;
|
|
28
|
+
guards: typeof Guards;
|
|
29
|
+
integration: typeof IntegrationUtils;
|
|
30
|
+
pdf: typeof PdfUtils;
|
|
31
|
+
publicService: typeof PublicServiceUtils;
|
|
32
|
+
random: typeof RandomUtils;
|
|
33
|
+
type: typeof TypeUtils;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { AddressUtils, IntegrationUtils, NetworkUtils, PaymentUtils, PublicServiceUtils, RandomUtils, SlackFormattingUtils, TypeUtils, Utils, asserts, extractProfileFeatures, guards, pdfUtils, phoneticChecker, profileFeaturesToList, utils };
|
package/dist/index.js
CHANGED
|
@@ -1,71 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { AddressUtils } from "./address.js";
|
|
2
|
+
import { ApplicationUtils } from "./applicationUtils.js";
|
|
3
|
+
import { Asserts } from "./asserts.js";
|
|
4
|
+
import { Guards } from "./guards.js";
|
|
5
|
+
import { IntegrationUtils } from "./integration.js";
|
|
6
|
+
import { NetworkUtils } from "./network.js";
|
|
7
|
+
import { PaymentUtils } from "./payment.js";
|
|
8
|
+
import { PdfUtils } from "./pdfUtils.js";
|
|
9
|
+
import { PublicServiceUtils } from "./publicService.js";
|
|
10
|
+
import { RandomUtils } from "./random.js";
|
|
11
|
+
import { SlackFormattingUtils } from "./slackFormatting.js";
|
|
12
|
+
import { TypeUtils } from "./typeUtils.js";
|
|
13
|
+
import { phoneticChecker } from "./phoneticChecker/index.js";
|
|
14
|
+
import { extractProfileFeatures, profileFeaturesToList } from "./session.js";
|
|
15
|
+
//#region src/index.ts
|
|
16
|
+
const asserts = Asserts;
|
|
17
|
+
const guards = Guards;
|
|
18
|
+
const utils = ApplicationUtils;
|
|
19
|
+
const pdfUtils = PdfUtils;
|
|
20
|
+
var Utils = class {
|
|
21
|
+
address = AddressUtils;
|
|
22
|
+
application = ApplicationUtils;
|
|
23
|
+
network = NetworkUtils;
|
|
24
|
+
payment = PaymentUtils;
|
|
25
|
+
slackFormatting = SlackFormattingUtils;
|
|
26
|
+
asserts = Asserts;
|
|
27
|
+
guards = Guards;
|
|
28
|
+
integration = IntegrationUtils;
|
|
29
|
+
pdf = PdfUtils;
|
|
30
|
+
publicService = PublicServiceUtils;
|
|
31
|
+
random = RandomUtils;
|
|
32
|
+
type = TypeUtils;
|
|
15
33
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const address_1 = require("./address");
|
|
19
|
-
const applicationUtils_1 = require("./applicationUtils");
|
|
20
|
-
const asserts_1 = require("./asserts");
|
|
21
|
-
const guards_1 = require("./guards");
|
|
22
|
-
const integration_1 = require("./integration");
|
|
23
|
-
const network_1 = require("./network");
|
|
24
|
-
const payment_1 = require("./payment");
|
|
25
|
-
const pdfUtils_1 = require("./pdfUtils");
|
|
26
|
-
const publicService_1 = require("./publicService");
|
|
27
|
-
const random_1 = require("./random");
|
|
28
|
-
const slackFormatting_1 = require("./slackFormatting");
|
|
29
|
-
const typeUtils_1 = require("./typeUtils");
|
|
30
|
-
const asserts = asserts_1.Asserts;
|
|
31
|
-
exports.asserts = asserts;
|
|
32
|
-
const guards = guards_1.Guards;
|
|
33
|
-
exports.guards = guards;
|
|
34
|
-
const utils = applicationUtils_1.ApplicationUtils;
|
|
35
|
-
exports.utils = utils;
|
|
36
|
-
const pdfUtils = pdfUtils_1.PdfUtils;
|
|
37
|
-
exports.pdfUtils = pdfUtils;
|
|
38
|
-
var typeUtils_2 = require("./typeUtils");
|
|
39
|
-
Object.defineProperty(exports, "TypeUtils", { enumerable: true, get: function () { return typeUtils_2.TypeUtils; } });
|
|
40
|
-
var payment_2 = require("./payment");
|
|
41
|
-
Object.defineProperty(exports, "PaymentUtils", { enumerable: true, get: function () { return payment_2.PaymentUtils; } });
|
|
42
|
-
var publicService_2 = require("./publicService");
|
|
43
|
-
Object.defineProperty(exports, "PublicServiceUtils", { enumerable: true, get: function () { return publicService_2.PublicServiceUtils; } });
|
|
44
|
-
var phoneticChecker_1 = require("./phoneticChecker");
|
|
45
|
-
Object.defineProperty(exports, "phoneticChecker", { enumerable: true, get: function () { return phoneticChecker_1.phoneticChecker; } });
|
|
46
|
-
var network_2 = require("./network");
|
|
47
|
-
Object.defineProperty(exports, "NetworkUtils", { enumerable: true, get: function () { return network_2.NetworkUtils; } });
|
|
48
|
-
var integration_2 = require("./integration");
|
|
49
|
-
Object.defineProperty(exports, "IntegrationUtils", { enumerable: true, get: function () { return integration_2.IntegrationUtils; } });
|
|
50
|
-
var random_2 = require("./random");
|
|
51
|
-
Object.defineProperty(exports, "RandomUtils", { enumerable: true, get: function () { return random_2.RandomUtils; } });
|
|
52
|
-
var address_2 = require("./address");
|
|
53
|
-
Object.defineProperty(exports, "AddressUtils", { enumerable: true, get: function () { return address_2.AddressUtils; } });
|
|
54
|
-
__exportStar(require("./session"), exports);
|
|
55
|
-
__exportStar(require("./slackFormatting"), exports);
|
|
56
|
-
class Utils {
|
|
57
|
-
address = address_1.AddressUtils;
|
|
58
|
-
application = applicationUtils_1.ApplicationUtils;
|
|
59
|
-
network = network_1.NetworkUtils;
|
|
60
|
-
payment = payment_1.PaymentUtils;
|
|
61
|
-
slackFormatting = slackFormatting_1.SlackFormattingUtils;
|
|
62
|
-
asserts = asserts_1.Asserts;
|
|
63
|
-
guards = guards_1.Guards;
|
|
64
|
-
integration = integration_1.IntegrationUtils;
|
|
65
|
-
pdf = pdfUtils_1.PdfUtils;
|
|
66
|
-
publicService = publicService_1.PublicServiceUtils;
|
|
67
|
-
random = random_1.RandomUtils;
|
|
68
|
-
type = typeUtils_1.TypeUtils;
|
|
69
|
-
}
|
|
70
|
-
exports.Utils = Utils;
|
|
71
|
-
//# sourceMappingURL=index.js.map
|
|
34
|
+
//#endregion
|
|
35
|
+
export { AddressUtils, IntegrationUtils, NetworkUtils, PaymentUtils, PublicServiceUtils, RandomUtils, SlackFormattingUtils, TypeUtils, Utils, asserts, extractProfileFeatures, guards, pdfUtils, phoneticChecker, profileFeaturesToList, utils };
|
package/dist/integration.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
},
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=integration.js.map
|
|
1
|
+
//#region src/integration.ts
|
|
2
|
+
const IntegrationUtils = { getRetryDelay(retry, timeLeft, initDelay, maxDelay, multiplier) {
|
|
3
|
+
const delay = Math.min(initDelay * Math.pow(multiplier, retry), maxDelay);
|
|
4
|
+
return Math.min(delay, timeLeft);
|
|
5
|
+
} };
|
|
6
|
+
//#endregion
|
|
7
|
+
export { IntegrationUtils };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TokenData, VerifiedBaseTokenData } from "@diia-inhouse/types";
|
|
2
|
+
|
|
3
|
+
//#region src/interfaces/asserts.d.ts
|
|
4
|
+
interface AssertsContainer {
|
|
5
|
+
isRefreshTokenExists(tokenData: TokenData): asserts tokenData is VerifiedBaseTokenData<TokenData>;
|
|
6
|
+
assertObjectHasOnlyOneOf<T extends object>(object: T, ...keys: (keyof T)[]): void | never;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { AssertsContainer };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/interfaces/publicService.d.ts
|
|
2
|
+
interface InputPhoneCodeOrgParams {
|
|
3
|
+
inputCode?: string;
|
|
4
|
+
phoneValue?: string;
|
|
5
|
+
codeValueId?: string;
|
|
6
|
+
codeIds?: string[];
|
|
7
|
+
hint?: string;
|
|
8
|
+
codeValueIsEditable?: boolean;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { InputPhoneCodeOrgParams };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GrpcStatusCode } from "@diia-inhouse/types";
|
|
2
|
+
|
|
3
|
+
//#region src/network.d.ts
|
|
4
|
+
declare class NetworkUtils {
|
|
5
|
+
private static readonly grpcStatusCodes;
|
|
6
|
+
private static readonly httpStatusCodeToGrpcCode;
|
|
7
|
+
/**
|
|
8
|
+
* @see https://gist.github.com/hamakn/708b9802ca845eb59f3975dbb3ae2a01
|
|
9
|
+
*/
|
|
10
|
+
private static readonly grpcCodeToHttpStatusCode;
|
|
11
|
+
static isHttpCode(code: number | undefined): boolean;
|
|
12
|
+
static isGrpcCode(code: number | undefined): boolean;
|
|
13
|
+
static getHttpStatusCodeByGrpcCode(code: GrpcStatusCode): number;
|
|
14
|
+
static getGrpcCodeByHttpStatusCode(code: number): GrpcStatusCode;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { NetworkUtils };
|
package/dist/network.js
CHANGED
|
@@ -1,72 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return this.grpcCodeToHttpStatusCode[code] ?? types_1.HttpStatusCode.INTERNAL_SERVER_ERROR;
|
|
66
|
-
}
|
|
67
|
-
static getGrpcCodeByHttpStatusCode(code) {
|
|
68
|
-
return this.httpStatusCodeToGrpcCode[code] ?? types_1.GrpcStatusCode.UNKNOWN;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports.NetworkUtils = NetworkUtils;
|
|
72
|
-
//# sourceMappingURL=network.js.map
|
|
1
|
+
import { GrpcStatusCode, HttpStatusCode } from "@diia-inhouse/types";
|
|
2
|
+
//#region src/network.ts
|
|
3
|
+
var NetworkUtils = class {
|
|
4
|
+
static grpcStatusCodes = Object.values(GrpcStatusCode);
|
|
5
|
+
static httpStatusCodeToGrpcCode = {
|
|
6
|
+
[HttpStatusCode.PROCESSING]: GrpcStatusCode.OK,
|
|
7
|
+
[HttpStatusCode.OK]: GrpcStatusCode.OK,
|
|
8
|
+
[HttpStatusCode.CREATED]: GrpcStatusCode.OK,
|
|
9
|
+
[HttpStatusCode.ACCEPTED]: GrpcStatusCode.OK,
|
|
10
|
+
[HttpStatusCode.NO_CONTENT]: GrpcStatusCode.OK,
|
|
11
|
+
[HttpStatusCode.PARTIAL_CONTENT]: GrpcStatusCode.OK,
|
|
12
|
+
[HttpStatusCode.BAD_REQUEST]: GrpcStatusCode.INVALID_ARGUMENT,
|
|
13
|
+
[HttpStatusCode.UNPROCESSABLE_ENTITY]: GrpcStatusCode.INVALID_ARGUMENT,
|
|
14
|
+
[HttpStatusCode.UNAUTHORIZED]: GrpcStatusCode.UNAUTHENTICATED,
|
|
15
|
+
[HttpStatusCode.FORBIDDEN]: GrpcStatusCode.PERMISSION_DENIED,
|
|
16
|
+
[HttpStatusCode.NOT_FOUND]: GrpcStatusCode.NOT_FOUND,
|
|
17
|
+
[HttpStatusCode.REQUEST_TIMEOUT]: GrpcStatusCode.DEADLINE_EXCEEDED,
|
|
18
|
+
[HttpStatusCode.TOO_MANY_REQUESTS]: GrpcStatusCode.RESOURCE_EXHAUSTED,
|
|
19
|
+
[HttpStatusCode.INTERNAL_SERVER_ERROR]: GrpcStatusCode.INTERNAL,
|
|
20
|
+
[HttpStatusCode.NOT_IMPLEMENTED]: GrpcStatusCode.UNIMPLEMENTED,
|
|
21
|
+
[HttpStatusCode.BAD_GATEWAY]: GrpcStatusCode.UNAVAILABLE,
|
|
22
|
+
[HttpStatusCode.SERVICE_UNAVAILABLE]: GrpcStatusCode.UNAVAILABLE,
|
|
23
|
+
[HttpStatusCode.GATEWAY_TIMEOUT]: GrpcStatusCode.DEADLINE_EXCEEDED
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* @see https://gist.github.com/hamakn/708b9802ca845eb59f3975dbb3ae2a01
|
|
27
|
+
*/
|
|
28
|
+
static grpcCodeToHttpStatusCode = {
|
|
29
|
+
[GrpcStatusCode.OK]: HttpStatusCode.OK,
|
|
30
|
+
[GrpcStatusCode.CANCELLED]: 499,
|
|
31
|
+
[GrpcStatusCode.UNKNOWN]: HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
32
|
+
[GrpcStatusCode.INVALID_ARGUMENT]: HttpStatusCode.BAD_REQUEST,
|
|
33
|
+
[GrpcStatusCode.DEADLINE_EXCEEDED]: HttpStatusCode.GATEWAY_TIMEOUT,
|
|
34
|
+
[GrpcStatusCode.NOT_FOUND]: HttpStatusCode.NOT_FOUND,
|
|
35
|
+
[GrpcStatusCode.ALREADY_EXISTS]: HttpStatusCode.CONFLICT,
|
|
36
|
+
[GrpcStatusCode.PERMISSION_DENIED]: HttpStatusCode.FORBIDDEN,
|
|
37
|
+
[GrpcStatusCode.RESOURCE_EXHAUSTED]: HttpStatusCode.TOO_MANY_REQUESTS,
|
|
38
|
+
[GrpcStatusCode.FAILED_PRECONDITION]: HttpStatusCode.BAD_REQUEST,
|
|
39
|
+
[GrpcStatusCode.ABORTED]: HttpStatusCode.CONFLICT,
|
|
40
|
+
[GrpcStatusCode.OUT_OF_RANGE]: HttpStatusCode.BAD_REQUEST,
|
|
41
|
+
[GrpcStatusCode.UNIMPLEMENTED]: HttpStatusCode.NOT_IMPLEMENTED,
|
|
42
|
+
[GrpcStatusCode.INTERNAL]: HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
43
|
+
[GrpcStatusCode.UNAVAILABLE]: HttpStatusCode.SERVICE_UNAVAILABLE,
|
|
44
|
+
[GrpcStatusCode.DATA_LOSS]: HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
45
|
+
[GrpcStatusCode.UNAUTHENTICATED]: HttpStatusCode.UNAUTHORIZED
|
|
46
|
+
};
|
|
47
|
+
static isHttpCode(code) {
|
|
48
|
+
if (typeof code !== "number") return false;
|
|
49
|
+
if (code >= 100 && code < 600) return true;
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
static isGrpcCode(code) {
|
|
53
|
+
if (typeof code !== "number") return false;
|
|
54
|
+
return this.grpcStatusCodes.includes(code);
|
|
55
|
+
}
|
|
56
|
+
static getHttpStatusCodeByGrpcCode(code) {
|
|
57
|
+
return this.grpcCodeToHttpStatusCode[code] ?? HttpStatusCode.INTERNAL_SERVER_ERROR;
|
|
58
|
+
}
|
|
59
|
+
static getGrpcCodeByHttpStatusCode(code) {
|
|
60
|
+
return this.httpStatusCodeToGrpcCode[code] ?? GrpcStatusCode.UNKNOWN;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
export { NetworkUtils };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/payment.d.ts
|
|
2
|
+
declare class PaymentUtils {
|
|
3
|
+
private static readonly config;
|
|
4
|
+
static getPaymentPayCommission(amount: number): number;
|
|
5
|
+
static getPaymentTotalAmount(amount: number, commission: number): number;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { PaymentUtils };
|
package/dist/payment.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
exports.PaymentUtils = PaymentUtils;
|
|
22
|
-
//# sourceMappingURL=payment.js.map
|
|
1
|
+
import { ApplicationUtils } from "./applicationUtils.js";
|
|
2
|
+
//#region src/payment.ts
|
|
3
|
+
var PaymentUtils = class {
|
|
4
|
+
static config = {
|
|
5
|
+
defaultMinCommission: 1,
|
|
6
|
+
commissionPercent: 1.5
|
|
7
|
+
};
|
|
8
|
+
static getPaymentPayCommission(amount) {
|
|
9
|
+
const { commissionPercent, defaultMinCommission } = this.config;
|
|
10
|
+
const rawCommission = Math.ceil(amount * commissionPercent) / 100;
|
|
11
|
+
const commission = Math.max(rawCommission, defaultMinCommission);
|
|
12
|
+
return ApplicationUtils.toDecimalPlaces(commission, 2);
|
|
13
|
+
}
|
|
14
|
+
static getPaymentTotalAmount(amount, commission) {
|
|
15
|
+
return ApplicationUtils.toDecimalPlaces(amount + commission, 2);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { PaymentUtils };
|
package/dist/pdfUtils.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
},
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=pdfUtils.js.map
|
|
1
|
+
import { ApplicationUtils } from "./applicationUtils.js";
|
|
2
|
+
//#region src/pdfUtils.ts
|
|
3
|
+
const PdfUtils = { getPdfFileName(name, id, requestDateTime) {
|
|
4
|
+
return `${ApplicationUtils.getFileName(name, id, requestDateTime)}.pdf`;
|
|
5
|
+
} };
|
|
6
|
+
//#endregion
|
|
7
|
+
export { PdfUtils };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/phoneticChecker/index.d.ts
|
|
2
|
+
declare class PhoneticChecker {
|
|
3
|
+
private equalityCoefficientThreshold;
|
|
4
|
+
arePhoneticallySimilar(etalonValue: string, slaveValue: string, threshold?: number): boolean;
|
|
5
|
+
private getEqualityCoefficient;
|
|
6
|
+
}
|
|
7
|
+
declare const phoneticChecker: PhoneticChecker;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { phoneticChecker };
|