@telorun/analyzer 0.8.0 → 0.9.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.
Files changed (38) hide show
  1. package/dist/analysis-registry.d.ts +1 -0
  2. package/dist/analysis-registry.d.ts.map +1 -1
  3. package/dist/analysis-registry.js +2 -1
  4. package/dist/analyzer.d.ts.map +1 -1
  5. package/dist/analyzer.js +23 -21
  6. package/dist/flatten-for-analyzer.d.ts +30 -0
  7. package/dist/flatten-for-analyzer.d.ts.map +1 -0
  8. package/dist/flatten-for-analyzer.js +119 -0
  9. package/dist/index.d.ts +6 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +3 -0
  12. package/dist/loaded-types.d.ts +81 -0
  13. package/dist/loaded-types.d.ts.map +1 -0
  14. package/dist/loaded-types.js +1 -0
  15. package/dist/manifest-loader.d.ts +30 -9
  16. package/dist/manifest-loader.d.ts.map +1 -1
  17. package/dist/manifest-loader.js +197 -417
  18. package/dist/parse-loaded-file.d.ts +12 -0
  19. package/dist/parse-loaded-file.d.ts.map +1 -0
  20. package/dist/parse-loaded-file.js +50 -0
  21. package/dist/position-metadata.d.ts +27 -0
  22. package/dist/position-metadata.d.ts.map +1 -0
  23. package/dist/position-metadata.js +88 -0
  24. package/dist/types.d.ts +6 -0
  25. package/dist/types.d.ts.map +1 -1
  26. package/dist/validate-references.d.ts.map +1 -1
  27. package/dist/validate-references.js +62 -0
  28. package/package.json +3 -3
  29. package/src/analysis-registry.ts +2 -1
  30. package/src/analyzer.ts +33 -29
  31. package/src/flatten-for-analyzer.ts +134 -0
  32. package/src/index.ts +18 -0
  33. package/src/loaded-types.ts +86 -0
  34. package/src/manifest-loader.ts +230 -459
  35. package/src/parse-loaded-file.ts +70 -0
  36. package/src/position-metadata.ts +106 -0
  37. package/src/types.ts +6 -0
  38. package/src/validate-references.ts +68 -0
@@ -0,0 +1,86 @@
1
+ import type { ResourceManifest } from "@telorun/sdk";
2
+ import type { Document } from "yaml";
3
+ import type { DocumentPosition } from "./position-metadata.js";
4
+ import type { Range } from "./types.js";
5
+
6
+ /** One physical file's parsed result. Returned for the owner manifest, for
7
+ * each `include:` partial, and for each external import target.
8
+ *
9
+ * Identity rule: every map key, every cross-reference, every editor-side
10
+ * cache uses `source` — the URL the source adapter's `read()` returned. */
11
+ export interface LoadedFile {
12
+ /** Canonical identity. The URL the source adapter's `read()` returned —
13
+ * HTTPS for http/registry, an absolute path for local. */
14
+ source: string;
15
+ /** The URL the caller supplied (e.g. registry ref `std/javascript@0.3.0`).
16
+ * Differs from `source` only for adapter-resolved URLs. */
17
+ requestedUrl: string;
18
+ /** Raw text exactly as `read()` returned it. */
19
+ text: string;
20
+ /** Per-document parsed AST, in source order. */
21
+ documents: Document[];
22
+ /** Per-document JSON projection (`doc.toJSON()`). Aligned to `documents`. */
23
+ manifests: Array<ResourceManifest | null>;
24
+ /** Per-document `{sourceLine, positionIndex}`. Aligned to `documents`. */
25
+ positions: DocumentPosition[];
26
+ /** Document-level parse errors aggregated from `yaml.Document.errors`. */
27
+ parseErrors: ParseError[];
28
+ }
29
+
30
+ export interface ParseError {
31
+ documentIndex: number;
32
+ message: string;
33
+ /** Line/character of the failure, when the yaml parser provided one. */
34
+ range?: Range;
35
+ }
36
+
37
+ /** An owner file plus the partial files it includes. The unit
38
+ * `Loader.loadModule` returns. */
39
+ export interface LoadedModule {
40
+ owner: LoadedFile;
41
+ /** Each `include:` target as its own LoadedFile. Empty when no `include:`.
42
+ * Order matches the `include:` list (after glob expansion). */
43
+ partials: LoadedFile[];
44
+ }
45
+
46
+ /** Resolved Telo.Import edge: where the import points and what library
47
+ * identity it resolves to. Carrying name/namespace on the edge means
48
+ * `flattenForAnalyzer` can stamp `metadata.resolvedModuleName` /
49
+ * `resolvedNamespace` from this single source rather than re-deriving
50
+ * the target from manifest metadata, which would silently miss whenever
51
+ * a future projection forgets to stamp `metadata.source` consistently. */
52
+ export interface ImportEdge {
53
+ /** Canonical resolved URL of the target — a key into `modules`. */
54
+ targetSource: string;
55
+ /** Target library's `metadata.name`, or `null` when the target had no
56
+ * Telo.Library doc (an error case captured in `LoadedGraph.errors`). */
57
+ targetModuleName: string | null;
58
+ /** Target library's `metadata.namespace` (or `null` when unset). */
59
+ targetNamespace: string | null;
60
+ }
61
+
62
+ /** An entry plus every transitively-imported library. Returned by
63
+ * `Loader.loadGraph`. */
64
+ export interface LoadedGraph {
65
+ /** Canonical entry source — equals `entry.owner.source`. */
66
+ rootSource: string;
67
+ entry: LoadedModule;
68
+ /** Map keyed by `LoadedFile.source` (canonical resolved URL). Includes
69
+ * entry, partials, and every transitively reachable Telo.Import target +
70
+ * its partials. */
71
+ modules: Map<string, LoadedModule>;
72
+ /** Per-Telo.Import resolution. Keyed by the resolved URL of the file the
73
+ * Telo.Import was declared in, then by the import's PascalCase alias. */
74
+ importEdges: Map<string, Map<string, ImportEdge>>;
75
+ /** Surface-level errors that did not abort the graph load (e.g. an import
76
+ * whose target failed to fetch). */
77
+ errors: GraphLoadError[];
78
+ }
79
+
80
+ export interface GraphLoadError {
81
+ /** URL of the file that failed to load. */
82
+ url: string;
83
+ /** Source of the import that triggered the load, or null for the entry. */
84
+ fromSource: string | null;
85
+ error: Error;
86
+ }