@alienplatform/bindings 3.3.11 → 3.3.13

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/loader.js CHANGED
@@ -3,7 +3,8 @@ import { AlienError, BindingNotFoundError, defineError } from "@alienplatform/co
3
3
  import { existsSync } from "node:fs";
4
4
  import { dirname, join } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
- Object.freeze({ status: "aborted" });
6
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
7
+ var _a$1;
7
8
  function $constructor(name, initializer, params) {
8
9
  function init(inst, def) {
9
10
  if (!inst._zod) Object.defineProperty(inst, "_zod", {
@@ -54,13 +55,14 @@ var $ZodEncodeError = class extends Error {
54
55
  this.name = "ZodEncodeError";
55
56
  }
56
57
  };
57
- const globalConfig = {};
58
+ (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
59
+ const globalConfig = globalThis.__zod_globalConfig;
58
60
  function config(newConfig) {
59
61
  if (newConfig) Object.assign(globalConfig, newConfig);
60
62
  return globalConfig;
61
63
  }
62
64
  //#endregion
63
- //#region ../../node_modules/.pnpm/zod@4.3.2/node_modules/zod/v4/core/util.js
65
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.js
64
66
  function getEnumValues(entries) {
65
67
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
66
68
  return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
@@ -86,7 +88,7 @@ function cleanRegex(source) {
86
88
  const end = source.endsWith("$") ? source.length - 1 : source.length;
87
89
  return source.slice(start, end);
88
90
  }
89
- const EVALUATING = Symbol("evaluating");
91
+ const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
90
92
  function defineLazy(object, key, getter) {
91
93
  let value = void 0;
92
94
  Object.defineProperty(object, key, {
@@ -130,7 +132,8 @@ const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace
130
132
  function isObject(data) {
131
133
  return typeof data === "object" && data !== null && !Array.isArray(data);
132
134
  }
133
- const allowsEval = cached$1(() => {
135
+ const allowsEval = /* @__PURE__*/ cached$1(() => {
136
+ if (globalConfig.jitless) return false;
134
137
  if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
135
138
  try {
136
139
  new Function("");
@@ -152,9 +155,11 @@ function isPlainObject(o) {
152
155
  function shallowClone(o) {
153
156
  if (isPlainObject(o)) return { ...o };
154
157
  if (Array.isArray(o)) return [...o];
158
+ if (o instanceof Map) return new Map(o);
159
+ if (o instanceof Set) return new Set(o);
155
160
  return o;
156
161
  }
157
- const propertyKeyTypes = /* @__PURE__ */ new Set([
162
+ const propertyKeyTypes = /* @__PURE__*/ new Set([
158
163
  "string",
159
164
  "number",
160
165
  "symbol"
@@ -252,6 +257,7 @@ function safeExtend(schema, shape) {
252
257
  } }));
253
258
  }
254
259
  function merge(a, b) {
260
+ if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
255
261
  return clone(a, mergeDefs(a._zod.def, {
256
262
  get shape() {
257
263
  const _shape = {
@@ -264,7 +270,7 @@ function merge(a, b) {
264
270
  get catchall() {
265
271
  return b._zod.def.catchall;
266
272
  },
267
- checks: []
273
+ checks: b._zod.def.checks ?? []
268
274
  }));
269
275
  }
270
276
  function partial(Class, schema, mask) {
@@ -317,6 +323,11 @@ function aborted(x, startIndex = 0) {
317
323
  for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
318
324
  return false;
319
325
  }
326
+ function explicitlyAborted(x, startIndex = 0) {
327
+ if (x.aborted === true) return true;
328
+ for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue === false) return true;
329
+ return false;
330
+ }
320
331
  function prefixIssues(path, issues) {
321
332
  return issues.map((iss) => {
322
333
  var _a;
@@ -329,15 +340,12 @@ function unwrapMessage(message) {
329
340
  return typeof message === "string" ? message : message?.message;
330
341
  }
331
342
  function finalizeIssue(iss, ctx, config) {
332
- const full = {
333
- ...iss,
334
- path: iss.path ?? []
335
- };
336
- if (!iss.message) full.message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
337
- delete full.inst;
338
- delete full.continue;
339
- if (!ctx?.reportInput) delete full.input;
340
- return full;
343
+ const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
344
+ const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
345
+ rest.path ?? (rest.path = []);
346
+ rest.message = message;
347
+ if (ctx?.reportInput) rest.input = _input;
348
+ return rest;
341
349
  }
342
350
  function getLengthableOrigin(input) {
343
351
  if (Array.isArray(input)) return "array";
@@ -355,7 +363,7 @@ function issue(...args) {
355
363
  return { ...iss };
356
364
  }
357
365
  //#endregion
358
- //#region ../../node_modules/.pnpm/zod@4.3.2/node_modules/zod/v4/core/errors.js
366
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/errors.js
359
367
  const initializer$1 = (inst, def) => {
360
368
  inst.name = "$ZodError";
361
369
  Object.defineProperty(inst, "_zod", {
@@ -388,23 +396,26 @@ function flattenError(error, mapper = (issue) => issue.message) {
388
396
  }
389
397
  function formatError(error, mapper = (issue) => issue.message) {
390
398
  const fieldErrors = { _errors: [] };
391
- const processError = (error) => {
392
- for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }));
393
- else if (issue.code === "invalid_key") processError({ issues: issue.issues });
394
- else if (issue.code === "invalid_element") processError({ issues: issue.issues });
395
- else if (issue.path.length === 0) fieldErrors._errors.push(mapper(issue));
399
+ const processError = (error, path = []) => {
400
+ for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
401
+ else if (issue.code === "invalid_key") processError({ issues: issue.issues }, [...path, ...issue.path]);
402
+ else if (issue.code === "invalid_element") processError({ issues: issue.issues }, [...path, ...issue.path]);
396
403
  else {
397
- let curr = fieldErrors;
398
- let i = 0;
399
- while (i < issue.path.length) {
400
- const el = issue.path[i];
401
- if (!(i === issue.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
402
- else {
403
- curr[el] = curr[el] || { _errors: [] };
404
- curr[el]._errors.push(mapper(issue));
404
+ const fullpath = [...path, ...issue.path];
405
+ if (fullpath.length === 0) fieldErrors._errors.push(mapper(issue));
406
+ else {
407
+ let curr = fieldErrors;
408
+ let i = 0;
409
+ while (i < fullpath.length) {
410
+ const el = fullpath[i];
411
+ if (!(i === fullpath.length - 1)) curr[el] = curr[el] || { _errors: [] };
412
+ else {
413
+ curr[el] = curr[el] || { _errors: [] };
414
+ curr[el]._errors.push(mapper(issue));
415
+ }
416
+ curr = curr[el];
417
+ i++;
405
418
  }
406
- curr = curr[el];
407
- i++;
408
419
  }
409
420
  }
410
421
  };
@@ -412,9 +423,12 @@ function formatError(error, mapper = (issue) => issue.message) {
412
423
  return fieldErrors;
413
424
  }
414
425
  //#endregion
415
- //#region ../../node_modules/.pnpm/zod@4.3.2/node_modules/zod/v4/core/parse.js
426
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/parse.js
416
427
  const _parse = (_Err) => (schema, value, _ctx, _params) => {
417
- const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
428
+ const ctx = _ctx ? {
429
+ ..._ctx,
430
+ async: false
431
+ } : { async: false };
418
432
  const result = schema._zod.run({
419
433
  value,
420
434
  issues: []
@@ -428,7 +442,10 @@ const _parse = (_Err) => (schema, value, _ctx, _params) => {
428
442
  return result.value;
429
443
  };
430
444
  const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
431
- const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
445
+ const ctx = _ctx ? {
446
+ ..._ctx,
447
+ async: true
448
+ } : { async: true };
432
449
  let result = schema._zod.run({
433
450
  value,
434
451
  issues: []
@@ -461,7 +478,10 @@ const _safeParse = (_Err) => (schema, value, _ctx) => {
461
478
  };
462
479
  const safeParse$1 = /* @__PURE__*/ _safeParse($ZodRealError);
463
480
  const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
464
- const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
481
+ const ctx = _ctx ? {
482
+ ..._ctx,
483
+ async: true
484
+ } : { async: true };
465
485
  let result = schema._zod.run({
466
486
  value,
467
487
  issues: []
@@ -477,36 +497,53 @@ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
477
497
  };
478
498
  const safeParseAsync$1 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
479
499
  const _encode = (_Err) => (schema, value, _ctx) => {
480
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
500
+ const ctx = _ctx ? {
501
+ ..._ctx,
502
+ direction: "backward"
503
+ } : { direction: "backward" };
481
504
  return _parse(_Err)(schema, value, ctx);
482
505
  };
483
506
  const _decode = (_Err) => (schema, value, _ctx) => {
484
507
  return _parse(_Err)(schema, value, _ctx);
485
508
  };
486
509
  const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
487
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
510
+ const ctx = _ctx ? {
511
+ ..._ctx,
512
+ direction: "backward"
513
+ } : { direction: "backward" };
488
514
  return _parseAsync(_Err)(schema, value, ctx);
489
515
  };
490
516
  const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
491
517
  return _parseAsync(_Err)(schema, value, _ctx);
492
518
  };
493
519
  const _safeEncode = (_Err) => (schema, value, _ctx) => {
494
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
520
+ const ctx = _ctx ? {
521
+ ..._ctx,
522
+ direction: "backward"
523
+ } : { direction: "backward" };
495
524
  return _safeParse(_Err)(schema, value, ctx);
496
525
  };
497
526
  const _safeDecode = (_Err) => (schema, value, _ctx) => {
498
527
  return _safeParse(_Err)(schema, value, _ctx);
499
528
  };
500
529
  const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
501
- const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
530
+ const ctx = _ctx ? {
531
+ ..._ctx,
532
+ direction: "backward"
533
+ } : { direction: "backward" };
502
534
  return _safeParseAsync(_Err)(schema, value, ctx);
503
535
  };
504
536
  const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
505
537
  return _safeParseAsync(_Err)(schema, value, _ctx);
506
538
  };
507
539
  //#endregion
508
- //#region ../../node_modules/.pnpm/zod@4.3.2/node_modules/zod/v4/core/regexes.js
509
- const cuid = /^[cC][^\s-]{8,}$/;
540
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/regexes.js
541
+ /**
542
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
543
+ * (timestamps embedded in the id). Use {@link cuid2} instead.
544
+ * See https://github.com/paralleldrive/cuid.
545
+ */
546
+ const cuid = /^[cC][0-9a-z]{6,}$/;
510
547
  const cuid2 = /^[0-9a-z]+$/;
511
548
  const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
512
549
  const xid = /^[0-9a-vA-V]{20}$/;
@@ -535,6 +572,7 @@ const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-
535
572
  const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
536
573
  const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
537
574
  const base64url = /^[A-Za-z0-9_-]*$/;
575
+ const httpProtocol = /^https?$/;
538
576
  const e164 = /^\+[1-9]\d{6,14}$/;
539
577
  const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
540
578
  const date$1 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
@@ -560,7 +598,7 @@ const string$1 = (params) => {
560
598
  const lowercase = /^[^A-Z]*$/;
561
599
  const uppercase = /^[^a-z]*$/;
562
600
  //#endregion
563
- //#region ../../node_modules/.pnpm/zod@4.3.2/node_modules/zod/v4/core/checks.js
601
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/checks.js
564
602
  const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
565
603
  var _a;
566
604
  inst._zod ?? (inst._zod = {});
@@ -779,7 +817,7 @@ const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (ins
779
817
  };
780
818
  });
781
819
  //#endregion
782
- //#region ../../node_modules/.pnpm/zod@4.3.2/node_modules/zod/v4/core/doc.js
820
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/doc.js
783
821
  var Doc = class {
784
822
  constructor(args = []) {
785
823
  this.content = [];
@@ -810,14 +848,14 @@ var Doc = class {
810
848
  }
811
849
  };
812
850
  //#endregion
813
- //#region ../../node_modules/.pnpm/zod@4.3.2/node_modules/zod/v4/core/versions.js
851
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/versions.js
814
852
  const version = {
815
853
  major: 4,
816
- minor: 3,
817
- patch: 2
854
+ minor: 4,
855
+ patch: 3
818
856
  };
819
857
  //#endregion
820
- //#region ../../node_modules/.pnpm/zod@4.3.2/node_modules/zod/v4/core/schemas.js
858
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/schemas.js
821
859
  const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
822
860
  var _a;
823
861
  inst ?? (inst = {});
@@ -838,6 +876,7 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
838
876
  let asyncResult;
839
877
  for (const ch of checks) {
840
878
  if (ch._zod.def.when) {
879
+ if (explicitlyAborted(payload)) continue;
841
880
  if (!ch._zod.def.when(payload)) continue;
842
881
  } else if (isAborted) continue;
843
882
  const currLen = payload.issues.length;
@@ -957,6 +996,19 @@ const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
957
996
  inst._zod.check = (payload) => {
958
997
  try {
959
998
  const trimmed = payload.value.trim();
999
+ if (!def.normalize && def.protocol?.source === httpProtocol.source) {
1000
+ if (!/^https?:\/\//i.test(trimmed)) {
1001
+ payload.issues.push({
1002
+ code: "invalid_format",
1003
+ format: "url",
1004
+ note: "Invalid URL format",
1005
+ input: payload.value,
1006
+ inst,
1007
+ continue: !def.abort
1008
+ });
1009
+ return;
1010
+ }
1011
+ }
960
1012
  const url = new URL(trimmed);
961
1013
  if (def.hostname) {
962
1014
  def.hostname.lastIndex = 0;
@@ -1004,6 +1056,11 @@ const $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
1004
1056
  def.pattern ?? (def.pattern = nanoid);
1005
1057
  $ZodStringFormat.init(inst, def);
1006
1058
  });
1059
+ /**
1060
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
1061
+ * (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
1062
+ * See https://github.com/paralleldrive/cuid.
1063
+ */
1007
1064
  const $ZodCUID = /*@__PURE__*/ $constructor("$ZodCUID", (inst, def) => {
1008
1065
  def.pattern ?? (def.pattern = cuid);
1009
1066
  $ZodStringFormat.init(inst, def);
@@ -1093,6 +1150,7 @@ const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
1093
1150
  });
1094
1151
  function isValidBase64(data) {
1095
1152
  if (data === "") return true;
1153
+ if (/\s/.test(data)) return false;
1096
1154
  if (data.length % 4 !== 0) return false;
1097
1155
  try {
1098
1156
  atob(data);
@@ -1216,13 +1274,23 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1216
1274
  return payload;
1217
1275
  };
1218
1276
  });
1219
- function handlePropertyResult(result, final, key, input, isOptionalOut) {
1277
+ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
1278
+ const isPresent = key in input;
1220
1279
  if (result.issues.length) {
1221
- if (isOptionalOut && !(key in input)) return;
1280
+ if (isOptionalIn && isOptionalOut && !isPresent) return;
1222
1281
  final.issues.push(...prefixIssues(key, result.issues));
1223
1282
  }
1283
+ if (!isPresent && !isOptionalIn) {
1284
+ if (!result.issues.length) final.issues.push({
1285
+ code: "invalid_type",
1286
+ expected: "nonoptional",
1287
+ input: void 0,
1288
+ path: [key]
1289
+ });
1290
+ return;
1291
+ }
1224
1292
  if (result.value === void 0) {
1225
- if (key in input) final.value[key] = void 0;
1293
+ if (isPresent) final.value[key] = void 0;
1226
1294
  } else final.value[key] = result.value;
1227
1295
  }
1228
1296
  function normalizeDef(def) {
@@ -1242,8 +1310,10 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1242
1310
  const keySet = def.keySet;
1243
1311
  const _catchall = def.catchall._zod;
1244
1312
  const t = _catchall.def.type;
1313
+ const isOptionalIn = _catchall.optin === "optional";
1245
1314
  const isOptionalOut = _catchall.optout === "optional";
1246
1315
  for (const key in input) {
1316
+ if (key === "__proto__") continue;
1247
1317
  if (keySet.has(key)) continue;
1248
1318
  if (t === "never") {
1249
1319
  unrecognized.push(key);
@@ -1253,8 +1323,8 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1253
1323
  value: input[key],
1254
1324
  issues: []
1255
1325
  }, ctx);
1256
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
1257
- else handlePropertyResult(r, payload, key, input, isOptionalOut);
1326
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1327
+ else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
1258
1328
  }
1259
1329
  if (unrecognized.length) payload.issues.push({
1260
1330
  code: "unrecognized_keys",
@@ -1310,13 +1380,14 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1310
1380
  const shape = value.shape;
1311
1381
  for (const key of value.keys) {
1312
1382
  const el = shape[key];
1383
+ const isOptionalIn = el._zod.optin === "optional";
1313
1384
  const isOptionalOut = el._zod.optout === "optional";
1314
1385
  const r = el._zod.run({
1315
1386
  value: input[key],
1316
1387
  issues: []
1317
1388
  }, ctx);
1318
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
1319
- else handlePropertyResult(r, payload, key, input, isOptionalOut);
1389
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1390
+ else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
1320
1391
  }
1321
1392
  if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
1322
1393
  return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
@@ -1345,9 +1416,11 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
1345
1416
  for (const key of normalized.keys) {
1346
1417
  const id = ids[key];
1347
1418
  const k = esc(key);
1348
- const isOptionalOut = shape[key]?._zod?.optout === "optional";
1419
+ const schema = shape[key];
1420
+ const isOptionalIn = schema?._zod?.optin === "optional";
1421
+ const isOptionalOut = schema?._zod?.optout === "optional";
1349
1422
  doc.write(`const ${id} = ${parseStr(key)};`);
1350
- if (isOptionalOut) doc.write(`
1423
+ if (isOptionalIn && isOptionalOut) doc.write(`
1351
1424
  if (${id}.issues.length) {
1352
1425
  if (${k} in input) {
1353
1426
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
@@ -1365,6 +1438,32 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
1365
1438
  newResult[${k}] = ${id}.value;
1366
1439
  }
1367
1440
 
1441
+ `);
1442
+ else if (!isOptionalIn) doc.write(`
1443
+ const ${id}_present = ${k} in input;
1444
+ if (${id}.issues.length) {
1445
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1446
+ ...iss,
1447
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1448
+ })));
1449
+ }
1450
+ if (!${id}_present && !${id}.issues.length) {
1451
+ payload.issues.push({
1452
+ code: "invalid_type",
1453
+ expected: "nonoptional",
1454
+ input: undefined,
1455
+ path: [${k}]
1456
+ });
1457
+ }
1458
+
1459
+ if (${id}_present) {
1460
+ if (${id}.value === undefined) {
1461
+ newResult[${k}] = undefined;
1462
+ } else {
1463
+ newResult[${k}] = ${id}.value;
1464
+ }
1465
+ }
1466
+
1368
1467
  `);
1369
1468
  else doc.write(`
1370
1469
  if (${id}.issues.length) {
@@ -1447,10 +1546,9 @@ const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
1447
1546
  return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
1448
1547
  }
1449
1548
  });
1450
- const single = def.options.length === 1;
1451
- const first = def.options[0]._zod.run;
1549
+ const first = def.options.length === 1 ? def.options[0]._zod.run : null;
1452
1550
  inst._zod.parse = (payload, ctx) => {
1453
- if (single) return first(payload, ctx);
1551
+ if (first) return first(payload, ctx);
1454
1552
  let async = false;
1455
1553
  const results = [];
1456
1554
  for (const option of def.options) {
@@ -1472,6 +1570,62 @@ const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
1472
1570
  });
1473
1571
  };
1474
1572
  });
1573
+ const $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
1574
+ def.inclusive = false;
1575
+ $ZodUnion.init(inst, def);
1576
+ const _super = inst._zod.parse;
1577
+ defineLazy(inst._zod, "propValues", () => {
1578
+ const propValues = {};
1579
+ for (const option of def.options) {
1580
+ const pv = option._zod.propValues;
1581
+ if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
1582
+ for (const [k, v] of Object.entries(pv)) {
1583
+ if (!propValues[k]) propValues[k] = /* @__PURE__ */ new Set();
1584
+ for (const val of v) propValues[k].add(val);
1585
+ }
1586
+ }
1587
+ return propValues;
1588
+ });
1589
+ const disc = cached$1(() => {
1590
+ const opts = def.options;
1591
+ const map = /* @__PURE__ */ new Map();
1592
+ for (const o of opts) {
1593
+ const values = o._zod.propValues?.[def.discriminator];
1594
+ if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
1595
+ for (const v of values) {
1596
+ if (map.has(v)) throw new Error(`Duplicate discriminator value "${String(v)}"`);
1597
+ map.set(v, o);
1598
+ }
1599
+ }
1600
+ return map;
1601
+ });
1602
+ inst._zod.parse = (payload, ctx) => {
1603
+ const input = payload.value;
1604
+ if (!isObject(input)) {
1605
+ payload.issues.push({
1606
+ code: "invalid_type",
1607
+ expected: "object",
1608
+ input,
1609
+ inst
1610
+ });
1611
+ return payload;
1612
+ }
1613
+ const opt = disc.value.get(input?.[def.discriminator]);
1614
+ if (opt) return opt._zod.run(payload, ctx);
1615
+ if (def.unionFallback || ctx.direction === "backward") return _super(payload, ctx);
1616
+ payload.issues.push({
1617
+ code: "invalid_union",
1618
+ errors: [],
1619
+ note: "No matching discriminator",
1620
+ discriminator: def.discriminator,
1621
+ options: Array.from(disc.value.keys()),
1622
+ input,
1623
+ path: [def.discriminator],
1624
+ inst
1625
+ });
1626
+ return payload;
1627
+ };
1628
+ });
1475
1629
  const $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (inst, def) => {
1476
1630
  $ZodType.init(inst, def);
1477
1631
  inst._zod.parse = (payload, ctx) => {
@@ -1589,22 +1743,43 @@ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
1589
1743
  return payload;
1590
1744
  };
1591
1745
  });
1746
+ const $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
1747
+ $ZodType.init(inst, def);
1748
+ if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
1749
+ const values = new Set(def.values);
1750
+ inst._zod.values = values;
1751
+ inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
1752
+ inst._zod.parse = (payload, _ctx) => {
1753
+ const input = payload.value;
1754
+ if (values.has(input)) return payload;
1755
+ payload.issues.push({
1756
+ code: "invalid_value",
1757
+ values: def.values,
1758
+ input,
1759
+ inst
1760
+ });
1761
+ return payload;
1762
+ };
1763
+ });
1592
1764
  const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
1593
1765
  $ZodType.init(inst, def);
1766
+ inst._zod.optin = "optional";
1594
1767
  inst._zod.parse = (payload, ctx) => {
1595
1768
  if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
1596
1769
  const _out = def.transform(payload.value, payload);
1597
1770
  if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
1598
1771
  payload.value = output;
1772
+ payload.fallback = true;
1599
1773
  return payload;
1600
1774
  });
1601
1775
  if (_out instanceof Promise) throw new $ZodAsyncError();
1602
1776
  payload.value = _out;
1777
+ payload.fallback = true;
1603
1778
  return payload;
1604
1779
  };
1605
1780
  });
1606
1781
  function handleOptionalResult(result, input) {
1607
- if (result.issues.length && input === void 0) return {
1782
+ if (input === void 0 && (result.issues.length || result.fallback)) return {
1608
1783
  issues: [],
1609
1784
  value: void 0
1610
1785
  };
@@ -1623,9 +1798,10 @@ const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
1623
1798
  });
1624
1799
  inst._zod.parse = (payload, ctx) => {
1625
1800
  if (def.innerType._zod.optin === "optional") {
1801
+ const input = payload.value;
1626
1802
  const result = def.innerType._zod.run(payload, ctx);
1627
- if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, payload.value));
1628
- return handleOptionalResult(result, payload.value);
1803
+ if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, input));
1804
+ return handleOptionalResult(result, input);
1629
1805
  }
1630
1806
  if (payload.value === void 0) return payload;
1631
1807
  return def.innerType._zod.run(payload, ctx);
@@ -1710,7 +1886,7 @@ function handleNonOptionalResult(payload, inst) {
1710
1886
  }
1711
1887
  const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
1712
1888
  $ZodType.init(inst, def);
1713
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1889
+ inst._zod.optin = "optional";
1714
1890
  defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1715
1891
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1716
1892
  inst._zod.parse = (payload, ctx) => {
@@ -1725,6 +1901,7 @@ const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
1725
1901
  input: payload.value
1726
1902
  });
1727
1903
  payload.issues = [];
1904
+ payload.fallback = true;
1728
1905
  }
1729
1906
  return payload;
1730
1907
  });
@@ -1736,6 +1913,7 @@ const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
1736
1913
  input: payload.value
1737
1914
  });
1738
1915
  payload.issues = [];
1916
+ payload.fallback = true;
1739
1917
  }
1740
1918
  return payload;
1741
1919
  };
@@ -1764,7 +1942,8 @@ function handlePipeResult(left, next, ctx) {
1764
1942
  }
1765
1943
  return next._zod.run({
1766
1944
  value: left.value,
1767
- issues: left.issues
1945
+ issues: left.issues,
1946
+ fallback: left.fallback
1768
1947
  }, ctx);
1769
1948
  }
1770
1949
  const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
@@ -1811,7 +1990,7 @@ function handleRefineResult(result, payload, input, inst) {
1811
1990
  }
1812
1991
  }
1813
1992
  //#endregion
1814
- //#region ../../node_modules/.pnpm/zod@4.3.2/node_modules/zod/v4/core/registries.js
1993
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/registries.js
1815
1994
  var _a;
1816
1995
  var $ZodRegistry = class {
1817
1996
  constructor() {
@@ -1858,7 +2037,7 @@ function registry() {
1858
2037
  (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
1859
2038
  const globalRegistry = globalThis.__zod_globalRegistry;
1860
2039
  //#endregion
1861
- //#region ../../node_modules/.pnpm/zod@4.3.2/node_modules/zod/v4/core/api.js
2040
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/api.js
1862
2041
  // @__NO_SIDE_EFFECTS__
1863
2042
  function _string(Class, params) {
1864
2043
  return new Class({
@@ -1959,6 +2138,11 @@ function _nanoid(Class, params) {
1959
2138
  ...normalizeParams(params)
1960
2139
  });
1961
2140
  }
2141
+ /**
2142
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
2143
+ * (timestamps embedded in the id). Use {@link _cuid2} instead.
2144
+ * See https://github.com/paralleldrive/cuid.
2145
+ */
1962
2146
  // @__NO_SIDE_EFFECTS__
1963
2147
  function _cuid(Class, params) {
1964
2148
  return new Class({
@@ -2261,7 +2445,7 @@ function _refine(Class, fn, _params) {
2261
2445
  });
2262
2446
  }
2263
2447
  // @__NO_SIDE_EFFECTS__
2264
- function _superRefine(fn) {
2448
+ function _superRefine(fn, params) {
2265
2449
  const ch = /* @__PURE__ */ _check((payload) => {
2266
2450
  payload.addIssue = (issue$2) => {
2267
2451
  if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
@@ -2276,7 +2460,7 @@ function _superRefine(fn) {
2276
2460
  }
2277
2461
  };
2278
2462
  return fn(payload.value, payload);
2279
- });
2463
+ }, params);
2280
2464
  return ch;
2281
2465
  }
2282
2466
  // @__NO_SIDE_EFFECTS__
@@ -2289,7 +2473,7 @@ function _check(fn, params) {
2289
2473
  return ch;
2290
2474
  }
2291
2475
  //#endregion
2292
- //#region ../../node_modules/.pnpm/zod@4.3.2/node_modules/zod/v4/core/to-json-schema.js
2476
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/to-json-schema.js
2293
2477
  function initializeContext(params) {
2294
2478
  let target = params?.target ?? "draft-2020-12";
2295
2479
  if (target === "draft-4") target = "draft-04";
@@ -2355,7 +2539,7 @@ function process$1(schema, ctx, _params = {
2355
2539
  delete result.schema.examples;
2356
2540
  delete result.schema.default;
2357
2541
  }
2358
- if (ctx.io === "input" && result.schema._prefault) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
2542
+ if (ctx.io === "input" && "_prefault" in result.schema) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
2359
2543
  delete result.schema._prefault;
2360
2544
  return ctx.seen.get(schema).schema;
2361
2545
  }
@@ -2460,7 +2644,7 @@ function finalize(ctx, schema) {
2460
2644
  if (key === "$ref" || key === "allOf") continue;
2461
2645
  if (!(key in _cached)) delete schema[key];
2462
2646
  }
2463
- if (refSchema.$ref) for (const key in schema) {
2647
+ if (refSchema.$ref && refSeen.def) for (const key in schema) {
2464
2648
  if (key === "$ref" || key === "allOf") continue;
2465
2649
  if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) delete schema[key];
2466
2650
  }
@@ -2495,13 +2679,20 @@ function finalize(ctx, schema) {
2495
2679
  result.$id = ctx.external.uri(id);
2496
2680
  }
2497
2681
  Object.assign(result, root.def ?? root.schema);
2682
+ const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
2683
+ if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
2498
2684
  const defs = ctx.external?.defs ?? {};
2499
2685
  for (const entry of ctx.seen.entries()) {
2500
2686
  const seen = entry[1];
2501
- if (seen.def && seen.defId) defs[seen.defId] = seen.def;
2687
+ if (seen.def && seen.defId) {
2688
+ if (seen.def.id === seen.defId) delete seen.def.id;
2689
+ defs[seen.defId] = seen.def;
2690
+ }
2691
+ }
2692
+ if (ctx.external) {} else if (Object.keys(defs).length > 0) {
2693
+ if (ctx.target === "draft-2020-12") result.$defs = defs;
2694
+ else result.definitions = defs;
2502
2695
  }
2503
- if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
2504
- else result.definitions = defs;
2505
2696
  try {
2506
2697
  const finalized = JSON.parse(JSON.stringify(result));
2507
2698
  Object.defineProperty(finalized, "~standard", {
@@ -2532,7 +2723,10 @@ function isTransforming(_schema, _ctx) {
2532
2723
  if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
2533
2724
  if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
2534
2725
  if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
2535
- if (def.type === "pipe") return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
2726
+ if (def.type === "pipe") {
2727
+ if (_schema._zod.traits.has("$ZodCodec")) return true;
2728
+ return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
2729
+ }
2536
2730
  if (def.type === "object") {
2537
2731
  for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
2538
2732
  return false;
@@ -2574,7 +2768,7 @@ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params)
2574
2768
  return finalize(ctx, schema);
2575
2769
  };
2576
2770
  //#endregion
2577
- //#region ../../node_modules/.pnpm/zod@4.3.2/node_modules/zod/v4/core/json-schema-processors.js
2771
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/json-schema-processors.js
2578
2772
  const formatMap = {
2579
2773
  guid: "uuid",
2580
2774
  url: "uri",
@@ -2613,6 +2807,28 @@ const enumProcessor = (schema, _ctx, json, _params) => {
2613
2807
  if (values.every((v) => typeof v === "string")) json.type = "string";
2614
2808
  json.enum = values;
2615
2809
  };
2810
+ const literalProcessor = (schema, ctx, json, _params) => {
2811
+ const def = schema._zod.def;
2812
+ const vals = [];
2813
+ for (const val of def.values) if (val === void 0) {
2814
+ if (ctx.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
2815
+ } else if (typeof val === "bigint") {
2816
+ if (ctx.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
2817
+ else vals.push(Number(val));
2818
+ } else vals.push(val);
2819
+ if (vals.length === 0) {} else if (vals.length === 1) {
2820
+ const val = vals[0];
2821
+ json.type = val === null ? "null" : typeof val;
2822
+ if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") json.enum = [val];
2823
+ else json.const = val;
2824
+ } else {
2825
+ if (vals.every((v) => typeof v === "number")) json.type = "number";
2826
+ if (vals.every((v) => typeof v === "string")) json.type = "string";
2827
+ if (vals.every((v) => typeof v === "boolean")) json.type = "boolean";
2828
+ if (vals.every((v) => v === null)) json.type = "null";
2829
+ json.enum = vals;
2830
+ }
2831
+ };
2616
2832
  const customProcessor = (_schema, ctx, _json, _params) => {
2617
2833
  if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
2618
2834
  };
@@ -2739,7 +2955,8 @@ const catchProcessor = (schema, ctx, json, params) => {
2739
2955
  };
2740
2956
  const pipeProcessor = (schema, ctx, _json, params) => {
2741
2957
  const def = schema._zod.def;
2742
- const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
2958
+ const inIsTransform = def.in._zod.traits.has("$ZodTransform");
2959
+ const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
2743
2960
  process$1(innerType, ctx, params);
2744
2961
  const seen = ctx.seen.get(schema);
2745
2962
  seen.ref = innerType;
@@ -2758,7 +2975,7 @@ const optionalProcessor = (schema, ctx, _json, params) => {
2758
2975
  seen.ref = def.innerType;
2759
2976
  };
2760
2977
  //#endregion
2761
- //#region ../../node_modules/.pnpm/zod@4.3.2/node_modules/zod/v4/classic/iso.js
2978
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/iso.js
2762
2979
  const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
2763
2980
  $ZodISODateTime.init(inst, def);
2764
2981
  ZodStringFormat.init(inst, def);
@@ -2788,7 +3005,7 @@ function duration(params) {
2788
3005
  return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
2789
3006
  }
2790
3007
  //#endregion
2791
- //#region ../../node_modules/.pnpm/zod@4.3.2/node_modules/zod/v4/classic/errors.js
3008
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/errors.js
2792
3009
  const initializer = (inst, issues) => {
2793
3010
  $ZodError.init(inst, issues);
2794
3011
  inst.name = "ZodError";
@@ -2808,10 +3025,9 @@ const initializer = (inst, issues) => {
2808
3025
  } }
2809
3026
  });
2810
3027
  };
2811
- $constructor("ZodError", initializer);
2812
- const ZodRealError = $constructor("ZodError", initializer, { Parent: Error });
3028
+ const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, { Parent: Error });
2813
3029
  //#endregion
2814
- //#region ../../node_modules/.pnpm/zod@4.3.2/node_modules/zod/v4/classic/parse.js
3030
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/parse.js
2815
3031
  const parse = /* @__PURE__ */ _parse(ZodRealError);
2816
3032
  const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
2817
3033
  const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
@@ -2825,7 +3041,43 @@ const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
2825
3041
  const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
2826
3042
  const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
2827
3043
  //#endregion
2828
- //#region ../../node_modules/.pnpm/zod@4.3.2/node_modules/zod/v4/classic/schemas.js
3044
+ //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/schemas.js
3045
+ const _installedGroups = /* @__PURE__ */ new WeakMap();
3046
+ function _installLazyMethods(inst, group, methods) {
3047
+ const proto = Object.getPrototypeOf(inst);
3048
+ let installed = _installedGroups.get(proto);
3049
+ if (!installed) {
3050
+ installed = /* @__PURE__ */ new Set();
3051
+ _installedGroups.set(proto, installed);
3052
+ }
3053
+ if (installed.has(group)) return;
3054
+ installed.add(group);
3055
+ for (const key in methods) {
3056
+ const fn = methods[key];
3057
+ Object.defineProperty(proto, key, {
3058
+ configurable: true,
3059
+ enumerable: false,
3060
+ get() {
3061
+ const bound = fn.bind(this);
3062
+ Object.defineProperty(this, key, {
3063
+ configurable: true,
3064
+ writable: true,
3065
+ enumerable: true,
3066
+ value: bound
3067
+ });
3068
+ return bound;
3069
+ },
3070
+ set(v) {
3071
+ Object.defineProperty(this, key, {
3072
+ configurable: true,
3073
+ writable: true,
3074
+ enumerable: true,
3075
+ value: v
3076
+ });
3077
+ }
3078
+ });
3079
+ }
3080
+ }
2829
3081
  const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
2830
3082
  $ZodType.init(inst, def);
2831
3083
  Object.assign(inst["~standard"], { jsonSchema: {
@@ -2836,20 +3088,6 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
2836
3088
  inst.def = def;
2837
3089
  inst.type = def.type;
2838
3090
  Object.defineProperty(inst, "_def", { value: def });
2839
- inst.check = (...checks) => {
2840
- return inst.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
2841
- check: ch,
2842
- def: { check: "custom" },
2843
- onattach: []
2844
- } } : ch)] }), { parent: true });
2845
- };
2846
- inst.with = inst.check;
2847
- inst.clone = (def, params) => clone(inst, def, params);
2848
- inst.brand = () => inst;
2849
- inst.register = ((reg, meta) => {
2850
- reg.add(inst, meta);
2851
- return inst;
2852
- });
2853
3091
  inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
2854
3092
  inst.safeParse = (data, params) => safeParse(inst, data, params);
2855
3093
  inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
@@ -2863,43 +3101,106 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
2863
3101
  inst.safeDecode = (data, params) => safeDecode(inst, data, params);
2864
3102
  inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
2865
3103
  inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
2866
- inst.refine = (check, params) => inst.check(refine(check, params));
2867
- inst.superRefine = (refinement) => inst.check(superRefine(refinement));
2868
- inst.overwrite = (fn) => inst.check(/* @__PURE__ */ _overwrite(fn));
2869
- inst.optional = () => optional(inst);
2870
- inst.exactOptional = () => exactOptional(inst);
2871
- inst.nullable = () => nullable(inst);
2872
- inst.nullish = () => optional(nullable(inst));
2873
- inst.nonoptional = (params) => nonoptional(inst, params);
2874
- inst.array = () => array(inst);
2875
- inst.or = (arg) => union([inst, arg]);
2876
- inst.and = (arg) => intersection(inst, arg);
2877
- inst.transform = (tx) => pipe(inst, transform(tx));
2878
- inst.default = (def) => _default(inst, def);
2879
- inst.prefault = (def) => prefault(inst, def);
2880
- inst.catch = (params) => _catch(inst, params);
2881
- inst.pipe = (target) => pipe(inst, target);
2882
- inst.readonly = () => readonly(inst);
2883
- inst.describe = (description) => {
2884
- const cl = inst.clone();
2885
- globalRegistry.add(cl, { description });
2886
- return cl;
2887
- };
3104
+ _installLazyMethods(inst, "ZodType", {
3105
+ check(...chks) {
3106
+ const def = this.def;
3107
+ return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
3108
+ check: ch,
3109
+ def: { check: "custom" },
3110
+ onattach: []
3111
+ } } : ch)] }), { parent: true });
3112
+ },
3113
+ with(...chks) {
3114
+ return this.check(...chks);
3115
+ },
3116
+ clone(def, params) {
3117
+ return clone(this, def, params);
3118
+ },
3119
+ brand() {
3120
+ return this;
3121
+ },
3122
+ register(reg, meta) {
3123
+ reg.add(this, meta);
3124
+ return this;
3125
+ },
3126
+ refine(check, params) {
3127
+ return this.check(refine(check, params));
3128
+ },
3129
+ superRefine(refinement, params) {
3130
+ return this.check(superRefine(refinement, params));
3131
+ },
3132
+ overwrite(fn) {
3133
+ return this.check(/* @__PURE__ */ _overwrite(fn));
3134
+ },
3135
+ optional() {
3136
+ return optional(this);
3137
+ },
3138
+ exactOptional() {
3139
+ return exactOptional(this);
3140
+ },
3141
+ nullable() {
3142
+ return nullable(this);
3143
+ },
3144
+ nullish() {
3145
+ return optional(nullable(this));
3146
+ },
3147
+ nonoptional(params) {
3148
+ return nonoptional(this, params);
3149
+ },
3150
+ array() {
3151
+ return array(this);
3152
+ },
3153
+ or(arg) {
3154
+ return union([this, arg]);
3155
+ },
3156
+ and(arg) {
3157
+ return intersection(this, arg);
3158
+ },
3159
+ transform(tx) {
3160
+ return pipe(this, transform(tx));
3161
+ },
3162
+ default(d) {
3163
+ return _default(this, d);
3164
+ },
3165
+ prefault(d) {
3166
+ return prefault(this, d);
3167
+ },
3168
+ catch(params) {
3169
+ return _catch(this, params);
3170
+ },
3171
+ pipe(target) {
3172
+ return pipe(this, target);
3173
+ },
3174
+ readonly() {
3175
+ return readonly(this);
3176
+ },
3177
+ describe(description) {
3178
+ const cl = this.clone();
3179
+ globalRegistry.add(cl, { description });
3180
+ return cl;
3181
+ },
3182
+ meta(...args) {
3183
+ if (args.length === 0) return globalRegistry.get(this);
3184
+ const cl = this.clone();
3185
+ globalRegistry.add(cl, args[0]);
3186
+ return cl;
3187
+ },
3188
+ isOptional() {
3189
+ return this.safeParse(void 0).success;
3190
+ },
3191
+ isNullable() {
3192
+ return this.safeParse(null).success;
3193
+ },
3194
+ apply(fn) {
3195
+ return fn(this);
3196
+ }
3197
+ });
2888
3198
  Object.defineProperty(inst, "description", {
2889
3199
  get() {
2890
3200
  return globalRegistry.get(inst)?.description;
2891
3201
  },
2892
3202
  configurable: true
2893
3203
  });
2894
- inst.meta = (...args) => {
2895
- if (args.length === 0) return globalRegistry.get(inst);
2896
- const cl = inst.clone();
2897
- globalRegistry.add(cl, args[0]);
2898
- return cl;
2899
- };
2900
- inst.isOptional = () => inst.safeParse(void 0).success;
2901
- inst.isNullable = () => inst.safeParse(null).success;
2902
- inst.apply = (fn) => fn(inst);
2903
3204
  return inst;
2904
3205
  });
