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