@rivetkit/engine-api-full 2.0.39 → 2.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/browser/cjs/index.js +2 -0
  2. package/dist/browser/cjs/serialization.js +2 -0
  3. package/dist/browser/esm/index.js +2 -0
  4. package/dist/browser/esm/serialization.js +2 -0
  5. package/dist/node/cjs/index.js +2 -0
  6. package/dist/node/cjs/serialization.js +2 -0
  7. package/dist/node/core.js +2353 -0
  8. package/dist/node/esm/index.js +2 -0
  9. package/dist/node/esm/serialization.js +2 -0
  10. package/dist/node/index.js +4252 -0
  11. package/dist/node/serialization.js +2014 -0
  12. package/package.json +1 -1
  13. package/types/api/types/ActorError.d.ts +20 -0
  14. package/types/api/types/ActorErrorCrashed.d.ts +11 -0
  15. package/types/api/types/ActorErrorCrashedCrashed.d.ts +9 -0
  16. package/types/api/types/ActorErrorRunnerConnectionLost.d.ts +11 -0
  17. package/types/api/types/ActorErrorRunnerConnectionLostRunnerConnectionLost.d.ts +10 -0
  18. package/types/api/types/ActorErrorRunnerDrainingTimeout.d.ts +11 -0
  19. package/types/api/types/ActorErrorRunnerDrainingTimeoutRunnerDrainingTimeout.d.ts +10 -0
  20. package/types/api/types/ActorErrorRunnerNoResponse.d.ts +11 -0
  21. package/types/api/types/ActorErrorRunnerNoResponseRunnerNoResponse.d.ts +10 -0
  22. package/types/api/types/ActorErrorRunnerPoolError.d.ts +11 -0
  23. package/types/api/types/RunnerConfigKindServerlessServerless.d.ts +2 -0
  24. package/types/api/types/RunnerConfigServerless.d.ts +2 -0
  25. package/types/api/types/RunnerPoolError.d.ts +14 -0
  26. package/types/api/types/RunnerPoolErrorServerlessConnectionError.d.ts +11 -0
  27. package/types/api/types/RunnerPoolErrorServerlessConnectionErrorServerlessConnectionError.d.ts +9 -0
  28. package/types/api/types/RunnerPoolErrorServerlessHttpError.d.ts +11 -0
  29. package/types/api/types/RunnerPoolErrorServerlessHttpErrorServerlessHttpError.d.ts +10 -0
  30. package/types/api/types/RunnerPoolErrorServerlessInvalidPayload.d.ts +11 -0
  31. package/types/api/types/RunnerPoolErrorServerlessInvalidPayloadServerlessInvalidPayload.d.ts +9 -0
  32. package/types/serialization/types/ActorError.d.ts +15 -0
  33. package/types/serialization/types/ActorErrorCrashed.d.ts +13 -0
  34. package/types/serialization/types/ActorErrorCrashedCrashed.d.ts +12 -0
  35. package/types/serialization/types/ActorErrorRunnerConnectionLost.d.ts +13 -0
  36. package/types/serialization/types/ActorErrorRunnerConnectionLostRunnerConnectionLost.d.ts +13 -0
  37. package/types/serialization/types/ActorErrorRunnerDrainingTimeout.d.ts +13 -0
  38. package/types/serialization/types/ActorErrorRunnerDrainingTimeoutRunnerDrainingTimeout.d.ts +13 -0
  39. package/types/serialization/types/ActorErrorRunnerNoResponse.d.ts +13 -0
  40. package/types/serialization/types/ActorErrorRunnerNoResponseRunnerNoResponse.d.ts +13 -0
  41. package/types/serialization/types/ActorErrorRunnerPoolError.d.ts +13 -0
  42. package/types/serialization/types/RunnerConfigKindServerlessServerless.d.ts +1 -0
  43. package/types/serialization/types/RunnerConfigServerless.d.ts +1 -0
  44. package/types/serialization/types/RunnerPoolError.d.ts +13 -0
  45. package/types/serialization/types/RunnerPoolErrorServerlessConnectionError.d.ts +13 -0
  46. package/types/serialization/types/RunnerPoolErrorServerlessConnectionErrorServerlessConnectionError.d.ts +12 -0
  47. package/types/serialization/types/RunnerPoolErrorServerlessHttpError.d.ts +13 -0
  48. package/types/serialization/types/RunnerPoolErrorServerlessHttpErrorServerlessHttpError.d.ts +13 -0
  49. package/types/serialization/types/RunnerPoolErrorServerlessInvalidPayload.d.ts +13 -0
  50. package/types/serialization/types/RunnerPoolErrorServerlessInvalidPayloadServerlessInvalidPayload.d.ts +12 -0
