@telorun/analyzer 0.65.0 → 0.66.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 (100) hide show
  1. package/dist/analyzer.d.ts +1 -1
  2. package/dist/analyzer.d.ts.map +1 -1
  3. package/dist/analyzer.js +157 -63
  4. package/dist/call-graph.d.ts.map +1 -1
  5. package/dist/call-graph.js +7 -1
  6. package/dist/cel-environment.d.ts +12 -0
  7. package/dist/cel-environment.d.ts.map +1 -1
  8. package/dist/cel-environment.js +35 -19
  9. package/dist/cel-scope.d.ts.map +1 -1
  10. package/dist/cel-scope.js +24 -4
  11. package/dist/definition-registry.d.ts +24 -0
  12. package/dist/definition-registry.d.ts.map +1 -1
  13. package/dist/definition-registry.js +41 -0
  14. package/dist/eval-paths.d.ts +68 -0
  15. package/dist/eval-paths.d.ts.map +1 -1
  16. package/dist/eval-paths.js +138 -0
  17. package/dist/flatten-for-analyzer.d.ts +1 -1
  18. package/dist/flatten-for-analyzer.js +1 -1
  19. package/dist/import-resolution-diagnostics.d.ts +1 -1
  20. package/dist/import-resolution-diagnostics.js +1 -1
  21. package/dist/index.d.ts +9 -7
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +6 -5
  24. package/dist/manifest-visitor.d.ts.map +1 -1
  25. package/dist/manifest-visitor.js +8 -1
  26. package/dist/migrations/entries/index.d.ts.map +1 -1
  27. package/dist/migrations/entries/index.js +2 -0
  28. package/dist/migrations/entries/schema-prepare-bucket.json +27 -0
  29. package/dist/peer-binding.d.ts +232 -0
  30. package/dist/peer-binding.d.ts.map +1 -0
  31. package/dist/peer-binding.js +418 -0
  32. package/dist/ref-slot.d.ts +13 -0
  33. package/dist/ref-slot.d.ts.map +1 -1
  34. package/dist/ref-slot.js +26 -0
  35. package/dist/reference-field-map.d.ts +28 -0
  36. package/dist/reference-field-map.d.ts.map +1 -1
  37. package/dist/reference-field-map.js +25 -0
  38. package/dist/referrer-rule.d.ts +17 -0
  39. package/dist/referrer-rule.d.ts.map +1 -1
  40. package/dist/referrer-rule.js +4 -1
  41. package/dist/release/index.d.ts +1 -1
  42. package/dist/release/index.js +1 -1
  43. package/dist/resource-rule.d.ts +40 -27
  44. package/dist/resource-rule.d.ts.map +1 -1
  45. package/dist/resource-rule.js +61 -7
  46. package/dist/rule-condition.d.ts +11 -0
  47. package/dist/rule-condition.d.ts.map +1 -1
  48. package/dist/rule-condition.js +13 -0
  49. package/dist/schema-projection.d.ts +106 -4
  50. package/dist/schema-projection.d.ts.map +1 -1
  51. package/dist/schema-projection.js +206 -18
  52. package/dist/telo-version.d.ts +1 -1
  53. package/dist/telo-version.js +1 -1
  54. package/dist/validate-cel-context.d.ts +1 -17
  55. package/dist/validate-cel-context.d.ts.map +1 -1
  56. package/dist/validate-cel-context.js +5 -70
  57. package/dist/validate-reference-forms.d.ts +10 -0
  58. package/dist/validate-reference-forms.d.ts.map +1 -1
  59. package/dist/validate-reference-forms.js +23 -0
  60. package/dist/validate-references.d.ts.map +1 -1
  61. package/dist/validate-references.js +9 -2
  62. package/dist/validate-referrer-rules.d.ts +38 -4
  63. package/dist/validate-referrer-rules.d.ts.map +1 -1
  64. package/dist/validate-referrer-rules.js +139 -31
  65. package/dist/validate-resource-rules.d.ts +11 -2
  66. package/dist/validate-resource-rules.d.ts.map +1 -1
  67. package/dist/validate-resource-rules.js +18 -12
  68. package/dist/validate-schema-projection.d.ts.map +1 -1
  69. package/dist/validate-schema-projection.js +33 -2
  70. package/dist/with-synthetic-positions.d.ts +1 -1
  71. package/dist/with-synthetic-positions.js +1 -1
  72. package/package.json +3 -3
  73. package/src/analyzer.ts +191 -68
  74. package/src/call-graph.ts +7 -1
  75. package/src/cel-environment.ts +48 -19
  76. package/src/cel-scope.ts +24 -6
  77. package/src/definition-registry.ts +42 -0
  78. package/src/eval-paths.ts +152 -0
  79. package/src/flatten-for-analyzer.ts +1 -1
  80. package/src/import-resolution-diagnostics.ts +1 -1
  81. package/src/index.ts +45 -4
  82. package/src/manifest-visitor.ts +8 -1
  83. package/src/migrations/entries/index.ts +2 -0
  84. package/src/migrations/entries/schema-prepare-bucket.json +27 -0
  85. package/src/peer-binding.ts +641 -0
  86. package/src/ref-slot.ts +36 -0
  87. package/src/reference-field-map.ts +42 -0
  88. package/src/referrer-rule.ts +20 -1
  89. package/src/release/index.ts +1 -1
  90. package/src/resource-rule.ts +69 -7
  91. package/src/rule-condition.ts +15 -0
  92. package/src/schema-projection.ts +283 -20
  93. package/src/telo-version.ts +1 -1
  94. package/src/validate-cel-context.ts +6 -71
  95. package/src/validate-reference-forms.ts +22 -0
  96. package/src/validate-references.ts +15 -2
  97. package/src/validate-referrer-rules.ts +215 -28
  98. package/src/validate-resource-rules.ts +26 -12
  99. package/src/validate-schema-projection.ts +50 -1
  100. package/src/with-synthetic-positions.ts +1 -1
