@swirls/sdk 0.0.10 → 0.0.12

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.
@@ -1,4049 +1,37 @@
1
- import "../chunk-MLKGABMK.js";
2
-
3
- // ../../node_modules/.bun/@orpc+shared@1.13.4+460773ef8ff1e07c/node_modules/@orpc/shared/dist/index.mjs
4
- function resolveMaybeOptionalOptions(rest) {
5
- return rest[0] ?? {};
6
- }
7
- function toArray(value2) {
8
- return Array.isArray(value2) ? value2 : value2 === void 0 || value2 === null ? [] : [value2];
9
- }
10
- var ORPC_NAME = "orpc";
11
- var ORPC_SHARED_PACKAGE_NAME = "@orpc/shared";
12
- var ORPC_SHARED_PACKAGE_VERSION = "1.13.4";
13
- var AbortError = class extends Error {
14
- constructor(...rest) {
15
- super(...rest);
16
- this.name = "AbortError";
17
- }
18
- };
19
- function once(fn) {
20
- let cached;
21
- return () => {
22
- if (cached) {
23
- return cached.result;
24
- }
25
- const result = fn();
26
- cached = { result };
27
- return result;
28
- };
29
- }
30
- function sequential(fn) {
31
- let lastOperationPromise = Promise.resolve();
32
- return (...args) => {
33
- return lastOperationPromise = lastOperationPromise.catch(() => {
34
- }).then(() => {
35
- return fn(...args);
36
- });
37
- };
38
- }
39
- var SPAN_ERROR_STATUS = 2;
40
- var GLOBAL_OTEL_CONFIG_KEY = `__${ORPC_SHARED_PACKAGE_NAME}@${ORPC_SHARED_PACKAGE_VERSION}/otel/config__`;
41
- function getGlobalOtelConfig() {
42
- return globalThis[GLOBAL_OTEL_CONFIG_KEY];
43
- }
44
- function startSpan(name, options = {}, context) {
45
- const tracer = getGlobalOtelConfig()?.tracer;
46
- return tracer?.startSpan(name, options, context);
47
- }
48
- function setSpanError(span, error, options = {}) {
49
- if (!span) {
50
- return;
51
- }
52
- const exception = toOtelException(error);
53
- span.recordException(exception);
54
- if (!options.signal?.aborted || options.signal.reason !== error) {
55
- span.setStatus({
56
- code: SPAN_ERROR_STATUS,
57
- message: exception.message
58
- });
59
- }
60
- }
61
- function toOtelException(error) {
62
- if (error instanceof Error) {
63
- const exception = {
64
- message: error.message,
65
- name: error.name,
66
- stack: error.stack
67
- };
68
- if ("code" in error && (typeof error.code === "string" || typeof error.code === "number")) {
69
- exception.code = error.code;
70
- }
71
- return exception;
72
- }
73
- return { message: String(error) };
74
- }
75
- async function runWithSpan({ name, context, ...options }, fn) {
76
- const tracer = getGlobalOtelConfig()?.tracer;
77
- if (!tracer) {
78
- return fn();
79
- }
80
- const callback = async (span) => {
81
- try {
82
- return await fn(span);
83
- } catch (e) {
84
- setSpanError(span, e, options);
85
- throw e;
86
- } finally {
87
- span.end();
88
- }
89
- };
90
- if (context) {
91
- return tracer.startActiveSpan(name, options, context, callback);
92
- } else {
93
- return tracer.startActiveSpan(name, options, callback);
94
- }
95
- }
96
- async function runInSpanContext(span, fn) {
97
- const otelConfig = getGlobalOtelConfig();
98
- if (!span || !otelConfig) {
99
- return fn();
100
- }
101
- const ctx = otelConfig.trace.setSpan(otelConfig.context.active(), span);
102
- return otelConfig.context.with(ctx, fn);
103
- }
104
- function isAsyncIteratorObject(maybe) {
105
- if (!maybe || typeof maybe !== "object") {
106
- return false;
107
- }
108
- return "next" in maybe && typeof maybe.next === "function" && Symbol.asyncIterator in maybe && typeof maybe[Symbol.asyncIterator] === "function";
109
- }
110
- var fallbackAsyncDisposeSymbol = /* @__PURE__ */ Symbol.for("asyncDispose");
111
- var asyncDisposeSymbol = Symbol.asyncDispose ?? fallbackAsyncDisposeSymbol;
112
- var AsyncIteratorClass = class {
113
- #isDone = false;
114
- #isExecuteComplete = false;
115
- #cleanup;
116
- #next;
117
- constructor(next, cleanup) {
118
- this.#cleanup = cleanup;
119
- this.#next = sequential(async () => {
120
- if (this.#isDone) {
121
- return { done: true, value: void 0 };
122
- }
123
- try {
124
- const result = await next();
125
- if (result.done) {
126
- this.#isDone = true;
127
- }
128
- return result;
129
- } catch (err) {
130
- this.#isDone = true;
131
- throw err;
132
- } finally {
133
- if (this.#isDone && !this.#isExecuteComplete) {
134
- this.#isExecuteComplete = true;
135
- await this.#cleanup("next");
136
- }
137
- }
138
- });
139
- }
140
- next() {
141
- return this.#next();
142
- }
143
- async return(value2) {
144
- this.#isDone = true;
145
- if (!this.#isExecuteComplete) {
146
- this.#isExecuteComplete = true;
147
- await this.#cleanup("return");
148
- }
149
- return { done: true, value: value2 };
150
- }
151
- async throw(err) {
152
- this.#isDone = true;
153
- if (!this.#isExecuteComplete) {
154
- this.#isExecuteComplete = true;
155
- await this.#cleanup("throw");
156
- }
157
- throw err;
158
- }
159
- /**
160
- * asyncDispose symbol only available in esnext, we should fallback to Symbol.for('asyncDispose')
161
- */
162
- async [asyncDisposeSymbol]() {
163
- this.#isDone = true;
164
- if (!this.#isExecuteComplete) {
165
- this.#isExecuteComplete = true;
166
- await this.#cleanup("dispose");
167
- }
168
- }
169
- [Symbol.asyncIterator]() {
170
- return this;
171
- }
172
- };
173
- function asyncIteratorWithSpan({ name, ...options }, iterator) {
174
- let span;
175
- return new AsyncIteratorClass(
176
- async () => {
177
- span ??= startSpan(name);
178
- try {
179
- const result = await runInSpanContext(span, () => iterator.next());
180
- span?.addEvent(result.done ? "completed" : "yielded");
181
- return result;
182
- } catch (err) {
183
- setSpanError(span, err, options);
184
- throw err;
185
- }
186
- },
187
- async (reason) => {
188
- try {
189
- if (reason !== "next") {
190
- await runInSpanContext(span, () => iterator.return?.());
191
- }
192
- } catch (err) {
193
- setSpanError(span, err, options);
194
- throw err;
195
- } finally {
196
- span?.end();
197
- }
198
- }
199
- );
200
- }
201
- function intercept(interceptors, options, main) {
202
- const next = (options2, index) => {
203
- const interceptor = interceptors[index];
204
- if (!interceptor) {
205
- return main(options2);
206
- }
207
- return interceptor({
208
- ...options2,
209
- next: (newOptions = options2) => next(newOptions, index + 1)
210
- });
211
- };
212
- return next(options, 0);
213
- }
214
- function parseEmptyableJSON(text) {
215
- if (!text) {
216
- return void 0;
217
- }
218
- return JSON.parse(text);
219
- }
220
- function stringifyJSON(value2) {
221
- return JSON.stringify(value2);
222
- }
223
- function getConstructor(value2) {
224
- if (!isTypescriptObject(value2)) {
225
- return null;
226
- }
227
- return Object.getPrototypeOf(value2)?.constructor;
228
- }
229
- function isObject(value2) {
230
- if (!value2 || typeof value2 !== "object") {
231
- return false;
232
- }
233
- const proto = Object.getPrototypeOf(value2);
234
- return proto === Object.prototype || !proto || !proto.constructor;
235
- }
236
- function isTypescriptObject(value2) {
237
- return !!value2 && (typeof value2 === "object" || typeof value2 === "function");
238
- }
239
- function get(object, path) {
240
- let current = object;
241
- for (const key of path) {
242
- if (!isTypescriptObject(current)) {
243
- return void 0;
244
- }
245
- current = current[key];
246
- }
247
- return current;
248
- }
249
- function value(value2, ...args) {
250
- if (typeof value2 === "function") {
251
- return value2(...args);
252
- }
253
- return value2;
254
- }
255
- function preventNativeAwait(target) {
256
- return new Proxy(target, {
257
- get(target2, prop, receiver) {
258
- const value2 = Reflect.get(target2, prop, receiver);
259
- if (prop !== "then" || typeof value2 !== "function") {
260
- return value2;
261
- }
262
- return new Proxy(value2, {
263
- apply(targetFn, thisArg, args) {
264
- if (args.length !== 2 || args.some((arg) => !isNativeFunction(arg))) {
265
- return Reflect.apply(targetFn, thisArg, args);
266
- }
267
- let shouldOmit = true;
268
- args[0].call(thisArg, preventNativeAwait(new Proxy(target2, {
269
- get: (target3, prop2, receiver2) => {
270
- if (shouldOmit && prop2 === "then") {
271
- shouldOmit = false;
272
- return void 0;
273
- }
274
- return Reflect.get(target3, prop2, receiver2);
275
- }
276
- })));
277
- }
278
- });
279
- }
280
- });
281
- }
282
- var NATIVE_FUNCTION_REGEX = /^\s*function\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/;
283
- function isNativeFunction(fn) {
284
- return typeof fn === "function" && NATIVE_FUNCTION_REGEX.test(fn.toString());
285
- }
286
- function tryDecodeURIComponent(value2) {
287
- try {
288
- return decodeURIComponent(value2);
289
- } catch {
290
- return value2;
291
- }
292
- }
293
-
294
- // ../../node_modules/.bun/@orpc+client@1.13.4+460773ef8ff1e07c/node_modules/@orpc/client/dist/shared/client.BwSYEMrK.mjs
295
- var ORPC_CLIENT_PACKAGE_NAME = "@orpc/client";
296
- var ORPC_CLIENT_PACKAGE_VERSION = "1.13.4";
297
- var COMMON_ORPC_ERROR_DEFS = {
298
- BAD_REQUEST: {
299
- status: 400,
300
- message: "Bad Request"
301
- },
302
- UNAUTHORIZED: {
303
- status: 401,
304
- message: "Unauthorized"
305
- },
306
- FORBIDDEN: {
307
- status: 403,
308
- message: "Forbidden"
309
- },
310
- NOT_FOUND: {
311
- status: 404,
312
- message: "Not Found"
313
- },
314
- METHOD_NOT_SUPPORTED: {
315
- status: 405,
316
- message: "Method Not Supported"
317
- },
318
- NOT_ACCEPTABLE: {
319
- status: 406,
320
- message: "Not Acceptable"
321
- },
322
- TIMEOUT: {
323
- status: 408,
324
- message: "Request Timeout"
325
- },
326
- CONFLICT: {
327
- status: 409,
328
- message: "Conflict"
329
- },
330
- PRECONDITION_FAILED: {
331
- status: 412,
332
- message: "Precondition Failed"
333
- },
334
- PAYLOAD_TOO_LARGE: {
335
- status: 413,
336
- message: "Payload Too Large"
337
- },
338
- UNSUPPORTED_MEDIA_TYPE: {
339
- status: 415,
340
- message: "Unsupported Media Type"
341
- },
342
- UNPROCESSABLE_CONTENT: {
343
- status: 422,
344
- message: "Unprocessable Content"
345
- },
346
- TOO_MANY_REQUESTS: {
347
- status: 429,
348
- message: "Too Many Requests"
349
- },
350
- CLIENT_CLOSED_REQUEST: {
351
- status: 499,
352
- message: "Client Closed Request"
353
- },
354
- INTERNAL_SERVER_ERROR: {
355
- status: 500,
356
- message: "Internal Server Error"
357
- },
358
- NOT_IMPLEMENTED: {
359
- status: 501,
360
- message: "Not Implemented"
361
- },
362
- BAD_GATEWAY: {
363
- status: 502,
364
- message: "Bad Gateway"
365
- },
366
- SERVICE_UNAVAILABLE: {
367
- status: 503,
368
- message: "Service Unavailable"
369
- },
370
- GATEWAY_TIMEOUT: {
371
- status: 504,
372
- message: "Gateway Timeout"
373
- }
374
- };
375
- function fallbackORPCErrorStatus(code, status) {
376
- return status ?? COMMON_ORPC_ERROR_DEFS[code]?.status ?? 500;
377
- }
378
- function fallbackORPCErrorMessage(code, message) {
379
- return message || COMMON_ORPC_ERROR_DEFS[code]?.message || code;
380
- }
381
- var GLOBAL_ORPC_ERROR_CONSTRUCTORS_SYMBOL = /* @__PURE__ */ Symbol.for(`__${ORPC_CLIENT_PACKAGE_NAME}@${ORPC_CLIENT_PACKAGE_VERSION}/error/ORPC_ERROR_CONSTRUCTORS__`);
382
- void (globalThis[GLOBAL_ORPC_ERROR_CONSTRUCTORS_SYMBOL] ??= /* @__PURE__ */ new WeakSet());
383
- var globalORPCErrorConstructors = globalThis[GLOBAL_ORPC_ERROR_CONSTRUCTORS_SYMBOL];
384
- var ORPCError = class extends Error {
385
- defined;
386
- code;
387
- status;
388
- data;
389
- constructor(code, ...rest) {
390
- const options = resolveMaybeOptionalOptions(rest);
391
- if (options.status !== void 0 && !isORPCErrorStatus(options.status)) {
392
- throw new Error("[ORPCError] Invalid error status code.");
393
- }
394
- const message = fallbackORPCErrorMessage(code, options.message);
395
- super(message, options);
396
- this.code = code;
397
- this.status = fallbackORPCErrorStatus(code, options.status);
398
- this.defined = options.defined ?? false;
399
- this.data = options.data;
400
- }
401
- toJSON() {
402
- return {
403
- defined: this.defined,
404
- code: this.code,
405
- status: this.status,
406
- message: this.message,
407
- data: this.data
408
- };
409
- }
410
- /**
411
- * Workaround for Next.js where different contexts use separate
412
- * dependency graphs, causing multiple ORPCError constructors existing and breaking
413
- * `instanceof` checks across contexts.
414
- *
415
- * This is particularly problematic with "Optimized SSR", where orpc-client
416
- * executes in one context but is invoked from another. When an error is thrown
417
- * in the execution context, `instanceof ORPCError` checks fail in the
418
- * invocation context due to separate class constructors.
419
- *
420
- * @todo Remove this and related code if Next.js resolves the multiple dependency graph issue.
421
- */
422
- static [Symbol.hasInstance](instance) {
423
- if (globalORPCErrorConstructors.has(this)) {
424
- const constructor = getConstructor(instance);
425
- if (constructor && globalORPCErrorConstructors.has(constructor)) {
426
- return true;
427
- }
428
- }
429
- return super[Symbol.hasInstance](instance);
430
- }
431
- };
432
- globalORPCErrorConstructors.add(ORPCError);
433
- function toORPCError(error) {
434
- return error instanceof ORPCError ? error : new ORPCError("INTERNAL_SERVER_ERROR", {
435
- message: "Internal server error",
436
- cause: error
437
- });
438
- }
439
- function isORPCErrorStatus(status) {
440
- return status < 200 || status >= 400;
441
- }
442
- function isORPCErrorJson(json) {
443
- if (!isObject(json)) {
444
- return false;
445
- }
446
- const validKeys = ["defined", "code", "status", "message", "data"];
447
- if (Object.keys(json).some((k) => !validKeys.includes(k))) {
448
- return false;
449
- }
450
- return "defined" in json && typeof json.defined === "boolean" && "code" in json && typeof json.code === "string" && "status" in json && typeof json.status === "number" && isORPCErrorStatus(json.status) && "message" in json && typeof json.message === "string";
451
- }
452
- function createORPCErrorFromJson(json, options = {}) {
453
- return new ORPCError(json.code, {
454
- ...options,
455
- ...json
456
- });
457
- }
458
-
459
- // ../../node_modules/.bun/@orpc+standard-server@1.13.4+460773ef8ff1e07c/node_modules/@orpc/standard-server/dist/index.mjs
460
- var EventEncoderError = class extends TypeError {
461
- };
462
- var EventDecoderError = class extends TypeError {
463
- };
464
- var ErrorEvent = class extends Error {
465
- data;
466
- constructor(options) {
467
- super(options?.message ?? "An error event was received", options);
468
- this.data = options?.data;
469
- }
470
- };
471
- function decodeEventMessage(encoded) {
472
- const lines = encoded.replace(/\n+$/, "").split(/\n/);
473
- const message = {
474
- data: void 0,
475
- event: void 0,
476
- id: void 0,
477
- retry: void 0,
478
- comments: []
479
- };
480
- for (const line of lines) {
481
- const index = line.indexOf(":");
482
- const key = index === -1 ? line : line.slice(0, index);
483
- const value2 = index === -1 ? "" : line.slice(index + 1).replace(/^\s/, "");
484
- if (index === 0) {
485
- message.comments.push(value2);
486
- } else if (key === "data") {
487
- message.data ??= "";
488
- message.data += `${value2}
489
- `;
490
- } else if (key === "event") {
491
- message.event = value2;
492
- } else if (key === "id") {
493
- message.id = value2;
494
- } else if (key === "retry") {
495
- const maybeInteger = Number.parseInt(value2);
496
- if (Number.isInteger(maybeInteger) && maybeInteger >= 0 && maybeInteger.toString() === value2) {
497
- message.retry = maybeInteger;
498
- }
499
- }
500
- }
501
- message.data = message.data?.replace(/\n$/, "");
502
- return message;
503
- }
504
- var EventDecoder = class {
505
- constructor(options = {}) {
506
- this.options = options;
507
- }
508
- incomplete = "";
509
- feed(chunk) {
510
- this.incomplete += chunk;
511
- const lastCompleteIndex = this.incomplete.lastIndexOf("\n\n");
512
- if (lastCompleteIndex === -1) {
513
- return;
514
- }
515
- const completes = this.incomplete.slice(0, lastCompleteIndex).split(/\n\n/);
516
- this.incomplete = this.incomplete.slice(lastCompleteIndex + 2);
517
- for (const encoded of completes) {
518
- const message = decodeEventMessage(`${encoded}
519
-
520
- `);
521
- if (this.options.onEvent) {
522
- this.options.onEvent(message);
523
- }
524
- }
525
- }
526
- end() {
527
- if (this.incomplete) {
528
- throw new EventDecoderError("Event Iterator ended before complete");
529
- }
530
- }
531
- };
532
- var EventDecoderStream = class extends TransformStream {
533
- constructor() {
534
- let decoder;
535
- super({
536
- start(controller) {
537
- decoder = new EventDecoder({
538
- onEvent: (event) => {
539
- controller.enqueue(event);
540
- }
541
- });
542
- },
543
- transform(chunk) {
544
- decoder.feed(chunk);
545
- },
546
- flush() {
547
- decoder.end();
548
- }
549
- });
550
- }
551
- };
552
- function assertEventId(id) {
553
- if (id.includes("\n")) {
554
- throw new EventEncoderError("Event's id must not contain a newline character");
555
- }
556
- }
557
- function assertEventName(event) {
558
- if (event.includes("\n")) {
559
- throw new EventEncoderError("Event's event must not contain a newline character");
560
- }
561
- }
562
- function assertEventRetry(retry) {
563
- if (!Number.isInteger(retry) || retry < 0) {
564
- throw new EventEncoderError("Event's retry must be a integer and >= 0");
565
- }
566
- }
567
- function assertEventComment(comment) {
568
- if (comment.includes("\n")) {
569
- throw new EventEncoderError("Event's comment must not contain a newline character");
570
- }
571
- }
572
- function encodeEventData(data) {
573
- const lines = data?.split(/\n/) ?? [];
574
- let output = "";
575
- for (const line of lines) {
576
- output += `data: ${line}
577
- `;
578
- }
579
- return output;
580
- }
581
- function encodeEventComments(comments) {
582
- let output = "";
583
- for (const comment of comments ?? []) {
584
- assertEventComment(comment);
585
- output += `: ${comment}
586
- `;
587
- }
588
- return output;
589
- }
590
- function encodeEventMessage(message) {
591
- let output = "";
592
- output += encodeEventComments(message.comments);
593
- if (message.event !== void 0) {
594
- assertEventName(message.event);
595
- output += `event: ${message.event}
596
- `;
597
- }
598
- if (message.retry !== void 0) {
599
- assertEventRetry(message.retry);
600
- output += `retry: ${message.retry}
601
- `;
602
- }
603
- if (message.id !== void 0) {
604
- assertEventId(message.id);
605
- output += `id: ${message.id}
606
- `;
607
- }
608
- output += encodeEventData(message.data);
609
- output += "\n";
610
- return output;
611
- }
612
- var EVENT_SOURCE_META_SYMBOL = /* @__PURE__ */ Symbol("ORPC_EVENT_SOURCE_META");
613
- function withEventMeta(container, meta) {
614
- if (meta.id === void 0 && meta.retry === void 0 && !meta.comments?.length) {
615
- return container;
616
- }
617
- if (meta.id !== void 0) {
618
- assertEventId(meta.id);
619
- }
620
- if (meta.retry !== void 0) {
621
- assertEventRetry(meta.retry);
622
- }
623
- if (meta.comments !== void 0) {
624
- for (const comment of meta.comments) {
625
- assertEventComment(comment);
626
- }
627
- }
628
- return new Proxy(container, {
629
- get(target, prop, receiver) {
630
- if (prop === EVENT_SOURCE_META_SYMBOL) {
631
- return meta;
632
- }
633
- return Reflect.get(target, prop, receiver);
634
- }
635
- });
636
- }
637
- function getEventMeta(container) {
638
- return isTypescriptObject(container) ? Reflect.get(container, EVENT_SOURCE_META_SYMBOL) : void 0;
639
- }
640
- function generateContentDisposition(filename) {
641
- const escapedFileName = filename.replace(/"/g, '\\"');
642
- const encodedFilenameStar = encodeURIComponent(filename).replace(/['()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(7C|60|5E)/g, (str, hex) => String.fromCharCode(Number.parseInt(hex, 16)));
643
- return `inline; filename="${escapedFileName}"; filename*=utf-8''${encodedFilenameStar}`;
644
- }
645
- function getFilenameFromContentDisposition(contentDisposition) {
646
- const encodedFilenameStarMatch = contentDisposition.match(/filename\*=(UTF-8'')?([^;]*)/i);
647
- if (encodedFilenameStarMatch && typeof encodedFilenameStarMatch[2] === "string") {
648
- return tryDecodeURIComponent(encodedFilenameStarMatch[2]);
649
- }
650
- const encodedFilenameMatch = contentDisposition.match(/filename="((?:\\"|[^"])*)"/i);
651
- if (encodedFilenameMatch && typeof encodedFilenameMatch[1] === "string") {
652
- return encodedFilenameMatch[1].replace(/\\"/g, '"');
653
- }
654
- }
655
- function mergeStandardHeaders(a, b) {
656
- const merged = { ...a };
657
- for (const key in b) {
658
- if (Array.isArray(b[key])) {
659
- merged[key] = [...toArray(merged[key]), ...b[key]];
660
- } else if (b[key] !== void 0) {
661
- if (Array.isArray(merged[key])) {
662
- merged[key] = [...merged[key], b[key]];
663
- } else if (merged[key] !== void 0) {
664
- merged[key] = [merged[key], b[key]];
665
- } else {
666
- merged[key] = b[key];
667
- }
668
- }
669
- }
670
- return merged;
671
- }
672
-
673
- // ../../node_modules/.bun/@orpc+client@1.13.4+460773ef8ff1e07c/node_modules/@orpc/client/dist/shared/client.BLtwTQUg.mjs
674
- function mapEventIterator(iterator, maps) {
675
- const mapError = async (error) => {
676
- let mappedError = await maps.error(error);
677
- if (mappedError !== error) {
678
- const meta = getEventMeta(error);
679
- if (meta && isTypescriptObject(mappedError)) {
680
- mappedError = withEventMeta(mappedError, meta);
681
- }
682
- }
683
- return mappedError;
684
- };
685
- return new AsyncIteratorClass(async () => {
686
- const { done, value: value2 } = await (async () => {
687
- try {
688
- return await iterator.next();
689
- } catch (error) {
690
- throw await mapError(error);
691
- }
692
- })();
693
- let mappedValue = await maps.value(value2, done);
694
- if (mappedValue !== value2) {
695
- const meta = getEventMeta(value2);
696
- if (meta && isTypescriptObject(mappedValue)) {
697
- mappedValue = withEventMeta(mappedValue, meta);
698
- }
699
- }
700
- return { done, value: mappedValue };
701
- }, async () => {
702
- try {
703
- await iterator.return?.();
704
- } catch (error) {
705
- throw await mapError(error);
706
- }
707
- });
708
- }
709
-
710
- // ../../node_modules/.bun/@orpc+client@1.13.4+460773ef8ff1e07c/node_modules/@orpc/client/dist/index.mjs
711
- function resolveFriendlyClientOptions(options) {
712
- return {
713
- ...options,
714
- context: options.context ?? {}
715
- // Context only optional if all fields are optional
716
- };
717
- }
718
- function createORPCClient(link, options = {}) {
719
- const path = options.path ?? [];
720
- const procedureClient = async (...[input, options2 = {}]) => {
721
- return await link.call(path, input, resolveFriendlyClientOptions(options2));
722
- };
723
- const recursive = new Proxy(procedureClient, {
724
- get(target, key) {
725
- if (typeof key !== "string") {
726
- return Reflect.get(target, key);
727
- }
728
- return createORPCClient(link, {
729
- ...options,
730
- path: [...path, key]
731
- });
732
- }
733
- });
734
- return preventNativeAwait(recursive);
735
- }
736
-
737
- // ../../node_modules/.bun/@orpc+standard-server-fetch@1.13.4+460773ef8ff1e07c/node_modules/@orpc/standard-server-fetch/dist/index.mjs
738
- function toEventIterator(stream, options = {}) {
739
- const eventStream = stream?.pipeThrough(new TextDecoderStream()).pipeThrough(new EventDecoderStream());
740
- const reader = eventStream?.getReader();
741
- let span;
742
- let isCancelled = false;
743
- return new AsyncIteratorClass(async () => {
744
- span ??= startSpan("consume_event_iterator_stream");
745
- try {
746
- while (true) {
747
- if (reader === void 0) {
748
- return { done: true, value: void 0 };
749
- }
750
- const { done, value: value2 } = await runInSpanContext(span, () => reader.read());
751
- if (done) {
752
- if (isCancelled) {
753
- throw new AbortError("Stream was cancelled");
754
- }
755
- return { done: true, value: void 0 };
756
- }
757
- switch (value2.event) {
758
- case "message": {
759
- let message = parseEmptyableJSON(value2.data);
760
- if (isTypescriptObject(message)) {
761
- message = withEventMeta(message, value2);
762
- }
763
- span?.addEvent("message");
764
- return { done: false, value: message };
765
- }
766
- case "error": {
767
- let error = new ErrorEvent({
768
- data: parseEmptyableJSON(value2.data)
769
- });
770
- error = withEventMeta(error, value2);
771
- span?.addEvent("error");
772
- throw error;
773
- }
774
- case "done": {
775
- let done2 = parseEmptyableJSON(value2.data);
776
- if (isTypescriptObject(done2)) {
777
- done2 = withEventMeta(done2, value2);
778
- }
779
- span?.addEvent("done");
780
- return { done: true, value: done2 };
781
- }
782
- default: {
783
- span?.addEvent("maybe_keepalive");
784
- }
785
- }
786
- }
787
- } catch (e) {
788
- if (!(e instanceof ErrorEvent)) {
789
- setSpanError(span, e, options);
790
- }
791
- throw e;
792
- }
793
- }, async (reason) => {
794
- try {
795
- if (reason !== "next") {
796
- isCancelled = true;
797
- span?.addEvent("cancelled");
798
- }
799
- await runInSpanContext(span, () => reader?.cancel());
800
- } catch (e) {
801
- setSpanError(span, e, options);
802
- throw e;
803
- } finally {
804
- span?.end();
805
- }
806
- });
807
- }
808
- function toEventStream(iterator, options = {}) {
809
- const keepAliveEnabled = options.eventIteratorKeepAliveEnabled ?? true;
810
- const keepAliveInterval = options.eventIteratorKeepAliveInterval ?? 5e3;
811
- const keepAliveComment = options.eventIteratorKeepAliveComment ?? "";
812
- const initialCommentEnabled = options.eventIteratorInitialCommentEnabled ?? true;
813
- const initialComment = options.eventIteratorInitialComment ?? "";
814
- let cancelled = false;
815
- let timeout;
816
- let span;
817
- const stream = new ReadableStream({
818
- start(controller) {
819
- span = startSpan("stream_event_iterator");
820
- if (initialCommentEnabled) {
821
- controller.enqueue(encodeEventMessage({
822
- comments: [initialComment]
823
- }));
824
- }
825
- },
826
- async pull(controller) {
827
- try {
828
- if (keepAliveEnabled) {
829
- timeout = setInterval(() => {
830
- controller.enqueue(encodeEventMessage({
831
- comments: [keepAliveComment]
832
- }));
833
- span?.addEvent("keepalive");
834
- }, keepAliveInterval);
835
- }
836
- const value2 = await runInSpanContext(span, () => iterator.next());
837
- clearInterval(timeout);
838
- if (cancelled) {
839
- return;
840
- }
841
- const meta = getEventMeta(value2.value);
842
- if (!value2.done || value2.value !== void 0 || meta !== void 0) {
843
- const event = value2.done ? "done" : "message";
844
- controller.enqueue(encodeEventMessage({
845
- ...meta,
846
- event,
847
- data: stringifyJSON(value2.value)
848
- }));
849
- span?.addEvent(event);
850
- }
851
- if (value2.done) {
852
- controller.close();
853
- span?.end();
854
- }
855
- } catch (err) {
856
- clearInterval(timeout);
857
- if (cancelled) {
858
- return;
859
- }
860
- if (err instanceof ErrorEvent) {
861
- controller.enqueue(encodeEventMessage({
862
- ...getEventMeta(err),
863
- event: "error",
864
- data: stringifyJSON(err.data)
865
- }));
866
- span?.addEvent("error");
867
- controller.close();
868
- } else {
869
- setSpanError(span, err);
870
- controller.error(err);
871
- }
872
- span?.end();
873
- }
874
- },
875
- async cancel() {
876
- try {
877
- cancelled = true;
878
- clearInterval(timeout);
879
- span?.addEvent("cancelled");
880
- await runInSpanContext(span, () => iterator.return?.());
881
- } catch (e) {
882
- setSpanError(span, e);
883
- throw e;
884
- } finally {
885
- span?.end();
886
- }
887
- }
888
- }).pipeThrough(new TextEncoderStream());
889
- return stream;
890
- }
891
- function toStandardBody(re, options = {}) {
892
- return runWithSpan(
893
- { name: "parse_standard_body", signal: options.signal },
894
- async () => {
895
- const contentDisposition = re.headers.get("content-disposition");
896
- if (typeof contentDisposition === "string") {
897
- const fileName = getFilenameFromContentDisposition(contentDisposition) ?? "blob";
898
- const blob2 = await re.blob();
899
- return new File([blob2], fileName, {
900
- type: blob2.type
901
- });
902
- }
903
- const contentType = re.headers.get("content-type");
904
- if (!contentType || contentType.startsWith("application/json")) {
905
- const text = await re.text();
906
- return parseEmptyableJSON(text);
907
- }
908
- if (contentType.startsWith("multipart/form-data")) {
909
- return await re.formData();
910
- }
911
- if (contentType.startsWith("application/x-www-form-urlencoded")) {
912
- const text = await re.text();
913
- return new URLSearchParams(text);
914
- }
915
- if (contentType.startsWith("text/event-stream")) {
916
- return toEventIterator(re.body, options);
917
- }
918
- if (contentType.startsWith("text/plain")) {
919
- return await re.text();
920
- }
921
- const blob = await re.blob();
922
- return new File([blob], "blob", {
923
- type: blob.type
924
- });
925
- }
926
- );
927
- }
928
- function toFetchBody(body, headers, options = {}) {
929
- const currentContentDisposition = headers.get("content-disposition");
930
- headers.delete("content-type");
931
- headers.delete("content-disposition");
932
- if (body === void 0) {
933
- return void 0;
934
- }
935
- if (body instanceof Blob) {
936
- headers.set("content-type", body.type);
937
- headers.set("content-length", body.size.toString());
938
- headers.set(
939
- "content-disposition",
940
- currentContentDisposition ?? generateContentDisposition(body instanceof File ? body.name : "blob")
941
- );
942
- return body;
943
- }
944
- if (body instanceof FormData) {
945
- return body;
946
- }
947
- if (body instanceof URLSearchParams) {
948
- return body;
949
- }
950
- if (isAsyncIteratorObject(body)) {
951
- headers.set("content-type", "text/event-stream");
952
- return toEventStream(body, options);
953
- }
954
- headers.set("content-type", "application/json");
955
- return stringifyJSON(body);
956
- }
957
- function toStandardHeaders(headers, standardHeaders = {}) {
958
- headers.forEach((value2, key) => {
959
- if (Array.isArray(standardHeaders[key])) {
960
- standardHeaders[key].push(value2);
961
- } else if (standardHeaders[key] !== void 0) {
962
- standardHeaders[key] = [standardHeaders[key], value2];
963
- } else {
964
- standardHeaders[key] = value2;
965
- }
966
- });
967
- return standardHeaders;
968
- }
969
- function toFetchHeaders(headers, fetchHeaders = new Headers()) {
970
- for (const [key, value2] of Object.entries(headers)) {
971
- if (Array.isArray(value2)) {
972
- for (const v of value2) {
973
- fetchHeaders.append(key, v);
974
- }
975
- } else if (value2 !== void 0) {
976
- fetchHeaders.append(key, value2);
977
- }
978
- }
979
- return fetchHeaders;
980
- }
981
- function toFetchRequest(request, options = {}) {
982
- const headers = toFetchHeaders(request.headers);
983
- const body = toFetchBody(request.body, headers, options);
984
- return new Request(request.url, {
985
- signal: request.signal,
986
- method: request.method,
987
- headers,
988
- body
989
- });
990
- }
991
- function toStandardLazyResponse(response, options = {}) {
992
- return {
993
- body: once(() => toStandardBody(response, options)),
994
- status: response.status,
995
- get headers() {
996
- const headers = toStandardHeaders(response.headers);
997
- Object.defineProperty(this, "headers", { value: headers, writable: true });
998
- return headers;
999
- },
1000
- set headers(value2) {
1001
- Object.defineProperty(this, "headers", { value: value2, writable: true });
1002
- }
1003
- };
1004
- }
1005
-
1006
- // ../../node_modules/.bun/@orpc+client@1.13.4+460773ef8ff1e07c/node_modules/@orpc/client/dist/shared/client.CRfRve1v.mjs
1007
- var CompositeStandardLinkPlugin = class {
1008
- plugins;
1009
- constructor(plugins = []) {
1010
- this.plugins = [...plugins].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
1011
- }
1012
- init(options) {
1013
- for (const plugin of this.plugins) {
1014
- plugin.init?.(options);
1015
- }
1016
- }
1017
- };
1018
- var StandardLink = class {
1019
- constructor(codec, sender, options = {}) {
1020
- this.codec = codec;
1021
- this.sender = sender;
1022
- const plugin = new CompositeStandardLinkPlugin(options.plugins);
1023
- plugin.init(options);
1024
- this.interceptors = toArray(options.interceptors);
1025
- this.clientInterceptors = toArray(options.clientInterceptors);
1026
- }
1027
- interceptors;
1028
- clientInterceptors;
1029
- call(path, input, options) {
1030
- return runWithSpan(
1031
- { name: `${ORPC_NAME}.${path.join("/")}`, signal: options.signal },
1032
- (span) => {
1033
- span?.setAttribute("rpc.system", ORPC_NAME);
1034
- span?.setAttribute("rpc.method", path.join("."));
1035
- if (isAsyncIteratorObject(input)) {
1036
- input = asyncIteratorWithSpan(
1037
- { name: "consume_event_iterator_input", signal: options.signal },
1038
- input
1039
- );
1040
- }
1041
- return intercept(this.interceptors, { ...options, path, input }, async ({ path: path2, input: input2, ...options2 }) => {
1042
- const otelConfig = getGlobalOtelConfig();
1043
- let otelContext;
1044
- const currentSpan = otelConfig?.trace.getActiveSpan() ?? span;
1045
- if (currentSpan && otelConfig) {
1046
- otelContext = otelConfig?.trace.setSpan(otelConfig.context.active(), currentSpan);
1047
- }
1048
- const request = await runWithSpan(
1049
- { name: "encode_request", context: otelContext },
1050
- () => this.codec.encode(path2, input2, options2)
1051
- );
1052
- const response = await intercept(
1053
- this.clientInterceptors,
1054
- { ...options2, input: input2, path: path2, request },
1055
- ({ input: input3, path: path3, request: request2, ...options3 }) => {
1056
- return runWithSpan(
1057
- { name: "send_request", signal: options3.signal, context: otelContext },
1058
- () => this.sender.call(request2, options3, path3, input3)
1059
- );
1060
- }
1061
- );
1062
- const output = await runWithSpan(
1063
- { name: "decode_response", context: otelContext },
1064
- () => this.codec.decode(response, options2, path2, input2)
1065
- );
1066
- if (isAsyncIteratorObject(output)) {
1067
- return asyncIteratorWithSpan(
1068
- { name: "consume_event_iterator_output", signal: options2.signal },
1069
- output
1070
- );
1071
- }
1072
- return output;
1073
- });
1074
- }
1075
- );
1076
- }
1077
- };
1078
- var STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES = {
1079
- BIGINT: 0,
1080
- DATE: 1,
1081
- NAN: 2,
1082
- UNDEFINED: 3,
1083
- URL: 4,
1084
- REGEXP: 5,
1085
- SET: 6,
1086
- MAP: 7
1087
- };
1088
- var StandardRPCJsonSerializer = class {
1089
- customSerializers;
1090
- constructor(options = {}) {
1091
- this.customSerializers = options.customJsonSerializers ?? [];
1092
- if (this.customSerializers.length !== new Set(this.customSerializers.map((custom) => custom.type)).size) {
1093
- throw new Error("Custom serializer type must be unique.");
1094
- }
1095
- }
1096
- serialize(data, segments = [], meta = [], maps = [], blobs = []) {
1097
- for (const custom of this.customSerializers) {
1098
- if (custom.condition(data)) {
1099
- const result = this.serialize(custom.serialize(data), segments, meta, maps, blobs);
1100
- meta.push([custom.type, ...segments]);
1101
- return result;
1102
- }
1103
- }
1104
- if (data instanceof Blob) {
1105
- maps.push(segments);
1106
- blobs.push(data);
1107
- return [data, meta, maps, blobs];
1108
- }
1109
- if (typeof data === "bigint") {
1110
- meta.push([STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.BIGINT, ...segments]);
1111
- return [data.toString(), meta, maps, blobs];
1112
- }
1113
- if (data instanceof Date) {
1114
- meta.push([STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.DATE, ...segments]);
1115
- if (Number.isNaN(data.getTime())) {
1116
- return [null, meta, maps, blobs];
1117
- }
1118
- return [data.toISOString(), meta, maps, blobs];
1119
- }
1120
- if (Number.isNaN(data)) {
1121
- meta.push([STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.NAN, ...segments]);
1122
- return [null, meta, maps, blobs];
1123
- }
1124
- if (data instanceof URL) {
1125
- meta.push([STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.URL, ...segments]);
1126
- return [data.toString(), meta, maps, blobs];
1127
- }
1128
- if (data instanceof RegExp) {
1129
- meta.push([STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.REGEXP, ...segments]);
1130
- return [data.toString(), meta, maps, blobs];
1131
- }
1132
- if (data instanceof Set) {
1133
- const result = this.serialize(Array.from(data), segments, meta, maps, blobs);
1134
- meta.push([STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.SET, ...segments]);
1135
- return result;
1136
- }
1137
- if (data instanceof Map) {
1138
- const result = this.serialize(Array.from(data.entries()), segments, meta, maps, blobs);
1139
- meta.push([STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.MAP, ...segments]);
1140
- return result;
1141
- }
1142
- if (Array.isArray(data)) {
1143
- const json = data.map((v, i) => {
1144
- if (v === void 0) {
1145
- meta.push([STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.UNDEFINED, ...segments, i]);
1146
- return v;
1147
- }
1148
- return this.serialize(v, [...segments, i], meta, maps, blobs)[0];
1149
- });
1150
- return [json, meta, maps, blobs];
1151
- }
1152
- if (isObject(data)) {
1153
- const json = {};
1154
- for (const k in data) {
1155
- if (k === "toJSON" && typeof data[k] === "function") {
1156
- continue;
1157
- }
1158
- json[k] = this.serialize(data[k], [...segments, k], meta, maps, blobs)[0];
1159
- }
1160
- return [json, meta, maps, blobs];
1161
- }
1162
- return [data, meta, maps, blobs];
1163
- }
1164
- deserialize(json, meta, maps, getBlob) {
1165
- const ref = { data: json };
1166
- if (maps && getBlob) {
1167
- maps.forEach((segments, i) => {
1168
- let currentRef = ref;
1169
- let preSegment = "data";
1170
- segments.forEach((segment) => {
1171
- currentRef = currentRef[preSegment];
1172
- preSegment = segment;
1173
- });
1174
- currentRef[preSegment] = getBlob(i);
1175
- });
1176
- }
1177
- for (const item of meta) {
1178
- const type = item[0];
1179
- let currentRef = ref;
1180
- let preSegment = "data";
1181
- for (let i = 1; i < item.length; i++) {
1182
- currentRef = currentRef[preSegment];
1183
- preSegment = item[i];
1184
- }
1185
- for (const custom of this.customSerializers) {
1186
- if (custom.type === type) {
1187
- currentRef[preSegment] = custom.deserialize(currentRef[preSegment]);
1188
- break;
1189
- }
1190
- }
1191
- switch (type) {
1192
- case STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.BIGINT:
1193
- currentRef[preSegment] = BigInt(currentRef[preSegment]);
1194
- break;
1195
- case STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.DATE:
1196
- currentRef[preSegment] = new Date(currentRef[preSegment] ?? "Invalid Date");
1197
- break;
1198
- case STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.NAN:
1199
- currentRef[preSegment] = Number.NaN;
1200
- break;
1201
- case STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.UNDEFINED:
1202
- currentRef[preSegment] = void 0;
1203
- break;
1204
- case STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.URL:
1205
- currentRef[preSegment] = new URL(currentRef[preSegment]);
1206
- break;
1207
- case STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.REGEXP: {
1208
- const [, pattern, flags] = currentRef[preSegment].match(/^\/(.*)\/([a-z]*)$/);
1209
- currentRef[preSegment] = new RegExp(pattern, flags);
1210
- break;
1211
- }
1212
- case STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.SET:
1213
- currentRef[preSegment] = new Set(currentRef[preSegment]);
1214
- break;
1215
- case STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.MAP:
1216
- currentRef[preSegment] = new Map(currentRef[preSegment]);
1217
- break;
1218
- }
1219
- }
1220
- return ref.data;
1221
- }
1222
- };
1223
- function toHttpPath(path) {
1224
- return `/${path.map(encodeURIComponent).join("/")}`;
1225
- }
1226
- function toStandardHeaders2(headers) {
1227
- if (typeof headers.forEach === "function") {
1228
- return toStandardHeaders(headers);
1229
- }
1230
- return headers;
1231
- }
1232
- function getMalformedResponseErrorCode(status) {
1233
- return Object.entries(COMMON_ORPC_ERROR_DEFS).find(([, def]) => def.status === status)?.[0] ?? "MALFORMED_ORPC_ERROR_RESPONSE";
1234
- }
1235
- var StandardRPCLinkCodec = class {
1236
- constructor(serializer, options) {
1237
- this.serializer = serializer;
1238
- this.baseUrl = options.url;
1239
- this.maxUrlLength = options.maxUrlLength ?? 2083;
1240
- this.fallbackMethod = options.fallbackMethod ?? "POST";
1241
- this.expectedMethod = options.method ?? this.fallbackMethod;
1242
- this.headers = options.headers ?? {};
1243
- }
1244
- baseUrl;
1245
- maxUrlLength;
1246
- fallbackMethod;
1247
- expectedMethod;
1248
- headers;
1249
- async encode(path, input, options) {
1250
- let headers = toStandardHeaders2(await value(this.headers, options, path, input));
1251
- if (options.lastEventId !== void 0) {
1252
- headers = mergeStandardHeaders(headers, { "last-event-id": options.lastEventId });
1253
- }
1254
- const expectedMethod = await value(this.expectedMethod, options, path, input);
1255
- const baseUrl = await value(this.baseUrl, options, path, input);
1256
- const url = new URL(baseUrl);
1257
- url.pathname = `${url.pathname.replace(/\/$/, "")}${toHttpPath(path)}`;
1258
- const serialized = this.serializer.serialize(input);
1259
- if (expectedMethod === "GET" && !(serialized instanceof FormData) && !isAsyncIteratorObject(serialized)) {
1260
- const maxUrlLength = await value(this.maxUrlLength, options, path, input);
1261
- const getUrl = new URL(url);
1262
- getUrl.searchParams.append("data", stringifyJSON(serialized));
1263
- if (getUrl.toString().length <= maxUrlLength) {
1264
- return {
1265
- body: void 0,
1266
- method: expectedMethod,
1267
- headers,
1268
- url: getUrl,
1269
- signal: options.signal
1270
- };
1271
- }
1272
- }
1273
- return {
1274
- url,
1275
- method: expectedMethod === "GET" ? this.fallbackMethod : expectedMethod,
1276
- headers,
1277
- body: serialized,
1278
- signal: options.signal
1279
- };
1280
- }
1281
- async decode(response) {
1282
- const isOk = !isORPCErrorStatus(response.status);
1283
- const deserialized = await (async () => {
1284
- let isBodyOk = false;
1285
- try {
1286
- const body = await response.body();
1287
- isBodyOk = true;
1288
- return this.serializer.deserialize(body);
1289
- } catch (error) {
1290
- if (!isBodyOk) {
1291
- throw new Error("Cannot parse response body, please check the response body and content-type.", {
1292
- cause: error
1293
- });
1294
- }
1295
- throw new Error("Invalid RPC response format.", {
1296
- cause: error
1297
- });
1298
- }
1299
- })();
1300
- if (!isOk) {
1301
- if (isORPCErrorJson(deserialized)) {
1302
- throw createORPCErrorFromJson(deserialized);
1303
- }
1304
- throw new ORPCError(getMalformedResponseErrorCode(response.status), {
1305
- status: response.status,
1306
- data: { ...response, body: deserialized }
1307
- });
1308
- }
1309
- return deserialized;
1310
- }
1311
- };
1312
- var StandardRPCSerializer = class {
1313
- constructor(jsonSerializer) {
1314
- this.jsonSerializer = jsonSerializer;
1315
- }
1316
- serialize(data) {
1317
- if (isAsyncIteratorObject(data)) {
1318
- return mapEventIterator(data, {
1319
- value: async (value2) => this.#serialize(value2, false),
1320
- error: async (e) => {
1321
- return new ErrorEvent({
1322
- data: this.#serialize(toORPCError(e).toJSON(), false),
1323
- cause: e
1324
- });
1325
- }
1326
- });
1327
- }
1328
- return this.#serialize(data, true);
1329
- }
1330
- #serialize(data, enableFormData) {
1331
- const [json, meta_, maps, blobs] = this.jsonSerializer.serialize(data);
1332
- const meta = meta_.length === 0 ? void 0 : meta_;
1333
- if (!enableFormData || blobs.length === 0) {
1334
- return {
1335
- json,
1336
- meta
1337
- };
1338
- }
1339
- const form = new FormData();
1340
- form.set("data", stringifyJSON({ json, meta, maps }));
1341
- blobs.forEach((blob, i) => {
1342
- form.set(i.toString(), blob);
1343
- });
1344
- return form;
1345
- }
1346
- deserialize(data) {
1347
- if (isAsyncIteratorObject(data)) {
1348
- return mapEventIterator(data, {
1349
- value: async (value2) => this.#deserialize(value2),
1350
- error: async (e) => {
1351
- if (!(e instanceof ErrorEvent)) {
1352
- return e;
1353
- }
1354
- const deserialized = this.#deserialize(e.data);
1355
- if (isORPCErrorJson(deserialized)) {
1356
- return createORPCErrorFromJson(deserialized, { cause: e });
1357
- }
1358
- return new ErrorEvent({
1359
- data: deserialized,
1360
- cause: e
1361
- });
1362
- }
1363
- });
1364
- }
1365
- return this.#deserialize(data);
1366
- }
1367
- #deserialize(data) {
1368
- if (data === void 0) {
1369
- return void 0;
1370
- }
1371
- if (!(data instanceof FormData)) {
1372
- return this.jsonSerializer.deserialize(data.json, data.meta ?? []);
1373
- }
1374
- const serialized = JSON.parse(data.get("data"));
1375
- return this.jsonSerializer.deserialize(
1376
- serialized.json,
1377
- serialized.meta ?? [],
1378
- serialized.maps,
1379
- (i) => data.get(i.toString())
1380
- );
1381
- }
1382
- };
1383
- var StandardRPCLink = class extends StandardLink {
1384
- constructor(linkClient, options) {
1385
- const jsonSerializer = new StandardRPCJsonSerializer(options);
1386
- const serializer = new StandardRPCSerializer(jsonSerializer);
1387
- const linkCodec = new StandardRPCLinkCodec(serializer, options);
1388
- super(linkCodec, linkClient, options);
1389
- }
1390
- };
1391
-
1392
- // ../../node_modules/.bun/@orpc+client@1.13.4+460773ef8ff1e07c/node_modules/@orpc/client/dist/adapters/fetch/index.mjs
1393
- var CompositeLinkFetchPlugin = class extends CompositeStandardLinkPlugin {
1394
- initRuntimeAdapter(options) {
1395
- for (const plugin of this.plugins) {
1396
- plugin.initRuntimeAdapter?.(options);
1397
- }
1398
- }
1399
- };
1400
- var LinkFetchClient = class {
1401
- fetch;
1402
- toFetchRequestOptions;
1403
- adapterInterceptors;
1404
- constructor(options) {
1405
- const plugin = new CompositeLinkFetchPlugin(options.plugins);
1406
- plugin.initRuntimeAdapter(options);
1407
- this.fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
1408
- this.toFetchRequestOptions = options;
1409
- this.adapterInterceptors = toArray(options.adapterInterceptors);
1410
- }
1411
- async call(standardRequest, options, path, input) {
1412
- const request = toFetchRequest(standardRequest, this.toFetchRequestOptions);
1413
- const fetchResponse = await intercept(
1414
- this.adapterInterceptors,
1415
- { ...options, request, path, input, init: { redirect: "manual" } },
1416
- ({ request: request2, path: path2, input: input2, init, ...options2 }) => this.fetch(request2, init, options2, path2, input2)
1417
- );
1418
- const lazyResponse = toStandardLazyResponse(fetchResponse, { signal: request.signal });
1419
- return lazyResponse;
1420
- }
1421
- };
1422
- var RPCLink = class extends StandardRPCLink {
1423
- constructor(options) {
1424
- const linkClient = new LinkFetchClient(options);
1425
- super(linkClient, options);
1426
- }
1427
- };
1428
-
1429
- // ../../node_modules/.bun/@tanstack+query-core@5.90.10/node_modules/@tanstack/query-core/build/modern/utils.js
1430
- var isServer = typeof window === "undefined" || "Deno" in globalThis;
1431
- var skipToken = /* @__PURE__ */ Symbol();
1432
-
1433
- // ../../node_modules/.bun/@orpc+tanstack-query@1.13.4+951a70f6a2b70cf3/node_modules/@orpc/tanstack-query/dist/index.mjs
1434
- function generateOperationKey(path, state = {}) {
1435
- return [path, {
1436
- ...state.input !== void 0 ? { input: state.input } : {},
1437
- ...state.type !== void 0 ? { type: state.type } : {},
1438
- ...state.fnOptions !== void 0 ? { fnOptions: state.fnOptions } : {}
1439
- }];
1440
- }
1441
- function createGeneralUtils(path) {
1442
- return {
1443
- key(options) {
1444
- return generateOperationKey(path, options);
1445
- }
1446
- };
1447
- }
1448
- function experimental_liveQuery(queryFn) {
1449
- return async (context) => {
1450
- const stream = await queryFn(context);
1451
- let last;
1452
- for await (const chunk of stream) {
1453
- if (context.signal.aborted) {
1454
- throw context.signal.reason;
1455
- }
1456
- last = { chunk };
1457
- context.client.setQueryData(context.queryKey, chunk);
1458
- }
1459
- if (!last) {
1460
- throw new Error(
1461
- `Live query for ${stringifyJSON(context.queryKey)} did not yield any data. Ensure the query function returns an AsyncIterable with at least one chunk.`
1462
- );
1463
- }
1464
- return last.chunk;
1465
- };
1466
- }
1467
- function experimental_serializableStreamedQuery(queryFn, { refetchMode = "reset", maxChunks = Number.POSITIVE_INFINITY } = {}) {
1468
- return async (context) => {
1469
- const query = context.client.getQueryCache().find({ queryKey: context.queryKey, exact: true });
1470
- const hasPreviousData = !!query && query.state.data !== void 0;
1471
- if (hasPreviousData) {
1472
- if (refetchMode === "reset") {
1473
- query.setState({
1474
- status: "pending",
1475
- data: void 0,
1476
- error: null,
1477
- fetchStatus: "fetching"
1478
- });
1479
- } else {
1480
- context.client.setQueryData(
1481
- context.queryKey,
1482
- (prev = []) => limitArraySize(prev, maxChunks)
1483
- );
1484
- }
1485
- }
1486
- let result = [];
1487
- const stream = await queryFn(context);
1488
- const shouldUpdateCacheDuringStream = !hasPreviousData || refetchMode !== "replace";
1489
- context.client.setQueryData(
1490
- context.queryKey,
1491
- (prev = []) => limitArraySize(prev, maxChunks)
1492
- );
1493
- for await (const chunk of stream) {
1494
- if (context.signal.aborted) {
1495
- throw context.signal.reason;
1496
- }
1497
- result.push(chunk);
1498
- result = limitArraySize(result, maxChunks);
1499
- if (shouldUpdateCacheDuringStream) {
1500
- context.client.setQueryData(
1501
- context.queryKey,
1502
- (prev = []) => limitArraySize([...prev, chunk], maxChunks)
1503
- );
1504
- }
1505
- }
1506
- if (!shouldUpdateCacheDuringStream) {
1507
- context.client.setQueryData(context.queryKey, result);
1508
- }
1509
- const cachedData = context.client.getQueryData(context.queryKey);
1510
- if (cachedData) {
1511
- return limitArraySize(cachedData, maxChunks);
1512
- }
1513
- return result;
1514
- };
1515
- }
1516
- function limitArraySize(items, maxSize) {
1517
- if (items.length <= maxSize) {
1518
- return items;
1519
- }
1520
- return items.slice(items.length - maxSize);
1521
- }
1522
- var OPERATION_CONTEXT_SYMBOL = /* @__PURE__ */ Symbol("ORPC_OPERATION_CONTEXT");
1523
- function createProcedureUtils(client, options) {
1524
- const utils = {
1525
- call: client,
1526
- queryKey(...[optionsIn = {}]) {
1527
- optionsIn = { ...options.experimental_defaults?.queryKey, ...optionsIn };
1528
- const queryKey = optionsIn.queryKey ?? generateOperationKey(options.path, { type: "query", input: optionsIn.input });
1529
- return queryKey;
1530
- },
1531
- queryOptions(...[optionsIn = {}]) {
1532
- optionsIn = { ...options.experimental_defaults?.queryOptions, ...optionsIn };
1533
- const queryKey = utils.queryKey(optionsIn);
1534
- return {
1535
- queryFn: ({ signal }) => {
1536
- if (optionsIn.input === skipToken) {
1537
- throw new Error("queryFn should not be called with skipToken used as input");
1538
- }
1539
- return client(optionsIn.input, {
1540
- signal,
1541
- context: {
1542
- [OPERATION_CONTEXT_SYMBOL]: {
1543
- key: queryKey,
1544
- type: "query"
1545
- },
1546
- ...optionsIn.context
1547
- }
1548
- });
1549
- },
1550
- ...optionsIn.input === skipToken ? { enabled: false } : {},
1551
- ...optionsIn,
1552
- queryKey
1553
- };
1554
- },
1555
- experimental_streamedKey(...[optionsIn = {}]) {
1556
- optionsIn = { ...options.experimental_defaults?.experimental_streamedKey, ...optionsIn };
1557
- const queryKey = optionsIn.queryKey ?? generateOperationKey(options.path, { type: "streamed", input: optionsIn.input, fnOptions: optionsIn.queryFnOptions });
1558
- return queryKey;
1559
- },
1560
- experimental_streamedOptions(...[optionsIn = {}]) {
1561
- optionsIn = { ...options.experimental_defaults?.experimental_streamedOptions, ...optionsIn };
1562
- const queryKey = utils.experimental_streamedKey(optionsIn);
1563
- return {
1564
- queryFn: experimental_serializableStreamedQuery(
1565
- async ({ signal }) => {
1566
- if (optionsIn.input === skipToken) {
1567
- throw new Error("queryFn should not be called with skipToken used as input");
1568
- }
1569
- const output = await client(optionsIn.input, {
1570
- signal,
1571
- context: {
1572
- [OPERATION_CONTEXT_SYMBOL]: {
1573
- key: queryKey,
1574
- type: "streamed"
1575
- },
1576
- ...optionsIn.context
1577
- }
1578
- });
1579
- if (!isAsyncIteratorObject(output)) {
1580
- throw new Error("streamedQuery requires an event iterator output");
1581
- }
1582
- return output;
1583
- },
1584
- optionsIn.queryFnOptions
1585
- ),
1586
- ...optionsIn.input === skipToken ? { enabled: false } : {},
1587
- ...optionsIn,
1588
- queryKey
1589
- };
1590
- },
1591
- experimental_liveKey(...[optionsIn = {}]) {
1592
- optionsIn = { ...options.experimental_defaults?.experimental_liveKey, ...optionsIn };
1593
- const queryKey = optionsIn.queryKey ?? generateOperationKey(options.path, { type: "live", input: optionsIn.input });
1594
- return queryKey;
1595
- },
1596
- experimental_liveOptions(...[optionsIn = {}]) {
1597
- optionsIn = { ...options.experimental_defaults?.experimental_liveOptions, ...optionsIn };
1598
- const queryKey = utils.experimental_liveKey(optionsIn);
1599
- return {
1600
- queryFn: experimental_liveQuery(async ({ signal }) => {
1601
- if (optionsIn.input === skipToken) {
1602
- throw new Error("queryFn should not be called with skipToken used as input");
1603
- }
1604
- const output = await client(optionsIn.input, {
1605
- signal,
1606
- context: {
1607
- [OPERATION_CONTEXT_SYMBOL]: {
1608
- key: queryKey,
1609
- type: "live"
1610
- },
1611
- ...optionsIn.context
1612
- }
1613
- });
1614
- if (!isAsyncIteratorObject(output)) {
1615
- throw new Error("liveQuery requires an event iterator output");
1616
- }
1617
- return output;
1618
- }),
1619
- ...optionsIn.input === skipToken ? { enabled: false } : {},
1620
- ...optionsIn,
1621
- queryKey
1622
- };
1623
- },
1624
- infiniteKey(optionsIn) {
1625
- optionsIn = { ...options.experimental_defaults?.infiniteKey, ...optionsIn };
1626
- const queryKey = optionsIn.queryKey ?? generateOperationKey(options.path, {
1627
- type: "infinite",
1628
- input: optionsIn.input === skipToken ? skipToken : optionsIn.input(optionsIn.initialPageParam)
1629
- });
1630
- return queryKey;
1631
- },
1632
- infiniteOptions(optionsIn) {
1633
- optionsIn = { ...options.experimental_defaults?.infiniteOptions, ...optionsIn };
1634
- const queryKey = utils.infiniteKey(optionsIn);
1635
- return {
1636
- queryFn: ({ pageParam, signal }) => {
1637
- if (optionsIn.input === skipToken) {
1638
- throw new Error("queryFn should not be called with skipToken used as input");
1639
- }
1640
- return client(optionsIn.input(pageParam), {
1641
- signal,
1642
- context: {
1643
- [OPERATION_CONTEXT_SYMBOL]: {
1644
- key: queryKey,
1645
- type: "infinite"
1646
- },
1647
- ...optionsIn.context
1648
- }
1649
- });
1650
- },
1651
- ...optionsIn.input === skipToken ? { enabled: false } : {},
1652
- ...optionsIn,
1653
- queryKey
1654
- };
1655
- },
1656
- mutationKey(...[optionsIn = {}]) {
1657
- optionsIn = { ...options.experimental_defaults?.mutationKey, ...optionsIn };
1658
- const mutationKey = optionsIn.mutationKey ?? generateOperationKey(options.path, { type: "mutation" });
1659
- return mutationKey;
1660
- },
1661
- mutationOptions(...[optionsIn = {}]) {
1662
- optionsIn = { ...options.experimental_defaults?.mutationOptions, ...optionsIn };
1663
- const mutationKey = utils.mutationKey(optionsIn);
1664
- return {
1665
- mutationFn: (input) => client(input, {
1666
- context: {
1667
- [OPERATION_CONTEXT_SYMBOL]: {
1668
- key: mutationKey,
1669
- type: "mutation"
1670
- },
1671
- ...optionsIn.context
1672
- }
1673
- }),
1674
- ...optionsIn,
1675
- mutationKey
1676
- };
1677
- }
1678
- };
1679
- return utils;
1680
- }
1681
- function createRouterUtils(client, options = {}) {
1682
- const path = toArray(options.path);
1683
- const generalUtils = createGeneralUtils(path);
1684
- const procedureUtils = createProcedureUtils(client, {
1685
- path,
1686
- experimental_defaults: options.experimental_defaults
1687
- });
1688
- const recursive = new Proxy({
1689
- ...generalUtils,
1690
- ...procedureUtils
1691
- }, {
1692
- get(target, prop) {
1693
- const value2 = Reflect.get(target, prop);
1694
- if (typeof prop !== "string") {
1695
- return value2;
1696
- }
1697
- const nextUtils = createRouterUtils(client[prop], {
1698
- ...options,
1699
- path: [...path, prop],
1700
- experimental_defaults: get(options.experimental_defaults, [prop])
1701
- });
1702
- if (typeof value2 !== "function") {
1703
- return nextUtils;
1704
- }
1705
- return new Proxy(value2, {
1706
- get(_, prop2) {
1707
- return Reflect.get(nextUtils, prop2);
1708
- }
1709
- });
1710
- }
1711
- });
1712
- return recursive;
1713
- }
1714
-
1715
- // ../core/src/client.ts
1716
- function createSwirlsClient(options) {
1
+ // src/client/client.ts
2
+ import { createORPCClient } from "@orpc/client";
3
+ import { RPCLink } from "@orpc/client/fetch";
4
+ import { createTanstackQueryUtils } from "@orpc/tanstack-query";
5
+ var DEFAULT_SWIRLS_API_URL = "https://swirls.ai/api";
6
+ function createSwirlsRpcClient(apiUrl, apiKey) {
1717
7
  const link = new RPCLink({
1718
- url: `${options.apiUrl.replace(/\/$/, "")}/rpc`,
8
+ url: `${apiUrl.replace(/\/$/, "")}/rpc`,
1719
9
  headers: () => ({
1720
- Authorization: `Bearer ${options.apiKey}`
10
+ Authorization: `Bearer ${apiKey}`
1721
11
  })
1722
12
  });
1723
13
  return createORPCClient(link);
1724
14
  }
1725
- function createSwirlsQueryUtils(client) {
1726
- return createRouterUtils(client);
1727
- }
1728
-
1729
- // src/client/generated.ts
1730
- var FoldersApi = class {
1731
- constructor(client, logger) {
1732
- this.client = client;
1733
- this.logger = logger;
1734
- }
1735
- /** Create a new folder for organizing resources */
1736
- async createFolder(input) {
1737
- const log = this.logger.createCallLogger("folders.createFolder");
1738
- log.set({ input });
1739
- const start = performance.now();
1740
- try {
1741
- const result = await this.client.createFolder(input);
1742
- log.set({ durationMs: Math.round(performance.now() - start) });
1743
- log.emit();
1744
- return result;
1745
- } catch (error) {
1746
- log.set({ durationMs: Math.round(performance.now() - start) });
1747
- log.error(error);
1748
- log.emit();
1749
- throw error;
1750
- }
1751
- }
1752
- /** Get a folder by ID */
1753
- async getFolder(input) {
1754
- const log = this.logger.createCallLogger("folders.getFolder");
1755
- log.set({ input });
1756
- const start = performance.now();
1757
- try {
1758
- const result = await this.client.getFolder(input);
1759
- log.set({ durationMs: Math.round(performance.now() - start) });
1760
- log.emit();
1761
- return result;
1762
- } catch (error) {
1763
- log.set({ durationMs: Math.round(performance.now() - start) });
1764
- log.error(error);
1765
- log.emit();
1766
- throw error;
1767
- }
1768
- }
1769
- /** Update a folder */
1770
- async updateFolder(input) {
1771
- const log = this.logger.createCallLogger("folders.updateFolder");
1772
- log.set({ input });
1773
- const start = performance.now();
1774
- try {
1775
- const result = await this.client.updateFolder(input);
1776
- log.set({ durationMs: Math.round(performance.now() - start) });
1777
- log.emit();
1778
- return result;
1779
- } catch (error) {
1780
- log.set({ durationMs: Math.round(performance.now() - start) });
1781
- log.error(error);
1782
- log.emit();
1783
- throw error;
1784
- }
1785
- }
1786
- /** Delete a folder */
1787
- async deleteFolder(input) {
1788
- const log = this.logger.createCallLogger("folders.deleteFolder");
1789
- log.set({ input });
1790
- const start = performance.now();
1791
- try {
1792
- const result = await this.client.deleteFolder(input);
1793
- log.set({ durationMs: Math.round(performance.now() - start) });
1794
- log.emit();
1795
- return result;
1796
- } catch (error) {
1797
- log.set({ durationMs: Math.round(performance.now() - start) });
1798
- log.error(error);
1799
- log.emit();
1800
- throw error;
1801
- }
1802
- }
1803
- /** List all folders in a project */
1804
- async listFolders(input) {
1805
- const log = this.logger.createCallLogger("folders.listFolders");
1806
- log.set({ input });
1807
- const start = performance.now();
1808
- try {
1809
- const result = await this.client.listFolders(input);
1810
- log.set({ durationMs: Math.round(performance.now() - start) });
1811
- log.emit();
1812
- return result;
1813
- } catch (error) {
1814
- log.set({ durationMs: Math.round(performance.now() - start) });
1815
- log.error(error);
1816
- log.emit();
1817
- throw error;
1818
- }
1819
- }
1820
- };
1821
- var GraphsApi = class {
1822
- constructor(client, logger) {
1823
- this.client = client;
1824
- this.logger = logger;
1825
- }
1826
- /** Create a new workflow graph */
1827
- async createGraph(input) {
1828
- const log = this.logger.createCallLogger("graphs.createGraph");
1829
- log.set({ input });
1830
- const start = performance.now();
1831
- try {
1832
- const result = await this.client.createGraph(input);
1833
- log.set({ durationMs: Math.round(performance.now() - start) });
1834
- log.emit();
1835
- return result;
1836
- } catch (error) {
1837
- log.set({ durationMs: Math.round(performance.now() - start) });
1838
- log.error(error);
1839
- log.emit();
1840
- throw error;
1841
- }
1842
- }
1843
- /** Get a graph with all its nodes and edges. Each node has position: { x, y } (canvas coordinates). Use this to understand workflow structure and existing layout. Before creating or updating nodes, call this to see existing positions so you can place new nodes and adjust positions for a visually compelling flow (e.g. left-to-right, consistent spacing, no overlap). Each node also includes inputSchema and outputSchema — inspect these before calling execute_graph. */
1844
- async getGraph(input) {
1845
- const log = this.logger.createCallLogger("graphs.getGraph");
1846
- log.set({ input });
1847
- const start = performance.now();
1848
- try {
1849
- const result = await this.client.getGraph(input);
1850
- log.set({ durationMs: Math.round(performance.now() - start) });
1851
- log.emit();
1852
- return result;
1853
- } catch (error) {
1854
- log.set({ durationMs: Math.round(performance.now() - start) });
1855
- log.error(error);
1856
- log.emit();
1857
- throw error;
1858
- }
1859
- }
1860
- /** Update an existing graph */
1861
- async updateGraph(input) {
1862
- const log = this.logger.createCallLogger("graphs.updateGraph");
1863
- log.set({ input });
1864
- const start = performance.now();
1865
- try {
1866
- const result = await this.client.updateGraph(input);
1867
- log.set({ durationMs: Math.round(performance.now() - start) });
1868
- log.emit();
1869
- return result;
1870
- } catch (error) {
1871
- log.set({ durationMs: Math.round(performance.now() - start) });
1872
- log.error(error);
1873
- log.emit();
1874
- throw error;
1875
- }
1876
- }
1877
- /** Delete a graph */
1878
- async deleteGraph(input) {
1879
- const log = this.logger.createCallLogger("graphs.deleteGraph");
1880
- log.set({ input });
1881
- const start = performance.now();
1882
- try {
1883
- const result = await this.client.deleteGraph(input);
1884
- log.set({ durationMs: Math.round(performance.now() - start) });
1885
- log.emit();
1886
- return result;
1887
- } catch (error) {
1888
- log.set({ durationMs: Math.round(performance.now() - start) });
1889
- log.error(error);
1890
- log.emit();
1891
- throw error;
1892
- }
1893
- }
1894
- /** List all graphs in a project */
1895
- async listGraphs(input) {
1896
- const log = this.logger.createCallLogger("graphs.listGraphs");
1897
- log.set({ input });
1898
- const start = performance.now();
1899
- try {
1900
- const result = await this.client.listGraphs(input);
1901
- log.set({ durationMs: Math.round(performance.now() - start) });
1902
- log.emit();
1903
- return result;
1904
- } catch (error) {
1905
- log.set({ durationMs: Math.round(performance.now() - start) });
1906
- log.error(error);
1907
- log.emit();
1908
- throw error;
1909
- }
1910
- }
1911
- /** Create a new node in a graph. For a visually compelling flow: call get_graph first to get existing nodes and their position { "x", "y" }; place the new node considering the layout—e.g. left-to-right (increase x for downstream), stack vertically (vary y), use ~150–200px spacing between nodes, avoid overlap. Position format: { "x": number, "y": number }. Node types and their configs: */
1912
- async createNode(input) {
1913
- const log = this.logger.createCallLogger("graphs.createNode");
1914
- log.set({ input });
1915
- const start = performance.now();
1916
- try {
1917
- const result = await this.client.createNode(input);
1918
- log.set({ durationMs: Math.round(performance.now() - start) });
1919
- log.emit();
1920
- return result;
1921
- } catch (error) {
1922
- log.set({ durationMs: Math.round(performance.now() - start) });
1923
- log.error(error);
1924
- log.emit();
1925
- throw error;
1926
- }
1927
- }
1928
- /** Update an existing node. For layout: call get_graph to see all nodes and edges; set position { "x", "y" } to improve flow—align with connected nodes, leave ~150–200px spacing, keep left-to-right or top-to-bottom order for a visually compelling layout. */
1929
- async updateNode(input) {
1930
- const log = this.logger.createCallLogger("graphs.updateNode");
1931
- log.set({ input });
1932
- const start = performance.now();
1933
- try {
1934
- const result = await this.client.updateNode(input);
1935
- log.set({ durationMs: Math.round(performance.now() - start) });
1936
- log.emit();
1937
- return result;
1938
- } catch (error) {
1939
- log.set({ durationMs: Math.round(performance.now() - start) });
1940
- log.error(error);
1941
- log.emit();
1942
- throw error;
1943
- }
1944
- }
1945
- /** Delete a node from a graph */
1946
- async deleteNode(input) {
1947
- const log = this.logger.createCallLogger("graphs.deleteNode");
1948
- log.set({ input });
1949
- const start = performance.now();
1950
- try {
1951
- const result = await this.client.deleteNode(input);
1952
- log.set({ durationMs: Math.round(performance.now() - start) });
1953
- log.emit();
1954
- return result;
1955
- } catch (error) {
1956
- log.set({ durationMs: Math.round(performance.now() - start) });
1957
- log.error(error);
1958
- log.emit();
1959
- throw error;
1960
- }
1961
- }
1962
- /** Create an edge connecting two nodes. Edges define the flow of data between nodes. Cycles are not allowed. */
1963
- async createEdge(input) {
1964
- const log = this.logger.createCallLogger("graphs.createEdge");
1965
- log.set({ input });
1966
- const start = performance.now();
1967
- try {
1968
- const result = await this.client.createEdge(input);
1969
- log.set({ durationMs: Math.round(performance.now() - start) });
1970
- log.emit();
1971
- return result;
1972
- } catch (error) {
1973
- log.set({ durationMs: Math.round(performance.now() - start) });
1974
- log.error(error);
1975
- log.emit();
1976
- throw error;
1977
- }
1978
- }
1979
- /** Delete an edge from a graph */
1980
- async deleteEdge(input) {
1981
- const log = this.logger.createCallLogger("graphs.deleteEdge");
1982
- log.set({ input });
1983
- const start = performance.now();
1984
- try {
1985
- const result = await this.client.deleteEdge(input);
1986
- log.set({ durationMs: Math.round(performance.now() - start) });
1987
- log.emit();
1988
- return result;
1989
- } catch (error) {
1990
- log.set({ durationMs: Math.round(performance.now() - start) });
1991
- log.error(error);
1992
- log.emit();
1993
- throw error;
1994
- }
1995
- }
1996
- /** Sync a complete graph structure with nodes and edges. This is the most efficient way to create or update a complete workflow in one operation. Each node can include position: { "x": number, "y": number }. For a visually compelling flow, assign positions so nodes run left-to-right (or top-to-bottom), with ~150–200px spacing and no overlap; consider edge connections when placing nodes. */
1997
- async syncGraph(input) {
1998
- const log = this.logger.createCallLogger("graphs.syncGraph");
1999
- log.set({ input });
2000
- const start = performance.now();
2001
- try {
2002
- const result = await this.client.syncGraph(input);
2003
- log.set({ durationMs: Math.round(performance.now() - start) });
2004
- log.emit();
2005
- return result;
2006
- } catch (error) {
2007
- log.set({ durationMs: Math.round(performance.now() - start) });
2008
- log.error(error);
2009
- log.emit();
2010
- throw error;
2011
- }
2012
- }
2013
- /** Execute a graph with input data. Returns an execution ID that can be used to track progress via get_execution. */
2014
- async executeGraph(input) {
2015
- const log = this.logger.createCallLogger("graphs.executeGraph");
2016
- log.set({ input });
2017
- const start = performance.now();
2018
- try {
2019
- const result = await this.client.executeGraph(input);
2020
- log.set({ durationMs: Math.round(performance.now() - start) });
2021
- log.emit();
2022
- return result;
2023
- } catch (error) {
2024
- log.set({ durationMs: Math.round(performance.now() - start) });
2025
- log.error(error);
2026
- log.emit();
2027
- throw error;
2028
- }
2029
- }
2030
- /** Get the status and results of a graph execution, including all node executions. Use the executionId returned by execute_graph. The response includes the overall status and each node's individual execution status and output. */
2031
- async getExecution(input) {
2032
- const log = this.logger.createCallLogger("graphs.getExecution");
2033
- log.set({ input });
2034
- const start = performance.now();
2035
- try {
2036
- const result = await this.client.getExecution(input);
2037
- log.set({ durationMs: Math.round(performance.now() - start) });
2038
- log.emit();
2039
- return result;
2040
- } catch (error) {
2041
- log.set({ durationMs: Math.round(performance.now() - start) });
2042
- log.error(error);
2043
- log.emit();
2044
- throw error;
2045
- }
2046
- }
2047
- /** List executions for a graph */
2048
- async listExecutions(input) {
2049
- const log = this.logger.createCallLogger("graphs.listExecutions");
2050
- log.set({ input });
2051
- const start = performance.now();
2052
- try {
2053
- const result = await this.client.listExecutions(input);
2054
- log.set({ durationMs: Math.round(performance.now() - start) });
2055
- log.emit();
2056
- return result;
2057
- } catch (error) {
2058
- log.set({ durationMs: Math.round(performance.now() - start) });
2059
- log.error(error);
2060
- log.emit();
2061
- throw error;
2062
- }
2063
- }
2064
- async listTriggers(input) {
2065
- const log = this.logger.createCallLogger("graphs.listTriggers");
2066
- log.set({ input });
2067
- const start = performance.now();
2068
- try {
2069
- const result = await this.client.listTriggers(input);
2070
- log.set({ durationMs: Math.round(performance.now() - start) });
2071
- log.emit();
2072
- return result;
2073
- } catch (error) {
2074
- log.set({ durationMs: Math.round(performance.now() - start) });
2075
- log.error(error);
2076
- log.emit();
2077
- throw error;
2078
- }
2079
- }
2080
- async getStream(input) {
2081
- const log = this.logger.createCallLogger("graphs.getStream");
2082
- log.set({ input });
2083
- const start = performance.now();
2084
- try {
2085
- const result = await this.client.getStream(input);
2086
- log.set({ durationMs: Math.round(performance.now() - start) });
2087
- log.emit();
2088
- return result;
2089
- } catch (error) {
2090
- log.set({ durationMs: Math.round(performance.now() - start) });
2091
- log.error(error);
2092
- log.emit();
2093
- throw error;
2094
- }
2095
- }
2096
- };
2097
- var TriggersApi = class {
2098
- constructor(client, logger) {
2099
- this.client = client;
2100
- this.logger = logger;
2101
- }
2102
- /** Create a trigger that connects a resource to a graph, so when the resource fires (form submission, webhook call, schedule tick, or agent tool call), the graph executes. Requires resourceType (form, webhook, schedule, or agent), resourceId (the resource's ID), and graphId (the target graph). */
2103
- async createTrigger(input) {
2104
- const log = this.logger.createCallLogger("triggers.createTrigger");
2105
- log.set({ input });
2106
- const start = performance.now();
2107
- try {
2108
- const result = await this.client.createTrigger(input);
2109
- log.set({ durationMs: Math.round(performance.now() - start) });
2110
- log.emit();
2111
- return result;
2112
- } catch (error) {
2113
- log.set({ durationMs: Math.round(performance.now() - start) });
2114
- log.error(error);
2115
- log.emit();
2116
- throw error;
2117
- }
2118
- }
2119
- /** Get a trigger by ID */
2120
- async getTrigger(input) {
2121
- const log = this.logger.createCallLogger("triggers.getTrigger");
2122
- log.set({ input });
2123
- const start = performance.now();
2124
- try {
2125
- const result = await this.client.getTrigger(input);
2126
- log.set({ durationMs: Math.round(performance.now() - start) });
2127
- log.emit();
2128
- return result;
2129
- } catch (error) {
2130
- log.set({ durationMs: Math.round(performance.now() - start) });
2131
- log.error(error);
2132
- log.emit();
2133
- throw error;
2134
- }
2135
- }
2136
- /** Update a trigger */
2137
- async updateTrigger(input) {
2138
- const log = this.logger.createCallLogger("triggers.updateTrigger");
2139
- log.set({ input });
2140
- const start = performance.now();
2141
- try {
2142
- const result = await this.client.updateTrigger(input);
2143
- log.set({ durationMs: Math.round(performance.now() - start) });
2144
- log.emit();
2145
- return result;
2146
- } catch (error) {
2147
- log.set({ durationMs: Math.round(performance.now() - start) });
2148
- log.error(error);
2149
- log.emit();
2150
- throw error;
2151
- }
2152
- }
2153
- /** Delete a trigger */
2154
- async deleteTrigger(input) {
2155
- const log = this.logger.createCallLogger("triggers.deleteTrigger");
2156
- log.set({ input });
2157
- const start = performance.now();
2158
- try {
2159
- const result = await this.client.deleteTrigger(input);
2160
- log.set({ durationMs: Math.round(performance.now() - start) });
2161
- log.emit();
2162
- return result;
2163
- } catch (error) {
2164
- log.set({ durationMs: Math.round(performance.now() - start) });
2165
- log.error(error);
2166
- log.emit();
2167
- throw error;
2168
- }
2169
- }
2170
- /** List all triggers in a project. Triggers connect resources (forms, webhooks, schedules, agents) to graphs. */
2171
- async listTriggers(input) {
2172
- const log = this.logger.createCallLogger("triggers.listTriggers");
2173
- log.set({ input });
2174
- const start = performance.now();
2175
- try {
2176
- const result = await this.client.listTriggers(input);
2177
- log.set({ durationMs: Math.round(performance.now() - start) });
2178
- log.emit();
2179
- return result;
2180
- } catch (error) {
2181
- log.set({ durationMs: Math.round(performance.now() - start) });
2182
- log.error(error);
2183
- log.emit();
2184
- throw error;
2185
- }
2186
- }
2187
- async listSchemaIncompatibilities(input) {
2188
- const log = this.logger.createCallLogger("triggers.listSchemaIncompatibilities");
2189
- log.set({ input });
2190
- const start = performance.now();
2191
- try {
2192
- const result = await this.client.listSchemaIncompatibilities(input);
2193
- log.set({ durationMs: Math.round(performance.now() - start) });
2194
- log.emit();
2195
- return result;
2196
- } catch (error) {
2197
- log.set({ durationMs: Math.round(performance.now() - start) });
2198
- log.error(error);
2199
- log.emit();
2200
- throw error;
2201
- }
2202
- }
2203
- /** Execute all enabled triggers for a resource (form, webhook, or schedule). The resourceId is the ID of the form/webhook/schedule. The "input" object should match the resource's schema — use get_form or get_webhook to inspect the schema first. Returns execution IDs for each triggered graph. */
2204
- async executeTriggers(input) {
2205
- const log = this.logger.createCallLogger("triggers.executeTriggers");
2206
- log.set({ input });
2207
- const start = performance.now();
2208
- try {
2209
- const result = await this.client.executeTriggers(input);
2210
- log.set({ durationMs: Math.round(performance.now() - start) });
2211
- log.emit();
2212
- return result;
2213
- } catch (error) {
2214
- log.set({ durationMs: Math.round(performance.now() - start) });
2215
- log.error(error);
2216
- log.emit();
2217
- throw error;
2218
- }
2219
- }
2220
- };
2221
- var AgentsApi = class {
2222
- constructor(client, logger) {
2223
- this.client = client;
2224
- this.logger = logger;
2225
- }
2226
- /** Create a new agent with a system prompt and tools that can trigger graphs */
2227
- async createAgent(input) {
2228
- const log = this.logger.createCallLogger("agents.createAgent");
2229
- log.set({ input });
2230
- const start = performance.now();
2231
- try {
2232
- const result = await this.client.createAgent(input);
2233
- log.set({ durationMs: Math.round(performance.now() - start) });
2234
- log.emit();
2235
- return result;
2236
- } catch (error) {
2237
- log.set({ durationMs: Math.round(performance.now() - start) });
2238
- log.error(error);
2239
- log.emit();
2240
- throw error;
2241
- }
2242
- }
2243
- /** Get an agent by ID with its tools */
2244
- async getAgent(input) {
2245
- const log = this.logger.createCallLogger("agents.getAgent");
2246
- log.set({ input });
2247
- const start = performance.now();
2248
- try {
2249
- const result = await this.client.getAgent(input);
2250
- log.set({ durationMs: Math.round(performance.now() - start) });
2251
- log.emit();
2252
- return result;
2253
- } catch (error) {
2254
- log.set({ durationMs: Math.round(performance.now() - start) });
2255
- log.error(error);
2256
- log.emit();
2257
- throw error;
2258
- }
2259
- }
2260
- /** Update an agent */
2261
- async updateAgent(input) {
2262
- const log = this.logger.createCallLogger("agents.updateAgent");
2263
- log.set({ input });
2264
- const start = performance.now();
2265
- try {
2266
- const result = await this.client.updateAgent(input);
2267
- log.set({ durationMs: Math.round(performance.now() - start) });
2268
- log.emit();
2269
- return result;
2270
- } catch (error) {
2271
- log.set({ durationMs: Math.round(performance.now() - start) });
2272
- log.error(error);
2273
- log.emit();
2274
- throw error;
2275
- }
2276
- }
2277
- /** Delete an agent */
2278
- async deleteAgent(input) {
2279
- const log = this.logger.createCallLogger("agents.deleteAgent");
2280
- log.set({ input });
2281
- const start = performance.now();
2282
- try {
2283
- const result = await this.client.deleteAgent(input);
2284
- log.set({ durationMs: Math.round(performance.now() - start) });
2285
- log.emit();
2286
- return result;
2287
- } catch (error) {
2288
- log.set({ durationMs: Math.round(performance.now() - start) });
2289
- log.error(error);
2290
- log.emit();
2291
- throw error;
2292
- }
2293
- }
2294
- /** List all agents in a project. Agents are AI assistants with tools that can trigger graphs. */
2295
- async listAgents(input) {
2296
- const log = this.logger.createCallLogger("agents.listAgents");
2297
- log.set({ input });
2298
- const start = performance.now();
2299
- try {
2300
- const result = await this.client.listAgents(input);
2301
- log.set({ durationMs: Math.round(performance.now() - start) });
2302
- log.emit();
2303
- return result;
2304
- } catch (error) {
2305
- log.set({ durationMs: Math.round(performance.now() - start) });
2306
- log.error(error);
2307
- log.emit();
2308
- throw error;
2309
- }
2310
- }
2311
- };
2312
- var SchemasApi = class {
2313
- constructor(client, logger) {
2314
- this.client = client;
2315
- this.logger = logger;
2316
- }
2317
- /** Create a new JSON Schema definition that can be used for validation. */
2318
- async createSchema(input) {
2319
- const log = this.logger.createCallLogger("schemas.createSchema");
2320
- log.set({ input });
2321
- const start = performance.now();
2322
- try {
2323
- const result = await this.client.createSchema(input);
2324
- log.set({ durationMs: Math.round(performance.now() - start) });
2325
- log.emit();
2326
- return result;
2327
- } catch (error) {
2328
- log.set({ durationMs: Math.round(performance.now() - start) });
2329
- log.error(error);
2330
- log.emit();
2331
- throw error;
2332
- }
2333
- }
2334
- /** Get a schema by ID */
2335
- async getSchema(input) {
2336
- const log = this.logger.createCallLogger("schemas.getSchema");
2337
- log.set({ input });
2338
- const start = performance.now();
2339
- try {
2340
- const result = await this.client.getSchema(input);
2341
- log.set({ durationMs: Math.round(performance.now() - start) });
2342
- log.emit();
2343
- return result;
2344
- } catch (error) {
2345
- log.set({ durationMs: Math.round(performance.now() - start) });
2346
- log.error(error);
2347
- log.emit();
2348
- throw error;
2349
- }
2350
- }
2351
- /** Update an existing schema. */
2352
- async updateSchema(input) {
2353
- const log = this.logger.createCallLogger("schemas.updateSchema");
2354
- log.set({ input });
2355
- const start = performance.now();
2356
- try {
2357
- const result = await this.client.updateSchema(input);
2358
- log.set({ durationMs: Math.round(performance.now() - start) });
2359
- log.emit();
2360
- return result;
2361
- } catch (error) {
2362
- log.set({ durationMs: Math.round(performance.now() - start) });
2363
- log.error(error);
2364
- log.emit();
2365
- throw error;
2366
- }
2367
- }
2368
- /** Delete a schema */
2369
- async deleteSchema(input) {
2370
- const log = this.logger.createCallLogger("schemas.deleteSchema");
2371
- log.set({ input });
2372
- const start = performance.now();
2373
- try {
2374
- const result = await this.client.deleteSchema(input);
2375
- log.set({ durationMs: Math.round(performance.now() - start) });
2376
- log.emit();
2377
- return result;
2378
- } catch (error) {
2379
- log.set({ durationMs: Math.round(performance.now() - start) });
2380
- log.error(error);
2381
- log.emit();
2382
- throw error;
2383
- }
2384
- }
2385
- /** List all schemas in a project */
2386
- async listSchemas(input) {
2387
- const log = this.logger.createCallLogger("schemas.listSchemas");
2388
- log.set({ input });
2389
- const start = performance.now();
2390
- try {
2391
- const result = await this.client.listSchemas(input);
2392
- log.set({ durationMs: Math.round(performance.now() - start) });
2393
- log.emit();
2394
- return result;
2395
- } catch (error) {
2396
- log.set({ durationMs: Math.round(performance.now() - start) });
2397
- log.error(error);
2398
- log.emit();
2399
- throw error;
2400
- }
2401
- }
2402
- async searchSchemaCandidates(input) {
2403
- const log = this.logger.createCallLogger("schemas.searchSchemaCandidates");
2404
- log.set({ input });
2405
- const start = performance.now();
2406
- try {
2407
- const result = await this.client.searchSchemaCandidates(input);
2408
- log.set({ durationMs: Math.round(performance.now() - start) });
2409
- log.emit();
2410
- return result;
2411
- } catch (error) {
2412
- log.set({ durationMs: Math.round(performance.now() - start) });
2413
- log.error(error);
2414
- log.emit();
2415
- throw error;
2416
- }
2417
- }
2418
- };
2419
- var FormsApi = class {
2420
- constructor(client, logger) {
2421
- this.client = client;
2422
- this.logger = logger;
2423
- }
2424
- /** Create a new form that can trigger graphs. The optional "schema" parameter defines the form's JSON Schema for input fields. */
2425
- async createForm(input) {
2426
- const log = this.logger.createCallLogger("forms.createForm");
2427
- log.set({ input });
2428
- const start = performance.now();
2429
- try {
2430
- const result = await this.client.createForm(input);
2431
- log.set({ durationMs: Math.round(performance.now() - start) });
2432
- log.emit();
2433
- return result;
2434
- } catch (error) {
2435
- log.set({ durationMs: Math.round(performance.now() - start) });
2436
- log.error(error);
2437
- log.emit();
2438
- throw error;
2439
- }
2440
- }
2441
- /** Get a form by ID */
2442
- async getForm(input) {
2443
- const log = this.logger.createCallLogger("forms.getForm");
2444
- log.set({ input });
2445
- const start = performance.now();
2446
- try {
2447
- const result = await this.client.getForm(input);
2448
- log.set({ durationMs: Math.round(performance.now() - start) });
2449
- log.emit();
2450
- return result;
2451
- } catch (error) {
2452
- log.set({ durationMs: Math.round(performance.now() - start) });
2453
- log.error(error);
2454
- log.emit();
2455
- throw error;
2456
- }
2457
- }
2458
- /** Update a form. The "schema" parameter defines the form's JSON Schema for input fields. */
2459
- async updateForm(input) {
2460
- const log = this.logger.createCallLogger("forms.updateForm");
2461
- log.set({ input });
2462
- const start = performance.now();
2463
- try {
2464
- const result = await this.client.updateForm(input);
2465
- log.set({ durationMs: Math.round(performance.now() - start) });
2466
- log.emit();
2467
- return result;
2468
- } catch (error) {
2469
- log.set({ durationMs: Math.round(performance.now() - start) });
2470
- log.error(error);
2471
- log.emit();
2472
- throw error;
2473
- }
2474
- }
2475
- /** Delete a form */
2476
- async deleteForm(input) {
2477
- const log = this.logger.createCallLogger("forms.deleteForm");
2478
- log.set({ input });
2479
- const start = performance.now();
2480
- try {
2481
- const result = await this.client.deleteForm(input);
2482
- log.set({ durationMs: Math.round(performance.now() - start) });
2483
- log.emit();
2484
- return result;
2485
- } catch (error) {
2486
- log.set({ durationMs: Math.round(performance.now() - start) });
2487
- log.error(error);
2488
- log.emit();
2489
- throw error;
2490
- }
2491
- }
2492
- /** List all forms in a project */
2493
- async listForms(input) {
2494
- const log = this.logger.createCallLogger("forms.listForms");
2495
- log.set({ input });
2496
- const start = performance.now();
2497
- try {
2498
- const result = await this.client.listForms(input);
2499
- log.set({ durationMs: Math.round(performance.now() - start) });
2500
- log.emit();
2501
- return result;
2502
- } catch (error) {
2503
- log.set({ durationMs: Math.round(performance.now() - start) });
2504
- log.error(error);
2505
- log.emit();
2506
- throw error;
2507
- }
2508
- }
2509
- async listTriggersForForm(input) {
2510
- const log = this.logger.createCallLogger("forms.listTriggersForForm");
2511
- log.set({ input });
2512
- const start = performance.now();
2513
- try {
2514
- const result = await this.client.listTriggersForForm(input);
2515
- log.set({ durationMs: Math.round(performance.now() - start) });
2516
- log.emit();
2517
- return result;
2518
- } catch (error) {
2519
- log.set({ durationMs: Math.round(performance.now() - start) });
2520
- log.error(error);
2521
- log.emit();
2522
- throw error;
2523
- }
2524
- }
2525
- async listFormSubmissions(input) {
2526
- const log = this.logger.createCallLogger("forms.listFormSubmissions");
2527
- log.set({ input });
2528
- const start = performance.now();
2529
- try {
2530
- const result = await this.client.listFormSubmissions(input);
2531
- log.set({ durationMs: Math.round(performance.now() - start) });
2532
- log.emit();
2533
- return result;
2534
- } catch (error) {
2535
- log.set({ durationMs: Math.round(performance.now() - start) });
2536
- log.error(error);
2537
- log.emit();
2538
- throw error;
2539
- }
2540
- }
2541
- /** Submit data to a form. The form must be enabled. Triggers associated with the form will be executed. Returns execution IDs for any triggered graphs. */
2542
- async submitForm(input) {
2543
- const log = this.logger.createCallLogger("forms.submitForm");
2544
- log.set({ input });
2545
- const start = performance.now();
2546
- try {
2547
- const result = await this.client.submitForm(input);
2548
- log.set({ durationMs: Math.round(performance.now() - start) });
2549
- log.emit();
2550
- return result;
2551
- } catch (error) {
2552
- log.set({ durationMs: Math.round(performance.now() - start) });
2553
- log.error(error);
2554
- log.emit();
2555
- throw error;
2556
- }
2557
- }
2558
- };
2559
- var DocumentsApi = class {
2560
- constructor(client, logger) {
2561
- this.client = client;
2562
- this.logger = logger;
2563
- }
2564
- /** Create a new document that can be referenced in document nodes */
2565
- async createDocument(input) {
2566
- const log = this.logger.createCallLogger("documents.createDocument");
2567
- log.set({ input });
2568
- const start = performance.now();
2569
- try {
2570
- const result = await this.client.createDocument(input);
2571
- log.set({ durationMs: Math.round(performance.now() - start) });
2572
- log.emit();
2573
- return result;
2574
- } catch (error) {
2575
- log.set({ durationMs: Math.round(performance.now() - start) });
2576
- log.error(error);
2577
- log.emit();
2578
- throw error;
2579
- }
2580
- }
2581
- /** Get a document by ID */
2582
- async getDocument(input) {
2583
- const log = this.logger.createCallLogger("documents.getDocument");
2584
- log.set({ input });
2585
- const start = performance.now();
2586
- try {
2587
- const result = await this.client.getDocument(input);
2588
- log.set({ durationMs: Math.round(performance.now() - start) });
2589
- log.emit();
2590
- return result;
2591
- } catch (error) {
2592
- log.set({ durationMs: Math.round(performance.now() - start) });
2593
- log.error(error);
2594
- log.emit();
2595
- throw error;
2596
- }
2597
- }
2598
- /** Update a document */
2599
- async updateDocument(input) {
2600
- const log = this.logger.createCallLogger("documents.updateDocument");
2601
- log.set({ input });
2602
- const start = performance.now();
2603
- try {
2604
- const result = await this.client.updateDocument(input);
2605
- log.set({ durationMs: Math.round(performance.now() - start) });
2606
- log.emit();
2607
- return result;
2608
- } catch (error) {
2609
- log.set({ durationMs: Math.round(performance.now() - start) });
2610
- log.error(error);
2611
- log.emit();
2612
- throw error;
2613
- }
2614
- }
2615
- /** Delete a document */
2616
- async deleteDocument(input) {
2617
- const log = this.logger.createCallLogger("documents.deleteDocument");
2618
- log.set({ input });
2619
- const start = performance.now();
2620
- try {
2621
- const result = await this.client.deleteDocument(input);
2622
- log.set({ durationMs: Math.round(performance.now() - start) });
2623
- log.emit();
2624
- return result;
2625
- } catch (error) {
2626
- log.set({ durationMs: Math.round(performance.now() - start) });
2627
- log.error(error);
2628
- log.emit();
2629
- throw error;
2630
- }
2631
- }
2632
- /** List all documents in a project */
2633
- async listDocuments(input) {
2634
- const log = this.logger.createCallLogger("documents.listDocuments");
2635
- log.set({ input });
2636
- const start = performance.now();
2637
- try {
2638
- const result = await this.client.listDocuments(input);
2639
- log.set({ durationMs: Math.round(performance.now() - start) });
2640
- log.emit();
2641
- return result;
2642
- } catch (error) {
2643
- log.set({ durationMs: Math.round(performance.now() - start) });
2644
- log.error(error);
2645
- log.emit();
2646
- throw error;
2647
- }
2648
- }
2649
- };
2650
- var WebhooksApi = class {
2651
- constructor(client, logger) {
2652
- this.client = client;
2653
- this.logger = logger;
2654
- }
2655
- /** Create a new webhook that can trigger graphs. The optional "schema" parameter defines the webhook's expected JSON Schema for input data. */
2656
- async createWebhook(input) {
2657
- const log = this.logger.createCallLogger("webhooks.createWebhook");
2658
- log.set({ input });
2659
- const start = performance.now();
2660
- try {
2661
- const result = await this.client.createWebhook(input);
2662
- log.set({ durationMs: Math.round(performance.now() - start) });
2663
- log.emit();
2664
- return result;
2665
- } catch (error) {
2666
- log.set({ durationMs: Math.round(performance.now() - start) });
2667
- log.error(error);
2668
- log.emit();
2669
- throw error;
2670
- }
2671
- }
2672
- /** Get a webhook by ID */
2673
- async getWebhook(input) {
2674
- const log = this.logger.createCallLogger("webhooks.getWebhook");
2675
- log.set({ input });
2676
- const start = performance.now();
2677
- try {
2678
- const result = await this.client.getWebhook(input);
2679
- log.set({ durationMs: Math.round(performance.now() - start) });
2680
- log.emit();
2681
- return result;
2682
- } catch (error) {
2683
- log.set({ durationMs: Math.round(performance.now() - start) });
2684
- log.error(error);
2685
- log.emit();
2686
- throw error;
2687
- }
2688
- }
2689
- /** Update a webhook. The "schema" parameter defines the webhook's expected JSON Schema for input data. */
2690
- async updateWebhook(input) {
2691
- const log = this.logger.createCallLogger("webhooks.updateWebhook");
2692
- log.set({ input });
2693
- const start = performance.now();
2694
- try {
2695
- const result = await this.client.updateWebhook(input);
2696
- log.set({ durationMs: Math.round(performance.now() - start) });
2697
- log.emit();
2698
- return result;
2699
- } catch (error) {
2700
- log.set({ durationMs: Math.round(performance.now() - start) });
2701
- log.error(error);
2702
- log.emit();
2703
- throw error;
2704
- }
2705
- }
2706
- /** Delete a webhook */
2707
- async deleteWebhook(input) {
2708
- const log = this.logger.createCallLogger("webhooks.deleteWebhook");
2709
- log.set({ input });
2710
- const start = performance.now();
2711
- try {
2712
- const result = await this.client.deleteWebhook(input);
2713
- log.set({ durationMs: Math.round(performance.now() - start) });
2714
- log.emit();
2715
- return result;
2716
- } catch (error) {
2717
- log.set({ durationMs: Math.round(performance.now() - start) });
2718
- log.error(error);
2719
- log.emit();
2720
- throw error;
2721
- }
2722
- }
2723
- /** List all webhooks in a project */
2724
- async listWebhooks(input) {
2725
- const log = this.logger.createCallLogger("webhooks.listWebhooks");
2726
- log.set({ input });
2727
- const start = performance.now();
2728
- try {
2729
- const result = await this.client.listWebhooks(input);
2730
- log.set({ durationMs: Math.round(performance.now() - start) });
2731
- log.emit();
2732
- return result;
2733
- } catch (error) {
2734
- log.set({ durationMs: Math.round(performance.now() - start) });
2735
- log.error(error);
2736
- log.emit();
2737
- throw error;
2738
- }
2739
- }
2740
- async listTriggersForWebhook(input) {
2741
- const log = this.logger.createCallLogger("webhooks.listTriggersForWebhook");
2742
- log.set({ input });
2743
- const start = performance.now();
2744
- try {
2745
- const result = await this.client.listTriggersForWebhook(input);
2746
- log.set({ durationMs: Math.round(performance.now() - start) });
2747
- log.emit();
2748
- return result;
2749
- } catch (error) {
2750
- log.set({ durationMs: Math.round(performance.now() - start) });
2751
- log.error(error);
2752
- log.emit();
2753
- throw error;
2754
- }
2755
- }
2756
- };
2757
- var SchedulesApi = class {
2758
- constructor(client, logger) {
2759
- this.client = client;
2760
- this.logger = logger;
2761
- }
2762
- /** Create a new cron schedule that can trigger graphs */
2763
- async createSchedule(input) {
2764
- const log = this.logger.createCallLogger("schedules.createSchedule");
2765
- log.set({ input });
2766
- const start = performance.now();
2767
- try {
2768
- const result = await this.client.createSchedule(input);
2769
- log.set({ durationMs: Math.round(performance.now() - start) });
2770
- log.emit();
2771
- return result;
2772
- } catch (error) {
2773
- log.set({ durationMs: Math.round(performance.now() - start) });
2774
- log.error(error);
2775
- log.emit();
2776
- throw error;
2777
- }
2778
- }
2779
- /** Get a schedule by ID */
2780
- async getSchedule(input) {
2781
- const log = this.logger.createCallLogger("schedules.getSchedule");
2782
- log.set({ input });
2783
- const start = performance.now();
2784
- try {
2785
- const result = await this.client.getSchedule(input);
2786
- log.set({ durationMs: Math.round(performance.now() - start) });
2787
- log.emit();
2788
- return result;
2789
- } catch (error) {
2790
- log.set({ durationMs: Math.round(performance.now() - start) });
2791
- log.error(error);
2792
- log.emit();
2793
- throw error;
2794
- }
2795
- }
2796
- /** Update a schedule */
2797
- async updateSchedule(input) {
2798
- const log = this.logger.createCallLogger("schedules.updateSchedule");
2799
- log.set({ input });
2800
- const start = performance.now();
2801
- try {
2802
- const result = await this.client.updateSchedule(input);
2803
- log.set({ durationMs: Math.round(performance.now() - start) });
2804
- log.emit();
2805
- return result;
2806
- } catch (error) {
2807
- log.set({ durationMs: Math.round(performance.now() - start) });
2808
- log.error(error);
2809
- log.emit();
2810
- throw error;
2811
- }
2812
- }
2813
- /** Delete a schedule */
2814
- async deleteSchedule(input) {
2815
- const log = this.logger.createCallLogger("schedules.deleteSchedule");
2816
- log.set({ input });
2817
- const start = performance.now();
2818
- try {
2819
- const result = await this.client.deleteSchedule(input);
2820
- log.set({ durationMs: Math.round(performance.now() - start) });
2821
- log.emit();
2822
- return result;
2823
- } catch (error) {
2824
- log.set({ durationMs: Math.round(performance.now() - start) });
2825
- log.error(error);
2826
- log.emit();
2827
- throw error;
2828
- }
2829
- }
2830
- /** List all schedules in a project */
2831
- async listSchedules(input) {
2832
- const log = this.logger.createCallLogger("schedules.listSchedules");
2833
- log.set({ input });
2834
- const start = performance.now();
2835
- try {
2836
- const result = await this.client.listSchedules(input);
2837
- log.set({ durationMs: Math.round(performance.now() - start) });
2838
- log.emit();
2839
- return result;
2840
- } catch (error) {
2841
- log.set({ durationMs: Math.round(performance.now() - start) });
2842
- log.error(error);
2843
- log.emit();
2844
- throw error;
2845
- }
2846
- }
2847
- async listTriggersForSchedule(input) {
2848
- const log = this.logger.createCallLogger("schedules.listTriggersForSchedule");
2849
- log.set({ input });
2850
- const start = performance.now();
2851
- try {
2852
- const result = await this.client.listTriggersForSchedule(input);
2853
- log.set({ durationMs: Math.round(performance.now() - start) });
2854
- log.emit();
2855
- return result;
2856
- } catch (error) {
2857
- log.set({ durationMs: Math.round(performance.now() - start) });
2858
- log.error(error);
2859
- log.emit();
2860
- throw error;
2861
- }
2862
- }
2863
- };
2864
- var StreamsApi = class {
2865
- constructor(client, logger) {
2866
- this.client = client;
2867
- this.logger = logger;
2868
- }
2869
- /** Create a new stream that persists data from graph executions over time. The persistenceCondition is a JavaScript expression evaluated after each execution to decide whether to store the result (e.g., "true" to always persist, or "output.status === 'success'"). */
2870
- async createStream(input) {
2871
- const log = this.logger.createCallLogger("streams.createStream");
2872
- log.set({ input });
2873
- const start = performance.now();
2874
- try {
2875
- const result = await this.client.createStream(input);
2876
- log.set({ durationMs: Math.round(performance.now() - start) });
2877
- log.emit();
2878
- return result;
2879
- } catch (error) {
2880
- log.set({ durationMs: Math.round(performance.now() - start) });
2881
- log.error(error);
2882
- log.emit();
2883
- throw error;
2884
- }
2885
- }
2886
- /** Get a stream by ID */
2887
- async getStream(input) {
2888
- const log = this.logger.createCallLogger("streams.getStream");
2889
- log.set({ input });
2890
- const start = performance.now();
2891
- try {
2892
- const result = await this.client.getStream(input);
2893
- log.set({ durationMs: Math.round(performance.now() - start) });
2894
- log.emit();
2895
- return result;
2896
- } catch (error) {
2897
- log.set({ durationMs: Math.round(performance.now() - start) });
2898
- log.error(error);
2899
- log.emit();
2900
- throw error;
2901
- }
2902
- }
2903
- /** Update a stream */
2904
- async updateStream(input) {
2905
- const log = this.logger.createCallLogger("streams.updateStream");
2906
- log.set({ input });
2907
- const start = performance.now();
2908
- try {
2909
- const result = await this.client.updateStream(input);
2910
- log.set({ durationMs: Math.round(performance.now() - start) });
2911
- log.emit();
2912
- return result;
2913
- } catch (error) {
2914
- log.set({ durationMs: Math.round(performance.now() - start) });
2915
- log.error(error);
2916
- log.emit();
2917
- throw error;
2918
- }
2919
- }
2920
- /** Delete a stream */
2921
- async deleteStream(input) {
2922
- const log = this.logger.createCallLogger("streams.deleteStream");
2923
- log.set({ input });
2924
- const start = performance.now();
2925
- try {
2926
- const result = await this.client.deleteStream(input);
2927
- log.set({ durationMs: Math.round(performance.now() - start) });
2928
- log.emit();
2929
- return result;
2930
- } catch (error) {
2931
- log.set({ durationMs: Math.round(performance.now() - start) });
2932
- log.error(error);
2933
- log.emit();
2934
- throw error;
2935
- }
2936
- }
2937
- /** List all streams in a project */
2938
- async listStreams(input) {
2939
- const log = this.logger.createCallLogger("streams.listStreams");
2940
- log.set({ input });
2941
- const start = performance.now();
2942
- try {
2943
- const result = await this.client.listStreams(input);
2944
- log.set({ durationMs: Math.round(performance.now() - start) });
2945
- log.emit();
2946
- return result;
2947
- } catch (error) {
2948
- log.set({ durationMs: Math.round(performance.now() - start) });
2949
- log.error(error);
2950
- log.emit();
2951
- throw error;
2952
- }
2953
- }
2954
- async listStreamSchemas(input) {
2955
- const log = this.logger.createCallLogger("streams.listStreamSchemas");
2956
- log.set({ input });
2957
- const start = performance.now();
2958
- try {
2959
- const result = await this.client.listStreamSchemas(input);
2960
- log.set({ durationMs: Math.round(performance.now() - start) });
2961
- log.emit();
2962
- return result;
2963
- } catch (error) {
2964
- log.set({ durationMs: Math.round(performance.now() - start) });
2965
- log.error(error);
2966
- log.emit();
2967
- throw error;
2968
- }
2969
- }
2970
- async promoteStreamSchema(input) {
2971
- const log = this.logger.createCallLogger("streams.promoteStreamSchema");
2972
- log.set({ input });
2973
- const start = performance.now();
2974
- try {
2975
- const result = await this.client.promoteStreamSchema(input);
2976
- log.set({ durationMs: Math.round(performance.now() - start) });
2977
- log.emit();
2978
- return result;
2979
- } catch (error) {
2980
- log.set({ durationMs: Math.round(performance.now() - start) });
2981
- log.error(error);
2982
- log.emit();
2983
- throw error;
2984
- }
2985
- }
2986
- async listStreamTableColumns(input) {
2987
- const log = this.logger.createCallLogger("streams.listStreamTableColumns");
2988
- log.set({ input });
2989
- const start = performance.now();
2990
- try {
2991
- const result = await this.client.listStreamTableColumns(input);
2992
- log.set({ durationMs: Math.round(performance.now() - start) });
2993
- log.emit();
2994
- return result;
2995
- } catch (error) {
2996
- log.set({ durationMs: Math.round(performance.now() - start) });
2997
- log.error(error);
2998
- log.emit();
2999
- throw error;
3000
- }
3001
- }
3002
- async getStreamTableSchema(input) {
3003
- const log = this.logger.createCallLogger("streams.getStreamTableSchema");
3004
- log.set({ input });
3005
- const start = performance.now();
3006
- try {
3007
- const result = await this.client.getStreamTableSchema(input);
3008
- log.set({ durationMs: Math.round(performance.now() - start) });
3009
- log.emit();
3010
- return result;
3011
- } catch (error) {
3012
- log.set({ durationMs: Math.round(performance.now() - start) });
3013
- log.error(error);
3014
- log.emit();
3015
- throw error;
3016
- }
3017
- }
3018
- /** Query data from a stream using filters. To discover available columns, first call get_stream_table_schema or list_stream_table_columns for the stream. */
3019
- async executeStreamQuery(input) {
3020
- const log = this.logger.createCallLogger("streams.executeStreamQuery");
3021
- log.set({ input });
3022
- const start = performance.now();
3023
- try {
3024
- const result = await this.client.executeStreamQuery(input);
3025
- log.set({ durationMs: Math.round(performance.now() - start) });
3026
- log.emit();
3027
- return result;
3028
- } catch (error) {
3029
- log.set({ durationMs: Math.round(performance.now() - start) });
3030
- log.error(error);
3031
- log.emit();
3032
- throw error;
3033
- }
3034
- }
3035
- };
3036
- var StorageApi = class {
3037
- constructor(client, logger) {
3038
- this.client = client;
3039
- this.logger = logger;
3040
- }
3041
- async listQueries(input) {
3042
- const log = this.logger.createCallLogger("storage.listQueries");
3043
- log.set({ input });
3044
- const start = performance.now();
3045
- try {
3046
- const result = await this.client.listQueries(input);
3047
- log.set({ durationMs: Math.round(performance.now() - start) });
3048
- log.emit();
3049
- return result;
3050
- } catch (error) {
3051
- log.set({ durationMs: Math.round(performance.now() - start) });
3052
- log.error(error);
3053
- log.emit();
3054
- throw error;
3055
- }
3056
- }
3057
- async getQuery(input) {
3058
- const log = this.logger.createCallLogger("storage.getQuery");
3059
- log.set({ input });
3060
- const start = performance.now();
3061
- try {
3062
- const result = await this.client.getQuery(input);
3063
- log.set({ durationMs: Math.round(performance.now() - start) });
3064
- log.emit();
3065
- return result;
3066
- } catch (error) {
3067
- log.set({ durationMs: Math.round(performance.now() - start) });
3068
- log.error(error);
3069
- log.emit();
3070
- throw error;
3071
- }
3072
- }
3073
- async createQuery(input) {
3074
- const log = this.logger.createCallLogger("storage.createQuery");
3075
- log.set({ input });
3076
- const start = performance.now();
3077
- try {
3078
- const result = await this.client.createQuery(input);
3079
- log.set({ durationMs: Math.round(performance.now() - start) });
3080
- log.emit();
3081
- return result;
3082
- } catch (error) {
3083
- log.set({ durationMs: Math.round(performance.now() - start) });
3084
- log.error(error);
3085
- log.emit();
3086
- throw error;
3087
- }
3088
- }
3089
- async updateQuery(input) {
3090
- const log = this.logger.createCallLogger("storage.updateQuery");
3091
- log.set({ input });
3092
- const start = performance.now();
3093
- try {
3094
- const result = await this.client.updateQuery(input);
3095
- log.set({ durationMs: Math.round(performance.now() - start) });
3096
- log.emit();
3097
- return result;
3098
- } catch (error) {
3099
- log.set({ durationMs: Math.round(performance.now() - start) });
3100
- log.error(error);
3101
- log.emit();
3102
- throw error;
3103
- }
3104
- }
3105
- async deleteQuery(input) {
3106
- const log = this.logger.createCallLogger("storage.deleteQuery");
3107
- log.set({ input });
3108
- const start = performance.now();
3109
- try {
3110
- const result = await this.client.deleteQuery(input);
3111
- log.set({ durationMs: Math.round(performance.now() - start) });
3112
- log.emit();
3113
- return result;
3114
- } catch (error) {
3115
- log.set({ durationMs: Math.round(performance.now() - start) });
3116
- log.error(error);
3117
- log.emit();
3118
- throw error;
3119
- }
3120
- }
3121
- async executeQuery(input) {
3122
- const log = this.logger.createCallLogger("storage.executeQuery");
3123
- log.set({ input });
3124
- const start = performance.now();
3125
- try {
3126
- const result = await this.client.executeQuery(input);
3127
- log.set({ durationMs: Math.round(performance.now() - start) });
3128
- log.emit();
3129
- return result;
3130
- } catch (error) {
3131
- log.set({ durationMs: Math.round(performance.now() - start) });
3132
- log.error(error);
3133
- log.emit();
3134
- throw error;
3135
- }
3136
- }
3137
- };
3138
- var ReviewsApi = class {
3139
- constructor(client, logger) {
3140
- this.client = client;
3141
- this.logger = logger;
3142
- }
3143
- /** List pending reviews. Reviews are created when nodes with review config pause execution. */
3144
- async listReviews(input) {
3145
- const log = this.logger.createCallLogger("reviews.listReviews");
3146
- log.set({ input });
3147
- const start = performance.now();
3148
- try {
3149
- const result = await this.client.listReviews(input);
3150
- log.set({ durationMs: Math.round(performance.now() - start) });
3151
- log.emit();
3152
- return result;
3153
- } catch (error) {
3154
- log.set({ durationMs: Math.round(performance.now() - start) });
3155
- log.error(error);
3156
- log.emit();
3157
- throw error;
3158
- }
3159
- }
3160
- /** Get a review by ID with execution details */
3161
- async getReview(input) {
3162
- const log = this.logger.createCallLogger("reviews.getReview");
3163
- log.set({ input });
3164
- const start = performance.now();
3165
- try {
3166
- const result = await this.client.getReview(input);
3167
- log.set({ durationMs: Math.round(performance.now() - start) });
3168
- log.emit();
3169
- return result;
3170
- } catch (error) {
3171
- log.set({ durationMs: Math.round(performance.now() - start) });
3172
- log.error(error);
3173
- log.emit();
3174
- throw error;
3175
- }
3176
- }
3177
- /** Approve a review to continue graph execution */
3178
- async approveReview(input) {
3179
- const log = this.logger.createCallLogger("reviews.approveReview");
3180
- log.set({ input });
3181
- const start = performance.now();
3182
- try {
3183
- const result = await this.client.approveReview(input);
3184
- log.set({ durationMs: Math.round(performance.now() - start) });
3185
- log.emit();
3186
- return result;
3187
- } catch (error) {
3188
- log.set({ durationMs: Math.round(performance.now() - start) });
3189
- log.error(error);
3190
- log.emit();
3191
- throw error;
3192
- }
3193
- }
3194
- /** Reject a review to stop graph execution */
3195
- async rejectReview(input) {
3196
- const log = this.logger.createCallLogger("reviews.rejectReview");
3197
- log.set({ input });
3198
- const start = performance.now();
3199
- try {
3200
- const result = await this.client.rejectReview(input);
3201
- log.set({ durationMs: Math.round(performance.now() - start) });
3202
- log.emit();
3203
- return result;
3204
- } catch (error) {
3205
- log.set({ durationMs: Math.round(performance.now() - start) });
3206
- log.error(error);
3207
- log.emit();
3208
- throw error;
3209
- }
3210
- }
3211
- };
3212
- var ProjectsApi = class {
3213
- constructor(client, logger) {
3214
- this.client = client;
3215
- this.logger = logger;
3216
- }
3217
- /** List all projects accessible to the authenticated user */
3218
- async listProjects() {
3219
- const log = this.logger.createCallLogger("projects.listProjects");
3220
- const start = performance.now();
3221
- try {
3222
- const result = await this.client.listProjects();
3223
- log.set({ durationMs: Math.round(performance.now() - start) });
3224
- log.emit();
3225
- return result;
3226
- } catch (error) {
3227
- log.set({ durationMs: Math.round(performance.now() - start) });
3228
- log.error(error);
3229
- log.emit();
3230
- throw error;
3231
- }
3232
- }
3233
- /** Create a new project */
3234
- async createProject(input) {
3235
- const log = this.logger.createCallLogger("projects.createProject");
3236
- log.set({ input });
3237
- const start = performance.now();
3238
- try {
3239
- const result = await this.client.createProject(input);
3240
- log.set({ durationMs: Math.round(performance.now() - start) });
3241
- log.emit();
3242
- return result;
3243
- } catch (error) {
3244
- log.set({ durationMs: Math.round(performance.now() - start) });
3245
- log.error(error);
3246
- log.emit();
3247
- throw error;
3248
- }
3249
- }
3250
- /** Get details of a specific project */
3251
- async getProject(input) {
3252
- const log = this.logger.createCallLogger("projects.getProject");
3253
- log.set({ input });
3254
- const start = performance.now();
3255
- try {
3256
- const result = await this.client.getProject(input);
3257
- log.set({ durationMs: Math.round(performance.now() - start) });
3258
- log.emit();
3259
- return result;
3260
- } catch (error) {
3261
- log.set({ durationMs: Math.round(performance.now() - start) });
3262
- log.error(error);
3263
- log.emit();
3264
- throw error;
3265
- }
3266
- }
3267
- async getStorage(input) {
3268
- const log = this.logger.createCallLogger("projects.getStorage");
3269
- log.set({ input });
3270
- const start = performance.now();
3271
- try {
3272
- const result = await this.client.getStorage(input);
3273
- log.set({ durationMs: Math.round(performance.now() - start) });
3274
- log.emit();
3275
- return result;
3276
- } catch (error) {
3277
- log.set({ durationMs: Math.round(performance.now() - start) });
3278
- log.error(error);
3279
- log.emit();
3280
- throw error;
3281
- }
3282
- }
3283
- async createStorage(input) {
3284
- const log = this.logger.createCallLogger("projects.createStorage");
3285
- log.set({ input });
3286
- const start = performance.now();
3287
- try {
3288
- const result = await this.client.createStorage(input);
3289
- log.set({ durationMs: Math.round(performance.now() - start) });
3290
- log.emit();
3291
- return result;
3292
- } catch (error) {
3293
- log.set({ durationMs: Math.round(performance.now() - start) });
3294
- log.error(error);
3295
- log.emit();
3296
- throw error;
3297
- }
3298
- }
3299
- };
3300
- var SecretsApi = class {
3301
- constructor(client, logger) {
3302
- this.client = client;
3303
- this.logger = logger;
3304
- }
3305
- /** List all secrets in a project (values are masked) */
3306
- async listSecrets(input) {
3307
- const log = this.logger.createCallLogger("secrets.listSecrets");
3308
- log.set({ input });
3309
- const start = performance.now();
3310
- try {
3311
- const result = await this.client.listSecrets(input);
3312
- log.set({ durationMs: Math.round(performance.now() - start) });
3313
- log.emit();
3314
- return result;
3315
- } catch (error) {
3316
- log.set({ durationMs: Math.round(performance.now() - start) });
3317
- log.error(error);
3318
- log.emit();
3319
- throw error;
3320
- }
3321
- }
3322
- async getSecretValue(input) {
3323
- const log = this.logger.createCallLogger("secrets.getSecretValue");
3324
- log.set({ input });
3325
- const start = performance.now();
3326
- try {
3327
- const result = await this.client.getSecretValue(input);
3328
- log.set({ durationMs: Math.round(performance.now() - start) });
3329
- log.emit();
3330
- return result;
3331
- } catch (error) {
3332
- log.set({ durationMs: Math.round(performance.now() - start) });
3333
- log.error(error);
3334
- log.emit();
3335
- throw error;
3336
- }
3337
- }
3338
- /** Create a new secret */
3339
- async createSecret(input) {
3340
- const log = this.logger.createCallLogger("secrets.createSecret");
3341
- log.set({ input });
3342
- const start = performance.now();
3343
- try {
3344
- const result = await this.client.createSecret(input);
3345
- log.set({ durationMs: Math.round(performance.now() - start) });
3346
- log.emit();
3347
- return result;
3348
- } catch (error) {
3349
- log.set({ durationMs: Math.round(performance.now() - start) });
3350
- log.error(error);
3351
- log.emit();
3352
- throw error;
3353
- }
3354
- }
3355
- /** Update a secret */
3356
- async updateSecret(input) {
3357
- const log = this.logger.createCallLogger("secrets.updateSecret");
3358
- log.set({ input });
3359
- const start = performance.now();
3360
- try {
3361
- const result = await this.client.updateSecret(input);
3362
- log.set({ durationMs: Math.round(performance.now() - start) });
3363
- log.emit();
3364
- return result;
3365
- } catch (error) {
3366
- log.set({ durationMs: Math.round(performance.now() - start) });
3367
- log.error(error);
3368
- log.emit();
3369
- throw error;
3370
- }
3371
- }
3372
- /** Delete a secret */
3373
- async deleteSecret(input) {
3374
- const log = this.logger.createCallLogger("secrets.deleteSecret");
3375
- log.set({ input });
3376
- const start = performance.now();
3377
- try {
3378
- const result = await this.client.deleteSecret(input);
3379
- log.set({ durationMs: Math.round(performance.now() - start) });
3380
- log.emit();
3381
- return result;
3382
- } catch (error) {
3383
- log.set({ durationMs: Math.round(performance.now() - start) });
3384
- log.error(error);
3385
- log.emit();
3386
- throw error;
3387
- }
3388
- }
3389
- };
3390
- var BucketsApi = class {
3391
- constructor(client, logger) {
3392
- this.client = client;
3393
- this.logger = logger;
3394
- }
3395
- /** Create a new storage bucket */
3396
- async createBucket(input) {
3397
- const log = this.logger.createCallLogger("buckets.createBucket");
3398
- log.set({ input });
3399
- const start = performance.now();
3400
- try {
3401
- const result = await this.client.createBucket(input);
3402
- log.set({ durationMs: Math.round(performance.now() - start) });
3403
- log.emit();
3404
- return result;
3405
- } catch (error) {
3406
- log.set({ durationMs: Math.round(performance.now() - start) });
3407
- log.error(error);
3408
- log.emit();
3409
- throw error;
3410
- }
3411
- }
3412
- /** List files and folders in a storage bucket */
3413
- async listFiles(input) {
3414
- const log = this.logger.createCallLogger("buckets.listFiles");
3415
- log.set({ input });
3416
- const start = performance.now();
3417
- try {
3418
- const result = await this.client.listFiles(input);
3419
- log.set({ durationMs: Math.round(performance.now() - start) });
3420
- log.emit();
3421
- return result;
3422
- } catch (error) {
3423
- log.set({ durationMs: Math.round(performance.now() - start) });
3424
- log.error(error);
3425
- log.emit();
3426
- throw error;
3427
- }
3428
- }
3429
- /** Delete a file from the storage bucket */
3430
- async deleteFile(input) {
3431
- const log = this.logger.createCallLogger("buckets.deleteFile");
3432
- log.set({ input });
3433
- const start = performance.now();
3434
- try {
3435
- const result = await this.client.deleteFile(input);
3436
- log.set({ durationMs: Math.round(performance.now() - start) });
3437
- log.emit();
3438
- return result;
3439
- } catch (error) {
3440
- log.set({ durationMs: Math.round(performance.now() - start) });
3441
- log.error(error);
3442
- log.emit();
3443
- throw error;
3444
- }
3445
- }
3446
- /** Delete multiple files from the storage bucket */
3447
- async deleteFiles(input) {
3448
- const log = this.logger.createCallLogger("buckets.deleteFiles");
3449
- log.set({ input });
3450
- const start = performance.now();
3451
- try {
3452
- const result = await this.client.deleteFiles(input);
3453
- log.set({ durationMs: Math.round(performance.now() - start) });
3454
- log.emit();
3455
- return result;
3456
- } catch (error) {
3457
- log.set({ durationMs: Math.round(performance.now() - start) });
3458
- log.error(error);
3459
- log.emit();
3460
- throw error;
3461
- }
3462
- }
3463
- /** Create a signed download URL for a file in the storage bucket */
3464
- async createSignedUrl(input) {
3465
- const log = this.logger.createCallLogger("buckets.createSignedUrl");
3466
- log.set({ input });
3467
- const start = performance.now();
3468
- try {
3469
- const result = await this.client.createSignedUrl(input);
3470
- log.set({ durationMs: Math.round(performance.now() - start) });
3471
- log.emit();
3472
- return result;
3473
- } catch (error) {
3474
- log.set({ durationMs: Math.round(performance.now() - start) });
3475
- log.error(error);
3476
- log.emit();
3477
- throw error;
3478
- }
3479
- }
3480
- /** Create a signed upload URL for uploading a file to the storage bucket */
3481
- async createSignedUploadUrl(input) {
3482
- const log = this.logger.createCallLogger("buckets.createSignedUploadUrl");
3483
- log.set({ input });
3484
- const start = performance.now();
3485
- try {
3486
- const result = await this.client.createSignedUploadUrl(input);
3487
- log.set({ durationMs: Math.round(performance.now() - start) });
3488
- log.emit();
3489
- return result;
3490
- } catch (error) {
3491
- log.set({ durationMs: Math.round(performance.now() - start) });
3492
- log.error(error);
3493
- log.emit();
3494
- throw error;
3495
- }
3496
- }
3497
- /** Move a file within the storage bucket */
3498
- async moveFile(input) {
3499
- const log = this.logger.createCallLogger("buckets.moveFile");
3500
- log.set({ input });
3501
- const start = performance.now();
3502
- try {
3503
- const result = await this.client.moveFile(input);
3504
- log.set({ durationMs: Math.round(performance.now() - start) });
3505
- log.emit();
3506
- return result;
3507
- } catch (error) {
3508
- log.set({ durationMs: Math.round(performance.now() - start) });
3509
- log.error(error);
3510
- log.emit();
3511
- throw error;
3512
- }
3513
- }
3514
- /** Copy a file within the storage bucket */
3515
- async copyFile(input) {
3516
- const log = this.logger.createCallLogger("buckets.copyFile");
3517
- log.set({ input });
3518
- const start = performance.now();
3519
- try {
3520
- const result = await this.client.copyFile(input);
3521
- log.set({ durationMs: Math.round(performance.now() - start) });
3522
- log.emit();
3523
- return result;
3524
- } catch (error) {
3525
- log.set({ durationMs: Math.round(performance.now() - start) });
3526
- log.error(error);
3527
- log.emit();
3528
- throw error;
3529
- }
3530
- }
3531
- };
3532
- var ApiKeysApi = class {
3533
- constructor(client, logger) {
3534
- this.client = client;
3535
- this.logger = logger;
3536
- }
3537
- /** Create a new API key for programmatic access. The secret is only returned once on creation - save it securely. */
3538
- async createApiKey(input) {
3539
- const log = this.logger.createCallLogger("apiKeys.createApiKey");
3540
- log.set({ input });
3541
- const start = performance.now();
3542
- try {
3543
- const result = await this.client.createApiKey(input);
3544
- log.set({ durationMs: Math.round(performance.now() - start) });
3545
- log.emit();
3546
- return result;
3547
- } catch (error) {
3548
- log.set({ durationMs: Math.round(performance.now() - start) });
3549
- log.error(error);
3550
- log.emit();
3551
- throw error;
3552
- }
3553
- }
3554
- /** List all API keys for the current user */
3555
- async listApiKeys(input) {
3556
- const log = this.logger.createCallLogger("apiKeys.listApiKeys");
3557
- log.set({ input });
3558
- const start = performance.now();
3559
- try {
3560
- const result = await this.client.listApiKeys(input);
3561
- log.set({ durationMs: Math.round(performance.now() - start) });
3562
- log.emit();
3563
- return result;
3564
- } catch (error) {
3565
- log.set({ durationMs: Math.round(performance.now() - start) });
3566
- log.error(error);
3567
- log.emit();
3568
- throw error;
3569
- }
3570
- }
3571
- /** Revoke an API key. This immediately invalidates the key and cannot be undone. */
3572
- async revokeApiKey(input) {
3573
- const log = this.logger.createCallLogger("apiKeys.revokeApiKey");
3574
- log.set({ input });
3575
- const start = performance.now();
3576
- try {
3577
- const result = await this.client.revokeApiKey(input);
3578
- log.set({ durationMs: Math.round(performance.now() - start) });
3579
- log.emit();
3580
- return result;
3581
- } catch (error) {
3582
- log.set({ durationMs: Math.round(performance.now() - start) });
3583
- log.error(error);
3584
- log.emit();
3585
- throw error;
3586
- }
3587
- }
3588
- };
3589
- var SwirlsApi = class {
3590
- folders;
3591
- graphs;
3592
- triggers;
3593
- agents;
3594
- schemas;
3595
- forms;
3596
- documents;
3597
- webhooks;
3598
- schedules;
3599
- streams;
3600
- storage;
3601
- reviews;
3602
- projects;
3603
- secrets;
3604
- buckets;
3605
- apiKeys;
3606
- constructor(client, logger) {
3607
- this.folders = new FoldersApi(client.folders, logger);
3608
- this.graphs = new GraphsApi(client.graphs, logger);
3609
- this.triggers = new TriggersApi(client.triggers, logger);
3610
- this.agents = new AgentsApi(client.agents, logger);
3611
- this.schemas = new SchemasApi(client.schemas, logger);
3612
- this.forms = new FormsApi(client.forms, logger);
3613
- this.documents = new DocumentsApi(client.documents, logger);
3614
- this.webhooks = new WebhooksApi(client.webhooks, logger);
3615
- this.schedules = new SchedulesApi(client.schedules, logger);
3616
- this.streams = new StreamsApi(client.streams, logger);
3617
- this.storage = new StorageApi(client.storage, logger);
3618
- this.reviews = new ReviewsApi(client.reviews, logger);
3619
- this.projects = new ProjectsApi(client.projects, logger);
3620
- this.secrets = new SecretsApi(client.secrets, logger);
3621
- this.buckets = new BucketsApi(client.buckets, logger);
3622
- this.apiKeys = new ApiKeysApi(client.apiKeys, logger);
3623
- }
3624
- };
3625
-
3626
- // ../../node_modules/.bun/evlog@1.9.0/node_modules/evlog/dist/utils.mjs
3627
- function formatDuration(ms) {
3628
- if (ms < 1e3) return `${Math.round(ms)}ms`;
3629
- return `${(ms / 1e3).toFixed(2)}s`;
3630
- }
3631
- function isDev() {
3632
- if (typeof process !== "undefined") return process.env.NODE_ENV !== "production";
3633
- if (typeof window !== "undefined") return true;
3634
- return false;
3635
- }
3636
- function detectEnvironment() {
3637
- const env = typeof process !== "undefined" ? process.env : {};
3638
- const defaultEnvironment = isDev() ? "development" : "production";
3639
- return {
3640
- environment: env.NODE_ENV || defaultEnvironment,
3641
- service: env.SERVICE_NAME || "app",
3642
- version: env.APP_VERSION,
3643
- commitHash: env.COMMIT_SHA || env.GITHUB_SHA || env.VERCEL_GIT_COMMIT_SHA || env.CF_PAGES_COMMIT_SHA,
3644
- region: env.VERCEL_REGION || env.AWS_REGION || env.FLY_REGION || env.CF_REGION
3645
- };
3646
- }
3647
- function getConsoleMethod(level) {
3648
- return level;
3649
- }
3650
- var colors = {
3651
- reset: "\x1B[0m",
3652
- bold: "\x1B[1m",
3653
- dim: "\x1B[2m",
3654
- red: "\x1B[31m",
3655
- green: "\x1B[32m",
3656
- yellow: "\x1B[33m",
3657
- blue: "\x1B[34m",
3658
- magenta: "\x1B[35m",
3659
- cyan: "\x1B[36m",
3660
- white: "\x1B[37m",
3661
- gray: "\x1B[90m"
3662
- };
3663
- function getLevelColor(level) {
3664
- switch (level) {
3665
- case "error":
3666
- return colors.red;
3667
- case "warn":
3668
- return colors.yellow;
3669
- case "info":
3670
- return colors.cyan;
3671
- case "debug":
3672
- return colors.gray;
3673
- default:
3674
- return colors.white;
3675
- }
3676
- }
3677
- function matchesPattern(path, pattern) {
3678
- const regexPattern = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "{{GLOBSTAR}}").replace(/\*/g, "[^/]*").replace(/{{GLOBSTAR}}/g, ".*").replace(/\?/g, "[^/]");
3679
- return new RegExp(`^${regexPattern}$`).test(path);
3680
- }
3681
-
3682
- // ../../node_modules/.bun/evlog@1.9.0/node_modules/evlog/dist/logger.mjs
3683
- function isPlainObject(val) {
3684
- return val !== null && typeof val === "object" && !Array.isArray(val);
3685
- }
3686
- function deepDefaults(base, defaults) {
3687
- const result = { ...base };
3688
- for (const key in defaults) {
3689
- const baseVal = result[key];
3690
- const defaultVal = defaults[key];
3691
- if (baseVal === void 0 || baseVal === null) result[key] = defaultVal;
3692
- else if (isPlainObject(baseVal) && isPlainObject(defaultVal)) result[key] = deepDefaults(baseVal, defaultVal);
3693
- }
3694
- return result;
3695
- }
3696
- var globalEnv = {
3697
- service: "app",
3698
- environment: "development"
3699
- };
3700
- var globalPretty = isDev();
3701
- var globalSampling = {};
3702
- var globalStringify = true;
3703
- var globalDrain;
3704
- var globalEnabled = true;
3705
- function initLogger(config = {}) {
3706
- globalEnabled = config.enabled ?? true;
3707
- const detected = detectEnvironment();
3708
- globalEnv = {
3709
- service: config.env?.service ?? detected.service ?? "app",
3710
- environment: config.env?.environment ?? detected.environment ?? "development",
3711
- version: config.env?.version ?? detected.version,
3712
- commitHash: config.env?.commitHash ?? detected.commitHash,
3713
- region: config.env?.region ?? detected.region
3714
- };
3715
- globalPretty = config.pretty ?? isDev();
3716
- globalSampling = config.sampling ?? {};
3717
- globalStringify = config.stringify ?? true;
3718
- globalDrain = config.drain;
3719
- }
3720
- function shouldSample(level) {
3721
- const { rates } = globalSampling;
3722
- if (!rates) return true;
3723
- const percentage = level === "error" && rates.error === void 0 ? 100 : rates[level] ?? 100;
3724
- if (percentage <= 0) return false;
3725
- if (percentage >= 100) return true;
3726
- return Math.random() * 100 < percentage;
3727
- }
3728
- function shouldKeep(ctx) {
3729
- const { keep } = globalSampling;
3730
- if (!keep?.length) return false;
3731
- return keep.some((condition) => {
3732
- if (condition.status !== void 0 && ctx.status !== void 0 && ctx.status >= condition.status) return true;
3733
- if (condition.duration !== void 0 && ctx.duration !== void 0 && ctx.duration >= condition.duration) return true;
3734
- if (condition.path && ctx.path && matchesPattern(ctx.path, condition.path)) return true;
3735
- return false;
3736
- });
3737
- }
3738
- function emitWideEvent(level, event, skipSamplingCheck = false) {
3739
- if (!globalEnabled) return null;
3740
- if (!skipSamplingCheck && !shouldSample(level)) return null;
3741
- const formatted = {
3742
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
3743
- level,
3744
- ...globalEnv,
3745
- ...event
3746
- };
3747
- if (globalPretty) prettyPrintWideEvent(formatted);
3748
- else if (globalStringify) console[getConsoleMethod(level)](JSON.stringify(formatted));
3749
- else console[getConsoleMethod(level)](formatted);
3750
- if (globalDrain) Promise.resolve(globalDrain({ event: formatted })).catch((err) => {
3751
- console.error("[evlog] drain failed:", err);
3752
- });
3753
- return formatted;
3754
- }
3755
- function emitTaggedLog(level, tag, message) {
3756
- if (!globalEnabled) return;
3757
- if (globalPretty) {
3758
- if (!shouldSample(level)) return;
3759
- const color = getLevelColor(level);
3760
- const timestamp = (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
3761
- console.log(`${colors.dim}${timestamp}${colors.reset} ${color}[${tag}]${colors.reset} ${message}`);
3762
- return;
3763
- }
3764
- emitWideEvent(level, {
3765
- tag,
3766
- message
3767
- });
3768
- }
3769
- function formatValue(value2) {
3770
- if (value2 === null || value2 === void 0) return String(value2);
3771
- if (typeof value2 === "object") {
3772
- const pairs = [];
3773
- for (const [k, v] of Object.entries(value2)) if (v !== void 0 && v !== null) if (typeof v === "object") pairs.push(`${k}=${JSON.stringify(v)}`);
3774
- else pairs.push(`${k}=${v}`);
3775
- return pairs.join(" ");
3776
- }
3777
- return String(value2);
3778
- }
3779
- function prettyPrintWideEvent(event) {
3780
- const { timestamp, level, service, environment, version, ...rest } = event;
3781
- const levelColor = getLevelColor(level);
3782
- const ts = timestamp.slice(11, 23);
3783
- let header = `${colors.dim}${ts}${colors.reset} ${levelColor}${level.toUpperCase()}${colors.reset}`;
3784
- header += ` ${colors.cyan}[${service}]${colors.reset}`;
3785
- if (rest.method && rest.path) {
3786
- header += ` ${rest.method} ${rest.path}`;
3787
- delete rest.method;
3788
- delete rest.path;
3789
- }
3790
- if (rest.status) {
3791
- const statusColor = rest.status >= 400 ? colors.red : colors.green;
3792
- header += ` ${statusColor}${rest.status}${colors.reset}`;
3793
- delete rest.status;
3794
- }
3795
- if (rest.duration) {
3796
- header += ` ${colors.dim}in ${rest.duration}${colors.reset}`;
3797
- delete rest.duration;
3798
- }
3799
- console.log(header);
3800
- const entries = Object.entries(rest).filter(([_, v]) => v !== void 0);
3801
- const lastIndex = entries.length - 1;
3802
- entries.forEach(([key, value2], index) => {
3803
- const prefix = index === lastIndex ? "\u2514\u2500" : "\u251C\u2500";
3804
- const formatted = formatValue(value2);
3805
- console.log(` ${colors.dim}${prefix}${colors.reset} ${colors.cyan}${key}:${colors.reset} ${formatted}`);
3806
- });
3807
- }
3808
- function createLogMethod(level) {
3809
- return function logMethod(tagOrEvent, message) {
3810
- if (typeof tagOrEvent === "string" && message !== void 0) emitTaggedLog(level, tagOrEvent, message);
3811
- else if (typeof tagOrEvent === "object") emitWideEvent(level, tagOrEvent);
3812
- else emitTaggedLog(level, "log", String(tagOrEvent));
3813
- };
3814
- }
3815
- var _log = {
3816
- info: createLogMethod("info"),
3817
- error: createLogMethod("error"),
3818
- warn: createLogMethod("warn"),
3819
- debug: createLogMethod("debug")
3820
- };
3821
- var noopLogger = {
3822
- set() {
3823
- },
3824
- error() {
3825
- },
3826
- info() {
3827
- },
3828
- warn() {
3829
- },
3830
- emit() {
3831
- return null;
3832
- },
3833
- getContext() {
3834
- return {};
3835
- }
3836
- };
3837
- function createRequestLogger(options = {}) {
3838
- if (!globalEnabled) return noopLogger;
3839
- const startTime = Date.now();
3840
- let context = {
3841
- method: options.method,
3842
- path: options.path,
3843
- requestId: options.requestId
3844
- };
3845
- let hasError = false;
3846
- let hasWarn = false;
3847
- function addRequestLog(level, message) {
3848
- const entry = {
3849
- level,
3850
- message,
3851
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
3852
- };
3853
- const requestLogs = Array.isArray(context.requestLogs) ? [...context.requestLogs, entry] : [entry];
3854
- context = {
3855
- ...context,
3856
- requestLogs
3857
- };
3858
- }
3859
- return {
3860
- set(data) {
3861
- context = deepDefaults(data, context);
3862
- },
3863
- error(error, errorContext) {
3864
- hasError = true;
3865
- const err = typeof error === "string" ? new Error(error) : error;
3866
- context = deepDefaults({
3867
- ...errorContext,
3868
- error: {
3869
- name: err.name,
3870
- message: err.message,
3871
- stack: err.stack,
3872
- ..."status" in err && { status: err.status },
3873
- ..."statusText" in err && { statusText: err.statusText },
3874
- ..."statusCode" in err && { statusCode: err.statusCode },
3875
- ..."statusMessage" in err && { statusMessage: err.statusMessage },
3876
- ..."data" in err && { data: err.data },
3877
- ..."cause" in err && { cause: err.cause }
3878
- }
3879
- }, context);
3880
- },
3881
- info(message, infoContext) {
3882
- addRequestLog("info", message);
3883
- if (infoContext) {
3884
- const { requestLogs: _, ...rest } = infoContext;
3885
- context = deepDefaults(rest, context);
3886
- }
3887
- },
3888
- warn(message, warnContext) {
3889
- hasWarn = true;
3890
- addRequestLog("warn", message);
3891
- if (warnContext) {
3892
- const { requestLogs: _, ...rest } = warnContext;
3893
- context = deepDefaults(rest, context);
3894
- }
3895
- },
3896
- emit(overrides) {
3897
- const durationMs = Date.now() - startTime;
3898
- const duration = formatDuration(durationMs);
3899
- const level = hasError ? "error" : hasWarn ? "warn" : "info";
3900
- const { _forceKeep, ...restOverrides } = overrides ?? {};
3901
- const tailCtx = {
3902
- status: context.status ?? restOverrides.status,
3903
- duration: durationMs,
3904
- path: context.path,
3905
- method: context.method,
3906
- context: {
3907
- ...context,
3908
- ...restOverrides
3909
- }
3910
- };
3911
- if (!(_forceKeep || shouldKeep(tailCtx)) && !shouldSample(level)) return null;
3912
- return emitWideEvent(level, {
3913
- ...context,
3914
- ...restOverrides,
3915
- duration
3916
- }, true);
3917
- },
3918
- getContext() {
3919
- return { ...context };
3920
- }
3921
- };
3922
- }
3923
-
3924
- // src/client/logger.ts
3925
- var NOOP_CALL_LOGGER = {
3926
- set() {
3927
- },
3928
- emit() {
3929
- },
3930
- error() {
3931
- }
3932
- };
3933
- var NOOP_LOGGER = {
3934
- createCallLogger() {
3935
- return NOOP_CALL_LOGGER;
3936
- }
3937
- };
3938
- function createSwirlsLogger(config) {
3939
- const service = config?.service ?? "swirls-sdk";
3940
- initLogger({
3941
- env: { service, environment: "production" }
3942
- });
3943
- return {
3944
- createCallLogger(operation) {
3945
- const log = createRequestLogger({ method: "SDK", path: operation });
3946
- return {
3947
- set(fields) {
3948
- log.set(fields);
3949
- },
3950
- emit() {
3951
- log.emit();
3952
- },
3953
- error(err) {
3954
- log.error(err);
3955
- }
3956
- };
3957
- }
3958
- };
3959
- }
3960
-
3961
- // src/client/client.ts
3962
- var DEFAULT_SWIRLS_API_URL = "https://swirls.ai/api";
3963
15
  var Swirls = class {
3964
16
  apiKey;
3965
17
  apiUrl;
3966
- loggingConfig;
3967
- _api;
3968
18
  /**
3969
19
  * Create a new Swirls SDK instance.
3970
20
  *
3971
- * @param options - SDK configuration options.
21
+ * @param options.apiKey - Your Swirls API key.
22
+ * @param options.apiUrl - Override the API base URL (defaults to `https://swirls.ai/api`).
3972
23
  */
3973
24
  constructor(options) {
3974
25
  this.apiKey = options.apiKey;
3975
26
  this.apiUrl = options.apiUrl ?? DEFAULT_SWIRLS_API_URL;
3976
- this.loggingConfig = options.logging;
3977
- }
3978
- /** Bare oRPC client — use this for advanced access or TanStack Query integration. */
3979
- get raw() {
3980
- return createSwirlsClient({ apiUrl: this.apiUrl, apiKey: this.apiKey });
3981
27
  }
3982
- /** @deprecated Use `swirls.raw` or namespace accessors (e.g. `swirls.graphs`). */
28
+ /** Type-safe oRPC client with namespaced methods for all Swirls resources. */
3983
29
  get client() {
3984
- return this.raw;
3985
- }
3986
- get api() {
3987
- if (!this._api) {
3988
- const logger = this.loggingConfig ? createSwirlsLogger(
3989
- typeof this.loggingConfig === "object" ? this.loggingConfig : void 0
3990
- ) : NOOP_LOGGER;
3991
- this._api = new SwirlsApi(this.raw, logger);
3992
- }
3993
- return this._api;
30
+ return createSwirlsRpcClient(this.apiUrl, this.apiKey);
3994
31
  }
3995
32
  /** TanStack Query utilities for use with `useQuery()` and `useMutation()`. */
3996
33
  get query() {
3997
- return createSwirlsQueryUtils(this.raw);
3998
- }
3999
- // -- Namespace shortcut getters --
4000
- get folders() {
4001
- return this.api.folders;
4002
- }
4003
- get graphs() {
4004
- return this.api.graphs;
4005
- }
4006
- get triggers() {
4007
- return this.api.triggers;
4008
- }
4009
- get agents() {
4010
- return this.api.agents;
4011
- }
4012
- get schemas() {
4013
- return this.api.schemas;
4014
- }
4015
- get forms() {
4016
- return this.api.forms;
4017
- }
4018
- get documents() {
4019
- return this.api.documents;
4020
- }
4021
- get webhooks() {
4022
- return this.api.webhooks;
4023
- }
4024
- get schedules() {
4025
- return this.api.schedules;
4026
- }
4027
- get streams() {
4028
- return this.api.streams;
4029
- }
4030
- get storage() {
4031
- return this.api.storage;
4032
- }
4033
- get reviews() {
4034
- return this.api.reviews;
4035
- }
4036
- get projects() {
4037
- return this.api.projects;
4038
- }
4039
- get secrets() {
4040
- return this.api.secrets;
4041
- }
4042
- get buckets() {
4043
- return this.api.buckets;
4044
- }
4045
- get apiKeys() {
4046
- return this.api.apiKeys;
34
+ return createTanstackQueryUtils(this.client);
4047
35
  }
4048
36
  };
4049
37
  export {