@elevasis/ui 1.25.0 → 1.26.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.
@@ -1,9 +1,7 @@
1
- import { CredentialNameSchema, UuidSchema, useErrorNotification, showApiErrorNotification, showSuccessNotification } from './chunk-QDO6NF2I.js';
2
- import { useSupabase } from './chunk-NJJ3NQ7B.js';
1
+ import { CredentialNameSchema, UuidSchema, useErrorNotification, showApiErrorNotification } from './chunk-ZVJKIJFG.js';
3
2
  import { getTimeRangeDates } from './chunk-LXHZYSMQ.js';
4
3
  import { useNotificationAdapter } from './chunk-R7WLWGPO.js';
5
4
  import { GC_TIME_SHORT, STALE_TIME_MONITORING, GC_TIME_MEDIUM, STALE_TIME_DEFAULT } from './chunk-IOKL7BKE.js';
6
- import { useOrganization } from './chunk-DD3CCMCZ.js';
7
5
  import { useElevasisServices } from './chunk-QEPXAWE2.js';
8
6
  import { z } from 'zod';
9
7
  import { create } from 'zustand';
@@ -62,11 +60,6 @@ var ListMembershipsQuerySchema = z.object({
62
60
  message: "Either userId or organizationId must be provided"
63
61
  }
64
62
  );
65
-
66
- // ../core/src/supabase/helpers.ts
67
- function sanitizePostgrestValue(value) {
68
- return value.replace(/[,()]/g, "");
69
- }
70
63
  var CredentialTypeSchema = z.enum(["oauth", "api-key", "webhook-secret", "api-key-secret"]);
71
64
  var CredentialValueSchema = z.record(z.string(), z.unknown()).refine((val) => Object.keys(val).length > 0, { message: "Credential value must not be empty" }).refine((val) => Object.keys(val).length <= 50, { message: "Credential value has too many keys (max 50)" }).refine(
72
65
  (val) => {
@@ -1047,323 +1040,6 @@ function useUpdateWebhookEndpoint() {
1047
1040
  }
1048
1041
  });
1049
1042
  }
