@temboplus/frontend-core 0.2.4 → 0.2.6

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 (86) hide show
  1. package/README.md +74 -20
  2. package/esm/src/data/countries.d.ts +36 -3
  3. package/esm/src/data/countries.js +2475 -974
  4. package/esm/src/models/amount/amount.d.ts.map +1 -1
  5. package/esm/src/models/amount/amount.js +1 -1
  6. package/esm/src/models/bank/bank.d.ts +127 -0
  7. package/esm/src/models/bank/bank.d.ts.map +1 -1
  8. package/esm/src/models/bank/bank.js +264 -7
  9. package/esm/src/models/bank/index.d.ts +0 -1
  10. package/esm/src/models/bank/index.d.ts.map +1 -1
  11. package/esm/src/models/bank/index.js +0 -1
  12. package/esm/src/models/country/country.d.ts +278 -24
  13. package/esm/src/models/country/country.d.ts.map +1 -1
  14. package/esm/src/models/country/country.js +603 -31
  15. package/esm/src/models/country/index.d.ts +1 -1
  16. package/esm/src/models/country/index.d.ts.map +1 -1
  17. package/esm/src/models/country/index.js +1 -1
  18. package/esm/src/models/country/types.d.ts +53 -0
  19. package/esm/src/models/country/types.d.ts.map +1 -0
  20. package/esm/src/models/country/types.js +43 -0
  21. package/esm/src/models/currency/currency.d.ts +127 -4
  22. package/esm/src/models/currency/currency.d.ts.map +1 -1
  23. package/esm/src/models/currency/currency.js +229 -11
  24. package/esm/src/models/currency/index.d.ts +1 -1
  25. package/esm/src/models/currency/index.d.ts.map +1 -1
  26. package/esm/src/models/currency/index.js +1 -1
  27. package/esm/src/models/currency/types.d.ts +20 -0
  28. package/esm/src/models/currency/types.d.ts.map +1 -0
  29. package/esm/src/models/currency/types.js +13 -0
  30. package/esm/src/models/phone_number/global/phone_number.d.ts +3 -2
  31. package/esm/src/models/phone_number/global/phone_number.d.ts.map +1 -1
  32. package/esm/src/models/phone_number/global/service.d.ts +27 -20
  33. package/esm/src/models/phone_number/global/service.d.ts.map +1 -1
  34. package/esm/src/models/phone_number/global/service.js +61 -40
  35. package/package.json +1 -1
  36. package/script/src/data/countries.d.ts +36 -3
  37. package/script/src/data/countries.js +2475 -974
  38. package/script/src/models/amount/amount.d.ts.map +1 -1
  39. package/script/src/models/amount/amount.js +4 -4
  40. package/script/src/models/bank/bank.d.ts +127 -0
  41. package/script/src/models/bank/bank.d.ts.map +1 -1
  42. package/script/src/models/bank/bank.js +273 -12
  43. package/script/src/models/bank/index.d.ts +0 -1
  44. package/script/src/models/bank/index.d.ts.map +1 -1
  45. package/script/src/models/bank/index.js +0 -1
  46. package/script/src/models/country/country.d.ts +278 -24
  47. package/script/src/models/country/country.d.ts.map +1 -1
  48. package/script/src/models/country/country.js +611 -35
  49. package/script/src/models/country/index.d.ts +1 -1
  50. package/script/src/models/country/index.d.ts.map +1 -1
  51. package/script/src/models/country/index.js +1 -1
  52. package/script/src/models/country/types.d.ts +53 -0
  53. package/script/src/models/country/types.d.ts.map +1 -0
  54. package/script/src/models/country/types.js +46 -0
  55. package/script/src/models/currency/currency.d.ts +127 -4
  56. package/script/src/models/currency/currency.d.ts.map +1 -1
  57. package/script/src/models/currency/currency.js +237 -15
  58. package/script/src/models/currency/index.d.ts +1 -1
  59. package/script/src/models/currency/index.d.ts.map +1 -1
  60. package/script/src/models/currency/index.js +1 -1
  61. package/script/src/models/currency/types.d.ts +20 -0
  62. package/script/src/models/currency/types.d.ts.map +1 -0
  63. package/script/src/models/currency/types.js +14 -0
  64. package/script/src/models/phone_number/global/phone_number.d.ts +3 -2
  65. package/script/src/models/phone_number/global/phone_number.d.ts.map +1 -1
  66. package/script/src/models/phone_number/global/service.d.ts +27 -20
  67. package/script/src/models/phone_number/global/service.d.ts.map +1 -1
  68. package/script/src/models/phone_number/global/service.js +61 -40
  69. package/esm/src/models/bank/service.d.ts +0 -106
  70. package/esm/src/models/bank/service.d.ts.map +0 -1
  71. package/esm/src/models/bank/service.js +0 -240
  72. package/esm/src/models/country/service.d.ts +0 -75
  73. package/esm/src/models/country/service.d.ts.map +0 -1
  74. package/esm/src/models/country/service.js +0 -267
  75. package/esm/src/models/currency/service.d.ts +0 -96
  76. package/esm/src/models/currency/service.d.ts.map +0 -1
  77. package/esm/src/models/currency/service.js +0 -194
  78. package/script/src/models/bank/service.d.ts +0 -106
  79. package/script/src/models/bank/service.d.ts.map +0 -1
  80. package/script/src/models/bank/service.js +0 -247
  81. package/script/src/models/country/service.d.ts +0 -75
  82. package/script/src/models/country/service.d.ts.map +0 -1
  83. package/script/src/models/country/service.js +0 -274
  84. package/script/src/models/currency/service.d.ts +0 -96
  85. package/script/src/models/currency/service.d.ts.map +0 -1
  86. package/script/src/models/currency/service.js +0 -201
