@telorun/analyzer 0.6.1 → 0.7.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/README.md CHANGED
@@ -42,8 +42,6 @@ $ telo ./examples/hello-api.yaml
42
42
  - **Indexes** resources by Kind and Name for constant-time lookup.
43
43
  - **Dispatches** execution to the controller that owns each Kind.
44
44
 
45
- Manifests also support directives for dynamic generation: `$let`, `$if`, `$for`, `$eval`, and `$include`. See [CEL-YAML Templating](./yaml-cel-templating/README.md) for documentation.
46
-
47
45
  ## Example manifest
48
46
 
49
47
  Here is an example Telo application that defines a simple HTTP API:
@@ -236,7 +234,6 @@ Those manifests were taken to the next level by allowing them to run inside a st
236
234
  ## See more at
237
235
 
238
236
  - [Telo Kernel](./kernel/README.md)
239
- - [CEL-YAML Templating](./yaml-cel-templating/README.md)
240
237
  - [Telo SDK for module authors](sdk/README.md)
241
238
  - [Modules](modules/README.md)
242
239
 
@@ -2,6 +2,7 @@ import { Environment } from "@marcbachmann/cel-js";
2
2
  import { type ResourceManifest } from "@telorun/sdk";
3
3
  export interface CelHandlers {
4
4
  sha256: (s: string) => string;
5
+ json: (value: unknown) => string;
5
6
  }
6
7
  /** Build a CEL `Environment` with Telo's stdlib of functions. Always registers the
7
8
  * same function signatures (so `env.check()` succeeds for type-inference) — the
@@ -1 +1 @@
1
- {"version":3,"file":"cel-environment.d.ts","sourceRoot":"","sources":["../src/cel-environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAU,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAG7D,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CAC/B;AAaD;;;;;;;;;;;;yDAYyD;AACzD,wBAAgB,mBAAmB,CAAC,QAAQ,GAAE,WAA2B,GAAG,WAAW,CAetF;AAED;;;;;;;;;uEASuE;AACvE,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,gBAAgB,EAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAC9C,WAAW,CAyCb"}
1
+ {"version":3,"file":"cel-environment.d.ts","sourceRoot":"","sources":["../src/cel-environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAU,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAG7D,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9B,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC;CAClC;AAcD;;;;;;;;;;;;yDAYyD;AACzD,wBAAgB,mBAAmB,CAAC,QAAQ,GAAE,WAA2B,GAAG,WAAW,CAgBtF;AAED;;;;;;;;;uEASuE;AACvE,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,gBAAgB,EAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAC9C,WAAW,CAyCb"}
@@ -7,6 +7,7 @@ const stub = (name) => () => {
7
7
  };
8
8
  const STUB_HANDLERS = {
9
9
  sha256: stub("sha256"),
10
+ json: stub("json"),
10
11
  };
11
12
  /** Build a CEL `Environment` with Telo's stdlib of functions. Always registers the
12
13
  * same function signatures (so `env.check()` succeeds for type-inference) — the
@@ -22,7 +23,7 @@ const STUB_HANDLERS = {
22
23
  * member access raises a CEL error at runtime — matching the analyzer's
23
24
  * static check on `x-telo-stream`-marked properties. */
24
25
  export function buildCelEnvironment(handlers = STUB_HANDLERS) {
25
- return new Environment({ unlistedVariablesAreDyn: true })
26
+ return new Environment({ unlistedVariablesAreDyn: true, enableOptionalTypes: true })
26
27
  .registerFunction("join(list, string): string", (list, sep) => list.map(String).join(sep))
27
28
  .registerFunction("keys(map): list", (map) => {
28
29
  if (map instanceof Map)
@@ -35,6 +36,7 @@ export function buildCelEnvironment(handlers = STUB_HANDLERS) {
35
36
  return Object.values(map);
36
37
  })
37
38
  .registerFunction("sha256(string): string", (s) => handlers.sha256(s))
39
+ .registerFunction("json(dyn): string", (value) => handlers.json(value))
38
40
  .registerType("Stream", Stream);
39
41
  }
40
42
  /** Clone `baseEnv` and register typed variable declarations so that
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telorun/analyzer",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Telo Analyzer - Static manifest validator for Telo manifests.",
5
5
  "keywords": [
6
6
  "telo",
@@ -4,6 +4,7 @@ import { jsonSchemaToCelType } from "./schema-compat.js";
4
4
 
5
5
  export interface CelHandlers {
6
6
  sha256: (s: string) => string;
7
+ json: (value: unknown) => string;
7
8
  }
8
9
 
9
10
  const stub = (name: string) => () => {
@@ -15,6 +16,7 @@ const stub = (name: string) => () => {
15
16
 
16
17
  const STUB_HANDLERS: CelHandlers = {
17
18
  sha256: stub("sha256"),
19
+ json: stub("json"),
18
20
  };
19
21
 
20
22
  /** Build a CEL `Environment` with Telo's stdlib of functions. Always registers the
@@ -31,7 +33,7 @@ const STUB_HANDLERS: CelHandlers = {
31
33
  * member access raises a CEL error at runtime — matching the analyzer's
32
34
  * static check on `x-telo-stream`-marked properties. */
33
35
  export function buildCelEnvironment(handlers: CelHandlers = STUB_HANDLERS): Environment {
34
- return new Environment({ unlistedVariablesAreDyn: true })
36
+ return new Environment({ unlistedVariablesAreDyn: true, enableOptionalTypes: true })
35
37
  .registerFunction("join(list, string): string", (list: unknown[], sep: string) =>
36
38
  list.map(String).join(sep),
37
39
  )
@@ -44,6 +46,7 @@ export function buildCelEnvironment(handlers: CelHandlers = STUB_HANDLERS): Envi
44
46
  return Object.values(map as Record<string, unknown>);
45
47
  })
46
48
  .registerFunction("sha256(string): string", (s: string) => handlers.sha256(s))
49
+ .registerFunction("json(dyn): string", (value: unknown) => handlers.json(value))
47
50
  .registerType("Stream", Stream as unknown as new (...args: unknown[]) => unknown);
48
51
  }
49
52