arktype 3.0.0-beta.0 → 3.0.0-beta.1

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 (51) hide show
  1. package/README.md +162 -10
  2. package/out/attributes.d.ts +4 -2
  3. package/out/checkers.d.ts +37 -2
  4. package/out/{chunk-Z4F45ZTE.js → chunk-2U2AWCI3.js} +3 -3
  5. package/out/{chunk-5NJWD7CO.js → chunk-5U2ZMDNI.js} +215 -140
  6. package/out/{chunk-KJ3C5GTL.js → chunk-DLWCO4RV.js} +1 -1
  7. package/out/{chunk-H4VRNKMB.js → chunk-E3DZXEZK.js} +1 -1
  8. package/out/{chunk-EJZJUYPI.js → chunk-EVCML554.js} +2 -2
  9. package/out/{chunk-KI2MOYNT.js → chunk-GPNK5353.js} +184 -32
  10. package/out/{chunk-LUXERINN.js → chunk-RAZ3TXOE.js} +40 -38
  11. package/out/chunk-SWOOCAHN.js +4 -0
  12. package/out/{chunk-ARTS74PX.js → chunk-UETB6YE2.js} +1 -1
  13. package/out/{chunk-JHDPSG5Y.js → chunk-UK5UGFOX.js} +6 -6
  14. package/out/{chunk-WEPQK3AY.js → chunk-VV6YDN2D.js} +441 -145
  15. package/out/codecs.js +5 -5
  16. package/out/config.d.ts +6 -3
  17. package/out/i18n.d.ts +1 -1
  18. package/out/i18n.js +1 -1
  19. package/out/index.d.ts +1 -1
  20. package/out/index.js +5 -5
  21. package/out/internal.d.ts +1 -0
  22. package/out/internal.js +11 -11
  23. package/out/island.js +2 -2
  24. package/out/islandDependency.js +11 -11
  25. package/out/keywords/functions.d.ts +24 -24
  26. package/out/keywords/keywords.d.ts +2 -2
  27. package/out/keywords/phrases.d.ts +23 -23
  28. package/out/keywords/ts.js +2 -2
  29. package/out/locale.d.ts +1 -1
  30. package/out/locales/de.js +1 -1
  31. package/out/locales/en.js +3 -3
  32. package/out/match.d.ts +5 -3
  33. package/out/mutatesInput.js +2 -2
  34. package/out/parser/definition.d.ts +54 -3
  35. package/out/parser/shift/operand/unenclosed.d.ts +3 -1
  36. package/out/parser/shift/operand/unresolvable.d.ts +68 -0
  37. package/out/parser/shift/operator/bounds.d.ts +4 -1
  38. package/out/runtime.d.ts +34 -25
  39. package/out/runtime.js +2 -2
  40. package/out/runtimeDevelopment.js +63 -4
  41. package/out/scope.d.ts +4 -4
  42. package/out/standalone/artifact.d.ts +4 -0
  43. package/out/standalone/baking.d.ts +8 -1
  44. package/out/standalone/sites.d.ts +6 -3
  45. package/out/standalone/values.d.ts +2 -0
  46. package/out/type.d.ts +42 -5
  47. package/package.json +49 -6
  48. package/skills/arktype/SKILL.md +211 -92
  49. package/skills/arktype/references/migrating.md +990 -255
  50. package/skills/arktype/references/precompile.md +8 -5
  51. package/out/chunk-EDEN5UWG.js +0 -4
@@ -3,10 +3,10 @@ import {
3
3
  } from "./chunk-G45P2CLE.js";
4
4
 
5
5
  // out/runtime.js
6
- import { ArkErrors as ArkErrors2, describeActual, enInfo, errorsOf, FirstIssues, issueAt, issuesOf, mergeIssues, problemOf, runtimeConfig as runtimeConfig2, supportedJsonSchemaTargets, throwOnDefault, traversesUnions, validateStandardJsonSchemaTarget, writeFromPath, writeListed } from "@ark/schema/runtime";
6
+ import { ArkErrors as ArkErrors2, codedIssue, describeActual, enInfo, errorsOf, failsKey, failsKeySite, failsSite, findsOnRead, FirstIssues, holdsExpression, isCustomIssue, issueAt, issuesOf, mergeIssues, runtimeConfig as runtimeConfig2, sharedMessageOf, supportedJsonSchemaTargets, throwOnDefault, traversesUnions, validateStandardJsonSchemaTarget, writeFromPath, writeListed } from "@ark/schema/runtime";
7
7
  import { dateGetTime, getBuiltinNameOfConstructor, hasDomain, printable, prototypeOf, stringifyPath, throwError, throwParseError } from "@ark/util";
8
8
  import { addErrors, addMorphErrs, allowsInBranchBy, allowsInContext, allowsUntracked, appliesValues, ArkErrors, copyOf, describePredicate, discriminatesBooleans, enterApplied, exitApplied, failsInBranches, pipeApplied, pipeChecked, pipeTransformed, runtimeConfig, runtimeScope, silentCtx, TransformErrors, transformed, transformedInApply, transformIfAllowed, transformResolution, transformsBranches, transformsValid } from "@ark/schema/runtime";
