@6thbridge/utils 0.1.16
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/lib/actions/charge.action.d.ts +9 -0
- package/lib/actions/charge.action.js +74 -0
- package/lib/actions/charge.action.js.map +1 -0
- package/lib/actions/currency.action.d.ts +15 -0
- package/lib/actions/currency.action.js +57 -0
- package/lib/actions/currency.action.js.map +1 -0
- package/lib/actions/index.d.ts +9 -0
- package/lib/actions/index.js +33 -0
- package/lib/actions/index.js.map +1 -0
- package/lib/actions/phone-number.action.d.ts +23 -0
- package/lib/actions/phone-number.action.js +77 -0
- package/lib/actions/phone-number.action.js.map +1 -0
- package/lib/brokers/index.d.ts +6 -0
- package/lib/brokers/index.js +8 -0
- package/lib/brokers/index.js.map +1 -0
- package/lib/brokers/kafka.d.ts +84 -0
- package/lib/brokers/kafka.js +265 -0
- package/lib/brokers/kafka.js.map +1 -0
- package/lib/brokers/kafka.test.d.ts +1 -0
- package/lib/brokers/kafka.test.js +118 -0
- package/lib/brokers/kafka.test.js.map +1 -0
- package/lib/brokers/rabbitmq.d.ts +108 -0
- package/lib/brokers/rabbitmq.js +290 -0
- package/lib/brokers/rabbitmq.js.map +1 -0
- package/lib/cache/in-memory.d.ts +0 -0
- package/lib/cache/in-memory.js +2 -0
- package/lib/cache/in-memory.js.map +1 -0
- package/lib/cache/redis.d.ts +18 -0
- package/lib/cache/redis.js +58 -0
- package/lib/cache/redis.js.map +1 -0
- package/lib/database/MongoDBRepository.d.ts +23 -0
- package/lib/database/MongoDBRepository.js +90 -0
- package/lib/database/MongoDBRepository.js.map +1 -0
- package/lib/database/MongoDBTypeRepository.d.ts +26 -0
- package/lib/database/MongoDBTypeRepository.js +90 -0
- package/lib/database/MongoDBTypeRepository.js.map +1 -0
- package/lib/database/index.d.ts +4 -0
- package/lib/database/index.js +36 -0
- package/lib/database/index.js.map +1 -0
- package/lib/database/query.d.ts +16 -0
- package/lib/database/query.js +82 -0
- package/lib/database/query.js.map +1 -0
- package/lib/exceptions/custom.exception.d.ts +14 -0
- package/lib/exceptions/custom.exception.js +16 -0
- package/lib/exceptions/custom.exception.js.map +1 -0
- package/lib/helpers/errors.d.ts +2 -0
- package/lib/helpers/errors.js +46 -0
- package/lib/helpers/errors.js.map +1 -0
- package/lib/helpers/index.d.ts +51 -0
- package/lib/helpers/index.js +198 -0
- package/lib/helpers/index.js.map +1 -0
- package/lib/helpers/utils.d.ts +9 -0
- package/lib/helpers/utils.js +18 -0
- package/lib/helpers/utils.js.map +1 -0
- package/lib/http/axios.d.ts +0 -0
- package/lib/http/axios.js +2 -0
- package/lib/http/axios.js.map +1 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.js +104 -0
- package/lib/index.js.map +1 -0
- package/lib/logger/index.d.ts +20 -0
- package/lib/logger/index.js +12 -0
- package/lib/logger/index.js.map +1 -0
- package/lib/logger/logger-test.d.ts +1 -0
- package/lib/logger/logger-test.js +40 -0
- package/lib/logger/logger-test.js.map +1 -0
- package/lib/logger/logger.d.ts +31 -0
- package/lib/logger/logger.js +106 -0
- package/lib/logger/logger.js.map +1 -0
- package/lib/logger/null-logger.d.ts +14 -0
- package/lib/logger/null-logger.js +29 -0
- package/lib/logger/null-logger.js.map +1 -0
- package/lib/logger/test.d.ts +1 -0
- package/lib/logger/test.js +45 -0
- package/lib/logger/test.js.map +1 -0
- package/lib/middlewares/common.d.ts +22 -0
- package/lib/middlewares/common.js +141 -0
- package/lib/middlewares/common.js.map +1 -0
- package/lib/middlewares/express.d.ts +4 -0
- package/lib/middlewares/express.js +99 -0
- package/lib/middlewares/express.js.map +1 -0
- package/lib/middlewares/fastify.d.ts +4 -0
- package/lib/middlewares/fastify.js +73 -0
- package/lib/middlewares/fastify.js.map +1 -0
- package/lib/middlewares/index.d.ts +4 -0
- package/lib/middlewares/index.js +34 -0
- package/lib/middlewares/index.js.map +1 -0
- package/lib/monitoring/index.d.ts +12 -0
- package/lib/monitoring/index.js +75 -0
- package/lib/monitoring/index.js.map +1 -0
- package/lib/responses/express.d.ts +26 -0
- package/lib/responses/express.js +98 -0
- package/lib/responses/express.js.map +1 -0
- package/lib/responses/fastify.d.ts +4 -0
- package/lib/responses/fastify.js +25 -0
- package/lib/responses/fastify.js.map +1 -0
- package/lib/responses/index.d.ts +3 -0
- package/lib/responses/index.js +31 -0
- package/lib/responses/index.js.map +1 -0
- package/lib/secrets/aws-secret.d.ts +4 -0
- package/lib/secrets/aws-secret.js +55 -0
- package/lib/secrets/aws-secret.js.map +1 -0
- package/lib/secrets/aws.d.ts +0 -0
- package/lib/secrets/aws.js +2 -0
- package/lib/secrets/aws.js.map +1 -0
- package/lib/secrets/index.d.ts +8 -0
- package/lib/secrets/index.js +18 -0
- package/lib/secrets/index.js.map +1 -0
- package/lib/test/actions/charge.action.test.d.ts +1 -0
- package/lib/test/actions/charge.action.test.js +86 -0
- package/lib/test/actions/charge.action.test.js.map +1 -0
- package/lib/test/database/test.spec.d.ts +1 -0
- package/lib/test/database/test.spec.js +74 -0
- package/lib/test/database/test.spec.js.map +1 -0
- package/lib/test/helpers/PhoneNumber.spec.d.ts +1 -0
- package/lib/test/helpers/PhoneNumber.spec.js +82 -0
- package/lib/test/helpers/PhoneNumber.spec.js.map +1 -0
- package/lib/test/logger/test.spec.d.ts +1 -0
- package/lib/test/logger/test.spec.js +37 -0
- package/lib/test/logger/test.spec.js.map +1 -0
- package/lib/test/types/context.entity.test.d.ts +1 -0
- package/lib/test/types/context.entity.test.js +29 -0
- package/lib/test/types/context.entity.test.js.map +1 -0
- package/lib/translations/index.d.ts +7 -0
- package/lib/translations/index.js +52 -0
- package/lib/translations/index.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/broker.entity.d.ts +15 -0
- package/lib/types/broker.entity.js +13 -0
- package/lib/types/broker.entity.js.map +1 -0
- package/lib/types/client.entity.d.ts +42 -0
- package/lib/types/client.entity.js +16 -0
- package/lib/types/client.entity.js.map +1 -0
- package/lib/types/context.entity.d.ts +43 -0
- package/lib/types/context.entity.js +105 -0
- package/lib/types/context.entity.js.map +1 -0
- package/lib/types/index.d.ts +82 -0
- package/lib/types/index.js +38 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/user.entity.d.ts +28 -0
- package/lib/types/user.entity.js +18 -0
- package/lib/types/user.entity.js.map +1 -0
- package/package.json +52 -0
- package/readme.md +66 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TransactionCharge, TransactionFee } from "../types";
|
|
2
|
+
export declare const FRANCOPHONE_CURRENCY_CODES: string[];
|
|
3
|
+
interface CalculateTransactionFeePayload {
|
|
4
|
+
currency: string;
|
|
5
|
+
amount: number;
|
|
6
|
+
}
|
|
7
|
+
export declare const calculateCharge: (chargeConfiguration: TransactionCharge, payload: CalculateTransactionFeePayload) => TransactionFee;
|
|
8
|
+
export declare function processFrancophoneCountries(charge: TransactionFee): TransactionFee;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.processFrancophoneCountries = exports.calculateCharge = exports.FRANCOPHONE_CURRENCY_CODES = void 0;
|
|
7
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
+
exports.FRANCOPHONE_CURRENCY_CODES = ["xaf", "xof"];
|
|
9
|
+
const calculateCharge = (chargeConfiguration, payload) => {
|
|
10
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
11
|
+
const response = {
|
|
12
|
+
charge: 0,
|
|
13
|
+
provider: 0,
|
|
14
|
+
custom: 0,
|
|
15
|
+
platform: 0,
|
|
16
|
+
tax: 0,
|
|
17
|
+
VAT: 0,
|
|
18
|
+
total: 0
|
|
19
|
+
};
|
|
20
|
+
if (!chargeConfiguration)
|
|
21
|
+
return response;
|
|
22
|
+
const amount = payload.amount;
|
|
23
|
+
//platform fee
|
|
24
|
+
response.platform = ((_a = chargeConfiguration.platform) === null || _a === void 0 ? void 0 : _a.fixed) || 0;
|
|
25
|
+
if ((_b = chargeConfiguration.platform) === null || _b === void 0 ? void 0 : _b.percentage) {
|
|
26
|
+
response.platform += new bignumber_js_1.default((_c = chargeConfiguration.platform) === null || _c === void 0 ? void 0 : _c.percentage).div(100).multipliedBy(amount).toNumber();
|
|
27
|
+
}
|
|
28
|
+
response.charge += response.platform;
|
|
29
|
+
//provider
|
|
30
|
+
response.provider = ((_d = chargeConfiguration.provider) === null || _d === void 0 ? void 0 : _d.fixed) || 0;
|
|
31
|
+
if ((_e = chargeConfiguration.provider) === null || _e === void 0 ? void 0 : _e.percentage) {
|
|
32
|
+
response.provider += new bignumber_js_1.default((_f = chargeConfiguration.provider) === null || _f === void 0 ? void 0 : _f.percentage).div(100).multipliedBy(amount).toNumber();
|
|
33
|
+
}
|
|
34
|
+
response.charge += response.provider;
|
|
35
|
+
//custom
|
|
36
|
+
response.custom = ((_g = chargeConfiguration.custom) === null || _g === void 0 ? void 0 : _g.fixed) || 0;
|
|
37
|
+
if ((_h = chargeConfiguration.custom) === null || _h === void 0 ? void 0 : _h.percentage) {
|
|
38
|
+
response.custom += new bignumber_js_1.default((_j = chargeConfiguration.custom) === null || _j === void 0 ? void 0 : _j.percentage).div(100).multipliedBy(amount).toNumber();
|
|
39
|
+
}
|
|
40
|
+
response.charge += response.custom;
|
|
41
|
+
//tax
|
|
42
|
+
response.tax = ((_k = chargeConfiguration.tax) === null || _k === void 0 ? void 0 : _k.fixed) || 0;
|
|
43
|
+
if ((_l = chargeConfiguration.tax) === null || _l === void 0 ? void 0 : _l.percentage) {
|
|
44
|
+
response.tax += new bignumber_js_1.default((_m = chargeConfiguration.tax) === null || _m === void 0 ? void 0 : _m.percentage).div(100).multipliedBy(amount).toNumber();
|
|
45
|
+
}
|
|
46
|
+
response.charge += response.tax;
|
|
47
|
+
response.total = response.charge;
|
|
48
|
+
if (((_o = chargeConfiguration.cap) === null || _o === void 0 ? void 0 : _o.minimum) && chargeConfiguration.cap.minimum > response.total) {
|
|
49
|
+
response.total = chargeConfiguration.cap.minimum;
|
|
50
|
+
}
|
|
51
|
+
if (((_p = chargeConfiguration.cap) === null || _p === void 0 ? void 0 : _p.maximum) && ((_q = chargeConfiguration.cap) === null || _q === void 0 ? void 0 : _q.maximum) < response.total) {
|
|
52
|
+
response.total = chargeConfiguration.cap.maximum;
|
|
53
|
+
}
|
|
54
|
+
//calculate VAT
|
|
55
|
+
if (chargeConfiguration.VATOnChargeAndFees) {
|
|
56
|
+
response.VAT = new bignumber_js_1.default(chargeConfiguration.VATOnChargeAndFees).div(100).multipliedBy(response.total).toNumber();
|
|
57
|
+
response.total += response.VAT;
|
|
58
|
+
}
|
|
59
|
+
response.total = Math.ceil(response.total);
|
|
60
|
+
if (!exports.FRANCOPHONE_CURRENCY_CODES.includes((_r = payload.currency) === null || _r === void 0 ? void 0 : _r.toLowerCase()))
|
|
61
|
+
return response;
|
|
62
|
+
return processFrancophoneCountries(response);
|
|
63
|
+
};
|
|
64
|
+
exports.calculateCharge = calculateCharge;
|
|
65
|
+
function processFrancophoneCountries(charge) {
|
|
66
|
+
console.log("calculateCharge: Processing Francophone currency", charge);
|
|
67
|
+
let chargeInLargestCurrency = charge.total / 100;
|
|
68
|
+
const roundedUpCharge = Math.ceil(chargeInLargestCurrency);
|
|
69
|
+
charge.extra = (roundedUpCharge - chargeInLargestCurrency) * 100;
|
|
70
|
+
charge.total = roundedUpCharge * 100;
|
|
71
|
+
return charge;
|
|
72
|
+
}
|
|
73
|
+
exports.processFrancophoneCountries = processFrancophoneCountries;
|
|
74
|
+
//# sourceMappingURL=charge.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"charge.action.js","sourceRoot":"","sources":["../../src/actions/charge.action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CAAC;AAPD,kEAOC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const FRANCOPHONE_CURRENCY_CODES: string[];
|
|
2
|
+
interface AmountLabelPayload {
|
|
3
|
+
currency: string;
|
|
4
|
+
amount: number;
|
|
5
|
+
currencyLabel?: string;
|
|
6
|
+
currencyExchangeValue?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const createAmountLabel: (payload: AmountLabelPayload) => string;
|
|
9
|
+
export declare const formatAmountAndCurrency: (currency: string, value: any) => string;
|
|
10
|
+
export declare function validateAmount(currency: string, amount: number): string | null;
|
|
11
|
+
export declare const symbols: {
|
|
12
|
+
[x: string]: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const getCurrencySymbol: (currency: string) => string;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getCurrencySymbol = exports.symbols = exports.validateAmount = exports.formatAmountAndCurrency = exports.createAmountLabel = exports.FRANCOPHONE_CURRENCY_CODES = void 0;
|
|
7
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
+
exports.FRANCOPHONE_CURRENCY_CODES = ["xaf", "xof"];
|
|
9
|
+
const createAmountLabel = (payload) => {
|
|
10
|
+
payload.currencyLabel = payload.currencyLabel || payload.currency;
|
|
11
|
+
if (payload.currencyLabel != payload.currency && payload.currencyExchangeValue != 1) {
|
|
12
|
+
const amount = Number(new bignumber_js_1.default(payload.currencyExchangeValue || 1).multipliedBy(payload.amount).toFixed(2));
|
|
13
|
+
return (0, exports.formatAmountAndCurrency)(payload.currencyLabel, Number(amount / 100).toFixed(2));
|
|
14
|
+
}
|
|
15
|
+
return (0, exports.formatAmountAndCurrency)(payload.currency, Number(payload.amount / 100).toFixed(2));
|
|
16
|
+
};
|
|
17
|
+
exports.createAmountLabel = createAmountLabel;
|
|
18
|
+
const formatAmountAndCurrency = (currency, value) => {
|
|
19
|
+
//get currency symbol
|
|
20
|
+
const currencySymbol = (0, exports.getCurrencySymbol)(currency);
|
|
21
|
+
if (currency && exports.FRANCOPHONE_CURRENCY_CODES.includes(currency.toLowerCase()))
|
|
22
|
+
return `${parseFloat(value || 0).toFixed(0).toLocaleString()} ${currencySymbol}`;
|
|
23
|
+
return `${currencySymbol}${parseFloat(value || 0).toFixed(2).toLocaleString()}`;
|
|
24
|
+
};
|
|
25
|
+
exports.formatAmountAndCurrency = formatAmountAndCurrency;
|
|
26
|
+
function validateAmount(currency, amount) {
|
|
27
|
+
if (!["XOF", "XAF"].includes(currency.toUpperCase()))
|
|
28
|
+
return null;
|
|
29
|
+
if (!Number.isInteger(amount / 100)) {
|
|
30
|
+
return "Oops. For XOF and XAF currencies, Please send in whole number amount as we do not allow decimal amounts";
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
exports.validateAmount = validateAmount;
|
|
35
|
+
exports.symbols = {
|
|
36
|
+
'USD': '$', // US Dollar
|
|
37
|
+
'EUR': '€', // Euro
|
|
38
|
+
'CAD': 'CA$',
|
|
39
|
+
'CRC': '₡', // Costa Rican Colón
|
|
40
|
+
'GBP': '£', // British Pound Sterling
|
|
41
|
+
'ILS': '₪', // Israeli New Sheqel
|
|
42
|
+
'INR': '₹', // Indian Rupee
|
|
43
|
+
'JPY': '¥', // Japanese Yen
|
|
44
|
+
'KRW': '₩', // South Korean Won
|
|
45
|
+
'NGN': '₦', // Nigerian Naira
|
|
46
|
+
'PHP': '₱', // Philippine Peso
|
|
47
|
+
'PLN': 'zł', // Polish Zloty
|
|
48
|
+
'PYG': '₲', // Paraguayan Guarani
|
|
49
|
+
'THB': '฿', // Thai Baht
|
|
50
|
+
'UAH': '₴', // Ukrainian Hryvnia
|
|
51
|
+
'VND': '₫', // Vietnamese Dong
|
|
52
|
+
};
|
|
53
|
+
const getCurrencySymbol = (currency) => {
|
|
54
|
+
return exports.symbols[currency] || currency;
|
|
55
|
+
};
|
|
56
|
+
exports.getCurrencySymbol = getCurrencySymbol;
|
|
57
|
+
//# sourceMappingURL=currency.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currency.action.js","sourceRoot":"","sources":["../../src/actions/currency.action.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAEb,gEAAqC;AAExB,QAAA,0BAA0B,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AASlD,MAAM,iBAAiB,GAAG,CAAC,OAA2B,EAAU,EAAE;IACrE,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,QAAQ,CAAC;IAClE,IAAG,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,qBAAqB,IAAI,CAAC,EAAC,CAAC;QAChF,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,sBAAS,CAAC,OAAO,CAAC,qBAAqB,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjH,OAAO,IAAA,+BAAuB,EAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,GAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACzF,CAAC;IAED,OAAO,IAAA,+BAAuB,EAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,GAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5F,CAAC,CAAA;AATY,QAAA,iBAAiB,qBAS7B;AAEM,MAAM,uBAAuB,GAAG,CAAC,QAAgB,EAAE,KAAU,EAAE,EAAE;IACpE,qBAAqB;IACr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AI,EAAE,eAAe;IAC5B,KAAK,EAAE,GAAG,EAAE,qBAAqB;IACjC,KAAK,EAAE,GAAG,EAAE,YAAY;IACxB,KAAK,EAAE,GAAG,EAAE,oBAAoB;IAChC,KAAK,EAAE,GAAG,EAAE,kBAAkB;CACjC,CAAC;AACK,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAU,EAAE;IAC1D,OAAO,eAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC;AACzC,CAAC,CAAA;AAFY,QAAA,iBAAiB,qBAE7B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as currency from "./currency.action";
|
|
2
|
+
import * as charge from "./charge.action";
|
|
3
|
+
import * as phoneNumber from "./phone-number.action";
|
|
4
|
+
declare const _default: {
|
|
5
|
+
currency: typeof currency;
|
|
6
|
+
charge: typeof charge;
|
|
7
|
+
phoneNumber: typeof phoneNumber;
|
|
8
|
+
};
|
|
9
|
+
export = _default;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
const currency = __importStar(require("./currency.action"));
|
|
26
|
+
const charge = __importStar(require("./charge.action"));
|
|
27
|
+
const phoneNumber = __importStar(require("./phone-number.action"));
|
|
28
|
+
module.exports = {
|
|
29
|
+
currency,
|
|
30
|
+
charge,
|
|
31
|
+
phoneNumber
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA8C;AAC9C,wDAA0C;AAC1C,mEAAqD;AAGrD,iBAAS;IACL,QAAQ;IACR,MAAM;IACN,WAAW;CACd,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as libphonenumber from "libphonenumber-js";
|
|
2
|
+
import { CountryCode } from "libphonenumber-js";
|
|
3
|
+
export declare class ProcessPhoneNumberDTO {
|
|
4
|
+
phoneNumber: string;
|
|
5
|
+
phoneNumberPrefix?: string;
|
|
6
|
+
countryCode: libphonenumber.CountryCode | string;
|
|
7
|
+
[x: string]: any;
|
|
8
|
+
}
|
|
9
|
+
export declare const formatPhoneNumber: (payload: ProcessPhoneNumberDTO, options: Record<string, any>) => Promise<{
|
|
10
|
+
phoneNumberPrefix: libphonenumber.CountryCallingCode;
|
|
11
|
+
phoneNumber: string;
|
|
12
|
+
phoneNumberWithPrefix: libphonenumber.E164Number;
|
|
13
|
+
countryCode: libphonenumber.CountryCode | undefined;
|
|
14
|
+
meta: libphonenumber.PhoneNumber;
|
|
15
|
+
} | {
|
|
16
|
+
phoneNumberPrefix: string | undefined;
|
|
17
|
+
phoneNumber: string;
|
|
18
|
+
countryCode: string;
|
|
19
|
+
phoneNumberWithPrefix?: undefined;
|
|
20
|
+
meta?: undefined;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function isPhoneNumberValid(phoneNumber: string, countryCode: CountryCode | string): boolean;
|
|
23
|
+
export declare function isPhoneNumberPossible(phoneNumber: string, countryCode: CountryCode | string): boolean;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.isPhoneNumberPossible = exports.isPhoneNumberValid = exports.formatPhoneNumber = exports.ProcessPhoneNumberDTO = void 0;
|
|
36
|
+
const libphonenumber = __importStar(require("libphonenumber-js"));
|
|
37
|
+
const logger_1 = require("../logger/logger");
|
|
38
|
+
const libphonenumber_js_1 = require("libphonenumber-js");
|
|
39
|
+
class ProcessPhoneNumberDTO {
|
|
40
|
+
}
|
|
41
|
+
exports.ProcessPhoneNumberDTO = ProcessPhoneNumberDTO;
|
|
42
|
+
const formatPhoneNumber = (payload, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
options.logger = options.logger || logger_1.logger;
|
|
44
|
+
try {
|
|
45
|
+
const countryCode = payload.countryCode;
|
|
46
|
+
let phoneNumber = payload.phoneNumber;
|
|
47
|
+
if (payload.phoneNumberPrefix) {
|
|
48
|
+
phoneNumber = `${payload.phoneNumberPrefix}${phoneNumber}`;
|
|
49
|
+
}
|
|
50
|
+
const formatPhoneNumberResponse = libphonenumber.parsePhoneNumber(phoneNumber, countryCode);
|
|
51
|
+
return {
|
|
52
|
+
phoneNumberPrefix: formatPhoneNumberResponse.countryCallingCode,
|
|
53
|
+
phoneNumber: `${formatPhoneNumberResponse.countryCallingCode}${formatPhoneNumberResponse.nationalNumber}`,
|
|
54
|
+
phoneNumberWithPrefix: formatPhoneNumberResponse.number,
|
|
55
|
+
countryCode: formatPhoneNumberResponse.country,
|
|
56
|
+
meta: formatPhoneNumberResponse
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
options.logger.exception(e, payload);
|
|
61
|
+
return {
|
|
62
|
+
phoneNumberPrefix: payload.phoneNumberPrefix,
|
|
63
|
+
phoneNumber: payload.phoneNumber,
|
|
64
|
+
countryCode: payload.countryCode,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
exports.formatPhoneNumber = formatPhoneNumber;
|
|
69
|
+
function isPhoneNumberValid(phoneNumber, countryCode) {
|
|
70
|
+
return (0, libphonenumber_js_1.isValidNumberForRegion)(phoneNumber, countryCode);
|
|
71
|
+
}
|
|
72
|
+
exports.isPhoneNumberValid = isPhoneNumberValid;
|
|
73
|
+
function isPhoneNumberPossible(phoneNumber, countryCode) {
|
|
74
|
+
return (0, libphonenumber_js_1.isPossiblePhoneNumber)(phoneNumber, countryCode);
|
|
75
|
+
}
|
|
76
|
+
exports.isPhoneNumberPossible = isPhoneNumberPossible;
|
|
77
|
+
//# sourceMappingURL=phone-number.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone-number.action.js","sourceRoot":"","sources":["../../src/actions/phone-number.action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAoD;AACpD,6CAAwC;AACxC,yDAA6F;AAE7F,MAAa,qBAAqB;CAKjC;AALD,sDAKC;AAEM,MAAM,iBAAiB,GAAG,CAAO,OAA8B,EAAE,OAA4B,EAAE,EAAE;IACpG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,eAAM,CAAC;IAC1C,IAAI,CAAC;QACD,MAAM,WAAW,GAAQ,OAAO,CAAC,WAAW,CAAC;QAE7C,IAAI,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QAEtC,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAC5B,WAAW,GAAG,GAAG,OAAO,CAAC,iBAAiB,GAAG,WAAW,EAAE,CAAC;QAC/D,CAAC;QAED,MAAM,yBAAyB,GAAG,cAAc,CAAC,gBAAgB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QAE5F,OAAO;YACH,iBAAiB,EAAE,yBAAyB,CAAC,kBAAkB;YAC/D,WAAW,EAAE,GAAG,yBAAyB,CAAC,kBAAkB,GAAG,yBAAyB,CAAC,cAAc,EAAE;YACzG,qBAAqB,EAAE,yBAAyB,CAAC,MAAM;YACvD,WAAW,EAAE,yBAAyB,CAAC,OAAO;YAC9C,IAAI,EAAE,yBAAyB;SAClC,CAAC;IAEN,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAErC,OAAO;YACH,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;YAC5C,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,WAAW,EAAE,OAAO,CAAC,WAAW;SACnC,CAAC;IACN,CAAC;AACL,CAAC,CAAA,CAAC;AA9BW,QAAA,iBAAiB,qBA8B5B;AAEF,SAAgB,kBAAkB,CAAC,WAAmB,EAAE,WAAiC;IACrF,OAAO,IAAA,0CAAsB,EAAC,WAAW,EAAE,WAA0B,CAAC,CAAC;AAC3E,CAAC;AAFD,gDAEC;AACD,SAAgB,qBAAqB,CAAC,WAAmB,EAAE,WAAiC;IACxF,OAAO,IAAA,yCAAqB,EAAC,WAAW,EAAE,WAA0B,CAAC,CAAC;AAC1E,CAAC;AAFD,sDAEC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RabbitMQ = exports.KafkaJS = void 0;
|
|
4
|
+
const kafka_1 = require("./kafka");
|
|
5
|
+
Object.defineProperty(exports, "KafkaJS", { enumerable: true, get: function () { return kafka_1.KafkaJS; } });
|
|
6
|
+
const rabbitmq_1 = require("./rabbitmq");
|
|
7
|
+
Object.defineProperty(exports, "RabbitMQ", { enumerable: true, get: function () { return rabbitmq_1.RabbitMQ; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/brokers/index.ts"],"names":[],"mappings":";;;AAAA,mCAA2C;AASvC,wFATe,eAAO,OASf;AARX,yCAAkD;AAW9C,yFAXI,mBAAQ,OAWJ"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { logLevel, SASLMechanism } from 'kafkajs';
|
|
2
|
+
export type KafkaInit = {
|
|
3
|
+
url?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
logLevel?: logLevel;
|
|
6
|
+
connectionTimeout?: number;
|
|
7
|
+
requestTimeout?: number;
|
|
8
|
+
ssl?: boolean;
|
|
9
|
+
saslUsername?: string;
|
|
10
|
+
saslPassword?: string;
|
|
11
|
+
saslMechanism?: SASLMechanism;
|
|
12
|
+
[x: string]: any;
|
|
13
|
+
};
|
|
14
|
+
export declare class KafkaJS {
|
|
15
|
+
private connection;
|
|
16
|
+
private retryCountBeforeExit;
|
|
17
|
+
private producer;
|
|
18
|
+
private consumer;
|
|
19
|
+
private admin;
|
|
20
|
+
constructor(options?: KafkaInit);
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} options
|
|
24
|
+
* @param {string} options.url
|
|
25
|
+
* @param {number} options.retryCountBeforeExit
|
|
26
|
+
* @param {number} options.heartbeat
|
|
27
|
+
* @return {Promise<null|*|undefined>}
|
|
28
|
+
*/
|
|
29
|
+
init(options: KafkaInit): Promise<any>;
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {object} Topic
|
|
32
|
+
* @property {string} name
|
|
33
|
+
* @property {number} numberOfPartitions
|
|
34
|
+
* @property {number} replicationFactor
|
|
35
|
+
* @property {string} retentionPolicy
|
|
36
|
+
* @property {string} cleanUpPolicy
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param {Topic[]} topics
|
|
42
|
+
* @return {Promise<{error: string}|{data: boolean}|{error}>}
|
|
43
|
+
*/
|
|
44
|
+
createTopics(topics: any[]): Promise<{
|
|
45
|
+
data: boolean;
|
|
46
|
+
error?: undefined;
|
|
47
|
+
} | {
|
|
48
|
+
error: any;
|
|
49
|
+
data?: undefined;
|
|
50
|
+
}>;
|
|
51
|
+
createProducer(): Promise<{
|
|
52
|
+
data: any;
|
|
53
|
+
error?: undefined;
|
|
54
|
+
} | {
|
|
55
|
+
error: any;
|
|
56
|
+
data?: undefined;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @param {string} topic
|
|
61
|
+
* @param {string} key
|
|
62
|
+
* @param {any} payload
|
|
63
|
+
* @return Promise<*>
|
|
64
|
+
*/
|
|
65
|
+
publish(topic: string, key: string, payload: any): Promise<{
|
|
66
|
+
data: any;
|
|
67
|
+
error?: undefined;
|
|
68
|
+
} | {
|
|
69
|
+
error: any;
|
|
70
|
+
data?: undefined;
|
|
71
|
+
}>;
|
|
72
|
+
/**
|
|
73
|
+
*
|
|
74
|
+
* @param {string[]} topics
|
|
75
|
+
* @param {string} groupId
|
|
76
|
+
* @param {function} callback
|
|
77
|
+
* @param fromBeginning
|
|
78
|
+
* @param {number} prefetch
|
|
79
|
+
* @return {null}
|
|
80
|
+
*/
|
|
81
|
+
listen(topics: any[], groupId: string, callback: any, fromBeginning?: boolean, prefetch?: number): Promise<void>;
|
|
82
|
+
listenInBatch(topics: any[], groupId: string, callback: any, options?: any): Promise<void>;
|
|
83
|
+
close(): void;
|
|
84
|
+
}
|