@astryxdesign/cli 0.6.3-canary.29be688 → 0.6.3-canary.2bb99ed

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 (62) hide show
  1. package/README.md +2 -0
  2. package/api/docs/detail/section/section.mjs +9 -15
  3. package/api/docs/detail/section/section.test.mjs +15 -6
  4. package/api/doctor/doctor.mjs +1 -1
  5. package/api/doctor/doctor.test.mjs +6 -6
  6. package/api/upgrade/_adapter.d.mts +22 -4
  7. package/api/upgrade/_adapter.mjs +19 -6
  8. package/api/upgrade/run/run.mjs +355 -59
  9. package/api/upgrade/upgrade.doc.mjs +5 -1
  10. package/api/upgrade/upgrade.type.d.mts +34 -0
  11. package/api/upgrade/upgrade.type.mjs +15 -0
  12. package/assets/codemods/__tests__/runner.test.mjs +330 -8
  13. package/assets/codemods/integration-runner.mjs +56 -4
  14. package/assets/codemods/integration-runner.protection.test.mjs +153 -0
  15. package/assets/codemods/run-codemod.mjs +177 -34
  16. package/assets/codemods/runner.mjs +248 -110
  17. package/assets/codemods/transforms/next/__tests__/migrate-native-picker-to-presentation.test.mjs +63 -0
  18. package/assets/codemods/transforms/next/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +4 -0
  19. package/assets/codemods/transforms/next/index.mjs +8 -0
  20. package/assets/codemods/transforms/next/migrate-native-picker-to-presentation.mjs +148 -0
  21. package/assets/docs/cli-integrations.doc.mjs +13 -0
  22. package/assets/templates/blocks/components/DateInput/DateInputDateRange.tsx +1 -1
  23. package/assets/templates/blocks/components/Item/ItemDocumentTabs.doc.mjs +14 -0
  24. package/assets/templates/blocks/components/Item/ItemDocumentTabs.tsx +100 -0
  25. package/assets/templates/blocks/components/TimeInput/TimeInputConstrained.tsx +1 -0
  26. package/authoring/codemod/type.ts +12 -0
  27. package/authoring/doctypes/_schema.d.mts +71 -141
  28. package/authoring/doctypes/_schema.mjs +29 -2
  29. package/authoring/doctypes/load-contract.test.mjs +1 -1
  30. package/authoring/doctypes/namespace/namespace.doc.mjs +2 -2
  31. package/authoring/doctypes/namespace/parse.test.mjs +23 -25
  32. package/authoring/doctypes/namespace/type.ts +5 -2
  33. package/authoring/doctypes/parse.mjs +3 -2
  34. package/authoring/doctypes/reference/reference.doc.mjs +5 -3
  35. package/authoring/doctypes/reference/type.ts +7 -8
  36. package/authoring/index.d.ts +1 -0
  37. package/clients/cli/commands/build-theme.mjs +10 -44
  38. package/clients/cli/commands/docs.mjs +15 -58
  39. package/clients/cli/commands/docs.test.mjs +11 -14
  40. package/clients/cli/commands/text-json-parity.test.mjs +718 -0
  41. package/clients/cli/commands/theme-targets.behavior.test.mjs +4 -3
  42. package/clients/cli/commands/upgrade.doc.mjs +2 -1
  43. package/clients/cli/commands/upgrade.file-protection.test.mjs +228 -0
  44. package/clients/cli/commands/upgrade.mjs +29 -7
  45. package/clients/cli/formatters/index.mjs +2 -0
  46. package/clients/cli/formatters/index.test.mjs +6 -0
  47. package/foundation/discovery/authoring-self-docs.test.mjs +3 -2
  48. package/foundation/discovery/docs-discovery.mjs +6 -5
  49. package/foundation/discovery/docs-discovery.test.mjs +7 -10
  50. package/foundation/discovery/docs-section-key.d.mts +19 -8
  51. package/foundation/discovery/docs-section-key.mjs +119 -32
  52. package/foundation/discovery/docs-section-key.test.mjs +41 -19
  53. package/foundation/doc-compiler/compile.mjs +5 -4
  54. package/foundation/fs/file-protection.d.mts +33 -0
  55. package/foundation/fs/file-protection.mjs +825 -0
  56. package/foundation/fs/file-protection.test.mjs +250 -0
  57. package/foundation/response/error-codes.d.mts +3 -1
  58. package/foundation/response/error-codes.d.ts +2 -0
  59. package/foundation/response/error-codes.doc.mjs +10 -0
  60. package/foundation/response/error-codes.mjs +6 -0
  61. package/foundation/response/error-codes.test.mjs +55 -11
  62. package/package.json +10 -9
