@elevasis/ui 1.0.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 (97) hide show
  1. package/dist/api/index.d.ts +87 -0
  2. package/dist/api/index.js +3 -0
  3. package/dist/auth/context.d.ts +19 -0
  4. package/dist/auth/context.js +1 -0
  5. package/dist/auth/index.d.ts +85 -0
  6. package/dist/auth/index.js +3 -0
  7. package/dist/chunk-3KMDHCAR.js +52 -0
  8. package/dist/chunk-5UWFGBFM.js +129 -0
  9. package/dist/chunk-6BJOYF6E.js +8 -0
  10. package/dist/chunk-6M6OLGQY.js +36 -0
  11. package/dist/chunk-7AI5ZYJ4.js +202 -0
  12. package/dist/chunk-7PLEQFHO.js +18 -0
  13. package/dist/chunk-GDV44UWF.js +138 -0
  14. package/dist/chunk-GEFB5YIR.js +338 -0
  15. package/dist/chunk-HBRMWW6V.js +43 -0
  16. package/dist/chunk-HUWJXLLF.js +681 -0
  17. package/dist/chunk-J3FALDQE.js +176 -0
  18. package/dist/chunk-JKERRYVS.js +109 -0
  19. package/dist/chunk-KA7LO7U5.js +28 -0
  20. package/dist/chunk-LHQTTUL2.js +27 -0
  21. package/dist/chunk-MAAS6CGR.js +1299 -0
  22. package/dist/chunk-NE36BUGQ.js +146 -0
  23. package/dist/chunk-NGXCFBCS.js +398 -0
  24. package/dist/chunk-OEYU5O27.js +235 -0
  25. package/dist/chunk-OUHGHTE7.js +748 -0
  26. package/dist/chunk-OXVOHOP3.js +661 -0
  27. package/dist/chunk-PSLKGOBZ.js +58 -0
  28. package/dist/chunk-PYL4XW6H.js +107 -0
  29. package/dist/chunk-Q47SPRY7.js +1 -0
  30. package/dist/chunk-Q7DJKLEN.js +18 -0
  31. package/dist/chunk-RJCA5672.js +1664 -0
  32. package/dist/chunk-S66I2PYB.js +748 -0
  33. package/dist/chunk-W7ZBF5AA.js +1 -0
  34. package/dist/chunk-WNWKOCGJ.js +1067 -0
  35. package/dist/chunk-XCYKC6OZ.js +1 -0
  36. package/dist/chunk-YULUKCS6.js +56 -0
  37. package/dist/chunk-YZ6GTZXL.js +48 -0
  38. package/dist/chunk-ZGHDPDTF.js +379 -0
  39. package/dist/components/command-queue/index.css +53 -0
  40. package/dist/components/command-queue/index.d.ts +204 -0
  41. package/dist/components/command-queue/index.js +10 -0
  42. package/dist/components/forms/index.d.ts +56 -0
  43. package/dist/components/forms/index.js +2 -0
  44. package/dist/components/index.css +443 -0
  45. package/dist/components/index.d.ts +1354 -0
  46. package/dist/components/index.js +18 -0
  47. package/dist/components/monitoring/index.d.ts +66 -0
  48. package/dist/components/monitoring/index.js +2 -0
  49. package/dist/components/navigation/index.d.ts +54 -0
  50. package/dist/components/navigation/index.js +91 -0
  51. package/dist/components/notifications/index.d.ts +52 -0
  52. package/dist/components/notifications/index.js +4 -0
  53. package/dist/components/resource-definition/index.css +388 -0
  54. package/dist/components/resource-definition/index.d.ts +301 -0
  55. package/dist/components/resource-definition/index.js +3 -0
  56. package/dist/display/index.css +53 -0
  57. package/dist/display/index.d.ts +606 -0
  58. package/dist/display/index.js +6 -0
  59. package/dist/execution/index.css +388 -0
  60. package/dist/execution/index.d.ts +1090 -0
  61. package/dist/execution/index.js +4 -0
  62. package/dist/graph/index.css +388 -0
  63. package/dist/graph/index.d.ts +429 -0
  64. package/dist/graph/index.js +1 -0
  65. package/dist/hooks/index.d.ts +1927 -0
  66. package/dist/hooks/index.js +6 -0
  67. package/dist/hooks/published.d.ts +1653 -0
  68. package/dist/hooks/published.js +4 -0
  69. package/dist/index.css +505 -0
  70. package/dist/index.d.ts +7284 -0
  71. package/dist/index.js +31 -0
  72. package/dist/initialization/index.d.ts +2325 -0
  73. package/dist/initialization/index.js +4 -0
  74. package/dist/organization/index.d.ts +225 -0
  75. package/dist/organization/index.js +4 -0
  76. package/dist/profile/index.d.ts +2265 -0
  77. package/dist/profile/index.js +3 -0
  78. package/dist/provider/index.css +61 -0
  79. package/dist/provider/index.d.ts +291 -0
  80. package/dist/provider/index.js +7 -0
  81. package/dist/provider/published.d.ts +198 -0
  82. package/dist/provider/published.js +6 -0
  83. package/dist/router/context.d.ts +19 -0
  84. package/dist/router/context.js +1 -0
  85. package/dist/router/index.d.ts +31 -0
  86. package/dist/router/index.js +2 -0
  87. package/dist/sse/index.d.ts +83 -0
  88. package/dist/sse/index.js +185 -0
  89. package/dist/supabase/index.d.ts +4289 -0
  90. package/dist/supabase/index.js +47 -0
  91. package/dist/typeform/index.d.ts +458 -0
  92. package/dist/typeform/index.js +1976 -0
  93. package/dist/typeform/schemas.d.ts +67 -0
  94. package/dist/typeform/schemas.js +1 -0
  95. package/dist/utils/index.d.ts +177 -0
  96. package/dist/utils/index.js +1 -0
  97. package/package.json +88 -0
