@telorun/analyzer 0.55.0 → 0.56.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/binary-slot.d.ts +39 -0
- package/dist/binary-slot.d.ts.map +1 -0
- package/dist/binary-slot.js +58 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/schema-compat.d.ts.map +1 -1
- package/dist/schema-compat.js +11 -0
- package/package.json +1 -1
- package/src/binary-slot.ts +71 -0
- package/src/index.ts +1 -0
- package/src/schema-compat.ts +10 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { KeywordDefinition } from "ajv";
|
|
2
|
+
/**
|
|
3
|
+
* `x-telo-binary: true` — the annotation that gives a byte buffer a declared
|
|
4
|
+
* identity, and the single accessor every surface reads it through (the
|
|
5
|
+
* `ref-slot.ts` precedent).
|
|
6
|
+
*
|
|
7
|
+
* WHY AN ANNOTATION RATHER THAN A TYPE. Bytes are not expressible in JSON
|
|
8
|
+
* Schema's type vocabulary. `type: object` is the closest fit and it is a lie
|
|
9
|
+
* that costs a real check: every arbitrary object satisfies it, so a mistyped
|
|
10
|
+
* `content: { foo: bar }` reaches the controller instead of failing statically.
|
|
11
|
+
* `type: binary` would fix the honesty and break everything else — AJV refuses
|
|
12
|
+
* to compile an unknown type at all (`type must be JSONType or JSONType[]`),
|
|
13
|
+
* with no option to allow it, so the schema would produce no validator; and a
|
|
14
|
+
* published `telo.yaml` would stop being JSON Schema, which is what the hub, the
|
|
15
|
+
* editor and any third-party reader consume. An `x-` keyword is ignored by
|
|
16
|
+
* unaware tooling BY SPECIFICATION, so it degrades to "unconstrained" rather
|
|
17
|
+
* than to "cannot validate this kind at all".
|
|
18
|
+
*
|
|
19
|
+
* ONE RULE, BOTH HALVES. The keyword is implemented as AJV CODEGEN rather than a
|
|
20
|
+
* `validate` function so it inlines into standalone-compiled validators — the
|
|
21
|
+
* kernel compiles and caches those, and a function-valued keyword would not
|
|
22
|
+
* survive serialization. The analyzer registers the identical keyword, and
|
|
23
|
+
* `celPlaceholderForSchema` hands a real `Uint8Array` to a CEL leaf at a binary
|
|
24
|
+
* slot, so static and runtime agree by construction instead of by two rules kept
|
|
25
|
+
* in step. What falls out is the check the annotation exists for: **bytes can
|
|
26
|
+
* never be manifest-authored** — no YAML literal is a `Uint8Array` — so a literal
|
|
27
|
+
* at a binary slot is rejected while a value arriving by reference passes.
|
|
28
|
+
*/
|
|
29
|
+
export declare const X_TELO_BINARY = "x-telo-binary";
|
|
30
|
+
/** True when this schema node declares its value to be raw bytes. */
|
|
31
|
+
export declare function isBinarySlot(schema: unknown): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The AJV keyword. `Uint8Array` is the structural test rather than any richer
|
|
34
|
+
* notion of "binary": it is what every byte producer in the runtime hands over
|
|
35
|
+
* (`Buffer` extends it, so Node buffers pass), and it is the one check that means
|
|
36
|
+
* the same thing in a browser-side analyzer and in the kernel.
|
|
37
|
+
*/
|
|
38
|
+
export declare function binaryKeyword(): KeywordDefinition;
|
|
39
|
+
//# sourceMappingURL=binary-slot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binary-slot.d.ts","sourceRoot":"","sources":["../src/binary-slot.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,KAAK,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAE7C,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAMrD;AAWD;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,iBAAiB,CAajD"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as AjvNS from "ajv";
|
|
2
|
+
/**
|
|
3
|
+
* `x-telo-binary: true` — the annotation that gives a byte buffer a declared
|
|
4
|
+
* identity, and the single accessor every surface reads it through (the
|
|
5
|
+
* `ref-slot.ts` precedent).
|
|
6
|
+
*
|
|
7
|
+
* WHY AN ANNOTATION RATHER THAN A TYPE. Bytes are not expressible in JSON
|
|
8
|
+
* Schema's type vocabulary. `type: object` is the closest fit and it is a lie
|
|
9
|
+
* that costs a real check: every arbitrary object satisfies it, so a mistyped
|
|
10
|
+
* `content: { foo: bar }` reaches the controller instead of failing statically.
|
|
11
|
+
* `type: binary` would fix the honesty and break everything else — AJV refuses
|
|
12
|
+
* to compile an unknown type at all (`type must be JSONType or JSONType[]`),
|
|
13
|
+
* with no option to allow it, so the schema would produce no validator; and a
|
|
14
|
+
* published `telo.yaml` would stop being JSON Schema, which is what the hub, the
|
|
15
|
+
* editor and any third-party reader consume. An `x-` keyword is ignored by
|
|
16
|
+
* unaware tooling BY SPECIFICATION, so it degrades to "unconstrained" rather
|
|
17
|
+
* than to "cannot validate this kind at all".
|
|
18
|
+
*
|
|
19
|
+
* ONE RULE, BOTH HALVES. The keyword is implemented as AJV CODEGEN rather than a
|
|
20
|
+
* `validate` function so it inlines into standalone-compiled validators — the
|
|
21
|
+
* kernel compiles and caches those, and a function-valued keyword would not
|
|
22
|
+
* survive serialization. The analyzer registers the identical keyword, and
|
|
23
|
+
* `celPlaceholderForSchema` hands a real `Uint8Array` to a CEL leaf at a binary
|
|
24
|
+
* slot, so static and runtime agree by construction instead of by two rules kept
|
|
25
|
+
* in step. What falls out is the check the annotation exists for: **bytes can
|
|
26
|
+
* never be manifest-authored** — no YAML literal is a `Uint8Array` — so a literal
|
|
27
|
+
* at a binary slot is rejected while a value arriving by reference passes.
|
|
28
|
+
*/
|
|
29
|
+
export const X_TELO_BINARY = "x-telo-binary";
|
|
30
|
+
/** True when this schema node declares its value to be raw bytes. */
|
|
31
|
+
export function isBinarySlot(schema) {
|
|
32
|
+
return (typeof schema === "object" &&
|
|
33
|
+
schema !== null &&
|
|
34
|
+
schema[X_TELO_BINARY] === true);
|
|
35
|
+
}
|
|
36
|
+
const ajvExports = AjvNS.default ?? AjvNS;
|
|
37
|
+
const codegen = ajvExports._ ?? AjvNS._;
|
|
38
|
+
/**
|
|
39
|
+
* The AJV keyword. `Uint8Array` is the structural test rather than any richer
|
|
40
|
+
* notion of "binary": it is what every byte producer in the runtime hands over
|
|
41
|
+
* (`Buffer` extends it, so Node buffers pass), and it is the one check that means
|
|
42
|
+
* the same thing in a browser-side analyzer and in the kernel.
|
|
43
|
+
*/
|
|
44
|
+
export function binaryKeyword() {
|
|
45
|
+
return {
|
|
46
|
+
keyword: X_TELO_BINARY,
|
|
47
|
+
schemaType: "boolean",
|
|
48
|
+
code(cxt) {
|
|
49
|
+
// `x-telo-binary: false` states nothing, so it constrains nothing.
|
|
50
|
+
if (cxt.schema !== true)
|
|
51
|
+
return;
|
|
52
|
+
cxt.pass(codegen `${cxt.data} instanceof Uint8Array`);
|
|
53
|
+
},
|
|
54
|
+
error: {
|
|
55
|
+
message: "must be raw bytes (a Uint8Array) — bytes cannot be written inline in a manifest",
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export { buildReferenceFieldMap, isRefEntry, isScopeEntry } from "./reference-fi
|
|
|
23
23
|
export type { ReferenceFieldMap, RefFieldEntry } from "./reference-field-map.js";
|
|
24
24
|
export { hasDeclaredUse, isRefSlot, isRefUse, possibleUses, readRefSlot, REF_USES, refSlotAnnotation, rewriteRefSlotKinds, transfersControl, } from "./ref-slot.js";
|
|
25
25
|
export type { RefSlot, RefUse, RefUseCases } from "./ref-slot.js";
|
|
26
|
+
export { binaryKeyword, isBinarySlot, X_TELO_BINARY } from "./binary-slot.js";
|
|
26
27
|
export { hasProvidesZone, hasRequiresZone, readProvidesZone, readRequiresZone, rewriteRequiresZoneKind, } from "./zone-slot.js";
|
|
27
28
|
export type { ProvidesZoneSlot, RequiresZoneSlot } from "./zone-slot.js";
|
|
28
29
|
export { deriveLibraryExportRequirements, projectZoneRequirements, runZoneAnalysis, zoneDocumentsSignature, } from "./resolve-zone-requirements.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjF,YAAY,EACR,cAAc,EACd,UAAU,EACV,UAAU,EACV,WAAW,EACX,YAAY,EACZ,UAAU,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,0BAA0B,EAC1B,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB,EACpB,gCAAgC,EAChC,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,iBAAiB,EACtB,KAAK,YAAY,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,iCAAiC,EACjC,wBAAwB,EACxB,iBAAiB,EACjB,iCAAiC,EACjC,qBAAqB,GACtB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACxF,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACtF,YAAY,EAAE,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iB,EACjB,sBAAsB,EACtB,WAAW,EACX,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,cAAc,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,cAAc,GACf,MAAM,2BAA2B,CAAC;AACnC,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAIvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC1D,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3E,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC3E,YAAY,EACR,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,QAAQ,EACR,aAAa,EACb,KAAK,EACR,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export { hasIntermediateWildcard, parseRedactionPath, RedactionPathError, } from
|
|
|
12
12
|
export { buildCallGraph, projectToPairs, resourceId } from "./call-graph.js";
|
|
13
13
|
export { buildReferenceFieldMap, isRefEntry, isScopeEntry } from "./reference-field-map.js";
|
|
14
14
|
export { hasDeclaredUse, isRefSlot, isRefUse, possibleUses, readRefSlot, REF_USES, refSlotAnnotation, rewriteRefSlotKinds, transfersControl, } from "./ref-slot.js";
|
|
15
|
+
export { binaryKeyword, isBinarySlot, X_TELO_BINARY } from "./binary-slot.js";
|
|
15
16
|
export { hasProvidesZone, hasRequiresZone, readProvidesZone, readRequiresZone, rewriteRequiresZoneKind, } from "./zone-slot.js";
|
|
16
17
|
export { deriveLibraryExportRequirements, projectZoneRequirements, runZoneAnalysis, zoneDocumentsSignature, } from "./resolve-zone-requirements.js";
|
|
17
18
|
export { validateZoneSlotDeclarations } from "./validate-zone-slots.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-compat.d.ts","sourceRoot":"","sources":["../src/schema-compat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema-compat.d.ts","sourceRoot":"","sources":["../src/schema-compat.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,GAAG,KAA0C,CAAC;AAEpD;;;;;;;mCAOmC;AACnC,wBAAgB,SAAS,IAAI,YAAY,CAAC,OAAO,GAAG,CAAC,CAWpD;AAKD,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;oEAEoE;AACpE,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC1B,mBAAmB,CAIrB;AAiDD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAelD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAGxE;AAuBD,mFAAmF;AACnF,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC;CACd;AAaD,0GAA0G;AAC1G,wBAAgB,qBAAqB,CAAC,IA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,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAwBlF;AAED;iGACiG;AACjG,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;AAChC;;;;;;;;6DAQ6D;AAC7D,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EACrC,IAAI,SAAK,GACR,OAAO,CAgDT"}
|
package/dist/schema-compat.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import AjvModule from "ajv";
|
|
2
2
|
import addFormats from "ajv-formats";
|
|
3
3
|
import { isRefSentinel, isTaggedSentinel, ManifestRootSchema, normalizeRefSlots } from "@telorun/templating";
|
|
4
|
+
import { binaryKeyword, isBinarySlot } from "./binary-slot.js";
|
|
4
5
|
const Ajv = AjvModule.default ?? AjvModule;
|
|
5
6
|
/** Creates a configured AJV instance (allErrors, strict: false, with formats).
|
|
6
7
|
* Also registers the kernel manifest root schema under `telo://manifest` so
|
|
@@ -15,6 +16,10 @@ export function createAjv() {
|
|
|
15
16
|
addFormats.default
|
|
16
17
|
? addFormats.default(instance)
|
|
17
18
|
: addFormats(instance);
|
|
19
|
+
// Bytes have no JSON Schema type, so the annotation carries the check. Registered
|
|
20
|
+
// here and in the kernel's validators from one definition, so a literal at a byte
|
|
21
|
+
// slot is rejected statically and at dispatch by the identical rule.
|
|
22
|
+
instance.addKeyword(binaryKeyword());
|
|
18
23
|
instance.addSchema(ManifestRootSchema);
|
|
19
24
|
return instance;
|
|
20
25
|
}
|
|
@@ -352,6 +357,12 @@ function foldedConstraints(schema) {
|
|
|
352
357
|
}
|
|
353
358
|
export function celPlaceholderForSchema(rawSchema) {
|
|
354
359
|
const schema = foldedConstraints(rawSchema);
|
|
360
|
+
// A byte slot's placeholder must BE bytes: the same keyword validates statically
|
|
361
|
+
// and at dispatch, so a CEL leaf standing in for a runtime buffer has to satisfy
|
|
362
|
+
// it. This is what keeps the rule single — a literal is rejected because no YAML
|
|
363
|
+
// literal is a Uint8Array, while a value arriving by reference passes.
|
|
364
|
+
if (isBinarySlot(schema))
|
|
365
|
+
return new Uint8Array();
|
|
355
366
|
if (schema.default !== undefined)
|
|
356
367
|
return schema.default;
|
|
357
368
|
// An enum-constrained field needs a placeholder drawn from the enum: the
|
package/package.json
CHANGED
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -97,6 +97,7 @@ export {
|
|
|
97
97
|
transfersControl,
|
|
98
98
|
} from "./ref-slot.js";
|
|
99
99
|
export type { RefSlot, RefUse, RefUseCases } from "./ref-slot.js";
|
|
100
|
+
export { binaryKeyword, isBinarySlot, X_TELO_BINARY } from "./binary-slot.js";
|
|
100
101
|
export {
|
|
101
102
|
hasProvidesZone,
|
|
102
103
|
hasRequiresZone,
|
package/src/schema-compat.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import AjvModule from "ajv";
|
|
2
2
|
import addFormats from "ajv-formats";
|
|
3
3
|
import { isRefSentinel, isTaggedSentinel, ManifestRootSchema, normalizeRefSlots } from "@telorun/templating";
|
|
4
|
+
import { binaryKeyword, isBinarySlot } from "./binary-slot.js";
|
|
4
5
|
|
|
5
6
|
const Ajv = (AjvModule as any).default ?? AjvModule;
|
|
6
7
|
|
|
@@ -17,6 +18,10 @@ export function createAjv(): InstanceType<typeof Ajv> {
|
|
|
17
18
|
(addFormats as any).default
|
|
18
19
|
? (addFormats as any).default(instance)
|
|
19
20
|
: (addFormats as any)(instance);
|
|
21
|
+
// Bytes have no JSON Schema type, so the annotation carries the check. Registered
|
|
22
|
+
// here and in the kernel's validators from one definition, so a literal at a byte
|
|
23
|
+
// slot is rejected statically and at dispatch by the identical rule.
|
|
24
|
+
instance.addKeyword(binaryKeyword());
|
|
20
25
|
instance.addSchema(ManifestRootSchema);
|
|
21
26
|
return instance;
|
|
22
27
|
}
|
|
@@ -371,6 +376,11 @@ function foldedConstraints(schema: Record<string, any>): Record<string, any> {
|
|
|
371
376
|
|
|
372
377
|
export function celPlaceholderForSchema(rawSchema: Record<string, any>): unknown {
|
|
373
378
|
const schema = foldedConstraints(rawSchema);
|
|
379
|
+
// A byte slot's placeholder must BE bytes: the same keyword validates statically
|
|
380
|
+
// and at dispatch, so a CEL leaf standing in for a runtime buffer has to satisfy
|
|
381
|
+
// it. This is what keeps the rule single — a literal is rejected because no YAML
|
|
382
|
+
// literal is a Uint8Array, while a value arriving by reference passes.
|
|
383
|
+
if (isBinarySlot(schema)) return new Uint8Array();
|
|
374
384
|
if (schema.default !== undefined) return schema.default;
|
|
375
385
|
// An enum-constrained field needs a placeholder drawn from the enum: the
|
|
376
386
|
// type-based fallbacks below ("" for a string, 0 for a number) satisfy `type`
|