@@ -26,6 +26,7 @@ import {
26
26
  projectionKeyMap,
27
27
  rawSchemaProjection,
28
28
  readSchemaProjection,
29
+ schemaMapBranch,
29
30
  schemaProjectionIsMisplaced,
30
31
  } from "./schema-projection.js";
31
32
 
@@ -118,6 +119,48 @@ export function validateSchemaProjection(manifest: ResourceManifest): SchemaProj
118
119
  ];
119
120
  }
120
121
 
122
+ const reference = raw.reference;
123
+ if (reference !== undefined) {
124
+ if (!isObject(reference)) {
125
+ issues.push(
126
+ issue(
127
+ "SCHEMA_PROJECTION_INVALID",
128
+ `${base}.reference`,
129
+ `'reference' says how an entry whose '${projection.key}' holds a REFERENCE projects. ` +
130
+ `It is an object naming 'from' (the target field to read), 'keyword' (the schema ` +
131
+ `keyword its values become) and one of 'base' / 'baseFrom'.`,
132
+ ),
133
+ );
134
+ } else {
135
+ const absent = ["from", "keyword"].filter((f) => typeof reference[f] !== "string");
136
+ if (absent.length > 0) {
137
+ issues.push(
138
+ issue(
139
+ "SCHEMA_PROJECTION_INVALID",
140
+ `${base}.reference`,
141
+ `'reference' is missing ${absent.map((f) => `'${f}'`).join(" and ")}. Without them a ` +
142
+ `referenced entry projects to nothing, so it vanishes from every consumer's view.`,
143
+ ),
144
+ );
145
+ }
146
+ const bases = ["base", "baseFrom"].filter((f) => reference[f] !== undefined);
147
+ if (bases.length !== 1) {
148
+ issues.push(
149
+ issue(
150
+ "SCHEMA_PROJECTION_INVALID",
151
+ `${base}.reference`,
152
+ bases.length === 0
153
+ ? `'reference' declares neither 'base' nor 'baseFrom', so the projected node has no ` +
154
+ `type. Write 'base' where the named type IS its own base type, or 'baseFrom' ` +
155
+ `naming the target field that holds a value of this kind's own map.`
156
+ : `'reference' declares both 'base' and 'baseFrom'. They are two answers to one ` +
157
+ `question — where the projected node's type comes from — so declare exactly one.`,
158
+ ),
159
+ );
160
+ }
161
+ }
162
+ }
163
+
121
164
  const map = projectionKeyMap(schema, projection);
122
165
  if (!map) {
123
166
  return [
@@ -180,5 +223,11 @@ function keySchema(
180
223
  : undefined;
181
224
  if (!isObject(entry) || !isObject(entry.properties)) return undefined;
182
225
  const field = entry.properties[key];
183
- return isObject(field) ? field : undefined;
226
+ if (!isObject(field)) return undefined;
227
+ // The vocabulary may sit on a BRANCH — a slot unioning a closed value set with
228
+ // a reference — and the branch carrying the map is the one whose `enum` the map
229
+ // has to answer for. Reading the union node instead finds no `enum` at all, so
230
+ // the completeness check would silently stop running exactly where the two
231
+ // halves can disagree. Asked through the single reader, never re-derived here.
232
+ return schemaMapBranch(field) ?? field;
184
233
  }
@@ -10,7 +10,7 @@ import { REF_VALIDATION_SKIP_KINDS } from "./system-kinds.js";
10
10
  * manifest (the dedup that backs `DUPLICATE_RESOURCE_NAME` reads
11
11
  * `(source, sourceLine)` to distinguish pipeline echoes from real
12
12
  * collisions). Production callers — the `Loader`, `flattenForAnalyzer`,
13
- * the telo-editor's `emitDocsFor`, the VSCode extension — all stamp
13
+ * telo studio's `emitDocsFor`, the VSCode extension — all stamp
14
14
  * positions already. This helper is the escape hatch for **programmatic
15
15
  * callers** (tests, ad-hoc scripts) that construct `ResourceManifest`
16
16
  * literals without going through a loader: it gives every otherwise-naked