@temboplus/afloat 0.1.77-beta.1 → 0.1.77-beta.10
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/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/modules/auth/auth.contract.d.ts +2 -2
- package/dist/modules/auth/company-membership.model.d.ts +122 -9
- package/dist/modules/auth/user.model.d.ts +238 -15
- package/dist/modules/contact/contact-info.model.d.ts +183 -533
- package/dist/modules/contact/contact.model.d.ts +309 -32
- package/dist/modules/login/login.model.d.ts +53 -23
- package/dist/modules/payout/payout.dtos.d.ts +6 -0
- package/dist/modules/payout/payout.model.d.ts +242 -2
- package/dist/modules/payout/payout.query.d.ts +7 -0
- package/dist/modules/profile/profile.model.d.ts +65 -30
- package/dist/modules/team-member/role.model.d.ts +49 -1
- package/dist/modules/team-member/team-member.contract.d.ts +6 -0
- package/dist/modules/team-member/team-member.dtos.d.ts +6 -0
- package/dist/modules/team-member/team-member.model.d.ts +106 -6
- package/dist/modules/wallet/narration.model.d.ts +34 -38
- package/dist/modules/wallet/statement-entry.model.d.ts +172 -73
- package/dist/modules/wallet/wallet.model.d.ts +56 -19
- package/dist/modules/wallet/wallet.query.d.ts +95 -0
- package/dist/modules/wallet/wallet.repository.d.ts +45 -13
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ContactInfo, MobileContactInfo, BankContactInfo } from "../contact/contact-info.model.js";
|
|
2
|
+
import z from "zod";
|
|
2
3
|
/** Prefix for Ecobank mobile transfer narrations */
|
|
3
4
|
export declare const ECOBANK_PREFIX = "MOBILE TRANSFER ";
|
|
4
5
|
/** V2 format prefix for payout narrations using contact details */
|
|
@@ -12,12 +13,19 @@ export declare const MOBILE_NARR_PREFIX: string;
|
|
|
12
13
|
/** Legacy format prefix for mobile money payout narrations */
|
|
13
14
|
export declare const LEGACY_MOBILE_NARR_PREFIX: string;
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* Zod schema for Narration JSON serialization
|
|
16
17
|
*/
|
|
17
|
-
export
|
|
18
|
+
export declare const NarrationJSONSchema: z.ZodObject<{
|
|
19
|
+
text: z.ZodString;
|
|
20
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
version: string;
|
|
18
23
|
text: string;
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
}, {
|
|
25
|
+
text: string;
|
|
26
|
+
version?: string | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
export type NarrationJSON = z.infer<typeof NarrationJSONSchema>;
|
|
21
29
|
/**
|
|
22
30
|
* Handles payout narration generation and parsing for the Afloat platform.
|
|
23
31
|
*
|
|
@@ -184,46 +192,34 @@ export declare class Narration {
|
|
|
184
192
|
*/
|
|
185
193
|
getMobileContactDetails: () => MobileContactInfo | undefined;
|
|
186
194
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* @returns {NarrationJson} A plain object containing the narration data
|
|
195
|
+
* Type guard to check if an unknown object is a valid Narration instance.
|
|
190
196
|
*
|
|
191
|
-
* @
|
|
192
|
-
*
|
|
193
|
-
* const narration = new Narration("PAYOUT +255123456789 JOHN DOE");
|
|
194
|
-
* const json = narration.toJson();
|
|
195
|
-
* // Returns: { text: "PAYOUT +255123456789 JOHN DOE", version: "2.0" }
|
|
196
|
-
* ```
|
|
197
|
+
* @param obj - The object to check
|
|
198
|
+
* @returns Type predicate indicating if the object is a Narration instance
|
|
197
199
|
*/
|
|
198
|
-
|
|
200
|
+
static is(obj: unknown): obj is Narration;
|
|
199
201
|
/**
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
*
|
|
205
|
-
* @example
|
|
206
|
-
* ```typescript
|
|
207
|
-
* // From object
|
|
208
|
-
* const narration = Narration.fromJson({ text: "PAYOUT +255123456789 JOHN DOE" });
|
|
209
|
-
*
|
|
210
|
-
* // From JSON string
|
|
211
|
-
* const narration = Narration.fromJson('{"text":"PAYOUT +255123456789 JOHN DOE"}');
|
|
212
|
-
* ```
|
|
202
|
+
* Serializes the Narration instance to a JSON-compatible object
|
|
203
|
+
*/
|
|
204
|
+
toJSON(): NarrationJSON;
|
|
205
|
+
/**
|
|
206
|
+
* Serializes the Narration instance to a JSON string
|
|
213
207
|
*/
|
|
214
|
-
|
|
208
|
+
toJSONString(): string;
|
|
215
209
|
/**
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* @param obj - The object to validate
|
|
219
|
-
* @returns True if the object conforms to NarrationJson structure
|
|
210
|
+
* Creates a Narration instance from a JSON-compatible object or string
|
|
220
211
|
*/
|
|
221
|
-
static
|
|
212
|
+
static fromJSON(json: NarrationJSON | string): Narration | undefined;
|
|
222
213
|
/**
|
|
223
|
-
* Type guard
|
|
224
|
-
*
|
|
225
|
-
* @param obj - The object to check
|
|
226
|
-
* @returns Type predicate indicating if the object is a Narration instance
|
|
214
|
+
* Type guard using Zod schema validation
|
|
227
215
|
*/
|
|
228
|
-
static
|
|
216
|
+
static isNarrationJSON(obj: unknown): obj is NarrationJSON;
|
|
217
|
+
/**
|
|
218
|
+
* @deprecated Use toJSON() instead
|
|
219
|
+
*/
|
|
220
|
+
toJson(): NarrationJSON;
|
|
221
|
+
/**
|
|
222
|
+
* @deprecated Use fromJSON() instead
|
|
223
|
+
*/
|
|
224
|
+
static fromJson(json: NarrationJSON | string): Narration | undefined;
|
|
229
225
|
}
|
|
@@ -1,22 +1,137 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { Amount } from "@temboplus/frontend-core";
|
|
2
|
+
import { Narration } from "./narration.model.js";
|
|
3
|
+
import z from "zod";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Zod schema for WalletStatementEntry JSON serialization
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
8
|
-
accountNo
|
|
7
|
+
export declare const WalletStatementEntryJSONSchema: z.ZodObject<{
|
|
8
|
+
accountNo: z.ZodOptional<z.ZodString>;
|
|
9
|
+
debitOrCredit: z.ZodString;
|
|
10
|
+
tranRefNo: z.ZodString;
|
|
11
|
+
narration: z.ZodObject<{
|
|
12
|
+
text: z.ZodString;
|
|
13
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
version: string;
|
|
16
|
+
text: string;
|
|
17
|
+
}, {
|
|
18
|
+
text: string;
|
|
19
|
+
version?: string | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
txnDate: z.ZodString;
|
|
22
|
+
valueDate: z.ZodString;
|
|
23
|
+
amountCredited: z.ZodObject<{
|
|
24
|
+
value: z.ZodNumber;
|
|
25
|
+
text: z.ZodString;
|
|
26
|
+
currencyCode: z.ZodString;
|
|
27
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
version: string;
|
|
30
|
+
value: number;
|
|
31
|
+
text: string;
|
|
32
|
+
currencyCode: string;
|
|
33
|
+
}, {
|
|
34
|
+
value: number;
|
|
35
|
+
text: string;
|
|
36
|
+
currencyCode: string;
|
|
37
|
+
version?: string | undefined;
|
|
38
|
+
}>;
|
|
39
|
+
amountDebited: z.ZodObject<{
|
|
40
|
+
value: z.ZodNumber;
|
|
41
|
+
text: z.ZodString;
|
|
42
|
+
currencyCode: z.ZodString;
|
|
43
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
version: string;
|
|
46
|
+
value: number;
|
|
47
|
+
text: string;
|
|
48
|
+
currencyCode: string;
|
|
49
|
+
}, {
|
|
50
|
+
value: number;
|
|
51
|
+
text: string;
|
|
52
|
+
currencyCode: string;
|
|
53
|
+
version?: string | undefined;
|
|
54
|
+
}>;
|
|
55
|
+
balance: z.ZodObject<{
|
|
56
|
+
value: z.ZodNumber;
|
|
57
|
+
text: z.ZodString;
|
|
58
|
+
currencyCode: z.ZodString;
|
|
59
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
version: string;
|
|
62
|
+
value: number;
|
|
63
|
+
text: string;
|
|
64
|
+
currencyCode: string;
|
|
65
|
+
}, {
|
|
66
|
+
value: number;
|
|
67
|
+
text: string;
|
|
68
|
+
currencyCode: string;
|
|
69
|
+
version?: string | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
currencyCode: z.ZodString;
|
|
72
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
73
|
+
}, "strip", z.ZodTypeAny, {
|
|
74
|
+
version: string;
|
|
75
|
+
currencyCode: string;
|
|
9
76
|
debitOrCredit: string;
|
|
10
77
|
tranRefNo: string;
|
|
11
|
-
narration:
|
|
78
|
+
narration: {
|
|
79
|
+
version: string;
|
|
80
|
+
text: string;
|
|
81
|
+
};
|
|
12
82
|
txnDate: string;
|
|
13
83
|
valueDate: string;
|
|
14
|
-
amountCredited:
|
|
15
|
-
|
|
16
|
-
|
|
84
|
+
amountCredited: {
|
|
85
|
+
version: string;
|
|
86
|
+
value: number;
|
|
87
|
+
text: string;
|
|
88
|
+
currencyCode: string;
|
|
89
|
+
};
|
|
90
|
+
amountDebited: {
|
|
91
|
+
version: string;
|
|
92
|
+
value: number;
|
|
93
|
+
text: string;
|
|
94
|
+
currencyCode: string;
|
|
95
|
+
};
|
|
96
|
+
balance: {
|
|
97
|
+
version: string;
|
|
98
|
+
value: number;
|
|
99
|
+
text: string;
|
|
100
|
+
currencyCode: string;
|
|
101
|
+
};
|
|
102
|
+
accountNo?: string | undefined;
|
|
103
|
+
}, {
|
|
17
104
|
currencyCode: string;
|
|
18
|
-
|
|
19
|
-
|
|
105
|
+
debitOrCredit: string;
|
|
106
|
+
tranRefNo: string;
|
|
107
|
+
narration: {
|
|
108
|
+
text: string;
|
|
109
|
+
version?: string | undefined;
|
|
110
|
+
};
|
|
111
|
+
txnDate: string;
|
|
112
|
+
valueDate: string;
|
|
113
|
+
amountCredited: {
|
|
114
|
+
value: number;
|
|
115
|
+
text: string;
|
|
116
|
+
currencyCode: string;
|
|
117
|
+
version?: string | undefined;
|
|
118
|
+
};
|
|
119
|
+
amountDebited: {
|
|
120
|
+
value: number;
|
|
121
|
+
text: string;
|
|
122
|
+
currencyCode: string;
|
|
123
|
+
version?: string | undefined;
|
|
124
|
+
};
|
|
125
|
+
balance: {
|
|
126
|
+
value: number;
|
|
127
|
+
text: string;
|
|
128
|
+
currencyCode: string;
|
|
129
|
+
version?: string | undefined;
|
|
130
|
+
};
|
|
131
|
+
accountNo?: string | undefined;
|
|
132
|
+
version?: string | undefined;
|
|
133
|
+
}>;
|
|
134
|
+
export type WalletStatementEntryJSON = z.infer<typeof WalletStatementEntryJSONSchema>;
|
|
20
135
|
/**
|
|
21
136
|
* Represents a single entry in a Wallet's statement history.
|
|
22
137
|
*
|
|
@@ -38,18 +153,18 @@ export declare class WalletStatementEntry {
|
|
|
38
153
|
/**
|
|
39
154
|
* Gets the statement entry schema used for validation.
|
|
40
155
|
*/
|
|
41
|
-
static get schema():
|
|
42
|
-
accountNo:
|
|
43
|
-
debitOrCredit:
|
|
44
|
-
tranRefNo:
|
|
45
|
-
narration:
|
|
46
|
-
txnDate:
|
|
47
|
-
valueDate:
|
|
48
|
-
amountCredited:
|
|
49
|
-
amountDebited:
|
|
50
|
-
balance:
|
|
51
|
-
currencyCode:
|
|
52
|
-
}, "strip",
|
|
156
|
+
static get schema(): z.ZodObject<{
|
|
157
|
+
accountNo: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
|
|
158
|
+
debitOrCredit: z.ZodString;
|
|
159
|
+
tranRefNo: z.ZodString;
|
|
160
|
+
narration: z.ZodString;
|
|
161
|
+
txnDate: z.ZodDate;
|
|
162
|
+
valueDate: z.ZodDate;
|
|
163
|
+
amountCredited: z.ZodNumber;
|
|
164
|
+
amountDebited: z.ZodNumber;
|
|
165
|
+
balance: z.ZodNumber;
|
|
166
|
+
currencyCode: z.ZodDefault<z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>>;
|
|
167
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
168
|
currencyCode: string;
|
|
54
169
|
debitOrCredit: string;
|
|
55
170
|
tranRefNo: string;
|
|
@@ -108,28 +223,6 @@ export declare class WalletStatementEntry {
|
|
|
108
223
|
get amountDebited(): Amount;
|
|
109
224
|
get balance(): Amount;
|
|
110
225
|
get currencyCode(): string;
|
|
111
|
-
/**
|
|
112
|
-
* Serializes the WalletStatementEntry instance to a JSON-compatible object.
|
|
113
|
-
* Dates are converted to ISO strings, amounts are serialized using Amount.toJson(),
|
|
114
|
-
* and narration is serialized using Narration.toJson().
|
|
115
|
-
*
|
|
116
|
-
* @returns {WalletStatementEntryJson} A plain object containing all necessary data
|
|
117
|
-
*/
|
|
118
|
-
toJson(): WalletStatementEntryJson;
|
|
119
|
-
/**
|
|
120
|
-
* Creates a WalletStatementEntry instance from a JSON-compatible object.
|
|
121
|
-
*
|
|
122
|
-
* @param {WalletStatementEntryJson | string} json - Either a WalletStatementEntryJson object or a JSON string
|
|
123
|
-
* @returns {WalletStatementEntry | undefined} A WalletStatementEntry instance if valid, undefined otherwise
|
|
124
|
-
*/
|
|
125
|
-
static fromJson(json: WalletStatementEntryJson | string): WalletStatementEntry | undefined;
|
|
126
|
-
/**
|
|
127
|
-
* Type guard to check if an object is a valid WalletStatementEntryJson
|
|
128
|
-
*
|
|
129
|
-
* @param obj - The object to validate
|
|
130
|
-
* @returns True if the object conforms to WalletStatementEntryJson structure
|
|
131
|
-
*/
|
|
132
|
-
static isWalletStatementEntryJson(obj: unknown): obj is WalletStatementEntryJson;
|
|
133
226
|
/**
|
|
134
227
|
* Validates the current statement entry instance data against the schema.
|
|
135
228
|
* @returns True if the statement entry instance data is valid, false otherwise.
|
|
@@ -159,42 +252,48 @@ export declare class WalletStatementEntry {
|
|
|
159
252
|
*/
|
|
160
253
|
toString(): string;
|
|
161
254
|
/**
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
* @param entries - Array of WalletStatementEntry instances to serialize
|
|
165
|
-
* @returns Array of WalletStatementEntryJson objects
|
|
255
|
+
* Legacy method for backwards compatibility - creates from plain object
|
|
256
|
+
* @deprecated Use fromJson() for serialized data or create() for raw data
|
|
166
257
|
*/
|
|
167
|
-
static
|
|
258
|
+
static from(data: any): WalletStatementEntry | undefined;
|
|
168
259
|
/**
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
260
|
+
* Serializes the WalletStatementEntry instance to a JSON-compatible object
|
|
261
|
+
*/
|
|
262
|
+
toJSON(): WalletStatementEntryJSON;
|
|
263
|
+
/**
|
|
264
|
+
* Serializes the WalletStatementEntry instance to a JSON string
|
|
173
265
|
*/
|
|
174
|
-
|
|
266
|
+
toJSONString(): string;
|
|
175
267
|
/**
|
|
176
|
-
*
|
|
177
|
-
* @deprecated Use toJson() instead for proper serialization
|
|
268
|
+
* Creates a WalletStatementEntry instance from a JSON-compatible object or string
|
|
178
269
|
*/
|
|
179
|
-
|
|
180
|
-
amountCredited: AmountJson;
|
|
181
|
-
amountDebited: AmountJson;
|
|
182
|
-
balance: AmountJson;
|
|
183
|
-
narration: string;
|
|
184
|
-
};
|
|
270
|
+
static fromJSON(json: WalletStatementEntryJSON | string): WalletStatementEntry | undefined;
|
|
185
271
|
/**
|
|
186
|
-
*
|
|
187
|
-
* @deprecated Use JSON.stringify(entry.toJson()) instead
|
|
272
|
+
* Type guard using Zod schema validation
|
|
188
273
|
*/
|
|
189
|
-
|
|
274
|
+
static isWalletStatementEntryJSON(obj: unknown): obj is WalletStatementEntryJSON;
|
|
190
275
|
/**
|
|
191
|
-
*
|
|
192
|
-
* @deprecated Use fromJson() instead
|
|
276
|
+
* Creates WalletStatementEntry instances from a JSON array
|
|
193
277
|
*/
|
|
194
|
-
static
|
|
278
|
+
static fromJSONArray(jsonArray: WalletStatementEntryJSON[] | string): WalletStatementEntry[];
|
|
195
279
|
/**
|
|
196
|
-
*
|
|
197
|
-
* @deprecated Use fromJson() for serialized data or create() for raw data
|
|
280
|
+
* Serializes an array of WalletStatementEntry instances to JSON
|
|
198
281
|
*/
|
|
199
|
-
static
|
|
282
|
+
static toJSONArray(entries: WalletStatementEntry[]): WalletStatementEntryJSON[];
|
|
283
|
+
/**
|
|
284
|
+
* @deprecated Use toJSON() instead
|
|
285
|
+
*/
|
|
286
|
+
toJson(): WalletStatementEntryJSON;
|
|
287
|
+
/**
|
|
288
|
+
* @deprecated Use fromJSON() instead
|
|
289
|
+
*/
|
|
290
|
+
static fromJson(json: WalletStatementEntryJSON | string): WalletStatementEntry | undefined;
|
|
291
|
+
/**
|
|
292
|
+
* @deprecated Use fromJSONArray() instead
|
|
293
|
+
*/
|
|
294
|
+
static fromJsonArray(jsonArray: WalletStatementEntryJSON[] | string): WalletStatementEntry[];
|
|
295
|
+
/**
|
|
296
|
+
* @deprecated Use toJSONArray() instead
|
|
297
|
+
*/
|
|
298
|
+
static toJsonArray(entries: WalletStatementEntry[]): WalletStatementEntryJSON[];
|
|
200
299
|
}
|
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
import { type CurrencyCode, type ISO2CountryCode } from "@temboplus/frontend-core";
|
|
2
|
-
import {
|
|
2
|
+
import { WalletDTOSchemas } from "@/modules/wallet/wallet.dtos.js";
|
|
3
|
+
import z from "zod";
|
|
4
|
+
/**
|
|
5
|
+
* Zod schema for Wallet JSON serialization
|
|
6
|
+
*/
|
|
7
|
+
export declare const WalletJSONSchema: z.ZodObject<{
|
|
8
|
+
id: z.ZodString;
|
|
9
|
+
profileId: z.ZodString;
|
|
10
|
+
accountNo: z.ZodString;
|
|
11
|
+
accountName: z.ZodString;
|
|
12
|
+
channel: z.ZodString;
|
|
13
|
+
countryCode: z.ZodString;
|
|
14
|
+
currencyCode: z.ZodString;
|
|
15
|
+
createdAt: z.ZodString;
|
|
16
|
+
updatedAt: z.ZodString;
|
|
17
|
+
version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
id: string;
|
|
20
|
+
accountNo: string;
|
|
21
|
+
version: string;
|
|
22
|
+
profileId: string;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
updatedAt: string;
|
|
25
|
+
accountName: string;
|
|
26
|
+
channel: string;
|
|
27
|
+
countryCode: string;
|
|
28
|
+
currencyCode: string;
|
|
29
|
+
}, {
|
|
30
|
+
id: string;
|
|
31
|
+
accountNo: string;
|
|
32
|
+
profileId: string;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
updatedAt: string;
|
|
35
|
+
accountName: string;
|
|
36
|
+
channel: string;
|
|
37
|
+
countryCode: string;
|
|
38
|
+
currencyCode: string;
|
|
39
|
+
version?: string | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
export type WalletJSON = z.infer<typeof WalletJSONSchema>;
|
|
3
42
|
/**
|
|
4
43
|
* Represents a digital Wallet entity.
|
|
5
44
|
*
|
|
@@ -63,30 +102,12 @@ export declare class Wallet {
|
|
|
63
102
|
* @returns The last update Date object.
|
|
64
103
|
*/
|
|
65
104
|
get updatedAtDate(): Date;
|
|
66
|
-
/**
|
|
67
|
-
* Creates a plain data object representation of the Wallet instance.
|
|
68
|
-
* Suitable for serialization or validation.
|
|
69
|
-
* @returns A plain object conforming to the WalletDataType structure.
|
|
70
|
-
*/
|
|
71
|
-
toObject(): WalletDTO;
|
|
72
|
-
/**
|
|
73
|
-
* Serializes the Wallet instance into a JSON string.
|
|
74
|
-
* @returns A JSON string representation of the wallet data.
|
|
75
|
-
*/
|
|
76
|
-
toJSON(): string;
|
|
77
105
|
/**
|
|
78
106
|
* Validates the Wallet instance's current data against the defined schema.
|
|
79
107
|
* This includes checking the countryCode against ISO2CountryCodesSet.
|
|
80
108
|
* @returns True if the current instance data is valid, otherwise false.
|
|
81
109
|
*/
|
|
82
110
|
validate(): boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Creates a Wallet instance from a JSON string.
|
|
85
|
-
* Performs parsing and validation, including the countryCode runtime check.
|
|
86
|
-
* @param jsonString - A JSON string containing wallet data.
|
|
87
|
-
* @returns A new Wallet instance if parsing and validation succeed, otherwise undefined.
|
|
88
|
-
*/
|
|
89
|
-
static fromJSON(jsonString: string): Wallet | undefined;
|
|
90
111
|
/**
|
|
91
112
|
* Creates a Wallet instance from a plain JavaScript object.
|
|
92
113
|
* Validates the input object using the Wallet schema, including the countryCode runtime check.
|
|
@@ -101,4 +122,20 @@ export declare class Wallet {
|
|
|
101
122
|
* @returns True if the object resembles a Wallet instance, false otherwise.
|
|
102
123
|
*/
|
|
103
124
|
static is(obj: unknown): obj is Wallet;
|
|
125
|
+
/**
|
|
126
|
+
* Serializes the Wallet instance to a JSON-compatible object
|
|
127
|
+
*/
|
|
128
|
+
toJSON(): WalletJSON;
|
|
129
|
+
/**
|
|
130
|
+
* Serializes the Wallet instance to a JSON string
|
|
131
|
+
*/
|
|
132
|
+
toJSONString(): string;
|
|
133
|
+
/**
|
|
134
|
+
* Creates a Wallet instance from a JSON-compatible object or string
|
|
135
|
+
*/
|
|
136
|
+
static fromJSON(json: WalletJSON | string): Wallet | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* Type guard using Zod schema validation
|
|
139
|
+
*/
|
|
140
|
+
static isWalletJSON(obj: unknown): obj is WalletJSON;
|
|
104
141
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { QueryBuilder } from "@/lib/query/index.js";
|
|
2
|
+
import { WalletQueryDTO } from "./wallet.dtos.js";
|
|
3
|
+
/**
|
|
4
|
+
* Wallet-specific query builder that extends the base QueryBuilder
|
|
5
|
+
* and handles all possible input conversions (DTOs, URL params, etc.)
|
|
6
|
+
*/
|
|
7
|
+
export declare class WalletQuery extends QueryBuilder {
|
|
8
|
+
/**
|
|
9
|
+
* Create empty wallet query with defaults
|
|
10
|
+
*/
|
|
11
|
+
static create(): WalletQuery;
|
|
12
|
+
/**
|
|
13
|
+
* Create from typed DTO/filters object
|
|
14
|
+
*/
|
|
15
|
+
static fromFilters(filters: WalletQueryDTO): WalletQuery;
|
|
16
|
+
/**
|
|
17
|
+
* Create from URL search parameters (strings)
|
|
18
|
+
*/
|
|
19
|
+
static fromUrlParams(params: Record<string, string>): WalletQuery;
|
|
20
|
+
/**
|
|
21
|
+
* Create from URLSearchParams object
|
|
22
|
+
*/
|
|
23
|
+
static fromSearchParams(searchParams: URLSearchParams): WalletQuery;
|
|
24
|
+
/**
|
|
25
|
+
* Create from Next.js Request object
|
|
26
|
+
*/
|
|
27
|
+
static fromRequest(request: Request): WalletQuery;
|
|
28
|
+
/**
|
|
29
|
+
* Create from any supported input type
|
|
30
|
+
*/
|
|
31
|
+
static from(input: QueryBuilder | WalletQueryDTO | Record<string, string> | URLSearchParams | null | undefined): WalletQuery;
|
|
32
|
+
/**
|
|
33
|
+
* Type guard for string records
|
|
34
|
+
*/
|
|
35
|
+
private static isStringRecord;
|
|
36
|
+
whereId(id: string): this;
|
|
37
|
+
whereProfileId(profileId: string): this;
|
|
38
|
+
whereAccountNo(accountNo: string): this;
|
|
39
|
+
whereAccountName(accountName: string): this;
|
|
40
|
+
whereChannel(channel: string): this;
|
|
41
|
+
whereCountryCode(countryCode: string): this;
|
|
42
|
+
whereCurrencyCode(currencyCode: string): this;
|
|
43
|
+
/**
|
|
44
|
+
* Apply all filters from WalletQueryDTO object
|
|
45
|
+
*/
|
|
46
|
+
private applyFilters;
|
|
47
|
+
/**
|
|
48
|
+
* Convert to WalletQueryDTO
|
|
49
|
+
*/
|
|
50
|
+
toFilters(): WalletQueryDTO;
|
|
51
|
+
/**
|
|
52
|
+
* Convert to URL-safe string parameters
|
|
53
|
+
*/
|
|
54
|
+
toUrlParams(): Record<string, string>;
|
|
55
|
+
/**
|
|
56
|
+
* Convert to URLSearchParams
|
|
57
|
+
*/
|
|
58
|
+
toSearchParams(): URLSearchParams;
|
|
59
|
+
/**
|
|
60
|
+
* Convert to query string
|
|
61
|
+
*/
|
|
62
|
+
toQueryString(): string;
|
|
63
|
+
/**
|
|
64
|
+
* Create new instance with wallet ID filter
|
|
65
|
+
*/
|
|
66
|
+
withId(id: string): WalletQuery;
|
|
67
|
+
/**
|
|
68
|
+
* Create new instance with profile ID filter
|
|
69
|
+
*/
|
|
70
|
+
withProfileId(profileId: string): WalletQuery;
|
|
71
|
+
/**
|
|
72
|
+
* Create new instance with account number filter
|
|
73
|
+
*/
|
|
74
|
+
withAccountNo(accountNo: string): WalletQuery;
|
|
75
|
+
/**
|
|
76
|
+
* Create new instance with country code filter
|
|
77
|
+
*/
|
|
78
|
+
withCountryCode(countryCode: string): WalletQuery;
|
|
79
|
+
/**
|
|
80
|
+
* Create new instance with currency code filter
|
|
81
|
+
*/
|
|
82
|
+
withCurrencyCode(currencyCode: string): WalletQuery;
|
|
83
|
+
/**
|
|
84
|
+
* Check if any filters are applied
|
|
85
|
+
*/
|
|
86
|
+
hasFilters(): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Get human-readable filter descriptions
|
|
89
|
+
*/
|
|
90
|
+
getActiveFilters(): string[];
|
|
91
|
+
/**
|
|
92
|
+
* Extract filter values from QueryBuilder options
|
|
93
|
+
*/
|
|
94
|
+
private extractFilterValues;
|
|
95
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { Amount } from "@temboplus/frontend-core";
|
|
2
2
|
import { WalletStatementEntry } from "./statement-entry.model.js";
|
|
3
3
|
import { Wallet } from "./wallet.model.js";
|
|
4
|
-
import { WalletDTOSchemas } from "./wallet.dtos.js";
|
|
5
|
-
import { z } from "zod";
|
|
6
4
|
import { contract } from "./wallet.contract.js";
|
|
7
5
|
import { BaseRepository } from "@/lib/api/base-repository.js";
|
|
6
|
+
import { WalletQuery } from "./wallet.query.js";
|
|
7
|
+
import { WalletQueryDTO } from "./wallet.dtos.js";
|
|
8
|
+
/**
|
|
9
|
+
* Flexible query input type - supports the class, filters interface, URL params, etc.
|
|
10
|
+
*/
|
|
11
|
+
export type WalletQueryInput = WalletQuery | WalletQueryDTO | Record<string, string> | URLSearchParams | null | undefined;
|
|
8
12
|
/**
|
|
9
13
|
* Repository class for managing wallet operations including balance checking,
|
|
10
14
|
* statement generation, and wallet information retrieval.
|
|
@@ -87,13 +91,9 @@ export declare class WalletRepository extends BaseRepository<typeof contract> {
|
|
|
87
91
|
/**
|
|
88
92
|
* Retrieves all wallets associated with the authenticated user.
|
|
89
93
|
*
|
|
90
|
-
* Supports
|
|
91
|
-
* status, or currency filtering.
|
|
94
|
+
* Supports flexible filtering through WalletQuery or plain filter objects.
|
|
92
95
|
*
|
|
93
96
|
* @param query - Optional query parameters for filtering wallets
|
|
94
|
-
* @param query.accountNo - Filter by specific account number
|
|
95
|
-
* @param query.status - Filter by wallet status (active, inactive, etc.)
|
|
96
|
-
* @param query.currencyCode - Filter by currency code
|
|
97
97
|
* @returns Promise that resolves to an array of validated Wallet instances
|
|
98
98
|
* @throws {Error} If the wallet fetch operation fails or data is invalid
|
|
99
99
|
*
|
|
@@ -105,14 +105,38 @@ export declare class WalletRepository extends BaseRepository<typeof contract> {
|
|
|
105
105
|
* // Get specific wallet by account number
|
|
106
106
|
* const specificWallet = await repo.getWallets({ accountNo: '123456789' });
|
|
107
107
|
*
|
|
108
|
-
* // Get wallets with multiple filters
|
|
109
|
-
* const
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
108
|
+
* // Get wallets with multiple filters using WalletQuery
|
|
109
|
+
* const query = WalletQuery.create()
|
|
110
|
+
* .whereCountryCode('TZ')
|
|
111
|
+
* .whereCurrencyCode('TZS');
|
|
112
|
+
* const tzWallets = await repo.getWallets(query);
|
|
113
|
+
*
|
|
114
|
+
* // Get wallets with filters object
|
|
115
|
+
* const usdWallets = await repo.getWallets({ currencyCode: 'USD' });
|
|
113
116
|
* ```
|
|
114
117
|
*/
|
|
115
|
-
getWallets(query?:
|
|
118
|
+
getWallets(query?: WalletQueryInput): Promise<Wallet[]>;
|
|
119
|
+
/**
|
|
120
|
+
* Retrieves a single wallet by its ID.
|
|
121
|
+
*
|
|
122
|
+
* Since the API doesn't have a dedicated /id endpoint, this method queries
|
|
123
|
+
* the list endpoint with the ID filter and returns the first result.
|
|
124
|
+
*
|
|
125
|
+
* @param id - The unique identifier of the wallet to retrieve
|
|
126
|
+
* @returns Promise that resolves to the wallet if found, undefined otherwise
|
|
127
|
+
* @throws {Error} If the fetch operation fails
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const wallet = await repo.getByID("wallet-id");
|
|
132
|
+
* if (wallet) {
|
|
133
|
+
* console.log(`Wallet: ${wallet.accountName}`);
|
|
134
|
+
* } else {
|
|
135
|
+
* console.log('Wallet not found');
|
|
136
|
+
* }
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
getByID(id: string): Promise<Wallet | undefined>;
|
|
116
140
|
/**
|
|
117
141
|
* Retrieves wallet statement entries for a specified date range.
|
|
118
142
|
*
|
|
@@ -170,4 +194,12 @@ export declare class WalletRepository extends BaseRepository<typeof contract> {
|
|
|
170
194
|
wallet?: Wallet;
|
|
171
195
|
accountNo?: string;
|
|
172
196
|
}): Promise<WalletStatementEntry[]>;
|
|
197
|
+
/**
|
|
198
|
+
* Check if a wallet exists with the given query
|
|
199
|
+
*/
|
|
200
|
+
exists(query?: WalletQueryInput): Promise<boolean>;
|
|
201
|
+
/**
|
|
202
|
+
* Get count of wallets matching a query
|
|
203
|
+
*/
|
|
204
|
+
count(query?: WalletQueryInput): Promise<number>;
|
|
173
205
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temboplus/afloat",
|
|
3
|
-
"version": "0.1.77-beta.
|
|
3
|
+
"version": "0.1.77-beta.10",
|
|
4
4
|
"description": "A foundational library for Temboplus-Afloat projects.",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -58,6 +58,6 @@
|
|
|
58
58
|
"typescript": "^5.8.3"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@temboplus/frontend-core": "^0.2.
|
|
61
|
+
"@temboplus/frontend-core": "^0.2.20-beta.2"
|
|
62
62
|
}
|
|
63
63
|
}
|