@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 +85 -90
- package/esm/src/data/countries.d.ts +26 -3
- package/esm/src/data/countries.js +2227 -974
- package/esm/src/models/country/country.d.ts +134 -18
- package/esm/src/models/country/country.d.ts.map +1 -1
- package/esm/src/models/country/country.js +184 -12
- package/esm/src/models/country/service.d.ts +43 -7
- package/esm/src/models/country/service.d.ts.map +1 -1
- package/esm/src/models/country/service.js +197 -98
- package/esm/src/models/phone_number/tz/network_operator.d.ts.map +1 -1
- package/esm/src/models/phone_number/tz/network_operator.js +5 -2
- package/esm/src/reports/report_manager.d.ts.map +1 -1
- package/esm/src/reports/report_manager.js +5 -2
- package/package.json +1 -1
- package/script/src/data/countries.d.ts +26 -3
- package/script/src/data/countries.js +2227 -974
- package/script/src/models/country/country.d.ts +134 -18
- package/script/src/models/country/country.d.ts.map +1 -1
- package/script/src/models/country/country.js +185 -13
- package/script/src/models/country/service.d.ts +43 -7
- package/script/src/models/country/service.d.ts.map +1 -1
- package/script/src/models/country/service.js +196 -97
- package/script/src/models/phone_number/tz/network_operator.d.ts.map +1 -1
- package/script/src/models/phone_number/tz/network_operator.js +5 -2
- package/script/src/reports/report_manager.d.ts.map +1 -1
- package/script/src/reports/report_manager.js +5 -2
package/README.md
CHANGED
|
@@ -1,142 +1,139 @@
|
|
|
1
1
|
# @temboplus/frontend-core
|
|
2
2
|
|
|
3
|
-
A
|
|
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
|
-
##
|
|
5
|
+
## Core Features
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
|
|
14
|
+
This library offers a set of meticulously crafted data models, each designed to handle specific data types with precision:
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
46
|
+
function getAllDashboardReports(){
|
|
47
|
+
const dashboardReports = getReportsByProject(ProjectType.DASHBOARD);
|
|
48
|
+
return dashboardReports;
|
|
49
|
+
}
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
###
|
|
53
|
-
|
|
54
|
-
The library supports the following report types:
|
|
52
|
+
### Supported Report Types
|
|
55
53
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
##
|
|
76
|
+
## Data Model Validation
|
|
84
77
|
|
|
85
|
-
Each data model
|
|
78
|
+
Each data model includes validation methods to ensure data integrity:
|
|
86
79
|
|
|
87
|
-
|
|
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
|
-
|
|
92
|
-
console.log(phoneNumber.label);
|
|
89
|
+
console.log(someObject.label);
|
|
93
90
|
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### 2. Validating Input Data with `canConstruct`
|
|
97
91
|
|
|
98
|
-
|
|
92
|
+
// Using canConstruct()
|
|
99
93
|
if (Amount.canConstruct(userInput)) {
|
|
100
94
|
const amount = Amount.from(userInput);
|
|
101
95
|
}
|
|
102
|
-
```
|
|
103
96
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
```typescript
|
|
97
|
+
// Using validate()
|
|
107
98
|
const phoneNumber = PhoneNumber.from("+1234567890");
|
|
108
99
|
if (phoneNumber.validate()) {
|
|
109
|
-
|
|
100
|
+
// Process the valid phone number.
|
|
110
101
|
}
|
|
111
102
|
```
|
|
112
103
|
|
|
113
|
-
## Static Access
|
|
104
|
+
## Static Data Access
|
|
114
105
|
|
|
115
|
-
|
|
106
|
+
Convenient static properties are available for accessing common data:
|
|
116
107
|
|
|
117
108
|
```typescript
|
|
118
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
121
|
+
// Currency access
|
|
123
122
|
const usd = Currency.USD;
|
|
124
123
|
const tzs = Currency.TANZANIAN_SHILLING;
|
|
125
124
|
|
|
126
|
-
//
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
##
|
|
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
|
-
//
|
|
155
|
-
const
|
|
156
|
-
console.log(
|
|
149
|
+
// International phone numbers
|
|
150
|
+
const internationalPhone = PhoneNumber.from("+1 (202) 555-0123");
|
|
151
|
+
console.log(internationalPhone.getWithFormat(PhoneNumberFormat.INTERNATIONAL)); // +12025550123
|
|
157
152
|
|
|
158
|
-
//
|
|
159
|
-
const
|
|
160
|
-
console.log(
|
|
161
|
-
console.log(
|
|
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
|
-
|
|
3
|
-
|
|
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
|