@temboplus/afloat 0.1.77-beta.8 → 0.1.77

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,5 +1,75 @@
1
1
  import { ContactDTO, ContactType } from "@/modules/contact/contact.dtos.js";
2
2
  import { ContactInfo } from "./contact-info.model.js";
3
+ import { z } from "zod";
4
+ /**
5
+ * Zod schema for Contact JSON serialization
6
+ * This schema validates the JSON representation of a Contact instance
7
+ *
8
+ * The Contact JSON format wraps the ContactDTO structure for consistency
9
+ * and future extensibility (e.g., adding metadata, version info)
10
+ */
11
+ export declare const ContactJSONSchema: z.ZodObject<{
12
+ /** The complete contact 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 ContactType>;
23
+ }, "strip", z.ZodTypeAny, {
24
+ type: ContactType;
25
+ id: string;
26
+ displayName: string;
27
+ accountNo: string;
28
+ profileId: string;
29
+ createdAt: string;
30
+ updatedAt: string;
31
+ channel: string;
32
+ }, {
33
+ type: ContactType;
34
+ id: string;
35
+ displayName: string;
36
+ accountNo: string;
37
+ profileId: string;
38
+ createdAt: string;
39
+ updatedAt: string;
40
+ channel: string;
41
+ }>;
42
+ /** Version for future compatibility */
43
+ version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
44
+ }, "strip", z.ZodTypeAny, {
45
+ version: string;
46
+ data: {
47
+ type: ContactType;
48
+ id: string;
49
+ displayName: string;
50
+ accountNo: string;
51
+ profileId: string;
52
+ createdAt: string;
53
+ updatedAt: string;
54
+ channel: string;
55
+ };
56
+ }, {
57
+ data: {
58
+ type: ContactType;
59
+ id: string;
60
+ displayName: string;
61
+ accountNo: string;
62
+ profileId: string;
63
+ createdAt: string;
64
+ updatedAt: string;
65
+ channel: string;
66
+ };
67
+ version?: string | undefined;
68
+ }>;
69
+ /**
70
+ * Infer the ContactJSON type from the schema
71
+ */
72
+ export type ContactJSON = z.infer<typeof ContactJSONSchema>;
3
73
  /**
4
74
  * Contact class that wraps the Zod schema and provides additional functionality.
5
75
  * Represents a contact entity with validation and type-safe access to contact information.
@@ -199,23 +269,6 @@ export declare class Contact {
199
269
  * ```
200
270
  */
201
271
  static createSafe(data: ContactDTO): Contact | null;
202
- /**
203
- * Creates a Contact instance from a JSON string.
204
- *
205
- * @static
206
- * @param {string} jsonString - JSON string containing contact data
207
- * @returns {Contact | undefined} Contact instance or undefined if parsing/validation fails
208
- *
209
- * @example
210
- * ```typescript
211
- * const jsonString = '{"id":"123","displayName":"John Doe",...}';
212
- * const contact = Contact.fromJSON(jsonString);
213
- * if (contact) {
214
- * console.log(contact.displayName);
215
- * }
216
- * ```
217
- */
218
- static fromJSON(jsonString: string): Contact | undefined;
219
272
  /**
220
273
  * Checks if an unknown value contains valid data to construct a Contact instance.
221
274
  * This is useful when validating raw data structures before instantiation.
@@ -268,29 +321,121 @@ export declare class Contact {
268
321
  */
269
322
  static is(obj: unknown): obj is Contact;
270
323
  /**
271
- * Converts the Contact instance to a plain object.
324
+ * Serializes the Contact instance to a JSON-compatible object
272
325
  *
273
- * @returns {ContactDTO} Plain object representation of the contact
326
+ * This method creates a structured representation suitable for storage or transmission.
327
+ * The serialized format includes all contact data and a version identifier for
328
+ * future compatibility.
329
+ *
330
+ * @returns {ContactJSON} JSON-compatible object representation
274
331
  *
275
332
  * @example
276
333
  * ```typescript
277
334
  * const contact = Contact.from(contactData);
278
- * const plainObject = contact?.toObject();
279
- * // Use plainObject for API calls or storage
335
+ * const json = contact.toJSON();
336
+ * // { data: { id: "123", displayName: "John", ... }, version: "1.0" }
337
+ *
338
+ * // Store in localStorage
339
+ * localStorage.setItem('contact', JSON.stringify(json));
280
340
  * ```
281
341
  */
