@astryxdesign/cli 0.7.11 → 0.7.12-canary.07e325e

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 (143) hide show
  1. package/api/build/kit/rank.mjs +21 -4
  2. package/api/build/kit/words.d.mts +1 -0
  3. package/api/build/kit/words.mjs +1 -1
  4. package/api/component/__fixtures__/resolutions/modules.txt +5 -5
  5. package/api/docs/_adapter.d.mts +22 -0
  6. package/api/docs/_adapter.mjs +81 -3
  7. package/api/docs/docs.doc.mjs +5 -5
  8. package/api/docs/docs.type.d.mts +21 -0
  9. package/api/docs/docs.type.mjs +11 -0
  10. package/api/docs/list/list.d.mts +5 -1
  11. package/api/docs/list/list.mjs +72 -6
  12. package/api/docs/node/node.mjs +2 -40
  13. package/api/icon/_adapter.d.mts +3 -2
  14. package/api/icon/_adapter.mjs +8 -2
  15. package/api/icon/_authoring.d.mts +1 -0
  16. package/api/icon/_authoring.mjs +586 -66
  17. package/api/icon/_default-look.d.mts +155 -0
  18. package/api/icon/_default-look.mjs +474 -0
  19. package/api/icon/_records.d.mts +1 -1
  20. package/api/icon/_records.mjs +1 -0
  21. package/api/icon/add/add.mjs +224 -38
  22. package/api/icon/icon.type.d.mts +22 -2
  23. package/api/icon/icon.type.mjs +6 -2
  24. package/api/icon/iconAdd.doc.mjs +2 -2
  25. package/api/icon/iconNewDefinition.doc.mjs +3 -2
  26. package/api/icon/iconNewSet.doc.mjs +4 -4
  27. package/api/icon/search/search.mjs +10 -9
  28. package/api/index.d.mts +1 -0
  29. package/api/index.mjs +1 -0
  30. package/api/integration/add-helpers.d.mts +11 -1
  31. package/api/integration/add-helpers.mjs +5 -2
  32. package/api/integration/authoring-checks.d.mts +0 -2
  33. package/api/integration/authoring-checks.mjs +1 -6
  34. package/api/logger.mjs +2 -1
  35. package/api/render/_adapter.mjs +9 -0
  36. package/api/render/render.doc.mjs +2 -2
  37. package/api/search/_adapter.d.mts +22 -1
  38. package/api/search/_adapter.mjs +37 -20
  39. package/api/search/exportSearchIndex.doc.d.mts +10 -0
  40. package/api/search/exportSearchIndex.doc.mjs +58 -0
  41. package/api/search/rankSearchIndex.doc.d.mts +10 -0
  42. package/api/search/rankSearchIndex.doc.mjs +79 -0
  43. package/api/search/search-index.d.mts +44 -0
  44. package/api/search/search-index.mjs +270 -0
  45. package/api/search/search.type.d.mts +28 -0
  46. package/api/search/search.type.mjs +17 -0
  47. package/api/swizzle/_adapter.d.mts +1 -0
  48. package/api/swizzle/_adapter.mjs +4 -1
  49. package/api/swizzle/_moduleGraph.d.mts +178 -0
  50. package/api/swizzle/_moduleGraph.mjs +903 -0
  51. package/api/swizzle/copy/copy.d.mts +2 -43
  52. package/api/swizzle/copy/copy.mjs +287 -315
  53. package/api/swizzle/swizzle.d.mts +0 -2
  54. package/api/swizzle/swizzle.doc.mjs +13 -4
  55. package/api/swizzle/swizzle.mjs +3 -7
  56. package/api/swizzle/swizzle.type.d.mts +7 -1
  57. package/api/swizzle/swizzle.type.mjs +4 -2
  58. package/api/template/template.mjs +1 -0
  59. package/assets/discover/official-packages.json +36 -0
  60. package/assets/docs/browser-support.doc.mjs +2 -2
  61. package/assets/docs/styling-overview.doc.mjs +6 -2
  62. package/assets/docs/tree/icon-sets.doc.mjs +11 -5
  63. package/assets/docs/tree/render-pages.doc.mjs +2 -2
  64. package/assets/docs/tree/tailwind.doc.mjs +41 -1
  65. package/assets/docs/tree/type-scale.doc.mjs +19 -2
  66. package/assets/templates/blocks/components/Calendar/useCalendarConstraintsHookUsage.doc.mjs +14 -0
  67. package/assets/templates/blocks/components/Calendar/useCalendarConstraintsHookUsage.tsx +146 -0
  68. package/assets/templates/blocks/components/Calendar/useCalendarNavigationHookUsage.doc.mjs +14 -0
  69. package/assets/templates/blocks/components/Calendar/useCalendarNavigationHookUsage.tsx +173 -0
  70. package/assets/templates/blocks/components/Hooks/useInputStatusIconHookUsage.tsx +1 -0
  71. package/assets/templates/blocks/components/Hooks/useInteractiveRoleHookUsage.doc.mjs +14 -0
  72. package/assets/templates/blocks/components/Hooks/useInteractiveRoleHookUsage.tsx +56 -0
  73. package/assets/templates/blocks/components/Hooks/useStreamingTextHookUsage.doc.mjs +2 -2
  74. package/assets/templates/blocks/components/Hooks/useStreamingTextHookUsage.tsx +66 -10
  75. package/assets/templates/blocks/components/Link/useLinkifyHookUsage.doc.mjs +14 -0
  76. package/assets/templates/blocks/components/Link/useLinkifyHookUsage.tsx +39 -0
  77. package/assets/templates/blocks/components/PowerSearch/usePowerSearchConfigHookUsage.doc.mjs +14 -0
  78. package/assets/templates/blocks/components/PowerSearch/usePowerSearchConfigHookUsage.tsx +83 -0
  79. package/assets/templates/blocks/components/Table/RowsVirtualizationHookUsage.doc.mjs +14 -0
  80. package/assets/templates/blocks/components/Table/RowsVirtualizationHookUsage.tsx +35 -0
  81. package/assets/templates/blocks/components/Table/TableRowIndexTable.doc.mjs +1 -1
  82. package/assets/templates/blocks/components/Table/TableRowIndexTable.tsx +2 -2
  83. package/assets/templates/blocks/components/Table/useTableColumnSettingsStateHookUsage.doc.mjs +14 -0
  84. package/assets/templates/blocks/components/Table/useTableColumnSettingsStateHookUsage.tsx +97 -0
  85. package/assets/templates/pages/course-detail/page.tsx +699 -0
  86. package/assets/templates/pages/course-detail/template.doc.mjs +37 -0
  87. package/assets/templates/pages/file-explorer/page.tsx +103 -79
  88. package/assets/templates/pages/table-filter/page.tsx +15 -23
  89. package/assets/templates/pages/table-grouped/page.tsx +160 -232
  90. package/assets/templates/pages/table-grouped/template.doc.mjs +0 -2
  91. package/assets/templates/pages/table-inbox/page.tsx +3 -6
  92. package/assets/templates/pages/theme-showcase/page.tsx +724 -792
  93. package/assets/templates/pages/theme-showcase/template.doc.mjs +4 -5
  94. package/assets/templates/themes/butter/butterTheme.ts +2 -2
  95. package/assets/templates/themes/stone/stoneTheme.ts +1 -1
  96. package/assets/templates/themes/y2k/y2kTheme.ts +1 -1
  97. package/authoring/doctypes/template/type.ts +1 -0
  98. package/clients/cli/commands/docs.doc.mjs +5 -1
  99. package/clients/cli/commands/docs.mjs +30 -2
  100. package/clients/cli/commands/experimental/icon.mjs +31 -10
  101. package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
  102. package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +2 -1
  103. package/clients/cli/commands/experimental-icon-new-set.doc.mjs +2 -2
  104. package/clients/cli/commands/swizzle.doc.mjs +12 -3
  105. package/clients/cli/commands/swizzle.mjs +33 -9
  106. package/clients/cli/lib/resolve-theme.mjs +16 -7
  107. package/foundation/discovery/component-loader.d.mts +1 -1
  108. package/foundation/discovery/doc-types.mjs +9 -2
  109. package/foundation/discovery/hook-discovery.mjs +31 -8
  110. package/foundation/discovery/icon-ranking.d.mts +27 -3
  111. package/foundation/discovery/icon-ranking.mjs +125 -8
  112. package/foundation/discovery/icon-set-checks.mjs +44 -35
  113. package/foundation/discovery/icon-set-discovery.d.mts +13 -0
  114. package/foundation/discovery/icon-set-discovery.mjs +25 -0
  115. package/foundation/discovery/icon-set-writer.d.mts +238 -16
  116. package/foundation/discovery/icon-set-writer.mjs +676 -79
  117. package/foundation/discovery/module-exports.d.mts +3 -2
  118. package/foundation/discovery/module-exports.mjs +167 -37
  119. package/foundation/doc-compiler/import.d.mts +5 -1
  120. package/foundation/doc-compiler/import.mjs +40 -6
  121. package/foundation/fs/import-url.d.mts +20 -0
  122. package/foundation/fs/import-url.mjs +22 -0
  123. package/foundation/fs/module-loader.d.mts +24 -3
  124. package/foundation/fs/module-loader.mjs +69 -47
  125. package/foundation/fs/paths.d.mts +2 -1
  126. package/foundation/fs/paths.mjs +3 -4
  127. package/foundation/render/charts.d.mts +59 -0
  128. package/foundation/render/charts.mjs +216 -0
  129. package/foundation/render/embedded-imports.d.mts +7 -7
  130. package/foundation/render/embedded-imports.mjs +63 -54
  131. package/foundation/render/page-worker.mjs +339 -52
  132. package/foundation/render/render-page.mjs +26 -10
  133. package/foundation/render/ts-paths.d.mts +63 -0
  134. package/foundation/render/ts-paths.mjs +138 -0
  135. package/foundation/response/error-codes.doc.mjs +2 -2
  136. package/foundation/response/error-codes.mjs +3 -2
  137. package/foundation/text/levenshtein.d.mts +6 -1
  138. package/foundation/text/levenshtein.mjs +25 -9
  139. package/foundation/text/shell-arg.d.mts +14 -0
  140. package/foundation/text/shell-arg.mjs +17 -0
  141. package/foundation/text/suggest-order.d.mts +8 -1
  142. package/foundation/text/suggest-order.mjs +72 -6
  143. package/package.json +7 -6
