@temboplus/afloat 0.2.0-beta.1 → 0.2.0-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/README.md +150 -238
- 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/lib/api/base-repository.d.ts +8 -8
- package/dist/lib/query/query.builder.d.ts +6 -1
- package/dist/modules/beneficiary/beneficiary-info.model.d.ts +82 -42
- package/dist/modules/beneficiary/beneficiary.model.d.ts +11 -2
- package/dist/modules/beneficiary/index.d.ts +2 -2
- package/dist/modules/login/permission.type.d.ts +2 -2
- package/dist/modules/payout/payout-channel-handler.d.ts +7 -6
- package/dist/modules/payout/payout.query.d.ts +54 -3
- package/dist/modules/wallet/narration.model.d.ts +2 -2
- package/dist/modules/wallet/wallet.query.d.ts +31 -0
- package/dist/modules/wallet/wallet.repository.d.ts +2 -2
- package/package.json +3 -4
|
@@ -6,24 +6,24 @@ export declare const setGlobalTokenGetter: (getter: TokenGetter) => void;
|
|
|
6
6
|
* BaseRepository - Generic base class for API repositories
|
|
7
7
|
*
|
|
8
8
|
* Provides a consistent way to interact with the Afloat API using ts-rest contracts.
|
|
9
|
-
* Handles authentication token management through
|
|
9
|
+
* Handles authentication token management through explicit repository options
|
|
10
|
+
* or a host-provided global token getter.
|
|
10
11
|
*
|
|
11
12
|
* **Token Resolution Order:**
|
|
12
13
|
* 1. Direct token provided in constructor
|
|
13
|
-
* 2. Global
|
|
14
|
+
* 2. Global token getter configured by the host app
|
|
14
15
|
*
|
|
15
16
|
* @template TContract - The API contract extending `AppRouter` from `@ts-rest/core`
|
|
16
17
|
*
|
|
17
18
|
* @example
|
|
18
19
|
* ```typescript
|
|
19
|
-
* //
|
|
20
|
+
* // Recommended authenticated usage
|
|
20
21
|
* const repo = new WalletRepository("wallet", walletContract, {
|
|
21
22
|
* token: "user-auth-token"
|
|
22
23
|
* });
|
|
23
24
|
*
|
|
24
|
-
* //
|
|
25
|
-
* //
|
|
26
|
-
* const repo = new WalletRepository("wallet", walletContract);
|
|
25
|
+
* // Advanced: the host app may also provide a global token getter,
|
|
26
|
+
* // but explicit tokens are the recommended integration path.
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export declare class BaseRepository<TContract extends AppRouter> {
|
|
@@ -64,8 +64,8 @@ export declare class BaseRepository<TContract extends AppRouter> {
|
|
|
64
64
|
* root: "https://api-staging.afloat.money/v1"
|
|
65
65
|
* });
|
|
66
66
|
*
|
|
67
|
-
* //
|
|
68
|
-
*
|
|
67
|
+
* // Advanced global token getter fallback is supported,
|
|
68
|
+
* // but explicit tokens are the recommended integration path.
|
|
69
69
|
* ```
|
|
70
70
|
*/
|
|
71
71
|
constructor(endpoint: string, contract: TContract, options?: {
|
|
@@ -64,7 +64,12 @@ export declare class QueryBuilder {
|
|
|
64
64
|
*/
|
|
65
65
|
countAs(expression: string, alias: string): this;
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
67
|
+
* Build the query into an objection-find compatible object.
|
|
68
|
+
*
|
|
69
|
+
* Pagination (rangeStart/rangeEnd) is only included if both `page` and `limit`
|
|
70
|
+
* have been explicitly set via `.paginate()` or in the constructor options.
|
|
71
|
+
*
|
|
72
|
+
* @returns An objection-find query object
|
|
68
73
|
*/
|
|
69
74
|
build(): Record<string, any>;
|
|
70
75
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BeneficiaryType, BeneficiaryDTO } from "@/modules/beneficiary/beneficiary.dtos.js";
|
|
2
2
|
import { PayoutDTO } from "@/modules/payout/payout.dtos.js";
|
|
3
|
-
import { Bank,
|
|
4
|
-
import type { BankSwiftCode,
|
|
3
|
+
import { Bank, PhoneNumber } from "@temboplus/frontend-core";
|
|
4
|
+
import type { BankSwiftCode, ISO2CountryCode, MobileMoneyProvider, MobileMoneyProviderId } from "@temboplus/frontend-core";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const MobileBeneficiaryJSONSchema: z.ZodObject<{
|
|
7
7
|
type: z.ZodLiteral<"Mobile">;
|
|
8
8
|
name: z.ZodString;
|
|
9
9
|
phoneNumber: z.ZodString;
|
|
@@ -22,7 +22,7 @@ export declare const MobileBeneficiaryInfoJSONSchema: z.ZodObject<{
|
|
|
22
22
|
mnoId: string;
|
|
23
23
|
version?: string | undefined;
|
|
24
24
|
}>;
|
|
25
|
-
export declare const
|
|
25
|
+
export declare const BankBeneficiaryJSONSchema: z.ZodObject<{
|
|
26
26
|
type: z.ZodLiteral<"Bank">;
|
|
27
27
|
accName: z.ZodString;
|
|
28
28
|
swiftCode: z.ZodString;
|
|
@@ -44,7 +44,7 @@ export declare const BankBeneficiaryInfoJSONSchema: z.ZodObject<{
|
|
|
44
44
|
accNo: string;
|
|
45
45
|
version?: string | undefined;
|
|
46
46
|
}>;
|
|
47
|
-
export declare const
|
|
47
|
+
export declare const BeneficiaryJSONSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
48
48
|
type: z.ZodLiteral<"Mobile">;
|
|
49
49
|
name: z.ZodString;
|
|
50
50
|
phoneNumber: z.ZodString;
|
|
@@ -84,17 +84,33 @@ export declare const BeneficiaryInfoJSONSchema: z.ZodDiscriminatedUnion<"type",
|
|
|
84
84
|
accNo: string;
|
|
85
85
|
version?: string | undefined;
|
|
86
86
|
}>]>;
|
|
87
|
-
export type
|
|
88
|
-
export type
|
|
89
|
-
export type
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
export type MobileBeneficiaryJSON = z.infer<typeof MobileBeneficiaryJSONSchema>;
|
|
88
|
+
export type BankBeneficiaryJSON = z.infer<typeof BankBeneficiaryJSONSchema>;
|
|
89
|
+
export type BeneficiaryJSON = z.infer<typeof BeneficiaryJSONSchema>;
|
|
90
|
+
export declare class BeneficiaryError extends Error {
|
|
91
|
+
readonly context: {
|
|
92
|
+
phoneNumber?: string;
|
|
93
|
+
countryCode?: ISO2CountryCode;
|
|
94
|
+
mnoId?: string;
|
|
95
|
+
operation?: string;
|
|
96
|
+
};
|
|
97
|
+
constructor(message: string, context?: {
|
|
98
|
+
phoneNumber?: string;
|
|
99
|
+
countryCode?: ISO2CountryCode;
|
|
100
|
+
mnoId?: string;
|
|
101
|
+
operation?: string;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
interface ValidationResult {
|
|
105
|
+
isValid: boolean;
|
|
106
|
+
errors: string[];
|
|
107
|
+
warnings: string[];
|
|
108
|
+
}
|
|
109
|
+
declare abstract class BaseBeneficiary {
|
|
94
110
|
readonly type: BeneficiaryType;
|
|
95
111
|
readonly countryCode: ISO2CountryCode;
|
|
96
|
-
constructor(type: BeneficiaryType, countryCode: ISO2CountryCode);
|
|
97
|
-
abstract get channelId():
|
|
112
|
+
protected constructor(type: BeneficiaryType, countryCode: ISO2CountryCode);
|
|
113
|
+
abstract get channelId(): MobileMoneyProviderId | BankSwiftCode;
|
|
98
114
|
abstract get channelName(): string;
|
|
99
115
|
abstract get accountName(): string;
|
|
100
116
|
abstract get accountNumber(): string;
|
|
@@ -102,54 +118,68 @@ declare abstract class BaseBeneficiaryInfo {
|
|
|
102
118
|
abstract get accountNumberLabel(): string;
|
|
103
119
|
abstract get channelLabel(): string;
|
|
104
120
|
abstract validate(): boolean;
|
|
105
|
-
abstract
|
|
121
|
+
abstract getValidationDetails(): ValidationResult;
|
|
122
|
+
abstract toJSON(): BeneficiaryJSON;
|
|
106
123
|
toJSONString(): string;
|
|
107
124
|
get isMobile(): boolean;
|
|
108
125
|
get isBank(): boolean;
|
|
109
126
|
get displayName(): string;
|
|
110
127
|
}
|
|
111
|
-
|
|
112
|
-
* Mobile beneficiary information implementation.
|
|
113
|
-
*/
|
|
114
|
-
export declare class MobileBeneficiaryInfo extends BaseBeneficiaryInfo {
|
|
128
|
+
export declare class MobileBeneficiaryInfo extends BaseBeneficiary {
|
|
115
129
|
readonly name: string;
|
|
116
130
|
readonly phoneNumber: PhoneNumber;
|
|
117
|
-
readonly mnoId:
|
|
118
|
-
constructor(name: string, phoneNumber: PhoneNumber, mnoId?:
|
|
131
|
+
readonly mnoId: MobileMoneyProviderId;
|
|
132
|
+
constructor(name: string, phoneNumber: PhoneNumber, mnoId?: MobileMoneyProviderId);
|
|
133
|
+
/**
|
|
134
|
+
* For prefix-detectable countries the MNO is always derived from the phone,
|
|
135
|
+
* so any caller-supplied id is intentionally ignored. For explicit-only
|
|
136
|
+
* countries, the supplied id is used as-is (validation happens later).
|
|
137
|
+
*/
|
|
138
|
+
private static resolveMnoId;
|
|
139
|
+
/**
|
|
140
|
+
* Single source of truth for input validity. Used by the constructor,
|
|
141
|
+
* validate(), and getValidationDetails().
|
|
142
|
+
*/
|
|
143
|
+
private static checkInputs;
|
|
144
|
+
/** Picks an MNO from a DTO `channel` field, or auto-detects when supported. */
|
|
145
|
+
private static pickMnoIdFromDTO;
|
|
119
146
|
static from(data: {
|
|
120
147
|
name: string;
|
|
121
148
|
phoneNumber: PhoneNumber;
|
|
122
|
-
mnoId?:
|
|
149
|
+
mnoId?: MobileMoneyProviderId;
|
|
123
150
|
}): MobileBeneficiaryInfo | undefined;
|
|
124
151
|
static fromBeneficiaryDTO(info: BeneficiaryDTO): MobileBeneficiaryInfo | undefined;
|
|
125
152
|
static fromPayoutDTO(info: PayoutDTO): MobileBeneficiaryInfo | undefined;
|
|
153
|
+
/**
|
|
154
|
+
* Pure runtime brand check — no rebuilding, no coercion. Use `fromJSON` to
|
|
155
|
+
* upgrade raw JSON shape into an instance.
|
|
156
|
+
*/
|
|
126
157
|
static is(obj: unknown): obj is MobileBeneficiaryInfo;
|
|
127
158
|
validate(): boolean;
|
|
128
|
-
getValidationDetails():
|
|
129
|
-
isValid: boolean;
|
|
130
|
-
errors: string[];
|
|
131
|
-
warnings: string[];
|
|
132
|
-
};
|
|
159
|
+
getValidationDetails(): ValidationResult;
|
|
133
160
|
get accountName(): string;
|
|
134
161
|
get accountNumber(): string;
|
|
135
162
|
get accountNameLabel(): string;
|
|
136
163
|
get accountNumberLabel(): string;
|
|
137
164
|
get channelLabel(): string;
|
|
138
|
-
get channelId():
|
|
165
|
+
get channelId(): MobileMoneyProviderId;
|
|
139
166
|
get channelName(): string;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
static
|
|
143
|
-
static
|
|
167
|
+
get mobileMoneyProvider(): MobileMoneyProvider | undefined;
|
|
168
|
+
toJSON(): MobileBeneficiaryJSON;
|
|
169
|
+
static fromJSON(json: MobileBeneficiaryJSON | string): MobileBeneficiaryInfo | undefined;
|
|
170
|
+
static fromJSONString(s: string): MobileBeneficiaryInfo | undefined;
|
|
171
|
+
static isJSON(obj: unknown): obj is MobileBeneficiaryJSON;
|
|
144
172
|
}
|
|
145
|
-
|
|
146
|
-
* Bank beneficiary information implementation.
|
|
147
|
-
*/
|
|
148
|
-
export declare class BankBeneficiaryInfo extends BaseBeneficiaryInfo {
|
|
173
|
+
export declare class BankBeneficiaryInfo extends BaseBeneficiary {
|
|
149
174
|
readonly accName: string;
|
|
150
175
|
readonly bank: Bank;
|
|
151
176
|
readonly accNo: string;
|
|
152
177
|
constructor(accName: string, bank: Bank, accNo: string);
|
|
178
|
+
/**
|
|
179
|
+
* Single source of truth for input validity. Used by the constructor,
|
|
180
|
+
* validate(), and getValidationDetails().
|
|
181
|
+
*/
|
|
182
|
+
private static checkInputs;
|
|
153
183
|
static from(data: {
|
|
154
184
|
accName: string;
|
|
155
185
|
bank: Bank;
|
|
@@ -159,6 +189,7 @@ export declare class BankBeneficiaryInfo extends BaseBeneficiaryInfo {
|
|
|
159
189
|
static fromPayoutDTO(info: PayoutDTO): BankBeneficiaryInfo | undefined;
|
|
160
190
|
static is(obj: unknown): obj is BankBeneficiaryInfo;
|
|
161
191
|
validate(): boolean;
|
|
192
|
+
getValidationDetails(): ValidationResult;
|
|
162
193
|
get accountName(): string;
|
|
163
194
|
get accountNumber(): string;
|
|
164
195
|
get accountNameLabel(): string;
|
|
@@ -166,13 +197,22 @@ export declare class BankBeneficiaryInfo extends BaseBeneficiaryInfo {
|
|
|
166
197
|
get channelLabel(): string;
|
|
167
198
|
get channelId(): BankSwiftCode;
|
|
168
199
|
get channelName(): string;
|
|
169
|
-
toJSON():
|
|
170
|
-
static fromJSON(json:
|
|
171
|
-
static fromJSONString(
|
|
172
|
-
static
|
|
200
|
+
toJSON(): BankBeneficiaryJSON;
|
|
201
|
+
static fromJSON(json: BankBeneficiaryJSON | string): BankBeneficiaryInfo | undefined;
|
|
202
|
+
static fromJSONString(s: string): BankBeneficiaryInfo | undefined;
|
|
203
|
+
static isJSON(obj: unknown): obj is BankBeneficiaryJSON;
|
|
173
204
|
}
|
|
205
|
+
export type BeneficiaryInfo = MobileBeneficiaryInfo | BankBeneficiaryInfo;
|
|
174
206
|
/**
|
|
175
|
-
*
|
|
207
|
+
* Top-level entry point for building / recognizing a beneficiary without
|
|
208
|
+
* caring about the variant. Each method dispatches on the discriminator.
|
|
176
209
|
*/
|
|
177
|
-
export
|
|
210
|
+
export declare const BeneficiaryInfo: {
|
|
211
|
+
fromBeneficiaryDTO(info: BeneficiaryDTO): BeneficiaryInfo | undefined;
|
|
212
|
+
fromPayoutDTO(info: PayoutDTO): BeneficiaryInfo | undefined;
|
|
213
|
+
fromJSON(json: BeneficiaryJSON | string): BeneficiaryInfo | undefined;
|
|
214
|
+
fromJSONString(s: string): BeneficiaryInfo | undefined;
|
|
215
|
+
is(obj: unknown): obj is BeneficiaryInfo;
|
|
216
|
+
isJSON(obj: unknown): obj is BeneficiaryJSON;
|
|
217
|
+
};
|
|
178
218
|
export {};
|
|
@@ -93,6 +93,8 @@ export type BeneficiaryJSON = z.infer<typeof BeneficiaryJSONSchema>;
|
|
|
93
93
|
*/
|
|
94
94
|
export declare class Beneficiary {
|
|
95
95
|
private readonly data;
|
|
96
|
+
private _info;
|
|
97
|
+
private _infoComputed;
|
|
96
98
|
/**
|
|
97
99
|
* Private constructor - use static factory methods to create instances.
|
|
98
100
|
*
|
|
@@ -148,6 +150,9 @@ export declare class Beneficiary {
|
|
|
148
150
|
* @remarks
|
|
149
151
|
* For mobile beneficiaries, constructs from phone number.
|
|
150
152
|
* For bank beneficiaries, constructs from SWIFT code and account number.
|
|
153
|
+
*
|
|
154
|
+
* Result is memoised — repeated accesses don't re-parse the phone number or
|
|
155
|
+
* re-resolve the bank.
|
|
151
156
|
*/
|
|
152
157
|
get info(): BeneficiaryInfo | undefined;
|
|
153
158
|
/**
|
|
@@ -275,7 +280,7 @@ export declare class Beneficiary {
|
|
|
275
280
|
*
|
|
276
281
|
* @static
|
|
277
282
|
* @param {unknown} obj - The value containing potential beneficiary data
|
|
278
|
-
* @returns {obj is
|
|
283
|
+
* @returns {obj is BeneficiaryDTO} Type predicate indicating the value is a valid BeneficiaryDTO
|
|
279
284
|
*
|
|
280
285
|
* @example
|
|
281
286
|
* ```typescript
|
|
@@ -288,8 +293,12 @@ export declare class Beneficiary {
|
|
|
288
293
|
*
|
|
289
294
|
* @remarks
|
|
290
295
|
* This method performs strict validation against the {@link BeneficiaryDTO} schema.
|
|
296
|
+
*
|
|
297
|
+
* The predicate narrows to {@link BeneficiaryDTO} (not `Beneficiary`) — what
|
|
298
|
+
* `obj` actually is on success — so callers don't accidentally try to use
|
|
299
|
+
* instance methods like `toJSON()` on a raw DTO.
|
|
291
300
|
*/
|
|
292
|
-
static canConstruct(obj: unknown): obj is
|
|
301
|
+
static canConstruct(obj: unknown): obj is BeneficiaryDTO;
|
|
293
302
|
/**
|
|
294
303
|
* Validates if an unknown value is a Beneficiary instance.
|
|
295
304
|
* This is a runtime type guard that ensures proper object structure and data validity.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./beneficiary.repository.js";
|
|
2
2
|
export * from "./beneficiary.dtos.js";
|
|
3
|
-
export
|
|
4
|
-
export
|
|
3
|
+
export { BankBeneficiaryInfo, BankBeneficiaryJSONSchema, BeneficiaryError, BeneficiaryInfo, BeneficiaryJSONSchema as BeneficiaryInfoJSONSchema, MobileBeneficiaryInfo, MobileBeneficiaryJSONSchema, type BankBeneficiaryJSON, type BeneficiaryJSON as BeneficiaryInfoJSON, type MobileBeneficiaryJSON, } from "./beneficiary-info.model.js";
|
|
4
|
+
export { Beneficiary, BeneficiaryJSONSchema, type BeneficiaryJSON, } from "./beneficiary.model.js";
|
|
5
5
|
export * from "./beneficiary-input-handler.js";
|
|
6
6
|
export * from "./beneficiary.api-contract.js";
|
|
@@ -6,7 +6,7 @@ export declare const Permissions: {
|
|
|
6
6
|
readonly ViewCurrent: "profile.getCurrent";
|
|
7
7
|
readonly Update: "profile.update";
|
|
8
8
|
};
|
|
9
|
-
readonly
|
|
9
|
+
readonly Beneficiary: {
|
|
10
10
|
readonly View: "contact.findById";
|
|
11
11
|
readonly List: "contact.findAll";
|
|
12
12
|
readonly Create: "contact.create";
|
|
@@ -51,4 +51,4 @@ export declare const Permissions: {
|
|
|
51
51
|
/**
|
|
52
52
|
* Permission Type
|
|
53
53
|
*/
|
|
54
|
-
export type Permission = (typeof Permissions.Profile)[keyof typeof Permissions.Profile] | (typeof Permissions.
|
|
54
|
+
export type Permission = (typeof Permissions.Profile)[keyof typeof Permissions.Profile] | (typeof Permissions.Beneficiary)[keyof typeof Permissions.Beneficiary] | (typeof Permissions.Payment)[keyof typeof Permissions.Payment] | (typeof Permissions.Payout)[keyof typeof Permissions.Payout] | (typeof Permissions.Transfer)[keyof typeof Permissions.Transfer] | (typeof Permissions.TeamManagement)[keyof typeof Permissions.TeamManagement] | (typeof Permissions.Role)[keyof typeof Permissions.Role] | (typeof Permissions.Wallet)[keyof typeof Permissions.Wallet];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Wallet } from "@/modules/wallet/wallet.model.js";
|
|
2
|
-
import { Amount,
|
|
2
|
+
import { Amount, PhoneNumber } from "@temboplus/frontend-core";
|
|
3
|
+
import type { ISO2CountryCode, MobileMoneyProviderId } from "@temboplus/frontend-core";
|
|
3
4
|
import { PayoutChannel, PayoutInputDTO } from "./payout.dtos.js";
|
|
4
5
|
import { BankBeneficiaryInfo, BeneficiaryInfo } from "../beneficiary/beneficiary-info.model.js";
|
|
5
6
|
/**
|
|
@@ -11,17 +12,17 @@ import { BankBeneficiaryInfo, BeneficiaryInfo } from "../beneficiary/beneficiary
|
|
|
11
12
|
*
|
|
12
13
|
* @see {@link PayoutChannelCodeFactory} for functions to generate valid codes
|
|
13
14
|
*/
|
|
14
|
-
export type PayoutChannelCode = `${
|
|
15
|
+
export type PayoutChannelCode = `${ISO2CountryCode}-${string}-B2C`;
|
|
15
16
|
/**
|
|
16
17
|
* Factory for creating standardized payout channel codes
|
|
17
18
|
*
|
|
18
19
|
* @example
|
|
19
20
|
* ```ts
|
|
20
21
|
* // Create bank channel code
|
|
21
|
-
* const bankCode = PayoutChannelCodeFactory.forBank(bankContactInfo); // Returns "TZ-BANK-B2C"
|
|
22
|
+
* const bankCode = PayoutChannelCodeFactory.forBank(bankContactInfo, wallet); // Returns "TZ-BANK-B2C"
|
|
22
23
|
*
|
|
23
24
|
* // Create mobile channel code
|
|
24
|
-
* const mobileCode = PayoutChannelCodeFactory.forMobile(phoneNumber); // Returns "TZ-VODACOM-B2C" for Vodacom number
|
|
25
|
+
* const mobileCode = PayoutChannelCodeFactory.forMobile(phoneNumber, mnoId, wallet); // Returns "TZ-VODACOM-B2C" for Vodacom number
|
|
25
26
|
* ```
|
|
26
27
|
*/
|
|
27
28
|
declare class PayoutChannelCodeFactory {
|
|
@@ -39,7 +40,7 @@ declare class PayoutChannelCodeFactory {
|
|
|
39
40
|
*
|
|
40
41
|
* @see {@link PhoneNumber} from "@temboplus/frontend-core" for phone number structure
|
|
41
42
|
*/
|
|
42
|
-
static forMobile(phoneNumber: PhoneNumber, mnoId:
|
|
43
|
+
static forMobile(phoneNumber: PhoneNumber, mnoId: MobileMoneyProviderId, wallet: Wallet): PayoutChannelCode;
|
|
43
44
|
}
|
|
44
45
|
/**
|
|
45
46
|
* Factory class for creating payout input DTOs based on channel and contact information
|
|
@@ -52,7 +53,7 @@ declare class PayoutChannelCodeFactory {
|
|
|
52
53
|
* receiver: mobileContactInfo,
|
|
53
54
|
* amount: new Amount(1000),
|
|
54
55
|
* notes: "Payment for services"
|
|
55
|
-
* });
|
|
56
|
+
* }, wallet);
|
|
56
57
|
* ```
|
|
57
58
|
*/
|
|
58
59
|
export declare class PayoutInputFactory {
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { QueryBuilder } from "@/lib/query/index.js";
|
|
2
2
|
import { PayoutStatus, PayoutApprovalStatus, PayoutFilters } from "./payout.dtos.js";
|
|
3
3
|
import { Amount } from "@temboplus/frontend-core";
|
|
4
|
+
/**
|
|
5
|
+
* Represents an active filter with its label and value
|
|
6
|
+
*/
|
|
7
|
+
export interface ActiveFilter {
|
|
8
|
+
label: string;
|
|
9
|
+
value: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DescribeFiltersOptions {
|
|
12
|
+
/** Custom date formatter function */
|
|
13
|
+
formatDate?: (date: string) => string;
|
|
14
|
+
}
|
|
4
15
|
/**
|
|
5
16
|
* Payout-specific query builder that extends the base QueryBuilder
|
|
6
17
|
* and handles all possible input conversions (DTOs, URL params, etc.)
|
|
@@ -108,9 +119,49 @@ export declare class PayoutQuery extends QueryBuilder {
|
|
|
108
119
|
*/
|
|
109
120
|
hasFilters(): boolean;
|
|
110
121
|
/**
|
|
111
|
-
* Get
|
|
112
|
-
|
|
113
|
-
|
|
122
|
+
* Get active filters as structured objects for programmatic use
|
|
123
|
+
* @param options - Formatting options
|
|
124
|
+
* @returns Array of ActiveFilter objects with label and value
|
|
125
|
+
*/
|
|
126
|
+
describeFilters(options?: DescribeFiltersOptions): ActiveFilter[];
|
|
127
|
+
/**
|
|
128
|
+
* Get active filters as human-readable strings for display
|
|
129
|
+
* @returns Array of formatted filter strings
|
|
130
|
+
*/
|
|
131
|
+
describeFiltersAsText(): string[];
|
|
132
|
+
/**
|
|
133
|
+
* Format sort field for display
|
|
134
|
+
*/
|
|
135
|
+
private formatSortField;
|
|
136
|
+
/**
|
|
137
|
+
* Build the query into an objection-find compatible object for payout queries.
|
|
138
|
+
*
|
|
139
|
+
* The output object contains:
|
|
140
|
+
* - Filters: Field conditions like `status:eq`, `createdAt:gte`, `payeeName:likeLower`
|
|
141
|
+
* - Sorting: `orderBy` and/or `orderByDesc` with comma-separated fields
|
|
142
|
+
* - Pagination: `rangeStart` and `rangeEnd` (only if `.paginate()` was called)
|
|
143
|
+
* - Relations: `eager` for included relations via `.with()` or `.includeDefaultRelations()`
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* // Paginated query
|
|
148
|
+
* const paged = PayoutQuery.create()
|
|
149
|
+
* .whereStatus(PayoutStatus.PAID)
|
|
150
|
+
* .paginate(1, 20)
|
|
151
|
+
* .build();
|
|
152
|
+
* // => { "status:eq": "PAID", rangeStart: 0, rangeEnd: 19 }
|
|
153
|
+
*
|
|
154
|
+
* // Unpaginated list (no rangeStart/rangeEnd)
|
|
155
|
+
* const all = PayoutQuery.create()
|
|
156
|
+
* .whereApproved()
|
|
157
|
+
* .orderByDesc("createdAt")
|
|
158
|
+
* .build();
|
|
159
|
+
* // => { "approvalStatus:eq": "APPROVED", orderByDesc: "createdAt" }
|
|
160
|
+
* ```
|
|
161
|
+
*
|
|
162
|
+
* @returns An objection-find query object
|
|
163
|
+
*/
|
|
164
|
+
build(): Record<string, any>;
|
|
114
165
|
/**
|
|
115
166
|
* Extract filter values from QueryBuilder options
|
|
116
167
|
*/
|
|
@@ -199,8 +199,8 @@ export declare class Narration {
|
|
|
199
199
|
*/
|
|
200
200
|
static is(obj: unknown): obj is Narration;
|
|
201
201
|
/**
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
* Serializes the Narration instance to a JSON-compatible object
|
|
203
|
+
*/
|
|
204
204
|
toJSON(): NarrationJSON;
|
|
205
205
|
/**
|
|
206
206
|
* Serializes the Narration instance to a JSON string
|
|
@@ -88,6 +88,37 @@ export declare class WalletQuery extends QueryBuilder {
|
|
|
88
88
|
* Get human-readable filter descriptions
|
|
89
89
|
*/
|
|
90
90
|
getActiveFilters(): string[];
|
|
91
|
+
/**
|
|
92
|
+
* Build the query into an objection-find compatible object for wallet queries.
|
|
93
|
+
*
|
|
94
|
+
* The output object contains:
|
|
95
|
+
* - Filters: Field conditions like `id:eq`, `profileId:eq`, `accountName:likeLower`
|
|
96
|
+
* - Sorting: `orderBy` and/or `orderByDesc` with comma-separated fields
|
|
97
|
+
* - Pagination: `rangeStart` and `rangeEnd` (only if `.paginate()` was called)
|
|
98
|
+
*
|
|
99
|
+
* Since wallets are typically fetched as complete lists (not paginated),
|
|
100
|
+
* pagination is usually omitted.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* // Get all wallets for a profile (no pagination)
|
|
105
|
+
* const query = WalletQuery.create()
|
|
106
|
+
* .whereProfileId("prof_123")
|
|
107
|
+
* .whereCurrencyCode("TZS")
|
|
108
|
+
* .build();
|
|
109
|
+
* // => { "profileId:eq": "prof_123", "currencyCode:eq": "TZS" }
|
|
110
|
+
*
|
|
111
|
+
* // Paginated wallet list (if needed)
|
|
112
|
+
* const paged = WalletQuery.create()
|
|
113
|
+
* .whereChannel("MOBILE")
|
|
114
|
+
* .paginate(1, 10)
|
|
115
|
+
* .build();
|
|
116
|
+
* // => { "channel:eq": "MOBILE", rangeStart: 0, rangeEnd: 9 }
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @returns An objection-find query object
|
|
120
|
+
*/
|
|
121
|
+
build(): Record<string, any>;
|
|
91
122
|
/**
|
|
92
123
|
* Extract filter values from QueryBuilder options
|
|
93
124
|
*/
|
|
@@ -24,8 +24,8 @@ export type WalletQueryInput = WalletQuery | WalletQueryDTO | Record<string, str
|
|
|
24
24
|
* const repo = new WalletRepository({ token: userToken });
|
|
25
25
|
* const balance = await repo.getBalance({ wallet });
|
|
26
26
|
*
|
|
27
|
-
* //
|
|
28
|
-
* const repo = new WalletRepository();
|
|
27
|
+
* // Reuse the same construction shape for authenticated calls
|
|
28
|
+
* const repo = new WalletRepository({ token: userToken });
|
|
29
29
|
* const wallets = await repo.getWallets();
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temboplus/afloat",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-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",
|
|
@@ -40,8 +40,7 @@
|
|
|
40
40
|
"@ts-rest/core": "^3.52.1",
|
|
41
41
|
"tslib": "^2.8.1",
|
|
42
42
|
"uuid": "^11.1.0",
|
|
43
|
-
"zod": "^3.24.2"
|
|
44
|
-
"zustand": "^5.0.9"
|
|
43
|
+
"zod": "^3.24.2"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"@rollup/plugin-alias": "^6.0.0",
|
|
@@ -58,6 +57,6 @@
|
|
|
58
57
|
"typescript": "^5.9.3"
|
|
59
58
|
},
|
|
60
59
|
"dependencies": {
|
|
61
|
-
"@temboplus/frontend-core": "^0.
|
|
60
|
+
"@temboplus/frontend-core": "^1.0.1-beta.2"
|
|
62
61
|
}
|
|
63
62
|
}
|