@elevasis/ui 1.24.3 → 1.25.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.
Files changed (41) hide show
  1. package/dist/charts/index.js +2 -2
  2. package/dist/{chunk-H3MU3WTM.js → chunk-3EVTCVKR.js} +2 -2
  3. package/dist/{chunk-ZDKC3V7C.js → chunk-7RS6VTAV.js} +56 -57
  4. package/dist/{chunk-TQBM3OEW.js → chunk-BS4J2LAW.js} +1 -1
  5. package/dist/{chunk-JR2C4XAN.js → chunk-CYXZHBP4.js} +202 -295
  6. package/dist/{chunk-OH74INP2.js → chunk-FEZZ3IDU.js} +434 -314
  7. package/dist/{chunk-IAZT3VO6.js → chunk-G25YWGUL.js} +4 -1
  8. package/dist/{chunk-BGTZFEKR.js → chunk-HYYI4ZFT.js} +6 -252
  9. package/dist/{chunk-CTF6FS2M.js → chunk-L3GVDMCA.js} +211 -1
  10. package/dist/{chunk-VMMNFRAO.js → chunk-QNABH7YG.js} +3 -3
  11. package/dist/{chunk-JTUX5FDC.js → chunk-R565P6XC.js} +691 -2
  12. package/dist/{chunk-WY5IJI37.js → chunk-RIL2CDFE.js} +2 -2
  13. package/dist/{chunk-TML32XBW.js → chunk-RMPXGBNI.js} +2 -2
  14. package/dist/{chunk-UG5565XQ.js → chunk-US4JUSI3.js} +3 -3
  15. package/dist/components/index.d.ts +3005 -192
  16. package/dist/components/index.js +1539 -24
  17. package/dist/features/auth/index.d.ts +108 -9
  18. package/dist/features/dashboard/index.js +7 -7
  19. package/dist/features/monitoring/index.js +8 -8
  20. package/dist/features/operations/index.d.ts +8 -2
  21. package/dist/features/operations/index.js +52 -55
  22. package/dist/features/settings/index.d.ts +108 -9
  23. package/dist/features/settings/index.js +27 -10
  24. package/dist/hooks/index.d.ts +3279 -185
  25. package/dist/hooks/index.js +4 -4
  26. package/dist/hooks/published.d.ts +108 -9
  27. package/dist/hooks/published.js +3 -3
  28. package/dist/index.d.ts +3285 -187
  29. package/dist/index.js +5 -5
  30. package/dist/initialization/index.d.ts +108 -9
  31. package/dist/layout/index.d.ts +60 -3
  32. package/dist/layout/index.js +2 -2
  33. package/dist/profile/index.d.ts +108 -9
  34. package/dist/provider/index.d.ts +6 -2
  35. package/dist/provider/index.js +3 -3
  36. package/dist/provider/published.d.ts +6 -2
  37. package/dist/supabase/index.d.ts +210 -18
  38. package/dist/theme/index.d.ts +6 -2
  39. package/dist/theme/index.js +3 -3
  40. package/dist/types/index.d.ts +108 -9
  41. package/package.json +1 -1
@@ -1,7 +1,9 @@
1
- import { CredentialNameSchema, UuidSchema, useErrorNotification, showApiErrorNotification } from './chunk-QDO6NF2I.js';
1
+ import { CredentialNameSchema, UuidSchema, useErrorNotification, showApiErrorNotification, showSuccessNotification } from './chunk-QDO6NF2I.js';
2
+ import { useSupabase } from './chunk-NJJ3NQ7B.js';
2
3
  import { getTimeRangeDates } from './chunk-LXHZYSMQ.js';
3
4
  import { useNotificationAdapter } from './chunk-R7WLWGPO.js';
4
5
  import { GC_TIME_SHORT, STALE_TIME_MONITORING, GC_TIME_MEDIUM, STALE_TIME_DEFAULT } from './chunk-IOKL7BKE.js';
