@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.
package/README.md CHANGED
@@ -1,142 +1,139 @@
1
1
  # @temboplus/frontend-core
2
2
 
3
- A foundational JavaScript/TypeScript library that powers TemboPlus front-end applications. This library provides essential tools and data models that ensure consistency across all TemboPlus projects.
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.
4
4
 
5
- ## What's Inside
5
+ ## Core Features
6
6
 
7
- The library contains:
7
+ * **Utility Functions:** A collection of pre-built helper functions to simplify common development tasks.
8
+ * **Standardized Data Models:** Consistent and reliable data structures for managing essential data types, including phone numbers, amounts, currencies, countries, and bank details.
9
+ * **Comprehensive Report Management:** A powerful `ReportManager` for generating and downloading reports in various formats across different TemboPlus projects.
10
+ * **Centralized Configuration Service:** A flexible `ConfigService` for managing application settings and environment configurations.
8
11
 
9
- * **Utilities**: Ready-to-use helper functions for common development tasks
10
- * **Data Models**: Standardized structures for handling data like phone numbers, amounts, currencies, countries, and bank details
11
- * **Report Management**: Tools for generating and downloading reports across different projects
12
- * **Configuration Service**: Centralized configuration management for application settings
12
+ ## Data Models
13
13
 
14
- ## Key Data Models
14
+ This library offers a set of meticulously crafted data models, each designed to handle specific data types with precision:
15
15
 
16
- - **PhoneNumber**: International phone number handling with country-specific validation
17
- - **TZPhoneNumber**: Tanzania-specific phone number handling with network operator identification
18
- - **Amount**: Currency value handling with formatting and conversion
19
- - **Currency**: Comprehensive currency information with symbols, formatting rules, and validation
20
- - **Country**: Standardized country data with ISO codes and validation
21
- - **Bank**: Standardized bank account information management
16
+ * **PhoneNumber:** Robust international phone number validation and formatting.
17
+ * **TZPhoneNumber:** Specialized phone number handling for Tanzania, including network operator identification.
18
+ * **Amount:** Precise currency value management, with support for formatting and conversion.
19
+ * **Currency:** Detailed currency information, including symbols, formatting rules, and validation.
20
+ * **Country:** Enhanced country data handling with ISO-2 and ISO-3 codes, official names, flag emojis, and strongly-typed geographical categorization.
21
+ * **Bank:** Consistent bank account information management.
22
22
 
23
- ## Report Management
23
+ ## Report Management with `ReportManager`
24
24
 
25
- The library includes a `ReportManager` for downloading reports in different formats across various TemboPlus projects:
25
+ The `ReportManager` simplifies the process of generating and downloading reports across various TemboPlus projects.
26
26
 
27
27
  ```typescript
28
- import {
29
- ReportManager,
30
- FileFormat,
31
- ReportType,
32
- ProjectType
33
- } from '@temboplus/frontend-core';
28
+ import { ReportManager, FileFormat, ReportType, ProjectType } from '@temboplus/frontend-core';
34
29
 
35
30
  // Download a report
36
- await ReportManager.instance.downloadReport({
37
- token: "your-auth-token",
38
- projectType: ProjectType.DASHBOARD,
39
- reportType: ReportType.MERCHANT_DISBURSEMENT_REPORT,
40
- fileFormat: FileFormat.PDF,
41
- query: {
42
- startDate: "2023-01-01T00:00:00.000Z",
43
- endDate: "2023-01-31T00:00:00.000Z"
44
- }
45
- });
31
+ async function downloadMerchantDisbursementReport() {
32
+ await ReportManager.instance.downloadReport({
33
+ token: "your-auth-token",
34
+ projectType: ProjectType.DASHBOARD,
35
+ reportType: ReportType.MERCHANT_DISBURSEMENT_REPORT,
36
+ fileFormat: FileFormat.PDF,
37
+ query: {
38
+ startDate: "2023-01-01T00:00:00.000Z",
39
+ endDate: "2023-01-31T00:00:00.000Z"
40
+ }
41
+ });
42
+ }
46
43
 
47
44
  // Get all reports for a specific project
48
45
  import { getReportsByProject } from '@temboplus/frontend-core';
49
- const dashboardReports = getReportsByProject(ProjectType.DASHBOARD);
46
+ function getAllDashboardReports(){
47
+ const dashboardReports = getReportsByProject(ProjectType.DASHBOARD);
48
+ return dashboardReports;
49
+ }
50
50
  ```
