apps 0.0.1-beta.4 → 0.0.1-beta.40
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 +68 -44
- package/framework-reference.json +1 -1
- package/js/{chunk-QKHR7BMF.js → chunk-3MMG2H6M.js} +89 -53
- package/js/chunk-4TLZGG4B.js +729 -0
- package/js/chunk-6KABJTDO.js +255 -0
- package/js/{chunk-FDNTX5QJ.js → chunk-CQD3WSYH.js} +2 -2
- package/js/{chunk-EQB7JMAL.js → chunk-DHX2OI2X.js} +146 -31
- package/js/{chunk-EVJUVWN2.js → chunk-DKUEYTYD.js} +463 -218
- package/js/chunk-EM4UL26F.js +118 -0
- package/js/{chunk-WFSQXYUT.js → chunk-GHXRRFZA.js} +418 -52
- package/js/{chunk-5MQZEB6Y.js → chunk-KANDIVIH.js} +40 -12
- package/js/chunk-KAQD3DTI.js +16 -0
- package/js/chunk-KIM5HXNK.js +49 -0
- package/js/{chunk-FW5HBOIK.js → chunk-MXDKXAY4.js} +19117 -18309
- package/js/{chunk-2VPJHFOU.js → chunk-MYF7KWUB.js} +128 -24
- package/js/{chunk-T2LAZCAD.js → chunk-NKWWPJYX.js} +3 -3
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/{chunk-3M2MEDNL.js → chunk-OTCLXFLL.js} +1337 -188
- package/js/chunk-P7MGDPFD.js +240 -0
- package/js/chunk-PDS2E2OZ.js +42 -0
- package/js/{chunk-ZCAMUXSG.js → chunk-PNVCCB4L.js} +432 -79
- package/js/{chunk-D47C7KG5.js → chunk-RIXVGVA6.js} +2 -2
- package/js/{chunk-6VRYO2BG.js → chunk-SALJXSS3.js} +779 -251
- package/js/{chunk-NQ3OMCA5.js → chunk-TT6OU4UG.js} +2 -2
- package/js/{chunk-YEJOQEII.js → chunk-UOZMSUJ2.js} +61 -9
- package/js/{chunk-G7ZIRKMK.js → chunk-VIU2XXA7.js} +228 -264
- package/js/{chunk-HDJH3RPR.js → chunk-VJQXXOQ3.js} +4 -4
- package/js/chunk-XDGUGB2A.js +156 -0
- package/js/{chunk-SATWJKN6.js → chunk-YQ35E7KS.js} +2 -2
- package/js/chunk-ZUKBIHMK.js +92 -0
- package/js/client.js +122 -88
- package/js/contracts.js +116 -25
- package/js/effect.js +19 -20
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +57 -55
- package/js/host.js +19 -20
- package/js/index.js +245 -212
- package/js/mcp/effect.js +23 -22
- package/js/mcp/stdio.js +34 -30
- package/js/mcp.js +104 -68
- package/js/openapi.js +4087 -1503
- package/js/react.js +2 -3
- package/js/skills/effect.js +6 -3
- package/js/skills.js +147 -65
- package/js/storage/facet.js +1 -540
- package/js/ui/auth/contracts.js +2 -2
- package/js/ui/auth.js +5 -5
- package/js/ui/contracts.js +5 -4
- package/js/ui/serving.js +8517 -214
- package/package.json +2 -3
- package/runtime.json +1 -1
- 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 +7 -8
- package/types/apps/src/contracts/cache.d.ts +14 -0
- package/types/apps/src/contracts/context.d.ts +12 -11
- package/types/apps/src/contracts/elicitation.d.ts +6 -6
- 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 +44 -17
- package/types/apps/src/contracts/live.d.ts +2 -0
- package/types/apps/src/contracts/mcp.d.ts +96 -10
- package/types/apps/src/contracts/network.d.ts +84 -0
- package/types/apps/src/contracts/openapi-compile.d.ts +32 -3
- package/types/apps/src/contracts/openapi.d.ts +45 -9
- package/types/apps/src/contracts/operations.d.ts +8 -9
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +263 -74
- package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
- package/types/apps/src/contracts/protocols/2.d.ts +66 -24
- package/types/apps/src/contracts/protocols/3.d.ts +715 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1297 -0
- package/types/apps/src/contracts/protocols/5.d.ts +1174 -0
- package/types/apps/src/contracts/protocols/6.d.ts +1620 -0
- package/types/apps/src/contracts/protocols/7.d.ts +1784 -0
- package/types/apps/src/contracts/protocols/8.d.ts +1130 -0
- package/types/apps/src/contracts/protocols/9.d.ts +1106 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +89 -0
- package/types/apps/src/contracts/provider-error.d.ts +9 -0
- package/types/apps/src/contracts/provider.d.ts +115 -10
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/skills.d.ts +39 -9
- package/types/apps/src/contracts/sql.d.ts +58 -0
- package/types/apps/src/contracts/ui.d.ts +19 -1
- package/types/apps/src/contracts/workflows.d.ts +40 -3
- package/types/apps/src/facet.d.ts +4 -5
- package/types/apps/src/graphql.d.ts +1 -3
- package/types/apps/src/implementation/account-router.d.ts +12 -0
- package/types/apps/src/implementation/app.d.ts +5 -4
- package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
- package/types/apps/src/implementation/catalog-cache.d.ts +32 -5
- package/types/apps/src/implementation/elicitation.d.ts +9 -9
- package/types/apps/src/implementation/failure-detail.d.ts +47 -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 +4 -1
- 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-stdio.d.ts +1 -1
- 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 +27 -6
- package/types/apps/src/implementation/openapi-document.d.ts +46 -19
- package/types/apps/src/implementation/openapi-names.d.ts +9 -4
- package/types/apps/src/implementation/openapi-request.d.ts +10 -2
- package/types/apps/src/implementation/openapi-source.d.ts +8 -6
- package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
- package/types/apps/src/implementation/operations.d.ts +36 -3
- package/types/apps/src/implementation/optimistic.d.ts +1 -1
- 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 +19 -5
- package/types/apps/src/implementation/query-commit.d.ts +1 -1
- package/types/apps/src/implementation/router-catalog.d.ts +223 -0
- package/types/apps/src/implementation/router.d.ts +68 -0
- package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
- package/types/apps/src/implementation/schema.d.ts +86 -11
- package/types/apps/src/implementation/skills.d.ts +18 -24
- package/types/apps/src/implementation/sql.d.ts +66 -0
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-auth.d.ts +1 -1
- package/types/apps/src/implementation/ui-client.d.ts +2 -2
- 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 +11 -5
- 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 +1 -1
- package/types/apps/src/implementation/workflow-context.d.ts +11 -3
- package/types/apps/src/index.d.ts +30 -13
- package/types/apps/src/mcp-stdio.d.ts +2 -5
- package/types/apps/src/mcp.d.ts +25 -5
- package/types/apps/src/openapi.d.ts +6 -6
- package/types/apps/src/react.d.ts +1 -1
- package/types/apps/src/skills.d.ts +10 -8
- package/types/telemetry/src/app-records.d.ts +42 -0
- package/types/telemetry/src/browser-operations.d.ts +6 -3
- package/types/telemetry/src/browser.d.ts +2 -2
- package/types/telemetry/src/config.d.ts +2 -2
- package/types/telemetry/src/layer.d.ts +2 -2
- package/types/telemetry/src/recorded-failure.d.ts +20 -0
- package/types/telemetry/src/relay.d.ts +2 -2
- package/types/telemetry/src/transport.d.ts +8 -1
- package/types/utils/src/api-error.d.ts +53 -0
- package/types/utils/src/recorded-message.d.ts +15 -0
- package/js/chunk-BMOIAIVR.js +0 -138
- package/js/chunk-DHUDODG5.js +0 -213
- package/js/chunk-FZJOYIZO.js +0 -19
- package/js/chunk-LGIYBDWA.js +0 -85
- package/js/chunk-M6ZRRIBI.js +0 -877
- package/js/chunk-PLCMJREA.js +0 -590
- package/js/chunk-PYUYJRSK.js +0 -93
- package/js/chunk-SWPD52J7.js +0 -35
- package/js/chunk-W7D7WVSY.js +0 -18
- package/js/chunk-Z5NMEGJN.js +0 -29
- package/js/chunk-ZJWDMTE3.js +0 -63
- 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/storage.d.ts +0 -13
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
JsonObject,
|
|
2
3
|
ValidationError
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YQ35E7KS.js";
|
|
4
5
|
import {
|
|
5
6
|
Cause_exports,
|
|
6
7
|
Effect_exports,
|
|
@@ -9,7 +10,7 @@ import {
|
|
|
9
10
|
SchemaIssue_exports,
|
|
10
11
|
SchemaParser_exports,
|
|
11
12
|
Schema_exports
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-MXDKXAY4.js";
|
|
13
14
|
|
|
14
15
|
// ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.js
|
|
15
16
|
function deepCompareStrict(a, b) {
|
|
@@ -106,9 +107,9 @@ var ignoredKeyword = {
|
|
|
106
107
|
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");
|
|
107
108
|
function dereference(schema, lookup = /* @__PURE__ */ Object.create(null), baseURI = initialBaseURI, basePointer = "") {
|
|
108
109
|
if (schema && typeof schema === "object" && !Array.isArray(schema)) {
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
111
|
-
const url = new URL(
|
|
110
|
+
const id = schema.$id || schema.id;
|
|
111
|
+
if (id) {
|
|
112
|
+
const url = new URL(id, baseURI.href);
|
|
112
113
|
if (url.hash.length > 1) {
|
|
113
114
|
lookup[url.href] = schema;
|
|
114
115
|
} else {
|
|
@@ -344,7 +345,7 @@ function validate(instance, schema, draft = "2019-09", lookup = dereference(sche
|
|
|
344
345
|
if ($recursiveAnchor === true && recursiveAnchor === null) {
|
|
345
346
|
recursiveAnchor = schema;
|
|
346
347
|
}
|
|
347
|
-
if ($recursiveRef
|
|
348
|
+
if ($recursiveRef !== void 0) {
|
|
348
349
|
const refSchema = recursiveAnchor === null ? lookup[__absolute_recursive_ref__] : recursiveAnchor;
|
|
349
350
|
const keywordLocation = `${schemaLocation}/$recursiveRef`;
|
|
350
351
|
const result = validate(instance, recursiveAnchor === null ? schema : recursiveAnchor, draft, lookup, shortCircuit, refSchema, instanceLocation, keywordLocation, evaluated);
|
|
@@ -1068,40 +1069,31 @@ function schemaPattern(pattern) {
|
|
|
1068
1069
|
}
|
|
1069
1070
|
|
|
1070
1071
|
// src/implementation/schema.ts
|
|
1071
|
-
var StorageField = /* @__PURE__ */ Symbol("apps.StorageField");
|
|
1072
1072
|
var Decoder = /* @__PURE__ */ Symbol("apps.Schema");
|
|
1073
1073
|
var decoderOf = (schema) => schema[Decoder];
|
|
1074
1074
|
var isSchema = (value) => typeof value === "object" && value !== null && Decoder in value;
|
|
1075
|
+
var schemaArgument = (value, role) => {
|
|
1076
|
+
if (isSchema(value)) return value;
|
|
1077
|
+
const received = value;
|
|
1078
|
+
throw new TypeError(
|
|
1079
|
+
`${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."}`
|
|
1080
|
+
);
|
|
1081
|
+
};
|
|
1075
1082
|
var parse = (decoder, input) => Effect_exports.suspend(() => Schema_exports.decodeUnknownEffect(decoder)(input)).pipe(
|
|
1076
1083
|
Effect_exports.mapError(() => new ValidationError())
|
|
1077
1084
|
);
|
|
1078
|
-
function wrap(decoder, optionalValue
|
|
1085
|
+
function wrap(decoder, optionalValue) {
|
|
1079
1086
|
return {
|
|
1080
1087
|
[Decoder]: decoder,
|
|
1081
|
-
...field === void 0 ? {} : { [StorageField]: field },
|
|
1082
1088
|
optionalValue,
|
|
1083
1089
|
parse: (input) => Effect_exports.runSync(parse(decoder, input)),
|
|
1084
|
-
optional: () => wrap(
|
|
1085
|
-
Schema_exports.optional(decoder),
|
|
1086
|
-
true,
|
|
1087
|
-
field === void 0 ? void 0 : { ...field, optional: true }
|
|
1088
|
-
),
|
|
1090
|
+
optional: () => wrap(Schema_exports.optional(decoder), true),
|
|
1089
1091
|
default: (value) => {
|
|
1090
1092
|
const parsed = Effect_exports.runSync(parse(decoder, value));
|
|
1091
1093
|
return {
|
|
1092
1094
|
...wrap(
|
|
1093
1095
|
decoder.annotate({ default: parsed }).pipe(Schema_exports.withDecodingDefault(Effect_exports.succeed(parsed))),
|
|
1094
|
-
false
|
|
1095
|
-
field === void 0 || parsed === void 0 ? void 0 : {
|
|
1096
|
-
...field,
|
|
1097
|
-
default: Schema_exports.decodeUnknownSync(
|
|
1098
|
-
Schema_exports.Union([
|
|
1099
|
-
Schema_exports.String,
|
|
1100
|
-
Schema_exports.Finite,
|
|
1101
|
-
Schema_exports.Boolean
|
|
1102
|
-
])
|
|
1103
|
-
)(parsed)
|
|
1104
|
-
}
|
|
1096
|
+
false
|
|
1105
1097
|
),
|
|
1106
1098
|
hasDefault: true,
|
|
1107
1099
|
inputOptional: optionalValue
|
|
@@ -1112,14 +1104,19 @@ function wrap(decoder, optionalValue, field) {
|
|
|
1112
1104
|
function string(options = {}) {
|
|
1113
1105
|
return wrap(
|
|
1114
1106
|
options.minLength === void 0 ? Schema_exports.String : Schema_exports.String.check(Schema_exports.isMinLength(options.minLength)),
|
|
1115
|
-
false
|
|
1116
|
-
{ kind: "string" }
|
|
1107
|
+
false
|
|
1117
1108
|
);
|
|
1118
1109
|
}
|
|
1119
|
-
var number = () => wrap(Schema_exports.Finite, false
|
|
1120
|
-
var boolean = () => wrap(Schema_exports.Boolean, false
|
|
1110
|
+
var number = () => wrap(Schema_exports.Finite, false);
|
|
1111
|
+
var boolean = () => wrap(Schema_exports.Boolean, false);
|
|
1121
1112
|
var json = () => wrap(Schema_exports.Json, false);
|
|
1122
|
-
var record = (value) => wrap(
|
|
1113
|
+
var record = (value) => wrap(
|
|
1114
|
+
Schema_exports.Record(
|
|
1115
|
+
Schema_exports.String,
|
|
1116
|
+
decoderOf(schemaArgument(value, "The record() value"))
|
|
1117
|
+
),
|
|
1118
|
+
false
|
|
1119
|
+
);
|
|
1123
1120
|
function literal(value) {
|
|
1124
1121
|
if (typeof value === "number") Effect_exports.runSync(parse(Schema_exports.Finite, value));
|
|
1125
1122
|
return wrap(
|
|
@@ -1127,10 +1124,13 @@ function literal(value) {
|
|
|
1127
1124
|
false
|
|
1128
1125
|
);
|
|
1129
1126
|
}
|
|
1130
|
-
var array = (item) => wrap(Schema_exports.Array(decoderOf(item)), false);
|
|
1127
|
+
var array = (item) => wrap(Schema_exports.Array(decoderOf(schemaArgument(item, "The array() item"))), false);
|
|
1131
1128
|
function object(fields) {
|
|
1132
1129
|
const entries = Object.entries(fields).map(
|
|
1133
|
-
([key, field]) => [
|
|
1130
|
+
([key, field]) => [
|
|
1131
|
+
key,
|
|
1132
|
+
decoderOf(schemaArgument(field, `The object() field ${JSON.stringify(key)}`))
|
|
1133
|
+
]
|
|
1134
1134
|
);
|
|
1135
1135
|
const decoder = entries.length === 0 ? withJsonSchemaDocument(
|
|
1136
1136
|
// Native Struct({}) accepts every non-null value and retains undeclared fields.
|
|
@@ -1144,6 +1144,25 @@ function object(fields) {
|
|
|
1144
1144
|
) : Schema_exports.Struct(Object.fromEntries(entries));
|
|
1145
1145
|
return { ...wrap(decoder, false), fields: Object.freeze({ ...fields }) };
|
|
1146
1146
|
}
|
|
1147
|
+
var Exposure = /* @__PURE__ */ Symbol("apps.FieldExposure");
|
|
1148
|
+
var exposureOf = (schema) => Exposure in schema && (schema[Exposure] === "plain" || schema[Exposure] === "raw") ? schema[Exposure] : void 0;
|
|
1149
|
+
var expose = (schema, exposure) => (
|
|
1150
|
+
// SAFETY: the copy keeps every member of S, and `optional` and `default` keep the marking.
|
|
1151
|
+
{
|
|
1152
|
+
...schema,
|
|
1153
|
+
[Exposure]: exposure,
|
|
1154
|
+
optional: () => expose(schema.optional(), exposure),
|
|
1155
|
+
default: (value) => expose(schema.default(value), exposure)
|
|
1156
|
+
}
|
|
1157
|
+
);
|
|
1158
|
+
var plain = (schema) => expose(schema, "plain");
|
|
1159
|
+
var raw = (schema) => expose(schema, "raw");
|
|
1160
|
+
var fieldExposure = (fields) => Object.fromEntries(
|
|
1161
|
+
Object.entries(fields).flatMap(([name, field]) => {
|
|
1162
|
+
const exposure = exposureOf(field);
|
|
1163
|
+
return exposure === void 0 ? [] : [[name, exposure]];
|
|
1164
|
+
})
|
|
1165
|
+
);
|
|
1147
1166
|
var ImportedJsonSchema = /* @__PURE__ */ Symbol("apps.JsonSchemaDocument");
|
|
1148
1167
|
var importedJsonSchema = (decoder) => ImportedJsonSchema in decoder ? decoder[ImportedJsonSchema] : void 0;
|
|
1149
1168
|
var withJsonSchemaDocument = (decoder, document) => Object.assign(decoder, { [ImportedJsonSchema]: document });
|
|
@@ -1273,18 +1292,334 @@ var containerKeywords = /* @__PURE__ */ new Set([
|
|
|
1273
1292
|
"else",
|
|
1274
1293
|
"dependentSchemas"
|
|
1275
1294
|
]);
|
|
1276
|
-
var
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1295
|
+
var echoableKey = (key) => /^[A-Za-z_$][\w$-]{0,63}$/.test(key);
|
|
1296
|
+
var schemaKey = (name) => echoableKey(name) ? name : JSON.stringify(name.slice(0, 64));
|
|
1297
|
+
var maxShapeKeys = 24;
|
|
1298
|
+
var objectShape = (keys, open, limit = maxShapeKeys) => {
|
|
1299
|
+
const listed = keys.slice(0, limit).map(({ name, optional }) => `${schemaKey(name)}${optional ? "?" : ""}`);
|
|
1300
|
+
const parts = [
|
|
1301
|
+
...listed,
|
|
1302
|
+
...keys.length > limit ? [`${keys.length - limit} more`] : [],
|
|
1303
|
+
...open ? ["..."] : []
|
|
1304
|
+
];
|
|
1305
|
+
return parts.length === 0 ? "object {} with no keys" : `object {${parts.join(", ")}}`;
|
|
1306
|
+
};
|
|
1307
|
+
var maxListedValues = 10;
|
|
1308
|
+
var maxValuesText = 200;
|
|
1309
|
+
var valueText = (value) => typeof value === "bigint" ? `${value}n` : JSON.stringify(value);
|
|
1310
|
+
var allowedValues = (values) => {
|
|
1311
|
+
const texts = [...new Set(values.map(valueText))];
|
|
1312
|
+
const listed = [];
|
|
1313
|
+
for (const text of texts) {
|
|
1314
|
+
if (listed.length === maxListedValues || [...listed, text].join(", ").length > maxValuesText)
|
|
1315
|
+
break;
|
|
1316
|
+
listed.push(text);
|
|
1317
|
+
}
|
|
1318
|
+
const [only] = listed;
|
|
1319
|
+
if (texts.length === 0) return "no value, since the schema allows none";
|
|
1320
|
+
if (only === void 0)
|
|
1321
|
+
return texts.length === 1 ? "a fixed value too long to list" : `one of ${texts.length} values too long to list`;
|
|
1322
|
+
if (texts.length === 1) return only;
|
|
1323
|
+
const rest = texts.length - listed.length;
|
|
1324
|
+
return `one of ${listed.join(", ")}${rest > 0 ? ` and ${rest} more` : ""}`;
|
|
1325
|
+
};
|
|
1326
|
+
var maxAlternativeKeys = 8;
|
|
1327
|
+
var maxAlternativesText = 360;
|
|
1328
|
+
var unionShape = (alternatives, selector) => {
|
|
1329
|
+
const listed = [];
|
|
1330
|
+
for (const alternative of alternatives) {
|
|
1331
|
+
if (listed.length > 0 && [...listed, alternative].join(" or ").length > maxAlternativesText)
|
|
1332
|
+
break;
|
|
1333
|
+
listed.push(alternative);
|
|
1334
|
+
}
|
|
1335
|
+
const rest = alternatives.length - listed.length;
|
|
1336
|
+
return `${[...listed, ...rest > 0 ? [`${rest} more`] : []].join(" or ")}${selector === void 0 ? "" : `, told apart by ${schemaKey(selector)}`}`;
|
|
1337
|
+
};
|
|
1338
|
+
var isJsonRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1339
|
+
var pointerSegments = (pointer) => pointer === "#" || pointer === "" ? [] : pointer.replace(/^#?\//, "").split("/").map((segment) => decodeURIComponent(segment).replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
1340
|
+
var resolved = (lookup, uri2) => typeof uri2 === "string" && Object.hasOwn(lookup, uri2) ? lookup[uri2] : void 0;
|
|
1341
|
+
var referenced = (lookup, node) => isJsonRecord(node) ? resolved(lookup, Reflect.get(node, "__absolute_ref__") ?? node.$ref) : void 0;
|
|
1342
|
+
var memberKeywords = /* @__PURE__ */ new Set([...schemaMaps, ...schemaArrays, "dependencies"]);
|
|
1343
|
+
var combinators = /* @__PURE__ */ new Set(["allOf", "anyOf", "oneOf"]);
|
|
1344
|
+
var schemaAt = (document, lookup, segments) => {
|
|
1345
|
+
const anchoredAt = (node2, anchor2) => anchor2 === null && isJsonRecord(node2) && node2.$recursiveAnchor === true ? node2 : anchor2;
|
|
1346
|
+
const pending = [...segments];
|
|
1347
|
+
let node = document;
|
|
1348
|
+
let anchor = anchoredAt(document, null);
|
|
1349
|
+
for (let keyword = pending.shift(); keyword !== void 0; keyword = pending.shift()) {
|
|
1350
|
+
if (!isJsonRecord(node)) return void 0;
|
|
1351
|
+
if (keyword === "$recursiveRef") {
|
|
1352
|
+
const target = anchor === null ? resolved(lookup, Reflect.get(node, "__absolute_recursive_ref__")) : anchor;
|
|
1353
|
+
if (anchor !== null) node = anchor;
|
|
1354
|
+
anchor = target;
|
|
1355
|
+
continue;
|
|
1356
|
+
}
|
|
1357
|
+
if (keyword === "$ref") node = referenced(lookup, node);
|
|
1358
|
+
else {
|
|
1359
|
+
const value = Object.hasOwn(node, keyword) ? node[keyword] : void 0;
|
|
1360
|
+
if (memberKeywords.has(keyword) || keyword === "items" && Array.isArray(value)) {
|
|
1361
|
+
const member = pending.shift();
|
|
1362
|
+
if (member === void 0) return value;
|
|
1363
|
+
if (combinators.has(keyword) && node.$recursiveAnchor !== true) anchor = null;
|
|
1364
|
+
node = Array.isArray(value) ? /^\d+$/.test(member) ? value[Number(member)] : void 0 : isJsonRecord(value) && Object.hasOwn(value, member) ? value[member] : void 0;
|
|
1365
|
+
} else node = value;
|
|
1366
|
+
}
|
|
1367
|
+
anchor = anchoredAt(node, anchor);
|
|
1368
|
+
}
|
|
1369
|
+
return node;
|
|
1370
|
+
};
|
|
1371
|
+
var jsonObjectShape = (node) => {
|
|
1372
|
+
if (!isJsonRecord(node)) return "object";
|
|
1373
|
+
const properties = isJsonRecord(node.properties) ? Object.keys(node.properties) : [];
|
|
1374
|
+
const required = new Set(Array.isArray(node.required) ? node.required : []);
|
|
1375
|
+
const open = node.additionalProperties !== false || isJsonRecord(node.patternProperties) && Object.keys(node.patternProperties).length > 0;
|
|
1376
|
+
return properties.length === 0 && open ? "object" : objectShape(
|
|
1377
|
+
properties.map((name) => ({ name, optional: !required.has(name) })),
|
|
1378
|
+
open
|
|
1379
|
+
);
|
|
1380
|
+
};
|
|
1381
|
+
var locationKey = (segments) => JSON.stringify(segments);
|
|
1382
|
+
var emptyOutline = {
|
|
1383
|
+
types: void 0,
|
|
1384
|
+
properties: /* @__PURE__ */ new Map(),
|
|
1385
|
+
required: /* @__PURE__ */ new Set(),
|
|
1386
|
+
closed: false,
|
|
1387
|
+
values: void 0
|
|
1388
|
+
};
|
|
1389
|
+
var commonValues = (a, b) => a === void 0 ? b : b === void 0 ? a : a.filter((value) => b.some((other) => deepCompareStrict(value, other)));
|
|
1390
|
+
var strings = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
1391
|
+
var commonTypes = (a, b) => new Set(
|
|
1392
|
+
[...a].flatMap(
|
|
1393
|
+
(type) => b.has(type) ? [type] : type === "number" && b.has("integer") || type === "integer" && b.has("number") ? ["integer"] : []
|
|
1394
|
+
)
|
|
1395
|
+
);
|
|
1396
|
+
var mergeOutlines = (a, b) => ({
|
|
1397
|
+
types: a.types === void 0 ? b.types : b.types === void 0 ? a.types : commonTypes(a.types, b.types),
|
|
1398
|
+
properties: new Map([...a.properties, ...b.properties]),
|
|
1399
|
+
required: /* @__PURE__ */ new Set([...a.required, ...b.required]),
|
|
1400
|
+
closed: a.closed || b.closed,
|
|
1401
|
+
values: commonValues(a.values, b.values)
|
|
1402
|
+
});
|
|
1403
|
+
var outlineOf = (node, inspection, seen = /* @__PURE__ */ new Set()) => {
|
|
1404
|
+
if (!isJsonRecord(node) || seen.has(node)) return emptyOutline;
|
|
1405
|
+
const within = /* @__PURE__ */ new Set([...seen, node]);
|
|
1406
|
+
const own = {
|
|
1407
|
+
types: typeof node.type === "string" ? /* @__PURE__ */ new Set([node.type]) : Array.isArray(node.type) ? new Set(strings(node.type)) : void 0,
|
|
1408
|
+
properties: new Map(isJsonRecord(node.properties) ? Object.entries(node.properties) : []),
|
|
1409
|
+
required: new Set(strings(node.required)),
|
|
1410
|
+
closed: (node.additionalProperties === false || node.unevaluatedProperties === false) && !(isJsonRecord(node.patternProperties) && Object.keys(node.patternProperties).length > 0),
|
|
1411
|
+
values: commonValues(
|
|
1412
|
+
Object.hasOwn(node, "const") ? [node.const] : void 0,
|
|
1413
|
+
Array.isArray(node.enum) ? node.enum : void 0
|
|
1414
|
+
)
|
|
1415
|
+
};
|
|
1416
|
+
return [inspection.referenced(node), ...Array.isArray(node.allOf) ? node.allOf : []].reduce(
|
|
1417
|
+
(outline, member) => mergeOutlines(outline, outlineOf(member, inspection, within)),
|
|
1418
|
+
own
|
|
1419
|
+
);
|
|
1420
|
+
};
|
|
1421
|
+
var describeOutline = (outline) => {
|
|
1422
|
+
if (outline.values !== void 0) return allowedValues(outline.values);
|
|
1423
|
+
const names = [
|
|
1424
|
+
...outline.properties.keys(),
|
|
1425
|
+
...[...outline.required].filter((name) => !outline.properties.has(name))
|
|
1426
|
+
];
|
|
1427
|
+
const shape = names.length === 0 && !outline.closed ? "object" : objectShape(
|
|
1428
|
+
names.map((name) => ({ name, optional: !outline.required.has(name) })),
|
|
1429
|
+
!outline.closed,
|
|
1430
|
+
maxAlternativeKeys
|
|
1431
|
+
);
|
|
1432
|
+
if (outline.types === void 0)
|
|
1433
|
+
return names.length > 0 || outline.closed ? shape : "a value with other constraints";
|
|
1434
|
+
return [...outline.types].map((type) => type === "object" ? shape : type).join(" or ");
|
|
1435
|
+
};
|
|
1436
|
+
var overlap = (outline, value, inspection, depth = 0) => !isJsonRecord(value) || depth > 16 ? 0 : Object.entries(value).reduce((total, [key, item]) => {
|
|
1437
|
+
const property = outline.properties.get(key);
|
|
1438
|
+
return property === void 0 ? total : total + 1 + overlap(outlineOf(property, inspection), item, inspection, depth + 1);
|
|
1439
|
+
}, 0);
|
|
1440
|
+
var jsonType = (value) => value === null ? "null" : Array.isArray(value) ? "array" : typeof value === "object" ? "object" : typeof value;
|
|
1441
|
+
var accepted = (outline, value) => {
|
|
1442
|
+
const type = jsonType(value);
|
|
1443
|
+
if (outline.values !== void 0)
|
|
1444
|
+
return outline.values.some((allowed) => jsonType(allowed) === type);
|
|
1445
|
+
if (outline.types === void 0) return true;
|
|
1446
|
+
return outline.types.has(type) || type === "number" && outline.types.has("integer") && Number.isInteger(value);
|
|
1447
|
+
};
|
|
1448
|
+
var valueAt = (input, location2) => location2.reduce(
|
|
1449
|
+
(value, segment) => Array.isArray(value) ? value[Number(segment)] : isJsonRecord(value) && Object.hasOwn(value, segment) ? value[segment] : void 0,
|
|
1450
|
+
input
|
|
1451
|
+
);
|
|
1452
|
+
var discriminatorOf = (holder) => isJsonRecord(holder) && isJsonRecord(holder.discriminator) ? holder.discriminator : void 0;
|
|
1453
|
+
var definitionName = (reference) => {
|
|
1454
|
+
if (typeof reference !== "string" || !reference.startsWith("#/")) return void 0;
|
|
1455
|
+
const segments = pointerSegments(reference);
|
|
1456
|
+
const container = segments.at(-2);
|
|
1457
|
+
return container === "$defs" || container === "definitions" || container === "schemas" && segments.at(-3) === "components" ? segments.at(-1) : void 0;
|
|
1458
|
+
};
|
|
1459
|
+
var discriminatedName = (holder, value) => {
|
|
1460
|
+
const discriminator = discriminatorOf(holder);
|
|
1461
|
+
if (discriminator === void 0 || typeof value !== "string") return void 0;
|
|
1462
|
+
const { mapping } = discriminator;
|
|
1463
|
+
const target = isJsonRecord(mapping) && Object.hasOwn(mapping, value) ? mapping[value] : value;
|
|
1464
|
+
if (typeof target !== "string") return void 0;
|
|
1465
|
+
return /^[\w.-]+$/.test(target) ? target : definitionName(target);
|
|
1466
|
+
};
|
|
1467
|
+
var selectorOf = (holder, alternatives, inspection) => {
|
|
1468
|
+
const declared = discriminatorOf(holder)?.propertyName;
|
|
1469
|
+
if (typeof declared === "string") return declared;
|
|
1470
|
+
const [first] = alternatives;
|
|
1471
|
+
if (first === void 0 || alternatives.length < 2) return void 0;
|
|
1472
|
+
return [...first.properties.keys()].find(
|
|
1473
|
+
(key) => alternatives.every(
|
|
1474
|
+
(alternative) => alternative.properties.has(key) && outlineOf(alternative.properties.get(key), inspection).values !== void 0
|
|
1475
|
+
)
|
|
1476
|
+
);
|
|
1477
|
+
};
|
|
1478
|
+
var alternativeErrors = (errors, head, schemas) => {
|
|
1479
|
+
const prefix = `${errors[head]?.keywordLocation}/`;
|
|
1480
|
+
const alternatives = /* @__PURE__ */ new Map();
|
|
1481
|
+
const settle = (current2, next) => {
|
|
1482
|
+
const collected = alternatives.get(current2);
|
|
1483
|
+
const rejected = Array.isArray(schemas) ? schemas.slice(current2 + 1, next).filter((schema) => schema === false).length : 0;
|
|
1484
|
+
if (collected !== void 0) collected.splice(collected.length - rejected, rejected);
|
|
1485
|
+
};
|
|
1486
|
+
let index = head + 1;
|
|
1487
|
+
let current = -1;
|
|
1488
|
+
for (; index < errors.length; index++) {
|
|
1489
|
+
const error = errors[index];
|
|
1490
|
+
if (error === void 0) break;
|
|
1491
|
+
if (error.keywordLocation.startsWith(prefix)) {
|
|
1492
|
+
const alternative = Number(error.keywordLocation.slice(prefix.length).split("/")[0]);
|
|
1493
|
+
if (alternative !== current) settle(current, alternative);
|
|
1494
|
+
current = alternative;
|
|
1495
|
+
} else if (error.keyword !== "false") break;
|
|
1496
|
+
if (current >= 0) alternatives.set(current, [...alternatives.get(current) ?? [], error]);
|
|
1497
|
+
}
|
|
1498
|
+
settle(current, Array.isArray(schemas) ? schemas.length : current);
|
|
1499
|
+
return { alternatives, end: index };
|
|
1500
|
+
};
|
|
1501
|
+
var pathOf = (location2) => location2.map((segment) => /^\d+$/.test(segment) ? Number(segment) : segment);
|
|
1502
|
+
var unionProblems = (union, schemas, errorsByAlternative, inspection) => {
|
|
1503
|
+
const location2 = pointerSegments(union.instanceLocation);
|
|
1504
|
+
const path = pathOf(location2);
|
|
1505
|
+
if (!Array.isArray(schemas))
|
|
1506
|
+
return [
|
|
1507
|
+
{ path, issue: `Failed the "${union.keyword}" constraint` },
|
|
1508
|
+
...[...errorsByAlternative.values()].flatMap((errors) => problemsOf(errors, inspection))
|
|
1509
|
+
];
|
|
1510
|
+
const alternatives = schemas.flatMap(
|
|
1511
|
+
(schema, index) => schema === false ? [] : [
|
|
1512
|
+
{
|
|
1513
|
+
schema,
|
|
1514
|
+
matched: !errorsByAlternative.has(index),
|
|
1515
|
+
problems: () => problemsOf(errorsByAlternative.get(index) ?? [], inspection)
|
|
1516
|
+
}
|
|
1517
|
+
]
|
|
1518
|
+
);
|
|
1519
|
+
const [only] = alternatives;
|
|
1520
|
+
if (only === void 0) return [{ path, issue: "No value is allowed here" }];
|
|
1521
|
+
if (alternatives.length === 1) return only.problems();
|
|
1522
|
+
const holder = inspection.schemaAt(pointerSegments(union.keywordLocation).slice(0, -1));
|
|
1523
|
+
const shared = outlineOf(holder, inspection);
|
|
1524
|
+
const own = alternatives.map(({ schema }) => outlineOf(schema, inspection));
|
|
1525
|
+
const outlines = own.map((outline) => mergeOutlines(shared, outline));
|
|
1526
|
+
const fixed = outlines.flatMap(({ values }) => values === void 0 ? [] : [values]);
|
|
1527
|
+
if (fixed.length === outlines.length)
|
|
1528
|
+
return [{ path, issue: `Expected ${allowedValues(fixed.flat())}` }];
|
|
1529
|
+
const selector = selectorOf(holder, own, inspection);
|
|
1530
|
+
const expected = `Expected ${unionShape(outlines.map(describeOutline), selector)}`;
|
|
1531
|
+
const matched = alternatives.filter((alternative) => alternative.matched).length;
|
|
1532
|
+
if (union.keyword === "oneOf" && matched > 1)
|
|
1533
|
+
return [{ path, issue: `${expected}. Exactly one may match, but ${matched} do` }];
|
|
1534
|
+
const value = valueAt(inspection.input, location2);
|
|
1535
|
+
const selectorValue = selector !== void 0 && isJsonRecord(value) && Object.hasOwn(value, selector) ? { value: value[selector] } : void 0;
|
|
1536
|
+
const named = discriminatedName(holder, selectorValue?.value);
|
|
1537
|
+
const ranked = alternatives.map(({ schema, problems }, index) => {
|
|
1538
|
+
const outline = outlines[index] ?? emptyOutline;
|
|
1539
|
+
const property = own[index]?.properties.get(selector ?? "");
|
|
1540
|
+
return {
|
|
1541
|
+
index,
|
|
1542
|
+
problems: problems(),
|
|
1543
|
+
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)),
|
|
1544
|
+
typed: accepted(outline, value),
|
|
1545
|
+
overlap: overlap(outline, value, inspection)
|
|
1285
1546
|
};
|
|
1286
|
-
return [issue];
|
|
1287
1547
|
});
|
|
1548
|
+
const closest = ranked.reduce(
|
|
1549
|
+
(best, candidate) => ([
|
|
1550
|
+
Number(candidate.selected) - Number(best.selected),
|
|
1551
|
+
Number(candidate.typed) - Number(best.typed),
|
|
1552
|
+
candidate.overlap - best.overlap,
|
|
1553
|
+
best.problems.length - candidate.problems.length
|
|
1554
|
+
].find((difference) => difference !== 0) ?? 0) > 0 ? candidate : best
|
|
1555
|
+
);
|
|
1556
|
+
return closest.selected || closest.typed ? [
|
|
1557
|
+
{
|
|
1558
|
+
path,
|
|
1559
|
+
issue: `${expected}. Closest is alternative ${closest.index + 1}, whose problems follow`
|
|
1560
|
+
},
|
|
1561
|
+
...closest.problems
|
|
1562
|
+
] : [{ path, issue: expected }];
|
|
1563
|
+
};
|
|
1564
|
+
var problemsOf = (errors, inspection) => {
|
|
1565
|
+
const closed = /* @__PURE__ */ new Map();
|
|
1566
|
+
const problems = [];
|
|
1567
|
+
for (let index = 0; index < errors.length; index++) {
|
|
1568
|
+
const error = errors[index];
|
|
1569
|
+
if (error === void 0) break;
|
|
1570
|
+
const { keyword, instanceLocation, keywordLocation } = error;
|
|
1571
|
+
if (keyword === "anyOf" || keyword === "oneOf") {
|
|
1572
|
+
const schemas = inspection.schemaAt(pointerSegments(keywordLocation));
|
|
1573
|
+
const { alternatives, end } = alternativeErrors(errors, index, schemas);
|
|
1574
|
+
problems.push(...unionProblems(error, schemas, alternatives, inspection));
|
|
1575
|
+
index = end - 1;
|
|
1576
|
+
continue;
|
|
1577
|
+
}
|
|
1578
|
+
const location2 = pointerSegments(instanceLocation);
|
|
1579
|
+
const path = pathOf(location2);
|
|
1580
|
+
const problem = (issue, at = path) => problems.push({ path: at, issue });
|
|
1581
|
+
const node = () => inspection.schemaAt(pointerSegments(keywordLocation).slice(0, -1));
|
|
1582
|
+
if (keyword === "additionalProperties" || keyword === "unevaluatedProperties") {
|
|
1583
|
+
closed.set(locationKey(location2), node());
|
|
1584
|
+
continue;
|
|
1585
|
+
}
|
|
1586
|
+
if (containerKeywords.has(keyword)) continue;
|
|
1587
|
+
if (keyword === "false") {
|
|
1588
|
+
const key = location2.at(-1);
|
|
1589
|
+
const parent = locationKey(location2.slice(0, -1));
|
|
1590
|
+
if (key === void 0 || !closed.has(parent)) problem("No value is allowed here");
|
|
1591
|
+
else
|
|
1592
|
+
problem(
|
|
1593
|
+
`Unexpected key${echoableKey(key) ? ` "${key}"` : ""}. Expected ${jsonObjectShape(closed.get(parent))}`,
|
|
1594
|
+
path.slice(0, -1)
|
|
1595
|
+
);
|
|
1596
|
+
continue;
|
|
1597
|
+
}
|
|
1598
|
+
const required = keyword === "required" ? /required property "([^"]*)"/.exec(error.error) : null;
|
|
1599
|
+
if (required !== null) {
|
|
1600
|
+
problem("Missing key", [...path, required[1] ?? ""]);
|
|
1601
|
+
continue;
|
|
1602
|
+
}
|
|
1603
|
+
const expected = keyword === "type" ? /Expected "([^.]*)"\.?$/.exec(error.error) : null;
|
|
1604
|
+
if (expected !== null) {
|
|
1605
|
+
const types = (expected[1] ?? "").split('", "').map((type) => type === "object" ? jsonObjectShape(node()) : type);
|
|
1606
|
+
problem(`Expected ${types.join(" or ")}`);
|
|
1607
|
+
continue;
|
|
1608
|
+
}
|
|
1609
|
+
if (keyword === "const" || keyword === "enum") {
|
|
1610
|
+
const schema = node();
|
|
1611
|
+
const values = !isJsonRecord(schema) ? void 0 : keyword === "const" ? Object.hasOwn(schema, "const") ? [schema.const] : void 0 : Array.isArray(schema.enum) ? schema.enum : void 0;
|
|
1612
|
+
problem(
|
|
1613
|
+
values === void 0 ? "Expected one of the allowed values" : `Expected ${allowedValues(values)}`
|
|
1614
|
+
);
|
|
1615
|
+
continue;
|
|
1616
|
+
}
|
|
1617
|
+
problem(`Failed the "${keyword}" constraint`);
|
|
1618
|
+
}
|
|
1619
|
+
return problems;
|
|
1620
|
+
};
|
|
1621
|
+
var jsonSchemaProblems = (errors, inspection) => {
|
|
1622
|
+
const problems = problemsOf(errors, inspection);
|
|
1288
1623
|
return problems.length === 0 ? false : problems;
|
|
1289
1624
|
};
|
|
1290
1625
|
var compileJsonSchemaDecoder = (document) => Effect_exports.gen(function* () {
|
|
@@ -1311,8 +1646,22 @@ var compileJsonSchemaDecoder = (document) => Effect_exports.gen(function* () {
|
|
|
1311
1646
|
throw new ValidationError();
|
|
1312
1647
|
}
|
|
1313
1648
|
}
|
|
1649
|
+
const inspection = (input) => ({
|
|
1650
|
+
schemaAt: (segments) => schemaAt(normalized, lookup, segments),
|
|
1651
|
+
referenced: (node) => referenced(lookup, node),
|
|
1652
|
+
accepts: (node, value) => {
|
|
1653
|
+
if (typeof node !== "boolean" && !isJsonRecord(node)) return false;
|
|
1654
|
+
try {
|
|
1655
|
+
return validate(value, node, draft, lookup).valid;
|
|
1656
|
+
} catch {
|
|
1657
|
+
return false;
|
|
1658
|
+
}
|
|
1659
|
+
},
|
|
1660
|
+
input
|
|
1661
|
+
});
|
|
1314
1662
|
return {
|
|
1315
|
-
validate: (input) => validate(input, normalized, draft, lookup)
|
|
1663
|
+
validate: (input) => validate(input, normalized, draft, lookup),
|
|
1664
|
+
inspection
|
|
1316
1665
|
};
|
|
1317
1666
|
},
|
|
1318
1667
|
catch: () => new ValidationError()
|
|
@@ -1322,7 +1671,7 @@ var compileJsonSchemaDecoder = (document) => Effect_exports.gen(function* () {
|
|
|
1322
1671
|
(value) => {
|
|
1323
1672
|
try {
|
|
1324
1673
|
const result = validator.validate(value);
|
|
1325
|
-
return result.valid || jsonSchemaProblems(result.errors);
|
|
1674
|
+
return result.valid || jsonSchemaProblems(result.errors, validator.inspection(value));
|
|
1326
1675
|
} catch {
|
|
1327
1676
|
return false;
|
|
1328
1677
|
}
|
|
@@ -1332,7 +1681,7 @@ var compileJsonSchemaDecoder = (document) => Effect_exports.gen(function* () {
|
|
|
1332
1681
|
);
|
|
1333
1682
|
return Object.assign(decoder, { [ImportedJsonSchema]: document });
|
|
1334
1683
|
});
|
|
1335
|
-
var
|
|
1684
|
+
var lazyCompiledDecoder = (document) => {
|
|
1336
1685
|
const read = once(document);
|
|
1337
1686
|
let compiled;
|
|
1338
1687
|
const compile = Effect_exports.suspend(
|
|
@@ -1352,9 +1701,11 @@ var lazyDecoder = (document) => {
|
|
|
1352
1701
|
Effect_exports.flatMap((schema) => SchemaParser_exports.decodeUnknownEffect(schema)(input, options))
|
|
1353
1702
|
)
|
|
1354
1703
|
);
|
|
1355
|
-
return withLazyJsonSchemaDocument(decoder, read);
|
|
1704
|
+
return { decoder: withLazyJsonSchemaDocument(decoder, read), compile };
|
|
1356
1705
|
};
|
|
1706
|
+
var lazyDecoder = (document) => lazyCompiledDecoder(document).decoder;
|
|
1357
1707
|
var lazyJsonSchemaDecoder = (document) => Effect_exports.sync(() => lazyDecoder(document));
|
|
1708
|
+
var preparedJsonSchemaDecoder = (document) => lazyCompiledDecoder(() => document);
|
|
1358
1709
|
var isJsonValue = Schema_exports.is(Schema_exports.Json);
|
|
1359
1710
|
var jsonDocument = (input) => {
|
|
1360
1711
|
if (typeof input !== "object" || input === null || Array.isArray(input)) return void 0;
|
|
@@ -1384,13 +1735,21 @@ var jsonSchema = (input) => {
|
|
|
1384
1735
|
false
|
|
1385
1736
|
);
|
|
1386
1737
|
};
|
|
1387
|
-
var
|
|
1388
|
-
|
|
1389
|
-
|
|
1738
|
+
var jsonSchemaDocument = (decoder) => {
|
|
1739
|
+
const imported = importedJsonSchema(decoder);
|
|
1740
|
+
if (imported !== void 0) return Schema_exports.decodeUnknownEffect(JsonObject)(imported);
|
|
1741
|
+
const document = Schema_exports.toJsonSchemaDocument(decoder);
|
|
1742
|
+
return Schema_exports.decodeUnknownEffect(JsonObject)({
|
|
1743
|
+
...document.schema,
|
|
1744
|
+
$defs: document.definitions,
|
|
1745
|
+
$schema: "https://json-schema.org/draft/2020-12/schema"
|
|
1746
|
+
});
|
|
1747
|
+
};
|
|
1390
1748
|
|
|
1391
1749
|
export {
|
|
1392
1750
|
decoderOf,
|
|
1393
1751
|
isSchema,
|
|
1752
|
+
schemaArgument,
|
|
1394
1753
|
parse,
|
|
1395
1754
|
wrap,
|
|
1396
1755
|
string,
|
|
@@ -1401,15 +1760,22 @@ export {
|
|
|
1401
1760
|
literal,
|
|
1402
1761
|
array,
|
|
1403
1762
|
object,
|
|
1763
|
+
plain,
|
|
1764
|
+
raw,
|
|
1765
|
+
fieldExposure,
|
|
1404
1766
|
importedJsonSchema,
|
|
1405
1767
|
once,
|
|
1406
1768
|
withLazyJsonSchemaDocument,
|
|
1407
1769
|
nestJsonSchema,
|
|
1770
|
+
echoableKey,
|
|
1771
|
+
objectShape,
|
|
1772
|
+
allowedValues,
|
|
1773
|
+
maxAlternativeKeys,
|
|
1774
|
+
unionShape,
|
|
1408
1775
|
compileJsonSchemaDecoder,
|
|
1409
1776
|
lazyJsonSchemaDecoder,
|
|
1777
|
+
preparedJsonSchemaDecoder,
|
|
1410
1778
|
jsonSchemaDecoder,
|
|
1411
1779
|
jsonSchema,
|
|
1412
|
-
|
|
1413
|
-
id,
|
|
1414
|
-
userId
|
|
1780
|
+
jsonSchemaDocument
|
|
1415
1781
|
};
|