@@ -0,0 +1,148 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Codemod: migrate nativePicker to presentation on date/time inputs
5
+ *
6
+ * `spec:AST-043` FR3 mapping, applied only to static literals written
7
+ * directly on imported `DateInput`, `DateTimeInput`, and `TimeInput`
8
+ * elements: the prop is renamed to `presentation` and its value mapped.
9
+ * When the element already sets `presentation`, the deprecated prop is
10
+ * removed (presentation wins, FR4). Dynamic values are left unchanged —
11
+ * the deprecated prop keeps working, so an unmigrated callsite is still
12
+ * correct, and guessing at an expression's values would not be.
13
+ */
14
+
15
+ import {transformProp} from '../../transform-prop.mjs';
16
+
17
+ export const meta = {
18
+ title: 'Migrate nativePicker to presentation',
19
+ description:
20
+ 'Renames `nativePicker` to `presentation` on DateInput, DateTimeInput, ' +
21
+ 'and TimeInput, mapping touch→adaptive-native, always→native, and ' +
22
+ 'never→adaptive-bottom-sheet (text-input for TimeInput). Dynamic ' +
23
+ 'values are left for manual migration; the deprecated prop still works.',
24
+ };
25
+
26
+ const CORE_IMPORT_RE = /^@(astryxdesign|xds)\/core(?:\/|$)/;
27
+
28
+ const COMPONENT_PROPS = new Map([
29
+ ['DateInput', new Set(['nativePicker'])],
30
+ ['DateTimeInput', new Set(['nativePicker'])],
31
+ ['TimeInput', new Set(['nativePicker'])],
32
+ ]);
33
+
34
+ /** @param {string} component @param {string} value */
35
+ function mapValue(component, value) {
36
+ switch (value) {
37
+ case 'touch':
38
+ return 'adaptive-native';
39
+ case 'always':
40
+ return 'native';
41
+ case 'never':
42
+ return component === 'TimeInput' ? 'text-input' : 'adaptive-bottom-sheet';
43
+ default:
44
+ return undefined;
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Collect the string-literal leaves of a value expression without mutating
50
+ * anything. Returns false for any dynamic or non-string node.
51
+ * @param {any} node
52
+ * @param {any[]} leaves
53
+ * @returns {boolean}
54
+ */
55
+ function collectStaticLeaves(node, leaves) {
56
+ if (!node) return false;
57
+ if (
58
+ node.type === 'TSAsExpression' ||
59
+ node.type === 'TSSatisfiesExpression' ||
60
+ node.type === 'TypeCastExpression' ||
61
+ node.type === 'ParenthesizedExpression'
62
+ ) {
63
+ return collectStaticLeaves(node.expression, leaves);
64
+ }
65
+ if (node.type === 'ConditionalExpression') {
66
+ return (
67
+ collectStaticLeaves(node.consequent, leaves) &&
68
+ collectStaticLeaves(node.alternate, leaves)
69
+ );
70
+ }
71
+ if (
72
+ (node.type !== 'StringLiteral' && node.type !== 'Literal') ||
73
+ typeof node.value !== 'string'
74
+ ) {
75
+ return false;
76
+ }
77
+ leaves.push(node);
78
+ return true;
79
+ }
80
+
81
+ /**
82
+ * Map every leaf, or none of them: a mixed static/dynamic conditional must
83
+ * stay byte-identical, never half-migrated.
84
+ * @param {any} node
85
+ * @param {string} component
86
+ */
87
+ function mapStaticValue(node, component) {
88
+ /** @type {any[]} */
89
+ const leaves = [];
90
+ if (!collectStaticLeaves(node, leaves)) return false;
91
+ if (leaves.some(leaf => mapValue(component, leaf.value) === undefined)) {
92
+ return false;
93
+ }
94
+ for (const leaf of leaves) {
95
+ leaf.value = mapValue(component, leaf.value);
96
+ if (leaf.raw) leaf.raw = undefined;
97
+ }
98
+ return true;
99
+ }
100
+
101
+ /**
102
+ * @param {import('../../../../authoring/codemod/type').AstryxCodemodFile} file
103
+ * @param {import('../../../../authoring/codemod/type').CodemodTransformApi} api
104
+ * @returns {string | null | undefined}
105
+ */
106
+ export default function transformer(file, api) {
107
+ if (!file.source.includes('nativePicker')) return undefined;
108
+ const j = api.jscodeshift;
109
+ const root = j(file.source);
110
+ let hasChanges = false;
111
+
112
+ transformProp(
113
+ root,
114
+ j,
115
+ {
116
+ matchesImport: source => CORE_IMPORT_RE.test(source),
117
+ components: COMPONENT_PROPS,
118
+ },
119
+ (propPath, {component}) => {
120
+ const opening = propPath.parent?.node;
121
+ const attributes = opening?.attributes ?? [];
122
+ const hasPresentation = attributes.some(
123
+ (/** @type {any} */ attribute) =>
124
+ attribute.type === 'JSXAttribute' &&
125
+ attribute.name?.name === 'presentation',
126
+ );
127
+ const prop = propPath.node;
128
+ if (hasPresentation) {
129
+ // FR4: presentation wins; drop the deprecated prop.
130
+ opening.attributes = attributes.filter(
131
+ (/** @type {any} */ attribute) => attribute !== prop,
132
+ );
133
+ hasChanges = true;
134
+ return;
135
+ }
136
+ const value =
137
+ prop.value?.type === 'JSXExpressionContainer'
138
+ ? prop.value.expression
139
+ : prop.value;
140
+ if (!mapStaticValue(value, component)) return;
141
+ prop.name.name = 'presentation';
142
+ hasChanges = true;
143
+ },
144
+ );
145
+
146
+ if (!hasChanges) return undefined;
147
+ return root.toSource({quote: 'single'});
148
+ }
@@ -330,6 +330,19 @@ export const docs = {
330
330
  lang: 'bash',
331
331
  code: '# Preview what would change (dry-run, the default)\nastryx upgrade --from 0.1.0\n\n# Apply the migration\nastryx upgrade --from 0.1.0 --apply',
332
332
  },
333
+ {
334
+ type: 'prose',
335
+ text: 'Core and integration upgrade codemods do not edit existing consumer files that the working tree protects. Protection is VCS-neutral: Astryx reads nested `.gitattributes` rules for `linguist-generated` and `linguist-vendored`, leading `@generated` and `@partially-generated` comments, standard `Code generated … DO NOT EDIT.` comments, `.gitignore`, and `.hgignore` directly from disk. Later attribute rules, explicit false or unset values, and ignore negation keep their normal semantics. Installed dependencies, VCS metadata, paths outside the project, and symbolic links are also protected. Directory or file names such as `dist` and `generated` are not evidence by themselves.',
336
+ },
337
+ {
338
+ type: 'prose',
339
+ text: 'A protected file is transformed only in memory. If it would change, the upgrade applies eligible owned-source edits, runs `hooks.postCodemod` regeneration, and checks the protected file again. A remaining change makes the run incomplete and exits nonzero with `ERR_CODEMOD_PROTECTED`; JSON output lists `modifiedFiles` and `protectedFiles` with every effective declaration. Generated headers may include `Command: <exact command>` so the result can tell a consumer how to regenerate when no hook resolves the output. Dry-run uses the same classification without writing.',
340
+ },
341
+ {
342
+ type: 'code',
343
+ lang: 'text',
344
+ code: '# .gitattributes\ngenerated/** linguist-generated=true\nvendor/** linguist-vendored=true\n\n# A later rule can explicitly return an authored file to normal handling\ngenerated/hand-authored.ts linguist-generated=false',
345
+ },
333
346
  {
334
347
  type: 'prose',
335
348
  text: 'All authoring types are exported from `@astryxdesign/cli/authoring`: `ComponentDoc`, `HookDoc`, and `ReferenceDoc` for docs, `TemplateDoc` for templates, and `AstryxConfig`, `AstryxIntegration`, and `AstryxCodemod` for the project files. Consumers can also run their own post-codemod hooks, such as a reinstall or rebuild, via `hooks.postCodemod` in their `astryx.config`.',
@@ -41,7 +41,7 @@ export default function DateInputDateRange() {
41
41
  max={max}
42
42
  description={description}
43
43
  placeholder="Select a booking date"
44
- nativePicker="never"
44
+ presentation="adaptive-bottom-sheet"
45
45
  value={value}
46
46
  onChange={setValue}
47
47
  />
@@ -0,0 +1,14 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ exampleFor: 'Item',
7
+ name: 'Item — Document Tabs',
8
+ displayName: 'Item — Document Tabs',
9
+ description:
10
+ 'Single-row, horizontally scrollable document switcher with compact selected rows, leading file icons, instant reveal-on-hover close actions with reserved geometry, stable separators, and an add control outside the scroll area. Use for editor tabs, workspace tabs, open documents, files, canvases, or panels.',
11
+ isReady: true,
12
+ aspectRatio: 16 / 4,
13
+ componentsUsed: ['Item', 'Divider', 'Icon', 'IconButton', 'Layout'],
14
+ };
@@ -0,0 +1,100 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {Fragment} from 'react';
6
+ import * as stylex from '@stylexjs/stylex';
7
+
8
+ import {Divider} from '@astryxdesign/core/Divider';
9
+ import {useContainerReveal} from '@astryxdesign/core/hooks';
10
+ import {Icon} from '@astryxdesign/core/Icon';
11
+ import {IconButton} from '@astryxdesign/core/IconButton';
12
+ import {Item} from '@astryxdesign/core/Item';
13
+ import {HStack} from '@astryxdesign/core/Layout';
14
+ import {mergeProps} from '@astryxdesign/core/utils';
15
+ import {DocumentIcon, PlusIcon, XMarkIcon} from '@heroicons/react/24/outline';
16
+
17
+ const TABS = [
18
+ {name: 'Project brief', isActive: true},
19
+ {name: 'Research notes', isActive: false},
20
+ {name: 'Interaction prototype', isActive: false},
21
+ ];
22
+
23
+ const styles = stylex.create({
24
+ strip: {minWidth: 0, flexShrink: 1, scrollbarWidth: 'none'},
25
+ rule: {height: 16},
26
+ hidden: {visibility: 'hidden'},
27
+ tab: {flexShrink: 1, width: 164, minWidth: 96},
28
+ action: {margin: 'calc(-1 * var(--spacing-1))', transitionProperty: 'none'},
29
+ });
30
+ function DocumentTab({name, isActive}: (typeof TABS)[number]) {
31
+ const {getContainerProps, getContentRevealProps} = useContainerReveal();
32
+ const revealProps = getContentRevealProps({
33
+ forceVisibility: isActive ? 'shown' : undefined,
34
+ isLayoutPreserved: true,
35
+ });
36
+ return (
37
+ <Item
38
+ label={name}
39
+ density="compact"
40
+ isSelected={isActive}
41
+ onClick={() => {}}
42
+ aria-current={isActive ? 'true' : undefined}
43
+ {...getContainerProps()}
44
+ startContent={
45
+ <Icon
46
+ icon={DocumentIcon}
47
+ size="sm"
48
+ color={isActive ? 'primary' : 'secondary'}
49
+ />
50
+ }
51
+ endContent={
52
+ <IconButton
53
+ label={`Close ${name}`}
54
+ variant="ghost"
55
+ size="sm"
56
+ icon={<Icon icon={XMarkIcon} size="sm" />}
57
+ {...mergeProps(revealProps, stylex.props(styles.action))}
58
+ />
59
+ }
60
+ xstyle={styles.tab}
61
+ />
62
+ );
63
+ }
64
+
65
+ export default function ItemDocumentTabs() {
66
+ return (
67
+ <HStack width="100%" maxWidth={600} gap={0.5} vAlign="center">
68
+ <HStack
69
+ role="group"
70
+ aria-label="Open documents"
71
+ vAlign="center"
72
+ paddingInline={2}
73
+ paddingBlock={1}
74
+ isScrollable
75
+ xstyle={styles.strip}>
76
+ {TABS.map((tab, index) => (
77
+ <Fragment key={tab.name}>
78
+ {index > 0 ? (
79
+ <Divider
80
+ orientation="vertical"
81
+ xstyle={[
82
+ styles.rule,
83
+ (TABS[index - 1]?.isActive || tab.isActive) && styles.hidden,
84
+ ]}
85
+ />
86
+ ) : null}
87
+ <DocumentTab {...tab} />
88
+ </Fragment>
89
+ ))}
90
+ </HStack>
91
+ <IconButton
92
+ label="New document"
93
+ tooltip="New document"
94
+ variant="ghost"
95
+ size="sm"
96
+ icon={<Icon icon={PlusIcon} size="sm" color="secondary" />}
97
+ />
98
+ </HStack>
99
+ );
100
+ }
@@ -17,6 +17,7 @@ export default function TimeInputConstrained() {
17
17
  max={'22:00' as never}
18
18
  description="Evening seating: 5 PM – 10 PM"
19
19
  placeholder="Select reservation time"
20
+ presentation="adaptive-bottom-sheet"
20
21
  value={evening as never}
21
22
  onChange={setEvening as never}
22
23
  hasClear
@@ -128,7 +128,19 @@ export interface CodemodEntry {
128
128
  /** The result of running a single codemod over one or more files. */
129
129
  export interface CodemodRunResult {
130
130
  filesChanged: number;
131
+ /** Existing owned files changed or previewed by this codemod. */
132
+ changedFiles: string[];
133
+ /** Files actually written; empty during a dry run. */
131
134
  writtenFiles: string[];
135
+ /** Existing files that require the change but are protected. */
136
+ protectedFiles: Array<{
137
+ file: string;
138
+ codemod: string;
139
+ reason: string;
140
+ declaration: string;
141
+ generated: boolean;
142
+ command?: string;
143
+ }>;
132
144
  errors: Array<{file: string; codemod: string; error: string}>;
133
145
  }
134
146
 
@@ -25,7 +25,7 @@ export namespace AuthoredDocGraphFields {
25
25
  internal: "internal";
26
26
  }>>;
27
27
  }
28
- /** Runtime schema for every existing and V1 semantic content block. */
28
+ /** Runtime schema for the stable content-block union published in 0.6.x. */
29
29
  export const ReferenceContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
30
30
  type: z.ZodLiteral<"prose">;
31
31
  text: z.ZodString;
@@ -55,6 +55,74 @@ export const ReferenceContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
55
55
  type: z.ZodLiteral<"token-ref">;
56
56
  topic: z.ZodString;
57
57
  section: z.ZodString;
58
+ }, z.core.$strict>], "type">;
59
+ /** Runtime schema for graph-only blocks used by NamespaceDoc. */
60
+ export const GraphContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
61
+ type: z.ZodLiteral<"workflow">;
62
+ title: z.ZodOptional<z.ZodString>;
63
+ steps: z.ZodArray<z.ZodObject<{
64
+ title: z.ZodString;
65
+ description: z.ZodOptional<z.ZodString>;
66
+ references: z.ZodOptional<z.ZodArray<z.ZodString>>;
67
+ }, z.core.$strict>>;
68
+ }, z.core.$strict>, z.ZodObject<{
69
+ type: z.ZodLiteral<"collection">;
70
+ title: z.ZodOptional<z.ZodString>;
71
+ source: z.ZodObject<{
72
+ slot: z.ZodString;
73
+ }, z.core.$strict>;
74
+ presentation: z.ZodOptional<z.ZodEnum<{
75
+ list: "list";
76
+ cards: "cards";
77
+ compact: "compact";
78
+ }>>;
79
+ whenEmpty: z.ZodOptional<z.ZodEnum<{
80
+ show: "show";
81
+ omit: "omit";
82
+ }>>;
83
+ }, z.core.$strict>, z.ZodObject<{
84
+ type: z.ZodLiteral<"reference">;
85
+ target: z.ZodString;
86
+ projection: z.ZodOptional<z.ZodObject<{
87
+ fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
88
+ sections: z.ZodOptional<z.ZodArray<z.ZodString>>;
89
+ }, z.core.$strict>>;
90
+ presentation: z.ZodOptional<z.ZodEnum<{
91
+ compact: "compact";
92
+ summary: "summary";
93
+ full: "full";
94
+ }>>;
95
+ }, z.core.$strict>], "type">;
96
+ /** Namespace content accepts both stable reference blocks and graph-only blocks. */
97
+ export const NamespaceContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
98
+ type: z.ZodLiteral<"prose">;
99
+ text: z.ZodString;
100
+ }, z.core.$strict>, z.ZodObject<{
101
+ type: z.ZodLiteral<"heading">;
102
+ level: z.ZodUnion<readonly [z.ZodLiteral<3>, z.ZodLiteral<4>, z.ZodLiteral<5>, z.ZodLiteral<6>]>;
103
+ text: z.ZodString;
104
+ }, z.core.$strict>, z.ZodObject<{
105
+ type: z.ZodLiteral<"code">;
106
+ lang: z.ZodString;
107
+ code: z.ZodString;
108
+ label: z.ZodOptional<z.ZodString>;
109
+ }, z.core.$strict>, z.ZodObject<{
110
+ type: z.ZodLiteral<"table">;
111
+ headers: z.ZodArray<z.ZodString>;
112
+ rows: z.ZodArray<z.ZodArray<z.ZodString>>;
113
+ }, z.core.$strict>, z.ZodObject<{
114
+ type: z.ZodLiteral<"list">;
115
+ style: z.ZodEnum<{
116
+ ordered: "ordered";
117
+ unordered: "unordered";
118
+ do: "do";
119
+ dont: "dont";
120
+ }>;
121
+ items: z.ZodArray<z.ZodString>;
122
+ }, z.core.$strict>, z.ZodObject<{
123
+ type: z.ZodLiteral<"token-ref">;
124
+ topic: z.ZodString;
125
+ section: z.ZodString;
58
126
  }, z.core.$strict>, z.ZodObject<{
59
127
  type: z.ZodLiteral<"workflow">;
60
128
  title: z.ZodOptional<z.ZodString>;
@@ -235,41 +303,6 @@ export const GenericDocKindSchema: z.ZodObject<{
235
303
  type: z.ZodLiteral<"token-ref">;
236
304
  topic: z.ZodString;
237
305
  section: z.ZodString;
238
- }, z.core.$strict>, z.ZodObject<{
239
- type: z.ZodLiteral<"workflow">;
240
- title: z.ZodOptional<z.ZodString>;
241
- steps: z.ZodArray<z.ZodObject<{
242
- title: z.ZodString;
243
- description: z.ZodOptional<z.ZodString>;
244
- references: z.ZodOptional<z.ZodArray<z.ZodString>>;
245
- }, z.core.$strict>>;
246
- }, z.core.$strict>, z.ZodObject<{
247
- type: z.ZodLiteral<"collection">;
248
- title: z.ZodOptional<z.ZodString>;
249
- source: z.ZodObject<{
250
- slot: z.ZodString;
251
- }, z.core.$strict>;
252
- presentation: z.ZodOptional<z.ZodEnum<{
253
- list: "list";
254
- cards: "cards";
255
- compact: "compact";
256
- }>>;
257
- whenEmpty: z.ZodOptional<z.ZodEnum<{
258
- show: "show";
259
- omit: "omit";
260
- }>>;
261
- }, z.core.$strict>, z.ZodObject<{
262
- type: z.ZodLiteral<"reference">;
263
- target: z.ZodString;
264
- projection: z.ZodOptional<z.ZodObject<{
265
- fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
266
- sections: z.ZodOptional<z.ZodArray<z.ZodString>>;
267
- }, z.core.$strict>>;
268
- presentation: z.ZodOptional<z.ZodEnum<{
269
- compact: "compact";
270
- summary: "summary";
271
- full: "full";
272
- }>>;
273
306
  }, z.core.$strict>], "type">>;
