@temboplus/afloat 0.2.1-beta.1 → 0.2.1-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/company-membership.model.d.ts +5 -5
- package/dist/modules/auth/user.model.d.ts +5 -5
- package/dist/modules/beneficiary/beneficiary-info.model.d.ts +22 -13
- package/dist/modules/beneficiary/beneficiary.dtos.d.ts +4 -4
- package/dist/modules/beneficiary/beneficiary.model.d.ts +1 -1
- package/dist/modules/payout/payout-channel-handler.d.ts +119 -53
- package/dist/modules/payout/payout.api-contract.d.ts +3 -3
- package/dist/modules/payout/payout.dtos.d.ts +30 -10
- package/dist/modules/payout/payout.query.d.ts +1 -1
- package/dist/modules/payout/payout.repository.d.ts +7 -6
- package/dist/modules/team-member/role.model.d.ts +4 -4
- package/dist/modules/team-member/team-member.contract.d.ts +48 -34
- package/dist/modules/team-member/team-member.dtos.d.ts +8 -8
- package/dist/modules/team-member/team-member.model.d.ts +5 -5
- package/package.json +1 -1
|
@@ -39,7 +39,7 @@ export declare const CompanyMembershipJSONSchema: z.ZodObject<{
|
|
|
39
39
|
role: z.ZodOptional<z.ZodObject<{
|
|
40
40
|
id: z.ZodString;
|
|
41
41
|
name: z.ZodString;
|
|
42
|
-
description: z.ZodOptional<z.ZodString
|
|
42
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
43
43
|
access: z.ZodArray<z.ZodString, "many">;
|
|
44
44
|
createdAt: z.ZodString;
|
|
45
45
|
updatedAt: z.ZodString;
|
|
@@ -51,7 +51,7 @@ export declare const CompanyMembershipJSONSchema: z.ZodObject<{
|
|
|
51
51
|
_version: string;
|
|
52
52
|
updatedAt: string;
|
|
53
53
|
access: string[];
|
|
54
|
-
description?: string | undefined;
|
|
54
|
+
description?: string | null | undefined;
|
|
55
55
|
}, {
|
|
56
56
|
name: string;
|
|
57
57
|
createdAt: string;
|
|
@@ -59,7 +59,7 @@ export declare const CompanyMembershipJSONSchema: z.ZodObject<{
|
|
|
59
59
|
updatedAt: string;
|
|
60
60
|
access: string[];
|
|
61
61
|
_version?: string | undefined;
|
|
62
|
-
description?: string | undefined;
|
|
62
|
+
description?: string | null | undefined;
|
|
63
63
|
}>>;
|
|
64
64
|
_version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
65
65
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -82,7 +82,7 @@ export declare const CompanyMembershipJSONSchema: z.ZodObject<{
|
|
|
82
82
|
_version: string;
|
|
83
83
|
updatedAt: string;
|
|
84
84
|
access: string[];
|
|
85
|
-
description?: string | undefined;
|
|
85
|
+
description?: string | null | undefined;
|
|
86
86
|
} | undefined;
|
|
87
87
|
}, {
|
|
88
88
|
companyProfile: {
|
|
@@ -104,7 +104,7 @@ export declare const CompanyMembershipJSONSchema: z.ZodObject<{
|
|
|
104
104
|
updatedAt: string;
|
|
105
105
|
access: string[];
|
|
106
106
|
_version?: string | undefined;
|
|
107
|
-
description?: string | undefined;
|
|
107
|
+
description?: string | null | undefined;
|
|
108
108
|
} | undefined;
|
|
109
109
|
}>;
|
|
110
110
|
export type CompanyMembershipJSON = z.infer<typeof CompanyMembershipJSONSchema>;
|
|
@@ -85,7 +85,7 @@ export declare const UserJSONSchema: z.ZodObject<{
|
|
|
85
85
|
role: z.ZodOptional<z.ZodObject<{
|
|
86
86
|
id: z.ZodString;
|
|
87
87
|
name: z.ZodString;
|
|
88
|
-
description: z.ZodOptional<z.ZodString
|
|
88
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
89
89
|
access: z.ZodArray<z.ZodString, "many">;
|
|
90
90
|
createdAt: z.ZodString;
|
|
91
91
|
updatedAt: z.ZodString;
|
|
@@ -97,7 +97,7 @@ export declare const UserJSONSchema: z.ZodObject<{
|
|
|
97
97
|
_version: string;
|
|
98
98
|
updatedAt: string;
|
|
99
99
|
access: string[];
|
|
100
|
-
description?: string | undefined;
|
|
100
|
+
description?: string | null | undefined;
|
|
101
101
|
}, {
|
|
102
102
|
name: string;
|
|
103
103
|
createdAt: string;
|
|
@@ -105,7 +105,7 @@ export declare const UserJSONSchema: z.ZodObject<{
|
|
|
105
105
|
updatedAt: string;
|
|
106
106
|
access: string[];
|
|
107
107
|
_version?: string | undefined;
|
|
108
|
-
description?: string | undefined;
|
|
108
|
+
description?: string | null | undefined;
|
|
109
109
|
}>>;
|
|
110
110
|
_version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
111
111
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -143,7 +143,7 @@ export declare const UserJSONSchema: z.ZodObject<{
|
|
|
143
143
|
_version: string;
|
|
144
144
|
updatedAt: string;
|
|
145
145
|
access: string[];
|
|
146
|
-
description?: string | undefined;
|
|
146
|
+
description?: string | null | undefined;
|
|
147
147
|
} | undefined;
|
|
148
148
|
}, {
|
|
149
149
|
companyProfile: {
|
|
@@ -180,7 +180,7 @@ export declare const UserJSONSchema: z.ZodObject<{
|
|
|
180
180
|
updatedAt: string;
|
|
181
181
|
access: string[];
|
|
182
182
|
_version?: string | undefined;
|
|
183
|
-
description?: string | undefined;
|
|
183
|
+
description?: string | null | undefined;
|
|
184
184
|
} | undefined;
|
|
185
185
|
}>;
|
|
186
186
|
/**
|
|
@@ -5,40 +5,40 @@ import { Bank, PhoneNumber } from "@temboplus/frontend-core";
|
|
|
5
5
|
import type { BankSwiftCode, ISO2CountryCode, MobileMoneyProvider, MobileMoneyProviderId } from "@temboplus/frontend-core";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
export declare const MobileBeneficiaryJSONSchema: z.ZodObject<{
|
|
8
|
-
type: z.ZodLiteral<BeneficiaryType.
|
|
8
|
+
type: z.ZodLiteral<BeneficiaryType.MOBILE>;
|
|
9
9
|
name: z.ZodString;
|
|
10
10
|
phoneNumber: z.ZodString;
|
|
11
11
|
mnoId: z.ZodUnion<[z.ZodEnum<["VODACOM", "AIRTEL", "TIGO", "HALOTEL"]>, z.ZodEnum<["SAFARICOM"]>]>;
|
|
12
12
|
_version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
13
13
|
}, "strip", z.ZodTypeAny, {
|
|
14
|
-
type: BeneficiaryType.
|
|
14
|
+
type: BeneficiaryType.MOBILE;
|
|
15
15
|
name: string;
|
|
16
16
|
_version: string;
|
|
17
17
|
phoneNumber: string;
|
|
18
18
|
mnoId: "VODACOM" | "AIRTEL" | "TIGO" | "HALOTEL" | "SAFARICOM";
|
|
19
19
|
}, {
|
|
20
|
-
type: BeneficiaryType.
|
|
20
|
+
type: BeneficiaryType.MOBILE;
|
|
21
21
|
name: string;
|
|
22
22
|
phoneNumber: string;
|
|
23
23
|
mnoId: "VODACOM" | "AIRTEL" | "TIGO" | "HALOTEL" | "SAFARICOM";
|
|
24
24
|
_version?: string | undefined;
|
|
25
25
|
}>;
|
|
26
26
|
export declare const BankBeneficiaryJSONSchema: z.ZodObject<{
|
|
27
|
-
type: z.ZodLiteral<BeneficiaryType.
|
|
27
|
+
type: z.ZodLiteral<BeneficiaryType.BANK>;
|
|
28
28
|
accName: z.ZodString;
|
|
29
29
|
swiftCode: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
30
30
|
countryCode: z.ZodEffects<z.ZodString, string, string>;
|
|
31
31
|
accNo: z.ZodString;
|
|
32
32
|
_version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
33
33
|
}, "strip", z.ZodTypeAny, {
|
|
34
|
-
type: BeneficiaryType.
|
|
34
|
+
type: BeneficiaryType.BANK;
|
|
35
35
|
_version: string;
|
|
36
36
|
countryCode: string;
|
|
37
37
|
accName: string;
|
|
38
38
|
swiftCode: string;
|
|
39
39
|
accNo: string;
|
|
40
40
|
}, {
|
|
41
|
-
type: BeneficiaryType.
|
|
41
|
+
type: BeneficiaryType.BANK;
|
|
42
42
|
countryCode: string;
|
|
43
43
|
accName: string;
|
|
44
44
|
swiftCode: string;
|
|
@@ -46,39 +46,39 @@ export declare const BankBeneficiaryJSONSchema: z.ZodObject<{
|
|
|
46
46
|
_version?: string | undefined;
|
|
47
47
|
}>;
|
|
48
48
|
export declare const BeneficiaryJSONSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
49
|
-
type: z.ZodLiteral<BeneficiaryType.
|
|
49
|
+
type: z.ZodLiteral<BeneficiaryType.MOBILE>;
|
|
50
50
|
name: z.ZodString;
|
|
51
51
|
phoneNumber: z.ZodString;
|
|
52
52
|
mnoId: z.ZodUnion<[z.ZodEnum<["VODACOM", "AIRTEL", "TIGO", "HALOTEL"]>, z.ZodEnum<["SAFARICOM"]>]>;
|
|
53
53
|
_version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
54
54
|
}, "strip", z.ZodTypeAny, {
|
|
55
|
-
type: BeneficiaryType.
|
|
55
|
+
type: BeneficiaryType.MOBILE;
|
|
56
56
|
name: string;
|
|
57
57
|
_version: string;
|
|
58
58
|
phoneNumber: string;
|
|
59
59
|
mnoId: "VODACOM" | "AIRTEL" | "TIGO" | "HALOTEL" | "SAFARICOM";
|
|
60
60
|
}, {
|
|
61
|
-
type: BeneficiaryType.
|
|
61
|
+
type: BeneficiaryType.MOBILE;
|
|
62
62
|
name: string;
|
|
63
63
|
phoneNumber: string;
|
|
64
64
|
mnoId: "VODACOM" | "AIRTEL" | "TIGO" | "HALOTEL" | "SAFARICOM";
|
|
65
65
|
_version?: string | undefined;
|
|
66
66
|
}>, z.ZodObject<{
|
|
67
|
-
type: z.ZodLiteral<BeneficiaryType.
|
|
67
|
+
type: z.ZodLiteral<BeneficiaryType.BANK>;
|
|
68
68
|
accName: z.ZodString;
|
|
69
69
|
swiftCode: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>;
|
|
70
70
|
countryCode: z.ZodEffects<z.ZodString, string, string>;
|
|
71
71
|
accNo: z.ZodString;
|
|
72
72
|
_version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
73
73
|
}, "strip", z.ZodTypeAny, {
|
|
74
|
-
type: BeneficiaryType.
|
|
74
|
+
type: BeneficiaryType.BANK;
|
|
75
75
|
_version: string;
|
|
76
76
|
countryCode: string;
|
|
77
77
|
accName: string;
|
|
78
78
|
swiftCode: string;
|
|
79
79
|
accNo: string;
|
|
80
80
|
}, {
|
|
81
|
-
type: BeneficiaryType.
|
|
81
|
+
type: BeneficiaryType.BANK;
|
|
82
82
|
countryCode: string;
|
|
83
83
|
accName: string;
|
|
84
84
|
swiftCode: string;
|
|
@@ -88,6 +88,7 @@ export declare const BeneficiaryJSONSchema: z.ZodDiscriminatedUnion<"type", [z.Z
|
|
|
88
88
|
export type MobileBeneficiaryJSON = z.infer<typeof MobileBeneficiaryJSONSchema>;
|
|
89
89
|
export type BankBeneficiaryJSON = z.infer<typeof BankBeneficiaryJSONSchema>;
|
|
90
90
|
export type BeneficiaryJSON = z.infer<typeof BeneficiaryJSONSchema>;
|
|
91
|
+
type BeneficiaryInfoDTO = BeneficiaryInputDTO | BeneficiaryDTO;
|
|
91
92
|
export declare class BeneficiaryError extends Error {
|
|
92
93
|
readonly context: {
|
|
93
94
|
phoneNumber?: string;
|
|
@@ -144,6 +145,14 @@ export declare class MobileBeneficiaryInfo extends BaseBeneficiary {
|
|
|
144
145
|
private static checkInputs;
|
|
145
146
|
/** Picks an MNO from a DTO `channel` field, or auto-detects when supported. */
|
|
146
147
|
private static pickMnoIdFromDTO;
|
|
148
|
+
/**
|
|
149
|
+
* Extracts a mobile provider id from an upstream payout channel code.
|
|
150
|
+
*
|
|
151
|
+
* @param countryCode - Beneficiary phone country code.
|
|
152
|
+
* @param channel - Candidate channel value from a beneficiary or payout DTO.
|
|
153
|
+
* @returns The provider id encoded in a mobile B2C channel, or `undefined` when the value is not a mobile channel.
|
|
154
|
+
*/
|
|
155
|
+
private static pickMnoIdFromPayoutChannel;
|
|
147
156
|
static from(data: {
|
|
148
157
|
name: string;
|
|
149
158
|
phoneNumber: PhoneNumber;
|
|
@@ -218,7 +227,7 @@ export declare class BeneficiaryInfoFactory {
|
|
|
218
227
|
static fromJSONString(s: string): BeneficiaryInfo | undefined;
|
|
219
228
|
static is(obj: unknown): obj is BeneficiaryInfo;
|
|
220
229
|
static isJSON(obj: unknown): obj is BeneficiaryJSON;
|
|
221
|
-
|
|
230
|
+
static fromDTO(info: BeneficiaryInfoDTO): BeneficiaryInfo | undefined;
|
|
222
231
|
}
|
|
223
232
|
/**
|
|
224
233
|
* @deprecated Use BeneficiaryInfoFactory instead.
|
|
@@ -4,14 +4,14 @@ import { z } from "zod";
|
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
6
|
* Currently supports two channel types:
|
|
7
|
-
* - "Bank": For traditional banking
|
|
8
|
-
* - "Mobile": For mobile money
|
|
7
|
+
* - "Bank": For traditional banking beneficiaries
|
|
8
|
+
* - "Mobile": For mobile money beneficiaries
|
|
9
9
|
*
|
|
10
10
|
* @see {@link BeneficiaryType} for the inferred type
|
|
11
11
|
*/
|
|
12
12
|
export declare enum BeneficiaryType {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
BANK = "Bank",
|
|
14
|
+
MOBILE = "Mobile"
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Type representing user-provided beneficiary information.
|
|
@@ -1,83 +1,149 @@
|
|
|
1
1
|
import { Wallet } from "@/modules/wallet/wallet.model.js";
|
|
2
|
-
import { Amount, PhoneNumber } from "@temboplus/frontend-core";
|
|
2
|
+
import { Amount, ChannelType, PhoneNumber } from "@temboplus/frontend-core";
|
|
3
3
|
import type { ISO2CountryCode, MobileMoneyProviderId } from "@temboplus/frontend-core";
|
|
4
4
|
import { PayoutChannel, PayoutInputDTO } from "./payout.dtos.js";
|
|
5
5
|
import { BankBeneficiaryInfo, BeneficiaryInfo } from "../beneficiary/beneficiary-info.model.js";
|
|
6
|
+
export type PayoutChannelCode = PayoutChannel;
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* Resolves the upstream payout channel owned by the library.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* - `${countryCode}-${telecom}-B2C`: Pattern for mobile money transfers where the telecom company is the provider code
|
|
12
|
-
*
|
|
13
|
-
* @see {@link PayoutChannelCodeFactory} for functions to generate valid codes
|
|
14
|
-
*/
|
|
15
|
-
export type PayoutChannelCode = `${ISO2CountryCode}-${string}-B2C`;
|
|
16
|
-
/**
|
|
17
|
-
* Factory for creating standardized payout channel codes
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* // Create bank channel code
|
|
22
|
-
* const bankCode = PayoutChannelCodeFactory.forBank(bankContactInfo, wallet); // Returns "TZ-BANK-B2C"
|
|
23
|
-
*
|
|
24
|
-
* // Create mobile channel code
|
|
25
|
-
* const mobileCode = PayoutChannelCodeFactory.forMobile(phoneNumber, mnoId, wallet); // Returns "TZ-VODACOM-B2C" for Vodacom number
|
|
26
|
-
* ```
|
|
10
|
+
* Consumers provide wallet, beneficiary, and amount details only. This resolver
|
|
11
|
+
* applies Tembo routing rules and returns the concrete upstream B2C channel.
|
|
27
12
|
*/
|
|
28
|
-
declare class
|
|
13
|
+
export declare class PayoutChannelResolver {
|
|
14
|
+
/**
|
|
15
|
+
* Resolves the upstream payout channel for a payout.
|
|
16
|
+
*
|
|
17
|
+
* @param args - Payout routing inputs.
|
|
18
|
+
* @param args.wallet - Wallet paying out; its country and currency define the corridor.
|
|
19
|
+
* @param args.receiver - Beneficiary receiving the payout.
|
|
20
|
+
* @param args.amount - Amount being paid out; its currency must match the wallet/country.
|
|
21
|
+
* @returns The concrete upstream channel code to send to the payout API.
|
|
22
|
+
* @throws Error when wallet, receiver, amount, or supported-country details are incompatible.
|
|
23
|
+
*/
|
|
24
|
+
static resolve(args: {
|
|
25
|
+
wallet: Wallet;
|
|
26
|
+
receiver: BeneficiaryInfo;
|
|
27
|
+
amount: Amount;
|
|
28
|
+
}): PayoutChannel;
|
|
29
|
+
/**
|
|
30
|
+
* Resolves a bank beneficiary to the upstream bank payout channel.
|
|
31
|
+
*
|
|
32
|
+
* @param receiver - Valid bank beneficiary details containing bank and account information.
|
|
33
|
+
* @param wallet - Wallet paying out; its country must match the beneficiary country.
|
|
34
|
+
* @returns `TZ-BANK-B2C` or `KE-BANK-B2C`.
|
|
35
|
+
* @throws Error when the beneficiary is invalid, unsupported, or in a different country from the wallet.
|
|
36
|
+
*/
|
|
37
|
+
static forBank(receiver: BankBeneficiaryInfo, wallet: Wallet): PayoutChannel;
|
|
38
|
+
/**
|
|
39
|
+
* Resolves a mobile money beneficiary to the upstream mobile payout channel.
|
|
40
|
+
*
|
|
41
|
+
* Routing rules:
|
|
42
|
+
* - All Kenya mobile money payouts route through `KE-SAFARICOM-B2C`.
|
|
43
|
+
* - Tanzania Vodacom mobile numbers route through `TZ-TIGO-B2C`.
|
|
44
|
+
* - Tanzania Tigo, Airtel, and Halotel route through their matching upstream channels.
|
|
45
|
+
*
|
|
46
|
+
* @param phoneNumber - Parsed mobile beneficiary phone number.
|
|
47
|
+
* @param mnoId - Beneficiary mobile money provider id.
|
|
48
|
+
* @param wallet - Wallet paying out; its country must match the phone number country.
|
|
49
|
+
* @returns The concrete upstream mobile money payout channel.
|
|
50
|
+
* @throws Error when the phone, provider, country, or wallet corridor is invalid or unsupported.
|
|
51
|
+
*/
|
|
52
|
+
static forMobile(phoneNumber: PhoneNumber, mnoId: MobileMoneyProviderId, wallet: Wallet): PayoutChannel;
|
|
53
|
+
/**
|
|
54
|
+
* Converts a concrete payout channel into the generic coverage channel type.
|
|
55
|
+
*
|
|
56
|
+
* @param channel - Concrete upstream payout channel.
|
|
57
|
+
* @returns `ChannelType.BANK` for bank channels; otherwise `ChannelType.MOBILE_MONEY`.
|
|
58
|
+
*/
|
|
59
|
+
static getChannelType(channel: PayoutChannel): ChannelType;
|
|
60
|
+
/**
|
|
61
|
+
* Extracts the country code prefix from a payout channel.
|
|
62
|
+
*
|
|
63
|
+
* @param channel - Concrete upstream payout channel.
|
|
64
|
+
* @returns ISO-2 country code embedded in the channel.
|
|
65
|
+
*/
|
|
66
|
+
static getCountryCode(channel: PayoutChannel): ISO2CountryCode;
|
|
67
|
+
/**
|
|
68
|
+
* Extracts the mobile provider segment from a mobile payout channel.
|
|
69
|
+
*
|
|
70
|
+
* @param channel - Concrete upstream payout channel.
|
|
71
|
+
* @returns Provider id for mobile money channels; `undefined` for bank channels.
|
|
72
|
+
*/
|
|
73
|
+
static getProviderId(channel: PayoutChannel): MobileMoneyProviderId | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Checks whether a concrete payout channel is a bank channel.
|
|
76
|
+
*
|
|
77
|
+
* @param channel - Concrete upstream payout channel.
|
|
78
|
+
* @returns `true` for `*-BANK-B2C` channels; otherwise `false`.
|
|
79
|
+
*/
|
|
80
|
+
static isBankChannel(channel: PayoutChannel): boolean;
|
|
29
81
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @
|
|
82
|
+
* Checks whether a concrete payout channel is a mobile money channel.
|
|
83
|
+
*
|
|
84
|
+
* @param channel - Concrete upstream payout channel.
|
|
85
|
+
* @returns `true` for mobile money channels; otherwise `false`.
|
|
33
86
|
*/
|
|
34
|
-
static
|
|
87
|
+
static isMobileMoneyChannel(channel: PayoutChannel): boolean;
|
|
35
88
|
/**
|
|
36
|
-
*
|
|
37
|
-
* @param phoneNumber - Phone number object containing telecom information
|
|
38
|
-
* @returns {PayoutChannelCode} Channel code in format "TZ-{TELECOM}-B2C"
|
|
39
|
-
* @throws {Error} If phone number is invalid or country is not supported
|
|
89
|
+
* Ensures the payout is internally consistent before resolving a channel.
|
|
40
90
|
*
|
|
41
|
-
* @
|
|
91
|
+
* @param wallet - Wallet paying out.
|
|
92
|
+
* @param receiver - Beneficiary receiving the payout.
|
|
93
|
+
* @param amount - Amount being paid out.
|
|
94
|
+
* @returns Nothing when validation passes.
|
|
95
|
+
* @throws Error when wallet country, receiver country, wallet currency, or amount currency do not align.
|
|
42
96
|
*/
|
|
43
|
-
static
|
|
97
|
+
private static assertCompatibleWalletReceiverAndAmount;
|
|
44
98
|
}
|
|
45
99
|
/**
|
|
46
|
-
*
|
|
100
|
+
* Builds the upstream payout API body from domain models.
|
|
47
101
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* const factory = new PayoutInputFactory();
|
|
51
|
-
* const payoutInput = factory.getPayoutInput({
|
|
52
|
-
* channel: PayoutChannel.MOBILE,
|
|
53
|
-
* receiver: mobileContactInfo,
|
|
54
|
-
* amount: new Amount(1000),
|
|
55
|
-
* notes: "Payment for services"
|
|
56
|
-
* }, wallet);
|
|
57
|
-
* ```
|
|
102
|
+
* The factory owns channel resolution; callers provide only wallet, receiver,
|
|
103
|
+
* amount, and optional notes.
|
|
58
104
|
*/
|
|
59
105
|
export declare class PayoutInputFactory {
|
|
60
|
-
private readonly handlers;
|
|
61
106
|
/**
|
|
62
|
-
* Creates
|
|
107
|
+
* Creates the DTO expected by the upstream payout API.
|
|
63
108
|
*
|
|
64
|
-
* @param args -
|
|
65
|
-
* @
|
|
66
|
-
* @
|
|
109
|
+
* @param args - Payout input fields controlled by the consumer.
|
|
110
|
+
* @param args.receiver - Beneficiary receiving the payout.
|
|
111
|
+
* @param args.amount - Amount to pay out.
|
|
112
|
+
* @param args.notes - Optional note used as narration when present.
|
|
113
|
+
* @param wallet - Wallet paying out.
|
|
114
|
+
* @returns Complete payout API input including the library-resolved channel.
|
|
115
|
+
* @throws Error when the receiver cannot be routed or validation fails.
|
|
67
116
|
*/
|
|
68
117
|
getPayoutInput(args: {
|
|
69
|
-
channel: PayoutChannel;
|
|
70
118
|
receiver: BeneficiaryInfo;
|
|
71
119
|
amount: Amount;
|
|
72
120
|
notes?: string;
|
|
73
121
|
}, wallet: Wallet): PayoutInputDTO;
|
|
122
|
+
/**
|
|
123
|
+
* Builds the upstream payout DTO for a mobile money beneficiary.
|
|
124
|
+
*
|
|
125
|
+
* @param receiver - Valid mobile beneficiary.
|
|
126
|
+
* @param amount - Amount to pay out.
|
|
127
|
+
* @param channel - Resolved upstream mobile money payout channel.
|
|
128
|
+
* @param notes - Optional note used as narration when present.
|
|
129
|
+
* @returns Complete mobile money payout API input.
|
|
130
|
+
*/
|
|
131
|
+
private createMobileInput;
|
|
132
|
+
/**
|
|
133
|
+
* Builds the upstream payout DTO for a bank beneficiary.
|
|
134
|
+
*
|
|
135
|
+
* @param receiver - Valid bank beneficiary.
|
|
136
|
+
* @param amount - Amount to pay out.
|
|
137
|
+
* @param channel - Resolved upstream bank payout channel.
|
|
138
|
+
* @param notes - Optional note used as narration when present.
|
|
139
|
+
* @returns Complete bank payout API input.
|
|
140
|
+
*/
|
|
141
|
+
private createBankInput;
|
|
74
142
|
}
|
|
75
143
|
/**
|
|
76
|
-
* @deprecated Use
|
|
77
|
-
* @see {@link PayoutChannelCodeFactory}
|
|
144
|
+
* @deprecated Use PayoutChannelResolver instead.
|
|
78
145
|
*/
|
|
79
146
|
export declare const createPayoutChannelCode: {
|
|
80
|
-
bank: typeof
|
|
81
|
-
mobile: typeof
|
|
147
|
+
bank: typeof PayoutChannelResolver.forBank;
|
|
148
|
+
mobile: typeof PayoutChannelResolver.forMobile;
|
|
82
149
|
};
|
|
83
|
-
export {};
|
|
@@ -402,7 +402,7 @@ export declare const contract: {
|
|
|
402
402
|
postPayout: {
|
|
403
403
|
method: "POST";
|
|
404
404
|
body: z.ZodObject<{
|
|
405
|
-
channel: z.
|
|
405
|
+
channel: z.ZodNativeEnum<typeof import("./payout.dtos.js").PayoutChannel>;
|
|
406
406
|
msisdn: z.ZodString;
|
|
407
407
|
amount: z.ZodNumber;
|
|
408
408
|
description: z.ZodString;
|
|
@@ -411,14 +411,14 @@ export declare const contract: {
|
|
|
411
411
|
payeeName: z.ZodString;
|
|
412
412
|
}, "strip", z.ZodTypeAny, {
|
|
413
413
|
description: string;
|
|
414
|
-
channel:
|
|
414
|
+
channel: import("./payout.dtos.js").PayoutChannel;
|
|
415
415
|
msisdn: string;
|
|
416
416
|
amount: number;
|
|
417
417
|
payeeName: string;
|
|
418
418
|
notes?: string | null | undefined;
|
|
419
419
|
}, {
|
|
420
420
|
description: string;
|
|
421
|
-
channel:
|
|
421
|
+
channel: import("./payout.dtos.js").PayoutChannel;
|
|
422
422
|
msisdn: string;
|
|
423
423
|
amount: number;
|
|
424
424
|
payeeName: string;
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
/**
|
|
3
3
|
* Represents the available channels through which payouts can be processed.
|
|
4
|
+
*
|
|
5
|
+
* These values are the upstream API channel codes, not beneficiary categories.
|
|
6
|
+
* Beneficiary categories live in `BeneficiaryType`.
|
|
7
|
+
*
|
|
4
8
|
* @enum {string}
|
|
5
9
|
* @readonly
|
|
6
10
|
*/
|
|
7
11
|
export declare enum PayoutChannel {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
TZ_TIGO_B2C = "TZ-TIGO-B2C",
|
|
13
|
+
TZ_VODACOM_B2C = "TZ-VODACOM-B2C",
|
|
14
|
+
TZ_AIRTEL_B2C = "TZ-AIRTEL-B2C",
|
|
15
|
+
TZ_HALOTEL_B2C = "TZ-HALOTEL-B2C",
|
|
16
|
+
KE_SAFARICOM_B2C = "KE-SAFARICOM-B2C",
|
|
17
|
+
TZ_BANK_B2C = "TZ-BANK-B2C",
|
|
18
|
+
KE_BANK_B2C = "KE-BANK-B2C"
|
|
12
19
|
}
|
|
13
20
|
/**
|
|
14
21
|
* Represents the current status of a payout transaction.
|
|
@@ -66,7 +73,7 @@ declare const AuthorizerSchema: z.ZodObject<{
|
|
|
66
73
|
* Extends base payout schema with payee information
|
|
67
74
|
*/
|
|
68
75
|
declare const PayoutInputDTOSchema: z.ZodObject<{
|
|
69
|
-
channel: z.
|
|
76
|
+
channel: z.ZodNativeEnum<typeof PayoutChannel>;
|
|
70
77
|
msisdn: z.ZodString;
|
|
71
78
|
amount: z.ZodNumber;
|
|
72
79
|
description: z.ZodString;
|
|
@@ -75,14 +82,14 @@ declare const PayoutInputDTOSchema: z.ZodObject<{
|
|
|
75
82
|
payeeName: z.ZodString;
|
|
76
83
|
}, "strip", z.ZodTypeAny, {
|
|
77
84
|
description: string;
|
|
78
|
-
channel:
|
|
85
|
+
channel: PayoutChannel;
|
|
79
86
|
msisdn: string;
|
|
80
87
|
amount: number;
|
|
81
88
|
payeeName: string;
|
|
82
89
|
notes?: string | null | undefined;
|
|
83
90
|
}, {
|
|
84
91
|
description: string;
|
|
85
|
-
channel:
|
|
92
|
+
channel: PayoutChannel;
|
|
86
93
|
msisdn: string;
|
|
87
94
|
amount: number;
|
|
88
95
|
payeeName: string;
|
|
@@ -235,6 +242,7 @@ declare const PayoutFiltersSchema: z.ZodObject<{
|
|
|
235
242
|
minAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
236
243
|
maxAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
237
244
|
search: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
245
|
+
relations: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
|
|
238
246
|
}, "strip", z.ZodTypeAny, {
|
|
239
247
|
page: number;
|
|
240
248
|
limit: number;
|
|
@@ -262,6 +270,7 @@ declare const PayoutFiltersSchema: z.ZodObject<{
|
|
|
262
270
|
actionedByIdIn?: string[] | null | undefined;
|
|
263
271
|
minAmount?: number | null | undefined;
|
|
264
272
|
maxAmount?: number | null | undefined;
|
|
273
|
+
relations?: string[] | null | undefined;
|
|
265
274
|
}, {
|
|
266
275
|
status?: PayoutStatus | null | undefined;
|
|
267
276
|
page?: number | undefined;
|
|
@@ -289,6 +298,7 @@ declare const PayoutFiltersSchema: z.ZodObject<{
|
|
|
289
298
|
actionedByIdIn?: string | string[] | null | undefined;
|
|
290
299
|
minAmount?: number | null | undefined;
|
|
291
300
|
maxAmount?: number | null | undefined;
|
|
301
|
+
relations?: string[] | null | undefined;
|
|
292
302
|
}>;
|
|
293
303
|
/**
|
|
294
304
|
* URL-safe schema for query parameters (all strings)
|
|
@@ -319,6 +329,7 @@ declare const PayoutURLQueryParamsSchema: z.ZodObject<{
|
|
|
319
329
|
minAmount: z.ZodOptional<z.ZodEffects<z.ZodString, number, string>>;
|
|
320
330
|
maxAmount: z.ZodOptional<z.ZodEffects<z.ZodString, number, string>>;
|
|
321
331
|
search: z.ZodOptional<z.ZodString>;
|
|
332
|
+
relations: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
322
333
|
}, "strip", z.ZodTypeAny, {
|
|
323
334
|
sortBy: string;
|
|
324
335
|
sortOrder: "asc" | "desc";
|
|
@@ -345,6 +356,7 @@ declare const PayoutURLQueryParamsSchema: z.ZodObject<{
|
|
|
345
356
|
actionedByIdIn?: string[] | undefined;
|
|
346
357
|
minAmount?: number | undefined;
|
|
347
358
|
maxAmount?: number | undefined;
|
|
359
|
+
relations?: string[] | undefined;
|
|
348
360
|
}, {
|
|
349
361
|
status?: string | undefined;
|
|
350
362
|
page?: string | undefined;
|
|
@@ -371,6 +383,7 @@ declare const PayoutURLQueryParamsSchema: z.ZodObject<{
|
|
|
371
383
|
actionedByIdIn?: string | string[] | undefined;
|
|
372
384
|
minAmount?: string | undefined;
|
|
373
385
|
maxAmount?: string | undefined;
|
|
386
|
+
relations?: string[] | undefined;
|
|
374
387
|
}>;
|
|
375
388
|
/**
|
|
376
389
|
* Type definition inferred from AuthorizerSchema
|
|
@@ -509,7 +522,7 @@ export declare const PayoutDTOSchemas: {
|
|
|
509
522
|
} | null | undefined;
|
|
510
523
|
}>;
|
|
511
524
|
readonly PayoutInputDTO: z.ZodObject<{
|
|
512
|
-
channel: z.
|
|
525
|
+
channel: z.ZodNativeEnum<typeof PayoutChannel>;
|
|
513
526
|
msisdn: z.ZodString;
|
|
514
527
|
amount: z.ZodNumber;
|
|
515
528
|
description: z.ZodString;
|
|
@@ -518,14 +531,14 @@ export declare const PayoutDTOSchemas: {
|
|
|
518
531
|
payeeName: z.ZodString;
|
|
519
532
|
}, "strip", z.ZodTypeAny, {
|
|
520
533
|
description: string;
|
|
521
|
-
channel:
|
|
534
|
+
channel: PayoutChannel;
|
|
522
535
|
msisdn: string;
|
|
523
536
|
amount: number;
|
|
524
537
|
payeeName: string;
|
|
525
538
|
notes?: string | null | undefined;
|
|
526
539
|
}, {
|
|
527
540
|
description: string;
|
|
528
|
-
channel:
|
|
541
|
+
channel: PayoutChannel;
|
|
529
542
|
msisdn: string;
|
|
530
543
|
amount: number;
|
|
531
544
|
payeeName: string;
|
|
@@ -533,6 +546,7 @@ export declare const PayoutDTOSchemas: {
|
|
|
533
546
|
}>;
|
|
534
547
|
readonly PayoutStatus: z.ZodNativeEnum<typeof PayoutStatus>;
|
|
535
548
|
readonly PayoutApprovalStatus: z.ZodNativeEnum<typeof PayoutApprovalStatus>;
|
|
549
|
+
readonly PayoutChannel: z.ZodNativeEnum<typeof PayoutChannel>;
|
|
536
550
|
readonly PayoutAuthorizer: z.ZodObject<{
|
|
537
551
|
id: z.ZodString;
|
|
538
552
|
name: z.ZodString;
|
|
@@ -573,6 +587,7 @@ export declare const PayoutDTOSchemas: {
|
|
|
573
587
|
minAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
574
588
|
maxAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
575
589
|
search: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
590
|
+
relations: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
|
|
576
591
|
}, "strip", z.ZodTypeAny, {
|
|
577
592
|
page: number;
|
|
578
593
|
limit: number;
|
|
@@ -600,6 +615,7 @@ export declare const PayoutDTOSchemas: {
|
|
|
600
615
|
actionedByIdIn?: string[] | null | undefined;
|
|
601
616
|
minAmount?: number | null | undefined;
|
|
602
617
|
maxAmount?: number | null | undefined;
|
|
618
|
+
relations?: string[] | null | undefined;
|
|
603
619
|
}, {
|
|
604
620
|
status?: PayoutStatus | null | undefined;
|
|
605
621
|
page?: number | undefined;
|
|
@@ -627,6 +643,7 @@ export declare const PayoutDTOSchemas: {
|
|
|
627
643
|
actionedByIdIn?: string | string[] | null | undefined;
|
|
628
644
|
minAmount?: number | null | undefined;
|
|
629
645
|
maxAmount?: number | null | undefined;
|
|
646
|
+
relations?: string[] | null | undefined;
|
|
630
647
|
}>;
|
|
631
648
|
readonly PayoutURLQueryParams: z.ZodObject<{
|
|
632
649
|
page: z.ZodOptional<z.ZodEffects<z.ZodString, number, string>>;
|
|
@@ -654,6 +671,7 @@ export declare const PayoutDTOSchemas: {
|
|
|
654
671
|
minAmount: z.ZodOptional<z.ZodEffects<z.ZodString, number, string>>;
|
|
655
672
|
maxAmount: z.ZodOptional<z.ZodEffects<z.ZodString, number, string>>;
|
|
656
673
|
search: z.ZodOptional<z.ZodString>;
|
|
674
|
+
relations: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
657
675
|
}, "strip", z.ZodTypeAny, {
|
|
658
676
|
sortBy: string;
|
|
659
677
|
sortOrder: "asc" | "desc";
|
|
@@ -680,6 +698,7 @@ export declare const PayoutDTOSchemas: {
|
|
|
680
698
|
actionedByIdIn?: string[] | undefined;
|
|
681
699
|
minAmount?: number | undefined;
|
|
682
700
|
maxAmount?: number | undefined;
|
|
701
|
+
relations?: string[] | undefined;
|
|
683
702
|
}, {
|
|
684
703
|
status?: string | undefined;
|
|
685
704
|
page?: string | undefined;
|
|
@@ -706,6 +725,7 @@ export declare const PayoutDTOSchemas: {
|
|
|
706
725
|
actionedByIdIn?: string | string[] | undefined;
|
|
707
726
|
minAmount?: string | undefined;
|
|
708
727
|
maxAmount?: string | undefined;
|
|
728
|
+
relations?: string[] | undefined;
|
|
709
729
|
}>;
|
|
710
730
|
};
|
|
711
731
|
/**
|
|
@@ -200,7 +200,7 @@ export declare class PayoutQuery extends QueryBuilder {
|
|
|
200
200
|
* .whereApproved()
|
|
201
201
|
* .orderByDesc("createdAt")
|
|
202
202
|
* .build();
|
|
203
|
-
* // => { "approvalStatus:eq": "
|
|
203
|
+
* // => { "approvalStatus:eq": "Approved", orderByDesc: "createdAt" }
|
|
204
204
|
* ```
|
|
205
205
|
*
|
|
206
206
|
* @returns An objection-find query object
|