@gravity-rail/sdk 0.8.0 → 0.11.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 (46) hide show
  1. package/README.md +45 -8
  2. package/dist/chunk-FSSXKQR5.js +471 -0
  3. package/dist/chunk-FSSXKQR5.js.map +1 -0
  4. package/dist/{chunk-QS6ZRQUZ.js → chunk-V7ZKEH4V.js} +8 -1
  5. package/dist/chunk-V7ZKEH4V.js.map +1 -0
  6. package/dist/{chunk-ML55PVP7.js → chunk-YESHLUL7.js} +1435 -703
  7. package/dist/chunk-YESHLUL7.js.map +1 -0
  8. package/dist/{client-C2aWAalu.d.cts → client-BCgXtr8p.d.cts} +3684 -1291
  9. package/dist/{client-CLGovEox.d.ts → client-Dh1l20Ue.d.ts} +3684 -1291
  10. package/dist/helpers.cjs +177 -13
  11. package/dist/helpers.cjs.map +1 -1
  12. package/dist/helpers.d.cts +82 -3
  13. package/dist/helpers.d.ts +82 -3
  14. package/dist/helpers.js +155 -12
  15. package/dist/helpers.js.map +1 -1
  16. package/dist/index.cjs +1679 -420
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +32 -24
  19. package/dist/index.d.ts +32 -24
  20. package/dist/index.js +193 -113
  21. package/dist/index.js.map +1 -1
  22. package/dist/internal.cjs +1742 -413
  23. package/dist/internal.cjs.map +1 -1
  24. package/dist/internal.d.cts +634 -29
  25. package/dist/internal.d.ts +634 -29
  26. package/dist/internal.js +140 -7
  27. package/dist/internal.js.map +1 -1
  28. package/dist/realtime.cjs +43 -0
  29. package/dist/realtime.cjs.map +1 -1
  30. package/dist/realtime.d.cts +26 -0
  31. package/dist/realtime.d.ts +26 -0
  32. package/dist/realtime.js +43 -0
  33. package/dist/realtime.js.map +1 -1
  34. package/dist/{scopes-D6a_Mvqr.d.ts → revision-state-BTF-MnbW.d.cts} +270 -23
  35. package/dist/{scopes-CDaJBQVT.d.cts → revision-state-DOH1NMGb.d.ts} +270 -23
  36. package/dist/schemas.cjs +56 -117
  37. package/dist/schemas.cjs.map +1 -1
  38. package/dist/schemas.d.cts +121 -484
  39. package/dist/schemas.d.ts +121 -484
  40. package/dist/schemas.js +55 -114
  41. package/dist/schemas.js.map +1 -1
  42. package/dist/{inquiries-CmECZnkl.d.cts → tasks-C4aYbWVv.d.cts} +944 -148
  43. package/dist/{inquiries-CmECZnkl.d.ts → tasks-C4aYbWVv.d.ts} +944 -148
  44. package/package.json +5 -5
  45. package/dist/chunk-ML55PVP7.js.map +0 -1
  46. package/dist/chunk-QS6ZRQUZ.js.map +0 -1
