@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.
- package/dist/api/index.d.ts +87 -0
- package/dist/api/index.js +3 -0
- package/dist/auth/context.d.ts +19 -0
- package/dist/auth/context.js +1 -0
- package/dist/auth/index.d.ts +85 -0
- package/dist/auth/index.js +3 -0
- package/dist/chunk-3KMDHCAR.js +52 -0
- package/dist/chunk-5UWFGBFM.js +129 -0
- package/dist/chunk-6BJOYF6E.js +8 -0
- package/dist/chunk-6M6OLGQY.js +36 -0
- package/dist/chunk-7AI5ZYJ4.js +202 -0
- package/dist/chunk-7PLEQFHO.js +18 -0
- package/dist/chunk-GDV44UWF.js +138 -0
- package/dist/chunk-GEFB5YIR.js +338 -0
- package/dist/chunk-HBRMWW6V.js +43 -0
- package/dist/chunk-HUWJXLLF.js +681 -0
- package/dist/chunk-J3FALDQE.js +176 -0
- package/dist/chunk-JKERRYVS.js +109 -0
- package/dist/chunk-KA7LO7U5.js +28 -0
- package/dist/chunk-LHQTTUL2.js +27 -0
- package/dist/chunk-MAAS6CGR.js +1299 -0
- package/dist/chunk-NE36BUGQ.js +146 -0
- package/dist/chunk-NGXCFBCS.js +398 -0
- package/dist/chunk-OEYU5O27.js +235 -0
- package/dist/chunk-OUHGHTE7.js +748 -0
- package/dist/chunk-OXVOHOP3.js +661 -0
- package/dist/chunk-PSLKGOBZ.js +58 -0
- package/dist/chunk-PYL4XW6H.js +107 -0
- package/dist/chunk-Q47SPRY7.js +1 -0
- package/dist/chunk-Q7DJKLEN.js +18 -0
- package/dist/chunk-RJCA5672.js +1664 -0
- package/dist/chunk-S66I2PYB.js +748 -0
- package/dist/chunk-W7ZBF5AA.js +1 -0
- package/dist/chunk-WNWKOCGJ.js +1067 -0
- package/dist/chunk-XCYKC6OZ.js +1 -0
- package/dist/chunk-YULUKCS6.js +56 -0
- package/dist/chunk-YZ6GTZXL.js +48 -0
- package/dist/chunk-ZGHDPDTF.js +379 -0
- package/dist/components/command-queue/index.css +53 -0
- package/dist/components/command-queue/index.d.ts +204 -0
- package/dist/components/command-queue/index.js +10 -0
- package/dist/components/forms/index.d.ts +56 -0
- package/dist/components/forms/index.js +2 -0
- package/dist/components/index.css +443 -0
- package/dist/components/index.d.ts +1354 -0
- package/dist/components/index.js +18 -0
- package/dist/components/monitoring/index.d.ts +66 -0
- package/dist/components/monitoring/index.js +2 -0
- package/dist/components/navigation/index.d.ts +54 -0
- package/dist/components/navigation/index.js +91 -0
- package/dist/components/notifications/index.d.ts +52 -0
- package/dist/components/notifications/index.js +4 -0
- package/dist/components/resource-definition/index.css +388 -0
- package/dist/components/resource-definition/index.d.ts +301 -0
- package/dist/components/resource-definition/index.js +3 -0
- package/dist/display/index.css +53 -0
- package/dist/display/index.d.ts +606 -0
- package/dist/display/index.js +6 -0
- package/dist/execution/index.css +388 -0
- package/dist/execution/index.d.ts +1090 -0
- package/dist/execution/index.js +4 -0
- package/dist/graph/index.css +388 -0
- package/dist/graph/index.d.ts +429 -0
- package/dist/graph/index.js +1 -0
- package/dist/hooks/index.d.ts +1927 -0
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/published.d.ts +1653 -0
- package/dist/hooks/published.js +4 -0
- package/dist/index.css +505 -0
- package/dist/index.d.ts +7284 -0
- package/dist/index.js +31 -0
- package/dist/initialization/index.d.ts +2325 -0
- package/dist/initialization/index.js +4 -0
- package/dist/organization/index.d.ts +225 -0
- package/dist/organization/index.js +4 -0
- package/dist/profile/index.d.ts +2265 -0
- package/dist/profile/index.js +3 -0
- package/dist/provider/index.css +61 -0
- package/dist/provider/index.d.ts +291 -0
- package/dist/provider/index.js +7 -0
- package/dist/provider/published.d.ts +198 -0
- package/dist/provider/published.js +6 -0
- package/dist/router/context.d.ts +19 -0
- package/dist/router/context.js +1 -0
- package/dist/router/index.d.ts +31 -0
- package/dist/router/index.js +2 -0
- package/dist/sse/index.d.ts +83 -0
- package/dist/sse/index.js +185 -0
- package/dist/supabase/index.d.ts +4289 -0
- package/dist/supabase/index.js +47 -0
- package/dist/typeform/index.d.ts +458 -0
- package/dist/typeform/index.js +1976 -0
- package/dist/typeform/schemas.d.ts +67 -0
- package/dist/typeform/schemas.js +1 -0
- package/dist/utils/index.d.ts +177 -0
- package/dist/utils/index.js +1 -0
- 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 };
|