274
307
  previewType: z.ZodOptional<z.ZodEnum<{
275
308
  swatch: "swatch";
@@ -351,41 +384,6 @@ export const SchemaDocKindSchema: z.ZodObject<{
351
384
  type: z.ZodLiteral<"token-ref">;
352
385
  topic: z.ZodString;
353
386
  section: z.ZodString;
354
- }, z.core.$strict>, z.ZodObject<{
355
- type: z.ZodLiteral<"workflow">;
356
- title: z.ZodOptional<z.ZodString>;
357
- steps: z.ZodArray<z.ZodObject<{
358
- title: z.ZodString;
359
- description: z.ZodOptional<z.ZodString>;
360
- references: z.ZodOptional<z.ZodArray<z.ZodString>>;
361
- }, z.core.$strict>>;
362
- }, z.core.$strict>, z.ZodObject<{
363
- type: z.ZodLiteral<"collection">;
364
- title: z.ZodOptional<z.ZodString>;
365
- source: z.ZodObject<{
366
- slot: z.ZodString;
367
- }, z.core.$strict>;
368
- presentation: z.ZodOptional<z.ZodEnum<{
369
- list: "list";
370
- cards: "cards";
371
- compact: "compact";
372
- }>>;
373
- whenEmpty: z.ZodOptional<z.ZodEnum<{
374
- show: "show";
375
- omit: "omit";
376
- }>>;
377
- }, z.core.$strict>, z.ZodObject<{
378
- type: z.ZodLiteral<"reference">;
379
- target: z.ZodString;
380
- projection: z.ZodOptional<z.ZodObject<{
381
- fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
382
- sections: z.ZodOptional<z.ZodArray<z.ZodString>>;
383
- }, z.core.$strict>>;
384
- presentation: z.ZodOptional<z.ZodEnum<{
385
- compact: "compact";
386
- summary: "summary";
387
- full: "full";
388
- }>>;
389
387
  }, z.core.$strict>], "type">>>;
