@rivetkit/engine-api-full 2.0.38 → 2.0.39

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 (51) hide show
  1. package/dist/browser/cjs/index.js +5 -130
  2. package/dist/browser/cjs/serialization.js +5 -130
  3. package/dist/browser/esm/index.js +5 -130
  4. package/dist/browser/esm/serialization.js +5 -130
  5. package/dist/node/{index.js → cjs/index.js} +5 -130
  6. package/dist/node/{serialization.js → cjs/serialization.js} +5 -147
  7. package/dist/node/esm/core.js +2317 -0
  8. package/dist/node/esm/index.js +4218 -0
  9. package/dist/node/esm/serialization.js +1925 -0
  10. package/package.json +13 -4
  11. package/types/api/types/Actor.d.ts +1 -1
  12. package/types/api/types/RunnerConfigResponse.d.ts +1 -1
  13. package/types/api/types/index.d.ts +0 -17
  14. package/types/serialization/types/Actor.d.ts +1 -2
  15. package/types/serialization/types/RunnerConfigResponse.d.ts +1 -2
  16. package/types/serialization/types/index.d.ts +0 -17
  17. package/types/api/types/ActorError.d.ts +0 -20
  18. package/types/api/types/ActorErrorCrashed.d.ts +0 -11
  19. package/types/api/types/ActorErrorCrashedCrashed.d.ts +0 -9
  20. package/types/api/types/ActorErrorRunnerConnectionLost.d.ts +0 -11
  21. package/types/api/types/ActorErrorRunnerConnectionLostRunnerConnectionLost.d.ts +0 -10
  22. package/types/api/types/ActorErrorRunnerDrainingTimeout.d.ts +0 -11
  23. package/types/api/types/ActorErrorRunnerDrainingTimeoutRunnerDrainingTimeout.d.ts +0 -10
  24. package/types/api/types/ActorErrorRunnerNoResponse.d.ts +0 -11
  25. package/types/api/types/ActorErrorRunnerNoResponseRunnerNoResponse.d.ts +0 -10
  26. package/types/api/types/ActorErrorRunnerPoolError.d.ts +0 -11
  27. package/types/api/types/RunnerPoolError.d.ts +0 -14
  28. package/types/api/types/RunnerPoolErrorServerlessConnectionError.d.ts +0 -11
  29. package/types/api/types/RunnerPoolErrorServerlessConnectionErrorServerlessConnectionError.d.ts +0 -9
  30. package/types/api/types/RunnerPoolErrorServerlessHttpError.d.ts +0 -11
  31. package/types/api/types/RunnerPoolErrorServerlessHttpErrorServerlessHttpError.d.ts +0 -10
  32. package/types/api/types/RunnerPoolErrorServerlessInvalidSsePayload.d.ts +0 -11
  33. package/types/api/types/RunnerPoolErrorServerlessInvalidSsePayloadServerlessInvalidSsePayload.d.ts +0 -10
  34. package/types/serialization/types/ActorError.d.ts +0 -15
  35. package/types/serialization/types/ActorErrorCrashed.d.ts +0 -13
  36. package/types/serialization/types/ActorErrorCrashedCrashed.d.ts +0 -12
  37. package/types/serialization/types/ActorErrorRunnerConnectionLost.d.ts +0 -13
  38. package/types/serialization/types/ActorErrorRunnerConnectionLostRunnerConnectionLost.d.ts +0 -13
  39. package/types/serialization/types/ActorErrorRunnerDrainingTimeout.d.ts +0 -13
  40. package/types/serialization/types/ActorErrorRunnerDrainingTimeoutRunnerDrainingTimeout.d.ts +0 -13
  41. package/types/serialization/types/ActorErrorRunnerNoResponse.d.ts +0 -13
  42. package/types/serialization/types/ActorErrorRunnerNoResponseRunnerNoResponse.d.ts +0 -13
  43. package/types/serialization/types/ActorErrorRunnerPoolError.d.ts +0 -13
  44. package/types/serialization/types/RunnerPoolError.d.ts +0 -13
  45. package/types/serialization/types/RunnerPoolErrorServerlessConnectionError.d.ts +0 -13
  46. package/types/serialization/types/RunnerPoolErrorServerlessConnectionErrorServerlessConnectionError.d.ts +0 -12
  47. package/types/serialization/types/RunnerPoolErrorServerlessHttpError.d.ts +0 -13
  48. package/types/serialization/types/RunnerPoolErrorServerlessHttpErrorServerlessHttpError.d.ts +0 -13
  49. package/types/serialization/types/RunnerPoolErrorServerlessInvalidSsePayload.d.ts +0 -13
  50. package/types/serialization/types/RunnerPoolErrorServerlessInvalidSsePayloadServerlessInvalidSsePayload.d.ts +0 -13
  51. /package/dist/node/{core.js → cjs/core.js} +0 -0
