@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
|
@@ -23,49 +23,66 @@
|
|
|
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 { type NetworkOperatorInfo } from "./network_operator.js";
|
|
34
|
-
|
|
35
|
-
* Enumeration for various mobile number formats.
|
|
36
|
-
* @enum {string}
|
|
37
|
-
*/
|
|
38
|
-
export declare enum MobileNumberFormat {
|
|
39
|
-
s255 = "255",// Mobile numbers prefixed with 255
|
|
40
|
-
sp255 = "+255",// Mobile numbers prefixed with +255
|
|
41
|
-
s0 = "0",// Mobile numbers prefixed with 0
|
|
42
|
-
none = ""
|
|
43
|
-
}
|
|
40
|
+
import { PhoneNumberFormat } from "../format.js";
|
|
44
41
|
/**
|
|
45
42
|
* Represents a TZ phone number
|
|
46
43
|
*/
|
|
47
|
-
export declare class
|
|
44
|
+
export declare class TZPhoneNumber {
|
|
48
45
|
/**
|
|
49
46
|
* Stores the phone number in a compact format excluding country code and the initial '0'.
|
|
50
47
|
*/
|
|
51
|
-
|
|
48
|
+
private _compactNumber;
|
|
52
49
|
/**
|
|
53
|
-
*
|
|
50
|
+
* Private constructor to prevent direct instantiation.
|
|
51
|
+
* Use TZPhoneNumber.from() instead.
|
|
54
52
|
*
|
|
55
53
|
* @param compactNumber - The phone number in a compact format (e.g., "712345678").
|
|
56
54
|
*/
|
|
57
|
-
constructor(
|
|
55
|
+
private constructor();
|
|
56
|
+
/**
|
|
57
|
+
* Gets the compact number (national number without formatting)
|
|
58
|
+
*/
|
|
59
|
+
get compactNumber(): string;
|
|
58
60
|
/**
|
|
59
|
-
* Formats the
|
|
61
|
+
* Formats the phone number according to the specified format
|
|
60
62
|
*
|
|
61
|
-
* @param format - The desired
|
|
62
|
-
* @returns The phone number
|
|
63
|
+
* @param format - The desired format from GlobalPhoneNumberFormat
|
|
64
|
+
* @returns The formatted phone number string
|
|
65
|
+
*/
|
|
66
|
+
getWithFormat(format: PhoneNumberFormat): string;
|
|
67
|
+
/**
|
|
68
|
+
* Formats the phone number in international format with spaces
|
|
69
|
+
* Format: +255 XXX XXX XXX
|
|
70
|
+
*/
|
|
71
|
+
private formatInternational;
|
|
72
|
+
/**
|
|
73
|
+
* Formats the phone number in national format with spaces
|
|
74
|
+
* Format: 0XXX XXX XXX
|
|
75
|
+
*/
|
|
76
|
+
private formatNational;
|
|
77
|
+
/**
|
|
78
|
+
* Formats the phone number according to RFC3966
|
|
79
|
+
* Format: tel:+255XXXXXXXXX
|
|
63
80
|
*/
|
|
64
|
-
|
|
81
|
+
private formatRFC3966;
|
|
65
82
|
/**
|
|
66
|
-
* Returns the formatted label of the phone number using the
|
|
83
|
+
* Returns the formatted label of the phone number using the international format.
|
|
67
84
|
*
|
|
68
|
-
* @returns The phone number label in
|
|
85
|
+
* @returns The phone number label in international format.
|
|
69
86
|
*/
|
|
70
87
|
get label(): string;
|
|
71
88
|
/**
|
|
@@ -75,12 +92,12 @@ export declare class PhoneNumber {
|
|
|
75
92
|
*/
|
|
76
93
|
get networkOperator(): NetworkOperatorInfo;
|
|
77
94
|
/**
|
|
78
|
-
* Creates a `
|
|
95
|
+
* Creates a `TZPhoneNumber` instance from a given string.
|
|
79
96
|
*
|
|
80
97
|
* @param s - The input phone number string in various formats (e.g., "+255712345678", "0712345678").
|
|
81
|
-
* @returns A `
|
|
98
|
+
* @returns A `TZPhoneNumber` instance if valid, otherwise `undefined`.
|
|
82
99
|
*/
|
|
83
|
-
static from(
|
|
100
|
+
static from(input: string): TZPhoneNumber | undefined;
|
|
84
101
|
/**
|
|
85
102
|
* Checks if a string can be constructed into a valid phone number object.
|
|
86
103
|
* @param {string | undefined} input - The string to validate as a phone number.
|
|
@@ -89,16 +106,16 @@ export declare class PhoneNumber {
|
|
|
89
106
|
*/
|
|
90
107
|
static canConstruct(input?: string | null): boolean;
|
|
91
108
|
/**
|
|
92
|
-
* Checks if an unknown value contains valid data to construct a
|
|
109
|
+
* Checks if an unknown value contains valid data to construct a TZPhoneNumber instance.
|
|
93
110
|
* Validates the structural integrity of the phone number object.
|
|
94
111
|
*
|
|
95
112
|
* @param {unknown} obj - The value to validate.
|
|
96
|
-
* @returns {obj is
|
|
113
|
+
* @returns {obj is TZPhoneNumber} Type predicate indicating if the value has a valid phone number structure.
|
|
97
114
|
*
|
|
98
115
|
* @example
|
|
99
116
|
* const maybePhone = JSON.parse(someData);
|
|
100
|
-
* if (
|
|
101
|
-
* // maybePhone is typed as
|
|
117
|
+
* if (TZPhoneNumber.is(maybePhone)) {
|
|
118
|
+
* // maybePhone is typed as TZPhoneNumber
|
|
102
119
|
* console.log(maybePhone.label);
|
|
103
120
|
* }
|
|
104
121
|
*
|
|
@@ -108,7 +125,7 @@ export declare class PhoneNumber {
|
|
|
108
125
|
* - compactNumber is a 9-digit string
|
|
109
126
|
* - Prefix matches a valid network operator
|
|
110
127
|
*/
|
|
111
|
-
static is(obj: unknown): obj is
|
|
128
|
+
static is(obj: unknown): obj is TZPhoneNumber;
|
|
112
129
|
/**
|
|
113
130
|
* Checks the validity of the phone number data
|
|
114
131
|
* @returns true if the phone number information is available and valid
|
|
@@ -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"}
|
|
@@ -24,33 +24,30 @@
|
|
|
24
24
|
* - Tigo: 65, 67, etc.
|
|
25
25
|
* - Halotel: 62, etc.
|
|
26
26
|
*
|
|
27
|
+
* 4. Phone numbers can be formatted in the following ways:
|
|
28
|
+
* - International format: "+255 XXX XXX XXX"
|
|
29
|
+
* - National format: "0XXX XXX XXX"
|
|
30
|
+
* - Compact format: "XXXXXXXXX"
|
|
31
|
+
* - RFC3966 format: "tel:+255XXXXXXXXX"
|
|
32
|
+
*
|
|
27
33
|
* ## Solution
|
|
28
|
-
* The
|
|
34
|
+
* The TZPhoneNumber class provides:
|
|
29
35
|
* 1. Parsing and validation of different input formats
|
|
30
36
|
* 2. Standardized storage in compact format
|
|
31
37
|
* 3. Formatting options for display and API use
|
|
32
38
|
* 4. Network operator identification
|
|
33
39
|
*/
|
|
34
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.
|
|
41
|
+
exports.TZPhoneNumber = void 0;
|
|
36
42
|
const network_operator_js_1 = require("./network_operator.js");
|
|
37
|
-
|
|
38
|
-
* Enumeration for various mobile number formats.
|
|
39
|
-
* @enum {string}
|
|
40
|
-
*/
|
|
41
|
-
var MobileNumberFormat;
|
|
42
|
-
(function (MobileNumberFormat) {
|
|
43
|
-
MobileNumberFormat["s255"] = "255";
|
|
44
|
-
MobileNumberFormat["sp255"] = "+255";
|
|
45
|
-
MobileNumberFormat["s0"] = "0";
|
|
46
|
-
MobileNumberFormat["none"] = "";
|
|
47
|
-
})(MobileNumberFormat || (exports.MobileNumberFormat = MobileNumberFormat = {}));
|
|
43
|
+
const format_js_1 = require("../format.js");
|
|
48
44
|
/**
|
|
49
45
|
* Represents a TZ phone number
|
|
50
46
|
*/
|
|
51
|
-
class
|
|
47
|
+
class TZPhoneNumber {
|
|
52
48
|
/**
|
|
53
|
-
*
|
|
49
|
+
* Private constructor to prevent direct instantiation.
|
|
50
|
+
* Use TZPhoneNumber.from() instead.
|
|
54
51
|
*
|
|
55
52
|
* @param compactNumber - The phone number in a compact format (e.g., "712345678").
|
|
56
53
|
*/
|
|
@@ -58,30 +55,76 @@ class PhoneNumber {
|
|
|
58
55
|
/**
|
|
59
56
|
* Stores the phone number in a compact format excluding country code and the initial '0'.
|
|
60
57
|
*/
|
|
61
|
-
Object.defineProperty(this, "
|
|
58
|
+
Object.defineProperty(this, "_compactNumber", {
|
|
62
59
|
enumerable: true,
|
|
63
60
|
configurable: true,
|
|
64
61
|
writable: true,
|
|
65
62
|
value: void 0
|
|
66
63
|
});
|
|
67
|
-
this.
|
|
64
|
+
this._compactNumber = compactNumber;
|
|
68
65
|
}
|
|
69
66
|
/**
|
|
70
|
-
*
|
|
67
|
+
* Gets the compact number (national number without formatting)
|
|
68
|
+
*/
|
|
69
|
+
get compactNumber() {
|
|
70
|
+
return this._compactNumber;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Formats the phone number according to the specified format
|
|
71
74
|
*
|
|
72
|
-
* @param format - The desired
|
|
73
|
-
* @returns The phone number
|
|
75
|
+
* @param format - The desired format from GlobalPhoneNumberFormat
|
|
76
|
+
* @returns The formatted phone number string
|
|
74
77
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
getWithFormat(format) {
|
|
79
|
+
switch (format) {
|
|
80
|
+
case format_js_1.PhoneNumberFormat.INTERNATIONAL:
|
|
81
|
+
// Format: +255 XXX XXX XXX
|
|
82
|
+
return this.formatInternational();
|
|
83
|
+
case format_js_1.PhoneNumberFormat.NATIONAL:
|
|
84
|
+
// Format: 0XXX XXX XXX
|
|
85
|
+
return this.formatNational();
|
|
86
|
+
case format_js_1.PhoneNumberFormat.COMPACT:
|
|
87
|
+
// Format: XXXXXXXXX (just the 9 digits)
|
|
88
|
+
return this._compactNumber;
|
|
89
|
+
case format_js_1.PhoneNumberFormat.RFC3966:
|
|
90
|
+
// Format: tel:+255XXXXXXXXX
|
|
91
|
+
return this.formatRFC3966();
|
|
92
|
+
default:
|
|
93
|
+
return `+255${this._compactNumber}`;
|
|
94
|
+
}
|
|
77
95
|
}
|
|
78
96
|
/**
|
|
79
|
-
*
|
|
97
|
+
* Formats the phone number in international format with spaces
|
|
98
|
+
* Format: +255 XXX XXX XXX
|
|
99
|
+
*/
|
|
100
|
+
formatInternational() {
|
|
101
|
+
const num = this._compactNumber;
|
|
102
|
+
// Insert spaces: +255 XXX XXX XXX
|
|
103
|
+
return `+255 ${num.substring(0, 3)} ${num.substring(3, 6)} ${num.substring(6)}`;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Formats the phone number in national format with spaces
|
|
107
|
+
* Format: 0XXX XXX XXX
|
|
108
|
+
*/
|
|
109
|
+
formatNational() {
|
|
110
|
+
const num = this._compactNumber;
|
|
111
|
+
// Insert spaces: 0XXX XXX XXX
|
|
112
|
+
return `0${num.substring(0, 3)} ${num.substring(3, 6)} ${num.substring(6)}`;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Formats the phone number according to RFC3966
|
|
116
|
+
* Format: tel:+255XXXXXXXXX
|
|
117
|
+
*/
|
|
118
|
+
formatRFC3966() {
|
|
119
|
+
return `tel:+255${this._compactNumber}`;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Returns the formatted label of the phone number using the international format.
|
|
80
123
|
*
|
|
81
|
-
* @returns The phone number label in
|
|
124
|
+
* @returns The phone number label in international format.
|
|
82
125
|
*/
|
|
83
126
|
get label() {
|
|
84
|
-
return this.
|
|
127
|
+
return this.getWithFormat(format_js_1.PhoneNumberFormat.INTERNATIONAL);
|
|
85
128
|
}
|
|
86
129
|
/**
|
|
87
130
|
* Derives the network operator information associated with the phone number by checking its prefix.
|
|
@@ -89,21 +132,24 @@ class PhoneNumber {
|
|
|
89
132
|
* @returns The `NetworkOperatorInfo` object that matches the phone number prefix.
|
|
90
133
|
*/
|
|
91
134
|
get networkOperator() {
|
|
92
|
-
const prefix = this.
|
|
135
|
+
const prefix = this._compactNumber.substring(0, 2);
|
|
93
136
|
const result = Object.values(network_operator_js_1.NETWORK_OPERATOR_CONFIG).find((operator) => operator.mobileNumberPrefixes.includes(prefix));
|
|
94
137
|
return result;
|
|
95
138
|
}
|
|
96
139
|
/**
|
|
97
|
-
* Creates a `
|
|
140
|
+
* Creates a `TZPhoneNumber` instance from a given string.
|
|
98
141
|
*
|
|
99
142
|
* @param s - The input phone number string in various formats (e.g., "+255712345678", "0712345678").
|
|
100
|
-
* @returns A `
|
|
143
|
+
* @returns A `TZPhoneNumber` instance if valid, otherwise `undefined`.
|
|
101
144
|
*/
|
|
102
|
-
static from(
|
|
145
|
+
static from(input) {
|
|
103
146
|
try {
|
|
104
|
-
|
|
147
|
+
// Clean the input (remove all non-digits except the leading '+')
|
|
148
|
+
const hasPlus = input.trim().startsWith("+");
|
|
149
|
+
let number = input.replace(/\D/g, "");
|
|
150
|
+
number = hasPlus ? `+${number}` : number;
|
|
105
151
|
if (number.length === 0)
|
|
106
|
-
return;
|
|
152
|
+
return undefined;
|
|
107
153
|
const isOnlyDigits = isOnlyDigitsOrPlus(number);
|
|
108
154
|
if (!isOnlyDigits)
|
|
109
155
|
return;
|
|
@@ -129,7 +175,7 @@ class PhoneNumber {
|
|
|
129
175
|
const operator = Object.values(network_operator_js_1.NETWORK_OPERATOR_CONFIG).find((op) => op.mobileNumberPrefixes.includes(prefix));
|
|
130
176
|
if (!operator)
|
|
131
177
|
return;
|
|
132
|
-
return new
|
|
178
|
+
return new TZPhoneNumber(compactNumber);
|
|
133
179
|
}
|
|
134
180
|
catch (_) {
|
|
135
181
|
return;
|
|
@@ -147,20 +193,20 @@ class PhoneNumber {
|
|
|
147
193
|
const text = removeSpaces(input.trim());
|
|
148
194
|
if (text.length === 0)
|
|
149
195
|
return false;
|
|
150
|
-
const phone =
|
|
196
|
+
const phone = TZPhoneNumber.from(text);
|
|
151
197
|
return phone !== undefined;
|
|
152
198
|
}
|
|
153
199
|
/**
|
|
154
|
-
* Checks if an unknown value contains valid data to construct a
|
|
200
|
+
* Checks if an unknown value contains valid data to construct a TZPhoneNumber instance.
|
|
155
201
|
* Validates the structural integrity of the phone number object.
|
|
156
202
|
*
|
|
157
203
|
* @param {unknown} obj - The value to validate.
|
|
158
|
-
* @returns {obj is
|
|
204
|
+
* @returns {obj is TZPhoneNumber} Type predicate indicating if the value has a valid phone number structure.
|
|
159
205
|
*
|
|
160
206
|
* @example
|
|
161
207
|
* const maybePhone = JSON.parse(someData);
|
|
162
|
-
* if (
|
|
163
|
-
* // maybePhone is typed as
|
|
208
|
+
* if (TZPhoneNumber.is(maybePhone)) {
|
|
209
|
+
* // maybePhone is typed as TZPhoneNumber
|
|
164
210
|
* console.log(maybePhone.label);
|
|
165
211
|
* }
|
|
166
212
|
*
|
|
@@ -174,11 +220,11 @@ class PhoneNumber {
|
|
|
174
220
|
if (!obj || typeof obj !== "object")
|
|
175
221
|
return false;
|
|
176
222
|
const maybePhone = obj;
|
|
177
|
-
// Check if
|
|
178
|
-
if (typeof maybePhone.
|
|
223
|
+
// Check if _compactNumber exists and is string
|
|
224
|
+
if (typeof maybePhone._compactNumber !== "string")
|
|
179
225
|
return false;
|
|
180
|
-
const compactNumber = maybePhone.
|
|
181
|
-
return
|
|
226
|
+
const compactNumber = maybePhone._compactNumber;
|
|
227
|
+
return TZPhoneNumber.canConstruct(compactNumber);
|
|
182
228
|
}
|
|
183
229
|
/**
|
|
184
230
|
* Checks the validity of the phone number data
|
|
@@ -186,14 +232,14 @@ class PhoneNumber {
|
|
|
186
232
|
*/
|
|
187
233
|
validate() {
|
|
188
234
|
try {
|
|
189
|
-
return
|
|
235
|
+
return TZPhoneNumber.canConstruct(this._compactNumber);
|
|
190
236
|
}
|
|
191
237
|
catch (_) {
|
|
192
238
|
return false;
|
|
193
239
|
}
|
|
194
240
|
}
|
|
195
241
|
}
|
|
196
|
-
exports.
|
|
242
|
+
exports.TZPhoneNumber = TZPhoneNumber;
|
|
197
243
|
/**
|
|
198
244
|
* Removes all whitespace characters from the given string.
|
|
199
245
|
*
|
|
@@ -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,17 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./report_manager.js"), exports);
|
|
@@ -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"}
|