package/README.md CHANGED
@@ -366,13 +366,51 @@ const clientWs = await client.createClientWorkspace(workspaceId, {
366
366
  await client.provisionClientWorkspace(workspaceId, clientWs.id);
367
367
  ```
368
368
 
369
+ ## Helpers (`@gravity-rail/sdk/helpers`)
370
+
371
+ Small compound operations built on the client methods, for the common
372
+ "register → populate a form → enroll → verify webhooks" integration flow:
373
+
374
+ ```typescript
375
+ import {
376
+ // member resolution + enrollment
377
+ resolveMemberId, // { memberId | phone | externalId } → member id
378
+ findOrCreateMemberLabels, // idempotent label lookup/create → ids
379
+ upsertDataRecordForMember,// idempotent member-scoped record write
380
+ enrollMemberInJourney, // resolve member → tag → enroll (409 = already enrolled)
381
+ // outbound calling
382
+ findMemberByPhone,
383
+ resolveOutboundPhoneNumberId,
384
+ resolveOutboundWorkflowId,
385
+ // webhook signatures (isomorphic HMAC-SHA256; verify the RAW body)
386
+ verifyWebhookSignature,
387
+ signWebhookPayload,
388
+ WEBHOOK_SIGNATURE_HEADER,
389
+ } from '@gravity-rail/sdk/helpers';
390
+
391
+ // Enroll into a journey by any identifier, applying cohort labels:
392
+ await enrollMemberInJourney(client, workspaceUuid, {
393
+ externalId: 'patient-123',
394
+ journeyId,
395
+ labels: ['pilot-cohort'],
396
+ });
397
+
398
+ // Verify an inbound webhook in your POST handler:
399
+ const result = await verifyWebhookSignature(
400
+ rawBody,
401
+ request.headers.get(WEBHOOK_SIGNATURE_HEADER),
402
+ signingSecret,
403
+ );
404
+ if (!result.ok) return new Response(result.reason, { status: 401 });
405
+ ```
406
+
369
407
  ## Type System
370
408
 
371
409
  Full TypeScript types for every API entity:
372
410
 
373
411
  ```typescript
374
412
  import type {
375
- Workspace, Member, Chat, Task, Workflow, Assistant,
413
+ Workspace, Member, Chat, Task, WorkflowRevision, Assistant,
376
414
  DataType, DataRecord, EventRule, Calendar, Site,
377
415
  PhoneNumber, Inbox, OperatorGroup, Qualification,
378
416
  Subscription, ApiKey, Agent, MemberRole,
@@ -426,14 +464,13 @@ try {
426
464
  }
427
465
  ```
428
466
 
429
- ## Compliance
430
-
431
- Gravity Rail is built for HIPAA compliance. The SDK enforces:
467
+ ## Security and PHI Use
432
468
 
433
- - **Data isolation** — every workspace has a dedicated database schema
434
- - **Scoped access** — API keys enforce granular permissions at the scope level
435
- - **Feature flags** — workspaces can enable `HIPAA_COMPLIANCE` for stricter data handling
436
- - **Audit trails** — all operations are logged for compliance reporting
469
+ The SDK provides scoped API access to workspace-isolated resources. Those
470
+ technical properties do not by themselves authorize PHI use or establish HIPAA
471
+ compliance. Before sending PHI, obtain a signed BAA and confirmation from
472
+ Gravity Rail that the intended organization, workspaces, and services are
473
+ configured for that use.
437
474
 
438
475
  ## Related
439
476
 
@@ -0,0 +1,471 @@
1
+ // src/api/base.ts
2
+ function getCookieValue(name) {
3
+ if (typeof document === "undefined") return void 0;
4
+ const cookies = document.cookie.split(";");
5
+ for (const cookie of cookies) {
6
+ const trimmedCookie = cookie.trim();
7
+ const eqIndex = trimmedCookie.indexOf("=");
8
+ if (eqIndex === -1) continue;
9
+ const cookieName = trimmedCookie.substring(0, eqIndex);
10
+ const cookieValue = trimmedCookie.substring(eqIndex + 1);
11
+ if (cookieName === name) {
12
+ return cookieValue;
13
+ }
14
+ }
15
+ return void 0;
16
+ }
17
+ function isApiValidationError(value) {
18
+ if (!value || typeof value !== "object") return false;
19
+ const v = value;
20
+ return typeof v.field === "string" && typeof v.kind === "string" && typeof v.message === "string";
21
+ }
22
+ var ApiError = class extends Error {
23
+ statusCode;
24
+ /** Legacy string-array errors — kept for non-validation callers. */
25
+ errors;
26
+ /**
27
+ * Structured workflow-expression validation errors (CEL/Jinja).
28
+ * Populated when the backend returns a WorkflowValidationErrorResponse.
29
+ */
30
+ validationErrors;
31
+ constructor(message, statusCode, errors, validationErrors) {
32
+ super(message);
33
+ this.statusCode = statusCode;
34
+ this.errors = errors;
35
+ this.validationErrors = validationErrors;
36
+ }
37
+ };
38
+ function requiresStepUpAuth(wwwAuthenticate) {
39
+ if (!wwwAuthenticate) return false;
40
+ return wwwAuthenticate.includes('error="insufficient_user_authentication"');
41
+ }
42
+ function parseOrgAuthChallenge(wwwAuthenticate) {
43
+ if (!wwwAuthenticate) return null;
44
+ if (!wwwAuthenticate.includes('realm="org"')) return null;
45
+ const orgUuidMatch = wwwAuthenticate.match(/org_uuid="([^"]+)"/);
46
+ const cookieNameMatch = wwwAuthenticate.match(/cookie_name="([^"]+)"/);
47
+ const authUrlMatch = wwwAuthenticate.match(/auth_url="([^"]+)"/);
48
+ if (!orgUuidMatch?.[1] || !cookieNameMatch?.[1] || !authUrlMatch?.[1]) {
49
+ console.warn("Invalid org auth challenge header: missing required fields");
50
+ return null;
51
+ }
52
+ return {
53
+ orgUuid: orgUuidMatch[1],
54
+ cookieName: cookieNameMatch[1],
55
+ authUrl: authUrlMatch[1]
56
+ };
57
+ }
58
+ function getRequestOrgCookieName(cookieName) {
59
+ if (cookieName.startsWith("orgToken")) {
60
+ return cookieName.replace(/^orgToken/, "requestOrgToken");
61
+ }
62
+ if (cookieName.startsWith("orgSession")) {
63
+ return cookieName.replace(/^orgSession/, "requestOrgSession");
64
+ }
65
+ return null;
66
+ }
67
+ function orgAuthHeaderName(token) {
68
+ return token.startsWith("gr_sess_") ? "X-Org-Session" : "X-Org-Token";
69
+ }
70
+ function setOrgAuthHeader(headers, token) {
71
+ if (!token) return;
72
+ headers.set(orgAuthHeaderName(token), token);
73
+ }
74
+ var BaseApiClient = class {
75
+ baseUrl;
76
+ apiKey;
77
+ isCrossDomain;
78
+ fetchFunction;
79
+ enhancedAuthHandler;
80
+ enhancedAuthInProgress = null;
81
+ orgAuthHandler;
82
+ orgAuthInProgress = null;
83
+ actingMemberUuid;
84
+ orgSession;
85
+ /**
86
+ * The org_uuid that issued the current org auth credential. Tracked so we can detect
87
+ * a 401 challenge from a *different* org and re-fire the handler — the
88
+ * credential is opaque to the client, so without this the original guard
89
+ * `!this.orgSession` would prevent re-auth across orgs and surface as a silent
90
+ * 401 in multi-org CLI workflows.
91
+ */
92
+ orgSessionOrgUuid;
93
+ constructor(apiKey, baseUrl, customFetch) {
94
+ this.baseUrl = baseUrl;
95
+ this.apiKey = apiKey;
96
+ this.fetchFunction = customFetch || (typeof window !== "undefined" ? fetch.bind(window) : fetch);
97
+ const apiUrlParsed = new URL(baseUrl);
98
+ const currentOrigin = typeof window !== "undefined" ? window.location.origin : "";
99
+ this.isCrossDomain = currentOrigin !== "" && currentOrigin !== apiUrlParsed.origin;
100
+ }
101
+ /**
102
+ * Set the handler for enhanced authentication requirements (RFC 9470 Step-Up Auth).
103
+ * This handler is called when a 401 response includes WWW-Authenticate header
104
+ * with error="insufficient_user_authentication".
105
+ */
106
+ setEnhancedAuthHandler(handler) {
107
+ this.enhancedAuthHandler = handler;
108
+ }
109
+ /**
110
+ * Set the handler for organization authentication requirements.
111
+ * This handler is called when a 401 response includes WWW-Authenticate header
112
+ * with realm="org". The handler should redirect the user to complete org auth.
113
+ */
114
+ setOrgAuthHandler(handler) {
115
+ this.orgAuthHandler = handler;
116
+ }
117
+ /**
118
+ * Update the API key (used after successful re-authentication).
119
+ */
120
+ updateApiKey(newApiKey) {
121
+ this.apiKey = newApiKey;
122
+ }
123
+ /**
124
+ * Set the acting member UUID for member identity switching.
125
+ * When set, all API requests will include the X-Acting-Member header.
126
+ * The backend will validate that the authenticated account owns this member
127
+ * and use it as the effective identity for the request.
128
+ */
129
+ setActingMember(memberUuid) {
130
+ this.actingMemberUuid = memberUuid;
131
+ }
132
+ /**
133
+ * Get the current acting member UUID.
134
+ */
135
+ getActingMember() {
136
+ return this.actingMemberUuid;
137
+ }
138
+ /**
139
+ * Set the opaque org session credential for cross-domain requests.
140
+ * Opaque gr_sess_ values use X-Org-Session. Legacy orgToken JWE values still
141
+ * use X-Org-Token through setOrgToken() during the migration window.
142
+ *
143
+ * `orgUuid` is the org that issued the credential; passing it lets the 401
144
+ * handler detect a stale session when a subsequent request targets a
145
+ * different org and re-fire the org-auth handler instead of silently
146
+ * 401-ing. Callers without that context (legacy / unknown) may omit it.
147
+ */
148
+ setOrgSession(session, orgUuid) {
149
+ this.orgSession = session;
150
+ this.orgSessionOrgUuid = session ? orgUuid : void 0;
151
+ }
152
+ /**
153
+ * @deprecated Legacy compatibility for stateless orgToken JWE credentials.
154
+ * Prefer setOrgSession() for opaque org browser sessions.
155
+ */
156
+ setOrgToken(token, orgUuid) {
157
+ this.setOrgSession(token, orgUuid);
158
+ }
159
+ async fetch(endpoint, options) {
160
+ try {
161
+ const headers = new Headers({
162
+ // Don't set Content-Type for FormData — the browser must set it
163
+ // with the multipart boundary automatically.
164
+ ...options?.body instanceof FormData ? {} : { "Content-Type": "application/json" },
165
+ ...options?.headers || {}
166
+ });
167
+ if (this.apiKey) {
168
+ headers.set("Authorization", `Bearer ${this.apiKey}`);
169
+ } else if (this.isCrossDomain) {
170
+ const requestToken = getCookieValue("requestToken");
171
+ if (requestToken) {
172
+ headers.set("Authorization", `Bearer ${requestToken}`);
173
+ }
174
+ }
175
+ if (this.actingMemberUuid) {
176
+ headers.set("X-Acting-Member", this.actingMemberUuid);
177
+ }
178
+ setOrgAuthHeader(headers, this.orgSession);
179
+ const fullUrl = `${this.baseUrl}/api/v2/${endpoint}`;
180
+ const response = await this.fetchFunction(fullUrl, {
181
+ ...options,
182
+ ...this.apiKey ? {} : { credentials: "include" },
183
+ ...this.isCrossDomain ? { mode: "cors" } : {},
184
+ headers
185
+ });
186
+ if (!response.ok) {
187
+ if (response.status === 401 && requiresStepUpAuth(response.headers.get("WWW-Authenticate")) && this.enhancedAuthHandler) {
188
+ if (this.enhancedAuthInProgress) {
189
+ await this.enhancedAuthInProgress;
190
+ } else {
191
+ this.enhancedAuthInProgress = this.enhancedAuthHandler();
192
+ try {
193
+ const newToken = await this.enhancedAuthInProgress;
194
+ this.apiKey = newToken;
195
+ } finally {
196
+ this.enhancedAuthInProgress = null;
197
+ }
198
+ }
199
+ try {
200
+ return await this.fetch(endpoint, options);
201
+ } catch (retryError) {
202
+ this.orgSession = void 0;
203
+ this.orgSessionOrgUuid = void 0;
204
+ throw retryError;
205
+ }
206
+ }
207
+ if (response.status === 401) {
208
+ const orgAuthInfo = parseOrgAuthChallenge(response.headers.get("WWW-Authenticate"));
209
+ if (orgAuthInfo && this.orgSession && this.orgSessionOrgUuid && this.orgSessionOrgUuid !== orgAuthInfo.orgUuid) {
210
+ this.orgSession = void 0;
211
+ this.orgSessionOrgUuid = void 0;
212
+ }
213
+ if (orgAuthInfo && !this.orgSession) {
214
+ const requestCookieName = getRequestOrgCookieName(orgAuthInfo.cookieName);
215
+ const cachedOrgSession = requestCookieName ? getCookieValue(requestCookieName) : void 0;
216
+ if (cachedOrgSession) {
217
+ this.orgSession = cachedOrgSession;
218
+ this.orgSessionOrgUuid = orgAuthInfo.orgUuid;
219
+ try {
220
+ return await this.fetch(endpoint, options);
221
+ } catch (retryError) {
222
+ this.orgSession = void 0;
223
+ this.orgSessionOrgUuid = void 0;
224
+ throw retryError;
225
+ }
226
+ }
227
+ if (this.orgAuthHandler) {
228
+ if (!this.orgAuthInProgress) {
229
+ const handler = this.orgAuthHandler;
230
+ this.orgAuthInProgress = (async () => {
231
+ try {
232
+ await handler(orgAuthInfo);
233
+ } finally {
234
+ this.orgAuthInProgress = null;
235
+ }
236
+ })();
237
+ }
238
+ await this.orgAuthInProgress;
239
+ const postHandlerSession = (requestCookieName ? getCookieValue(requestCookieName) : void 0) ?? this.orgSession;
240
+ if (!postHandlerSession) {
241
+ throw new ApiError(
242
+ "Organization authentication did not issue a session",
243
+ 401
244
+ );
245
+ }
246
+ this.orgSession = postHandlerSession;
247
+ this.orgSessionOrgUuid = orgAuthInfo.orgUuid;
248
+ try {
249
+ return await this.fetch(endpoint, options);
250
+ } catch (retryError) {
251
+ this.orgSession = void 0;
252
+ this.orgSessionOrgUuid = void 0;
253
+ throw retryError;
254
+ }
255
+ }
256
+ }
257
+ }
258
+ const errorData = await response.json().catch(() => ({}));
259
+ if (response.status === 401 && endpoint === "account") {
260
+ throw new Error("unauthorized");
261
+ }
262
+ if (Array.isArray(errorData.detail)) {
263
+ const formattedErrors = errorData.detail.map((error) => {
264
+ const location = error.loc.join(" > ");
265
+ return `${location}: ${error.msg}`;
266
+ }).join("\n");
267
+ throw new ApiError(`Validation Error:
268
+ ${formattedErrors}`, response.status);
269
+ }
270
+ if (errorData.errors && Array.isArray(errorData.errors)) {
271
+ if (errorData.errors.length > 0 && isApiValidationError(errorData.errors[0])) {
272
+ const validationErrors = errorData.errors.filter(isApiValidationError);
273
+ const [first] = validationErrors;
274
+ if (first) {
275
+ const extra = validationErrors.length > 1 ? ` (+${validationErrors.length - 1} more)` : "";
276
+ const readable = `${first.field}: ${first.message}${extra}`;
277
+ throw new ApiError(
278
+ readable,
279
+ response.status,
280
+ validationErrors.map((e) => `${e.field}: ${e.message}`),
281
+ validationErrors
282
+ );
283
+ }
284
+ }
285
+ const stringErrors = errorData.errors.filter(
286
+ (e) => typeof e === "string"
287
+ );
288
+ const details = stringErrors.join("; ");
289
+ const message = errorData.detail ? `${errorData.detail}: ${details}` : `Validation failed: ${details}`;
290
+ throw new ApiError(message, response.status, stringErrors);
291
+ }
292
+ const structuredError = errorData.detail || errorData;
293
+ if (structuredError && typeof structuredError === "object" && (structuredError.error === true || structuredError.code)) {
294
+ const message = structuredError.message || structuredError.code || "Unknown error";
295
+ const error = new ApiError(message, response.status);
296
+ error.errorData = structuredError;
297
+ throw error;
298
+ }
299
+ const errorMessage = typeof errorData.detail === "string" ? errorData.detail : errorData.message || response.statusText;
300
+ throw new ApiError(errorMessage, response.status);
301
+ }
302
+ if (response.status === 204) {
303
+ return void 0;
304
+ }
305
+ return response.json();
306
+ } catch (error) {
307
+ console.warn(error);
308
+ throw error;
309
+ }
310
+ }
311
+ async fetchRaw(endpoint, options, allowedErrorStatuses = []) {
312
+ try {
313
+ const headers = new Headers({
314
+ ...options?.headers || {}
315
+ });
316
+ if (this.apiKey) {
317
+ headers.set("Authorization", `Bearer ${this.apiKey}`);
318
+ } else if (this.isCrossDomain) {
319
+ const requestToken = getCookieValue("requestToken");
320
+ if (requestToken) {
321
+ headers.set("Authorization", `Bearer ${requestToken}`);
322
+ }
323
+ }
324
+ if (this.actingMemberUuid) {
325
+ headers.set("X-Acting-Member", this.actingMemberUuid);
326
+ }
327
+ setOrgAuthHeader(headers, this.orgSession);
328
+ const response = await this.fetchFunction(`${this.baseUrl}/api/v2/${endpoint}`, {
329
+ ...options,
330
+ ...this.apiKey ? {} : { credentials: "include" },
331
+ ...this.isCrossDomain ? { mode: "cors" } : {},
332
+ headers
333
+ });
334
+ if (!response.ok) {
335
+ if (response.status === 401 && requiresStepUpAuth(response.headers.get("WWW-Authenticate")) && this.enhancedAuthHandler) {
336
+ if (this.enhancedAuthInProgress) {
337
+ await this.enhancedAuthInProgress;
338
+ } else {
339
+ this.enhancedAuthInProgress = this.enhancedAuthHandler();
340
+ try {
341
+ const newToken = await this.enhancedAuthInProgress;
342
+ this.apiKey = newToken;
343
+ } finally {
344
+ this.enhancedAuthInProgress = null;
345
+ }
346
+ }
347
+ try {
348
+ return await this.fetchRaw(endpoint, options, allowedErrorStatuses);
349
+ } catch (retryError) {
350
+ this.orgSession = void 0;
351
+ this.orgSessionOrgUuid = void 0;
352
+ throw retryError;
353
+ }
354
+ }
355
+ if (response.status === 401) {
356
+ const orgAuthInfo = parseOrgAuthChallenge(response.headers.get("WWW-Authenticate"));
357
+ if (orgAuthInfo && this.orgSession && this.orgSessionOrgUuid && this.orgSessionOrgUuid !== orgAuthInfo.orgUuid) {
358
+ this.orgSession = void 0;
359
+ this.orgSessionOrgUuid = void 0;
360
+ }
361
+ if (orgAuthInfo && !this.orgSession) {
362
+ const requestCookieName = getRequestOrgCookieName(orgAuthInfo.cookieName);
363
+ const cachedOrgSession = requestCookieName ? getCookieValue(requestCookieName) : void 0;
364
+ if (cachedOrgSession) {
365
+ this.orgSession = cachedOrgSession;
366
+ this.orgSessionOrgUuid = orgAuthInfo.orgUuid;
367
+ try {
368
+ return await this.fetchRaw(endpoint, options, allowedErrorStatuses);
369
+ } catch (retryError) {
370
+ this.orgSession = void 0;
371
+ this.orgSessionOrgUuid = void 0;
372
+ throw retryError;
373
+ }
374
+ }
375
+ if (this.orgAuthHandler) {
376
+ if (!this.orgAuthInProgress) {
377
+ const handler = this.orgAuthHandler;
378
+ this.orgAuthInProgress = (async () => {
379
+ try {
380
+ await handler(orgAuthInfo);
381
+ } finally {
382
+ this.orgAuthInProgress = null;
383
+ }
384
+ })();
385
+ }
386
+ await this.orgAuthInProgress;
387
+ const postHandlerSession = (requestCookieName ? getCookieValue(requestCookieName) : void 0) ?? this.orgSession;
388
+ if (!postHandlerSession) {
389
+ throw new ApiError(
390
+ "Organization authentication did not issue a session",
391
+ 401
392
+ );
393
+ }
394
+ this.orgSession = postHandlerSession;
395
+ this.orgSessionOrgUuid = orgAuthInfo.orgUuid;
396
+ try {
397
+ return await this.fetchRaw(endpoint, options, allowedErrorStatuses);
398
+ } catch (retryError) {
399
+ this.orgSession = void 0;
400
+ this.orgSessionOrgUuid = void 0;
401
+ throw retryError;
402
+ }
403
+ }
404
+ }
405
+ }
406
+ if (allowedErrorStatuses.includes(response.status)) {
407
+ return response;
408
+ }
409
+ const errorText = await response.text().catch(() => "");
410
+ throw new ApiError(errorText || response.statusText, response.status);
411
+ }
412
+ return response;
413
+ } catch (error) {
414
+ console.warn(error);
415
+ throw error;
416
+ }
417
+ }
418
+ /**
419
+ * Fetch from root path (not prefixed with /api/v2/)
420
+ * Used for OAuth and other non-API endpoints
421
+ */
422
+ async fetchRoot(path, options) {
423
+ try {
424
+ const headers = new Headers({
425
+ ...options?.body instanceof FormData ? {} : { "Content-Type": "application/json" },
426
+ ...options?.headers || {}
427
+ });
428
+ if (this.apiKey) {
429
+ headers.set("Authorization", `Bearer ${this.apiKey}`);
430
+ } else if (this.isCrossDomain) {
431
+ const requestToken = getCookieValue("requestToken");
432
+ if (requestToken) {
433
+ headers.set("Authorization", `Bearer ${requestToken}`);
434
+ }
435
+ }
436
+ if (this.actingMemberUuid) {
437
+ headers.set("X-Acting-Member", this.actingMemberUuid);
438
+ }
439
+ setOrgAuthHeader(headers, this.orgSession);
440
+ const fullUrl = `${this.baseUrl}/${path}`;
441
+ const response = await this.fetchFunction(fullUrl, {
442
+ ...options,
443
+ ...this.apiKey ? {} : { credentials: "include" },
444
+ ...this.isCrossDomain ? { mode: "cors" } : {},
445
+ headers
446
+ });
447
+ if (!response.ok) {
448
+ if (response.status === 404) {
449
+ return null;
450
+ }
451
+ const errorData = await response.json().catch(() => ({}));
452
+ const errorMessage = errorData.detail || errorData.message || response.statusText;
453
+ throw new ApiError(errorMessage, response.status);
454
+ }
455
+ if (response.status === 204) {
456
+ return void 0;
457
+ }
458
+ return response.json();
459
+ } catch (error) {
460
+ console.warn(error);
461
+ throw error;
462
+ }
463
+ }
464
+ };
465
+
466
+ export {
467
+ getCookieValue,
468
+ ApiError,
469
+ BaseApiClient
470
+ };
471
+ //# sourceMappingURL=chunk-FSSXKQR5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/api/base.ts"],"sourcesContent":["// Utility function to read a specific cookie value\nexport function getCookieValue(name: string): string | undefined {\n if (typeof document === 'undefined') return undefined;\n\n const cookies = document.cookie.split(';');\n for (const cookie of cookies) {\n const trimmedCookie = cookie.trim();\n const eqIndex = trimmedCookie.indexOf('=');\n if (eqIndex === -1) continue;\n\n const cookieName = trimmedCookie.substring(0, eqIndex);\n const cookieValue = trimmedCookie.substring(eqIndex + 1);\n\n if (cookieName === name) {\n return cookieValue;\n }\n }\n\n return undefined;\n}\n\n/**\n * Structured validation error returned by the backend's workflow-expression\n * validator (CEL / Jinja schema checks). See WorkflowValidationErrorResponse\n * in workflowValidationTypes.ts for the public-facing shape.\n */\nexport interface ApiValidationError {\n field: string;\n kind: 'cel_syntax' | 'cel_schema' | 'jinja_syntax' | 'jinja_schema';\n message: string;\n offendingPath: string | null;\n location: {\n start: number;\n end: number;\n line: number;\n column: number;\n length: number;\n } | null;\n suggestion: string | null;\n}\n\nfunction isApiValidationError(value: unknown): value is ApiValidationError {\n if (!value || typeof value !== 'object') return false;\n const v = value as Record<string, unknown>;\n return (\n typeof v.field === 'string' && typeof v.kind === 'string' && typeof v.message === 'string'\n );\n}\n\nexport class ApiError extends Error {\n statusCode: number;\n /** Legacy string-array errors — kept for non-validation callers. */\n errors?: string[];\n /**\n * Structured workflow-expression validation errors (CEL/Jinja).\n * Populated when the backend returns a WorkflowValidationErrorResponse.\n */\n validationErrors?: ApiValidationError[];\n\n constructor(\n message: string,\n statusCode: number,\n errors?: string[],\n validationErrors?: ApiValidationError[]\n ) {\n super(message);\n this.statusCode = statusCode;\n this.errors = errors;\n this.validationErrors = validationErrors;\n }\n}\n\n/**\n * Handler for enhanced authentication requirement (RFC 9470 Step-Up Authentication).\n * Called when a 401 response includes WWW-Authenticate header with\n * error=\"insufficient_user_authentication\".\n * Should return a promise that resolves with the new auth token after re-auth.\n */\nexport type EnhancedAuthHandler = () => Promise<string>;\n\n/**\n * Info parsed from WWW-Authenticate header for org auth requirement.\n */\nexport interface OrgAuthInfo {\n orgUuid: string;\n cookieName: string;\n authUrl: string;\n}\n\n/**\n * Handler for organization authentication requirement.\n * Called when a 401 response includes WWW-Authenticate header with realm=\"org\".\n * The handler should redirect the user to the auth URL for consent/SSO.\n * Returns a promise that resolves when the user should retry (after page reload with cookie).\n */\nexport type OrgAuthHandler = (info: OrgAuthInfo) => Promise<void>;\n\n/**\n * Check if a WWW-Authenticate header indicates step-up authentication is required.\n * Per RFC 9470, this is indicated by error=\"insufficient_user_authentication\".\n */\nfunction requiresStepUpAuth(wwwAuthenticate: string | null): boolean {\n if (!wwwAuthenticate) return false;\n return wwwAuthenticate.includes('error=\"insufficient_user_authentication\"');\n}\n\n/**\n * Parse org auth info from WWW-Authenticate header.\n * Returns null if this is not an org auth challenge.\n * Expected format: Bearer realm=\"org\", org_uuid=\"...\", cookie_name=\"...\", auth_url=\"...\"\n */\nfunction parseOrgAuthChallenge(wwwAuthenticate: string | null): OrgAuthInfo | null {\n if (!wwwAuthenticate) return null;\n if (!wwwAuthenticate.includes('realm=\"org\"')) return null;\n\n // Parse the key-value pairs from the header\n const orgUuidMatch = wwwAuthenticate.match(/org_uuid=\"([^\"]+)\"/);\n const cookieNameMatch = wwwAuthenticate.match(/cookie_name=\"([^\"]+)\"/);\n const authUrlMatch = wwwAuthenticate.match(/auth_url=\"([^\"]+)\"/);\n\n if (!orgUuidMatch?.[1] || !cookieNameMatch?.[1] || !authUrlMatch?.[1]) {\n // Don't log the raw header value — it embeds org_uuid + auth_url.\n console.warn('Invalid org auth challenge header: missing required fields');\n return null;\n }\n\n return {\n orgUuid: orgUuidMatch[1],\n cookieName: cookieNameMatch[1],\n authUrl: authUrlMatch[1],\n };\n}\n\nfunction getRequestOrgCookieName(cookieName: string): string | null {\n if (cookieName.startsWith('orgToken')) {\n return cookieName.replace(/^orgToken/, 'requestOrgToken');\n }\n if (cookieName.startsWith('orgSession')) {\n return cookieName.replace(/^orgSession/, 'requestOrgSession');\n }\n return null;\n}\n\nfunction orgAuthHeaderName(token: string): 'X-Org-Token' | 'X-Org-Session' {\n return token.startsWith('gr_sess_') ? 'X-Org-Session' : 'X-Org-Token';\n}\n\nfunction setOrgAuthHeader(headers: Headers, token: string | undefined): void {\n if (!token) return;\n headers.set(orgAuthHeaderName(token), token);\n}\n\nexport class BaseApiClient {\n protected baseUrl: string;\n protected apiKey: string | undefined;\n protected isCrossDomain: boolean;\n protected fetchFunction: typeof fetch;\n private enhancedAuthHandler?: EnhancedAuthHandler;\n private enhancedAuthInProgress: Promise<string> | null = null;\n private orgAuthHandler?: OrgAuthHandler;\n private orgAuthInProgress: Promise<void> | null = null;\n private actingMemberUuid?: string;\n private orgSession?: string;\n /**\n * The org_uuid that issued the current org auth credential. Tracked so we can detect\n * a 401 challenge from a *different* org and re-fire the handler — the\n * credential is opaque to the client, so without this the original guard\n * `!this.orgSession` would prevent re-auth across orgs and surface as a silent\n * 401 in multi-org CLI workflows.\n */\n private orgSessionOrgUuid?: string;\n\n constructor(apiKey: string | undefined, baseUrl: string, customFetch?: typeof fetch) {\n this.baseUrl = baseUrl;\n this.apiKey = apiKey;\n // console.log('[BaseApiClient] constructor - baseUrl:', baseUrl);\n // Bind fetch to its proper context (window in browser, global in Node)\n this.fetchFunction =\n customFetch || (typeof window !== 'undefined' ? fetch.bind(window) : fetch);\n\n // Determine if we're making cross-domain requests by comparing current origin to API origin\n const apiUrlParsed = new URL(baseUrl);\n const currentOrigin = typeof window !== 'undefined' ? window.location.origin : '';\n this.isCrossDomain = currentOrigin !== '' && currentOrigin !== apiUrlParsed.origin;\n // console.log('[BaseApiClient] isCrossDomain:', this.isCrossDomain, 'currentOrigin:', currentOrigin, 'apiOrigin:', apiUrlParsed.origin);\n }\n\n /**\n * Set the handler for enhanced authentication requirements (RFC 9470 Step-Up Auth).\n * This handler is called when a 401 response includes WWW-Authenticate header\n * with error=\"insufficient_user_authentication\".\n */\n setEnhancedAuthHandler(handler: EnhancedAuthHandler | undefined) {\n this.enhancedAuthHandler = handler;\n }\n\n /**\n * Set the handler for organization authentication requirements.\n * This handler is called when a 401 response includes WWW-Authenticate header\n * with realm=\"org\". The handler should redirect the user to complete org auth.\n */\n setOrgAuthHandler(handler: OrgAuthHandler | undefined) {\n this.orgAuthHandler = handler;\n }\n\n /**\n * Update the API key (used after successful re-authentication).\n */\n updateApiKey(newApiKey: string) {\n this.apiKey = newApiKey;\n }\n\n /**\n * Set the acting member UUID for member identity switching.\n * When set, all API requests will include the X-Acting-Member header.\n * The backend will validate that the authenticated account owns this member\n * and use it as the effective identity for the request.\n */\n setActingMember(memberUuid: string | undefined) {\n this.actingMemberUuid = memberUuid;\n }\n\n /**\n * Get the current acting member UUID.\n */\n getActingMember(): string | undefined {\n return this.actingMemberUuid;\n }\n\n /**\n * Set the opaque org session credential for cross-domain requests.\n * Opaque gr_sess_ values use X-Org-Session. Legacy orgToken JWE values still\n * use X-Org-Token through setOrgToken() during the migration window.\n *\n * `orgUuid` is the org that issued the credential; passing it lets the 401\n * handler detect a stale session when a subsequent request targets a\n * different org and re-fire the org-auth handler instead of silently\n * 401-ing. Callers without that context (legacy / unknown) may omit it.\n */\n setOrgSession(session: string | undefined, orgUuid?: string) {\n this.orgSession = session;\n this.orgSessionOrgUuid = session ? orgUuid : undefined;\n }\n\n /**\n * @deprecated Legacy compatibility for stateless orgToken JWE credentials.\n * Prefer setOrgSession() for opaque org browser sessions.\n */\n setOrgToken(token: string | undefined, orgUuid?: string) {\n this.setOrgSession(token, orgUuid);\n }\n\n protected async fetch<T>(endpoint: string, options?: RequestInit): Promise<T> {\n try {\n const headers = new Headers({\n // Don't set Content-Type for FormData — the browser must set it\n // with the multipart boundary automatically.\n ...(options?.body instanceof FormData ? {} : { 'Content-Type': 'application/json' }),\n ...((options?.headers as Record<string, string>) || {}),\n });\n\n if (this.apiKey) {\n headers.set('Authorization', `Bearer ${this.apiKey}`);\n } else if (this.isCrossDomain) {\n // For cross-domain requests, try to use the requestToken cookie\n const requestToken = getCookieValue('requestToken');\n if (requestToken) {\n headers.set('Authorization', `Bearer ${requestToken}`);\n }\n }\n\n // Include X-Acting-Member header for member identity switching\n if (this.actingMemberUuid) {\n headers.set('X-Acting-Member', this.actingMemberUuid);\n }\n\n setOrgAuthHeader(headers, this.orgSession);\n\n // console.warn(\"Calling with apiKey:\", this.apiKey)\n const fullUrl = `${this.baseUrl}/api/v2/${endpoint}`;\n // console.log('[BaseApiClient] fetch - URL:', fullUrl, 'baseUrl:', this.baseUrl, 'endpoint:', endpoint);\n\n const response = await this.fetchFunction(fullUrl, {\n ...options,\n ...(this.apiKey ? {} : { credentials: 'include' }),\n ...(this.isCrossDomain ? { mode: 'cors' } : {}),\n headers,\n });\n\n if (!response.ok) {\n // Check for step-up auth requirement per RFC 9470 (superuser 2FA re-auth needed)\n if (\n response.status === 401 &&\n requiresStepUpAuth(response.headers.get('WWW-Authenticate')) &&\n this.enhancedAuthHandler\n ) {\n // If re-auth is already in progress, wait for it\n if (this.enhancedAuthInProgress) {\n await this.enhancedAuthInProgress;\n } else {\n // Trigger re-auth and wait for completion\n this.enhancedAuthInProgress = this.enhancedAuthHandler();\n try {\n const newToken = await this.enhancedAuthInProgress;\n this.apiKey = newToken;\n } finally {\n this.enhancedAuthInProgress = null;\n }\n }\n // Retry the request with the new token\n try {\n return await this.fetch<T>(endpoint, options);\n } catch (retryError) {\n this.orgSession = undefined;\n this.orgSessionOrgUuid = undefined;\n throw retryError;\n }\n }\n\n if (response.status === 401) {\n const orgAuthInfo = parseOrgAuthChallenge(response.headers.get('WWW-Authenticate'));\n // If the challenge targets a different org than our current\n // token, the token is stale (e.g. switching from Org A to Org\n // B mid-session). Clear it so the handler re-fires below.\n if (\n orgAuthInfo &&\n this.orgSession &&\n this.orgSessionOrgUuid &&\n this.orgSessionOrgUuid !== orgAuthInfo.orgUuid\n ) {\n this.orgSession = undefined;\n this.orgSessionOrgUuid = undefined;\n }\n if (orgAuthInfo && !this.orgSession) {\n const requestCookieName = getRequestOrgCookieName(orgAuthInfo.cookieName);\n const cachedOrgSession = requestCookieName\n ? getCookieValue(requestCookieName)\n : undefined;\n if (cachedOrgSession) {\n this.orgSession = cachedOrgSession;\n this.orgSessionOrgUuid = orgAuthInfo.orgUuid;\n try {\n return await this.fetch<T>(endpoint, options);\n } catch (retryError) {\n this.orgSession = undefined;\n this.orgSessionOrgUuid = undefined;\n throw retryError;\n }\n }\n\n if (this.orgAuthHandler) {\n if (!this.orgAuthInProgress) {\n const handler = this.orgAuthHandler;\n this.orgAuthInProgress = (async () => {\n try {\n await handler(orgAuthInfo);\n } finally {\n this.orgAuthInProgress = null;\n }\n })();\n }\n await this.orgAuthInProgress;\n // Prefer cookie (browser). Fall back to this.orgSession which\n // non-browser handlers (e.g. CLI) set directly via setOrgSession().\n const postHandlerSession =\n (requestCookieName ? getCookieValue(requestCookieName) : undefined) ??\n this.orgSession;\n if (!postHandlerSession) {\n throw new ApiError(\n 'Organization authentication did not issue a session',\n 401\n );\n }\n this.orgSession = postHandlerSession;\n this.orgSessionOrgUuid = orgAuthInfo.orgUuid;\n try {\n return await this.fetch<T>(endpoint, options);\n } catch (retryError) {\n this.orgSession = undefined;\n this.orgSessionOrgUuid = undefined;\n throw retryError;\n }\n }\n }\n }\n\n const errorData = await response.json().catch(() => ({}));\n\n // Handle unauthorized errors for account endpoint\n if (response.status === 401 && endpoint === 'account') {\n throw new Error('unauthorized');\n }\n\n // Handle structured validation errors (Pydantic array format)\n if (Array.isArray(errorData.detail)) {\n const formattedErrors = errorData.detail\n .map((error: any) => {\n const location = error.loc.join(' > ');\n return `${location}: ${error.msg}`;\n })\n .join('\\n');\n throw new ApiError(`Validation Error:\\n${formattedErrors}`, response.status);\n }\n\n // Handle validation errors with errors array (new format)\n if (errorData.errors && Array.isArray(errorData.errors)) {\n // Structured workflow-expression validation errors — objects with\n // { field, kind, message, offendingPath, location }. Build a\n // readable message and preserve the structured payload.\n if (errorData.errors.length > 0 && isApiValidationError(errorData.errors[0])) {\n const validationErrors: ApiValidationError[] =\n errorData.errors.filter(isApiValidationError);\n const [first] = validationErrors;\n if (first) {\n const extra =\n validationErrors.length > 1\n ? ` (+${validationErrors.length - 1} more)`\n : '';\n const readable = `${first.field}: ${first.message}${extra}`;\n throw new ApiError(\n readable,\n response.status,\n validationErrors.map((e) => `${e.field}: ${e.message}`),\n validationErrors\n );\n }\n }\n\n // Legacy string-array errors.\n const stringErrors: string[] = errorData.errors.filter(\n (e: unknown): e is string => typeof e === 'string'\n );\n const details = stringErrors.join('; ');\n const message = errorData.detail\n ? `${errorData.detail}: ${details}`\n : `Validation failed: ${details}`;\n throw new ApiError(message, response.status, stringErrors);\n }\n\n // Handle structured errors (with error: true or with code property)\n const structuredError = errorData.detail || errorData;\n if (\n structuredError &&\n typeof structuredError === 'object' &&\n (structuredError.error === true || structuredError.code)\n ) {\n const message = structuredError.message || structuredError.code || 'Unknown error';\n const error = new ApiError(message, response.status);\n // Attach the full error data for frontend handling\n (error as any).errorData = structuredError;\n throw error;\n }\n\n // Handle simple error messages\n const errorMessage =\n typeof errorData.detail === 'string'\n ? errorData.detail\n : errorData.message || response.statusText;\n throw new ApiError(errorMessage, response.status);\n }\n\n // Handle 204 No Content - no JSON body to parse\n if (response.status === 204) {\n return undefined as any;\n }\n\n return response.json();\n } catch (error) {\n console.warn(error);\n throw error;\n }\n }\n\n protected async fetchRaw(\n endpoint: string,\n options?: RequestInit,\n allowedErrorStatuses: number[] = []\n ): Promise<Response> {\n try {\n const headers = new Headers({\n ...((options?.headers as Record<string, string>) || {}),\n });\n\n if (this.apiKey) {\n headers.set('Authorization', `Bearer ${this.apiKey}`);\n } else if (this.isCrossDomain) {\n // For cross-domain requests, try to use the requestToken cookie\n const requestToken = getCookieValue('requestToken');\n if (requestToken) {\n headers.set('Authorization', `Bearer ${requestToken}`);\n }\n }\n\n // Include X-Acting-Member header for member identity switching\n if (this.actingMemberUuid) {\n headers.set('X-Acting-Member', this.actingMemberUuid);\n }\n\n setOrgAuthHeader(headers, this.orgSession);\n\n const response = await this.fetchFunction(`${this.baseUrl}/api/v2/${endpoint}`, {\n ...options,\n ...(this.apiKey ? {} : { credentials: 'include' }),\n ...(this.isCrossDomain ? { mode: 'cors' } : {}),\n headers,\n });\n\n if (!response.ok) {\n // Check for step-up auth requirement per RFC 9470 (superuser 2FA re-auth needed)\n if (\n response.status === 401 &&\n requiresStepUpAuth(response.headers.get('WWW-Authenticate')) &&\n this.enhancedAuthHandler\n ) {\n // If re-auth is already in progress, wait for it\n if (this.enhancedAuthInProgress) {\n await this.enhancedAuthInProgress;\n } else {\n // Trigger re-auth and wait for completion\n this.enhancedAuthInProgress = this.enhancedAuthHandler();\n try {\n const newToken = await this.enhancedAuthInProgress;\n this.apiKey = newToken;\n } finally {\n this.enhancedAuthInProgress = null;\n }\n }\n // Retry the request with the new token\n try {\n return await this.fetchRaw(endpoint, options, allowedErrorStatuses);\n } catch (retryError) {\n this.orgSession = undefined;\n this.orgSessionOrgUuid = undefined;\n throw retryError;\n }\n }\n\n // Mirror of the org-auth branch in fetch() above; see comments there.\n if (response.status === 401) {\n const orgAuthInfo = parseOrgAuthChallenge(response.headers.get('WWW-Authenticate'));\n if (\n orgAuthInfo &&\n this.orgSession &&\n this.orgSessionOrgUuid &&\n this.orgSessionOrgUuid !== orgAuthInfo.orgUuid\n ) {\n this.orgSession = undefined;\n this.orgSessionOrgUuid = undefined;\n }\n if (orgAuthInfo && !this.orgSession) {\n const requestCookieName = getRequestOrgCookieName(orgAuthInfo.cookieName);\n const cachedOrgSession = requestCookieName\n ? getCookieValue(requestCookieName)\n : undefined;\n if (cachedOrgSession) {\n this.orgSession = cachedOrgSession;\n this.orgSessionOrgUuid = orgAuthInfo.orgUuid;\n try {\n return await this.fetchRaw(endpoint, options, allowedErrorStatuses);\n } catch (retryError) {\n this.orgSession = undefined;\n this.orgSessionOrgUuid = undefined;\n throw retryError;\n }\n }\n\n if (this.orgAuthHandler) {\n if (!this.orgAuthInProgress) {\n const handler = this.orgAuthHandler;\n this.orgAuthInProgress = (async () => {\n try {\n await handler(orgAuthInfo);\n } finally {\n this.orgAuthInProgress = null;\n }\n })();\n }\n await this.orgAuthInProgress;\n // Prefer cookie (browser). Fall back to this.orgSession which\n // non-browser handlers (e.g. CLI) set directly via setOrgSession().\n const postHandlerSession =\n (requestCookieName ? getCookieValue(requestCookieName) : undefined) ??\n this.orgSession;\n if (!postHandlerSession) {\n throw new ApiError(\n 'Organization authentication did not issue a session',\n 401\n );\n }\n this.orgSession = postHandlerSession;\n this.orgSessionOrgUuid = orgAuthInfo.orgUuid;\n try {\n return await this.fetchRaw(endpoint, options, allowedErrorStatuses);\n } catch (retryError) {\n this.orgSession = undefined;\n this.orgSessionOrgUuid = undefined;\n throw retryError;\n }\n }\n }\n }\n\n if (allowedErrorStatuses.includes(response.status)) {\n return response;\n }\n\n const errorText = await response.text().catch(() => '');\n throw new ApiError(errorText || response.statusText, response.status);\n }\n\n return response;\n } catch (error) {\n console.warn(error);\n throw error;\n }\n }\n\n /**\n * Fetch from root path (not prefixed with /api/v2/)\n * Used for OAuth and other non-API endpoints\n */\n protected async fetchRoot<T>(path: string, options?: RequestInit): Promise<T> {\n try {\n const headers = new Headers({\n ...(options?.body instanceof FormData ? {} : { 'Content-Type': 'application/json' }),\n ...((options?.headers as Record<string, string>) || {}),\n });\n\n if (this.apiKey) {\n headers.set('Authorization', `Bearer ${this.apiKey}`);\n } else if (this.isCrossDomain) {\n const requestToken = getCookieValue('requestToken');\n if (requestToken) {\n headers.set('Authorization', `Bearer ${requestToken}`);\n }\n }\n\n // Include X-Acting-Member header for member identity switching\n if (this.actingMemberUuid) {\n headers.set('X-Acting-Member', this.actingMemberUuid);\n }\n\n setOrgAuthHeader(headers, this.orgSession);\n\n const fullUrl = `${this.baseUrl}/${path}`;\n\n const response = await this.fetchFunction(fullUrl, {\n ...options,\n ...(this.apiKey ? {} : { credentials: 'include' }),\n ...(this.isCrossDomain ? { mode: 'cors' } : {}),\n headers,\n });\n\n if (!response.ok) {\n if (response.status === 404) {\n return null as T;\n }\n const errorData = await response.json().catch(() => ({}));\n const errorMessage = errorData.detail || errorData.message || response.statusText;\n throw new ApiError(errorMessage, response.status);\n }\n\n if (response.status === 204) {\n return undefined as T;\n }\n\n return response.json();\n } catch (error) {\n console.warn(error);\n throw error;\n }\n }\n}\n"],"mappings":";AACO,SAAS,eA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AAS,cAAc,SAAS,MAAM;AAAA,MACnD;AAEA,UAAI,SAAS,WAAW,KAAK;AAC1B,eAAO;AAAA,MACV;AAEA,aAAO,SAAS,KAAK;AAAA,IACxB,SAAS,OAAO;AACb,cAAQ,KAAK,KAAK;AAClB,YAAM;AAAA,IACT;AAAA,EACH;AACH;","names":[]}
@@ -1,3 +1,9 @@
1
+ // src/types/generated/data.ts
2
+ var DataRecordRetirementResponseReason = {
3
+ monday_item_archived: "monday_item_archived",
4
+ monday_item_deleted: "monday_item_deleted"
5
+ };
6
+
1
7
  // src/types/data-types.ts
2
8
  var DataFieldType = /* @__PURE__ */ ((DataFieldType2) => {
3
9
  DataFieldType2["ENUM"] = "enum";
@@ -100,6 +106,7 @@ var AttendeeResponseStatus = /* @__PURE__ */ ((AttendeeResponseStatus2) => {
100
106
  })(AttendeeResponseStatus || {});
101
107
 
102
108
  export {
109
+ DataRecordRetirementResponseReason,
103
110
  DataFieldType,
104
111
  IndexStatus,
105
112
  DataTypeRecordScope,
@@ -113,4 +120,4 @@ export {
113
120
  AttendeeStatus,
114
121
  AttendeeResponseStatus
115
122
  };
116
- //# sourceMappingURL=chunk-QS6ZRQUZ.js.map
123
+ //# sourceMappingURL=chunk-V7ZKEH4V.js.map