@telorun/analyzer 0.72.0 → 0.74.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/analyzer.d.ts.map +1 -1
- package/dist/analyzer.js +76 -20
- package/dist/artifact-axes.d.ts +14 -0
- package/dist/artifact-axes.d.ts.map +1 -0
- package/dist/artifact-axes.js +12 -0
- package/dist/artifact-layer-index.d.ts +2 -2
- package/dist/artifact-layer-index.d.ts.map +1 -1
- package/dist/artifact-layer-index.js +9 -4
- package/dist/artifact-selector.d.ts +47 -21
- package/dist/artifact-selector.d.ts.map +1 -1
- package/dist/artifact-selector.js +85 -16
- package/dist/builtins.d.ts.map +1 -1
- package/dist/builtins.js +144 -113
- package/dist/call-graph.d.ts +12 -1
- package/dist/call-graph.d.ts.map +1 -1
- package/dist/call-graph.js +22 -0
- package/dist/catch-scope.js +1 -1
- package/dist/cel-scope-query.d.ts.map +1 -1
- package/dist/cel-scope-query.js +32 -11
- package/dist/cel-scope.d.ts.map +1 -1
- package/dist/cel-scope.js +1 -0
- package/dist/eval-paths.d.ts +36 -5
- package/dist/eval-paths.d.ts.map +1 -1
- package/dist/eval-paths.js +47 -6
- package/dist/extends-resolution.d.ts +12 -0
- package/dist/extends-resolution.d.ts.map +1 -1
- package/dist/extends-resolution.js +23 -0
- package/dist/forwarded-declaration.d.ts +26 -0
- package/dist/forwarded-declaration.d.ts.map +1 -0
- package/dist/forwarded-declaration.js +31 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/kernel-globals.d.ts.map +1 -1
- package/dist/kernel-globals.js +21 -5
- package/dist/module-alias-scope.d.ts +11 -0
- package/dist/module-alias-scope.d.ts.map +1 -1
- package/dist/module-alias-scope.js +10 -0
- package/dist/module-file-claims.d.ts +17 -1
- package/dist/module-file-claims.d.ts.map +1 -1
- package/dist/module-file-claims.js +38 -3
- package/dist/module-named-files.d.ts +72 -0
- package/dist/module-named-files.d.ts.map +1 -0
- package/dist/module-named-files.js +115 -0
- package/dist/native-entries.d.ts +83 -0
- package/dist/native-entries.d.ts.map +1 -0
- package/dist/native-entries.js +169 -0
- package/dist/nearest-name.d.ts +22 -0
- package/dist/nearest-name.d.ts.map +1 -0
- package/dist/nearest-name.js +43 -0
- package/dist/normalize-inline-resources.d.ts +41 -13
- package/dist/normalize-inline-resources.d.ts.map +1 -1
- package/dist/normalize-inline-resources.js +236 -54
- package/dist/reference-field-map.d.ts +59 -1
- package/dist/reference-field-map.d.ts.map +1 -1
- package/dist/reference-field-map.js +200 -34
- package/dist/release/destinations.d.ts +59 -0
- package/dist/release/destinations.d.ts.map +1 -0
- package/dist/release/destinations.js +75 -0
- package/dist/release/index.d.ts +6 -2
- package/dist/release/index.d.ts.map +1 -1
- package/dist/release/index.js +3 -1
- package/dist/release/ledger.d.ts +20 -11
- package/dist/release/ledger.d.ts.map +1 -1
- package/dist/release/ledger.js +43 -14
- package/dist/release/payload-digest.d.ts +2 -1
- package/dist/release/payload-digest.d.ts.map +1 -1
- package/dist/release/payload-digest.js +2 -1
- package/dist/release/release-plan.d.ts +3 -2
- package/dist/release/release-plan.d.ts.map +1 -1
- package/dist/release/release-plan.js +12 -19
- package/dist/release/workspace-config.d.ts +114 -34
- package/dist/release/workspace-config.d.ts.map +1 -1
- package/dist/release/workspace-config.js +322 -38
- package/dist/release/workspace-schema.d.ts +41 -0
- package/dist/release/workspace-schema.d.ts.map +1 -0
- package/dist/release/workspace-schema.js +77 -0
- package/dist/resolve-ref-sentinels.d.ts.map +1 -1
- package/dist/resolve-ref-sentinels.js +8 -5
- package/dist/resolve-throws-union.d.ts +25 -4
- package/dist/resolve-throws-union.d.ts.map +1 -1
- package/dist/resolve-throws-union.js +62 -32
- package/dist/resolve-zone-requirements.d.ts.map +1 -1
- package/dist/resolve-zone-requirements.js +2 -1
- package/dist/rewrite-synthetic-origins.d.ts +6 -1
- package/dist/rewrite-synthetic-origins.d.ts.map +1 -1
- package/dist/rewrite-synthetic-origins.js +107 -13
- package/dist/schema-compat.d.ts.map +1 -1
- package/dist/schema-compat.js +18 -5
- package/dist/schema-error-report.d.ts +7 -0
- package/dist/schema-error-report.d.ts.map +1 -1
- package/dist/schema-error-report.js +9 -4
- package/dist/schema-walk.d.ts +47 -13
- package/dist/schema-walk.d.ts.map +1 -1
- package/dist/schema-walk.js +150 -30
- package/dist/scope-declarations.d.ts +59 -0
- package/dist/scope-declarations.d.ts.map +1 -0
- package/dist/scope-declarations.js +45 -0
- package/dist/source-entries.d.ts +119 -0
- package/dist/source-entries.d.ts.map +1 -0
- package/dist/source-entries.js +349 -0
- package/dist/step-bodies.d.ts +24 -0
- package/dist/step-bodies.d.ts.map +1 -0
- package/dist/step-bodies.js +28 -0
- package/dist/telo-version.d.ts +1 -1
- package/dist/telo-version.js +1 -1
- package/dist/template-body.d.ts +10 -0
- package/dist/template-body.d.ts.map +1 -1
- package/dist/template-body.js +25 -0
- package/dist/validate-cel-context.d.ts +23 -8
- package/dist/validate-cel-context.d.ts.map +1 -1
- package/dist/validate-cel-context.js +51 -18
- package/dist/validate-exports.d.ts +28 -0
- package/dist/validate-exports.d.ts.map +1 -0
- package/dist/validate-exports.js +146 -0
- package/dist/validate-extends.d.ts.map +1 -1
- package/dist/validate-extends.js +37 -1
- package/dist/validate-module-artifact.d.ts +4 -2
- package/dist/validate-module-artifact.d.ts.map +1 -1
- package/dist/validate-module-artifact.js +43 -4
- package/dist/validate-native-entries.d.ts +15 -0
- package/dist/validate-native-entries.d.ts.map +1 -0
- package/dist/validate-native-entries.js +103 -0
- package/dist/validate-observed-state.d.ts +7 -1
- package/dist/validate-observed-state.d.ts.map +1 -1
- package/dist/validate-observed-state.js +24 -6
- package/dist/validate-provider-coherence.d.ts +4 -8
- package/dist/validate-provider-coherence.d.ts.map +1 -1
- package/dist/validate-provider-coherence.js +12 -123
- package/dist/validate-reference-forms.d.ts.map +1 -1
- package/dist/validate-reference-forms.js +2 -2
- package/dist/validate-references.d.ts.map +1 -1
- package/dist/validate-references.js +152 -65
- package/dist/validate-scope-reach.d.ts +31 -0
- package/dist/validate-scope-reach.d.ts.map +1 -0
- package/dist/validate-scope-reach.js +180 -0
- package/dist/validate-source-entries.d.ts +16 -0
- package/dist/validate-source-entries.d.ts.map +1 -0
- package/dist/validate-source-entries.js +90 -0
- package/dist/validate-template-body.d.ts +36 -0
- package/dist/validate-template-body.d.ts.map +1 -0
- package/dist/validate-template-body.js +246 -0
- package/dist/validate-throws-coverage.d.ts.map +1 -1
- package/dist/validate-throws-coverage.js +21 -39
- package/dist/value-type-keyword.d.ts +22 -5
- package/dist/value-type-keyword.d.ts.map +1 -1
- package/dist/value-type-keyword.js +16 -7
- package/package.json +4 -3
- package/src/analyzer.ts +97 -20
- package/src/artifact-axes.ts +24 -0
- package/src/artifact-layer-index.ts +9 -6
- package/src/artifact-selector.ts +110 -35
- package/src/builtins.ts +160 -113
- package/src/call-graph.ts +30 -0
- package/src/catch-scope.ts +1 -1
- package/src/cel-scope-query.ts +28 -9
- package/src/cel-scope.ts +1 -0
- package/src/eval-paths.ts +53 -6
- package/src/extends-resolution.ts +24 -0
- package/src/forwarded-declaration.ts +32 -0
- package/src/index.ts +37 -1
- package/src/kernel-globals.ts +28 -5
- package/src/migrations/CLAUDE.md +35 -0
- package/src/module-alias-scope.ts +17 -0
- package/src/module-file-claims.ts +63 -4
- package/src/module-named-files.ts +162 -0
- package/src/native-entries.ts +227 -0
- package/src/nearest-name.ts +47 -0
- package/src/normalize-inline-resources.ts +326 -70
- package/src/reference-field-map.ts +257 -52
- package/src/release/CLAUDE.md +32 -0
- package/src/release/destinations.ts +105 -0
- package/src/release/index.ts +33 -2
- package/src/release/ledger.ts +51 -21
- package/src/release/payload-digest.ts +2 -1
- package/src/release/release-plan.ts +16 -26
- package/src/release/workspace-config.ts +483 -47
- package/src/release/workspace-schema.ts +99 -0
- package/src/resolve-ref-sentinels.ts +7 -6
- package/src/resolve-throws-union.ts +87 -32
- package/src/resolve-zone-requirements.ts +2 -1
- package/src/rewrite-synthetic-origins.ts +107 -16
- package/src/schema-compat.ts +18 -4
- package/src/schema-error-report.ts +16 -4
- package/src/schema-walk.ts +162 -34
- package/src/scope-declarations.ts +98 -0
- package/src/source-entries.ts +502 -0
- package/src/step-bodies.ts +55 -0
- package/src/telo-version.ts +1 -1
- package/src/template-body.ts +25 -0
- package/src/validate-cel-context.ts +60 -18
- package/src/validate-exports.ts +185 -0
- package/src/validate-extends.ts +43 -0
- package/src/validate-module-artifact.ts +46 -3
- package/src/validate-native-entries.ts +147 -0
- package/src/validate-observed-state.ts +36 -7
- package/src/validate-provider-coherence.ts +17 -127
- package/src/validate-reference-forms.ts +2 -3
- package/src/validate-references.ts +151 -66
- package/src/validate-scope-reach.ts +213 -0
- package/src/validate-source-entries.ts +120 -0
- package/src/validate-template-body.ts +274 -0
- package/src/validate-throws-coverage.ts +24 -31
- package/src/value-type-keyword.ts +35 -9
- package/dist/validate-template-dispatch.d.ts +0 -27
- package/dist/validate-template-dispatch.d.ts.map +0 -1
- package/dist/validate-template-dispatch.js +0 -95
- package/src/validate-template-dispatch.ts +0 -99
package/dist/schema-walk.js
CHANGED
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
* scope rule is consumed by the IDE, which must not pull the pass in behind it.
|
|
10
10
|
*/
|
|
11
11
|
import { MANIFEST_SCHEMA_URI, ManifestRootSchema } from "./manifest-schemas.js";
|
|
12
|
-
import {
|
|
13
|
-
import { readStepSlot } from "./step-slot.js";
|
|
12
|
+
import { buildDrivenSlotMap, refSlotOfEntry } from "./reference-field-map.js";
|
|
14
13
|
/** Resolve a local `$ref` (only `#/$defs/<name>` form) against the root schema.
|
|
15
14
|
* Non-refs and unresolved refs pass through unchanged. */
|
|
16
15
|
export function resolveLocalRef(schema, root) {
|
|
@@ -126,45 +125,166 @@ export function walkStepArray(steps, stepItemSchema, rootSchema, basePath, visit
|
|
|
126
125
|
}
|
|
127
126
|
});
|
|
128
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Every slot a kind's schema declares through which its resources drive
|
|
130
|
+
* another — the schema-only mode of {@link forEachDrivenSlot}, read off the
|
|
131
|
+
* same {@link buildDrivenSlotMap}.
|
|
132
|
+
*/
|
|
133
|
+
export function forEachDeclaredSlot(schema, visit) {
|
|
134
|
+
if (!schema || typeof schema !== "object")
|
|
135
|
+
return;
|
|
136
|
+
for (const [path, at] of buildDrivenSlotMap(schema).paths) {
|
|
137
|
+
if (at.steps.length > 0)
|
|
138
|
+
visit({ kind: "step", slots: at.steps, path });
|
|
139
|
+
if (at.refs.length > 0)
|
|
140
|
+
visit({ kind: "ref", slots: at.refs.map(refSlotOfEntry), path });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
129
143
|
/**
|
|
130
144
|
* Every slot of one resource through which it drives another, schema and data in
|
|
131
145
|
* tandem.
|
|
132
146
|
*
|
|
133
|
-
* One traversal
|
|
134
|
-
* scope enclosure
|
|
135
|
-
* structural question and two copies would eventually
|
|
136
|
-
* walk stops.
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
147
|
+
* One traversal for every throws question — a kind's `inherit` union, a scope
|
|
148
|
+
* list's denominator, catch-scope enclosure, and whether `inherit` is legal —
|
|
149
|
+
* because they ask the same structural question and two copies would eventually
|
|
150
|
+
* disagree about where the walk stops. The slots are the driven-slot map's, so
|
|
151
|
+
* the reach is the reference field map's plus local `$ref`; a step slot is a
|
|
152
|
+
* stop (that traversal owns everything below it, `try`/`catch` subtraction
|
|
153
|
+
* included) and so is a reference slot (a resolved ref is a leaf).
|
|
154
|
+
*
|
|
155
|
+
* Each concrete site is visited once, with every slot that reaches it. A
|
|
156
|
+
* map-value (`additionalProperties`) slot applies only to keys its schema does
|
|
157
|
+
* not declare, and never to the resource envelope at the root, as JSON Schema
|
|
158
|
+
* applies it. A recursive schema's back-edge is followed as deep as the data
|
|
159
|
+
* goes, guarded against data that aliases one of its own ancestors. A schema
|
|
160
|
+
* whose map holds no step or reference slot is not walked at all.
|
|
140
161
|
*/
|
|
141
|
-
export function forEachDrivenSlot(schema, data, visit
|
|
162
|
+
export function forEachDrivenSlot(schema, data, visit) {
|
|
142
163
|
if (!schema || typeof schema !== "object" || data === undefined || data === null)
|
|
143
164
|
return;
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
if (stepSlot) {
|
|
147
|
-
if (Array.isArray(data))
|
|
148
|
-
visit({ kind: "step", slot: stepSlot, data, path });
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
const refSlot = readRefSlot(node);
|
|
152
|
-
if (refSlot) {
|
|
153
|
-
visit({ kind: "ref", slot: refSlot, data, path });
|
|
165
|
+
const driven = buildDrivenSlotMap(schema);
|
|
166
|
+
if (!driven.drives)
|
|
154
167
|
return;
|
|
155
|
-
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
if (
|
|
168
|
+
const sites = new Map();
|
|
169
|
+
const onData = new Set([data]);
|
|
170
|
+
const walk = (prefix, value, base) => {
|
|
171
|
+
for (const [fieldPath, at] of driven.paths) {
|
|
172
|
+
const rel = relativeFieldPath(fieldPath, prefix);
|
|
173
|
+
if (rel === undefined)
|
|
161
174
|
continue;
|
|
162
|
-
|
|
175
|
+
for (const found of resolveSites(value, rel, prefix, driven)) {
|
|
176
|
+
const path = joinConcrete(base, found.path);
|
|
177
|
+
if (at.steps.length > 0 || at.refs.length > 0) {
|
|
178
|
+
let site = sites.get(path);
|
|
179
|
+
if (!site) {
|
|
180
|
+
site = { data: found.value, steps: [], refs: [], from: new Set() };
|
|
181
|
+
sites.set(path, site);
|
|
182
|
+
}
|
|
183
|
+
for (const step of at.steps) {
|
|
184
|
+
if (site.from.has(step))
|
|
185
|
+
continue;
|
|
186
|
+
site.from.add(step);
|
|
187
|
+
site.steps.push(step);
|
|
188
|
+
}
|
|
189
|
+
for (const entry of at.refs) {
|
|
190
|
+
if (site.from.has(entry))
|
|
191
|
+
continue;
|
|
192
|
+
site.from.add(entry);
|
|
193
|
+
site.refs.push({ slot: refSlotOfEntry(entry), fieldPath });
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (at.recurse.length === 0)
|
|
197
|
+
continue;
|
|
198
|
+
if (!found.value || typeof found.value !== "object" || onData.has(found.value))
|
|
199
|
+
continue;
|
|
200
|
+
onData.add(found.value);
|
|
201
|
+
for (const to of at.recurse)
|
|
202
|
+
walk(to, found.value, path);
|
|
203
|
+
onData.delete(found.value);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
walk("", data, "");
|
|
208
|
+
for (const [path, site] of sites) {
|
|
209
|
+
if (site.steps.length > 0 && Array.isArray(site.data)) {
|
|
210
|
+
visit({ kind: "step", slots: site.steps, data: site.data, path });
|
|
211
|
+
}
|
|
212
|
+
else if (site.refs.length > 0) {
|
|
213
|
+
visit({ kind: "ref", slots: site.refs, data: site.data, path });
|
|
163
214
|
}
|
|
164
215
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
216
|
+
}
|
|
217
|
+
/** The values at `rel` below `value`, where `rel` is relative to the field path
|
|
218
|
+
* `prefix`. A `{}` segment skips the keys the driven map records as declared
|
|
219
|
+
* for that map path; each `[]` iterates one array level. */
|
|
220
|
+
function resolveSites(value, rel, prefix, driven) {
|
|
221
|
+
let sites = [{ value, path: "" }];
|
|
222
|
+
let field = prefix;
|
|
223
|
+
for (const part of rel.split(".")) {
|
|
224
|
+
const next = [];
|
|
225
|
+
if (part === "{}") {
|
|
226
|
+
field = joinKey(field, "{}");
|
|
227
|
+
const declared = driven.declaredKeys.get(field);
|
|
228
|
+
for (const site of sites) {
|
|
229
|
+
if (!site.value || typeof site.value !== "object" || Array.isArray(site.value))
|
|
230
|
+
continue;
|
|
231
|
+
for (const [key, entry] of Object.entries(site.value)) {
|
|
232
|
+
if (entry == null || declared?.has(key))
|
|
233
|
+
continue;
|
|
234
|
+
next.push({ value: entry, path: joinKey(site.path, key) });
|
|
235
|
+
}
|
|
236
|
+
}
|
|
168
237
|
}
|
|
238
|
+
else {
|
|
239
|
+
const key = part.replace(/(\[\])+$/, "");
|
|
240
|
+
const depth = (part.length - key.length) / 2;
|
|
241
|
+
field = key ? joinKey(field, part) : `${field}${part}`;
|
|
242
|
+
for (const site of sites) {
|
|
243
|
+
let level;
|
|
244
|
+
if (key) {
|
|
245
|
+
if (!site.value || typeof site.value !== "object")
|
|
246
|
+
continue;
|
|
247
|
+
const entry = site.value[key];
|
|
248
|
+
if (entry == null)
|
|
249
|
+
continue;
|
|
250
|
+
level = [{ value: entry, path: joinKey(site.path, key) }];
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
level = [site];
|
|
254
|
+
}
|
|
255
|
+
for (let d = 0; d < depth; d++) {
|
|
256
|
+
const items = [];
|
|
257
|
+
for (const holder of level) {
|
|
258
|
+
if (!Array.isArray(holder.value))
|
|
259
|
+
continue;
|
|
260
|
+
holder.value.forEach((item, i) => {
|
|
261
|
+
if (item != null)
|
|
262
|
+
items.push({ value: item, path: `${holder.path}[${i}]` });
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
level = items;
|
|
266
|
+
}
|
|
267
|
+
next.push(...level);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
sites = next;
|
|
169
271
|
}
|
|
272
|
+
return sites;
|
|
273
|
+
}
|
|
274
|
+
const joinKey = (path, key) => (path ? `${path}.${key}` : key);
|
|
275
|
+
/** `fieldPath` relative to `prefix`, or undefined when it is not strictly
|
|
276
|
+
* below it. A result starting `[]` iterates the value at `prefix` itself. */
|
|
277
|
+
function relativeFieldPath(fieldPath, prefix) {
|
|
278
|
+
if (prefix === "")
|
|
279
|
+
return fieldPath;
|
|
280
|
+
if (fieldPath.startsWith(`${prefix}.`))
|
|
281
|
+
return fieldPath.slice(prefix.length + 1);
|
|
282
|
+
if (fieldPath.startsWith(`${prefix}[]`))
|
|
283
|
+
return fieldPath.slice(prefix.length);
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
286
|
+
function joinConcrete(base, rel) {
|
|
287
|
+
if (!base)
|
|
288
|
+
return rel;
|
|
289
|
+
return rel.startsWith("[") ? `${base}${rel}` : `${base}.${rel}`;
|
|
170
290
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ResourceManifest } from "@telorun/sdk";
|
|
2
|
+
import { type ReferenceFieldMap } from "./reference-field-map.js";
|
|
3
|
+
/**
|
|
4
|
+
* The execution scopes ONE resource declares — the `x-telo-scope` arrays it
|
|
5
|
+
* holds — read off its kind's field map, which is the analyzer's single
|
|
6
|
+
* definition of "scope" (the same one `resolve-ref-sentinels` and
|
|
7
|
+
* `manifest-visitor` read). Inferring a scope from shape instead would give one
|
|
8
|
+
* to any kind that happens to carry an array of named declarations.
|
|
9
|
+
*
|
|
10
|
+
* Browser-safe.
|
|
11
|
+
*/
|
|
12
|
+
/** One declared scope: the array a scope run creates, and where its names resolve. */
|
|
13
|
+
export interface DeclaredScope {
|
|
14
|
+
/** Concrete path of the scope slot on its resource (`with`). */
|
|
15
|
+
path: string;
|
|
16
|
+
/** The declaration array itself — what a scope run registers and tears down. */
|
|
17
|
+
declarations: unknown[];
|
|
18
|
+
/** Dot-form prefixes of every region its names resolve in (`steps`, `targets`). */
|
|
19
|
+
regions: string[];
|
|
20
|
+
}
|
|
21
|
+
export type ScopeMember = ResourceManifest & {
|
|
22
|
+
metadata: {
|
|
23
|
+
name: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
/** Every scope `resource` declares, in field-map order. A scope slot left unset
|
|
27
|
+
* declares nothing: no scope run happens, so nothing is created in one. */
|
|
28
|
+
export declare function declaredScopes(resource: Record<string, unknown>, fieldMap: ReferenceFieldMap | undefined): DeclaredScope[];
|
|
29
|
+
/** True when `path` — a field-map path (`steps[].invoke`) or a concrete one
|
|
30
|
+
* (`steps[0].invoke`) — lies inside one of the scope's regions. */
|
|
31
|
+
export declare function scopeEncloses(scope: DeclaredScope, path: string): boolean;
|
|
32
|
+
/** A scope's inline resource declarations. A `!ref` entry is a category error
|
|
33
|
+
* (`SCOPE_ENTRY_NOT_INLINE`), not a member. */
|
|
34
|
+
export declare function scopeMembers(scope: DeclaredScope): ScopeMember[];
|
|
35
|
+
/** True when a scope array entry is an inline resource declaration. */
|
|
36
|
+
export declare function isScopeMember(value: unknown): value is ScopeMember;
|
|
37
|
+
/**
|
|
38
|
+
* A scope an extracted declaration was WRITTEN inside and is NOT created in.
|
|
39
|
+
*
|
|
40
|
+
* An inline declaration is created in the set its owner is declared in, never in
|
|
41
|
+
* a scope its owner declares — moving it there would make every step target of a
|
|
42
|
+
* sequence with a `with:` block a scoped resource, which is a change of durable
|
|
43
|
+
* identity. So a declaration written in `steps:` next to a `with:` block is
|
|
44
|
+
* lexically inside that scope and lives outside it, and the names the scope
|
|
45
|
+
* declares are out of its reach. Recorded at extraction, where both facts are in
|
|
46
|
+
* hand, as `metadata.xTeloOrigin.outsideScopes`.
|
|
47
|
+
*/
|
|
48
|
+
export interface OutsideScope {
|
|
49
|
+
/** The resource declaring the scope, as its manifest spells it. */
|
|
50
|
+
ownerKind: string;
|
|
51
|
+
ownerName: string;
|
|
52
|
+
/** The scope slot (`with`). */
|
|
53
|
+
field: string;
|
|
54
|
+
/** Every name the scope declares. */
|
|
55
|
+
names: string[];
|
|
56
|
+
}
|
|
57
|
+
/** The scopes recorded as out of reach for an extracted declaration. */
|
|
58
|
+
export declare function outsideScopesOf(manifest: unknown): OutsideScope[];
|
|
59
|
+
//# sourceMappingURL=scope-declarations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-declarations.d.ts","sourceRoot":"","sources":["../src/scope-declarations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAqC,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAErG;;;;;;;;GAQG;AAEH,sFAAsF;AACtF,MAAM,WAAW,aAAa;IAC5B,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,gFAAgF;IAChF,YAAY,EAAE,OAAO,EAAE,CAAC;IACxB,mFAAmF;IACnF,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG;IAAE,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAE5E;4EAC4E;AAC5E,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,QAAQ,EAAE,iBAAiB,GAAG,SAAS,GACtC,aAAa,EAAE,CAYjB;AAED;oEACoE;AACpE,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAIzE;AAED;gDACgD;AAChD,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,WAAW,EAAE,CAEhE;AAED,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAOlE;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,YAAY;IAC3B,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,wEAAwE;AACxE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,YAAY,EAAE,CAMjE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { isRefSentinel } from "@telorun/templating";
|
|
2
|
+
import { isScopeEntry, resolveFieldEntries } from "./reference-field-map.js";
|
|
3
|
+
/** Every scope `resource` declares, in field-map order. A scope slot left unset
|
|
4
|
+
* declares nothing: no scope run happens, so nothing is created in one. */
|
|
5
|
+
export function declaredScopes(resource, fieldMap) {
|
|
6
|
+
if (!fieldMap)
|
|
7
|
+
return [];
|
|
8
|
+
const out = [];
|
|
9
|
+
for (const [fieldPath, entry] of fieldMap) {
|
|
10
|
+
if (!isScopeEntry(entry))
|
|
11
|
+
continue;
|
|
12
|
+
const pointers = Array.isArray(entry.scope) ? entry.scope : [entry.scope];
|
|
13
|
+
const regions = pointers.map((p) => p.replace(/^\//, "").replace(/\//g, "."));
|
|
14
|
+
for (const { value, path } of resolveFieldEntries(resource, fieldPath)) {
|
|
15
|
+
if (Array.isArray(value))
|
|
16
|
+
out.push({ path, declarations: value, regions });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
21
|
+
/** True when `path` — a field-map path (`steps[].invoke`) or a concrete one
|
|
22
|
+
* (`steps[0].invoke`) — lies inside one of the scope's regions. */
|
|
23
|
+
export function scopeEncloses(scope, path) {
|
|
24
|
+
return scope.regions.some((region) => path === region || path.startsWith(`${region}.`) || path.startsWith(`${region}[`));
|
|
25
|
+
}
|
|
26
|
+
/** A scope's inline resource declarations. A `!ref` entry is a category error
|
|
27
|
+
* (`SCOPE_ENTRY_NOT_INLINE`), not a member. */
|
|
28
|
+
export function scopeMembers(scope) {
|
|
29
|
+
return scope.declarations.filter(isScopeMember);
|
|
30
|
+
}
|
|
31
|
+
/** True when a scope array entry is an inline resource declaration. */
|
|
32
|
+
export function isScopeMember(value) {
|
|
33
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || isRefSentinel(value)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const entry = value;
|
|
37
|
+
const name = entry.metadata?.name;
|
|
38
|
+
return typeof entry.kind === "string" && typeof entry.name !== "string" && typeof name === "string";
|
|
39
|
+
}
|
|
40
|
+
/** The scopes recorded as out of reach for an extracted declaration. */
|
|
41
|
+
export function outsideScopesOf(manifest) {
|
|
42
|
+
const origin = (manifest
|
|
43
|
+
?.metadata?.xTeloOrigin)?.outsideScopes;
|
|
44
|
+
return Array.isArray(origin) ? origin : [];
|
|
45
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A module's **sources** — the `sources:` block on a `Telo.Library` or
|
|
3
|
+
* `Telo.Application` doc, saying where every staged file comes from: a pinned
|
|
4
|
+
* upstream archive, fetched by `telo release stage`.
|
|
5
|
+
*
|
|
6
|
+
* ```yaml
|
|
7
|
+
* sources:
|
|
8
|
+
* better-sqlite3:
|
|
9
|
+
* version: 12.8.0
|
|
10
|
+
* url: https://github.com/WiseLibs/better-sqlite3/releases/download/v{version}/better-sqlite3-v{version}-{upstream}.tar.gz
|
|
11
|
+
* archive: tar.gz
|
|
12
|
+
* notices: [./notices/better-sqlite3.LICENSE]
|
|
13
|
+
* entries:
|
|
14
|
+
* ./native/linux-amd64-gnu-node-137/better_sqlite3.node:
|
|
15
|
+
* upstream: node-v137-linux-x64
|
|
16
|
+
* member: build/Release/better_sqlite3.node
|
|
17
|
+
* sha256: 4c9e…
|
|
18
|
+
* executable: false
|
|
19
|
+
* ./native/linux-amd64-gnu/libvips.so:
|
|
20
|
+
* target: libvips.so.42
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Keyed by the module-relative path an entry produces, because the manifest
|
|
24
|
+
* already names every staged file — a `native:` entry's path or a
|
|
25
|
+
* platform-qualified controller candidate's `path=`.
|
|
26
|
+
*
|
|
27
|
+
* The single reader: every rule decidable from the block alone is a problem
|
|
28
|
+
* here, so `telo check` (`validate-source-entries.ts`), the stager and the
|
|
29
|
+
* kernels refuse the same blocks. Browser-safe: string work only.
|
|
30
|
+
*/
|
|
31
|
+
/** The archive formats an upstream may be. */
|
|
32
|
+
export declare const SOURCE_ARCHIVE_FORMATS: readonly ["tar.gz"];
|
|
33
|
+
export type SourceArchiveFormat = (typeof SOURCE_ARCHIVE_FORMATS)[number];
|
|
34
|
+
export interface SourcePin {
|
|
35
|
+
/** Lowercase hex digest of the file's bytes. */
|
|
36
|
+
readonly sha256: string;
|
|
37
|
+
readonly executable: boolean;
|
|
38
|
+
}
|
|
39
|
+
interface SourceEntryBase {
|
|
40
|
+
/** The key as written, for diagnostic paths. */
|
|
41
|
+
readonly key: string;
|
|
42
|
+
/** Module-root-relative POSIX path, normalized. */
|
|
43
|
+
readonly path: string;
|
|
44
|
+
}
|
|
45
|
+
export type SourceEntry = (SourceEntryBase & {
|
|
46
|
+
readonly kind: "file";
|
|
47
|
+
readonly upstream: string;
|
|
48
|
+
/** Path of the file inside the archive. */
|
|
49
|
+
readonly member: string;
|
|
50
|
+
/** Absent until `telo release stage --pin` writes it. */
|
|
51
|
+
readonly pin?: SourcePin;
|
|
52
|
+
}) | (SourceEntryBase & {
|
|
53
|
+
readonly kind: "link";
|
|
54
|
+
/** The link target, exactly as the link stores it. */
|
|
55
|
+
readonly target: string;
|
|
56
|
+
/** The module-relative path the target resolves to. */
|
|
57
|
+
readonly resolved: string;
|
|
58
|
+
});
|
|
59
|
+
/** How a source's files are built in this repository, keyed by build system. */
|
|
60
|
+
export interface SourceBuild {
|
|
61
|
+
/** Module-root-relative directory of the Cargo crate the files are built
|
|
62
|
+
* from, normalized (`""` for the module root). */
|
|
63
|
+
readonly cargo: string;
|
|
64
|
+
/** Digest of that crate's build inputs, `sha256-<base64url>`; absent until
|
|
65
|
+
* `telo release stage --pin` records it. */
|
|
66
|
+
readonly inputs?: string;
|
|
67
|
+
}
|
|
68
|
+
export interface ModuleSource {
|
|
69
|
+
readonly name: string;
|
|
70
|
+
readonly version: string;
|
|
71
|
+
/** The URL template, as written. */
|
|
72
|
+
readonly url: string;
|
|
73
|
+
readonly archive: SourceArchiveFormat;
|
|
74
|
+
/** Module-root-relative notice paths, normalized. */
|
|
75
|
+
readonly notices: readonly string[];
|
|
76
|
+
readonly entries: readonly SourceEntry[];
|
|
77
|
+
readonly build?: SourceBuild;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Why part of the block could not be read.
|
|
81
|
+
*
|
|
82
|
+
* `SHAPE` is a missing, mistyped or unknown key the owner doc's JSON Schema
|
|
83
|
+
* reports in the same pass; every other code is a rule `telo check` reports.
|
|
84
|
+
*/
|
|
85
|
+
export type SourceProblemCode = "SHAPE" | "SOURCE_INVALID" | "SOURCE_URL_PLACEHOLDER_UNKNOWN" | "SOURCE_URL_INSECURE" | "SOURCE_ENTRY_INVALID" | "SOURCE_LINK_TARGET_UNRESOLVED" | "SOURCE_LINK_CYCLE" | "SOURCE_ENTRY_DUPLICATE" | "SOURCE_ENTRY_NESTED";
|
|
86
|
+
export interface SourceProblem {
|
|
87
|
+
readonly code: SourceProblemCode;
|
|
88
|
+
/** Dotted path from the module doc root, for `data.path`. */
|
|
89
|
+
readonly path: string;
|
|
90
|
+
readonly message: string;
|
|
91
|
+
}
|
|
92
|
+
export interface ModuleSources {
|
|
93
|
+
readonly sources: ModuleSource[];
|
|
94
|
+
readonly problems: SourceProblem[];
|
|
95
|
+
}
|
|
96
|
+
/** The URL an entry is fetched from: substitution only. */
|
|
97
|
+
export declare function resolveSourceUrl(source: ModuleSource, upstream: string): string;
|
|
98
|
+
/** Why a url — a template, or the URL a fetch ended at after redirects — may not
|
|
99
|
+
* be fetched from, or undefined when it may: https, or plain http to a loopback
|
|
100
|
+
* host. */
|
|
101
|
+
export declare function sourceUrlProblem(url: string): {
|
|
102
|
+
code: SourceProblemCode;
|
|
103
|
+
detail: string;
|
|
104
|
+
} | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Read the `sources:` block off an owner document's JSON projection.
|
|
107
|
+
*
|
|
108
|
+
* A source or entry with any problem is left out, never read partially: a
|
|
109
|
+
* half-read entry would stage a file the author did not declare.
|
|
110
|
+
*
|
|
111
|
+
* `ignorePins` reads a file entry's `sha256` / `executable` and a build's
|
|
112
|
+
* `inputs` as absent — for the one writer of pins, which replaces them whatever
|
|
113
|
+
* they held.
|
|
114
|
+
*/
|
|
115
|
+
export declare function readModuleSources(ownerJson: unknown, options?: {
|
|
116
|
+
ignorePins?: boolean;
|
|
117
|
+
}): ModuleSources;
|
|
118
|
+
export {};
|
|
119
|
+
//# sourceMappingURL=source-entries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-entries.d.ts","sourceRoot":"","sources":["../src/source-entries.ts"],"names":[],"mappings":"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"}
|