@astryxdesign/cli 0.6.3-canary.f22695a → 0.6.3

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 (197) 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/assets/templates/blocks/components/Toolbar/ToolbarTableFilter.doc.mjs +3 -19
  61. package/assets/templates/blocks/components/Toolbar/ToolbarTableFilter.tsx +65 -383
  62. package/authoring/_shared/contract.ts +0 -22
  63. package/authoring/codemod/codemod.doc.mjs +1 -6
  64. package/authoring/codemod/parse.d.mts +8 -8
  65. package/authoring/codemod/parse.mjs +6 -8
  66. package/authoring/config/parse.d.mts +13 -13
  67. package/authoring/config/parse.mjs +8 -8
  68. package/authoring/config/type.ts +3 -3
  69. package/authoring/debug/parse.d.mts +5 -5
  70. package/authoring/debug/parse.mjs +3 -3
  71. package/authoring/doctypes/_schema.d.mts +23 -788
  72. package/authoring/doctypes/_schema.mjs +39 -492
  73. package/authoring/doctypes/base/type.ts +0 -40
  74. package/authoring/doctypes/command/command.doc.mjs +2 -3
  75. package/authoring/doctypes/command/parse.d.mts +2 -2
  76. package/authoring/doctypes/command/parse.mjs +1 -1
  77. package/authoring/doctypes/command/type.ts +2 -3
  78. package/authoring/doctypes/component/component.doc.mjs +3 -6
  79. package/authoring/doctypes/component/parse.d.mts +2 -2
  80. package/authoring/doctypes/component/parse.mjs +1 -1
  81. package/authoring/doctypes/component/type.ts +3 -4
  82. package/authoring/doctypes/enum/parse.d.mts +2 -2
  83. package/authoring/doctypes/enum/parse.mjs +1 -1
  84. package/authoring/doctypes/enum/type.ts +1 -3
  85. package/authoring/doctypes/function/function.doc.mjs +0 -4
  86. package/authoring/doctypes/function/parse.d.mts +2 -2
  87. package/authoring/doctypes/function/parse.mjs +1 -1
  88. package/authoring/doctypes/function/type.ts +2 -6
  89. package/authoring/doctypes/hook/hook.doc.mjs +0 -4
  90. package/authoring/doctypes/hook/parse.d.mts +2 -2
  91. package/authoring/doctypes/hook/parse.mjs +1 -1
  92. package/authoring/doctypes/hook/type.ts +2 -3
  93. package/authoring/doctypes/legacy.d.mts +6 -8
  94. package/authoring/doctypes/legacy.mjs +4 -5
  95. package/authoring/doctypes/parse.d.mts +18 -20
  96. package/authoring/doctypes/parse.mjs +10 -16
  97. package/authoring/doctypes/parse.test.mjs +3 -77
  98. package/authoring/doctypes/reference/parse.d.mts +2 -2
  99. package/authoring/doctypes/reference/parse.mjs +5 -8
  100. package/authoring/doctypes/reference/reference.doc.mjs +4 -17
  101. package/authoring/doctypes/reference/type.ts +5 -51
  102. package/authoring/doctypes/schema/parse.d.mts +2 -2
  103. package/authoring/doctypes/schema/parse.mjs +1 -1
  104. package/authoring/doctypes/schema/type.ts +2 -3
  105. package/authoring/doctypes/template/parse.d.mts +1 -92
  106. package/authoring/doctypes/template/parse.mjs +2 -36
  107. package/authoring/doctypes/template/parse.test.mjs +2 -8
  108. package/authoring/doctypes/template/template.doc.mjs +0 -4
  109. package/authoring/doctypes/template/type.ts +2 -5
  110. package/authoring/doctypes/types.ts +9 -10
  111. package/authoring/gap-report/parse.d.mts +10 -10
  112. package/authoring/gap-report/parse.mjs +6 -6
  113. package/authoring/gap-report/type.ts +1 -1
  114. package/authoring/index.d.mts +0 -1
  115. package/authoring/index.d.ts +17 -49
  116. package/authoring/index.mjs +0 -1
  117. package/authoring/integration/integration.doc.mjs +6 -13
  118. package/authoring/integration/parse.d.mts +2 -2
  119. package/authoring/integration/parse.mjs +1 -1
  120. package/authoring/integration/parse.test.mjs +1 -10
  121. package/authoring/integration/schema.d.mts +4 -6
  122. package/authoring/integration/schema.mjs +3 -9
  123. package/authoring/integration/type.ts +6 -23
  124. package/authoring/shadcn/receipt.d.mts +6 -6
  125. package/clients/cli/commands/docs.doc.mjs +3 -13
  126. package/clients/cli/commands/docs.mjs +21 -121
  127. package/clients/cli/commands/docs.test.mjs +0 -88
  128. package/clients/cli/commands/integration-authoring.test.mjs +9 -13
  129. package/clients/cli/commands/theme-palette-generate.doc.mjs +4 -8
  130. package/clients/cli/commands/upgrade.doc.mjs +2 -2
  131. package/clients/cli/formatters/index.mjs +1 -162
  132. package/clients/cli/formatters/index.test.mjs +0 -91
  133. package/clients/cli/lib/manifest.mjs +2 -7
  134. package/foundation/config/project.mjs +6 -21
  135. package/foundation/discovery/component-discovery.d.mts +1 -1
  136. package/foundation/discovery/component-discovery.mjs +1 -2
  137. package/foundation/discovery/docs-discovery.d.mts +4 -11
  138. package/foundation/discovery/docs-discovery.mjs +88 -208
  139. package/foundation/discovery/docs-discovery.test.mjs +13 -279
  140. package/foundation/discovery/template-adapter.mjs +1 -2
  141. package/foundation/integrations/autolink.mjs +5 -12
  142. package/foundation/integrations/integration-warnings.mjs +0 -6
  143. package/foundation/integrations/integrations.d.mts +2 -46
  144. package/foundation/integrations/integrations.mjs +8 -167
  145. package/foundation/integrations/integrations.test.mjs +1 -384
  146. package/foundation/integrations/validate-contributions.d.mts +0 -2
  147. package/foundation/integrations/validate-contributions.mjs +0 -10
  148. package/foundation/response/json-contract.test.mjs +17 -46
  149. package/foundation/response/response-types.doc.mjs +1 -6
  150. package/package.json +11 -9
  151. package/api/docs/compiled-topics.test.mjs +0 -78
  152. package/api/docs/index/index.d.mts +0 -18
  153. package/api/docs/index/index.mjs +0 -32
  154. package/api/docs/index/index.test.mjs +0 -62
  155. package/api/upgrade/project-context.test.mjs +0 -272
  156. package/assets/docs/authoring.doc.mjs +0 -14
  157. package/assets/templates/blocks/components/Timer/TimerFormats.doc.mjs +0 -14
  158. package/assets/templates/blocks/components/Timer/TimerFormats.tsx +0 -34
  159. package/assets/templates/blocks/components/Timer/TimerInline.doc.mjs +0 -14
  160. package/assets/templates/blocks/components/Timer/TimerInline.tsx +0 -14
  161. package/assets/templates/blocks/components/Timer/TimerShowcase.doc.mjs +0 -13
  162. package/assets/templates/blocks/components/Timer/TimerShowcase.tsx +0 -47
  163. package/assets/templates/blocks/components/Timer/TimerTypography.doc.mjs +0 -14
  164. package/assets/templates/blocks/components/Timer/TimerTypography.tsx +0 -31
  165. package/authoring/doctypes/base/graph-fields.doc.d.mts +0 -9
  166. package/authoring/doctypes/base/graph-fields.doc.mjs +0 -62
  167. package/authoring/doctypes/load-contract.test.mjs +0 -207
  168. package/authoring/doctypes/namespace/namespace.doc.d.mts +0 -9
  169. package/authoring/doctypes/namespace/namespace.doc.mjs +0 -132
  170. package/authoring/doctypes/namespace/parse.d.mts +0 -12
  171. package/authoring/doctypes/namespace/parse.mjs +0 -25
  172. package/authoring/doctypes/namespace/parse.test.mjs +0 -165
  173. package/authoring/doctypes/namespace/type.ts +0 -71
  174. package/authoring/identity/identity.doc.d.mts +0 -9
  175. package/authoring/identity/identity.doc.mjs +0 -61
  176. package/authoring/identity/type.ts +0 -132
  177. package/foundation/discovery/authoring-self-docs.d.mts +0 -69
  178. package/foundation/discovery/authoring-self-docs.mjs +0 -214
  179. package/foundation/discovery/authoring-self-docs.test.mjs +0 -154
  180. package/foundation/discovery/docs-output-budget.d.mts +0 -28
  181. package/foundation/discovery/docs-output-budget.mjs +0 -50
  182. package/foundation/discovery/docs-section-key.d.mts +0 -98
  183. package/foundation/discovery/docs-section-key.mjs +0 -221
  184. package/foundation/discovery/docs-section-key.test.mjs +0 -224
  185. package/foundation/doc-compiler/compile.d.mts +0 -162
  186. package/foundation/doc-compiler/compile.mjs +0 -262
  187. package/foundation/doc-compiler/doc-compiler.test.mjs +0 -687
  188. package/foundation/doc-compiler/ir.d.mts +0 -9
  189. package/foundation/doc-compiler/ir.mjs +0 -287
  190. package/foundation/doc-compiler/lenses.d.mts +0 -33
  191. package/foundation/doc-compiler/lenses.mjs +0 -127
  192. package/foundation/identity/provider-identity.d.mts +0 -90
  193. package/foundation/identity/provider-identity.mjs +0 -320
  194. package/foundation/identity/provider-identity.test.mjs +0 -254
  195. package/foundation/identity/providers.d.mts +0 -7
  196. package/foundation/identity/providers.mjs +0 -16
  197. package/foundation/integrations/provider-conflicts.test.mjs +0 -125
