@temboplus/afloat 0.2.0-beta.1 → 0.2.0-beta.11

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.
Files changed (30) hide show
  1. package/README.md +150 -238
  2. package/dist/index.cjs.js +1 -1
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.esm.js +1 -1
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/lib/api/base-repository.d.ts +8 -8
  7. package/dist/lib/query/query.builder.d.ts +6 -1
  8. package/dist/modules/auth/auth.contract.d.ts +30 -28
  9. package/dist/modules/auth/auth.dtos.d.ts +117 -0
  10. package/dist/modules/auth/auth.repository.d.ts +9 -4
  11. package/dist/modules/auth/company-membership.model.d.ts +13 -13
  12. package/dist/modules/auth/index.d.ts +1 -0
  13. package/dist/modules/auth/user.model.d.ts +23 -35
  14. package/dist/modules/beneficiary/beneficiary-info.model.d.ts +113 -56
  15. package/dist/modules/beneficiary/beneficiary.model.d.ts +53 -64
  16. package/dist/modules/beneficiary/index.d.ts +2 -2
  17. package/dist/modules/login/login.model.d.ts +3 -3
  18. package/dist/modules/login/permission.type.d.ts +2 -2
  19. package/dist/modules/payout/payout-channel-handler.d.ts +7 -6
  20. package/dist/modules/payout/payout.model.d.ts +4 -4
  21. package/dist/modules/payout/payout.query.d.ts +54 -3
  22. package/dist/modules/profile/profile.model.d.ts +3 -3
  23. package/dist/modules/team-member/role.model.d.ts +3 -3
  24. package/dist/modules/team-member/team-member.model.d.ts +8 -8
  25. package/dist/modules/wallet/narration.model.d.ts +5 -5
  26. package/dist/modules/wallet/statement-entry.model.d.ts +23 -23
  27. package/dist/modules/wallet/wallet.model.d.ts +3 -3
  28. package/dist/modules/wallet/wallet.query.d.ts +31 -0
  29. package/dist/modules/wallet/wallet.repository.d.ts +2 -2
  30. package/package.json +3 -4
@@ -1,6 +1,17 @@
1
1
  import { QueryBuilder } from "@/lib/query/index.js";
2
2
  import { PayoutStatus, PayoutApprovalStatus, PayoutFilters } from "./payout.dtos.js";
3
3
  import { Amount } from "@temboplus/frontend-core";
4
+ /**
5
+ * Represents an active filter with its label and value
6
+ */
7
+ export interface ActiveFilter {
8
+ label: string;
9
+ value: string;
10
+ }
11
+ export interface DescribeFiltersOptions {
12
+ /** Custom date formatter function */
13
+ formatDate?: (date: string) => string;
14
+ }
4
15
  /**
5
16
  * Payout-specific query builder that extends the base QueryBuilder
6
17
  * and handles all possible input conversions (DTOs, URL params, etc.)
@@ -108,9 +119,49 @@ export declare class PayoutQuery extends QueryBuilder {
108
119
  */
109
120
  hasFilters(): boolean;
