@temboplus/frontend-core 0.2.1 → 0.2.3
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/README.md +126 -25
- package/esm/deps/jsr.io/@std/internal/1.0.5/assertion_state.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/testing/1.0.9/_test_suite.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/testing/1.0.9/bdd.d.ts.map +1 -0
- package/esm/mod.d.ts +2 -0
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +2 -0
- package/esm/src/config/config_service.d.ts +11 -0
- package/esm/src/config/config_service.d.ts.map +1 -0
- package/esm/src/config/config_service.js +19 -0
- package/esm/src/config/index.d.ts +2 -0
- package/esm/src/config/index.d.ts.map +1 -0
- package/esm/src/config/index.js +1 -0
- package/esm/src/{models/bank/banks.d.ts → data/banks_tz.d.ts} +1 -1
- package/esm/src/data/banks_tz.d.ts.map +1 -0
- package/esm/src/data/countries.d.ts +6 -0
- package/esm/src/data/countries.d.ts.map +1 -0
- package/esm/src/data/countries.js +974 -0
- package/esm/src/data/currencies.d.ts +1901 -0
- package/esm/src/data/currencies.d.ts.map +1 -0
- package/esm/src/data/currencies.js +1073 -0
- package/esm/src/data/phone_patterns.d.ts +3809 -0
- package/esm/src/data/phone_patterns.d.ts.map +1 -0
- package/esm/src/data/phone_patterns.js +2325 -0
- package/esm/src/models/amount/amount.d.ts +10 -12
- package/esm/src/models/amount/amount.d.ts.map +1 -1
- package/esm/src/models/amount/amount.js +58 -96
- package/esm/src/models/bank/bank.d.ts +58 -53
- package/esm/src/models/bank/bank.d.ts.map +1 -1
- package/esm/src/models/bank/bank.js +49 -84
- package/esm/src/models/bank/index.d.ts +1 -1
- package/esm/src/models/bank/index.d.ts.map +1 -1
- package/esm/src/models/bank/index.js +1 -1
- package/esm/src/models/bank/service.d.ts +106 -0
- package/esm/src/models/bank/service.d.ts.map +1 -0
- package/esm/src/models/bank/service.js +240 -0
- package/esm/src/models/country/country.d.ts +568 -0
- package/esm/src/models/country/country.d.ts.map +1 -0
- package/esm/src/models/country/country.js +165 -0
- package/esm/src/models/country/country.test.d.ts.map +1 -0
- package/esm/src/models/country/index.d.ts +3 -0
- package/esm/src/models/country/index.d.ts.map +1 -0
- package/esm/src/models/country/index.js +2 -0
- package/esm/src/models/country/service.d.ts +75 -0
- package/esm/src/models/country/service.d.ts.map +1 -0
- package/esm/src/models/country/service.js +267 -0
- package/esm/src/models/currency/currency.d.ts +341 -0
- package/esm/src/models/currency/currency.d.ts.map +1 -0
- package/esm/src/models/currency/currency.js +225 -0
- package/esm/src/models/currency/currency.test.d.ts.map +1 -0
- package/esm/src/models/currency/index.d.ts +3 -0
- package/esm/src/models/currency/index.d.ts.map +1 -0
- package/esm/src/models/currency/index.js +2 -0
- package/esm/src/models/currency/service.d.ts +96 -0
- package/esm/src/models/currency/service.d.ts.map +1 -0
- package/esm/src/models/currency/service.js +194 -0
- package/esm/src/models/index.d.ts +2 -0
- package/esm/src/models/index.d.ts.map +1 -1
- package/esm/src/models/index.js +2 -0
- package/esm/src/models/phone_number/format.d.ts +14 -0
- package/esm/src/models/phone_number/format.d.ts.map +1 -0
- package/esm/src/models/phone_number/format.js +14 -0
- package/esm/src/models/phone_number/global/phone_number.d.ts +160 -0
- package/esm/src/models/phone_number/global/phone_number.d.ts.map +1 -0
- package/esm/src/models/phone_number/global/phone_number.js +453 -0
- package/esm/src/models/phone_number/global/phone_number.test.d.ts.map +1 -0
- package/esm/src/models/phone_number/global/service.d.ts +260 -0
- package/esm/src/models/phone_number/global/service.d.ts.map +1 -0
- package/esm/src/models/phone_number/global/service.js +477 -0
- package/esm/src/models/phone_number/global/service.test.d.ts.map +1 -0
- package/esm/src/models/phone_number/index.d.ts +5 -3
- package/esm/src/models/phone_number/index.d.ts.map +1 -1
- package/esm/src/models/phone_number/index.js +5 -3
- package/esm/src/models/phone_number/{antd_validator.d.ts → tz/antd_validator.d.ts} +2 -2
- package/esm/src/models/phone_number/tz/antd_validator.d.ts.map +1 -0
- package/esm/src/models/phone_number/{antd_validator.js → tz/antd_validator.js} +2 -2
- package/esm/src/models/phone_number/tz/antdvalidator.test.d.ts.map +1 -0
- package/esm/src/models/phone_number/tz/network_operator.d.ts.map +1 -0
- package/{script/src/models/phone_number → esm/src/models/phone_number/tz}/phone_number.d.ts +46 -29
- package/esm/src/models/phone_number/tz/phone_number.d.ts.map +1 -0
- package/esm/src/models/phone_number/{phone_number.js → tz/phone_number.js} +87 -41
- package/esm/src/models/phone_number/tz/phone_number.test.d.ts.map +1 -0
- package/esm/src/reports/index.d.ts +2 -0
- package/esm/src/reports/index.d.ts.map +1 -0
- package/esm/src/reports/index.js +1 -0
- package/esm/src/reports/report_manager.d.ts +144 -0
- package/esm/src/reports/report_manager.d.ts.map +1 -0
- package/esm/src/reports/report_manager.js +315 -0
- package/package.json +4 -3
- package/script/deps/jsr.io/@std/internal/1.0.5/assertion_state.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/testing/1.0.9/_test_suite.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/testing/1.0.9/bdd.d.ts.map +1 -0
- package/script/mod.d.ts +2 -0
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +2 -0
- package/script/src/config/config_service.d.ts +11 -0
- package/script/src/config/config_service.d.ts.map +1 -0
- package/script/src/config/config_service.js +23 -0
- package/script/src/config/index.d.ts +2 -0
- package/script/src/config/index.d.ts.map +1 -0
- package/script/src/config/index.js +17 -0
- package/script/src/{models/bank/banks.d.ts → data/banks_tz.d.ts} +1 -1
- package/script/src/data/banks_tz.d.ts.map +1 -0
- package/script/src/data/countries.d.ts +6 -0
- package/script/src/data/countries.d.ts.map +1 -0
- package/script/src/data/countries.js +976 -0
- package/script/src/data/currencies.d.ts +1901 -0
- package/script/src/data/currencies.d.ts.map +1 -0
- package/script/src/data/currencies.js +1075 -0
- package/script/src/data/phone_patterns.d.ts +3809 -0
- package/script/src/data/phone_patterns.d.ts.map +1 -0
- package/script/src/data/phone_patterns.js +2327 -0
- package/script/src/models/amount/amount.d.ts +10 -12
- package/script/src/models/amount/amount.d.ts.map +1 -1
- package/script/src/models/amount/amount.js +60 -98
- package/script/src/models/bank/bank.d.ts +58 -53
- package/script/src/models/bank/bank.d.ts.map +1 -1
- package/script/src/models/bank/bank.js +49 -87
- package/script/src/models/bank/index.d.ts +1 -1
- package/script/src/models/bank/index.d.ts.map +1 -1
- package/script/src/models/bank/index.js +1 -1
- package/script/src/models/bank/service.d.ts +106 -0
- package/script/src/models/bank/service.d.ts.map +1 -0
- package/script/src/models/bank/service.js +247 -0
- package/script/src/models/country/country.d.ts +568 -0
- package/script/src/models/country/country.d.ts.map +1 -0
- package/script/src/models/country/country.js +169 -0
- package/script/src/models/country/country.test.d.ts.map +1 -0
- package/script/src/models/country/index.d.ts +3 -0
- package/script/src/models/country/index.d.ts.map +1 -0
- package/script/src/models/country/index.js +18 -0
- package/script/src/models/country/service.d.ts +75 -0
- package/script/src/models/country/service.d.ts.map +1 -0
- package/script/src/models/country/service.js +274 -0
- package/script/src/models/currency/currency.d.ts +341 -0
- package/script/src/models/currency/currency.d.ts.map +1 -0
- package/script/src/models/currency/currency.js +229 -0
- package/script/src/models/currency/currency.test.d.ts.map +1 -0
- package/script/src/models/currency/index.d.ts +3 -0
- package/script/src/models/currency/index.d.ts.map +1 -0
- package/script/src/models/currency/index.js +18 -0
- package/script/src/models/currency/service.d.ts +96 -0
- package/script/src/models/currency/service.d.ts.map +1 -0
- package/script/src/models/currency/service.js +201 -0
- package/script/src/models/index.d.ts +2 -0
- package/script/src/models/index.d.ts.map +1 -1
- package/script/src/models/index.js +2 -0
- package/script/src/models/phone_number/format.d.ts +14 -0
- package/script/src/models/phone_number/format.d.ts.map +1 -0
- package/script/src/models/phone_number/format.js +17 -0
- package/script/src/models/phone_number/global/phone_number.d.ts +160 -0
- package/script/src/models/phone_number/global/phone_number.d.ts.map +1 -0
- package/script/src/models/phone_number/global/phone_number.js +457 -0
- package/script/src/models/phone_number/global/phone_number.test.d.ts.map +1 -0
- package/script/src/models/phone_number/global/service.d.ts +260 -0
- package/script/src/models/phone_number/global/service.d.ts.map +1 -0
- package/script/src/models/phone_number/global/service.js +485 -0
- package/script/src/models/phone_number/global/service.test.d.ts.map +1 -0
- package/script/src/models/phone_number/index.d.ts +5 -3
- package/script/src/models/phone_number/index.d.ts.map +1 -1
- package/script/src/models/phone_number/index.js +5 -3
- package/script/src/models/phone_number/{antd_validator.d.ts → tz/antd_validator.d.ts} +2 -2
- package/script/src/models/phone_number/tz/antd_validator.d.ts.map +1 -0
- package/script/src/models/phone_number/{antd_validator.js → tz/antd_validator.js} +1 -1
- package/script/src/models/phone_number/tz/antdvalidator.test.d.ts.map +1 -0
- package/script/src/models/phone_number/tz/network_operator.d.ts.map +1 -0
- package/{esm/src/models/phone_number → script/src/models/phone_number/tz}/phone_number.d.ts +46 -29
- package/script/src/models/phone_number/tz/phone_number.d.ts.map +1 -0
- package/script/src/models/phone_number/{phone_number.js → tz/phone_number.js} +89 -43
- package/script/src/models/phone_number/tz/phone_number.test.d.ts.map +1 -0
- package/script/src/reports/index.d.ts +2 -0
- package/script/src/reports/index.d.ts.map +1 -0
- package/script/src/reports/index.js +17 -0
- package/script/src/reports/report_manager.d.ts +144 -0
- package/script/src/reports/report_manager.d.ts.map +1 -0
- package/script/src/reports/report_manager.js +325 -0
- package/esm/src/models/bank/banks.d.ts.map +0 -1
- package/esm/src/models/bank/utils.d.ts +0 -25
- package/esm/src/models/bank/utils.d.ts.map +0 -1
- package/esm/src/models/bank/utils.js +0 -35
- package/esm/src/models/phone_number/antd_validator.d.ts.map +0 -1
- package/esm/src/models/phone_number/antdvalidator.test.d.ts.map +0 -1
- package/esm/src/models/phone_number/network_operator.d.ts.map +0 -1
- package/esm/src/models/phone_number/phone_number.d.ts.map +0 -1
- package/esm/src/models/phone_number/phone_number.test.d.ts.map +0 -1
- package/script/src/models/bank/banks.d.ts.map +0 -1
- package/script/src/models/bank/utils.d.ts +0 -25
- package/script/src/models/bank/utils.d.ts.map +0 -1
- package/script/src/models/bank/utils.js +0 -41
- package/script/src/models/phone_number/antd_validator.d.ts.map +0 -1
- package/script/src/models/phone_number/antdvalidator.test.d.ts.map +0 -1
- package/script/src/models/phone_number/network_operator.d.ts.map +0 -1
- package/script/src/models/phone_number/phone_number.d.ts.map +0 -1
- package/script/src/models/phone_number/phone_number.test.d.ts.map +0 -1
- /package/esm/src/{models/bank/banks.js → data/banks_tz.js} +0 -0
- /package/esm/src/models/phone_number/{network_operator.d.ts → tz/network_operator.d.ts} +0 -0
- /package/esm/src/models/phone_number/{network_operator.js → tz/network_operator.js} +0 -0
- /package/script/src/{models/bank/banks.js → data/banks_tz.js} +0 -0
- /package/script/src/models/phone_number/{network_operator.d.ts → tz/network_operator.d.ts} +0 -0
- /package/script/src/models/phone_number/{network_operator.js → tz/network_operator.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone_number.d.ts","sourceRoot":"","sources":["../../../../../src/src/models/phone_number/tz/phone_number.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD;;GAEG;AACH,qBAAa,aAAa;IACxB;;OAEG;IACH,OAAO,CAAC,cAAc,CAAS;IAE/B;;;;;OAKG;IACH,OAAO;IAIP;;OAEG;IACH,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED;;;;;OAKG;IACH,aAAa,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM;IAmBhD;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAQ3B;;;OAGG;IACH,OAAO,CAAC,cAAc;IAMtB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAIrB;;;;OAIG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;;;OAIG;IACH,IAAI,eAAe,IAAI,mBAAmB,CAMzC;IAED;;;;;OAKG;WACW,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAyC5D;;;;;OAKG;WACW,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO;IAW1D;;;;;;;;;;;;;;;;;;;OAmBG;WACW,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,aAAa;IAYpD;;;OAGG;IACI,QAAQ,IAAI,OAAO;CAO3B"}
|
|
@@ -23,31 +23,28 @@
|
|
|
23
23
|
* - Tigo: 65, 67, etc.
|
|
24
24
|
* - Halotel: 62, etc.
|
|
25
25
|
*
|
|
26
|
+
* 4. Phone numbers can be formatted in the following ways:
|
|
27
|
+
* - International format: "+255 XXX XXX XXX"
|
|
28
|
+
* - National format: "0XXX XXX XXX"
|
|
29
|
+
* - Compact format: "XXXXXXXXX"
|
|
30
|
+
* - RFC3966 format: "tel:+255XXXXXXXXX"
|
|
31
|
+
*
|
|
26
32
|
* ## Solution
|
|
27
|
-
* The
|
|
33
|
+
* The TZPhoneNumber class provides:
|
|
28
34
|
* 1. Parsing and validation of different input formats
|
|
29
35
|
* 2. Standardized storage in compact format
|
|
30
36
|
* 3. Formatting options for display and API use
|
|
31
37
|
* 4. Network operator identification
|
|
32
38
|
*/
|
|
33
39
|
import { NETWORK_OPERATOR_CONFIG, } from "./network_operator.js";
|
|
34
|
-
|
|
35
|
-
* Enumeration for various mobile number formats.
|
|
36
|
-
* @enum {string}
|
|
37
|
-
*/
|
|
38
|
-
export var MobileNumberFormat;
|
|
39
|
-
(function (MobileNumberFormat) {
|
|
40
|
-
MobileNumberFormat["s255"] = "255";
|
|
41
|
-
MobileNumberFormat["sp255"] = "+255";
|
|
42
|
-
MobileNumberFormat["s0"] = "0";
|
|
43
|
-
MobileNumberFormat["none"] = "";
|
|
44
|
-
})(MobileNumberFormat || (MobileNumberFormat = {}));
|
|
40
|
+
import { PhoneNumberFormat } from "../format.js";
|
|
45
41
|
/**
|
|
46
42
|
* Represents a TZ phone number
|
|
47
43
|
*/
|
|
48
|
-
export class
|
|
44
|
+
export class TZPhoneNumber {
|
|
49
45
|
/**
|
|
50
|
-
*
|
|
46
|
+
* Private constructor to prevent direct instantiation.
|
|
47
|
+
* Use TZPhoneNumber.from() instead.
|
|
51
48
|
*
|
|
52
49
|
* @param compactNumber - The phone number in a compact format (e.g., "712345678").
|
|
53
50
|
*/
|
|
@@ -55,30 +52,76 @@ export class PhoneNumber {
|
|
|
55
52
|
/**
|
|
56
53
|
* Stores the phone number in a compact format excluding country code and the initial '0'.
|
|
57
54
|
*/
|
|
58
|
-
Object.defineProperty(this, "
|
|
55
|
+
Object.defineProperty(this, "_compactNumber", {
|
|
59
56
|
enumerable: true,
|
|
60
57
|
configurable: true,
|
|
61
58
|
writable: true,
|
|
62
59
|
value: void 0
|
|
63
60
|
});
|
|
64
|
-
this.
|
|
61
|
+
this._compactNumber = compactNumber;
|
|
65
62
|
}
|
|
66
63
|
/**
|
|
67
|
-
*
|
|
64
|
+
* Gets the compact number (national number without formatting)
|
|
65
|
+
*/
|
|
66
|
+
get compactNumber() {
|
|
67
|
+
return this._compactNumber;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Formats the phone number according to the specified format
|
|
68
71
|
*
|
|
69
|
-
* @param format - The desired
|
|
70
|
-
* @returns The phone number
|
|
72
|
+
* @param format - The desired format from GlobalPhoneNumberFormat
|
|
73
|
+
* @returns The formatted phone number string
|
|
71
74
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
getWithFormat(format) {
|
|
76
|
+
switch (format) {
|
|
77
|
+
case PhoneNumberFormat.INTERNATIONAL:
|
|
78
|
+
// Format: +255 XXX XXX XXX
|
|
79
|
+
return this.formatInternational();
|
|
80
|
+
case PhoneNumberFormat.NATIONAL:
|
|
81
|
+
// Format: 0XXX XXX XXX
|
|
82
|
+
return this.formatNational();
|
|
83
|
+
case PhoneNumberFormat.COMPACT:
|
|
84
|
+
// Format: XXXXXXXXX (just the 9 digits)
|
|
85
|
+
return this._compactNumber;
|
|
86
|
+
case PhoneNumberFormat.RFC3966:
|
|
87
|
+
// Format: tel:+255XXXXXXXXX
|
|
88
|
+
return this.formatRFC3966();
|
|
89
|
+
default:
|
|
90
|
+
return `+255${this._compactNumber}`;
|
|
91
|
+
}
|
|
74
92
|
}
|
|
75
93
|
/**
|
|
76
|
-
*
|
|
94
|
+
* Formats the phone number in international format with spaces
|
|
95
|
+
* Format: +255 XXX XXX XXX
|
|
96
|
+
*/
|
|
97
|
+
formatInternational() {
|
|
98
|
+
const num = this._compactNumber;
|
|
99
|
+
// Insert spaces: +255 XXX XXX XXX
|
|
100
|
+
return `+255 ${num.substring(0, 3)} ${num.substring(3, 6)} ${num.substring(6)}`;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Formats the phone number in national format with spaces
|
|
104
|
+
* Format: 0XXX XXX XXX
|
|
105
|
+
*/
|
|
106
|
+
formatNational() {
|
|
107
|
+
const num = this._compactNumber;
|
|
108
|
+
// Insert spaces: 0XXX XXX XXX
|
|
109
|
+
return `0${num.substring(0, 3)} ${num.substring(3, 6)} ${num.substring(6)}`;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Formats the phone number according to RFC3966
|
|
113
|
+
* Format: tel:+255XXXXXXXXX
|
|
114
|
+
*/
|
|
115
|
+
formatRFC3966() {
|
|
116
|
+
return `tel:+255${this._compactNumber}`;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Returns the formatted label of the phone number using the international format.
|
|
77
120
|
*
|
|
78
|
-
* @returns The phone number label in
|
|
121
|
+
* @returns The phone number label in international format.
|
|
79
122
|
*/
|
|
80
123
|
get label() {
|
|
81
|
-
return this.
|
|
124
|
+
return this.getWithFormat(PhoneNumberFormat.INTERNATIONAL);
|
|
82
125
|
}
|
|
83
126
|
/**
|
|
84
127
|
* Derives the network operator information associated with the phone number by checking its prefix.
|
|
@@ -86,21 +129,24 @@ export class PhoneNumber {
|
|
|
86
129
|
* @returns The `NetworkOperatorInfo` object that matches the phone number prefix.
|
|
87
130
|
*/
|
|
88
131
|
get networkOperator() {
|
|
89
|
-
const prefix = this.
|
|
132
|
+
const prefix = this._compactNumber.substring(0, 2);
|
|
90
133
|
const result = Object.values(NETWORK_OPERATOR_CONFIG).find((operator) => operator.mobileNumberPrefixes.includes(prefix));
|
|
91
134
|
return result;
|
|
92
135
|
}
|
|
93
136
|
/**
|
|
94
|
-
* Creates a `
|
|
137
|
+
* Creates a `TZPhoneNumber` instance from a given string.
|
|
95
138
|
*
|
|
96
139
|
* @param s - The input phone number string in various formats (e.g., "+255712345678", "0712345678").
|
|
97
|
-
* @returns A `
|
|
140
|
+
* @returns A `TZPhoneNumber` instance if valid, otherwise `undefined`.
|
|
98
141
|
*/
|
|
99
|
-
static from(
|
|
142
|
+
static from(input) {
|
|
100
143
|
try {
|
|
101
|
-
|
|
144
|
+
// Clean the input (remove all non-digits except the leading '+')
|
|
145
|
+
const hasPlus = input.trim().startsWith("+");
|
|
146
|
+
let number = input.replace(/\D/g, "");
|
|
147
|
+
number = hasPlus ? `+${number}` : number;
|
|
102
148
|
if (number.length === 0)
|
|
103
|
-
return;
|
|
149
|
+
return undefined;
|
|
104
150
|
const isOnlyDigits = isOnlyDigitsOrPlus(number);
|
|
105
151
|
if (!isOnlyDigits)
|
|
106
152
|
return;
|
|
@@ -126,7 +172,7 @@ export class PhoneNumber {
|
|
|
126
172
|
const operator = Object.values(NETWORK_OPERATOR_CONFIG).find((op) => op.mobileNumberPrefixes.includes(prefix));
|
|
127
173
|
if (!operator)
|
|
128
174
|
return;
|
|
129
|
-
return new
|
|
175
|
+
return new TZPhoneNumber(compactNumber);
|
|
130
176
|
}
|
|
131
177
|
catch (_) {
|
|
132
178
|
return;
|
|
@@ -144,20 +190,20 @@ export class PhoneNumber {
|
|
|
144
190
|
const text = removeSpaces(input.trim());
|
|
145
191
|
if (text.length === 0)
|
|
146
192
|
return false;
|
|
147
|
-
const phone =
|
|
193
|
+
const phone = TZPhoneNumber.from(text);
|
|
148
194
|
return phone !== undefined;
|
|
149
195
|
}
|
|
150
196
|
/**
|
|
151
|
-
* Checks if an unknown value contains valid data to construct a
|
|
197
|
+
* Checks if an unknown value contains valid data to construct a TZPhoneNumber instance.
|
|
152
198
|
* Validates the structural integrity of the phone number object.
|
|
153
199
|
*
|
|
154
200
|
* @param {unknown} obj - The value to validate.
|
|
155
|
-
* @returns {obj is
|
|
201
|
+
* @returns {obj is TZPhoneNumber} Type predicate indicating if the value has a valid phone number structure.
|
|
156
202
|
*
|
|
157
203
|
* @example
|
|
158
204
|
* const maybePhone = JSON.parse(someData);
|
|
159
|
-
* if (
|
|
160
|
-
* // maybePhone is typed as
|
|
205
|
+
* if (TZPhoneNumber.is(maybePhone)) {
|
|
206
|
+
* // maybePhone is typed as TZPhoneNumber
|
|
161
207
|
* console.log(maybePhone.label);
|
|
162
208
|
* }
|
|
163
209
|
*
|
|
@@ -171,11 +217,11 @@ export class PhoneNumber {
|
|
|
171
217
|
if (!obj || typeof obj !== "object")
|
|
172
218
|
return false;
|
|
173
219
|
const maybePhone = obj;
|
|
174
|
-
// Check if
|
|
175
|
-
if (typeof maybePhone.
|
|
220
|
+
// Check if _compactNumber exists and is string
|
|
221
|
+
if (typeof maybePhone._compactNumber !== "string")
|
|
176
222
|
return false;
|
|
177
|
-
const compactNumber = maybePhone.
|
|
178
|
-
return
|
|
223
|
+
const compactNumber = maybePhone._compactNumber;
|
|
224
|
+
return TZPhoneNumber.canConstruct(compactNumber);
|
|
179
225
|
}
|
|
180
226
|
/**
|
|
181
227
|
* Checks the validity of the phone number data
|
|
@@ -183,7 +229,7 @@ export class PhoneNumber {
|
|
|
183
229
|
*/
|
|
184
230
|
validate() {
|
|
185
231
|
try {
|
|
186
|
-
return
|
|
232
|
+
return TZPhoneNumber.canConstruct(this._compactNumber);
|
|
187
233
|
}
|
|
188
234
|
catch (_) {
|
|
189
235
|
return false;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone_number.test.d.ts","sourceRoot":"","sources":["../../../../../src/src/models/phone_number/tz/phone_number.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/reports/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./report_manager.js";
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Available file formats for reports
|
|
3
|
+
*/
|
|
4
|
+
export declare enum FileFormat {
|
|
5
|
+
/** PDF file format */
|
|
6
|
+
PDF = "pdf",
|
|
7
|
+
/** Excel file format */
|
|
8
|
+
EXCEL = "excel"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Available project types
|
|
12
|
+
*/
|
|
13
|
+
export declare enum ProjectType {
|
|
14
|
+
/** Tembo Dashboard project */
|
|
15
|
+
DASHBOARD = "dashboard",
|
|
16
|
+
/** Afloat project */
|
|
17
|
+
AFLOAT = "afloat",
|
|
18
|
+
/** VertoX project */
|
|
19
|
+
VERTO_X = "verto_x"
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Available report types with improved naming
|
|
23
|
+
*/
|
|
24
|
+
export declare enum ReportType {
|
|
25
|
+
/** Merchant payout statement (Dashboard) */
|
|
26
|
+
MERCHANT_DISBURSEMENT_REPORT = "merchant_disbursement_report",
|
|
27
|
+
/** Transaction revenue summary (Dashboard) */
|
|
28
|
+
TRANSACTION_REVENUE_SUMMARY = "transaction_revenue_summary",
|
|
29
|
+
/** Customer wallet activity (Afloat) */
|
|
30
|
+
CUSTOMER_WALLET_ACTIVITY = "customer_wallet_activity",
|
|
31
|
+
/** Customer profile information (Afloat) */
|
|
32
|
+
CUSTOMER_PROFILE_SNAPSHOT = "customer_profile_snapshot",
|
|
33
|
+
/** Gateway transaction log (VertoX) */
|
|
34
|
+
GATEWAY_TRANSACTION_LOG = "gateway_transaction_log"
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Report definition interface
|
|
38
|
+
*/
|
|
39
|
+
export interface ReportDefinition {
|
|
40
|
+
/** Unique identifier for the report */
|
|
41
|
+
id: string;
|
|
42
|
+
/** Human-readable report name for UI display */
|
|
43
|
+
displayName: string;
|
|
44
|
+
/** API endpoint path for the report */
|
|
45
|
+
endpoint: string;
|
|
46
|
+
/** Available file formats for the report */
|
|
47
|
+
availableFormats: FileFormat[];
|
|
48
|
+
/** Optional description of the report */
|
|
49
|
+
description?: string;
|
|
50
|
+
/** Project the report belongs to */
|
|
51
|
+
projectType: ProjectType;
|
|
52
|
+
/** Type of the report */
|
|
53
|
+
reportType: ReportType;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Registry of all available reports
|
|
57
|
+
*/
|
|
58
|
+
export declare const REPORTS: {
|
|
59
|
+
merchant_disbursement_report: ReportDefinition;
|
|
60
|
+
transaction_revenue_summary: ReportDefinition;
|
|
61
|
+
customer_wallet_activity: ReportDefinition;
|
|
62
|
+
customer_profile_snapshot: ReportDefinition;
|
|
63
|
+
gateway_transaction_log: ReportDefinition;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Get all reports for a specific project
|
|
67
|
+
* @param projectType The project type to filter by
|
|
68
|
+
* @returns Array of report definitions for the project
|
|
69
|
+
*/
|
|
70
|
+
export declare function getReportsByProject(projectType: ProjectType): ReportDefinition[];
|
|
71
|
+
/**
|
|
72
|
+
* Get a report by its type
|
|
73
|
+
* @param reportType The report type to retrieve
|
|
74
|
+
* @returns The report definition or undefined if not found
|
|
75
|
+
*/
|
|
76
|
+
export declare function getReportByType(reportType: ReportType): ReportDefinition;
|
|
77
|
+
/**
|
|
78
|
+
* Validates if a report type is available for a project
|
|
79
|
+
* @param projectType The project type
|
|
80
|
+
* @param reportType The report type
|
|
81
|
+
* @returns True if the report is available for the project, false otherwise
|
|
82
|
+
*/
|
|
83
|
+
export declare function isReportAvailableForProject(projectType: ProjectType, reportType: ReportType): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Report Manager class for handling report downloads
|
|
86
|
+
*/
|
|
87
|
+
export declare class ReportManager {
|
|
88
|
+
private static _instance;
|
|
89
|
+
private constructor();
|
|
90
|
+
/**
|
|
91
|
+
* Get the singleton instance of ReportManager
|
|
92
|
+
*/
|
|
93
|
+
static get instance(): ReportManager;
|
|
94
|
+
/**
|
|
95
|
+
* Get the base URL for the report API
|
|
96
|
+
* @returns The base URL
|
|
97
|
+
*/
|
|
98
|
+
private getBaseURL;
|
|
99
|
+
/**
|
|
100
|
+
* Downloads a report based on project type and report type
|
|
101
|
+
* @param args Arguments for the report download
|
|
102
|
+
* @returns Promise that resolves when download is complete
|
|
103
|
+
*/
|
|
104
|
+
downloadReport(args: {
|
|
105
|
+
token: string;
|
|
106
|
+
projectType: ProjectType;
|
|
107
|
+
reportType: ReportType;
|
|
108
|
+
fileFormat: FileFormat;
|
|
109
|
+
query?: Record<string, any>;
|
|
110
|
+
}): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Process the download
|
|
113
|
+
* @param response The response from the API
|
|
114
|
+
* @param report The report definition
|
|
115
|
+
* @param fileFormat The requested file format
|
|
116
|
+
*/
|
|
117
|
+
private processDownload;
|
|
118
|
+
/**
|
|
119
|
+
* Handle error responses from the API
|
|
120
|
+
* @param response The response from the API
|
|
121
|
+
* @throws Error with appropriate message
|
|
122
|
+
*/
|
|
123
|
+
private handleErrorResponse;
|
|
124
|
+
/**
|
|
125
|
+
* Generates a default filename based on report and file format
|
|
126
|
+
* @param report The report definition
|
|
127
|
+
* @param fileFormat The requested file format
|
|
128
|
+
* @returns A suitable default filename with proper extension
|
|
129
|
+
*/
|
|
130
|
+
private getDefaultFilename;
|
|
131
|
+
/**
|
|
132
|
+
* Extracts the filename from the Content-Disposition header
|
|
133
|
+
* @param contentDisposition The Content-Disposition header value
|
|
134
|
+
* @returns The extracted filename or null if not found
|
|
135
|
+
*/
|
|
136
|
+
private extractFilenameFromContentDisposition;
|
|
137
|
+
/**
|
|
138
|
+
* Converts a base64 string to a Blob
|
|
139
|
+
* @param base64 The base64 string
|
|
140
|
+
* @returns A Blob
|
|
141
|
+
*/
|
|
142
|
+
private b64toBlob;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=report_manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report_manager.d.ts","sourceRoot":"","sources":["../../../src/src/reports/report_manager.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,oBAAY,UAAU;IACpB,sBAAsB;IACtB,GAAG,QAAQ;IACX,wBAAwB;IACxB,KAAK,UAAU;CAChB;AAED;;GAEG;AACH,oBAAY,WAAW;IACrB,8BAA8B;IAC9B,SAAS,cAAc;IACvB,qBAAqB;IACrB,MAAM,WAAW;IACjB,qBAAqB;IACrB,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,oBAAY,UAAU;IACpB,4CAA4C;IAC5C,4BAA4B,iCAAiC;IAC7D,8CAA8C;IAC9C,2BAA2B,gCAAgC;IAC3D,wCAAwC;IACxC,wBAAwB,6BAA6B;IACrD,4CAA4C;IAC5C,yBAAyB,8BAA8B;IACvD,uCAAuC;IACvC,uBAAuB,4BAA4B;CACpD;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uCAAuC;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,gBAAgB,EAAE,UAAU,EAAE,CAAC;IAC/B,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,WAAW,EAAE,WAAW,CAAC;IACzB,yBAAyB;IACzB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;;GAEG;AACH,eAAO,MAAM,OAAO;kCAUb,gBAAgB;iCAUhB,gBAAgB;8BAWhB,gBAAgB;+BAUhB,gBAAgB;6BAWhB,gBAAgB;CACtB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,WAAW,GACvB,gBAAgB,EAAE,CAIpB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,gBAAgB,CAExE;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,GACrB,OAAO,CAGT;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAgB;IAExC,OAAO;IAEP;;OAEG;IACH,WAAkB,QAAQ,kBAEzB;IAED;;;OAGG;IACH,OAAO,CAAC,UAAU,CAIhB;IAEF;;;;OAIG;IACU,cAAc,CAAC,IAAI,EAAE;QAChC,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,WAAW,CAAC;QACzB,UAAU,EAAE,UAAU,CAAC;QACvB,UAAU,EAAE,UAAU,CAAC;QAEvB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC7B,GAAG,OAAO,CAAC,IAAI,CAAC;IAmFjB;;;;;OAKG;YACW,eAAe;IAqB7B;;;;OAIG;YACW,mBAAmB;IAwBjC;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAe1B;;;;OAIG;IACH,OAAO,CAAC,qCAAqC;IA6B7C;;;;OAIG;IACH,OAAO,CAAC,SAAS,CACyB;CAC3C"}
|