9
- export { aliasVisits, allowsAcyclic, allowsInBranch, applyCyclic, applyIssues, applyRejected, arrayIndexMatcher, callMorph, computeDefaultValueMorph, configure, configuredFallbackOf, configuredWriterOf, copyDeclared, alikeIssue, describeCollapsibleDate, disallowed, enInfo, enterResolution, execMorph, exitResolution, FirstIssues, FirstIssueTraversal, fixConfig, foundErrors, fixConfigured, holdsOnlyIndices, keepOwn, InternalTraversal, listedIssue, matchesRepeated, mergeTransformed, pipe, printKind, rejected, rejects, throwIssues, throwOnDefault, Traversal, TraversalError, tryMorph, writeDomainActual, writeLengthActual, writeNotEqualActual, writeProblem, writeProtoActual, writeNullableJsonSchema, writeUnionJsonSchema, writeUnitActual, writeUnitProblem } from "@ark/schema/runtime";
9
+ export { aliasVisits, allowsAcyclic, allowsInBranch, applyCyclic, applyIssues, applyRejected, arrayIndexMatcher, callMorph, codedIssue, computeDefaultValueMorph, configure, configuredFallbackOf, configuredWriterOf, copyDeclared, alikeIssue, describeCollapsibleDate, disallowed, enInfo, enterResolution, execMorph, exitResolution, failsKey, failsKeySite, failsSite, FirstIssues, FirstIssueTraversal, fixConfig, foundErrors, fixConfigured, holdsOnlyIndices, keepOwn, InternalTraversal, listedIssue, matchesRepeated, mergeTransformed, missingTextOf, pipe, printKind, rejected, rejects, throwIssues, throwOnDefault, Traversal, TraversalError, tryMorph, writeDomainActual, writeLengthActual, writeMessage, writeNotEqualActual, writeProtoActual, writeNullableJsonSchema, writeUnionJsonSchema, writeUnitActual, writeUnitMessage } from "@ark/schema/runtime";
10
10
  export { baseNameOf, functionNameOf, isIpv4, isIpv6, isIso8601, isNumericString, isPlainObjectOrArray, isUuid, isValidDate, isWellFormedInteger, jsTypeOfDescriptions, liftArray, ParseError, printable, throwParseError, timeOf } from "@ark/util";
11
11
 
12
12
  // out/checkers.js
@@ -43,19 +43,19 @@ var reportedBy = (read, description, data, ctx) => {
43
43
  return !ctx.failFast || ctx.errN === errN;
44
44
  };
45
45
  var narrowedWithCtx = ((read, description) => {
46
- const checker = (data, ctx) => ctx?._at && ctx._at !== stops ? reportedBy(read, description, data, ctx) : !!read()(data, silentCtx);
46
+ const checker = (data, ctx) => ctx?._e && ctx._e !== stops ? reportedBy(read, description, data, ctx) : !!read()(data, silentCtx);
47
47
  checker.description = description;
48
48
  return checker;
49
49
  });
50
50
  var stops = () => true;
