@telorun/templating 0.5.0 → 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
@@ -55,8 +55,8 @@ metadata:
55
55
  A complete feedback collection REST API — no code, pure YAML.
56
56
  Persists entries to SQLite and serves them over HTTP.
57
57
  imports:
58
- Http: std/http-server@0.8.0
59
- Sql: std/sql@0.5.1
58
+ Http: std/http-server@0.9.0
59
+ Sql: std/sql@0.8.0
60
60
  targets:
61
61
  - Migrations
62
62
  - Server
@@ -0,0 +1,47 @@
1
+ /** Host-injected functions that need platform APIs the templating package must
2
+ * not import directly (Node `crypto` / `Buffer`), keeping it browser-safe. The
3
+ * kernel supplies real implementations; the analyzer omits them (the stubs
4
+ * throw, since static analysis never executes these). */
5
+ export interface CelHandlers {
6
+ sha256: (s: string) => string;
7
+ md5: (s: string) => string;
8
+ sha1: (s: string) => string;
9
+ sha512: (s: string) => string;
10
+ hmac: (algorithm: string, key: string, message: string) => string;
11
+ base64Encode: (s: string) => string;
12
+ base64Decode: (s: string) => string;
13
+ json: (value: unknown) => string;
14
+ }
15
+ export type CelFunctionCategory = "conversion" | "time" | "uuid" | "string" | "math" | "collection" | "json" | "encoding" | "hashing" | "null";
16
+ /** One entry in the CEL standard library — the single source of truth that both
17
+ * registers the function (`build`) and documents it (everything else). `telo
18
+ * cel functions` and `celFunctionCatalog()` read the metadata; `buildCelEnvironment`
19
+ * calls `build`. */
20
+ export interface CelFunctionDoc {
21
+ /** Bare function name (`nowIso`, `uuidv4`). */
22
+ readonly name: string;
23
+ /** Human-facing signature for docs (`nowIso(tz?): string`). May use `?` for
24
+ * optional args even though cel-js itself has no optional syntax. */
25
+ readonly signature: string;
26
+ /** Actual cel-js signatures to register — one per arity for an overloaded
27
+ * function. When omitted, `deriveSignatures(signature)` is used: if the
28
+ * signature contains `type?`-marked optional params (e.g. `fn(string?): T`),
29
+ * it auto-expands to one registration per arity. Set `register` explicitly
30
+ * only when the auto-derivation is insufficient. */
31
+ readonly register?: readonly string[];
32
+ readonly category: CelFunctionCategory;
33
+ readonly summary: string;
34
+ /** False → re-evaluates per call; in an `x-telo-eval: compile` field it bakes
35
+ * once at load. */
36
+ readonly deterministic: boolean;
37
+ /** Needs a `CelHandlers` implementation (Node `crypto` / `Buffer`); the
38
+ * analyzer's stub throws if such a function is actually evaluated. */
39
+ readonly hostBacked: boolean;
40
+ readonly build: (h: CelHandlers) => (...args: any[]) => unknown;
41
+ }
42
+ /** Public, build-free view of a catalog entry (for `--json` / docs). */
43
+ export type CelFunctionInfo = Omit<CelFunctionDoc, "build">;
44
+ export declare const CEL_FUNCTIONS: readonly CelFunctionDoc[];
45
+ /** Build-free catalog for the CLI / docs (`telo cel functions`). */
46
+ export declare function celFunctionCatalog(): CelFunctionInfo[];
47
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/cel/catalog.ts"],"names":[],"mappings":"AAEA;;;0DAG0D;AAC1D,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9B,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3B,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5B,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9B,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;IAClE,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC;CAClC;AAED,MAAM,MAAM,mBAAmB,GAC3B,YAAY,GACZ,MAAM,GACN,MAAM,GACN,QAAQ,GACR,MAAM,GACN,YAAY,GACZ,MAAM,GACN,UAAU,GACV,SAAS,GACT,MAAM,CAAC;AAEX;;;qBAGqB;AACrB,MAAM,WAAW,cAAc;IAC7B,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;0EACsE;IACtE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;;yDAIqD;IACrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;wBACoB;IACpB,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC;2EACuE;IACvE,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC;CACjE;AAED,wEAAwE;AACxE,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;AAyE5D,eAAO,MAAM,aAAa,EAAE,SAAS,cAAc,EAoZlD,CAAC;AAEF,oEAAoE;AACpE,wBAAgB,kBAAkB,IAAI,eAAe,EAAE,CAEtD"}
@@ -0,0 +1,473 @@
1
+ import { v1, v3, v4, v5, v6, v7, validate as uuidValidate, version as uuidVersion } from "uuid";
2
+ const num = (x) => Number(x);
3
+ const minMax = (list, isMin) => {
4
+ if (!Array.isArray(list) || list.length === 0)
5
+ return null;
6
+ let best = list[0];
7
+ let bestN = num(best);
8
+ for (const x of list) {
9
+ const n = num(x);
10
+ if (isMin ? n < bestN : n > bestN) {
11
+ best = x;
12
+ bestN = n;
13
+ }
14
+ }
15
+ return best;
16
+ };
17
+ const sortList = (list) => [...list].sort((a, b) => {
18
+ if (typeof a === "number" || typeof a === "bigint") {
19
+ const d = num(a) - num(b);
20
+ return d < 0 ? -1 : d > 0 ? 1 : 0;
21
+ }
22
+ return String(a) < String(b) ? -1 : String(a) > String(b) ? 1 : 0;
23
+ });
24
+ /** `Intl.DateTimeFormat` is an ECMA-402 global in Node (full ICU) and browsers,
25
+ * so timezone handling needs no Node-only API and stays browser-safe. */
26
+ const zoneParts = (date, tz, opts) => {
27
+ const parts = {};
28
+ for (const p of new Intl.DateTimeFormat("en-US", { timeZone: tz, ...opts }).formatToParts(date)) {
29
+ parts[p.type] = p.value;
30
+ }
31
+ return parts;
32
+ };
33
+ /** Current instant as ISO-8601 in `tz`: UTC `…Z` for "UTC", else the zone's
34
+ * offset (e.g. `2026-06-06T18:30:00.000-05:00`). Uses only standard Intl
35
+ * fields and derives the offset arithmetically, so it needs no newer Intl
36
+ * type-lib features and stays portable. */
37
+ const isoInZone = (tz) => {
38
+ const now = new Date();
39
+ if (tz === "UTC" || tz === "Z")
40
+ return now.toISOString();
41
+ const p = zoneParts(now, tz, {
42
+ hourCycle: "h23",
43
+ year: "numeric",
44
+ month: "2-digit",
45
+ day: "2-digit",
46
+ hour: "2-digit",
47
+ minute: "2-digit",
48
+ second: "2-digit",
49
+ });
50
+ // Sub-second is timezone-independent; read it off the instant directly.
51
+ const ms = String(now.getUTCMilliseconds()).padStart(3, "0");
52
+ // Offset = the zone's wall-clock read as UTC, minus the real instant.
53
+ const asUtc = Date.UTC(+p.year, +p.month - 1, +p.day, +p.hour, +p.minute, +p.second);
54
+ const offsetMin = Math.round((asUtc - now.getTime()) / 60000);
55
+ const offset = offsetMin === 0
56
+ ? "Z"
57
+ : `${offsetMin > 0 ? "+" : "-"}${String(Math.floor(Math.abs(offsetMin) / 60)).padStart(2, "0")}:${String(Math.abs(offsetMin) % 60).padStart(2, "0")}`;
58
+ return `${p.year}-${p.month}-${p.day}T${p.hour}:${p.minute}:${p.second}.${ms}${offset}`;
59
+ };
60
+ /** Current calendar date (`YYYY-MM-DD`) in `tz`. */
61
+ const dateInZone = (tz) => {
62
+ const now = new Date();
63
+ if (tz === "UTC" || tz === "Z")
64
+ return now.toISOString().slice(0, 10);
65
+ const p = zoneParts(now, tz, { year: "numeric", month: "2-digit", day: "2-digit" });
66
+ return `${p.year}-${p.month}-${p.day}`;
67
+ };
68
+ export const CEL_FUNCTIONS = [
69
+ // Collections
70
+ {
71
+ name: "join",
72
+ signature: "join(list, string): string",
73
+ category: "collection",
74
+ summary: "Join list elements into a string with a separator.",
75
+ deterministic: true,
76
+ hostBacked: false,
77
+ build: () => (list, sep) => list.map(String).join(sep),
78
+ },
79
+ {
80
+ name: "keys",
81
+ signature: "keys(map): list",
82
+ category: "collection",
83
+ summary: "List a map's keys.",
84
+ deterministic: true,
85
+ hostBacked: false,
86
+ build: () => (map) => map instanceof Map ? [...map.keys()] : Object.keys(map),
87
+ },
88
+ {
89
+ name: "values",
90
+ signature: "values(map): list",
91
+ category: "collection",
92
+ summary: "List a map's values.",
93
+ deterministic: true,
94
+ hostBacked: false,
95
+ build: () => (map) => map instanceof Map ? [...map.values()] : Object.values(map),
96
+ },
97
+ {
98
+ name: "distinct",
99
+ signature: "distinct(list): list",
100
+ category: "collection",
101
+ summary: "Remove duplicate elements, preserving order.",
102
+ deterministic: true,
103
+ hostBacked: false,
104
+ build: () => (list) => [...new Set(list)],
105
+ },
106
+ {
107
+ name: "reverse",
108
+ signature: "reverse(list): list",
109
+ category: "collection",
110
+ summary: "Reverse a list (copy; never mutates the input).",
111
+ deterministic: true,
112
+ hostBacked: false,
113
+ build: () => (list) => [...list].reverse(),
114
+ },
115
+ {
116
+ name: "flatten",
117
+ signature: "flatten(list): list",
118
+ category: "collection",
119
+ summary: "Flatten one level of nested lists.",
120
+ deterministic: true,
121
+ hostBacked: false,
122
+ build: () => (list) => list.flat(),
123
+ },
124
+ {
125
+ name: "sort",
126
+ signature: "sort(list): list",
127
+ category: "collection",
128
+ summary: "Sort a list numerically (numbers) or lexicographically; copy.",
129
+ deterministic: true,
130
+ hostBacked: false,
131
+ build: () => (list) => sortList(list),
132
+ },
133
+ // Strings
134
+ {
135
+ name: "lower",
136
+ signature: "lower(string): string",
137
+ category: "string",
138
+ summary: "Lowercase a string.",
139
+ deterministic: true,
140
+ hostBacked: false,
141
+ build: () => (s) => s.toLowerCase(),
142
+ },
143
+ {
144
+ name: "upper",
145
+ signature: "upper(string): string",
146
+ category: "string",
147
+ summary: "Uppercase a string.",
148
+ deterministic: true,
149
+ hostBacked: false,
150
+ build: () => (s) => s.toUpperCase(),
151
+ },
152
+ {
153
+ name: "trim",
154
+ signature: "trim(string): string",
155
+ category: "string",
156
+ summary: "Strip leading/trailing whitespace.",
157
+ deterministic: true,
158
+ hostBacked: false,
159
+ build: () => (s) => s.trim(),
160
+ },
161
+ {
162
+ name: "replace",
163
+ signature: "replace(string, string, string): string",
164
+ category: "string",
165
+ summary: "Replace all occurrences of a substring.",
166
+ deterministic: true,
167
+ hostBacked: false,
168
+ build: () => (s, a, b) => s.split(a).join(b),
169
+ },
170
+ {
171
+ name: "split",
172
+ signature: "split(string, string): list",
173
+ category: "string",
174
+ summary: "Split a string on a separator into a list.",
175
+ deterministic: true,
176
+ hostBacked: false,
177
+ build: () => (s, sep) => s.split(sep),
178
+ },
179
+ // Math
180
+ {
181
+ name: "abs",
182
+ signature: "abs(dyn): double",
183
+ category: "math",
184
+ summary: "Absolute value.",
185
+ deterministic: true,
186
+ hostBacked: false,
187
+ build: () => (x) => Math.abs(num(x)),
188
+ },
189
+ {
190
+ name: "floor",
191
+ signature: "floor(dyn): double",
192
+ category: "math",
193
+ summary: "Round down to an integer.",
194
+ deterministic: true,
195
+ hostBacked: false,
196
+ build: () => (x) => Math.floor(num(x)),
197
+ },
198
+ {
199
+ name: "ceil",
200
+ signature: "ceil(dyn): double",
201
+ category: "math",
202
+ summary: "Round up to an integer.",
203
+ deterministic: true,
204
+ hostBacked: false,
205
+ build: () => (x) => Math.ceil(num(x)),
206
+ },
207
+ {
208
+ name: "round",
209
+ signature: "round(dyn): double",
210
+ category: "math",
211
+ summary: "Round to the nearest integer.",
212
+ deterministic: true,
213
+ hostBacked: false,
214
+ build: () => (x) => Math.round(num(x)),
215
+ },
216
+ {
217
+ name: "min",
218
+ signature: "min(list): dyn",
219
+ category: "math",
220
+ summary: "Smallest element (by numeric value); null for an empty list.",
221
+ deterministic: true,
222
+ hostBacked: false,
223
+ build: () => (list) => minMax(list, true),
224
+ },
225
+ {
226
+ name: "max",
227
+ signature: "max(list): dyn",
228
+ category: "math",
229
+ summary: "Largest element (by numeric value); null for an empty list.",
230
+ deterministic: true,
231
+ hostBacked: false,
232
+ build: () => (list) => minMax(list, false),
233
+ },
234
+ // JSON
235
+ {
236
+ name: "json",
237
+ signature: "json(dyn): string",
238
+ category: "json",
239
+ summary: "Serialize any value to a JSON string.",
240
+ deterministic: true,
241
+ hostBacked: true,
242
+ build: (h) => (value) => h.json(value),
243
+ },
244
+ {
245
+ name: "parseJson",
246
+ signature: "parseJson(string): dyn",
247
+ category: "json",
248
+ summary: "Parse a JSON string into a value (numbers come back as doubles).",
249
+ deterministic: true,
250
+ hostBacked: false,
251
+ build: () => (s) => JSON.parse(s),
252
+ },
253
+ // Encoding
254
+ {
255
+ name: "base64Encode",
256
+ signature: "base64Encode(string): string",
257
+ category: "encoding",
258
+ summary: "Encode a UTF-8 string as base64.",
259
+ deterministic: true,
260
+ hostBacked: true,
261
+ build: (h) => (s) => h.base64Encode(s),
262
+ },
263
+ {
264
+ name: "base64Decode",
265
+ signature: "base64Decode(string): string",
266
+ category: "encoding",
267
+ summary: "Decode a base64 string to UTF-8.",
268
+ deterministic: true,
269
+ hostBacked: true,
270
+ build: (h) => (s) => h.base64Decode(s),
271
+ },
272
+ {
273
+ name: "urlEncode",
274
+ signature: "urlEncode(string): string",
275
+ category: "encoding",
276
+ summary: "Percent-encode a URI component.",
277
+ deterministic: true,
278
+ hostBacked: false,
279
+ build: () => (s) => encodeURIComponent(s),
280
+ },
281
+ {
282
+ name: "urlDecode",
283
+ signature: "urlDecode(string): string",
284
+ category: "encoding",
285
+ summary: "Decode a percent-encoded URI component.",
286
+ deterministic: true,
287
+ hostBacked: false,
288
+ build: () => (s) => decodeURIComponent(s),
289
+ },
290
+ // Hashing
291
+ {
292
+ name: "sha256",
293
+ signature: "sha256(string): string",
294
+ category: "hashing",
295
+ summary: "SHA-256 hash, hex-encoded.",
296
+ deterministic: true,
297
+ hostBacked: true,
298
+ build: (h) => (s) => h.sha256(s),
299
+ },
300
+ {
301
+ name: "md5",
302
+ signature: "md5(string): string",
303
+ category: "hashing",
304
+ summary: "MD5 hash, hex-encoded.",
305
+ deterministic: true,
306
+ hostBacked: true,
307
+ build: (h) => (s) => h.md5(s),
308
+ },
309
+ {
310
+ name: "sha1",
311
+ signature: "sha1(string): string",
312
+ category: "hashing",
313
+ summary: "SHA-1 hash, hex-encoded.",
314
+ deterministic: true,
315
+ hostBacked: true,
316
+ build: (h) => (s) => h.sha1(s),
317
+ },
318
+ {
319
+ name: "sha512",
320
+ signature: "sha512(string): string",
321
+ category: "hashing",
322
+ summary: "SHA-512 hash, hex-encoded.",
323
+ deterministic: true,
324
+ hostBacked: true,
325
+ build: (h) => (s) => h.sha512(s),
326
+ },
327
+ {
328
+ name: "hmac",
329
+ signature: "hmac(string, string, string): string",
330
+ category: "hashing",
331
+ summary: "HMAC of message under key for an algorithm (e.g. 'sha256'), hex.",
332
+ deterministic: true,
333
+ hostBacked: true,
334
+ build: (h) => (algo, key, msg) => h.hmac(algo, key, msg),
335
+ },
336
+ // Null handling
337
+ {
338
+ name: "default",
339
+ signature: "default(dyn, dyn): dyn",
340
+ category: "null",
341
+ summary: "Return the value, or the fallback when it is null.",
342
+ deterministic: true,
343
+ hostBacked: false,
344
+ build: () => (v, fallback) => v === null || v === undefined ? fallback : v,
345
+ },
346
+ {
347
+ name: "coalesce",
348
+ signature: "coalesce(list): dyn",
349
+ category: "null",
350
+ summary: "First non-null element of a list, or null.",
351
+ deterministic: true,
352
+ hostBacked: false,
353
+ build: () => (list) => {
354
+ const found = list.find((x) => x !== null && x !== undefined);
355
+ return found === undefined ? null : found;
356
+ },
357
+ },
358
+ // Time (non-deterministic). `nowIso`/`today` take an optional IANA timezone
359
+ // (default "UTC"); epoch values are absolute and take none.
360
+ {
361
+ name: "nowIso",
362
+ signature: "nowIso(string?): string",
363
+ category: "time",
364
+ summary: "Current time as ISO-8601; UTC by default, or in the given IANA timezone.",
365
+ deterministic: false,
366
+ hostBacked: false,
367
+ build: () => (tz) => isoInZone(tz ?? "UTC"),
368
+ },
369
+ {
370
+ name: "today",
371
+ signature: "today(string?): string",
372
+ category: "time",
373
+ summary: "Current calendar date (YYYY-MM-DD); UTC by default, or in the given IANA timezone.",
374
+ deterministic: false,
375
+ hostBacked: false,
376
+ build: () => (tz) => dateInZone(tz ?? "UTC"),
377
+ },
378
+ {
379
+ name: "nowMillis",
380
+ signature: "nowMillis(): int",
381
+ category: "time",
382
+ summary: "Current time as epoch milliseconds (absolute; timezone-independent).",
383
+ deterministic: false,
384
+ hostBacked: false,
385
+ build: () => () => BigInt(Date.now()),
386
+ },
387
+ {
388
+ name: "nowSeconds",
389
+ signature: "nowSeconds(): int",
390
+ category: "time",
391
+ summary: "Current time as epoch seconds (absolute; timezone-independent).",
392
+ deterministic: false,
393
+ hostBacked: false,
394
+ build: () => () => BigInt(Math.floor(Date.now() / 1000)),
395
+ },
396
+ // UUID
397
+ {
398
+ name: "uuidv1",
399
+ signature: "uuidv1(): string",
400
+ category: "uuid",
401
+ summary: "Time-based UUID (v1).",
402
+ deterministic: false,
403
+ hostBacked: false,
404
+ build: () => () => v1(),
405
+ },
406
+ {
407
+ name: "uuidv4",
408
+ signature: "uuidv4(): string",
409
+ category: "uuid",
410
+ summary: "Random UUID (v4).",
411
+ deterministic: false,
412
+ hostBacked: false,
413
+ build: () => () => v4(),
414
+ },
415
+ {
416
+ name: "uuidv6",
417
+ signature: "uuidv6(): string",
418
+ category: "uuid",
419
+ summary: "Time-ordered UUID (v6).",
420
+ deterministic: false,
421
+ hostBacked: false,
422
+ build: () => () => v6(),
423
+ },
424
+ {
425
+ name: "uuidv7",
426
+ signature: "uuidv7(): string",
427
+ category: "uuid",
428
+ summary: "Time-ordered UUID (v7).",
429
+ deterministic: false,
430
+ hostBacked: false,
431
+ build: () => () => v7(),
432
+ },
433
+ {
434
+ name: "uuidv3",
435
+ signature: "uuidv3(string, string): string",
436
+ category: "uuid",
437
+ summary: "Name-based UUID (v3, MD5) under a namespace UUID.",
438
+ deterministic: true,
439
+ hostBacked: false,
440
+ build: () => (name, ns) => v3(name, ns),
441
+ },
442
+ {
443
+ name: "uuidv5",
444
+ signature: "uuidv5(string, string): string",
445
+ category: "uuid",
446
+ summary: "Name-based UUID (v5, SHA-1) under a namespace UUID.",
447
+ deterministic: true,
448
+ hostBacked: false,
449
+ build: () => (name, ns) => v5(name, ns),
450
+ },
451
+ {
452
+ name: "uuidValidate",
453
+ signature: "uuidValidate(string): bool",
454
+ category: "uuid",
455
+ summary: "True if the string is a valid UUID.",
456
+ deterministic: true,
457
+ hostBacked: false,
458
+ build: () => (s) => uuidValidate(s),
459
+ },
460
+ {
461
+ name: "uuidVersion",
462
+ signature: "uuidVersion(string): int",
463
+ category: "uuid",
464
+ summary: "The version number of a UUID.",
465
+ deterministic: true,
466
+ hostBacked: false,
467
+ build: () => (s) => BigInt(uuidVersion(s)),
468
+ },
469
+ ];
470
+ /** Build-free catalog for the CLI / docs (`telo cel functions`). */
471
+ export function celFunctionCatalog() {
472
+ return CEL_FUNCTIONS.map(({ build: _build, ...info }) => info);
473
+ }
@@ -1,12 +1,13 @@
1
1
  import { Environment } from "@marcbachmann/cel-js";
