@astryxdesign/cli 0.7.17-canary.g5a3fd39 → 0.7.17-canary.g5cf5d69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -63
- package/api/build/_adapter.d.mts +51 -0
- package/api/build/_adapter.mjs +122 -6
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.mjs +23 -14
- package/api/build/build.type.d.mts +1 -1
- package/api/build/build.type.mjs +3 -3
- package/api/build/help/help.d.mts +15 -14
- package/api/build/help/help.mjs +62 -3
- package/api/build/kit/answer.mjs +2 -3
- package/api/build/kit/signals.d.mts +10 -0
- package/api/build/kit/signals.mjs +15 -2
- package/api/component/detail/blocks/blocks.mjs +2 -1
- package/api/discover/_adapter.d.mts +57 -6
- package/api/discover/_adapter.mjs +278 -49
- package/api/discover/_catalog-view.d.mts +7 -0
- package/api/discover/_catalog-view.mjs +10 -1
- package/api/discover/detail/detail.d.mts +3 -2
- package/api/discover/detail/detail.mjs +3 -2
- package/api/discover/detail/doc/doc.mjs +1 -1
- package/api/discover/discover.d.mts +24 -0
- package/api/discover/discover.doc.mjs +1 -1
- package/api/discover/discover.mjs +146 -25
- package/api/discover/discover.type.d.mts +6 -4
- package/api/discover/discover.type.mjs +6 -4
- package/api/discover/search/search.d.mts +22 -0
- package/api/discover/search/search.mjs +290 -70
- package/api/docs/_entry-names.mjs +4 -3
- package/api/doctor/_adapter.d.mts +43 -3
- package/api/doctor/_adapter.mjs +142 -18
- package/api/doctor/built-checks.d.mts +30 -3
- package/api/doctor/built-checks.mjs +132 -5
- package/api/doctor/doctor.d.mts +93 -6
- package/api/doctor/doctor.doc.mjs +2 -2
- package/api/doctor/doctor.mjs +524 -33
- package/api/doctor/doctor.type.d.mts +2 -1
- package/api/doctor/doctor.type.mjs +2 -1
- package/api/doctor/theme-checks.d.mts +19 -0
- package/api/doctor/theme-checks.mjs +74 -6
- package/api/hook/hook.type.d.mts +1 -1
- package/api/hook/hook.type.mjs +1 -1
- package/api/hook/list/list.mjs +11 -7
- package/api/icon/_adapter.d.mts +2 -1
- package/api/icon/_adapter.mjs +10 -15
- package/api/icon/_records.d.mts +3 -1
- package/api/icon/_records.mjs +30 -3
- package/api/icon/exportIconIndex.doc.mjs +1 -1
- package/api/icon/icon.doc.mjs +3 -3
- package/api/icon/icon.type.d.mts +32 -1
- package/api/icon/icon.type.mjs +19 -3
- package/api/icon/list/list.mjs +4 -1
- package/api/icon/rankIconIndex.doc.mjs +1 -1
- package/api/icon/search/icon-index.mjs +18 -8
- package/api/icon/search/search.d.mts +26 -3
- package/api/icon/search/search.mjs +155 -9
- package/api/init/_adapter.d.mts +14 -0
- package/api/init/_adapter.mjs +26 -4
- package/api/init/init.d.mts +1 -1
- package/api/init/init.doc.mjs +2 -2
- package/api/init/init.mjs +1 -1
- package/api/init/init.type.d.mts +29 -1
- package/api/init/init.type.mjs +14 -1
- package/api/init/run/run.d.mts +11 -1
- package/api/init/run/run.mjs +84 -5
- package/api/integration/_adapter.d.mts +5 -4
- package/api/integration/_adapter.mjs +7 -5
- package/api/integration/integrationCheck.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +8 -9
- package/api/integration/validate-integration.d.mts +1 -1
- package/api/integration/validate-integration.mjs +26 -24
- package/api/integration/validate-integration.type.d.mts +5 -2
- package/api/integration/validate-integration.type.mjs +5 -2
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/render/_adapter.d.mts +4 -2
- package/api/render/_adapter.mjs +62 -21
- package/api/render/render.doc.mjs +8 -5
- package/api/render/render.mjs +1 -1
- package/api/render/render.type.d.mts +2 -0
- package/api/render/render.type.mjs +2 -0
- package/api/search/ORDERING.md +2 -2
- package/api/search/_candidate-score.d.mts +3 -0
- package/api/search/_candidate-score.mjs +36 -3
- package/api/search/_gather-docs.mjs +29 -2
- package/api/search/_gather-templates.mjs +2 -1
- package/api/search/_main-searcher.mjs +13 -0
- package/api/search/_named-keywords.d.mts +2 -1
- package/api/search/_named-keywords.mjs +48 -6
- package/api/search/_order.d.mts +36 -1
- package/api/search/_order.mjs +141 -3
- package/api/swizzle/list/list.mjs +8 -1
- package/api/swizzle/swizzle.type.d.mts +1 -1
- package/api/swizzle/swizzle.type.mjs +1 -1
- package/api/template/copy/copy.mjs +3 -4
- package/api/template/list/list.mjs +2 -1
- package/api/template/show/show.mjs +2 -1
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.mjs +19 -1
- package/api/template/template.type.d.mts +1 -0
- package/api/template/template.type.mjs +2 -1
- package/api/theme/_adapter.d.mts +1 -0
- package/api/theme/_adapter.mjs +3 -5
- package/api/theme/_app-provider.d.mts +42 -0
- package/api/theme/_app-provider.mjs +61 -27
- package/api/theme/build/build.d.mts +4 -10
- package/api/theme/build/build.mjs +165 -116
- package/api/theme/build/input-fields.d.mts +9 -0
- package/api/theme/build/input-fields.mjs +155 -16
- package/api/theme/build/radius-values.d.mts +18 -0
- package/api/theme/build/radius-values.mjs +76 -0
- package/api/theme/build/typography-values.mjs +7 -23
- package/api/theme/build/written-values.d.mts +18 -0
- package/api/theme/build/written-values.mjs +107 -31
- package/api/theme/eject/eject.mjs +6 -1
- package/api/theme/palette/generate/generator.mjs +24 -0
- package/api/theme/theme.type.d.mts +4 -2
- package/api/theme/theme.type.mjs +3 -2
- package/api/theme/themeBuild.doc.mjs +2 -2
- package/api/theme/themeEject.doc.mjs +1 -1
- package/api/theme-edit/_catalog.d.mts +40 -0
- package/api/theme-edit/_catalog.mjs +100 -22
- package/api/theme-edit/_check.mjs +213 -43
- package/api/theme-edit/_color.d.mts +14 -0
- package/api/theme-edit/_color.mjs +22 -0
- package/api/theme-edit/_compiler.mjs +52 -0
- package/api/theme-edit/_context.d.mts +20 -2
- package/api/theme-edit/_context.mjs +157 -29
- package/api/theme-edit/_edit.mjs +426 -58
- package/api/theme-edit/_how-question.d.mts +14 -0
- package/api/theme-edit/_how-question.mjs +1541 -127
- package/api/theme-edit/_how.mjs +43 -0
- package/api/theme-edit/_missed.mjs +107 -27
- package/api/theme-edit/_normal.d.mts +18 -4
- package/api/theme-edit/_normal.mjs +84 -3
- package/api/theme-edit/_palette.d.mts +9 -0
- package/api/theme-edit/_palette.mjs +158 -33
- package/api/theme-edit/_part-words.mjs +16 -3
- package/api/theme-edit/_parts.d.mts +8 -0
- package/api/theme-edit/_parts.mjs +120 -36
- package/api/theme-edit/_png.d.mts +24 -0
- package/api/theme-edit/_png.mjs +99 -0
- package/api/theme-edit/_preview-app.d.mts +16 -0
- package/api/theme-edit/_preview-app.mjs +52 -18
- package/api/theme-edit/_preview.d.mts +44 -26
- package/api/theme-edit/_preview.mjs +255 -67
- package/api/theme-edit/_project.d.mts +12 -1
- package/api/theme-edit/_project.mjs +16 -1
- package/api/theme-edit/_settings.d.mts +116 -0
- package/api/theme-edit/_settings.mjs +1197 -58
- package/api/theme-edit/_tables.d.mts +16 -0
- package/api/theme-edit/_tables.mjs +34 -4
- package/api/theme-edit/theme-edit.type.d.mts +15 -2
- package/api/theme-edit/theme-edit.type.mjs +8 -6
- package/api/upgrade/_adapter.d.mts +46 -7
- package/api/upgrade/_adapter.mjs +110 -15
- package/api/upgrade/registry/registry.d.mts +6 -3
- package/api/upgrade/registry/registry.mjs +21 -6
- package/api/upgrade/run/run.mjs +23 -11
- package/api/upgrade/upgrade.doc.mjs +4 -3
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/tree/agent-guidance.doc.mjs +3 -2
- package/assets/docs/tree/checks.doc.mjs +2 -2
- package/assets/docs/tree/host-entry.doc.mjs +4 -0
- package/assets/docs/tree/icon-definitions.doc.mjs +3 -3
- package/assets/docs/tree/icon-sets.doc.mjs +6 -6
- package/assets/docs/tree/problems.doc.mjs +3 -3
- package/assets/docs/tree/render-pages.doc.mjs +17 -3
- package/assets/docs/tree/share-a-page.doc.mjs +5 -5
- package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
- package/assets/docs/tree/troubleshooting.doc.mjs +8 -0
- package/assets/docs/tree/updates.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +40 -5
- package/assets/docs-routes.generated.json +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/icons/installed-icon-set.doc.mjs +30 -0
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Avatar/AvatarInteractive.tsx +6 -1
- package/assets/templates/blocks/components/CodeBlock/CodeBlockTerminal.tsx +1 -1
- package/assets/templates/blocks/components/LinkProvider/LinkProviderCustomLink.tsx +3 -1
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/page.tsx +6 -2
- package/assets/templates/pages/ai-chat-landing/page.tsx +1 -1
- package/assets/templates/pages/blank/page.tsx +4 -2
- package/assets/templates/pages/canvas-editor/page.tsx +3 -1
- package/assets/templates/pages/centered-hero/page.tsx +1 -1
- package/assets/templates/pages/checkout-wizard/page.tsx +1 -1
- package/assets/templates/pages/classic-gallery/page.tsx +1 -1
- package/assets/templates/pages/contact-form/page.tsx +2 -2
- package/assets/templates/pages/course-detail/page.tsx +1 -1
- package/assets/templates/pages/dashboard/page.tsx +24 -8
- package/assets/templates/pages/dashboard-alert-rail/page.tsx +4 -2
- package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +7 -3
- package/assets/templates/pages/dashboard-comparison/page.tsx +5 -2
- package/assets/templates/pages/dashboard-composition/page.tsx +10 -4
- package/assets/templates/pages/dashboard-progress/page.tsx +6 -3
- package/assets/templates/pages/dashboard-scorecard/page.tsx +17 -8
- package/assets/templates/pages/detail-page/page.tsx +22 -5
- package/assets/templates/pages/documentation/page.tsx +4 -2
- package/assets/templates/pages/documentation-design/page.tsx +5 -2
- package/assets/templates/pages/documentation-technical/page.tsx +4 -2
- package/assets/templates/pages/editor/page.tsx +28 -9
- package/assets/templates/pages/file-explorer/page.tsx +3 -1
- package/assets/templates/pages/form-two-column/page.tsx +1 -1
- package/assets/templates/pages/form-wizard/page.tsx +1 -1
- package/assets/templates/pages/form-wizard-dialog/page.tsx +3 -1
- package/assets/templates/pages/form-wizard-inline/page.tsx +1 -1
- package/assets/templates/pages/form-wizard-vertical/page.tsx +1 -1
- package/assets/templates/pages/gallery-hero/page.tsx +1 -1
- package/assets/templates/pages/ide/page.tsx +7 -2
- package/assets/templates/pages/kanban-board/page.tsx +10 -4
- package/assets/templates/pages/library/page.tsx +31 -61
- package/assets/templates/pages/login/page.tsx +4 -2
- package/assets/templates/pages/login-card/page.tsx +4 -2
- package/assets/templates/pages/login-split/page.tsx +3 -2
- package/assets/templates/pages/login-sso/page.tsx +4 -4
- package/assets/templates/pages/mixed-gallery/page.tsx +1 -1
- package/assets/templates/pages/payment-form/page.tsx +1 -1
- package/assets/templates/pages/product-detail/page.tsx +16 -4
- package/assets/templates/pages/product-gallery/page.tsx +1 -1
- package/assets/templates/pages/settings/page.tsx +10 -4
- package/assets/templates/pages/settings-dialog/page.tsx +5 -6
- package/assets/templates/pages/settings-sidebar/page.tsx +39 -13
- package/assets/templates/pages/side-gallery/page.tsx +1 -1
- package/assets/templates/pages/table/page.tsx +2 -2
- package/assets/templates/pages/table-filter/page.tsx +21 -6
- package/assets/templates/pages/table-grouped/page.tsx +23 -2
- package/assets/templates/pages/table-inbox/page.tsx +82 -32
- package/assets/templates/pages/theme-showcase/page.tsx +3 -2
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +12 -12
- package/assets/templates/themes/butter/butterTheme.ts +197 -4
- package/assets/templates/themes/chocolate/chocolateTheme.ts +72 -8
- package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +3 -3
- package/assets/templates/themes/gothic/gothicTheme.ts +114 -4
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +8 -8
- package/assets/templates/themes/matcha/matchaTheme.ts +48 -12
- package/assets/templates/themes/neutral/neutralTheme.ts +29 -0
- package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +2 -2
- package/assets/templates/themes/stone/stoneTheme.ts +69 -0
- package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +9 -9
- package/assets/templates/themes/y2k/y2kTheme.ts +249 -14
- package/authoring/codemod/parse.d.mts +0 -36
- package/authoring/codemod/parse.mjs +62 -41
- package/authoring/config/config.doc.mjs +1 -1
- package/authoring/config/parse.d.mts +0 -47
- package/authoring/config/parse.mjs +128 -103
- package/authoring/config/type.ts +4 -3
- package/authoring/debug/parse.d.mts +2 -2
- package/authoring/discover/parse.d.mts +2 -2
- package/authoring/discover/parse.mjs +52 -38
- package/authoring/discover/type.ts +2 -1
- package/authoring/doctypes/_schema.d.mts +834 -950
- package/authoring/doctypes/_schema.mjs +863 -825
- package/authoring/doctypes/command/parse.mjs +2 -2
- package/authoring/doctypes/component/parse.mjs +2 -2
- package/authoring/doctypes/enum/parse.mjs +2 -2
- package/authoring/doctypes/hook/parse.mjs +2 -2
- package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +1 -1
- package/authoring/doctypes/icon-definition/parse.d.mts +0 -24
- package/authoring/doctypes/icon-definition/parse.mjs +59 -43
- package/authoring/doctypes/icon-set/parse.d.mts +0 -75
- package/authoring/doctypes/icon-set/parse.mjs +239 -210
- package/authoring/doctypes/legacy.mjs +3 -3
- package/authoring/doctypes/namespace/parse.mjs +2 -2
- package/authoring/doctypes/reference/parse.mjs +2 -2
- package/authoring/doctypes/schema/parse.mjs +2 -2
- package/authoring/doctypes/template/parse.d.mts +0 -101
- package/authoring/doctypes/template/parse.mjs +131 -106
- package/authoring/doctypes/theme/parse.d.mts +0 -23
- package/authoring/doctypes/theme/parse.mjs +52 -36
- package/authoring/gap-report/parse.d.mts +1 -1
- package/authoring/integration/integration.doc.mjs +8 -0
- package/authoring/integration/schema.d.mts +14 -3
- package/authoring/integration/schema.mjs +20 -2
- package/authoring/integration/type.ts +14 -0
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/build.mjs +27 -13
- package/clients/cli/commands/component.mjs +14 -3
- package/clients/cli/commands/discover.doc.mjs +2 -2
- package/clients/cli/commands/discover.mjs +20 -3
- package/clients/cli/commands/docs.doc.mjs +11 -9
- package/clients/cli/commands/docs.mjs +50 -21
- package/clients/cli/commands/experimental/icon.mjs +330 -227
- package/clients/cli/commands/experimental/render.mjs +16 -1
- package/clients/cli/commands/experimental/theme.mjs +42 -17
- package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon-map.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-use.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
- package/clients/cli/commands/experimental-render.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
- package/clients/cli/commands/init.doc.mjs +36 -24
- package/clients/cli/commands/integration-check.doc.mjs +1 -1
- package/clients/cli/commands/mcp.doc.mjs +53 -0
- package/clients/cli/commands/mcp.mjs +51 -0
- package/clients/cli/commands/search.mjs +46 -9
- package/clients/cli/commands/template.mjs +3 -2
- package/clients/cli/commands/theme-build.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +12 -2
- package/clients/cli/commands/upgrade.doc.mjs +3 -2
- package/clients/cli/commands.generated.json +1 -1
- package/clients/cli/formatters/index.mjs +52 -6
- package/clients/cli/index.mjs +23 -17
- package/clients/cli/lib/base-gate.mjs +37 -5
- package/clients/cli/lib/define-command.mjs +82 -4
- package/clients/cli/lib/json-shim.mjs +61 -4
- package/clients/cli/lib/manifest.mjs +9 -1
- package/clients/cli/lib/mcp-server.mjs +286 -0
- package/clients/cli/lib/mcp-tools.mjs +405 -0
- package/clients/cli/lib/other-cli-words.mjs +99 -0
- package/clients/cli/lib/stray-option.mjs +27 -1
- package/clients/cli/lib/unknown-command.mjs +326 -11
- package/clients/cli/manifest.generated.json +1 -1
- package/clients/cli/run.mjs +1 -1
- package/foundation/agent-docs/agent-docs.d.mts +49 -1
- package/foundation/agent-docs/agent-docs.mjs +108 -7
- package/foundation/agent-docs/computer-agent-text.mjs +1 -1
- package/foundation/bases/core.d.mts +1 -1
- package/foundation/bases/core.mjs +3 -3
- package/foundation/bases/resolve.d.mts +4 -8
- package/foundation/bases/resolve.mjs +15 -21
- package/foundation/bases/state.d.mts +15 -9
- package/foundation/bases/state.mjs +33 -6
- package/foundation/config/project.d.mts +5 -4
- package/foundation/config/project.mjs +33 -17
- package/foundation/discovery/component-discovery.mjs +15 -28
- package/foundation/discovery/icon-imports.d.mts +66 -0
- package/foundation/discovery/icon-imports.mjs +225 -0
- package/foundation/discovery/icon-ranking.d.mts +12 -2
- package/foundation/discovery/icon-ranking.mjs +197 -10
- package/foundation/discovery/icon-set-checks.mjs +2 -1
- package/foundation/discovery/icon-set-discovery.d.mts +28 -0
- package/foundation/discovery/icon-set-discovery.mjs +42 -0
- package/foundation/discovery/icon-set-writer.d.mts +2 -11
- package/foundation/discovery/icon-set-writer.mjs +3 -29
- package/foundation/discovery/module-exports.d.mts +1 -1
- package/foundation/discovery/module-exports.mjs +136 -33
- package/foundation/discovery/name-roots.d.mts +5 -0
- package/foundation/discovery/name-roots.mjs +11 -0
- package/foundation/discovery/runner-allowlist.d.mts +1 -0
- package/foundation/discovery/runner-allowlist.mjs +2 -0
- package/foundation/discovery/runner-commands.mjs +1 -0
- package/foundation/discovery/template-adapter.d.mts +1 -1
- package/foundation/discovery/template-destination.d.mts +14 -6
- package/foundation/discovery/template-destination.mjs +42 -8
- package/foundation/discovery/template-icons.d.mts +45 -2
- package/foundation/discovery/template-icons.mjs +26 -54
- package/foundation/discovery/template-needs.d.mts +28 -2
- package/foundation/discovery/template-needs.mjs +92 -11
- package/foundation/discovery/theme-discovery.d.mts +8 -0
- package/foundation/discovery/theme-discovery.mjs +23 -6
- package/foundation/discovery/theme-imports.mjs +2 -4
- package/foundation/doc-compiler/parse-readable.mjs +4 -3
- package/foundation/doc-compiler/stored-docs.d.mts +13 -0
- package/foundation/doc-compiler/stored-docs.mjs +74 -3
- package/foundation/env/cli-command.d.mts +68 -10
- package/foundation/env/cli-command.mjs +116 -22
- package/foundation/env/project-scope.d.mts +9 -0
- package/foundation/env/project-scope.mjs +28 -2
- package/foundation/fs/gather-cache.d.mts +23 -0
- package/foundation/fs/gather-cache.mjs +94 -2
- package/foundation/fs/module-loader.d.mts +3 -1
- package/foundation/fs/module-loader.mjs +85 -5
- package/foundation/fs/read-record.mjs +9 -5
- package/foundation/identity/package-names.d.mts +18 -0
- package/foundation/identity/package-names.mjs +19 -0
- package/foundation/identity/providers.mjs +3 -2
- package/foundation/integrations/icon-features.d.mts +63 -0
- package/foundation/integrations/icon-features.mjs +54 -0
- package/foundation/integrations/integrations.d.mts +13 -1
- package/foundation/integrations/integrations.mjs +47 -6
- package/foundation/integrations/pack-state.d.mts +21 -0
- package/foundation/integrations/pack-state.mjs +42 -19
- package/foundation/integrations/validate-contributions.d.mts +11 -3
- package/foundation/integrations/validate-contributions.mjs +51 -13
- package/foundation/release/cache.d.mts +13 -1
- package/foundation/release/cache.mjs +94 -14
- package/foundation/release/notices.d.mts +15 -0
- package/foundation/release/notices.mjs +111 -7
- package/foundation/release/project.d.mts +3 -4
- package/foundation/release/project.mjs +5 -6
- package/foundation/render/client-bundle.d.mts +126 -0
- package/foundation/render/client-bundle.mjs +565 -0
- package/foundation/render/cut-short.d.mts +7 -1
- package/foundation/render/cut-short.mjs +46 -6
- package/foundation/render/embedded-imports.d.mts +4 -3
- package/foundation/render/embedded-imports.mjs +13 -8
- package/foundation/render/esbuild-dependency.d.mts +14 -0
- package/foundation/render/esbuild-dependency.mjs +41 -0
- package/foundation/render/file-header.mjs +5 -4
- package/foundation/render/page-worker.mjs +562 -86
- package/foundation/render/picture-chrome.mjs +54 -29
- package/foundation/render/picture-playwright.mjs +78 -42
- package/foundation/render/picture-window.d.mts +33 -0
- package/foundation/render/picture-window.mjs +78 -0
- package/foundation/render/render-page.d.mts +55 -4
- package/foundation/render/render-page.mjs +199 -28
- package/foundation/render/restore-folder.d.mts +13 -0
- package/foundation/render/restore-folder.mjs +30 -0
- package/foundation/render/served-packages.d.mts +2 -1
- package/foundation/render/served-packages.mjs +5 -3
- package/foundation/render/ts-paths.d.mts +11 -0
- package/foundation/render/ts-paths.mjs +27 -2
- package/foundation/render/value-uses.d.mts +43 -0
- package/foundation/render/value-uses.mjs +110 -0
- package/foundation/response/error-codes.d.mts +2 -1
- package/foundation/response/error-codes.doc.mjs +7 -1
- package/foundation/response/error-codes.mjs +10 -2
- package/foundation/response/response-types.doc.mjs +12 -12
- package/foundation/runtime/package-root.d.mts +8 -0
- package/foundation/runtime/package-root.mjs +20 -0
- package/foundation/suggest/other-command.d.mts +11 -0
- package/foundation/suggest/other-command.mjs +1 -1
- package/foundation/text/icon-id.d.mts +20 -0
- package/foundation/text/icon-id.mjs +40 -0
- package/foundation/text/icon-set-next.d.mts +25 -0
- package/foundation/text/icon-set-next.mjs +29 -0
- package/foundation/xle/browser.d.mts +2 -2
- package/package.json +7 -6
|
@@ -27,879 +27,917 @@ import {z} from 'zod';
|
|
|
27
27
|
/** @typedef {import('./command/type.js').CommandDoc} CommandDoc */
|
|
28
28
|
/** @typedef {import('./enum/type.js').EnumDoc} EnumDoc */
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
parent: nonEmptyString,
|
|
57
|
-
slot: nonEmptyString.optional(),
|
|
58
|
-
order: z.number().int().safe().optional(),
|
|
59
|
-
})
|
|
60
|
-
.strict()
|
|
61
|
-
.optional(),
|
|
62
|
-
aliases: z.array(nonEmptyString).optional(),
|
|
63
|
-
audience: z.enum(['public', 'internal']).optional(),
|
|
64
|
-
stability: z.literal('experimental').optional(),
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const _AuthoredDocGraphSchema = z.object(AuthoredDocGraphFields).strict();
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* @typedef {import('../_shared/contract.js').Expect<
|
|
71
|
-
* import('../_shared/contract.js').MutuallyAssignable<
|
|
72
|
-
* z.infer<typeof _AuthoredDocGraphSchema>,
|
|
73
|
-
* AuthoredDocGraphFieldsType
|
|
74
|
-
* >
|
|
75
|
-
* >} _AuthoredDocGraphDriftLock
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
const ProseBlockSchema = z
|
|
79
|
-
.object({type: z.literal('prose'), text: nonEmptyString})
|
|
80
|
-
.strict();
|
|
81
|
-
const HeadingBlockSchema = z
|
|
82
|
-
.object({
|
|
83
|
-
type: z.literal('heading'),
|
|
84
|
-
level: z.union([z.literal(3), z.literal(4), z.literal(5), z.literal(6)]),
|
|
85
|
-
text: nonEmptyString,
|
|
86
|
-
})
|
|
87
|
-
.strict();
|
|
88
|
-
const CodeBlockSchema = z
|
|
89
|
-
.object({
|
|
90
|
-
type: z.literal('code'),
|
|
91
|
-
lang: nonEmptyString,
|
|
92
|
-
code: z.string(),
|
|
93
|
-
label: nonEmptyString.optional(),
|
|
94
|
-
})
|
|
95
|
-
.strict();
|
|
96
|
-
const TableBlockSchema = z
|
|
97
|
-
.object({
|
|
98
|
-
type: z.literal('table'),
|
|
99
|
-
headers: z.array(z.string()).min(1),
|
|
100
|
-
rows: z.array(z.array(z.string())),
|
|
101
|
-
})
|
|
102
|
-
.strict()
|
|
103
|
-
.superRefine((table, context) => {
|
|
104
|
-
table.rows.forEach((row, index) => {
|
|
105
|
-
if (row.length !== table.headers.length) {
|
|
106
|
-
context.addIssue({
|
|
107
|
-
code: 'custom',
|
|
108
|
-
path: ['rows', index],
|
|
109
|
-
message: `expected ${table.headers.length} cells`,
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
const ListBlockSchema = z
|
|
115
|
-
.object({
|
|
116
|
-
type: z.literal('list'),
|
|
117
|
-
style: z.enum(['ordered', 'unordered', 'do', 'dont']),
|
|
118
|
-
items: z.array(nonEmptyString).min(1),
|
|
119
|
-
})
|
|
120
|
-
.strict();
|
|
121
|
-
const TokenReferenceBlockSchema = z
|
|
122
|
-
.object({
|
|
123
|
-
type: z.literal('token-ref'),
|
|
124
|
-
topic: nonEmptyString,
|
|
125
|
-
section: nonEmptyString,
|
|
126
|
-
})
|
|
127
|
-
.strict();
|
|
128
|
-
const WorkflowBlockSchema = z
|
|
129
|
-
.object({
|
|
130
|
-
type: z.literal('workflow'),
|
|
131
|
-
title: nonEmptyString.optional(),
|
|
132
|
-
steps: z
|
|
133
|
-
.array(
|
|
134
|
-
z
|
|
135
|
-
.object({
|
|
136
|
-
title: nonEmptyString,
|
|
137
|
-
description: nonEmptyString.optional(),
|
|
138
|
-
references: z.array(nonEmptyString).min(1).optional(),
|
|
139
|
-
})
|
|
140
|
-
.strict(),
|
|
141
|
-
)
|
|
142
|
-
.min(1),
|
|
143
|
-
})
|
|
144
|
-
.strict();
|
|
145
|
-
const CollectionBlockSchema = z
|
|
146
|
-
.object({
|
|
147
|
-
type: z.literal('collection'),
|
|
148
|
-
title: nonEmptyString.optional(),
|
|
149
|
-
source: z.object({slot: nonEmptyString}).strict(),
|
|
150
|
-
presentation: z.enum(['list', 'cards', 'compact']).optional(),
|
|
151
|
-
whenEmpty: z.enum(['show', 'omit']).optional(),
|
|
152
|
-
})
|
|
153
|
-
.strict();
|
|
154
|
-
const ReferenceBlockSchema = z
|
|
155
|
-
.object({
|
|
156
|
-
type: z.literal('reference'),
|
|
157
|
-
target: nonEmptyString,
|
|
158
|
-
projection: z
|
|
30
|
+
function buildDocSchemas() {
|
|
31
|
+
const nonEmptyString = z.string().min(1);
|
|
32
|
+
|
|
33
|
+
/** Every authored doc-kind discriminant accepted by parseDoc. */
|
|
34
|
+
const AuthoredDocKindSchema = z.enum([
|
|
35
|
+
'component',
|
|
36
|
+
'function',
|
|
37
|
+
'generic',
|
|
38
|
+
'page',
|
|
39
|
+
'block',
|
|
40
|
+
'schema',
|
|
41
|
+
'command',
|
|
42
|
+
'enum',
|
|
43
|
+
'namespace',
|
|
44
|
+
'icon-definition',
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @typedef {import('../_shared/contract.js').Expect<
|
|
49
|
+
* import('../_shared/contract.js').Equal<z.infer<typeof AuthoredDocKindSchema>, AuthoredDocKind>
|
|
50
|
+
* >} _AuthoredDocKindDriftLock
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/** Shared optional graph fields for every authored doc kind. */
|
|
54
|
+
const AuthoredDocGraphFields = {
|
|
55
|
+
placement: z
|
|
159
56
|
.object({
|
|
160
|
-
|
|
161
|
-
|
|
57
|
+
parent: nonEmptyString,
|
|
58
|
+
slot: nonEmptyString.optional(),
|
|
59
|
+
order: z.number().int().safe().optional(),
|
|
162
60
|
})
|
|
163
61
|
.strict()
|
|
164
62
|
.optional(),
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
]
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
* z.infer<typeof ReferenceContentBlockSchema>,
|
|
217
|
-
* ReferenceContentBlock
|
|
218
|
-
* >
|
|
219
|
-
* >} _ReferenceContentBlockDriftLock
|
|
220
|
-
*/
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* @typedef {import('../_shared/contract.js').Expect<
|
|
224
|
-
* import('../_shared/contract.js').Equal<
|
|
225
|
-
* z.infer<typeof GraphContentBlockSchema>,
|
|
226
|
-
* GraphContentBlock
|
|
227
|
-
* >
|
|
228
|
-
* >} _GraphContentBlockDriftLock
|
|
229
|
-
*/
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* @typedef {import('../_shared/contract.js').Expect<
|
|
233
|
-
* import('../_shared/contract.js').Equal<
|
|
234
|
-
* z.infer<typeof SectionContentBlockSchema>,
|
|
235
|
-
* ReferenceSection['content'][number]
|
|
236
|
-
* >
|
|
237
|
-
* >} _SectionContentBlockDriftLock
|
|
238
|
-
*/
|
|
239
|
-
|
|
240
|
-
const ReferenceSectionSchema = z
|
|
241
|
-
.object({
|
|
242
|
-
id: nonEmptyString.optional(),
|
|
243
|
-
title: nonEmptyString,
|
|
244
|
-
category: z.string().optional(),
|
|
245
|
-
content: z.array(SectionContentBlockSchema),
|
|
246
|
-
// Where an extension adds this section to the topic it extends: before
|
|
247
|
-
// or after the section with this key. Ignored on any other section.
|
|
248
|
-
before: nonEmptyString.optional(),
|
|
249
|
-
after: nonEmptyString.optional(),
|
|
250
|
-
previewType: z
|
|
251
|
-
.enum([
|
|
252
|
-
'swatch',
|
|
253
|
-
'shadow-box',
|
|
254
|
-
'radius-box',
|
|
255
|
-
'spacing-bar',
|
|
256
|
-
'size-bar',
|
|
257
|
-
'border-line',
|
|
258
|
-
'duration-bar',
|
|
259
|
-
'easing-curve',
|
|
260
|
-
'font-sample',
|
|
261
|
-
])
|
|
262
|
-
.optional(),
|
|
263
|
-
})
|
|
264
|
-
.strict();
|
|
265
|
-
|
|
266
|
-
const PropSchema = z
|
|
267
|
-
.object({
|
|
268
|
-
name: z.string().min(1, 'prop name is required'),
|
|
269
|
-
type: z.string().min(1, 'prop type is required'),
|
|
270
|
-
description: z.string(),
|
|
271
|
-
default: z.string().optional(),
|
|
272
|
-
required: z.boolean().optional(),
|
|
273
|
-
})
|
|
274
|
-
.passthrough();
|
|
275
|
-
|
|
276
|
-
const ParamSchema = z
|
|
277
|
-
.object({
|
|
278
|
-
name: z.string().min(1, 'param name is required'),
|
|
279
|
-
type: z.string().min(1, 'param type is required'),
|
|
280
|
-
description: z.string(),
|
|
281
|
-
default: z.string().optional(),
|
|
282
|
-
required: z.boolean().optional(),
|
|
283
|
-
})
|
|
284
|
-
.passthrough();
|
|
285
|
-
|
|
286
|
-
const ReturnSchema = z
|
|
287
|
-
.object({
|
|
288
|
-
name: z.string().min(1, 'return name is required'),
|
|
289
|
-
type: z.string().min(1, 'return type is required'),
|
|
290
|
-
description: z.string(),
|
|
291
|
-
})
|
|
292
|
-
.passthrough();
|
|
293
|
-
|
|
294
|
-
/** Every example kind, in the order the docs list them. */
|
|
295
|
-
const EXAMPLE_KINDS = /** @type {const} */ (['demo', 'setup']);
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* An example's `kind`. The message names both values and what each one does,
|
|
299
|
-
* because an author who misspells it needs to pick again.
|
|
300
|
-
*/
|
|
301
|
-
const ExampleKindSchema = z.enum(EXAMPLE_KINDS, {
|
|
302
|
-
error: issue =>
|
|
303
|
-
`unknown example kind ${JSON.stringify(issue.input)}; use 'demo' (may render as a live preview) or 'setup' (code only)`,
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* One component example as it loads. Only `kind` is checked: the rest passes
|
|
308
|
-
* through unchecked, as component examples always have.
|
|
309
|
-
*/
|
|
310
|
-
const ComponentExampleSchema = z
|
|
311
|
-
.object({kind: ExampleKindSchema.optional()})
|
|
312
|
-
.passthrough();
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* The example fields of any doc, checked before the permissive legacy union so
|
|
316
|
-
* a bad `kind` fails with its own message, not as a union mismatch.
|
|
317
|
-
*/
|
|
318
|
-
export const DocExampleKindsSchema = z
|
|
319
|
-
.object({
|
|
320
|
-
examples: z.array(ComponentExampleSchema).optional(),
|
|
321
|
-
components: z
|
|
322
|
-
.array(
|
|
323
|
-
z
|
|
324
|
-
.object({examples: z.array(ComponentExampleSchema).optional()})
|
|
325
|
-
.passthrough(),
|
|
326
|
-
)
|
|
327
|
-
.optional(),
|
|
328
|
-
})
|
|
329
|
-
.passthrough();
|
|
330
|
-
|
|
331
|
-
const BaseDocFields = {
|
|
332
|
-
...AuthoredDocGraphFields,
|
|
333
|
-
name: z.string().min(1, 'name is required'),
|
|
334
|
-
displayName: z.string().optional(),
|
|
335
|
-
description: z.string().optional(),
|
|
336
|
-
usage: z.unknown().optional(),
|
|
337
|
-
import: z.string().min(1).optional(),
|
|
338
|
-
group: z.string().optional(),
|
|
339
|
-
category: z.string().optional(),
|
|
340
|
-
keywords: z.array(z.string()).optional(),
|
|
341
|
-
parent: z.string().optional(),
|
|
342
|
-
relatedDocs: z.array(z.string()).optional(),
|
|
343
|
-
hidden: z.boolean().optional(),
|
|
344
|
-
isHiddenFromOverview: z.boolean().optional(),
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* A deprecated component's replacement (`ComponentBaseDoc.deprecated`). Strict:
|
|
349
|
-
* the docsite and search read both fields, so a misspelled one fails to load.
|
|
350
|
-
*/
|
|
351
|
-
const ComponentDeprecationSchema = z
|
|
352
|
-
.object({
|
|
353
|
-
replacement: nonEmptyString,
|
|
354
|
-
description: nonEmptyString,
|
|
355
|
-
})
|
|
356
|
-
.strict();
|
|
357
|
-
|
|
358
|
-
const ComponentBaseSchema = z
|
|
359
|
-
.object({
|
|
360
|
-
...BaseDocFields,
|
|
361
|
-
type: z.literal('component'),
|
|
362
|
-
theming: z.unknown().optional(),
|
|
363
|
-
playground: z.unknown().optional(),
|
|
364
|
-
examples: z.array(ComponentExampleSchema).optional(),
|
|
365
|
-
replaces: z.string().min(1).optional(),
|
|
366
|
-
deprecated: ComponentDeprecationSchema.optional(),
|
|
367
|
-
})
|
|
368
|
-
.passthrough();
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* One entry in a group doc's `components`: a full ComponentEntry or a
|
|
372
|
-
* name-only ComponentRef. Readers look every entry up by `name`, so that much
|
|
373
|
-
* is checked here; the rest passes through, as on an unstamped doc.
|
|
374
|
-
*/
|
|
375
|
-
const ComponentGroupEntrySchema = z
|
|
376
|
-
.object({
|
|
377
|
-
name: z.string().min(1, 'component name is required'),
|
|
378
|
-
examples: z.array(ComponentExampleSchema).optional(),
|
|
379
|
-
})
|
|
380
|
-
.passthrough();
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* New-format stamped component doc (`type: 'component'`): one component's
|
|
384
|
-
* `props`, or the `components` a group doc documents together. These are the
|
|
385
|
-
* shapes the published ComponentDoc type allows, and the ones an unstamped doc
|
|
386
|
-
* may already take.
|
|
387
|
-
*/
|
|
388
|
-
export const ComponentDocKindSchema = ComponentBaseSchema.extend({
|
|
389
|
-
props: z.array(PropSchema).optional(),
|
|
390
|
-
components: z.array(ComponentGroupEntrySchema).optional(),
|
|
391
|
-
}).superRefine((doc, context) => {
|
|
392
|
-
if (doc.props == null && doc.components == null) {
|
|
393
|
-
context.addIssue({
|
|
394
|
-
code: 'custom',
|
|
395
|
-
path: ['props'],
|
|
396
|
-
message:
|
|
397
|
-
'expected the props array, or `components` for a doc that groups several components',
|
|
63
|
+
aliases: z.array(nonEmptyString).optional(),
|
|
64
|
+
audience: z.enum(['public', 'internal']).optional(),
|
|
65
|
+
stability: z.literal('experimental').optional(),
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const _AuthoredDocGraphSchema = z.object(AuthoredDocGraphFields).strict();
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @typedef {import('../_shared/contract.js').Expect<
|
|
72
|
+
* import('../_shared/contract.js').MutuallyAssignable<
|
|
73
|
+
* z.infer<typeof _AuthoredDocGraphSchema>,
|
|
74
|
+
* AuthoredDocGraphFieldsType
|
|
75
|
+
* >
|
|
76
|
+
* >} _AuthoredDocGraphDriftLock
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
const ProseBlockSchema = z
|
|
80
|
+
.object({type: z.literal('prose'), text: nonEmptyString})
|
|
81
|
+
.strict();
|
|
82
|
+
const HeadingBlockSchema = z
|
|
83
|
+
.object({
|
|
84
|
+
type: z.literal('heading'),
|
|
85
|
+
level: z.union([z.literal(3), z.literal(4), z.literal(5), z.literal(6)]),
|
|
86
|
+
text: nonEmptyString,
|
|
87
|
+
})
|
|
88
|
+
.strict();
|
|
89
|
+
const CodeBlockSchema = z
|
|
90
|
+
.object({
|
|
91
|
+
type: z.literal('code'),
|
|
92
|
+
lang: nonEmptyString,
|
|
93
|
+
code: z.string(),
|
|
94
|
+
label: nonEmptyString.optional(),
|
|
95
|
+
})
|
|
96
|
+
.strict();
|
|
97
|
+
const TableBlockSchema = z
|
|
98
|
+
.object({
|
|
99
|
+
type: z.literal('table'),
|
|
100
|
+
headers: z.array(z.string()).min(1),
|
|
101
|
+
rows: z.array(z.array(z.string())),
|
|
102
|
+
})
|
|
103
|
+
.strict()
|
|
104
|
+
.superRefine((table, context) => {
|
|
105
|
+
table.rows.forEach((row, index) => {
|
|
106
|
+
if (row.length !== table.headers.length) {
|
|
107
|
+
context.addIssue({
|
|
108
|
+
code: 'custom',
|
|
109
|
+
path: ['rows', index],
|
|
110
|
+
message: `expected ${table.headers.length} cells`,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
});
|
|
398
114
|
});
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
115
|
+
const ListBlockSchema = z
|
|
116
|
+
.object({
|
|
117
|
+
type: z.literal('list'),
|
|
118
|
+
style: z.enum(['ordered', 'unordered', 'do', 'dont']),
|
|
119
|
+
items: z.array(nonEmptyString).min(1),
|
|
120
|
+
})
|
|
121
|
+
.strict();
|
|
122
|
+
const TokenReferenceBlockSchema = z
|
|
123
|
+
.object({
|
|
124
|
+
type: z.literal('token-ref'),
|
|
125
|
+
topic: nonEmptyString,
|
|
126
|
+
section: nonEmptyString,
|
|
127
|
+
})
|
|
128
|
+
.strict();
|
|
129
|
+
const WorkflowBlockSchema = z
|
|
130
|
+
.object({
|
|
131
|
+
type: z.literal('workflow'),
|
|
132
|
+
title: nonEmptyString.optional(),
|
|
133
|
+
steps: z
|
|
134
|
+
.array(
|
|
135
|
+
z
|
|
136
|
+
.object({
|
|
137
|
+
title: nonEmptyString,
|
|
138
|
+
description: nonEmptyString.optional(),
|
|
139
|
+
references: z.array(nonEmptyString).min(1).optional(),
|
|
140
|
+
})
|
|
141
|
+
.strict(),
|
|
142
|
+
)
|
|
143
|
+
.min(1),
|
|
144
|
+
})
|
|
145
|
+
.strict();
|
|
146
|
+
const CollectionBlockSchema = z
|
|
147
|
+
.object({
|
|
148
|
+
type: z.literal('collection'),
|
|
149
|
+
title: nonEmptyString.optional(),
|
|
150
|
+
source: z.object({slot: nonEmptyString}).strict(),
|
|
151
|
+
presentation: z.enum(['list', 'cards', 'compact']).optional(),
|
|
152
|
+
whenEmpty: z.enum(['show', 'omit']).optional(),
|
|
153
|
+
})
|
|
154
|
+
.strict();
|
|
155
|
+
const ReferenceBlockSchema = z
|
|
156
|
+
.object({
|
|
157
|
+
type: z.literal('reference'),
|
|
158
|
+
target: nonEmptyString,
|
|
159
|
+
projection: z
|
|
160
|
+
.object({
|
|
161
|
+
fields: z.array(nonEmptyString).min(1).optional(),
|
|
162
|
+
sections: z.array(nonEmptyString).min(1).optional(),
|
|
163
|
+
})
|
|
164
|
+
.strict()
|
|
165
|
+
.optional(),
|
|
166
|
+
presentation: z.enum(['summary', 'compact', 'full']).optional(),
|
|
167
|
+
})
|
|
168
|
+
.strict();
|
|
169
|
+
|
|
170
|
+
/** Runtime schema for the stable content-block union published in 0.6.x. */
|
|
171
|
+
const ReferenceContentBlockSchema = z.discriminatedUnion('type', [
|
|
172
|
+
ProseBlockSchema,
|
|
173
|
+
HeadingBlockSchema,
|
|
174
|
+
CodeBlockSchema,
|
|
175
|
+
TableBlockSchema,
|
|
176
|
+
ListBlockSchema,
|
|
177
|
+
TokenReferenceBlockSchema,
|
|
178
|
+
]);
|
|
179
|
+
|
|
180
|
+
/** Runtime schema for graph-only blocks used by NamespaceDoc. */
|
|
181
|
+
const GraphContentBlockSchema = z.discriminatedUnion('type', [
|
|
182
|
+
WorkflowBlockSchema,
|
|
183
|
+
CollectionBlockSchema,
|
|
184
|
+
ReferenceBlockSchema,
|
|
185
|
+
]);
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* A topic section's blocks: the stable union, plus a reference block, which a
|
|
189
|
+
* read inlines as the doc it includes.
|
|
190
|
+
*/
|
|
191
|
+
const SectionContentBlockSchema = z.discriminatedUnion('type', [
|
|
192
|
+
ProseBlockSchema,
|
|
193
|
+
HeadingBlockSchema,
|
|
194
|
+
CodeBlockSchema,
|
|
195
|
+
TableBlockSchema,
|
|
196
|
+
ListBlockSchema,
|
|
197
|
+
TokenReferenceBlockSchema,
|
|
198
|
+
ReferenceBlockSchema,
|
|
199
|
+
]);
|
|
200
|
+
|
|
201
|
+
/** Namespace content accepts both stable reference blocks and graph-only blocks. */
|
|
202
|
+
const NamespaceContentBlockSchema = z.discriminatedUnion('type', [
|
|
203
|
+
ProseBlockSchema,
|
|
204
|
+
HeadingBlockSchema,
|
|
205
|
+
CodeBlockSchema,
|
|
206
|
+
TableBlockSchema,
|
|
207
|
+
ListBlockSchema,
|
|
208
|
+
TokenReferenceBlockSchema,
|
|
209
|
+
WorkflowBlockSchema,
|
|
210
|
+
CollectionBlockSchema,
|
|
211
|
+
ReferenceBlockSchema,
|
|
212
|
+
]);
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* @typedef {import('../_shared/contract.js').Expect<
|
|
216
|
+
* import('../_shared/contract.js').Equal<
|
|
217
|
+
* z.infer<typeof ReferenceContentBlockSchema>,
|
|
218
|
+
* ReferenceContentBlock
|
|
219
|
+
* >
|
|
220
|
+
* >} _ReferenceContentBlockDriftLock
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* @typedef {import('../_shared/contract.js').Expect<
|
|
225
|
+
* import('../_shared/contract.js').Equal<
|
|
226
|
+
* z.infer<typeof GraphContentBlockSchema>,
|
|
227
|
+
* GraphContentBlock
|
|
228
|
+
* >
|
|
229
|
+
* >} _GraphContentBlockDriftLock
|
|
230
|
+
*/
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* @typedef {import('../_shared/contract.js').Expect<
|
|
234
|
+
* import('../_shared/contract.js').Equal<
|
|
235
|
+
* z.infer<typeof SectionContentBlockSchema>,
|
|
236
|
+
* ReferenceSection['content'][number]
|
|
237
|
+
* >
|
|
238
|
+
* >} _SectionContentBlockDriftLock
|
|
239
|
+
*/
|
|
240
|
+
|
|
241
|
+
const ReferenceSectionSchema = z
|
|
242
|
+
.object({
|
|
243
|
+
id: nonEmptyString.optional(),
|
|
244
|
+
title: nonEmptyString,
|
|
245
|
+
category: z.string().optional(),
|
|
246
|
+
content: z.array(SectionContentBlockSchema),
|
|
247
|
+
// Where an extension adds this section to the topic it extends: before
|
|
248
|
+
// or after the section with this key. Ignored on any other section.
|
|
249
|
+
before: nonEmptyString.optional(),
|
|
250
|
+
after: nonEmptyString.optional(),
|
|
251
|
+
previewType: z
|
|
252
|
+
.enum([
|
|
253
|
+
'swatch',
|
|
254
|
+
'shadow-box',
|
|
255
|
+
'radius-box',
|
|
256
|
+
'spacing-bar',
|
|
257
|
+
'size-bar',
|
|
258
|
+
'border-line',
|
|
259
|
+
'duration-bar',
|
|
260
|
+
'easing-curve',
|
|
261
|
+
'font-sample',
|
|
262
|
+
])
|
|
263
|
+
.optional(),
|
|
264
|
+
})
|
|
265
|
+
.strict();
|
|
426
266
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
267
|
+
const PropSchema = z
|
|
268
|
+
.object({
|
|
269
|
+
name: z.string().min(1, 'prop name is required'),
|
|
270
|
+
type: z.string().min(1, 'prop type is required'),
|
|
271
|
+
description: z.string(),
|
|
272
|
+
default: z.string().optional(),
|
|
273
|
+
required: z.boolean().optional(),
|
|
274
|
+
})
|
|
275
|
+
.passthrough();
|
|
435
276
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
z
|
|
446
|
-
.object({
|
|
447
|
-
label: z.string().optional(),
|
|
448
|
-
code: z.string(),
|
|
449
|
-
result: z.string().optional(),
|
|
450
|
-
kind: ExampleKindSchema.optional(),
|
|
451
|
-
})
|
|
452
|
-
.passthrough(),
|
|
453
|
-
)
|
|
454
|
-
.optional(),
|
|
455
|
-
})
|
|
456
|
-
.passthrough();
|
|
277
|
+
const ParamSchema = z
|
|
278
|
+
.object({
|
|
279
|
+
name: z.string().min(1, 'param name is required'),
|
|
280
|
+
type: z.string().min(1, 'param type is required'),
|
|
281
|
+
description: z.string(),
|
|
282
|
+
default: z.string().optional(),
|
|
283
|
+
required: z.boolean().optional(),
|
|
284
|
+
})
|
|
285
|
+
.passthrough();
|
|
457
286
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
287
|
+
const ReturnSchema = z
|
|
288
|
+
.object({
|
|
289
|
+
name: z.string().min(1, 'return name is required'),
|
|
290
|
+
type: z.string().min(1, 'return type is required'),
|
|
291
|
+
description: z.string(),
|
|
292
|
+
})
|
|
293
|
+
.passthrough();
|
|
294
|
+
|
|
295
|
+
/** Every example kind, in the order the docs list them. */
|
|
296
|
+
const EXAMPLE_KINDS = /** @type {const} */ (['demo', 'setup']);
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* An example's `kind`. The message names both values and what each one does,
|
|
300
|
+
* because an author who misspells it needs to pick again.
|
|
301
|
+
*/
|
|
302
|
+
const ExampleKindSchema = z.enum(EXAMPLE_KINDS, {
|
|
303
|
+
error: issue =>
|
|
304
|
+
`unknown example kind ${JSON.stringify(issue.input)}; use 'demo' (may render as a live preview) or 'setup' (code only)`,
|
|
305
|
+
});
|
|
473
306
|
|
|
474
|
-
/**
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
307
|
+
/**
|
|
308
|
+
* One component example as it loads. Only `kind` is checked: the rest passes
|
|
309
|
+
* through unchecked, as component examples always have.
|
|
310
|
+
*/
|
|
311
|
+
const ComponentExampleSchema = z
|
|
312
|
+
.object({kind: ExampleKindSchema.optional()})
|
|
313
|
+
.passthrough();
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* The example fields of any doc, checked before the permissive legacy union so
|
|
317
|
+
* a bad `kind` fails with its own message, not as a union mismatch.
|
|
318
|
+
*/
|
|
319
|
+
const DocExampleKindsSchema = z
|
|
320
|
+
.object({
|
|
321
|
+
examples: z.array(ComponentExampleSchema).optional(),
|
|
322
|
+
components: z
|
|
323
|
+
.array(
|
|
324
|
+
z
|
|
325
|
+
.object({examples: z.array(ComponentExampleSchema).optional()})
|
|
326
|
+
.passthrough(),
|
|
327
|
+
)
|
|
328
|
+
.optional(),
|
|
329
|
+
})
|
|
330
|
+
.passthrough();
|
|
479
331
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
type: z.literal('generic'),
|
|
490
|
-
title: nonEmptyString.optional(),
|
|
491
|
-
// Search terms the title and sections do not use; `astryx search` matches
|
|
492
|
-
// them as keywords of the whole topic (ReferenceDoc `keywords`).
|
|
332
|
+
const BaseDocFields = {
|
|
333
|
+
...AuthoredDocGraphFields,
|
|
334
|
+
name: z.string().min(1, 'name is required'),
|
|
335
|
+
displayName: z.string().optional(),
|
|
336
|
+
description: z.string().optional(),
|
|
337
|
+
usage: z.unknown().optional(),
|
|
338
|
+
import: z.string().min(1).optional(),
|
|
339
|
+
group: z.string().optional(),
|
|
340
|
+
category: z.string().optional(),
|
|
493
341
|
keywords: z.array(z.string()).optional(),
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
342
|
+
parent: z.string().optional(),
|
|
343
|
+
relatedDocs: z.array(z.string()).optional(),
|
|
344
|
+
hidden: z.boolean().optional(),
|
|
345
|
+
isHiddenFromOverview: z.boolean().optional(),
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* A deprecated component's replacement (`ComponentBaseDoc.deprecated`). Strict:
|
|
350
|
+
* the docsite and search read both fields, so a misspelled one fails to load.
|
|
351
|
+
*/
|
|
352
|
+
const ComponentDeprecationSchema = z
|
|
353
|
+
.object({
|
|
354
|
+
replacement: nonEmptyString,
|
|
355
|
+
description: nonEmptyString,
|
|
356
|
+
})
|
|
357
|
+
.strict();
|
|
358
|
+
|
|
359
|
+
const ComponentBaseSchema = z
|
|
360
|
+
.object({
|
|
361
|
+
...BaseDocFields,
|
|
362
|
+
type: z.literal('component'),
|
|
363
|
+
theming: z.unknown().optional(),
|
|
364
|
+
playground: z.unknown().optional(),
|
|
365
|
+
examples: z.array(ComponentExampleSchema).optional(),
|
|
366
|
+
replaces: z.string().min(1).optional(),
|
|
367
|
+
deprecated: ComponentDeprecationSchema.optional(),
|
|
368
|
+
})
|
|
369
|
+
.passthrough();
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* One entry in a group doc's `components`: a full ComponentEntry or a
|
|
373
|
+
* name-only ComponentRef. Readers look every entry up by `name`, so that much
|
|
374
|
+
* is checked here; the rest passes through, as on an unstamped doc.
|
|
375
|
+
*/
|
|
376
|
+
const ComponentGroupEntrySchema = z
|
|
377
|
+
.object({
|
|
378
|
+
name: z.string().min(1, 'component name is required'),
|
|
379
|
+
examples: z.array(ComponentExampleSchema).optional(),
|
|
380
|
+
})
|
|
381
|
+
.passthrough();
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* New-format stamped component doc (`type: 'component'`): one component's
|
|
385
|
+
* `props`, or the `components` a group doc documents together. These are the
|
|
386
|
+
* shapes the published ComponentDoc type allows, and the ones an unstamped doc
|
|
387
|
+
* may already take.
|
|
388
|
+
*/
|
|
389
|
+
const ComponentDocKindSchema = ComponentBaseSchema.extend({
|
|
390
|
+
props: z.array(PropSchema).optional(),
|
|
391
|
+
components: z.array(ComponentGroupEntrySchema).optional(),
|
|
392
|
+
}).superRefine((doc, context) => {
|
|
393
|
+
if (doc.props == null && doc.components == null) {
|
|
502
394
|
context.addIssue({
|
|
503
395
|
code: 'custom',
|
|
504
|
-
path: ['
|
|
505
|
-
message:
|
|
396
|
+
path: ['props'],
|
|
397
|
+
message:
|
|
398
|
+
'expected the props array, or `components` for a doc that groups several components',
|
|
506
399
|
});
|
|
507
400
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* A stamped component doc as it loads. The loader accepts what the unstamped
|
|
405
|
+
* format always accepted, so stamping an existing doc never breaks it:
|
|
406
|
+
* `displayName` may be missing, `category` is any string, `usage`, `theming`
|
|
407
|
+
* and `playground` pass through unchecked, an example is checked only for its
|
|
408
|
+
* `kind`, and a doc has `props`, `components`, or both; each `components` entry
|
|
409
|
+
* needs only a `name`. Every
|
|
410
|
+
* other field matches the published type.
|
|
411
|
+
*
|
|
412
|
+
* @typedef {Omit<SingleComponentDoc,
|
|
413
|
+
* 'type' | 'displayName' | 'category' | 'usage' | 'theming' | 'examples' | 'playground' | 'props'>
|
|
414
|
+
* & {type: 'component', displayName?: string, category?: string, usage?: unknown,
|
|
415
|
+
* theming?: unknown, examples?: Array<{kind?: ExampleKind}>, playground?: unknown,
|
|
416
|
+
* props?: ComponentPropDoc[],
|
|
417
|
+
* components?: Array<{name: string, examples?: Array<{kind?: ExampleKind}>}>}} LoadedComponentDoc
|
|
418
|
+
*/
|
|
419
|
+
/**
|
|
420
|
+
* @typedef {import('../_shared/contract.js').Expect<
|
|
421
|
+
* import('../_shared/contract.js').MutuallyAssignable<
|
|
422
|
+
* import('../_shared/contract.js').NamedFields<z.infer<typeof ComponentDocKindSchema>>,
|
|
423
|
+
* import('../_shared/contract.js').NamedFields<LoadedComponentDoc>
|
|
424
|
+
* >
|
|
425
|
+
* >} _ComponentDocDriftLock
|
|
426
|
+
*/
|
|
427
|
+
|
|
428
|
+
/** Return entry for generalized function docs. */
|
|
429
|
+
const FunctionReturnSchema = z
|
|
430
|
+
.object({
|
|
431
|
+
name: z.string().min(1).optional(),
|
|
432
|
+
type: z.string().min(1, 'return type is required'),
|
|
433
|
+
description: z.string(),
|
|
434
|
+
})
|
|
435
|
+
.passthrough();
|
|
436
|
+
|
|
437
|
+
/** New-format stamped function doc (`type: 'function'`). */
|
|
438
|
+
const FunctionDocKindSchema = z
|
|
439
|
+
.object({
|
|
440
|
+
...BaseDocFields,
|
|
441
|
+
type: z.literal('function'),
|
|
442
|
+
params: z.array(ParamSchema),
|
|
443
|
+
returns: z.array(FunctionReturnSchema),
|
|
444
|
+
examples: z
|
|
445
|
+
.array(
|
|
446
|
+
z
|
|
447
|
+
.object({
|
|
448
|
+
label: z.string().optional(),
|
|
449
|
+
code: z.string(),
|
|
450
|
+
result: z.string().optional(),
|
|
451
|
+
kind: ExampleKindSchema.optional(),
|
|
452
|
+
})
|
|
453
|
+
.passthrough(),
|
|
454
|
+
)
|
|
455
|
+
.optional(),
|
|
456
|
+
})
|
|
457
|
+
.passthrough();
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* A stamped function doc as it loads: as with components, `displayName` may be
|
|
461
|
+
* missing and `usage` passes through unchecked.
|
|
462
|
+
*
|
|
463
|
+
* @typedef {Omit<FunctionDoc, 'type' | 'displayName' | 'usage'>
|
|
464
|
+
* & {type: 'function', displayName?: string, usage?: unknown}} LoadedFunctionDoc
|
|
465
|
+
*/
|
|
466
|
+
/**
|
|
467
|
+
* @typedef {import('../_shared/contract.js').Expect<
|
|
468
|
+
* import('../_shared/contract.js').MutuallyAssignable<
|
|
469
|
+
* import('../_shared/contract.js').NamedFields<z.infer<typeof FunctionDocKindSchema>>,
|
|
470
|
+
* import('../_shared/contract.js').NamedFields<LoadedFunctionDoc>
|
|
471
|
+
* >
|
|
472
|
+
* >} _FunctionDocDriftLock
|
|
473
|
+
*/
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Every HookDoc is a FunctionDoc, so the one function schema covers both.
|
|
477
|
+
*
|
|
478
|
+
* @typedef {import('../_shared/contract.js').Expect<[HookDoc] extends [FunctionDoc] ? true : false>} _HookDocIsFunctionDocLock
|
|
479
|
+
*/
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Stamped generic reference/topic doc (`type: 'generic'`). `title` and
|
|
483
|
+
* `sections` stay optional at this parser boundary for docs produced by the
|
|
484
|
+
* shipped v0.3.0 factory-removal codemod. When present, all rich fields and
|
|
485
|
+
* semantic blocks are validated.
|
|
486
|
+
*/
|
|
487
|
+
const GenericDocKindSchema = z
|
|
488
|
+
.object({
|
|
489
|
+
...BaseDocFields,
|
|
490
|
+
type: z.literal('generic'),
|
|
491
|
+
title: nonEmptyString.optional(),
|
|
492
|
+
// Search terms the title and sections do not use; `astryx search` matches
|
|
493
|
+
// them as keywords of the whole topic (ReferenceDoc `keywords`).
|
|
494
|
+
keywords: z.array(z.string()).optional(),
|
|
495
|
+
sections: z.array(ReferenceSectionSchema).min(1).optional(),
|
|
496
|
+
replaces: nonEmptyString.optional(),
|
|
497
|
+
extends: nonEmptyString.optional(),
|
|
498
|
+
tokenCategory: z.string().optional(),
|
|
499
|
+
})
|
|
500
|
+
.passthrough()
|
|
501
|
+
.superRefine((doc, context) => {
|
|
502
|
+
if (doc.replaces != null && doc.extends != null) {
|
|
512
503
|
context.addIssue({
|
|
513
504
|
code: 'custom',
|
|
514
|
-
path: ['
|
|
515
|
-
message: `
|
|
505
|
+
path: ['extends'],
|
|
506
|
+
message: 'declares both `replaces` and `extends`; choose one',
|
|
516
507
|
});
|
|
517
508
|
}
|
|
518
|
-
sectionIds
|
|
509
|
+
const sectionIds = new Set();
|
|
510
|
+
doc.sections?.forEach((section, index) => {
|
|
511
|
+
if (section.id == null) return;
|
|
512
|
+
if (sectionIds.has(section.id)) {
|
|
513
|
+
context.addIssue({
|
|
514
|
+
code: 'custom',
|
|
515
|
+
path: ['sections', index, 'id'],
|
|
516
|
+
message: `duplicate section id "${section.id}"`,
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
sectionIds.add(section.id);
|
|
520
|
+
});
|
|
519
521
|
});
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
* A stamped generic doc as the load check accepts it. `title`, `description`
|
|
524
|
-
* and `sections` may be missing, as in docs the v0.3.0 factory-removal codemod
|
|
525
|
-
* produced; `parseReference` then fills them (title from `displayName` or
|
|
526
|
-
* `name`, an empty description, no sections), so its result is a full
|
|
527
|
-
* ReferenceDoc. Only a doc with a description and sections is a usable topic
|
|
528
|
-
* (see `problemsInTopic`).
|
|
529
|
-
*
|
|
530
|
-
* @typedef {Omit<ReferenceDoc, 'type' | 'title' | 'description' | 'sections'>
|
|
531
|
-
* & {type: 'generic'}
|
|
532
|
-
* & Partial<Pick<ReferenceDoc, 'title' | 'description' | 'sections'>>} LoadedReferenceDoc
|
|
533
|
-
*/
|
|
534
|
-
/**
|
|
535
|
-
* @typedef {import('../_shared/contract.js').Expect<
|
|
536
|
-
* import('../_shared/contract.js').MutuallyAssignable<
|
|
537
|
-
* import('../_shared/contract.js').NamedFields<z.infer<typeof GenericDocKindSchema>>,
|
|
538
|
-
* import('../_shared/contract.js').NamedFields<LoadedReferenceDoc>
|
|
539
|
-
* >
|
|
540
|
-
* >} _ReferenceDocDriftLock
|
|
541
|
-
*/
|
|
542
|
-
|
|
543
|
-
/** Recursive field descriptor for a SchemaDoc. */
|
|
544
|
-
const SchemaFieldSchema =
|
|
545
|
-
/** @type {import('zod').ZodType<import('./schema/type.js').SchemaFieldDoc>} */ (
|
|
546
|
-
z.lazy(() =>
|
|
547
|
-
z
|
|
548
|
-
.object({
|
|
549
|
-
name: z.string().min(1, 'field name is required'),
|
|
550
|
-
type: z
|
|
551
|
-
.string({error: 'field type is required'})
|
|
552
|
-
.min(1, 'field type is required'),
|
|
553
|
-
description: z.string(),
|
|
554
|
-
required: z.boolean().optional(),
|
|
555
|
-
default: z.string().optional(),
|
|
556
|
-
example: z.string().optional(),
|
|
557
|
-
deprecated: z.string().optional(),
|
|
558
|
-
stability: z.literal('experimental').optional(),
|
|
559
|
-
fields: z.array(SchemaFieldSchema).optional(),
|
|
560
|
-
})
|
|
561
|
-
.passthrough(),
|
|
562
|
-
)
|
|
563
|
-
);
|
|
564
|
-
|
|
565
|
-
/** New stamped schema doc (`type: 'schema'`). */
|
|
566
|
-
export const SchemaDocKindSchema = z
|
|
567
|
-
.object({
|
|
568
|
-
...AuthoredDocGraphFields,
|
|
569
|
-
type: z.literal('schema'),
|
|
570
|
-
name: z.string().min(1, 'name is required'),
|
|
571
|
-
displayName: z.string().min(1, 'displayName is required'),
|
|
572
|
-
description: z.string(),
|
|
573
|
-
namespace: z.string().optional(),
|
|
574
|
-
appliesTo: z.string().optional(),
|
|
575
|
-
fields: z.array(SchemaFieldSchema),
|
|
576
|
-
examples: z
|
|
577
|
-
.array(
|
|
578
|
-
z
|
|
579
|
-
.object({label: z.string().optional(), code: z.string()})
|
|
580
|
-
.passthrough(),
|
|
581
|
-
)
|
|
582
|
-
.optional(),
|
|
583
|
-
notes: z.array(ReferenceContentBlockSchema).optional(),
|
|
584
|
-
})
|
|
585
|
-
.passthrough();
|
|
586
|
-
|
|
587
|
-
/**
|
|
588
|
-
* @typedef {import('../_shared/contract.js').Expect<
|
|
589
|
-
* import('../_shared/contract.js').MutuallyAssignable<
|
|
590
|
-
* import('../_shared/contract.js').NamedFields<z.infer<typeof SchemaDocKindSchema>>,
|
|
591
|
-
* import('../_shared/contract.js').NamedFields<SchemaDoc & {type: 'schema'}>
|
|
592
|
-
* >
|
|
593
|
-
* >} _SchemaDocDriftLock
|
|
594
|
-
*/
|
|
595
522
|
|
|
596
|
-
/**
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
523
|
+
/**
|
|
524
|
+
* A stamped generic doc as the load check accepts it. `title`, `description`
|
|
525
|
+
* and `sections` may be missing, as in docs the v0.3.0 factory-removal codemod
|
|
526
|
+
* produced; `parseReference` then fills them (title from `displayName` or
|
|
527
|
+
* `name`, an empty description, no sections), so its result is a full
|
|
528
|
+
* ReferenceDoc. Only a doc with a description and sections is a usable topic
|
|
529
|
+
* (see `problemsInTopic`).
|
|
530
|
+
*
|
|
531
|
+
* @typedef {Omit<ReferenceDoc, 'type' | 'title' | 'description' | 'sections'>
|
|
532
|
+
* & {type: 'generic'}
|
|
533
|
+
* & Partial<Pick<ReferenceDoc, 'title' | 'description' | 'sections'>>} LoadedReferenceDoc
|
|
534
|
+
*/
|
|
535
|
+
/**
|
|
536
|
+
* @typedef {import('../_shared/contract.js').Expect<
|
|
537
|
+
* import('../_shared/contract.js').MutuallyAssignable<
|
|
538
|
+
* import('../_shared/contract.js').NamedFields<z.infer<typeof GenericDocKindSchema>>,
|
|
539
|
+
* import('../_shared/contract.js').NamedFields<LoadedReferenceDoc>
|
|
540
|
+
* >
|
|
541
|
+
* >} _ReferenceDocDriftLock
|
|
542
|
+
*/
|
|
543
|
+
|
|
544
|
+
/** Recursive field descriptor for a SchemaDoc. */
|
|
545
|
+
const SchemaFieldSchema =
|
|
546
|
+
/** @type {import('zod').ZodType<import('./schema/type.js').SchemaFieldDoc>} */ (
|
|
547
|
+
z.lazy(() =>
|
|
620
548
|
z
|
|
621
549
|
.object({
|
|
622
|
-
name: z.string().min(1),
|
|
623
|
-
|
|
624
|
-
|
|
550
|
+
name: z.string().min(1, 'field name is required'),
|
|
551
|
+
type: z
|
|
552
|
+
.string({error: 'field type is required'})
|
|
553
|
+
.min(1, 'field type is required'),
|
|
554
|
+
description: z.string(),
|
|
625
555
|
required: z.boolean().optional(),
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
})
|
|
632
|
-
.passthrough(),
|
|
633
|
-
)
|
|
634
|
-
.optional(),
|
|
635
|
-
options: z
|
|
636
|
-
.array(
|
|
637
|
-
z
|
|
638
|
-
.object({
|
|
639
|
-
flag: z.string().min(1),
|
|
640
|
-
param: z.string().optional(),
|
|
641
|
-
description: z.string().optional(),
|
|
642
|
-
choices: z.array(z.string()).optional(),
|
|
643
|
-
default: z
|
|
644
|
-
.union([z.string(), z.boolean(), z.array(z.string())])
|
|
645
|
-
.optional(),
|
|
646
|
-
cliOnly: z.boolean().optional(),
|
|
647
|
-
requires: z.array(BaseStepSchema).optional(),
|
|
648
|
-
names: z
|
|
649
|
-
.enum(['component', 'hook', 'topic', 'template', 'theme'])
|
|
650
|
-
.optional(),
|
|
556
|
+
default: z.string().optional(),
|
|
557
|
+
example: z.string().optional(),
|
|
558
|
+
deprecated: z.string().optional(),
|
|
559
|
+
stability: z.literal('experimental').optional(),
|
|
560
|
+
fields: z.array(SchemaFieldSchema).optional(),
|
|
651
561
|
})
|
|
652
562
|
.passthrough(),
|
|
653
563
|
)
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
564
|
+
);
|
|
565
|
+
|
|
566
|
+
/** New stamped schema doc (`type: 'schema'`). */
|
|
567
|
+
const SchemaDocKindSchema = z
|
|
568
|
+
.object({
|
|
569
|
+
...AuthoredDocGraphFields,
|
|
570
|
+
type: z.literal('schema'),
|
|
571
|
+
name: z.string().min(1, 'name is required'),
|
|
572
|
+
displayName: z.string().min(1, 'displayName is required'),
|
|
573
|
+
description: z.string(),
|
|
574
|
+
namespace: z.string().optional(),
|
|
575
|
+
appliesTo: z.string().optional(),
|
|
576
|
+
fields: z.array(SchemaFieldSchema),
|
|
577
|
+
examples: z
|
|
578
|
+
.array(
|
|
579
|
+
z
|
|
580
|
+
.object({label: z.string().optional(), code: z.string()})
|
|
581
|
+
.passthrough(),
|
|
582
|
+
)
|
|
583
|
+
.optional(),
|
|
584
|
+
notes: z.array(ReferenceContentBlockSchema).optional(),
|
|
585
|
+
})
|
|
586
|
+
.passthrough();
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* @typedef {import('../_shared/contract.js').Expect<
|
|
590
|
+
* import('../_shared/contract.js').MutuallyAssignable<
|
|
591
|
+
* import('../_shared/contract.js').NamedFields<z.infer<typeof SchemaDocKindSchema>>,
|
|
592
|
+
* import('../_shared/contract.js').NamedFields<SchemaDoc & {type: 'schema'}>
|
|
593
|
+
* >
|
|
594
|
+
* >} _SchemaDocDriftLock
|
|
595
|
+
*/
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* A platform step a base serves, named `<capability>.<step>`. The schema
|
|
599
|
+
* checks the shape; the closed list lives with the CLI's requirement check,
|
|
600
|
+
* and a test holds every command declaration to it.
|
|
601
|
+
* @type {z.ZodType<import('../integration/type.js').BaseStep>}
|
|
602
|
+
*/
|
|
603
|
+
const BaseStepSchema = z.custom(
|
|
604
|
+
value => typeof value === 'string' && /^[a-z]+\.[a-zA-Z]+$/u.test(value),
|
|
605
|
+
{
|
|
606
|
+
message:
|
|
607
|
+
'a step is named `<capability>.<step>`, such as `themes.compile`',
|
|
608
|
+
},
|
|
609
|
+
);
|
|
610
|
+
|
|
611
|
+
/** New stamped command doc (`type: 'command'`). */
|
|
612
|
+
const CommandDocKindSchema = z
|
|
613
|
+
.object({
|
|
614
|
+
...AuthoredDocGraphFields,
|
|
615
|
+
type: z.literal('command'),
|
|
616
|
+
name: z.string().min(1, 'name is required'),
|
|
617
|
+
displayName: z.string().min(1, 'displayName is required'),
|
|
618
|
+
summary: z.string(),
|
|
619
|
+
description: z.string().optional(),
|
|
620
|
+
namespace: z.string().optional(),
|
|
621
|
+
fn: z.string().optional(),
|
|
622
|
+
args: z
|
|
623
|
+
.array(
|
|
624
|
+
z
|
|
625
|
+
.object({
|
|
626
|
+
name: z.string().min(1),
|
|
627
|
+
param: z.string().optional(),
|
|
628
|
+
description: z.string().optional(),
|
|
629
|
+
required: z.boolean().optional(),
|
|
630
|
+
variadic: z.boolean().optional(),
|
|
631
|
+
requires: z
|
|
632
|
+
.record(z.string(), z.array(BaseStepSchema))
|
|
633
|
+
.optional(),
|
|
634
|
+
names: z
|
|
635
|
+
.enum(['component', 'hook', 'topic', 'template', 'theme'])
|
|
636
|
+
.optional(),
|
|
637
|
+
})
|
|
638
|
+
.passthrough(),
|
|
639
|
+
)
|
|
640
|
+
.optional(),
|
|
641
|
+
options: z
|
|
642
|
+
.array(
|
|
643
|
+
z
|
|
644
|
+
.object({
|
|
645
|
+
flag: z.string().min(1),
|
|
646
|
+
param: z.string().optional(),
|
|
647
|
+
description: z.string().optional(),
|
|
648
|
+
choices: z.array(z.string()).optional(),
|
|
649
|
+
default: z
|
|
650
|
+
.union([z.string(), z.boolean(), z.array(z.string())])
|
|
651
|
+
.optional(),
|
|
652
|
+
cliOnly: z.boolean().optional(),
|
|
653
|
+
requires: z.array(BaseStepSchema).optional(),
|
|
654
|
+
names: z
|
|
655
|
+
.enum(['component', 'hook', 'topic', 'template', 'theme'])
|
|
656
|
+
.optional(),
|
|
657
|
+
})
|
|
658
|
+
.passthrough(),
|
|
659
|
+
)
|
|
660
|
+
.optional(),
|
|
661
|
+
subcommands: z.array(z.string()).optional(),
|
|
662
|
+
examples: z
|
|
663
|
+
.array(
|
|
664
|
+
z
|
|
665
|
+
.object({
|
|
666
|
+
label: z.string().optional(),
|
|
667
|
+
cli: z.string(),
|
|
668
|
+
output: z.string().optional(),
|
|
669
|
+
})
|
|
670
|
+
.passthrough(),
|
|
671
|
+
)
|
|
672
|
+
.optional(),
|
|
673
|
+
exitCodes: z
|
|
674
|
+
.array(z.object({code: z.number(), when: z.string()}).passthrough())
|
|
675
|
+
.optional(),
|
|
676
|
+
outsideProject: z.enum(['same', 'refuse', 'own']).optional(),
|
|
677
|
+
replaces: z.array(z.string()).optional(),
|
|
678
|
+
requires: z.array(BaseStepSchema).optional(),
|
|
679
|
+
pointers: z
|
|
680
|
+
.array(
|
|
681
|
+
z
|
|
682
|
+
.object({
|
|
683
|
+
commands: z.array(z.string().min(1)).min(1),
|
|
684
|
+
text: z.string().min(1),
|
|
685
|
+
})
|
|
686
|
+
.strict(),
|
|
687
|
+
)
|
|
688
|
+
.optional(),
|
|
689
|
+
related: z.array(z.string()).optional(),
|
|
690
|
+
notes: z.array(ReferenceContentBlockSchema).optional(),
|
|
691
|
+
})
|
|
692
|
+
.passthrough();
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* @typedef {import('../_shared/contract.js').Expect<
|
|
696
|
+
* import('../_shared/contract.js').MutuallyAssignable<
|
|
697
|
+
* import('../_shared/contract.js').NamedFields<z.infer<typeof CommandDocKindSchema>>,
|
|
698
|
+
* import('../_shared/contract.js').NamedFields<CommandDoc & {type: 'command'}>
|
|
699
|
+
* >
|
|
700
|
+
* >} _CommandDocDriftLock
|
|
701
|
+
*/
|
|
702
|
+
|
|
703
|
+
/** New stamped enum doc (`type: 'enum'`). */
|
|
704
|
+
const EnumDocKindSchema = z
|
|
705
|
+
.object({
|
|
706
|
+
...AuthoredDocGraphFields,
|
|
707
|
+
type: z.literal('enum'),
|
|
708
|
+
name: z.string().min(1, 'name is required'),
|
|
709
|
+
displayName: z.string().min(1, 'displayName is required'),
|
|
710
|
+
description: z.string(),
|
|
711
|
+
namespace: z.string().optional(),
|
|
712
|
+
members: z.array(
|
|
658
713
|
z
|
|
659
714
|
.object({
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
715
|
+
value: z.string().min(1, 'member value is required'),
|
|
716
|
+
description: z.string(),
|
|
717
|
+
deprecated: z.string().optional(),
|
|
718
|
+
stability: z.literal('experimental').optional(),
|
|
663
719
|
})
|
|
664
720
|
.passthrough(),
|
|
665
|
-
)
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
.optional(),
|
|
683
|
-
related: z.array(z.string()).optional(),
|
|
684
|
-
notes: z.array(ReferenceContentBlockSchema).optional(),
|
|
685
|
-
})
|
|
686
|
-
.passthrough();
|
|
687
|
-
|
|
688
|
-
/**
|
|
689
|
-
* @typedef {import('../_shared/contract.js').Expect<
|
|
690
|
-
* import('../_shared/contract.js').MutuallyAssignable<
|
|
691
|
-
* import('../_shared/contract.js').NamedFields<z.infer<typeof CommandDocKindSchema>>,
|
|
692
|
-
* import('../_shared/contract.js').NamedFields<CommandDoc & {type: 'command'}>
|
|
693
|
-
* >
|
|
694
|
-
* >} _CommandDocDriftLock
|
|
695
|
-
*/
|
|
696
|
-
|
|
697
|
-
/** New stamped enum doc (`type: 'enum'`). */
|
|
698
|
-
export const EnumDocKindSchema = z
|
|
699
|
-
.object({
|
|
700
|
-
...AuthoredDocGraphFields,
|
|
701
|
-
type: z.literal('enum'),
|
|
702
|
-
name: z.string().min(1, 'name is required'),
|
|
703
|
-
displayName: z.string().min(1, 'displayName is required'),
|
|
704
|
-
description: z.string(),
|
|
705
|
-
namespace: z.string().optional(),
|
|
706
|
-
members: z.array(
|
|
707
|
-
z
|
|
721
|
+
),
|
|
722
|
+
})
|
|
723
|
+
.passthrough();
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* @typedef {import('../_shared/contract.js').Expect<
|
|
727
|
+
* import('../_shared/contract.js').MutuallyAssignable<
|
|
728
|
+
* import('../_shared/contract.js').NamedFields<z.infer<typeof EnumDocKindSchema>>,
|
|
729
|
+
* import('../_shared/contract.js').NamedFields<EnumDoc & {type: 'enum'}>
|
|
730
|
+
* >
|
|
731
|
+
* >} _EnumDocDriftLock
|
|
732
|
+
*/
|
|
733
|
+
|
|
734
|
+
const NamespaceSlotSchema = z
|
|
735
|
+
.object({
|
|
736
|
+
title: nonEmptyString,
|
|
737
|
+
accepts: z
|
|
708
738
|
.object({
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
deprecated: z.string().optional(),
|
|
712
|
-
stability: z.literal('experimental').optional(),
|
|
739
|
+
kinds: z.array(AuthoredDocKindSchema).min(1),
|
|
740
|
+
providers: z.enum(['same', 'configured']).optional(),
|
|
713
741
|
})
|
|
714
|
-
.
|
|
715
|
-
)
|
|
716
|
-
|
|
717
|
-
.passthrough();
|
|
718
|
-
|
|
719
|
-
/**
|
|
720
|
-
* @typedef {import('../_shared/contract.js').Expect<
|
|
721
|
-
* import('../_shared/contract.js').MutuallyAssignable<
|
|
722
|
-
* import('../_shared/contract.js').NamedFields<z.infer<typeof EnumDocKindSchema>>,
|
|
723
|
-
* import('../_shared/contract.js').NamedFields<EnumDoc & {type: 'enum'}>
|
|
724
|
-
* >
|
|
725
|
-
* >} _EnumDocDriftLock
|
|
726
|
-
*/
|
|
742
|
+
.strict(),
|
|
743
|
+
})
|
|
744
|
+
.strict();
|
|
727
745
|
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
.
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
.
|
|
737
|
-
|
|
738
|
-
|
|
746
|
+
/** The one new authored doctype: a hierarchy and layout owner. */
|
|
747
|
+
const NamespaceDocKindSchema = z
|
|
748
|
+
.object({
|
|
749
|
+
...AuthoredDocGraphFields,
|
|
750
|
+
type: z.literal('namespace'),
|
|
751
|
+
name: nonEmptyString,
|
|
752
|
+
title: nonEmptyString,
|
|
753
|
+
summary: nonEmptyString,
|
|
754
|
+
keywords: z.array(nonEmptyString).optional(),
|
|
755
|
+
describes: z.literal('cli').optional(),
|
|
756
|
+
slots: z
|
|
757
|
+
.record(nonEmptyString, NamespaceSlotSchema)
|
|
758
|
+
.refine(slots => Object.keys(slots).length > 0, {
|
|
759
|
+
message: 'at least one slot is required',
|
|
760
|
+
}),
|
|
761
|
+
adopts: z
|
|
762
|
+
.array(
|
|
763
|
+
z
|
|
764
|
+
.object({
|
|
765
|
+
source: z
|
|
766
|
+
.object({
|
|
767
|
+
group: nonEmptyString,
|
|
768
|
+
kinds: z.array(AuthoredDocKindSchema).min(1).optional(),
|
|
769
|
+
packages: z.literal('all').optional(),
|
|
770
|
+
})
|
|
771
|
+
.strict(),
|
|
772
|
+
into: nonEmptyString,
|
|
773
|
+
groupBy: z.literal('kind').optional(),
|
|
774
|
+
})
|
|
775
|
+
.strict(),
|
|
776
|
+
)
|
|
777
|
+
.optional(),
|
|
778
|
+
blocks: z.array(NamespaceContentBlockSchema).optional(),
|
|
779
|
+
})
|
|
780
|
+
.strict()
|
|
781
|
+
.superRefine((doc, context) => {
|
|
782
|
+
const slots = new Set(Object.keys(doc.slots));
|
|
783
|
+
doc.adopts?.forEach((rule, index) => {
|
|
784
|
+
const slot = doc.slots[rule.into];
|
|
785
|
+
if (slot == null) {
|
|
786
|
+
context.addIssue({
|
|
787
|
+
code: 'custom',
|
|
788
|
+
path: ['adopts', index, 'into'],
|
|
789
|
+
message: `must name a declared slot; received "${rule.into}"`,
|
|
790
|
+
});
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
/** @type {AuthoredDocKind[]} */
|
|
794
|
+
const adoptedKinds =
|
|
795
|
+
rule.groupBy === 'kind' ? ['namespace'] : (rule.source.kinds ?? []);
|
|
796
|
+
adoptedKinds.forEach(kind => {
|
|
797
|
+
if (!slot.accepts.kinds.includes(kind)) {
|
|
798
|
+
context.addIssue({
|
|
799
|
+
code: 'custom',
|
|
800
|
+
path: ['adopts', index, 'into'],
|
|
801
|
+
message: `slot "${rule.into}" does not accept adopted kind "${kind}"`,
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
});
|
|
805
|
+
});
|
|
806
|
+
doc.blocks?.forEach((block, index) => {
|
|
807
|
+
if (block.type === 'collection' && !slots.has(block.source.slot)) {
|
|
808
|
+
context.addIssue({
|
|
809
|
+
code: 'custom',
|
|
810
|
+
path: ['blocks', index, 'source', 'slot'],
|
|
811
|
+
message: `must name a declared slot; received "${block.source.slot}"`,
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
});
|
|
739
816
|
|
|
740
|
-
/**
|
|
741
|
-
|
|
742
|
-
|
|
817
|
+
/**
|
|
818
|
+
* @typedef {import('../_shared/contract.js').Expect<
|
|
819
|
+
* import('../_shared/contract.js').Equal<
|
|
820
|
+
* z.infer<typeof NamespaceDocKindSchema>,
|
|
821
|
+
* NamespaceDoc
|
|
822
|
+
* >
|
|
823
|
+
* >} _NamespaceDocDriftLock
|
|
824
|
+
*/
|
|
825
|
+
|
|
826
|
+
// Legacy loose format stays permissive for backward compatibility.
|
|
827
|
+
const LegacyBaseDocSchema = z.object({
|
|
743
828
|
...AuthoredDocGraphFields,
|
|
744
|
-
|
|
745
|
-
|
|
829
|
+
name: z.string().min(1, 'name is required'),
|
|
830
|
+
displayName: z.string().optional(),
|
|
831
|
+
description: z.string().optional(),
|
|
832
|
+
group: z.string().optional(),
|
|
833
|
+
category: z.string().optional(),
|
|
834
|
+
keywords: z.array(z.string()).optional(),
|
|
835
|
+
isHiddenFromOverview: z.boolean().optional(),
|
|
836
|
+
hidden: z.boolean().optional(),
|
|
837
|
+
hiddenComponents: z.array(z.string()).optional(),
|
|
838
|
+
usage: z.unknown().optional(),
|
|
839
|
+
playground: z.unknown().optional(),
|
|
840
|
+
theming: z.unknown().optional(),
|
|
841
|
+
examples: z.array(z.unknown()).optional(),
|
|
842
|
+
showcase: z.unknown().optional(),
|
|
843
|
+
parent: z.string().optional(),
|
|
844
|
+
relatedDocs: z.array(z.string()).optional(),
|
|
845
|
+
relatedComponents: z.array(z.string()).optional(),
|
|
846
|
+
relatedHooks: z.array(z.string()).optional(),
|
|
847
|
+
});
|
|
848
|
+
|
|
849
|
+
const LegacyReferenceDocSchema = LegacyBaseDocSchema.extend({
|
|
746
850
|
title: nonEmptyString,
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
}),
|
|
755
|
-
adopts: z
|
|
756
|
-
.array(
|
|
757
|
-
z
|
|
758
|
-
.object({
|
|
759
|
-
source: z
|
|
760
|
-
.object({
|
|
761
|
-
group: nonEmptyString,
|
|
762
|
-
kinds: z.array(AuthoredDocKindSchema).min(1).optional(),
|
|
763
|
-
packages: z.literal('all').optional(),
|
|
764
|
-
})
|
|
765
|
-
.strict(),
|
|
766
|
-
into: nonEmptyString,
|
|
767
|
-
groupBy: z.literal('kind').optional(),
|
|
768
|
-
})
|
|
769
|
-
.strict(),
|
|
770
|
-
)
|
|
771
|
-
.optional(),
|
|
772
|
-
blocks: z.array(NamespaceContentBlockSchema).optional(),
|
|
851
|
+
description: z.string(),
|
|
852
|
+
// As on the stamped schema: search terms for the whole topic.
|
|
853
|
+
keywords: z.array(z.string()).optional(),
|
|
854
|
+
sections: z.array(ReferenceSectionSchema).min(1),
|
|
855
|
+
replaces: nonEmptyString.optional(),
|
|
856
|
+
extends: nonEmptyString.optional(),
|
|
857
|
+
tokenCategory: z.string().optional(),
|
|
773
858
|
})
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
doc.adopts?.forEach((rule, index) => {
|
|
778
|
-
const slot = doc.slots[rule.into];
|
|
779
|
-
if (slot == null) {
|
|
859
|
+
.passthrough()
|
|
860
|
+
.superRefine((doc, context) => {
|
|
861
|
+
if (doc.replaces != null && doc.extends != null) {
|
|
780
862
|
context.addIssue({
|
|
781
863
|
code: 'custom',
|
|
782
|
-
path: ['
|
|
783
|
-
message:
|
|
864
|
+
path: ['extends'],
|
|
865
|
+
message: 'declares both `replaces` and `extends`; choose one',
|
|
784
866
|
});
|
|
785
|
-
return;
|
|
786
867
|
}
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
if (!slot.accepts.kinds.includes(kind)) {
|
|
868
|
+
const sectionIds = new Set();
|
|
869
|
+
doc.sections.forEach((section, index) => {
|
|
870
|
+
if (section.id == null) return;
|
|
871
|
+
if (sectionIds.has(section.id)) {
|
|
792
872
|
context.addIssue({
|
|
793
873
|
code: 'custom',
|
|
794
|
-
path: ['
|
|
795
|
-
message: `
|
|
874
|
+
path: ['sections', index, 'id'],
|
|
875
|
+
message: `duplicate section id "${section.id}"`,
|
|
796
876
|
});
|
|
797
877
|
}
|
|
878
|
+
sectionIds.add(section.id);
|
|
798
879
|
});
|
|
799
880
|
});
|
|
800
|
-
doc.blocks?.forEach((block, index) => {
|
|
801
|
-
if (block.type === 'collection' && !slots.has(block.source.slot)) {
|
|
802
|
-
context.addIssue({
|
|
803
|
-
code: 'custom',
|
|
804
|
-
path: ['blocks', index, 'source', 'slot'],
|
|
805
|
-
message: `must name a declared slot; received "${block.source.slot}"`,
|
|
806
|
-
});
|
|
807
|
-
}
|
|
808
|
-
});
|
|
809
|
-
});
|
|
810
881
|
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
* NamespaceDoc
|
|
816
|
-
* >
|
|
817
|
-
* >} _NamespaceDocDriftLock
|
|
818
|
-
*/
|
|
882
|
+
const LegacySingleComponentDocSchema = LegacyBaseDocSchema.extend({
|
|
883
|
+
props: z.array(PropSchema),
|
|
884
|
+
deprecated: ComponentDeprecationSchema.optional(),
|
|
885
|
+
}).passthrough();
|
|
819
886
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
displayName: z.string().optional(),
|
|
825
|
-
description: z.string().optional(),
|
|
826
|
-
group: z.string().optional(),
|
|
827
|
-
category: z.string().optional(),
|
|
828
|
-
keywords: z.array(z.string()).optional(),
|
|
829
|
-
isHiddenFromOverview: z.boolean().optional(),
|
|
830
|
-
hidden: z.boolean().optional(),
|
|
831
|
-
hiddenComponents: z.array(z.string()).optional(),
|
|
832
|
-
usage: z.unknown().optional(),
|
|
833
|
-
playground: z.unknown().optional(),
|
|
834
|
-
theming: z.unknown().optional(),
|
|
835
|
-
examples: z.array(z.unknown()).optional(),
|
|
836
|
-
showcase: z.unknown().optional(),
|
|
837
|
-
parent: z.string().optional(),
|
|
838
|
-
relatedDocs: z.array(z.string()).optional(),
|
|
839
|
-
relatedComponents: z.array(z.string()).optional(),
|
|
840
|
-
relatedHooks: z.array(z.string()).optional(),
|
|
841
|
-
});
|
|
842
|
-
|
|
843
|
-
const LegacyReferenceDocSchema = LegacyBaseDocSchema.extend({
|
|
844
|
-
title: nonEmptyString,
|
|
845
|
-
description: z.string(),
|
|
846
|
-
// As on the stamped schema: search terms for the whole topic.
|
|
847
|
-
keywords: z.array(z.string()).optional(),
|
|
848
|
-
sections: z.array(ReferenceSectionSchema).min(1),
|
|
849
|
-
replaces: nonEmptyString.optional(),
|
|
850
|
-
extends: nonEmptyString.optional(),
|
|
851
|
-
tokenCategory: z.string().optional(),
|
|
852
|
-
})
|
|
853
|
-
.passthrough()
|
|
854
|
-
.superRefine((doc, context) => {
|
|
855
|
-
if (doc.replaces != null && doc.extends != null) {
|
|
856
|
-
context.addIssue({
|
|
857
|
-
code: 'custom',
|
|
858
|
-
path: ['extends'],
|
|
859
|
-
message: 'declares both `replaces` and `extends`; choose one',
|
|
860
|
-
});
|
|
861
|
-
}
|
|
862
|
-
const sectionIds = new Set();
|
|
863
|
-
doc.sections.forEach((section, index) => {
|
|
864
|
-
if (section.id == null) return;
|
|
865
|
-
if (sectionIds.has(section.id)) {
|
|
866
|
-
context.addIssue({
|
|
867
|
-
code: 'custom',
|
|
868
|
-
path: ['sections', index, 'id'],
|
|
869
|
-
message: `duplicate section id "${section.id}"`,
|
|
870
|
-
});
|
|
871
|
-
}
|
|
872
|
-
sectionIds.add(section.id);
|
|
873
|
-
});
|
|
874
|
-
});
|
|
887
|
+
const LegacyMultiComponentDocSchema = LegacyBaseDocSchema.extend({
|
|
888
|
+
components: z.array(z.unknown()),
|
|
889
|
+
deprecated: ComponentDeprecationSchema.optional(),
|
|
890
|
+
}).passthrough();
|
|
875
891
|
|
|
876
|
-
const
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
}).passthrough();
|
|
880
|
-
|
|
881
|
-
const
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
892
|
+
const LegacyHookDocSchema = LegacyBaseDocSchema.extend({
|
|
893
|
+
params: z.array(ParamSchema),
|
|
894
|
+
returns: z.array(ReturnSchema),
|
|
895
|
+
}).passthrough();
|
|
896
|
+
|
|
897
|
+
const LegacySubComponentDocSchema = LegacyBaseDocSchema.extend({
|
|
898
|
+
subComponentOf: z.string().min(1, 'subComponentOf is required'),
|
|
899
|
+
description: z.string(),
|
|
900
|
+
props: z.array(PropSchema),
|
|
901
|
+
deprecated: ComponentDeprecationSchema.optional(),
|
|
902
|
+
}).passthrough();
|
|
903
|
+
|
|
904
|
+
/** The permissive legacy union (sub-component, hook, multi, single, then reference). */
|
|
905
|
+
const LegacyDocSchema = z.union([
|
|
906
|
+
LegacySubComponentDocSchema,
|
|
907
|
+
LegacyHookDocSchema,
|
|
908
|
+
LegacyMultiComponentDocSchema,
|
|
909
|
+
LegacySingleComponentDocSchema,
|
|
910
|
+
LegacyReferenceDocSchema,
|
|
911
|
+
]);
|
|
912
|
+
|
|
913
|
+
return {
|
|
914
|
+
AuthoredDocKindSchema,
|
|
915
|
+
AuthoredDocGraphFields,
|
|
916
|
+
ReferenceContentBlockSchema,
|
|
917
|
+
GraphContentBlockSchema,
|
|
918
|
+
SectionContentBlockSchema,
|
|
919
|
+
NamespaceContentBlockSchema,
|
|
920
|
+
DocExampleKindsSchema,
|
|
921
|
+
ComponentDocKindSchema,
|
|
922
|
+
FunctionDocKindSchema,
|
|
923
|
+
GenericDocKindSchema,
|
|
924
|
+
SchemaDocKindSchema,
|
|
925
|
+
CommandDocKindSchema,
|
|
926
|
+
EnumDocKindSchema,
|
|
927
|
+
NamespaceDocKindSchema,
|
|
928
|
+
LegacyDocSchema,
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
/** @type {ReturnType<typeof buildDocSchemas> | undefined} */
|
|
933
|
+
let builtDocSchemas;
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* The sealed schemas. They are built when a doc is first parsed, not when
|
|
937
|
+
* this module loads: a read whose docs all have a stored or kept parse
|
|
938
|
+
* parses nothing, so it builds none of them.
|
|
939
|
+
* @returns {ReturnType<typeof buildDocSchemas>}
|
|
940
|
+
*/
|
|
941
|
+
export function docSchemas() {
|
|
942
|
+
return (builtDocSchemas ??= buildDocSchemas());
|
|
943
|
+
}
|