51
51
 
52
- ### Available Report Types
53
-
54
- The library supports the following report types:
52
+ ### Supported Report Types
55
53
 
56
- - **Dashboard Reports**:
57
- - `MERCHANT_DISBURSEMENT_REPORT`: Detailed breakdown of payments made to merchants
58
- - `TRANSACTION_REVENUE_SUMMARY`: Summary of all revenue transactions by period
59
-
60
- - **Afloat Reports**:
61
- - `CUSTOMER_WALLET_ACTIVITY`: Detailed record of all customer wallet transactions
62
- - `CUSTOMER_PROFILE_SNAPSHOT`: Current account information and status
63
-
64
- - **VertoX Reports**:
65
- - `GATEWAY_TRANSACTION_LOG`: Log of all payment gateway API transactions
54
+ * **Dashboard Reports:**
55
+ * `MERCHANT_DISBURSEMENT_REPORT`: Detailed merchant disbursement reports.
56
+ * `TRANSACTION_REVENUE_SUMMARY`: Revenue transaction summaries.
57
+ * **Afloat Reports:**
58
+ * `CUSTOMER_WALLET_ACTIVITY`: Customer wallet activity logs.
59
+ * `CUSTOMER_PROFILE_SNAPSHOT`: Customer profile snapshots.
60
+ * **VertoX Reports:**
61
+ * `GATEWAY_TRANSACTION_LOG`: Payment gateway transaction logs.
66
62
 
67
- ## Configuration Service
63
+ ## Configuration Service with `ConfigService`
68
64
 
69
- The library provides a centralized configuration service for managing application settings:
65
+ The `ConfigService` provides a centralized mechanism for managing application configurations.
70
66
 
71
67
  ```typescript
72
68
  import { ConfigService } from '@temboplus/frontend-core';
73
69
 
74
70
  // Initialize configuration at application startup
75
71
  ConfigService.instance.initialize({
76
- pdfMakerBaseUrl: 'https://api.temboplus.com/pdf-maker'
72
+ pdfMakerBaseUrl: 'http://localhost:3000' // Optional: Override default PDF maker base URL.
77
73
  });
78
-
79
- // Access configuration values throughout your application
80
- const baseUrl = ConfigService.instance.pdfMakerBaseUrl;
81
74
  ```
82
75
 
83
- ## Working with Data Models
76
+ ## Data Model Validation
84
77
 
85
- Each data model in our library comes with three key validation methods:
78
+ Each data model includes validation methods to ensure data integrity:
86
79
 
87
- ### 1. Checking Object Types with `is`
80
+ * **`is(object)`:** Checks if an object is a valid instance of the data model.
81
+ * **`canConstruct(input)`:** Validates input data before constructing a new instance.
82
+ * **`validate()`:** Verifies the validity of an existing data model instance.
88
83
 
89
84
  ```typescript
85
+ import { PhoneNumber, Amount } from '@temboplus/frontend-core';
86
+
87
+ // Using is()
90
88
  if (PhoneNumber.is(someObject)) {
91
- // someObject is a valid PhoneNumber
92
- console.log(phoneNumber.label);
89
+ console.log(someObject.label);
93
90
  }
94
- ```
95
-
96
- ### 2. Validating Input Data with `canConstruct`
97
91
 
98
- ```typescript
92
+ // Using canConstruct()
99
93
  if (Amount.canConstruct(userInput)) {
100
94
  const amount = Amount.from(userInput);
101
95
  }
102
- ```
103
96
 