package/README.md CHANGED
@@ -1,4 +1,3 @@
1
- ```markdown
2
1
  # @temboplus/frontend-core
3
2
 
4
3
  A robust and versatile JavaScript/TypeScript library designed to streamline the development of TemboPlus front-end applications. This library provides a comprehensive suite of utilities, standardized data models, and services to ensure consistency, efficiency, and maintainability across all TemboPlus projects.
@@ -18,7 +17,7 @@ This library offers a set of meticulously crafted data models, each designed to
18
17
  * **TZPhoneNumber:** Specialized phone number handling for Tanzania, including network operator identification.
19
18
  * **Amount:** Precise currency value management, with support for formatting and conversion.
20
19
  * **Currency:** Detailed currency information, including symbols, formatting rules, and validation.
21
- * **Country:** Standardized country data with ISO codes and comprehensive validation.
20
+ * **Country:** Enhanced country data handling with ISO-2 and ISO-3 codes, official names, flag emojis, and strongly-typed geographical categorization.
22
21
  * **Bank:** Consistent bank account information management.
23
22
 
24
23
  ## Report Management with `ReportManager`
@@ -70,7 +69,7 @@ import { ConfigService } from '@temboplus/frontend-core';
70
69
 
71
70
  // Initialize configuration at application startup
72
71
  ConfigService.instance.initialize({
73
- pdfMakerBaseUrl: 'https://api.temboplus.com/pdf-maker' // Optional: Override default PDF maker base URL.
72
+ pdfMakerBaseUrl: 'http://localhost:3000' // Optional: Override default PDF maker base URL.
74
73
  });
75
74
  ```
76
75
 
@@ -102,40 +101,81 @@ if (phoneNumber.validate()) {
102
101
  }
103
102
  ```
104
103
 
104
+ ## Type-Safe String Literals
105
+
106
+ This library provides strongly-typed string literals for standardized codes:
107
+
108
+ * **Country Codes:**
109
+ * `ISO2CountryCode`: Two-letter country codes (e.g., "US", "GB", "DE")
110
+ * `ISO3CountryCode`: Three-letter country codes (e.g., "USA", "GBR", "DEU")
111
+ * `CountryCode`: A union type that accepts either ISO-2 or ISO-3 formats
112
+
113
+ * **Currency Codes:**
114
+ * `CurrencyCode`: Three-letter currency codes (e.g., "USD", "EUR", "JPY")
115
+
116
+ These types provide compile-time validation and auto-completion while having zero runtime overhead:
117
+
118
+ ```typescript
119
+ import {
120
+ ISO2CountryCode,
121
+ ISO3CountryCode,
122
+ CountryCode,
123
+ CurrencyCode
124
+ } from '@temboplus/frontend-core';
125
+
126
+ // Type-safe function parameters
127
+ function processTransaction(
128
+ amount: number,
129
+ currency: CurrencyCode,
130
+ country: CountryCode
131
+ ) {
132
+ // Implementation
133
+ }
134
+
135
+ // Valid calls - compile-time checking ensures only valid codes are accepted
136
+ processTransaction(100, "USD", "US"); // ISO-2 country code
137
+ processTransaction(200, "EUR", "DEU"); // ISO-3 country code
138
+
139
+ // Invalid calls - caught by TypeScript at compile time
140
+ processTransaction(300, "XYZ", "US"); // Error: "XYZ" is not a valid CurrencyCode
141
+ processTransaction(400, "USD", "ZZZ"); // Error: "ZZZ" is not a valid CountryCode
142
+ ```
143
+
105
144
  ## Static Data Access
106
145
 
107
146
  Convenient static properties are available for accessing common data:
108
147
 
109
148
  ```typescript
