@temboplus/afloat 0.1.77-beta.22 → 0.1.77-beta.25

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.
@@ -0,0 +1,178 @@
1
+ import { BeneficiaryType, BeneficiaryDTO } from "@/modules/beneficiary/beneficiary.dtos.js";
2
+ import { PayoutDTO } from "@/modules/payout/payout.dtos.js";
3
+ import { Bank, ISO2CountryCode, PhoneNumber } from "@temboplus/frontend-core";
4
+ import type { BankSwiftCode, MNOId } from "@temboplus/frontend-core";
5
+ import { z } from "zod";
6
+ export declare const MobileBeneficiaryInfoJSONSchema: z.ZodObject<{
7
+ type: z.ZodLiteral<"Mobile">;
8
+ name: z.ZodString;
9
+ phoneNumber: z.ZodString;
10
+ mnoId: z.ZodString;
11
+ version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
12
+ }, "strip", z.ZodTypeAny, {
13
+ type: "Mobile";
14
+ name: string;
15
+ version: string;
16
+ phoneNumber: string;
17
+ mnoId: string;
18
+ }, {
19
+ type: "Mobile";
20
+ name: string;
21
+ phoneNumber: string;
22
+ mnoId: string;
23
+ version?: string | undefined;
24
+ }>;
25
+ export declare const BankBeneficiaryInfoJSONSchema: z.ZodObject<{
26
+ type: z.ZodLiteral<"Bank">;
27
+ accName: z.ZodString;
28
+ swiftCode: z.ZodString;
29
+ countryCode: z.ZodString;
30
+ accNo: z.ZodString;
31
+ version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
32
+ }, "strip", z.ZodTypeAny, {
33
+ type: "Bank";
34
+ version: string;
35
+ countryCode: string;
36
+ accName: string;
37
+ swiftCode: string;
38
+ accNo: string;
39
+ }, {
40
+ type: "Bank";
41
+ countryCode: string;
42
+ accName: string;
43
+ swiftCode: string;
44
+ accNo: string;
45
+ version?: string | undefined;
46
+ }>;
47
+ export declare const BeneficiaryInfoJSONSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
48
+ type: z.ZodLiteral<"Mobile">;
49
+ name: z.ZodString;
50
+ phoneNumber: z.ZodString;
51
+ mnoId: z.ZodString;
52
+ version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
53
+ }, "strip", z.ZodTypeAny, {
54
+ type: "Mobile";
55
+ name: string;
56
+ version: string;
57
+ phoneNumber: string;
58
+ mnoId: string;
59
+ }, {
60
+ type: "Mobile";
61
+ name: string;
62
+ phoneNumber: string;
63
+ mnoId: string;
64
+ version?: string | undefined;
65
+ }>, z.ZodObject<{
66
+ type: z.ZodLiteral<"Bank">;
67
+ accName: z.ZodString;
68
+ swiftCode: z.ZodString;
69
+ countryCode: z.ZodString;
70
+ accNo: z.ZodString;
71
+ version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
72
+ }, "strip", z.ZodTypeAny, {
73
+ type: "Bank";
74
+ version: string;
75
+ countryCode: string;
76
+ accName: string;
77
+ swiftCode: string;
78
+ accNo: string;
79
+ }, {
80
+ type: "Bank";
81
+ countryCode: string;
82
+ accName: string;
83
+ swiftCode: string;
84
+ accNo: string;
85
+ version?: string | undefined;
86
+ }>]>;
87
+ export type MobileBeneficiaryInfoJSON = z.infer<typeof MobileBeneficiaryInfoJSONSchema>;
88
+ export type BankBeneficiaryInfoJSON = z.infer<typeof BankBeneficiaryInfoJSONSchema>;
89
+ export type BeneficiaryInfoJSON = z.infer<typeof BeneficiaryInfoJSONSchema>;
90
+ /**
91
+ * Abstract base class for beneficiary information.
92
+ */
93
+ declare abstract class BaseBeneficiaryInfo {
94
+ readonly type: BeneficiaryType;
95
+ readonly countryCode: ISO2CountryCode;
96
+ constructor(type: BeneficiaryType, countryCode: ISO2CountryCode);
97
+ abstract get channelId(): MNOId | BankSwiftCode;
98
+ abstract get channelName(): string;
99
+ abstract get accountName(): string;
100
+ abstract get accountNumber(): string;
101
+ abstract get accountNameLabel(): string;
102
+ abstract get accountNumberLabel(): string;
103
+ abstract get channelLabel(): string;
104
+ abstract validate(): boolean;
105
+ abstract toJSON(): BeneficiaryInfoJSON;
106
+ toJSONString(): string;
107
+ get isMobile(): boolean;
108
+ get isBank(): boolean;
109
+ get displayName(): string;
110
+ }
111
+ /**
112
+ * Mobile beneficiary information implementation.
113
+ */
114
+ export declare class MobileBeneficiaryInfo extends BaseBeneficiaryInfo {
115
+ readonly name: string;
116
+ readonly phoneNumber: PhoneNumber;
117
+ readonly mnoId: MNOId;
118
+ constructor(name: string, phoneNumber: PhoneNumber, mnoId?: MNOId);
119
+ static from(data: {
120
+ name: string;
121
+ phoneNumber: PhoneNumber;
122
+ mnoId?: MNOId;
123
+ }): MobileBeneficiaryInfo | undefined;
124
+ static fromBeneficiaryDTO(info: BeneficiaryDTO): MobileBeneficiaryInfo | undefined;
125
+ static fromPayoutDTO(info: PayoutDTO): MobileBeneficiaryInfo | undefined;
126
+ static is(obj: unknown): obj is MobileBeneficiaryInfo;
127
+ validate(): boolean;
128
+ getValidationDetails(): {
129
+ isValid: boolean;
130
+ errors: string[];
131
+ warnings: string[];
132
+ };
133
+ get accountName(): string;
134
+ get accountNumber(): string;
135
+ get accountNameLabel(): string;
136
+ get accountNumberLabel(): string;
137
+ get channelLabel(): string;
138
+ get channelId(): MNOId;
139
+ get channelName(): string;
140
+ toJSON(): MobileBeneficiaryInfoJSON;
141
+ static fromJSON(json: MobileBeneficiaryInfoJSON | string): MobileBeneficiaryInfo | undefined;
142
+ static fromJSONString(jsonString: string): MobileBeneficiaryInfo | undefined;
143
+ static isMobileBeneficiaryInfoJSON(obj: unknown): obj is MobileBeneficiaryInfoJSON;
144
+ }
145
+ /**
146
+ * Bank beneficiary information implementation.
147
+ */
148
+ export declare class BankBeneficiaryInfo extends BaseBeneficiaryInfo {
149
+ readonly accName: string;
150
+ readonly bank: Bank;
151
+ readonly accNo: string;
152
+ constructor(accName: string, bank: Bank, accNo: string);
153
+ static from(data: {
154
+ accName: string;
155
+ bank: Bank;
156
+ accNo: string;
157
+ }): BankBeneficiaryInfo | undefined;
158
+ static fromBeneficiaryDTO(info: BeneficiaryDTO): BankBeneficiaryInfo | undefined;
159
+ static fromPayoutDTO(info: PayoutDTO): BankBeneficiaryInfo | undefined;
160
+ static is(obj: unknown): obj is BankBeneficiaryInfo;
161
+ validate(): boolean;
162
+ get accountName(): string;
163
+ get accountNumber(): string;
164
+ get accountNameLabel(): string;
165
+ get accountNumberLabel(): string;
166
+ get channelLabel(): string;
167
+ get channelId(): BankSwiftCode;
168
+ get channelName(): string;
169
+ toJSON(): BankBeneficiaryInfoJSON;
170
+ static fromJSON(json: BankBeneficiaryInfoJSON | string): BankBeneficiaryInfo | undefined;
171
+ static fromJSONString(jsonString: string): BankBeneficiaryInfo | undefined;
172
+ static isBankBeneficiaryInfoJSON(obj: unknown): obj is BankBeneficiaryInfoJSON;
173
+ }
174
+ /**
175
+ * Union type representing either a mobile or bank beneficiary.
176
+ */
177
+ export type BeneficiaryInfo = MobileBeneficiaryInfo | BankBeneficiaryInfo;
178
+ export {};
@@ -0,0 +1,16 @@
1
+ import { BeneficiaryInfo } from "@/modules/beneficiary/beneficiary-info.model.js";
2
+ import { BeneficiaryInputDTO } from "./beneficiary.dtos.js";
3
+ /**
4
+ * Factory for resolving and validating a raw `BeneficiaryInput` into a typed and valid version.
5
+ */
6
+ export declare class ValidatedBeneficiaryInputFactory {
7
+ private handlers;
8
+ /**
9
+ * Resolves a raw beneficiary input into a valid and strongly-typed `BeneficiaryInput`.
10
+ *
11
+ * @param {BeneficiaryInputDTO} data - The unvalidated input object
12
+ * @returns {BeneficiaryInputDTO} - A valid and converted input ready for use
13
+ * @throws {Error} - If the input cannot be handled by any handler
14
+ */
15
+ resolve(data: BeneficiaryInfo): BeneficiaryInputDTO;
16
+ }
@@ -1,28 +1,28 @@
1
1
  import { z } from "zod";