@@ -0,0 +1,4252 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // src/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts
34
+ var Node18UniversalStreamWrapper_exports = {};
35
+ __export(Node18UniversalStreamWrapper_exports, {
36
+ Node18UniversalStreamWrapper: () => Node18UniversalStreamWrapper
37
+ });
38
+ var Node18UniversalStreamWrapper;
39
+ var init_Node18UniversalStreamWrapper = __esm({
40
+ "src/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts"() {
41
+ "use strict";
42
+ Node18UniversalStreamWrapper = class _Node18UniversalStreamWrapper {
43
+ readableStream;
44
+ reader;
45
+ events;
46
+ paused;
47
+ resumeCallback;
48
+ encoding;
49
+ constructor(readableStream) {
50
+ this.readableStream = readableStream;
51
+ this.reader = this.readableStream.getReader();
52
+ this.events = {
53
+ data: [],
54
+ end: [],
55
+ error: [],
56
+ readable: [],
57
+ close: [],
58
+ pause: [],
59
+ resume: []
60
+ };
61
+ this.paused = false;
62
+ this.resumeCallback = null;
63
+ this.encoding = null;
64
+ }
65
+ on(event, callback) {
66
+ var _a;
67
+ (_a = this.events[event]) == null ? void 0 : _a.push(callback);
68
+ }
69
+ off(event, callback) {
70
+ var _a;
71
+ this.events[event] = (_a = this.events[event]) == null ? void 0 : _a.filter((cb) => cb !== callback);
72
+ }
73
+ pipe(dest) {
74
+ this.on("data", async (chunk) => {
75
+ if (dest instanceof _Node18UniversalStreamWrapper) {
76
+ dest._write(chunk);
77
+ } else if (dest instanceof WritableStream) {
78
+ const writer = dest.getWriter();
79
+ writer.write(chunk).then(() => writer.releaseLock());
80
+ } else {
81
+ dest.write(chunk);
82
+ }
83
+ });
84
+ this.on("end", async () => {
85
+ if (dest instanceof _Node18UniversalStreamWrapper) {
86
+ dest._end();
87
+ } else if (dest instanceof WritableStream) {
88
+ const writer = dest.getWriter();
89
+ writer.close();
90
+ } else {
91
+ dest.end();
92
+ }
93
+ });
94
+ this.on("error", async (error) => {
95
+ if (dest instanceof _Node18UniversalStreamWrapper) {
96
+ dest._error(error);
97
+ } else if (dest instanceof WritableStream) {
98
+ const writer = dest.getWriter();
99
+ writer.abort(error);
100
+ } else {
101
+ dest.destroy(error);
102
+ }
103
+ });
104
+ this._startReading();
105
+ return dest;
106
+ }
107
+ pipeTo(dest) {
108
+ return this.pipe(dest);
109
+ }
110
+ unpipe(dest) {
111
+ this.off("data", async (chunk) => {
112
+ if (dest instanceof _Node18UniversalStreamWrapper) {
113
+ dest._write(chunk);
114
+ } else if (dest instanceof WritableStream) {
115
+ const writer = dest.getWriter();
116
+ writer.write(chunk).then(() => writer.releaseLock());
117
+ } else {
118
+ dest.write(chunk);
119
+ }
120
+ });
121
+ this.off("end", async () => {
122
+ if (dest instanceof _Node18UniversalStreamWrapper) {
123
+ dest._end();
124
+ } else if (dest instanceof WritableStream) {
125
+ const writer = dest.getWriter();
126
+ writer.close();
127
+ } else {
128
+ dest.end();
129
+ }
130
+ });
131
+ this.off("error", async (error) => {
132
+ if (dest instanceof _Node18UniversalStreamWrapper) {
133
+ dest._error(error);
134
+ } else if (dest instanceof WritableStream) {
135
+ const writer = dest.getWriter();
136
+ writer.abort(error);
137
+ } else {
138
+ dest.destroy(error);
139
+ }
140
+ });
141
+ }
142
+ destroy(error) {
143
+ this.reader.cancel(error).then(() => {
144
+ this._emit("close");
145
+ }).catch((err) => {
146
+ this._emit("error", err);
147
+ });
148
+ }
149
+ pause() {
150
+ this.paused = true;
151
+ this._emit("pause");
152
+ }
153
+ resume() {
154
+ if (this.paused) {
155
+ this.paused = false;
156
+ this._emit("resume");
157
+ if (this.resumeCallback) {
158
+ this.resumeCallback();
159
+ this.resumeCallback = null;
160
+ }
161
+ }
162
+ }
163
+ get isPaused() {
164
+ return this.paused;
165
+ }
166
+ async read() {
167
+ if (this.paused) {
168
+ await new Promise((resolve) => {
169
+ this.resumeCallback = resolve;
170
+ });
171
+ }
172
+ const { done, value } = await this.reader.read();
173
+ if (done) {
174
+ return void 0;
175
+ }
176
+ return value;
177
+ }
178
+ setEncoding(encoding) {
179
+ this.encoding = encoding;
180
+ }
181
+ async text() {
182
+ const chunks = [];
183
+ while (true) {
184
+ const { done, value } = await this.reader.read();
185
+ if (done) {
186
+ break;
187
+ }
188
+ if (value) {
189
+ chunks.push(value);
190
+ }
191
+ }
192
+ const decoder = new TextDecoder(this.encoding || "utf-8");
193
+ return decoder.decode(await new Blob(chunks).arrayBuffer());
194
+ }
195
+ async json() {
196
+ const text = await this.text();
197
+ return JSON.parse(text);
198
+ }
199
+ _write(chunk) {
200
+ this._emit("data", chunk);
201
+ }
202
+ _end() {
203
+ this._emit("end");
204
+ }
205
+ _error(error) {
206
+ this._emit("error", error);
207
+ }
208
+ _emit(event, data) {
209
+ if (this.events[event]) {
210
+ for (const callback of this.events[event] || []) {
211
+ callback(data);
212
+ }
213
+ }
214
+ }
215
+ async _startReading() {
216
+ try {
217
+ this._emit("readable");
218
+ while (true) {
219
+ if (this.paused) {
220
+ await new Promise((resolve) => {
221
+ this.resumeCallback = resolve;
222
+ });
223
+ }
224
+ const { done, value } = await this.reader.read();
225
+ if (done) {
226
+ this._emit("end");
227
+ this._emit("close");
228
+ break;
229
+ }
230
+ if (value) {
231
+ this._emit("data", value);
232
+ }
233
+ }
234
+ } catch (error) {
235
+ this._emit("error", error);
236
+ }
237
+ }
238
+ [Symbol.asyncIterator]() {
239
+ return {
240
+ next: async () => {
241
+ if (this.paused) {
242
+ await new Promise((resolve) => {
243
+ this.resumeCallback = resolve;
244
+ });
245
+ }
246
+ const { done, value } = await this.reader.read();
247
+ if (done) {
248
+ return { done: true, value: void 0 };
249
+ }
250
+ return { done: false, value };
251
+ },
252
+ [Symbol.asyncIterator]() {
253
+ return this;
254
+ }
255
+ };
256
+ }
257
+ };
258
+ }
259
+ });
260
+
261
+ // src/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts
262
+ var UndiciStreamWrapper_exports = {};
263
+ __export(UndiciStreamWrapper_exports, {
264
+ UndiciStreamWrapper: () => UndiciStreamWrapper
265
+ });
266
+ var UndiciStreamWrapper;
267
+ var init_UndiciStreamWrapper = __esm({
268
+ "src/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts"() {
269
+ "use strict";
270
+ UndiciStreamWrapper = class _UndiciStreamWrapper {
271
+ readableStream;
272
+ reader;
273
+ events;
274
+ paused;
275
+ resumeCallback;
276
+ encoding;
277
+ constructor(readableStream) {
278
+ this.readableStream = readableStream;
279
+ this.reader = this.readableStream.getReader();
280
+ this.events = {
281
+ data: [],
282
+ end: [],
283
+ error: [],
284
+ readable: [],
285
+ close: [],
286
+ pause: [],
287
+ resume: []
288
+ };
289
+ this.paused = false;
290
+ this.resumeCallback = null;
291
+ this.encoding = null;
292
+ }
293
+ on(event, callback) {
294
+ var _a;
295
+ (_a = this.events[event]) == null ? void 0 : _a.push(callback);
296
+ }
297
+ off(event, callback) {
298
+ var _a;
299
+ this.events[event] = (_a = this.events[event]) == null ? void 0 : _a.filter((cb) => cb !== callback);
300
+ }
301
+ pipe(dest) {
302
+ this.on("data", (chunk) => {
303
+ if (dest instanceof _UndiciStreamWrapper) {
304
+ dest._write(chunk);
305
+ } else {
306
+ const writer = dest.getWriter();
307
+ writer.write(chunk).then(() => writer.releaseLock());
308
+ }
309
+ });
310
+ this.on("end", () => {
311
+ if (dest instanceof _UndiciStreamWrapper) {
312
+ dest._end();
313
+ } else {
314
+ const writer = dest.getWriter();
315
+ writer.close();
316
+ }
317
+ });
318
+ this.on("error", (error) => {
319
+ if (dest instanceof _UndiciStreamWrapper) {
320
+ dest._error(error);
321
+ } else {
322
+ const writer = dest.getWriter();
323
+ writer.abort(error);
324
+ }
325
+ });
326
+ this._startReading();
327
+ return dest;
328
+ }
329
+ pipeTo(dest) {
330
+ return this.pipe(dest);
331
+ }
332
+ unpipe(dest) {
333
+ this.off("data", (chunk) => {
334
+ if (dest instanceof _UndiciStreamWrapper) {
335
+ dest._write(chunk);
336
+ } else {
337
+ const writer = dest.getWriter();
338
+ writer.write(chunk).then(() => writer.releaseLock());
339
+ }
340
+ });
341
+ this.off("end", () => {
342
+ if (dest instanceof _UndiciStreamWrapper) {
343
+ dest._end();
344
+ } else {
345
+ const writer = dest.getWriter();
346
+ writer.close();
347
+ }
348
+ });
349
+ this.off("error", (error) => {
350
+ if (dest instanceof _UndiciStreamWrapper) {
351
+ dest._error(error);
352
+ } else {
353
+ const writer = dest.getWriter();
354
+ writer.abort(error);
355
+ }
356
+ });
357
+ }
358
+ destroy(error) {
359
+ this.reader.cancel(error).then(() => {
360
+ this._emit("close");
361
+ }).catch((err) => {
362
+ this._emit("error", err);
363
+ });
364
+ }
365
+ pause() {
366
+ this.paused = true;
367
+ this._emit("pause");
368
+ }
369
+ resume() {
370
+ if (this.paused) {
371
+ this.paused = false;
372
+ this._emit("resume");
373
+ if (this.resumeCallback) {
374
+ this.resumeCallback();
375
+ this.resumeCallback = null;
376
+ }
377
+ }
378
+ }
379
+ get isPaused() {
380
+ return this.paused;
381
+ }
382
+ async read() {
383
+ if (this.paused) {
384
+ await new Promise((resolve) => {
385
+ this.resumeCallback = resolve;
386
+ });
387
+ }
388
+ const { done, value } = await this.reader.read();
389
+ if (done) {
390
+ return void 0;
391
+ }
392
+ return value;
393
+ }
394
+ setEncoding(encoding) {
395
+ this.encoding = encoding;
396
+ }
397
+ async text() {
398
+ const chunks = [];
399
+ while (true) {
400
+ const { done, value } = await this.reader.read();
401
+ if (done) {
402
+ break;
403
+ }
404
+ if (value) {
405
+ chunks.push(value);
406
+ }
407
+ }
408
+ const decoder = new TextDecoder(this.encoding || "utf-8");
409
+ return decoder.decode(await new Blob(chunks).arrayBuffer());
410
+ }
411
+ async json() {
412
+ const text = await this.text();
413
+ return JSON.parse(text);
414
+ }
415
+ _write(chunk) {
416
+ this._emit("data", chunk);
417
+ }
418
+ _end() {
419
+ this._emit("end");
420
+ }
421
+ _error(error) {
422
+ this._emit("error", error);
423
+ }
424
+ _emit(event, data) {
425
+ if (this.events[event]) {
426
+ for (const callback of this.events[event] || []) {
427
+ callback(data);
428
+ }
429
+ }
430
+ }
431
+ async _startReading() {
432
+ try {
433
+ this._emit("readable");
434
+ while (true) {
435
+ if (this.paused) {
436
+ await new Promise((resolve) => {
437
+ this.resumeCallback = resolve;
438
+ });
439
+ }
440
+ const { done, value } = await this.reader.read();
441
+ if (done) {
442
+ this._emit("end");
443
+ this._emit("close");
444
+ break;
445
+ }
446
+ if (value) {
447
+ this._emit("data", value);
448
+ }
449
+ }
450
+ } catch (error) {
451
+ this._emit("error", error);
452
+ }
453
+ }
454
+ [Symbol.asyncIterator]() {
455
+ return {
456
+ next: async () => {
457
+ if (this.paused) {
458
+ await new Promise((resolve) => {
459
+ this.resumeCallback = resolve;
460
+ });
461
+ }
462
+ const { done, value } = await this.reader.read();
463
+ if (done) {
464
+ return { done: true, value: void 0 };
465
+ }
466
+ return { done: false, value };
467
+ },
468
+ [Symbol.asyncIterator]() {
469
+ return this;
470
+ }
471
+ };
472
+ }
473
+ };
474
+ }
475
+ });
476
+
477
+ // src/core/fetcher/stream-wrappers/NodePre18StreamWrapper.ts
478
+ var NodePre18StreamWrapper_exports = {};
479
+ __export(NodePre18StreamWrapper_exports, {
480
+ NodePre18StreamWrapper: () => NodePre18StreamWrapper
481
+ });
482
+ var NodePre18StreamWrapper;
483
+ var init_NodePre18StreamWrapper = __esm({
484
+ "src/core/fetcher/stream-wrappers/NodePre18StreamWrapper.ts"() {
485
+ "use strict";
486
+ NodePre18StreamWrapper = class {
487
+ readableStream;
488
+ encoding;
489
+ constructor(readableStream) {
490
+ this.readableStream = readableStream;
491
+ }
492
+ on(event, callback) {
493
+ this.readableStream.on(event, callback);
494
+ }
495
+ off(event, callback) {
496
+ this.readableStream.off(event, callback);
497
+ }
498
+ pipe(dest) {
499
+ this.readableStream.pipe(dest);
500
+ return dest;
501
+ }
502
+ pipeTo(dest) {
503
+ return this.pipe(dest);
504
+ }
505
+ unpipe(dest) {
506
+ if (dest) {
507
+ this.readableStream.unpipe(dest);
508
+ } else {
509
+ this.readableStream.unpipe();
510
+ }
511
+ }
512
+ destroy(error) {
513
+ this.readableStream.destroy(error);
514
+ }
515
+ pause() {
516
+ this.readableStream.pause();
517
+ }
518
+ resume() {
519
+ this.readableStream.resume();
520
+ }
521
+ get isPaused() {
522
+ return this.readableStream.isPaused();
523
+ }
524
+ async read() {
525
+ return new Promise((resolve, reject) => {
526
+ const chunk = this.readableStream.read();
527
+ if (chunk) {
528
+ resolve(chunk);
529
+ } else {
530
+ this.readableStream.once("readable", () => {
531
+ const chunk2 = this.readableStream.read();
532
+ resolve(chunk2);
533
+ });
534
+ this.readableStream.once("error", reject);
535
+ }
536
+ });
537
+ }
538
+ setEncoding(encoding) {
539
+ this.readableStream.setEncoding(encoding);
540
+ this.encoding = encoding;
541
+ }
542
+ async text() {
543
+ const chunks = [];
544
+ const encoder = new TextEncoder();
545
+ this.readableStream.setEncoding(this.encoding || "utf-8");
546
+ for await (const chunk of this.readableStream) {
547
+ chunks.push(encoder.encode(chunk));
548
+ }
549
+ const decoder = new TextDecoder(this.encoding || "utf-8");
550
+ return decoder.decode(Buffer.concat(chunks));
551
+ }
552
+ async json() {
553
+ const text = await this.text();
554
+ return JSON.parse(text);
555
+ }
556
+ [Symbol.asyncIterator]() {
557
+ const readableStream = this.readableStream;
558
+ const iterator = readableStream[Symbol.asyncIterator]();
559
+ return {
560
+ async next() {
561
+ const { value, done } = await iterator.next();
562
+ return { value, done };
563
+ },
564
+ [Symbol.asyncIterator]() {
565
+ return this;
566
+ }
567
+ };
568
+ }
569
+ };
570
+ }
571
+ });
572
+
573
+ // src/index.ts
574
+ var src_exports = {};
575
+ __export(src_exports, {
576
+ Rivet: () => api_exports,
577
+ RivetClient: () => RivetClient,
578
+ RivetError: () => RivetError,
579
+ RivetTimeoutError: () => RivetTimeoutError,
580
+ serialization: () => serialization_exports
581
+ });
582
+ module.exports = __toCommonJS(src_exports);
583
+
584
+ // src/api/index.ts
585
+ var api_exports = {};
586
+ __export(api_exports, {
587
+ CrashPolicy: () => CrashPolicy,
588
+ HealthStatus: () => HealthStatus,
589
+ RunnerConfigVariant: () => RunnerConfigVariant,
590
+ datacenters: () => datacenters_exports,
591
+ health: () => health_exports,
592
+ metadata: () => metadata_exports,
593
+ namespaces: () => namespaces_exports,
594
+ runners: () => runners_exports
595
+ });
596
+
597
+ // src/api/types/CrashPolicy.ts
598
+ var CrashPolicy = {
599
+ Restart: "restart",
600
+ Sleep: "sleep",
601
+ Destroy: "destroy"
602
+ };
603
+
604
+ // src/api/types/HealthStatus.ts
605
+ var HealthStatus = {
606
+ Ok: "ok",
607
+ Error: "error"
608
+ };
609
+
610
+ // src/api/types/RunnerConfigVariant.ts
611
+ var RunnerConfigVariant = {
612
+ Serverless: "serverless",
613
+ Normal: "normal"
614
+ };
615
+
616
+ // src/api/resources/datacenters/index.ts
617
+ var datacenters_exports = {};
618
+
619
+ // src/api/resources/health/index.ts
620
+ var health_exports = {};
621
+
622
+ // src/api/resources/metadata/index.ts
623
+ var metadata_exports = {};
624
+
625
+ // src/api/resources/namespaces/index.ts
626
+ var namespaces_exports = {};
627
+
628
+ // src/api/resources/runners/index.ts
629
+ var runners_exports = {};
630
+
631
+ // src/core/json.ts
632
+ var toJson = (value, replacer, space) => {
633
+ return JSON.stringify(value, replacer, space);
634
+ };
635
+
636
+ // src/core/fetcher/createRequestUrl.ts
637
+ var import_qs = __toESM(require("qs"));
638
+ function createRequestUrl(baseUrl, queryParameters) {
639
+ return Object.keys(queryParameters ?? {}).length > 0 ? `${baseUrl}?${import_qs.default.stringify(queryParameters, { arrayFormat: "repeat" })}` : baseUrl;
640
+ }
641
+
642
+ // src/core/runtime/runtime.ts
643
+ var RUNTIME = evaluateRuntime();
644
+ function evaluateRuntime() {
645
+ var _a, _b, _c, _d, _e;
646
+ const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
647
+ if (isBrowser) {
648
+ return {
649
+ type: "browser",
650
+ version: window.navigator.userAgent
651
+ };
652
+ }
653
+ const isCloudflare = typeof globalThis !== "undefined" && ((_a = globalThis == null ? void 0 : globalThis.navigator) == null ? void 0 : _a.userAgent) === "Cloudflare-Workers";
654
+ if (isCloudflare) {
655
+ return {
656
+ type: "workerd"
657
+ };
658
+ }
659
+ const isEdgeRuntime = typeof EdgeRuntime === "string";
660
+ if (isEdgeRuntime) {
661
+ return {
662
+ type: "edge-runtime"
663
+ };
664
+ }
665
+ const isWebWorker = typeof self === "object" && // @ts-ignore
666
+ typeof (self == null ? void 0 : self.importScripts) === "function" && (((_b = self.constructor) == null ? void 0 : _b.name) === "DedicatedWorkerGlobalScope" || ((_c = self.constructor) == null ? void 0 : _c.name) === "ServiceWorkerGlobalScope" || ((_d = self.constructor) == null ? void 0 : _d.name) === "SharedWorkerGlobalScope");
667
+ if (isWebWorker) {
668
+ return {
669
+ type: "web-worker"
670
+ };
671
+ }
672
+ const isDeno = typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined";
673
+ if (isDeno) {
674
+ return {
675
+ type: "deno",
676
+ version: Deno.version.deno
677
+ };
678
+ }
679
+ const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined";
680
+ if (isBun) {
681
+ return {
682
+ type: "bun",
683
+ version: Bun.version
684
+ };
685
+ }
686
+ const isNode = typeof process !== "undefined" && "version" in process && !!process.version && "versions" in process && !!((_e = process.versions) == null ? void 0 : _e.node);
687
+ if (isNode) {
688
+ return {
689
+ type: "node",
690
+ version: process.versions.node,
691
+ parsedVersion: Number(process.versions.node.split(".")[0])
692
+ };
693
+ }
694
+ const isReactNative = typeof navigator !== "undefined" && (navigator == null ? void 0 : navigator.product) === "ReactNative";
695
+ if (isReactNative) {
696
+ return {
697
+ type: "react-native"
698
+ };
699
+ }
700
+ return {
701
+ type: "unknown"
702
+ };
703
+ }
704
+
705
+ // src/core/fetcher/getFetchFn.ts
706
+ async function getFetchFn() {
707
+ if (RUNTIME.type === "node" && RUNTIME.parsedVersion != null && RUNTIME.parsedVersion >= 18) {
708
+ return fetch;
709
+ }
710
+ if (RUNTIME.type === "node") {
711
+ return (await import("node-fetch")).default;
712
+ }
713
+ if (typeof fetch == "function") {
714
+ return fetch;
715
+ }
716
+ return (await import("node-fetch")).default;
717
+ }
718
+
719
+ // src/core/fetcher/getRequestBody.ts
720
+ async function getRequestBody({ body, type }) {
721
+ if (type.includes("json")) {
722
+ return toJson(body);
723
+ } else {
724
+ return body;
725
+ }
726
+ }
727
+
728
+ // src/core/fetcher/stream-wrappers/chooseStreamWrapper.ts
729
+ async function chooseStreamWrapper(responseBody) {
730
+ if (RUNTIME.type === "node" && RUNTIME.parsedVersion != null && RUNTIME.parsedVersion >= 18) {
731
+ return new (await Promise.resolve().then(() => (init_Node18UniversalStreamWrapper(), Node18UniversalStreamWrapper_exports))).Node18UniversalStreamWrapper(
732
+ responseBody
733
+ );
734
+ } else if (RUNTIME.type !== "node" && typeof fetch === "function") {
735
+ return new (await Promise.resolve().then(() => (init_UndiciStreamWrapper(), UndiciStreamWrapper_exports))).UndiciStreamWrapper(responseBody);
736
+ } else {
737
+ return new (await Promise.resolve().then(() => (init_NodePre18StreamWrapper(), NodePre18StreamWrapper_exports))).NodePre18StreamWrapper(responseBody);
738
+ }
739
+ }
740
+
741
+ // src/core/fetcher/getResponseBody.ts
742
+ async function getResponseBody(response, responseType) {
743
+ if (response.body != null && responseType === "blob") {
744
+ return await response.blob();
745
+ } else if (response.body != null && responseType === "arrayBuffer") {
746
+ return await response.arrayBuffer();
747
+ } else if (response.body != null && responseType === "sse") {
748
+ return response.body;
749
+ } else if (response.body != null && responseType === "streaming") {
750
+ return chooseStreamWrapper(response.body);
751
+ } else if (response.body != null && responseType === "text") {
752
+ return await response.text();
753
+ } else {
754
+ const text = await response.text();
755
+ if (text.length > 0) {
756
+ try {
757
+ let responseBody = JSON.parse(text);
758
+ return responseBody;
759
+ } catch (err) {
760
+ return {
761
+ ok: false,
762
+ error: {
763
+ reason: "non-json",
764
+ statusCode: response.status,
765
+ rawBody: text
766
+ }
767
+ };
768
+ }
769
+ } else {
770
+ return void 0;
771
+ }
772
+ }
773
+ }
774
+
775
+ // src/core/fetcher/signals.ts
776
+ var TIMEOUT = "timeout";
777
+ function getTimeoutSignal(timeoutMs) {
778
+ const controller = new AbortController();
779
+ const abortId = setTimeout(() => controller.abort(TIMEOUT), timeoutMs);
780
+ return { signal: controller.signal, abortId };
781
+ }
782
+ function anySignal(...args) {
783
+ const signals = args.length === 1 && Array.isArray(args[0]) ? args[0] : args;
784
+ const controller = new AbortController();
785
+ for (const signal of signals) {
786
+ if (signal.aborted) {
787
+ controller.abort(signal == null ? void 0 : signal.reason);
788
+ break;
789
+ }
790
+ signal.addEventListener("abort", () => controller.abort(signal == null ? void 0 : signal.reason), {
791
+ signal: controller.signal
792
+ });
793
+ }
794
+ return controller.signal;
795
+ }
796
+
797
+ // src/core/fetcher/makeRequest.ts
798
+ var makeRequest = async (fetchFn, url, method, headers, requestBody, timeoutMs, abortSignal, withCredentials, duplex) => {
799
+ const signals = [];
800
+ let timeoutAbortId = void 0;
801
+ if (timeoutMs != null) {
802
+ const { signal, abortId } = getTimeoutSignal(timeoutMs);
803
+ timeoutAbortId = abortId;
804
+ signals.push(signal);
805
+ }
806
+ if (abortSignal != null) {
807
+ signals.push(abortSignal);
808
+ }
809
+ let newSignals = anySignal(signals);
810
+ const response = await fetchFn(url, {
811
+ method,
812
+ headers,
813
+ body: requestBody,
814
+ signal: newSignals,
815
+ credentials: withCredentials ? "include" : void 0,
816
+ // @ts-ignore
817
+ duplex
818
+ });
819
+ if (timeoutAbortId != null) {
820
+ clearTimeout(timeoutAbortId);
821
+ }
822
+ return response;
823
+ };
824
+
825
+ // src/core/fetcher/requestWithRetries.ts
826
+ var INITIAL_RETRY_DELAY = 1e3;
827
+ var MAX_RETRY_DELAY = 6e4;
828
+ var DEFAULT_MAX_RETRIES = 2;
829
+ var JITTER_FACTOR = 0.2;
830
+ function addJitter(delay) {
831
+ const jitterMultiplier = 1 + (Math.random() * 2 - 1) * JITTER_FACTOR;
832
+ return delay * jitterMultiplier;
833
+ }
834
+ async function requestWithRetries(requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
835
+ let response = await requestFn();
836
+ for (let i = 0; i < maxRetries; ++i) {
837
+ if ([408, 429].includes(response.status) || response.status >= 500) {
838
+ const baseDelay = Math.min(INITIAL_RETRY_DELAY * Math.pow(2, i), MAX_RETRY_DELAY);
839
+ const delayWithJitter = addJitter(baseDelay);
840
+ await new Promise((resolve) => setTimeout(resolve, delayWithJitter));
841
+ response = await requestFn();
842
+ } else {
843
+ break;
844
+ }
845
+ }
846
+ return response;
847
+ }
848
+
849
+ // src/core/fetcher/Fetcher.ts
850
+ async function fetcherImpl(args) {
851
+ const headers = {};
852
+ if (args.body !== void 0 && args.contentType != null) {
853
+ headers["Content-Type"] = args.contentType;
854
+ }
855
+ if (args.headers != null) {
856
+ for (const [key, value] of Object.entries(args.headers)) {
857
+ if (value != null) {
858
+ headers[key] = value;
859
+ }
860
+ }
861
+ }
862
+ const url = createRequestUrl(args.url, args.queryParameters);
863
+ const requestBody = await getRequestBody({
864
+ body: args.body,
865
+ type: args.requestType === "json" ? "json" : "other"
866
+ });
867
+ const fetchFn = await getFetchFn();
868
+ try {
869
+ const response = await requestWithRetries(
870
+ async () => makeRequest(
871
+ fetchFn,
872
+ url,
873
+ args.method,
874
+ headers,
875
+ requestBody,
876
+ args.timeoutMs,
877
+ args.abortSignal,
878
+ args.withCredentials,
879
+ args.duplex
880
+ ),
881
+ args.maxRetries
882
+ );
883
+ const responseBody = await getResponseBody(response, args.responseType);
884
+ if (response.status >= 200 && response.status < 400) {
885
+ return {
886
+ ok: true,
887
+ body: responseBody,
888
+ headers: response.headers
889
+ };
890
+ } else {
891
+ return {
892
+ ok: false,
893
+ error: {
894
+ reason: "status-code",
895
+ statusCode: response.status,
896
+ body: responseBody
897
+ }
898
+ };
899
+ }
900
+ } catch (error) {
901
+ if (args.abortSignal != null && args.abortSignal.aborted) {
902
+ return {
903
+ ok: false,
904
+ error: {
905
+ reason: "unknown",
906
+ errorMessage: "The user aborted a request"
907
+ }
908
+ };
909
+ } else if (error instanceof Error && error.name === "AbortError") {
910
+ return {
911
+ ok: false,
912
+ error: {
913
+ reason: "timeout"
914
+ }
915
+ };
916
+ } else if (error instanceof Error) {
917
+ return {
918
+ ok: false,
919
+ error: {
920
+ reason: "unknown",
921
+ errorMessage: error.message
922
+ }
923
+ };
924
+ }
925
+ return {
926
+ ok: false,
927
+ error: {
928
+ reason: "unknown",
929
+ errorMessage: toJson(error)
930
+ }
931
+ };
932
+ }
933
+ }
934
+ var fetcher = fetcherImpl;
935
+
936
+ // src/core/fetcher/Supplier.ts
937
+ var Supplier = {
938
+ get: async (supplier) => {
939
+ if (typeof supplier === "function") {
940
+ return supplier();
941
+ } else {
942
+ return supplier;
943
+ }
944
+ }
945
+ };
946
+
947
+ // src/core/auth/BasicAuth.ts
948
+ var import_js_base64 = require("js-base64");
949
+
950
+ // src/core/schemas/index.ts
951
+ var schemas_exports = {};
952
+ __export(schemas_exports, {
953
+ JsonError: () => JsonError,
954
+ ParseError: () => ParseError,
955
+ any: () => any,
956
+ bigint: () => bigint,
957
+ boolean: () => boolean,
958
+ booleanLiteral: () => booleanLiteral,
959
+ date: () => date,
960
+ discriminant: () => discriminant,
961
+ enum_: () => enum_,
962
+ getObjectLikeUtils: () => getObjectLikeUtils,
963
+ getObjectUtils: () => getObjectUtils,
964
+ getSchemaUtils: () => getSchemaUtils,
965
+ isProperty: () => isProperty,
966
+ lazy: () => lazy,
967
+ lazyObject: () => lazyObject,
968
+ list: () => list,
969
+ number: () => number,
970
+ object: () => object,
971
+ objectWithoutOptionalProperties: () => objectWithoutOptionalProperties,
972
+ optional: () => optional,
973
+ property: () => property,
974
+ record: () => record,
975
+ set: () => set,
976
+ string: () => string,
977
+ stringLiteral: () => stringLiteral,
978
+ transform: () => transform,
979
+ undiscriminatedUnion: () => undiscriminatedUnion,
980
+ union: () => union,
981
+ unknown: () => unknown,
982
+ withParsedProperties: () => withParsedProperties
983
+ });
984
+
985
+ // src/core/schemas/Schema.ts
986
+ var SchemaType = {
987
+ BIGINT: "bigint",
988
+ DATE: "date",
989
+ ENUM: "enum",
990
+ LIST: "list",
991
+ STRING_LITERAL: "stringLiteral",
992
+ BOOLEAN_LITERAL: "booleanLiteral",
993
+ OBJECT: "object",
994
+ ANY: "any",
995
+ BOOLEAN: "boolean",
996
+ NUMBER: "number",
997
+ STRING: "string",
998
+ UNKNOWN: "unknown",
999
+ RECORD: "record",
1000
+ SET: "set",
1001
+ UNION: "union",
1002
+ UNDISCRIMINATED_UNION: "undiscriminatedUnion",
1003
+ NULLABLE: "nullable",
1004
+ OPTIONAL: "optional",
1005
+ OPTIONAL_NULLABLE: "optionalNullable"
1006
+ };
1007
+
1008
+ // src/core/schemas/utils/getErrorMessageForIncorrectType.ts
1009
+ function getErrorMessageForIncorrectType(value, expectedType) {
1010
+ return `Expected ${expectedType}. Received ${getTypeAsString(value)}.`;
1011
+ }
1012
+ function getTypeAsString(value) {
1013
+ if (Array.isArray(value)) {
1014
+ return "list";
1015
+ }
1016
+ if (value === null) {
1017
+ return "null";
1018
+ }
1019
+ if (value instanceof BigInt) {
1020
+ return "BigInt";
1021
+ }
1022
+ switch (typeof value) {
1023
+ case "string":
1024
+ return `"${value}"`;
1025
+ case "bigint":
1026
+ case "number":
1027
+ case "boolean":
1028
+ case "undefined":
1029
+ return `${value}`;
1030
+ }
1031
+ return typeof value;
1032
+ }
1033
+
1034
+ // src/core/schemas/utils/maybeSkipValidation.ts
1035
+ function maybeSkipValidation(schema) {
1036
+ return {
1037
+ ...schema,
1038
+ json: transformAndMaybeSkipValidation(schema.json),
1039
+ parse: transformAndMaybeSkipValidation(schema.parse)
1040
+ };
1041
+ }
1042
+ function transformAndMaybeSkipValidation(transform2) {
1043
+ return (value, opts) => {
1044
+ const transformed = transform2(value, opts);
1045
+ const { skipValidation = false } = opts ?? {};
1046
+ if (!transformed.ok && skipValidation) {
1047
+ console.warn(
1048
+ [
1049
+ "Failed to validate.",
1050
+ ...transformed.errors.map(
1051
+ (error) => " - " + (error.path.length > 0 ? `${error.path.join(".")}: ${error.message}` : error.message)
1052
+ )
1053
+ ].join("\n")
1054
+ );
1055
+ return {
1056
+ ok: true,
1057
+ value
1058
+ };
1059
+ } else {
1060
+ return transformed;
1061
+ }
1062
+ };
1063
+ }
1064
+
1065
+ // src/core/schemas/builders/schema-utils/stringifyValidationErrors.ts
1066
+ function stringifyValidationError(error) {
1067
+ if (error.path.length === 0) {
1068
+ return error.message;
1069
+ }
1070
+ return `${error.path.join(" -> ")}: ${error.message}`;
1071
+ }
1072
+
1073
+ // src/core/schemas/builders/schema-utils/JsonError.ts
1074
+ var JsonError = class _JsonError extends Error {
1075
+ constructor(errors) {
1076
+ super(errors.map(stringifyValidationError).join("; "));
1077
+ this.errors = errors;
1078
+ Object.setPrototypeOf(this, _JsonError.prototype);
1079
+ }
1080
+ };
1081
+
1082
+ // src/core/schemas/builders/schema-utils/ParseError.ts
1083
+ var ParseError = class _ParseError extends Error {
1084
+ constructor(errors) {
1085
+ super(errors.map(stringifyValidationError).join("; "));
1086
+ this.errors = errors;
1087
+ Object.setPrototypeOf(this, _ParseError.prototype);
1088
+ }
1089
+ };
1090
+
1091
+ // src/core/schemas/builders/schema-utils/getSchemaUtils.ts
1092
+ function getSchemaUtils(schema) {
1093
+ return {
1094
+ nullable: () => nullable(schema),
1095
+ optional: () => optional(schema),
1096
+ optionalNullable: () => optionalNullable(schema),
1097
+ transform: (transformer) => transform(schema, transformer),
1098
+ parseOrThrow: (raw, opts) => {
1099
+ const parsed = schema.parse(raw, opts);
1100
+ if (parsed.ok) {
1101
+ return parsed.value;
1102
+ }
1103
+ throw new ParseError(parsed.errors);
1104
+ },
1105
+ jsonOrThrow: (parsed, opts) => {
1106
+ const raw = schema.json(parsed, opts);
1107
+ if (raw.ok) {
1108
+ return raw.value;
1109
+ }
1110
+ throw new JsonError(raw.errors);
1111
+ }
1112
+ };
1113
+ }
1114
+ function nullable(schema) {
1115
+ const baseSchema = {
1116
+ parse: (raw, opts) => {
1117
+ if (raw == null) {
1118
+ return {
1119
+ ok: true,
1120
+ value: null
1121
+ };
1122
+ }
1123
+ return schema.parse(raw, opts);
1124
+ },
1125
+ json: (parsed, opts) => {
1126
+ if (parsed == null) {
1127
+ return {
1128
+ ok: true,
1129
+ value: null
1130
+ };
1131
+ }
1132
+ return schema.json(parsed, opts);
1133
+ },
1134
+ getType: () => SchemaType.NULLABLE
1135
+ };
1136
+ return {
1137
+ ...baseSchema,
1138
+ ...getSchemaUtils(baseSchema)
1139
+ };
1140
+ }
1141
+ function optional(schema) {
1142
+ const baseSchema = {
1143
+ parse: (raw, opts) => {
1144
+ if (raw == null) {
1145
+ return {
1146
+ ok: true,
1147
+ value: void 0
1148
+ };
1149
+ }
1150
+ return schema.parse(raw, opts);
1151
+ },
1152
+ json: (parsed, opts) => {
1153
+ if ((opts == null ? void 0 : opts.omitUndefined) && parsed === void 0) {
1154
+ return {
1155
+ ok: true,
1156
+ value: void 0
1157
+ };
1158
+ }
1159
+ if (parsed == null) {
1160
+ return {
1161
+ ok: true,
1162
+ value: null
1163
+ };
1164
+ }
1165
+ return schema.json(parsed, opts);
1166
+ },
1167
+ getType: () => SchemaType.OPTIONAL
1168
+ };
1169
+ return {
1170
+ ...baseSchema,
1171
+ ...getSchemaUtils(baseSchema)
1172
+ };
1173
+ }
1174
+ function optionalNullable(schema) {
1175
+ const baseSchema = {
1176
+ parse: (raw, opts) => {
1177
+ if (raw === void 0) {
1178
+ return {
1179
+ ok: true,
1180
+ value: void 0
1181
+ };
1182
+ }
1183
+ if (raw === null) {
1184
+ return {
1185
+ ok: true,
1186
+ value: null
1187
+ };
1188
+ }
1189
+ return schema.parse(raw, opts);
1190
+ },
1191
+ json: (parsed, opts) => {
1192
+ if (parsed === void 0) {
1193
+ return {
1194
+ ok: true,
1195
+ value: void 0
1196
+ };
1197
+ }
1198
+ if (parsed === null) {
1199
+ return {
1200
+ ok: true,
1201
+ value: null
1202
+ };
1203
+ }
1204
+ return schema.json(parsed, opts);
1205
+ },
1206
+ getType: () => SchemaType.OPTIONAL_NULLABLE
1207
+ };
1208
+ return {
1209
+ ...baseSchema,
1210
+ ...getSchemaUtils(baseSchema)
1211
+ };
1212
+ }
1213
+ function transform(schema, transformer) {
1214
+ const baseSchema = {
1215
+ parse: (raw, opts) => {
1216
+ const parsed = schema.parse(raw, opts);
1217
+ if (!parsed.ok) {
1218
+ return parsed;
1219
+ }
1220
+ return {
1221
+ ok: true,
1222
+ value: transformer.transform(parsed.value)
1223
+ };
1224
+ },
1225
+ json: (transformed, opts) => {
1226
+ const parsed = transformer.untransform(transformed);
1227
+ return schema.json(parsed, opts);
1228
+ },
1229
+ getType: () => schema.getType()
1230
+ };
1231
+ return {
1232
+ ...baseSchema,
1233
+ ...getSchemaUtils(baseSchema)
1234
+ };
1235
+ }
1236
+
1237
+ // src/core/schemas/builders/bigint/bigint.ts
1238
+ function bigint() {
1239
+ const baseSchema = {
1240
+ parse: (raw, { breadcrumbsPrefix = [] } = {}) => {
1241
+ if (typeof raw === "bigint") {
1242
+ return {
1243
+ ok: true,
1244
+ value: raw
1245
+ };
1246
+ }
1247
+ if (typeof raw === "number") {
1248
+ return {
1249
+ ok: true,
1250
+ value: BigInt(raw)
1251
+ };
1252
+ }
1253
+ return {
1254
+ ok: false,
1255
+ errors: [
1256
+ {
1257
+ path: breadcrumbsPrefix,
1258
+ message: getErrorMessageForIncorrectType(raw, "bigint | number")
1259
+ }
1260
+ ]
1261
+ };
1262
+ },
1263
+ json: (bigint2, { breadcrumbsPrefix = [] } = {}) => {
1264
+ if (typeof bigint2 !== "bigint") {
1265
+ return {
1266
+ ok: false,
1267
+ errors: [
1268
+ {
1269
+ path: breadcrumbsPrefix,
1270
+ message: getErrorMessageForIncorrectType(bigint2, "bigint")
1271
+ }
1272
+ ]
1273
+ };
1274
+ }
1275
+ return {
1276
+ ok: true,
1277
+ value: bigint2
1278
+ };
1279
+ },
1280
+ getType: () => SchemaType.BIGINT
1281
+ };
1282
+ return {
1283
+ ...maybeSkipValidation(baseSchema),
1284
+ ...getSchemaUtils(baseSchema)
1285
+ };
1286
+ }
1287
+
1288
+ // src/core/schemas/builders/date/date.ts
1289
+ var ISO_8601_REGEX = /^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
1290
+ function date() {
1291
+ const baseSchema = {
1292
+ parse: (raw, { breadcrumbsPrefix = [] } = {}) => {
1293
+ if (typeof raw !== "string") {
1294
+ return {
1295
+ ok: false,
1296
+ errors: [
1297
+ {
1298
+ path: breadcrumbsPrefix,
1299
+ message: getErrorMessageForIncorrectType(raw, "string")
1300
+ }
1301
+ ]
1302
+ };
1303
+ }
1304
+ if (!ISO_8601_REGEX.test(raw)) {
1305
+ return {
1306
+ ok: false,
1307
+ errors: [
1308
+ {
1309
+ path: breadcrumbsPrefix,
1310
+ message: getErrorMessageForIncorrectType(raw, "ISO 8601 date string")
1311
+ }
1312
+ ]
1313
+ };
1314
+ }
1315
+ return {
1316
+ ok: true,
1317
+ value: new Date(raw)
1318
+ };
1319
+ },
1320
+ json: (date2, { breadcrumbsPrefix = [] } = {}) => {
1321
+ if (date2 instanceof Date) {
1322
+ return {
1323
+ ok: true,
1324
+ value: date2.toISOString()
1325
+ };
1326
+ } else {
1327
+ return {
1328
+ ok: false,
1329
+ errors: [
1330
+ {
1331
+ path: breadcrumbsPrefix,
1332
+ message: getErrorMessageForIncorrectType(date2, "Date object")
1333
+ }
1334
+ ]
1335
+ };
1336
+ }
1337
+ },
1338
+ getType: () => SchemaType.DATE
1339
+ };
1340
+ return {
1341
+ ...maybeSkipValidation(baseSchema),
1342
+ ...getSchemaUtils(baseSchema)
1343
+ };
1344
+ }
1345
+
1346
+ // src/core/schemas/utils/createIdentitySchemaCreator.ts
1347
+ function createIdentitySchemaCreator(schemaType, validate) {
1348
+ return () => {
1349
+ const baseSchema = {
1350
+ parse: validate,
1351
+ json: validate,
1352
+ getType: () => schemaType
1353
+ };
1354
+ return {
1355
+ ...maybeSkipValidation(baseSchema),
1356
+ ...getSchemaUtils(baseSchema)
1357
+ };
1358
+ };
1359
+ }
1360
+
1361
+ // src/core/schemas/builders/enum/enum.ts
1362
+ function enum_(values) {
1363
+ const validValues = new Set(values);
1364
+ const schemaCreator = createIdentitySchemaCreator(
1365
+ SchemaType.ENUM,
1366
+ (value, { allowUnrecognizedEnumValues, breadcrumbsPrefix = [] } = {}) => {
1367
+ if (typeof value !== "string") {
1368
+ return {
1369
+ ok: false,
1370
+ errors: [
1371
+ {
1372
+ path: breadcrumbsPrefix,
1373
+ message: getErrorMessageForIncorrectType(value, "string")
1374
+ }
1375
+ ]
1376
+ };
1377
+ }
1378
+ if (!validValues.has(value) && !allowUnrecognizedEnumValues) {
1379
+ return {
1380
+ ok: false,
1381
+ errors: [
1382
+ {
1383
+ path: breadcrumbsPrefix,
1384
+ message: getErrorMessageForIncorrectType(value, "enum")
1385
+ }
1386
+ ]
1387
+ };
1388
+ }
1389
+ return {
1390
+ ok: true,
1391
+ value
1392
+ };
1393
+ }
1394
+ );
1395
+ return schemaCreator();
1396
+ }
1397
+
1398
+ // src/core/schemas/builders/lazy/lazy.ts
1399
+ function lazy(getter) {
1400
+ const baseSchema = constructLazyBaseSchema(getter);
1401
+ return {
1402
+ ...baseSchema,
1403
+ ...getSchemaUtils(baseSchema)
1404
+ };
1405
+ }
1406
+ function constructLazyBaseSchema(getter) {
1407
+ return {
1408
+ parse: (raw, opts) => getMemoizedSchema(getter).parse(raw, opts),
1409
+ json: (parsed, opts) => getMemoizedSchema(getter).json(parsed, opts),
1410
+ getType: () => getMemoizedSchema(getter).getType()
1411
+ };
1412
+ }
1413
+ function getMemoizedSchema(getter) {
1414
+ const castedGetter = getter;
1415
+ if (castedGetter.__zurg_memoized == null) {
1416
+ castedGetter.__zurg_memoized = getter();
1417
+ }
1418
+ return castedGetter.__zurg_memoized;
1419
+ }
1420
+
1421
+ // src/core/schemas/utils/entries.ts
1422
+ function entries(object2) {
1423
+ return Object.entries(object2);
1424
+ }
1425
+
1426
+ // src/core/schemas/utils/filterObject.ts
1427
+ function filterObject(obj, keysToInclude) {
1428
+ const keysToIncludeSet = new Set(keysToInclude);
1429
+ return Object.entries(obj).reduce(
1430
+ (acc, [key, value]) => {
1431
+ if (keysToIncludeSet.has(key)) {
1432
+ acc[key] = value;
1433
+ }
1434
+ return acc;
1435
+ },
1436
+ {}
1437
+ );
1438
+ }
1439
+
1440
+ // src/core/schemas/utils/isPlainObject.ts
1441
+ function isPlainObject(value) {
1442
+ if (typeof value !== "object" || value === null) {
1443
+ return false;
1444
+ }
1445
+ if (Object.getPrototypeOf(value) === null) {
1446
+ return true;
1447
+ }
1448
+ let proto = value;
1449
+ while (Object.getPrototypeOf(proto) !== null) {
1450
+ proto = Object.getPrototypeOf(proto);
1451
+ }
1452
+ return Object.getPrototypeOf(value) === proto;
1453
+ }
1454
+
1455
+ // src/core/schemas/utils/keys.ts
1456
+ function keys(object2) {
1457
+ return Object.keys(object2);
1458
+ }
1459
+
1460
+ // src/core/schemas/utils/partition.ts
1461
+ function partition(items, predicate) {
1462
+ const trueItems = [], falseItems = [];
1463
+ for (const item of items) {
1464
+ if (predicate(item)) {
1465
+ trueItems.push(item);
1466
+ } else {
1467
+ falseItems.push(item);
1468
+ }
1469
+ }
1470
+ return [trueItems, falseItems];
1471
+ }
1472
+
1473
+ // src/core/schemas/builders/object-like/getObjectLikeUtils.ts
1474
+ function getObjectLikeUtils(schema) {
1475
+ return {
1476
+ withParsedProperties: (properties) => withParsedProperties(schema, properties)
1477
+ };
1478
+ }
1479
+ function withParsedProperties(objectLike, properties) {
1480
+ const objectSchema = {
1481
+ parse: (raw, opts) => {
1482
+ const parsedObject = objectLike.parse(raw, opts);
1483
+ if (!parsedObject.ok) {
1484
+ return parsedObject;
1485
+ }
1486
+ const additionalProperties = Object.entries(properties).reduce(
1487
+ (processed, [key, value]) => {
1488
+ return {
1489
+ ...processed,
1490
+ [key]: typeof value === "function" ? value(parsedObject.value) : value
1491
+ };
1492
+ },
1493
+ {}
1494
+ );
1495
+ return {
1496
+ ok: true,
1497
+ value: {
1498
+ ...parsedObject.value,
1499
+ ...additionalProperties
1500
+ }
1501
+ };
1502
+ },
1503
+ json: (parsed, opts) => {
1504
+ if (!isPlainObject(parsed)) {
1505
+ return {
1506
+ ok: false,
1507
+ errors: [
1508
+ {
1509
+ path: (opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [],
1510
+ message: getErrorMessageForIncorrectType(parsed, "object")
1511
+ }
1512
+ ]
1513
+ };
1514
+ }
1515
+ const addedPropertyKeys = new Set(Object.keys(properties));
1516
+ const parsedWithoutAddedProperties = filterObject(
1517
+ parsed,
1518
+ Object.keys(parsed).filter((key) => !addedPropertyKeys.has(key))
1519
+ );
1520
+ return objectLike.json(parsedWithoutAddedProperties, opts);
1521
+ },
1522
+ getType: () => objectLike.getType()
1523
+ };
1524
+ return {
1525
+ ...objectSchema,
1526
+ ...getSchemaUtils(objectSchema),
1527
+ ...getObjectLikeUtils(objectSchema)
1528
+ };
1529
+ }
1530
+
1531
+ // src/core/schemas/builders/object/property.ts
1532
+ function property(rawKey, valueSchema) {
1533
+ return {
1534
+ rawKey,
1535
+ valueSchema,
1536
+ isProperty: true
1537
+ };
1538
+ }
1539
+ function isProperty(maybeProperty) {
1540
+ return maybeProperty.isProperty;
1541
+ }
1542
+
1543
+ // src/core/schemas/builders/object/object.ts
1544
+ function object(schemas) {
1545
+ const baseSchema = {
1546
+ _getRawProperties: () => Object.entries(schemas).map(
1547
+ ([parsedKey, propertySchema]) => isProperty(propertySchema) ? propertySchema.rawKey : parsedKey
1548
+ ),
1549
+ _getParsedProperties: () => keys(schemas),
1550
+ parse: (raw, opts) => {
1551
+ const rawKeyToProperty = {};
1552
+ const requiredKeys = [];
1553
+ for (const [parsedKey, schemaOrObjectProperty] of entries(schemas)) {
1554
+ const rawKey = isProperty(schemaOrObjectProperty) ? schemaOrObjectProperty.rawKey : parsedKey;
1555
+ const valueSchema = isProperty(schemaOrObjectProperty) ? schemaOrObjectProperty.valueSchema : schemaOrObjectProperty;
1556
+ const property2 = {
1557
+ rawKey,
1558
+ parsedKey,
1559
+ valueSchema
1560
+ };
1561
+ rawKeyToProperty[rawKey] = property2;
1562
+ if (isSchemaRequired(valueSchema)) {
1563
+ requiredKeys.push(rawKey);
1564
+ }
1565
+ }
1566
+ return validateAndTransformObject({
1567
+ value: raw,
1568
+ requiredKeys,
1569
+ getProperty: (rawKey) => {
1570
+ const property2 = rawKeyToProperty[rawKey];
1571
+ if (property2 == null) {
1572
+ return void 0;
1573
+ }
1574
+ return {
1575
+ transformedKey: property2.parsedKey,
1576
+ transform: (propertyValue) => property2.valueSchema.parse(propertyValue, {
1577
+ ...opts,
1578
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], rawKey]
1579
+ })
1580
+ };
1581
+ },
1582
+ unrecognizedObjectKeys: opts == null ? void 0 : opts.unrecognizedObjectKeys,
1583
+ skipValidation: opts == null ? void 0 : opts.skipValidation,
1584
+ breadcrumbsPrefix: opts == null ? void 0 : opts.breadcrumbsPrefix,
1585
+ omitUndefined: opts == null ? void 0 : opts.omitUndefined
1586
+ });
1587
+ },
1588
+ json: (parsed, opts) => {
1589
+ const requiredKeys = [];
1590
+ for (const [parsedKey, schemaOrObjectProperty] of entries(schemas)) {
1591
+ const valueSchema = isProperty(schemaOrObjectProperty) ? schemaOrObjectProperty.valueSchema : schemaOrObjectProperty;
1592
+ if (isSchemaRequired(valueSchema)) {
1593
+ requiredKeys.push(parsedKey);
1594
+ }
1595
+ }
1596
+ return validateAndTransformObject({
1597
+ value: parsed,
1598
+ requiredKeys,
1599
+ getProperty: (parsedKey) => {
1600
+ const property2 = schemas[parsedKey];
1601
+ if (property2 == null) {
1602
+ return void 0;
1603
+ }
1604
+ if (isProperty(property2)) {
1605
+ return {
1606
+ transformedKey: property2.rawKey,
1607
+ transform: (propertyValue) => property2.valueSchema.json(propertyValue, {
1608
+ ...opts,
1609
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], parsedKey]
1610
+ })
1611
+ };
1612
+ } else {
1613
+ return {
1614
+ transformedKey: parsedKey,
1615
+ transform: (propertyValue) => property2.json(propertyValue, {
1616
+ ...opts,
1617
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], parsedKey]
1618
+ })
1619
+ };
1620
+ }
1621
+ },
1622
+ unrecognizedObjectKeys: opts == null ? void 0 : opts.unrecognizedObjectKeys,
1623
+ skipValidation: opts == null ? void 0 : opts.skipValidation,
1624
+ breadcrumbsPrefix: opts == null ? void 0 : opts.breadcrumbsPrefix,
1625
+ omitUndefined: opts == null ? void 0 : opts.omitUndefined
1626
+ });
1627
+ },
1628
+ getType: () => SchemaType.OBJECT
1629
+ };
1630
+ return {
1631
+ ...maybeSkipValidation(baseSchema),
1632
+ ...getSchemaUtils(baseSchema),
1633
+ ...getObjectLikeUtils(baseSchema),
1634
+ ...getObjectUtils(baseSchema)
1635
+ };
1636
+ }
1637
+ function validateAndTransformObject({
1638
+ value,
1639
+ requiredKeys,
1640
+ getProperty,
1641
+ unrecognizedObjectKeys = "fail",
1642
+ skipValidation = false,
1643
+ breadcrumbsPrefix = []
1644
+ }) {
1645
+ if (!isPlainObject(value)) {
1646
+ return {
1647
+ ok: false,
1648
+ errors: [
1649
+ {
1650
+ path: breadcrumbsPrefix,
1651
+ message: getErrorMessageForIncorrectType(value, "object")
1652
+ }
1653
+ ]
1654
+ };
1655
+ }
1656
+ const missingRequiredKeys = new Set(requiredKeys);
1657
+ const errors = [];
1658
+ const transformed = {};
1659
+ for (const [preTransformedKey, preTransformedItemValue] of Object.entries(value)) {
1660
+ const property2 = getProperty(preTransformedKey);
1661
+ if (property2 != null) {
1662
+ missingRequiredKeys.delete(preTransformedKey);
1663
+ const value2 = property2.transform(preTransformedItemValue);
1664
+ if (value2.ok) {
1665
+ transformed[property2.transformedKey] = value2.value;
1666
+ } else {
1667
+ transformed[preTransformedKey] = preTransformedItemValue;
1668
+ errors.push(...value2.errors);
1669
+ }
1670
+ } else {
1671
+ switch (unrecognizedObjectKeys) {
1672
+ case "fail":
1673
+ errors.push({
1674
+ path: [...breadcrumbsPrefix, preTransformedKey],
1675
+ message: `Unexpected key "${preTransformedKey}"`
1676
+ });
1677
+ break;
1678
+ case "strip":
1679
+ break;
1680
+ case "passthrough":
1681
+ transformed[preTransformedKey] = preTransformedItemValue;
1682
+ break;
1683
+ }
1684
+ }
1685
+ }
1686
+ errors.push(
1687
+ ...requiredKeys.filter((key) => missingRequiredKeys.has(key)).map((key) => ({
1688
+ path: breadcrumbsPrefix,
1689
+ message: `Missing required key "${key}"`
1690
+ }))
1691
+ );
1692
+ if (errors.length === 0 || skipValidation) {
1693
+ return {
1694
+ ok: true,
1695
+ value: transformed
1696
+ };
1697
+ } else {
1698
+ return {
1699
+ ok: false,
1700
+ errors
1701
+ };
1702
+ }
1703
+ }
1704
+ function getObjectUtils(schema) {
1705
+ return {
1706
+ extend: (extension) => {
1707
+ const baseSchema = {
1708
+ _getParsedProperties: () => [...schema._getParsedProperties(), ...extension._getParsedProperties()],
1709
+ _getRawProperties: () => [...schema._getRawProperties(), ...extension._getRawProperties()],
1710
+ parse: (raw, opts) => {
1711
+ return validateAndTransformExtendedObject({
1712
+ extensionKeys: extension._getRawProperties(),
1713
+ value: raw,
1714
+ transformBase: (rawBase) => schema.parse(rawBase, opts),
1715
+ transformExtension: (rawExtension) => extension.parse(rawExtension, opts)
1716
+ });
1717
+ },
1718
+ json: (parsed, opts) => {
1719
+ return validateAndTransformExtendedObject({
1720
+ extensionKeys: extension._getParsedProperties(),
1721
+ value: parsed,
1722
+ transformBase: (parsedBase) => schema.json(parsedBase, opts),
1723
+ transformExtension: (parsedExtension) => extension.json(parsedExtension, opts)
1724
+ });
1725
+ },
1726
+ getType: () => SchemaType.OBJECT
1727
+ };
1728
+ return {
1729
+ ...baseSchema,
1730
+ ...getSchemaUtils(baseSchema),
1731
+ ...getObjectLikeUtils(baseSchema),
1732
+ ...getObjectUtils(baseSchema)
1733
+ };
1734
+ },
1735
+ passthrough: () => {
1736
+ const baseSchema = {
1737
+ _getParsedProperties: () => schema._getParsedProperties(),
1738
+ _getRawProperties: () => schema._getRawProperties(),
1739
+ parse: (raw, opts) => {
1740
+ const transformed = schema.parse(raw, { ...opts, unrecognizedObjectKeys: "passthrough" });
1741
+ if (!transformed.ok) {
1742
+ return transformed;
1743
+ }
1744
+ return {
1745
+ ok: true,
1746
+ value: {
1747
+ ...raw,
1748
+ ...transformed.value
1749
+ }
1750
+ };
1751
+ },
1752
+ json: (parsed, opts) => {
1753
+ const transformed = schema.json(parsed, { ...opts, unrecognizedObjectKeys: "passthrough" });
1754
+ if (!transformed.ok) {
1755
+ return transformed;
1756
+ }
1757
+ return {
1758
+ ok: true,
1759
+ value: {
1760
+ ...parsed,
1761
+ ...transformed.value
1762
+ }
1763
+ };
1764
+ },
1765
+ getType: () => SchemaType.OBJECT
1766
+ };
1767
+ return {
1768
+ ...baseSchema,
1769
+ ...getSchemaUtils(baseSchema),
1770
+ ...getObjectLikeUtils(baseSchema),
1771
+ ...getObjectUtils(baseSchema)
1772
+ };
1773
+ }
1774
+ };
1775
+ }
1776
+ function validateAndTransformExtendedObject({
1777
+ extensionKeys,
1778
+ value,
1779
+ transformBase,
1780
+ transformExtension
1781
+ }) {
1782
+ const extensionPropertiesSet = new Set(extensionKeys);
1783
+ const [extensionProperties, baseProperties] = partition(
1784
+ keys(value),
1785
+ (key) => extensionPropertiesSet.has(key)
1786
+ );
1787
+ const transformedBase = transformBase(filterObject(value, baseProperties));
1788
+ const transformedExtension = transformExtension(filterObject(value, extensionProperties));
1789
+ if (transformedBase.ok && transformedExtension.ok) {
1790
+ return {
1791
+ ok: true,
1792
+ value: {
1793
+ ...transformedBase.value,
1794
+ ...transformedExtension.value
1795
+ }
1796
+ };
1797
+ } else {
1798
+ return {
1799
+ ok: false,
1800
+ errors: [
1801
+ ...transformedBase.ok ? [] : transformedBase.errors,
1802
+ ...transformedExtension.ok ? [] : transformedExtension.errors
1803
+ ]
1804
+ };
1805
+ }
1806
+ }
1807
+ function isSchemaRequired(schema) {
1808
+ return !isSchemaOptional(schema);
1809
+ }
1810
+ function isSchemaOptional(schema) {
1811
+ switch (schema.getType()) {
1812
+ case SchemaType.ANY:
1813
+ case SchemaType.UNKNOWN:
1814
+ case SchemaType.OPTIONAL:
1815
+ case SchemaType.OPTIONAL_NULLABLE:
1816
+ return true;
1817
+ default:
1818
+ return false;
1819
+ }
1820
+ }
1821
+
1822
+ // src/core/schemas/builders/object/objectWithoutOptionalProperties.ts
1823
+ function objectWithoutOptionalProperties(schemas) {
1824
+ return object(schemas);
1825
+ }
1826
+
1827
+ // src/core/schemas/builders/lazy/lazyObject.ts
1828
+ function lazyObject(getter) {
1829
+ const baseSchema = {
1830
+ ...constructLazyBaseSchema(getter),
1831
+ _getRawProperties: () => getMemoizedSchema(getter)._getRawProperties(),
1832
+ _getParsedProperties: () => getMemoizedSchema(getter)._getParsedProperties()
1833
+ };
1834
+ return {
1835
+ ...baseSchema,
1836
+ ...getSchemaUtils(baseSchema),
1837
+ ...getObjectLikeUtils(baseSchema),
1838
+ ...getObjectUtils(baseSchema)
1839
+ };
1840
+ }
1841
+
1842
+ // src/core/schemas/builders/list/list.ts
1843
+ function list(schema) {
1844
+ const baseSchema = {
1845
+ parse: (raw, opts) => validateAndTransformArray(
1846
+ raw,
1847
+ (item, index) => schema.parse(item, {
1848
+ ...opts,
1849
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], `[${index}]`]
1850
+ })
1851
+ ),
1852
+ json: (parsed, opts) => validateAndTransformArray(
1853
+ parsed,
1854
+ (item, index) => schema.json(item, {
1855
+ ...opts,
1856
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], `[${index}]`]
1857
+ })
1858
+ ),
1859
+ getType: () => SchemaType.LIST
1860
+ };
1861
+ return {
1862
+ ...maybeSkipValidation(baseSchema),
1863
+ ...getSchemaUtils(baseSchema)
1864
+ };
1865
+ }
1866
+ function validateAndTransformArray(value, transformItem) {
1867
+ if (!Array.isArray(value)) {
1868
+ return {
1869
+ ok: false,
1870
+ errors: [
1871
+ {
1872
+ message: getErrorMessageForIncorrectType(value, "list"),
1873
+ path: []
1874
+ }
1875
+ ]
1876
+ };
1877
+ }
1878
+ const maybeValidItems = value.map((item, index) => transformItem(item, index));
1879
+ return maybeValidItems.reduce(
1880
+ (acc, item) => {
1881
+ if (acc.ok && item.ok) {
1882
+ return {
1883
+ ok: true,
1884
+ value: [...acc.value, item.value]
1885
+ };
1886
+ }
1887
+ const errors = [];
1888
+ if (!acc.ok) {
1889
+ errors.push(...acc.errors);
1890
+ }
1891
+ if (!item.ok) {
1892
+ errors.push(...item.errors);
1893
+ }
1894
+ return {
1895
+ ok: false,
1896
+ errors
1897
+ };
1898
+ },
1899
+ { ok: true, value: [] }
1900
+ );
1901
+ }
1902
+
1903
+ // src/core/schemas/builders/literals/stringLiteral.ts
1904
+ function stringLiteral(literal) {
1905
+ const schemaCreator = createIdentitySchemaCreator(
1906
+ SchemaType.STRING_LITERAL,
1907
+ (value, { breadcrumbsPrefix = [] } = {}) => {
1908
+ if (value === literal) {
1909
+ return {
1910
+ ok: true,
1911
+ value: literal
1912
+ };
1913
+ } else {
1914
+ return {
1915
+ ok: false,
1916
+ errors: [
1917
+ {
1918
+ path: breadcrumbsPrefix,
1919
+ message: getErrorMessageForIncorrectType(value, `"${literal}"`)
1920
+ }
1921
+ ]
1922
+ };
1923
+ }
1924
+ }
1925
+ );
1926
+ return schemaCreator();
1927
+ }
1928
+
1929
+ // src/core/schemas/builders/literals/booleanLiteral.ts
1930
+ function booleanLiteral(literal) {
1931
+ const schemaCreator = createIdentitySchemaCreator(
1932
+ SchemaType.BOOLEAN_LITERAL,
1933
+ (value, { breadcrumbsPrefix = [] } = {}) => {
1934
+ if (value === literal) {
1935
+ return {
1936
+ ok: true,
1937
+ value: literal
1938
+ };
1939
+ } else {
1940
+ return {
1941
+ ok: false,
1942
+ errors: [
1943
+ {
1944
+ path: breadcrumbsPrefix,
1945
+ message: getErrorMessageForIncorrectType(value, `${literal.toString()}`)
1946
+ }
1947
+ ]
1948
+ };
1949
+ }
1950
+ }
1951
+ );
1952
+ return schemaCreator();
1953
+ }
1954
+
1955
+ // src/core/schemas/builders/primitives/any.ts
1956
+ var any = createIdentitySchemaCreator(SchemaType.ANY, (value) => ({ ok: true, value }));
1957
+
1958
+ // src/core/schemas/builders/primitives/boolean.ts
1959
+ var boolean = createIdentitySchemaCreator(
1960
+ SchemaType.BOOLEAN,
1961
+ (value, { breadcrumbsPrefix = [] } = {}) => {
1962
+ if (typeof value === "boolean") {
1963
+ return {
1964
+ ok: true,
1965
+ value
1966
+ };
1967
+ } else {
1968
+ return {
1969
+ ok: false,
1970
+ errors: [
1971
+ {
1972
+ path: breadcrumbsPrefix,
1973
+ message: getErrorMessageForIncorrectType(value, "boolean")
1974
+ }
1975
+ ]
1976
+ };
1977
+ }
1978
+ }
1979
+ );
1980
+
1981
+ // src/core/schemas/builders/primitives/number.ts
1982
+ var number = createIdentitySchemaCreator(
1983
+ SchemaType.NUMBER,
1984
+ (value, { breadcrumbsPrefix = [] } = {}) => {
1985
+ if (typeof value === "number") {
1986
+ return {
1987
+ ok: true,
1988
+ value
1989
+ };
1990
+ } else {
1991
+ return {
1992
+ ok: false,
1993
+ errors: [
1994
+ {
1995
+ path: breadcrumbsPrefix,
1996
+ message: getErrorMessageForIncorrectType(value, "number")
1997
+ }
1998
+ ]
1999
+ };
2000
+ }
2001
+ }
2002
+ );
2003
+
2004
+ // src/core/schemas/builders/primitives/string.ts
2005
+ var string = createIdentitySchemaCreator(
2006
+ SchemaType.STRING,
2007
+ (value, { breadcrumbsPrefix = [] } = {}) => {
2008
+ if (typeof value === "string") {
2009
+ return {
2010
+ ok: true,
2011
+ value
2012
+ };
2013
+ } else {
2014
+ return {
2015
+ ok: false,
2016
+ errors: [
2017
+ {
2018
+ path: breadcrumbsPrefix,
2019
+ message: getErrorMessageForIncorrectType(value, "string")
2020
+ }
2021
+ ]
2022
+ };
2023
+ }
2024
+ }
2025
+ );
2026
+
2027
+ // src/core/schemas/builders/primitives/unknown.ts
2028
+ var unknown = createIdentitySchemaCreator(SchemaType.UNKNOWN, (value) => ({ ok: true, value }));
2029
+
2030
+ // src/core/schemas/builders/record/record.ts
2031
+ function record(keySchema, valueSchema) {
2032
+ const baseSchema = {
2033
+ parse: (raw, opts) => {
2034
+ return validateAndTransformRecord({
2035
+ value: raw,
2036
+ isKeyNumeric: keySchema.getType() === SchemaType.NUMBER,
2037
+ transformKey: (key) => keySchema.parse(key, {
2038
+ ...opts,
2039
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], `${key} (key)`]
2040
+ }),
2041
+ transformValue: (value, key) => valueSchema.parse(value, {
2042
+ ...opts,
2043
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], `${key}`]
2044
+ }),
2045
+ breadcrumbsPrefix: opts == null ? void 0 : opts.breadcrumbsPrefix
2046
+ });
2047
+ },
2048
+ json: (parsed, opts) => {
2049
+ return validateAndTransformRecord({
2050
+ value: parsed,
2051
+ isKeyNumeric: keySchema.getType() === SchemaType.NUMBER,
2052
+ transformKey: (key) => keySchema.json(key, {
2053
+ ...opts,
2054
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], `${key} (key)`]
2055
+ }),
2056
+ transformValue: (value, key) => valueSchema.json(value, {
2057
+ ...opts,
2058
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], `${key}`]
2059
+ }),
2060
+ breadcrumbsPrefix: opts == null ? void 0 : opts.breadcrumbsPrefix
2061
+ });
2062
+ },
2063
+ getType: () => SchemaType.RECORD
2064
+ };
2065
+ return {
2066
+ ...maybeSkipValidation(baseSchema),
2067
+ ...getSchemaUtils(baseSchema)
2068
+ };
2069
+ }
2070
+ function validateAndTransformRecord({
2071
+ value,
2072
+ isKeyNumeric,
2073
+ transformKey,
2074
+ transformValue,
2075
+ breadcrumbsPrefix = []
2076
+ }) {
2077
+ if (!isPlainObject(value)) {
2078
+ return {
2079
+ ok: false,
2080
+ errors: [
2081
+ {
2082
+ path: breadcrumbsPrefix,
2083
+ message: getErrorMessageForIncorrectType(value, "object")
2084
+ }
2085
+ ]
2086
+ };
2087
+ }
2088
+ return entries(value).reduce(
2089
+ (accPromise, [stringKey, value2]) => {
2090
+ if (value2 === void 0) {
2091
+ return accPromise;
2092
+ }
2093
+ const acc = accPromise;
2094
+ let key = stringKey;
2095
+ if (isKeyNumeric) {
2096
+ const numberKey = stringKey.length > 0 ? Number(stringKey) : NaN;
2097
+ if (!isNaN(numberKey)) {
2098
+ key = numberKey;
2099
+ }
2100
+ }
2101
+ const transformedKey = transformKey(key);
2102
+ const transformedValue = transformValue(value2, key);
2103
+ if (acc.ok && transformedKey.ok && transformedValue.ok) {
2104
+ return {
2105
+ ok: true,
2106
+ value: {
2107
+ ...acc.value,
2108
+ [transformedKey.value]: transformedValue.value
2109
+ }
2110
+ };
2111
+ }
2112
+ const errors = [];
2113
+ if (!acc.ok) {
2114
+ errors.push(...acc.errors);
2115
+ }
2116
+ if (!transformedKey.ok) {
2117
+ errors.push(...transformedKey.errors);
2118
+ }
2119
+ if (!transformedValue.ok) {
2120
+ errors.push(...transformedValue.errors);
2121
+ }
2122
+ return {
2123
+ ok: false,
2124
+ errors
2125
+ };
2126
+ },
2127
+ { ok: true, value: {} }
2128
+ );
2129
+ }
2130
+
2131
+ // src/core/schemas/builders/set/set.ts
2132
+ function set(schema) {
2133
+ const listSchema = list(schema);
2134
+ const baseSchema = {
2135
+ parse: (raw, opts) => {
2136
+ const parsedList = listSchema.parse(raw, opts);
2137
+ if (parsedList.ok) {
2138
+ return {
2139
+ ok: true,
2140
+ value: new Set(parsedList.value)
2141
+ };
2142
+ } else {
2143
+ return parsedList;
2144
+ }
2145
+ },
2146
+ json: (parsed, opts) => {
2147
+ if (!(parsed instanceof Set)) {
2148
+ return {
2149
+ ok: false,
2150
+ errors: [
2151
+ {
2152
+ path: (opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [],
2153
+ message: getErrorMessageForIncorrectType(parsed, "Set")
2154
+ }
2155
+ ]
2156
+ };
2157
+ }
2158
+ const jsonList = listSchema.json([...parsed], opts);
2159
+ return jsonList;
2160
+ },
2161
+ getType: () => SchemaType.SET
2162
+ };
2163
+ return {
2164
+ ...maybeSkipValidation(baseSchema),
2165
+ ...getSchemaUtils(baseSchema)
2166
+ };
2167
+ }
2168
+
2169
+ // src/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.ts
2170
+ function undiscriminatedUnion(schemas) {
2171
+ const baseSchema = {
2172
+ parse: (raw, opts) => {
2173
+ return validateAndTransformUndiscriminatedUnion(
2174
+ (schema, opts2) => schema.parse(raw, opts2),
2175
+ schemas,
2176
+ opts
2177
+ );
2178
+ },
2179
+ json: (parsed, opts) => {
2180
+ return validateAndTransformUndiscriminatedUnion(
2181
+ (schema, opts2) => schema.json(parsed, opts2),
2182
+ schemas,
2183
+ opts
2184
+ );
2185
+ },
2186
+ getType: () => SchemaType.UNDISCRIMINATED_UNION
2187
+ };
2188
+ return {
2189
+ ...maybeSkipValidation(baseSchema),
2190
+ ...getSchemaUtils(baseSchema)
2191
+ };
2192
+ }
2193
+ function validateAndTransformUndiscriminatedUnion(transform2, schemas, opts) {
2194
+ const errors = [];
2195
+ for (const [index, schema] of schemas.entries()) {
2196
+ const transformed = transform2(schema, { ...opts, skipValidation: false });
2197
+ if (transformed.ok) {
2198
+ return transformed;
2199
+ } else {
2200
+ for (const error of transformed.errors) {
2201
+ errors.push({
2202
+ path: error.path,
2203
+ message: `[Variant ${index}] ${error.message}`
2204
+ });
2205
+ }
2206
+ }
2207
+ }
2208
+ return {
2209
+ ok: false,
2210
+ errors
2211
+ };
2212
+ }
2213
+
2214
+ // src/core/schemas/builders/union/discriminant.ts
2215
+ function discriminant(parsedDiscriminant, rawDiscriminant) {
2216
+ return {
2217
+ parsedDiscriminant,
2218
+ rawDiscriminant
2219
+ };
2220
+ }
2221
+
2222
+ // src/core/schemas/builders/union/union.ts
2223
+ function union(discriminant2, union2) {
2224
+ const rawDiscriminant = typeof discriminant2 === "string" ? discriminant2 : discriminant2.rawDiscriminant;
2225
+ const parsedDiscriminant = typeof discriminant2 === "string" ? discriminant2 : discriminant2.parsedDiscriminant;
2226
+ const discriminantValueSchema = enum_(keys(union2));
2227
+ const baseSchema = {
2228
+ parse: (raw, opts) => {
2229
+ return transformAndValidateUnion({
2230
+ value: raw,
2231
+ discriminant: rawDiscriminant,
2232
+ transformedDiscriminant: parsedDiscriminant,
2233
+ transformDiscriminantValue: (discriminantValue) => discriminantValueSchema.parse(discriminantValue, {
2234
+ allowUnrecognizedEnumValues: opts == null ? void 0 : opts.allowUnrecognizedUnionMembers,
2235
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], rawDiscriminant]
2236
+ }),
2237
+ getAdditionalPropertiesSchema: (discriminantValue) => union2[discriminantValue],
2238
+ allowUnrecognizedUnionMembers: opts == null ? void 0 : opts.allowUnrecognizedUnionMembers,
2239
+ transformAdditionalProperties: (additionalProperties, additionalPropertiesSchema) => additionalPropertiesSchema.parse(additionalProperties, opts),
2240
+ breadcrumbsPrefix: opts == null ? void 0 : opts.breadcrumbsPrefix
2241
+ });
2242
+ },
2243
+ json: (parsed, opts) => {
2244
+ return transformAndValidateUnion({
2245
+ value: parsed,
2246
+ discriminant: parsedDiscriminant,
2247
+ transformedDiscriminant: rawDiscriminant,
2248
+ transformDiscriminantValue: (discriminantValue) => discriminantValueSchema.json(discriminantValue, {
2249
+ allowUnrecognizedEnumValues: opts == null ? void 0 : opts.allowUnrecognizedUnionMembers,
2250
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], parsedDiscriminant]
2251
+ }),
2252
+ getAdditionalPropertiesSchema: (discriminantValue) => union2[discriminantValue],
2253
+ allowUnrecognizedUnionMembers: opts == null ? void 0 : opts.allowUnrecognizedUnionMembers,
2254
+ transformAdditionalProperties: (additionalProperties, additionalPropertiesSchema) => additionalPropertiesSchema.json(additionalProperties, opts),
2255
+ breadcrumbsPrefix: opts == null ? void 0 : opts.breadcrumbsPrefix
2256
+ });
2257
+ },
2258
+ getType: () => SchemaType.UNION
2259
+ };
2260
+ return {
2261
+ ...maybeSkipValidation(baseSchema),
2262
+ ...getSchemaUtils(baseSchema),
2263
+ ...getObjectLikeUtils(baseSchema)
2264
+ };
2265
+ }
2266
+ function transformAndValidateUnion({
2267
+ value,
2268
+ discriminant: discriminant2,
2269
+ transformedDiscriminant,
2270
+ transformDiscriminantValue,
2271
+ getAdditionalPropertiesSchema,
2272
+ allowUnrecognizedUnionMembers = false,
2273
+ transformAdditionalProperties,
2274
+ breadcrumbsPrefix = []
2275
+ }) {
2276
+ if (!isPlainObject(value)) {
2277
+ return {
2278
+ ok: false,
2279
+ errors: [
2280
+ {
2281
+ path: breadcrumbsPrefix,
2282
+ message: getErrorMessageForIncorrectType(value, "object")
2283
+ }
2284
+ ]
2285
+ };
2286
+ }
2287
+ const { [discriminant2]: discriminantValue, ...additionalProperties } = value;
2288
+ if (discriminantValue == null) {
2289
+ return {
2290
+ ok: false,
2291
+ errors: [
2292
+ {
2293
+ path: breadcrumbsPrefix,
2294
+ message: `Missing discriminant ("${discriminant2}")`
2295
+ }
2296
+ ]
2297
+ };
2298
+ }
2299
+ const transformedDiscriminantValue = transformDiscriminantValue(discriminantValue);
2300
+ if (!transformedDiscriminantValue.ok) {
2301
+ return {
2302
+ ok: false,
2303
+ errors: transformedDiscriminantValue.errors
2304
+ };
2305
+ }
2306
+ const additionalPropertiesSchema = getAdditionalPropertiesSchema(transformedDiscriminantValue.value);
2307
+ if (additionalPropertiesSchema == null) {
2308
+ if (allowUnrecognizedUnionMembers) {
2309
+ return {
2310
+ ok: true,
2311
+ value: {
2312
+ [transformedDiscriminant]: transformedDiscriminantValue.value,
2313
+ ...additionalProperties
2314
+ }
2315
+ };
2316
+ } else {
2317
+ return {
2318
+ ok: false,
2319
+ errors: [
2320
+ {
2321
+ path: [...breadcrumbsPrefix, discriminant2],
2322
+ message: "Unexpected discriminant value"
2323
+ }
2324
+ ]
2325
+ };
2326
+ }
2327
+ }
2328
+ const transformedAdditionalProperties = transformAdditionalProperties(
2329
+ additionalProperties,
2330
+ additionalPropertiesSchema
2331
+ );
2332
+ if (!transformedAdditionalProperties.ok) {
2333
+ return transformedAdditionalProperties;
2334
+ }
2335
+ return {
2336
+ ok: true,
2337
+ value: {
2338
+ [transformedDiscriminant]: discriminantValue,
2339
+ ...transformedAdditionalProperties.value
2340
+ }
2341
+ };
2342
+ }
2343
+
2344
+ // src/serialization/index.ts
2345
+ var serialization_exports = {};
2346
+ __export(serialization_exports, {
2347
+ Actor: () => Actor,
2348
+ ActorName: () => ActorName,
2349
+ ActorsCreateRequest: () => ActorsCreateRequest,
2350
+ ActorsCreateResponse: () => ActorsCreateResponse,
2351
+ ActorsDeleteResponse: () => ActorsDeleteResponse,
2352
+ ActorsGetOrCreateRequest: () => ActorsGetOrCreateRequest,
2353
+ ActorsGetOrCreateResponse: () => ActorsGetOrCreateResponse,
2354
+ ActorsKvGetResponse: () => ActorsKvGetResponse,
2355
+ ActorsListNamesResponse: () => ActorsListNamesResponse,
2356
+ ActorsListResponse: () => ActorsListResponse,
2357
+ CrashPolicy: () => CrashPolicy2,
2358
+ Datacenter: () => Datacenter,
2359
+ DatacenterHealth: () => DatacenterHealth,
2360
+ DatacentersListResponse: () => DatacentersListResponse,
2361
+ HealthFanoutResponse: () => HealthFanoutResponse,
2362
+ HealthResponse: () => HealthResponse,
2363
+ HealthStatus: () => HealthStatus2,
2364
+ MetadataGetResponse: () => MetadataGetResponse,
2365
+ Namespace: () => Namespace,
2366
+ NamespaceListResponse: () => NamespaceListResponse,
2367
+ NamespacesCreateRequest: () => NamespacesCreateRequest,
2368
+ NamespacesCreateResponse: () => NamespacesCreateResponse,
2369
+ Pagination: () => Pagination,
2370
+ RivetId: () => RivetId,
2371
+ Runner: () => Runner,
2372
+ RunnerConfig: () => RunnerConfig,
2373
+ RunnerConfigKind: () => RunnerConfigKind,
2374
+ RunnerConfigKindNormal: () => RunnerConfigKindNormal,
2375
+ RunnerConfigKindServerless: () => RunnerConfigKindServerless,
2376
+ RunnerConfigKindServerlessServerless: () => RunnerConfigKindServerlessServerless,
2377
+ RunnerConfigResponse: () => RunnerConfigResponse,
2378
+ RunnerConfigServerless: () => RunnerConfigServerless,
2379
+ RunnerConfigVariant: () => RunnerConfigVariant2,
2380
+ RunnerConfigsDeleteResponse: () => RunnerConfigsDeleteResponse,
2381
+ RunnerConfigsListResponse: () => RunnerConfigsListResponse,
2382
+ RunnerConfigsListResponseRunnerConfigsValue: () => RunnerConfigsListResponseRunnerConfigsValue,
2383
+ RunnerConfigsRefreshMetadataRequestBody: () => RunnerConfigsRefreshMetadataRequestBody,
2384
+ RunnerConfigsRefreshMetadataResponse: () => RunnerConfigsRefreshMetadataResponse,
2385
+ RunnerConfigsServerlessHealthCheckRequest: () => RunnerConfigsServerlessHealthCheckRequest,
2386
+ RunnerConfigsServerlessHealthCheckResponse: () => RunnerConfigsServerlessHealthCheckResponse,
2387
+ RunnerConfigsServerlessHealthCheckResponseFailure: () => RunnerConfigsServerlessHealthCheckResponseFailure,
2388
+ RunnerConfigsServerlessHealthCheckResponseFailureFailure: () => RunnerConfigsServerlessHealthCheckResponseFailureFailure,
2389
+ RunnerConfigsServerlessHealthCheckResponseSuccess: () => RunnerConfigsServerlessHealthCheckResponseSuccess,
2390
+ RunnerConfigsServerlessHealthCheckResponseSuccessSuccess: () => RunnerConfigsServerlessHealthCheckResponseSuccessSuccess,
2391
+ RunnerConfigsServerlessMetadataError: () => RunnerConfigsServerlessMetadataError,
2392
+ RunnerConfigsServerlessMetadataErrorInvalidRequest: () => RunnerConfigsServerlessMetadataErrorInvalidRequest,
2393
+ RunnerConfigsServerlessMetadataErrorInvalidResponseJson: () => RunnerConfigsServerlessMetadataErrorInvalidResponseJson,
2394
+ RunnerConfigsServerlessMetadataErrorInvalidResponseJsonInvalidResponseJson: () => RunnerConfigsServerlessMetadataErrorInvalidResponseJsonInvalidResponseJson,
2395
+ RunnerConfigsServerlessMetadataErrorInvalidResponseSchema: () => RunnerConfigsServerlessMetadataErrorInvalidResponseSchema,
2396
+ RunnerConfigsServerlessMetadataErrorInvalidResponseSchemaInvalidResponseSchema: () => RunnerConfigsServerlessMetadataErrorInvalidResponseSchemaInvalidResponseSchema,
2397
+ RunnerConfigsServerlessMetadataErrorNonSuccessStatus: () => RunnerConfigsServerlessMetadataErrorNonSuccessStatus,
2398
+ RunnerConfigsServerlessMetadataErrorNonSuccessStatusNonSuccessStatus: () => RunnerConfigsServerlessMetadataErrorNonSuccessStatusNonSuccessStatus,
2399
+ RunnerConfigsServerlessMetadataErrorRequestFailed: () => RunnerConfigsServerlessMetadataErrorRequestFailed,
2400
+ RunnerConfigsServerlessMetadataErrorRequestTimedOut: () => RunnerConfigsServerlessMetadataErrorRequestTimedOut,
2401
+ RunnerConfigsUpsertRequestBody: () => RunnerConfigsUpsertRequestBody,
2402
+ RunnerConfigsUpsertResponse: () => RunnerConfigsUpsertResponse,
2403
+ RunnersListNamesResponse: () => RunnersListNamesResponse,
2404
+ RunnersListResponse: () => RunnersListResponse,
2405
+ namespaces: () => namespaces_exports2
2406
+ });
2407
+
2408
+ // src/serialization/types/RivetId.ts
2409
+ var RivetId = schemas_exports.string();
2410
+
2411
+ // src/serialization/types/CrashPolicy.ts
2412
+ var CrashPolicy2 = schemas_exports.enum_(["restart", "sleep", "destroy"]);
2413
+
2414
+ // src/serialization/types/Actor.ts
2415
+ var Actor = schemas_exports.object({
2416
+ actorId: schemas_exports.property("actor_id", RivetId),
2417
+ connectableTs: schemas_exports.property("connectable_ts", schemas_exports.number().optional()),
2418
+ crashPolicy: schemas_exports.property("crash_policy", CrashPolicy2),
2419
+ createTs: schemas_exports.property("create_ts", schemas_exports.number()),
2420
+ datacenter: schemas_exports.string(),
2421
+ destroyTs: schemas_exports.property("destroy_ts", schemas_exports.number().optional()),
2422
+ error: schemas_exports.record(schemas_exports.string(), schemas_exports.unknown()).optional(),
2423
+ key: schemas_exports.string().optional(),
2424
+ name: schemas_exports.string(),
2425
+ namespaceId: schemas_exports.property("namespace_id", RivetId),
2426
+ pendingAllocationTs: schemas_exports.property("pending_allocation_ts", schemas_exports.number().optional()),
2427
+ rescheduleTs: schemas_exports.property("reschedule_ts", schemas_exports.number().optional()),
2428
+ runnerNameSelector: schemas_exports.property("runner_name_selector", schemas_exports.string()),
2429
+ sleepTs: schemas_exports.property("sleep_ts", schemas_exports.number().optional()),
2430
+ startTs: schemas_exports.property("start_ts", schemas_exports.number().optional())
2431
+ });
2432
+
2433
+ // src/serialization/types/ActorName.ts
2434
+ var ActorName = schemas_exports.object({
2435
+ metadata: schemas_exports.record(schemas_exports.string(), schemas_exports.unknown())
2436
+ });
2437
+
2438
+ // src/serialization/types/ActorsCreateResponse.ts
2439
+ var ActorsCreateResponse = schemas_exports.object({
2440
+ actor: Actor
2441
+ });
2442
+
2443
+ // src/serialization/types/ActorsDeleteResponse.ts
2444
+ var ActorsDeleteResponse = schemas_exports.record(schemas_exports.string(), schemas_exports.unknown());
2445
+
2446
+ // src/serialization/types/ActorsGetOrCreateResponse.ts
2447
+ var ActorsGetOrCreateResponse = schemas_exports.object({
2448
+ actor: Actor,
2449
+ created: schemas_exports.boolean()
2450
+ });
2451
+
2452
+ // src/serialization/types/ActorsKvGetResponse.ts
2453
+ var ActorsKvGetResponse = schemas_exports.object({
2454
+ updateTs: schemas_exports.property("update_ts", schemas_exports.number()),
2455
+ value: schemas_exports.string()
2456
+ });
2457
+
2458
+ // src/serialization/types/Pagination.ts
2459
+ var Pagination = schemas_exports.object({
2460
+ cursor: schemas_exports.string().optional()
2461
+ });
2462
+
2463
+ // src/serialization/types/ActorsListNamesResponse.ts
2464
+ var ActorsListNamesResponse = schemas_exports.object({
2465
+ names: schemas_exports.record(schemas_exports.string(), ActorName),
2466
+ pagination: Pagination
2467
+ });
2468
+
2469
+ // src/serialization/types/ActorsListResponse.ts
2470
+ var ActorsListResponse = schemas_exports.object({
2471
+ actors: schemas_exports.list(Actor),
2472
+ pagination: Pagination
2473
+ });
2474
+
2475
+ // src/serialization/types/Datacenter.ts
2476
+ var Datacenter = schemas_exports.object({
2477
+ label: schemas_exports.number(),
2478
+ name: schemas_exports.string(),
2479
+ url: schemas_exports.string()
2480
+ });
2481
+
2482
+ // src/serialization/types/HealthResponse.ts
2483
+ var HealthResponse = schemas_exports.object({
2484
+ runtime: schemas_exports.string(),
2485
+ status: schemas_exports.string(),
2486
+ version: schemas_exports.string()
2487
+ });
2488
+
2489
+ // src/serialization/types/HealthStatus.ts
2490
+ var HealthStatus2 = schemas_exports.enum_(["ok", "error"]);
2491
+
2492
+ // src/serialization/types/DatacenterHealth.ts
2493
+ var DatacenterHealth = schemas_exports.object({
2494
+ datacenterLabel: schemas_exports.property("datacenter_label", schemas_exports.number()),
2495
+ datacenterName: schemas_exports.property("datacenter_name", schemas_exports.string()),
2496
+ error: schemas_exports.string().optional(),
2497
+ response: HealthResponse.optional(),
2498
+ rttMs: schemas_exports.property("rtt_ms", schemas_exports.number().optional()),
2499
+ status: HealthStatus2
2500
+ });
2501
+
2502
+ // src/serialization/types/DatacentersListResponse.ts
2503
+ var DatacentersListResponse = schemas_exports.object({
2504
+ datacenters: schemas_exports.list(Datacenter),
2505
+ pagination: Pagination
2506
+ });
2507
+
2508
+ // src/serialization/types/HealthFanoutResponse.ts
2509
+ var HealthFanoutResponse = schemas_exports.object({
2510
+ datacenters: schemas_exports.list(DatacenterHealth)
2511
+ });
2512
+
2513
+ // src/serialization/types/MetadataGetResponse.ts
2514
+ var MetadataGetResponse = schemas_exports.object({
2515
+ buildTimestamp: schemas_exports.property("build_timestamp", schemas_exports.string()),
2516
+ cargoProfile: schemas_exports.property("cargo_profile", schemas_exports.string()),
2517
+ cargoTarget: schemas_exports.property("cargo_target", schemas_exports.string()),
2518
+ gitSha: schemas_exports.property("git_sha", schemas_exports.string()),
2519
+ runtime: schemas_exports.string(),
2520
+ rustcHost: schemas_exports.property("rustc_host", schemas_exports.string()),
2521
+ rustcVersion: schemas_exports.property("rustc_version", schemas_exports.string()),
2522
+ version: schemas_exports.string()
2523
+ });
2524
+
2525
+ // src/serialization/types/Namespace.ts
2526
+ var Namespace = schemas_exports.object({
2527
+ createTs: schemas_exports.property("create_ts", schemas_exports.number()),
2528
+ displayName: schemas_exports.property("display_name", schemas_exports.string()),
2529
+ name: schemas_exports.string(),
2530
+ namespaceId: schemas_exports.property("namespace_id", RivetId)
2531
+ });
2532
+
2533
+ // src/serialization/types/NamespaceListResponse.ts
2534
+ var NamespaceListResponse = schemas_exports.object({
2535
+ namespaces: schemas_exports.list(Namespace),
2536
+ pagination: Pagination
2537
+ });
2538
+
2539
+ // src/serialization/types/NamespacesCreateResponse.ts
2540
+ var NamespacesCreateResponse = schemas_exports.object({
2541
+ namespace: Namespace
2542
+ });
2543
+
2544
+ // src/serialization/types/Runner.ts
2545
+ var Runner = schemas_exports.object({
2546
+ createTs: schemas_exports.property("create_ts", schemas_exports.number()),
2547
+ datacenter: schemas_exports.string(),
2548
+ drainTs: schemas_exports.property("drain_ts", schemas_exports.number().optional()),
2549
+ key: schemas_exports.string(),
2550
+ lastConnectedTs: schemas_exports.property("last_connected_ts", schemas_exports.number().optional()),
2551
+ lastPingTs: schemas_exports.property("last_ping_ts", schemas_exports.number()),
2552
+ lastRtt: schemas_exports.property("last_rtt", schemas_exports.number()),
2553
+ metadata: schemas_exports.record(schemas_exports.string(), schemas_exports.unknown()).optional(),
2554
+ name: schemas_exports.string(),
2555
+ namespaceId: schemas_exports.property("namespace_id", RivetId),
2556
+ remainingSlots: schemas_exports.property("remaining_slots", schemas_exports.number()),
2557
+ runnerId: schemas_exports.property("runner_id", RivetId),
2558
+ stopTs: schemas_exports.property("stop_ts", schemas_exports.number().optional()),
2559
+ totalSlots: schemas_exports.property("total_slots", schemas_exports.number()),
2560
+ version: schemas_exports.number()
2561
+ });
2562
+
2563
+ // src/serialization/types/RunnerConfigServerless.ts
2564
+ var RunnerConfigServerless = schemas_exports.object({
2565
+ headers: schemas_exports.record(schemas_exports.string(), schemas_exports.string()).optional(),
2566
+ maxRunners: schemas_exports.property("max_runners", schemas_exports.number()),
2567
+ minRunners: schemas_exports.property("min_runners", schemas_exports.number().optional()),
2568
+ requestLifespan: schemas_exports.property("request_lifespan", schemas_exports.number()),
2569
+ runnersMargin: schemas_exports.property("runners_margin", schemas_exports.number().optional()),
2570
+ slotsPerRunner: schemas_exports.property("slots_per_runner", schemas_exports.number()),
2571
+ url: schemas_exports.string()
2572
+ });
2573
+
2574
+ // src/serialization/types/RunnerConfig.ts
2575
+ var RunnerConfig = schemas_exports.object({
2576
+ normal: schemas_exports.record(schemas_exports.string(), schemas_exports.unknown()).optional(),
2577
+ serverless: RunnerConfigServerless.optional(),
2578
+ drainOnVersionUpgrade: schemas_exports.property(
2579
+ "drain_on_version_upgrade",
2580
+ schemas_exports.boolean().optional()
2581
+ ),
2582
+ metadata: schemas_exports.unknown().optional()
2583
+ });
2584
+
2585
+ // src/serialization/types/RunnerConfigKindNormal.ts
2586
+ var RunnerConfigKindNormal = schemas_exports.object({
2587
+ normal: schemas_exports.record(schemas_exports.string(), schemas_exports.unknown())
2588
+ });
2589
+
2590
+ // src/serialization/types/RunnerConfigKindServerlessServerless.ts
2591
+ var RunnerConfigKindServerlessServerless = schemas_exports.object({
2592
+ headers: schemas_exports.record(schemas_exports.string(), schemas_exports.string()).optional(),
2593
+ maxRunners: schemas_exports.property("max_runners", schemas_exports.number()),
2594
+ minRunners: schemas_exports.property("min_runners", schemas_exports.number().optional()),
2595
+ requestLifespan: schemas_exports.property("request_lifespan", schemas_exports.number()),
2596
+ runnersMargin: schemas_exports.property("runners_margin", schemas_exports.number().optional()),
2597
+ slotsPerRunner: schemas_exports.property("slots_per_runner", schemas_exports.number()),
2598
+ url: schemas_exports.string()
2599
+ });
2600
+
2601
+ // src/serialization/types/RunnerConfigKindServerless.ts
2602
+ var RunnerConfigKindServerless = schemas_exports.object({
2603
+ serverless: RunnerConfigKindServerlessServerless
2604
+ });
2605
+
2606
+ // src/serialization/types/RunnerConfigKind.ts
2607
+ var RunnerConfigKind = schemas_exports.undiscriminatedUnion([RunnerConfigKindNormal, RunnerConfigKindServerless]);
2608
+
2609
+ // src/serialization/types/RunnerConfigResponse.ts
2610
+ var RunnerConfigResponse = schemas_exports.object({
2611
+ runnerPoolError: schemas_exports.property(
2612
+ "runner_pool_error",
2613
+ schemas_exports.record(schemas_exports.string(), schemas_exports.unknown()).optional()
2614
+ )
2615
+ }).extend(RunnerConfig);
2616
+
2617
+ // src/serialization/types/RunnerConfigVariant.ts
2618
+ var RunnerConfigVariant2 = schemas_exports.enum_(["serverless", "normal"]);
2619
+
2620
+ // src/serialization/types/RunnerConfigsDeleteResponse.ts
2621
+ var RunnerConfigsDeleteResponse = schemas_exports.record(schemas_exports.string(), schemas_exports.unknown());
2622
+
2623
+ // src/serialization/types/RunnerConfigsListResponseRunnerConfigsValue.ts
2624
+ var RunnerConfigsListResponseRunnerConfigsValue = schemas_exports.object({
2625
+ datacenters: schemas_exports.record(schemas_exports.string(), RunnerConfigResponse)
2626
+ });
2627
+
2628
+ // src/serialization/types/RunnerConfigsListResponse.ts
2629
+ var RunnerConfigsListResponse = schemas_exports.object({
2630
+ pagination: Pagination,
2631
+ runnerConfigs: schemas_exports.property(
2632
+ "runner_configs",
2633
+ schemas_exports.record(schemas_exports.string(), RunnerConfigsListResponseRunnerConfigsValue)
2634
+ )
2635
+ });
2636
+
2637
+ // src/serialization/types/RunnerConfigsRefreshMetadataRequestBody.ts
2638
+ var RunnerConfigsRefreshMetadataRequestBody = schemas_exports.record(schemas_exports.string(), schemas_exports.unknown());
2639
+
2640
+ // src/serialization/types/RunnerConfigsRefreshMetadataResponse.ts
2641
+ var RunnerConfigsRefreshMetadataResponse = schemas_exports.record(schemas_exports.string(), schemas_exports.unknown());
2642
+
2643
+ // src/serialization/types/RunnerConfigsServerlessHealthCheckResponseSuccessSuccess.ts
2644
+ var RunnerConfigsServerlessHealthCheckResponseSuccessSuccess = schemas_exports.object({
2645
+ version: schemas_exports.string()
2646
+ });
2647
+
2648
+ // src/serialization/types/RunnerConfigsServerlessHealthCheckResponseSuccess.ts
2649
+ var RunnerConfigsServerlessHealthCheckResponseSuccess = schemas_exports.object({
2650
+ success: RunnerConfigsServerlessHealthCheckResponseSuccessSuccess
2651
+ });
2652
+
2653
+ // src/serialization/types/RunnerConfigsServerlessMetadataErrorInvalidRequest.ts
2654
+ var RunnerConfigsServerlessMetadataErrorInvalidRequest = schemas_exports.object({
2655
+ invalidRequest: schemas_exports.property(
2656
+ "invalid_request",
2657
+ schemas_exports.record(schemas_exports.string(), schemas_exports.unknown())
2658
+ )
2659
+ });
2660
+
2661
+ // src/serialization/types/RunnerConfigsServerlessMetadataErrorRequestFailed.ts
2662
+ var RunnerConfigsServerlessMetadataErrorRequestFailed = schemas_exports.object({
2663
+ requestFailed: schemas_exports.property(
2664
+ "request_failed",
2665
+ schemas_exports.record(schemas_exports.string(), schemas_exports.unknown())
2666
+ )
2667
+ });
2668
+
2669
+ // src/serialization/types/RunnerConfigsServerlessMetadataErrorRequestTimedOut.ts
2670
+ var RunnerConfigsServerlessMetadataErrorRequestTimedOut = schemas_exports.object({
2671
+ requestTimedOut: schemas_exports.property(
2672
+ "request_timed_out",
2673
+ schemas_exports.record(schemas_exports.string(), schemas_exports.unknown())
2674
+ )
2675
+ });
2676
+
2677
+ // src/serialization/types/RunnerConfigsServerlessMetadataErrorNonSuccessStatusNonSuccessStatus.ts
2678
+ var RunnerConfigsServerlessMetadataErrorNonSuccessStatusNonSuccessStatus = schemas_exports.object({
2679
+ body: schemas_exports.string(),
2680
+ statusCode: schemas_exports.property("status_code", schemas_exports.number())
2681
+ });
2682
+
2683
+ // src/serialization/types/RunnerConfigsServerlessMetadataErrorNonSuccessStatus.ts
2684
+ var RunnerConfigsServerlessMetadataErrorNonSuccessStatus = schemas_exports.object({
2685
+ nonSuccessStatus: schemas_exports.property(
2686
+ "non_success_status",
2687
+ RunnerConfigsServerlessMetadataErrorNonSuccessStatusNonSuccessStatus
2688
+ )
2689
+ });
2690
+
2691
+ // src/serialization/types/RunnerConfigsServerlessMetadataErrorInvalidResponseJsonInvalidResponseJson.ts
2692
+ var RunnerConfigsServerlessMetadataErrorInvalidResponseJsonInvalidResponseJson = schemas_exports.object({
2693
+ body: schemas_exports.string()
2694
+ });
2695
+
2696
+ // src/serialization/types/RunnerConfigsServerlessMetadataErrorInvalidResponseJson.ts
2697
+ var RunnerConfigsServerlessMetadataErrorInvalidResponseJson = schemas_exports.object({
2698
+ invalidResponseJson: schemas_exports.property(
2699
+ "invalid_response_json",
2700
+ RunnerConfigsServerlessMetadataErrorInvalidResponseJsonInvalidResponseJson
2701
+ )
2702
+ });
2703
+
2704
+ // src/serialization/types/RunnerConfigsServerlessMetadataErrorInvalidResponseSchemaInvalidResponseSchema.ts
2705
+ var RunnerConfigsServerlessMetadataErrorInvalidResponseSchemaInvalidResponseSchema = schemas_exports.object({
2706
+ runtime: schemas_exports.string(),
2707
+ version: schemas_exports.string()
2708
+ });
2709
+
2710
+ // src/serialization/types/RunnerConfigsServerlessMetadataErrorInvalidResponseSchema.ts
2711
+ var RunnerConfigsServerlessMetadataErrorInvalidResponseSchema = schemas_exports.object({
2712
+ invalidResponseSchema: schemas_exports.property(
2713
+ "invalid_response_schema",
2714
+ RunnerConfigsServerlessMetadataErrorInvalidResponseSchemaInvalidResponseSchema
2715
+ )
2716
+ });
2717
+
2718
+ // src/serialization/types/RunnerConfigsServerlessMetadataError.ts
2719
+ var RunnerConfigsServerlessMetadataError = schemas_exports.undiscriminatedUnion([
2720
+ RunnerConfigsServerlessMetadataErrorInvalidRequest,
2721
+ RunnerConfigsServerlessMetadataErrorRequestFailed,
2722
+ RunnerConfigsServerlessMetadataErrorRequestTimedOut,
2723
+ RunnerConfigsServerlessMetadataErrorNonSuccessStatus,
2724
+ RunnerConfigsServerlessMetadataErrorInvalidResponseJson,
2725
+ RunnerConfigsServerlessMetadataErrorInvalidResponseSchema
2726
+ ]);
2727
+
2728
+ // src/serialization/types/RunnerConfigsServerlessHealthCheckResponseFailureFailure.ts
2729
+ var RunnerConfigsServerlessHealthCheckResponseFailureFailure = schemas_exports.object({
2730
+ error: RunnerConfigsServerlessMetadataError
2731
+ });
2732
+
2733
+ // src/serialization/types/RunnerConfigsServerlessHealthCheckResponseFailure.ts
2734
+ var RunnerConfigsServerlessHealthCheckResponseFailure = schemas_exports.object({
2735
+ failure: RunnerConfigsServerlessHealthCheckResponseFailureFailure
2736
+ });
2737
+
2738
+ // src/serialization/types/RunnerConfigsServerlessHealthCheckResponse.ts
2739
+ var RunnerConfigsServerlessHealthCheckResponse = schemas_exports.undiscriminatedUnion([
2740
+ RunnerConfigsServerlessHealthCheckResponseSuccess,
2741
+ RunnerConfigsServerlessHealthCheckResponseFailure
2742
+ ]);
2743
+
2744
+ // src/serialization/types/RunnerConfigsUpsertResponse.ts
2745
+ var RunnerConfigsUpsertResponse = schemas_exports.object({
2746
+ endpointConfigChanged: schemas_exports.property("endpoint_config_changed", schemas_exports.boolean())
2747
+ });
2748
+
2749
+ // src/serialization/types/RunnersListNamesResponse.ts
2750
+ var RunnersListNamesResponse = schemas_exports.object({
2751
+ names: schemas_exports.list(schemas_exports.string()),
2752
+ pagination: Pagination
2753
+ });
2754
+
2755
+ // src/serialization/types/RunnersListResponse.ts
2756
+ var RunnersListResponse = schemas_exports.object({
2757
+ pagination: Pagination,
2758
+ runners: schemas_exports.list(Runner)
2759
+ });
2760
+
2761
+ // src/serialization/client/requests/ActorsCreateRequest.ts
2762
+ var ActorsCreateRequest = schemas_exports.object({
2763
+ crashPolicy: schemas_exports.property("crash_policy", CrashPolicy2),
2764
+ datacenter: schemas_exports.string().optional(),
2765
+ input: schemas_exports.string().optional(),
2766
+ key: schemas_exports.string().optional(),
2767
+ name: schemas_exports.string(),
2768
+ runnerNameSelector: schemas_exports.property("runner_name_selector", schemas_exports.string())
2769
+ });
2770
+
2771
+ // src/serialization/client/requests/ActorsGetOrCreateRequest.ts
2772
+ var ActorsGetOrCreateRequest = schemas_exports.object({
2773
+ crashPolicy: schemas_exports.property("crash_policy", CrashPolicy2),
2774
+ datacenter: schemas_exports.string().optional(),
2775
+ input: schemas_exports.string().optional(),
2776
+ key: schemas_exports.string(),
2777
+ name: schemas_exports.string(),
2778
+ runnerNameSelector: schemas_exports.property("runner_name_selector", schemas_exports.string())
2779
+ });
2780
+
2781
+ // src/serialization/client/requests/RunnerConfigsServerlessHealthCheckRequest.ts
2782
+ var RunnerConfigsServerlessHealthCheckRequest = schemas_exports.object({
2783
+ headers: schemas_exports.record(schemas_exports.string(), schemas_exports.string()).optional(),
2784
+ url: schemas_exports.string()
2785
+ });
2786
+
2787
+ // src/serialization/client/requests/RunnerConfigsUpsertRequestBody.ts
2788
+ var RunnerConfigsUpsertRequestBody = schemas_exports.object({
2789
+ datacenters: schemas_exports.record(schemas_exports.string(), RunnerConfig)
2790
+ });
2791
+
2792
+ // src/serialization/resources/namespaces/index.ts
2793
+ var namespaces_exports2 = {};
2794
+ __export(namespaces_exports2, {
2795
+ NamespacesCreateRequest: () => NamespacesCreateRequest
2796
+ });
2797
+
2798
+ // src/serialization/resources/namespaces/client/requests/NamespacesCreateRequest.ts
2799
+ var NamespacesCreateRequest = schemas_exports.object({
2800
+ displayName: schemas_exports.property("display_name", schemas_exports.string()),
2801
+ name: schemas_exports.string()
2802
+ });
2803
+
2804
+ // src/Client.ts
2805
+ var import_url_join6 = __toESM(require("url-join"));
2806
+
2807
+ // src/errors/RivetError.ts
2808
+ var RivetError = class _RivetError extends Error {
2809
+ statusCode;
2810
+ body;
2811
+ constructor({ message, statusCode, body }) {
2812
+ super(buildMessage({ message, statusCode, body }));
2813
+ Object.setPrototypeOf(this, _RivetError.prototype);
2814
+ if (statusCode != null) {
2815
+ this.statusCode = statusCode;
2816
+ }
2817
+ if (body !== void 0) {
2818
+ this.body = body;
2819
+ }
2820
+ }
2821
+ };
2822
+ function buildMessage({
2823
+ message,
2824
+ statusCode,
2825
+ body
2826
+ }) {
2827
+ let lines = [];
2828
+ if (message != null) {
2829
+ lines.push(message);
2830
+ }
2831
+ if (statusCode != null) {
2832
+ lines.push(`Status code: ${statusCode.toString()}`);
2833
+ }
2834
+ if (body != null) {
2835
+ lines.push(`Body: ${toJson(body, void 0, 2)}`);
2836
+ }
2837
+ return lines.join("\n");
2838
+ }
2839
+
2840
+ // src/errors/RivetTimeoutError.ts
2841
+ var RivetTimeoutError = class _RivetTimeoutError extends Error {
2842
+ constructor(message) {
2843
+ super(message);
2844
+ Object.setPrototypeOf(this, _RivetTimeoutError.prototype);
2845
+ }
2846
+ };
2847
+
2848
+ // src/api/resources/datacenters/client/Client.ts
2849
+ var import_url_join = __toESM(require("url-join"));
2850
+ var Datacenters = class {
2851
+ constructor(_options) {
2852
+ this._options = _options;
2853
+ }
2854
+ /**
2855
+ * @param {Datacenters.RequestOptions} requestOptions - Request-specific configuration.
2856
+ *
2857
+ * @example
2858
+ * await client.datacenters.list()
2859
+ */
2860
+ async list(requestOptions) {
2861
+ const _response = await (this._options.fetcher ?? fetcher)({
2862
+ url: (0, import_url_join.default)(
2863
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
2864
+ "datacenters"
2865
+ ),
2866
+ method: "GET",
2867
+ headers: {
2868
+ Authorization: await this._getAuthorizationHeader(),
2869
+ "X-Fern-Language": "JavaScript",
2870
+ "X-Fern-Runtime": RUNTIME.type,
2871
+ "X-Fern-Runtime-Version": RUNTIME.version,
2872
+ ...requestOptions == null ? void 0 : requestOptions.headers
2873
+ },
2874
+ contentType: "application/json",
2875
+ requestType: "json",
2876
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 18e4,
2877
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
2878
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
2879
+ });
2880
+ if (_response.ok) {
2881
+ return DatacentersListResponse.parseOrThrow(_response.body, {
2882
+ unrecognizedObjectKeys: "passthrough",
2883
+ allowUnrecognizedUnionMembers: true,
2884
+ allowUnrecognizedEnumValues: true,
2885
+ skipValidation: true,
2886
+ breadcrumbsPrefix: ["response"]
2887
+ });
2888
+ }
2889
+ if (_response.error.reason === "status-code") {
2890
+ throw new RivetError({
2891
+ statusCode: _response.error.statusCode,
2892
+ body: _response.error.body
2893
+ });
2894
+ }
2895
+ switch (_response.error.reason) {
2896
+ case "non-json":
2897
+ throw new RivetError({
2898
+ statusCode: _response.error.statusCode,
2899
+ body: _response.error.rawBody
2900
+ });
2901
+ case "timeout":
2902
+ throw new RivetTimeoutError("Timeout exceeded when calling GET /datacenters.");
2903
+ case "unknown":
2904
+ throw new RivetError({
2905
+ message: _response.error.errorMessage
2906
+ });
2907
+ }
2908
+ }
2909
+ async _getAuthorizationHeader() {
2910
+ return `Bearer ${await Supplier.get(this._options.token)}`;
2911
+ }
2912
+ };
2913
+
2914
+ // src/api/resources/health/client/Client.ts
2915
+ var import_url_join2 = __toESM(require("url-join"));
2916
+ var Health = class {
2917
+ constructor(_options) {
2918
+ this._options = _options;
2919
+ }
2920
+ /**
2921
+ * @param {Health.RequestOptions} requestOptions - Request-specific configuration.
2922
+ *
2923
+ * @example
2924
+ * await client.health.fanout()
2925
+ */
2926
+ async fanout(requestOptions) {
2927
+ const _response = await (this._options.fetcher ?? fetcher)({
2928
+ url: (0, import_url_join2.default)(
2929
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
2930
+ "health/fanout"
2931
+ ),
2932
+ method: "GET",
2933
+ headers: {
2934
+ Authorization: await this._getAuthorizationHeader(),
2935
+ "X-Fern-Language": "JavaScript",
2936
+ "X-Fern-Runtime": RUNTIME.type,
2937
+ "X-Fern-Runtime-Version": RUNTIME.version,
2938
+ ...requestOptions == null ? void 0 : requestOptions.headers
2939
+ },
2940
+ contentType: "application/json",
2941
+ requestType: "json",
2942
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 18e4,
2943
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
2944
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
2945
+ });
2946
+ if (_response.ok) {
2947
+ return HealthFanoutResponse.parseOrThrow(_response.body, {
2948
+ unrecognizedObjectKeys: "passthrough",
2949
+ allowUnrecognizedUnionMembers: true,
2950
+ allowUnrecognizedEnumValues: true,
2951
+ skipValidation: true,
2952
+ breadcrumbsPrefix: ["response"]
2953
+ });
2954
+ }
2955
+ if (_response.error.reason === "status-code") {
2956
+ throw new RivetError({
2957
+ statusCode: _response.error.statusCode,
2958
+ body: _response.error.body
2959
+ });
2960
+ }
2961
+ switch (_response.error.reason) {
2962
+ case "non-json":
2963
+ throw new RivetError({
2964
+ statusCode: _response.error.statusCode,
2965
+ body: _response.error.rawBody
2966
+ });
2967
+ case "timeout":
2968
+ throw new RivetTimeoutError("Timeout exceeded when calling GET /health/fanout.");
2969
+ case "unknown":
2970
+ throw new RivetError({
2971
+ message: _response.error.errorMessage
2972
+ });
2973
+ }
2974
+ }
2975
+ async _getAuthorizationHeader() {
2976
+ return `Bearer ${await Supplier.get(this._options.token)}`;
2977
+ }
2978
+ };
2979
+
2980
+ // src/api/resources/metadata/client/Client.ts
2981
+ var import_url_join3 = __toESM(require("url-join"));
2982
+ var Metadata = class {
2983
+ constructor(_options) {
2984
+ this._options = _options;
2985
+ }
2986
+ /**
2987
+ * @param {Metadata.RequestOptions} requestOptions - Request-specific configuration.
2988
+ *
2989
+ * @example
2990
+ * await client.metadata.get()
2991
+ */
2992
+ async get(requestOptions) {
2993
+ const _response = await (this._options.fetcher ?? fetcher)({
2994
+ url: (0, import_url_join3.default)(
2995
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
2996
+ "metadata"
2997
+ ),
2998
+ method: "GET",
2999
+ headers: {
3000
+ Authorization: await this._getAuthorizationHeader(),
3001
+ "X-Fern-Language": "JavaScript",
3002
+ "X-Fern-Runtime": RUNTIME.type,
3003
+ "X-Fern-Runtime-Version": RUNTIME.version,
3004
+ ...requestOptions == null ? void 0 : requestOptions.headers
3005
+ },
3006
+ contentType: "application/json",
3007
+ requestType: "json",
3008
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 18e4,
3009
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
3010
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
3011
+ });
3012
+ if (_response.ok) {
3013
+ return MetadataGetResponse.parseOrThrow(_response.body, {
3014
+ unrecognizedObjectKeys: "passthrough",
3015
+ allowUnrecognizedUnionMembers: true,
3016
+ allowUnrecognizedEnumValues: true,
3017
+ skipValidation: true,
3018
+ breadcrumbsPrefix: ["response"]
3019
+ });
3020
+ }
3021
+ if (_response.error.reason === "status-code") {
3022
+ throw new RivetError({
3023
+ statusCode: _response.error.statusCode,
3024
+ body: _response.error.body
3025
+ });
3026
+ }
3027
+ switch (_response.error.reason) {
3028
+ case "non-json":
3029
+ throw new RivetError({
3030
+ statusCode: _response.error.statusCode,
3031
+ body: _response.error.rawBody
3032
+ });
3033
+ case "timeout":
3034
+ throw new RivetTimeoutError("Timeout exceeded when calling GET /metadata.");
3035
+ case "unknown":
3036
+ throw new RivetError({
3037
+ message: _response.error.errorMessage
3038
+ });
3039
+ }
3040
+ }
3041
+ async _getAuthorizationHeader() {
3042
+ return `Bearer ${await Supplier.get(this._options.token)}`;
3043
+ }
3044
+ };
3045
+
3046
+ // src/api/resources/namespaces/client/Client.ts
3047
+ var import_url_join4 = __toESM(require("url-join"));
3048
+ var Namespaces = class {
3049
+ constructor(_options) {
3050
+ this._options = _options;
3051
+ }
3052
+ /**
3053
+ * @param {Rivet.NamespacesListRequest} request
3054
+ * @param {Namespaces.RequestOptions} requestOptions - Request-specific configuration.
3055
+ *
3056
+ * @example
3057
+ * await client.namespaces.list()
3058
+ */
3059
+ async list(request = {}, requestOptions) {
3060
+ const { limit, cursor, name, namespaceIds, namespaceId } = request;
3061
+ const _queryParams = {};
3062
+ if (limit != null) {
3063
+ _queryParams["limit"] = limit.toString();
3064
+ }
3065
+ if (cursor != null) {
3066
+ _queryParams["cursor"] = cursor;
3067
+ }
3068
+ if (name != null) {
3069
+ _queryParams["name"] = name;
3070
+ }
3071
+ if (namespaceIds != null) {
3072
+ _queryParams["namespace_ids"] = namespaceIds;
3073
+ }
3074
+ if (namespaceId != null) {
3075
+ if (Array.isArray(namespaceId)) {
3076
+ _queryParams["namespace_id"] = namespaceId.map(
3077
+ (item) => RivetId.jsonOrThrow(item, { unrecognizedObjectKeys: "strip" })
3078
+ );
3079
+ } else {
3080
+ _queryParams["namespace_id"] = namespaceId;
3081
+ }
3082
+ }
3083
+ const _response = await (this._options.fetcher ?? fetcher)({
3084
+ url: (0, import_url_join4.default)(
3085
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
3086
+ "namespaces"
3087
+ ),
3088
+ method: "GET",
3089
+ headers: {
3090
+ Authorization: await this._getAuthorizationHeader(),
3091
+ "X-Fern-Language": "JavaScript",
3092
+ "X-Fern-Runtime": RUNTIME.type,
3093
+ "X-Fern-Runtime-Version": RUNTIME.version,
3094
+ ...requestOptions == null ? void 0 : requestOptions.headers
3095
+ },
3096
+ contentType: "application/json",
3097
+ queryParameters: _queryParams,
3098
+ requestType: "json",
3099
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 18e4,
3100
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
3101
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
3102
+ });
3103
+ if (_response.ok) {
3104
+ return NamespaceListResponse.parseOrThrow(_response.body, {
3105
+ unrecognizedObjectKeys: "passthrough",
3106
+ allowUnrecognizedUnionMembers: true,
3107
+ allowUnrecognizedEnumValues: true,
3108
+ skipValidation: true,
3109
+ breadcrumbsPrefix: ["response"]
3110
+ });
3111
+ }
3112
+ if (_response.error.reason === "status-code") {
3113
+ throw new RivetError({
3114
+ statusCode: _response.error.statusCode,
3115
+ body: _response.error.body
3116
+ });
3117
+ }
3118
+ switch (_response.error.reason) {
3119
+ case "non-json":
3120
+ throw new RivetError({
3121
+ statusCode: _response.error.statusCode,
3122
+ body: _response.error.rawBody
3123
+ });
3124
+ case "timeout":
3125
+ throw new RivetTimeoutError("Timeout exceeded when calling GET /namespaces.");
3126
+ case "unknown":
3127
+ throw new RivetError({
3128
+ message: _response.error.errorMessage
3129
+ });
3130
+ }
3131
+ }
3132
+ /**
3133
+ * @param {Rivet.NamespacesCreateRequest} request
3134
+ * @param {Namespaces.RequestOptions} requestOptions - Request-specific configuration.
3135
+ *
3136
+ * @example
3137
+ * await client.namespaces.create({
3138
+ * displayName: "display_name",
3139
+ * name: "name"
3140
+ * })
3141
+ */
3142
+ async create(request, requestOptions) {
3143
+ const _response = await (this._options.fetcher ?? fetcher)({
3144
+ url: (0, import_url_join4.default)(
3145
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
3146
+ "namespaces"
3147
+ ),
3148
+ method: "POST",
3149
+ headers: {
3150
+ Authorization: await this._getAuthorizationHeader(),
3151
+ "X-Fern-Language": "JavaScript",
3152
+ "X-Fern-Runtime": RUNTIME.type,
3153
+ "X-Fern-Runtime-Version": RUNTIME.version,
3154
+ ...requestOptions == null ? void 0 : requestOptions.headers
3155
+ },
3156
+ contentType: "application/json",
3157
+ requestType: "json",
3158
+ body: NamespacesCreateRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
3159
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 18e4,
3160
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
3161
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
3162
+ });
3163
+ if (_response.ok) {
3164
+ return NamespacesCreateResponse.parseOrThrow(_response.body, {
3165
+ unrecognizedObjectKeys: "passthrough",
3166
+ allowUnrecognizedUnionMembers: true,
3167
+ allowUnrecognizedEnumValues: true,
3168
+ skipValidation: true,
3169
+ breadcrumbsPrefix: ["response"]
3170
+ });
3171
+ }
3172
+ if (_response.error.reason === "status-code") {
3173
+ throw new RivetError({
3174
+ statusCode: _response.error.statusCode,
3175
+ body: _response.error.body
3176
+ });
3177
+ }
3178
+ switch (_response.error.reason) {
3179
+ case "non-json":
3180
+ throw new RivetError({
3181
+ statusCode: _response.error.statusCode,
3182
+ body: _response.error.rawBody
3183
+ });
3184
+ case "timeout":
3185
+ throw new RivetTimeoutError("Timeout exceeded when calling POST /namespaces.");
3186
+ case "unknown":
3187
+ throw new RivetError({
3188
+ message: _response.error.errorMessage
3189
+ });
3190
+ }
3191
+ }
3192
+ async _getAuthorizationHeader() {
3193
+ return `Bearer ${await Supplier.get(this._options.token)}`;
3194
+ }
3195
+ };
3196
+
3197
+ // src/api/resources/runners/client/Client.ts
3198
+ var import_url_join5 = __toESM(require("url-join"));
3199
+ var Runners = class {
3200
+ constructor(_options) {
3201
+ this._options = _options;
3202
+ }
3203
+ /**
3204
+ * @param {Rivet.RunnersListRequest} request
3205
+ * @param {Runners.RequestOptions} requestOptions - Request-specific configuration.
3206
+ *
3207
+ * @example
3208
+ * await client.runners.list({
3209
+ * namespace: "namespace"
3210
+ * })
3211
+ */
3212
+ async list(request, requestOptions) {
3213
+ const { namespace, name, runnerIds, runnerId, includeStopped, limit, cursor } = request;
3214
+ const _queryParams = {};
3215
+ _queryParams["namespace"] = namespace;
3216
+ if (name != null) {
3217
+ _queryParams["name"] = name;
3218
+ }
3219
+ if (runnerIds != null) {
3220
+ _queryParams["runner_ids"] = runnerIds;
3221
+ }
3222
+ if (runnerId != null) {
3223
+ if (Array.isArray(runnerId)) {
3224
+ _queryParams["runner_id"] = runnerId.map(
3225
+ (item) => RivetId.jsonOrThrow(item, { unrecognizedObjectKeys: "strip" })
3226
+ );
3227
+ } else {
3228
+ _queryParams["runner_id"] = runnerId;
3229
+ }
3230
+ }
3231
+ if (includeStopped != null) {
3232
+ _queryParams["include_stopped"] = includeStopped.toString();
3233
+ }
3234
+ if (limit != null) {
3235
+ _queryParams["limit"] = limit.toString();
3236
+ }
3237
+ if (cursor != null) {
3238
+ _queryParams["cursor"] = cursor;
3239
+ }
3240
+ const _response = await (this._options.fetcher ?? fetcher)({
3241
+ url: (0, import_url_join5.default)(
3242
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
3243
+ "runners"
3244
+ ),
3245
+ method: "GET",
3246
+ headers: {
3247
+ Authorization: await this._getAuthorizationHeader(),
3248
+ "X-Fern-Language": "JavaScript",
3249
+ "X-Fern-Runtime": RUNTIME.type,
3250
+ "X-Fern-Runtime-Version": RUNTIME.version,
3251
+ ...requestOptions == null ? void 0 : requestOptions.headers
3252
+ },
3253
+ contentType: "application/json",
3254
+ queryParameters: _queryParams,
3255
+ requestType: "json",
3256
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 18e4,
3257
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
3258
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
3259
+ });
3260
+ if (_response.ok) {
3261
+ return RunnersListResponse.parseOrThrow(_response.body, {
3262
+ unrecognizedObjectKeys: "passthrough",
3263
+ allowUnrecognizedUnionMembers: true,
3264
+ allowUnrecognizedEnumValues: true,
3265
+ skipValidation: true,
3266
+ breadcrumbsPrefix: ["response"]
3267
+ });
3268
+ }
3269
+ if (_response.error.reason === "status-code") {
3270
+ throw new RivetError({
3271
+ statusCode: _response.error.statusCode,
3272
+ body: _response.error.body
3273
+ });
3274
+ }
3275
+ switch (_response.error.reason) {
3276
+ case "non-json":
3277
+ throw new RivetError({
3278
+ statusCode: _response.error.statusCode,
3279
+ body: _response.error.rawBody
3280
+ });
3281
+ case "timeout":
3282
+ throw new RivetTimeoutError("Timeout exceeded when calling GET /runners.");
3283
+ case "unknown":
3284
+ throw new RivetError({
3285
+ message: _response.error.errorMessage
3286
+ });
3287
+ }
3288
+ }
3289
+ /**
3290
+ * 2 round trips:
3291
+ *
3292
+ * - GET /runners/names (fanout)
3293
+ * - [api-peer] namespace::ops::resolve_for_name_global
3294
+ *
3295
+ * @param {Rivet.RunnersListNamesRequest} request
3296
+ * @param {Runners.RequestOptions} requestOptions - Request-specific configuration.
3297
+ *
3298
+ * @example
3299
+ * await client.runners.listNames({
3300
+ * namespace: "namespace"
3301
+ * })
3302
+ */
3303
+ async listNames(request, requestOptions) {
3304
+ const { namespace, limit, cursor } = request;
3305
+ const _queryParams = {};
3306
+ _queryParams["namespace"] = namespace;
3307
+ if (limit != null) {
3308
+ _queryParams["limit"] = limit.toString();
3309
+ }
3310
+ if (cursor != null) {
3311
+ _queryParams["cursor"] = cursor;
3312
+ }
3313
+ const _response = await (this._options.fetcher ?? fetcher)({
3314
+ url: (0, import_url_join5.default)(
3315
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
3316
+ "runners/names"
3317
+ ),
3318
+ method: "GET",
3319
+ headers: {
3320
+ Authorization: await this._getAuthorizationHeader(),
3321
+ "X-Fern-Language": "JavaScript",
3322
+ "X-Fern-Runtime": RUNTIME.type,
3323
+ "X-Fern-Runtime-Version": RUNTIME.version,
3324
+ ...requestOptions == null ? void 0 : requestOptions.headers
3325
+ },
3326
+ contentType: "application/json",
3327
+ queryParameters: _queryParams,
3328
+ requestType: "json",
3329
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 18e4,
3330
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
3331
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
3332
+ });
3333
+ if (_response.ok) {
3334
+ return RunnersListNamesResponse.parseOrThrow(_response.body, {
3335
+ unrecognizedObjectKeys: "passthrough",
3336
+ allowUnrecognizedUnionMembers: true,
3337
+ allowUnrecognizedEnumValues: true,
3338
+ skipValidation: true,
3339
+ breadcrumbsPrefix: ["response"]
3340
+ });
3341
+ }
3342
+ if (_response.error.reason === "status-code") {
3343
+ throw new RivetError({
3344
+ statusCode: _response.error.statusCode,
3345
+ body: _response.error.body
3346
+ });
3347
+ }
3348
+ switch (_response.error.reason) {
3349
+ case "non-json":
3350
+ throw new RivetError({
3351
+ statusCode: _response.error.statusCode,
3352
+ body: _response.error.rawBody
3353
+ });
3354
+ case "timeout":
3355
+ throw new RivetTimeoutError("Timeout exceeded when calling GET /runners/names.");
3356
+ case "unknown":
3357
+ throw new RivetError({
3358
+ message: _response.error.errorMessage
3359
+ });
3360
+ }
3361
+ }
3362
+ async _getAuthorizationHeader() {
3363
+ return `Bearer ${await Supplier.get(this._options.token)}`;
3364
+ }
3365
+ };
3366
+
3367
+ // src/Client.ts
3368
+ var RivetClient = class {
3369
+ constructor(_options) {
3370
+ this._options = _options;
3371
+ }
3372
+ _datacenters;
3373
+ _health;
3374
+ _metadata;
3375
+ _namespaces;
3376
+ _runners;
3377
+ get datacenters() {
3378
+ return this._datacenters ?? (this._datacenters = new Datacenters(this._options));
3379
+ }
3380
+ get health() {
3381
+ return this._health ?? (this._health = new Health(this._options));
3382
+ }
3383
+ get metadata() {
3384
+ return this._metadata ?? (this._metadata = new Metadata(this._options));
3385
+ }
3386
+ get namespaces() {
3387
+ return this._namespaces ?? (this._namespaces = new Namespaces(this._options));
3388
+ }
3389
+ get runners() {
3390
+ return this._runners ?? (this._runners = new Runners(this._options));
3391
+ }
3392
+ /**
3393
+ * **If key is some & `include_destroyed` is false**
3394
+ *
3395
+ * 2 round trips:
3396
+ *
3397
+ * - namespace::ops::resolve_for_name_global
3398
+ * - GET /actors (multiple DCs based on actor IDs)
3399
+ *
3400
+ * This path is optimized because we can read the actor IDs fro the key directly from Epoxy with
3401
+ * stale consistency to determine which datacenter the actor lives in. Under most circumstances,
3402
+ * this means we don't need to fan out to all datacenters (like normal list does).
3403
+ *
3404
+ * The reason `include_destroyed` has to be false is Epoxy only stores currently active actors. If
3405
+ * `include_destroyed` is true, we show all previous iterations of actors with the same key.
3406
+ *
3407
+ * **Otherwise**
3408
+ *
3409
+ * 2 round trips:
3410
+ *
3411
+ * - namespace::ops::resolve_for_name_global
3412
+ * - GET /actors (fanout)
3413
+ *
3414
+ * ## Optimized Alternative Routes
3415
+ *
3416
+ * @param {Rivet.ActorsListRequest} request
3417
+ * @param {RivetClient.RequestOptions} requestOptions - Request-specific configuration.
3418
+ *
3419
+ * @example
3420
+ * await client.actorsList({
3421
+ * namespace: "namespace"
3422
+ * })
3423
+ */
3424
+ async actorsList(request, requestOptions) {
3425
+ const { namespace, name, key, actorIds, actorId, includeDestroyed, limit, cursor } = request;
3426
+ const _queryParams = {};
3427
+ _queryParams["namespace"] = namespace;
3428
+ if (name != null) {
3429
+ _queryParams["name"] = name;
3430
+ }
3431
+ if (key != null) {
3432
+ _queryParams["key"] = key;
3433
+ }
3434
+ if (actorIds != null) {
3435
+ _queryParams["actor_ids"] = actorIds;
3436
+ }
3437
+ if (actorId != null) {
3438
+ if (Array.isArray(actorId)) {
3439
+ _queryParams["actor_id"] = actorId.map(
3440
+ (item) => RivetId.jsonOrThrow(item, { unrecognizedObjectKeys: "strip" })
3441
+ );
3442
+ } else {
3443
+ _queryParams["actor_id"] = actorId;
3444
+ }
3445
+ }
3446
+ if (includeDestroyed != null) {
3447
+ _queryParams["include_destroyed"] = includeDestroyed.toString();
3448
+ }
3449
+ if (limit != null) {
3450
+ _queryParams["limit"] = limit.toString();
3451
+ }
3452
+ if (cursor != null) {
3453
+ _queryParams["cursor"] = cursor;
3454
+ }
3455
+ const _response = await (this._options.fetcher ?? fetcher)({
3456
+ url: (0, import_url_join6.default)(
3457
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
3458
+ "actors"
3459
+ ),
3460
+ method: "GET",
3461
+ headers: {
3462
+ Authorization: await this._getAuthorizationHeader(),
3463
+ "X-Fern-Language": "JavaScript",
3464
+ "X-Fern-Runtime": RUNTIME.type,
3465
+ "X-Fern-Runtime-Version": RUNTIME.version,
3466
+ ...requestOptions == null ? void 0 : requestOptions.headers
3467
+ },
3468
+ contentType: "application/json",
3469
+ queryParameters: _queryParams,
3470
+ requestType: "json",
3471
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 18e4,
3472
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
3473
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
3474
+ });
3475
+ if (_response.ok) {
3476
+ return ActorsListResponse.parseOrThrow(_response.body, {
3477
+ unrecognizedObjectKeys: "passthrough",
3478
+ allowUnrecognizedUnionMembers: true,
3479
+ allowUnrecognizedEnumValues: true,
3480
+ skipValidation: true,
3481
+ breadcrumbsPrefix: ["response"]
3482
+ });
3483
+ }
3484
+ if (_response.error.reason === "status-code") {
3485
+ throw new RivetError({
3486
+ statusCode: _response.error.statusCode,
3487
+ body: _response.error.body
3488
+ });
3489
+ }
3490
+ switch (_response.error.reason) {
3491
+ case "non-json":
3492
+ throw new RivetError({
3493
+ statusCode: _response.error.statusCode,
3494
+ body: _response.error.rawBody
3495
+ });
3496
+ case "timeout":
3497
+ throw new RivetTimeoutError("Timeout exceeded when calling GET /actors.");
3498
+ case "unknown":
3499
+ throw new RivetError({
3500
+ message: _response.error.errorMessage
3501
+ });
3502
+ }
3503
+ }
3504
+ /**
3505
+ * **If actor is created in the current datacenter:**
3506
+ *
3507
+ * 2 round trips:
3508
+ *
3509
+ * - namespace::ops::resolve_for_name_global
3510
+ * - [pegboard::workflows::actor] Create actor workflow (includes Epoxy key allocation)
3511
+ *
3512
+ * **If actor is created in a different datacenter:**
3513
+ *
3514
+ * 3 round trips:
3515
+ *
3516
+ * - namespace::ops::resolve_for_name_global
3517
+ * - POST /actors to remote datacenter
3518
+ * - [pegboard::workflows::actor] Create actor workflow (includes Epoxy key allocation)
3519
+ *
3520
+ * actor::get will always be in the same datacenter.
3521
+ *
3522
+ * @param {Rivet.ActorsCreateRequest} request
3523
+ * @param {RivetClient.RequestOptions} requestOptions - Request-specific configuration.
3524
+ *
3525
+ * @example
3526
+ * await client.actorsCreate({
3527
+ * namespace: "namespace",
3528
+ * crashPolicy: "restart",
3529
+ * name: "name",
3530
+ * runnerNameSelector: "runner_name_selector"
3531
+ * })
3532
+ */
3533
+ async actorsCreate(request, requestOptions) {
3534
+ const { namespace, ..._body } = request;
3535
+ const _queryParams = {};
3536
+ _queryParams["namespace"] = namespace;
3537
+ const _response = await (this._options.fetcher ?? fetcher)({
3538
+ url: (0, import_url_join6.default)(
3539
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
3540
+ "actors"
3541
+ ),
3542
+ method: "POST",
3543
+ headers: {
3544
+ Authorization: await this._getAuthorizationHeader(),
3545
+ "X-Fern-Language": "JavaScript",
3546
+ "X-Fern-Runtime": RUNTIME.type,
3547
+ "X-Fern-Runtime-Version": RUNTIME.version,
3548
+ ...requestOptions == null ? void 0 : requestOptions.headers
3549
+ },
3550
+ contentType: "application/json",
3551
+ queryParameters: _queryParams,
3552
+ requestType: "json",
3553
+ body: ActorsCreateRequest.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }),
3554
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 18e4,
3555
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
3556
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
3557
+ });
3558
+ if (_response.ok) {
3559
+ return ActorsCreateResponse.parseOrThrow(_response.body, {
3560
+ unrecognizedObjectKeys: "passthrough",
3561
+ allowUnrecognizedUnionMembers: true,
3562
+ allowUnrecognizedEnumValues: true,
3563
+ skipValidation: true,
3564
+ breadcrumbsPrefix: ["response"]
3565
+ });
3566
+ }
3567
+ if (_response.error.reason === "status-code") {
3568
+ throw new RivetError({
3569
+ statusCode: _response.error.statusCode,
3570
+ body: _response.error.body
3571
+ });
3572
+ }
3573
+ switch (_response.error.reason) {
3574
+ case "non-json":
3575
+ throw new RivetError({
3576
+ statusCode: _response.error.statusCode,
3577
+ body: _response.error.rawBody
3578
+ });
3579
+ case "timeout":
3580
+ throw new RivetTimeoutError("Timeout exceeded when calling POST /actors.");
3581
+ case "unknown":
3582
+ throw new RivetError({
3583
+ message: _response.error.errorMessage
3584
+ });
3585
+ }
3586
+ }
3587
+ /**
3588
+ * **If actor exists**
3589
+ *
3590
+ * 2 round trips:
3591
+ *
3592
+ * - namespace::ops::resolve_for_name_global
3593
+ * - GET /actors/{}
3594
+ *
3595
+ * **If actor does not exist and is created in the current datacenter:**
3596
+ *
3597
+ * 2 round trips:
3598
+ *
3599
+ * - namespace::ops::resolve_for_name_global
3600
+ * - [pegboard::workflows::actor] Create actor workflow (includes Epoxy key allocation)
3601
+ *
3602
+ * **If actor does not exist and is created in a different datacenter:**
3603
+ *
3604
+ * 3 round trips:
3605
+ *
3606
+ * - namespace::ops::resolve_for_name_global
3607
+ * - POST /actors to remote datacenter
3608
+ * - [pegboard::workflows::actor] Create actor workflow (includes Epoxy key allocation)
3609
+ *
3610
+ * actor::get will always be in the same datacenter.
3611
+ *
3612
+ * ## Optimized Alternative Routes
3613
+ *
3614
+ * @param {Rivet.ActorsGetOrCreateRequest} request
3615
+ * @param {RivetClient.RequestOptions} requestOptions - Request-specific configuration.
3616
+ *
3617
+ * @example
3618
+ * await client.actorsGetOrCreate({
3619
+ * namespace: "namespace",
3620
+ * crashPolicy: "restart",
3621
+ * key: "key",
3622
+ * name: "name",
3623
+ * runnerNameSelector: "runner_name_selector"
3624
+ * })
3625
+ */
3626
+ async actorsGetOrCreate(request, requestOptions) {
3627
+ const { namespace, ..._body } = request;
3628
+ const _queryParams = {};
3629
+ _queryParams["namespace"] = namespace;
3630
+ const _response = await (this._options.fetcher ?? fetcher)({
3631
+ url: (0, import_url_join6.default)(
3632
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
3633
+ "actors"
3634
+ ),
3635
+ method: "PUT",
3636
+ headers: {
3637
+ Authorization: await this._getAuthorizationHeader(),
3638
+ "X-Fern-Language": "JavaScript",
3639
+ "X-Fern-Runtime": RUNTIME.type,
3640
+ "X-Fern-Runtime-Version": RUNTIME.version,
3641
+ ...requestOptions == null ? void 0 : requestOptions.headers
3642
+ },
3643
+ contentType: "application/json",
3644
+ queryParameters: _queryParams,
3645
+ requestType: "json",
3646
+ body: ActorsGetOrCreateRequest.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }),
3647
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 18e4,
3648
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
3649
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
3650
+ });
3651
+ if (_response.ok) {
3652
+ return ActorsGetOrCreateResponse.parseOrThrow(_response.body, {
3653
+ unrecognizedObjectKeys: "passthrough",
3654
+ allowUnrecognizedUnionMembers: true,
3655
+ allowUnrecognizedEnumValues: true,
3656
+ skipValidation: true,
3657
+ breadcrumbsPrefix: ["response"]
3658
+ });
3659
+ }
3660
+ if (_response.error.reason === "status-code") {
3661
+ throw new RivetError({
3662
+ statusCode: _response.error.statusCode,
3663
+ body: _response.error.body
3664
+ });
3665
+ }
3666
+ switch (_response.error.reason) {
3667
+ case "non-json":
3668
+ throw new RivetError({
3669
+ statusCode: _response.error.statusCode,
3670
+ body: _response.error.rawBody
3671
+ });
3672
+ case "timeout":
3673
+ throw new RivetTimeoutError("Timeout exceeded when calling PUT /actors.");
3674
+ case "unknown":
3675
+ throw new RivetError({
3676
+ message: _response.error.errorMessage
3677
+ });
3678
+ }
3679
+ }
3680
+ /**
3681
+ * 2 round trips:
3682
+ *
3683
+ * - GET /actors/names (fanout)
3684
+ * - [api-peer] namespace::ops::resolve_for_name_global
3685
+ *
3686
+ * @param {Rivet.ActorsListNamesRequest} request
3687
+ * @param {RivetClient.RequestOptions} requestOptions - Request-specific configuration.
3688
+ *
3689
+ * @example
3690
+ * await client.actorsListNames({
3691
+ * namespace: "namespace"
3692
+ * })
3693
+ */
3694
+ async actorsListNames(request, requestOptions) {
3695
+ const { namespace, limit, cursor } = request;
3696
+ const _queryParams = {};
3697
+ _queryParams["namespace"] = namespace;
3698
+ if (limit != null) {
3699
+ _queryParams["limit"] = limit.toString();
3700
+ }
3701
+ if (cursor != null) {
3702
+ _queryParams["cursor"] = cursor;
3703
+ }
3704
+ const _response = await (this._options.fetcher ?? fetcher)({
3705
+ url: (0, import_url_join6.default)(
3706
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
3707
+ "actors/names"
3708
+ ),
3709
+ method: "GET",
3710
+ headers: {
3711
+ Authorization: await this._getAuthorizationHeader(),
3712
+ "X-Fern-Language": "JavaScript",
3713
+ "X-Fern-Runtime": RUNTIME.type,
3714
+ "X-Fern-Runtime-Version": RUNTIME.version,
3715
+ ...requestOptions == null ? void 0 : requestOptions.headers
3716
+ },
3717
+ contentType: "application/json",
3718
+ queryParameters: _queryParams,
3719
+ requestType: "json",
3720
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 18e4,
3721
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
3722
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
3723
+ });
3724
+ if (_response.ok) {
3725
+ return ActorsListNamesResponse.parseOrThrow(_response.body, {
3726
+ unrecognizedObjectKeys: "passthrough",
3727
+ allowUnrecognizedUnionMembers: true,
3728
+ allowUnrecognizedEnumValues: true,
3729
+ skipValidation: true,
3730
+ breadcrumbsPrefix: ["response"]
3731
+ });
3732
+ }
3733
+ if (_response.error.reason === "status-code") {
3734
+ throw new RivetError({
3735
+ statusCode: _response.error.statusCode,
3736
+ body: _response.error.body
3737
+ });
3738
+ }
3739
+ switch (_response.error.reason) {
3740
+ case "non-json":
3741
+ throw new RivetError({
3742
+ statusCode: _response.error.statusCode,
3743
+ body: _response.error.rawBody
3744
+ });
3745
+ case "timeout":
3746
+ throw new RivetTimeoutError("Timeout exceeded when calling GET /actors/names.");
3747
+ case "unknown":
3748
+ throw new RivetError({
3749
+ message: _response.error.errorMessage
3750
+ });
3751
+ }
3752
+ }
3753
+ /**
3754
+ * 2 round trip:
3755
+ *
3756
+ * - DELETE /actors/{}
3757
+ * - [api-peer] namespace::ops::resolve_for_name_global
3758
+ *
3759
+ * @param {Rivet.RivetId} actorId
3760
+ * @param {Rivet.ActorsDeleteRequest} request
3761
+ * @param {RivetClient.RequestOptions} requestOptions - Request-specific configuration.
3762
+ *
3763
+ * @example
3764
+ * await client.actorsDelete("actor_id", {
3765
+ * namespace: "namespace"
3766
+ * })
3767
+ */
3768
+ async actorsDelete(actorId, request, requestOptions) {
3769
+ const { namespace } = request;
3770
+ const _queryParams = {};
3771
+ _queryParams["namespace"] = namespace;
3772
+ const _response = await (this._options.fetcher ?? fetcher)({
3773
+ url: (0, import_url_join6.default)(
3774
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
3775
+ `actors/${encodeURIComponent(RivetId.jsonOrThrow(actorId))}`
3776
+ ),
3777
+ method: "DELETE",
3778
+ headers: {
3779
+ Authorization: await this._getAuthorizationHeader(),
3780
+ "X-Fern-Language": "JavaScript",
3781
+ "X-Fern-Runtime": RUNTIME.type,
3782
+ "X-Fern-Runtime-Version": RUNTIME.version,
3783
+ ...requestOptions == null ? void 0 : requestOptions.headers
3784
+ },
3785
+ contentType: "application/json",
3786
+ queryParameters: _queryParams,
3787
+ requestType: "json",
3788
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 18e4,
3789
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
3790
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
3791
+ });
3792
+ if (_response.ok) {
3793
+ return ActorsDeleteResponse.parseOrThrow(_response.body, {
3794
+ unrecognizedObjectKeys: "passthrough",
3795
+ allowUnrecognizedUnionMembers: true,
3796
+ allowUnrecognizedEnumValues: true,
3797
+ skipValidation: true,
3798
+ breadcrumbsPrefix: ["response"]
3799
+ });
3800
+ }
3801
+ if (_response.error.reason === "status-code") {
3802
+ throw new RivetError({
3803
+ statusCode: _response.error.statusCode,
3804
+ body: _response.error.body
3805
+ });
3806
+ }
3807
+ switch (_response.error.reason) {
3808
+ case "non-json":
3809
+ throw new RivetError({
3810
+ statusCode: _response.error.statusCode,
3811
+ body: _response.error.rawBody
3812
+ });
3813
+ case "timeout":
3814
+ throw new RivetTimeoutError("Timeout exceeded when calling DELETE /actors/{actor_id}.");
3815
+ case "unknown":
3816
+ throw new RivetError({
3817
+ message: _response.error.errorMessage
3818
+ });
3819
+ }
3820
+ }
3821
+ /**
3822
+ * @param {Rivet.RivetId} actorId
3823
+ * @param {string} key
3824
+ * @param {Rivet.ActorsKvGetRequest} request
3825
+ * @param {RivetClient.RequestOptions} requestOptions - Request-specific configuration.
3826
+ *
3827
+ * @example
3828
+ * await client.actorsKvGet("actor_id", "key", {
3829
+ * namespace: "namespace"
3830
+ * })
3831
+ */
3832
+ async actorsKvGet(actorId, key, request, requestOptions) {
3833
+ const { namespace } = request;
3834
+ const _queryParams = {};
3835
+ _queryParams["namespace"] = namespace;
3836
+ const _response = await (this._options.fetcher ?? fetcher)({
3837
+ url: (0, import_url_join6.default)(
3838
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
3839
+ `actors/${encodeURIComponent(RivetId.jsonOrThrow(actorId))}/kv/keys/${encodeURIComponent(key)}`
3840
+ ),
3841
+ method: "GET",
3842
+ headers: {
3843
+ Authorization: await this._getAuthorizationHeader(),
3844
+ "X-Fern-Language": "JavaScript",
3845
+ "X-Fern-Runtime": RUNTIME.type,
3846
+ "X-Fern-Runtime-Version": RUNTIME.version,
3847
+ ...requestOptions == null ? void 0 : requestOptions.headers
3848
+ },
3849
+ contentType: "application/json",
3850
+ queryParameters: _queryParams,
3851
+ requestType: "json",
3852
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 18e4,
3853
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
3854
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
3855
+ });
3856
+ if (_response.ok) {
3857
+ return ActorsKvGetResponse.parseOrThrow(_response.body, {
3858
+ unrecognizedObjectKeys: "passthrough",
3859
+ allowUnrecognizedUnionMembers: true,
3860
+ allowUnrecognizedEnumValues: true,
3861
+ skipValidation: true,
3862
+ breadcrumbsPrefix: ["response"]
3863
+ });
3864
+ }
3865
+ if (_response.error.reason === "status-code") {
3866
+ throw new RivetError({
3867
+ statusCode: _response.error.statusCode,
3868
+ body: _response.error.body
3869
+ });
3870
+ }
3871
+ switch (_response.error.reason) {
3872
+ case "non-json":
3873
+ throw new RivetError({
3874
+ statusCode: _response.error.statusCode,
3875
+ body: _response.error.rawBody
3876
+ });
3877
+ case "timeout":
3878
+ throw new RivetTimeoutError(
3879
+ "Timeout exceeded when calling GET /actors/{actor_id}/kv/keys/{key}."
3880
+ );
3881
+ case "unknown":
3882
+ throw new RivetError({
3883
+ message: _response.error.errorMessage
3884
+ });
3885
+ }
3886
+ }
3887
+ /**
3888
+ * @param {Rivet.RunnerConfigsListRequest} request
3889
+ * @param {RivetClient.RequestOptions} requestOptions - Request-specific configuration.
3890
+ *
3891
+ * @example
3892
+ * await client.runnerConfigsList({
3893
+ * namespace: "namespace"
3894
+ * })
3895
+ */
3896
+ async runnerConfigsList(request, requestOptions) {
3897
+ const { namespace, limit, cursor, variant, runnerNames, runnerName } = request;
3898
+ const _queryParams = {};
3899
+ _queryParams["namespace"] = namespace;
3900
+ if (limit != null) {
3901
+ _queryParams["limit"] = limit.toString();
3902
+ }
3903
+ if (cursor != null) {
3904
+ _queryParams["cursor"] = cursor;
3905
+ }
3906
+ if (variant != null) {
3907
+ _queryParams["variant"] = RunnerConfigVariant2.jsonOrThrow(variant, {
3908
+ unrecognizedObjectKeys: "strip"
3909
+ });
3910
+ }
3911
+ if (runnerNames != null) {
3912
+ _queryParams["runner_names"] = runnerNames;
3913
+ }
3914
+ if (runnerName != null) {
3915
+ if (Array.isArray(runnerName)) {
3916
+ _queryParams["runner_name"] = runnerName.map((item) => item);
3917
+ } else {
3918
+ _queryParams["runner_name"] = runnerName;
3919
+ }
3920
+ }
3921
+ const _response = await (this._options.fetcher ?? fetcher)({
3922
+ url: (0, import_url_join6.default)(
3923
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
3924
+ "runner-configs"
3925
+ ),
3926
+ method: "GET",
3927
+ headers: {
3928
+ Authorization: await this._getAuthorizationHeader(),
3929
+ "X-Fern-Language": "JavaScript",
3930
+ "X-Fern-Runtime": RUNTIME.type,
3931
+ "X-Fern-Runtime-Version": RUNTIME.version,
3932
+ ...requestOptions == null ? void 0 : requestOptions.headers
3933
+ },
3934
+ contentType: "application/json",
3935
+ queryParameters: _queryParams,
3936
+ requestType: "json",
3937
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 18e4,
3938
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
3939
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
3940
+ });
3941
+ if (_response.ok) {
3942
+ return RunnerConfigsListResponse.parseOrThrow(_response.body, {
3943
+ unrecognizedObjectKeys: "passthrough",
3944
+ allowUnrecognizedUnionMembers: true,
3945
+ allowUnrecognizedEnumValues: true,
3946
+ skipValidation: true,
3947
+ breadcrumbsPrefix: ["response"]
3948
+ });
3949
+ }
3950
+ if (_response.error.reason === "status-code") {
3951
+ throw new RivetError({
3952
+ statusCode: _response.error.statusCode,
3953
+ body: _response.error.body
3954
+ });
3955
+ }
3956
+ switch (_response.error.reason) {
3957
+ case "non-json":
3958
+ throw new RivetError({
3959
+ statusCode: _response.error.statusCode,
3960
+ body: _response.error.rawBody
3961
+ });
3962
+ case "timeout":
3963
+ throw new RivetTimeoutError("Timeout exceeded when calling GET /runner-configs.");
3964
+ case "unknown":
3965
+ throw new RivetError({
3966
+ message: _response.error.errorMessage
3967
+ });
3968
+ }
3969
+ }
3970
+ /**
3971
+ * @param {Rivet.RunnerConfigsServerlessHealthCheckRequest} request
3972
+ * @param {RivetClient.RequestOptions} requestOptions - Request-specific configuration.
3973
+ *
3974
+ * @example
3975
+ * await client.runnerConfigsServerlessHealthCheck({
3976
+ * namespace: "namespace",
3977
+ * url: "url"
3978
+ * })
3979
+ */
3980
+ async runnerConfigsServerlessHealthCheck(request, requestOptions) {
3981
+ const { namespace, ..._body } = request;
3982
+ const _queryParams = {};
3983
+ _queryParams["namespace"] = namespace;
3984
+ const _response = await (this._options.fetcher ?? fetcher)({
3985
+ url: (0, import_url_join6.default)(
3986
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
3987
+ "runner-configs/serverless-health-check"
3988
+ ),
3989
+ method: "POST",
3990
+ headers: {
3991
+ Authorization: await this._getAuthorizationHeader(),
3992
+ "X-Fern-Language": "JavaScript",
3993
+ "X-Fern-Runtime": RUNTIME.type,
3994
+ "X-Fern-Runtime-Version": RUNTIME.version,
3995
+ ...requestOptions == null ? void 0 : requestOptions.headers
3996
+ },
3997
+ contentType: "application/json",
3998
+ queryParameters: _queryParams,
3999
+ requestType: "json",
4000
+ body: RunnerConfigsServerlessHealthCheckRequest.jsonOrThrow(_body, {
4001
+ unrecognizedObjectKeys: "strip"
4002
+ }),
4003
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 18e4,
4004
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
4005
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
4006
+ });
4007
+ if (_response.ok) {
4008
+ return RunnerConfigsServerlessHealthCheckResponse.parseOrThrow(_response.body, {
4009
+ unrecognizedObjectKeys: "passthrough",
4010
+ allowUnrecognizedUnionMembers: true,
4011
+ allowUnrecognizedEnumValues: true,
4012
+ skipValidation: true,
4013
+ breadcrumbsPrefix: ["response"]
4014
+ });
4015
+ }
4016
+ if (_response.error.reason === "status-code") {
4017
+ throw new RivetError({
4018
+ statusCode: _response.error.statusCode,
4019
+ body: _response.error.body
4020
+ });
4021
+ }
4022
+ switch (_response.error.reason) {
4023
+ case "non-json":
4024
+ throw new RivetError({
4025
+ statusCode: _response.error.statusCode,
4026
+ body: _response.error.rawBody
4027
+ });
4028
+ case "timeout":
4029
+ throw new RivetTimeoutError(
4030
+ "Timeout exceeded when calling POST /runner-configs/serverless-health-check."
4031
+ );
4032
+ case "unknown":
4033
+ throw new RivetError({
4034
+ message: _response.error.errorMessage
4035
+ });
4036
+ }
4037
+ }
4038
+ /**
4039
+ * @param {string} runnerName
4040
+ * @param {Rivet.RunnerConfigsUpsertRequestBody} request
4041
+ * @param {RivetClient.RequestOptions} requestOptions - Request-specific configuration.
4042
+ *
4043
+ * @example
4044
+ * await client.runnerConfigsUpsert("runner_name", {
4045
+ * namespace: "namespace",
4046
+ * datacenters: {
4047
+ * "key": {}
4048
+ * }
4049
+ * })
4050
+ */
4051
+ async runnerConfigsUpsert(runnerName, request, requestOptions) {
4052
+ const { namespace, ..._body } = request;
4053
+ const _queryParams = {};
4054
+ _queryParams["namespace"] = namespace;
4055
+ const _response = await (this._options.fetcher ?? fetcher)({
4056
+ url: (0, import_url_join6.default)(
4057
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
4058
+ `runner-configs/${encodeURIComponent(runnerName)}`
4059
+ ),
4060
+ method: "PUT",
4061
+ headers: {
4062
+ Authorization: await this._getAuthorizationHeader(),
4063
+ "X-Fern-Language": "JavaScript",
4064
+ "X-Fern-Runtime": RUNTIME.type,
4065
+ "X-Fern-Runtime-Version": RUNTIME.version,
4066
+ ...requestOptions == null ? void 0 : requestOptions.headers
4067
+ },
4068
+ contentType: "application/json",
4069
+ queryParameters: _queryParams,
4070
+ requestType: "json",
4071
+ body: RunnerConfigsUpsertRequestBody.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }),
4072
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 18e4,
4073
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
4074
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
4075
+ });
4076
+ if (_response.ok) {
4077
+ return RunnerConfigsUpsertResponse.parseOrThrow(_response.body, {
4078
+ unrecognizedObjectKeys: "passthrough",
4079
+ allowUnrecognizedUnionMembers: true,
4080
+ allowUnrecognizedEnumValues: true,
4081
+ skipValidation: true,
4082
+ breadcrumbsPrefix: ["response"]
4083
+ });
4084
+ }
4085
+ if (_response.error.reason === "status-code") {
4086
+ throw new RivetError({
4087
+ statusCode: _response.error.statusCode,
4088
+ body: _response.error.body
4089
+ });
4090
+ }
4091
+ switch (_response.error.reason) {
4092
+ case "non-json":
4093
+ throw new RivetError({
4094
+ statusCode: _response.error.statusCode,
4095
+ body: _response.error.rawBody
4096
+ });
4097
+ case "timeout":
4098
+ throw new RivetTimeoutError("Timeout exceeded when calling PUT /runner-configs/{runner_name}.");
4099
+ case "unknown":
4100
+ throw new RivetError({
4101
+ message: _response.error.errorMessage
4102
+ });
4103
+ }
4104
+ }
4105
+ /**
4106
+ * @param {string} runnerName
4107
+ * @param {Rivet.RunnerConfigsDeleteRequest} request
4108
+ * @param {RivetClient.RequestOptions} requestOptions - Request-specific configuration.
4109
+ *
4110
+ * @example
4111
+ * await client.runnerConfigsDelete("runner_name", {
4112
+ * namespace: "namespace"
4113
+ * })
4114
+ */
4115
+ async runnerConfigsDelete(runnerName, request, requestOptions) {
4116
+ const { namespace } = request;
4117
+ const _queryParams = {};
4118
+ _queryParams["namespace"] = namespace;
4119
+ const _response = await (this._options.fetcher ?? fetcher)({
4120
+ url: (0, import_url_join6.default)(
4121
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
4122
+ `runner-configs/${encodeURIComponent(runnerName)}`
4123
+ ),
4124
+ method: "DELETE",
4125
+ headers: {
4126
+ Authorization: await this._getAuthorizationHeader(),
4127
+ "X-Fern-Language": "JavaScript",
4128
+ "X-Fern-Runtime": RUNTIME.type,
4129
+ "X-Fern-Runtime-Version": RUNTIME.version,
4130
+ ...requestOptions == null ? void 0 : requestOptions.headers
4131
+ },
4132
+ contentType: "application/json",
4133
+ queryParameters: _queryParams,
4134
+ requestType: "json",
4135
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 18e4,
4136
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
4137
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
4138
+ });
4139
+ if (_response.ok) {
4140
+ return RunnerConfigsDeleteResponse.parseOrThrow(_response.body, {
4141
+ unrecognizedObjectKeys: "passthrough",
4142
+ allowUnrecognizedUnionMembers: true,
4143
+ allowUnrecognizedEnumValues: true,
4144
+ skipValidation: true,
4145
+ breadcrumbsPrefix: ["response"]
4146
+ });
4147
+ }
4148
+ if (_response.error.reason === "status-code") {
4149
+ throw new RivetError({
4150
+ statusCode: _response.error.statusCode,
4151
+ body: _response.error.body
4152
+ });
4153
+ }
4154
+ switch (_response.error.reason) {
4155
+ case "non-json":
4156
+ throw new RivetError({
4157
+ statusCode: _response.error.statusCode,
4158
+ body: _response.error.rawBody
4159
+ });
4160
+ case "timeout":
4161
+ throw new RivetTimeoutError(
4162
+ "Timeout exceeded when calling DELETE /runner-configs/{runner_name}."
4163
+ );
4164
+ case "unknown":
4165
+ throw new RivetError({
4166
+ message: _response.error.errorMessage
4167
+ });
4168
+ }
4169
+ }
4170
+ /**
4171
+ * @param {string} runnerName
4172
+ * @param {Rivet.RunnerConfigsRefreshMetadataRequest} request
4173
+ * @param {RivetClient.RequestOptions} requestOptions - Request-specific configuration.
4174
+ *
4175
+ * @example
4176
+ * await client.runnerConfigsRefreshMetadata("runner_name", {
4177
+ * namespace: "namespace",
4178
+ * body: {
4179
+ * "key": "value"
4180
+ * }
4181
+ * })
4182
+ */
4183
+ async runnerConfigsRefreshMetadata(runnerName, request, requestOptions) {
4184
+ const { namespace, body: _body } = request;
4185
+ const _queryParams = {};
4186
+ _queryParams["namespace"] = namespace;
4187
+ const _response = await (this._options.fetcher ?? fetcher)({
4188
+ url: (0, import_url_join6.default)(
4189
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
4190
+ `runner-configs/${encodeURIComponent(runnerName)}/refresh-metadata`
4191
+ ),
4192
+ method: "POST",
4193
+ headers: {
4194
+ Authorization: await this._getAuthorizationHeader(),
4195
+ "X-Fern-Language": "JavaScript",
4196
+ "X-Fern-Runtime": RUNTIME.type,
4197
+ "X-Fern-Runtime-Version": RUNTIME.version,
4198
+ ...requestOptions == null ? void 0 : requestOptions.headers
4199
+ },
4200
+ contentType: "application/json",
4201
+ queryParameters: _queryParams,
4202
+ requestType: "json",
4203
+ body: RunnerConfigsRefreshMetadataRequestBody.jsonOrThrow(_body, {
4204
+ unrecognizedObjectKeys: "strip"
4205
+ }),
4206
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 18e4,
4207
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
4208
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
4209
+ });
4210
+ if (_response.ok) {
4211
+ return RunnerConfigsRefreshMetadataResponse.parseOrThrow(_response.body, {
4212
+ unrecognizedObjectKeys: "passthrough",
4213
+ allowUnrecognizedUnionMembers: true,
4214
+ allowUnrecognizedEnumValues: true,
4215
+ skipValidation: true,
4216
+ breadcrumbsPrefix: ["response"]
4217
+ });
4218
+ }
4219
+ if (_response.error.reason === "status-code") {
4220
+ throw new RivetError({
4221
+ statusCode: _response.error.statusCode,
4222
+ body: _response.error.body
4223
+ });
4224
+ }
4225
+ switch (_response.error.reason) {
4226
+ case "non-json":
4227
+ throw new RivetError({
4228
+ statusCode: _response.error.statusCode,
4229
+ body: _response.error.rawBody
4230
+ });
4231
+ case "timeout":
4232
+ throw new RivetTimeoutError(
4233
+ "Timeout exceeded when calling POST /runner-configs/{runner_name}/refresh-metadata."
4234
+ );
4235
+ case "unknown":
4236
+ throw new RivetError({
4237
+ message: _response.error.errorMessage
4238
+ });
4239
+ }
4240
+ }
4241
+ async _getAuthorizationHeader() {
4242
+ return `Bearer ${await Supplier.get(this._options.token)}`;
4243
+ }
4244
+ };
4245
+ // Annotate the CommonJS export names for ESM import in node:
4246
+ 0 && (module.exports = {
4247
+ Rivet,
4248
+ RivetClient,
4249
+ RivetError,
4250
+ RivetTimeoutError,
4251
+ serialization
4252
+ });