@temboplus/tembo-dashboard 0.0.10 → 0.0.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.
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/lib/query/query.builder.d.ts +1 -1
- package/dist/modules/collection/collection.api-contract.d.ts +16 -16
- package/dist/modules/collection/collection.model.d.ts +1 -1
- package/dist/modules/collection/collection.query.d.ts +119 -0
- package/dist/modules/collection/collection.repository.d.ts +14 -92
- package/dist/modules/collection/{collection.dtos.d.ts → collection.types.d.ts} +3 -41
- package/dist/modules/collection/index.d.ts +3 -5
- package/dist/modules/payout/index.d.ts +3 -3
- package/dist/modules/payout/payout.api-contract.d.ts +17 -62
- package/dist/modules/payout/payout.model.d.ts +1 -1
- package/dist/modules/payout/payout.query.d.ts +119 -0
- package/dist/modules/payout/payout.repository.d.ts +48 -7
- package/dist/modules/payout/{payout.dtos.d.ts → payout.types.d.ts} +82 -6
- package/package.json +1 -1
- package/dist/modules/collection/collection.query-builder.d.ts +0 -27
- package/dist/modules/collection/collection.query-params.model.d.ts +0 -218
- package/dist/modules/collection/collection.utils.d.ts +0 -96
- package/dist/modules/payout/payout.query-builder.d.ts +0 -25
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { QueryBuilder } from "@/lib/query";
|
|
2
|
+
import { COLLECTION_STATUS, COLLECTION_CHANNEL, CollectionFilters } from "./collection.types";
|
|
3
|
+
/**
|
|
4
|
+
* Collection-specific query builder that extends the base QueryBuilder
|
|
5
|
+
* and handles all possible input conversions (DTOs, URL params, etc.)
|
|
6
|
+
*/
|
|
7
|
+
export declare class CollectionQuery extends QueryBuilder {
|
|
8
|
+
/**
|
|
9
|
+
* Create empty collection query with defaults
|
|
10
|
+
*/
|
|
11
|
+
static create(): CollectionQuery;
|
|
12
|
+
/**
|
|
13
|
+
* Create from typed DTO/filters object
|
|
14
|
+
*/
|
|
15
|
+
static fromFilters(filters: CollectionFilters): CollectionQuery;
|
|
16
|
+
/**
|
|
17
|
+
* Create from URL search parameters (strings)
|
|
18
|
+
*/
|
|
19
|
+
static fromUrlParams(params: Record<string, string>): CollectionQuery;
|
|
20
|
+
/**
|
|
21
|
+
* Create from URLSearchParams object
|
|
22
|
+
*/
|
|
23
|
+
static fromSearchParams(searchParams: URLSearchParams): CollectionQuery;
|
|
24
|
+
/**
|
|
25
|
+
* Create from Next.js Request object
|
|
26
|
+
*/
|
|
27
|
+
static fromRequest(request: Request): CollectionQuery;
|
|
28
|
+
/**
|
|
29
|
+
* Create from any supported input type
|
|
30
|
+
*/
|
|
31
|
+
static from(input: QueryBuilder | CollectionFilters | Record<string, string> | URLSearchParams | null | undefined): CollectionQuery;
|
|
32
|
+
/**
|
|
33
|
+
* Type guard for string records
|
|
34
|
+
*/
|
|
35
|
+
private static isStringRecord;
|
|
36
|
+
whereStatus(status: COLLECTION_STATUS): this;
|
|
37
|
+
whereChannel(channel: COLLECTION_CHANNEL): this;
|
|
38
|
+
wherePending(): this;
|
|
39
|
+
whereSuccessful(): this;
|
|
40
|
+
whereFailed(): this;
|
|
41
|
+
whereAmountBetween(min: number, max: number): this;
|
|
42
|
+
whereSender(msisdn: string): this;
|
|
43
|
+
whereAccount(accountNo: string): this;
|
|
44
|
+
whereReference(reference: string): this;
|
|
45
|
+
wherePartnerReference(partnerReference: string): this;
|
|
46
|
+
whereSearch(searchTerm: string): this;
|
|
47
|
+
/**
|
|
48
|
+
* Apply all filters from CollectionFilters object
|
|
49
|
+
*/
|
|
50
|
+
private applyFilters;
|
|
51
|
+
/**
|
|
52
|
+
* Convert to CollectionFilters DTO
|
|
53
|
+
*/
|
|
54
|
+
toFilters(): CollectionFilters;
|
|
55
|
+
/**
|
|
56
|
+
* Convert to URL-safe string parameters
|
|
57
|
+
*/
|
|
58
|
+
toUrlParams(): Record<string, string>;
|
|
59
|
+
/**
|
|
60
|
+
* Convert to URLSearchParams
|
|
61
|
+
*/
|
|
62
|
+
toSearchParams(): URLSearchParams;
|
|
63
|
+
/**
|
|
64
|
+
* Convert to query string
|
|
65
|
+
*/
|
|
66
|
+
toQueryString(): string;
|
|
67
|
+
/**
|
|
68
|
+
* Create new instance with updated pagination
|
|
69
|
+
*/
|
|
70
|
+
withPagination(page: number, limit?: number): CollectionQuery;
|
|
71
|
+
/**
|
|
72
|
+
* Create new instance with updated sorting
|
|
73
|
+
*/
|
|
74
|
+
withSorting(sortBy: string, sortOrder?: "asc" | "desc"): CollectionQuery;
|
|
75
|
+
/**
|
|
76
|
+
* Create new instance with date range
|
|
77
|
+
*/
|
|
78
|
+
withDateRange(startDate?: string, endDate?: string): CollectionQuery;
|
|
79
|
+
/**
|
|
80
|
+
* Create new instance with status filter
|
|
81
|
+
*/
|
|
82
|
+
withStatus(status?: COLLECTION_STATUS): CollectionQuery;
|
|
83
|
+
/**
|
|
84
|
+
* Create new instance with channel filter
|
|
85
|
+
*/
|
|
86
|
+
withChannel(channel?: COLLECTION_CHANNEL): CollectionQuery;
|
|
87
|
+
/**
|
|
88
|
+
* Reset to first page
|
|
89
|
+
*/
|
|
90
|
+
resetPage(): CollectionQuery;
|
|
91
|
+
/**
|
|
92
|
+
* Check if any filters are applied
|
|
93
|
+
*/
|
|
94
|
+
hasFilters(): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Get human-readable filter descriptions
|
|
97
|
+
*/
|
|
98
|
+
getActiveFilters(): string[];
|
|
99
|
+
/**
|
|
100
|
+
* Extract filter values from QueryBuilder options
|
|
101
|
+
*/
|
|
102
|
+
private extractFilterValues;
|
|
103
|
+
/**
|
|
104
|
+
* Extract primary sort field
|
|
105
|
+
*/
|
|
106
|
+
private extractSortField;
|
|
107
|
+
/**
|
|
108
|
+
* Extract primary sort order
|
|
109
|
+
*/
|
|
110
|
+
private extractSortOrder;
|
|
111
|
+
/**
|
|
112
|
+
* Type guard for valid channels
|
|
113
|
+
*/
|
|
114
|
+
private isValidChannel;
|
|
115
|
+
/**
|
|
116
|
+
* Type guard for valid statuses
|
|
117
|
+
*/
|
|
118
|
+
private isValidStatus;
|
|
119
|
+
}
|
|
@@ -1,32 +1,25 @@
|
|
|
1
1
|
import { BaseRepository, PaginationDTO, WalletSummaryDTO } from "@/lib/api";
|
|
2
2
|
import { collectionContract } from "./collection.api-contract";
|
|
3
3
|
import { Collection } from "./collection.model";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { CollectionQuery } from "./collection.query";
|
|
5
|
+
import { CollectionFilters } from "./collection.types";
|
|
6
6
|
/**
|
|
7
|
-
* Flexible query input type - supports the class,
|
|
7
|
+
* Flexible query input type - supports the class, filters interface, URL params, etc.
|
|
8
8
|
*/
|
|
9
|
-
export type CollectionQueryInput =
|
|
9
|
+
export type CollectionQueryInput = CollectionQuery | CollectionFilters | Record<string, string> | URLSearchParams | null | undefined;
|
|
10
10
|
/**
|
|
11
11
|
* Repository class for managing collections through API interactions.
|
|
12
12
|
* Handles collection operations, filtering, and summary data retrieval.
|
|
13
|
-
*
|
|
13
|
+
* Simplified to use CollectionQuery as the primary query interface.
|
|
14
14
|
*/
|
|
15
15
|
export declare class CollectionRepository extends BaseRepository<typeof collectionContract> {
|
|
16
16
|
constructor(options?: {
|
|
17
17
|
token?: string;
|
|
18
18
|
root?: string;
|
|
19
19
|
});
|
|
20
|
-
/**
|
|
21
|
-
* Normalize query input to CollectionQueryParams class instance
|
|
22
|
-
* @param query - Any supported query input type
|
|
23
|
-
* @returns CollectionQueryParams instance
|
|
24
|
-
* @throws Error if validation fails
|
|
25
|
-
*/
|
|
26
|
-
private normalizeQueryParams;
|
|
27
20
|
/**
|
|
28
21
|
* Get all collections with filtering and pagination.
|
|
29
|
-
*
|
|
22
|
+
* Accepts flexible input types and normalizes them to CollectionQuery.
|
|
30
23
|
*
|
|
31
24
|
* @param query - Query parameters in any supported format
|
|
32
25
|
* @returns Promise resolving to collections and pagination info
|
|
@@ -35,16 +28,15 @@ export declare class CollectionRepository extends BaseRepository<typeof collecti
|
|
|
35
28
|
* ```typescript
|
|
36
29
|
* // From API route with URL search params
|
|
37
30
|
* const { searchParams } = new URL(req.url);
|
|
38
|
-
* const
|
|
39
|
-
* const result = await repo.getCollections(stringParams);
|
|
31
|
+
* const result = await repo.getCollections(searchParams);
|
|
40
32
|
*
|
|
41
33
|
* // From client with typed params
|
|
42
|
-
* const
|
|
43
|
-
* const result2 = await repo.getCollections(
|
|
34
|
+
* const filters: CollectionFilters = { page: 1, limit: 20, status: 'PAYMENT_ACCEPTED' };
|
|
35
|
+
* const result2 = await repo.getCollections(filters);
|
|
44
36
|
*
|
|
45
|
-
* // With
|
|
46
|
-
* const
|
|
47
|
-
* const result3 = await repo.getCollections(
|
|
37
|
+
* // With CollectionQuery instance
|
|
38
|
+
* const query = CollectionQuery.create().whereSuccessful().withPagination(1, 50);
|
|
39
|
+
* const result3 = await repo.getCollections(query);
|
|
48
40
|
* ```
|
|
49
41
|
*/
|
|
50
42
|
getCollections(query?: CollectionQueryInput): Promise<{
|
|
@@ -52,42 +44,8 @@ export declare class CollectionRepository extends BaseRepository<typeof collecti
|
|
|
52
44
|
pagination: PaginationDTO;
|
|
53
45
|
}>;
|
|
54
46
|
/**
|
|
55
|
-
* Convenience method
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* @param searchParams - URLSearchParams from request
|
|
59
|
-
* @returns Promise resolving to collections and pagination info
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
* // In API route
|
|
64
|
-
* export async function GET(req: Request) {
|
|
65
|
-
* const { searchParams } = new URL(req.url);
|
|
66
|
-
* const repo = new CollectionRepository({ token });
|
|
67
|
-
* return repo.getCollectionsFromSearchParams(searchParams);
|
|
68
|
-
* }
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
getCollectionsFromSearchParams(searchParams: URLSearchParams): Promise<{
|
|
72
|
-
collections: Collection[];
|
|
73
|
-
pagination: PaginationDTO;
|
|
74
|
-
}>;
|
|
75
|
-
/**
|
|
76
|
-
* Convenience method to get collections from Next.js Request object.
|
|
77
|
-
* Extracts and processes search params automatically.
|
|
78
|
-
*
|
|
79
|
-
* @param req - Next.js Request object
|
|
80
|
-
* @returns Promise resolving to collections and pagination info
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```typescript
|
|
84
|
-
* // In API route
|
|
85
|
-
* export async function GET(req: Request) {
|
|
86
|
-
* const repo = new CollectionRepository({ token });
|
|
87
|
-
* const result = await repo.getCollectionsFromRequest(req);
|
|
88
|
-
* return NextResponse.json(result);
|
|
89
|
-
* }
|
|
90
|
-
* ```
|
|
47
|
+
* Convenience method for Next.js API routes
|
|
48
|
+
* Extracts search params directly from Request object
|
|
91
49
|
*/
|
|
92
50
|
getCollectionsFromRequest(req: Request): Promise<{
|
|
93
51
|
collections: Collection[];
|
|
@@ -110,40 +68,4 @@ export declare class CollectionRepository extends BaseRepository<typeof collecti
|
|
|
110
68
|
* Get account balance and summary information
|
|
111
69
|
*/
|
|
112
70
|
getBalance(): Promise<WalletSummaryDTO>;
|
|
113
|
-
/**
|
|
114
|
-
* Build a query using the fluent query builder interface
|
|
115
|
-
* Returns a query builder instance for complex filtering scenarios.
|
|
116
|
-
*
|
|
117
|
-
* @returns CollectionQueryBuilder instance for method chaining
|
|
118
|
-
*
|
|
119
|
-
* @example
|
|
120
|
-
* ```typescript
|
|
121
|
-
* const collections = await repo.query()
|
|
122
|
-
* .whereSuccessful()
|
|
123
|
-
* .whereAmountBetween(100, 1000)
|
|
124
|
-
* .whereDateBetween('2024-01-01', '2024-01-31')
|
|
125
|
-
* .orderByDesc('amount')
|
|
126
|
-
* .paginate(1, 50)
|
|
127
|
-
* .execute(repo);
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
query(): CollectionQueryBuilderWithExecute;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Extended query builder that includes execute method for direct repository integration
|
|
134
|
-
*/
|
|
135
|
-
declare class CollectionQueryBuilderWithExecute extends CollectionQueryBuilder {
|
|
136
|
-
private builder;
|
|
137
|
-
private repository;
|
|
138
|
-
constructor(builder: CollectionQueryBuilder, repository: CollectionRepository);
|
|
139
|
-
/**
|
|
140
|
-
* Execute the query and return results
|
|
141
|
-
*
|
|
142
|
-
* @returns Promise resolving to collections and pagination info
|
|
143
|
-
*/
|
|
144
|
-
execute(): Promise<{
|
|
145
|
-
collections: Collection[];
|
|
146
|
-
pagination: PaginationDTO;
|
|
147
|
-
}>;
|
|
148
71
|
}
|
|
149
|
-
export {};
|
|
@@ -81,7 +81,7 @@ export declare const CollectionDTOSchemas: {
|
|
|
81
81
|
notes?: string | undefined;
|
|
82
82
|
currencyCode?: string | undefined;
|
|
83
83
|
}>;
|
|
84
|
-
|
|
84
|
+
collectionFilters: z.ZodObject<{
|
|
85
85
|
page: z.ZodDefault<z.ZodNumber>;
|
|
86
86
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
87
87
|
sortBy: z.ZodDefault<z.ZodString>;
|
|
@@ -185,47 +185,9 @@ export declare const CollectionDTOSchemas: {
|
|
|
185
185
|
minAmount?: string | undefined;
|
|
186
186
|
maxAmount?: string | undefined;
|
|
187
187
|
}>;
|
|
188
|
-
pagination: z.ZodObject<{
|
|
189
|
-
page: z.ZodNumber;
|
|
190
|
-
limit: z.ZodNumber;
|
|
191
|
-
total: z.ZodNumber;
|
|
192
|
-
totalPages: z.ZodNumber;
|
|
193
|
-
hasNext: z.ZodBoolean;
|
|
194
|
-
hasPrev: z.ZodBoolean;
|
|
195
|
-
}, "strip", z.ZodTypeAny, {
|
|
196
|
-
page: number;
|
|
197
|
-
limit: number;
|
|
198
|
-
total: number;
|
|
199
|
-
totalPages: number;
|
|
200
|
-
hasNext: boolean;
|
|
201
|
-
hasPrev: boolean;
|
|
202
|
-
}, {
|
|
203
|
-
page: number;
|
|
204
|
-
limit: number;
|
|
205
|
-
total: number;
|
|
206
|
-
totalPages: number;
|
|
207
|
-
hasNext: boolean;
|
|
208
|
-
hasPrev: boolean;
|
|
209
|
-
}>;
|
|
210
188
|
paymentStatus: z.ZodNativeEnum<typeof COLLECTION_STATUS>;
|
|
211
189
|
paymentChannel: z.ZodNativeEnum<typeof COLLECTION_CHANNEL>;
|
|
212
|
-
walletSummary: z.ZodObject<{
|
|
213
|
-
balance: z.ZodNumber;
|
|
214
|
-
availableBalance: z.ZodNumber;
|
|
215
|
-
accountNumber: z.ZodString;
|
|
216
|
-
accountName: z.ZodString;
|
|
217
|
-
}, "strip", z.ZodTypeAny, {
|
|
218
|
-
balance: number;
|
|
219
|
-
availableBalance: number;
|
|
220
|
-
accountNumber: string;
|
|
221
|
-
accountName: string;
|
|
222
|
-
}, {
|
|
223
|
-
balance: number;
|
|
224
|
-
availableBalance: number;
|
|
225
|
-
accountNumber: string;
|
|
226
|
-
accountName: string;
|
|
227
|
-
}>;
|
|
228
190
|
};
|
|
229
191
|
export type CollectionDTO = z.infer<typeof CollectionDTOSchemas.collection>;
|
|
230
|
-
export type
|
|
231
|
-
export type
|
|
192
|
+
export type CollectionFilters = z.infer<typeof CollectionDTOSchemas.collectionFilters>;
|
|
193
|
+
export type CollectionURLQueryParams = z.infer<typeof CollectionDTOSchemas.collectionURLQueryParams>;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export * from "./collection.api-contract";
|
|
2
|
-
export * from "./collection.dtos";
|
|
3
|
-
export * from "./collection.model";
|
|
4
|
-
export * from "./collection.query-builder";
|
|
5
2
|
export * from "./collection.repository";
|
|
6
|
-
export * from "./collection.
|
|
7
|
-
export * from "./collection.
|
|
3
|
+
export * from "./collection.model";
|
|
4
|
+
export * from "./collection.types";
|
|
5
|
+
export * from "./collection.query";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "./payout.api-contract";
|
|
2
|
-
export * from "./payout.dtos";
|
|
3
|
-
export * from "./payout.model";
|
|
4
|
-
export * from "./payout.query-builder";
|
|
5
2
|
export * from "./payout.repository";
|
|
3
|
+
export * from "./payout.types";
|
|
4
|
+
export * from "./payout.model";
|
|
5
|
+
export * from "./payout.query";
|
|
@@ -1,52 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const payoutContract: {
|
|
3
3
|
getPayouts: {
|
|
4
|
-
query:
|
|
5
|
-
page: z.ZodDefault<z.ZodNumber>;
|
|
6
|
-
limit: z.ZodDefault<z.ZodNumber>;
|
|
7
|
-
sortBy: z.ZodDefault<z.ZodString>;
|
|
8
|
-
sortOrder: z.ZodDefault<z.ZodEnum<["asc", "desc"]>>;
|
|
9
|
-
startDate: z.ZodOptional<z.ZodString>;
|
|
10
|
-
endDate: z.ZodOptional<z.ZodString>;
|
|
11
|
-
msisdn: z.ZodOptional<z.ZodString>;
|
|
12
|
-
id: z.ZodOptional<z.ZodString>;
|
|
13
|
-
ref: z.ZodOptional<z.ZodString>;
|
|
14
|
-
channel: z.ZodOptional<z.ZodUnion<[z.ZodNativeEnum<typeof import("./payout.dtos").MOBILE_PAYOUT_CHANNEL>, z.ZodNativeEnum<typeof import("./payout.dtos").BANK_PAYOUT_CHANNEL>]>>;
|
|
15
|
-
status: z.ZodOptional<z.ZodNativeEnum<typeof import("./payout.dtos").PAYOUT_STATUS>>;
|
|
16
|
-
minAmount: z.ZodOptional<z.ZodNumber>;
|
|
17
|
-
maxAmount: z.ZodOptional<z.ZodNumber>;
|
|
18
|
-
search: z.ZodOptional<z.ZodString>;
|
|
19
|
-
}, "strip", z.ZodTypeAny, {
|
|
20
|
-
page: number;
|
|
21
|
-
limit: number;
|
|
22
|
-
sortBy: string;
|
|
23
|
-
sortOrder: "asc" | "desc";
|
|
24
|
-
status?: import("./payout.dtos").PAYOUT_STATUS | undefined;
|
|
25
|
-
startDate?: string | undefined;
|
|
26
|
-
endDate?: string | undefined;
|
|
27
|
-
search?: string | undefined;
|
|
28
|
-
id?: string | undefined;
|
|
29
|
-
msisdn?: string | undefined;
|
|
30
|
-
channel?: import("./payout.dtos").MOBILE_PAYOUT_CHANNEL | import("./payout.dtos").BANK_PAYOUT_CHANNEL | undefined;
|
|
31
|
-
minAmount?: number | undefined;
|
|
32
|
-
maxAmount?: number | undefined;
|
|
33
|
-
ref?: string | undefined;
|
|
34
|
-
}, {
|
|
35
|
-
status?: import("./payout.dtos").PAYOUT_STATUS | undefined;
|
|
36
|
-
startDate?: string | undefined;
|
|
37
|
-
endDate?: string | undefined;
|
|
38
|
-
page?: number | undefined;
|
|
39
|
-
limit?: number | undefined;
|
|
40
|
-
search?: string | undefined;
|
|
41
|
-
id?: string | undefined;
|
|
42
|
-
msisdn?: string | undefined;
|
|
43
|
-
channel?: import("./payout.dtos").MOBILE_PAYOUT_CHANNEL | import("./payout.dtos").BANK_PAYOUT_CHANNEL | undefined;
|
|
44
|
-
sortBy?: string | undefined;
|
|
45
|
-
sortOrder?: "asc" | "desc" | undefined;
|
|
46
|
-
minAmount?: number | undefined;
|
|
47
|
-
maxAmount?: number | undefined;
|
|
48
|
-
ref?: string | undefined;
|
|
49
|
-
}>;
|
|
4
|
+
query: any;
|
|
50
5
|
summary: "List payouts";
|
|
51
6
|
description: "Retrieve a paginated list of payouts with optional filtering";
|
|
52
7
|
method: "GET";
|
|
@@ -56,10 +11,10 @@ export declare const payoutContract: {
|
|
|
56
11
|
results: z.ZodArray<z.ZodObject<{
|
|
57
12
|
id: z.ZodString;
|
|
58
13
|
statusCode: z.ZodString;
|
|
59
|
-
statusCodeText: z.ZodNativeEnum<typeof import("./payout.
|
|
14
|
+
statusCodeText: z.ZodNativeEnum<typeof import("./payout.types").PAYOUT_STATUS>;
|
|
60
15
|
statusDescription: z.ZodString;
|
|
61
16
|
countryCode: z.ZodString;
|
|
62
|
-
serviceCode: z.ZodUnion<[z.ZodNativeEnum<typeof import("./payout.
|
|
17
|
+
serviceCode: z.ZodUnion<[z.ZodNativeEnum<typeof import("./payout.types").MOBILE_PAYOUT_CHANNEL>, z.ZodNativeEnum<typeof import("./payout.types").BANK_PAYOUT_CHANNEL>]>;
|
|
63
18
|
amount: z.ZodNumber;
|
|
64
19
|
serviceFee: z.ZodOptional<z.ZodString>;
|
|
65
20
|
postedAmount: z.ZodOptional<z.ZodString>;
|
|
@@ -92,10 +47,10 @@ export declare const payoutContract: {
|
|
|
92
47
|
amount: number;
|
|
93
48
|
transactionId: string;
|
|
94
49
|
currencyCode: string;
|
|
95
|
-
statusCodeText: import("./payout.
|
|
50
|
+
statusCodeText: import("./payout.types").PAYOUT_STATUS;
|
|
96
51
|
statusDescription: string;
|
|
97
52
|
countryCode: string;
|
|
98
|
-
serviceCode: import("./payout.
|
|
53
|
+
serviceCode: import("./payout.types").MOBILE_PAYOUT_CHANNEL | import("./payout.types").BANK_PAYOUT_CHANNEL;
|
|
99
54
|
transactionRef: string;
|
|
100
55
|
walletId?: string | undefined;
|
|
101
56
|
serviceFee?: string | undefined;
|
|
@@ -121,10 +76,10 @@ export declare const payoutContract: {
|
|
|
121
76
|
amount: number;
|
|
122
77
|
transactionId: string;
|
|
123
78
|
currencyCode: string;
|
|
124
|
-
statusCodeText: import("./payout.
|
|
79
|
+
statusCodeText: import("./payout.types").PAYOUT_STATUS;
|
|
125
80
|
statusDescription: string;
|
|
126
81
|
countryCode: string;
|
|
127
|
-
serviceCode: import("./payout.
|
|
82
|
+
serviceCode: import("./payout.types").MOBILE_PAYOUT_CHANNEL | import("./payout.types").BANK_PAYOUT_CHANNEL;
|
|
128
83
|
transactionRef: string;
|
|
129
84
|
walletId?: string | undefined;
|
|
130
85
|
serviceFee?: string | undefined;
|
|
@@ -154,10 +109,10 @@ export declare const payoutContract: {
|
|
|
154
109
|
amount: number;
|
|
155
110
|
transactionId: string;
|
|
156
111
|
currencyCode: string;
|
|
157
|
-
statusCodeText: import("./payout.
|
|
112
|
+
statusCodeText: import("./payout.types").PAYOUT_STATUS;
|
|
158
113
|
statusDescription: string;
|
|
159
114
|
countryCode: string;
|
|
160
|
-
serviceCode: import("./payout.
|
|
115
|
+
serviceCode: import("./payout.types").MOBILE_PAYOUT_CHANNEL | import("./payout.types").BANK_PAYOUT_CHANNEL;
|
|
161
116
|
transactionRef: string;
|
|
162
117
|
walletId?: string | undefined;
|
|
163
118
|
serviceFee?: string | undefined;
|
|
@@ -186,10 +141,10 @@ export declare const payoutContract: {
|
|
|
186
141
|
amount: number;
|
|
187
142
|
transactionId: string;
|
|
188
143
|
currencyCode: string;
|
|
189
|
-
statusCodeText: import("./payout.
|
|
144
|
+
statusCodeText: import("./payout.types").PAYOUT_STATUS;
|
|
190
145
|
statusDescription: string;
|
|
191
146
|
countryCode: string;
|
|
192
|
-
serviceCode: import("./payout.
|
|
147
|
+
serviceCode: import("./payout.types").MOBILE_PAYOUT_CHANNEL | import("./payout.types").BANK_PAYOUT_CHANNEL;
|
|
193
148
|
transactionRef: string;
|
|
194
149
|
walletId?: string | undefined;
|
|
195
150
|
serviceFee?: string | undefined;
|
|
@@ -239,10 +194,10 @@ export declare const payoutContract: {
|
|
|
239
194
|
200: z.ZodObject<{
|
|
240
195
|
id: z.ZodString;
|
|
241
196
|
statusCode: z.ZodString;
|
|
242
|
-
statusCodeText: z.ZodNativeEnum<typeof import("./payout.
|
|
197
|
+
statusCodeText: z.ZodNativeEnum<typeof import("./payout.types").PAYOUT_STATUS>;
|
|
243
198
|
statusDescription: z.ZodString;
|
|
244
199
|
countryCode: z.ZodString;
|
|
245
|
-
serviceCode: z.ZodUnion<[z.ZodNativeEnum<typeof import("./payout.
|
|
200
|
+
serviceCode: z.ZodUnion<[z.ZodNativeEnum<typeof import("./payout.types").MOBILE_PAYOUT_CHANNEL>, z.ZodNativeEnum<typeof import("./payout.types").BANK_PAYOUT_CHANNEL>]>;
|
|
246
201
|
amount: z.ZodNumber;
|
|
247
202
|
serviceFee: z.ZodOptional<z.ZodString>;
|
|
248
203
|
postedAmount: z.ZodOptional<z.ZodString>;
|
|
@@ -275,10 +230,10 @@ export declare const payoutContract: {
|
|
|
275
230
|
amount: number;
|
|
276
231
|
transactionId: string;
|
|
277
232
|
currencyCode: string;
|
|
278
|
-
statusCodeText: import("./payout.
|
|
233
|
+
statusCodeText: import("./payout.types").PAYOUT_STATUS;
|
|
279
234
|
statusDescription: string;
|
|
280
235
|
countryCode: string;
|
|
281
|
-
serviceCode: import("./payout.
|
|
236
|
+
serviceCode: import("./payout.types").MOBILE_PAYOUT_CHANNEL | import("./payout.types").BANK_PAYOUT_CHANNEL;
|
|
282
237
|
transactionRef: string;
|
|
283
238
|
walletId?: string | undefined;
|
|
284
239
|
serviceFee?: string | undefined;
|
|
@@ -304,10 +259,10 @@ export declare const payoutContract: {
|
|
|
304
259
|
amount: number;
|
|
305
260
|
transactionId: string;
|
|
306
261
|
currencyCode: string;
|
|
307
|
-
statusCodeText: import("./payout.
|
|
262
|
+
statusCodeText: import("./payout.types").PAYOUT_STATUS;
|
|
308
263
|
statusDescription: string;
|
|
309
264
|
countryCode: string;
|
|
310
|
-
serviceCode: import("./payout.
|
|
265
|
+
serviceCode: import("./payout.types").MOBILE_PAYOUT_CHANNEL | import("./payout.types").BANK_PAYOUT_CHANNEL;
|
|
311
266
|
transactionRef: string;
|
|
312
267
|
walletId?: string | undefined;
|
|
313
268
|
serviceFee?: string | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Amount, AmountJson, Bank } from "@temboplus/frontend-core";
|
|
2
|
-
import { BANK_PAYOUT_CHANNEL, MOBILE_PAYOUT_CHANNEL, PAYOUT_CHANNEL, PAYOUT_STATUS } from "./payout.
|
|
2
|
+
import { BANK_PAYOUT_CHANNEL, MOBILE_PAYOUT_CHANNEL, PAYOUT_CHANNEL, PAYOUT_STATUS } from "./payout.types";
|
|
3
3
|
export interface PayoutStatusInfo {
|
|
4
4
|
label: string;
|
|
5
5
|
description: string;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { QueryBuilder } from "@/lib/query";
|
|
2
|
+
import { PAYOUT_STATUS, PAYOUT_CHANNEL, PayoutFilters } from "./payout.types";
|
|
3
|
+
/**
|
|
4
|
+
* Payout-specific query builder that extends the base QueryBuilder
|
|
5
|
+
* and handles all possible input conversions (DTOs, URL params, etc.)
|
|
6
|
+
*/
|
|
7
|
+
export declare class PayoutQuery extends QueryBuilder {
|
|
8
|
+
/**
|
|
9
|
+
* Create empty payout query with defaults
|
|
10
|
+
*/
|
|
11
|
+
static create(): PayoutQuery;
|
|
12
|
+
/**
|
|
13
|
+
* Create from typed DTO/filters object
|
|
14
|
+
*/
|
|
15
|
+
static fromFilters(filters: PayoutFilters): PayoutQuery;
|
|
16
|
+
/**
|
|
17
|
+
* Create from URL search parameters (strings)
|
|
18
|
+
*/
|
|
19
|
+
static fromUrlParams(params: Record<string, string>): PayoutQuery;
|
|
20
|
+
/**
|
|
21
|
+
* Create from URLSearchParams object
|
|
22
|
+
*/
|
|
23
|
+
static fromSearchParams(searchParams: URLSearchParams): PayoutQuery;
|
|
24
|
+
/**
|
|
25
|
+
* Create from Next.js Request object
|
|
26
|
+
*/
|
|
27
|
+
static fromRequest(request: Request): PayoutQuery;
|
|
28
|
+
/**
|
|
29
|
+
* Create from any supported input type
|
|
30
|
+
*/
|
|
31
|
+
static from(input: QueryBuilder | PayoutFilters | Record<string, string> | URLSearchParams | null | undefined): PayoutQuery;
|
|
32
|
+
/**
|
|
33
|
+
* Type guard for string records
|
|
34
|
+
*/
|
|
35
|
+
private static isStringRecord;
|
|
36
|
+
whereStatus(status: PAYOUT_STATUS): this;
|
|
37
|
+
whereChannel(channel: PAYOUT_CHANNEL): this;
|
|
38
|
+
wherePending(): this;
|
|
39
|
+
whereSuccessful(): this;
|
|
40
|
+
whereFailed(): this;
|
|
41
|
+
whereAmountBetween(min: number, max: number): this;
|
|
42
|
+
whereRecipient(msisdn: string): this;
|
|
43
|
+
whereReference(ref: string): this;
|
|
44
|
+
whereMobile(): this;
|
|
45
|
+
whereBank(): this;
|
|
46
|
+
whereSearch(searchTerm: string): this;
|
|
47
|
+
/**
|
|
48
|
+
* Apply all filters from PayoutFilters object
|
|
49
|
+
*/
|
|
50
|
+
private applyFilters;
|
|
51
|
+
/**
|
|
52
|
+
* Convert to PayoutFilters DTO
|
|
53
|
+
*/
|
|
54
|
+
toFilters(): PayoutFilters;
|
|
55
|
+
/**
|
|
56
|
+
* Convert to URL-safe string parameters
|
|
57
|
+
*/
|
|
58
|
+
toUrlParams(): Record<string, string>;
|
|
59
|
+
/**
|
|
60
|
+
* Convert to URLSearchParams
|
|
61
|
+
*/
|
|
62
|
+
toSearchParams(): URLSearchParams;
|
|
63
|
+
/**
|
|
64
|
+
* Convert to query string
|
|
65
|
+
*/
|
|
66
|
+
toQueryString(): string;
|
|
67
|
+
/**
|
|
68
|
+
* Create new instance with updated pagination
|
|
69
|
+
*/
|
|
70
|
+
withPagination(page: number, limit?: number): PayoutQuery;
|
|
71
|
+
/**
|
|
72
|
+
* Create new instance with updated sorting
|
|
73
|
+
*/
|
|
74
|
+
withSorting(sortBy: string, sortOrder?: "asc" | "desc"): PayoutQuery;
|
|
75
|
+
/**
|
|
76
|
+
* Create new instance with date range
|
|
77
|
+
*/
|
|
78
|
+
withDateRange(startDate?: string, endDate?: string): PayoutQuery;
|
|
79
|
+
/**
|
|
80
|
+
* Create new instance with status filter
|
|
81
|
+
*/
|
|
82
|
+
withStatus(status?: PAYOUT_STATUS): PayoutQuery;
|
|
83
|
+
/**
|
|
84
|
+
* Create new instance with channel filter
|
|
85
|
+
*/
|
|
86
|
+
withChannel(channel?: PAYOUT_CHANNEL): PayoutQuery;
|
|
87
|
+
/**
|
|
88
|
+
* Reset to first page
|
|
89
|
+
*/
|
|
90
|
+
resetPage(): PayoutQuery;
|
|
91
|
+
/**
|
|
92
|
+
* Check if any filters are applied
|
|
93
|
+
*/
|
|
94
|
+
hasFilters(): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Get human-readable filter descriptions
|
|
97
|
+
*/
|
|
98
|
+
getActiveFilters(): string[];
|
|
99
|
+
/**
|
|
100
|
+
* Extract filter values from QueryBuilder options
|
|
101
|
+
*/
|
|
102
|
+
private extractFilterValues;
|
|
103
|
+
/**
|
|
104
|
+
* Extract primary sort field
|
|
105
|
+
*/
|
|
106
|
+
private extractSortField;
|
|
107
|
+
/**
|
|
108
|
+
* Extract primary sort order
|
|
109
|
+
*/
|
|
110
|
+
private extractSortOrder;
|
|
111
|
+
/**
|
|
112
|
+
* Type guard for valid channels
|
|
113
|
+
*/
|
|
114
|
+
private isValidChannel;
|
|
115
|
+
/**
|
|
116
|
+
* Type guard for valid statuses
|
|
117
|
+
*/
|
|
118
|
+
private isValidStatus;
|
|
119
|
+
}
|