@temboplus/frontend-core 0.2.3 → 0.2.5

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.
@@ -1,4 +1,4 @@
1
- import { Country } from "./country.js";
1
+ import { CONTINENT, Country, SUB_REGION } from "./country.js";
2
2
  /**
3
3
  * Service for managing country data.
4
4
  * @class CountryService
@@ -7,8 +7,10 @@ export declare class CountryService {
7
7
  private static instance;
8
8
  private countryList;
9
9
  private codeRecord;
10
+ private iso3Record;
10
11
  private nameRecord;
11
- private fullNameRecord;
12
+ private continentRecord;
13
+ private regionRecord;
12
14
  private staticReferences;
13
15
  private constructor();
14
16
  /**
@@ -18,37 +20,71 @@ export declare class CountryService {
18
20
  * @returns {CountryService} The singleton instance
19
21
  */
20
22
  static getInstance(): CountryService;
23
+ /**
24
+ * Maps a string continent name to the CONTINENT enum
25
+ * @param continentName String continent name from JSON
26
+ * @returns The corresponding CONTINENT enum value
27
+ */
28
+ private mapContinent;
29
+ /**
30
+ * Maps a string region name to the SUB_REGION enum
31
+ * @param regionName String region name from JSON
32
+ * @returns The corresponding SUB_REGION enum value
33
+ */
34
+ private mapRegion;
21
35
  /**
22
36
  * Initializes the service with country data.
23
37
  * Should be called once when your application starts.
24
38
  */
25
39
  private initialize;
40
+ /**
41
+ * Initialize the static properties on the Country class
42
+ */
43
+ private initializeCountryStatics;
26
44
  /**
27
45
  * Gets all countries.
28
46
  * @returns {Country[]} Array of all countries
29
47
  */
30
48
  getAll(): Country[];
49
+ /**
50
+ * Gets static country references to be used by the Country class.
51
+ * @returns {Map<string, Country>} Map of static references
52
+ */
53
+ getStaticReferences(): Map<string, Country>;
31
54
  /**
32
55
  * Gets all countries as a record.
33
56
  * @returns {Record<string, Country>} Record of country codes and country objects
34
57
  */
35
58
  getAllAsRecord(): Record<string, Country>;
36
59
  /**
37
- * Gets static country references to be used by the Country class.
38
- * @returns {Map<string, Country>} Map of static references
60
+ * Gets all countries from a specific continent.
61
+ * @param {CONTINENT} continent The continent enum value
62
+ * @returns {Country[]} Array of countries in the specified continent
39
63
  */
40
- getStaticReferences(): Map<string, Country>;
64
+ getByContinent(continent: CONTINENT): Country[];
65
+ /**
66
+ * Gets all countries from a specific region.
67
+ * @param {SUB_REGION} region The region enum value
68
+ * @returns {Country[]} Array of countries in the specified region
69
+ */
70
+ getByRegion(region: SUB_REGION): Country[];
41
71
  /**
42
72
  * Gets the full name record mapping.
43
73
  * @returns {Record<string, Country>} Record of uppercase full name keys to country objects
44
74
  */
45
75
  getFullNameRecord(): Record<string, Country>;
46
76
  /**
47
- * Retrieves a country by its ISO code.
48
- * @param {string} code The ISO code of the country.
77
+ * Retrieves a country by its ISO-2 code.
78
+ * @param {string} code The ISO-2 code of the country.
49
79
  * @returns {Country | undefined} The country corresponding to the ISO code or `undefined` if not found.
50
80
  */
51
81
  fromCode(code: string): Country | undefined;
