@temboplus/afloat 0.2.1-beta.10 → 0.2.1-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.
- 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 +8 -2
- package/dist/modules/wallet/wallet.contract.d.ts +6 -6
- package/dist/modules/wallet/wallet.dtos.d.ts +10 -0
- package/dist/modules/wallet/wallet.repository.d.ts +38 -18
- package/package.json +1 -1
|
@@ -28,8 +28,14 @@ export declare class QueryBuilder {
|
|
|
28
28
|
whereLessThanOrEqual(field: string, value: any): this;
|
|
29
29
|
whereBetween(field: string, min: any, max: any): this;
|
|
30
30
|
/**
|
|
31
|
-
* Filter by date range with support for Date objects, strings, and null
|
|
32
|
-
* Internally converts to createdAt:gte and createdAt:lte filters
|
|
31
|
+
* Filter by date range with support for Date objects, strings, and null.
|
|
32
|
+
* Internally converts to createdAt:gte and createdAt:lte filters.
|
|
33
|
+
*
|
|
34
|
+
* Date objects are normalised to UTC-`Z` ISO format on the wire,
|
|
35
|
+
* regardless of subclass. Some host-app helpers (e.g. `@date-fns/tz`'s
|
|
36
|
+
* `TZDate`) override `.toISOString()` to emit `+HH:MM` offset form;
|
|
37
|
+
* routing through `new Date(d.getTime())` strips the zone identity and
|
|
38
|
+
* forces the canonical UTC representation.
|
|
33
39
|
*/
|
|
34
40
|
whereDateBetween(startDate?: string | Date | null, endDate?: string | Date | null): this;
|
|
35
41
|
addSort(criteria: SortCriteria): this;
|
|
@@ -86,16 +86,16 @@ export declare const contract: {
|
|
|
86
86
|
summary: "Get Wallet Statement";
|
|
87
87
|
method: "POST";
|
|
88
88
|
body: z.ZodObject<{
|
|
89
|
-
endDate: z.
|
|
90
|
-
startDate: z.
|
|
89
|
+
endDate: z.ZodString;
|
|
90
|
+
startDate: z.ZodString;
|
|
91
91
|
accountNo: z.ZodOptional<z.ZodString>;
|
|
92
92
|
}, "strip", z.ZodTypeAny, {
|
|
93
|
-
startDate:
|
|
94
|
-
endDate:
|
|
93
|
+
startDate: string;
|
|
94
|
+
endDate: string;
|
|
95
95
|
accountNo?: string | undefined;
|
|
96
96
|
}, {
|
|
97
|
-
startDate:
|
|
98
|
-
endDate:
|
|
97
|
+
startDate: string;
|
|
98
|
+
endDate: string;
|
|
99
99
|
accountNo?: string | undefined;
|
|
100
100
|
}>;
|
|
101
101
|
path: "/statement";
|
|
@@ -102,6 +102,14 @@ declare const statementEntrySchema: z.ZodObject<{
|
|
|
102
102
|
accountNo?: string | undefined;
|
|
103
103
|
currencyCode?: string | undefined;
|
|
104
104
|
}>;
|
|
105
|
+
/**
|
|
106
|
+
* Plain calendar date as a `YYYY-MM-DD` string. Used by endpoints that
|
|
107
|
+
* filter against a calendar day rather than a moment in time — e.g. the
|
|
108
|
+
* statement endpoint, which the server evaluates against EAT-anchored
|
|
109
|
+
* data. Validated by regex to avoid silently sending a full ISO
|
|
110
|
+
* timestamp where a date-only string is expected.
|
|
111
|
+
*/
|
|
112
|
+
declare const plainDateSchema: z.ZodString;
|
|
105
113
|
/**
|
|
106
114
|
* Collection of wallet-related schemas for export.
|
|
107
115
|
* Provides access to both wallet and statement entry validation schemas.
|
|
@@ -197,8 +205,10 @@ export declare const WalletDTOSchemas: {
|
|
|
197
205
|
accountNo?: string | undefined;
|
|
198
206
|
currencyCode?: string | undefined;
|
|
199
207
|
}>;
|
|
208
|
+
plainDate: z.ZodString;
|
|
200
209
|
};
|
|
201
210
|
export type WalletDTO = z.infer<typeof walletSchema>;
|
|
202
211
|
export type WalletQueryDTO = z.infer<typeof walletQuerySchema>;
|
|
203
212
|
export type WalletStatementEntryDTO = z.infer<typeof statementEntrySchema>;
|
|
213
|
+
export type PlainDate = z.infer<typeof plainDateSchema>;
|
|
204
214
|
export {};
|
|
@@ -144,52 +144,60 @@ export declare class WalletRepository extends BaseRepository<typeof contract> {
|
|
|
144
144
|
* 1. Direct wallet object (preferred for performance and currency context)
|
|
145
145
|
* 2. Account number lookup (requires additional API call to determine currency)
|
|
146
146
|
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
147
|
+
* The statement endpoint filters by calendar day, evaluated against
|
|
148
|
+
* the EAT-anchored database. Bounds are therefore *plain* date strings
|
|
149
|
+
* (`YYYY-MM-DD`), not full timestamps — sending a datetime gets
|
|
150
|
+
* rejected upstream. If you have `Date` objects from a picker, format
|
|
151
|
+
* them with the exported `toPlainDate` helper.
|
|
150
152
|
*
|
|
151
153
|
* @param props - The statement request properties
|
|
152
154
|
* @param props.wallet - The wallet to get statement for (preferred method)
|
|
153
155
|
* @param props.accountNo - Alternative: account number to lookup wallet and fetch statement
|
|
154
|
-
* @param props.range -
|
|
155
|
-
*
|
|
156
|
-
* @param props.range.
|
|
156
|
+
* @param props.range - Required date range. Both bounds are `YYYY-MM-DD`
|
|
157
|
+
* strings; they correspond to calendar days in EAT.
|
|
158
|
+
* @param props.range.startDate - Start of statement period (inclusive), `YYYY-MM-DD`
|
|
159
|
+
* @param props.range.endDate - End of statement period (inclusive), `YYYY-MM-DD`
|
|
157
160
|
* @returns Promise that resolves to an array of validated WalletStatementEntry instances with Narration objects
|
|
158
161
|
* @throws {Error} If neither wallet nor accountNo is provided
|
|
159
162
|
* @throws {Error} If accountNo is provided but no matching wallet is found
|
|
163
|
+
* @throws {Error} If either `range` bound isn't a valid `YYYY-MM-DD` string
|
|
160
164
|
* @throws {Error} If the statement fetch operation fails or data is invalid
|
|
161
165
|
*
|
|
162
166
|
* @example
|
|
163
167
|
* ```typescript
|
|
164
168
|
* // Method 1: Using wallet object (recommended)
|
|
165
169
|
* const wallet = await repo.getWallets().then(w => w[0]);
|
|
166
|
-
* const
|
|
170
|
+
* const entries = await repo.getStatement({
|
|
171
|
+
* wallet,
|
|
172
|
+
* range: { startDate: "2024-01-01", endDate: "2024-01-31" },
|
|
173
|
+
* });
|
|
167
174
|
*
|
|
168
175
|
* // Method 2: Using account number
|
|
169
|
-
* const
|
|
170
|
-
* accountNo: '123456789'
|
|
176
|
+
* const byAccount = await repo.getStatement({
|
|
177
|
+
* accountNo: '123456789',
|
|
178
|
+
* range: { startDate: "2024-01-01", endDate: "2024-01-31" },
|
|
171
179
|
* });
|
|
172
180
|
*
|
|
173
|
-
* //
|
|
174
|
-
* const
|
|
181
|
+
* // From a Date picker
|
|
182
|
+
* const entries = await repo.getStatement({
|
|
175
183
|
* wallet,
|
|
176
184
|
* range: {
|
|
177
|
-
* startDate:
|
|
178
|
-
* endDate:
|
|
179
|
-
* }
|
|
185
|
+
* startDate: toPlainDate(pickedFromDate),
|
|
186
|
+
* endDate: toPlainDate(pickedToDate),
|
|
187
|
+
* },
|
|
180
188
|
* });
|
|
181
189
|
*
|
|
182
190
|
* // Process payout transactions
|
|
183
|
-
* const payoutEntries =
|
|
191
|
+
* const payoutEntries = entries.filter(entry => entry.isPayout);
|
|
184
192
|
* payoutEntries.forEach(entry => {
|
|
185
193
|
* console.log(`Payout ID: ${entry.payoutId}, Amount: ${entry.amountDebited.label}`);
|
|
186
194
|
* });
|
|
187
195
|
* ```
|
|
188
196
|
*/
|
|
189
197
|
getStatement(props: {
|
|
190
|
-
range
|
|
191
|
-
startDate:
|
|
192
|
-
endDate:
|
|
198
|
+
range: {
|
|
199
|
+
startDate: string;
|
|
200
|
+
endDate: string;
|
|
193
201
|
};
|
|
194
202
|
wallet?: Wallet;
|
|
195
203
|
accountNo?: string;
|
|
@@ -203,3 +211,15 @@ export declare class WalletRepository extends BaseRepository<typeof contract> {
|
|
|
203
211
|
*/
|
|
204
212
|
count(query?: WalletQueryInput): Promise<number>;
|
|
205
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Format a `Date` as `YYYY-MM-DD` using its local (browser/runtime)
|
|
216
|
+
* Y/M/D fields. Use this to convert a picker-emitted `Date` into the
|
|
217
|
+
* plain-date string `getStatement` expects.
|
|
218
|
+
*
|
|
219
|
+
* The local-field choice is intentional: a `react-day-picker` (or any
|
|
220
|
+
* grid-based) calendar picks a wall-clock day in the runtime's clock,
|
|
221
|
+
* and that's the calendar day the user expects to filter against. If
|
|
222
|
+
* you need to bias the conversion toward a specific zone, pre-position
|
|
223
|
+
* the `Date` (e.g. via `@date-fns/tz`'s `TZDate`) before calling this.
|
|
224
|
+
*/
|
|
225
|
+
export declare function toPlainDate(date: Date): string;
|