apps 0.0.1-beta.9 → 0.0.1-beta.91
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 +56 -38
- package/framework-reference.json +1 -1
- package/js/chunk-3LEVTFD4.js +712 -0
- package/js/chunk-5FHWNLCI.js +88 -0
- package/js/{chunk-FL2QR3XW.js → chunk-5MDA7MKL.js} +338 -73
- package/js/chunk-6XQLA5NC.js +5047 -0
- package/js/{chunk-M3B3DE4K.js → chunk-74YVXBKY.js} +463 -218
- package/js/chunk-7PHHWYV4.js +335 -0
- package/js/chunk-DADXWWRZ.js +449 -0
- package/js/{chunk-27F7W2LG.js → chunk-DDHBUKXX.js} +18 -2
- package/js/{chunk-UK573G7W.js → chunk-EOPQ727L.js} +87 -51
- package/js/{chunk-5T57N25Q.js → chunk-GQ33QSNB.js} +583 -69
- package/js/{chunk-JU7VHODU.js → chunk-H72MEDMN.js} +65 -10
- package/js/chunk-I5C7FD5Z.js +171 -0
- package/js/{chunk-CDL5PM2Q.js → chunk-IFJU5SYQ.js} +19082 -18402
- package/js/{chunk-VFZKSM3T.js → chunk-JPEUKEV4.js} +3 -3
- package/js/{chunk-KUMBKVJD.js → chunk-KLYSEHUD.js} +2 -2
- package/js/{chunk-RFVIONFX.js → chunk-KUCCHNVY.js} +123 -44
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/{chunk-57RKNWL2.js → chunk-PD6I2SDG.js} +4 -4
- package/js/{chunk-72JNVHPK.js → chunk-PYQLOLOC.js} +4 -3
- package/js/{chunk-ODEIDRGW.js → chunk-QWQM3CLH.js} +795 -176
- package/js/{chunk-IJX4CYZO.js → chunk-TUMGL2OC.js} +228 -264
- package/js/{chunk-IPI4MFSN.js → chunk-XBG7HHXC.js} +2 -2
- package/js/chunk-XPRZTLHD.js +1915 -0
- package/js/chunk-YNJ5CZMJ.js +93 -0
- package/js/chunk-YRGL4QEF.js +49 -0
- package/js/{chunk-Z5M2LQOZ.js → chunk-YWFUWTUJ.js} +113 -58
- package/js/client.js +142 -78
- package/js/contracts.js +142 -21
- package/js/effect.js +18 -19
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +49 -40
- package/js/host.js +85 -62
- package/js/index.js +165 -70
- package/js/mcp/effect.js +21 -21
- package/js/mcp.js +76 -56
- package/js/openapi.js +4189 -1411
- package/js/react.js +2 -3
- package/js/skills/effect.js +6 -3
- package/js/skills.js +208 -81
- 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 +8605 -225
- package/package.json +3 -8
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +18 -0
- package/types/app-cache/src/index.d.ts +34 -2
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/app.d.ts +60 -11
- package/types/apps/src/contracts/cache.d.ts +20 -0
- 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 +30 -1
- package/types/apps/src/contracts/graphql.d.ts +2 -1
- package/types/apps/src/contracts/host.d.ts +1446 -17
- 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 +81 -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.d.ts +41 -9
- package/types/apps/src/contracts/operations.d.ts +14 -7
- package/types/apps/src/contracts/placement.d.ts +102 -0
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +733 -81
- 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 +69 -26
- package/types/apps/src/contracts/protocols/3.d.ts +133 -33
- package/types/apps/src/contracts/protocols/4.d.ts +122 -45
- package/types/apps/src/contracts/protocols/5.d.ts +157 -47
- 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 +6669 -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 +90 -6
- 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/skills.d.ts +50 -13
- package/types/apps/src/contracts/sql.d.ts +63 -0
- package/types/apps/src/contracts/ui.d.ts +44 -14
- package/types/apps/src/contracts/webhooks.d.ts +24 -7
- package/types/apps/src/contracts/workflows.d.ts +19 -17
- package/types/apps/src/facet.d.ts +4 -5
- package/types/apps/src/host.d.ts +5 -0
- package/types/apps/src/implementation/account-router.d.ts +4 -3
- package/types/apps/src/implementation/app.d.ts +41 -14
- 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 +29 -2
- package/types/apps/src/implementation/catalog-cache.d.ts +35 -4
- 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 +28 -5
- package/types/apps/src/implementation/graphql-catalog.d.ts +3 -3
- 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 +6 -4
- package/types/apps/src/implementation/mcp-client.d.ts +17 -9
- package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
- package/types/apps/src/implementation/mcp.d.ts +20 -9
- package/types/apps/src/implementation/network.d.ts +16 -0
- package/types/apps/src/implementation/openapi-compile.d.ts +28 -7
- 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 +23 -1
- package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
- package/types/apps/src/implementation/operations.d.ts +57 -7
- 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 +3 -0
- package/types/apps/src/implementation/provider-error.d.ts +28 -1
- package/types/apps/src/implementation/provider.d.ts +19 -4
- package/types/apps/src/implementation/query-commit.d.ts +1 -1
- package/types/apps/src/implementation/router-catalog.d.ts +20 -18
- package/types/apps/src/implementation/router.d.ts +24 -5
- 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 +98 -11
- 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/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 +26 -9
- 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 +6 -2
- package/types/apps/src/implementation/workflows.d.ts +11 -4
- package/types/apps/src/index.d.ts +68 -19
- package/types/apps/src/mcp.d.ts +20 -1
- package/types/apps/src/openapi.d.ts +6 -1
- package/types/apps/src/react.d.ts +1 -1
- package/types/apps/src/skills.d.ts +10 -8
- 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 +2 -2
- 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/recorded-message.d.ts +18 -0
- package/types/utils/src/user-facing-error.d.ts +83 -0
- package/js/chunk-7EK2JDX4.js +0 -299
- package/js/chunk-IKS2C5MQ.js +0 -224
- package/js/chunk-MKWZPDR6.js +0 -63
- package/js/chunk-N7YDVXYJ.js +0 -186
- package/js/chunk-NKLWZJLE.js +0 -172
- package/js/chunk-PJJ24GU7.js +0 -877
- package/js/chunk-PZB6T6KU.js +0 -19
- package/js/chunk-R3EV5FTO.js +0 -97
- package/js/chunk-SJFZCGXG.js +0 -1243
- package/js/chunk-WLE7WX2U.js +0 -2645
- package/js/chunk-YXQHV65J.js +0 -242
- package/js/chunk-ZQINWV4W.js +0 -630
- 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 -18
- 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/storage.d.ts +0 -68
- package/types/apps/src/implementation/mcp-stdio.d.ts +0 -4
- package/types/apps/src/implementation/storage.d.ts +0 -15
- package/types/apps/src/mcp-stdio.d.ts +0 -5
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DeclarationInvalid,
|
|
2
3
|
JsonObject,
|
|
3
4
|
ValidationError
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-DDHBUKXX.js";
|
|
5
6
|
import {
|
|
6
7
|
Cause_exports,
|
|
7
8
|
Effect_exports,
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
SchemaIssue_exports,
|
|
11
12
|
SchemaParser_exports,
|
|
12
13
|
Schema_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-IFJU5SYQ.js";
|
|
14
15
|
|
|
15
16
|
// ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.js
|
|
16
17
|
function deepCompareStrict(a, b) {
|
|
@@ -62,6 +63,19 @@ function escapePointer(p) {
|
|
|
62
63
|
}
|
|
63
64
|
|
|
64
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
|
+
};
|
|
65
79
|
var schemaArrayKeyword = {
|
|
66
80
|
prefixItems: true,
|
|
67
81
|
items: true,
|
|
@@ -107,9 +121,9 @@ var ignoredKeyword = {
|
|
|
107
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");
|
|
108
122
|
function dereference(schema, lookup = /* @__PURE__ */ Object.create(null), baseURI = initialBaseURI, basePointer = "") {
|
|
109
123
|
if (schema && typeof schema === "object" && !Array.isArray(schema)) {
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
112
|
-
const url = new URL(
|
|
124
|
+
const id = schema.$id || schema.id;
|
|
125
|
+
if (id) {
|
|
126
|
+
const url = new URL(id, baseURI.href);
|
|
113
127
|
if (url.hash.length > 1) {
|
|
114
128
|
lookup[url.href] = schema;
|
|
115
129
|
} else {
|
|
@@ -175,8 +189,14 @@ function dereference(schema, lookup = /* @__PURE__ */ Object.create(null), baseU
|
|
|
175
189
|
for (let subKey in subSchema) {
|
|
176
190
|
dereference(subSchema[subKey], lookup, baseURI, `${keyBase}/${encodePointer(subKey)}`);
|
|
177
191
|
}
|
|
178
|
-
} else {
|
|
192
|
+
} else if (schemaKeyword[key]) {
|
|
179
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
|
+
}
|
|
180
200
|
}
|
|
181
201
|
}
|
|
182
202
|
return lookup;
|
|
@@ -345,7 +365,7 @@ function validate(instance, schema, draft = "2019-09", lookup = dereference(sche
|
|
|
345
365
|
if ($recursiveAnchor === true && recursiveAnchor === null) {
|
|
346
366
|
recursiveAnchor = schema;
|
|
347
367
|
}
|
|
348
|
-
if ($recursiveRef
|
|
368
|
+
if ($recursiveRef !== void 0) {
|
|
349
369
|
const refSchema = recursiveAnchor === null ? lookup[__absolute_recursive_ref__] : recursiveAnchor;
|
|
350
370
|
const keywordLocation = `${schemaLocation}/$recursiveRef`;
|
|
351
371
|
const result = validate(instance, recursiveAnchor === null ? schema : recursiveAnchor, draft, lookup, shortCircuit, refSchema, instanceLocation, keywordLocation, evaluated);
|
|
@@ -1069,40 +1089,57 @@ function schemaPattern(pattern) {
|
|
|
1069
1089
|
}
|
|
1070
1090
|
|
|
1071
1091
|
// src/implementation/schema.ts
|
|
1072
|
-
var StorageField = /* @__PURE__ */ Symbol("apps.StorageField");
|
|
1073
1092
|
var Decoder = /* @__PURE__ */ Symbol("apps.Schema");
|
|
1074
1093
|
var decoderOf = (schema) => schema[Decoder];
|
|
1075
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
|
+
};
|
|
1076
1102
|
var parse = (decoder, input) => Effect_exports.suspend(() => Schema_exports.decodeUnknownEffect(decoder)(input)).pipe(
|
|
1077
1103
|
Effect_exports.mapError(() => new ValidationError())
|
|
1078
1104
|
);
|
|
1079
|
-
|
|
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) {
|
|
1080
1132
|
return {
|
|
1081
1133
|
[Decoder]: decoder,
|
|
1082
|
-
...field === void 0 ? {} : { [StorageField]: field },
|
|
1083
1134
|
optionalValue,
|
|
1084
1135
|
parse: (input) => Effect_exports.runSync(parse(decoder, input)),
|
|
1085
|
-
optional: () => wrap(
|
|
1086
|
-
Schema_exports.optional(decoder),
|
|
1087
|
-
true,
|
|
1088
|
-
field === void 0 ? void 0 : { ...field, optional: true }
|
|
1089
|
-
),
|
|
1136
|
+
optional: () => wrap(Schema_exports.optional(decoder), true),
|
|
1090
1137
|
default: (value) => {
|
|
1091
1138
|
const parsed = Effect_exports.runSync(parse(decoder, value));
|
|
1092
1139
|
return {
|
|
1093
1140
|
...wrap(
|
|
1094
1141
|
decoder.annotate({ default: parsed }).pipe(Schema_exports.withDecodingDefault(Effect_exports.succeed(parsed))),
|
|
1095
|
-
false
|
|
1096
|
-
field === void 0 || parsed === void 0 ? void 0 : {
|
|
1097
|
-
...field,
|
|
1098
|
-
default: Schema_exports.decodeUnknownSync(
|
|
1099
|
-
Schema_exports.Union([
|
|
1100
|
-
Schema_exports.String,
|
|
1101
|
-
Schema_exports.Finite,
|
|
1102
|
-
Schema_exports.Boolean
|
|
1103
|
-
])
|
|
1104
|
-
)(parsed)
|
|
1105
|
-
}
|
|
1142
|
+
false
|
|
1106
1143
|
),
|
|
1107
1144
|
hasDefault: true,
|
|
1108
1145
|
inputOptional: optionalValue
|
|
@@ -1113,14 +1150,19 @@ function wrap(decoder, optionalValue, field) {
|
|
|
1113
1150
|
function string(options = {}) {
|
|
1114
1151
|
return wrap(
|
|
1115
1152
|
options.minLength === void 0 ? Schema_exports.String : Schema_exports.String.check(Schema_exports.isMinLength(options.minLength)),
|
|
1116
|
-
false
|
|
1117
|
-
{ kind: "string" }
|
|
1153
|
+
false
|
|
1118
1154
|
);
|
|
1119
1155
|
}
|
|
1120
|
-
var number = () => wrap(Schema_exports.Finite, false
|
|
1121
|
-
var boolean = () => wrap(Schema_exports.Boolean, false
|
|
1156
|
+
var number = () => wrap(Schema_exports.Finite, false);
|
|
1157
|
+
var boolean = () => wrap(Schema_exports.Boolean, false);
|
|
1122
1158
|
var json = () => wrap(Schema_exports.Json, false);
|
|
1123
|
-
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
|
+
);
|
|
1124
1166
|
function literal(value) {
|
|
1125
1167
|
if (typeof value === "number") Effect_exports.runSync(parse(Schema_exports.Finite, value));
|
|
1126
1168
|
return wrap(
|
|
@@ -1128,10 +1170,13 @@ function literal(value) {
|
|
|
1128
1170
|
false
|
|
1129
1171
|
);
|
|
1130
1172
|
}
|
|
1131
|
-
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);
|
|
1132
1174
|
function object(fields) {
|
|
1133
1175
|
const entries = Object.entries(fields).map(
|
|
1134
|
-
([key, field]) => [
|
|
1176
|
+
([key, field]) => [
|
|
1177
|
+
key,
|
|
1178
|
+
decoderOf(schemaArgument(field, `The object() field ${JSON.stringify(key)}`))
|
|
1179
|
+
]
|
|
1135
1180
|
);
|
|
1136
1181
|
const decoder = entries.length === 0 ? withJsonSchemaDocument(
|
|
1137
1182
|
// Native Struct({}) accepts every non-null value and retains undeclared fields.
|
|
@@ -1145,6 +1190,25 @@ function object(fields) {
|
|
|
1145
1190
|
) : Schema_exports.Struct(Object.fromEntries(entries));
|
|
1146
1191
|
return { ...wrap(decoder, false), fields: Object.freeze({ ...fields }) };
|
|
1147
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
|
+
);
|
|
1148
1212
|
var ImportedJsonSchema = /* @__PURE__ */ Symbol("apps.JsonSchemaDocument");
|
|
1149
1213
|
var importedJsonSchema = (decoder) => ImportedJsonSchema in decoder ? decoder[ImportedJsonSchema] : void 0;
|
|
1150
1214
|
var withJsonSchemaDocument = (decoder, document) => Object.assign(decoder, { [ImportedJsonSchema]: document });
|
|
@@ -1160,7 +1224,7 @@ var withLazyJsonSchemaDocument = (decoder, document) => Object.defineProperty(de
|
|
|
1160
1224
|
var nestJsonSchema = (input, pointer) => {
|
|
1161
1225
|
const document = structuredClone(input);
|
|
1162
1226
|
const lookup = dereference(document);
|
|
1163
|
-
const
|
|
1227
|
+
const evaluated = evaluatedSchemas(document, lookup);
|
|
1164
1228
|
const pointers = /* @__PURE__ */ new Map();
|
|
1165
1229
|
const locate = (value, path) => {
|
|
1166
1230
|
if (!pointers.has(value)) pointers.set(value, path);
|
|
@@ -1174,8 +1238,7 @@ var nestJsonSchema = (input, pointer) => {
|
|
|
1174
1238
|
};
|
|
1175
1239
|
locate(document, pointer);
|
|
1176
1240
|
const references = /* @__PURE__ */ new Map();
|
|
1177
|
-
for (const schema of
|
|
1178
|
-
if (typeof schema === "boolean") continue;
|
|
1241
|
+
for (const schema of evaluated) {
|
|
1179
1242
|
const refs = {};
|
|
1180
1243
|
for (const [key, absolute] of [
|
|
1181
1244
|
["$ref", schema.__absolute_ref__],
|
|
@@ -1222,6 +1285,27 @@ var schemaNodes = /* @__PURE__ */ new Set([
|
|
|
1222
1285
|
"unevaluatedItems",
|
|
1223
1286
|
"propertyNames"
|
|
1224
1287
|
]);
|
|
1288
|
+
var isSchemaObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1289
|
+
var evaluatedSchemas = (root, lookup) => {
|
|
1290
|
+
const found = /* @__PURE__ */ new Set();
|
|
1291
|
+
const pending = [root];
|
|
1292
|
+
for (let value = pending.pop(); value !== void 0; value = pending.pop()) {
|
|
1293
|
+
if (!isSchemaObject(value) || found.has(value)) continue;
|
|
1294
|
+
found.add(value);
|
|
1295
|
+
for (const target of [value.__absolute_ref__, value.__absolute_recursive_ref__]) {
|
|
1296
|
+
const schema = target === void 0 ? void 0 : lookup[target];
|
|
1297
|
+
if (schema !== void 0) pending.push(schema);
|
|
1298
|
+
}
|
|
1299
|
+
for (const [key, item] of Object.entries(value)) {
|
|
1300
|
+
if (Array.isArray(item)) {
|
|
1301
|
+
if (schemaArrays.has(key) || key === "items") pending.push(...item);
|
|
1302
|
+
} else if (schemaMaps.has(key) || key === "dependencies") {
|
|
1303
|
+
if (isJsonRecord(item)) pending.push(...Object.values(item));
|
|
1304
|
+
} else if (schemaNodes.has(key)) pending.push(item);
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
return found;
|
|
1308
|
+
};
|
|
1225
1309
|
function interpretedDocument(value) {
|
|
1226
1310
|
if (typeof value === "boolean") return value;
|
|
1227
1311
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
@@ -1274,18 +1358,425 @@ var containerKeywords = /* @__PURE__ */ new Set([
|
|
|
1274
1358
|
"else",
|
|
1275
1359
|
"dependentSchemas"
|
|
1276
1360
|
]);
|
|
1277
|
-
var
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1361
|
+
var echoableKey = (key) => /^[A-Za-z_$][\w$-]{0,63}$/.test(key);
|
|
1362
|
+
var schemaKey = (name) => echoableKey(name) ? name : JSON.stringify(name.slice(0, 64));
|
|
1363
|
+
var maxShapeKeys = 24;
|
|
1364
|
+
var objectShape = (keys, open, limit = maxShapeKeys) => {
|
|
1365
|
+
const listed = keys.slice(0, limit).map(({ name, optional }) => `${schemaKey(name)}${optional ? "?" : ""}`);
|
|
1366
|
+
const parts = [
|
|
1367
|
+
...listed,
|
|
1368
|
+
...keys.length > limit ? [`${keys.length - limit} more`] : [],
|
|
1369
|
+
...open ? ["..."] : []
|
|
1370
|
+
];
|
|
1371
|
+
return parts.length === 0 ? "object {} with no keys" : `object {${parts.join(", ")}}`;
|
|
1372
|
+
};
|
|
1373
|
+
var maxListedValues = 10;
|
|
1374
|
+
var maxValuesText = 200;
|
|
1375
|
+
var valueText = (value) => typeof value === "bigint" ? `${value}n` : JSON.stringify(value);
|
|
1376
|
+
var allowedValues = (values) => {
|
|
1377
|
+
const texts = [...new Set(values.map(valueText))];
|
|
1378
|
+
const listed = [];
|
|
1379
|
+
for (const text of texts) {
|
|
1380
|
+
if (listed.length === maxListedValues || [...listed, text].join(", ").length > maxValuesText)
|
|
1381
|
+
break;
|
|
1382
|
+
listed.push(text);
|
|
1383
|
+
}
|
|
1384
|
+
const [only] = listed;
|
|
1385
|
+
if (texts.length === 0) return "no value, since the schema allows none";
|
|
1386
|
+
if (only === void 0)
|
|
1387
|
+
return texts.length === 1 ? "a fixed value too long to list" : `one of ${texts.length} values too long to list`;
|
|
1388
|
+
if (texts.length === 1) return only;
|
|
1389
|
+
const rest = texts.length - listed.length;
|
|
1390
|
+
return `one of ${listed.join(", ")}${rest > 0 ? ` and ${rest} more` : ""}`;
|
|
1391
|
+
};
|
|
1392
|
+
var maxAlternativeKeys = 8;
|
|
1393
|
+
var maxAlternativesText = 360;
|
|
1394
|
+
var unionShape = (alternatives, selector) => {
|
|
1395
|
+
const listed = [];
|
|
1396
|
+
for (const alternative of alternatives) {
|
|
1397
|
+
if (listed.length > 0 && [...listed, alternative].join(" or ").length > maxAlternativesText)
|
|
1398
|
+
break;
|
|
1399
|
+
listed.push(alternative);
|
|
1400
|
+
}
|
|
1401
|
+
const rest = alternatives.length - listed.length;
|
|
1402
|
+
return `${[...listed, ...rest > 0 ? [`${rest} more`] : []].join(" or ")}${selector === void 0 ? "" : `, told apart by ${schemaKey(selector)}`}`;
|
|
1403
|
+
};
|
|
1404
|
+
var missingKey = (expected) => expected === void 0 ? missingKeyText : `${missingKeyText}. Expected ${expected}`;
|
|
1405
|
+
var missingKeyText = "Missing key";
|
|
1406
|
+
var isJsonRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1407
|
+
var pointerSegments = (pointer) => pointer === "#" || pointer === "" ? [] : pointer.replace(/^#?\//, "").split("/").map((segment) => decodeURIComponent(segment).replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
1408
|
+
var resolved = (lookup, uri2) => typeof uri2 === "string" && Object.hasOwn(lookup, uri2) ? lookup[uri2] : void 0;
|
|
1409
|
+
var referenced = (lookup, node) => isJsonRecord(node) ? resolved(lookup, Reflect.get(node, "__absolute_ref__") ?? node.$ref) : void 0;
|
|
1410
|
+
var memberKeywords = /* @__PURE__ */ new Set([...schemaMaps, ...schemaArrays, "dependencies"]);
|
|
1411
|
+
var combinators = /* @__PURE__ */ new Set(["allOf", "anyOf", "oneOf"]);
|
|
1412
|
+
var schemaAt = (document, lookup, segments) => {
|
|
1413
|
+
const anchoredAt = (node2, anchor2) => anchor2 === null && isJsonRecord(node2) && node2.$recursiveAnchor === true ? node2 : anchor2;
|
|
1414
|
+
const pending = [...segments];
|
|
1415
|
+
let node = document;
|
|
1416
|
+
let anchor = anchoredAt(document, null);
|
|
1417
|
+
for (let keyword = pending.shift(); keyword !== void 0; keyword = pending.shift()) {
|
|
1418
|
+
if (!isJsonRecord(node)) return void 0;
|
|
1419
|
+
if (keyword === "$recursiveRef") {
|
|
1420
|
+
const target = anchor === null ? resolved(lookup, Reflect.get(node, "__absolute_recursive_ref__")) : anchor;
|
|
1421
|
+
if (anchor !== null) node = anchor;
|
|
1422
|
+
anchor = target;
|
|
1423
|
+
continue;
|
|
1424
|
+
}
|
|
1425
|
+
if (keyword === "$ref") node = referenced(lookup, node);
|
|
1426
|
+
else {
|
|
1427
|
+
const value = Object.hasOwn(node, keyword) ? node[keyword] : void 0;
|
|
1428
|
+
if (memberKeywords.has(keyword) || keyword === "items" && Array.isArray(value)) {
|
|
1429
|
+
const member = pending.shift();
|
|
1430
|
+
if (member === void 0) return value;
|
|
1431
|
+
if (combinators.has(keyword) && node.$recursiveAnchor !== true) anchor = null;
|
|
1432
|
+
node = Array.isArray(value) ? /^\d+$/.test(member) ? value[Number(member)] : void 0 : isJsonRecord(value) && Object.hasOwn(value, member) ? value[member] : void 0;
|
|
1433
|
+
} else node = value;
|
|
1434
|
+
}
|
|
1435
|
+
anchor = anchoredAt(node, anchor);
|
|
1436
|
+
}
|
|
1437
|
+
return node;
|
|
1438
|
+
};
|
|
1439
|
+
var jsonObjectShape = (node) => {
|
|
1440
|
+
if (!isJsonRecord(node)) return "object";
|
|
1441
|
+
const properties = isJsonRecord(node.properties) ? Object.keys(node.properties) : [];
|
|
1442
|
+
const required = new Set(Array.isArray(node.required) ? node.required : []);
|
|
1443
|
+
const open = node.additionalProperties !== false || isJsonRecord(node.patternProperties) && Object.keys(node.patternProperties).length > 0;
|
|
1444
|
+
return properties.length === 0 && open ? "object" : objectShape(
|
|
1445
|
+
properties.map((name) => ({ name, optional: !required.has(name) })),
|
|
1446
|
+
open
|
|
1447
|
+
);
|
|
1448
|
+
};
|
|
1449
|
+
var locationKey = (segments) => JSON.stringify(segments);
|
|
1450
|
+
var emptyOutline = {
|
|
1451
|
+
types: void 0,
|
|
1452
|
+
properties: /* @__PURE__ */ new Map(),
|
|
1453
|
+
required: /* @__PURE__ */ new Set(),
|
|
1454
|
+
closed: false,
|
|
1455
|
+
values: void 0
|
|
1456
|
+
};
|
|
1457
|
+
var commonValues = (a, b) => a === void 0 ? b : b === void 0 ? a : a.filter((value) => b.some((other) => deepCompareStrict(value, other)));
|
|
1458
|
+
var strings = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
1459
|
+
var commonTypes = (a, b) => new Set(
|
|
1460
|
+
[...a].flatMap(
|
|
1461
|
+
(type) => b.has(type) ? [type] : type === "number" && b.has("integer") || type === "integer" && b.has("number") ? ["integer"] : []
|
|
1462
|
+
)
|
|
1463
|
+
);
|
|
1464
|
+
var mergeOutlines = (a, b) => ({
|
|
1465
|
+
types: a.types === void 0 ? b.types : b.types === void 0 ? a.types : commonTypes(a.types, b.types),
|
|
1466
|
+
properties: new Map([...a.properties, ...b.properties]),
|
|
1467
|
+
required: /* @__PURE__ */ new Set([...a.required, ...b.required]),
|
|
1468
|
+
closed: a.closed || b.closed,
|
|
1469
|
+
values: commonValues(a.values, b.values)
|
|
1470
|
+
});
|
|
1471
|
+
var outlineOf = (node, inspection, seen = /* @__PURE__ */ new Set()) => {
|
|
1472
|
+
if (!isJsonRecord(node) || seen.has(node)) return emptyOutline;
|
|
1473
|
+
const within = /* @__PURE__ */ new Set([...seen, node]);
|
|
1474
|
+
const own = {
|
|
1475
|
+
types: typeof node.type === "string" ? /* @__PURE__ */ new Set([node.type]) : Array.isArray(node.type) ? new Set(strings(node.type)) : void 0,
|
|
1476
|
+
properties: new Map(isJsonRecord(node.properties) ? Object.entries(node.properties) : []),
|
|
1477
|
+
required: new Set(strings(node.required)),
|
|
1478
|
+
closed: (node.additionalProperties === false || node.unevaluatedProperties === false) && !(isJsonRecord(node.patternProperties) && Object.keys(node.patternProperties).length > 0),
|
|
1479
|
+
values: commonValues(
|
|
1480
|
+
Object.hasOwn(node, "const") ? [node.const] : void 0,
|
|
1481
|
+
Array.isArray(node.enum) ? node.enum : void 0
|
|
1482
|
+
)
|
|
1483
|
+
};
|
|
1484
|
+
return [inspection.referenced(node), ...Array.isArray(node.allOf) ? node.allOf : []].reduce(
|
|
1485
|
+
(outline, member) => mergeOutlines(outline, outlineOf(member, inspection, within)),
|
|
1486
|
+
own
|
|
1487
|
+
);
|
|
1488
|
+
};
|
|
1489
|
+
var otherConstraints = "a value with other constraints";
|
|
1490
|
+
var outlineText = (outline, limit) => {
|
|
1491
|
+
if (outline.values !== void 0) return allowedValues(outline.values);
|
|
1492
|
+
const names = [
|
|
1493
|
+
...outline.properties.keys(),
|
|
1494
|
+
...[...outline.required].filter((name) => !outline.properties.has(name))
|
|
1495
|
+
];
|
|
1496
|
+
const shape = names.length === 0 && !outline.closed ? "object" : objectShape(
|
|
1497
|
+
names.map((name) => ({ name, optional: !outline.required.has(name) })),
|
|
1498
|
+
!outline.closed,
|
|
1499
|
+
limit
|
|
1500
|
+
);
|
|
1501
|
+
if (outline.types === void 0)
|
|
1502
|
+
return names.length > 0 || outline.closed ? shape : otherConstraints;
|
|
1503
|
+
return [...outline.types].map((type) => type === "object" ? shape : type).join(" or ");
|
|
1504
|
+
};
|
|
1505
|
+
var describeOutline = (outline) => outlineText(outline, maxAlternativeKeys);
|
|
1506
|
+
var typed = (outline) => outline.values !== void 0 || outline.types !== void 0;
|
|
1507
|
+
var describeProperty = (node, inspection) => {
|
|
1508
|
+
const target = inspection.referenced(node) ?? node;
|
|
1509
|
+
if (isJsonRecord(target) && Object.hasOwn(target, "oneOf")) return void 0;
|
|
1510
|
+
const outline = outlineOf(node, inspection);
|
|
1511
|
+
if (typed(outline)) return outlineText(outline, maxShapeKeys);
|
|
1512
|
+
const members = isJsonRecord(target) && Array.isArray(target.anyOf) ? target.anyOf : [];
|
|
1513
|
+
const outlines = members.filter((member) => member !== false).map((member) => outlineOf(member, inspection));
|
|
1514
|
+
return outlines.length === 0 || !outlines.every(typed) ? void 0 : unionShape([...new Set(outlines.map(describeOutline))], void 0);
|
|
1515
|
+
};
|
|
1516
|
+
var maxPatternText = 160;
|
|
1517
|
+
var count = (amount, noun) => `${amount} ${noun}${amount === 1 ? "" : "s"}`;
|
|
1518
|
+
var constraintProblem = (keyword, node) => {
|
|
1519
|
+
if (!isJsonRecord(node)) return void 0;
|
|
1520
|
+
const value = node[keyword];
|
|
1521
|
+
if (keyword === "pattern")
|
|
1522
|
+
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";
|
|
1523
|
+
if (keyword === "format")
|
|
1524
|
+
return typeof value === "string" ? `Expected a string in the ${JSON.stringify(value.slice(0, 64))} format` : void 0;
|
|
1525
|
+
if (keyword === "uniqueItems") return "Expected an array without repeated items";
|
|
1526
|
+
if (typeof value !== "number") return void 0;
|
|
1527
|
+
switch (keyword) {
|
|
1528
|
+
// Draft 4's boolean `exclusiveMinimum` is not applied: imported schemas validate as draft 7
|
|
1529
|
+
// or 2020-12, where `minimum` and `maximum` always include their bound.
|
|
1530
|
+
case "minimum":
|
|
1531
|
+
return `Expected a number of at least ${value}`;
|
|
1532
|
+
case "maximum":
|
|
1533
|
+
return `Expected a number of at most ${value}`;
|
|
1534
|
+
case "exclusiveMinimum":
|
|
1535
|
+
return `Expected a number greater than ${value}`;
|
|
1536
|
+
case "exclusiveMaximum":
|
|
1537
|
+
return `Expected a number less than ${value}`;
|
|
1538
|
+
case "multipleOf":
|
|
1539
|
+
return `Expected a multiple of ${value}`;
|
|
1540
|
+
case "minLength":
|
|
1541
|
+
return `Expected a string of at least ${count(value, "character")}`;
|
|
1542
|
+
case "maxLength":
|
|
1543
|
+
return `Expected a string of at most ${count(value, "character")}`;
|
|
1544
|
+
case "minItems":
|
|
1545
|
+
return `Expected an array of at least ${count(value, "item")}`;
|
|
1546
|
+
case "maxItems":
|
|
1547
|
+
return `Expected an array of at most ${count(value, "item")}`;
|
|
1548
|
+
case "minProperties":
|
|
1549
|
+
return `Expected an object with at least ${count(value, "key")}`;
|
|
1550
|
+
case "maxProperties":
|
|
1551
|
+
return `Expected an object with at most ${count(value, "key")}`;
|
|
1552
|
+
default:
|
|
1553
|
+
return void 0;
|
|
1554
|
+
}
|
|
1555
|
+
};
|
|
1556
|
+
var overlap = (outline, value, inspection, depth = 0) => !isJsonRecord(value) || depth > 16 ? 0 : Object.entries(value).reduce((total, [key, item]) => {
|
|
1557
|
+
const property = outline.properties.get(key);
|
|
1558
|
+
return property === void 0 ? total : total + 1 + overlap(outlineOf(property, inspection), item, inspection, depth + 1);
|
|
1559
|
+
}, 0);
|
|
1560
|
+
var jsonType = (value) => value === null ? "null" : Array.isArray(value) ? "array" : typeof value === "object" ? "object" : typeof value;
|
|
1561
|
+
var accepted = (outline, value) => {
|
|
1562
|
+
const type = jsonType(value);
|
|
1563
|
+
if (outline.values !== void 0)
|
|
1564
|
+
return outline.values.some((allowed) => jsonType(allowed) === type);
|
|
1565
|
+
if (outline.types === void 0) return true;
|
|
1566
|
+
return outline.types.has(type) || type === "number" && outline.types.has("integer") && Number.isInteger(value);
|
|
1567
|
+
};
|
|
1568
|
+
var valueAt = (input, location2) => location2.reduce(
|
|
1569
|
+
(value, segment) => Array.isArray(value) ? value[Number(segment)] : isJsonRecord(value) && Object.hasOwn(value, segment) ? value[segment] : void 0,
|
|
1570
|
+
input
|
|
1571
|
+
);
|
|
1572
|
+
var discriminatorOf = (holder) => isJsonRecord(holder) && isJsonRecord(holder.discriminator) ? holder.discriminator : void 0;
|
|
1573
|
+
var definitionName = (reference) => {
|
|
1574
|
+
if (typeof reference !== "string" || !reference.startsWith("#/")) return void 0;
|
|
1575
|
+
const segments = pointerSegments(reference);
|
|
1576
|
+
const container = segments.at(-2);
|
|
1577
|
+
return container === "$defs" || container === "definitions" || container === "schemas" && segments.at(-3) === "components" ? segments.at(-1) : void 0;
|
|
1578
|
+
};
|
|
1579
|
+
var discriminatedName = (holder, value) => {
|
|
1580
|
+
const discriminator = discriminatorOf(holder);
|
|
1581
|
+
if (discriminator === void 0 || typeof value !== "string") return void 0;
|
|
1582
|
+
const { mapping } = discriminator;
|
|
1583
|
+
const target = isJsonRecord(mapping) && Object.hasOwn(mapping, value) ? mapping[value] : value;
|
|
1584
|
+
if (typeof target !== "string") return void 0;
|
|
1585
|
+
return /^[\w.-]+$/.test(target) ? target : definitionName(target);
|
|
1586
|
+
};
|
|
1587
|
+
var selectorOf = (holder, alternatives, inspection) => {
|
|
1588
|
+
const declared = discriminatorOf(holder)?.propertyName;
|
|
1589
|
+
if (typeof declared === "string") return declared;
|
|
1590
|
+
const [first] = alternatives;
|
|
1591
|
+
if (first === void 0 || alternatives.length < 2) return void 0;
|
|
1592
|
+
return [...first.properties.keys()].find(
|
|
1593
|
+
(key) => alternatives.every(
|
|
1594
|
+
(alternative) => alternative.properties.has(key) && outlineOf(alternative.properties.get(key), inspection).values !== void 0
|
|
1595
|
+
)
|
|
1596
|
+
);
|
|
1597
|
+
};
|
|
1598
|
+
var alternativeErrors = (errors, head, schemas) => {
|
|
1599
|
+
const prefix = `${errors[head]?.keywordLocation}/`;
|
|
1600
|
+
const alternatives = /* @__PURE__ */ new Map();
|
|
1601
|
+
const settle = (current2, next) => {
|
|
1602
|
+
const collected = alternatives.get(current2);
|
|
1603
|
+
const rejected = Array.isArray(schemas) ? schemas.slice(current2 + 1, next).filter((schema) => schema === false).length : 0;
|
|
1604
|
+
if (collected !== void 0) collected.splice(collected.length - rejected, rejected);
|
|
1605
|
+
};
|
|
1606
|
+
let index = head + 1;
|
|
1607
|
+
let current = -1;
|
|
1608
|
+
for (; index < errors.length; index++) {
|
|
1609
|
+
const error = errors[index];
|
|
1610
|
+
if (error === void 0) break;
|
|
1611
|
+
if (error.keywordLocation.startsWith(prefix)) {
|
|
1612
|
+
const alternative = Number(error.keywordLocation.slice(prefix.length).split("/")[0]);
|
|
1613
|
+
if (alternative !== current) settle(current, alternative);
|
|
1614
|
+
current = alternative;
|
|
1615
|
+
} else if (error.keyword !== "false") break;
|
|
1616
|
+
if (current >= 0) alternatives.set(current, [...alternatives.get(current) ?? [], error]);
|
|
1617
|
+
}
|
|
1618
|
+
settle(current, Array.isArray(schemas) ? schemas.length : current);
|
|
1619
|
+
return { alternatives, end: index };
|
|
1620
|
+
};
|
|
1621
|
+
var pathOf = (location2) => location2.map((segment) => /^\d+$/.test(segment) ? Number(segment) : segment);
|
|
1622
|
+
var unionProblems = (union, schemas, errorsByAlternative, inspection) => {
|
|
1623
|
+
const location2 = pointerSegments(union.instanceLocation);
|
|
1624
|
+
const path = pathOf(location2);
|
|
1625
|
+
if (!Array.isArray(schemas))
|
|
1626
|
+
return [
|
|
1627
|
+
{ path, issue: `Failed the "${union.keyword}" constraint` },
|
|
1628
|
+
...[...errorsByAlternative.values()].flatMap((errors) => problemsOf(errors, inspection))
|
|
1629
|
+
];
|
|
1630
|
+
const alternatives = schemas.flatMap(
|
|
1631
|
+
(schema, index) => schema === false ? [] : [
|
|
1632
|
+
{
|
|
1633
|
+
schema,
|
|
1634
|
+
matched: !errorsByAlternative.has(index),
|
|
1635
|
+
problems: () => problemsOf(errorsByAlternative.get(index) ?? [], inspection)
|
|
1636
|
+
}
|
|
1637
|
+
]
|
|
1638
|
+
);
|
|
1639
|
+
const [only] = alternatives;
|
|
1640
|
+
if (only === void 0) return [{ path, issue: "No value is allowed here" }];
|
|
1641
|
+
if (alternatives.length === 1) return only.problems();
|
|
1642
|
+
const holder = inspection.schemaAt(pointerSegments(union.keywordLocation).slice(0, -1));
|
|
1643
|
+
const shared = outlineOf(holder, inspection);
|
|
1644
|
+
const own = alternatives.map(({ schema }) => outlineOf(schema, inspection));
|
|
1645
|
+
const outlines = own.map((outline) => mergeOutlines(shared, outline));
|
|
1646
|
+
const selector = selectorOf(holder, own, inspection);
|
|
1647
|
+
const expected = `Expected ${unionShape(outlines.map(describeOutline), selector)}`;
|
|
1648
|
+
const matched = alternatives.filter((alternative) => alternative.matched).length;
|
|
1649
|
+
if (union.keyword === "oneOf" && matched > 1)
|
|
1650
|
+
return [{ path, issue: `${expected}. Exactly one may match, but ${matched} do` }];
|
|
1651
|
+
const fixed = outlines.flatMap(({ values }) => values === void 0 ? [] : [values]);
|
|
1652
|
+
if (fixed.length === outlines.length)
|
|
1653
|
+
return [
|
|
1654
|
+
{
|
|
1655
|
+
path,
|
|
1656
|
+
issue: union.keyword === "oneOf" ? `${expected}. Exactly one alternative must match` : `Expected ${allowedValues(fixed.flat())}`
|
|
1657
|
+
}
|
|
1658
|
+
];
|
|
1659
|
+
const value = valueAt(inspection.input, location2);
|
|
1660
|
+
const selectorValue = selector !== void 0 && isJsonRecord(value) && Object.hasOwn(value, selector) ? { value: value[selector] } : void 0;
|
|
1661
|
+
const named = discriminatedName(holder, selectorValue?.value);
|
|
1662
|
+
const ranked = alternatives.map(({ schema, problems }, index) => {
|
|
1663
|
+
const outline = outlines[index] ?? emptyOutline;
|
|
1664
|
+
const property = own[index]?.properties.get(selector ?? "");
|
|
1665
|
+
return {
|
|
1666
|
+
index,
|
|
1667
|
+
problems: problems(),
|
|
1668
|
+
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)),
|
|
1669
|
+
typed: accepted(outline, value),
|
|
1670
|
+
overlap: overlap(outline, value, inspection)
|
|
1286
1671
|
};
|
|
1287
|
-
return [issue];
|
|
1288
1672
|
});
|
|
1673
|
+
const closest = ranked.reduce(
|
|
1674
|
+
(best, candidate) => ([
|
|
1675
|
+
Number(candidate.selected) - Number(best.selected),
|
|
1676
|
+
Number(candidate.typed) - Number(best.typed),
|
|
1677
|
+
candidate.overlap - best.overlap,
|
|
1678
|
+
best.problems.length - candidate.problems.length
|
|
1679
|
+
].find((difference) => difference !== 0) ?? 0) > 0 ? candidate : best
|
|
1680
|
+
);
|
|
1681
|
+
return closest.selected || closest.typed ? [
|
|
1682
|
+
{
|
|
1683
|
+
path,
|
|
1684
|
+
issue: `${expected}. Closest is alternative ${closest.index + 1}, whose problems follow`
|
|
1685
|
+
},
|
|
1686
|
+
...closest.problems
|
|
1687
|
+
] : [{ path, issue: expected }];
|
|
1688
|
+
};
|
|
1689
|
+
var problemsOf = (errors, inspection) => {
|
|
1690
|
+
const closed = /* @__PURE__ */ new Map();
|
|
1691
|
+
const problems = [];
|
|
1692
|
+
for (let index = 0; index < errors.length; index++) {
|
|
1693
|
+
const error = errors[index];
|
|
1694
|
+
if (error === void 0) break;
|
|
1695
|
+
const { keyword, instanceLocation, keywordLocation } = error;
|
|
1696
|
+
if (keyword === "anyOf" || keyword === "oneOf") {
|
|
1697
|
+
const schemas = inspection.schemaAt(pointerSegments(keywordLocation));
|
|
1698
|
+
const { alternatives, end } = alternativeErrors(errors, index, schemas);
|
|
1699
|
+
problems.push(...unionProblems(error, schemas, alternatives, inspection));
|
|
1700
|
+
index = end - 1;
|
|
1701
|
+
continue;
|
|
1702
|
+
}
|
|
1703
|
+
const location2 = pointerSegments(instanceLocation);
|
|
1704
|
+
const path = pathOf(location2);
|
|
1705
|
+
const problem = (issue, at = path) => problems.push({ path: at, issue });
|
|
1706
|
+
const node = () => inspection.schemaAt(pointerSegments(keywordLocation).slice(0, -1));
|
|
1707
|
+
if (keyword === "additionalProperties" || keyword === "unevaluatedProperties") {
|
|
1708
|
+
closed.set(locationKey(location2), node());
|
|
1709
|
+
continue;
|
|
1710
|
+
}
|
|
1711
|
+
if (containerKeywords.has(keyword)) continue;
|
|
1712
|
+
if (keyword === "false") {
|
|
1713
|
+
const key = location2.at(-1);
|
|
1714
|
+
const parent = locationKey(location2.slice(0, -1));
|
|
1715
|
+
if (key === void 0 || !closed.has(parent)) problem("No value is allowed here");
|
|
1716
|
+
else
|
|
1717
|
+
problem(
|
|
1718
|
+
`Unexpected key${echoableKey(key) ? ` "${key}"` : ""}. Expected ${jsonObjectShape(closed.get(parent))}`,
|
|
1719
|
+
path.slice(0, -1)
|
|
1720
|
+
);
|
|
1721
|
+
continue;
|
|
1722
|
+
}
|
|
1723
|
+
const required = keyword === "required" ? /required property "([^"]*)"/.exec(error.error) : null;
|
|
1724
|
+
if (required !== null) {
|
|
1725
|
+
const name = required[1] ?? "";
|
|
1726
|
+
const property = outlineOf(node(), inspection).properties.get(name);
|
|
1727
|
+
problem(
|
|
1728
|
+
missingKey(property === void 0 ? void 0 : describeProperty(property, inspection)),
|
|
1729
|
+
[...path, name]
|
|
1730
|
+
);
|
|
1731
|
+
continue;
|
|
1732
|
+
}
|
|
1733
|
+
const expected = keyword === "type" ? /Expected "([^.]*)"\.?$/.exec(error.error) : null;
|
|
1734
|
+
if (expected !== null) {
|
|
1735
|
+
const types = (expected[1] ?? "").split('", "').map((type) => type === "object" ? jsonObjectShape(node()) : type);
|
|
1736
|
+
problem(`Expected ${types.join(" or ")}`);
|
|
1737
|
+
continue;
|
|
1738
|
+
}
|
|
1739
|
+
if (keyword === "const" || keyword === "enum") {
|
|
1740
|
+
const schema = node();
|
|
1741
|
+
const values = !isJsonRecord(schema) ? void 0 : keyword === "const" ? Object.hasOwn(schema, "const") ? [schema.const] : void 0 : Array.isArray(schema.enum) ? schema.enum : void 0;
|
|
1742
|
+
problem(
|
|
1743
|
+
values === void 0 ? "Expected one of the allowed values" : `Expected ${allowedValues(values)}`
|
|
1744
|
+
);
|
|
1745
|
+
continue;
|
|
1746
|
+
}
|
|
1747
|
+
problem(constraintProblem(keyword, node()) ?? `Failed the "${keyword}" constraint`);
|
|
1748
|
+
}
|
|
1749
|
+
return problems;
|
|
1750
|
+
};
|
|
1751
|
+
var documentKeys = (document) => {
|
|
1752
|
+
const named = /* @__PURE__ */ new Set();
|
|
1753
|
+
let any = false;
|
|
1754
|
+
const visit = (node, depth) => {
|
|
1755
|
+
if (depth > 64 || typeof node !== "object" || node === null) return;
|
|
1756
|
+
if (Array.isArray(node)) {
|
|
1757
|
+
for (const item of node) visit(item, depth + 1);
|
|
1758
|
+
return;
|
|
1759
|
+
}
|
|
1760
|
+
const record2 = node;
|
|
1761
|
+
if (isJsonRecord(record2.properties))
|
|
1762
|
+
for (const name of Object.keys(record2.properties)) named.add(name);
|
|
1763
|
+
for (const name of strings(record2.required)) named.add(name);
|
|
1764
|
+
if (isJsonRecord(record2.dependentRequired))
|
|
1765
|
+
for (const [name, names] of Object.entries(record2.dependentRequired)) {
|
|
1766
|
+
named.add(name);
|
|
1767
|
+
for (const other of strings(names)) named.add(other);
|
|
1768
|
+
}
|
|
1769
|
+
if (isJsonRecord(record2.patternProperties) && Object.keys(record2.patternProperties).length > 0 || isJsonRecord(record2.additionalProperties) || isJsonRecord(record2.unevaluatedProperties))
|
|
1770
|
+
any = true;
|
|
1771
|
+
for (const value of Object.values(record2)) visit(value, depth + 1);
|
|
1772
|
+
};
|
|
1773
|
+
visit(document, 0);
|
|
1774
|
+
return (key) => any || named.has(key);
|
|
1775
|
+
};
|
|
1776
|
+
var importedKeys = /* @__PURE__ */ new WeakMap();
|
|
1777
|
+
var importedSchemaKeys = (check) => importedKeys.get(check);
|
|
1778
|
+
var jsonSchemaProblems = (errors, inspection) => {
|
|
1779
|
+
const problems = problemsOf(errors, inspection);
|
|
1289
1780
|
return problems.length === 0 ? false : problems;
|
|
1290
1781
|
};
|
|
1291
1782
|
var compileJsonSchemaDecoder = (document) => Effect_exports.gen(function* () {
|
|
@@ -1296,8 +1787,7 @@ var compileJsonSchemaDecoder = (document) => Effect_exports.gen(function* () {
|
|
|
1296
1787
|
if (normalized === null || typeof normalized !== "object" || Array.isArray(normalized))
|
|
1297
1788
|
throw new ValidationError();
|
|
1298
1789
|
const lookup = dereference(normalized);
|
|
1299
|
-
for (const schema of
|
|
1300
|
-
if (typeof schema === "boolean") continue;
|
|
1790
|
+
for (const schema of evaluatedSchemas(normalized, lookup)) {
|
|
1301
1791
|
for (const pattern of [schema.pattern, ...Object.keys(schema.patternProperties ?? {})]) {
|
|
1302
1792
|
if (pattern === void 0) continue;
|
|
1303
1793
|
try {
|
|
@@ -1312,28 +1802,42 @@ var compileJsonSchemaDecoder = (document) => Effect_exports.gen(function* () {
|
|
|
1312
1802
|
throw new ValidationError();
|
|
1313
1803
|
}
|
|
1314
1804
|
}
|
|
1805
|
+
const inspection = (input) => ({
|
|
1806
|
+
schemaAt: (segments) => schemaAt(normalized, lookup, segments),
|
|
1807
|
+
referenced: (node) => referenced(lookup, node),
|
|
1808
|
+
accepts: (node, value) => {
|
|
1809
|
+
if (typeof node !== "boolean" && !isJsonRecord(node)) return false;
|
|
1810
|
+
try {
|
|
1811
|
+
return validate(value, node, draft, lookup).valid;
|
|
1812
|
+
} catch {
|
|
1813
|
+
return false;
|
|
1814
|
+
}
|
|
1815
|
+
},
|
|
1816
|
+
input
|
|
1817
|
+
});
|
|
1315
1818
|
return {
|
|
1316
|
-
validate: (input) => validate(input, normalized, draft, lookup)
|
|
1819
|
+
validate: (input) => validate(input, normalized, draft, lookup),
|
|
1820
|
+
inspection
|
|
1317
1821
|
};
|
|
1318
1822
|
},
|
|
1319
1823
|
catch: () => new ValidationError()
|
|
1320
1824
|
});
|
|
1321
|
-
const
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
{ expected: "a value matching a supported imported JSON Schema" }
|
|
1332
|
-
)
|
|
1825
|
+
const check = Schema_exports.makeFilter(
|
|
1826
|
+
(value) => {
|
|
1827
|
+
try {
|
|
1828
|
+
const result = validator.validate(value);
|
|
1829
|
+
return result.valid || jsonSchemaProblems(result.errors, validator.inspection(value));
|
|
1830
|
+
} catch {
|
|
1831
|
+
return false;
|
|
1832
|
+
}
|
|
1833
|
+
},
|
|
1834
|
+
{ expected: "a value matching a supported imported JSON Schema" }
|
|
1333
1835
|
);
|
|
1836
|
+
importedKeys.set(check, documentKeys(document));
|
|
1837
|
+
const decoder = Schema_exports.Json.check(check);
|
|
1334
1838
|
return Object.assign(decoder, { [ImportedJsonSchema]: document });
|
|
1335
1839
|
});
|
|
1336
|
-
var
|
|
1840
|
+
var lazyCompiledDecoder = (document) => {
|
|
1337
1841
|
const read = once(document);
|
|
1338
1842
|
let compiled;
|
|
1339
1843
|
const compile = Effect_exports.suspend(
|
|
@@ -1353,9 +1857,11 @@ var lazyDecoder = (document) => {
|
|
|
1353
1857
|
Effect_exports.flatMap((schema) => SchemaParser_exports.decodeUnknownEffect(schema)(input, options))
|
|
1354
1858
|
)
|
|
1355
1859
|
);
|
|
1356
|
-
return withLazyJsonSchemaDocument(decoder, read);
|
|
1860
|
+
return { decoder: withLazyJsonSchemaDocument(decoder, read), compile };
|
|
1357
1861
|
};
|
|
1862
|
+
var lazyDecoder = (document) => lazyCompiledDecoder(document).decoder;
|
|
1358
1863
|
var lazyJsonSchemaDecoder = (document) => Effect_exports.sync(() => lazyDecoder(document));
|
|
1864
|
+
var preparedJsonSchemaDecoder = (document) => lazyCompiledDecoder(() => document);
|
|
1359
1865
|
var isJsonValue = Schema_exports.is(Schema_exports.Json);
|
|
1360
1866
|
var jsonDocument = (input) => {
|
|
1361
1867
|
if (typeof input !== "object" || input === null || Array.isArray(input)) return void 0;
|
|
@@ -1385,9 +1891,6 @@ var jsonSchema = (input) => {
|
|
|
1385
1891
|
false
|
|
1386
1892
|
);
|
|
1387
1893
|
};
|
|
1388
|
-
var storageFieldOf = (schema) => schema[StorageField];
|
|
1389
|
-
var id = (table) => wrap(Schema_exports.NonEmptyString, false, { kind: "id", references: table });
|
|
1390
|
-
var userId = () => wrap(Schema_exports.NonEmptyString, false, { kind: "userId" });
|
|
1391
1894
|
var jsonSchemaDocument = (decoder) => {
|
|
1392
1895
|
const imported = importedJsonSchema(decoder);
|
|
1393
1896
|
if (imported !== void 0) return Schema_exports.decodeUnknownEffect(JsonObject)(imported);
|
|
@@ -1402,7 +1905,9 @@ var jsonSchemaDocument = (decoder) => {
|
|
|
1402
1905
|
export {
|
|
1403
1906
|
decoderOf,
|
|
1404
1907
|
isSchema,
|
|
1908
|
+
schemaArgument,
|
|
1405
1909
|
parse,
|
|
1910
|
+
parseDeclaration,
|
|
1406
1911
|
wrap,
|
|
1407
1912
|
string,
|
|
1408
1913
|
number,
|
|
@@ -1412,16 +1917,25 @@ export {
|
|
|
1412
1917
|
literal,
|
|
1413
1918
|
array,
|
|
1414
1919
|
object,
|
|
1920
|
+
plain,
|
|
1921
|
+
raw,
|
|
1922
|
+
fieldExposure,
|
|
1415
1923
|
importedJsonSchema,
|
|
1416
1924
|
once,
|
|
1417
1925
|
withLazyJsonSchemaDocument,
|
|
1418
1926
|
nestJsonSchema,
|
|
1927
|
+
echoableKey,
|
|
1928
|
+
objectShape,
|
|
1929
|
+
allowedValues,
|
|
1930
|
+
maxAlternativeKeys,
|
|
1931
|
+
unionShape,
|
|
1932
|
+
missingKey,
|
|
1933
|
+
missingKeyText,
|
|
1934
|
+
importedSchemaKeys,
|
|
1419
1935
|
compileJsonSchemaDecoder,
|
|
1420
1936
|
lazyJsonSchemaDecoder,
|
|
1937
|
+
preparedJsonSchemaDecoder,
|
|
1421
1938
|
jsonSchemaDecoder,
|
|
1422
1939
|
jsonSchema,
|
|
1423
|
-
storageFieldOf,
|
|
1424
|
-
id,
|
|
1425
|
-
userId,
|
|
1426
1940
|
jsonSchemaDocument
|
|
1427
1941
|
};
|