@astryxdesign/cli 0.7.3-canary.cbe384c → 0.7.3-canary.d421aed

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 (230) hide show
  1. package/README.md +68 -68
  2. package/api/build/_adapter.mjs +37 -25
  3. package/api/build/blocks/blocks.d.mts +68 -18
  4. package/api/build/blocks/blocks.mjs +475 -116
  5. package/api/build/blocks/blocks.test.mjs +191 -61
  6. package/api/build/blocks/blocks.weights.json +1 -1
  7. package/api/build/build.type.mjs +1 -1
  8. package/api/build/kit/answer.d.mts +9 -5
  9. package/api/build/kit/answer.mjs +123 -13
  10. package/api/build/kit/answer.test.mjs +73 -3
  11. package/api/build/kit/signals.d.mts +19 -0
  12. package/api/build/kit/signals.mjs +18 -7
  13. package/api/build/tree.mjs +2 -1
  14. package/api/build/tree.test.mjs +37 -29
  15. package/api/component/_adapter.mjs +39 -5
  16. package/api/component/component-replacement.test.mjs +1 -0
  17. package/api/component/component.mjs +17 -3
  18. package/api/component/component.test.mjs +15 -0
  19. package/api/component/doc-links.test.mjs +2 -2
  20. package/api/discover/_adapter.d.mts +1 -2
  21. package/api/discover/_adapter.mjs +6 -8
  22. package/api/discover/discover.mjs +0 -1
  23. package/api/docs/_adapter.d.mts +2 -2
  24. package/api/docs/_adapter.mjs +65 -18
  25. package/api/docs/docs-homes.test.mjs +127 -0
  26. package/api/docs/docs.doc.mjs +3 -3
  27. package/api/docs/docs.test.mjs +28 -18
  28. package/api/docs/integration-tree.test.mjs +20 -20
  29. package/api/docs/integrationDocs.test.mjs +1 -1
  30. package/api/docs/namespace-section.test.mjs +6 -6
  31. package/api/docs/reference-blocks.test.mjs +2 -2
  32. package/api/doctor/_adapter.d.mts +24 -10
  33. package/api/doctor/_adapter.mjs +28 -25
  34. package/api/doctor/doctor.d.mts +7 -4
  35. package/api/doctor/doctor.mjs +68 -26
  36. package/api/doctor/doctor.test.mjs +95 -12
  37. package/api/hook/hook.mjs +1 -1
  38. package/api/integration/_adapter.d.mts +8 -0
  39. package/api/integration/_adapter.mjs +21 -1
  40. package/api/integration/authoring-checks.test.mjs +220 -0
  41. package/api/integration/validate-integration-fixes.test.mjs +6 -5
  42. package/api/integration/validate-integration-gaps.test.mjs +12 -1
  43. package/api/integration/validate-integration.d.mts +6 -1
  44. package/api/integration/validate-integration.mjs +78 -12
  45. package/api/integration/validate-integration.type.d.mts +36 -4
  46. package/api/integration/validate-integration.type.mjs +27 -5
  47. package/api/integration/validateIntegration.doc.mjs +1 -1
  48. package/api/search/_adapter.d.mts +16 -0
  49. package/api/search/_adapter.mjs +39 -0
  50. package/api/search/_adapter.test.mjs +173 -0
  51. package/api/search/_candidate-score.mjs +1 -1
  52. package/api/search/_entries.d.mts +11 -0
  53. package/api/search/_entries.mjs +77 -3
  54. package/api/search/_entries.test.mjs +48 -0
  55. package/api/search/_gather-docs.mjs +3 -3
  56. package/api/search/search.doc.mjs +1 -1
  57. package/api/search/search.mjs +6 -2
  58. package/api/search/search.test.mjs +14 -14
  59. package/api/template/template.mjs +5 -1
  60. package/api/upgrade/_adapter.d.mts +57 -3
  61. package/api/upgrade/_adapter.mjs +149 -27
  62. package/api/upgrade/registry/registry.d.mts +10 -4
  63. package/api/upgrade/registry/registry.mjs +33 -16
  64. package/api/upgrade/registry/registry.test.mjs +85 -0
  65. package/api/upgrade/run/run.d.mts +4 -2
  66. package/api/upgrade/run/run.mjs +13 -2
  67. package/api/upgrade/run/run.test.mjs +417 -3
  68. package/api/upgrade/upgrade.doc.mjs +10 -5
  69. package/api/upgrade/upgrade.mjs +13 -2
  70. package/api/upgrade/upgrade.type.d.mts +5 -3
  71. package/api/upgrade/upgrade.type.mjs +8 -6
  72. package/assets/docs/author-a-theme.doc.mjs +2 -2
  73. package/assets/docs/tree/add-a-component.doc.mjs +1 -1
  74. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  75. package/assets/docs/tree/add-a-topic.doc.mjs +2 -2
  76. package/assets/docs/tree/agent-guidance.doc.mjs +1 -1
  77. package/assets/docs/tree/{integrations.doc.mjs → authoring.doc.mjs} +15 -6
  78. package/assets/docs/tree/block-template.doc.mjs +1 -1
  79. package/assets/docs/tree/build-the-template.doc.mjs +1 -1
  80. package/assets/docs/tree/building-blocks.doc.mjs +2 -2
  81. package/assets/docs/tree/check-the-props.doc.mjs +1 -1
  82. package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
  83. package/assets/docs/tree/checks.doc.mjs +3 -3
  84. package/assets/docs/tree/cli-command.doc.mjs +1 -1
  85. package/assets/docs/tree/cli.doc.mjs +1 -1
  86. package/assets/docs/tree/codemods.doc.mjs +1 -1
  87. package/assets/docs/tree/component-family.doc.mjs +1 -1
  88. package/assets/docs/tree/component-imports.doc.mjs +1 -1
  89. package/assets/docs/tree/components.doc.mjs +1 -1
  90. package/assets/docs/tree/configuration.doc.mjs +1 -1
  91. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
  92. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  93. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  94. package/assets/docs/tree/docs.doc.mjs +1 -1
  95. package/assets/docs/tree/document-the-template.doc.mjs +1 -1
  96. package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
  97. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  98. package/assets/docs/tree/extend-or-replace.doc.mjs +1 -1
  99. package/assets/docs/{authoring.doc.mjs → tree/field-reference.doc.mjs} +4 -3
  100. package/assets/docs/tree/fonts-and-assets.doc.mjs +1 -1
  101. package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
  102. package/assets/docs/tree/global-integrations.doc.mjs +2 -2
  103. package/assets/docs/tree/grade-template-with-agent.doc.mjs +4 -4
  104. package/assets/docs/tree/help.doc.mjs +2 -2
  105. package/assets/docs/tree/links.doc.mjs +1 -1
  106. package/assets/docs/tree/package-and-test.doc.mjs +1 -1
  107. package/assets/docs/tree/page-template.doc.mjs +1 -1
  108. package/assets/docs/tree/publishing.doc.mjs +1 -1
  109. package/assets/docs/tree/quick-start.doc.mjs +1 -1
  110. package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
  111. package/assets/docs/tree/replace-a-core-template.doc.mjs +1 -1
  112. package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
  113. package/assets/docs/tree/see-it-in-an-app.doc.mjs +1 -1
  114. package/assets/docs/tree/ship.doc.mjs +2 -2
  115. package/assets/docs/tree/short-and-findable.doc.mjs +1 -1
  116. package/assets/docs/tree/single-component.doc.mjs +1 -1
  117. package/assets/docs/tree/start-a-template.doc.mjs +1 -1
  118. package/assets/docs/tree/subcomponent.doc.mjs +1 -1
  119. package/assets/docs/tree/template-assets.doc.mjs +1 -1
  120. package/assets/docs/tree/template-doc-overview.doc.mjs +2 -2
  121. package/assets/docs/tree/template-fonts.doc.mjs +1 -1
  122. package/assets/docs/tree/template-grading-rubric.doc.mjs +1 -1
  123. package/assets/docs/tree/template-icons.doc.mjs +1 -1
  124. package/assets/docs/tree/template-images-media.doc.mjs +1 -1
  125. package/assets/docs/tree/template-styles.doc.mjs +1 -1
  126. package/assets/docs/tree/templates.doc.mjs +1 -1
  127. package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
  128. package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
  129. package/assets/docs/tree/themes.doc.mjs +1 -1
  130. package/assets/docs/tree/troubleshooting.doc.mjs +1 -1
  131. package/assets/docs/tree/upgrading.doc.mjs +1 -1
  132. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
  133. package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
  134. package/assets/docs/tree/versioning.doc.mjs +5 -1
  135. package/assets/docs/tree/write-good-templates.doc.mjs +1 -1
  136. package/assets/docs/tree/write-the-template-file.doc.mjs +1 -1
  137. package/assets/docs/use-integrations.doc.mjs +120 -0
  138. package/assets/templates/themes/butter/butterTheme.ts +4 -2
  139. package/assets/templates/themes/stone/stoneTheme.ts +4 -2
  140. package/assets/templates/themes/y2k/y2kTheme.ts +4 -2
  141. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  142. package/authoring/integration/integration.doc.mjs +1 -1
  143. package/authoring/integration/type.ts +1 -1
  144. package/clients/cli/command-result-coverage.test.mjs +6 -5
  145. package/clients/cli/commands/build-theme.color-scheme.test.mjs +1 -1
  146. package/clients/cli/commands/{component/index.mjs → component.mjs} +37 -37
  147. package/clients/cli/commands/component.test.mjs +6 -6
  148. package/clients/cli/commands/docs.doc.mjs +2 -2
  149. package/clients/cli/commands/docs.mjs +1 -1
  150. package/clients/cli/commands/docs.test.mjs +14 -14
  151. package/clients/cli/commands/doctor-integration.test.mjs +49 -1
  152. package/clients/cli/commands/doctor.mjs +10 -0
  153. package/clients/cli/commands/{hook/index.mjs → hook.mjs} +22 -22
  154. package/clients/cli/commands/import-hint-correctness.test.mjs +1 -1
  155. package/clients/cli/commands/integration-check.test.mjs +48 -0
  156. package/clients/cli/commands/integration.doc.mjs +1 -1
  157. package/clients/cli/commands/manifest.doc.mjs +1 -1
  158. package/clients/cli/commands/manifest.mjs +67 -0
  159. package/clients/cli/commands/postinstall.doc.mjs +23 -0
  160. package/clients/cli/commands/postinstall.mjs +31 -0
  161. package/clients/cli/commands/setup-nudge.test.mjs +17 -0
  162. package/clients/cli/commands/{build-theme.mjs → theme.mjs} +1 -1
  163. package/clients/cli/commands/upgrade.doc.mjs +4 -2
  164. package/clients/cli/commands/upgrade.mjs +9 -2
  165. package/clients/cli/commands/upgrade.subfolder-path.test.mjs +97 -0
  166. package/clients/cli/index.mjs +35 -93
  167. package/clients/cli/lib/component-format.mjs +1 -1
  168. package/clients/cli/lib/define-command.mjs +12 -7
  169. package/clients/cli/lib/exit-codes.test.mjs +5 -0
  170. package/clients/cli/lib/manifest.test.mjs +12 -0
  171. package/clients/cli/lib/welcome-box.mjs +50 -0
  172. package/foundation/agent-docs/agent-doc-state.d.mts +12 -0
  173. package/foundation/agent-docs/agent-doc-state.mjs +24 -2
  174. package/foundation/agent-docs/agent-docs.mjs +7 -6
  175. package/foundation/agent-docs/agent-docs.test.mjs +5 -4
  176. package/foundation/agent-docs/computer-agent-text.mjs +16 -1
  177. package/foundation/agent-docs/computer-agent-text.test.mjs +23 -2
  178. package/foundation/config/project.mjs +5 -20
  179. package/foundation/config/project.test.mjs +30 -0
  180. package/foundation/discovery/authoring-self-docs.d.mts +7 -0
  181. package/foundation/discovery/authoring-self-docs.mjs +16 -4
  182. package/foundation/discovery/authoring-self-docs.test.mjs +15 -3
  183. package/foundation/discovery/authoring-surface.d.mts +1 -1
  184. package/foundation/discovery/authoring-surface.mjs +2 -2
  185. package/foundation/discovery/authoring-surface.test.mjs +1 -1
  186. package/foundation/discovery/cli-self-docs.d.mts +2 -1
  187. package/foundation/discovery/cli-self-docs.mjs +4 -3
  188. package/foundation/discovery/cli-self-docs.test.mjs +2 -2
  189. package/foundation/discovery/runner-allowlist.d.mts +2 -4
  190. package/foundation/discovery/runner-allowlist.mjs +2 -4
  191. package/foundation/discovery/runner-commands.d.mts +77 -0
  192. package/foundation/discovery/runner-commands.mjs +294 -0
  193. package/foundation/discovery/runner-commands.test.mjs +128 -0
  194. package/foundation/discovery/stray-pointers.test.mjs +1 -1
  195. package/foundation/discovery/template-needs.mjs +1 -44
  196. package/foundation/doc-compiler/doc-loads.test.mjs +25 -9
  197. package/foundation/doc-compiler/split-topic-keywords.test.mjs +3 -2
  198. package/foundation/doc-compiler/tree.d.mts +32 -6
  199. package/foundation/doc-compiler/tree.mjs +77 -43
  200. package/foundation/doc-compiler/tree.test.mjs +7 -7
  201. package/foundation/fs/paths.d.mts +70 -8
  202. package/foundation/fs/paths.mjs +526 -35
  203. package/foundation/fs/paths.test.mjs +430 -54
  204. package/foundation/fs/read-record.d.mts +18 -0
  205. package/foundation/fs/read-record.mjs +131 -0
  206. package/foundation/fs/read-record.test.mjs +77 -0
  207. package/foundation/integrations/autolink.d.mts +2 -1
  208. package/foundation/integrations/autolink.mjs +4 -13
  209. package/foundation/integrations/cli-peer-version.d.mts +36 -0
  210. package/foundation/integrations/cli-peer-version.mjs +132 -0
  211. package/foundation/integrations/cli-peer-version.test.mjs +354 -0
  212. package/foundation/integrations/exports-subpaths.d.mts +57 -0
  213. package/foundation/integrations/exports-subpaths.mjs +113 -0
  214. package/foundation/integrations/integrations.d.mts +11 -0
  215. package/foundation/integrations/integrations.mjs +21 -1
  216. package/foundation/integrations/public-imports.d.mts +118 -0
  217. package/foundation/integrations/public-imports.mjs +1769 -0
  218. package/foundation/integrations/public-imports.test.mjs +1793 -0
  219. package/foundation/release/global-state.d.mts +8 -4
  220. package/foundation/release/global-state.mjs +4 -2
  221. package/foundation/release/notices.d.mts +62 -8
  222. package/foundation/release/notices.mjs +136 -25
  223. package/foundation/release/notices.test.mjs +21 -0
  224. package/foundation/response/response-types.doc.mjs +1 -1
  225. package/foundation/text/string-utils.d.mts +2 -1
  226. package/foundation/text/string-utils.mjs +16 -5
  227. package/foundation/text/suggest-order.d.mts +72 -0
  228. package/foundation/text/suggest-order.mjs +363 -0
  229. package/foundation/text/suggest-order.test.mjs +259 -0
  230. package/package.json +9 -9
