@astryxdesign/cli 0.6.3-canary.e073c9f → 0.6.3-canary.ea2f048

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 (188) hide show
  1. package/README.md +1 -2
  2. package/api/build/build.type.d.mts +2 -2
  3. package/api/build/build.type.mjs +2 -2
  4. package/api/component/component.type.d.mts +6 -6
  5. package/api/component/component.type.mjs +19 -19
  6. package/api/discover/discover.type.d.mts +4 -4
  7. package/api/discover/discover.type.mjs +10 -10
  8. package/api/docs/_adapter.d.mts +24 -37
  9. package/api/docs/_adapter.mjs +83 -169
  10. package/api/docs/detail/detail.mjs +63 -14
  11. package/api/docs/detail/section/section.d.mts +1 -1
  12. package/api/docs/detail/section/section.mjs +20 -44
  13. package/api/docs/detail/section/section.test.mjs +0 -41
  14. package/api/docs/docs.d.mts +2 -7
  15. package/api/docs/docs.doc.mjs +10 -27
  16. package/api/docs/docs.mjs +9 -16
  17. package/api/docs/docs.test.mjs +0 -6
  18. package/api/docs/docs.type.d.mts +3 -40
  19. package/api/docs/docs.type.mjs +8 -36
  20. package/api/docs/integrationDocs.test.mjs +0 -106
  21. package/api/doctor/doctor.d.mts +0 -48
  22. package/api/doctor/doctor.mjs +0 -232
  23. package/api/doctor/doctor.test.mjs +0 -196
  24. package/api/hook/hook.type.d.mts +3 -3
  25. package/api/hook/hook.type.mjs +11 -11
  26. package/api/hook/list/list.d.mts +1 -1
  27. package/api/integration/add-contribution.mjs +3 -5
  28. package/api/integration/add-contribution.test.mjs +4 -4
  29. package/api/integration/integration-authoring.type.d.mts +1 -1
  30. package/api/integration/pack-check.mjs +7 -49
  31. package/api/integration/pack-check.test.mjs +0 -249
  32. package/api/search/search.d.mts +1 -1
  33. package/api/search/search.mjs +5 -5
  34. package/api/search/search.type.d.mts +2 -2
  35. package/api/search/search.type.mjs +1 -1
  36. package/api/swizzle/swizzle.type.d.mts +2 -2
  37. package/api/swizzle/swizzle.type.mjs +2 -2
  38. package/api/template/template.d.mts +1 -1
  39. package/api/template/template.type.d.mts +6 -6
  40. package/api/template/template.type.mjs +12 -12
  41. package/api/theme/build/build.mjs +6 -20
  42. package/api/theme/build/build.test.mjs +0 -127
  43. package/api/theme/palette/generate/generate.mjs +1 -1
  44. package/api/theme/palette/generate/generator.d.mts +13 -10
  45. package/api/theme/palette/generate/generator.mjs +3 -7
  46. package/api/theme/theme.type.d.mts +11 -170
  47. package/api/theme/theme.type.mjs +27 -94
  48. package/api/upgrade/_adapter.mjs +5 -71
  49. package/api/upgrade/upgrade.doc.mjs +3 -4
  50. package/api/upgrade/upgrade.type.d.mts +5 -5
  51. package/api/upgrade/upgrade.type.mjs +11 -11
  52. package/assets/codemods/integration-discovery.mjs +2 -40
  53. package/assets/codemods/integration-discovery.test.mjs +0 -58
  54. package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +5 -27
  55. package/assets/codemods/transforms/v0.3.0/unwrap-authoring-factories.mjs +5 -20
  56. package/assets/docs/README.md +0 -9
  57. package/assets/docs/cli-integrations.doc.mjs +15 -86
  58. package/assets/docs/styling-libraries.doc.mjs +1 -1
  59. package/assets/docs/working-with-ai.doc.mjs +1 -1
  60. package/authoring/_shared/contract.ts +0 -22
  61. package/authoring/codemod/codemod.doc.mjs +1 -6
  62. package/authoring/codemod/parse.d.mts +8 -8
  63. package/authoring/codemod/parse.mjs +6 -8
  64. package/authoring/config/parse.d.mts +13 -13
  65. package/authoring/config/parse.mjs +8 -8
  66. package/authoring/config/type.ts +3 -3
  67. package/authoring/debug/parse.d.mts +5 -5
  68. package/authoring/debug/parse.mjs +3 -3
  69. package/authoring/doctypes/_schema.d.mts +23 -788
  70. package/authoring/doctypes/_schema.mjs +39 -492
  71. package/authoring/doctypes/base/type.ts +0 -40
  72. package/authoring/doctypes/command/command.doc.mjs +2 -3
  73. package/authoring/doctypes/command/parse.d.mts +2 -2
  74. package/authoring/doctypes/command/parse.mjs +1 -1
  75. package/authoring/doctypes/command/type.ts +2 -3
  76. package/authoring/doctypes/component/component.doc.mjs +3 -6
  77. package/authoring/doctypes/component/parse.d.mts +2 -2
  78. package/authoring/doctypes/component/parse.mjs +1 -1
  79. package/authoring/doctypes/component/type.ts +3 -4
  80. package/authoring/doctypes/enum/parse.d.mts +2 -2
  81. package/authoring/doctypes/enum/parse.mjs +1 -1
  82. package/authoring/doctypes/enum/type.ts +1 -3
  83. package/authoring/doctypes/function/function.doc.mjs +0 -4
  84. package/authoring/doctypes/function/parse.d.mts +2 -2
  85. package/authoring/doctypes/function/parse.mjs +1 -1
  86. package/authoring/doctypes/function/type.ts +2 -6
  87. package/authoring/doctypes/hook/hook.doc.mjs +0 -4
  88. package/authoring/doctypes/hook/parse.d.mts +2 -2
  89. package/authoring/doctypes/hook/parse.mjs +1 -1
  90. package/authoring/doctypes/hook/type.ts +2 -3
  91. package/authoring/doctypes/legacy.d.mts +6 -8
  92. package/authoring/doctypes/legacy.mjs +4 -5
  93. package/authoring/doctypes/parse.d.mts +18 -20
  94. package/authoring/doctypes/parse.mjs +10 -16
  95. package/authoring/doctypes/parse.test.mjs +3 -77
  96. package/authoring/doctypes/reference/parse.d.mts +2 -2
  97. package/authoring/doctypes/reference/parse.mjs +5 -8
  98. package/authoring/doctypes/reference/reference.doc.mjs +4 -17
  99. package/authoring/doctypes/reference/type.ts +5 -51
  100. package/authoring/doctypes/schema/parse.d.mts +2 -2
  101. package/authoring/doctypes/schema/parse.mjs +1 -1
  102. package/authoring/doctypes/schema/type.ts +2 -3
  103. package/authoring/doctypes/template/parse.d.mts +1 -92
  104. package/authoring/doctypes/template/parse.mjs +2 -36
  105. package/authoring/doctypes/template/parse.test.mjs +2 -8
  106. package/authoring/doctypes/template/template.doc.mjs +0 -4
  107. package/authoring/doctypes/template/type.ts +2 -5
  108. package/authoring/doctypes/types.ts +9 -10
  109. package/authoring/gap-report/parse.d.mts +10 -10
  110. package/authoring/gap-report/parse.mjs +6 -6
  111. package/authoring/gap-report/type.ts +1 -1
  112. package/authoring/index.d.mts +0 -1
  113. package/authoring/index.d.ts +17 -49
  114. package/authoring/index.mjs +0 -1
  115. package/authoring/integration/integration.doc.mjs +6 -13
  116. package/authoring/integration/parse.d.mts +2 -2
  117. package/authoring/integration/parse.mjs +1 -1
  118. package/authoring/integration/parse.test.mjs +1 -10
  119. package/authoring/integration/schema.d.mts +4 -6
  120. package/authoring/integration/schema.mjs +3 -9
  121. package/authoring/integration/type.ts +6 -23
  122. package/authoring/shadcn/receipt.d.mts +6 -6
  123. package/clients/cli/commands/docs.doc.mjs +3 -13
  124. package/clients/cli/commands/docs.mjs +21 -121
  125. package/clients/cli/commands/docs.test.mjs +0 -88
  126. package/clients/cli/commands/integration-authoring.test.mjs +9 -13
  127. package/clients/cli/commands/theme-palette-generate.doc.mjs +4 -8
  128. package/clients/cli/commands/upgrade.doc.mjs +2 -2
  129. package/clients/cli/formatters/index.mjs +1 -162
  130. package/clients/cli/formatters/index.test.mjs +0 -91
  131. package/clients/cli/lib/manifest.mjs +2 -7
  132. package/foundation/config/project.mjs +6 -21
  133. package/foundation/discovery/component-discovery.d.mts +1 -1
  134. package/foundation/discovery/component-discovery.mjs +1 -2
  135. package/foundation/discovery/docs-discovery.d.mts +4 -11
  136. package/foundation/discovery/docs-discovery.mjs +88 -208
  137. package/foundation/discovery/docs-discovery.test.mjs +13 -279
  138. package/foundation/discovery/template-adapter.mjs +1 -2
  139. package/foundation/discovery/theming-targets.test.mjs +0 -4
  140. package/foundation/integrations/autolink.mjs +5 -12
  141. package/foundation/integrations/integration-warnings.mjs +0 -6
  142. package/foundation/integrations/integrations.d.mts +2 -46
  143. package/foundation/integrations/integrations.mjs +8 -167
  144. package/foundation/integrations/integrations.test.mjs +1 -384
  145. package/foundation/integrations/validate-contributions.d.mts +0 -2
  146. package/foundation/integrations/validate-contributions.mjs +0 -10
  147. package/foundation/response/json-contract.test.mjs +17 -46
  148. package/foundation/response/response-types.doc.mjs +1 -6
  149. package/package.json +11 -9
  150. package/api/docs/compiled-topics.test.mjs +0 -78
  151. package/api/docs/index/index.d.mts +0 -18
  152. package/api/docs/index/index.mjs +0 -32
  153. package/api/docs/index/index.test.mjs +0 -62
  154. package/api/upgrade/project-context.test.mjs +0 -272
  155. package/assets/docs/authoring.doc.mjs +0 -14
  156. package/authoring/doctypes/base/graph-fields.doc.d.mts +0 -9
  157. package/authoring/doctypes/base/graph-fields.doc.mjs +0 -62
  158. package/authoring/doctypes/load-contract.test.mjs +0 -207
  159. package/authoring/doctypes/namespace/namespace.doc.d.mts +0 -9
  160. package/authoring/doctypes/namespace/namespace.doc.mjs +0 -132
  161. package/authoring/doctypes/namespace/parse.d.mts +0 -12
  162. package/authoring/doctypes/namespace/parse.mjs +0 -25
  163. package/authoring/doctypes/namespace/parse.test.mjs +0 -165
  164. package/authoring/doctypes/namespace/type.ts +0 -71
  165. package/authoring/identity/identity.doc.d.mts +0 -9
  166. package/authoring/identity/identity.doc.mjs +0 -61
  167. package/authoring/identity/type.ts +0 -132
  168. package/foundation/discovery/authoring-self-docs.d.mts +0 -69
  169. package/foundation/discovery/authoring-self-docs.mjs +0 -214
  170. package/foundation/discovery/authoring-self-docs.test.mjs +0 -154
  171. package/foundation/discovery/docs-output-budget.d.mts +0 -28
  172. package/foundation/discovery/docs-output-budget.mjs +0 -50
  173. package/foundation/discovery/docs-section-key.d.mts +0 -98
  174. package/foundation/discovery/docs-section-key.mjs +0 -221
  175. package/foundation/discovery/docs-section-key.test.mjs +0 -224
  176. package/foundation/doc-compiler/compile.d.mts +0 -162
  177. package/foundation/doc-compiler/compile.mjs +0 -262
  178. package/foundation/doc-compiler/doc-compiler.test.mjs +0 -687
  179. package/foundation/doc-compiler/ir.d.mts +0 -9
  180. package/foundation/doc-compiler/ir.mjs +0 -287
  181. package/foundation/doc-compiler/lenses.d.mts +0 -33
  182. package/foundation/doc-compiler/lenses.mjs +0 -127
  183. package/foundation/identity/provider-identity.d.mts +0 -90
  184. package/foundation/identity/provider-identity.mjs +0 -320
  185. package/foundation/identity/provider-identity.test.mjs +0 -254
  186. package/foundation/identity/providers.d.mts +0 -7
  187. package/foundation/identity/providers.mjs +0 -16
  188. package/foundation/integrations/provider-conflicts.test.mjs +0 -125
