@openclaw/slack 2026.8.1-beta.3 → 2026.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account-configured-sUohAxZr.js +33 -0
- package/dist/account-inspect-CN2hBsim.js +87 -0
- package/dist/account-inspect-api.js +1 -1
- package/dist/{accounts-BlzxuYle.js → accounts-Dm_H77gH.js} +7 -10
- package/dist/{accounts.runtime-CbabBL8x.js → accounts.runtime-DRuEK6mL.js} +1 -1
- package/dist/{action-runtime-D6jg2CQd.js → action-runtime-044ldvNL.js} +53 -48
- package/dist/action-runtime.runtime-BL3KzX13.js +2 -0
- package/dist/{actions-DFk0ANVB.js → actions-BI7JkfVm.js} +266 -96
- package/dist/api.js +12 -12
- package/dist/{approval-handler.runtime-BNvAoKdK.js → approval-handler.runtime-DYv0UIZS.js} +53 -176
- package/dist/{channel-CA5w7qDF.js → channel-1vIJOzPx.js} +77 -142
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-type-CZWv55Wu.js → channel-type-DlFSKeIZ.js} +3 -3
- package/dist/{channel.setup-CpyYsEXH.js → channel.setup-ofDi3_Pu.js} +34 -49
- package/dist/{config-schema-CN3XZRX5.js → config-schema-BVIMyiDN.js} +19 -12
- package/dist/configured-state.js +34 -0
- package/dist/{directory-config-BGYyuzWh.js → directory-config-DqfQ42OV.js} +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/{directory-live-DjUJQLbq.js → directory-live-BPaNHjmP.js} +2 -2
- package/dist/{group-policy-DyfB_ZIE.js → group-policy-BdwszjYn.js} +581 -743
- package/dist/{message-tool-api-CqMr5Rmc.js → message-tool-api-CJ0kjcg5.js} +23 -5
- package/dist/message-tool-api.js +1 -1
- package/dist/{monitor-Chrecrb9.js → monitor-Dq5Cmrvp.js} +3 -3
- package/dist/{outbound-adapter-DuRqAQXK.js → outbound-adapter-DYaI8ThX.js} +93 -68
- package/dist/{pipeline.runtime-Bbfd5VFW.js → pipeline.runtime-Bd22U0ga.js} +128 -160
- package/dist/{policy-BKXSxrIS.js → policy-CtQVbde1.js} +2 -1
- package/dist/{probe-BVA65leh.js → probe-0usmAb0i.js} +209 -22
- package/dist/{provider-CUUiwsg2.js → provider-CN_8hFv2.js} +243 -146
- package/dist/{relay-source-mhpMMRG-.js → relay-source-BNGpsdwV.js} +1 -1
- package/dist/{replies-SnWyXcsL.js → replies-BSiRQOJ1.js} +15 -5
- package/dist/{resolve-channels-BSpqC8jU.js → resolve-channels-Czheznc8.js} +1 -1
- package/dist/{resolve-users-Dvz9pDe0.js → resolve-users-BAOlNimr.js} +1 -1
- package/dist/runtime-api.js +11 -11
- package/dist/{scopes-BSk4GZvZ.js → scopes-COSlmhnH.js} +1 -1
- package/dist/{send-CtnOxKCc.js → send-DS9ICrBI.js} +39 -31
- package/dist/send-results-eeOu_HYm.js +23 -0
- package/dist/{send.runtime-kYctMHSd.js → send.runtime-D_Bb6IuH.js} +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-BPFfp6So.js → setup-surface-BGnd2pSe.js} +6 -6
- package/dist/{shared-DJBaslN7.js → shared-D5B-5hBg.js} +26 -6
- package/dist/{slash-dispatch.runtime-Cf2FTrnf.js → slash-dispatch.runtime-CilDmI0c.js} +3 -3
- package/node_modules/@slack/bolt/node_modules/@types/node/README.md +1 -1
- package/node_modules/@slack/bolt/node_modules/@types/node/child_process.d.ts +0 -1
- package/node_modules/@slack/bolt/node_modules/@types/node/crypto.d.ts +6 -6
- package/node_modules/@slack/bolt/node_modules/@types/node/dns/promises.d.ts +5 -5
- package/node_modules/@slack/bolt/node_modules/@types/node/dns.d.ts +5 -5
- package/node_modules/@slack/bolt/node_modules/@types/node/fs.d.ts +7 -0
- package/node_modules/@slack/bolt/node_modules/@types/node/http.d.ts +30 -0
- package/node_modules/@slack/bolt/node_modules/@types/node/http2.d.ts +4 -4
- package/node_modules/@slack/bolt/node_modules/@types/node/os.d.ts +30 -30
- package/node_modules/@slack/bolt/node_modules/@types/node/package.json +2 -2
- package/node_modules/@slack/bolt/node_modules/@types/node/perf_hooks.d.ts +2 -1
- package/node_modules/@slack/bolt/node_modules/@types/node/process.d.ts +42 -43
- package/node_modules/@slack/bolt/node_modules/@types/node/quic.d.ts +1049 -84
- package/node_modules/@slack/bolt/node_modules/@types/node/sqlite.d.ts +14 -1
- package/node_modules/@slack/bolt/node_modules/@types/node/stream/iter.d.ts +3 -2
- package/node_modules/@slack/bolt/node_modules/@types/node/test.d.ts +61 -0
- package/node_modules/@slack/bolt/node_modules/@types/node/v8.d.ts +20 -23
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/README.md +2 -0
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/package.json +1 -1
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/README.md +2 -0
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/package.json +1 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/README.md +1 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/child_process.d.ts +0 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/crypto.d.ts +6 -6
- package/node_modules/@slack/socket-mode/node_modules/@types/node/dns/promises.d.ts +5 -5
- package/node_modules/@slack/socket-mode/node_modules/@types/node/dns.d.ts +5 -5
- package/node_modules/@slack/socket-mode/node_modules/@types/node/fs.d.ts +7 -0
- package/node_modules/@slack/socket-mode/node_modules/@types/node/http.d.ts +30 -0
- package/node_modules/@slack/socket-mode/node_modules/@types/node/http2.d.ts +4 -4
- package/node_modules/@slack/socket-mode/node_modules/@types/node/os.d.ts +30 -30
- package/node_modules/@slack/socket-mode/node_modules/@types/node/package.json +2 -2
- package/node_modules/@slack/socket-mode/node_modules/@types/node/perf_hooks.d.ts +2 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/process.d.ts +42 -43
- package/node_modules/@slack/socket-mode/node_modules/@types/node/quic.d.ts +1049 -84
- package/node_modules/@slack/socket-mode/node_modules/@types/node/sqlite.d.ts +14 -1
- package/node_modules/@slack/socket-mode/node_modules/@types/node/stream/iter.d.ts +3 -2
- package/node_modules/@slack/socket-mode/node_modules/@types/node/test.d.ts +61 -0
- package/node_modules/@slack/socket-mode/node_modules/@types/node/v8.d.ts +20 -23
- package/node_modules/@slack/web-api/node_modules/@types/node/README.md +1 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/child_process.d.ts +0 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/crypto.d.ts +6 -6
- package/node_modules/@slack/web-api/node_modules/@types/node/dns/promises.d.ts +5 -5
- package/node_modules/@slack/web-api/node_modules/@types/node/dns.d.ts +5 -5
- package/node_modules/@slack/web-api/node_modules/@types/node/fs.d.ts +7 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/http.d.ts +30 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/http2.d.ts +4 -4
- package/node_modules/@slack/web-api/node_modules/@types/node/os.d.ts +30 -30
- package/node_modules/@slack/web-api/node_modules/@types/node/package.json +2 -2
- package/node_modules/@slack/web-api/node_modules/@types/node/perf_hooks.d.ts +2 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/process.d.ts +42 -43
- package/node_modules/@slack/web-api/node_modules/@types/node/quic.d.ts +1049 -84
- package/node_modules/@slack/web-api/node_modules/@types/node/sqlite.d.ts +14 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/stream/iter.d.ts +3 -2
- package/node_modules/@slack/web-api/node_modules/@types/node/test.d.ts +61 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/v8.d.ts +20 -23
- package/node_modules/typebox/build/format/date.d.mts +1 -1
- package/node_modules/typebox/build/format/date.mjs +1 -1
- package/node_modules/typebox/build/format/date_time.d.mts +2 -2
- package/node_modules/typebox/build/format/date_time.mjs +3 -3
- package/node_modules/typebox/build/format/email.d.mts +1 -1
- package/node_modules/typebox/build/format/email.mjs +2 -2
- package/node_modules/typebox/build/format/hostname.mjs +2 -10
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_email.mjs +3 -3
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
- package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
- package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
- package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
- package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
- package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
- package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +23 -0
- package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
- package/node_modules/typebox/build/format/idna/index.mjs +2 -0
- package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
- package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
- package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
- package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
- package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
- package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
- package/node_modules/typebox/build/format/ipv4.mjs +2 -32
- package/node_modules/typebox/build/format/ipv6.mjs +2 -61
- package/node_modules/typebox/build/format/iri.d.mts +2 -2
- package/node_modules/typebox/build/format/iri.mjs +26 -8
- package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
- package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
- package/node_modules/typebox/build/format/regex.d.mts +1 -2
- package/node_modules/typebox/build/format/regex.mjs +2 -6
- package/node_modules/typebox/build/format/time.d.mts +2 -2
- package/node_modules/typebox/build/format/time.mjs +19 -14
- package/node_modules/typebox/build/format/uri.d.mts +1 -1
- package/node_modules/typebox/build/format/uri.mjs +3 -130
- package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
- package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
- package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
- package/node_modules/typebox/build/format/uri_template.mjs +4 -5
- package/node_modules/typebox/build/format/url.d.mts +3 -3
- package/node_modules/typebox/build/format/url.mjs +4 -5
- package/node_modules/typebox/build/guard/emit.d.mts +3 -1
- package/node_modules/typebox/build/guard/emit.mjs +12 -5
- package/node_modules/typebox/build/guard/guard.d.mts +8 -2
- package/node_modules/typebox/build/guard/guard.mjs +25 -4
- package/node_modules/typebox/build/guard/string.d.mts +2 -2
- package/node_modules/typebox/build/guard/string.mjs +7 -7
- package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
- package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
- package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
- package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
- package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
- package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
- package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
- package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
- package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
- package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
- package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
- package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
- package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
- package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
- package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
- package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
- package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
- package/node_modules/typebox/build/schema/types/index.mjs +0 -2
- package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
- package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
- package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
- package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
- package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
- package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
- package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
- package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
- package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
- package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
- package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
- package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
- package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
- package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
- package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
- package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
- package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
- package/node_modules/typebox/build/type/script/parser.mjs +27 -23
- package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
- package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
- package/node_modules/typebox/package.json +27 -27
- package/node_modules/typebox/readme.md +79 -82
- package/node_modules/ws/lib/permessage-deflate.js +3 -1
- package/node_modules/ws/package.json +1 -1
- package/openclaw.plugin.json +14 -6
- package/package.json +9 -7
- package/dist/account-configured-BwfXBo_F.js +0 -14
- package/dist/account-inspect-YJvFBbCR.js +0 -89
- package/dist/action-runtime.runtime-JtoOK9l5.js +0 -2
- package/dist/actions.runtime-CYLsYRai.js +0 -2
- package/dist/runtime-api-DBi7xc_g.js +0 -10
- package/dist/slack-client-kind-BXyOOICI.js +0 -94
- package/node_modules/typebox/build/format/_idna.d.mts +0 -2
- package/node_modules/typebox/build/format/_idna.mjs +0 -246
- package/node_modules/typebox/build/format/_puny.d.mts +0 -1
- package/node_modules/typebox/build/format/_puny.mjs +0 -77
- package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
- package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
- package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
- package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
- package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
- package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
|
@@ -12,13 +12,24 @@ function IsValid(schema) {
|
|
|
12
12
|
// ------------------------------------------------------------------
|
|
13
13
|
// Build
|
|
14
14
|
// ------------------------------------------------------------------
|
|
15
|
+
function BuildContainsStandard(stack, context, schema, value) {
|
|
16
|
+
const [item, index] = [Unique(), Unique()];
|
|
17
|
+
const isLength = E.Not(E.IsEqual(E.Member(value, 'length'), E.Constant(0)));
|
|
18
|
+
const isSome = E.SomeAll(value, [item, index], E.And(BuildSchema(stack, context, schema.contains, item), context.AddIndex(index)));
|
|
19
|
+
return E.And(isLength, isSome);
|
|
20
|
+
}
|
|
21
|
+
function BuildContainsFast(stack, context, schema, value) {
|
|
22
|
+
const [item] = [Unique()];
|
|
23
|
+
const isLength = E.Not(E.IsEqual(E.Member(value, 'length'), E.Constant(0)));
|
|
24
|
+
const isSome = E.Some(value, [item, '_'], BuildSchema(stack, context, schema.contains, item));
|
|
25
|
+
return E.And(isLength, isSome);
|
|
26
|
+
}
|
|
15
27
|
export function BuildContains(stack, context, schema, value) {
|
|
16
28
|
if (!IsValid(schema))
|
|
17
29
|
return E.Constant(true);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return E.And(isLength, isSome);
|
|
30
|
+
return context.UseUnevaluated()
|
|
31
|
+
? BuildContainsStandard(stack, context, schema, value)
|
|
32
|
+
: BuildContainsFast(stack, context, schema, value);
|
|
22
33
|
}
|
|
23
34
|
// ------------------------------------------------------------------
|
|
24
35
|
// Check
|
|
@@ -26,8 +37,9 @@ export function BuildContains(stack, context, schema, value) {
|
|
|
26
37
|
export function CheckContains(stack, context, schema, value) {
|
|
27
38
|
if (!IsValid(schema))
|
|
28
39
|
return true;
|
|
29
|
-
return !G.IsEqual(value.length, 0) &&
|
|
30
|
-
|
|
40
|
+
return !G.IsEqual(value.length, 0) && G.SomeAll(value, (item, index) => {
|
|
41
|
+
return CheckSchema(stack, context, schema.contains, item) && context.AddIndex(index);
|
|
42
|
+
});
|
|
31
43
|
}
|
|
32
44
|
// ------------------------------------------------------------------
|
|
33
45
|
// Error
|
|
@@ -16,7 +16,7 @@ export function BuildEnum(_stack, _context, schema, value) {
|
|
|
16
16
|
// Check
|
|
17
17
|
// ------------------------------------------------------------------
|
|
18
18
|
export function CheckEnum(_stack, _context, schema, value) {
|
|
19
|
-
return schema.enum
|
|
19
|
+
return G.Some(schema.enum, option => G.IsValueLike(option)
|
|
20
20
|
? G.IsEqual(value, option)
|
|
21
21
|
: G.IsDeepEqual(value, option));
|
|
22
22
|
}
|
|
@@ -5,15 +5,26 @@ import { BuildSchemaPushStack, CheckSchemaPushStack, ErrorSchemaPushStack } from
|
|
|
5
5
|
// ------------------------------------------------------------------
|
|
6
6
|
// ItemsSized
|
|
7
7
|
// ------------------------------------------------------------------
|
|
8
|
-
function
|
|
8
|
+
function BuildItemsSizedStandard(stack, context, schema, value) {
|
|
9
9
|
return E.ReduceAnd(schema.items.map((schema, index) => {
|
|
10
10
|
const isLength = E.IsLessEqualThan(E.Member(value, 'length'), E.Constant(index));
|
|
11
11
|
const isSchema = BuildSchemaPushStack(stack, context, schema, `${value}[${index}]`);
|
|
12
12
|
const addIndex = context.AddIndex(E.Constant(index));
|
|
13
|
-
|
|
14
|
-
return E.Or(isLength, guarded);
|
|
13
|
+
return E.Or(isLength, E.And(isSchema, addIndex));
|
|
15
14
|
}));
|
|
16
15
|
}
|
|
16
|
+
function BuildItemsSizedFast(stack, context, schema, value) {
|
|
17
|
+
return E.ReduceAnd(schema.items.map((schema, index) => {
|
|
18
|
+
const isLength = E.IsLessEqualThan(E.Member(value, 'length'), E.Constant(index));
|
|
19
|
+
const isSchema = BuildSchemaPushStack(stack, context, schema, `${value}[${index}]`);
|
|
20
|
+
return E.Or(isLength, isSchema);
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
function BuildItemsSized(stack, context, schema, value) {
|
|
24
|
+
return context.UseUnevaluated()
|
|
25
|
+
? BuildItemsSizedStandard(stack, context, schema, value)
|
|
26
|
+
: BuildItemsSizedFast(stack, context, schema, value);
|
|
27
|
+
}
|
|
17
28
|
function CheckItemsSized(stack, context, schema, value) {
|
|
18
29
|
return G.Every(schema.items, 0, (schema, index) => {
|
|
19
30
|
return G.IsLessEqualThan(value.length, index)
|
|
@@ -31,12 +42,21 @@ function ErrorItemsSized(stack, context, schemaPath, instancePath, schema, value
|
|
|
31
42
|
// ------------------------------------------------------------------
|
|
32
43
|
// ItemsUnsized
|
|
33
44
|
// ------------------------------------------------------------------
|
|
34
|
-
function
|
|
45
|
+
function BuildItemsUnsizedStandard(stack, context, schema, value) {
|
|
35
46
|
const offset = Schema.IsPrefixItems(schema) ? schema.prefixItems.length : 0;
|
|
36
47
|
const isSchema = BuildSchemaPushStack(stack, context, schema.items, 'element');
|
|
37
48
|
const addIndex = context.AddIndex('index');
|
|
38
|
-
|
|
39
|
-
|
|
49
|
+
return E.Every(value, E.Constant(offset), ['element', 'index'], E.And(isSchema, addIndex));
|
|
50
|
+
}
|
|
51
|
+
function BuildItemsUnsizedFast(stack, context, schema, value) {
|
|
52
|
+
const offset = Schema.IsPrefixItems(schema) ? schema.prefixItems.length : 0;
|
|
53
|
+
const isSchema = BuildSchemaPushStack(stack, context, schema.items, 'element');
|
|
54
|
+
return E.Every(value, E.Constant(offset), ['element', 'index'], isSchema);
|
|
55
|
+
}
|
|
56
|
+
function BuildItemsUnsized(stack, context, schema, value) {
|
|
57
|
+
return context.UseUnevaluated()
|
|
58
|
+
? BuildItemsUnsizedStandard(stack, context, schema, value)
|
|
59
|
+
: BuildItemsUnsizedFast(stack, context, schema, value);
|
|
40
60
|
}
|
|
41
61
|
function CheckItemsUnsized(stack, context, schema, value) {
|
|
42
62
|
const offset = Schema.IsPrefixItems(schema) ? schema.prefixItems.length : 0;
|
|
@@ -15,8 +15,8 @@ function IsValid(schema) {
|
|
|
15
15
|
export function BuildMaxContains(stack, context, schema, value) {
|
|
16
16
|
if (!IsValid(schema))
|
|
17
17
|
return E.Constant(true);
|
|
18
|
-
const [
|
|
19
|
-
const count = E.
|
|
18
|
+
const [item] = [Unique()];
|
|
19
|
+
const count = E.Counted(value, [item, '_'], BuildSchema(stack, context, schema.contains, item));
|
|
20
20
|
return E.IsLessEqualThan(count, E.Constant(schema.maxContains));
|
|
21
21
|
}
|
|
22
22
|
// ------------------------------------------------------------------
|
|
@@ -25,7 +25,7 @@ export function BuildMaxContains(stack, context, schema, value) {
|
|
|
25
25
|
export function CheckMaxContains(stack, context, schema, value) {
|
|
26
26
|
if (!IsValid(schema))
|
|
27
27
|
return true;
|
|
28
|
-
const count =
|
|
28
|
+
const count = G.Counted(value, (item) => CheckSchema(stack, context, schema.contains, item));
|
|
29
29
|
return G.IsLessEqualThan(count, schema.maxContains);
|
|
30
30
|
}
|
|
31
31
|
// ------------------------------------------------------------------
|
|
@@ -12,12 +12,22 @@ function IsValid(schema) {
|
|
|
12
12
|
// ------------------------------------------------------------------
|
|
13
13
|
// Build
|
|
14
14
|
// ------------------------------------------------------------------
|
|
15
|
+
function BuildMinContainsStandard(stack, context, schema, value) {
|
|
16
|
+
const [item, index] = [Unique(), Unique()];
|
|
17
|
+
const count = E.Counted(value, [item, index], E.And(BuildSchema(stack, context, schema.contains, item), context.AddIndex(index)));
|
|
18
|
+
return E.IsGreaterEqualThan(count, E.Constant(schema.minContains));
|
|
19
|
+
}
|
|
20
|
+
function BuildMinContainsFast(stack, context, schema, value) {
|
|
21
|
+
const [item] = [Unique()];
|
|
22
|
+
const count = E.Counted(value, [item, '_'], BuildSchema(stack, context, schema.contains, item));
|
|
23
|
+
return E.IsGreaterEqualThan(count, E.Constant(schema.minContains));
|
|
24
|
+
}
|
|
15
25
|
export function BuildMinContains(stack, context, schema, value) {
|
|
16
26
|
if (!IsValid(schema))
|
|
17
27
|
return E.Constant(true);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
28
|
+
return context.UseUnevaluated()
|
|
29
|
+
? BuildMinContainsStandard(stack, context, schema, value)
|
|
30
|
+
: BuildMinContainsFast(stack, context, schema, value);
|
|
21
31
|
}
|
|
22
32
|
// ------------------------------------------------------------------
|
|
23
33
|
// Check
|
|
@@ -25,7 +35,7 @@ export function BuildMinContains(stack, context, schema, value) {
|
|
|
25
35
|
export function CheckMinContains(stack, context, schema, value) {
|
|
26
36
|
if (!IsValid(schema))
|
|
27
37
|
return true;
|
|
28
|
-
const count =
|
|
38
|
+
const count = G.Counted(value, (item, index) => CheckSchema(stack, context, schema.contains, item) && context.AddIndex(index));
|
|
29
39
|
return G.IsGreaterEqualThan(count, schema.minContains);
|
|
30
40
|
}
|
|
31
41
|
// ------------------------------------------------------------------
|
|
@@ -6,14 +6,16 @@ import { BuildSchema, CheckSchema } from './schema.mjs';
|
|
|
6
6
|
// ------------------------------------------------------------------
|
|
7
7
|
// Build
|
|
8
8
|
// ------------------------------------------------------------------
|
|
9
|
-
function
|
|
9
|
+
function BuildNotStandard(stack, context, schema, value) {
|
|
10
10
|
return Reducer(stack, context, [schema.not], value, E.Not(E.IsEqual(E.Member('results', 'length'), E.Constant(1))));
|
|
11
11
|
}
|
|
12
12
|
function BuildNotFast(stack, context, schema, value) {
|
|
13
13
|
return E.Not(BuildSchema(stack, context, schema.not, value));
|
|
14
14
|
}
|
|
15
15
|
export function BuildNot(stack, context, schema, value) {
|
|
16
|
-
return context.UseUnevaluated()
|
|
16
|
+
return context.UseUnevaluated()
|
|
17
|
+
? BuildNotStandard(stack, context, schema, value)
|
|
18
|
+
: BuildNotFast(stack, context, schema, value);
|
|
17
19
|
}
|
|
18
20
|
// ------------------------------------------------------------------
|
|
19
21
|
// Check
|
|
@@ -3,22 +3,23 @@ import { CheckContext, AccumulatedErrorContext } from './_context.mjs';
|
|
|
3
3
|
import { Reducer } from './_reducer.mjs';
|
|
4
4
|
import { EmitGuard as E, Guard as G } from '../../guard/index.mjs';
|
|
5
5
|
import { BuildSchema, CheckSchema, ErrorSchema } from './schema.mjs';
|
|
6
|
+
import { Unique } from './_unique.mjs';
|
|
6
7
|
// ------------------------------------------------------------------
|
|
7
8
|
// Build
|
|
8
9
|
// ------------------------------------------------------------------
|
|
9
|
-
function
|
|
10
|
+
function BuildOneOfStandard(stack, context, schema, value) {
|
|
10
11
|
return Reducer(stack, context, schema.oneOf, value, E.IsEqual(E.Member('results', 'length'), E.Constant(1)));
|
|
11
12
|
}
|
|
12
13
|
function BuildOneOfFast(stack, context, schema, value) {
|
|
14
|
+
const [result] = [Unique()];
|
|
13
15
|
const results = E.ArrayLiteral(schema.oneOf.map((schema) => BuildSchema(stack, context, schema, value)));
|
|
14
|
-
const count = E.
|
|
15
|
-
E.ArrowFunction(['count', 'result'], E.Ternary(E.IsEqual('result', E.Constant(true)), E.PrefixIncrement('count'), 'count')),
|
|
16
|
-
E.Constant(0),
|
|
17
|
-
]);
|
|
16
|
+
const count = E.Counted(results, [result, '_'], E.IsEqual(result, E.Constant(true)));
|
|
18
17
|
return E.IsEqual(count, E.Constant(1));
|
|
19
18
|
}
|
|
20
19
|
export function BuildOneOf(stack, context, schema, value) {
|
|
21
|
-
return context.UseUnevaluated()
|
|
20
|
+
return context.UseUnevaluated()
|
|
21
|
+
? BuildOneOfStandard(stack, context, schema, value)
|
|
22
|
+
: BuildOneOfFast(stack, context, schema, value);
|
|
22
23
|
}
|
|
23
24
|
// ------------------------------------------------------------------
|
|
24
25
|
// Check
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import * as Externals from './_externals.mjs';
|
|
3
3
|
import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
|
|
4
|
+
import { UnicodeRegExp } from './_regexp.mjs';
|
|
4
5
|
// ------------------------------------------------------------------
|
|
5
6
|
// Build
|
|
6
7
|
// ------------------------------------------------------------------
|
|
7
8
|
export function BuildPattern(_stack, _context, schema, value) {
|
|
8
|
-
const regexp = Externals.CreateVariable(G.IsString(schema.pattern) ?
|
|
9
|
+
const regexp = Externals.CreateVariable(G.IsString(schema.pattern) ? UnicodeRegExp(schema.pattern) : schema.pattern);
|
|
9
10
|
return E.Call(E.Member(regexp, 'test'), [value]);
|
|
10
11
|
}
|
|
11
12
|
// ------------------------------------------------------------------
|
|
12
13
|
// Check
|
|
13
14
|
// ------------------------------------------------------------------
|
|
14
15
|
export function CheckPattern(_stack, _context, schema, value) {
|
|
15
|
-
const regexp = G.IsString(schema.pattern) ?
|
|
16
|
+
const regexp = G.IsString(schema.pattern) ? UnicodeRegExp(schema.pattern) : schema.pattern;
|
|
16
17
|
return regexp.test(value);
|
|
17
18
|
}
|
|
18
19
|
// ------------------------------------------------------------------
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
import * as Externals from './_externals.mjs';
|
|
3
3
|
import { Unique } from './_unique.mjs';
|
|
4
|
+
import { UnicodeRegExp } from './_regexp.mjs';
|
|
4
5
|
import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
|
|
5
6
|
import { BuildSchemaPushStack, CheckSchemaPushStack, ErrorSchemaPushStack } from './schema.mjs';
|
|
6
7
|
// ------------------------------------------------------------------
|
|
@@ -9,7 +10,7 @@ import { BuildSchemaPushStack, CheckSchemaPushStack, ErrorSchemaPushStack } from
|
|
|
9
10
|
export function BuildPatternProperties(stack, context, schema, value) {
|
|
10
11
|
return E.ReduceAnd(G.Entries(schema.patternProperties).map(([pattern, schema]) => {
|
|
11
12
|
const [key, prop] = [Unique(), Unique()];
|
|
12
|
-
const regexp = Externals.CreateVariable(
|
|
13
|
+
const regexp = Externals.CreateVariable(UnicodeRegExp(pattern));
|
|
13
14
|
const notKey = E.Not(E.Call(E.Member(regexp, 'test'), [key]));
|
|
14
15
|
const isSchema = BuildSchemaPushStack(stack, context, schema, prop);
|
|
15
16
|
const addKey = context.AddKey(key);
|
|
@@ -22,7 +23,7 @@ export function BuildPatternProperties(stack, context, schema, value) {
|
|
|
22
23
|
// ------------------------------------------------------------------
|
|
23
24
|
export function CheckPatternProperties(stack, context, schema, value) {
|
|
24
25
|
return G.Every(G.Entries(schema.patternProperties), 0, ([pattern, schema]) => {
|
|
25
|
-
const regexp =
|
|
26
|
+
const regexp = UnicodeRegExp(pattern);
|
|
26
27
|
return G.Every(G.Entries(value), 0, ([key, prop]) => {
|
|
27
28
|
return !regexp.test(key) || CheckSchemaPushStack(stack, context, schema, prop) && context.AddKey(key);
|
|
28
29
|
});
|
|
@@ -34,7 +35,7 @@ export function CheckPatternProperties(stack, context, schema, value) {
|
|
|
34
35
|
export function ErrorPatternProperties(stack, context, schemaPath, instancePath, schema, value) {
|
|
35
36
|
return G.EveryAll(G.Entries(schema.patternProperties), 0, ([pattern, schema]) => {
|
|
36
37
|
const nextSchemaPath = `${schemaPath}/patternProperties/${pattern}`;
|
|
37
|
-
const regexp =
|
|
38
|
+
const regexp = UnicodeRegExp(pattern);
|
|
38
39
|
return G.EveryAll(G.Entries(value), 0, ([key, value]) => {
|
|
39
40
|
const nextInstancePath = `${instancePath}/${key}`;
|
|
40
41
|
const notKey = !regexp.test(key);
|
|
@@ -5,7 +5,7 @@ import { CheckContext, AccumulatedErrorContext } from './_context.mjs';
|
|
|
5
5
|
import { EmitGuard as E } from '../../guard/index.mjs';
|
|
6
6
|
import { CheckSchema, ErrorSchema } from './schema.mjs';
|
|
7
7
|
// ------------------------------------------------------------------
|
|
8
|
-
//
|
|
8
|
+
// BuildRef
|
|
9
9
|
// ------------------------------------------------------------------
|
|
10
10
|
function BuildRefStandard(stack, context, target, value) {
|
|
11
11
|
const interior = E.ArrowFunction(['context', 'value'], Functions.CreateFunction(stack, context, target, 'value'));
|
|
@@ -17,15 +17,9 @@ function BuildRefStandard(stack, context, target, value) {
|
|
|
17
17
|
]));
|
|
18
18
|
return E.Call(exterior, ['context', value]);
|
|
19
19
|
}
|
|
20
|
-
// ------------------------------------------------------------------
|
|
21
|
-
// BuildRefStandard
|
|
22
|
-
// ------------------------------------------------------------------
|
|
23
20
|
function BuildRefFast(stack, context, target, value) {
|
|
24
21
|
return Functions.CreateFunction(stack, context, target, value);
|
|
25
22
|
}
|
|
26
|
-
// ------------------------------------------------------------------
|
|
27
|
-
// BuildRef
|
|
28
|
-
// ------------------------------------------------------------------
|
|
29
23
|
export function BuildRef(stack, context, schema, value) {
|
|
30
24
|
const target = stack.Ref(schema) ?? false;
|
|
31
25
|
return context.UseUnevaluated()
|
|
@@ -45,12 +45,21 @@ import { BuildUnevaluatedItems, CheckUnevaluatedItems, ErrorUnevaluatedItems } f
|
|
|
45
45
|
import { BuildUnevaluatedProperties, CheckUnevaluatedProperties, ErrorUnevaluatedProperties } from './unevaluatedProperties.mjs';
|
|
46
46
|
import { BuildUniqueItems, CheckUniqueItems, ErrorUniqueItems } from './uniqueItems.mjs';
|
|
47
47
|
// ----------------------------------------------------------------
|
|
48
|
-
// HasTypeName
|
|
48
|
+
// HasTypeName (Optimization)
|
|
49
|
+
//
|
|
50
|
+
// We only consider a schema as having a type name when the schema
|
|
51
|
+
// has a single type string, or when every element in the type
|
|
52
|
+
// array is the same. For a type array, we must treat multi-variant
|
|
53
|
+
// types as unions and therefore can NOT use an optimized forward
|
|
54
|
+
// type check.
|
|
55
|
+
//
|
|
49
56
|
// ----------------------------------------------------------------
|
|
50
57
|
function HasTypeName(schema, typename) {
|
|
51
|
-
return Schema.IsType(schema) &&
|
|
52
|
-
(G.IsArray(schema.type) &&
|
|
53
|
-
G.
|
|
58
|
+
return (Schema.IsType(schema) &&
|
|
59
|
+
((G.IsArray(schema.type) &&
|
|
60
|
+
G.IsGreaterThan(schema.type.length, 0) &&
|
|
61
|
+
G.Every(schema.type, 0, type => G.IsEqual(type, typename))) ||
|
|
62
|
+
G.IsEqual(schema.type, typename)));
|
|
54
63
|
}
|
|
55
64
|
// ----------------------------------------------------------------
|
|
56
65
|
// HasObject
|
|
@@ -48,7 +48,7 @@ function BuildTypeNames(stack, context, typenames, value) {
|
|
|
48
48
|
return E.ReduceOr(typenames.map(type => BuildTypeName(stack, context, type, value)));
|
|
49
49
|
}
|
|
50
50
|
function CheckTypeNames(stack, context, types, schema, value) {
|
|
51
|
-
return
|
|
51
|
+
return G.Some(types, type => CheckTypeName(stack, context, type, schema, value));
|
|
52
52
|
}
|
|
53
53
|
// ------------------------------------------------------------------
|
|
54
54
|
// Type
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import * as Schema from '../types/index.mjs';
|
|
2
|
+
export declare const DefaultBase: URL;
|
|
3
|
+
export declare function Ref(context: Record<string, Schema.XSchema>, schema: Schema.XSchemaObject, ref: string): Schema.XSchema | undefined;
|
|
4
|
+
export declare function DynamicRef(context: Record<string, Schema.XSchema>, root: Schema.XSchemaObject, base: Schema.XSchemaObject, dynamicRef: Schema.XDynamicRef, dynamicAnchors: Schema.XDynamicAnchor[]): Schema.XSchema | undefined;
|
|
@@ -1 +1,202 @@
|
|
|
1
|
-
|
|
1
|
+
// deno-fmt-ignore-file
|
|
2
|
+
import { Guard } from '../../guard/index.mjs';
|
|
3
|
+
import { Pointer } from '../pointer/index.mjs';
|
|
4
|
+
import * as Schema from '../types/index.mjs';
|
|
5
|
+
// ------------------------------------------------------------------
|
|
6
|
+
// DefaultBase
|
|
7
|
+
// ------------------------------------------------------------------
|
|
8
|
+
export const DefaultBase = new URL('https://json-schema.org');
|
|
9
|
+
// ------------------------------------------------------------------
|
|
10
|
+
// Match: Id
|
|
11
|
+
// ------------------------------------------------------------------
|
|
12
|
+
function MatchId(schema, base, ref) {
|
|
13
|
+
if (schema.$id === ref.hash)
|
|
14
|
+
return schema;
|
|
15
|
+
const absoluteId = new URL(schema.$id, base.href);
|
|
16
|
+
const absoluteRef = new URL(ref.href, base.href);
|
|
17
|
+
if (Guard.IsEqual(absoluteId.pathname, absoluteRef.pathname)) {
|
|
18
|
+
return ref.hash.startsWith('#') ? MatchHash(schema, base, ref) : schema;
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
// ------------------------------------------------------------------
|
|
23
|
+
// Match: Anchor
|
|
24
|
+
// ------------------------------------------------------------------
|
|
25
|
+
function MatchAnchor(schema, base, ref) {
|
|
26
|
+
const absoluteAnchor = new URL(`#${schema.$anchor}`, base.href);
|
|
27
|
+
const absoluteRef = new URL(ref.href, base.href);
|
|
28
|
+
return Guard.IsEqual(absoluteAnchor.href, absoluteRef.href) ? schema : undefined;
|
|
29
|
+
}
|
|
30
|
+
// ------------------------------------------------------------------
|
|
31
|
+
// Match: DynamicAnchor
|
|
32
|
+
// ------------------------------------------------------------------
|
|
33
|
+
function MatchDynamicAnchor(schema, base, ref) {
|
|
34
|
+
const absoluteAnchor = new URL(`#${schema.$dynamicAnchor}`, base.href);
|
|
35
|
+
const absoluteRef = new URL(ref.href, base.href);
|
|
36
|
+
return Guard.IsEqual(absoluteAnchor.href, absoluteRef.href) ? schema : undefined;
|
|
37
|
+
}
|
|
38
|
+
// ------------------------------------------------------------------
|
|
39
|
+
// Match: Hash
|
|
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
|
+
//
|
|
46
|
+
// ------------------------------------------------------------------
|
|
47
|
+
function MatchHash(schema, _base, ref) {
|
|
48
|
+
if (ref.href.endsWith('#'))
|
|
49
|
+
return schema;
|
|
50
|
+
if (!ref.hash.startsWith('#'))
|
|
51
|
+
return undefined;
|
|
52
|
+
const fragment = decodeURIComponent(ref.hash.slice(1));
|
|
53
|
+
if (!fragment.startsWith('/'))
|
|
54
|
+
return undefined;
|
|
55
|
+
return Pointer.Get(schema, fragment);
|
|
56
|
+
}
|
|
57
|
+
// ------------------------------------------------------------------
|
|
58
|
+
// Match
|
|
59
|
+
// ------------------------------------------------------------------
|
|
60
|
+
function Match(schema, base, ref) {
|
|
61
|
+
if (Schema.IsId(schema)) {
|
|
62
|
+
const result = MatchId(schema, base, ref);
|
|
63
|
+
if (!Guard.IsUndefined(result))
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
if (Schema.IsAnchor(schema)) {
|
|
67
|
+
const result = MatchAnchor(schema, base, ref);
|
|
68
|
+
if (!Guard.IsUndefined(result))
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
if (Schema.IsDynamicAnchor(schema)) {
|
|
72
|
+
const result = MatchDynamicAnchor(schema, base, ref);
|
|
73
|
+
if (!Guard.IsUndefined(result))
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
return MatchHash(schema, base, ref);
|
|
77
|
+
}
|
|
78
|
+
// ------------------------------------------------------------------
|
|
79
|
+
// FromArray
|
|
80
|
+
// ------------------------------------------------------------------
|
|
81
|
+
function FromArray(schema, base, ref) {
|
|
82
|
+
return schema.reduce((result, item) => {
|
|
83
|
+
const match = FromValue(item, base, ref);
|
|
84
|
+
return !Guard.IsUndefined(match) ? match : result;
|
|
85
|
+
}, undefined);
|
|
86
|
+
}
|
|
87
|
+
// ------------------------------------------------------------------
|
|
88
|
+
// FromObject
|
|
89
|
+
// ------------------------------------------------------------------
|
|
90
|
+
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
|
+
return Guard.IsEqual(key, 'const') || Guard.IsEqual(key, 'enum');
|
|
94
|
+
}
|
|
95
|
+
function FromObject(schema, base, ref) {
|
|
96
|
+
return Guard.Keys(schema).reduce((result, key) => {
|
|
97
|
+
if (SkipProperty(key))
|
|
98
|
+
return result;
|
|
99
|
+
const match = FromValue(schema[key], base, ref);
|
|
100
|
+
return !Guard.IsUndefined(match) ? match : result;
|
|
101
|
+
}, undefined);
|
|
102
|
+
}
|
|
103
|
+
// ------------------------------------------------------------------
|
|
104
|
+
// FromValue
|
|
105
|
+
// ------------------------------------------------------------------
|
|
106
|
+
function FromValue(schema, base, ref) {
|
|
107
|
+
const nextBase = Schema.IsSchemaObject(schema) && Schema.IsId(schema)
|
|
108
|
+
? new URL(schema.$id, base.href)
|
|
109
|
+
: base;
|
|
110
|
+
if (Schema.IsSchemaObject(schema)) {
|
|
111
|
+
const result = Match(schema, nextBase, ref);
|
|
112
|
+
if (!Guard.IsUndefined(result))
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
if (Guard.IsArray(schema))
|
|
116
|
+
return FromArray(schema, nextBase, ref);
|
|
117
|
+
if (Guard.IsObject(schema))
|
|
118
|
+
return FromObject(schema, nextBase, ref);
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
// ------------------------------------------------------------------
|
|
122
|
+
// 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
|
+
// ------------------------------------------------------------------
|
|
128
|
+
function CanonicalHref(url) {
|
|
129
|
+
return url.href.split('#')[0];
|
|
130
|
+
}
|
|
131
|
+
// ------------------------------------------------------------------
|
|
132
|
+
// RefContext: Phase 1
|
|
133
|
+
//
|
|
134
|
+
// A ContextRef targets a simple key name in the context and is
|
|
135
|
+
// used for fast resolution of inline referential TypeBox types.
|
|
136
|
+
// ------------------------------------------------------------------
|
|
137
|
+
function RefContext(context, ref) {
|
|
138
|
+
return Guard.HasPropertyKey(context, ref) ? context[ref] : undefined;
|
|
139
|
+
}
|
|
140
|
+
// ------------------------------------------------------------------
|
|
141
|
+
// RefLocal: Phase 2
|
|
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.
|
|
146
|
+
// ------------------------------------------------------------------
|
|
147
|
+
function RefLocal(schema, base, ref) {
|
|
148
|
+
return FromValue(schema, base, ref);
|
|
149
|
+
}
|
|
150
|
+
// ------------------------------------------------------------------
|
|
151
|
+
// RefRemote: Phase 3
|
|
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.
|
|
156
|
+
// ------------------------------------------------------------------
|
|
157
|
+
function RefRemote(context, base, ref) {
|
|
158
|
+
const targetDocumentHref = CanonicalHref(ref);
|
|
159
|
+
if (Guard.IsEqual(targetDocumentHref, CanonicalHref(base)))
|
|
160
|
+
return undefined;
|
|
161
|
+
if (!Guard.HasPropertyKey(context, targetDocumentHref))
|
|
162
|
+
return undefined;
|
|
163
|
+
const remoteSchema = context[targetDocumentHref];
|
|
164
|
+
const remoteBase = (Schema.IsSchemaObject(remoteSchema) && Schema.IsId(remoteSchema)) ? new URL(remoteSchema.$id, DefaultBase.href) : new URL(targetDocumentHref);
|
|
165
|
+
return FromValue(remoteSchema, remoteBase, ref);
|
|
166
|
+
}
|
|
167
|
+
// ------------------------------------------------------------------
|
|
168
|
+
// Ref
|
|
169
|
+
// ------------------------------------------------------------------
|
|
170
|
+
export function Ref(context, schema, ref) {
|
|
171
|
+
const initialBase = Schema.IsId(schema) ? new URL(schema.$id, DefaultBase.href) : DefaultBase;
|
|
172
|
+
const initialRef = new URL(ref, initialBase.href);
|
|
173
|
+
return RefContext(context, ref) ?? RefLocal(schema, initialBase, initialRef) ?? RefRemote(context, initialBase, initialRef);
|
|
174
|
+
}
|
|
175
|
+
// ------------------------------------------------------------------
|
|
176
|
+
// DynamicRef
|
|
177
|
+
// ------------------------------------------------------------------
|
|
178
|
+
export function DynamicRef(context, root, base, dynamicRef, dynamicAnchors) {
|
|
179
|
+
// Resolve the static target using either the local base (for fragment‑only references)
|
|
180
|
+
// or the document root (for absolute URI references).
|
|
181
|
+
const fragmentTarget = dynamicRef.$dynamicRef.startsWith('#')
|
|
182
|
+
? Ref(context, base, dynamicRef.$dynamicRef)
|
|
183
|
+
: Ref(context, root, dynamicRef.$dynamicRef);
|
|
184
|
+
if (Guard.IsUndefined(fragmentTarget))
|
|
185
|
+
return undefined;
|
|
186
|
+
// Dynamic override only applies if the resolved target itself declares a $dynamicAnchor.
|
|
187
|
+
// If it does not, return the static target unchanged.
|
|
188
|
+
if (!Schema.IsSchemaObject(fragmentTarget) || !Schema.IsDynamicAnchor(fragmentTarget))
|
|
189
|
+
return fragmentTarget;
|
|
190
|
+
// Extract the fragment portion of the reference. According to the test suite,
|
|
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;
|
|
194
|
+
if (fragment.startsWith('#/'))
|
|
195
|
+
return fragmentTarget;
|
|
196
|
+
// Search the live dynamic anchor stack for a schema whose $dynamicAnchor matches the
|
|
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);
|
|
201
|
+
return anchorTarget ?? fragmentTarget;
|
|
202
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { XSchema } from '../types/schema.mjs';
|
|
2
|
+
import type { XStaticSchema } from './schema.mjs';
|
|
3
|
+
export type XStaticPropertyNames<Stack extends string[], Root extends XSchema, Schema extends XSchema, StaticKey extends unknown = XStaticSchema<Stack, Root, Schema>, Result extends Record<string, unknown> = [StaticKey] extends [PropertyKey] ? {
|
|
4
|
+
[Key in StaticKey]?: unknown;
|
|
5
|
+
} : {}> = Result;
|
|
@@ -9,6 +9,7 @@ import type { XOneOf } from '../types/oneOf.mjs';
|
|
|
9
9
|
import type { XPatternProperties } from '../types/patternProperties.mjs';
|
|
10
10
|
import type { XPrefixItems } from '../types/prefixItems.mjs';
|
|
11
11
|
import type { XProperties } from '../types/properties.mjs';
|
|
12
|
+
import type { XPropertyNames } from '../types/propertyNames.mjs';
|
|
12
13
|
import type { XRef } from '../types/ref.mjs';
|
|
13
14
|
import type { XRequired } from '../types/required.mjs';
|
|
14
15
|
import type { XSchema } from '../types/schema.mjs';
|
|
@@ -25,6 +26,7 @@ import type { XStaticOneOf } from './oneOf.mjs';
|
|
|
25
26
|
import type { XStaticPatternProperties } from './patternProperties.mjs';
|
|
26
27
|
import type { XStaticPrefixItems } from './prefixItems.mjs';
|
|
27
28
|
import type { XStaticProperties } from './properties.mjs';
|
|
29
|
+
import type { XStaticPropertyNames } from './propertyNames.mjs';
|
|
28
30
|
import type { XStaticRef } from './ref.mjs';
|
|
29
31
|
import type { XStaticRequired } from './required.mjs';
|
|
30
32
|
import type { XStaticType } from './type.mjs';
|
|
@@ -41,6 +43,7 @@ type XFromKeywords<Stack extends string[], Root extends XSchema, Schema extends
|
|
|
41
43
|
Schema extends XPatternProperties<infer Properties extends Record<PropertyKey, XSchema>> ? XStaticPatternProperties<Stack, Root, Properties> : unknown,
|
|
42
44
|
Schema extends XPrefixItems<infer Types extends XSchema[]> ? XStaticPrefixItems<Stack, Root, Schema, Types> : unknown,
|
|
43
45
|
Schema extends XProperties<infer Properties extends Record<PropertyKey, XSchema>> ? XStaticProperties<Stack, Root, Schema, Properties> : unknown,
|
|
46
|
+
Schema extends XPropertyNames<infer Type extends XSchema> ? XStaticPropertyNames<Stack, Root, Type> : unknown,
|
|
44
47
|
Schema extends XRef<infer Ref extends string> ? XStaticRef<Stack, Root, Ref> : unknown,
|
|
45
48
|
Schema extends XRequired<infer Keys extends string[]> ? XStaticRequired<Stack, Root, Schema, Keys> : unknown,
|
|
46
49
|
Schema extends XType<infer TypeName extends string[] | string> ? XStaticType<TypeName> : unknown,
|
|
@@ -6,8 +6,6 @@ export * from './anchor.mjs';
|
|
|
6
6
|
export * from './anyOf.mjs';
|
|
7
7
|
export * from './const.mjs';
|
|
8
8
|
export * from './contains.mjs';
|
|
9
|
-
export * from './contentEncoding.mjs';
|
|
10
|
-
export * from './contentMediaType.mjs';
|
|
11
9
|
export * from './default.mjs';
|
|
12
10
|
export * from './defs.mjs';
|
|
13
11
|
export * from './dependencies.mjs';
|
|
@@ -12,8 +12,6 @@ export * from './anchor.mjs';
|
|
|
12
12
|
export * from './anyOf.mjs';
|
|
13
13
|
export * from './const.mjs';
|
|
14
14
|
export * from './contains.mjs';
|
|
15
|
-
export * from './contentEncoding.mjs';
|
|
16
|
-
export * from './contentMediaType.mjs';
|
|
17
15
|
export * from './default.mjs';
|
|
18
16
|
export * from './defs.mjs';
|
|
19
17
|
export * from './dependencies.mjs';
|