@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.
Files changed (200) hide show
  1. package/README.md +126 -25
  2. package/esm/deps/jsr.io/@std/internal/1.0.5/assertion_state.d.ts.map +1 -0
  3. package/esm/deps/jsr.io/@std/testing/1.0.9/_test_suite.d.ts.map +1 -0
  4. package/esm/deps/jsr.io/@std/testing/1.0.9/bdd.d.ts.map +1 -0
  5. package/esm/mod.d.ts +2 -0
  6. package/esm/mod.d.ts.map +1 -1
  7. package/esm/mod.js +2 -0
  8. package/esm/src/config/config_service.d.ts +11 -0
  9. package/esm/src/config/config_service.d.ts.map +1 -0
  10. package/esm/src/config/config_service.js +19 -0
  11. package/esm/src/config/index.d.ts +2 -0
  12. package/esm/src/config/index.d.ts.map +1 -0
  13. package/esm/src/config/index.js +1 -0
  14. package/esm/src/{models/bank/banks.d.ts → data/banks_tz.d.ts} +1 -1
  15. package/esm/src/data/banks_tz.d.ts.map +1 -0
  16. package/esm/src/data/countries.d.ts +6 -0
  17. package/esm/src/data/countries.d.ts.map +1 -0
  18. package/esm/src/data/countries.js +974 -0
  19. package/esm/src/data/currencies.d.ts +1901 -0
  20. package/esm/src/data/currencies.d.ts.map +1 -0
  21. package/esm/src/data/currencies.js +1073 -0
  22. package/esm/src/data/phone_patterns.d.ts +3809 -0
  23. package/esm/src/data/phone_patterns.d.ts.map +1 -0
  24. package/esm/src/data/phone_patterns.js +2325 -0
  25. package/esm/src/models/amount/amount.d.ts +10 -12
  26. package/esm/src/models/amount/amount.d.ts.map +1 -1
  27. package/esm/src/models/amount/amount.js +58 -96
  28. package/esm/src/models/bank/bank.d.ts +58 -53
  29. package/esm/src/models/bank/bank.d.ts.map +1 -1
  30. package/esm/src/models/bank/bank.js +49 -84
  31. package/esm/src/models/bank/index.d.ts +1 -1
  32. package/esm/src/models/bank/index.d.ts.map +1 -1
  33. package/esm/src/models/bank/index.js +1 -1
  34. package/esm/src/models/bank/service.d.ts +106 -0
  35. package/esm/src/models/bank/service.d.ts.map +1 -0
  36. package/esm/src/models/bank/service.js +240 -0
  37. package/esm/src/models/country/country.d.ts +568 -0
  38. package/esm/src/models/country/country.d.ts.map +1 -0
  39. package/esm/src/models/country/country.js +165 -0
  40. package/esm/src/models/country/country.test.d.ts.map +1 -0
  41. package/esm/src/models/country/index.d.ts +3 -0
  42. package/esm/src/models/country/index.d.ts.map +1 -0
  43. package/esm/src/models/country/index.js +2 -0
  44. package/esm/src/models/country/service.d.ts +75 -0
  45. package/esm/src/models/country/service.d.ts.map +1 -0
  46. package/esm/src/models/country/service.js +267 -0
  47. package/esm/src/models/currency/currency.d.ts +341 -0
  48. package/esm/src/models/currency/currency.d.ts.map +1 -0
  49. package/esm/src/models/currency/currency.js +225 -0
  50. package/esm/src/models/currency/currency.test.d.ts.map +1 -0
  51. package/esm/src/models/currency/index.d.ts +3 -0
  52. package/esm/src/models/currency/index.d.ts.map +1 -0
  53. package/esm/src/models/currency/index.js +2 -0
  54. package/esm/src/models/currency/service.d.ts +96 -0
  55. package/esm/src/models/currency/service.d.ts.map +1 -0
  56. package/esm/src/models/currency/service.js +194 -0
  57. package/esm/src/models/index.d.ts +2 -0
  58. package/esm/src/models/index.d.ts.map +1 -1
  59. package/esm/src/models/index.js +2 -0
  60. package/esm/src/models/phone_number/format.d.ts +14 -0
  61. package/esm/src/models/phone_number/format.d.ts.map +1 -0
  62. package/esm/src/models/phone_number/format.js +14 -0
  63. package/esm/src/models/phone_number/global/phone_number.d.ts +160 -0
  64. package/esm/src/models/phone_number/global/phone_number.d.ts.map +1 -0
  65. package/esm/src/models/phone_number/global/phone_number.js +453 -0
  66. package/esm/src/models/phone_number/global/phone_number.test.d.ts.map +1 -0
  67. package/esm/src/models/phone_number/global/service.d.ts +260 -0
  68. package/esm/src/models/phone_number/global/service.d.ts.map +1 -0
  69. package/esm/src/models/phone_number/global/service.js +477 -0
  70. package/esm/src/models/phone_number/global/service.test.d.ts.map +1 -0
  71. package/esm/src/models/phone_number/index.d.ts +5 -3
  72. package/esm/src/models/phone_number/index.d.ts.map +1 -1
  73. package/esm/src/models/phone_number/index.js +5 -3
  74. package/esm/src/models/phone_number/{antd_validator.d.ts → tz/antd_validator.d.ts} +2 -2
  75. package/esm/src/models/phone_number/tz/antd_validator.d.ts.map +1 -0
  76. package/esm/src/models/phone_number/{antd_validator.js → tz/antd_validator.js} +2 -2
  77. package/esm/src/models/phone_number/tz/antdvalidator.test.d.ts.map +1 -0
  78. package/esm/src/models/phone_number/tz/network_operator.d.ts.map +1 -0
  79. package/{script/src/models/phone_number → esm/src/models/phone_number/tz}/phone_number.d.ts +46 -29
  80. package/esm/src/models/phone_number/tz/phone_number.d.ts.map +1 -0
  81. package/esm/src/models/phone_number/{phone_number.js → tz/phone_number.js} +87 -41
  82. package/esm/src/models/phone_number/tz/phone_number.test.d.ts.map +1 -0
  83. package/esm/src/reports/index.d.ts +2 -0
  84. package/esm/src/reports/index.d.ts.map +1 -0
  85. package/esm/src/reports/index.js +1 -0
  86. package/esm/src/reports/report_manager.d.ts +144 -0
  87. package/esm/src/reports/report_manager.d.ts.map +1 -0
  88. package/esm/src/reports/report_manager.js +315 -0
  89. package/package.json +4 -3
  90. package/script/deps/jsr.io/@std/internal/1.0.5/assertion_state.d.ts.map +1 -0
  91. package/script/deps/jsr.io/@std/testing/1.0.9/_test_suite.d.ts.map +1 -0
  92. package/script/deps/jsr.io/@std/testing/1.0.9/bdd.d.ts.map +1 -0
  93. package/script/mod.d.ts +2 -0
  94. package/script/mod.d.ts.map +1 -1
  95. package/script/mod.js +2 -0
  96. package/script/src/config/config_service.d.ts +11 -0
  97. package/script/src/config/config_service.d.ts.map +1 -0
  98. package/script/src/config/config_service.js +23 -0
  99. package/script/src/config/index.d.ts +2 -0
  100. package/script/src/config/index.d.ts.map +1 -0
  101. package/script/src/config/index.js +17 -0
  102. package/script/src/{models/bank/banks.d.ts → data/banks_tz.d.ts} +1 -1
  103. package/script/src/data/banks_tz.d.ts.map +1 -0
  104. package/script/src/data/countries.d.ts +6 -0
  105. package/script/src/data/countries.d.ts.map +1 -0
  106. package/script/src/data/countries.js +976 -0
  107. package/script/src/data/currencies.d.ts +1901 -0
  108. package/script/src/data/currencies.d.ts.map +1 -0
  109. package/script/src/data/currencies.js +1075 -0
  110. package/script/src/data/phone_patterns.d.ts +3809 -0
  111. package/script/src/data/phone_patterns.d.ts.map +1 -0
  112. package/script/src/data/phone_patterns.js +2327 -0
  113. package/script/src/models/amount/amount.d.ts +10 -12
  114. package/script/src/models/amount/amount.d.ts.map +1 -1
  115. package/script/src/models/amount/amount.js +60 -98
  116. package/script/src/models/bank/bank.d.ts +58 -53
  117. package/script/src/models/bank/bank.d.ts.map +1 -1
  118. package/script/src/models/bank/bank.js +49 -87
  119. package/script/src/models/bank/index.d.ts +1 -1
  120. package/script/src/models/bank/index.d.ts.map +1 -1
  121. package/script/src/models/bank/index.js +1 -1
  122. package/script/src/models/bank/service.d.ts +106 -0
  123. package/script/src/models/bank/service.d.ts.map +1 -0
  124. package/script/src/models/bank/service.js +247 -0
  125. package/script/src/models/country/country.d.ts +568 -0
  126. package/script/src/models/country/country.d.ts.map +1 -0
  127. package/script/src/models/country/country.js +169 -0
  128. package/script/src/models/country/country.test.d.ts.map +1 -0
  129. package/script/src/models/country/index.d.ts +3 -0
  130. package/script/src/models/country/index.d.ts.map +1 -0
  131. package/script/src/models/country/index.js +18 -0
  132. package/script/src/models/country/service.d.ts +75 -0
  133. package/script/src/models/country/service.d.ts.map +1 -0
  134. package/script/src/models/country/service.js +274 -0
  135. package/script/src/models/currency/currency.d.ts +341 -0
  136. package/script/src/models/currency/currency.d.ts.map +1 -0
  137. package/script/src/models/currency/currency.js +229 -0
  138. package/script/src/models/currency/currency.test.d.ts.map +1 -0
  139. package/script/src/models/currency/index.d.ts +3 -0
  140. package/script/src/models/currency/index.d.ts.map +1 -0
  141. package/script/src/models/currency/index.js +18 -0
  142. package/script/src/models/currency/service.d.ts +96 -0
  143. package/script/src/models/currency/service.d.ts.map +1 -0
  144. package/script/src/models/currency/service.js +201 -0
  145. package/script/src/models/index.d.ts +2 -0
  146. package/script/src/models/index.d.ts.map +1 -1
  147. package/script/src/models/index.js +2 -0
  148. package/script/src/models/phone_number/format.d.ts +14 -0
  149. package/script/src/models/phone_number/format.d.ts.map +1 -0
  150. package/script/src/models/phone_number/format.js +17 -0
  151. package/script/src/models/phone_number/global/phone_number.d.ts +160 -0
  152. package/script/src/models/phone_number/global/phone_number.d.ts.map +1 -0
  153. package/script/src/models/phone_number/global/phone_number.js +457 -0
  154. package/script/src/models/phone_number/global/phone_number.test.d.ts.map +1 -0
  155. package/script/src/models/phone_number/global/service.d.ts +260 -0
  156. package/script/src/models/phone_number/global/service.d.ts.map +1 -0
  157. package/script/src/models/phone_number/global/service.js +485 -0
  158. package/script/src/models/phone_number/global/service.test.d.ts.map +1 -0
  159. package/script/src/models/phone_number/index.d.ts +5 -3
  160. package/script/src/models/phone_number/index.d.ts.map +1 -1
  161. package/script/src/models/phone_number/index.js +5 -3
  162. package/script/src/models/phone_number/{antd_validator.d.ts → tz/antd_validator.d.ts} +2 -2
  163. package/script/src/models/phone_number/tz/antd_validator.d.ts.map +1 -0
  164. package/script/src/models/phone_number/{antd_validator.js → tz/antd_validator.js} +1 -1
  165. package/script/src/models/phone_number/tz/antdvalidator.test.d.ts.map +1 -0
  166. package/script/src/models/phone_number/tz/network_operator.d.ts.map +1 -0
  167. package/{esm/src/models/phone_number → script/src/models/phone_number/tz}/phone_number.d.ts +46 -29
  168. package/script/src/models/phone_number/tz/phone_number.d.ts.map +1 -0
  169. package/script/src/models/phone_number/{phone_number.js → tz/phone_number.js} +89 -43
  170. package/script/src/models/phone_number/tz/phone_number.test.d.ts.map +1 -0
  171. package/script/src/reports/index.d.ts +2 -0
  172. package/script/src/reports/index.d.ts.map +1 -0
  173. package/script/src/reports/index.js +17 -0
  174. package/script/src/reports/report_manager.d.ts +144 -0
  175. package/script/src/reports/report_manager.d.ts.map +1 -0
  176. package/script/src/reports/report_manager.js +325 -0
  177. package/esm/src/models/bank/banks.d.ts.map +0 -1
  178. package/esm/src/models/bank/utils.d.ts +0 -25
  179. package/esm/src/models/bank/utils.d.ts.map +0 -1
  180. package/esm/src/models/bank/utils.js +0 -35
  181. package/esm/src/models/phone_number/antd_validator.d.ts.map +0 -1
  182. package/esm/src/models/phone_number/antdvalidator.test.d.ts.map +0 -1
  183. package/esm/src/models/phone_number/network_operator.d.ts.map +0 -1
  184. package/esm/src/models/phone_number/phone_number.d.ts.map +0 -1
  185. package/esm/src/models/phone_number/phone_number.test.d.ts.map +0 -1
  186. package/script/src/models/bank/banks.d.ts.map +0 -1
  187. package/script/src/models/bank/utils.d.ts +0 -25
  188. package/script/src/models/bank/utils.d.ts.map +0 -1
  189. package/script/src/models/bank/utils.js +0 -41
  190. package/script/src/models/phone_number/antd_validator.d.ts.map +0 -1
  191. package/script/src/models/phone_number/antdvalidator.test.d.ts.map +0 -1
  192. package/script/src/models/phone_number/network_operator.d.ts.map +0 -1
  193. package/script/src/models/phone_number/phone_number.d.ts.map +0 -1
  194. package/script/src/models/phone_number/phone_number.test.d.ts.map +0 -1
  195. /package/esm/src/{models/bank/banks.js → data/banks_tz.js} +0 -0
  196. /package/esm/src/models/phone_number/{network_operator.d.ts → tz/network_operator.d.ts} +0 -0
  197. /package/esm/src/models/phone_number/{network_operator.js → tz/network_operator.js} +0 -0
  198. /package/script/src/{models/bank/banks.js → data/banks_tz.js} +0 -0
  199. /package/script/src/models/phone_number/{network_operator.d.ts → tz/network_operator.d.ts} +0 -0
  200. /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 PhoneNumber class provides:
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 PhoneNumber {
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
- compactNumber: string;
48
+ private _compactNumber;
52
49
  /**
53
- * Constructs a new `PhoneNumber` instance.
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(compactNumber: string);
55
+ private constructor();
56
+ /**
57
+ * Gets the compact number (national number without formatting)
58
+ */
59
+ get compactNumber(): string;
58
60
  /**
59
- * Formats the compact phone number with the specified `MobileNumberFormat`.
61
+ * Formats the phone number according to the specified format
60
62
  *
61
- * @param format - The desired phone number format (e.g., `+255` or `255`).
62
- * @returns The phone number formatted as a string.
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
- getNumberWithFormat(format: MobileNumberFormat): string;
81
+ private formatRFC3966;
65
82
  /**
66
- * Returns the formatted label of the phone number using the `s255` format.
83
+ * Returns the formatted label of the phone number using the international format.
67
84
  *
68
- * @returns The phone number label in `255` format.
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 `PhoneNumber` instance from a given string.
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 `PhoneNumber` instance if valid, otherwise `undefined`.
98
+ * @returns A `TZPhoneNumber` instance if valid, otherwise `undefined`.
82
99
  */
83
- static from(s: string): PhoneNumber | undefined;
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 PhoneNumber instance.
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 PhoneNumber} Type predicate indicating if the value has a valid phone number structure.
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 (PhoneNumber.is(maybePhone)) {
101
- * // maybePhone is typed as PhoneNumber
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 PhoneNumber;
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 PhoneNumber class provides:
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.PhoneNumber = exports.MobileNumberFormat = void 0;
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 PhoneNumber {
47
+ class TZPhoneNumber {
52
48
  /**
53
- * Constructs a new `PhoneNumber` instance.
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, "compactNumber", {
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.compactNumber = compactNumber;
64
+ this._compactNumber = compactNumber;
68
65
  }
69
66
  /**
70
- * Formats the compact phone number with the specified `MobileNumberFormat`.
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 phone number format (e.g., `+255` or `255`).
73
- * @returns The phone number formatted as a string.
75
+ * @param format - The desired format from GlobalPhoneNumberFormat
76
+ * @returns The formatted phone number string
74
77
  */
75
- getNumberWithFormat(format) {
76
- return `${format}${this.compactNumber}`;
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
- * Returns the formatted label of the phone number using the `s255` format.
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 `255` format.
124
+ * @returns The phone number label in international format.
82
125
  */
83
126
  get label() {
84
- return this.getNumberWithFormat(MobileNumberFormat.s255);
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.compactNumber.substring(0, 2);
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 `PhoneNumber` instance from a given string.
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 `PhoneNumber` instance if valid, otherwise `undefined`.
143
+ * @returns A `TZPhoneNumber` instance if valid, otherwise `undefined`.
101
144
  */
102
- static from(s) {
145
+ static from(input) {
103
146
  try {
104
- const number = removeSpaces(s.trim());
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 PhoneNumber(compactNumber);
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 = PhoneNumber.from(text);
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 PhoneNumber instance.
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 PhoneNumber} Type predicate indicating if the value has a valid phone number structure.
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 (PhoneNumber.is(maybePhone)) {
163
- * // maybePhone is typed as PhoneNumber
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 compactNumber exists and is string
178
- if (typeof maybePhone.compactNumber !== "string")
223
+ // Check if _compactNumber exists and is string
224
+ if (typeof maybePhone._compactNumber !== "string")
179
225
  return false;
180
- const compactNumber = maybePhone.compactNumber;
181
- return PhoneNumber.canConstruct(compactNumber);
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 PhoneNumber.canConstruct(this.compactNumber);
235
+ return TZPhoneNumber.canConstruct(this._compactNumber);
190
236
  }
191
237
  catch (_) {
192
238
  return false;
193
239
  }
194
240
  }
195
241
  }
196
- exports.PhoneNumber = PhoneNumber;
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,2 @@
1
+ export * from "./report_manager.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -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"}