282
- toObject(): ContactDTO;
342
+ toJSON(): ContactJSON;
283
343
  /**
284
- * Converts the Contact instance to a JSON string.
344
+ * Serializes the Contact instance to a JSON string
285
345
  *
286
- * @returns {string} JSON string representation of the contact
346
+ * Convenience method that combines toJSON() with JSON.stringify()
347
+ *
348
+ * @returns {string} JSON string representation
287
349
  *
288
350
  * @example
289
351
  * ```typescript
290
352
  * const contact = Contact.from(contactData);
291
- * const jsonString = contact?.toJSON();
353
+ * const jsonString = contact.toJSONString();
292
354
  * localStorage.setItem('contact', jsonString);
293
355
  * ```
294
356
  */
295
- toJSON(): string;
357
+ toJSONString(): string;
358
+ /**
359
+ * Creates a Contact instance from a JSON-compatible object or string
360
+ *
361
+ * This static method reconstructs a Contact instance from data that was
362
+ * previously serialized using toJSON(). It performs comprehensive validation
363
+ * to ensure data integrity.
364
+ *
365
+ * **Validation Process:**
366
+ * 1. Parses JSON string if provided
367
+ * 2. Validates structure using Zod schema
368
+ * 3. Extracts and validates ContactDTO data
369
+ * 4. Constructs Contact instance with validated data
370
+ *
371
+ * @static
372
+ * @param {ContactJSON | string} json - JSON object or string containing contact data
373
+ * @returns {Contact | undefined} New Contact instance if successful, undefined if parsing/validation fails
374
+ *
375
+ * @example
376
+ * ```typescript
377
+ * // From JSON object
378
+ * const json = { data: { id: "123", displayName: "John", ... }, version: "1.0" };
379
+ * const contact = Contact.fromJSON(json);
380
+ *
381
+ * // From JSON string
382
+ * const jsonString = localStorage.getItem('contact');
383
+ * const contact = Contact.fromJSON(jsonString);
384
+ *
385
+ * // With error handling
386
+ * const contact = Contact.fromJSON(jsonString);
387
+ * if (contact) {
388
+ * console.log("Contact restored:", contact.displayName);
389
+ * } else {
390
+ * console.error("Failed to restore contact from JSON");
391
+ * }
392
+ * ```
393
+ */
394
+ static fromJSON(json: ContactJSON | string): Contact | undefined;
395
+ /**
396
+ * Creates a Contact instance from a JSON string
397
+ *
398
+ * Convenience method that delegates to fromJSON()
399
+ *
400
+ * @static
401
+ * @param {string} jsonString - JSON string containing contact data
402
+ * @returns {Contact | undefined} New Contact instance if successful, undefined if parsing fails
403
+ *
404
+ * @example
405
+ * ```typescript
406
+ * const jsonString = '{"data":{"id":"123","displayName":"John",...},"version":"1.0"}';
407
+ * const contact = Contact.fromJSONString(jsonString);
408
+ * ```
409
+ */
410
+ static fromJSONString(jsonString: string): Contact | undefined;
411
+ /**
412
+ * Type guard to check if an object is a valid ContactJSON using Zod validation
413
+ *
414
+ * This method validates the structure of a JSON object to ensure it contains
415
+ * all required fields and meets the ContactJSON schema requirements.
416
+ *
417
+ * @static
418
+ * @param {unknown} obj - The object to validate
419
+ * @returns {obj is ContactJSON} Type predicate indicating if the object is valid ContactJSON
420
+ *
421
+ * @example
422
+ * ```typescript
423
+ * const data = JSON.parse(jsonString);
424
+ *
425
+ * if (Contact.isContactJSON(data)) {
426
+ * // TypeScript now knows data is ContactJSON
427
+ * const contact = Contact.fromJSON(data);
428
+ * } else {
429
+ * console.error("Invalid ContactJSON structure");
430
+ * }
431
+ * ```
432
+ *
433
+ * @remarks
434
+ * Use this method when:
435
+ * - Validating JSON data before deserialization
436
+ * - Implementing type guards in conditional logic
437
+ * - Checking API responses before processing
438
+ * - Validating cached data integrity
439
+ */
440
+ static isContactJSON(obj: unknown): obj is ContactJSON;
296
441
  }