390
388
  placement: z.ZodOptional<z.ZodObject<{
391
389
  parent: z.ZodString;
@@ -470,41 +468,6 @@ export const CommandDocKindSchema: z.ZodObject<{
470
468
  type: z.ZodLiteral<"token-ref">;
471
469
  topic: z.ZodString;
472
470
  section: z.ZodString;
473
- }, z.core.$strict>, z.ZodObject<{
474
- type: z.ZodLiteral<"workflow">;
475
- title: z.ZodOptional<z.ZodString>;
476
- steps: z.ZodArray<z.ZodObject<{
477
- title: z.ZodString;
478
- description: z.ZodOptional<z.ZodString>;
479
- references: z.ZodOptional<z.ZodArray<z.ZodString>>;
480
- }, z.core.$strict>>;
481
- }, z.core.$strict>, z.ZodObject<{
482
- type: z.ZodLiteral<"collection">;
483
- title: z.ZodOptional<z.ZodString>;
484
- source: z.ZodObject<{
485
- slot: z.ZodString;
486
- }, z.core.$strict>;
487
- presentation: z.ZodOptional<z.ZodEnum<{
488
- list: "list";
489
- cards: "cards";
490
- compact: "compact";
491
- }>>;
492
- whenEmpty: z.ZodOptional<z.ZodEnum<{
493
- show: "show";
494
- omit: "omit";
495
- }>>;
496
- }, z.core.$strict>, z.ZodObject<{
497
- type: z.ZodLiteral<"reference">;
498
- target: z.ZodString;
499
- projection: z.ZodOptional<z.ZodObject<{
500
- fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
501
- sections: z.ZodOptional<z.ZodArray<z.ZodString>>;
502
- }, z.core.$strict>>;
503
- presentation: z.ZodOptional<z.ZodEnum<{
504
- compact: "compact";
505
- summary: "summary";
506
- full: "full";
507
- }>>;
508
471
  }, z.core.$strict>], "type">>>;