2
2
  /**
3
- * Contact API contract
4
- * Defines the REST endpoints for managing contacts
3
+ * Beneficiary API contract
4
+ * Defines the REST endpoints for managing beneficiaries
5
5
  *
6
- * @property {Object} postContact - Create a new contact (POST /)
7
- * @property {Object} editContact - Update an existing contact (PATCH /:id)
8
- * @property {Object} getContacts - Retrieve contacts list (GET /)
9
- * @property {Object} deleteContact - Delete a contact (DELETE /:id)
6
+ * @property {Object} createBeneficiary - Create a new beneficiary (POST /)
7
+ * @property {Object} editBeneficiary - Update an existing beneficiary (PATCH /:id)
8
+ * @property {Object} getBeneficiaries - Retrieve beneficiaries list (GET /)
9
+ * @property {Object} deleteBeneficiary - Delete a beneficiary (DELETE /:id)
10
10
  */
11
11
  export declare const contract: {
12
- createContact: {
12
+ createBeneficiary: {
13
13
  method: "POST";
14
14
  body: z.ZodObject<{
15
15
  displayName: z.ZodString;
16
16
  accountNo: z.ZodString;
17
17
  channel: z.ZodString;
18
- type: z.ZodNativeEnum<typeof import("./contact.dtos.js").ContactType>;
18
+ type: z.ZodNativeEnum<typeof import("./beneficiary.dtos.js").BeneficiaryType>;
19
19
  }, "strip", z.ZodTypeAny, {
20
- type: import("./contact.dtos.js").ContactType;
20
+ type: import("./beneficiary.dtos.js").BeneficiaryType;
21
21
  displayName: string;
22
22
  accountNo: string;
23
23
  channel: string;
24
24
  }, {
25
- type: import("./contact.dtos.js").ContactType;
25
+ type: import("./beneficiary.dtos.js").BeneficiaryType;
26
26
  displayName: string;
27
27
  accountNo: string;
28
28
  channel: string;
@@ -38,9 +38,9 @@ export declare const contract: {
38
38
  displayName: z.ZodString;
39
39
  accountNo: z.ZodString;
40
40
  channel: z.ZodString;
41
- type: z.ZodNativeEnum<typeof import("./contact.dtos.js").ContactType>;
41
+ type: z.ZodNativeEnum<typeof import("./beneficiary.dtos.js").BeneficiaryType>;
42
42
  }, "strip", z.ZodTypeAny, {
43
- type: import("./contact.dtos.js").ContactType;
43
+ type: import("./beneficiary.dtos.js").BeneficiaryType;
44
44
  createdAt: string;
45
45
  id: string;
46
46
  displayName: string;
@@ -49,7 +49,7 @@ export declare const contract: {
49
49
  updatedAt: string;
50
50
  channel: string;
51
51
  }, {
52
- type: import("./contact.dtos.js").ContactType;
52
+ type: import("./beneficiary.dtos.js").BeneficiaryType;
53
53
  createdAt: string;
54
54
  id: string;
55
55
  displayName: string;
@@ -60,20 +60,20 @@ export declare const contract: {
60
60
  }>;
61
61
  };
62
62
  };
63
- editContact: {
63
+ editBeneficiary: {
64
64
  method: "PATCH";
65
65
  body: z.ZodObject<{
66
66
  displayName: z.ZodString;
67
67
  accountNo: z.ZodString;
68
68
  channel: z.ZodString;
69
- type: z.ZodNativeEnum<typeof import("./contact.dtos.js").ContactType>;
69
+ type: z.ZodNativeEnum<typeof import("./beneficiary.dtos.js").BeneficiaryType>;
70
70
  }, "strip", z.ZodTypeAny, {
71
- type: import("./contact.dtos.js").ContactType;
71
+ type: import("./beneficiary.dtos.js").BeneficiaryType;
72
72
  displayName: string;
73
73
  accountNo: string;
74
74
  channel: string;
75
75
  }, {
76
- type: import("./contact.dtos.js").ContactType;
76
+ type: import("./beneficiary.dtos.js").BeneficiaryType;
77
77
  displayName: string;
78
78
  accountNo: string;
79
79
  channel: string;
@@ -89,9 +89,9 @@ export declare const contract: {
89
89
  displayName: z.ZodString;
90
90
  accountNo: z.ZodString;
91
91
  channel: z.ZodString;
92
- type: z.ZodNativeEnum<typeof import("./contact.dtos.js").ContactType>;
92
+ type: z.ZodNativeEnum<typeof import("./beneficiary.dtos.js").BeneficiaryType>;
93
93
  }, "strip", z.ZodTypeAny, {
94
- type: import("./contact.dtos.js").ContactType;
94
+ type: import("./beneficiary.dtos.js").BeneficiaryType;
95
95
  createdAt: string;
96
96
  id: string;
97
97
  displayName: string;
@@ -100,7 +100,7 @@ export declare const contract: {
100
100
  updatedAt: string;
101
101
  channel: string;
102
102
  }, {
103
- type: import("./contact.dtos.js").ContactType;
103
+ type: import("./beneficiary.dtos.js").BeneficiaryType;
104
104
  createdAt: string;
105
105
  id: string;
106
106
  displayName: string;
@@ -111,7 +111,7 @@ export declare const contract: {
111
111
  }>;
112
112
  };
113
113
  };
114
- getContacts: {
114
+ getBeneficiaries: {
115
115
  query: z.ZodObject<{
116
116
  orderByDesc: z.ZodString;
117
117
  }, "strip", z.ZodTypeAny, {
@@ -131,9 +131,9 @@ export declare const contract: {
131
131
  displayName: z.ZodString;
132
132
  accountNo: z.ZodString;
133
133
  channel: z.ZodString;
134
- type: z.ZodNativeEnum<typeof import("./contact.dtos.js").ContactType>;
134
+ type: z.ZodNativeEnum<typeof import("./beneficiary.dtos.js").BeneficiaryType>;
135
135
  }, "strip", z.ZodTypeAny, {
136
- type: import("./contact.dtos.js").ContactType;
136
+ type: import("./beneficiary.dtos.js").BeneficiaryType;
137
137
  createdAt: string;
138
138
  id: string;
139
139
  displayName: string;
@@ -142,7 +142,7 @@ export declare const contract: {
142
142
  updatedAt: string;
143
143
  channel: string;
144
144
  }, {
145
- type: import("./contact.dtos.js").ContactType;
145
+ type: import("./beneficiary.dtos.js").BeneficiaryType;
146
146
  createdAt: string;
147
147
  id: string;
148
148
  displayName: string;
@@ -166,9 +166,9 @@ export declare const contract: {
166
166
  displayName: z.ZodString;
167
167
  accountNo: z.ZodString;
168
168
  channel: z.ZodString;
169
- type: z.ZodNativeEnum<typeof import("./contact.dtos.js").ContactType>;
169
+ type: z.ZodNativeEnum<typeof import("./beneficiary.dtos.js").BeneficiaryType>;
170
170
  }, "strip", z.ZodTypeAny, {
171
- type: import("./contact.dtos.js").ContactType;
171
+ type: import("./beneficiary.dtos.js").BeneficiaryType;
172
172
  createdAt: string;
173
173
  id: string;
174
174
  displayName: string;
@@ -177,7 +177,7 @@ export declare const contract: {
177
177
  updatedAt: string;
178
178
  channel: string;
179
179
  }, {
180
- type: import("./contact.dtos.js").ContactType;
180
+ type: import("./beneficiary.dtos.js").BeneficiaryType;
181
181
  createdAt: string;
182
182
  id: string;
183
183
  displayName: string;
@@ -188,7 +188,7 @@ export declare const contract: {
188
188
  }>;
189
189
  };
190
190
  };
191
- deleteContact: {
191
+ deleteBeneficiary: {
192
192
  method: "DELETE";
193
193
  body: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
194
194
  path: "/:id";
@@ -200,4 +200,4 @@ export declare const contract: {
200
200
  /**
201
201
  * Export type for use in client implementations
202
202
  */
203
- export type ContactAPI = typeof contract;
203
+ export type BeneficiaryAPI = typeof contract;
@@ -0,0 +1,84 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Schema for beneficiary channel types.
4
+ *
5
+ * @remarks
6
+ * Currently supports two channel types:
7
+ * - "Bank": For traditional banking channels
8
+ * - "Mobile": For mobile money channels
9
+ *
10
+ * @see {@link BeneficiaryType} for the inferred type
11
+ */
12
+ export declare enum BeneficiaryType {
13
+ Bank = "Bank",
14
+ Mobile = "Mobile"
15
+ }
16
+ /**
17
+ * Type representing user-provided beneficiary information.
18
+ * Used for creating or updating beneficiaries.
19
+ *
20
+ * @see {@link beneficiaryInputSchema} for validation rules
21
+ * @see {@link BeneficiaryDTOSchemas} for all available schemas
22
+ */
23
+ export type BeneficiaryInputDTO = z.infer<typeof BeneficiaryDTOSchemas.beneficiaryInputDTO>;
24
+ /**
25
+ * Type representing a complete beneficiary record.
26
+ * Includes both user-provided and system-generated fields.
27
+ *
28
+ * @see {@link beneficiarySchema} for validation rules
29
+ */
30
+ export type BeneficiaryDTO = z.infer<typeof BeneficiaryDTOSchemas.beneficiaryDTO>;
31
+ /**
32
+ * Collection of all beneficiary-related schemas.
33
+ */
34
+ export declare const BeneficiaryDTOSchemas: {
35
+ /** Schema for complete beneficiary records */
36
+ beneficiaryDTO: z.ZodObject<{
37
+ id: z.ZodString;
38
+ profileId: z.ZodString;
39
+ createdAt: z.ZodString;
40
+ updatedAt: z.ZodString;
41
+ } & {
42
+ displayName: z.ZodString;
43
+ accountNo: z.ZodString;
44
+ channel: z.ZodString;
45
+ type: z.ZodNativeEnum<typeof BeneficiaryType>;
46
+ }, "strip", z.ZodTypeAny, {
47
+ type: BeneficiaryType;
48
+ createdAt: string;
49
+ id: string;
50
+ displayName: string;
51
+ accountNo: string;
52
+ profileId: string;
53
+ updatedAt: string;
54
+ channel: string;
55
+ }, {
56
+ type: BeneficiaryType;
57
+ createdAt: string;
58
+ id: string;
59
+ displayName: string;
60
+ accountNo: string;
61
+ profileId: string;
62
+ updatedAt: string;
63
+ channel: string;
64
+ }>;
65
+ /** Schema for beneficiary input validation */
66
+ beneficiaryInputDTO: z.ZodObject<{
67
+ displayName: z.ZodString;
68
+ accountNo: z.ZodString;
69
+ channel: z.ZodString;
70
+ type: z.ZodNativeEnum<typeof BeneficiaryType>;
71
+ }, "strip", z.ZodTypeAny, {
72
+ type: BeneficiaryType;
73
+ displayName: string;
74
+ accountNo: string;
75
+ channel: string;
76
+ }, {
77
+ type: BeneficiaryType;
78
+ displayName: string;
79
+ accountNo: string;
80
+ channel: string;
81
+ }>;
82
+ /** Schema for beneficiary channel types */
83
+ beneficiaryType: z.ZodNativeEnum<typeof BeneficiaryType>;
84
+ };