@temboplus/afloat 0.2.0-beta.8 → 0.2.0

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.
@@ -1,18 +1,19 @@
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";
1
+ import { BeneficiaryType } from "@/modules/beneficiary/beneficiary.dtos.js";
2
+ import type { BeneficiaryDTO, BeneficiaryInputDTO } from "@/modules/beneficiary/beneficiary.dtos.js";
3
+ import type { PayoutDTO } from "@/modules/payout/payout.dtos.js";
4
+ import { Bank, PhoneNumber } from "@temboplus/frontend-core";
5
+ import type { BankSwiftCode, ISO2CountryCode, MobileMoneyProvider, MobileMoneyProviderId } from "@temboplus/frontend-core";
5
6
  import { z } from "zod";
6
- export declare const MobileBeneficiaryInfoJSONSchema: z.ZodObject<{
7
+ export declare const MobileBeneficiaryJSONSchema: z.ZodObject<{
7
8
  type: z.ZodLiteral<"Mobile">;
8
9
  name: z.ZodString;
9
10
  phoneNumber: z.ZodString;
10
11
  mnoId: z.ZodString;
11
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
12
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
12
13
  }, "strip", z.ZodTypeAny, {
13
14
  type: "Mobile";
14
15
  name: string;
15
- version: string;
16
+ _version: string;
16
17
  phoneNumber: string;
17
18
  mnoId: string;
18
19
  }, {
@@ -20,18 +21,18 @@ export declare const MobileBeneficiaryInfoJSONSchema: z.ZodObject<{
20
21
  name: string;
21
22
  phoneNumber: string;
22
23
  mnoId: string;
23
- version?: string | undefined;
24
+ _version?: string | undefined;
24
25
  }>;
25
- export declare const BankBeneficiaryInfoJSONSchema: z.ZodObject<{
26
+ export declare const BankBeneficiaryJSONSchema: z.ZodObject<{
26
27
  type: z.ZodLiteral<"Bank">;
27
28
  accName: z.ZodString;
28
29
  swiftCode: z.ZodString;
29
30
  countryCode: z.ZodString;
30
31
  accNo: z.ZodString;
31
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
32
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
32
33
  }, "strip", z.ZodTypeAny, {
33
34
  type: "Bank";
34
- version: string;
35
+ _version: string;
35
36
  countryCode: string;
36
37
  accName: string;
37
38
  swiftCode: string;
@@ -42,18 +43,18 @@ export declare const BankBeneficiaryInfoJSONSchema: z.ZodObject<{
42
43
  accName: string;
43
44
  swiftCode: string;
44
45
  accNo: string;
45
- version?: string | undefined;
46
+ _version?: string | undefined;
46
47
  }>;
47
- export declare const BeneficiaryInfoJSONSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
48
+ export declare const BeneficiaryJSONSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
48
49
  type: z.ZodLiteral<"Mobile">;
49
50
  name: z.ZodString;
50
51
  phoneNumber: z.ZodString;
51
52
  mnoId: z.ZodString;
52
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
53
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
53
54
  }, "strip", z.ZodTypeAny, {
54
55
  type: "Mobile";
55
56
  name: string;
56
- version: string;
57
+ _version: string;
57
58
  phoneNumber: string;
58
59
  mnoId: string;
59
60
  }, {
@@ -61,17 +62,17 @@ export declare const BeneficiaryInfoJSONSchema: z.ZodDiscriminatedUnion<"type",
61
62
  name: string;
62
63
  phoneNumber: string;
63
64
  mnoId: string;
64
- version?: string | undefined;
65
+ _version?: string | undefined;
65
66
  }>, z.ZodObject<{
66
67
  type: z.ZodLiteral<"Bank">;
67
68
  accName: z.ZodString;
68
69
  swiftCode: z.ZodString;
69
70
  countryCode: z.ZodString;
70
71
  accNo: z.ZodString;
71
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
72
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
72
73
  }, "strip", z.ZodTypeAny, {
73
74
  type: "Bank";
74
- version: string;
75
+ _version: string;
75
76
  countryCode: string;
76
77
  accName: string;
77
78
  swiftCode: string;
@@ -82,19 +83,35 @@ export declare const BeneficiaryInfoJSONSchema: z.ZodDiscriminatedUnion<"type",
82
83
  accName: string;
83
84
  swiftCode: string;
84
85
  accNo: string;
85
- version?: string | undefined;
86
+ _version?: string | undefined;
86
87
  }>]>;
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 {
88
+ export type MobileBeneficiaryJSON = z.infer<typeof MobileBeneficiaryJSONSchema>;
89
+ export type BankBeneficiaryJSON = z.infer<typeof BankBeneficiaryJSONSchema>;
90
+ export type BeneficiaryJSON = z.infer<typeof BeneficiaryJSONSchema>;
91
+ export declare class BeneficiaryError extends Error {
92
+ readonly context: {
93
+ phoneNumber?: string;
94
+ countryCode?: ISO2CountryCode;
95
+ mnoId?: string;
96
+ operation?: string;
97
+ };
98
+ constructor(message: string, context?: {
99
+ phoneNumber?: string;
100
+ countryCode?: ISO2CountryCode;
101
+ mnoId?: string;
102
+ operation?: string;
103
+ });
104
+ }
105
+ interface ValidationResult {
106
+ isValid: boolean;
107
+ errors: string[];
108
+ warnings: string[];
109
+ }
110
+ declare abstract class BaseBeneficiary {
94
111
  readonly type: BeneficiaryType;
95
112
  readonly countryCode: ISO2CountryCode;
96
- constructor(type: BeneficiaryType, countryCode: ISO2CountryCode);
97
- abstract get channelId(): MNOId | BankSwiftCode;
113
+ protected constructor(type: BeneficiaryType, countryCode: ISO2CountryCode);
114
+ abstract get channelId(): MobileMoneyProviderId | BankSwiftCode;
98
115
  abstract get channelName(): string;
99
116
  abstract get accountName(): string;
100
117
  abstract get accountNumber(): string;
@@ -102,63 +119,80 @@ declare abstract class BaseBeneficiaryInfo {
102
119
  abstract get accountNumberLabel(): string;
103
120
  abstract get channelLabel(): string;
104
121
  abstract validate(): boolean;
105
- abstract toJSON(): BeneficiaryInfoJSON;
122
+ abstract getValidationDetails(): ValidationResult;
123
+ abstract toJSON(): BeneficiaryJSON;
106
124
  toJSONString(): string;
107
125
  get isMobile(): boolean;
108
126
  get isBank(): boolean;
109
127
  get displayName(): string;
110
128
  }
111
- /**
112
- * Mobile beneficiary information implementation.
113
- */
114
- export declare class MobileBeneficiaryInfo extends BaseBeneficiaryInfo {
129
+ export declare class MobileBeneficiaryInfo extends BaseBeneficiary {
115
130
  readonly name: string;
116
131
  readonly phoneNumber: PhoneNumber;
117
- readonly mnoId: MNOId;
118
- constructor(name: string, phoneNumber: PhoneNumber, mnoId?: MNOId);
132
+ readonly mnoId: MobileMoneyProviderId;
133
+ constructor(name: string, phoneNumber: PhoneNumber, mnoId?: MobileMoneyProviderId);
134
+ /**
135
+ * For prefix-detectable countries the MNO is always derived from the phone,
136
+ * so any caller-supplied id is intentionally ignored. For explicit-only
137
+ * countries, the supplied id is used as-is (validation happens later).
138
+ */
139
+ private static resolveMnoId;
140
+ /**
141
+ * Single source of truth for input validity. Used by the constructor,
142
+ * validate(), and getValidationDetails().
143
+ */
144
+ private static checkInputs;
145
+ /** Picks an MNO from a DTO `channel` field, or auto-detects when supported. */
146
+ private static pickMnoIdFromDTO;
119
147
  static from(data: {
120
148
  name: string;
121
149
  phoneNumber: PhoneNumber;
122
- mnoId?: MNOId;
150
+ mnoId?: MobileMoneyProviderId;
123
151
  }): MobileBeneficiaryInfo | undefined;
152
+ static fromInputDTO(info: BeneficiaryInputDTO): MobileBeneficiaryInfo | undefined;
124
153
  static fromBeneficiaryDTO(info: BeneficiaryDTO): MobileBeneficiaryInfo | undefined;
125
154
  static fromPayoutDTO(info: PayoutDTO): MobileBeneficiaryInfo | undefined;
155
+ /**
156
+ * Pure runtime brand check — no rebuilding, no coercion. Use `fromJSON` to
157
+ * upgrade raw JSON shape into an instance.
158
+ */
126
159
  static is(obj: unknown): obj is MobileBeneficiaryInfo;
127
160
  validate(): boolean;
128
- getValidationDetails(): {
129
- isValid: boolean;
130
- errors: string[];
131
- warnings: string[];
132
- };
161
+ getValidationDetails(): ValidationResult;
133
162
  get accountName(): string;
134
163
  get accountNumber(): string;
135
164
  get accountNameLabel(): string;
136
165
  get accountNumberLabel(): string;
137
166
  get channelLabel(): string;
138
- get channelId(): MNOId;
167
+ get channelId(): MobileMoneyProviderId;
139
168
  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;
169
+ get mobileMoneyProvider(): MobileMoneyProvider | undefined;
170
+ toJSON(): MobileBeneficiaryJSON;
171
+ static fromJSON(json: MobileBeneficiaryJSON | string): MobileBeneficiaryInfo | undefined;
172
+ static fromJSONString(s: string): MobileBeneficiaryInfo | undefined;
173
+ static isJSON(obj: unknown): obj is MobileBeneficiaryJSON;
144
174
  }
145
- /**
146
- * Bank beneficiary information implementation.
147
- */
148
- export declare class BankBeneficiaryInfo extends BaseBeneficiaryInfo {
175
+ export declare class BankBeneficiaryInfo extends BaseBeneficiary {
149
176
  readonly accName: string;
150
177
  readonly bank: Bank;
151
178
  readonly accNo: string;
152
179
  constructor(accName: string, bank: Bank, accNo: string);
180
+ /**
181
+ * Single source of truth for input validity. Used by the constructor,
182
+ * validate(), and getValidationDetails().
183
+ */
184
+ private static checkInputs;
153
185
  static from(data: {
154
186
  accName: string;
155
187
  bank: Bank;
156
188
  accNo: string;
157
189
  }): BankBeneficiaryInfo | undefined;
190
+ static fromInputDTO(info: BeneficiaryInputDTO): BankBeneficiaryInfo | undefined;
158
191
  static fromBeneficiaryDTO(info: BeneficiaryDTO): BankBeneficiaryInfo | undefined;
159
192
  static fromPayoutDTO(info: PayoutDTO): BankBeneficiaryInfo | undefined;
160
193
  static is(obj: unknown): obj is BankBeneficiaryInfo;
161
194
  validate(): boolean;
195
+ getValidationDetails(): ValidationResult;
162
196
  get accountName(): string;
163
197
  get accountNumber(): string;
164
198
  get accountNameLabel(): string;
@@ -166,13 +200,36 @@ export declare class BankBeneficiaryInfo extends BaseBeneficiaryInfo {
166
200
  get channelLabel(): string;
167
201
  get channelId(): BankSwiftCode;
168
202
  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;
203
+ toJSON(): BankBeneficiaryJSON;
204
+ static fromJSON(json: BankBeneficiaryJSON | string): BankBeneficiaryInfo | undefined;
205
+ static fromJSONString(s: string): BankBeneficiaryInfo | undefined;
206
+ static isJSON(obj: unknown): obj is BankBeneficiaryJSON;
173
207
  }
208
+ export type BeneficiaryInfo = MobileBeneficiaryInfo | BankBeneficiaryInfo;
174
209
  /**
175
- * Union type representing either a mobile or bank beneficiary.
210
+ * Factory for building / recognizing a beneficiary without
211
+ * caring about the variant. Each method dispatches on the discriminator.
176
212
  */
177
- export type BeneficiaryInfo = MobileBeneficiaryInfo | BankBeneficiaryInfo;
213
+ export declare class BeneficiaryInfoFactory {
214
+ static fromInputDTO(info: BeneficiaryInputDTO): BeneficiaryInfo | undefined;
215
+ static fromBeneficiaryDTO(info: BeneficiaryDTO): BeneficiaryInfo | undefined;
216
+ static fromPayoutDTO(info: PayoutDTO): BeneficiaryInfo | undefined;
217
+ static fromJSON(json: BeneficiaryJSON | string): BeneficiaryInfo | undefined;
218
+ static fromJSONString(s: string): BeneficiaryInfo | undefined;
219
+ static is(obj: unknown): obj is BeneficiaryInfo;
220
+ static isJSON(obj: unknown): obj is BeneficiaryJSON;
221
+ private static fromDTO;
222
+ }
223
+ /**
224
+ * @deprecated Use BeneficiaryInfoFactory instead.
225
+ */
226
+ export declare const BeneficiaryInfo: {
227
+ fromInputDTO(info: BeneficiaryInputDTO): BeneficiaryInfo | undefined;
228
+ fromBeneficiaryDTO(info: BeneficiaryDTO): BeneficiaryInfo | undefined;
229
+ fromPayoutDTO(info: PayoutDTO): BeneficiaryInfo | undefined;
230
+ fromJSON(json: BeneficiaryJSON | string): BeneficiaryInfo | undefined;
231
+ fromJSONString(s: string): BeneficiaryInfo | undefined;
232
+ is(obj: unknown): obj is BeneficiaryInfo;
233
+ isJSON(obj: unknown): obj is BeneficiaryJSON;
234
+ };
178
235
  export {};
@@ -1,75 +1,54 @@
1
1
  import { BeneficiaryDTO, BeneficiaryType } from "@/modules/beneficiary/beneficiary.dtos.js";
2
- import { BeneficiaryInfo } from "./beneficiary-info.model.js";
2
+ import { type BeneficiaryInfo } from "./beneficiary-info.model.js";
3
3
  import { z } from "zod";
4
4
  /**
5
5
  * Zod schema for Beneficiary JSON serialization
6
6
  * This schema validates the JSON representation of a Beneficiary instance
7
7
  *
8
- * The Beneficiary JSON format wraps the BeneficiaryDTO structure for consistency
9
- * and future extensibility (e.g., adding metadata, version info)
8
+ * The Beneficiary JSON format is a flat BeneficiaryDTO structure with metadata
9
+ * under underscored keys.
10
10
  */
11
11
  export declare const BeneficiaryJSONSchema: z.ZodObject<{
12
- /** The complete beneficiary data transfer object */
13
- data: z.ZodObject<{
14
- id: z.ZodString;
15
- profileId: z.ZodString;
16
- createdAt: z.ZodString;
17
- updatedAt: z.ZodString;
18
- } & {
19
- displayName: z.ZodString;
20
- accountNo: z.ZodString;
21
- channel: z.ZodString;
22
- type: z.ZodNativeEnum<typeof BeneficiaryType>;
23
- }, "strip", z.ZodTypeAny, {
24
- type: BeneficiaryType;
25
- createdAt: string;
26
- id: string;
27
- displayName: string;
28
- accountNo: string;
29
- profileId: string;
30
- updatedAt: string;
31
- channel: string;
32
- }, {
33
- type: BeneficiaryType;
34
- createdAt: string;
35
- id: string;
36
- displayName: string;
37
- accountNo: string;
38
- profileId: string;
39
- updatedAt: string;
40
- channel: string;
41
- }>;
42
- /** Version for future compatibility */
43
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
12
+ id: z.ZodString;
13
+ profileId: z.ZodString;
14
+ createdAt: z.ZodString;
15
+ updatedAt: z.ZodString;
16
+ } & {
17
+ displayName: z.ZodString;
18
+ accountNo: z.ZodString;
19
+ channel: z.ZodString;
20
+ type: z.ZodNativeEnum<typeof BeneficiaryType>;
21
+ } & {
22
+ /** Serialization version for future compatibility */
23
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
44
24
  }, "strip", z.ZodTypeAny, {
45
- version: string;
46
- data: {
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
- };
25
+ type: BeneficiaryType;
26
+ createdAt: string;
27
+ id: string;
28
+ displayName: string;
29
+ accountNo: string;
30
+ _version: string;
31
+ profileId: string;
32
+ updatedAt: string;
33
+ channel: string;
56
34
  }, {
57
- data: {
58
- type: BeneficiaryType;
59
- createdAt: string;
60
- id: string;
61
- displayName: string;
62
- accountNo: string;
63
- profileId: string;
64
- updatedAt: string;
65
- channel: string;
66
- };
67
- version?: string | undefined;
35
+ type: BeneficiaryType;
36
+ createdAt: string;
37
+ id: string;
38
+ displayName: string;
39
+ accountNo: string;
40
+ profileId: string;
41
+ updatedAt: string;
42
+ channel: string;
43
+ _version?: string | undefined;
68
44
  }>;
69
45
  /**
70
46
  * Infer the BeneficiaryJSON type from the schema
71
47
  */
72
48
  export type BeneficiaryJSON = z.infer<typeof BeneficiaryJSONSchema>;
49
+ type LegacyBeneficiaryJSON = {
50
+ data: BeneficiaryDTO;
51
+ } & Record<string, unknown>;
73
52
  /**
74
53
  * Beneficiary class that wraps the Zod schema and provides additional functionality.
75
54
  * Represents a beneficiary entity with validation and type-safe access to beneficiary information.
@@ -93,6 +72,8 @@ export type BeneficiaryJSON = z.infer<typeof BeneficiaryJSONSchema>;
93
72
  */
94
73
  export declare class Beneficiary {
95
74
  private readonly data;
75
+ private _info;
76
+ private _infoComputed;
96
77
  /**
97
78
  * Private constructor - use static factory methods to create instances.
98
79
  *
@@ -148,6 +129,9 @@ export declare class Beneficiary {
148
129
  * @remarks
149
130
  * For mobile beneficiaries, constructs from phone number.
150
131
  * For bank beneficiaries, constructs from SWIFT code and account number.
132
+ *
133
+ * Result is memoised — repeated accesses don't re-parse the phone number or
134
+ * re-resolve the bank.
151
135
  */
152
136
  get info(): BeneficiaryInfo | undefined;
153
137
  /**
@@ -275,7 +259,7 @@ export declare class Beneficiary {
275
259
  *
276
260
  * @static
277
261
  * @param {unknown} obj - The value containing potential beneficiary data
278
- * @returns {obj is Beneficiary} Type predicate indicating if a Beneficiary can be constructed
262
+ * @returns {obj is BeneficiaryDTO} Type predicate indicating the value is a valid BeneficiaryDTO
279
263
  *
280
264
  * @example
281
265
  * ```typescript
@@ -288,8 +272,12 @@ export declare class Beneficiary {
288
272
  *
289
273
  * @remarks
290
274
  * This method performs strict validation against the {@link BeneficiaryDTO} schema.
275
+ *
276
+ * The predicate narrows to {@link BeneficiaryDTO} (not `Beneficiary`) — what
277
+ * `obj` actually is on success — so callers don't accidentally try to use
278
+ * instance methods like `toJSON()` on a raw DTO.
291
279
  */
292
- static canConstruct(obj: unknown): obj is Beneficiary;
280
+ static canConstruct(obj: unknown): obj is BeneficiaryDTO;
293
281
  /**
294
282
  * Validates if an unknown value is a Beneficiary instance.
295
283
  * This is a runtime type guard that ensures proper object structure and data validity.
@@ -333,7 +321,7 @@ export declare class Beneficiary {
333
321
  * ```typescript
334
322
  * const beneficiary = Beneficiary.from(beneficiaryData);
335
323
  * const json = beneficiary.toJSON();
336
- * // { data: { id: "123", displayName: "John", ... }, version: "1.0" }
324
+ * // { id: "123", displayName: "John", ..., _version: "1.0" }
337
325
  *
338
326
  * // Store in localStorage
339
327
  * localStorage.setItem('beneficiary', JSON.stringify(json));
@@ -369,13 +357,13 @@ export declare class Beneficiary {
369
357
  * 4. Constructs Beneficiary instance with validated data
370
358
  *
371
359
  * @static
372
- * @param {BeneficiaryJSON | string} json - JSON object or string containing beneficiary data
360
+ * @param {BeneficiaryJSON | LegacyBeneficiaryJSON | string} json - JSON object or string containing beneficiary data
373
361
  * @returns {Beneficiary | undefined} New Beneficiary instance if successful, undefined if parsing/validation fails
374
362
  *
375
363
  * @example
376
364
  * ```typescript
377
365
  * // From JSON object
378
- * const json = { data: { id: "123", displayName: "John", ... }, version: "1.0" };
366
+ * const json = { id: "123", displayName: "John", ..., _version: "1.0" };
379
367
  * const beneficiary = Beneficiary.fromJSON(json);
380
368
  *
381
369
  * // From JSON string
@@ -391,7 +379,7 @@ export declare class Beneficiary {
391
379
  * }
392
380
  * ```
393
381
  */
394
- static fromJSON(json: BeneficiaryJSON | string): Beneficiary | undefined;
382
+ static fromJSON(json: BeneficiaryJSON | LegacyBeneficiaryJSON | string): Beneficiary | undefined;
395
383
  /**
396
384
  * Creates a Beneficiary instance from a JSON string
397
385
  *
@@ -403,7 +391,7 @@ export declare class Beneficiary {
403
391
  *
404
392
  * @example
405
393
  * ```typescript
406
- * const jsonString = '{"data":{"id":"123","displayName":"John",...},"version":"1.0"}';
394
+ * const jsonString = '{"id":"123","displayName":"John",...,"_version":"1.0"}';
407
395
  * const beneficiary = Beneficiary.fromJSONString(jsonString);
408
396
  * ```
409
397
  */
@@ -439,3 +427,4 @@ export declare class Beneficiary {
439
427
  */
440
428
  static isBeneficiaryJSON(obj: unknown): obj is BeneficiaryJSON;
441
429
  }
430
+ export {};
@@ -1,6 +1,6 @@
1
1
  export * from "./beneficiary.repository.js";
2
2
  export * from "./beneficiary.dtos.js";
3
- export * from "./beneficiary-info.model.js";
4
- export * from "./beneficiary.model.js";
3
+ export { BankBeneficiaryInfo, BankBeneficiaryJSONSchema, BeneficiaryError, BeneficiaryInfo, BeneficiaryInfoFactory, 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";
@@ -1,4 +1,5 @@
1
1
  import { LogInDTO } from "./login.dtos.js";
2
+ import { Permission } from "./permission.type.js";
2
3
  import { z } from "zod";
3
4
  /**
4
5
  * Zod schema for LogIn JSON serialization
@@ -17,13 +18,13 @@ export declare const LogInJSONSchema: z.ZodObject<{
17
18
  createdAt: z.ZodString;
18
19
  updatedAt: z.ZodString;
19
20
  access: z.ZodArray<z.ZodString, "many">;
20
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
21
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
21
22
  }, "strip", z.ZodTypeAny, {
22
23
  type: string;
23
24
  name: string;
24
25
  createdAt: string;
25
26
  id: string;
26
- version: string;
27
+ _version: string;
27
28
  profileId: string;
28
29
  identity: string;
29
30
  roleId: string;
@@ -45,7 +46,7 @@ export declare const LogInJSONSchema: z.ZodObject<{
45
46
  resetPassword: boolean;
46
47
  updatedAt: string;
47
48
  access: string[];
48
- version?: string | undefined;
49
+ _version?: string | undefined;
49
50
  }>;
50
51
  /**
51
52
  * Infer the LogInJSON type from the schema
@@ -74,6 +75,7 @@ export declare class LogIn {
74
75
  private readonly _createdAt;
75
76
  private readonly _updatedAt;
76
77
  private readonly _access;
78
+ private readonly _permissionMap;
77
79
  private constructor();
78
80
  /**
79
81
  * Creates a LogIn instance from a validated DTO.
@@ -149,6 +151,27 @@ export declare class LogIn {
149
151
  * Gets the user's permissions/access list.
150
152
  */
151
153
  get access(): ReadonlyArray<string>;
154
+ /**
155
+ * Checks if the login has a specific permission.
156
+ *
157
+ * @param permission - The permission to check
158
+ * @returns true if the login has the permission
159
+ */
160
+ can(permission: Permission): boolean;
161
+ /**
162
+ * Checks if the login has any of the specified permissions.
163
+ *
164
+ * @param permissions - Array of permissions to check
165
+ * @returns true if the login has at least one permission
166
+ */
167
+ canAny(permissions: Permission[]): boolean;
168
+ /**
169
+ * Checks if the login has all of the specified permissions.
170
+ *
171
+ * @param permissions - Array of permissions to check
172
+ * @returns true if the login has all permissions
173
+ */
174
+ canAll(permissions: Permission[]): boolean;
152
175
  /**
153
176
  * Serializes the LogIn instance to a JSON-compatible object
154
177
  */
@@ -1,5 +1,6 @@
1
1
  import { Wallet } from "@/modules/wallet/wallet.model.js";
2
- import { Amount, MNOId, PhoneNumber } from "@temboplus/frontend-core";
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 = `${string}-BANK-B2C` | `${string}-${string}-B2C`;
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: MNOId, wallet: Wallet): PayoutChannelCode;
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 {
@@ -646,6 +646,46 @@ export declare const contract: {
646
646
  identity: string;
647
647
  } | null | undefined;
648
648
  }>;
649
+ 400: z.ZodObject<{
650
+ message: z.ZodString;
651
+ statusCode: z.ZodNumber;
652
+ error: z.ZodOptional<z.ZodString>;
653
+ details: z.ZodOptional<z.AnyZodObject>;
654
+ }, z.UnknownKeysParam, z.ZodTypeAny, {
655
+ message: string;
656
+ statusCode: number;
657
+ error?: string | undefined;
658
+ details?: {
659
+ [x: string]: any;
660
+ } | undefined;
661
+ }, {
662
+ message: string;
663
+ statusCode: number;
664
+ error?: string | undefined;
665
+ details?: {
666
+ [x: string]: any;
667
+ } | undefined;
668
+ }>;
669
+ 401: z.ZodObject<{
670
+ message: z.ZodString;
671
+ statusCode: z.ZodNumber;
672
+ error: z.ZodOptional<z.ZodString>;
673
+ details: z.ZodOptional<z.AnyZodObject>;
674
+ }, z.UnknownKeysParam, z.ZodTypeAny, {
675
+ message: string;
676
+ statusCode: number;
677
+ error?: string | undefined;
678
+ details?: {
679
+ [x: string]: any;
680
+ } | undefined;
681
+ }, {
682
+ message: string;
683
+ statusCode: number;
684
+ error?: string | undefined;
685
+ details?: {
686
+ [x: string]: any;
687
+ } | undefined;
688
+ }>;
649
689
  404: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
650
690
  409: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
651
691
  };