509
472
  placement: z.ZodOptional<z.ZodObject<{
510
473
  parent: z.ZodString;
@@ -877,41 +840,6 @@ export const LegacyDocSchema: z.ZodUnion<readonly [z.ZodObject<{
877
840
  type: z.ZodLiteral<"token-ref">;
878
841
  topic: z.ZodString;
879
842
  section: z.ZodString;
880
- }, z.core.$strict>, z.ZodObject<{
881
- type: z.ZodLiteral<"workflow">;
882
- title: z.ZodOptional<z.ZodString>;
883
- steps: z.ZodArray<z.ZodObject<{
884
- title: z.ZodString;
885
- description: z.ZodOptional<z.ZodString>;
886
- references: z.ZodOptional<z.ZodArray<z.ZodString>>;
887
- }, z.core.$strict>>;
888
- }, z.core.$strict>, z.ZodObject<{
889
- type: z.ZodLiteral<"collection">;
890
- title: z.ZodOptional<z.ZodString>;
891
- source: z.ZodObject<{
892
- slot: z.ZodString;
893
- }, z.core.$strict>;
894
- presentation: z.ZodOptional<z.ZodEnum<{
895
- list: "list";
896
- cards: "cards";
897
- compact: "compact";
898
- }>>;
899
- whenEmpty: z.ZodOptional<z.ZodEnum<{
900
- show: "show";
901
- omit: "omit";
902
- }>>;
903
- }, z.core.$strict>, z.ZodObject<{
904
- type: z.ZodLiteral<"reference">;
905
- target: z.ZodString;
906
- projection: z.ZodOptional<z.ZodObject<{
907
- fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
908
- sections: z.ZodOptional<z.ZodArray<z.ZodString>>;
909
- }, z.core.$strict>>;
910
- presentation: z.ZodOptional<z.ZodEnum<{
911
- compact: "compact";
912
- summary: "summary";
913
- full: "full";
914
- }>>;
915
843
  }, z.core.$strict>], "type">>;
916
844
  previewType: z.ZodOptional<z.ZodEnum<{
917
845
  swatch: "swatch";
@@ -933,6 +861,7 @@ export type AuthoredDocGraphFieldsType = import("./base/type.js").AuthoredDocGra
933
861
  export type AuthoredDocKind = import("./base/type.js").AuthoredDocKind;
934
862
  export type NamespaceDoc = import("./namespace/type.js").NamespaceDoc;
935
863
  export type ReferenceContentBlock = import("./reference/type.js").ReferenceContentBlock;
864
+ export type GraphContentBlock = import("./reference/type.js").GraphContentBlock;
936
865
  export type ReferenceDoc = import("./reference/type.js").ReferenceDoc;
937
866
  export type SingleComponentDoc = import("./component/type.js").SingleComponentDoc;
938
867
  export type ComponentPropDoc = import("./base/type.js").ComponentPropDoc;
@@ -944,6 +873,7 @@ export type EnumDoc = import("./enum/type.js").EnumDoc;
944
873
  export type _AuthoredDocKindDriftLock = import("../_shared/contract.js").Expect<import("../_shared/contract.js").Equal<z.infer<typeof AuthoredDocKindSchema>, AuthoredDocKind>>;
945
874
  export type _AuthoredDocGraphDriftLock = import("../_shared/contract.js").Expect<import("../_shared/contract.js").MutuallyAssignable<z.infer<typeof _AuthoredDocGraphSchema>, AuthoredDocGraphFieldsType>>;
946
875
  export type _ReferenceContentBlockDriftLock = import("../_shared/contract.js").Expect<import("../_shared/contract.js").Equal<z.infer<typeof ReferenceContentBlockSchema>, ReferenceContentBlock>>;
876
+ export type _GraphContentBlockDriftLock = import("../_shared/contract.js").Expect<import("../_shared/contract.js").Equal<z.infer<typeof GraphContentBlockSchema>, GraphContentBlock>>;
947
877
  /**
948
878
  * A stamped component doc as it loads. The loader accepts what the unstamped
949
879
  * format always accepted, so stamping an existing doc never breaks it:
@@ -15,6 +15,7 @@ import {z} from 'zod';
15
15
  /** @typedef {import('./base/type.js').AuthoredDocKind} AuthoredDocKind */
16
16
  /** @typedef {import('./namespace/type.js').NamespaceDoc} NamespaceDoc */
17
17
  /** @typedef {import('./reference/type.js').ReferenceContentBlock} ReferenceContentBlock */
18
+ /** @typedef {import('./reference/type.js').GraphContentBlock} GraphContentBlock */
18
19
  /** @typedef {import('./reference/type.js').ReferenceDoc} ReferenceDoc */
19
20
  /** @typedef {import('./component/type.js').SingleComponentDoc} SingleComponentDoc */
20
21
  /** @typedef {import('./base/type.js').ComponentPropDoc} ComponentPropDoc */
@@ -161,7 +162,7 @@ const ReferenceBlockSchema = z
161
162
  })
