@rivetkit/engine-api-full 25.5.3

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