@pfm-platform/accounts-data-access 0.2.0
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 +316 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +702 -0
- package/dist/index.d.ts +702 -0
- package/dist/index.js +299 -0
- package/dist/index.js.map +1 -0
- package/package.json +62 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,702 @@
|
|
|
1
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
+
import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
|
|
3
|
+
import { AccountsResponse, Account, NetWorth, AccountCreate, AccountUpdate, NetWorthAsset, NetWorthDebt, NetWorthAccountCreate, NetWorthAccountUpdate } from '@pfm-platform/shared';
|
|
4
|
+
import * as axios from 'axios';
|
|
5
|
+
|
|
6
|
+
interface UseAccountsParams {
|
|
7
|
+
userId: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Fetch all accounts for a user
|
|
11
|
+
* Uses Zod validation to ensure API response matches expected schema
|
|
12
|
+
*
|
|
13
|
+
* @param params - Query parameters
|
|
14
|
+
* @param options - TanStack Query options
|
|
15
|
+
* @returns Query result with validated accounts data
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* function AccountsList() {
|
|
20
|
+
* const { data, isLoading, error } = useAccounts({ userId: 'user123' });
|
|
21
|
+
*
|
|
22
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
23
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
24
|
+
*
|
|
25
|
+
* return (
|
|
26
|
+
* <ul>
|
|
27
|
+
* {data.accounts.map(account => (
|
|
28
|
+
* <li key={account.id}>{account.name}</li>
|
|
29
|
+
* ))}
|
|
30
|
+
* </ul>
|
|
31
|
+
* );
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare function useAccounts(params: UseAccountsParams, options?: Omit<UseQueryOptions<AccountsResponse>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
|
|
36
|
+
accounts: {
|
|
37
|
+
id: number;
|
|
38
|
+
name: string;
|
|
39
|
+
balance: string;
|
|
40
|
+
account_type: "checking" | "savings" | "cards" | "student_loans" | "bill" | "autos" | "home" | "investment" | "loan" | "asset" | "cd" | "money_market" | "certificates" | "commercial" | "creditline";
|
|
41
|
+
state: "active" | "closed" | "archived" | "pending_deletion";
|
|
42
|
+
aggregation_type: "finicity" | "cashedge" | "partner";
|
|
43
|
+
harvest_updated_at: string | null;
|
|
44
|
+
include_in_expenses: boolean;
|
|
45
|
+
include_in_budget: boolean;
|
|
46
|
+
include_in_cashflow: boolean;
|
|
47
|
+
include_in_dashboard: boolean;
|
|
48
|
+
include_in_goals: boolean;
|
|
49
|
+
include_in_networth: boolean;
|
|
50
|
+
fi: {
|
|
51
|
+
id: number;
|
|
52
|
+
name: string;
|
|
53
|
+
} | null;
|
|
54
|
+
cashedge_account_type: {
|
|
55
|
+
name: string;
|
|
56
|
+
acct_type: string;
|
|
57
|
+
ext_type: string;
|
|
58
|
+
group: string;
|
|
59
|
+
} | null;
|
|
60
|
+
locked_balance?: string | null | undefined;
|
|
61
|
+
preferred_balance_type?: "Available" | "Current" | "Outstanding" | null | undefined;
|
|
62
|
+
display_account_type?: string | undefined;
|
|
63
|
+
reference_id?: string | undefined;
|
|
64
|
+
error?: {
|
|
65
|
+
message: string;
|
|
66
|
+
code: string;
|
|
67
|
+
actionable: boolean;
|
|
68
|
+
description?: string | undefined;
|
|
69
|
+
} | null | undefined;
|
|
70
|
+
other_balances?: {
|
|
71
|
+
balance_type: string;
|
|
72
|
+
balance: string;
|
|
73
|
+
}[] | undefined;
|
|
74
|
+
}[];
|
|
75
|
+
}, Error>;
|
|
76
|
+
|
|
77
|
+
interface UseAccountParams {
|
|
78
|
+
userId: string;
|
|
79
|
+
accountId: number;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Fetch a single account by ID
|
|
83
|
+
* Uses Zod validation to ensure API response matches expected schema
|
|
84
|
+
*
|
|
85
|
+
* @param params - Query parameters
|
|
86
|
+
* @param options - TanStack Query options
|
|
87
|
+
* @returns Query result with validated account data
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```tsx
|
|
91
|
+
* function AccountDetail({ accountId }: { accountId: number }) {
|
|
92
|
+
* const { data, isLoading, error } = useAccount({
|
|
93
|
+
* userId: 'user123',
|
|
94
|
+
* accountId
|
|
95
|
+
* });
|
|
96
|
+
*
|
|
97
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
98
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
99
|
+
*
|
|
100
|
+
* return (
|
|
101
|
+
* <div>
|
|
102
|
+
* <h2>{data.name}</h2>
|
|
103
|
+
* <p>Balance: ${data.balance}</p>
|
|
104
|
+
* <p>Type: {data.account_type}</p>
|
|
105
|
+
* </div>
|
|
106
|
+
* );
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
declare function useAccount(params: UseAccountParams, options?: Omit<UseQueryOptions<Account>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
|
|
111
|
+
id: number;
|
|
112
|
+
name: string;
|
|
113
|
+
balance: string;
|
|
114
|
+
account_type: "checking" | "savings" | "cards" | "student_loans" | "bill" | "autos" | "home" | "investment" | "loan" | "asset" | "cd" | "money_market" | "certificates" | "commercial" | "creditline";
|
|
115
|
+
state: "active" | "closed" | "archived" | "pending_deletion";
|
|
116
|
+
aggregation_type: "finicity" | "cashedge" | "partner";
|
|
117
|
+
harvest_updated_at: string | null;
|
|
118
|
+
include_in_expenses: boolean;
|
|
119
|
+
include_in_budget: boolean;
|
|
120
|
+
include_in_cashflow: boolean;
|
|
121
|
+
include_in_dashboard: boolean;
|
|
122
|
+
include_in_goals: boolean;
|
|
123
|
+
include_in_networth: boolean;
|
|
124
|
+
fi: {
|
|
125
|
+
id: number;
|
|
126
|
+
name: string;
|
|
127
|
+
} | null;
|
|
128
|
+
cashedge_account_type: {
|
|
129
|
+
name: string;
|
|
130
|
+
acct_type: string;
|
|
131
|
+
ext_type: string;
|
|
132
|
+
group: string;
|
|
133
|
+
} | null;
|
|
134
|
+
locked_balance?: string | null | undefined;
|
|
135
|
+
preferred_balance_type?: "Available" | "Current" | "Outstanding" | null | undefined;
|
|
136
|
+
display_account_type?: string | undefined;
|
|
137
|
+
reference_id?: string | undefined;
|
|
138
|
+
error?: {
|
|
139
|
+
message: string;
|
|
140
|
+
code: string;
|
|
141
|
+
actionable: boolean;
|
|
142
|
+
description?: string | undefined;
|
|
143
|
+
} | null | undefined;
|
|
144
|
+
other_balances?: {
|
|
145
|
+
balance_type: string;
|
|
146
|
+
balance: string;
|
|
147
|
+
}[] | undefined;
|
|
148
|
+
}, Error>;
|
|
149
|
+
|
|
150
|
+
interface UseNetWorthParams {
|
|
151
|
+
userId: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Fetch net worth summary for a user
|
|
155
|
+
* Includes: assets, debts, history, and summary metadata
|
|
156
|
+
* Uses Zod validation to ensure API response matches expected schema
|
|
157
|
+
*
|
|
158
|
+
* @param params - Query parameters
|
|
159
|
+
* @param options - TanStack Query options
|
|
160
|
+
* @returns Query result with validated net worth data
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```tsx
|
|
164
|
+
* function NetWorthSummary() {
|
|
165
|
+
* const { data, isLoading, error } = useNetWorth({ userId: 'user123' });
|
|
166
|
+
*
|
|
167
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
168
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
169
|
+
*
|
|
170
|
+
* return (
|
|
171
|
+
* <div>
|
|
172
|
+
* <h2>Net Worth: {data.meta.net_worth}</h2>
|
|
173
|
+
* <p>Total Assets: {data.meta.total_assets}</p>
|
|
174
|
+
* <p>Total Debts: {data.meta.total_debts}</p>
|
|
175
|
+
* </div>
|
|
176
|
+
* );
|
|
177
|
+
* }
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
declare function useNetWorth(params: UseNetWorthParams, options?: Omit<UseQueryOptions<NetWorth>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
|
|
181
|
+
meta: {
|
|
182
|
+
net_worth: string;
|
|
183
|
+
net_worth_change: string;
|
|
184
|
+
total_assets: string;
|
|
185
|
+
total_debts: string;
|
|
186
|
+
};
|
|
187
|
+
assets: {
|
|
188
|
+
id: number;
|
|
189
|
+
name: string;
|
|
190
|
+
balance: string;
|
|
191
|
+
additional_networth_account: boolean;
|
|
192
|
+
}[];
|
|
193
|
+
debts: {
|
|
194
|
+
id: number;
|
|
195
|
+
name: string;
|
|
196
|
+
balance: string;
|
|
197
|
+
additional_networth_account: boolean;
|
|
198
|
+
}[];
|
|
199
|
+
networth_histories: {
|
|
200
|
+
total: string;
|
|
201
|
+
total_asset: string;
|
|
202
|
+
total_debt: string;
|
|
203
|
+
month: string;
|
|
204
|
+
year: string;
|
|
205
|
+
since_last_month: string;
|
|
206
|
+
}[];
|
|
207
|
+
}, Error>;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Parameters for useCreateAccount mutation
|
|
211
|
+
*/
|
|
212
|
+
interface CreateAccountParams {
|
|
213
|
+
userId: string;
|
|
214
|
+
data: AccountCreate;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Mutation hook for creating a new account
|
|
218
|
+
*
|
|
219
|
+
* Creates an account manually for testing purposes.
|
|
220
|
+
* Uses mode switching for validation:
|
|
221
|
+
* - Admin mode: Minimal validation for test data creation
|
|
222
|
+
* - User mode: Full validation with business rules
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```tsx
|
|
226
|
+
* const createAccount = useCreateAccount();
|
|
227
|
+
*
|
|
228
|
+
* createAccount.mutate({
|
|
229
|
+
* userId: 'user123',
|
|
230
|
+
* data: {
|
|
231
|
+
* name: 'Test Checking',
|
|
232
|
+
* balance: '1000.00',
|
|
233
|
+
* account_type: 'checking',
|
|
234
|
+
* state: 'active',
|
|
235
|
+
* aggregation_type: 'partner',
|
|
236
|
+
* include_in_expenses: true,
|
|
237
|
+
* include_in_budget: true,
|
|
238
|
+
* include_in_cashflow: true,
|
|
239
|
+
* include_in_dashboard: true,
|
|
240
|
+
* include_in_goals: false,
|
|
241
|
+
* include_in_networth: true
|
|
242
|
+
* }
|
|
243
|
+
* });
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
declare function useCreateAccount(options?: Omit<UseMutationOptions<Account, Error, CreateAccountParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
|
|
247
|
+
id: number;
|
|
248
|
+
name: string;
|
|
249
|
+
balance: string;
|
|
250
|
+
account_type: "checking" | "savings" | "cards" | "student_loans" | "bill" | "autos" | "home" | "investment" | "loan" | "asset" | "cd" | "money_market" | "certificates" | "commercial" | "creditline";
|
|
251
|
+
state: "active" | "closed" | "archived" | "pending_deletion";
|
|
252
|
+
aggregation_type: "finicity" | "cashedge" | "partner";
|
|
253
|
+
harvest_updated_at: string | null;
|
|
254
|
+
include_in_expenses: boolean;
|
|
255
|
+
include_in_budget: boolean;
|
|
256
|
+
include_in_cashflow: boolean;
|
|
257
|
+
include_in_dashboard: boolean;
|
|
258
|
+
include_in_goals: boolean;
|
|
259
|
+
include_in_networth: boolean;
|
|
260
|
+
fi: {
|
|
261
|
+
id: number;
|
|
262
|
+
name: string;
|
|
263
|
+
} | null;
|
|
264
|
+
cashedge_account_type: {
|
|
265
|
+
name: string;
|
|
266
|
+
acct_type: string;
|
|
267
|
+
ext_type: string;
|
|
268
|
+
group: string;
|
|
269
|
+
} | null;
|
|
270
|
+
locked_balance?: string | null | undefined;
|
|
271
|
+
preferred_balance_type?: "Available" | "Current" | "Outstanding" | null | undefined;
|
|
272
|
+
display_account_type?: string | undefined;
|
|
273
|
+
reference_id?: string | undefined;
|
|
274
|
+
error?: {
|
|
275
|
+
message: string;
|
|
276
|
+
code: string;
|
|
277
|
+
actionable: boolean;
|
|
278
|
+
description?: string | undefined;
|
|
279
|
+
} | null | undefined;
|
|
280
|
+
other_balances?: {
|
|
281
|
+
balance_type: string;
|
|
282
|
+
balance: string;
|
|
283
|
+
}[] | undefined;
|
|
284
|
+
}, Error, CreateAccountParams, unknown>;
|
|
285
|
+
|
|
286
|
+
interface UpdateAccountParams {
|
|
287
|
+
userId: string;
|
|
288
|
+
accountId: number;
|
|
289
|
+
data: AccountUpdate;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Update an existing account
|
|
293
|
+
* Validates input with Zod schema and invalidates related queries on success
|
|
294
|
+
*
|
|
295
|
+
* @param options - TanStack Mutation options
|
|
296
|
+
* @returns Mutation result
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
* ```tsx
|
|
300
|
+
* function AccountEditForm({ account }: { account: Account }) {
|
|
301
|
+
* const updateAccount = useUpdateAccount();
|
|
302
|
+
*
|
|
303
|
+
* const handleSubmit = (formData) => {
|
|
304
|
+
* updateAccount.mutate({
|
|
305
|
+
* userId: 'user123',
|
|
306
|
+
* accountId: account.id,
|
|
307
|
+
* data: {
|
|
308
|
+
* nickname: formData.nickname,
|
|
309
|
+
* goal_amount: formData.goalAmount,
|
|
310
|
+
* }
|
|
311
|
+
* }, {
|
|
312
|
+
* onSuccess: () => {
|
|
313
|
+
* toast.success('Account updated!');
|
|
314
|
+
* },
|
|
315
|
+
* onError: (error) => {
|
|
316
|
+
* toast.error(`Failed to update: ${error.message}`);
|
|
317
|
+
* }
|
|
318
|
+
* });
|
|
319
|
+
* };
|
|
320
|
+
*
|
|
321
|
+
* return <form onSubmit={handleSubmit}>...</form>;
|
|
322
|
+
* }
|
|
323
|
+
* ```
|
|
324
|
+
*/
|
|
325
|
+
declare function useUpdateAccount(options?: Omit<UseMutationOptions<Account, Error, UpdateAccountParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
|
|
326
|
+
id: number;
|
|
327
|
+
name: string;
|
|
328
|
+
balance: string;
|
|
329
|
+
account_type: "checking" | "savings" | "cards" | "student_loans" | "bill" | "autos" | "home" | "investment" | "loan" | "asset" | "cd" | "money_market" | "certificates" | "commercial" | "creditline";
|
|
330
|
+
state: "active" | "closed" | "archived" | "pending_deletion";
|
|
331
|
+
aggregation_type: "finicity" | "cashedge" | "partner";
|
|
332
|
+
harvest_updated_at: string | null;
|
|
333
|
+
include_in_expenses: boolean;
|
|
334
|
+
include_in_budget: boolean;
|
|
335
|
+
include_in_cashflow: boolean;
|
|
336
|
+
include_in_dashboard: boolean;
|
|
337
|
+
include_in_goals: boolean;
|
|
338
|
+
include_in_networth: boolean;
|
|
339
|
+
fi: {
|
|
340
|
+
id: number;
|
|
341
|
+
name: string;
|
|
342
|
+
} | null;
|
|
343
|
+
cashedge_account_type: {
|
|
344
|
+
name: string;
|
|
345
|
+
acct_type: string;
|
|
346
|
+
ext_type: string;
|
|
347
|
+
group: string;
|
|
348
|
+
} | null;
|
|
349
|
+
locked_balance?: string | null | undefined;
|
|
350
|
+
preferred_balance_type?: "Available" | "Current" | "Outstanding" | null | undefined;
|
|
351
|
+
display_account_type?: string | undefined;
|
|
352
|
+
reference_id?: string | undefined;
|
|
353
|
+
error?: {
|
|
354
|
+
message: string;
|
|
355
|
+
code: string;
|
|
356
|
+
actionable: boolean;
|
|
357
|
+
description?: string | undefined;
|
|
358
|
+
} | null | undefined;
|
|
359
|
+
other_balances?: {
|
|
360
|
+
balance_type: string;
|
|
361
|
+
balance: string;
|
|
362
|
+
}[] | undefined;
|
|
363
|
+
}, Error, UpdateAccountParams, unknown>;
|
|
364
|
+
|
|
365
|
+
interface DeleteAccountParams {
|
|
366
|
+
userId: string;
|
|
367
|
+
accountId: number;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Delete an account
|
|
371
|
+
* Removes account from user's account list
|
|
372
|
+
* Invalidates related queries on success
|
|
373
|
+
*
|
|
374
|
+
* @param options - TanStack Mutation options
|
|
375
|
+
* @returns Mutation result
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* ```tsx
|
|
379
|
+
* function AccountDeleteButton({ accountId }: { accountId: number }) {
|
|
380
|
+
* const deleteAccount = useDeleteAccount();
|
|
381
|
+
*
|
|
382
|
+
* const handleDelete = () => {
|
|
383
|
+
* if (confirm('Are you sure you want to delete this account?')) {
|
|
384
|
+
* deleteAccount.mutate({
|
|
385
|
+
* userId: 'user123',
|
|
386
|
+
* accountId
|
|
387
|
+
* }, {
|
|
388
|
+
* onSuccess: () => {
|
|
389
|
+
* toast.success('Account deleted successfully');
|
|
390
|
+
* navigate('/accounts');
|
|
391
|
+
* },
|
|
392
|
+
* onError: (error) => {
|
|
393
|
+
* toast.error(`Failed to delete: ${error.message}`);
|
|
394
|
+
* }
|
|
395
|
+
* });
|
|
396
|
+
* }
|
|
397
|
+
* };
|
|
398
|
+
*
|
|
399
|
+
* return (
|
|
400
|
+
* <button onClick={handleDelete} disabled={deleteAccount.isPending}>
|
|
401
|
+
* {deleteAccount.isPending ? 'Deleting...' : 'Delete Account'}
|
|
402
|
+
* </button>
|
|
403
|
+
* );
|
|
404
|
+
* }
|
|
405
|
+
* ```
|
|
406
|
+
*/
|
|
407
|
+
declare function useDeleteAccount(options?: Omit<UseMutationOptions<void, Error, DeleteAccountParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<void, Error, DeleteAccountParams, unknown>;
|
|
408
|
+
|
|
409
|
+
interface ArchiveAccountParams {
|
|
410
|
+
userId: string;
|
|
411
|
+
accountId: number;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Archive an account (soft delete)
|
|
415
|
+
* Changes account state to 'archived' instead of permanently deleting
|
|
416
|
+
* Invalidates related queries on success
|
|
417
|
+
*
|
|
418
|
+
* @param options - TanStack Mutation options
|
|
419
|
+
* @returns Mutation result
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* ```tsx
|
|
423
|
+
* function AccountArchiveButton({ accountId }: { accountId: number }) {
|
|
424
|
+
* const archiveAccount = useArchiveAccount();
|
|
425
|
+
*
|
|
426
|
+
* const handleArchive = () => {
|
|
427
|
+
* archiveAccount.mutate({
|
|
428
|
+
* userId: 'user123',
|
|
429
|
+
* accountId
|
|
430
|
+
* }, {
|
|
431
|
+
* onSuccess: (archivedAccount) => {
|
|
432
|
+
* toast.success(`${archivedAccount.name} archived`);
|
|
433
|
+
* },
|
|
434
|
+
* onError: (error) => {
|
|
435
|
+
* toast.error(`Failed to archive: ${error.message}`);
|
|
436
|
+
* }
|
|
437
|
+
* });
|
|
438
|
+
* };
|
|
439
|
+
*
|
|
440
|
+
* return (
|
|
441
|
+
* <button onClick={handleArchive} disabled={archiveAccount.isPending}>
|
|
442
|
+
* {archiveAccount.isPending ? 'Archiving...' : 'Archive Account'}
|
|
443
|
+
* </button>
|
|
444
|
+
* );
|
|
445
|
+
* }
|
|
446
|
+
* ```
|
|
447
|
+
*/
|
|
448
|
+
declare function useArchiveAccount(options?: Omit<UseMutationOptions<Account, Error, ArchiveAccountParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
|
|
449
|
+
id: number;
|
|
450
|
+
name: string;
|
|
451
|
+
balance: string;
|
|
452
|
+
account_type: "checking" | "savings" | "cards" | "student_loans" | "bill" | "autos" | "home" | "investment" | "loan" | "asset" | "cd" | "money_market" | "certificates" | "commercial" | "creditline";
|
|
453
|
+
state: "active" | "closed" | "archived" | "pending_deletion";
|
|
454
|
+
aggregation_type: "finicity" | "cashedge" | "partner";
|
|
455
|
+
harvest_updated_at: string | null;
|
|
456
|
+
include_in_expenses: boolean;
|
|
457
|
+
include_in_budget: boolean;
|
|
458
|
+
include_in_cashflow: boolean;
|
|
459
|
+
include_in_dashboard: boolean;
|
|
460
|
+
include_in_goals: boolean;
|
|
461
|
+
include_in_networth: boolean;
|
|
462
|
+
fi: {
|
|
463
|
+
id: number;
|
|
464
|
+
name: string;
|
|
465
|
+
} | null;
|
|
466
|
+
cashedge_account_type: {
|
|
467
|
+
name: string;
|
|
468
|
+
acct_type: string;
|
|
469
|
+
ext_type: string;
|
|
470
|
+
group: string;
|
|
471
|
+
} | null;
|
|
472
|
+
locked_balance?: string | null | undefined;
|
|
473
|
+
preferred_balance_type?: "Available" | "Current" | "Outstanding" | null | undefined;
|
|
474
|
+
display_account_type?: string | undefined;
|
|
475
|
+
reference_id?: string | undefined;
|
|
476
|
+
error?: {
|
|
477
|
+
message: string;
|
|
478
|
+
code: string;
|
|
479
|
+
actionable: boolean;
|
|
480
|
+
description?: string | undefined;
|
|
481
|
+
} | null | undefined;
|
|
482
|
+
other_balances?: {
|
|
483
|
+
balance_type: string;
|
|
484
|
+
balance: string;
|
|
485
|
+
}[] | undefined;
|
|
486
|
+
}, Error, ArchiveAccountParams, unknown>;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Parameters for useCreateNetWorthAccount mutation
|
|
490
|
+
*/
|
|
491
|
+
interface CreateNetWorthAccountParams {
|
|
492
|
+
userId: string;
|
|
493
|
+
data: NetWorthAccountCreate;
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Mutation hook for creating a manual net worth account
|
|
497
|
+
*
|
|
498
|
+
* Creates a manual asset or debt account for net worth tracking.
|
|
499
|
+
* Returns either an asset or debt object depending on account_type.
|
|
500
|
+
*
|
|
501
|
+
* @example
|
|
502
|
+
* ```tsx
|
|
503
|
+
* const createAccount = useCreateNetWorthAccount();
|
|
504
|
+
*
|
|
505
|
+
* // Create asset
|
|
506
|
+
* createAccount.mutate({
|
|
507
|
+
* userId: 'user123',
|
|
508
|
+
* data: {
|
|
509
|
+
* networth_account: {
|
|
510
|
+
* account_type: 'asset',
|
|
511
|
+
* balance: '250000.00',
|
|
512
|
+
* name: 'My House'
|
|
513
|
+
* }
|
|
514
|
+
* }
|
|
515
|
+
* });
|
|
516
|
+
*
|
|
517
|
+
* // Create debt
|
|
518
|
+
* createAccount.mutate({
|
|
519
|
+
* userId: 'user123',
|
|
520
|
+
* data: {
|
|
521
|
+
* networth_account: {
|
|
522
|
+
* account_type: 'debt',
|
|
523
|
+
* balance: '15000.00',
|
|
524
|
+
* name: 'Car Loan'
|
|
525
|
+
* }
|
|
526
|
+
* }
|
|
527
|
+
* });
|
|
528
|
+
* ```
|
|
529
|
+
*/
|
|
530
|
+
declare function useCreateNetWorthAccount(options?: Omit<UseMutationOptions<NetWorthAsset | NetWorthDebt, Error, CreateNetWorthAccountParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
|
|
531
|
+
id: number;
|
|
532
|
+
name: string;
|
|
533
|
+
balance: string;
|
|
534
|
+
additional_networth_account: boolean;
|
|
535
|
+
}, Error, CreateNetWorthAccountParams, unknown>;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Parameters for useUpdateNetWorthAccount mutation
|
|
539
|
+
*/
|
|
540
|
+
interface UpdateNetWorthAccountParams {
|
|
541
|
+
userId: string;
|
|
542
|
+
accountId: number;
|
|
543
|
+
data: NetWorthAccountUpdate;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Mutation hook for updating a manual net worth account
|
|
547
|
+
*
|
|
548
|
+
* Updates name, balance, or account type for a manual net worth account.
|
|
549
|
+
* All fields are optional - only provided fields will be updated.
|
|
550
|
+
*
|
|
551
|
+
* @example
|
|
552
|
+
* ```tsx
|
|
553
|
+
* const updateAccount = useUpdateNetWorthAccount();
|
|
554
|
+
*
|
|
555
|
+
* // Update only balance
|
|
556
|
+
* updateAccount.mutate({
|
|
557
|
+
* userId: 'user123',
|
|
558
|
+
* accountId: 5,
|
|
559
|
+
* data: {
|
|
560
|
+
* networth_account: {
|
|
561
|
+
* balance: '260000.00'
|
|
562
|
+
* }
|
|
563
|
+
* }
|
|
564
|
+
* });
|
|
565
|
+
*
|
|
566
|
+
* // Update name and type
|
|
567
|
+
* updateAccount.mutate({
|
|
568
|
+
* userId: 'user123',
|
|
569
|
+
* accountId: 5,
|
|
570
|
+
* data: {
|
|
571
|
+
* networth_account: {
|
|
572
|
+
* name: 'Updated House Name',
|
|
573
|
+
* account_type: 'debt'
|
|
574
|
+
* }
|
|
575
|
+
* }
|
|
576
|
+
* });
|
|
577
|
+
* ```
|
|
578
|
+
*/
|
|
579
|
+
declare function useUpdateNetWorthAccount(options?: Omit<UseMutationOptions<NetWorthAsset | NetWorthDebt, Error, UpdateNetWorthAccountParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
|
|
580
|
+
id: number;
|
|
581
|
+
name: string;
|
|
582
|
+
balance: string;
|
|
583
|
+
additional_networth_account: boolean;
|
|
584
|
+
}, Error, UpdateNetWorthAccountParams, unknown>;
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Parameters for useDeleteNetWorthAccount mutation
|
|
588
|
+
*/
|
|
589
|
+
interface DeleteNetWorthAccountParams {
|
|
590
|
+
userId: string;
|
|
591
|
+
accountId: number;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Mutation hook for deleting a manual net worth account
|
|
595
|
+
*
|
|
596
|
+
* Permanently deletes a manual asset or debt account from net worth tracking.
|
|
597
|
+
* This operation cannot be undone.
|
|
598
|
+
*
|
|
599
|
+
* @example
|
|
600
|
+
* ```tsx
|
|
601
|
+
* const deleteAccount = useDeleteNetWorthAccount();
|
|
602
|
+
*
|
|
603
|
+
* deleteAccount.mutate({
|
|
604
|
+
* userId: 'user123',
|
|
605
|
+
* accountId: 5
|
|
606
|
+
* }, {
|
|
607
|
+
* onSuccess: () => {
|
|
608
|
+
* console.log('Net worth account deleted successfully');
|
|
609
|
+
* }
|
|
610
|
+
* });
|
|
611
|
+
* ```
|
|
612
|
+
*/
|
|
613
|
+
declare function useDeleteNetWorthAccount(options?: Omit<UseMutationOptions<void, Error, DeleteNetWorthAccountParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<void, Error, DeleteNetWorthAccountParams, unknown>;
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Query key factory for Accounts domain
|
|
617
|
+
* Following TanStack Query best practices for hierarchical cache keys
|
|
618
|
+
*
|
|
619
|
+
* Key structure:
|
|
620
|
+
* - ['accounts'] - Root key for all account queries
|
|
621
|
+
* - ['accounts', 'list', userId] - List of accounts for a user
|
|
622
|
+
* - ['accounts', 'detail', userId, accountId] - Single account detail
|
|
623
|
+
* - ['accounts', 'investments', userId, accountId] - Account investments
|
|
624
|
+
* - ['accounts', 'transactions', userId, accountId, page] - Account transactions
|
|
625
|
+
*/
|
|
626
|
+
declare const accountKeys: {
|
|
627
|
+
/**
|
|
628
|
+
* Root key for all account-related queries
|
|
629
|
+
*/
|
|
630
|
+
all: readonly ["accounts"];
|
|
631
|
+
/**
|
|
632
|
+
* Key for all account list queries
|
|
633
|
+
*/
|
|
634
|
+
lists: () => readonly ["accounts", "list"];
|
|
635
|
+
/**
|
|
636
|
+
* Key for a specific user's account list
|
|
637
|
+
* @param userId - User ID
|
|
638
|
+
*/
|
|
639
|
+
list: (userId: string) => readonly ["accounts", "list", string];
|
|
640
|
+
/**
|
|
641
|
+
* Key for all account detail queries
|
|
642
|
+
*/
|
|
643
|
+
details: () => readonly ["accounts", "detail"];
|
|
644
|
+
/**
|
|
645
|
+
* Key for a specific account detail
|
|
646
|
+
* @param userId - User ID
|
|
647
|
+
* @param accountId - Account ID
|
|
648
|
+
*/
|
|
649
|
+
detail: (userId: string, accountId: number) => readonly ["accounts", "detail", string, number];
|
|
650
|
+
/**
|
|
651
|
+
* Key for all account investment queries
|
|
652
|
+
*/
|
|
653
|
+
investments: () => readonly ["accounts", "investments"];
|
|
654
|
+
/**
|
|
655
|
+
* Key for a specific account's investments
|
|
656
|
+
* @param userId - User ID
|
|
657
|
+
* @param accountId - Account ID
|
|
658
|
+
*/
|
|
659
|
+
investment: (userId: string, accountId: number) => readonly ["accounts", "investments", string, number];
|
|
660
|
+
/**
|
|
661
|
+
* Key for all account transaction queries
|
|
662
|
+
*/
|
|
663
|
+
transactions: () => readonly ["accounts", "transactions"];
|
|
664
|
+
/**
|
|
665
|
+
* Key for a specific account's transactions
|
|
666
|
+
* @param userId - User ID
|
|
667
|
+
* @param accountId - Account ID
|
|
668
|
+
* @param page - Page number for pagination
|
|
669
|
+
*/
|
|
670
|
+
transaction: (userId: string, accountId: number, page: number) => readonly ["accounts", "transactions", string, number, number];
|
|
671
|
+
/**
|
|
672
|
+
* Key for all net worth queries
|
|
673
|
+
*/
|
|
674
|
+
networth: () => readonly ["accounts", "networth"];
|
|
675
|
+
/**
|
|
676
|
+
* Key for a specific user's net worth summary
|
|
677
|
+
* @param userId - User ID
|
|
678
|
+
*/
|
|
679
|
+
networthSummary: (userId: string) => readonly ["accounts", "networth", string];
|
|
680
|
+
/**
|
|
681
|
+
* Key for all net worth account queries
|
|
682
|
+
*/
|
|
683
|
+
networthAccounts: () => readonly ["accounts", "networth", "accounts"];
|
|
684
|
+
/**
|
|
685
|
+
* Key for a specific net worth account
|
|
686
|
+
* @param userId - User ID
|
|
687
|
+
* @param accountId - Net worth account ID
|
|
688
|
+
*/
|
|
689
|
+
networthAccount: (userId: string, accountId: number) => readonly ["accounts", "networth", "accounts", string, number];
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* Base API client for Accounts domain
|
|
694
|
+
* Uses axios with interceptors for auth and error handling
|
|
695
|
+
*/
|
|
696
|
+
/**
|
|
697
|
+
* Axios instance configured for PFM API
|
|
698
|
+
* Base URL can be overridden via VITE_API_BASE_URL environment variable
|
|
699
|
+
*/
|
|
700
|
+
declare const api: axios.AxiosInstance;
|
|
701
|
+
|
|
702
|
+
export { type ArchiveAccountParams, type CreateAccountParams, type CreateNetWorthAccountParams, type DeleteAccountParams, type DeleteNetWorthAccountParams, type UpdateAccountParams, type UpdateNetWorthAccountParams, type UseAccountParams, type UseAccountsParams, type UseNetWorthParams, accountKeys, api, useAccount, useAccounts, useArchiveAccount, useCreateAccount, useCreateNetWorthAccount, useDeleteAccount, useDeleteNetWorthAccount, useNetWorth, useUpdateAccount, useUpdateNetWorthAccount };
|