104
- ### 3. Verifying Instance Data with `validate`
105
-
106
- ```typescript
97
+ // Using validate()
107
98
  const phoneNumber = PhoneNumber.from("+1234567890");
108
99
  if (phoneNumber.validate()) {
109
- processPhoneNumber(phoneNumber);
100
+ // Process the valid phone number.
110
101
  }
111
102
  ```
112
103
 
113
- ## Static Access to Common Data
104
+ ## Static Data Access
114
105
 
115
- Many of our models provide convenient static access to common data:
106
+ Convenient static properties are available for accessing common data:
116
107
 
117
108
  ```typescript
118
- // Access countries by ISO code or full name
109
+ import { Country, Currency, Bank, CONTINENT, SUB_REGION } from '@temboplus/frontend-core';
110
+
111
+ // Country access with enhanced features
119
112
  const tanzania = Country.TZ;
120
- const usa = Country.UNITED_STATES;
113
+ console.log(tanzania.flagEmoji); // 🇹🇿
114
+ console.log(tanzania.continent); // CONTINENT.AFRICA
115
+ console.log(tanzania.region); // SUB_REGION.EASTERN_AFRICA
116
+
117
+ // Regional country grouping with type-safe enums
118
+ const africanCountries = Country.getByContinent(CONTINENT.AFRICA);
119
+ const caribbeanCountries = Country.getByRegion(SUB_REGION.CARIBBEAN);
121
120
 
122
- // Access currencies by code or full name
121
+ // Currency access
123
122
  const usd = Currency.USD;
124
123
  const tzs = Currency.TANZANIAN_SHILLING;
125
124
 
126
- // Access banks by short name
125
+ // Bank access
127
126
  const crdb = Bank.CRDB;
128
127
  const nmb = Bank.NMB;
129
128
  ```
130
129
 
131
- ## Documentation
130
+ ## Detailed Model Documentation
132
131
 
133
- For detailed documentation on specific models:
134
-
135
- - [PhoneNumber Documentation](./docs/phone_number.md)
136
- - [Amount Documentation](./docs/amount.md)
137
- - [Bank Documentation](./docs/bank.md)
138
- - [Currency Documentation](./docs/currency.md)
139
- - [Country Documentation](./docs/country.md)
132
+ * [PhoneNumber](./docs/phone_number.md)
133
+ * [Amount](./docs/amount.md)
134
+ * [Bank](./docs/bank.md)
135
+ * [Currency](./docs/currency.md)
136
+ * [Country](./docs/country.md)
140
137
 
141
138
  ## Installation
142
139
 
@@ -144,19 +141,17 @@ For detailed documentation on specific models:
144
141
  npm install @temboplus/frontend-core
145
142
  ```
146
143
 
147
- ## Using Phone Numbers
148
-
149
- The library provides two phone number implementations:
144
+ ## Phone Number Usage
150
145
 
151
146
  ```typescript
152
147
  import { PhoneNumber, TZPhoneNumber, PhoneNumberFormat } from '@temboplus/frontend-core';
153
148
 
154
- // For international phone numbers:
155
- const phone = PhoneNumber.from("+1 (202) 555-0123");
156
- console.log(phone.getWithFormat(PhoneNumberFormat.INTERNATIONAL)); // +12025550123
149
+ // International phone numbers
150
+ const internationalPhone = PhoneNumber.from("+1 (202) 555-0123");
151
+ console.log(internationalPhone.getWithFormat(PhoneNumberFormat.INTERNATIONAL)); // +12025550123
157
152
 
158
- // For Tanzania phone numbers:
159
- const tzPhone = TZPhoneNumber.from("0712345678");
160
- console.log(tzPhone.getWithFormat(PhoneNumberFormat.INTERNATIONAL)); // +255 712 345 678
161
- console.log(tzPhone.networkOperator.name); // "Vodacom"
153
+ // Tanzania phone numbers
154
+ const tanzaniaPhone = TZPhoneNumber.from("0712345678");
155
+ console.log(tanzaniaPhone.getWithFormat(PhoneNumberFormat.INTERNATIONAL)); // +255 712 345 678
156
+ console.log(tanzaniaPhone.networkOperator.name); // "Yas"
162
157
  ```
@@ -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