@aws/nx-plugin 0.106.0 → 0.108.0
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.
- package/LICENSE-THIRD-PARTY +2401 -175
- package/package.json +19 -8
- package/src/connection/serve-local.js +4 -4
- package/src/connection/serve-local.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +13 -13
- package/src/mcp-server/generator-info.d.ts +95 -13
- package/src/mcp-server/generator-info.js +319 -164
- package/src/mcp-server/generator-info.js.map +1 -1
- package/src/mcp-server/guide-pipeline.d.ts +28 -0
- package/src/mcp-server/guide-pipeline.js +393 -0
- package/src/mcp-server/guide-pipeline.js.map +1 -0
- package/src/mcp-server/guide-render.d.ts +25 -0
- package/src/mcp-server/guide-render.js +50 -0
- package/src/mcp-server/guide-render.js.map +1 -0
- package/src/mcp-server/mdx-ast.d.ts +30 -0
- package/src/mcp-server/mdx-ast.js +96 -0
- package/src/mcp-server/mdx-ast.js.map +1 -0
- package/src/mcp-server/option-filter.d.ts +33 -0
- package/src/mcp-server/option-filter.js +119 -0
- package/src/mcp-server/option-filter.js.map +1 -0
- package/src/mcp-server/schema-registry.d.ts +36 -0
- package/src/mcp-server/schema-registry.js +79 -0
- package/src/mcp-server/schema-registry.js.map +1 -0
- package/src/mcp-server/tools/generator-guide.d.ts +7 -1
- package/src/mcp-server/tools/generator-guide.js +32 -4
- package/src/mcp-server/tools/generator-guide.js.map +1 -1
- package/src/mcp-server/tools/list-generators.d.ts +10 -1
- package/src/mcp-server/tools/list-generators.js +34 -13
- package/src/mcp-server/tools/list-generators.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/preset/schema.json +2 -2
- package/src/py/fast-api/generator.js +9 -0
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/py/strands-agent/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +12 -0
- package/src/smithy/ts/api/generator.js +9 -0
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/trpc/backend/generator.js +9 -0
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/mcp-server/generator.js +15 -0
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/nx-generator/__snapshots__/generator.spec.ts.snap +2 -0
- package/src/ts/nx-generator/files/nx-plugin-for-aws/docs/__nameKebabCase__.mdx.template +2 -0
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +27 -27
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap +12 -3
- package/src/utils/files/common/shadcn/src/components/ui/avatar.tsx.template +60 -4
- package/src/utils/files/common/shadcn/src/components/ui/textarea.tsx.template +1 -1
- package/src/utils/generators.d.ts +1 -1
- package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +13 -3
- package/src/utils/versions.d.ts +37 -37
- package/src/utils/versions.js +36 -36
- package/src/utils/versions.js.map +1 -1
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.postProcessGuideWithRemark = exports.parseMdx = void 0;
|
|
8
|
+
const tslib_1 = require("tslib");
|
|
9
|
+
const option_filter_1 = require("./option-filter");
|
|
10
|
+
const commands_1 = require("../utils/commands");
|
|
11
|
+
const guide_render_1 = require("./guide-render");
|
|
12
|
+
const mdx_ast_1 = require("./mdx-ast");
|
|
13
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
14
|
+
let depsPromise;
|
|
15
|
+
const loadRemarkDeps = () => {
|
|
16
|
+
if (!depsPromise) {
|
|
17
|
+
depsPromise = (async () => ({
|
|
18
|
+
unified: (await Promise.resolve().then(() => tslib_1.__importStar(require('unified')))).unified,
|
|
19
|
+
remarkParse: (await Promise.resolve().then(() => tslib_1.__importStar(require('remark-parse')))).default,
|
|
20
|
+
remarkMdx: (await Promise.resolve().then(() => tslib_1.__importStar(require('remark-mdx')))).default,
|
|
21
|
+
remarkStringify: (await Promise.resolve().then(() => tslib_1.__importStar(require('remark-stringify')))).default,
|
|
22
|
+
remarkFrontmatter: (await Promise.resolve().then(() => tslib_1.__importStar(require('remark-frontmatter')))).default,
|
|
23
|
+
}))();
|
|
24
|
+
}
|
|
25
|
+
return depsPromise;
|
|
26
|
+
};
|
|
27
|
+
const parseMdxWithDeps = (source, deps) => deps
|
|
28
|
+
.unified()
|
|
29
|
+
.use(deps.remarkParse)
|
|
30
|
+
.use(deps.remarkFrontmatter)
|
|
31
|
+
.use(deps.remarkMdx)
|
|
32
|
+
.parse(source);
|
|
33
|
+
/** Parse MDX (with frontmatter) into mdast. Exposed so callers like
|
|
34
|
+
* `fetchGuideFrontmatters` don't need to re-load remark themselves. */
|
|
35
|
+
const parseMdx = async (source) => {
|
|
36
|
+
const deps = await loadRemarkDeps();
|
|
37
|
+
return parseMdxWithDeps(source, deps);
|
|
38
|
+
};
|
|
39
|
+
exports.parseMdx = parseMdx;
|
|
40
|
+
const stringifyMdx = (tree, deps) => String(deps
|
|
41
|
+
.unified()
|
|
42
|
+
.use(deps.remarkFrontmatter)
|
|
43
|
+
.use(deps.remarkMdx)
|
|
44
|
+
.use(deps.remarkStringify, {
|
|
45
|
+
bullet: '-',
|
|
46
|
+
fences: true,
|
|
47
|
+
listItemIndent: 'one',
|
|
48
|
+
})
|
|
49
|
+
.stringify(tree));
|
|
50
|
+
const postProcessGuideWithRemark = async (guide, opts) => {
|
|
51
|
+
const deps = await loadRemarkDeps();
|
|
52
|
+
const tree = parseMdxWithDeps(guide, deps);
|
|
53
|
+
await inlineSnippets(tree, opts, deps);
|
|
54
|
+
applyFilterTransforms(tree, opts.options);
|
|
55
|
+
applyComponentTransforms(tree, opts, deps);
|
|
56
|
+
return stringifyMdx(tree, deps);
|
|
57
|
+
};
|
|
58
|
+
exports.postProcessGuideWithRemark = postProcessGuideWithRemark;
|
|
59
|
+
const inlineSnippets = async (tree, opts, deps) => {
|
|
60
|
+
const provider = opts.snippetContentProvider;
|
|
61
|
+
if (!provider)
|
|
62
|
+
return;
|
|
63
|
+
const pending = [];
|
|
64
|
+
const walk = (parent) => {
|
|
65
|
+
const children = parent.children;
|
|
66
|
+
for (let i = 0; i < children.length; i++) {
|
|
67
|
+
const child = children[i];
|
|
68
|
+
if (!(0, mdx_ast_1.isJsxElement)(child))
|
|
69
|
+
continue;
|
|
70
|
+
if (child.name === 'Snippet') {
|
|
71
|
+
const name = (0, mdx_ast_1.readStringAttr)(child, 'name');
|
|
72
|
+
if (name)
|
|
73
|
+
pending.push({ parent, index: i, name, node: child });
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
walk(child);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
walk(tree);
|
|
80
|
+
if (pending.length === 0)
|
|
81
|
+
return;
|
|
82
|
+
const fetched = await Promise.all(pending.map(async (p) => {
|
|
83
|
+
let raw = '';
|
|
84
|
+
try {
|
|
85
|
+
raw = await provider(p.name);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
raw = '';
|
|
89
|
+
}
|
|
90
|
+
if (!raw)
|
|
91
|
+
return { ...p, replacement: undefined };
|
|
92
|
+
const processed = await (0, exports.postProcessGuideWithRemark)(raw.trim(), opts);
|
|
93
|
+
return { ...p, replacement: processed };
|
|
94
|
+
}));
|
|
95
|
+
// Splice in descending index order per parent so earlier indices stay valid.
|
|
96
|
+
const byParent = new Map();
|
|
97
|
+
for (const f of fetched) {
|
|
98
|
+
const bucket = byParent.get(f.parent) ?? [];
|
|
99
|
+
bucket.push(f);
|
|
100
|
+
byParent.set(f.parent, bucket);
|
|
101
|
+
}
|
|
102
|
+
for (const [parent, items] of byParent) {
|
|
103
|
+
items.sort((a, b) => b.index - a.index);
|
|
104
|
+
for (const { index, name, replacement, node } of items) {
|
|
105
|
+
if (replacement === undefined)
|
|
106
|
+
continue;
|
|
107
|
+
const snippetTree = parseMdxWithDeps(replacement, deps);
|
|
108
|
+
const wrapper = {
|
|
109
|
+
type: 'mdxJsxFlowElement',
|
|
110
|
+
name: 'Snippet',
|
|
111
|
+
attributes: [{ type: 'mdxJsxAttribute', name: 'name', value: name }],
|
|
112
|
+
children: snippetTree.children,
|
|
113
|
+
};
|
|
114
|
+
if ('position' in node && node.position) {
|
|
115
|
+
wrapper.position = node.position;
|
|
116
|
+
}
|
|
117
|
+
parent.children.splice(index, 1, wrapper);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const applyFilterTransforms = (tree, options) => {
|
|
122
|
+
const iacProvider = options?.iacProvider;
|
|
123
|
+
const transform = (parent) => {
|
|
124
|
+
const children = parent.children;
|
|
125
|
+
for (let i = 0; i < children.length; i++) {
|
|
126
|
+
const child = children[i];
|
|
127
|
+
if (!(0, mdx_ast_1.isJsxElement)(child))
|
|
128
|
+
continue;
|
|
129
|
+
if (child.name === 'OptionFilter') {
|
|
130
|
+
const when = parseWhenAttr(child);
|
|
131
|
+
if (!when)
|
|
132
|
+
continue; // malformed — leave alone
|
|
133
|
+
// Recurse first so nested filters collapse before we replace this wrapper.
|
|
134
|
+
transform(child);
|
|
135
|
+
const not = (0, mdx_ast_1.hasBareAttr)(child, 'not');
|
|
136
|
+
if (options) {
|
|
137
|
+
const replacement = (0, option_filter_1.evaluatePredicate)(when, not, options)
|
|
138
|
+
? child.children
|
|
139
|
+
: [];
|
|
140
|
+
children.splice(i, 1, ...replacement);
|
|
141
|
+
i += replacement.length - 1;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
children.splice(i, 1, buildNoteQuote(child, when, not));
|
|
145
|
+
}
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (child.name === 'Infrastructure') {
|
|
149
|
+
if (iacProvider === 'CDK' || iacProvider === 'Terraform') {
|
|
150
|
+
const body = selectInfrastructureSlot(child, iacProvider);
|
|
151
|
+
const pseudo = {
|
|
152
|
+
type: 'mdxJsxFlowElement',
|
|
153
|
+
name: 'tmp',
|
|
154
|
+
attributes: [],
|
|
155
|
+
children: body,
|
|
156
|
+
};
|
|
157
|
+
transform(pseudo);
|
|
158
|
+
children.splice(i, 1, ...pseudo.children);
|
|
159
|
+
i--;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
// No iacProvider → keep both slots so readers / agents see both variants.
|
|
163
|
+
transform(child);
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
if (child.name === 'Tabs' && child.type === 'mdxJsxFlowElement') {
|
|
167
|
+
transform(child);
|
|
168
|
+
const dropped = applyTabsFilter(child, options);
|
|
169
|
+
if (dropped === 'empty') {
|
|
170
|
+
children.splice(i, 1);
|
|
171
|
+
i--;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (dropped === 'inline') {
|
|
175
|
+
const survivor = child.children.find((c) => (0, mdx_ast_1.isJsxElement)(c) && c.name === 'TabItem');
|
|
176
|
+
const body = survivor.children;
|
|
177
|
+
children.splice(i, 1, ...body);
|
|
178
|
+
i += body.length - 1;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
transform(child);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
transform(tree);
|
|
187
|
+
};
|
|
188
|
+
const selectInfrastructureSlot = (node, iacProvider) => {
|
|
189
|
+
const slotName = iacProvider.toLowerCase();
|
|
190
|
+
const frag = node.children.find((c) => (0, mdx_ast_1.isJsxElement)(c) &&
|
|
191
|
+
c.name === 'Fragment' &&
|
|
192
|
+
(0, mdx_ast_1.readStringAttr)(c, 'slot') === slotName);
|
|
193
|
+
return frag?.children ?? [];
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Prune TabItems whose `_filter` doesn't match `options`. Returns:
|
|
197
|
+
* - `'empty'` if the <Tabs> now has no <TabItem>s — caller drops it.
|
|
198
|
+
* - `'inline'` if exactly one filtered <TabItem> survived — caller
|
|
199
|
+
* inlines the body so agents see just the picked variant.
|
|
200
|
+
* - `'keep'` otherwise.
|
|
201
|
+
*/
|
|
202
|
+
const applyTabsFilter = (tabs, options) => {
|
|
203
|
+
const children = tabs.children;
|
|
204
|
+
const surviving = [];
|
|
205
|
+
let anyFiltered = false;
|
|
206
|
+
for (const child of children) {
|
|
207
|
+
if (!(0, mdx_ast_1.isJsxElement)(child) || child.name !== 'TabItem') {
|
|
208
|
+
surviving.push(child);
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
const filterEstree = (0, mdx_ast_1.readEstreeAttr)(child, '_filter');
|
|
212
|
+
if (!filterEstree) {
|
|
213
|
+
surviving.push(child);
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
anyFiltered = true;
|
|
217
|
+
let predicate;
|
|
218
|
+
try {
|
|
219
|
+
predicate = (0, option_filter_1.parseWhenExpression)(filterEstree);
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
stripFilterAttr(child);
|
|
223
|
+
surviving.push(child);
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
if (!options || (0, option_filter_1.evaluatePredicate)(predicate, false, options)) {
|
|
227
|
+
stripFilterAttr(child);
|
|
228
|
+
surviving.push(child);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (anyFiltered) {
|
|
232
|
+
tabs.children = surviving;
|
|
233
|
+
}
|
|
234
|
+
const tabItems = surviving.filter((c) => (0, mdx_ast_1.isJsxElement)(c) && c.name === 'TabItem');
|
|
235
|
+
if (tabItems.length === 0 && surviving.length === 0)
|
|
236
|
+
return 'empty';
|
|
237
|
+
if (anyFiltered && tabItems.length === 1)
|
|
238
|
+
return 'inline';
|
|
239
|
+
return 'keep';
|
|
240
|
+
};
|
|
241
|
+
const stripFilterAttr = (el) => {
|
|
242
|
+
el.attributes = el.attributes.filter((a) => !(a.type === 'mdxJsxAttribute' && a.name === '_filter'));
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* `> [!NOTE] Only when …` blockquote. The alert header goes through as an
|
|
246
|
+
* `html` node so remark-stringify doesn't escape the `[`/`]` brackets —
|
|
247
|
+
* downstream agents match on the literal GitHub alert syntax.
|
|
248
|
+
*/
|
|
249
|
+
const buildNoteQuote = (source, predicate, not) => {
|
|
250
|
+
const marker = (0, option_filter_1.describePredicate)(predicate, not);
|
|
251
|
+
const description = (0, mdx_ast_1.readStringAttr)(source, 'description');
|
|
252
|
+
const headerLines = description
|
|
253
|
+
? [`[!NOTE] ${marker}`, description]
|
|
254
|
+
: [`[!NOTE] ${marker}`];
|
|
255
|
+
const headerNodes = headerLines.map((line) => ({ type: 'html', value: line }));
|
|
256
|
+
return {
|
|
257
|
+
type: 'blockquote',
|
|
258
|
+
children: [...headerNodes, ...source.children],
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
const parseWhenAttr = (node) => {
|
|
262
|
+
const estree = (0, mdx_ast_1.readEstreeAttr)(node, 'when');
|
|
263
|
+
if (!estree)
|
|
264
|
+
return undefined;
|
|
265
|
+
try {
|
|
266
|
+
return (0, option_filter_1.parseWhenExpression)(estree);
|
|
267
|
+
}
|
|
268
|
+
catch {
|
|
269
|
+
return undefined;
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
const applyComponentTransforms = (tree, opts, deps) => {
|
|
273
|
+
const pm = opts.packageManager ?? 'pnpm';
|
|
274
|
+
const transform = (parent) => {
|
|
275
|
+
const children = parent.children;
|
|
276
|
+
for (let i = 0; i < children.length; i++) {
|
|
277
|
+
const child = children[i];
|
|
278
|
+
if (!(0, mdx_ast_1.isJsxElement)(child))
|
|
279
|
+
continue;
|
|
280
|
+
const replacement = renderComponent(child, opts, pm, deps);
|
|
281
|
+
if (replacement !== undefined) {
|
|
282
|
+
children.splice(i, 1, ...replacement);
|
|
283
|
+
i += replacement.length - 1;
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
transform(child);
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
transform(tree);
|
|
290
|
+
};
|
|
291
|
+
const renderComponent = (node, opts, pm, deps) => {
|
|
292
|
+
switch (node.name) {
|
|
293
|
+
case 'NxCommands': {
|
|
294
|
+
const commands = readCommandsAttr(node);
|
|
295
|
+
if (!commands)
|
|
296
|
+
return undefined;
|
|
297
|
+
return [
|
|
298
|
+
codeBlock(commands
|
|
299
|
+
.map((c) => (0, guide_render_1.buildNxCommand)(c, opts.packageManager))
|
|
300
|
+
.join('\n')),
|
|
301
|
+
];
|
|
302
|
+
}
|
|
303
|
+
case 'RunGenerator': {
|
|
304
|
+
const generatorId = (0, mdx_ast_1.readStringAttr)(node, 'generator');
|
|
305
|
+
if (!generatorId)
|
|
306
|
+
return undefined;
|
|
307
|
+
const schema = findSchema(opts.generators, generatorId);
|
|
308
|
+
if (!schema)
|
|
309
|
+
return undefined;
|
|
310
|
+
return parseMarkdownFragment((0, guide_render_1.renderGeneratorCommand)(generatorId, schema, opts.packageManager), deps);
|
|
311
|
+
}
|
|
312
|
+
case 'GeneratorParameters': {
|
|
313
|
+
const generatorId = (0, mdx_ast_1.readStringAttr)(node, 'generator');
|
|
314
|
+
if (!generatorId)
|
|
315
|
+
return undefined;
|
|
316
|
+
const schema = findSchema(opts.generators, generatorId);
|
|
317
|
+
if (!schema)
|
|
318
|
+
return undefined;
|
|
319
|
+
return parseMarkdownFragment((0, guide_render_1.renderSchema)(schema), deps);
|
|
320
|
+
}
|
|
321
|
+
case 'CreateNxWorkspaceCommand': {
|
|
322
|
+
const workspace = (0, mdx_ast_1.readStringAttr)(node, 'workspace');
|
|
323
|
+
if (!workspace)
|
|
324
|
+
return undefined;
|
|
325
|
+
const iacProvider = (0, mdx_ast_1.readStringAttr)(node, 'iacProvider');
|
|
326
|
+
return [
|
|
327
|
+
codeBlock((0, commands_1.buildCreateNxWorkspaceCommand)(pm, workspace, iacProvider)),
|
|
328
|
+
];
|
|
329
|
+
}
|
|
330
|
+
case 'InstallCommand': {
|
|
331
|
+
const pkg = (0, mdx_ast_1.readStringAttr)(node, 'pkg') ?? (0, mdx_ast_1.readExpressionAttr)(node, 'pkg');
|
|
332
|
+
if (!pkg)
|
|
333
|
+
return undefined;
|
|
334
|
+
return [
|
|
335
|
+
codeBlock((0, commands_1.buildInstallCommand)(pm, pkg, (0, mdx_ast_1.hasBareAttr)(node, 'dev'))),
|
|
336
|
+
];
|
|
337
|
+
}
|
|
338
|
+
case 'PackageManagerShortCommand': {
|
|
339
|
+
const commands = readCommandsAttr(node);
|
|
340
|
+
if (!commands)
|
|
341
|
+
return undefined;
|
|
342
|
+
return [
|
|
343
|
+
codeBlock(commands
|
|
344
|
+
.map((c) => (0, commands_1.buildPackageManagerShortCommand)(pm, c))
|
|
345
|
+
.join('\n')),
|
|
346
|
+
];
|
|
347
|
+
}
|
|
348
|
+
case 'PackageManagerExecCommand': {
|
|
349
|
+
const commands = readCommandsAttr(node);
|
|
350
|
+
if (!commands)
|
|
351
|
+
return undefined;
|
|
352
|
+
return [
|
|
353
|
+
codeBlock(commands.map((c) => (0, commands_1.buildPackageManagerExecCommand)(pm, c)).join('\n')),
|
|
354
|
+
];
|
|
355
|
+
}
|
|
356
|
+
default:
|
|
357
|
+
return undefined;
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
const codeBlock = (body) => ({
|
|
361
|
+
type: 'code',
|
|
362
|
+
lang: 'bash',
|
|
363
|
+
value: body,
|
|
364
|
+
});
|
|
365
|
+
const parseMarkdownFragment = (markdown, deps) => {
|
|
366
|
+
const fragTree = deps.unified().use(deps.remarkParse).parse(markdown);
|
|
367
|
+
return fragTree.children;
|
|
368
|
+
};
|
|
369
|
+
const findSchema = (generators, generatorId) => {
|
|
370
|
+
const info = generators.find((g) => g.id === generatorId);
|
|
371
|
+
if (!info)
|
|
372
|
+
return undefined;
|
|
373
|
+
try {
|
|
374
|
+
return JSON.parse(fs_1.default.readFileSync(info.resolvedSchemaPath, 'utf-8'));
|
|
375
|
+
}
|
|
376
|
+
catch {
|
|
377
|
+
return undefined;
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
/** Parse the `commands={[…]}` attribute from the estree that remark-mdx
|
|
381
|
+
* attaches to the JSX attribute value. */
|
|
382
|
+
const readCommandsAttr = (node) => {
|
|
383
|
+
const estree = (0, mdx_ast_1.readEstreeAttr)(node, 'commands');
|
|
384
|
+
if (!estree)
|
|
385
|
+
return undefined;
|
|
386
|
+
try {
|
|
387
|
+
return (0, option_filter_1.extractStringArrayExpression)(estree);
|
|
388
|
+
}
|
|
389
|
+
catch {
|
|
390
|
+
return undefined;
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
//# sourceMappingURL=guide-pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guide-pipeline.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/mcp-server/guide-pipeline.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAiBH,mDAMyB;AACzB,gDAK2B;AAC3B,iDAIwB;AACxB,uCAQmB;AACnB,oDAAoB;AAmBpB,IAAI,WAA4C,CAAC;AACjD,MAAM,cAAc,GAAG,GAAwB,EAAE;IAC/C,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,WAAW,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;YAC1B,OAAO,EAAE,CAAC,gEAAa,SAAS,GAAC,CAAC,CAAC,OAAO;YAC1C,WAAW,EAAE,CAAC,gEAAa,cAAc,GAAC,CAAC,CAAC,OAAO;YACnD,SAAS,EAAE,CAAC,gEAAa,YAAY,GAAC,CAAC,CAAC,OAAO;YAC/C,eAAe,EAAE,CAAC,gEAAa,kBAA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CAAC,IAAgB,EAAwB,EAAE;IAClE,MAAM,MAAM,GAAG,IAAA,wBAAc,EAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAChD,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,IAAI,CAAC;QACH,OAAO,IAAA,4CAA4B,EAAC,MAAe,CAAC,CAAC;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Build an nx command, optionally prefixed by the package manager's exec
|
|
7
|
+
* wrapper. A bare `nx <command>` is returned when no package manager is
|
|
8
|
+
* passed, matching the legacy regex-based post-processor's behaviour.
|
|
9
|
+
*/
|
|
10
|
+
export declare const buildNxCommand: (command: string, pm?: string) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Serialise a generator schema's `properties` map to the bullet list
|
|
13
|
+
* `<GeneratorParameters>` expands to.
|
|
14
|
+
*/
|
|
15
|
+
export declare const renderSchema: (schema: {
|
|
16
|
+
properties?: Record<string, unknown>;
|
|
17
|
+
required?: string[];
|
|
18
|
+
}) => string;
|
|
19
|
+
/**
|
|
20
|
+
* Build the fenced-code invocation that `<RunGenerator>` expands to.
|
|
21
|
+
*/
|
|
22
|
+
export declare const renderGeneratorCommand: (generatorId: string, schema: {
|
|
23
|
+
properties?: Record<string, unknown>;
|
|
24
|
+
required?: string[];
|
|
25
|
+
}, packageManager?: string) => string;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.renderGeneratorCommand = exports.renderSchema = exports.buildNxCommand = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Shared rendering helpers used by the unified/remark-mdx guide pipeline.
|
|
10
|
+
* Kept in their own module so `generator-info.ts` (which still exports
|
|
11
|
+
* `renderGeneratorInfo` for list-generators) and the pipeline both render
|
|
12
|
+
* identical command strings without either re-implementing the other.
|
|
13
|
+
*/
|
|
14
|
+
const commands_1 = require("../utils/commands");
|
|
15
|
+
/**
|
|
16
|
+
* Build an nx command, optionally prefixed by the package manager's exec
|
|
17
|
+
* wrapper. A bare `nx <command>` is returned when no package manager is
|
|
18
|
+
* passed, matching the legacy regex-based post-processor's behaviour.
|
|
19
|
+
*/
|
|
20
|
+
const buildNxCommand = (command, pm) => pm ? (0, commands_1.buildPackageManagerExecCommand)(pm, `nx ${command}`) : `nx ${command}`;
|
|
21
|
+
exports.buildNxCommand = buildNxCommand;
|
|
22
|
+
/**
|
|
23
|
+
* Serialise a generator schema's `properties` map to the bullet list
|
|
24
|
+
* `<GeneratorParameters>` expands to.
|
|
25
|
+
*/
|
|
26
|
+
const renderSchema = (schema) => {
|
|
27
|
+
const required = new Set(schema.required ?? []);
|
|
28
|
+
return Object.entries(schema.properties ?? {})
|
|
29
|
+
.map(([parameter, raw]) => {
|
|
30
|
+
const p = raw;
|
|
31
|
+
const enumPart = p.enum ? ` [options: ${p.enum.join(', ')}]` : '';
|
|
32
|
+
const requiredPart = required.has(parameter) ? ` (required)` : '';
|
|
33
|
+
return `- ${parameter} [type: ${p.type}]${enumPart}${requiredPart} ${p.description}`;
|
|
34
|
+
})
|
|
35
|
+
.join('\n');
|
|
36
|
+
};
|
|
37
|
+
exports.renderSchema = renderSchema;
|
|
38
|
+
/**
|
|
39
|
+
* Build the fenced-code invocation that `<RunGenerator>` expands to.
|
|
40
|
+
*/
|
|
41
|
+
const renderGeneratorCommand = (generatorId, schema, packageManager) => {
|
|
42
|
+
const required = new Set(schema.required ?? []);
|
|
43
|
+
const args = Object.keys(schema.properties ?? {})
|
|
44
|
+
.filter((k) => required.has(k))
|
|
45
|
+
.map((k) => `--${k}=<${k}>`)
|
|
46
|
+
.join(' ');
|
|
47
|
+
return `\`\`\`bash\n${(0, exports.buildNxCommand)(`g @aws/nx-plugin:${generatorId} --no-interactive ${args}`, packageManager)}\n\`\`\``;
|
|
48
|
+
};
|
|
49
|
+
exports.renderGeneratorCommand = renderGeneratorCommand;
|
|
50
|
+
//# sourceMappingURL=guide-render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guide-render.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/mcp-server/guide-render.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;GAKG;AACH,gDAAmE;AAEnE;;;;GAIG;AACI,MAAM,cAAc,GAAG,CAAC,OAAe,EAAE,EAAW,EAAE,EAAE,CAC7D,EAAE,CAAC,CAAC,CAAC,IAAA,yCAA8B,EAAC,EAAE,EAAE,MAAM,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,OAAO,EAAE,CAAC;AADhE,QAAA,cAAc,kBACkD;AAE7E;;;GAGG;AACI,MAAM,YAAY,GAAG,CAAC,MAG5B,EAAU,EAAE;IACX,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;IAChD,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC;SAC3C,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,EAAE;QACxB,MAAM,CAAC,GAAG,GAIT,CAAC;QACF,MAAM,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,OAAO,KAAK,SAAS,WAAW,CAAC,CAAC,IAAI,IAAI,QAAQ,GAAG,YAAY,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IACvF,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC,CAAC;AAjBW,QAAA,YAAY,gBAiBvB;AAEF;;GAEG;AACI,MAAM,sBAAsB,GAAG,CACpC,WAAmB,EACnB,MAAqE,EACrE,cAAuB,EACf,EAAE;IACV,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC;SAC9C,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SAC9B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;SAC3B,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,OAAO,eAAe,IAAA,sBAAc,EAClC,oBAAoB,WAAW,qBAAqB,IAAI,EAAE,EAC1D,cAAc,CACf,UAAU,CAAC;AACd,CAAC,CAAC;AAdW,QAAA,sBAAsB,0BAcjC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { Root, RootContent } from 'mdast';
|
|
6
|
+
import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
|
|
7
|
+
export type JsxParent = Root | MdxJsxFlowElement | MdxJsxTextElement;
|
|
8
|
+
export type JsxElement = MdxJsxFlowElement | MdxJsxTextElement;
|
|
9
|
+
export declare const isJsxElement: (node: RootContent) => node is JsxElement;
|
|
10
|
+
export declare const readStringAttr: (node: JsxElement, name: string) => string | undefined;
|
|
11
|
+
export declare const readExpressionAttr: (node: JsxElement, name: string) => string | undefined;
|
|
12
|
+
export declare const readEstreeAttr: (node: JsxElement, name: string) => unknown | undefined;
|
|
13
|
+
export declare const hasBareAttr: (node: JsxElement, name: string) => boolean;
|
|
14
|
+
/** Walk every JSX element in the subtree, pre-order. */
|
|
15
|
+
export declare const walkJsx: (parent: JsxParent, visit: (node: JsxElement, parent: JsxParent) => void) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Every option key referenced by `<OptionFilter when>` or
|
|
18
|
+
* `<TabItem _filter>` in the subtree. Malformed predicates are skipped.
|
|
19
|
+
*/
|
|
20
|
+
export declare const collectFilterableKeysFromJsx: (tree: Root) => Set<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Parse the leading `---…---` YAML frontmatter from an mdast Root produced
|
|
23
|
+
* with `remark-frontmatter`. Returns `{ data, bodyOffset }` where
|
|
24
|
+
* `bodyOffset` is the character index after the closing `---` — slice the
|
|
25
|
+
* original source from it to get the body without re-stringifying the tree.
|
|
26
|
+
*/
|
|
27
|
+
export declare const extractFrontmatter: (tree: Root) => {
|
|
28
|
+
data: Record<string, unknown>;
|
|
29
|
+
bodyOffset: number;
|
|
30
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractFrontmatter = exports.collectFilterableKeysFromJsx = exports.walkJsx = exports.hasBareAttr = exports.readEstreeAttr = exports.readExpressionAttr = exports.readStringAttr = exports.isJsxElement = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
6
|
+
const option_filter_1 = require("./option-filter");
|
|
7
|
+
const isJsxElement = (node) => node.type === 'mdxJsxFlowElement' || node.type === 'mdxJsxTextElement';
|
|
8
|
+
exports.isJsxElement = isJsxElement;
|
|
9
|
+
const findAttr = (node, name) => node.attributes.find((a) => a.type === 'mdxJsxAttribute' && a.name === name);
|
|
10
|
+
const readStringAttr = (node, name) => {
|
|
11
|
+
const attr = findAttr(node, name);
|
|
12
|
+
return typeof attr?.value === 'string' ? attr.value : undefined;
|
|
13
|
+
};
|
|
14
|
+
exports.readStringAttr = readStringAttr;
|
|
15
|
+
const readExpressionAttr = (node, name) => {
|
|
16
|
+
const attr = findAttr(node, name);
|
|
17
|
+
if (attr && typeof attr.value === 'object' && attr.value !== null) {
|
|
18
|
+
return attr.value.value;
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
};
|
|
22
|
+
exports.readExpressionAttr = readExpressionAttr;
|
|
23
|
+
const readEstreeAttr = (node, name) => {
|
|
24
|
+
const attr = findAttr(node, name);
|
|
25
|
+
if (attr && typeof attr.value === 'object' && attr.value !== null) {
|
|
26
|
+
return attr.value.data?.estree;
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
};
|
|
30
|
+
exports.readEstreeAttr = readEstreeAttr;
|
|
31
|
+
const hasBareAttr = (node, name) => node.attributes.some((a) => a.type === 'mdxJsxAttribute' && a.name === name);
|
|
32
|
+
exports.hasBareAttr = hasBareAttr;
|
|
33
|
+
/** Walk every JSX element in the subtree, pre-order. */
|
|
34
|
+
const walkJsx = (parent, visit) => {
|
|
35
|
+
const children = parent.children;
|
|
36
|
+
for (const child of children) {
|
|
37
|
+
if (!(0, exports.isJsxElement)(child))
|
|
38
|
+
continue;
|
|
39
|
+
visit(child, parent);
|
|
40
|
+
(0, exports.walkJsx)(child, visit);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.walkJsx = walkJsx;
|
|
44
|
+
/**
|
|
45
|
+
* Every option key referenced by `<OptionFilter when>` or
|
|
46
|
+
* `<TabItem _filter>` in the subtree. Malformed predicates are skipped.
|
|
47
|
+
*/
|
|
48
|
+
const collectFilterableKeysFromJsx = (tree) => {
|
|
49
|
+
const keys = new Set();
|
|
50
|
+
(0, exports.walkJsx)(tree, (node) => {
|
|
51
|
+
const attrName = node.name === 'OptionFilter'
|
|
52
|
+
? 'when'
|
|
53
|
+
: node.name === 'TabItem'
|
|
54
|
+
? '_filter'
|
|
55
|
+
: undefined;
|
|
56
|
+
if (!attrName)
|
|
57
|
+
return;
|
|
58
|
+
const estree = (0, exports.readEstreeAttr)(node, attrName);
|
|
59
|
+
if (!estree)
|
|
60
|
+
return;
|
|
61
|
+
try {
|
|
62
|
+
for (const key of Object.keys((0, option_filter_1.parseWhenExpression)(estree))) {
|
|
63
|
+
keys.add(key);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// Malformed / partially-typed — skip.
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return keys;
|
|
71
|
+
};
|
|
72
|
+
exports.collectFilterableKeysFromJsx = collectFilterableKeysFromJsx;
|
|
73
|
+
/**
|
|
74
|
+
* Parse the leading `---…---` YAML frontmatter from an mdast Root produced
|
|
75
|
+
* with `remark-frontmatter`. Returns `{ data, bodyOffset }` where
|
|
76
|
+
* `bodyOffset` is the character index after the closing `---` — slice the
|
|
77
|
+
* original source from it to get the body without re-stringifying the tree.
|
|
78
|
+
*/
|
|
79
|
+
const extractFrontmatter = (tree) => {
|
|
80
|
+
const node = tree.children.find((c) => c.type === 'yaml');
|
|
81
|
+
if (!node)
|
|
82
|
+
return { data: {}, bodyOffset: 0 };
|
|
83
|
+
let parsed;
|
|
84
|
+
try {
|
|
85
|
+
parsed = js_yaml_1.default.load(node.value);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return { data: {}, bodyOffset: node.position?.end.offset ?? 0 };
|
|
89
|
+
}
|
|
90
|
+
const data = parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
91
|
+
? parsed
|
|
92
|
+
: {};
|
|
93
|
+
return { data, bodyOffset: node.position?.end.offset ?? 0 };
|
|
94
|
+
};
|
|
95
|
+
exports.extractFrontmatter = extractFrontmatter;
|
|
96
|
+
//# sourceMappingURL=mdx-ast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdx-ast.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/mcp-server/mdx-ast.ts"],"names":[],"mappings":";;;;AAWA,8DAA2B;AAC3B,mDAAsD;AAK/C,MAAM,YAAY,GAAG,CAAC,IAAiB,EAAsB,EAAE,CACpE,IAAI,CAAC,IAAI,KAAK,mBAAmB,IAAI,IAAI,CAAC,IAAI,KAAK,mBAAmB,CAAC;AAD5D,QAAA,YAAY,gBACgD;AAEzE,MAAM,QAAQ,GAAG,CACf,IAAgB,EAChB,IAAY,EACiB,EAAE,CAC/B,IAAI,CAAC,UAAU,CAAC,IAAI,CAClB,CAAC,CAAC,EAAwB,EAAE,CAC1B,CAAC,CAAC,IAAI,KAAK,iBAAiB,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAClD,CAAC;AAEG,MAAM,cAAc,GAAG,CAC5B,IAAgB,EAChB,IAAY,EACQ,EAAE;IACtB,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,OAAO,OAAO,IAAI,EAAE,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC,CAAC;AANW,QAAA,cAAc,kBAMzB;AAEK,MAAM,kBAAkB,GAAG,CAChC,IAAgB,EAChB,IAAY,EACQ,EAAE;IACtB,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,KAAK,IAA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E,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;IAClE,CAAC;IACD,MAAM,IAAI,GACR,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAC5D,CAAC,CAAE,MAAkC;QACrC,CAAC,CAAC,EAAE,CAAC;IACT,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;AAC9D,CAAC,CAAC;AAhBW,QAAA,kBAAkB,sBAgB7B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Predicate helpers for `<OptionFilter when>` / `<TabItem _filter>`.
|
|
7
|
+
* Parses the estree AST that remark-mdx attaches to each attribute value
|
|
8
|
+
* — we never evaluate arbitrary JS; only string/number/boolean literals and
|
|
9
|
+
* arrays of them are allowed so the same helpers can run in the browser
|
|
10
|
+
* and in the user's shell.
|
|
11
|
+
*/
|
|
12
|
+
import type { Node as EstreeNode } from 'estree';
|
|
13
|
+
export type Predicate = Record<string, string[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Turn the `data.estree` of an `MdxJsxAttributeValueExpression` into a
|
|
16
|
+
* `Predicate`. The estree is a Program wrapping a single ObjectExpression.
|
|
17
|
+
*/
|
|
18
|
+
export declare const parseWhenExpression: (estree: EstreeNode) => Predicate;
|
|
19
|
+
/**
|
|
20
|
+
* AND across keys, OR within a key's values, `not` negates. A key not
|
|
21
|
+
* present in `options` is "no opinion". A predicate whose keys have no
|
|
22
|
+
* intersection with `options` short-circuits to true.
|
|
23
|
+
*/
|
|
24
|
+
export declare const evaluatePredicate: (predicate: Predicate, not: boolean, options: Record<string, string>) => boolean;
|
|
25
|
+
/** Short human label used on the docs pill and in the `> [!NOTE] Only when …` marker. */
|
|
26
|
+
export declare const describePredicate: (predicate: Predicate, not: boolean) => string;
|
|
27
|
+
/**
|
|
28
|
+
* Extract a `string[]` from the estree of an attribute-value expression
|
|
29
|
+
* like `{['a', 'b']}`. Used by JSX attribute readers (e.g. the
|
|
30
|
+
* `commands={[...]}` prop on <NxCommands>). Throws if anything other than
|
|
31
|
+
* string / number / boolean literal array elements are encountered.
|
|
32
|
+
*/
|
|
33
|
+
export declare const extractStringArrayExpression: (estree: EstreeNode) => string[];
|