apps 0.0.1-beta.1 → 0.0.1-beta.100
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/README.md +112 -72
- package/framework-reference.json +1 -1
- package/js/browser-XIPJGLH2.js +65 -0
- package/js/chunk-2CURR5Y7.js +264 -0
- package/js/chunk-2LSGC7XY.js +42 -0
- package/js/{chunk-YEJOQEII.js → chunk-4PIQKACY.js} +65 -10
- package/js/chunk-4UPC36ZL.js +5185 -0
- package/js/{chunk-4LPG6RCH.js → chunk-4X2UI4R2.js} +7 -27
- package/js/chunk-5C6RAGAS.js +335 -0
- package/js/chunk-62NVUKED.js +39 -0
- package/js/chunk-74H25C4X.js +95 -0
- package/js/chunk-7HG422GB.js +90 -0
- package/js/chunk-7STIP5CS.js +171 -0
- package/js/{chunk-QKHR7BMF.js → chunk-ACQXVKVQ.js} +87 -51
- package/js/{chunk-OHRT55C4.js → chunk-DILSCQPJ.js} +226 -265
- package/js/chunk-ILYCJ3HV.js +449 -0
- package/js/chunk-K6TSCYAO.js +712 -0
- package/js/{chunk-EVJUVWN2.js → chunk-KLSEU35Y.js} +463 -218
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/chunk-OWN3DP2W.js +88 -0
- package/js/{chunk-ZTFQHGEB.js → chunk-PBGPES67.js} +3 -5
- package/js/chunk-QI66R4FP.js +786 -0
- package/js/chunk-RN4YB4JT.js +1922 -0
- package/js/{chunk-ZCAMUXSG.js → chunk-URKOTNDA.js} +795 -177
- package/js/{chunk-NCYXZN2G.js → chunk-UVL56Z6E.js} +390 -23
- package/js/{chunk-2HHMABB6.js → chunk-VAI3EVCS.js} +700 -78
- package/js/chunk-VCYWAA4N.js +49 -0
- package/js/{chunk-HDJH3RPR.js → chunk-YDW7DX3A.js} +4 -4
- package/js/chunk-YWVISRZD.js +268 -0
- package/js/{chunk-FW5HBOIK.js → chunk-ZKDXML77.js} +19272 -18299
- package/js/client.js +148 -100
- package/js/contracts.js +208 -24
- package/js/effect.js +18 -19
- package/js/es-DIULA3ZF.js +39371 -0
- package/js/graphql.js +62 -58
- package/js/host.js +83 -60
- package/js/index.js +381 -263
- package/js/mcp/effect.js +21 -21
- package/js/mcp.js +117 -74
- package/js/openapi.js +4613 -42691
- package/js/react.js +2 -3
- package/js/skills/effect.js +6 -4
- package/js/skills.js +233 -70
- package/js/storage/facet.js +1 -540
- package/js/ui/auth/contracts.js +8 -9
- package/js/ui/auth.js +16 -14
- package/js/ui/contracts.js +9 -8
- package/js/ui/serving.js +8609 -227
- package/package.json +3 -8
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +60 -2
- package/types/app-cache/src/index.d.ts +92 -2
- package/types/app-data/src/contracts/database.d.ts +33 -6
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/app.d.ts +63 -17
- package/types/apps/src/contracts/cache.d.ts +24 -1
- package/types/apps/src/contracts/context.d.ts +60 -17
- package/types/apps/src/contracts/elicitation.d.ts +23 -7
- package/types/apps/src/contracts/events.d.ts +94 -0
- package/types/apps/src/contracts/failure.d.ts +54 -0
- package/types/apps/src/contracts/graphql.d.ts +2 -1
- package/types/apps/src/contracts/host.d.ts +1325 -534
- package/types/apps/src/contracts/icons.d.ts +28 -0
- package/types/apps/src/contracts/live.d.ts +2 -0
- package/types/apps/src/contracts/mcp.d.ts +97 -20
- package/types/apps/src/contracts/network.d.ts +120 -0
- package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
- package/types/apps/src/contracts/openapi-document.d.ts +1 -1
- package/types/apps/src/contracts/openapi.d.ts +51 -9
- package/types/apps/src/contracts/operations.d.ts +14 -12
- package/types/apps/src/contracts/placement.d.ts +102 -0
- package/types/apps/src/contracts/protocol-version.d.ts +6 -0
- package/types/apps/src/contracts/protocols/1.d.ts +2241 -0
- package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
- package/types/apps/src/contracts/protocols/11.d.ts +1149 -0
- package/types/apps/src/contracts/protocols/12.d.ts +3310 -0
- package/types/apps/src/contracts/protocols/2.d.ts +711 -0
- package/types/apps/src/contracts/protocols/3.d.ts +776 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1306 -0
- package/types/apps/src/contracts/protocols/5.d.ts +1200 -0
- package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
- package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
- package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
- package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
- package/types/apps/src/contracts/protocols/current.d.ts +6857 -0
- package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
- package/types/apps/src/contracts/provider-error.d.ts +9 -0
- package/types/apps/src/contracts/provider.d.ts +140 -10
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/schedules.d.ts +7 -1
- package/types/apps/src/contracts/schema.d.ts +21 -0
- package/types/apps/src/contracts/shared-catalog.d.ts +11 -0
- package/types/apps/src/contracts/skills.d.ts +60 -14
- package/types/apps/src/contracts/sql.d.ts +63 -0
- package/types/apps/src/contracts/ui-auth.d.ts +6 -14
- package/types/apps/src/contracts/ui.d.ts +70 -30
- package/types/apps/src/contracts/webhooks.d.ts +24 -7
- package/types/apps/src/contracts/workflows.d.ts +89 -36
- package/types/apps/src/facet.d.ts +4 -5
- package/types/apps/src/graphql.d.ts +1 -3
- package/types/apps/src/host.d.ts +5 -0
- package/types/apps/src/implementation/account-router.d.ts +13 -0
- package/types/apps/src/implementation/app.d.ts +44 -16
- package/types/apps/src/implementation/authoring.d.ts +25 -5
- package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
- package/types/apps/src/implementation/cache.d.ts +32 -3
- package/types/apps/src/implementation/catalog-cache.d.ts +43 -5
- package/types/apps/src/implementation/elicitation.d.ts +18 -15
- package/types/apps/src/implementation/events.d.ts +64 -0
- package/types/apps/src/implementation/failure-detail.d.ts +48 -0
- package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
- package/types/apps/src/implementation/graphql.d.ts +4 -3
- package/types/apps/src/implementation/input-problems.d.ts +6 -2
- package/types/apps/src/implementation/invocation-timing.d.ts +18 -0
- package/types/apps/src/implementation/live.d.ts +2 -2
- package/types/apps/src/implementation/mcp-call.d.ts +6 -5
- package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
- package/types/apps/src/implementation/mcp-client.d.ts +49 -25
- package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
- package/types/apps/src/implementation/mcp.d.ts +52 -25
- package/types/apps/src/implementation/network.d.ts +16 -0
- package/types/apps/src/implementation/openapi-compile.d.ts +30 -8
- package/types/apps/src/implementation/openapi-document.d.ts +46 -21
- package/types/apps/src/implementation/openapi-names.d.ts +23 -0
- package/types/apps/src/implementation/openapi-request.d.ts +10 -3
- package/types/apps/src/implementation/openapi-source.d.ts +30 -8
- package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
- package/types/apps/src/implementation/operations.d.ts +84 -10
- package/types/apps/src/implementation/optimistic.d.ts +1 -1
- package/types/apps/src/implementation/placement.d.ts +60 -0
- package/types/apps/src/implementation/protocol-operations.d.ts +6 -4
- package/types/apps/src/implementation/provider-error.d.ts +28 -1
- package/types/apps/src/implementation/provider.d.ts +26 -6
- package/types/apps/src/implementation/query-commit.d.ts +1 -1
- package/types/apps/src/implementation/router-catalog.d.ts +227 -0
- package/types/apps/src/implementation/router.d.ts +78 -0
- package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
- package/types/apps/src/implementation/schedules.d.ts +39 -8
- package/types/apps/src/implementation/schema.d.ts +111 -15
- package/types/apps/src/implementation/skills.d.ts +18 -24
- package/types/apps/src/implementation/sql.d.ts +71 -0
- package/types/apps/src/implementation/swagger-client.d.ts +28 -0
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-auth.d.ts +12 -6
- package/types/apps/src/implementation/ui-client.d.ts +3 -3
- package/types/apps/src/implementation/ui-document.d.ts +5 -0
- package/types/apps/src/implementation/ui-errors.d.ts +1 -1
- package/types/apps/src/implementation/ui-serving.d.ts +31 -12
- package/types/apps/src/implementation/ui-watch.d.ts +1 -1
- package/types/apps/src/implementation/upstream-error.d.ts +7 -0
- package/types/apps/src/implementation/webhooks.d.ts +15 -6
- package/types/apps/src/implementation/workflow-context.d.ts +17 -5
- package/types/apps/src/implementation/workflows.d.ts +11 -4
- package/types/apps/src/index.d.ts +71 -21
- package/types/apps/src/mcp.d.ts +25 -5
- package/types/apps/src/openapi.d.ts +11 -6
- package/types/apps/src/react.d.ts +1 -1
- package/types/apps/src/skills.d.ts +13 -8
- package/types/apps/src/ui-auth.d.ts +2 -2
- package/types/apps/src/ui-serving.d.ts +1 -1
- package/types/telemetry/src/app-records.d.ts +42 -0
- package/types/telemetry/src/browser-operations.d.ts +7 -4
- package/types/telemetry/src/browser.d.ts +8 -3
- package/types/telemetry/src/config.d.ts +2 -2
- package/types/telemetry/src/index.d.ts +2 -1
- package/types/telemetry/src/layer.d.ts +10 -4
- package/types/telemetry/src/measurements.d.ts +1 -1
- package/types/telemetry/src/ownership.d.ts +60 -0
- package/types/telemetry/src/recorded-failure.d.ts +29 -0
- package/types/telemetry/src/relay.d.ts +16 -6
- package/types/telemetry/src/span-attributes.d.ts +17 -1
- package/types/telemetry/src/transport.d.ts +8 -1
- package/types/utils/src/api-error.d.ts +55 -0
- package/types/utils/src/connection-failure.d.ts +33 -0
- package/types/utils/src/legacy-keys.d.ts +20 -0
- package/types/utils/src/recorded-message.d.ts +18 -0
- package/types/utils/src/schema-definitions.d.ts +13 -0
- package/types/utils/src/user-facing-error.d.ts +83 -0
- package/js/chunk-6IIO4NPI.js +0 -29
- package/js/chunk-6YBRWRK3.js +0 -160
- package/js/chunk-BMOIAIVR.js +0 -138
- package/js/chunk-FZJOYIZO.js +0 -19
- package/js/chunk-G7IE6BKC.js +0 -224
- package/js/chunk-IHQ4ML7K.js +0 -2193
- package/js/chunk-KOXMLKTM.js +0 -1288
- package/js/chunk-M6ZRRIBI.js +0 -877
- package/js/chunk-PLCMJREA.js +0 -590
- package/js/chunk-PZ36XMXW.js +0 -93
- package/js/chunk-RBAC33PQ.js +0 -267
- package/js/chunk-SATWJKN6.js +0 -34
- package/js/chunk-SWPD52J7.js +0 -35
- package/js/chunk-TE4KO4HI.js +0 -47
- package/js/chunk-W7D7WVSY.js +0 -18
- package/js/chunk-X7SFGU4Q.js +0 -280
- package/js/chunk-ZJWDMTE3.js +0 -63
- package/js/mcp/stdio.js +0 -128
- package/types/app-data/src/implementation/cursor.d.ts +0 -10
- package/types/app-data/src/implementation/index-key.d.ts +0 -7
- package/types/app-data/src/implementation/promise.d.ts +0 -68
- package/types/app-data/src/implementation/range.d.ts +0 -8
- package/types/app-data/src/implementation/schema.d.ts +0 -33
- package/types/app-data/src/implementation/sqlite.d.ts +0 -11
- package/types/app-data/src/index.d.ts +0 -4
- package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
- package/types/apps/src/contracts/storage.d.ts +0 -68
- package/types/apps/src/implementation/account-operations.d.ts +0 -151
- package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
- package/types/apps/src/implementation/mcp-stdio.d.ts +0 -4
- package/types/apps/src/implementation/storage.d.ts +0 -13
- package/types/apps/src/mcp-stdio.d.ts +0 -8
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DeclarationInvalid,
|
|
3
|
+
JsonObject,
|
|
2
4
|
ValidationError
|
|
3
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-7HG422GB.js";
|
|
4
6
|
import {
|
|
7
|
+
Cause_exports,
|
|
5
8
|
Effect_exports,
|
|
9
|
+
Exit_exports,
|
|
6
10
|
SchemaGetter_exports,
|
|
7
11
|
SchemaIssue_exports,
|
|
8
12
|
SchemaParser_exports,
|
|
9
13
|
Schema_exports
|
|
10
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-ZKDXML77.js";
|
|
11
15
|
|
|
12
16
|
// ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.js
|
|
13
17
|
function deepCompareStrict(a, b) {
|
|
@@ -59,6 +63,19 @@ function escapePointer(p) {
|
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
// ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/dereference.js
|
|
66
|
+
var schemaKeyword = {
|
|
67
|
+
additionalItems: true,
|
|
68
|
+
unevaluatedItems: true,
|
|
69
|
+
items: true,
|
|
70
|
+
contains: true,
|
|
71
|
+
additionalProperties: true,
|
|
72
|
+
unevaluatedProperties: true,
|
|
73
|
+
propertyNames: true,
|
|
74
|
+
not: true,
|
|
75
|
+
if: true,
|
|
76
|
+
then: true,
|
|
77
|
+
else: true
|
|
78
|
+
};
|
|
62
79
|
var schemaArrayKeyword = {
|
|
63
80
|
prefixItems: true,
|
|
64
81
|
items: true,
|
|
@@ -104,9 +121,9 @@ var ignoredKeyword = {
|
|
|
104
121
|
var initialBaseURI = typeof self !== "undefined" && self.location && self.location.origin !== "null" ? new URL(self.location.origin + self.location.pathname + location.search) : new URL("https://github.com/cfworker");
|
|
105
122
|
function dereference(schema, lookup = /* @__PURE__ */ Object.create(null), baseURI = initialBaseURI, basePointer = "") {
|
|
106
123
|
if (schema && typeof schema === "object" && !Array.isArray(schema)) {
|
|
107
|
-
const
|
|
108
|
-
if (
|
|
109
|
-
const url = new URL(
|
|
124
|
+
const id = schema.$id || schema.id;
|
|
125
|
+
if (id) {
|
|
126
|
+
const url = new URL(id, baseURI.href);
|
|
110
127
|
if (url.hash.length > 1) {
|
|
111
128
|
lookup[url.href] = schema;
|
|
112
129
|
} else {
|
|
@@ -172,8 +189,14 @@ function dereference(schema, lookup = /* @__PURE__ */ Object.create(null), baseU
|
|
|
172
189
|
for (let subKey in subSchema) {
|
|
173
190
|
dereference(subSchema[subKey], lookup, baseURI, `${keyBase}/${encodePointer(subKey)}`);
|
|
174
191
|
}
|
|
175
|
-
} else {
|
|
192
|
+
} else if (schemaKeyword[key]) {
|
|
176
193
|
dereference(subSchema, lookup, baseURI, keyBase);
|
|
194
|
+
} else if (key === "dependencies" && subSchema && typeof subSchema === "object") {
|
|
195
|
+
for (let subKey in subSchema) {
|
|
196
|
+
if (!Array.isArray(subSchema[subKey])) {
|
|
197
|
+
dereference(subSchema[subKey], lookup, baseURI, `${keyBase}/${encodePointer(subKey)}`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
177
200
|
}
|
|
178
201
|
}
|
|
179
202
|
return lookup;
|
|
@@ -342,7 +365,7 @@ function validate(instance, schema, draft = "2019-09", lookup = dereference(sche
|
|
|
342
365
|
if ($recursiveAnchor === true && recursiveAnchor === null) {
|
|
343
366
|
recursiveAnchor = schema;
|
|
344
367
|
}
|
|
345
|
-
if ($recursiveRef
|
|
368
|
+
if ($recursiveRef !== void 0) {
|
|
346
369
|
const refSchema = recursiveAnchor === null ? lookup[__absolute_recursive_ref__] : recursiveAnchor;
|
|
347
370
|
const keywordLocation = `${schemaLocation}/$recursiveRef`;
|
|
348
371
|
const result = validate(instance, recursiveAnchor === null ? schema : recursiveAnchor, draft, lookup, shortCircuit, refSchema, instanceLocation, keywordLocation, evaluated);
|
|
@@ -1066,40 +1089,57 @@ function schemaPattern(pattern) {
|
|
|
1066
1089
|
}
|
|
1067
1090
|
|
|
1068
1091
|
// src/implementation/schema.ts
|
|
1069
|
-
var StorageField = /* @__PURE__ */ Symbol("apps.StorageField");
|
|
1070
1092
|
var Decoder = /* @__PURE__ */ Symbol("apps.Schema");
|
|
1071
1093
|
var decoderOf = (schema) => schema[Decoder];
|
|
1072
1094
|
var isSchema = (value) => typeof value === "object" && value !== null && Decoder in value;
|
|
1095
|
+
var schemaArgument = (value, role) => {
|
|
1096
|
+
if (isSchema(value)) return value;
|
|
1097
|
+
const received = value;
|
|
1098
|
+
throw new TypeError(
|
|
1099
|
+
`${role} must be a schema, such as string() or object({ ... }), but ${typeof received === "function" ? "it is a function. Call it, as in string()." : received === void 0 ? "it is undefined. Check that it is defined and imported before this declaration." : typeof received === "object" && received !== null && Object.getPrototypeOf(received) === Object.prototype ? "it is a plain object. Wrap its fields in object({ ... })." : "no apps schema constructor created it."}`
|
|
1100
|
+
);
|
|
1101
|
+
};
|
|
1073
1102
|
var parse = (decoder, input) => Effect_exports.suspend(() => Schema_exports.decodeUnknownEffect(decoder)(input)).pipe(
|
|
1074
1103
|
Effect_exports.mapError(() => new ValidationError())
|
|
1075
1104
|
);
|
|
1076
|
-
|
|
1105
|
+
var declarationIssues = SchemaIssue_exports.makeFormatterStandardSchemaV1({
|
|
1106
|
+
leafHook: SchemaIssue_exports.defaultLeafHook
|
|
1107
|
+
});
|
|
1108
|
+
var parseDeclaration = (decoder, input, declaration, intended = () => decoder) => Effect_exports.suspend(() => Schema_exports.decodeUnknownEffect(decoder)(input)).pipe(
|
|
1109
|
+
Effect_exports.catch(
|
|
1110
|
+
(failed) => Effect_exports.suspend(
|
|
1111
|
+
() => Schema_exports.decodeUnknownEffect(intended(input))(input, { errors: "all" })
|
|
1112
|
+
).pipe(
|
|
1113
|
+
Effect_exports.flip,
|
|
1114
|
+
Effect_exports.orElseSucceed(() => failed),
|
|
1115
|
+
Effect_exports.flatMap(
|
|
1116
|
+
(error) => Effect_exports.fail(
|
|
1117
|
+
new DeclarationInvalid({
|
|
1118
|
+
declaration,
|
|
1119
|
+
issues: declarationIssues(error.issue).issues.map((issue) => ({
|
|
1120
|
+
path: (issue.path ?? []).map(
|
|
1121
|
+
(segment) => String(typeof segment === "object" ? segment.key : segment)
|
|
1122
|
+
),
|
|
1123
|
+
message: issue.message
|
|
1124
|
+
}))
|
|
1125
|
+
})
|
|
1126
|
+
)
|
|
1127
|
+
)
|
|
1128
|
+
)
|
|
1129
|
+
)
|
|
1130
|
+
);
|
|
1131
|
+
function wrap(decoder, optionalValue) {
|
|
1077
1132
|
return {
|
|
1078
1133
|
[Decoder]: decoder,
|
|
1079
|
-
...field === void 0 ? {} : { [StorageField]: field },
|
|
1080
1134
|
optionalValue,
|
|
1081
1135
|
parse: (input) => Effect_exports.runSync(parse(decoder, input)),
|
|
1082
|
-
optional: () => wrap(
|
|
1083
|
-
Schema_exports.optional(decoder),
|
|
1084
|
-
true,
|
|
1085
|
-
field === void 0 ? void 0 : { ...field, optional: true }
|
|
1086
|
-
),
|
|
1136
|
+
optional: () => wrap(Schema_exports.optional(decoder), true),
|
|
1087
1137
|
default: (value) => {
|
|
1088
1138
|
const parsed = Effect_exports.runSync(parse(decoder, value));
|
|
1089
1139
|
return {
|
|
1090
1140
|
...wrap(
|
|
1091
1141
|
decoder.annotate({ default: parsed }).pipe(Schema_exports.withDecodingDefault(Effect_exports.succeed(parsed))),
|
|
1092
|
-
false
|
|
1093
|
-
field === void 0 || parsed === void 0 ? void 0 : {
|
|
1094
|
-
...field,
|
|
1095
|
-
default: Schema_exports.decodeUnknownSync(
|
|
1096
|
-
Schema_exports.Union([
|
|
1097
|
-
Schema_exports.String,
|
|
1098
|
-
Schema_exports.Finite,
|
|
1099
|
-
Schema_exports.Boolean
|
|
1100
|
-
])
|
|
1101
|
-
)(parsed)
|
|
1102
|
-
}
|
|
1142
|
+
false
|
|
1103
1143
|
),
|
|
1104
1144
|
hasDefault: true,
|
|
1105
1145
|
inputOptional: optionalValue
|
|
@@ -1110,14 +1150,19 @@ function wrap(decoder, optionalValue, field) {
|
|
|
1110
1150
|
function string(options = {}) {
|
|
1111
1151
|
return wrap(
|
|
1112
1152
|
options.minLength === void 0 ? Schema_exports.String : Schema_exports.String.check(Schema_exports.isMinLength(options.minLength)),
|
|
1113
|
-
false
|
|
1114
|
-
{ kind: "string" }
|
|
1153
|
+
false
|
|
1115
1154
|
);
|
|
1116
1155
|
}
|
|
1117
|
-
var number = () => wrap(Schema_exports.Finite, false
|
|
1118
|
-
var boolean = () => wrap(Schema_exports.Boolean, false
|
|
1156
|
+
var number = () => wrap(Schema_exports.Finite, false);
|
|
1157
|
+
var boolean = () => wrap(Schema_exports.Boolean, false);
|
|
1119
1158
|
var json = () => wrap(Schema_exports.Json, false);
|
|
1120
|
-
var record = (value) => wrap(
|
|
1159
|
+
var record = (value) => wrap(
|
|
1160
|
+
Schema_exports.Record(
|
|
1161
|
+
Schema_exports.String,
|
|
1162
|
+
decoderOf(schemaArgument(value, "The record() value"))
|
|
1163
|
+
),
|
|
1164
|
+
false
|
|
1165
|
+
);
|
|
1121
1166
|
function literal(value) {
|
|
1122
1167
|
if (typeof value === "number") Effect_exports.runSync(parse(Schema_exports.Finite, value));
|
|
1123
1168
|
return wrap(
|
|
@@ -1125,10 +1170,13 @@ function literal(value) {
|
|
|
1125
1170
|
false
|
|
1126
1171
|
);
|
|
1127
1172
|
}
|
|
1128
|
-
var array = (item) => wrap(Schema_exports.Array(decoderOf(item)), false);
|
|
1173
|
+
var array = (item) => wrap(Schema_exports.Array(decoderOf(schemaArgument(item, "The array() item"))), false);
|
|
1129
1174
|
function object(fields) {
|
|
1130
1175
|
const entries = Object.entries(fields).map(
|
|
1131
|
-
([key, field]) => [
|
|
1176
|
+
([key, field]) => [
|
|
1177
|
+
key,
|
|
1178
|
+
decoderOf(schemaArgument(field, `The object() field ${JSON.stringify(key)}`))
|
|
1179
|
+
]
|
|
1132
1180
|
);
|
|
1133
1181
|
const decoder = entries.length === 0 ? withJsonSchemaDocument(
|
|
1134
1182
|
// Native Struct({}) accepts every non-null value and retains undeclared fields.
|
|
@@ -1142,6 +1190,25 @@ function object(fields) {
|
|
|
1142
1190
|
) : Schema_exports.Struct(Object.fromEntries(entries));
|
|
1143
1191
|
return { ...wrap(decoder, false), fields: Object.freeze({ ...fields }) };
|
|
1144
1192
|
}
|
|
1193
|
+
var Exposure = /* @__PURE__ */ Symbol("apps.FieldExposure");
|
|
1194
|
+
var exposureOf = (schema) => Exposure in schema && (schema[Exposure] === "plain" || schema[Exposure] === "raw") ? schema[Exposure] : void 0;
|
|
1195
|
+
var expose = (schema, exposure) => (
|
|
1196
|
+
// SAFETY: the copy keeps every member of S, and `optional` and `default` keep the marking.
|
|
1197
|
+
{
|
|
1198
|
+
...schema,
|
|
1199
|
+
[Exposure]: exposure,
|
|
1200
|
+
optional: () => expose(schema.optional(), exposure),
|
|
1201
|
+
default: (value) => expose(schema.default(value), exposure)
|
|
1202
|
+
}
|
|
1203
|
+
);
|
|
1204
|
+
var plain = (schema) => expose(schema, "plain");
|
|
1205
|
+
var raw = (schema) => expose(schema, "raw");
|
|
1206
|
+
var fieldExposure = (fields) => Object.fromEntries(
|
|
1207
|
+
Object.entries(fields).flatMap(([name, field]) => {
|
|
1208
|
+
const exposure = exposureOf(field);
|
|
1209
|
+
return exposure === void 0 ? [] : [[name, exposure]];
|
|
1210
|
+
})
|
|
1211
|
+
);
|
|
1145
1212
|
var ImportedJsonSchema = /* @__PURE__ */ Symbol("apps.JsonSchemaDocument");
|
|
1146
1213
|
var importedJsonSchema = (decoder) => ImportedJsonSchema in decoder ? decoder[ImportedJsonSchema] : void 0;
|
|
1147
1214
|
var withJsonSchemaDocument = (decoder, document) => Object.assign(decoder, { [ImportedJsonSchema]: document });
|
|
@@ -1157,7 +1224,7 @@ var withLazyJsonSchemaDocument = (decoder, document) => Object.defineProperty(de
|
|
|
1157
1224
|
var nestJsonSchema = (input, pointer) => {
|
|
1158
1225
|
const document = structuredClone(input);
|
|
1159
1226
|
const lookup = dereference(document);
|
|
1160
|
-
const
|
|
1227
|
+
const evaluated = evaluatedSchemas(document, lookup);
|
|
1161
1228
|
const pointers = /* @__PURE__ */ new Map();
|
|
1162
1229
|
const locate = (value, path) => {
|
|
1163
1230
|
if (!pointers.has(value)) pointers.set(value, path);
|
|
@@ -1171,8 +1238,7 @@ var nestJsonSchema = (input, pointer) => {
|
|
|
1171
1238
|
};
|
|
1172
1239
|
locate(document, pointer);
|
|
1173
1240
|
const references = /* @__PURE__ */ new Map();
|
|
1174
|
-
for (const schema of
|
|
1175
|
-
if (typeof schema === "boolean") continue;
|
|
1241
|
+
for (const schema of evaluated) {
|
|
1176
1242
|
const refs = {};
|
|
1177
1243
|
for (const [key, absolute] of [
|
|
1178
1244
|
["$ref", schema.__absolute_ref__],
|
|
@@ -1198,6 +1264,65 @@ var nestJsonSchema = (input, pointer) => {
|
|
|
1198
1264
|
Schema_exports.Record(Schema_exports.String, Schema_exports.Json)
|
|
1199
1265
|
)(rewrite(document));
|
|
1200
1266
|
};
|
|
1267
|
+
var identifiers = /* @__PURE__ */ new Set([
|
|
1268
|
+
"$id",
|
|
1269
|
+
"id",
|
|
1270
|
+
"$anchor",
|
|
1271
|
+
"$recursiveAnchor",
|
|
1272
|
+
"$recursiveRef",
|
|
1273
|
+
"$dynamicAnchor",
|
|
1274
|
+
"$dynamicRef"
|
|
1275
|
+
]);
|
|
1276
|
+
var ownDefinition = (reference) => {
|
|
1277
|
+
if (typeof reference !== "string" || !reference.startsWith("#/$defs/")) return void 0;
|
|
1278
|
+
const segments = pointerSegments(reference);
|
|
1279
|
+
return segments.length === 2 ? segments[1] : void 0;
|
|
1280
|
+
};
|
|
1281
|
+
var rootDefinitions = (schema) => {
|
|
1282
|
+
const definitions = schema.$defs ?? {};
|
|
1283
|
+
if (!isJsonRecord(definitions)) return void 0;
|
|
1284
|
+
const pending = [schema];
|
|
1285
|
+
for (let value = pending.pop(); value !== void 0; value = pending.pop()) {
|
|
1286
|
+
if (!isSchemaObject(value)) continue;
|
|
1287
|
+
for (const [key, item] of Object.entries(value)) {
|
|
1288
|
+
if (identifiers.has(key)) return void 0;
|
|
1289
|
+
if (key === "$ref") {
|
|
1290
|
+
const name = ownDefinition(item);
|
|
1291
|
+
if (name === void 0 || !Object.hasOwn(definitions, name)) return void 0;
|
|
1292
|
+
} else if (Array.isArray(item)) {
|
|
1293
|
+
if (schemaArrays.has(key) || key === "items") pending.push(...item);
|
|
1294
|
+
} else if (schemaMaps.has(key) || key === "dependencies") {
|
|
1295
|
+
if (isJsonRecord(item)) pending.push(...Object.values(item));
|
|
1296
|
+
} else if (schemaNodes.has(key)) pending.push(item);
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
return definitions;
|
|
1300
|
+
};
|
|
1301
|
+
var combineJsonSchemas = (schemas, pointer) => {
|
|
1302
|
+
const shared = {};
|
|
1303
|
+
const texts = /* @__PURE__ */ new Map();
|
|
1304
|
+
const combined = schemas.map((schema, index) => {
|
|
1305
|
+
const definitions = rootDefinitions(schema);
|
|
1306
|
+
const entries = Object.entries(definitions ?? {}).map(
|
|
1307
|
+
([name, definition]) => [name, definition, JSON.stringify(definition)]
|
|
1308
|
+
);
|
|
1309
|
+
if (definitions === void 0 || entries.some(([name, , text]) => texts.has(name) && texts.get(name) !== text))
|
|
1310
|
+
return nestJsonSchema(schema, pointer(index));
|
|
1311
|
+
for (const [name, definition, text] of entries) {
|
|
1312
|
+
if (texts.has(name)) continue;
|
|
1313
|
+
texts.set(name, text);
|
|
1314
|
+
Object.defineProperty(shared, name, {
|
|
1315
|
+
value: definition,
|
|
1316
|
+
enumerable: true,
|
|
1317
|
+
writable: true,
|
|
1318
|
+
configurable: true
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
const { $defs: _, ...rest } = schema;
|
|
1322
|
+
return rest;
|
|
1323
|
+
});
|
|
1324
|
+
return texts.size === 0 ? { schemas: combined } : { $defs: shared, schemas: combined };
|
|
1325
|
+
};
|
|
1201
1326
|
var schemaMaps = /* @__PURE__ */ new Set([
|
|
1202
1327
|
"$defs",
|
|
1203
1328
|
"definitions",
|
|
@@ -1219,6 +1344,27 @@ var schemaNodes = /* @__PURE__ */ new Set([
|
|
|
1219
1344
|
"unevaluatedItems",
|
|
1220
1345
|
"propertyNames"
|
|
1221
1346
|
]);
|
|
1347
|
+
var isSchemaObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1348
|
+
var evaluatedSchemas = (root, lookup) => {
|
|
1349
|
+
const found = /* @__PURE__ */ new Set();
|
|
1350
|
+
const pending = [root];
|
|
1351
|
+
for (let value = pending.pop(); value !== void 0; value = pending.pop()) {
|
|
1352
|
+
if (!isSchemaObject(value) || found.has(value)) continue;
|
|
1353
|
+
found.add(value);
|
|
1354
|
+
for (const target of [value.__absolute_ref__, value.__absolute_recursive_ref__]) {
|
|
1355
|
+
const schema = target === void 0 ? void 0 : lookup[target];
|
|
1356
|
+
if (schema !== void 0) pending.push(schema);
|
|
1357
|
+
}
|
|
1358
|
+
for (const [key, item] of Object.entries(value)) {
|
|
1359
|
+
if (Array.isArray(item)) {
|
|
1360
|
+
if (schemaArrays.has(key) || key === "items") pending.push(...item);
|
|
1361
|
+
} else if (schemaMaps.has(key) || key === "dependencies") {
|
|
1362
|
+
if (isJsonRecord(item)) pending.push(...Object.values(item));
|
|
1363
|
+
} else if (schemaNodes.has(key)) pending.push(item);
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
return found;
|
|
1367
|
+
};
|
|
1222
1368
|
function interpretedDocument(value) {
|
|
1223
1369
|
if (typeof value === "boolean") return value;
|
|
1224
1370
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
@@ -1271,18 +1417,425 @@ var containerKeywords = /* @__PURE__ */ new Set([
|
|
|
1271
1417
|
"else",
|
|
1272
1418
|
"dependentSchemas"
|
|
1273
1419
|
]);
|
|
1274
|
-
var
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1420
|
+
var echoableKey = (key) => /^[A-Za-z_$][\w$-]{0,63}$/.test(key);
|
|
1421
|
+
var schemaKey = (name) => echoableKey(name) ? name : JSON.stringify(name.slice(0, 64));
|
|
1422
|
+
var maxShapeKeys = 24;
|
|
1423
|
+
var objectShape = (keys, open, limit = maxShapeKeys) => {
|
|
1424
|
+
const listed = keys.slice(0, limit).map(({ name, optional }) => `${schemaKey(name)}${optional ? "?" : ""}`);
|
|
1425
|
+
const parts = [
|
|
1426
|
+
...listed,
|
|
1427
|
+
...keys.length > limit ? [`${keys.length - limit} more`] : [],
|
|
1428
|
+
...open ? ["..."] : []
|
|
1429
|
+
];
|
|
1430
|
+
return parts.length === 0 ? "object {} with no keys" : `object {${parts.join(", ")}}`;
|
|
1431
|
+
};
|
|
1432
|
+
var maxListedValues = 10;
|
|
1433
|
+
var maxValuesText = 200;
|
|
1434
|
+
var valueText = (value) => typeof value === "bigint" ? `${value}n` : JSON.stringify(value);
|
|
1435
|
+
var allowedValues = (values) => {
|
|
1436
|
+
const texts = [...new Set(values.map(valueText))];
|
|
1437
|
+
const listed = [];
|
|
1438
|
+
for (const text of texts) {
|
|
1439
|
+
if (listed.length === maxListedValues || [...listed, text].join(", ").length > maxValuesText)
|
|
1440
|
+
break;
|
|
1441
|
+
listed.push(text);
|
|
1442
|
+
}
|
|
1443
|
+
const [only] = listed;
|
|
1444
|
+
if (texts.length === 0) return "no value, since the schema allows none";
|
|
1445
|
+
if (only === void 0)
|
|
1446
|
+
return texts.length === 1 ? "a fixed value too long to list" : `one of ${texts.length} values too long to list`;
|
|
1447
|
+
if (texts.length === 1) return only;
|
|
1448
|
+
const rest = texts.length - listed.length;
|
|
1449
|
+
return `one of ${listed.join(", ")}${rest > 0 ? ` and ${rest} more` : ""}`;
|
|
1450
|
+
};
|
|
1451
|
+
var maxAlternativeKeys = 8;
|
|
1452
|
+
var maxAlternativesText = 360;
|
|
1453
|
+
var unionShape = (alternatives, selector) => {
|
|
1454
|
+
const listed = [];
|
|
1455
|
+
for (const alternative of alternatives) {
|
|
1456
|
+
if (listed.length > 0 && [...listed, alternative].join(" or ").length > maxAlternativesText)
|
|
1457
|
+
break;
|
|
1458
|
+
listed.push(alternative);
|
|
1459
|
+
}
|
|
1460
|
+
const rest = alternatives.length - listed.length;
|
|
1461
|
+
return `${[...listed, ...rest > 0 ? [`${rest} more`] : []].join(" or ")}${selector === void 0 ? "" : `, told apart by ${schemaKey(selector)}`}`;
|
|
1462
|
+
};
|
|
1463
|
+
var missingKey = (expected) => expected === void 0 ? missingKeyText : `${missingKeyText}. Expected ${expected}`;
|
|
1464
|
+
var missingKeyText = "Missing key";
|
|
1465
|
+
var isJsonRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1466
|
+
var pointerSegments = (pointer) => pointer === "#" || pointer === "" ? [] : pointer.replace(/^#?\//, "").split("/").map((segment) => decodeURIComponent(segment).replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
1467
|
+
var resolved = (lookup, uri2) => typeof uri2 === "string" && Object.hasOwn(lookup, uri2) ? lookup[uri2] : void 0;
|
|
1468
|
+
var referenced = (lookup, node) => isJsonRecord(node) ? resolved(lookup, Reflect.get(node, "__absolute_ref__") ?? node.$ref) : void 0;
|
|
1469
|
+
var memberKeywords = /* @__PURE__ */ new Set([...schemaMaps, ...schemaArrays, "dependencies"]);
|
|
1470
|
+
var combinators = /* @__PURE__ */ new Set(["allOf", "anyOf", "oneOf"]);
|
|
1471
|
+
var schemaAt = (document, lookup, segments) => {
|
|
1472
|
+
const anchoredAt = (node2, anchor2) => anchor2 === null && isJsonRecord(node2) && node2.$recursiveAnchor === true ? node2 : anchor2;
|
|
1473
|
+
const pending = [...segments];
|
|
1474
|
+
let node = document;
|
|
1475
|
+
let anchor = anchoredAt(document, null);
|
|
1476
|
+
for (let keyword = pending.shift(); keyword !== void 0; keyword = pending.shift()) {
|
|
1477
|
+
if (!isJsonRecord(node)) return void 0;
|
|
1478
|
+
if (keyword === "$recursiveRef") {
|
|
1479
|
+
const target = anchor === null ? resolved(lookup, Reflect.get(node, "__absolute_recursive_ref__")) : anchor;
|
|
1480
|
+
if (anchor !== null) node = anchor;
|
|
1481
|
+
anchor = target;
|
|
1482
|
+
continue;
|
|
1483
|
+
}
|
|
1484
|
+
if (keyword === "$ref") node = referenced(lookup, node);
|
|
1485
|
+
else {
|
|
1486
|
+
const value = Object.hasOwn(node, keyword) ? node[keyword] : void 0;
|
|
1487
|
+
if (memberKeywords.has(keyword) || keyword === "items" && Array.isArray(value)) {
|
|
1488
|
+
const member = pending.shift();
|
|
1489
|
+
if (member === void 0) return value;
|
|
1490
|
+
if (combinators.has(keyword) && node.$recursiveAnchor !== true) anchor = null;
|
|
1491
|
+
node = Array.isArray(value) ? /^\d+$/.test(member) ? value[Number(member)] : void 0 : isJsonRecord(value) && Object.hasOwn(value, member) ? value[member] : void 0;
|
|
1492
|
+
} else node = value;
|
|
1493
|
+
}
|
|
1494
|
+
anchor = anchoredAt(node, anchor);
|
|
1495
|
+
}
|
|
1496
|
+
return node;
|
|
1497
|
+
};
|
|
1498
|
+
var jsonObjectShape = (node) => {
|
|
1499
|
+
if (!isJsonRecord(node)) return "object";
|
|
1500
|
+
const properties = isJsonRecord(node.properties) ? Object.keys(node.properties) : [];
|
|
1501
|
+
const required = new Set(Array.isArray(node.required) ? node.required : []);
|
|
1502
|
+
const open = node.additionalProperties !== false || isJsonRecord(node.patternProperties) && Object.keys(node.patternProperties).length > 0;
|
|
1503
|
+
return properties.length === 0 && open ? "object" : objectShape(
|
|
1504
|
+
properties.map((name) => ({ name, optional: !required.has(name) })),
|
|
1505
|
+
open
|
|
1506
|
+
);
|
|
1507
|
+
};
|
|
1508
|
+
var locationKey = (segments) => JSON.stringify(segments);
|
|
1509
|
+
var emptyOutline = {
|
|
1510
|
+
types: void 0,
|
|
1511
|
+
properties: /* @__PURE__ */ new Map(),
|
|
1512
|
+
required: /* @__PURE__ */ new Set(),
|
|
1513
|
+
closed: false,
|
|
1514
|
+
values: void 0
|
|
1515
|
+
};
|
|
1516
|
+
var commonValues = (a, b) => a === void 0 ? b : b === void 0 ? a : a.filter((value) => b.some((other) => deepCompareStrict(value, other)));
|
|
1517
|
+
var strings = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
1518
|
+
var commonTypes = (a, b) => new Set(
|
|
1519
|
+
[...a].flatMap(
|
|
1520
|
+
(type) => b.has(type) ? [type] : type === "number" && b.has("integer") || type === "integer" && b.has("number") ? ["integer"] : []
|
|
1521
|
+
)
|
|
1522
|
+
);
|
|
1523
|
+
var mergeOutlines = (a, b) => ({
|
|
1524
|
+
types: a.types === void 0 ? b.types : b.types === void 0 ? a.types : commonTypes(a.types, b.types),
|
|
1525
|
+
properties: new Map([...a.properties, ...b.properties]),
|
|
1526
|
+
required: /* @__PURE__ */ new Set([...a.required, ...b.required]),
|
|
1527
|
+
closed: a.closed || b.closed,
|
|
1528
|
+
values: commonValues(a.values, b.values)
|
|
1529
|
+
});
|
|
1530
|
+
var outlineOf = (node, inspection, seen = /* @__PURE__ */ new Set()) => {
|
|
1531
|
+
if (!isJsonRecord(node) || seen.has(node)) return emptyOutline;
|
|
1532
|
+
const within = /* @__PURE__ */ new Set([...seen, node]);
|
|
1533
|
+
const own = {
|
|
1534
|
+
types: typeof node.type === "string" ? /* @__PURE__ */ new Set([node.type]) : Array.isArray(node.type) ? new Set(strings(node.type)) : void 0,
|
|
1535
|
+
properties: new Map(isJsonRecord(node.properties) ? Object.entries(node.properties) : []),
|
|
1536
|
+
required: new Set(strings(node.required)),
|
|
1537
|
+
closed: (node.additionalProperties === false || node.unevaluatedProperties === false) && !(isJsonRecord(node.patternProperties) && Object.keys(node.patternProperties).length > 0),
|
|
1538
|
+
values: commonValues(
|
|
1539
|
+
Object.hasOwn(node, "const") ? [node.const] : void 0,
|
|
1540
|
+
Array.isArray(node.enum) ? node.enum : void 0
|
|
1541
|
+
)
|
|
1542
|
+
};
|
|
1543
|
+
return [inspection.referenced(node), ...Array.isArray(node.allOf) ? node.allOf : []].reduce(
|
|
1544
|
+
(outline, member) => mergeOutlines(outline, outlineOf(member, inspection, within)),
|
|
1545
|
+
own
|
|
1546
|
+
);
|
|
1547
|
+
};
|
|
1548
|
+
var otherConstraints = "a value with other constraints";
|
|
1549
|
+
var outlineText = (outline, limit) => {
|
|
1550
|
+
if (outline.values !== void 0) return allowedValues(outline.values);
|
|
1551
|
+
const names = [
|
|
1552
|
+
...outline.properties.keys(),
|
|
1553
|
+
...[...outline.required].filter((name) => !outline.properties.has(name))
|
|
1554
|
+
];
|
|
1555
|
+
const shape = names.length === 0 && !outline.closed ? "object" : objectShape(
|
|
1556
|
+
names.map((name) => ({ name, optional: !outline.required.has(name) })),
|
|
1557
|
+
!outline.closed,
|
|
1558
|
+
limit
|
|
1559
|
+
);
|
|
1560
|
+
if (outline.types === void 0)
|
|
1561
|
+
return names.length > 0 || outline.closed ? shape : otherConstraints;
|
|
1562
|
+
return [...outline.types].map((type) => type === "object" ? shape : type).join(" or ");
|
|
1563
|
+
};
|
|
1564
|
+
var describeOutline = (outline) => outlineText(outline, maxAlternativeKeys);
|
|
1565
|
+
var typed = (outline) => outline.values !== void 0 || outline.types !== void 0;
|
|
1566
|
+
var describeProperty = (node, inspection) => {
|
|
1567
|
+
const target = inspection.referenced(node) ?? node;
|
|
1568
|
+
if (isJsonRecord(target) && Object.hasOwn(target, "oneOf")) return void 0;
|
|
1569
|
+
const outline = outlineOf(node, inspection);
|
|
1570
|
+
if (typed(outline)) return outlineText(outline, maxShapeKeys);
|
|
1571
|
+
const members = isJsonRecord(target) && Array.isArray(target.anyOf) ? target.anyOf : [];
|
|
1572
|
+
const outlines = members.filter((member) => member !== false).map((member) => outlineOf(member, inspection));
|
|
1573
|
+
return outlines.length === 0 || !outlines.every(typed) ? void 0 : unionShape([...new Set(outlines.map(describeOutline))], void 0);
|
|
1574
|
+
};
|
|
1575
|
+
var maxPatternText = 160;
|
|
1576
|
+
var count = (amount, noun) => `${amount} ${noun}${amount === 1 ? "" : "s"}`;
|
|
1577
|
+
var constraintProblem = (keyword, node) => {
|
|
1578
|
+
if (!isJsonRecord(node)) return void 0;
|
|
1579
|
+
const value = node[keyword];
|
|
1580
|
+
if (keyword === "pattern")
|
|
1581
|
+
return typeof value !== "string" ? void 0 : value.length <= maxPatternText ? `Expected a string matching the pattern ${JSON.stringify(value)}` : "Expected a string matching the schema's pattern, which is too long to show";
|
|
1582
|
+
if (keyword === "format")
|
|
1583
|
+
return typeof value === "string" ? `Expected a string in the ${JSON.stringify(value.slice(0, 64))} format` : void 0;
|
|
1584
|
+
if (keyword === "uniqueItems") return "Expected an array without repeated items";
|
|
1585
|
+
if (typeof value !== "number") return void 0;
|
|
1586
|
+
switch (keyword) {
|
|
1587
|
+
// Draft 4's boolean `exclusiveMinimum` is not applied: imported schemas validate as draft 7
|
|
1588
|
+
// or 2020-12, where `minimum` and `maximum` always include their bound.
|
|
1589
|
+
case "minimum":
|
|
1590
|
+
return `Expected a number of at least ${value}`;
|
|
1591
|
+
case "maximum":
|
|
1592
|
+
return `Expected a number of at most ${value}`;
|
|
1593
|
+
case "exclusiveMinimum":
|
|
1594
|
+
return `Expected a number greater than ${value}`;
|
|
1595
|
+
case "exclusiveMaximum":
|
|
1596
|
+
return `Expected a number less than ${value}`;
|
|
1597
|
+
case "multipleOf":
|
|
1598
|
+
return `Expected a multiple of ${value}`;
|
|
1599
|
+
case "minLength":
|
|
1600
|
+
return `Expected a string of at least ${count(value, "character")}`;
|
|
1601
|
+
case "maxLength":
|
|
1602
|
+
return `Expected a string of at most ${count(value, "character")}`;
|
|
1603
|
+
case "minItems":
|
|
1604
|
+
return `Expected an array of at least ${count(value, "item")}`;
|
|
1605
|
+
case "maxItems":
|
|
1606
|
+
return `Expected an array of at most ${count(value, "item")}`;
|
|
1607
|
+
case "minProperties":
|
|
1608
|
+
return `Expected an object with at least ${count(value, "key")}`;
|
|
1609
|
+
case "maxProperties":
|
|
1610
|
+
return `Expected an object with at most ${count(value, "key")}`;
|
|
1611
|
+
default:
|
|
1612
|
+
return void 0;
|
|
1613
|
+
}
|
|
1614
|
+
};
|
|
1615
|
+
var overlap = (outline, value, inspection, depth = 0) => !isJsonRecord(value) || depth > 16 ? 0 : Object.entries(value).reduce((total, [key, item]) => {
|
|
1616
|
+
const property = outline.properties.get(key);
|
|
1617
|
+
return property === void 0 ? total : total + 1 + overlap(outlineOf(property, inspection), item, inspection, depth + 1);
|
|
1618
|
+
}, 0);
|
|
1619
|
+
var jsonType = (value) => value === null ? "null" : Array.isArray(value) ? "array" : typeof value === "object" ? "object" : typeof value;
|
|
1620
|
+
var accepted = (outline, value) => {
|
|
1621
|
+
const type = jsonType(value);
|
|
1622
|
+
if (outline.values !== void 0)
|
|
1623
|
+
return outline.values.some((allowed) => jsonType(allowed) === type);
|
|
1624
|
+
if (outline.types === void 0) return true;
|
|
1625
|
+
return outline.types.has(type) || type === "number" && outline.types.has("integer") && Number.isInteger(value);
|
|
1626
|
+
};
|
|
1627
|
+
var valueAt = (input, location2) => location2.reduce(
|
|
1628
|
+
(value, segment) => Array.isArray(value) ? value[Number(segment)] : isJsonRecord(value) && Object.hasOwn(value, segment) ? value[segment] : void 0,
|
|
1629
|
+
input
|
|
1630
|
+
);
|
|
1631
|
+
var discriminatorOf = (holder) => isJsonRecord(holder) && isJsonRecord(holder.discriminator) ? holder.discriminator : void 0;
|
|
1632
|
+
var definitionName = (reference) => {
|
|
1633
|
+
if (typeof reference !== "string" || !reference.startsWith("#/")) return void 0;
|
|
1634
|
+
const segments = pointerSegments(reference);
|
|
1635
|
+
const container = segments.at(-2);
|
|
1636
|
+
return container === "$defs" || container === "definitions" || container === "schemas" && segments.at(-3) === "components" ? segments.at(-1) : void 0;
|
|
1637
|
+
};
|
|
1638
|
+
var discriminatedName = (holder, value) => {
|
|
1639
|
+
const discriminator = discriminatorOf(holder);
|
|
1640
|
+
if (discriminator === void 0 || typeof value !== "string") return void 0;
|
|
1641
|
+
const { mapping } = discriminator;
|
|
1642
|
+
const target = isJsonRecord(mapping) && Object.hasOwn(mapping, value) ? mapping[value] : value;
|
|
1643
|
+
if (typeof target !== "string") return void 0;
|
|
1644
|
+
return /^[\w.-]+$/.test(target) ? target : definitionName(target);
|
|
1645
|
+
};
|
|
1646
|
+
var selectorOf = (holder, alternatives, inspection) => {
|
|
1647
|
+
const declared = discriminatorOf(holder)?.propertyName;
|
|
1648
|
+
if (typeof declared === "string") return declared;
|
|
1649
|
+
const [first] = alternatives;
|
|
1650
|
+
if (first === void 0 || alternatives.length < 2) return void 0;
|
|
1651
|
+
return [...first.properties.keys()].find(
|
|
1652
|
+
(key) => alternatives.every(
|
|
1653
|
+
(alternative) => alternative.properties.has(key) && outlineOf(alternative.properties.get(key), inspection).values !== void 0
|
|
1654
|
+
)
|
|
1655
|
+
);
|
|
1656
|
+
};
|
|
1657
|
+
var alternativeErrors = (errors, head, schemas) => {
|
|
1658
|
+
const prefix = `${errors[head]?.keywordLocation}/`;
|
|
1659
|
+
const alternatives = /* @__PURE__ */ new Map();
|
|
1660
|
+
const settle = (current2, next) => {
|
|
1661
|
+
const collected = alternatives.get(current2);
|
|
1662
|
+
const rejected = Array.isArray(schemas) ? schemas.slice(current2 + 1, next).filter((schema) => schema === false).length : 0;
|
|
1663
|
+
if (collected !== void 0) collected.splice(collected.length - rejected, rejected);
|
|
1664
|
+
};
|
|
1665
|
+
let index = head + 1;
|
|
1666
|
+
let current = -1;
|
|
1667
|
+
for (; index < errors.length; index++) {
|
|
1668
|
+
const error = errors[index];
|
|
1669
|
+
if (error === void 0) break;
|
|
1670
|
+
if (error.keywordLocation.startsWith(prefix)) {
|
|
1671
|
+
const alternative = Number(error.keywordLocation.slice(prefix.length).split("/")[0]);
|
|
1672
|
+
if (alternative !== current) settle(current, alternative);
|
|
1673
|
+
current = alternative;
|
|
1674
|
+
} else if (error.keyword !== "false") break;
|
|
1675
|
+
if (current >= 0) alternatives.set(current, [...alternatives.get(current) ?? [], error]);
|
|
1676
|
+
}
|
|
1677
|
+
settle(current, Array.isArray(schemas) ? schemas.length : current);
|
|
1678
|
+
return { alternatives, end: index };
|
|
1679
|
+
};
|
|
1680
|
+
var pathOf = (location2) => location2.map((segment) => /^\d+$/.test(segment) ? Number(segment) : segment);
|
|
1681
|
+
var unionProblems = (union, schemas, errorsByAlternative, inspection) => {
|
|
1682
|
+
const location2 = pointerSegments(union.instanceLocation);
|
|
1683
|
+
const path = pathOf(location2);
|
|
1684
|
+
if (!Array.isArray(schemas))
|
|
1685
|
+
return [
|
|
1686
|
+
{ path, issue: `Failed the "${union.keyword}" constraint` },
|
|
1687
|
+
...[...errorsByAlternative.values()].flatMap((errors) => problemsOf(errors, inspection))
|
|
1688
|
+
];
|
|
1689
|
+
const alternatives = schemas.flatMap(
|
|
1690
|
+
(schema, index) => schema === false ? [] : [
|
|
1691
|
+
{
|
|
1692
|
+
schema,
|
|
1693
|
+
matched: !errorsByAlternative.has(index),
|
|
1694
|
+
problems: () => problemsOf(errorsByAlternative.get(index) ?? [], inspection)
|
|
1695
|
+
}
|
|
1696
|
+
]
|
|
1697
|
+
);
|
|
1698
|
+
const [only] = alternatives;
|
|
1699
|
+
if (only === void 0) return [{ path, issue: "No value is allowed here" }];
|
|
1700
|
+
if (alternatives.length === 1) return only.problems();
|
|
1701
|
+
const holder = inspection.schemaAt(pointerSegments(union.keywordLocation).slice(0, -1));
|
|
1702
|
+
const shared = outlineOf(holder, inspection);
|
|
1703
|
+
const own = alternatives.map(({ schema }) => outlineOf(schema, inspection));
|
|
1704
|
+
const outlines = own.map((outline) => mergeOutlines(shared, outline));
|
|
1705
|
+
const selector = selectorOf(holder, own, inspection);
|
|
1706
|
+
const expected = `Expected ${unionShape(outlines.map(describeOutline), selector)}`;
|
|
1707
|
+
const matched = alternatives.filter((alternative) => alternative.matched).length;
|
|
1708
|
+
if (union.keyword === "oneOf" && matched > 1)
|
|
1709
|
+
return [{ path, issue: `${expected}. Exactly one may match, but ${matched} do` }];
|
|
1710
|
+
const fixed = outlines.flatMap(({ values }) => values === void 0 ? [] : [values]);
|
|
1711
|
+
if (fixed.length === outlines.length)
|
|
1712
|
+
return [
|
|
1713
|
+
{
|
|
1714
|
+
path,
|
|
1715
|
+
issue: union.keyword === "oneOf" ? `${expected}. Exactly one alternative must match` : `Expected ${allowedValues(fixed.flat())}`
|
|
1716
|
+
}
|
|
1717
|
+
];
|
|
1718
|
+
const value = valueAt(inspection.input, location2);
|
|
1719
|
+
const selectorValue = selector !== void 0 && isJsonRecord(value) && Object.hasOwn(value, selector) ? { value: value[selector] } : void 0;
|
|
1720
|
+
const named = discriminatedName(holder, selectorValue?.value);
|
|
1721
|
+
const ranked = alternatives.map(({ schema, problems }, index) => {
|
|
1722
|
+
const outline = outlines[index] ?? emptyOutline;
|
|
1723
|
+
const property = own[index]?.properties.get(selector ?? "");
|
|
1724
|
+
return {
|
|
1725
|
+
index,
|
|
1726
|
+
problems: problems(),
|
|
1727
|
+
selected: selectorValue !== void 0 && (named !== void 0 && isJsonRecord(schema) && definitionName(schema.$ref) === named || property !== void 0 && outlineOf(property, inspection).values !== void 0 && inspection.accepts(property, selectorValue.value)),
|
|
1728
|
+
typed: accepted(outline, value),
|
|
1729
|
+
overlap: overlap(outline, value, inspection)
|
|
1283
1730
|
};
|
|
1284
|
-
return [issue];
|
|
1285
1731
|
});
|
|
1732
|
+
const closest = ranked.reduce(
|
|
1733
|
+
(best, candidate) => ([
|
|
1734
|
+
Number(candidate.selected) - Number(best.selected),
|
|
1735
|
+
Number(candidate.typed) - Number(best.typed),
|
|
1736
|
+
candidate.overlap - best.overlap,
|
|
1737
|
+
best.problems.length - candidate.problems.length
|
|
1738
|
+
].find((difference) => difference !== 0) ?? 0) > 0 ? candidate : best
|
|
1739
|
+
);
|
|
1740
|
+
return closest.selected || closest.typed ? [
|
|
1741
|
+
{
|
|
1742
|
+
path,
|
|
1743
|
+
issue: `${expected}. Closest is alternative ${closest.index + 1}, whose problems follow`
|
|
1744
|
+
},
|
|
1745
|
+
...closest.problems
|
|
1746
|
+
] : [{ path, issue: expected }];
|
|
1747
|
+
};
|
|
1748
|
+
var problemsOf = (errors, inspection) => {
|
|
1749
|
+
const closed = /* @__PURE__ */ new Map();
|
|
1750
|
+
const problems = [];
|
|
1751
|
+
for (let index = 0; index < errors.length; index++) {
|
|
1752
|
+
const error = errors[index];
|
|
1753
|
+
if (error === void 0) break;
|
|
1754
|
+
const { keyword, instanceLocation, keywordLocation } = error;
|
|
1755
|
+
if (keyword === "anyOf" || keyword === "oneOf") {
|
|
1756
|
+
const schemas = inspection.schemaAt(pointerSegments(keywordLocation));
|
|
1757
|
+
const { alternatives, end } = alternativeErrors(errors, index, schemas);
|
|
1758
|
+
problems.push(...unionProblems(error, schemas, alternatives, inspection));
|
|
1759
|
+
index = end - 1;
|
|
1760
|
+
continue;
|
|
1761
|
+
}
|
|
1762
|
+
const location2 = pointerSegments(instanceLocation);
|
|
1763
|
+
const path = pathOf(location2);
|
|
1764
|
+
const problem = (issue, at = path) => problems.push({ path: at, issue });
|
|
1765
|
+
const node = () => inspection.schemaAt(pointerSegments(keywordLocation).slice(0, -1));
|
|
1766
|
+
if (keyword === "additionalProperties" || keyword === "unevaluatedProperties") {
|
|
1767
|
+
closed.set(locationKey(location2), node());
|
|
1768
|
+
continue;
|
|
1769
|
+
}
|
|
1770
|
+
if (containerKeywords.has(keyword)) continue;
|
|
1771
|
+
if (keyword === "false") {
|
|
1772
|
+
const key = location2.at(-1);
|
|
1773
|
+
const parent = locationKey(location2.slice(0, -1));
|
|
1774
|
+
if (key === void 0 || !closed.has(parent)) problem("No value is allowed here");
|
|
1775
|
+
else
|
|
1776
|
+
problem(
|
|
1777
|
+
`Unexpected key${echoableKey(key) ? ` "${key}"` : ""}. Expected ${jsonObjectShape(closed.get(parent))}`,
|
|
1778
|
+
path.slice(0, -1)
|
|
1779
|
+
);
|
|
1780
|
+
continue;
|
|
1781
|
+
}
|
|
1782
|
+
const required = keyword === "required" ? /required property "([^"]*)"/.exec(error.error) : null;
|
|
1783
|
+
if (required !== null) {
|
|
1784
|
+
const name = required[1] ?? "";
|
|
1785
|
+
const property = outlineOf(node(), inspection).properties.get(name);
|
|
1786
|
+
problem(
|
|
1787
|
+
missingKey(property === void 0 ? void 0 : describeProperty(property, inspection)),
|
|
1788
|
+
[...path, name]
|
|
1789
|
+
);
|
|
1790
|
+
continue;
|
|
1791
|
+
}
|
|
1792
|
+
const expected = keyword === "type" ? /Expected "([^.]*)"\.?$/.exec(error.error) : null;
|
|
1793
|
+
if (expected !== null) {
|
|
1794
|
+
const types = (expected[1] ?? "").split('", "').map((type) => type === "object" ? jsonObjectShape(node()) : type);
|
|
1795
|
+
problem(`Expected ${types.join(" or ")}`);
|
|
1796
|
+
continue;
|
|
1797
|
+
}
|
|
1798
|
+
if (keyword === "const" || keyword === "enum") {
|
|
1799
|
+
const schema = node();
|
|
1800
|
+
const values = !isJsonRecord(schema) ? void 0 : keyword === "const" ? Object.hasOwn(schema, "const") ? [schema.const] : void 0 : Array.isArray(schema.enum) ? schema.enum : void 0;
|
|
1801
|
+
problem(
|
|
1802
|
+
values === void 0 ? "Expected one of the allowed values" : `Expected ${allowedValues(values)}`
|
|
1803
|
+
);
|
|
1804
|
+
continue;
|
|
1805
|
+
}
|
|
1806
|
+
problem(constraintProblem(keyword, node()) ?? `Failed the "${keyword}" constraint`);
|
|
1807
|
+
}
|
|
1808
|
+
return problems;
|
|
1809
|
+
};
|
|
1810
|
+
var documentKeys = (document) => {
|
|
1811
|
+
const named = /* @__PURE__ */ new Set();
|
|
1812
|
+
let any = false;
|
|
1813
|
+
const visit = (node, depth) => {
|
|
1814
|
+
if (depth > 64 || typeof node !== "object" || node === null) return;
|
|
1815
|
+
if (Array.isArray(node)) {
|
|
1816
|
+
for (const item of node) visit(item, depth + 1);
|
|
1817
|
+
return;
|
|
1818
|
+
}
|
|
1819
|
+
const record2 = node;
|
|
1820
|
+
if (isJsonRecord(record2.properties))
|
|
1821
|
+
for (const name of Object.keys(record2.properties)) named.add(name);
|
|
1822
|
+
for (const name of strings(record2.required)) named.add(name);
|
|
1823
|
+
if (isJsonRecord(record2.dependentRequired))
|
|
1824
|
+
for (const [name, names] of Object.entries(record2.dependentRequired)) {
|
|
1825
|
+
named.add(name);
|
|
1826
|
+
for (const other of strings(names)) named.add(other);
|
|
1827
|
+
}
|
|
1828
|
+
if (isJsonRecord(record2.patternProperties) && Object.keys(record2.patternProperties).length > 0 || isJsonRecord(record2.additionalProperties) || isJsonRecord(record2.unevaluatedProperties))
|
|
1829
|
+
any = true;
|
|
1830
|
+
for (const value of Object.values(record2)) visit(value, depth + 1);
|
|
1831
|
+
};
|
|
1832
|
+
visit(document, 0);
|
|
1833
|
+
return (key) => any || named.has(key);
|
|
1834
|
+
};
|
|
1835
|
+
var importedKeys = /* @__PURE__ */ new WeakMap();
|
|
1836
|
+
var importedSchemaKeys = (check) => importedKeys.get(check);
|
|
1837
|
+
var jsonSchemaProblems = (errors, inspection) => {
|
|
1838
|
+
const problems = problemsOf(errors, inspection);
|
|
1286
1839
|
return problems.length === 0 ? false : problems;
|
|
1287
1840
|
};
|
|
1288
1841
|
var compileJsonSchemaDecoder = (document) => Effect_exports.gen(function* () {
|
|
@@ -1293,8 +1846,7 @@ var compileJsonSchemaDecoder = (document) => Effect_exports.gen(function* () {
|
|
|
1293
1846
|
if (normalized === null || typeof normalized !== "object" || Array.isArray(normalized))
|
|
1294
1847
|
throw new ValidationError();
|
|
1295
1848
|
const lookup = dereference(normalized);
|
|
1296
|
-
for (const schema of
|
|
1297
|
-
if (typeof schema === "boolean") continue;
|
|
1849
|
+
for (const schema of evaluatedSchemas(normalized, lookup)) {
|
|
1298
1850
|
for (const pattern of [schema.pattern, ...Object.keys(schema.patternProperties ?? {})]) {
|
|
1299
1851
|
if (pattern === void 0) continue;
|
|
1300
1852
|
try {
|
|
@@ -1309,53 +1861,112 @@ var compileJsonSchemaDecoder = (document) => Effect_exports.gen(function* () {
|
|
|
1309
1861
|
throw new ValidationError();
|
|
1310
1862
|
}
|
|
1311
1863
|
}
|
|
1864
|
+
const inspection = (input) => ({
|
|
1865
|
+
schemaAt: (segments) => schemaAt(normalized, lookup, segments),
|
|
1866
|
+
referenced: (node) => referenced(lookup, node),
|
|
1867
|
+
accepts: (node, value) => {
|
|
1868
|
+
if (typeof node !== "boolean" && !isJsonRecord(node)) return false;
|
|
1869
|
+
try {
|
|
1870
|
+
return validate(value, node, draft, lookup).valid;
|
|
1871
|
+
} catch {
|
|
1872
|
+
return false;
|
|
1873
|
+
}
|
|
1874
|
+
},
|
|
1875
|
+
input
|
|
1876
|
+
});
|
|
1312
1877
|
return {
|
|
1313
|
-
validate: (input) => validate(input, normalized, draft, lookup)
|
|
1878
|
+
validate: (input) => validate(input, normalized, draft, lookup),
|
|
1879
|
+
inspection
|
|
1314
1880
|
};
|
|
1315
1881
|
},
|
|
1316
1882
|
catch: () => new ValidationError()
|
|
1317
1883
|
});
|
|
1318
|
-
const
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
{ expected: "a value matching a supported imported JSON Schema" }
|
|
1329
|
-
)
|
|
1884
|
+
const check = Schema_exports.makeFilter(
|
|
1885
|
+
(value) => {
|
|
1886
|
+
try {
|
|
1887
|
+
const result = validator.validate(value);
|
|
1888
|
+
return result.valid || jsonSchemaProblems(result.errors, validator.inspection(value));
|
|
1889
|
+
} catch {
|
|
1890
|
+
return false;
|
|
1891
|
+
}
|
|
1892
|
+
},
|
|
1893
|
+
{ expected: "a value matching a supported imported JSON Schema" }
|
|
1330
1894
|
);
|
|
1895
|
+
importedKeys.set(check, documentKeys(document));
|
|
1896
|
+
const decoder = Schema_exports.Json.check(check);
|
|
1331
1897
|
return Object.assign(decoder, { [ImportedJsonSchema]: document });
|
|
1332
1898
|
});
|
|
1333
|
-
var
|
|
1899
|
+
var lazyCompiledDecoder = (document) => {
|
|
1334
1900
|
const read = once(document);
|
|
1335
|
-
|
|
1901
|
+
let compiled;
|
|
1902
|
+
const compile = Effect_exports.suspend(
|
|
1903
|
+
() => compiled ?? compileJsonSchemaDecoder(read()).pipe(
|
|
1904
|
+
// An interrupted compilation is not a result; the next decode compiles again.
|
|
1905
|
+
Effect_exports.onExit(
|
|
1906
|
+
(exit) => Effect_exports.sync(() => {
|
|
1907
|
+
if (Exit_exports.isSuccess(exit) || !Cause_exports.hasInterrupts(exit.cause)) compiled = exit;
|
|
1908
|
+
})
|
|
1909
|
+
)
|
|
1910
|
+
)
|
|
1911
|
+
);
|
|
1336
1912
|
const decoder = Schema_exports.declareConstructor()(
|
|
1337
1913
|
[],
|
|
1338
|
-
() => (input, _ast, options) =>
|
|
1339
|
-
Effect_exports.mapError(
|
|
1340
|
-
() => new SchemaIssue_exports.InvalidValue({ message: "Unsupported JSON Schema" })
|
|
1341
|
-
),
|
|
1914
|
+
() => (input, _ast, options) => compile.pipe(
|
|
1915
|
+
Effect_exports.mapError(() => new SchemaIssue_exports.InvalidValue({ message: "Unsupported JSON Schema" })),
|
|
1342
1916
|
Effect_exports.flatMap((schema) => SchemaParser_exports.decodeUnknownEffect(schema)(input, options))
|
|
1343
1917
|
)
|
|
1344
1918
|
);
|
|
1345
|
-
return withLazyJsonSchemaDocument(decoder, read);
|
|
1919
|
+
return { decoder: withLazyJsonSchemaDocument(decoder, read), compile };
|
|
1920
|
+
};
|
|
1921
|
+
var lazyDecoder = (document) => lazyCompiledDecoder(document).decoder;
|
|
1922
|
+
var lazyJsonSchemaDecoder = (document) => Effect_exports.sync(() => lazyDecoder(document));
|
|
1923
|
+
var preparedJsonSchemaDecoder = (document) => lazyCompiledDecoder(() => document);
|
|
1924
|
+
var isJsonValue = Schema_exports.is(Schema_exports.Json);
|
|
1925
|
+
var jsonDocument = (input) => {
|
|
1926
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) return void 0;
|
|
1927
|
+
const keys = Object.keys(input);
|
|
1928
|
+
const values = keys.map((key) => Reflect.get(input, key));
|
|
1929
|
+
if (!isJsonValue(values)) return void 0;
|
|
1930
|
+
const document = {};
|
|
1931
|
+
keys.forEach(
|
|
1932
|
+
(key, index) => Object.defineProperty(document, key, {
|
|
1933
|
+
value: values[index],
|
|
1934
|
+
enumerable: true,
|
|
1935
|
+
writable: true,
|
|
1936
|
+
configurable: true
|
|
1937
|
+
})
|
|
1938
|
+
);
|
|
1939
|
+
return document;
|
|
1940
|
+
};
|
|
1941
|
+
var jsonSchemaDecoder = (input) => Effect_exports.suspend(() => {
|
|
1942
|
+
const document = jsonDocument(input);
|
|
1943
|
+
return document === void 0 ? Effect_exports.fail(new ValidationError()) : lazyJsonSchemaDecoder(() => document);
|
|
1346
1944
|
});
|
|
1347
|
-
var
|
|
1348
|
-
|
|
1349
|
-
);
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1945
|
+
var jsonSchema = (input) => {
|
|
1946
|
+
const document = jsonDocument(input);
|
|
1947
|
+
if (document === void 0) throw new ValidationError();
|
|
1948
|
+
return wrap(
|
|
1949
|
+
lazyDecoder(() => document),
|
|
1950
|
+
false
|
|
1951
|
+
);
|
|
1952
|
+
};
|
|
1953
|
+
var jsonSchemaDocument = (decoder) => {
|
|
1954
|
+
const imported = importedJsonSchema(decoder);
|
|
1955
|
+
if (imported !== void 0) return Schema_exports.decodeUnknownEffect(JsonObject)(imported);
|
|
1956
|
+
const document = Schema_exports.toJsonSchemaDocument(decoder);
|
|
1957
|
+
return Schema_exports.decodeUnknownEffect(JsonObject)({
|
|
1958
|
+
...document.schema,
|
|
1959
|
+
$defs: document.definitions,
|
|
1960
|
+
$schema: "https://json-schema.org/draft/2020-12/schema"
|
|
1961
|
+
});
|
|
1962
|
+
};
|
|
1354
1963
|
|
|
1355
1964
|
export {
|
|
1356
1965
|
decoderOf,
|
|
1357
1966
|
isSchema,
|
|
1967
|
+
schemaArgument,
|
|
1358
1968
|
parse,
|
|
1969
|
+
parseDeclaration,
|
|
1359
1970
|
wrap,
|
|
1360
1971
|
string,
|
|
1361
1972
|
number,
|
|
@@ -1365,15 +1976,26 @@ export {
|
|
|
1365
1976
|
literal,
|
|
1366
1977
|
array,
|
|
1367
1978
|
object,
|
|
1979
|
+
plain,
|
|
1980
|
+
raw,
|
|
1981
|
+
fieldExposure,
|
|
1368
1982
|
importedJsonSchema,
|
|
1369
1983
|
once,
|
|
1370
1984
|
withLazyJsonSchemaDocument,
|
|
1371
1985
|
nestJsonSchema,
|
|
1986
|
+
combineJsonSchemas,
|
|
1987
|
+
echoableKey,
|
|
1988
|
+
objectShape,
|
|
1989
|
+
allowedValues,
|
|
1990
|
+
maxAlternativeKeys,
|
|
1991
|
+
unionShape,
|
|
1992
|
+
missingKey,
|
|
1993
|
+
missingKeyText,
|
|
1994
|
+
importedSchemaKeys,
|
|
1372
1995
|
compileJsonSchemaDecoder,
|
|
1373
1996
|
lazyJsonSchemaDecoder,
|
|
1997
|
+
preparedJsonSchemaDecoder,
|
|
1374
1998
|
jsonSchemaDecoder,
|
|
1375
1999
|
jsonSchema,
|
|
1376
|
-
|
|
1377
|
-
id,
|
|
1378
|
-
userId
|
|
2000
|
+
jsonSchemaDocument
|
|
1379
2001
|
};
|