dal-code 1.0.50 → 1.0.52
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/CHANGELOG.md +1050 -5
- package/NOTICE +17 -1
- package/dist/bundle/chunks/anthropic-messages-NK5NGKAI.js +5 -0
- package/dist/bundle/chunks/anthropic.js +74 -0
- package/dist/bundle/chunks/azure-openai-responses-VEASENYL.js +1 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +88 -0
- package/dist/bundle/chunks/chunk-3YGHTGYM.js +7 -0
- package/dist/bundle/chunks/chunk-4LDEEFCY.js +1 -0
- package/dist/bundle/chunks/chunk-4UTLMBZZ.js +13 -0
- package/dist/bundle/chunks/chunk-4VJJ6NXH.js +8 -0
- package/dist/bundle/chunks/chunk-567OJLS7.js +1 -0
- package/dist/bundle/chunks/chunk-5AGIVGSV.js +5 -0
- package/dist/bundle/chunks/chunk-6EEJ4MZH.js +1 -0
- package/dist/bundle/chunks/chunk-6QGV3IWD.js +5 -0
- package/dist/bundle/chunks/chunk-723ZGEZ2.js +1 -0
- package/dist/bundle/chunks/chunk-7DDKXS2Q.js +1 -0
- package/dist/bundle/chunks/chunk-7ZC4UXSL.js +1 -0
- package/dist/bundle/chunks/chunk-A5CI3CVQ.js +1 -0
- package/dist/bundle/chunks/chunk-AAQZXQA7.js +1 -0
- package/dist/bundle/chunks/chunk-ANL2BCIQ.js +15 -0
- package/dist/bundle/chunks/chunk-CF5GWZHW.js +30 -0
- package/dist/bundle/chunks/chunk-CS4T4O5O.js +1 -0
- package/dist/bundle/chunks/chunk-D2WTLI2T.js +19 -0
- package/dist/bundle/chunks/chunk-DLKRCASW.js +17 -0
- package/dist/bundle/chunks/chunk-EH7SFF47.js +129 -0
- package/dist/bundle/chunks/chunk-FFMDRXC4.js +9 -0
- package/dist/bundle/chunks/chunk-HEFI7NO7.js +1 -0
- package/dist/bundle/chunks/chunk-IEBK4HQA.js +1 -0
- package/dist/bundle/chunks/chunk-JXWJOIH4.js +1 -0
- package/dist/bundle/chunks/chunk-K7VBBYTT.js +1 -0
- package/dist/bundle/chunks/chunk-KJW3E2CB.js +9 -0
- package/dist/bundle/chunks/chunk-L2ZPNLYD.js +1 -0
- package/dist/bundle/chunks/chunk-LVVZS2NO.js +11 -0
- package/dist/bundle/chunks/chunk-ML5DIOWR.js +1 -0
- package/dist/bundle/chunks/chunk-ON7ZX67F.js +30 -0
- package/dist/bundle/chunks/chunk-OQWPBJCS.js +81 -0
- package/dist/bundle/chunks/chunk-P7FPUEYA.js +1 -0
- package/dist/bundle/chunks/chunk-PGXDEOVV.js +1 -0
- package/dist/bundle/chunks/chunk-PJACZCIR.js +1 -0
- package/dist/bundle/chunks/chunk-PRRNXB7S.js +1 -0
- package/dist/bundle/chunks/chunk-R47JBGS3.js +1 -0
- package/dist/bundle/chunks/chunk-RDZVAGPR.js +1 -0
- package/dist/bundle/chunks/chunk-SE42OS3U.js +21 -0
- package/dist/bundle/chunks/chunk-TK2WJTRC.js +3 -0
- package/dist/bundle/chunks/chunk-TMTOQ7H7.js +1 -0
- package/dist/bundle/chunks/chunk-UTB4DTYQ.js +1 -0
- package/dist/bundle/chunks/chunk-UVKMBM5X.js +56 -0
- package/dist/bundle/chunks/chunk-WIZGOHKY.js +9 -0
- package/dist/bundle/chunks/chunk-XAS5HHBW.js +1180 -0
- package/dist/bundle/chunks/chunk-XDBGA662.js +43 -0
- package/dist/bundle/chunks/chunk-XJFQKN3N.js +2 -0
- package/dist/bundle/chunks/chunk-YWNDPXVM.js +25 -0
- package/dist/bundle/chunks/chunk-ZG74NES2.js +1 -0
- package/dist/bundle/chunks/cli-GXB5WYKG.js +52 -0
- package/dist/bundle/chunks/cli-YPE3BB5X.js +30 -0
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-B7WOBGWO.js +1 -0
- package/dist/bundle/chunks/codemode-worker.js +480 -0
- package/dist/bundle/chunks/dist-D3WIBXB5.js +10 -0
- package/dist/bundle/chunks/easter-egg-3d-5TFBCTIS.js +1 -0
- package/dist/bundle/chunks/execute-27QCJECT.js +506 -0
- package/dist/bundle/chunks/github-copilot.js +1 -0
- package/dist/bundle/chunks/google-generative-ai-MBMRBHSZ.js +1 -0
- package/dist/bundle/chunks/google-vertex-S2ZFBDPP.js +1 -0
- package/dist/bundle/chunks/http-proxy-KF35JLJN.js +1 -0
- package/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +12 -0
- package/dist/bundle/chunks/image-resize-worker.js +1 -0
- package/dist/bundle/chunks/jiti-loader-GL4HJFAD.js +20 -0
- package/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +1 -0
- package/dist/bundle/chunks/kimi-coding.js +1 -0
- package/dist/bundle/chunks/lib-4AVRLBHM.js +8 -0
- package/dist/bundle/chunks/llama-cpp-classify-S4LVGNNY.js +21 -0
- package/dist/bundle/chunks/mcp-6LJKGKJQ.js +10 -0
- package/dist/bundle/chunks/meta.js +1 -0
- package/dist/bundle/chunks/mistral-conversations-C7LUXIEY.js +4 -0
- package/dist/bundle/chunks/multipart-parser-FMGQ7342.js +2 -0
- package/dist/bundle/chunks/node-AUOGOBCN.js +1 -0
- package/dist/bundle/chunks/node-ZTHARAQV.js +15 -0
- package/dist/bundle/chunks/office-5OWKTZOA.js +419 -0
- package/dist/bundle/chunks/openai-chatgpt.js +74 -0
- package/dist/bundle/chunks/openai-codex-responses-YQQXJ24E.js +9 -0
- package/dist/bundle/chunks/openai-codex.js +74 -0
- package/dist/bundle/chunks/openai-completions-7CMH2FKD.js +6 -0
- package/dist/bundle/chunks/openai-decisions-AOGZTREY.js +4 -0
- package/dist/bundle/chunks/openai-responses-ZSOGZ3MK.js +3 -0
- package/dist/bundle/chunks/openrouter-images-AHXST2TH.js +1 -0
- package/dist/bundle/chunks/openrouter.js +74 -0
- package/dist/bundle/chunks/pi-messages-QERJLMZ6.js +7 -0
- package/dist/bundle/chunks/radius.js +74 -0
- package/dist/bundle/chunks/review-5G56KIWY.js +80 -0
- package/dist/bundle/chunks/rewind-2OYLDDHH.js +8 -0
- package/dist/bundle/chunks/router-776Z7G7G.js +3 -0
- package/dist/bundle/chunks/runtime-NKPT25KD.js +1 -0
- package/dist/bundle/chunks/sdk-TVC4GDUX.js +1 -0
- package/dist/bundle/chunks/src-QKGKDFSU.js +3 -0
- package/dist/bundle/chunks/sync-JBDC3YBK.js +7 -0
- package/dist/bundle/chunks/typesafe-system-one-MMNGGQ46.js +1 -0
- package/dist/bundle/chunks/usage-BDCIALHO.js +1 -0
- package/dist/bundle/chunks/virtual-modules-25RQ6XTV.js +1 -0
- package/dist/bundle/chunks/xai.js +1 -0
- package/dist/bundle/cli-runtime.js +2 -0
- package/dist/bundle/cli.js +2 -0
- package/dist/bundle/index.js +1 -0
- package/dist/bundle/rpc-entry.js +2 -0
- package/dist/cli/args.js +1 -1
- package/dist/cli/auth-command.js +9 -6
- package/dist/cli/auth-login.js +2 -0
- package/dist/cli/auth-logout.js +1 -0
- package/dist/cli/auth-terminal.js +5 -0
- package/dist/cli/config-selector.js +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.js +1 -1
- package/dist/core/agent-session-runtime.js +1 -1
- package/dist/core/agent-session-services.js +1 -1
- package/dist/core/agent-session.d.ts +8 -1
- package/dist/core/agent-session.js +12 -9
- package/dist/core/auth-storage.js +1 -1
- package/dist/core/bash-executor.js +1 -1
- package/dist/core/bug-report.js +3 -3
- package/dist/core/cache-warmer.d.ts +3 -15
- package/dist/core/cache-warmer.js +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +3 -2
- package/dist/core/compaction/branch-summarization.js +5 -5
- package/dist/core/compaction/compaction.d.ts +1 -0
- package/dist/core/compaction/compaction.js +14 -14
- package/dist/core/compaction/tool-output-pruning.js +1 -1
- package/dist/core/compaction/utils.d.ts +0 -1
- package/dist/core/compaction/utils.js +8 -8
- package/dist/core/exec.d.ts +2 -0
- package/dist/core/exec.js +1 -1
- package/dist/core/export-html/template.css +9 -0
- package/dist/core/export-html/template.js +46 -39
- package/dist/core/export-html/tool-renderer.js +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/extensions/pi-ai-extension-view.js +1 -0
- package/dist/core/extensions/runner.js +1 -1
- package/dist/core/extensions/types.d.ts +25 -7
- package/dist/core/extensions/virtual-modules.js +1 -1
- package/dist/core/keybindings.d.ts +1 -1
- package/dist/core/keybindings.js +1 -1
- package/dist/core/mcp-servers.d.ts +6 -17
- package/dist/core/mcp-servers.js +1 -1
- package/dist/core/model-config.d.ts +1912 -2211
- package/dist/core/model-config.js +4 -4
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-runtime.d.ts +1 -0
- package/dist/core/model-runtime.js +1 -1
- package/dist/core/package-manager.d.ts +10 -1
- package/dist/core/package-manager.js +2 -2
- package/dist/core/pi-ai-schemas.js +1 -0
- package/dist/core/pi-manifest.js +1 -1
- package/dist/core/preferred-providers.js +1 -0
- package/dist/core/project-trust.js +2 -2
- package/dist/core/prompt-templates.js +2 -2
- package/dist/core/provider-composer.js +1 -1
- package/dist/core/provider-matching.js +1 -0
- package/dist/core/radius-mcp.js +1 -0
- package/dist/core/remote-catalog-provider.js +1 -1
- package/dist/core/resource-loader.d.ts +3 -1
- package/dist/core/resource-loader.js +1 -1
- package/dist/core/runtime-credentials.js +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/session-cwd.js +3 -7
- package/dist/core/session-manager.d.ts +1 -0
- package/dist/core/session-manager.js +12 -12
- package/dist/core/settings-defaults.js +1 -1
- package/dist/core/settings-manager.d.ts +4 -0
- package/dist/core/settings-manager.js +1 -1
- package/dist/core/settings-schema.d.ts +4 -2
- package/dist/core/settings-schema.js +1 -1
- package/dist/core/skills.js +3 -3
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/source-info.d.ts +8 -0
- package/dist/core/source-info.js +1 -1
- package/dist/core/system-prompt.js +3 -3
- package/dist/core/tools/bash.d.ts +2 -2
- package/dist/core/tools/bash.js +15 -15
- package/dist/core/tools/edit-diff.d.ts +9 -4
- package/dist/core/tools/edit-diff.js +22 -15
- package/dist/core/tools/edit.d.ts +3 -3
- package/dist/core/tools/edit.js +3 -3
- package/dist/core/tools/find.d.ts +2 -2
- package/dist/core/tools/find.js +10 -11
- package/dist/core/tools/grep.d.ts +3 -3
- package/dist/core/tools/grep.js +8 -12
- package/dist/core/tools/ls.d.ts +2 -2
- package/dist/core/tools/ls.js +4 -4
- package/dist/core/tools/powershell.js +6 -2
- package/dist/core/tools/read.d.ts +5 -2
- package/dist/core/tools/read.js +20 -19
- package/dist/core/tools/render-utils.js +5 -5
- package/dist/core/tools/renderers/write.js +10 -10
- package/dist/core/tools/tool-definition-wrapper.d.ts +11 -0
- package/dist/core/tools/truncate.d.ts +2 -8
- package/dist/core/tools/truncate.js +10 -10
- package/dist/core/tools/write.d.ts +2 -2
- package/dist/core/trust-manager.js +2 -2
- package/dist/core/usage-totals.js +1 -1
- package/dist/dal/builtins.js +2 -2
- package/dist/dal/manifest.d.ts +1 -0
- package/dist/dal/manifest.js +1 -1
- package/dist/dal/safety-net.js +11 -3
- package/dist/extensions/codemode/execute.js +12 -12
- package/dist/extensions/codemode/renderer.js +6 -6
- package/dist/extensions/codemode/tool.d.ts +2 -1
- package/dist/extensions/codemode/tool.js +11 -10
- package/dist/extensions/llama/client.js +5 -5
- package/dist/extensions/llama/ui.js +2 -2
- package/dist/extensions/mcp/cli.js +21 -19
- package/dist/extensions/mcp/config.js +2 -2
- package/dist/extensions/mcp/index.js +7 -7
- package/dist/extensions/mcp/oauth.d.ts +3 -22
- package/dist/extensions/mcp/oauth.js +2 -2
- package/dist/extensions/mcp/resources.d.ts +1 -1
- package/dist/extensions/mcp/resources.js +1 -1
- package/dist/extensions/mcp/runtime.d.ts +2 -2
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/extensions/mcp/tools.d.ts +1 -8
- package/dist/extensions/mcp/tools.js +4 -9
- package/dist/extensions/mcp/ui.js +1 -1
- package/dist/extensions/tool-search/tool.js +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/main.js +4 -4
- package/dist/modes/interactive/components/assistant-message.d.ts +4 -1
- package/dist/modes/interactive/components/assistant-message.js +2 -2
- package/dist/modes/interactive/components/branch-summary-message.d.ts +5 -1
- package/dist/modes/interactive/components/branch-summary-message.js +2 -2
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +5 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +2 -2
- package/dist/modes/interactive/components/config-selector.js +1 -1
- package/dist/modes/interactive/components/custom-editor.js +1 -1
- package/dist/modes/interactive/components/custom-entry.js +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +5 -2
- package/dist/modes/interactive/components/custom-message.js +3 -3
- package/dist/modes/interactive/components/diff.js +3 -3
- package/dist/modes/interactive/components/extension-editor.d.ts +1 -0
- package/dist/modes/interactive/components/extension-editor.js +1 -1
- package/dist/modes/interactive/components/extension-selector.js +2 -2
- package/dist/modes/interactive/components/login-dialog.d.ts +5 -0
- package/dist/modes/interactive/components/login-dialog.js +1 -1
- package/dist/modes/interactive/components/markdown-transform.js +1 -1
- package/dist/modes/interactive/components/mermaid.js +4 -4
- package/dist/modes/interactive/components/model-selector.d.ts +1 -0
- package/dist/modes/interactive/components/model-selector.js +2 -2
- package/dist/modes/interactive/components/oauth-selector.d.ts +2 -1
- package/dist/modes/interactive/components/oauth-selector.js +1 -1
- package/dist/modes/interactive/components/provider-brand.js +1 -0
- package/dist/modes/interactive/components/radius-login-selector.js +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +1 -1
- package/dist/modes/interactive/components/session-selector-search.js +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +2 -1
- package/dist/modes/interactive/components/session-selector.js +2 -2
- package/dist/modes/interactive/components/settings-submenu.js +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +5 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +2 -2
- package/dist/modes/interactive/components/tool-execution.d.ts +1 -0
- package/dist/modes/interactive/components/tool-execution.js +3 -3
- package/dist/modes/interactive/components/tree-selector.d.ts +2 -0
- package/dist/modes/interactive/components/tree-selector.js +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +2 -1
- package/dist/modes/interactive/components/user-message.js +1 -1
- package/dist/modes/interactive/external-editor.js +3 -3
- package/dist/modes/interactive/interactive-mode.d.ts +10 -1
- package/dist/modes/interactive/interactive-mode.js +45 -40
- package/dist/modes/interactive/model-search.js +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +4 -0
- package/dist/modes/interactive/theme/theme.js +3 -6
- package/dist/modes/print-mode.js +7 -7
- package/dist/modes/rpc/rpc-mode.js +1 -1
- package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-codeindex/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-compat/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-learn/package.json +5 -2
- package/dist/node_modules/@dalcode/dal-learn/src/engine.js +4 -4
- package/dist/node_modules/@dalcode/dal-learn/src/extract.js +31 -5
- package/dist/node_modules/@dalcode/dal-learn/src/index.js +16 -16
- package/dist/node_modules/@dalcode/dal-learn/src/learn-mode.js +1 -0
- package/dist/node_modules/@dalcode/dal-learn/src/lesson-events.js +1 -0
- package/dist/node_modules/@dalcode/dal-learn/src/lessons.js +4 -3
- package/dist/node_modules/@dalcode/dal-learn/src/project-map.js +2 -2
- package/dist/node_modules/@dalcode/dal-learn/src/safety.js +2 -2
- package/dist/node_modules/@dalcode/dal-learn/src/signals.js +6 -5
- package/dist/node_modules/@dalcode/dal-learn/src/store.js +3 -2
- package/dist/node_modules/@dalcode/dal-lsp/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-mcp/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +4 -3
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +4 -3
- package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-remote/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-router/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-sync/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-sync/src/core.js +2 -2
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-workflow/src/todo-snapshot.js +2 -2
- package/dist/node_modules/@dalcode/dal-workflow/src/todo.js +3 -3
- package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-agent-core/README.md +8 -6
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +2 -2
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +8 -5
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/README.md +58 -39
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +5 -5
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +2 -2
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/lazy.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/lazy.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +4 -4
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +2 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +5 -5
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +9 -9
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/strict-tool-limits.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/meta.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/trusted-url.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/cache-warming.d.ts +21 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/cache-warming.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/cli.js +5 -5
- package/dist/node_modules/@earendil-works/pi-ai/dist/compat/extension-oauth-types.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/index.d.ts +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/lazy-bedrock-provider.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/lazy-oauth.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.generated.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/all.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.d.ts +485 -498
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/azure.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/meta.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-individual-cn.json +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-individual.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +5 -5
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.d.ts +65 -65
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual-cn.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual-cn.models.d.ts +5 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual-cn.models.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/schema-builders.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/telemetry.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/types.d.ts +4 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/openrouter-cost.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/streaming-json.d.ts +26 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/streaming-json.js +4 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/{typebox-helpers.d.ts → string-enum.d.ts} +2 -2
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/string-enum.js +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/text.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/text.js +2 -2
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/validation.js +4 -4
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/package.json +12 -5
- package/dist/node_modules/@earendil-works/pi-codemode/README.md +2 -2
- package/dist/node_modules/@earendil-works/pi-codemode/dist/declarations.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-codemode/dist/declarations.js +4 -4
- package/dist/node_modules/@earendil-works/pi-codemode/dist/index.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-codemode/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/prelude-source.js +2 -0
- package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/CHANGELOG.md +32 -0
- package/dist/node_modules/@earendil-works/pi-mcp/README.md +60 -5
- package/dist/node_modules/@earendil-works/pi-mcp/dist/config.d.ts +45 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/config.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/index.d.ts +5 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/input-schema.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/input-schema.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/naming.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/naming.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/auth-provider.d.ts +18 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/auth-provider.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/callback.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/client-settings.d.ts +42 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/client-settings.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/index.d.ts +5 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/loopback.d.ts +22 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/loopback.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/sign-in.d.ts +28 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/sign-in.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/types.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/types.js +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/dist/output-limit.d.ts +8 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/output-limit.js +11 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/lines.js +1 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/pipe.d.ts +34 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/pipe.js +2 -0
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/stdio.d.ts +1 -4
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/stdio.js +2 -2
- package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.js +6 -4
- package/dist/node_modules/@earendil-works/pi-mcp/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-schema/CHANGELOG.md +37 -0
- package/dist/node_modules/@earendil-works/pi-schema/LICENSE +21 -0
- package/dist/node_modules/@earendil-works/pi-schema/README.md +319 -0
- package/dist/node_modules/@earendil-works/pi-schema/THIRD_PARTY_NOTICES/typebox-LICENSE +23 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/annotations.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/builders.d.ts +89 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/builders.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/checks.d.ts +51 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/checks.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/coerce.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/compiler.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/explain.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/index.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/date.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/date_time.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/duration.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/email.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/hostname.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idn_email.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idn_hostname.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/format/bidi.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/format/puny.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/hostname.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/idn-hostname.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/index.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/label/ascii.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/label/puny.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/label/unicode.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/idna/pattern/pattern.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/ipv4.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/ipv6.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/iri.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/iri_reference.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/json_pointer.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/json_pointer_uri_fragment.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/regex.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/relative_json_pointer.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/time.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uri.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uri_reference.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uri_template.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/url.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/formats/typebox/uuid.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/index.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/index.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/resolver.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/shared.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/typebox-static.d.ts +54 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/typebox-static.js +0 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/types.d.ts +25 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/types.js +0 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/validator.d.ts +20 -0
- package/dist/node_modules/@earendil-works/pi-schema/dist/validator.js +1 -0
- package/dist/node_modules/@earendil-works/pi-schema/package.json +43 -0
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/index.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/memory.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/memory.js +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/render.js +2 -2
- package/dist/node_modules/@earendil-works/pi-telemetry/package.json +3 -1
- package/dist/node_modules/@earendil-works/pi-tui/README.md +2 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.js +3 -3
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +11 -10
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/select-list.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/text.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/fuzzy.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/index.d.ts +2 -2
- package/dist/node_modules/@earendil-works/pi-tui/dist/index.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/keybindings.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/keys.js +5 -5
- package/dist/node_modules/@earendil-works/pi-tui/dist/layout.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/program-status.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +4 -4
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.js +13 -13
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui.js +2 -2
- package/dist/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/utils.js +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/dist/package-manager-cli.js +17 -16
- package/dist/utils/ansi.js +1 -1
- package/dist/utils/changelog.js +3 -3
- package/dist/utils/clipboard-command.js +1 -1
- package/dist/utils/image-resize-core.js +1 -1
- package/dist/utils/image-resize.js +1 -1
- package/dist/utils/open-browser.js +1 -1
- package/dist/utils/paths.js +1 -1
- package/dist/utils/shell.js +3 -3
- package/dist/utils/syntax-highlight.js +4 -4
- package/dist/utils/terminal-question.js +1 -0
- package/dist/utils/tools-manager.js +1 -1
- package/dist/utils/web-url.js +1 -0
- package/examples/extensions/README.md +2 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +14 -14
- package/examples/extensions/debug-provider.ts +2 -2
- package/examples/extensions/gondolin/package-lock.json +19 -29
- package/examples/extensions/gondolin/package.json +2 -2
- package/examples/extensions/plan-mode/index.ts +20 -9
- package/examples/extensions/plan-mode/utils.ts +42 -16
- package/examples/extensions/preset.ts +2 -0
- package/examples/extensions/reload-runtime.ts +17 -5
- package/examples/extensions/subagent/README.md +14 -11
- package/examples/extensions/subagent/index.ts +392 -171
- package/examples/extensions/todo.ts +7 -0
- package/examples/extensions/tools.ts +2 -0
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +20 -20
- package/examples/tsconfig.json +208 -0
- package/npm-shrinkwrap.json +407 -383
- package/package.json +6 -7
- package/examples/extensions/sandbox/index.ts +0 -327
- package/examples/extensions/sandbox/package-lock.json +0 -92
- package/examples/extensions/sandbox/package.json +0 -19
- /package/dist/node_modules/@earendil-works/pi-mcp/{LICENSES → THIRD_PARTY_NOTICES}/modelcontextprotocol-typescript-sdk.txt +0 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
# @earendil-works/pi-schema
|
|
2
|
+
|
|
3
|
+
JSON Schema builders and validation without `eval`. A schema compiles once into plain closures, so it checks values
|
|
4
|
+
at close to the speed of validators that generate code, also under a strict Content Security Policy, and needs no
|
|
5
|
+
dependencies.
|
|
6
|
+
|
|
7
|
+
- Drafts 2020-12 and 7. Passes 2,222 of the 2,223 core tests of the official
|
|
8
|
+
[JSON-Schema-Test-Suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite).
|
|
9
|
+
- Builders return plain JSON Schema typed with the values it accepts; a compiled check narrows to that type.
|
|
10
|
+
- Errors as JSON Pointer paths. A missing or unknown field is reported at the field.
|
|
11
|
+
- Never modifies a schema; frozen schemas work.
|
|
12
|
+
- 8.5 KB minified and gzipped. Format checks are an optional import.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @earendil-works/pi-schema
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { compile, int, obj, oneOf, opt, type Static, str } from "@earendil-works/pi-schema";
|
|
24
|
+
|
|
25
|
+
const Read = obj({
|
|
26
|
+
path: str({ description: "Path to the file", minLength: 1 }),
|
|
27
|
+
offset: opt(int({ minimum: 1 })),
|
|
28
|
+
mode: oneOf(["text", "binary"]),
|
|
29
|
+
});
|
|
30
|
+
type Read = Static<typeof Read>; // { path: string; mode: "text" | "binary"; offset?: number }
|
|
31
|
+
|
|
32
|
+
const read = compile(Read);
|
|
33
|
+
if (read.check(value)) value.path; // value: Read
|
|
34
|
+
|
|
35
|
+
read.errors({ offset: 0, extra: true });
|
|
36
|
+
// [
|
|
37
|
+
// { path: "/path", keyword: "required", message: "missing" },
|
|
38
|
+
// { path: "/mode", keyword: "required", message: "missing" },
|
|
39
|
+
// { path: "/offset", keyword: "minimum", message: "expected >= 1" },
|
|
40
|
+
// { path: "/extra", keyword: "additionalProperties", message: "unknown field" },
|
|
41
|
+
// ]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`Read` is plain JSON Schema (`{ type: "object", properties: {...}, required: ["path", "mode"], additionalProperties:
|
|
45
|
+
false }`), ready for a tool definition or `JSON.stringify`. `compile` takes any JSON Schema, built with the builders
|
|
46
|
+
or not.
|
|
47
|
+
|
|
48
|
+
`check(value)` is the fast path: a boolean, no allocations for most schemas, and a plain function you can pass
|
|
49
|
+
around. `errors(value)` explains a failure and returns `[]` for a valid value. It is built on the first failure and
|
|
50
|
+
kept, so a schema whose values always pass never pays for it. `validate(value)` combines the two without changing
|
|
51
|
+
the value: `{ ok: true, value }` or `{ ok: false, errors }`.
|
|
52
|
+
|
|
53
|
+
### Builders
|
|
54
|
+
|
|
55
|
+
| builder | schema | type |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| `str({ minLength, maxLength, pattern, format })` | `{ type: "string", ... }` | `string` |
|
|
58
|
+
| `num({ minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf })`, `int(...)` | `{ type: "number" }`, `{ type: "integer" }` | `number` |
|
|
59
|
+
| `bool()`, `nul()`, `unknown()` | `{ type: "boolean" }`, `{ type: "null" }`, `{}` | `boolean`, `null`, `unknown` |
|
|
60
|
+
| `lit(value)` | `{ const: value }` | the literal |
|
|
61
|
+
| `oneOf(["a", "b"])` | `{ enum: [...] }` | `"a" \| "b"` |
|
|
62
|
+
| `obj({ a: str(), b: opt(num()) }, { open })` | closed object; `open: true` allows other properties | `{ a: string; b?: number }` |
|
|
63
|
+
| `arr(items, { minItems, maxItems, uniqueItems })` | `{ type: "array", items }` | `T[]` |
|
|
64
|
+
| `tuple([str(), num()])` | `prefixItems`, no more items | `[string, number]` |
|
|
65
|
+
| `map(value)` | `{ type: "object", additionalProperties: value }` | `Record<string, T>` |
|
|
66
|
+
| `union([...])` | `{ anyOf: [...] }` | the union |
|
|
67
|
+
| `nullable(schema)` | `{ anyOf: [schema, { type: "null" }] }` | `T \| null` |
|
|
68
|
+
| `bytes({ minLength, maxLength })` | `{ type: "bytes", ... }` | `Uint8Array` |
|
|
69
|
+
| `bigint({ minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf })` | `{ type: "bigint", ... }`, bigint bounds | `bigint` |
|
|
70
|
+
| `unsafe<T>(schema)` | `schema` as given (`{}` by default) | `T`, unchecked |
|
|
71
|
+
| `recursive<T>(id, (self) => schema)` | `schema` with `$id: id`; `self` is `{ $ref: id }` | `T` |
|
|
72
|
+
|
|
73
|
+
Every builder also takes `title`, `description`, `examples`, `deprecated` and `default`. A `default` is an annotation;
|
|
74
|
+
validation never inserts it.
|
|
75
|
+
|
|
76
|
+
A union of objects tagged by a `lit()` property checks and reports by the tag: only the branch the tag selects runs.
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const Block = union([obj({ kind: lit("text"), text: str() }), obj({ kind: lit("image"), width: int({ minimum: 0 }) })]);
|
|
80
|
+
compile(Block).errors({ kind: "video" });
|
|
81
|
+
// [{ path: "/kind", keyword: "anyOf", message: 'expected one of ["text","image"]' }]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
A recursive schema needs its type spelled out, since TypeScript cannot infer one from the builders. Its `id` must be
|
|
85
|
+
unique among the recursive schemas within one schema:
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
type Tree = { name: string; children: Tree[] };
|
|
89
|
+
const Tree = recursive<Tree>("Tree", (self) => obj({ name: str(), children: arr(self) }));
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`Static` also types schemas built with TypeBox 1.x, read from TypeBox's type shapes (pi-schema does not import
|
|
93
|
+
TypeBox): `String`, `Number`, `Integer`, `Boolean`, `Null`, `Literal`, `Array`, `Object` (with `Type.Optional` and
|
|
94
|
+
`Type.Readonly` properties), `Union`, `Record`, `Enum`, `Tuple`, `BigInt`, `Undefined`, `Unsafe`, `Unknown` and `Any`
|
|
95
|
+
give TypeBox's own static type, so `Static<typeof Type.Object({ path: Type.String() })>` is `{ path: string }`. Other
|
|
96
|
+
TypeBox kinds (`Intersect`, `Cyclic`, `Ref`, ...) give `unknown` where they stand. Other JSON Schema objects give
|
|
97
|
+
`unknown`.
|
|
98
|
+
|
|
99
|
+
### Options
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { formats } from "@earendil-works/pi-schema/formats";
|
|
103
|
+
|
|
104
|
+
const validator = compile(schema, {
|
|
105
|
+
draft: "7", // "2020-12" (default) or "7"
|
|
106
|
+
formats, // check `format`; without it `format` is an annotation, as 2020-12 specifies
|
|
107
|
+
schemas: { "https://example.com/point.json": point }, // documents for $refs to other documents, by URI
|
|
108
|
+
unresolvedRefs: "reject", // a $ref that names nothing rejects values at its place; default "throw"
|
|
109
|
+
coerce: true, // adds coerce() and parse(), see Coercion
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
`formats` has every format 2020-12 defines (`date-time`, `email`, `uri`, `uuid`, `ipv6`, ...), plus `url` and
|
|
114
|
+
`json-pointer-uri-fragment`, which TypeBox and ajv-formats also check. Pass your own map to check fewer formats, or
|
|
115
|
+
custom ones.
|
|
116
|
+
|
|
117
|
+
A `$ref` that names nothing (a missing definition, a document not in `schemas`) throws when the schema compiles. With
|
|
118
|
+
`unresolvedRefs: "reject"` it compiles as `false` instead: only values at that place fail, with the error
|
|
119
|
+
`unresolved reference <ref>`, and the rest of the schema works. Use it for schemas from other systems, such as MCP
|
|
120
|
+
servers, whose references may dangle.
|
|
121
|
+
|
|
122
|
+
### TypeBox schemas
|
|
123
|
+
|
|
124
|
+
TypeBox 1.x schemas are JSON Schema, so they compile as they are:
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
import Type from "typebox";
|
|
128
|
+
|
|
129
|
+
const user = compile(Type.Object({ name: Type.String(), tags: Type.Array(Type.String()) }));
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
TypeBox's `BigInt` and `Undefined` are supported (see Values). Its other JavaScript-only types (`Function`, `Symbol`,
|
|
133
|
+
...), refinements and codecs are not JSON Schema and are not supported.
|
|
134
|
+
|
|
135
|
+
### Coercion
|
|
136
|
+
|
|
137
|
+
`compile(schema, { coerce: true })` adds `coerce()` and `parse()`, for loosely typed input such as a model's tool call
|
|
138
|
+
arguments. Without the option the validator has neither, and its `check` pays nothing for them: the coercion rules are
|
|
139
|
+
built on the first `coerce()` or `parse()`.
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
const read = compile(Read, { coerce: true });
|
|
143
|
+
|
|
144
|
+
read.coerce({ path: "a.txt", offset: "10", mode: "text" }); // { path: "a.txt", offset: 10, mode: "text" }
|
|
145
|
+
|
|
146
|
+
const result = read.parse({ path: "a.txt", offset: "ten", mode: "text" });
|
|
147
|
+
if (result.ok) result.value.offset; // number
|
|
148
|
+
else result.errors; // [{ path: "/offset", keyword: "type", message: "expected integer, got string" }]
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
`coerce(value)` returns the coerced value. It copies only the paths it changes, returns `value` itself when nothing
|
|
152
|
+
changes, and never modifies `value`. A value no rule applies to stays as it is. `parse(value)` coerces, then checks:
|
|
153
|
+
`{ ok: true, value }` with the coerced value, or `{ ok: false, errors }` with the errors of the coerced value.
|
|
154
|
+
|
|
155
|
+
Three passes run in order:
|
|
156
|
+
|
|
157
|
+
1. **Optional nulls.** A `null` in an optional property whose schema rejects `null` is dropped, as if omitted.
|
|
158
|
+
2. **Conversions**, ported from TypeBox 1.3.27's `Value.Convert` and keyed on JSON Schema keywords (the first that
|
|
159
|
+
applies to a schema): `$ref` follows the reference; `const` and `enum` take the member the value converts to;
|
|
160
|
+
`anyOf`/`oneOf` keep a value one branch accepts, else take the first branch's conversion the whole schema
|
|
161
|
+
accepts; `allOf` converts with each member in turn; then by `type`:
|
|
162
|
+
- `string`: numbers and booleans to their text, `null` to `"null"`.
|
|
163
|
+
- `number`: numeric strings (`""` is 0), `"true"`/`"false"`, booleans to 1/0, `null` to 0.
|
|
164
|
+
- `integer`: as `number`, then truncated (`"3.5"` and `3.5` become 3).
|
|
165
|
+
- `boolean`: `"true"`/`"false"` (any case), `"1"`/`"0"`, 1/0, `null` to `false`.
|
|
166
|
+
- `null`: `"null"`, `"undefined"`, `""`, `"0"`, 0 and `false`.
|
|
167
|
+
- `bigint`: integer strings (`"12"`, `"12n"`; `"12.9"` truncated), numbers truncated, `"true"`/`"false"` and
|
|
168
|
+
booleans to 1n/0n, `null` to 0n.
|
|
169
|
+
- `undefined`: `"undefined"`, `"null"`, `""`, `"0"`, 0, 0n, `false` and `null`.
|
|
170
|
+
- `array`: a single value becomes a one-item array, then each item converts; a tuple (`prefixItems` or an `items`
|
|
171
|
+
array) converts its items and never wraps.
|
|
172
|
+
- `object`: each property converts by `properties`, `patternProperties` or `additionalProperties`.
|
|
173
|
+
3. **Primitive coercion by type**, as Ajv's `coerceTypes`, for what pass 2 leaves (type arrays such as
|
|
174
|
+
`["integer", "null"]`): numbers from numeric strings and booleans, booleans from `"true"`/`"false"` and 1/0,
|
|
175
|
+
strings from numbers and booleans, `null` from `""`, 0 and `false`, and `null` to `""`, 0 or `false`. A value that
|
|
176
|
+
already has one of a type array's types stays.
|
|
177
|
+
|
|
178
|
+
Where passes 2 and 3 disagree, pass 2 wins: `null` for a required string becomes `"null"`, not `""`. A union's
|
|
179
|
+
branches convert in order and only until one is accepted; a union node that also declares properties converts them into
|
|
180
|
+
each branch's candidate before checking it. A recursive schema (a tree through `$ref`) that meets a value it cannot
|
|
181
|
+
convert leaves the value as it is, so `check` reports it, and results through a `$ref` are reused within one call, so a
|
|
182
|
+
recursive union does not convert (or explain) the same child once per branch.
|
|
183
|
+
|
|
184
|
+
Pass 1 drops optional nulls inside the values of `properties`, `patternProperties` and `additionalProperties` alike; a
|
|
185
|
+
pattern or additional key itself is never dropped. Items past a draft-7 `items` array (`additionalItems`) are not
|
|
186
|
+
coerced by any pass.
|
|
187
|
+
|
|
188
|
+
### Values
|
|
189
|
+
|
|
190
|
+
- An optional property whose value is `undefined` counts as absent, as in TypeBox. A required property set to
|
|
191
|
+
`undefined` is present: valid when its schema takes `undefined` (`Type.Undefined()` in it, `Type.Unknown()`,
|
|
192
|
+
`Type.Any()`), else missing.
|
|
193
|
+
- `{ type: "bytes", minLength, maxLength }` matches a `Uint8Array` of that length, an extension for values that never
|
|
194
|
+
pass through JSON.
|
|
195
|
+
- `{ type: "bigint" }` (TypeBox's `Type.BigInt`) matches a `bigint`. The number keywords (`minimum`, `maximum`,
|
|
196
|
+
`exclusiveMinimum`, `exclusiveMaximum`, `multipleOf`) apply to numbers and bigints alike, with bounds of either kind,
|
|
197
|
+
as in TypeBox.
|
|
198
|
+
- `{ type: "undefined" }` (TypeBox's `Type.Undefined`) matches `undefined`.
|
|
199
|
+
- `equal(a, b)` is JSON equality as `const`, `enum` and `uniqueItems` compare (TypeBox's `Value.Equal`).
|
|
200
|
+
|
|
201
|
+
## Supported keywords
|
|
202
|
+
|
|
203
|
+
- Every validation keyword of drafts 2020-12 and 7, including draft 7's `dependencies` and `items` arrays with
|
|
204
|
+
`additionalItems`.
|
|
205
|
+
- `$id`, `$anchor`, `$ref` (local, by anchor, relative and remote), `$dynamicRef` and `$dynamicAnchor`.
|
|
206
|
+
- `unevaluatedProperties` and `unevaluatedItems`.
|
|
207
|
+
- `pattern` and `patternProperties` are ECMAScript regular expressions with the `u` flag.
|
|
208
|
+
- Not supported: meta-schemas that switch vocabularies on or off (`$vocabulary`), `contentMediaType` and
|
|
209
|
+
`contentEncoding` assertions (optional in the spec), and draft 2019-09's `$recursiveRef`.
|
|
210
|
+
|
|
211
|
+
## Benchmarks
|
|
212
|
+
|
|
213
|
+
Node 24.4.1 on one core of an i9-13900. The other libraries:
|
|
214
|
+
|
|
215
|
+
- ata-validator 1.61.3: its generated code, and its eval-free interpreter chosen with `engine: "interpreter"`;
|
|
216
|
+
- Ajv 8.20.0, with ajv-formats 3.0.1 for the format tests;
|
|
217
|
+
- Zod 4.6.7: native Zod schemas for speed, setup and memory, and `z.fromJSONSchema` for the test suite;
|
|
218
|
+
- TypeBox 1.3.27;
|
|
219
|
+
- @cfworker/json-schema 4.1.1;
|
|
220
|
+
- @oh-my-pi/omptype 18.13.3, through `fromJsonSchema`.
|
|
221
|
+
|
|
222
|
+
| test suite (tests passed) | pi-schema | ata | ata interpreter | Ajv | Zod | TypeBox | cfworker | omptype |
|
|
223
|
+
|---|---:|---:|---:|---:|---:|---:|---:|---:|
|
|
224
|
+
| draft 2020-12 core (1,298) | 1,297 | 1,298 | 1,298 | 1,236 | 693 | 1,276 | 1,249 | 863 |
|
|
225
|
+
| draft 7 core (925) | 925 | 925 | 925 | 917 | 632 | 924 | 918 | 659 |
|
|
226
|
+
| draft 2020-12 format (895), with format checks | 895 | 814 | 814 | 750 | 412 | 895 | 740 | 412 |
|
|
227
|
+
|
|
228
|
+
| check, valid value | pi-schema | ata | ata interpreter | Ajv | Zod | TypeBox | cfworker | omptype |
|
|
229
|
+
|---|---:|---:|---:|---:|---:|---:|---:|---:|
|
|
230
|
+
| nested object with tagged unions | 410 ns | 180 ns | 836 ns | 627 ns | 1.3 µs | 475 ns | 43 µs | 730 ns |
|
|
231
|
+
| union of 5 messages | 86 ns | 37 ns | 212 ns | 70 ns | 297 ns | 95 ns | 11 µs | 96 ns |
|
|
232
|
+
| tool schema (read) | 31 ns | 10 ns | 41 ns | 13 ns | 41 ns | 9 ns | 2.0 µs | 9 ns |
|
|
233
|
+
| MCP tool schema with `$ref` | 161 ns | 64 ns | 314 ns | 136 ns | 927 ns | 87 ns | 15 µs | 1.9 µs |
|
|
234
|
+
| recursive `$ref` schema | 755 ns | 307 ns | 1.9 µs | 378 ns | 2.7 µs | 1.2 µs | 41 µs | 7.5 µs |
|
|
235
|
+
|
|
236
|
+
| same, without eval (strict CSP) | pi-schema | ata | ata interpreter | Ajv | Zod | TypeBox | cfworker | omptype |
|
|
237
|
+
|---|---:|---:|---:|---:|---:|---:|---:|---:|
|
|
238
|
+
| nested object with tagged unions | 411 ns | 1.6 µs | 844 ns | fails | 3.4 µs | 44 µs | 44 µs | 2.7 µs |
|
|
239
|
+
| union of 5 messages | 87 ns | 396 ns | 209 ns | fails | 652 ns | 10 µs | 11 µs | 501 ns |
|
|
240
|
+
| MCP tool schema with `$ref` | 164 ns | 484 ns | 326 ns | fails | 2.0 µs | 39 µs | 13 µs | 2.2 µs |
|
|
241
|
+
| recursive `$ref` schema | 746 ns | 2.8 µs | 1.9 µs | fails | 7.3 µs | 130 µs | 42 µs | 9.0 µs |
|
|
242
|
+
|
|
243
|
+
| cost | pi-schema | ata | ata interpreter | Ajv | Zod | TypeBox | cfworker | omptype |
|
|
244
|
+
|---|---:|---:|---:|---:|---:|---:|---:|---:|
|
|
245
|
+
| compile a new schema | 20 µs | 4.9 µs | 1.3 µs | 1.4 ms | 151 µs | 210 µs | 22 µs | 28 µs |
|
|
246
|
+
| its first check | 0.8 µs | 335 µs | 87 µs | 195 µs | 466 µs | 41 µs | 7.1 µs | 109 µs |
|
|
247
|
+
| memory, 3,200 distinct schemas | 7.1 MB | 36.0 MB | 51.3 MB | 59.7 MB | 170.8 MB | 54.7 MB | 7.6 MB | 19.9 MB |
|
|
248
|
+
| bundle, minified + gzip | 8.5 KB | 134.0 KB | 134.0 KB | 39.7 KB | 24.4 KB | 35.2 KB | 5.8 KB | 38.8 KB |
|
|
249
|
+
|
|
250
|
+
Where code generation is unavailable:
|
|
251
|
+
|
|
252
|
+
- **ata** answers through its interpreted engine without being told. That automatic fallback measured slower than the
|
|
253
|
+
engine chosen with `engine: "interpreter"`.
|
|
254
|
+
- **Ajv** cannot compile at all: `compile()` throws `EvalError`.
|
|
255
|
+
- **Zod** notices and parses objects without its generated code.
|
|
256
|
+
- **TypeBox** falls back to its interpreter.
|
|
257
|
+
- **omptype** throws `EvalError` once per schema, then validates through its interpreter.
|
|
258
|
+
|
|
259
|
+
ata, Zod and omptype compile on a schema's first check, so their compile cost shows there. ata's bundle is for the
|
|
260
|
+
browser without code splitting; with splitting, its first load is about 53 KB plus a 76 KB generator chunk loaded
|
|
261
|
+
later.
|
|
262
|
+
|
|
263
|
+
Zod is not a JSON Schema validator:
|
|
264
|
+
|
|
265
|
+
- **Speed, setup and memory:** Zod gets the same schemas written as native Zod schemas (`z.strictObject`,
|
|
266
|
+
`z.discriminatedUnion`, `z.lazy`), with `.describe()` for the corpus descriptions, and `safeParse` as the check.
|
|
267
|
+
Its memory includes building the schemas, which the other libraries receive as JSON. Without the descriptions it
|
|
268
|
+
is 131 MB.
|
|
269
|
+
- **Test suite:** through `z.fromJSONSchema`, which is semi-experimental. It refuses `unevaluatedProperties`,
|
|
270
|
+
`unevaluatedItems`, `dependentSchemas`, `dependentRequired`, `if`/`then`/`else`, `not`, and every `$ref` that is
|
|
271
|
+
not local. A refused schema fails all its tests: 405 of the 1,298 draft 2020-12 core tests and 107 of the 925 draft
|
|
272
|
+
7 core tests.
|
|
273
|
+
- **Bundle:** measured with Zod's documented `import * as z from "zod"`. A named `import { z }` keeps every locale
|
|
274
|
+
(about 90 KB gzipped), and `z.fromJSONSchema` brings it to 40.0 KB; `zod/mini` is about 6 KB.
|
|
275
|
+
|
|
276
|
+
Flat objects of simple types check in 13–80 ns, against 7–15 ns for TypeBox. Without code generation, reading a
|
|
277
|
+
property whose name comes from a list costs a few nanoseconds.
|
|
278
|
+
|
|
279
|
+
### Reproduce
|
|
280
|
+
|
|
281
|
+
`npm run bench` in `packages/schema` takes about 12 minutes. It runs every library through its fastest boolean path
|
|
282
|
+
(ata's `isValidObject()`) and keeps the object each returns. ata runs with `ATA_NO_NATIVE=1`: its optional native
|
|
283
|
+
addon only serves its buffer APIs. The scripts are in `test/bench/`.
|
|
284
|
+
|
|
285
|
+
- **Conformance:** every library on the vendored test suite, with the remote documents and meta-schemas the tests
|
|
286
|
+
reference (Zod through `z.fromJSONSchema`, which takes no remote documents). ata reads the draft only from `$schema`, so draft 7 schemas without one get it declared. ata's defaults
|
|
287
|
+
(`useDefaults`, `assertFormat`) are turned off to match the other libraries; formats are checked only in the
|
|
288
|
+
format tests, by each library's own checks.
|
|
289
|
+
- **Speed:** realistic schemas, in ns per check after warm-up. Each result is the median of 15 rounds, with the
|
|
290
|
+
libraries' order rotated in each round.
|
|
291
|
+
- **Speed without eval:** the same, run with `--disallow-code-generation-from-strings`.
|
|
292
|
+
- **Setup:** compiling 1,000 schemas a library has not seen, and their first checks.
|
|
293
|
+
- **Memory:** 3,200 distinct tool-like schemas, compiled and each checked 3 times, each library in its own process.
|
|
294
|
+
- **Size:** esbuild browser bundles of what a validator needs, minified and gzipped.
|
|
295
|
+
|
|
296
|
+
### Code generated at build time
|
|
297
|
+
|
|
298
|
+
Ajv (`ajv/dist/standalone`) and ata (`ata build`, `ata compile`, `toStandaloneModule()`) can also generate their
|
|
299
|
+
validation code when the app is built. The app then imports plain modules and evaluates nothing at run time, so those
|
|
300
|
+
checks run at code-generation speed under a strict CSP. This is not in the benchmark, because it is a different
|
|
301
|
+
deal:
|
|
302
|
+
|
|
303
|
+
- **A build step per schema.** Every schema must be known when the app is built. Schemas that arrive at run time
|
|
304
|
+
(MCP servers, extensions, user input) cannot be validated this way.
|
|
305
|
+
- **Code per schema.** In a separate measurement on the same 3,200 schemas:
|
|
306
|
+
- Ajv: 1.8 ms to build and 8.9 KB of JavaScript per schema;
|
|
307
|
+
- ata: 1.1 ms and 13 KB per schema, or 0.3–0.8 KB gzipped when only its `isValid` export is bundled;
|
|
308
|
+
- importing all 3,200 generated validators took 40 MB of heap (Ajv, one module) and 68 MB (ata, one module per
|
|
309
|
+
schema).
|
|
310
|
+
|
|
311
|
+
pi-schema compiles at run time in 25 µs per schema, generates no code, and covers schemas known at build time and
|
|
312
|
+
schemas that arrive later.
|
|
313
|
+
|
|
314
|
+
## Development
|
|
315
|
+
|
|
316
|
+
`npm test` runs the official test suite (drafts 2020-12 and 7, including the optional and format tests, vendored in
|
|
317
|
+
`test/fixtures/`) and the package's own tests.
|
|
318
|
+
|
|
319
|
+
The format checks are adapted from TypeBox 1.3.27 (MIT); its license is in `THIRD_PARTY_NOTICES/`.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
TypeBox
|
|
2
|
+
|
|
3
|
+
The MIT License (MIT)
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2017-2026 Haydn Paterson
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var A=Object.defineProperty;var u=(t,e)=>A(t,"name",{value:e,configurable:!0});import{isObject as p}from"./checks.js";function a(){return{props:null,allProps:!1,items:0,allItems:!1,indexes:null}}u(a,"newAnnotations");function d(t,e){if(e.props!==null)for(const n of e.props)h(t,n);if(t.allProps||=e.allProps,e.items>t.items&&(t.items=e.items),t.allItems||=e.allItems,e.indexes!==null)for(const n of e.indexes)m(t,n)}u(d,"merge");function h(t,e){t.props===null&&(t.props=new Set),t.props.add(e)}u(h,"addProp");function m(t,e){t.indexes===null&&(t.indexes=new Set),t.indexes.add(e)}u(m,"addIndex");const I=u(()=>!0,"ANNOTATING_TRUE"),O=u(()=>!1,"ANNOTATING_FALSE");function y(t){return(e,n)=>t.check(e,n)}u(y,"indirectAnnotating");function P(t){return e=>t(e)}u(P,"ignoreAnnotations");function j(t){return e=>t(e,a())}u(j,"withFreshAnnotations");function w(t,e,n){return(r,o)=>{t.push(e);const s=n(r,o);return t.pop(),s}}u(w,"scopedAnnotating");function N(t){return(e,n)=>{const r=a();return t(e,r)?(d(n,r),!0):!1}}u(N,"isolateAnnotations");function T(t,e){return(n,r)=>{if(!t(n))return!1;for(let o=0;o<e.length;o++)if(!e[o](n,r))return!1;return!0}}u(T,"annotateAll");function S(t,e,n){const r=new Set(t.map(([o])=>o));return(o,s)=>{if(!p(o))return!0;const l=[];for(const[i,f]of t)if(Object.hasOwn(o,i)){if(!f(o[i]))return!1;l.push(i)}for(const i of Object.keys(o)){let f=r.has(i);for(const[c,x]of e)if(c.test(i)){if(!x(o[i]))return!1;f=!0,l.push(i)}if(!f&&n!==void 0){if(!n(o[i]))return!1;l.push(i)}}for(const i of l)h(s,i);return!0}}u(S,"annotateObject");function b(t,e,n,r,o){return(s,l)=>{if(!Array.isArray(s))return!0;const i=Math.min(s.length,t.length);for(let f=0;f<i;f++)if(!t[f](s[f]))return!1;if(e!==void 0){for(let f=t.length;f<s.length;f++)if(!e(s[f]))return!1;l.allItems=!0}if(i>l.items&&(l.items=i),n!==void 0){let f=0;for(let c=0;c<s.length;c++)n(s[c])&&(f++,m(l,c));if(f<r||f>o)return!1}return!0}}u(b,"annotateArray");function E(t,e){return(n,r)=>{let o=0;for(const s of t){const l=a();s(n,l)&&(o++,d(r,l))}return e?o===1:o>0}}u(E,"annotateAny");function F(t,e,n){return(r,o)=>{const s=a();return t(r,s)?(d(o,s),e===void 0||e(r,o)):n===void 0||n(r,o)}}u(F,"annotateIf");function G(t,e){return(n,r)=>!p(n)||!Object.hasOwn(n,t)||e(n,r)}u(G,"annotateDependent");function _(t){return(e,n)=>{if(!p(e)||n.allProps)return!0;for(const r of Object.keys(e))if(!(n.props?.has(r)??!1)&&!t(e[r]))return!1;return n.allProps=!0,!0}}u(_,"unevaluatedProperties");function D(t){return(e,n)=>{if(!Array.isArray(e)||n.allItems)return!0;for(let r=n.items;r<e.length;r++)if(!(n.indexes?.has(r)??!1)&&!t(e[r]))return!1;return n.allItems=!0,!0}}u(D,"unevaluatedItems");export{O as ANNOTATING_FALSE,I as ANNOTATING_TRUE,T as annotateAll,E as annotateAny,b as annotateArray,G as annotateDependent,F as annotateIf,S as annotateObject,P as ignoreAnnotations,y as indirectAnnotating,N as isolateAnnotations,a as newAnnotations,w as scopedAnnotating,D as unevaluatedItems,_ as unevaluatedProperties,j as withFreshAnnotations};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { TypeBoxStatic } from "./typebox-static.ts";
|
|
2
|
+
declare const STATIC: unique symbol;
|
|
3
|
+
declare const OPTIONAL_TYPE: unique symbol;
|
|
4
|
+
export type Schema<T = unknown> = {
|
|
5
|
+
readonly [keyword: string]: unknown;
|
|
6
|
+
} & {
|
|
7
|
+
readonly [STATIC]?: T;
|
|
8
|
+
};
|
|
9
|
+
export type Static<S> = S extends {
|
|
10
|
+
readonly "~kind": unknown;
|
|
11
|
+
} | {
|
|
12
|
+
readonly "~unsafe": unknown;
|
|
13
|
+
} ? TypeBoxStatic<S> : S extends {
|
|
14
|
+
readonly [STATIC]?: infer T;
|
|
15
|
+
} ? unknown extends T ? unknown : T : unknown;
|
|
16
|
+
export interface Annotations<T = unknown> {
|
|
17
|
+
readonly title?: string;
|
|
18
|
+
readonly description?: string;
|
|
19
|
+
readonly examples?: readonly T[];
|
|
20
|
+
readonly deprecated?: boolean;
|
|
21
|
+
readonly default?: T;
|
|
22
|
+
}
|
|
23
|
+
export interface LengthBounds {
|
|
24
|
+
readonly minLength?: number;
|
|
25
|
+
readonly maxLength?: number;
|
|
26
|
+
}
|
|
27
|
+
export declare function str(options?: Annotations<string> & LengthBounds & {
|
|
28
|
+
readonly pattern?: string;
|
|
29
|
+
readonly format?: string;
|
|
30
|
+
}): Schema<string>;
|
|
31
|
+
export interface NumberBounds {
|
|
32
|
+
readonly minimum?: number;
|
|
33
|
+
readonly maximum?: number;
|
|
34
|
+
readonly exclusiveMinimum?: number;
|
|
35
|
+
readonly exclusiveMaximum?: number;
|
|
36
|
+
readonly multipleOf?: number;
|
|
37
|
+
}
|
|
38
|
+
export declare function num(options?: Annotations<number> & NumberBounds): Schema<number>;
|
|
39
|
+
export declare function int(options?: Annotations<number> & NumberBounds): Schema<number>;
|
|
40
|
+
export interface BigintBounds {
|
|
41
|
+
readonly minimum?: bigint;
|
|
42
|
+
readonly maximum?: bigint;
|
|
43
|
+
readonly exclusiveMinimum?: bigint;
|
|
44
|
+
readonly exclusiveMaximum?: bigint;
|
|
45
|
+
readonly multipleOf?: bigint;
|
|
46
|
+
}
|
|
47
|
+
export declare function bigint(options?: Annotations<bigint> & BigintBounds): Schema<bigint>;
|
|
48
|
+
export declare function bool(options?: Annotations<boolean>): Schema<boolean>;
|
|
49
|
+
export declare function nul(options?: Annotations<null>): Schema<null>;
|
|
50
|
+
export declare function unknown(options?: Annotations): Schema<unknown>;
|
|
51
|
+
export declare function lit<const V extends string | number | boolean | null>(value: V, options?: Annotations<V>): Schema<V>;
|
|
52
|
+
export declare function oneOf<const V extends readonly (string | number | boolean | null)[]>(values: V, options?: Annotations<V[number]>): Schema<V[number]>;
|
|
53
|
+
export declare function union<const S extends readonly Schema[]>(schemas: S, options?: Annotations<Static<S[number]>>): Schema<Static<S[number]>>;
|
|
54
|
+
export declare function nullable<T>(schema: Schema<T>, options?: Annotations<T | null>): Schema<T | null>;
|
|
55
|
+
export declare function arr<T>(items: Schema<T>, options?: Annotations<T[]> & {
|
|
56
|
+
readonly minItems?: number;
|
|
57
|
+
readonly maxItems?: number;
|
|
58
|
+
readonly uniqueItems?: boolean;
|
|
59
|
+
}): Schema<T[]>;
|
|
60
|
+
export declare function tuple<const S extends readonly Schema[]>(items: S, options?: Annotations<{
|
|
61
|
+
-readonly [K in keyof S]: Static<S[K]>;
|
|
62
|
+
}>): Schema<{
|
|
63
|
+
-readonly [K in keyof S]: Static<S[K]>;
|
|
64
|
+
}>;
|
|
65
|
+
export declare function map<T>(value: Schema<T>, options?: Annotations<Record<string, T>>): Schema<Record<string, T>>;
|
|
66
|
+
export declare function unsafe<T>(schema?: Schema): Schema<T>;
|
|
67
|
+
export declare function recursive<T>(id: string, build: (self: Schema<T>) => Schema<T>): Schema<T>;
|
|
68
|
+
export declare function bytes(options?: Annotations<Uint8Array> & LengthBounds): Schema<Uint8Array>;
|
|
69
|
+
export declare class Optional<S extends Schema = Schema> {
|
|
70
|
+
readonly [OPTIONAL_TYPE]?: S;
|
|
71
|
+
readonly schema: S;
|
|
72
|
+
constructor(schema: S);
|
|
73
|
+
}
|
|
74
|
+
export declare function opt<S extends Schema>(schema: S): Optional<S>;
|
|
75
|
+
export type Properties = {
|
|
76
|
+
readonly [name: string]: Schema | Optional;
|
|
77
|
+
};
|
|
78
|
+
export type StaticObject<P extends Properties> = Simplify<{
|
|
79
|
+
-readonly [K in keyof P as P[K] extends Optional ? never : K]: Static<P[K]>;
|
|
80
|
+
} & {
|
|
81
|
+
-readonly [K in keyof P as P[K] extends Optional ? K : never]?: P[K] extends Optional<infer S> ? Static<S> : never;
|
|
82
|
+
}>;
|
|
83
|
+
type Simplify<T> = {
|
|
84
|
+
[K in keyof T]: T[K];
|
|
85
|
+
} & {};
|
|
86
|
+
export declare function obj<const P extends Properties>(properties: P, options?: Annotations<StaticObject<P>> & {
|
|
87
|
+
readonly open?: boolean;
|
|
88
|
+
}): Schema<StaticObject<P>>;
|
|
89
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var s=Object.defineProperty;var e=(t,n)=>s(t,"name",{value:n,configurable:!0});function l(t={}){return{type:"string",...t}}e(l,"str");function x(t={}){return{type:"number",...t}}e(x,"num");function y(t={}){return{type:"integer",...t}}e(y,"int");function b(t={}){return{type:"bigint",...t}}e(b,"bigint");function m(t={}){return{type:"boolean",...t}}e(m,"bool");function h(t={}){return{type:"null",...t}}e(h,"nul");function g(t={}){return{...t}}e(g,"unknown");function d(t,n={}){return{const:t,...n}}e(d,"lit");function O(t,n={}){return{enum:t,...n}}e(O,"oneOf");function j(t,n={}){return{anyOf:t,...n}}e(j,"union");function w(t,n={}){return{anyOf:[t,{type:"null"}],...n}}e(w,"nullable");function I(t,n={}){return{type:"array",items:t,...n}}e(I,"arr");function P(t,n={}){return{type:"array",prefixItems:t,items:!1,minItems:t.length,...n}}e(P,"tuple");function $(t,n={}){return{type:"object",additionalProperties:t,...n}}e($,"map");function k(t={}){return t}e(k,"unsafe");function q(t,n){return{...n({$ref:t}),$id:t}}e(q,"recursive");function v(t={}){return{type:"bytes",...t}}e(v,"bytes");class i{static{e(this,"Optional")}schema;constructor(n){this.schema=n}}function z(t){return new i(t)}e(z,"opt");function A(t,n={}){const{open:c,...f}=n,r={},o=[];for(const[u,p]of Object.entries(t))p instanceof i?r[u]=p.schema:(r[u]=p,o.push(u));return{type:"object",properties:r,...o.length>0?{required:o}:{},...c===!0?{}:{additionalProperties:!1},...f}}e(A,"obj");export{i as Optional,I as arr,b as bigint,m as bool,v as bytes,y as int,d as lit,$ as map,h as nul,w as nullable,x as num,A as obj,O as oneOf,z as opt,q as recursive,l as str,P as tuple,j as union,g as unknown,k as unsafe};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Check } from "./types.ts";
|
|
2
|
+
export declare const ALWAYS: Check;
|
|
3
|
+
export declare const NEVER: Check;
|
|
4
|
+
export declare const IS_ARRAY: Check;
|
|
5
|
+
export declare const IS_OBJECT: Check;
|
|
6
|
+
export declare function isObject(v: unknown): v is Record<string, unknown>;
|
|
7
|
+
export declare const TYPE_CHECKS: ReadonlyMap<string, Check>;
|
|
8
|
+
export type Leaf = readonly [code: number, arg: unknown];
|
|
9
|
+
export declare function leafOf(check: Check): Leaf | undefined;
|
|
10
|
+
export declare const GUARD_NONE = 0;
|
|
11
|
+
export declare const GUARD_STRICT = 1;
|
|
12
|
+
export declare const GUARD_LOOSE = 2;
|
|
13
|
+
export type Guard = typeof GUARD_NONE | typeof GUARD_STRICT | typeof GUARD_LOOSE;
|
|
14
|
+
export declare const CODE = 15;
|
|
15
|
+
export declare const REQUIRED = 16;
|
|
16
|
+
export declare const INHERITED = 32;
|
|
17
|
+
export declare function and(parts: readonly Check[]): Check;
|
|
18
|
+
export declare function indirect(slot: {
|
|
19
|
+
check: Check | undefined;
|
|
20
|
+
}): Check;
|
|
21
|
+
export declare function scopedCheck(scope: string[], uri: string, check: Check): Check;
|
|
22
|
+
export declare function typeCheck(types: readonly unknown[]): Check;
|
|
23
|
+
export declare function typeMask(types: readonly unknown[]): number;
|
|
24
|
+
export declare function maskedAnyCheck(mask: number, checks: readonly Check[]): Check;
|
|
25
|
+
export declare function bytesCheck(min: number, max: number): Check;
|
|
26
|
+
export declare function codePoints(s: string): number;
|
|
27
|
+
export declare function stringCheck(strict: boolean, min: number, max: number, re: RegExp | undefined, format: ((value: string) => boolean) | undefined): Check;
|
|
28
|
+
export type Bound = number | bigint;
|
|
29
|
+
export declare function numberCheck(mode: 0 | 1 | 2 | 3, min: Bound, max: Bound, xmin: Bound, xmax: Bound, multipleOf: Bound | undefined): Check;
|
|
30
|
+
export declare function isMultiple(v: Bound, d: Bound): boolean;
|
|
31
|
+
export declare function guardObject(inner: Check, strict: boolean): Check;
|
|
32
|
+
export declare function guardArray(inner: Check, strict: boolean): Check;
|
|
33
|
+
export declare function declaredObject(entries: readonly unknown[], requiredCount: number, closed: boolean, guard: Guard): Check;
|
|
34
|
+
export declare function openObject(entries: readonly unknown[], keys: readonly string[], extraRequired: readonly string[], patterns: readonly (readonly [RegExp, Check])[], additional: Check | undefined, guard: Guard): Check;
|
|
35
|
+
export declare function propertyNamesCheck(check: Check): Check;
|
|
36
|
+
export declare function propertyCountCheck(min: number, max: number): Check;
|
|
37
|
+
export declare function dependentRequiredCheck(entries: readonly (readonly [string, readonly string[]])[]): Check;
|
|
38
|
+
export declare function dependentSchemasCheck(entries: readonly (readonly [string, Check])[]): Check;
|
|
39
|
+
export declare function listCheck(guard: Guard, min: number, max: number, prefix: readonly Check[], rest: Check | undefined): Check;
|
|
40
|
+
export declare function itemsCheck(prefix: readonly Check[], rest: Check | undefined): Check;
|
|
41
|
+
export declare function lengthCheck(min: number, max: number): Check;
|
|
42
|
+
export declare function containsCheck(check: Check, min: number, max: number): Check;
|
|
43
|
+
export declare function uniqueCheck(v: unknown): boolean;
|
|
44
|
+
export declare function enumCheck(values: readonly unknown[]): Check;
|
|
45
|
+
export declare function constCheck(value: unknown): Check;
|
|
46
|
+
export declare function anyCheck(checks: readonly Check[]): Check;
|
|
47
|
+
export declare function oneCheck(checks: readonly Check[]): Check;
|
|
48
|
+
export declare function notCheck(check: Check): Check;
|
|
49
|
+
export declare function ifCheck(cond: Check, then: Check, otherwise: Check): Check;
|
|
50
|
+
export declare function taggedCheck(key: string, tags: readonly unknown[], checks: readonly Check[]): Check;
|
|
51
|
+
export declare function deepEqual(a: unknown, b: unknown): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var M=Object.defineProperty;var u=(e,t)=>M(e,"name",{value:t,configurable:!0});const C=u(()=>!0,"ALWAYS"),Y=u(()=>!1,"NEVER"),j=u(e=>typeof e=="string","IS_STRING"),E=u(e=>Number.isFinite(e),"IS_NUMBER"),m=u(e=>Number.isInteger(e),"IS_INTEGER"),S=u(e=>typeof e=="boolean","IS_BOOLEAN"),w=u(e=>e===null,"IS_NULL"),G=u(e=>Array.isArray(e),"IS_ARRAY"),L=u(e=>e instanceof Uint8Array,"IS_BYTES"),P=u(e=>typeof e=="bigint","IS_BIGINT"),q=u(e=>e===void 0,"IS_UNDEFINED"),V=u(e=>g(e),"IS_OBJECT");function g(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof Uint8Array)}u(g,"isObject");const H=new Map([["string",j],["number",E],["integer",m],["boolean",S],["null",w],["array",G],["object",V],["bytes",L],["bigint",P],["undefined",q]]),_=new WeakMap([[j,[1,void 0]],[E,[2,void 0]],[m,[3,void 0]],[S,[4,void 0]],[w,[5,void 0]],[C,[6,void 0]]]);function W(e){return _.get(e)}u(W,"leafOf");function d(e,t,n){return _.set(n,[e,t]),n}u(d,"leaf");class T{static{u(this,"Bounds")}min;max;xmin;xmax;constructor(t,n,r,o){this.min=t,this.max=n,this.xmin=r,this.xmax=o}}function x(e,t,n){switch(e){case 1:return typeof t=="string";case 2:return Number.isFinite(t);case 3:return Number.isInteger(t);case 4:return typeof t=="boolean";case 5:return t===null;case 7:return t===n;case 8:{const r=n;for(let o=0;o<r.length;o++)if(r[o]===t)return!0;return!1}case 9:return(O(t)&n)!==0;case 10:return Number.isInteger(t)&&B(t,n);case 11:return Number.isFinite(t)&&B(t,n);case 12:return typeof t=="string"&&k(t,n.min,n.max);case 13:return typeof t=="string"&&n.test(t);default:return!0}}u(x,"leafOk");function B(e,t){return e>=t.min&&e<=t.max&&e>t.xmin&&e<t.xmax}u(B,"inBounds");const N=0,ee=1,A=2,R=15,I=16,J=32;function te(e){switch(e.length){case 0:return C;case 1:return e[0];case 2:{const[t,n]=e;return r=>t(r)&&n(r)}case 3:{const[t,n,r]=e;return o=>t(o)&&n(o)&&r(o)}default:return t=>{for(let n=0;n<e.length;n++)if(!e[n](t))return!1;return!0}}}u(te,"and");function ne(e){return t=>e.check(t)}u(ne,"indirect");function re(e,t,n){return r=>{e.push(t);const o=n(r);return e.pop(),o}}u(re,"scopedCheck");function oe(e){return e.length===1?(typeof e[0]=="string"?H.get(e[0]):void 0)??Y:U(Q(e))}u(oe,"typeCheck");const K=new Map([["string",1],["number",2],["integer",4],["boolean",8],["null",16],["array",32],["object",64],["bytes",128],["bigint",256],["undefined",512]]);function Q(e){let t=0;for(const n of e)typeof n=="string"&&(t|=K.get(n)??0);return t}u(Q,"typeMask");function O(e){switch(typeof e){case"string":return 1;case"number":return Number.isInteger(e)?6:Number.isFinite(e)?2:0;case"boolean":return 8;case"object":return e===null?16:Array.isArray(e)?32:e instanceof Uint8Array?128:64;case"bigint":return 256;case"undefined":return 512;default:return 0}}u(O,"typeBits");function U(e){return d(9,e,t=>(O(t)&e)!==0)}u(U,"maskCheck");function ue(e,t){if(t.length===0)return U(e);const n=t.length===1?t[0]:$(t);return r=>(O(r)&e)!==0||n(r)}u(ue,"maskedAnyCheck");function ie(e,t){return n=>n instanceof Uint8Array&&n.length>=e&&n.length<=t}u(ie,"bytesCheck");function F(e){let t=0;for(let n=0;n<e.length;n++,t++){const r=e.charCodeAt(n);if(r>=55296&&r<=56319&&n+1<e.length){const o=e.charCodeAt(n+1);o>=56320&&o<=57343&&n++}}return t}u(F,"codePoints");function k(e,t,n){const r=e.length;return r<t||r<2*t&&F(e)<t?!1:r<=n||F(e)<=n}u(k,"lengthOk");function fe(e,t,n,r,o){return r!==void 0&&t===0&&n===Number.POSITIVE_INFINITY&&o===void 0?e?d(13,r,i=>typeof i=="string"&&r.test(i)):i=>typeof i!="string"||r.test(i):r===void 0&&o===void 0?e?d(12,new T(t,n,0,0),i=>typeof i=="string"&&k(i,t,n)):i=>typeof i!="string"||k(i,t,n):i=>typeof i!="string"?!e:k(i,t,n)&&(r===void 0||r.test(i))&&(o===void 0||o(i))}u(fe,"stringCheck");function ce(e,t,n,r,o,i){const c=u(f=>typeof f!="number"&&typeof f!="bigint"?e===0:(e===3?typeof f!="bigint":e!==0&&!Number.isFinite(f))||e===2&&!Number.isInteger(f)?!1:f>=t&&f<=n&&f>r&&f<o&&(i===void 0||z(f,i)),"check");return e===0||e===3||i!==void 0||!(typeof t=="number"&&typeof n=="number"&&typeof r=="number"&&typeof o=="number")?c:d(e===2?10:11,new T(t,n,r,o),c)}u(ce,"numberCheck");function z(e,t){if(typeof e=="bigint"||typeof t=="bigint"){if(typeof e=="number"&&!Number.isInteger(e)||typeof t=="number"&&!Number.isInteger(t))return!1;const p=BigInt(t);return p!==0n&&BigInt(e)%p===0n}const n=e/t;if(Number.isInteger(n))return!0;if(!Number.isFinite(n))return e%t===0;const[r,o]=D(e),[i,c]=D(t);return o>=c?r*10n**BigInt(o-c)%i===0n:r%(i*10n**BigInt(c-o))===0n}u(z,"isMultiple");function D(e){const[t,n="0"]=Math.abs(e).toString().split("e"),r=t.indexOf("."),o=r<0?0:t.length-r-1;return[BigInt(t.replace(".","")),Number(n)-o]}u(D,"decimal");function se(e,t){return t?n=>g(n)&&e(n):n=>!g(n)||e(n)}u(se,"guardObject");function le(e,t){return t?n=>Array.isArray(n)&&e(n):n=>!Array.isArray(n)||e(n)}u(le,"guardArray");function ae(e,t,n,r){const o=e.length;return i=>{if(r!==N&&!g(i))return r===A;const c=i;let p=0,f=0;for(const s in c){let a=f;if(e[a]!==s){for(a=0;a<o&&e[a]!==s;)a+=3;if(a===o){if(n)return!1;continue}}f=a+3;const l=c[s],h=e[a+2];if(l===void 0&&!(h&I))continue;const y=h&R;if(y!==0?!x(y,l,e[a+1]):!e[a+1](l))return!1;h&I&&p++}return p===t}}u(ae,"declaredObject");function pe(e,t,n,r,o,i){const c=r.length>0||o!==void 0?new Set(t):void 0;return p=>{if(i!==N&&!g(p))return i===A;const f=p;for(let s=0;s<e.length;s+=3){const a=e[s],l=f[a],h=e[s+2];if(l===void 0&&!(h&I&&Object.hasOwn(f,a))||h&J&&!Object.hasOwn(f,a)){if(h&I)return!1;continue}const y=h&R;if(y!==0?!x(y,l,e[s+1]):!e[s+1](l))return!1}for(let s=0;s<n.length;s++)if(!Object.hasOwn(f,n[s]))return!1;if(c===void 0)return!0;for(const s of Object.keys(f)){let a=c.has(s);for(let l=0;l<r.length;l++)if(r[l][0].test(s)&&(a=!0,!r[l][1](f[s])))return!1;if(!a&&o!==void 0&&!o(f[s]))return!1}return!0}}u(pe,"openObject");function he(e){return t=>{for(const n in t)if(!e(n))return!1;return!0}}u(he,"propertyNamesCheck");function ge(e,t){return n=>{let r=0;for(const o in n)r++;return r>=e&&r<=t}}u(ge,"propertyCountCheck");function de(e){return t=>{const n=t;for(const[r,o]of e)if(Object.hasOwn(n,r)){for(const i of o)if(!Object.hasOwn(n,i))return!1}return!0}}u(de,"dependentRequiredCheck");function ye(e){return t=>{for(const[n,r]of e)if(Object.hasOwn(t,n)&&!r(t))return!1;return!0}}u(ye,"dependentSchemasCheck");const X=[0,void 0];function Z(e,t,n,r,o){const i=r.length,[c,p]=(o===void 0?void 0:W(o))??X;return f=>{if(!Array.isArray(f))return e===A;const s=f.length;if(s<t||s>n)return!1;const a=s<i?s:i;for(let l=0;l<a;l++)if(!r[l](f[l]))return!1;if(o===void 0)return!0;if(c!==0){for(let l=i;l<s;l++)if(!x(c,f[l],p))return!1;return!0}for(let l=i;l<s;l++)if(!o(f[l]))return!1;return!0}}u(Z,"listCheck");function be(e,t){return Z(N,0,Number.POSITIVE_INFINITY,e,t)}u(be,"itemsCheck");function Ie(e,t){return n=>n.length>=e&&n.length<=t}u(Ie,"lengthCheck");function ke(e,t,n){return r=>{const o=r;let i=0;for(let c=0;c<o.length;c++)if(e(o[c])&&++i>n)return!1;return i>=t}}u(ke,"containsCheck");function xe(e){const t=e;for(let n=1;n<t.length;n++)for(let r=0;r<n;r++)if(b(t[n],t[r]))return!1;return!0}u(xe,"uniqueCheck");function Ne(e){const t=e.filter(o=>typeof o!="object"||o===null);if(t.length===e.length&&t.length<=8)return d(8,t,o=>{for(let i=0;i<t.length;i++)if(t[i]===o)return!0;return!1});const n=new Set(t),r=e.filter(o=>typeof o=="object"&&o!==null);return o=>n.has(o)||typeof o=="object"&&r.some(i=>b(o,i))}u(Ne,"enumCheck");function Ae(e){return typeof e!="object"||e===null?d(7,e,t=>t===e):t=>b(t,e)}u(Ae,"constCheck");function $(e){return t=>{for(let n=0;n<e.length;n++)if(e[n](t))return!0;return!1}}u($,"anyCheck");function Oe(e){return t=>{let n=0;for(let r=0;r<e.length;r++)if(e[r](t)&&++n>1)return!1;return n===1}}u(Oe,"oneCheck");function Ce(e){return t=>!e(t)}u(Ce,"notCheck");function je(e,t,n){return r=>e(r)?t(r):n(r)}u(je,"ifCheck");function Ee(e,t,n){return r=>{if(!g(r))return!1;const o=r[e];for(let i=0;i<t.length;i++)if(t[i]===o)return n[i](r);return!1}}u(Ee,"taggedCheck");function b(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){const c=e,p=t;if(c.length!==p.length)return!1;for(let f=0;f<c.length;f++)if(!b(c[f],p[f]))return!1;return!0}const r=e,o=t,i=Object.keys(r);if(i.length!==Object.keys(o).length)return!1;for(const c of i)if(!Object.hasOwn(o,c)||!b(r[c],o[c]))return!1;return!0}u(b,"deepEqual");export{C as ALWAYS,R as CODE,A as GUARD_LOOSE,N as GUARD_NONE,ee as GUARD_STRICT,J as INHERITED,G as IS_ARRAY,V as IS_OBJECT,Y as NEVER,I as REQUIRED,H as TYPE_CHECKS,te as and,$ as anyCheck,ie as bytesCheck,F as codePoints,Ae as constCheck,ke as containsCheck,ae as declaredObject,b as deepEqual,de as dependentRequiredCheck,ye as dependentSchemasCheck,Ne as enumCheck,le as guardArray,se as guardObject,je as ifCheck,ne as indirect,z as isMultiple,g as isObject,be as itemsCheck,W as leafOf,Ie as lengthCheck,Z as listCheck,ue as maskedAnyCheck,Ce as notCheck,ce as numberCheck,Oe as oneCheck,pe as openObject,ge as propertyCountCheck,he as propertyNamesCheck,re as scopedCheck,fe as stringCheck,Ee as taggedCheck,oe as typeCheck,Q as typeMask,xe as uniqueCheck};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var l=Object.defineProperty;var d=(t,r)=>l(t,"name",{value:r,configurable:!0});import{isSchemaObject as h}from"./resolver.js";import{sharedRegex as I}from"./shared.js";class R{static{d(this,"Coercer")}c;schema;entered=[];cuts=0;memo=void 0;constructor(r,n){this.c=r,this.schema=n}coerce(r){const n=this.c.r.rootBase,e=this.dropOptionalNulls(r,this.schema,n);return this.coerceTypes(this.convertOnly(e),this.schema,n)}convertOnly(r){try{return this.convert(this.schema,this.c.r.rootBase,r)}finally{this.memo=void 0,this.cuts=0}}reenter(r,n,e,i){const s=this.entered;for(let f=0;f<s.length;f+=2)if(s[f]===r&&Object.is(s[f+1],e))return this.cuts++,e;const o=i?this.memo?.get(r):void 0;if(o?.has(e))return o.get(e);const p=this.cuts;s.push(r,e);let c;try{c=this.convert(r,n,e)}finally{s.length-=2}if(i&&this.cuts===p){this.memo??=new Map;let f=this.memo.get(r);f===void 0&&(f=new Map,this.memo.set(r,f)),f.set(e,c)}return c}passes(r,n,e){try{return this.c.check(r,this.baseOf(r,n))(e)}catch{return}}baseOf(r,n){return h(r)?this.c.r.baseFor(r,n):n}dropOptionalNulls(r,n,e){if(!h(n))return r;const i=this.baseOf(n,e);if(Array.isArray(r))return A(r,(u,y)=>{const m=j(n,y);return m===void 0?u:this.dropOptionalNulls(u,m,i)});if(!N(r))return r;const s=h(n.properties)?n.properties:{},o=h(n.patternProperties)?Object.entries(n.patternProperties).map(([u,y])=>[I(u),y]):[],p=h(n.additionalProperties)?n.additionalProperties:void 0;if(o.length===0&&p===void 0&&!h(n.properties))return r;const c=new Set(Array.isArray(n.required)?n.required:[]);let f;const b=d((u,y)=>{y!==(f??r)[u]&&(f??={...r},f[u]=y)},"set");for(const[u,y]of Object.entries(s)){if(!Object.hasOwn(r,u))continue;const m=h(y)&&typeof y.$ref=="string";if(r[u]===null&&!c.has(u)&&!m&&this.passes(y,i,null)===!1){f??={...r},delete f[u];continue}b(u,this.dropOptionalNulls(r[u],y,i))}if(o.length>0||p!==void 0)for(const u of Object.keys(r)){let y=Object.hasOwn(s,u);for(const[m,k]of o)m.test(u)&&(y=!0,b(u,this.dropOptionalNulls((f??r)[u],k,i)));!y&&p!==void 0&&b(u,this.dropOptionalNulls(r[u],p,i))}return f??r}convert(r,n,e){if(!h(r))return e;const i=this.baseOf(r,n);if(typeof r.$ref=="string"){let s;try{s=this.c.r.resolve(r.$ref,i)}catch{return e}return h(s.node)?this.reenter(s.node,s.base,e,!0):e}return this.convertNode(r,i,e)}convertNode(r,n,e){if(Object.hasOwn(r,"const"))return w(r.const,e);if(Array.isArray(r.enum))return this.convertEnum(r,r.enum,n,e);if(Array.isArray(r.anyOf))return this.convertUnion(r,r.anyOf,n,e);if(Array.isArray(r.oneOf))return this.convertUnion(r,r.oneOf,n,e);if(Array.isArray(r.allOf)){let i=e;for(const s of r.allOf)i=this.convert(s,n,i);return this.convertMembers(r,n,i)}switch(r.type){case"string":return g(P(e),e);case"number":return g(a(e),e);case"integer":{const i=a(e);return i===void 0?e:Math.trunc(i.value)}case"boolean":return g(x(e),e);case"null":return g(F(e),e);case"bigint":return g(S(e),e);case"undefined":return g(E(e),e);case"array":return this.convertArray(r,n,e);case"object":return this.convertObject(r,n,e);case void 0:return r.properties!==void 0||r.patternProperties!==void 0?this.convertObject(r,n,e):r.items!==void 0||r.prefixItems!==void 0?this.convertArray(r,n,e):e;default:return e}}convertEnum(r,n,e,i){if(n.some(s=>s===i))return i;for(const s of n){const o=w(s,i);if(o!==i&&this.passes(r,e,o)===!0)return o}return i}convertUnion(r,n,e,i){if(n.some(s=>this.passes(s,e,i)===!0))return this.convertMembers(r,e,i);for(const s of n){const o=this.convertMembers(r,e,this.convert(s,e,i));if(this.passes(r,e,o)===!0)return o}return this.convertMembers(r,e,i)}convertMembers(r,n,e){return r.properties!==void 0||r.patternProperties!==void 0||r.additionalProperties!==void 0?this.convertObject(r,n,e):e}convertArray(r,n,e){const i=Array.isArray(r.items)?r.items:Array.isArray(r.prefixItems)?r.prefixItems:void 0;if(i!==void 0){if(!Array.isArray(e))return e;const o=Array.isArray(r.items)?void 0:r.items;return A(e,(p,c)=>{const f=c<i.length?i[c]:o;return f===void 0?p:this.convert(f,n,p)})}if(Array.isArray(e))return r.items===void 0?e:A(e,o=>this.convert(r.items,n,o));const s=r.items;return[h(s)?this.reenter(s,n,e,!1):e]}convertObject(r,n,e){if(!N(e))return e;const i=h(r.properties)?r.properties:{},s=h(r.patternProperties)?Object.entries(r.patternProperties).map(([c,f])=>[I(c),f]):[],o=h(r.additionalProperties)?r.additionalProperties:void 0;let p;for(const c of Object.keys(e)){if(e[c]===void 0)continue;let f=e[c],b=Object.hasOwn(i,c);b&&(f=this.convert(i[c],n,f));for(const[u,y]of s)u.test(c)&&(b=!0,f=this.convert(y,n,f));!b&&o!==void 0&&(f=this.convert(o,n,f)),f!==e[c]&&(p??={...e},p[c]=f)}return p??e}coerceTypes(r,n,e){if(!h(n))return r;const i=this.baseOf(n,e);let s=r;if(Array.isArray(n.allOf))for(const c of n.allOf)s=this.coerceTypes(s,c,i);Array.isArray(n.anyOf)&&(s=this.coerceUnion(s,n.anyOf,i)),Array.isArray(n.oneOf)&&(s=this.coerceUnion(s,n.oneOf,i));const o=U(n),p=o.length>1&&o.some(c=>C(s,c));if(o.length>0&&!p)for(const c of o){const f=L(s,c);if(f!==s){s=f;break}}return o.includes("object")&&N(s)&&(s=this.coerceProperties(s,n,i)),o.includes("array")&&Array.isArray(s)&&(s=this.coerceItems(s,n,i)),s}coerceUnion(r,n,e){for(const i of n)if(this.passes(i,e,r)===!0)return r;for(const i of n){const s=this.coerceTypes(r,i,e);if(this.passes(i,e,s)===!0)return s}return r}coerceProperties(r,n,e){const i=h(n.properties)?n.properties:{},s=h(n.patternProperties)?Object.entries(n.patternProperties).map(([f,b])=>[I(f),b]):[],o=h(n.additionalProperties)?n.additionalProperties:void 0;let p;const c=d((f,b)=>{b!==(p??r)[f]&&(p??={...r},p[f]=b)},"set");for(const[f,b]of Object.entries(i))f in r&&c(f,this.coerceTypes(r[f],b,e));for(const f of Object.keys(r)){let b=Object.hasOwn(i,f);for(const[u,y]of s)u.test(f)&&(b=!0,c(f,this.coerceTypes((p??r)[f],y,e)));!b&&o!==void 0&&c(f,this.coerceTypes(r[f],o,e))}return p??r}coerceItems(r,n,e){return A(r,(i,s)=>{const o=j(n,s);return h(o)?this.coerceTypes(i,o,e):i})}}function j(t,r){return Array.isArray(t.items)?t.items[r]:Array.isArray(t.prefixItems)&&r<t.prefixItems.length?t.prefixItems[r]:t.items}d(j,"itemSchemaAt");function A(t,r){let n;for(let e=0;e<t.length;e++){const i=r(t[e],e);i!==t[e]&&(n??=t.slice(),n[e]=i)}return n??t}d(A,"mapItems");function g(t,r){return t===void 0?r:t.value}d(g,"orValue");function w(t,r){if(t===r)return r;const n=typeof t=="string"?P(r):typeof t=="number"?a(r):typeof t=="boolean"?x(r):typeof t=="bigint"?S(r):void 0;return n!==void 0&&n.value===t?n.value:r}d(w,"convertLiteral");function P(t){if(typeof t=="bigint"||typeof t=="boolean"||O(t))return{value:String(t)};if(t===null)return{value:"null"};if(typeof t=="string")return{value:t};if(t===void 0)return{value:""}}d(P,"tryString");const M=BigInt(Number.MAX_SAFE_INTEGER),T=BigInt(Number.MIN_SAFE_INTEGER);function a(t){if(typeof t=="bigint")return t<=M&&t>=T?{value:Number(t)}:void 0;if(typeof t=="boolean")return{value:t?1:0};if(O(t))return{value:t};if(t==null)return{value:0};if(typeof t!="string")return;const r=+t;if(Number.isFinite(r))return{value:r};const n=t.toLowerCase();if(n==="false")return{value:0};if(n==="true")return{value:1};const e=B(t);return e!==void 0&&e<=M&&e>=T?{value:Number(e)}:void 0}d(a,"tryNumber");function B(t){if(/^-?(0|[1-9]\d*)n$/.test(t))return BigInt(t.slice(0,-1));if(/^-?(0|[1-9]\d*)\.\d+$/.test(t))return BigInt(t.split(".")[0]);if(/^-?(0|[1-9]\d*)$/.test(t))return BigInt(t)}d(B,"bigIntOfString");function S(t){if(typeof t=="bigint")return{value:t};if(typeof t=="boolean")return{value:t?1n:0n};if(O(t))return{value:BigInt(Math.trunc(t))};if(t==null)return{value:0n};if(typeof t!="string")return;const r=B(t);if(r!==void 0)return{value:r};const n=t.toLowerCase();return n==="false"?{value:0n}:n==="true"?{value:1n}:void 0}d(S,"tryBigInt");function E(t){if(t==null||t===0n||t===!1||t===0)return{value:void 0};if(typeof t!="string")return;const r=t.toLowerCase();return r==="undefined"||r==="null"||t===""||t==="0"?{value:void 0}:void 0}d(E,"tryUndefined");function x(t){if(typeof t=="bigint")return t===0n?{value:!1}:t===1n?{value:!0}:void 0;if(typeof t=="boolean")return{value:t};if(O(t))return t===0?{value:!1}:t===1?{value:!0}:void 0;if(t==null)return{value:!1};if(typeof t!="string")return;const r=t.toLowerCase();if(r==="false"||t==="0")return{value:!1};if(r==="true"||t==="1")return{value:!0}}d(x,"tryBoolean");function F(t){if(typeof t=="bigint")return t===0n?{value:null}:void 0;if(typeof t=="boolean")return t===!1?{value:null}:void 0;if(O(t))return t===0?{value:null}:void 0;if(t==null)return{value:null};if(typeof t!="string")return;const r=t.toLowerCase();return r==="undefined"||r==="null"||t===""||t==="0"?{value:null}:void 0}d(F,"tryNull");function O(t){return typeof t=="number"&&Number.isFinite(t)}d(O,"isFiniteNumber");function U(t){return typeof t.type=="string"?[t.type]:Array.isArray(t.type)?t.type.filter(r=>typeof r=="string"):[]}d(U,"typesOf");function C(t,r){switch(r){case"number":return Number.isFinite(t);case"integer":return typeof t=="number"&&Number.isInteger(t);case"boolean":return typeof t=="boolean";case"string":return typeof t=="string";case"null":return t===null;case"bigint":return typeof t=="bigint";case"undefined":return t===void 0;case"array":return Array.isArray(t);case"object":return N(t);default:return!1}}d(C,"matchesType");function L(t,r){switch(r){case"number":case"integer":{if(t===null)return 0;if(typeof t=="string"&&t.trim()!==""){const n=Number(t);if(r==="number"?Number.isFinite(n):Number.isInteger(n))return n}return typeof t=="boolean"?t?1:0:t}case"boolean":return t===null?!1:t==="true"||t===1?!0:t==="false"||t===0?!1:t;case"string":return t===null?"":typeof t=="number"||typeof t=="boolean"?String(t):t;case"null":return t===""||t===0||t===!1?null:t;default:return t}}d(L,"coercePrimitive");function N(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}d(N,"isPlainObject");export{R as Coercer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var v=Object.defineProperty;var y=(h,e)=>v(h,"name",{value:e,configurable:!0});import{ANNOTATING_FALSE as _,ANNOTATING_TRUE as F,annotateAll as G,annotateAny as P,annotateArray as Y,annotateDependent as q,annotateIf as L,annotateObject as V,ignoreAnnotations as D,indirectAnnotating as M,isolateAnnotations as U,scopedAnnotating as R,unevaluatedItems as B,unevaluatedProperties as J,withFreshAnnotations as K}from"./annotations.js";import{ALWAYS as A,and as O,anyCheck as W,bytesCheck as H,constCheck as z,containsCheck as Q,declaredObject as X,dependentRequiredCheck as Z,dependentSchemasCheck as ee,enumCheck as x,GUARD_LOOSE as S,GUARD_NONE as te,GUARD_STRICT as b,guardArray as ne,guardObject as ie,INHERITED as re,IS_ARRAY as se,IS_OBJECT as ce,ifCheck as fe,indirect as ue,itemsCheck as ae,leafOf as oe,lengthCheck as he,listCheck as de,maskedAnyCheck as pe,NEVER as me,notCheck as le,numberCheck as ye,oneCheck as ge,openObject as ke,propertyCountCheck as Ie,propertyNamesCheck as Ae,REQUIRED as Oe,scopedCheck as E,stringCheck as Ne,TYPE_CHECKS as j,taggedCheck as Ce,typeCheck as Te,typeMask as Pe,uniqueCheck as Re}from"./checks.js";import{documentOf as xe,isSchemaObject as m,Resolver as Se,resolveUri as be}from"./resolver.js";import{sharedRegex as C}from"./shared.js";const Ee=Symbol("restart");class De{static{y(this,"Compiler")}r;draft;formats;dynamic;schema;scope;cache=new Map;annotatingCache=new Map;constructor(e,n,t){this.schema=e,this.r=new Se(e,n),this.draft=this.r.draft,this.formats=n.formats,this.dynamic=t,this.scope=[]}root(){return this.check(this.schema,this.r.rootBase)}check(e,n){if(e===!0)return A;if(e===!1)return me;if(!m(e))throw new Error(`A schema must be an object or a boolean, got ${JSON.stringify(e)}`);const t=this.cache.get(e);if(t!==void 0)return t;const r=this.bareType(e);if(r!==void 0)return r;const i={check:void 0};this.cache.set(e,ue(i));const s=this.build(e,this.r.baseFor(e,n));return i.check=s,this.cache.set(e,s),s}build(e,n){if(this.draft==="7"&&typeof e.$ref=="string")return this.ref(e.$ref,n);if(this.draft!=="7"&&(e.unevaluatedProperties!==void 0||e.unevaluatedItems!==void 0))return K(this.annotating(e,n));const t=this.plain(e,n);return this.dynamic&&this.r.isResource(e,n)?E(this.scope,n,t):t}bareType(e){let n;for(const t in e)if(t==="type")n=e.type;else if(!w.has(t))return;return n===void 0?A:typeof n=="string"?j.get(n):void 0}plain(e,n){const t=[],r=e.type===void 0?void 0:Array.isArray(e.type)?e.type:[e.type],i=r?.length===1?r[0]:void 0;let s=!1;if(i==="bytes")t.push(H(l(e.minLength)??0,l(e.maxLength)??Number.POSITIVE_INFINITY)),s=!0;else{const c=this.stringGroup(e,i==="string");c!==void 0&&t.push(c);const f=i==="number"||i==="integer"||i==="bigint",a=i==="number"?1:i==="integer"?2:i==="bigint"?3:0,u=this.numberGroup(e,a);u!==void 0&&t.push(u);const o=this.objectGroup(e,n,i==="object");o!==void 0&&t.push(o);const d=this.arrayGroup(e,n,i==="array");d!==void 0&&t.push(d),s=i==="string"&&c!==void 0||f&&u!==void 0||i==="object"&&o!==void 0||i==="array"&&d!==void 0}return r!==void 0&&!s&&t.unshift(Te(r)),this.inPlace(e,n,t),O(t)}inPlace(e,n,t){if(Array.isArray(e.enum)&&t.push(x(e.enum)),Object.hasOwn(e,"const")&&t.push(z(e.const)),Array.isArray(e.allOf)&&t.push(O(e.allOf.map(r=>this.check(r,n)))),Array.isArray(e.anyOf)&&t.push(this.union(e.anyOf,n,!1)),Array.isArray(e.oneOf)&&t.push(this.union(e.oneOf,n,!0)),e.not!==void 0&&t.push(le(this.check(e.not,n))),e.if!==void 0&&(e.then!==void 0||e.else!==void 0)){const r=e.then===void 0?A:this.check(e.then,n),i=e.else===void 0?A:this.check(e.else,n);t.push(fe(this.check(e.if,n),r,i))}typeof e.$ref=="string"&&t.push(this.ref(e.$ref,n)),this.draft!=="7"&&typeof e.$dynamicRef=="string"&&t.push(this.dynamicRef(e.$dynamicRef,n))}union(e,n,t){const r=y(()=>e.map(i=>this.check(i,n)),"checks");return $e(e,t)??this.tagged(e,n)??(t?ge(r()):ve(r()))}ref(e,n){const t=this.r.resolve(e,n),r=this.check(t.node,t.base);return this.dynamic&&t.base!==n?E(this.scope,t.base,r):r}dynamicRef(e,n){const t=this.bookended(e,n);if(t===void 0)return this.ref(e,n);const{initial:r,name:i}=t,s=this.check(r.node,r.base),c=this.dynamicLookup(i,(a,u)=>this.check(a,u)),f=this.scope;return a=>{for(let u=0;u<f.length;u++){const o=c(f[u]);if(o!==null)return o(a)}return s(a)}}bookended(e,n){const t=this.r.resolve(e,n),r=be(e,n),i=r.slice(xe(r).length+1),s=m(t.node)&&t.node.$dynamicAnchor===i;if(!(i===""||i.startsWith("/")||!s)){if(!this.dynamic)throw Ee;return{initial:t,name:i}}}dynamicLookup(e,n){const t=new Map;return r=>{const i=`${r}#${e}`;let s=t.get(i);if(s===void 0){const c=this.r.dynamicAnchors.get(i);s=c===void 0?null:n(c,this.r.baseOf.get(c)??r),t.set(i,s)}return s}}tagged(e,n){if(e.length<2)return;const t=[];for(const i of e){if(!m(i))return;const s=typeof i.$ref=="string"&&Object.keys(i).length===1?i.$ref:void 0,c=s===void 0?i:this.r.resolve(s,this.r.baseFor(i,n)).node;if(!m(c))return;t.push(c)}const r=t[0].properties;if(m(r))for(const i of Object.keys(r)){const s=t.map(c=>Fe(c,i));if(!(s.some(c=>c===void 0)||new Set(s).size!==s.length))return Ce(i,s,e.map(c=>this.check(c,n)))}}stringGroup(e,n){const t=l(e.minLength)??0,r=l(e.maxLength)??Number.POSITIVE_INFINITY,i=typeof e.pattern=="string"?C(e.pattern):void 0,s=this.formats!==void 0&&typeof e.format=="string"&&Object.hasOwn(this.formats,e.format)?this.formats[e.format]:void 0;if(!(t===0&&r===Number.POSITIVE_INFINITY&&i===void 0&&s===void 0))return Ne(n,t,r,i,s)}numberGroup(e,n){const t=k(e.minimum),r=k(e.maximum),i=k(e.exclusiveMinimum),s=k(e.exclusiveMaximum),c=k(e.multipleOf);if([t,r,i,s,c].every(a=>a===void 0))return;const f=Number.POSITIVE_INFINITY;return ye(n,t??-f,r??f,i??-f,s??f,c)}objectGroup(e,n,t){const r=je.every(o=>e[o]===void 0),i=this.objectCore(e,n,r?t?b:S:te);if(i!==void 0&&r)return i;const s=i===void 0?[]:[i];e.propertyNames!==void 0&&s.push(Ae(this.check(e.propertyNames,n)));const c=l(e.minProperties),f=l(e.maxProperties);(c!==void 0||f!==void 0)&&s.push(Ie(c??0,f??Number.POSITIVE_INFINITY));const a=[],u=[];if(this.draft!=="7"){for(const[o,d]of g(e.dependentRequired))Array.isArray(d)&&a.push([o,d]);for(const[o,d]of g(e.dependentSchemas))u.push([o,this.check(d,n)])}for(const[o,d]of g(e.dependencies))Array.isArray(d)?a.push([o,d]):u.push([o,this.check(d,n)]);return a.length>0&&s.push(Z(a)),u.length>0&&s.push(ee(u)),s.length===0?t?ce:void 0:ie(O(s),t)}objectCore(e,n,t){const r=m(e.properties)?e.properties:{},i=Array.isArray(e.required)?e.required.filter(p=>typeof p=="string"):[],s=m(e.patternProperties)?e.patternProperties:{},c=e.additionalProperties,f=Object.keys(r),a=Object.keys(s);if(f.length+i.length+a.length===0&&(c===void 0||c===!0))return;const u=[];for(const p of f){const I=this.check(r[p],n),N=oe(I),$=(N?.[0]??0)|(i.includes(p)?Oe:0)|(p in Object.prototype?re:0);u.push(p,N===void 0?I:N[1],$)}const o=i.filter(p=>!Object.hasOwn(r,p)),d=a.map(p=>[C(p),this.check(s[p],n)]),T=c===void 0||c===!0?void 0:this.check(c,n);if(d.length===0&&o.length===0&&(T===void 0||c===!1)){const p=f.filter(I=>i.includes(I)).length;return X(u,p,c===!1,t)}return ke(u,f,o,d,T,t)}arrayGroup(e,n,t){let r=[],i;Array.isArray(e.items)?(r=e.items,i=e.additionalItems):(this.draft!=="7"&&Array.isArray(e.prefixItems)&&(r=e.prefixItems),i=e.items);const s=r.map(o=>this.check(o,n)),c=i===void 0||i===!0?void 0:this.check(i,n),f=l(e.minItems),a=l(e.maxItems);if(e.contains===void 0&&e.uniqueItems!==!0&&(s.length>0||c!==void 0))return de(t?b:S,f??0,a??Number.POSITIVE_INFINITY,s,c);const u=[];if((s.length>0||c!==void 0)&&u.push(ae(s,c)),(f!==void 0||a!==void 0)&&u.push(he(f??0,a??Number.POSITIVE_INFINITY)),e.contains!==void 0){const o=this.draft==="7"?1:l(e.minContains)??1,d=this.draft==="7"?Number.POSITIVE_INFINITY:l(e.maxContains)??Number.POSITIVE_INFINITY;u.push(Q(this.check(e.contains,n),o,d))}return e.uniqueItems===!0&&u.push(Re),u.length===0?t?se:void 0:ne(O(u),t)}annotating(e,n){if(e===!0)return F;if(e===!1)return _;if(!m(e))throw new Error(`A schema must be an object or a boolean, got ${JSON.stringify(e)}`);const t=this.annotatingCache.get(e);if(t!==void 0)return t;const r={check:void 0};this.annotatingCache.set(e,M(r));const i=this.buildAnnotating(e,this.r.baseFor(e,n));return r.check=i,this.annotatingCache.set(e,i),i}buildAnnotating(e,n){const t={};let r=!1;for(const a of Object.keys(e))we.has(a)?r=!0:t[a]=e[a];const i=this.plain(t,n),s=[];r&&this.annotatingParts(e,n,s);const c=s.length===0?D(i):G(i,s),f=e.unevaluatedProperties!==void 0||e.unevaluatedItems!==void 0?U(c):c;return this.dynamic&&this.r.isResource(e,n)?R(this.scope,n,f):f}annotatingParts(e,n,t){if(e.properties!==void 0||e.patternProperties!==void 0||e.additionalProperties!==void 0){const r=g(e.properties).map(([c,f])=>[c,this.check(f,n)]),i=g(e.patternProperties).map(([c,f])=>[C(c),this.check(f,n)]),s=e.additionalProperties===void 0?void 0:this.check(e.additionalProperties,n);t.push(V(r,i,s))}if(e.prefixItems!==void 0||e.items!==void 0||e.contains!==void 0){const r=Array.isArray(e.prefixItems)?e.prefixItems:Array.isArray(e.items)?e.items:[],i=Array.isArray(e.items)?e.additionalItems:e.items;t.push(Y(r.map(s=>this.check(s,n)),i===void 0?void 0:this.check(i,n),e.contains===void 0?void 0:this.check(e.contains,n),l(e.minContains)??1,l(e.maxContains)??Number.POSITIVE_INFINITY))}if(Array.isArray(e.allOf))for(const r of e.allOf)t.push(this.annotating(r,n));if(Array.isArray(e.anyOf)&&t.push(P(e.anyOf.map(r=>this.annotating(r,n)),!1)),Array.isArray(e.oneOf)&&t.push(P(e.oneOf.map(r=>this.annotating(r,n)),!0)),e.if!==void 0){const r=e.then===void 0?void 0:this.annotating(e.then,n),i=e.else===void 0?void 0:this.annotating(e.else,n);t.push(L(this.annotating(e.if,n),r,i))}typeof e.$ref=="string"&&t.push(this.annotatingRef(e.$ref,n)),typeof e.$dynamicRef=="string"&&t.push(this.annotatingDynamicRef(e.$dynamicRef,n));for(const[r,i]of g(e.dependentSchemas))t.push(q(r,this.annotating(i,n)));e.unevaluatedProperties!==void 0&&t.push(J(this.check(e.unevaluatedProperties,n))),e.unevaluatedItems!==void 0&&t.push(B(this.check(e.unevaluatedItems,n)))}annotatingRef(e,n){const t=this.r.resolve(e,n),r=this.annotating(t.node,t.base);return this.dynamic&&t.base!==n?R(this.scope,t.base,r):r}annotatingDynamicRef(e,n){const t=this.bookended(e,n);if(t===void 0)return this.annotatingRef(e,n);const{initial:r,name:i}=t,s=this.annotating(r.node,r.base),c=this.dynamicLookup(i,(a,u)=>this.annotating(a,u)),f=this.scope;return(a,u)=>{for(let o=0;o<f.length;o++){const d=c(f[o]);if(d!==null)return d(a,u)}return s(a,u)}}}const w=new Set(["$schema","$comment","title","description","default","examples","deprecated","readOnly","writeOnly","$defs","definitions","contentEncoding","contentMediaType","minContains","maxContains","$vocabulary"]),je=["propertyNames","minProperties","maxProperties","dependentRequired","dependentSchemas","dependencies"],we=new Set(["properties","patternProperties","additionalProperties","prefixItems","items","additionalItems","contains","minContains","maxContains","allOf","anyOf","oneOf","if","then","else","$ref","$dynamicRef","dependentSchemas","unevaluatedProperties","unevaluatedItems"]);function $e(h,e){const n=[];for(const t of h){if(!m(t)||!Object.hasOwn(t,"const"))return;for(const r of Object.keys(t))if(r!=="const"&&!w.has(r))return;if(typeof t.const=="object"&&t.const!==null||e&&n.includes(t.const))return;n.push(t.const)}return x(n)}y($e,"constUnion");function ve(h){const e=[],n=[];for(const t of h){const r=_e.get(t);r===void 0?n.push(t):e.push(r)}return e.length===0?W(n):pe(Pe(e),n)}y(ve,"anyOf");const _e=new Map([...j].map(([h,e])=>[e,h]));function Fe(h,e){const n=h.properties;if(h.type!=="object"||!Array.isArray(h.required)||!h.required.includes(e))return;const t=m(n)?n[e]:void 0;if(!(!m(t)||!Object.hasOwn(t,"const")))return typeof t.const=="object"&&t.const!==null?void 0:t.const}y(Fe,"tagOf");function k(h){return typeof h=="number"||typeof h=="bigint"?h:void 0}y(k,"bound");function l(h){return typeof h=="number"?h:void 0}y(l,"number");function g(h){return m(h)?Object.entries(h):[]}y(g,"entries");export{De as Compiler,w as NEUTRAL_KEYWORDS,Ee as RESTART};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var A=Object.defineProperty;var d=(l,e)=>A(l,"name",{value:e,configurable:!0});import{newAnnotations as I}from"./annotations.js";import{codePoints as j,constCheck as P,containsCheck as L,enumCheck as N,isMultiple as S,isObject as w,NEVER as q,TYPE_CHECKS as C,uniqueCheck as R}from"./checks.js";import{isSchemaObject as p}from"./resolver.js";import{sharedRegex as O}from"./shared.js";class B{static{d(this,"Explainer")}c;schema;memo=void 0;constructor(e,n){this.c=e,this.schema=n,e.root()}errors(e){const n=[];try{this.walk(this.schema,this.c.r.rootBase,e,"",n)}finally{this.memo=void 0}return n.length===0&&n.push({path:"",keyword:"schema",message:"invalid"}),n}ok(e,n,t){return this.c.check(e,n)(t)}walk(e,n,t,r,i){if(e===!0)return;if(e===!1){i.push({path:r,keyword:"false",message:"no value is allowed here"});return}if(!p(e))return;const s=this.c.r.baseFor(e,n);if(this.ok(e,s,t))return;const m=i.length,a=d((f,u,o=r)=>{i.push({path:o,keyword:f,message:u})},"push");if(this.c.draft==="7"&&typeof e.$ref=="string"){this.walkRef(e.$ref,s,t,r,i);return}if(e.type!==void 0){const f=Array.isArray(e.type)?e.type:[e.type];if(!f.map(o=>(typeof o=="string"?C.get(o):void 0)??q).some(o=>o(t))){a("type",`expected ${f.join(" or ")}, got ${U(t)}`);return}}if(Array.isArray(e.enum)&&!N(e.enum)(t)&&a("enum",`expected one of ${$(e.enum)}`),Object.hasOwn(e,"const")&&!P(e.const)(t)&&a("const",`expected ${JSON.stringify(e.const)}`),typeof t=="string"&&e.type!=="bytes"&&this.walkString(e,t,a),t instanceof Uint8Array&&e.type==="bytes"&&this.walkBytes(e,t,a),(typeof t=="number"||typeof t=="bigint")&&this.walkNumber(e,t,a),w(t)&&this.walkObject(e,s,t,r,i,a),Array.isArray(t)&&this.walkArray(e,s,t,r,i,a),Array.isArray(e.allOf))for(const f of e.allOf)this.walk(f,s,t,r,i);if(Array.isArray(e.anyOf)&&this.walkUnion(e.anyOf,s,t,r,i,!1),Array.isArray(e.oneOf)&&this.walkUnion(e.oneOf,s,t,r,i,!0),e.not!==void 0&&this.ok(e.not,s,t)&&a("not","must not match the schema in not"),e.if!==void 0){const f=this.ok(e.if,s,t)?e.then:e.else;f!==void 0&&this.walk(f,s,t,r,i)}typeof e.$ref=="string"&&this.walkRef(e.$ref,s,t,r,i),i.length===m&&(e.unevaluatedProperties!==void 0||e.unevaluatedItems!==void 0)&&this.walkUnevaluated(e,s,t,r,i),i.length===m&&typeof e.$dynamicRef=="string"&&a("$dynamicRef","does not match the dynamically referenced schema")}walkRef(e,n,t,r,i){const s=this.c.r.resolve(e,n);if(s.node===!1&&this.c.r.isUnresolved(e,n)){i.push({path:r,keyword:"$ref",message:`unresolved reference ${e}`});return}if(!p(s.node)||typeof t!="object"||t===null){this.walk(s.node,s.base,t,r,i);return}this.memo??=new Map;let m=this.memo.get(s.node);const a=m?.get(t);if(a!==void 0&&a.path===r){i.push(...a.errors);return}const f=[];this.walk(s.node,s.base,t,r,f),m===void 0&&(m=new Map,this.memo.set(s.node,m)),m.set(t,{path:r,errors:f}),i.push(...f)}walkString(e,n,t){const r=j(n);typeof e.minLength=="number"&&r<e.minLength&&t("minLength",`expected at least ${e.minLength} characters`),typeof e.maxLength=="number"&&r>e.maxLength&&t("maxLength",`expected at most ${e.maxLength} characters`),typeof e.pattern=="string"&&!O(e.pattern).test(n)&&t("pattern",`expected to match ${e.pattern}`);const i=this.c.formats,s=i!==void 0&&typeof e.format=="string"&&Object.hasOwn(i,e.format)?i[e.format]:void 0;s!==void 0&&!s(n)&&t("format",`expected format ${e.format}`)}walkBytes(e,n,t){typeof e.minLength=="number"&&n.length<e.minLength&&t("minLength",`expected at least ${e.minLength} bytes`),typeof e.maxLength=="number"&&n.length>e.maxLength&&t("maxLength",`expected at most ${e.maxLength} bytes`)}walkNumber(e,n,t){const{minimum:r,maximum:i,exclusiveMinimum:s,exclusiveMaximum:m,multipleOf:a}=e;k(r)&&n<r&&t("minimum",`expected >= ${r}`),k(i)&&n>i&&t("maximum",`expected <= ${i}`),k(s)&&n<=s&&t("exclusiveMinimum",`expected > ${s}`),k(m)&&n>=m&&t("exclusiveMaximum",`expected < ${m}`),k(a)&&!S(n,a)&&t("multipleOf",`expected a multiple of ${a}`)}walkObject(e,n,t,r,i,s){const m=p(e.properties)?e.properties:{},a=Array.isArray(e.required)?e.required:[];for(const c of a){if(typeof c!="string")continue;const h=t[c]===void 0&&Object.hasOwn(m,c)&&this.ok(m[c],n,void 0);(!Object.hasOwn(t,c)||t[c]===void 0&&!h)&&s("required","missing",y(r,c))}for(const c of Object.keys(m))Object.hasOwn(t,c)&&t[c]!==void 0&&this.walk(m[c],n,t[c],y(r,c),i);const f=p(e.patternProperties)?Object.entries(e.patternProperties):[];for(const c of Object.keys(t)){let h=Object.hasOwn(m,c);for(const[g,b]of f)O(g).test(c)&&(h=!0,this.walk(b,n,t[c],y(r,c),i));!h&&e.additionalProperties!==void 0&&(e.additionalProperties===!1?s("additionalProperties","unknown field",y(r,c)):this.walk(e.additionalProperties,n,t[c],y(r,c),i)),e.propertyNames!==void 0&&!this.ok(e.propertyNames,n,c)&&s("propertyNames","invalid property name",y(r,c))}const u=Object.keys(t).length;typeof e.minProperties=="number"&&u<e.minProperties&&s("minProperties",`expected at least ${e.minProperties} properties`),typeof e.maxProperties=="number"&&u>e.maxProperties&&s("maxProperties",`expected at most ${e.maxProperties} properties`);const o={...this.c.draft==="7"||!p(e.dependentRequired)?{}:e.dependentRequired,...p(e.dependencies)?e.dependencies:{}};for(const[c,h]of Object.entries(o))if(Object.hasOwn(t,c))if(!Array.isArray(h))this.walk(h,n,t,r,i);else for(const g of h)Object.hasOwn(t,g)||s("dependentRequired",`required when ${c} is present`,y(r,g));if(this.c.draft!=="7"&&p(e.dependentSchemas))for(const[c,h]of Object.entries(e.dependentSchemas))Object.hasOwn(t,c)&&this.walk(h,n,t,r,i)}walkArray(e,n,t,r,i,s){let m=[],a;Array.isArray(e.items)?(m=e.items,a=e.additionalItems):(this.c.draft!=="7"&&Array.isArray(e.prefixItems)&&(m=e.prefixItems),a=e.items);for(let f=0;f<t.length;f++){const u=f<m.length?m[f]:a;u!==void 0&&this.walk(u,n,t[f],`${r}/${f}`,i)}if(typeof e.minItems=="number"&&t.length<e.minItems&&s("minItems",`expected at least ${e.minItems} items`),typeof e.maxItems=="number"&&t.length>e.maxItems&&s("maxItems",`expected at most ${e.maxItems} items`),e.uniqueItems===!0&&!R(t)&&s("uniqueItems","expected unique items"),e.contains!==void 0){const f=this.c.draft==="7",u=f||typeof e.minContains!="number"?1:e.minContains,o=f||typeof e.maxContains!="number"?Number.POSITIVE_INFINITY:e.maxContains;L(this.c.check(e.contains,n),u,o)(t)||s("contains",E(u,o))}}walkUnion(e,n,t,r,i,s){const m=e.filter(o=>this.ok(o,n,t)).length;if(m===1||!s&&m>0)return;const a=s?"oneOf":"anyOf";if(m>1){i.push({path:r,keyword:a,message:"matches more than one alternative"});return}const f=this.tagOf(e,n);if(f!==void 0&&w(t)){const o=f.values.indexOf(t[f.key]);o<0?i.push({path:y(r,f.key),keyword:a,message:`expected one of ${$(f.values)}`}):this.walk(e[o],n,t,r,i);return}let u;for(const o of e){const c=[];if(this.walk(o,n,t,r,c),c.length===0)continue;const h=w(t)?this.declaredKeys(o,n,t):0;(u===void 0||h>u.declared||h===u.declared&&c[0].path.length>u.errors[0].path.length)&&(u={errors:c,declared:h})}i.push(...u?.errors??[{path:r,keyword:a,message:"matches no alternative"}])}declaredKeys(e,n,t){const r=p(e)&&typeof e.$ref=="string"?this.c.r.resolve(e.$ref,this.c.r.baseFor(e,n)).node:e,i=p(r)&&p(r.properties)?r.properties:{};return Object.keys(t).filter(s=>Object.hasOwn(i,s)).length}tagOf(e,n){const t=e.map(i=>p(i)&&typeof i.$ref=="string"?this.c.r.resolve(i.$ref,this.c.r.baseFor(i,n)).node:i),r=t[0];if(!(!p(r)||!p(r.properties)))for(const i of Object.keys(r.properties)){const s=t.map(a=>{const f=p(a)&&p(a.properties)?a.properties[i]:void 0;return p(f)?f.const:void 0});if(s.every(a=>a!==void 0&&(typeof a!="object"||a===null))&&new Set(s).size===s.length)return{key:i,values:s}}}walkUnevaluated(e,n,t,r,i){const{unevaluatedProperties:s,unevaluatedItems:m,$id:a,...f}=e,u=I();if(this.c.annotating(f,n)(t,u),w(t)&&s!==void 0&&!u.allProps)for(const o of Object.keys(t))u.props?.has(o)||(s===!1?i.push({path:y(r,o),keyword:"unevaluatedProperties",message:"unknown field"}):this.walk(s,n,t[o],y(r,o),i));if(Array.isArray(t)&&m!==void 0&&!u.allItems)for(let o=u.items;o<t.length;o++)u.indexes?.has(o)||(m===!1?i.push({path:`${r}/${o}`,keyword:"unevaluatedItems",message:"unexpected item"}):this.walk(m,n,t[o],`${r}/${o}`,i))}}const x=20;function $(l){return l.length<=x?JSON.stringify(l):`${JSON.stringify(l.slice(0,x)).slice(0,-1)}, ... and ${l.length-x} more]`}d($,"listValues");function E(l,e){return e===Number.POSITIVE_INFINITY?`expected at least ${l} matching ${l===1?"item":"items"}`:l===0?`expected at most ${e} matching ${e===1?"item":"items"}`:`expected between ${l} and ${e} matching items`}d(E,"containsMessage");function k(l){return typeof l=="number"||typeof l=="bigint"}d(k,"isBound");function y(l,e){return`${l}/${String(e).replace(/~/g,"~0").replace(/\//g,"~1")}`}d(y,"pointer");function U(l){return l===null?"null":Array.isArray(l)?"array":l instanceof Uint8Array?"bytes":typeof l=="bigint"?"bigint":typeof l=="number"&&Number.isInteger(l)?"integer":typeof l=="number"&&!Number.isFinite(l)?String(l):typeof l}d(U,"typeName");export{B as Explainer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{IsDate as r}from"./typebox/date.js";import{IsDateTime as o}from"./typebox/date_time.js";import{IsDuration as i}from"./typebox/duration.js";import{IsEmail as m}from"./typebox/email.js";import{IsHostname as e}from"./typebox/hostname.js";import{IsIdnEmail as t}from"./typebox/idn_email.js";import{IsIdnHostname as s}from"./typebox/idn_hostname.js";import{IsIPv4 as n}from"./typebox/ipv4.js";import{IsIPv6 as p}from"./typebox/ipv6.js";import{IsIri as f}from"./typebox/iri.js";import{IsIriReference as I}from"./typebox/iri_reference.js";import{IsJsonPointer as a}from"./typebox/json_pointer.js";import{IsJsonPointerUriFragment as l}from"./typebox/json_pointer_uri_fragment.js";import{IsRegex as u}from"./typebox/regex.js";import{IsRelativeJsonPointer as d}from"./typebox/relative_json_pointer.js";import{IsTime as c}from"./typebox/time.js";import{IsUri as v}from"./typebox/uri.js";import{IsUriReference as U}from"./typebox/uri_reference.js";import{IsUriTemplate as P}from"./typebox/uri_template.js";import{IsUrl as g}from"./typebox/url.js";import{IsUuid as j}from"./typebox/uuid.js";const L=Object.freeze({date:r,"date-time":o,duration:i,email:m,hostname:e,"idn-email":t,"idn-hostname":s,ipv4:n,ipv6:p,iri:f,"iri-reference":I,"json-pointer":a,"json-pointer-uri-fragment":l,regex:u,"relative-json-pointer":d,time:c,uri:v,"uri-reference":U,"uri-template":P,url:g,uuid:j});export{L as formats};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=Object.defineProperty;var e=(t,n)=>d(t,"name",{value:n,configurable:!0});const r=[0,31,28,31,30,31,30,31,31,30,31,30,31],a=/^(\d\d\d\d)-(\d\d)-(\d\d)$/;function u(t){return t%4===0&&(t%100!==0||t%400===0)}e(u,"IsLeapYear");function i(t){const n=a.exec(t);if(!n)return!1;const s=+n[1],c=+n[2],o=+n[3];return c>=1&&c<=12&&o>=1&&o<=(c===2&&u(s)?29:r[c])}e(i,"IsDate");export{i as IsDate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var m=Object.defineProperty;var i=(e,t)=>m(e,"name",{value:t,configurable:!0});import{IsDate as o}from"./date.js";import{IsTime as r}from"./time.js";function T(e){const t=e.split(/T/i);return t.length===2&&o(t[0])&&r(t[1])}i(T,"IsDateTime");export{T as IsDateTime};
|