@temboplus/afloat 0.1.77-beta.6 → 0.1.77-beta.7
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.
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { QueryBuilder } from "@/lib/query/index.js";
|
|
2
|
+
import { WalletQueryDTO } from "./wallet.dtos.js";
|
|
3
|
+
/**
|
|
4
|
+
* Wallet-specific query builder that extends the base QueryBuilder
|
|
5
|
+
* and handles all possible input conversions (DTOs, URL params, etc.)
|
|
6
|
+
*/
|
|
7
|
+
export declare class WalletQuery extends QueryBuilder {
|
|
8
|
+
/**
|
|
9
|
+
* Create empty wallet query with defaults
|
|
10
|
+
*/
|
|
11
|
+
static create(): WalletQuery;
|
|
12
|
+
/**
|
|
13
|
+
* Create from typed DTO/filters object
|
|
14
|
+
*/
|
|
15
|
+
static fromFilters(filters: WalletQueryDTO): WalletQuery;
|
|
16
|
+
/**
|
|
17
|
+
* Create from URL search parameters (strings)
|
|
18
|
+
*/
|
|
19
|
+
static fromUrlParams(params: Record<string, string>): WalletQuery;
|
|
20
|
+
/**
|
|
21
|
+
* Create from URLSearchParams object
|
|
22
|
+
*/
|
|
23
|
+
static fromSearchParams(searchParams: URLSearchParams): WalletQuery;
|
|
24
|
+
/**
|
|
25
|
+
* Create from Next.js Request object
|
|
26
|
+
*/
|
|
27
|
+
static fromRequest(request: Request): WalletQuery;
|
|
28
|
+
/**
|
|
29
|
+
* Create from any supported input type
|
|
30
|
+
*/
|
|
31
|
+
static from(input: QueryBuilder | WalletQueryDTO | Record<string, string> | URLSearchParams | null | undefined): WalletQuery;
|
|
32
|
+
/**
|
|
33
|
+
* Type guard for string records
|
|
34
|
+
*/
|
|
35
|
+
private static isStringRecord;
|
|
36
|
+
whereId(id: string): this;
|
|
37
|
+
whereProfileId(profileId: string): this;
|
|
38
|
+
whereAccountNo(accountNo: string): this;
|
|
39
|
+
whereAccountName(accountName: string): this;
|
|
40
|
+
whereChannel(channel: string): this;
|
|
41
|
+
whereCountryCode(countryCode: string): this;
|
|
42
|
+
whereCurrencyCode(currencyCode: string): this;
|
|
43
|
+
/**
|
|
44
|
+
* Apply all filters from WalletQueryDTO object
|
|
45
|
+
*/
|
|
46
|
+
private applyFilters;
|
|
47
|
+
/**
|
|
48
|
+
* Convert to WalletQueryDTO
|
|
49
|
+
*/
|
|
50
|
+
toFilters(): WalletQueryDTO;
|
|
51
|
+
/**
|
|
52
|
+
* Convert to URL-safe string parameters
|
|
53
|
+
*/
|
|
54
|
+
toUrlParams(): Record<string, string>;
|
|
55
|
+
/**
|
|
56
|
+
* Convert to URLSearchParams
|
|
57
|
+
*/
|
|
58
|
+
toSearchParams(): URLSearchParams;
|
|
59
|
+
/**
|
|
60
|
+
* Convert to query string
|
|
61
|
+
*/
|
|
62
|
+
toQueryString(): string;
|
|
63
|
+
/**
|
|
64
|
+
* Create new instance with wallet ID filter
|
|
65
|
+
*/
|
|
66
|
+
withId(id: string): WalletQuery;
|
|
67
|
+
/**
|
|
68
|
+
* Create new instance with profile ID filter
|
|
69
|
+
*/
|
|
70
|
+
withProfileId(profileId: string): WalletQuery;
|
|
71
|
+
/**
|
|
72
|
+
* Create new instance with account number filter
|
|
73
|
+
*/
|
|
74
|
+
withAccountNo(accountNo: string): WalletQuery;
|
|
75
|
+
/**
|
|
76
|
+
* Create new instance with country code filter
|
|
77
|
+
*/
|
|
78
|
+
withCountryCode(countryCode: string): WalletQuery;
|
|
79
|
+
/**
|
|
80
|
+
* Create new instance with currency code filter
|
|
81
|
+
*/
|
|
82
|
+
withCurrencyCode(currencyCode: string): WalletQuery;
|
|
83
|
+
/**
|
|
84
|
+
* Check if any filters are applied
|
|
85
|
+
*/
|
|
86
|
+
hasFilters(): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Get human-readable filter descriptions
|
|
89
|
+
*/
|
|
90
|
+
getActiveFilters(): string[];
|
|
91
|
+
/**
|
|
92
|
+
* Extract filter values from QueryBuilder options
|
|
93
|
+
*/
|
|
94
|
+
private extractFilterValues;
|
|
95
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { Amount } from "@temboplus/frontend-core";
|
|
2
2
|
import { WalletStatementEntry } from "./statement-entry.model.js";
|
|
3
3
|
import { Wallet } from "./wallet.model.js";
|
|
4
|
-
import { WalletDTOSchemas } from "./wallet.dtos.js";
|
|
5
|
-
import { z } from "zod";
|
|
6
4
|
import { contract } from "./wallet.contract.js";
|
|
7
5
|
import { BaseRepository } from "@/lib/api/base-repository.js";
|
|
6
|
+
import { WalletQuery } from "./wallet.query.js";
|
|
7
|
+
import { WalletQueryDTO } from "./wallet.dtos.js";
|
|
8
|
+
/**
|
|
9
|
+
* Flexible query input type - supports the class, filters interface, URL params, etc.
|
|
10
|
+
*/
|
|
11
|
+
export type WalletQueryInput = WalletQuery | WalletQueryDTO | Record<string, string> | URLSearchParams | null | undefined;
|
|
8
12
|
/**
|
|
9
13
|
* Repository class for managing wallet operations including balance checking,
|
|
10
14
|
* statement generation, and wallet information retrieval.
|
|
@@ -87,13 +91,9 @@ export declare class WalletRepository extends BaseRepository<typeof contract> {
|
|
|
87
91
|
/**
|
|
88
92
|
* Retrieves all wallets associated with the authenticated user.
|
|
89
93
|
*
|
|
90
|
-
* Supports
|
|
91
|
-
* status, or currency filtering.
|
|
94
|
+
* Supports flexible filtering through WalletQuery or plain filter objects.
|
|
92
95
|
*
|
|
93
96
|
* @param query - Optional query parameters for filtering wallets
|
|
94
|
-
* @param query.accountNo - Filter by specific account number
|
|
95
|
-
* @param query.status - Filter by wallet status (active, inactive, etc.)
|
|
96
|
-
* @param query.currencyCode - Filter by currency code
|
|
97
97
|
* @returns Promise that resolves to an array of validated Wallet instances
|
|
98
98
|
* @throws {Error} If the wallet fetch operation fails or data is invalid
|
|
99
99
|
*
|
|
@@ -105,14 +105,38 @@ export declare class WalletRepository extends BaseRepository<typeof contract> {
|
|
|
105
105
|
* // Get specific wallet by account number
|
|
106
106
|
* const specificWallet = await repo.getWallets({ accountNo: '123456789' });
|
|
107
107
|
*
|
|
108
|
-
* // Get wallets with multiple filters
|
|
109
|
-
* const
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
108
|
+
* // Get wallets with multiple filters using WalletQuery
|
|
109
|
+
* const query = WalletQuery.create()
|
|
110
|
+
* .whereCountryCode('TZ')
|
|
111
|
+
* .whereCurrencyCode('TZS');
|
|
112
|
+
* const tzWallets = await repo.getWallets(query);
|
|
113
|
+
*
|
|
114
|
+
* // Get wallets with filters object
|
|
115
|
+
* const usdWallets = await repo.getWallets({ currencyCode: 'USD' });
|
|
113
116
|
* ```
|
|
114
117
|
*/
|
|
115
|
-
getWallets(query?:
|
|
118
|
+
getWallets(query?: WalletQueryInput): Promise<Wallet[]>;
|
|
119
|
+
/**
|
|
120
|
+
* Retrieves a single wallet by its ID.
|
|
121
|
+
*
|
|
122
|
+
* Since the API doesn't have a dedicated /id endpoint, this method queries
|
|
123
|
+
* the list endpoint with the ID filter and returns the first result.
|
|
124
|
+
*
|
|
125
|
+
* @param id - The unique identifier of the wallet to retrieve
|
|
126
|
+
* @returns Promise that resolves to the wallet if found, undefined otherwise
|
|
127
|
+
* @throws {Error} If the fetch operation fails
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const wallet = await repo.getByID("wallet-id");
|
|
132
|
+
* if (wallet) {
|
|
133
|
+
* console.log(`Wallet: ${wallet.accountName}`);
|
|
134
|
+
* } else {
|
|
135
|
+
* console.log('Wallet not found');
|
|
136
|
+
* }
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
getByID(id: string): Promise<Wallet | undefined>;
|
|
116
140
|
/**
|
|
117
141
|
* Retrieves wallet statement entries for a specified date range.
|
|
118
142
|
*
|
|
@@ -170,4 +194,12 @@ export declare class WalletRepository extends BaseRepository<typeof contract> {
|
|
|
170
194
|
wallet?: Wallet;
|
|
171
195
|
accountNo?: string;
|
|
172
196
|
}): Promise<WalletStatementEntry[]>;
|
|
197
|
+
/**
|
|
198
|
+
* Check if a wallet exists with the given query
|
|
199
|
+
*/
|
|
200
|
+
exists(query?: WalletQueryInput): Promise<boolean>;
|
|
201
|
+
/**
|
|
202
|
+
* Get count of wallets matching a query
|
|
203
|
+
*/
|
|
204
|
+
count(query?: WalletQueryInput): Promise<number>;
|
|
173
205
|
}
|