modulex-js 0.1.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/index.js ADDED
@@ -0,0 +1,2224 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AuthenticationError: () => AuthenticationError,
24
+ BadRequestError: () => BadRequestError,
25
+ ConflictError: () => ConflictError,
26
+ ExternalServiceError: () => ExternalServiceError,
27
+ InternalError: () => InternalError,
28
+ Modulex: () => Modulex,
29
+ ModulexError: () => ModulexError,
30
+ NotFoundError: () => NotFoundError,
31
+ PermissionError: () => PermissionError,
32
+ RateLimitError: () => RateLimitError,
33
+ ServiceUnavailableError: () => ServiceUnavailableError,
34
+ StreamError: () => StreamError,
35
+ TimeoutError: () => TimeoutError,
36
+ ValidationError: () => ValidationError
37
+ });
38
+ module.exports = __toCommonJS(index_exports);
39
+
40
+ // src/config.ts
41
+ var DEFAULT_BASE_URL = "https://api.modulex.dev";
42
+ var DEFAULT_TIMEOUT = 3e4;
43
+ var DEFAULT_MAX_RETRIES = 3;
44
+ function resolveConfig(config) {
45
+ if (!config.apiKey) {
46
+ throw new Error("ModuleX API key is required. Pass `apiKey` to the Modulex constructor.");
47
+ }
48
+ return {
49
+ apiKey: config.apiKey,
50
+ organizationId: config.organizationId,
51
+ baseUrl: (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, ""),
52
+ timeout: config.timeout ?? DEFAULT_TIMEOUT,
53
+ maxRetries: config.maxRetries ?? DEFAULT_MAX_RETRIES,
54
+ fetch: config.fetch ?? globalThis.fetch
55
+ };
56
+ }
57
+
58
+ // src/errors.ts
59
+ var ModulexError = class extends Error {
60
+ constructor(message, status, body, headers) {
61
+ super(message);
62
+ this.status = status;
63
+ this.body = body;
64
+ this.headers = headers;
65
+ this.name = "ModulexError";
66
+ }
67
+ };
68
+ var BadRequestError = class extends ModulexError {
69
+ constructor(message, body, headers) {
70
+ super(message, 400, body, headers);
71
+ this.name = "BadRequestError";
72
+ }
73
+ };
74
+ var AuthenticationError = class extends ModulexError {
75
+ constructor(message, body, headers) {
76
+ super(message, 401, body, headers);
77
+ this.name = "AuthenticationError";
78
+ }
79
+ };
80
+ var PermissionError = class extends ModulexError {
81
+ constructor(message, body, headers) {
82
+ super(message, 403, body, headers);
83
+ this.name = "PermissionError";
84
+ }
85
+ };
86
+ var NotFoundError = class extends ModulexError {
87
+ constructor(message, body, headers) {
88
+ super(message, 404, body, headers);
89
+ this.name = "NotFoundError";
90
+ }
91
+ };
92
+ var ConflictError = class extends ModulexError {
93
+ constructor(message, body, headers) {
94
+ super(message, 409, body, headers);
95
+ this.name = "ConflictError";
96
+ }
97
+ };
98
+ var ValidationError = class extends ModulexError {
99
+ constructor(message, body, headers) {
100
+ super(message, 422, body, headers);
101
+ this.name = "ValidationError";
102
+ }
103
+ };
104
+ var RateLimitError = class extends ModulexError {
105
+ constructor(message, body, headers) {
106
+ super(message, 429, body, headers);
107
+ this.name = "RateLimitError";
108
+ const retryHeader = headers?.get("retry-after");
109
+ this.retryAfter = retryHeader ? Number(retryHeader) : void 0;
110
+ }
111
+ };
112
+ var InternalError = class extends ModulexError {
113
+ constructor(message, body, headers) {
114
+ super(message, 500, body, headers);
115
+ this.name = "InternalError";
116
+ }
117
+ };
118
+ var ExternalServiceError = class extends ModulexError {
119
+ constructor(message, body, headers) {
120
+ super(message, 502, body, headers);
121
+ this.name = "ExternalServiceError";
122
+ }
123
+ };
124
+ var ServiceUnavailableError = class extends ModulexError {
125
+ constructor(message, body, headers) {
126
+ super(message, 503, body, headers);
127
+ this.name = "ServiceUnavailableError";
128
+ }
129
+ };
130
+ var StreamError = class extends ModulexError {
131
+ constructor(message) {
132
+ super(message, void 0, void 0, void 0);
133
+ this.name = "StreamError";
134
+ }
135
+ };
136
+ var TimeoutError = class extends ModulexError {
137
+ constructor(message = "Request timed out") {
138
+ super(message, void 0, void 0, void 0);
139
+ this.name = "TimeoutError";
140
+ }
141
+ };
142
+ function createErrorFromStatus(status, body, headers) {
143
+ const message = extractErrorMessage(body, status);
144
+ switch (status) {
145
+ case 400:
146
+ return new BadRequestError(message, body, headers);
147
+ case 401:
148
+ return new AuthenticationError(message, body, headers);
149
+ case 403:
150
+ return new PermissionError(message, body, headers);
151
+ case 404:
152
+ return new NotFoundError(message, body, headers);
153
+ case 409:
154
+ return new ConflictError(message, body, headers);
155
+ case 422:
156
+ return new ValidationError(message, body, headers);
157
+ case 429:
158
+ return new RateLimitError(message, body, headers);
159
+ case 500:
160
+ return new InternalError(message, body, headers);
161
+ case 502:
162
+ return new ExternalServiceError(message, body, headers);
163
+ case 503:
164
+ return new ServiceUnavailableError(message, body, headers);
165
+ default:
166
+ return new ModulexError(message, status, body, headers);
167
+ }
168
+ }
169
+ function extractErrorMessage(body, status) {
170
+ if (body && typeof body === "object" && "detail" in body) {
171
+ const detail = body.detail;
172
+ if (typeof detail === "string") return detail;
173
+ if (Array.isArray(detail)) {
174
+ return detail.map((d) => `${d.loc?.join(".")}: ${d.msg}`).join("; ");
175
+ }
176
+ }
177
+ return `HTTP ${status} error`;
178
+ }
179
+
180
+ // src/streaming.ts
181
+ async function* parseSSEStream(response, signal) {
182
+ const body = response.body;
183
+ if (!body) {
184
+ throw new StreamError("Response body is null \u2014 cannot read SSE stream");
185
+ }
186
+ const reader = body.getReader();
187
+ const decoder = new TextDecoder();
188
+ let buffer = "";
189
+ let currentEvent = "";
190
+ let currentData = [];
191
+ let currentId;
192
+ let currentRetry;
193
+ try {
194
+ while (true) {
195
+ if (signal?.aborted) {
196
+ break;
197
+ }
198
+ const { done, value } = await reader.read();
199
+ if (done) break;
200
+ buffer += decoder.decode(value, { stream: true });
201
+ const lines = buffer.split("\n");
202
+ buffer = lines.pop() ?? "";
203
+ for (const line of lines) {
204
+ if (line === "" || line === "\r") {
205
+ if (currentData.length > 0) {
206
+ const dataStr = currentData.join("\n");
207
+ let parsedData;
208
+ try {
209
+ parsedData = JSON.parse(dataStr);
210
+ } catch {
211
+ parsedData = { raw: dataStr };
212
+ }
213
+ yield {
214
+ event: currentEvent || "message",
215
+ data: parsedData,
216
+ id: currentId,
217
+ retry: currentRetry
218
+ };
219
+ }
220
+ currentEvent = "";
221
+ currentData = [];
222
+ currentId = void 0;
223
+ currentRetry = void 0;
224
+ continue;
225
+ }
226
+ if (line.startsWith(":")) continue;
227
+ const colonIdx = line.indexOf(":");
228
+ let field;
229
+ let value_str;
230
+ if (colonIdx === -1) {
231
+ field = line;
232
+ value_str = "";
233
+ } else {
234
+ field = line.slice(0, colonIdx);
235
+ value_str = line.slice(colonIdx + 1);
236
+ if (value_str.startsWith(" ")) {
237
+ value_str = value_str.slice(1);
238
+ }
239
+ }
240
+ switch (field) {
241
+ case "event":
242
+ currentEvent = value_str;
243
+ break;
244
+ case "data":
245
+ currentData.push(value_str);
246
+ break;
247
+ case "id":
248
+ currentId = value_str;
249
+ break;
250
+ case "retry": {
251
+ const n = parseInt(value_str, 10);
252
+ if (!isNaN(n)) currentRetry = n;
253
+ break;
254
+ }
255
+ }
256
+ }
257
+ }
258
+ if (currentData.length > 0) {
259
+ const dataStr = currentData.join("\n");
260
+ let parsedData;
261
+ try {
262
+ parsedData = JSON.parse(dataStr);
263
+ } catch {
264
+ parsedData = { raw: dataStr };
265
+ }
266
+ yield {
267
+ event: currentEvent || "message",
268
+ data: parsedData,
269
+ id: currentId,
270
+ retry: currentRetry
271
+ };
272
+ }
273
+ } finally {
274
+ reader.releaseLock();
275
+ }
276
+ }
277
+
278
+ // src/base.ts
279
+ var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([429, 500, 502, 503]);
280
+ var NON_RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([400, 401, 403, 404, 409, 422]);
281
+ function toSnakeCase(str) {
282
+ return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
283
+ }
284
+ function convertKeysToSnakeCase(obj) {
285
+ if (obj === null || obj === void 0) return obj;
286
+ if (Array.isArray(obj)) return obj.map(convertKeysToSnakeCase);
287
+ if (typeof obj === "object" && !(obj instanceof Date) && !(obj instanceof Blob) && !(typeof File !== "undefined" && obj instanceof File)) {
288
+ const result = {};
289
+ for (const [key, value] of Object.entries(obj)) {
290
+ result[toSnakeCase(key)] = convertKeysToSnakeCase(value);
291
+ }
292
+ return result;
293
+ }
294
+ return obj;
295
+ }
296
+ var BaseResource = class {
297
+ constructor(config) {
298
+ this._config = config;
299
+ }
300
+ /**
301
+ * Resolve the organization ID from per-request options or client default.
302
+ * @internal
303
+ */
304
+ resolveOrgId(options) {
305
+ return options?.organizationId ?? this._config.organizationId;
306
+ }
307
+ /**
308
+ * Build full URL with query parameters.
309
+ * @internal
310
+ */
311
+ buildUrl(path, params) {
312
+ const url = new URL(`${this._config.baseUrl}${path}`);
313
+ if (params) {
314
+ for (const [key, value] of Object.entries(params)) {
315
+ if (value !== void 0) {
316
+ url.searchParams.set(toSnakeCase(key), String(value));
317
+ }
318
+ }
319
+ }
320
+ return url.toString();
321
+ }
322
+ /**
323
+ * Build headers for a request.
324
+ * @internal
325
+ */
326
+ buildHeaders(orgId, contentType) {
327
+ const headers = {
328
+ "Authorization": `Bearer ${this._config.apiKey}`
329
+ };
330
+ if (contentType) {
331
+ headers["Content-Type"] = contentType;
332
+ }
333
+ if (orgId) {
334
+ headers["X-Organization-ID"] = orgId;
335
+ }
336
+ return headers;
337
+ }
338
+ /**
339
+ * Create an abort signal that combines timeout and user-provided signal.
340
+ * @internal
341
+ */
342
+ createSignal(options) {
343
+ const timeout = options?.timeout ?? this._config.timeout;
344
+ const signals = [AbortSignal.timeout(timeout)];
345
+ if (options?.signal) {
346
+ signals.push(options.signal);
347
+ }
348
+ return AbortSignal.any(signals);
349
+ }
350
+ /**
351
+ * Execute a fetch request with retry logic.
352
+ * @internal
353
+ */
354
+ async fetchWithRetry(url, init, maxRetries) {
355
+ let lastError;
356
+ const attempts = maxRetries + 1;
357
+ for (let attempt = 0; attempt < attempts; attempt++) {
358
+ try {
359
+ const response = await this._config.fetch(url, init);
360
+ if (response.ok) {
361
+ return response;
362
+ }
363
+ let body;
364
+ try {
365
+ body = await response.json();
366
+ } catch {
367
+ body = { detail: response.statusText };
368
+ }
369
+ const error = createErrorFromStatus(response.status, body, response.headers);
370
+ if (NON_RETRYABLE_STATUS_CODES.has(response.status)) {
371
+ throw error;
372
+ }
373
+ if (RETRYABLE_STATUS_CODES.has(response.status) && attempt < maxRetries) {
374
+ lastError = error;
375
+ const delay = this.calculateDelay(attempt, response.headers);
376
+ await this.sleep(delay, init.signal ?? void 0);
377
+ continue;
378
+ }
379
+ throw error;
380
+ } catch (e) {
381
+ if (e instanceof DOMException && e.name === "AbortError") {
382
+ throw new TimeoutError();
383
+ }
384
+ if (e instanceof DOMException && e.name === "TimeoutError") {
385
+ throw new TimeoutError();
386
+ }
387
+ if (e && typeof e === "object" && "status" in e) {
388
+ const status = e.status;
389
+ if (NON_RETRYABLE_STATUS_CODES.has(status)) throw e;
390
+ }
391
+ if (attempt < maxRetries) {
392
+ lastError = e instanceof Error ? e : new Error(String(e));
393
+ const delay = this.calculateDelay(attempt);
394
+ try {
395
+ await this.sleep(delay, init.signal ?? void 0);
396
+ } catch {
397
+ throw lastError;
398
+ }
399
+ continue;
400
+ }
401
+ throw e;
402
+ }
403
+ }
404
+ throw lastError ?? new Error("Request failed");
405
+ }
406
+ /**
407
+ * Calculate delay for exponential backoff with jitter.
408
+ * @internal
409
+ */
410
+ calculateDelay(attempt, headers) {
411
+ const retryAfter = headers?.get("retry-after");
412
+ if (retryAfter) {
413
+ const seconds = Number(retryAfter);
414
+ if (!isNaN(seconds)) return seconds * 1e3;
415
+ }
416
+ const base = 500;
417
+ const maxDelay = 3e4;
418
+ const exponential = base * Math.pow(2, attempt);
419
+ const jitter = Math.random() * base;
420
+ return Math.min(exponential + jitter, maxDelay);
421
+ }
422
+ /**
423
+ * Sleep for a given duration, respecting abort signals.
424
+ * @internal
425
+ */
426
+ sleep(ms, signal) {
427
+ return new Promise((resolve, reject) => {
428
+ if (signal?.aborted) {
429
+ reject(new TimeoutError());
430
+ return;
431
+ }
432
+ const timer = setTimeout(resolve, ms);
433
+ signal?.addEventListener("abort", () => {
434
+ clearTimeout(timer);
435
+ reject(new TimeoutError());
436
+ }, { once: true });
437
+ });
438
+ }
439
+ /** Perform a GET request. */
440
+ async _get(path, options) {
441
+ const orgId = this.resolveOrgId(options);
442
+ const url = this.buildUrl(path, options?.params);
443
+ const signal = this.createSignal(options);
444
+ const response = await this.fetchWithRetry(url, {
445
+ method: "GET",
446
+ headers: this.buildHeaders(orgId, "application/json"),
447
+ signal
448
+ }, this._config.maxRetries);
449
+ return response.json();
450
+ }
451
+ /** Perform a POST request. */
452
+ async _post(path, body, options) {
453
+ const orgId = this.resolveOrgId(options);
454
+ const url = this.buildUrl(path, options?.params);
455
+ const signal = this.createSignal(options);
456
+ const response = await this.fetchWithRetry(url, {
457
+ method: "POST",
458
+ headers: this.buildHeaders(orgId, "application/json"),
459
+ body: body !== void 0 ? JSON.stringify(convertKeysToSnakeCase(body)) : void 0,
460
+ signal
461
+ }, this._config.maxRetries);
462
+ const text = await response.text();
463
+ if (!text) return void 0;
464
+ return JSON.parse(text);
465
+ }
466
+ /** Perform a PUT request. */
467
+ async _put(path, body, options) {
468
+ const orgId = this.resolveOrgId(options);
469
+ const url = this.buildUrl(path, options?.params);
470
+ const signal = this.createSignal(options);
471
+ const response = await this.fetchWithRetry(url, {
472
+ method: "PUT",
473
+ headers: this.buildHeaders(orgId, "application/json"),
474
+ body: body !== void 0 ? JSON.stringify(convertKeysToSnakeCase(body)) : void 0,
475
+ signal
476
+ }, this._config.maxRetries);
477
+ const text = await response.text();
478
+ if (!text) return void 0;
479
+ return JSON.parse(text);
480
+ }
481
+ /** Perform a PATCH request. */
482
+ async _patch(path, body, options) {
483
+ const orgId = this.resolveOrgId(options);
484
+ const url = this.buildUrl(path, options?.params);
485
+ const signal = this.createSignal(options);
486
+ const response = await this.fetchWithRetry(url, {
487
+ method: "PATCH",
488
+ headers: this.buildHeaders(orgId, "application/json"),
489
+ body: body !== void 0 ? JSON.stringify(convertKeysToSnakeCase(body)) : void 0,
490
+ signal
491
+ }, this._config.maxRetries);
492
+ const text = await response.text();
493
+ if (!text) return void 0;
494
+ return JSON.parse(text);
495
+ }
496
+ /** Perform a DELETE request. */
497
+ async _delete(path, body, options) {
498
+ const orgId = this.resolveOrgId(options);
499
+ const url = this.buildUrl(path, options?.params);
500
+ const signal = this.createSignal(options);
501
+ const response = await this.fetchWithRetry(url, {
502
+ method: "DELETE",
503
+ headers: this.buildHeaders(orgId, "application/json"),
504
+ body: body !== void 0 ? JSON.stringify(convertKeysToSnakeCase(body)) : void 0,
505
+ signal
506
+ }, this._config.maxRetries);
507
+ if (response.status === 204) return void 0;
508
+ const text = await response.text();
509
+ if (!text) return void 0;
510
+ return JSON.parse(text);
511
+ }
512
+ /** Open an SSE stream and return an async iterable of events. */
513
+ async *streamSSE(path, options) {
514
+ const orgId = this.resolveOrgId(options);
515
+ const url = this.buildUrl(path, options?.params);
516
+ const response = await this._config.fetch(url, {
517
+ method: "GET",
518
+ headers: {
519
+ ...this.buildHeaders(orgId),
520
+ "Accept": "text/event-stream",
521
+ "Cache-Control": "no-cache"
522
+ },
523
+ signal: options?.signal
524
+ });
525
+ if (!response.ok) {
526
+ let body;
527
+ try {
528
+ body = await response.json();
529
+ } catch {
530
+ body = { detail: response.statusText };
531
+ }
532
+ throw createErrorFromStatus(response.status, body, response.headers);
533
+ }
534
+ yield* parseSSEStream(response, options?.signal);
535
+ }
536
+ /** Perform a POST SSE stream request. */
537
+ async *streamSSEPost(path, body, options) {
538
+ const orgId = this.resolveOrgId(options);
539
+ const url = this.buildUrl(path, options?.params);
540
+ const response = await this._config.fetch(url, {
541
+ method: "POST",
542
+ headers: {
543
+ ...this.buildHeaders(orgId, "application/json"),
544
+ "Accept": "text/event-stream"
545
+ },
546
+ body: body !== void 0 ? JSON.stringify(convertKeysToSnakeCase(body)) : void 0,
547
+ signal: options?.signal
548
+ });
549
+ if (!response.ok) {
550
+ let errorBody;
551
+ try {
552
+ errorBody = await response.json();
553
+ } catch {
554
+ errorBody = { detail: response.statusText };
555
+ }
556
+ throw createErrorFromStatus(response.status, errorBody, response.headers);
557
+ }
558
+ yield* parseSSEStream(response, options?.signal);
559
+ }
560
+ /** Upload a file using multipart/form-data. */
561
+ async upload(path, formData, options) {
562
+ const orgId = this.resolveOrgId(options);
563
+ const url = this.buildUrl(path, options?.params);
564
+ const signal = this.createSignal(options);
565
+ const headers = this.buildHeaders(orgId);
566
+ const response = await this.fetchWithRetry(url, {
567
+ method: "POST",
568
+ headers,
569
+ body: formData,
570
+ signal
571
+ }, this._config.maxRetries);
572
+ return response.json();
573
+ }
574
+ };
575
+
576
+ // src/resources/auth.ts
577
+ var Auth = class extends BaseResource {
578
+ /**
579
+ * GET /auth/me
580
+ *
581
+ * Returns the authenticated user's profile.
582
+ */
583
+ async me(options) {
584
+ return this._get("/auth/me", options);
585
+ }
586
+ /**
587
+ * GET /auth/me/organizations
588
+ *
589
+ * Returns the organizations the authenticated user belongs to.
590
+ */
591
+ async organizations(params, options) {
592
+ return this._get("/auth/me/organizations", {
593
+ ...options,
594
+ params: { ...options?.params, role: params?.role }
595
+ });
596
+ }
597
+ /**
598
+ * GET /auth/invitations/my
599
+ *
600
+ * Returns pending invitations for the authenticated user.
601
+ */
602
+ async invitations(options) {
603
+ return this._get("/auth/invitations/my", options);
604
+ }
605
+ /**
606
+ * POST /auth/invitations/{id}/accept
607
+ *
608
+ * Accepts a pending organization invitation.
609
+ */
610
+ async acceptInvitation(invitationId, options) {
611
+ return this._post(
612
+ `/auth/invitations/${invitationId}/accept`,
613
+ void 0,
614
+ options
615
+ );
616
+ }
617
+ /**
618
+ * POST /auth/invitations/{id}/reject
619
+ *
620
+ * Rejects a pending organization invitation.
621
+ */
622
+ async rejectInvitation(invitationId, options) {
623
+ return this._post(
624
+ `/auth/invitations/${invitationId}/reject`,
625
+ void 0,
626
+ options
627
+ );
628
+ }
629
+ /**
630
+ * POST /auth/organizations/leave
631
+ *
632
+ * Leaves the current organization (requires organization context).
633
+ */
634
+ async leaveOrganization(options) {
635
+ return this._post("/auth/organizations/leave", void 0, options);
636
+ }
637
+ };
638
+
639
+ // src/resources/api-keys.ts
640
+ var ApiKeys = class extends BaseResource {
641
+ /**
642
+ * POST /api-keys
643
+ *
644
+ * Creates a new API key. The full key value is returned only once.
645
+ */
646
+ async create(params, options) {
647
+ return this._post("/api-keys", params, options);
648
+ }
649
+ /**
650
+ * GET /api-keys
651
+ *
652
+ * Lists all API keys for the authenticated user.
653
+ */
654
+ async list(params, options) {
655
+ return this._get("/api-keys", {
656
+ ...options,
657
+ params: {
658
+ ...options?.params,
659
+ include_revoked: params?.includeRevoked
660
+ }
661
+ });
662
+ }
663
+ /**
664
+ * GET /api-keys/{keyId}
665
+ *
666
+ * Returns details for a specific API key (masked — never the full key).
667
+ */
668
+ async get(keyId, options) {
669
+ return this._get(`/api-keys/${keyId}`, options);
670
+ }
671
+ /**
672
+ * DELETE /api-keys/{keyId}
673
+ *
674
+ * Permanently revokes an API key.
675
+ */
676
+ async revoke(keyId, options) {
677
+ return this._delete(`/api-keys/${keyId}`, void 0, options);
678
+ }
679
+ };
680
+
681
+ // src/resources/organizations.ts
682
+ var Organizations = class extends BaseResource {
683
+ /**
684
+ * POST /organizations
685
+ *
686
+ * Creates a new organization. The authenticated user becomes the owner.
687
+ */
688
+ async create(params, options) {
689
+ return this._post("/organizations", params, options);
690
+ }
691
+ /**
692
+ * GET /organizations/llms
693
+ *
694
+ * Returns the LLM integrations configured for the current organization.
695
+ */
696
+ async llms(options) {
697
+ return this._get("/organizations/llms", options);
698
+ }
699
+ /**
700
+ * POST /organizations/invite
701
+ *
702
+ * Sends an invitation email to add a user to the current organization.
703
+ */
704
+ async invite(params, options) {
705
+ return this._post("/organizations/invite", params, options);
706
+ }
707
+ /**
708
+ * POST /organizations/invitations/{id}/cancel
709
+ *
710
+ * Cancels a pending organization invitation.
711
+ */
712
+ async cancelInvitation(invitationId, options) {
713
+ return this._post(
714
+ `/organizations/invitations/${invitationId}/cancel`,
715
+ void 0,
716
+ options
717
+ );
718
+ }
719
+ /**
720
+ * POST /organizations/invitations/{id}/reinvite
721
+ *
722
+ * Re-sends an invitation email for a pending invitation.
723
+ */
724
+ async reinvite(invitationId, options) {
725
+ return this._post(
726
+ `/organizations/invitations/${invitationId}/reinvite`,
727
+ void 0,
728
+ options
729
+ );
730
+ }
731
+ /**
732
+ * PUT /organizations/{orgId}/users/{userId}/role
733
+ *
734
+ * Updates a member's role within an organization.
735
+ */
736
+ async updateRole(organizationId, userId, params, options) {
737
+ return this._put(
738
+ `/organizations/${organizationId}/users/${userId}/role`,
739
+ params,
740
+ options
741
+ );
742
+ }
743
+ /**
744
+ * DELETE /organizations/{orgId}/users/{userId}
745
+ *
746
+ * Removes a user from an organization. Requires owner permission.
747
+ */
748
+ async removeUser(organizationId, userId, options) {
749
+ return this._delete(
750
+ `/organizations/${organizationId}/users/${userId}`,
751
+ void 0,
752
+ options
753
+ );
754
+ }
755
+ };
756
+
757
+ // src/resources/workflows.ts
758
+ var Workflows = class extends BaseResource {
759
+ /**
760
+ * POST /workflows
761
+ *
762
+ * Creates a new workflow with the given schema.
763
+ */
764
+ async create(params, options) {
765
+ return this._post("/workflows", params, options);
766
+ }
767
+ /**
768
+ * GET /workflows
769
+ *
770
+ * Lists workflows in the current organization.
771
+ */
772
+ async list(params, options) {
773
+ return this._get("/workflows", {
774
+ ...options,
775
+ params: {
776
+ ...options?.params,
777
+ status: params?.status,
778
+ category: params?.category,
779
+ visibility: params?.visibility,
780
+ search: params?.search,
781
+ page: params?.page,
782
+ page_size: params?.pageSize
783
+ }
784
+ });
785
+ }
786
+ /**
787
+ * Auto-pagination — yields all WorkflowSummary records across pages.
788
+ *
789
+ * Fetches page=1 with pageSize=100 and continues until all pages have been
790
+ * exhausted or there are no more results.
791
+ */
792
+ async *listAll(params, options) {
793
+ let page = 1;
794
+ const pageSize = 100;
795
+ while (true) {
796
+ const response = await this.list({ ...params, page, pageSize }, options);
797
+ for (const workflow of response.workflows) {
798
+ yield workflow;
799
+ }
800
+ const totalPages = response.total_pages ?? Math.ceil(response.total / pageSize);
801
+ if (page >= totalPages || response.workflows.length === 0) {
802
+ break;
803
+ }
804
+ page++;
805
+ }
806
+ }
807
+ /**
808
+ * GET /workflows/{workflowId}
809
+ *
810
+ * Returns a full workflow object including the stored schema.
811
+ */
812
+ async get(workflowId, options) {
813
+ return this._get(`/workflows/${workflowId}`, options);
814
+ }
815
+ /**
816
+ * PUT /workflows/{workflowId}
817
+ *
818
+ * Updates an existing workflow. Only provided fields are changed.
819
+ */
820
+ async update(workflowId, params, options) {
821
+ return this._put(`/workflows/${workflowId}`, params, options);
822
+ }
823
+ /**
824
+ * DELETE /workflows/{workflowId}
825
+ *
826
+ * Soft-deletes a workflow.
827
+ */
828
+ async delete(workflowId, options) {
829
+ return this._delete(
830
+ `/workflows/${workflowId}`,
831
+ void 0,
832
+ options
833
+ );
834
+ }
835
+ /**
836
+ * GET /workflows/builder/details
837
+ *
838
+ * Returns available node types, integration categories, and counts for
839
+ * the visual workflow builder. Results are cached for 60 minutes.
840
+ */
841
+ async builderDetails(params, options) {
842
+ return this._get("/workflows/builder/details", {
843
+ ...options,
844
+ params: {
845
+ ...options?.params,
846
+ node_type: params?.nodeType,
847
+ category: params?.category,
848
+ integration_name: params?.integrationName
849
+ }
850
+ });
851
+ }
852
+ };
853
+
854
+ // src/resources/executions.ts
855
+ var Executions = class extends BaseResource {
856
+ /**
857
+ * POST /workflows/run
858
+ *
859
+ * Initiates a workflow run. Supports four modes: existing workflow, ad-hoc
860
+ * workflow, direct LLM call, and system workflow. Returns immediately with
861
+ * run metadata; stream events via `listen()`.
862
+ */
863
+ async run(params, options) {
864
+ return this._post("/workflows/run", params, options);
865
+ }
866
+ /**
867
+ * GET /workflows/state/{threadId}
868
+ *
869
+ * Returns the persisted state snapshot of a workflow thread at its latest
870
+ * checkpoint.
871
+ */
872
+ async getState(threadId, options) {
873
+ return this._get(`/workflows/state/${threadId}`, options);
874
+ }
875
+ /**
876
+ * POST /workflows/resume/{threadId}
877
+ *
878
+ * Resumes a workflow that is waiting at an interrupt node.
879
+ */
880
+ async resume(params, options) {
881
+ const { threadId, ...rest } = params;
882
+ return this._post(
883
+ `/workflows/resume/${threadId}`,
884
+ rest,
885
+ options
886
+ );
887
+ }
888
+ /**
889
+ * POST /workflows/cancel/{runId}
890
+ *
891
+ * Requests cancellation of an in-progress workflow run.
892
+ */
893
+ async cancel(runId, params, options) {
894
+ return this._post(
895
+ `/workflows/cancel/${runId}`,
896
+ params ?? {},
897
+ options
898
+ );
899
+ }
900
+ /**
901
+ * GET /workflows/listen/{runId} — SSE stream
902
+ *
903
+ * Opens a Server-Sent Events stream for real-time execution events of
904
+ * an in-progress workflow run. Yields typed `WorkflowSSEEvent` values.
905
+ */
906
+ listen(runId, options) {
907
+ return this.streamSSE(
908
+ `/workflows/listen/${runId}`,
909
+ options
910
+ );
911
+ }
912
+ };
913
+
914
+ // src/resources/deployments.ts
915
+ var Deployments = class extends BaseResource {
916
+ /**
917
+ * POST /workflows/{workflowId}/deploy
918
+ *
919
+ * Creates a new deployment snapshot of a workflow.
920
+ */
921
+ async create(workflowId, params, options) {
922
+ return this._post(
923
+ `/workflows/${workflowId}/deploy`,
924
+ params ?? {},
925
+ options
926
+ );
927
+ }
928
+ /**
929
+ * GET /workflows/{workflowId}/deployments
930
+ *
931
+ * Lists deployment snapshots for a workflow.
932
+ */
933
+ async list(workflowId, params, options) {
934
+ return this._get(
935
+ `/workflows/${workflowId}/deployments`,
936
+ {
937
+ ...options,
938
+ params: {
939
+ ...options?.params,
940
+ limit: params?.limit,
941
+ offset: params?.offset
942
+ }
943
+ }
944
+ );
945
+ }
946
+ /**
947
+ * GET /workflows/{workflowId}/deployments/{deploymentId}
948
+ *
949
+ * Returns the full deployment record including the stored workflow schema.
950
+ */
951
+ async get(workflowId, deploymentId, options) {
952
+ return this._get(
953
+ `/workflows/${workflowId}/deployments/${deploymentId}`,
954
+ options
955
+ );
956
+ }
957
+ /**
958
+ * PUT /workflows/{workflowId}/deployments/{deploymentId}/activate
959
+ *
960
+ * Sets the given deployment as the live (active) version for the workflow.
961
+ */
962
+ async activate(workflowId, deploymentId, options) {
963
+ return this._put(
964
+ `/workflows/${workflowId}/deployments/${deploymentId}/activate`,
965
+ void 0,
966
+ options
967
+ );
968
+ }
969
+ /**
970
+ * DELETE /workflows/{workflowId}/deployments/live
971
+ *
972
+ * Deactivates the currently live deployment so no version is active.
973
+ */
974
+ async deactivate(workflowId, options) {
975
+ return this._delete(
976
+ `/workflows/${workflowId}/deployments/live`,
977
+ void 0,
978
+ options
979
+ );
980
+ }
981
+ /**
982
+ * DELETE /workflows/{workflowId}/deployments/{deploymentId}
983
+ *
984
+ * Permanently deletes a deployment snapshot.
985
+ */
986
+ async delete(workflowId, deploymentId, options) {
987
+ return this._delete(
988
+ `/workflows/${workflowId}/deployments/${deploymentId}`,
989
+ void 0,
990
+ options
991
+ );
992
+ }
993
+ };
994
+
995
+ // src/resources/chats.ts
996
+ var Chats = class extends BaseResource {
997
+ /**
998
+ * GET /chats
999
+ *
1000
+ * Returns all chats for the current organization, grouped by folder.
1001
+ * Keys include at minimum `"chats"`, `"pinned"`, and `"archived"`.
1002
+ */
1003
+ async list(options) {
1004
+ return this._get("/chats", options);
1005
+ }
1006
+ /**
1007
+ * GET /chats/stream — SSE
1008
+ *
1009
+ * Opens a Server-Sent Events stream for real-time chat list updates.
1010
+ * Emits `connected`, `chat_list_updated`, and `keepalive` events.
1011
+ */
1012
+ stream(options) {
1013
+ return this.streamSSE("/chats/stream", options);
1014
+ }
1015
+ /**
1016
+ * GET /chats/{chatId}
1017
+ *
1018
+ * Returns a single chat session with its embedded messages.
1019
+ */
1020
+ async get(chatId, options) {
1021
+ return this._get(`/chats/${chatId}`, options);
1022
+ }
1023
+ /**
1024
+ * GET /chats/{chatId}/messages
1025
+ *
1026
+ * Returns paginated messages for a chat session.
1027
+ */
1028
+ async messages(chatId, params, options) {
1029
+ return this._get(`/chats/${chatId}/messages`, {
1030
+ ...options,
1031
+ params: {
1032
+ ...options?.params,
1033
+ limit: params?.limit,
1034
+ offset: params?.offset
1035
+ }
1036
+ });
1037
+ }
1038
+ /**
1039
+ * PATCH /chats/{chatId}
1040
+ *
1041
+ * Updates a chat's title, privacy, or folder assignment.
1042
+ */
1043
+ async update(chatId, params, options) {
1044
+ return this._patch(`/chats/${chatId}`, params, options);
1045
+ }
1046
+ /**
1047
+ * DELETE /chats/{chatId}
1048
+ *
1049
+ * Soft-deletes a chat. Private chats can only be deleted by the creator.
1050
+ */
1051
+ async delete(chatId, options) {
1052
+ return this._delete(`/chats/${chatId}`, void 0, options);
1053
+ }
1054
+ };
1055
+
1056
+ // src/resources/credentials.ts
1057
+ var Credentials = class extends BaseResource {
1058
+ /**
1059
+ * GET /credentials
1060
+ *
1061
+ * Lists credentials for the current organization.
1062
+ * Returns a grouped response by default, or a flat list when
1063
+ * `integrationName` is specified.
1064
+ */
1065
+ async list(params, options) {
1066
+ return this._get("/credentials", {
1067
+ ...options,
1068
+ params: {
1069
+ ...options?.params,
1070
+ integration_name: params?.integrationName,
1071
+ auth_type: params?.authType,
1072
+ limit: params?.limit,
1073
+ offset: params?.offset
1074
+ }
1075
+ });
1076
+ }
1077
+ /**
1078
+ * GET /credentials/{credentialId}
1079
+ *
1080
+ * Returns a single credential record.
1081
+ */
1082
+ async get(credentialId, params, options) {
1083
+ return this._get(`/credentials/${credentialId}`, {
1084
+ ...options,
1085
+ params: {
1086
+ ...options?.params,
1087
+ include_masked: params?.includeMasked
1088
+ }
1089
+ });
1090
+ }
1091
+ /**
1092
+ * POST /credentials
1093
+ *
1094
+ * Creates a new credential. The auth data is encrypted at rest.
1095
+ */
1096
+ async create(params, options) {
1097
+ return this._post("/credentials", params, options);
1098
+ }
1099
+ /**
1100
+ * PUT /credentials/{credentialId}
1101
+ *
1102
+ * Updates a credential's display name or metadata.
1103
+ */
1104
+ async update(credentialId, params, options) {
1105
+ return this._put(`/credentials/${credentialId}`, params, options);
1106
+ }
1107
+ /**
1108
+ * DELETE /credentials/{credentialId}
1109
+ *
1110
+ * Permanently deletes a credential. Returns 204 No Content on success.
1111
+ */
1112
+ async delete(credentialId, options) {
1113
+ return this._delete(`/credentials/${credentialId}`, void 0, options);
1114
+ }
1115
+ /**
1116
+ * POST /credentials/{credentialId}/set-default
1117
+ *
1118
+ * Sets the credential as the default for its integration.
1119
+ * Unsets any previously set default.
1120
+ */
1121
+ async setDefault(credentialId, options) {
1122
+ return this._post(
1123
+ `/credentials/${credentialId}/set-default`,
1124
+ void 0,
1125
+ options
1126
+ );
1127
+ }
1128
+ /**
1129
+ * POST /credentials/test-temporary
1130
+ *
1131
+ * Validates a credential's auth data without saving it.
1132
+ */
1133
+ async testTemporary(params, options) {
1134
+ return this._post(
1135
+ "/credentials/test-temporary",
1136
+ params,
1137
+ options
1138
+ );
1139
+ }
1140
+ /**
1141
+ * POST /credentials/{credentialId}/test
1142
+ *
1143
+ * Tests an existing saved credential by making a live API call.
1144
+ */
1145
+ async test(credentialId, options) {
1146
+ return this._post(
1147
+ `/credentials/${credentialId}/test`,
1148
+ void 0,
1149
+ options
1150
+ );
1151
+ }
1152
+ /**
1153
+ * GET /credentials/{credentialId}/usage
1154
+ *
1155
+ * Returns usage statistics for a credential.
1156
+ */
1157
+ async usage(credentialId, params, options) {
1158
+ return this._get(`/credentials/${credentialId}/usage`, {
1159
+ ...options,
1160
+ params: {
1161
+ ...options?.params,
1162
+ start_date: params?.startDate,
1163
+ end_date: params?.endDate
1164
+ }
1165
+ });
1166
+ }
1167
+ /**
1168
+ * GET /credentials/{credentialId}/audit
1169
+ *
1170
+ * Returns the audit log for a credential.
1171
+ */
1172
+ async audit(credentialId, params, options) {
1173
+ return this._get(`/credentials/${credentialId}/audit`, {
1174
+ ...options,
1175
+ params: {
1176
+ ...options?.params,
1177
+ limit: params?.limit,
1178
+ offset: params?.offset
1179
+ }
1180
+ });
1181
+ }
1182
+ /**
1183
+ * POST /credentials/bulk-modulex-keys/stream — SSE
1184
+ *
1185
+ * Streams bulk ModuleX managed key provisioning events.
1186
+ */
1187
+ bulkModulexKeys(options) {
1188
+ return this.streamSSEPost("/credentials/bulk-modulex-keys/stream", void 0, options);
1189
+ }
1190
+ /**
1191
+ * POST /credentials/mcp-server
1192
+ *
1193
+ * Creates a credential for a Model Context Protocol (MCP) server.
1194
+ */
1195
+ async mcpServer(params, options) {
1196
+ return this._post("/credentials/mcp-server", params, options);
1197
+ }
1198
+ /**
1199
+ * POST /credentials/{credentialId}/refresh-discovery
1200
+ *
1201
+ * Refreshes the tool discovery cache for an MCP server credential.
1202
+ */
1203
+ async refreshDiscovery(credentialId, options) {
1204
+ return this._post(
1205
+ `/credentials/${credentialId}/refresh-discovery`,
1206
+ void 0,
1207
+ options
1208
+ );
1209
+ }
1210
+ /**
1211
+ * GET /credentials/{credentialId}/mcp-tools
1212
+ *
1213
+ * Returns the tools discovered from an MCP server credential.
1214
+ */
1215
+ async mcpTools(credentialId, options) {
1216
+ return this._get(
1217
+ `/credentials/${credentialId}/mcp-tools`,
1218
+ options
1219
+ );
1220
+ }
1221
+ };
1222
+
1223
+ // src/resources/integrations.ts
1224
+ var Integrations = class extends BaseResource {
1225
+ /**
1226
+ * GET /integrations/browse
1227
+ *
1228
+ * Returns the integration catalog, optionally filtered by category or type.
1229
+ */
1230
+ async browse(params, options) {
1231
+ return this._get("/integrations/browse", {
1232
+ ...options,
1233
+ params: {
1234
+ ...options?.params,
1235
+ category: params?.category,
1236
+ type: params?.type,
1237
+ auth_type: params?.authType,
1238
+ search: params?.search,
1239
+ include_details: params?.includeDetails,
1240
+ paginate: params?.paginate,
1241
+ page: params?.page,
1242
+ page_size: params?.pageSize
1243
+ }
1244
+ });
1245
+ }
1246
+ /**
1247
+ * GET /integrations/tools
1248
+ *
1249
+ * Returns all available tool integrations, optionally filtered by category.
1250
+ */
1251
+ async tools(params, options) {
1252
+ return this._get("/integrations/tools", {
1253
+ ...options,
1254
+ params: { ...options?.params, category: params?.category }
1255
+ });
1256
+ }
1257
+ /**
1258
+ * GET /integrations/tools/{integrationName}
1259
+ *
1260
+ * Returns the full detail for a specific tool integration including its actions.
1261
+ */
1262
+ async tool(integrationName, options) {
1263
+ return this._get(
1264
+ `/integrations/tools/${integrationName}`,
1265
+ options
1266
+ );
1267
+ }
1268
+ /**
1269
+ * GET /integrations/llm-providers
1270
+ *
1271
+ * Returns all available LLM provider integrations, optionally filtered by category.
1272
+ */
1273
+ async llmProviders(params, options) {
1274
+ return this._get("/integrations/llm-providers", {
1275
+ ...options,
1276
+ params: { ...options?.params, category: params?.category }
1277
+ });
1278
+ }
1279
+ /**
1280
+ * GET /integrations/llm-providers/{providerName}
1281
+ *
1282
+ * Returns the full detail for a specific LLM provider including available models.
1283
+ */
1284
+ async llmProvider(providerName, options) {
1285
+ return this._get(
1286
+ `/integrations/llm-providers/${providerName}`,
1287
+ options
1288
+ );
1289
+ }
1290
+ /**
1291
+ * GET /integrations/knowledge-providers
1292
+ *
1293
+ * Returns all available knowledge provider integrations.
1294
+ */
1295
+ async knowledgeProviders(params, options) {
1296
+ return this._get("/integrations/knowledge-providers", {
1297
+ ...options,
1298
+ params: { ...options?.params, category: params?.category }
1299
+ });
1300
+ }
1301
+ /**
1302
+ * GET /integrations/knowledge-providers/{providerName}
1303
+ *
1304
+ * Returns the full detail for a specific knowledge provider.
1305
+ */
1306
+ async knowledgeProvider(providerName, options) {
1307
+ return this._get(
1308
+ `/integrations/knowledge-providers/${providerName}`,
1309
+ options
1310
+ );
1311
+ }
1312
+ /**
1313
+ * GET /integrations/{integrationName}
1314
+ *
1315
+ * Returns the detail object for any integration by name.
1316
+ */
1317
+ async get(integrationName, options) {
1318
+ return this._get(
1319
+ `/integrations/${integrationName}`,
1320
+ options
1321
+ );
1322
+ }
1323
+ };
1324
+
1325
+ // src/resources/knowledge.ts
1326
+ var Knowledge = class extends BaseResource {
1327
+ /**
1328
+ * GET /knowledge-bases
1329
+ *
1330
+ * Lists knowledge bases for the current organization.
1331
+ */
1332
+ async list(params, options) {
1333
+ return this._get("/knowledge-bases", {
1334
+ ...options,
1335
+ params: {
1336
+ ...options?.params,
1337
+ status: params?.status,
1338
+ limit: params?.limit,
1339
+ offset: params?.offset
1340
+ }
1341
+ });
1342
+ }
1343
+ /**
1344
+ * POST /knowledge-bases
1345
+ *
1346
+ * Creates a new knowledge base.
1347
+ */
1348
+ async create(params, options) {
1349
+ return this._post("/knowledge-bases", params, options);
1350
+ }
1351
+ /**
1352
+ * GET /knowledge-bases/stats
1353
+ *
1354
+ * Returns aggregated statistics across all knowledge bases in the organization.
1355
+ */
1356
+ async stats(options) {
1357
+ return this._get("/knowledge-bases/stats", options);
1358
+ }
1359
+ /**
1360
+ * GET /knowledge-bases/{kbId}
1361
+ *
1362
+ * Returns a single knowledge base record.
1363
+ */
1364
+ async get(knowledgeBaseId, options) {
1365
+ return this._get(
1366
+ `/knowledge-bases/${knowledgeBaseId}`,
1367
+ options
1368
+ );
1369
+ }
1370
+ /**
1371
+ * PUT /knowledge-bases/{kbId}
1372
+ *
1373
+ * Updates a knowledge base's name, description, or configuration.
1374
+ */
1375
+ async update(knowledgeBaseId, params, options) {
1376
+ return this._put(
1377
+ `/knowledge-bases/${knowledgeBaseId}`,
1378
+ params,
1379
+ options
1380
+ );
1381
+ }
1382
+ /**
1383
+ * DELETE /knowledge-bases/{kbId}
1384
+ *
1385
+ * Deletes a knowledge base. Pass `deleteFiles: true` to also remove
1386
+ * the underlying stored files.
1387
+ */
1388
+ async delete(knowledgeBaseId, params, options) {
1389
+ return this._delete(
1390
+ `/knowledge-bases/${knowledgeBaseId}`,
1391
+ void 0,
1392
+ {
1393
+ ...options,
1394
+ params: {
1395
+ ...options?.params,
1396
+ delete_files: params?.deleteFiles
1397
+ }
1398
+ }
1399
+ );
1400
+ }
1401
+ /**
1402
+ * POST /knowledge-bases/{kbId}/archive
1403
+ *
1404
+ * Archives a knowledge base, pausing ingestion without deleting data.
1405
+ */
1406
+ async archive(knowledgeBaseId, options) {
1407
+ return this._post(
1408
+ `/knowledge-bases/${knowledgeBaseId}/archive`,
1409
+ void 0,
1410
+ options
1411
+ );
1412
+ }
1413
+ /**
1414
+ * GET /knowledge-bases/{kbId}/documents
1415
+ *
1416
+ * Returns documents within a knowledge base.
1417
+ */
1418
+ async documents(knowledgeBaseId, params, options) {
1419
+ return this._get(
1420
+ `/knowledge-bases/${knowledgeBaseId}/documents`,
1421
+ {
1422
+ ...options,
1423
+ params: {
1424
+ ...options?.params,
1425
+ status: params?.status,
1426
+ limit: params?.limit,
1427
+ offset: params?.offset
1428
+ }
1429
+ }
1430
+ );
1431
+ }
1432
+ /**
1433
+ * POST /knowledge-bases/{kbId}/documents — multipart upload
1434
+ *
1435
+ * Uploads a document file to a knowledge base for ingestion.
1436
+ * Builds a `FormData` with the file and optional metadata JSON.
1437
+ */
1438
+ async uploadDocument(knowledgeBaseId, params, options) {
1439
+ const formData = new FormData();
1440
+ formData.append("file", params.file, params.filename);
1441
+ if (params.metadata) {
1442
+ formData.append("metadata", JSON.stringify(params.metadata));
1443
+ }
1444
+ return this.upload(
1445
+ `/knowledge-bases/${knowledgeBaseId}/documents`,
1446
+ formData,
1447
+ options
1448
+ );
1449
+ }
1450
+ /**
1451
+ * GET /knowledge-bases/{kbId}/documents/{docId}
1452
+ *
1453
+ * Returns a single document record.
1454
+ */
1455
+ async getDocument(knowledgeBaseId, documentId, options) {
1456
+ return this._get(
1457
+ `/knowledge-bases/${knowledgeBaseId}/documents/${documentId}`,
1458
+ options
1459
+ );
1460
+ }
1461
+ /**
1462
+ * GET /knowledge-bases/{kbId}/documents/{docId}/status
1463
+ *
1464
+ * Returns the processing status and progress of a document.
1465
+ */
1466
+ async documentStatus(knowledgeBaseId, documentId, options) {
1467
+ return this._get(
1468
+ `/knowledge-bases/${knowledgeBaseId}/documents/${documentId}/status`,
1469
+ options
1470
+ );
1471
+ }
1472
+ /**
1473
+ * DELETE /knowledge-bases/{kbId}/documents/{docId}
1474
+ *
1475
+ * Deletes a document and its chunks from the knowledge base.
1476
+ * Pass `deleteFile: true` to also remove the source file from storage.
1477
+ */
1478
+ async deleteDocument(knowledgeBaseId, documentId, params, options) {
1479
+ return this._delete(
1480
+ `/knowledge-bases/${knowledgeBaseId}/documents/${documentId}`,
1481
+ void 0,
1482
+ {
1483
+ ...options,
1484
+ params: {
1485
+ ...options?.params,
1486
+ delete_file: params?.deleteFile
1487
+ }
1488
+ }
1489
+ );
1490
+ }
1491
+ /**
1492
+ * POST /knowledge-bases/{kbId}/documents/{docId}/retry
1493
+ *
1494
+ * Retries ingestion of a failed document.
1495
+ */
1496
+ async retryDocument(knowledgeBaseId, documentId, options) {
1497
+ return this._post(
1498
+ `/knowledge-bases/${knowledgeBaseId}/documents/${documentId}/retry`,
1499
+ void 0,
1500
+ options
1501
+ );
1502
+ }
1503
+ /**
1504
+ * GET /knowledge-bases/{kbId}/documents/{docId}/chunks
1505
+ *
1506
+ * Returns the processed chunks for a document.
1507
+ */
1508
+ async documentChunks(knowledgeBaseId, documentId, params, options) {
1509
+ return this._get(
1510
+ `/knowledge-bases/${knowledgeBaseId}/documents/${documentId}/chunks`,
1511
+ {
1512
+ ...options,
1513
+ params: {
1514
+ ...options?.params,
1515
+ limit: params?.limit,
1516
+ offset: params?.offset
1517
+ }
1518
+ }
1519
+ );
1520
+ }
1521
+ /**
1522
+ * POST /knowledge-bases/{kbId}/search
1523
+ *
1524
+ * Performs a semantic search within a single knowledge base.
1525
+ */
1526
+ async search(knowledgeBaseId, params, options) {
1527
+ return this._post(
1528
+ `/knowledge-bases/${knowledgeBaseId}/search`,
1529
+ params,
1530
+ options
1531
+ );
1532
+ }
1533
+ /**
1534
+ * POST /knowledge-bases/search
1535
+ *
1536
+ * Searches across multiple knowledge bases simultaneously.
1537
+ */
1538
+ async searchMultiple(params, options) {
1539
+ return this._post("/knowledge-bases/search", params, options);
1540
+ }
1541
+ /**
1542
+ * POST /knowledge-bases/{kbId}/hybrid-search
1543
+ *
1544
+ * Performs a hybrid (semantic + keyword) search within a knowledge base.
1545
+ */
1546
+ async hybridSearch(knowledgeBaseId, params, options) {
1547
+ return this._post(
1548
+ `/knowledge-bases/${knowledgeBaseId}/hybrid-search`,
1549
+ params,
1550
+ options
1551
+ );
1552
+ }
1553
+ /**
1554
+ * POST /knowledge-bases/{kbId}/retrieve-context
1555
+ *
1556
+ * Retrieves a pre-formatted context string from a knowledge base for
1557
+ * prompt injection.
1558
+ */
1559
+ async retrieveContext(knowledgeBaseId, params, options) {
1560
+ return this._post(
1561
+ `/knowledge-bases/${knowledgeBaseId}/retrieve-context`,
1562
+ params,
1563
+ options
1564
+ );
1565
+ }
1566
+ /**
1567
+ * GET /knowledge-bases/info/supported-file-types
1568
+ *
1569
+ * Returns the list of file types accepted by the document ingestion pipeline.
1570
+ */
1571
+ async supportedFileTypes(options) {
1572
+ return this._get(
1573
+ "/knowledge-bases/info/supported-file-types",
1574
+ options
1575
+ );
1576
+ }
1577
+ };
1578
+
1579
+ // src/resources/schedules.ts
1580
+ var Schedules = class extends BaseResource {
1581
+ /**
1582
+ * POST /schedules
1583
+ *
1584
+ * Creates a new workflow schedule.
1585
+ */
1586
+ async create(params, options) {
1587
+ return this._post("/schedules", params, options);
1588
+ }
1589
+ /**
1590
+ * GET /schedules
1591
+ *
1592
+ * Lists schedules for the current organization.
1593
+ */
1594
+ async list(params, options) {
1595
+ return this._get("/schedules", {
1596
+ ...options,
1597
+ params: {
1598
+ ...options?.params,
1599
+ workflow_id: params?.workflowId,
1600
+ is_active: params?.isActive,
1601
+ limit: params?.limit,
1602
+ offset: params?.offset
1603
+ }
1604
+ });
1605
+ }
1606
+ /**
1607
+ * GET /schedules/{scheduleId}
1608
+ *
1609
+ * Returns a single schedule record.
1610
+ */
1611
+ async get(scheduleId, options) {
1612
+ return this._get(`/schedules/${scheduleId}`, options);
1613
+ }
1614
+ /**
1615
+ * PUT /schedules/{scheduleId}
1616
+ *
1617
+ * Updates an existing schedule. Only provided fields are changed.
1618
+ */
1619
+ async update(scheduleId, params, options) {
1620
+ return this._put(`/schedules/${scheduleId}`, params, options);
1621
+ }
1622
+ /**
1623
+ * DELETE /schedules/{scheduleId}
1624
+ *
1625
+ * Deletes a schedule and cancels all pending executions.
1626
+ */
1627
+ async delete(scheduleId, options) {
1628
+ return this._delete(
1629
+ `/schedules/${scheduleId}`,
1630
+ void 0,
1631
+ options
1632
+ );
1633
+ }
1634
+ /**
1635
+ * POST /schedules/{scheduleId}/pause
1636
+ *
1637
+ * Pauses a schedule, preventing future runs until resumed.
1638
+ */
1639
+ async pause(scheduleId, options) {
1640
+ return this._post(
1641
+ `/schedules/${scheduleId}/pause`,
1642
+ void 0,
1643
+ options
1644
+ );
1645
+ }
1646
+ /**
1647
+ * POST /schedules/{scheduleId}/resume
1648
+ *
1649
+ * Resumes a paused schedule.
1650
+ */
1651
+ async resume(scheduleId, options) {
1652
+ return this._post(
1653
+ `/schedules/${scheduleId}/resume`,
1654
+ void 0,
1655
+ options
1656
+ );
1657
+ }
1658
+ /**
1659
+ * GET /schedules/{scheduleId}/runs
1660
+ *
1661
+ * Returns the run history for a schedule.
1662
+ */
1663
+ async runs(scheduleId, params, options) {
1664
+ return this._get(`/schedules/${scheduleId}/runs`, {
1665
+ ...options,
1666
+ params: {
1667
+ ...options?.params,
1668
+ status: params?.status,
1669
+ limit: params?.limit,
1670
+ offset: params?.offset
1671
+ }
1672
+ });
1673
+ }
1674
+ /**
1675
+ * GET /schedules/{scheduleId}/runs/stats
1676
+ *
1677
+ * Returns aggregate run statistics for a schedule.
1678
+ */
1679
+ async runStats(scheduleId, params, options) {
1680
+ return this._get(
1681
+ `/schedules/${scheduleId}/runs/stats`,
1682
+ {
1683
+ ...options,
1684
+ params: {
1685
+ ...options?.params,
1686
+ days: params?.days
1687
+ }
1688
+ }
1689
+ );
1690
+ }
1691
+ /**
1692
+ * GET /schedules/{scheduleId}/runs/{runId}
1693
+ *
1694
+ * Returns details for a single scheduled run.
1695
+ */
1696
+ async getRun(scheduleId, runId, options) {
1697
+ return this._get(
1698
+ `/schedules/${scheduleId}/runs/${runId}`,
1699
+ options
1700
+ );
1701
+ }
1702
+ /**
1703
+ * POST /schedules/{scheduleId}/runs/{runId}/retry
1704
+ *
1705
+ * Retries a failed scheduled run.
1706
+ */
1707
+ async retryRun(scheduleId, runId, options) {
1708
+ return this._post(
1709
+ `/schedules/${scheduleId}/runs/${runId}/retry`,
1710
+ void 0,
1711
+ options
1712
+ );
1713
+ }
1714
+ };
1715
+
1716
+ // src/resources/templates.ts
1717
+ var Templates = class extends BaseResource {
1718
+ /**
1719
+ * GET /templates
1720
+ *
1721
+ * Returns the public template library.
1722
+ */
1723
+ async list(options) {
1724
+ return this._get("/templates", options);
1725
+ }
1726
+ /**
1727
+ * GET /templates/{templateId}
1728
+ *
1729
+ * Returns a single template including its full workflow schema.
1730
+ */
1731
+ async get(templateId, options) {
1732
+ return this._get(`/templates/${templateId}`, options);
1733
+ }
1734
+ /**
1735
+ * GET /templates/me
1736
+ *
1737
+ * Returns templates created by the authenticated user.
1738
+ */
1739
+ async mine(options) {
1740
+ return this._get("/templates/me", options);
1741
+ }
1742
+ /**
1743
+ * POST /templates
1744
+ *
1745
+ * Publishes a workflow as a new template.
1746
+ */
1747
+ async create(params, options) {
1748
+ return this._post("/templates", params, options);
1749
+ }
1750
+ /**
1751
+ * POST /templates/{templateId}/like
1752
+ *
1753
+ * Toggles the authenticated user's like on a template.
1754
+ */
1755
+ async like(templateId, options) {
1756
+ return this._post(
1757
+ `/templates/${templateId}/like`,
1758
+ void 0,
1759
+ options
1760
+ );
1761
+ }
1762
+ /**
1763
+ * POST /templates/{templateId}/use
1764
+ *
1765
+ * Imports a template as a new workflow in the current organization.
1766
+ */
1767
+ async use(templateId, options) {
1768
+ return this._post(
1769
+ `/templates/${templateId}/use`,
1770
+ void 0,
1771
+ options
1772
+ );
1773
+ }
1774
+ /**
1775
+ * POST /templates/{templateId}/update-request
1776
+ *
1777
+ * Submits an update request for a published template.
1778
+ */
1779
+ async updateRequest(templateId, params, options) {
1780
+ return this._post(
1781
+ `/templates/${templateId}/update-request`,
1782
+ params,
1783
+ options
1784
+ );
1785
+ }
1786
+ /**
1787
+ * POST /templates/creators
1788
+ *
1789
+ * Creates or updates the authenticated user's template creator profile.
1790
+ */
1791
+ async createCreator(params, options) {
1792
+ return this._post("/templates/creators", params, options);
1793
+ }
1794
+ /**
1795
+ * GET /templates/creators/me
1796
+ *
1797
+ * Returns the authenticated user's template creator profile.
1798
+ */
1799
+ async getCreator(options) {
1800
+ return this._get("/templates/creators/me", options);
1801
+ }
1802
+ };
1803
+
1804
+ // src/resources/composer.ts
1805
+ var Composer = class extends BaseResource {
1806
+ /**
1807
+ * POST /composer/chat
1808
+ *
1809
+ * Starts a new Composer chat or sends a message to an existing session.
1810
+ * Returns a run ID that can be used to listen to the SSE stream.
1811
+ */
1812
+ async chat(params, options) {
1813
+ return this._post("/composer/chat", params, options);
1814
+ }
1815
+ /**
1816
+ * GET /composer/chat/{composerChatId}
1817
+ *
1818
+ * Returns a Composer chat session with its messages and workflow snapshot status.
1819
+ */
1820
+ async get(composerChatId, options) {
1821
+ return this._get(
1822
+ `/composer/chat/${composerChatId}`,
1823
+ options
1824
+ );
1825
+ }
1826
+ /**
1827
+ * GET /composer/chat/{composerChatId}/listen/{runId} — SSE
1828
+ *
1829
+ * Opens a Server-Sent Events stream for real-time Composer output during a run.
1830
+ */
1831
+ listen(composerChatId, runId, options) {
1832
+ return this.streamSSE(
1833
+ `/composer/chat/${composerChatId}/listen/${runId}`,
1834
+ options
1835
+ );
1836
+ }
1837
+ /**
1838
+ * POST /composer/chat/{composerChatId}/save
1839
+ *
1840
+ * Saves the Composer's current workflow changes to the associated workflow.
1841
+ */
1842
+ async save(composerChatId, options) {
1843
+ return this._post(
1844
+ `/composer/chat/${composerChatId}/save`,
1845
+ void 0,
1846
+ options
1847
+ );
1848
+ }
1849
+ /**
1850
+ * POST /composer/chat/{composerChatId}/revert
1851
+ *
1852
+ * Reverts the Composer's pending changes, restoring the last saved state.
1853
+ */
1854
+ async revert(composerChatId, options) {
1855
+ return this._post(
1856
+ `/composer/chat/${composerChatId}/revert`,
1857
+ void 0,
1858
+ options
1859
+ );
1860
+ }
1861
+ /**
1862
+ * GET /composer/chat/workflow/{workflowId}/history
1863
+ *
1864
+ * Returns the Composer chat history associated with a workflow.
1865
+ */
1866
+ async history(workflowId, params, options) {
1867
+ return this._get(
1868
+ `/composer/chat/workflow/${workflowId}/history`,
1869
+ {
1870
+ ...options,
1871
+ params: {
1872
+ ...options?.params,
1873
+ limit: params?.limit
1874
+ }
1875
+ }
1876
+ );
1877
+ }
1878
+ /**
1879
+ * DELETE /composer/chat/{composerChatId}
1880
+ *
1881
+ * Deletes a Composer chat session. Pass `permanent: true` to also delete
1882
+ * the associated workflow.
1883
+ */
1884
+ async delete(composerChatId, params, options) {
1885
+ return this._delete(
1886
+ `/composer/chat/${composerChatId}`,
1887
+ params,
1888
+ options
1889
+ );
1890
+ }
1891
+ /**
1892
+ * GET /composer/chat/{composerChatId}/status
1893
+ *
1894
+ * Returns the real-time status of a Composer chat session.
1895
+ */
1896
+ async status(composerChatId, options) {
1897
+ return this._get(
1898
+ `/composer/chat/${composerChatId}/status`,
1899
+ options
1900
+ );
1901
+ }
1902
+ /**
1903
+ * POST /composer/chat/{composerChatId}/cancel
1904
+ *
1905
+ * Cancels the in-progress run for a Composer chat session.
1906
+ */
1907
+ async cancel(composerChatId, options) {
1908
+ return this._post(
1909
+ `/composer/chat/${composerChatId}/cancel`,
1910
+ void 0,
1911
+ options
1912
+ );
1913
+ }
1914
+ };
1915
+
1916
+ // src/resources/dashboard.ts
1917
+ var Dashboard = class extends BaseResource {
1918
+ /**
1919
+ * GET /dashboard/logs
1920
+ *
1921
+ * Returns paginated activity logs for the current organization.
1922
+ */
1923
+ async logs(params, options) {
1924
+ return this._get("/dashboard/logs", {
1925
+ ...options,
1926
+ params: {
1927
+ ...options?.params,
1928
+ limit: params?.limit,
1929
+ offset: params?.offset,
1930
+ category: params?.category,
1931
+ operation: params?.operation,
1932
+ start_date: params?.startDate,
1933
+ end_date: params?.endDate
1934
+ }
1935
+ });
1936
+ }
1937
+ /**
1938
+ * GET /dashboard/analytics/overview
1939
+ *
1940
+ * Returns high-level execution and usage analytics for the organization.
1941
+ */
1942
+ async analyticsOverview(params, options) {
1943
+ return this._get("/dashboard/analytics/overview", {
1944
+ ...options,
1945
+ params: {
1946
+ ...options?.params,
1947
+ limit: params?.limit,
1948
+ offset: params?.offset
1949
+ }
1950
+ });
1951
+ }
1952
+ /**
1953
+ * GET /dashboard/analytics/tools
1954
+ *
1955
+ * Returns tool-usage analytics broken down by integration.
1956
+ */
1957
+ async analyticsTools(params, options) {
1958
+ return this._get("/dashboard/analytics/tools", {
1959
+ ...options,
1960
+ params: {
1961
+ ...options?.params,
1962
+ period: params?.period,
1963
+ limit: params?.limit,
1964
+ offset: params?.offset
1965
+ }
1966
+ });
1967
+ }
1968
+ /**
1969
+ * GET /dashboard/analytics/llm-usage
1970
+ *
1971
+ * Returns LLM token-usage analytics broken down by model and provider.
1972
+ */
1973
+ async analyticsLlmUsage(params, options) {
1974
+ return this._get("/dashboard/analytics/llm-usage", {
1975
+ ...options,
1976
+ params: {
1977
+ ...options?.params,
1978
+ period: params?.period,
1979
+ limit: params?.limit,
1980
+ offset: params?.offset
1981
+ }
1982
+ });
1983
+ }
1984
+ /**
1985
+ * GET /dashboard/users
1986
+ *
1987
+ * Returns organization members with pagination and search support.
1988
+ */
1989
+ async users(params, options) {
1990
+ return this._get("/dashboard/users", {
1991
+ ...options,
1992
+ params: {
1993
+ ...options?.params,
1994
+ search: params?.search,
1995
+ status: params?.status,
1996
+ sort_by: params?.sortBy,
1997
+ order: params?.order,
1998
+ page: params?.page,
1999
+ limit: params?.limit
2000
+ }
2001
+ });
2002
+ }
2003
+ };
2004
+
2005
+ // src/resources/subscriptions.ts
2006
+ var Subscriptions = class extends BaseResource {
2007
+ /**
2008
+ * GET /subscriptions/organization-plans
2009
+ *
2010
+ * Returns the list of available organization subscription plans.
2011
+ */
2012
+ async organizationPlans(options) {
2013
+ return this._get(
2014
+ "/subscriptions/organization-plans",
2015
+ options
2016
+ );
2017
+ }
2018
+ /**
2019
+ * GET /subscriptions/organization-billing
2020
+ *
2021
+ * Returns the current organization's billing status and active subscription.
2022
+ */
2023
+ async billing(options) {
2024
+ return this._get("/subscriptions/organization-billing", options);
2025
+ }
2026
+ /**
2027
+ * POST /subscriptions/checkout-link
2028
+ *
2029
+ * Creates a Stripe Checkout session and returns the redirect URL.
2030
+ */
2031
+ async checkoutLink(params, options) {
2032
+ return this._post(
2033
+ "/subscriptions/checkout-link",
2034
+ params,
2035
+ options
2036
+ );
2037
+ }
2038
+ /**
2039
+ * POST /subscriptions/customer-portal
2040
+ *
2041
+ * Creates a Stripe Customer Portal session and returns the redirect URL
2042
+ * for the user to manage their billing.
2043
+ */
2044
+ async customerPortal(options) {
2045
+ return this._post(
2046
+ "/subscriptions/customer-portal",
2047
+ void 0,
2048
+ options
2049
+ );
2050
+ }
2051
+ };
2052
+
2053
+ // src/resources/notifications.ts
2054
+ var Notifications = class extends BaseResource {
2055
+ /**
2056
+ * GET /notifications
2057
+ *
2058
+ * Returns notifications for the current organization.
2059
+ */
2060
+ async list(options) {
2061
+ return this._get("/notifications", options);
2062
+ }
2063
+ /**
2064
+ * POST /notifications/organization
2065
+ *
2066
+ * Creates a new notification for the organization or a specific user.
2067
+ */
2068
+ async create(params, options) {
2069
+ return this._post(
2070
+ "/notifications/organization",
2071
+ params,
2072
+ options
2073
+ );
2074
+ }
2075
+ };
2076
+
2077
+ // src/resources/system.ts
2078
+ var System = class extends BaseResource {
2079
+ /**
2080
+ * GET /system/health
2081
+ *
2082
+ * Returns the service health status, name, and version.
2083
+ */
2084
+ async health(options) {
2085
+ return this._get(
2086
+ "/system/health",
2087
+ options
2088
+ );
2089
+ }
2090
+ /**
2091
+ * GET /system/metrics
2092
+ *
2093
+ * Returns Prometheus-format metrics as plain text.
2094
+ * This endpoint bypasses the JSON-parsing logic of `BaseResource.get()` and
2095
+ * reads the raw response body as a string.
2096
+ */
2097
+ async metrics(options) {
2098
+ const orgId = options?.organizationId ?? this._config.organizationId;
2099
+ const url = `${this._config.baseUrl}/system/metrics`;
2100
+ const headers = {
2101
+ "Authorization": `Bearer ${this._config.apiKey}`
2102
+ };
2103
+ if (orgId) {
2104
+ headers["X-Organization-ID"] = orgId;
2105
+ }
2106
+ const response = await this._config.fetch(url, {
2107
+ method: "GET",
2108
+ headers,
2109
+ signal: options?.signal
2110
+ });
2111
+ return response.text();
2112
+ }
2113
+ /**
2114
+ * GET /system/timezones
2115
+ *
2116
+ * Returns the list of supported IANA timezone identifiers.
2117
+ */
2118
+ async timezones(options) {
2119
+ return this._get("/system/timezones", options);
2120
+ }
2121
+ /**
2122
+ * GET /system/timezones/search
2123
+ *
2124
+ * Searches supported IANA timezone identifiers by query string.
2125
+ */
2126
+ async searchTimezones(query, options) {
2127
+ return this._get("/system/timezones/search", {
2128
+ ...options,
2129
+ params: { ...options?.params, q: query }
2130
+ });
2131
+ }
2132
+ };
2133
+
2134
+ // src/client.ts
2135
+ var Modulex = class {
2136
+ constructor(config) {
2137
+ this._config = resolveConfig(config);
2138
+ }
2139
+ /** Authentication and user profile endpoints. */
2140
+ get auth() {
2141
+ return this._auth ?? (this._auth = new Auth(this._config));
2142
+ }
2143
+ /** API key management endpoints. */
2144
+ get apiKeys() {
2145
+ return this._apiKeys ?? (this._apiKeys = new ApiKeys(this._config));
2146
+ }
2147
+ /** Organization management endpoints. */
2148
+ get organizations() {
2149
+ return this._organizations ?? (this._organizations = new Organizations(this._config));
2150
+ }
2151
+ /** Workflow CRUD endpoints. */
2152
+ get workflows() {
2153
+ return this._workflows ?? (this._workflows = new Workflows(this._config));
2154
+ }
2155
+ /** Workflow execution endpoints (run, resume, cancel, listen). */
2156
+ get executions() {
2157
+ return this._executions ?? (this._executions = new Executions(this._config));
2158
+ }
2159
+ /** Workflow deployment endpoints. */
2160
+ get deployments() {
2161
+ return this._deployments ?? (this._deployments = new Deployments(this._config));
2162
+ }
2163
+ /** Chat endpoints. */
2164
+ get chats() {
2165
+ return this._chats ?? (this._chats = new Chats(this._config));
2166
+ }
2167
+ /** Credential management endpoints. */
2168
+ get credentials() {
2169
+ return this._credentials ?? (this._credentials = new Credentials(this._config));
2170
+ }
2171
+ /** Integration browsing endpoints. */
2172
+ get integrations() {
2173
+ return this._integrations ?? (this._integrations = new Integrations(this._config));
2174
+ }
2175
+ /** Knowledge base endpoints. */
2176
+ get knowledge() {
2177
+ return this._knowledge ?? (this._knowledge = new Knowledge(this._config));
2178
+ }
2179
+ /** Schedule management endpoints. */
2180
+ get schedules() {
2181
+ return this._schedules ?? (this._schedules = new Schedules(this._config));
2182
+ }
2183
+ /** Template endpoints. */
2184
+ get templates() {
2185
+ return this._templates ?? (this._templates = new Templates(this._config));
2186
+ }
2187
+ /** Composer (AI workflow builder) endpoints. */
2188
+ get composer() {
2189
+ return this._composer ?? (this._composer = new Composer(this._config));
2190
+ }
2191
+ /** Dashboard and analytics endpoints. */
2192
+ get dashboard() {
2193
+ return this._dashboard ?? (this._dashboard = new Dashboard(this._config));
2194
+ }
2195
+ /** Subscription and billing endpoints. */
2196
+ get subscriptions() {
2197
+ return this._subscriptions ?? (this._subscriptions = new Subscriptions(this._config));
2198
+ }
2199
+ /** Notification endpoints. */
2200
+ get notifications() {
2201
+ return this._notifications ?? (this._notifications = new Notifications(this._config));
2202
+ }
2203
+ /** System health and utility endpoints. */
2204
+ get system() {
2205
+ return this._system ?? (this._system = new System(this._config));
2206
+ }
2207
+ };
2208
+ // Annotate the CommonJS export names for ESM import in node:
2209
+ 0 && (module.exports = {
2210
+ AuthenticationError,
2211
+ BadRequestError,
2212
+ ConflictError,
2213
+ ExternalServiceError,
2214
+ InternalError,
2215
+ Modulex,
2216
+ ModulexError,
2217
+ NotFoundError,
2218
+ PermissionError,
2219
+ RateLimitError,
2220
+ ServiceUnavailableError,
2221
+ StreamError,
2222
+ TimeoutError,
2223
+ ValidationError
2224
+ });