@astryxdesign/cli 0.6.4-canary.f0355e3 → 0.6.4
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 +96 -99
- package/api/build/build.doc.mjs +1 -6
- package/api/build/build.test.mjs +0 -22
- package/api/build/kit/kit.mjs +5 -44
- package/api/component/_adapter.d.mts +0 -25
- package/api/component/_adapter.mjs +5 -59
- package/api/component/component.d.mts +3 -6
- package/api/component/component.doc.mjs +17 -37
- package/api/component/component.mjs +9 -249
- package/api/component/component.type.d.mts +0 -25
- package/api/component/component.type.mjs +0 -44
- package/api/discover/_adapter.d.mts +6 -114
- package/api/discover/_adapter.mjs +17 -372
- package/api/discover/detail/detail.d.mts +6 -18
- package/api/discover/detail/detail.mjs +13 -67
- package/api/discover/detail/detail.test.mjs +0 -85
- package/api/discover/discover.d.mts +9 -3
- package/api/discover/discover.doc.mjs +18 -61
- package/api/discover/discover.mjs +36 -220
- package/api/discover/discover.test.mjs +2 -11
- package/api/discover/discover.type.d.mts +8 -147
- package/api/discover/discover.type.mjs +12 -102
- package/api/discover/list/list.d.mts +6 -20
- package/api/discover/list/list.mjs +12 -45
- package/api/discover/list/list.test.mjs +0 -46
- package/api/discover/search/search.d.mts +16 -18
- package/api/discover/search/search.mjs +56 -102
- package/api/discover/search/search.test.mjs +10 -144
- package/api/docs/_adapter.d.mts +3 -8
- package/api/docs/_adapter.mjs +6 -14
- package/api/docs/docOverlays.test.mjs +1 -27
- package/api/docs/docs.doc.mjs +2 -2
- package/api/docs/docs.test.mjs +243 -0
- package/api/docs/integration-tree.test.mjs +555 -0
- package/api/docs/integrationDocs.test.mjs +314 -0
- package/api/doctor/doctor.d.mts +3 -8
- package/api/doctor/doctor.doc.mjs +8 -17
- package/api/doctor/doctor.mjs +9 -90
- package/api/doctor/doctor.test.mjs +10 -122
- 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 +10 -19
- package/api/hook/hook.doc.mjs +3 -6
- package/api/index.d.mts +2 -1
- package/api/index.mjs +5 -5
- package/api/init/init.doc.mjs +12 -17
- package/api/integration/add-helpers.d.mts +2 -5
- package/api/integration/add-helpers.mjs +9 -36
- package/api/integration/add-theme.mjs +1 -22
- package/api/integration/add-theme.test.mjs +0 -34
- package/api/integration/authoring-checks.mjs +2 -2
- package/api/integration/integrationPackCheck.doc.mjs +3 -3
- package/api/integration/pack-check.mjs +9 -82
- package/api/integration/pack-check.test.mjs +0 -90
- package/api/integration/pack-check.type.mjs +1 -1
- package/api/json/assertResponse.doc.mjs +1 -1
- package/api/json/index.ts +1 -0
- package/api/json/isError.doc.mjs +1 -1
- package/api/layout/_adapter.d.mts +34 -0
- package/api/layout/_adapter.mjs +148 -0
- package/api/layout/check/check.d.mts +16 -0
- package/api/layout/check/check.mjs +40 -0
- package/api/layout/expand/expand.d.mts +22 -0
- package/api/layout/expand/expand.mjs +155 -0
- package/api/layout/expand/expand.path-safety.test.mjs +53 -0
- package/api/layout/grammar/grammar.d.mts +13 -0
- package/api/layout/grammar/grammar.mjs +87 -0
- package/api/layout/layout.d.mts +6 -0
- package/api/layout/layout.mjs +17 -0
- package/api/layout/layout.test.mjs +297 -0
- package/api/layout/layout.type.d.mts +89 -0
- package/api/layout/layout.type.mjs +103 -0
- package/api/layout/layoutCheck.doc.d.mts +11 -0
- package/api/layout/layoutCheck.doc.mjs +85 -0
- package/api/layout/layoutExpand.doc.d.mts +11 -0
- package/api/layout/layoutExpand.doc.mjs +107 -0
- package/api/layout/layoutGrammar.doc.d.mts +11 -0
- package/api/layout/layoutGrammar.doc.mjs +57 -0
- package/api/search/search.d.mts +1 -27
- package/api/search/search.doc.mjs +2 -2
- package/api/search/search.mjs +16 -228
- package/api/search/search.test.mjs +512 -0
- package/api/swizzle/swizzle.doc.mjs +5 -7
- package/api/template/copy/copy.mjs +1 -1
- package/api/template/copy/copy.test.mjs +0 -9
- package/api/template/template-integration.test.mjs +65 -1
- package/api/template/template.doc.mjs +1 -2
- package/api/template/template.mjs +1 -1
- package/api/theme/add/add.mjs +25 -17
- package/api/theme/add/add.staging.test.mjs +23 -40
- package/api/theme/build/build.family.test.mjs +12 -7
- package/api/theme/build/build.mjs +18 -8
- package/api/theme/generateTonalPalette.doc.mjs +2 -1
- package/api/theme/listThemes.doc.mjs +1 -1
- package/api/theme/themeAdd.doc.mjs +10 -9
- package/api/theme/themeBuild.doc.mjs +13 -13
- package/api/theme/themeList.doc.mjs +1 -1
- package/api/theme/themeListAvailable.doc.mjs +1 -2
- package/api/theme/themePaletteGenerate.doc.mjs +8 -15
- package/api/theme/themeTargets.doc.mjs +2 -3
- package/api/theme/themeTemplate.doc.mjs +1 -2
- package/api/upgrade/run/run.mjs +4 -6
- package/api/upgrade/upgrade.doc.mjs +22 -24
- package/api/upgrade/upgrade.type.mjs +2 -2
- package/assets/codemods/__tests__/runner.test.mjs +1 -3
- package/assets/codemods/integration-runner.mjs +3 -3
- package/assets/codemods/runner.mjs +4 -5
- package/assets/docs/README.md +2 -4
- package/assets/docs/browser-support.doc.mjs +11 -11
- package/assets/docs/color.doc.mjs +2 -8
- package/assets/docs/elevation.doc.mjs +4 -6
- package/assets/docs/getting-started.doc.mjs +16 -5
- package/assets/docs/icons.doc.mjs +21 -2
- package/assets/docs/illustrations.doc.mjs +15 -7
- package/assets/docs/internationalization.doc.mjs +5 -7
- package/assets/docs/layout.doc.dense.mjs +82 -130
- package/assets/docs/layout.doc.mjs +77 -133
- package/assets/docs/migration.doc.mjs +21 -19
- package/assets/docs/motion.doc.mjs +3 -16
- package/assets/docs/principles.doc.dense.mjs +5 -5
- package/assets/docs/principles.doc.mjs +0 -8
- package/assets/docs/principles.doc.zh.mjs +6 -6
- package/assets/docs/shape.doc.mjs +3 -8
- package/assets/docs/spacing.doc.mjs +2 -7
- package/assets/docs/styling-libraries.doc.mjs +2 -6
- package/assets/docs/styling.doc.mjs +23 -19
- package/assets/docs/theme.doc.dense.mjs +18 -58
- package/assets/docs/theme.doc.mjs +46 -56
- package/assets/docs/theme.doc.zh.mjs +8 -9
- package/assets/docs/tokens.doc.dense.mjs +2 -2
- package/assets/docs/tokens.doc.mjs +8 -389
- package/assets/docs/tokens.doc.zh.mjs +2 -2
- package/assets/docs/tree/integrations.doc.mjs +451 -25
- package/assets/docs/tree/integrations.test.mjs +62 -0
- package/assets/docs/tree/writing-docs.doc.mjs +286 -0
- package/assets/docs/typography.doc.mjs +4 -24
- package/assets/docs/working-with-ai.doc.mjs +22 -30
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +1 -1
- package/authoring/config/config.doc.mjs +2 -10
- package/authoring/config/parse.d.mts +0 -2
- package/authoring/config/parse.mjs +0 -19
- package/authoring/config/parse.test.mjs +0 -8
- package/authoring/config/type.ts +2 -13
- package/authoring/doctypes/_schema.d.mts +2 -3
- package/authoring/doctypes/_schema.mjs +0 -6
- package/authoring/doctypes/base/graph-fields.doc.mjs +3 -3
- package/authoring/doctypes/base/type.ts +2 -4
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/command/type.ts +1 -1
- package/authoring/doctypes/component/component.doc.mjs +0 -6
- package/authoring/doctypes/component/type.ts +0 -8
- package/authoring/doctypes/reference/reference.doc.mjs +0 -7
- package/authoring/doctypes/reference/type.ts +0 -5
- package/authoring/doctypes/schema/schema.doc.mjs +2 -2
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +2 -2
- package/authoring/index.d.mts +0 -1
- package/authoring/index.d.ts +0 -10
- package/authoring/index.mjs +0 -1
- package/authoring/integration/integration.doc.mjs +10 -12
- package/clients/cli/command-result-coverage.test.mjs +7 -7
- package/clients/cli/commands/component/index.mjs +55 -152
- package/clients/cli/commands/component-ownership.test.mjs +0 -89
- package/clients/cli/commands/component.doc.mjs +9 -27
- package/clients/cli/commands/debug-result-summary.test.mjs +2 -2
- package/clients/cli/commands/discover.doc.mjs +9 -53
- package/clients/cli/commands/discover.mjs +118 -393
- package/clients/cli/commands/docs.doc.mjs +1 -1
- package/clients/cli/commands/docs.mjs +17 -60
- package/clients/cli/commands/docs.test.mjs +294 -0
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +2 -3
- package/clients/cli/commands/doctor-integration.test.mjs +0 -53
- package/clients/cli/commands/doctor.doc.mjs +1 -3
- package/clients/cli/commands/doctor.mjs +5 -49
- package/clients/cli/commands/gap-report.doc.mjs +9 -10
- package/clients/cli/commands/init.doc.mjs +6 -9
- package/clients/cli/commands/integration-add.doc.mjs +9 -9
- package/clients/cli/commands/integration-authoring.test.mjs +10 -61
- package/clients/cli/commands/integration-pack.doc.mjs +9 -5
- package/clients/cli/commands/integration-real-world.test.mjs +1 -1
- package/clients/cli/commands/integration.doc.mjs +4 -4
- package/clients/cli/commands/integration.mjs +43 -74
- package/clients/cli/commands/layout-check.doc.mjs +65 -0
- package/clients/cli/commands/layout-expand.doc.mjs +83 -0
- package/clients/cli/commands/layout-grammar.doc.mjs +30 -0
- package/clients/cli/commands/layout.doc.mjs +34 -0
- package/clients/cli/commands/layout.error-codes.test.mjs +66 -0
- package/clients/cli/commands/layout.exit-parity.test.mjs +41 -0
- package/clients/cli/commands/layout.mjs +275 -0
- 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/search.doc.mjs +3 -10
- package/clients/cli/commands/search.mjs +2 -21
- package/clients/cli/commands/search.test.mjs +4 -21
- package/clients/cli/commands/swizzle.doc.mjs +1 -1
- package/clients/cli/commands/template.doc.mjs +1 -1
- package/clients/cli/commands/text-json-parity.test.mjs +16 -5
- package/clients/cli/commands/theme-add.doc.mjs +1 -1
- package/clients/cli/commands/theme-palette-generate.doc.mjs +2 -3
- package/clients/cli/commands/theme-palette.doc.mjs +2 -1
- package/clients/cli/commands/theme-targets.doc.mjs +2 -2
- package/clients/cli/commands/theme.doc.mjs +1 -2
- package/clients/cli/commands/upgrade.doc.mjs +3 -62
- package/clients/cli/index.mjs +10 -28
- package/clients/cli/lib/define-command.mjs +4 -28
- package/clients/cli/lib/define-command.test.mjs +0 -54
- package/clients/cli/lib/exit-codes.test.mjs +9 -18
- package/clients/cli/lib/json-shim.mjs +14 -24
- package/clients/cli/lib/json-shim.test.mjs +20 -6
- package/clients/cli/lib/manifest.mjs +13 -18
- package/clients/cli/lib/manifest.test.mjs +2 -5
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/agent-docs/agent-docs.test.mjs +1159 -0
- package/foundation/discovery/authoring-self-docs.mjs +0 -1
- package/foundation/discovery/authoring-self-docs.test.mjs +2 -6
- package/foundation/discovery/cli-self-docs.mjs +2 -16
- package/foundation/discovery/cli-self-docs.test.mjs +0 -20
- package/foundation/discovery/docs-discovery.mjs +1 -5
- package/foundation/discovery/docs-discovery.test.mjs +0 -21
- package/foundation/discovery/docs-section-key.d.mts +1 -1
- package/foundation/discovery/docs-section-key.mjs +1 -1
- package/foundation/discovery/template-adapter.mjs +1 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +14 -3
- package/foundation/doc-compiler/tree.d.mts +0 -4
- package/foundation/doc-compiler/tree.mjs +1 -6
- package/foundation/doc-compiler/tree.test.mjs +598 -0
- package/foundation/integrations/cli-requirement.d.mts +6 -26
- package/foundation/integrations/cli-requirement.mjs +11 -46
- package/foundation/integrations/cli-requirement.test.mjs +2 -7
- package/foundation/integrations/contribution-inventory.mjs +1 -1
- package/foundation/integrations/integrations.d.mts +1 -14
- package/foundation/integrations/integrations.mjs +1 -41
- package/foundation/integrations/integrations.test.mjs +0 -31
- package/foundation/response/error-codes.doc.mjs +8 -6
- package/foundation/response/error-codes.test.mjs +5 -30
- package/foundation/response/response-types.doc.d.mts +3 -4
- package/foundation/response/response-types.doc.mjs +27 -40
- package/foundation/response/response-types.doc.test.mjs +0 -23
- package/foundation/response/response.doc.mjs +10 -11
- package/foundation/xle/browser.d.mts +3 -3
- package/foundation/xle/browser.mjs +3 -3
- package/foundation/xle/expand.mjs +2 -2
- package/foundation/xle/parse.mjs +1 -1
- package/foundation/xle/print.mjs +2 -2
- package/foundation/xle/splice.mjs +1 -1
- package/package.json +9 -9
- package/api/discover/_adapter.test.mjs +0 -215
- package/api/discover/_catalog-view.d.mts +0 -115
- package/api/discover/_catalog-view.mjs +0 -203
- package/api/discover/_catalog-view.test.mjs +0 -128
- package/api/discover/detail/item/item.d.mts +0 -26
- package/api/discover/detail/item/item.mjs +0 -78
- package/api/discover/detail/item/item.test.mjs +0 -73
- package/api/integration/pack-check.lifecycle-output.test.mjs +0 -107
- package/api/theme/add/add.rollback.test.mjs +0 -158
- package/api/theme/build/build.rollback.test.mjs +0 -148
- package/api/upgrade/run/files-changed.test.mjs +0 -111
- package/assets/codemods/file-count.test.mjs +0 -163
- package/assets/docs/tree/add-a-component.doc.mjs +0 -75
- package/assets/docs/tree/add-a-theme.doc.mjs +0 -85
- package/assets/docs/tree/add-a-topic.doc.mjs +0 -144
- package/assets/docs/tree/agent-guidance.doc.mjs +0 -138
- package/assets/docs/tree/block-template.doc.mjs +0 -130
- package/assets/docs/tree/build-the-template.doc.mjs +0 -28
- package/assets/docs/tree/building-blocks.doc.mjs +0 -46
- package/assets/docs/tree/check-your-docs.doc.mjs +0 -137
- package/assets/docs/tree/checks.doc.mjs +0 -119
- package/assets/docs/tree/codemods.doc.mjs +0 -147
- package/assets/docs/tree/component-family.doc.mjs +0 -113
- package/assets/docs/tree/component-imports.doc.mjs +0 -69
- package/assets/docs/tree/component-lookups.doc.mjs +0 -149
- package/assets/docs/tree/components.doc.mjs +0 -23
- package/assets/docs/tree/configuration.doc.mjs +0 -23
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +0 -182
- package/assets/docs/tree/define-the-theme.doc.mjs +0 -118
- package/assets/docs/tree/describe-the-component.doc.mjs +0 -57
- package/assets/docs/tree/docs.doc.mjs +0 -21
- package/assets/docs/tree/document-the-template.doc.mjs +0 -28
- package/assets/docs/tree/document-the-theme.doc.mjs +0 -68
- package/assets/docs/tree/export-template-assets.doc.mjs +0 -147
- package/assets/docs/tree/extend-or-replace.doc.mjs +0 -103
- package/assets/docs/tree/fonts-and-assets.doc.mjs +0 -106
- package/assets/docs/tree/generate-a-palette.doc.mjs +0 -66
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +0 -105
- package/assets/docs/tree/help.doc.mjs +0 -16
- package/assets/docs/tree/links.doc.mjs +0 -98
- package/assets/docs/tree/package-and-test.doc.mjs +0 -32
- package/assets/docs/tree/page-template.doc.mjs +0 -71
- package/assets/docs/tree/publishing.doc.mjs +0 -111
- package/assets/docs/tree/quick-start.doc.mjs +0 -272
- package/assets/docs/tree/replace-a-core-component.doc.mjs +0 -104
- package/assets/docs/tree/replace-a-core-template.doc.mjs +0 -172
- package/assets/docs/tree/sections-and-placement.doc.mjs +0 -108
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +0 -59
- package/assets/docs/tree/ship.doc.mjs +0 -16
- package/assets/docs/tree/short-and-findable.doc.mjs +0 -108
- package/assets/docs/tree/single-component.doc.mjs +0 -165
- package/assets/docs/tree/start-a-template.doc.mjs +0 -143
- package/assets/docs/tree/subcomponent.doc.mjs +0 -115
- package/assets/docs/tree/template-assets.doc.mjs +0 -64
- package/assets/docs/tree/template-doc-overview.doc.mjs +0 -109
- package/assets/docs/tree/template-fonts.doc.mjs +0 -102
- package/assets/docs/tree/template-grading-rubric.doc.mjs +0 -452
- package/assets/docs/tree/template-icons.doc.mjs +0 -97
- package/assets/docs/tree/template-images-media.doc.mjs +0 -127
- package/assets/docs/tree/template-styles.doc.mjs +0 -93
- package/assets/docs/tree/templates.doc.mjs +0 -34
- package/assets/docs/tree/test-in-an-app.doc.mjs +0 -115
- package/assets/docs/tree/test-template-in-app.doc.mjs +0 -128
- package/assets/docs/tree/themes.doc.mjs +0 -39
- package/assets/docs/tree/troubleshooting.doc.mjs +0 -149
- package/assets/docs/tree/upgrading.doc.mjs +0 -103
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +0 -51
- package/assets/docs/tree/verify-packed-template.doc.mjs +0 -77
- package/assets/docs/tree/versioning.doc.mjs +0 -161
- package/assets/docs/tree/write-good-templates.doc.mjs +0 -64
- package/assets/docs/tree/write-the-template-file.doc.mjs +0 -154
- package/authoring/discover/discover.doc.d.mts +0 -13
- package/authoring/discover/discover.doc.mjs +0 -138
- package/authoring/discover/parse.d.mts +0 -24
- package/authoring/discover/parse.mjs +0 -128
- package/authoring/discover/parse.test.mjs +0 -124
- package/authoring/discover/type.ts +0 -87
- package/clients/cli/commands/component-batch.test.mjs +0 -341
- package/clients/cli/commands/discover.sources.test.mjs +0 -267
- package/clients/cli/commands/integration-verify.doc.mjs +0 -22
- package/clients/cli/lib/parse-error-format.test.mjs +0 -81
- package/foundation/response/batch.type.d.mts +0 -33
- package/foundation/response/batch.type.mjs +0 -34
|
@@ -68,16 +68,6 @@ export function requireCoreDir(cwd: string): string;
|
|
|
68
68
|
* @returns {Promise<import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]>}
|
|
69
69
|
*/
|
|
70
70
|
export function loadIntegrationsSafely(cwd: string): Promise<import("../../foundation/integrations/integrations.mjs").LoadedIntegration[]>;
|
|
71
|
-
/**
|
|
72
|
-
* Read the exact installed version available to a package-qualified component
|
|
73
|
-
* selector. Legacy docs packages do not expose a reliable version here, so a
|
|
74
|
-
* version-qualified lookup never falls through to them.
|
|
75
|
-
* @param {string} coreDir
|
|
76
|
-
* @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
|
|
77
|
-
* @param {string} packageName
|
|
78
|
-
* @returns {string|null}
|
|
79
|
-
*/
|
|
80
|
-
export function installedComponentPackageVersion(coreDir: string, loadedIntegrations: import("../../foundation/integrations/integrations.mjs").LoadedIntegration[], packageName: string): string | null;
|
|
81
71
|
/**
|
|
82
72
|
* Build the set of OWNER packages that provide a component with this name
|
|
83
73
|
* across core + every loaded integration. This is what lets the CLI
|
|
@@ -190,20 +180,6 @@ export function scopeSubComponent(docs: LoadedComponentDoc, dirName: string, cor
|
|
|
190
180
|
matchingComponent: any;
|
|
191
181
|
} | null;
|
|
192
182
|
export { CORE_PACKAGE };
|
|
193
|
-
/**
|
|
194
|
-
* Internal ambiguity marker. Single-component callers still receive the same
|
|
195
|
-
* AstryxError code, message, and suggestions; batch callers can additionally
|
|
196
|
-
* project every installed candidate without parsing prose.
|
|
197
|
-
*/
|
|
198
|
-
export class ComponentAmbiguityError extends AstryxError {
|
|
199
|
-
/**
|
|
200
|
-
* @param {ComponentOwner[]} owners
|
|
201
|
-
* @param {string} dirName
|
|
202
|
-
*/
|
|
203
|
-
constructor(owners: ComponentOwner[], dirName: string);
|
|
204
|
-
/** @type {import('./component.type.mjs').ComponentBatchCandidate[]} */
|
|
205
|
-
candidates: import("./component.type.mjs").ComponentBatchCandidate[];
|
|
206
|
-
}
|
|
207
183
|
/**
|
|
208
184
|
* A loaded component doc. The shared validated loader accepts stamped and legacy
|
|
209
185
|
* component docs; this loose view captures the fields the API reads across both.
|
|
@@ -282,4 +258,3 @@ export type ResolvedUnscopedDoc = {
|
|
|
282
258
|
resolvedSourcePath: string | null;
|
|
283
259
|
};
|
|
284
260
|
import { CORE_PACKAGE } from '../../foundation/discovery/component-discovery.mjs';
|
|
285
|
-
import { AstryxError } from '../error.mjs';
|
|
@@ -18,8 +18,6 @@
|
|
|
18
18
|
* deduped, so each leaf stays a thin projection.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
import * as fs from 'node:fs';
|
|
22
|
-
import * as path from 'node:path';
|
|
23
21
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
24
22
|
import {
|
|
25
23
|
findCoreDir,
|
|
@@ -148,34 +146,6 @@ function findLoadedIntegration(loadedIntegrations, packageName) {
|
|
|
148
146
|
return loadedIntegrations.find(i => i.name === packageName) ?? null;
|
|
149
147
|
}
|
|
150
148
|
|
|
151
|
-
/**
|
|
152
|
-
* Read the exact installed version available to a package-qualified component
|
|
153
|
-
* selector. Legacy docs packages do not expose a reliable version here, so a
|
|
154
|
-
* version-qualified lookup never falls through to them.
|
|
155
|
-
* @param {string} coreDir
|
|
156
|
-
* @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
|
|
157
|
-
* @param {string} packageName
|
|
158
|
-
* @returns {string|null}
|
|
159
|
-
*/
|
|
160
|
-
export function installedComponentPackageVersion(
|
|
161
|
-
coreDir,
|
|
162
|
-
loadedIntegrations,
|
|
163
|
-
packageName,
|
|
164
|
-
) {
|
|
165
|
-
if (packageName === CORE_PACKAGE) {
|
|
166
|
-
try {
|
|
167
|
-
const pkg = JSON.parse(
|
|
168
|
-
fs.readFileSync(path.join(coreDir, 'package.json'), 'utf8'),
|
|
169
|
-
);
|
|
170
|
-
return typeof pkg.version === 'string' ? pkg.version : null;
|
|
171
|
-
} catch {
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
const integration = findLoadedIntegration(loadedIntegrations, packageName);
|
|
176
|
-
return typeof integration?.version === 'string' ? integration.version : null;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
149
|
/**
|
|
180
150
|
* Resolve an external package by name from the discovered externals list.
|
|
181
151
|
* @param {string} packageName - e.g. '@acme/xds-widgets'
|
|
@@ -274,34 +244,6 @@ export function classifyScope(
|
|
|
274
244
|
return {kind: 'legacy', ext};
|
|
275
245
|
}
|
|
276
246
|
|
|
277
|
-
/**
|
|
278
|
-
* Internal ambiguity marker. Single-component callers still receive the same
|
|
279
|
-
* AstryxError code, message, and suggestions; batch callers can additionally
|
|
280
|
-
* project every installed candidate without parsing prose.
|
|
281
|
-
*/
|
|
282
|
-
export class ComponentAmbiguityError extends AstryxError {
|
|
283
|
-
/** @type {import('./component.type.mjs').ComponentBatchCandidate[]} */
|
|
284
|
-
candidates;
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* @param {ComponentOwner[]} owners
|
|
288
|
-
* @param {string} dirName
|
|
289
|
-
*/
|
|
290
|
-
constructor(owners, dirName) {
|
|
291
|
-
super(
|
|
292
|
-
`Component "${dirName}" is provided by multiple packages. Re-run with --package <pkg> to choose one.`,
|
|
293
|
-
owners.map(o => ({name: o.package, reason: 'provides this component'})),
|
|
294
|
-
ERROR_CODES.ERR_UNKNOWN_COMPONENT,
|
|
295
|
-
);
|
|
296
|
-
this.candidates = owners.map(owner => ({
|
|
297
|
-
package: owner.package,
|
|
298
|
-
component: dirName,
|
|
299
|
-
kind: 'component',
|
|
300
|
-
installed: true,
|
|
301
|
-
}));
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
247
|
/**
|
|
306
248
|
* Refuse to guess when the name is owned by MORE THAN ONE package (core and/or
|
|
307
249
|
* integrations) and the caller did not scope with --package. Legacy
|
|
@@ -312,7 +254,11 @@ export class ComponentAmbiguityError extends AstryxError {
|
|
|
312
254
|
*/
|
|
313
255
|
export function assertUnambiguousOwners(owners, dirName) {
|
|
314
256
|
if (owners.length > 1) {
|
|
315
|
-
throw new
|
|
257
|
+
throw new AstryxError(
|
|
258
|
+
`Component "${dirName}" is provided by multiple packages. Re-run with --package <pkg> to choose one.`,
|
|
259
|
+
owners.map(o => ({name: o.package, reason: 'provides this component'})),
|
|
260
|
+
ERROR_CODES.ERR_UNKNOWN_COMPONENT,
|
|
261
|
+
);
|
|
316
262
|
}
|
|
317
263
|
}
|
|
318
264
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @param {string
|
|
5
|
+
* @param {string} [name]
|
|
6
6
|
* @param {object} [options]
|
|
7
7
|
* @param {string} [options.cwd]
|
|
8
8
|
* @param {boolean} [options.list]
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
* @param {boolean} [options.dense]
|
|
19
19
|
* @returns {Promise<(
|
|
20
20
|
* import('./component.type.mjs').ComponentListResponse
|
|
21
|
-
* | import('./component.type.mjs').ComponentBatchResponse
|
|
22
21
|
* | import('./component.type.mjs').ComponentDetailResponse
|
|
23
22
|
* | import('./component.type.mjs').ComponentDetailPropsResponse
|
|
24
23
|
* | import('./component.type.mjs').ComponentDetailSourceResponse
|
|
@@ -26,7 +25,7 @@
|
|
|
26
25
|
* | import('./component.type.mjs').ComponentDetailBlocksResponse
|
|
27
26
|
* )>}
|
|
28
27
|
*/
|
|
29
|
-
export function component(name?: string
|
|
28
|
+
export function component(name?: string, options?: {
|
|
30
29
|
cwd?: string | undefined;
|
|
31
30
|
list?: boolean | undefined;
|
|
32
31
|
category?: string | undefined;
|
|
@@ -39,6 +38,4 @@ export function component(name?: string | string[], options?: {
|
|
|
39
38
|
lang?: string | undefined;
|
|
40
39
|
zh?: boolean | undefined;
|
|
41
40
|
dense?: boolean | undefined;
|
|
42
|
-
}): Promise<(import("./component.type.mjs").ComponentListResponse | import("./component.type.mjs").
|
|
43
|
-
/** Maximum selectors accepted before any component resolution starts. */
|
|
44
|
-
export const COMPONENT_BATCH_SELECTOR_LIMIT: 100;
|
|
41
|
+
}): Promise<(import("./component.type.mjs").ComponentListResponse | import("./component.type.mjs").ComponentDetailResponse | import("./component.type.mjs").ComponentDetailPropsResponse | import("./component.type.mjs").ComponentDetailSourceResponse | import("./component.type.mjs").ComponentDetailShowcaseResponse | import("./component.type.mjs").ComponentDetailBlocksResponse)>;
|
|
@@ -15,16 +15,16 @@ export const doc = {
|
|
|
15
15
|
namespace: 'cli/api',
|
|
16
16
|
displayName: 'component()',
|
|
17
17
|
summary:
|
|
18
|
-
'Resolve
|
|
18
|
+
'Resolve a component by name, or list the catalog, with optional focused slices (props, source, showcase, blocks).',
|
|
19
19
|
description:
|
|
20
|
-
'Routes on its arguments:
|
|
21
|
-
'integration packages
|
|
22
|
-
'
|
|
23
|
-
'Boolean flags narrow
|
|
24
|
-
'showcase, or example blocks.',
|
|
20
|
+
'Routes on its arguments: a name resolves that component across core and ' +
|
|
21
|
+
'integration packages and returns its authored ComponentDoc plus ownership ' +
|
|
22
|
+
'metadata; no name (or `list`/`category`) returns the catalog grouped by ' +
|
|
23
|
+
'category. Boolean flags narrow a single component to just its props, ' +
|
|
24
|
+
'source, showcase, or example blocks.',
|
|
25
25
|
importPath: '@astryxdesign/cli/api',
|
|
26
26
|
signature:
|
|
27
|
-
'component(name?: string
|
|
27
|
+
'component(name?: string, options?: ComponentOptions): Promise<ComponentListResponse | ComponentDetailResponse | ComponentDetailPropsResponse | ComponentDetailSourceResponse | ComponentDetailShowcaseResponse | ComponentDetailBlocksResponse>',
|
|
28
28
|
keywords: [
|
|
29
29
|
'component',
|
|
30
30
|
'components',
|
|
@@ -37,15 +37,14 @@ export const doc = {
|
|
|
37
37
|
params: [
|
|
38
38
|
{
|
|
39
39
|
name: 'name',
|
|
40
|
-
type: 'string
|
|
40
|
+
type: 'string',
|
|
41
41
|
description:
|
|
42
|
-
"
|
|
42
|
+
"Component name to resolve (e.g. 'Button'). Omit to list the catalog.",
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
name: 'options.cwd',
|
|
46
46
|
type: 'string',
|
|
47
47
|
description: 'Directory to resolve @astryxdesign/core from.',
|
|
48
|
-
default: 'process.cwd()',
|
|
49
48
|
},
|
|
50
49
|
{
|
|
51
50
|
name: 'options.list',
|
|
@@ -55,14 +54,13 @@ export const doc = {
|
|
|
55
54
|
{
|
|
56
55
|
name: 'options.category',
|
|
57
56
|
type: 'string',
|
|
58
|
-
description:
|
|
59
|
-
"List only the components in this group: a key of the unfiltered list (each component's group field), such as 'Layout' or 'Button'. It is not the category field of a component detail.",
|
|
57
|
+
description: 'List only components in this category.',
|
|
60
58
|
},
|
|
61
59
|
{
|
|
62
60
|
name: 'options.package',
|
|
63
61
|
type: 'string',
|
|
64
62
|
description:
|
|
65
|
-
"Scope lookup to a specific external package (e.g. '@acme/widgets').",
|
|
63
|
+
"Scope lookup to a specific external package (e.g. '@acme/xds-widgets').",
|
|
66
64
|
},
|
|
67
65
|
{
|
|
68
66
|
name: 'options.props',
|
|
@@ -89,8 +87,7 @@ export const doc = {
|
|
|
89
87
|
name: 'options.detail',
|
|
90
88
|
type: "'full' | 'compact' | 'brief'",
|
|
91
89
|
description: 'Detail level for list views.',
|
|
92
|
-
default:
|
|
93
|
-
"'full' for a named component; 'brief' for lists (returned as data.detail: 'names')",
|
|
90
|
+
default: "'full' for a named component, 'brief' for list views",
|
|
94
91
|
},
|
|
95
92
|
{
|
|
96
93
|
name: 'options.lang',
|
|
@@ -113,12 +110,7 @@ export const doc = {
|
|
|
113
110
|
{
|
|
114
111
|
type: 'component.list',
|
|
115
112
|
description:
|
|
116
|
-
"The catalog grouped by
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
type: 'component.batch',
|
|
120
|
-
description:
|
|
121
|
-
'An explicit selector array returns one ordered receipt at every array length: count and one results row per selector, including duplicates. ComponentBatchResponse specializes the shared BatchResponse and BatchRow types. Each row carries selector and status (found, not_found, ambiguous, or error); found rows carry the single-selector result, ambiguous rows carry installed candidates ({package, component, kind, installed}), and failed rows carry code, error, and optional suggestions.',
|
|
113
|
+
"The catalog grouped by category. data.detail is the level ('names' | 'compact' | 'full') and data.components is the grouped map: names entries with name, package, and an optional canonical import for integration and legacy package components; brief entries; or full ComponentDoc entries.",
|
|
122
114
|
},
|
|
123
115
|
{
|
|
124
116
|
type: 'component.detail',
|
|
@@ -145,10 +137,6 @@ export const doc = {
|
|
|
145
137
|
},
|
|
146
138
|
],
|
|
147
139
|
throws: [
|
|
148
|
-
{
|
|
149
|
-
code: 'ERR_INVALID_ARGUMENT',
|
|
150
|
-
when: 'a selector array has more than 100 entries, a package-shaped selector has no component item, or its package conflicts with options.package',
|
|
151
|
-
},
|
|
152
140
|
{
|
|
153
141
|
code: 'ERR_INVALID_DETAIL',
|
|
154
142
|
when: "options.detail is not 'full', 'compact', or 'brief'",
|
|
@@ -163,7 +151,7 @@ export const doc = {
|
|
|
163
151
|
},
|
|
164
152
|
{
|
|
165
153
|
code: 'ERR_UNKNOWN_CATEGORY',
|
|
166
|
-
when: 'options.category is not a string or matches no
|
|
154
|
+
when: 'options.category is not a string or matches no known category',
|
|
167
155
|
},
|
|
168
156
|
{
|
|
169
157
|
code: 'ERR_UNKNOWN_COMPONENT',
|
|
@@ -171,16 +159,12 @@ export const doc = {
|
|
|
171
159
|
},
|
|
172
160
|
{
|
|
173
161
|
code: 'ERR_UNKNOWN_PACKAGE',
|
|
174
|
-
when: 'options.package names a legacy external package that cannot be found
|
|
162
|
+
when: 'options.package names a legacy external package that cannot be found',
|
|
175
163
|
},
|
|
176
164
|
{
|
|
177
165
|
code: 'ERR_NO_DOC',
|
|
178
166
|
when: 'the resolved component has no .doc.mjs typed doc file',
|
|
179
167
|
},
|
|
180
|
-
{
|
|
181
|
-
code: 'ERR_INVALID_DOC',
|
|
182
|
-
when: "the resolved component's .doc.mjs fails to load or validate",
|
|
183
|
-
},
|
|
184
168
|
{
|
|
185
169
|
code: 'ERR_NO_SOURCE',
|
|
186
170
|
when: 'options.source is set but the component has no source file',
|
|
@@ -195,14 +179,10 @@ export const doc = {
|
|
|
195
179
|
label: 'Look up a component',
|
|
196
180
|
code: "const r = await component('Button');",
|
|
197
181
|
},
|
|
198
|
-
{
|
|
199
|
-
label: 'Look up several components',
|
|
200
|
-
code: "await component(['Button', 'Badge']);",
|
|
201
|
-
},
|
|
202
182
|
{label: 'Props only', code: "await component('Button', {props: true});"},
|
|
203
183
|
{
|
|
204
|
-
label: 'Browse
|
|
205
|
-
code: "await component(undefined, {category: '
|
|
184
|
+
label: 'Browse a category',
|
|
185
|
+
code: "await component(undefined, {category: 'Form', detail: 'compact'});",
|
|
206
186
|
},
|
|
207
187
|
],
|
|
208
188
|
command: 'component',
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* @file Programmatic API for the component command — DISPATCHER + BARREL.
|
|
5
5
|
*
|
|
6
6
|
* Returns the same typed envelope { type, data } that `astryx --json component`
|
|
7
|
-
* outputs. `component(name, opts)` parses
|
|
8
|
-
*
|
|
9
|
-
* (list · detail · detail.props/source/showcase/blocks)
|
|
10
|
-
* is a thin wrapper around this function.
|
|
7
|
+
* outputs. `component(name, opts)` parses the (name, options) pair, resolves the
|
|
8
|
+
* subject once via `_adapter`, and routes to the correct leaf
|
|
9
|
+
* (list · detail · detail.props/source/showcase/blocks), returning that leaf's
|
|
10
|
+
* envelope. The CLI command handler is a thin wrapper around this function.
|
|
11
11
|
*
|
|
12
12
|
* Every leaf is also re-exported for direct scripting use.
|
|
13
13
|
*/
|
|
@@ -26,8 +26,6 @@ import {
|
|
|
26
26
|
resolveUnscopedDoc,
|
|
27
27
|
loadComponentDoc,
|
|
28
28
|
scopeSubComponent,
|
|
29
|
-
ComponentAmbiguityError,
|
|
30
|
-
installedComponentPackageVersion,
|
|
31
29
|
} from './_adapter.mjs';
|
|
32
30
|
import {componentList} from './list/list.mjs';
|
|
33
31
|
import {componentDetail} from './detail/detail.mjs';
|
|
@@ -36,199 +34,13 @@ import {componentDetailSource} from './detail/source/source.mjs';
|
|
|
36
34
|
import {componentDetailShowcase} from './detail/showcase/showcase.mjs';
|
|
37
35
|
import {componentDetailBlocks} from './detail/blocks/blocks.mjs';
|
|
38
36
|
|
|
39
|
-
/** Maximum selectors accepted before any component resolution starts. */
|
|
40
|
-
export const COMPONENT_BATCH_SELECTOR_LIMIT = 100;
|
|
41
|
-
|
|
42
37
|
/** @type {ReadonlyArray<string>} */
|
|
43
38
|
const DETAIL_LEVELS = ['full', 'compact', 'brief'];
|
|
44
39
|
/** @type {ReadonlyArray<string>} */
|
|
45
40
|
const LANGS = ['en', 'zh', 'dense'];
|
|
46
|
-
/** @type {Set<string>} */
|
|
47
|
-
const NOT_FOUND_CODES = new Set([
|
|
48
|
-
ERROR_CODES.ERR_UNKNOWN_COMPONENT,
|
|
49
|
-
ERROR_CODES.ERR_UNKNOWN_PACKAGE,
|
|
50
|
-
ERROR_CODES.ERR_NOT_FOUND,
|
|
51
|
-
]);
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Discover-compatible package target grammar. Versions belong to the package
|
|
55
|
-
* head, never the item after the package slash.
|
|
56
|
-
* @param {string} selector
|
|
57
|
-
* @returns {{scoped: boolean, name: string, version?: string, item?: string}}
|
|
58
|
-
*/
|
|
59
|
-
function splitSelector(selector) {
|
|
60
|
-
const scoped = selector.startsWith('@');
|
|
61
|
-
const firstSlash = selector.indexOf('/');
|
|
62
|
-
let head = selector;
|
|
63
|
-
/** @type {string | undefined} */
|
|
64
|
-
let rest;
|
|
65
|
-
const split = scoped
|
|
66
|
-
? firstSlash < 0
|
|
67
|
-
? -1
|
|
68
|
-
: selector.indexOf('/', firstSlash + 1)
|
|
69
|
-
: firstSlash;
|
|
70
|
-
if (split > 0) {
|
|
71
|
-
head = selector.slice(0, split);
|
|
72
|
-
rest = selector.slice(split + 1) || undefined;
|
|
73
|
-
}
|
|
74
|
-
const at = head.indexOf('@', 1);
|
|
75
|
-
return {
|
|
76
|
-
scoped,
|
|
77
|
-
name: at > 0 ? head.slice(0, at) : head,
|
|
78
|
-
...(at > 0 && head.slice(at + 1) ? {version: head.slice(at + 1)} : {}),
|
|
79
|
-
...(rest ? {item: rest} : {}),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Resolve one component selector into the existing single-component API inputs.
|
|
85
|
-
* @param {unknown} value
|
|
86
|
-
* @param {string|undefined} packageScope
|
|
87
|
-
* @returns {{selector: string, name: string, package?: string, version?: string}}
|
|
88
|
-
*/
|
|
89
|
-
function parseComponentSelector(value, packageScope) {
|
|
90
|
-
if (typeof value !== 'string' || value.length === 0) {
|
|
91
|
-
throw new AstryxError(
|
|
92
|
-
`Invalid component selector "${String(value)}"`,
|
|
93
|
-
undefined,
|
|
94
|
-
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
const target = splitSelector(value);
|
|
98
|
-
const packageShaped =
|
|
99
|
-
target.scoped || target.item != null || target.version != null;
|
|
100
|
-
if (!packageShaped) {
|
|
101
|
-
return {selector: value, name: target.name, package: packageScope};
|
|
102
|
-
}
|
|
103
|
-
if (!target.item) {
|
|
104
|
-
throw new AstryxError(
|
|
105
|
-
`Component selector "${value}" names a package but no component`,
|
|
106
|
-
undefined,
|
|
107
|
-
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
if (packageScope && packageScope !== target.name) {
|
|
111
|
-
throw new AstryxError(
|
|
112
|
-
`Component selector "${value}" conflicts with --package "${packageScope}"`,
|
|
113
|
-
undefined,
|
|
114
|
-
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
return {
|
|
118
|
-
selector: value,
|
|
119
|
-
name: target.item,
|
|
120
|
-
package: target.name,
|
|
121
|
-
...(target.version ? {version: target.version} : {}),
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* A version-qualified selector never falls through to another installed
|
|
127
|
-
* version. Its structured suggestion points at the command that can discover
|
|
128
|
-
* the requested package release.
|
|
129
|
-
* @param {{package?: string, version?: string}} target
|
|
130
|
-
* @param {string} coreDir
|
|
131
|
-
* @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
|
|
132
|
-
* @returns {void}
|
|
133
|
-
*/
|
|
134
|
-
function requireInstalledSelectorVersion(target, coreDir, loadedIntegrations) {
|
|
135
|
-
if (!target.version) return;
|
|
136
|
-
const packageName = /** @type {string} */ (target.package);
|
|
137
|
-
const installed = installedComponentPackageVersion(
|
|
138
|
-
coreDir,
|
|
139
|
-
loadedIntegrations,
|
|
140
|
-
packageName,
|
|
141
|
-
);
|
|
142
|
-
if (installed === target.version) return;
|
|
143
|
-
const exact = `${packageName}@${target.version}`;
|
|
144
|
-
throw new AstryxError(
|
|
145
|
-
`Package "${exact}" is not installed`,
|
|
146
|
-
[
|
|
147
|
-
{
|
|
148
|
-
name: `astryx discover ${exact}`,
|
|
149
|
-
reason: 'look up this package version',
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
ERROR_CODES.ERR_UNKNOWN_PACKAGE,
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Turn a single-lookup failure into one complete batch row.
|
|
158
|
-
* @param {string} selector
|
|
159
|
-
* @param {unknown} error
|
|
160
|
-
* @returns {import('./component.type.mjs').ComponentBatchResult}
|
|
161
|
-
*/
|
|
162
|
-
function batchFailure(selector, error) {
|
|
163
|
-
const err =
|
|
164
|
-
error instanceof AstryxError
|
|
165
|
-
? error
|
|
166
|
-
: new AstryxError(
|
|
167
|
-
error instanceof Error ? error.message : String(error),
|
|
168
|
-
undefined,
|
|
169
|
-
ERROR_CODES.ERR_UNKNOWN,
|
|
170
|
-
);
|
|
171
|
-
if (err instanceof ComponentAmbiguityError) {
|
|
172
|
-
return {
|
|
173
|
-
selector,
|
|
174
|
-
status: 'ambiguous',
|
|
175
|
-
code: err.code,
|
|
176
|
-
error: err.message,
|
|
177
|
-
candidates: err.candidates,
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
return {
|
|
181
|
-
selector,
|
|
182
|
-
status: NOT_FOUND_CODES.has(err.code) ? 'not_found' : 'error',
|
|
183
|
-
code: err.code,
|
|
184
|
-
error: err.message,
|
|
185
|
-
...(err.suggestions ? {suggestions: err.suggestions} : {}),
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
41
|
|
|
189
42
|
/**
|
|
190
|
-
* @param {
|
|
191
|
-
* @param {object} options
|
|
192
|
-
* @param {string} options.cwd
|
|
193
|
-
* @param {string} [options.package]
|
|
194
|
-
* @param {boolean} [options.props]
|
|
195
|
-
* @param {boolean} [options.source]
|
|
196
|
-
* @param {boolean} [options.showcase]
|
|
197
|
-
* @param {boolean} [options.blocks]
|
|
198
|
-
* @param {'full'|'compact'|'brief'} [options.detail]
|
|
199
|
-
* @param {string|null} [options.lang]
|
|
200
|
-
* @param {boolean} [options.zh]
|
|
201
|
-
* @param {boolean} [options.dense]
|
|
202
|
-
* @param {string} coreDir
|
|
203
|
-
* @returns {Promise<import('./component.type.mjs').ComponentBatchResponse>}
|
|
204
|
-
*/
|
|
205
|
-
async function componentBatch(selectors, options, coreDir) {
|
|
206
|
-
const loadedIntegrations = await loadIntegrationsSafely(options.cwd);
|
|
207
|
-
/** @type {import('./component.type.mjs').ComponentBatchResult[]} */
|
|
208
|
-
const results = [];
|
|
209
|
-
for (const value of selectors) {
|
|
210
|
-
const selector = typeof value === 'string' ? value : String(value);
|
|
211
|
-
try {
|
|
212
|
-
const target = parseComponentSelector(value, options.package);
|
|
213
|
-
requireInstalledSelectorVersion(target, coreDir, loadedIntegrations);
|
|
214
|
-
const result =
|
|
215
|
-
/** @type {import('./component.type.mjs').ComponentSingleResponse} */ (
|
|
216
|
-
await component(target.name, {
|
|
217
|
-
...options,
|
|
218
|
-
lang: options.lang ?? undefined,
|
|
219
|
-
package: target.package,
|
|
220
|
-
})
|
|
221
|
-
);
|
|
222
|
-
results.push({selector, status: 'found', result});
|
|
223
|
-
} catch (error) {
|
|
224
|
-
results.push(batchFailure(selector, error));
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
return {type: 'component.batch', data: {count: results.length, results}};
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* @param {string|string[]} [name]
|
|
43
|
+
* @param {string} [name]
|
|
232
44
|
* @param {object} [options]
|
|
233
45
|
* @param {string} [options.cwd]
|
|
234
46
|
* @param {boolean} [options.list]
|
|
@@ -244,7 +56,6 @@ async function componentBatch(selectors, options, coreDir) {
|
|
|
244
56
|
* @param {boolean} [options.dense]
|
|
245
57
|
* @returns {Promise<(
|
|
246
58
|
* import('./component.type.mjs').ComponentListResponse
|
|
247
|
-
* | import('./component.type.mjs').ComponentBatchResponse
|
|
248
59
|
* | import('./component.type.mjs').ComponentDetailResponse
|
|
249
60
|
* | import('./component.type.mjs').ComponentDetailPropsResponse
|
|
250
61
|
* | import('./component.type.mjs').ComponentDetailSourceResponse
|
|
@@ -268,16 +79,11 @@ export async function component(name, options = {}) {
|
|
|
268
79
|
dense = false,
|
|
269
80
|
} = options;
|
|
270
81
|
|
|
271
|
-
const selectorList = Array.isArray(name) ? name : null;
|
|
272
|
-
const noName = selectorList == null && !name;
|
|
273
|
-
|
|
274
82
|
// Default detail level mirrors the CLI (see commands/component/index.mjs):
|
|
275
83
|
// single-component views default to 'full', list-style views (--list,
|
|
276
84
|
// --category, or no name) default to 'brief' (scannable name lists).
|
|
277
|
-
//
|
|
278
|
-
|
|
279
|
-
const isListView =
|
|
280
|
-
selectorList == null && (list || category != null || noName);
|
|
85
|
+
// Keeping this in sync with the CLI is what the API↔CLI parity test checks.
|
|
86
|
+
const isListView = list || category != null || !name;
|
|
281
87
|
const detail = detailOption ?? (isListView ? 'brief' : 'full');
|
|
282
88
|
|
|
283
89
|
// Same accepted values and codes as the CLI's --detail and --lang, checked
|
|
@@ -297,14 +103,6 @@ export async function component(name, options = {}) {
|
|
|
297
103
|
);
|
|
298
104
|
}
|
|
299
105
|
|
|
300
|
-
if (selectorList && selectorList.length > COMPONENT_BATCH_SELECTOR_LIMIT) {
|
|
301
|
-
throw new AstryxError(
|
|
302
|
-
`Component batch accepts at most ${COMPONENT_BATCH_SELECTOR_LIMIT} selectors; received ${selectorList.length}`,
|
|
303
|
-
undefined,
|
|
304
|
-
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
305
|
-
);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
106
|
const coreDir = requireCoreDir(cwd);
|
|
309
107
|
|
|
310
108
|
// A public API caller could pass a non-string category; the list leaf does
|
|
@@ -318,46 +116,11 @@ export async function component(name, options = {}) {
|
|
|
318
116
|
);
|
|
319
117
|
}
|
|
320
118
|
|
|
321
|
-
// ── Explicit batch selector list ─────────────────────────────────
|
|
322
|
-
// Array shape owns cardinality even if a caller also supplies a list-only
|
|
323
|
-
// option. The aggregate limit above is checked before core or integrations
|
|
324
|
-
// are resolved, so an oversized request can never emit a partial receipt.
|
|
325
|
-
if (selectorList) {
|
|
326
|
-
return componentBatch(
|
|
327
|
-
selectorList,
|
|
328
|
-
{
|
|
329
|
-
cwd,
|
|
330
|
-
package: packageScope,
|
|
331
|
-
props,
|
|
332
|
-
source,
|
|
333
|
-
showcase,
|
|
334
|
-
blocks,
|
|
335
|
-
detail,
|
|
336
|
-
lang,
|
|
337
|
-
zh,
|
|
338
|
-
dense,
|
|
339
|
-
},
|
|
340
|
-
coreDir,
|
|
341
|
-
);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
119
|
// ── List mode ──────────────────────────────────────────────────
|
|
345
|
-
if (category || list ||
|
|
120
|
+
if (category || list || !name) {
|
|
346
121
|
return componentList(coreDir, {cwd, category, detail, zh, dense, lang});
|
|
347
122
|
}
|
|
348
123
|
|
|
349
|
-
if (typeof name === 'string') {
|
|
350
|
-
const target = parseComponentSelector(name, packageScope);
|
|
351
|
-
if (target.version) {
|
|
352
|
-
const loadedIntegrations = await loadIntegrationsSafely(cwd);
|
|
353
|
-
requireInstalledSelectorVersion(target, coreDir, loadedIntegrations);
|
|
354
|
-
}
|
|
355
|
-
if (target.name !== name || target.package !== packageScope) {
|
|
356
|
-
return component(target.name, {...options, package: target.package});
|
|
357
|
-
}
|
|
358
|
-
name = target.name;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
124
|
// ── Single component ───────────────────────────────────────────
|
|
362
125
|
if (typeof name !== 'string') {
|
|
363
126
|
throw new AstryxError(
|
|
@@ -423,10 +186,7 @@ export async function component(name, options = {}) {
|
|
|
423
186
|
if (extDocPath) {
|
|
424
187
|
// Legacy packages ship docs, never source.
|
|
425
188
|
if (source) {
|
|
426
|
-
return componentDetailSource(dirName, null, {
|
|
427
|
-
name,
|
|
428
|
-
notFoundInPackage: packageScope,
|
|
429
|
-
});
|
|
189
|
+
return componentDetailSource(dirName, null, {name, notFoundInPackage: packageScope});
|
|
430
190
|
}
|
|
431
191
|
if (blocks) {
|
|
432
192
|
return componentDetailBlocks(dirName, cwd);
|
|
@@ -28,31 +28,6 @@ export type ComponentListData = ({
|
|
|
28
28
|
detail: "full";
|
|
29
29
|
components: Record<string, import("@astryxdesign/cli/authoring").ComponentDoc[]>;
|
|
30
30
|
});
|
|
31
|
-
/**
|
|
32
|
-
* `component(string[])` always returns this type, including empty and one-item
|
|
33
|
-
* arrays. The CLI returns it for two or more positional selectors.
|
|
34
|
-
*/
|
|
35
|
-
export type ComponentBatchResponse = import("../../foundation/response/batch.type.mjs").BatchResponse<"component.batch", ComponentSingleResponse, ComponentBatchCandidate>;
|
|
36
|
-
/**
|
|
37
|
-
* One installed component that makes an unqualified selector ambiguous.
|
|
38
|
-
* Keys match a component row in `discover.search` so a caller does not learn a
|
|
39
|
-
* second candidate shape.
|
|
40
|
-
*/
|
|
41
|
-
export type ComponentBatchCandidate = {
|
|
42
|
-
package: string;
|
|
43
|
-
component: string;
|
|
44
|
-
kind: "component";
|
|
45
|
-
installed: true;
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* The response a successful single selector would have returned.
|
|
49
|
-
*/
|
|
50
|
-
export type ComponentSingleResponse = (ComponentDetailResponse | ComponentDetailPropsResponse | ComponentDetailSourceResponse | ComponentDetailShowcaseResponse | ComponentDetailBlocksResponse);
|
|
51
|
-
/**
|
|
52
|
-
* One row per requested selector, in argument order. Duplicate selectors keep
|
|
53
|
-
* duplicate rows.
|
|
54
|
-
*/
|
|
55
|
-
export type ComponentBatchResult = import("../../foundation/response/batch.type.mjs").BatchRow<ComponentSingleResponse, ComponentBatchCandidate>;
|
|
56
31
|
/**
|
|
57
32
|
* A single entry in a `component.list` group at `detail: 'names'`. Pre-1.0 the
|
|
58
33
|
* list moved from bare strings to package-qualified objects so consumers can
|