@astryxdesign/cli 0.6.4-canary.ed2e54e → 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.
Files changed (145) hide show
  1. package/README.md +66 -64
  2. package/api/component/_adapter.d.mts +0 -25
  3. package/api/component/_adapter.mjs +5 -59
  4. package/api/component/component.d.mts +3 -6
  5. package/api/component/component.doc.mjs +10 -23
  6. package/api/component/component.mjs +9 -249
  7. package/api/component/component.type.d.mts +0 -25
  8. package/api/component/component.type.mjs +0 -44
  9. package/api/discover/_adapter.d.mts +6 -114
  10. package/api/discover/_adapter.mjs +17 -372
  11. package/api/discover/detail/detail.d.mts +6 -18
  12. package/api/discover/detail/detail.mjs +13 -67
  13. package/api/discover/detail/detail.test.mjs +0 -85
  14. package/api/discover/discover.d.mts +9 -3
  15. package/api/discover/discover.doc.mjs +18 -61
  16. package/api/discover/discover.mjs +36 -220
  17. package/api/discover/discover.test.mjs +2 -11
  18. package/api/discover/discover.type.d.mts +8 -147
  19. package/api/discover/discover.type.mjs +12 -102
  20. package/api/discover/list/list.d.mts +6 -20
  21. package/api/discover/list/list.mjs +12 -45
  22. package/api/discover/list/list.test.mjs +0 -46
  23. package/api/discover/search/search.d.mts +16 -18
  24. package/api/discover/search/search.mjs +56 -102
  25. package/api/discover/search/search.test.mjs +10 -144
  26. package/api/docs/docs.test.mjs +0 -2
  27. package/api/doctor/doctor.d.mts +3 -8
  28. package/api/doctor/doctor.mjs +9 -90
  29. package/api/doctor/doctor.test.mjs +10 -122
  30. package/api/index.d.mts +2 -1
  31. package/api/index.mjs +4 -4
  32. package/api/integration/add-helpers.d.mts +2 -5
  33. package/api/integration/add-helpers.mjs +9 -36
  34. package/api/integration/pack-check.mjs +3 -28
  35. package/api/json/index.ts +1 -0
  36. package/api/layout/_adapter.d.mts +34 -0
  37. package/api/layout/_adapter.mjs +148 -0
  38. package/api/layout/check/check.d.mts +16 -0
  39. package/api/layout/check/check.mjs +40 -0
  40. package/api/layout/expand/expand.d.mts +22 -0
  41. package/api/layout/expand/expand.mjs +155 -0
  42. package/api/layout/expand/expand.path-safety.test.mjs +53 -0
  43. package/api/layout/grammar/grammar.d.mts +13 -0
  44. package/api/layout/grammar/grammar.mjs +87 -0
  45. package/api/layout/layout.d.mts +6 -0
  46. package/api/layout/layout.mjs +17 -0
  47. package/api/layout/layout.test.mjs +297 -0
  48. package/api/layout/layout.type.d.mts +89 -0
  49. package/api/layout/layout.type.mjs +103 -0
  50. package/api/layout/layoutCheck.doc.d.mts +11 -0
  51. package/api/layout/layoutCheck.doc.mjs +85 -0
  52. package/api/layout/layoutExpand.doc.d.mts +11 -0
  53. package/api/layout/layoutExpand.doc.mjs +107 -0
  54. package/api/layout/layoutGrammar.doc.d.mts +11 -0
  55. package/api/layout/layoutGrammar.doc.mjs +57 -0
  56. package/api/search/search.test.mjs +0 -18
  57. package/api/template/template-integration.test.mjs +65 -1
  58. package/api/template/template.mjs +1 -1
  59. package/api/theme/add/add.mjs +25 -17
  60. package/api/theme/add/add.staging.test.mjs +23 -40
  61. package/api/theme/build/build.family.test.mjs +12 -7
  62. package/api/theme/build/build.mjs +18 -8
  63. package/api/upgrade/run/run.mjs +4 -6
  64. package/api/upgrade/upgrade.type.mjs +2 -2
  65. package/assets/codemods/__tests__/runner.test.mjs +1 -3
  66. package/assets/codemods/integration-runner.mjs +3 -3
  67. package/assets/codemods/runner.mjs +4 -5
  68. package/assets/docs/internationalization.doc.mjs +5 -7
  69. package/assets/docs/tree/integrations.doc.mjs +1 -20
  70. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +1 -1
  71. package/authoring/config/config.doc.mjs +1 -9
  72. package/authoring/config/parse.d.mts +0 -2
  73. package/authoring/config/parse.mjs +0 -19
  74. package/authoring/config/parse.test.mjs +0 -8
  75. package/authoring/config/type.ts +2 -13
  76. package/authoring/doctypes/command/command.doc.mjs +1 -1
  77. package/authoring/doctypes/command/type.ts +1 -1
  78. package/authoring/index.d.mts +0 -1
  79. package/authoring/index.d.ts +0 -10
  80. package/authoring/index.mjs +0 -1
  81. package/clients/cli/command-result-coverage.test.mjs +7 -7
  82. package/clients/cli/commands/component/index.mjs +55 -152
  83. package/clients/cli/commands/component-ownership.test.mjs +0 -89
  84. package/clients/cli/commands/component.doc.mjs +6 -23
  85. package/clients/cli/commands/debug-result-summary.test.mjs +2 -2
  86. package/clients/cli/commands/discover.doc.mjs +9 -53
  87. package/clients/cli/commands/discover.mjs +118 -393
  88. package/clients/cli/commands/docs.test.mjs +0 -29
  89. package/clients/cli/commands/layout-check.doc.mjs +65 -0
  90. package/clients/cli/commands/layout-expand.doc.mjs +83 -0
  91. package/clients/cli/commands/layout-grammar.doc.mjs +30 -0
  92. package/clients/cli/commands/layout.doc.mjs +34 -0
  93. package/clients/cli/commands/layout.error-codes.test.mjs +66 -0
  94. package/clients/cli/commands/layout.exit-parity.test.mjs +41 -0
  95. package/clients/cli/commands/layout.mjs +275 -0
  96. package/clients/cli/commands/layout.path-help.test.mjs +33 -0
  97. package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
  98. package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
  99. package/clients/cli/commands/text-json-parity.test.mjs +17 -0
  100. package/clients/cli/index.mjs +4 -0
  101. package/clients/cli/lib/exit-codes.test.mjs +8 -1
  102. package/clients/cli/lib/json-shim.mjs +14 -24
  103. package/clients/cli/lib/json-shim.test.mjs +20 -6
  104. package/clients/cli/lib/manifest.mjs +8 -3
  105. package/clients/cli/lib/manifest.test.mjs +2 -5
  106. package/foundation/discovery/authoring-self-docs.mjs +0 -1
  107. package/foundation/discovery/template-adapter.mjs +1 -1
  108. package/foundation/doc-compiler/doc-loads.test.mjs +12 -0
  109. package/foundation/doc-compiler/tree.test.mjs +1 -9
  110. package/foundation/integrations/integrations.d.mts +1 -14
  111. package/foundation/integrations/integrations.mjs +1 -41
  112. package/foundation/integrations/integrations.test.mjs +0 -31
  113. package/foundation/response/response-types.doc.mjs +21 -15
  114. package/foundation/response/response-types.doc.test.mjs +0 -23
  115. package/foundation/xle/browser.d.mts +3 -3
  116. package/foundation/xle/browser.mjs +3 -3
  117. package/foundation/xle/expand.mjs +2 -2
  118. package/foundation/xle/parse.mjs +1 -1
  119. package/foundation/xle/print.mjs +2 -2
  120. package/foundation/xle/splice.mjs +1 -1
  121. package/package.json +9 -9
  122. package/api/discover/_adapter.test.mjs +0 -215
  123. package/api/discover/_catalog-view.d.mts +0 -115
  124. package/api/discover/_catalog-view.mjs +0 -203
  125. package/api/discover/_catalog-view.test.mjs +0 -128
  126. package/api/discover/detail/item/item.d.mts +0 -26
  127. package/api/discover/detail/item/item.mjs +0 -78
  128. package/api/discover/detail/item/item.test.mjs +0 -73
  129. package/api/integration/pack-check.lifecycle-output.test.mjs +0 -105
  130. package/api/theme/add/add.rollback.test.mjs +0 -158
  131. package/api/theme/build/build.rollback.test.mjs +0 -148
  132. package/api/upgrade/run/files-changed.test.mjs +0 -111
  133. package/assets/codemods/file-count.test.mjs +0 -163
  134. package/assets/docs/tree/component-lookups.doc.mjs +0 -149
  135. package/authoring/discover/discover.doc.d.mts +0 -13
  136. package/authoring/discover/discover.doc.mjs +0 -138
  137. package/authoring/discover/parse.d.mts +0 -24
  138. package/authoring/discover/parse.mjs +0 -128
  139. package/authoring/discover/parse.test.mjs +0 -124
  140. package/authoring/discover/type.ts +0 -87
  141. package/clients/cli/commands/component-batch.test.mjs +0 -341
  142. package/clients/cli/commands/discover.sources.test.mjs +0 -267
  143. package/clients/cli/lib/parse-error-format.test.mjs +0 -81
  144. package/foundation/response/batch.type.d.mts +0 -33
  145. package/foundation/response/batch.type.mjs +0 -34
