@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,71 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Namespace doc types. A namespace owns navigation slots and a
5
- * renderer-neutral layout over already-discovered docs. It never scans files
6
- * or copies child documents.
7
- */
8
-
9
- import type {AuthoredDocGraphFields, AuthoredDocKind} from '../base/type.js';
10
- import type {ReferenceContentBlock} from '../reference/type.js';
11
-
12
- /** Which providers may contribute appearances to a namespace slot. */
13
- export type NamespaceProviderScope = 'same' | 'configured';
14
-
15
- /** Constraints declared by the namespace that owns a slot. */
16
- export interface NamespaceSlotAcceptance {
17
- /** Authored doc kinds accepted by this slot. */
18
- kinds: AuthoredDocKind[];
19
- /** Omit for the namespace provider; `configured` admits provider appearances. */
20
- providers?: NamespaceProviderScope;
21
- }
22
-
23
- /** One named placement and collection target owned by a NamespaceDoc. */
24
- export interface NamespaceSlot {
25
- /** Human-readable heading for children in this slot. */
26
- title: string;
27
- /** Which docs may be placed or shown in this slot. */
28
- accepts: NamespaceSlotAcceptance;
29
- }
30
-
31
- /** One logical source group that a namespace may adopt. */
32
- export interface NamespaceAdoptionSource {
33
- /** Provider-local discovery group, such as `cli-commands`. */
34
- group: string;
35
- /** Optional subset of authored kinds from the group. */
36
- kinds?: AuthoredDocKind[];
37
- }
38
-
39
- /**
40
- * Assigns otherwise-unplaced docs from one provider-local source group to a
41
- * child namespace. Discovery defines groups; this rule never scans a folder.
42
- */
43
- export interface NamespaceAdoptionRule {
44
- source: NamespaceAdoptionSource;
45
- /** Slot owned by this namespace that becomes the canonical destination. */
46
- into: string;
47
- /** Generate one child namespace per authored kind. */
48
- groupBy?: 'kind';
49
- }
50
-
51
- /**
52
- * An authored documentation namespace. Its ordered blocks control layout while
53
- * slots and adoption rules describe where already-discovered docs may appear.
54
- */
55
- export interface NamespaceDoc extends AuthoredDocGraphFields {
56
- type: 'namespace';
57
- /** Stable provider-local name. Navigation changes do not change this value. */
58
- name: string;
59
- /** Human-readable page title. */
60
- title: string;
61
- /** One-line summary shown in listings and search results. */
62
- summary: string;
63
- /** Search terms that are not already present in the title or summary. */
64
- keywords?: string[];
65
- /** Named child-placement and collection targets. */
66
- slots: Record<string, NamespaceSlot>;
67
- /** Optional source-adoption rules for otherwise-unplaced docs. */
68
- adopts?: NamespaceAdoptionRule[];
69
- /** Ordered renderer-neutral content and collection blocks. */
70
- blocks?: ReferenceContentBlock[];
71
- }
@@ -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 provider, artifact, and immutable instance identity.
6
- * @position packages/cli/authoring/identity — identity documentation
7
- */
8
- /** @type {import('@astryxdesign/cli/authoring').SchemaDoc} */
9
- export const doc: import("@astryxdesign/cli/authoring").SchemaDoc;
@@ -1,61 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file SchemaDoc for provider, artifact, and immutable instance identity.
5
- * @position packages/cli/authoring/identity — identity documentation
6
- */
7
-
8
- /** @type {import('@astryxdesign/cli/authoring').SchemaDoc} */
9
- export const doc = {
10
- type: 'schema',
11
- name: 'provider-identity',
12
- displayName: 'Provider and artifact identity',
13
- namespace: 'authoring',
14
- description:
15
- 'Separates stable provider/artifact identity from package instances and runtime lifecycle state. providerId is in use today: an integration manifest may declare it, and Doctor and every command report two packages that claim one. The artifact, doc, instance, and compiler-input identities are defined for the docs graph, which is not built yet, and no command reads them.',
16
- appliesTo:
17
- 'Integration manifests and provider conflicts today; the docs graph once it ships',
18
- fields: [
19
- {
20
- name: 'ProviderId',
21
- type: 'string',
22
- description:
23
- 'Canonical logical provider ID. It defaults to the lowercase npm package name; Core uses the same model without publishing an integration manifest.',
24
- required: true,
25
- },
26
- {
27
- name: 'ArtifactId',
28
- type: 'string',
29
- description:
30
- 'Versioned serialization of provider ID, contribution kind, and stable artifact name. Every segment uses RFC 3986 escaping.',
31
- required: true,
32
- },
33
- {
34
- name: 'DocId',
35
- type: 'ArtifactId',
36
- description:
37
- 'Artifact ID restricted to one authored doc kind. Navigation changes do not change it.',
38
- required: true,
39
- },
40
- {
41
- name: 'ProviderInstance',
42
- type: '{ id; providerId; packageName; packageVersion; sourceDigest }',
43
- description:
44
- 'One immutable package version and source/content digest. Installed, configured, loaded, selected, and healthy state is a separate runtime overlay.',
45
- required: true,
46
- },
47
- {
48
- name: 'AuthoredDocEntry',
49
- type: '{ id; provider; kind; stableName; source; authored }',
50
- description:
51
- 'Normalized compiler input. Discovery supplies stableName independently from the authored display name, source paths remain package-relative, and provider provenance plus the authored snapshot are immutable.',
52
- required: true,
53
- },
54
- ],
55
- notes: [
56
- {
57
- type: 'prose',
58
- text: 'Provider package renames require an explicit mapping: a ProviderInstance may retain its stable providerId while packageName changes. Silent identity changes are not inferred.',
59
- },
60
- ],
61
- };
@@ -1,132 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Stable provider, artifact, and authored-doc entry contracts.
5
- *
6
- * Logical IDs exclude installed/configured/loaded/healthy state. A concrete
7
- * provider instance adds package version and a content digest, while an
8
- * artifact ID stays stable across those instances.
9
- */
10
-
11
- import type {AuthoredDocKind} from '../doctypes/base/type.js';
12
- import type {CommandDoc} from '../doctypes/command/type.js';
13
- import type {ComponentDoc} from '../doctypes/component/type.js';
14
- import type {EnumDoc} from '../doctypes/enum/type.js';
15
- import type {FunctionDoc} from '../doctypes/function/type.js';
16
- import type {HookDoc} from '../doctypes/hook/type.js';
17
- import type {NamespaceDoc} from '../doctypes/namespace/type.js';
18
- import type {ReferenceDoc} from '../doctypes/reference/type.js';
19
- import type {SchemaDoc} from '../doctypes/schema/type.js';
20
- import type {TemplateDoc} from '../doctypes/template/type.js';
21
-
22
- declare const providerIdBrand: unique symbol;
23
- declare const artifactIdBrand: unique symbol;
24
- declare const docIdBrand: unique symbol;
25
- declare const providerInstanceIdBrand: unique symbol;
26
- declare const contentDigestBrand: unique symbol;
27
-
28
- /** Canonical provider identity. It defaults to the normalized npm package name. */
29
- export type ProviderId = string & {readonly [providerIdBrand]: true};
30
-
31
- /** Stable provider + contribution kind + artifact-name identity. */
32
- export type ArtifactId = string & {readonly [artifactIdBrand]: true};
33
-
34
- /** ArtifactId narrowed to an authored documentation kind. */
35
- export type DocId = ArtifactId & {readonly [docIdBrand]: true};
36
-
37
- /** Immutable provider version + source/content digest identity. */
38
- export type ProviderInstanceId = string & {
39
- readonly [providerInstanceIdBrand]: true;
40
- };
41
-
42
- /** Lowercase `sha256:<64 hex characters>` digest. */
43
- export type ContentDigest = string & {readonly [contentDigestBrand]: true};
44
-
45
- /** Every stable artifact kind owned by a provider. */
46
- export type ContributionKind =
47
- AuthoredDocKind | 'theme' | 'codemod' | 'agent-doc';
48
-
49
- /** Stable logical identity for one provider-owned artifact. */
50
- export interface ArtifactIdentity {
51
- readonly id: ArtifactId;
52
- readonly providerId: ProviderId;
53
- readonly kind: ContributionKind;
54
- readonly name: string;
55
- }
56
-
57
- /** One immutable package instance. Runtime lifecycle state does not belong here. */
58
- export interface ProviderInstance {
59
- readonly id: ProviderInstanceId;
60
- readonly providerId: ProviderId;
61
- readonly packageName: string;
62
- readonly packageVersion: string;
63
- readonly sourceDigest: ContentDigest;
64
- }
65
-
66
- /** Every authored value accepted by the documentation compiler boundary. */
67
- export type AuthoredDoc =
68
- | ComponentDoc
69
- | HookDoc
70
- | FunctionDoc
71
- | ReferenceDoc
72
- | TemplateDoc
73
- | SchemaDoc
74
- | CommandDoc
75
- | EnumDoc
76
- | NamespaceDoc;
77
-
78
- /** Provenance attached by discovery before compilation. */
79
- export interface AuthoredDocSource {
80
- /** Provider-local logical discovery group. */
81
- readonly group: string;
82
- /** Package-relative source path; excluded from compiled renderer data. */
83
- readonly path: string;
84
- /** Digest of the authored source bytes. */
85
- readonly digest: ContentDigest;
86
- }
87
-
88
- /** Authored kind that corresponds to one public document type. */
89
- export type AuthoredDocKindOf<TDoc extends AuthoredDoc> =
90
- TDoc extends ComponentDoc
91
- ? 'component'
92
- : TDoc extends HookDoc | FunctionDoc
93
- ? 'function'
94
- : TDoc extends ReferenceDoc
95
- ? 'generic'
96
- : TDoc extends TemplateDoc
97
- ? TDoc['type']
98
- : TDoc extends SchemaDoc
99
- ? 'schema'
100
- : TDoc extends CommandDoc
101
- ? 'command'
102
- : TDoc extends EnumDoc
103
- ? 'enum'
104
- : TDoc extends NamespaceDoc
105
- ? 'namespace'
106
- : never;
107
-
108
- type DeepReadonly<Value> = Value extends (...args: never[]) => unknown
109
- ? Value
110
- : Value extends readonly (infer Item)[]
111
- ? readonly DeepReadonly<Item>[]
112
- : Value extends object
113
- ? {readonly [Key in keyof Value]: DeepReadonly<Value[Key]>}
114
- : Value;
115
-
116
- /** Immutable authored-data snapshot stored in a compiler entry. */
117
- export type AuthoredDocSnapshot<TDoc extends AuthoredDoc = AuthoredDoc> =
118
- DeepReadonly<TDoc>;
119
-
120
- /**
121
- * One normalized compiler input. Stable identity is provider + authored kind +
122
- * stable name; provider version and source bytes remain explicit provenance.
123
- */
124
- export interface AuthoredDocEntry<TDoc extends AuthoredDoc = AuthoredDoc> {
125
- readonly id: DocId;
126
- readonly provider: ProviderInstance;
127
- readonly kind: AuthoredDocKindOf<TDoc>;
128
- /** Stable provider-local key used in the DocId; it need not equal a display name. */
129
- readonly stableName: string;
130
- readonly source: AuthoredDocSource;
131
- readonly authored: AuthoredDocSnapshot<TDoc>;
132
- }
@@ -1,69 +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
- * Every `*.doc.mjs` under `root`, relative and sorted.
6
- * @param {string} [root]
7
- * @returns {string[]}
8
- */
9
- export function discoverAuthoringSelfDocSources(root?: string): string[];
10
- /**
11
- * Import each self-doc. One that fails is reported, never thrown, so one bad
12
- * file cannot take the rest of the topic down with it.
13
- * @param {string[]} [sources]
14
- * @param {string} [root]
15
- * @returns {Promise<{loaded: {source: string, doc: any}[], failed: {source: string, error: string}[]}>}
16
- */
17
- export function loadAuthoringSelfDocs(sources?: string[], root?: string): Promise<{
18
- loaded: {
19
- source: string;
20
- doc: any;
21
- }[];
22
- failed: {
23
- source: string;
24
- error: string;
25
- }[];
26
- }>;
27
- /**
28
- * The `authoring` topic: one section per self-doc, in the order given.
29
- * @param {any[]} docs
30
- * @returns {import('../../authoring/doctypes/reference/type').ReferenceDoc}
31
- */
32
- export function buildAuthoringReferenceDoc(docs: any[]): import("../../authoring/doctypes/reference/type").ReferenceDoc;
33
- /**
34
- * The `authoring` topic from every self-doc that loads. One that fails is left
35
- * out here and reported by {@link auditAuthoringSelfDocs}.
36
- * @returns {Promise<import('../../authoring/doctypes/reference/type').ReferenceDoc>}
37
- */
38
- export function buildAuthoringTopic(): Promise<import("../../authoring/doctypes/reference/type").ReferenceDoc>;
39
- /**
40
- * What stands between a self-doc and a reader of `astryx docs authoring`.
41
- * @param {{root?: string, sources?: string[], budget?: number}} [options]
42
- * @returns {Promise<{
43
- * sections: number,
44
- * unreachable: string[],
45
- * failed: {source: string, error: string}[],
46
- * oversized: {key: string, title: string, bytes: number}[],
47
- * }>}
48
- */
49
- export function auditAuthoringSelfDocs({ root, sources, budget, }?: {
50
- root?: string;
51
- sources?: string[];
52
- budget?: number;
53
- }): Promise<{
54
- sections: number;
55
- unreachable: string[];
56
- failed: {
57
- source: string;
58
- error: string;
59
- }[];
60
- oversized: {
61
- key: string;
62
- title: string;
63
- bytes: number;
64
- }[];
65
- }>;
66
- /** The directory the self-docs live under. */
67
- export const AUTHORING_ROOT: string;
68
- /** Every authoring self-doc, relative to {@link AUTHORING_ROOT}, in reading order. */
69
- export const AUTHORING_SELF_DOCS: string[];
@@ -1,214 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file The authoring self-docs, and the `authoring` topic built from them.
5
- *
6
- * @input The SchemaDoc each authoring module colocates as `*.doc.mjs` under
7
- * packages/cli/authoring.
8
- * @output {@link AUTHORING_SELF_DOCS} (every self-doc, in reading order), the
9
- * `authoring` reference topic with one section per self-doc, and an audit
10
- * naming any self-doc the topic cannot reach, any that fails to load, and any
11
- * section over the docs output budget.
12
- * @position Read by assets/docs/authoring.doc.mjs (the topic) and by Doctor
13
- * (the audit). Lives in foundation because authoring/ holds only contracts.
14
- * A new `*.doc.mjs` under authoring/ must be added to the list, or Doctor and
15
- * the self-doc tests fail.
16
- */
17
-
18
- import * as fs from 'node:fs';
19
- import * as path from 'node:path';
20
- import {pathToFileURL} from 'node:url';
21
- import {CLI_ROOT} from '../fs/paths.mjs';
22
- import {
23
- DOC_OUTPUT_BUDGET_BYTES,
24
- oversizedDocSections,
25
- } from './docs-output-budget.mjs';
26
-
27
- /** The directory the self-docs live under. */
28
- export const AUTHORING_ROOT = path.join(CLI_ROOT, 'authoring');
29
-
30
- /** Every authoring self-doc, relative to {@link AUTHORING_ROOT}, in reading order. */
31
- export const AUTHORING_SELF_DOCS = [
32
- 'integration/integration.doc.mjs',
33
- 'config/config.doc.mjs',
34
- 'codemod/codemod.doc.mjs',
35
- 'identity/identity.doc.mjs',
36
- 'doctypes/base/graph-fields.doc.mjs',
37
- 'doctypes/component/component.doc.mjs',
38
- 'doctypes/hook/hook.doc.mjs',
39
- 'doctypes/function/function.doc.mjs',
40
- 'doctypes/command/command.doc.mjs',
41
- 'doctypes/enum/enum.doc.mjs',
42
- 'doctypes/namespace/namespace.doc.mjs',
43
- 'doctypes/reference/reference.doc.mjs',
44
- 'doctypes/schema/schema.doc.mjs',
45
- 'doctypes/template/template.doc.mjs',
46
- ];
47
-
48
- /** Blocks a self-doc note may carry that a topic section can render. */
49
- const TOPIC_BLOCKS = new Set(['prose', 'list', 'code', 'heading', 'table']);
50
-
51
- /**
52
- * Every `*.doc.mjs` under `root`, relative and sorted.
53
- * @param {string} [root]
54
- * @returns {string[]}
55
- */
56
- export function discoverAuthoringSelfDocSources(root = AUTHORING_ROOT) {
57
- /** @type {string[]} */
58
- const found = [];
59
- /** @param {string} dir */
60
- const walk = dir => {
61
- for (const entry of fs.readdirSync(dir, {withFileTypes: true})) {
62
- if (entry.name === 'node_modules' || entry.name.startsWith('__')) continue;
63
- const full = path.join(dir, entry.name);
64
- if (entry.isDirectory()) walk(full);
65
- else if (entry.name.endsWith('.doc.mjs')) {
66
- found.push(path.relative(root, full).split(path.sep).join('/'));
67
- }
68
- }
69
- };
70
- walk(root);
71
- return found.sort();
72
- }
73
-
74
- /**
75
- * Import each self-doc. One that fails is reported, never thrown, so one bad
76
- * file cannot take the rest of the topic down with it.
77
- * @param {string[]} [sources]
78
- * @param {string} [root]
79
- * @returns {Promise<{loaded: {source: string, doc: any}[], failed: {source: string, error: string}[]}>}
80
- */
81
- export async function loadAuthoringSelfDocs(
82
- sources = AUTHORING_SELF_DOCS,
83
- root = AUTHORING_ROOT,
84
- ) {
85
- const loaded = [];
86
- const failed = [];
87
- for (const source of sources) {
88
- try {
89
- const mod = await import(pathToFileURL(path.join(root, source)).href);
90
- const doc = mod.doc ?? mod.docs ?? mod.default;
91
- if (typeof doc?.name !== 'string' || typeof doc?.description !== 'string') {
92
- throw new Error('exports no doc with a name and a description');
93
- }
94
- loaded.push({source, doc});
95
- } catch (error) {
96
- failed.push({
97
- source,
98
- error: error instanceof Error ? error.message : String(error),
99
- });
100
- }
101
- }
102
- return {loaded, failed};
103
- }
104
-
105
- /**
106
- * @param {any[]} fields
107
- * @returns {string[][]}
108
- */
109
- function fieldRows(fields) {
110
- return fields.flatMap(field => [
111
- [
112
- String(field.name),
113
- String(field.type ?? ''),
114
- field.required ? 'yes' : 'no',
115
- [
116
- field.description,
117
- field.default != null ? `Default: ${field.default}.` : null,
118
- field.example != null ? `Example: ${field.example}.` : null,
119
- ]
120
- .filter(Boolean)
121
- .join(' '),
122
- ],
123
- ...fieldRows(field.fields ?? []),
124
- ]);
125
- }
126
-
127
- /**
128
- * One self-doc as a topic section, keyed by the doc's own name.
129
- * @param {any} doc
130
- * @returns {import('../../authoring/doctypes/reference/type').ReferenceSection}
131
- */
132
- function selfDocSection(doc) {
133
- /** @type {any[]} */
134
- const content = [{type: 'prose', text: doc.description}];
135
- if (doc.appliesTo) {
136
- content.push({type: 'prose', text: `Applies to: ${doc.appliesTo}`});
137
- }
138
- const rows = fieldRows(doc.fields ?? []);
139
- if (rows.length > 0) {
140
- content.push({
141
- type: 'table',
142
- headers: ['Field', 'Type', 'Required', 'Description'],
143
- rows,
144
- });
145
- }
146
- for (const example of doc.examples ?? []) {
147
- if (typeof example?.code !== 'string' || example.code.trim() === '') continue;
148
- content.push({
149
- type: 'code',
150
- lang: example.lang ?? 'js',
151
- ...(example.label ? {label: example.label} : {}),
152
- code: example.code,
153
- });
154
- }
155
- for (const note of doc.notes ?? []) {
156
- if (TOPIC_BLOCKS.has(note?.type)) content.push(note);
157
- }
158
- return {id: doc.name, title: doc.displayName ?? doc.name, content};
159
- }
160
-
161
- /**
162
- * The `authoring` topic: one section per self-doc, in the order given.
163
- * @param {any[]} docs
164
- * @returns {import('../../authoring/doctypes/reference/type').ReferenceDoc}
165
- */
166
- export function buildAuthoringReferenceDoc(docs) {
167
- return /** @type {any} */ ({
168
- name: 'authoring',
169
- title: 'Authoring Reference',
170
- category: 'guide',
171
- description:
172
- 'Every file an integration author writes, field by field: the integration manifest, astryx.config, codemods, identity, and each doc type.',
173
- sections: docs.map(selfDocSection),
174
- });
175
- }
176
-
177
- /**
178
- * The `authoring` topic from every self-doc that loads. One that fails is left
179
- * out here and reported by {@link auditAuthoringSelfDocs}.
180
- * @returns {Promise<import('../../authoring/doctypes/reference/type').ReferenceDoc>}
181
- */
182
- export async function buildAuthoringTopic() {
183
- const {loaded} = await loadAuthoringSelfDocs();
184
- return buildAuthoringReferenceDoc(loaded.map(entry => entry.doc));
185
- }
186
-
187
- /**
188
- * What stands between a self-doc and a reader of `astryx docs authoring`.
189
- * @param {{root?: string, sources?: string[], budget?: number}} [options]
190
- * @returns {Promise<{
191
- * sections: number,
192
- * unreachable: string[],
193
- * failed: {source: string, error: string}[],
194
- * oversized: {key: string, title: string, bytes: number}[],
195
- * }>}
196
- */
197
- export async function auditAuthoringSelfDocs({
198
- root = AUTHORING_ROOT,
199
- sources = AUTHORING_SELF_DOCS,
200
- budget = DOC_OUTPUT_BUDGET_BYTES,
201
- } = {}) {
202
- const listed = new Set(sources);
203
- const unreachable = discoverAuthoringSelfDocSources(root).filter(
204
- source => !listed.has(source),
205
- );
206
- const {loaded, failed} = await loadAuthoringSelfDocs(sources, root);
207
- const topic = buildAuthoringReferenceDoc(loaded.map(entry => entry.doc));
208
- return {
209
- sections: topic.sections.length,
210
- unreachable,
211
- failed,
212
- oversized: oversizedDocSections(topic.sections, budget),
213
- };
214
- }