82
+ /**
83
+ * Retrieves a country by its ISO-3 code.
84
+ * @param {string} iso3 The ISO-3 code of the country.
85
+ * @returns {Country | undefined} The country corresponding to the ISO-3 code or `undefined` if not found.
86
+ */
87
+ fromIso3(iso3: string): Country | undefined;
52
88
  /**
53
89
  * Retrieves a country by its name.
54
90
  * @param {string} countryName The name of the country.
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../src/src/models/country/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiB;IACxC,OAAO,CAAC,WAAW,CAAiB;IACpC,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,cAAc,CAA+B;IAGrD,OAAO,CAAC,gBAAgB,CAAmC;IAE3D,OAAO;IAEP;;;;;OAKG;IACH,MAAM,CAAC,WAAW,IAAI,cAAc;IAQpC;;;OAGG;IACH,OAAO,CA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OAAO,CAAC,UAAU;IAqIlB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAchC;;;OAGG;IACH,MAAM,IAAI,OAAO,EAAE;IAInB;;;OAGG;IACH,mBAAmB,IAAI,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAI3C;;;OAGG;IACH,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIzC;;;;OAIG;IACH,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,EAAE;IAI/C;;;;OAIG;IACH,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,EAAE;IAI1C;;;OAGG;IACH,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAI5C;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAI3C;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAI3C;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAgBlD;;;;;OAKG;IACH,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW,GAAG,OAAO,EAAE;IAgBzD;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO;CAMvD"}
@@ -1,4 +1,4 @@
1
- import { Country } from "./country.js";
1
+ import { CONTINENT, Country, SUB_REGION } from "./country.js";
2
2
  import file from "../../data/countries.js";
3
3
  /**
4
4
  * Service for managing country data.
@@ -18,13 +18,26 @@ export class CountryService {
18
18
  writable: true,
19
19
  value: {}
20
20
  });
21
+ Object.defineProperty(this, "iso3Record", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: {}
26
+ });
27
+ // private nameRecord: Record<string, Country> = {};
21
28
  Object.defineProperty(this, "nameRecord", {
22
29
  enumerable: true,
23
30
  configurable: true,
24
31
  writable: true,
25
32
  value: {}
26
33
  });
27
- Object.defineProperty(this, "fullNameRecord", {
34
+ Object.defineProperty(this, "continentRecord", {
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true,
38
+ value: {}
39
+ });
40
+ Object.defineProperty(this, "regionRecord", {
28
41
  enumerable: true,
29
42
  configurable: true,
30
43
  writable: true,
@@ -51,133 +64,198 @@ export class CountryService {
51
64
  }
52
65
  return CountryService.instance;
53
66
  }
67
+ /**
68
+ * Maps a string continent name to the CONTINENT enum
69
+ * @param continentName String continent name from JSON
70
+ * @returns The corresponding CONTINENT enum value
71
+ */
72
+ mapContinent(continentName) {
73
+ switch (continentName) {
74
+ case "Africa":
75
+ return CONTINENT.AFRICA;
76
+ case "Antarctica":
77
+ return CONTINENT.ANTARCTICA;
78
+ case "Asia":
79
+ return CONTINENT.ASIA;
80
+ case "Europe":
81
+ return CONTINENT.EUROPE;
82
+ case "North America":
83
+ return CONTINENT.NORTH_AMERICA;
84
+ case "Oceania":
85
+ return CONTINENT.OCEANIA;
86
+ case "South America":
87
+ return CONTINENT.SOUTH_AMERICA;
88
+ default:
89
+ return CONTINENT.EUROPE; // Default value
90
+ }
91
+ }
92
+ /**
93
+ * Maps a string region name to the SUB_REGION enum
94
+ * @param regionName String region name from JSON
95
+ * @returns The corresponding SUB_REGION enum value
96
+ */
97
+ mapRegion(regionName) {
98
+ switch (regionName) {
99
+ case "Australia and New Zealand":
100
+ return SUB_REGION.AUSTRALIA_AND_NEW_ZEALAND;
101
+ case "Caribbean":
102
+ return SUB_REGION.CARIBBEAN;
103
+ case "Central America":
104
+ return SUB_REGION.CENTRAL_AMERICA;
105
+ case "Central Asia":
106
+ return SUB_REGION.CENTRAL_ASIA;
107
+ case "Eastern Africa":
108
+ return SUB_REGION.EASTERN_AFRICA;
109
+ case "Eastern Asia":
110
+ return SUB_REGION.EASTERN_ASIA;
111
+ case "Eastern Europe":
112
+ return SUB_REGION.EASTERN_EUROPE;
113
+ case "Melanesia":
114
+ return SUB_REGION.MELANESIA;
115
+ case "Micronesia":
116
+ return SUB_REGION.MICRONESIA;
117
+ case "Middle Africa":
118
+ return SUB_REGION.MIDDLE_AFRICA;
119
+ case "Northern Africa":
120
+ return SUB_REGION.NORTHERN_AFRICA;
121
+ case "Northern America":
122
+ return SUB_REGION.NORTHERN_AMERICA;
123
+ case "Northern Europe":
124
+ return SUB_REGION.NORTHERN_EUROPE;
125
+ case "Polynesia":
126
+ return SUB_REGION.POLYNESIA;
127
+ case "South-eastern Asia":
128
+ return SUB_REGION.SOUTH_EASTERN_ASIA;
129
+ case "Southern Africa":
130
+ return SUB_REGION.SOUTHERN_AFRICA;
131
+ case "Southern Asia":
132
+ return SUB_REGION.SOUTHERN_ASIA;
133
+ case "Southern Europe":
134
+ return SUB_REGION.SOUTHERN_EUROPE;
135
+ case "Western Africa":
136
+ return SUB_REGION.WESTERN_AFRICA;
137
+ case "Western Asia":
138
+ return SUB_REGION.WESTERN_ASIA;
139
+ case "Western Europe":
140
+ return SUB_REGION.WESTERN_EUROPE;
141
+ default:
142
+ return SUB_REGION.NORTHERN_EUROPE; // Default value
143
+ }
144
+ }
54
145
  /**
55
146
  * Initializes the service with country data.
56
147
  * Should be called once when your application starts.
57
148
  */