@@ -1,138 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file SchemaDoc for DiscoverSource, the function `astryx discover` calls to
5
- * learn which integrations a project could add.
6
- * @input The DiscoverSource type and the catalog types beside it (`type.ts`),
7
- * which `parse.mjs` validates.
8
- * @output The `discover-source` section of `astryx docs authoring`.
9
- * @position packages/cli/authoring/discover — schema documentation
10
- */
11
-
12
- /** @type {import('@astryxdesign/cli/authoring').SchemaDoc} */
13
- export const doc = {
14
- type: 'schema',
15
- name: 'discover-source',
16
- displayName: 'DiscoverSource',
17
- namespace: 'authoring',
18
- description:
19
- 'A source for `astryx discover`: an async function that returns a catalog of packages a project could add, their versions, and what each version adds. Set it as `discover` in astryx.config, or export it as `discover` from an integration manifest. Discover calls every source, the project one first, and one that throws, runs past 30 seconds, or returns an invalid catalog never hides the others; discover then uses the last good answer it saved for that source. Discover only reads: it prints the command that adds a package and never runs it.',
20
- appliesTo:
21
- '`discover` in astryx.config.*, or the `discover` named export of astryx.integration.*',
22
- fields: [
23
- {
24
- name: 'context',
25
- type: 'DiscoverSourceContext',
26
- description: 'The one argument the source is called with.',
27
- required: true,
28
- fields: [
29
- {
30
- name: 'context.signal',
31
- type: 'AbortSignal',
32
- description: 'Aborted when the source runs past 30 seconds.',
33
- required: true,
34
- },
35
- {
36
- name: 'context.package',
37
- type: 'string',
38
- description:
39
- 'Set when discover shows one package: return that package with every version.',
40
- },
41
- {
42
- name: 'context.version',
43
- type: 'string',
44
- description:
45
- "With `package`: return that version's contributions. Without it, the latest release's.",
46
- },
47
- ],
48
- },
49
- {
50
- name: 'returns',
51
- type: 'Promise<DiscoverCatalog>',
52
- description:
53
- 'The catalog. Discover checks it, ignores fields and item kinds it does not know, and refuses any schemaVersion but 1.',
54
- required: true,
55
- fields: [
56
- {
57
- name: 'schemaVersion',
58
- type: '1',
59
- description: 'Version of the catalog shape.',
60
- required: true,
61
- },
62
- {
63
- name: 'source',
64
- type: '{name: string, generatedAt: string, complete: boolean}',
65
- description:
66
- 'Who answered, when the data was produced (ISO 8601), and false when the source knows its list is partial.',
67
- required: true,
68
- },
69
- {
70
- name: 'packages',
71
- type: 'DiscoverPackage[]',
72
- description:
73
- 'One entry per npm package. When two sources list the same package, the earlier source wins.',
74
- required: true,
75
- fields: [
76
- {
77
- name: 'packages[].package',
78
- type: 'string',
79
- description: 'The npm name.',
80
- required: true,
81
- },
82
- {
83
- name: 'packages[].integration',
84
- type: 'string',
85
- description:
86
- 'Shared by every npm name that publishes the same integration. Discover lists an integration once.',
87
- required: true,
88
- },
89
- {
90
- name: 'packages[].aliases',
91
- type: 'string[]',
92
- description:
93
- "The integration's other npm names. Discover never offers a package the project has under another name.",
94
- required: true,
95
- },
96
- {
97
- name: 'packages[].description',
98
- type: 'string',
99
- description: 'One line, for the list and search.',
100
- },
101
- {
102
- name: 'packages[].latest',
103
- type: 'string | null',
104
- description: 'The latest release. Null when there are only prereleases.',
105
- required: true,
106
- },
107
- {
108
- name: 'packages[].versions',
109
- type: 'DiscoverVersion[]',
110
- description:
111
- 'Every version, newest first: `{version, publishedAt, prerelease, status}`, where status is `ok` or why the version could not be read.',
112
- required: true,
113
- },
114
- {
115
- name: 'packages[].contributions',
116
- type: 'DiscoverContribution[]',
117
- description:
118
- "What the requested (else latest) version adds: `{kind, name, title?, summary?, keywords?}`, where kind is `component`, `template`, `doc`, `theme`, `codemod`, or `agent-doc` (a DiscoverKind) and name is the name the CLI uses for it.",
119
- required: true,
120
- },
121
- ],
122
- },
123
- ],
124
- },
125
- ],
126
- examples: [
127
- {
128
- label: 'A project source in astryx.config',
129
- code:
130
- 'export default {\n' +
131
- ' async discover({signal, package: name, version}) {\n' +
132
- ' const res = await fetch(catalogUrl(name, version), {signal});\n' +
133
- ' return res.json();\n' +
134
- ' },\n' +
135
- '};',
136
- },
137
- ],
138
- };
@@ -1,24 +0,0 @@
1
- // @generated by scripts/sync-api-types.mjs from the JSDoc in authoring/**/*.mjs.
2
- // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
-
4
- /**
5
- * Check a catalog a discover source returned. Throws an Error naming the first
6
- * problem. Items of a kind this CLI does not know are dropped, and versions are
7
- * put newest first whatever order the source used.
8
- *
9
- * @param {unknown} value
10
- * @param {string} [label]
11
- * @returns {import('./type.js').DiscoverCatalog}
12
- */
13
- export function parseDiscoverCatalog(value: unknown, label?: string): import("./type.js").DiscoverCatalog;
14
- /**
15
- * Check a discover source itself: an async function, like `debug`, that takes
16
- * `{signal, package?, version?}` and resolves to a catalog.
17
- *
18
- * @param {unknown} value
19
- * @param {string} label
20
- * @returns {import('./type.js').DiscoverSource}
21
- */
22
- export function parseDiscoverSource(value: unknown, label: string): import("./type.js").DiscoverSource;
23
- /** Item kinds a catalog may list, in display order. */
24
- export const DISCOVER_KINDS: readonly ["component", "template", "doc", "theme", "codemod", "agent-doc"];
@@ -1,128 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Runtime checks for discover sources and the catalogs they return.
5
- *
6
- * The catalog schema is deliberately not strict: a source may add fields this
7
- * CLI does not know, and they are dropped. An unknown `schemaVersion` is
8
- * refused, and an item of a kind this CLI does not know is skipped, so a newer
9
- * source never breaks an older CLI.
10
- *
11
- * @position packages/cli/authoring/discover — parse + validate, no I/O.
12
- */
13
-
14
- import {z} from 'zod';
15
-
16
- /** Item kinds a catalog may list, in display order. */
17
- export const DISCOVER_KINDS = /** @type {const} */ ([
18
- 'component',
19
- 'template',
20
- 'doc',
21
- 'theme',
22
- 'codemod',
23
- 'agent-doc',
24
- ]);
25
-
26
- const text = (/** @type {number} */ max) => z.string().min(1).max(max);
27
-
28
- const contributionSchema = z.object({
29
- kind: text(32),
30
- name: text(512),
31
- title: z.string().max(512).optional(),
32
- summary: z.string().max(4096).optional(),
33
- keywords: z.array(z.string().max(128)).max(64).optional(),
34
- });
35
-
36
- const versionSchema = z.object({
37
- version: text(256),
38
- publishedAt: z.string().max(64).nullable(),
39
- prerelease: z.boolean(),
40
- status: text(64),
41
- });
42
-
43
- const packageSchema = z.object({
44
- package: text(214),
45
- integration: text(214),
46
- aliases: z.array(text(214)).max(64),
47
- description: z.string().max(1024).optional(),
48
- latest: text(256).nullable(),
49
- versions: z.array(versionSchema).max(50_000),
50
- contributions: z.array(contributionSchema).max(50_000),
51
- });
52
-
53
- const catalogSchema = z.object({
54
- schemaVersion: z.literal(1),
55
- source: z.object({
56
- name: text(256),
57
- generatedAt: text(64),
58
- complete: z.boolean(),
59
- }),
60
- packages: z.array(packageSchema).max(20_000),
61
- });
62
-
63
- /**
64
- * Newest first by publish time. A version with no known publish time goes
65
- * last, and ties fall back to the version number.
66
- * @param {{version: string, publishedAt: string | null}} a
67
- * @param {{version: string, publishedAt: string | null}} b
68
- */
69
- function newestFirst(a, b) {
70
- const at = Date.parse(a.publishedAt ?? '');
71
- const bt = Date.parse(b.publishedAt ?? '');
72
- if (Number.isNaN(at) !== Number.isNaN(bt)) return Number.isNaN(at) ? 1 : -1;
73
- if (!Number.isNaN(at) && at !== bt) return bt - at;
74
- return b.version.localeCompare(a.version, 'en', {numeric: true});
75
- }
76
-
77
- /**
78
- * Check a catalog a discover source returned. Throws an Error naming the first
79
- * problem. Items of a kind this CLI does not know are dropped, and versions are
80
- * put newest first whatever order the source used.
81
- *
82
- * @param {unknown} value
83
- * @param {string} [label]
84
- * @returns {import('./type.js').DiscoverCatalog}
85
- */
86
- export function parseDiscoverCatalog(value, label = 'discover source') {
87
- const version =
88
- value != null && typeof value === 'object'
89
- ? /** @type {{schemaVersion?: unknown}} */ (value).schemaVersion
90
- : undefined;
91
- if (version !== undefined && version !== 1) {
92
- throw new Error(
93
- `${label} returned schemaVersion ${String(version)}; this CLI reads schemaVersion 1`,
94
- );
95
- }
96
- const parsed = catalogSchema.safeParse(value);
97
- if (!parsed.success) {
98
- const issue = parsed.error.issues[0];
99
- const where = issue?.path.length ? ` at ${issue.path.join('.')}` : '';
100
- throw new Error(
101
- `${label} returned an invalid catalog${where}: ${issue?.message}`,
102
- );
103
- }
104
- const known = /** @type {readonly string[]} */ (DISCOVER_KINDS);
105
- return /** @type {import('./type.js').DiscoverCatalog} */ ({
106
- ...parsed.data,
107
- packages: parsed.data.packages.map(pkg => ({
108
- ...pkg,
109
- versions: [...pkg.versions].sort(newestFirst),
110
- contributions: pkg.contributions.filter(c => known.includes(c.kind)),
111
- })),
112
- });
113
- }
114
-
115
- /**
116
- * Check a discover source itself: an async function, like `debug`, that takes
117
- * `{signal, package?, version?}` and resolves to a catalog.
118
- *
119
- * @param {unknown} value
120
- * @param {string} label
121
- * @returns {import('./type.js').DiscoverSource}
122
- */
123
- export function parseDiscoverSource(value, label) {
124
- if (typeof value !== 'function') {
125
- throw new Error(`${label} must be a function`);
126
- }
127
- return /** @type {import('./type.js').DiscoverSource} */ (value);
128
- }
@@ -1,124 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Tests for the discover source and catalog checks.
5
- */
6
-
7
- import {describe, it, expect} from 'vitest';
8
- import {
9
- DISCOVER_KINDS,
10
- parseDiscoverCatalog,
11
- parseDiscoverSource,
12
- } from './parse.mjs';
13
-
14
- function catalog(overrides = {}) {
15
- return {
16
- schemaVersion: 1,
17
- source: {
18
- name: 'Acme catalog',
19
- generatedAt: '2026-09-30T14:00:00.000Z',
20
- complete: true,
21
- },
22
- packages: [
23
- {
24
- package: '@acme/ui',
25
- integration: 'acme-ui',
26
- aliases: [],
27
- latest: '2.0.0',
28
- versions: [
29
- {
30
- version: '2.0.0',
31
- publishedAt: '2026-09-29T00:00:00.000Z',
32
- prerelease: false,
33
- status: 'ok',
34
- },
35
- ],
36
- contributions: [{kind: 'component', name: 'Button'}],
37
- },
38
- ],
39
- ...overrides,
40
- };
41
- }
42
-
43
- describe('parseDiscoverCatalog', () => {
44
- it('accepts a catalog', () => {
45
- expect(parseDiscoverCatalog(catalog())).toEqual(catalog());
46
- });
47
-
48
- it('drops fields it does not know, so a newer source still works', () => {
49
- const parsed = parseDiscoverCatalog({...catalog(), cursor: 'next'});
50
- expect(parsed).not.toHaveProperty('cursor');
51
- });
52
-
53
- it('drops items of a kind it does not know', () => {
54
- const value = catalog();
55
- value.packages[0].contributions.push({kind: 'widget', name: 'Spinner'});
56
- expect(parseDiscoverCatalog(value).packages[0].contributions).toEqual([
57
- {kind: 'component', name: 'Button'},
58
- ]);
59
- });
60
-
61
- it('puts versions newest first whatever order the source used', () => {
62
- const value = catalog();
63
- value.packages[0].versions = [
64
- {
65
- version: '1.0.0',
66
- publishedAt: '2026-01-05T00:00:00.000Z',
67
- prerelease: false,
68
- status: 'ok',
69
- },
70
- {version: '1.5.0', publishedAt: null, prerelease: false, status: 'ok'},
71
- {
72
- version: '2.0.0',
73
- publishedAt: '2026-09-29T00:00:00.000Z',
74
- prerelease: false,
75
- status: 'ok',
76
- },
77
- {
78
- version: '2.0.0-rc.1',
79
- publishedAt: '2026-09-01T00:00:00.000Z',
80
- prerelease: true,
81
- status: 'ok',
82
- },
83
- ];
84
- expect(
85
- parseDiscoverCatalog(value).packages[0].versions.map(v => v.version),
86
- ).toEqual(['2.0.0', '2.0.0-rc.1', '1.0.0', '1.5.0']);
87
- });
88
-
89
- it('refuses a schemaVersion it does not read', () => {
90
- expect(() => parseDiscoverCatalog(catalog({schemaVersion: 2}))).toThrow(
91
- 'this CLI reads schemaVersion 1',
92
- );
93
- });
94
-
95
- it('names the first problem and where it is', () => {
96
- expect(() =>
97
- parseDiscoverCatalog(catalog({packages: [{package: ''}]}), 'the source'),
98
- ).toThrow(/^the source returned an invalid catalog at packages\.0\./);
99
- });
100
-
101
- it('lists the kinds in display order', () => {
102
- expect(DISCOVER_KINDS).toEqual([
103
- 'component',
104
- 'template',
105
- 'doc',
106
- 'theme',
107
- 'codemod',
108
- 'agent-doc',
109
- ]);
110
- });
111
- });
112
-
113
- describe('parseDiscoverSource', () => {
114
- it('accepts a function', () => {
115
- const source = async () => catalog();
116
- expect(parseDiscoverSource(source, 'discover')).toBe(source);
117
- });
118
-
119
- it('refuses anything else, such as a URL', () => {
120
- expect(() =>
121
- parseDiscoverSource('https://example.com/catalog.json', 'discover'),
122
- ).toThrow('discover must be a function');
123
- });
124
- });
@@ -1,87 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * Public type surface for discover sources.
5
- *
6
- * A discover source tells `astryx discover` which integrations exist beyond the
7
- * ones a project already has. A project sets one as `discover` in
8
- * `astryx.config`; an integration exports one as a `discover` NAMED export from
9
- * its manifest. Discover calls every source, checks each answer, keeps a saved
10
- * copy of the last good one, and never installs, enables, or runs anything a
11
- * catalog names.
12
- */
13
-
14
- /** Kinds of item a package can add. */
15
- export type DiscoverKind =
16
- 'component' | 'template' | 'doc' | 'theme' | 'codemod' | 'agent-doc';
17
-
18
- /** One item a package version adds. */
19
- export interface DiscoverContribution {
20
- kind: DiscoverKind;
21
- /**
22
- * The name the CLI uses for it: a component name, template id, doc topic,
23
- * theme slug, or codemod id.
24
- */
25
- name: string;
26
- title?: string;
27
- summary?: string;
28
- keywords?: string[];
29
- }
30
-
31
- /** One published version of a package. */
32
- export interface DiscoverVersion {
33
- version: string;
34
- /** ISO 8601 publish time, or null when the source does not know it. */
35
- publishedAt: string | null;
36
- prerelease: boolean;
37
- /** `ok`, or why the source could not read this version. */
38
- status: string;
39
- }
40
-
41
- /** One npm package a source knows about. */
42
- export interface DiscoverPackage {
43
- package: string;
44
- /** Shared by every npm name that publishes the same integration. */
45
- integration: string;
46
- /** The integration's other npm names. Discover never offers one the project has. */
47
- aliases: string[];
48
- description?: string;
49
- /** The latest release, or null when the package has only prereleases. */
50
- latest: string | null;
51
- /** Every version, newest first. */
52
- versions: DiscoverVersion[];
53
- /** What the requested version adds, or the latest when none was requested. */
54
- contributions: DiscoverContribution[];
55
- }
56
-
57
- /** What a discover source returns. */
58
- export interface DiscoverCatalog {
59
- schemaVersion: 1;
60
- source: {
61
- /** Shown to people, for example "Acme catalog". */
62
- name: string;
63
- /** ISO 8601 time the source's data was produced. */
64
- generatedAt: string;
65
- /** False when the source knows its list is partial. */
66
- complete: boolean;
67
- };
68
- packages: DiscoverPackage[];
69
- }
70
-
71
- /** One call to a discover source. */
72
- export interface DiscoverSourceContext {
73
- /** Aborted when the source exceeds its 30-second budget. */
74
- readonly signal: AbortSignal;
75
- /** Asks for one package: every version, and `version`'s contributions. */
76
- readonly package?: string;
77
- /** With `package`: the version whose contributions to return. Defaults to the latest. */
78
- readonly version?: string;
79
- }
80
-
81
- /**
82
- * A discover source: an async function, like `debug`. Set it as `discover` in
83
- * astryx.config, or export it as `discover` from an integration manifest.
84
- */
85
- export type DiscoverSource = (
86
- context: DiscoverSourceContext,
87
- ) => Promise<DiscoverCatalog>;