@astryxdesign/cli 0.6.4-canary.ed2e54e → 0.6.4

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 (145) hide show
  1. package/README.md +66 -64
  2. package/api/component/_adapter.d.mts +0 -25
  3. package/api/component/_adapter.mjs +5 -59
  4. package/api/component/component.d.mts +3 -6
  5. package/api/component/component.doc.mjs +10 -23
  6. package/api/component/component.mjs +9 -249
  7. package/api/component/component.type.d.mts +0 -25
  8. package/api/component/component.type.mjs +0 -44
  9. package/api/discover/_adapter.d.mts +6 -114
  10. package/api/discover/_adapter.mjs +17 -372
  11. package/api/discover/detail/detail.d.mts +6 -18
  12. package/api/discover/detail/detail.mjs +13 -67
  13. package/api/discover/detail/detail.test.mjs +0 -85
  14. package/api/discover/discover.d.mts +9 -3
  15. package/api/discover/discover.doc.mjs +18 -61
  16. package/api/discover/discover.mjs +36 -220
  17. package/api/discover/discover.test.mjs +2 -11
  18. package/api/discover/discover.type.d.mts +8 -147
  19. package/api/discover/discover.type.mjs +12 -102
  20. package/api/discover/list/list.d.mts +6 -20
  21. package/api/discover/list/list.mjs +12 -45
  22. package/api/discover/list/list.test.mjs +0 -46
  23. package/api/discover/search/search.d.mts +16 -18
  24. package/api/discover/search/search.mjs +56 -102
  25. package/api/discover/search/search.test.mjs +10 -144
  26. package/api/docs/docs.test.mjs +0 -2
  27. package/api/doctor/doctor.d.mts +3 -8
  28. package/api/doctor/doctor.mjs +9 -90
  29. package/api/doctor/doctor.test.mjs +10 -122
  30. package/api/index.d.mts +2 -1
  31. package/api/index.mjs +4 -4
  32. package/api/integration/add-helpers.d.mts +2 -5
  33. package/api/integration/add-helpers.mjs +9 -36
  34. package/api/integration/pack-check.mjs +3 -28
  35. package/api/json/index.ts +1 -0
  36. package/api/layout/_adapter.d.mts +34 -0
  37. package/api/layout/_adapter.mjs +148 -0
  38. package/api/layout/check/check.d.mts +16 -0
  39. package/api/layout/check/check.mjs +40 -0
  40. package/api/layout/expand/expand.d.mts +22 -0
  41. package/api/layout/expand/expand.mjs +155 -0
  42. package/api/layout/expand/expand.path-safety.test.mjs +53 -0
  43. package/api/layout/grammar/grammar.d.mts +13 -0
  44. package/api/layout/grammar/grammar.mjs +87 -0
  45. package/api/layout/layout.d.mts +6 -0
  46. package/api/layout/layout.mjs +17 -0
  47. package/api/layout/layout.test.mjs +297 -0
  48. package/api/layout/layout.type.d.mts +89 -0
  49. package/api/layout/layout.type.mjs +103 -0
  50. package/api/layout/layoutCheck.doc.d.mts +11 -0
  51. package/api/layout/layoutCheck.doc.mjs +85 -0
  52. package/api/layout/layoutExpand.doc.d.mts +11 -0
  53. package/api/layout/layoutExpand.doc.mjs +107 -0
  54. package/api/layout/layoutGrammar.doc.d.mts +11 -0
  55. package/api/layout/layoutGrammar.doc.mjs +57 -0
  56. package/api/search/search.test.mjs +0 -18
  57. package/api/template/template-integration.test.mjs +65 -1
  58. package/api/template/template.mjs +1 -1
  59. package/api/theme/add/add.mjs +25 -17
  60. package/api/theme/add/add.staging.test.mjs +23 -40
  61. package/api/theme/build/build.family.test.mjs +12 -7
  62. package/api/theme/build/build.mjs +18 -8
  63. package/api/upgrade/run/run.mjs +4 -6
  64. package/api/upgrade/upgrade.type.mjs +2 -2
  65. package/assets/codemods/__tests__/runner.test.mjs +1 -3
  66. package/assets/codemods/integration-runner.mjs +3 -3
  67. package/assets/codemods/runner.mjs +4 -5
  68. package/assets/docs/internationalization.doc.mjs +5 -7
  69. package/assets/docs/tree/integrations.doc.mjs +1 -20
  70. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +1 -1
  71. package/authoring/config/config.doc.mjs +1 -9
  72. package/authoring/config/parse.d.mts +0 -2
  73. package/authoring/config/parse.mjs +0 -19
  74. package/authoring/config/parse.test.mjs +0 -8
  75. package/authoring/config/type.ts +2 -13
  76. package/authoring/doctypes/command/command.doc.mjs +1 -1
  77. package/authoring/doctypes/command/type.ts +1 -1
  78. package/authoring/index.d.mts +0 -1
  79. package/authoring/index.d.ts +0 -10
  80. package/authoring/index.mjs +0 -1
  81. package/clients/cli/command-result-coverage.test.mjs +7 -7
  82. package/clients/cli/commands/component/index.mjs +55 -152
  83. package/clients/cli/commands/component-ownership.test.mjs +0 -89
  84. package/clients/cli/commands/component.doc.mjs +6 -23
  85. package/clients/cli/commands/debug-result-summary.test.mjs +2 -2
  86. package/clients/cli/commands/discover.doc.mjs +9 -53
  87. package/clients/cli/commands/discover.mjs +118 -393
  88. package/clients/cli/commands/docs.test.mjs +0 -29
  89. package/clients/cli/commands/layout-check.doc.mjs +65 -0
  90. package/clients/cli/commands/layout-expand.doc.mjs +83 -0
  91. package/clients/cli/commands/layout-grammar.doc.mjs +30 -0
  92. package/clients/cli/commands/layout.doc.mjs +34 -0
  93. package/clients/cli/commands/layout.error-codes.test.mjs +66 -0
  94. package/clients/cli/commands/layout.exit-parity.test.mjs +41 -0
  95. package/clients/cli/commands/layout.mjs +275 -0
  96. package/clients/cli/commands/layout.path-help.test.mjs +33 -0
  97. package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
  98. package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
  99. package/clients/cli/commands/text-json-parity.test.mjs +17 -0
  100. package/clients/cli/index.mjs +4 -0
  101. package/clients/cli/lib/exit-codes.test.mjs +8 -1
  102. package/clients/cli/lib/json-shim.mjs +14 -24
  103. package/clients/cli/lib/json-shim.test.mjs +20 -6
  104. package/clients/cli/lib/manifest.mjs +8 -3
  105. package/clients/cli/lib/manifest.test.mjs +2 -5
  106. package/foundation/discovery/authoring-self-docs.mjs +0 -1
  107. package/foundation/discovery/template-adapter.mjs +1 -1
  108. package/foundation/doc-compiler/doc-loads.test.mjs +12 -0
  109. package/foundation/doc-compiler/tree.test.mjs +1 -9
  110. package/foundation/integrations/integrations.d.mts +1 -14
  111. package/foundation/integrations/integrations.mjs +1 -41
  112. package/foundation/integrations/integrations.test.mjs +0 -31
  113. package/foundation/response/response-types.doc.mjs +21 -15
  114. package/foundation/response/response-types.doc.test.mjs +0 -23
  115. package/foundation/xle/browser.d.mts +3 -3
  116. package/foundation/xle/browser.mjs +3 -3
  117. package/foundation/xle/expand.mjs +2 -2
  118. package/foundation/xle/parse.mjs +1 -1
  119. package/foundation/xle/print.mjs +2 -2
  120. package/foundation/xle/splice.mjs +1 -1
  121. package/package.json +9 -9
  122. package/api/discover/_adapter.test.mjs +0 -215
  123. package/api/discover/_catalog-view.d.mts +0 -115
  124. package/api/discover/_catalog-view.mjs +0 -203
  125. package/api/discover/_catalog-view.test.mjs +0 -128
  126. package/api/discover/detail/item/item.d.mts +0 -26
  127. package/api/discover/detail/item/item.mjs +0 -78
  128. package/api/discover/detail/item/item.test.mjs +0 -73
  129. package/api/integration/pack-check.lifecycle-output.test.mjs +0 -105
  130. package/api/theme/add/add.rollback.test.mjs +0 -158
  131. package/api/theme/build/build.rollback.test.mjs +0 -148
  132. package/api/upgrade/run/files-changed.test.mjs +0 -111
  133. package/assets/codemods/file-count.test.mjs +0 -163
  134. package/assets/docs/tree/component-lookups.doc.mjs +0 -149
  135. package/authoring/discover/discover.doc.d.mts +0 -13
  136. package/authoring/discover/discover.doc.mjs +0 -138
  137. package/authoring/discover/parse.d.mts +0 -24
  138. package/authoring/discover/parse.mjs +0 -128
  139. package/authoring/discover/parse.test.mjs +0 -124
  140. package/authoring/discover/type.ts +0 -87
  141. package/clients/cli/commands/component-batch.test.mjs +0 -341
  142. package/clients/cli/commands/discover.sources.test.mjs +0 -267
  143. package/clients/cli/lib/parse-error-format.test.mjs +0 -81
  144. package/foundation/response/batch.type.d.mts +0 -33
  145. package/foundation/response/batch.type.mjs +0 -34
