@elaraai/east 1.0.104 → 1.0.106

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 (120) hide show
  1. package/dist/src/ast_to_ir.d.ts.map +1 -1
  2. package/dist/src/ast_to_ir.js +29 -7
  3. package/dist/src/ast_to_ir.js.map +1 -1
  4. package/dist/src/codegen/codegen.spec.js +14 -0
  5. package/dist/src/codegen/codegen.spec.js.map +1 -1
  6. package/dist/src/codegen/types.d.ts +3 -1
  7. package/dist/src/codegen/types.d.ts.map +1 -1
  8. package/dist/src/codegen/types.js +19 -3
  9. package/dist/src/codegen/types.js.map +1 -1
  10. package/dist/src/compile/control.d.ts.map +1 -1
  11. package/dist/src/compile/control.js +10 -5
  12. package/dist/src/compile/control.js.map +1 -1
  13. package/dist/src/compile.open_beast.spec.js +7 -3
  14. package/dist/src/compile.open_beast.spec.js.map +1 -1
  15. package/dist/src/expr/query.d.ts.map +1 -1
  16. package/dist/src/expr/query.js +3 -1
  17. package/dist/src/expr/query.js.map +1 -1
  18. package/dist/src/fuzz.js +8 -8
  19. package/dist/src/fuzz.js.map +1 -1
  20. package/dist/src/patch/type_of_patch.d.ts.map +1 -1
  21. package/dist/src/patch/type_of_patch.js +4 -5
  22. package/dist/src/patch/type_of_patch.js.map +1 -1
  23. package/dist/src/query/jq/catalog.d.ts.map +1 -1
  24. package/dist/src/query/jq/catalog.js +15 -15
  25. package/dist/src/query/jq/catalog.js.map +1 -1
  26. package/dist/src/query/jq/check.d.ts.map +1 -1
  27. package/dist/src/query/jq/check.js +22 -16
  28. package/dist/src/query/jq/check.js.map +1 -1
  29. package/dist/src/query/jq/narrow.d.ts +68 -0
  30. package/dist/src/query/jq/narrow.d.ts.map +1 -0
  31. package/dist/src/query/jq/narrow.js +691 -0
  32. package/dist/src/query/jq/narrow.js.map +1 -0
  33. package/dist/src/query/jq/shapes.d.ts.map +1 -1
  34. package/dist/src/query/jq/shapes.js +4 -2
  35. package/dist/src/query/jq/shapes.js.map +1 -1
  36. package/dist/src/query/jq/split.d.ts +35 -11
  37. package/dist/src/query/jq/split.d.ts.map +1 -1
  38. package/dist/src/query/jq/split.js +206 -35
  39. package/dist/src/query/jq/split.js.map +1 -1
  40. package/dist/src/query/jq/translate-builtins.d.ts.map +1 -1
  41. package/dist/src/query/jq/translate-builtins.js +52 -14
  42. package/dist/src/query/jq/translate-builtins.js.map +1 -1
  43. package/dist/src/query/jq/translate.d.ts +58 -4
  44. package/dist/src/query/jq/translate.d.ts.map +1 -1
  45. package/dist/src/query/jq/translate.js +192 -34
  46. package/dist/src/query/jq/translate.js.map +1 -1
  47. package/dist/src/runner_exec.d.ts +10 -0
  48. package/dist/src/runner_exec.d.ts.map +1 -1
  49. package/dist/src/runner_exec.js +11 -3
  50. package/dist/src/runner_exec.js.map +1 -1
  51. package/dist/src/runner_exec.spec.js +40 -2
  52. package/dist/src/runner_exec.spec.js.map +1 -1
  53. package/dist/src/serialization/beast.d.ts.map +1 -1
  54. package/dist/src/serialization/beast.js +4 -2
  55. package/dist/src/serialization/beast.js.map +1 -1
  56. package/dist/src/serialization/beast2/index.d.ts +2 -1
  57. package/dist/src/serialization/beast2/index.d.ts.map +1 -1
  58. package/dist/src/serialization/beast2/index.js +2 -1
  59. package/dist/src/serialization/beast2/index.js.map +1 -1
  60. package/dist/src/serialization/beast2/v5/codec.d.ts +30 -1
  61. package/dist/src/serialization/beast2/v5/codec.d.ts.map +1 -1
  62. package/dist/src/serialization/beast2/v5/codec.js +24 -3
  63. package/dist/src/serialization/beast2/v5/codec.js.map +1 -1
  64. package/dist/src/serialization/beast2/v5/header-type.spec.d.ts +6 -0
  65. package/dist/src/serialization/beast2/v5/header-type.spec.d.ts.map +1 -0
  66. package/dist/src/serialization/beast2/v5/header-type.spec.js +120 -0
  67. package/dist/src/serialization/beast2/v5/header-type.spec.js.map +1 -0
  68. package/dist/src/serialization/beast2/v5/lazy.d.ts +23 -4
  69. package/dist/src/serialization/beast2/v5/lazy.d.ts.map +1 -1
  70. package/dist/src/serialization/beast2/v5/lazy.js +84 -19
  71. package/dist/src/serialization/beast2/v5/lazy.js.map +1 -1
  72. package/dist/src/serialization/beast2/v5/project.d.ts +156 -0
  73. package/dist/src/serialization/beast2/v5/project.d.ts.map +1 -0
  74. package/dist/src/serialization/beast2/v5/project.js +830 -0
  75. package/dist/src/serialization/beast2/v5/project.js.map +1 -0
  76. package/dist/src/serialization/beast2/v5/project.spec.d.ts +6 -0
  77. package/dist/src/serialization/beast2/v5/project.spec.d.ts.map +1 -0
  78. package/dist/src/serialization/beast2/v5/project.spec.js +273 -0
  79. package/dist/src/serialization/beast2/v5/project.spec.js.map +1 -0
  80. package/dist/src/serialization/beast2/v5/runs.d.ts +78 -7
  81. package/dist/src/serialization/beast2/v5/runs.d.ts.map +1 -1
  82. package/dist/src/serialization/beast2/v5/runs.js +218 -7
  83. package/dist/src/serialization/beast2/v5/runs.js.map +1 -1
  84. package/dist/src/serialization/beast2/v5/runs.spec.js +223 -6
  85. package/dist/src/serialization/beast2/v5/runs.spec.js.map +1 -1
  86. package/dist/src/serialization/beast2/v5/stream.d.ts +40 -6
  87. package/dist/src/serialization/beast2/v5/stream.d.ts.map +1 -1
  88. package/dist/src/serialization/beast2/v5/stream.js +54 -15
  89. package/dist/src/serialization/beast2/v5/stream.js.map +1 -1
  90. package/dist/src/serialization/east.js +3 -5
  91. package/dist/src/serialization/east.js.map +1 -1
  92. package/dist/src/serialization/index.d.ts +1 -1
  93. package/dist/src/serialization/index.d.ts.map +1 -1
  94. package/dist/src/serialization/index.js +1 -1
  95. package/dist/src/serialization/index.js.map +1 -1
  96. package/dist/src/serialization/json_schema.spec.js +12 -2
  97. package/dist/src/serialization/json_schema.spec.js.map +1 -1
  98. package/dist/src/serialization/json_schema_to_type.d.ts +7 -0
  99. package/dist/src/serialization/json_schema_to_type.d.ts.map +1 -1
  100. package/dist/src/serialization/json_schema_to_type.js +34 -5
  101. package/dist/src/serialization/json_schema_to_type.js.map +1 -1
  102. package/dist/src/serialization/json_schema_to_type.spec.js +22 -0
  103. package/dist/src/serialization/json_schema_to_type.spec.js.map +1 -1
  104. package/dist/src/type_of_type.d.ts +9 -1
  105. package/dist/src/type_of_type.d.ts.map +1 -1
  106. package/dist/src/type_of_type.js +47 -7
  107. package/dist/src/type_of_type.js.map +1 -1
  108. package/dist/src/types.d.ts +67 -3
  109. package/dist/src/types.d.ts.map +1 -1
  110. package/dist/src/types.js +133 -43
  111. package/dist/src/types.js.map +1 -1
  112. package/dist/src/types.struct_fields.spec.d.ts +6 -0
  113. package/dist/src/types.struct_fields.spec.d.ts.map +1 -0
  114. package/dist/src/types.struct_fields.spec.js +118 -0
  115. package/dist/src/types.struct_fields.spec.js.map +1 -0
  116. package/dist/src/types.variant_cases.spec.d.ts +6 -0
  117. package/dist/src/types.variant_cases.spec.d.ts.map +1 -0
  118. package/dist/src/types.variant_cases.spec.js +85 -0
  119. package/dist/src/types.variant_cases.spec.js.map +1 -0
  120. package/package.json +1 -1
