@temboplus/afloat 0.1.65 → 0.1.66
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/dist/features/payout/payout-channel-handler.d.ts +1 -27
- package/dist/features/payout/payout.repository.d.ts +1 -17
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/models/narration.model.d.ts +112 -67
- package/dist/models/statement-entry.model.d.ts +0 -48
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BankContactInfo, ContactInfo, MobileContactInfo } from "./contact-info.model";
|
|
2
2
|
/** Prefix for Ecobank mobile transfer narrations */
|
|
3
3
|
export declare const ECOBANK_PREFIX = "MOBILE TRANSFER ";
|
|
4
|
-
/** V2 format prefix for payout narrations using
|
|
4
|
+
/** V2 format prefix for payout narrations using contact details */
|
|
5
5
|
export declare const NARR_V2_PREFIX: string;
|
|
6
6
|
/** V1 format prefix for bank payout narrations */
|
|
7
7
|
export declare const BANK_NARR_PREFIX: string;
|
|
@@ -22,25 +22,27 @@ export interface NarrationJson {
|
|
|
22
22
|
* Handles payout narration generation and parsing for the Afloat platform.
|
|
23
23
|
*
|
|
24
24
|
* This class provides functionality to:
|
|
25
|
-
* - Generate standardized payout narrations using
|
|
26
|
-
* - Parse
|
|
25
|
+
* - Generate standardized payout narrations using contact details (V2 format)
|
|
26
|
+
* - Parse existing narrations to extract contact information
|
|
27
27
|
* - Format narration text for different display contexts
|
|
28
|
-
* - Handle V2 (
|
|
28
|
+
* - Handle V2 (PAY format), V1, and legacy narration formats for backward compatibility
|
|
29
29
|
* - Serialize/deserialize to/from JSON format
|
|
30
30
|
*
|
|
31
31
|
* @example
|
|
32
32
|
* ```typescript
|
|
33
|
-
* // Generate V2 narration using
|
|
34
|
-
* const
|
|
35
|
-
*
|
|
33
|
+
* // Generate V2 narration using contact info
|
|
34
|
+
* const mobileContact = new MobileContactInfo("John Doe", phoneNumber);
|
|
35
|
+
* const narration = Narration.generateDefaultPayoutNarration(mobileContact);
|
|
36
|
+
* // Result: "PAYOUT +255123456789 JOHN DOE"
|
|
36
37
|
*
|
|
37
|
-
*
|
|
38
|
-
* const
|
|
39
|
-
*
|
|
40
|
-
* const restored = Narration.fromJson(json);
|
|
38
|
+
* const bankContact = new BankContactInfo("Jane Smith", bank, "1234567890");
|
|
39
|
+
* const narration = Narration.generateDefaultPayoutNarration(bankContact);
|
|
40
|
+
* // Result: "PAYOUT CORUTZTZ 1234567890 JANE SMITH"
|
|
41
41
|
*
|
|
42
|
-
* // Extract
|
|
43
|
-
* const
|
|
42
|
+
* // Extract contact details from narration
|
|
43
|
+
* const existingNarration = new Narration("PAYOUT +255123456789 JOHN DOE");
|
|
44
|
+
* const contactInfo = existingNarration.getContactDetails();
|
|
45
|
+
* // Returns: MobileContactInfo instance
|
|
44
46
|
* ```
|
|
45
47
|
*/
|
|
46
48
|
export declare class Narration {
|
|
@@ -53,78 +55,134 @@ export declare class Narration {
|
|
|
53
55
|
*/
|
|
54
56
|
constructor(text: string);
|
|
55
57
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* Format: "TEMBO-DISB #{PAYOUT_ID}"
|
|
58
|
+
* Returns a medium-length version of the narration text suitable for table columns.
|
|
59
|
+
* Truncates to 47 characters + "..." if longer than 50 characters.
|
|
59
60
|
*
|
|
60
|
-
*
|
|
61
|
+
* @returns Truncated narration text for medium-width displays
|
|
62
|
+
*/
|
|
63
|
+
get mediumText(): string;
|
|
64
|
+
/**
|
|
65
|
+
* Returns a short version of the narration text suitable for compact displays.
|
|
66
|
+
* Truncates to 32 characters + "..." if longer than 35 characters.
|
|
67
|
+
*
|
|
68
|
+
* @returns Truncated narration text for narrow displays
|
|
69
|
+
*/
|
|
70
|
+
get shortText(): string;
|
|
71
|
+
/**
|
|
72
|
+
* Generates the default payout narration based on contact information using the V2 format.
|
|
73
|
+
* Automatically determines whether to generate mobile or bank narration based on contact type.
|
|
61
74
|
*
|
|
62
|
-
* @param
|
|
63
|
-
* @returns Formatted
|
|
75
|
+
* @param data - Contact information (either MobileContactInfo or BankContactInfo)
|
|
76
|
+
* @returns Formatted default narration string in uppercase using V2 format, or empty string if contact type is unrecognized
|
|
64
77
|
*
|
|
65
78
|
* @example
|
|
66
79
|
* ```typescript
|
|
67
|
-
* const
|
|
68
|
-
*
|
|
80
|
+
* const mobileContact = new MobileContactInfo("John Doe", phoneNumber);
|
|
81
|
+
* const narration = Narration.generateDefaultPayoutNarration(mobileContact);
|
|
82
|
+
* // Returns: "PAYOUT +255123456789 JOHN DOE"
|
|
69
83
|
*
|
|
70
|
-
* const
|
|
71
|
-
*
|
|
84
|
+
* const bankContact = new BankContactInfo("Jane Smith", bank, "1234567890");
|
|
85
|
+
* const narration = Narration.generateDefaultPayoutNarration(bankContact);
|
|
86
|
+
* // Returns: "PAYOUT CORUTZTZ 1234567890 JANE SMITH"
|
|
72
87
|
* ```
|
|
73
88
|
*/
|
|
74
|
-
static generateDefaultPayoutNarration(
|
|
89
|
+
static generateDefaultPayoutNarration(data: ContactInfo): string;
|
|
75
90
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* Returns undefined for V1 and legacy formats.
|
|
91
|
+
* Generates a V2 standardized mobile money payout narration with contact details.
|
|
92
|
+
* Format: "PAY {phone_number} {name}"
|
|
79
93
|
*
|
|
80
|
-
* @
|
|
94
|
+
* @param data - Mobile contact information containing phone number and name
|
|
95
|
+
* @returns Formatted V2 mobile payout narration in uppercase
|
|
81
96
|
*
|
|
82
97
|
* @example
|
|
83
98
|
* ```typescript
|
|
84
|
-
*
|
|
85
|
-
* const
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* // V1 format (does not work - returns undefined)
|
|
89
|
-
* const v1Narration = new Narration("PAYOUT TO BANK CRDB 1234567890 Jane Smith");
|
|
90
|
-
* const payoutId = v1Narration.getPayoutId(); // Returns: undefined
|
|
99
|
+
* const contact = new MobileContactInfo("John Doe", phoneNumber);
|
|
100
|
+
* const narration = Narration.generateMobilePayoutNarrationV2(contact);
|
|
101
|
+
* // Returns: "PAYOUT +255123456789 JOHN DOE"
|
|
91
102
|
* ```
|
|
92
103
|
*/
|
|
93
|
-
|
|
104
|
+
static generateMobilePayoutNarrationV2(data: MobileContactInfo): string;
|
|
94
105
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
106
|
+
* Generates a V2 standardized bank payout narration with contact details.
|
|
107
|
+
* Format: "PAY {swift_code} {account_number} {account_name}"
|
|
108
|
+
*
|
|
109
|
+
* @param data - Bank contact information containing bank details, account number, and account name
|
|
110
|
+
* @returns Formatted V2 bank payout narration in uppercase
|
|
97
111
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* const contact = new BankContactInfo("Jane Smith", bank, "1234567890");
|
|
115
|
+
* const narration = Narration.generateBankPayoutNarrationV2(contact);
|
|
116
|
+
* // Returns: "PAYOUT CORUTZTZ 1234567890 JANE SMITH"
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
static generateBankPayoutNarrationV2(data: BankContactInfo): string;
|
|
120
|
+
/**
|
|
121
|
+
* Extracts contact information from the narration text.
|
|
122
|
+
* Supports V2 (PAY format), V1, and legacy formats for comprehensive contact detection.
|
|
100
123
|
*
|
|
101
124
|
* @returns Parsed ContactInfo (BankContactInfo or MobileContactInfo) if successful, undefined otherwise
|
|
102
125
|
*
|
|
103
126
|
* @example
|
|
104
127
|
* ```typescript
|
|
105
|
-
* //
|
|
128
|
+
* // V2 format
|
|
129
|
+
* const v2Narration = new Narration("PAYOUT +255123456789 JOHN DOE");
|
|
130
|
+
* const v2Contact = v2Narration.getContactDetails();
|
|
131
|
+
* // Returns: MobileContactInfo instance
|
|
132
|
+
*
|
|
133
|
+
* // V1 format
|
|
106
134
|
* const v1Narration = new Narration("PAYOUT TO BANK CRDB 1234567890 Jane Smith");
|
|
107
135
|
* const v1Contact = v1Narration.getContactDetails();
|
|
108
|
-
*
|
|
109
|
-
* // V2 format (does not work - returns undefined)
|
|
110
|
-
* const v2Narration = new Narration("TEMBO-DISB #AF-2024-001234");
|
|
111
|
-
* const v2Contact = v2Narration.getContactDetails(); // Returns undefined
|
|
136
|
+
* // Returns: BankContactInfo instance
|
|
112
137
|
* ```
|
|
113
138
|
*/
|
|
114
139
|
getContactDetails: () => ContactInfo | undefined;
|
|
115
140
|
/**
|
|
116
|
-
*
|
|
117
|
-
* V2
|
|
118
|
-
*
|
|
119
|
-
* Extracts bank contact information from legacy narration text.
|
|
120
|
-
* Only works for V1 and legacy formats. V2 format uses payout IDs and will return undefined.
|
|
141
|
+
* Extracts bank contact information from the narration text.
|
|
142
|
+
* Handles V2 format (PAY with SWIFT code and details), V1 format, and legacy format.
|
|
143
|
+
* Also handles Ecobank-prefixed narrations by stripping the prefix.
|
|
121
144
|
*
|
|
145
|
+
* V2 format: "PAYOUT {swift_code} {account_number} {account_name}"
|
|
122
146
|
* V1 format: "PAYOUT TO BANK {bank_name} {account_number} {account_name}"
|
|
123
147
|
* Legacy format: "TO_BANK => {json_object}"
|
|
124
148
|
*
|
|
125
149
|
* @returns BankContactInfo if parsing is successful, undefined otherwise
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* // V2 format
|
|
154
|
+
* const v2Narration = new Narration("PAYOUT CORUTZTZ 1234567890 JANE SMITH");
|
|
155
|
+
* const v2Contact = v2Narration.getBankContactDetails();
|
|
156
|
+
*
|
|
157
|
+
* // V1 format
|
|
158
|
+
* const v1Narration = new Narration("PAYOUT TO BANK CRDB 1234567890 Jane Smith");
|
|
159
|
+
* const v1Contact = v1Narration.getBankContactDetails();
|
|
160
|
+
* ```
|
|
126
161
|
*/
|
|
127
162
|
getBankContactDetails: () => BankContactInfo | undefined;
|
|
163
|
+
/**
|
|
164
|
+
* Extracts mobile contact information from the narration text.
|
|
165
|
+
* Handles V2 format (PAY with phone number and name), V1 format, and legacy format.
|
|
166
|
+
* Also handles Ecobank-prefixed narrations by stripping the prefix.
|
|
167
|
+
*
|
|
168
|
+
* V2 format: "PAYOUT {phone_number} {name}"
|
|
169
|
+
* V1 format: "PAYOUT TO MOBILE {phone_number} {name}"
|
|
170
|
+
* Legacy format: "TO_MOMO => {json_object}"
|
|
171
|
+
*
|
|
172
|
+
* @returns MobileContactInfo if parsing is successful, undefined otherwise
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* // V2 format
|
|
177
|
+
* const v2Narration = new Narration("PAYOUT +255123456789 JOHN DOE");
|
|
178
|
+
* const v2Contact = v2Narration.getMobileContactDetails();
|
|
179
|
+
*
|
|
180
|
+
* // V1 format
|
|
181
|
+
* const v1Narration = new Narration("PAYOUT TO MOBILE +255123456789 John Doe");
|
|
182
|
+
* const v1Contact = v1Narration.getMobileContactDetails();
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
getMobileContactDetails: () => MobileContactInfo | undefined;
|
|
128
186
|
/**
|
|
129
187
|
* Serializes the Narration instance to a JSON-compatible object.
|
|
130
188
|
*
|
|
@@ -132,9 +190,9 @@ export declare class Narration {
|
|
|
132
190
|
*
|
|
133
191
|
* @example
|
|
134
192
|
* ```typescript
|
|
135
|
-
* const narration = new Narration("
|
|
193
|
+
* const narration = new Narration("PAYOUT +255123456789 JOHN DOE");
|
|
136
194
|
* const json = narration.toJson();
|
|
137
|
-
* // Returns: { text: "
|
|
195
|
+
* // Returns: { text: "PAYOUT +255123456789 JOHN DOE", version: "2.0" }
|
|
138
196
|
* ```
|
|
139
197
|
*/
|
|
140
198
|
toJson(): NarrationJson;
|
|
@@ -147,10 +205,10 @@ export declare class Narration {
|
|
|
147
205
|
* @example
|
|
148
206
|
* ```typescript
|
|
149
207
|
* // From object
|
|
150
|
-
* const narration = Narration.fromJson({ text: "
|
|
208
|
+
* const narration = Narration.fromJson({ text: "PAYOUT +255123456789 JOHN DOE" });
|
|
151
209
|
*
|
|
152
210
|
* // From JSON string
|
|
153
|
-
* const narration = Narration.fromJson('{"text":"
|
|
211
|
+
* const narration = Narration.fromJson('{"text":"PAYOUT +255123456789 JOHN DOE"}');
|
|
154
212
|
* ```
|
|
155
213
|
*/
|
|
156
214
|
static fromJson(json: NarrationJson | string): Narration | undefined;
|
|
@@ -168,17 +226,4 @@ export declare class Narration {
|
|
|
168
226
|
* @returns Type predicate indicating if the object is a Narration instance
|
|
169
227
|
*/
|
|
170
228
|
static is(obj: unknown): obj is Narration;
|
|
171
|
-
/**
|
|
172
|
-
* @deprecated Contact extraction from narrations is deprecated and should only be used for legacy/V1 format support.
|
|
173
|
-
* V2 narrations use payout IDs and do not contain contact information.
|
|
174
|
-
*
|
|
175
|
-
* Extracts mobile contact information from legacy narration text.
|
|
176
|
-
* Only works for V1 and legacy formats. V2 format uses payout IDs and will return undefined.
|
|
177
|
-
*
|
|
178
|
-
* V1 format: "PAYOUT TO MOBILE {phone_number} {name}"
|
|
179
|
-
* Legacy format: "TO_MOMO => {json_object}"
|
|
180
|
-
*
|
|
181
|
-
* @returns MobileContactInfo if parsing is successful, undefined otherwise
|
|
182
|
-
*/
|
|
183
|
-
getMobileContactDetails: () => MobileContactInfo | undefined;
|
|
184
229
|
}
|
|
@@ -98,40 +98,6 @@ export declare class WalletStatementEntry {
|
|
|
98
98
|
balance: number;
|
|
99
99
|
currencyCode?: string;
|
|
100
100
|
}): WalletStatementEntry | undefined;
|
|
101
|
-
/**
|
|
102
|
-
* Creates a new WalletStatementEntry with a payout narration using the V2 format.
|
|
103
|
-
* This is a convenience method for creating statement entries for payout transactions.
|
|
104
|
-
*
|
|
105
|
-
* @param data - Statement entry data without narration
|
|
106
|
-
* @param payoutId - Unique payout identifier for generating narration
|
|
107
|
-
* @returns A new WalletStatementEntry instance with generated narration, or undefined if validation fails
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* ```typescript
|
|
111
|
-
* const entry = WalletStatementEntry.createWithPayoutNarration({
|
|
112
|
-
* debitOrCredit: "DEBIT",
|
|
113
|
-
* tranRefNo: "TXN-12345",
|
|
114
|
-
* txnDate: new Date(),
|
|
115
|
-
* valueDate: new Date(),
|
|
116
|
-
* amountDebited: 50000,
|
|
117
|
-
* amountCredited: 0,
|
|
118
|
-
* balance: 450000,
|
|
119
|
-
* currencyCode: "TZS"
|
|
120
|
-
* }, "AF-2024-001234");
|
|
121
|
-
* // Creates entry with narration: "TEMBO-DISB #AF-2024-001234"
|
|
122
|
-
* ```
|
|
123
|
-
*/
|
|
124
|
-
static createWithPayoutNarration(data: {
|
|
125
|
-
accountNo?: string | null;
|
|
126
|
-
debitOrCredit: string;
|
|
127
|
-
tranRefNo: string;
|
|
128
|
-
txnDate: string | Date;
|
|
129
|
-
valueDate: string | Date;
|
|
130
|
-
amountCredited: number;
|
|
131
|
-
amountDebited: number;
|
|
132
|
-
balance: number;
|
|
133
|
-
currencyCode?: string;
|
|
134
|
-
}, payoutId: string): WalletStatementEntry | undefined;
|
|
135
101
|
get accountNo(): string | undefined;
|
|
136
102
|
get debitOrCredit(): string;
|
|
137
103
|
get tranRefNo(): string;
|
|
@@ -142,20 +108,6 @@ export declare class WalletStatementEntry {
|
|
|
142
108
|
get amountDebited(): Amount;
|
|
143
109
|
get balance(): Amount;
|
|
144
110
|
get currencyCode(): string;
|
|
145
|
-
/**
|
|
146
|
-
* Gets the payout ID from the narration if it's a V2 format payout narration.
|
|
147
|
-
* This is a convenience method that delegates to the narration instance.
|
|
148
|
-
*
|
|
149
|
-
* @returns The payout ID if available, undefined otherwise
|
|
150
|
-
*/
|
|
151
|
-
get payoutId(): string | undefined;
|
|
152
|
-
/**
|
|
153
|
-
* Checks if this statement entry represents a payout transaction.
|
|
154
|
-
* Determined by checking if the narration contains a payout ID.
|
|
155
|
-
*
|
|
156
|
-
* @returns True if this is a payout transaction, false otherwise
|
|
157
|
-
*/
|
|
158
|
-
get isPayout(): boolean;
|
|
159
111
|
/**
|
|
160
112
|
* Serializes the WalletStatementEntry instance to a JSON-compatible object.
|
|
161
113
|
* Dates are converted to ISO strings, amounts are serialized using Amount.toJson(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temboplus/afloat",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.66",
|
|
4
4
|
"description": "A foundational library for Temboplus-Afloat projects.",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/TemboPlus-Frontend/afloat-js#readme",
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@temboplus/frontend-core": "^0.2.
|
|
40
|
+
"@temboplus/frontend-core": "^0.2.14",
|
|
41
41
|
"@ts-rest/core": "^3.52.1",
|
|
42
42
|
"tslib": "^2.8.1",
|
|
43
43
|
"uuid": "^11.1.0",
|