2905
3206
  /** @internal */
@@ -2911,21 +3212,53 @@ const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
2911
3212
  inst.format = bag.format ?? null;
2912
3213
  inst.minLength = bag.minimum ?? null;
2913
3214
  inst.maxLength = bag.maximum ?? null;
2914
- inst.regex = (...args) => inst.check(/* @__PURE__ */ _regex(...args));
2915
- inst.includes = (...args) => inst.check(/* @__PURE__ */ _includes(...args));
2916
- inst.startsWith = (...args) => inst.check(/* @__PURE__ */ _startsWith(...args));
2917
- inst.endsWith = (...args) => inst.check(/* @__PURE__ */ _endsWith(...args));
2918
- inst.min = (...args) => inst.check(/* @__PURE__ */ _minLength(...args));
2919
- inst.max = (...args) => inst.check(/* @__PURE__ */ _maxLength(...args));
2920
- inst.length = (...args) => inst.check(/* @__PURE__ */ _length(...args));
2921
- inst.nonempty = (...args) => inst.check(/* @__PURE__ */ _minLength(1, ...args));
2922
- inst.lowercase = (params) => inst.check(/* @__PURE__ */ _lowercase(params));
2923
- inst.uppercase = (params) => inst.check(/* @__PURE__ */ _uppercase(params));
2924
- inst.trim = () => inst.check(/* @__PURE__ */ _trim());
2925
- inst.normalize = (...args) => inst.check(/* @__PURE__ */ _normalize(...args));
2926
- inst.toLowerCase = () => inst.check(/* @__PURE__ */ _toLowerCase());
2927
- inst.toUpperCase = () => inst.check(/* @__PURE__ */ _toUpperCase());
2928
- inst.slugify = () => inst.check(/* @__PURE__ */ _slugify());
3215
+ _installLazyMethods(inst, "_ZodString", {
3216
+ regex(...args) {
3217
+ return this.check(/* @__PURE__ */ _regex(...args));
3218
+ },
3219
+ includes(...args) {
3220
+ return this.check(/* @__PURE__ */ _includes(...args));
3221
+ },
3222
+ startsWith(...args) {
3223
+ return this.check(/* @__PURE__ */ _startsWith(...args));
3224
+ },
3225
+ endsWith(...args) {
3226
+ return this.check(/* @__PURE__ */ _endsWith(...args));
3227
+ },
3228
+ min(...args) {
3229
+ return this.check(/* @__PURE__ */ _minLength(...args));
3230
+ },
3231
+ max(...args) {
3232
+ return this.check(/* @__PURE__ */ _maxLength(...args));
3233
+ },
3234
+ length(...args) {
3235
+ return this.check(/* @__PURE__ */ _length(...args));
3236
+ },
3237
+ nonempty(...args) {
3238
+ return this.check(/* @__PURE__ */ _minLength(1, ...args));
3239
+ },
3240
+ lowercase(params) {
3241
+ return this.check(/* @__PURE__ */ _lowercase(params));
3242
+ },
3243
+ uppercase(params) {
3244
+ return this.check(/* @__PURE__ */ _uppercase(params));
3245
+ },
3246
+ trim() {
3247
+ return this.check(/* @__PURE__ */ _trim());
3248
+ },
3249
+ normalize(...args) {
3250
+ return this.check(/* @__PURE__ */ _normalize(...args));
3251
+ },
3252
+ toLowerCase() {
3253
+ return this.check(/* @__PURE__ */ _toLowerCase());
3254
+ },
3255
+ toUpperCase() {
3256
+ return this.check(/* @__PURE__ */ _toUpperCase());
3257
+ },
3258
+ slugify() {
3259
+ return this.check(/* @__PURE__ */ _slugify());
3260
+ }
3261
+ });
2929
3262
  });