6
+ import { useOrganization } from './chunk-DD3CCMCZ.js';
5
7
  import { useElevasisServices } from './chunk-QEPXAWE2.js';
6
8
  import { z } from 'zod';
7
9
  import { create } from 'zustand';
@@ -60,6 +62,11 @@ var ListMembershipsQuerySchema = z.object({
60
62
  message: "Either userId or organizationId must be provided"
61
63
  }
62
64
  );
65
+
66
+ // ../core/src/supabase/helpers.ts
67
+ function sanitizePostgrestValue(value) {
68
+ return value.replace(/[,()]/g, "");
69
+ }
63
70
  var CredentialTypeSchema = z.enum(["oauth", "api-key", "webhook-secret", "api-key-secret"]);
64
71
  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(
65
72
  (val) => {
@@ -1040,5 +1047,687 @@ function useUpdateWebhookEndpoint() {
1040
1047
  }
1041
1048
  });
1042
1049
  }
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
+ var projectKeys = {
1368
+ all: ["projects"],
1369
+ lists: () => [...projectKeys.all, "list"],
1370
+ list: (orgId, filters) => [...projectKeys.all, "list", orgId, filters],
1371
+ details: () => [...projectKeys.all, "detail"],
1372
+ detail: (id) => [...projectKeys.all, "detail", id]
1373
+ };
1374
+ function useProjects(filters = {}) {
1375
+ const supabase = useSupabase();
1376
+ const { currentSupabaseOrganizationId, isInitializing, isOrgRefreshing } = useOrganization();
1377
+ const isReady = !!currentSupabaseOrganizationId && !isInitializing && !isOrgRefreshing;
1378
+ return useQuery({
1379
+ queryKey: projectKeys.list(currentSupabaseOrganizationId, filters),
1380
+ 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
+ }));
1431
+ },
1432
+ enabled: isReady
1433
+ });
1434
+ }
1435
+ function useProject(id) {
1436
+ const supabase = useSupabase();
1437
+ const { currentSupabaseOrganizationId, isInitializing, isOrgRefreshing } = useOrganization();
1438
+ const isReady = !!currentSupabaseOrganizationId && !isInitializing && !isOrgRefreshing;
1439
+ return useQuery({
1440
+ queryKey: [...projectKeys.detail(id), currentSupabaseOrganizationId],
1441
+ 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;
1456
+ }
1457
+ return data;
1458
+ },
1459
+ enabled: isReady && !!id
1460
+ });
1461
+ }
1462
+ function useCreateProject() {
1463
+ const supabase = useSupabase();
1464
+ const queryClient = useQueryClient();
1465
+ const { currentSupabaseOrganizationId } = useOrganization();
1466
+ return useMutation({
1467
+ 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;
1478
+ },
1479
+ onSuccess: () => {
1480
+ queryClient.invalidateQueries({ queryKey: projectKeys.all });
1481
+ },
1482
+ onError: (error) => {
1483
+ showApiErrorNotification(error);
1484
+ }
1485
+ });
1486
+ }
1487
+ function useUpdateProject() {
1488
+ const supabase = useSupabase();
1489
+ const queryClient = useQueryClient();
1490
+ return useMutation({
1491
+ 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;
1495
+ },
1496
+ onSuccess: (data) => {
1497
+ queryClient.invalidateQueries({ queryKey: projectKeys.all });
1498
+ queryClient.invalidateQueries({ queryKey: projectKeys.detail(data.id) });
1499
+ },
1500
+ onError: (error) => {
1501
+ showApiErrorNotification(error);
1502
+ }
1503
+ });
1504
+ }
1505
+ function useDeleteProject() {
1506
+ const supabase = useSupabase();
1507
+ const queryClient = useQueryClient();
1508
+ return useMutation({
1509
+ mutationFn: async (id) => {
1510
+ const { error } = await supabase.from("prj_projects").delete().eq("id", id);
1511
+ if (error) throw error;
1512
+ },
1513
+ onSuccess: () => {
1514
+ queryClient.invalidateQueries({ queryKey: projectKeys.all });
1515
+ },
1516
+ onError: (error) => {
1517
+ showApiErrorNotification(error);
1518
+ }
1519
+ });
1520
+ }
1521
+ var milestoneKeys = {
1522
+ all: ["project-milestones"],
1523
+ lists: () => [...milestoneKeys.all, "list"],
1524
+ list: (orgId, filters) => [...milestoneKeys.all, "list", orgId, filters],
1525
+ details: () => [...milestoneKeys.all, "detail"],
1526
+ detail: (id) => [...milestoneKeys.all, "detail", id]
1527
+ };
1528
+ function useMilestones(filters = {}) {
1529
+ const supabase = useSupabase();
1530
+ const { currentSupabaseOrganizationId, isInitializing, isOrgRefreshing } = useOrganization();
1531
+ const isReady = !!currentSupabaseOrganizationId && !isInitializing && !isOrgRefreshing;
1532
+ return useQuery({
1533
+ queryKey: milestoneKeys.list(currentSupabaseOrganizationId, filters),
1534
+ 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 || [];
1549
+ },
1550
+ enabled: isReady
1551
+ });
1552
+ }
1553
+ function useCreateMilestone() {
1554
+ const supabase = useSupabase();
1555
+ const queryClient = useQueryClient();
1556
+ const { currentSupabaseOrganizationId } = useOrganization();
1557
+ return useMutation({
1558
+ 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;
1569
+ },
1570
+ onSuccess: (data) => {
1571
+ queryClient.invalidateQueries({ queryKey: milestoneKeys.all });
1572
+ queryClient.invalidateQueries({ queryKey: projectKeys.all });
1573
+ queryClient.invalidateQueries({ queryKey: projectKeys.detail(data.project_id) });
1574
+ },
1575
+ onError: (error) => {
1576
+ showApiErrorNotification(error);
1577
+ }
1578
+ });
1579
+ }
1580
+ function useUpdateMilestone() {
1581
+ const supabase = useSupabase();
1582
+ const queryClient = useQueryClient();
1583
+ return useMutation({
1584
+ 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;
1588
+ },
1589
+ onSuccess: (data) => {
1590
+ queryClient.invalidateQueries({ queryKey: milestoneKeys.all });
1591
+ queryClient.invalidateQueries({ queryKey: projectKeys.all });
1592
+ queryClient.invalidateQueries({ queryKey: projectKeys.detail(data.project_id) });
1593
+ },
1594
+ onError: (error) => {
1595
+ showApiErrorNotification(error);
1596
+ }
1597
+ });
1598
+ }
1599
+ function useDeleteMilestone() {
1600
+ const supabase = useSupabase();
1601
+ const queryClient = useQueryClient();
1602
+ return useMutation({
1603
+ mutationFn: async (params) => {
1604
+ const { error } = await supabase.from("prj_milestones").delete().eq("id", params.id);
1605
+ if (error) throw error;
1606
+ },
1607
+ onSuccess: (_, params) => {
1608
+ queryClient.invalidateQueries({ queryKey: milestoneKeys.all });
1609
+ queryClient.invalidateQueries({ queryKey: projectKeys.all });
1610
+ queryClient.invalidateQueries({ queryKey: projectKeys.detail(params.projectId) });
1611
+ },
1612
+ onError: (error) => {
1613
+ showApiErrorNotification(error);
1614
+ }
1615
+ });
1616
+ }
1617
+ var taskKeys = {
1618
+ all: ["project-tasks"],
1619
+ lists: () => [...taskKeys.all, "list"],
1620
+ list: (orgId, filters) => [...taskKeys.all, "list", orgId, filters],
1621
+ details: () => [...taskKeys.all, "detail"],
1622
+ detail: (id) => [...taskKeys.all, "detail", id]
1623
+ };
1624
+ function useTasks(filters = {}) {
1625
+ const supabase = useSupabase();
1626
+ const { currentSupabaseOrganizationId, isInitializing, isOrgRefreshing } = useOrganization();
1627
+ const isReady = !!currentSupabaseOrganizationId && !isInitializing && !isOrgRefreshing;
1628
+ return useQuery({
1629
+ queryKey: taskKeys.list(currentSupabaseOrganizationId, filters),
1630
+ 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
1653
+ });
1654
+ }
1655
+ function useDeleteTask() {
1656
+ const supabase = useSupabase();
1657
+ const queryClient = useQueryClient();
1658
+ return useMutation({
1659
+ mutationFn: async (params) => {
1660
+ const { error } = await supabase.from("prj_tasks").delete().eq("id", params.id);
1661
+ if (error) throw error;
1662
+ },
1663
+ onSuccess: (_, params) => {
1664
+ queryClient.invalidateQueries({ queryKey: taskKeys.all });
1665
+ queryClient.invalidateQueries({ queryKey: projectKeys.all });
1666
+ queryClient.invalidateQueries({ queryKey: projectKeys.detail(params.projectId) });
1667
+ },
1668
+ onError: (error) => {
1669
+ showApiErrorNotification(error);
1670
+ }
1671
+ });
1672
+ }
1673
+ var noteKeys = {
1674
+ all: ["project-notes"],
1675
+ lists: () => [...noteKeys.all, "list"],
1676
+ list: (orgId, filters) => [...noteKeys.all, "list", orgId, filters],
1677
+ details: () => [...noteKeys.all, "detail"],
1678
+ detail: (id) => [...noteKeys.all, "detail", id]
1679
+ };
1680
+ function useProjectNotes(filters = {}) {
1681
+ const supabase = useSupabase();
1682
+ const { currentSupabaseOrganizationId, isInitializing, isOrgRefreshing } = useOrganization();
1683
+ const isReady = !!currentSupabaseOrganizationId && !isInitializing && !isOrgRefreshing;
1684
+ return useQuery({
1685
+ queryKey: noteKeys.list(currentSupabaseOrganizationId, filters),
1686
+ 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 || [];
1701
+ },
1702
+ enabled: isReady
1703
+ });
1704
+ }
1705
+ function useCreateNote() {
1706
+ const supabase = useSupabase();
1707
+ const queryClient = useQueryClient();
1708
+ const { currentSupabaseOrganizationId } = useOrganization();
1709
+ return useMutation({
1710
+ 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;
1721
+ },
1722
+ onSuccess: (data) => {
1723
+ queryClient.invalidateQueries({ queryKey: noteKeys.all });
1724
+ queryClient.invalidateQueries({ queryKey: projectKeys.all });
1725
+ queryClient.invalidateQueries({ queryKey: projectKeys.detail(data.project_id) });
1726
+ },
1727
+ onError: (error) => {
1728
+ showApiErrorNotification(error);
1729
+ }
1730
+ });
1731
+ }
1043
1732
 
1044
- export { ApiKeyService, CredentialSchemas, CredentialService, DeploymentService, MEMBERSHIP_STATUS_COLORS, OrganizationMembershipService, WebhookEndpointService, filterByDomainFilters, transformMembershipToTableRow, useActivateDeployment, useActivityFilters, useCommandViewDomainFilters, useCreateApiKey, useCreateCredential, useCreateWebhookEndpoint, useCredentials, useDeactivateDeployment, useDeactivateMembership, useDeleteApiKey, useDeleteCredential, useDeleteDeployment, useDeleteWebhookEndpoint, useExecutionLogsFilters, useListApiKeys, useListDeployments, useListWebhookEndpoints, useOrganizationMembers, useReactivateMembership, useResourceSearch, useResourcesDomainFilters, useStatusFilter, useTimeRangeDates, useUpdateApiKey, useUpdateCredential, useUpdateMemberConfig, useUpdateWebhookEndpoint, useUserMemberships, useVisibleResources };
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 };