58
149
  initialize() {
59
150
  try {
151
+ // Parse the JSON data
60
152
  const data = JSON.parse(JSON.stringify(file));
61
- const countries = Object.values(data).map((c) => new Country(c.name, c.code));
153
+ // deno-lint-ignore no-explicit-any
154
+ const countriesData = data.countries || [];
155
+ // Initialize continent and region records
156
+ Object.values(CONTINENT).forEach((continent) => {
157
+ this.continentRecord[continent] = [];
158
+ });
159
+ Object.values(SUB_REGION).forEach((region) => {
160
+ this.regionRecord[region] = [];
161
+ });
162
+ // Create Country instances from the data
163
+ const countries = countriesData.map((c) => {
164
+ const continent = this.mapContinent(c.continent);
165
+ const region = this.mapRegion(c.region);
166
+ return new Country(c.name, c.iso_2, c.name_official, c.iso_3, c.flag_emoji, continent, region);
167
+ });
62
168
  const code_record = {};
169
+ const iso3_record = {};
170
+ // const name_record: Record<string, Country> = {};
63
171
  const name_record = {};
64
- const fullname_record = {};
65
172
  countries.forEach((country) => {
66
- // Populate code record
173
+ // Populate code records
67
174
  code_record[country.code] = country;
175
+ iso3_record[country.iso3] = country;
68
176
  // Add to record by name
69
- name_record[country.name.toUpperCase()] = country;
177
+ // name_record[country.name.toUpperCase()] = country;
70
178
  // Generate uppercase full name with underscores
71
- const fullNameKey = country.name
179
+ const nameKey = country.name
72
180
  .toUpperCase()
73
181
  .replace(/\s+/g, "_")
74
182
  .replace(/[-(),.']/g, "")
75
183
  .replace(/&/g, "AND");
76
- fullname_record[fullNameKey] = country;
77
- // Save references for static access
78
- this.staticReferences.set(country.code.toUpperCase(), country);
79
- this.staticReferences.set(fullNameKey, country);
184
+ name_record[nameKey] = country;
185
+ // Group countries by continent
186
+ this.continentRecord[country.continent].push(country);
187
+ // Group countries by region
188
+ this.regionRecord[country.region].push(country);
189
+ this.staticReferences.set(country.code, country);
190
+ this.staticReferences.set(nameKey, country);
80
191
  });
81
- // Ensure specific mappings are available
82
- if (code_record["US"]) {
83
- fullname_record["UNITED_STATES"] = code_record["US"];
84
- this.staticReferences.set("UNITED_STATES", code_record["US"]);
85
- }
86
- // Add specific country mappings
192
+ // Add specific country mappings for special cases
87
193
  // Cocos Islands
88
194
  if (code_record["CC"]) {
89
- fullname_record["COCOS_ISLANDS"] = code_record["CC"];
195
+ name_record["COCOS_ISLANDS"] = code_record["CC"];
90
196
  this.staticReferences.set("COCOS_ISLANDS", code_record["CC"]);
91
197
  }
92
- // Democratic Republic of Congo
93
- if (code_record["CD"]) {
94
- fullname_record["DEMOCRATIC_REPUBLIC_OF_CONGO"] = code_record["CD"];
95
- this.staticReferences.set("DEMOCRATIC_REPUBLIC_OF_CONGO", code_record["CD"]);
96
- }
97
198
  // Cote d'Ivoire
98
199
  if (code_record["CI"]) {
99
- fullname_record["COTE_DIVOIRE"] = code_record["CI"];
200
+ name_record["COTE_DIVOIRE"] = code_record["CI"];
100
201
  this.staticReferences.set("COTE_DIVOIRE", code_record["CI"]);
101
202
  }
102
- // Falkland Islands
103
- if (code_record["FK"]) {
104
- fullname_record["FALKLAND_ISLANDS"] = code_record["FK"];
105
- this.staticReferences.set("FALKLAND_ISLANDS", code_record["FK"]);
106
- }
107
- // Holy See (Vatican)
108
- if (code_record["VA"]) {
109
- fullname_record["HOLY_SEE"] = code_record["VA"];
110
- this.staticReferences.set("HOLY_SEE", code_record["VA"]);
111
- }
112
- // Iran
113
- if (code_record["IR"]) {
114
- fullname_record["IRAN"] = code_record["IR"];
115
- this.staticReferences.set("IRAN", code_record["IR"]);
116
- }
117
- // North Korea
118
- if (code_record["KP"]) {
119
- fullname_record["NORTH_KOREA"] = code_record["KP"];
120
- this.staticReferences.set("NORTH_KOREA", code_record["KP"]);
121
- }
122
- // South Korea
123
- if (code_record["KR"]) {
124
- fullname_record["SOUTH_KOREA"] = code_record["KR"];
125
- this.staticReferences.set("SOUTH_KOREA", code_record["KR"]);
126
- }
127
- // Lao People's Democratic Republic
128
- if (code_record["LA"]) {
129
- fullname_record["LAO"] = code_record["LA"];
130
- this.staticReferences.set("LAO", code_record["LA"]);
131
- }
132
- // Palestine
133
- if (code_record["PS"]) {
134
- fullname_record["PALESTINE"] = code_record["PS"];
135
- this.staticReferences.set("PALESTINE", code_record["PS"]);
136
- }
137
- // Macedonia
203
+ // Macedonia (North Macedonia)
138
204
  if (code_record["MK"]) {
139
- fullname_record["MACEDONIA"] = code_record["MK"];
205
+ name_record["MACEDONIA"] = code_record["MK"];
140
206
  this.staticReferences.set("MACEDONIA", code_record["MK"]);
141
207
  }
142
- // Micronesia
143
- if (code_record["FM"]) {
144
- fullname_record["MICRONESIA"] = code_record["FM"];
145
- this.staticReferences.set("MICRONESIA", code_record["FM"]);
146
- }
147
- // Moldova
148
- if (code_record["MD"]) {
149
- fullname_record["MOLDOVA"] = code_record["MD"];
150
- this.staticReferences.set("MOLDOVA", code_record["MD"]);
151
- }
152
- // Taiwan
153
- if (code_record["TW"]) {
154
- fullname_record["TAIWAN"] = code_record["TW"];
155
- this.staticReferences.set("TAIWAN", code_record["TW"]);
156
- }
157
- // Tanzania
158
- if (code_record["TZ"]) {
159
- fullname_record["TANZANIA"] = code_record["TZ"];
160
- this.staticReferences.set("TANZANIA", code_record["TZ"]);
161
- }
162
208
  // US Virgin Islands
163
209
  if (code_record["VI"]) {
164
- fullname_record["VIRGIN_ISLANDS_US"] = code_record["VI"];
210
+ name_record["VIRGIN_ISLANDS_US"] = code_record["VI"];
165
211
  this.staticReferences.set("VIRGIN_ISLANDS_US", code_record["VI"]);
166
212
  }
167
213
  // British Virgin Islands
168
214
  if (code_record["VG"]) {
169
- fullname_record["VIRGIN_ISLANDS_BRITISH"] = code_record["VG"];
215
+ name_record["VIRGIN_ISLANDS_BRITISH"] = code_record["VG"];
170
216
  this.staticReferences.set("VIRGIN_ISLANDS_BRITISH", code_record["VG"]);
171
217
  }
218
+ // Democratic Republic of the Congo
219
+ if (code_record["CD"]) {
220
+ name_record["DEMOCRATIC_REPUBLIC_OF_CONGO"] = code_record["CD"];
221
+ this.staticReferences.set("DEMOCRATIC_REPUBLIC_OF_CONGO", code_record["CD"]);
222
+ }
223
+ // Falkland Islands (Malvinas)
224
+ if (code_record["FK"]) {
225
+ name_record["FALKLAND_ISLANDS"] = code_record["FK"];
226
+ this.staticReferences.set("FALKLAND_ISLANDS", code_record["FK"]);
227
+ }
228
+ // Lao
229
+ if (code_record["LA"]) {
230
+ name_record["LAO"] = code_record["LA"];
231
+ this.staticReferences.set("LAO", code_record["LA"]);
232
+ }
172
233
  this.codeRecord = code_record;
234
+ this.iso3Record = iso3_record;
173
235
  this.nameRecord = name_record;
174
- this.fullNameRecord = fullname_record;
175
236
  this.countryList = countries;
237
+ // Initialize static properties on Country class
238
+ this.initializeCountryStatics();
176
239
  }
177
240
  catch (error) {
178
241
  console.error("Failed to initialize CountryService:", error);
179
242
  }
180
243
  }
244
+ /**
245
+ * Initialize the static properties on the Country class
246
+ */
247
+ initializeCountryStatics() {
248
+ // Initialize ISO-2 code properties
249
+ Object.entries(this.codeRecord).forEach(([code, country]) => {
250
+ // deno-lint-ignore no-explicit-any
251
+ Country[code.toUpperCase()] = country;
252
+ });
253
+ // Initialize full name properties
254
+ Object.entries(this.nameRecord).forEach(([fullName, country]) => {
255
+ // deno-lint-ignore no-explicit-any
256
+ Country[fullName] = country;
257
+ });
258
+ }
181
259
  /**
182
260
  * Gets all countries.
183
261
  * @returns {Country[]} Array of all countries
@@ -185,6 +263,13 @@ export class CountryService {
185
263
  getAll() {
186
264
  return this.countryList;
187
265
  }
266
+ /**
267
+ * Gets static country references to be used by the Country class.
268
+ * @returns {Map<string, Country>} Map of static references
269
+ */
270
+ getStaticReferences() {
271
+ return this.staticReferences;
272
+ }
188
273
  /**
189
274
  * Gets all countries as a record.
190
275
  * @returns {Record<string, Country>} Record of country codes and country objects
@@ -193,44 +278,56 @@ export class CountryService {
193
278
  return this.codeRecord;
194
279
  }
195
280
  /**
196
- * Gets static country references to be used by the Country class.
197
- * @returns {Map<string, Country>} Map of static references
281
+ * Gets all countries from a specific continent.
282
+ * @param {CONTINENT} continent The continent enum value
283
+ * @returns {Country[]} Array of countries in the specified continent
198
284
  */
199
- getStaticReferences() {
200
- return this.staticReferences;
285
+ getByContinent(continent) {
286
+ return this.continentRecord[continent] || [];
287
+ }
288
+ /**
289
+ * Gets all countries from a specific region.
290
+ * @param {SUB_REGION} region The region enum value
291
+ * @returns {Country[]} Array of countries in the specified region
292
+ */
293
+ getByRegion(region) {
294
+ return this.regionRecord[region] || [];
201
295
  }
202
296
  /**
203
297
  * Gets the full name record mapping.
204
298
  * @returns {Record<string, Country>} Record of uppercase full name keys to country objects
205
299
  */
206
300
  getFullNameRecord() {
207
- return this.fullNameRecord;
301
+ return this.nameRecord;
208
302
  }
209
303
  /**
210
- * Retrieves a country by its ISO code.
211
- * @param {string} code The ISO code of the country.
304
+ * Retrieves a country by its ISO-2 code.
305
+ * @param {string} code The ISO-2 code of the country.
212
306
  * @returns {Country | undefined} The country corresponding to the ISO code or `undefined` if not found.
213
307
  */
214
308
  fromCode(code) {
215
309
  return this.codeRecord[code.toUpperCase()];
216
310
  }
311
+ /**
312
+ * Retrieves a country by its ISO-3 code.
313
+ * @param {string} iso3 The ISO-3 code of the country.
314
+ * @returns {Country | undefined} The country corresponding to the ISO-3 code or `undefined` if not found.
315
+ */
316
+ fromIso3(iso3) {
317
+ return this.iso3Record[iso3.toUpperCase()];
318
+ }
217
319
  /**
218
320
  * Retrieves a country by its name.
219
321
  * @param {string} countryName The name of the country.
220
322
  * @returns {Country | undefined} The country corresponding to the name or `undefined` if not found.
221
323
  */
222
324
  fromName(countryName) {
223
- // First try direct lookup in name record
224
- const directMatch = this.nameRecord[countryName.toUpperCase()];
225
- if (directMatch)
226
- return directMatch;
227
- // Then try full name record
228
325
  const fullNameKey = countryName
229
326
  .toUpperCase()
230
327
  .replace(/\s+/g, "_")
231
328
  .replace(/[-(),.']/g, "")
232
329
  .replace(/&/g, "AND");
233
- const fullNameMatch = this.fullNameRecord[fullNameKey];
330
+ const fullNameMatch = this.nameRecord[fullNameKey];
234
331
  if (fullNameMatch)
235
332
  return fullNameMatch;
236
333
  // If not found, try more lenient matching
@@ -249,7 +346,9 @@ export class CountryService {
249
346
  if (term.length === 0)
250
347
  return [];
251
348
  const results = this.countryList.filter((country) => country.name.toLowerCase().includes(term) ||
252
- country.code.toLowerCase().includes(term));
349
+ country.nameOfficial.toLowerCase().includes(term) ||
350
+ country.code.toLowerCase().includes(term) ||
351
+ country.iso3.toLowerCase().includes(term));
253
352
  return results.slice(0, limit);
254
353
  }
255
354
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"network_operator.d.ts","sourceRoot":"","sources":["../../../../../src/src/models/phone_number/tz/network_operator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,eAAe;IACzB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,iDAAiD;IACjD,EAAE,EAAE,eAAe,CAAC;IAEpB,+DAA+D;IAC/D,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAE/B,2CAA2C;IAC3C,WAAW,EAAE,MAAM,CAAC;IAEpB,wDAAwD;IACxD,kBAAkB,EAAE,MAAM,CAAC;IAE3B,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAC1C,eAAe,EACf,mBAAmB,CA8BpB,CAAC"}
1
+ {"version":3,"file":"network_operator.d.ts","sourceRoot":"","sources":["../../../../../src/src/models/phone_number/tz/network_operator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,eAAe;IACzB,OAAO,YAAY;IACnB,MAAM,WAAW;IAIjB,IAAI,SAAS;IACb,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,iDAAiD;IACjD,EAAE,EAAE,eAAe,CAAC;IAEpB,+DAA+D;IAC/D,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAE/B,2CAA2C;IAC3C,WAAW,EAAE,MAAM,CAAC;IAEpB,wDAAwD;IACxD,kBAAkB,EAAE,MAAM,CAAC;IAE3B,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAC1C,eAAe,EACf,mBAAmB,CA8BpB,CAAC"}
@@ -6,6 +6,9 @@ export var NetworkOperator;
6
6
  (function (NetworkOperator) {
7
7
  NetworkOperator["VODACOM"] = "Vodacom";
8
8
  NetworkOperator["AIRTEL"] = "Airtel";
9
+ // Preserve the value "Tigo" bse our backend still recognizes it for payout channel codes
10
+ // It should not be seen anywhere for we have NetworkOperatorInfo.displayName & NetworkOperatorInfo.mobileMoneyService
11
+ // as labels we can use on the frontend
9
12
  NetworkOperator["TIGO"] = "Tigo";
10
13
  NetworkOperator["HALOTEL"] = "Halotel";
11
14
  })(NetworkOperator || (NetworkOperator = {}));
@@ -31,8 +34,8 @@ export const NETWORK_OPERATOR_CONFIG = {
31
34
  id: NetworkOperator.TIGO,
32
35
  mobileNumberPrefixes: ["71", "65", "67", "77"],
33
36
  displayName: "Yas",
34
- mobileMoneyService: "Mixx",
35
- brandColor: "blue",
37
+ mobileMoneyService: "Mixx by Yas",
38
+ brandColor: "yellow",
36
39
  },
37
40
  [NetworkOperator.HALOTEL]: {
38
41
  id: NetworkOperator.HALOTEL,
@@ -1 +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"}
1
+ {"version":3,"file":"report_manager.d.ts","sourceRoot":"","sources":["../../../src/src/reports/report_manager.ts"],"names":[],"mappings":"A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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,CAOhB;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"}
@@ -131,7 +131,10 @@ export class ReportManager {
131
131
  configurable: true,
132
132
  writable: true,
133
133
  value: () => {
134
- const url = ConfigService.instance.pdfMakerBaseUrl;
134
+ let url = ConfigService.instance.pdfMakerBaseUrl;
135
+ if (url.trim().length === 0) {
136
+ url = "https://api.afloat.money/pdf-maker";
137
+ }
135
138
  if (url.endsWith("/"))
136
139
  return url.slice(0, -1);
137
140
  return url;
@@ -181,7 +184,7 @@ export class ReportManager {
181
184
  // deno-lint-ignore no-explicit-any
182
185
  const queryParams = {
183
186
  ...(args.query || {}),
184
- format: args.fileFormat,
187
+ fileFormat: args.fileFormat,
185
188
  };
186
189
  // Build the query string
187
190
  const searchParams = new URLSearchParams();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temboplus/frontend-core",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "A JavaScript/TypeScript package providing common utilities and logic shared across front-end TemboPlus projects.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,6 +1,29 @@
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
+ }[];
27
+ };
5
28
  export default _default;
6
29
  //# sourceMappingURL=countries.d.ts.map