@telorun/analyzer 0.56.1 → 0.58.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 (133) hide show
  1. package/dist/analyzer.d.ts +5 -0
  2. package/dist/analyzer.d.ts.map +1 -1
  3. package/dist/analyzer.js +232 -94
  4. package/dist/cel-environment.d.ts.map +1 -1
  5. package/dist/cel-environment.js +6 -3
  6. package/dist/definition-registry.d.ts +5 -0
  7. package/dist/definition-registry.d.ts.map +1 -1
  8. package/dist/definition-registry.js +9 -0
  9. package/dist/index.d.ts +14 -4
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +8 -3
  12. package/dist/invocation-contract.d.ts +21 -13
  13. package/dist/invocation-contract.d.ts.map +1 -1
  14. package/dist/invocation-contract.js +43 -46
  15. package/dist/loaded-types.d.ts +13 -0
  16. package/dist/loaded-types.d.ts.map +1 -1
  17. package/dist/manifest-loader.d.ts +8 -1
  18. package/dist/manifest-loader.d.ts.map +1 -1
  19. package/dist/manifest-loader.js +33 -6
  20. package/dist/manifest-visitor.d.ts +4 -0
  21. package/dist/manifest-visitor.d.ts.map +1 -1
  22. package/dist/manifest-visitor.js +3 -3
  23. package/dist/migrations/driver.d.ts +69 -0
  24. package/dist/migrations/driver.d.ts.map +1 -0
  25. package/dist/migrations/driver.js +200 -0
  26. package/dist/migrations/entries/index.d.ts +3 -0
  27. package/dist/migrations/entries/index.d.ts.map +1 -0
  28. package/dist/migrations/entries/index.js +9 -0
  29. package/dist/migrations/entries/normalize-value-types.json +48 -0
  30. package/dist/migrations/entries/ref-slot-scalar-type.json +20 -0
  31. package/dist/migrations/entry-data.d.ts +25 -0
  32. package/dist/migrations/entry-data.d.ts.map +1 -0
  33. package/dist/migrations/entry-data.js +171 -0
  34. package/dist/migrations/index.d.ts +22 -0
  35. package/dist/migrations/index.d.ts.map +1 -0
  36. package/dist/migrations/index.js +19 -0
  37. package/dist/migrations/match.d.ts +162 -0
  38. package/dist/migrations/match.d.ts.map +1 -0
  39. package/dist/migrations/match.js +295 -0
  40. package/dist/migrations/patch.d.ts +68 -0
  41. package/dist/migrations/patch.d.ts.map +1 -0
  42. package/dist/migrations/patch.js +236 -0
  43. package/dist/migrations/provenance.d.ts +25 -0
  44. package/dist/migrations/provenance.d.ts.map +1 -0
  45. package/dist/migrations/provenance.js +118 -0
  46. package/dist/migrations/registry.d.ts +35 -0
  47. package/dist/migrations/registry.d.ts.map +1 -0
  48. package/dist/migrations/registry.js +35 -0
  49. package/dist/migrations/report.d.ts +28 -0
  50. package/dist/migrations/report.d.ts.map +1 -0
  51. package/dist/migrations/report.js +144 -0
  52. package/dist/migrations/types.d.ts +115 -0
  53. package/dist/migrations/types.d.ts.map +1 -0
  54. package/dist/migrations/types.js +24 -0
  55. package/dist/migrations/yaml-edit.d.ts +21 -0
  56. package/dist/migrations/yaml-edit.d.ts.map +1 -0
  57. package/dist/migrations/yaml-edit.js +245 -0
  58. package/dist/module-file-claims.d.ts +65 -0
  59. package/dist/module-file-claims.d.ts.map +1 -0
  60. package/dist/module-file-claims.js +106 -0
  61. package/dist/parse-loaded-file.d.ts +8 -0
  62. package/dist/parse-loaded-file.d.ts.map +1 -1
  63. package/dist/parse-loaded-file.js +22 -13
  64. package/dist/resolve-schema-type-refs.d.ts +29 -12
  65. package/dist/resolve-schema-type-refs.d.ts.map +1 -1
  66. package/dist/resolve-schema-type-refs.js +89 -16
  67. package/dist/schema-compat.d.ts +35 -9
  68. package/dist/schema-compat.d.ts.map +1 -1
  69. package/dist/schema-compat.js +181 -54
  70. package/dist/schema-region.d.ts +33 -0
  71. package/dist/schema-region.d.ts.map +1 -0
  72. package/dist/schema-region.js +45 -0
  73. package/dist/types.d.ts +51 -0
  74. package/dist/types.d.ts.map +1 -1
  75. package/dist/types.js +6 -0
  76. package/dist/validate-cel-context.d.ts.map +1 -1
  77. package/dist/validate-cel-context.js +29 -3
  78. package/dist/validate-include-placement.d.ts +26 -0
  79. package/dist/validate-include-placement.d.ts.map +1 -0
  80. package/dist/validate-include-placement.js +67 -0
  81. package/dist/validate-step-inputs.d.ts +8 -1
  82. package/dist/validate-step-inputs.d.ts.map +1 -1
  83. package/dist/validate-step-inputs.js +47 -2
  84. package/dist/validate-throws-coverage.d.ts.map +1 -1
  85. package/dist/validate-throws-coverage.js +15 -12
  86. package/dist/validate-value-type-slots.d.ts +43 -0
  87. package/dist/validate-value-type-slots.d.ts.map +1 -0
  88. package/dist/validate-value-type-slots.js +142 -0
  89. package/dist/value-type-keyword.d.ts +60 -0
  90. package/dist/value-type-keyword.d.ts.map +1 -0
  91. package/dist/value-type-keyword.js +119 -0
  92. package/dist/yaml-source-edit.d.ts +56 -0
  93. package/dist/yaml-source-edit.d.ts.map +1 -0
  94. package/dist/yaml-source-edit.js +93 -0
  95. package/package.json +4 -3
  96. package/src/analyzer.ts +276 -129
  97. package/src/cel-environment.ts +6 -3
  98. package/src/definition-registry.ts +10 -0
  99. package/src/index.ts +31 -3
  100. package/src/invocation-contract.ts +43 -48
  101. package/src/loaded-types.ts +13 -0
  102. package/src/manifest-loader.ts +37 -6
  103. package/src/manifest-visitor.ts +11 -3
  104. package/src/migrations/driver.ts +262 -0
  105. package/src/migrations/entries/index.ts +10 -0
  106. package/src/migrations/entries/normalize-value-types.json +48 -0
  107. package/src/migrations/entries/ref-slot-scalar-type.json +20 -0
  108. package/src/migrations/entry-data.ts +207 -0
  109. package/src/migrations/index.ts +22 -0
  110. package/src/migrations/match.ts +382 -0
  111. package/src/migrations/patch.ts +265 -0
  112. package/src/migrations/provenance.ts +167 -0
  113. package/src/migrations/registry.ts +40 -0
  114. package/src/migrations/report.ts +169 -0
  115. package/src/migrations/types.ts +144 -0
  116. package/src/migrations/yaml-edit.ts +260 -0
  117. package/src/module-file-claims.ts +168 -0
  118. package/src/parse-loaded-file.ts +31 -12
  119. package/src/resolve-schema-type-refs.ts +93 -16
  120. package/src/schema-compat.ts +218 -62
  121. package/src/schema-region.ts +46 -0
  122. package/src/types.ts +54 -0
  123. package/src/validate-cel-context.ts +36 -3
  124. package/src/validate-include-placement.ts +70 -0
  125. package/src/validate-step-inputs.ts +56 -1
  126. package/src/validate-throws-coverage.ts +16 -11
  127. package/src/validate-value-type-slots.ts +182 -0
  128. package/src/value-type-keyword.ts +135 -0
  129. package/src/yaml-source-edit.ts +106 -0
  130. package/dist/binary-slot.d.ts +0 -39
  131. package/dist/binary-slot.d.ts.map +0 -1
  132. package/dist/binary-slot.js +0 -58
  133. package/src/binary-slot.ts +0 -71