110
121
  /**
111
- * Get human-readable filter descriptions
112
- */
113
- getActiveFilters(): string[];
122
+ * Get active filters as structured objects for programmatic use
123
+ * @param options - Formatting options
124
+ * @returns Array of ActiveFilter objects with label and value
125
+ */
126
+ describeFilters(options?: DescribeFiltersOptions): ActiveFilter[];
127
+ /**
128
+ * Get active filters as human-readable strings for display
129
+ * @returns Array of formatted filter strings
130
+ */
131
+ describeFiltersAsText(): string[];
132
+ /**
133
+ * Format sort field for display
134
+ */
135
+ private formatSortField;
136
+ /**
137
+ * Build the query into an objection-find compatible object for payout queries.
138
+ *
139
+ * The output object contains:
140
+ * - Filters: Field conditions like `status:eq`, `createdAt:gte`, `payeeName:likeLower`
141
+ * - Sorting: `orderBy` and/or `orderByDesc` with comma-separated fields
142
+ * - Pagination: `rangeStart` and `rangeEnd` (only if `.paginate()` was called)
143
+ * - Relations: `eager` for included relations via `.with()` or `.includeDefaultRelations()`
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * // Paginated query
148
+ * const paged = PayoutQuery.create()
149
+ * .whereStatus(PayoutStatus.PAID)
150
+ * .paginate(1, 20)
151
+ * .build();
152
+ * // => { "status:eq": "PAID", rangeStart: 0, rangeEnd: 19 }
153
+ *
154
+ * // Unpaginated list (no rangeStart/rangeEnd)
155
+ * const all = PayoutQuery.create()
156
+ * .whereApproved()
157
+ * .orderByDesc("createdAt")
158
+ * .build();
159
+ * // => { "approvalStatus:eq": "APPROVED", orderByDesc: "createdAt" }
160
+ * ```
161
+ *
162
+ * @returns An objection-find query object
163
+ */
164
+ build(): Record<string, any>;
114
165
  /**
115
166
  * Extract filter values from QueryBuilder options
116
167
  */
