@telorun/cel 0.107.0 → 0.109.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 (78) hide show
  1. package/dist/backend-runtime.d.ts +46 -8
  2. package/dist/backend-runtime.d.ts.map +1 -1
  3. package/dist/backend-runtime.js +133 -30
  4. package/dist/catalog-runtime.d.ts.map +1 -1
  5. package/dist/catalog-runtime.js +110 -109
  6. package/dist/cel-map-value.d.ts +20 -7
  7. package/dist/cel-map-value.d.ts.map +1 -1
  8. package/dist/cel-map-value.js +29 -18
  9. package/dist/cel-value.d.ts +10 -3
  10. package/dist/cel-value.d.ts.map +1 -1
  11. package/dist/check-diagnostic.d.ts +3 -2
  12. package/dist/check-diagnostic.d.ts.map +1 -1
  13. package/dist/checker.d.ts +9 -0
  14. package/dist/checker.d.ts.map +1 -1
  15. package/dist/checker.js +98 -13
  16. package/dist/closure-backend.js +66 -15
  17. package/dist/duration-value.d.ts +11 -0
  18. package/dist/duration-value.d.ts.map +1 -1
  19. package/dist/duration-value.js +17 -3
  20. package/dist/emitted-module.d.ts +1 -1
  21. package/dist/emitted-module.js +1 -1
  22. package/dist/engine-version.d.ts +1 -1
  23. package/dist/engine-version.js +1 -1
  24. package/dist/environment.d.ts +8 -0
  25. package/dist/environment.d.ts.map +1 -1
  26. package/dist/environment.js +20 -5
  27. package/dist/function-registry.d.ts +40 -0
  28. package/dist/function-registry.d.ts.map +1 -1
  29. package/dist/function-registry.js +105 -2
  30. package/dist/index.d.ts +10 -8
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +12 -6
  33. package/dist/js-emitter.d.ts +3 -2
  34. package/dist/js-emitter.d.ts.map +1 -1
  35. package/dist/js-emitter.js +11 -5
  36. package/dist/macro-check.d.ts +8 -0
  37. package/dist/macro-check.d.ts.map +1 -1
  38. package/dist/macro-check.js +1 -1
  39. package/dist/member-read.d.ts +42 -5
  40. package/dist/member-read.d.ts.map +1 -1
  41. package/dist/member-read.js +47 -6
  42. package/dist/resolved-call.d.ts +13 -0
  43. package/dist/resolved-call.d.ts.map +1 -1
  44. package/dist/runtime-library.d.ts +13 -2
  45. package/dist/runtime-library.d.ts.map +1 -1
  46. package/dist/runtime-library.js +134 -125
  47. package/dist/serializer.d.ts.map +1 -1
  48. package/dist/serializer.js +20 -4
  49. package/dist/timestamp-value.d.ts +9 -0
  50. package/dist/timestamp-value.d.ts.map +1 -1
  51. package/dist/timestamp-value.js +15 -0
  52. package/dist/type-expression.d.ts +18 -2
  53. package/dist/type-expression.d.ts.map +1 -1
  54. package/dist/type-expression.js +23 -3
  55. package/dist/value-equality.d.ts.map +1 -1
  56. package/package.json +1 -1
  57. package/src/backend-runtime.ts +180 -30
  58. package/src/catalog-runtime.ts +133 -133
  59. package/src/cel-map-value.ts +31 -20
  60. package/src/cel-value.ts +11 -3
  61. package/src/check-diagnostic.ts +4 -2
  62. package/src/checker.ts +123 -10
  63. package/src/closure-backend.ts +59 -14
  64. package/src/duration-value.ts +18 -3
  65. package/src/emitted-module.ts +1 -1
  66. package/src/engine-version.ts +1 -1
  67. package/src/environment.ts +26 -5
  68. package/src/function-registry.ts +114 -2
  69. package/src/index.ts +24 -3
  70. package/src/js-emitter.ts +13 -5
  71. package/src/macro-check.ts +7 -1
  72. package/src/member-read.ts +48 -7
  73. package/src/resolved-call.ts +13 -0
  74. package/src/runtime-library.ts +167 -143
  75. package/src/serializer.ts +19 -3
  76. package/src/timestamp-value.ts +16 -0
  77. package/src/type-expression.ts +25 -3
  78. package/src/value-equality.ts +3 -3
@@ -50,9 +50,9 @@ class CatalogRefusal extends Error {
50
50
  }
51
51
  /** The one place a refusal becomes a value. Anything else thrown is a defect here. */
