@telorun/analyzer 0.53.0 → 0.55.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/analysis-registry.d.ts +20 -0
- package/dist/analysis-registry.d.ts.map +1 -1
- package/dist/analysis-registry.js +36 -3
- package/dist/analyzer.d.ts +3 -2
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/analyzer.js +188 -26
- package/dist/builtins.d.ts.map +1 -1
- package/dist/builtins.js +32 -12
- package/dist/call-graph.d.ts +189 -0
- package/dist/call-graph.d.ts.map +1 -0
- package/dist/call-graph.js +617 -0
- package/dist/dependency-graph.d.ts +17 -7
- package/dist/dependency-graph.d.ts.map +1 -1
- package/dist/dependency-graph.js +36 -65
- package/dist/flatten-for-analyzer.d.ts +8 -0
- package/dist/flatten-for-analyzer.d.ts.map +1 -1
- package/dist/flatten-for-analyzer.js +32 -0
- package/dist/index.d.ts +14 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/manifest-navigation.d.ts +32 -0
- package/dist/manifest-navigation.d.ts.map +1 -0
- package/dist/manifest-navigation.js +91 -0
- package/dist/manifest-visitor.js +1 -1
- package/dist/ref-slot.d.ts +125 -0
- package/dist/ref-slot.d.ts.map +1 -0
- package/dist/ref-slot.js +226 -0
- package/dist/reference-field-map.d.ts +15 -1
- package/dist/reference-field-map.d.ts.map +1 -1
- package/dist/reference-field-map.js +29 -35
- package/dist/resolve-schema-ref-kinds.d.ts +4 -0
- package/dist/resolve-schema-ref-kinds.d.ts.map +1 -1
- package/dist/resolve-schema-ref-kinds.js +31 -8
- package/dist/resolve-zone-requirements.d.ts +110 -0
- package/dist/resolve-zone-requirements.d.ts.map +1 -0
- package/dist/resolve-zone-requirements.js +541 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/validate-observed-state.d.ts +14 -13
- package/dist/validate-observed-state.d.ts.map +1 -1
- package/dist/validate-observed-state.js +21 -88
- package/dist/validate-ref-slots.d.ts +48 -0
- package/dist/validate-ref-slots.d.ts.map +1 -0
- package/dist/validate-ref-slots.js +219 -0
- package/dist/validate-references.d.ts.map +1 -1
- package/dist/validate-references.js +8 -1
- package/dist/validate-zone-slots.d.ts +39 -0
- package/dist/validate-zone-slots.d.ts.map +1 -0
- package/dist/validate-zone-slots.js +114 -0
- package/dist/zone-module-documents.d.ts +27 -0
- package/dist/zone-module-documents.d.ts.map +1 -0
- package/dist/zone-module-documents.js +1 -0
- package/dist/zone-slot.d.ts +61 -0
- package/dist/zone-slot.d.ts.map +1 -0
- package/dist/zone-slot.js +91 -0
- package/package.json +3 -3
- package/src/analysis-registry.ts +36 -2
- package/src/analyzer.ts +206 -24
- package/src/builtins.ts +32 -12
- package/src/call-graph.ts +827 -0
- package/src/dependency-graph.ts +34 -68
- package/src/flatten-for-analyzer.ts +32 -0
- package/src/index.ts +47 -0
- package/src/manifest-navigation.ts +91 -0
- package/src/manifest-visitor.ts +1 -1
- package/src/ref-slot.ts +273 -0
- package/src/reference-field-map.ts +39 -36
- package/src/resolve-schema-ref-kinds.ts +34 -7
- package/src/resolve-zone-requirements.ts +781 -0
- package/src/types.ts +8 -0
- package/src/validate-observed-state.ts +26 -92
- package/src/validate-ref-slots.ts +293 -0
- package/src/validate-references.ts +8 -1
- package/src/validate-zone-slots.ts +175 -0
- package/src/zone-module-documents.ts +27 -0
- package/src/zone-slot.ts +116 -0
package/src/zone-slot.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single reader of the two execution-zone annotations —
|
|
3
|
+
* `x-telo-provides-zone` and `x-telo-requires-zone` (see
|
|
4
|
+
* `kernel/specs/execution-zones.md`). The analyzer's zone projection, the
|
|
5
|
+
* kernel's `withZone` / `requireZone`, and any editor surface all recognise a
|
|
6
|
+
* zone slot here and nowhere else, the same one-accessor rule `ref-slot.ts`
|
|
7
|
+
* established for `x-telo-ref`. Browser-safe: no Node built-ins.
|
|
8
|
+
*
|
|
9
|
+
* Accepted shapes:
|
|
10
|
+
*
|
|
11
|
+
* x-telo-provides-zone: true # uncorrelated — the zone is the kind
|
|
12
|
+
* x-telo-provides-zone: /connection # correlation-key pointer (own field)
|
|
13
|
+
*
|
|
14
|
+
* x-telo-requires-zone: Self.Transaction # uncorrelated string form
|
|
15
|
+
* x-telo-requires-zone: # object form
|
|
16
|
+
* zone: Self.Transaction
|
|
17
|
+
* key: [/connection, /transaction/connection] # ordered, first hit wins
|
|
18
|
+
* reason: the statement would execute outside any transaction
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const PROVIDES = "x-telo-provides-zone";
|
|
22
|
+
const REQUIRES = "x-telo-requires-zone";
|
|
23
|
+
|
|
24
|
+
/** A body slot that establishes the declaring kind's zone when dispatched
|
|
25
|
+
* through. The zone's identity is always the declaring kind — the annotation
|
|
26
|
+
* never names one, so provision-on-behalf-of is unrepresentable. */
|
|
27
|
+
export interface ProvidesZoneSlot {
|
|
28
|
+
/** Self-relative JSON pointer to the declaring kind's own field whose resolved
|
|
29
|
+
* reference the zone carries as its correlation payload. Absent =
|
|
30
|
+
* uncorrelated (`true`). */
|
|
31
|
+
key?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** A field declaring that its resource must be reached through a zone. */
|
|
35
|
+
export interface RequiresZoneSlot {
|
|
36
|
+
/** The providing kind, alias-qualified as authored (`Self.Transaction`,
|
|
37
|
+
* `<Alias>.<Kind>`) — canonical `<module>.<Kind>` once
|
|
38
|
+
* `resolveSchemaRefKinds` has rewritten it in the declaring scope. */
|
|
39
|
+
zone: string;
|
|
40
|
+
/** Ordered self-relative JSON pointers tried in order, first hit winning; a
|
|
41
|
+
* pointer may traverse a `!ref` into the referenced resource's own field.
|
|
42
|
+
* Empty = uncorrelated. */
|
|
43
|
+
key: string[];
|
|
44
|
+
/** The runtime consequence, quoted after the path in diagnostics. */
|
|
45
|
+
reason?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A self-relative JSON Pointer — the only correlation-key spelling the
|
|
49
|
+
* analyzer and the kernel read identically. Applied to BOTH the scalar and the
|
|
50
|
+
* list form: the kernel's walk splits on `/` and drops empty segments, so a
|
|
51
|
+
* bare `connection` would resolve there while the checker skipped it, and the
|
|
52
|
+
* two halves would disagree about what the manifest means. `validate-zone-slots`
|
|
53
|
+
* reports what this rejects. */
|
|
54
|
+
function isPointer(value: unknown): value is string {
|
|
55
|
+
return typeof value === "string" && value.startsWith("/") && value.length > 1;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Reads a schema node's provides-zone declaration, or undefined when it has
|
|
59
|
+
* none or the value is malformed (`validate-zone-slots` reports those). */
|
|
60
|
+
export function readProvidesZone(node: Record<string, any> | undefined): ProvidesZoneSlot | undefined {
|
|
61
|
+
const raw = node?.[PROVIDES];
|
|
62
|
+
if (raw === true) return {};
|
|
63
|
+
if (isPointer(raw)) return { key: raw };
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** True when the node carries `x-telo-provides-zone` in any shape, valid or not
|
|
68
|
+
* — the recognition test validation needs before it judges the value. */
|
|
69
|
+
export function hasProvidesZone(node: Record<string, any> | undefined): boolean {
|
|
70
|
+
return node?.[PROVIDES] !== undefined;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Reads a schema node's requires-zone declaration, or undefined when it has
|
|
74
|
+
* none or the value is malformed (`validate-zone-slots` reports those). */
|
|
75
|
+
export function readRequiresZone(node: Record<string, any> | undefined): RequiresZoneSlot | undefined {
|
|
76
|
+
const raw = node?.[REQUIRES];
|
|
77
|
+
if (typeof raw === "string" && raw) return { zone: raw, key: [] };
|
|
78
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return undefined;
|
|
79
|
+
const obj = raw as Record<string, unknown>;
|
|
80
|
+
if (typeof obj.zone !== "string" || !obj.zone) return undefined;
|
|
81
|
+
// One filter for both spellings — see `isPointer`.
|
|
82
|
+
const key = (Array.isArray(obj.key) ? obj.key : [obj.key]).filter(isPointer);
|
|
83
|
+
const slot: RequiresZoneSlot = { zone: obj.zone, key };
|
|
84
|
+
if (typeof obj.reason === "string") slot.reason = obj.reason;
|
|
85
|
+
return slot;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** True when the node carries `x-telo-requires-zone` in any shape. */
|
|
89
|
+
export function hasRequiresZone(node: Record<string, any> | undefined): boolean {
|
|
90
|
+
return node?.[REQUIRES] !== undefined;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Rewrites the requires-zone kind name in place, in whichever shape it is
|
|
95
|
+
* written — the write-side twin of {@link readRequiresZone}, mirroring
|
|
96
|
+
* `rewriteRefSlotKinds` so `resolveSchemaRefKinds` canonicalizes both
|
|
97
|
+
* annotations in one walk. `map` returns the replacement or `undefined` to
|
|
98
|
+
* leave the authored name untouched (idempotence + quotable diagnostics).
|
|
99
|
+
*/
|
|
100
|
+
export function rewriteRequiresZoneKind(
|
|
101
|
+
annotationHolder: Record<string, any>,
|
|
102
|
+
map: (kind: string) => string | undefined,
|
|
103
|
+
): void {
|
|
104
|
+
const raw = annotationHolder[REQUIRES];
|
|
105
|
+
if (typeof raw === "string") {
|
|
106
|
+
const next = map(raw);
|
|
107
|
+
if (next !== undefined) annotationHolder[REQUIRES] = next;
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return;
|
|
111
|
+
const obj = raw as Record<string, unknown>;
|
|
112
|
+
if (typeof obj.zone === "string") {
|
|
113
|
+
const next = map(obj.zone);
|
|
114
|
+
if (next !== undefined) obj.zone = next;
|
|
115
|
+
}
|
|
116
|
+
}
|