@@ -11,12 +11,12 @@ export declare const ProfileJSONSchema: z.ZodObject<{
11
11
  accountNo: z.ZodString;
12
12
  email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
13
13
  autoApprove: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
14
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
14
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
15
15
  }, "strip", z.ZodTypeAny, {
16
16
  id: string;
17
17
  displayName: string;
18
18
  accountNo: string;
19
- version: string;
19
+ _version: string;
20
20
  firstName?: string | null | undefined;
21
21
  lastName?: string | null | undefined;
22
22
  phone?: string | null | undefined;
@@ -31,7 +31,7 @@ export declare const ProfileJSONSchema: z.ZodObject<{
31
31
  phone?: string | null | undefined;
32
32
  email?: string | null | undefined;
33
33
  autoApprove?: boolean | null | undefined;
34
- version?: string | undefined;
34
+ _version?: string | undefined;
35
35
  }>;
36
36
  /**
37
37
  * Infer the ProfileJSON type from the schema
@@ -10,12 +10,12 @@ export declare const RoleJSONSchema: z.ZodObject<{
10
10
  access: z.ZodArray<z.ZodString, "many">;
11
11
  createdAt: z.ZodString;
12
12
  updatedAt: z.ZodString;
13
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
13
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
14
14
  }, "strip", z.ZodTypeAny, {
15
15
  name: string;
16
16
  createdAt: string;
17
17
  id: string;
18
- version: string;
18
+ _version: string;
19
19
  updatedAt: string;
20
20
  access: string[];
21
21
  description?: string | undefined;
@@ -25,7 +25,7 @@ export declare const RoleJSONSchema: z.ZodObject<{
25
25
  id: string;
26
26
  updatedAt: string;
27
27
  access: string[];
28
- version?: string | undefined;
28
+ _version?: string | undefined;
29
29
  description?: string | undefined;
30
30
  }>;
31
31
  /**
@@ -35,12 +35,12 @@ export declare const TeamMemberJSONSchema: z.ZodObject<{
35
35
  access: z.ZodArray<z.ZodString, "many">;
36
36
  createdAt: z.ZodString;
37
37
  updatedAt: z.ZodString;
38
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
38
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
39
39
  }, "strip", z.ZodTypeAny, {
40
40
  name: string;
41
41
  createdAt: string;
42
42
  id: string;
43
- version: string;
43
+ _version: string;
44
44
  updatedAt: string;
45
45
  access: string[];
46
46
  description?: string | undefined;
@@ -50,18 +50,18 @@ export declare const TeamMemberJSONSchema: z.ZodObject<{
50
50
  id: string;
51
51
  updatedAt: string;
52
52
  access: string[];
53
- version?: string | undefined;
53
+ _version?: string | undefined;
54
54
  description?: string | undefined;
55
55
  }>>;
56
56
  createdAt: z.ZodString;
57
57
  updatedAt: z.ZodString;
58
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
58
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
59
59
  }, "strip", z.ZodTypeAny, {
60
60
  type: string;
61
61
  name: string;
62
62
  createdAt: string;
63
63
  id: string;
64
- version: string;
64
+ _version: string;
65
65
  profileId: string;
66
66
  identity: string;
67
67
  roleId: string;
@@ -73,7 +73,7 @@ export declare const TeamMemberJSONSchema: z.ZodObject<{
73
73
  name: string;
74
74
  createdAt: string;
75
75
  id: string;
76
- version: string;
76
+ _version: string;
77
77
  updatedAt: string;
78
78
  access: string[];
79
79
  description?: string | undefined;
@@ -90,14 +90,14 @@ export declare const TeamMemberJSONSchema: z.ZodObject<{
90
90
  isArchived: boolean;
91
91
  resetPassword: boolean;
92
92
  updatedAt: string;
93
- version?: string | undefined;
93
+ _version?: string | undefined;
94
94
  role?: {
95
95
  name: string;
96
96
  createdAt: string;
97
97
  id: string;
98
98
  updatedAt: string;
99
99
  access: string[];
100
- version?: string | undefined;
100
+ _version?: string | undefined;
101
101
  description?: string | undefined;
102
102
  } | undefined;
103
103
  }>;
@@ -17,13 +17,13 @@ export declare const LEGACY_MOBILE_NARR_PREFIX: string;
17
17
  */
18
18
  export declare const NarrationJSONSchema: z.ZodObject<{
19
19
  text: z.ZodString;
20
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
20
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
21
21
  }, "strip", z.ZodTypeAny, {
22
- version: string;
22
+ _version: string;
23
23
  text: string;
24
24
  }, {
25
25
  text: string;
26
- version?: string | undefined;
26
+ _version?: string | undefined;
27
27
  }>;
28
28
  export type NarrationJSON = z.infer<typeof NarrationJSONSchema>;
29
29
  /**
@@ -199,8 +199,8 @@ export declare class Narration {
199
199
  */
200
200
  static is(obj: unknown): obj is Narration;
201
201
  /**
202
- * Serializes the Narration instance to a JSON-compatible object
203
- */
202
+ * Serializes the Narration instance to a JSON-compatible object
203
+ */
204
204
  toJSON(): NarrationJSON;
205
205
  /**
206
206
  * Serializes the Narration instance to a JSON string
@@ -10,13 +10,13 @@ export declare const WalletStatementEntryJSONSchema: z.ZodObject<{
10
10
  tranRefNo: z.ZodString;
11
11
  narration: z.ZodObject<{
12
12
  text: z.ZodString;
13
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
13
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
14
14
  }, "strip", z.ZodTypeAny, {
15
- version: string;
15
+ _version: string;
16
16
  text: string;
17
17
  }, {
18
18
  text: string;
19
- version?: string | undefined;
19
+ _version?: string | undefined;
20
20
  }>;
21
21
  txnDate: z.ZodString;
22
22
  valueDate: z.ZodString;
@@ -24,9 +24,9 @@ export declare const WalletStatementEntryJSONSchema: z.ZodObject<{
24
24
  value: z.ZodNumber;
25
25
  text: z.ZodString;
26
26
  currencyCode: z.ZodString;
27
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
27
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
28
28
  }, "strip", z.ZodTypeAny, {
29
- version: string;
29
+ _version: string;
30
30
  value: number;
31
31
  text: string;
32
32
  currencyCode: string;
@@ -34,15 +34,15 @@ export declare const WalletStatementEntryJSONSchema: z.ZodObject<{
34
34
  value: number;
35
35
  text: string;
36
36
  currencyCode: string;
37
- version?: string | undefined;
37
+ _version?: string | undefined;
38
38
  }>;
39
39
  amountDebited: z.ZodObject<{
40
40
  value: z.ZodNumber;
41
41
  text: z.ZodString;
42
42
  currencyCode: z.ZodString;
43
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
43
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
44
44
  }, "strip", z.ZodTypeAny, {
45
- version: string;
45
+ _version: string;
46
46
  value: number;
47
47
  text: string;
48
48
  currencyCode: string;
@@ -50,15 +50,15 @@ export declare const WalletStatementEntryJSONSchema: z.ZodObject<{
50
50
  value: number;
51
51
  text: string;
52
52
  currencyCode: string;
53
- version?: string | undefined;
53
+ _version?: string | undefined;
54
54
  }>;
55
55
  balance: z.ZodObject<{
56
56
  value: z.ZodNumber;
57
57
  text: z.ZodString;
58
58
  currencyCode: z.ZodString;
59
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
59
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
60
60
  }, "strip", z.ZodTypeAny, {
61
- version: string;
61
+ _version: string;
62
62
  value: number;
63
63
  text: string;
64
64
  currencyCode: string;
@@ -66,35 +66,35 @@ export declare const WalletStatementEntryJSONSchema: z.ZodObject<{
66
66
  value: number;
67
67
  text: string;
68
68
  currencyCode: string;
69
- version?: string | undefined;
69
+ _version?: string | undefined;
70
70
  }>;
71
71
  currencyCode: z.ZodString;
72
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
72
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
73
73
  }, "strip", z.ZodTypeAny, {
74
- version: string;
74
+ _version: string;
75
75
  currencyCode: string;
76
76
  debitOrCredit: string;
77
77
  tranRefNo: string;
78
78
  narration: {
79
- version: string;
79
+ _version: string;
80
80
  text: string;
81
81
  };
82
82
  txnDate: string;
83
83
  valueDate: string;
84
84
  amountCredited: {
85
- version: string;
85
+ _version: string;
86
86
  value: number;
87
87
  text: string;
88
88
  currencyCode: string;
89
89
  };
90
90
  amountDebited: {
91
- version: string;
91
+ _version: string;
92
92
  value: number;
93
93
  text: string;
94
94
  currencyCode: string;
95
95
  };
96
96
  balance: {
97
- version: string;
97
+ _version: string;
98
98
  value: number;
99
99
  text: string;
100
100
  currencyCode: string;
@@ -106,7 +106,7 @@ export declare const WalletStatementEntryJSONSchema: z.ZodObject<{
106
106
  tranRefNo: string;
107
107
  narration: {
108
108
  text: string;
109
- version?: string | undefined;
109
+ _version?: string | undefined;
110
110
  };
111
111
  txnDate: string;
112
112
  valueDate: string;
@@ -114,22 +114,22 @@ export declare const WalletStatementEntryJSONSchema: z.ZodObject<{
114
114
  value: number;
115
115
  text: string;
116
116
  currencyCode: string;
117
- version?: string | undefined;
117
+ _version?: string | undefined;
118
118
  };
119
119
  amountDebited: {
120
120
  value: number;
121
121
  text: string;
122
122
  currencyCode: string;
123
- version?: string | undefined;
123
+ _version?: string | undefined;
124
124
  };
125
125
  balance: {
126
126
  value: number;
127
127
  text: string;
128
128
  currencyCode: string;
129
- version?: string | undefined;
129
+ _version?: string | undefined;
130
130
  };
131
131
  accountNo?: string | undefined;
132
- version?: string | undefined;
132
+ _version?: string | undefined;
133
133
  }>;
134
134
  export type WalletStatementEntryJSON = z.infer<typeof WalletStatementEntryJSONSchema>;
135
135
  /**
@@ -14,12 +14,12 @@ export declare const WalletJSONSchema: z.ZodObject<{
14
14
  currencyCode: z.ZodString;
15
15
  createdAt: z.ZodString;
16
16
  updatedAt: z.ZodString;
17
- version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
17
+ _version: z.ZodDefault<z.ZodOptional<z.ZodString>>;
18
18
  }, "strip", z.ZodTypeAny, {
19
19
  createdAt: string;
20
20
  id: string;
21
21
  accountNo: string;
22
- version: string;
22
+ _version: string;
23
23
  profileId: string;
24
24
  updatedAt: string;
25
25
  channel: string;
@@ -36,7 +36,7 @@ export declare const WalletJSONSchema: z.ZodObject<{
36
36
  countryCode: string;
37
37
  currencyCode: string;
38
38
  accountName: string;
39
- version?: string | undefined;
39
+ _version?: string | undefined;
40
40
  }>;
41
41
  export type WalletJSON = z.infer<typeof WalletJSONSchema>;
42
42
  /**
@@ -88,6 +88,37 @@ export declare class WalletQuery extends QueryBuilder {
88
88
  * Get human-readable filter descriptions
89
89
  */
90
90
  getActiveFilters(): string[];
91
+ /**
92
+ * Build the query into an objection-find compatible object for wallet queries.
93
+ *
94
+ * The output object contains:
95
+ * - Filters: Field conditions like `id:eq`, `profileId:eq`, `accountName:likeLower`
96
+ * - Sorting: `orderBy` and/or `orderByDesc` with comma-separated fields
97
+ * - Pagination: `rangeStart` and `rangeEnd` (only if `.paginate()` was called)
98
+ *
99
+ * Since wallets are typically fetched as complete lists (not paginated),
100
+ * pagination is usually omitted.
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * // Get all wallets for a profile (no pagination)
105
+ * const query = WalletQuery.create()
106
+ * .whereProfileId("prof_123")
107
+ * .whereCurrencyCode("TZS")
108
+ * .build();
109
+ * // => { "profileId:eq": "prof_123", "currencyCode:eq": "TZS" }
110
+ *
111
+ * // Paginated wallet list (if needed)
112
+ * const paged = WalletQuery.create()
113
+ * .whereChannel("MOBILE")
114
+ * .paginate(1, 10)
115
+ * .build();
116
+ * // => { "channel:eq": "MOBILE", rangeStart: 0, rangeEnd: 9 }
117
+ * ```
118
+ *
119
+ * @returns An objection-find query object
120
+ */
121
+ build(): Record<string, any>;
91
122
  /**
92
123
  * Extract filter values from QueryBuilder options
93
124
  */
@@ -24,8 +24,8 @@ export type WalletQueryInput = WalletQuery | WalletQueryDTO | Record<string, str
24
24
  * const repo = new WalletRepository({ token: userToken });
25
25
  * const balance = await repo.getBalance({ wallet });
26
26
  *
27
- * // Service locator usage
28
- * const repo = new WalletRepository();
27
+ * // Reuse the same construction shape for authenticated calls
28
+ * const repo = new WalletRepository({ token: userToken });
29
29
  * const wallets = await repo.getWallets();
30
30
  * ```
31
31
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temboplus/afloat",
3
- "version": "0.2.0-beta.1",
3
+ "version": "0.2.0-beta.11",
4
4
  "description": "A foundational library for Temboplus-Afloat projects.",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.js",
@@ -40,8 +40,7 @@
40
40
  "@ts-rest/core": "^3.52.1",
41
41
  "tslib": "^2.8.1",
42
42
  "uuid": "^11.1.0",
43
- "zod": "^3.24.2",
44
- "zustand": "^5.0.9"
43
+ "zod": "^3.24.2"
45
44
  },
46
45
  "devDependencies": {
47
46
  "@rollup/plugin-alias": "^6.0.0",
@@ -58,6 +57,6 @@
58
57
  "typescript": "^5.9.3"
59
58
  },
60
59
  "dependencies": {
61
- "@temboplus/frontend-core": "^0.3.0-beta.1"
60
+ "@temboplus/frontend-core": "^1.0.1-beta.3"
62
61
  }
63
62
  }