@temboplus/frontend-core 0.2.2 → 0.2.4
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 +101 -49
- package/esm/mod.d.ts +2 -0
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +2 -0
- package/esm/src/config/config_service.d.ts +11 -0
- package/esm/src/config/config_service.d.ts.map +1 -0
- package/esm/src/config/config_service.js +19 -0
- package/esm/src/config/index.d.ts +2 -0
- package/esm/src/config/index.d.ts.map +1 -0
- package/esm/src/config/index.js +1 -0
- 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/index.d.ts +2 -0
- package/esm/src/reports/index.d.ts.map +1 -0
- package/esm/src/reports/index.js +1 -0
- package/esm/src/reports/report_manager.d.ts +144 -0
- package/esm/src/reports/report_manager.d.ts.map +1 -0
- package/esm/src/reports/report_manager.js +318 -0
- package/package.json +2 -1
- package/script/mod.d.ts +2 -0
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +2 -0
- package/script/src/config/config_service.d.ts +11 -0
- package/script/src/config/config_service.d.ts.map +1 -0
- package/script/src/config/config_service.js +23 -0
- package/script/src/config/index.d.ts +2 -0
- package/script/src/config/index.d.ts.map +1 -0
- package/script/src/config/index.js +17 -0
- 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/index.d.ts +2 -0
- package/script/src/reports/index.d.ts.map +1 -0
- package/script/src/reports/index.js +17 -0
- package/script/src/reports/report_manager.d.ts +144 -0
- package/script/src/reports/report_manager.d.ts.map +1 -0
- package/script/src/reports/report_manager.js +328 -0
package/README.md
CHANGED
|
@@ -1,80 +1,134 @@
|
|
|
1
|
+
```markdown
|
|
1
2
|
# @temboplus/frontend-core
|
|
2
3
|
|
|
3
|
-
A
|
|
4
|
+
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
5
|
|
|
5
|
-
##
|
|
6
|
+
## Core Features
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
* **Utility Functions:** A collection of pre-built helper functions to simplify common development tasks.
|
|
9
|
+
* **Standardized Data Models:** Consistent and reliable data structures for managing essential data types, including phone numbers, amounts, currencies, countries, and bank details.
|
|
10
|
+
* **Comprehensive Report Management:** A powerful `ReportManager` for generating and downloading reports in various formats across different TemboPlus projects.
|
|
11
|
+
* **Centralized Configuration Service:** A flexible `ConfigService` for managing application settings and environment configurations.
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
* **Data Models**: Standardized structures for handling data like phone numbers, amounts, currencies, countries, and bank details
|
|
13
|
+
## Data Models
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
This library offers a set of meticulously crafted data models, each designed to handle specific data types with precision:
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
* **PhoneNumber:** Robust international phone number validation and formatting.
|
|
18
|
+
* **TZPhoneNumber:** Specialized phone number handling for Tanzania, including network operator identification.
|
|
19
|
+
* **Amount:** Precise currency value management, with support for formatting and conversion.
|
|
20
|
+
* **Currency:** Detailed currency information, including symbols, formatting rules, and validation.
|
|
21
|
+
* **Country:** Standardized country data with ISO codes and comprehensive validation.
|
|
22
|
+
* **Bank:** Consistent bank account information management.
|
|
20
23
|
|
|
21
|
-
##
|
|
24
|
+
## Report Management with `ReportManager`
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
### 1. Checking Object Types with `is`
|
|
26
|
+
The `ReportManager` simplifies the process of generating and downloading reports across various TemboPlus projects.
|
|
26
27
|
|
|
27
28
|
```typescript
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
import { ReportManager, FileFormat, ReportType, ProjectType } from '@temboplus/frontend-core';
|
|
30
|
+
|
|
31
|
+
// Download a report
|
|
32
|
+
async function downloadMerchantDisbursementReport() {
|
|
33
|
+
await ReportManager.instance.downloadReport({
|
|
34
|
+
token: "your-auth-token",
|
|
35
|
+
projectType: ProjectType.DASHBOARD,
|
|
36
|
+
reportType: ReportType.MERCHANT_DISBURSEMENT_REPORT,
|
|
37
|
+
fileFormat: FileFormat.PDF,
|
|
38
|
+
query: {
|
|
39
|
+
startDate: "2023-01-01T00:00:00.000Z",
|
|
40
|
+
endDate: "2023-01-31T00:00:00.000Z"
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Get all reports for a specific project
|
|
46
|
+
import { getReportsByProject } from '@temboplus/frontend-core';
|
|
47
|
+
function getAllDashboardReports(){
|
|
48
|
+
const dashboardReports = getReportsByProject(ProjectType.DASHBOARD);
|
|
49
|
+
return dashboardReports;
|
|
31
50
|
}
|
|
32
51
|
```
|
|
33
52
|
|
|
34
|
-
###
|
|
53
|
+
### Supported Report Types
|
|
54
|
+
|
|
55
|
+
* **Dashboard Reports:**
|
|
56
|
+
* `MERCHANT_DISBURSEMENT_REPORT`: Detailed merchant disbursement reports.
|
|
57
|
+
* `TRANSACTION_REVENUE_SUMMARY`: Revenue transaction summaries.
|
|
58
|
+
* **Afloat Reports:**
|
|
59
|
+
* `CUSTOMER_WALLET_ACTIVITY`: Customer wallet activity logs.
|
|
60
|
+
* `CUSTOMER_PROFILE_SNAPSHOT`: Customer profile snapshots.
|
|
61
|
+
* **VertoX Reports:**
|
|
62
|
+
* `GATEWAY_TRANSACTION_LOG`: Payment gateway transaction logs.
|
|
63
|
+
|
|
64
|
+
## Configuration Service with `ConfigService`
|
|
65
|
+
|
|
66
|
+
The `ConfigService` provides a centralized mechanism for managing application configurations.
|
|
35
67
|
|
|
36
68
|
```typescript
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
69
|
+
import { ConfigService } from '@temboplus/frontend-core';
|
|
70
|
+
|
|
71
|
+
// Initialize configuration at application startup
|
|
72
|
+
ConfigService.instance.initialize({
|
|
73
|
+
pdfMakerBaseUrl: 'https://api.temboplus.com/pdf-maker' // Optional: Override default PDF maker base URL.
|
|
74
|
+
});
|
|
40
75
|
```
|
|
41
76
|
|
|
42
|
-
|
|
77
|
+
## Data Model Validation
|
|
78
|
+
|
|
79
|
+
Each data model includes validation methods to ensure data integrity:
|
|
80
|
+
|
|
81
|
+
* **`is(object)`:** Checks if an object is a valid instance of the data model.
|
|
82
|
+
* **`canConstruct(input)`:** Validates input data before constructing a new instance.
|
|
83
|
+
* **`validate()`:** Verifies the validity of an existing data model instance.
|
|
43
84
|
|
|
44
85
|
```typescript
|
|
86
|
+
import { PhoneNumber, Amount } from '@temboplus/frontend-core';
|
|
87
|
+
|
|
88
|
+
// Using is()
|
|
89
|
+
if (PhoneNumber.is(someObject)) {
|
|
90
|
+
console.log(someObject.label);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Using canConstruct()
|
|
94
|
+
if (Amount.canConstruct(userInput)) {
|
|
95
|
+
const amount = Amount.from(userInput);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Using validate()
|
|
45
99
|
const phoneNumber = PhoneNumber.from("+1234567890");
|
|
46
100
|
if (phoneNumber.validate()) {
|
|
47
|
-
|
|
101
|
+
// Process the valid phone number.
|
|
48
102
|
}
|
|
49
103
|
```
|
|
50
104
|
|
|
51
|
-
## Static Access
|
|
105
|
+
## Static Data Access
|
|
52
106
|
|
|
53
|
-
|
|
107
|
+
Convenient static properties are available for accessing common data:
|
|
54
108
|
|
|
55
109
|
```typescript
|
|
56
|
-
|
|
110
|
+
import { Country, Currency, Bank } from '@temboplus/frontend-core';
|
|
111
|
+
|
|
112
|
+
// Country access
|
|
57
113
|
const tanzania = Country.TZ;
|
|
58
114
|
const usa = Country.UNITED_STATES;
|
|
59
115
|
|
|
60
|
-
//
|
|
116
|
+
// Currency access
|
|
61
117
|
const usd = Currency.USD;
|
|
62
118
|
const tzs = Currency.TANZANIAN_SHILLING;
|
|
63
119
|
|
|
64
|
-
//
|
|
120
|
+
// Bank access
|
|
65
121
|
const crdb = Bank.CRDB;
|
|
66
122
|
const nmb = Bank.NMB;
|
|
67
123
|
```
|
|
68
124
|
|
|
69
|
-
## Documentation
|
|
125
|
+
## Detailed Model Documentation
|
|
70
126
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
- [Currency Documentation](./docs/currency.md)
|
|
77
|
-
- [Country Documentation](./docs/country.md)
|
|
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)
|
|
78
132
|
|
|
79
133
|
## Installation
|
|
80
134
|
|
|
@@ -82,19 +136,17 @@ For detailed documentation on specific models:
|
|
|
82
136
|
npm install @temboplus/frontend-core
|
|
83
137
|
```
|
|
84
138
|
|
|
85
|
-
##
|
|
86
|
-
|
|
87
|
-
The library provides two phone number implementations:
|
|
139
|
+
## Phone Number Usage
|
|
88
140
|
|
|
89
141
|
```typescript
|
|
90
142
|
import { PhoneNumber, TZPhoneNumber, PhoneNumberFormat } from '@temboplus/frontend-core';
|
|
91
143
|
|
|
92
|
-
//
|
|
93
|
-
const
|
|
94
|
-
console.log(
|
|
144
|
+
// International phone numbers
|
|
145
|
+
const internationalPhone = PhoneNumber.from("+1 (202) 555-0123");
|
|
146
|
+
console.log(internationalPhone.getWithFormat(PhoneNumberFormat.INTERNATIONAL)); // +12025550123
|
|
95
147
|
|
|
96
|
-
//
|
|
97
|
-
const
|
|
98
|
-
console.log(
|
|
99
|
-
console.log(
|
|
100
|
-
```
|
|
148
|
+
// Tanzania phone numbers
|
|
149
|
+
const tanzaniaPhone = TZPhoneNumber.from("0712345678");
|
|
150
|
+
console.log(tanzaniaPhone.getWithFormat(PhoneNumberFormat.INTERNATIONAL)); // +255 712 345 678
|
|
151
|
+
console.log(tanzaniaPhone.networkOperator.name); // "Yas"
|
|
152
|
+
```
|
package/esm/mod.d.ts
CHANGED
package/esm/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC"}
|
package/esm/mod.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class ConfigService {
|
|
2
|
+
private static _instance;
|
|
3
|
+
private _pdfMakerBaseUrl;
|
|
4
|
+
private constructor();
|
|
5
|
+
static get instance(): ConfigService;
|
|
6
|
+
initialize(config: {
|
|
7
|
+
pdfMakerBaseUrl: string;
|
|
8
|
+
}): void;
|
|
9
|
+
get pdfMakerBaseUrl(): string;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=config_service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config_service.d.ts","sourceRoot":"","sources":["../../../src/src/config/config_service.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAgB;IACxC,OAAO,CAAC,gBAAgB,CAAc;IAEtC,OAAO;IAEP,WAAkB,QAAQ,kBAEzB;IAEM,UAAU,CAAC,MAAM,EAAE;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE;IAIrD,IAAW,eAAe,IAAI,MAAM,CAEnC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class ConfigService {
|
|
2
|
+
constructor() {
|
|
3
|
+
Object.defineProperty(this, "_pdfMakerBaseUrl", {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
configurable: true,
|
|
6
|
+
writable: true,
|
|
7
|
+
value: ""
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
static get instance() {
|
|
11
|
+
return this._instance || (this._instance = new this());
|
|
12
|
+
}
|
|
13
|
+
initialize(config) {
|
|
14
|
+
this._pdfMakerBaseUrl = config.pdfMakerBaseUrl;
|
|
15
|
+
}
|
|
16
|
+
get pdfMakerBaseUrl() {
|
|
17
|
+
return this._pdfMakerBaseUrl;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./config_service.js";
|
|
@@ -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;
|
|
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: "
|
|
37
|
+
mobileMoneyService: "Mixx by Yas",
|
|
38
|
+
brandColor: "yellow",
|
|
36
39
|
},
|
|
37
40
|
[NetworkOperator.HALOTEL]: {
|
|
38
41
|
id: NetworkOperator.HALOTEL,
|
|
@@ -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 @@
|
|
|
1
|
+
export * from "./report_manager.js";
|
|
@@ -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;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