2930
3263
  const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
2931
3264
  $ZodString.init(inst, def);
@@ -2981,6 +3314,9 @@ const ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def) => {
2981
3314
  $ZodURL.init(inst, def);
2982
3315
  ZodStringFormat.init(inst, def);
2983
3316
  });
3317
+ function url(params) {
3318
+ return /* @__PURE__ */ _url(ZodURL, params);
3319
+ }
2984
3320
  const ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (inst, def) => {
2985
3321
  $ZodEmoji.init(inst, def);
2986
3322
  ZodStringFormat.init(inst, def);
@@ -2989,6 +3325,11 @@ const ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (inst, def) => {
2989
3325
  $ZodNanoID.init(inst, def);
2990
3326
  ZodStringFormat.init(inst, def);
2991
3327
  });
3328
+ /**
3329
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
3330
+ * (timestamps embedded in the id). Use {@link ZodCUID2} instead.
3331
+ * See https://github.com/paralleldrive/cuid.
3332
+ */
2992
3333
  const ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (inst, def) => {
2993
3334
  $ZodCUID.init(inst, def);
2994
3335
  ZodStringFormat.init(inst, def);
@@ -3062,11 +3403,23 @@ const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
3062
3403
  ZodType.init(inst, def);
3063
3404
  inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
3064
3405
  inst.element = def.element;
3065
- inst.min = (minLength, params) => inst.check(/* @__PURE__ */ _minLength(minLength, params));
3066
- inst.nonempty = (params) => inst.check(/* @__PURE__ */ _minLength(1, params));
3067
- inst.max = (maxLength, params) => inst.check(/* @__PURE__ */ _maxLength(maxLength, params));
3068
- inst.length = (len, params) => inst.check(/* @__PURE__ */ _length(len, params));
3069
- inst.unwrap = () => inst.element;
3406
+ _installLazyMethods(inst, "ZodArray", {
3407
+ min(n, params) {
3408
+ return this.check(/* @__PURE__ */ _minLength(n, params));
3409
+ },
3410
+ nonempty(params) {
3411
+ return this.check(/* @__PURE__ */ _minLength(1, params));
3412
+ },
3413
+ max(n, params) {
3414
+ return this.check(/* @__PURE__ */ _maxLength(n, params));
3415
+ },
3416
+ length(n, params) {
3417
+ return this.check(/* @__PURE__ */ _length(n, params));
3418
+ },
3419
+ unwrap() {
3420
+ return this.element;
3421
+ }
3422
+ });
3070
3423
  });
