@telorun/analyzer 0.11.0 → 1.2.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 (56) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +3 -3
  3. package/dist/analysis-registry.d.ts +7 -0
  4. package/dist/analysis-registry.d.ts.map +1 -1
  5. package/dist/analysis-registry.js +38 -0
  6. package/dist/analyzer.d.ts.map +1 -1
  7. package/dist/analyzer.js +53 -9
  8. package/dist/builtins.d.ts.map +1 -1
  9. package/dist/builtins.js +44 -1
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +1 -0
  13. package/dist/kernel-globals.d.ts.map +1 -1
  14. package/dist/kernel-globals.js +9 -11
  15. package/dist/manifest-loader.d.ts +23 -1
  16. package/dist/manifest-loader.d.ts.map +1 -1
  17. package/dist/manifest-loader.js +66 -3
  18. package/dist/normalize-inline-resources.d.ts.map +1 -1
  19. package/dist/normalize-inline-resources.js +26 -14
  20. package/dist/position-metadata.d.ts +5 -1
  21. package/dist/position-metadata.d.ts.map +1 -1
  22. package/dist/position-metadata.js +8 -1
  23. package/dist/reference-field-map.d.ts +21 -4
  24. package/dist/reference-field-map.d.ts.map +1 -1
  25. package/dist/reference-field-map.js +35 -19
  26. package/dist/residual-schema.d.ts +23 -0
  27. package/dist/residual-schema.d.ts.map +1 -0
  28. package/dist/residual-schema.js +45 -0
  29. package/dist/rewrite-synthetic-origins.d.ts +10 -0
  30. package/dist/rewrite-synthetic-origins.d.ts.map +1 -0
  31. package/dist/rewrite-synthetic-origins.js +55 -0
  32. package/dist/types.d.ts +12 -0
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/validate-cel-context.d.ts +5 -0
  35. package/dist/validate-cel-context.d.ts.map +1 -1
  36. package/dist/validate-cel-context.js +27 -15
  37. package/dist/validate-provider-coherence.d.ts +23 -0
  38. package/dist/validate-provider-coherence.d.ts.map +1 -0
  39. package/dist/validate-provider-coherence.js +148 -0
  40. package/dist/validate-references.js +24 -24
  41. package/package.json +7 -4
  42. package/src/analysis-registry.ts +37 -0
  43. package/src/analyzer.ts +55 -11
  44. package/src/builtins.ts +44 -1
  45. package/src/index.ts +1 -0
  46. package/src/kernel-globals.ts +9 -11
  47. package/src/manifest-loader.ts +69 -4
  48. package/src/normalize-inline-resources.ts +48 -13
  49. package/src/position-metadata.ts +8 -1
  50. package/src/reference-field-map.ts +46 -18
  51. package/src/residual-schema.ts +49 -0
  52. package/src/rewrite-synthetic-origins.ts +75 -0
  53. package/src/types.ts +12 -0
  54. package/src/validate-cel-context.ts +28 -15
  55. package/src/validate-provider-coherence.ts +166 -0
  56. package/src/validate-references.ts +24 -24
@@ -1,5 +1,5 @@
1
1
  import type { ResourceManifest } from "@telorun/sdk";
2
- import { isRefEntry, isScopeEntry, isSchemaFromEntry, isInlineResource, resolveFieldValues, type RefFieldEntry } from "./reference-field-map.js";
2
+ import { isRefEntry, isScopeEntry, isSchemaFromEntry, isInlineResource, resolveFieldEntries, resolveFieldValues, type RefFieldEntry } from "./reference-field-map.js";
3
3
  import { navigateJsonPointer } from "./schema-compat.js";
4
4
  import { DiagnosticSeverity, type AnalysisDiagnostic, type AnalysisContext } from "./types.js";
5
5
  import type { AliasResolver } from "./alias-resolver.js";
@@ -142,7 +142,7 @@ export function validateReferences(
142
142
  }
143
143
  }
144
144
 
145
- for (const val of resolveFieldValues(r, fieldPath)) {
145
+ for (const { value: val, path: concretePath } of resolveFieldEntries(r, fieldPath)) {
146
146
  if (!val) continue;
147
147
 
148
148
  // Name-only reference (plain string) — look up by name to validate.
@@ -166,8 +166,8 @@ export function validateReferences(
166
166
  severity: DiagnosticSeverity.Error,
167
167
  code: "UNRESOLVED_REFERENCE",
168
168
  source: SOURCE,
169
- message: `${resourceLabel}: reference at '${fieldPath}' → resource '${val}' not found`,
170
- data: { resource: resourceData, filePath, path: fieldPath },
169
+ message: `${resourceLabel}: reference at '${concretePath}' → resource '${val}' not found`,
170
+ data: { resource: resourceData, filePath, path: concretePath },
171
171
  });
172
172
  continue;
173
173
  }
@@ -177,8 +177,8 @@ export function validateReferences(
177
177
  severity: DiagnosticSeverity.Error,
178
178
  code: "REFERENCE_KIND_MISMATCH",
179
179
  source: SOURCE,
180
- message: `${resourceLabel}: reference at '${fieldPath}' → ${kindErrors.join("; ")}`,
181
- data: { resource: resourceData, filePath, path: fieldPath },
180
+ message: `${resourceLabel}: reference at '${concretePath}' → ${kindErrors.join("; ")}`,
181
+ data: { resource: resourceData, filePath, path: concretePath },
182
182
  });
183
183
  }
184
184
  continue;
