@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.
Files changed (208) hide show
  1. package/dist/analyzer.d.ts.map +1 -1
  2. package/dist/analyzer.js +76 -20
  3. package/dist/artifact-axes.d.ts +14 -0
  4. package/dist/artifact-axes.d.ts.map +1 -0
  5. package/dist/artifact-axes.js +12 -0
  6. package/dist/artifact-layer-index.d.ts +2 -2
  7. package/dist/artifact-layer-index.d.ts.map +1 -1
  8. package/dist/artifact-layer-index.js +9 -4
  9. package/dist/artifact-selector.d.ts +47 -21
  10. package/dist/artifact-selector.d.ts.map +1 -1
  11. package/dist/artifact-selector.js +85 -16
  12. package/dist/builtins.d.ts.map +1 -1
  13. package/dist/builtins.js +144 -113
  14. package/dist/call-graph.d.ts +12 -1
  15. package/dist/call-graph.d.ts.map +1 -1
  16. package/dist/call-graph.js +22 -0
  17. package/dist/catch-scope.js +1 -1
  18. package/dist/cel-scope-query.d.ts.map +1 -1
  19. package/dist/cel-scope-query.js +32 -11
  20. package/dist/cel-scope.d.ts.map +1 -1
  21. package/dist/cel-scope.js +1 -0
  22. package/dist/eval-paths.d.ts +36 -5
  23. package/dist/eval-paths.d.ts.map +1 -1
  24. package/dist/eval-paths.js +47 -6
  25. package/dist/extends-resolution.d.ts +12 -0
  26. package/dist/extends-resolution.d.ts.map +1 -1
  27. package/dist/extends-resolution.js +23 -0
  28. package/dist/forwarded-declaration.d.ts +26 -0
  29. package/dist/forwarded-declaration.d.ts.map +1 -0
  30. package/dist/forwarded-declaration.js +31 -0
  31. package/dist/index.d.ts +10 -4
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +5 -2
  34. package/dist/kernel-globals.d.ts.map +1 -1
  35. package/dist/kernel-globals.js +21 -5
  36. package/dist/module-alias-scope.d.ts +11 -0
  37. package/dist/module-alias-scope.d.ts.map +1 -1
  38. package/dist/module-alias-scope.js +10 -0
  39. package/dist/module-file-claims.d.ts +17 -1
  40. package/dist/module-file-claims.d.ts.map +1 -1
  41. package/dist/module-file-claims.js +38 -3
  42. package/dist/module-named-files.d.ts +72 -0
  43. package/dist/module-named-files.d.ts.map +1 -0
  44. package/dist/module-named-files.js +115 -0
  45. package/dist/native-entries.d.ts +83 -0
  46. package/dist/native-entries.d.ts.map +1 -0
  47. package/dist/native-entries.js +169 -0
  48. package/dist/nearest-name.d.ts +22 -0
  49. package/dist/nearest-name.d.ts.map +1 -0
  50. package/dist/nearest-name.js +43 -0
  51. package/dist/normalize-inline-resources.d.ts +41 -13
  52. package/dist/normalize-inline-resources.d.ts.map +1 -1
  53. package/dist/normalize-inline-resources.js +236 -54
  54. package/dist/reference-field-map.d.ts +59 -1
  55. package/dist/reference-field-map.d.ts.map +1 -1
  56. package/dist/reference-field-map.js +200 -34
  57. package/dist/release/destinations.d.ts +59 -0
  58. package/dist/release/destinations.d.ts.map +1 -0
  59. package/dist/release/destinations.js +75 -0
  60. package/dist/release/index.d.ts +6 -2
  61. package/dist/release/index.d.ts.map +1 -1
  62. package/dist/release/index.js +3 -1
  63. package/dist/release/ledger.d.ts +20 -11
  64. package/dist/release/ledger.d.ts.map +1 -1
  65. package/dist/release/ledger.js +43 -14
  66. package/dist/release/payload-digest.d.ts +2 -1
  67. package/dist/release/payload-digest.d.ts.map +1 -1
  68. package/dist/release/payload-digest.js +2 -1
  69. package/dist/release/release-plan.d.ts +3 -2
  70. package/dist/release/release-plan.d.ts.map +1 -1
  71. package/dist/release/release-plan.js +12 -19
  72. package/dist/release/workspace-config.d.ts +114 -34
  73. package/dist/release/workspace-config.d.ts.map +1 -1
  74. package/dist/release/workspace-config.js +322 -38
  75. package/dist/release/workspace-schema.d.ts +41 -0
  76. package/dist/release/workspace-schema.d.ts.map +1 -0
  77. package/dist/release/workspace-schema.js +77 -0
  78. package/dist/resolve-ref-sentinels.d.ts.map +1 -1
  79. package/dist/resolve-ref-sentinels.js +8 -5
  80. package/dist/resolve-throws-union.d.ts +25 -4
  81. package/dist/resolve-throws-union.d.ts.map +1 -1
  82. package/dist/resolve-throws-union.js +62 -32
  83. package/dist/resolve-zone-requirements.d.ts.map +1 -1
  84. package/dist/resolve-zone-requirements.js +2 -1
  85. package/dist/rewrite-synthetic-origins.d.ts +6 -1
  86. package/dist/rewrite-synthetic-origins.d.ts.map +1 -1
  87. package/dist/rewrite-synthetic-origins.js +107 -13
  88. package/dist/schema-compat.d.ts.map +1 -1
  89. package/dist/schema-compat.js +18 -5
  90. package/dist/schema-error-report.d.ts +7 -0
  91. package/dist/schema-error-report.d.ts.map +1 -1
  92. package/dist/schema-error-report.js +9 -4
  93. package/dist/schema-walk.d.ts +47 -13
  94. package/dist/schema-walk.d.ts.map +1 -1
  95. package/dist/schema-walk.js +150 -30
  96. package/dist/scope-declarations.d.ts +59 -0
  97. package/dist/scope-declarations.d.ts.map +1 -0
  98. package/dist/scope-declarations.js +45 -0
  99. package/dist/source-entries.d.ts +119 -0
  100. package/dist/source-entries.d.ts.map +1 -0
  101. package/dist/source-entries.js +349 -0
  102. package/dist/step-bodies.d.ts +24 -0
  103. package/dist/step-bodies.d.ts.map +1 -0
  104. package/dist/step-bodies.js +28 -0
  105. package/dist/telo-version.d.ts +1 -1
  106. package/dist/telo-version.js +1 -1
  107. package/dist/template-body.d.ts +10 -0
  108. package/dist/template-body.d.ts.map +1 -1
  109. package/dist/template-body.js +25 -0
  110. package/dist/validate-cel-context.d.ts +23 -8
  111. package/dist/validate-cel-context.d.ts.map +1 -1
  112. package/dist/validate-cel-context.js +51 -18
  113. package/dist/validate-exports.d.ts +28 -0
  114. package/dist/validate-exports.d.ts.map +1 -0
  115. package/dist/validate-exports.js +146 -0
  116. package/dist/validate-extends.d.ts.map +1 -1
  117. package/dist/validate-extends.js +37 -1
  118. package/dist/validate-module-artifact.d.ts +4 -2
  119. package/dist/validate-module-artifact.d.ts.map +1 -1
  120. package/dist/validate-module-artifact.js +43 -4
  121. package/dist/validate-native-entries.d.ts +15 -0
  122. package/dist/validate-native-entries.d.ts.map +1 -0
  123. package/dist/validate-native-entries.js +103 -0
  124. package/dist/validate-observed-state.d.ts +7 -1
  125. package/dist/validate-observed-state.d.ts.map +1 -1
  126. package/dist/validate-observed-state.js +24 -6
  127. package/dist/validate-provider-coherence.d.ts +4 -8
  128. package/dist/validate-provider-coherence.d.ts.map +1 -1
  129. package/dist/validate-provider-coherence.js +12 -123
  130. package/dist/validate-reference-forms.d.ts.map +1 -1
  131. package/dist/validate-reference-forms.js +2 -2
  132. package/dist/validate-references.d.ts.map +1 -1
  133. package/dist/validate-references.js +152 -65
  134. package/dist/validate-scope-reach.d.ts +31 -0
  135. package/dist/validate-scope-reach.d.ts.map +1 -0
  136. package/dist/validate-scope-reach.js +180 -0
  137. package/dist/validate-source-entries.d.ts +16 -0
  138. package/dist/validate-source-entries.d.ts.map +1 -0
  139. package/dist/validate-source-entries.js +90 -0
  140. package/dist/validate-template-body.d.ts +36 -0
  141. package/dist/validate-template-body.d.ts.map +1 -0
  142. package/dist/validate-template-body.js +246 -0
  143. package/dist/validate-throws-coverage.d.ts.map +1 -1
  144. package/dist/validate-throws-coverage.js +21 -39
  145. package/dist/value-type-keyword.d.ts +22 -5
  146. package/dist/value-type-keyword.d.ts.map +1 -1
  147. package/dist/value-type-keyword.js +16 -7
  148. package/package.json +4 -3
  149. package/src/analyzer.ts +97 -20
  150. package/src/artifact-axes.ts +24 -0
  151. package/src/artifact-layer-index.ts +9 -6
  152. package/src/artifact-selector.ts +110 -35
  153. package/src/builtins.ts +160 -113
  154. package/src/call-graph.ts +30 -0
  155. package/src/catch-scope.ts +1 -1
  156. package/src/cel-scope-query.ts +28 -9
  157. package/src/cel-scope.ts +1 -0
  158. package/src/eval-paths.ts +53 -6
  159. package/src/extends-resolution.ts +24 -0
  160. package/src/forwarded-declaration.ts +32 -0
  161. package/src/index.ts +37 -1
  162. package/src/kernel-globals.ts +28 -5
  163. package/src/migrations/CLAUDE.md +35 -0
  164. package/src/module-alias-scope.ts +17 -0
  165. package/src/module-file-claims.ts +63 -4
  166. package/src/module-named-files.ts +162 -0
  167. package/src/native-entries.ts +227 -0
  168. package/src/nearest-name.ts +47 -0
  169. package/src/normalize-inline-resources.ts +326 -70
  170. package/src/reference-field-map.ts +257 -52
  171. package/src/release/CLAUDE.md +32 -0
  172. package/src/release/destinations.ts +105 -0
  173. package/src/release/index.ts +33 -2
  174. package/src/release/ledger.ts +51 -21
  175. package/src/release/payload-digest.ts +2 -1
  176. package/src/release/release-plan.ts +16 -26
  177. package/src/release/workspace-config.ts +483 -47
  178. package/src/release/workspace-schema.ts +99 -0
  179. package/src/resolve-ref-sentinels.ts +7 -6
  180. package/src/resolve-throws-union.ts +87 -32
  181. package/src/resolve-zone-requirements.ts +2 -1
  182. package/src/rewrite-synthetic-origins.ts +107 -16
  183. package/src/schema-compat.ts +18 -4
  184. package/src/schema-error-report.ts +16 -4
  185. package/src/schema-walk.ts +162 -34
  186. package/src/scope-declarations.ts +98 -0
  187. package/src/source-entries.ts +502 -0
  188. package/src/step-bodies.ts +55 -0
  189. package/src/telo-version.ts +1 -1
  190. package/src/template-body.ts +25 -0
  191. package/src/validate-cel-context.ts +60 -18
  192. package/src/validate-exports.ts +185 -0
  193. package/src/validate-extends.ts +43 -0
  194. package/src/validate-module-artifact.ts +46 -3
  195. package/src/validate-native-entries.ts +147 -0
  196. package/src/validate-observed-state.ts +36 -7
  197. package/src/validate-provider-coherence.ts +17 -127
  198. package/src/validate-reference-forms.ts +2 -3
  199. package/src/validate-references.ts +151 -66
  200. package/src/validate-scope-reach.ts +213 -0
  201. package/src/validate-source-entries.ts +120 -0
  202. package/src/validate-template-body.ts +274 -0
  203. package/src/validate-throws-coverage.ts +24 -31
  204. package/src/value-type-keyword.ts +35 -9
  205. package/dist/validate-template-dispatch.d.ts +0 -27
  206. package/dist/validate-template-dispatch.d.ts.map +0 -1
  207. package/dist/validate-template-dispatch.js +0 -95
  208. package/src/validate-template-dispatch.ts +0 -99