@@ -0,0 +1,1067 @@
1
+ import { UuidSchema, ResourceTypeSchema, NonEmptyStringSchema, OriginResourceTypeSchema } from './chunk-JKERRYVS.js';
2
+ import { useElevasisServices } from './chunk-KA7LO7U5.js';
3
+ import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
4
+ import { z } from 'zod';
5
+
6
+ // src/hooks/executions/queryKeys.ts
7
+ var executionsKeys = {
8
+ all: ["executions"],
9
+ resources: (orgId) => [...executionsKeys.all, "resources", orgId],
10
+ resourceDefinition: (orgId, resourceId) => [...executionsKeys.all, "definition", orgId, resourceId],
11
+ // NOTE: resourceStatus and limit intentionally excluded from queryKey for unified cache invalidation.
12
+ // All filter variants share the same cache so SSE invalidations work across filters.
13
+ executions: (orgId, resourceId) => [...executionsKeys.all, "list", orgId, resourceId],
14
+ execution: (orgId, resourceId, executionId) => [...executionsKeys.all, "execution", orgId, resourceId, executionId]
15
+ };
16
+ function useExecutions(resourceId, resourceStatus, limit) {
17
+ const { apiRequest, organizationId, isReady } = useElevasisServices();
18
+ return useQuery({
19
+ // eslint-disable-next-line @tanstack/query/exhaustive-deps
20
+ queryKey: executionsKeys.executions(organizationId, resourceId),
21
+ queryFn: async () => {
22
+ const params = new URLSearchParams();
23
+ if (resourceStatus && resourceStatus !== "all") {
24
+ params.set("resourceStatus", resourceStatus);
25
+ }
26
+ if (limit) {
27
+ params.set("limit", String(limit));
28
+ }
29
+ const queryString = params.toString();
30
+ const endpoint = `/execution-engine/executions/${resourceId}${queryString ? `?${queryString}` : ""}`;
31
+ return apiRequest(endpoint);
32
+ },
33
+ enabled: isReady && !!resourceId
34
+ });
35
+ }
36
+ var REFETCH_INTERVAL_RUNNING = 2e3;
37
+ function useExecution(resourceId, executionId) {
38
+ const { apiRequest, organizationId, isReady } = useElevasisServices();
39
+ return useQuery({
40
+ queryKey: executionsKeys.execution(organizationId, resourceId, executionId),
41
+ queryFn: () => apiRequest(`/execution-engine/executions/${resourceId}/${executionId}`),
42
+ enabled: isReady && !!resourceId && !!executionId,
43
+ refetchInterval: (query) => {
44
+ const data = query.state.data;
45
+ return data?.status === "running" ? REFETCH_INTERVAL_RUNNING : false;
46
+ }
47
+ });
48
+ }
49
+ function useExecuteAsync() {
50
+ const { apiRequest, organizationId } = useElevasisServices();
51
+ const queryClient = useQueryClient();
52
+ return useMutation({
53
+ mutationFn: async ({ resourceId, resourceType, input }) => {
54
+ const response = await apiRequest("/execution-engine/execute-async", {
55
+ method: "POST",
56
+ body: JSON.stringify({ resourceType, resourceId, input })
57
+ });
58
+ return { ...response, resourceId };
59
+ },
60
+ onSuccess: (data) => {
61
+ queryClient.invalidateQueries({
62
+ queryKey: executionsKeys.executions(organizationId, data.resourceId)
63
+ });
64
+ }
65
+ });
66
+ }
67
+ function useRetryExecution() {
68
+ const { apiRequest, organizationId } = useElevasisServices();
69
+ const queryClient = useQueryClient();
70
+ return useMutation({
71
+ mutationFn: async ({ resourceId, resourceType, input }) => {
72
+ const response = await apiRequest("/execution-engine/execute-async", {
73
+ method: "POST",
74
+ body: JSON.stringify({ resourceType, resourceId, input })
75
+ });
76
+ return { ...response, resourceId };
77
+ },
78
+ onSuccess: (data) => {
79
+ queryClient.invalidateQueries({
80
+ queryKey: executionsKeys.executions(organizationId, data.resourceId)
81
+ });
82
+ }
83
+ });
84
+ }
85
+ function useCancelExecution() {
86
+ const { apiRequest, organizationId } = useElevasisServices();
87
+ const queryClient = useQueryClient();
88
+ return useMutation({
89
+ mutationFn: async ({ resourceId, executionId }) => {
90
+ const response = await apiRequest(
91
+ `/execution-engine/executions/${resourceId}/${executionId}/cancel`,
92
+ { method: "POST" }
93
+ );
94
+ return { ...response, resourceId, executionId };
95
+ },
96
+ onSuccess: (data) => {
97
+ queryClient.invalidateQueries({
98
+ queryKey: executionsKeys.execution(organizationId, data.resourceId, data.executionId)
99
+ });
100
+ queryClient.invalidateQueries({
101
+ queryKey: executionsKeys.executions(organizationId, data.resourceId)
102
+ });
103
+ }
104
+ });
105
+ }
106
+ function useDeleteExecution() {
107
+ const { apiRequest, organizationId } = useElevasisServices();
108
+ const queryClient = useQueryClient();
109
+ return useMutation({
110
+ mutationFn: async ({ resourceId, executionId }) => {
111
+ await apiRequest(`/execution-engine/executions/${resourceId}/${executionId}`, {
112
+ method: "DELETE"
113
+ });
114
+ return { resourceId, executionId };
115
+ },
116
+ onSuccess: (data) => {
117
+ queryClient.removeQueries({
118
+ queryKey: executionsKeys.execution(organizationId, data.resourceId, data.executionId)
119
+ });
120
+ queryClient.invalidateQueries({
121
+ queryKey: executionsKeys.executions(organizationId, data.resourceId)
122
+ });
123
+ }
124
+ });
125
+ }
126
+ function useBulkDeleteExecutions() {
127
+ const { apiRequest, organizationId } = useElevasisServices();
128
+ const queryClient = useQueryClient();
129
+ return useMutation({
130
+ mutationFn: async ({
131
+ resourceId,
132
+ resourceStatus
133
+ }) => {
134
+ const params = new URLSearchParams();
135
+ if (resourceStatus && resourceStatus !== "all") {
136
+ params.set("resourceStatus", resourceStatus);
137
+ }
138
+ const queryString = params.toString();
139
+ const endpoint = `/execution-engine/executions/${resourceId}${queryString ? `?${queryString}` : ""}`;
140
+ const response = await apiRequest(
141
+ endpoint,
142
+ { method: "DELETE" }
143
+ );
144
+ return { resourceId, deletedCount: response.deletedCount, resourceStatus };
145
+ },
146
+ onSuccess: (data) => {
147
+ queryClient.invalidateQueries({
148
+ queryKey: executionsKeys.executions(organizationId, data.resourceId)
149
+ });
150
+ }
151
+ });
152
+ }
153
+ var SessionIdParamSchema = z.object({
154
+ sessionId: UuidSchema
155
+ }).strict();
156
+ z.object({
157
+ sessionId: UuidSchema,
158
+ executionId: UuidSchema
159
+ }).strict();
160
+ var CreateSessionSchema = z.object({
161
+ resourceId: z.string().min(1).max(100),
162
+ userId: UuidSchema.optional(),
163
+ metadata: z.any().optional()
164
+ }).strict();
165
+ z.object({
166
+ input: z.unknown().refine(
167
+ (val) => {
168
+ let text;
169
+ if (typeof val === "string") {
170
+ text = val;
171
+ } else if (val && typeof val === "object" && "message" in val) {
172
+ text = String(val.message);
173
+ } else {
174
+ text = JSON.stringify(val);
175
+ }
176
+ return text.length > 0 && text.length <= 1e5;
177
+ },
178
+ { message: "Input must be between 1 and 100,000 characters" }
179
+ ),
180
+ metadata: z.any().optional()
181
+ }).strict();
182
+ z.object({
183
+ userId: UuidSchema.optional(),
184
+ resourceId: z.string().optional(),
185
+ limit: z.coerce.number().int().min(1).max(100).default(20)
186
+ }).strict();
187
+ z.object({
188
+ type: z.literal("session:turn"),
189
+ input: z.unknown().refine(
190
+ (val) => {
191
+ let text;
192
+ if (typeof val === "string") {
193
+ text = val;
194
+ } else if (val && typeof val === "object" && "message" in val) {
195
+ text = String(val.message);
196
+ } else {
197
+ text = JSON.stringify(val) || "";
198
+ }
199
+ return text && text.length > 0 && text.length <= 1e5;
200
+ },
201
+ { message: "Input must be between 1 and 100,000 characters" }
202
+ )
203
+ }).strict();
204
+
205
+ // src/hooks/services/OperationsService.ts
206
+ var OperationsService = class {
207
+ constructor(apiRequest) {
208
+ this.apiRequest = apiRequest;
209
+ }
210
+ /**
211
+ * Fetch all available Execution Engine resources
212
+ * Uses the unified /list-resources endpoint
213
+ */
214
+ async getResources() {
215
+ return this.apiRequest("/execution-engine/resources");
216
+ }
217
+ /**
218
+ * Get detailed workflow information
219
+ * Optional: For future detailed views
220
+ */
221
+ async getWorkflowDetails() {
222
+ return this.apiRequest("/execution-engine/workflows/details");
223
+ }
224
+ /**
225
+ * Get detailed agent information
226
+ * Optional: For future detailed views
227
+ */
228
+ async getAgentDetails() {
229
+ return this.apiRequest("/execution-engine/agents/details");
230
+ }
231
+ /**
232
+ * Get detailed pipeline information
233
+ * Optional: For future detailed views
234
+ */
235
+ async getPipelineDetails() {
236
+ return this.apiRequest("/execution-engine/pipelines/details");
237
+ }
238
+ /**
239
+ * Get resource definition (workflow steps, agent actions, pipeline stages, etc.)
240
+ */
241
+ async getResourceDefinition(resourceId) {
242
+ return this.apiRequest(`/execution-engine/resources/${resourceId}/definition`);
243
+ }
244
+ /**
245
+ * List sessions with optional filtering
246
+ */
247
+ async listSessions(params) {
248
+ const queryParams = new URLSearchParams();
249
+ if (params?.resourceId) queryParams.append("resourceId", params.resourceId);
250
+ const endpoint = queryParams.toString() ? `/sessions?${queryParams.toString()}` : "/sessions";
251
+ const response = await this.apiRequest(endpoint);
252
+ return response.sessions.map((session) => ({
253
+ sessionId: session.sessionId,
254
+ resourceId: session.resourceId,
255
+ turnCount: session.turnCount,
256
+ isEnded: session.isEnded,
257
+ createdAt: new Date(session.createdAt),
258
+ updatedAt: new Date(session.updatedAt)
259
+ }));
260
+ }
261
+ /**
262
+ * Get session details by ID
263
+ */
264
+ async getSession(sessionId) {
265
+ SessionIdParamSchema.parse({ sessionId });
266
+ const response = await this.apiRequest(`/sessions/${sessionId}`);
267
+ return {
268
+ sessionId: response.sessionId,
269
+ resourceId: response.resourceId,
270
+ organizationId: response.organizationId,
271
+ userId: response.userId || void 0,
272
+ turnCount: response.turnCount,
273
+ isEnded: response.isEnded,
274
+ metadata: response.metadata || void 0,
275
+ memorySnapshot: response.memorySnapshot || void 0,
276
+ createdAt: new Date(response.createdAt),
277
+ updatedAt: new Date(response.updatedAt),
278
+ endedAt: response.endedAt ? new Date(response.endedAt) : void 0
279
+ };
280
+ }
281
+ /**
282
+ * Create a new session for an agent
283
+ */
284
+ async createSession(resourceId) {
285
+ const validated = CreateSessionSchema.parse({
286
+ resourceId
287
+ });
288
+ const result = await this.apiRequest("/sessions", {
289
+ method: "POST",
290
+ body: JSON.stringify(validated)
291
+ });
292
+ return result;
293
+ }
294
+ /**
295
+ * Archive a session
296
+ */
297
+ async archiveSession(sessionId) {
298
+ SessionIdParamSchema.parse({ sessionId });
299
+ return this.apiRequest(`/sessions/${sessionId}/archive`, {
300
+ method: "POST"
301
+ });
302
+ }
303
+ };
304
+ function useResources() {
305
+ const { apiRequest, organizationId, isReady } = useElevasisServices();
306
+ return useQuery({
307
+ queryKey: executionsKeys.resources(organizationId),
308
+ queryFn: async () => {
309
+ const service = new OperationsService(apiRequest);
310
+ const result = await service.getResources();
311
+ return {
312
+ workflows: result.workflows ?? [],
313
+ agents: result.agents ?? [],
314
+ pipelines: result.pipelines ?? [],
315
+ total: (result.workflows?.length ?? 0) + (result.agents?.length ?? 0) + (result.pipelines?.length ?? 0)
316
+ };
317
+ },
318
+ enabled: isReady
319
+ });
320
+ }
321
+ function useResourceDefinition(resourceId, enabled = true) {
322
+ const { apiRequest, organizationId, isReady } = useElevasisServices();
323
+ return useQuery({
324
+ queryKey: executionsKeys.resourceDefinition(organizationId, resourceId),
325
+ queryFn: () => {
326
+ const service = new OperationsService(apiRequest);
327
+ return service.getResourceDefinition(resourceId);
328
+ },
329
+ enabled: enabled && isReady && !!resourceId,
330
+ retry: 2,
331
+ retryDelay: (attemptIndex) => Math.min(1e3 * 2 ** attemptIndex, 3e4)
332
+ });
333
+ }
334
+ function useActivityTrend(params = {}) {
335
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
336
+ return useQuery({
337
+ queryKey: ["activities", "trend", organizationId, params],
338
+ queryFn: async () => {
339
+ const queryParams = new URLSearchParams();
340
+ if (params.activityType) queryParams.set("activityType", params.activityType);
341
+ if (params.entityType) queryParams.set("entityType", params.entityType);
342
+ if (params.entityId) queryParams.set("entityId", params.entityId);
343
+ if (params.startDate) queryParams.set("startDate", params.startDate);
344
+ if (params.endDate) queryParams.set("endDate", params.endDate);
345
+ const queryString = queryParams.toString();
346
+ const endpoint = `/activities/trend${queryString ? `?${queryString}` : ""}`;
347
+ const response = await apiRequest(endpoint);
348
+ return {
349
+ timestamps: response.timestamps.map((t) => new Date(t)),
350
+ total: response.total
351
+ };
352
+ },
353
+ enabled: isReady,
354
+ refetchInterval: 3e4,
355
+ staleTime: 0
356
+ });
357
+ }
358
+ function useActivities(params = {}) {
359
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
360
+ return useQuery({
361
+ queryKey: ["activities", "list", organizationId, params],
362
+ queryFn: async () => {
363
+ const queryParams = new URLSearchParams();
364
+ if (params.limit) queryParams.set("limit", params.limit.toString());
365
+ if (params.offset) queryParams.set("offset", params.offset.toString());
366
+ if (params.activityType) queryParams.set("activityType", params.activityType);
367
+ if (params.entityType) queryParams.set("entityType", params.entityType);
368
+ if (params.entityId) queryParams.set("entityId", params.entityId);
369
+ if (params.startDate) queryParams.set("startDate", params.startDate);
370
+ if (params.endDate) queryParams.set("endDate", params.endDate);
371
+ if (params.status && params.status !== "all") queryParams.set("status", params.status);
372
+ if (params.search && params.search.trim()) queryParams.set("search", params.search.trim());
373
+ const queryString = queryParams.toString();
374
+ const endpoint = `/activities${queryString ? `?${queryString}` : ""}`;
375
+ const response = await apiRequest(endpoint);
376
+ return {
377
+ activities: response.activities.map((activity) => ({
378
+ ...activity,
379
+ occurredAt: new Date(activity.occurredAt),
380
+ createdAt: new Date(activity.createdAt)
381
+ })),
382
+ total: response.total
383
+ };
384
+ },
385
+ enabled: isReady,
386
+ refetchInterval: 3e4,
387
+ // 30s real-time polling
388
+ staleTime: 0
389
+ // Real-time data - always refetch on mount/org switch
390
+ });
391
+ }
392
+ function useExecutionLogs(params = {}) {
393
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
394
+ return useQuery({
395
+ queryKey: ["monitoring", "execution-logs", organizationId, params],
396
+ queryFn: async () => {
397
+ const queryParams = new URLSearchParams();
398
+ if (params.resourceId) queryParams.set("resourceId", params.resourceId);
399
+ if (params.status && params.status !== "all") queryParams.set("status", params.status);
400
+ if (params.resourceStatus && params.resourceStatus !== "all") queryParams.set("resourceStatus", params.resourceStatus);
401
+ if (params.startDate !== void 0) queryParams.set("startDate", params.startDate.toString());
402
+ if (params.endDate !== void 0) queryParams.set("endDate", params.endDate.toString());
403
+ if (params.limit !== void 0) queryParams.set("limit", params.limit.toString());
404
+ if (params.offset !== void 0) queryParams.set("offset", params.offset.toString());
405
+ const queryString = queryParams.toString();
406
+ const endpoint = `/execution-engine/executions${queryString ? `?${queryString}` : ""}`;
407
+ return apiRequest(endpoint);
408
+ },
409
+ enabled: isReady,
410
+ refetchInterval: 3e4,
411
+ // 30s real-time polling
412
+ staleTime: 0
413
+ // Real-time data - always refetch on mount/org switch
414
+ });
415
+ }
416
+ var RelativeScheduleItemSchema = z.object({
417
+ offset: z.string().regex(/^[+-]\d+[dhm]$/, "Invalid offset format. Use +3d, -2h, +30m, etc."),
418
+ payload: z.record(z.string(), z.unknown()),
419
+ label: z.string().optional()
420
+ });
421
+ var AbsoluteScheduleItemSchema = z.object({
422
+ runAt: z.string().datetime({ message: "Invalid datetime format" }),
423
+ payload: z.record(z.string(), z.unknown()),
424
+ label: z.string().optional()
425
+ });
426
+ var RecurringScheduleConfigSchema = z.object({
427
+ type: z.literal("recurring"),
428
+ cron: z.string().optional(),
429
+ interval: z.enum(["daily", "weekly", "monthly"]).optional(),
430
+ time: z.string().regex(/^\d{2}:\d{2}$/, "Time must be in HH:MM format").optional(),
431
+ timezone: z.string().min(1, "Timezone is required"),
432
+ payload: z.record(z.string(), z.unknown()),
433
+ endAt: z.string().datetime().nullable().optional(),
434
+ overduePolicy: z.enum(["skip", "execute"]).optional()
435
+ }).refine((data) => data.cron || data.interval, { message: "Either cron or interval must be provided" });
436
+ var RelativeScheduleConfigSchema = z.object({
437
+ type: z.literal("relative"),
438
+ anchorAt: z.string().datetime({ message: "Invalid anchor datetime" }),
439
+ anchorLabel: z.string().optional(),
440
+ items: z.array(RelativeScheduleItemSchema).min(1, "At least one item required"),
441
+ overduePolicy: z.enum(["skip", "execute"]).optional()
442
+ });
443
+ var AbsoluteScheduleConfigSchema = z.object({
444
+ type: z.literal("absolute"),
445
+ items: z.array(AbsoluteScheduleItemSchema).min(1, "At least one item required"),
446
+ overduePolicy: z.enum(["skip", "execute"]).optional()
447
+ });
448
+ var TaskScheduleConfigSchema = z.discriminatedUnion("type", [
449
+ RecurringScheduleConfigSchema,
450
+ RelativeScheduleConfigSchema,
451
+ AbsoluteScheduleConfigSchema
452
+ ]);
453
+ var ScheduleTargetSchema = z.object({
454
+ resourceType: ResourceTypeSchema,
455
+ resourceId: NonEmptyStringSchema.max(255)
456
+ });
457
+ var OptionalOriginTrackingSchema = z.object({
458
+ originExecutionId: UuidSchema.optional(),
459
+ originResourceType: OriginResourceTypeSchema.optional(),
460
+ originResourceId: z.string().max(100).optional()
461
+ });
462
+ z.object({
463
+ organizationId: UuidSchema,
464
+ name: NonEmptyStringSchema.max(255),
465
+ description: z.string().max(1e3).optional(),
466
+ target: ScheduleTargetSchema,
467
+ scheduleConfig: TaskScheduleConfigSchema,
468
+ maxRetries: z.number().int().min(0).max(10).optional().default(3),
469
+ idempotencyKey: z.string().max(255).optional(),
470
+ metadata: z.record(z.string(), z.unknown()).optional()
471
+ }).merge(OptionalOriginTrackingSchema);
472
+ var CreateScheduleRequestSchema = z.object({
473
+ name: z.string().min(1, "Name is required").max(255),
474
+ description: z.string().max(1e3).optional(),
475
+ target: z.object({
476
+ resourceType: ResourceTypeSchema,
477
+ resourceId: z.string().min(1, "Resource ID is required").max(255)
478
+ }),
479
+ scheduleConfig: TaskScheduleConfigSchema,
480
+ maxRetries: z.number().int().min(0).max(10).optional(),
481
+ idempotencyKey: z.string().max(255).optional(),
482
+ // Origin tracking (optional)
483
+ originExecutionId: z.string().uuid().optional(),
484
+ originResourceType: OriginResourceTypeSchema.optional(),
485
+ originResourceId: z.string().max(255).optional()
486
+ });
487
+ z.object({
488
+ status: z.enum(["active", "paused", "completed", "cancelled"]).optional(),
489
+ targetResourceType: ResourceTypeSchema.optional(),
490
+ targetResourceId: z.string().optional(),
491
+ limit: z.coerce.number().int().min(1).max(100).optional().default(50),
492
+ offset: z.coerce.number().int().min(0).optional().default(0)
493
+ });
494
+ var GetScheduleParamsSchema = z.object({
495
+ id: z.string().uuid("Invalid schedule ID")
496
+ });
497
+ var UpdateAnchorRequestSchema = z.object({
498
+ anchorAt: z.string().datetime({ message: "Invalid anchor datetime format" })
499
+ });
500
+ var UpdateScheduleRequestSchema = z.object({
501
+ name: z.string().min(1, "Name cannot be empty").max(255).optional(),
502
+ description: z.string().max(1e3).nullable().optional(),
503
+ scheduleConfig: TaskScheduleConfigSchema.optional(),
504
+ maxRetries: z.number().int().min(0).max(10).optional()
505
+ }).strict().refine(
506
+ (data) => data.name !== void 0 || data.description !== void 0 || data.scheduleConfig !== void 0 || data.maxRetries !== void 0,
507
+ { message: "At least one field (name, description, scheduleConfig, maxRetries) must be provided" }
508
+ );
509
+ z.object({
510
+ schedules: z.array(
511
+ z.object({
512
+ // Required identifiers
513
+ id: z.string().uuid(),
514
+ organization_id: z.string().uuid(),
515
+ name: z.string(),
516
+ // Target
517
+ target_resource_type: z.string(),
518
+ target_resource_id: z.string(),
519
+ // Schedule definition
520
+ schedule_config: z.record(z.string(), z.unknown()),
521
+ // JSONB from database
522
+ current_step: z.number().int(),
523
+ status: z.string(),
524
+ // Scheduling state
525
+ next_run_at: z.string().nullable(),
526
+ last_run_at: z.string().nullable(),
527
+ last_execution_id: z.string().uuid().nullable(),
528
+ // Config
529
+ max_retries: z.number().int(),
530
+ retry_count: z.number().int(),
531
+ idempotency_key: z.string().nullable(),
532
+ description: z.string().nullable(),
533
+ // Origin tracking
534
+ origin_execution_id: z.string().uuid().nullable(),
535
+ origin_resource_type: z.string().nullable(),
536
+ origin_resource_id: z.string().nullable(),
537
+ // Timestamps (PostgreSQL format with microseconds)
538
+ created_at: z.string(),
539
+ updated_at: z.string()
540
+ })
541
+ ).min(1).max(100)
542
+ });
543
+ z.object({
544
+ id: z.string().uuid("Invalid schedule ID")
545
+ });
546
+ z.object({
547
+ limit: z.coerce.number().int().min(1).max(100).optional().default(20),
548
+ offset: z.coerce.number().int().min(0).optional().default(0)
549
+ });
550
+ var ScheduleResponseSchema = z.object({
551
+ id: z.string().uuid(),
552
+ organizationId: z.string().uuid(),
553
+ name: z.string(),
554
+ description: z.string().nullable(),
555
+ target: z.object({
556
+ resourceType: ResourceTypeSchema,
557
+ resourceId: z.string()
558
+ }),
559
+ scheduleConfig: TaskScheduleConfigSchema,
560
+ nextRunAt: z.string().datetime().nullable(),
561
+ currentStep: z.number().int(),
562
+ status: z.enum(["active", "paused", "completed", "cancelled"]),
563
+ lastRunAt: z.string().datetime().nullable(),
564
+ lastExecutionId: z.string().uuid().nullable(),
565
+ maxRetries: z.number().int(),
566
+ idempotencyKey: z.string().nullable(),
567
+ createdAt: z.string().datetime(),
568
+ updatedAt: z.string().datetime()
569
+ });
570
+ z.object({
571
+ schedules: z.array(ScheduleResponseSchema),
572
+ total: z.number().int(),
573
+ limit: z.number().int(),
574
+ offset: z.number().int()
575
+ });
576
+ var ExecutionHistoryItemSchema = z.object({
577
+ id: z.string().uuid(),
578
+ createdAt: z.string().datetime(),
579
+ status: z.enum(["running", "completed", "failed", "cancelled"]),
580
+ step: z.number().int().nullable(),
581
+ itemLabel: z.string().nullable(),
582
+ duration: z.number().nullable(),
583
+ // milliseconds
584
+ error: z.string().nullable()
585
+ });
586
+ z.object({
587
+ executions: z.array(ExecutionHistoryItemSchema),
588
+ total: z.number().int(),
589
+ limit: z.number().int(),
590
+ offset: z.number().int()
591
+ });
592
+ z.object({
593
+ processed: z.number().int(),
594
+ succeeded: z.number().int(),
595
+ failed: z.number().int(),
596
+ errors: z.array(
597
+ z.object({
598
+ scheduleId: z.string().uuid(),
599
+ error: z.string()
600
+ })
601
+ ).optional()
602
+ });
603
+
604
+ // ../core/src/operations/observability/utils.ts
605
+ function getTimeRangeDates(range) {
606
+ const end = /* @__PURE__ */ new Date();
607
+ const start = /* @__PURE__ */ new Date();
608
+ switch (range) {
609
+ case "1h":
610
+ start.setHours(start.getHours() - 1);
611
+ break;
612
+ case "24h":
613
+ start.setHours(start.getHours() - 24);
614
+ break;
615
+ case "7d":
616
+ start.setDate(start.getDate() - 7);
617
+ break;
618
+ case "30d":
619
+ start.setDate(start.getDate() - 30);
620
+ break;
621
+ }
622
+ return {
623
+ startDate: start.toISOString(),
624
+ endDate: end.toISOString()
625
+ };
626
+ }
627
+
628
+ // src/hooks/monitoring/useCostSummary.ts
629
+ function useCostSummary(timeRange) {
630
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
631
+ return useQuery({
632
+ queryKey: ["cost-analytics", "cost-summary", organizationId, timeRange],
633
+ queryFn: async () => {
634
+ const { startDate, endDate } = getTimeRangeDates(timeRange);
635
+ return apiRequest(
636
+ `/observability/cost-summary?startDate=${startDate}&endDate=${endDate}`
637
+ );
638
+ },
639
+ enabled: isReady,
640
+ refetchInterval: 6e4
641
+ // 60s dashboard polling
642
+ });
643
+ }
644
+ function useExecutionHealth({ timeRange }) {
645
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
646
+ return useQuery({
647
+ queryKey: ["monitoring", "execution-health", organizationId, timeRange],
648
+ queryFn: async () => {
649
+ const { startDate, endDate } = getTimeRangeDates(timeRange);
650
+ return apiRequest(
651
+ `/observability/dashboard?startDate=${startDate}&endDate=${endDate}`
652
+ );
653
+ },
654
+ enabled: isReady,
655
+ refetchInterval: 6e4,
656
+ // 60s dashboard polling
657
+ staleTime: 3e4
658
+ // 30s monitoring stale time
659
+ });
660
+ }
661
+
662
+ // src/hooks/observability/queryKeys.ts
663
+ var observabilityKeys = {
664
+ all: ["observability"],
665
+ // Error analysis
666
+ errorAnalysis: (organizationId, timeRange) => [...observabilityKeys.all, "error-analysis", organizationId, timeRange],
667
+ // Error details list
668
+ errorDetails: (organizationId, filters) => [...observabilityKeys.all, "error-details", organizationId, filters],
669
+ // Single execution error detail
670
+ errorDetail: (organizationId, executionId) => [...observabilityKeys.all, "error-detail", organizationId, executionId],
671
+ // Error trends time-series
672
+ errorTrends: (organizationId, startDate, endDate, granularity) => [...observabilityKeys.all, "error-trends", organizationId, startDate, endDate, granularity],
673
+ // Error distribution breakdown
674
+ errorDistribution: (organizationId, startDate, endDate, groupBy) => [...observabilityKeys.all, "error-distribution", organizationId, startDate, endDate, groupBy],
675
+ // Top failing resources
676
+ topFailingResources: (organizationId, startDate, endDate, limit) => [...observabilityKeys.all, "top-failing-resources", organizationId, startDate, endDate, limit],
677
+ // Cost trends time-series
678
+ costTrends: (organizationId, timeRange, granularity) => [...observabilityKeys.all, "cost-trends", organizationId, timeRange, granularity],
679
+ // Cost by model breakdown
680
+ costByModel: (organizationId, timeRange) => [...observabilityKeys.all, "cost-by-model", organizationId, timeRange],
681
+ // Cost breakdown per resource/model
682
+ costBreakdown: (organizationId, timeRange) => [...observabilityKeys.all, "cost-breakdown", organizationId, timeRange],
683
+ // Composite dashboard metrics
684
+ dashboardMetrics: (organizationId, timeRange) => [...observabilityKeys.all, "dashboard-metrics", organizationId, timeRange],
685
+ // Business impact / automation ROI
686
+ businessImpact: (organizationId, timeRange) => [...observabilityKeys.all, "business-impact", organizationId, timeRange]
687
+ };
688
+ function useErrorAnalysis(timeRange) {
689
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
690
+ return useQuery({
691
+ queryKey: observabilityKeys.errorAnalysis(organizationId, timeRange),
692
+ queryFn: async () => {
693
+ const { startDate, endDate } = getTimeRangeDates(timeRange);
694
+ return apiRequest(`/observability/error-analysis?startDate=${startDate}&endDate=${endDate}`);
695
+ },
696
+ enabled: isReady,
697
+ refetchInterval: 6e4
698
+ });
699
+ }
700
+ function useErrorDetails(filters) {
701
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
702
+ return useQuery({
703
+ queryKey: observabilityKeys.errorDetails(organizationId, filters),
704
+ queryFn: async () => {
705
+ const params = new URLSearchParams();
706
+ if (filters.errorType) params.append("errorType", filters.errorType);
707
+ if (filters.severity) params.append("severity", filters.severity);
708
+ if (filters.search) params.append("search", filters.search);
709
+ if (filters.startDate) params.append("startDate", filters.startDate);
710
+ if (filters.endDate) params.append("endDate", filters.endDate);
711
+ if (filters.page) params.append("page", filters.page.toString());
712
+ if (filters.limit) params.append("limit", filters.limit.toString());
713
+ if (filters.resolved !== void 0) params.append("resolved", filters.resolved.toString());
714
+ const queryString = params.toString();
715
+ const endpoint = `/observability/error-details${queryString ? `?${queryString}` : ""}`;
716
+ return apiRequest(endpoint);
717
+ },
718
+ enabled: isReady,
719
+ refetchInterval: 6e4,
720
+ staleTime: 3e4
721
+ });
722
+ }
723
+ function useErrorDetail(executionId) {
724
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
725
+ return useQuery({
726
+ queryKey: observabilityKeys.errorDetail(organizationId, executionId),
727
+ queryFn: async () => {
728
+ if (!executionId) return null;
729
+ const response = await apiRequest(`/observability/error-details/${executionId}`);
730
+ return response.errors;
731
+ },
732
+ enabled: !!executionId && isReady,
733
+ staleTime: 3e4
734
+ });
735
+ }
736
+ function useErrorTrends({ startDate, endDate, granularity }) {
737
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
738
+ return useQuery({
739
+ queryKey: observabilityKeys.errorTrends(organizationId, startDate, endDate, granularity),
740
+ queryFn: async () => {
741
+ const params = new URLSearchParams({ startDate, endDate, granularity });
742
+ return apiRequest(`/observability/error-analytics/trends?${params.toString()}`);
743
+ },
744
+ enabled: isReady,
745
+ refetchInterval: 6e4,
746
+ staleTime: 3e4
747
+ });
748
+ }
749
+ function useErrorDistribution({ startDate, endDate, groupBy }) {
750
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
751
+ return useQuery({
752
+ queryKey: observabilityKeys.errorDistribution(organizationId, startDate, endDate, groupBy),
753
+ queryFn: async () => {
754
+ const params = new URLSearchParams({ startDate, endDate, groupBy });
755
+ return apiRequest(`/observability/error-analytics/distribution?${params.toString()}`);
756
+ },
757
+ enabled: isReady,
758
+ refetchInterval: 6e4,
759
+ staleTime: 3e4
760
+ });
761
+ }
762
+ function useTopFailingResources({ startDate, endDate, limit = 10 }) {
763
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
764
+ return useQuery({
765
+ queryKey: observabilityKeys.topFailingResources(organizationId, startDate, endDate, limit),
766
+ queryFn: async () => {
767
+ const params = new URLSearchParams({ startDate, endDate, limit: String(limit) });
768
+ return apiRequest(`/observability/error-analytics/top-resources?${params.toString()}`);
769
+ },
770
+ enabled: isReady,
771
+ refetchInterval: 6e4,
772
+ staleTime: 3e4
773
+ });
774
+ }
775
+ function useResolveError() {
776
+ const { apiRequest } = useElevasisServices();
777
+ const queryClient = useQueryClient();
778
+ return useMutation({
779
+ mutationFn: async (errorId) => {
780
+ return apiRequest(`/observability/error-details/${errorId}/resolve`, { method: "PATCH" });
781
+ },
782
+ onSuccess: () => {
783
+ queryClient.invalidateQueries({ queryKey: observabilityKeys.all });
784
+ }
785
+ });
786
+ }
787
+ function useUnresolveError() {
788
+ const { apiRequest } = useElevasisServices();
789
+ const queryClient = useQueryClient();
790
+ return useMutation({
791
+ mutationFn: async (errorId) => {
792
+ return apiRequest(`/observability/error-details/${errorId}/unresolve`, { method: "PATCH" });
793
+ },
794
+ onSuccess: () => {
795
+ queryClient.invalidateQueries({ queryKey: observabilityKeys.all });
796
+ }
797
+ });
798
+ }
799
+ function useResolveAllErrors() {
800
+ const { apiRequest } = useElevasisServices();
801
+ const queryClient = useQueryClient();
802
+ return useMutation({
803
+ mutationFn: async () => {
804
+ return apiRequest("/observability/error-details/resolve-all", { method: "PATCH" });
805
+ },
806
+ onSuccess: () => {
807
+ queryClient.invalidateQueries({ queryKey: observabilityKeys.all });
808
+ }
809
+ });
810
+ }
811
+ function useResolveErrorsByExecution() {
812
+ const { apiRequest } = useElevasisServices();
813
+ const queryClient = useQueryClient();
814
+ return useMutation({
815
+ mutationFn: async (executionId) => {
816
+ return apiRequest(`/observability/error-details/execution/${executionId}/resolve`, { method: "PATCH" });
817
+ },
818
+ onSuccess: () => {
819
+ queryClient.invalidateQueries({ queryKey: observabilityKeys.all });
820
+ }
821
+ });
822
+ }
823
+ function useCostTrends(timeRange, granularity = "day") {
824
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
825
+ return useQuery({
826
+ queryKey: observabilityKeys.costTrends(organizationId, timeRange, granularity),
827
+ queryFn: async () => {
828
+ const { startDate, endDate } = getTimeRangeDates(timeRange);
829
+ const params = new URLSearchParams({ startDate, endDate, granularity });
830
+ return apiRequest(`/observability/cost-trends?${params.toString()}`);
831
+ },
832
+ enabled: isReady,
833
+ refetchInterval: 6e4
834
+ });
835
+ }
836
+ function useCostByModel(timeRange) {
837
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
838
+ return useQuery({
839
+ queryKey: observabilityKeys.costByModel(organizationId, timeRange),
840
+ queryFn: async () => {
841
+ const { startDate, endDate } = getTimeRangeDates(timeRange);
842
+ const params = new URLSearchParams({ startDate, endDate });
843
+ return apiRequest(`/observability/cost-by-model?${params.toString()}`);
844
+ },
845
+ enabled: isReady,
846
+ refetchInterval: 6e4
847
+ });
848
+ }
849
+ function useCostBreakdown(timeRange) {
850
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
851
+ return useQuery({
852
+ queryKey: observabilityKeys.costBreakdown(organizationId, timeRange),
853
+ queryFn: async () => {
854
+ const { startDate, endDate } = getTimeRangeDates(timeRange);
855
+ const params = new URLSearchParams({ startDate, endDate });
856
+ return apiRequest(`/observability/cost-breakdown?${params.toString()}`);
857
+ },
858
+ enabled: isReady,
859
+ refetchInterval: 6e4
860
+ });
861
+ }
862
+ function useDashboardMetrics(timeRange) {
863
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
864
+ return useQuery({
865
+ queryKey: observabilityKeys.dashboardMetrics(organizationId, timeRange),
866
+ queryFn: async () => {
867
+ const { startDate, endDate } = getTimeRangeDates(timeRange);
868
+ const params = new URLSearchParams({ startDate, endDate });
869
+ return apiRequest(`/observability/dashboard?${params.toString()}`);
870
+ },
871
+ enabled: isReady,
872
+ refetchInterval: 6e4
873
+ });
874
+ }
875
+ function useBusinessImpact(timeRange) {
876
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
877
+ return useQuery({
878
+ queryKey: observabilityKeys.businessImpact(organizationId, timeRange),
879
+ queryFn: async () => {
880
+ const { startDate, endDate } = getTimeRangeDates(timeRange);
881
+ const params = new URLSearchParams({ startDate, endDate });
882
+ return apiRequest(`/observability/business-impact?${params.toString()}`);
883
+ },
884
+ enabled: isReady,
885
+ refetchInterval: 6e4
886
+ });
887
+ }
888
+
889
+ // src/hooks/scheduling/queryKeys.ts
890
+ var scheduleKeys = {
891
+ all: (orgId) => ["schedules", orgId],
892
+ lists: (orgId) => [...scheduleKeys.all(orgId), "list"],
893
+ list: (orgId, filters) => [...scheduleKeys.lists(orgId), filters],
894
+ details: (orgId) => [...scheduleKeys.all(orgId), "detail"],
895
+ detail: (orgId, id) => [...scheduleKeys.details(orgId), id],
896
+ executions: (orgId, id) => [...scheduleKeys.detail(orgId, id), "executions"]
897
+ };
898
+ function useListSchedules(filters) {
899
+ const { apiRequest, organizationId, isReady } = useElevasisServices();
900
+ return useQuery({
901
+ queryKey: scheduleKeys.list(organizationId, filters),
902
+ queryFn: async () => {
903
+ const params = new URLSearchParams();
904
+ if (filters?.status) params.set("status", filters.status);
905
+ if (filters?.targetResourceType) params.set("targetResourceType", filters.targetResourceType);
906
+ if (filters?.targetResourceId) params.set("targetResourceId", filters.targetResourceId);
907
+ if (filters?.limit) params.set("limit", String(filters.limit));
908
+ if (filters?.offset) params.set("offset", String(filters.offset));
909
+ const queryString = params.toString();
910
+ const endpoint = `/task-scheduler/schedules${queryString ? `?${queryString}` : ""}`;
911
+ return apiRequest(endpoint);
912
+ },
913
+ enabled: isReady
914
+ });
915
+ }
916
+ function useGetSchedule(id) {
917
+ const { apiRequest, organizationId, isReady } = useElevasisServices();
918
+ return useQuery({
919
+ queryKey: scheduleKeys.detail(organizationId, id),
920
+ queryFn: async () => {
921
+ const data = await apiRequest(`/task-scheduler/schedules/${id}`);
922
+ return data.schedule;
923
+ },
924
+ enabled: isReady && !!id
925
+ });
926
+ }
927
+ function useGetExecutionHistory(scheduleId, options) {
928
+ const { apiRequest, organizationId, isReady } = useElevasisServices();
929
+ return useQuery({
930
+ queryKey: [...scheduleKeys.executions(organizationId, scheduleId), options?.limit, options?.offset],
931
+ queryFn: async () => {
932
+ const params = new URLSearchParams();
933
+ if (options?.limit) params.set("limit", String(options.limit));
934
+ if (options?.offset) params.set("offset", String(options.offset));
935
+ const queryString = params.toString();
936
+ const endpoint = `/task-scheduler/schedules/${scheduleId}/executions${queryString ? `?${queryString}` : ""}`;
937
+ return apiRequest(endpoint);
938
+ },
939
+ enabled: isReady && !!scheduleId
940
+ });
941
+ }
942
+ function useCreateSchedule() {
943
+ const queryClient = useQueryClient();
944
+ const { apiRequest, organizationId } = useElevasisServices();
945
+ return useMutation({
946
+ mutationFn: async (input) => {
947
+ const validated = CreateScheduleRequestSchema.parse(input);
948
+ const data = await apiRequest("/task-scheduler/schedules", {
949
+ method: "POST",
950
+ body: JSON.stringify(validated)
951
+ });
952
+ return data.schedule;
953
+ },
954
+ onSuccess: () => {
955
+ queryClient.invalidateQueries({ queryKey: scheduleKeys.lists(organizationId) });
956
+ }
957
+ });
958
+ }
959
+ function useUpdateSchedule() {
960
+ const queryClient = useQueryClient();
961
+ const { apiRequest, organizationId } = useElevasisServices();
962
+ return useMutation({
963
+ mutationFn: async ({ id, ...fields }) => {
964
+ GetScheduleParamsSchema.parse({ id });
965
+ const validated = UpdateScheduleRequestSchema.parse(fields);
966
+ const data = await apiRequest(`/task-scheduler/schedules/${id}`, {
967
+ method: "PATCH",
968
+ body: JSON.stringify(validated)
969
+ });
970
+ return data.schedule;
971
+ },
972
+ onSuccess: (_, variables) => {
973
+ queryClient.invalidateQueries({
974
+ queryKey: scheduleKeys.detail(organizationId, variables.id)
975
+ });
976
+ queryClient.invalidateQueries({ queryKey: scheduleKeys.lists(organizationId) });
977
+ }
978
+ });
979
+ }
980
+ function useUpdateAnchor() {
981
+ const queryClient = useQueryClient();
982
+ const { apiRequest, organizationId } = useElevasisServices();
983
+ return useMutation({
984
+ mutationFn: async ({ id, anchorAt }) => {
985
+ GetScheduleParamsSchema.parse({ id });
986
+ UpdateAnchorRequestSchema.parse({ anchorAt });
987
+ const data = await apiRequest(`/task-scheduler/schedules/${id}/anchor`, {
988
+ method: "PATCH",
989
+ body: JSON.stringify({ anchorAt })
990
+ });
991
+ return data.schedule;
992
+ },
993
+ onSuccess: (_, variables) => {
994
+ queryClient.invalidateQueries({
995
+ queryKey: scheduleKeys.detail(organizationId, variables.id)
996
+ });
997
+ queryClient.invalidateQueries({ queryKey: scheduleKeys.lists(organizationId) });
998
+ }
999
+ });
1000
+ }
1001
+ function usePauseSchedule() {
1002
+ const queryClient = useQueryClient();
1003
+ const { apiRequest, organizationId } = useElevasisServices();
1004
+ return useMutation({
1005
+ mutationFn: async (id) => {
1006
+ GetScheduleParamsSchema.parse({ id });
1007
+ const data = await apiRequest(`/task-scheduler/schedules/${id}/pause`, {
1008
+ method: "POST"
1009
+ });
1010
+ return data.schedule;
1011
+ },
1012
+ onSuccess: (_, id) => {
1013
+ queryClient.invalidateQueries({ queryKey: scheduleKeys.detail(organizationId, id) });
1014
+ queryClient.invalidateQueries({ queryKey: scheduleKeys.lists(organizationId) });
1015
+ }
1016
+ });
1017
+ }
1018
+ function useResumeSchedule() {
1019
+ const queryClient = useQueryClient();
1020
+ const { apiRequest, organizationId } = useElevasisServices();
1021
+ return useMutation({
1022
+ mutationFn: async (id) => {
1023
+ GetScheduleParamsSchema.parse({ id });
1024
+ const data = await apiRequest(`/task-scheduler/schedules/${id}/resume`, {
1025
+ method: "POST"
1026
+ });
1027
+ return data.schedule;
1028
+ },
1029
+ onSuccess: (_, id) => {
1030
+ queryClient.invalidateQueries({ queryKey: scheduleKeys.detail(organizationId, id) });
1031
+ queryClient.invalidateQueries({ queryKey: scheduleKeys.lists(organizationId) });
1032
+ }
1033
+ });
1034
+ }
1035
+ function useCancelSchedule() {
1036
+ const queryClient = useQueryClient();
1037
+ const { apiRequest, organizationId } = useElevasisServices();
1038
+ return useMutation({
1039
+ mutationFn: async (id) => {
1040
+ GetScheduleParamsSchema.parse({ id });
1041
+ const data = await apiRequest(`/task-scheduler/schedules/${id}/cancel`, {
1042
+ method: "POST"
1043
+ });
1044
+ return data.schedule;
1045
+ },
1046
+ onSuccess: (_, id) => {
1047
+ queryClient.invalidateQueries({ queryKey: scheduleKeys.detail(organizationId, id) });
1048
+ queryClient.invalidateQueries({ queryKey: scheduleKeys.lists(organizationId) });
1049
+ }
1050
+ });
1051
+ }
1052
+ function useDeleteSchedule() {
1053
+ const queryClient = useQueryClient();
1054
+ const { apiRequest, organizationId } = useElevasisServices();
1055
+ return useMutation({
1056
+ mutationFn: async (id) => {
1057
+ GetScheduleParamsSchema.parse({ id });
1058
+ await apiRequest(`/task-scheduler/schedules/${id}`, { method: "DELETE" });
1059
+ },
1060
+ onSuccess: (_, id) => {
1061
+ queryClient.invalidateQueries({ queryKey: scheduleKeys.detail(organizationId, id) });
1062
+ queryClient.invalidateQueries({ queryKey: scheduleKeys.lists(organizationId) });
1063
+ }
1064
+ });
1065
+ }
1066
+
1067
+ export { OperationsService, executionsKeys, observabilityKeys, scheduleKeys, useActivities, useActivityTrend, useBulkDeleteExecutions, useBusinessImpact, useCancelExecution, useCancelSchedule, useCostBreakdown, useCostByModel, useCostSummary, useCostTrends, useCreateSchedule, useDashboardMetrics, useDeleteExecution, useDeleteSchedule, useErrorAnalysis, useErrorDetail, useErrorDetails, useErrorDistribution, useErrorTrends, useExecuteAsync, useExecution, useExecutionHealth, useExecutionLogs, useExecutions, useGetExecutionHistory, useGetSchedule, useListSchedules, usePauseSchedule, useResolveAllErrors, useResolveError, useResolveErrorsByExecution, useResourceDefinition, useResources, useResumeSchedule, useRetryExecution, useTopFailingResources, useUnresolveError, useUpdateAnchor, useUpdateSchedule };