@@ -6,36 +6,16 @@
6
6
  */
7
7
  export type DiscoverListResponse = {
8
8
  type: "discover.list";
9
- /**
10
- * The integrations the project loads.
11
- */
12
9
  data: DiscoverListEntry[];
13
10
  /**
14
- * Present when the list is empty, and
15
- * whenever the project has a discover source.
11
+ * Present when the list is empty so
12
+ * callers can distinguish "no packages configured" from "configured but
13
+ * nothing discovered".
16
14
  */
17
- meta?: DiscoverListMeta | undefined;
15
+ meta?: {
16
+ configured: boolean;
17
+ } | undefined;
18
18
  };
19
- export type DiscoverListMeta = {
20
- /**
21
- * Present when `data` is empty, so callers can
22
- * distinguish "no packages configured" from "configured but nothing
23
- * discovered".
24
- */
25
- configured?: boolean | undefined;
26
- /**
27
- * What the project could add,
28
- * one entry per integration, never an alias of a package it has.
29
- */
30
- available?: DiscoverAvailableEntry[] | undefined;
31
- /**
32
- * What each discover source did.
33
- */
34
- sources?: DiscoverSourceState[] | undefined;
35
- };
36
- /**
37
- * An installed integration.
38
- */
39
19
  export type DiscoverListEntry = {
40
20
  name: string;
41
21
  category: string;
@@ -43,94 +23,13 @@ export type DiscoverListEntry = {
43
23
  version?: string | undefined;
44
24
  description?: string | undefined;
45
25
  displayName?: string | undefined;
46
- /**
47
- * Template ids, when it adds any.
48
- */
49
- templates?: string[] | undefined;
50
- /**
51
- * Doc topic names, when it adds any.
52
- */
53
- docs?: string[] | undefined;
54
- /**
55
- * Theme slugs, when it adds any.
56
- */
57
- themes?: string[] | undefined;
58
- /**
59
- * `<version>/<id>`, when it adds any.
60
- */
61
- codemods?: string[] | undefined;
62
- /**
63
- * Agent guidance, when a source lists any.
64
- */
65
- agentDocs?: string[] | undefined;
66
- /**
67
- * The latest release a discover source knows.
68
- */
69
- latest?: string | undefined;
70
- };
71
- /**
72
- * A package the project could add.
73
- */
74
- export type DiscoverAvailableEntry = {
75
- name: string;
76
- /**
77
- * Its latest release.
78
- */
79
- version?: string | undefined;
80
- components: string[];
81
- templates?: string[] | undefined;
82
- docs?: string[] | undefined;
83
- themes?: string[] | undefined;
84
- codemods?: string[] | undefined;
85
- agentDocs?: string[] | undefined;
86
- description?: string | undefined;
87
- /**
88
- * The integration's other package names.
89
- */
90
- aliases?: string[] | undefined;
91
- /**
92
- * The discover source that lists it.
93
- */
94
- source: string;
95
- };
96
- export type DiscoverSourceState = {
97
- name: string;
98
- /**
99
- * `astryx.config`, or the integration that exports it.
100
- */
101
- from: string;
102
- /**
103
- * `saved`: the live call
104
- * failed and discover used the copy saved at `savedAt`.
105
- */
106
- status: "fresh" | "saved" | "failed";
107
- generatedAt?: string | undefined;
108
- complete?: boolean | undefined;
109
- savedAt?: string | undefined;
110
- error?: string | undefined;
111
26
  };
112
27
  /**
113
28
  * astryx --json discover
114
29
  */
115
30
  export type DiscoverDetailResponse = {
116
31
  type: "discover.detail";
117
- /**
118
- * `installed` says whether the project has the package;
119
- * `installedVersion` is set when it has another version than the one shown.
120
- * `install` is the package-manager command that adds a package the project
121
- * does not have; discover prints it and never runs it. `installedAs` names
122
- * the package the project has instead, when this one is an alias of it.
123
- * `versions` (newest first) comes from a discover source.
124
- */
125
- data: DiscoverListEntry & {
126
- installed: boolean;
127
- installedVersion?: string;
128
- aliases?: string[];
129
- source?: string;
130
- installedAs?: string;
131
- install?: string;
132
- versions?: import("../../authoring/discover/type").DiscoverVersion[];
133
- };
32
+ data: DiscoverListEntry;
134
33
  };
135
34
  /**
136
35
  * astryx --json discover
@@ -140,52 +39,18 @@ export type DiscoverDetailDocResponse = {
140
39
  data: import("@astryxdesign/cli/authoring").ComponentDoc;
141
40
  };
142
41
  /**
143
- * astryx --json discover
144
- */
145
- export type DiscoverItemResponse = {
146
- type: "discover.item";
147
- data: {
148
- package: string;
149
- version?: string;
150
- kind: import("../../authoring/discover/type").DiscoverKind;
151
- name: string;
152
- title?: string;
153
- summary?: string;
154
- keywords?: string[];
155
- installed: boolean;
156
- installedAs?: string;
157
- install?: string;
158
- source?: string;
159
- };
160
- };
161
- /**
162
- * astryx --json discover <searchterm>
42
+ * astryx --json discover <searchterm> (multiple matches)
163
43
  */
164
44
  export type DiscoverSearchResponse = {
165
45
  type: "discover.search";
166
- /**
167
- * `total` is set when `--limit` cut the list.
168
- */
169
46
  data: {
170
47
  query: string;
171
48
  matches: DiscoverSearchEntry[];
172
- total?: number;
173
49
  };
174
50
  };
175
51
  export type DiscoverSearchEntry = {
176
52
  package: string;
177
- /**
178
- * The item's name, for every kind; for a package
179
- * match, the package name.
180
- */
181
53
  component: string;
182
- kind: import("../../authoring/discover/type").DiscoverKind | "package";
183
- /**
184
- * Whether the project has the package.
185
- */
186
- installed: boolean;
187
- title?: string | undefined;
188
- summary?: string | undefined;
189
54
  };
190
55
  /**
191
56
  * Options for `discover()`.
@@ -194,8 +59,4 @@ export type DiscoverOptions = {
194
59
  components?: boolean | undefined;
195
60
  lang?: string | undefined;
196
61
  zh?: boolean | undefined;
197
- type?: import("@astryxdesign/cli/authoring").DiscoverKind | undefined;
198
- installed?: boolean | undefined;
199
- available?: boolean | undefined;
200
- limit?: number | undefined;
201
62
  };
@@ -7,37 +7,24 @@
7
7
  * Invocation -> type discriminator
8
8
  * ------------------------------------------------------------------
9
9
  * astryx --json discover -> discover.list
10
- * astryx --json discover @scope/name[@version] -> discover.detail
10
+ * astryx --json discover @scope/name -> discover.detail
11
11
  * astryx --json discover @scope/name/Component -> discover.detail.doc
12
- * astryx --json discover @scope/name/<item> -> discover.item
13
- * astryx --json discover <searchterm> -> discover.search
12
+ * astryx --json discover <searchterm> (1 match) -> discover.detail.doc
13
+ * astryx --json discover <searchterm> (N matches) -> discover.search
14
14
  * (not found) -> CLIError
15
- *
16
- * Fields added for discover sources are additive: every earlier field keeps
17
- * its meaning.
18
15
  */
19
16
 
20
17
  /**
21
18
  * astryx --json discover
22
19
  * @typedef {object} DiscoverListResponse
23
20
  * @property {'discover.list'} type
24
- * @property {DiscoverListEntry[]} data The integrations the project loads.
25
- * @property {DiscoverListMeta} [meta] Present when the list is empty, and
26
- * whenever the project has a discover source.
21
+ * @property {DiscoverListEntry[]} data
22
+ * @property {{configured: boolean}} [meta] Present when the list is empty so
23
+ * callers can distinguish "no packages configured" from "configured but
24
+ * nothing discovered".
27
25
  */
28
26
 
29
27
  /**
30
- * @typedef {object} DiscoverListMeta
31
- * @property {boolean} [configured] Present when `data` is empty, so callers can
32
- * distinguish "no packages configured" from "configured but nothing
33
- * discovered".
34
- * @property {DiscoverAvailableEntry[]} [available] What the project could add,
35
- * one entry per integration, never an alias of a package it has.
36
- * @property {DiscoverSourceState[]} [sources] What each discover source did.
37
- */
38
-
39
- /**
40
- * An installed integration.
41
28
  * @typedef {object} DiscoverListEntry
42
29
  * @property {string} name
43
30
  * @property {string} category
@@ -45,60 +32,13 @@
45
32
  * @property {string} [version]
46
33
  * @property {string} [description]
47
34
  * @property {string} [displayName]
48
- * @property {string[]} [templates] Template ids, when it adds any.
49
- * @property {string[]} [docs] Doc topic names, when it adds any.
50
- * @property {string[]} [themes] Theme slugs, when it adds any.
51
- * @property {string[]} [codemods] `<version>/<id>`, when it adds any.
52
- * @property {string[]} [agentDocs] Agent guidance, when a source lists any.
53
- * @property {string} [latest] The latest release a discover source knows.
54
35
  */
55
36
 
56
37
  /**
57
- * A package the project could add.
58
- * @typedef {object} DiscoverAvailableEntry
59
- * @property {string} name
60
- * @property {string} [version] Its latest release.
61
- * @property {string[]} components
62
- * @property {string[]} [templates]
63
- * @property {string[]} [docs]
64
- * @property {string[]} [themes]
65
- * @property {string[]} [codemods]
66
- * @property {string[]} [agentDocs]
67
- * @property {string} [description]
68
- * @property {string[]} [aliases] The integration's other package names.
69
- * @property {string} source The discover source that lists it.
70
- */
71
-
72
- /**
73
- * @typedef {object} DiscoverSourceState
74
- * @property {string} name
75
- * @property {string} from `astryx.config`, or the integration that exports it.
76
- * @property {'fresh' | 'saved' | 'failed'} status `saved`: the live call
77
- * failed and discover used the copy saved at `savedAt`.
78
- * @property {string} [generatedAt]
79
- * @property {boolean} [complete]
80
- * @property {string} [savedAt]
81
- * @property {string} [error]
82
- */
83
-
84
- /**
85
- * astryx --json discover @scope/name[@version]
38
+ * astryx --json discover @scope/name
86
39
  * @typedef {object} DiscoverDetailResponse
87
40
  * @property {'discover.detail'} type
88
- * @property {DiscoverListEntry & {
89
- * installed: boolean,
90
- * installedVersion?: string,
91
- * aliases?: string[],
92
- * source?: string,
93
- * installedAs?: string,
94
- * install?: string,
95
- * versions?: import('../../authoring/discover/type').DiscoverVersion[],
96
- * }} data `installed` says whether the project has the package;
97
- * `installedVersion` is set when it has another version than the one shown.
98
- * `install` is the package-manager command that adds a package the project
99
- * does not have; discover prints it and never runs it. `installedAs` names
100
- * the package the project has instead, when this one is an alias of it.
101
- * `versions` (newest first) comes from a discover source.
41
+ * @property {DiscoverListEntry} data
102
42
  */
103
43
 
104
44
  /**
@@ -109,42 +49,16 @@
109
49
  */
110
50
 
111
51
  /**
112
- * astryx --json discover @scope/name/<item>, for an item that is not an
113
- * installed component.
114
- * @typedef {object} DiscoverItemResponse
115
- * @property {'discover.item'} type
116
- * @property {{
117
- * package: string,
118
- * version?: string,
119
- * kind: import('../../authoring/discover/type').DiscoverKind,
120
- * name: string,
121
- * title?: string,
122
- * summary?: string,
123
- * keywords?: string[],
124
- * installed: boolean,
125
- * installedAs?: string,
126
- * install?: string,
127
- * source?: string,
128
- * }} data
129
- */
130
-
131
- /**
132
- * astryx --json discover <searchterm>
52
+ * astryx --json discover <searchterm> (multiple matches)
133
53
  * @typedef {object} DiscoverSearchResponse
134
54
  * @property {'discover.search'} type
135
- * @property {{query: string, matches: DiscoverSearchEntry[], total?: number}} data
136
- * `total` is set when `--limit` cut the list.
55
+ * @property {{query: string, matches: DiscoverSearchEntry[]}} data
137
56
  */
138
57
 
139
58
  /**
140
59
  * @typedef {object} DiscoverSearchEntry
141
60
  * @property {string} package
142
- * @property {string} component The item's name, for every kind; for a package
143
- * match, the package name.
144
- * @property {import('../../authoring/discover/type').DiscoverKind | 'package'} kind
145
- * @property {boolean} installed Whether the project has the package.
146
- * @property {string} [title]
147
- * @property {string} [summary]
61
+ * @property {string} component
148
62
  */
149
63
 
150
64
  /**
@@ -153,10 +67,6 @@
153
67
  * @property {boolean} [components]
154
68
  * @property {string} [lang]
155
69
  * @property {boolean} [zh]
156
- * @property {import('../../authoring/discover/type').DiscoverKind} [type]
157
- * @property {boolean} [installed]
158
- * @property {boolean} [available]
159
- * @property {number} [limit]
160
70
  */
161
71
 
162
72
  export {};
@@ -2,28 +2,14 @@
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
4
  /**
5
- * Build the discover.list response. `data` lists installed integrations. An
6
- * empty `data` carries `meta.configured`, so callers can distinguish "nothing
7
- * configured" from "configured but nothing discovered". With discover sources,
8
- * `meta.available` lists what the project could add and `meta.sources` reports
9
- * what each source did.
5
+ * Build the discover.list response. An empty `packages` set produces the empty
6
+ * envelope carrying `meta.configured`, so callers can distinguish "nothing
7
+ * configured" from "configured but nothing discovered".
10
8
  *
11
- * @param {Array<import('../_adapter.mjs').InstalledPackage & {latest?: string}>} packages
12
- * @param {{
13
- * configured: boolean,
14
- * available?: Array<Record<string, unknown>>,
15
- * sources?: import('../_adapter.mjs').SourceState[],
16
- * type?: import('../../../authoring/discover/type').DiscoverKind,
17
- * only?: 'installed' | 'available',
18
- * }} options
9
+ * @param {import('../_package-scanner.mjs').ScannedPackage[]} packages
10
+ * @param {{configured: boolean}} meta
19
11
  * @returns {import('../discover.type.mjs').DiscoverListResponse}
20
12
  */
21
- export function list(packages: Array<import("../_adapter.mjs").InstalledPackage & {
22
- latest?: string;
23
- }>, { configured, available, sources, type, only }: {
13
+ export function list(packages: import("../_package-scanner.mjs").ScannedPackage[], { configured }: {
24
14
  configured: boolean;
25
- available?: Array<Record<string, unknown>>;
26
- sources?: import("../_adapter.mjs").SourceState[];
27
- type?: import("../../../authoring/discover/type").DiscoverKind;
28
- only?: "installed" | "available";
29
15
  }): import("../discover.type.mjs").DiscoverListResponse;
@@ -1,59 +1,26 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
3
  /**
4
- * @file discover.list leaf — the integrations the project has, and, when it has
5
- * discover sources, the ones it could add.
4
+ * @file discover.list leaf — list the discovered external packages.
6
5
  *
7
- * @position api/discover/list — pure projection of the packages and catalog
8
- * resolved by ../_adapter into the discover.list envelope.
6
+ * @position api/discover/list — pure projection of the packages resolved by
7
+ * ../_adapter into the discover.list envelope.
9
8
  */
10
9
 
11
10
  import {toEntry} from '../_adapter.mjs';
12
- import {hasKind} from '../_catalog-view.mjs';
13
11
 
14
12
  /**
15
- * Build the discover.list response. `data` lists installed integrations. An
16
- * empty `data` carries `meta.configured`, so callers can distinguish "nothing
17
- * configured" from "configured but nothing discovered". With discover sources,
18
- * `meta.available` lists what the project could add and `meta.sources` reports
19
- * what each source did.
13
+ * Build the discover.list response. An empty `packages` set produces the empty
14
+ * envelope carrying `meta.configured`, so callers can distinguish "nothing
15
+ * configured" from "configured but nothing discovered".
20
16
  *
21
- * @param {Array<import('../_adapter.mjs').InstalledPackage & {latest?: string}>} packages
22
- * @param {{
23
- * configured: boolean,
24
- * available?: Array<Record<string, unknown>>,
25
- * sources?: import('../_adapter.mjs').SourceState[],
26
- * type?: import('../../../authoring/discover/type').DiscoverKind,
27
- * only?: 'installed' | 'available',
28
- * }} options
17
+ * @param {import('../_package-scanner.mjs').ScannedPackage[]} packages
18
+ * @param {{configured: boolean}} meta
29
19
  * @returns {import('../discover.type.mjs').DiscoverListResponse}
30
20
  */
31
- export function list(packages, {configured, available, sources, type, only}) {
32
- const keep = (/** @type {Record<string, unknown>} */ entry) =>
33
- type == null || hasKind(entry, type);
34
- const data =
35
- only === 'available'
36
- ? []
37
- : packages
38
- .map(toEntry)
39
- .filter(entry =>
40
- keep(/** @type {Record<string, unknown>} */ (entry)),
41
- );
42
-
43
- /** @type {Record<string, unknown>} */
44
- const meta = {};
45
- if (data.length === 0) meta.configured = configured;
46
- if (sources !== undefined) {
47
- meta.available = only === 'installed' ? [] : (available ?? []).filter(keep);
48
- meta.sources = sources;
21
+ export function list(packages, {configured}) {
22
+ if (packages.length === 0) {
23
+ return {type: 'discover.list', data: [], meta: {configured}};
49
24
  }
50
- return Object.keys(meta).length > 0
51
- ? {
52
- type: 'discover.list',
53
- data,
54
- meta: /** @type {import('../discover.type.mjs').DiscoverListMeta} */ (
55
- meta
56
- ),
57
- }
58
- : {type: 'discover.list', data};
25
+ return {type: 'discover.list', data: packages.map(toEntry)};
59
26
  }
@@ -57,49 +57,3 @@ describe('discover.list leaf', () => {
57
57
  });
58
58
  });
59
59
  });
60
-
61
- describe('discover.list leaf with discover sources', () => {
62
- const installed = [
63
- pkg('@acme/widgets', ['Alpha'], {
64
- version: '1.2.3',
65
- latest: '1.3.0',
66
- templates: ['pages/Home'],
67
- }),
68
- ];
69
- const available = [
70
- {name: '@acme/charts', version: '2.0.0', components: ['Chart'], source: 'Acme'},
71
- {name: '@acme/themes', version: '1.0.0', components: [], themes: ['ocean'], source: 'Acme'},
72
- ];
73
- const sources = [{name: 'Acme', from: 'astryx.config', status: 'fresh'}];
74
-
75
- it('lists what is installed in data and what could be added in meta', () => {
76
- const res = list(installed, {configured: true, available, sources});
77
- expect(res.data).toEqual([
78
- {
79
- name: '@acme/widgets',
80
- category: '@acme/widgets',
81
- components: ['Alpha'],
82
- version: '1.2.3',
83
- templates: ['pages/Home'],
84
- latest: '1.3.0',
85
- },
86
- ]);
87
- expect(res.meta).toEqual({available, sources});
88
- });
89
-
90
- it('keeps one side with only', () => {
91
- expect(
92
- list(installed, {configured: true, available, sources, only: 'installed'})
93
- .meta?.available,
94
- ).toEqual([]);
95
- const res = list(installed, {configured: true, available, sources, only: 'available'});
96
- expect(res.data).toEqual([]);
97
- expect(res.meta).toEqual({configured: true, available, sources});
98
- });
99
-
100
- it('keeps only packages that add a kind with type', () => {
101
- const res = list(installed, {configured: true, available, sources, type: 'theme'});
102
- expect(res.data).toEqual([]);
103
- expect(res.meta?.available?.map(e => e.name)).toEqual(['@acme/themes']);
104
- });
105
- });
@@ -1,27 +1,25 @@
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
+ /**
5
+ * @typedef {import('../_package-scanner.mjs').ScannedPackage} ScannedPackage
6
+ */
4
7
  /**
5
8
  * Search all packages for `query` (a free-text term that never starts with
6
- * `@`). Resolves to a search response when anything matches, even a single
7
- * item or an exact component name, or throws AstryxError (ERR_NOT_FOUND) —
8
- * with fuzzy suggestions when any exist.
9
+ * `@`). Resolves to a single component's docs when unambiguous, a search
10
+ * response when several match, or throws AstryxError (ERR_NOT_FOUND) — with
11
+ * fuzzy suggestions when any exist.
9
12
  *
10
- * @param {ScannedPackage[]} packages installed packages
13
+ * @param {ScannedPackage[]} packages
11
14
  * @param {string} query
12
- * @param {{
13
- * items?: SearchItem[],
14
- * type?: import('../../../authoring/discover/type').DiscoverKind,
15
- * only?: 'installed' | 'available',
16
- * limit?: number,
17
- * }} opts
18
- * @returns {Promise<import('../discover.type.mjs').DiscoverSearchResponse>}
15
+ * @param {{lang?: string | null, zh?: boolean}} opts
16
+ * @returns {Promise<
17
+ * import('../discover.type.mjs').DiscoverDetailDocResponse |
18
+ * import('../discover.type.mjs').DiscoverSearchResponse
19
+ * >}
19
20
  */
20
- export function search(packages: ScannedPackage[], query: string, opts: {
21
- items?: SearchItem[];
22
- type?: import("../../../authoring/discover/type").DiscoverKind;
23
- only?: "installed" | "available";
24
- limit?: number;
25
- }): Promise<import("../discover.type.mjs").DiscoverSearchResponse>;
21
+ export function search(packages: ScannedPackage[], query: string, { lang, zh }: {
22
+ lang?: string | null;
23
+ zh?: boolean;
24
+ }): Promise<import("../discover.type.mjs").DiscoverDetailDocResponse | import("../discover.type.mjs").DiscoverSearchResponse>;
26
25
  export type ScannedPackage = import("../_package-scanner.mjs").ScannedPackage;
27
- export type SearchItem = import("../_catalog-view.mjs").SearchItem;