@openclaw/slack 2026.8.1-beta.2 → 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.
Files changed (246) hide show
  1. package/dist/account-configured-sUohAxZr.js +33 -0
  2. package/dist/account-inspect-CN2hBsim.js +87 -0
  3. package/dist/account-inspect-api.js +1 -1
  4. package/dist/{accounts-CK4AVI2_.js → accounts-Dm_H77gH.js} +12 -11
  5. package/dist/{accounts.runtime-Cb7QwWBz.js → accounts.runtime-DRuEK6mL.js} +1 -1
  6. package/dist/{action-runtime-BkGe7ny_.js → action-runtime-044ldvNL.js} +80 -79
  7. package/dist/action-runtime.runtime-BL3KzX13.js +2 -0
  8. package/dist/{actions-BTDXwwE3.js → actions-BI7JkfVm.js} +273 -263
  9. package/dist/api.js +14 -14
  10. package/dist/{approval-handler.runtime-CJaNzAq2.js → approval-handler.runtime-DYv0UIZS.js} +53 -174
  11. package/dist/{channel-D_tovcUL.js → channel-1vIJOzPx.js} +134 -160
  12. package/dist/channel-config-api.js +1 -1
  13. package/dist/channel-plugin-api.js +1 -1
  14. package/dist/{channel-type-B9MSdoGN.js → channel-type-DlFSKeIZ.js} +3 -7
  15. package/dist/{channel.setup-Bch9dYmA.js → channel.setup-ofDi3_Pu.js} +34 -49
  16. package/dist/{config-schema-xto5jFIx.js → config-schema-BVIMyiDN.js} +42 -19
  17. package/dist/configured-state.js +34 -0
  18. package/dist/conversation-binding-route-DFVLUdYF.js +115 -0
  19. package/dist/{directory-config-CNBz8lJa.js → directory-config-DqfQ42OV.js} +1 -1
  20. package/dist/directory-contract-api.js +1 -1
  21. package/dist/{directory-live-CFKUtW9E.js → directory-live-BPaNHjmP.js} +2 -2
  22. package/dist/{group-policy-c4RP9bjc.js → group-policy-BdwszjYn.js} +625 -773
  23. package/dist/{message-tool-api-BykQB4AU.js → message-tool-api-CJ0kjcg5.js} +23 -5
  24. package/dist/message-tool-api.js +1 -1
  25. package/dist/{monitor-1nF1NtqT.js → monitor-Dq5Cmrvp.js} +3 -3
  26. package/dist/{outbound-adapter-S81tsswN.js → outbound-adapter-DYaI8ThX.js} +101 -66
  27. package/dist/{pipeline.runtime-BvYsM5JO.js → pipeline.runtime-Bd22U0ga.js} +494 -474
  28. package/dist/{policy-TapwbeaT.js → policy-CtQVbde1.js} +2 -1
  29. package/dist/{probe-HoEg_WxB.js → probe-0usmAb0i.js} +209 -22
  30. package/dist/{provider-CDNvBXUi.js → provider-CN_8hFv2.js} +296 -178
  31. package/dist/{relay-source-C9leF11u.js → relay-source-BNGpsdwV.js} +1 -1
  32. package/dist/{replies-CeOfv82I.js → replies-BSiRQOJ1.js} +48 -27
  33. package/dist/{resolve-channels-CNPrxaXY.js → resolve-channels-Czheznc8.js} +1 -1
  34. package/dist/{resolve-users-Dzomuwnr.js → resolve-users-BAOlNimr.js} +1 -1
  35. package/dist/runtime-api.js +11 -11
  36. package/dist/{scopes-cYXKkrRD.js → scopes-COSlmhnH.js} +1 -1
  37. package/dist/security-contract-api.js +1 -1
  38. package/dist/{send-Nor0iBwY.js → send-DS9ICrBI.js} +88 -100
  39. package/dist/send-results-eeOu_HYm.js +23 -0
  40. package/dist/{send.runtime-BmgNe6S9.js → send.runtime-D_Bb6IuH.js} +1 -1
  41. package/dist/setup-plugin-api.js +1 -1
  42. package/dist/{setup-surface-CbX1-Knh.js → setup-surface-BGnd2pSe.js} +6 -6
  43. package/dist/{shared-zdT5AMp-.js → shared-D5B-5hBg.js} +35 -9
  44. package/dist/{slash-dispatch.runtime-Bnr9GR1S.js → slash-dispatch.runtime-CilDmI0c.js} +2 -2
  45. package/node_modules/@slack/bolt/node_modules/@types/node/README.md +1 -1
  46. package/node_modules/@slack/bolt/node_modules/@types/node/child_process.d.ts +0 -1
  47. package/node_modules/@slack/bolt/node_modules/@types/node/crypto.d.ts +6 -6
  48. package/node_modules/@slack/bolt/node_modules/@types/node/dns/promises.d.ts +5 -5
  49. package/node_modules/@slack/bolt/node_modules/@types/node/dns.d.ts +5 -5
  50. package/node_modules/@slack/bolt/node_modules/@types/node/fs.d.ts +7 -0
  51. package/node_modules/@slack/bolt/node_modules/@types/node/http.d.ts +30 -0
  52. package/node_modules/@slack/bolt/node_modules/@types/node/http2.d.ts +4 -4
  53. package/node_modules/@slack/bolt/node_modules/@types/node/os.d.ts +30 -30
  54. package/node_modules/@slack/bolt/node_modules/@types/node/package.json +2 -2
  55. package/node_modules/@slack/bolt/node_modules/@types/node/perf_hooks.d.ts +2 -1
  56. package/node_modules/@slack/bolt/node_modules/@types/node/process.d.ts +42 -43
  57. package/node_modules/@slack/bolt/node_modules/@types/node/quic.d.ts +1049 -84
  58. package/node_modules/@slack/bolt/node_modules/@types/node/sqlite.d.ts +14 -1
  59. package/node_modules/@slack/bolt/node_modules/@types/node/stream/iter.d.ts +3 -2
  60. package/node_modules/@slack/bolt/node_modules/@types/node/test.d.ts +61 -0
  61. package/node_modules/@slack/bolt/node_modules/@types/node/v8.d.ts +20 -23
  62. package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/README.md +2 -0
  63. package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/dist/index.d.ts +20 -0
  64. package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/dist/index.js +20 -14
  65. package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/dist/index.js.map +1 -1
  66. package/node_modules/@slack/bolt/node_modules/body-parser/node_modules/content-type/package.json +1 -1
  67. package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/README.md +2 -0
  68. package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/dist/index.d.ts +20 -0
  69. package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/dist/index.js +20 -14
  70. package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -1
  71. package/node_modules/@slack/bolt/node_modules/type-is/node_modules/content-type/package.json +1 -1
  72. package/node_modules/@slack/socket-mode/node_modules/@types/node/README.md +1 -1
  73. package/node_modules/@slack/socket-mode/node_modules/@types/node/child_process.d.ts +0 -1
  74. package/node_modules/@slack/socket-mode/node_modules/@types/node/crypto.d.ts +6 -6
  75. package/node_modules/@slack/socket-mode/node_modules/@types/node/dns/promises.d.ts +5 -5
  76. package/node_modules/@slack/socket-mode/node_modules/@types/node/dns.d.ts +5 -5
  77. package/node_modules/@slack/socket-mode/node_modules/@types/node/fs.d.ts +7 -0
  78. package/node_modules/@slack/socket-mode/node_modules/@types/node/http.d.ts +30 -0
  79. package/node_modules/@slack/socket-mode/node_modules/@types/node/http2.d.ts +4 -4
  80. package/node_modules/@slack/socket-mode/node_modules/@types/node/os.d.ts +30 -30
  81. package/node_modules/@slack/socket-mode/node_modules/@types/node/package.json +2 -2
  82. package/node_modules/@slack/socket-mode/node_modules/@types/node/perf_hooks.d.ts +2 -1
  83. package/node_modules/@slack/socket-mode/node_modules/@types/node/process.d.ts +42 -43
  84. package/node_modules/@slack/socket-mode/node_modules/@types/node/quic.d.ts +1049 -84
  85. package/node_modules/@slack/socket-mode/node_modules/@types/node/sqlite.d.ts +14 -1
  86. package/node_modules/@slack/socket-mode/node_modules/@types/node/stream/iter.d.ts +3 -2
  87. package/node_modules/@slack/socket-mode/node_modules/@types/node/test.d.ts +61 -0
  88. package/node_modules/@slack/socket-mode/node_modules/@types/node/v8.d.ts +20 -23
  89. package/node_modules/@slack/web-api/node_modules/@types/node/README.md +1 -1
  90. package/node_modules/@slack/web-api/node_modules/@types/node/child_process.d.ts +0 -1
  91. package/node_modules/@slack/web-api/node_modules/@types/node/crypto.d.ts +6 -6
  92. package/node_modules/@slack/web-api/node_modules/@types/node/dns/promises.d.ts +5 -5
  93. package/node_modules/@slack/web-api/node_modules/@types/node/dns.d.ts +5 -5
  94. package/node_modules/@slack/web-api/node_modules/@types/node/fs.d.ts +7 -0
  95. package/node_modules/@slack/web-api/node_modules/@types/node/http.d.ts +30 -0
  96. package/node_modules/@slack/web-api/node_modules/@types/node/http2.d.ts +4 -4
  97. package/node_modules/@slack/web-api/node_modules/@types/node/os.d.ts +30 -30
  98. package/node_modules/@slack/web-api/node_modules/@types/node/package.json +2 -2
  99. package/node_modules/@slack/web-api/node_modules/@types/node/perf_hooks.d.ts +2 -1
  100. package/node_modules/@slack/web-api/node_modules/@types/node/process.d.ts +42 -43
  101. package/node_modules/@slack/web-api/node_modules/@types/node/quic.d.ts +1049 -84
  102. package/node_modules/@slack/web-api/node_modules/@types/node/sqlite.d.ts +14 -1
  103. package/node_modules/@slack/web-api/node_modules/@types/node/stream/iter.d.ts +3 -2
  104. package/node_modules/@slack/web-api/node_modules/@types/node/test.d.ts +61 -0
  105. package/node_modules/@slack/web-api/node_modules/@types/node/v8.d.ts +20 -23
  106. package/node_modules/typebox/build/format/date.d.mts +1 -1
  107. package/node_modules/typebox/build/format/date.mjs +1 -1
  108. package/node_modules/typebox/build/format/date_time.d.mts +2 -2
  109. package/node_modules/typebox/build/format/date_time.mjs +3 -3
  110. package/node_modules/typebox/build/format/email.d.mts +1 -1
  111. package/node_modules/typebox/build/format/email.mjs +2 -2
  112. package/node_modules/typebox/build/format/hostname.mjs +2 -10
  113. package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
  114. package/node_modules/typebox/build/format/idn_email.mjs +3 -3
  115. package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
  116. package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
  117. package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
  118. package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
  119. package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
  120. package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
  121. package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
  122. package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
  123. package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
  124. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +23 -0
  125. package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
  126. package/node_modules/typebox/build/format/idna/index.mjs +2 -0
  127. package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
  128. package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
  129. package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
  130. package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
  131. package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
  132. package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
  133. package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
  134. package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
  135. package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
  136. package/node_modules/typebox/build/format/ipv4.mjs +2 -32
  137. package/node_modules/typebox/build/format/ipv6.mjs +2 -61
  138. package/node_modules/typebox/build/format/iri.d.mts +2 -2
  139. package/node_modules/typebox/build/format/iri.mjs +26 -8
  140. package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
  141. package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
  142. package/node_modules/typebox/build/format/regex.d.mts +1 -2
  143. package/node_modules/typebox/build/format/regex.mjs +2 -6
  144. package/node_modules/typebox/build/format/time.d.mts +2 -2
  145. package/node_modules/typebox/build/format/time.mjs +19 -14
  146. package/node_modules/typebox/build/format/uri.d.mts +1 -1
  147. package/node_modules/typebox/build/format/uri.mjs +3 -130
  148. package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
  149. package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
  150. package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
  151. package/node_modules/typebox/build/format/uri_template.mjs +4 -5
  152. package/node_modules/typebox/build/format/url.d.mts +3 -3
  153. package/node_modules/typebox/build/format/url.mjs +4 -5
  154. package/node_modules/typebox/build/guard/emit.d.mts +3 -1
  155. package/node_modules/typebox/build/guard/emit.mjs +12 -5
  156. package/node_modules/typebox/build/guard/guard.d.mts +8 -2
  157. package/node_modules/typebox/build/guard/guard.mjs +25 -4
  158. package/node_modules/typebox/build/guard/string.d.mts +2 -2
  159. package/node_modules/typebox/build/guard/string.mjs +7 -7
  160. package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
  161. package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
  162. package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
  163. package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
  164. package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
  165. package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
  166. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
  167. package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
  168. package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
  169. package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
  170. package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
  171. package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
  172. package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
  173. package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
  174. package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
  175. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
  176. package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
  177. package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
  178. package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
  179. package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
  180. package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
  181. package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
  182. package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
  183. package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
  184. package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
  185. package/node_modules/typebox/build/schema/types/index.mjs +0 -2
  186. package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
  187. package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
  188. package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
  189. package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
  190. package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
  191. package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
  192. package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
  193. package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
  194. package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
  195. package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
  196. package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
  197. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
  198. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
  199. package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
  200. package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
  201. package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
  202. package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
  203. package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
  204. package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
  205. package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
  206. package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
  207. package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
  208. package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
  209. package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
  210. package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
  211. package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
  212. package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
  213. package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
  214. package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
  215. package/node_modules/typebox/build/type/script/parser.mjs +27 -23
  216. package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
  217. package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
  218. package/node_modules/typebox/package.json +27 -27
  219. package/node_modules/typebox/readme.md +79 -82
  220. package/node_modules/ws/lib/permessage-deflate.js +3 -1
  221. package/node_modules/ws/package.json +1 -1
  222. package/openclaw.plugin.json +57 -7
  223. package/package.json +9 -9
  224. package/dist/account-configured-BwfXBo_F.js +0 -14
  225. package/dist/account-inspect-Drw2gAiN.js +0 -89
  226. package/dist/account-reply-mode-DrUXogvO.js +0 -14
  227. package/dist/action-runtime.runtime-D9I6uc0Q.js +0 -2
  228. package/dist/actions.runtime-DLFyUkvg.js +0 -2
  229. package/dist/block-text-YtiNkqmx.js +0 -79
  230. package/dist/runtime-api-Cj9nxBNv.js +0 -10
  231. package/node_modules/p-map/index.d.ts +0 -155
  232. package/node_modules/p-map/index.js +0 -285
  233. package/node_modules/p-map/license +0 -9
  234. package/node_modules/p-map/package.json +0 -57
  235. package/node_modules/p-map/readme.md +0 -190
  236. package/node_modules/typebox/build/format/_idna.d.mts +0 -2
  237. package/node_modules/typebox/build/format/_idna.mjs +0 -246
  238. package/node_modules/typebox/build/format/_puny.d.mts +0 -1
  239. package/node_modules/typebox/build/format/_puny.mjs +0 -77
  240. package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
  241. package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
  242. package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
  243. package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
  244. package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
  245. package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
  246. package/dist/{security-audit-DR097212.js → security-audit-B_yKr7MW.js} +1 -1