@@ -1,10 +1,43 @@
1
1
  import { LogInDTO } from "./login.dtos.js";
2
- export type LogInJson = {
2
+ import { z } from "zod";
3
+ /**
4
+ * Zod schema for LogIn JSON serialization
5
+ * This schema validates the JSON representation of a LogIn instance
6
+ */
7
+ export declare const LogInJSONSchema: z.ZodObject<{
8
+ id: z.ZodString;
9
+ profileId: z.ZodString;
10
+ name: z.ZodString;
11
+ identity: z.ZodString;
12
+ type: z.ZodString;
13
+ roleId: z.ZodString;
14
+ isActive: z.ZodBoolean;
15
+ isArchived: z.ZodBoolean;
16
+ resetPassword: z.ZodBoolean;
17
+ createdAt: z.ZodString;
18
+ updatedAt: z.ZodString;
19
+ access: z.ZodArray<z.ZodString, "many">;
20
+ version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
21
+ }, "strip", z.ZodTypeAny, {
22
+ type: string;
23
+ name: string;
3
24
  id: string;
25
+ version: string;
4
26
  profileId: string;
5
- name: string;
6
27
  identity: string;
28
+ roleId: string;
29
+ isActive: boolean;
30
+ isArchived: boolean;
31
+ resetPassword: boolean;
32
+ createdAt: string;
33
+ updatedAt: string;
34
+ access: string[];
35
+ }, {
7
36
  type: string;
37
+ name: string;
38
+ id: string;
39
+ profileId: string;
40
+ identity: string;
8
41
  roleId: string;
9
42
  isActive: boolean;
10
43
  isArchived: boolean;
@@ -12,7 +45,12 @@ export type LogInJson = {
12
45
  createdAt: string;
13
46
  updatedAt: string;
14
47
  access: string[];
15
- };
48
+ version?: string | undefined;
49
+ }>;
50
+ /**
51
+ * Infer the LogInJSON type from the schema
52
+ */
53
+ export type LogInJSON = z.infer<typeof LogInJSONSchema>;
16
54
  /**
17
55
  * Represents the authenticated user's identity and account information.
18
56
  *
@@ -63,18 +101,6 @@ export declare class LogIn {
63
101
  * ```
64
102
  */
65
103
  static from(dto: LogInDTO): LogIn;
66
- /**
67
- * Creates a LogIn instance from a JSON string.
68
- *
69
- * @param json - JSON string containing login data
70
- * @returns A new LogIn instance, or undefined if parsing failed
71
- *
72
- * @example
73
- * ```typescript
74
- * const logIn = LogIn.fromJson('{"id":"abc","name":"John",...}');
75
- * ```
76
- */
77
- static fromJson(json: string): LogIn | undefined;
78
104
  /**
79
105
  * Gets the user's unique identifier.
80
106
  */
@@ -124,15 +150,19 @@ export declare class LogIn {
124
150
  */
125
151
  get access(): ReadonlyArray<string>;
126
152
  /**
127
- * Converts the LogIn instance to a plain object.
128
- *
129
- * @returns A plain object representation
153
+ * Serializes the LogIn instance to a JSON-compatible object
154
+ */
155
+ toJSON(): LogInJSON;
156
+ /**
157
+ * Serializes the LogIn instance to a JSON string
130
158
  */
131
- toObject(): LogInJson;
159
+ toJSONString(): string;
132
160
  /**
133
- * Converts the LogIn instance to a JSON string.
134
- *
135
- * @returns A JSON string representation
161
+ * Creates a LogIn instance from a JSON-compatible object or string
162
+ */
163
+ static fromJSON(json: LogInJSON | string): LogIn | undefined;
164
+ /**
165
+ * Type guard using Zod schema validation
136
166
  */
137
- toJson(): string;
167
+ static isLogInJSON(obj: unknown): obj is LogInJSON;
138
168
  }
@@ -27,7 +27,9 @@ export declare enum PayoutStatus {
27
27
  /** Payout has been rejected */
28
28
  REJECTED = "REJECTED",
29
29
  /** Payout has been reversed */
30
- REVERSED = "REVERSED"
30
+ REVERSED = "REVERSED",
31
+ /** Payout has been queued for processing */
32
+ QUEUED = "QUEUED"
31
33
  }
32
34
  /**
33
35
  * Represents the approval status for payouts that require authorization.
@@ -228,14 +230,14 @@ declare const PayoutFiltersSchema: z.ZodObject<{
228
230
  id?: string | null | undefined;
229
231
  profileId?: string | null | undefined;
230
232
  search?: string | null | undefined;
231
- startDate?: string | null | undefined;
232
- endDate?: string | null | undefined;
233
233
  channel?: string | null | undefined;
234
234
  currencyCode?: string | null | undefined;
235
235
  msisdn?: string | null | undefined;
236
236
  payeeName?: string | null | undefined;
237
237
  partnerReference?: string | null | undefined;
238
238
  approvalStatus?: PayoutApprovalStatus | null | undefined;
239
+ startDate?: string | null | undefined;
240
+ endDate?: string | null | undefined;
239
241
  minAmount?: number | null | undefined;
240
242
  maxAmount?: number | null | undefined;
241
243
  }, {
@@ -243,8 +245,6 @@ declare const PayoutFiltersSchema: z.ZodObject<{
243
245
  id?: string | null | undefined;
244
246
  profileId?: string | null | undefined;
245
247
  search?: string | null | undefined;
246
- startDate?: string | null | undefined;
247
- endDate?: string | null | undefined;
248
248
  page?: number | undefined;
249
249
  limit?: number | undefined;
250
250
  channel?: string | null | undefined;
@@ -255,6 +255,8 @@ declare const PayoutFiltersSchema: z.ZodObject<{
255
255
  approvalStatus?: PayoutApprovalStatus | null | undefined;
256
256
  sortBy?: string | undefined;
257
257
  sortOrder?: "asc" | "desc" | undefined;
258
+ startDate?: string | null | undefined;
259
+ endDate?: string | null | undefined;
258
260
  minAmount?: number | null | undefined;
259
261
  maxAmount?: number | null | undefined;
260
262
  }>;
@@ -286,8 +288,6 @@ declare const PayoutURLQueryParamsSchema: z.ZodObject<{
286
288
  id?: string | undefined;
287
289
  profileId?: string | undefined;
288
290
  search?: string | undefined;
289
- startDate?: string | undefined;
290
- endDate?: string | undefined;
291
291
  page?: number | undefined;
292
292
  limit?: number | undefined;
293
293
  channel?: string | undefined;
@@ -295,6 +295,8 @@ declare const PayoutURLQueryParamsSchema: z.ZodObject<{
295
295
  payeeName?: string | undefined;
296
296
  partnerReference?: string | undefined;
297
297
  approvalStatus?: PayoutApprovalStatus | undefined;
298
+ startDate?: string | undefined;
299
+ endDate?: string | undefined;
298
300
  minAmount?: number | undefined;
299
301
  maxAmount?: number | undefined;
300
302
  }, {
@@ -302,8 +304,6 @@ declare const PayoutURLQueryParamsSchema: z.ZodObject<{
302
304
  id?: string | undefined;
303
305
  profileId?: string | undefined;
304
306
  search?: string | undefined;
305
- startDate?: string | undefined;
306
- endDate?: string | undefined;
307
307
  page?: string | undefined;
308
308
  limit?: string | undefined;
309
309
  channel?: string | undefined;
@@ -313,6 +313,8 @@ declare const PayoutURLQueryParamsSchema: z.ZodObject<{
313
313
  approvalStatus?: string | undefined;
314
314
  sortBy?: string | undefined;
315
315
  sortOrder?: "asc" | "desc" | undefined;
316
+ startDate?: string | undefined;
317
+ endDate?: string | undefined;
316
318
  minAmount?: string | undefined;
317
319
  maxAmount?: string | undefined;
318
320
  }>;
@@ -512,14 +514,14 @@ export declare const PayoutDTOSchemas: {
512
514
  id?: string | null | undefined;
513
515
  profileId?: string | null | undefined;
514
516
  search?: string | null | undefined;
515
- startDate?: string | null | undefined;
516
- endDate?: string | null | undefined;
517
517
  channel?: string | null | undefined;
518
518
  currencyCode?: string | null | undefined;
519
519
  msisdn?: string | null | undefined;
520
520
  payeeName?: string | null | undefined;
521
521
  partnerReference?: string | null | undefined;
522
522
  approvalStatus?: PayoutApprovalStatus | null | undefined;
523
+ startDate?: string | null | undefined;
524
+ endDate?: string | null | undefined;
523
525
  minAmount?: number | null | undefined;
524
526
  maxAmount?: number | null | undefined;
525
527
  }, {
@@ -527,8 +529,6 @@ export declare const PayoutDTOSchemas: {
527
529
  id?: string | null | undefined;
528
530
  profileId?: string | null | undefined;
529
531
  search?: string | null | undefined;
530
- startDate?: string | null | undefined;
531
- endDate?: string | null | undefined;
532
532
  page?: number | undefined;
533
533
  limit?: number | undefined;
534
534
  channel?: string | null | undefined;
@@ -539,6 +539,8 @@ export declare const PayoutDTOSchemas: {
539
539
  approvalStatus?: PayoutApprovalStatus | null | undefined;
540
540
  sortBy?: string | undefined;
541
541
  sortOrder?: "asc" | "desc" | undefined;
542
+ startDate?: string | null | undefined;
543
+ endDate?: string | null | undefined;
542
544
  minAmount?: number | null | undefined;
543
545
  maxAmount?: number | null | undefined;
544
546
  }>;
@@ -567,8 +569,6 @@ export declare const PayoutDTOSchemas: {
567
569
  id?: string | undefined;
568
570
  profileId?: string | undefined;
569
571
  search?: string | undefined;
570
- startDate?: string | undefined;
571
- endDate?: string | undefined;
572
572
  page?: number | undefined;
573
573
  limit?: number | undefined;
574
574
  channel?: string | undefined;
@@ -576,6 +576,8 @@ export declare const PayoutDTOSchemas: {
576
576
  payeeName?: string | undefined;
577
577
  partnerReference?: string | undefined;
578
578
  approvalStatus?: PayoutApprovalStatus | undefined;
579
+ startDate?: string | undefined;
580
+ endDate?: string | undefined;
579
581
  minAmount?: number | undefined;
580
582
  maxAmount?: number | undefined;
581
583
  }, {
@@ -583,8 +585,6 @@ export declare const PayoutDTOSchemas: {
583
585
  id?: string | undefined;
584
586
  profileId?: string | undefined;
585
587
  search?: string | undefined;
586
- startDate?: string | undefined;
587
- endDate?: string | undefined;
588
588
  page?: string | undefined;
589
589
  limit?: string | undefined;
590
590
  channel?: string | undefined;
@@ -594,6 +594,8 @@ export declare const PayoutDTOSchemas: {
594
594
  approvalStatus?: string | undefined;
595
595
  sortBy?: string | undefined;
596
596
  sortOrder?: "asc" | "desc" | undefined;
597
+ startDate?: string | undefined;
598
+ endDate?: string | undefined;
597
599
  minAmount?: string | undefined;
598
600
  maxAmount?: string | undefined;
599
601
  }>;