@@ -0,0 +1,57 @@
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
+ * @file How a package.json `exports` field declares a subpath, read without
6
+ * touching the targets (which may be build output that does not exist yet).
7
+ *
8
+ * @input A package.json `exports` value and a `.`/`./…` subpath.
9
+ * @output Whether the subpath is declared for an ES module importer, and why
10
+ * not when it is not.
11
+ * @position foundation/integrations; read by the public-import checks.
12
+ */
13
+ /** @param {unknown} value @returns {value is Record<string, unknown>} */
14
+ export function isRecord(value: unknown): value is Record<string, unknown>;
15
+ /**
16
+ * Whether an export value gives an ES module importer something: a string,
17
+ * or a condition object / fallback array with a target under a condition
18
+ * other than `require` and `types`.
19
+ * @param {unknown} value
20
+ * @returns {boolean}
21
+ */
22
+ export function importable(value: unknown): boolean;
23
+ /**
24
+ * Every string target an export value names, any condition.
25
+ * @param {unknown} value
26
+ * @param {string[]} [out]
27
+ * @returns {string[]}
28
+ */
29
+ export function allTargets(value: unknown, out?: string[]): string[];
30
+ /**
31
+ * @typedef {object} SubpathDeclaration
32
+ * @property {'declared'|'no_exports'|'root_only'|'missing'|'blocked'|'not_importable'} state
33
+ * @property {unknown} [value] the matched export value
34
+ * @property {string} [wildcard] what a `*` key matched
35
+ */
36
+ /**
37
+ * How a package's `exports` field declares one subpath, without touching the
38
+ * targets: a missing key, a key with only a `require` condition, an `exports`
39
+ * that is a bare string or a condition object (so only `.`), a wildcard that
40
+ * does not match, or a `null` that blocks it. An `exports` of `null` is no
41
+ * `exports` field, as Node reads it.
42
+ * @param {unknown} exportsField
43
+ * @param {string} subpath `.` or `./…`
44
+ * @returns {SubpathDeclaration}
45
+ */
46
+ export function subpathDeclaration(exportsField: unknown, subpath: string): SubpathDeclaration;
47
+ export type SubpathDeclaration = {
48
+ state: "declared" | "no_exports" | "root_only" | "missing" | "blocked" | "not_importable";
49
+ /**
50
+ * the matched export value
51
+ */
52
+ value?: unknown;
53
+ /**
54
+ * what a `*` key matched
55
+ */
56
+ wildcard?: string | undefined;
57
+ };
@@ -0,0 +1,113 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file How a package.json `exports` field declares a subpath, read without
5
+ * touching the targets (which may be build output that does not exist yet).
6
+ *
7
+ * @input A package.json `exports` value and a `.`/`./…` subpath.
8
+ * @output Whether the subpath is declared for an ES module importer, and why
9
+ * not when it is not.
10
+ * @position foundation/integrations; read by the public-import checks.
11
+ */
12
+
13
+ /** @param {unknown} value @returns {value is Record<string, unknown>} */
14
+ export function isRecord(value) {
15
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
16
+ }
17
+
18
+ /**
19
+ * Whether an export value gives an ES module importer something: a string,
20
+ * or a condition object / fallback array with a target under a condition
21
+ * other than `require` and `types`.
22
+ * @param {unknown} value
23
+ * @returns {boolean}
24
+ */
25
+ export function importable(value) {
26
+ if (typeof value === 'string') return true;
27
+ if (Array.isArray(value)) return value.some(importable);
28
+ if (!isRecord(value)) return false;
29
+ return Object.entries(value).some(
30
+ ([condition, target]) =>
31
+ condition !== 'require' && condition !== 'types' && importable(target),
32
+ );
33
+ }
34
+
35
+ /**
36
+ * Every string target an export value names, any condition.
37
+ * @param {unknown} value
38
+ * @param {string[]} [out]
39
+ * @returns {string[]}
40
+ */
41
+ export function allTargets(value, out = []) {
42
+ if (typeof value === 'string') out.push(value);
43
+ else if (Array.isArray(value)) for (const v of value) allTargets(v, out);
44
+ else if (isRecord(value))
45
+ for (const v of Object.values(value)) allTargets(v, out);
46
+ return out;
47
+ }
48
+
49
+ /**
50
+ * @typedef {object} SubpathDeclaration
51
+ * @property {'declared'|'no_exports'|'root_only'|'missing'|'blocked'|'not_importable'} state
52
+ * @property {unknown} [value] the matched export value
53
+ * @property {string} [wildcard] what a `*` key matched
54
+ */
55
+
56
+ /**
57
+ * How a package's `exports` field declares one subpath, without touching the
58
+ * targets: a missing key, a key with only a `require` condition, an `exports`
59
+ * that is a bare string or a condition object (so only `.`), a wildcard that
60
+ * does not match, or a `null` that blocks it. An `exports` of `null` is no
61
+ * `exports` field, as Node reads it.
62
+ * @param {unknown} exportsField
63
+ * @param {string} subpath `.` or `./…`
64
+ * @returns {SubpathDeclaration}
65
+ */
66
+ export function subpathDeclaration(exportsField, subpath) {
67
+ if (exportsField == null) return {state: 'no_exports'};
68
+ const keys = isRecord(exportsField) ? Object.keys(exportsField) : [];
69
+ // An empty object is a subpath map with no keys: it exports nothing, so
70
+ // every subpath (the root too) is missing from it.
71
+ const isMap =
72
+ isRecord(exportsField) && keys.every(key => key.startsWith('.'));
73
+ if (!isMap) {
74
+ if (subpath !== '.') return {state: 'root_only'};
75
+ return importable(exportsField)
76
+ ? {state: 'declared', value: exportsField}
77
+ : {state: 'not_importable', value: exportsField};
78
+ }
79
+ const map = /** @type {Record<string, unknown>} */ (exportsField);
80
+ /** @type {{value: unknown, wildcard: string} | null} */
81
+ let hit = null;
82
+ if (Object.hasOwn(map, subpath)) {
83
+ hit = {value: map[subpath], wildcard: ''};
84
+ } else {
85
+ const patterns = keys
86
+ .filter(key => key.split('*').length === 2)
87
+ .sort((a, b) => b.indexOf('*') - a.indexOf('*') || b.length - a.length);
88
+ for (const pattern of patterns) {
89
+ const star = pattern.indexOf('*');
90
+ const prefix = pattern.slice(0, star);
91
+ const suffix = pattern.slice(star + 1);
92
+ if (
93
+ subpath.length >= prefix.length + suffix.length &&
94
+ subpath.startsWith(prefix) &&
95
+ subpath.endsWith(suffix)
96
+ ) {
97
+ hit = {
98
+ value: map[pattern],
99
+ wildcard: subpath.slice(
100
+ prefix.length,
101
+ subpath.length - suffix.length,
102
+ ),
103
+ };
104
+ break;
105
+ }
106
+ }
107
+ }
108
+ if (!hit) return {state: 'missing'};
109
+ if (hit.value == null) return {state: 'blocked'};
110
+ if (!importable(hit.value))
111
+ return {state: 'not_importable', value: hit.value, wildcard: hit.wildcard};
112
+ return {state: 'declared', value: hit.value, wildcard: hit.wildcard};
113
+ }
@@ -80,6 +80,17 @@ export function loadManifestObject(file: string, label?: string, options?: {
80
80
  * @param {string} [cwd]
81
81
  */
82
82
  export function resolvePackageDir(packageName: string, cwd?: string): string;
83
+ /**
84
+ * Where an integration named in astryx.config is installed: the nearest
85
+ * `node_modules/<name>` at or above `cwd`, found the way an autolinked
86
+ * dependency is, so a package a workspace hoists to its root loads in every
87
+ * member. When it is installed nowhere, `cwd`'s own `node_modules/<name>`,
88
+ * which the caller reports as not installed.
89
+ * @param {string} packageName
90
+ * @param {string} [cwd]
91
+ * @returns {string}
92
+ */
93
+ export function resolveInstalledIntegrationDir(packageName: string, cwd?: string): string;
83
94
  /**
84
95
  * Load the integration package rooted at `packageDir` directly, without first
85
96
  * installing or publishing it. This is the self-resolution seam: an author in
@@ -19,6 +19,7 @@
19
19
  import * as fs from 'node:fs';
20
20
  import * as path from 'node:path';
21
21
  import {assertWithin} from '../fs/path-safety.mjs';
22
+ import {findNodeModulesPackage} from '../fs/paths.mjs';
22
23
  import {normalizeProviderId} from '../identity/provider-identity.mjs';
23
24
  // The key census and contribution parsers are internal to the schema module on
24
25
  // purpose: the public parser still validates the complete authored type, while
@@ -368,6 +369,25 @@ export function resolvePackageDir(packageName, cwd = process.cwd()) {
368
369
  return dir;
369
370
  }
370
371
 
372
+ /**
373
+ * Where an integration named in astryx.config is installed: the nearest
374
+ * `node_modules/<name>` at or above `cwd`, found the way an autolinked
375
+ * dependency is, so a package a workspace hoists to its root loads in every
376
+ * member. When it is installed nowhere, `cwd`'s own `node_modules/<name>`,
377
+ * which the caller reports as not installed.
378
+ * @param {string} packageName
379
+ * @param {string} [cwd]
380
+ * @returns {string}
381
+ */
382
+ export function resolveInstalledIntegrationDir(
383
+ packageName,
384
+ cwd = process.cwd(),
385
+ ) {
386
+ // Validates the name first: it throws on a spec with path segments.
387
+ const ownDir = resolvePackageDir(packageName, cwd);
388
+ return findNodeModulesPackage(cwd, packageName)?.packageDir ?? ownDir;
389
+ }
390
+
371
391
  /**
372
392
  * Find the single conventional root manifest sibling of the package's
373
393
  * package.json. Multiple present is a hard error; missing is a hard error.
@@ -531,7 +551,7 @@ export async function loadIntegrations(
531
551
  if (!spec || seenSpecs.has(spec)) continue;
532
552
  seenSpecs.add(spec);
533
553
 
534
- const packageDir = resolvePackageDir(spec, cwd);
554
+ const packageDir = resolveInstalledIntegrationDir(spec, cwd);
535
555
  const pkgPath = path.join(packageDir, 'package.json');
536
556
  let pkg;
537
557
  try {
@@ -0,0 +1,118 @@
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
+ * Split a bare specifier into its package name and `./`-prefixed subpath.
6
+ * @param {string} specifier
7
+ * @returns {{pkg: string, subpath: string} | null}
8
+ */
9
+ export function splitSpecifier(specifier: string): {
10
+ pkg: string;
11
+ subpath: string;
12
+ } | null;
13
+ /**
14
+ * Read the import statements of a module or a snippet: named, default,
15
+ * aliased, namespace and type-only. A snippet that does not parse (an example
16
+ * with elisions, say) falls back to reading `import … from '…'` lines.
17
+ * @param {string} text
18
+ * @returns {ImportStatement[]}
19
+ */
20
+ export function readImports(text: string): ImportStatement[];
21
+ /**
22
+ * Every name (runtime or type) a module exports, and whether the list is
23
+ * complete: an `export *` from another package, `export =`, or a module that
24
+ * does not parse leaves it incomplete, and then no name is judged missing.
25
+ * @param {string} file
26
+ * @param {ExportNameCache} [cache] export lists already read in this check
27
+ * @returns {{names: Set<string>, complete: boolean, types: Set<string>, typed: boolean}}
28
+ * `types`: the names exported only as types (an interface, a type alias,
29
+ * `export type`); `typed`: the list includes every type the module
30
+ * exports (TypeScript source, or a JavaScript module whose declaration
31
+ * file was read in full), so a name absent from it is absent as a type too
32
+ */
33
+ export function moduleExportNames(file: string, cache?: ExportNameCache): {
34
+ names: Set<string>;
35
+ complete: boolean;
36
+ types: Set<string>;
37
+ typed: boolean;
38
+ };
39
+ /**
40
+ * Every public-import finding for one package, as notes, and the report of
41
+ * what could not be judged. It returns no issues: the notes are listed
42
+ * only, and fail `--strict` from the next minor release.
43
+ * @param {string} packageDir
44
+ * @param {any} integration the loaded integration record
45
+ * @returns {Promise<{issues: Issue[], notes: PublicImportNote[], report: PublicImportsReport}>}
46
+ * `issues` is always empty: kept so validate's call site stays one shape
47
+ */
48
+ export function publicImportIssues(packageDir: string, integration: any): Promise<{
49
+ issues: Issue[];
50
+ notes: PublicImportNote[];
51
+ report: PublicImportsReport;
52
+ }>;
53
+ export type SubpathDeclaration = import("./exports-subpaths.mjs").SubpathDeclaration;
54
+ export type PublicImportUnchecked = import("../../api/integration/validate-integration.type.mjs").PublicImportUnchecked;
55
+ export type PublicImportsReport = import("../../api/integration/validate-integration.type.mjs").PublicImportsReport;
56
+ export type PublicImportNote = {
57
+ code: string;
58
+ message: string;
59
+ };
60
+ export type Issue = import("./issue").AstryxIntegrationIssue;
61
+ export type ImportBinding = {
62
+ /**
63
+ * the exported name (`default` for a default import)
64
+ */
65
+ imported: string;
66
+ typeOnly: boolean;
67
+ };
68
+ export type ImportStatement = {
69
+ source: string;
70
+ names: ImportBinding[];
71
+ namespace: boolean;
72
+ /**
73
+ * the whole statement is `import type`
74
+ */
75
+ typeOnly?: boolean | undefined;
76
+ };
77
+ /**
78
+ * Export lists read during one public-import check, by file. Scoped to that
79
+ * check, so a later check in the same process rereads every module.
80
+ */
81
+ export type ExportNameCache = Map<string, {
82
+ names: Set<string>;
83
+ complete: boolean;
84
+ types: Set<string>;
85
+ typed: boolean;
86
+ }>;
87
+ export type Context = {
88
+ packageDir: string;
89
+ /**
90
+ * the package name; null when package.json has
91
+ * none, and then no import of the package's own name is judged
92
+ */
93
+ name: string | null;
94
+ exportsField: unknown;
95
+ coreDir: string | null;
96
+ corePkg: any;
97
+ /**
98
+ * what could not be judged
99
+ */
100
+ unchecked: PublicImportUnchecked[];
101
+ /**
102
+ * export lists read in this check
103
+ */
104
+ exportNames: ExportNameCache;
105
+ /**
106
+ * why no name is judged missing
107
+ * (a module augmentation in the package); null when none, unset until read
108
+ */
109
+ augmentation?: string | null | undefined;
110
+ /**
111
+ * the package.json `files` entries, normalized
112
+ */
113
+ files: string[];
114
+ /**
115
+ * the integration's contribution roots, absolute
116
+ */
117
+ roots: string[];
118
+ };