terminal-pilot 0.0.30 → 0.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1375 -435
- package/dist/cli.js.map +4 -4
- package/dist/commands/close-session.js +485 -6
- package/dist/commands/close-session.js.map +4 -4
- package/dist/commands/create-session.js +485 -6
- package/dist/commands/create-session.js.map +4 -4
- package/dist/commands/fill.js +485 -6
- package/dist/commands/fill.js.map +4 -4
- package/dist/commands/get-session.js +485 -6
- package/dist/commands/get-session.js.map +4 -4
- package/dist/commands/index.js +626 -44
- package/dist/commands/index.js.map +4 -4
- package/dist/commands/install.js +622 -40
- package/dist/commands/install.js.map +4 -4
- package/dist/commands/installer.js +68 -17
- package/dist/commands/installer.js.map +4 -4
- package/dist/commands/list-sessions.js +485 -6
- package/dist/commands/list-sessions.js.map +4 -4
- package/dist/commands/press-key.js +485 -6
- package/dist/commands/press-key.js.map +4 -4
- package/dist/commands/read-history.js +485 -6
- package/dist/commands/read-history.js.map +4 -4
- package/dist/commands/read-screen.js +485 -6
- package/dist/commands/read-screen.js.map +4 -4
- package/dist/commands/resize.js +485 -6
- package/dist/commands/resize.js.map +4 -4
- package/dist/commands/screenshot.js +485 -6
- package/dist/commands/screenshot.js.map +4 -4
- package/dist/commands/send-signal.js +485 -6
- package/dist/commands/send-signal.js.map +4 -4
- package/dist/commands/type.js +485 -6
- package/dist/commands/type.js.map +4 -4
- package/dist/commands/uninstall.js +550 -20
- package/dist/commands/uninstall.js.map +4 -4
- package/dist/commands/wait-for-exit.js +485 -6
- package/dist/commands/wait-for-exit.js.map +4 -4
- package/dist/commands/wait-for.js +485 -6
- package/dist/commands/wait-for.js.map +4 -4
- package/dist/testing/cli-repl.js +1375 -435
- package/dist/testing/cli-repl.js.map +4 -4
- package/dist/testing/qa-cli.js +1385 -445
- package/dist/testing/qa-cli.js.map +4 -4
- package/node_modules/@poe-code/agent-defs/README.md +35 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.js +21 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.js +18 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/codex.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/codex.js +25 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/cursor.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/cursor.js +15 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/gemini-cli.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/gemini-cli.js +16 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/goose.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/goose.js +16 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/index.d.ts +9 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/index.js +9 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/kimi.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/kimi.js +16 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/opencode.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/opencode.js +20 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.js +14 -0
- package/node_modules/@poe-code/agent-defs/dist/index.d.ts +5 -0
- package/node_modules/@poe-code/agent-defs/dist/index.js +3 -0
- package/node_modules/@poe-code/agent-defs/dist/registry.d.ts +3 -0
- package/node_modules/@poe-code/agent-defs/dist/registry.js +45 -0
- package/node_modules/@poe-code/agent-defs/dist/specifier.d.ts +7 -0
- package/node_modules/@poe-code/agent-defs/dist/specifier.js +40 -0
- package/node_modules/@poe-code/agent-defs/dist/types.d.ts +28 -0
- package/node_modules/@poe-code/agent-defs/dist/types.js +1 -0
- package/node_modules/@poe-code/agent-defs/package.json +20 -0
- package/node_modules/@poe-code/agent-skill-config/dist/apply.js +2 -1
- package/node_modules/@poe-code/agent-skill-config/dist/bridge-active-skills.d.ts +1 -0
- package/node_modules/@poe-code/agent-skill-config/dist/bridge-active-skills.js +37 -18
- package/node_modules/@poe-code/agent-skill-config/dist/resolve-skill-reference.js +8 -4
- package/node_modules/@poe-code/agent-skill-config/package.json +1 -5
- package/node_modules/@poe-code/config-mutations/README.md +55 -0
- package/node_modules/@poe-code/config-mutations/dist/error-codes.d.ts +1 -0
- package/node_modules/@poe-code/config-mutations/dist/error-codes.js +6 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.d.ts +6 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.js +829 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.d.ts +17 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.js +64 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/run-mutations.d.ts +7 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/run-mutations.js +39 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/index.d.ts +13 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/index.js +49 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/json.d.ts +32 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/json.js +171 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/object.d.ts +4 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/object.js +27 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/toml.d.ts +2 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/toml.js +75 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/yaml.d.ts +2 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/yaml.js +76 -0
- package/node_modules/@poe-code/config-mutations/dist/fs-utils.d.ts +18 -0
- package/node_modules/@poe-code/config-mutations/dist/fs-utils.js +43 -0
- package/node_modules/@poe-code/config-mutations/dist/index.d.ts +8 -0
- package/node_modules/@poe-code/config-mutations/dist/index.js +8 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/config-mutation.d.ts +47 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/config-mutation.js +34 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/file-mutation.d.ts +62 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/file-mutation.js +55 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.d.ts +40 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.js +32 -0
- package/node_modules/@poe-code/config-mutations/dist/template/render.d.ts +6 -0
- package/node_modules/@poe-code/config-mutations/dist/template/render.js +8 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/format-utils.d.ts +7 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/format-utils.js +21 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/index.d.ts +3 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/index.js +2 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.d.ts +25 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.js +194 -0
- package/node_modules/@poe-code/config-mutations/dist/types.d.ts +168 -0
- package/node_modules/@poe-code/config-mutations/dist/types.js +6 -0
- package/node_modules/@poe-code/config-mutations/package.json +29 -0
- package/node_modules/@poe-code/frontmatter/README.md +35 -0
- package/node_modules/@poe-code/frontmatter/dist/fences.d.ts +25 -0
- package/node_modules/@poe-code/frontmatter/dist/fences.js +100 -0
- package/node_modules/@poe-code/frontmatter/dist/index.d.ts +3 -0
- package/node_modules/@poe-code/frontmatter/dist/index.js +3 -0
- package/node_modules/@poe-code/frontmatter/dist/parse.d.ts +20 -0
- package/node_modules/@poe-code/frontmatter/dist/parse.js +209 -0
- package/node_modules/@poe-code/frontmatter/dist/stringify.d.ts +1 -0
- package/node_modules/@poe-code/frontmatter/dist/stringify.js +48 -0
- package/node_modules/@poe-code/frontmatter/package.json +25 -0
- package/node_modules/toolcraft-design/README.md +160 -0
- package/node_modules/toolcraft-design/dist/acp/components.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/acp/components.js +137 -0
- package/node_modules/toolcraft-design/dist/acp/index.d.ts +3 -0
- package/node_modules/toolcraft-design/dist/acp/index.js +2 -0
- package/node_modules/toolcraft-design/dist/acp/writer.d.ts +13 -0
- package/node_modules/toolcraft-design/dist/acp/writer.js +21 -0
- package/node_modules/toolcraft-design/dist/components/browser.d.ts +15 -0
- package/node_modules/toolcraft-design/dist/components/browser.js +31 -0
- package/node_modules/toolcraft-design/dist/components/catalog.d.ts +26 -0
- package/node_modules/toolcraft-design/dist/components/catalog.js +95 -0
- package/node_modules/toolcraft-design/dist/components/color.d.ts +31 -0
- package/node_modules/toolcraft-design/dist/components/color.js +102 -0
- package/node_modules/toolcraft-design/dist/components/command-errors.d.ts +16 -0
- package/node_modules/toolcraft-design/dist/components/command-errors.js +23 -0
- package/node_modules/toolcraft-design/dist/components/detail-card.d.ts +22 -0
- package/node_modules/toolcraft-design/dist/components/detail-card.js +45 -0
- package/node_modules/toolcraft-design/dist/components/help-formatter-plain.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/components/help-formatter-plain.js +132 -0
- package/node_modules/toolcraft-design/dist/components/help-formatter.d.ts +33 -0
- package/node_modules/toolcraft-design/dist/components/help-formatter.js +213 -0
- package/node_modules/toolcraft-design/dist/components/index.d.ts +16 -0
- package/node_modules/toolcraft-design/dist/components/index.js +10 -0
- package/node_modules/toolcraft-design/dist/components/logger.d.ts +11 -0
- package/node_modules/toolcraft-design/dist/components/logger.js +60 -0
- package/node_modules/toolcraft-design/dist/components/symbols.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/components/symbols.js +71 -0
- package/node_modules/toolcraft-design/dist/components/table.d.ts +15 -0
- package/node_modules/toolcraft-design/dist/components/table.js +302 -0
- package/node_modules/toolcraft-design/dist/components/template.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/components/template.js +437 -0
- package/node_modules/toolcraft-design/dist/components/text.d.ts +16 -0
- package/node_modules/toolcraft-design/dist/components/text.js +145 -0
- package/node_modules/toolcraft-design/dist/dashboard/ansi.d.ts +18 -0
- package/node_modules/toolcraft-design/dist/dashboard/ansi.js +343 -0
- package/node_modules/toolcraft-design/dist/dashboard/buffer.d.ts +25 -0
- package/node_modules/toolcraft-design/dist/dashboard/buffer.js +219 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/border.d.ts +9 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/border.js +123 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/footer.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/footer.js +56 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/output-pane.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/output-pane.js +268 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/stats-pane.d.ts +7 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/stats-pane.js +107 -0
- package/node_modules/toolcraft-design/dist/dashboard/dashboard.d.ts +20 -0
- package/node_modules/toolcraft-design/dist/dashboard/dashboard.js +167 -0
- package/node_modules/toolcraft-design/dist/dashboard/demo.d.ts +13 -0
- package/node_modules/toolcraft-design/dist/dashboard/demo.js +145 -0
- package/node_modules/toolcraft-design/dist/dashboard/index.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/dashboard/index.js +4 -0
- package/node_modules/toolcraft-design/dist/dashboard/keymap.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/dashboard/keymap.js +233 -0
- package/node_modules/toolcraft-design/dist/dashboard/layout.d.ts +25 -0
- package/node_modules/toolcraft-design/dist/dashboard/layout.js +79 -0
- package/node_modules/toolcraft-design/dist/dashboard/should-use-dashboard.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/dashboard/should-use-dashboard.js +7 -0
- package/node_modules/toolcraft-design/dist/dashboard/snapshot.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/dashboard/snapshot.js +68 -0
- package/node_modules/toolcraft-design/dist/dashboard/store.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/dashboard/store.js +51 -0
- package/node_modules/toolcraft-design/dist/dashboard/terminal-width.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/dashboard/terminal-width.js +71 -0
- package/node_modules/toolcraft-design/dist/dashboard/terminal.d.ts +37 -0
- package/node_modules/toolcraft-design/dist/dashboard/terminal.js +264 -0
- package/node_modules/toolcraft-design/dist/dashboard/types.d.ts +38 -0
- package/node_modules/toolcraft-design/dist/dashboard/types.js +1 -0
- package/node_modules/toolcraft-design/dist/explorer/actions.d.ts +16 -0
- package/node_modules/toolcraft-design/dist/explorer/actions.js +39 -0
- package/node_modules/toolcraft-design/dist/explorer/demo.d.ts +13 -0
- package/node_modules/toolcraft-design/dist/explorer/demo.js +297 -0
- package/node_modules/toolcraft-design/dist/explorer/events.d.ts +67 -0
- package/node_modules/toolcraft-design/dist/explorer/events.js +1 -0
- package/node_modules/toolcraft-design/dist/explorer/filter.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/explorer/filter.js +95 -0
- package/node_modules/toolcraft-design/dist/explorer/index.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/explorer/index.js +8 -0
- package/node_modules/toolcraft-design/dist/explorer/jobs.d.ts +7 -0
- package/node_modules/toolcraft-design/dist/explorer/jobs.js +59 -0
- package/node_modules/toolcraft-design/dist/explorer/keymap.d.ts +21 -0
- package/node_modules/toolcraft-design/dist/explorer/keymap.js +376 -0
- package/node_modules/toolcraft-design/dist/explorer/layout.d.ts +20 -0
- package/node_modules/toolcraft-design/dist/explorer/layout.js +73 -0
- package/node_modules/toolcraft-design/dist/explorer/reducer.d.ts +9 -0
- package/node_modules/toolcraft-design/dist/explorer/reducer.js +782 -0
- package/node_modules/toolcraft-design/dist/explorer/render/detail.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/explorer/render/detail.js +97 -0
- package/node_modules/toolcraft-design/dist/explorer/render/footer.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/explorer/render/footer.js +73 -0
- package/node_modules/toolcraft-design/dist/explorer/render/header.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/explorer/render/header.js +49 -0
- package/node_modules/toolcraft-design/dist/explorer/render/index.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/explorer/render/index.js +53 -0
- package/node_modules/toolcraft-design/dist/explorer/render/list.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/explorer/render/list.js +116 -0
- package/node_modules/toolcraft-design/dist/explorer/render/modal.d.ts +3 -0
- package/node_modules/toolcraft-design/dist/explorer/render/modal.js +87 -0
- package/node_modules/toolcraft-design/dist/explorer/render/test-fixtures.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/explorer/render/test-fixtures.js +156 -0
- package/node_modules/toolcraft-design/dist/explorer/render/text.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/explorer/render/text.js +81 -0
- package/node_modules/toolcraft-design/dist/explorer/runtime.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/explorer/runtime.js +340 -0
- package/node_modules/toolcraft-design/dist/explorer/runtime.test-helpers.d.ts +50 -0
- package/node_modules/toolcraft-design/dist/explorer/runtime.test-helpers.js +101 -0
- package/node_modules/toolcraft-design/dist/explorer/state.d.ts +137 -0
- package/node_modules/toolcraft-design/dist/explorer/state.js +86 -0
- package/node_modules/toolcraft-design/dist/explorer/theme.d.ts +27 -0
- package/node_modules/toolcraft-design/dist/explorer/theme.js +29 -0
- package/node_modules/toolcraft-design/dist/index.d.ts +50 -0
- package/node_modules/toolcraft-design/dist/index.js +43 -0
- package/node_modules/toolcraft-design/dist/internal/color-support.d.ts +9 -0
- package/node_modules/toolcraft-design/dist/internal/color-support.js +12 -0
- package/node_modules/toolcraft-design/dist/internal/output-format.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/internal/output-format.js +22 -0
- package/node_modules/toolcraft-design/dist/internal/strip-ansi.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/internal/strip-ansi.js +50 -0
- package/node_modules/toolcraft-design/dist/internal/theme-detect.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/internal/theme-detect.js +71 -0
- package/node_modules/toolcraft-design/dist/internal/theme-state.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/internal/theme-state.js +35 -0
- package/node_modules/toolcraft-design/dist/prompts/index.d.ts +91 -0
- package/node_modules/toolcraft-design/dist/prompts/index.js +137 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/cancel-symbol.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/cancel-symbol.js +4 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/confirm.d.ts +9 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/confirm.js +47 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/core.d.ts +55 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/core.js +274 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/glyphs.d.ts +20 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/glyphs.js +53 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/index.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/index.js +6 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/keys.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/keys.js +28 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/multiselect.d.ts +13 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/multiselect.js +131 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/pagination.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/pagination.js +52 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/password.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/password.js +55 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/select.d.ts +18 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/select.js +89 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/test-helpers.d.ts +21 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/test-helpers.js +32 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/text.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/text.js +60 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/wrap.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/wrap.js +18 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/cancel.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/cancel.js +9 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/intro.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/intro.js +16 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/log.d.ts +18 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/log.js +104 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/note.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/note.js +39 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/outro.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/outro.js +16 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/spinner.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/spinner.js +74 -0
- package/node_modules/toolcraft-design/dist/prompts/theme.d.ts +11 -0
- package/node_modules/toolcraft-design/dist/prompts/theme.js +15 -0
- package/node_modules/toolcraft-design/dist/static/index.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/static/index.js +2 -0
- package/node_modules/toolcraft-design/dist/static/menu.d.ts +11 -0
- package/node_modules/toolcraft-design/dist/static/menu.js +42 -0
- package/node_modules/toolcraft-design/dist/static/spinner.d.ts +14 -0
- package/node_modules/toolcraft-design/dist/static/spinner.js +52 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/ast.d.ts +92 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/ast.js +1 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/demo-content.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/demo-content.js +139 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/index.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/index.js +8 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/block.d.ts +7 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/block.js +1495 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/frontmatter.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/frontmatter.js +36 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/inline.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/inline.js +1190 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser.js +42 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/renderer.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/renderer.js +615 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/testing/theme-render-fixture.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/testing/theme-render-fixture.js +27 -0
- package/node_modules/toolcraft-design/dist/tokens/brand.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/tokens/brand.js +5 -0
- package/node_modules/toolcraft-design/dist/tokens/colors.d.ts +37 -0
- package/node_modules/toolcraft-design/dist/tokens/colors.js +85 -0
- package/node_modules/toolcraft-design/dist/tokens/index.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/tokens/index.js +5 -0
- package/node_modules/toolcraft-design/dist/tokens/spacing.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/tokens/spacing.js +6 -0
- package/node_modules/toolcraft-design/dist/tokens/typography.d.ts +7 -0
- package/node_modules/toolcraft-design/dist/tokens/typography.js +8 -0
- package/node_modules/toolcraft-design/dist/tokens/widths.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/tokens/widths.js +5 -0
- package/node_modules/toolcraft-design/package.json +44 -0
- package/package.json +15 -5
|
@@ -76,6 +76,9 @@ function isOptionalSchema(schema) {
|
|
|
76
76
|
function getRequiredKeys(schema) {
|
|
77
77
|
return Object.keys(schema.shape).filter((key) => !isOptionalSchema(schema.shape[key])).sort();
|
|
78
78
|
}
|
|
79
|
+
function getRequiredKeyFingerprint(schema) {
|
|
80
|
+
return getRequiredKeys(schema).join("+");
|
|
81
|
+
}
|
|
79
82
|
function assertUniqueRequiredKeyFingerprints(branches) {
|
|
80
83
|
const fingerprints = /* @__PURE__ */ new Map();
|
|
81
84
|
branches.forEach((branch, index) => {
|
|
@@ -113,6 +116,451 @@ function Union(branches) {
|
|
|
113
116
|
};
|
|
114
117
|
}
|
|
115
118
|
|
|
119
|
+
// ../toolcraft-schema/src/validate.ts
|
|
120
|
+
var missingValue = /* @__PURE__ */ Symbol("missingValue");
|
|
121
|
+
function validate(schema, value) {
|
|
122
|
+
const state = { issues: [] };
|
|
123
|
+
const result = walkSchema(schema, value, [], state);
|
|
124
|
+
if (state.issues.length > 0) {
|
|
125
|
+
return { ok: false, issues: state.issues };
|
|
126
|
+
}
|
|
127
|
+
return { ok: true, value: result.present ? result.value : void 0 };
|
|
128
|
+
}
|
|
129
|
+
function walkSchema(schema, value, path2, state) {
|
|
130
|
+
if (schema.kind === "optional") {
|
|
131
|
+
return walkOptional(schema, value, path2, state);
|
|
132
|
+
}
|
|
133
|
+
if (value === missingValue) {
|
|
134
|
+
addIssue(
|
|
135
|
+
state,
|
|
136
|
+
path2,
|
|
137
|
+
expectedFor(schema),
|
|
138
|
+
"missing",
|
|
139
|
+
`Expected ${expectedFor(schema)} at ${formatPath(path2)}`
|
|
140
|
+
);
|
|
141
|
+
return { present: false };
|
|
142
|
+
}
|
|
143
|
+
if (value === null && schema.nullable === true) {
|
|
144
|
+
return { present: true, value };
|
|
145
|
+
}
|
|
146
|
+
switch (schema.kind) {
|
|
147
|
+
case "string":
|
|
148
|
+
return walkString(schema, value, path2, state);
|
|
149
|
+
case "number":
|
|
150
|
+
return walkNumber(schema, value, path2, state);
|
|
151
|
+
case "boolean":
|
|
152
|
+
return walkBoolean(value, path2, state);
|
|
153
|
+
case "enum":
|
|
154
|
+
return walkEnum(schema, value, path2, state);
|
|
155
|
+
case "array":
|
|
156
|
+
return walkArray(schema, value, path2, state);
|
|
157
|
+
case "object":
|
|
158
|
+
return walkObject(schema, value, path2, state);
|
|
159
|
+
case "oneOf":
|
|
160
|
+
return walkOneOf(schema, value, path2, state);
|
|
161
|
+
case "union":
|
|
162
|
+
return walkUnion(schema, value, path2, state);
|
|
163
|
+
case "record":
|
|
164
|
+
return walkRecord(schema, value, path2, state);
|
|
165
|
+
case "json":
|
|
166
|
+
return walkJson(value, path2, state);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function walkOptional(schema, value, path2, state) {
|
|
170
|
+
if (value === missingValue || value === void 0) {
|
|
171
|
+
const defaultValue = getDefault(schema.inner);
|
|
172
|
+
if (defaultValue.present) {
|
|
173
|
+
return walkSchema(schema.inner, cloneDefault(defaultValue.value), path2, state);
|
|
174
|
+
}
|
|
175
|
+
return { present: false };
|
|
176
|
+
}
|
|
177
|
+
return walkSchema(schema.inner, value, path2, state);
|
|
178
|
+
}
|
|
179
|
+
function walkString(schema, value, path2, state) {
|
|
180
|
+
if (typeof value !== "string") {
|
|
181
|
+
addExpectedIssue(state, path2, "string", value);
|
|
182
|
+
return { present: true, value };
|
|
183
|
+
}
|
|
184
|
+
if (schema.minLength !== void 0 && value.length < schema.minLength) {
|
|
185
|
+
const expected = `string with length at least ${schema.minLength}`;
|
|
186
|
+
addIssue(
|
|
187
|
+
state,
|
|
188
|
+
path2,
|
|
189
|
+
expected,
|
|
190
|
+
`string with length ${value.length}`,
|
|
191
|
+
`Expected ${expected} at ${formatPath(path2)}`
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
if (schema.maxLength !== void 0 && value.length > schema.maxLength) {
|
|
195
|
+
const expected = `string with length at most ${schema.maxLength}`;
|
|
196
|
+
addIssue(
|
|
197
|
+
state,
|
|
198
|
+
path2,
|
|
199
|
+
expected,
|
|
200
|
+
`string with length ${value.length}`,
|
|
201
|
+
`Expected ${expected} at ${formatPath(path2)}`
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
if (schema.pattern !== void 0) {
|
|
205
|
+
const pattern = compilePattern(schema.pattern);
|
|
206
|
+
if (pattern === void 0 || !pattern.test(value)) {
|
|
207
|
+
const expected = `string matching pattern ${schema.pattern}`;
|
|
208
|
+
addIssue(state, path2, expected, value, `Expected ${expected} at ${formatPath(path2)}`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return { present: true, value };
|
|
212
|
+
}
|
|
213
|
+
function walkNumber(schema, value, path2, state) {
|
|
214
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
215
|
+
addExpectedIssue(state, path2, schema.jsonType === "integer" ? "integer" : "number", value);
|
|
216
|
+
return { present: true, value };
|
|
217
|
+
}
|
|
218
|
+
if (schema.jsonType === "integer" && !Number.isInteger(value)) {
|
|
219
|
+
addExpectedIssue(state, path2, "integer", value);
|
|
220
|
+
}
|
|
221
|
+
if (schema.minimum !== void 0 && value < schema.minimum) {
|
|
222
|
+
const expected = `number greater than or equal to ${schema.minimum}`;
|
|
223
|
+
addIssue(state, path2, expected, String(value), `Expected ${expected} at ${formatPath(path2)}`);
|
|
224
|
+
}
|
|
225
|
+
if (schema.maximum !== void 0 && value > schema.maximum) {
|
|
226
|
+
const expected = `number less than or equal to ${schema.maximum}`;
|
|
227
|
+
addIssue(state, path2, expected, String(value), `Expected ${expected} at ${formatPath(path2)}`);
|
|
228
|
+
}
|
|
229
|
+
return { present: true, value };
|
|
230
|
+
}
|
|
231
|
+
function walkBoolean(value, path2, state) {
|
|
232
|
+
if (typeof value !== "boolean") {
|
|
233
|
+
addExpectedIssue(state, path2, "boolean", value);
|
|
234
|
+
}
|
|
235
|
+
return { present: true, value };
|
|
236
|
+
}
|
|
237
|
+
function walkEnum(schema, value, path2, state) {
|
|
238
|
+
if (!schema.values.includes(value)) {
|
|
239
|
+
const expected = `one of ${schema.values.join(", ")}`;
|
|
240
|
+
addIssue(
|
|
241
|
+
state,
|
|
242
|
+
path2,
|
|
243
|
+
expected,
|
|
244
|
+
receivedValue(value),
|
|
245
|
+
`Expected ${expected} at ${formatPath(path2)}`
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
return { present: true, value };
|
|
249
|
+
}
|
|
250
|
+
function walkArray(schema, value, path2, state) {
|
|
251
|
+
if (!Array.isArray(value)) {
|
|
252
|
+
addExpectedIssue(state, path2, "array", value);
|
|
253
|
+
return { present: true, value };
|
|
254
|
+
}
|
|
255
|
+
if (schema.minItems !== void 0 && value.length < schema.minItems) {
|
|
256
|
+
const expected = `array with at least ${schema.minItems} items`;
|
|
257
|
+
addIssue(
|
|
258
|
+
state,
|
|
259
|
+
path2,
|
|
260
|
+
expected,
|
|
261
|
+
`array with ${value.length} items`,
|
|
262
|
+
`Expected ${expected} at ${formatPath(path2)}`
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
if (schema.maxItems !== void 0 && value.length > schema.maxItems) {
|
|
266
|
+
const expected = `array with at most ${schema.maxItems} items`;
|
|
267
|
+
addIssue(
|
|
268
|
+
state,
|
|
269
|
+
path2,
|
|
270
|
+
expected,
|
|
271
|
+
`array with ${value.length} items`,
|
|
272
|
+
`Expected ${expected} at ${formatPath(path2)}`
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
const nextValue = value.map((item, index) => {
|
|
276
|
+
const result = walkSchema(schema.item, item, [...path2, String(index)], state);
|
|
277
|
+
return result.present ? result.value : item;
|
|
278
|
+
});
|
|
279
|
+
return { present: true, value: nextValue };
|
|
280
|
+
}
|
|
281
|
+
function walkObject(schema, value, path2, state, injectedProperties = {}) {
|
|
282
|
+
if (!isPlainRecord(value)) {
|
|
283
|
+
addExpectedIssue(state, path2, "object", value);
|
|
284
|
+
return { present: true, value };
|
|
285
|
+
}
|
|
286
|
+
const nextValue = {};
|
|
287
|
+
const allowedKeys = /* @__PURE__ */ new Set([...Object.keys(schema.shape), ...Object.keys(injectedProperties)]);
|
|
288
|
+
for (const [key, propertySchema] of Object.entries(schema.shape)) {
|
|
289
|
+
const propertyValue = Object.hasOwn(value, key) ? value[key] : missingValue;
|
|
290
|
+
const result = walkSchema(propertySchema, propertyValue, [...path2, key], state);
|
|
291
|
+
if (result.present) {
|
|
292
|
+
setOwnValue(nextValue, key, result.value);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
for (const [key, injectedValue] of Object.entries(injectedProperties)) {
|
|
296
|
+
if (Object.hasOwn(value, key)) {
|
|
297
|
+
setOwnValue(nextValue, key, value[key]);
|
|
298
|
+
} else {
|
|
299
|
+
setOwnValue(nextValue, key, injectedValue);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
for (const [key, propertyValue] of Object.entries(value)) {
|
|
303
|
+
if (allowedKeys.has(key)) {
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
if (schema.additionalProperties === true) {
|
|
307
|
+
setOwnValue(nextValue, key, propertyValue);
|
|
308
|
+
} else {
|
|
309
|
+
addUnexpectedPropertyIssue(state, [...path2, key]);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return { present: true, value: nextValue };
|
|
313
|
+
}
|
|
314
|
+
function walkOneOf(schema, value, path2, state) {
|
|
315
|
+
if (!isPlainRecord(value)) {
|
|
316
|
+
addExpectedIssue(state, path2, "object", value);
|
|
317
|
+
return { present: true, value };
|
|
318
|
+
}
|
|
319
|
+
const discriminatorValue = value[schema.discriminator];
|
|
320
|
+
const discriminatorPath = [...path2, schema.discriminator];
|
|
321
|
+
const branchValues = Object.keys(schema.branches);
|
|
322
|
+
const expected = `one of ${branchValues.join(", ")}`;
|
|
323
|
+
if (!Object.hasOwn(value, schema.discriminator)) {
|
|
324
|
+
addIssueWithMessage(
|
|
325
|
+
state,
|
|
326
|
+
discriminatorPath,
|
|
327
|
+
expected,
|
|
328
|
+
"missing",
|
|
329
|
+
`Missing discriminator "${schema.discriminator}" at ${formatPath(path2)}. Expected one of: ${branchValues.join(", ")}.`
|
|
330
|
+
);
|
|
331
|
+
return { present: true, value };
|
|
332
|
+
}
|
|
333
|
+
if (typeof discriminatorValue !== "string" || !Object.hasOwn(schema.branches, discriminatorValue)) {
|
|
334
|
+
addIssueWithMessage(
|
|
335
|
+
state,
|
|
336
|
+
discriminatorPath,
|
|
337
|
+
expected,
|
|
338
|
+
receivedValue(discriminatorValue),
|
|
339
|
+
`Expected ${expected} at ${formatPath(discriminatorPath)}, got ${formatReceivedDiscriminator(discriminatorValue)}`
|
|
340
|
+
);
|
|
341
|
+
return { present: true, value };
|
|
342
|
+
}
|
|
343
|
+
return walkObject(schema.branches[discriminatorValue], value, path2, state, {
|
|
344
|
+
[schema.discriminator]: discriminatorValue
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
function walkUnion(schema, value, path2, state) {
|
|
348
|
+
if (isPlainRecord(value)) {
|
|
349
|
+
const candidateBranches = schema.branches.filter((branch) => hasRequiredKeys(branch, value));
|
|
350
|
+
if (candidateBranches.length === 1) {
|
|
351
|
+
return walkObject(candidateBranches[0], value, path2, state);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
const matches = [];
|
|
355
|
+
for (const branch of schema.branches) {
|
|
356
|
+
const branchState = { issues: [] };
|
|
357
|
+
const result = walkObject(branch, value, path2, branchState);
|
|
358
|
+
if (branchState.issues.length === 0 && result.present) {
|
|
359
|
+
matches.push({ fingerprint: getRequiredKeyFingerprint(branch), value: result.value });
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (matches.length === 1) {
|
|
363
|
+
return { present: true, value: matches[0].value };
|
|
364
|
+
}
|
|
365
|
+
if (matches.length === 0) {
|
|
366
|
+
const branchDescriptions = schema.branches.map((branch) => getRequiredKeyFingerprint(branch));
|
|
367
|
+
addIssueWithMessage(
|
|
368
|
+
state,
|
|
369
|
+
path2,
|
|
370
|
+
"exactly one union branch",
|
|
371
|
+
"0 matching branches",
|
|
372
|
+
`No union branch matched at ${formatPath(path2)}. Tried ${schema.branches.length} branches. Expected one of: ${branchDescriptions.join(" | ")}.`
|
|
373
|
+
);
|
|
374
|
+
return { present: true, value };
|
|
375
|
+
}
|
|
376
|
+
addIssueWithMessage(
|
|
377
|
+
state,
|
|
378
|
+
path2,
|
|
379
|
+
"exactly one union branch",
|
|
380
|
+
`${matches.length} matching branches`,
|
|
381
|
+
`Expected exactly one union branch at ${formatPath(path2)}, but matched more than one branch: ${matches.map((match) => match.fingerprint).join(" | ")}`
|
|
382
|
+
);
|
|
383
|
+
return { present: true, value };
|
|
384
|
+
}
|
|
385
|
+
function hasRequiredKeys(schema, value) {
|
|
386
|
+
for (const [key, propertySchema] of Object.entries(schema.shape)) {
|
|
387
|
+
if (propertySchema.kind !== "optional" && !Object.hasOwn(value, key)) {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
function walkRecord(schema, value, path2, state) {
|
|
394
|
+
if (!isPlainRecord(value)) {
|
|
395
|
+
addExpectedIssue(state, path2, "object", value);
|
|
396
|
+
return { present: true, value };
|
|
397
|
+
}
|
|
398
|
+
const nextValue = {};
|
|
399
|
+
for (const [key, propertyValue] of Object.entries(value)) {
|
|
400
|
+
const result = walkSchema(schema.value, propertyValue, [...path2, key], state);
|
|
401
|
+
if (result.present) {
|
|
402
|
+
setOwnValue(nextValue, key, result.value);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return { present: true, value: nextValue };
|
|
406
|
+
}
|
|
407
|
+
function walkJson(value, path2, state) {
|
|
408
|
+
if (isJsonValue(value)) {
|
|
409
|
+
return { present: true, value };
|
|
410
|
+
}
|
|
411
|
+
addExpectedIssue(state, path2, "JSON value", value);
|
|
412
|
+
return { present: true, value };
|
|
413
|
+
}
|
|
414
|
+
function getDefault(schema) {
|
|
415
|
+
if (schema.default !== void 0) {
|
|
416
|
+
return { present: true, value: schema.default };
|
|
417
|
+
}
|
|
418
|
+
if (schema.kind === "optional") {
|
|
419
|
+
return getDefault(schema.inner);
|
|
420
|
+
}
|
|
421
|
+
return { present: false };
|
|
422
|
+
}
|
|
423
|
+
function isPlainRecord(value) {
|
|
424
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
const prototype = Object.getPrototypeOf(value);
|
|
428
|
+
return prototype === Object.prototype || prototype === null;
|
|
429
|
+
}
|
|
430
|
+
function isJsonValue(value, ancestors = /* @__PURE__ */ new Set()) {
|
|
431
|
+
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
432
|
+
return typeof value !== "number" || Number.isFinite(value);
|
|
433
|
+
}
|
|
434
|
+
if (Array.isArray(value)) {
|
|
435
|
+
if (ancestors.has(value)) {
|
|
436
|
+
return false;
|
|
437
|
+
}
|
|
438
|
+
ancestors.add(value);
|
|
439
|
+
const result = value.every((item) => isJsonValue(item, ancestors));
|
|
440
|
+
ancestors.delete(value);
|
|
441
|
+
return result;
|
|
442
|
+
}
|
|
443
|
+
if (isPlainRecord(value)) {
|
|
444
|
+
if (ancestors.has(value)) {
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
ancestors.add(value);
|
|
448
|
+
const result = Object.values(value).every((item) => isJsonValue(item, ancestors));
|
|
449
|
+
ancestors.delete(value);
|
|
450
|
+
return result;
|
|
451
|
+
}
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
454
|
+
function cloneDefault(value) {
|
|
455
|
+
return structuredClone(value);
|
|
456
|
+
}
|
|
457
|
+
function setOwnValue(target, key, value) {
|
|
458
|
+
Object.defineProperty(target, key, {
|
|
459
|
+
configurable: true,
|
|
460
|
+
enumerable: true,
|
|
461
|
+
writable: true,
|
|
462
|
+
value
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
function expectedFor(schema) {
|
|
466
|
+
switch (schema.kind) {
|
|
467
|
+
case "string":
|
|
468
|
+
return "string";
|
|
469
|
+
case "number":
|
|
470
|
+
return schema.jsonType === "integer" ? "integer" : "number";
|
|
471
|
+
case "boolean":
|
|
472
|
+
return "boolean";
|
|
473
|
+
case "enum":
|
|
474
|
+
return `one of ${schema.values.join(", ")}`;
|
|
475
|
+
case "array":
|
|
476
|
+
return "array";
|
|
477
|
+
case "object":
|
|
478
|
+
case "oneOf":
|
|
479
|
+
case "record":
|
|
480
|
+
return "object";
|
|
481
|
+
case "union":
|
|
482
|
+
return "exactly one union branch";
|
|
483
|
+
case "json":
|
|
484
|
+
return "JSON value";
|
|
485
|
+
case "optional":
|
|
486
|
+
return expectedFor(schema.inner);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
function addExpectedIssue(state, path2, expected, value) {
|
|
490
|
+
addIssue(
|
|
491
|
+
state,
|
|
492
|
+
path2,
|
|
493
|
+
expected,
|
|
494
|
+
receivedType(value),
|
|
495
|
+
`Expected ${expected} at ${formatPath(path2)}`
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
function addUnexpectedPropertyIssue(state, path2) {
|
|
499
|
+
addIssue(
|
|
500
|
+
state,
|
|
501
|
+
path2,
|
|
502
|
+
"no additional properties",
|
|
503
|
+
"unknown property",
|
|
504
|
+
`Unexpected property ${formatPath(path2)}`
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
function addIssue(state, path2, expected, received, _message) {
|
|
508
|
+
state.issues.push({
|
|
509
|
+
path: path2,
|
|
510
|
+
expected,
|
|
511
|
+
received,
|
|
512
|
+
message: formatIssueMessage(expected, path2, received)
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
function addIssueWithMessage(state, path2, expected, received, message) {
|
|
516
|
+
state.issues.push({
|
|
517
|
+
path: path2,
|
|
518
|
+
expected,
|
|
519
|
+
received,
|
|
520
|
+
message
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
function formatIssueMessage(expected, path2, received) {
|
|
524
|
+
return `Expected ${expected} at ${formatPath(path2)}, got ${received}`;
|
|
525
|
+
}
|
|
526
|
+
function formatPath(path2) {
|
|
527
|
+
return path2.length === 0 ? "value" : path2.join(".");
|
|
528
|
+
}
|
|
529
|
+
function compilePattern(pattern) {
|
|
530
|
+
try {
|
|
531
|
+
return new RegExp(pattern);
|
|
532
|
+
} catch {
|
|
533
|
+
return void 0;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
function receivedType(value) {
|
|
537
|
+
if (value === null) {
|
|
538
|
+
return "null";
|
|
539
|
+
}
|
|
540
|
+
if (Array.isArray(value)) {
|
|
541
|
+
return "array";
|
|
542
|
+
}
|
|
543
|
+
if (typeof value === "number" && Number.isInteger(value)) {
|
|
544
|
+
return "integer";
|
|
545
|
+
}
|
|
546
|
+
return typeof value;
|
|
547
|
+
}
|
|
548
|
+
function receivedValue(value) {
|
|
549
|
+
if (typeof value === "string") {
|
|
550
|
+
return value;
|
|
551
|
+
}
|
|
552
|
+
if (value === void 0) {
|
|
553
|
+
return "undefined";
|
|
554
|
+
}
|
|
555
|
+
return String(value);
|
|
556
|
+
}
|
|
557
|
+
function formatReceivedDiscriminator(value) {
|
|
558
|
+
if (typeof value === "string") {
|
|
559
|
+
return JSON.stringify(value);
|
|
560
|
+
}
|
|
561
|
+
return receivedValue(value);
|
|
562
|
+
}
|
|
563
|
+
|
|
116
564
|
// ../toolcraft-schema/src/index.ts
|
|
117
565
|
function assertValidEnumValues(values) {
|
|
118
566
|
if (values.length === 0) {
|
|
@@ -136,6 +584,22 @@ function assertFiniteNumber(value, name) {
|
|
|
136
584
|
throw new Error(`${name} must be finite`);
|
|
137
585
|
}
|
|
138
586
|
}
|
|
587
|
+
function assertMinMaxOrder(minimum, maximum, minimumName, maximumName) {
|
|
588
|
+
if (minimum !== void 0 && maximum !== void 0 && minimum > maximum) {
|
|
589
|
+
throw new Error(`${minimumName} must be less than or equal to ${maximumName}`);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
function assertValidDefault(schema) {
|
|
593
|
+
if (schema.default === void 0) {
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
const result = validate(schema, schema.default);
|
|
597
|
+
if (!result.ok) {
|
|
598
|
+
throw new Error(
|
|
599
|
+
`default must satisfy schema: ${result.issues[0]?.message ?? "invalid default"}`
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
139
603
|
function assertPattern(pattern) {
|
|
140
604
|
if (pattern === void 0) {
|
|
141
605
|
return;
|
|
@@ -150,56 +614,71 @@ var S = {
|
|
|
150
614
|
String(options = {}) {
|
|
151
615
|
assertNonNegativeInteger(options.minLength, "minLength");
|
|
152
616
|
assertNonNegativeInteger(options.maxLength, "maxLength");
|
|
617
|
+
assertMinMaxOrder(options.minLength, options.maxLength, "minLength", "maxLength");
|
|
153
618
|
assertPattern(options.pattern);
|
|
154
|
-
|
|
619
|
+
const schema = {
|
|
155
620
|
kind: "string",
|
|
156
621
|
...options
|
|
157
622
|
};
|
|
623
|
+
assertValidDefault(schema);
|
|
624
|
+
return schema;
|
|
158
625
|
},
|
|
159
626
|
Number(options = {}) {
|
|
160
627
|
assertFiniteNumber(options.minimum, "minimum");
|
|
161
628
|
assertFiniteNumber(options.maximum, "maximum");
|
|
629
|
+
assertMinMaxOrder(options.minimum, options.maximum, "minimum", "maximum");
|
|
162
630
|
assertFiniteNumber(options.default, "default");
|
|
163
631
|
if (options.jsonType === "integer" && options.default !== void 0 && !Number.isInteger(options.default)) {
|
|
164
632
|
throw new Error("default must be an integer");
|
|
165
633
|
}
|
|
166
|
-
|
|
634
|
+
const schema = {
|
|
167
635
|
kind: "number",
|
|
168
636
|
...options
|
|
169
637
|
};
|
|
638
|
+
assertValidDefault(schema);
|
|
639
|
+
return schema;
|
|
170
640
|
},
|
|
171
641
|
Boolean(options = {}) {
|
|
172
|
-
|
|
642
|
+
const schema = {
|
|
173
643
|
kind: "boolean",
|
|
174
644
|
...options
|
|
175
645
|
};
|
|
646
|
+
assertValidDefault(schema);
|
|
647
|
+
return schema;
|
|
176
648
|
},
|
|
177
649
|
Enum(values, options = {}) {
|
|
178
650
|
assertValidEnumValues(values);
|
|
179
651
|
if (options.jsonType === "integer" && values.some((value) => typeof value !== "number" || !Number.isInteger(value))) {
|
|
180
652
|
throw new Error("Integer enum values must be integers");
|
|
181
653
|
}
|
|
182
|
-
|
|
654
|
+
const schema = {
|
|
183
655
|
kind: "enum",
|
|
184
656
|
values,
|
|
185
657
|
...options
|
|
186
658
|
};
|
|
659
|
+
assertValidDefault(schema);
|
|
660
|
+
return schema;
|
|
187
661
|
},
|
|
188
662
|
Array(item, options = {}) {
|
|
189
663
|
assertNonNegativeInteger(options.minItems, "minItems");
|
|
190
664
|
assertNonNegativeInteger(options.maxItems, "maxItems");
|
|
191
|
-
|
|
665
|
+
assertMinMaxOrder(options.minItems, options.maxItems, "minItems", "maxItems");
|
|
666
|
+
const schema = {
|
|
192
667
|
kind: "array",
|
|
193
668
|
item,
|
|
194
669
|
...options
|
|
195
670
|
};
|
|
671
|
+
assertValidDefault(schema);
|
|
672
|
+
return schema;
|
|
196
673
|
},
|
|
197
674
|
Object(shape, options = {}) {
|
|
198
|
-
|
|
675
|
+
const schema = {
|
|
199
676
|
kind: "object",
|
|
200
677
|
shape,
|
|
201
678
|
...options
|
|
202
679
|
};
|
|
680
|
+
assertValidDefault(schema);
|
|
681
|
+
return schema;
|
|
203
682
|
},
|
|
204
683
|
Optional(inner) {
|
|
205
684
|
return {
|