3071
3424
  function array(element, params) {
3072
3425
  return /* @__PURE__ */ _array(ZodArray, element, params);
@@ -3078,38 +3431,62 @@ const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
3078
3431
  defineLazy(inst, "shape", () => {
3079
3432
  return def.shape;
3080
3433
  });
3081
- inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
3082
- inst.catchall = (catchall) => inst.clone({
3083
- ...inst._zod.def,
3084
- catchall
3085
- });
3086
- inst.passthrough = () => inst.clone({
3087
- ...inst._zod.def,
3088
- catchall: unknown()
3089
- });
3090
- inst.loose = () => inst.clone({
3091
- ...inst._zod.def,
3092
- catchall: unknown()
3093
- });
3094
- inst.strict = () => inst.clone({
3095
- ...inst._zod.def,
3096
- catchall: never()
3097
- });
3098
- inst.strip = () => inst.clone({
3099
- ...inst._zod.def,
3100
- catchall: void 0
3434
+ _installLazyMethods(inst, "ZodObject", {
3435
+ keyof() {
3436
+ return _enum(Object.keys(this._zod.def.shape));
3437
+ },
3438
+ catchall(catchall) {
3439
+ return this.clone({
3440
+ ...this._zod.def,
3441
+ catchall
3442
+ });
3443
+ },
3444
+ passthrough() {
3445
+ return this.clone({
3446
+ ...this._zod.def,
3447
+ catchall: unknown()
3448
+ });
3449
+ },
3450
+ loose() {
3451
+ return this.clone({
3452
+ ...this._zod.def,
3453
+ catchall: unknown()
3454
+ });
3455
+ },
3456
+ strict() {
3457
+ return this.clone({
3458
+ ...this._zod.def,
3459
+ catchall: never()
3460
+ });
3461
+ },
3462
+ strip() {
3463
+ return this.clone({
3464
+ ...this._zod.def,
3465
+ catchall: void 0
3466
+ });
3467
+ },
3468
+ extend(incoming) {
3469
+ return extend(this, incoming);
3470
+ },
3471
+ safeExtend(incoming) {
3472
+ return safeExtend(this, incoming);
3473
+ },
3474
+ merge(other) {
3475
+ return merge(this, other);
3476
+ },
3477
+ pick(mask) {
3478
+ return pick(this, mask);
3479
+ },
3480
+ omit(mask) {
3481
+ return omit(this, mask);
3482
+ },
3483
+ partial(...args) {
3484
+ return partial(ZodOptional, this, args[0]);
3485
+ },
3486
+ required(...args) {
3487
+ return required(ZodNonOptional, this, args[0]);
3488
+ }
3101
3489
  });
3102
- inst.extend = (incoming) => {
3103
- return extend(inst, incoming);
3104
- };
3105
- inst.safeExtend = (incoming) => {
3106
- return safeExtend(inst, incoming);
3107
- };
3108
- inst.merge = (other) => merge(inst, other);
3109
- inst.pick = (mask) => pick(inst, mask);
3110
- inst.omit = (mask) => omit(inst, mask);
3111
- inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
3112
- inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
3113
3490
  });
3114
3491
  function object(shape, params) {
3115
3492
  const def = {
@@ -3132,6 +3509,18 @@ function union(options, params) {
3132
3509
  ...normalizeParams(params)
3133
3510
  });
3134
3511
  }
3512
+ const ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("ZodDiscriminatedUnion", (inst, def) => {
3513
+ ZodUnion.init(inst, def);
3514
+ $ZodDiscriminatedUnion.init(inst, def);
3515
+ });
3516
+ function discriminatedUnion(discriminator, options, params) {
3517
+ return new ZodDiscriminatedUnion({
3518
+ type: "union",
3519
+ options,
3520
+ discriminator,
3521
+ ...normalizeParams(params)
3522
+ });
3523
+ }
3135
3524
  const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
3136
3525
  $ZodIntersection.init(inst, def);
3137
3526
  ZodType.init(inst, def);
@@ -3182,6 +3571,23 @@ function _enum(values, params) {
3182
3571
  ...normalizeParams(params)
3183
3572
  });