@@ -13,7 +13,7 @@ import { walkSteps } from "./check.js";
13
13
  import { jqTypeNames, nullablePayload, unify, unwrap } from "./shapes.js";
14
14
  import { childPath, jqChildren } from "./spans.js";
15
15
  import { formatTokens } from "./strftime.js";
16
- import { isRoot, parts } from "./translate.js";
16
+ import { isRoot, isRows, parts } from "./translate.js";
17
17
  /** Builds a rule table entry for each of some names. */
18
18
  const rules = {};
19
19
  function rule(names, r) {
@@ -102,7 +102,8 @@ rule("first", (t, c) => {
102
102
  t.once(c.$, ($, label) => arg(t, c, 0, $, c.x, ($2, v) => { c.emit($2, v); t.brk($2, label); }), c.path);
103
103
  return;
104
104
  }
105
- t.indexOf(c.$, input(t, c), t.int(0), false, c.path, c.emit);
105
+ // A stage's rows (#1140): the first, kept as it is made.
106
+ t.indexOf(c.$, isRows(c.x) ? t.firstRows(c.$, c.x, 1n, c.path) : input(t, c), t.int(0), false, c.path, c.emit);
106
107
  });
107
108
  rule("last", (t, c) => {
108
109
  if (c.args.length === 1) {
@@ -335,14 +336,17 @@ rule("walk", (t, c) => {
335
336
  if (ot.type === "Struct") {
336
337
  const s = t.bind($, o, "struct");
337
338
  const values = {};
338
- const types = {};
339
+ // The rebuilt fields in the struct's order: a list, as an object would
340
+ // list a name like an integer first (#1574)
341
+ const types = [];
339
342
  for (const name of Object.keys(ot.fields)) {
340
343
  values[name] = walk($, t.field(s, name));
341
- types[name] = t.type(values[name]);
344
+ types.push([name, t.type(values[name])]);
342
345
  }
343
346
  // A recursive value keeps its type; a reference's value is read through it.
344
347
  const vt = t.type(v);
345
- const rebuiltType = vt.type === "Recursive" && isTypeEqual(StructType(types), ot) ? vt : StructType(types);
348
+ const rebuilt = StructType(types);
349
+ const rebuiltType = vt.type === "Recursive" && isTypeEqual(rebuilt, ot) ? vt : rebuilt;
346
350
  return t.struct(rebuiltType, values);
347
351
  }
348
352
  return v;
@@ -470,13 +474,13 @@ function deleteAt(t, c, $, v, paths) {
470
474
  }
471
475
  }
472
476
  const values = {};
473
- const types = {};
477
+ const types = [];
474
478
  for (const name of Object.keys(fields)) {
475
479
  if (removed.has(name))
476
480
  continue;
477
481
  const rests = nested.get(name);
478
482
  values[name] = rests === undefined ? t.field(s, name) : t.bind($, deleteAt(t, c, $, t.field(s, name), rests), name);
479
- types[name] = t.type(values[name]);
483
+ types.push([name, t.type(values[name])]);
480
484
  }
481
485
  return t.struct(StructType(types), values);
482
486
  }
@@ -679,7 +683,7 @@ rule("pick", (t, c) => {
679
683
  // `null`'s fields are null.
680
684
  const inner = t.type(v).type === "Null" ? t.null(c.path) : t.field(v, rest[0]);
681
685
  const picked = rest.length === 1 ? inner : build($, t.bind($, inner, rest[0]), rest.slice(1));
682
- return t.struct(StructType({ [rest[0]]: t.type(picked) }), { [rest[0]]: picked });
686
+ return t.struct(StructType([[rest[0], t.type(picked)]]), { [rest[0]]: picked });
683
687
  };
684
688
  c.emit(c.$, build(c.$, t.bind(c.$, t.open(input(t, c)), "value"), names));
685
689
  });
@@ -710,6 +714,13 @@ rule("transpose", (t, c) => {
710
714
  });
711
715
  // ─── Collections ─────────────────────────────────────────────────────────
712
716
  rule("length", (t, c) => {
717
+ if (isRows(c.x)) {
718
+ // A stage's rows, counted as they are made (#1140).
719
+ const count = t.declare(c.$, t.int(0), "count");
720
+ c.x.each(c.$, $ => t.assign($, count, t.add(count, t.int(1), c.path)));
721
+ c.emit(c.$, count);
722
+ return;
723
+ }
713
724
  const x = t.open(input(t, c));
714
725
  const length = ($, v, emit) => {
715
726
  const o = t.open(v);
@@ -933,10 +944,15 @@ export function addInto(t, c, $, acc, v, type) {
933
944
  }
934
945
  rule("add", (t, c) => {
935
946
  const type = outputType(t, c);
947
+ // A stage's rows, added as they are made (#1140).
948
+ const rows = c.args.length === 0 && isRows(c.x) ? c.x : undefined;
936
949
  if (type.type === "Null") {
937
950
  // The values' type has no identity to add: jq's null.
938
951
  if (c.args.length === 1)
939
952
  arg(t, c, 0, c.$, c.x, () => { });
953
+ // The rows are made all the same, as the array's were, when making one may raise.
954
+ else if (rows !== undefined && !rows.stops)
955
+ rows.each(c.$, () => { });
940
956
  c.emit(c.$, t.null(c.path));
941
957
  return;
942
958
  }
@@ -946,6 +962,8 @@ rule("add", (t, c) => {
946
962
  const each = ($, v) => addInto(t, c, $, acc, v, type);
947
963
  if (c.args.length === 1)
948
964
  arg(t, c, 0, c.$, c.x, each);
965
+ else if (rows !== undefined)
966
+ rows.each(c.$, each);
949
967
  else
950
968
  t.iterate(c.$, input(t, c), false, c.path, each);
951
969
  c.emit(c.$, acc);
@@ -956,8 +974,22 @@ rule(["any", "all"], (t, c) => {
956
974
  const result = t.declare(c.$, t.bool(!any), "result");
957
975
  const test = ($, v, label) => {
958
976
  const truth = t.truthy(v, c.path);
959
- t.branch($, any ? truth : negate(t, truth, c.path), $2 => { t.assign($2, result, t.bool(any)); t.brk($2, label); }, () => { }, c.path);
977
+ t.branch($, any ? truth : negate(t, truth, c.path), $2 => {
978
+ t.assign($2, result, t.bool(any));
979
+ if (label !== undefined)
980
+ t.brk($2, label);
981
+ }, () => { }, c.path);
960
982
  };
983
+ if (c.args.length === 0 && isRows(c.x)) {
984
+ // A stage's rows, tested as they are made (#1140): the stage stops at the answer, unless making a row may raise.
985
+ const rows = c.x;
986
+ if (rows.stops)
987
+ t.once(c.$, ($, label) => rows.each($, ($2, row) => test($2, row, label)), c.path);
988
+ else
989
+ rows.each(c.$, ($, row) => test($, row, undefined));
990
+ c.emit(c.$, result);
991
+ return;
992
+ }
961
993
  t.once(c.$, ($, label) => {
962
994
  if (c.args.length === 2) {
963
995
  arg(t, c, 0, $, c.x, ($2, g) => arg(t, c, 1, $2, g, ($3, v) => test($3, v, label)));
@@ -1123,21 +1155,27 @@ rule("unique", (t, c) => {
1123
1155
  c.emit(c.$, out);
1124
1156
  });
1125
1157
  rule(["min", "max"], (t, c) => {
1126
- const array = elementsOf(t, c, c.$);
1127
- if (array === undefined) {
1158
+ // A stage's rows, compared as they are made (#1140), or an array's elements.
1159
+ const rows = isRows(c.x) ? c.x : undefined;
1160
+ const array = rows === undefined ? elementsOf(t, c, c.$) : undefined;
1161
+ if (rows === undefined && array === undefined) {
1128
1162
  cannot(t, c, c.$, input(t, c), "an array");
1129
1163
  return;
1130
1164
  }
1131
- const element = t.type(array).value;
1165
+ const element = (rows === undefined ? t.type(array) : parts(rows.type)).value;
1132
1166
  const option = OptionType(element);
1133
1167
  const best = t.declare(c.$, t.none(option), "best");
1134
- t.forEach(c.$, array, ($, item) => {
1168
+ const each = ($, item) => {
1135
1169
  const better = t.matchValue(best, {
1136
1170
  none: () => t.bool(true),
1137
1171
  some: (_$2, b) => c.name === "min" ? t.lt(item, b, c.path) : t.b("GreaterEqual", [element], [item, b], BooleanType, c.path),
1138
1172
  }, BooleanType, c.path);
1139
1173
  t.ifElse($, better, $2 => t.assign($2, best, t.some(item, option)), undefined, c.path);
1140
- }, c.path);
1174
+ };
1175
+ if (rows !== undefined)
1176
+ rows.each(c.$, each);
1177
+ else
1178
+ t.forEach(c.$, array, ($, item) => each($, item), c.path);
1141
1179
  const out = outputType(t, c);
1142
1180
  if (nullablePayload(option) !== undefined) {
1143
1181
  c.emit(c.$, t.widenTo(c.$, best, out, c.path));