@pfm-platform/goals-data-access 0.1.1

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,523 @@
1
+ import * as _tanstack_react_query from '@tanstack/react-query';
2
+ import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
3
+ import { SavingsGoalsResponse, SavingsGoal, GoalImagesResponse, GoalCreate, GoalUpdate, PayoffGoalsResponse, PayoffGoal } from '@pfm-platform/shared';
4
+ import * as axios from 'axios';
5
+
6
+ /**
7
+ * Parameters for useSavingsGoals query hook
8
+ */
9
+ interface UseSavingsGoalsParams {
10
+ userId: string;
11
+ }
12
+ /**
13
+ * Query hook for fetching all savings goals for a user
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * const { data, isLoading } = useSavingsGoals({ userId: 'user123' });
18
+ * ```
19
+ */
20
+ declare function useSavingsGoals(params: UseSavingsGoalsParams, options?: Omit<UseQueryOptions<SavingsGoalsResponse>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
21
+ savings_goals: {
22
+ id: number;
23
+ name: string;
24
+ state: "active" | "archived" | "completed";
25
+ status: "complete" | "under" | "risk" | "over";
26
+ image_name: string;
27
+ image_url: string;
28
+ percent_complete: number;
29
+ complete: boolean;
30
+ initial_value: string;
31
+ current_value: string;
32
+ target_value: string;
33
+ monthly_contribution: string;
34
+ remaining_monthly_contribution: string;
35
+ target_completion_on: string;
36
+ created_at: string;
37
+ updated_at: string;
38
+ links: {
39
+ accounts: number[];
40
+ };
41
+ current_progress?: string | undefined;
42
+ target_contribution?: string | undefined;
43
+ weight?: number | undefined;
44
+ }[];
45
+ }, Error>;
46
+
47
+ /**
48
+ * Parameters for useSavingsGoal query hook
49
+ */
50
+ interface UseSavingsGoalParams {
51
+ userId: string;
52
+ goalId: number;
53
+ }
54
+ /**
55
+ * Query hook for fetching a single savings goal by ID
56
+ *
57
+ * @example
58
+ * ```tsx
59
+ * const { data, isLoading } = useSavingsGoal({
60
+ * userId: 'user123',
61
+ * goalId: 456
62
+ * });
63
+ * ```
64
+ */
65
+ declare function useSavingsGoal(params: UseSavingsGoalParams, options?: Omit<UseQueryOptions<SavingsGoal>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
66
+ id: number;
67
+ name: string;
68
+ state: "active" | "archived" | "completed";
69
+ status: "complete" | "under" | "risk" | "over";
70
+ image_name: string;
71
+ image_url: string;
72
+ percent_complete: number;
73
+ complete: boolean;
74
+ initial_value: string;
75
+ current_value: string;
76
+ target_value: string;
77
+ monthly_contribution: string;
78
+ remaining_monthly_contribution: string;
79
+ target_completion_on: string;
80
+ created_at: string;
81
+ updated_at: string;
82
+ links: {
83
+ accounts: number[];
84
+ };
85
+ current_progress?: string | undefined;
86
+ target_contribution?: string | undefined;
87
+ weight?: number | undefined;
88
+ }, Error>;
89
+
90
+ /**
91
+ * Query hook for fetching savings goal image catalog
92
+ * This is a global resource (no userId required)
93
+ *
94
+ * @example
95
+ * ```tsx
96
+ * const { data, isLoading } = useSavingsGoalImages();
97
+ * ```
98
+ */
99
+ declare function useSavingsGoalImages(options?: Omit<UseQueryOptions<GoalImagesResponse>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
100
+ images: {
101
+ id: number;
102
+ name: string;
103
+ url: string;
104
+ }[];
105
+ }, Error>;
106
+
107
+ /**
108
+ * Parameters for useCreateSavingsGoal mutation
109
+ */
110
+ interface CreateSavingsGoalParams {
111
+ userId: string;
112
+ data: GoalCreate;
113
+ }
114
+ /**
115
+ * Mutation hook for creating a savings goal
116
+ *
117
+ * @example
118
+ * ```tsx
119
+ * const createSavingsGoal = useCreateSavingsGoal();
120
+ *
121
+ * createSavingsGoal.mutate({
122
+ * userId: 'user123',
123
+ * data: {
124
+ * name: 'Emergency Fund',
125
+ * image_name: 'piggy_bank',
126
+ * target_value: '5000.00',
127
+ * target_completion_on: '2026-12-31',
128
+ * }
129
+ * });
130
+ * ```
131
+ */
132
+ declare function useCreateSavingsGoal(options?: Omit<UseMutationOptions<SavingsGoal, Error, CreateSavingsGoalParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
133
+ id: number;
134
+ name: string;
135
+ state: "active" | "archived" | "completed";
136
+ status: "complete" | "under" | "risk" | "over";
137
+ image_name: string;
138
+ image_url: string;
139
+ percent_complete: number;
140
+ complete: boolean;
141
+ initial_value: string;
142
+ current_value: string;
143
+ target_value: string;
144
+ monthly_contribution: string;
145
+ remaining_monthly_contribution: string;
146
+ target_completion_on: string;
147
+ created_at: string;
148
+ updated_at: string;
149
+ links: {
150
+ accounts: number[];
151
+ };
152
+ current_progress?: string | undefined;
153
+ target_contribution?: string | undefined;
154
+ weight?: number | undefined;
155
+ }, Error, CreateSavingsGoalParams, unknown>;
156
+
157
+ /**
158
+ * Parameters for useUpdateSavingsGoal mutation
159
+ */
160
+ interface UpdateSavingsGoalParams {
161
+ userId: string;
162
+ goalId: number;
163
+ data: GoalUpdate;
164
+ }
165
+ /**
166
+ * Mutation hook for updating a savings goal
167
+ *
168
+ * @example
169
+ * ```tsx
170
+ * const updateSavingsGoal = useUpdateSavingsGoal();
171
+ *
172
+ * updateSavingsGoal.mutate({
173
+ * userId: 'user123',
174
+ * goalId: 456,
175
+ * data: {
176
+ * id: 456,
177
+ * name: 'Updated Emergency Fund',
178
+ * image_name: 'piggy_bank',
179
+ * target_value: '6000.00'
180
+ * }
181
+ * });
182
+ * ```
183
+ */
184
+ declare function useUpdateSavingsGoal(options?: Omit<UseMutationOptions<SavingsGoal, Error, UpdateSavingsGoalParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
185
+ id: number;
186
+ name: string;
187
+ state: "active" | "archived" | "completed";
188
+ status: "complete" | "under" | "risk" | "over";
189
+ image_name: string;
190
+ image_url: string;
191
+ percent_complete: number;
192
+ complete: boolean;
193
+ initial_value: string;
194
+ current_value: string;
195
+ target_value: string;
196
+ monthly_contribution: string;
197
+ remaining_monthly_contribution: string;
198
+ target_completion_on: string;
199
+ created_at: string;
200
+ updated_at: string;
201
+ links: {
202
+ accounts: number[];
203
+ };
204
+ current_progress?: string | undefined;
205
+ target_contribution?: string | undefined;
206
+ weight?: number | undefined;
207
+ }, Error, UpdateSavingsGoalParams, unknown>;
208
+
209
+ /**
210
+ * Parameters for useArchiveSavingsGoal mutation
211
+ */
212
+ interface ArchiveSavingsGoalParams {
213
+ userId: string;
214
+ goalId: number;
215
+ }
216
+ /**
217
+ * Mutation hook for archiving a savings goal
218
+ * Archived goals remain in system but marked as inactive
219
+ *
220
+ * @example
221
+ * ```tsx
222
+ * const archiveSavingsGoal = useArchiveSavingsGoal();
223
+ *
224
+ * archiveSavingsGoal.mutate({
225
+ * userId: 'user123',
226
+ * goalId: 456
227
+ * });
228
+ * ```
229
+ */
230
+ declare function useArchiveSavingsGoal(options?: Omit<UseMutationOptions<void, Error, ArchiveSavingsGoalParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<void, Error, ArchiveSavingsGoalParams, unknown>;
231
+
232
+ /**
233
+ * Parameters for useDeleteSavingsGoal mutation
234
+ */
235
+ interface DeleteSavingsGoalParams {
236
+ userId: string;
237
+ goalId: number;
238
+ }
239
+ /**
240
+ * Mutation hook for deleting a savings goal permanently
241
+ *
242
+ * @example
243
+ * ```tsx
244
+ * const deleteSavingsGoal = useDeleteSavingsGoal();
245
+ *
246
+ * deleteSavingsGoal.mutate({
247
+ * userId: 'user123',
248
+ * goalId: 456
249
+ * });
250
+ * ```
251
+ */
252
+ declare function useDeleteSavingsGoal(options?: Omit<UseMutationOptions<void, Error, DeleteSavingsGoalParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<void, Error, DeleteSavingsGoalParams, unknown>;
253
+
254
+ /**
255
+ * Parameters for usePayoffGoals query hook
256
+ */
257
+ interface UsePayoffGoalsParams {
258
+ userId: string;
259
+ }
260
+ /**
261
+ * Query hook for fetching all payoff goals for a user
262
+ *
263
+ * @example
264
+ * ```tsx
265
+ * const { data, isLoading } = usePayoffGoals({ userId: 'user123' });
266
+ * ```
267
+ */
268
+ declare function usePayoffGoals(params: UsePayoffGoalsParams, options?: Omit<UseQueryOptions<PayoffGoalsResponse>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
269
+ payoff_goals: {
270
+ id: number;
271
+ name: string;
272
+ state: "active" | "archived" | "completed";
273
+ status: "complete" | "under" | "risk" | "over";
274
+ image_name: string;
275
+ image_url: string;
276
+ percent_complete: number;
277
+ complete: boolean;
278
+ initial_value: string;
279
+ current_value: string;
280
+ target_value: string;
281
+ monthly_contribution: string;
282
+ remaining_monthly_contribution: string;
283
+ target_completion_on: string;
284
+ created_at: string;
285
+ updated_at: string;
286
+ links: {
287
+ accounts: number[];
288
+ };
289
+ current_progress?: string | undefined;
290
+ target_contribution?: string | undefined;
291
+ }[];
292
+ }, Error>;
293
+
294
+ /**
295
+ * Parameters for usePayoffGoal query hook
296
+ */
297
+ interface UsePayoffGoalParams {
298
+ userId: string;
299
+ goalId: number;
300
+ }
301
+ /**
302
+ * Query hook for fetching a single payoff goal by ID
303
+ *
304
+ * @example
305
+ * ```tsx
306
+ * const { data, isLoading } = usePayoffGoal({
307
+ * userId: 'user123',
308
+ * goalId: 456
309
+ * });
310
+ * ```
311
+ */
312
+ declare function usePayoffGoal(params: UsePayoffGoalParams, options?: Omit<UseQueryOptions<PayoffGoal>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
313
+ id: number;
314
+ name: string;
315
+ state: "active" | "archived" | "completed";
316
+ status: "complete" | "under" | "risk" | "over";
317
+ image_name: string;
318
+ image_url: string;
319
+ percent_complete: number;
320
+ complete: boolean;
321
+ initial_value: string;
322
+ current_value: string;
323
+ target_value: string;
324
+ monthly_contribution: string;
325
+ remaining_monthly_contribution: string;
326
+ target_completion_on: string;
327
+ created_at: string;
328
+ updated_at: string;
329
+ links: {
330
+ accounts: number[];
331
+ };
332
+ current_progress?: string | undefined;
333
+ target_contribution?: string | undefined;
334
+ }, Error>;
335
+
336
+ /**
337
+ * Query hook for fetching payoff goal image catalog
338
+ * This is a global resource (no userId required)
339
+ *
340
+ * @example
341
+ * ```tsx
342
+ * const { data, isLoading } = usePayoffGoalImages();
343
+ * ```
344
+ */
345
+ declare function usePayoffGoalImages(options?: Omit<UseQueryOptions<GoalImagesResponse>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
346
+ images: {
347
+ id: number;
348
+ name: string;
349
+ url: string;
350
+ }[];
351
+ }, Error>;
352
+
353
+ /**
354
+ * Parameters for useCreatePayoffGoal mutation
355
+ */
356
+ interface CreatePayoffGoalParams {
357
+ userId: string;
358
+ data: GoalCreate;
359
+ }
360
+ /**
361
+ * Mutation hook for creating a payoff goal
362
+ *
363
+ * @example
364
+ * ```tsx
365
+ * const createPayoffGoal = useCreatePayoffGoal();
366
+ *
367
+ * createPayoffGoal.mutate({
368
+ * userId: 'user123',
369
+ * data: {
370
+ * name: 'Credit Card Debt',
371
+ * image_name: 'credit_card',
372
+ * target_value: '3000.00',
373
+ * target_completion_on: '2026-06-30',
374
+ * }
375
+ * });
376
+ * ```
377
+ */
378
+ declare function useCreatePayoffGoal(options?: Omit<UseMutationOptions<PayoffGoal, Error, CreatePayoffGoalParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
379
+ id: number;
380
+ name: string;
381
+ state: "active" | "archived" | "completed";
382
+ status: "complete" | "under" | "risk" | "over";
383
+ image_name: string;
384
+ image_url: string;
385
+ percent_complete: number;
386
+ complete: boolean;
387
+ initial_value: string;
388
+ current_value: string;
389
+ target_value: string;
390
+ monthly_contribution: string;
391
+ remaining_monthly_contribution: string;
392
+ target_completion_on: string;
393
+ created_at: string;
394
+ updated_at: string;
395
+ links: {
396
+ accounts: number[];
397
+ };
398
+ current_progress?: string | undefined;
399
+ target_contribution?: string | undefined;
400
+ }, Error, CreatePayoffGoalParams, unknown>;
401
+
402
+ /**
403
+ * Parameters for useUpdatePayoffGoal mutation
404
+ */
405
+ interface UpdatePayoffGoalParams {
406
+ userId: string;
407
+ goalId: number;
408
+ data: GoalUpdate;
409
+ }
410
+ /**
411
+ * Mutation hook for updating a payoff goal
412
+ *
413
+ * @example
414
+ * ```tsx
415
+ * const updatePayoffGoal = useUpdatePayoffGoal();
416
+ *
417
+ * updatePayoffGoal.mutate({
418
+ * userId: 'user123',
419
+ * goalId: 456,
420
+ * data: {
421
+ * id: 456,
422
+ * name: 'Updated Credit Card',
423
+ * image_name: 'credit_card',
424
+ * target_value: '2500.00'
425
+ * }
426
+ * });
427
+ * ```
428
+ */
429
+ declare function useUpdatePayoffGoal(options?: Omit<UseMutationOptions<PayoffGoal, Error, UpdatePayoffGoalParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
430
+ id: number;
431
+ name: string;
432
+ state: "active" | "archived" | "completed";
433
+ status: "complete" | "under" | "risk" | "over";
434
+ image_name: string;
435
+ image_url: string;
436
+ percent_complete: number;
437
+ complete: boolean;
438
+ initial_value: string;
439
+ current_value: string;
440
+ target_value: string;
441
+ monthly_contribution: string;
442
+ remaining_monthly_contribution: string;
443
+ target_completion_on: string;
444
+ created_at: string;
445
+ updated_at: string;
446
+ links: {
447
+ accounts: number[];
448
+ };
449
+ current_progress?: string | undefined;
450
+ target_contribution?: string | undefined;
451
+ }, Error, UpdatePayoffGoalParams, unknown>;
452
+
453
+ /**
454
+ * Parameters for useArchivePayoffGoal mutation
455
+ */
456
+ interface ArchivePayoffGoalParams {
457
+ userId: string;
458
+ goalId: number;
459
+ }
460
+ /**
461
+ * Mutation hook for archiving a payoff goal
462
+ * Archived goals remain in system but marked as inactive
463
+ *
464
+ * @example
465
+ * ```tsx
466
+ * const archivePayoffGoal = useArchivePayoffGoal();
467
+ *
468
+ * archivePayoffGoal.mutate({
469
+ * userId: 'user123',
470
+ * goalId: 456
471
+ * });
472
+ * ```
473
+ */
474
+ declare function useArchivePayoffGoal(options?: Omit<UseMutationOptions<void, Error, ArchivePayoffGoalParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<void, Error, ArchivePayoffGoalParams, unknown>;
475
+
476
+ /**
477
+ * Parameters for useDeletePayoffGoal mutation
478
+ */
479
+ interface DeletePayoffGoalParams {
480
+ userId: string;
481
+ goalId: number;
482
+ }
483
+ /**
484
+ * Mutation hook for deleting a payoff goal permanently
485
+ *
486
+ * @example
487
+ * ```tsx
488
+ * const deletePayoffGoal = useDeletePayoffGoal();
489
+ *
490
+ * deletePayoffGoal.mutate({
491
+ * userId: 'user123',
492
+ * goalId: 456
493
+ * });
494
+ * ```
495
+ */
496
+ declare function useDeletePayoffGoal(options?: Omit<UseMutationOptions<void, Error, DeletePayoffGoalParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<void, Error, DeletePayoffGoalParams, unknown>;
497
+
498
+ /**
499
+ * Query key factory for Goals domain
500
+ * Handles both Savings goals and Payoff goals with shared structure
501
+ */
502
+ type GoalType = 'savings' | 'payoff';
503
+ declare const goalKeys: {
504
+ all: readonly ["goals"];
505
+ savingsLists: () => readonly ["goals", "savings", "list"];
506
+ savingsList: (userId: string) => readonly ["goals", "savings", "list", string];
507
+ savingsDetails: () => readonly ["goals", "savings", "detail"];
508
+ savingsDetail: (userId: string, goalId: number) => readonly ["goals", "savings", "detail", string, number];
509
+ payoffLists: () => readonly ["goals", "payoff", "list"];
510
+ payoffList: (userId: string) => readonly ["goals", "payoff", "list", string];
511
+ payoffDetails: () => readonly ["goals", "payoff", "detail"];
512
+ payoffDetail: (userId: string, goalId: number) => readonly ["goals", "payoff", "detail", string, number];
513
+ savingsImages: () => readonly ["goals", "savings", "images"];
514
+ payoffImages: () => readonly ["goals", "payoff", "images"];
515
+ };
516
+
517
+ /**
518
+ * Axios instance for Goals API
519
+ * Base URL configured through environment variables or defaults to relative path
520
+ */
521
+ declare const api: axios.AxiosInstance;
522
+
523
+ export { type ArchivePayoffGoalParams, type ArchiveSavingsGoalParams, type CreatePayoffGoalParams, type CreateSavingsGoalParams, type DeletePayoffGoalParams, type DeleteSavingsGoalParams, type GoalType, type UpdatePayoffGoalParams, type UpdateSavingsGoalParams, type UsePayoffGoalParams, type UsePayoffGoalsParams, type UseSavingsGoalParams, type UseSavingsGoalsParams, api, goalKeys, useArchivePayoffGoal, useArchiveSavingsGoal, useCreatePayoffGoal, useCreateSavingsGoal, useDeletePayoffGoal, useDeleteSavingsGoal, usePayoffGoal, usePayoffGoalImages, usePayoffGoals, useSavingsGoal, useSavingsGoalImages, useSavingsGoals, useUpdatePayoffGoal, useUpdateSavingsGoal };