@@ -196,8 +196,8 @@ export function validateReferences(
196
196
  severity: DiagnosticSeverity.Error,
197
197
  code: "INVALID_REFERENCE",
198
198
  source: SOURCE,
199
- message: `${resourceLabel}: reference at '${fieldPath}' must have string 'kind' and 'name' fields`,
200
- data: { resource: resourceData, filePath, path: fieldPath },
199
+ message: `${resourceLabel}: reference at '${concretePath}' must have string 'kind' and 'name' fields`,
200
+ data: { resource: resourceData, filePath, path: concretePath },
201
201
  });
202
202
  continue;
203
203
  }
@@ -209,8 +209,8 @@ export function validateReferences(
209
209
  severity: DiagnosticSeverity.Error,
210
210
  code: "REFERENCE_KIND_MISMATCH",
211
211
  source: SOURCE,
212
- message: `${resourceLabel}: reference at '${fieldPath}' → ${kindErrors.join("; ")}`,
213
- data: { resource: resourceData, filePath, path: fieldPath },
212
+ message: `${resourceLabel}: reference at '${concretePath}' → ${kindErrors.join("; ")}`,
213
+ data: { resource: resourceData, filePath, path: concretePath },
214
214
  });
215
215
  }
216
216
 
@@ -223,8 +223,8 @@ export function validateReferences(
223
223
  severity: DiagnosticSeverity.Error,
224
224
  code: "UNRESOLVED_REFERENCE",
225
225
  source: SOURCE,
226
- message: `${resourceLabel}: reference at '${fieldPath}' → resource '${refVal.name}' not found`,
227
- data: { resource: resourceData, filePath, path: fieldPath },
226
+ message: `${resourceLabel}: reference at '${concretePath}' → resource '${refVal.name}' not found`,
227
+ data: { resource: resourceData, filePath, path: concretePath },
228
228
  });
229
229
  }
230
230
  }
@@ -317,7 +317,7 @@ export function validateReferences(
317
317
  continue;
318
318
  }
319
319
 
320
- for (const fieldValue of resolveFieldValues(r, fieldPath)) {
320
+ for (const { value: fieldValue, path: concretePath } of resolveFieldEntries(r, fieldPath)) {
321
321
  if (fieldValue == null) continue;
322
322
  const issues = registry.validateWithRefs(fieldValue, subSchema as Record<string, any>);
323
323
  for (const issue of issues) {
@@ -325,8 +325,8 @@ export function validateReferences(
325
325
  severity: DiagnosticSeverity.Error,
326
326
  code: "DEPENDENT_SCHEMA_MISMATCH",
327
327
  source: SOURCE,
328
- message: `${resourceLabel}: '${fieldPath}' does not match schema from '${anchorName}${jsonPointer}': ${issue}`,
329
- data: { resource: resourceData, filePath, path: fieldPath },
328
+ message: `${resourceLabel}: '${concretePath}' does not match schema from '${anchorName}${jsonPointer}': ${issue}`,
329
+ data: { resource: resourceData, filePath, path: concretePath },
330
330
  });
331
331
  }
332
332
  }
@@ -347,10 +347,10 @@ export function validateReferences(
347
347
  const anchorValues = resolveFieldValues(r, anchorPath);
348
348
  if (anchorValues.length === 0) continue; // anchor field not set — nothing to validate
349
349
 
350
- const fieldValues = resolveFieldValues(r, fieldPath);
350
+ const fieldEntries = resolveFieldEntries(r, fieldPath);
351
351
 
352
- for (let i = 0; i < fieldValues.length; i++) {
353
- const fieldValue = fieldValues[i];
352
+ for (let i = 0; i < fieldEntries.length; i++) {
353
+ const { value: fieldValue, path: concretePath } = fieldEntries[i];
354
354
  if (fieldValue == null) continue;
355
355
 
356
356
  // For absolute paths, the single anchor applies to all field values.
@@ -367,8 +367,8 @@ export function validateReferences(
367
367
  severity: DiagnosticSeverity.Error,
368
368
  code: "SCHEMA_FROM_MISSING_PATH",
369
369
  source: SOURCE,
370
- message: `${resourceLabel}: x-telo-schema-from at '${fieldPath}' → kind '${refVal.kind}' has no schema`,
371
- data: { resource: resourceData, filePath, path: fieldPath },
370
+ message: `${resourceLabel}: x-telo-schema-from at '${concretePath}' → kind '${refVal.kind}' has no schema`,
371
+ data: { resource: resourceData, filePath, path: concretePath },
372
372
  });
373
373
  continue;
374
374
  }
@@ -379,8 +379,8 @@ export function validateReferences(
379
379
  severity: DiagnosticSeverity.Error,
380
380
  code: "SCHEMA_FROM_MISSING_PATH",
381
381
  source: SOURCE,
382
- message: `${resourceLabel}: x-telo-schema-from at '${fieldPath}' → kind '${refVal.kind}' has no schema path '${jsonPointer}'`,
383
- data: { resource: resourceData, filePath, path: fieldPath },
382
+ message: `${resourceLabel}: x-telo-schema-from at '${concretePath}' → kind '${refVal.kind}' has no schema path '${jsonPointer}'`,
383
+ data: { resource: resourceData, filePath, path: concretePath },
384
384
  });
385
385
  continue;
386
386
  }
@@ -391,8 +391,8 @@ export function validateReferences(
391
391
  severity: DiagnosticSeverity.Error,
392
392
  code: "DEPENDENT_SCHEMA_MISMATCH",
393
393
  source: SOURCE,
394
- message: `${resourceLabel}: '${fieldPath}' does not match schema from '${refVal.kind}${jsonPointer}': ${issue}`,
395
- data: { resource: resourceData, filePath, path: fieldPath },
394
+ message: `${resourceLabel}: '${concretePath}' does not match schema from '${refVal.kind}${jsonPointer}': ${issue}`,
395
+ data: { resource: resourceData, filePath, path: concretePath },
396
396
  });
397
397
  }
398
398
  }