51
51
  var allowingCtx = (data, ctx, checker) => {
52
- if (ctx._at === stops)
52
+ if (ctx._e === stops)
53
53
  return checker(data, ctx);
54
- const { chkOnly, _at, failsUnion } = ctx;
54
+ const { chkOnly, _e, failsUnion } = ctx;
55
55
  ctx.chkOnly = true;
56
- ctx._at = ctx.failsUnion = stops;
56
+ ctx._e = ctx.failsUnion = stops;
57
57
  const allowed = checker(data, ctx);
58
- ctx._at = _at;
58
+ ctx._e = _e;
59
59
  ctx.failsUnion = failsUnion;
60
60
  ctx.chkOnly = chkOnly;
61
61
  return allowed;
@@ -74,14 +74,14 @@ var readingCtx = ((checker) => {
74
74
  });
75
75
  var allowsReadingCtx = ((checker) => (data, ctx) => typeof ctx === "object" ? allowingCtx(data, ctx, checker) : checker(data));
76
76
  var compiled = ((node, transforms) => {
77
- const checker = (data, ctx) => !ctx ? node.tAllows(data, 0) : ctx._at === stops ? node.tAllows(data, ctx) : node.tApply(data, ctx);
77
+ const checker = (data, ctx) => !ctx ? node.tAllows(data, 0) : ctx._e === stops ? node.tAllows(data, ctx) : node.tApply(data, ctx);
78
78
  if (transforms) {
79
79
  checker.t = (data, ctx) => node.tTransform(data, ctx);
80
80
  checker.t.c = 1;
81
81
  }
82
82
  return checker;
83
83
  });
84
- var wrapping = (checker) => Object.assign((data, ctx) => checker(data, ctx), checker);
84
+ var wrapping = (checker, also) => Object.assign((data, ctx) => checker(data, ctx), checker, also);
85
85
  var resolvedBy = (node, t) => {
86
86
  const resolved = (data, ctx) => transformResolution(ctx, node.id, data, t);
87
87
  resolved.c = 1;
@@ -92,7 +92,7 @@ var aliasedValue = ((checker, node, flags) => {
92
92
  const enters = flags & 1;
93
93
  wrapped.e = (ctx, _, value, k) => {
94
94
  ctx.path.push(k);
95
- const passes = ctx._at === stops ? checker(value, ctx) : node.tfs && transformIfAllowed(ctx, node, value) || (enters ? enterApplied(ctx, node.id, value) ?? exitApplied(ctx, checker(value, ctx)) : checker(value, ctx));
95
+ const passes = ctx._e === stops ? checker(value, ctx) : node.tfs && transformIfAllowed(ctx, node, value) || (enters ? enterApplied(ctx, node.id, value) ?? exitApplied(ctx, checker(value, ctx)) : checker(value, ctx));
96
96
  ctx.path.pop();
97
97
  return !passes;
98
98
  };
@@ -101,7 +101,7 @@ var aliasedValue = ((checker, node, flags) => {
101
101
  return wrapped;
102
102
  });
103
103
  var aliasedMember = ((checker, id) => {
104
- const entered = (data, ctx) => ctx?._at && ctx._at !== stops ? enterApplied(ctx, id, data) ?? exitApplied(ctx, checker(data, ctx)) : checker(data, ctx);
104
+ const entered = (data, ctx) => ctx?._e && ctx._e !== stops ? enterApplied(ctx, id, data) ?? exitApplied(ctx, checker(data, ctx)) : checker(data, ctx);
105
105
  entered.description = checker.description;
106
106
  entered.a = checker.a;
107
107
  if (checker.t)
@@ -116,7 +116,7 @@ var holdingAlias = ((checker) => {
116
116
  var narrowedInCtx = ((read, description) => {
117
117
  const checker = (data, ctx) => (
118
118
  // one taking only data is passed no ctx where arktype only asks
119
- !ctx?._at ? !!read()(data, void 0) : ctx._at === stops ? !!read()(data, ctx) : reportedBy(read, description, data, ctx)
119
+ !ctx?._e ? !!read()(data, void 0) : ctx._e === stops ? !!read()(data, ctx) : reportedBy(read, description, data, ctx)
120
120
  );
121
121
  checker.description = description;
122
122
  return checker;
@@ -124,27 +124,23 @@ var narrowedInCtx = ((read, description) => {
124
124
  var issuesIn = (ctx) => ctx.errN ?? ctx.count;
125
125
  var narrowedAfter = ((structure, narrowed2) => {
126
126
  const checker = (data, ctx) => {
127
- if (!ctx?._at || ctx._at === stops)
127
+ if (!ctx?._e || ctx._e === stops)
128
128
  return structure(data, ctx) && narrowed2(data, ctx);
129
- if (structure.t) {
130
- if (!(structure.a ? structure.a(data, ctx) : structure(data)))
131
- return structure(data, ctx);
132
- } else {
133
- const issues = issuesIn(ctx);
134
- if (!structure(data, ctx))
135
- return false;
136
- if (issuesIn(ctx) > issues)
137
- return true;
138
- }
139
- return narrowed2(data, ctx);
129
+ const issues = issuesIn(ctx);
130
+ return structure(data, ctx) && (issuesIn(ctx) > issues || narrowed2(data, ctx));
140
131
  };
132
+ checker.description = structure.description;
133
+ return checker;
134
+ });
135
+ var transformingNarrowedAfter = ((structure, narrowed2) => {
136
+ const checker = (data, ctx) => !ctx?._e || ctx._e === stops ? structure(data, ctx) && narrowed2(data, ctx) : (structure.a ? structure.a(data, ctx) : structure(data)) ? narrowed2(data, ctx) : structure(data, ctx);
141
137
  checker.t = structure.t;
142
138
  checker.description = structure.description;
143
139
  return checker;
144
140
  });
145
141
  var narrowedByEach = ((checkers) => {
146
142
  const checker = (data, ctx) => {
147
- const applies = ctx?._at && ctx._at !== stops;
143
+ const applies = ctx?._e && ctx._e !== stops;
148
144
  const issues = applies && issuesIn(ctx);
149
145
  for (const narrowed2 of checkers) {
150
146
  if (!narrowed2(data, ctx))
@@ -163,6 +159,28 @@ var narrowed = ((narrow, description = "valid according to an anonymous predicat
163
159
  checker.description = description;
164
160
  return checker;
165
161
  });
162
+ function unnamed() {
163
+ return arguments[0];
164
+ }
165
+ var rejecting = ((passes, message) => (data, ctx) => passes(data) || ctx.reject({ message }));
166
+ var rejectedSiteOf = (message) => ({
167
+ code: "predicate",
168
+ description: "valid according to an anonymous predicate",
169
+ x: message
170
+ });
171
+ var rejectsWith = ((passes, message, description) => {
172
+ const site = rejectedSiteOf(message);
173
+ const checker = (data, ctx) => !!passes(data) || !failsAt(ctx, site, data);
174
+ checker.description = description;
175
+ return checker;
176
+ });
177
+ var narrowedRejecting = ((read, description) => {
178
+ const checker = (data, ctx) => !!read()(data, {
179
+ reject: (input) => !failsAt(ctx, rejectedSiteOf(input.message), data)
180
+ });
181
+ checker.description = description;
182
+ return checker;
183
+ });
166
184
  var allowsOf = ((validator) => validator.allows);
167
185
  var stringCheck = /* @__PURE__ */ check("domain", "a string", (data) => typeof data === "string");
168
186
  var numberCheck = /* @__PURE__ */ check("domain", "a number", (data) => Number.isFinite(data));
@@ -201,11 +219,11 @@ var arrayOf = ((element, max2, min2) => {
201
219
  return checker;
202
220
  });
203
221
  var printValue = (value) => typeof value === "string" ? JSON.stringify(value) : `${value}`;
204
- var describeValues = (values) => {
205
- const printed = values.map(printValue);
222
+ var listed = (printed) => {
206
223
  const last = printed.pop();
207
224
  return printed.length ? `${printed.join(", ")} or ${last}` : last;
208
225
  };
226
+ var describeValues = (values) => listed(values.map(printValue));
209
227
  var unit = ((value, description = printValue(value)) => check("unit", description, (data) => data === value));
210
228
  var booleanChecker = /* @__PURE__ */ check("discriminant", "boolean", (data) => typeof data === "boolean");
211
229
  var intersection = ((basis, refinements, within, brief = basis ? basis.description : "present") => {
@@ -226,12 +244,7 @@ var intersection = ((basis, refinements, within, brief = basis ? basis.descripti
226
244
  checker.t = within?.t;
227
245
  return checker;
228
246
  });
229
- var optional = ((checker, ...value) => {
230
- const wrapped = wrapping(checker);
231
- wrapped.o = 1;
232
- wrapped.d = value;
233
- return wrapped;
234
- });
247
+ var optional = ((checker, ...value) => wrapping(checker, { o: 1, d: value }));
235
248
  var writtenBy = ((checker, write, replacesUndefined) => {
236
249
  const wrapped = optional(checker);
237
250
  wrapped.w = write;
@@ -243,23 +256,42 @@ var replacingUndefined = ((checker, value) => {
243
256
  wrapped.u = 1;
244
257
  return wrapped;
245
258
  });
246
- var required = ((checker, description) => {
247
- const wrapped = wrapping(checker);
248
- wrapped.description = description;
249
- return wrapped;
259
+ var required = ((checker, description) => wrapping(checker, { description, x: void 0 }));
260
+ var sayingMissing = ((checker, message, text, description = checker.description) => wrapping(checker, { description, x: message, text }));
261
+ var saying = ((checker, message) => {
262
+ const said = (data, ctx) => {
263
+ const at = ctx?._e;
264
+ if (!at || at === stops)
265
+ return checker(data, ctx);
266
+ ctx._e = (data2, code, expected) => at.call(ctx, data2, code, expected, message);
267
+ try {
268
+ return checker(data, ctx);
269
+ } finally {
270
+ ctx._e = at;
271
+ }
272
+ };
273
+ Object.assign(said, checker);
274
+ said.x = message;
275
+ return said;
250
276
  });
251
- var failsValue = (ctx, checker, data, k, value) => ctx?._at ? appliesValues && checker.e ? checker.e(ctx, checker, value, k) : appliesValues && checker.t?.e ? checker.t.e(ctx, checker, value, k) : (!checker.t || !(appliesValues && checker.a ? (
277
+ var failsValue = (ctx, checker, data, k, value) => ctx?._e ? appliesValues && checker.e ? checker.e(ctx, checker, value, k) : appliesValues && checker.t?.e ? checker.t.e(ctx, checker, value, k) : (!checker.t || !(appliesValues && checker.a ? (
252
278
  // as arktype, a value reading its ctx is applied once where
253
279
  // one only checks, as Allows does
254
280
  !ctx.chkOnly && checker.a(value, ctx, k)
255
- ) : checker(value))) && ctx._in(checker, data, k) : !checker(value);
281
+ ) : checker(value))) && ctx._k(checker, data, k) : !checker(value);
256
282
  var props = ((declared) => {
257
283
  const checker = (data, ctx) => {
258
284
  if (!objectCheck.test(data))
259
285
  return !failsAt(ctx, objectCheck, data);
260
286
  for (const k in declared) {
261
287
  const value = data[k];
262
- if (value === void 0 && !(k in data) ? !declared[k].o && failsAt(ctx, requiredSiteOf(declared[k].description), data, k) : failsValue(ctx, declared[k], data, k, value))
288
+ if (value === void 0 && !(k in data) ? (
289
+ // entered by the ctx, which fails a key missing from data as
290
+ // required with what it's passed: what its checker holds for
291
+ // it, the description it expects, the message it says and
292
+ // what notes one that's its code's
293
+ !declared[k].o && (!ctx?._e || ctx._k(declared[k], data, k, declared[k].description, declared[k].x, declared[k].text))
294
+ ) : failsValue(ctx, declared[k], data, k, value))
263
295
  return false;
264
296
  }
265
297
  return true;
@@ -276,7 +308,7 @@ var closedProps = ((declared, description = "removed") => {
276
308
  if (!walks(data, ctx))
277
309
  return false;
278
310
  for (const k in data) {
279
- if (!hasOwn(declared, k) && hasOwn(data, k) && failsAt(ctx, removed, data, k))
311
+ if (!hasOwn(declared, k) && hasOwn(data, k) && failsAtKey(ctx, removed, data, k))
280
312
  return false;
281
313
  }
282
314
  return true;
@@ -313,7 +345,7 @@ var indexed = ((signatures, declared = {}, removed) => {
313
345
  if (matchesKey(key, k, ctx) && failsValue(ctx, value, data, k, data[k]))
314
346
  return false;
315
347
  }
316
- if (site && typeof k === "string" && !hasOwn(declared, k) && !signatures.some(([key]) => matchesKey(key, k, ctx)) && failsAt(ctx, site, data, k))
348
+ if (site && typeof k === "string" && !hasOwn(declared, k) && !signatures.some(([key]) => matchesKey(key, k, ctx)) && failsAtKey(ctx, site, data, k))
317
349
  return false;
318
350
  }
319
351
  return true;
@@ -462,26 +494,33 @@ var failingDeletingProps = ((declared, withCtx) => {
462
494
  }, Object.values(declared), withCtx);
463
495
  return checker;
464
496
  });
465
- var sited = ((allows, declared, write, writes, removed, withCtx) => {
497
+ var sitedKeeps = (declared, checkers, write) => (data, values) => {
498
+ const out = write(data, checkers, values, copyOf);
499
+ if (out !== data) {
500
+ for (const k in declared)
501
+ if (!(k in out) && k in data)
502
+ out[k] = data[k];
503
+ }
504
+ return out;
505
+ };
506
+ var sitedProps = ((allows, declared, write, walks = props(declared)) => {
466
507
  const checkers = Object.values(declared);
467
- const walks = removed ? closedProps(declared, removed) : props(declared);
468
- const checker = (data, ctx) => !objectCheck.test(data) ? !failsAt(ctx, objectCheck, data) : ctx?._at ? walks(data, ctx) : allows(data, checkers);
508
+ const checker = (data, ctx) => !objectCheck.test(data) ? !failsAt(ctx, objectCheck, data) : ctx?._e ? walks(data, ctx) : allows(data, checkers);
469
509
  checker.description = objectCheck.description;
510
+ if (write) {
511
+ const written = sitedKeeps(declared, checkers, write);
512
+ checker.t = (data) => written(data);
513
+ }
514
+ return checker;
515
+ });
516
+ var sited = ((allows, declared, write, writes, removed, withCtx) => {
517
+ const checker = sitedProps(allows, declared, 0, removed ? closedProps(declared, removed) : void 0);
470
518
  if (!write)
471
519
  return checker;
520
+ const checkers = Object.values(declared);
472
521
  const changing = changingIn(declared);
473
- const written = (data, values) => {
474
- if (writes > 2) {
475
- return Object.getPrototypeOf(data) === Object.prototype ? write(data, checkers, values, copyOf) : deletes(declared, data, values ? writtenValues(declared, changing, data, values) : writtenProps(declared, changing, data));
476
- }
477
- const out = write(data, checkers, values, copyOf);
478
- if (out !== data) {
479
- for (const k in declared)
480
- if (!(k in out) && k in data)
481
- out[k] = data[k];
482
- }
483
- return out;
484
- };
522
+ const keeps = sitedKeeps(declared, checkers, write);
523
+ const written = (data, values) => writes < 3 ? keeps(data, values) : Object.getPrototypeOf(data) === Object.prototype ? write(data, checkers, values, copyOf) : deletes(declared, data, values ? writtenValues(declared, changing, data, values) : writtenProps(declared, changing, data));
485
524
  checker.t = writes % 2 ? (data) => written(data) : readingValues((data, ctx) => {
486
525
  const values = writtenFor(ctx);
487
526
  try {
@@ -671,21 +710,25 @@ var checkerNode = ((checker, reportsPred) => Object.freeze({
671
710
  tTransform: checker.t,
672
711
  allows: checker
673
712
  }));
674
- var ctxNode = ((flags, tAllows, tApply, tTransform) => {
675
- const node = Object.freeze({
676
- ...flags,
713
+ var ctxNode = ((flags, tAllows, tApply, tTransform, declared = {}) => {
714
+ const node = Object.freeze(Object.assign(declared, flags, {
677
715
  allowsCtx: true,
678
716
  tAllows,
679
717
  tApply,
680
718
  tTransform,
681
719
  allows: (data) => allowsUntracked(node, data) ?? allowsInContext(node, data, runtimeConfig),
682
720
  $: runtimeScope
683
- });
721
+ }));
684
722
  return node;
685
723
  });
724
+ var readingCtxNode = ((tApply, reportsPred) => ctxNode(reportsPred ? { checksCtx: true, reportsPred } : { checksCtx: true }, allowsReadingCtx(tApply), tApply));
686
725
  var failingBranches = ((branchOf, branches) => holdingMorphs((data, ctx) => transformedBy(branchOf(data), data, ctx), branches));
687
726
  var units = ((values, code = "discriminant", description = describeValues(values)) => check(code, description, (data) => values.includes(data)));
688
- var domains = ((cases, description, fails) => {
727
+ var describeDomains = (cases) => listed(Object.keys(cases).map((domain) => {
728
+ const branch = cases[domain];
729
+ return branch !== 1 ? `${branch.description}` : domain === "undefined" || domain === "null" ? domain : `${domain === "object" ? "an" : "a"} ${domain}`;
730
+ }));
731
+ var domains = ((cases, description = describeDomains(cases), fails) => {
689
732
  const site = { code: "discriminant", description };
690
733
  const caseOf = (data) => cases[data === null ? "null" : typeof data === "function" ? "object" : typeof data];
691
734
  const checker = (data, ctx) => {
@@ -726,7 +769,7 @@ var discriminate = ((key, cases, description = describeValues(Object.keys(cases)
726
769
  const site = { code: "discriminant", description };
727
770
  const checker = (data, ctx) => {
728
771
  const branch = byValue.get(data?.[key]);
729
- return branch ? branch === 1 || branch(data, ctx) : objectCheck.test(data) ? !failsAt(ctx, site, data, isOwn ? void 0 : key) : !failsAt(ctx, missed, data);
772
+ return branch ? branch === 1 || branch(data, ctx) : objectCheck.test(data) ? !(isOwn ? failsAt(ctx, site, data) : failsAtKey(ctx, site, data, key)) : !failsAt(ctx, missed, data);
730
773
  };
731
774
  checker.description = missed.description;
732
775
  if (transformsBranches && Object.values(cases).some((branch) => branch.t)) {
@@ -737,7 +780,7 @@ var discriminate = ((key, cases, description = describeValues(Object.keys(cases)
737
780
  var discriminateOr = ((otherwise, key, cases, description, missed = { code: "union", description: "an object" }, fails) => {
738
781
  const byValue = new Map(Object.entries(cases));
739
782
  const site = { code: "discriminant", description };
740
- const miss = (data, ctx) => !failsAt(ctx, site, data, key);
783
+ const miss = (data, ctx) => !failsAtKey(ctx, site, data, key);
741
784
  const checker = (data, ctx) => {
742
785
  const branch = byValue.get(data?.[key]);
743
786
  return branch ? branch === 1 || branch(data, ctx) : otherwise(data) || (objectCheck.test(data) ? !failsBranches(ctx, [miss, otherwise], data, listedIssue) : !failsAt(ctx, missed, data));
@@ -759,7 +802,7 @@ var union = ((branches, description, issueOf, fails) => {
759
802
  });
760
803
 
761
804
  // out/runtime.js
762
- var precompiledForArktype_3_0_0_beta_0 = true;
805
+ var precompiledForArktype_3_0_0_beta_1 = true;
763
806
  var assign = /* @__PURE__ */ (() => Object.assign)();
764
807
  var is = /* @__PURE__ */ (() => Object.is)();
765
808
  var freeze = /* @__PURE__ */ (() => Object.freeze)();
@@ -771,33 +814,12 @@ var Validator = class {
771
814
  from(input) {
772
815
  return this.assert(input);
773
816
  }
774
- // a build without the expression member has none to print
817
+ // a build without the expression member has none to print, and one whose
818
+ // validators all lack it ships no read of it
775
819
  toString() {
776
- try {
777
- return `Type<${this.expression}>`;
778
- } catch {
779
- return "Type";
780
- }
781
- }
782
- // a member the build bakes is the validator's own, so reading one it
783
- // doesn't throws with the fix
784
- get expression() {
785
- throw lacks("expression");
786
- }
787
- get description() {
788
- throw lacks("description");
789
- }
790
- get json() {
791
- throw lacks("json");
792
- }
793
- get toJSON() {
794
- throw lacks("toJSON");
795
- }
796
- get toJsonSchema() {
797
- throw lacks("toJsonSchema");
820
+ return holdsExpression && this.expression ? `Type<${this.expression}>` : "Type";
798
821
  }
799
822
  };
800
- var lacks = (member) => new Error(`${member} isn't precompiled: set members["${member}"] true in the precompile options`);
801
823
  var getOwnPropertyDescriptors = /* @__PURE__ */ (() => Object.getOwnPropertyDescriptors)();
802
824
  var own = (validator, attributes) => Object.defineProperties(validator, getOwnPropertyDescriptors(attributes));
803
825
  var bakeInto = (validator, { "~standard": standard, ...attributes }) => {
@@ -823,13 +845,16 @@ var bakeInto = (validator, { "~standard": standard, ...attributes }) => {
823
845
  }
824
846
  return validator;
825
847
  };
826
- var standardResultOf = (out) => out instanceof ArkErrors2 ? {
827
- issues: (out._i ? out.issues : out._).map((issue) => ({
828
- ...issue,
829
- // arktype's errors hold their problem whether or not a site writes text
830
- message: issue.problem ?? problemOf(issue)
831
- }))
832
- } : { value: out };
848
+ var failureMessage = {
849
+ get() {
850
+ return this._s();
851
+ },
852
+ enumerable: true
853
+ };
854
+ var standardResultOf = (out) => out instanceof ArkErrors2 ? Object.defineProperty(Object.defineProperty({ issues: out.issues }, "_s", {
855
+ value: () => out.summary,
856
+ writable: true
857
+ }), "message", failureMessage) : { value: out };
833
858
  var siteOf = ((code, description, message) => ({ code, description, x: message }));
834
859
  var requiredSiteOf = ((description) => ({
835
860
  m: { code: "required", description }
@@ -842,9 +867,6 @@ var standardOf = (validator, attributes) => freeze({
842
867
  vendor: "arktype",
843
868
  version: 1,
844
869
  validate: freeze((input) => standardResultOf(validator(input))),
845
- get jsonSchema() {
846
- throw lacks("~standard.jsonSchema");
847
- },
848
870
  ...attributes["~standard"]
849
871
  });
850
872
  var createValidator = ((rootApply, allows, attributes, id, holes) => createValidatorWith((_, configuredOnFail) => ((data, pipedFromCtx, onFail = configuredOnFail) => pipedFromCtx ? rootApply(data, pipedInto(pipedFromCtx)) : rootApply(data, onFail)), [allows], id, attributes, holes));
@@ -963,22 +985,21 @@ var type = /* @__PURE__ */ freeze({
963
985
  errors: ArkErrors2
964
986
  });
965
987
  var canParseUrl = ((s) => URL.canParse(s));
966
- var problemSiteOf = ((code, description, message, problem) => ({
988
+ var codeSiteOf = ((code, description, message) => ({
967
989
  code,
968
990
  description,
969
991
  x: message,
970
- text: (issue) => {
971
- issue.problem = problem;
972
- }
992
+ text: codedIssue
973
993
  }));
974
994
  var defineProperty = /* @__PURE__ */ (() => Object.defineProperty)();
975
- var writeIssue = (issue, context, [expected, actual, problem, message], keeps) => {
995
+ var writeIssue = (issue, context, [expected, actual, message], keeps) => {
976
996
  const text = {
977
997
  expected: issue.expected,
978
- message: issue.message
998
+ // one supplied where it's raised, which is its own
999
+ message: context.message
979
1000
  };
980
- if (keeps & 2)
981
- text.problem = issue.problem;
1001
+ if (keeps & 2 && text.message === void 0)
1002
+ codedIssue(issue);
982
1003
  const writeText = () => {
983
1004
  const error = {
984
1005
  data: issue.data,
@@ -995,11 +1016,8 @@ var writeIssue = (issue, context, [expected, actual, problem, message], keeps) =
995
1016
  describeActual(error);
996
1017
  error.actual = write(actual, issue.data, error);
997
1018
  }
998
- error.problem = context.problem ?? write(problem, error);
999
1019
  if (keeps & 1)
1000
1020
  text.expected = error.expected;
1001
- if (keeps & 2)
1002
- text.problem = error.problem;
1003
1021
  text.message ??= write(message, error);
1004
1022
  for (const k in text) {
1005
1023
  defineProperty(issue, k, {
@@ -1034,16 +1052,19 @@ var raisingTraversalOf = (Base, writtenByCode) => class extends Base {
1034
1052
  return issue;
1035
1053
  }
1036
1054
  };
1037
- var failsAt = ((ctx, site, data, key) => !ctx?._at || ctx._at(site, data, key));
1038
- var failsAtPath = ((ctx, site, data, [k, ...deeper]) => !ctx?._at || (deeper.length ? ctx._in((value, ctx2) => !failsAtPath(ctx2, site, value, deeper), data, k) : ctx._at(site, data, k)));
1039
- var failsIn = ((ctx, apply, data, key, missing) => ctx?._at ? ctx._in(apply, data, key, missing) : !apply(data[key]));
1055
+ var failsAt = ((ctx, site, data) => !ctx?._e || failsSite(ctx, site, data));
1056
+ var failsWith = ((ctx, ...failure) => !ctx?._e || ctx._e(...failure));
1057
+ var failsKeyWith = ((ctx, ...failure) => !ctx?._e || failsKey(ctx, ...failure));
1058
+ var failsAtKey = ((ctx, site, data, key) => !ctx?._e || failsKeySite(ctx, site, data, key));
1059
+ var failsAtPath = ((ctx, site, data, [k, ...deeper]) => !ctx?._e || (deeper.length ? ctx._k((value, ctx2) => !failsAtPath(ctx2, site, value, deeper), data, k) : failsKeySite(ctx, site, data, k)));
1060
+ var failsIn = ((ctx, apply, data, key, ...missing) => ctx?._e ? ctx._k(apply, data, key, ...missing) : !apply(data[key]));
1040
1061
  var ownIssue = ((site) => (path, data, errors) => {
1041
1062
  const issue = issueAt(path, site, data, void 0);
1042
- const listed = writeListed(errors);
1043
- if (issue.expected === void 0) {
1044
- const expected = issue.expected = path.length ? writeFromPath(path, errors, writeListed) : listed;
1045
- issue.problem ??= expected;
1046
- }
1063
+ const listed2 = writeListed(errors);
1064
+ issue.expected ??= path.length ? writeFromPath(path, errors, writeListed) : listed2;
1065
+ const shared = isCustomIssue(issue) ? void 0 : sharedMessageOf(errors);
1066
+ if (shared !== void 0)
1067
+ issue.message = shared;
1047
1068
  issue.errors = errors;
1048
1069
  return issue;
1049
1070
  });
@@ -1060,7 +1081,7 @@ var failsListed = ((ctx, firsts, data, issueOf) => {
1060
1081
  return ctx.failFast;
1061
1082
  });
1062
1083
  var failsBranches = ((ctx, branches, data, issueOf) => {
1063
- if (!ctx?._at)
1084
+ if (!ctx?._e)
1064
1085
  return true;
1065
1086
  const firsts = [];
1066
1087
  for (const branch of branches) {
@@ -1090,7 +1111,7 @@ var applyErrors = (apply, data, config, onFail, Ctx) => {
1090
1111
  var applyNodeErrors = (node, data, config, onFail, Ctx) => applyErrors(node.tApply, data, config, onFail, Ctx);
1091
1112
  var elementsFrom = (allows, apply, i, data) => (_, ctx) => {
1092
1113
  for (let j = i; j < data.length; j++)
1093
- if (!allows(data[j]) && ctx._in(apply, data, j))
1114
+ if (!allows(data[j]) && ctx._k(apply, data, j))
1094
1115
  return false;
1095
1116
  return true;
1096
1117
  };
@@ -1109,9 +1130,9 @@ var applyCallErrors = (apply, data, args, onFail, Ctx) => {
1109
1130
  }
1110
1131
  return onFail ? onFail(errors) : errors;
1111
1132
  };
1112
- var unreadOf = (Ctx) => {
1133
+ var unreadClassOf = (Ctx) => {
1113
1134
  class Unread {
1114
- constructor(apply, data) {
1135
+ constructor(data, config, apply) {
1115
1136
  this._a = apply;
1116
1137
  this._d = data;
1117
1138
  }
@@ -1124,13 +1145,21 @@ var unreadOf = (Ctx) => {
1124
1145
  return Unread;
1125
1146
  };
1126
1147
  var unreadArkErrors;
1127
- var UnreadArkErrors = () => unreadArkErrors ??= unreadOf(ArkErrors2);
1128
- var unreadErrors = (apply, data, onFail, Ctx) => {
1129
- const errors = new (Ctx())(apply, data);
1148
+ var unreadClasses = /* @__PURE__ */ new Map();
1149
+ var unreadOf = (Ctx) => {
1150
+ if (Ctx === ArkErrors2)
1151
+ return unreadArkErrors ??= unreadClassOf(Ctx);
1152
+ let unread = unreadClasses.get(Ctx);
1153
+ if (!unread)
1154
+ unreadClasses.set(Ctx, unread = unreadClassOf(Ctx));
1155
+ return unread;
1156
+ };
1157
+ var unreadErrors = (apply, data, onFail, Ctx = ArkErrors2) => {
1158
+ const errors = new (findsOnRead ? Ctx : unreadOf(Ctx))(data, 0, apply);
1130
1159
  return onFail ? onFail(errors) : errors;
1131
1160
  };
1132
- var unreadCallErrors = (apply, data, args, onFail, Ctx) => {
1133
- const errors = new (Ctx())(apply, data);
1161
+ var unreadCallErrors = (apply, data, args, onFail, Ctx = ArkErrors2) => {
1162
+ const errors = new (findsOnRead ? Ctx : unreadOf(Ctx))(data, 0, apply);
1134
1163
  if (args.length) {
1135
1164
  if (args[0])
1136
1165
  return args[0].piped(errors);
@@ -1140,8 +1169,6 @@ var unreadCallErrors = (apply, data, args, onFail, Ctx) => {
1140
1169
  return onFail ? onFail(errors) : errors;
1141
1170
  };
1142
1171
  var emptyMeta = /* @__PURE__ */ freeze({});
1143
- var unreadFirstIssues;
1144
- var UnreadFirstIssues = () => unreadFirstIssues ??= unreadOf(FirstIssues);
1145
1172
  var firstIssue = (errors) => {
1146
1173
  const unread = errors;
1147
1174
  if (unread._1)
@@ -1208,13 +1235,44 @@ var describeShape = (value) => {
1208
1235
  const keys = Reflect.ownKeys(value);
1209
1236
  return keys.length ? `${prototype ? "an" : "a"} ${kind} with keys ${keys.map(String).join(", ")}` : `an empty ${kind}`;
1210
1237
  };
1211
- var checkFacts = (actual, expected, label) => {
1238
+ var digestOf = (value) => {
1239
+ let low = 3735928559;
1240
+ let high = 1103547991;
1241
+ const add = (part) => {
1242
+ for (let i = 0; i <= part.length; i++) {
1243
+ const code = i < part.length ? part.charCodeAt(i) : 1114111;
1244
+ low = Math.imul(low ^ code, 2654435761);
1245
+ high = Math.imul(high ^ code, 1597334677);
1246
+ }
1247
+ };
1248
+ const prototype = prototypeOf(value);
1249
+ add(Array.isArray(value) ? "array" : prototype === Object.prototype ? "object" : prototype === null ? "null" : "instance");
1250
+ for (const k of Reflect.ownKeys(value)) {
1251
+ if (k === "length" && Array.isArray(value))
1252
+ continue;
1253
+ const v = Reflect.get(value, k);
1254
+ add(String(k));
1255
+ add(typeof v);
1256
+ add(Object.is(v, -0) ? "-0" : String(v));
1257
+ }
1258
+ low = Math.imul(low ^ low >>> 16, 2246822507) ^ Math.imul(high ^ high >>> 13, 3266489909);
1259
+ high = Math.imul(high ^ high >>> 16, 2246822507) ^ Math.imul(low ^ low >>> 13, 3266489909);
1260
+ return (4294967296 * (2097151 & high) + (low >>> 0)).toString(36);
1261
+ };
1262
+ var writeDigestMismatchMessage = (label) => `${label} holds other keys or values than it was precompiled with`;
1263
+ var unnamed2 = "A value a validator reads";
1264
+ var checkDigest = (value, expected, label = unnamed2) => {
1265
+ if (!hasDomain(value, "object") || digestOf(value) !== expected)
1266
+ throwError(writeDigestMismatchMessage(label));
1267
+ };
1268
+ var checkFacts = (actual, expected, label = unnamed2) => {
1212
1269
  if (actual !== expected) {
1213
1270
  throwError(writeCreationMismatchMessage(label, describeFact(actual), describeFact(expected)));
1214
1271
  }
1215
1272
  };
1273
+ var checkArity = (value, expected, label) => checkFacts(typeof value !== "function" || isValidator(value) ? describeValue(value) : Math.min(value.length, 2), expected, label);
1216
1274
  var describeFact = (fact) => typeof fact === "string" ? fact : `a function of ${fact === 0 ? "no parameters" : fact === 1 ? "1 parameter" : "2 or more parameters"}`;
1217
- var checkIdentity = (value, expected, label, expectedLabel) => {
1275
+ var checkIdentity = (value, expected, label = unnamed2, expectedLabel = "another it reads") => {
1218
1276
  if (value !== expected)
1219
1277
  throwError(writeIdentityMismatchMessage(label, expectedLabel));
1220
1278
  };
@@ -1238,7 +1296,7 @@ var checkDefault = (validator, value, key, defaultKey) => {
1238
1296
  }
1239
1297
  checked.value = true;
1240
1298
  };
1241
- var checkInput = (value, expected, label) => {
1299
+ var checkInput = (value, expected, label = unnamed2) => {
1242
1300
  if (!is(value, expected)) {
1243
1301
  throwError(writeCreationMismatchMessage(label, describeValue(value), describeValue(expected)));
1244
1302
  }
@@ -1247,12 +1305,12 @@ var checkProgress = (progress, at, name) => {
1247
1305
  if (progress === void 0 || progress < at)
1248
1306
  throw new ReferenceError(`Cannot access '${name}' before initialization`);
1249
1307
  };
1250
- var checkFunction = (value, label) => {
1308
+ var checkFunction = (value, label = unnamed2) => {
1251
1309
  if (typeof value !== "function") {
1252
1310
  throwError(writeCreationMismatchMessage(label, describeValue(value), "a function"));
1253
1311
  }
1254
1312
  };
1255
- var checkHeld = (value, label = "A value a validator reads", kind = "Type") => {
1313
+ var checkHeld = (value, label = unnamed2, kind = "Type") => {
1256
1314
  if (value === void 0) {
1257
1315
  throwError(writeCreationMismatchMessage(label, describeValue(value), `the ${kind} it was at build`));
1258
1316
  }
@@ -1262,7 +1320,7 @@ var holdHoles = ((value, id, holes = []) => {
1262
1320
  holesByValue.set(value, [id, freeze(holes)]);
1263
1321
  return value;
1264
1322
  });
1265
- var holesOf = ((holder, id, label, kind = "Type") => {
1323
+ var holesOf = ((holder, id, label = unnamed2, kind = "Type") => {
1266
1324
  const created = holesByValue.get(holder);
1267
1325
  if (created?.[0] !== id) {
1268
1326
  return throwError(writeCreationMismatchMessage(label, created ? `another ${kind}` : describeValue(holder), `the ${kind} it was at build`));
@@ -1299,6 +1357,8 @@ var intern = (table, holes, create, defaults = []) => {
1299
1357
  create();
1300
1358
  return table.value ??= create();
1301
1359
  };
1360
+ var tablesByHolder = /* @__PURE__ */ new InternTable();
1361
+ var internIn = (holder, holes, create, defaults) => intern(tablesByHolder.next(holder), holes, create, defaults);
1302
1362
  var interned = (key, create, ...args) => intern(internedTable(key), [], () => create(...args));
1303
1363
  var helpersKey = /* @__PURE__ */ Symbol.for("arktype.helpers");
1304
1364
  var checkHelper = (helper, file, name, label) => {
@@ -1332,8 +1392,13 @@ export {
1332
1392
  holdingAlias,
1333
1393
  narrowedInCtx,
1334
1394
  narrowedAfter,
1395
+ transformingNarrowedAfter,
1335
1396
  narrowedByEach,
1336
1397
  narrowed,
1398
+ unnamed,
1399
+ rejecting,
1400
+ rejectsWith,
1401
+ narrowedRejecting,
1337
1402
  allowsOf,
1338
1403
  stringCheck,
1339
1404
  numberCheck,
@@ -1360,6 +1425,8 @@ export {
1360
1425
  writtenBy,
1361
1426
  replacingUndefined,
1362
1427
  required,
1428
+ sayingMissing,
1429
+ saying,
1363
1430
  props,
1364
1431
  closedProps,
1365
1432
  recordOf,
@@ -1370,6 +1437,7 @@ export {
1370
1437
  failingClosedProps,
1371
1438
  deletingProps,
1372
1439
  failingDeletingProps,
1440
+ sitedProps,
1373
1441
  sited,
1374
1442
  elementsOf,
1375
1443
  transformingElementsOf,
@@ -1380,8 +1448,10 @@ export {
1380
1448
  transformOf,
1381
1449
  checkerNode,
1382
1450
  ctxNode,
1451
+ readingCtxNode,
1383
1452
  failingBranches,
1384
1453
  units,
1454
+ describeDomains,
1385
1455
  domains,
1386
1456
  nullableDescriptionOf,
1387
1457
  nullable,
@@ -1389,13 +1459,12 @@ export {
1389
1459
  discriminate,
1390
1460
  discriminateOr,
1391
1461
  union,
1392
- precompiledForArktype_3_0_0_beta_0,
1462
+ precompiledForArktype_3_0_0_beta_1,
1393
1463
  assign,
1394
1464
  is,
1395
1465
  freeze,
1396
1466
  setPrototypeOf,
1397
1467
  Validator,
1398
- lacks,
1399
1468
  own,
1400
1469
  bakeInto,
1401
1470
  standardResultOf,
@@ -1419,10 +1488,13 @@ export {
1419
1488
  typedFn,
1420
1489
  type,
1421
1490
  canParseUrl,
1422
- problemSiteOf,
1491
+ codeSiteOf,
1423
1492
  writtenSiteOf,
1424
1493
  raisingTraversalOf,
1425
1494
  failsAt,
1495
+ failsWith,
1496
+ failsKeyWith,
1497
+ failsAtKey,
1426
1498
  failsAtPath,
1427
1499
  failsIn,
1428
1500
  ownIssue,
@@ -1432,17 +1504,19 @@ export {
1432
1504
  applyNodeErrors,
1433
1505
  applyElements,
1434
1506
  applyCallErrors,
1435
- UnreadArkErrors,
1436
1507
  unreadErrors,
1437
1508
  unreadCallErrors,
1438
1509
  emptyMeta,
1439
- UnreadFirstIssues,
1440
1510
  firstIssue,
1441
1511
  InvalidErrors,
1442
1512
  unreadElements,
1443
1513
  factOfHole,
1444
1514
  describeShape,
1515
+ digestOf,
1516
+ writeDigestMismatchMessage,
1517
+ checkDigest,
1445
1518
  checkFacts,
1519
+ checkArity,
1446
1520
  checkIdentity,
1447
1521
  checkDefault,
1448
1522
  checkInput,
@@ -1455,6 +1529,7 @@ export {
1455
1529
  internTable,
1456
1530
  internedTable,
1457
1531
  intern,
1532
+ internIn,
1458
1533
  interned,
1459
1534
  checkHelper,
1460
1535
  writeCreationMismatchMessage,