@atscript/typescript 0.1.108 → 0.1.109

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/cli.cjs CHANGED
@@ -692,24 +692,44 @@ function _define_property$5(obj, key, value) {
692
692
  * after a validator was created are always honoured — the same as the full walk.
693
693
  *
694
694
  * Result contract (relative to the full walk over the same node and value):
695
- * - `PASS` — the walk returns `true`, collects no errors and has no side effects.
696
- * - `FAIL` — the walk returns `false`; every node the walk would visit was visited
697
- * here too (so a walk that would throw makes this throw first) and the walk has
698
- * no side effects for this node.
695
+ * - `PASS` — the walk returns `true`, collects no errors and has no side effects other
696
+ * than the strips recorded here (see below).
697
+ * - `FAIL` — the walk returns `false`. Inside a union, every node the walk would visit
698
+ * was visited here too (so a walk that would throw makes this throw first) and the
699
+ * walk's only side effects for this node are the strips recorded here. Outside unions
700
+ * a `FAIL` always ends in the walk, so it may be returned early.
699
701
  * - `BAIL` — not decidable here; the caller must run the full walk.
700
702
  *
701
703
  * Union branches are tried in declared order, continuing past `FAIL` and stopping
702
704
  * at `BAIL`, which keeps union results identical to the walk.
705
+ *
706
+ * `unknownProps: 'strip'`: the walk deletes an object's unknown keys right after the object
707
+ * passes (even when an ancestor fails later). This check records those deletions only for
708
+ * the top-level object (`pendingKeys`), whose strip is the walk's last read of the input:
709
+ * deferring an earlier strip past later reads could be observed by them (a prototype, a
710
+ * proxy or an accessor over the stripped object), so a nested object with unknown keys
711
+ * bails, as does any object visit once a strip is pending (a later intersection member).
712
+ * The recorded keys are deleted, in the walk's order, only when the whole value passes —
713
+ * so a `PASS` result still has exactly the walk's side effects, and `FAIL` / `BAIL` leave
714
+ * the value untouched for the walk.
703
715
  */ const FAIL = 0;
704
716
  const PASS = 1;
705
717
  const BAIL = 2;
706
718
  /** Node is at walk depth 0 (only object props / array & tuple items increase depth). */ const TOP = 1;
707
719
  /** Node is inside a union branch — failures must be exhaustive (see contract). */ const IN_UNION = 2;
708
720
  /** Incremented per {@link fastCheckPasses} call; snapshots verified in older calls re-verify. */ let stamp = 0;
721
+ /** A 'strip' {@link fastCheckPasses} call is in progress (the pending strips below are its own). */ let stripping = false;
722
+ /**
723
+ * Unknown keys of the top-level object the walk would delete (`unknownProps: 'strip'`), in
724
+ * the walk's deletion order. Deleted when the call passes, dropped otherwise.
725
+ */ const pendingKeys = [];
709
726
  /**
710
- * `true` only when the full walk over `value` is guaranteed to pass with no errors
711
- * and no side effects. Any other outcome (including a throw) means "run the walk".
727
+ * `true` only when the full walk over `value` is guaranteed to pass with no errors and
728
+ * no side effects other than its 'strip' deletions, which are then performed here, as the
729
+ * walk would. Any other outcome (including a throw) leaves `value` untouched and means
730
+ * "run the walk".
712
731
  */ function fastCheckPasses(def, value, opts) {
732
+ if (opts.unknownProps === "strip") return fastCheckStripping(def, value, opts);
713
733
  stamp++;
714
734
  try {
715
735
  return fastCheck(def, value, TOP, opts) === PASS;
@@ -717,6 +737,25 @@ const BAIL = 2;
717
737
  return false;
718
738
  }
719
739
  }
740
+ /** {@link fastCheckPasses} for `unknownProps: 'strip'`: performs the recorded strips on a pass. */ function fastCheckStripping(def, value, opts) {
741
+ if (stripping) return false;
742
+ stamp++;
743
+ stripping = true;
744
+ let passed;
745
+ try {
746
+ passed = fastCheck(def, value, TOP, opts) === PASS;
747
+ } catch {
748
+ passed = false;
749
+ } finally {
750
+ stripping = false;
751
+ }
752
+ try {
753
+ if (passed) for (const key of pendingKeys) delete value[key];
754
+ } finally {
755
+ pendingKeys.length = 0;
756
+ }
757
+ return passed;
758
+ }
720
759
  const DECIMAL_RE = /^[+-]?\d+(\.\d+)?$/;
721
760
  const regexCache = /* @__PURE__ */ new Map();
722
761
  /** Compiled `@expect.pattern` regex, cached per (pattern, flags). */ function getRegex(pattern, flags) {
@@ -762,6 +801,7 @@ function fastCheck(def, value, flags, opts) {
762
801
  for (const item of type.items) {
763
802
  const result = fastCheck(item, value, branchFlags, opts);
764
803
  if (result !== FAIL) return unionMatchResult(result, item, def.metadata, value);
804
+ if (pendingKeys.length > 0) return BAIL;
765
805
  }
766
806
  return FAIL;
767
807
  }
@@ -838,15 +878,17 @@ function fastCheckString(metadata, value) {
838
878
  }
839
879
  function fastCheckNumber(metadata, value) {
840
880
  if (metadata.size === 0) return PASS;
841
- return numberConstraints(value, metadata.get("expect.int"), metadata.get("expect.min"), metadata.get("expect.max"));
881
+ return numberConstraints(value, metadata.get("expect.int"), metadata.get("expect.min"), metadata.get("expect.max"), metadata.get("expect.exclusiveMin"), metadata.get("expect.exclusiveMax"));
842
882
  }
843
883
  function booleanConstraints(value, required) {
844
884
  return required && value !== true ? FAIL : PASS;
845
885
  }
846
- function numberConstraints(value, int, min, max) {
886
+ function numberConstraints(value, int, min, max, exMin, exMax) {
847
887
  if (int && value % 1 !== 0) return FAIL;
848
888
  if (min !== void 0 && value < (typeof min === "number" ? min : min.minValue)) return FAIL;
849
889
  if (max !== void 0 && value > (typeof max === "number" ? max : max.maxValue)) return FAIL;
890
+ if (exMin !== void 0 && value <= (typeof exMin === "number" ? exMin : exMin.exclusiveMinValue)) return FAIL;
891
+ if (exMax !== void 0 && value >= (typeof exMax === "number" ? exMax : exMax.exclusiveMaxValue)) return FAIL;
850
892
  return PASS;
851
893
  }
852
894
  /** `@expect.minLength` / `@expect.maxLength` (strings and arrays). */ function lengthFails(length, minLength, maxLength) {
@@ -860,9 +902,12 @@ function fastCheckObject(def, value, flags, opts) {
860
902
  if (typeof value !== "object" || value === null || Array.isArray(value)) return FAIL;
861
903
  const type = def.type;
862
904
  if (type.propsPatterns.length > 0) return BAIL;
905
+ if (pendingKeys.length > 0) return BAIL;
906
+ const unknownProps = opts.unknownProps;
907
+ const inUnion = (flags & IN_UNION) !== 0;
908
+ if (unknownProps === "error" && !inUnion && hasUnknownKey(type.props, value)) return FAIL;
863
909
  const partial = opts.partial;
864
910
  const skipUndefined = partial === "deep" || partial === true && (flags & TOP) !== 0;
865
- const inUnion = (flags & IN_UNION) !== 0;
866
911
  const propFlags = flags & IN_UNION;
867
912
  let result = PASS;
868
913
  for (const [key, item] of type.props) {
@@ -876,16 +921,28 @@ function fastCheckObject(def, value, flags, opts) {
876
921
  }
877
922
  }
878
923
  if (result !== PASS) return result;
879
- const unknownProps = opts.unknownProps;
880
- if (unknownProps === "error" || unknownProps === "strip") {
881
- const props = type.props;
882
- for (const key of Object.keys(value)) {
883
- const known = props.get(key);
884
- if (known === void 0 || isPhantomType(known)) return unknownProps === "error" ? FAIL : BAIL;
885
- }
924
+ if (unknownProps === "strip") return pendStrips(type.props, value, flags);
925
+ return unknownProps === "error" && inUnion && hasUnknownKey(type.props, value) ? FAIL : PASS;
926
+ }
927
+ /**
928
+ * Records the unknown keys of a passing top-level object: the walk deletes them at this
929
+ * point, after its last read of the input. A nested object's strip would be followed by
930
+ * more reads, so it is left to the walk.
931
+ */ function pendStrips(props, value, flags) {
932
+ for (const key of Object.keys(value)) if (isUnknownKey(props, key)) {
933
+ if ((flags & TOP) === 0) return BAIL;
934
+ pendingKeys.push(key);
886
935
  }
887
936
  return PASS;
888
937
  }
938
+ /** `true` when `value` has a key the walk treats as unknown. */ function hasUnknownKey(props, value) {
939
+ for (const key of Object.keys(value)) if (isUnknownKey(props, key)) return true;
940
+ return false;
941
+ }
942
+ /** `true` when the walk treats `key` as unknown (no prop, or a phantom one). */ function isUnknownKey(props, key) {
943
+ const known = props.get(key);
944
+ return known === void 0 || isPhantomType(known);
945
+ }
889
946
  function fastCheckArray(def, value, flags, opts) {
890
947
  if (!Array.isArray(value)) return FAIL;
891
948
  const metadata = def.metadata;
@@ -929,7 +986,7 @@ const plans = /* @__PURE__ */ new WeakMap();
929
986
  constructor(def) {
930
987
  _define_property$5(this, "def", void 0);
931
988
  /** Call in which the node structure was last verified (`-1`: must rebuild). */ _define_property$5(this, "stamp", void 0);
932
- /** Call in which the annotation values (`m0`–`m3`) were last verified. */ _define_property$5(this, "metaStamp", void 0);
989
+ /** Call in which the annotation values (`m0`–`m4`) were last verified. */ _define_property$5(this, "metaStamp", void 0);
933
990
  _define_property$5(this, "op", void 0);
934
991
  _define_property$5(this, "type", void 0);
935
992
  _define_property$5(this, "optional", void 0);
@@ -941,15 +998,17 @@ const plans = /* @__PURE__ */ new WeakMap();
941
998
  /**
942
999
  * Annotation keys the node's check reads, and their values (`undefined` when absent):
943
1000
  * string `meta.required, expect.minLength, maxLength, pattern`; number `expect.int, min,
944
- * max`; boolean `meta.required`; array `expect.minLength, maxLength, array.uniqueItems`.
1001
+ * max, exclusiveMin, exclusiveMax`; boolean `meta.required`; array `expect.minLength, maxLength, array.uniqueItems`.
945
1002
  */ _define_property$5(this, "k0", void 0);
946
1003
  _define_property$5(this, "k1", void 0);
947
1004
  _define_property$5(this, "k2", void 0);
948
1005
  _define_property$5(this, "k3", void 0);
1006
+ _define_property$5(this, "k4", void 0);
949
1007
  _define_property$5(this, "m0", void 0);
950
1008
  _define_property$5(this, "m1", void 0);
951
1009
  _define_property$5(this, "m2", void 0);
952
1010
  _define_property$5(this, "m3", void 0);
1011
+ _define_property$5(this, "m4", void 0);
953
1012
  _define_property$5(this, "props", void 0);
954
1013
  _define_property$5(this, "propsPatterns", void 0);
955
1014
  _define_property$5(this, "keys", void 0);
@@ -975,10 +1034,12 @@ const plans = /* @__PURE__ */ new WeakMap();
975
1034
  this.k1 = void 0;
976
1035
  this.k2 = void 0;
977
1036
  this.k3 = void 0;
1037
+ this.k4 = void 0;
978
1038
  this.m0 = void 0;
979
1039
  this.m1 = void 0;
980
1040
  this.m2 = void 0;
981
1041
  this.m3 = void 0;
1042
+ this.m4 = void 0;
982
1043
  this.props = void 0;
983
1044
  this.propsPatterns = void 0;
984
1045
  this.keys = EMPTY;
@@ -1028,7 +1089,7 @@ function planFor(def) {
1028
1089
  }
1029
1090
  /** Brings the annotation values up to date (once per call, when a constraint is read). */ function refreshMeta(plan) {
1030
1091
  const metadata = plan.metadata;
1031
- if (!(metadata.size === 0 ? plan.m0 === void 0 && plan.m1 === void 0 && plan.m2 === void 0 && plan.m3 === void 0 : metadata.get(plan.k0) === plan.m0 && (plan.k1 === void 0 || metadata.get(plan.k1) === plan.m1) && (plan.k2 === void 0 || metadata.get(plan.k2) === plan.m2) && (plan.k3 === void 0 || metadata.get(plan.k3) === plan.m3))) snapshotMeta(plan);
1092
+ if (!(metadata.size === 0 ? plan.m0 === void 0 && plan.m1 === void 0 && plan.m2 === void 0 && plan.m3 === void 0 && plan.m4 === void 0 : metadata.get(plan.k0) === plan.m0 && (plan.k1 === void 0 || metadata.get(plan.k1) === plan.m1) && (plan.k2 === void 0 || metadata.get(plan.k2) === plan.m2) && (plan.k3 === void 0 || metadata.get(plan.k3) === plan.m3) && (plan.k4 === void 0 || metadata.get(plan.k4) === plan.m4))) snapshotMeta(plan);
1032
1093
  plan.metaStamp = stamp;
1033
1094
  }
1034
1095
  function snapshotMeta(plan) {
@@ -1037,12 +1098,14 @@ function snapshotMeta(plan) {
1037
1098
  plan.m1 = metadata.get(plan.k1);
1038
1099
  plan.m2 = metadata.get(plan.k2);
1039
1100
  plan.m3 = metadata.get(plan.k3);
1101
+ plan.m4 = metadata.get(plan.k4);
1040
1102
  }
1041
- function setMetaKeys(plan, k0, k1, k2, k3) {
1103
+ function setMetaKeys(plan, k0, k1, k2, k3, k4) {
1042
1104
  plan.k0 = k0;
1043
1105
  plan.k1 = k1;
1044
1106
  plan.k2 = k2;
1045
1107
  plan.k3 = k3;
1108
+ plan.k4 = k4;
1046
1109
  snapshotMeta(plan);
1047
1110
  plan.metaStamp = stamp;
1048
1111
  }
@@ -1068,7 +1131,7 @@ function setMetaKeys(plan, k0, k1, k2, k3) {
1068
1131
  plan.of = void 0;
1069
1132
  plan.ofPlan = void 0;
1070
1133
  plan.items = void 0;
1071
- setMetaKeys(plan, void 0, void 0, void 0, void 0);
1134
+ setMetaKeys(plan);
1072
1135
  switch (type.kind) {
1073
1136
  case "":
1074
1137
  if (type.designType === "phantom") plan.op = OP_PHANTOM;
@@ -1078,10 +1141,10 @@ function setMetaKeys(plan, k0, k1, k2, k3) {
1078
1141
  plan.regexes = [];
1079
1142
  plan.op = OP_STRING;
1080
1143
  } else if (type.designType === "number") {
1081
- setMetaKeys(plan, "expect.int", "expect.min", "expect.max", void 0);
1144
+ setMetaKeys(plan, "expect.int", "expect.min", "expect.max", "expect.exclusiveMin", "expect.exclusiveMax");
1082
1145
  plan.op = OP_NUMBER;
1083
1146
  } else if (type.designType === "boolean") {
1084
- setMetaKeys(plan, "meta.required", void 0, void 0, void 0);
1147
+ setMetaKeys(plan, "meta.required");
1085
1148
  plan.op = OP_BOOLEAN;
1086
1149
  } else plan.op = OP_FINAL;
1087
1150
  break;
@@ -1107,7 +1170,7 @@ function setMetaKeys(plan, k0, k1, k2, k3) {
1107
1170
  break;
1108
1171
  }
1109
1172
  case "array":
1110
- setMetaKeys(plan, "expect.minLength", "expect.maxLength", "expect.array.uniqueItems", void 0);
1173
+ setMetaKeys(plan, "expect.minLength", "expect.maxLength", "expect.array.uniqueItems");
1111
1174
  plan.of = type.of;
1112
1175
  plan.ofPlan = planFor(type.of);
1113
1176
  plan.op = OP_ARRAY;
@@ -1179,7 +1242,7 @@ function setMetaKeys(plan, k0, k1, k2, k3) {
1179
1242
  }
1180
1243
  /** Plan counterpart of {@link fastCheckNumber}; constraint objects are read live. */ function checkNumber(plan, value) {
1181
1244
  if (plan.metaStamp !== stamp) refreshMeta(plan);
1182
- return numberConstraints(value, plan.m0, plan.m1, plan.m2);
1245
+ return numberConstraints(value, plan.m0, plan.m1, plan.m2, plan.m3, plan.m4);
1183
1246
  }
1184
1247
  /** Plan counterpart of {@link fastCheckObject}. */ function checkObject(plan, value, flags, opts) {
1185
1248
  if (typeof value !== "object" || value === null || Array.isArray(value)) return FAIL;
@@ -1693,7 +1756,7 @@ function _define_property$4(obj, key, value) {
1693
1756
  validateNumber(def, value) {
1694
1757
  return this.validateNumberConstraints(def.metadata, value);
1695
1758
  }
1696
- /** `@expect.int` / `min` / `max` checks for a number value. */ validateNumberConstraints(metadata, value) {
1759
+ /** `@expect.int` / `min` / `max` / `exclusiveMin` / `exclusiveMax` checks for a number value. */ validateNumberConstraints(metadata, value) {
1697
1760
  if (metadata.size === 0) return true;
1698
1761
  const int = metadata.get("expect.int");
1699
1762
  if (int && value % 1 !== 0) {
@@ -1704,23 +1767,30 @@ function _define_property$4(obj, key, value) {
1704
1767
  const min = metadata.get("expect.min");
1705
1768
  if (min !== void 0) {
1706
1769
  const minValue = typeof min === "number" ? min : min.minValue;
1707
- if (value < minValue) {
1708
- const message = typeof min === "object" && min.message ? min.message : `Expected minimum ${minValue}, got ${value}`;
1709
- this.error(message);
1710
- return false;
1711
- }
1770
+ if (value < minValue) return this.numberBoundFailed(min, "minimum", minValue, value);
1712
1771
  }
1713
1772
  const max = metadata.get("expect.max");
1714
1773
  if (max !== void 0) {
1715
1774
  const maxValue = typeof max === "number" ? max : max.maxValue;
1716
- if (value > maxValue) {
1717
- const message = typeof max === "object" && max.message ? max.message : `Expected maximum ${maxValue}, got ${value}`;
1718
- this.error(message);
1719
- return false;
1720
- }
1775
+ if (value > maxValue) return this.numberBoundFailed(max, "maximum", maxValue, value);
1776
+ }
1777
+ const exMin = metadata.get("expect.exclusiveMin");
1778
+ if (exMin !== void 0) {
1779
+ const bound = typeof exMin === "number" ? exMin : exMin.exclusiveMinValue;
1780
+ if (value <= bound) return this.numberBoundFailed(exMin, "greater than", bound, value);
1781
+ }
1782
+ const exMax = metadata.get("expect.exclusiveMax");
1783
+ if (exMax !== void 0) {
1784
+ const bound = typeof exMax === "number" ? exMax : exMax.exclusiveMaxValue;
1785
+ if (value >= bound) return this.numberBoundFailed(exMax, "less than", bound, value);
1721
1786
  }
1722
1787
  return true;
1723
1788
  }
1789
+ /** Reports a failed number bound: its custom message, else `Expected <label> <bound>, got <value>`. */ numberBoundFailed(annotation, label, bound, value) {
1790
+ const message = typeof annotation === "object" && annotation.message ? annotation.message : `Expected ${label} ${bound}, got ${value}`;
1791
+ this.error(message);
1792
+ return false;
1793
+ }
1724
1794
  validateBoolean(def, value) {
1725
1795
  return this.validateBooleanConstraints(def.metadata, value);
1726
1796
  }
@@ -2231,18 +2301,27 @@ function cloneTypeDef(type) {
2231
2301
  }
2232
2302
  if (schema.type === "number" || schema.type === "integer") {
2233
2303
  const min = meta.get("expect.min");
2234
- if (min !== void 0) schema.minimum = typeof min === "number" ? min : min.minValue;
2304
+ if (min !== void 0) schema.minimum = boundOf(min, "minValue");
2235
2305
  const max = meta.get("expect.max");
2236
- if (max !== void 0) schema.maximum = typeof max === "number" ? max : max.maxValue;
2306
+ if (max !== void 0) schema.maximum = boundOf(max, "maxValue");
2307
+ const exMin = meta.get("expect.exclusiveMin");
2308
+ if (exMin !== void 0) schema.exclusiveMinimum = boundOf(exMin, "exclusiveMinValue");
2309
+ const exMax = meta.get("expect.exclusiveMax");
2310
+ if (exMax !== void 0) schema.exclusiveMaximum = boundOf(exMax, "exclusiveMaxValue");
2237
2311
  }
2238
2312
  }
2313
+ /** A number-bound annotation's value: the bare number, or its `field` in the object form. */ function boundOf(m, field) {
2314
+ return typeof m === "number" ? m : m[field];
2315
+ }
2239
2316
  const LOWER_BOUNDS = new Set([
2240
2317
  "minimum",
2318
+ "exclusiveMinimum",
2241
2319
  "minLength",
2242
2320
  "minItems"
2243
2321
  ]);
2244
2322
  const UPPER_BOUNDS = new Set([
2245
2323
  "maximum",
2324
+ "exclusiveMaximum",
2246
2325
  "maxLength",
2247
2326
  "maxItems"
2248
2327
  ]);
@@ -2301,6 +2380,12 @@ const QUERY_OP_MAP = {
2301
2380
  "exists": "$exists",
2302
2381
  "not exists": "$exists"
2303
2382
  };
2383
+ /** Value field of each number-bound annotation's object form. */ const NUMBER_BOUND_FIELDS = {
2384
+ "expect.min": "minValue",
2385
+ "expect.max": "maxValue",
2386
+ "expect.exclusiveMin": "exclusiveMinValue",
2387
+ "expect.exclusiveMax": "exclusiveMaxValue"
2388
+ };
2304
2389
  const SYNTH_IMPORTS_MARKER = "/*@@atscript-synth-imports@@*/";
2305
2390
  var JsRenderer = class extends BaseRenderer {
2306
2391
  /**
@@ -2724,14 +2809,11 @@ var JsRenderer = class extends BaseRenderer {
2724
2809
  });
2725
2810
  break;
2726
2811
  case "expect.min":
2727
- if (a.args[0]) handle.annotate(a.name, {
2728
- minValue: Number(a.args[0].text),
2729
- message: a.args[1]?.text
2730
- });
2731
- break;
2732
2812
  case "expect.max":
2813
+ case "expect.exclusiveMin":
2814
+ case "expect.exclusiveMax":
2733
2815
  if (a.args[0]) handle.annotate(a.name, {
2734
- maxValue: Number(a.args[0].text),
2816
+ [NUMBER_BOUND_FIELDS[a.name]]: Number(a.args[0].text),
2735
2817
  message: a.args[1]?.text
2736
2818
  });
2737
2819
  break;
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
- const require_plugin = require('./plugin-Cv2odCwI.cjs');
3
- require('./json-schema-BqpH_eYJ.cjs');
2
+ const require_plugin = require('./plugin-6r27w6rG.cjs');
3
+ require('./json-schema-9OBvrg9D.cjs');
4
4
 
5
5
  exports.default = require_plugin.tsPlugin;
6
6
  exports.tsPlugin = require_plugin.tsPlugin;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as tsPlugin } from "./plugin-DpfsG4O7.mjs";
2
- import "./json-schema-BtZ_OIcu.mjs";
1
+ import { t as tsPlugin } from "./plugin-D3_BnRrI.mjs";
2
+ import "./json-schema-CioBVi6F.mjs";
3
3
 
4
4
  export { tsPlugin as default, tsPlugin };
@@ -24,24 +24,44 @@ function _define_property$1(obj, key, value) {
24
24
  * after a validator was created are always honoured — the same as the full walk.
25
25
  *
26
26
  * Result contract (relative to the full walk over the same node and value):
27
- * - `PASS` — the walk returns `true`, collects no errors and has no side effects.
28
- * - `FAIL` — the walk returns `false`; every node the walk would visit was visited
29
- * here too (so a walk that would throw makes this throw first) and the walk has
30
- * no side effects for this node.
27
+ * - `PASS` — the walk returns `true`, collects no errors and has no side effects other
28
+ * than the strips recorded here (see below).
29
+ * - `FAIL` — the walk returns `false`. Inside a union, every node the walk would visit
30
+ * was visited here too (so a walk that would throw makes this throw first) and the
31
+ * walk's only side effects for this node are the strips recorded here. Outside unions
32
+ * a `FAIL` always ends in the walk, so it may be returned early.
31
33
  * - `BAIL` — not decidable here; the caller must run the full walk.
32
34
  *
33
35
  * Union branches are tried in declared order, continuing past `FAIL` and stopping
34
36
  * at `BAIL`, which keeps union results identical to the walk.
37
+ *
38
+ * `unknownProps: 'strip'`: the walk deletes an object's unknown keys right after the object
39
+ * passes (even when an ancestor fails later). This check records those deletions only for
40
+ * the top-level object (`pendingKeys`), whose strip is the walk's last read of the input:
41
+ * deferring an earlier strip past later reads could be observed by them (a prototype, a
42
+ * proxy or an accessor over the stripped object), so a nested object with unknown keys
43
+ * bails, as does any object visit once a strip is pending (a later intersection member).
44
+ * The recorded keys are deleted, in the walk's order, only when the whole value passes —
45
+ * so a `PASS` result still has exactly the walk's side effects, and `FAIL` / `BAIL` leave
46
+ * the value untouched for the walk.
35
47
  */ const FAIL = 0;
36
48
  const PASS = 1;
37
49
  const BAIL = 2;
38
50
  /** Node is at walk depth 0 (only object props / array & tuple items increase depth). */ const TOP = 1;
39
51
  /** Node is inside a union branch — failures must be exhaustive (see contract). */ const IN_UNION = 2;
40
52
  /** Incremented per {@link fastCheckPasses} call; snapshots verified in older calls re-verify. */ let stamp = 0;
53
+ /** A 'strip' {@link fastCheckPasses} call is in progress (the pending strips below are its own). */ let stripping = false;
54
+ /**
55
+ * Unknown keys of the top-level object the walk would delete (`unknownProps: 'strip'`), in
56
+ * the walk's deletion order. Deleted when the call passes, dropped otherwise.
57
+ */ const pendingKeys = [];
41
58
  /**
42
- * `true` only when the full walk over `value` is guaranteed to pass with no errors
43
- * and no side effects. Any other outcome (including a throw) means "run the walk".
59
+ * `true` only when the full walk over `value` is guaranteed to pass with no errors and
60
+ * no side effects other than its 'strip' deletions, which are then performed here, as the
61
+ * walk would. Any other outcome (including a throw) leaves `value` untouched and means
62
+ * "run the walk".
44
63
  */ function fastCheckPasses(def, value, opts) {
64
+ if (opts.unknownProps === "strip") return fastCheckStripping(def, value, opts);
45
65
  stamp++;
46
66
  try {
47
67
  return fastCheck(def, value, TOP, opts) === PASS;
@@ -49,6 +69,25 @@ const BAIL = 2;
49
69
  return false;
50
70
  }
51
71
  }
72
+ /** {@link fastCheckPasses} for `unknownProps: 'strip'`: performs the recorded strips on a pass. */ function fastCheckStripping(def, value, opts) {
73
+ if (stripping) return false;
74
+ stamp++;
75
+ stripping = true;
76
+ let passed;
77
+ try {
78
+ passed = fastCheck(def, value, TOP, opts) === PASS;
79
+ } catch {
80
+ passed = false;
81
+ } finally {
82
+ stripping = false;
83
+ }
84
+ try {
85
+ if (passed) for (const key of pendingKeys) delete value[key];
86
+ } finally {
87
+ pendingKeys.length = 0;
88
+ }
89
+ return passed;
90
+ }
52
91
  const DECIMAL_RE = /^[+-]?\d+(\.\d+)?$/;
53
92
  const regexCache = /* @__PURE__ */ new Map();
54
93
  /** Compiled `@expect.pattern` regex, cached per (pattern, flags). */ function getRegex(pattern, flags) {
@@ -94,6 +133,7 @@ function fastCheck(def, value, flags, opts) {
94
133
  for (const item of type.items) {
95
134
  const result = fastCheck(item, value, branchFlags, opts);
96
135
  if (result !== FAIL) return unionMatchResult(result, item, def.metadata, value);
136
+ if (pendingKeys.length > 0) return BAIL;
97
137
  }
98
138
  return FAIL;
99
139
  }
@@ -170,15 +210,17 @@ function fastCheckString(metadata, value) {
170
210
  }
171
211
  function fastCheckNumber(metadata, value) {
172
212
  if (metadata.size === 0) return PASS;
173
- return numberConstraints(value, metadata.get("expect.int"), metadata.get("expect.min"), metadata.get("expect.max"));
213
+ return numberConstraints(value, metadata.get("expect.int"), metadata.get("expect.min"), metadata.get("expect.max"), metadata.get("expect.exclusiveMin"), metadata.get("expect.exclusiveMax"));
174
214
  }
175
215
  function booleanConstraints(value, required) {
176
216
  return required && value !== true ? FAIL : PASS;
177
217
  }
178
- function numberConstraints(value, int, min, max) {
218
+ function numberConstraints(value, int, min, max, exMin, exMax) {
179
219
  if (int && value % 1 !== 0) return FAIL;
180
220
  if (min !== void 0 && value < (typeof min === "number" ? min : min.minValue)) return FAIL;
181
221
  if (max !== void 0 && value > (typeof max === "number" ? max : max.maxValue)) return FAIL;
222
+ if (exMin !== void 0 && value <= (typeof exMin === "number" ? exMin : exMin.exclusiveMinValue)) return FAIL;
223
+ if (exMax !== void 0 && value >= (typeof exMax === "number" ? exMax : exMax.exclusiveMaxValue)) return FAIL;
182
224
  return PASS;
183
225
  }
184
226
  /** `@expect.minLength` / `@expect.maxLength` (strings and arrays). */ function lengthFails(length, minLength, maxLength) {
@@ -192,9 +234,12 @@ function fastCheckObject(def, value, flags, opts) {
192
234
  if (typeof value !== "object" || value === null || Array.isArray(value)) return FAIL;
193
235
  const type = def.type;
194
236
  if (type.propsPatterns.length > 0) return BAIL;
237
+ if (pendingKeys.length > 0) return BAIL;
238
+ const unknownProps = opts.unknownProps;
239
+ const inUnion = (flags & IN_UNION) !== 0;
240
+ if (unknownProps === "error" && !inUnion && hasUnknownKey(type.props, value)) return FAIL;
195
241
  const partial = opts.partial;
196
242
  const skipUndefined = partial === "deep" || partial === true && (flags & TOP) !== 0;
197
- const inUnion = (flags & IN_UNION) !== 0;
198
243
  const propFlags = flags & IN_UNION;
199
244
  let result = PASS;
200
245
  for (const [key, item] of type.props) {
@@ -208,16 +253,28 @@ function fastCheckObject(def, value, flags, opts) {
208
253
  }
209
254
  }
210
255
  if (result !== PASS) return result;
211
- const unknownProps = opts.unknownProps;
212
- if (unknownProps === "error" || unknownProps === "strip") {
213
- const props = type.props;
214
- for (const key of Object.keys(value)) {
215
- const known = props.get(key);
216
- if (known === void 0 || isPhantomType(known)) return unknownProps === "error" ? FAIL : BAIL;
217
- }
256
+ if (unknownProps === "strip") return pendStrips(type.props, value, flags);
257
+ return unknownProps === "error" && inUnion && hasUnknownKey(type.props, value) ? FAIL : PASS;
258
+ }
259
+ /**
260
+ * Records the unknown keys of a passing top-level object: the walk deletes them at this
261
+ * point, after its last read of the input. A nested object's strip would be followed by
262
+ * more reads, so it is left to the walk.
263
+ */ function pendStrips(props, value, flags) {
264
+ for (const key of Object.keys(value)) if (isUnknownKey(props, key)) {
265
+ if ((flags & TOP) === 0) return BAIL;
266
+ pendingKeys.push(key);
218
267
  }
219
268
  return PASS;
220
269
  }
270
+ /** `true` when `value` has a key the walk treats as unknown. */ function hasUnknownKey(props, value) {
271
+ for (const key of Object.keys(value)) if (isUnknownKey(props, key)) return true;
272
+ return false;
273
+ }
274
+ /** `true` when the walk treats `key` as unknown (no prop, or a phantom one). */ function isUnknownKey(props, key) {
275
+ const known = props.get(key);
276
+ return known === void 0 || isPhantomType(known);
277
+ }
221
278
  function fastCheckArray(def, value, flags, opts) {
222
279
  if (!Array.isArray(value)) return FAIL;
223
280
  const metadata = def.metadata;
@@ -261,7 +318,7 @@ const plans = /* @__PURE__ */ new WeakMap();
261
318
  constructor(def) {
262
319
  _define_property$1(this, "def", void 0);
263
320
  /** Call in which the node structure was last verified (`-1`: must rebuild). */ _define_property$1(this, "stamp", void 0);
264
- /** Call in which the annotation values (`m0`–`m3`) were last verified. */ _define_property$1(this, "metaStamp", void 0);
321
+ /** Call in which the annotation values (`m0`–`m4`) were last verified. */ _define_property$1(this, "metaStamp", void 0);
265
322
  _define_property$1(this, "op", void 0);
266
323
  _define_property$1(this, "type", void 0);
267
324
  _define_property$1(this, "optional", void 0);
@@ -273,15 +330,17 @@ const plans = /* @__PURE__ */ new WeakMap();
273
330
  /**
274
331
  * Annotation keys the node's check reads, and their values (`undefined` when absent):
275
332
  * string `meta.required, expect.minLength, maxLength, pattern`; number `expect.int, min,
276
- * max`; boolean `meta.required`; array `expect.minLength, maxLength, array.uniqueItems`.
333
+ * max, exclusiveMin, exclusiveMax`; boolean `meta.required`; array `expect.minLength, maxLength, array.uniqueItems`.
277
334
  */ _define_property$1(this, "k0", void 0);
278
335
  _define_property$1(this, "k1", void 0);
279
336
  _define_property$1(this, "k2", void 0);
280
337
  _define_property$1(this, "k3", void 0);
338
+ _define_property$1(this, "k4", void 0);
281
339
  _define_property$1(this, "m0", void 0);
282
340
  _define_property$1(this, "m1", void 0);
283
341
  _define_property$1(this, "m2", void 0);
284
342
  _define_property$1(this, "m3", void 0);
343
+ _define_property$1(this, "m4", void 0);
285
344
  _define_property$1(this, "props", void 0);
286
345
  _define_property$1(this, "propsPatterns", void 0);
287
346
  _define_property$1(this, "keys", void 0);
@@ -307,10 +366,12 @@ const plans = /* @__PURE__ */ new WeakMap();
307
366
  this.k1 = void 0;
308
367
  this.k2 = void 0;
309
368
  this.k3 = void 0;
369
+ this.k4 = void 0;
310
370
  this.m0 = void 0;
311
371
  this.m1 = void 0;
312
372
  this.m2 = void 0;
313
373
  this.m3 = void 0;
374
+ this.m4 = void 0;
314
375
  this.props = void 0;
315
376
  this.propsPatterns = void 0;
316
377
  this.keys = EMPTY;
@@ -360,7 +421,7 @@ function planFor(def) {
360
421
  }
361
422
  /** Brings the annotation values up to date (once per call, when a constraint is read). */ function refreshMeta(plan) {
362
423
  const metadata = plan.metadata;
363
- if (!(metadata.size === 0 ? plan.m0 === void 0 && plan.m1 === void 0 && plan.m2 === void 0 && plan.m3 === void 0 : metadata.get(plan.k0) === plan.m0 && (plan.k1 === void 0 || metadata.get(plan.k1) === plan.m1) && (plan.k2 === void 0 || metadata.get(plan.k2) === plan.m2) && (plan.k3 === void 0 || metadata.get(plan.k3) === plan.m3))) snapshotMeta(plan);
424
+ if (!(metadata.size === 0 ? plan.m0 === void 0 && plan.m1 === void 0 && plan.m2 === void 0 && plan.m3 === void 0 && plan.m4 === void 0 : metadata.get(plan.k0) === plan.m0 && (plan.k1 === void 0 || metadata.get(plan.k1) === plan.m1) && (plan.k2 === void 0 || metadata.get(plan.k2) === plan.m2) && (plan.k3 === void 0 || metadata.get(plan.k3) === plan.m3) && (plan.k4 === void 0 || metadata.get(plan.k4) === plan.m4))) snapshotMeta(plan);
364
425
  plan.metaStamp = stamp;
365
426
  }
366
427
  function snapshotMeta(plan) {
@@ -369,12 +430,14 @@ function snapshotMeta(plan) {
369
430
  plan.m1 = metadata.get(plan.k1);
370
431
  plan.m2 = metadata.get(plan.k2);
371
432
  plan.m3 = metadata.get(plan.k3);
433
+ plan.m4 = metadata.get(plan.k4);
372
434
  }
373
- function setMetaKeys(plan, k0, k1, k2, k3) {
435
+ function setMetaKeys(plan, k0, k1, k2, k3, k4) {
374
436
  plan.k0 = k0;
375
437
  plan.k1 = k1;
376
438
  plan.k2 = k2;
377
439
  plan.k3 = k3;
440
+ plan.k4 = k4;
378
441
  snapshotMeta(plan);
379
442
  plan.metaStamp = stamp;
380
443
  }
@@ -400,7 +463,7 @@ function setMetaKeys(plan, k0, k1, k2, k3) {
400
463
  plan.of = void 0;
401
464
  plan.ofPlan = void 0;
402
465
  plan.items = void 0;
403
- setMetaKeys(plan, void 0, void 0, void 0, void 0);
466
+ setMetaKeys(plan);
404
467
  switch (type.kind) {
405
468
  case "":
406
469
  if (type.designType === "phantom") plan.op = OP_PHANTOM;
@@ -410,10 +473,10 @@ function setMetaKeys(plan, k0, k1, k2, k3) {
410
473
  plan.regexes = [];
411
474
  plan.op = OP_STRING;
412
475
  } else if (type.designType === "number") {
413
- setMetaKeys(plan, "expect.int", "expect.min", "expect.max", void 0);
476
+ setMetaKeys(plan, "expect.int", "expect.min", "expect.max", "expect.exclusiveMin", "expect.exclusiveMax");
414
477
  plan.op = OP_NUMBER;
415
478
  } else if (type.designType === "boolean") {
416
- setMetaKeys(plan, "meta.required", void 0, void 0, void 0);
479
+ setMetaKeys(plan, "meta.required");
417
480
  plan.op = OP_BOOLEAN;
418
481
  } else plan.op = OP_FINAL;
419
482
  break;
@@ -439,7 +502,7 @@ function setMetaKeys(plan, k0, k1, k2, k3) {
439
502
  break;
440
503
  }
441
504
  case "array":
442
- setMetaKeys(plan, "expect.minLength", "expect.maxLength", "expect.array.uniqueItems", void 0);
505
+ setMetaKeys(plan, "expect.minLength", "expect.maxLength", "expect.array.uniqueItems");
443
506
  plan.of = type.of;
444
507
  plan.ofPlan = planFor(type.of);
445
508
  plan.op = OP_ARRAY;
@@ -511,7 +574,7 @@ function setMetaKeys(plan, k0, k1, k2, k3) {
511
574
  }
512
575
  /** Plan counterpart of {@link fastCheckNumber}; constraint objects are read live. */ function checkNumber(plan, value) {
513
576
  if (plan.metaStamp !== stamp) refreshMeta(plan);
514
- return numberConstraints(value, plan.m0, plan.m1, plan.m2);
577
+ return numberConstraints(value, plan.m0, plan.m1, plan.m2, plan.m3, plan.m4);
515
578
  }
516
579
  /** Plan counterpart of {@link fastCheckObject}. */ function checkObject(plan, value, flags, opts) {
517
580
  if (typeof value !== "object" || value === null || Array.isArray(value)) return FAIL;
@@ -1025,7 +1088,7 @@ function _define_property(obj, key, value) {
1025
1088
  validateNumber(def, value) {
1026
1089
  return this.validateNumberConstraints(def.metadata, value);
1027
1090
  }
1028
- /** `@expect.int` / `min` / `max` checks for a number value. */ validateNumberConstraints(metadata, value) {
1091
+ /** `@expect.int` / `min` / `max` / `exclusiveMin` / `exclusiveMax` checks for a number value. */ validateNumberConstraints(metadata, value) {
1029
1092
  if (metadata.size === 0) return true;
1030
1093
  const int = metadata.get("expect.int");
1031
1094
  if (int && value % 1 !== 0) {
@@ -1036,23 +1099,30 @@ function _define_property(obj, key, value) {
1036
1099
  const min = metadata.get("expect.min");
1037
1100
  if (min !== void 0) {
1038
1101
  const minValue = typeof min === "number" ? min : min.minValue;
1039
- if (value < minValue) {
1040
- const message = typeof min === "object" && min.message ? min.message : `Expected minimum ${minValue}, got ${value}`;
1041
- this.error(message);
1042
- return false;
1043
- }
1102
+ if (value < minValue) return this.numberBoundFailed(min, "minimum", minValue, value);
1044
1103
  }
1045
1104
  const max = metadata.get("expect.max");
1046
1105
  if (max !== void 0) {
1047
1106
  const maxValue = typeof max === "number" ? max : max.maxValue;
1048
- if (value > maxValue) {
1049
- const message = typeof max === "object" && max.message ? max.message : `Expected maximum ${maxValue}, got ${value}`;
1050
- this.error(message);
1051
- return false;
1052
- }
1107
+ if (value > maxValue) return this.numberBoundFailed(max, "maximum", maxValue, value);
1108
+ }
1109
+ const exMin = metadata.get("expect.exclusiveMin");
1110
+ if (exMin !== void 0) {
1111
+ const bound = typeof exMin === "number" ? exMin : exMin.exclusiveMinValue;
1112
+ if (value <= bound) return this.numberBoundFailed(exMin, "greater than", bound, value);
1113
+ }
1114
+ const exMax = metadata.get("expect.exclusiveMax");
1115
+ if (exMax !== void 0) {
1116
+ const bound = typeof exMax === "number" ? exMax : exMax.exclusiveMaxValue;
1117
+ if (value >= bound) return this.numberBoundFailed(exMax, "less than", bound, value);
1053
1118
  }
1054
1119
  return true;
1055
1120
  }
1121
+ /** Reports a failed number bound: its custom message, else `Expected <label> <bound>, got <value>`. */ numberBoundFailed(annotation, label, bound, value) {
1122
+ const message = typeof annotation === "object" && annotation.message ? annotation.message : `Expected ${label} ${bound}, got ${value}`;
1123
+ this.error(message);
1124
+ return false;
1125
+ }
1056
1126
  validateBoolean(def, value) {
1057
1127
  return this.validateBooleanConstraints(def.metadata, value);
1058
1128
  }
@@ -1593,18 +1663,27 @@ function cloneTypeDef(type) {
1593
1663
  }
1594
1664
  if (schema.type === "number" || schema.type === "integer") {
1595
1665
  const min = meta.get("expect.min");
1596
- if (min !== void 0) schema.minimum = typeof min === "number" ? min : min.minValue;
1666
+ if (min !== void 0) schema.minimum = boundOf(min, "minValue");
1597
1667
  const max = meta.get("expect.max");
1598
- if (max !== void 0) schema.maximum = typeof max === "number" ? max : max.maxValue;
1668
+ if (max !== void 0) schema.maximum = boundOf(max, "maxValue");
1669
+ const exMin = meta.get("expect.exclusiveMin");
1670
+ if (exMin !== void 0) schema.exclusiveMinimum = boundOf(exMin, "exclusiveMinValue");
1671
+ const exMax = meta.get("expect.exclusiveMax");
1672
+ if (exMax !== void 0) schema.exclusiveMaximum = boundOf(exMax, "exclusiveMaxValue");
1599
1673
  }
1600
1674
  }
1675
+ /** A number-bound annotation's value: the bare number, or its `field` in the object form. */ function boundOf(m, field) {
1676
+ return typeof m === "number" ? m : m[field];
1677
+ }
1601
1678
  const LOWER_BOUNDS = new Set([
1602
1679
  "minimum",
1680
+ "exclusiveMinimum",
1603
1681
  "minLength",
1604
1682
  "minItems"
1605
1683
  ]);
1606
1684
  const UPPER_BOUNDS = new Set([
1607
1685
  "maximum",
1686
+ "exclusiveMaximum",
1608
1687
  "maxLength",
1609
1688
  "maxItems"
1610
1689
  ]);
@@ -1744,14 +1823,12 @@ const UPPER_BOUNDS = new Set([
1744
1823
  if (s.type === "integer") {
1745
1824
  const handle = defineAnnotatedType().designType("number").tags("number");
1746
1825
  handle.annotate("expect.int", true);
1747
- if (typeof s.minimum === "number") handle.annotate("expect.min", { minValue: s.minimum });
1748
- if (typeof s.maximum === "number") handle.annotate("expect.max", { maxValue: s.maximum });
1826
+ annotateNumberBounds(handle, s);
1749
1827
  return handle.$type;
1750
1828
  }
1751
1829
  if (s.type === "number") {
1752
1830
  const handle = defineAnnotatedType().designType("number").tags("number");
1753
- if (typeof s.minimum === "number") handle.annotate("expect.min", { minValue: s.minimum });
1754
- if (typeof s.maximum === "number") handle.annotate("expect.max", { maxValue: s.maximum });
1831
+ annotateNumberBounds(handle, s);
1755
1832
  return handle.$type;
1756
1833
  }
1757
1834
  if (s.type === "boolean") return defineAnnotatedType().designType("boolean").tags("boolean").$type;
@@ -1761,6 +1838,18 @@ const UPPER_BOUNDS = new Set([
1761
1838
  return convert(schema);
1762
1839
  }
1763
1840
  /**
1841
+ * Maps `minimum` / `maximum` / `exclusiveMinimum` / `exclusiveMaximum` onto
1842
+ * `@expect.min` / `max` / `exclusiveMin` / `exclusiveMax`. Also reads the draft-4 form,
1843
+ * where `exclusiveMinimum: true` makes `minimum` exclusive.
1844
+ */ function annotateNumberBounds(handle, s) {
1845
+ if (typeof s.minimum === "number") if (s.exclusiveMinimum === true) handle.annotate("expect.exclusiveMin", { exclusiveMinValue: s.minimum });
1846
+ else handle.annotate("expect.min", { minValue: s.minimum });
1847
+ if (typeof s.maximum === "number") if (s.exclusiveMaximum === true) handle.annotate("expect.exclusiveMax", { exclusiveMaxValue: s.maximum });
1848
+ else handle.annotate("expect.max", { maxValue: s.maximum });
1849
+ if (typeof s.exclusiveMinimum === "number") handle.annotate("expect.exclusiveMin", { exclusiveMinValue: s.exclusiveMinimum });
1850
+ if (typeof s.exclusiveMaximum === "number") handle.annotate("expect.exclusiveMax", { exclusiveMaxValue: s.exclusiveMaximum });
1851
+ }
1852
+ /**
1764
1853
  * Merges multiple annotated types into a combined schema map with shared `$defs`.
1765
1854
  *
1766
1855
  * Each type must have an `id`. The returned `schemas` object contains individual
@@ -23,24 +23,44 @@ function _define_property$1(obj, key, value) {
23
23
  * after a validator was created are always honoured — the same as the full walk.
24
24
  *
25
25
  * Result contract (relative to the full walk over the same node and value):
26
- * - `PASS` — the walk returns `true`, collects no errors and has no side effects.
27
- * - `FAIL` — the walk returns `false`; every node the walk would visit was visited
28
- * here too (so a walk that would throw makes this throw first) and the walk has
29
- * no side effects for this node.
26
+ * - `PASS` — the walk returns `true`, collects no errors and has no side effects other
27
+ * than the strips recorded here (see below).
28
+ * - `FAIL` — the walk returns `false`. Inside a union, every node the walk would visit
29
+ * was visited here too (so a walk that would throw makes this throw first) and the
30
+ * walk's only side effects for this node are the strips recorded here. Outside unions
31
+ * a `FAIL` always ends in the walk, so it may be returned early.
30
32
  * - `BAIL` — not decidable here; the caller must run the full walk.
31
33
  *
32
34
  * Union branches are tried in declared order, continuing past `FAIL` and stopping
33
35
  * at `BAIL`, which keeps union results identical to the walk.
36
+ *
37
+ * `unknownProps: 'strip'`: the walk deletes an object's unknown keys right after the object
38
+ * passes (even when an ancestor fails later). This check records those deletions only for
39
+ * the top-level object (`pendingKeys`), whose strip is the walk's last read of the input:
40
+ * deferring an earlier strip past later reads could be observed by them (a prototype, a
41
+ * proxy or an accessor over the stripped object), so a nested object with unknown keys
42
+ * bails, as does any object visit once a strip is pending (a later intersection member).
43
+ * The recorded keys are deleted, in the walk's order, only when the whole value passes —
44
+ * so a `PASS` result still has exactly the walk's side effects, and `FAIL` / `BAIL` leave
45
+ * the value untouched for the walk.
34
46
  */ const FAIL = 0;
35
47
  const PASS = 1;
36
48
  const BAIL = 2;
37
49
  /** Node is at walk depth 0 (only object props / array & tuple items increase depth). */ const TOP = 1;
38
50
  /** Node is inside a union branch — failures must be exhaustive (see contract). */ const IN_UNION = 2;
39
51
  /** Incremented per {@link fastCheckPasses} call; snapshots verified in older calls re-verify. */ let stamp = 0;
52
+ /** A 'strip' {@link fastCheckPasses} call is in progress (the pending strips below are its own). */ let stripping = false;
53
+ /**
54
+ * Unknown keys of the top-level object the walk would delete (`unknownProps: 'strip'`), in
55
+ * the walk's deletion order. Deleted when the call passes, dropped otherwise.
56
+ */ const pendingKeys = [];
40
57
  /**
41
- * `true` only when the full walk over `value` is guaranteed to pass with no errors
42
- * and no side effects. Any other outcome (including a throw) means "run the walk".
58
+ * `true` only when the full walk over `value` is guaranteed to pass with no errors and
59
+ * no side effects other than its 'strip' deletions, which are then performed here, as the
60
+ * walk would. Any other outcome (including a throw) leaves `value` untouched and means
61
+ * "run the walk".
43
62
  */ function fastCheckPasses(def, value, opts) {
63
+ if (opts.unknownProps === "strip") return fastCheckStripping(def, value, opts);
44
64
  stamp++;
45
65
  try {
46
66
  return fastCheck(def, value, TOP, opts) === PASS;
@@ -48,6 +68,25 @@ const BAIL = 2;
48
68
  return false;
49
69
  }
50
70
  }
71
+ /** {@link fastCheckPasses} for `unknownProps: 'strip'`: performs the recorded strips on a pass. */ function fastCheckStripping(def, value, opts) {
72
+ if (stripping) return false;
73
+ stamp++;
74
+ stripping = true;
75
+ let passed;
76
+ try {
77
+ passed = fastCheck(def, value, TOP, opts) === PASS;
78
+ } catch {
79
+ passed = false;
80
+ } finally {
81
+ stripping = false;
82
+ }
83
+ try {
84
+ if (passed) for (const key of pendingKeys) delete value[key];
85
+ } finally {
86
+ pendingKeys.length = 0;
87
+ }
88
+ return passed;
89
+ }
51
90
  const DECIMAL_RE = /^[+-]?\d+(\.\d+)?$/;
52
91
  const regexCache = /* @__PURE__ */ new Map();
53
92
  /** Compiled `@expect.pattern` regex, cached per (pattern, flags). */ function getRegex(pattern, flags) {
@@ -93,6 +132,7 @@ function fastCheck(def, value, flags, opts) {
93
132
  for (const item of type.items) {
94
133
  const result = fastCheck(item, value, branchFlags, opts);
95
134
  if (result !== FAIL) return unionMatchResult(result, item, def.metadata, value);
135
+ if (pendingKeys.length > 0) return BAIL;
96
136
  }
97
137
  return FAIL;
98
138
  }
@@ -169,15 +209,17 @@ function fastCheckString(metadata, value) {
169
209
  }
170
210
  function fastCheckNumber(metadata, value) {
171
211
  if (metadata.size === 0) return PASS;
172
- return numberConstraints(value, metadata.get("expect.int"), metadata.get("expect.min"), metadata.get("expect.max"));
212
+ return numberConstraints(value, metadata.get("expect.int"), metadata.get("expect.min"), metadata.get("expect.max"), metadata.get("expect.exclusiveMin"), metadata.get("expect.exclusiveMax"));
173
213
  }
174
214
  function booleanConstraints(value, required) {
175
215
  return required && value !== true ? FAIL : PASS;
176
216
  }
177
- function numberConstraints(value, int, min, max) {
217
+ function numberConstraints(value, int, min, max, exMin, exMax) {
178
218
  if (int && value % 1 !== 0) return FAIL;
179
219
  if (min !== void 0 && value < (typeof min === "number" ? min : min.minValue)) return FAIL;
180
220
  if (max !== void 0 && value > (typeof max === "number" ? max : max.maxValue)) return FAIL;
221
+ if (exMin !== void 0 && value <= (typeof exMin === "number" ? exMin : exMin.exclusiveMinValue)) return FAIL;
222
+ if (exMax !== void 0 && value >= (typeof exMax === "number" ? exMax : exMax.exclusiveMaxValue)) return FAIL;
181
223
  return PASS;
182
224
  }
183
225
  /** `@expect.minLength` / `@expect.maxLength` (strings and arrays). */ function lengthFails(length, minLength, maxLength) {
@@ -191,9 +233,12 @@ function fastCheckObject(def, value, flags, opts) {
191
233
  if (typeof value !== "object" || value === null || Array.isArray(value)) return FAIL;
192
234
  const type = def.type;
193
235
  if (type.propsPatterns.length > 0) return BAIL;
236
+ if (pendingKeys.length > 0) return BAIL;
237
+ const unknownProps = opts.unknownProps;
238
+ const inUnion = (flags & IN_UNION) !== 0;
239
+ if (unknownProps === "error" && !inUnion && hasUnknownKey(type.props, value)) return FAIL;
194
240
  const partial = opts.partial;
195
241
  const skipUndefined = partial === "deep" || partial === true && (flags & TOP) !== 0;
196
- const inUnion = (flags & IN_UNION) !== 0;
197
242
  const propFlags = flags & IN_UNION;
198
243
  let result = PASS;
199
244
  for (const [key, item] of type.props) {
@@ -207,16 +252,28 @@ function fastCheckObject(def, value, flags, opts) {
207
252
  }
208
253
  }
209
254
  if (result !== PASS) return result;
210
- const unknownProps = opts.unknownProps;
211
- if (unknownProps === "error" || unknownProps === "strip") {
212
- const props = type.props;
213
- for (const key of Object.keys(value)) {
214
- const known = props.get(key);
215
- if (known === void 0 || isPhantomType(known)) return unknownProps === "error" ? FAIL : BAIL;
216
- }
255
+ if (unknownProps === "strip") return pendStrips(type.props, value, flags);
256
+ return unknownProps === "error" && inUnion && hasUnknownKey(type.props, value) ? FAIL : PASS;
257
+ }
258
+ /**
259
+ * Records the unknown keys of a passing top-level object: the walk deletes them at this
260
+ * point, after its last read of the input. A nested object's strip would be followed by
261
+ * more reads, so it is left to the walk.
262
+ */ function pendStrips(props, value, flags) {
263
+ for (const key of Object.keys(value)) if (isUnknownKey(props, key)) {
264
+ if ((flags & TOP) === 0) return BAIL;
265
+ pendingKeys.push(key);
217
266
  }
218
267
  return PASS;
219
268
  }
269
+ /** `true` when `value` has a key the walk treats as unknown. */ function hasUnknownKey(props, value) {
270
+ for (const key of Object.keys(value)) if (isUnknownKey(props, key)) return true;
271
+ return false;
272
+ }
273
+ /** `true` when the walk treats `key` as unknown (no prop, or a phantom one). */ function isUnknownKey(props, key) {
274
+ const known = props.get(key);
275
+ return known === void 0 || isPhantomType(known);
276
+ }
220
277
  function fastCheckArray(def, value, flags, opts) {
221
278
  if (!Array.isArray(value)) return FAIL;
222
279
  const metadata = def.metadata;
@@ -260,7 +317,7 @@ const plans = /* @__PURE__ */ new WeakMap();
260
317
  constructor(def) {
261
318
  _define_property$1(this, "def", void 0);
262
319
  /** Call in which the node structure was last verified (`-1`: must rebuild). */ _define_property$1(this, "stamp", void 0);
263
- /** Call in which the annotation values (`m0`–`m3`) were last verified. */ _define_property$1(this, "metaStamp", void 0);
320
+ /** Call in which the annotation values (`m0`–`m4`) were last verified. */ _define_property$1(this, "metaStamp", void 0);
264
321
  _define_property$1(this, "op", void 0);
265
322
  _define_property$1(this, "type", void 0);
266
323
  _define_property$1(this, "optional", void 0);
@@ -272,15 +329,17 @@ const plans = /* @__PURE__ */ new WeakMap();
272
329
  /**
273
330
  * Annotation keys the node's check reads, and their values (`undefined` when absent):
274
331
  * string `meta.required, expect.minLength, maxLength, pattern`; number `expect.int, min,
275
- * max`; boolean `meta.required`; array `expect.minLength, maxLength, array.uniqueItems`.
332
+ * max, exclusiveMin, exclusiveMax`; boolean `meta.required`; array `expect.minLength, maxLength, array.uniqueItems`.
276
333
  */ _define_property$1(this, "k0", void 0);
277
334
  _define_property$1(this, "k1", void 0);
278
335
  _define_property$1(this, "k2", void 0);
279
336
  _define_property$1(this, "k3", void 0);
337
+ _define_property$1(this, "k4", void 0);
280
338
  _define_property$1(this, "m0", void 0);
281
339
  _define_property$1(this, "m1", void 0);
282
340
  _define_property$1(this, "m2", void 0);
283
341
  _define_property$1(this, "m3", void 0);
342
+ _define_property$1(this, "m4", void 0);
284
343
  _define_property$1(this, "props", void 0);
285
344
  _define_property$1(this, "propsPatterns", void 0);
286
345
  _define_property$1(this, "keys", void 0);
@@ -306,10 +365,12 @@ const plans = /* @__PURE__ */ new WeakMap();
306
365
  this.k1 = void 0;
307
366
  this.k2 = void 0;
308
367
  this.k3 = void 0;
368
+ this.k4 = void 0;
309
369
  this.m0 = void 0;
310
370
  this.m1 = void 0;
311
371
  this.m2 = void 0;
312
372
  this.m3 = void 0;
373
+ this.m4 = void 0;
313
374
  this.props = void 0;
314
375
  this.propsPatterns = void 0;
315
376
  this.keys = EMPTY;
@@ -359,7 +420,7 @@ function planFor(def) {
359
420
  }
360
421
  /** Brings the annotation values up to date (once per call, when a constraint is read). */ function refreshMeta(plan) {
361
422
  const metadata = plan.metadata;
362
- if (!(metadata.size === 0 ? plan.m0 === void 0 && plan.m1 === void 0 && plan.m2 === void 0 && plan.m3 === void 0 : metadata.get(plan.k0) === plan.m0 && (plan.k1 === void 0 || metadata.get(plan.k1) === plan.m1) && (plan.k2 === void 0 || metadata.get(plan.k2) === plan.m2) && (plan.k3 === void 0 || metadata.get(plan.k3) === plan.m3))) snapshotMeta(plan);
423
+ if (!(metadata.size === 0 ? plan.m0 === void 0 && plan.m1 === void 0 && plan.m2 === void 0 && plan.m3 === void 0 && plan.m4 === void 0 : metadata.get(plan.k0) === plan.m0 && (plan.k1 === void 0 || metadata.get(plan.k1) === plan.m1) && (plan.k2 === void 0 || metadata.get(plan.k2) === plan.m2) && (plan.k3 === void 0 || metadata.get(plan.k3) === plan.m3) && (plan.k4 === void 0 || metadata.get(plan.k4) === plan.m4))) snapshotMeta(plan);
363
424
  plan.metaStamp = stamp;
364
425
  }
365
426
  function snapshotMeta(plan) {
@@ -368,12 +429,14 @@ function snapshotMeta(plan) {
368
429
  plan.m1 = metadata.get(plan.k1);
369
430
  plan.m2 = metadata.get(plan.k2);
370
431
  plan.m3 = metadata.get(plan.k3);
432
+ plan.m4 = metadata.get(plan.k4);
371
433
  }
372
- function setMetaKeys(plan, k0, k1, k2, k3) {
434
+ function setMetaKeys(plan, k0, k1, k2, k3, k4) {
373
435
  plan.k0 = k0;
374
436
  plan.k1 = k1;
375
437
  plan.k2 = k2;
376
438
  plan.k3 = k3;
439
+ plan.k4 = k4;
377
440
  snapshotMeta(plan);
378
441
  plan.metaStamp = stamp;
379
442
  }
@@ -399,7 +462,7 @@ function setMetaKeys(plan, k0, k1, k2, k3) {
399
462
  plan.of = void 0;
400
463
  plan.ofPlan = void 0;
401
464
  plan.items = void 0;
402
- setMetaKeys(plan, void 0, void 0, void 0, void 0);
465
+ setMetaKeys(plan);
403
466
  switch (type.kind) {
404
467
  case "":
405
468
  if (type.designType === "phantom") plan.op = OP_PHANTOM;
@@ -409,10 +472,10 @@ function setMetaKeys(plan, k0, k1, k2, k3) {
409
472
  plan.regexes = [];
410
473
  plan.op = OP_STRING;
411
474
  } else if (type.designType === "number") {
412
- setMetaKeys(plan, "expect.int", "expect.min", "expect.max", void 0);
475
+ setMetaKeys(plan, "expect.int", "expect.min", "expect.max", "expect.exclusiveMin", "expect.exclusiveMax");
413
476
  plan.op = OP_NUMBER;
414
477
  } else if (type.designType === "boolean") {
415
- setMetaKeys(plan, "meta.required", void 0, void 0, void 0);
478
+ setMetaKeys(plan, "meta.required");
416
479
  plan.op = OP_BOOLEAN;
417
480
  } else plan.op = OP_FINAL;
418
481
  break;
@@ -438,7 +501,7 @@ function setMetaKeys(plan, k0, k1, k2, k3) {
438
501
  break;
439
502
  }
440
503
  case "array":
441
- setMetaKeys(plan, "expect.minLength", "expect.maxLength", "expect.array.uniqueItems", void 0);
504
+ setMetaKeys(plan, "expect.minLength", "expect.maxLength", "expect.array.uniqueItems");
442
505
  plan.of = type.of;
443
506
  plan.ofPlan = planFor(type.of);
444
507
  plan.op = OP_ARRAY;
@@ -510,7 +573,7 @@ function setMetaKeys(plan, k0, k1, k2, k3) {
510
573
  }
511
574
  /** Plan counterpart of {@link fastCheckNumber}; constraint objects are read live. */ function checkNumber(plan, value) {
512
575
  if (plan.metaStamp !== stamp) refreshMeta(plan);
513
- return numberConstraints(value, plan.m0, plan.m1, plan.m2);
576
+ return numberConstraints(value, plan.m0, plan.m1, plan.m2, plan.m3, plan.m4);
514
577
  }
515
578
  /** Plan counterpart of {@link fastCheckObject}. */ function checkObject(plan, value, flags, opts) {
516
579
  if (typeof value !== "object" || value === null || Array.isArray(value)) return FAIL;
@@ -1024,7 +1087,7 @@ function _define_property(obj, key, value) {
1024
1087
  validateNumber(def, value) {
1025
1088
  return this.validateNumberConstraints(def.metadata, value);
1026
1089
  }
1027
- /** `@expect.int` / `min` / `max` checks for a number value. */ validateNumberConstraints(metadata, value) {
1090
+ /** `@expect.int` / `min` / `max` / `exclusiveMin` / `exclusiveMax` checks for a number value. */ validateNumberConstraints(metadata, value) {
1028
1091
  if (metadata.size === 0) return true;
1029
1092
  const int = metadata.get("expect.int");
1030
1093
  if (int && value % 1 !== 0) {
@@ -1035,23 +1098,30 @@ function _define_property(obj, key, value) {
1035
1098
  const min = metadata.get("expect.min");
1036
1099
  if (min !== void 0) {
1037
1100
  const minValue = typeof min === "number" ? min : min.minValue;
1038
- if (value < minValue) {
1039
- const message = typeof min === "object" && min.message ? min.message : `Expected minimum ${minValue}, got ${value}`;
1040
- this.error(message);
1041
- return false;
1042
- }
1101
+ if (value < minValue) return this.numberBoundFailed(min, "minimum", minValue, value);
1043
1102
  }
1044
1103
  const max = metadata.get("expect.max");
1045
1104
  if (max !== void 0) {
1046
1105
  const maxValue = typeof max === "number" ? max : max.maxValue;
1047
- if (value > maxValue) {
1048
- const message = typeof max === "object" && max.message ? max.message : `Expected maximum ${maxValue}, got ${value}`;
1049
- this.error(message);
1050
- return false;
1051
- }
1106
+ if (value > maxValue) return this.numberBoundFailed(max, "maximum", maxValue, value);
1107
+ }
1108
+ const exMin = metadata.get("expect.exclusiveMin");
1109
+ if (exMin !== void 0) {
1110
+ const bound = typeof exMin === "number" ? exMin : exMin.exclusiveMinValue;
1111
+ if (value <= bound) return this.numberBoundFailed(exMin, "greater than", bound, value);
1112
+ }
1113
+ const exMax = metadata.get("expect.exclusiveMax");
1114
+ if (exMax !== void 0) {
1115
+ const bound = typeof exMax === "number" ? exMax : exMax.exclusiveMaxValue;
1116
+ if (value >= bound) return this.numberBoundFailed(exMax, "less than", bound, value);
1052
1117
  }
1053
1118
  return true;
1054
1119
  }
1120
+ /** Reports a failed number bound: its custom message, else `Expected <label> <bound>, got <value>`. */ numberBoundFailed(annotation, label, bound, value) {
1121
+ const message = typeof annotation === "object" && annotation.message ? annotation.message : `Expected ${label} ${bound}, got ${value}`;
1122
+ this.error(message);
1123
+ return false;
1124
+ }
1055
1125
  validateBoolean(def, value) {
1056
1126
  return this.validateBooleanConstraints(def.metadata, value);
1057
1127
  }
@@ -1592,18 +1662,27 @@ function cloneTypeDef(type) {
1592
1662
  }
1593
1663
  if (schema.type === "number" || schema.type === "integer") {
1594
1664
  const min = meta.get("expect.min");
1595
- if (min !== void 0) schema.minimum = typeof min === "number" ? min : min.minValue;
1665
+ if (min !== void 0) schema.minimum = boundOf(min, "minValue");
1596
1666
  const max = meta.get("expect.max");
1597
- if (max !== void 0) schema.maximum = typeof max === "number" ? max : max.maxValue;
1667
+ if (max !== void 0) schema.maximum = boundOf(max, "maxValue");
1668
+ const exMin = meta.get("expect.exclusiveMin");
1669
+ if (exMin !== void 0) schema.exclusiveMinimum = boundOf(exMin, "exclusiveMinValue");
1670
+ const exMax = meta.get("expect.exclusiveMax");
1671
+ if (exMax !== void 0) schema.exclusiveMaximum = boundOf(exMax, "exclusiveMaxValue");
1598
1672
  }
1599
1673
  }
1674
+ /** A number-bound annotation's value: the bare number, or its `field` in the object form. */ function boundOf(m, field) {
1675
+ return typeof m === "number" ? m : m[field];
1676
+ }
1600
1677
  const LOWER_BOUNDS = new Set([
1601
1678
  "minimum",
1679
+ "exclusiveMinimum",
1602
1680
  "minLength",
1603
1681
  "minItems"
1604
1682
  ]);
1605
1683
  const UPPER_BOUNDS = new Set([
1606
1684
  "maximum",
1685
+ "exclusiveMaximum",
1607
1686
  "maxLength",
1608
1687
  "maxItems"
1609
1688
  ]);
@@ -1743,14 +1822,12 @@ const UPPER_BOUNDS = new Set([
1743
1822
  if (s.type === "integer") {
1744
1823
  const handle = defineAnnotatedType().designType("number").tags("number");
1745
1824
  handle.annotate("expect.int", true);
1746
- if (typeof s.minimum === "number") handle.annotate("expect.min", { minValue: s.minimum });
1747
- if (typeof s.maximum === "number") handle.annotate("expect.max", { maxValue: s.maximum });
1825
+ annotateNumberBounds(handle, s);
1748
1826
  return handle.$type;
1749
1827
  }
1750
1828
  if (s.type === "number") {
1751
1829
  const handle = defineAnnotatedType().designType("number").tags("number");
1752
- if (typeof s.minimum === "number") handle.annotate("expect.min", { minValue: s.minimum });
1753
- if (typeof s.maximum === "number") handle.annotate("expect.max", { maxValue: s.maximum });
1830
+ annotateNumberBounds(handle, s);
1754
1831
  return handle.$type;
1755
1832
  }
1756
1833
  if (s.type === "boolean") return defineAnnotatedType().designType("boolean").tags("boolean").$type;
@@ -1760,6 +1837,18 @@ const UPPER_BOUNDS = new Set([
1760
1837
  return convert(schema);
1761
1838
  }
1762
1839
  /**
1840
+ * Maps `minimum` / `maximum` / `exclusiveMinimum` / `exclusiveMaximum` onto
1841
+ * `@expect.min` / `max` / `exclusiveMin` / `exclusiveMax`. Also reads the draft-4 form,
1842
+ * where `exclusiveMinimum: true` makes `minimum` exclusive.
1843
+ */ function annotateNumberBounds(handle, s) {
1844
+ if (typeof s.minimum === "number") if (s.exclusiveMinimum === true) handle.annotate("expect.exclusiveMin", { exclusiveMinValue: s.minimum });
1845
+ else handle.annotate("expect.min", { minValue: s.minimum });
1846
+ if (typeof s.maximum === "number") if (s.exclusiveMaximum === true) handle.annotate("expect.exclusiveMax", { exclusiveMaxValue: s.maximum });
1847
+ else handle.annotate("expect.max", { maxValue: s.maximum });
1848
+ if (typeof s.exclusiveMinimum === "number") handle.annotate("expect.exclusiveMin", { exclusiveMinValue: s.exclusiveMinimum });
1849
+ if (typeof s.exclusiveMaximum === "number") handle.annotate("expect.exclusiveMax", { exclusiveMaxValue: s.exclusiveMaximum });
1850
+ }
1851
+ /**
1763
1852
  * Merges multiple annotated types into a combined schema map with shared `$defs`.
1764
1853
  *
1765
1854
  * Each type must have an `id`. The returned `schemas` object contains individual
@@ -25,7 +25,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  }) : target, mod));
26
26
 
27
27
  //#endregion
28
- const require_json_schema = require('./json-schema-BqpH_eYJ.cjs');
28
+ const require_json_schema = require('./json-schema-9OBvrg9D.cjs');
29
29
  let path = require("path");
30
30
  path = __toESM(path);
31
31
  let _atscript_core = require("@atscript/core");
@@ -686,6 +686,12 @@ const QUERY_OP_MAP = {
686
686
  "exists": "$exists",
687
687
  "not exists": "$exists"
688
688
  };
689
+ /** Value field of each number-bound annotation's object form. */ const NUMBER_BOUND_FIELDS = {
690
+ "expect.min": "minValue",
691
+ "expect.max": "maxValue",
692
+ "expect.exclusiveMin": "exclusiveMinValue",
693
+ "expect.exclusiveMax": "exclusiveMaxValue"
694
+ };
689
695
  const SYNTH_IMPORTS_MARKER = "/*@@atscript-synth-imports@@*/";
690
696
  var JsRenderer = class extends BaseRenderer {
691
697
  /**
@@ -1109,14 +1115,11 @@ var JsRenderer = class extends BaseRenderer {
1109
1115
  });
1110
1116
  break;
1111
1117
  case "expect.min":
1112
- if (a.args[0]) handle.annotate(a.name, {
1113
- minValue: Number(a.args[0].text),
1114
- message: a.args[1]?.text
1115
- });
1116
- break;
1117
1118
  case "expect.max":
1119
+ case "expect.exclusiveMin":
1120
+ case "expect.exclusiveMax":
1118
1121
  if (a.args[0]) handle.annotate(a.name, {
1119
- maxValue: Number(a.args[0].text),
1122
+ [NUMBER_BOUND_FIELDS[a.name]]: Number(a.args[0].text),
1120
1123
  message: a.args[1]?.text
1121
1124
  });
1122
1125
  break;
@@ -1,4 +1,4 @@
1
- import { l as defineAnnotatedType, t as buildJsonSchema } from "./json-schema-BtZ_OIcu.mjs";
1
+ import { l as defineAnnotatedType, t as buildJsonSchema } from "./json-schema-CioBVi6F.mjs";
2
2
  import path from "path";
3
3
  import { DEFAULT_FORMAT, flattenInterfaceNode, getRelPath, hasNavPropAnnotation, isArray, isBareId, isBareSpecifier, isConst, isDbEntityNode, isGroup, isInterface, isPrimitive, isProp, isQueryLogical, isRef, isStructure } from "@atscript/core";
4
4
 
@@ -658,6 +658,12 @@ const QUERY_OP_MAP = {
658
658
  "exists": "$exists",
659
659
  "not exists": "$exists"
660
660
  };
661
+ /** Value field of each number-bound annotation's object form. */ const NUMBER_BOUND_FIELDS = {
662
+ "expect.min": "minValue",
663
+ "expect.max": "maxValue",
664
+ "expect.exclusiveMin": "exclusiveMinValue",
665
+ "expect.exclusiveMax": "exclusiveMaxValue"
666
+ };
661
667
  const SYNTH_IMPORTS_MARKER = "/*@@atscript-synth-imports@@*/";
662
668
  var JsRenderer = class extends BaseRenderer {
663
669
  /**
@@ -1081,14 +1087,11 @@ var JsRenderer = class extends BaseRenderer {
1081
1087
  });
1082
1088
  break;
1083
1089
  case "expect.min":
1084
- if (a.args[0]) handle.annotate(a.name, {
1085
- minValue: Number(a.args[0].text),
1086
- message: a.args[1]?.text
1087
- });
1088
- break;
1089
1090
  case "expect.max":
1091
+ case "expect.exclusiveMin":
1092
+ case "expect.exclusiveMax":
1090
1093
  if (a.args[0]) handle.annotate(a.name, {
1091
- maxValue: Number(a.args[0].text),
1094
+ [NUMBER_BOUND_FIELDS[a.name]]: Number(a.args[0].text),
1092
1095
  message: a.args[1]?.text
1093
1096
  });
1094
1097
  break;
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_plugin = require('./plugin-Cv2odCwI.cjs');
3
- require('./json-schema-BqpH_eYJ.cjs');
2
+ const require_plugin = require('./plugin-6r27w6rG.cjs');
3
+ require('./json-schema-9OBvrg9D.cjs');
4
4
  let path = require("path");
5
5
  path = require_plugin.__toESM(path);
6
6
  let _atscript_core = require("@atscript/core");
@@ -1,5 +1,5 @@
1
- import { t as tsPlugin } from "./plugin-DpfsG4O7.mjs";
2
- import "./json-schema-BtZ_OIcu.mjs";
1
+ import { t as tsPlugin } from "./plugin-D3_BnRrI.mjs";
2
+ import "./json-schema-CioBVi6F.mjs";
3
3
  import path from "path";
4
4
  import { build } from "@atscript/core";
5
5
  import { readFileSync, writeFileSync } from "fs";
package/dist/utils.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_json_schema = require('./json-schema-BqpH_eYJ.cjs');
2
+ const require_json_schema = require('./json-schema-9OBvrg9D.cjs');
3
3
 
4
4
  //#region packages/typescript/src/runtime/coerce.ts
5
5
  /**
package/dist/utils.d.ts CHANGED
@@ -115,8 +115,10 @@ declare class Validator<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedTyp
115
115
  /** `@meta.required` / `@expect.minLength` / `maxLength` / `pattern` checks for a string value. */
116
116
  protected validateStringConstraints(metadata: TMetadataMap<AtscriptMetadata>, value: string): boolean;
117
117
  protected validateNumber(def: TAtscriptAnnotatedType<TAtscriptTypeFinal>, value: number): boolean;
118
- /** `@expect.int` / `min` / `max` checks for a number value. */
118
+ /** `@expect.int` / `min` / `max` / `exclusiveMin` / `exclusiveMax` checks for a number value. */
119
119
  protected validateNumberConstraints(metadata: TMetadataMap<AtscriptMetadata>, value: number): boolean;
120
+ /** Reports a failed number bound: its custom message, else `Expected <label> <bound>, got <value>`. */
121
+ private numberBoundFailed;
120
122
  protected validateBoolean(def: TAtscriptAnnotatedType<TAtscriptTypeFinal>, value: boolean): boolean;
121
123
  /** `@meta.required` check for a boolean value (must be `true`). */
122
124
  protected validateBooleanConstraints(metadata: TMetadataMap<AtscriptMetadata>, value: boolean): boolean;
package/dist/utils.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as forAnnotatedType, c as createAnnotatedTypeNode, d as isAnnotatedTypeOfPrimitive, f as isPhantomType, i as mergeJsonSchemas, l as defineAnnotatedType, m as ValidatorError, n as detectDiscriminator, o as annotate, p as Validator, r as fromJsonSchema, s as cloneRefProp, t as buildJsonSchema, u as isAnnotatedType } from "./json-schema-BtZ_OIcu.mjs";
1
+ import { a as forAnnotatedType, c as createAnnotatedTypeNode, d as isAnnotatedTypeOfPrimitive, f as isPhantomType, i as mergeJsonSchemas, l as defineAnnotatedType, m as ValidatorError, n as detectDiscriminator, o as annotate, p as Validator, r as fromJsonSchema, s as cloneRefProp, t as buildJsonSchema, u as isAnnotatedType } from "./json-schema-CioBVi6F.mjs";
2
2
 
3
3
  //#region packages/typescript/src/runtime/coerce.ts
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/typescript",
3
- "version": "0.1.108",
3
+ "version": "0.1.109",
4
4
  "description": "Atscript: typescript-gen support.",
5
5
  "keywords": [
6
6
  "annotations",
@@ -63,17 +63,17 @@
63
63
  "./package.json": "./package.json"
64
64
  },
65
65
  "dependencies": {
66
- "@moostjs/event-cli": "^0.6.52",
67
- "moost": "^0.6.52"
66
+ "@moostjs/event-cli": "^0.6.53",
67
+ "moost": "^0.6.53"
68
68
  },
69
69
  "devDependencies": {
70
- "@atscript/db": "^0.1.159",
70
+ "@atscript/db": "^0.1.161",
71
71
  "@uniqu/core": "^0.1.15",
72
72
  "vitest": "3.2.7"
73
73
  },
74
74
  "peerDependencies": {
75
75
  "@atscript/db": "^0.1.159",
76
- "@atscript/core": "^0.1.108"
76
+ "@atscript/core": "^0.1.109"
77
77
  },
78
78
  "peerDependenciesMeta": {
79
79
  "@atscript/db": {