@@ -131,7 +131,10 @@ export function packageJsonFilesUpdate(
131
131
  }
132
132
  }
133
133
 
134
- if ((pkg.exports !== undefined || createExports) && publicExports.length > 0) {
134
+ if (
135
+ (pkg.exports !== undefined || createExports) &&
136
+ publicExports.length > 0
137
+ ) {
135
138
  const authored = pkg.exports;
136
139
  /** @type {Record<string, unknown>} */
137
140
  let exportsMap;
@@ -483,7 +486,7 @@ export async function loadCurrentManifest(manifestFile, manifestExists) {
483
486
  * @param {string} manifestPath
484
487
  * @param {string[]} files
485
488
  * @param {boolean} dryRun
486
- * @returns {{type: 'integration.add', data: Omit<import('./integration-authoring.type.mjs').IntegrationAddData, 'kind'> & {kind: K, icons?: number, refreshed?: boolean, renamed?: Array<{from: string, to: string}>, mapped?: Array<{definition: string, icon: string}>, suggestions?: Array<{definition: string, icon: string, word: string}>, notes?: string[]}}}
489
+ * @returns {{type: 'integration.add', data: Omit<import('./integration-authoring.type.mjs').IntegrationAddData, 'kind'> & {kind: K, icons?: number, refreshed?: boolean, updated?: boolean, renamed?: Array<{from: string, to: string}>, moved?: Array<{id: string, from: string, to: string}>, licenseNoticeMissing?: {library: string, path: string}, mapped?: Array<{definition: string, icon: string}>, suggestions?: Array<{definition: string, icon: string, word: string}>, notes?: string[]}}}
487
490
  */
488
491
  export function receipt(kind, name, root, manifestPath, files, dryRun) {
489
492
  return {
@@ -1,8 +1,6 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
- /** @param {string} value */
5
- export function shellArg(value: string): string;
6
4
  /**
7
5
  * Find integration template ids that are also owned by Core.
8
6
  * @param {string} [pkg] Installed integration package; omit for the local package.
@@ -57,12 +57,7 @@ import {
57
57
  } from './validate-integration.mjs';
58
58
  import {rootProblem} from '../../foundation/integrations/validate-contributions.mjs';
59
59
  import {normalizeProviderId} from '../../foundation/identity/provider-identity.mjs';
60
-
61
- /** @param {string} value */
62
- export function shellArg(value) {
63
- if (/^[A-Za-z0-9@/._-]+$/.test(value)) return value;
64
- return `'${value.replace(/'/g, `'\\''`)}'`;
65
- }
60
+ import {shellArg} from '../../foundation/text/shell-arg.mjs';
66
61
 
67
62
  /**
68
63
  * The provider ID a package without a name is checked under: a valid bare
package/api/logger.mjs CHANGED
@@ -3,7 +3,8 @@
3
3
  /**
4
4
  * @file The one `Logger`. Source of truth: the `Logger` type is generated from
5
5
  * the JSDoc here, and `logger` is the single instance every side-effecting
6
- * command (`upgrade`, `init`, `themeBuild`) writes progress through.
6
+ * command (`upgrade`, `init`, `themeBuild`, the experimental icon commands)
7
+ * writes progress through.
7
8
  *
8
9
  * It is silent by default, so a programmatic caller (or `--json` mode) sees
9
10
  * nothing but the returned `{type, data}`. The CLI calls `logger.setSilent(false)`
@@ -548,6 +548,15 @@ export function reverseToFile({cwd, input, output, overwrite}) {
548
548
  ...(missing.length > 0 ? {missing} : {}),
549
549
  };
550
550
  }
551
+ // A file a render wrote, whose source block was taken out on the way
552
+ // (sanitizers and editors strip <script> elements), says so.
553
+ if (!isAstryxMarkup(html) && /<meta name="generator" content="Astryx[ "]/.test(html)) {
554
+ throw new AstryxError(
555
+ `${shown(cwd, input)} was rendered by Astryx, but its embedded source was removed (a sanitizer or an editor strips <script> blocks) and it has no Astryx components to rebuild from; nothing was written. Render the page again from its source and send the new file as is.`,
556
+ [],
557
+ ERROR_CODES.ERR_RENDER_SOURCE_DAMAGED,
558
+ );
559
+ }
551
560
  if (!isAstryxMarkup(html)) {
552
561
  throw new AstryxError(
553
562
  `${shown(cwd, input)} is not an Astryx page: it has no embedded source and no Astryx components to rebuild from. To start an Astryx page like it, run astryx build "<what the page is>".`,
@@ -99,9 +99,9 @@ export const doc = {
99
99
  {code: 'ERR_RENDER_FAILED', when: 'the page throws while rendering for any other reason'},
100
100
  {
101
101
  code: 'ERR_RENDER_NOT_ASTRYX',
102
- when: 'reversing a file with no embedded source and no Astryx markup; the suggestion is `astryx build "<what the page is>"`',
102
+ when: 'reversing a file a render did not write, with no embedded source and no Astryx markup; the suggestion is `astryx build "<what the page is>"`',
103
103
  },
104
- {code: 'ERR_RENDER_SOURCE_DAMAGED', when: 'reversing a file whose embedded source is damaged, lists a path twice, carries a module, stylesheet or JSON file the page does not reach through its imports, or an image, font or media file whose bytes are not one, or carries a file a render never embeds (a dotfile or dot-folder, `node_modules`, a package manifest, lockfile or tool configuration, or any kind but a page module, stylesheet, JSON or image)'},
104
+ {code: 'ERR_RENDER_SOURCE_DAMAGED', when: 'reversing a file a render wrote whose embedded source was removed (and that has no Astryx components to rebuild from), a file whose embedded source is damaged, lists a path twice, carries a module, stylesheet or JSON file the page does not reach through its imports, or an image, font or media file whose bytes are not one, or carries a file a render never embeds (a dotfile or dot-folder, `node_modules`, a package manifest, lockfile or tool configuration, or any kind but a page module, stylesheet, JSON or image)'},
105
105
  {code: 'ERR_PATH_TRAVERSAL', when: 'a file would be written outside the current folder (symlinks followed), or through a symbolic link: `out`, or with `reverse` the page or an embedded file; or, with `reverse`, a file other than the page would go into a folder that already exists'},
106
106
  ],
107
107
  examples: [
@@ -16,7 +16,7 @@ export function requireSearchCoreDir(cwd: string): string;
16
16
  * in the CLI's searches. A caller that runs its own operation shares it.
17
17
  *
18
18
  * @param {{cwd?: string, type?: string}} options
19
- * @returns {Promise<{all: Candidate[], components: Candidate[], searchedComponents: boolean, outside: boolean, coreSkipped: string | null}>}
19
+ * @returns {Promise<{all: Candidate[], components: Candidate[], searchedComponents: boolean, outside: boolean, coreSkipped: string | null, coreSkippedCode: string | null}>}
20
20
  */
21
21
  export function gatherCandidates(options: {
22
22
  cwd?: string;
@@ -27,7 +27,28 @@ export function gatherCandidates(options: {
27
27
  searchedComponents: boolean;
28
28
  outside: boolean;
29
29
  coreSkipped: string | null;
30
+ coreSkippedCode: string | null;
30
31
  }>;
32
+ /**
33
+ * The Core a search of `type` reads, and the domains it gathers. `astryx docs`
34
+ * reads docs without @astryxdesign/core, and `astryx theme list` reads themes
35
+ * without it, so a docs or themes search never looks for Core. Every other
36
+ * domain reads Core: the project's, else the answering release's own,
37
+ * installed into the per-user cache on first need (spec AST-081 FR3). A Core
38
+ * domain asked for by name throws the lookup's coded error. An open search
39
+ * without Core gathers the docs and themes alone and records why in
40
+ * `coreSkipped`; it never fails silently.
41
+ * @param {string | undefined} type
42
+ * @param {(cwd: string) => string} lookup finds the Core folder, or throws
43
+ * @param {string} cwd
44
+ * @returns {{coreDir: string | null, coreSkipped: string | null, coreSkippedCode: string | null, wants: (domain: string) => boolean}}
45
+ */
46
+ export function resolveSearchCore(type: string | undefined, lookup: (cwd: string) => string, cwd: string): {
47
+ coreDir: string | null;
48
+ coreSkipped: string | null;
49
+ coreSkippedCode: string | null;
50
+ wants: (domain: string) => boolean;
51
+ };
31
52
  /**
32
53
  * gatherCandidates, reused within one process: a later search in the same
33
54
  * folder, for the same `type`, ranks the candidates an earlier search
@@ -43,46 +43,62 @@ export function requireSearchCoreDir(cwd) {
43
43
  * in the CLI's searches. A caller that runs its own operation shares it.
44
44
  *
45
45
  * @param {{cwd?: string, type?: string}} options
46
- * @returns {Promise<{all: Candidate[], components: Candidate[], searchedComponents: boolean, outside: boolean, coreSkipped: string | null}>}
46
+ * @returns {Promise<{all: Candidate[], components: Candidate[], searchedComponents: boolean, outside: boolean, coreSkipped: string | null, coreSkippedCode: string | null}>}
47
47
  */
48
48
  export function gatherCandidates(options) {
49
49
  return withListingCache(() => gatherDomains(options));
50
50
  }
51
51
 
52
52
  /**
53
- * @param {{cwd?: string, type?: string}} options
53
+ * The Core a search of `type` reads, and the domains it gathers. `astryx docs`
54
+ * reads docs without @astryxdesign/core, and `astryx theme list` reads themes
55
+ * without it, so a docs or themes search never looks for Core. Every other
56
+ * domain reads Core: the project's, else the answering release's own,
57
+ * installed into the per-user cache on first need (spec AST-081 FR3). A Core
58
+ * domain asked for by name throws the lookup's coded error. An open search
59
+ * without Core gathers the docs and themes alone and records why in
60
+ * `coreSkipped`; it never fails silently.
61
+ * @param {string | undefined} type
62
+ * @param {(cwd: string) => string} lookup finds the Core folder, or throws
63
+ * @param {string} cwd
64
+ * @returns {{coreDir: string | null, coreSkipped: string | null, coreSkippedCode: string | null, wants: (domain: string) => boolean}}
54
65
  */
55
- async function gatherDomains(options) {
56
- const {cwd = process.cwd(), type} = options;
57
- // `astryx docs` reads docs without @astryxdesign/core, and `astryx theme
58
- // list` reads themes without it (bundled themes need no project), so a
59
- // search of either must too. Every other domain reads core: asked for by
60
- // name, it is an error without core; an open search then covers the docs
61
- // and themes alone.
66
+ export function resolveSearchCore(type, lookup, cwd) {
62
67
  const needsCore = !type || !CORELESS_DOMAINS.includes(type);
63
- // A domain that reads Core gets it as `component` does: the project's, else
64
- // the answering release's own, installed into the per-user cache on first
65
- // need (spec AST-081 FR3). Asked for by name, a Core that cannot be had is
66
- // the error; an open search answers from the rest and says what it skipped
67
- // and why, never silently.
68
68
  /** @type {string | null} */
69
69
  let coreDir = null;
70
70
  /** @type {string | null} */
71
71
  let coreSkipped = null;
72
+ /** @type {string | null} */
73
+ let coreSkippedCode = null;
72
74
  if (needsCore && type) {
73
- coreDir = coreDirOrThrow(requireSearchCoreDir, cwd);
75
+ coreDir = coreDirOrThrow(lookup, cwd);
74
76
  } else if (needsCore) {
75
77
  try {
76
- coreDir = requireSearchCoreDir(cwd);
78
+ coreDir = lookup(cwd);
77
79
  } catch (error) {
78
80
  coreSkipped = /** @type {Error} */ (error).message;
81
+ const code = /** @type {any} */ (error)?.code;
82
+ coreSkippedCode = typeof code === 'string' ? code : null;
79
83
  }
80
84
  }
85
+ /** @param {string} domain */
86
+ const wants = domain =>
87
+ (!type && (coreDir != null || CORELESS_DOMAINS.includes(domain))) ||
88
+ type === domain;
89
+ return {coreDir, coreSkipped, coreSkippedCode, wants};
90
+ }
81
91
 
82
- // Gather candidates from each requested domain in parallel.
83
- /** @param {string} d */
84
- const wants = d =>
85
- (!type && (coreDir != null || CORELESS_DOMAINS.includes(d))) || type === d;
92
+ /**
93
+ * @param {{cwd?: string, type?: string}} options
94
+ */
95
+ async function gatherDomains(options) {
96
+ const {cwd = process.cwd(), type} = options;
97
+ const {coreDir, coreSkipped, coreSkippedCode, wants} = resolveSearchCore(
98
+ type,
99
+ requireSearchCoreDir,
100
+ cwd,
101
+ );
86
102
  const [components, hooks, docTopics, templates, themes] = await Promise.all([
87
103
  wants('component')
88
104
  ? gatherComponents(/** @type {string} */ (coreDir), cwd)
@@ -103,6 +119,7 @@ async function gatherDomains(options) {
103
119
  searchedComponents: wants('component'),
104
120
  outside,
105
121
  coreSkipped,
122
+ coreSkippedCode,
106
123
  };
107
124
  }
108
125
 
@@ -0,0 +1,10 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * @file FunctionDoc for `exportSearchIndex()`. Colocated with the API function it
6
+ * documents; the shape source of truth stays in `search.type.mjs`.
7
+ * @position packages/cli/api/search — function documentation
8
+ */
9
+ /** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
10
+ export const doc: import("@astryxdesign/cli/authoring").FunctionDoc;
@@ -0,0 +1,58 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file FunctionDoc for `exportSearchIndex()`. Colocated with the API function it
5
+ * documents; the shape source of truth stays in `search.type.mjs`.
6
+ * @position packages/cli/api/search — function documentation
7
+ */
8
+
9
+ /** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
10
+ export const doc = {
11
+ type: 'function',
12
+ kind: 'api',
13
+ name: 'exportSearchIndex',
14
+ namespace: 'cli/api',
15
+ stability: 'experimental',
16
+ displayName: 'exportSearchIndex()',
17
+ summary:
18
+ 'The candidates search ranks in a folder, as plain JSON to store and rank later with rankSearchIndex().',
19
+ description:
20
+ "Gathers what `search()` would rank in `cwd` and returns it as `{version, candidates}`. Gathering reads each installed package's docs and loads its integration manifest, which runs that package's code, so a catalog that lists packages it must not load makes the index where loading is safe (a folder with those packages installed), stores it, and ranks it with {@link function:rankSearchIndex}. With `package`, the index keeps only that package's candidates, for a catalog that stores one index per package. A component description's inline doc tokens are resolved where the index is made, as `search` prints them; when Core could not be had there, the index says why in `coreSkipped`. Fields that point into the folder are left out, so an index reads the same wherever it was made. The candidates are the ranker's input, not a stable shape: an index is ranked only by the CLI version that made it. Experimental: it may change or be removed in a patch release.",
21
+ importPath: '@astryxdesign/cli/api',
22
+ signature: 'exportSearchIndex(options?: {cwd?: string, package?: string}): Promise<SearchIndex>',
23
+ keywords: ['search index', 'stored search index'],
24
+ params: [
25
+ {
26
+ name: 'options.cwd',
27
+ type: 'string',
28
+ description: 'The folder to gather from, read as `search()` reads it.',
29
+ default: 'process.cwd()',
30
+ },
31
+ {
32
+ name: 'options.package',
33
+ type: 'string',
34
+ description:
35
+ "Keep only the candidates this npm package owns: its components, templates, themes, and doc parts. Without it the index holds everything the folder's search ranks, Core's entries and the CLI's docs included.",
36
+ },
37
+ ],
38
+ returns: [
39
+ {
40
+ type: 'SearchIndex',
41
+ description:
42
+ '`version`, the CLI version that made it, and `candidates`, the gathered entries as plain JSON.',
43
+ },
44
+ ],
45
+ throws: [
46
+ {
47
+ code: 'ERR_INVALID_ARGUMENT',
48
+ when: '`package` is given and is not a non-empty string',
49
+ },
50
+ ],
51
+ examples: [
52
+ {
53
+ label: 'Index one installed integration',
54
+ code: "const index = await exportSearchIndex({cwd: '/tmp/harness', package: '@acme/ui'});",
55
+ },
56
+ ],
57
+ related: ['search', 'rankSearchIndex'],
58
+ };
@@ -0,0 +1,10 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * @file FunctionDoc for `rankSearchIndex()`. Colocated with the API function it
6
+ * documents; the shape source of truth stays in `search.type.mjs`.
7
+ * @position packages/cli/api/search — function documentation
8
+ */
9
+ /** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
10
+ export const doc: import("@astryxdesign/cli/authoring").FunctionDoc;
@@ -0,0 +1,79 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file FunctionDoc for `rankSearchIndex()`. Colocated with the API function it
5
+ * documents; the shape source of truth stays in `search.type.mjs`.
6
+ * @position packages/cli/api/search — function documentation
7
+ */
8
+
9
+ /** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
10
+ export const doc = {
11
+ type: 'function',
12
+ kind: 'api',
13
+ name: 'rankSearchIndex',
14
+ namespace: 'cli/api',
15
+ stability: 'experimental',
16
+ displayName: 'rankSearchIndex()',
17
+ summary:
18
+ "Ranks stored search indexes with search's own tree: an index made in one folder answers as search() does there.",
19
+ description:
20
+ "Ranks the candidates of every index together, with the same tree, weights, and order as {@link function:search}. An index made with `exportSearchIndex()` in one folder ranks exactly as `search(query)` does in that folder: the same results, order, and scores. Indexes made in separate folders are ranked together as one list; a doc that one package replaces or extends in another is not merged across them, so a project's own `search` can differ where that happens. A theme result's command is the in-project `theme add`. When every index was made where Core could not be had, an open rank (no `type`) carries `meta.partial`, as `search` does; a rank of `type` `component`, `hook`, or `template` throws the error `search` throws there. Every index must come from this CLI's version, because the candidates' shape is the ranker's input. Experimental: it may change or be removed in a patch release.",
21
+ importPath: '@astryxdesign/cli/api',
22
+ signature:
23
+ 'rankSearchIndex(query: string, indexes: SearchIndex | SearchIndex[], options?: {type?: SearchDomain, limit?: number}): Promise<SearchResponse>',
24
+ keywords: ['search index', 'stored search index'],
25
+ params: [
26
+ {
27
+ name: 'query',
28
+ type: 'string',
29
+ description: 'Free-text search term.',
30
+ required: true,
31
+ },
32
+ {
33
+ name: 'indexes',
34
+ type: 'SearchIndex | SearchIndex[]',
35
+ description:
36
+ 'Indexes made by `exportSearchIndex()` with this CLI version.',
37
+ required: true,
38
+ },
39
+ {
40
+ name: 'options.type',
41
+ type: "'component' | 'hook' | 'doc' | 'template' | 'theme'",
42
+ description: 'Restrict results to a single domain.',
43
+ },
44
+ {
45
+ name: 'options.limit',
46
+ type: 'number',
47
+ description: 'Maximum number of results.',
48
+ default: '20',
49
+ },
50
+ ],
51
+ returns: [
52
+ {
53
+ type: 'search',
54
+ description:
55
+ 'The same response as `search()`: the query, `matchCount`, and the ranked results bounded by `limit`.',
56
+ },
57
+ ],
58
+ throws: [
59
+ {
60
+ code: 'ERR_INVALID_ARGUMENT',
61
+ when: 'the query is empty, `type` is unknown, `limit` is not a positive integer, an index is not `{version, candidates}`, or an index was made by another CLI version',
62
+ },
63
+ {
64
+ code: 'ERR_CORE_NOT_FOUND',
65
+ when: 'every index was made where @astryxdesign/core could not be found, and `type` names a domain that reads it: `component`, `hook`, or `template`',
66
+ },
67
+ {
68
+ code: 'ERR_VERSIONS_UNAVAILABLE',
69
+ when: 'every index was made where the Core of the release that answers could not be installed into the per-user cache, and `type` names a domain that reads it: `component`, `hook`, or `template`; a rank with no `type` answers with `meta.partial` instead',
70
+ },
71
+ ],
72
+ examples: [
73
+ {
74
+ label: 'Rank stored indexes',
75
+ code: 'const r = await rankSearchIndex(text, [coreIndex, ...packageIndexes]);',
76
+ },
77
+ ],
78
+ related: ['search', 'exportSearchIndex'],
79
+ };
@@ -0,0 +1,44 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * The candidates `search` ranks in a folder, as plain JSON: store it, and rank
6
+ * it later with {@link rankSearchIndex}.
7
+ *
8
+ * Experimental (spec:AST-017 FR27): may change or be removed in a patch
9
+ * release.
10
+ * @experimental
11
+ * @param {object} [options]
12
+ * @param {string} [options.cwd] - The folder to gather from, as `search` reads it.
13
+ * @param {string} [options.package] - Keep only the candidates this npm package
14
+ * owns (its components, templates, themes, and doc parts).
15
+ * @returns {Promise<import('./search.type.mjs').SearchIndex>}
16
+ */
17
+ export function exportSearchIndex(options?: {
18
+ cwd?: string | undefined;
19
+ package?: string | undefined;
20
+ }): Promise<import("./search.type.mjs").SearchIndex>;
21
+ /**
22
+ * Ranks stored indexes with search's tree. An index made in one folder answers
23
+ * as `search(query)` does there (a theme result's command is the in-project
24
+ * `theme add`). Indexes made in separate folders, such as one per package
25
+ * (made with `package`) and one for Core, are ranked together as one list; a
26
+ * doc that one package replaces or extends in another is not merged across
27
+ * them. Every index must come from this CLI's version, since the tree reads
28
+ * the candidates' shape. When every index was made where Core could not be
29
+ * had, the answer carries `meta.partial`, as `search` does.
30
+ *
31
+ * Experimental (spec:AST-017 FR27): may change or be removed in a patch
32
+ * release.
33
+ * @experimental
34
+ * @param {string} query - Free-text search term.
35
+ * @param {import('./search.type.mjs').SearchIndex | import('./search.type.mjs').SearchIndex[]} indexes
36
+ * @param {object} [options]
37
+ * @param {import('./search.type.mjs').SearchDomain} [options.type] - Restrict to one domain.
38
+ * @param {number} [options.limit] - Max results (default 20).
39
+ * @returns {Promise<import('./search.type.mjs').SearchResponse>}
40
+ */
41
+ export function rankSearchIndex(query: string, indexes: import("./search.type.mjs").SearchIndex | import("./search.type.mjs").SearchIndex[], options?: {
42
+ type?: import("./search.type.mjs").SearchDomain | undefined;
43
+ limit?: number | undefined;
44
+ }): Promise<import("./search.type.mjs").SearchResponse>;