@astryxdesign/cli 0.6.3-canary.ea2f048 → 0.6.3-canary.f04b501
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 +106 -72
- package/api/blog/blog.doc.mjs +1 -0
- package/api/build/build.doc.mjs +4 -3
- package/api/build/build.test.mjs +14 -3
- package/api/build/build.type.d.mts +36 -2
- package/api/build/build.type.mjs +25 -4
- package/api/build/help/help.d.mts +8 -5
- package/api/build/help/help.mjs +56 -6
- package/api/component/component.doc.mjs +13 -3
- package/api/component/component.mjs +31 -2
- package/api/component/component.test.mjs +38 -0
- package/api/component/component.type.d.mts +22 -11
- package/api/component/component.type.mjs +32 -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 +37 -9
- package/api/discover/discover.doc.mjs +2 -1
- package/api/discover/discover.type.d.mts +4 -4
- package/api/discover/discover.type.mjs +10 -10
- package/api/docs/_adapter.d.mts +32 -24
- package/api/docs/_adapter.mjs +81 -87
- package/api/docs/compiled-topics.test.mjs +78 -0
- package/api/docs/detail/detail.mjs +14 -63
- package/api/docs/detail/section/section.d.mts +1 -1
- package/api/docs/detail/section/section.mjs +44 -20
- package/api/docs/detail/section/section.test.mjs +41 -0
- package/api/docs/docs.d.mts +7 -2
- package/api/docs/docs.doc.mjs +28 -10
- package/api/docs/docs.mjs +16 -9
- package/api/docs/docs.test.mjs +6 -0
- package/api/docs/docs.type.d.mts +40 -3
- package/api/docs/docs.type.mjs +36 -8
- package/api/docs/index/index.d.mts +18 -0
- package/api/docs/index/index.mjs +32 -0
- package/api/docs/index/index.test.mjs +62 -0
- package/api/docs/integrationDocs.test.mjs +106 -0
- package/api/docs/list/list.mjs +3 -7
- package/api/doctor/doctor.d.mts +70 -0
- package/api/doctor/doctor.doc.mjs +1 -0
- package/api/doctor/doctor.mjs +404 -0
- package/api/doctor/doctor.test.mjs +522 -1
- package/api/gap-report/gap-report.doc.mjs +8 -4
- package/api/hook/_adapter.mjs +19 -5
- package/api/hook/hook.doc.mjs +1 -0
- 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/init/init.doc.mjs +5 -0
- 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.mjs +23 -10
- package/api/integration/add-contribution.test.mjs +121 -7
- package/api/integration/add-theme.mjs +34 -64
- package/api/integration/add-theme.test.mjs +105 -21
- package/api/integration/authoring-checks.test.mjs +8 -4
- package/api/integration/integration-authoring.type.d.mts +1 -1
- package/api/integration/integration-block-exports.test.mjs +10 -6
- package/api/integration/integrationAdd.doc.mjs +8 -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 +1 -0
- 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 +1 -0
- package/api/integration/integrationPackCheck.doc.mjs +1 -0
- package/api/integration/integrationTemplateConflicts.doc.mjs +1 -0
- package/api/integration/pack-check.mjs +49 -7
- package/api/integration/pack-check.test.mjs +266 -47
- package/api/integration/summarizeIssues.doc.mjs +1 -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 +176 -23
- package/api/integration/validate-unread-theme-folders.test.mjs +110 -0
- package/api/integration/validateIntegration.doc.mjs +2 -1
- package/api/json/assertResponse.doc.mjs +1 -0
- package/api/json/envelope-types.test.mjs +76 -0
- package/api/json/isError.doc.mjs +1 -0
- package/api/json/parseResponse.doc.mjs +3 -2
- 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 +3 -10
- package/api/search/search.doc.mjs +6 -1
- package/api/search/search.mjs +31 -14
- package/api/search/search.test.mjs +34 -0
- package/api/search/search.type.d.mts +2 -2
- package/api/search/search.type.mjs +1 -1
- package/api/swizzle/copy/copy.mjs +28 -11
- package/api/swizzle/swizzle.doc.mjs +2 -1
- package/api/swizzle/swizzle.type.d.mts +2 -2
- package/api/swizzle/swizzle.type.mjs +2 -2
- package/api/template/copy/copy.mjs +17 -23
- package/api/template/copy/copy.test.mjs +17 -0
- package/api/template/template-suffix.test.mjs +41 -21
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +3 -1
- package/api/template/template.type.d.mts +6 -6
- package/api/template/template.type.mjs +12 -12
- 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 +20 -3
- package/api/theme/add/add.staging.test.mjs +66 -0
- package/api/theme/add/add.test.mjs +14 -1
- package/api/theme/build/build.mjs +133 -42
- 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.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 +1 -0
- 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 +15 -0
- package/api/theme/theme.type.d.mts +170 -11
- package/api/theme/theme.type.mjs +94 -27
- package/api/theme/themeAdd.doc.mjs +4 -3
- package/api/theme/themeBuild.doc.mjs +8 -4
- package/api/theme/themeList.doc.mjs +6 -3
- package/api/theme/themeListAvailable.doc.mjs +5 -3
- package/api/theme/themePaletteGenerate.doc.mjs +1 -0
- package/api/theme/themeTargets.doc.mjs +1 -0
- package/api/theme/themeTemplate.doc.mjs +5 -1
- package/api/upgrade/_adapter.d.mts +12 -3
- package/api/upgrade/_adapter.mjs +123 -19
- 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/run.mjs +1 -0
- package/api/upgrade/status/status.mjs +2 -2
- package/api/upgrade/upgrade.doc.mjs +7 -4
- package/api/upgrade/upgrade.type.d.mts +9 -5
- package/api/upgrade/upgrade.type.mjs +12 -11
- package/assets/codemods/integration-discovery.mjs +48 -4
- package/assets/codemods/integration-discovery.test.mjs +73 -0
- package/assets/codemods/runner.mjs +115 -5
- 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/next/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +216 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-theme-catalog-to-descriptors.mjs +141 -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/docs/README.md +9 -0
- package/assets/docs/authoring.doc.mjs +14 -0
- package/assets/docs/cli-integrations.doc.mjs +78 -20
- package/assets/docs/cli.doc.mjs +15 -0
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +1 -1
- 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/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/config/config.doc.mjs +2 -2
- package/authoring/config/debug-composition.test.mjs +92 -0
- package/authoring/config/parse.d.mts +13 -13
- package/authoring/config/parse.mjs +8 -8
- package/authoring/config/type.ts +18 -6
- package/authoring/debug/debug.doc.d.mts +11 -0
- package/authoring/debug/debug.doc.mjs +182 -0
- package/authoring/debug/parse.d.mts +5 -5
- package/authoring/debug/parse.mjs +3 -3
- package/authoring/doctypes/_schema.d.mts +788 -23
- package/authoring/doctypes/_schema.mjs +492 -39
- package/authoring/doctypes/base/graph-fields.doc.d.mts +9 -0
- package/authoring/doctypes/base/graph-fields.doc.mjs +62 -0
- package/authoring/doctypes/base/type.ts +40 -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 +4 -3
- package/authoring/doctypes/component/component.doc.mjs +6 -3
- package/authoring/doctypes/component/parse.d.mts +2 -2
- package/authoring/doctypes/component/parse.mjs +1 -1
- package/authoring/doctypes/component/type.ts +6 -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 +5 -1
- package/authoring/doctypes/function/parse.d.mts +2 -2
- package/authoring/doctypes/function/parse.mjs +1 -1
- package/authoring/doctypes/function/type.ts +7 -3
- 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 +208 -0
- package/authoring/doctypes/namespace/namespace.doc.d.mts +9 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +132 -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 +165 -0
- package/authoring/doctypes/namespace/type.ts +71 -0
- package/authoring/doctypes/parse.d.mts +22 -18
- package/authoring/doctypes/parse.mjs +22 -12
- 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 +18 -5
- package/authoring/doctypes/reference/type.ts +53 -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 +1 -1
- package/authoring/doctypes/schema/type.ts +4 -4
- package/authoring/doctypes/template/parse.d.mts +92 -1
- package/authoring/doctypes/template/parse.mjs +36 -2
- package/authoring/doctypes/template/parse.test.mjs +8 -2
- package/authoring/doctypes/template/template.doc.mjs +7 -3
- package/authoring/doctypes/template/type.ts +5 -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 +2 -0
- package/authoring/index.d.ts +51 -17
- package/authoring/index.mjs +3 -1
- package/authoring/integration/integration.doc.mjs +15 -8
- 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 +18 -7
- 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.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 +5 -5
- 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 +5 -2
- package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
- package/clients/cli/commands/build.mjs +32 -47
- package/clients/cli/commands/build.playbook.test.mjs +75 -0
- package/clients/cli/commands/build.text-fields.test.mjs +40 -0
- package/clients/cli/commands/component/index.mjs +2 -7
- 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 +1 -1
- 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 +48 -0
- package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
- package/clients/cli/commands/discover.doc.mjs +5 -3
- package/clients/cli/commands/discover.mjs +3 -3
- package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
- package/clients/cli/commands/docs.doc.mjs +14 -4
- package/clients/cli/commands/docs.mjs +121 -21
- package/clients/cli/commands/docs.test.mjs +88 -0
- package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
- package/clients/cli/commands/doctor-integration-templates.doc.mjs +1 -1
- 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 +15 -7
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.mjs +6 -16
- package/clients/cli/commands/doctor.test.mjs +42 -0
- package/clients/cli/commands/gap-report.doc.mjs +17 -6
- 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 +20 -9
- 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 +22 -6
- package/clients/cli/commands/integration-authoring.test.mjs +13 -9
- package/clients/cli/commands/integration-pack.doc.mjs +1 -1
- package/clients/cli/commands/integration-real-world.test.mjs +3 -9
- package/clients/cli/commands/integration.doc.mjs +1 -1
- 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 +1 -1
- package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
- package/clients/cli/commands/search.doc.mjs +7 -4
- package/clients/cli/commands/search.mjs +17 -7
- package/clients/cli/commands/search.test.mjs +75 -0
- package/clients/cli/commands/swizzle.doc.mjs +3 -2
- package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
- package/clients/cli/commands/template.doc.mjs +29 -7
- package/clients/cli/commands/template.flag-help.test.mjs +117 -0
- package/clients/cli/commands/template.path-help.test.mjs +40 -0
- package/clients/cli/commands/theme-add.doc.mjs +4 -3
- 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 +9 -5
- package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
- package/clients/cli/commands/theme-palette.doc.mjs +1 -1
- package/clients/cli/commands/theme-targets.doc.mjs +1 -1
- 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 +1 -1
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
- package/clients/cli/commands/upgrade.doc.mjs +20 -9
- 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/formatters/index.mjs +162 -1
- package/clients/cli/formatters/index.test.mjs +91 -0
- package/clients/cli/index.mjs +13 -30
- 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 +32 -6
- package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
- package/clients/cli/lib/exit-codes.test.mjs +97 -0
- package/clients/cli/lib/hook-format.mjs +19 -10
- package/clients/cli/lib/json-shim.mjs +38 -2
- 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 +29 -2
- package/clients/cli/lib/manifest.test.mjs +17 -0
- package/foundation/agent-docs/agent-docs.d.mts +4 -0
- package/foundation/agent-docs/agent-docs.mjs +69 -3
- 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 +8 -0
- package/foundation/config/project.mjs +190 -32
- package/foundation/config/project.test.mjs +129 -16
- package/foundation/discovery/authoring-self-docs.d.mts +75 -0
- package/foundation/discovery/authoring-self-docs.mjs +224 -0
- package/foundation/discovery/authoring-self-docs.test.mjs +154 -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 +113 -0
- package/foundation/discovery/cli-self-docs.mjs +514 -0
- package/foundation/discovery/cli-self-docs.test.mjs +437 -0
- package/foundation/discovery/component-discovery.d.mts +1 -1
- package/foundation/discovery/component-discovery.mjs +2 -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 +12 -4
- package/foundation/discovery/docs-discovery.mjs +214 -98
- package/foundation/discovery/docs-discovery.test.mjs +284 -15
- 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 +98 -0
- package/foundation/discovery/docs-section-key.mjs +221 -0
- package/foundation/discovery/docs-section-key.test.mjs +224 -0
- package/foundation/discovery/template-adapter.d.mts +21 -5
- 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 +321 -66
- package/foundation/discovery/template-adapter.test.mjs +15 -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 +218 -0
- package/foundation/doc-compiler/bundle.test.mjs +255 -0
- package/foundation/doc-compiler/compile.d.mts +362 -0
- package/foundation/doc-compiler/compile.mjs +511 -0
- package/foundation/doc-compiler/diagnostics.d.mts +126 -0
- package/foundation/doc-compiler/diagnostics.mjs +277 -0
- package/foundation/doc-compiler/doc-compiler.test.mjs +714 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +1642 -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 +286 -0
- package/foundation/doc-compiler/inputs.test.mjs +299 -0
- package/foundation/doc-compiler/ir.d.mts +22 -0
- package/foundation/doc-compiler/ir.mjs +464 -0
- package/foundation/doc-compiler/lenses.d.mts +33 -0
- package/foundation/doc-compiler/lenses.mjs +127 -0
- package/foundation/doc-compiler/lower-doc.test.mjs +492 -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 +126 -0
- package/foundation/doc-compiler/read.mjs +320 -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/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/contribution-fixes.d.mts +145 -0
- package/foundation/integrations/contribution-fixes.mjs +1284 -0
- package/foundation/integrations/contribution-inventory.d.mts +1 -1
- package/foundation/integrations/contribution-inventory.mjs +17 -20
- package/foundation/integrations/contribution-inventory.test.mjs +67 -27
- package/foundation/integrations/integration-warnings.mjs +6 -0
- package/foundation/integrations/integrations.d.mts +49 -2
- package/foundation/integrations/integrations.mjs +81 -8
- package/foundation/integrations/integrations.test.mjs +384 -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 +114 -10
- package/foundation/response/base.d.ts +8 -4
- package/foundation/response/error-codes.doc.mjs +3 -4
- package/foundation/response/error-codes.mjs +2 -2
- package/foundation/response/error-codes.test.mjs +83 -0
- 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.mjs +16 -11
- package/foundation/response/response-types.doc.test.mjs +158 -0
- package/foundation/response/response.doc.mjs +1 -1
- package/foundation/text/string-utils.mjs +22 -10
- package/foundation/xle/expand.d.mts +2 -0
- package/foundation/xle/expand.mjs +3 -2
- package/foundation/xle/expand.test.mjs +54 -0
- package/package.json +9 -11
- package/assets/templates/themes/manifest.json +0 -95
- 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
|
@@ -1,107 +1,142 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* @file Integration proof for filesystems that reject hard links.
|
|
5
|
+
*
|
|
6
|
+
* A module mock makes `fs.linkSync` fail the way those filesystems do (EPERM,
|
|
7
|
+
* or EXDEV across devices), so `applyWrites` publishes through the
|
|
8
|
+
* exclusive-copy fallback on every run. Private tests use injected seams, not
|
|
9
|
+
* environment variables (AST-017 FR14, DEC-5); the last case holds the
|
|
10
|
+
* publish-file module and its proofs to that.
|
|
7
11
|
*/
|
|
8
12
|
|
|
9
|
-
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
10
|
-
import * as fs from 'node:fs';
|
|
13
|
+
import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
|
|
11
14
|
import * as path from 'node:path';
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
import * as os from 'node:os';
|
|
16
|
+
import {fileURLToPath} from 'node:url';
|
|
17
|
+
import jscodeshift from 'jscodeshift';
|
|
18
|
+
|
|
19
|
+
vi.mock('node:fs', async importOriginal => {
|
|
20
|
+
const actual = await importOriginal();
|
|
21
|
+
return {
|
|
22
|
+
...actual,
|
|
23
|
+
linkSync: vi.fn(() => {
|
|
24
|
+
throw Object.assign(new Error('EPERM: operation not permitted, link'), {code: 'EPERM'});
|
|
25
|
+
}),
|
|
26
|
+
copyFileSync: vi.fn(actual.copyFileSync),
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const {applyWrites} = await import('../../api/integration/add-helpers.mjs');
|
|
31
|
+
const fs = await import('node:fs');
|
|
32
|
+
|
|
33
|
+
describe.each(['EPERM', 'EXDEV'])('hard links fail with %s', code => {
|
|
34
|
+
let testDir;
|
|
35
|
+
|
|
36
|
+
beforeEach(() => {
|
|
37
|
+
vi.clearAllMocks();
|
|
38
|
+
vi.mocked(fs.linkSync).mockImplementation(() => {
|
|
39
|
+
throw Object.assign(new Error(`${code}: cannot link`), {code});
|
|
23
40
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
testDir = fs.mkdtempSync(path.join(os.tmpdir(), '.astryx-publish-proof-'));
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
fs.rmSync(testDir, {recursive: true, force: true});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('applyWrites creates files through the exclusive-copy fallback', () => {
|
|
49
|
+
const plans = [
|
|
50
|
+
{
|
|
51
|
+
path: path.join(testDir, 'MyComponent.tsx'),
|
|
52
|
+
contents: '// MyComponent\nexport default function MyComponent() {}\n',
|
|
53
|
+
createOnly: true,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
path: path.join(testDir, 'MyComponent.test.tsx'),
|
|
57
|
+
contents: '// test\nimport MyComponent from "./MyComponent";\n',
|
|
58
|
+
createOnly: true,
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
const rollback = applyWrites(plans);
|
|
63
|
+
expect(typeof rollback).toBe('function');
|
|
64
|
+
expect(fs.readFileSync(plans[0].path, 'utf-8')).toContain('MyComponent');
|
|
65
|
+
expect(fs.readFileSync(plans[1].path, 'utf-8')).toContain('test');
|
|
66
|
+
expect(fs.linkSync).toHaveBeenCalledTimes(plans.length);
|
|
67
|
+
for (const plan of plans) {
|
|
68
|
+
expect(fs.copyFileSync).toHaveBeenCalledWith(
|
|
69
|
+
expect.any(String),
|
|
70
|
+
plan.path,
|
|
71
|
+
fs.constants.COPYFILE_EXCL,
|
|
36
72
|
);
|
|
37
|
-
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
38
75
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
path: path.join(testDir, 'MyComponent.tsx'),
|
|
43
|
-
contents: '// MyComponent\nexport default function MyComponent() {}\n',
|
|
44
|
-
createOnly: true,
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
path: path.join(testDir, 'MyComponent.test.tsx'),
|
|
48
|
-
contents: '// test\nimport MyComponent from "./MyComponent";\n',
|
|
49
|
-
createOnly: true,
|
|
50
|
-
},
|
|
51
|
-
];
|
|
52
|
-
|
|
53
|
-
const rollback = applyWrites(plans);
|
|
54
|
-
expect(typeof rollback).toBe('function');
|
|
55
|
-
expect(fs.readFileSync(plans[0].path, 'utf-8')).toContain('MyComponent');
|
|
56
|
-
expect(fs.readFileSync(plans[1].path, 'utf-8')).toContain('test');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('applyWrites preserves no-clobber behavior', () => {
|
|
60
|
-
const target = path.join(testDir, 'existing.tsx');
|
|
61
|
-
fs.writeFileSync(target, '// original\n');
|
|
62
|
-
|
|
63
|
-
expect(() =>
|
|
64
|
-
applyWrites([
|
|
65
|
-
{
|
|
66
|
-
path: target,
|
|
67
|
-
contents: '// replacement\n',
|
|
68
|
-
createOnly: true,
|
|
69
|
-
},
|
|
70
|
-
]),
|
|
71
|
-
).toThrow(/overwrite|exists/i);
|
|
72
|
-
expect(fs.readFileSync(target, 'utf-8')).toBe('// original\n');
|
|
73
|
-
});
|
|
76
|
+
it('applyWrites preserves no-clobber behavior', () => {
|
|
77
|
+
const target = path.join(testDir, 'existing.tsx');
|
|
78
|
+
fs.writeFileSync(target, '// original\n');
|
|
74
79
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const bad = path.join(testDir, 'bad.tsx');
|
|
78
|
-
fs.writeFileSync(bad, '// preexisting\n');
|
|
79
|
-
|
|
80
|
-
expect(() =>
|
|
81
|
-
applyWrites([
|
|
82
|
-
{path: good, contents: '// good file\n', createOnly: true},
|
|
83
|
-
{path: bad, contents: '// replacement\n', createOnly: true},
|
|
84
|
-
]),
|
|
85
|
-
).toThrow();
|
|
86
|
-
expect(fs.existsSync(good)).toBe(false);
|
|
87
|
-
expect(fs.readFileSync(bad, 'utf-8')).toBe('// preexisting\n');
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('applyWrites keeps compare-and-swap replacement behavior', () => {
|
|
91
|
-
const target = path.join(testDir, 'config.json');
|
|
92
|
-
const original = '{"version": 1}\n';
|
|
93
|
-
fs.writeFileSync(target, original);
|
|
94
|
-
|
|
95
|
-
const rollback = applyWrites([
|
|
80
|
+
expect(() =>
|
|
81
|
+
applyWrites([
|
|
96
82
|
{
|
|
97
83
|
path: target,
|
|
98
|
-
contents: '
|
|
99
|
-
createOnly:
|
|
100
|
-
expectedOriginal: Buffer.from(original),
|
|
84
|
+
contents: '// replacement\n',
|
|
85
|
+
createOnly: true,
|
|
101
86
|
},
|
|
102
|
-
])
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
)
|
|
87
|
+
]),
|
|
88
|
+
).toThrow(/overwrite|exists/i);
|
|
89
|
+
expect(fs.readFileSync(target, 'utf-8')).toBe('// original\n');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('applyWrites rolls back partial publication', () => {
|
|
93
|
+
const good = path.join(testDir, 'good.tsx');
|
|
94
|
+
const bad = path.join(testDir, 'bad.tsx');
|
|
95
|
+
fs.writeFileSync(bad, '// preexisting\n');
|
|
96
|
+
|
|
97
|
+
expect(() =>
|
|
98
|
+
applyWrites([
|
|
99
|
+
{path: good, contents: '// good file\n', createOnly: true},
|
|
100
|
+
{path: bad, contents: '// replacement\n', createOnly: true},
|
|
101
|
+
]),
|
|
102
|
+
).toThrow();
|
|
103
|
+
expect(fs.existsSync(good)).toBe(false);
|
|
104
|
+
expect(fs.readFileSync(bad, 'utf-8')).toBe('// preexisting\n');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('applyWrites keeps compare-and-swap replacement behavior', () => {
|
|
108
|
+
const target = path.join(testDir, 'config.json');
|
|
109
|
+
const original = '{"version": 1}\n';
|
|
110
|
+
fs.writeFileSync(target, original);
|
|
111
|
+
|
|
112
|
+
const rollback = applyWrites([
|
|
113
|
+
{
|
|
114
|
+
path: target,
|
|
115
|
+
contents: '{"version": 2}\n',
|
|
116
|
+
createOnly: false,
|
|
117
|
+
expectedOriginal: Buffer.from(original),
|
|
118
|
+
},
|
|
119
|
+
]);
|
|
120
|
+
expect(typeof rollback).toBe('function');
|
|
121
|
+
expect(fs.readFileSync(target, 'utf-8')).toBe('{"version": 2}\n');
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe('private test seams', () => {
|
|
126
|
+
it('no publish-file module or proof reads process.env', () => {
|
|
127
|
+
const self = fileURLToPath(import.meta.url);
|
|
128
|
+
const dir = path.dirname(self);
|
|
129
|
+
const files = fs.readdirSync(dir).filter(name => /^publish-file.*\.mjs$/.test(name));
|
|
130
|
+
const j = jscodeshift.withParser('babylon');
|
|
131
|
+
const reads = files.flatMap(name =>
|
|
132
|
+
j(fs.readFileSync(path.join(dir, name), 'utf8'))
|
|
133
|
+
.find(j.MemberExpression, {object: {name: 'process'}})
|
|
134
|
+
.filter(p => (p.node.computed ? p.node.property.value : p.node.property.name) === 'env')
|
|
135
|
+
.nodes()
|
|
136
|
+
.map(node => `${name}:${node.loc?.start.line}`),
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
expect(files).toEqual(expect.arrayContaining(['publish-file.mjs', path.basename(self)]));
|
|
140
|
+
expect(reads).toEqual([]);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Normalize an npm package name into a ProviderId.
|
|
6
|
+
* @param {string} packageName
|
|
7
|
+
* @returns {ProviderId}
|
|
8
|
+
*/
|
|
9
|
+
export function normalizeProviderId(packageName: string): ProviderId;
|
|
10
|
+
/**
|
|
11
|
+
* Normalize a SHA-256 digest.
|
|
12
|
+
* @param {string} digest
|
|
13
|
+
* @returns {ContentDigest}
|
|
14
|
+
*/
|
|
15
|
+
export function normalizeContentDigest(digest: string): ContentDigest;
|
|
16
|
+
/**
|
|
17
|
+
* Build a stable provider + contribution kind + artifact-name ID.
|
|
18
|
+
* @param {string} provider
|
|
19
|
+
* @param {ContributionKind} kind
|
|
20
|
+
* @param {string} name
|
|
21
|
+
* @returns {ArtifactId}
|
|
22
|
+
*/
|
|
23
|
+
export function createArtifactId(provider: string, kind: ContributionKind, name: string): ArtifactId;
|
|
24
|
+
/**
|
|
25
|
+
* Build a stable document ID from provider + authored kind + stable name.
|
|
26
|
+
* @param {string} provider
|
|
27
|
+
* @param {AuthoredDocKind} kind
|
|
28
|
+
* @param {string} name
|
|
29
|
+
* @returns {DocId}
|
|
30
|
+
*/
|
|
31
|
+
export function createDocId(provider: string, kind: AuthoredDocKind, name: string): DocId;
|
|
32
|
+
/**
|
|
33
|
+
* Build a normalized logical artifact record.
|
|
34
|
+
* @param {string} provider
|
|
35
|
+
* @param {ContributionKind} kind
|
|
36
|
+
* @param {string} name
|
|
37
|
+
* @returns {ArtifactIdentity}
|
|
38
|
+
*/
|
|
39
|
+
export function createArtifactIdentity(provider: string, kind: ContributionKind, name: string): ArtifactIdentity;
|
|
40
|
+
/**
|
|
41
|
+
* Parse and canonicalize an ArtifactId.
|
|
42
|
+
* @param {string} value
|
|
43
|
+
* @returns {ArtifactIdentity}
|
|
44
|
+
*/
|
|
45
|
+
export function parseArtifactId(value: string): ArtifactIdentity;
|
|
46
|
+
/**
|
|
47
|
+
* Build one immutable provider instance.
|
|
48
|
+
* @param {{providerId: string, packageName: string, packageVersion: string, sourceDigest: string}} input
|
|
49
|
+
* @returns {ProviderInstance}
|
|
50
|
+
*/
|
|
51
|
+
export function createProviderInstance(input: {
|
|
52
|
+
providerId: string;
|
|
53
|
+
packageName: string;
|
|
54
|
+
packageVersion: string;
|
|
55
|
+
sourceDigest: string;
|
|
56
|
+
}): ProviderInstance;
|
|
57
|
+
/**
|
|
58
|
+
* Bind one validated authored document to immutable provider and source
|
|
59
|
+
* provenance. Runtime lifecycle state is intentionally absent.
|
|
60
|
+
* @param {{
|
|
61
|
+
* provider: ProviderInstance,
|
|
62
|
+
* kind: AuthoredDocKind,
|
|
63
|
+
* stableName: string,
|
|
64
|
+
* source: {group: string, path: string, digest: string},
|
|
65
|
+
* authored: AuthoredDoc,
|
|
66
|
+
* }} input
|
|
67
|
+
* @returns {AuthoredDocEntry}
|
|
68
|
+
*/
|
|
69
|
+
export function createAuthoredDocEntry(input: {
|
|
70
|
+
provider: ProviderInstance;
|
|
71
|
+
kind: AuthoredDocKind;
|
|
72
|
+
stableName: string;
|
|
73
|
+
source: {
|
|
74
|
+
group: string;
|
|
75
|
+
path: string;
|
|
76
|
+
digest: string;
|
|
77
|
+
};
|
|
78
|
+
authored: AuthoredDoc;
|
|
79
|
+
}): AuthoredDocEntry;
|
|
80
|
+
export type ArtifactId = import("../../authoring/identity/type").ArtifactId;
|
|
81
|
+
export type ArtifactIdentity = import("../../authoring/identity/type").ArtifactIdentity;
|
|
82
|
+
export type AuthoredDoc = import("../../authoring/identity/type").AuthoredDoc;
|
|
83
|
+
export type AuthoredDocEntry = import("../../authoring/identity/type").AuthoredDocEntry;
|
|
84
|
+
export type AuthoredDocKind = import("../../authoring/doctypes/base/type").AuthoredDocKind;
|
|
85
|
+
export type ContentDigest = import("../../authoring/identity/type").ContentDigest;
|
|
86
|
+
export type ContributionKind = import("../../authoring/identity/type").ContributionKind;
|
|
87
|
+
export type DocId = import("../../authoring/identity/type").DocId;
|
|
88
|
+
export type ProviderId = import("../../authoring/identity/type").ProviderId;
|
|
89
|
+
export type ProviderInstance = import("../../authoring/identity/type").ProviderInstance;
|
|
90
|
+
export type ProviderInstanceId = import("../../authoring/identity/type").ProviderInstanceId;
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Canonical provider, artifact, and immutable-instance identity helpers.
|
|
5
|
+
*
|
|
6
|
+
* IDs use versioned, RFC 3986-escaped path segments. Provider package names are
|
|
7
|
+
* case-insensitive and normalize to lowercase. Artifact names preserve case and
|
|
8
|
+
* normalize Unicode to NFC.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** @typedef {import('../../authoring/identity/type').ArtifactId} ArtifactId */
|
|
12
|
+
/** @typedef {import('../../authoring/identity/type').ArtifactIdentity} ArtifactIdentity */
|
|
13
|
+
/** @typedef {import('../../authoring/identity/type').AuthoredDoc} AuthoredDoc */
|
|
14
|
+
/** @typedef {import('../../authoring/identity/type').AuthoredDocEntry} AuthoredDocEntry */
|
|
15
|
+
/** @typedef {import('../../authoring/doctypes/base/type').AuthoredDocKind} AuthoredDocKind */
|
|
16
|
+
/** @typedef {import('../../authoring/identity/type').ContentDigest} ContentDigest */
|
|
17
|
+
/** @typedef {import('../../authoring/identity/type').ContributionKind} ContributionKind */
|
|
18
|
+
/** @typedef {import('../../authoring/identity/type').DocId} DocId */
|
|
19
|
+
/** @typedef {import('../../authoring/identity/type').ProviderId} ProviderId */
|
|
20
|
+
/** @typedef {import('../../authoring/identity/type').ProviderInstance} ProviderInstance */
|
|
21
|
+
/** @typedef {import('../../authoring/identity/type').ProviderInstanceId} ProviderInstanceId */
|
|
22
|
+
|
|
23
|
+
const ARTIFACT_PREFIX = 'astryx:artifact:v1/';
|
|
24
|
+
const PROVIDER_INSTANCE_PREFIX = 'astryx:provider-instance:v1/';
|
|
25
|
+
const PACKAGE_NAME_RE =
|
|
26
|
+
/^(?:@[a-z0-9][a-z0-9._~!*'()-]*\/)?[a-z0-9][a-z0-9._~!*'()-]*$/u;
|
|
27
|
+
const SHA256_RE = /^sha256:[0-9a-f]{64}$/u;
|
|
28
|
+
|
|
29
|
+
/** @type {ReadonlySet<ContributionKind>} */
|
|
30
|
+
const CONTRIBUTION_KINDS = new Set([
|
|
31
|
+
'component',
|
|
32
|
+
'function',
|
|
33
|
+
'generic',
|
|
34
|
+
'page',
|
|
35
|
+
'block',
|
|
36
|
+
'schema',
|
|
37
|
+
'command',
|
|
38
|
+
'enum',
|
|
39
|
+
'namespace',
|
|
40
|
+
'theme',
|
|
41
|
+
'codemod',
|
|
42
|
+
'agent-doc',
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
/** @type {ReadonlySet<AuthoredDocKind>} */
|
|
46
|
+
const DOC_KINDS = new Set([
|
|
47
|
+
'component',
|
|
48
|
+
'function',
|
|
49
|
+
'generic',
|
|
50
|
+
'page',
|
|
51
|
+
'block',
|
|
52
|
+
'schema',
|
|
53
|
+
'command',
|
|
54
|
+
'enum',
|
|
55
|
+
'namespace',
|
|
56
|
+
]);
|
|
57
|
+
|
|
58
|
+
/** RFC 3986 path-segment encoding with uppercase escapes. */
|
|
59
|
+
/** @param {string} value @returns {string} */
|
|
60
|
+
function encodeSegment(value) {
|
|
61
|
+
return encodeURIComponent(value).replace(
|
|
62
|
+
/[!'()*]/gu,
|
|
63
|
+
character => `%${character.charCodeAt(0).toString(16).toUpperCase()}`,
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Decode one identity segment or throw a stable, readable error. */
|
|
68
|
+
/** @param {string} value @param {string} label @returns {string} */
|
|
69
|
+
function decodeSegment(value, label) {
|
|
70
|
+
try {
|
|
71
|
+
return decodeURIComponent(value);
|
|
72
|
+
} catch {
|
|
73
|
+
throw new Error(`${label} contains invalid percent escaping.`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Normalize a required identity string without changing meaningful case. */
|
|
78
|
+
/** @param {unknown} value @param {string} label @returns {string} */
|
|
79
|
+
function normalizeName(value, label) {
|
|
80
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
81
|
+
throw new Error(`${label} must be a non-empty string.`);
|
|
82
|
+
}
|
|
83
|
+
return value.trim().normalize('NFC');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Normalize an npm package name into a ProviderId.
|
|
88
|
+
* @param {string} packageName
|
|
89
|
+
* @returns {ProviderId}
|
|
90
|
+
*/
|
|
91
|
+
export function normalizeProviderId(packageName) {
|
|
92
|
+
const normalized = normalizeName(packageName, 'Provider ID').toLowerCase();
|
|
93
|
+
if (!PACKAGE_NAME_RE.test(normalized)) {
|
|
94
|
+
throw new Error(
|
|
95
|
+
`Provider ID "${packageName}" must be a bare npm package name.`,
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
return /** @type {ProviderId} */ (normalized);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Normalize a SHA-256 digest.
|
|
103
|
+
* @param {string} digest
|
|
104
|
+
* @returns {ContentDigest}
|
|
105
|
+
*/
|
|
106
|
+
export function normalizeContentDigest(digest) {
|
|
107
|
+
const normalized = normalizeName(digest, 'Content digest').toLowerCase();
|
|
108
|
+
if (!SHA256_RE.test(normalized)) {
|
|
109
|
+
throw new Error(
|
|
110
|
+
'Content digest must use sha256:<64 lowercase hex characters>.',
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
return /** @type {ContentDigest} */ (normalized);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Build a stable provider + contribution kind + artifact-name ID.
|
|
118
|
+
* @param {string} provider
|
|
119
|
+
* @param {ContributionKind} kind
|
|
120
|
+
* @param {string} name
|
|
121
|
+
* @returns {ArtifactId}
|
|
122
|
+
*/
|
|
123
|
+
export function createArtifactId(provider, kind, name) {
|
|
124
|
+
const providerId = normalizeProviderId(provider);
|
|
125
|
+
if (!CONTRIBUTION_KINDS.has(kind)) {
|
|
126
|
+
throw new Error(`Unknown contribution kind "${String(kind)}".`);
|
|
127
|
+
}
|
|
128
|
+
const stableName = normalizeName(name, 'Artifact name');
|
|
129
|
+
return /** @type {ArtifactId} */ (
|
|
130
|
+
`${ARTIFACT_PREFIX}${encodeSegment(providerId)}/${kind}/${encodeSegment(stableName)}`
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Build a stable document ID from provider + authored kind + stable name.
|
|
136
|
+
* @param {string} provider
|
|
137
|
+
* @param {AuthoredDocKind} kind
|
|
138
|
+
* @param {string} name
|
|
139
|
+
* @returns {DocId}
|
|
140
|
+
*/
|
|
141
|
+
export function createDocId(provider, kind, name) {
|
|
142
|
+
if (!DOC_KINDS.has(kind)) {
|
|
143
|
+
throw new Error(`Unknown authored doc kind "${String(kind)}".`);
|
|
144
|
+
}
|
|
145
|
+
return /** @type {DocId} */ (createArtifactId(provider, kind, name));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Build a normalized logical artifact record.
|
|
150
|
+
* @param {string} provider
|
|
151
|
+
* @param {ContributionKind} kind
|
|
152
|
+
* @param {string} name
|
|
153
|
+
* @returns {ArtifactIdentity}
|
|
154
|
+
*/
|
|
155
|
+
export function createArtifactIdentity(provider, kind, name) {
|
|
156
|
+
const providerId = normalizeProviderId(provider);
|
|
157
|
+
const stableName = normalizeName(name, 'Artifact name');
|
|
158
|
+
return Object.freeze({
|
|
159
|
+
id: createArtifactId(providerId, kind, stableName),
|
|
160
|
+
providerId,
|
|
161
|
+
kind,
|
|
162
|
+
name: stableName,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Parse and canonicalize an ArtifactId.
|
|
168
|
+
* @param {string} value
|
|
169
|
+
* @returns {ArtifactIdentity}
|
|
170
|
+
*/
|
|
171
|
+
export function parseArtifactId(value) {
|
|
172
|
+
if (typeof value !== 'string' || !value.startsWith(ARTIFACT_PREFIX)) {
|
|
173
|
+
throw new Error(`Artifact ID must start with "${ARTIFACT_PREFIX}".`);
|
|
174
|
+
}
|
|
175
|
+
const segments = value.slice(ARTIFACT_PREFIX.length).split('/');
|
|
176
|
+
if (segments.length !== 3) {
|
|
177
|
+
throw new Error(
|
|
178
|
+
'Artifact ID must contain provider, kind, and name segments.',
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
const provider = decodeSegment(segments[0], 'Artifact provider');
|
|
182
|
+
const kind = decodeSegment(segments[1], 'Artifact kind');
|
|
183
|
+
const name = decodeSegment(segments[2], 'Artifact name');
|
|
184
|
+
if (!CONTRIBUTION_KINDS.has(/** @type {ContributionKind} */ (kind))) {
|
|
185
|
+
throw new Error(`Unknown contribution kind "${kind}".`);
|
|
186
|
+
}
|
|
187
|
+
const identity = createArtifactIdentity(
|
|
188
|
+
provider,
|
|
189
|
+
/** @type {ContributionKind} */ (kind),
|
|
190
|
+
name,
|
|
191
|
+
);
|
|
192
|
+
if (identity.id !== value) {
|
|
193
|
+
throw new Error('Artifact ID is not in canonical serialized form.');
|
|
194
|
+
}
|
|
195
|
+
return identity;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Build one immutable provider instance.
|
|
200
|
+
* @param {{providerId: string, packageName: string, packageVersion: string, sourceDigest: string}} input
|
|
201
|
+
* @returns {ProviderInstance}
|
|
202
|
+
*/
|
|
203
|
+
export function createProviderInstance(input) {
|
|
204
|
+
const providerId = normalizeProviderId(input.providerId);
|
|
205
|
+
const packageName = normalizeProviderId(input.packageName);
|
|
206
|
+
const packageVersion = normalizeName(input.packageVersion, 'Package version');
|
|
207
|
+
const sourceDigest = normalizeContentDigest(input.sourceDigest);
|
|
208
|
+
const id = /** @type {ProviderInstanceId} */ (
|
|
209
|
+
`${PROVIDER_INSTANCE_PREFIX}${encodeSegment(providerId)}/${encodeSegment(packageName)}/${encodeSegment(packageVersion)}/${encodeSegment(sourceDigest)}`
|
|
210
|
+
);
|
|
211
|
+
return Object.freeze({
|
|
212
|
+
id,
|
|
213
|
+
providerId,
|
|
214
|
+
packageName,
|
|
215
|
+
packageVersion,
|
|
216
|
+
sourceDigest,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** Normalize a package-relative source path to forward slashes. */
|
|
221
|
+
/** @param {unknown} value @returns {string} */
|
|
222
|
+
function normalizeSourcePath(value) {
|
|
223
|
+
const normalized = normalizeName(value, 'Source path').replaceAll('\\', '/');
|
|
224
|
+
const segments = normalized.split('/');
|
|
225
|
+
if (
|
|
226
|
+
normalized.startsWith('/') ||
|
|
227
|
+
/^[A-Za-z]:\//u.test(normalized) ||
|
|
228
|
+
segments.some(
|
|
229
|
+
segment => segment === '' || segment === '.' || segment === '..',
|
|
230
|
+
)
|
|
231
|
+
) {
|
|
232
|
+
throw new Error('Source path must be a normalized package-relative path.');
|
|
233
|
+
}
|
|
234
|
+
return normalized;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** Infer an unstamped legacy document's kind from its required shape. */
|
|
238
|
+
/** @param {AuthoredDoc} authored @returns {AuthoredDocKind} */
|
|
239
|
+
function authoredKindOf(authored) {
|
|
240
|
+
if (authored.type != null) return authored.type;
|
|
241
|
+
if ('params' in authored && 'returns' in authored) return 'function';
|
|
242
|
+
if (
|
|
243
|
+
'props' in authored ||
|
|
244
|
+
'components' in authored ||
|
|
245
|
+
'subComponentOf' in authored
|
|
246
|
+
) {
|
|
247
|
+
return 'component';
|
|
248
|
+
}
|
|
249
|
+
if ('sections' in authored && 'title' in authored) return 'generic';
|
|
250
|
+
throw new Error('Cannot infer the kind of an unstamped authored document.');
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** Clone and recursively freeze plain authored data. */
|
|
254
|
+
/** @template T @param {T} value @returns {T} */
|
|
255
|
+
function frozenClone(value) {
|
|
256
|
+
const clone = structuredClone(value);
|
|
257
|
+
const seen = new WeakSet();
|
|
258
|
+
/** @param {unknown} current */
|
|
259
|
+
const freeze = current => {
|
|
260
|
+
if (
|
|
261
|
+
current == null ||
|
|
262
|
+
typeof current !== 'object' ||
|
|
263
|
+
Object.isFrozen(current) ||
|
|
264
|
+
seen.has(current)
|
|
265
|
+
) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
seen.add(current);
|
|
269
|
+
for (const nested of Object.values(current)) freeze(nested);
|
|
270
|
+
Object.freeze(current);
|
|
271
|
+
};
|
|
272
|
+
freeze(clone);
|
|
273
|
+
return clone;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Bind one validated authored document to immutable provider and source
|
|
278
|
+
* provenance. Runtime lifecycle state is intentionally absent.
|
|
279
|
+
* @param {{
|
|
280
|
+
* provider: ProviderInstance,
|
|
281
|
+
* kind: AuthoredDocKind,
|
|
282
|
+
* stableName: string,
|
|
283
|
+
* source: {group: string, path: string, digest: string},
|
|
284
|
+
* authored: AuthoredDoc,
|
|
285
|
+
* }} input
|
|
286
|
+
* @returns {AuthoredDocEntry}
|
|
287
|
+
*/
|
|
288
|
+
export function createAuthoredDocEntry(input) {
|
|
289
|
+
const stableName = normalizeName(input.stableName, 'Stable document name');
|
|
290
|
+
const group = normalizeName(input.source.group, 'Source group');
|
|
291
|
+
const sourcePath = normalizeSourcePath(input.source.path);
|
|
292
|
+
const digest = normalizeContentDigest(input.source.digest);
|
|
293
|
+
const authoredKind = authoredKindOf(input.authored);
|
|
294
|
+
if (authoredKind !== input.kind) {
|
|
295
|
+
throw new Error(
|
|
296
|
+
`Document kind "${input.kind}" does not match authored type "${authoredKind}".`,
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const provider = createProviderInstance({
|
|
301
|
+
providerId: input.provider.providerId,
|
|
302
|
+
packageName: input.provider.packageName,
|
|
303
|
+
packageVersion: input.provider.packageVersion,
|
|
304
|
+
sourceDigest: input.provider.sourceDigest,
|
|
305
|
+
});
|
|
306
|
+
if (provider.id !== input.provider.id) {
|
|
307
|
+
throw new Error(
|
|
308
|
+
'Provider instance ID does not match its immutable fields.',
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return Object.freeze({
|
|
313
|
+
id: createDocId(provider.providerId, input.kind, stableName),
|
|
314
|
+
provider,
|
|
315
|
+
kind: input.kind,
|
|
316
|
+
stableName,
|
|
317
|
+
source: Object.freeze({group, path: sourcePath, digest}),
|
|
318
|
+
authored: frozenClone(input.authored),
|
|
319
|
+
});
|
|
320
|
+
}
|