@@ -1,9 +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
- * @file SchemaDoc for graph metadata shared by every authored doc kind.
6
- * @position packages/cli/authoring/doctypes/base — doc-type documentation
7
- */
8
- /** @type {import('@astryxdesign/cli/authoring').SchemaDoc} */
9
- export const doc: import("@astryxdesign/cli/authoring").SchemaDoc;
@@ -1,62 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file SchemaDoc for graph metadata shared by every authored doc kind.
5
- * @position packages/cli/authoring/doctypes/base — doc-type documentation
6
- */
7
-
8
- /** @type {import('@astryxdesign/cli/authoring').SchemaDoc} */
9
- export const doc = {
10
- type: 'schema',
11
- name: 'authored-doc-graph-fields',
12
- displayName: 'Authored doc graph fields',
13
- namespace: 'authoring',
14
- description:
15
- 'Placement, compatibility aliases, and audience: fields every authored doc kind declares for the docs graph. The docs graph is not built yet, so nothing reads them: a reference topic that sets one fails to load, and other doc kinds accept them and ignore them.',
16
- appliesTo: 'Every supported .doc.mjs object',
17
- fields: [
18
- {
19
- name: 'placement',
20
- type: 'DocPlacement',
21
- description:
22
- 'Requests one canonical parent in the docs graph. Not read yet: a topic that sets it fails to load.',
23
- fields: [
24
- {
25
- name: 'placement.parent',
26
- type: 'string',
27
- description: 'Stable reference to the requested parent namespace.',
28
- required: true,
29
- },
30
- {
31
- name: 'placement.slot',
32
- type: 'string',
33
- description: 'Named slot owned by the parent namespace.',
34
- },
35
- {
36
- name: 'placement.order',
37
- type: 'number',
38
- description: 'Integer sibling order within the slot.',
39
- },
40
- ],
41
- },
42
- {
43
- name: 'aliases',
44
- type: 'string[]',
45
- description:
46
- 'Prior names or routes the docs graph will keep resolving to this doc, without creating another identity. Not read yet: a topic that sets it fails to load.',
47
- },
48
- {
49
- name: 'audience',
50
- type: "'public' | 'internal'",
51
- description:
52
- "Which docs bundle includes this doc ('public' when omitted). Not read yet: a topic that sets it fails to load.",
53
- default: "'public'",
54
- },
55
- ],
56
- notes: [
57
- {
58
- type: 'prose',
59
- text: 'Unknown fields: `component`, `function`, `generic`, `schema`, `command` and `enum` docs accept a field they do not know, and nothing reads it, so a doc written for a newer CLI still loads here. `page`, `block` and `namespace` docs refuse one. Sections and content blocks refuse one in every doc.',
60
- },
61
- ],
62
- };
@@ -1,207 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Every authored doc kind has a compile-time lock between its load check
5
- * and its published type: the `_*DriftLock` typedefs in `_schema.mjs` and
6
- * `template/parse.mjs`, which the strict typecheck evaluates. A lock names each
7
- * place the loader is deliberately looser than the type. These tests pin that
8
- * looser behavior and the published unknown-field policy, so tightening a load
9
- * check is a reviewed change rather than a silent one.
10
- */
11
-
12
- import * as fs from 'node:fs';
13
- import * as path from 'node:path';
14
- import {fileURLToPath, pathToFileURL} from 'node:url';
15
- import {describe, expect, it} from 'vitest';
16
- import {parseDoc} from './parse.mjs';
17
- import {AuthoredDocKindSchema} from './_schema.mjs';
18
- import {doc as graphFieldsDoc} from './base/graph-fields.doc.mjs';
19
- import {problemsInTopic} from '../../foundation/discovery/docs-discovery.mjs';
20
-
21
- const HERE = path.dirname(fileURLToPath(import.meta.url));
22
- const KINDS = AuthoredDocKindSchema.options;
23
-
24
- /** The lock that pins each kind's load check to its published type. */
25
- const LOCKS = {
26
- component: '_ComponentDocDriftLock',
27
- function: '_FunctionDocDriftLock',
28
- generic: '_ReferenceDocDriftLock',
29
- page: '_PageTemplateDocDriftLock',
30
- block: '_BlockTemplateDocDriftLock',
31
- schema: '_SchemaDocDriftLock',
32
- command: '_CommandDocDriftLock',
33
- enum: '_EnumDocDriftLock',
34
- namespace: '_NamespaceDocDriftLock',
35
- };
36
-
37
- /** One valid example doc per kind, from the typed examples. */
38
- const EXAMPLES = Object.fromEntries(
39
- await Promise.all(
40
- KINDS.map(async kind => {
41
- const file = {generic: 'reference', function: 'function'}[kind] ?? kind;
42
- const url = pathToFileURL(
43
- path.join(HERE, '../../test/authoring-types', `${file}.doc.mjs`),
44
- );
45
- return [kind, (await import(url.href)).docs];
46
- }),
47
- ),
48
- );
49
-
50
- describe('load check vs published type', () => {
51
- it('locks every doc kind', () => {
52
- const source = ['_schema.mjs', 'template/parse.mjs']
53
- .map(file => fs.readFileSync(path.join(HERE, file), 'utf8'))
54
- .join('\n');
55
- expect(Object.keys(LOCKS).sort()).toEqual([...KINDS].sort());
56
- const locks = [
57
- ...Object.values(LOCKS),
58
- '_AuthoredDocKindDriftLock',
59
- '_HookDocIsFunctionDocLock',
60
- ];
61
- for (const lock of locks) {
62
- expect(source, `${lock} is missing`).toMatch(
63
- new RegExp(`\\}\\s*${lock}\\b`),
64
- );
65
- }
66
- });
67
-
68
- it('dispatches every doc kind and refuses any other', () => {
69
- for (const kind of KINDS) {
70
- expect(() => parseDoc(EXAMPLES[kind], `${kind}.doc.mjs`)).not.toThrow();
71
- }
72
- expect(() => parseDoc({type: 'widget', name: 'x'}, 'x.doc.mjs')).toThrow(
73
- /unsupported type "widget"/,
74
- );
75
- });
76
- });
77
-
78
- describe('where loading is deliberately looser than the type', () => {
79
- it('a stamped component needs no displayName; usage, theming and examples are unchecked', () => {
80
- expect(() =>
81
- parseDoc(
82
- {
83
- type: 'component',
84
- name: 'Badge',
85
- category: 'badges',
86
- props: [],
87
- usage: 'free text',
88
- theming: 5,
89
- examples: [{title: 'Basic'}],
90
- },
91
- 'Badge.doc.mjs',
92
- ),
93
- ).not.toThrow();
94
- });
95
-
96
- it('each entry of a stamped group doc needs a name, and nothing more', () => {
97
- const group = (/** @type {unknown[]} */ components) => ({
98
- type: 'component',
99
- name: 'Tabs',
100
- components,
101
- });
102
- expect(() =>
103
- parseDoc(
104
- group([{name: 'Tab'}, {name: 'TabPanel', description: 'x'}]),
105
- 'Tabs.doc.mjs',
106
- ),
107
- ).not.toThrow();
108
- for (const bad of [null, 5, 'Tab', {}, {name: ''}, {displayName: 'Tab'}]) {
109
- expect(() => parseDoc(group([bad]), 'Tabs.doc.mjs')).toThrow(
110
- /components\.0/,
111
- );
112
- }
113
- });
114
-
115
- it('a stamped function needs no displayName; usage is unchecked', () => {
116
- expect(() =>
117
- parseDoc(
118
- {type: 'function', name: 'useX', params: [], returns: [], usage: 5},
119
- 'useX.doc.mjs',
120
- ),
121
- ).not.toThrow();
122
- });
123
-
124
- it('a stamped generic doc loads without title, description or sections, but is no topic', () => {
125
- const doc = parseDoc({type: 'generic', name: 'notes'}, 'notes.doc.mjs');
126
- expect(doc.title).toBe('notes');
127
- expect(problemsInTopic(doc)).toEqual([
128
- 'description: expected a non-empty string',
129
- 'sections: expected at least one section',
130
- ]);
131
- });
132
-
133
- it('a template needs no displayName or aspectRatio and may use its own category', () => {
134
- expect(() =>
135
- parseDoc(
136
- {type: 'block', name: 'widget-demo', category: 'components/Widget'},
137
- 'widget-demo.doc.mjs',
138
- ),
139
- ).not.toThrow();
140
- expect(() =>
141
- parseDoc(
142
- {type: 'page', name: 'widget-page', category: 'Widgets'},
143
- 'widget-page.doc.mjs',
144
- ),
145
- ).not.toThrow();
146
- });
147
-
148
- it('schema, command and enum docs load only as their type allows', () => {
149
- const {fields, ...schemaDoc} = EXAMPLES.schema;
150
- const {summary, ...commandDoc} = EXAMPLES.command;
151
- const {members, ...enumDoc} = EXAMPLES.enum;
152
- expect(() => parseDoc(schemaDoc, 's.doc.mjs')).toThrow(/fields/);
153
- expect(() => parseDoc(commandDoc, 'c.doc.mjs')).toThrow(/summary/);
154
- expect(() => parseDoc(enumDoc, 'e.doc.mjs')).toThrow(/members/);
155
- });
156
- });
157
-
158
- describe('unknown fields', () => {
159
- const keeps = KINDS.filter(kind => {
160
- try {
161
- parseDoc({...EXAMPLES[kind], notAField: true}, `${kind}.doc.mjs`);
162
- return true;
163
- } catch {
164
- return false;
165
- }
166
- });
167
-
168
- it('match the published policy', () => {
169
- const policy = graphFieldsDoc.notes
170
- .map(note => ('text' in note ? note.text : ''))
171
- .find(text => text.startsWith('Unknown fields'));
172
- expect(policy, 'graph-fields.doc.mjs states the policy').toBeDefined();
173
- const [kept, refused] = /** @type {string} */ (policy).split(
174
- ' docs accept',
175
- );
176
- const named = (/** @type {string} */ text) =>
177
- [...text.matchAll(/`([a-z]+)`/g)].map(match => match[1]).sort();
178
- expect(named(kept)).toEqual([...keeps].sort());
179
- expect(named(refused).filter(kind => KINDS.includes(kind))).toEqual(
180
- KINDS.filter(kind => !keeps.includes(kind)).sort(),
181
- );
182
- });
183
-
184
- it('are refused inside sections and content blocks', () => {
185
- const [section] = EXAMPLES.generic.sections;
186
- expect(() =>
187
- parseDoc(
188
- {...EXAMPLES.generic, sections: [{...section, notAField: true}]},
189
- 'r.doc.mjs',
190
- ),
191
- ).toThrow();
192
- expect(() =>
193
- parseDoc(
194
- {
195
- ...EXAMPLES.generic,
196
- sections: [
197
- {
198
- ...section,
199
- content: [{type: 'prose', text: 'x', notAField: true}],
200
- },
201
- ],
202
- },
203
- 'r.doc.mjs',
204
- ),
205
- ).toThrow();
206
- });
207
- });
@@ -1,9 +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
- * @file SchemaDoc for NamespaceDoc, the authored hierarchy and layout owner.
6
- * @position packages/cli/authoring/doctypes/namespace — doc-type documentation
7
- */
8
- /** @type {import('@astryxdesign/cli/authoring').SchemaDoc} */
9
- export const doc: import("@astryxdesign/cli/authoring").SchemaDoc;
@@ -1,132 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file SchemaDoc for NamespaceDoc, the authored hierarchy and layout owner.
5
- * @position packages/cli/authoring/doctypes/namespace — doc-type documentation
6
- */
7
-
8
- /** @type {import('@astryxdesign/cli/authoring').SchemaDoc} */
9
- export const doc = {
10
- type: 'schema',
11
- name: 'namespace-doc',
12
- displayName: 'NamespaceDoc',
13
- namespace: 'authoring',
14
- description:
15
- "Declares named navigation slots and renderer-neutral layout blocks for already-discovered docs. It never scans folders or copies child documents. Not loaded yet: only the docs graph reads namespace docs, and it is not built, so keep them out of an integration's docs directory for now.",
16
- appliesTo: '<namespace>.doc.mjs',
17
- fields: [
18
- {
19
- name: 'type',
20
- type: "'namespace'",
21
- description: 'Doc-kind discriminant.',
22
- required: true,
23
- },
24
- {
25
- name: 'name',
26
- type: 'string',
27
- description:
28
- 'Stable provider-local identity. Moving the namespace does not change this value.',
29
- required: true,
30
- },
31
- {
32
- name: 'title',
33
- type: 'string',
34
- description: 'Human-readable page title.',
35
- required: true,
36
- },
37
- {
38
- name: 'summary',
39
- type: 'string',
40
- description: 'One-line summary used in listings and search results.',
41
- required: true,
42
- },
43
- {
44
- name: 'placement',
45
- type: 'DocPlacement',
46
- description:
47
- 'Optional canonical parent request: {parent, slot?, order?}. Invalid explicit placement will fail compilation instead of falling back.',
48
- },
49
- {
50
- name: 'aliases',
51
- type: 'string[]',
52
- description:
53
- 'Prior names or routes the docs graph will keep resolving to this doc.',
54
- },
55
- {
56
- name: 'audience',
57
- type: "'public' | 'internal'",
58
- description: "Bundle audience. Defaults to 'public'.",
59
- default: "'public'",
60
- },
61
- {
62
- name: 'keywords',
63
- type: 'string[]',
64
- description: 'Search terms not already present in the title or summary.',
65
- },
66
- {
67
- name: 'slots',
68
- type: 'Record<string, NamespaceSlot>',
69
- description:
70
- 'Named placement and collection targets. Each slot declares a title and accepted doc kinds; configured providers require an explicit extension slot.',
71
- required: true,
72
- },
73
- {
74
- name: 'adopts',
75
- type: 'NamespaceAdoptionRule[]',
76
- description:
77
- 'Provider-local rules that adopt otherwise-unplaced docs from a logical discovery group. They never scan a folder.',
78
- },
79
- {
80
- name: 'blocks',
81
- type: 'ReferenceContentBlock[]',
82
- description:
83
- 'Ordered layout content. V1 adds only workflow, collection, and reference to the existing prose, heading, code, table, list, and token-ref blocks.',
84
- },
85
- ],
86
- examples: [
87
- {
88
- label: 'A CLI namespace with one adopted source group',
89
- code: `/** @type {import('@astryxdesign/cli/authoring').NamespaceDoc} */
90
- export const docs = {
91
- type: 'namespace',
92
- name: 'cli',
93
- title: 'Astryx CLI',
94
- summary: 'Commands, APIs, and integration authoring.',
95
- slots: {
96
- guides: {title: 'Guides', accepts: {kinds: ['namespace', 'generic']}},
97
- reference: {
98
- title: 'Reference',
99
- accepts: {kinds: ['namespace', 'command']},
100
- },
101
- },
102
- adopts: [{
103
- source: {group: 'cli-commands', kinds: ['command']},
104
- into: 'reference',
105
- }],
106
- blocks: [
107
- {type: 'collection', source: {slot: 'guides'}, presentation: 'cards'},
108
- {type: 'collection', source: {slot: 'reference'}, presentation: 'compact'},
109
- ],
110
- };`,
111
- },
112
- ],
113
- notes: [
114
- {
115
- type: 'prose',
116
- text: "Namespace docs are not loaded yet. Only the docs graph reads them, and it is not built. A namespace doc in an integration's docs directory fails to load as a topic, and with it every topic that package contributes, until the file is removed.",
117
- },
118
- {
119
- type: 'prose',
120
- text: 'Child docs request one canonical home with placement. Collections store and render stable references to those docs; they never create a second identity or parent.',
121
- },
122
- {
123
- type: 'list',
124
- style: 'dont',
125
- items: [
126
- 'Use a directory as implicit navigation.',
127
- 'Put JSX, HTML, ANSI, callbacks, or custom renderer code in a doc.',
128
- 'Use choice, callout, or checklist blocks before the full block-extension contract exists.',
129
- ],
130
- },
131
- ],
132
- };
@@ -1,12 +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
- /** @typedef {import('../types.js').NamespaceDoc} NamespaceDoc */
5
- /**
6
- * Validate an unknown value as a NamespaceDoc, or throw a readable error.
7
- * @param {unknown} input
8
- * @param {string} [label]
9
- * @returns {NamespaceDoc}
10
- */
11
- export function parseNamespace(input: unknown, label?: string): NamespaceDoc;
12
- export type NamespaceDoc = import("../types.js").NamespaceDoc;
@@ -1,25 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Namespace doc parser. Zod is sealed in `../_schema.mjs`; consumers call
5
- * `parseNamespace` or use `parseDoc`.
6
- */
7
-
8
- import {NamespaceDocKindSchema} from '../_schema.mjs';
9
- import {formatZodError} from '../../_shared/errors.mjs';
10
-
11
- /** @typedef {import('../types.js').NamespaceDoc} NamespaceDoc */
12
-
13
- /**
14
- * Validate an unknown value as a NamespaceDoc, or throw a readable error.
15
- * @param {unknown} input
16
- * @param {string} [label]
17
- * @returns {NamespaceDoc}
18
- */
19
- export function parseNamespace(input, label = 'namespace doc') {
20
- const result = NamespaceDocKindSchema.safeParse(input);
21
- if (!result.success) {
22
- throw new Error(formatZodError(label, result.error));
23
- }
24
- return result.data;
25
- }
@@ -1,165 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- import {describe, expect, it} from 'vitest';
4
- import {parseDoc, parseNamespace, parseReference} from '../../index.mjs';
5
-
6
- const namespaceDoc = {
7
- type: 'namespace',
8
- name: 'integrations',
9
- title: 'Author integrations',
10
- summary: 'Publish reusable Astryx packages.',
11
- aliases: ['cli-integrations'],
12
- placement: {parent: 'namespace:cli', slot: 'guides', order: 10},
13
- slots: {
14
- contributions: {
15
- title: 'What do you want to publish?',
16
- accepts: {kinds: ['namespace']},
17
- },
18
- providerGuides: {
19
- title: 'Provider guidance',
20
- accepts: {providers: 'configured', kinds: ['generic', 'schema']},
21
- },
22
- },
23
- adopts: [
24
- {
25
- source: {group: 'cli-api', kinds: ['function', 'schema', 'enum']},
26
- into: 'contributions',
27
- groupBy: 'kind',
28
- },
29
- ],
30
- blocks: [
31
- {
32
- type: 'workflow',
33
- title: 'Package lifecycle',
34
- steps: [
35
- {title: 'Add', references: ['command:integration-add']},
36
- {
37
- title: 'Validate',
38
- references: ['command:doctor-integration-validate'],
39
- },
40
- ],
41
- },
42
- {
43
- type: 'collection',
44
- source: {slot: 'contributions'},
45
- presentation: 'cards',
46
- },
47
- {
48
- type: 'reference',
49
- target: 'schema:integration',
50
- projection: {fields: ['components', 'docs']},
51
- },
52
- ],
53
- };
54
-
55
- describe('NamespaceDoc', () => {
56
- it('accepts the reviewed plain-object shape through both parsers', () => {
57
- expect(parseNamespace(namespaceDoc)).toEqual(namespaceDoc);
58
- expect(parseDoc(namespaceDoc)).toEqual(namespaceDoc);
59
- });
60
-
61
- it('reports stable nested field paths', () => {
62
- expect(() =>
63
- parseNamespace({
64
- ...namespaceDoc,
65
- blocks: [{type: 'workflow', steps: [{title: ''}]}],
66
- }),
67
- ).toThrow(/blocks\.0\.steps\.0\.title/u);
68
- });
69
-
70
- it.each(['choice', 'callout', 'checklist'])(
71
- 'rejects unsupported %s blocks',
72
- type => {
73
- expect(() => parseNamespace({...namespaceDoc, blocks: [{type}]})).toThrow(
74
- /blocks\.0\.type/u,
75
- );
76
- },
77
- );
78
-
79
- it('rejects misspelled fields instead of silently dropping them', () => {
80
- expect(() =>
81
- parseNamespace({...namespaceDoc, summmary: 'misspelled'}),
82
- ).toThrow(/summmary/u);
83
- });
84
-
85
- it('requires at least one declared slot', () => {
86
- expect(() => parseNamespace({...namespaceDoc, slots: {}})).toThrow(
87
- /at least one slot is required/u,
88
- );
89
- });
90
-
91
- it('rejects a collection that names an undeclared slot', () => {
92
- expect(() =>
93
- parseNamespace({
94
- ...namespaceDoc,
95
- blocks: [{type: 'collection', source: {slot: 'missing'}}],
96
- }),
97
- ).toThrow(/blocks\.0\.source\.slot.*declared slot/u);
98
- });
99
-
100
- it('rejects an adoption rule that names an undeclared slot', () => {
101
- expect(() =>
102
- parseNamespace({
103
- ...namespaceDoc,
104
- adopts: [{source: {group: 'cli-api'}, into: 'missing'}],
105
- }),
106
- ).toThrow(/adopts\.0\.into.*declared slot/u);
107
- });
108
-
109
- it('rejects an adoption rule whose generated kind is not accepted', () => {
110
- expect(() =>
111
- parseNamespace({
112
- ...namespaceDoc,
113
- adopts: [
114
- {
115
- source: {group: 'cli-api', kinds: ['command']},
116
- into: 'providerGuides',
117
- groupBy: 'kind',
118
- },
119
- ],
120
- }),
121
- ).toThrow(/does not accept adopted kind "namespace"/u);
122
-
123
- expect(() =>
124
- parseNamespace({
125
- ...namespaceDoc,
126
- adopts: [
127
- {
128
- source: {group: 'cli-api', kinds: ['command']},
129
- into: 'providerGuides',
130
- },
131
- ],
132
- }),
133
- ).toThrow(/does not accept adopted kind "command"/u);
134
- });
135
- });
136
-
137
- describe('semantic blocks in existing docs', () => {
138
- it('accepts workflow, collection, and reference in a ReferenceDoc section', () => {
139
- const parsed = parseReference({
140
- type: 'generic',
141
- name: 'publishing',
142
- title: 'Publishing',
143
- description: 'Publish an integration.',
144
- sections: [
145
- {
146
- id: 'start',
147
- title: 'Start',
148
- content: namespaceDoc.blocks,
149
- },
150
- ],
151
- });
152
- expect(parsed.sections[0].id).toBe('start');
153
- expect(parsed.sections[0].content.map(block => block.type)).toEqual([
154
- 'workflow',
155
- 'collection',
156
- 'reference',
157
- ]);
158
- });
159
-
160
- it('rejects an unknown stamped doc kind instead of treating it as legacy', () => {
161
- expect(() => parseDoc({type: 'choice', name: 'x', props: []})).toThrow(
162
- /unsupported type "choice"/u,
163
- );
164
- });
165
- });