52
52
  function refusing(run) {
53
- return (args, ctx) => {
53
+ return (ctx, a, b, c, d) => {
54
54
  try {
55
- return run(args, ctx);
55
+ return run(ctx, a, b, c, d);
56
56
  }
57
57
  catch (cause) {
58
58
  if (cause instanceof CatalogRefusal)
@@ -71,11 +71,13 @@ const own = (run) => () => refusing(run);
71
71
  const hosted = (name, build) => (handlers) => {
72
72
  const handler = handlers[name];
73
73
  if (handler === undefined) {
74
- return (_args, ctx) => celError("unbound_function", `${name}() is supplied by the host, and this environment was given no implementation for it`, ctx.range);
74
+ return (ctx) => celError("unbound_function", `${name}() is supplied by the host, and this environment was given no implementation for it`, ctx.range);
75
75
  }
76
76
  return refusing(build(handler));
77
77
  };
78
78
  // --- reading arguments ------------------------------------------------------
79
+ // `CelValue | undefined` because a parameter list is as wide as the widest overload; the
80
+ // dispatcher has already resolved on this argument's type.
79
81
  const text = (value) => value;
80
82
  const bytes = (value) => value;
81
83
  /**
@@ -467,174 +469,173 @@ function compacted(value) {
467
469
  // --- the table -------------------------------------------------------------
468
470
  const IMPLEMENTATIONS = new Map([
469
471
  // collections
470
- ["join(list<dyn>, string)", own((args) => list("join", args[0]).map((held) => textOf("join", held)).join(text(args[1])))],
471
- ["keys(map<dyn, dyn>)", own((args) => mapEntries("keys", args[0]).map(([key]) => key))],
472
- ["values(map<dyn, dyn>)", own((args) => mapEntries("values", args[0]).map(([, value]) => value))],
473
- ["distinct(list<dyn>)", own((args) => distinct(list("distinct", args[0])))],
474
- ["reverse(list<dyn>)", own((args) => [...list("reverse", args[0])].reverse())],
475
- ["flatten(list<dyn>)", own((args) => list("flatten", args[0]).flat())],
476
- ["sort(list<dyn>)", own((args) => sorted("sort", list("sort", args[0])))],
472
+ ["join(list<dyn>, string)", own((ctx, a, b) => list("join", a).map((held) => textOf("join", held)).join(text(b)))],
473
+ ["keys(map<dyn, dyn>)", own((ctx, a) => mapEntries("keys", a).map(([key]) => key))],
474
+ ["values(map<dyn, dyn>)", own((ctx, a) => mapEntries("values", a).map(([, value]) => value))],
475
+ ["distinct(list<dyn>)", own((ctx, a) => distinct(list("distinct", a)))],
476
+ ["reverse(list<dyn>)", own((ctx, a) => [...list("reverse", a)].reverse())],
477
+ ["flatten(list<dyn>)", own((ctx, a) => list("flatten", a).flat())],
478
+ ["sort(list<dyn>)", own((ctx, a) => sorted("sort", list("sort", a)))],
477
479
  [
478
480
  "range(int)",
479
- own((args) => Array.from({ length: Math.max(0, Math.trunc(numberOf(args[0]))) }, (_unused, at) => BigInt(at))),
481
+ own((ctx, a) => Array.from({ length: Math.max(0, Math.trunc(numberOf(a))) }, (_unused, at) => BigInt(at))),
480
482
  ],
481
483
  [
482
484
  "enumerate(list<dyn>)",
483
- own((args) => list("enumerate", args[0]).map((value, at) => {
485
+ own((ctx, a) => list("enumerate", a).map((value, at) => {
484
486
  const entry = Object.create(null);
485
487
  entry.index = BigInt(at);
486
488
  entry.value = value;
487
489
  return entry;
488
490
  })),
489
491
  ],
490
- ["compact(list<dyn>)", own((args) => compacted(args[0]))],
491
- ["compact(map<dyn, dyn>)", own((args) => compacted(args[0]))],
492
+ ["compact(list<dyn>)", own((ctx, a) => compacted(a))],
493
+ ["compact(map<dyn, dyn>)", own((ctx, a) => compacted(a))],
492
494
  [
493
495
  "merge(map<dyn, dyn>, map<dyn, dyn>)",
494
- own((args) => mapOfEntries(args[0], [...mapEntries("merge", args[0]), ...mapEntries("merge", args[1])])),
496
+ own((ctx, a, b) => mapOfEntries(a, [...mapEntries("merge", a), ...mapEntries("merge", b)])),
495
497
  ],
496
498
  // One body over the three: the overloads exist so that a statically wrong receiver is a
497
499
  // type error, and at runtime a `dyn` receiver reaches whichever of them resolved first, so
498
500
  // the VALUE decides what is sliced.
499
- ["slice(bytes, int, int)", own(sliced)],
500
- ["slice(string, int, int)", own(sliced)],
501
- ["slice(list<dyn>, int, int)", own(sliced)],
501
+ ["slice(bytes, int, int)", own((ctx, a, b, c) => sliced(a, b, c))],
502
+ ["slice(string, int, int)", own((ctx, a, b, c) => sliced(a, b, c))],
503
+ ["slice(list<dyn>, int, int)", own((ctx, a, b, c) => sliced(a, b, c))],
502
504
  // strings
503
- ["lower(string)", own((args) => text(args[0]).toLowerCase())],
504
- ["upper(string)", own((args) => text(args[0]).toUpperCase())],
505
- ["trim(string)", own((args) => text(args[0]).trim())],
506
- ["replace(string, string, string)", own((args) => text(args[0]).split(text(args[1])).join(text(args[2])))],
507
- ["split(string, string)", own((args) => text(args[0]).split(text(args[1])))],
505
+ ["lower(string)", own((ctx, a) => text(a).toLowerCase())],
506
+ ["upper(string)", own((ctx, a) => text(a).toUpperCase())],
507
+ ["trim(string)", own((ctx, a) => text(a).trim())],
508
+ ["replace(string, string, string)", own((ctx, a, b, c) => text(a).split(text(b)).join(text(c)))],
509
+ ["split(string, string)", own((ctx, a, b) => text(a).split(text(b)))],
508
510
  [
509
511
  "trimPrefix(string, string)",
510
- own((args) => {
511
- const prefix = text(args[1]);
512
- return text(args[0]).startsWith(prefix) ? text(args[0]).slice(prefix.length) : args[0];
512
+ own((ctx, a, b) => {
513
+ const prefix = text(b);
514
+ return text(a).startsWith(prefix) ? text(a).slice(prefix.length) : text(a);
513
515
  }),
514
516
  ],
515
517
  [
516
518
  "trimSuffix(string, string)",
517
- own((args) => {
518
- const suffix = text(args[1]);
519
- const value = text(args[0]);
519
+ own((ctx, a, b) => {
520
+ const suffix = text(b);
521
+ const value = text(a);
520
522
  return suffix !== "" && value.endsWith(suffix) ? value.slice(0, value.length - suffix.length) : value;
521
523
  }),
522
524
  ],
523
525
  [
524
526
  "regexReplace(string, string, string)",
525
- own((args) => pattern("regexReplace", args[1], undefined).matcher(text(args[0])).replaceAll(text(args[2]))),
527
+ own((ctx, a, b, c) => pattern("regexReplace", b, undefined).matcher(text(a)).replaceAll(text(c))),
526
528
  ],
527
529
  [
528
530
  "regexReplace(string, string, string, string)",
529
- own((args) => pattern("regexReplace", args[1], args[3]).matcher(text(args[0])).replaceAll(text(args[2]))),
531
+ own((ctx, a, b, c, d) => pattern("regexReplace", b, d).matcher(text(a)).replaceAll(text(c))),
530
532
  ],
531
- ["regexExtract(string, string)", own((args) => firstMatch("regexExtract", args, undefined))],
532
- ["regexExtract(string, string, string)", own((args) => firstMatch("regexExtract", args, args[2]))],
533
- ["regexExtractAll(string, string)", own((args) => everyMatch("regexExtractAll", args, undefined))],
534
- ["regexExtractAll(string, string, string)", own((args) => everyMatch("regexExtractAll", args, args[2]))],
535
- ["regexGroups(string, string)", own((args) => matchGroups("regexGroups", args, undefined))],
536
- ["regexGroups(string, string, string)", own((args) => matchGroups("regexGroups", args, args[2]))],
533
+ ["regexExtract(string, string)", own((ctx, a, b) => firstMatch("regexExtract", a, b, undefined))],
534
+ ["regexExtract(string, string, string)", own((ctx, a, b, c) => firstMatch("regexExtract", a, b, c))],
535
+ ["regexExtractAll(string, string)", own((ctx, a, b) => everyMatch("regexExtractAll", a, b, undefined))],
536
+ ["regexExtractAll(string, string, string)", own((ctx, a, b, c) => everyMatch("regexExtractAll", a, b, c))],
537
+ ["regexGroups(string, string)", own((ctx, a, b) => matchGroups("regexGroups", a, b, undefined))],
538
+ ["regexGroups(string, string, string)", own((ctx, a, b, c) => matchGroups("regexGroups", a, b, c))],
537
539
  // math
538
- ["abs(dyn)", own((args) => Math.abs(numberOf(args[0])))],
539
- ["floor(dyn)", own((args) => Math.floor(numberOf(args[0])))],
540
- ["ceil(dyn)", own((args) => Math.ceil(numberOf(args[0])))],
540
+ ["abs(dyn)", own((ctx, a) => Math.abs(numberOf(a)))],
541
+ ["floor(dyn)", own((ctx, a) => Math.floor(numberOf(a)))],
542
+ ["ceil(dyn)", own((ctx, a) => Math.ceil(numberOf(a)))],
541
543
  // Both arities go through `formattable`, so the 2^53 refusal does not depend on which
542
544
  // one the author wrote: guarding only the two-argument form left `round(x)` silently
543
545
  // answering with a neighbouring integer, reachable by writing one fewer argument.
544
- ["round(double)", own((args) => Math.round(formattable("round", args[0])))],
545
- ["round(int)", own((args) => Math.round(formattable("round", args[0])))],
546
- ["round(double, int)", own((args) => roundedTo(args))],
547
- ["round(int, int)", own((args) => roundedTo(args))],
548
- ["min(list<dyn>)", own((args) => smallest(list("min", args[0]), true))],
549
- ["max(list<dyn>)", own((args) => smallest(list("max", args[0]), false))],
546
+ ["round(double)", own((ctx, a) => Math.round(formattable("round", a)))],
547
+ ["round(int)", own((ctx, a) => Math.round(formattable("round", a)))],
548
+ ["round(double, int)", own((ctx, a, b) => roundedTo(a, b))],
549
+ ["round(int, int)", own((ctx, a, b) => roundedTo(a, b))],
550
+ ["min(list<dyn>)", own((ctx, a) => smallest(list("min", a), true))],
551
+ ["max(list<dyn>)", own((ctx, a) => smallest(list("max", a), false))],
550
552
  [
551
553
  "sum(list<dyn>)",
552
- own((args) => list("sum", args[0]).reduce((total, held) => total + numberOf(held), 0)),
554
+ own((ctx, a) => list("sum", a).reduce((total, held) => total + numberOf(held), 0)),
553
555
  ],
554
556
  [
555
557
  "avg(list<dyn>)",
556
- own((args) => {
557
- const values = list("avg", args[0]);
558
+ own((ctx, a) => {
559
+ const values = list("avg", a);
558
560
  if (values.length === 0)
559
561
  return null;
560
562
  return values.reduce((total, held) => total + numberOf(held), 0) / values.length;
561
563
  }),
562
564
  ],
563
565
  // JSON
564
- ["json(dyn)", hosted("json", (handler) => (args) => handler(args[0]))],
565
- ["parseJson(string)", own((args) => parseJsonText(text(args[0])))],
566
+ ["json(dyn)", hosted("json", (handler) => (ctx, a) => handler(a))],
567
+ ["parseJson(string)", own((ctx, a) => parseJsonText(text(a)))],
566
568
  // paths
567
569
  [
568
570
  "string.joinPath(string)",
569
- hosted("joinPath", (handler) => (args) => handler(text(args[0]), text(args[1]))),
571
+ hosted("joinPath", (handler) => (ctx, a, b) => handler(text(a), text(b))),
570
572
  ],
571
573
  // encoding
572
- ["base64Encode(string)", hosted("base64Encode", (handler) => (args) => handler(text(args[0])))],
573
- ["base64Decode(string)", hosted("base64Decode", (handler) => (args) => handler(text(args[0])))],
574
- ["bytesFromBase64(string)", own((args) => bytesFromBase64(text(args[0])))],
575
- ["bytesToBase64(bytes)", own((args) => base64Text(bytes(args[0])))],
576
- ["urlEncode(string)", own((args) => encodeURIComponent(text(args[0])))],
577
- ["urlDecode(string)", own((args) => decodeURIComponent(text(args[0])))],
574
+ ["base64Encode(string)", hosted("base64Encode", (handler) => (ctx, a) => handler(text(a)))],
575
+ ["base64Decode(string)", hosted("base64Decode", (handler) => (ctx, a) => handler(text(a)))],
576
+ ["bytesFromBase64(string)", own((ctx, a) => bytesFromBase64(text(a)))],
577
+ ["bytesToBase64(bytes)", own((ctx, a) => base64Text(bytes(a)))],
578
+ ["urlEncode(string)", own((ctx, a) => encodeURIComponent(text(a)))],
579
+ ["urlDecode(string)", own((ctx, a) => decodeURIComponent(text(a)))],
578
580
  // hashing
579
- ["sha256(string)", hosted("sha256", (handler) => (args) => handler(text(args[0])))],
580
- ["md5(string)", hosted("md5", (handler) => (args) => handler(text(args[0])))],
581
- ["sha1(string)", hosted("sha1", (handler) => (args) => handler(text(args[0])))],
582
- ["sha512(string)", hosted("sha512", (handler) => (args) => handler(text(args[0])))],
581
+ ["sha256(string)", hosted("sha256", (handler) => (ctx, a) => handler(text(a)))],
582
+ ["md5(string)", hosted("md5", (handler) => (ctx, a) => handler(text(a)))],
583
+ ["sha1(string)", hosted("sha1", (handler) => (ctx, a) => handler(text(a)))],
584
+ ["sha512(string)", hosted("sha512", (handler) => (ctx, a) => handler(text(a)))],
583
585
  [
584
586
  "hmac(string, string, string)",
585
- hosted("hmac", (handler) => (args) => handler(text(args[0]), text(args[1]), text(args[2]))),
587
+ hosted("hmac", (handler) => (ctx, a, b, c) => handler(text(a), text(b), text(c))),
586
588
  ],
587
589
  // null handling
588
- ["default(dyn, dyn)", own((args) => (args[0] === null ? args[1] : args[0]))],
590
+ ["default(dyn, dyn)", own((ctx, a, b) => (a === null ? b : a))],
589
591
  [
590
592
  "coalesce(list<dyn>)",
591
- own((args) => {
592
- const found = list("coalesce", args[0]).find((held) => held !== null);
593
+ own((ctx, a) => {
594
+ const found = list("coalesce", a).find((held) => held !== null);
593
595
  return found === undefined ? null : found;
594
596
  }),
595
597
  ],
596
598
  // time
597
599
  ["now()", own(() => instantOfMillis("now", Date.now()))],
598
600
  ["nowIso()", own(() => isoTextIn(Date.now(), "UTC"))],
599
- ["nowIso(string)", own((args) => isoTextIn(Date.now(), zoneArg("nowIso", args[0])))],
601
+ ["nowIso(string)", own((ctx, a) => isoTextIn(Date.now(), zoneArg("nowIso", a)))],
600
602
  ["today()", own(() => dateTextIn(Date.now(), "UTC"))],
601
- ["today(string)", own((args) => dateTextIn(Date.now(), zoneArg("today", args[0])))],
603
+ ["today(string)", own((ctx, a) => dateTextIn(Date.now(), zoneArg("today", a)))],
602
604
  ["nowMillis()", own(() => BigInt(Date.now()))],
603
605
  ["nowSeconds()", own(() => BigInt(Math.floor(Date.now() / 1000)))],
604
- ["dateIn(google.protobuf.Timestamp)", own((args) => dateIn(args, undefined))],
605
- ["dateIn(google.protobuf.Timestamp, string)", own((args) => dateIn(args, args[1]))],
606
- ["isoIn(google.protobuf.Timestamp)", own((args) => isoIn(args, undefined))],
607
- ["isoIn(google.protobuf.Timestamp, string)", own((args) => isoIn(args, args[1]))],
608
- ["startOfMonth(google.protobuf.Timestamp)", own((args) => startOfMonth(args, undefined))],
609
- ["startOfMonth(google.protobuf.Timestamp, string)", own((args) => startOfMonth(args, args[1]))],
610
- ["addMonths(google.protobuf.Timestamp, int)", own((args) => addMonths(args, undefined))],
611
- ["addMonths(google.protobuf.Timestamp, int, string)", own((args) => addMonths(args, args[2]))],
606
+ ["dateIn(google.protobuf.Timestamp)", own((ctx, a) => dateIn(a, undefined))],
607
+ ["dateIn(google.protobuf.Timestamp, string)", own((ctx, a, b) => dateIn(a, b))],
608
+ ["isoIn(google.protobuf.Timestamp)", own((ctx, a) => isoIn(a, undefined))],
609
+ ["isoIn(google.protobuf.Timestamp, string)", own((ctx, a, b) => isoIn(a, b))],
610
+ ["startOfMonth(google.protobuf.Timestamp)", own((ctx, a) => startOfMonth(a, undefined))],
611
+ ["startOfMonth(google.protobuf.Timestamp, string)", own((ctx, a, b) => startOfMonth(a, b))],
612
+ ["addMonths(google.protobuf.Timestamp, int)", own((ctx, a, b) => addMonths(a, b, undefined))],
613
+ ["addMonths(google.protobuf.Timestamp, int, string)", own((ctx, a, b, c) => addMonths(a, b, c))],
612
614
  // formatting
613
- ["format(double, string)", own((args) => formatter("format", args[1])(formattable("format", args[0])))],
614
- ["format(int, string)", own((args) => formatter("format", args[1])(formattable("format", args[0])))],
615
- ["fixed(double, int)", own((args) => fixedText(args))],
616
- ["fixed(int, int)", own((args) => fixedText(args))],
617
- ["formatDuration(double, int)", own((args) => durationText(args[0], args[1]))],
618
- ["formatDuration(int, int)", own((args) => durationText(args[0], args[1]))],
615
+ ["format(double, string)", own((ctx, a, b) => formatter("format", b)(formattable("format", a)))],
616
+ ["format(int, string)", own((ctx, a, b) => formatter("format", b)(formattable("format", a)))],
617
+ ["fixed(double, int)", own((ctx, a, b) => fixedText(a, b))],
618
+ ["fixed(int, int)", own((ctx, a, b) => fixedText(a, b))],
619
+ ["formatDuration(double, int)", own((ctx, a, b) => durationText(a, b))],
620
+ ["formatDuration(int, int)", own((ctx, a, b) => durationText(a, b))],
619
621
  // uuid
620
622
  ["uuidv1()", own(() => v1())],
621
623
  ["uuidv4()", own(() => v4())],
622
624
  ["uuidv6()", own(() => v6())],
623
625
  ["uuidv7()", own(() => v7())],
624
- ["uuidv3(string, string)", own((args) => v3(text(args[0]), text(args[1])))],
625
- ["uuidv5(string, string)", own((args) => v5(text(args[0]), text(args[1])))],
626
- ["uuidValidate(string)", own((args) => uuidValidate(text(args[0])))],
627
- ["uuidVersion(string)", own((args) => BigInt(uuidVersion(text(args[0]))))],
626
+ ["uuidv3(string, string)", own((ctx, a, b) => v3(text(a), text(b)))],
627
+ ["uuidv5(string, string)", own((ctx, a, b) => v5(text(a), text(b)))],
628
+ ["uuidValidate(string)", own((ctx, a) => uuidValidate(text(a)))],
629
+ ["uuidVersion(string)", own((ctx, a) => BigInt(uuidVersion(text(a))))],
628
630
  ]);
629
631
  /**
630
632
  * The half-open range of a string, bytes or a list. Indices arrive as CEL ints (`bigint`),
631
633
  * which neither `String.slice` nor `TypedArray.subarray` accepts. `subarray` rather than
632
634
  * `slice` for bytes: a view costs no copy, and every consumer treats the result as read-only.
633
635
  */
634
- function sliced(args) {
635
- const from = Number(args[1]);
636
- const to = Number(args[2]);
637
- const value = args[0];
636
+ function sliced(value, start, end) {
637
+ const from = Number(start);
638
+ const to = Number(end);
638
639
  if (typeof value === "string")
639
640
  return value.slice(from, to);
640
641
  if (isCelBytes(value))
@@ -643,44 +644,44 @@ function sliced(args) {
643
644
  return value.slice(from, to);
644
645
  throw new CatalogRefusal(`slice: expected a string, bytes or a list, got ${celTypeNameOf(value) ?? "no CEL value"}`);
645
646
  }
646
- function roundedTo(args) {
647
- return Number(formattable("round", args[0]).toFixed(digitCount("round", args[1])));
647
+ function roundedTo(value, digits) {
648
+ return Number(formattable("round", value).toFixed(digitCount("round", digits)));
648
649
  }
649
- function fixedText(args) {
650
- return formatter("fixed", `.${digitCount("fixed", args[1])}f`)(formattable("fixed", args[0]));
650
+ function fixedText(value, digits) {
651
+ return formatter("fixed", `.${digitCount("fixed", digits)}f`)(formattable("fixed", value));
651
652
  }
652
- function firstMatch(what, args, flags) {
653
- const matcher = pattern(what, args[1], flags).matcher(text(args[0]));
653
+ function firstMatch(what, subject, source, flags) {
654
+ const matcher = pattern(what, source, flags).matcher(text(subject));
654
655
  return matcher.find() ? (matcher.group() ?? "") : "";
655
656
  }
656
- function everyMatch(what, args, flags) {
657
- const matcher = pattern(what, args[1], flags).matcher(text(args[0]));
657
+ function everyMatch(what, subject, source, flags) {
658
+ const matcher = pattern(what, source, flags).matcher(text(subject));
658
659
  const out = [];
659
660
  while (matcher.find())
660
661
  out.push(matcher.group() ?? "");
661
662
  return out;
662
663
  }
663
- function matchGroups(what, args, flags) {
664
- const matcher = pattern(what, args[1], flags).matcher(text(args[0]));
664
+ function matchGroups(what, subject, source, flags) {
665
+ const matcher = pattern(what, source, flags).matcher(text(subject));
665
666
  if (!matcher.find())
666
667
  return [];
667
668
  return Array.from({ length: matcher.groupCount() }, (_unused, at) => matcher.group(at + 1) ?? "");
668
669
  }
669
- function dateIn(args, zone) {
670
- return dateTextIn(millisOf(instantArg("dateIn", args[0])), zoneArg("dateIn", zone));
670
+ function dateIn(instant, zone) {
671
+ return dateTextIn(millisOf(instantArg("dateIn", instant)), zoneArg("dateIn", zone));
671
672
  }
672
- function isoIn(args, zone) {
673
- return isoTextIn(millisOf(instantArg("isoIn", args[0])), zoneArg("isoIn", zone));
673
+ function isoIn(instant, zone) {
674
+ return isoTextIn(millisOf(instantArg("isoIn", instant)), zoneArg("isoIn", zone));
674
675
  }
675
- function startOfMonth(args, zone) {
676
+ function startOfMonth(instant, zone) {
676
677
  const named = zoneArg("startOfMonth", zone);
677
- const fields = civilTimeIn(millisOf(instantArg("startOfMonth", args[0])), named);
678
+ const fields = civilTimeIn(millisOf(instantArg("startOfMonth", instant)), named);
678
679
  return instantOfMillis("startOfMonth", instantOfCivilTime({ ...fields, day: 1, hour: 0, minute: 0, second: 0 }, named));
679
680
  }
680
- function addMonths(args, zone) {
681
+ function addMonths(instant, months, zone) {
681
682
  const named = zoneArg("addMonths", zone);
682
- const fields = civilTimeIn(millisOf(instantArg("addMonths", args[0])), named);
683
- const shifted = fields.year * 12 + (fields.month - 1) + Number(args[1]);
683
+ const fields = civilTimeIn(millisOf(instantArg("addMonths", instant)), named);
684
+ const shifted = fields.year * 12 + (fields.month - 1) + Number(months);
684
685
  // `%` takes the dividend's sign in JS, so a negative total would yield month 0.
685
686
  const year = Math.floor(shifted / 12);
686
687
  const month = (((shifted % 12) + 12) % 12) + 1;
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Building a CEL map, and the one identity a key has.
3
3
  *
4
- * A map's entries live in a `Map` keyed by the **canonical text** of each key, never by
5
- * a property name. Two consequences, both load-bearing:
4
+ * A map's entries live in a `Map` keyed by each key's **own typed value**, never by a
5
+ * property name. Three consequences, all load-bearing:
6
6
  *
7
7
  * - A map holds CEL's four key types (int, uint, bool, string) in one container, and an
8
8
  * int key and a uint key of the same number are **one** key, because CEL equality
@@ -10,25 +10,38 @@
10
10
  * - Nothing a key spells can reach a prototype, a method or an inherited member. A map
11
11
  * built from `{'__proto__': 1}` holds `__proto__` as data and reads it back as data;
12
12
  * dropping such a key would be swallowing what the author wrote.
13
+ * - The types separate themselves. A `Map` compares its keys by type as well as value, so
14
+ * a string `"1"` and an int `1` are distinct keys with nothing prefixed to say so — and a
15
+ * second engine keys an entry by its own discriminant rather than reproducing this one's
16
+ * text byte for byte.
13
17
  */
14
- import type { CelMap, CelMapValueEntry, CelValue } from "./cel-value.js";
18
+ import type { CelMap, CelMapKey, CelMapValueEntry, CelValue } from "./cel-value.js";
15
19
  import { type CelError } from "./cel-value.js";
16
20
  import type { SourceRange } from "./syntax-tree.js";
17
21
  /**
18
- * The text that identifies a key. `n` covers the numeric types together: CEL equality
22
+ * What identifies a key. The `bigint` covers the numeric types together: CEL equality
19
23
  * makes `1`, `1u` and `1.0` one key, so a map carrying two of them is not a map and a
20
24
  * lookup by any of the three finds the entry — which is what
21
25
  * `{1u: 1.0, 2: 2.0, 3u: 3.0}[?3.0]` reads. A double that is not whole identifies
22
26
  * nothing, since no entry can hold it.
27
+ *
28
+ * A string and a bool identify themselves, and nothing is prefixed to keep the types
29
+ * apart: a `Map` key of one type never equals a key of another, so `"1"` and `1` are
30
+ * distinct keys and `"true"` is not `true`.
23
31
  */
24
- export declare function mapKeyIdentity(key: CelValue): string | undefined;
32
+ export declare function mapKeyIdentity(key: CelValue): CelMapKey | undefined;
25
33
  /** An empty map, for a literal with no entries. */
26
- export declare function celMapOf(entries: ReadonlyMap<string, CelMapValueEntry>): CelMap;
34
+ export declare function celMapOf(entries: ReadonlyMap<CelMapKey, CelMapValueEntry>): CelMap;
27
35
  /**
28
36
  * A map from its entries in written order, or the error that stops it: a key of a type
29
37
  * no map is keyed by, or two keys CEL equality makes one.
38
+ *
39
+ * The entries arrive **flat** — key, value, key, value — because a literal of n entries
40
+ * then costs one allocation rather than one per entry, and both backends write the same
41
+ * call. A duplicate is caught by the size not moving, which is the one hash lookup the
42
+ * insert already performs.
30
43
  */
31
- export declare function celMapFromEntries(pairs: readonly (readonly [CelValue, CelValue])[], range?: SourceRange): CelMap | CelError;
44
+ export declare function celMapFromEntries(flat: readonly CelValue[], range?: SourceRange): CelMap | CelError;
32
45
  /** Every key of a map, in insertion order — what a comprehension ranges over. */
33
46
  export declare function celMapKeys(map: CelMap): CelValue[];
34
47
  //# sourceMappingURL=cel-map-value.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cel-map-value.d.ts","sourceRoot":"","sources":["../src/cel-map-value.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAKL,KAAK,QAAQ,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAOhE;AAED,mDAAmD;AACnD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,MAAM,CAE/E;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,EAAE,EACjD,KAAK,CAAC,EAAE,WAAW,GAClB,MAAM,GAAG,QAAQ,CAsBnB;AAQD,iFAAiF;AACjF,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,EAAE,CAElD"}
1
+ {"version":3,"file":"cel-map-value.d.ts","sourceRoot":"","sources":["../src/cel-map-value.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAKL,KAAK,QAAQ,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAKnE;AAED,mDAAmD;AACnD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,SAAS,EAAE,gBAAgB,CAAC,GAAG,MAAM,CAElF;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,QAAQ,EAAE,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,QAAQ,CAyBnG;AAQD,iFAAiF;AACjF,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,EAAE,CAElD"}
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Building a CEL map, and the one identity a key has.
3
3
  *
4
- * A map's entries live in a `Map` keyed by the **canonical text** of each key, never by
5
- * a property name. Two consequences, both load-bearing:
4
+ * A map's entries live in a `Map` keyed by each key's **own typed value**, never by a
5
+ * property name. Three consequences, all load-bearing:
6
6
  *
7
7
  * - A map holds CEL's four key types (int, uint, bool, string) in one container, and an
8
8
  * int key and a uint key of the same number are **one** key, because CEL equality
@@ -10,27 +10,30 @@
10
10
  * - Nothing a key spells can reach a prototype, a method or an inherited member. A map
11
11
  * built from `{'__proto__': 1}` holds `__proto__` as data and reads it back as data;
12
12
  * dropping such a key would be swallowing what the author wrote.
13
+ * - The types separate themselves. A `Map` compares its keys by type as well as value, so
14
+ * a string `"1"` and an int `1` are distinct keys with nothing prefixed to say so — and a
15
+ * second engine keys an entry by its own discriminant rather than reproducing this one's
16
+ * text byte for byte.
13
17
  */
14
18
  import { CEL_VALUE_TYPE, celError, isCelError, isCelUint, } from "./cel-value.js";
15
19
  /**
16
- * The text that identifies a key. `n` covers the numeric types together: CEL equality
20
+ * What identifies a key. The `bigint` covers the numeric types together: CEL equality
17
21
  * makes `1`, `1u` and `1.0` one key, so a map carrying two of them is not a map and a
18
22
  * lookup by any of the three finds the entry — which is what
19
23
  * `{1u: 1.0, 2: 2.0, 3u: 3.0}[?3.0]` reads. A double that is not whole identifies
20
24
  * nothing, since no entry can hold it.
25
+ *
26
+ * A string and a bool identify themselves, and nothing is prefixed to keep the types
27
+ * apart: a `Map` key of one type never equals a key of another, so `"1"` and `1` are
28
+ * distinct keys and `"true"` is not `true`.
21
29
  */
22
30
  export function mapKeyIdentity(key) {
23
- if (typeof key === "string")
24
- return `s${key}`;
25
- if (typeof key === "boolean")
26
- return `b${key}`;
27
- if (typeof key === "bigint")
28
- return `n${key}`;
29
- if (isCelUint(key))
30
- return `n${key.value}`;
31
- if (typeof key === "number" && Number.isInteger(key))
32
- return `n${BigInt(key)}`;
33
- return undefined;
31
+ const held = typeof key;
32
+ if (held === "string" || held === "boolean" || held === "bigint")
33
+ return key;
34
+ if (held === "number")
35
+ return Number.isInteger(key) ? BigInt(key) : undefined;
36
+ return isCelUint(key) ? key.value : undefined;
34
37
  }
35
38
  /** An empty map, for a literal with no entries. */
36
39
  export function celMapOf(entries) {
@@ -39,10 +42,17 @@ export function celMapOf(entries) {
39
42
  /**
40
43
  * A map from its entries in written order, or the error that stops it: a key of a type
41
44
  * no map is keyed by, or two keys CEL equality makes one.
45
+ *
46
+ * The entries arrive **flat** — key, value, key, value — because a literal of n entries
47
+ * then costs one allocation rather than one per entry, and both backends write the same
48
+ * call. A duplicate is caught by the size not moving, which is the one hash lookup the
49
+ * insert already performs.
42
50
  */
43
- export function celMapFromEntries(pairs, range) {
51
+ export function celMapFromEntries(flat, range) {
44
52
  const entries = new Map();
45
- for (const [key, value] of pairs) {
53
+ for (let at = 0; at < flat.length; at += 2) {
54
+ const key = flat[at];
55
+ const value = flat[at + 1];
46
56
  if (isCelError(key))
47
57
  return key;
48
58
  if (isCelError(value))
@@ -54,10 +64,11 @@ export function celMapFromEntries(pairs, range) {
54
64
  if (identity === undefined) {
55
65
  return celError("unsupported_key_type", "a map is keyed by an int, a uint, a bool or a string", range);
56
66
  }
57
- if (entries.has(identity)) {
67
+ const before = entries.size;
68
+ entries.set(identity, { key, value });
69
+ if (entries.size === before) {
58
70
  return celError("duplicate_map_key", `the key ${describeKey(key)} is written twice`, range);
59
71
  }
60
- entries.set(identity, { key, value });
61
72
  }
62
73
  return celMapOf(entries);
63
74
  }
@@ -62,12 +62,19 @@ export interface CelMapValueEntry {
62
62
  readonly value: CelValue;
63
63
  }
64
64
  /**
65
- * A map. Entries live in a `Map` keyed by the canonical text of each key, so the map
66
- * holds int, uint, bool and string keys alike and **no key is ever a property name**:
65
+ * What identifies a key inside a map's entries. A `Map` distinguishes its own keys **by
66
+ * type**, so the four CEL key types collapse onto three JS ones with no namespace to
67
+ * separate by hand: a string key is itself, a bool is itself, and an int, a uint and a
68
+ * whole double are all the `bigint` CEL equality makes them.
69
+ */
70
+ export type CelMapKey = string | bigint | boolean;
71
+ /**
72
+ * A map. Entries live in a `Map` keyed by each key's own `CelMapKey`, so the map holds
73
+ * int, uint, bool and string keys alike and **no key is ever a property name**:
67
74
  * `__proto__`, `constructor` and `prototype` are data here, as they are in any map.
68
75
  */
69
76
  export interface CelMap extends Branded<"map"> {
70
- readonly entries: ReadonlyMap<string, CelMapValueEntry>;
77
+ readonly entries: ReadonlyMap<CelMapKey, CelMapValueEntry>;
71
78
  }
72
79
  /** Every evaluation failure this engine names. A code is never derived from a message. */
73
80
  export declare const CEL_EVALUATION_CODES: readonly ["no_such_key", "no_such_variable", "index_out_of_range", "no_matching_overload", "unsupported_container", "unsupported_key_type", "duplicate_map_key", "numeric_overflow", "division_by_zero", "modulo_by_zero", "invalid_conversion", "invalid_argument", "invalid_regular_expression", "optional_value_missing", "unbound_function", "async_value_unsupported"];
@@ -1 +1 @@
1
- {"version":3,"file":"cel-value.d.ts","sourceRo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AED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG,QAAQ,CAiB1D"}
@@ -36,9 +36,10 @@ export interface CelCheckDiagnostic {
36
36
  * refusal to compile a tree the front end already reported a syntax diagnostic for,
37
37
  * which is a question the caller should have asked before compiling, and
38
38
  * `emitted_module_rejected` is the refusal to run a loaded module whose integrity header
39
- * is not the one the emission asked for.
39
+ * is not the one the emission asked for, and `signature_too_wide` is a registration
40
+ * declaring more values than an implementation receives.
40
41
  */
41
- export type CelEngineErrorCode = "namespaces_mismatch" | "unreadable_expression" | "emitted_module_rejected";
42
+ export type CelEngineErrorCode = "namespaces_mismatch" | "unreadable_expression" | "emitted_module_rejected" | "signature_too_wide";
42
43
  export declare class CelEngineError extends Error {
43
44
  readonly code: CelEngineErrorCode;
44
45
  constructor(code: CelEngineErrorCode, message: string);
@@ -1 +1 @@
1
- {"version":3,"file":"check-diagnostic.d.ts","sourceRoot":"","sources":["../src/check-diagnostic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;GAIG;AACH,eAAO,MAAM,eAAe,4SAyBlB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5D,MAAM,WAAW,gBAAgB;IAC/B,uCAAuC;IACvC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,GAAG,CAAC,EAAE,gBAAgB,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAC1B,qBAAqB,GACrB,uBAAuB,GAC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FAAmF;AACnF,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA4B;IAEjD,GAAG,CAAC,UAAU,EAAE,kBAAkB,GAAG,IAAI;IAIzC,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,IAAI,SAAS,kBAAkB,EAAE;CAGtC"}
package/dist/checker.d.ts CHANGED
@@ -38,6 +38,15 @@ export interface NamespaceFunction {
38
38
  readonly parameters?: readonly CelType[];
39
39
  /** How the declaration is written, for a listing; absent with the parameters. */
40
40
  readonly signature?: string;
41
+ /**
42
+ * Types the declaration named that nothing is registered under, in the order written.
43
+ *
44
+ * The declaration is accepted and reads `dyn` where one stands: a host's declaration is
45
+ * data out of someone's manifest, so a name its own registry does not carry is the host
46
+ * disagreeing with itself — reported at the call, where there is a range, rather than
47
+ * thrown at registration, where there is none. Same rule as an unjudged schema node.
48
+ */
49
+ readonly unregisteredTypes?: readonly string[];
41
50
  readonly deterministic?: boolean;
42
51
  readonly hostBacked?: boolean;
43
52
  readonly throws?: readonly string[];
@@ -1 +1 @@
1
- {"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../src/checker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,eAAe,CAAC;AAyBzD,OAAO,KAAK,EAAgB,kBAAkB,EAAoB,MAAM,uBAAuB,CAAC;AAGhG,OAAO,KAAK,EAAE,gBAAgB,EAAyC,MAAM,wBAAwB,CAAC;AAKtG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAYvD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,4FAA4F;IAC5F,QAAQ,CAAC,UAA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