@@ -1,262 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Doc compiler — authored reference topics in, compiled nodes out.
5
- *
6
- * @input A {@link ReferenceTopicInput}: one topic's own file and the files of
7
- * the extensions merged onto it, each already through the authored-doc parser
8
- * and each carrying the overlay for the language being read. Discovery
9
- * assembles it, and records a file that failed to load instead of throwing,
10
- * so problems surface here in the order a reader meets them.
11
- * @output A compiled reference node: plain JSON carrying a schema version, the
12
- * topic after overlay, extension merge and key stamping, and the authored
13
- * title of every section. Linking then resolves each token reference against
14
- * its target. Nothing in a node is a function, a symbol, or a file path: an
15
- * authored value JSON cannot hold (a function, a Date, `undefined`) takes its
16
- * JSON form, the one `--json` output has always shown.
17
- * @position The one step between authored docs and every docs reader. The docs
18
- * API, doctor and search read compiled nodes, and ./lenses.mjs turns them into
19
- * response shapes. Internal to the CLI: the public way in is `docs()`.
20
- */
21
-
22
- import {mergeTopic, problemsInTopic} from '../discovery/docs-discovery.mjs';
23
- import {
24
- sectionKey,
25
- sectionKeyProblems,
26
- sourceTitle,
27
- withSectionKeys,
28
- withSourceTitle,
29
- } from '../discovery/docs-section-key.mjs';
30
-
31
- /** Bumped whenever the shape of a compiled node changes. */
32
- export const COMPILED_DOC_SCHEMA_VERSION = 1;
33
-
34
- /**
35
- * One authored file, as discovery loaded it.
36
- * @typedef {object} AuthoredFile
37
- * @property {string} file the file's name, for messages only
38
- * @property {any} [doc] the parsed doc, when it loaded
39
- * @property {unknown} [error] why it did not load or parse
40
- * @property {any} [overlay] the language overlay's export, when one applies
41
- * @property {unknown} [overlayError] why the overlay did not load
42
- */
43
-
44
- /**
45
- * @typedef {object} ReferenceTopicInput
46
- * @property {string} id the topic's name in the catalog
47
- * @property {string} provider the package that owns the topic
48
- * @property {string | null} replaces the topic it took the place of
49
- * @property {string | null} lang the overlay language, or null for authored text
50
- * @property {AuthoredFile} base
51
- * @property {Array<AuthoredFile & {provider: string}>} extensions in merge order
52
- */
53
-
54
- /**
55
- * A token reference after linking: the target section's content, or why it
56
- * has none.
57
- * @typedef {{status: 'resolved', topic: string, section: string, previewType?: string, content: any[]}
58
- * | {status: 'unknown-topic'}
59
- * | {status: 'unknown-section'}} TokenRefResolution
60
- */
61
-
62
- /**
63
- * @typedef {object} CompiledReferenceNode
64
- * @property {number} schemaVersion
65
- * @property {'reference'} kind
66
- * @property {'lowered' | 'linked'} stage `linked` once every token reference
67
- * carries its resolution; a lowered node carries none
68
- * @property {string} id the topic's name in the catalog
69
- * @property {string | null} lang
70
- * @property {{provider: string, replaces: string | null, extensions: string[]}} provenance
71
- * @property {Record<string, string>} sourceTitles section key -> authored title
72
- * @property {any} doc the topic: authored fields in authored order, every
73
- * section keyed; a linked node's token references carry `resolved`
74
- */
75
-
76
- /**
77
- * Lower one topic: overlay each file, merge the extensions in order, and stamp
78
- * every section with its key.
79
- * @param {ReferenceTopicInput} input
80
- * @returns {CompiledReferenceNode}
81
- */
82
- export function lowerReferenceTopic(input) {
83
- let doc = readAuthoredFile(input.base);
84
- for (const extension of input.extensions) {
85
- doc = mergeTopic(doc, readAuthoredFile(extension));
86
- // Merging matches on keys, so this holds unless merge itself regresses.
87
- const problems = sectionKeyProblems(doc.sections);
88
- if (problems.length > 0) {
89
- throw new Error(
90
- `${extension.file}, extending ${input.id}, leaves two sections with one key: ${problems.join('; ')}`,
91
- );
92
- }
93
- }
94
- // Derived keys are stamped only now, so they never take part in merging.
95
- const keyed = withSectionKeys(doc);
96
- /** @type {Record<string, string>} */
97
- const sourceTitles = {};
98
- for (const section of keyed.sections) {
99
- sourceTitles[section.id] = sourceTitle(section);
100
- }
101
- return {
102
- schemaVersion: COMPILED_DOC_SCHEMA_VERSION,
103
- kind: 'reference',
104
- stage: 'lowered',
105
- id: input.id,
106
- lang: input.lang,
107
- provenance: {
108
- provider: input.provider,
109
- replaces: input.replaces,
110
- extensions: input.extensions.map(extension => extension.provider),
111
- },
112
- sourceTitles,
113
- // The authored title travels in sourceTitles; JSON drops the symbol.
114
- doc: asJson(keyed, input.id),
115
- };
116
- }
117
-
118
- /**
119
- * Link every section of a lowered node.
120
- * @param {CompiledReferenceNode} node
121
- * @param {(topic: string) => Promise<CompiledReferenceNode | null>} lowerTarget
122
- * the lowered node a reference names, or null when no topic has that name
123
- * @returns {Promise<CompiledReferenceNode>}
124
- */
125
- export async function linkReferenceTopic(node, lowerTarget) {
126
- const sections = [];
127
- for (const section of node.doc.sections) {
128
- sections.push(await linkReferenceSection(section, lowerTarget));
129
- }
130
- return {...node, stage: 'linked', doc: {...node.doc, sections}};
131
- }
132
-
133
- /**
134
- * Resolve the token references in one section. A section with none comes back
135
- * as it went in.
136
- * @template {{content: any[]}} S
137
- * @param {S} section
138
- * @param {(topic: string) => Promise<CompiledReferenceNode | null>} lowerTarget
139
- * @returns {Promise<S>}
140
- */
141
- export async function linkReferenceSection(section, lowerTarget) {
142
- if (!section.content.some(block => block?.type === 'token-ref')) {
143
- return section;
144
- }
145
- const content = [];
146
- for (const block of section.content) {
147
- content.push(
148
- block?.type === 'token-ref'
149
- ? {...block, resolved: await resolveTokenRef(block, lowerTarget)}
150
- : block,
151
- );
152
- }
153
- return {...section, content};
154
- }
155
-
156
- /**
157
- * The section a token reference names — by key, or by authored title in any
158
- * letter case — in the target topic lowered for the same language.
159
- * @param {any} block
160
- * @param {(topic: string) => Promise<CompiledReferenceNode | null>} lowerTarget
161
- * @returns {Promise<TokenRefResolution>}
162
- */
163
- async function resolveTokenRef(block, lowerTarget) {
164
- const target = await lowerTarget(block.topic);
165
- if (!target) return {status: 'unknown-topic'};
166
- const wanted = block.section.toLowerCase();
167
- const found = target.doc.sections.find(
168
- (/** @type {any} */ section) =>
169
- sectionKey(section) === block.section ||
170
- (target.sourceTitles[section.id] ?? section.title).toLowerCase() ===
171
- wanted,
172
- );
173
- if (!found) return {status: 'unknown-section'};
174
- return {
175
- status: 'resolved',
176
- topic: target.id,
177
- section: found.id,
178
- ...(found.previewType ? {previewType: found.previewType} : {}),
179
- content: found.content,
180
- };
181
- }
182
-
183
- /**
184
- * A value as JSON carries it: functions, symbols and `undefined` dropped,
185
- * Dates as ISO strings.
186
- * @param {any} value
187
- * @param {string} topic for the message when the value cannot be serialized
188
- * @returns {any}
189
- */
190
- function asJson(value, topic) {
191
- try {
192
- return JSON.parse(JSON.stringify(value));
193
- } catch (err) {
194
- throw new Error(
195
- `${topic} cannot be compiled: ${err instanceof Error ? err.message : String(err)}`,
196
- {cause: err},
197
- );
198
- }
199
- }
200
-
201
- /**
202
- * One file's doc, checked and in the reading language. Problems throw in the
203
- * order a reader meets them: the file itself, then its overlay.
204
- * @param {AuthoredFile} file
205
- * @returns {any}
206
- */
207
- function readAuthoredFile(file) {
208
- if ('error' in file) throw file.error;
209
- const parsed = file.doc;
210
- if (!('sections' in parsed)) {
211
- throw new Error(`${file.file} is not a reference document.`);
212
- }
213
- const problems = problemsInTopic(parsed);
214
- if (problems.length > 0) {
215
- throw new Error(`${file.file} is invalid: ${problems.join('; ')}`);
216
- }
217
- if ('overlayError' in file) throw file.overlayError;
218
- return file.overlay ? applyOverlay(parsed, file.overlay) : parsed;
219
- }
220
-
221
- /**
222
- * Lay a translation over a doc. Overlays are keyed to a base section by title
223
- * (`section`), not by array position: position keying grafted each overlay
224
- * title onto whatever base section shared its index, so an overlay that omitted
225
- * or reordered a section corrupted every section after it (#2182). An overlay
226
- * may cover any subset of sections, in any order; the rest keep their base
227
- * content.
228
- * @param {any} docs
229
- * @param {any} translation
230
- * @returns {any}
231
- */
232
- function applyOverlay(docs, translation) {
233
- /** @type {Map<string, any>} */
234
- const bySection = new Map();
235
- for (const ts of translation.sections ?? []) {
236
- if (ts?.section != null) bySection.set(ts.section, ts);
237
- }
238
- return {
239
- ...docs,
240
- description: translation.description || docs.description,
241
- sections: docs.sections.map((/** @type {any} */ section) => {
242
- const ts = bySection.get(section.title);
243
- if (!ts) return section;
244
- const localized = {
245
- ...section,
246
- title: ts.title || section.title,
247
- content: section.content.map(
248
- (/** @type {any} */ block, /** @type {number} */ bi) => {
249
- const tb = ts.content?.[bi];
250
- if (!tb) return block;
251
- if (tb.type === 'prose' && block.type === 'prose')
252
- return {...block, text: tb.text};
253
- if (tb.type === 'list' && block.type === 'list')
254
- return {...block, items: tb.items};
255
- return block;
256
- },
257
- ),
258
- };
259
- return withSourceTitle(localized, section.title);
260
- }),
261
- };
262
- }