162
163
  .strict();
163
164
 
164
- /** Runtime schema for every existing and V1 semantic content block. */
165
+ /** Runtime schema for the stable content-block union published in 0.6.x. */
165
166
  export const ReferenceContentBlockSchema = z.discriminatedUnion('type', [
166
167
  ProseBlockSchema,
167
168
  HeadingBlockSchema,
@@ -169,6 +170,23 @@ export const ReferenceContentBlockSchema = z.discriminatedUnion('type', [
169
170
  TableBlockSchema,
170
171
  ListBlockSchema,
171
172
  TokenReferenceBlockSchema,
173
+ ]);
174
+
175
+ /** Runtime schema for graph-only blocks used by NamespaceDoc. */
176
+ export const GraphContentBlockSchema = z.discriminatedUnion('type', [
177
+ WorkflowBlockSchema,
178
+ CollectionBlockSchema,
179
+ ReferenceBlockSchema,
180
+ ]);
181
+
182
+ /** Namespace content accepts both stable reference blocks and graph-only blocks. */
183
+ export const NamespaceContentBlockSchema = z.discriminatedUnion('type', [
184
+ ProseBlockSchema,
185
+ HeadingBlockSchema,
186
+ CodeBlockSchema,
187
+ TableBlockSchema,
188
+ ListBlockSchema,
189
+ TokenReferenceBlockSchema,
172
190
  WorkflowBlockSchema,
173
191
  CollectionBlockSchema,
174
192
  ReferenceBlockSchema,
@@ -183,6 +201,15 @@ export const ReferenceContentBlockSchema = z.discriminatedUnion('type', [
183
201
  * >} _ReferenceContentBlockDriftLock
184
202
  */
185
203
 
204
+ /**
205
+ * @typedef {import('../_shared/contract.js').Expect<
206
+ * import('../_shared/contract.js').Equal<
207
+ * z.infer<typeof GraphContentBlockSchema>,
208
+ * GraphContentBlock
209
+ * >
210
+ * >} _GraphContentBlockDriftLock
211
+ */
212
+
186
213
  const ReferenceSectionSchema = z
187
214
  .object({
188
215
  id: nonEmptyString.optional(),
@@ -605,7 +632,7 @@ export const NamespaceDocKindSchema = z
605
632
  .strict(),
606
633
  )
607
634
  .optional(),
608
- blocks: z.array(ReferenceContentBlockSchema).optional(),
635
+ blocks: z.array(NamespaceContentBlockSchema).optional(),
609
636
  })
610
637
  .strict()
611
638
  .superRefine((doc, context) => {
@@ -71,7 +71,7 @@ describe('load check vs published type', () => {
71
71
  expect(() => parseDoc(EXAMPLES[kind], `${kind}.doc.mjs`)).not.toThrow();
72
72
  }
73
73
  expect(() => parseDoc({type: 'widget', name: 'x'}, 'x.doc.mjs')).toThrow(
74
- /unsupported type "widget"/,
74
+ /x\.doc\.mjs is invalid/u,
75
75
  );
76
76
  });
77
77
  });
@@ -78,9 +78,9 @@ export const doc = {
78
78
  },
79
79
  {
80
80
  name: 'blocks',
81
- type: 'ReferenceContentBlock[]',
81
+ type: '(ReferenceContentBlock | GraphContentBlock)[]',
82
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.',
83
+ 'Ordered layout content. Graph-only workflow, collection, and reference blocks are available here without widening the stable ReferenceContentBlock union used by existing topic renderers.',
84
84
  },
85
85
  ],
86
86
  examples: [