3184
3573
  }
3574
+ const ZodLiteral = /*@__PURE__*/ $constructor("ZodLiteral", (inst, def) => {
3575
+ $ZodLiteral.init(inst, def);
3576
+ ZodType.init(inst, def);
3577
+ inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
3578
+ inst.values = new Set(def.values);
3579
+ Object.defineProperty(inst, "value", { get() {
3580
+ if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
3581
+ return def.values[0];
3582
+ } });
3583
+ });
3584
+ function literal(value, params) {
3585
+ return new ZodLiteral({
3586
+ type: "literal",
3587
+ values: Array.isArray(value) ? value : [value],
3588
+ ...normalizeParams(params)
3589
+ });
3590
+ }
3185
3591
  const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
3186
3592
  $ZodTransform.init(inst, def);
3187
3593
  ZodType.init(inst, def);
@@ -3202,9 +3608,11 @@ const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
3202
3608
  const output = def.transform(payload.value, payload);
3203
3609
  if (output instanceof Promise) return output.then((output) => {
3204
3610
  payload.value = output;
3611
+ payload.fallback = true;
3205
3612
  return payload;
3206
3613
  });
3207
3614
  payload.value = output;
3615
+ payload.fallback = true;
3208
3616
  return payload;
3209
3617
  };
3210
3618
  });