@@ -0,0 +1,1925 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/core/fetcher/createRequestUrl.ts
8
+ import qs from "qs";
9
+
10
+ // src/core/runtime/runtime.ts
11
+ var RUNTIME = evaluateRuntime();
12
+ function evaluateRuntime() {
13
+ var _a, _b, _c, _d, _e;
14
+ const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
15
+ if (isBrowser) {
16
+ return {
17
+ type: "browser",
18
+ version: window.navigator.userAgent
19
+ };
20
+ }
21
+ const isCloudflare = typeof globalThis !== "undefined" && ((_a = globalThis == null ? void 0 : globalThis.navigator) == null ? void 0 : _a.userAgent) === "Cloudflare-Workers";
22
+ if (isCloudflare) {
23
+ return {
24
+ type: "workerd"
25
+ };
26
+ }
27
+ const isEdgeRuntime = typeof EdgeRuntime === "string";
28
+ if (isEdgeRuntime) {
29
+ return {
30
+ type: "edge-runtime"
31
+ };
32
+ }
33
+ const isWebWorker = typeof self === "object" && // @ts-ignore
34
+ 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");
35
+ if (isWebWorker) {
36
+ return {
37
+ type: "web-worker"
38
+ };
39
+ }
40
+ const isDeno = typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined";
41
+ if (isDeno) {
42
+ return {
43
+ type: "deno",
44
+ version: Deno.version.deno
45
+ };
46
+ }
47
+ const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined";
48
+ if (isBun) {
49
+ return {
50
+ type: "bun",
51
+ version: Bun.version
52
+ };
53
+ }
54
+ const isNode = typeof process !== "undefined" && "version" in process && !!process.version && "versions" in process && !!((_e = process.versions) == null ? void 0 : _e.node);
55
+ if (isNode) {
56
+ return {
57
+ type: "node",
58
+ version: process.versions.node,
59
+ parsedVersion: Number(process.versions.node.split(".")[0])
60
+ };
61
+ }
62
+ const isReactNative = typeof navigator !== "undefined" && (navigator == null ? void 0 : navigator.product) === "ReactNative";
63
+ if (isReactNative) {
64
+ return {
65
+ type: "react-native"
66
+ };
67
+ }
68
+ return {
69
+ type: "unknown"
70
+ };
71
+ }
72
+
73
+ // src/core/auth/BasicAuth.ts
74
+ import { Base64 } from "js-base64";
75
+
76
+ // src/core/schemas/index.ts
77
+ var schemas_exports = {};
78
+ __export(schemas_exports, {
79
+ JsonError: () => JsonError,
80
+ ParseError: () => ParseError,
81
+ any: () => any,
82
+ bigint: () => bigint,
83
+ boolean: () => boolean,
84
+ booleanLiteral: () => booleanLiteral,
85
+ date: () => date,
86
+ discriminant: () => discriminant,
87
+ enum_: () => enum_,
88
+ getObjectLikeUtils: () => getObjectLikeUtils,
89
+ getObjectUtils: () => getObjectUtils,
90
+ getSchemaUtils: () => getSchemaUtils,
91
+ isProperty: () => isProperty,
92
+ lazy: () => lazy,
93
+ lazyObject: () => lazyObject,
94
+ list: () => list,
95
+ number: () => number,
96
+ object: () => object,
97
+ objectWithoutOptionalProperties: () => objectWithoutOptionalProperties,
98
+ optional: () => optional,
99
+ property: () => property,
100
+ record: () => record,
101
+ set: () => set,
102
+ string: () => string,
103
+ stringLiteral: () => stringLiteral,
104
+ transform: () => transform,
105
+ undiscriminatedUnion: () => undiscriminatedUnion,
106
+ union: () => union,
107
+ unknown: () => unknown,
108
+ withParsedProperties: () => withParsedProperties
109
+ });
110
+
111
+ // src/core/schemas/Schema.ts
112
+ var SchemaType = {
113
+ BIGINT: "bigint",
114
+ DATE: "date",
115
+ ENUM: "enum",
116
+ LIST: "list",
117
+ STRING_LITERAL: "stringLiteral",
118
+ BOOLEAN_LITERAL: "booleanLiteral",
119
+ OBJECT: "object",
120
+ ANY: "any",
121
+ BOOLEAN: "boolean",
122
+ NUMBER: "number",
123
+ STRING: "string",
124
+ UNKNOWN: "unknown",
125
+ RECORD: "record",
126
+ SET: "set",
127
+ UNION: "union",
128
+ UNDISCRIMINATED_UNION: "undiscriminatedUnion",
129
+ NULLABLE: "nullable",
130
+ OPTIONAL: "optional",
131
+ OPTIONAL_NULLABLE: "optionalNullable"
132
+ };
133
+
134
+ // src/core/schemas/utils/getErrorMessageForIncorrectType.ts
135
+ function getErrorMessageForIncorrectType(value, expectedType) {
136
+ return `Expected ${expectedType}. Received ${getTypeAsString(value)}.`;
137
+ }
138
+ function getTypeAsString(value) {
139
+ if (Array.isArray(value)) {
140
+ return "list";
141
+ }
142
+ if (value === null) {
143
+ return "null";
144
+ }
145
+ if (value instanceof BigInt) {
146
+ return "BigInt";
147
+ }
148
+ switch (typeof value) {
149
+ case "string":
150
+ return `"${value}"`;
151
+ case "bigint":
152
+ case "number":
153
+ case "boolean":
154
+ case "undefined":
155
+ return `${value}`;
156
+ }
157
+ return typeof value;
158
+ }
159
+
160
+ // src/core/schemas/utils/maybeSkipValidation.ts
161
+ function maybeSkipValidation(schema) {
162
+ return {
163
+ ...schema,
164
+ json: transformAndMaybeSkipValidation(schema.json),
165
+ parse: transformAndMaybeSkipValidation(schema.parse)
166
+ };
167
+ }
168
+ function transformAndMaybeSkipValidation(transform2) {
169
+ return (value, opts) => {
170
+ const transformed = transform2(value, opts);
171
+ const { skipValidation = false } = opts ?? {};
172
+ if (!transformed.ok && skipValidation) {
173
+ console.warn(
174
+ [
175
+ "Failed to validate.",
176
+ ...transformed.errors.map(
177
+ (error) => " - " + (error.path.length > 0 ? `${error.path.join(".")}: ${error.message}` : error.message)
178
+ )
179
+ ].join("\n")
180
+ );
181
+ return {
182
+ ok: true,
183
+ value
184
+ };
185
+ } else {
186
+ return transformed;
187
+ }
188
+ };
189
+ }
190
+
191
+ // src/core/schemas/builders/schema-utils/stringifyValidationErrors.ts
192
+ function stringifyValidationError(error) {
193
+ if (error.path.length === 0) {
194
+ return error.message;
195
+ }
196
+ return `${error.path.join(" -> ")}: ${error.message}`;
197
+ }
198
+
199
+ // src/core/schemas/builders/schema-utils/JsonError.ts
200
+ var JsonError = class _JsonError extends Error {
201
+ constructor(errors) {
202
+ super(errors.map(stringifyValidationError).join("; "));
203
+ this.errors = errors;
204
+ Object.setPrototypeOf(this, _JsonError.prototype);
205
+ }
206
+ };
207
+
208
+ // src/core/schemas/builders/schema-utils/ParseError.ts
209
+ var ParseError = class _ParseError extends Error {
210
+ constructor(errors) {
211
+ super(errors.map(stringifyValidationError).join("; "));
212
+ this.errors = errors;
213
+ Object.setPrototypeOf(this, _ParseError.prototype);
214
+ }
215
+ };
216
+
217
+ // src/core/schemas/builders/schema-utils/getSchemaUtils.ts
218
+ function getSchemaUtils(schema) {
219
+ return {
220
+ nullable: () => nullable(schema),
221
+ optional: () => optional(schema),
222
+ optionalNullable: () => optionalNullable(schema),
223
+ transform: (transformer) => transform(schema, transformer),
224
+ parseOrThrow: (raw, opts) => {
225
+ const parsed = schema.parse(raw, opts);
226
+ if (parsed.ok) {
227
+ return parsed.value;
228
+ }
229
+ throw new ParseError(parsed.errors);
230
+ },
231
+ jsonOrThrow: (parsed, opts) => {
232
+ const raw = schema.json(parsed, opts);
233
+ if (raw.ok) {
234
+ return raw.value;
235
+ }
236
+ throw new JsonError(raw.errors);
237
+ }
238
+ };
239
+ }
240
+ function nullable(schema) {
241
+ const baseSchema = {
242
+ parse: (raw, opts) => {
243
+ if (raw == null) {
244
+ return {
245
+ ok: true,
246
+ value: null
247
+ };
248
+ }
249
+ return schema.parse(raw, opts);
250
+ },
251
+ json: (parsed, opts) => {
252
+ if (parsed == null) {
253
+ return {
254
+ ok: true,
255
+ value: null
256
+ };
257
+ }
258
+ return schema.json(parsed, opts);
259
+ },
260
+ getType: () => SchemaType.NULLABLE
261
+ };
262
+ return {
263
+ ...baseSchema,
264
+ ...getSchemaUtils(baseSchema)
265
+ };
266
+ }
267
+ function optional(schema) {
268
+ const baseSchema = {
269
+ parse: (raw, opts) => {
270
+ if (raw == null) {
271
+ return {
272
+ ok: true,
273
+ value: void 0
274
+ };
275
+ }
276
+ return schema.parse(raw, opts);
277
+ },
278
+ json: (parsed, opts) => {
279
+ if ((opts == null ? void 0 : opts.omitUndefined) && parsed === void 0) {
280
+ return {
281
+ ok: true,
282
+ value: void 0
283
+ };
284
+ }
285
+ if (parsed == null) {
286
+ return {
287
+ ok: true,
288
+ value: null
289
+ };
290
+ }
291
+ return schema.json(parsed, opts);
292
+ },
293
+ getType: () => SchemaType.OPTIONAL
294
+ };
295
+ return {
296
+ ...baseSchema,
297
+ ...getSchemaUtils(baseSchema)
298
+ };
299
+ }
300
+ function optionalNullable(schema) {
301
+ const baseSchema = {
302
+ parse: (raw, opts) => {
303
+ if (raw === void 0) {
304
+ return {
305
+ ok: true,
306
+ value: void 0
307
+ };
308
+ }
309
+ if (raw === null) {
310
+ return {
311
+ ok: true,
312
+ value: null
313
+ };
314
+ }
315
+ return schema.parse(raw, opts);
316
+ },
317
+ json: (parsed, opts) => {
318
+ if (parsed === void 0) {
319
+ return {
320
+ ok: true,
321
+ value: void 0
322
+ };
323
+ }
324
+ if (parsed === null) {
325
+ return {
326
+ ok: true,
327
+ value: null
328
+ };
329
+ }
330
+ return schema.json(parsed, opts);
331
+ },
332
+ getType: () => SchemaType.OPTIONAL_NULLABLE
333
+ };
334
+ return {
335
+ ...baseSchema,
336
+ ...getSchemaUtils(baseSchema)
337
+ };
338
+ }
339
+ function transform(schema, transformer) {
340
+ const baseSchema = {
341
+ parse: (raw, opts) => {
342
+ const parsed = schema.parse(raw, opts);
343
+ if (!parsed.ok) {
344
+ return parsed;
345
+ }
346
+ return {
347
+ ok: true,
348
+ value: transformer.transform(parsed.value)
349
+ };
350
+ },
351
+ json: (transformed, opts) => {
352
+ const parsed = transformer.untransform(transformed);
353
+ return schema.json(parsed, opts);
354
+ },
355
+ getType: () => schema.getType()
356
+ };
357
+ return {
358
+ ...baseSchema,
359
+ ...getSchemaUtils(baseSchema)
360
+ };
361
+ }
362
+
363
+ // src/core/schemas/builders/bigint/bigint.ts
364
+ function bigint() {
365
+ const baseSchema = {
366
+ parse: (raw, { breadcrumbsPrefix = [] } = {}) => {
367
+ if (typeof raw === "bigint") {
368
+ return {
369
+ ok: true,
370
+ value: raw
371
+ };
372
+ }
373
+ if (typeof raw === "number") {
374
+ return {
375
+ ok: true,
376
+ value: BigInt(raw)
377
+ };
378
+ }
379
+ return {
380
+ ok: false,
381
+ errors: [
382
+ {
383
+ path: breadcrumbsPrefix,
384
+ message: getErrorMessageForIncorrectType(raw, "bigint | number")
385
+ }
386
+ ]
387
+ };
388
+ },
389
+ json: (bigint2, { breadcrumbsPrefix = [] } = {}) => {
390
+ if (typeof bigint2 !== "bigint") {
391
+ return {
392
+ ok: false,
393
+ errors: [
394
+ {
395
+ path: breadcrumbsPrefix,
396
+ message: getErrorMessageForIncorrectType(bigint2, "bigint")
397
+ }
398
+ ]
399
+ };
400
+ }
401
+ return {
402
+ ok: true,
403
+ value: bigint2
404
+ };
405
+ },
406
+ getType: () => SchemaType.BIGINT
407
+ };
408
+ return {
409
+ ...maybeSkipValidation(baseSchema),
410
+ ...getSchemaUtils(baseSchema)
411
+ };
412
+ }
413
+
414
+ // src/core/schemas/builders/date/date.ts
415
+ 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)?)?)?)?$/;
416
+ function date() {
417
+ const baseSchema = {
418
+ parse: (raw, { breadcrumbsPrefix = [] } = {}) => {
419
+ if (typeof raw !== "string") {
420
+ return {
421
+ ok: false,
422
+ errors: [
423
+ {
424
+ path: breadcrumbsPrefix,
425
+ message: getErrorMessageForIncorrectType(raw, "string")
426
+ }
427
+ ]
428
+ };
429
+ }
430
+ if (!ISO_8601_REGEX.test(raw)) {
431
+ return {
432
+ ok: false,
433
+ errors: [
434
+ {
435
+ path: breadcrumbsPrefix,
436
+ message: getErrorMessageForIncorrectType(raw, "ISO 8601 date string")
437
+ }
438
+ ]
439
+ };
440
+ }
441
+ return {
442
+ ok: true,
443
+ value: new Date(raw)
444
+ };
445
+ },
446
+ json: (date2, { breadcrumbsPrefix = [] } = {}) => {
447
+ if (date2 instanceof Date) {
448
+ return {
449
+ ok: true,
450
+ value: date2.toISOString()
451
+ };
452
+ } else {
453
+ return {
454
+ ok: false,
455
+ errors: [
456
+ {
457
+ path: breadcrumbsPrefix,
458
+ message: getErrorMessageForIncorrectType(date2, "Date object")
459
+ }
460
+ ]
461
+ };
462
+ }
463
+ },
464
+ getType: () => SchemaType.DATE
465
+ };
466
+ return {
467
+ ...maybeSkipValidation(baseSchema),
468
+ ...getSchemaUtils(baseSchema)
469
+ };
470
+ }
471
+
472
+ // src/core/schemas/utils/createIdentitySchemaCreator.ts
473
+ function createIdentitySchemaCreator(schemaType, validate) {
474
+ return () => {
475
+ const baseSchema = {
476
+ parse: validate,
477
+ json: validate,
478
+ getType: () => schemaType
479
+ };
480
+ return {
481
+ ...maybeSkipValidation(baseSchema),
482
+ ...getSchemaUtils(baseSchema)
483
+ };
484
+ };
485
+ }
486
+
487
+ // src/core/schemas/builders/enum/enum.ts
488
+ function enum_(values) {
489
+ const validValues = new Set(values);
490
+ const schemaCreator = createIdentitySchemaCreator(
491
+ SchemaType.ENUM,
492
+ (value, { allowUnrecognizedEnumValues, breadcrumbsPrefix = [] } = {}) => {
493
+ if (typeof value !== "string") {
494
+ return {
495
+ ok: false,
496
+ errors: [
497
+ {
498
+ path: breadcrumbsPrefix,
499
+ message: getErrorMessageForIncorrectType(value, "string")
500
+ }
501
+ ]
502
+ };
503
+ }
504
+ if (!validValues.has(value) && !allowUnrecognizedEnumValues) {
505
+ return {
506
+ ok: false,
507
+ errors: [
508
+ {
509
+ path: breadcrumbsPrefix,
510
+ message: getErrorMessageForIncorrectType(value, "enum")
511
+ }
512
+ ]
513
+ };
514
+ }
515
+ return {
516
+ ok: true,
517
+ value
518
+ };
519
+ }
520
+ );
521
+ return schemaCreator();
522
+ }
523
+
524
+ // src/core/schemas/builders/lazy/lazy.ts
525
+ function lazy(getter) {
526
+ const baseSchema = constructLazyBaseSchema(getter);
527
+ return {
528
+ ...baseSchema,
529
+ ...getSchemaUtils(baseSchema)
530
+ };
531
+ }
532
+ function constructLazyBaseSchema(getter) {
533
+ return {
534
+ parse: (raw, opts) => getMemoizedSchema(getter).parse(raw, opts),
535
+ json: (parsed, opts) => getMemoizedSchema(getter).json(parsed, opts),
536
+ getType: () => getMemoizedSchema(getter).getType()
537
+ };
538
+ }
539
+ function getMemoizedSchema(getter) {
540
+ const castedGetter = getter;
541
+ if (castedGetter.__zurg_memoized == null) {
542
+ castedGetter.__zurg_memoized = getter();
543
+ }
544
+ return castedGetter.__zurg_memoized;
545
+ }
546
+
547
+ // src/core/schemas/utils/entries.ts
548
+ function entries(object2) {
549
+ return Object.entries(object2);
550
+ }
551
+
552
+ // src/core/schemas/utils/filterObject.ts
553
+ function filterObject(obj, keysToInclude) {
554
+ const keysToIncludeSet = new Set(keysToInclude);
555
+ return Object.entries(obj).reduce(
556
+ (acc, [key, value]) => {
557
+ if (keysToIncludeSet.has(key)) {
558
+ acc[key] = value;
559
+ }
560
+ return acc;
561
+ },
562
+ {}
563
+ );
564
+ }
565
+
566
+ // src/core/schemas/utils/isPlainObject.ts
567
+ function isPlainObject(value) {
568
+ if (typeof value !== "object" || value === null) {
569
+ return false;
570
+ }
571
+ if (Object.getPrototypeOf(value) === null) {
572
+ return true;
573
+ }
574
+ let proto = value;
575
+ while (Object.getPrototypeOf(proto) !== null) {
576
+ proto = Object.getPrototypeOf(proto);
577
+ }
578
+ return Object.getPrototypeOf(value) === proto;
579
+ }
580
+
581
+ // src/core/schemas/utils/keys.ts
582
+ function keys(object2) {
583
+ return Object.keys(object2);
584
+ }
585
+
586
+ // src/core/schemas/utils/partition.ts
587
+ function partition(items, predicate) {
588
+ const trueItems = [], falseItems = [];
589
+ for (const item of items) {
590
+ if (predicate(item)) {
591
+ trueItems.push(item);
592
+ } else {
593
+ falseItems.push(item);
594
+ }
595
+ }
596
+ return [trueItems, falseItems];
597
+ }
598
+
599
+ // src/core/schemas/builders/object-like/getObjectLikeUtils.ts
600
+ function getObjectLikeUtils(schema) {
601
+ return {
602
+ withParsedProperties: (properties) => withParsedProperties(schema, properties)
603
+ };
604
+ }
605
+ function withParsedProperties(objectLike, properties) {
606
+ const objectSchema = {
607
+ parse: (raw, opts) => {
608
+ const parsedObject = objectLike.parse(raw, opts);
609
+ if (!parsedObject.ok) {
610
+ return parsedObject;
611
+ }
612
+ const additionalProperties = Object.entries(properties).reduce(
613
+ (processed, [key, value]) => {
614
+ return {
615
+ ...processed,
616
+ [key]: typeof value === "function" ? value(parsedObject.value) : value
617
+ };
618
+ },
619
+ {}
620
+ );
621
+ return {
622
+ ok: true,
623
+ value: {
624
+ ...parsedObject.value,
625
+ ...additionalProperties
626
+ }
627
+ };
628
+ },
629
+ json: (parsed, opts) => {
630
+ if (!isPlainObject(parsed)) {
631
+ return {
632
+ ok: false,
633
+ errors: [
634
+ {
635
+ path: (opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [],
636
+ message: getErrorMessageForIncorrectType(parsed, "object")
637
+ }
638
+ ]
639
+ };
640
+ }
641
+ const addedPropertyKeys = new Set(Object.keys(properties));
642
+ const parsedWithoutAddedProperties = filterObject(
643
+ parsed,
644
+ Object.keys(parsed).filter((key) => !addedPropertyKeys.has(key))
645
+ );
646
+ return objectLike.json(parsedWithoutAddedProperties, opts);
647
+ },
648
+ getType: () => objectLike.getType()
649
+ };
650
+ return {
651
+ ...objectSchema,
652
+ ...getSchemaUtils(objectSchema),
653
+ ...getObjectLikeUtils(objectSchema)
654
+ };
655
+ }
656
+
657
+ // src/core/schemas/builders/object/property.ts
658
+ function property(rawKey, valueSchema) {
659
+ return {
660
+ rawKey,
661
+ valueSchema,
662
+ isProperty: true
663
+ };
664
+ }
665
+ function isProperty(maybeProperty) {
666
+ return maybeProperty.isProperty;
667
+ }
668
+
669
+ // src/core/schemas/builders/object/object.ts
670
+ function object(schemas) {
671
+ const baseSchema = {
672
+ _getRawProperties: () => Object.entries(schemas).map(
673
+ ([parsedKey, propertySchema]) => isProperty(propertySchema) ? propertySchema.rawKey : parsedKey
674
+ ),
675
+ _getParsedProperties: () => keys(schemas),
676
+ parse: (raw, opts) => {
677
+ const rawKeyToProperty = {};
678
+ const requiredKeys = [];
679
+ for (const [parsedKey, schemaOrObjectProperty] of entries(schemas)) {
680
+ const rawKey = isProperty(schemaOrObjectProperty) ? schemaOrObjectProperty.rawKey : parsedKey;
681
+ const valueSchema = isProperty(schemaOrObjectProperty) ? schemaOrObjectProperty.valueSchema : schemaOrObjectProperty;
682
+ const property2 = {
683
+ rawKey,
684
+ parsedKey,
685
+ valueSchema
686
+ };
687
+ rawKeyToProperty[rawKey] = property2;
688
+ if (isSchemaRequired(valueSchema)) {
689
+ requiredKeys.push(rawKey);
690
+ }
691
+ }
692
+ return validateAndTransformObject({
693
+ value: raw,
694
+ requiredKeys,
695
+ getProperty: (rawKey) => {
696
+ const property2 = rawKeyToProperty[rawKey];
697
+ if (property2 == null) {
698
+ return void 0;
699
+ }
700
+ return {
701
+ transformedKey: property2.parsedKey,
702
+ transform: (propertyValue) => property2.valueSchema.parse(propertyValue, {
703
+ ...opts,
704
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], rawKey]
705
+ })
706
+ };
707
+ },
708
+ unrecognizedObjectKeys: opts == null ? void 0 : opts.unrecognizedObjectKeys,
709
+ skipValidation: opts == null ? void 0 : opts.skipValidation,
710
+ breadcrumbsPrefix: opts == null ? void 0 : opts.breadcrumbsPrefix,
711
+ omitUndefined: opts == null ? void 0 : opts.omitUndefined
712
+ });
713
+ },
714
+ json: (parsed, opts) => {
715
+ const requiredKeys = [];
716
+ for (const [parsedKey, schemaOrObjectProperty] of entries(schemas)) {
717
+ const valueSchema = isProperty(schemaOrObjectProperty) ? schemaOrObjectProperty.valueSchema : schemaOrObjectProperty;
718
+ if (isSchemaRequired(valueSchema)) {
719
+ requiredKeys.push(parsedKey);
720
+ }
721
+ }
722
+ return validateAndTransformObject({
723
+ value: parsed,
724
+ requiredKeys,
725
+ getProperty: (parsedKey) => {
726
+ const property2 = schemas[parsedKey];
727
+ if (property2 == null) {
728
+ return void 0;
729
+ }
730
+ if (isProperty(property2)) {
731
+ return {
732
+ transformedKey: property2.rawKey,
733
+ transform: (propertyValue) => property2.valueSchema.json(propertyValue, {
734
+ ...opts,
735
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], parsedKey]
736
+ })
737
+ };
738
+ } else {
739
+ return {
740
+ transformedKey: parsedKey,
741
+ transform: (propertyValue) => property2.json(propertyValue, {
742
+ ...opts,
743
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], parsedKey]
744
+ })
745
+ };
746
+ }
747
+ },
748
+ unrecognizedObjectKeys: opts == null ? void 0 : opts.unrecognizedObjectKeys,
749
+ skipValidation: opts == null ? void 0 : opts.skipValidation,
750
+ breadcrumbsPrefix: opts == null ? void 0 : opts.breadcrumbsPrefix,
751
+ omitUndefined: opts == null ? void 0 : opts.omitUndefined
752
+ });
753
+ },
754
+ getType: () => SchemaType.OBJECT
755
+ };
756
+ return {
757
+ ...maybeSkipValidation(baseSchema),
758
+ ...getSchemaUtils(baseSchema),
759
+ ...getObjectLikeUtils(baseSchema),
760
+ ...getObjectUtils(baseSchema)
761
+ };
762
+ }
763
+ function validateAndTransformObject({
764
+ value,
765
+ requiredKeys,
766
+ getProperty,
767
+ unrecognizedObjectKeys = "fail",
768
+ skipValidation = false,
769
+ breadcrumbsPrefix = []
770
+ }) {
771
+ if (!isPlainObject(value)) {
772
+ return {
773
+ ok: false,
774
+ errors: [
775
+ {
776
+ path: breadcrumbsPrefix,
777
+ message: getErrorMessageForIncorrectType(value, "object")
778
+ }
779
+ ]
780
+ };
781
+ }
782
+ const missingRequiredKeys = new Set(requiredKeys);
783
+ const errors = [];
784
+ const transformed = {};
785
+ for (const [preTransformedKey, preTransformedItemValue] of Object.entries(value)) {
786
+ const property2 = getProperty(preTransformedKey);
787
+ if (property2 != null) {
788
+ missingRequiredKeys.delete(preTransformedKey);
789
+ const value2 = property2.transform(preTransformedItemValue);
790
+ if (value2.ok) {
791
+ transformed[property2.transformedKey] = value2.value;
792
+ } else {
793
+ transformed[preTransformedKey] = preTransformedItemValue;
794
+ errors.push(...value2.errors);
795
+ }
796
+ } else {
797
+ switch (unrecognizedObjectKeys) {
798
+ case "fail":
799
+ errors.push({
800
+ path: [...breadcrumbsPrefix, preTransformedKey],
801
+ message: `Unexpected key "${preTransformedKey}"`
802
+ });
803
+ break;
804
+ case "strip":
805
+ break;
806
+ case "passthrough":
807
+ transformed[preTransformedKey] = preTransformedItemValue;
808
+ break;
809
+ }
810
+ }
811
+ }
812
+ errors.push(
813
+ ...requiredKeys.filter((key) => missingRequiredKeys.has(key)).map((key) => ({
814
+ path: breadcrumbsPrefix,
815
+ message: `Missing required key "${key}"`
816
+ }))
817
+ );
818
+ if (errors.length === 0 || skipValidation) {
819
+ return {
820
+ ok: true,
821
+ value: transformed
822
+ };
823
+ } else {
824
+ return {
825
+ ok: false,
826
+ errors
827
+ };
828
+ }
829
+ }
830
+ function getObjectUtils(schema) {
831
+ return {
832
+ extend: (extension) => {
833
+ const baseSchema = {
834
+ _getParsedProperties: () => [...schema._getParsedProperties(), ...extension._getParsedProperties()],
835
+ _getRawProperties: () => [...schema._getRawProperties(), ...extension._getRawProperties()],
836
+ parse: (raw, opts) => {
837
+ return validateAndTransformExtendedObject({
838
+ extensionKeys: extension._getRawProperties(),
839
+ value: raw,
840
+ transformBase: (rawBase) => schema.parse(rawBase, opts),
841
+ transformExtension: (rawExtension) => extension.parse(rawExtension, opts)
842
+ });
843
+ },
844
+ json: (parsed, opts) => {
845
+ return validateAndTransformExtendedObject({
846
+ extensionKeys: extension._getParsedProperties(),
847
+ value: parsed,
848
+ transformBase: (parsedBase) => schema.json(parsedBase, opts),
849
+ transformExtension: (parsedExtension) => extension.json(parsedExtension, opts)
850
+ });
851
+ },
852
+ getType: () => SchemaType.OBJECT
853
+ };
854
+ return {
855
+ ...baseSchema,
856
+ ...getSchemaUtils(baseSchema),
857
+ ...getObjectLikeUtils(baseSchema),
858
+ ...getObjectUtils(baseSchema)
859
+ };
860
+ },
861
+ passthrough: () => {
862
+ const baseSchema = {
863
+ _getParsedProperties: () => schema._getParsedProperties(),
864
+ _getRawProperties: () => schema._getRawProperties(),
865
+ parse: (raw, opts) => {
866
+ const transformed = schema.parse(raw, { ...opts, unrecognizedObjectKeys: "passthrough" });
867
+ if (!transformed.ok) {
868
+ return transformed;
869
+ }
870
+ return {
871
+ ok: true,
872
+ value: {
873
+ ...raw,
874
+ ...transformed.value
875
+ }
876
+ };
877
+ },
878
+ json: (parsed, opts) => {
879
+ const transformed = schema.json(parsed, { ...opts, unrecognizedObjectKeys: "passthrough" });
880
+ if (!transformed.ok) {
881
+ return transformed;
882
+ }
883
+ return {
884
+ ok: true,
885
+ value: {
886
+ ...parsed,
887
+ ...transformed.value
888
+ }
889
+ };
890
+ },
891
+ getType: () => SchemaType.OBJECT
892
+ };
893
+ return {
894
+ ...baseSchema,
895
+ ...getSchemaUtils(baseSchema),
896
+ ...getObjectLikeUtils(baseSchema),
897
+ ...getObjectUtils(baseSchema)
898
+ };
899
+ }
900
+ };
901
+ }
902
+ function validateAndTransformExtendedObject({
903
+ extensionKeys,
904
+ value,
905
+ transformBase,
906
+ transformExtension
907
+ }) {
908
+ const extensionPropertiesSet = new Set(extensionKeys);
909
+ const [extensionProperties, baseProperties] = partition(
910
+ keys(value),
911
+ (key) => extensionPropertiesSet.has(key)
912
+ );
913
+ const transformedBase = transformBase(filterObject(value, baseProperties));
914
+ const transformedExtension = transformExtension(filterObject(value, extensionProperties));
915
+ if (transformedBase.ok && transformedExtension.ok) {
916
+ return {
917
+ ok: true,
918
+ value: {
919
+ ...transformedBase.value,
920
+ ...transformedExtension.value
921
+ }
922
+ };
923
+ } else {
924
+ return {
925
+ ok: false,
926
+ errors: [
927
+ ...transformedBase.ok ? [] : transformedBase.errors,
928
+ ...transformedExtension.ok ? [] : transformedExtension.errors
929
+ ]
930
+ };
931
+ }
932
+ }
933
+ function isSchemaRequired(schema) {
934
+ return !isSchemaOptional(schema);
935
+ }
936
+ function isSchemaOptional(schema) {
937
+ switch (schema.getType()) {
938
+ case SchemaType.ANY:
939
+ case SchemaType.UNKNOWN:
940
+ case SchemaType.OPTIONAL:
941
+ case SchemaType.OPTIONAL_NULLABLE:
942
+ return true;
943
+ default:
944
+ return false;
945
+ }
946
+ }
947
+
948
+ // src/core/schemas/builders/object/objectWithoutOptionalProperties.ts
949
+ function objectWithoutOptionalProperties(schemas) {
950
+ return object(schemas);
951
+ }
952
+
953
+ // src/core/schemas/builders/lazy/lazyObject.ts
954
+ function lazyObject(getter) {
955
+ const baseSchema = {
956
+ ...constructLazyBaseSchema(getter),
957
+ _getRawProperties: () => getMemoizedSchema(getter)._getRawProperties(),
958
+ _getParsedProperties: () => getMemoizedSchema(getter)._getParsedProperties()
959
+ };
960
+ return {
961
+ ...baseSchema,
962
+ ...getSchemaUtils(baseSchema),
963
+ ...getObjectLikeUtils(baseSchema),
964
+ ...getObjectUtils(baseSchema)
965
+ };
966
+ }
967
+
968
+ // src/core/schemas/builders/list/list.ts
969
+ function list(schema) {
970
+ const baseSchema = {
971
+ parse: (raw, opts) => validateAndTransformArray(
972
+ raw,
973
+ (item, index) => schema.parse(item, {
974
+ ...opts,
975
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], `[${index}]`]
976
+ })
977
+ ),
978
+ json: (parsed, opts) => validateAndTransformArray(
979
+ parsed,
980
+ (item, index) => schema.json(item, {
981
+ ...opts,
982
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], `[${index}]`]
983
+ })
984
+ ),
985
+ getType: () => SchemaType.LIST
986
+ };
987
+ return {
988
+ ...maybeSkipValidation(baseSchema),
989
+ ...getSchemaUtils(baseSchema)
990
+ };
991
+ }
992
+ function validateAndTransformArray(value, transformItem) {
993
+ if (!Array.isArray(value)) {
994
+ return {
995
+ ok: false,
996
+ errors: [
997
+ {
998
+ message: getErrorMessageForIncorrectType(value, "list"),
999
+ path: []
1000
+ }
1001
+ ]
1002
+ };
1003
+ }
1004
+ const maybeValidItems = value.map((item, index) => transformItem(item, index));
1005
+ return maybeValidItems.reduce(
1006
+ (acc, item) => {
1007
+ if (acc.ok && item.ok) {
1008
+ return {
1009
+ ok: true,
1010
+ value: [...acc.value, item.value]
1011
+ };
1012
+ }
1013
+ const errors = [];
1014
+ if (!acc.ok) {
1015
+ errors.push(...acc.errors);
1016
+ }
1017
+ if (!item.ok) {
1018
+ errors.push(...item.errors);
1019
+ }
1020
+ return {
1021
+ ok: false,
1022
+ errors
1023
+ };
1024
+ },
1025
+ { ok: true, value: [] }
1026
+ );
1027
+ }
1028
+
1029
+ // src/core/schemas/builders/literals/stringLiteral.ts
1030
+ function stringLiteral(literal) {
1031
+ const schemaCreator = createIdentitySchemaCreator(
1032
+ SchemaType.STRING_LITERAL,
1033
+ (value, { breadcrumbsPrefix = [] } = {}) => {
1034
+ if (value === literal) {
1035
+ return {
1036
+ ok: true,
1037
+ value: literal
1038
+ };
1039
+ } else {
1040
+ return {
1041
+ ok: false,
1042
+ errors: [
1043
+ {
1044
+ path: breadcrumbsPrefix,
1045
+ message: getErrorMessageForIncorrectType(value, `"${literal}"`)
1046
+ }
1047
+ ]
1048
+ };
1049
+ }
1050
+ }
1051
+ );
1052
+ return schemaCreator();
1053
+ }
1054
+
1055
+ // src/core/schemas/builders/literals/booleanLiteral.ts
1056
+ function booleanLiteral(literal) {
1057
+ const schemaCreator = createIdentitySchemaCreator(
1058
+ SchemaType.BOOLEAN_LITERAL,
1059
+ (value, { breadcrumbsPrefix = [] } = {}) => {
1060
+ if (value === literal) {
1061
+ return {
1062
+ ok: true,
1063
+ value: literal
1064
+ };
1065
+ } else {
1066
+ return {
1067
+ ok: false,
1068
+ errors: [
1069
+ {
1070
+ path: breadcrumbsPrefix,
1071
+ message: getErrorMessageForIncorrectType(value, `${literal.toString()}`)
1072
+ }
1073
+ ]
1074
+ };
1075
+ }
1076
+ }
1077
+ );
1078
+ return schemaCreator();
1079
+ }
1080
+
1081
+ // src/core/schemas/builders/primitives/any.ts
1082
+ var any = createIdentitySchemaCreator(SchemaType.ANY, (value) => ({ ok: true, value }));
1083
+
1084
+ // src/core/schemas/builders/primitives/boolean.ts
1085
+ var boolean = createIdentitySchemaCreator(
1086
+ SchemaType.BOOLEAN,
1087
+ (value, { breadcrumbsPrefix = [] } = {}) => {
1088
+ if (typeof value === "boolean") {
1089
+ return {
1090
+ ok: true,
1091
+ value
1092
+ };
1093
+ } else {
1094
+ return {
1095
+ ok: false,
1096
+ errors: [
1097
+ {
1098
+ path: breadcrumbsPrefix,
1099
+ message: getErrorMessageForIncorrectType(value, "boolean")
1100
+ }
1101
+ ]
1102
+ };
1103
+ }
1104
+ }
1105
+ );
1106
+
1107
+ // src/core/schemas/builders/primitives/number.ts
1108
+ var number = createIdentitySchemaCreator(
1109
+ SchemaType.NUMBER,
1110
+ (value, { breadcrumbsPrefix = [] } = {}) => {
1111
+ if (typeof value === "number") {
1112
+ return {
1113
+ ok: true,
1114
+ value
1115
+ };
1116
+ } else {
1117
+ return {
1118
+ ok: false,
1119
+ errors: [
1120
+ {
1121
+ path: breadcrumbsPrefix,
1122
+ message: getErrorMessageForIncorrectType(value, "number")
1123
+ }
1124
+ ]
1125
+ };
1126
+ }
1127
+ }
1128
+ );
1129
+
1130
+ // src/core/schemas/builders/primitives/string.ts
1131
+ var string = createIdentitySchemaCreator(
1132
+ SchemaType.STRING,
1133
+ (value, { breadcrumbsPrefix = [] } = {}) => {
1134
+ if (typeof value === "string") {
1135
+ return {
1136
+ ok: true,
1137
+ value
1138
+ };
1139
+ } else {
1140
+ return {
1141
+ ok: false,
1142
+ errors: [
1143
+ {
1144
+ path: breadcrumbsPrefix,
1145
+ message: getErrorMessageForIncorrectType(value, "string")
1146
+ }
1147
+ ]
1148
+ };
1149
+ }
1150
+ }
1151
+ );
1152
+
1153
+ // src/core/schemas/builders/primitives/unknown.ts
1154
+ var unknown = createIdentitySchemaCreator(SchemaType.UNKNOWN, (value) => ({ ok: true, value }));
1155
+
1156
+ // src/core/schemas/builders/record/record.ts
1157
+ function record(keySchema, valueSchema) {
1158
+ const baseSchema = {
1159
+ parse: (raw, opts) => {
1160
+ return validateAndTransformRecord({
1161
+ value: raw,
1162
+ isKeyNumeric: keySchema.getType() === SchemaType.NUMBER,
1163
+ transformKey: (key) => keySchema.parse(key, {
1164
+ ...opts,
1165
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], `${key} (key)`]
1166
+ }),
1167
+ transformValue: (value, key) => valueSchema.parse(value, {
1168
+ ...opts,
1169
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], `${key}`]
1170
+ }),
1171
+ breadcrumbsPrefix: opts == null ? void 0 : opts.breadcrumbsPrefix
1172
+ });
1173
+ },
1174
+ json: (parsed, opts) => {
1175
+ return validateAndTransformRecord({
1176
+ value: parsed,
1177
+ isKeyNumeric: keySchema.getType() === SchemaType.NUMBER,
1178
+ transformKey: (key) => keySchema.json(key, {
1179
+ ...opts,
1180
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], `${key} (key)`]
1181
+ }),
1182
+ transformValue: (value, key) => valueSchema.json(value, {
1183
+ ...opts,
1184
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], `${key}`]
1185
+ }),
1186
+ breadcrumbsPrefix: opts == null ? void 0 : opts.breadcrumbsPrefix
1187
+ });
1188
+ },
1189
+ getType: () => SchemaType.RECORD
1190
+ };
1191
+ return {
1192
+ ...maybeSkipValidation(baseSchema),
1193
+ ...getSchemaUtils(baseSchema)
1194
+ };
1195
+ }
1196
+ function validateAndTransformRecord({
1197
+ value,
1198
+ isKeyNumeric,
1199
+ transformKey,
1200
+ transformValue,
1201
+ breadcrumbsPrefix = []
1202
+ }) {
1203
+ if (!isPlainObject(value)) {
1204
+ return {
1205
+ ok: false,
1206
+ errors: [
1207
+ {
1208
+ path: breadcrumbsPrefix,
1209
+ message: getErrorMessageForIncorrectType(value, "object")
1210
+ }
1211
+ ]
1212
+ };
1213
+ }
1214
+ return entries(value).reduce(
1215
+ (accPromise, [stringKey, value2]) => {
1216
+ if (value2 === void 0) {
1217
+ return accPromise;
1218
+ }
1219
+ const acc = accPromise;
1220
+ let key = stringKey;
1221
+ if (isKeyNumeric) {
1222
+ const numberKey = stringKey.length > 0 ? Number(stringKey) : NaN;
1223
+ if (!isNaN(numberKey)) {
1224
+ key = numberKey;
1225
+ }
1226
+ }
1227
+ const transformedKey = transformKey(key);
1228
+ const transformedValue = transformValue(value2, key);
1229
+ if (acc.ok && transformedKey.ok && transformedValue.ok) {
1230
+ return {
1231
+ ok: true,
1232
+ value: {
1233
+ ...acc.value,
1234
+ [transformedKey.value]: transformedValue.value
1235
+ }
1236
+ };
1237
+ }
1238
+ const errors = [];
1239
+ if (!acc.ok) {
1240
+ errors.push(...acc.errors);
1241
+ }
1242
+ if (!transformedKey.ok) {
1243
+ errors.push(...transformedKey.errors);
1244
+ }
1245
+ if (!transformedValue.ok) {
1246
+ errors.push(...transformedValue.errors);
1247
+ }
1248
+ return {
1249
+ ok: false,
1250
+ errors
1251
+ };
1252
+ },
1253
+ { ok: true, value: {} }
1254
+ );
1255
+ }
1256
+
1257
+ // src/core/schemas/builders/set/set.ts
1258
+ function set(schema) {
1259
+ const listSchema = list(schema);
1260
+ const baseSchema = {
1261
+ parse: (raw, opts) => {
1262
+ const parsedList = listSchema.parse(raw, opts);
1263
+ if (parsedList.ok) {
1264
+ return {
1265
+ ok: true,
1266
+ value: new Set(parsedList.value)
1267
+ };
1268
+ } else {
1269
+ return parsedList;
1270
+ }
1271
+ },
1272
+ json: (parsed, opts) => {
1273
+ if (!(parsed instanceof Set)) {
1274
+ return {
1275
+ ok: false,
1276
+ errors: [
1277
+ {
1278
+ path: (opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [],
1279
+ message: getErrorMessageForIncorrectType(parsed, "Set")
1280
+ }
1281
+ ]
1282
+ };
1283
+ }
1284
+ const jsonList = listSchema.json([...parsed], opts);
1285
+ return jsonList;
1286
+ },
1287
+ getType: () => SchemaType.SET
1288
+ };
1289
+ return {
1290
+ ...maybeSkipValidation(baseSchema),
1291
+ ...getSchemaUtils(baseSchema)
1292
+ };
1293
+ }
1294
+
1295
+ // src/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.ts
1296
+ function undiscriminatedUnion(schemas) {
1297
+ const baseSchema = {
1298
+ parse: (raw, opts) => {
1299
+ return validateAndTransformUndiscriminatedUnion(
1300
+ (schema, opts2) => schema.parse(raw, opts2),
1301
+ schemas,
1302
+ opts
1303
+ );
1304
+ },
1305
+ json: (parsed, opts) => {
1306
+ return validateAndTransformUndiscriminatedUnion(
1307
+ (schema, opts2) => schema.json(parsed, opts2),
1308
+ schemas,
1309
+ opts
1310
+ );
1311
+ },
1312
+ getType: () => SchemaType.UNDISCRIMINATED_UNION
1313
+ };
1314
+ return {
1315
+ ...maybeSkipValidation(baseSchema),
1316
+ ...getSchemaUtils(baseSchema)
1317
+ };
1318
+ }
1319
+ function validateAndTransformUndiscriminatedUnion(transform2, schemas, opts) {
1320
+ const errors = [];
1321
+ for (const [index, schema] of schemas.entries()) {
1322
+ const transformed = transform2(schema, { ...opts, skipValidation: false });
1323
+ if (transformed.ok) {
1324
+ return transformed;
1325
+ } else {
1326
+ for (const error of transformed.errors) {
1327
+ errors.push({
1328
+ path: error.path,
1329
+ message: `[Variant ${index}] ${error.message}`
1330
+ });
1331
+ }
1332
+ }
1333
+ }
1334
+ return {
1335
+ ok: false,
1336
+ errors
1337
+ };
1338
+ }
1339
+
1340
+ // src/core/schemas/builders/union/discriminant.ts
1341
+ function discriminant(parsedDiscriminant, rawDiscriminant) {
1342
+ return {
1343
+ parsedDiscriminant,
1344
+ rawDiscriminant
1345
+ };
1346
+ }
1347
+
1348
+ // src/core/schemas/builders/union/union.ts
1349
+ function union(discriminant2, union2) {
1350
+ const rawDiscriminant = typeof discriminant2 === "string" ? discriminant2 : discriminant2.rawDiscriminant;
1351
+ const parsedDiscriminant = typeof discriminant2 === "string" ? discriminant2 : discriminant2.parsedDiscriminant;
1352
+ const discriminantValueSchema = enum_(keys(union2));
1353
+ const baseSchema = {
1354
+ parse: (raw, opts) => {
1355
+ return transformAndValidateUnion({
1356
+ value: raw,
1357
+ discriminant: rawDiscriminant,
1358
+ transformedDiscriminant: parsedDiscriminant,
1359
+ transformDiscriminantValue: (discriminantValue) => discriminantValueSchema.parse(discriminantValue, {
1360
+ allowUnrecognizedEnumValues: opts == null ? void 0 : opts.allowUnrecognizedUnionMembers,
1361
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], rawDiscriminant]
1362
+ }),
1363
+ getAdditionalPropertiesSchema: (discriminantValue) => union2[discriminantValue],
1364
+ allowUnrecognizedUnionMembers: opts == null ? void 0 : opts.allowUnrecognizedUnionMembers,
1365
+ transformAdditionalProperties: (additionalProperties, additionalPropertiesSchema) => additionalPropertiesSchema.parse(additionalProperties, opts),
1366
+ breadcrumbsPrefix: opts == null ? void 0 : opts.breadcrumbsPrefix
1367
+ });
1368
+ },
1369
+ json: (parsed, opts) => {
1370
+ return transformAndValidateUnion({
1371
+ value: parsed,
1372
+ discriminant: parsedDiscriminant,
1373
+ transformedDiscriminant: rawDiscriminant,
1374
+ transformDiscriminantValue: (discriminantValue) => discriminantValueSchema.json(discriminantValue, {
1375
+ allowUnrecognizedEnumValues: opts == null ? void 0 : opts.allowUnrecognizedUnionMembers,
1376
+ breadcrumbsPrefix: [...(opts == null ? void 0 : opts.breadcrumbsPrefix) ?? [], parsedDiscriminant]
1377
+ }),
1378
+ getAdditionalPropertiesSchema: (discriminantValue) => union2[discriminantValue],
1379
+ allowUnrecognizedUnionMembers: opts == null ? void 0 : opts.allowUnrecognizedUnionMembers,
1380
+ transformAdditionalProperties: (additionalProperties, additionalPropertiesSchema) => additionalPropertiesSchema.json(additionalProperties, opts),
1381
+ breadcrumbsPrefix: opts == null ? void 0 : opts.breadcrumbsPrefix
1382
+ });
1383
+ },
1384
+ getType: () => SchemaType.UNION
1385
+ };
1386
+ return {
1387
+ ...maybeSkipValidation(baseSchema),
1388
+ ...getSchemaUtils(baseSchema),
1389
+ ...getObjectLikeUtils(baseSchema)
1390
+ };
1391
+ }
1392
+ function transformAndValidateUnion({
1393
+ value,
1394
+ discriminant: discriminant2,
1395
+ transformedDiscriminant,
1396
+ transformDiscriminantValue,
1397
+ getAdditionalPropertiesSchema,
1398
+ allowUnrecognizedUnionMembers = false,
1399
+ transformAdditionalProperties,
1400
+ breadcrumbsPrefix = []
1401
+ }) {
1402
+ if (!isPlainObject(value)) {
1403
+ return {
1404
+ ok: false,
1405
+ errors: [
1406
+ {
1407
+ path: breadcrumbsPrefix,
1408
+ message: getErrorMessageForIncorrectType(value, "object")
1409
+ }
1410
+ ]
1411
+ };
1412
+ }
1413
+ const { [discriminant2]: discriminantValue, ...additionalProperties } = value;
1414
+ if (discriminantValue == null) {
1415
+ return {
1416
+ ok: false,
1417
+ errors: [
1418
+ {
1419
+ path: breadcrumbsPrefix,
1420
+ message: `Missing discriminant ("${discriminant2}")`
1421
+ }
1422
+ ]
1423
+ };
1424
+ }
1425
+ const transformedDiscriminantValue = transformDiscriminantValue(discriminantValue);
1426
+ if (!transformedDiscriminantValue.ok) {
1427
+ return {
1428
+ ok: false,
1429
+ errors: transformedDiscriminantValue.errors
1430
+ };
1431
+ }
1432
+ const additionalPropertiesSchema = getAdditionalPropertiesSchema(transformedDiscriminantValue.value);
1433
+ if (additionalPropertiesSchema == null) {
1434
+ if (allowUnrecognizedUnionMembers) {
1435
+ return {
1436
+ ok: true,
1437
+ value: {
1438
+ [transformedDiscriminant]: transformedDiscriminantValue.value,
1439
+ ...additionalProperties
1440
+ }
1441
+ };
1442
+ } else {
1443
+ return {
1444
+ ok: false,
1445
+ errors: [
1446
+ {
1447
+ path: [...breadcrumbsPrefix, discriminant2],
1448
+ message: "Unexpected discriminant value"
1449
+ }
1450
+ ]
1451
+ };
1452
+ }
1453
+ }
1454
+ const transformedAdditionalProperties = transformAdditionalProperties(
1455
+ additionalProperties,
1456
+ additionalPropertiesSchema
1457
+ );
1458
+ if (!transformedAdditionalProperties.ok) {
1459
+ return transformedAdditionalProperties;
1460
+ }
1461
+ return {
1462
+ ok: true,
1463
+ value: {
1464
+ [transformedDiscriminant]: discriminantValue,
1465
+ ...transformedAdditionalProperties.value
1466
+ }
1467
+ };
1468
+ }
1469
+
1470
+ // src/serialization/types/RivetId.ts
1471
+ var RivetId = schemas_exports.string();
1472
+
1473
+ // src/serialization/types/CrashPolicy.ts
1474
+ var CrashPolicy = schemas_exports.enum_(["restart", "sleep", "destroy"]);
1475
+
1476
+ // src/serialization/types/Actor.ts
1477
+ var Actor = schemas_exports.object({
1478
+ actorId: schemas_exports.property("actor_id", RivetId),
1479
+ connectableTs: schemas_exports.property("connectable_ts", schemas_exports.number().optional()),
1480
+ crashPolicy: schemas_exports.property("crash_policy", CrashPolicy),
1481
+ createTs: schemas_exports.property("create_ts", schemas_exports.number()),
1482
+ datacenter: schemas_exports.string(),
1483
+ destroyTs: schemas_exports.property("destroy_ts", schemas_exports.number().optional()),
1484
+ error: schemas_exports.record(schemas_exports.string(), schemas_exports.unknown()).optional(),
1485
+ key: schemas_exports.string().optional(),
1486
+ name: schemas_exports.string(),
1487
+ namespaceId: schemas_exports.property("namespace_id", RivetId),
1488
+ pendingAllocationTs: schemas_exports.property("pending_allocation_ts", schemas_exports.number().optional()),
1489
+ rescheduleTs: schemas_exports.property("reschedule_ts", schemas_exports.number().optional()),
1490
+ runnerNameSelector: schemas_exports.property("runner_name_selector", schemas_exports.string()),
1491
+ sleepTs: schemas_exports.property("sleep_ts", schemas_exports.number().optional()),
1492
+ startTs: schemas_exports.property("start_ts", schemas_exports.number().optional())
1493
+ });
1494
+
1495
+ // src/serialization/types/ActorName.ts
1496
+ var ActorName = schemas_exports.object({
1497
+ metadata: schemas_exports.record(schemas_exports.string(), schemas_exports.unknown())
1498
+ });
1499
+
1500
+ // src/serialization/types/ActorsCreateResponse.ts
1501
+ var ActorsCreateResponse = schemas_exports.object({
1502
+ actor: Actor
1503
+ });
1504
+
1505
+ // src/serialization/types/ActorsDeleteResponse.ts
1506
+ var ActorsDeleteResponse = schemas_exports.record(schemas_exports.string(), schemas_exports.unknown());
1507
+
1508
+ // src/serialization/types/ActorsGetOrCreateResponse.ts
1509
+ var ActorsGetOrCreateResponse = schemas_exports.object({
1510
+ actor: Actor,
1511
+ created: schemas_exports.boolean()
1512
+ });
1513
+
1514
+ // src/serialization/types/ActorsKvGetResponse.ts
1515
+ var ActorsKvGetResponse = schemas_exports.object({
1516
+ updateTs: schemas_exports.property("update_ts", schemas_exports.number()),
1517
+ value: schemas_exports.string()
1518
+ });
1519
+
1520
+ // src/serialization/types/Pagination.ts
1521
+ var Pagination = schemas_exports.object({
1522
+ cursor: schemas_exports.string().optional()
1523
+ });
1524
+
1525
+ // src/serialization/types/ActorsListNamesResponse.ts
1526
+ var ActorsListNamesResponse = schemas_exports.object({
1527
+ names: schemas_exports.record(schemas_exports.string(), ActorName),
1528
+ pagination: Pagination
1529
+ });
1530
+
1531
+ // src/serialization/types/ActorsListResponse.ts
1532
+ var ActorsListResponse = schemas_exports.object({
1533
+ actors: schemas_exports.list(Actor),
1534
+ pagination: Pagination
1535
+ });
1536
+
1537
+ // src/serialization/types/Datacenter.ts
1538
+ var Datacenter = schemas_exports.object({
1539
+ label: schemas_exports.number(),
1540
+ name: schemas_exports.string(),
1541
+ url: schemas_exports.string()
1542
+ });
1543
+
1544
+ // src/serialization/types/HealthResponse.ts
1545
+ var HealthResponse = schemas_exports.object({
1546
+ runtime: schemas_exports.string(),
1547
+ status: schemas_exports.string(),
1548
+ version: schemas_exports.string()
1549
+ });
1550
+
1551
+ // src/serialization/types/HealthStatus.ts
1552
+ var HealthStatus = schemas_exports.enum_(["ok", "error"]);
1553
+
1554
+ // src/serialization/types/DatacenterHealth.ts
1555
+ var DatacenterHealth = schemas_exports.object({
1556
+ datacenterLabel: schemas_exports.property("datacenter_label", schemas_exports.number()),
1557
+ datacenterName: schemas_exports.property("datacenter_name", schemas_exports.string()),
1558
+ error: schemas_exports.string().optional(),
1559
+ response: HealthResponse.optional(),
1560
+ rttMs: schemas_exports.property("rtt_ms", schemas_exports.number().optional()),
1561
+ status: HealthStatus
1562
+ });
1563
+
1564
+ // src/serialization/types/DatacentersListResponse.ts
1565
+ var DatacentersListResponse = schemas_exports.object({
1566
+ datacenters: schemas_exports.list(Datacenter),
1567
+ pagination: Pagination
1568
+ });
1569
+
1570
+ // src/serialization/types/HealthFanoutResponse.ts
1571
+ var HealthFanoutResponse = schemas_exports.object({
1572
+ datacenters: schemas_exports.list(DatacenterHealth)
1573
+ });
1574
+
1575
+ // src/serialization/types/MetadataGetResponse.ts
1576
+ var MetadataGetResponse = schemas_exports.object({
1577
+ buildTimestamp: schemas_exports.property("build_timestamp", schemas_exports.string()),
1578
+ cargoProfile: schemas_exports.property("cargo_profile", schemas_exports.string()),
1579
+ cargoTarget: schemas_exports.property("cargo_target", schemas_exports.string()),
1580
+ gitSha: schemas_exports.property("git_sha", schemas_exports.string()),
1581
+ runtime: schemas_exports.string(),
1582
+ rustcHost: schemas_exports.property("rustc_host", schemas_exports.string()),
1583
+ rustcVersion: schemas_exports.property("rustc_version", schemas_exports.string()),
1584
+ version: schemas_exports.string()
1585
+ });
1586
+
1587
+ // src/serialization/types/Namespace.ts
1588
+ var Namespace = schemas_exports.object({
1589
+ createTs: schemas_exports.property("create_ts", schemas_exports.number()),
1590
+ displayName: schemas_exports.property("display_name", schemas_exports.string()),
1591
+ name: schemas_exports.string(),
1592
+ namespaceId: schemas_exports.property("namespace_id", RivetId)
1593
+ });
1594
+
1595
+ // src/serialization/types/NamespaceListResponse.ts
1596
+ var NamespaceListResponse = schemas_exports.object({
1597
+ namespaces: schemas_exports.list(Namespace),
1598
+ pagination: Pagination
1599
+ });
1600
+
1601
+ // src/serialization/types/NamespacesCreateResponse.ts
1602
+ var NamespacesCreateResponse = schemas_exports.object({
1603
+ namespace: Namespace
1604
+ });
1605
+
1606
+ // src/serialization/types/Runner.ts
1607
+ var Runner = schemas_exports.object({
1608
+ createTs: schemas_exports.property("create_ts", schemas_exports.number()),
1609
+ datacenter: schemas_exports.string(),
1610
+ drainTs: schemas_exports.property("drain_ts", schemas_exports.number().optional()),
1611
+ key: schemas_exports.string(),
1612
+ lastConnectedTs: schemas_exports.property("last_connected_ts", schemas_exports.number().optional()),
1613
+ lastPingTs: schemas_exports.property("last_ping_ts", schemas_exports.number()),
1614
+ lastRtt: schemas_exports.property("last_rtt", schemas_exports.number()),
1615
+ metadata: schemas_exports.record(schemas_exports.string(), schemas_exports.unknown()).optional(),
1616
+ name: schemas_exports.string(),
1617
+ namespaceId: schemas_exports.property("namespace_id", RivetId),
1618
+ remainingSlots: schemas_exports.property("remaining_slots", schemas_exports.number()),
1619
+ runnerId: schemas_exports.property("runner_id", RivetId),
1620
+ stopTs: schemas_exports.property("stop_ts", schemas_exports.number().optional()),
1621
+ totalSlots: schemas_exports.property("total_slots", schemas_exports.number()),
1622
+ version: schemas_exports.number()
1623
+ });
1624
+
1625
+ // src/serialization/types/RunnerConfigServerless.ts
1626
+ var RunnerConfigServerless = schemas_exports.object({
1627
+ headers: schemas_exports.record(schemas_exports.string(), schemas_exports.string()).optional(),
1628
+ maxRunners: schemas_exports.property("max_runners", schemas_exports.number()),
1629
+ minRunners: schemas_exports.property("min_runners", schemas_exports.number().optional()),
1630
+ requestLifespan: schemas_exports.property("request_lifespan", schemas_exports.number()),
1631
+ runnersMargin: schemas_exports.property("runners_margin", schemas_exports.number().optional()),
1632
+ slotsPerRunner: schemas_exports.property("slots_per_runner", schemas_exports.number()),
1633
+ url: schemas_exports.string()
1634
+ });
1635
+
1636
+ // src/serialization/types/RunnerConfig.ts
1637
+ var RunnerConfig = schemas_exports.object({
1638
+ normal: schemas_exports.record(schemas_exports.string(), schemas_exports.unknown()).optional(),
1639
+ serverless: RunnerConfigServerless.optional(),
1640
+ drainOnVersionUpgrade: schemas_exports.property(
1641
+ "drain_on_version_upgrade",
1642
+ schemas_exports.boolean().optional()
1643
+ ),
1644
+ metadata: schemas_exports.unknown().optional()
1645
+ });
1646
+
1647
+ // src/serialization/types/RunnerConfigKindNormal.ts
1648
+ var RunnerConfigKindNormal = schemas_exports.object({
1649
+ normal: schemas_exports.record(schemas_exports.string(), schemas_exports.unknown())
1650
+ });
1651
+
1652
+ // src/serialization/types/RunnerConfigKindServerlessServerless.ts
1653
+ var RunnerConfigKindServerlessServerless = schemas_exports.object({
1654
+ headers: schemas_exports.record(schemas_exports.string(), schemas_exports.string()).optional(),
1655
+ maxRunners: schemas_exports.property("max_runners", schemas_exports.number()),
1656
+ minRunners: schemas_exports.property("min_runners", schemas_exports.number().optional()),
1657
+ requestLifespan: schemas_exports.property("request_lifespan", schemas_exports.number()),
1658
+ runnersMargin: schemas_exports.property("runners_margin", schemas_exports.number().optional()),
1659
+ slotsPerRunner: schemas_exports.property("slots_per_runner", schemas_exports.number()),
1660
+ url: schemas_exports.string()
1661
+ });
1662
+
1663
+ // src/serialization/types/RunnerConfigKindServerless.ts
1664
+ var RunnerConfigKindServerless = schemas_exports.object({
1665
+ serverless: RunnerConfigKindServerlessServerless
1666
+ });
1667
+
1668
+ // src/serialization/types/RunnerConfigKind.ts
1669
+ var RunnerConfigKind = schemas_exports.undiscriminatedUnion([RunnerConfigKindNormal, RunnerConfigKindServerless]);
1670
+
1671
+ // src/serialization/types/RunnerConfigResponse.ts
1672
+ var RunnerConfigResponse = schemas_exports.object({
1673
+ runnerPoolError: schemas_exports.property(
1674
+ "runner_pool_error",
1675
+ schemas_exports.record(schemas_exports.string(), schemas_exports.unknown()).optional()
1676
+ )
1677
+ }).extend(RunnerConfig);
1678
+
1679
+ // src/serialization/types/RunnerConfigVariant.ts
1680
+ var RunnerConfigVariant = schemas_exports.enum_(["serverless", "normal"]);
1681
+
1682
+ // src/serialization/types/RunnerConfigsDeleteResponse.ts
1683
+ var RunnerConfigsDeleteResponse = schemas_exports.record(schemas_exports.string(), schemas_exports.unknown());
1684
+
1685
+ // src/serialization/types/RunnerConfigsListResponseRunnerConfigsValue.ts
1686
+ var RunnerConfigsListResponseRunnerConfigsValue = schemas_exports.object({
1687
+ datacenters: schemas_exports.record(schemas_exports.string(), RunnerConfigResponse)
1688
+ });
1689
+
1690
+ // src/serialization/types/RunnerConfigsListResponse.ts
1691
+ var RunnerConfigsListResponse = schemas_exports.object({
1692
+ pagination: Pagination,
1693
+ runnerConfigs: schemas_exports.property(
1694
+ "runner_configs",
1695
+ schemas_exports.record(schemas_exports.string(), RunnerConfigsListResponseRunnerConfigsValue)
1696
+ )
1697
+ });
1698
+
1699
+ // src/serialization/types/RunnerConfigsRefreshMetadataRequestBody.ts
1700
+ var RunnerConfigsRefreshMetadataRequestBody = schemas_exports.record(schemas_exports.string(), schemas_exports.unknown());
1701
+
1702
+ // src/serialization/types/RunnerConfigsRefreshMetadataResponse.ts
1703
+ var RunnerConfigsRefreshMetadataResponse = schemas_exports.record(schemas_exports.string(), schemas_exports.unknown());
1704
+
1705
+ // src/serialization/types/RunnerConfigsServerlessHealthCheckResponseSuccessSuccess.ts
1706
+ var RunnerConfigsServerlessHealthCheckResponseSuccessSuccess = schemas_exports.object({
1707
+ version: schemas_exports.string()
1708
+ });
1709
+
1710
+ // src/serialization/types/RunnerConfigsServerlessHealthCheckResponseSuccess.ts
1711
+ var RunnerConfigsServerlessHealthCheckResponseSuccess = schemas_exports.object({
1712
+ success: RunnerConfigsServerlessHealthCheckResponseSuccessSuccess
1713
+ });
1714
+
1715
+ // src/serialization/types/RunnerConfigsServerlessMetadataErrorInvalidRequest.ts
1716
+ var RunnerConfigsServerlessMetadataErrorInvalidRequest = schemas_exports.object({
1717
+ invalidRequest: schemas_exports.property(
1718
+ "invalid_request",
1719
+ schemas_exports.record(schemas_exports.string(), schemas_exports.unknown())
1720
+ )
1721
+ });
1722
+
1723
+ // src/serialization/types/RunnerConfigsServerlessMetadataErrorRequestFailed.ts
1724
+ var RunnerConfigsServerlessMetadataErrorRequestFailed = schemas_exports.object({
1725
+ requestFailed: schemas_exports.property(
1726
+ "request_failed",
1727
+ schemas_exports.record(schemas_exports.string(), schemas_exports.unknown())
1728
+ )
1729
+ });
1730
+
1731
+ // src/serialization/types/RunnerConfigsServerlessMetadataErrorRequestTimedOut.ts
1732
+ var RunnerConfigsServerlessMetadataErrorRequestTimedOut = schemas_exports.object({
1733
+ requestTimedOut: schemas_exports.property(
1734
+ "request_timed_out",
1735
+ schemas_exports.record(schemas_exports.string(), schemas_exports.unknown())
1736
+ )
1737
+ });
1738
+
1739
+ // src/serialization/types/RunnerConfigsServerlessMetadataErrorNonSuccessStatusNonSuccessStatus.ts
1740
+ var RunnerConfigsServerlessMetadataErrorNonSuccessStatusNonSuccessStatus = schemas_exports.object({
1741
+ body: schemas_exports.string(),
1742
+ statusCode: schemas_exports.property("status_code", schemas_exports.number())
1743
+ });
1744
+
1745
+ // src/serialization/types/RunnerConfigsServerlessMetadataErrorNonSuccessStatus.ts
1746
+ var RunnerConfigsServerlessMetadataErrorNonSuccessStatus = schemas_exports.object({
1747
+ nonSuccessStatus: schemas_exports.property(
1748
+ "non_success_status",
1749
+ RunnerConfigsServerlessMetadataErrorNonSuccessStatusNonSuccessStatus
1750
+ )
1751
+ });
1752
+
1753
+ // src/serialization/types/RunnerConfigsServerlessMetadataErrorInvalidResponseJsonInvalidResponseJson.ts
1754
+ var RunnerConfigsServerlessMetadataErrorInvalidResponseJsonInvalidResponseJson = schemas_exports.object({
1755
+ body: schemas_exports.string()
1756
+ });
1757
+
1758
+ // src/serialization/types/RunnerConfigsServerlessMetadataErrorInvalidResponseJson.ts
1759
+ var RunnerConfigsServerlessMetadataErrorInvalidResponseJson = schemas_exports.object({
1760
+ invalidResponseJson: schemas_exports.property(
1761
+ "invalid_response_json",
1762
+ RunnerConfigsServerlessMetadataErrorInvalidResponseJsonInvalidResponseJson
1763
+ )
1764
+ });
1765
+
1766
+ // src/serialization/types/RunnerConfigsServerlessMetadataErrorInvalidResponseSchemaInvalidResponseSchema.ts
1767
+ var RunnerConfigsServerlessMetadataErrorInvalidResponseSchemaInvalidResponseSchema = schemas_exports.object({
1768
+ runtime: schemas_exports.string(),
1769
+ version: schemas_exports.string()
1770
+ });
1771
+
1772
+ // src/serialization/types/RunnerConfigsServerlessMetadataErrorInvalidResponseSchema.ts
1773
+ var RunnerConfigsServerlessMetadataErrorInvalidResponseSchema = schemas_exports.object({
1774
+ invalidResponseSchema: schemas_exports.property(
1775
+ "invalid_response_schema",
1776
+ RunnerConfigsServerlessMetadataErrorInvalidResponseSchemaInvalidResponseSchema
1777
+ )
1778
+ });
1779
+
1780
+ // src/serialization/types/RunnerConfigsServerlessMetadataError.ts
1781
+ var RunnerConfigsServerlessMetadataError = schemas_exports.undiscriminatedUnion([
1782
+ RunnerConfigsServerlessMetadataErrorInvalidRequest,
1783
+ RunnerConfigsServerlessMetadataErrorRequestFailed,
1784
+ RunnerConfigsServerlessMetadataErrorRequestTimedOut,
1785
+ RunnerConfigsServerlessMetadataErrorNonSuccessStatus,
1786
+ RunnerConfigsServerlessMetadataErrorInvalidResponseJson,
1787
+ RunnerConfigsServerlessMetadataErrorInvalidResponseSchema
1788
+ ]);
1789
+
1790
+ // src/serialization/types/RunnerConfigsServerlessHealthCheckResponseFailureFailure.ts
1791
+ var RunnerConfigsServerlessHealthCheckResponseFailureFailure = schemas_exports.object({
1792
+ error: RunnerConfigsServerlessMetadataError
1793
+ });
1794
+
1795
+ // src/serialization/types/RunnerConfigsServerlessHealthCheckResponseFailure.ts
1796
+ var RunnerConfigsServerlessHealthCheckResponseFailure = schemas_exports.object({
1797
+ failure: RunnerConfigsServerlessHealthCheckResponseFailureFailure
1798
+ });
1799
+
1800
+ // src/serialization/types/RunnerConfigsServerlessHealthCheckResponse.ts
1801
+ var RunnerConfigsServerlessHealthCheckResponse = schemas_exports.undiscriminatedUnion([
1802
+ RunnerConfigsServerlessHealthCheckResponseSuccess,
1803
+ RunnerConfigsServerlessHealthCheckResponseFailure
1804
+ ]);
1805
+
1806
+ // src/serialization/types/RunnerConfigsUpsertResponse.ts
1807
+ var RunnerConfigsUpsertResponse = schemas_exports.object({
1808
+ endpointConfigChanged: schemas_exports.property("endpoint_config_changed", schemas_exports.boolean())
1809
+ });
1810
+
1811
+ // src/serialization/types/RunnersListNamesResponse.ts
1812
+ var RunnersListNamesResponse = schemas_exports.object({
1813
+ names: schemas_exports.list(schemas_exports.string()),
1814
+ pagination: Pagination
1815
+ });
1816
+
1817
+ // src/serialization/types/RunnersListResponse.ts
1818
+ var RunnersListResponse = schemas_exports.object({
1819
+ pagination: Pagination,
1820
+ runners: schemas_exports.list(Runner)
1821
+ });
1822
+
1823
+ // src/serialization/client/requests/ActorsCreateRequest.ts
1824
+ var ActorsCreateRequest = schemas_exports.object({
1825
+ crashPolicy: schemas_exports.property("crash_policy", CrashPolicy),
1826
+ datacenter: schemas_exports.string().optional(),
1827
+ input: schemas_exports.string().optional(),
1828
+ key: schemas_exports.string().optional(),
1829
+ name: schemas_exports.string(),
1830
+ runnerNameSelector: schemas_exports.property("runner_name_selector", schemas_exports.string())
1831
+ });
1832
+
1833
+ // src/serialization/client/requests/ActorsGetOrCreateRequest.ts
1834
+ var ActorsGetOrCreateRequest = schemas_exports.object({
1835
+ crashPolicy: schemas_exports.property("crash_policy", CrashPolicy),
1836
+ datacenter: schemas_exports.string().optional(),
1837
+ input: schemas_exports.string().optional(),
1838
+ key: schemas_exports.string(),
1839
+ name: schemas_exports.string(),
1840
+ runnerNameSelector: schemas_exports.property("runner_name_selector", schemas_exports.string())
1841
+ });
1842
+
1843
+ // src/serialization/client/requests/RunnerConfigsServerlessHealthCheckRequest.ts
1844
+ var RunnerConfigsServerlessHealthCheckRequest = schemas_exports.object({
1845
+ headers: schemas_exports.record(schemas_exports.string(), schemas_exports.string()).optional(),
1846
+ url: schemas_exports.string()
1847
+ });
1848
+
1849
+ // src/serialization/client/requests/RunnerConfigsUpsertRequestBody.ts
1850
+ var RunnerConfigsUpsertRequestBody = schemas_exports.object({
1851
+ datacenters: schemas_exports.record(schemas_exports.string(), RunnerConfig)
1852
+ });
1853
+
1854
+ // src/serialization/resources/namespaces/index.ts
1855
+ var namespaces_exports = {};
1856
+ __export(namespaces_exports, {
1857
+ NamespacesCreateRequest: () => NamespacesCreateRequest
1858
+ });
1859
+
1860
+ // src/serialization/resources/namespaces/client/requests/NamespacesCreateRequest.ts
1861
+ var NamespacesCreateRequest = schemas_exports.object({
1862
+ displayName: schemas_exports.property("display_name", schemas_exports.string()),
1863
+ name: schemas_exports.string()
1864
+ });
1865
+ export {
1866
+ Actor,
1867
+ ActorName,
1868
+ ActorsCreateRequest,
1869
+ ActorsCreateResponse,
1870
+ ActorsDeleteResponse,
1871
+ ActorsGetOrCreateRequest,
1872
+ ActorsGetOrCreateResponse,
1873
+ ActorsKvGetResponse,
1874
+ ActorsListNamesResponse,
1875
+ ActorsListResponse,
1876
+ CrashPolicy,
1877
+ Datacenter,
1878
+ DatacenterHealth,
1879
+ DatacentersListResponse,
1880
+ HealthFanoutResponse,
1881
+ HealthResponse,
1882
+ HealthStatus,
1883
+ MetadataGetResponse,
1884
+ Namespace,
1885
+ NamespaceListResponse,
1886
+ NamespacesCreateRequest,
1887
+ NamespacesCreateResponse,
1888
+ Pagination,
1889
+ RivetId,
1890
+ Runner,
1891
+ RunnerConfig,
1892
+ RunnerConfigKind,
1893
+ RunnerConfigKindNormal,
1894
+ RunnerConfigKindServerless,
1895
+ RunnerConfigKindServerlessServerless,
1896
+ RunnerConfigResponse,
1897
+ RunnerConfigServerless,
1898
+ RunnerConfigVariant,
1899
+ RunnerConfigsDeleteResponse,
1900
+ RunnerConfigsListResponse,
1901
+ RunnerConfigsListResponseRunnerConfigsValue,
1902
+ RunnerConfigsRefreshMetadataRequestBody,
1903
+ RunnerConfigsRefreshMetadataResponse,
1904
+ RunnerConfigsServerlessHealthCheckRequest,
1905
+ RunnerConfigsServerlessHealthCheckResponse,
1906
+ RunnerConfigsServerlessHealthCheckResponseFailure,
1907
+ RunnerConfigsServerlessHealthCheckResponseFailureFailure,
1908
+ RunnerConfigsServerlessHealthCheckResponseSuccess,
1909
+ RunnerConfigsServerlessHealthCheckResponseSuccessSuccess,
1910
+ RunnerConfigsServerlessMetadataError,
1911
+ RunnerConfigsServerlessMetadataErrorInvalidRequest,
1912
+ RunnerConfigsServerlessMetadataErrorInvalidResponseJson,
1913
+ RunnerConfigsServerlessMetadataErrorInvalidResponseJsonInvalidResponseJson,
1914
+ RunnerConfigsServerlessMetadataErrorInvalidResponseSchema,
1915
+ RunnerConfigsServerlessMetadataErrorInvalidResponseSchemaInvalidResponseSchema,
1916
+ RunnerConfigsServerlessMetadataErrorNonSuccessStatus,
1917
+ RunnerConfigsServerlessMetadataErrorNonSuccessStatusNonSuccessStatus,
1918
+ RunnerConfigsServerlessMetadataErrorRequestFailed,
1919
+ RunnerConfigsServerlessMetadataErrorRequestTimedOut,
1920
+ RunnerConfigsUpsertRequestBody,
1921
+ RunnerConfigsUpsertResponse,
1922
+ RunnersListNamesResponse,
1923
+ RunnersListResponse,
1924
+ namespaces_exports as namespaces
1925
+ };