@astryxdesign/cli 0.6.3 → 0.6.4-canary.078fd25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +194 -0
- package/README.md +152 -107
- package/api/blog/blog.doc.mjs +1 -0
- package/api/build/_adapter.d.mts +50 -0
- package/api/build/_adapter.mjs +60 -0
- package/api/build/build.doc.mjs +22 -10
- package/api/build/build.test.mjs +219 -8
- package/api/build/build.type.d.mts +91 -2
- package/api/build/build.type.mjs +52 -8
- package/api/build/help/help.d.mts +12 -5
- package/api/build/help/help.mjs +69 -6
- package/api/build/kit/kit.d.mts +4 -1
- package/api/build/kit/kit.mjs +208 -53
- package/api/build/kit/rank.d.mts +44 -0
- package/api/build/kit/rank.mjs +432 -0
- package/api/build/kit/rank.test.mjs +196 -0
- package/api/component/_adapter.d.mts +31 -12
- package/api/component/_adapter.mjs +79 -15
- package/api/component/component.d.mts +6 -3
- package/api/component/component.doc.mjs +49 -19
- package/api/component/component.mjs +339 -22
- package/api/component/component.test.mjs +38 -0
- package/api/component/component.type.d.mts +47 -11
- package/api/component/component.type.mjs +76 -24
- package/api/component/detail/blocks/blocks.d.mts +2 -1
- package/api/component/detail/blocks/blocks.mjs +4 -3
- package/api/component/list/list.d.mts +0 -5
- package/api/component/list/list.mjs +40 -11
- package/api/discover/_adapter.d.mts +114 -6
- package/api/discover/_adapter.mjs +372 -17
- package/api/discover/_adapter.test.mjs +215 -0
- package/api/discover/_catalog-view.d.mts +115 -0
- package/api/discover/_catalog-view.mjs +203 -0
- package/api/discover/_catalog-view.test.mjs +128 -0
- package/api/discover/detail/detail.d.mts +18 -6
- package/api/discover/detail/detail.mjs +67 -13
- package/api/discover/detail/detail.test.mjs +85 -0
- package/api/discover/detail/item/item.d.mts +26 -0
- package/api/discover/detail/item/item.mjs +78 -0
- package/api/discover/detail/item/item.test.mjs +73 -0
- package/api/discover/discover.d.mts +3 -9
- package/api/discover/discover.doc.mjs +62 -18
- package/api/discover/discover.mjs +220 -36
- package/api/discover/discover.test.mjs +11 -2
- package/api/discover/discover.type.d.mts +150 -11
- package/api/discover/discover.type.mjs +107 -17
- package/api/discover/list/list.d.mts +20 -6
- package/api/discover/list/list.mjs +45 -12
- package/api/discover/list/list.test.mjs +46 -0
- package/api/discover/search/search.d.mts +18 -16
- package/api/discover/search/search.mjs +102 -56
- package/api/discover/search/search.test.mjs +144 -10
- package/api/docs/_adapter.d.mts +277 -41
- package/api/docs/_adapter.mjs +993 -108
- package/api/docs/compiled-topics.test.mjs +78 -0
- package/api/docs/detail/detail.mjs +22 -63
- package/api/docs/detail/section/section.d.mts +1 -1
- package/api/docs/detail/section/section.mjs +54 -19
- package/api/docs/detail/section/section.test.mjs +50 -0
- package/api/docs/docOverlays.test.mjs +27 -1
- package/api/docs/docs.d.mts +10 -3
- package/api/docs/docs.doc.mjs +55 -16
- package/api/docs/docs.mjs +53 -10
- package/api/docs/docs.type.d.mts +221 -5
- package/api/docs/docs.type.mjs +153 -11
- package/api/docs/index/index.d.mts +18 -0
- package/api/docs/index/index.mjs +40 -0
- package/api/docs/index/index.test.mjs +62 -0
- package/api/docs/list/list.mjs +28 -12
- package/api/docs/node/node.d.mts +43 -0
- package/api/docs/node/node.mjs +192 -0
- package/api/docs/reference-blocks.test.mjs +406 -0
- package/api/doctor/doctor.d.mts +104 -1
- package/api/doctor/doctor.doc.mjs +18 -8
- package/api/doctor/doctor.mjs +635 -7
- package/api/doctor/doctor.test.mjs +732 -11
- package/api/doctor/doctor.type.d.mts +1 -1
- package/api/doctor/doctor.type.mjs +1 -1
- package/api/gap-report/gap-report.doc.mjs +27 -14
- package/api/hook/_adapter.mjs +19 -5
- package/api/hook/hook.doc.mjs +7 -3
- package/api/hook/hook.type.d.mts +3 -3
- package/api/hook/hook.type.mjs +11 -11
- package/api/hook/list/list.d.mts +2 -2
- package/api/hook/list/list.mjs +69 -17
- package/api/index.d.mts +2 -1
- package/api/index.mjs +6 -3
- package/api/init/init.doc.mjs +22 -12
- package/api/init/init.test.mjs +41 -1
- package/api/init/remove/remove.mjs +1 -1
- package/api/init/run/run.mjs +20 -10
- package/api/integration/add-contribution.component-names.test.mjs +120 -0
- package/api/integration/add-contribution.d.mts +2 -1
- package/api/integration/add-contribution.mjs +130 -15
- package/api/integration/add-contribution.test.mjs +258 -7
- package/api/integration/add-helpers.d.mts +5 -2
- package/api/integration/add-helpers.mjs +36 -9
- package/api/integration/add-theme.mjs +56 -65
- package/api/integration/add-theme.test.mjs +139 -21
- package/api/integration/authoring-checks.mjs +138 -28
- package/api/integration/authoring-checks.test.mjs +179 -7
- package/api/integration/authoring-checks.type.mjs +6 -1
- package/api/integration/integration-authoring.type.d.mts +3 -1
- package/api/integration/integration-authoring.type.mjs +2 -0
- package/api/integration/integration-block-exports.test.mjs +10 -6
- package/api/integration/integrationAdd.doc.mjs +14 -4
- package/api/integration/integrationAddAgentDoc.doc.mjs +1 -0
- package/api/integration/integrationAddCodemod.doc.mjs +1 -0
- package/api/integration/integrationAddComponent.doc.mjs +2 -1
- package/api/integration/integrationAddDoc.doc.mjs +8 -1
- package/api/integration/integrationAddTemplate.doc.mjs +1 -0
- package/api/integration/integrationAddTheme.doc.mjs +6 -5
- package/api/integration/integrationComponentConflicts.doc.mjs +1 -0
- package/api/integration/integrationDocConflicts.doc.mjs +2 -1
- package/api/integration/integrationPackCheck.doc.mjs +5 -4
- package/api/integration/integrationTemplateConflicts.doc.d.mts +3 -0
- package/api/integration/integrationTemplateConflicts.doc.mjs +4 -0
- package/api/integration/pack-check.lifecycle-output.test.mjs +107 -0
- package/api/integration/pack-check.mjs +160 -11
- package/api/integration/pack-check.test.mjs +477 -47
- package/api/integration/pack-check.type.d.mts +26 -2
- package/api/integration/pack-check.type.mjs +15 -2
- package/api/integration/summarizeIssues.doc.mjs +1 -0
- package/api/integration/template-conflict-compatibility.test.mjs +73 -0
- package/api/integration/validate-integration-fixes.test.mjs +1389 -0
- package/api/integration/validate-integration.mjs +52 -102
- package/api/integration/validate-integration.test.mjs +179 -26
- package/api/integration/validate-unread-theme-folders.test.mjs +110 -0
- package/api/integration/validateIntegration.doc.mjs +3 -2
- package/api/json/assertResponse.doc.mjs +2 -1
- package/api/json/envelope-types.test.mjs +76 -0
- package/api/json/index.ts +2 -0
- package/api/json/isError.doc.mjs +2 -1
- package/api/json/parseResponse.doc.mjs +3 -2
- package/api/layout/_adapter.mjs +20 -5
- package/api/layout/expand/expand.mjs +7 -5
- package/api/layout/expand/expand.path-safety.test.mjs +53 -0
- package/api/layout/grammar/grammar.mjs +2 -1
- package/api/layout/layoutCheck.doc.mjs +1 -0
- package/api/layout/layoutExpand.doc.mjs +2 -1
- package/api/layout/layoutGrammar.doc.mjs +1 -0
- package/api/search/search-return-type.test.mjs +54 -0
- package/api/search/search.d.mts +89 -12
- package/api/search/search.doc.mjs +8 -2
- package/api/search/search.mjs +697 -97
- package/api/search/search.type.d.mts +15 -3
- package/api/search/search.type.mjs +5 -2
- package/api/swizzle/copy/copy.mjs +28 -11
- package/api/swizzle/swizzle.doc.mjs +8 -5
- package/api/swizzle/swizzle.type.d.mts +2 -2
- package/api/swizzle/swizzle.type.mjs +2 -2
- package/api/template/copy/copy.mjs +18 -24
- package/api/template/copy/copy.test.mjs +26 -0
- package/api/template/list/list.mjs +1 -0
- package/api/template/table-floating-bulk-actions.test.mjs +66 -0
- package/api/template/template-integration.test.mjs +1072 -3
- package/api/template/template-suffix.test.mjs +41 -21
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +32 -9
- package/api/template/template.mjs +45 -8
- package/api/template/template.type.d.mts +12 -14
- package/api/template/template.type.mjs +15 -14
- package/api/theme/_adapter.d.mts +2 -3
- package/api/theme/_adapter.mjs +4 -5
- package/api/theme/add/add.binary.test.mjs +84 -0
- package/api/theme/add/add.mjs +31 -22
- package/api/theme/add/add.rollback.test.mjs +158 -0
- package/api/theme/add/add.staging.test.mjs +83 -0
- package/api/theme/add/add.test.mjs +14 -1
- package/api/theme/build/build.family.test.mjs +7 -12
- package/api/theme/build/build.mjs +140 -59
- package/api/theme/build/build.public-component-vars.test.mjs +1 -1
- package/api/theme/build/build.receipt-doc.test.mjs +111 -0
- package/api/theme/build/build.rollback.test.mjs +148 -0
- package/api/theme/build/build.test.mjs +127 -0
- package/api/theme/build/font-warning.mjs +3 -3
- package/api/theme/build/font-warning.test.mjs +5 -2
- package/api/theme/generateTonalPalette.doc.mjs +2 -2
- package/api/theme/integration-themes.test.mjs +39 -28
- package/api/theme/list/list.test.mjs +19 -20
- package/api/theme/listThemes.doc.mjs +6 -5
- package/api/theme/palette/generate/generate.mjs +8 -3
- package/api/theme/palette/generate/generate.test.mjs +96 -0
- package/api/theme/palette/generate/generator.d.mts +10 -13
- package/api/theme/palette/generate/generator.mjs +15 -4
- package/api/theme/palette/generate/generator.test.mjs +10 -0
- package/api/theme/template/template.mjs +11 -2
- package/api/theme/template/template.test.mjs +20 -0
- package/api/theme/theme.type.d.mts +170 -11
- package/api/theme/theme.type.mjs +94 -27
- package/api/theme/themeAdd.doc.mjs +12 -12
- package/api/theme/themeBuild.doc.mjs +21 -17
- package/api/theme/themeList.doc.mjs +6 -3
- package/api/theme/themeListAvailable.doc.mjs +6 -3
- package/api/theme/themePaletteGenerate.doc.mjs +16 -8
- package/api/theme/themeTargets.doc.mjs +4 -2
- package/api/theme/themeTemplate.doc.mjs +8 -3
- package/api/upgrade/_adapter.d.mts +32 -5
- package/api/upgrade/_adapter.mjs +139 -22
- package/api/upgrade/list/list.mjs +2 -1
- package/api/upgrade/list/list.test.mjs +73 -0
- package/api/upgrade/project-context.test.mjs +272 -0
- package/api/upgrade/provider-agreement.test.mjs +152 -0
- package/api/upgrade/run/files-changed.test.mjs +111 -0
- package/api/upgrade/run/run.mjs +358 -59
- package/api/upgrade/status/status.mjs +2 -2
- package/api/upgrade/upgrade.doc.mjs +32 -23
- package/api/upgrade/upgrade.type.d.mts +43 -5
- package/api/upgrade/upgrade.type.mjs +29 -13
- package/assets/codemods/__tests__/registry.test.mjs +1 -0
- package/assets/codemods/__tests__/runner.test.mjs +332 -8
- package/assets/codemods/file-count.test.mjs +163 -0
- package/assets/codemods/integration-discovery.mjs +48 -4
- package/assets/codemods/integration-discovery.test.mjs +73 -0
- package/assets/codemods/integration-runner.mjs +59 -7
- package/assets/codemods/integration-runner.protection.test.mjs +153 -0
- package/assets/codemods/registry.mjs +1 -0
- package/assets/codemods/run-codemod.mjs +177 -34
- package/assets/codemods/runner.mjs +353 -104
- package/assets/codemods/term-log.mjs +32 -8
- package/assets/codemods/term-log.test.mjs +19 -1
- package/assets/codemods/transform-prop.mjs +109 -0
- package/assets/codemods/transform-prop.test.mjs +95 -0
- package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +86 -165
- package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +72 -210
- package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +83 -115
- package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +57 -186
- package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +27 -5
- package/assets/codemods/transforms/v0.3.0/unwrap-authoring-factories.mjs +20 -5
- package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +47 -0
- package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +57 -10
- package/assets/codemods/transforms/v0.6.4/__tests__/migrate-native-picker-to-presentation.test.mjs +63 -0
- package/assets/codemods/transforms/v0.6.4/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +220 -0
- package/assets/codemods/transforms/v0.6.4/index.mjs +31 -0
- package/assets/codemods/transforms/v0.6.4/migrate-native-picker-to-presentation.mjs +148 -0
- package/assets/codemods/transforms/v0.6.4/migrate-theme-catalog-to-descriptors.mjs +141 -0
- package/assets/docs/README.md +12 -1
- package/assets/docs/authoring.doc.mjs +14 -0
- package/assets/docs/browser-support.doc.mjs +11 -11
- package/assets/docs/color.doc.mjs +8 -2
- package/assets/docs/elevation.doc.mjs +6 -4
- package/assets/docs/getting-started.doc.mjs +6 -17
- package/assets/docs/icons.doc.mjs +2 -21
- package/assets/docs/illustrations.doc.mjs +7 -15
- package/assets/docs/internationalization.doc.mjs +7 -5
- package/assets/docs/layout.doc.dense.mjs +132 -84
- package/assets/docs/layout.doc.mjs +134 -78
- package/assets/docs/migration.doc.mjs +19 -21
- package/assets/docs/motion.doc.mjs +16 -3
- package/assets/docs/principles.doc.dense.mjs +5 -5
- package/assets/docs/principles.doc.mjs +14 -6
- package/assets/docs/principles.doc.zh.mjs +6 -6
- package/assets/docs/shape.doc.mjs +8 -3
- package/assets/docs/spacing.doc.mjs +7 -2
- package/assets/docs/styling-libraries.doc.mjs +10 -6
- package/assets/docs/styling.doc.mjs +22 -26
- package/assets/docs/theme.doc.dense.mjs +58 -18
- package/assets/docs/theme.doc.mjs +60 -50
- package/assets/docs/theme.doc.zh.mjs +9 -8
- package/assets/docs/tokens.doc.dense.mjs +2 -2
- package/assets/docs/tokens.doc.mjs +390 -9
- package/assets/docs/tokens.doc.zh.mjs +2 -2
- package/assets/docs/tree/add-a-component.doc.mjs +75 -0
- package/assets/docs/tree/add-a-theme.doc.mjs +85 -0
- package/assets/docs/tree/add-a-topic.doc.mjs +144 -0
- package/assets/docs/tree/agent-guidance.doc.mjs +138 -0
- package/assets/docs/tree/api.doc.mjs +30 -0
- package/assets/docs/tree/block-template.doc.mjs +130 -0
- package/assets/docs/tree/build-the-template.doc.mjs +28 -0
- package/assets/docs/tree/building-blocks.doc.mjs +46 -0
- package/assets/docs/tree/check-your-docs.doc.mjs +137 -0
- package/assets/docs/tree/checks.doc.mjs +119 -0
- package/assets/docs/tree/cli.doc.mjs +23 -0
- package/assets/docs/tree/codemods.doc.mjs +147 -0
- package/assets/docs/tree/commands.doc.mjs +25 -0
- package/assets/docs/tree/component-family.doc.mjs +113 -0
- package/assets/docs/tree/component-imports.doc.mjs +69 -0
- package/assets/docs/tree/component-lookups.doc.mjs +149 -0
- package/assets/docs/tree/components.doc.mjs +23 -0
- package/assets/docs/tree/configuration.doc.mjs +23 -0
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +182 -0
- package/assets/docs/tree/define-the-theme.doc.mjs +118 -0
- package/assets/docs/tree/describe-the-component.doc.mjs +57 -0
- package/assets/docs/tree/docs.doc.mjs +21 -0
- package/assets/docs/tree/document-the-template.doc.mjs +28 -0
- package/assets/docs/tree/document-the-theme.doc.mjs +68 -0
- package/assets/docs/tree/export-template-assets.doc.mjs +147 -0
- package/assets/docs/tree/extend-or-replace.doc.mjs +103 -0
- package/assets/docs/tree/fonts-and-assets.doc.mjs +106 -0
- package/assets/docs/tree/generate-a-palette.doc.mjs +66 -0
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +105 -0
- package/assets/docs/tree/help.doc.mjs +16 -0
- package/assets/docs/tree/integrations.doc.mjs +40 -0
- package/assets/docs/tree/links.doc.mjs +98 -0
- package/assets/docs/tree/package-and-test.doc.mjs +32 -0
- package/assets/docs/tree/page-template.doc.mjs +71 -0
- package/assets/docs/tree/publishing.doc.mjs +111 -0
- package/assets/docs/tree/quick-start.doc.mjs +272 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +104 -0
- package/assets/docs/tree/replace-a-core-template.doc.mjs +172 -0
- package/assets/docs/tree/sections-and-placement.doc.mjs +108 -0
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +59 -0
- package/assets/docs/tree/ship.doc.mjs +16 -0
- package/assets/docs/tree/short-and-findable.doc.mjs +108 -0
- package/assets/docs/tree/single-component.doc.mjs +165 -0
- package/assets/docs/tree/start-a-template.doc.mjs +143 -0
- package/assets/docs/tree/subcomponent.doc.mjs +115 -0
- package/assets/docs/tree/template-assets.doc.mjs +64 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +109 -0
- package/assets/docs/tree/template-fonts.doc.mjs +102 -0
- package/assets/docs/tree/template-grading-rubric.doc.mjs +452 -0
- package/assets/docs/tree/template-icons.doc.mjs +97 -0
- package/assets/docs/tree/template-images-media.doc.mjs +127 -0
- package/assets/docs/tree/template-styles.doc.mjs +93 -0
- package/assets/docs/tree/templates.doc.mjs +34 -0
- package/assets/docs/tree/test-in-an-app.doc.mjs +115 -0
- package/assets/docs/tree/test-template-in-app.doc.mjs +128 -0
- package/assets/docs/tree/themes.doc.mjs +39 -0
- package/assets/docs/tree/troubleshooting.doc.mjs +149 -0
- package/assets/docs/tree/upgrading.doc.mjs +103 -0
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +51 -0
- package/assets/docs/tree/verify-packed-template.doc.mjs +77 -0
- package/assets/docs/tree/versioning.doc.mjs +161 -0
- package/assets/docs/tree/write-good-templates.doc.mjs +64 -0
- package/assets/docs/tree/write-the-template-file.doc.mjs +154 -0
- package/assets/docs/typography.doc.mjs +24 -4
- package/assets/docs/working-with-ai.doc.mjs +34 -26
- package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs +1 -1
- package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx +1 -3
- package/assets/templates/blocks/components/DateInput/DateInputDateRange.tsx +1 -1
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +1 -1
- package/assets/templates/blocks/components/Item/ItemDocumentTabs.doc.mjs +14 -0
- package/assets/templates/blocks/components/Item/ItemDocumentTabs.tsx +100 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.tsx +61 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.tsx +126 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.tsx +86 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.tsx +99 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.tsx +122 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.tsx +95 -0
- package/assets/templates/blocks/components/Table/TableBulkActionsTable.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +71 -0
- package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.doc.mjs +19 -0
- package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx +139 -0
- package/assets/templates/blocks/components/TimeInput/TimeInputConstrained.tsx +1 -0
- package/assets/templates/blocks/components/Timer/TimerFormats.doc.mjs +14 -0
- package/assets/templates/blocks/components/Timer/TimerFormats.tsx +34 -0
- package/assets/templates/blocks/components/Timer/TimerInline.doc.mjs +14 -0
- package/assets/templates/blocks/components/Timer/TimerInline.tsx +14 -0
- package/assets/templates/blocks/components/Timer/TimerShowcase.doc.mjs +13 -0
- package/assets/templates/blocks/components/Timer/TimerShowcase.tsx +47 -0
- package/assets/templates/blocks/components/Timer/TimerTypography.doc.mjs +14 -0
- package/assets/templates/blocks/components/Timer/TimerTypography.tsx +31 -0
- package/assets/templates/blocks/components/Toolbar/ToolbarTableFilter.doc.mjs +19 -3
- package/assets/templates/blocks/components/Toolbar/ToolbarTableFilter.tsx +383 -65
- package/assets/templates/pages/table-tree/page.tsx +1704 -0
- package/assets/templates/pages/table-tree/template.doc.mjs +12 -0
- package/assets/templates/themes/butter/butterTheme.doc.mjs +11 -0
- package/assets/templates/themes/chocolate/chocolateTheme.doc.mjs +11 -0
- package/assets/templates/themes/gothic/gothicTheme.doc.mjs +11 -0
- package/assets/templates/themes/matcha/matchaTheme.doc.mjs +11 -0
- package/assets/templates/themes/neutral/neutralTheme.doc.mjs +11 -0
- package/assets/templates/themes/stone/stoneTheme.doc.mjs +11 -0
- package/assets/templates/themes/y2k/y2kTheme.doc.mjs +11 -0
- package/authoring/_shared/contract.ts +22 -0
- package/authoring/codemod/codemod.doc.mjs +7 -2
- package/authoring/codemod/parse.d.mts +8 -8
- package/authoring/codemod/parse.mjs +8 -6
- package/authoring/codemod/type.ts +12 -0
- package/authoring/config/config.doc.mjs +11 -3
- package/authoring/config/debug-composition.test.mjs +92 -0
- package/authoring/config/parse.d.mts +15 -13
- package/authoring/config/parse.mjs +27 -8
- package/authoring/config/parse.test.mjs +8 -0
- package/authoring/config/type.ts +29 -6
- package/authoring/debug/debug.doc.d.mts +11 -0
- package/authoring/debug/debug.doc.mjs +182 -0
- package/authoring/debug/parse.d.mts +8 -8
- package/authoring/debug/parse.mjs +3 -3
- package/authoring/discover/discover.doc.d.mts +13 -0
- package/authoring/discover/discover.doc.mjs +138 -0
- package/authoring/discover/parse.d.mts +24 -0
- package/authoring/discover/parse.mjs +128 -0
- package/authoring/discover/parse.test.mjs +124 -0
- package/authoring/discover/type.ts +87 -0
- package/authoring/doctypes/_schema.d.mts +792 -24
- package/authoring/doctypes/_schema.mjs +549 -39
- package/authoring/doctypes/base/graph-fields.doc.d.mts +9 -0
- package/authoring/doctypes/base/graph-fields.doc.mjs +64 -0
- package/authoring/doctypes/base/type.ts +43 -0
- package/authoring/doctypes/command/command.doc.mjs +4 -3
- package/authoring/doctypes/command/parse.d.mts +2 -2
- package/authoring/doctypes/command/parse.mjs +1 -1
- package/authoring/doctypes/command/type.ts +5 -4
- package/authoring/doctypes/component/component.doc.mjs +12 -3
- package/authoring/doctypes/component/parse.d.mts +2 -2
- package/authoring/doctypes/component/parse.mjs +1 -1
- package/authoring/doctypes/component/type.ts +14 -5
- package/authoring/doctypes/doctypes-new.test.mjs +48 -6
- package/authoring/doctypes/enum/enum.doc.mjs +1 -1
- package/authoring/doctypes/enum/parse.d.mts +2 -2
- package/authoring/doctypes/enum/parse.mjs +1 -1
- package/authoring/doctypes/enum/type.ts +4 -2
- package/authoring/doctypes/function/function.doc.mjs +7 -2
- package/authoring/doctypes/function/parse.d.mts +2 -2
- package/authoring/doctypes/function/parse.mjs +1 -1
- package/authoring/doctypes/function/type.ts +9 -4
- package/authoring/doctypes/hook/hook.doc.mjs +4 -0
- package/authoring/doctypes/hook/parse.d.mts +2 -2
- package/authoring/doctypes/hook/parse.mjs +1 -1
- package/authoring/doctypes/hook/type.ts +5 -4
- package/authoring/doctypes/legacy.d.mts +8 -6
- package/authoring/doctypes/legacy.mjs +5 -4
- package/authoring/doctypes/load-contract.test.mjs +233 -0
- package/authoring/doctypes/namespace/namespace.doc.d.mts +9 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +128 -0
- package/authoring/doctypes/namespace/parse.d.mts +12 -0
- package/authoring/doctypes/namespace/parse.mjs +25 -0
- package/authoring/doctypes/namespace/parse.test.mjs +163 -0
- package/authoring/doctypes/namespace/type.ts +74 -0
- package/authoring/doctypes/parse.d.mts +22 -18
- package/authoring/doctypes/parse.mjs +22 -11
- package/authoring/doctypes/parse.test.mjs +77 -3
- package/authoring/doctypes/reference/parse.d.mts +2 -2
- package/authoring/doctypes/reference/parse.mjs +8 -5
- package/authoring/doctypes/reference/reference.doc.mjs +55 -6
- package/authoring/doctypes/reference/type.ts +75 -7
- package/authoring/doctypes/schema/parse.d.mts +2 -2
- package/authoring/doctypes/schema/parse.mjs +1 -1
- package/authoring/doctypes/schema/schema.doc.mjs +2 -2
- package/authoring/doctypes/schema/type.ts +4 -4
- package/authoring/doctypes/template/parse.d.mts +94 -1
- package/authoring/doctypes/template/parse.mjs +40 -2
- package/authoring/doctypes/template/parse.test.mjs +26 -2
- package/authoring/doctypes/template/template.doc.mjs +13 -3
- package/authoring/doctypes/template/type.ts +13 -2
- package/authoring/doctypes/theme/parse.d.mts +35 -0
- package/authoring/doctypes/theme/parse.mjs +76 -0
- package/authoring/doctypes/theme/theme.doc.d.mts +9 -0
- package/authoring/doctypes/theme/theme.doc.mjs +79 -0
- package/authoring/doctypes/theme/type.ts +42 -0
- package/authoring/doctypes/types.ts +12 -10
- package/authoring/gap-report/gap-report.doc.d.mts +12 -0
- package/authoring/gap-report/gap-report.doc.mjs +183 -0
- package/authoring/gap-report/parse.d.mts +10 -10
- package/authoring/gap-report/parse.mjs +6 -6
- package/authoring/gap-report/type.ts +1 -1
- package/authoring/identity/identity.doc.d.mts +9 -0
- package/authoring/identity/identity.doc.mjs +61 -0
- package/authoring/identity/type.ts +132 -0
- package/authoring/index.d.mts +3 -0
- package/authoring/index.d.ts +62 -17
- package/authoring/index.mjs +4 -1
- package/authoring/integration/integration.doc.mjs +22 -13
- package/authoring/integration/parse.d.mts +2 -2
- package/authoring/integration/parse.mjs +1 -1
- package/authoring/integration/parse.test.mjs +10 -1
- package/authoring/integration/schema.d.mts +6 -4
- package/authoring/integration/schema.mjs +9 -3
- package/authoring/integration/type.ts +19 -8
- package/authoring/shadcn/receipt.d.mts +6 -6
- package/clients/cli/__tests__/cliManifest.test.ts +27 -29
- package/clients/cli/command-load-failure.test.mjs +83 -0
- package/clients/cli/commands/blog.doc.mjs +1 -1
- package/clients/cli/commands/blog.mjs +23 -8
- package/clients/cli/commands/blog.test.mjs +42 -1
- package/clients/cli/commands/build-theme.adaptations.test.mjs +100 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +161 -0
- package/clients/cli/commands/build-theme.flag-docs.test.mjs +110 -0
- package/clients/cli/commands/build-theme.mjs +16 -50
- package/clients/cli/commands/build-theme.path-safety.test.mjs +86 -1
- package/clients/cli/commands/build-theme.variants.test.mjs +76 -0
- package/clients/cli/commands/build.doc.mjs +16 -8
- package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
- package/clients/cli/commands/build.mjs +137 -114
- package/clients/cli/commands/build.playbook.test.mjs +75 -0
- package/clients/cli/commands/build.text-fields.test.mjs +81 -0
- package/clients/cli/commands/component/index.mjs +153 -61
- package/clients/cli/commands/component-batch.test.mjs +341 -0
- package/clients/cli/commands/component-ownership.test.mjs +92 -3
- package/clients/cli/commands/component-package.test.mjs +46 -0
- package/clients/cli/commands/component-resolution.test.mjs +21 -0
- package/clients/cli/commands/component.doc.mjs +28 -10
- package/clients/cli/commands/component.test.mjs +19 -0
- package/clients/cli/commands/detail-levels.test.mjs +2 -2
- package/clients/cli/commands/discover.broken-integration.test.mjs +52 -5
- package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
- package/clients/cli/commands/discover.doc.mjs +55 -9
- package/clients/cli/commands/discover.mjs +393 -118
- package/clients/cli/commands/discover.sources.test.mjs +267 -0
- package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
- package/clients/cli/commands/docs.doc.mjs +28 -6
- package/clients/cli/commands/docs.mjs +295 -38
- package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +6 -5
- package/clients/cli/commands/doctor-integration-templates.doc.mjs +15 -8
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration.package-json.test.mjs +53 -0
- package/clients/cli/commands/doctor-integration.test.mjs +143 -8
- package/clients/cli/commands/doctor.doc.mjs +4 -2
- package/clients/cli/commands/doctor.mjs +108 -37
- package/clients/cli/commands/doctor.test.mjs +42 -0
- package/clients/cli/commands/gap-report.doc.mjs +27 -15
- package/clients/cli/commands/gap-report.test.mjs +72 -0
- package/clients/cli/commands/hook/index.mjs +7 -17
- package/clients/cli/commands/hook.doc.mjs +1 -1
- package/clients/cli/commands/hook.text-projection.test.mjs +45 -0
- package/clients/cli/commands/init.doc.mjs +24 -10
- package/clients/cli/commands/init.flag-help.test.mjs +153 -0
- package/clients/cli/commands/integration-add.controls.test.mjs +132 -0
- package/clients/cli/commands/integration-add.doc.mjs +39 -13
- package/clients/cli/commands/integration-authoring.test.mjs +74 -19
- package/clients/cli/commands/integration-pack.doc.mjs +6 -10
- package/clients/cli/commands/integration-real-world.test.mjs +4 -10
- package/clients/cli/commands/integration-verify.doc.mjs +22 -0
- package/clients/cli/commands/integration.doc.mjs +5 -5
- package/clients/cli/commands/integration.mjs +75 -43
- package/clients/cli/commands/interactive-guard.test.mjs +101 -24
- package/clients/cli/commands/json-contract.test.mjs +33 -0
- package/clients/cli/commands/layout-check.doc.mjs +15 -4
- package/clients/cli/commands/layout-expand.doc.mjs +22 -5
- package/clients/cli/commands/layout-grammar.doc.mjs +1 -1
- package/clients/cli/commands/layout.doc.mjs +3 -3
- package/clients/cli/commands/layout.mjs +21 -9
- package/clients/cli/commands/layout.path-help.test.mjs +33 -0
- package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
- package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
- package/clients/cli/commands/manifest.doc.mjs +2 -2
- package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
- package/clients/cli/commands/search.doc.mjs +16 -6
- package/clients/cli/commands/search.mjs +49 -11
- package/clients/cli/commands/search.test.mjs +92 -0
- package/clients/cli/commands/setup-nudge.test.mjs +6 -0
- package/clients/cli/commands/swizzle.doc.mjs +4 -3
- package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
- package/clients/cli/commands/template.doc.mjs +53 -14
- package/clients/cli/commands/template.flag-help.test.mjs +117 -0
- package/clients/cli/commands/template.mjs +4 -91
- package/clients/cli/commands/template.path-help.test.mjs +40 -0
- package/clients/cli/commands/text-json-parity.test.mjs +725 -0
- package/clients/cli/commands/theme-add.doc.mjs +5 -4
- package/clients/cli/commands/theme-build.doc.mjs +8 -7
- package/clients/cli/commands/theme-list.doc.mjs +2 -2
- package/clients/cli/commands/theme-palette-generate.doc.mjs +12 -7
- package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
- package/clients/cli/commands/theme-palette.doc.mjs +2 -3
- package/clients/cli/commands/theme-targets.behavior.test.mjs +4 -3
- package/clients/cli/commands/theme-targets.doc.mjs +3 -3
- package/clients/cli/commands/theme-template.behavior.test.mjs +12 -0
- package/clients/cli/commands/theme-template.doc.mjs +2 -2
- package/clients/cli/commands/theme.doc.mjs +3 -2
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
- package/clients/cli/commands/upgrade.doc.mjs +83 -12
- package/clients/cli/commands/upgrade.file-protection.test.mjs +228 -0
- package/clients/cli/commands/upgrade.flag-help.test.mjs +188 -0
- package/clients/cli/commands/upgrade.hook-output.test.mjs +88 -0
- package/clients/cli/commands/upgrade.mjs +29 -7
- package/clients/cli/formatters/index.mjs +164 -1
- package/clients/cli/formatters/index.test.mjs +97 -0
- package/clients/cli/index.mjs +47 -34
- package/clients/cli/latest-version-env.test.mjs +50 -0
- package/clients/cli/lib/cli-error.test.mjs +7 -0
- package/clients/cli/lib/component-format.mjs +9 -9
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +56 -6
- package/clients/cli/lib/define-command.test.mjs +54 -0
- package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
- package/clients/cli/lib/exit-codes.test.mjs +113 -0
- package/clients/cli/lib/hook-format.mjs +19 -10
- package/clients/cli/lib/json-shim.mjs +62 -16
- package/clients/cli/lib/json-shim.test.mjs +83 -0
- package/clients/cli/lib/manifest.d.ts +2 -0
- package/clients/cli/lib/manifest.mjs +53 -6
- package/clients/cli/lib/manifest.test.mjs +22 -2
- package/clients/cli/lib/parse-error-format.test.mjs +81 -0
- package/foundation/agent-docs/agent-docs.d.mts +7 -2
- package/foundation/agent-docs/agent-docs.mjs +83 -13
- package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
- package/foundation/config/integration-debug.test.mjs +28 -3
- package/foundation/config/project-themes.test.mjs +11 -19
- package/foundation/config/project.d.mts +20 -11
- package/foundation/config/project.mjs +263 -91
- package/foundation/config/project.test.mjs +270 -21
- package/foundation/discovery/authoring-self-docs.d.mts +87 -0
- package/foundation/discovery/authoring-self-docs.mjs +237 -0
- package/foundation/discovery/authoring-self-docs.test.mjs +174 -0
- package/foundation/discovery/authoring-surface.d.mts +74 -0
- package/foundation/discovery/authoring-surface.mjs +525 -0
- package/foundation/discovery/authoring-surface.test.mjs +392 -0
- package/foundation/discovery/cli-self-docs.d.mts +119 -0
- package/foundation/discovery/cli-self-docs.mjs +504 -0
- package/foundation/discovery/cli-self-docs.test.mjs +395 -0
- package/foundation/discovery/component-discovery.d.mts +39 -1
- package/foundation/discovery/component-discovery.mjs +50 -1
- package/foundation/discovery/component-loader.d.mts +35 -38
- package/foundation/discovery/component-loader.mjs +53 -222
- package/foundation/discovery/docs-discovery.d.mts +119 -11
- package/foundation/discovery/docs-discovery.mjs +427 -108
- package/foundation/discovery/docs-discovery.test.mjs +386 -20
- package/foundation/discovery/docs-output-budget.d.mts +28 -0
- package/foundation/discovery/docs-output-budget.mjs +50 -0
- package/foundation/discovery/docs-section-key.d.mts +116 -0
- package/foundation/discovery/docs-section-key.mjs +322 -0
- package/foundation/discovery/docs-section-key.test.mjs +246 -0
- package/foundation/discovery/template-adapter.d.mts +113 -11
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +248 -0
- package/foundation/discovery/template-adapter.integration-isolation.test.mjs +94 -0
- package/foundation/discovery/template-adapter.mjs +774 -83
- package/foundation/discovery/template-adapter.test.mjs +57 -0
- package/foundation/discovery/template-conflict-release.d.mts +13 -0
- package/foundation/discovery/template-conflict-release.mjs +40 -0
- package/foundation/discovery/template-conflict-release.test.mjs +40 -0
- package/foundation/discovery/theme-discovery.d.mts +67 -7
- package/foundation/discovery/theme-discovery.mjs +916 -186
- package/foundation/discovery/theme-discovery.test.mjs +613 -219
- package/foundation/discovery/theming-targets.test.mjs +4 -0
- package/foundation/doc-compiler/bundle.d.mts +47 -0
- package/foundation/doc-compiler/bundle.mjs +278 -0
- package/foundation/doc-compiler/bundle.test.mjs +266 -0
- package/foundation/doc-compiler/compile.d.mts +343 -0
- package/foundation/doc-compiler/compile.mjs +558 -0
- package/foundation/doc-compiler/diagnostics.d.mts +126 -0
- package/foundation/doc-compiler/diagnostics.mjs +305 -0
- package/foundation/doc-compiler/doc-compiler.test.mjs +714 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +1643 -0
- package/foundation/doc-compiler/import.d.mts +24 -0
- package/foundation/doc-compiler/import.mjs +59 -0
- package/foundation/doc-compiler/inputs.d.mts +102 -0
- package/foundation/doc-compiler/inputs.mjs +291 -0
- package/foundation/doc-compiler/inputs.test.mjs +298 -0
- package/foundation/doc-compiler/ir.d.mts +22 -0
- package/foundation/doc-compiler/ir.mjs +471 -0
- package/foundation/doc-compiler/lenses.d.mts +36 -0
- package/foundation/doc-compiler/lenses.mjs +173 -0
- package/foundation/doc-compiler/links.d.mts +162 -0
- package/foundation/doc-compiler/links.mjs +294 -0
- package/foundation/doc-compiler/links.test.mjs +192 -0
- package/foundation/doc-compiler/lower-doc.test.mjs +495 -0
- package/foundation/doc-compiler/overlays.d.mts +37 -0
- package/foundation/doc-compiler/overlays.mjs +206 -0
- package/foundation/doc-compiler/parse-readable.d.mts +9 -0
- package/foundation/doc-compiler/parse-readable.mjs +29 -0
- package/foundation/doc-compiler/read.d.mts +127 -0
- package/foundation/doc-compiler/read.mjs +325 -0
- package/foundation/doc-compiler/read.test.mjs +313 -0
- package/foundation/doc-compiler/source.d.mts +33 -0
- package/foundation/doc-compiler/source.mjs +128 -0
- package/foundation/doc-compiler/tree.d.mts +292 -0
- package/foundation/doc-compiler/tree.mjs +881 -0
- package/foundation/fs/file-protection.d.mts +33 -0
- package/foundation/fs/file-protection.mjs +825 -0
- package/foundation/fs/file-protection.test.mjs +250 -0
- package/foundation/fs/module-loader.d.mts +1 -0
- package/foundation/fs/module-loader.mjs +50 -1
- package/foundation/fs/module-loader.stdout.test.mjs +332 -0
- package/foundation/fs/path-safety.d.mts +3 -2
- package/foundation/fs/path-safety.mjs +49 -19
- package/foundation/fs/path-safety.test.mjs +50 -0
- package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +129 -94
- package/foundation/identity/provider-identity.d.mts +90 -0
- package/foundation/identity/provider-identity.mjs +320 -0
- package/foundation/identity/provider-identity.test.mjs +254 -0
- package/foundation/identity/providers.d.mts +7 -0
- package/foundation/identity/providers.mjs +16 -0
- package/foundation/integrations/autolink.d.mts +58 -1
- package/foundation/integrations/autolink.mjs +143 -45
- package/foundation/integrations/autolink.test.mjs +1 -1
- package/foundation/integrations/cli-requirement.d.mts +65 -0
- package/foundation/integrations/cli-requirement.mjs +189 -0
- package/foundation/integrations/cli-requirement.test.mjs +89 -0
- package/foundation/integrations/contribution-fixes.d.mts +145 -0
- package/foundation/integrations/contribution-fixes.mjs +1284 -0
- package/foundation/integrations/contribution-inventory.d.mts +3 -2
- package/foundation/integrations/contribution-inventory.mjs +28 -25
- package/foundation/integrations/contribution-inventory.test.mjs +86 -27
- package/foundation/integrations/integration-warnings.d.mts +9 -2
- package/foundation/integrations/integration-warnings.mjs +52 -21
- package/foundation/integrations/integration-warnings.test.mjs +74 -1
- package/foundation/integrations/integrations.d.mts +63 -3
- package/foundation/integrations/integrations.mjs +122 -9
- package/foundation/integrations/integrations.test.mjs +415 -1
- package/foundation/integrations/provider-conflicts.test.mjs +125 -0
- package/foundation/integrations/provider-ledger.test.mjs +275 -0
- package/foundation/integrations/provider-resolution.d.mts +152 -0
- package/foundation/integrations/provider-resolution.mjs +576 -0
- package/foundation/integrations/provider-resolution.test.mjs +369 -0
- package/foundation/integrations/theme-descriptor.d.mts +8 -0
- package/foundation/integrations/theme-descriptor.mjs +44 -0
- package/foundation/integrations/validate-contributions.d.mts +2 -0
- package/foundation/integrations/validate-contributions.mjs +131 -29
- package/foundation/response/base.d.ts +8 -4
- package/foundation/response/batch.type.d.mts +33 -0
- package/foundation/response/batch.type.mjs +34 -0
- package/foundation/response/error-codes.d.mts +3 -1
- package/foundation/response/error-codes.d.ts +2 -0
- package/foundation/response/error-codes.doc.mjs +19 -12
- package/foundation/response/error-codes.mjs +8 -2
- package/foundation/response/error-codes.test.mjs +166 -14
- package/foundation/response/json-contract.test.mjs +57 -17
- package/foundation/response/json.d.mts +4 -2
- package/foundation/response/json.mjs +8 -10
- package/foundation/response/response-types.doc.d.mts +7 -2
- package/foundation/response/response-types.doc.mjs +69 -25
- package/foundation/response/response-types.doc.test.mjs +181 -0
- package/foundation/response/response.doc.mjs +12 -11
- package/foundation/text/string-utils.d.mts +8 -0
- package/foundation/text/string-utils.mjs +40 -10
- package/foundation/xle/expand.d.mts +2 -0
- package/foundation/xle/expand.mjs +4 -3
- package/foundation/xle/expand.test.mjs +54 -0
- package/foundation/xle/xle.test.mjs +13 -0
- package/package.json +10 -11
- package/api/docs/docs.test.mjs +0 -83
- package/api/docs/integrationDocs.test.mjs +0 -208
- package/api/search/search.test.mjs +0 -389
- package/assets/docs/cli-integrations.doc.mjs +0 -367
- package/assets/templates/themes/manifest.json +0 -95
- package/clients/cli/commands/docs.test.mjs +0 -102
- package/clients/cli/lib/update-check.mjs +0 -83
- package/clients/cli/lib/update-check.test.mjs +0 -137
- package/clients/cli/update-hint-commands.test.mjs +0 -54
- package/foundation/agent-docs/agent-docs.test.mjs +0 -1141
package/api/docs/_adapter.mjs
CHANGED
|
@@ -7,26 +7,57 @@
|
|
|
7
7
|
* packages/cli/assets/docs/{topic}.doc.mjs plus every topic the configured
|
|
8
8
|
* integrations contribute — and, when a --dense/--zh overlay is requested,
|
|
9
9
|
* the sibling {topic}.doc.dense.mjs / {topic}.doc.zh.mjs.
|
|
10
|
-
* @output Catalog access,
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @position Sits beside docs.mjs (api/docs/).
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import * as path from 'node:path';
|
|
21
|
-
import {pathToFileURL} from 'node:url';
|
|
10
|
+
* @output Catalog access, the compiler input for a topic, and the compiled
|
|
11
|
+
* node for it: lowered (overlaid, extensions merged, keys stamped) or linked
|
|
12
|
+
* (token references resolved too), memoized per catalog.
|
|
13
|
+
* @position Sits beside docs.mjs (api/docs/). Hands topics to
|
|
14
|
+
* foundation/doc-compiler (which loads their files) and memoizes the nodes
|
|
15
|
+
* per catalog, so no leaf, doctor check or search loads, merges, or resolves
|
|
16
|
+
* docs on its own. Discovery itself lives in
|
|
17
|
+
* foundation/discovery/docs-discovery, which the catalog comes from.
|
|
18
|
+
*/
|
|
19
|
+
|
|
22
20
|
import {Project} from '../../foundation/config/project.mjs';
|
|
21
|
+
import {DocsCatalog} from '../../foundation/discovery/docs-discovery.mjs';
|
|
22
|
+
import {
|
|
23
|
+
linkReferenceTopic,
|
|
24
|
+
lowerReferenceTopic,
|
|
25
|
+
} from '../../foundation/doc-compiler/compile.mjs';
|
|
26
|
+
import {
|
|
27
|
+
deepFreeze,
|
|
28
|
+
loadTopicFile,
|
|
29
|
+
loadTopicInput,
|
|
30
|
+
OVERLAY_LANGUAGES,
|
|
31
|
+
overlayLanguages,
|
|
32
|
+
} from '../../foundation/doc-compiler/read.mjs';
|
|
33
|
+
import {
|
|
34
|
+
buildDocsTree,
|
|
35
|
+
loadTreeInputs,
|
|
36
|
+
} from '../../foundation/doc-compiler/tree.mjs';
|
|
37
|
+
import {sortDiagnostics} from '../../foundation/doc-compiler/diagnostics.mjs';
|
|
38
|
+
import {
|
|
39
|
+
linkBlocks,
|
|
40
|
+
parseLinkTarget,
|
|
41
|
+
} from '../../foundation/doc-compiler/links.mjs';
|
|
42
|
+
import {
|
|
43
|
+
createDocId,
|
|
44
|
+
normalizeProviderId,
|
|
45
|
+
} from '../../foundation/identity/provider-identity.mjs';
|
|
23
46
|
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} from '../../foundation/discovery/docs
|
|
47
|
+
cliDocIndex,
|
|
48
|
+
cliDocSection,
|
|
49
|
+
} from '../../foundation/discovery/cli-self-docs.mjs';
|
|
50
|
+
import {
|
|
51
|
+
loadAuthoringSelfDocs,
|
|
52
|
+
schemaFieldTable,
|
|
53
|
+
selfDocSection,
|
|
54
|
+
} from '../../foundation/discovery/authoring-self-docs.mjs';
|
|
55
|
+
import {CLI_PROVIDER_ID} from '../../foundation/identity/providers.mjs';
|
|
27
56
|
import {AstryxError} from '../error.mjs';
|
|
28
57
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
29
58
|
|
|
59
|
+
export {OVERLAY_LANGUAGES, overlayLanguages};
|
|
60
|
+
|
|
30
61
|
/**
|
|
31
62
|
* The project's topics: the built-in ones plus whatever the configured
|
|
32
63
|
* integrations contribute.
|
|
@@ -50,121 +81,975 @@ export async function loadDocsCatalog(cwd = process.cwd()) {
|
|
|
50
81
|
}
|
|
51
82
|
|
|
52
83
|
/**
|
|
53
|
-
*
|
|
54
|
-
* @param {
|
|
55
|
-
* @returns {
|
|
84
|
+
* The overlay a read applies: none for the authored language.
|
|
85
|
+
* @param {string | null | undefined} lang
|
|
86
|
+
* @returns {string | null}
|
|
56
87
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (!lang || lang === 'en') return docs;
|
|
88
|
+
function overlayLanguage(lang) {
|
|
89
|
+
return lang && lang !== 'en' ? lang : null;
|
|
90
|
+
}
|
|
61
91
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
92
|
+
/** @type {WeakMap<DocsCatalog, Map<string, Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode>>>} */
|
|
93
|
+
const loweredByCatalog = new WeakMap();
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* One topic, lowered for `lang` with its links as written: overlaid,
|
|
97
|
+
* extensions merged, keys stamped. Memoized per catalog, so a read that
|
|
98
|
+
* references a topic twice loads it once. Every read of the catalog shares the
|
|
99
|
+
* memoized node, so it is frozen; the lenses hand readers copies.
|
|
100
|
+
* @param {DocsCatalog} catalog
|
|
101
|
+
* @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
|
|
102
|
+
* @param {string | null} [lang]
|
|
103
|
+
* @returns {Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode>}
|
|
104
|
+
*/
|
|
105
|
+
function lowerRawTopic(catalog, entry, lang = null) {
|
|
106
|
+
const overlay = overlayLanguage(lang);
|
|
107
|
+
let cache = loweredByCatalog.get(catalog);
|
|
108
|
+
if (!cache) {
|
|
109
|
+
cache = new Map();
|
|
110
|
+
loweredByCatalog.set(catalog, cache);
|
|
111
|
+
}
|
|
112
|
+
const key = `${entry.name.toLowerCase()}\u0000${overlay ?? ''}`;
|
|
113
|
+
let lowered = cache.get(key);
|
|
114
|
+
if (!lowered) {
|
|
115
|
+
lowered = loadTopicInput(entry, overlay).then(input =>
|
|
116
|
+
deepFreeze(lowerReferenceTopic(input)),
|
|
117
|
+
);
|
|
118
|
+
cache.set(key, lowered);
|
|
119
|
+
}
|
|
120
|
+
return lowered;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @typedef {import('../../foundation/doc-compiler/tree.mjs').DocsTree} DocsTree
|
|
125
|
+
* @typedef {import('../../foundation/doc-compiler/tree.mjs').TreeNode} TreeNode
|
|
126
|
+
* @typedef {import('../../foundation/doc-compiler/links.mjs').LinkProblem} LinkProblem
|
|
127
|
+
* @typedef {import('../../foundation/doc-compiler/links.mjs').LinkResolver} LinkResolver
|
|
128
|
+
* @typedef {import('../../foundation/doc-compiler/links.mjs').DocIncluder} DocIncluder
|
|
129
|
+
* @typedef {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} DocsTopicEntry
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
/** @type {WeakMap<DocsCatalog, Map<string, Promise<{node: import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode, problems: LinkProblem[]}>>>} */
|
|
133
|
+
const linkedByCatalog = new WeakMap();
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The CLI's own topics alone, for a check that runs without a project.
|
|
137
|
+
* @returns {DocsCatalog}
|
|
138
|
+
*/
|
|
139
|
+
export function builtinCatalog() {
|
|
140
|
+
return DocsCatalog.fromBuiltins();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The provider id a topic's (or an extension's) links resolve against: its
|
|
145
|
+
* owner's.
|
|
146
|
+
* @param {{providerId?: string, package: string}} entry
|
|
147
|
+
* @returns {string}
|
|
148
|
+
*/
|
|
149
|
+
function providerOf(entry) {
|
|
150
|
+
return normalizeProviderId(entry.providerId ?? entry.package);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* One topic, lowered for `lang` with every link between docs resolved
|
|
155
|
+
* (spec:AST-047 FR9): an inline `{@link <target>}` reads as the command that
|
|
156
|
+
* opens its doc, and a `reference` block carries the doc it names and the
|
|
157
|
+
* `content` it includes of it. Memoized per catalog and frozen, like the
|
|
158
|
+
* lowered node.
|
|
159
|
+
* @param {DocsCatalog} catalog
|
|
160
|
+
* @param {DocsTopicEntry} entry
|
|
161
|
+
* @param {string | null} [lang]
|
|
162
|
+
* @returns {Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode>}
|
|
163
|
+
*/
|
|
164
|
+
export async function lowerTopic(catalog, entry, lang = null) {
|
|
165
|
+
return (await linkTopic(catalog, entry, lang)).node;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Each link in a topic that names no doc.
|
|
170
|
+
* @param {DocsCatalog} catalog
|
|
171
|
+
* @param {DocsTopicEntry} entry
|
|
172
|
+
* @returns {Promise<LinkProblem[]>}
|
|
173
|
+
*/
|
|
174
|
+
export async function topicLinkProblems(catalog, entry) {
|
|
175
|
+
return (await linkTopic(catalog, entry, null)).problems;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* @param {DocsCatalog} catalog
|
|
180
|
+
* @param {DocsTopicEntry} entry
|
|
181
|
+
* @param {string | null} lang
|
|
182
|
+
*/
|
|
183
|
+
function linkTopic(catalog, entry, lang) {
|
|
184
|
+
let cache = linkedByCatalog.get(catalog);
|
|
185
|
+
if (!cache) {
|
|
186
|
+
cache = new Map();
|
|
187
|
+
linkedByCatalog.set(catalog, cache);
|
|
188
|
+
}
|
|
189
|
+
const key = `${entry.name.toLowerCase()}\u0000${overlayLanguage(lang) ?? ''}`;
|
|
190
|
+
let linked = cache.get(key);
|
|
191
|
+
if (!linked) {
|
|
192
|
+
linked = (async () => {
|
|
193
|
+
const raw = await lowerRawTopic(catalog, entry, lang);
|
|
194
|
+
/** @type {Map<string, {resolve: LinkResolver, include: DocIncluder}>} */
|
|
195
|
+
const linkers = new Map();
|
|
196
|
+
/** @param {string} provider */
|
|
197
|
+
const linkerFor = async provider => {
|
|
198
|
+
let linker = linkers.get(provider);
|
|
199
|
+
if (!linker) {
|
|
200
|
+
linker = {
|
|
201
|
+
resolve: await linkResolver(catalog, provider),
|
|
202
|
+
include: await docIncluder(catalog, provider),
|
|
203
|
+
};
|
|
204
|
+
linkers.set(provider, linker);
|
|
205
|
+
}
|
|
206
|
+
return linker;
|
|
207
|
+
};
|
|
208
|
+
/** @type {LinkProblem[]} */
|
|
209
|
+
const problems = [];
|
|
210
|
+
const sections = [];
|
|
211
|
+
// Each section resolves its links against the provider that wrote it:
|
|
212
|
+
// an extension's sections against the extension's provider, never the
|
|
213
|
+
// base topic's.
|
|
214
|
+
for (const section of raw.doc.sections) {
|
|
215
|
+
const provider = raw.sectionProviders?.[section.id];
|
|
216
|
+
const {resolve, include} = await linkerFor(
|
|
217
|
+
provider == null ? providerOf(entry) : normalizeProviderId(provider),
|
|
218
|
+
);
|
|
219
|
+
const linked = await linkBlocks(
|
|
220
|
+
section.content,
|
|
221
|
+
resolve,
|
|
222
|
+
{section: section.id ?? section.title},
|
|
223
|
+
include,
|
|
224
|
+
);
|
|
225
|
+
problems.push(...linked.problems);
|
|
226
|
+
sections.push({...section, content: linked.content});
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
node: deepFreeze({...raw, doc: {...raw.doc, sections}}),
|
|
230
|
+
problems,
|
|
231
|
+
};
|
|
232
|
+
})();
|
|
233
|
+
cache.set(key, linked);
|
|
234
|
+
}
|
|
235
|
+
return linked;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** @type {WeakMap<DocsCatalog, Promise<DocsTree>>} */
|
|
239
|
+
const treesByCatalog = new WeakMap();
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* The project's docs tree: the CLI's own docs plus the namespace docs and
|
|
243
|
+
* placed guides the configured integrations ship (spec:AST-046), built once
|
|
244
|
+
* per catalog. Without integration docs it is the CLI's tree, built once per
|
|
245
|
+
* process.
|
|
246
|
+
* @param {DocsCatalog} catalog
|
|
247
|
+
* @param {{fresh?: boolean}} [options] `fresh`: reread the CLI's tree files
|
|
248
|
+
* @returns {Promise<DocsTree>}
|
|
249
|
+
*/
|
|
250
|
+
export function projectTree(catalog, {fresh = false} = {}) {
|
|
251
|
+
let tree = treesByCatalog.get(catalog);
|
|
252
|
+
if (!tree || fresh) {
|
|
253
|
+
tree = buildProjectTree(catalog, fresh);
|
|
254
|
+
treesByCatalog.set(catalog, tree);
|
|
255
|
+
}
|
|
256
|
+
return tree;
|
|
257
|
+
}
|
|
67
258
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (!translation) return docs;
|
|
259
|
+
/** @type {ReturnType<typeof loadTreeInputs> | undefined} */
|
|
260
|
+
let cliTreeInputs;
|
|
71
261
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
262
|
+
/**
|
|
263
|
+
* Every flat topic in the catalog, as the tree's Unorganized level reads it.
|
|
264
|
+
* @param {DocsCatalog} catalog
|
|
265
|
+
* @returns {Promise<import('../../foundation/doc-compiler/tree.mjs').TreeTopicInput[]>}
|
|
266
|
+
*/
|
|
267
|
+
async function flatTopicInputs(catalog) {
|
|
268
|
+
/** @type {import('../../foundation/doc-compiler/tree.mjs').TreeTopicInput[]} */
|
|
269
|
+
const topics = [];
|
|
270
|
+
for (const entry of catalog.entries()) {
|
|
271
|
+
const aliases = catalog.aliasesOf(entry);
|
|
272
|
+
let {title, description} = entry;
|
|
273
|
+
if (title == null || description == null) {
|
|
274
|
+
try {
|
|
275
|
+
const file = await loadTopicFile(entry.path, null);
|
|
276
|
+
title ??= file.doc?.title;
|
|
277
|
+
description ??= file.doc?.description;
|
|
278
|
+
} catch {
|
|
279
|
+
// A topic that does not load is reported where it is read.
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
topics.push({
|
|
283
|
+
provider: entry.package,
|
|
284
|
+
providerId: entry.providerId ?? entry.package,
|
|
285
|
+
name: entry.name,
|
|
286
|
+
title: title ?? entry.name,
|
|
287
|
+
summary: description ?? '',
|
|
288
|
+
source: `${entry.package}:${entry.name}`,
|
|
289
|
+
...(aliases.length > 0 ? {aliases} : {}),
|
|
290
|
+
});
|
|
83
291
|
}
|
|
292
|
+
return topics;
|
|
293
|
+
}
|
|
84
294
|
|
|
295
|
+
/**
|
|
296
|
+
* The CLI's tree, each configured integration's namespaces and guides, and
|
|
297
|
+
* every flat topic in the generated Unorganized level.
|
|
298
|
+
* @param {DocsCatalog} catalog
|
|
299
|
+
* @param {boolean} fresh
|
|
300
|
+
* @returns {Promise<DocsTree>}
|
|
301
|
+
*/
|
|
302
|
+
async function buildProjectTree(catalog, fresh) {
|
|
303
|
+
const added = catalog.treeInputs;
|
|
304
|
+
if (fresh || !cliTreeInputs) cliTreeInputs = loadTreeInputs();
|
|
305
|
+
const cli = await cliTreeInputs;
|
|
306
|
+
const result = buildDocsTree({
|
|
307
|
+
namespaces: [...cli.namespaces, ...added.flatMap(each => each.namespaces)],
|
|
308
|
+
docs: [...cli.docs, ...added.flatMap(each => each.guides)],
|
|
309
|
+
topics: await flatTopicInputs(catalog),
|
|
310
|
+
});
|
|
85
311
|
return {
|
|
86
|
-
...
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
312
|
+
...result,
|
|
313
|
+
diagnostics: sortDiagnostics([...cli.diagnostics, ...result.diagnostics]),
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/** @type {WeakMap<DocsTree, Map<string, TreeNode>>} */
|
|
318
|
+
const identitiesByTree = new WeakMap();
|
|
319
|
+
|
|
320
|
+
/** @param {string} provider @param {string} kind @param {string} name */
|
|
321
|
+
function identityKey(provider, kind, name) {
|
|
322
|
+
return `${provider}\u0000${kind}\u0000${kind === 'generic' ? name.toLowerCase() : name}`;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Every tree node with an identity, by provider id, kind, and name.
|
|
327
|
+
* @param {DocsTree} tree
|
|
328
|
+
*/
|
|
329
|
+
function identitiesOf(tree) {
|
|
330
|
+
let index = identitiesByTree.get(tree);
|
|
331
|
+
if (!index) {
|
|
332
|
+
index = new Map();
|
|
333
|
+
for (const node of tree.nodes.values()) {
|
|
334
|
+
if (node.id == null) continue;
|
|
335
|
+
let provider = node.providerId;
|
|
336
|
+
try {
|
|
337
|
+
provider = normalizeProviderId(node.providerId);
|
|
338
|
+
} catch {
|
|
339
|
+
// Kept as given; a link names it the same way.
|
|
340
|
+
}
|
|
341
|
+
index.set(identityKey(provider, node.kind, node.name), node);
|
|
342
|
+
}
|
|
343
|
+
identitiesByTree.set(tree, index);
|
|
344
|
+
}
|
|
345
|
+
return index;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* The CLI's authoring docs, by kind and name. `astryx docs authoring` reads
|
|
350
|
+
* each as one section keyed by its name, so a link to one opens that section.
|
|
351
|
+
* Loaded once per process, like the CLI's tree files.
|
|
352
|
+
* @type {Promise<Map<string, any>> | undefined}
|
|
353
|
+
*/
|
|
354
|
+
let authoringDocs;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* The CLI authoring doc a link names, while `astryx docs authoring` is the
|
|
358
|
+
* CLI's own topic.
|
|
359
|
+
* @param {DocsCatalog} catalog
|
|
360
|
+
* @param {string} kind
|
|
361
|
+
* @param {string} name
|
|
362
|
+
* @returns {Promise<any | null>}
|
|
363
|
+
*/
|
|
364
|
+
async function authoringDoc(catalog, kind, name) {
|
|
365
|
+
if (catalog.resolve('authoring')?.package !== CLI_PROVIDER_ID) return null;
|
|
366
|
+
authoringDocs ??= loadAuthoringSelfDocs().then(
|
|
367
|
+
({loaded}) =>
|
|
368
|
+
new Map(loaded.map(({doc}) => [`${doc.type}\u0000${doc.name}`, doc])),
|
|
369
|
+
);
|
|
370
|
+
return (await authoringDocs).get(`${kind}\u0000${name}`) ?? null;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* A doc a link found: what a read shows of the link, and the typed doc behind
|
|
375
|
+
* it when a reference block can include it.
|
|
376
|
+
* @typedef {object} FoundDoc
|
|
377
|
+
* @property {import('../../foundation/doc-compiler/links.mjs').DocLink} link
|
|
378
|
+
* @property {string} kind the doc's kind
|
|
379
|
+
* @property {{doc: any, providerId: string, tree: boolean} | null} typed a
|
|
380
|
+
* schema, command, function, or enum doc: a leaf of the docs tree (`tree`),
|
|
381
|
+
* or a section of `astryx docs authoring`; null for any other kind
|
|
382
|
+
*/
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* How a doc's links find their targets (spec:AST-047 FR9): a doc in the
|
|
386
|
+
* project's docs tree by its identity, a CLI authoring doc (a section of
|
|
387
|
+
* `astryx docs authoring`), or a flat topic by its provider and name. A
|
|
388
|
+
* target that matches none is a problem, never a guess.
|
|
389
|
+
* @param {DocsCatalog} catalog
|
|
390
|
+
* @param {string} fromProvider the provider id of the doc the links sit in
|
|
391
|
+
* @returns {Promise<(target: string) => Promise<FoundDoc | {problem: string}>>}
|
|
392
|
+
*/
|
|
393
|
+
async function docFinder(catalog, fromProvider) {
|
|
394
|
+
const identities = identitiesOf(await projectTree(catalog));
|
|
395
|
+
return async target => {
|
|
396
|
+
const parsed = parseLinkTarget(target);
|
|
397
|
+
if ('error' in parsed) return {problem: parsed.error};
|
|
398
|
+
let provider;
|
|
399
|
+
try {
|
|
400
|
+
provider = normalizeProviderId(parsed.provider ?? fromProvider);
|
|
401
|
+
} catch {
|
|
402
|
+
return {
|
|
403
|
+
problem: `"${target}" names "${parsed.provider}", which is not a provider id: an npm package name, or the \`providerId\` its manifest declares`,
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
const node = identities.get(identityKey(provider, parsed.kind, parsed.name));
|
|
407
|
+
if (node) {
|
|
408
|
+
return {
|
|
409
|
+
link: {
|
|
410
|
+
target,
|
|
411
|
+
id: /** @type {string} */ (node.id),
|
|
412
|
+
route: node.route,
|
|
413
|
+
title: node.title,
|
|
414
|
+
summary: node.summary,
|
|
415
|
+
command: `astryx docs ${node.route}`,
|
|
416
|
+
},
|
|
417
|
+
kind: node.kind,
|
|
418
|
+
typed: node.ref?.selfDoc
|
|
419
|
+
? {doc: node.ref.selfDoc, providerId: node.providerId, tree: true}
|
|
420
|
+
: null,
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
const authored =
|
|
424
|
+
provider === CLI_PROVIDER_ID
|
|
425
|
+
? await authoringDoc(catalog, parsed.kind, parsed.name)
|
|
426
|
+
: null;
|
|
427
|
+
if (authored) {
|
|
428
|
+
return {
|
|
429
|
+
link: {
|
|
430
|
+
target,
|
|
431
|
+
id: createDocId(provider, authored.type, authored.name),
|
|
432
|
+
route: 'authoring',
|
|
433
|
+
title: authored.displayName ?? authored.name,
|
|
434
|
+
summary: authored.description ?? '',
|
|
435
|
+
command: `astryx docs authoring ${authored.name}`,
|
|
436
|
+
},
|
|
437
|
+
kind: parsed.kind,
|
|
438
|
+
typed: {doc: authored, providerId: CLI_PROVIDER_ID, tree: false},
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
if (parsed.kind === 'generic') {
|
|
442
|
+
const entry = catalog.resolve(parsed.name);
|
|
443
|
+
if (
|
|
444
|
+
entry &&
|
|
445
|
+
!entry.tree &&
|
|
446
|
+
(providerOf(entry) === provider ||
|
|
447
|
+
catalog.aliasesOf(entry).includes(parsed.name.toLowerCase()))
|
|
448
|
+
) {
|
|
449
|
+
let title = entry.title ?? entry.name;
|
|
450
|
+
let summary = entry.description ?? '';
|
|
451
|
+
try {
|
|
452
|
+
const raw = await lowerRawTopic(catalog, entry);
|
|
453
|
+
title = raw.doc.title ?? title;
|
|
454
|
+
summary = raw.doc.description ?? summary;
|
|
455
|
+
} catch {
|
|
456
|
+
// The topic budget check reports a topic that does not load; the
|
|
457
|
+
// link still opens it.
|
|
458
|
+
}
|
|
92
459
|
return {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (tb.type === 'list' && block.type === 'list') return {...block, items: tb.items};
|
|
104
|
-
return block;
|
|
105
|
-
},
|
|
106
|
-
),
|
|
460
|
+
link: {
|
|
461
|
+
target,
|
|
462
|
+
id: createDocId(provider, 'generic', parsed.name),
|
|
463
|
+
route: entry.name,
|
|
464
|
+
title,
|
|
465
|
+
summary,
|
|
466
|
+
command: `astryx docs ${entry.name}`,
|
|
467
|
+
},
|
|
468
|
+
kind: 'generic',
|
|
469
|
+
typed: null,
|
|
107
470
|
};
|
|
108
|
-
}
|
|
109
|
-
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
return {
|
|
474
|
+
problem: `"${target}" names no doc. Find it with \`astryx search ${parsed.name} --type doc\`, then name it as \`[<provider>:]<kind>:<name>\`.`,
|
|
475
|
+
};
|
|
110
476
|
};
|
|
111
477
|
}
|
|
112
478
|
|
|
113
479
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
480
|
+
* How a doc's links find their targets (spec:AST-047 FR9), as
|
|
481
|
+
* {@link docFinder} finds them: each resolves to the link a read shows.
|
|
482
|
+
* @param {DocsCatalog} catalog
|
|
483
|
+
* @param {string} fromProvider the provider id of the doc the links sit in
|
|
484
|
+
* @returns {Promise<LinkResolver>}
|
|
485
|
+
*/
|
|
486
|
+
export async function linkResolver(catalog, fromProvider) {
|
|
487
|
+
const find = await docFinder(catalog, fromProvider);
|
|
488
|
+
return async target => {
|
|
489
|
+
const found = await find(target);
|
|
490
|
+
return 'problem' in found ? found : found.link;
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/** How a problem names a doc kind that a reference block cannot include. */
|
|
495
|
+
const KIND_NAMES = /** @type {Record<string, string>} */ ({
|
|
496
|
+
generic: 'topic',
|
|
497
|
+
namespace: 'namespace',
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* How a topic's reference blocks include the docs they name (spec:AST-047
|
|
502
|
+
* FR9): a schema, command, function, or enum doc as `astryx docs` prints
|
|
503
|
+
* it, narrowed by the block's projection and presentation, with the included
|
|
504
|
+
* doc's own links resolved against its own provider. Any other doc shows its
|
|
505
|
+
* title and summary. Each part a block names that it cannot include is a
|
|
506
|
+
* problem, and a read marks where it is missing; a target that names no doc
|
|
507
|
+
* is the resolver's problem.
|
|
508
|
+
* @param {DocsCatalog} catalog
|
|
509
|
+
* @param {string} fromProvider the provider id of the doc the blocks sit in
|
|
510
|
+
* @returns {Promise<DocIncluder>}
|
|
511
|
+
*/
|
|
512
|
+
async function docIncluder(catalog, fromProvider) {
|
|
513
|
+
const find = await docFinder(catalog, fromProvider);
|
|
514
|
+
const tree = await projectTree(catalog);
|
|
515
|
+
return async block => {
|
|
516
|
+
const found = await find(block.target);
|
|
517
|
+
if ('problem' in found) return {content: [], problems: []};
|
|
518
|
+
return includedContent(catalog, tree, block, found);
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* What one reference block includes of the doc it found.
|
|
524
|
+
* @param {DocsCatalog} catalog
|
|
525
|
+
* @param {DocsTree} tree
|
|
526
|
+
* @param {any} block
|
|
527
|
+
* @param {FoundDoc} found
|
|
528
|
+
* @returns {Promise<{content: any[], problems: string[]}>}
|
|
529
|
+
*/
|
|
530
|
+
async function includedContent(catalog, tree, block, found) {
|
|
531
|
+
/** @type {string[]} */
|
|
532
|
+
const problems = [];
|
|
533
|
+
const {fields, sections} = block.projection ?? {};
|
|
534
|
+
const presentation = block.presentation ?? 'full';
|
|
535
|
+
if (sections != null) {
|
|
536
|
+
problems.push(
|
|
537
|
+
'projection.sections: a reference block does not include topic sections; reference a schema, command, function, or enum doc, and name the fields of a schema with projection.fields',
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
const typed = found.typed;
|
|
541
|
+
if (typed == null) {
|
|
542
|
+
// A reference shows any other doc only by its title and summary.
|
|
543
|
+
if (fields != null || (block.presentation ?? 'summary') !== 'summary') {
|
|
544
|
+
problems.push(
|
|
545
|
+
`"${block.target}" is a ${KIND_NAMES[found.kind] ?? `${found.kind} doc`}, which a reference block shows only by its title and summary; remove the projection and the presentation, or reference a schema, command, function, or enum doc`,
|
|
546
|
+
);
|
|
547
|
+
}
|
|
548
|
+
return {content: [], problems};
|
|
549
|
+
}
|
|
550
|
+
if (presentation === 'summary') {
|
|
551
|
+
if (fields != null) {
|
|
552
|
+
problems.push(
|
|
553
|
+
"projection.fields: a summary includes no fields; remove projection.fields or presentation: 'summary'",
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
return {content: [], problems};
|
|
557
|
+
}
|
|
558
|
+
/** @type {any[]} */
|
|
559
|
+
let content;
|
|
560
|
+
if (fields != null && typed.doc.type === 'schema') {
|
|
561
|
+
/** @type {Map<string, any>} */
|
|
562
|
+
const byName = new Map(
|
|
563
|
+
(typed.doc.fields ?? []).map((/** @type {any} */ field) => [
|
|
564
|
+
field.name,
|
|
565
|
+
field,
|
|
566
|
+
]),
|
|
567
|
+
);
|
|
568
|
+
const selected = [];
|
|
569
|
+
/** @type {any[]} */
|
|
570
|
+
const missing = [];
|
|
571
|
+
for (const name of fields) {
|
|
572
|
+
const field = byName.get(name);
|
|
573
|
+
if (field) {
|
|
574
|
+
selected.push(field);
|
|
575
|
+
continue;
|
|
576
|
+
}
|
|
577
|
+
problems.push(
|
|
578
|
+
`projection.fields: "${name}" is not a field of ${found.link.title} (${block.target}). Its fields: ${[...byName.keys()].join(', ')}`,
|
|
579
|
+
);
|
|
580
|
+
missing.push({
|
|
581
|
+
type: 'prose',
|
|
582
|
+
text: `[reference: field "${name}" not found in "${block.target}"]`,
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
const table = schemaFieldTable(selected);
|
|
586
|
+
content = [...(table ? [table] : []), ...missing];
|
|
587
|
+
} else {
|
|
588
|
+
if (fields != null) {
|
|
589
|
+
problems.push(
|
|
590
|
+
`projection.fields: names the fields of a schema doc, and "${block.target}" is a ${typed.doc.type} doc; remove it to include the whole doc`,
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
content = typed.tree
|
|
594
|
+
? cliDocSection(typed.doc, typedDocIndex(tree)).content
|
|
595
|
+
: selfDocSection(typed.doc).content;
|
|
596
|
+
}
|
|
597
|
+
if (presentation === 'compact') {
|
|
598
|
+
content = content.filter(each => each?.type !== 'code');
|
|
599
|
+
}
|
|
600
|
+
// The included doc's own links resolve against its own provider. A link in
|
|
601
|
+
// it that names no doc is that doc's problem, reported where it is written.
|
|
602
|
+
const linked = await linkBlocks(
|
|
603
|
+
content,
|
|
604
|
+
await linkResolver(catalog, typed.providerId),
|
|
605
|
+
);
|
|
606
|
+
return {content: linked.content, problems};
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Every link in the project's docs that names no doc: in each topic, each
|
|
611
|
+
* guide the tree places, and each typed doc.
|
|
612
|
+
* @param {DocsCatalog} catalog
|
|
613
|
+
* @param {DocsTree} tree
|
|
614
|
+
* @param {{owner?: string, references?: boolean}} [options] `owner`: only the
|
|
615
|
+
* docs this package owns. `references`: instead of the links, each reference
|
|
616
|
+
* block that cannot include what it names; a reader loses that content,
|
|
617
|
+
* where a link that names no doc still prints as written
|
|
618
|
+
* @returns {Promise<string[]>}
|
|
619
|
+
*/
|
|
620
|
+
export async function docsLinkProblems(
|
|
621
|
+
catalog,
|
|
622
|
+
tree,
|
|
623
|
+
{owner, references = false} = {},
|
|
624
|
+
) {
|
|
625
|
+
/** @type {string[]} */
|
|
626
|
+
const problems = [];
|
|
627
|
+
/** @param {string} where @param {LinkProblem[]} found */
|
|
628
|
+
const note = (where, found) => {
|
|
629
|
+
for (const problem of found) {
|
|
630
|
+
if ((problem.include === true) !== references) continue;
|
|
631
|
+
problems.push(
|
|
632
|
+
`${where}${problem.section ? ` \u00a7 ${problem.section}` : ''}: ${problem.message}`,
|
|
633
|
+
);
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
for (const entry of catalog.entries()) {
|
|
637
|
+
// A package owns a topic it wrote, and the sections it adds to another
|
|
638
|
+
// package's topic.
|
|
639
|
+
if (
|
|
640
|
+
owner != null &&
|
|
641
|
+
entry.package !== owner &&
|
|
642
|
+
!entry.extensions.some(extension => extension.package === owner)
|
|
643
|
+
) {
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
try {
|
|
647
|
+
note(entry.name, await topicLinkProblems(catalog, entry));
|
|
648
|
+
} catch {
|
|
649
|
+
// The topic budget check reports a topic that does not load.
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
for (const node of tree.nodes.values()) {
|
|
653
|
+
if (owner != null && node.provider !== owner) continue;
|
|
654
|
+
if (node.kind === 'generic' && node.ref?.topicFile) {
|
|
655
|
+
try {
|
|
656
|
+
note(node.route, await topicLinkProblems(catalog, guideEntry(node)));
|
|
657
|
+
} catch {
|
|
658
|
+
// As above.
|
|
659
|
+
}
|
|
660
|
+
} else if (node.ref?.selfDoc) {
|
|
661
|
+
note(node.route, (await nodeContent(catalog, tree, node)).problems);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
return problems;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* What \`astryx doctor integration docs\` checks in one integration's docs: the
|
|
669
|
+
* docs tree they build beside the CLI's (namespaces, placements, routes) and
|
|
670
|
+
* every link in them (spec:AST-046, spec:AST-047). A tree problem hides a doc,
|
|
671
|
+
* so it is an error; a link that names no doc prints as written, so it is a
|
|
672
|
+
* warning.
|
|
673
|
+
* @param {{name: string}} integration
|
|
674
|
+
* @param {{records: import('../../foundation/discovery/docs-discovery.mjs').DocsTopicRecord[], namespaces: import('../../foundation/doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../../foundation/doc-compiler/tree.mjs').TreeDocInput[]}} discovered
|
|
675
|
+
* @returns {Promise<Array<{severity: 'error' | 'warning', message: string}>>}
|
|
676
|
+
*/
|
|
677
|
+
export async function packageDocsProblems(integration, discovered) {
|
|
678
|
+
const catalog = DocsCatalog.fromBuiltins();
|
|
679
|
+
for (const record of discovered.records) catalog.add(record);
|
|
680
|
+
catalog.addTreeInputs({
|
|
681
|
+
namespaces: discovered.namespaces.map(input => ({...input, rank: 1})),
|
|
682
|
+
guides: discovered.guides.map(input => ({...input, rank: 1})),
|
|
683
|
+
});
|
|
684
|
+
const tree = await projectTree(catalog);
|
|
685
|
+
/** @type {Array<{severity: 'error' | 'warning', message: string}>} */
|
|
686
|
+
const problems = tree.diagnostics
|
|
687
|
+
.filter(d => d.severity === 'error' && d.provider === integration.name)
|
|
688
|
+
.map(d => ({
|
|
689
|
+
severity: /** @type {const} */ ('error'),
|
|
690
|
+
message: `${d.source ?? integration.name}: ${d.message}`,
|
|
691
|
+
}));
|
|
692
|
+
for (const message of await docsLinkProblems(catalog, tree, {
|
|
693
|
+
owner: integration.name,
|
|
694
|
+
})) {
|
|
695
|
+
problems.push({severity: 'warning', message});
|
|
696
|
+
}
|
|
697
|
+
return problems;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* How a token reference finds its target: the topic it names in `catalog`,
|
|
702
|
+
* lowered for the same language.
|
|
703
|
+
* @param {DocsCatalog} catalog
|
|
704
|
+
* @param {string | null} lang
|
|
705
|
+
* @returns {(topic: string) => Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode | null>}
|
|
706
|
+
*/
|
|
707
|
+
export function referenceTargets(catalog, lang) {
|
|
708
|
+
return async topic => {
|
|
709
|
+
const target = catalog.resolve(topic);
|
|
710
|
+
return target ? lowerTopic(catalog, target, lang) : null;
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* Each reference block in one integration's docs that cannot include what it
|
|
716
|
+
* names (spec:AST-047 FR9): a target that names no doc, a field its schema
|
|
717
|
+
* does not have, or a projection its doc cannot take. A reader would lose
|
|
718
|
+
* that content, so `astryx doctor integration docs` fails on each.
|
|
719
|
+
* @param {{name: string}} integration
|
|
720
|
+
* @param {{records: import('../../foundation/discovery/docs-discovery.mjs').DocsTopicRecord[], namespaces: import('../../foundation/doc-compiler/tree.mjs').TreeNamespaceInput[], guides: import('../../foundation/doc-compiler/tree.mjs').TreeDocInput[]}} discovered
|
|
721
|
+
* @returns {Promise<string[]>}
|
|
722
|
+
*/
|
|
723
|
+
export async function packageReferenceProblems(integration, discovered) {
|
|
724
|
+
const catalog = DocsCatalog.fromBuiltins();
|
|
725
|
+
for (const record of discovered.records) catalog.add(record);
|
|
726
|
+
catalog.addTreeInputs({
|
|
727
|
+
namespaces: discovered.namespaces.map(input => ({...input, rank: 1})),
|
|
728
|
+
guides: discovered.guides.map(input => ({...input, rank: 1})),
|
|
729
|
+
});
|
|
730
|
+
return docsLinkProblems(catalog, await projectTree(catalog), {
|
|
731
|
+
owner: integration.name,
|
|
732
|
+
references: true,
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* One topic, compiled for `lang`: lowered, then every token reference linked.
|
|
738
|
+
* @param {DocsCatalog} catalog
|
|
122
739
|
* @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
|
|
123
|
-
* @param {
|
|
124
|
-
* @returns {Promise<import('
|
|
740
|
+
* @param {string | null} [lang]
|
|
741
|
+
* @returns {Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode>}
|
|
125
742
|
*/
|
|
126
|
-
export async function
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
743
|
+
export async function compileTopic(catalog, entry, lang = null) {
|
|
744
|
+
return linkReferenceTopic(
|
|
745
|
+
await lowerTopic(catalog, entry, lang),
|
|
746
|
+
referenceTargets(catalog, lang),
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* A guide the docs tree places, as a topic entry the topic readers open by its
|
|
752
|
+
* route. It is never a flat topic: `astryx docs <route>` is its only name.
|
|
753
|
+
* @param {import('../../foundation/doc-compiler/tree.mjs').TreeNode} node
|
|
754
|
+
* @returns {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry}
|
|
755
|
+
*/
|
|
756
|
+
export function guideEntry(node) {
|
|
757
|
+
return {
|
|
758
|
+
name: node.route,
|
|
759
|
+
route: node.route,
|
|
760
|
+
package: node.provider,
|
|
761
|
+
providerId: node.providerId,
|
|
762
|
+
path: node.ref.topicFile,
|
|
763
|
+
extensions: [],
|
|
764
|
+
tree: true,
|
|
765
|
+
parent: node.parent ?? undefined,
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/** @type {WeakMap<DocsTree, ReturnType<typeof cliDocIndex>>} */
|
|
770
|
+
const typedDocIndexes = new WeakMap();
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* What a typed doc in the docs tree prints: its content, with every link to
|
|
774
|
+
* another doc resolved (spec:AST-047 FR9). A namespace has no content. The
|
|
775
|
+
* CLI's doc modules are discovery, so this lives in the adapter
|
|
776
|
+
* (architecture:cli-surface INV21).
|
|
777
|
+
* @param {DocsCatalog} catalog
|
|
778
|
+
* @param {DocsTree} tree
|
|
779
|
+
* @param {TreeNode} node
|
|
780
|
+
* @returns {Promise<{content: any[], problems: LinkProblem[]}>}
|
|
781
|
+
*/
|
|
782
|
+
export async function nodeContent(catalog, tree, node) {
|
|
783
|
+
if (!node.ref?.selfDoc) return {content: [], problems: []};
|
|
784
|
+
const resolve = await linkResolver(catalog, node.providerId);
|
|
785
|
+
return linkBlocks(
|
|
786
|
+
cliDocSection(node.ref.selfDoc, typedDocIndex(tree)).content,
|
|
787
|
+
resolve,
|
|
788
|
+
);
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* The index a typed doc's content reads its cross-links from: every typed doc
|
|
793
|
+
* in the tree. Built once per tree.
|
|
794
|
+
* @param {DocsTree} tree
|
|
795
|
+
* @returns {ReturnType<typeof cliDocIndex>}
|
|
796
|
+
*/
|
|
797
|
+
function typedDocIndex(tree) {
|
|
798
|
+
let index = typedDocIndexes.get(tree);
|
|
799
|
+
if (!index) {
|
|
800
|
+
index = cliDocIndex(
|
|
801
|
+
[...tree.nodes.values()].flatMap(each =>
|
|
802
|
+
each.ref?.selfDoc ? [each.ref.selfDoc] : [],
|
|
803
|
+
),
|
|
804
|
+
);
|
|
805
|
+
typedDocIndexes.set(tree, index);
|
|
130
806
|
}
|
|
131
|
-
return
|
|
807
|
+
return index;
|
|
132
808
|
}
|
|
133
809
|
|
|
134
810
|
/**
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* @param {string} topic
|
|
141
|
-
* @param {object} [options]
|
|
142
|
-
* @param {string} [options.lang]
|
|
143
|
-
* @param {boolean} [options.zh]
|
|
144
|
-
* @param {boolean} [options.dense]
|
|
145
|
-
* @param {string} [options.cwd]
|
|
146
|
-
* @returns {Promise<{
|
|
147
|
-
* catalog: DocsCatalog,
|
|
148
|
-
* docsData: import('./docs.type.mjs').DocsDetailResponse['data'],
|
|
149
|
-
* }>}
|
|
811
|
+
* The command that opens the level a topic sits in when the tree cannot say:
|
|
812
|
+
* a guide's parent namespace, or the topic list.
|
|
813
|
+
* @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
|
|
814
|
+
* @returns {import('./docs.type.mjs').DocsCommand}
|
|
150
815
|
*/
|
|
151
|
-
export
|
|
152
|
-
|
|
153
|
-
|
|
816
|
+
export function topicUp(entry) {
|
|
817
|
+
return entry.tree && entry.parent
|
|
818
|
+
? `astryx docs ${entry.parent}`
|
|
819
|
+
: 'astryx docs';
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* The moves from a node's place in the tree (spec:AST-047 FR2, FR4): up to its
|
|
824
|
+
* parent (the topic list, at the top), and across to the nodes before and
|
|
825
|
+
* after it in its parent's slot.
|
|
826
|
+
* @param {DocsTree} tree
|
|
827
|
+
* @param {TreeNode} node
|
|
828
|
+
* @returns {import('./docs.type.mjs').DocsLinks}
|
|
829
|
+
*/
|
|
830
|
+
export function placeLinks(tree, node) {
|
|
831
|
+
/** @type {import('./docs.type.mjs').DocsLinks} */
|
|
832
|
+
const links = {
|
|
833
|
+
up: node.parent == null ? 'astryx docs' : `astryx docs ${node.parent}`,
|
|
834
|
+
};
|
|
835
|
+
const parent = node.parent == null ? undefined : tree.get(node.parent);
|
|
836
|
+
const siblings =
|
|
837
|
+
parent?.slots.find(slot => slot.children.includes(node.route))?.children ??
|
|
838
|
+
[];
|
|
839
|
+
const at = siblings.indexOf(node.route);
|
|
840
|
+
if (at > 0) links.previous = `astryx docs ${siblings[at - 1]}`;
|
|
841
|
+
if (at !== -1 && at < siblings.length - 1) {
|
|
842
|
+
links.next = `astryx docs ${siblings[at + 1]}`;
|
|
843
|
+
}
|
|
844
|
+
return links;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* The moves a topic read offers: from its place in the tree, where a guide
|
|
849
|
+
* sits in its namespace and a flat topic in the Unorganized level.
|
|
850
|
+
* @param {DocsCatalog} catalog
|
|
851
|
+
* @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
|
|
852
|
+
* @returns {Promise<import('./docs.type.mjs').DocsLinks>}
|
|
853
|
+
*/
|
|
854
|
+
export async function topicLinks(catalog, entry) {
|
|
855
|
+
const tree = await projectTree(catalog);
|
|
856
|
+
const node = tree.get(entry.tree ? (entry.route ?? entry.name) : entry.name);
|
|
857
|
+
const placed =
|
|
858
|
+
node && (entry.tree ? node.kind === 'generic' : node.ref?.flatTopic === entry.name);
|
|
859
|
+
return placed ? placeLinks(tree, node) : {up: topicUp(entry)};
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* What a docs argument names: a topic (a flat one, or a guide the docs tree
|
|
864
|
+
* places), a namespace or typed doc in the tree, or nothing, as nameOwner
|
|
865
|
+
* decides.
|
|
866
|
+
* @param {unknown} topic
|
|
867
|
+
* @param {{cwd?: string}} [options]
|
|
868
|
+
* @returns {Promise<
|
|
869
|
+
* | {kind: 'topic', catalog: DocsCatalog, entry: import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry}
|
|
870
|
+
* | {kind: 'node', catalog: DocsCatalog, tree: import('../../foundation/doc-compiler/tree.mjs').DocsTree, node: import('../../foundation/doc-compiler/tree.mjs').TreeNode}
|
|
871
|
+
* | {kind: 'unknown', catalog: DocsCatalog}
|
|
872
|
+
* >}
|
|
873
|
+
*/
|
|
874
|
+
export async function resolveDocsArgument(topic, {cwd} = {}) {
|
|
154
875
|
const catalog = await loadDocsCatalog(cwd);
|
|
876
|
+
if (typeof topic !== 'string' || topic === '')
|
|
877
|
+
return {kind: 'unknown', catalog};
|
|
878
|
+
const tree = await projectTree(catalog);
|
|
879
|
+
const owner = nameOwner(tree, catalog, topic);
|
|
880
|
+
if (owner == null) return {kind: 'unknown', catalog};
|
|
881
|
+
if (owner.kind === 'topic') return {kind: 'topic', catalog, entry: owner.entry};
|
|
882
|
+
return treeArgument(catalog, tree, owner.node);
|
|
883
|
+
}
|
|
155
884
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
885
|
+
/**
|
|
886
|
+
* Who answers to a name a reader types (spec:AST-046 FR5, FR11). The tree
|
|
887
|
+
* decides first: the node at that route, compared without case, holds it. A
|
|
888
|
+
* name with no node of its own is a topic's other name (its `replaces`
|
|
889
|
+
* alias), and that topic answers, unless the tree gave the topic's own route
|
|
890
|
+
* to another doc. Reads, the topic list, and search all ask this, so they
|
|
891
|
+
* agree on every name.
|
|
892
|
+
* @param {DocsTree} tree
|
|
893
|
+
* @param {DocsCatalog} catalog
|
|
894
|
+
* @param {string} name
|
|
895
|
+
* @returns {{kind: 'topic', entry: import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} | {kind: 'node', node: TreeNode} | null}
|
|
896
|
+
*/
|
|
897
|
+
export function nameOwner(tree, catalog, name) {
|
|
898
|
+
const node = tree.get(name) ?? tree.getFolded?.(name);
|
|
899
|
+
if (node != null) {
|
|
900
|
+
if (node.ref?.flatTopic == null) return {kind: 'node', node};
|
|
901
|
+
const entry = catalog.resolve(node.ref.flatTopic);
|
|
902
|
+
return entry == null ? null : {kind: 'topic', entry};
|
|
166
903
|
}
|
|
904
|
+
const entry = catalog.resolve(name);
|
|
905
|
+
if (entry == null) return null;
|
|
906
|
+
const owner = routeOwner(tree, entry);
|
|
907
|
+
return owner == null ? {kind: 'topic', entry} : {kind: 'node', node: owner};
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* Whether a topic answers to its own name: what the topic list and search
|
|
912
|
+
* offer must open that topic.
|
|
913
|
+
* @param {DocsTree} tree
|
|
914
|
+
* @param {DocsCatalog} catalog
|
|
915
|
+
* @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
|
|
916
|
+
* @returns {boolean}
|
|
917
|
+
*/
|
|
918
|
+
export function holdsOwnName(tree, catalog, entry) {
|
|
919
|
+
const owner = nameOwner(tree, catalog, entry.name);
|
|
920
|
+
return (
|
|
921
|
+
owner?.kind === 'topic' &&
|
|
922
|
+
owner.entry.name === entry.name &&
|
|
923
|
+
owner.entry.package === entry.package
|
|
924
|
+
);
|
|
925
|
+
}
|
|
167
926
|
|
|
168
|
-
|
|
169
|
-
|
|
927
|
+
/**
|
|
928
|
+
* What a tree node opens as: a guide the tree places reads like a topic; a
|
|
929
|
+
* namespace or a typed doc is a node.
|
|
930
|
+
* @param {DocsCatalog} catalog
|
|
931
|
+
* @param {DocsTree} tree
|
|
932
|
+
* @param {TreeNode} node
|
|
933
|
+
* @returns {{kind: 'topic', catalog: DocsCatalog, entry: import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} | {kind: 'node', catalog: DocsCatalog, tree: DocsTree, node: TreeNode}}
|
|
934
|
+
*/
|
|
935
|
+
function treeArgument(catalog, tree, node) {
|
|
936
|
+
if (node.kind === 'generic') {
|
|
937
|
+
return {kind: 'topic', catalog, entry: guideEntry(node)};
|
|
938
|
+
}
|
|
939
|
+
return {kind: 'node', catalog, tree, node};
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* The doc that took a flat topic's route in the docs tree, when it is not
|
|
944
|
+
* that topic (spec:AST-046 FR11): the CLI keeps its routes, such as `cli`
|
|
945
|
+
* and `unorganized`, and a namespace keeps its route over a topic of the same
|
|
946
|
+
* name. Null when the topic owns its route, or the tree has no node there.
|
|
947
|
+
* @param {DocsTree} tree
|
|
948
|
+
* @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
|
|
949
|
+
* @returns {TreeNode | null}
|
|
950
|
+
*/
|
|
951
|
+
export function routeOwner(tree, entry) {
|
|
952
|
+
const node = tree.get(entry.name) ?? tree.getFolded?.(entry.name);
|
|
953
|
+
if (node == null) return null;
|
|
954
|
+
return node.ref?.flatTopic === entry.name && node.provider === entry.package
|
|
955
|
+
? null
|
|
956
|
+
: node;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* The error for a docs argument that names nothing. For a route, it suggests
|
|
961
|
+
* the children of the deepest namespace the route reaches; otherwise, every
|
|
962
|
+
* topic and every top-level namespace.
|
|
963
|
+
* @param {unknown} topic
|
|
964
|
+
* @param {DocsCatalog} catalog
|
|
965
|
+
* @returns {Promise<AstryxError>}
|
|
966
|
+
*/
|
|
967
|
+
export async function unknownTopicError(topic, catalog) {
|
|
968
|
+
const tree = await projectTree(catalog);
|
|
969
|
+
/** @type {Array<{name: string, reason: string}>} */
|
|
970
|
+
let suggestions = [];
|
|
971
|
+
if (typeof topic === 'string' && topic.includes('/')) {
|
|
972
|
+
const parts = topic.split('/');
|
|
973
|
+
for (
|
|
974
|
+
let depth = parts.length - 1;
|
|
975
|
+
depth > 0 && suggestions.length === 0;
|
|
976
|
+
depth--
|
|
977
|
+
) {
|
|
978
|
+
const near = tree.get(parts.slice(0, depth).join('/'));
|
|
979
|
+
if (near) {
|
|
980
|
+
suggestions = near.slots.flatMap(slot =>
|
|
981
|
+
slot.children.map(route => ({
|
|
982
|
+
name: route,
|
|
983
|
+
reason: tree.get(route)?.summary ?? '',
|
|
984
|
+
})),
|
|
985
|
+
);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
if (suggestions.length === 0 && typeof topic === 'string') {
|
|
990
|
+
// The docs whose own name it is (`doctor` is cli/commands/doctor), or whose
|
|
991
|
+
// route it spells with hyphens (`cli-integrations`, the guide's name before
|
|
992
|
+
// it moved to cli/integrations).
|
|
993
|
+
const wanted = topic.toLowerCase();
|
|
994
|
+
suggestions = [...tree.nodes.values()]
|
|
995
|
+
.filter(
|
|
996
|
+
node =>
|
|
997
|
+
!node.ref?.flatTopic &&
|
|
998
|
+
(node.name.toLowerCase() === wanted ||
|
|
999
|
+
node.route.replaceAll('/', '-').toLowerCase() === wanted),
|
|
1000
|
+
)
|
|
1001
|
+
.map(node => ({name: node.route, reason: node.summary}));
|
|
1002
|
+
}
|
|
1003
|
+
if (suggestions.length === 0) {
|
|
1004
|
+
suggestions = [
|
|
1005
|
+
...tree
|
|
1006
|
+
.roots()
|
|
1007
|
+
.map(root => ({name: root.route, reason: 'docs namespace'})),
|
|
1008
|
+
...catalog.names().map(name => ({name, reason: 'available topic'})),
|
|
1009
|
+
];
|
|
1010
|
+
}
|
|
1011
|
+
return new AstryxError(
|
|
1012
|
+
`Unknown topic "${String(topic)}"${notLoaded(catalog)}`,
|
|
1013
|
+
suggestions,
|
|
1014
|
+
ERROR_CODES.ERR_UNKNOWN_TOPIC,
|
|
1015
|
+
);
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* A sentence naming the packages whose docs did not load, or nothing: a doc
|
|
1020
|
+
* that fails to load withdraws its package's docs, so a reader who cannot
|
|
1021
|
+
* find one learns where to look.
|
|
1022
|
+
* @param {DocsCatalog} catalog
|
|
1023
|
+
* @returns {string}
|
|
1024
|
+
*/
|
|
1025
|
+
export function notLoaded(catalog) {
|
|
1026
|
+
const packages = [...new Set(catalog.issues.map(issue => issue.package))];
|
|
1027
|
+
if (packages.length === 0) return '';
|
|
1028
|
+
return `. The docs of ${packages.join(', ')} did not load; run \`astryx doctor integration docs\` in that package to see why.`;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
* Resolve a topic (a flat one, or a guide the docs tree places by its route)
|
|
1033
|
+
* and lower it for the topic readers.
|
|
1034
|
+
* @param {unknown} topic
|
|
1035
|
+
* @param {{lang?: string | null, zh?: boolean, dense?: boolean, cwd?: string}} [options]
|
|
1036
|
+
*/
|
|
1037
|
+
export async function resolveTopicDocs(topic, options = {}) {
|
|
1038
|
+
const {lang = null, zh = false, dense = false, cwd} = options;
|
|
1039
|
+
const effectiveLang = lang || (dense ? 'dense' : zh ? 'zh' : null);
|
|
1040
|
+
// A public API caller could pass a non-string topic; it lands on the same
|
|
1041
|
+
// stable code as an unknown name rather than a raw TypeError.
|
|
1042
|
+
const found = await resolveDocsArgument(topic, {cwd});
|
|
1043
|
+
if (found.kind !== 'topic') {
|
|
1044
|
+
throw found.kind === 'node'
|
|
1045
|
+
? new AstryxError(
|
|
1046
|
+
`"${found.node.route}" is a ${found.node.kind === 'namespace' ? 'namespace' : `${found.node.kind} doc`} in the docs tree, not a topic. Read it with \`astryx docs ${found.node.route}\`.`,
|
|
1047
|
+
undefined,
|
|
1048
|
+
ERROR_CODES.ERR_UNKNOWN_TOPIC,
|
|
1049
|
+
)
|
|
1050
|
+
: await unknownTopicError(topic, found.catalog);
|
|
1051
|
+
}
|
|
1052
|
+
const {catalog, entry} = found;
|
|
1053
|
+
const node = await lowerTopic(catalog, entry, effectiveLang);
|
|
1054
|
+
return {catalog, node, lang: effectiveLang, entry};
|
|
170
1055
|
}
|