@@ -3342,8 +3750,8 @@ const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
3342
3750
  function refine(fn, _params = {}) {
3343
3751
  return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
3344
3752
  }
3345
- function superRefine(fn) {
3346
- return /* @__PURE__ */ _superRefine(fn);
3753
+ function superRefine(fn, params) {
3754
+ return /* @__PURE__ */ _superRefine(fn, params);
3347
3755
  }
3348
3756
  //#endregion
3349
3757
  //#region src/errors.ts
@@ -3355,7 +3763,7 @@ function superRefine(fn) {
3355
3763
  * `"GenericFailure"` and carries no information. The addon instead serializes a
3356
3764
  * structured envelope into the JS `err.message`:
3357
3765
  *
3358
- * { code, message, context?, retryable }
3766
+ * { code, message, context?, retryable, internal, httpStatusCode?, hint? }
3359
3767
  *
3360
3768
  * where `context` keys are snake_case (e.g. `binding_name`, `env_var`).
3361
3769
  * `unwrapNapiError` recovers that envelope with a single `JSON.parse` — never by
@@ -3443,7 +3851,7 @@ function parseEnvelope(rawMessage) {
3443
3851
  * becomes {@link BindingNotConfiguredError} (with `binding` / `envVar` mapped
3444
3852
  * from the envelope's snake_case context); every other envelope code becomes a
3445
3853
  * generic `AlienError` that preserves the `code`, `message`, `context`, and
3446
- * `retryable` flag.
3854
+ * `retryable`, `internal`, `httpStatusCode`, and `hint` metadata.
3447
3855
  * - A non-envelope message (napi-internal error) is wrapped as a generic
3448
3856
  * `BINDINGS_ERROR`, preserving the original message.
3449
3857
  */
@@ -3466,7 +3874,9 @@ function unwrapNapiError(err) {
3466
3874
  code: envelope.code,
3467
3875
  message: envelope.message ?? rawMessage,
3468
3876
  retryable: envelope.retryable ?? false,
3469
- internal: false,
3877
+ internal: envelope.internal ?? false,
3878
+ httpStatusCode: envelope.httpStatusCode,
3879
+ hint: envelope.hint,
3470
3880
  context
3471
3881
  });
3472
3882
  }
@@ -3528,6 +3938,12 @@ function makeStorage(handle) {
3528
3938
  signedUrl: (options) => guard(handle, (raw) => raw.signedUrl(options.method, options.path, options.expiresIn))
3529
3939
  };
3530
3940
  }
3941
+ function makeKey(handle) {
3942
+ return {
3943
+ encrypt: (plaintext, options) => guard(handle, (raw) => raw.encrypt(toBuffer(plaintext), options?.context ?? null)),
3944
+ decrypt: (ciphertext, options) => guard(handle, (raw) => raw.decrypt(toBuffer(ciphertext), options?.context ?? null))
3945
+ };
3946
+ }
3531
3947
  function makeRemoteStorage(handle) {
3532
3948
  return {
3533
3949
  get: (path) => guard(handle, (raw) => raw.get(path)),
@@ -3682,6 +4098,7 @@ function createFactories(getAddon) {
3682
4098
  const getBindings = bindingsFromAddon(getAddon);
3683
4099
  return {
3684
4100
  storage: (name) => makeStorage(lazyHandle(async () => (await getBindings()).storage(name))),
4101
+ key: (name) => makeKey(lazyHandle(async () => (await getBindings()).key(name))),
3685
4102
  kv: (name) => makeKv(lazyHandle(async () => (await getBindings()).kv(name))),
3686
4103
  queue: (name) => makeQueue(lazyHandle(async () => (await getBindings()).queue(name))),
3687
4104
  vault: (name) => makeVault(lazyHandle(async () => (await getBindings()).vault(name))),
@@ -3701,6 +4118,18 @@ function createRemoteStorageFactory(bindings) {
3701
4118
  return storage;
3702
4119
  };
3703
4120
  }
4121
+ /** Build the remote Key factory around one native bindings handle. */
4122
+ function createRemoteKeyFactory(bindings) {
4123
+ const keys = /* @__PURE__ */ new Map();
4124
+ return (name) => {
4125
+ let key = keys.get(name);
4126
+ if (!key) {
4127
+ key = makeKey(lazyHandle(() => bindings.key(name)));
4128
+ keys.set(name, key);
4129
+ }
4130
+ return key;
4131
+ };
4132
+ }
3704
4133
  //#endregion
3705
4134
  //#region src/loader.ts
3706
4135
  /**
@@ -3867,4 +4296,4 @@ function loadAddon() {
3867
4296
  throw new Error(`Cannot load the @alienplatform/bindings native addon for '${triple}'. Install the '${pkg}' prebuild, or build it locally with \`napi build --platform\` in crates/alien-bindings-node, or set ALIEN_BINDINGS_ADDON_PATH to a built .node file.`);
3868
4297
  }
3869
4298
  //#endregion
3870
- export { AlienError as a, InvalidPostgresTlsConfigError as c, unwrapNapiError as d, createRemoteStorageFactory as i, UnknownPostgresSslModeError as l, registerEmbeddedAddon as n, BindingNotConfiguredError as o, createFactories as r, BindingNotFoundError as s, loadAddon as t, defineError as u };
4299
+ export { url as _, createRemoteStorageFactory as a, BindingNotFoundError as c, defineError as d, unwrapNapiError as f, string as g, object as h, createRemoteKeyFactory as i, InvalidPostgresTlsConfigError as l, literal as m, registerEmbeddedAddon as n, AlienError as o, discriminatedUnion as p, createFactories as r, BindingNotConfiguredError as s, loadAddon as t, UnknownPostgresSslModeError as u, datetime as v };