@pfm-platform/alerts-data-access 0.1.1 → 0.2.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.
package/dist/index.cjs CHANGED
@@ -2,19 +2,8 @@
2
2
 
3
3
  var reactQuery = require('@tanstack/react-query');
4
4
  var shared = require('@pfm-platform/shared');
5
- var axios = require('axios');
6
-
7
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
-
9
- var axios__default = /*#__PURE__*/_interopDefault(axios);
10
5
 
11
6
  // src/queries/useAlerts.ts
12
- var api = axios__default.default.create({
13
- baseURL: "/api",
14
- headers: {
15
- "Content-Type": "application/json"
16
- }
17
- });
18
7
 
19
8
  // src/keys.ts
20
9
  var alertKeys = {
@@ -33,12 +22,11 @@ function useAlerts({ userId }, options) {
33
22
  return reactQuery.useQuery({
34
23
  queryKey: alertKeys.list(userId),
35
24
  queryFn: async () => {
36
- const response = await api.get(`/users/${userId}/alerts`);
37
- const validated = shared.AlertsResponseSchema.parse(response.data);
38
- return validated.alerts;
25
+ const { data, error } = await shared.supabase.from("alerts").select("*").eq("user_id", userId).order("created_at");
26
+ if (error) throw new Error(error.message);
27
+ return shared.AlertsResponseSchema.parse(data);
39
28
  },
40
29
  staleTime: 1e3 * 60 * 5,
41
- // 5 minutes (alerts change moderately)
42
30
  ...options
43
31
  });
44
32
  }
@@ -46,11 +34,11 @@ function useAlert({ userId, alertId }, options) {
46
34
  return reactQuery.useQuery({
47
35
  queryKey: alertKeys.detail(userId, alertId),
48
36
  queryFn: async () => {
49
- const response = await api.get(`/users/${userId}/alerts/${alertId}`);
50
- return shared.AlertSchema.parse(response.data);
37
+ const { data, error } = await shared.supabase.from("alerts").select("*").eq("id", alertId).eq("user_id", userId).single();
38
+ if (error) throw new Error(error.message);
39
+ return shared.AlertRowSchema.parse(data);
51
40
  },
52
41
  staleTime: 1e3 * 60 * 5,
53
- // 5 minutes
54
42
  ...options
55
43
  });
56
44
  }
@@ -58,66 +46,40 @@ function useAlertDestinations({ userId }, options) {
58
46
  return reactQuery.useQuery({
59
47
  queryKey: alertKeys.destinations(userId),
60
48
  queryFn: async () => {
61
- const response = await api.get(`/users/${userId}/alert_destinations`);
62
- return shared.AlertDestinationsSchema.parse(response.data);
49
+ const { data, error } = await shared.supabase.from("alert_destinations").select("*").eq("user_id", userId).single();
50
+ if (error) throw new Error(error.message);
51
+ return shared.AlertDestinationsSchema.parse(data);
63
52
  },
64
53
  staleTime: 1e3 * 60 * 10,
65
- // 10 minutes (destinations rarely change)
66
54
  ...options
67
55
  });
68
56
  }
69
57
  function useCreateAlert(options) {
70
58
  const queryClient = reactQuery.useQueryClient();
71
- const getEndpoint = (type) => {
72
- const mapping = {
73
- AccountThresholdAlert: "account_threshold_alerts",
74
- GoalAlert: "goal_alerts",
75
- MerchantNameAlert: "merchant_name_alerts",
76
- SpendingTargetAlert: "spending_target_alerts",
77
- TransactionLimitAlert: "transaction_limit_alerts",
78
- UpcomingBillAlert: "upcoming_bill_alerts"
79
- };
80
- return mapping[type];
81
- };
82
59
  return reactQuery.useMutation({
83
- mutationFn: async ({ userId, type, data }) => {
60
+ mutationFn: async ({ userId, data }) => {
84
61
  const validated = shared.AlertCreateSchema.parse(data);
85
- const endpoint = getEndpoint(type);
86
- const response = await api.post(`/users/${userId}/${endpoint}`, {
87
- alert: validated
88
- });
89
- return shared.AlertSchema.parse(response.data);
62
+ const { data: row, error } = await shared.supabase.from("alerts").insert({ user_id: userId, ...validated }).select().single();
63
+ if (error) throw new Error(error.message);
64
+ return shared.AlertRowSchema.parse(row);
90
65
  },
91
- onSuccess: (_, { userId }) => {
92
- queryClient.invalidateQueries({ queryKey: alertKeys.list(userId) });
66
+ onSuccess: () => {
67
+ queryClient.invalidateQueries({ queryKey: alertKeys.lists() });
93
68
  },
94
69
  ...options
95
70
  });
96
71
  }
97
72
  function useUpdateAlert(options) {
98
73
  const queryClient = reactQuery.useQueryClient();
99
- const getEndpoint = (type) => {
100
- const mapping = {
101
- AccountThresholdAlert: "account_threshold_alerts",
102
- GoalAlert: "goal_alerts",
103
- MerchantNameAlert: "merchant_name_alerts",
104
- SpendingTargetAlert: "spending_target_alerts",
105
- TransactionLimitAlert: "transaction_limit_alerts",
106
- UpcomingBillAlert: "upcoming_bill_alerts"
107
- };
108
- return mapping[type];
109
- };
110
74
  return reactQuery.useMutation({
111
- mutationFn: async ({ userId, alertId, type, data }) => {
75
+ mutationFn: async ({ userId, alertId, data }) => {
112
76
  const validated = shared.AlertUpdateSchema.parse(data);
113
- const endpoint = getEndpoint(type);
114
- const response = await api.put(`/users/${userId}/${endpoint}/${alertId}`, {
115
- alert: validated
116
- });
117
- return shared.AlertSchema.parse(response.data);
77
+ const { data: row, error } = await shared.supabase.from("alerts").update(validated).eq("id", alertId).eq("user_id", userId).select().single();
78
+ if (error) throw new Error(error.message);
79
+ return shared.AlertRowSchema.parse(row);
118
80
  },
119
81
  onSuccess: (_, { userId, alertId }) => {
120
- queryClient.invalidateQueries({ queryKey: alertKeys.list(userId) });
82
+ queryClient.invalidateQueries({ queryKey: alertKeys.lists() });
121
83
  queryClient.invalidateQueries({ queryKey: alertKeys.detail(userId, alertId) });
122
84
  },
123
85
  ...options
@@ -127,10 +89,11 @@ function useDeleteAlert(options) {
127
89
  const queryClient = reactQuery.useQueryClient();
128
90
  return reactQuery.useMutation({
129
91
  mutationFn: async ({ userId, alertId }) => {
130
- await api.delete(`/users/${userId}/alerts/${alertId}`);
92
+ const { error } = await shared.supabase.from("alerts").delete().eq("id", alertId).eq("user_id", userId);
93
+ if (error) throw new Error(error.message);
131
94
  },
132
95
  onSuccess: (_, { userId, alertId }) => {
133
- queryClient.invalidateQueries({ queryKey: alertKeys.list(userId) });
96
+ queryClient.invalidateQueries({ queryKey: alertKeys.lists() });
134
97
  queryClient.removeQueries({ queryKey: alertKeys.detail(userId, alertId) });
135
98
  },
136
99
  ...options
@@ -141,10 +104,9 @@ function useUpdateAlertDestinations(options) {
141
104
  return reactQuery.useMutation({
142
105
  mutationFn: async ({ userId, data }) => {
143
106
  const validated = shared.AlertDestinationsUpdateSchema.parse(data);
144
- const response = await api.put(`/users/${userId}/alert_destinations`, {
145
- destinations: validated
146
- });
147
- return shared.AlertDestinationsSchema.parse(response.data);
107
+ const { data: row, error } = await shared.supabase.from("alert_destinations").upsert({ user_id: userId, ...validated }).select().single();
108
+ if (error) throw new Error(error.message);
109
+ return shared.AlertDestinationsSchema.parse(row);
148
110
  },
149
111
  onSuccess: (_, { userId }) => {
150
112
  queryClient.invalidateQueries({ queryKey: alertKeys.destinations(userId) });
@@ -154,7 +116,6 @@ function useUpdateAlertDestinations(options) {
154
116
  }
155
117
 
156
118
  exports.alertKeys = alertKeys;
157
- exports.api = api;
158
119
  exports.useAlert = useAlert;
159
120
  exports.useAlertDestinations = useAlertDestinations;
160
121
  exports.useAlerts = useAlerts;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts","../src/keys.ts","../src/queries/useAlerts.ts","../src/queries/useAlert.ts","../src/queries/useAlertDestinations.ts","../src/mutations/useCreateAlert.ts","../src/mutations/useUpdateAlert.ts","../src/mutations/useDeleteAlert.ts","../src/mutations/useUpdateAlertDestinations.ts"],"names":["axios","useQuery","AlertsResponseSchema","AlertSchema","AlertDestinationsSchema","useQueryClient","useMutation","AlertCreateSchema","AlertUpdateSchema","AlertDestinationsUpdateSchema"],"mappings":";;;;;;;;;;;AAMO,IAAM,GAAA,GAAMA,uBAAM,MAAA,CAAO;AAAA,EAC9B,OAAA,EAAS,MAAA;AAAA,EACT,OAAA,EAAS;AAAA,IACP,cAAA,EAAgB;AAAA;AAEpB,CAAC;;;ACPM,IAAM,SAAA,GAAY;AAAA,EACvB,GAAA,EAAK,CAAC,QAAQ,CAAA;AAAA;AAAA,EAGd,OAAO,MAAM,CAAC,GAAG,SAAA,CAAU,KAAK,MAAM,CAAA;AAAA,EACtC,IAAA,EAAM,CAAC,MAAA,KAAmB,CAAC,GAAG,SAAA,CAAU,KAAA,I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AA,MAAM,WAAW,MAAM,GAAA,CAAI,GAAA,CAAI,CAAA,OAAA,EAAU,MAAM,CAAA,mBAAA,CAAA,EAAuB;AAAA,QACpE,YAAA,EAAc;AAAA,OACf,CAAA;AACD,MAAA,OAAOL,8BAAAA,CAAwB,KAAA,CAAM,QAAA,CAAS,IAAI,CAAA;AAAA,IACpD,CAAA;AAAA,IACA,SAAA,EAAW,CAAC,CAAA,EAAG,EAAE,QAAO,KAAM;AAC5B,MAAA,WAAA,CAAY,kBAAkB,EAAE,QAAA,EAAU,UAAU,YAAA,CAAa,MAAM,GAAG,CAAA;AAAA,IAC5E,CAAA;AAAA,IACA,GAAG;AAAA,GACJ,CAAA;AACH","file":"index.cjs","sourcesContent":["import axios from 'axios';\n\n/**\n * Axios instance for Alerts API\n * Base URL configured through environment variables or defaults to relative path\n */\nexport const api = axios.create({\n baseURL: '/api',\n headers: {\n 'Content-Type': 'application/json',\n },\n});\n","/**\n * Query key factory for Alerts domain\n */\n\nexport const alertKeys = {\n all: ['alerts'] as const,\n\n // Alert lists and details\n lists: () => [...alertKeys.all, 'list'] as const,\n list: (userId: string) => [...alertKeys.lists(), userId] as const,\n details: () => [...alertKeys.all, 'detail'] as const,\n detail: (userId: string, alertId: number) =>\n [...alertKeys.details(), userId, alertId] as const,\n\n // Alert destinations\n destinations: (userId: string) =>\n [...alertKeys.all, 'destinations', userId] as const,\n};\n","import { useQuery, UseQueryOptions } from '@tanstack/react-query';\nimport { Alert, AlertsResponseSchema } from '@pfm-platform/shared';\nimport { api } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UseAlertsParams {\n userId: string;\n}\n\n/**\n * Fetch all alerts for a user\n * GET /users/:userId/alerts\n */\nexport function useAlerts(\n { userId }: UseAlertsParams,\n options?: Omit<UseQueryOptions<Alert[]>, 'queryKey' | 'queryFn'>\n) {\n return useQuery({\n queryKey: alertKeys.list(userId),\n queryFn: async () => {\n const response = await api.get(`/users/${userId}/alerts`);\n const validated = AlertsResponseSchema.parse(response.data);\n return validated.alerts;\n },\n staleTime: 1000 * 60 * 5, // 5 minutes (alerts change moderately)\n ...options,\n });\n}\n","import { useQuery, UseQueryOptions } from '@tanstack/react-query';\nimport { Alert, AlertSchema } from '@pfm-platform/shared';\nimport { api } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UseAlertParams {\n userId: string;\n alertId: number;\n}\n\n/**\n * Fetch a single alert by ID\n * GET /users/:userId/alerts/:alertId\n */\nexport function useAlert(\n { userId, alertId }: UseAlertParams,\n options?: Omit<UseQueryOptions<Alert>, 'queryKey' | 'queryFn'>\n) {\n return useQuery({\n queryKey: alertKeys.detail(userId, alertId),\n queryFn: async () => {\n const response = await api.get(`/users/${userId}/alerts/${alertId}`);\n return AlertSchema.parse(response.data);\n },\n staleTime: 1000 * 60 * 5, // 5 minutes\n ...options,\n });\n}\n","import { useQuery, UseQueryOptions } from '@tanstack/react-query';\nimport { AlertDestinations, AlertDestinationsSchema } from '@pfm-platform/shared';\nimport { api } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UseAlertDestinationsParams {\n userId: string;\n}\n\n/**\n * Fetch alert destinations for a user\n * GET /users/:userId/alert_destinations\n */\nexport function useAlertDestinations(\n { userId }: UseAlertDestinationsParams,\n options?: Omit<UseQueryOptions<AlertDestinations>, 'queryKey' | 'queryFn'>\n) {\n return useQuery({\n queryKey: alertKeys.destinations(userId),\n queryFn: async () => {\n const response = await api.get(`/users/${userId}/alert_destinations`);\n return AlertDestinationsSchema.parse(response.data);\n },\n staleTime: 1000 * 60 * 10, // 10 minutes (destinations rarely change)\n ...options,\n });\n}\n","import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query';\nimport { Alert, AlertCreate, AlertCreateSchema, AlertSchema, AlertType } from '@pfm-platform/shared';\nimport { api } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface CreateAlertParams {\n userId: string;\n type: AlertType;\n data: AlertCreate;\n}\n\n/**\n * Create a new alert\n * POST /users/:userId/alerts/:type\n *\n * Type-based routing from legacy API routeMapping:\n * - AccountThresholdAlert → account_threshold_alerts\n * - GoalAlert → goal_alerts\n * - MerchantNameAlert → merchant_name_alerts\n * - SpendingTargetAlert → spending_target_alerts\n * - TransactionLimitAlert → transaction_limit_alerts\n * - UpcomingBillAlert → upcoming_bill_alerts\n */\nexport function useCreateAlert(\n options?: Omit<UseMutationOptions<Alert, Error, CreateAlertParams>, 'mutationFn'>\n) {\n const queryClient = useQueryClient();\n\n // Type to endpoint mapping\n const getEndpoint = (type: AlertType): string => {\n const mapping: Record<AlertType, string> = {\n AccountThresholdAlert: 'account_threshold_alerts',\n GoalAlert: 'goal_alerts',\n MerchantNameAlert: 'merchant_name_alerts',\n SpendingTargetAlert: 'spending_target_alerts',\n TransactionLimitAlert: 'transaction_limit_alerts',\n UpcomingBillAlert: 'upcoming_bill_alerts',\n };\n return mapping[type];\n };\n\n return useMutation({\n mutationFn: async ({ userId, type, data }: CreateAlertParams) => {\n const validated = AlertCreateSchema.parse(data);\n const endpoint = getEndpoint(type);\n const response = await api.post(`/users/${userId}/${endpoint}`, {\n alert: validated,\n });\n return AlertSchema.parse(response.data);\n },\n onSuccess: (_, { userId }) => {\n queryClient.invalidateQueries({ queryKey: alertKeys.list(userId) });\n },\n ...options,\n });\n}\n","import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query';\nimport { Alert, AlertUpdate, AlertUpdateSchema, AlertSchema, AlertType } from '@pfm-platform/shared';\nimport { api } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UpdateAlertParams {\n userId: string;\n alertId: number;\n type: AlertType;\n data: AlertUpdate;\n}\n\n/**\n * Update an existing alert\n * PUT /users/:userId/alerts/:type/:alertId\n *\n * Type-based routing - same mapping as create\n */\nexport function useUpdateAlert(\n options?: Omit<UseMutationOptions<Alert, Error, UpdateAlertParams>, 'mutationFn'>\n) {\n const queryClient = useQueryClient();\n\n // Type to endpoint mapping\n const getEndpoint = (type: AlertType): string => {\n const mapping: Record<AlertType, string> = {\n AccountThresholdAlert: 'account_threshold_alerts',\n GoalAlert: 'goal_alerts',\n MerchantNameAlert: 'merchant_name_alerts',\n SpendingTargetAlert: 'spending_target_alerts',\n TransactionLimitAlert: 'transaction_limit_alerts',\n UpcomingBillAlert: 'upcoming_bill_alerts',\n };\n return mapping[type];\n };\n\n return useMutation({\n mutationFn: async ({ userId, alertId, type, data }: UpdateAlertParams) => {\n const validated = AlertUpdateSchema.parse(data);\n const endpoint = getEndpoint(type);\n const response = await api.put(`/users/${userId}/${endpoint}/${alertId}`, {\n alert: validated,\n });\n return AlertSchema.parse(response.data);\n },\n onSuccess: (_, { userId, alertId }) => {\n queryClient.invalidateQueries({ queryKey: alertKeys.list(userId) });\n queryClient.invalidateQueries({ queryKey: alertKeys.detail(userId, alertId) });\n },\n ...options,\n });\n}\n","import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query';\nimport { api } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface DeleteAlertParams {\n userId: string;\n alertId: number;\n}\n\n/**\n * Delete an alert\n * DELETE /users/:userId/alerts/:alertId\n */\nexport function useDeleteAlert(\n options?: Omit<UseMutationOptions<void, Error, DeleteAlertParams>, 'mutationFn'>\n) {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ userId, alertId }: DeleteAlertParams) => {\n await api.delete(`/users/${userId}/alerts/${alertId}`);\n },\n onSuccess: (_, { userId, alertId }) => {\n queryClient.invalidateQueries({ queryKey: alertKeys.list(userId) });\n queryClient.removeQueries({ queryKey: alertKeys.detail(userId, alertId) });\n },\n ...options,\n });\n}\n","import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query';\nimport {\n AlertDestinations,\n AlertDestinationsUpdate,\n AlertDestinationsUpdateSchema,\n AlertDestinationsSchema,\n} from '@pfm-platform/shared';\nimport { api } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UpdateAlertDestinationsParams {\n userId: string;\n data: AlertDestinationsUpdate;\n}\n\n/**\n * Update alert destinations for a user\n * PUT /users/:userId/alert_destinations\n */\nexport function useUpdateAlertDestinations(\n options?: Omit<UseMutationOptions<AlertDestinations, Error, UpdateAlertDestinationsParams>, 'mutationFn'>\n) {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ userId, data }: UpdateAlertDestinationsParams) => {\n const validated = AlertDestinationsUpdateSchema.parse(data);\n const response = await api.put(`/users/${userId}/alert_destinations`, {\n destinations: validated,\n });\n return AlertDestinationsSchema.parse(response.data);\n },\n onSuccess: (_, { userId }) => {\n queryClient.invalidateQueries({ queryKey: alertKeys.destinations(userId) });\n },\n ...options,\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/keys.ts","../src/queries/useAlerts.ts","../src/queries/useAlert.ts","../src/queries/useAlertDestinations.ts","../src/mutations/useCreateAlert.ts","../src/mutations/useUpdateAlert.ts","../src/mutations/useDeleteAlert.ts","../src/mutations/useUpdateAlertDestinations.ts"],"names":["useQuery","supabase","AlertsResponseSchema","AlertRowSchema","AlertDestinationsSchema","useQueryClient","useMutation","AlertCreateSchema","AlertUpdateSchema","AlertDestinationsUpdateSchema"],"mappings":";;;;;;;;AAIO,IAAM,SAAA,GAAY;AAAA,EACvB,GAAA,EAAK,CAAC,QAAQ,CAAA;AAAA;AAAA,EAGd,OAAO,MAAM,CAAC,GAAG,SAAA,CAAU,KAAK,MAAM,CAAA;AAAA,EACtC,IAAA,EAAM,CAAC,MAAA,KAAmB,CAAC,GAAG,SAAA,CAAU,KAAA,IAAS,MAAM,CAAA;AAAA,EACvD,SAAS,MAAM,CAAC,GAAG,SAAA,CAAU,KAAK,QAAQ,CAAA;AAAA,EAC1C,MAAA,EAAQ,CAAC,MAAA,EAAgB,OAAA,KACvB,CAAC,GAAG,SAAA,CAAU,OAAA,EAAQ,EAAG,MAAA,EAAQ,OAAO,CAAA;AAAA;AAAA,EAG1C,YAAA,EAAc,CAAC,MAAA,KACb,CAAC,GAAG,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AA,CAAa,MAAM,GAAG,CAAA;AAAA,IAC5E,CAAA;AAAA,IACA,GAAG;AAAA,GACJ,CAAA;AACH","file":"index.cjs","sourcesContent":["/**\n * Query key factory for Alerts domain\n */\n\nexport const alertKeys = {\n all: ['alerts'] as const,\n\n // Alert lists and details\n lists: () => [...alertKeys.all, 'list'] as const,\n list: (userId: string) => [...alertKeys.lists(), userId] as const,\n details: () => [...alertKeys.all, 'detail'] as const,\n detail: (userId: string, alertId: string) =>\n [...alertKeys.details(), userId, alertId] as const,\n\n // Alert destinations\n destinations: (userId: string) =>\n [...alertKeys.all, 'destinations', userId] as const,\n};\n","import { useQuery, type UseQueryOptions } from '@tanstack/react-query';\nimport { AlertsResponseSchema, type AlertRow } from '@pfm-platform/shared';\nimport { supabase } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UseAlertsParams {\n userId: string;\n}\n\n/**\n * Fetch all alerts for a user from Supabase\n */\nexport function useAlerts(\n { userId }: UseAlertsParams,\n options?: Omit<UseQueryOptions<AlertRow[]>, 'queryKey' | 'queryFn'>\n) {\n return useQuery({\n queryKey: alertKeys.list(userId),\n queryFn: async () => {\n const { data, error } = await supabase\n .from('alerts')\n .select('*')\n .eq('user_id', userId)\n .order('created_at');\n\n if (error) throw new Error(error.message);\n\n return AlertsResponseSchema.parse(data);\n },\n staleTime: 1000 * 60 * 5,\n ...options,\n });\n}\n","import { useQuery, type UseQueryOptions } from '@tanstack/react-query';\nimport { AlertRowSchema, type AlertRow } from '@pfm-platform/shared';\nimport { supabase } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UseAlertParams {\n userId: string;\n alertId: string;\n}\n\n/**\n * Fetch a single alert by ID from Supabase\n */\nexport function useAlert(\n { userId, alertId }: UseAlertParams,\n options?: Omit<UseQueryOptions<AlertRow>, 'queryKey' | 'queryFn'>\n) {\n return useQuery({\n queryKey: alertKeys.detail(userId, alertId),\n queryFn: async () => {\n const { data, error } = await supabase\n .from('alerts')\n .select('*')\n .eq('id', alertId)\n .eq('user_id', userId)\n .single();\n\n if (error) throw new Error(error.message);\n\n return AlertRowSchema.parse(data);\n },\n staleTime: 1000 * 60 * 5,\n ...options,\n });\n}\n","import { useQuery, type UseQueryOptions } from '@tanstack/react-query';\nimport { AlertDestinationsSchema, type AlertDestinations } from '@pfm-platform/shared';\nimport { supabase } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UseAlertDestinationsParams {\n userId: string;\n}\n\n/**\n * Fetch alert destinations for a user from Supabase\n * alert_destinations is a single-row-per-user table (user_id is PK)\n */\nexport function useAlertDestinations(\n { userId }: UseAlertDestinationsParams,\n options?: Omit<UseQueryOptions<AlertDestinations>, 'queryKey' | 'queryFn'>\n) {\n return useQuery({\n queryKey: alertKeys.destinations(userId),\n queryFn: async () => {\n const { data, error } = await supabase\n .from('alert_destinations')\n .select('*')\n .eq('user_id', userId)\n .single();\n\n if (error) throw new Error(error.message);\n\n return AlertDestinationsSchema.parse(data);\n },\n staleTime: 1000 * 60 * 10,\n ...options,\n });\n}\n","import {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n} from '@tanstack/react-query';\nimport {\n AlertCreateSchema,\n AlertRowSchema,\n type AlertCreate,\n type AlertRow,\n type TablesInsert,\n} from '@pfm-platform/shared';\nimport { supabase } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface CreateAlertParams {\n userId: string;\n data: AlertCreate;\n}\n\n/**\n * Create a new alert in Supabase\n * Single table — no type-based routing needed\n */\nexport function useCreateAlert(\n options?: Omit<UseMutationOptions<AlertRow, Error, CreateAlertParams>, 'mutationFn'>\n) {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ userId, data }: CreateAlertParams) => {\n const validated = AlertCreateSchema.parse(data);\n\n const { data: row, error } = await supabase\n .from('alerts')\n .insert({ user_id: userId, ...validated } as TablesInsert<'alerts'>)\n .select()\n .single();\n\n if (error) throw new Error(error.message);\n\n return AlertRowSchema.parse(row);\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: alertKeys.lists() });\n },\n ...options,\n });\n}\n","import {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n} from '@tanstack/react-query';\nimport {\n AlertUpdateSchema,\n AlertRowSchema,\n type AlertUpdate,\n type AlertRow,\n type TablesUpdate,\n} from '@pfm-platform/shared';\nimport { supabase } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UpdateAlertParams {\n userId: string;\n alertId: string;\n data: AlertUpdate;\n}\n\n/**\n * Update an existing alert in Supabase\n */\nexport function useUpdateAlert(\n options?: Omit<UseMutationOptions<AlertRow, Error, UpdateAlertParams>, 'mutationFn'>\n) {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ userId, alertId, data }: UpdateAlertParams) => {\n const validated = AlertUpdateSchema.parse(data);\n\n const { data: row, error } = await supabase\n .from('alerts')\n .update(validated as TablesUpdate<'alerts'>)\n .eq('id', alertId)\n .eq('user_id', userId)\n .select()\n .single();\n\n if (error) throw new Error(error.message);\n\n return AlertRowSchema.parse(row);\n },\n onSuccess: (_, { userId, alertId }) => {\n queryClient.invalidateQueries({ queryKey: alertKeys.lists() });\n queryClient.invalidateQueries({ queryKey: alertKeys.detail(userId, alertId) });\n },\n ...options,\n });\n}\n","import {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n} from '@tanstack/react-query';\nimport { supabase } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface DeleteAlertParams {\n userId: string;\n alertId: string;\n}\n\n/**\n * Delete an alert from Supabase\n */\nexport function useDeleteAlert(\n options?: Omit<UseMutationOptions<void, Error, DeleteAlertParams>, 'mutationFn'>\n) {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ userId, alertId }: DeleteAlertParams) => {\n const { error } = await supabase\n .from('alerts')\n .delete()\n .eq('id', alertId)\n .eq('user_id', userId);\n\n if (error) throw new Error(error.message);\n },\n onSuccess: (_, { userId, alertId }) => {\n queryClient.invalidateQueries({ queryKey: alertKeys.lists() });\n queryClient.removeQueries({ queryKey: alertKeys.detail(userId, alertId) });\n },\n ...options,\n });\n}\n","import {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n} from '@tanstack/react-query';\nimport {\n AlertDestinationsUpdateSchema,\n AlertDestinationsSchema,\n type AlertDestinations,\n type AlertDestinationsUpdate,\n} from '@pfm-platform/shared';\nimport { supabase } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UpdateAlertDestinationsParams {\n userId: string;\n data: AlertDestinationsUpdate;\n}\n\n/**\n * Update alert destinations for a user in Supabase\n * Uses upsert since alert_destinations is a single-row-per-user table\n */\nexport function useUpdateAlertDestinations(\n options?: Omit<UseMutationOptions<AlertDestinations, Error, UpdateAlertDestinationsParams>, 'mutationFn'>\n) {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ userId, data }: UpdateAlertDestinationsParams) => {\n const validated = AlertDestinationsUpdateSchema.parse(data);\n\n const { data: row, error } = await supabase\n .from('alert_destinations')\n .upsert({ user_id: userId, ...validated })\n .select()\n .single();\n\n if (error) throw new Error(error.message);\n\n return AlertDestinationsSchema.parse(row);\n },\n onSuccess: (_, { userId }) => {\n queryClient.invalidateQueries({ queryKey: alertKeys.destinations(userId) });\n },\n ...options,\n });\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,55 +1,52 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
3
- import { Alert, AlertDestinations, AlertType, AlertCreate, AlertUpdate, AlertDestinationsUpdate } from '@pfm-platform/shared';
4
- import * as axios from 'axios';
3
+ import { AlertRow, AlertDestinations, AlertCreate, AlertUpdate, AlertDestinationsUpdate } from '@pfm-platform/shared';
5
4
 
6
5
  interface UseAlertsParams {
7
6
  userId: string;
8
7
  }
9
8
  /**
10
- * Fetch all alerts for a user
11
- * GET /users/:userId/alerts
9
+ * Fetch all alerts for a user from Supabase
12
10
  */
13
- declare function useAlerts({ userId }: UseAlertsParams, options?: Omit<UseQueryOptions<Alert[]>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
14
- id: number;
11
+ declare function useAlerts({ userId }: UseAlertsParams, options?: Omit<UseQueryOptions<AlertRow[]>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
12
+ id: string;
13
+ user_id: string;
15
14
  type: "AccountThresholdAlert" | "GoalAlert" | "MerchantNameAlert" | "SpendingTargetAlert" | "TransactionLimitAlert" | "UpcomingBillAlert";
16
- options: {
17
- [x: string]: unknown;
18
- };
15
+ options: Record<string, unknown>;
19
16
  email_delivery: boolean;
20
17
  sms_delivery: boolean;
21
18
  source_type: "Account" | "Budget" | "CashflowTransaction" | "PayoffGoal" | "SavingsGoal" | null;
22
- source_id?: string | number | undefined;
23
- source?: unknown;
19
+ source_id: string | null;
20
+ created_at: string | null;
21
+ updated_at: string | null;
24
22
  }[], Error>;
25
23
 
26
24
  interface UseAlertParams {
27
25
  userId: string;
28
- alertId: number;
26
+ alertId: string;
29
27
  }
30
28
  /**
31
- * Fetch a single alert by ID
32
- * GET /users/:userId/alerts/:alertId
29
+ * Fetch a single alert by ID from Supabase
33
30
  */
34
- declare function useAlert({ userId, alertId }: UseAlertParams, options?: Omit<UseQueryOptions<Alert>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
35
- id: number;
31
+ declare function useAlert({ userId, alertId }: UseAlertParams, options?: Omit<UseQueryOptions<AlertRow>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
32
+ id: string;
33
+ user_id: string;
36
34
  type: "AccountThresholdAlert" | "GoalAlert" | "MerchantNameAlert" | "SpendingTargetAlert" | "TransactionLimitAlert" | "UpcomingBillAlert";
37
- options: {
38
- [x: string]: unknown;
39
- };
35
+ options: Record<string, unknown>;
40
36
  email_delivery: boolean;
41
37
  sms_delivery: boolean;
42
38
  source_type: "Account" | "Budget" | "CashflowTransaction" | "PayoffGoal" | "SavingsGoal" | null;
43
- source_id?: string | number | undefined;
44
- source?: unknown;
39
+ source_id: string | null;
40
+ created_at: string | null;
41
+ updated_at: string | null;
45
42
  }, Error>;
46
43
 
47
44
  interface UseAlertDestinationsParams {
48
45
  userId: string;
49
46
  }
50
47
  /**
51
- * Fetch alert destinations for a user
52
- * GET /users/:userId/alert_destinations
48
+ * Fetch alert destinations for a user from Supabase
49
+ * alert_destinations is a single-row-per-user table (user_id is PK)
53
50
  */
54
51
  declare function useAlertDestinations({ userId }: UseAlertDestinationsParams, options?: Omit<UseQueryOptions<AlertDestinations>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
55
52
  email_address: string | null;
@@ -59,66 +56,52 @@ declare function useAlertDestinations({ userId }: UseAlertDestinationsParams, op
59
56
 
60
57
  interface CreateAlertParams {
61
58
  userId: string;
62
- type: AlertType;
63
59
  data: AlertCreate;
64
60
  }
65
61
  /**
66
- * Create a new alert
67
- * POST /users/:userId/alerts/:type
68
- *
69
- * Type-based routing from legacy API routeMapping:
70
- * - AccountThresholdAlert → account_threshold_alerts
71
- * - GoalAlert → goal_alerts
72
- * - MerchantNameAlert → merchant_name_alerts
73
- * - SpendingTargetAlert → spending_target_alerts
74
- * - TransactionLimitAlert → transaction_limit_alerts
75
- * - UpcomingBillAlert → upcoming_bill_alerts
62
+ * Create a new alert in Supabase
63
+ * Single table — no type-based routing needed
76
64
  */
77
- declare function useCreateAlert(options?: Omit<UseMutationOptions<Alert, Error, CreateAlertParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
78
- id: number;
65
+ declare function useCreateAlert(options?: Omit<UseMutationOptions<AlertRow, Error, CreateAlertParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
66
+ id: string;
67
+ user_id: string;
79
68
  type: "AccountThresholdAlert" | "GoalAlert" | "MerchantNameAlert" | "SpendingTargetAlert" | "TransactionLimitAlert" | "UpcomingBillAlert";
80
- options: {
81
- [x: string]: unknown;
82
- };
69
+ options: Record<string, unknown>;
83
70
  email_delivery: boolean;
84
71
  sms_delivery: boolean;
85
72
  source_type: "Account" | "Budget" | "CashflowTransaction" | "PayoffGoal" | "SavingsGoal" | null;
86
- source_id?: string | number | undefined;
87
- source?: unknown;
73
+ source_id: string | null;
74
+ created_at: string | null;
75
+ updated_at: string | null;
88
76
  }, Error, CreateAlertParams, unknown>;
89
77
 
90
78
  interface UpdateAlertParams {
91
79
  userId: string;
92
- alertId: number;
93
- type: AlertType;
80
+ alertId: string;
94
81
  data: AlertUpdate;
95
82
  }
96
83
  /**
97
- * Update an existing alert
98
- * PUT /users/:userId/alerts/:type/:alertId
99
- *
100
- * Type-based routing - same mapping as create
84
+ * Update an existing alert in Supabase
101
85
  */
102
- declare function useUpdateAlert(options?: Omit<UseMutationOptions<Alert, Error, UpdateAlertParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
103
- id: number;
86
+ declare function useUpdateAlert(options?: Omit<UseMutationOptions<AlertRow, Error, UpdateAlertParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
87
+ id: string;
88
+ user_id: string;
104
89
  type: "AccountThresholdAlert" | "GoalAlert" | "MerchantNameAlert" | "SpendingTargetAlert" | "TransactionLimitAlert" | "UpcomingBillAlert";
105
- options: {
106
- [x: string]: unknown;
107
- };
90
+ options: Record<string, unknown>;
108
91
  email_delivery: boolean;
109
92
  sms_delivery: boolean;
110
93
  source_type: "Account" | "Budget" | "CashflowTransaction" | "PayoffGoal" | "SavingsGoal" | null;
111
- source_id?: string | number | undefined;
112
- source?: unknown;
94
+ source_id: string | null;
95
+ created_at: string | null;
96
+ updated_at: string | null;
113
97
  }, Error, UpdateAlertParams, unknown>;
114
98
 
115
99
  interface DeleteAlertParams {
116
100
  userId: string;
117
- alertId: number;
101
+ alertId: string;
118
102
  }
119
103
  /**
120
- * Delete an alert
121
- * DELETE /users/:userId/alerts/:alertId
104
+ * Delete an alert from Supabase
122
105
  */
123
106
  declare function useDeleteAlert(options?: Omit<UseMutationOptions<void, Error, DeleteAlertParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<void, Error, DeleteAlertParams, unknown>;
124
107
 
@@ -127,8 +110,8 @@ interface UpdateAlertDestinationsParams {
127
110
  data: AlertDestinationsUpdate;
128
111
  }
129
112
  /**
130
- * Update alert destinations for a user
131
- * PUT /users/:userId/alert_destinations
113
+ * Update alert destinations for a user in Supabase
114
+ * Uses upsert since alert_destinations is a single-row-per-user table
132
115
  */
133
116
  declare function useUpdateAlertDestinations(options?: Omit<UseMutationOptions<AlertDestinations, Error, UpdateAlertDestinationsParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
134
117
  email_address: string | null;
@@ -144,14 +127,8 @@ declare const alertKeys: {
144
127
  lists: () => readonly ["alerts", "list"];
145
128
  list: (userId: string) => readonly ["alerts", "list", string];
146
129
  details: () => readonly ["alerts", "detail"];
147
- detail: (userId: string, alertId: number) => readonly ["alerts", "detail", string, number];
130
+ detail: (userId: string, alertId: string) => readonly ["alerts", "detail", string, string];
148
131
  destinations: (userId: string) => readonly ["alerts", "destinations", string];
149
132
  };
150
133
 
151
- /**
152
- * Axios instance for Alerts API
153
- * Base URL configured through environment variables or defaults to relative path
154
- */
155
- declare const api: axios.AxiosInstance;
156
-
157
- export { type CreateAlertParams, type DeleteAlertParams, type UpdateAlertDestinationsParams, type UpdateAlertParams, type UseAlertDestinationsParams, type UseAlertParams, type UseAlertsParams, alertKeys, api, useAlert, useAlertDestinations, useAlerts, useCreateAlert, useDeleteAlert, useUpdateAlert, useUpdateAlertDestinations };
134
+ export { type CreateAlertParams, type DeleteAlertParams, type UpdateAlertDestinationsParams, type UpdateAlertParams, type UseAlertDestinationsParams, type UseAlertParams, type UseAlertsParams, alertKeys, useAlert, useAlertDestinations, useAlerts, useCreateAlert, useDeleteAlert, useUpdateAlert, useUpdateAlertDestinations };
package/dist/index.d.ts CHANGED
@@ -1,55 +1,52 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
3
- import { Alert, AlertDestinations, AlertType, AlertCreate, AlertUpdate, AlertDestinationsUpdate } from '@pfm-platform/shared';
4
- import * as axios from 'axios';
3
+ import { AlertRow, AlertDestinations, AlertCreate, AlertUpdate, AlertDestinationsUpdate } from '@pfm-platform/shared';
5
4
 
6
5
  interface UseAlertsParams {
7
6
  userId: string;
8
7
  }
9
8
  /**
10
- * Fetch all alerts for a user
11
- * GET /users/:userId/alerts
9
+ * Fetch all alerts for a user from Supabase
12
10
  */
13
- declare function useAlerts({ userId }: UseAlertsParams, options?: Omit<UseQueryOptions<Alert[]>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
14
- id: number;
11
+ declare function useAlerts({ userId }: UseAlertsParams, options?: Omit<UseQueryOptions<AlertRow[]>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
12
+ id: string;
13
+ user_id: string;
15
14
  type: "AccountThresholdAlert" | "GoalAlert" | "MerchantNameAlert" | "SpendingTargetAlert" | "TransactionLimitAlert" | "UpcomingBillAlert";
16
- options: {
17
- [x: string]: unknown;
18
- };
15
+ options: Record<string, unknown>;
19
16
  email_delivery: boolean;
20
17
  sms_delivery: boolean;
21
18
  source_type: "Account" | "Budget" | "CashflowTransaction" | "PayoffGoal" | "SavingsGoal" | null;
22
- source_id?: string | number | undefined;
23
- source?: unknown;
19
+ source_id: string | null;
20
+ created_at: string | null;
21
+ updated_at: string | null;
24
22
  }[], Error>;
25
23
 
26
24
  interface UseAlertParams {
27
25
  userId: string;
28
- alertId: number;
26
+ alertId: string;
29
27
  }
30
28
  /**
31
- * Fetch a single alert by ID
32
- * GET /users/:userId/alerts/:alertId
29
+ * Fetch a single alert by ID from Supabase
33
30
  */
34
- declare function useAlert({ userId, alertId }: UseAlertParams, options?: Omit<UseQueryOptions<Alert>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
35
- id: number;
31
+ declare function useAlert({ userId, alertId }: UseAlertParams, options?: Omit<UseQueryOptions<AlertRow>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
32
+ id: string;
33
+ user_id: string;
36
34
  type: "AccountThresholdAlert" | "GoalAlert" | "MerchantNameAlert" | "SpendingTargetAlert" | "TransactionLimitAlert" | "UpcomingBillAlert";
37
- options: {
38
- [x: string]: unknown;
39
- };
35
+ options: Record<string, unknown>;
40
36
  email_delivery: boolean;
41
37
  sms_delivery: boolean;
42
38
  source_type: "Account" | "Budget" | "CashflowTransaction" | "PayoffGoal" | "SavingsGoal" | null;
43
- source_id?: string | number | undefined;
44
- source?: unknown;
39
+ source_id: string | null;
40
+ created_at: string | null;
41
+ updated_at: string | null;
45
42
  }, Error>;
46
43
 
47
44
  interface UseAlertDestinationsParams {
48
45
  userId: string;
49
46
  }
50
47
  /**
51
- * Fetch alert destinations for a user
52
- * GET /users/:userId/alert_destinations
48
+ * Fetch alert destinations for a user from Supabase
49
+ * alert_destinations is a single-row-per-user table (user_id is PK)
53
50
  */
54
51
  declare function useAlertDestinations({ userId }: UseAlertDestinationsParams, options?: Omit<UseQueryOptions<AlertDestinations>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<{
55
52
  email_address: string | null;
@@ -59,66 +56,52 @@ declare function useAlertDestinations({ userId }: UseAlertDestinationsParams, op
59
56
 
60
57
  interface CreateAlertParams {
61
58
  userId: string;
62
- type: AlertType;
63
59
  data: AlertCreate;
64
60
  }
65
61
  /**
66
- * Create a new alert
67
- * POST /users/:userId/alerts/:type
68
- *
69
- * Type-based routing from legacy API routeMapping:
70
- * - AccountThresholdAlert → account_threshold_alerts
71
- * - GoalAlert → goal_alerts
72
- * - MerchantNameAlert → merchant_name_alerts
73
- * - SpendingTargetAlert → spending_target_alerts
74
- * - TransactionLimitAlert → transaction_limit_alerts
75
- * - UpcomingBillAlert → upcoming_bill_alerts
62
+ * Create a new alert in Supabase
63
+ * Single table — no type-based routing needed
76
64
  */
77
- declare function useCreateAlert(options?: Omit<UseMutationOptions<Alert, Error, CreateAlertParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
78
- id: number;
65
+ declare function useCreateAlert(options?: Omit<UseMutationOptions<AlertRow, Error, CreateAlertParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
66
+ id: string;
67
+ user_id: string;
79
68
  type: "AccountThresholdAlert" | "GoalAlert" | "MerchantNameAlert" | "SpendingTargetAlert" | "TransactionLimitAlert" | "UpcomingBillAlert";
80
- options: {
81
- [x: string]: unknown;
82
- };
69
+ options: Record<string, unknown>;
83
70
  email_delivery: boolean;
84
71
  sms_delivery: boolean;
85
72
  source_type: "Account" | "Budget" | "CashflowTransaction" | "PayoffGoal" | "SavingsGoal" | null;
86
- source_id?: string | number | undefined;
87
- source?: unknown;
73
+ source_id: string | null;
74
+ created_at: string | null;
75
+ updated_at: string | null;
88
76
  }, Error, CreateAlertParams, unknown>;
89
77
 
90
78
  interface UpdateAlertParams {
91
79
  userId: string;
92
- alertId: number;
93
- type: AlertType;
80
+ alertId: string;
94
81
  data: AlertUpdate;
95
82
  }
96
83
  /**
97
- * Update an existing alert
98
- * PUT /users/:userId/alerts/:type/:alertId
99
- *
100
- * Type-based routing - same mapping as create
84
+ * Update an existing alert in Supabase
101
85
  */
102
- declare function useUpdateAlert(options?: Omit<UseMutationOptions<Alert, Error, UpdateAlertParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
103
- id: number;
86
+ declare function useUpdateAlert(options?: Omit<UseMutationOptions<AlertRow, Error, UpdateAlertParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
87
+ id: string;
88
+ user_id: string;
104
89
  type: "AccountThresholdAlert" | "GoalAlert" | "MerchantNameAlert" | "SpendingTargetAlert" | "TransactionLimitAlert" | "UpcomingBillAlert";
105
- options: {
106
- [x: string]: unknown;
107
- };
90
+ options: Record<string, unknown>;
108
91
  email_delivery: boolean;
109
92
  sms_delivery: boolean;
110
93
  source_type: "Account" | "Budget" | "CashflowTransaction" | "PayoffGoal" | "SavingsGoal" | null;
111
- source_id?: string | number | undefined;
112
- source?: unknown;
94
+ source_id: string | null;
95
+ created_at: string | null;
96
+ updated_at: string | null;
113
97
  }, Error, UpdateAlertParams, unknown>;
114
98
 
115
99
  interface DeleteAlertParams {
116
100
  userId: string;
117
- alertId: number;
101
+ alertId: string;
118
102
  }
119
103
  /**
120
- * Delete an alert
121
- * DELETE /users/:userId/alerts/:alertId
104
+ * Delete an alert from Supabase
122
105
  */
123
106
  declare function useDeleteAlert(options?: Omit<UseMutationOptions<void, Error, DeleteAlertParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<void, Error, DeleteAlertParams, unknown>;
124
107
 
@@ -127,8 +110,8 @@ interface UpdateAlertDestinationsParams {
127
110
  data: AlertDestinationsUpdate;
128
111
  }
129
112
  /**
130
- * Update alert destinations for a user
131
- * PUT /users/:userId/alert_destinations
113
+ * Update alert destinations for a user in Supabase
114
+ * Uses upsert since alert_destinations is a single-row-per-user table
132
115
  */
133
116
  declare function useUpdateAlertDestinations(options?: Omit<UseMutationOptions<AlertDestinations, Error, UpdateAlertDestinationsParams>, 'mutationFn'>): _tanstack_react_query.UseMutationResult<{
134
117
  email_address: string | null;
@@ -144,14 +127,8 @@ declare const alertKeys: {
144
127
  lists: () => readonly ["alerts", "list"];
145
128
  list: (userId: string) => readonly ["alerts", "list", string];
146
129
  details: () => readonly ["alerts", "detail"];
147
- detail: (userId: string, alertId: number) => readonly ["alerts", "detail", string, number];
130
+ detail: (userId: string, alertId: string) => readonly ["alerts", "detail", string, string];
148
131
  destinations: (userId: string) => readonly ["alerts", "destinations", string];
149
132
  };
150
133
 
151
- /**
152
- * Axios instance for Alerts API
153
- * Base URL configured through environment variables or defaults to relative path
154
- */
155
- declare const api: axios.AxiosInstance;
156
-
157
- export { type CreateAlertParams, type DeleteAlertParams, type UpdateAlertDestinationsParams, type UpdateAlertParams, type UseAlertDestinationsParams, type UseAlertParams, type UseAlertsParams, alertKeys, api, useAlert, useAlertDestinations, useAlerts, useCreateAlert, useDeleteAlert, useUpdateAlert, useUpdateAlertDestinations };
134
+ export { type CreateAlertParams, type DeleteAlertParams, type UpdateAlertDestinationsParams, type UpdateAlertParams, type UseAlertDestinationsParams, type UseAlertParams, type UseAlertsParams, alertKeys, useAlert, useAlertDestinations, useAlerts, useCreateAlert, useDeleteAlert, useUpdateAlert, useUpdateAlertDestinations };
package/dist/index.js CHANGED
@@ -1,14 +1,7 @@
1
1
  import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
2
- import { AlertsResponseSchema, AlertSchema, AlertDestinationsSchema, AlertCreateSchema, AlertUpdateSchema, AlertDestinationsUpdateSchema } from '@pfm-platform/shared';
3
- import axios from 'axios';
2
+ import { supabase, AlertsResponseSchema, AlertRowSchema, AlertDestinationsSchema, AlertCreateSchema, AlertUpdateSchema, AlertDestinationsUpdateSchema } from '@pfm-platform/shared';
4
3
 
5
4
  // src/queries/useAlerts.ts
6
- var api = axios.create({
7
- baseURL: "/api",
8
- headers: {
9
- "Content-Type": "application/json"
10
- }
11
- });
12
5
 
13
6
  // src/keys.ts
14
7
  var alertKeys = {
@@ -27,12 +20,11 @@ function useAlerts({ userId }, options) {
27
20
  return useQuery({
28
21
  queryKey: alertKeys.list(userId),
29
22
  queryFn: async () => {
30
- const response = await api.get(`/users/${userId}/alerts`);
31
- const validated = AlertsResponseSchema.parse(response.data);
32
- return validated.alerts;
23
+ const { data, error } = await supabase.from("alerts").select("*").eq("user_id", userId).order("created_at");
24
+ if (error) throw new Error(error.message);
25
+ return AlertsResponseSchema.parse(data);
33
26
  },
34
27
  staleTime: 1e3 * 60 * 5,
35
- // 5 minutes (alerts change moderately)
36
28
  ...options
37
29
  });
38
30
  }
@@ -40,11 +32,11 @@ function useAlert({ userId, alertId }, options) {
40
32
  return useQuery({
41
33
  queryKey: alertKeys.detail(userId, alertId),
42
34
  queryFn: async () => {
43
- const response = await api.get(`/users/${userId}/alerts/${alertId}`);
44
- return AlertSchema.parse(response.data);
35
+ const { data, error } = await supabase.from("alerts").select("*").eq("id", alertId).eq("user_id", userId).single();
36
+ if (error) throw new Error(error.message);
37
+ return AlertRowSchema.parse(data);
45
38
  },
46
39
  staleTime: 1e3 * 60 * 5,
47
- // 5 minutes
48
40
  ...options
49
41
  });
50
42
  }
@@ -52,66 +44,40 @@ function useAlertDestinations({ userId }, options) {
52
44
  return useQuery({
53
45
  queryKey: alertKeys.destinations(userId),
54
46
  queryFn: async () => {
55
- const response = await api.get(`/users/${userId}/alert_destinations`);
56
- return AlertDestinationsSchema.parse(response.data);
47
+ const { data, error } = await supabase.from("alert_destinations").select("*").eq("user_id", userId).single();
48
+ if (error) throw new Error(error.message);
49
+ return AlertDestinationsSchema.parse(data);
57
50
  },
58
51
  staleTime: 1e3 * 60 * 10,
59
- // 10 minutes (destinations rarely change)
60
52
  ...options
61
53
  });
62
54
  }
63
55
  function useCreateAlert(options) {
64
56
  const queryClient = useQueryClient();
65
- const getEndpoint = (type) => {
66
- const mapping = {
67
- AccountThresholdAlert: "account_threshold_alerts",
68
- GoalAlert: "goal_alerts",
69
- MerchantNameAlert: "merchant_name_alerts",
70
- SpendingTargetAlert: "spending_target_alerts",
71
- TransactionLimitAlert: "transaction_limit_alerts",
72
- UpcomingBillAlert: "upcoming_bill_alerts"
73
- };
74
- return mapping[type];
75
- };
76
57
  return useMutation({
77
- mutationFn: async ({ userId, type, data }) => {
58
+ mutationFn: async ({ userId, data }) => {
78
59
  const validated = AlertCreateSchema.parse(data);
79
- const endpoint = getEndpoint(type);
80
- const response = await api.post(`/users/${userId}/${endpoint}`, {
81
- alert: validated
82
- });
83
- return AlertSchema.parse(response.data);
60
+ const { data: row, error } = await supabase.from("alerts").insert({ user_id: userId, ...validated }).select().single();
61
+ if (error) throw new Error(error.message);
62
+ return AlertRowSchema.parse(row);
84
63
  },
85
- onSuccess: (_, { userId }) => {
86
- queryClient.invalidateQueries({ queryKey: alertKeys.list(userId) });
64
+ onSuccess: () => {
65
+ queryClient.invalidateQueries({ queryKey: alertKeys.lists() });
87
66
  },
88
67
  ...options
89
68
  });
90
69
  }
91
70
  function useUpdateAlert(options) {
92
71
  const queryClient = useQueryClient();
93
- const getEndpoint = (type) => {
94
- const mapping = {
95
- AccountThresholdAlert: "account_threshold_alerts",
96
- GoalAlert: "goal_alerts",
97
- MerchantNameAlert: "merchant_name_alerts",
98
- SpendingTargetAlert: "spending_target_alerts",
99
- TransactionLimitAlert: "transaction_limit_alerts",
100
- UpcomingBillAlert: "upcoming_bill_alerts"
101
- };
102
- return mapping[type];
103
- };
104
72
  return useMutation({
105
- mutationFn: async ({ userId, alertId, type, data }) => {
73
+ mutationFn: async ({ userId, alertId, data }) => {
106
74
  const validated = AlertUpdateSchema.parse(data);
107
- const endpoint = getEndpoint(type);
108
- const response = await api.put(`/users/${userId}/${endpoint}/${alertId}`, {
109
- alert: validated
110
- });
111
- return AlertSchema.parse(response.data);
75
+ const { data: row, error } = await supabase.from("alerts").update(validated).eq("id", alertId).eq("user_id", userId).select().single();
76
+ if (error) throw new Error(error.message);
77
+ return AlertRowSchema.parse(row);
112
78
  },
113
79
  onSuccess: (_, { userId, alertId }) => {
114
- queryClient.invalidateQueries({ queryKey: alertKeys.list(userId) });
80
+ queryClient.invalidateQueries({ queryKey: alertKeys.lists() });
115
81
  queryClient.invalidateQueries({ queryKey: alertKeys.detail(userId, alertId) });
116
82
  },
117
83
  ...options
@@ -121,10 +87,11 @@ function useDeleteAlert(options) {
121
87
  const queryClient = useQueryClient();
122
88
  return useMutation({
123
89
  mutationFn: async ({ userId, alertId }) => {
124
- await api.delete(`/users/${userId}/alerts/${alertId}`);
90
+ const { error } = await supabase.from("alerts").delete().eq("id", alertId).eq("user_id", userId);
91
+ if (error) throw new Error(error.message);
125
92
  },
126
93
  onSuccess: (_, { userId, alertId }) => {
127
- queryClient.invalidateQueries({ queryKey: alertKeys.list(userId) });
94
+ queryClient.invalidateQueries({ queryKey: alertKeys.lists() });
128
95
  queryClient.removeQueries({ queryKey: alertKeys.detail(userId, alertId) });
129
96
  },
130
97
  ...options
@@ -135,10 +102,9 @@ function useUpdateAlertDestinations(options) {
135
102
  return useMutation({
136
103
  mutationFn: async ({ userId, data }) => {
137
104
  const validated = AlertDestinationsUpdateSchema.parse(data);
138
- const response = await api.put(`/users/${userId}/alert_destinations`, {
139
- destinations: validated
140
- });
141
- return AlertDestinationsSchema.parse(response.data);
105
+ const { data: row, error } = await supabase.from("alert_destinations").upsert({ user_id: userId, ...validated }).select().single();
106
+ if (error) throw new Error(error.message);
107
+ return AlertDestinationsSchema.parse(row);
142
108
  },
143
109
  onSuccess: (_, { userId }) => {
144
110
  queryClient.invalidateQueries({ queryKey: alertKeys.destinations(userId) });
@@ -147,6 +113,6 @@ function useUpdateAlertDestinations(options) {
147
113
  });
148
114
  }
149
115
 
150
- export { alertKeys, api, useAlert, useAlertDestinations, useAlerts, useCreateAlert, useDeleteAlert, useUpdateAlert, useUpdateAlertDestinations };
116
+ export { alertKeys, useAlert, useAlertDestinations, useAlerts, useCreateAlert, useDeleteAlert, useUpdateAlert, useUpdateAlertDestinations };
151
117
  //# sourceMappingURL=index.js.map
152
118
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts","../src/keys.ts","../src/queries/useAlerts.ts","../src/queries/useAlert.ts","../src/queries/useAlertDestinations.ts","../src/mutations/useCreateAlert.ts","../src/mutations/useUpdateAlert.ts","../src/mutations/useDeleteAlert.ts","../src/mutations/useUpdateAlertDestinations.ts"],"names":["useQuery","AlertSchema","useQueryClient","useMutation","AlertDestinationsSchema"],"mappings":";;;;;AAMO,IAAM,GAAA,GAAM,MAAM,MAAA,CAAO;AAAA,EAC9B,OAAA,EAAS,MAAA;AAAA,EACT,OAAA,EAAS;AAAA,IACP,cAAA,EAAgB;AAAA;AAEpB,CAAC;;;ACPM,IAAM,SAAA,GAAY;AAAA,EACvB,GAAA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AY;AAAA,IACjB,UAAA,EAAY,OAAO,EAAE,MAAA,EAAQ,MAAK,KAAqC;AACrE,MAAA,MAAM,SAAA,GAAY,6BAAA,CAA8B,KAAA,CAAM,IAAI,CAAA;AAC1D,MAAA,MAAM,WAAW,MAAM,GAAA,CAAI,GAAA,CAAI,CAAA,OAAA,EAAU,MAAM,CAAA,mBAAA,CAAA,EAAuB;AAAA,QACpE,YAAA,EAAc;AAAA,OACf,CAAA;AACD,MAAA,OAAOC,uBAAAA,CAAwB,KAAA,CAAM,QAAA,CAAS,IAAI,CAAA;AAAA,IACpD,CAAA;AAAA,IACA,SAAA,EAAW,CAAC,CAAA,EAAG,EAAE,QAAO,KAAM;AAC5B,MAAA,WAAA,CAAY,kBAAkB,EAAE,QAAA,EAAU,UAAU,YAAA,CAAa,MAAM,GAAG,CAAA;AAAA,IAC5E,CAAA;AAAA,IACA,GAAG;AAAA,GACJ,CAAA;AACH","file":"index.js","sourcesContent":["import axios from 'axios';\n\n/**\n * Axios instance for Alerts API\n * Base URL configured through environment variables or defaults to relative path\n */\nexport const api = axios.create({\n baseURL: '/api',\n headers: {\n 'Content-Type': 'application/json',\n },\n});\n","/**\n * Query key factory for Alerts domain\n */\n\nexport const alertKeys = {\n all: ['alerts'] as const,\n\n // Alert lists and details\n lists: () => [...alertKeys.all, 'list'] as const,\n list: (userId: string) => [...alertKeys.lists(), userId] as const,\n details: () => [...alertKeys.all, 'detail'] as const,\n detail: (userId: string, alertId: number) =>\n [...alertKeys.details(), userId, alertId] as const,\n\n // Alert destinations\n destinations: (userId: string) =>\n [...alertKeys.all, 'destinations', userId] as const,\n};\n","import { useQuery, UseQueryOptions } from '@tanstack/react-query';\nimport { Alert, AlertsResponseSchema } from '@pfm-platform/shared';\nimport { api } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UseAlertsParams {\n userId: string;\n}\n\n/**\n * Fetch all alerts for a user\n * GET /users/:userId/alerts\n */\nexport function useAlerts(\n { userId }: UseAlertsParams,\n options?: Omit<UseQueryOptions<Alert[]>, 'queryKey' | 'queryFn'>\n) {\n return useQuery({\n queryKey: alertKeys.list(userId),\n queryFn: async () => {\n const response = await api.get(`/users/${userId}/alerts`);\n const validated = AlertsResponseSchema.parse(response.data);\n return validated.alerts;\n },\n staleTime: 1000 * 60 * 5, // 5 minutes (alerts change moderately)\n ...options,\n });\n}\n","import { useQuery, UseQueryOptions } from '@tanstack/react-query';\nimport { Alert, AlertSchema } from '@pfm-platform/shared';\nimport { api } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UseAlertParams {\n userId: string;\n alertId: number;\n}\n\n/**\n * Fetch a single alert by ID\n * GET /users/:userId/alerts/:alertId\n */\nexport function useAlert(\n { userId, alertId }: UseAlertParams,\n options?: Omit<UseQueryOptions<Alert>, 'queryKey' | 'queryFn'>\n) {\n return useQuery({\n queryKey: alertKeys.detail(userId, alertId),\n queryFn: async () => {\n const response = await api.get(`/users/${userId}/alerts/${alertId}`);\n return AlertSchema.parse(response.data);\n },\n staleTime: 1000 * 60 * 5, // 5 minutes\n ...options,\n });\n}\n","import { useQuery, UseQueryOptions } from '@tanstack/react-query';\nimport { AlertDestinations, AlertDestinationsSchema } from '@pfm-platform/shared';\nimport { api } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UseAlertDestinationsParams {\n userId: string;\n}\n\n/**\n * Fetch alert destinations for a user\n * GET /users/:userId/alert_destinations\n */\nexport function useAlertDestinations(\n { userId }: UseAlertDestinationsParams,\n options?: Omit<UseQueryOptions<AlertDestinations>, 'queryKey' | 'queryFn'>\n) {\n return useQuery({\n queryKey: alertKeys.destinations(userId),\n queryFn: async () => {\n const response = await api.get(`/users/${userId}/alert_destinations`);\n return AlertDestinationsSchema.parse(response.data);\n },\n staleTime: 1000 * 60 * 10, // 10 minutes (destinations rarely change)\n ...options,\n });\n}\n","import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query';\nimport { Alert, AlertCreate, AlertCreateSchema, AlertSchema, AlertType } from '@pfm-platform/shared';\nimport { api } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface CreateAlertParams {\n userId: string;\n type: AlertType;\n data: AlertCreate;\n}\n\n/**\n * Create a new alert\n * POST /users/:userId/alerts/:type\n *\n * Type-based routing from legacy API routeMapping:\n * - AccountThresholdAlert → account_threshold_alerts\n * - GoalAlert → goal_alerts\n * - MerchantNameAlert → merchant_name_alerts\n * - SpendingTargetAlert → spending_target_alerts\n * - TransactionLimitAlert → transaction_limit_alerts\n * - UpcomingBillAlert → upcoming_bill_alerts\n */\nexport function useCreateAlert(\n options?: Omit<UseMutationOptions<Alert, Error, CreateAlertParams>, 'mutationFn'>\n) {\n const queryClient = useQueryClient();\n\n // Type to endpoint mapping\n const getEndpoint = (type: AlertType): string => {\n const mapping: Record<AlertType, string> = {\n AccountThresholdAlert: 'account_threshold_alerts',\n GoalAlert: 'goal_alerts',\n MerchantNameAlert: 'merchant_name_alerts',\n SpendingTargetAlert: 'spending_target_alerts',\n TransactionLimitAlert: 'transaction_limit_alerts',\n UpcomingBillAlert: 'upcoming_bill_alerts',\n };\n return mapping[type];\n };\n\n return useMutation({\n mutationFn: async ({ userId, type, data }: CreateAlertParams) => {\n const validated = AlertCreateSchema.parse(data);\n const endpoint = getEndpoint(type);\n const response = await api.post(`/users/${userId}/${endpoint}`, {\n alert: validated,\n });\n return AlertSchema.parse(response.data);\n },\n onSuccess: (_, { userId }) => {\n queryClient.invalidateQueries({ queryKey: alertKeys.list(userId) });\n },\n ...options,\n });\n}\n","import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query';\nimport { Alert, AlertUpdate, AlertUpdateSchema, AlertSchema, AlertType } from '@pfm-platform/shared';\nimport { api } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UpdateAlertParams {\n userId: string;\n alertId: number;\n type: AlertType;\n data: AlertUpdate;\n}\n\n/**\n * Update an existing alert\n * PUT /users/:userId/alerts/:type/:alertId\n *\n * Type-based routing - same mapping as create\n */\nexport function useUpdateAlert(\n options?: Omit<UseMutationOptions<Alert, Error, UpdateAlertParams>, 'mutationFn'>\n) {\n const queryClient = useQueryClient();\n\n // Type to endpoint mapping\n const getEndpoint = (type: AlertType): string => {\n const mapping: Record<AlertType, string> = {\n AccountThresholdAlert: 'account_threshold_alerts',\n GoalAlert: 'goal_alerts',\n MerchantNameAlert: 'merchant_name_alerts',\n SpendingTargetAlert: 'spending_target_alerts',\n TransactionLimitAlert: 'transaction_limit_alerts',\n UpcomingBillAlert: 'upcoming_bill_alerts',\n };\n return mapping[type];\n };\n\n return useMutation({\n mutationFn: async ({ userId, alertId, type, data }: UpdateAlertParams) => {\n const validated = AlertUpdateSchema.parse(data);\n const endpoint = getEndpoint(type);\n const response = await api.put(`/users/${userId}/${endpoint}/${alertId}`, {\n alert: validated,\n });\n return AlertSchema.parse(response.data);\n },\n onSuccess: (_, { userId, alertId }) => {\n queryClient.invalidateQueries({ queryKey: alertKeys.list(userId) });\n queryClient.invalidateQueries({ queryKey: alertKeys.detail(userId, alertId) });\n },\n ...options,\n });\n}\n","import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query';\nimport { api } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface DeleteAlertParams {\n userId: string;\n alertId: number;\n}\n\n/**\n * Delete an alert\n * DELETE /users/:userId/alerts/:alertId\n */\nexport function useDeleteAlert(\n options?: Omit<UseMutationOptions<void, Error, DeleteAlertParams>, 'mutationFn'>\n) {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ userId, alertId }: DeleteAlertParams) => {\n await api.delete(`/users/${userId}/alerts/${alertId}`);\n },\n onSuccess: (_, { userId, alertId }) => {\n queryClient.invalidateQueries({ queryKey: alertKeys.list(userId) });\n queryClient.removeQueries({ queryKey: alertKeys.detail(userId, alertId) });\n },\n ...options,\n });\n}\n","import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query';\nimport {\n AlertDestinations,\n AlertDestinationsUpdate,\n AlertDestinationsUpdateSchema,\n AlertDestinationsSchema,\n} from '@pfm-platform/shared';\nimport { api } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UpdateAlertDestinationsParams {\n userId: string;\n data: AlertDestinationsUpdate;\n}\n\n/**\n * Update alert destinations for a user\n * PUT /users/:userId/alert_destinations\n */\nexport function useUpdateAlertDestinations(\n options?: Omit<UseMutationOptions<AlertDestinations, Error, UpdateAlertDestinationsParams>, 'mutationFn'>\n) {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ userId, data }: UpdateAlertDestinationsParams) => {\n const validated = AlertDestinationsUpdateSchema.parse(data);\n const response = await api.put(`/users/${userId}/alert_destinations`, {\n destinations: validated,\n });\n return AlertDestinationsSchema.parse(response.data);\n },\n onSuccess: (_, { userId }) => {\n queryClient.invalidateQueries({ queryKey: alertKeys.destinations(userId) });\n },\n ...options,\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/keys.ts","../src/queries/useAlerts.ts","../src/queries/useAlert.ts","../src/queries/useAlertDestinations.ts","../src/mutations/useCreateAlert.ts","../src/mutations/useUpdateAlert.ts","../src/mutations/useDeleteAlert.ts","../src/mutations/useUpdateAlertDestinations.ts"],"names":["useQuery","AlertRowSchema","useQueryClient","useMutation","AlertDestinationsSchema"],"mappings":";;;;;;AAIO,IAAM,SAAA,GAAY;AAAA,EACvB,GAAA,EAAK,CAAC,QAAQ,CAAA;AAAA;AAAA,EAGd,OAAO,MAAM,CAAC,GAAG,SAAA,CAAU,KAAK,MAAM,CAAA;AAAA,EACtC,IAAA,EAAM,CAAC,MAAA,KAAmB,CAAC,GAAG,SAAA,CAAU,KAAA,IAAS,MAAM,CAAA;AAAA,EACvD,SAAS,MAAM,CAAC,GAAG,SAAA,CAAU,KAAK,QAAQ,CAAA;AAAA,EAC1C,MAAA,EAAQ,CAAC,MAAA,EAAgB,OAAA,KACvB,CAAC,GAAG,SAAA,CAAU,OAAA,EAAQ,EAAG,MAAA,EA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AAY,kBAAkB,EAAE,QAAA,EAAU,UAAU,YAAA,CAAa,MAAM,GAAG,CAAA;AAAA,IAC5E,CAAA;AAAA,IACA,GAAG;AAAA,GACJ,CAAA;AACH","file":"index.js","sourcesContent":["/**\n * Query key factory for Alerts domain\n */\n\nexport const alertKeys = {\n all: ['alerts'] as const,\n\n // Alert lists and details\n lists: () => [...alertKeys.all, 'list'] as const,\n list: (userId: string) => [...alertKeys.lists(), userId] as const,\n details: () => [...alertKeys.all, 'detail'] as const,\n detail: (userId: string, alertId: string) =>\n [...alertKeys.details(), userId, alertId] as const,\n\n // Alert destinations\n destinations: (userId: string) =>\n [...alertKeys.all, 'destinations', userId] as const,\n};\n","import { useQuery, type UseQueryOptions } from '@tanstack/react-query';\nimport { AlertsResponseSchema, type AlertRow } from '@pfm-platform/shared';\nimport { supabase } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UseAlertsParams {\n userId: string;\n}\n\n/**\n * Fetch all alerts for a user from Supabase\n */\nexport function useAlerts(\n { userId }: UseAlertsParams,\n options?: Omit<UseQueryOptions<AlertRow[]>, 'queryKey' | 'queryFn'>\n) {\n return useQuery({\n queryKey: alertKeys.list(userId),\n queryFn: async () => {\n const { data, error } = await supabase\n .from('alerts')\n .select('*')\n .eq('user_id', userId)\n .order('created_at');\n\n if (error) throw new Error(error.message);\n\n return AlertsResponseSchema.parse(data);\n },\n staleTime: 1000 * 60 * 5,\n ...options,\n });\n}\n","import { useQuery, type UseQueryOptions } from '@tanstack/react-query';\nimport { AlertRowSchema, type AlertRow } from '@pfm-platform/shared';\nimport { supabase } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UseAlertParams {\n userId: string;\n alertId: string;\n}\n\n/**\n * Fetch a single alert by ID from Supabase\n */\nexport function useAlert(\n { userId, alertId }: UseAlertParams,\n options?: Omit<UseQueryOptions<AlertRow>, 'queryKey' | 'queryFn'>\n) {\n return useQuery({\n queryKey: alertKeys.detail(userId, alertId),\n queryFn: async () => {\n const { data, error } = await supabase\n .from('alerts')\n .select('*')\n .eq('id', alertId)\n .eq('user_id', userId)\n .single();\n\n if (error) throw new Error(error.message);\n\n return AlertRowSchema.parse(data);\n },\n staleTime: 1000 * 60 * 5,\n ...options,\n });\n}\n","import { useQuery, type UseQueryOptions } from '@tanstack/react-query';\nimport { AlertDestinationsSchema, type AlertDestinations } from '@pfm-platform/shared';\nimport { supabase } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UseAlertDestinationsParams {\n userId: string;\n}\n\n/**\n * Fetch alert destinations for a user from Supabase\n * alert_destinations is a single-row-per-user table (user_id is PK)\n */\nexport function useAlertDestinations(\n { userId }: UseAlertDestinationsParams,\n options?: Omit<UseQueryOptions<AlertDestinations>, 'queryKey' | 'queryFn'>\n) {\n return useQuery({\n queryKey: alertKeys.destinations(userId),\n queryFn: async () => {\n const { data, error } = await supabase\n .from('alert_destinations')\n .select('*')\n .eq('user_id', userId)\n .single();\n\n if (error) throw new Error(error.message);\n\n return AlertDestinationsSchema.parse(data);\n },\n staleTime: 1000 * 60 * 10,\n ...options,\n });\n}\n","import {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n} from '@tanstack/react-query';\nimport {\n AlertCreateSchema,\n AlertRowSchema,\n type AlertCreate,\n type AlertRow,\n type TablesInsert,\n} from '@pfm-platform/shared';\nimport { supabase } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface CreateAlertParams {\n userId: string;\n data: AlertCreate;\n}\n\n/**\n * Create a new alert in Supabase\n * Single table — no type-based routing needed\n */\nexport function useCreateAlert(\n options?: Omit<UseMutationOptions<AlertRow, Error, CreateAlertParams>, 'mutationFn'>\n) {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ userId, data }: CreateAlertParams) => {\n const validated = AlertCreateSchema.parse(data);\n\n const { data: row, error } = await supabase\n .from('alerts')\n .insert({ user_id: userId, ...validated } as TablesInsert<'alerts'>)\n .select()\n .single();\n\n if (error) throw new Error(error.message);\n\n return AlertRowSchema.parse(row);\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: alertKeys.lists() });\n },\n ...options,\n });\n}\n","import {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n} from '@tanstack/react-query';\nimport {\n AlertUpdateSchema,\n AlertRowSchema,\n type AlertUpdate,\n type AlertRow,\n type TablesUpdate,\n} from '@pfm-platform/shared';\nimport { supabase } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UpdateAlertParams {\n userId: string;\n alertId: string;\n data: AlertUpdate;\n}\n\n/**\n * Update an existing alert in Supabase\n */\nexport function useUpdateAlert(\n options?: Omit<UseMutationOptions<AlertRow, Error, UpdateAlertParams>, 'mutationFn'>\n) {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ userId, alertId, data }: UpdateAlertParams) => {\n const validated = AlertUpdateSchema.parse(data);\n\n const { data: row, error } = await supabase\n .from('alerts')\n .update(validated as TablesUpdate<'alerts'>)\n .eq('id', alertId)\n .eq('user_id', userId)\n .select()\n .single();\n\n if (error) throw new Error(error.message);\n\n return AlertRowSchema.parse(row);\n },\n onSuccess: (_, { userId, alertId }) => {\n queryClient.invalidateQueries({ queryKey: alertKeys.lists() });\n queryClient.invalidateQueries({ queryKey: alertKeys.detail(userId, alertId) });\n },\n ...options,\n });\n}\n","import {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n} from '@tanstack/react-query';\nimport { supabase } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface DeleteAlertParams {\n userId: string;\n alertId: string;\n}\n\n/**\n * Delete an alert from Supabase\n */\nexport function useDeleteAlert(\n options?: Omit<UseMutationOptions<void, Error, DeleteAlertParams>, 'mutationFn'>\n) {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ userId, alertId }: DeleteAlertParams) => {\n const { error } = await supabase\n .from('alerts')\n .delete()\n .eq('id', alertId)\n .eq('user_id', userId);\n\n if (error) throw new Error(error.message);\n },\n onSuccess: (_, { userId, alertId }) => {\n queryClient.invalidateQueries({ queryKey: alertKeys.lists() });\n queryClient.removeQueries({ queryKey: alertKeys.detail(userId, alertId) });\n },\n ...options,\n });\n}\n","import {\n useMutation,\n useQueryClient,\n type UseMutationOptions,\n} from '@tanstack/react-query';\nimport {\n AlertDestinationsUpdateSchema,\n AlertDestinationsSchema,\n type AlertDestinations,\n type AlertDestinationsUpdate,\n} from '@pfm-platform/shared';\nimport { supabase } from '../client.js';\nimport { alertKeys } from '../keys.js';\n\nexport interface UpdateAlertDestinationsParams {\n userId: string;\n data: AlertDestinationsUpdate;\n}\n\n/**\n * Update alert destinations for a user in Supabase\n * Uses upsert since alert_destinations is a single-row-per-user table\n */\nexport function useUpdateAlertDestinations(\n options?: Omit<UseMutationOptions<AlertDestinations, Error, UpdateAlertDestinationsParams>, 'mutationFn'>\n) {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ userId, data }: UpdateAlertDestinationsParams) => {\n const validated = AlertDestinationsUpdateSchema.parse(data);\n\n const { data: row, error } = await supabase\n .from('alert_destinations')\n .upsert({ user_id: userId, ...validated })\n .select()\n .single();\n\n if (error) throw new Error(error.message);\n\n return AlertDestinationsSchema.parse(row);\n },\n onSuccess: (_, { userId }) => {\n queryClient.invalidateQueries({ queryKey: alertKeys.destinations(userId) });\n },\n ...options,\n });\n}\n"]}
package/package.json CHANGED
@@ -1,22 +1,21 @@
1
1
  {
2
2
  "name": "@pfm-platform/alerts-data-access",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "dependencies": {
8
- "axios": "^1.13.2",
9
8
  "zod": "4.1.12",
10
- "@pfm-platform/shared": "0.0.1"
9
+ "@pfm-platform/shared": "0.2.1"
11
10
  },
12
11
  "devDependencies": {
13
- "@testing-library/react": "^16.3.0",
14
- "@vitejs/plugin-react": "^5.1.1",
15
- "@vitest/coverage-v8": "^4.0.9",
12
+ "@testing-library/react": "^16.3.2",
13
+ "@vitejs/plugin-react": "^5.1.4",
14
+ "@vitest/coverage-v8": "^4.0.18",
16
15
  "jsdom": "^27.2.0",
17
- "react-dom": "19.2.0",
16
+ "react-dom": "19.2.4",
18
17
  "typescript": "5.9.3",
19
- "vitest": "4.0.9"
18
+ "vitest": "4.0.18"
20
19
  },
21
20
  "module": "./dist/index.js",
22
21
  "exports": {