110
- import { Country, Currency, Bank } from '@temboplus/frontend-core';
149
+ import { Country, Currency, Bank, CONTINENT, SUB_REGION } from '@temboplus/frontend-core';
111
150
 
112
- // Country access
151
+ // Country access with enhanced features
113
152
  const tanzania = Country.TZ;
114
- const usa = Country.UNITED_STATES;
153
+ console.log(tanzania.flagEmoji); // 🇹🇿
154
+ console.log(tanzania.continent); // CONTINENT.AFRICA
155
+ console.log(tanzania.region); // SUB_REGION.EASTERN_AFRICA
156
+
157
+ // Regional country grouping with type-safe enums
158
+ const africanCountries = Country.getByContinent(CONTINENT.AFRICA);
159
+ const caribbeanCountries = Country.getByRegion(SUB_REGION.CARIBBEAN);
115
160
 
116
161
  // Currency access
117
162
  const usd = Currency.USD;
118
163
  const tzs = Currency.TANZANIAN_SHILLING;
119
164
 
165
+ // Access country's currency
166
+ const japan = Country.JP;
167
+ const yen = japan.getCurrency();
168
+ console.log(yen?.code); // "JPY"
169
+
170
+ // Find countries using a specific currency
171
+ const euroCountries = Country.getByCurrencyCode("EUR");
172
+ console.log(`${euroCountries.length} countries use the Euro`);
173
+
120
174
  // Bank access
121
175
  const crdb = Bank.CRDB;
122
176
  const nmb = Bank.NMB;
123
177
  ```
124
178
 
125
- ## Detailed Model Documentation
126
-
127
- * [PhoneNumber](./docs/phone_number.md)
128
- * [Amount](./docs/amount.md)
129
- * [Bank](./docs/bank.md)
130
- * [Currency](./docs/currency.md)
131
- * [Country](./docs/country.md)
132
-
133
- ## Installation
134
-
135
- ```bash
136
- npm install @temboplus/frontend-core
137
- ```
138
-
139
179
  ## Phone Number Usage
140
180
 
141
181
  ```typescript
@@ -150,3 +190,17 @@ const tanzaniaPhone = TZPhoneNumber.from("0712345678");
150
190
  console.log(tanzaniaPhone.getWithFormat(PhoneNumberFormat.INTERNATIONAL)); // +255 712 345 678
151
191
  console.log(tanzaniaPhone.networkOperator.name); // "Yas"
152
192
  ```
193
+
194
+ ## Detailed Model Documentation
195
+
196
+ * [PhoneNumber](./docs/phone_number.md)
197
+ * [Amount](./docs/amount.md)
198
+ * [Bank](./docs/bank.md)
199
+ * [Currency](./docs/currency.md)
200
+ * [Country](./docs/country.md)
201
+
202
+ ## Installation
203
+
204
+ ```bash
205
+ npm install @temboplus/frontend-core
206
+ ```
@@ -1,6 +1,39 @@
1
1
  declare const _default: {
2
- name: string;
3
- code: string;
4
- }[];
2
+ dataset_name: string;
3
+ version: string;
4
+ description: string;
5
+ "source(s)": ({
6
+ name: string;
7
+ url: string;
8
+ } | {
9
+ name: string;
10
+ url: null;
11
+ })[];
12
+ last_updated: string;
13
+ creation_date: string;
14
+ license: string;
15
+ coverage: string;
16
+ contact_info: string;
17
+ notes: string;
18
+ countries: ({
19
+ name: string;
20
+ name_official: string;
21
+ iso_2: string;
22
+ iso_3: string;
23
+ flag_emoji: string;
24
+ continent: string;
25
+ region: string;
26
+ currency_iso_code: string;
27
+ } | {
28
+ name: string;
29
+ name_official: string;
30
+ iso_2: string;
31
+ iso_3: string;
32
+ flag_emoji: string;
33
+ continent: string;
34
+ region: string;
35
+ currency_iso_code: null;
36
+ })[];
37
+ };
5
38
  export default _default;
6
39
  //# sourceMappingURL=countries.d.ts.map