@@ -1,71 +0,0 @@
1
- import * as AjvNS from "ajv";
2
- import type { KeywordDefinition } from "ajv";
3
-
4
- /**
5
- * `x-telo-binary: true` — the annotation that gives a byte buffer a declared
6
- * identity, and the single accessor every surface reads it through (the
7
- * `ref-slot.ts` precedent).
8
- *
9
- * WHY AN ANNOTATION RATHER THAN A TYPE. Bytes are not expressible in JSON
10
- * Schema's type vocabulary. `type: object` is the closest fit and it is a lie
11
- * that costs a real check: every arbitrary object satisfies it, so a mistyped
12
- * `content: { foo: bar }` reaches the controller instead of failing statically.
13
- * `type: binary` would fix the honesty and break everything else — AJV refuses
14
- * to compile an unknown type at all (`type must be JSONType or JSONType[]`),
15
- * with no option to allow it, so the schema would produce no validator; and a
16
- * published `telo.yaml` would stop being JSON Schema, which is what the hub, the
17
- * editor and any third-party reader consume. An `x-` keyword is ignored by
18
- * unaware tooling BY SPECIFICATION, so it degrades to "unconstrained" rather
19
- * than to "cannot validate this kind at all".
20
- *
21
- * ONE RULE, BOTH HALVES. The keyword is implemented as AJV CODEGEN rather than a
22
- * `validate` function so it inlines into standalone-compiled validators — the
23
- * kernel compiles and caches those, and a function-valued keyword would not
24
- * survive serialization. The analyzer registers the identical keyword, and
25
- * `celPlaceholderForSchema` hands a real `Uint8Array` to a CEL leaf at a binary
26
- * slot, so static and runtime agree by construction instead of by two rules kept
27
- * in step. What falls out is the check the annotation exists for: **bytes can
28
- * never be manifest-authored** — no YAML literal is a `Uint8Array` — so a literal
29
- * at a binary slot is rejected while a value arriving by reference passes.
30
- */
31
-
32
- export const X_TELO_BINARY = "x-telo-binary";
33
-
34
- /** True when this schema node declares its value to be raw bytes. */
35
- export function isBinarySlot(schema: unknown): boolean {
36
- return (
37
- typeof schema === "object" &&
38
- schema !== null &&
39
- (schema as Record<string, unknown>)[X_TELO_BINARY] === true
40
- );
41
- }
42
-
43
- // AJV's codegen template tag. The package is consumed in both ESM and CJS interop
44
- // shapes, so the named export may sit on the namespace or behind `.default` —
45
- // the same fallback `schema-compat` uses to reach the constructor. Skipping it
46
- // would leave `codegen` undefined under a loader that does not detect AJV's named
47
- // CJS re-exports, and the keyword would throw on its first compile.
48
- type CodegenTag = (s: TemplateStringsArray, ...a: unknown[]) => unknown;
49
- const ajvExports = (AjvNS as any).default ?? AjvNS;
50
- const codegen: CodegenTag = ajvExports._ ?? (AjvNS as any)._;
51
-
52
- /**
53
- * The AJV keyword. `Uint8Array` is the structural test rather than any richer
54
- * notion of "binary": it is what every byte producer in the runtime hands over
55
- * (`Buffer` extends it, so Node buffers pass), and it is the one check that means
56
- * the same thing in a browser-side analyzer and in the kernel.
57
- */
58
- export function binaryKeyword(): KeywordDefinition {
59
- return {
60
- keyword: X_TELO_BINARY,
61
- schemaType: "boolean",
62
- code(cxt: any) {
63
- // `x-telo-binary: false` states nothing, so it constrains nothing.
64
- if (cxt.schema !== true) return;
65
- cxt.pass(codegen`${cxt.data} instanceof Uint8Array`);
66
- },
67
- error: {
68
- message: "must be raw bytes (a Uint8Array) — bytes cannot be written inline in a manifest",
69
- },
70
- } as KeywordDefinition;
71
- }