2
- export interface CelHandlers {
3
- sha256: (s: string) => string;
4
- json: (value: unknown) => string;
5
- }
6
- /** Build a CEL `Environment` with Telo's stdlib of functions. Always registers the
7
- * same function signatures (so `env.check()` succeeds for type-inference) the
8
- * handlers govern what the function does when called at runtime. Analyzer-only
9
- * callers can omit handlers; runtime callers (kernel) must supply real ones.
2
+ import { type CelHandlers } from "./catalog.js";
3
+ export type { CelHandlers } from "./catalog.js";
4
+ /** Build a CEL `Environment` with Telo's stdlib. Every function comes from the
5
+ * single-source catalog (`CEL_FUNCTIONS`), so registration and the documented
6
+ * surface (`telo cel functions`) can never drift. Always registers the same
7
+ * signatures (so `env.check()` succeeds for type-inference); the host-injected
8
+ * handlers govern what `hostBacked` functions do at runtime. Analyzer-only
9
+ * callers can omit handlers (the stubs throw if such a function is evaluated);
10
+ * runtime callers (kernel) supply real ones.
10
11
  *
11
12
  * Also registers the `Stream` object type, backed by the `Stream` class from
12
13
  * `@telorun/sdk`. CEL's type-checker rejects values whose constructor isn't
@@ -16,5 +17,12 @@ export interface CelHandlers {
16
17
  * no fields, so terminal access (passing the value through CEL) succeeds but
17
18
  * member access raises a CEL error at runtime — matching the analyzer's
18
19
  * static check on `x-telo-stream`-marked properties. */
19
- export declare function buildCelEnvironment(handlers?: CelHandlers): Environment;
20
+ /** Expand a documented signature that may contain `type?`-marked optional
21
+ * parameters into one cel-js registration signature per arity. For example,
22
+ * `"nowIso(string?): string"` produces `["nowIso(): string",
23
+ * "nowIso(string): string"]`. Required parameters must precede optional ones.
24
+ * Returns `[signature]` unchanged when no `?` is present or the signature
25
+ * cannot be parsed. */
26
+ export declare function deriveSignatures(signature: string): string[];
27
+ export declare function buildCelEnvironment(handlers?: Partial<CelHandlers>): Environment;
20
28
  //# sourceMappingURL=environment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/cel/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,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"}
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/cel/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE/D,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAoBhD;;;;;;;;;;;;;;;yDAeyD;AACzD;;;;;wBAKwB;AACxB,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAyB5D;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,WAAW,CAcpF"}