@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,287 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file The compiled-node contract and its sealed parser.
5
- *
6
- * @input Any value that claims to be a compiled reference node — typically one
7
- * read back from JSON.
8
- * @output The same value once it validates; a thrown Error naming the problems
9
- * otherwise. An unsupported schema version fails with its own message before
10
- * anything else is checked.
11
- * @position The load boundary for compiled nodes that did not come straight
12
- * from ./compile.mjs in this process. The value is returned as given, not
13
- * rebuilt, so key order (which response JSON follows) survives. A node is
14
- * plain JSON throughout, so nothing it holds can surprise a reader.
15
- */
16
-
17
- import {SECTION_KEY_RE} from '../discovery/docs-section-key.mjs';
18
- import {COMPILED_DOC_SCHEMA_VERSION} from './compile.mjs';
19
-
20
- const NODE_FIELDS = new Set([
21
- 'schemaVersion',
22
- 'kind',
23
- 'stage',
24
- 'id',
25
- 'lang',
26
- 'provenance',
27
- 'sourceTitles',
28
- 'doc',
29
- ]);
30
- const RESOLVED_FIELDS = new Set([
31
- 'status',
32
- 'topic',
33
- 'section',
34
- 'previewType',
35
- 'content',
36
- ]);
37
-
38
- /** How many problems one message lists before it stops. */
39
- const MAX_PROBLEMS = 10;
40
-
41
- /** @param {unknown} value @returns {value is Record<string, any>} */
42
- const isRecord = value =>
43
- value != null && typeof value === 'object' && !Array.isArray(value);
44
-
45
- /** @param {unknown} value @returns {value is string} */
46
- const isText = value => typeof value === 'string' && value !== '';
47
-
48
- /**
49
- * A package name, never a location: provenance must not leak a path.
50
- * @param {unknown} value
51
- * @returns {boolean}
52
- */
53
- const isPackageName = value =>
54
- isText(value) &&
55
- !value.startsWith('/') &&
56
- !value.startsWith('.') &&
57
- !value.startsWith('\\') &&
58
- !value.startsWith('file:') &&
59
- !/^[A-Za-z]:[\\/]/.test(value);
60
-
61
- /**
62
- * Validate a compiled reference node.
63
- * @param {unknown} value
64
- * @returns {import('./compile.mjs').CompiledReferenceNode}
65
- */
66
- export function parseCompiledReferenceNode(value) {
67
- const node = /** @type {any} */ (value);
68
- if (node?.schemaVersion !== COMPILED_DOC_SCHEMA_VERSION) {
69
- throw new Error(
70
- `Compiled doc schema version ${JSON.stringify(node?.schemaVersion)} is not supported; this CLI reads version ${COMPILED_DOC_SCHEMA_VERSION}. Compile the docs again with this CLI.`,
71
- );
72
- }
73
- const problems = jsonProblems(node, 'node');
74
- if (problems.length === 0) problems.push(...structureProblems(node));
75
- if (problems.length > 0) {
76
- throw new Error(
77
- `Invalid compiled doc node: ${problems.slice(0, MAX_PROBLEMS).join('; ')}`,
78
- );
79
- }
80
- return node;
81
- }
82
-
83
- /**
84
- * Where a value stops being plain JSON: anything but null, booleans, finite
85
- * numbers, strings, arrays and plain objects; a symbol key; or a cycle.
86
- * @param {unknown} value
87
- * @param {string} at
88
- * @param {Set<object>} [ancestors]
89
- * @param {string[]} [out]
90
- * @returns {string[]}
91
- */
92
- function jsonProblems(value, at, ancestors = new Set(), out = []) {
93
- if (out.length >= MAX_PROBLEMS) return out;
94
- if (
95
- value === null ||
96
- typeof value === 'string' ||
97
- typeof value === 'boolean'
98
- ) {
99
- return out;
100
- }
101
- if (typeof value === 'number') {
102
- if (!Number.isFinite(value))
103
- out.push(`${at}: ${value} is not a JSON number`);
104
- return out;
105
- }
106
- if (value === undefined) {
107
- out.push(`${at}: undefined is not JSON`);
108
- return out;
109
- }
110
- if (typeof value !== 'object') {
111
- out.push(`${at}: a ${typeof value} is not JSON`);
112
- return out;
113
- }
114
- if (ancestors.has(value)) {
115
- out.push(`${at}: refers back to itself`);
116
- return out;
117
- }
118
- const proto = Object.getPrototypeOf(value);
119
- if (!Array.isArray(value) && proto !== Object.prototype && proto !== null) {
120
- out.push(
121
- `${at}: a ${proto?.constructor?.name ?? 'non-plain object'} is not JSON`,
122
- );
123
- return out;
124
- }
125
- if (Object.getOwnPropertySymbols(value).length > 0) {
126
- out.push(`${at}: has symbol keys`);
127
- }
128
- ancestors.add(value);
129
- if (Array.isArray(value)) {
130
- value.forEach((item, index) =>
131
- jsonProblems(item, `${at}[${index}]`, ancestors, out),
132
- );
133
- } else {
134
- for (const [key, item] of Object.entries(value)) {
135
- jsonProblems(item, `${at}.${key}`, ancestors, out);
136
- }
137
- }
138
- ancestors.delete(value);
139
- return out;
140
- }
141
-
142
- /**
143
- * The node's own shape, once it is known to be JSON.
144
- * @param {Record<string, any>} node
145
- * @returns {string[]}
146
- */
147
- function structureProblems(node) {
148
- /** @type {string[]} */
149
- const problems = [];
150
- const unknown = Object.keys(node).filter(key => !NODE_FIELDS.has(key));
151
- if (unknown.length > 0)
152
- problems.push(`unknown fields: ${unknown.join(', ')}`);
153
- if (node.kind !== 'reference') problems.push('kind: expected "reference"');
154
- if (node.stage !== 'lowered' && node.stage !== 'linked') {
155
- problems.push('stage: expected "lowered" or "linked"');
156
- }
157
- if (!isText(node.id)) problems.push('id: expected a topic name');
158
- if (node.lang !== null && !isText(node.lang)) {
159
- problems.push('lang: expected a language or null');
160
- }
161
- const provenance = node.provenance;
162
- if (
163
- !isRecord(provenance) ||
164
- !isPackageName(provenance.provider) ||
165
- (provenance.replaces !== null && !isText(provenance.replaces)) ||
166
- !Array.isArray(provenance.extensions) ||
167
- !provenance.extensions.every(isPackageName)
168
- ) {
169
- problems.push(
170
- 'provenance: expected {provider, replaces, extensions} naming packages, not paths',
171
- );
172
- }
173
- const titles = isRecord(node.sourceTitles) ? node.sourceTitles : null;
174
- if (!titles || !Object.values(titles).every(isText)) {
175
- problems.push('sourceTitles: expected section key -> authored title');
176
- }
177
- const doc = node.doc;
178
- if (
179
- !isRecord(doc) ||
180
- !isText(doc.name) ||
181
- !isText(doc.title) ||
182
- typeof doc.description !== 'string' ||
183
- !Array.isArray(doc.sections) ||
184
- doc.sections.length === 0
185
- ) {
186
- problems.push('doc: expected {name, title, description, sections}');
187
- } else {
188
- problems.push(...sectionProblems(doc.sections, titles, node.stage));
189
- }
190
- return problems;
191
- }
192
-
193
- /**
194
- * @param {any[]} sections
195
- * @param {Record<string, any> | null} titles
196
- * @param {unknown} stage
197
- * @returns {string[]}
198
- */
199
- function sectionProblems(sections, titles, stage) {
200
- /** @type {string[]} */
201
- const problems = [];
202
- const seen = new Set();
203
- sections.forEach((section, index) => {
204
- const at = `doc.sections[${index}]`;
205
- if (
206
- !isRecord(section) ||
207
- typeof section.id !== 'string' ||
208
- !SECTION_KEY_RE.test(section.id)
209
- ) {
210
- problems.push(`${at}.id: expected a section key`);
211
- return;
212
- }
213
- if (seen.has(section.id)) {
214
- problems.push(`${at}.id: two sections have the key "${section.id}"`);
215
- }
216
- seen.add(section.id);
217
- if (!isText(section.title)) problems.push(`${at}.title: expected a title`);
218
- if (titles && !Object.hasOwn(titles, section.id)) {
219
- problems.push(
220
- `sourceTitles: no authored title for section "${section.id}"`,
221
- );
222
- }
223
- if (!Array.isArray(section.content)) {
224
- problems.push(`${at}.content: expected an array of blocks`);
225
- return;
226
- }
227
- section.content.forEach((/** @type {unknown} */ block, blockIndex) => {
228
- const where = `${at}.content[${blockIndex}]`;
229
- if (!isRecord(block) || !isText(block.type)) {
230
- problems.push(`${where}: expected a block with a type`);
231
- return;
232
- }
233
- if (block.type !== 'token-ref') return;
234
- const ref = `${where}: token reference to "${block.topic}"`;
235
- if (stage === 'lowered') {
236
- if ('resolved' in block) {
237
- problems.push(`${ref}: a lowered node carries no resolution`);
238
- }
239
- return;
240
- }
241
- if (!('resolved' in block)) {
242
- problems.push(`${ref}: a linked node resolves every reference`);
243
- return;
244
- }
245
- const problem = resolutionProblem(block.resolved);
246
- if (problem) problems.push(`${ref}: ${problem}`);
247
- });
248
- });
249
- return problems;
250
- }
251
-
252
- /**
253
- * @param {unknown} resolved
254
- * @returns {string | null}
255
- */
256
- function resolutionProblem(resolved) {
257
- if (!isRecord(resolved)) return 'expected a resolution';
258
- switch (resolved.status) {
259
- case 'unknown-topic':
260
- case 'unknown-section':
261
- return Object.keys(resolved).length === 1 ? null : 'unexpected fields';
262
- case 'resolved': {
263
- if (!isText(resolved.topic)) return 'topic: expected a topic name';
264
- if (
265
- typeof resolved.section !== 'string' ||
266
- !SECTION_KEY_RE.test(resolved.section)
267
- ) {
268
- return 'section: expected a section key';
269
- }
270
- if ('previewType' in resolved && !isText(resolved.previewType)) {
271
- return 'previewType: expected a preview type';
272
- }
273
- if (
274
- !Array.isArray(resolved.content) ||
275
- !resolved.content.every(block => isRecord(block) && isText(block.type))
276
- ) {
277
- return 'content: expected blocks with a type';
278
- }
279
- const extra = Object.keys(resolved).filter(
280
- key => !RESOLVED_FIELDS.has(key),
281
- );
282
- return extra.length > 0 ? `unexpected fields: ${extra.join(', ')}` : null;
283
- }
284
- default:
285
- return `status: expected resolved, unknown-topic or unknown-section, got ${JSON.stringify(resolved.status)}`;
286
- }
287
- }
@@ -1,33 +0,0 @@
1
- // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
- // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
-
4
- /**
5
- * The node's sections as readers look them up: each one knows its authored
6
- * title, so a query in the authoring language finds a translated section.
7
- * For lookup only; a section a reader gets back comes from
8
- * {@link sectionView}.
9
- * @param {import('./compile.mjs').CompiledReferenceNode} node
10
- * @returns {any[]}
11
- */
12
- export function readerSections(node: import("./compile.mjs").CompiledReferenceNode): any[];
13
- /**
14
- * `docs.detail`: the whole topic, with every token reference inlined.
15
- * @param {import('./compile.mjs').CompiledReferenceNode} node a linked node
16
- * @returns {any}
17
- */
18
- export function detailView(node: import("./compile.mjs").CompiledReferenceNode): any;
19
- /**
20
- * `docs.index`: what the topic is, and each section's key, title and summary.
21
- * @param {import('./compile.mjs').CompiledReferenceNode} node
22
- * @returns {import('../../api/docs/docs.type.mjs').DocsIndex}
23
- */
24
- export function indexView(node: import("./compile.mjs").CompiledReferenceNode): import("../../api/docs/docs.type.mjs").DocsIndex;
25
- /**
26
- * `docs.detail.section`: one section with its token references inlined. A
27
- * referenced section's content takes the reference's place; the section takes
28
- * the preview type of the last reference that has one, unless it has its own.
29
- * @param {import('./compile.mjs').CompiledReferenceNode} node
30
- * @param {any} section a linked section of `node`
31
- * @returns {any}
32
- */
33
- export function sectionView(node: import("./compile.mjs").CompiledReferenceNode, section: any): any;
@@ -1,127 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Lenses — the docs API's response shapes, read off compiled nodes.
5
- *
6
- * @input A compiled reference node from ./compile.mjs: lowered for the index
7
- * and for section lookup, linked for anything that inlines token references.
8
- * @output The `docs.detail` topic, the `docs.index` section index, one
9
- * `docs.detail.section` section, and the sections as readers look them up.
10
- * Every view is a fresh copy, so a reader may edit what it gets back without
11
- * touching the node, which other reads of the same catalog share.
12
- * @position Between the compiler and api/docs. A lens only projects: it never
13
- * loads, merges, overlays, keys, or resolves a reference itself.
14
- */
15
-
16
- import {
17
- buildDocsIndexData,
18
- withSourceTitle,
19
- } from '../discovery/docs-section-key.mjs';
20
-
21
- /**
22
- * @param {import('./compile.mjs').CompiledReferenceNode} node
23
- * @param {any} section
24
- * @returns {string}
25
- */
26
- function authoredTitle(node, section) {
27
- return node.sourceTitles[section.id] ?? section.title;
28
- }
29
-
30
- /**
31
- * The node's sections as readers look them up: each one knows its authored
32
- * title, so a query in the authoring language finds a translated section.
33
- * For lookup only; a section a reader gets back comes from
34
- * {@link sectionView}.
35
- * @param {import('./compile.mjs').CompiledReferenceNode} node
36
- * @returns {any[]}
37
- */
38
- export function readerSections(node) {
39
- return node.doc.sections.map((/** @type {any} */ section) =>
40
- withSourceTitle({...section}, authoredTitle(node, section)),
41
- );
42
- }
43
-
44
- /**
45
- * `docs.detail`: the whole topic, with every token reference inlined.
46
- * @param {import('./compile.mjs').CompiledReferenceNode} node a linked node
47
- * @returns {any}
48
- */
49
- export function detailView(node) {
50
- if (node.stage !== 'linked') {
51
- throw new Error(
52
- `"${node.id}" must be linked before its whole doc is read.`,
53
- );
54
- }
55
- // Assigning `sections` keeps it where the authored doc put it.
56
- const view = structuredClone({...node.doc, sections: []});
57
- view.sections = node.doc.sections.map((/** @type {any} */ section) =>
58
- sectionView(node, section),
59
- );
60
- return view;
61
- }
62
-
63
- /**
64
- * `docs.index`: what the topic is, and each section's key, title and summary.
65
- * @param {import('./compile.mjs').CompiledReferenceNode} node
66
- * @returns {import('../../api/docs/docs.type.mjs').DocsIndex}
67
- */
68
- export function indexView(node) {
69
- return buildDocsIndexData(node.doc);
70
- }
71
-
72
- /**
73
- * `docs.detail.section`: one section with its token references inlined. A
74
- * referenced section's content takes the reference's place; the section takes
75
- * the preview type of the last reference that has one, unless it has its own.
76
- * @param {import('./compile.mjs').CompiledReferenceNode} node
77
- * @param {any} section a linked section of `node`
78
- * @returns {any}
79
- */
80
- export function sectionView(node, section) {
81
- /** @type {any[]} */
82
- const content = [];
83
- /** @type {string | null} */
84
- let previewType = null;
85
- for (const block of section.content) {
86
- if (block?.type !== 'token-ref') {
87
- content.push(structuredClone(block));
88
- continue;
89
- }
90
- const target = block.resolved;
91
- if (target == null) {
92
- throw new Error(
93
- `The token reference to "${block.topic}" in "${node.id}" was read before it was linked.`,
94
- );
95
- }
96
- if (target.status === 'unknown-topic') {
97
- content.push({
98
- type: 'prose',
99
- text: `[token-ref: unknown topic "${block.topic}"]`,
100
- });
101
- continue;
102
- }
103
- if (target.status === 'unknown-section') {
104
- content.push({
105
- type: 'prose',
106
- text: `[token-ref: section "${block.section}" not found in "${block.topic}"]`,
107
- });
108
- continue;
109
- }
110
- // A copy per reference: two references to one section share nothing.
111
- for (const refBlock of target.content) {
112
- content.push(structuredClone(refBlock));
113
- }
114
- if (target.previewType && !section.previewType) {
115
- previewType = target.previewType;
116
- }
117
- }
118
- // Assigning `content` keeps it where the section put it; a carried preview
119
- // type lands after the section's own keys, as it always has.
120
- const view = structuredClone(
121
- previewType == null
122
- ? {...section, content: []}
123
- : {...section, previewType, content: []},
124
- );
125
- view.content = content;
126
- return withSourceTitle(view, authoredTitle(node, section));
127
- }
@@ -1,90 +0,0 @@
1
- // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
- // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
-
4
- /**
5
- * Normalize an npm package name into a ProviderId.
6
- * @param {string} packageName
7
- * @returns {ProviderId}
8
- */
9
- export function normalizeProviderId(packageName: string): ProviderId;
10
- /**
11
- * Normalize a SHA-256 digest.
12
- * @param {string} digest
13
- * @returns {ContentDigest}
14
- */
15
- export function normalizeContentDigest(digest: string): ContentDigest;
16
- /**
17
- * Build a stable provider + contribution kind + artifact-name ID.
18
- * @param {string} provider
19
- * @param {ContributionKind} kind
20
- * @param {string} name
21
- * @returns {ArtifactId}
22
- */
23
- export function createArtifactId(provider: string, kind: ContributionKind, name: string): ArtifactId;
24
- /**
25
- * Build a stable document ID from provider + authored kind + stable name.
26
- * @param {string} provider
27
- * @param {AuthoredDocKind} kind
28
- * @param {string} name
29
- * @returns {DocId}
30
- */
31
- export function createDocId(provider: string, kind: AuthoredDocKind, name: string): DocId;
32
- /**
33
- * Build a normalized logical artifact record.
34
- * @param {string} provider
35
- * @param {ContributionKind} kind
36
- * @param {string} name
37
- * @returns {ArtifactIdentity}
38
- */
39
- export function createArtifactIdentity(provider: string, kind: ContributionKind, name: string): ArtifactIdentity;
40
- /**
41
- * Parse and canonicalize an ArtifactId.
42
- * @param {string} value
43
- * @returns {ArtifactIdentity}
44
- */
45
- export function parseArtifactId(value: string): ArtifactIdentity;
46
- /**
47
- * Build one immutable provider instance.
48
- * @param {{providerId: string, packageName: string, packageVersion: string, sourceDigest: string}} input
49
- * @returns {ProviderInstance}
50
- */
51
- export function createProviderInstance(input: {
52
- providerId: string;
53
- packageName: string;
54
- packageVersion: string;
55
- sourceDigest: string;
56
- }): ProviderInstance;
57
- /**
58
- * Bind one validated authored document to immutable provider and source
59
- * provenance. Runtime lifecycle state is intentionally absent.
60
- * @param {{
61
- * provider: ProviderInstance,
62
- * kind: AuthoredDocKind,
63
- * stableName: string,
64
- * source: {group: string, path: string, digest: string},
65
- * authored: AuthoredDoc,
66
- * }} input
67
- * @returns {AuthoredDocEntry}
68
- */
69
- export function createAuthoredDocEntry(input: {
70
- provider: ProviderInstance;
71
- kind: AuthoredDocKind;
72
- stableName: string;
73
- source: {
74
- group: string;
75
- path: string;
76
- digest: string;
77
- };
78
- authored: AuthoredDoc;
79
- }): AuthoredDocEntry;
80
- export type ArtifactId = import("../../authoring/identity/type").ArtifactId;
81
- export type ArtifactIdentity = import("../../authoring/identity/type").ArtifactIdentity;
82
- export type AuthoredDoc = import("../../authoring/identity/type").AuthoredDoc;
83
- export type AuthoredDocEntry = import("../../authoring/identity/type").AuthoredDocEntry;
84
- export type AuthoredDocKind = import("../../authoring/doctypes/base/type").AuthoredDocKind;
85
- export type ContentDigest = import("../../authoring/identity/type").ContentDigest;
86
- export type ContributionKind = import("../../authoring/identity/type").ContributionKind;
87
- export type DocId = import("../../authoring/identity/type").DocId;
88
- export type ProviderId = import("../../authoring/identity/type").ProviderId;
89
- export type ProviderInstance = import("../../authoring/identity/type").ProviderInstance;
90
- export type ProviderInstanceId = import("../../authoring/identity/type").ProviderInstanceId;