@redocly/openapi-core 0.0.0-snapshot.1786626470 → 0.0.0-snapshot.1786811652
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/lib/api-graph/build-graph.d.ts +71 -0
- package/lib/api-graph/build-graph.d.ts.map +1 -0
- package/lib/api-graph/build-graph.js +418 -0
- package/lib/api-graph/build-graph.js.map +1 -0
- package/lib/api-graph/build-index.d.ts +39 -0
- package/lib/api-graph/build-index.d.ts.map +1 -0
- package/lib/api-graph/build-index.js +191 -0
- package/lib/api-graph/build-index.js.map +1 -0
- package/lib/api-graph/file-view.d.ts +27 -0
- package/lib/api-graph/file-view.d.ts.map +1 -0
- package/lib/api-graph/file-view.js +51 -0
- package/lib/api-graph/file-view.js.map +1 -0
- package/lib/api-graph/find.d.ts +20 -0
- package/lib/api-graph/find.d.ts.map +1 -0
- package/lib/api-graph/find.js +75 -0
- package/lib/api-graph/find.js.map +1 -0
- package/lib/api-graph/node-id.d.ts +28 -0
- package/lib/api-graph/node-id.d.ts.map +1 -0
- package/lib/api-graph/node-id.js +100 -0
- package/lib/api-graph/node-id.js.map +1 -0
- package/lib/api-graph/pointer.d.ts +86 -0
- package/lib/api-graph/pointer.d.ts.map +1 -0
- package/lib/api-graph/pointer.js +213 -0
- package/lib/api-graph/pointer.js.map +1 -0
- package/lib/api-graph/select.d.ts +15 -0
- package/lib/api-graph/select.d.ts.map +1 -0
- package/lib/api-graph/select.js +71 -0
- package/lib/api-graph/select.js.map +1 -0
- package/lib/api-graph/slice.d.ts +54 -0
- package/lib/api-graph/slice.d.ts.map +1 -0
- package/lib/api-graph/slice.js +211 -0
- package/lib/api-graph/slice.js.map +1 -0
- package/lib/api-graph/types.d.ts +26 -0
- package/lib/api-graph/types.d.ts.map +1 -0
- package/lib/api-graph/types.js +2 -0
- package/lib/api-graph/types.js.map +1 -0
- package/lib/api-graph/views.d.ts +139 -0
- package/lib/api-graph/views.d.ts.map +1 -0
- package/lib/api-graph/views.js +348 -0
- package/lib/api-graph/views.js.map +1 -0
- package/lib/format/codeframes.d.ts +5 -0
- package/lib/format/codeframes.d.ts.map +1 -1
- package/lib/format/codeframes.js +74 -19
- package/lib/format/codeframes.js.map +1 -1
- package/lib/index.d.ts +11 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +9 -0
- package/lib/index.js.map +1 -1
- package/lib/resolve.d.ts +6 -0
- package/lib/resolve.d.ts.map +1 -1
- package/lib/resolve.js +30 -0
- package/lib/resolve.js.map +1 -1
- package/lib/types/redocly-yaml.d.ts.map +1 -1
- package/lib/types/redocly-yaml.js +0 -12
- package/lib/types/redocly-yaml.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { getContentLineColLocation } from '../format/codeframes.js';
|
|
3
|
+
import { isAbsoluteUrl } from '../ref-utils.js';
|
|
4
|
+
export const SUMMARY_LIMIT = 160;
|
|
5
|
+
const UNTAGGED = 'untagged';
|
|
6
|
+
/** OpenAPI component sections, in the order the index lists them. */
|
|
7
|
+
export const COMPONENT_SECTIONS = [
|
|
8
|
+
'schemas',
|
|
9
|
+
'responses',
|
|
10
|
+
'parameters',
|
|
11
|
+
'requestBodies',
|
|
12
|
+
'headers',
|
|
13
|
+
'securitySchemes',
|
|
14
|
+
'examples',
|
|
15
|
+
'links',
|
|
16
|
+
'callbacks',
|
|
17
|
+
];
|
|
18
|
+
export function buildApiIndex(analysis, options) {
|
|
19
|
+
const { meta, rootDocument } = analysis;
|
|
20
|
+
const { specVersion, cwd, groupBy } = options;
|
|
21
|
+
const structure = [];
|
|
22
|
+
if (meta.info) {
|
|
23
|
+
const summary = truncateSummary(meta.info.description);
|
|
24
|
+
structure.push({
|
|
25
|
+
id: 'Overview',
|
|
26
|
+
title: 'Overview',
|
|
27
|
+
...toFileRange(meta.info.location, cwd),
|
|
28
|
+
...(summary ? { summary } : {}),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (meta.servers) {
|
|
32
|
+
const summary = truncateSummary(meta.servers.urls.join(', '));
|
|
33
|
+
structure.push({
|
|
34
|
+
id: 'Servers',
|
|
35
|
+
title: 'Servers',
|
|
36
|
+
...toFileRange(meta.servers.location, cwd),
|
|
37
|
+
...(summary ? { summary } : {}),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const pathOperations = meta.operations.filter((operation) => !operation.isWebhook);
|
|
41
|
+
if (pathOperations.length > 0) {
|
|
42
|
+
structure.push({
|
|
43
|
+
id: 'Operations',
|
|
44
|
+
title: 'Operations',
|
|
45
|
+
...(meta.pathsLocation ? toFileRange(meta.pathsLocation, cwd) : {}),
|
|
46
|
+
nodes: groupBy === 'tags'
|
|
47
|
+
? groupByTags(pathOperations, meta.declaredTags, cwd)
|
|
48
|
+
: groupByPaths(pathOperations, cwd),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const webhookOperations = meta.operations.filter((operation) => operation.isWebhook);
|
|
52
|
+
if (webhookOperations.length > 0) {
|
|
53
|
+
structure.push({
|
|
54
|
+
id: 'Webhooks',
|
|
55
|
+
title: 'Webhooks',
|
|
56
|
+
...(meta.webhooksLocation ? toFileRange(meta.webhooksLocation, cwd) : {}),
|
|
57
|
+
nodes: webhookOperations.map((operation) => toOperationNode(operation, cwd)),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const componentNodes = groupComponents(meta.components, cwd);
|
|
61
|
+
if (componentNodes.length > 0) {
|
|
62
|
+
structure.push({
|
|
63
|
+
id: 'Components',
|
|
64
|
+
title: 'Components',
|
|
65
|
+
...(meta.componentsLocation ? toFileRange(meta.componentsLocation, cwd) : {}),
|
|
66
|
+
nodes: componentNodes,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const docDescription = meta.info ? buildDocDescription(meta.info) : undefined;
|
|
70
|
+
return {
|
|
71
|
+
docName: toRelativePath(rootDocument.source.absoluteRef, cwd),
|
|
72
|
+
spec: specVersion,
|
|
73
|
+
...(docDescription ? { docDescription } : {}),
|
|
74
|
+
structure,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export function toRelativePath(absoluteRef, cwd) {
|
|
78
|
+
return isAbsoluteUrl(absoluteRef)
|
|
79
|
+
? absoluteRef
|
|
80
|
+
: path.relative(cwd, absoluteRef).split(path.sep).join('/');
|
|
81
|
+
}
|
|
82
|
+
export function toFileRange(location, cwd) {
|
|
83
|
+
const lineCol = getContentLineColLocation({
|
|
84
|
+
source: location.source,
|
|
85
|
+
pointer: location.pointer,
|
|
86
|
+
reportOnKey: false,
|
|
87
|
+
});
|
|
88
|
+
return {
|
|
89
|
+
pointer: location.pointer,
|
|
90
|
+
file: toRelativePath(location.source.absoluteRef, cwd),
|
|
91
|
+
start_line: lineCol.start.line,
|
|
92
|
+
// getContentLineColLocation always computes `end` for a string pointer.
|
|
93
|
+
end_line: lineCol.end.line,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export function truncateSummary(text) {
|
|
97
|
+
if (!text)
|
|
98
|
+
return undefined;
|
|
99
|
+
const normalized = text.replace(/\s+/g, ' ').trim();
|
|
100
|
+
if (!normalized)
|
|
101
|
+
return undefined;
|
|
102
|
+
if (normalized.length <= SUMMARY_LIMIT)
|
|
103
|
+
return normalized;
|
|
104
|
+
const cut = normalized.slice(0, SUMMARY_LIMIT);
|
|
105
|
+
const lastSpace = cut.lastIndexOf(' ');
|
|
106
|
+
return `${lastSpace > 0 ? cut.slice(0, lastSpace) : cut}…`;
|
|
107
|
+
}
|
|
108
|
+
function buildDocDescription(docInfo) {
|
|
109
|
+
return truncateSummary([docInfo.title, docInfo.description].filter(Boolean).join(' — '));
|
|
110
|
+
}
|
|
111
|
+
function toOperationNode(operation, cwd) {
|
|
112
|
+
const titleSuffix = truncateSummary(operation.summary);
|
|
113
|
+
const summary = truncateSummary(operation.summary ?? operation.description);
|
|
114
|
+
return {
|
|
115
|
+
id: operation.id,
|
|
116
|
+
title: titleSuffix ? `${operation.id} — ${titleSuffix}` : operation.id,
|
|
117
|
+
...(operation.operationId ? { operationId: operation.operationId } : {}),
|
|
118
|
+
...(operation.deprecated ? { deprecated: true } : {}),
|
|
119
|
+
...toFileRange(operation.location, cwd),
|
|
120
|
+
...(summary ? { summary } : {}),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function groupByTags(operations, declaredTags, cwd) {
|
|
124
|
+
const groups = new Map();
|
|
125
|
+
for (const operation of operations) {
|
|
126
|
+
const tagNames = operation.tags.length > 0 ? operation.tags : [UNTAGGED];
|
|
127
|
+
for (const tagName of new Set(tagNames)) {
|
|
128
|
+
const group = groups.get(tagName) ?? [];
|
|
129
|
+
group.push(operation);
|
|
130
|
+
groups.set(tagName, group);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const orderedNames = [
|
|
134
|
+
...declaredTags.map((tag) => tag.name),
|
|
135
|
+
...[...groups.keys()].filter((name) => name !== UNTAGGED && !declaredTags.some((tag) => tag.name === name)),
|
|
136
|
+
UNTAGGED,
|
|
137
|
+
];
|
|
138
|
+
const nodes = [];
|
|
139
|
+
for (const name of orderedNames) {
|
|
140
|
+
const groupOperations = groups.get(name);
|
|
141
|
+
if (!groupOperations)
|
|
142
|
+
continue;
|
|
143
|
+
const declared = declaredTags.find((tag) => tag.name === name);
|
|
144
|
+
const summary = truncateSummary(declared?.description);
|
|
145
|
+
nodes.push({
|
|
146
|
+
id: name,
|
|
147
|
+
title: name,
|
|
148
|
+
...(declared ? toFileRange(declared.location, cwd) : {}),
|
|
149
|
+
...(summary ? { summary } : {}),
|
|
150
|
+
nodes: groupOperations.map((operation) => toOperationNode(operation, cwd)),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
return nodes;
|
|
154
|
+
}
|
|
155
|
+
function groupByPaths(operations, cwd) {
|
|
156
|
+
const groups = new Map();
|
|
157
|
+
for (const operation of operations) {
|
|
158
|
+
const group = groups.get(operation.containerKey) ?? {
|
|
159
|
+
location: operation.pathItemLocation,
|
|
160
|
+
operations: [],
|
|
161
|
+
};
|
|
162
|
+
group.operations.push(operation);
|
|
163
|
+
groups.set(operation.containerKey, group);
|
|
164
|
+
}
|
|
165
|
+
return [...groups.entries()].map(([pathKey, group]) => ({
|
|
166
|
+
id: pathKey,
|
|
167
|
+
title: pathKey,
|
|
168
|
+
...toFileRange(group.location, cwd),
|
|
169
|
+
nodes: group.operations.map((operation) => toOperationNode(operation, cwd)),
|
|
170
|
+
}));
|
|
171
|
+
}
|
|
172
|
+
function groupComponents(components, cwd) {
|
|
173
|
+
const sections = [...new Set(components.map((component) => component.section))];
|
|
174
|
+
sections.sort((a, b) => COMPONENT_SECTIONS.indexOf(a) - COMPONENT_SECTIONS.indexOf(b));
|
|
175
|
+
return sections.map((section) => ({
|
|
176
|
+
id: `components/${section}`,
|
|
177
|
+
title: section,
|
|
178
|
+
nodes: components
|
|
179
|
+
.filter((component) => component.section === section)
|
|
180
|
+
.map((component) => {
|
|
181
|
+
const summary = truncateSummary(component.description);
|
|
182
|
+
return {
|
|
183
|
+
id: `${section}/${component.name}`,
|
|
184
|
+
title: component.name,
|
|
185
|
+
...toFileRange(component.location, cwd),
|
|
186
|
+
...(summary ? { summary } : {}),
|
|
187
|
+
};
|
|
188
|
+
}),
|
|
189
|
+
}));
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=build-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-index.js","sourceRoot":"","sources":["../../src/api-graph/build-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAiB,MAAM,iBAAiB,CAAC;AAQ/D,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AACjC,MAAM,QAAQ,GAAG,UAAU,CAAC;AAE5B,qEAAqE;AACr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,CAAC;aACpD,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;YACjB,MAAM,OAAO,GAAG,eAAe,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YACvD,OAAO;gBACL,EAAE,EAAE,GAAG,OAAO,IAAI,SAAS,CAAC,IAAI,EAAE;gBAClC,KAAK,EAAE,SAAS,CAAC,IAAI;gBACrB,GAAG,WAAW,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC;gBACvC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAChC,CAAC;QACJ,CAAC,CAAC;KACL,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ApiAnalysis } from './build-graph.js';
|
|
2
|
+
import { type ComponentListCard, type OperationListCard, type UsedByReport } from './views.js';
|
|
3
|
+
export type FileCard = {
|
|
4
|
+
file: string;
|
|
5
|
+
defines: (OperationListCard | ComponentListCard)[];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Card-shaped view of everything a single file defines: every operation and component whose
|
|
9
|
+
* resolved location lands in `filePath`. `filePath` is already normalized to the graph's file-id
|
|
10
|
+
* form by the caller (see `toNodeId`/`toRelativePath`), so it's compared as-is.
|
|
11
|
+
*
|
|
12
|
+
* Returns `undefined` only when the file defines nothing AND isn't a node in the graph either —
|
|
13
|
+
* i.e. it plays no part in this API description. A file that IS a graph node (the root document,
|
|
14
|
+
* or a file whose only role is structural) but defines no operation or component of its own still
|
|
15
|
+
* gets a card, just with an empty `defines`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildFileCard(analysis: ApiAnalysis, filePath: string, options: {
|
|
18
|
+
cwd: string;
|
|
19
|
+
}): FileCard | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Reverse analysis for a whole file: seeds the BFS from every graph node the file defines
|
|
22
|
+
* (operations, components, and any structural node stamped with this file), then merges the
|
|
23
|
+
* resulting chains, keeping the shortest one per referrer. A referrer that itself lives in
|
|
24
|
+
* `filePath` is excluded — a file doesn't count as affecting itself.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildFileUsedByReport(analysis: ApiAnalysis, filePath: string, cwd: string): UsedByReport;
|
|
27
|
+
//# sourceMappingURL=file-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-view.d.ts","sourceRoot":"","sources":["../../src/api-graph/file-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE3E,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAClB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,QAAQ,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,EAAE,CAAA;CAAE,CAAC;AAE5F;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,WAAW,EACrB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,GACvB,QAAQ,GAAG,SAAS,CAmBtB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,WAAW,EACrB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,YAAY,CA0Bd"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { collectReversePathsTo } from './build-graph.js';
|
|
2
|
+
import { toFileRange } from './build-index.js';
|
|
3
|
+
import { buildComponentListCard, buildOperationListCard, buildUsedByReportFromChains, } from './views.js';
|
|
4
|
+
/**
|
|
5
|
+
* Card-shaped view of everything a single file defines: every operation and component whose
|
|
6
|
+
* resolved location lands in `filePath`. `filePath` is already normalized to the graph's file-id
|
|
7
|
+
* form by the caller (see `toNodeId`/`toRelativePath`), so it's compared as-is.
|
|
8
|
+
*
|
|
9
|
+
* Returns `undefined` only when the file defines nothing AND isn't a node in the graph either —
|
|
10
|
+
* i.e. it plays no part in this API description. A file that IS a graph node (the root document,
|
|
11
|
+
* or a file whose only role is structural) but defines no operation or component of its own still
|
|
12
|
+
* gets a card, just with an empty `defines`.
|
|
13
|
+
*/
|
|
14
|
+
export function buildFileCard(analysis, filePath, options) {
|
|
15
|
+
const { cwd } = options;
|
|
16
|
+
const operations = analysis.meta.operations.filter((operation) => toFileRange(operation.location, cwd).file === filePath);
|
|
17
|
+
const components = analysis.meta.components.filter((component) => toFileRange(component.location, cwd).file === filePath);
|
|
18
|
+
const isGraphNodeFile = analysis.graph.nodes.some((node) => node.file === filePath);
|
|
19
|
+
if (operations.length === 0 && components.length === 0 && !isGraphNodeFile) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const defines = [
|
|
23
|
+
...operations.map((operation) => buildOperationListCard(analysis, operation, cwd)),
|
|
24
|
+
...components.map((component) => buildComponentListCard(analysis, component, cwd)),
|
|
25
|
+
];
|
|
26
|
+
return { file: filePath, defines };
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Reverse analysis for a whole file: seeds the BFS from every graph node the file defines
|
|
30
|
+
* (operations, components, and any structural node stamped with this file), then merges the
|
|
31
|
+
* resulting chains, keeping the shortest one per referrer. A referrer that itself lives in
|
|
32
|
+
* `filePath` is excluded — a file doesn't count as affecting itself.
|
|
33
|
+
*/
|
|
34
|
+
export function buildFileUsedByReport(analysis, filePath, cwd) {
|
|
35
|
+
const seedIds = [
|
|
36
|
+
...new Set(analysis.graph.nodes
|
|
37
|
+
.filter((node) => node.file === filePath && !node.root)
|
|
38
|
+
.map((node) => node.id)),
|
|
39
|
+
];
|
|
40
|
+
const shortestChains = new Map();
|
|
41
|
+
for (const seedId of seedIds) {
|
|
42
|
+
for (const [referrerId, chain] of collectReversePathsTo(seedId, analysis.graph.edges)) {
|
|
43
|
+
const shortest = shortestChains.get(referrerId);
|
|
44
|
+
if (!shortest || chain.length < shortest.length) {
|
|
45
|
+
shortestChains.set(referrerId, chain);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return buildUsedByReportFromChains(analysis, { id: filePath, file: filePath }, shortestChains, cwd, new Set(seedIds));
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=file-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-view.js","sourceRoot":"","sources":["../../src/api-graph/file-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAoB,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,2BAA2B,GAI5B,MAAM,YAAY,CAAC;AAIpB;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAC3B,QAAqB,EACrB,QAAgB,EAChB,OAAwB;IAExB,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IAExB,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAChD,CAAC,SAAS,EAAE,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,KAAK,QAAQ,CACtE,CAAC;IACF,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAChD,CAAC,SAAS,EAAE,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,KAAK,QAAQ,CACtE,CAAC;IACF,MAAM,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;IACpF,IAAI,UAAU,C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;gBAChD,cAAc,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;YACxC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,2BAA2B,CAChC,QAAQ,EACR,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,EAChC,cAAc,EACd,GAAG,EACH,IAAI,GAAG,CAAC,OAAO,CAAC,CACjB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ApiAnalysis } from './build-graph.js';
|
|
2
|
+
import { type ComponentListCard, type OperationListCard } from './views.js';
|
|
3
|
+
/** Per-kind cap on returned matches; totals still count everything so the caller can say "N more". */
|
|
4
|
+
export declare const FIND_LIMIT = 20;
|
|
5
|
+
export type FindReport = {
|
|
6
|
+
terms: string[];
|
|
7
|
+
operations: OperationListCard[];
|
|
8
|
+
components: ComponentListCard[];
|
|
9
|
+
totalOperations: number;
|
|
10
|
+
totalComponents: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Case-insensitive substring search over the collected index. Every term must match somewhere in
|
|
14
|
+
* the same entry (AND); an entry's score sums per-term field weights, so identifier hits
|
|
15
|
+
* (path/operationId/name) rank above prose hits (summary/description/tags).
|
|
16
|
+
*/
|
|
17
|
+
export declare function findMatches(analysis: ApiAnalysis, terms: string[], options: {
|
|
18
|
+
cwd: string;
|
|
19
|
+
}): FindReport;
|
|
20
|
+
//# sourceMappingURL=find.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../src/api-graph/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAA0C,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAC;AAEpB,sGAAsG;AACtG,eAAO,MAAM,UAAU,KAAK,CAAC;AAE7B,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,WAAW,EACrB,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,GACvB,UAAU,CA2BZ"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { buildComponentListCard, buildOperationListCard, } from './views.js';
|
|
2
|
+
/** Per-kind cap on returned matches; totals still count everything so the caller can say "N more". */
|
|
3
|
+
export const FIND_LIMIT = 20;
|
|
4
|
+
/**
|
|
5
|
+
* Case-insensitive substring search over the collected index. Every term must match somewhere in
|
|
6
|
+
* the same entry (AND); an entry's score sums per-term field weights, so identifier hits
|
|
7
|
+
* (path/operationId/name) rank above prose hits (summary/description/tags).
|
|
8
|
+
*/
|
|
9
|
+
export function findMatches(analysis, terms, options) {
|
|
10
|
+
const normalized = terms.map((term) => term.toLowerCase());
|
|
11
|
+
// scoreAll treats an empty terms array as "every entry matches" (no term fails), so bail out early.
|
|
12
|
+
if (normalized.length === 0) {
|
|
13
|
+
return {
|
|
14
|
+
terms: normalized,
|
|
15
|
+
operations: [],
|
|
16
|
+
components: [],
|
|
17
|
+
totalOperations: 0,
|
|
18
|
+
totalComponents: 0,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const operationMatches = scoreAll(analysis.meta.operations, normalized, scoreOperation);
|
|
22
|
+
const componentMatches = scoreAll(analysis.meta.components, normalized, scoreComponent);
|
|
23
|
+
return {
|
|
24
|
+
terms: normalized,
|
|
25
|
+
operations: operationMatches
|
|
26
|
+
.slice(0, FIND_LIMIT)
|
|
27
|
+
.map((operation) => buildOperationListCard(analysis, operation, options.cwd)),
|
|
28
|
+
components: componentMatches
|
|
29
|
+
.slice(0, FIND_LIMIT)
|
|
30
|
+
.map((component) => buildComponentListCard(analysis, component, options.cwd)),
|
|
31
|
+
totalOperations: operationMatches.length,
|
|
32
|
+
totalComponents: componentMatches.length,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** Keeps entries where every term scores above zero, ranked by descending summed score. */
|
|
36
|
+
function scoreAll(entries, terms, scoreEntry) {
|
|
37
|
+
const scored = [];
|
|
38
|
+
for (const entry of entries) {
|
|
39
|
+
let total = 0;
|
|
40
|
+
let matchesEveryTerm = true;
|
|
41
|
+
for (const term of terms) {
|
|
42
|
+
const termScore = scoreEntry(entry, term);
|
|
43
|
+
if (termScore === 0) {
|
|
44
|
+
matchesEveryTerm = false;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
total += termScore;
|
|
48
|
+
}
|
|
49
|
+
if (matchesEveryTerm)
|
|
50
|
+
scored.push({ entry, score: total });
|
|
51
|
+
}
|
|
52
|
+
// Sort is stable (V8), so document order breaks ties between equal scores.
|
|
53
|
+
return scored.sort((left, right) => right.score - left.score).map((item) => item.entry);
|
|
54
|
+
}
|
|
55
|
+
/** Identifier fields weigh 2, prose fields 1, no hit 0 — per term. */
|
|
56
|
+
function scoreOperation(operation, term) {
|
|
57
|
+
if (operation.containerKey.toLowerCase().includes(term) ||
|
|
58
|
+
(operation.operationId?.toLowerCase().includes(term) ?? false)) {
|
|
59
|
+
return 2;
|
|
60
|
+
}
|
|
61
|
+
if ((operation.summary?.toLowerCase().includes(term) ?? false) ||
|
|
62
|
+
(operation.description?.toLowerCase().includes(term) ?? false) ||
|
|
63
|
+
operation.tags.some((tag) => tag.toLowerCase().includes(term))) {
|
|
64
|
+
return 1;
|
|
65
|
+
}
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
function scoreComponent(component, term) {
|
|
69
|
+
if (`${component.section}/${component.name}`.toLowerCase().includes(term))
|
|
70
|
+
return 2;
|
|
71
|
+
if (component.description?.toLowerCase().includes(term) ?? false)
|
|
72
|
+
return 1;
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=find.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../src/api-graph/find.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,GAGvB,MAAM,YAAY,CAAC;AAEpB,sGAAsG;AACtG,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,CAAC;AAU7B;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,QAAqB,EACrB,KAAe,EACf,OAAwB;IAExB,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAC3D,oGAAoG;IACpG,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO;YACL,KAAK,EAAE,UAAU;YACjB,UAAU,EAAE,EAAE;YACd,UAAU,EAAE,EAAE;YACd,eAAe,EAAE,CAAC;YAClB,eAAe,EAAE,CAAC;SACnB,CAAC;IACJ,CAAC;IAED,MAAM,gBAAgB,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;IACxF,MAAM,gBAAgB,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;IAExF,OAAO;QACL,KAAK,EAAE,UAAU;QACjB,UAAU,EAAE,gBAAgB;aACzB,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC;aACpB,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,sBAAsB,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QAC/E,UAAU,EAAE,gB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I,CAAC;QACnD,CAAC,SAAS,CAAC,WAAW,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,EAC9D,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;IACD,IACE,CAAC,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC;QAC1D,CAAC,SAAS,CAAC,WAAW,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC;QAC9D,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAC9D,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,cAAc,CAAC,SAA6B,EAAE,IAAY;IACjE,IAAI,GAAG,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IACpF,IAAI,SAAS,CAAC,WAAW,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK;QAAE,OAAO,CAAC,CAAC;IAC3E,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { NodeKind } from './types.js';
|
|
2
|
+
export declare const compareStrings: (a: string, b: string) => number;
|
|
3
|
+
export declare function toNodeId(absoluteRef: string, cwd: string): string;
|
|
4
|
+
export declare function commonDir(dirs: string[]): string;
|
|
5
|
+
export declare const OPERATION_METHODS: Set<string>;
|
|
6
|
+
export type MappedNode = {
|
|
7
|
+
id: string;
|
|
8
|
+
kind: NodeKind;
|
|
9
|
+
/** Ancestor ids for structural spine edges, outermost first ([] = link directly to root; undefined = no structural link). */
|
|
10
|
+
ancestry?: string[];
|
|
11
|
+
};
|
|
12
|
+
export declare function parsePointerSegments(pointer: string): string[];
|
|
13
|
+
/**
|
|
14
|
+
* Maps a JSON pointer inside the root document to its tree node — the document root, a path, an
|
|
15
|
+
* operation, a component, or a generic top-level group — with a short, file-prefix-free id such as
|
|
16
|
+
* `GET /pets` or `schemas/Pet`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function mapRootPointer(pointer: string, rootId: string): MappedNode;
|
|
19
|
+
/**
|
|
20
|
+
* Maps a location in another file to its tree node — a component inside that file or the whole file.
|
|
21
|
+
* A component address is `components/{type}/{name}` in OAS 3.x (first 3 segments) or `{section}/{name}`
|
|
22
|
+
* in OAS 2.0 (first 2); anything deeper, like a property, collapses back to that component.
|
|
23
|
+
* Examples: `common.yaml#/components/schemas/Pet` (kept copy-pasteable as a `$ref`), `schemas/pet.yaml`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function mapForeignLocation(fileId: string, pointer: string): MappedNode & {
|
|
26
|
+
file: string;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=node-id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-id.d.ts","sourceRoot":"","sources":["../../src/api-graph/node-id.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,eAAO,MAAM,cAAc,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,MAAsC,CAAC;AAE7F,wBAAgB,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAWhD;AAED,eAAO,MAAM,iBAAiB,aAW5B,CAAC;AASH,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,QAAQ,CAAC;IACf,6HAA6H;IAC7H,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAM9D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAuB1E;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAoBjG"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { escapePointerFragment, isAbsoluteUrl, unescapePointerFragment } from '../ref-utils.js';
|
|
3
|
+
import { slash } from '../utils/slash.js';
|
|
4
|
+
export const compareStrings = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
5
|
+
export function toNodeId(absoluteRef, cwd) {
|
|
6
|
+
return isAbsoluteUrl(absoluteRef) ? absoluteRef : slash(path.relative(cwd, absoluteRef));
|
|
7
|
+
}
|
|
8
|
+
export function commonDir(dirs) {
|
|
9
|
+
if (dirs.length === 0)
|
|
10
|
+
return '';
|
|
11
|
+
const segmented = dirs.map((dir) => slash(dir).split('/'));
|
|
12
|
+
const [first, ...rest] = segmented;
|
|
13
|
+
let end = first.length;
|
|
14
|
+
for (const parts of rest) {
|
|
15
|
+
let i = 0;
|
|
16
|
+
while (i < end && parts[i] === first[i])
|
|
17
|
+
i++;
|
|
18
|
+
end = i;
|
|
19
|
+
}
|
|
20
|
+
return first.slice(0, end).join('/') || '/';
|
|
21
|
+
}
|
|
22
|
+
export const OPERATION_METHODS = new Set([
|
|
23
|
+
'get',
|
|
24
|
+
'put',
|
|
25
|
+
'post',
|
|
26
|
+
'delete',
|
|
27
|
+
'options',
|
|
28
|
+
'head',
|
|
29
|
+
'patch',
|
|
30
|
+
'trace',
|
|
31
|
+
'query',
|
|
32
|
+
'x-query',
|
|
33
|
+
]);
|
|
34
|
+
const OAS2_COMPONENT_SECTIONS = new Set([
|
|
35
|
+
'definitions',
|
|
36
|
+
'parameters',
|
|
37
|
+
'responses',
|
|
38
|
+
'securityDefinitions',
|
|
39
|
+
]);
|
|
40
|
+
export function parsePointerSegments(pointer) {
|
|
41
|
+
return pointer
|
|
42
|
+
.replace(/^#?\/?/, '')
|
|
43
|
+
.split('/')
|
|
44
|
+
.filter(Boolean)
|
|
45
|
+
.map(unescapePointerFragment);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Maps a JSON pointer inside the root document to its tree node — the document root, a path, an
|
|
49
|
+
* operation, a component, or a generic top-level group — with a short, file-prefix-free id such as
|
|
50
|
+
* `GET /pets` or `schemas/Pet`.
|
|
51
|
+
*/
|
|
52
|
+
export function mapRootPointer(pointer, rootId) {
|
|
53
|
+
const segments = parsePointerSegments(pointer);
|
|
54
|
+
if (segments.length === 0) {
|
|
55
|
+
return { id: rootId, kind: 'root' };
|
|
56
|
+
}
|
|
57
|
+
const [head, second, third] = segments;
|
|
58
|
+
if (head === 'paths' && second !== undefined) {
|
|
59
|
+
if (third !== undefined && OPERATION_METHODS.has(third)) {
|
|
60
|
+
return { id: `${third.toUpperCase()} ${second}`, kind: 'operation', ancestry: [second] };
|
|
61
|
+
}
|
|
62
|
+
return { id: second, kind: 'path', ancestry: [] };
|
|
63
|
+
}
|
|
64
|
+
if (head === 'components' && second !== undefined && third !== undefined) {
|
|
65
|
+
return { id: `${second}/${third}`, kind: 'component' };
|
|
66
|
+
}
|
|
67
|
+
if (OAS2_COMPONENT_SECTIONS.has(head) && second !== undefined) {
|
|
68
|
+
return { id: `${head}/${second}`, kind: 'component' };
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
id: second !== undefined ? `${head}/${second}` : head,
|
|
72
|
+
kind: 'component',
|
|
73
|
+
ancestry: [],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Maps a location in another file to its tree node — a component inside that file or the whole file.
|
|
78
|
+
* A component address is `components/{type}/{name}` in OAS 3.x (first 3 segments) or `{section}/{name}`
|
|
79
|
+
* in OAS 2.0 (first 2); anything deeper, like a property, collapses back to that component.
|
|
80
|
+
* Examples: `common.yaml#/components/schemas/Pet` (kept copy-pasteable as a `$ref`), `schemas/pet.yaml`.
|
|
81
|
+
*/
|
|
82
|
+
export function mapForeignLocation(fileId, pointer) {
|
|
83
|
+
const segments = parsePointerSegments(pointer);
|
|
84
|
+
let componentPath;
|
|
85
|
+
if (segments[0] === 'components' && segments.length >= 3) {
|
|
86
|
+
componentPath = segments.slice(0, 3);
|
|
87
|
+
}
|
|
88
|
+
else if (OAS2_COMPONENT_SECTIONS.has(segments[0]) &&
|
|
89
|
+
segments.length >= 2 &&
|
|
90
|
+
// A numeric key is an array index (path-item `parameters`), not a named OAS2 component.
|
|
91
|
+
!/^\d+$/.test(segments[1])) {
|
|
92
|
+
componentPath = segments.slice(0, 2);
|
|
93
|
+
}
|
|
94
|
+
if (componentPath) {
|
|
95
|
+
const canonical = componentPath.map(escapePointerFragment).join('/');
|
|
96
|
+
return { id: `${fileId}#/${canonical}`, kind: 'component', file: fileId };
|
|
97
|
+
}
|
|
98
|
+
return { id: fileId, kind: 'file', file: fileId };
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=node-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-id.js","sourceRoot":"","sources":["../../src/api-graph/node-id.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAChG,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG1C,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAS,EAAE,CAAS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QACrE,OAAO,EAAE,EAAE,EAAE,GAAG,MAAM,KAAK,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC5E,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type ApiAnalysis, type CollectedComponent, type CollectedOperation } from './build-graph.js';
|
|
2
|
+
import { type ApiNodeEnvelope } from './slice.js';
|
|
3
|
+
import { type TypedRef } from './views.js';
|
|
4
|
+
export type PointerAncestor = {
|
|
5
|
+
id: string;
|
|
6
|
+
pointer: string;
|
|
7
|
+
file: string;
|
|
8
|
+
start_line: number;
|
|
9
|
+
end_line: number;
|
|
10
|
+
usedByCount: number;
|
|
11
|
+
};
|
|
12
|
+
export type PointerCard = {
|
|
13
|
+
pointer: string;
|
|
14
|
+
file: string;
|
|
15
|
+
start_line: number;
|
|
16
|
+
end_line: number;
|
|
17
|
+
content: string;
|
|
18
|
+
refs: TypedRef[];
|
|
19
|
+
truncated?: boolean;
|
|
20
|
+
ancestor?: PointerAncestor;
|
|
21
|
+
};
|
|
22
|
+
export type PointerResolution = {
|
|
23
|
+
kind: 'component';
|
|
24
|
+
component: CollectedComponent;
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'operation';
|
|
27
|
+
operation: CollectedOperation;
|
|
28
|
+
}
|
|
29
|
+
/** `#/` (or empty): the same overview the bare invocation renders. */
|
|
30
|
+
| {
|
|
31
|
+
kind: 'overview';
|
|
32
|
+
}
|
|
33
|
+
/** `#/paths`: every non-webhook operation, the same listing `--operations` renders. */
|
|
34
|
+
| {
|
|
35
|
+
kind: 'all-operations';
|
|
36
|
+
}
|
|
37
|
+
/** `#/webhooks`: every webhook operation, the same listing `--webhooks` renders. */
|
|
38
|
+
| {
|
|
39
|
+
kind: 'all-webhooks';
|
|
40
|
+
}
|
|
41
|
+
/** `#/components`: not a bounded view on its own — the caller rejects it, naming the sections. */
|
|
42
|
+
| {
|
|
43
|
+
kind: 'components-root';
|
|
44
|
+
}
|
|
45
|
+
/** `#/components/<section>`: that section's components, the same listing `--component` renders. */
|
|
46
|
+
| {
|
|
47
|
+
kind: 'component-section';
|
|
48
|
+
section: string;
|
|
49
|
+
}
|
|
50
|
+
/** `#/paths/<path>` (the path exists): that path's operations, the same listing `--path` renders. */
|
|
51
|
+
| {
|
|
52
|
+
kind: 'path-operations';
|
|
53
|
+
path: string;
|
|
54
|
+
}
|
|
55
|
+
/** `#/webhooks/<name>` (the webhook exists): that webhook's operations, the same listing `--webhook` renders. */
|
|
56
|
+
| {
|
|
57
|
+
kind: 'webhook-operations';
|
|
58
|
+
webhook: string;
|
|
59
|
+
} | {
|
|
60
|
+
kind: 'deep';
|
|
61
|
+
pointer: string;
|
|
62
|
+
envelope: ApiNodeEnvelope;
|
|
63
|
+
ancestor?: PointerAncestor;
|
|
64
|
+
} | {
|
|
65
|
+
kind: 'unresolved';
|
|
66
|
+
pointer: string;
|
|
67
|
+
nearestResolvable?: string;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Resolves a raw JSON pointer (as it appears in lint problems, `--format=json` refs, or diffs)
|
|
71
|
+
* against the analyzed API: an indexed match (component/operation/webhook) routes to the same
|
|
72
|
+
* result a typed selector would produce; a pointer that lands exactly on a container boundary —
|
|
73
|
+
* the document root, `paths`, `webhooks`, `components`, one component section, or one path —
|
|
74
|
+
* routes to the same bounded listing its typed selector equivalent produces, instead of slicing
|
|
75
|
+
* that whole subtree; anything else that still resolves inside the root document comes back as a
|
|
76
|
+
* `deep` node with its own coordinates, content, and nearest indexed ancestor. Root-document
|
|
77
|
+
* pointers only — a split layout's other files are out of scope for v1.
|
|
78
|
+
*/
|
|
79
|
+
export declare function resolvePointerSelector(analysis: ApiAnalysis, pointerInput: string, options: {
|
|
80
|
+
cwd: string;
|
|
81
|
+
}): PointerResolution;
|
|
82
|
+
/** Builds the renderable card for a `deep` pointer resolution: coordinates, body, and typed refs. */
|
|
83
|
+
export declare function buildPointerCard(resolution: Extract<PointerResolution, {
|
|
84
|
+
kind: 'deep';
|
|
85
|
+
}>): PointerCard;
|
|
86
|
+
//# sourceMappingURL=pointer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../src/api-graph/pointer.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,WAAW,EAEhB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAS1B,OAAO,EAA6C,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7F,OAAO,EAA4B,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAErE,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,kBAAkB,CAAA;CAAE,GACpD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,kBAAkB,CAAA;CAAE;AACt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