@depup/typebox 1.3.22-depup.0 → 1.3.27-depup.0
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 +2 -2
- package/build/compile/validator.d.mts +1 -1
- package/build/compile/validator.mjs +1 -1
- package/build/format/iri.mjs +5 -1
- package/build/schema/compile.d.mts +3 -2
- package/build/schema/compile.mjs +8 -8
- package/build/schema/engine/_context.d.mts +1 -6
- package/build/schema/engine/_context.mjs +9 -14
- package/build/schema/engine/_functions.mjs +1 -1
- package/build/schema/engine/_stack.d.mts +6 -2
- package/build/schema/engine/_stack.mjs +135 -32
- package/build/schema/engine/additionalProperties.mjs +1 -3
- package/build/schema/engine/allOf.mjs +2 -2
- package/build/schema/engine/anyOf.mjs +2 -2
- package/build/schema/engine/if.mjs +2 -2
- package/build/schema/engine/oneOf.mjs +2 -2
- package/build/schema/engine/propertyNames.mjs +1 -3
- package/build/schema/engine/ref.mjs +2 -2
- package/build/schema/engine/schema.mjs +6 -0
- package/build/schema/engine/unevaluatedItems.mjs +2 -2
- package/build/schema/engine/unevaluatedProperties.mjs +2 -2
- package/build/schema/errors.d.mts +2 -2
- package/build/schema/errors.mjs +7 -13
- package/build/schema/intern/index.d.mts +1 -0
- package/build/schema/intern/index.mjs +1 -0
- package/build/schema/intern/intern.d.mts +14 -0
- package/build/schema/intern/intern.mjs +259 -0
- package/build/schema/parse.d.mts +1 -0
- package/build/schema/parse.mjs +10 -5
- package/build/schema/resolve/resolve.d.mts +34 -3
- package/build/schema/resolve/resolve.mjs +198 -73
- package/build/schema/schema.d.mts +1 -0
- package/build/schema/schema.mjs +1 -0
- package/build/value/errors/errors.d.mts +2 -12
- package/build/value/errors/errors.mjs +2 -7
- package/changes.json +1 -1
- package/package.json +3 -3
- package/readme.md +9 -5
|
@@ -2,25 +2,69 @@
|
|
|
2
2
|
import { Guard } from '../../guard/index.mjs';
|
|
3
3
|
import { Pointer } from '../pointer/index.mjs';
|
|
4
4
|
import * as Schema from '../types/index.mjs';
|
|
5
|
+
export const DefaultBase = 'https://json-schema.org';
|
|
5
6
|
// ------------------------------------------------------------------
|
|
6
|
-
//
|
|
7
|
+
// Find: FindDynamicAnchor
|
|
7
8
|
// ------------------------------------------------------------------
|
|
8
|
-
|
|
9
|
+
function FindDynamicAnchor(schema, name) {
|
|
10
|
+
if (Guard.IsObject(schema) && Schema.IsDynamicAnchor(schema) && Guard.IsEqual(schema.$dynamicAnchor, name)) {
|
|
11
|
+
return schema;
|
|
12
|
+
}
|
|
13
|
+
if (Guard.IsObject(schema)) {
|
|
14
|
+
for (const key of Guard.Keys(schema)) {
|
|
15
|
+
const result = FindDynamicAnchor(schema[key], name);
|
|
16
|
+
if (result)
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// (no-coverage) - is it even possible to search for an anchor
|
|
21
|
+
// with embedded logical schema like allOf, anyOf, etc?
|
|
22
|
+
// if (Guard.IsArray(schema)) { // (no-coverage)
|
|
23
|
+
// for (const item of schema) {
|
|
24
|
+
// const result = FindDynamicAnchor(item, name)
|
|
25
|
+
// if (result) return result
|
|
26
|
+
// }
|
|
27
|
+
// }
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
9
30
|
// ------------------------------------------------------------------
|
|
10
|
-
//
|
|
31
|
+
// Find: FindBase
|
|
32
|
+
// ------------------------------------------------------------------
|
|
33
|
+
function FindBase(schema, base, target) {
|
|
34
|
+
if (Guard.IsEqual(schema, target))
|
|
35
|
+
return base.href;
|
|
36
|
+
const nextBase = Schema.IsSchemaObject(schema) && Schema.IsId(schema) ? new URL(schema.$id, base.href) : base;
|
|
37
|
+
if (Guard.IsArray(schema)) {
|
|
38
|
+
for (const item of schema) {
|
|
39
|
+
const result = FindBase(item, nextBase, target);
|
|
40
|
+
if (!Guard.IsUndefined(result))
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if (Guard.IsObject(schema)) {
|
|
45
|
+
for (const key of Guard.Keys(schema)) {
|
|
46
|
+
const result = FindBase(schema[key], nextBase, target);
|
|
47
|
+
if (!Guard.IsUndefined(result))
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
// ------------------------------------------------------------------
|
|
54
|
+
// Match: MatchId
|
|
11
55
|
// ------------------------------------------------------------------
|
|
12
56
|
function MatchId(schema, base, ref) {
|
|
13
|
-
|
|
57
|
+
// ref is a bare fragment naming this schema's $id directly
|
|
58
|
+
if (Guard.IsEqual(schema.$id, ref.hash))
|
|
14
59
|
return schema;
|
|
15
|
-
const absoluteId = new URL(schema.$id, base.href);
|
|
16
60
|
const absoluteRef = new URL(ref.href, base.href);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
61
|
+
// ref shares this $id's document, so resolve the fragment within it
|
|
62
|
+
if (Guard.IsEqual(base.pathname, absoluteRef.pathname))
|
|
63
|
+
return ref.hash.startsWith('#') ? MatchHash(schema, ref) : schema;
|
|
20
64
|
return undefined;
|
|
21
65
|
}
|
|
22
66
|
// ------------------------------------------------------------------
|
|
23
|
-
// Match:
|
|
67
|
+
// Match: MatchAnchor
|
|
24
68
|
// ------------------------------------------------------------------
|
|
25
69
|
function MatchAnchor(schema, base, ref) {
|
|
26
70
|
const absoluteAnchor = new URL(`#${schema.$anchor}`, base.href);
|
|
@@ -28,23 +72,18 @@ function MatchAnchor(schema, base, ref) {
|
|
|
28
72
|
return Guard.IsEqual(absoluteAnchor.href, absoluteRef.href) ? schema : undefined;
|
|
29
73
|
}
|
|
30
74
|
// ------------------------------------------------------------------
|
|
31
|
-
// Match:
|
|
75
|
+
// Match: MatchDynamicAnchor
|
|
32
76
|
// ------------------------------------------------------------------
|
|
33
77
|
function MatchDynamicAnchor(schema, base, ref) {
|
|
34
78
|
const absoluteAnchor = new URL(`#${schema.$dynamicAnchor}`, base.href);
|
|
35
79
|
const absoluteRef = new URL(ref.href, base.href);
|
|
36
|
-
|
|
80
|
+
const isMatch = Guard.IsEqual(absoluteAnchor.href, absoluteRef.href);
|
|
81
|
+
return isMatch ? schema : undefined;
|
|
37
82
|
}
|
|
38
83
|
// ------------------------------------------------------------------
|
|
39
|
-
// Match:
|
|
40
|
-
//
|
|
41
|
-
// Resolves JSON Pointer fragments only. Plain anchor-style fragments
|
|
42
|
-
// (no leading '/') are handled exclusively by MatchAnchor and
|
|
43
|
-
// MatchDynamicAnchor to prevent accidentally resolving an anchor name
|
|
44
|
-
// as a pointer into the schema tree.
|
|
45
|
-
//
|
|
84
|
+
// Match: MatchHash
|
|
46
85
|
// ------------------------------------------------------------------
|
|
47
|
-
function MatchHash(schema,
|
|
86
|
+
function MatchHash(schema, ref) {
|
|
48
87
|
if (ref.href.endsWith('#'))
|
|
49
88
|
return schema;
|
|
50
89
|
if (!ref.hash.startsWith('#'))
|
|
@@ -52,10 +91,11 @@ function MatchHash(schema, _base, ref) {
|
|
|
52
91
|
const fragment = decodeURIComponent(ref.hash.slice(1));
|
|
53
92
|
if (!fragment.startsWith('/'))
|
|
54
93
|
return undefined;
|
|
55
|
-
|
|
94
|
+
const result = Pointer.Get(schema, fragment);
|
|
95
|
+
return result;
|
|
56
96
|
}
|
|
57
97
|
// ------------------------------------------------------------------
|
|
58
|
-
// Match
|
|
98
|
+
// Match: Match
|
|
59
99
|
// ------------------------------------------------------------------
|
|
60
100
|
function Match(schema, base, ref) {
|
|
61
101
|
if (Schema.IsId(schema)) {
|
|
@@ -73,7 +113,7 @@ function Match(schema, base, ref) {
|
|
|
73
113
|
if (!Guard.IsUndefined(result))
|
|
74
114
|
return result;
|
|
75
115
|
}
|
|
76
|
-
return MatchHash(schema,
|
|
116
|
+
return MatchHash(schema, ref);
|
|
77
117
|
}
|
|
78
118
|
// ------------------------------------------------------------------
|
|
79
119
|
// FromArray
|
|
@@ -88,8 +128,6 @@ function FromArray(schema, base, ref) {
|
|
|
88
128
|
// FromObject
|
|
89
129
|
// ------------------------------------------------------------------
|
|
90
130
|
function SkipProperty(key) {
|
|
91
|
-
// these are explicit data encoded in a schema, they should not
|
|
92
|
-
// be considered valid targets used for de-referencing.
|
|
93
131
|
return Guard.IsEqual(key, 'const') || Guard.IsEqual(key, 'enum');
|
|
94
132
|
}
|
|
95
133
|
function FromObject(schema, base, ref) {
|
|
@@ -104,9 +142,7 @@ function FromObject(schema, base, ref) {
|
|
|
104
142
|
// FromValue
|
|
105
143
|
// ------------------------------------------------------------------
|
|
106
144
|
function FromValue(schema, base, ref) {
|
|
107
|
-
const nextBase = Schema.IsSchemaObject(schema) && Schema.IsId(schema)
|
|
108
|
-
? new URL(schema.$id, base.href)
|
|
109
|
-
: base;
|
|
145
|
+
const nextBase = Schema.IsSchemaObject(schema) && Schema.IsId(schema) ? new URL(schema.$id, base.href) : base;
|
|
110
146
|
if (Schema.IsSchemaObject(schema)) {
|
|
111
147
|
const result = Match(schema, nextBase, ref);
|
|
112
148
|
if (!Guard.IsUndefined(result))
|
|
@@ -119,84 +155,173 @@ function FromValue(schema, base, ref) {
|
|
|
119
155
|
return undefined;
|
|
120
156
|
}
|
|
121
157
|
// ------------------------------------------------------------------
|
|
158
|
+
// Base
|
|
159
|
+
// ------------------------------------------------------------------
|
|
160
|
+
export function Base(schema, base, target) {
|
|
161
|
+
return FindBase(schema, new URL(base || '.', DefaultBase), target);
|
|
162
|
+
}
|
|
163
|
+
// ------------------------------------------------------------------
|
|
164
|
+
// Resource
|
|
165
|
+
// ------------------------------------------------------------------
|
|
166
|
+
export function Resource(context, schema, base, ref) {
|
|
167
|
+
const result = Ref(context, schema, base, ref, false);
|
|
168
|
+
return Schema.IsSchemaObject(result) && Schema.IsId(result) ? result : undefined;
|
|
169
|
+
}
|
|
170
|
+
// ------------------------------------------------------------------
|
|
122
171
|
// CanonicalHref
|
|
123
|
-
//
|
|
124
|
-
// Returns the URL's href with its fragment removed, as a string.
|
|
125
|
-
// This is the canonical URI a document is identified and keyed by
|
|
126
|
-
// in context.
|
|
127
172
|
// ------------------------------------------------------------------
|
|
128
173
|
function CanonicalHref(url) {
|
|
129
174
|
return url.href.split('#')[0];
|
|
130
175
|
}
|
|
131
176
|
// ------------------------------------------------------------------
|
|
132
|
-
//
|
|
133
|
-
//
|
|
134
|
-
// A ContextRef targets a simple key name in the context and is
|
|
135
|
-
// used for fast resolution of inline referential TypeBox types.
|
|
177
|
+
// Ref: RefRemote (Phase 1)
|
|
136
178
|
// ------------------------------------------------------------------
|
|
137
179
|
function RefContext(context, ref) {
|
|
138
180
|
return Guard.HasPropertyKey(context, ref) ? context[ref] : undefined;
|
|
139
181
|
}
|
|
140
182
|
// ------------------------------------------------------------------
|
|
141
|
-
//
|
|
142
|
-
//
|
|
143
|
-
// Resolves the ref's fragment within the current schema resource,
|
|
144
|
-
// either as a JSON Pointer or a plain-name fragment ($anchor,
|
|
145
|
-
// $dynamicAnchor), per the JSON Schema spec.
|
|
183
|
+
// Ref: RefRemote (Phase 2)
|
|
146
184
|
// ------------------------------------------------------------------
|
|
147
185
|
function RefLocal(schema, base, ref) {
|
|
148
186
|
return FromValue(schema, base, ref);
|
|
149
187
|
}
|
|
150
188
|
// ------------------------------------------------------------------
|
|
151
|
-
//
|
|
152
|
-
//
|
|
153
|
-
// Locates the schema resource identified by the ref's base URI, then
|
|
154
|
-
// resolves the ref's fragment within that resource, either as a JSON
|
|
155
|
-
// Pointer or a plain-name fragment, per the JSON Schema spec.
|
|
189
|
+
// Ref: RefRemote (Phase 3)
|
|
156
190
|
// ------------------------------------------------------------------
|
|
157
191
|
function RefRemote(context, base, ref) {
|
|
158
|
-
const
|
|
159
|
-
if (Guard.IsEqual(
|
|
192
|
+
const canonicalHref = CanonicalHref(ref);
|
|
193
|
+
if (Guard.IsEqual(canonicalHref, CanonicalHref(base)))
|
|
194
|
+
return undefined;
|
|
195
|
+
if (!Guard.HasPropertyKey(context, canonicalHref))
|
|
196
|
+
return undefined;
|
|
197
|
+
const remoteSchema = context[canonicalHref];
|
|
198
|
+
const remoteBase = (Schema.IsSchemaObject(remoteSchema) && Schema.IsId(remoteSchema)) ? new URL(remoteSchema.$id, canonicalHref) : new URL(canonicalHref);
|
|
199
|
+
const result = Guard.IsEqual(ref.hash, '') ? remoteSchema : FromValue(remoteSchema, remoteBase, ref);
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
202
|
+
// ------------------------------------------------------------------
|
|
203
|
+
// RetrievedResource: LegacyRetrievedResource
|
|
204
|
+
//
|
|
205
|
+
// Draft-4 style schemas (no $schema keyword) treat a nested $id as an
|
|
206
|
+
// in-place base URI change rather than a new resource boundary. A
|
|
207
|
+
// local ('#...') ref that lands somewhere with a different base than
|
|
208
|
+
// the current reference base needs a frame so later anchor/pointer
|
|
209
|
+
// resolution is computed against the right base.
|
|
210
|
+
// ------------------------------------------------------------------
|
|
211
|
+
function LegacyRetrievedResource(root, lexicalSchema, referenceBase, ref, schema) {
|
|
212
|
+
if (!ref.$ref.startsWith('#'))
|
|
213
|
+
return undefined;
|
|
214
|
+
if (Guard.HasPropertyKey(root, '$schema'))
|
|
215
|
+
return undefined;
|
|
216
|
+
const targetBase = Base(lexicalSchema, referenceBase, schema);
|
|
217
|
+
if (Guard.IsUndefined(targetBase) || Guard.IsEqual(targetBase, referenceBase))
|
|
160
218
|
return undefined;
|
|
161
|
-
|
|
219
|
+
return { target: schema, base: targetBase, root: lexicalSchema };
|
|
220
|
+
}
|
|
221
|
+
// ------------------------------------------------------------------
|
|
222
|
+
// RetrievedResource: RemoteRetrievedResource
|
|
223
|
+
//
|
|
224
|
+
// The ref's canonical URL names a document already loaded into
|
|
225
|
+
// context. That document becomes the frame's root going forward.
|
|
226
|
+
// ------------------------------------------------------------------
|
|
227
|
+
function RemoteRetrievedResource(context, canonical, schema) {
|
|
228
|
+
const remoteRoot = context[canonical];
|
|
229
|
+
if (!Schema.IsSchemaObject(remoteRoot))
|
|
162
230
|
return undefined;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
231
|
+
return { target: schema, base: canonical, root: remoteRoot };
|
|
232
|
+
}
|
|
233
|
+
// ------------------------------------------------------------------
|
|
234
|
+
// RetrievedResource
|
|
235
|
+
//
|
|
236
|
+
// A genuinely remote document frame always wins over a same-document
|
|
237
|
+
// legacy one: only one frame is ever entered per ref.
|
|
238
|
+
// ------------------------------------------------------------------
|
|
239
|
+
function FindRetrievedResource(stackframe, ref, schema, canonical, isRemote) {
|
|
240
|
+
const remote = isRemote ? RemoteRetrievedResource(stackframe.context, canonical, schema) : undefined;
|
|
241
|
+
if (!Guard.IsUndefined(remote))
|
|
242
|
+
return remote;
|
|
243
|
+
return LegacyRetrievedResource(stackframe.root, stackframe.lexicalSchema, stackframe.referenceBase, ref, schema);
|
|
244
|
+
}
|
|
245
|
+
// ------------------------------------------------------------------
|
|
246
|
+
// ResolvedResource: FindResolvedResource
|
|
247
|
+
//
|
|
248
|
+
// The ref crossed into a different resource but landed on a schema
|
|
249
|
+
// that doesn't itself carry that resource's $id (e.g. a pointer into
|
|
250
|
+
// the middle of a remote document). The enclosing resource still
|
|
251
|
+
// needs to be entered so lexical/base lookups behave as if traversal
|
|
252
|
+
// had walked in from its top.
|
|
253
|
+
// ------------------------------------------------------------------
|
|
254
|
+
function FindResolvedResource(context, root, referenceBase, canonical, schema, ids) {
|
|
255
|
+
if (Schema.IsId(schema))
|
|
256
|
+
return undefined;
|
|
257
|
+
const resource = Resource(context, root, referenceBase, canonical);
|
|
258
|
+
if (!resource || ids.includes(resource))
|
|
259
|
+
return undefined;
|
|
260
|
+
return { target: schema, resource };
|
|
166
261
|
}
|
|
167
262
|
// ------------------------------------------------------------------
|
|
168
263
|
// Ref
|
|
169
264
|
// ------------------------------------------------------------------
|
|
170
|
-
export function Ref(
|
|
171
|
-
const initialBase =
|
|
172
|
-
const
|
|
173
|
-
|
|
265
|
+
export function Ref(remotes, schema, base, ref, applySchemaId = true) {
|
|
266
|
+
const initialBase = new URL(base || '.', DefaultBase);
|
|
267
|
+
const resolvedBase = applySchemaId && Schema.IsId(schema) ? new URL(schema.$id, initialBase) : initialBase;
|
|
268
|
+
const initialRef = new URL(ref, resolvedBase.href);
|
|
269
|
+
return RefContext(remotes, ref) ?? RefLocal(schema, resolvedBase, initialRef) ?? RefRemote(remotes, resolvedBase, initialRef);
|
|
174
270
|
}
|
|
175
271
|
// ------------------------------------------------------------------
|
|
176
272
|
// DynamicRef
|
|
177
273
|
// ------------------------------------------------------------------
|
|
178
|
-
export function DynamicRef(context, root, base, dynamicRef, dynamicAnchors) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const fragmentTarget = dynamicRef.$dynamicRef
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
274
|
+
export function DynamicRef(context, root, base, schema, dynamicRef, dynamicAnchors) {
|
|
275
|
+
const initialBase = new URL(base || '.', DefaultBase);
|
|
276
|
+
const fragmentRoot = dynamicRef.$dynamicRef.startsWith('#') ? schema : root;
|
|
277
|
+
const fragmentTarget = Ref(context, fragmentRoot, base, dynamicRef.$dynamicRef, false);
|
|
278
|
+
if (Guard.IsUndefined(fragmentTarget)) {
|
|
279
|
+
const fragment = new URL(dynamicRef.$dynamicRef, initialBase).hash;
|
|
280
|
+
if (!fragment.startsWith('#/') && fragment.startsWith('#')) {
|
|
281
|
+
const name = decodeURIComponent(fragment.slice(1));
|
|
282
|
+
const anchorTarget = dynamicAnchors.find((anchor) => Guard.IsEqual(anchor.$dynamicAnchor, name)) ?? FindDynamicAnchor(root, name);
|
|
283
|
+
return anchorTarget;
|
|
284
|
+
}
|
|
185
285
|
return undefined;
|
|
186
|
-
|
|
187
|
-
// If it does not, return the static target unchanged.
|
|
286
|
+
}
|
|
188
287
|
if (!Schema.IsSchemaObject(fragmentTarget) || !Schema.IsDynamicAnchor(fragmentTarget))
|
|
189
288
|
return fragmentTarget;
|
|
190
|
-
|
|
191
|
-
// only plain fragment names (e.g., "#foo") trigger the dynamic scope; JSON
|
|
192
|
-
// Pointer fragments (e.g., "#/definitions/foo") bypass dynamic resolution.
|
|
193
|
-
const fragment = new URL(dynamicRef.$dynamicRef, DefaultBase).hash;
|
|
289
|
+
const fragment = new URL(dynamicRef.$dynamicRef, initialBase).hash;
|
|
194
290
|
if (fragment.startsWith('#/'))
|
|
195
291
|
return fragmentTarget;
|
|
196
|
-
|
|
197
|
-
// target's $dynamicAnchor. The stack reflects the current evaluation path, and
|
|
198
|
-
// find() returns the outermost (first encountered) match, which is the correct
|
|
199
|
-
// lexical scope per the specification.
|
|
200
|
-
const anchorTarget = dynamicAnchors.find(anchor => anchor.$dynamicAnchor === fragmentTarget.$dynamicAnchor);
|
|
292
|
+
const anchorTarget = dynamicAnchors.find((anchor) => Guard.IsEqual(anchor.$dynamicAnchor, fragmentTarget.$dynamicAnchor));
|
|
201
293
|
return anchorTarget ?? fragmentTarget;
|
|
202
294
|
}
|
|
295
|
+
// ------------------------------------------------------------------
|
|
296
|
+
// ResolveRef
|
|
297
|
+
//
|
|
298
|
+
// Resolves the schema a $ref points to, and describes whether that
|
|
299
|
+
// crossing implies a "retrieved resource" frame or entering a
|
|
300
|
+
// resource the target doesn't itself carry the $id for. The caller
|
|
301
|
+
// decides whether and how to record these.
|
|
302
|
+
// ------------------------------------------------------------------
|
|
303
|
+
export function ResolveRef(stackframe, ref) {
|
|
304
|
+
const source = stackframe.inRetrievedFrame ? stackframe.lexicalSchema : stackframe.root;
|
|
305
|
+
const refRoot = ref.$ref.startsWith('#') ? stackframe.lexicalSchema : source;
|
|
306
|
+
const schema = Ref(stackframe.context, refRoot, stackframe.referenceBase, ref.$ref, false);
|
|
307
|
+
if (!schema || !Schema.IsSchemaObject(schema))
|
|
308
|
+
return { schema };
|
|
309
|
+
const canonical = new URL(ref.$ref, stackframe.referenceBase).href.split('#')[0];
|
|
310
|
+
const isRemote = !Guard.IsEqual(canonical, stackframe.resourceBase);
|
|
311
|
+
const retrievedResource = FindRetrievedResource(stackframe, ref, schema, canonical, isRemote);
|
|
312
|
+
const resolvedResource = isRemote ? FindResolvedResource(stackframe.context, stackframe.root, stackframe.referenceBase, canonical, schema, stackframe.ids) : undefined;
|
|
313
|
+
return { schema, retrievedResource, resolvedResource };
|
|
314
|
+
}
|
|
315
|
+
// ------------------------------------------------------------------
|
|
316
|
+
// ResolveRecursiveRef
|
|
317
|
+
// ------------------------------------------------------------------
|
|
318
|
+
export function ResolveRecursiveRef(stackframe, recursiveRef) {
|
|
319
|
+
const refRoot = Schema.IsRecursiveAnchorTrue(stackframe.lexicalSchema) ? stackframe.recursiveAnchors[0] : stackframe.lexicalSchema;
|
|
320
|
+
return Ref(stackframe.context, refRoot, stackframe.lexicalBase, recursiveRef.$recursiveRef, false);
|
|
321
|
+
}
|
|
322
|
+
// ------------------------------------------------------------------
|
|
323
|
+
// ResolveDynamicRef
|
|
324
|
+
// ------------------------------------------------------------------
|
|
325
|
+
export function ResolveDynamicRef(stackframe, dynamicRef) {
|
|
326
|
+
return DynamicRef(stackframe.context, stackframe.root, stackframe.lexicalBase, stackframe.lexicalSchema, dynamicRef, stackframe.dynamicAnchors);
|
|
327
|
+
}
|
package/build/schema/schema.mjs
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import type { TProperties, TSchema } from '../../type/index.mjs';
|
|
2
2
|
import type { TLocalizedValidationError } from '../../error/index.mjs';
|
|
3
|
-
/**
|
|
4
|
-
* Performs an exhaustive Check on the specified value and reports any errors found.
|
|
5
|
-
* If no errors are found, an empty array is returned. Unlike Check, this function
|
|
6
|
-
* does not terminate at the first occurrence of an error. For best performance, call
|
|
7
|
-
* Check first and call Errors only if Check returns false.
|
|
8
|
-
*/
|
|
3
|
+
/** Returns an array of validation errors for the given value. */
|
|
9
4
|
export declare function Errors<Type extends TSchema>(type: Type, value: unknown): TLocalizedValidationError[];
|
|
10
|
-
/**
|
|
11
|
-
* Performs an exhaustive Check on the specified value and reports any errors found.
|
|
12
|
-
* If no errors are found, an empty array is returned. Unlike Check, this function
|
|
13
|
-
* does not terminate at the first occurrence of an error. For best performance, call
|
|
14
|
-
* Check first and call Errors only if Check returns false.
|
|
15
|
-
*/
|
|
5
|
+
/** Returns an array of validation errors for the given value. */
|
|
16
6
|
export declare function Errors<Context extends TProperties, Type extends TSchema>(context: Context, type: Type, value: unknown): TLocalizedValidationError[];
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import { Arguments } from '../../system/arguments/index.mjs';
|
|
3
|
-
import { Errors as SchemaErrors
|
|
4
|
-
/**
|
|
5
|
-
* Performs an exhaustive Check on the specified value and reports any errors found.
|
|
6
|
-
* If no errors are found, an empty array is returned. Unlike Check, this function
|
|
7
|
-
* does not terminate at the first occurrence of an error. For best performance, call
|
|
8
|
-
* Check first and call Errors only if Check returns false.
|
|
9
|
-
*/
|
|
3
|
+
import { Errors as SchemaErrors } from '../../schema/index.mjs';
|
|
4
|
+
/** Returns an array of validation errors for the given value. */
|
|
10
5
|
export function Errors(...args) {
|
|
11
6
|
const [context, type, value] = Arguments.Match(args, {
|
|
12
7
|
3: (context, type, value) => [context, type, value],
|
package/changes.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depup/typebox",
|
|
3
3
|
"description": "Json Schema Type Builder with Static Type Resolution for TypeScript (with updated dependencies)",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.27-depup.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typebox",
|
|
7
7
|
"depup",
|
|
@@ -94,8 +94,8 @@
|
|
|
94
94
|
"changes": {},
|
|
95
95
|
"depsUpdated": 0,
|
|
96
96
|
"originalPackage": "typebox",
|
|
97
|
-
"originalVersion": "1.3.
|
|
98
|
-
"processedAt": "2026-
|
|
97
|
+
"originalVersion": "1.3.27",
|
|
98
|
+
"processedAt": "2026-09-06T01:04:02.687Z",
|
|
99
99
|
"smokeTest": "passed"
|
|
100
100
|
}
|
|
101
101
|
}
|
package/readme.md
CHANGED
|
@@ -245,13 +245,16 @@ TypeBox supports all major JSON Schema draft versions and tracks compliance agai
|
|
|
245
245
|
| contains | - | - | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
246
246
|
| content | - | - | - | - | ✅ | ✅ | ✅ |
|
|
247
247
|
| default | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
248
|
+
| definitions | - | 1/2 | ✅ | ✅ | - | - | - |
|
|
249
|
+
| defs | - | - | - | - | ✅ | ✅ | - |
|
|
248
250
|
| dependencies | 17/18 | ✅ | ✅ | ✅ | - | - | - |
|
|
249
251
|
| dependentRequired | - | - | - | - | ✅ | ✅ | ✅ |
|
|
250
252
|
| dependentSchemas | - | - | - | - | ✅ | ✅ | ✅ |
|
|
251
|
-
| dynamicRef | - | - | - | - | - |
|
|
252
|
-
| enum |
|
|
253
|
+
| dynamicRef | - | - | - | - | - | ✅ | ✅ |
|
|
254
|
+
| enum | 16/18 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
253
255
|
| exclusiveMaximum | - | - | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
254
256
|
| exclusiveMinimum | - | - | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
257
|
+
| format | ✅ | ✅ | ✅ | ✅ | ✅ | 114/133 | - |
|
|
255
258
|
| if-then-else | - | - | - | ✅ | ✅ | ✅ | ✅ |
|
|
256
259
|
| infinite-loop-detection | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
257
260
|
| items | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
@@ -274,11 +277,12 @@ TypeBox supports all major JSON Schema draft versions and tracks compliance agai
|
|
|
274
277
|
| properties | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
275
278
|
| propertyNames | - | - | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
276
279
|
| recursiveRef | - | - | - | - | ✅ | - | - |
|
|
277
|
-
| ref |
|
|
280
|
+
| ref | 23/27 | 38/45 | 69/70 | 77/78 | ✅ | ✅ | ✅ |
|
|
281
|
+
| refRemote | 7/8 | 11/17 | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
278
282
|
| required | 3/4 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
279
283
|
| type | 73/80 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
280
|
-
| unevaluatedItems | - | - | - | - | ✅ | ✅ |
|
|
281
|
-
| unevaluatedProperties | - | - | - | - | ✅ | ✅ |
|
|
284
|
+
| unevaluatedItems | - | - | - | - | ✅ | ✅ | ✅ |
|
|
285
|
+
| unevaluatedProperties | - | - | - | - | ✅ | ✅ | ✅ |
|
|
282
286
|
| uniqueItems | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
283
287
|
|
|
284
288
|
### Performance
|