@telorun/analyzer 0.39.0 → 0.41.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/dist/cel-ast.d.ts +98 -0
- package/dist/cel-ast.d.ts.map +1 -0
- package/dist/cel-ast.js +188 -0
- package/dist/import-resolution-diagnostics.d.ts +20 -0
- package/dist/import-resolution-diagnostics.d.ts.map +1 -0
- package/dist/import-resolution-diagnostics.js +59 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/loaded-types.d.ts +19 -2
- package/dist/loaded-types.d.ts.map +1 -1
- package/dist/manifest-loader.d.ts.map +1 -1
- package/dist/manifest-loader.js +11 -1
- package/dist/parse-loaded-file.d.ts.map +1 -1
- package/dist/parse-loaded-file.js +4 -1
- package/dist/position-metadata.d.ts +7 -6
- package/dist/position-metadata.d.ts.map +1 -1
- package/dist/position-metadata.js +11 -18
- package/dist/sources/local-path-ref.d.ts +4 -0
- package/dist/sources/local-path-ref.d.ts.map +1 -0
- package/dist/sources/local-path-ref.js +5 -0
- package/dist/yaml-ast.d.ts +46 -0
- package/dist/yaml-ast.d.ts.map +1 -0
- package/dist/yaml-ast.js +58 -0
- package/package.json +1 -1
- package/src/cel-ast.ts +259 -0
- package/src/import-resolution-diagnostics.ts +66 -0
- package/src/index.ts +7 -0
- package/src/loaded-types.ts +19 -2
- package/src/manifest-loader.ts +11 -1
- package/src/parse-loaded-file.ts +4 -1
- package/src/position-metadata.ts +17 -21
- package/src/sources/local-path-ref.ts +5 -0
- package/src/yaml-ast.ts +108 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { type ASTNode as CelJsNode } from "@marcbachmann/cel-js";
|
|
2
|
+
/** Read-only CEL expression tree owned by the analyzer. The third-party
|
|
3
|
+
* `@marcbachmann/cel-js` `ASTNode` stays an internal detail — `wrapCelAst`
|
|
4
|
+
* translates it into this union so no external AST type leaks through the
|
|
5
|
+
* public surface (full symmetry with the YAML `AstNode` decision). Every
|
|
6
|
+
* `range` is `[start, end]` in DOCUMENT offsets. */
|
|
7
|
+
export type CelNode = {
|
|
8
|
+
kind: "literal";
|
|
9
|
+
range: [number, number];
|
|
10
|
+
value: unknown;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "ident";
|
|
13
|
+
range: [number, number];
|
|
14
|
+
name: string;
|
|
15
|
+
} | {
|
|
16
|
+
kind: "member";
|
|
17
|
+
range: [number, number];
|
|
18
|
+
target: CelNode;
|
|
19
|
+
property: string;
|
|
20
|
+
/** Span of just the `.prop` identifier, for a future rename. */
|
|
21
|
+
propertyRange: [number, number];
|
|
22
|
+
/** `.?` optional member access. */
|
|
23
|
+
optional: boolean;
|
|
24
|
+
} | {
|
|
25
|
+
kind: "index";
|
|
26
|
+
range: [number, number];
|
|
27
|
+
target: CelNode;
|
|
28
|
+
index: CelNode;
|
|
29
|
+
/** `[?]` optional index. */
|
|
30
|
+
optional: boolean;
|
|
31
|
+
} | {
|
|
32
|
+
kind: "call";
|
|
33
|
+
range: [number, number];
|
|
34
|
+
name: string;
|
|
35
|
+
args: CelNode[];
|
|
36
|
+
} | {
|
|
37
|
+
kind: "methodCall";
|
|
38
|
+
range: [number, number];
|
|
39
|
+
name: string;
|
|
40
|
+
receiver: CelNode;
|
|
41
|
+
args: CelNode[];
|
|
42
|
+
} | {
|
|
43
|
+
kind: "list";
|
|
44
|
+
range: [number, number];
|
|
45
|
+
items: CelNode[];
|
|
46
|
+
} | {
|
|
47
|
+
kind: "map";
|
|
48
|
+
range: [number, number];
|
|
49
|
+
entries: {
|
|
50
|
+
key: CelNode;
|
|
51
|
+
value: CelNode;
|
|
52
|
+
}[];
|
|
53
|
+
} | {
|
|
54
|
+
kind: "ternary";
|
|
55
|
+
range: [number, number];
|
|
56
|
+
cond: CelNode;
|
|
57
|
+
then: CelNode;
|
|
58
|
+
else: CelNode;
|
|
59
|
+
} | {
|
|
60
|
+
kind: "unary";
|
|
61
|
+
range: [number, number];
|
|
62
|
+
op: string;
|
|
63
|
+
operand: CelNode;
|
|
64
|
+
} | {
|
|
65
|
+
kind: "binary";
|
|
66
|
+
range: [number, number];
|
|
67
|
+
op: string;
|
|
68
|
+
left: CelNode;
|
|
69
|
+
right: CelNode;
|
|
70
|
+
};
|
|
71
|
+
/** A `${{ }}` / `!cel` region inside a YAML scalar. Ranges are DOCUMENT
|
|
72
|
+
* offsets; `source` is the CEL body (a longest-valid prefix when `open`).
|
|
73
|
+
* `ast()` parses lazily — nothing parses CEL during `parseToAst`, only the
|
|
74
|
+
* expression a caller actually inspects. */
|
|
75
|
+
export interface CelSegment {
|
|
76
|
+
/** Segment span in document offsets (includes the `${{ }}` for interpolation). */
|
|
77
|
+
range: [number, number];
|
|
78
|
+
/** The CEL body (a prefix when `open`). */
|
|
79
|
+
source: string;
|
|
80
|
+
/** True when a `${{` has no matching `}}` yet (the user is mid-typing). */
|
|
81
|
+
open: boolean;
|
|
82
|
+
/** Lazily parse + wrap; ranges are already absolute. */
|
|
83
|
+
ast(): CelNode;
|
|
84
|
+
}
|
|
85
|
+
/** Maps a `@marcbachmann/cel-js` node into the analyzer `CelNode`, translating
|
|
86
|
+
* each node's segment-relative `start`/`end` to absolute document offsets by
|
|
87
|
+
* adding `segmentStart`. */
|
|
88
|
+
export declare function wrapCelAst(node: CelJsNode, segmentStart: number): CelNode;
|
|
89
|
+
/** Build the CEL segments of a scalar from its raw source slice. `scalarText`
|
|
90
|
+
* is `text.slice(start, valueEnd)` and `scalarStart` its document offset.
|
|
91
|
+
*
|
|
92
|
+
* - `tag === "!cel"` → one closed segment spanning the tagged body.
|
|
93
|
+
* - otherwise → one closed segment per `${{ … }}` match, plus a trailing
|
|
94
|
+
* `open` segment for a dangling `${{` with no `}}` (bounded to its line, so
|
|
95
|
+
* an unterminated quote that swallowed following lines still recovers the
|
|
96
|
+
* region the user is typing in). */
|
|
97
|
+
export declare function buildCelSegments(scalarText: string, scalarStart: number, tag: string | undefined, taggedSource: string | undefined): CelSegment[];
|
|
98
|
+
//# sourceMappingURL=cel-ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cel-ast.d.ts","sourceRoot":"","sources":["../src/cel-ast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,OAAO,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAExE;;;;qDAIqD;AACrD,MAAM,MAAM,OAAO,GACf;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC5D;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACxD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,mCAAmC;IACnC,QAAQ,EAAE,OAAO,CAAC;CACnB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,4BAA4B;IAC5B,QAAQ,EAAE,OAAO,CAAC;CACnB,GACD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,EAAE,CAAA;CAAE,GACxE;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,CAAC,MAAM,EAAE,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D;;6BAE6B;AAC7B,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAiFzE;AA0BD;;;;;;;uCAOuC;AACvC,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,UAAU,EAAE,CAuDd"}
|
package/dist/cel-ast.js
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { parse } from "@marcbachmann/cel-js";
|
|
2
|
+
const BINARY_OPS = new Set([
|
|
3
|
+
"!=",
|
|
4
|
+
"==",
|
|
5
|
+
"in",
|
|
6
|
+
"+",
|
|
7
|
+
"-",
|
|
8
|
+
"*",
|
|
9
|
+
"/",
|
|
10
|
+
"%",
|
|
11
|
+
"<",
|
|
12
|
+
"<=",
|
|
13
|
+
">",
|
|
14
|
+
">=",
|
|
15
|
+
"||",
|
|
16
|
+
"&&",
|
|
17
|
+
]);
|
|
18
|
+
/** Maps a `@marcbachmann/cel-js` node into the analyzer `CelNode`, translating
|
|
19
|
+
* each node's segment-relative `start`/`end` to absolute document offsets by
|
|
20
|
+
* adding `segmentStart`. */
|
|
21
|
+
export function wrapCelAst(node, segmentStart) {
|
|
22
|
+
const range = abs(node, segmentStart);
|
|
23
|
+
const op = node.op;
|
|
24
|
+
const args = node.args;
|
|
25
|
+
if (op === "value")
|
|
26
|
+
return { kind: "literal", range, value: args };
|
|
27
|
+
if (op === "id")
|
|
28
|
+
return { kind: "ident", range, name: String(args) };
|
|
29
|
+
if (op === "." || op === ".?") {
|
|
30
|
+
const [target, property] = args;
|
|
31
|
+
return {
|
|
32
|
+
kind: "member",
|
|
33
|
+
range,
|
|
34
|
+
target: wrapCelAst(target, segmentStart),
|
|
35
|
+
property,
|
|
36
|
+
propertyRange: [range[1] - property.length, range[1]],
|
|
37
|
+
optional: op === ".?",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (op === "[]" || op === "[?]") {
|
|
41
|
+
const [target, index] = args;
|
|
42
|
+
return {
|
|
43
|
+
kind: "index",
|
|
44
|
+
range,
|
|
45
|
+
target: wrapCelAst(target, segmentStart),
|
|
46
|
+
index: wrapCelAst(index, segmentStart),
|
|
47
|
+
optional: op === "[?]",
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (op === "call") {
|
|
51
|
+
const [name, callArgs] = args;
|
|
52
|
+
return { kind: "call", range, name, args: callArgs.map((a) => wrapCelAst(a, segmentStart)) };
|
|
53
|
+
}
|
|
54
|
+
if (op === "rcall") {
|
|
55
|
+
const [name, receiver, callArgs] = args;
|
|
56
|
+
return {
|
|
57
|
+
kind: "methodCall",
|
|
58
|
+
range,
|
|
59
|
+
name,
|
|
60
|
+
receiver: wrapCelAst(receiver, segmentStart),
|
|
61
|
+
args: callArgs.map((a) => wrapCelAst(a, segmentStart)),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (op === "list") {
|
|
65
|
+
return { kind: "list", range, items: args.map((a) => wrapCelAst(a, segmentStart)) };
|
|
66
|
+
}
|
|
67
|
+
if (op === "map") {
|
|
68
|
+
return {
|
|
69
|
+
kind: "map",
|
|
70
|
+
range,
|
|
71
|
+
entries: args.map(([k, v]) => ({
|
|
72
|
+
key: wrapCelAst(k, segmentStart),
|
|
73
|
+
value: wrapCelAst(v, segmentStart),
|
|
74
|
+
})),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (op === "?:") {
|
|
78
|
+
const [cond, then, els] = args;
|
|
79
|
+
return {
|
|
80
|
+
kind: "ternary",
|
|
81
|
+
range,
|
|
82
|
+
cond: wrapCelAst(cond, segmentStart),
|
|
83
|
+
then: wrapCelAst(then, segmentStart),
|
|
84
|
+
else: wrapCelAst(els, segmentStart),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (op === "!_" || op === "-_") {
|
|
88
|
+
return { kind: "unary", range, op, operand: wrapCelAst(args, segmentStart) };
|
|
89
|
+
}
|
|
90
|
+
if (BINARY_OPS.has(op)) {
|
|
91
|
+
const [left, right] = args;
|
|
92
|
+
return {
|
|
93
|
+
kind: "binary",
|
|
94
|
+
range,
|
|
95
|
+
op,
|
|
96
|
+
left: wrapCelAst(left, segmentStart),
|
|
97
|
+
right: wrapCelAst(right, segmentStart),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
// Unknown operator — surface it as a literal so consumers can still hit-test
|
|
101
|
+
// the range rather than crash on an unmapped node.
|
|
102
|
+
return { kind: "literal", range, value: undefined };
|
|
103
|
+
}
|
|
104
|
+
function abs(node, segmentStart) {
|
|
105
|
+
const r = node.range ?? { start: node.start, end: node.end };
|
|
106
|
+
return [r.start + segmentStart, r.end + segmentStart];
|
|
107
|
+
}
|
|
108
|
+
/** Parse `source` and wrap it, tolerating a trailing partial member/index
|
|
109
|
+
* access (`req.`, `req.fo`) by falling back to the longest parseable prefix.
|
|
110
|
+
* Used for `open` segments where completion fires mid-token. */
|
|
111
|
+
function parseLenient(source, segmentStart, range) {
|
|
112
|
+
const candidates = [source, source.replace(/[.?[]+\w*$/, ""), source.replace(/[.?[(]+.*$/, "")];
|
|
113
|
+
for (const candidate of candidates) {
|
|
114
|
+
const trimmed = candidate.trim();
|
|
115
|
+
if (!trimmed)
|
|
116
|
+
break;
|
|
117
|
+
try {
|
|
118
|
+
return wrapCelAst(parse(trimmed).ast, segmentStart);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
// try the next-shorter prefix
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return { kind: "ident", range, name: source.trim() };
|
|
125
|
+
}
|
|
126
|
+
const OPEN_MARKER = "${{";
|
|
127
|
+
/** Build the CEL segments of a scalar from its raw source slice. `scalarText`
|
|
128
|
+
* is `text.slice(start, valueEnd)` and `scalarStart` its document offset.
|
|
129
|
+
*
|
|
130
|
+
* - `tag === "!cel"` → one closed segment spanning the tagged body.
|
|
131
|
+
* - otherwise → one closed segment per `${{ … }}` match, plus a trailing
|
|
132
|
+
* `open` segment for a dangling `${{` with no `}}` (bounded to its line, so
|
|
133
|
+
* an unterminated quote that swallowed following lines still recovers the
|
|
134
|
+
* region the user is typing in). */
|
|
135
|
+
export function buildCelSegments(scalarText, scalarStart, tag, taggedSource) {
|
|
136
|
+
if (tag === "!cel" && taggedSource != null) {
|
|
137
|
+
const idx = scalarText.indexOf(taggedSource);
|
|
138
|
+
const bodyStart = scalarStart + (idx >= 0 ? idx : 0);
|
|
139
|
+
const range = [bodyStart, bodyStart + taggedSource.length];
|
|
140
|
+
return [
|
|
141
|
+
{
|
|
142
|
+
range,
|
|
143
|
+
source: taggedSource,
|
|
144
|
+
open: false,
|
|
145
|
+
ast: () => wrapCelAst(parse(taggedSource).ast, bodyStart),
|
|
146
|
+
},
|
|
147
|
+
];
|
|
148
|
+
}
|
|
149
|
+
const segments = [];
|
|
150
|
+
const re = /\$\{\{([\s\S]*?)\}\}/g;
|
|
151
|
+
let match;
|
|
152
|
+
let lastClosedEnd = 0;
|
|
153
|
+
while ((match = re.exec(scalarText)) !== null) {
|
|
154
|
+
const whole = match[0];
|
|
155
|
+
const inner = match[1];
|
|
156
|
+
const leadingWs = inner.match(/^\s*/)?.[0].length ?? 0;
|
|
157
|
+
const bodyStart = scalarStart + match.index + OPEN_MARKER.length + leadingWs;
|
|
158
|
+
const source = inner.trim();
|
|
159
|
+
segments.push({
|
|
160
|
+
range: [scalarStart + match.index, scalarStart + match.index + whole.length],
|
|
161
|
+
source,
|
|
162
|
+
open: false,
|
|
163
|
+
ast: () => wrapCelAst(parse(source).ast, bodyStart),
|
|
164
|
+
});
|
|
165
|
+
lastClosedEnd = match.index + whole.length;
|
|
166
|
+
}
|
|
167
|
+
const openIdx = scalarText.indexOf(OPEN_MARKER, lastClosedEnd);
|
|
168
|
+
if (openIdx >= 0 && scalarText.indexOf("}}", openIdx) < 0) {
|
|
169
|
+
let lineEnd = scalarText.indexOf("\n", openIdx);
|
|
170
|
+
if (lineEnd < 0)
|
|
171
|
+
lineEnd = scalarText.length;
|
|
172
|
+
const after = openIdx + OPEN_MARKER.length;
|
|
173
|
+
// Drop a trailing scalar-closing quote so `foo: "${{ req"` recovers `req`,
|
|
174
|
+
// not `req"` — the quote closes the YAML string, it isn't part of the CEL.
|
|
175
|
+
const rawBody = scalarText.slice(after, lineEnd).replace(/["']\s*$/, "");
|
|
176
|
+
const leadingWs = rawBody.match(/^\s*/)?.[0].length ?? 0;
|
|
177
|
+
const bodyStart = scalarStart + after + leadingWs;
|
|
178
|
+
const source = rawBody.trim();
|
|
179
|
+
const range = [scalarStart + openIdx, scalarStart + lineEnd];
|
|
180
|
+
segments.push({
|
|
181
|
+
range,
|
|
182
|
+
source,
|
|
183
|
+
open: true,
|
|
184
|
+
ast: () => parseLenient(source, bodyStart, range),
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
return segments;
|
|
188
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { LoadedGraph } from "./loaded-types.js";
|
|
2
|
+
import { type AnalysisDiagnostic } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Convert a graph's import-resolution failures (`graph.errors`) into structured,
|
|
5
|
+
* coded diagnostics. This is the single source of truth for surfacing a broken
|
|
6
|
+
* import — every host (CLI, VS Code, telo-editor) routes these instead of each
|
|
7
|
+
* re-deriving the channel and drifting (the VS Code extension used to drop it
|
|
8
|
+
* entirely, showing nothing for a broken import).
|
|
9
|
+
*
|
|
10
|
+
* The analyzer owns only this raw channel conversion; the *presentation* policy
|
|
11
|
+
* — which analysis cascade to hold back for a compromised file — lives in
|
|
12
|
+
* `@telorun/ide-support`'s `assembleGraphDiagnostics`.
|
|
13
|
+
*
|
|
14
|
+
* Each diagnostic adopts the same `data` shape as version-reconciliation
|
|
15
|
+
* diagnostics — `{ filePath, path: "imports.<alias>" }` — so the shared
|
|
16
|
+
* `findPositions` / `resolveRange` routing anchors it on the offending import
|
|
17
|
+
* line with no host-specific code.
|
|
18
|
+
*/
|
|
19
|
+
export declare function importResolutionDiagnostics(graph: LoadedGraph): AnalysisDiagnostic[];
|
|
20
|
+
//# sourceMappingURL=import-resolution-diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-resolution-diagnostics.d.ts","sourceRoot":"","sources":["../src/import-resolution-diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrE,OAAO,EAAsB,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AA8BzE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,WAAW,GAAG,kBAAkB,EAAE,CAepF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { isLocalPathSource } from "./sources/local-path-ref.js";
|
|
2
|
+
import { isRegistryRef } from "./sources/module-ref.js";
|
|
3
|
+
import { isOciRef } from "./sources/oci-ref.js";
|
|
4
|
+
import { DiagnosticSeverity } from "./types.js";
|
|
5
|
+
const SOURCE = "telo-analyzer";
|
|
6
|
+
/** True when `source` is a shape some transport claims — a registry ref, an OCI
|
|
7
|
+
* ref, an HTTP(S) URL, or a relative/absolute path. A source matching none of
|
|
8
|
+
* these is malformed (no transport can ever resolve it), which we report
|
|
9
|
+
* differently from a well-formed ref that simply failed to fetch. */
|
|
10
|
+
function isRecognizedSourceShape(source) {
|
|
11
|
+
return (isRegistryRef(source) ||
|
|
12
|
+
isOciRef(source) ||
|
|
13
|
+
source.startsWith("http://") ||
|
|
14
|
+
source.startsWith("https://") ||
|
|
15
|
+
isLocalPathSource(source));
|
|
16
|
+
}
|
|
17
|
+
function messageFor(e, malformed) {
|
|
18
|
+
const authored = e.source ?? e.url;
|
|
19
|
+
const via = e.alias ? `import '${e.alias}' → '${authored}'` : `'${authored}'`;
|
|
20
|
+
if (malformed) {
|
|
21
|
+
return (`Cannot resolve ${via}: not a recognized module reference. Expected ` +
|
|
22
|
+
`'namespace/name@version', 'oci://host/repo@tag', 'https://…', or a relative path.`);
|
|
23
|
+
}
|
|
24
|
+
return `Cannot resolve ${via}: ${e.error.message}`;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Convert a graph's import-resolution failures (`graph.errors`) into structured,
|
|
28
|
+
* coded diagnostics. This is the single source of truth for surfacing a broken
|
|
29
|
+
* import — every host (CLI, VS Code, telo-editor) routes these instead of each
|
|
30
|
+
* re-deriving the channel and drifting (the VS Code extension used to drop it
|
|
31
|
+
* entirely, showing nothing for a broken import).
|
|
32
|
+
*
|
|
33
|
+
* The analyzer owns only this raw channel conversion; the *presentation* policy
|
|
34
|
+
* — which analysis cascade to hold back for a compromised file — lives in
|
|
35
|
+
* `@telorun/ide-support`'s `assembleGraphDiagnostics`.
|
|
36
|
+
*
|
|
37
|
+
* Each diagnostic adopts the same `data` shape as version-reconciliation
|
|
38
|
+
* diagnostics — `{ filePath, path: "imports.<alias>" }` — so the shared
|
|
39
|
+
* `findPositions` / `resolveRange` routing anchors it on the offending import
|
|
40
|
+
* line with no host-specific code.
|
|
41
|
+
*/
|
|
42
|
+
export function importResolutionDiagnostics(graph) {
|
|
43
|
+
return graph.errors.map((e) => {
|
|
44
|
+
const filePath = e.fromSource ?? graph.entry.owner.source;
|
|
45
|
+
const malformed = !isRecognizedSourceShape(e.source ?? e.url);
|
|
46
|
+
const data = { filePath };
|
|
47
|
+
if (e.alias)
|
|
48
|
+
data.path = `imports.${e.alias}`;
|
|
49
|
+
if (e.sourceLine !== undefined)
|
|
50
|
+
data.sourceLine = e.sourceLine;
|
|
51
|
+
return {
|
|
52
|
+
severity: DiagnosticSeverity.Error,
|
|
53
|
+
code: malformed ? "INVALID_IMPORT_SOURCE" : "IMPORT_UNRESOLVED",
|
|
54
|
+
source: SOURCE,
|
|
55
|
+
message: messageFor(e, malformed),
|
|
56
|
+
data,
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { AnalysisRegistry } from "./analysis-registry.js";
|
|
2
2
|
export type { RefFieldInfo } from "./analysis-registry.js";
|
|
3
3
|
export { StaticAnalyzer } from "./analyzer.js";
|
|
4
|
+
export { importResolutionDiagnostics } from "./import-resolution-diagnostics.js";
|
|
4
5
|
export type { GraphLoadError, ImportEdge, LoadedFile, LoadedGraph, LoadedModule, ParseError, } from "./loaded-types.js";
|
|
5
6
|
export { flattenForAnalyzer, flattenLoadedModule, forwardReExportManifests, parseExportEntry, reExportSpecsFromExports, resolveExportedKinds, selectModuleManifestsForAnalysis, stampExportedKinds, stampReExportedKinds, type ParsedExportEntry, type ReExportSpec, } from "./flatten-for-analyzer.js";
|
|
6
7
|
export { buildEvalPaths, evalPathCovers } from "./eval-paths.js";
|
|
@@ -22,7 +23,7 @@ export type { SyntheticImport } from "./inline-imports.js";
|
|
|
22
23
|
export { reconcileModuleVersions } from "./reconcile-module-versions.js";
|
|
23
24
|
export type { VersionReconciliation } from "./reconcile-module-versions.js";
|
|
24
25
|
export { residualEntrySchema, residualEntrySchemaMap } from "./residual-schema.js";
|
|
25
|
-
export { buildDocumentPositions, buildLineOffsets, buildPositionIndex, documentLineOffsets, } from "./position-metadata.js";
|
|
26
|
+
export { buildDocumentPositions, buildLineOffsets, buildPositionIndex, documentLineOffsets, offsetToPosition, } from "./position-metadata.js";
|
|
26
27
|
export type { DocumentPosition } from "./position-metadata.js";
|
|
27
28
|
export { HttpSource } from "./sources/http-source.js";
|
|
28
29
|
export { RegistrySource } from "./sources/registry-source.js";
|
|
@@ -32,9 +33,14 @@ export { parseModuleRef, isRegistryRef } from "./sources/module-ref.js";
|
|
|
32
33
|
export type { ParsedModuleRef } from "./sources/module-ref.js";
|
|
33
34
|
export { OCI_SCHEME, isOciRef, parseOciRef } from "./sources/oci-ref.js";
|
|
34
35
|
export type { ParsedOciRef } from "./sources/oci-ref.js";
|
|
36
|
+
export { isLocalPathSource } from "./sources/local-path-ref.js";
|
|
35
37
|
export { MANIFEST_CACHE_BASE_URL, ManifestCacheSource, isHttpsModuleRef, manifestCacheKey, manifestCacheUrl, ociManifestCacheCoords, urlManifestCacheCoords, } from "./sources/manifest-cache.js";
|
|
36
38
|
export type { ManifestCacheCoords } from "./sources/manifest-cache.js";
|
|
37
39
|
export { withSyntheticPositions } from "./with-synthetic-positions.js";
|
|
40
|
+
export { documentToAst, parseToAst } from "./yaml-ast.js";
|
|
41
|
+
export type { AstDocument, AstMap, AstNode, AstPair, AstScalar, AstSeq } from "./yaml-ast.js";
|
|
42
|
+
export { buildCelSegments, wrapCelAst } from "./cel-ast.js";
|
|
43
|
+
export type { CelNode, CelSegment } from "./cel-ast.js";
|
|
38
44
|
export { DEFAULT_MANIFEST_FILENAME, DiagnosticSeverity } from "./types.js";
|
|
39
45
|
export type { AnalysisDiagnostic, AnalysisOptions, LoaderInitOptions, LoadOptions, ManifestSource, Position, PositionIndex, Range } from "./types.js";
|
|
40
46
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,YAAY,EACR,cAAc,EACd,UAAU,EACV,UAAU,EACV,WAAW,EACX,YAAY,EACZ,UAAU,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB,EACpB,gCAAgC,EAChC,kBAAkB,EAClB,oBAAoB,EACpB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,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACzE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC1D,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC5D,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC3E,YAAY,EACR,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,QAAQ,EACR,aAAa,EACb,KAAK,EACR,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { AnalysisRegistry } from "./analysis-registry.js";
|
|
2
2
|
export { StaticAnalyzer } from "./analyzer.js";
|
|
3
|
+
export { importResolutionDiagnostics } from "./import-resolution-diagnostics.js";
|
|
3
4
|
export { flattenForAnalyzer, flattenLoadedModule, forwardReExportManifests, parseExportEntry, reExportSpecsFromExports, resolveExportedKinds, selectModuleManifestsForAnalysis, stampExportedKinds, stampReExportedKinds, } from "./flatten-for-analyzer.js";
|
|
4
5
|
export { buildEvalPaths, evalPathCovers } from "./eval-paths.js";
|
|
5
6
|
export { ancestorChain, controllerBearingAncestor, effectiveAuthorSchema, hasOwnControllerOrTemplate, inheritedCapability, isInheritedDelegation, resolveParent, } from "./extends-resolution.js";
|
|
@@ -12,13 +13,16 @@ export { parseLoadedFile } from "./parse-loaded-file.js";
|
|
|
12
13
|
export { desugarLoadedFile, inlineImportManifests } from "./inline-imports.js";
|
|
13
14
|
export { reconcileModuleVersions } from "./reconcile-module-versions.js";
|
|
14
15
|
export { residualEntrySchema, residualEntrySchemaMap } from "./residual-schema.js";
|
|
15
|
-
export { buildDocumentPositions, buildLineOffsets, buildPositionIndex, documentLineOffsets, } from "./position-metadata.js";
|
|
16
|
+
export { buildDocumentPositions, buildLineOffsets, buildPositionIndex, documentLineOffsets, offsetToPosition, } from "./position-metadata.js";
|
|
16
17
|
export { HttpSource } from "./sources/http-source.js";
|
|
17
18
|
export { RegistrySource } from "./sources/registry-source.js";
|
|
18
19
|
export { defaultSources } from "./sources/default-sources.js";
|
|
19
20
|
export { splitIntegrity, foldIntegrity, verifyIntegrity, verifiedFetch, sha256Base64Url, IntegrityError, } from "./sources/integrity.js";
|
|
20
21
|
export { parseModuleRef, isRegistryRef } from "./sources/module-ref.js";
|
|
21
22
|
export { OCI_SCHEME, isOciRef, parseOciRef } from "./sources/oci-ref.js";
|
|
23
|
+
export { isLocalPathSource } from "./sources/local-path-ref.js";
|
|
22
24
|
export { MANIFEST_CACHE_BASE_URL, ManifestCacheSource, isHttpsModuleRef, manifestCacheKey, manifestCacheUrl, ociManifestCacheCoords, urlManifestCacheCoords, } from "./sources/manifest-cache.js";
|
|
23
25
|
export { withSyntheticPositions } from "./with-synthetic-positions.js";
|
|
26
|
+
export { documentToAst, parseToAst } from "./yaml-ast.js";
|
|
27
|
+
export { buildCelSegments, wrapCelAst } from "./cel-ast.js";
|
|
24
28
|
export { DEFAULT_MANIFEST_FILENAME, DiagnosticSeverity } from "./types.js";
|
package/dist/loaded-types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { ResourceManifest } from "@telorun/sdk";
|
|
|
2
2
|
import type { Document } from "yaml";
|
|
3
3
|
import type { DocumentPosition } from "./position-metadata.js";
|
|
4
4
|
import type { AnalysisDiagnostic, Range } from "./types.js";
|
|
5
|
+
import type { AstDocument } from "./yaml-ast.js";
|
|
5
6
|
/** One physical file's parsed result. Returned for the owner manifest, for
|
|
6
7
|
* each `include:` partial, and for each external import target.
|
|
7
8
|
*
|
|
@@ -16,8 +17,13 @@ export interface LoadedFile {
|
|
|
16
17
|
requestedUrl: string;
|
|
17
18
|
/** Raw text exactly as `read()` returned it. */
|
|
18
19
|
text: string;
|
|
19
|
-
/** Per-document parsed AST, in source order.
|
|
20
|
+
/** Per-document parsed `yaml` AST, in source order. The editor's mutable
|
|
21
|
+
* round-trip model reads this handle; structure-only consumers use the
|
|
22
|
+
* read-only `astDocuments` instead so `yaml` stays an internal detail. */
|
|
20
23
|
documents: Document[];
|
|
24
|
+
/** Per-document read-only `AstNode` view (`yaml`-free), aligned to
|
|
25
|
+
* `documents`. The shared structural source of truth for IDE features. */
|
|
26
|
+
astDocuments: AstDocument[];
|
|
21
27
|
/** Per-document JSON projection (`doc.toJSON()`). Aligned to `documents`. */
|
|
22
28
|
manifests: Array<ResourceManifest | null>;
|
|
23
29
|
/** Per-document `{sourceLine, positionIndex}`. Aligned to `documents`. */
|
|
@@ -90,10 +96,21 @@ export interface LoadedGraph {
|
|
|
90
96
|
errors: GraphLoadError[];
|
|
91
97
|
}
|
|
92
98
|
export interface GraphLoadError {
|
|
93
|
-
/** URL of the file that failed to load
|
|
99
|
+
/** URL of the file that failed to load (resolved — may be a `file://` URL for
|
|
100
|
+
* a relative import). */
|
|
94
101
|
url: string;
|
|
102
|
+
/** The import source string exactly as authored (`./lib`, `std/x@1.0.0`),
|
|
103
|
+
* before relative-path resolution. Preferred over `url` for classification
|
|
104
|
+
* and display, so a diagnostic quotes what the author wrote. */
|
|
105
|
+
source?: string;
|
|
95
106
|
/** Source of the import that triggered the load, or null for the entry. */
|
|
96
107
|
fromSource: string | null;
|
|
108
|
+
/** Import alias the failed source was bound to in `fromSource`'s `imports:`
|
|
109
|
+
* map, when the failure is a transitive import (absent for an entry-load
|
|
110
|
+
* failure). Lets a consumer anchor the diagnostic at `imports.<alias>`. */
|
|
111
|
+
alias?: string;
|
|
112
|
+
/** Line of the `Telo.Import` doc in `fromSource`, for position fallback. */
|
|
113
|
+
sourceLine?: number;
|
|
97
114
|
error: Error;
|
|
98
115
|
}
|
|
99
116
|
//# sourceMappingURL=loaded-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loaded-types.d.ts","sourceRoot":"","sources":["../src/loaded-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"loaded-types.d.ts","sourceRoot":"","sources":["../src/loaded-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAA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AAc,GAAG,IAAI;IAKtC,OAAO,CAAC,IAAI;IAMN,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAUrD;;;;2CAIuC;IACvC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAM7C;;;+BAG2B;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAyCvE;;;;gEAI4D;IAC5D,OAAO,CAAC,oBAAoB;IAa5B;gFAC4E;IAC5E,OAAO,CAAC,cAAc;IAQtB;;wEAEoE;IAC9D,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAsB3E;;;qCAGiC;IAC3B,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAgI9E;;;;;;;;sBAQkB;IAClB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM;IAOlE,OAAO,CAAC,6BAA6B;IAarC,OAAO,CAAC,mCAAmC;IAc3C,OAAO,CAAC,2BAA2B;YAkCrB,eAAe;IAmB7B;;;0CAGsC;IAChC,gBAAgB,CACpB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC;QAAE,KAAK,EAAE,WAAW,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CA0B5D"}
|
package/dist/manifest-loader.js
CHANGED
|
@@ -215,7 +215,10 @@ export class Loader {
|
|
|
215
215
|
catch (err) {
|
|
216
216
|
errors.push({
|
|
217
217
|
url: importSource,
|
|
218
|
+
source: importSource,
|
|
218
219
|
fromSource: file.source,
|
|
220
|
+
alias,
|
|
221
|
+
sourceLine,
|
|
219
222
|
error: err instanceof Error ? err : new Error(String(err)),
|
|
220
223
|
});
|
|
221
224
|
continue;
|
|
@@ -243,7 +246,14 @@ export class Loader {
|
|
|
243
246
|
catch (err) {
|
|
244
247
|
const e = err instanceof Error ? err : new Error(String(err));
|
|
245
248
|
e.sourceLine = sourceLine;
|
|
246
|
-
errors.push({
|
|
249
|
+
errors.push({
|
|
250
|
+
url: resolvedTarget,
|
|
251
|
+
source: importSource,
|
|
252
|
+
fromSource: file.source,
|
|
253
|
+
alias,
|
|
254
|
+
sourceLine,
|
|
255
|
+
error: e,
|
|
256
|
+
});
|
|
247
257
|
continue;
|
|
248
258
|
}
|
|
249
259
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-loaded-file.d.ts","sourceRoot":"","sources":["../src/parse-loaded-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAKxD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"parse-loaded-file.d.ts","sourceRoot":"","sources":["../src/parse-loaded-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAKxD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,mBAAmB,CAAC;AAKhE,MAAM,WAAW,YAAY;IAC3B;4EACwE;IACxE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AA4BD,oEAAoE;AACpE,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,YAAY,GACrB,UAAU,CAiDZ"}
|
|
@@ -3,6 +3,7 @@ import { parseAllDocuments } from "yaml";
|
|
|
3
3
|
import { buildCelEnvironment } from "./cel-environment.js";
|
|
4
4
|
import { buildDocumentPositions } from "./position-metadata.js";
|
|
5
5
|
import { precompileDoc } from "./precompile.js";
|
|
6
|
+
import { documentToAst } from "./yaml-ast.js";
|
|
6
7
|
/** Append an actionable hint to raw yaml-parser messages that are otherwise
|
|
7
8
|
* cryptic. The parser reports `BLOCK_AS_IMPLICIT_KEY` ("Nested mappings are
|
|
8
9
|
* not allowed in compact mappings") when a plain (unquoted) scalar contains
|
|
@@ -29,7 +30,8 @@ function rangeFromLinePos(linePos) {
|
|
|
29
30
|
/** Pure: text in, structured load result out. No I/O, no caches. */
|
|
30
31
|
export function parseLoadedFile(source, requestedUrl, text, options) {
|
|
31
32
|
const documents = parseAllDocuments(text, { customTags: defaultCustomTags() });
|
|
32
|
-
const
|
|
33
|
+
const astDocuments = documents.map((doc) => documentToAst(doc, text));
|
|
34
|
+
const positions = buildDocumentPositions(text, astDocuments);
|
|
33
35
|
const parseErrors = [];
|
|
34
36
|
documents.forEach((doc, documentIndex) => {
|
|
35
37
|
for (const err of doc.errors) {
|
|
@@ -67,6 +69,7 @@ export function parseLoadedFile(source, requestedUrl, text, options) {
|
|
|
67
69
|
requestedUrl,
|
|
68
70
|
text,
|
|
69
71
|
documents,
|
|
72
|
+
astDocuments,
|
|
70
73
|
manifests,
|
|
71
74
|
positions,
|
|
72
75
|
parseErrors,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Position, PositionIndex } from "./types.js";
|
|
2
|
+
import type { AstDocument } from "./yaml-ast.js";
|
|
3
3
|
/** Single source of truth for "given the source text of a multi-document YAML
|
|
4
4
|
* file, where does each document start, and what is the byte→(line,char)
|
|
5
5
|
* table for the file." Both the analyzer's `Loader` and editor frontends
|
|
6
|
-
* feed the same
|
|
6
|
+
* feed the same adapted `AstDocument[]` through this so diagnostics
|
|
7
7
|
* resolved against `positionIndex` / `sourceLine` line up identically
|
|
8
8
|
* across hosts. */
|
|
9
9
|
/** Per-document position metadata used by `normalizeDiagnostic`'s fallback chain. */
|
|
@@ -12,7 +12,7 @@ export interface DocumentPosition {
|
|
|
12
12
|
positionIndex: PositionIndex;
|
|
13
13
|
}
|
|
14
14
|
/** Builds DocumentPosition entries aligned to `parsedDocs[i]`. */
|
|
15
|
-
export declare function buildDocumentPositions(text: string, parsedDocs:
|
|
15
|
+
export declare function buildDocumentPositions(text: string, parsedDocs: AstDocument[]): DocumentPosition[];
|
|
16
16
|
/** Line numbers (0-indexed) where each YAML document in a multi-doc file
|
|
17
17
|
* starts. The first document is always at line 0; subsequent entries point
|
|
18
18
|
* to the line after each `---` separator.
|
|
@@ -26,11 +26,12 @@ export declare function documentLineOffsets(text: string): number[];
|
|
|
26
26
|
* the first character on line `i`. Used with `offsetToPosition` to turn a
|
|
27
27
|
* yaml-AST node range into Range coordinates. */
|
|
28
28
|
export declare function buildLineOffsets(text: string): number[];
|
|
29
|
-
|
|
29
|
+
export declare function offsetToPosition(offset: number, lineOffsets: number[]): Position;
|
|
30
|
+
/** Walks the AST and records source ranges for every field value, keyed
|
|
30
31
|
* by dotted path (e.g. "kind", "config.handler", "config.routes[0].path").
|
|
31
32
|
* Map keys are also recorded under the `@key:<path>` namespace so diagnostic
|
|
32
33
|
* resolvers can squiggle just the key identifier instead of the full value
|
|
33
34
|
* block — used when a diagnostic targets a missing child property and the
|
|
34
35
|
* resolver has to fall back to the parent. */
|
|
35
|
-
export declare function buildPositionIndex(doc:
|
|
36
|
+
export declare function buildPositionIndex(doc: AstDocument, lineOffsets: number[]): PositionIndex;
|
|
36
37
|
//# sourceMappingURL=position-metadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"position-metadata.d.ts","sourceRoot":"","sources":["../src/position-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"position-metadata.d.ts","sourceRoot":"","sources":["../src/position-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAW,MAAM,eAAe,CAAC;AAE1D;;;;;oBAKoB;AAEpB,qFAAqF;AACrF,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,kEAAkE;AAClE,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,WAAW,EAAE,GACxB,gBAAgB,EAAE,CAOpB;AAED;;;;;;;wCAOwC;AACxC,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAW1D;AAED;;kDAEkD;AAClD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAMvD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,QAAQ,CAShF;AAED;;;;;+CAK+C;AAC/C,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,aAAa,CAsCzF"}
|