@@ -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
- const item = Unique();
19
- const isLength = E.Not(E.IsEqual(E.Member(value, 'length'), E.Constant(0)));
20
- const isSome = E.Call(E.Member(value, 'some'), [E.ArrowFunction([item], BuildSchema(stack, context, schema.contains, item))]);
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
- value.some((item) => CheckSchema(stack, context, schema.contains, item));
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.some(option => G.IsValueLike(option)
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 BuildItemsSized(stack, context, schema, value) {
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
- const guarded = context.UseUnevaluated() ? E.And(isSchema, addIndex) : isSchema;
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 BuildItemsUnsized(stack, context, schema, value) {
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
- const guarded = context.UseUnevaluated() ? E.And(isSchema, addIndex) : isSchema;
39
- return E.Every(value, E.Constant(offset), ['element', 'index'], guarded);
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 [result, item] = [Unique(), Unique()];
19
- const count = E.Call(E.Member(value, 'reduce'), [E.ArrowFunction([result, item], E.Ternary(BuildSchema(stack, context, schema.contains, item), E.PrefixIncrement(result), result)), E.Constant(0)]);
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 = value.reduce((result, item) => CheckSchema(stack, context, schema.contains, item) ? ++result : result, 0);
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
- const [result, item] = [Unique(), Unique()];
19
- const count = E.Call(E.Member(value, 'reduce'), [E.ArrowFunction([result, item], E.Ternary(BuildSchema(stack, context, schema.contains, item), E.PrefixIncrement(result), result)), E.Constant(0)]);
20
- return E.IsGreaterEqualThan(count, E.Constant(schema.minContains));
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 = value.reduce((result, item) => CheckSchema(stack, context, schema.contains, item) ? ++result : result, 0);
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 BuildNotUnevaluated(stack, context, schema, value) {
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() ? BuildNotUnevaluated(stack, context, schema, value) : BuildNotFast(stack, context, schema, value);
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 BuildOneOfUnevaluated(stack, context, schema, value) {
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.Call(E.Member(results, 'reduce'), [
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() ? BuildOneOfUnevaluated(stack, context, schema, value) : BuildOneOfFast(stack, context, schema, value);
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) ? new RegExp(schema.pattern, 'u') : 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) ? new RegExp(schema.pattern, 'u') : 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(new RegExp(pattern, 'u'));
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 = new RegExp(pattern, 'u');
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 = new RegExp(pattern, 'u');
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
- // BuildRefStandard
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) && schema.type.includes(typename) ||
53
- G.IsEqual(schema.type, typename));
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 types.some(type => CheckTypeName(stack, context, type, schema, value));
51
+ return G.Some(types, type => CheckTypeName(stack, context, type, schema, value));
52
52
  }
53
53
  // ------------------------------------------------------------------
54
54
  // Type
@@ -1 +1,4 @@
1
- export * from './ref.mjs';
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
- export * from './ref.mjs';
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;
@@ -0,0 +1,3 @@
1
+ // deno-lint-ignore-file ban-types
2
+ // deno-fmt-ignore-file
3
+ export {};
@@ -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';