1050
- var dealKeys = {
1051
- all: ["acq-deals"],
1052
- lists: () => [...dealKeys.all, "list"],
1053
- list: (orgId, filters) => [...dealKeys.all, "list", orgId, filters],
1054
- details: () => [...dealKeys.all, "detail"],
1055
- detail: (id) => [...dealKeys.all, "detail", id]
1056
- };
1057
- function useDeals(filters = {}) {
1058
- const supabase = useSupabase();
1059
- const { currentSupabaseOrganizationId: organizationId, isInitializing, isOrgRefreshing } = useOrganization();
1060
- const isReady = !!organizationId && !isInitializing && !isOrgRefreshing;
1061
- return useQuery({
1062
- queryKey: dealKeys.list(organizationId, filters),
1063
- queryFn: async () => {
1064
- if (!organizationId) return [];
1065
- let query = supabase.from("acq_deals").select(
1066
- `
1067
- *,
1068
- contact:acq_contacts(
1069
- id,
1070
- first_name,
1071
- last_name,
1072
- email,
1073
- title,
1074
- company:acq_companies(
1075
- id,
1076
- name,
1077
- domain
1078
- )
1079
- )
1080
- `
1081
- ).eq("organization_id", organizationId);
1082
- if (filters.stage) {
1083
- query = query.eq("cached_stage", filters.stage);
1084
- }
1085
- if (filters.search) {
1086
- query = query.ilike("contact_email", `%${filters.search}%`);
1087
- }
1088
- query = query.order("updated_at", { ascending: false });
1089
- const { data, error } = await query;
1090
- if (error) throw error;
1091
- return data || [];
1092
- },
1093
- enabled: isReady
1094
- });
1095
- }
1096
- function useDeleteDeal() {
1097
- const { apiRequest } = useElevasisServices();
1098
- const queryClient = useQueryClient();
1099
- return useMutation({
1100
- mutationFn: async (dealId) => {
1101
- await apiRequest(`/deals/${dealId}`, { method: "DELETE" });
1102
- },
1103
- onSuccess: () => {
1104
- queryClient.invalidateQueries({ queryKey: dealKeys.all });
1105
- },
1106
- onError: (error) => {
1107
- showApiErrorNotification(error);
1108
- }
1109
- });
1110
- }
1111
- function useSyncDealStage() {
1112
- const supabase = useSupabase();
1113
- const queryClient = useQueryClient();
1114
- const { currentSupabaseOrganizationId: organizationId } = useOrganization();
1115
- return useMutation({
1116
- mutationFn: async ({ dealId, stage }) => {
1117
- if (!organizationId) throw new Error("No organization context");
1118
- const { error } = await supabase.from("acq_deals").update({ cached_stage: stage }).eq("id", dealId).eq("organization_id", organizationId);
1119
- if (error) throw error;
1120
- },
1121
- onError: (error) => {
1122
- queryClient.invalidateQueries({ queryKey: dealKeys.all });
1123
- showApiErrorNotification(error);
1124
- }
1125
- });
1126
- }
1127
- var dealNoteKeys = {
1128
- all: ["dealNotes"],
1129
- list: (organizationId, dealId) => ["dealNotes", organizationId, dealId]
1130
- };
1131
- function useDealNotes(dealId) {
1132
- const supabase = useSupabase();
1133
- const { currentSupabaseOrganizationId: organizationId, isInitializing, isOrgRefreshing } = useOrganization();
1134
- const isReady = !!organizationId && !isInitializing && !isOrgRefreshing;
1135
- return useQuery({
1136
- queryKey: dealNoteKeys.list(organizationId, dealId),
1137
- queryFn: async () => {
1138
- if (!organizationId || !dealId) return [];
1139
- const { data, error } = await supabase.from("acq_deal_notes").select("*").eq("deal_id", dealId).eq("organization_id", organizationId).order("created_at", { ascending: false });
1140
- if (error) throw error;
1141
- return (data || []).map((row) => ({
1142
- id: row.id,
1143
- dealId: row.deal_id,
1144
- organizationId: row.organization_id,
1145
- authorUserId: row.author_user_id,
1146
- body: row.body,
1147
- createdAt: row.created_at,
1148
- updatedAt: row.updated_at
1149
- }));
1150
- },
1151
- enabled: isReady && !!dealId
1152
- });
1153
- }
1154
- function useCreateDealNote() {
1155
- const supabase = useSupabase();
1156
- const queryClient = useQueryClient();
1157
- const { currentSupabaseOrganizationId: organizationId } = useOrganization();
1158
- return useMutation({
1159
- mutationFn: async ({ dealId, body, authorUserId }) => {
1160
- if (!organizationId) throw new Error("No organization context");
1161
- const { data, error } = await supabase.from("acq_deal_notes").insert({
1162
- deal_id: dealId,
1163
- organization_id: organizationId,
1164
- body,
1165
- author_user_id: authorUserId ?? null
1166
- }).select().single();
1167
- if (error) throw error;
1168
- return {
1169
- id: data.id,
1170
- dealId: data.deal_id,
1171
- organizationId: data.organization_id,
1172
- authorUserId: data.author_user_id,
1173
- body: data.body,
1174
- createdAt: data.created_at,
1175
- updatedAt: data.updated_at
1176
- };
1177
- },
1178
- onSuccess: (_, variables) => {
1179
- queryClient.invalidateQueries({ queryKey: dealNoteKeys.list(organizationId, variables.dealId) });
1180
- showSuccessNotification("Note added");
1181
- },
1182
- onError: (error) => {
1183
- showApiErrorNotification(error);
1184
- }
1185
- });
1186
- }
1187
- var dealTaskKeys = {
1188
- all: ["deal-tasks"],
1189
- list: (orgId, dealId) => ["deal-tasks", orgId, dealId],
1190
- due: (orgId, window, assigneeUserId) => ["deal-tasks-due", orgId, window, assigneeUserId]
1191
- };
1192
- function transformTaskRow(row) {
1193
- return {
1194
- id: row.id,
1195
- organizationId: row.organization_id,
1196
- dealId: row.deal_id,
1197
- title: row.title,
1198
- description: row.description,
1199
- kind: row.kind,
1200
- dueAt: row.due_at,
1201
- assigneeUserId: row.assignee_user_id,
1202
- completedAt: row.completed_at,
1203
- completedByUserId: row.completed_by_user_id,
1204
- createdAt: row.created_at,
1205
- updatedAt: row.updated_at,
1206
- createdByUserId: row.created_by_user_id
1207
- };
1208
- }
1209
- function useDealTasks(dealId) {
1210
- const supabase = useSupabase();
1211
- const { currentSupabaseOrganizationId: organizationId, isInitializing, isOrgRefreshing } = useOrganization();
1212
- const isReady = !!organizationId && !isInitializing && !isOrgRefreshing;
1213
- return useQuery({
1214
- queryKey: dealTaskKeys.list(organizationId, dealId ?? ""),
1215
- queryFn: async () => {
1216
- if (!organizationId || !dealId) return [];
1217
- const { data, error } = await supabase.from("acq_deal_tasks").select("*").eq("deal_id", dealId).eq("organization_id", organizationId).order("due_at", { ascending: true, nullsFirst: false });
1218
- if (error) throw error;
1219
- return (data || []).map(transformTaskRow);
1220
- },
1221
- enabled: isReady && !!dealId
1222
- });
1223
- }
1224
- function useDealTasksDue(opts) {
1225
- const supabase = useSupabase();
1226
- const { currentSupabaseOrganizationId: organizationId, isInitializing, isOrgRefreshing } = useOrganization();
1227
- const isReady = !!organizationId && !isInitializing && !isOrgRefreshing;
1228
- const window = opts?.window ?? "today_and_overdue";
1229
- const assigneeUserId = opts?.assigneeUserId ?? null;
1230
- return useQuery({
1231
- queryKey: dealTaskKeys.due(organizationId, window, assigneeUserId),
1232
- queryFn: async () => {
1233
- if (!organizationId) return [];
1234
- const now = /* @__PURE__ */ new Date();
1235
- const todayStart = new Date(now.getFullYear(), now.getMonth(), now.getDate()).toISOString();
1236
- const todayEnd = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1).toISOString();
1237
- let query = supabase.from("acq_deal_tasks").select("*").eq("organization_id", organizationId).is("completed_at", null);
1238
- if (window === "overdue") {
1239
- query = query.lt("due_at", todayStart);
1240
- } else if (window === "today") {
1241
- query = query.gte("due_at", todayStart).lt("due_at", todayEnd);
1242
- } else if (window === "today_and_overdue") {
1243
- query = query.lt("due_at", todayEnd);
1244
- } else if (window === "upcoming") {
1245
- query = query.gte("due_at", todayEnd);
1246
- }
1247
- if (assigneeUserId !== null) {
1248
- query = query.eq("assignee_user_id", assigneeUserId);
1249
- }
1250
- query = query.order("due_at", { ascending: true, nullsFirst: false });
1251
- const { data, error } = await query;
1252
- if (error) throw error;
1253
- return (data || []).map(transformTaskRow);
1254
- },
1255
- enabled: isReady
1256
- });
1257
- }
1258
- function useCreateDealTask() {
1259
- const supabase = useSupabase();
1260
- const { currentSupabaseOrganizationId: organizationId } = useOrganization();
1261
- const queryClient = useQueryClient();
1262
- return useMutation({
1263
- mutationFn: async (params) => {
1264
- if (!organizationId) throw new Error("No organization context");
1265
- const { data, error } = await supabase.from("acq_deal_tasks").insert({
1266
- deal_id: params.dealId,
1267
- organization_id: organizationId,
1268
- title: params.title,
1269
- description: params.description ?? null,
1270
- kind: params.kind ?? "other",
1271
- due_at: params.dueAt ?? null,
1272
- assignee_user_id: params.assigneeUserId ?? null,
1273
- created_by_user_id: params.createdByUserId ?? null
1274
- }).select().single();
1275
- if (error) throw error;
1276
- return transformTaskRow(data);
1277
- },
1278
- onSuccess: (_, variables) => {
1279
- queryClient.invalidateQueries({ queryKey: dealTaskKeys.list(organizationId, variables.dealId) });
1280
- queryClient.invalidateQueries({
1281
- predicate: (query) => query.queryKey[0] === "deal-tasks-due"
1282
- });
1283
- showSuccessNotification("Task created");
1284
- },
1285
- onError: (error) => {
1286
- showApiErrorNotification(error);
1287
- }
1288
- });
1289
- }
1290
- function useCompleteDealTask() {
1291
- const supabase = useSupabase();
1292
- const { currentSupabaseOrganizationId: organizationId } = useOrganization();
1293
- const queryClient = useQueryClient();
1294
- return useMutation({
1295
- mutationFn: async ({ taskId, completedByUserId }) => {
1296
- if (!organizationId) throw new Error("No organization context");
1297
- const { data, error } = await supabase.from("acq_deal_tasks").update({
1298
- completed_at: (/* @__PURE__ */ new Date()).toISOString(),
1299
- completed_by_user_id: completedByUserId ?? null
1300
- }).eq("id", taskId).eq("organization_id", organizationId).select().single();
1301
- if (error) throw error;
1302
- return transformTaskRow(data);
1303
- },
1304
- onSuccess: (_, variables) => {
1305
- queryClient.invalidateQueries({ queryKey: dealTaskKeys.list(organizationId, variables.dealId) });
1306
- queryClient.invalidateQueries({
1307
- predicate: (query) => query.queryKey[0] === "deal-tasks-due"
1308
- });
1309
- showSuccessNotification("Task completed");
1310
- },
1311
- onError: (error) => {
1312
- showApiErrorNotification(error);
1313
- }
1314
- });
1315
- }
1316
- function useDealDetail(acqDealId) {
1317
- const supabase = useSupabase();
1318
- const { currentSupabaseOrganizationId: organizationId, isInitializing, isOrgRefreshing } = useOrganization();
1319
- const isReady = !!organizationId && !isInitializing && !isOrgRefreshing;
1320
- return useQuery({
1321
- queryKey: [...dealKeys.detail(acqDealId), organizationId],
1322
- queryFn: async () => {
1323
- if (!organizationId || !acqDealId) return null;
1324
- const { data, error } = await supabase.from("acq_deals").select(
1325
- `
1326
- *,
1327
- contact:acq_contacts(
1328
- id,
1329
- first_name,
1330
- last_name,
1331
- email,
1332
- title,
1333
- headline,
1334
- linkedin_url,
1335
- pipeline_status,
1336
- enrichment_data,
1337
- company:acq_companies(
1338
- id,
1339
- name,
1340
- domain,
1341
- website,
1342
- linkedin_url,
1343
- segment,
1344
- category,
1345
- num_employees
1346
- )
1347
- )
1348
- `
1349
- ).eq("id", acqDealId).eq("organization_id", organizationId).single();
1350
- if (error) {
1351
- if (error.code === "PGRST116") return null;
1352
- throw error;
1353
- }
1354
- return data;
1355
- },
1356
- enabled: isReady && !!acqDealId
1357
- });
1358
- }
1359
- function useBatchTelemetry() {
1360
- const { apiRequest, isReady, organizationId } = useElevasisServices();
1361
- return useQuery({
1362
- queryKey: ["acq-batch-telemetry", organizationId],
1363
- queryFn: () => apiRequest("/acquisition/batches/telemetry"),
1364
- enabled: isReady
1365
- });
1366
- }
1367
1043
  var projectKeys = {
1368
1044
  all: ["projects"],
1369
1045
  lists: () => [...projectKeys.all, "list"],
@@ -1372,109 +1048,48 @@ var projectKeys = {
1372
1048
  detail: (id) => [...projectKeys.all, "detail", id]
1373
1049
  };
1374
1050
  function useProjects(filters = {}) {
1375
- const supabase = useSupabase();
1376
- const { currentSupabaseOrganizationId, isInitializing, isOrgRefreshing } = useOrganization();
1377
- const isReady = !!currentSupabaseOrganizationId && !isInitializing && !isOrgRefreshing;
1051
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
1378
1052
  return useQuery({
1379
- queryKey: projectKeys.list(currentSupabaseOrganizationId, filters),
1053
+ queryKey: projectKeys.list(organizationId, filters),
1380
1054
  queryFn: async () => {
1381
- if (!currentSupabaseOrganizationId) {
1382
- return [];
1383
- }
1384
- let query = supabase.from("prj_projects").select("*").eq("organization_id", currentSupabaseOrganizationId);
1385
- if (filters.status) {
1386
- query = query.eq("status", filters.status);
1387
- }
1388
- if (filters.kind) {
1389
- query = query.eq("kind", filters.kind);
1390
- }
1391
- if (filters.companyId) {
1392
- query = query.eq("company_id", filters.companyId);
1393
- }
1394
- if (filters.search) {
1395
- const search = sanitizePostgrestValue(filters.search);
1396
- query = query.ilike("name", `%${search}%`);
1397
- }
1398
- query = query.order("created_at", { ascending: false });
1399
- const { data: projects, error: projectsError } = await query;
1400
- if (projectsError) throw projectsError;
1401
- const { data: milestones, error: milestonesError } = await supabase.from("prj_milestones").select("project_id, status").eq("organization_id", currentSupabaseOrganizationId);
1402
- if (milestonesError) throw milestonesError;
1403
- const { data: tasks, error: tasksError } = await supabase.from("prj_tasks").select("project_id, status").eq("organization_id", currentSupabaseOrganizationId);
1404
- if (tasksError) throw tasksError;
1405
- const milestoneCountMap = /* @__PURE__ */ new Map();
1406
- const completedMilestoneCountMap = /* @__PURE__ */ new Map();
1407
- for (const milestone of milestones || []) {
1408
- milestoneCountMap.set(milestone.project_id, (milestoneCountMap.get(milestone.project_id) || 0) + 1);
1409
- if (milestone.status === "completed") {
1410
- completedMilestoneCountMap.set(
1411
- milestone.project_id,
1412
- (completedMilestoneCountMap.get(milestone.project_id) || 0) + 1
1413
- );
1414
- }
1415
- }
1416
- const taskCountMap = /* @__PURE__ */ new Map();
1417
- const completedTaskCountMap = /* @__PURE__ */ new Map();
1418
- for (const task of tasks || []) {
1419
- taskCountMap.set(task.project_id, (taskCountMap.get(task.project_id) || 0) + 1);
1420
- if (task.status === "approved") {
1421
- completedTaskCountMap.set(task.project_id, (completedTaskCountMap.get(task.project_id) || 0) + 1);
1422
- }
1423
- }
1424
- return (projects || []).map((project) => ({
1425
- ...project,
1426
- milestoneCount: milestoneCountMap.get(project.id) || 0,
1427
- taskCount: taskCountMap.get(project.id) || 0,
1428
- completedMilestones: completedMilestoneCountMap.get(project.id) || 0,
1429
- completedTasks: completedTaskCountMap.get(project.id) || 0
1430
- }));
1055
+ const params = new URLSearchParams();
1056
+ if (filters.kind) params.set("kind", filters.kind);
1057
+ const qs = params.toString();
1058
+ const path = qs ? `/projects?${qs}` : "/projects";
1059
+ const res = await apiRequest(path);
1060
+ return res.projects;
1431
1061
  },
1432
1062
  enabled: isReady
1433
1063
  });
1434
1064
  }
1435
1065
  function useProject(id) {
1436
- const supabase = useSupabase();
1437
- const { currentSupabaseOrganizationId, isInitializing, isOrgRefreshing } = useOrganization();
1438
- const isReady = !!currentSupabaseOrganizationId && !isInitializing && !isOrgRefreshing;
1066
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
1439
1067
  return useQuery({
1440
- queryKey: [...projectKeys.detail(id), currentSupabaseOrganizationId],
1068
+ queryKey: [...projectKeys.detail(id), organizationId],
1441
1069
  queryFn: async () => {
1442
- if (!currentSupabaseOrganizationId || !id) {
1443
- return null;
1444
- }
1445
- const { data, error } = await supabase.from("prj_projects").select(
1446
- `
1447
- *,
1448
- milestones:prj_milestones(*),
1449
- tasks:prj_tasks(*),
1450
- company:acq_companies(id, name, domain)
1451
- `
1452
- ).eq("id", id).eq("organization_id", currentSupabaseOrganizationId).order("sequence", { ascending: true, referencedTable: "prj_milestones" }).order("created_at", { ascending: false, referencedTable: "prj_tasks" }).single();
1453
- if (error) {
1454
- if (error.code === "PGRST116") return null;
1455
- throw error;
1070
+ try {
1071
+ const res = await apiRequest(`/projects/${id}`);
1072
+ return res.project;
1073
+ } catch (err) {
1074
+ if (err && typeof err === "object" && "statusCode" in err && err.statusCode === 404) {
1075
+ return null;
1076
+ }
1077
+ throw err;
1456
1078
  }
1457
- return data;
1458
1079
  },
1459
1080
  enabled: isReady && !!id
1460
1081
  });
1461
1082
  }
1462
1083
  function useCreateProject() {
1463
- const supabase = useSupabase();
1084
+ const { apiRequest } = useElevasisServices();
1464
1085
  const queryClient = useQueryClient();
1465
- const { currentSupabaseOrganizationId } = useOrganization();
1466
1086
  return useMutation({
1467
1087
  mutationFn: async (params) => {
1468
- if (!currentSupabaseOrganizationId) {
1469
- throw new Error("No organization selected");
1470
- }
1471
- const insert = {
1472
- ...params,
1473
- organization_id: currentSupabaseOrganizationId
1474
- };
1475
- const { data, error } = await supabase.from("prj_projects").insert(insert).select().single();
1476
- if (error) throw error;
1477
- return data;
1088
+ const res = await apiRequest("/projects", {
1089
+ method: "POST",
1090
+ body: JSON.stringify(params)
1091
+ });
1092
+ return res.project;
1478
1093
  },
1479
1094
  onSuccess: () => {
1480
1095
  queryClient.invalidateQueries({ queryKey: projectKeys.all });
@@ -1485,13 +1100,15 @@ function useCreateProject() {
1485
1100
  });
1486
1101
  }
1487
1102
  function useUpdateProject() {
1488
- const supabase = useSupabase();
1103
+ const { apiRequest } = useElevasisServices();
1489
1104
  const queryClient = useQueryClient();
1490
1105
  return useMutation({
1491
1106
  mutationFn: async (params) => {
1492
- const { data, error } = await supabase.from("prj_projects").update(params.updates).eq("id", params.id).select().single();
1493
- if (error) throw error;
1494
- return data;
1107
+ const res = await apiRequest(`/projects/${params.id}`, {
1108
+ method: "PATCH",
1109
+ body: JSON.stringify(params.updates)
1110
+ });
1111
+ return res.project;
1495
1112
  },
1496
1113
  onSuccess: (data) => {
1497
1114
  queryClient.invalidateQueries({ queryKey: projectKeys.all });
@@ -1503,12 +1120,13 @@ function useUpdateProject() {
1503
1120
  });
1504
1121
  }
1505
1122
  function useDeleteProject() {
1506
- const supabase = useSupabase();
1123
+ const { apiRequest } = useElevasisServices();
1507
1124
  const queryClient = useQueryClient();
1508
1125
  return useMutation({
1509
1126
  mutationFn: async (id) => {
1510
- const { error } = await supabase.from("prj_projects").delete().eq("id", id);
1511
- if (error) throw error;
1127
+ await apiRequest(`/projects/${id}`, {
1128
+ method: "DELETE"
1129
+ });
1512
1130
  },
1513
1131
  onSuccess: () => {
1514
1132
  queryClient.invalidateQueries({ queryKey: projectKeys.all });
@@ -1526,46 +1144,28 @@ var milestoneKeys = {
1526
1144
  detail: (id) => [...milestoneKeys.all, "detail", id]
1527
1145
  };
1528
1146
  function useMilestones(filters = {}) {
1529
- const supabase = useSupabase();
1530
- const { currentSupabaseOrganizationId, isInitializing, isOrgRefreshing } = useOrganization();
1531
- const isReady = !!currentSupabaseOrganizationId && !isInitializing && !isOrgRefreshing;
1147
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
1532
1148
  return useQuery({
1533
- queryKey: milestoneKeys.list(currentSupabaseOrganizationId, filters),
1149
+ queryKey: milestoneKeys.list(organizationId, filters),
1534
1150
  queryFn: async () => {
1535
- if (!currentSupabaseOrganizationId) {
1536
- return [];
1537
- }
1538
- let query = supabase.from("prj_milestones").select("*").eq("organization_id", currentSupabaseOrganizationId);
1539
- if (filters.projectId) {
1540
- query = query.eq("project_id", filters.projectId);
1541
- }
1542
- if (filters.status) {
1543
- query = query.eq("status", filters.status);
1544
- }
1545
- query = query.order("sequence", { ascending: true });
1546
- const { data, error } = await query;
1547
- if (error) throw error;
1548
- return data || [];
1151
+ const res = await apiRequest(`/projects/${filters.projectId}/milestones`);
1152
+ return res.milestones;
1549
1153
  },
1550
- enabled: isReady
1154
+ enabled: isReady && !!filters.projectId
1551
1155
  });
1552
1156
  }
1553
1157
  function useCreateMilestone() {
1554
- const supabase = useSupabase();
1158
+ const { apiRequest } = useElevasisServices();
1555
1159
  const queryClient = useQueryClient();
1556
- const { currentSupabaseOrganizationId } = useOrganization();
1557
1160
  return useMutation({
1558
1161
  mutationFn: async (params) => {
1559
- if (!currentSupabaseOrganizationId) {
1560
- throw new Error("No organization selected");
1561
- }
1562
- const insert = {
1563
- ...params,
1564
- organization_id: currentSupabaseOrganizationId
1565
- };
1566
- const { data, error } = await supabase.from("prj_milestones").insert(insert).select().single();
1567
- if (error) throw error;
1568
- return data;
1162
+ const { project_id, ...body } = params;
1163
+ if (!project_id) throw new Error("project_id is required to create a milestone");
1164
+ const res = await apiRequest(`/projects/${project_id}/milestones`, {
1165
+ method: "POST",
1166
+ body: JSON.stringify(body)
1167
+ });
1168
+ return res.milestone;
1569
1169
  },
1570
1170
  onSuccess: (data) => {
1571
1171
  queryClient.invalidateQueries({ queryKey: milestoneKeys.all });
@@ -1578,13 +1178,15 @@ function useCreateMilestone() {
1578
1178
  });
1579
1179
  }
1580
1180
  function useUpdateMilestone() {
1581
- const supabase = useSupabase();
1181
+ const { apiRequest } = useElevasisServices();
1582
1182
  const queryClient = useQueryClient();
1583
1183
  return useMutation({
1584
1184
  mutationFn: async (params) => {
1585
- const { data, error } = await supabase.from("prj_milestones").update(params.updates).eq("id", params.id).select().single();
1586
- if (error) throw error;
1587
- return data;
1185
+ const res = await apiRequest(`/milestones/${params.id}`, {
1186
+ method: "PATCH",
1187
+ body: JSON.stringify(params.updates)
1188
+ });
1189
+ return res.milestone;
1588
1190
  },
1589
1191
  onSuccess: (data) => {
1590
1192
  queryClient.invalidateQueries({ queryKey: milestoneKeys.all });
@@ -1597,12 +1199,13 @@ function useUpdateMilestone() {
1597
1199
  });
1598
1200
  }
1599
1201
  function useDeleteMilestone() {
1600
- const supabase = useSupabase();
1202
+ const { apiRequest } = useElevasisServices();
1601
1203
  const queryClient = useQueryClient();
1602
1204
  return useMutation({
1603
1205
  mutationFn: async (params) => {
1604
- const { error } = await supabase.from("prj_milestones").delete().eq("id", params.id);
1605
- if (error) throw error;
1206
+ await apiRequest(`/milestones/${params.id}`, {
1207
+ method: "DELETE"
1208
+ });
1606
1209
  },
1607
1210
  onSuccess: (_, params) => {
1608
1211
  queryClient.invalidateQueries({ queryKey: milestoneKeys.all });
@@ -1622,43 +1225,30 @@ var taskKeys = {
1622
1225
  detail: (id) => [...taskKeys.all, "detail", id]
1623
1226
  };
1624
1227
  function useTasks(filters = {}) {
1625
- const supabase = useSupabase();
1626
- const { currentSupabaseOrganizationId, isInitializing, isOrgRefreshing } = useOrganization();
1627
- const isReady = !!currentSupabaseOrganizationId && !isInitializing && !isOrgRefreshing;
1228
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
1628
1229
  return useQuery({
1629
- queryKey: taskKeys.list(currentSupabaseOrganizationId, filters),
1230
+ queryKey: taskKeys.list(organizationId, filters),
1630
1231
  queryFn: async () => {
1631
- if (!currentSupabaseOrganizationId) {
1632
- return [];
1633
- }
1634
- let query = supabase.from("prj_tasks").select("*").eq("organization_id", currentSupabaseOrganizationId);
1635
- if (filters.projectId) {
1636
- query = query.eq("project_id", filters.projectId);
1637
- }
1638
- if (filters.milestoneId) {
1639
- query = query.eq("milestone_id", filters.milestoneId);
1640
- }
1641
- if (filters.status) {
1642
- query = query.eq("status", filters.status);
1643
- }
1644
- if (filters.type) {
1645
- query = query.eq("type", filters.type);
1646
- }
1647
- query = query.order("created_at", { ascending: false });
1648
- const { data, error } = await query;
1649
- if (error) throw error;
1650
- return data || [];
1651
- },
1652
- enabled: isReady
1232
+ const params = new URLSearchParams();
1233
+ if (filters.status) params.set("status", filters.status);
1234
+ if (filters.milestoneId) params.set("milestone_id", filters.milestoneId);
1235
+ const qs = params.toString();
1236
+ const base = `/projects/${filters.projectId}/tasks`;
1237
+ const path = qs ? `${base}?${qs}` : base;
1238
+ const res = await apiRequest(path);
1239
+ return res.tasks;
1240
+ },
1241
+ enabled: isReady && !!filters.projectId
1653
1242
  });
1654
1243
  }
1655
1244
  function useDeleteTask() {
1656
- const supabase = useSupabase();
1245
+ const { apiRequest } = useElevasisServices();
1657
1246
  const queryClient = useQueryClient();
1658
1247
  return useMutation({
1659
1248
  mutationFn: async (params) => {
1660
- const { error } = await supabase.from("prj_tasks").delete().eq("id", params.id);
1661
- if (error) throw error;
1249
+ await apiRequest(`/project-tasks/${params.id}`, {
1250
+ method: "DELETE"
1251
+ });
1662
1252
  },
1663
1253
  onSuccess: (_, params) => {
1664
1254
  queryClient.invalidateQueries({ queryKey: taskKeys.all });
@@ -1678,46 +1268,26 @@ var noteKeys = {
1678
1268
  detail: (id) => [...noteKeys.all, "detail", id]
1679
1269
  };
1680
1270
  function useProjectNotes(filters = {}) {
1681
- const supabase = useSupabase();
1682
- const { currentSupabaseOrganizationId, isInitializing, isOrgRefreshing } = useOrganization();
1683
- const isReady = !!currentSupabaseOrganizationId && !isInitializing && !isOrgRefreshing;
1271
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
1684
1272
  return useQuery({
1685
- queryKey: noteKeys.list(currentSupabaseOrganizationId, filters),
1273
+ queryKey: noteKeys.list(organizationId, filters),
1686
1274
  queryFn: async () => {
1687
- if (!currentSupabaseOrganizationId) {
1688
- return [];
1689
- }
1690
- let query = supabase.from("prj_notes").select("*").eq("organization_id", currentSupabaseOrganizationId);
1691
- if (filters.projectId) {
1692
- query = query.eq("project_id", filters.projectId);
1693
- }
1694
- if (filters.type) {
1695
- query = query.eq("type", filters.type);
1696
- }
1697
- query = query.order("occurred_at", { ascending: false });
1698
- const { data, error } = await query;
1699
- if (error) throw error;
1700
- return data || [];
1275
+ const res = await apiRequest(`/projects/${filters.projectId}/notes`);
1276
+ return res.notes;
1701
1277
  },
1702
- enabled: isReady
1278
+ enabled: isReady && !!filters.projectId
1703
1279
  });
1704
1280
  }
1705
1281
  function useCreateNote() {
1706
- const supabase = useSupabase();
1282
+ const { apiRequest } = useElevasisServices();
1707
1283
  const queryClient = useQueryClient();
1708
- const { currentSupabaseOrganizationId } = useOrganization();
1709
1284
  return useMutation({
1710
1285
  mutationFn: async (params) => {
1711
- if (!currentSupabaseOrganizationId) {
1712
- throw new Error("No organization selected");
1713
- }
1714
- const insert = {
1715
- ...params,
1716
- organization_id: currentSupabaseOrganizationId
1717
- };
1718
- const { data, error } = await supabase.from("prj_notes").insert(insert).select().single();
1719
- if (error) throw error;
1720
- return data;
1286
+ const res = await apiRequest("/project-notes", {
1287
+ method: "POST",
1288
+ body: JSON.stringify(params)
1289
+ });
1290
+ return res.note;
1721
1291
  },
1722
1292
  onSuccess: (data) => {
1723
1293
  queryClient.invalidateQueries({ queryKey: noteKeys.all });
@@ -1730,4 +1300,4 @@ function useCreateNote() {
1730
1300
  });
1731
1301
  }
1732
1302
 
1733
- export { ApiKeyService, CredentialSchemas, CredentialService, DeploymentService, MEMBERSHIP_STATUS_COLORS, OrganizationMembershipService, WebhookEndpointService, dealKeys, dealNoteKeys, dealTaskKeys, filterByDomainFilters, milestoneKeys, noteKeys, projectKeys, taskKeys, transformMembershipToTableRow, useActivateDeployment, useActivityFilters, useBatchTelemetry, useCommandViewDomainFilters, useCompleteDealTask, useCreateApiKey, useCreateCredential, useCreateDealNote, useCreateDealTask, useCreateMilestone, useCreateNote, useCreateProject, useCreateWebhookEndpoint, useCredentials, useDeactivateDeployment, useDeactivateMembership, useDealDetail, useDealNotes, useDealTasks, useDealTasksDue, useDeals, useDeleteApiKey, useDeleteCredential, useDeleteDeal, useDeleteDeployment, useDeleteMilestone, useDeleteProject, useDeleteTask, useDeleteWebhookEndpoint, useExecutionLogsFilters, useListApiKeys, useListDeployments, useListWebhookEndpoints, useMilestones, useOrganizationMembers, useProject, useProjectNotes, useProjects, useReactivateMembership, useResourceSearch, useResourcesDomainFilters, useStatusFilter, useSyncDealStage, useTasks, useTimeRangeDates, useUpdateApiKey, useUpdateCredential, useUpdateMemberConfig, useUpdateMilestone, useUpdateProject, useUpdateWebhookEndpoint, useUserMemberships, useVisibleResources };
1303
+ export { ApiKeyService, CredentialSchemas, CredentialService, DeploymentService, MEMBERSHIP_STATUS_COLORS, OrganizationMembershipService, WebhookEndpointService, filterByDomainFilters, milestoneKeys, noteKeys, projectKeys, taskKeys, transformMembershipToTableRow, useActivateDeployment, useActivityFilters, useCommandViewDomainFilters, useCreateApiKey, useCreateCredential, useCreateMilestone, useCreateNote, useCreateProject, useCreateWebhookEndpoint, useCredentials, useDeactivateDeployment, useDeactivateMembership, useDeleteApiKey, useDeleteCredential, useDeleteDeployment, useDeleteMilestone, useDeleteProject, useDeleteTask, useDeleteWebhookEndpoint, useExecutionLogsFilters, useListApiKeys, useListDeployments, useListWebhookEndpoints, useMilestones, useOrganizationMembers, useProject, useProjectNotes, useProjects, useReactivateMembership, useResourceSearch, useResourcesDomainFilters, useStatusFilter, useTasks, useTimeRangeDates, useUpdateApiKey, useUpdateCredential, useUpdateMemberConfig, useUpdateMilestone, useUpdateProject, useUpdateWebhookEndpoint, useUserMemberships, useVisibleResources };