@temboplus/tembo-dashboard 0.0.4 → 0.0.6

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.
@@ -21,7 +21,7 @@ declare const paginationSchema: z.ZodObject<{
21
21
  hasNext: boolean;
22
22
  hasPrev: boolean;
23
23
  }>;
24
- declare const accountSummarySchema: z.ZodObject<{
24
+ declare const walletSummarySchema: z.ZodObject<{
25
25
  balance: z.ZodNumber;
26
26
  availableBalance: z.ZodNumber;
27
27
  accountNumber: z.ZodString;
@@ -92,7 +92,7 @@ export declare const CommonSchemas: {
92
92
  thisMonth: number;
93
93
  lastMonth: number;
94
94
  }>;
95
- accountSummary: z.ZodObject<{
95
+ walletSummary: z.ZodObject<{
96
96
  balance: z.ZodNumber;
97
97
  availableBalance: z.ZodNumber;
98
98
  accountNumber: z.ZodString;
@@ -111,5 +111,5 @@ export declare const CommonSchemas: {
111
111
  };
112
112
  export type PaginationDTO = z.infer<typeof paginationSchema>;
113
113
  export type TransactionSummaryDTO = z.infer<typeof transactionSummarySchema>;
114
- export type WalletSummaryDTO = z.infer<typeof accountSummarySchema>;
114
+ export type WalletSummaryDTO = z.infer<typeof walletSummarySchema>;
115
115
  export {};
@@ -8,7 +8,7 @@ export declare const collectionContract: {
8
8
  path: "/";
9
9
  responses: {
10
10
  200: z.ZodObject<{
11
- data: z.ZodArray<z.ZodObject<{
11
+ results: z.ZodArray<z.ZodObject<{
12
12
  id: z.ZodString;
13
13
  status: z.ZodNativeEnum<typeof import("./collection.dtos").COLLECTION_STATUS>;
14
14
  statusMessage: z.ZodString;
@@ -81,7 +81,7 @@ export declare const collectionContract: {
81
81
  total: z.ZodNumber;
82
82
  }, "strip", z.ZodTypeAny, {
83
83
  total: number;
84
- data: {
84
+ results: {
85
85
  status: import("./collection.dtos").COLLECTION_STATUS;
86
86
  createdAt: string;
87
87
  id: string;
@@ -107,7 +107,7 @@ export declare const collectionContract: {
107
107
  }[];
108
108
  }, {
109
109
  total: number;
110
- data: {
110
+ results: {
111
111
  status: import("./collection.dtos").COLLECTION_STATUS;
112
112
  createdAt: string;
113
113
  id: string;
@@ -10,22 +10,6 @@ export declare enum COLLECTION_CHANNEL {
10
10
  TIGO = "TZ-TIGO-C2B",
11
11
  HALOTEL = "TZ-HALOTEL-C2B"
12
12
  }
13
- export declare const accountSummarySchema: z.ZodObject<{
14
- balance: z.ZodNumber;
15
- availableBalance: z.ZodNumber;
16
- accountNumber: z.ZodString;
17
- accountName: z.ZodString;
18
- }, "strip", z.ZodTypeAny, {
19
- balance: number;
20
- availableBalance: number;
21
- accountNumber: string;
22
- accountName: string;
23
- }, {
24
- balance: number;
25
- availableBalance: number;
26
- accountNumber: string;
27
- accountName: string;
28
- }>;
29
13
  export declare const CollectionDTOSchemas: {
30
14
  collection: z.ZodObject<{
31
15
  id: z.ZodString;
@@ -149,6 +133,58 @@ export declare const CollectionDTOSchemas: {
149
133
  minAmount?: number | undefined;
150
134
  maxAmount?: number | undefined;
151
135
  }>;
136
+ collectionURLQueryParams: z.ZodObject<{
137
+ page: z.ZodOptional<z.ZodEffects<z.ZodString, number, string>>;
138
+ limit: z.ZodOptional<z.ZodEffects<z.ZodString, number, string>>;
139
+ sortBy: z.ZodDefault<z.ZodString>;
140
+ sortOrder: z.ZodDefault<z.ZodEnum<["asc", "desc"]>>;
141
+ startDate: z.ZodOptional<z.ZodString>;
142
+ endDate: z.ZodOptional<z.ZodString>;
143
+ msisdn: z.ZodOptional<z.ZodString>;
144
+ id: z.ZodOptional<z.ZodString>;
145
+ reference: z.ZodOptional<z.ZodString>;
146
+ accountNo: z.ZodOptional<z.ZodString>;
147
+ partnerReference: z.ZodOptional<z.ZodString>;
148
+ channel: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, COLLECTION_CHANNEL, string>>;
149
+ status: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, COLLECTION_STATUS, string>>;
150
+ minAmount: z.ZodOptional<z.ZodEffects<z.ZodString, number, string>>;
151
+ maxAmount: z.ZodOptional<z.ZodEffects<z.ZodString, number, string>>;
152
+ search: z.ZodOptional<z.ZodString>;
153
+ }, "strip", z.ZodTypeAny, {
154
+ sortBy: string;
155
+ sortOrder: "asc" | "desc";
156
+ status?: COLLECTION_STATUS | undefined;
157
+ startDate?: string | undefined;
158
+ endDate?: string | undefined;
159
+ page?: number | undefined;
160
+ limit?: number | undefined;
161
+ search?: string | undefined;
162
+ id?: string | undefined;
163
+ accountNo?: string | undefined;
164
+ msisdn?: string | undefined;
165
+ channel?: COLLECTION_CHANNEL | undefined;
166
+ reference?: string | undefined;
167
+ partnerReference?: string | undefined;
168
+ minAmount?: number | undefined;
169
+ maxAmount?: number | undefined;
170
+ }, {
171
+ status?: string | undefined;
172
+ startDate?: string | undefined;
173
+ endDate?: string | undefined;
174
+ page?: string | undefined;
175
+ limit?: string | undefined;
176
+ search?: string | undefined;
177
+ id?: string | undefined;
178
+ accountNo?: string | undefined;
179
+ msisdn?: string | undefined;
180
+ channel?: string | undefined;
181
+ reference?: string | undefined;
182
+ partnerReference?: string | undefined;
183
+ sortBy?: string | undefined;
184
+ sortOrder?: "asc" | "desc" | undefined;
185
+ minAmount?: string | undefined;
186
+ maxAmount?: string | undefined;
187
+ }>;
152
188
  pagination: z.ZodObject<{
153
189
  page: z.ZodNumber;
154
190
  limit: z.ZodNumber;
@@ -173,7 +209,7 @@ export declare const CollectionDTOSchemas: {
173
209
  }>;
174
210
  paymentStatus: z.ZodNativeEnum<typeof COLLECTION_STATUS>;
175
211
  paymentChannel: z.ZodNativeEnum<typeof COLLECTION_CHANNEL>;
176
- accountSummary: z.ZodObject<{
212
+ walletSummary: z.ZodObject<{
177
213
  balance: z.ZodNumber;
178
214
  availableBalance: z.ZodNumber;
179
215
  accountNumber: z.ZodString;
@@ -192,4 +228,4 @@ export declare const CollectionDTOSchemas: {
192
228
  };
193
229
  export type CollectionDTO = z.infer<typeof CollectionDTOSchemas.collection>;
194
230
  export type CollectionQueryParamsDTO = z.infer<typeof CollectionDTOSchemas.collectionQueryParams>;
195
- export type AccountSummaryDTO = z.infer<typeof CollectionDTOSchemas.accountSummary>;
231
+ export type CollectionURLQueryParamsDTO = z.infer<typeof CollectionDTOSchemas.collectionURLQueryParams>;
@@ -1,6 +1,6 @@
1
- import { BaseRepository, PaginationDTO } from "@/lib/api";
1
+ import { BaseRepository, PaginationDTO, WalletSummaryDTO } from "@/lib/api";
2
2
  import { collectionContract } from "./collection.api-contract";
3
- import { type CollectionQueryParamsDTO, AccountSummaryDTO } from "./collection.dtos";
3
+ import { type CollectionQueryParamsDTO } from "./collection.dtos";
4
4
  import { Collection } from "./collection.model";
5
5
  /**
6
6
  * Repository class for managing collections through API interactions.
@@ -34,5 +34,5 @@ export declare class CollectionRepository extends BaseRepository<typeof collecti
34
34
  /**
35
35
  * Get account balance and summary information
36
36
  */
37
- getBalance(): Promise<AccountSummaryDTO>;
37
+ getBalance(): Promise<WalletSummaryDTO>;
38
38
  }
@@ -0,0 +1,91 @@
1
+ import { CollectionQueryParamsDTO } from "./collection.dtos";
2
+ /**
3
+ * Converts URL search parameters (string-based) to properly typed CollectionQueryParamsDTO.
4
+ *
5
+ * This function handles the conversion from URL search parameters (which are always strings)
6
+ * to the typed DTO used internally. It performs validation and type conversion for:
7
+ * - Numbers (page, limit, amounts)
8
+ * - Enums (status, channel)
9
+ * - Dates (startDate, endDate)
10
+ * - Optional string fields
11
+ *
12
+ * @param urlParams - Raw URL search parameters as key-value string pairs
13
+ * @returns Validated and typed CollectionQueryParamsDTO object
14
+ *
15
+ * @throws {ZodError} When URL parameters fail validation (invalid enum values, malformed numbers, etc.)
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const urlParams = {
20
+ * page: "1",
21
+ * limit: "20",
22
+ * status: "PAYMENT_ACCEPTED",
23
+ * minAmount: "100.50"
24
+ * };
25
+ *
26
+ * const queryParams = urlParamsToQueryParams(urlParams);
27
+ * // Result: { page: 1, limit: 20, status: COLLECTION_STATUS.PAYMENT_ACCEPTED, minAmount: 100.5 }
28
+ * ```
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * // Usage in API route
33
+ * export async function GET(req: NextRequest) {
34
+ * const searchParams = Object.fromEntries(req.nextUrl.searchParams.entries());
35
+ * const queryParams = urlParamsToQueryParams(searchParams);
36
+ * // Now you have properly typed parameters
37
+ * }
38
+ * ```
39
+ */
40
+ export declare function urlParamsToQueryParams(urlParams: Record<string, string>): CollectionQueryParamsDTO;
41
+ /**
42
+ * Converts typed CollectionQueryParamsDTO to URL-safe string parameters.
43
+ *
44
+ * This function transforms the typed DTO back into string-based key-value pairs
45
+ * suitable for URL search parameters or form submission. It:
46
+ * - Filters out undefined and null values
47
+ * - Converts all values to strings
48
+ * - Preserves the original parameter names
49
+ *
50
+ * @param queryParams - Typed collection query parameters
51
+ * @returns Object with string values suitable for URLSearchParams or query string construction
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const queryParams: CollectionQueryParamsDTO = {
56
+ * page: 1,
57
+ * limit: 20,
58
+ * status: COLLECTION_STATUS.PAYMENT_ACCEPTED,
59
+ * minAmount: 100.50,
60
+ * search: "test query"
61
+ * };
62
+ *
63
+ * const urlParams = queryParamsToURLParams(queryParams);
64
+ * // Result: {
65
+ * // page: "1",
66
+ * // limit: "20",
67
+ * // status: "PAYMENT_ACCEPTED",
68
+ * // minAmount: "100.5",
69
+ * // search: "test query"
70
+ * // }
71
+ * ```
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * // Usage with URLSearchParams
76
+ * const queryParams = { page: 1, limit: 20, status: COLLECTION_STATUS.PAYMENT_ACCEPTED };
77
+ * const urlParams = queryParamsToURLParams(queryParams);
78
+ * const searchParams = new URLSearchParams(urlParams);
79
+ * const queryString = searchParams.toString();
80
+ * // Result: "page=1&limit=20&status=PAYMENT_ACCEPTED"
81
+ * ```
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * // Usage in client-side API calls
86
+ * const filters = { status: COLLECTION_STATUS.PENDING_ACK, minAmount: 50 };
87
+ * const urlParams = queryParamsToURLParams(filters);
88
+ * const response = await fetch(`/api/collections?${new URLSearchParams(urlParams)}`);
89
+ * ```
90
+ */
91
+ export declare function queryParamsToURLParams(queryParams: CollectionQueryParamsDTO): Record<string, string>;
@@ -53,7 +53,7 @@ export declare const payoutContract: {
53
53
  path: "";
54
54
  responses: {
55
55
  200: z.ZodObject<{
56
- data: z.ZodArray<z.ZodObject<{
56
+ results: z.ZodArray<z.ZodObject<{
57
57
  id: z.ZodString;
58
58
  statusCode: z.ZodString;
59
59
  statusCodeText: z.ZodNativeEnum<typeof import("./payout.dtos").PAYOUT_STATUS>;
@@ -144,7 +144,7 @@ export declare const payoutContract: {
144
144
  total: z.ZodNumber;
145
145
  }, "strip", z.ZodTypeAny, {
146
146
  total: number;
147
- data: {
147
+ results: {
148
148
  statusCode: string;
149
149
  createdAt: string;
150
150
  id: string;
@@ -176,7 +176,7 @@ export declare const payoutContract: {
176
176
  }[];
177
177
  }, {
178
178
  total: number;
179
- data: {
179
+ results: {
180
180
  statusCode: string;
181
181
  createdAt: string;
182
182
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temboplus/tembo-dashboard",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "A foundational library for Temboplus-Dashboard projects providing type-safe data layer abstraction with API contracts, domain models, and repositories.",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.js",