@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,83 @@
1
+ interface EventSourceMessage {
2
+ id: string;
3
+ event: string;
4
+ data: string;
5
+ retry?: number;
6
+ }
7
+
8
+ interface FetchEventSourceWithTokenRefreshOptions {
9
+ url: string;
10
+ getToken: () => Promise<string | undefined>;
11
+ headers?: Record<string, string>;
12
+ signal: AbortSignal;
13
+ /** Delay in ms before reconnecting after token refresh. Defaults to 2000. */
14
+ tokenRefreshDelayMs?: number;
15
+ onopen?: (response: Response) => void | Promise<void>;
16
+ onmessage?: (event: EventSourceMessage) => void;
17
+ onerror?: (error: unknown) => void;
18
+ onclose?: () => void;
19
+ }
20
+ /**
21
+ * Wrapper around fetchEventSource that handles token expiration and automatic retry with fresh token.
22
+ *
23
+ * When a 401 response is received:
24
+ * 1. Aborts current connection
25
+ * 2. Waits for tokenRefreshDelayMs (default 2s)
26
+ * 3. Fetches fresh token
27
+ * 4. Reconnects with new token
28
+ */
29
+ declare function fetchEventSourceWithTokenRefresh(options: FetchEventSourceWithTokenRefreshOptions): Promise<void>;
30
+
31
+ interface SSEConnectionManagerOptions {
32
+ /** Grace period in ms before closing idle connections. Defaults to 5000. */
33
+ closeGracePeriodMs?: number;
34
+ }
35
+ /**
36
+ * SSE Connection Manager
37
+ *
38
+ * Ensures only ONE SSE connection exists per endpoint, preventing duplicate
39
+ * connections when components re-render or remount.
40
+ *
41
+ * Benefits:
42
+ * - Prevents resource waste from duplicate connections
43
+ * - Eliminates race conditions from overlapping connections
44
+ * - Automatically manages connection lifecycle
45
+ * - Shares single connection across multiple subscribers
46
+ */
47
+ declare class SSEConnectionManager {
48
+ private connections;
49
+ private closeGracePeriodMs;
50
+ constructor(options?: SSEConnectionManagerOptions);
51
+ /**
52
+ * Subscribe to an SSE endpoint
53
+ *
54
+ * If a connection already exists for this endpoint, reuses it.
55
+ * Otherwise, creates a new connection.
56
+ *
57
+ * @param key - Unique identifier for the connection (e.g., 'notifications', 'resource-executive-agent')
58
+ * @param subscriberId - Unique identifier for this subscriber (usually component instance)
59
+ * @param options - SSE connection options
60
+ * @returns Unsubscribe function to call when component unmounts
61
+ */
62
+ subscribe(key: string, subscriberId: string, options: Omit<FetchEventSourceWithTokenRefreshOptions, 'signal'>): () => void;
63
+ /**
64
+ * Unsubscribe from an SSE endpoint
65
+ *
66
+ * If this is the last subscriber, closes the connection after grace period.
67
+ */
68
+ private unsubscribe;
69
+ /**
70
+ * Force close a connection and all its subscribers
71
+ */
72
+ closeConnection(key: string): void;
73
+ /**
74
+ * Get current connection status
75
+ */
76
+ getConnectionInfo(): Map<string, {
77
+ url: string;
78
+ subscribers: number;
79
+ }>;
80
+ }
81
+
82
+ export { SSEConnectionManager, fetchEventSourceWithTokenRefresh };
83
+ export type { FetchEventSourceWithTokenRefreshOptions, SSEConnectionManagerOptions };
@@ -0,0 +1,185 @@
1
+ import { fetchEventSource } from '@microsoft/fetch-event-source';
2
+
3
+ // src/sse/fetchEventSourceWithTokenRefresh.ts
4
+ async function fetchEventSourceWithTokenRefresh(options) {
5
+ const {
6
+ url,
7
+ getToken,
8
+ headers: additionalHeaders,
9
+ signal,
10
+ tokenRefreshDelayMs = 2e3,
11
+ onopen,
12
+ onmessage,
13
+ onerror,
14
+ onclose
15
+ } = options;
16
+ let reconnectTimeout = null;
17
+ let isActive = true;
18
+ let controller = new AbortController();
19
+ let shouldReconnect = false;
20
+ let hasConnected = false;
21
+ const cleanup = () => {
22
+ isActive = false;
23
+ shouldReconnect = false;
24
+ controller.abort();
25
+ if (reconnectTimeout) {
26
+ clearTimeout(reconnectTimeout);
27
+ reconnectTimeout = null;
28
+ }
29
+ };
30
+ signal.addEventListener("abort", cleanup);
31
+ const connect = async () => {
32
+ if (!isActive || signal.aborted) {
33
+ return;
34
+ }
35
+ shouldReconnect = false;
36
+ const token = await getToken();
37
+ const headers = {
38
+ ...token ? { Authorization: `Bearer ${token}` } : {},
39
+ ...additionalHeaders
40
+ };
41
+ try {
42
+ await fetchEventSource(url, {
43
+ method: "GET",
44
+ headers,
45
+ signal: controller.signal,
46
+ async onopen(response) {
47
+ if (response.ok && response.headers.get("content-type")?.includes("text/event-stream")) {
48
+ if (!hasConnected) {
49
+ hasConnected = true;
50
+ }
51
+ if (onopen) {
52
+ await onopen(response);
53
+ }
54
+ return;
55
+ }
56
+ if (response.status === 401) {
57
+ shouldReconnect = true;
58
+ hasConnected = false;
59
+ controller.abort();
60
+ return;
61
+ }
62
+ throw new Error(`Unexpected response: ${response.status}`);
63
+ },
64
+ onmessage(event) {
65
+ onmessage?.(event);
66
+ },
67
+ onerror(error) {
68
+ if (error instanceof Error && error.name === "AbortError") {
69
+ throw error;
70
+ }
71
+ onerror?.(error);
72
+ },
73
+ onclose() {
74
+ onclose?.();
75
+ }
76
+ });
77
+ } catch (error) {
78
+ if (error instanceof Error && error.name === "AbortError" && shouldReconnect) {
79
+ if (isActive && !reconnectTimeout && !signal.aborted) {
80
+ reconnectTimeout = setTimeout(() => {
81
+ controller = new AbortController();
82
+ reconnectTimeout = null;
83
+ connect();
84
+ }, tokenRefreshDelayMs);
85
+ }
86
+ return;
87
+ }
88
+ if (error instanceof Error && error.name === "AbortError") {
89
+ return;
90
+ }
91
+ throw error;
92
+ }
93
+ };
94
+ await connect();
95
+ }
96
+
97
+ // src/sse/SSEConnectionManager.ts
98
+ var SSEConnectionManager = class {
99
+ connections = /* @__PURE__ */ new Map();
100
+ closeGracePeriodMs;
101
+ constructor(options = {}) {
102
+ this.closeGracePeriodMs = options.closeGracePeriodMs ?? 5e3;
103
+ }
104
+ /**
105
+ * Subscribe to an SSE endpoint
106
+ *
107
+ * If a connection already exists for this endpoint, reuses it.
108
+ * Otherwise, creates a new connection.
109
+ *
110
+ * @param key - Unique identifier for the connection (e.g., 'notifications', 'resource-executive-agent')
111
+ * @param subscriberId - Unique identifier for this subscriber (usually component instance)
112
+ * @param options - SSE connection options
113
+ * @returns Unsubscribe function to call when component unmounts
114
+ */
115
+ subscribe(key, subscriberId, options) {
116
+ const existing = this.connections.get(key);
117
+ if (existing) {
118
+ if (existing.closeTimeout) {
119
+ clearTimeout(existing.closeTimeout);
120
+ existing.closeTimeout = void 0;
121
+ }
122
+ existing.subscribers.add(subscriberId);
123
+ } else {
124
+ const controller = new AbortController();
125
+ this.connections.set(key, {
126
+ controller,
127
+ subscribers: /* @__PURE__ */ new Set([subscriberId]),
128
+ url: options.url
129
+ });
130
+ fetchEventSourceWithTokenRefresh({
131
+ ...options,
132
+ signal: controller.signal
133
+ });
134
+ }
135
+ return () => this.unsubscribe(key, subscriberId);
136
+ }
137
+ /**
138
+ * Unsubscribe from an SSE endpoint
139
+ *
140
+ * If this is the last subscriber, closes the connection after grace period.
141
+ */
142
+ unsubscribe(key, subscriberId) {
143
+ const connection = this.connections.get(key);
144
+ if (!connection) {
145
+ return;
146
+ }
147
+ connection.subscribers.delete(subscriberId);
148
+ if (connection.subscribers.size === 0 && !connection.closeTimeout) {
149
+ connection.closeTimeout = setTimeout(() => {
150
+ const current = this.connections.get(key);
151
+ if (current && current.subscribers.size === 0) {
152
+ this.closeConnection(key);
153
+ }
154
+ }, this.closeGracePeriodMs);
155
+ }
156
+ }
157
+ /**
158
+ * Force close a connection and all its subscribers
159
+ */
160
+ closeConnection(key) {
161
+ const connection = this.connections.get(key);
162
+ if (connection) {
163
+ if (connection.closeTimeout) {
164
+ clearTimeout(connection.closeTimeout);
165
+ }
166
+ connection.controller.abort();
167
+ this.connections.delete(key);
168
+ }
169
+ }
170
+ /**
171
+ * Get current connection status
172
+ */
173
+ getConnectionInfo() {
174
+ const info = /* @__PURE__ */ new Map();
175
+ this.connections.forEach((connection, key) => {
176
+ info.set(key, {
177
+ url: connection.url,
178
+ subscribers: connection.subscribers.size
179
+ });
180
+ });
181
+ return info;
182
+ }
183
+ };
184
+
185
+ export { SSEConnectionManager, fetchEventSourceWithTokenRefresh };