@temboplus/frontend-core 0.2.11 → 0.2.13
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.
|
@@ -726,6 +726,27 @@ declare class Amount {
|
|
|
726
726
|
* @returns True if the amount data is available and valid
|
|
727
727
|
*/
|
|
728
728
|
validate(): boolean;
|
|
729
|
+
/**
|
|
730
|
+
* Gets payout constraints (min/max amounts) for a specific currency
|
|
731
|
+
*
|
|
732
|
+
* Returns Amount objects that can be directly compared and formatted,
|
|
733
|
+
* providing type safety and automatic currency context.
|
|
734
|
+
*
|
|
735
|
+
* @param currency - The currency code to get constraints for
|
|
736
|
+
* @returns Object with min and max Amount objects, or undefined if currency not supported
|
|
737
|
+
*
|
|
738
|
+
* @example
|
|
739
|
+
* ```typescript
|
|
740
|
+
* const constraints = Amount.getTransactionLimits('TZS');
|
|
741
|
+
* if (constraints && myAmount.lessThan(constraints.min)) {
|
|
742
|
+
* throw new Error(`Minimum amount is ${constraints.min.label}`);
|
|
743
|
+
* }
|
|
744
|
+
* ```
|
|
745
|
+
*/
|
|
746
|
+
static getTransactionLimits(currency: CurrencyCode): {
|
|
747
|
+
min: Amount;
|
|
748
|
+
max: Amount;
|
|
749
|
+
} | undefined;
|
|
729
750
|
}
|
|
730
751
|
/**
|
|
731
752
|
* Export the Amount class and regex pattern
|
|
@@ -52,6 +52,17 @@ export interface ReportDefinition {
|
|
|
52
52
|
/** Type of the report */
|
|
53
53
|
reportType: ReportType;
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Return type for server-side report downloads
|
|
57
|
+
*/
|
|
58
|
+
export interface ReportDownloadResult {
|
|
59
|
+
/** The filename for the downloaded report */
|
|
60
|
+
filename: string;
|
|
61
|
+
/** The raw base64 data from the response */
|
|
62
|
+
data: string;
|
|
63
|
+
/** The report definition used */
|
|
64
|
+
report: ReportDefinition;
|
|
65
|
+
}
|
|
55
66
|
/**
|
|
56
67
|
* Registry of all available reports
|
|
57
68
|
*/
|
|
@@ -97,7 +108,7 @@ export declare class ReportManager {
|
|
|
97
108
|
*/
|
|
98
109
|
private getBaseURL;
|
|
99
110
|
/**
|
|
100
|
-
* Downloads a report
|
|
111
|
+
* Downloads a report for client-side usage (browser)
|
|
101
112
|
* @param args Arguments for the report download
|
|
102
113
|
* @returns Promise that resolves when download is complete
|
|
103
114
|
*/
|
|
@@ -109,12 +120,25 @@ export declare class ReportManager {
|
|
|
109
120
|
query?: Record<string, any>;
|
|
110
121
|
}): Promise<void>;
|
|
111
122
|
/**
|
|
112
|
-
*
|
|
123
|
+
* Fetches a report for server-side usage or when you want to handle saving separately
|
|
124
|
+
* @param args Arguments for the report fetch
|
|
125
|
+
* @returns Promise that resolves with the report data and filename
|
|
126
|
+
*/
|
|
127
|
+
fetchReport(args: {
|
|
128
|
+
token: string;
|
|
129
|
+
projectType: ProjectType;
|
|
130
|
+
reportType: ReportType;
|
|
131
|
+
fileFormat: FileFormat;
|
|
132
|
+
query?: Record<string, any>;
|
|
133
|
+
}): Promise<ReportDownloadResult>;
|
|
134
|
+
/**
|
|
135
|
+
* Get the filename from response or generate a default one
|
|
113
136
|
* @param response The response from the API
|
|
114
137
|
* @param report The report definition
|
|
115
138
|
* @param fileFormat The requested file format
|
|
139
|
+
* @returns The filename to use
|
|
116
140
|
*/
|
|
117
|
-
private
|
|
141
|
+
private getFilename;
|
|
118
142
|
/**
|
|
119
143
|
* Handle error responses from the API
|
|
120
144
|
* @param response The response from the API
|
package/dist/utils/text.d.ts
CHANGED
|
@@ -29,11 +29,75 @@ declare function abbreviateName(fullName: string): string;
|
|
|
29
29
|
* @returns {string} - The initials in uppercase format.
|
|
30
30
|
*/
|
|
31
31
|
declare function getInitialsFrom(fullName: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Validates a personal name (account holder name, wallet owner name, etc.)
|
|
34
|
+
* Used across bank accounts and MNO wallets for consistent validation.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} name - The name to validate
|
|
37
|
+
* @returns {boolean} True if the name meets all validation criteria, false otherwise
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // Returns true
|
|
41
|
+
* validatePersonalName("John Smith");
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* // Returns false (too short)
|
|
45
|
+
* validatePersonalName("Jo");
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // Returns false (invalid characters)
|
|
49
|
+
* validatePersonalName("User123");
|
|
50
|
+
*/
|
|
51
|
+
declare function validatePersonalName(name: string): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Validates a business name (company, organization, etc.)
|
|
54
|
+
* More lenient than personal name validation.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} name - The business name to validate
|
|
57
|
+
* @returns {boolean} True if the name meets business name criteria, false otherwise
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* // Returns true
|
|
61
|
+
* validateBusinessName("ABC Corporation Ltd");
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* // Returns true
|
|
65
|
+
* validateBusinessName("Smith & Sons Inc.");
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* // Returns true
|
|
69
|
+
* validateBusinessName("M-Pesa");
|
|
70
|
+
*/
|
|
71
|
+
declare function validateBusinessName(name: string): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Validates any name (personal or business) with automatic detection.
|
|
74
|
+
* First tries to detect if it's a business name, then validates accordingly.
|
|
75
|
+
* If detection fails, tries both validation methods.
|
|
76
|
+
*
|
|
77
|
+
* @param {string} name - The name to validate (personal or business)
|
|
78
|
+
* @returns {boolean} True if the name is valid as either personal or business name
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* // Returns true (personal name)
|
|
82
|
+
* validateName("John Smith");
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* // Returns true (business name)
|
|
86
|
+
* validateName("CRDB Bank PLC");
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* // Returns true (could be either)
|
|
90
|
+
* validateName("Smith Solutions");
|
|
91
|
+
*/
|
|
92
|
+
declare function validateName(name: string): boolean;
|
|
32
93
|
export declare const TextUtils: {
|
|
33
94
|
capitalizeFirstLetter: typeof capitalizeFirstLetter;
|
|
34
95
|
getFullName: typeof getFullName;
|
|
35
96
|
generateSlug: typeof generateSlug;
|
|
36
97
|
abbreviateName: typeof abbreviateName;
|
|
37
98
|
getInitialsFrom: typeof getInitialsFrom;
|
|
99
|
+
validatePersonalName: typeof validatePersonalName;
|
|
100
|
+
validateBusinessName: typeof validateBusinessName;
|
|
101
|
+
validateName: typeof validateName;
|
|
38
102
|
};
|
|
39
103
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temboplus/frontend-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
4
4
|
"description": "A JavaScript/TypeScript package providing common utilities and logic shared across front-end TemboPlus projects.",
|
|
5
5
|
"author": "Okello Gerald",
|
|
6
6
|
"license": "MIT",
|
|
@@ -67,4 +67,4 @@
|
|
|
67
67
|
"ts-node": "^10.9.2",
|
|
68
68
|
"typescript": "^5.8.3"
|
|
69
69
|
}
|
|
70
|
-
}
|
|
70
|
+
}
|