@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,176 @@
1
+ import { useElevasisServices } from './chunk-KA7LO7U5.js';
2
+ import { showApiErrorNotification } from './chunk-7AI5ZYJ4.js';
3
+ import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
4
+ import { notifications } from '@mantine/notifications';
5
+
6
+ function useCommandQueue({
7
+ status,
8
+ limit,
9
+ offset,
10
+ humanCheckpoint,
11
+ timeRange,
12
+ priorityMin,
13
+ priorityMax
14
+ } = {}) {
15
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
16
+ return useQuery({
17
+ queryKey: ["command-queue", "list", organizationId, status, humanCheckpoint, timeRange, priorityMin, priorityMax, limit, offset],
18
+ queryFn: async () => {
19
+ const params = new URLSearchParams();
20
+ if (status) params.set("status", status);
21
+ if (humanCheckpoint) params.set("humanCheckpoint", humanCheckpoint);
22
+ if (timeRange) params.set("timeRange", timeRange);
23
+ if (priorityMin !== void 0) params.set("priorityMin", String(priorityMin));
24
+ if (priorityMax !== void 0) params.set("priorityMax", String(priorityMax));
25
+ if (limit !== void 0) params.set("limit", String(limit));
26
+ if (offset !== void 0) params.set("offset", String(offset));
27
+ const response = await apiRequest(
28
+ `/command-queue?${params.toString()}`
29
+ );
30
+ return response.tasks.map((task) => ({
31
+ ...task,
32
+ createdAt: new Date(task.createdAt),
33
+ completedAt: task.completedAt ? new Date(task.completedAt) : void 0,
34
+ expiresAt: task.expiresAt ? new Date(task.expiresAt) : void 0
35
+ }));
36
+ },
37
+ enabled: isReady
38
+ });
39
+ }
40
+ function useSubmitAction() {
41
+ const { apiRequest } = useElevasisServices();
42
+ const queryClient = useQueryClient();
43
+ return useMutation({
44
+ mutationFn: async ({ taskId, actionId, payload, notes }) => {
45
+ const response = await apiRequest(`/command-queue/${taskId}/action`, {
46
+ method: "POST",
47
+ body: JSON.stringify({
48
+ actionId,
49
+ payload,
50
+ notes
51
+ })
52
+ });
53
+ return response;
54
+ },
55
+ onMutate: async ({ taskId }) => {
56
+ await queryClient.cancelQueries({ queryKey: ["command-queue", "list"] });
57
+ const previousData = /* @__PURE__ */ new Map();
58
+ const queries = queryClient.getQueriesData({ queryKey: ["command-queue", "list"] });
59
+ for (const [queryKey, data] of queries) {
60
+ previousData.set(queryKey, data);
61
+ if (data) {
62
+ queryClient.setQueryData(
63
+ queryKey,
64
+ (old) => old?.map((task) => task.id === taskId ? { ...task, status: "processing" } : task)
65
+ );
66
+ }
67
+ }
68
+ return { previousData };
69
+ },
70
+ onSuccess: () => {
71
+ queryClient.invalidateQueries({ queryKey: ["command-queue"] });
72
+ },
73
+ onError: (_error, _variables, context) => {
74
+ if (context?.previousData) {
75
+ for (const [queryKey, data] of context.previousData) {
76
+ queryClient.setQueryData(queryKey, data);
77
+ }
78
+ }
79
+ }
80
+ });
81
+ }
82
+ function useDeleteTask() {
83
+ const { apiRequest } = useElevasisServices();
84
+ const queryClient = useQueryClient();
85
+ return useMutation({
86
+ mutationFn: async (taskId) => {
87
+ await apiRequest(`/command-queue/${taskId}`, {
88
+ method: "DELETE"
89
+ });
90
+ },
91
+ onMutate: async (taskId) => {
92
+ await queryClient.cancelQueries({ queryKey: ["command-queue", "list"] });
93
+ const previousData = /* @__PURE__ */ new Map();
94
+ const queries = queryClient.getQueriesData({ queryKey: ["command-queue", "list"] });
95
+ for (const [queryKey, data] of queries) {
96
+ previousData.set(queryKey, data);
97
+ if (data) {
98
+ queryClient.setQueryData(
99
+ queryKey,
100
+ (old) => old?.filter((task) => task.id !== taskId)
101
+ );
102
+ }
103
+ }
104
+ return { previousData };
105
+ },
106
+ onSuccess: () => {
107
+ notifications.show({
108
+ title: "Task Deleted",
109
+ message: "Task has been removed",
110
+ color: "green"
111
+ });
112
+ queryClient.invalidateQueries({ queryKey: ["command-queue"] });
113
+ },
114
+ onError: (error, _taskId, context) => {
115
+ if (context?.previousData) {
116
+ for (const [queryKey, data] of context.previousData) {
117
+ queryClient.setQueryData(queryKey, data);
118
+ }
119
+ }
120
+ showApiErrorNotification(error);
121
+ }
122
+ });
123
+ }
124
+ function useCommandQueueTotals({
125
+ timeRange = "24h",
126
+ priorityMin,
127
+ priorityMax,
128
+ status
129
+ } = {}) {
130
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
131
+ return useQuery({
132
+ queryKey: ["command-queue", "checkpoints", organizationId, timeRange, priorityMin, priorityMax, status],
133
+ queryFn: async () => {
134
+ const params = new URLSearchParams();
135
+ params.set("timeRange", timeRange);
136
+ if (priorityMin !== void 0) params.set("priorityMin", String(priorityMin));
137
+ if (priorityMax !== void 0) params.set("priorityMax", String(priorityMax));
138
+ if (status) params.set("status", status);
139
+ return apiRequest(`/command-queue/checkpoints?${params.toString()}`);
140
+ },
141
+ enabled: isReady,
142
+ staleTime: 3e4
143
+ // 30s monitoring stale time
144
+ });
145
+ }
146
+ function usePatchTask() {
147
+ const { apiRequest } = useElevasisServices();
148
+ const queryClient = useQueryClient();
149
+ return useMutation({
150
+ mutationFn: async ({ taskId, params }) => {
151
+ const response = await apiRequest(`/command-queue/${taskId}`, {
152
+ method: "PATCH",
153
+ headers: { "Content-Type": "application/json" },
154
+ body: JSON.stringify(params)
155
+ });
156
+ return response.task;
157
+ },
158
+ onSuccess: (updatedTask) => {
159
+ const deserialized = {
160
+ ...updatedTask,
161
+ createdAt: new Date(updatedTask.createdAt),
162
+ completedAt: updatedTask.completedAt ? new Date(updatedTask.completedAt) : void 0,
163
+ expiresAt: updatedTask.expiresAt ? new Date(updatedTask.expiresAt) : void 0
164
+ };
165
+ queryClient.setQueriesData(
166
+ { queryKey: ["command-queue", "list"] },
167
+ (old) => old?.map((t) => t.id === deserialized.id ? { ...t, ...deserialized } : t)
168
+ );
169
+ },
170
+ onError: (error) => {
171
+ showApiErrorNotification(error);
172
+ }
173
+ });
174
+ }
175
+
176
+ export { useCommandQueue, useCommandQueueTotals, useDeleteTask, usePatchTask, useSubmitAction };
@@ -0,0 +1,109 @@
1
+ import { useElevasisServices } from './chunk-KA7LO7U5.js';
2
+ import { showApiErrorNotification } from './chunk-7AI5ZYJ4.js';
3
+ import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query';
4
+ import { z } from 'zod';
5
+
6
+ var UuidSchema = z.string().uuid();
7
+ var NonEmptyStringSchema = z.string().trim().min(1).max(1e3);
8
+ var ResourceTypeSchema = z.enum(["agent", "workflow"]);
9
+ var OriginResourceTypeSchema = z.enum(["agent", "workflow", "scheduler", "api"]);
10
+ z.string().trim().toLowerCase().min(1, "Credential name required").max(100, "Credential name too long (max 100 chars)").regex(
11
+ /^[a-z0-9]+(-[a-z0-9]+)+$/,
12
+ "Credential name must be lowercase letters, numbers, and hyphens in format: service-environment (e.g., gmail-prod, attio-dev)"
13
+ );
14
+ z.enum(["google-sheets", "dropbox"]);
15
+ z.string().min(10, "Authorization code too short").max(1e3, "Authorization code too long");
16
+ z.string().min(10, "State parameter too short").max(2048, "State parameter too long");
17
+ z.string().trim().transform((str) => str.replace(/[<>'"]/g, ""));
18
+ z.string().email();
19
+ z.string().url();
20
+ z.object({
21
+ limit: z.coerce.number().int().min(1).max(100).default(20),
22
+ offset: z.coerce.number().int().min(0).default(0)
23
+ });
24
+ z.string().datetime();
25
+ z.object({
26
+ startDate: z.string().datetime(),
27
+ endDate: z.string().datetime()
28
+ });
29
+ var NotificationCategorySchema = z.enum(["info", "queue", "alert", "error", "system"]);
30
+ var GetNotificationsQuerySchema = z.object({
31
+ limit: z.coerce.number().int().min(1).max(100).default(50),
32
+ offset: z.coerce.number().int().min(0).default(0)
33
+ });
34
+ var MarkAsReadParamsSchema = z.object({
35
+ id: UuidSchema
36
+ });
37
+ z.object({
38
+ userId: UuidSchema,
39
+ organizationId: UuidSchema,
40
+ category: NotificationCategorySchema,
41
+ title: z.string().trim().min(1).max(200),
42
+ message: z.string().trim().min(1).max(1e3),
43
+ actionUrl: z.string().url().optional()
44
+ }).strict();
45
+
46
+ // src/hooks/notifications/useMarkAsRead.ts
47
+ function useMarkAsRead() {
48
+ const queryClient = useQueryClient();
49
+ const { apiRequest } = useElevasisServices();
50
+ return useMutation({
51
+ mutationFn: async (notificationId) => {
52
+ MarkAsReadParamsSchema.parse({ id: notificationId });
53
+ await apiRequest(`/notifications/${notificationId}/read`, {
54
+ method: "PATCH"
55
+ });
56
+ },
57
+ onSuccess: () => {
58
+ queryClient.invalidateQueries({ queryKey: ["notifications"] });
59
+ },
60
+ onError: (error) => {
61
+ showApiErrorNotification(error);
62
+ }
63
+ });
64
+ }
65
+ function useMarkAllAsRead() {
66
+ const queryClient = useQueryClient();
67
+ const { apiRequest } = useElevasisServices();
68
+ return useMutation({
69
+ mutationFn: async () => {
70
+ await apiRequest("/notifications/mark-all-read", {
71
+ method: "PATCH"
72
+ });
73
+ },
74
+ onSuccess: () => {
75
+ queryClient.invalidateQueries({ queryKey: ["notifications"] });
76
+ },
77
+ onError: (error) => {
78
+ showApiErrorNotification(error);
79
+ }
80
+ });
81
+ }
82
+ function useNotifications({ limit = 20, offset = 0 } = {}) {
83
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
84
+ return useQuery({
85
+ queryKey: ["notifications", organizationId, { limit, offset }],
86
+ queryFn: async () => {
87
+ const params = GetNotificationsQuerySchema.parse({ limit, offset });
88
+ const response = await apiRequest(
89
+ `/notifications?limit=${params.limit}&offset=${params.offset}`
90
+ );
91
+ return response;
92
+ },
93
+ enabled: isReady
94
+ });
95
+ }
96
+ function useNotificationCount() {
97
+ const { apiRequest, isReady, organizationId } = useElevasisServices();
98
+ return useQuery({
99
+ queryKey: ["notifications", "unread-count", organizationId],
100
+ queryFn: async () => {
101
+ const response = await apiRequest("/notifications/unread-count");
102
+ return response.count;
103
+ },
104
+ enabled: isReady,
105
+ staleTime: 3e4
106
+ });
107
+ }
108
+
109
+ export { NonEmptyStringSchema, OriginResourceTypeSchema, ResourceTypeSchema, UuidSchema, useMarkAllAsRead, useMarkAsRead, useNotificationCount, useNotifications };
@@ -0,0 +1,28 @@
1
+ import { createContext, useContext, useMemo } from 'react';
2
+ import { jsx } from 'react/jsx-runtime';
3
+
4
+ // src/provider/ElevasisServiceContext.tsx
5
+ var ElevasisServiceContext = createContext(null);
6
+ function useElevasisServices() {
7
+ const ctx = useContext(ElevasisServiceContext);
8
+ if (!ctx) {
9
+ throw new Error(
10
+ "useElevasisServices must be used within an ElevasisServiceProvider or an ElevasisProvider with apiUrl configured."
11
+ );
12
+ }
13
+ return ctx;
14
+ }
15
+ function ElevasisServiceProvider({
16
+ apiRequest,
17
+ organizationId,
18
+ isReady,
19
+ children
20
+ }) {
21
+ const value = useMemo(
22
+ () => ({ apiRequest, organizationId, isReady }),
23
+ [apiRequest, organizationId, isReady]
24
+ );
25
+ return /* @__PURE__ */ jsx(ElevasisServiceContext.Provider, { value, children });
26
+ }
27
+
28
+ export { ElevasisServiceProvider, useElevasisServices };
@@ -0,0 +1,27 @@
1
+ import { RouterProvider } from './chunk-Q7DJKLEN.js';
2
+ import { useLocation, useRouter, Link } from '@tanstack/react-router';
3
+ import { useCallback, useMemo, forwardRef } from 'react';
4
+ import { jsx } from 'react/jsx-runtime';
5
+
6
+ function TanStackRouterBridge({ children }) {
7
+ const location = useLocation();
8
+ const router = useRouter();
9
+ const navigate = useCallback((to) => router.navigate({ to }), [router]);
10
+ const Link$1 = useMemo(
11
+ () => forwardRef(function AdapterLink(props, ref) {
12
+ return /* @__PURE__ */ jsx(Link, { ref, ...props });
13
+ }),
14
+ []
15
+ );
16
+ const value = useMemo(
17
+ () => ({
18
+ currentPath: location.pathname,
19
+ navigate,
20
+ Link: Link$1
21
+ }),
22
+ [location.pathname, navigate, Link$1]
23
+ );
24
+ return /* @__PURE__ */ jsx(RouterProvider, { value, children });
25
+ }
26
+
27
+ export { TanStackRouterBridge };