@@ -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 { readRefSlot } from "./ref-slot.js";
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 with two consumersthe inherited union here, and the catch
134
- * scope enclosure in `validate-throws-coverage.ts` because both ask the same
135
- * structural question and two copies would eventually disagree about where the
136
- * walk stops. It terminates on the manifest's own depth, and it stops AT a step
137
- * slot (that traversal owns everything below it, `try`/`catch` subtraction
138
- * included) and AT a reference slot (a resolved ref is a leaf, `{kind, name}`,
139
- * with nothing beneath it to visit).
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, path = "") {
162
+ export function forEachDrivenSlot(schema, data, visit) {
142
163
  if (!schema || typeof schema !== "object" || data === undefined || data === null)
143
164
  return;
144
- const node = schema;
145
- const stepSlot = readStepSlot(node);
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 props = node.properties;
157
- if (props && typeof data === "object" && !Array.isArray(data)) {
158
- const obj = data;
159
- for (const [key, propSchema] of Object.entries(props)) {
160
- if (obj[key] === undefined)
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
- forEachDrivenSlot(propSchema, obj[key], visit, path ? `${path}.${key}` : key);
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
- if (node.items && Array.isArray(data)) {
166
- for (const [i, item] of data.entries()) {
167
- forEachDrivenSlot(node.items, item, visit, `${path}[${i}]`);
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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AO,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":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAcH,8CAA8C;AAC9C,eAAO,MAAM,sBAAsB,qBAAsB,CAAC;AAC1D,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1E,MAAM,WAAW,SAAS;IACxB,gDAAgD;IAChD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED,UAAU,eAAe;IACvB,gDAAgD;IAChD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,WAAW,GACnB,CAAC,eAAe,GAAG;IACjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,2CAA2C;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,yDAAyD;IACzD,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC;CAC1B,CAAC,GACF,CAAC,eAAe,GAAG;IACjB,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