better-call 1.1.0 → 1.1.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.
- package/dist/{client.d.ts → client-85UqI56y.d.cts} +2 -2
- package/dist/{client.d.cts → client-r9q--Cwq.d.ts} +2 -2
- package/dist/client.cjs +1 -2
- package/dist/client.cjs.map +1 -1
- package/dist/index-2ZsOphT7.d.cts +14 -0
- package/dist/index-BI30kuja.d.ts +14 -0
- package/dist/index.cjs +32 -1701
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -1693
- package/dist/index.js.map +1 -1
- package/dist/{node.d.cts → node-B5huLF_B.d.ts} +2 -2
- package/dist/{node.d.ts → node-DxNP7smX.d.cts} +2 -2
- package/dist/node.cjs +29 -2
- package/dist/node.cjs.map +1 -1
- package/dist/{router-DgnLO11b.d.ts → router-Ci1V_nyg.d.ts} +2 -2
- package/dist/{router-DxkLDx_d.d.cts → router-_duuM9nW.d.cts} +2 -2
- package/package.json +10 -3
- package/dist/chunk-CUT6urMc.cjs +0 -30
- package/dist/index.d.cts +0 -14
- package/dist/index.d.ts +0 -14
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getWebcryptoSubtle } from "@better-auth/utils";
|
|
2
2
|
import { addRoute, createRouter as createRouter$1, findAllRoutes, findRoute } from "rou3";
|
|
3
|
+
import { ZodObject, ZodOptional } from "zod";
|
|
3
4
|
|
|
4
5
|
//#region src/error.ts
|
|
5
6
|
function isErrorStackTraceLimitWritable() {
|
|
@@ -311,8 +312,8 @@ async function runValidation(options, context = {}) {
|
|
|
311
312
|
}
|
|
312
313
|
function fromError(error, validating) {
|
|
313
314
|
const errorMessages = [];
|
|
314
|
-
for (const issue
|
|
315
|
-
const message = issue
|
|
315
|
+
for (const issue of error) {
|
|
316
|
+
const message = issue.message;
|
|
316
317
|
errorMessages.push(message);
|
|
317
318
|
}
|
|
318
319
|
return { message: `Invalid ${validating} parameters` };
|
|
@@ -612,1674 +613,6 @@ createMiddleware.create = (opts) => {
|
|
|
612
613
|
return fn;
|
|
613
614
|
};
|
|
614
615
|
|
|
615
|
-
//#endregion
|
|
616
|
-
//#region node_modules/.pnpm/zod@4.0.1/node_modules/zod/v4/core/core.js
|
|
617
|
-
/** A special constant with type `never` */
|
|
618
|
-
const NEVER = Object.freeze({ status: "aborted" });
|
|
619
|
-
function $constructor(name, initializer$2, params) {
|
|
620
|
-
function init(inst, def) {
|
|
621
|
-
var _a;
|
|
622
|
-
Object.defineProperty(inst, "_zod", {
|
|
623
|
-
value: inst._zod ?? {},
|
|
624
|
-
enumerable: false
|
|
625
|
-
});
|
|
626
|
-
(_a = inst._zod).traits ?? (_a.traits = /* @__PURE__ */ new Set());
|
|
627
|
-
inst._zod.traits.add(name);
|
|
628
|
-
initializer$2(inst, def);
|
|
629
|
-
for (const k in _.prototype) if (!(k in inst)) Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
|
|
630
|
-
inst._zod.constr = _;
|
|
631
|
-
inst._zod.def = def;
|
|
632
|
-
}
|
|
633
|
-
const Parent = params?.Parent ?? Object;
|
|
634
|
-
class Definition extends Parent {}
|
|
635
|
-
Object.defineProperty(Definition, "name", { value: name });
|
|
636
|
-
function _(def) {
|
|
637
|
-
var _a;
|
|
638
|
-
const inst = params?.Parent ? new Definition() : this;
|
|
639
|
-
init(inst, def);
|
|
640
|
-
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
641
|
-
for (const fn of inst._zod.deferred) fn();
|
|
642
|
-
return inst;
|
|
643
|
-
}
|
|
644
|
-
Object.defineProperty(_, "init", { value: init });
|
|
645
|
-
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
|
|
646
|
-
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
647
|
-
return inst?._zod?.traits?.has(name);
|
|
648
|
-
} });
|
|
649
|
-
Object.defineProperty(_, "name", { value: name });
|
|
650
|
-
return _;
|
|
651
|
-
}
|
|
652
|
-
const $brand = Symbol("zod_brand");
|
|
653
|
-
var $ZodAsyncError = class extends Error {
|
|
654
|
-
constructor() {
|
|
655
|
-
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
656
|
-
}
|
|
657
|
-
};
|
|
658
|
-
const globalConfig = {};
|
|
659
|
-
function config(newConfig) {
|
|
660
|
-
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
661
|
-
return globalConfig;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
//#endregion
|
|
665
|
-
//#region node_modules/.pnpm/zod@4.0.1/node_modules/zod/v4/core/util.js
|
|
666
|
-
function getEnumValues(entries) {
|
|
667
|
-
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
668
|
-
return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
669
|
-
}
|
|
670
|
-
function jsonStringifyReplacer(_, value) {
|
|
671
|
-
if (typeof value === "bigint") return value.toString();
|
|
672
|
-
return value;
|
|
673
|
-
}
|
|
674
|
-
function cached(getter) {
|
|
675
|
-
return { get value() {
|
|
676
|
-
{
|
|
677
|
-
const value = getter();
|
|
678
|
-
Object.defineProperty(this, "value", { value });
|
|
679
|
-
return value;
|
|
680
|
-
}
|
|
681
|
-
throw new Error("cached value already set");
|
|
682
|
-
} };
|
|
683
|
-
}
|
|
684
|
-
function nullish(input) {
|
|
685
|
-
return input === null || input === void 0;
|
|
686
|
-
}
|
|
687
|
-
function cleanRegex(source) {
|
|
688
|
-
const start = source.startsWith("^") ? 1 : 0;
|
|
689
|
-
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
690
|
-
return source.slice(start, end);
|
|
691
|
-
}
|
|
692
|
-
function defineLazy(object, key, getter) {
|
|
693
|
-
Object.defineProperty(object, key, {
|
|
694
|
-
get() {
|
|
695
|
-
{
|
|
696
|
-
const value = getter();
|
|
697
|
-
object[key] = value;
|
|
698
|
-
return value;
|
|
699
|
-
}
|
|
700
|
-
throw new Error("cached value already set");
|
|
701
|
-
},
|
|
702
|
-
set(v) {
|
|
703
|
-
Object.defineProperty(object, key, { value: v });
|
|
704
|
-
},
|
|
705
|
-
configurable: true
|
|
706
|
-
});
|
|
707
|
-
}
|
|
708
|
-
function assignProp(target, prop, value) {
|
|
709
|
-
Object.defineProperty(target, prop, {
|
|
710
|
-
value,
|
|
711
|
-
writable: true,
|
|
712
|
-
enumerable: true,
|
|
713
|
-
configurable: true
|
|
714
|
-
});
|
|
715
|
-
}
|
|
716
|
-
function esc(str) {
|
|
717
|
-
return JSON.stringify(str);
|
|
718
|
-
}
|
|
719
|
-
const captureStackTrace = Error.captureStackTrace ? Error.captureStackTrace : (..._args) => {};
|
|
720
|
-
function isObject(data) {
|
|
721
|
-
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
722
|
-
}
|
|
723
|
-
const allowsEval = cached(() => {
|
|
724
|
-
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
|
|
725
|
-
try {
|
|
726
|
-
new Function("");
|
|
727
|
-
return true;
|
|
728
|
-
} catch (_) {
|
|
729
|
-
return false;
|
|
730
|
-
}
|
|
731
|
-
});
|
|
732
|
-
function isPlainObject(o) {
|
|
733
|
-
if (isObject(o) === false) return false;
|
|
734
|
-
const ctor = o.constructor;
|
|
735
|
-
if (ctor === void 0) return true;
|
|
736
|
-
const prot = ctor.prototype;
|
|
737
|
-
if (isObject(prot) === false) return false;
|
|
738
|
-
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
|
|
739
|
-
return true;
|
|
740
|
-
}
|
|
741
|
-
const propertyKeyTypes = new Set([
|
|
742
|
-
"string",
|
|
743
|
-
"number",
|
|
744
|
-
"symbol"
|
|
745
|
-
]);
|
|
746
|
-
function escapeRegex(str) {
|
|
747
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
748
|
-
}
|
|
749
|
-
function clone(inst, def, params) {
|
|
750
|
-
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
751
|
-
if (!def || params?.parent) cl._zod.parent = inst;
|
|
752
|
-
return cl;
|
|
753
|
-
}
|
|
754
|
-
function normalizeParams(_params) {
|
|
755
|
-
const params = _params;
|
|
756
|
-
if (!params) return {};
|
|
757
|
-
if (typeof params === "string") return { error: () => params };
|
|
758
|
-
if (params?.message !== void 0) {
|
|
759
|
-
if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
|
|
760
|
-
params.error = params.message;
|
|
761
|
-
}
|
|
762
|
-
delete params.message;
|
|
763
|
-
if (typeof params.error === "string") return {
|
|
764
|
-
...params,
|
|
765
|
-
error: () => params.error
|
|
766
|
-
};
|
|
767
|
-
return params;
|
|
768
|
-
}
|
|
769
|
-
function optionalKeys(shape) {
|
|
770
|
-
return Object.keys(shape).filter((k) => {
|
|
771
|
-
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
|
-
const NUMBER_FORMAT_RANGES = {
|
|
775
|
-
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
776
|
-
int32: [-2147483648, 2147483647],
|
|
777
|
-
uint32: [0, 4294967295],
|
|
778
|
-
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
779
|
-
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
780
|
-
};
|
|
781
|
-
function pick(schema, mask) {
|
|
782
|
-
const newShape = {};
|
|
783
|
-
const currDef = schema._zod.def;
|
|
784
|
-
for (const key in mask) {
|
|
785
|
-
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
786
|
-
if (!mask[key]) continue;
|
|
787
|
-
newShape[key] = currDef.shape[key];
|
|
788
|
-
}
|
|
789
|
-
return clone(schema, {
|
|
790
|
-
...schema._zod.def,
|
|
791
|
-
shape: newShape,
|
|
792
|
-
checks: []
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
|
-
function omit(schema, mask) {
|
|
796
|
-
const newShape = { ...schema._zod.def.shape };
|
|
797
|
-
const currDef = schema._zod.def;
|
|
798
|
-
for (const key in mask) {
|
|
799
|
-
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
800
|
-
if (!mask[key]) continue;
|
|
801
|
-
delete newShape[key];
|
|
802
|
-
}
|
|
803
|
-
return clone(schema, {
|
|
804
|
-
...schema._zod.def,
|
|
805
|
-
shape: newShape,
|
|
806
|
-
checks: []
|
|
807
|
-
});
|
|
808
|
-
}
|
|
809
|
-
function extend(schema, shape) {
|
|
810
|
-
if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
|
|
811
|
-
return clone(schema, {
|
|
812
|
-
...schema._zod.def,
|
|
813
|
-
get shape() {
|
|
814
|
-
const _shape = {
|
|
815
|
-
...schema._zod.def.shape,
|
|
816
|
-
...shape
|
|
817
|
-
};
|
|
818
|
-
assignProp(this, "shape", _shape);
|
|
819
|
-
return _shape;
|
|
820
|
-
},
|
|
821
|
-
checks: []
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
function merge(a, b) {
|
|
825
|
-
return clone(a, {
|
|
826
|
-
...a._zod.def,
|
|
827
|
-
get shape() {
|
|
828
|
-
const _shape = {
|
|
829
|
-
...a._zod.def.shape,
|
|
830
|
-
...b._zod.def.shape
|
|
831
|
-
};
|
|
832
|
-
assignProp(this, "shape", _shape);
|
|
833
|
-
return _shape;
|
|
834
|
-
},
|
|
835
|
-
catchall: b._zod.def.catchall,
|
|
836
|
-
checks: []
|
|
837
|
-
});
|
|
838
|
-
}
|
|
839
|
-
function partial(Class, schema, mask) {
|
|
840
|
-
const oldShape = schema._zod.def.shape;
|
|
841
|
-
const shape = { ...oldShape };
|
|
842
|
-
if (mask) for (const key in mask) {
|
|
843
|
-
if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
844
|
-
if (!mask[key]) continue;
|
|
845
|
-
shape[key] = Class ? new Class({
|
|
846
|
-
type: "optional",
|
|
847
|
-
innerType: oldShape[key]
|
|
848
|
-
}) : oldShape[key];
|
|
849
|
-
}
|
|
850
|
-
else for (const key in oldShape) shape[key] = Class ? new Class({
|
|
851
|
-
type: "optional",
|
|
852
|
-
innerType: oldShape[key]
|
|
853
|
-
}) : oldShape[key];
|
|
854
|
-
return clone(schema, {
|
|
855
|
-
...schema._zod.def,
|
|
856
|
-
shape,
|
|
857
|
-
checks: []
|
|
858
|
-
});
|
|
859
|
-
}
|
|
860
|
-
function required(Class, schema, mask) {
|
|
861
|
-
const oldShape = schema._zod.def.shape;
|
|
862
|
-
const shape = { ...oldShape };
|
|
863
|
-
if (mask) for (const key in mask) {
|
|
864
|
-
if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
865
|
-
if (!mask[key]) continue;
|
|
866
|
-
shape[key] = new Class({
|
|
867
|
-
type: "nonoptional",
|
|
868
|
-
innerType: oldShape[key]
|
|
869
|
-
});
|
|
870
|
-
}
|
|
871
|
-
else for (const key in oldShape) shape[key] = new Class({
|
|
872
|
-
type: "nonoptional",
|
|
873
|
-
innerType: oldShape[key]
|
|
874
|
-
});
|
|
875
|
-
return clone(schema, {
|
|
876
|
-
...schema._zod.def,
|
|
877
|
-
shape,
|
|
878
|
-
checks: []
|
|
879
|
-
});
|
|
880
|
-
}
|
|
881
|
-
function aborted(x, startIndex = 0) {
|
|
882
|
-
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
|
|
883
|
-
return false;
|
|
884
|
-
}
|
|
885
|
-
function prefixIssues(path, issues) {
|
|
886
|
-
return issues.map((iss) => {
|
|
887
|
-
var _a;
|
|
888
|
-
(_a = iss).path ?? (_a.path = []);
|
|
889
|
-
iss.path.unshift(path);
|
|
890
|
-
return iss;
|
|
891
|
-
});
|
|
892
|
-
}
|
|
893
|
-
function unwrapMessage(message) {
|
|
894
|
-
return typeof message === "string" ? message : message?.message;
|
|
895
|
-
}
|
|
896
|
-
function finalizeIssue(iss, ctx, config$1) {
|
|
897
|
-
const full = {
|
|
898
|
-
...iss,
|
|
899
|
-
path: iss.path ?? []
|
|
900
|
-
};
|
|
901
|
-
if (!iss.message) full.message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config$1.customError?.(iss)) ?? unwrapMessage(config$1.localeError?.(iss)) ?? "Invalid input";
|
|
902
|
-
delete full.inst;
|
|
903
|
-
delete full.continue;
|
|
904
|
-
if (!ctx?.reportInput) delete full.input;
|
|
905
|
-
return full;
|
|
906
|
-
}
|
|
907
|
-
function getLengthableOrigin(input) {
|
|
908
|
-
if (Array.isArray(input)) return "array";
|
|
909
|
-
if (typeof input === "string") return "string";
|
|
910
|
-
return "unknown";
|
|
911
|
-
}
|
|
912
|
-
function issue(...args) {
|
|
913
|
-
const [iss, input, inst] = args;
|
|
914
|
-
if (typeof iss === "string") return {
|
|
915
|
-
message: iss,
|
|
916
|
-
code: "custom",
|
|
917
|
-
input,
|
|
918
|
-
inst
|
|
919
|
-
};
|
|
920
|
-
return { ...iss };
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
//#endregion
|
|
924
|
-
//#region node_modules/.pnpm/zod@4.0.1/node_modules/zod/v4/core/errors.js
|
|
925
|
-
const initializer$1 = (inst, def) => {
|
|
926
|
-
inst.name = "$ZodError";
|
|
927
|
-
Object.defineProperty(inst, "_zod", {
|
|
928
|
-
value: inst._zod,
|
|
929
|
-
enumerable: false
|
|
930
|
-
});
|
|
931
|
-
Object.defineProperty(inst, "issues", {
|
|
932
|
-
value: def,
|
|
933
|
-
enumerable: false
|
|
934
|
-
});
|
|
935
|
-
Object.defineProperty(inst, "message", {
|
|
936
|
-
get() {
|
|
937
|
-
return JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
938
|
-
},
|
|
939
|
-
enumerable: true
|
|
940
|
-
});
|
|
941
|
-
Object.defineProperty(inst, "toString", {
|
|
942
|
-
value: () => inst.message,
|
|
943
|
-
enumerable: false
|
|
944
|
-
});
|
|
945
|
-
};
|
|
946
|
-
const $ZodError = $constructor("$ZodError", initializer$1);
|
|
947
|
-
const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
|
|
948
|
-
function flattenError(error, mapper = (issue$1) => issue$1.message) {
|
|
949
|
-
const fieldErrors = {};
|
|
950
|
-
const formErrors = [];
|
|
951
|
-
for (const sub of error.issues) if (sub.path.length > 0) {
|
|
952
|
-
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
953
|
-
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
954
|
-
} else formErrors.push(mapper(sub));
|
|
955
|
-
return {
|
|
956
|
-
formErrors,
|
|
957
|
-
fieldErrors
|
|
958
|
-
};
|
|
959
|
-
}
|
|
960
|
-
function formatError(error, _mapper) {
|
|
961
|
-
const mapper = _mapper || function(issue$1) {
|
|
962
|
-
return issue$1.message;
|
|
963
|
-
};
|
|
964
|
-
const fieldErrors = { _errors: [] };
|
|
965
|
-
const processError = (error$1) => {
|
|
966
|
-
for (const issue$1 of error$1.issues) if (issue$1.code === "invalid_union" && issue$1.errors.length) issue$1.errors.map((issues) => processError({ issues }));
|
|
967
|
-
else if (issue$1.code === "invalid_key") processError({ issues: issue$1.issues });
|
|
968
|
-
else if (issue$1.code === "invalid_element") processError({ issues: issue$1.issues });
|
|
969
|
-
else if (issue$1.path.length === 0) fieldErrors._errors.push(mapper(issue$1));
|
|
970
|
-
else {
|
|
971
|
-
let curr = fieldErrors;
|
|
972
|
-
let i = 0;
|
|
973
|
-
while (i < issue$1.path.length) {
|
|
974
|
-
const el = issue$1.path[i];
|
|
975
|
-
if (!(i === issue$1.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
|
|
976
|
-
else {
|
|
977
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
978
|
-
curr[el]._errors.push(mapper(issue$1));
|
|
979
|
-
}
|
|
980
|
-
curr = curr[el];
|
|
981
|
-
i++;
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
};
|
|
985
|
-
processError(error);
|
|
986
|
-
return fieldErrors;
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
//#endregion
|
|
990
|
-
//#region node_modules/.pnpm/zod@4.0.1/node_modules/zod/v4/core/parse.js
|
|
991
|
-
const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
992
|
-
const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
|
|
993
|
-
const result = schema._zod.run({
|
|
994
|
-
value,
|
|
995
|
-
issues: []
|
|
996
|
-
}, ctx);
|
|
997
|
-
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
998
|
-
if (result.issues.length) {
|
|
999
|
-
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
1000
|
-
captureStackTrace(e, _params?.callee);
|
|
1001
|
-
throw e;
|
|
1002
|
-
}
|
|
1003
|
-
return result.value;
|
|
1004
|
-
};
|
|
1005
|
-
const parse$1 = /* @__PURE__ */ _parse($ZodRealError);
|
|
1006
|
-
const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
1007
|
-
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
1008
|
-
let result = schema._zod.run({
|
|
1009
|
-
value,
|
|
1010
|
-
issues: []
|
|
1011
|
-
}, ctx);
|
|
1012
|
-
if (result instanceof Promise) result = await result;
|
|
1013
|
-
if (result.issues.length) {
|
|
1014
|
-
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
1015
|
-
captureStackTrace(e, params?.callee);
|
|
1016
|
-
throw e;
|
|
1017
|
-
}
|
|
1018
|
-
return result.value;
|
|
1019
|
-
};
|
|
1020
|
-
const parseAsync$1 = /* @__PURE__ */ _parseAsync($ZodRealError);
|
|
1021
|
-
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
1022
|
-
const ctx = _ctx ? {
|
|
1023
|
-
..._ctx,
|
|
1024
|
-
async: false
|
|
1025
|
-
} : { async: false };
|
|
1026
|
-
const result = schema._zod.run({
|
|
1027
|
-
value,
|
|
1028
|
-
issues: []
|
|
1029
|
-
}, ctx);
|
|
1030
|
-
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
1031
|
-
return result.issues.length ? {
|
|
1032
|
-
success: false,
|
|
1033
|
-
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
1034
|
-
} : {
|
|
1035
|
-
success: true,
|
|
1036
|
-
data: result.value
|
|
1037
|
-
};
|
|
1038
|
-
};
|
|
1039
|
-
const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
1040
|
-
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
1041
|
-
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
1042
|
-
let result = schema._zod.run({
|
|
1043
|
-
value,
|
|
1044
|
-
issues: []
|
|
1045
|
-
}, ctx);
|
|
1046
|
-
if (result instanceof Promise) result = await result;
|
|
1047
|
-
return result.issues.length ? {
|
|
1048
|
-
success: false,
|
|
1049
|
-
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
1050
|
-
} : {
|
|
1051
|
-
success: true,
|
|
1052
|
-
data: result.value
|
|
1053
|
-
};
|
|
1054
|
-
};
|
|
1055
|
-
const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
1056
|
-
|
|
1057
|
-
//#endregion
|
|
1058
|
-
//#region node_modules/.pnpm/zod@4.0.1/node_modules/zod/v4/core/checks.js
|
|
1059
|
-
const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
1060
|
-
var _a;
|
|
1061
|
-
inst._zod ?? (inst._zod = {});
|
|
1062
|
-
inst._zod.def = def;
|
|
1063
|
-
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
1064
|
-
});
|
|
1065
|
-
const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
1066
|
-
var _a;
|
|
1067
|
-
$ZodCheck.init(inst, def);
|
|
1068
|
-
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
1069
|
-
const val = payload.value;
|
|
1070
|
-
return !nullish(val) && val.length !== void 0;
|
|
1071
|
-
});
|
|
1072
|
-
inst._zod.onattach.push((inst$1) => {
|
|
1073
|
-
const curr = inst$1._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
1074
|
-
if (def.maximum < curr) inst$1._zod.bag.maximum = def.maximum;
|
|
1075
|
-
});
|
|
1076
|
-
inst._zod.check = (payload) => {
|
|
1077
|
-
const input = payload.value;
|
|
1078
|
-
if (input.length <= def.maximum) return;
|
|
1079
|
-
const origin = getLengthableOrigin(input);
|
|
1080
|
-
payload.issues.push({
|
|
1081
|
-
origin,
|
|
1082
|
-
code: "too_big",
|
|
1083
|
-
maximum: def.maximum,
|
|
1084
|
-
inclusive: true,
|
|
1085
|
-
input,
|
|
1086
|
-
inst,
|
|
1087
|
-
continue: !def.abort
|
|
1088
|
-
});
|
|
1089
|
-
};
|
|
1090
|
-
});
|
|
1091
|
-
const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
1092
|
-
var _a;
|
|
1093
|
-
$ZodCheck.init(inst, def);
|
|
1094
|
-
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
1095
|
-
const val = payload.value;
|
|
1096
|
-
return !nullish(val) && val.length !== void 0;
|
|
1097
|
-
});
|
|
1098
|
-
inst._zod.onattach.push((inst$1) => {
|
|
1099
|
-
const curr = inst$1._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
1100
|
-
if (def.minimum > curr) inst$1._zod.bag.minimum = def.minimum;
|
|
1101
|
-
});
|
|
1102
|
-
inst._zod.check = (payload) => {
|
|
1103
|
-
const input = payload.value;
|
|
1104
|
-
if (input.length >= def.minimum) return;
|
|
1105
|
-
const origin = getLengthableOrigin(input);
|
|
1106
|
-
payload.issues.push({
|
|
1107
|
-
origin,
|
|
1108
|
-
code: "too_small",
|
|
1109
|
-
minimum: def.minimum,
|
|
1110
|
-
inclusive: true,
|
|
1111
|
-
input,
|
|
1112
|
-
inst,
|
|
1113
|
-
continue: !def.abort
|
|
1114
|
-
});
|
|
1115
|
-
};
|
|
1116
|
-
});
|
|
1117
|
-
const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
1118
|
-
var _a;
|
|
1119
|
-
$ZodCheck.init(inst, def);
|
|
1120
|
-
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
1121
|
-
const val = payload.value;
|
|
1122
|
-
return !nullish(val) && val.length !== void 0;
|
|
1123
|
-
});
|
|
1124
|
-
inst._zod.onattach.push((inst$1) => {
|
|
1125
|
-
const bag = inst$1._zod.bag;
|
|
1126
|
-
bag.minimum = def.length;
|
|
1127
|
-
bag.maximum = def.length;
|
|
1128
|
-
bag.length = def.length;
|
|
1129
|
-
});
|
|
1130
|
-
inst._zod.check = (payload) => {
|
|
1131
|
-
const input = payload.value;
|
|
1132
|
-
const length = input.length;
|
|
1133
|
-
if (length === def.length) return;
|
|
1134
|
-
const origin = getLengthableOrigin(input);
|
|
1135
|
-
const tooBig = length > def.length;
|
|
1136
|
-
payload.issues.push({
|
|
1137
|
-
origin,
|
|
1138
|
-
...tooBig ? {
|
|
1139
|
-
code: "too_big",
|
|
1140
|
-
maximum: def.length
|
|
1141
|
-
} : {
|
|
1142
|
-
code: "too_small",
|
|
1143
|
-
minimum: def.length
|
|
1144
|
-
},
|
|
1145
|
-
inclusive: true,
|
|
1146
|
-
exact: true,
|
|
1147
|
-
input: payload.value,
|
|
1148
|
-
inst,
|
|
1149
|
-
continue: !def.abort
|
|
1150
|
-
});
|
|
1151
|
-
};
|
|
1152
|
-
});
|
|
1153
|
-
const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
1154
|
-
$ZodCheck.init(inst, def);
|
|
1155
|
-
inst._zod.check = (payload) => {
|
|
1156
|
-
payload.value = def.tx(payload.value);
|
|
1157
|
-
};
|
|
1158
|
-
});
|
|
1159
|
-
|
|
1160
|
-
//#endregion
|
|
1161
|
-
//#region node_modules/.pnpm/zod@4.0.1/node_modules/zod/v4/core/doc.js
|
|
1162
|
-
var Doc = class {
|
|
1163
|
-
constructor(args = []) {
|
|
1164
|
-
this.content = [];
|
|
1165
|
-
this.indent = 0;
|
|
1166
|
-
if (this) this.args = args;
|
|
1167
|
-
}
|
|
1168
|
-
indented(fn) {
|
|
1169
|
-
this.indent += 1;
|
|
1170
|
-
fn(this);
|
|
1171
|
-
this.indent -= 1;
|
|
1172
|
-
}
|
|
1173
|
-
write(arg) {
|
|
1174
|
-
if (typeof arg === "function") {
|
|
1175
|
-
arg(this, { execution: "sync" });
|
|
1176
|
-
arg(this, { execution: "async" });
|
|
1177
|
-
return;
|
|
1178
|
-
}
|
|
1179
|
-
const lines = arg.split("\n").filter((x) => x);
|
|
1180
|
-
const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
|
|
1181
|
-
const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
|
|
1182
|
-
for (const line of dedented) this.content.push(line);
|
|
1183
|
-
}
|
|
1184
|
-
compile() {
|
|
1185
|
-
const F = Function;
|
|
1186
|
-
const args = this?.args;
|
|
1187
|
-
const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
|
|
1188
|
-
return new F(...args, lines.join("\n"));
|
|
1189
|
-
}
|
|
1190
|
-
};
|
|
1191
|
-
|
|
1192
|
-
//#endregion
|
|
1193
|
-
//#region node_modules/.pnpm/zod@4.0.1/node_modules/zod/v4/core/versions.js
|
|
1194
|
-
const version = {
|
|
1195
|
-
major: 4,
|
|
1196
|
-
minor: 0,
|
|
1197
|
-
patch: 0
|
|
1198
|
-
};
|
|
1199
|
-
|
|
1200
|
-
//#endregion
|
|
1201
|
-
//#region node_modules/.pnpm/zod@4.0.1/node_modules/zod/v4/core/schemas.js
|
|
1202
|
-
const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
1203
|
-
var _a;
|
|
1204
|
-
inst ?? (inst = {});
|
|
1205
|
-
inst._zod.def = def;
|
|
1206
|
-
inst._zod.bag = inst._zod.bag || {};
|
|
1207
|
-
inst._zod.version = version;
|
|
1208
|
-
const checks = [...inst._zod.def.checks ?? []];
|
|
1209
|
-
if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
|
|
1210
|
-
for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
|
|
1211
|
-
if (checks.length === 0) {
|
|
1212
|
-
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
1213
|
-
inst._zod.deferred?.push(() => {
|
|
1214
|
-
inst._zod.run = inst._zod.parse;
|
|
1215
|
-
});
|
|
1216
|
-
} else {
|
|
1217
|
-
const runChecks = (payload, checks$1, ctx) => {
|
|
1218
|
-
let isAborted = aborted(payload);
|
|
1219
|
-
let asyncResult;
|
|
1220
|
-
for (const ch of checks$1) {
|
|
1221
|
-
if (ch._zod.def.when) {
|
|
1222
|
-
if (!ch._zod.def.when(payload)) continue;
|
|
1223
|
-
} else if (isAborted) continue;
|
|
1224
|
-
const currLen = payload.issues.length;
|
|
1225
|
-
const _ = ch._zod.check(payload);
|
|
1226
|
-
if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
|
|
1227
|
-
if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
1228
|
-
await _;
|
|
1229
|
-
if (payload.issues.length === currLen) return;
|
|
1230
|
-
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
1231
|
-
});
|
|
1232
|
-
else {
|
|
1233
|
-
if (payload.issues.length === currLen) continue;
|
|
1234
|
-
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
if (asyncResult) return asyncResult.then(() => {
|
|
1238
|
-
return payload;
|
|
1239
|
-
});
|
|
1240
|
-
return payload;
|
|
1241
|
-
};
|
|
1242
|
-
inst._zod.run = (payload, ctx) => {
|
|
1243
|
-
const result = inst._zod.parse(payload, ctx);
|
|
1244
|
-
if (result instanceof Promise) {
|
|
1245
|
-
if (ctx.async === false) throw new $ZodAsyncError();
|
|
1246
|
-
return result.then((result$1) => runChecks(result$1, checks, ctx));
|
|
1247
|
-
}
|
|
1248
|
-
return runChecks(result, checks, ctx);
|
|
1249
|
-
};
|
|
1250
|
-
}
|
|
1251
|
-
inst["~standard"] = {
|
|
1252
|
-
validate: (value) => {
|
|
1253
|
-
try {
|
|
1254
|
-
const r = safeParse$1(inst, value);
|
|
1255
|
-
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
1256
|
-
} catch (_) {
|
|
1257
|
-
return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
|
|
1258
|
-
}
|
|
1259
|
-
},
|
|
1260
|
-
vendor: "zod",
|
|
1261
|
-
version: 1
|
|
1262
|
-
};
|
|
1263
|
-
});
|
|
1264
|
-
const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
|
|
1265
|
-
$ZodType.init(inst, def);
|
|
1266
|
-
inst._zod.parse = (payload) => payload;
|
|
1267
|
-
});
|
|
1268
|
-
const $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
|
|
1269
|
-
$ZodType.init(inst, def);
|
|
1270
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
1271
|
-
payload.issues.push({
|
|
1272
|
-
expected: "never",
|
|
1273
|
-
code: "invalid_type",
|
|
1274
|
-
input: payload.value,
|
|
1275
|
-
inst
|
|
1276
|
-
});
|
|
1277
|
-
return payload;
|
|
1278
|
-
};
|
|
1279
|
-
});
|
|
1280
|
-
function handleArrayResult(result, final, index) {
|
|
1281
|
-
if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
|
|
1282
|
-
final.value[index] = result.value;
|
|
1283
|
-
}
|
|
1284
|
-
const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
1285
|
-
$ZodType.init(inst, def);
|
|
1286
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1287
|
-
const input = payload.value;
|
|
1288
|
-
if (!Array.isArray(input)) {
|
|
1289
|
-
payload.issues.push({
|
|
1290
|
-
expected: "array",
|
|
1291
|
-
code: "invalid_type",
|
|
1292
|
-
input,
|
|
1293
|
-
inst
|
|
1294
|
-
});
|
|
1295
|
-
return payload;
|
|
1296
|
-
}
|
|
1297
|
-
payload.value = Array(input.length);
|
|
1298
|
-
const proms = [];
|
|
1299
|
-
for (let i = 0; i < input.length; i++) {
|
|
1300
|
-
const item = input[i];
|
|
1301
|
-
const result = def.element._zod.run({
|
|
1302
|
-
value: item,
|
|
1303
|
-
issues: []
|
|
1304
|
-
}, ctx);
|
|
1305
|
-
if (result instanceof Promise) proms.push(result.then((result$1) => handleArrayResult(result$1, payload, i)));
|
|
1306
|
-
else handleArrayResult(result, payload, i);
|
|
1307
|
-
}
|
|
1308
|
-
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
1309
|
-
return payload;
|
|
1310
|
-
};
|
|
1311
|
-
});
|
|
1312
|
-
function handleObjectResult(result, final, key) {
|
|
1313
|
-
if (result.issues.length) final.issues.push(...prefixIssues(key, result.issues));
|
|
1314
|
-
final.value[key] = result.value;
|
|
1315
|
-
}
|
|
1316
|
-
function handleOptionalObjectResult(result, final, key, input) {
|
|
1317
|
-
if (result.issues.length) if (input[key] === void 0) if (key in input) final.value[key] = void 0;
|
|
1318
|
-
else final.value[key] = result.value;
|
|
1319
|
-
else final.issues.push(...prefixIssues(key, result.issues));
|
|
1320
|
-
else if (result.value === void 0) {
|
|
1321
|
-
if (key in input) final.value[key] = void 0;
|
|
1322
|
-
} else final.value[key] = result.value;
|
|
1323
|
-
}
|
|
1324
|
-
const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
1325
|
-
$ZodType.init(inst, def);
|
|
1326
|
-
const _normalized = cached(() => {
|
|
1327
|
-
const keys = Object.keys(def.shape);
|
|
1328
|
-
for (const k of keys) if (!(def.shape[k] instanceof $ZodType)) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
1329
|
-
const okeys = optionalKeys(def.shape);
|
|
1330
|
-
return {
|
|
1331
|
-
shape: def.shape,
|
|
1332
|
-
keys,
|
|
1333
|
-
keySet: new Set(keys),
|
|
1334
|
-
numKeys: keys.length,
|
|
1335
|
-
optionalKeys: new Set(okeys)
|
|
1336
|
-
};
|
|
1337
|
-
});
|
|
1338
|
-
defineLazy(inst._zod, "propValues", () => {
|
|
1339
|
-
const shape = def.shape;
|
|
1340
|
-
const propValues = {};
|
|
1341
|
-
for (const key in shape) {
|
|
1342
|
-
const field = shape[key]._zod;
|
|
1343
|
-
if (field.values) {
|
|
1344
|
-
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
1345
|
-
for (const v of field.values) propValues[key].add(v);
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
|
-
return propValues;
|
|
1349
|
-
});
|
|
1350
|
-
const generateFastpass = (shape) => {
|
|
1351
|
-
const doc = new Doc([
|
|
1352
|
-
"shape",
|
|
1353
|
-
"payload",
|
|
1354
|
-
"ctx"
|
|
1355
|
-
]);
|
|
1356
|
-
const normalized = _normalized.value;
|
|
1357
|
-
const parseStr = (key) => {
|
|
1358
|
-
const k = esc(key);
|
|
1359
|
-
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
1360
|
-
};
|
|
1361
|
-
doc.write(`const input = payload.value;`);
|
|
1362
|
-
const ids = Object.create(null);
|
|
1363
|
-
let counter = 0;
|
|
1364
|
-
for (const key of normalized.keys) ids[key] = `key_${counter++}`;
|
|
1365
|
-
doc.write(`const newResult = {}`);
|
|
1366
|
-
for (const key of normalized.keys) if (normalized.optionalKeys.has(key)) {
|
|
1367
|
-
const id = ids[key];
|
|
1368
|
-
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
1369
|
-
const k = esc(key);
|
|
1370
|
-
doc.write(`
|
|
1371
|
-
if (${id}.issues.length) {
|
|
1372
|
-
if (input[${k}] === undefined) {
|
|
1373
|
-
if (${k} in input) {
|
|
1374
|
-
newResult[${k}] = undefined;
|
|
1375
|
-
}
|
|
1376
|
-
} else {
|
|
1377
|
-
payload.issues = payload.issues.concat(
|
|
1378
|
-
${id}.issues.map((iss) => ({
|
|
1379
|
-
...iss,
|
|
1380
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}],
|
|
1381
|
-
}))
|
|
1382
|
-
);
|
|
1383
|
-
}
|
|
1384
|
-
} else if (${id}.value === undefined) {
|
|
1385
|
-
if (${k} in input) newResult[${k}] = undefined;
|
|
1386
|
-
} else {
|
|
1387
|
-
newResult[${k}] = ${id}.value;
|
|
1388
|
-
}
|
|
1389
|
-
`);
|
|
1390
|
-
} else {
|
|
1391
|
-
const id = ids[key];
|
|
1392
|
-
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
1393
|
-
doc.write(`
|
|
1394
|
-
if (${id}.issues.length) payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1395
|
-
...iss,
|
|
1396
|
-
path: iss.path ? [${esc(key)}, ...iss.path] : [${esc(key)}]
|
|
1397
|
-
})));`);
|
|
1398
|
-
doc.write(`newResult[${esc(key)}] = ${id}.value`);
|
|
1399
|
-
}
|
|
1400
|
-
doc.write(`payload.value = newResult;`);
|
|
1401
|
-
doc.write(`return payload;`);
|
|
1402
|
-
const fn = doc.compile();
|
|
1403
|
-
return (payload, ctx) => fn(shape, payload, ctx);
|
|
1404
|
-
};
|
|
1405
|
-
let fastpass;
|
|
1406
|
-
const isObject$1 = isObject;
|
|
1407
|
-
const jit = !globalConfig.jitless;
|
|
1408
|
-
const allowsEval$1 = allowsEval;
|
|
1409
|
-
const fastEnabled = jit && allowsEval$1.value;
|
|
1410
|
-
const catchall = def.catchall;
|
|
1411
|
-
let value;
|
|
1412
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1413
|
-
value ?? (value = _normalized.value);
|
|
1414
|
-
const input = payload.value;
|
|
1415
|
-
if (!isObject$1(input)) {
|
|
1416
|
-
payload.issues.push({
|
|
1417
|
-
expected: "object",
|
|
1418
|
-
code: "invalid_type",
|
|
1419
|
-
input,
|
|
1420
|
-
inst
|
|
1421
|
-
});
|
|
1422
|
-
return payload;
|
|
1423
|
-
}
|
|
1424
|
-
const proms = [];
|
|
1425
|
-
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
|
1426
|
-
if (!fastpass) fastpass = generateFastpass(def.shape);
|
|
1427
|
-
payload = fastpass(payload, ctx);
|
|
1428
|
-
} else {
|
|
1429
|
-
payload.value = {};
|
|
1430
|
-
const shape = value.shape;
|
|
1431
|
-
for (const key of value.keys) {
|
|
1432
|
-
const el = shape[key];
|
|
1433
|
-
const r = el._zod.run({
|
|
1434
|
-
value: input[key],
|
|
1435
|
-
issues: []
|
|
1436
|
-
}, ctx);
|
|
1437
|
-
const isOptional = el._zod.optin === "optional" && el._zod.optout === "optional";
|
|
1438
|
-
if (r instanceof Promise) proms.push(r.then((r$1) => isOptional ? handleOptionalObjectResult(r$1, payload, key, input) : handleObjectResult(r$1, payload, key)));
|
|
1439
|
-
else if (isOptional) handleOptionalObjectResult(r, payload, key, input);
|
|
1440
|
-
else handleObjectResult(r, payload, key);
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
1444
|
-
const unrecognized = [];
|
|
1445
|
-
const keySet = value.keySet;
|
|
1446
|
-
const _catchall = catchall._zod;
|
|
1447
|
-
const t = _catchall.def.type;
|
|
1448
|
-
for (const key of Object.keys(input)) {
|
|
1449
|
-
if (keySet.has(key)) continue;
|
|
1450
|
-
if (t === "never") {
|
|
1451
|
-
unrecognized.push(key);
|
|
1452
|
-
continue;
|
|
1453
|
-
}
|
|
1454
|
-
const r = _catchall.run({
|
|
1455
|
-
value: input[key],
|
|
1456
|
-
issues: []
|
|
1457
|
-
}, ctx);
|
|
1458
|
-
if (r instanceof Promise) proms.push(r.then((r$1) => handleObjectResult(r$1, payload, key)));
|
|
1459
|
-
else handleObjectResult(r, payload, key);
|
|
1460
|
-
}
|
|
1461
|
-
if (unrecognized.length) payload.issues.push({
|
|
1462
|
-
code: "unrecognized_keys",
|
|
1463
|
-
keys: unrecognized,
|
|
1464
|
-
input,
|
|
1465
|
-
inst
|
|
1466
|
-
});
|
|
1467
|
-
if (!proms.length) return payload;
|
|
1468
|
-
return Promise.all(proms).then(() => {
|
|
1469
|
-
return payload;
|
|
1470
|
-
});
|
|
1471
|
-
};
|
|
1472
|
-
});
|
|
1473
|
-
function handleUnionResults(results, final, inst, ctx) {
|
|
1474
|
-
for (const result of results) if (result.issues.length === 0) {
|
|
1475
|
-
final.value = result.value;
|
|
1476
|
-
return final;
|
|
1477
|
-
}
|
|
1478
|
-
final.issues.push({
|
|
1479
|
-
code: "invalid_union",
|
|
1480
|
-
input: final.value,
|
|
1481
|
-
inst,
|
|
1482
|
-
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
1483
|
-
});
|
|
1484
|
-
return final;
|
|
1485
|
-
}
|
|
1486
|
-
const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
1487
|
-
$ZodType.init(inst, def);
|
|
1488
|
-
defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
|
|
1489
|
-
defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
|
|
1490
|
-
defineLazy(inst._zod, "values", () => {
|
|
1491
|
-
if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
1492
|
-
});
|
|
1493
|
-
defineLazy(inst._zod, "pattern", () => {
|
|
1494
|
-
if (def.options.every((o) => o._zod.pattern)) {
|
|
1495
|
-
const patterns = def.options.map((o) => o._zod.pattern);
|
|
1496
|
-
return /* @__PURE__ */ new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
1497
|
-
}
|
|
1498
|
-
});
|
|
1499
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1500
|
-
let async = false;
|
|
1501
|
-
const results = [];
|
|
1502
|
-
for (const option of def.options) {
|
|
1503
|
-
const result = option._zod.run({
|
|
1504
|
-
value: payload.value,
|
|
1505
|
-
issues: []
|
|
1506
|
-
}, ctx);
|
|
1507
|
-
if (result instanceof Promise) {
|
|
1508
|
-
results.push(result);
|
|
1509
|
-
async = true;
|
|
1510
|
-
} else {
|
|
1511
|
-
if (result.issues.length === 0) return result;
|
|
1512
|
-
results.push(result);
|
|
1513
|
-
}
|
|
1514
|
-
}
|
|
1515
|
-
if (!async) return handleUnionResults(results, payload, inst, ctx);
|
|
1516
|
-
return Promise.all(results).then((results$1) => {
|
|
1517
|
-
return handleUnionResults(results$1, payload, inst, ctx);
|
|
1518
|
-
});
|
|
1519
|
-
};
|
|
1520
|
-
});
|
|
1521
|
-
const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
|
|
1522
|
-
$ZodType.init(inst, def);
|
|
1523
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1524
|
-
const input = payload.value;
|
|
1525
|
-
const left = def.left._zod.run({
|
|
1526
|
-
value: input,
|
|
1527
|
-
issues: []
|
|
1528
|
-
}, ctx);
|
|
1529
|
-
const right = def.right._zod.run({
|
|
1530
|
-
value: input,
|
|
1531
|
-
issues: []
|
|
1532
|
-
}, ctx);
|
|
1533
|
-
if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left$1, right$1]) => {
|
|
1534
|
-
return handleIntersectionResults(payload, left$1, right$1);
|
|
1535
|
-
});
|
|
1536
|
-
return handleIntersectionResults(payload, left, right);
|
|
1537
|
-
};
|
|
1538
|
-
});
|
|
1539
|
-
function mergeValues(a, b) {
|
|
1540
|
-
if (a === b) return {
|
|
1541
|
-
valid: true,
|
|
1542
|
-
data: a
|
|
1543
|
-
};
|
|
1544
|
-
if (a instanceof Date && b instanceof Date && +a === +b) return {
|
|
1545
|
-
valid: true,
|
|
1546
|
-
data: a
|
|
1547
|
-
};
|
|
1548
|
-
if (isPlainObject(a) && isPlainObject(b)) {
|
|
1549
|
-
const bKeys = Object.keys(b);
|
|
1550
|
-
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
1551
|
-
const newObj = {
|
|
1552
|
-
...a,
|
|
1553
|
-
...b
|
|
1554
|
-
};
|
|
1555
|
-
for (const key of sharedKeys) {
|
|
1556
|
-
const sharedValue = mergeValues(a[key], b[key]);
|
|
1557
|
-
if (!sharedValue.valid) return {
|
|
1558
|
-
valid: false,
|
|
1559
|
-
mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
|
|
1560
|
-
};
|
|
1561
|
-
newObj[key] = sharedValue.data;
|
|
1562
|
-
}
|
|
1563
|
-
return {
|
|
1564
|
-
valid: true,
|
|
1565
|
-
data: newObj
|
|
1566
|
-
};
|
|
1567
|
-
}
|
|
1568
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
1569
|
-
if (a.length !== b.length) return {
|
|
1570
|
-
valid: false,
|
|
1571
|
-
mergeErrorPath: []
|
|
1572
|
-
};
|
|
1573
|
-
const newArray = [];
|
|
1574
|
-
for (let index = 0; index < a.length; index++) {
|
|
1575
|
-
const itemA = a[index];
|
|
1576
|
-
const itemB = b[index];
|
|
1577
|
-
const sharedValue = mergeValues(itemA, itemB);
|
|
1578
|
-
if (!sharedValue.valid) return {
|
|
1579
|
-
valid: false,
|
|
1580
|
-
mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
|
|
1581
|
-
};
|
|
1582
|
-
newArray.push(sharedValue.data);
|
|
1583
|
-
}
|
|
1584
|
-
return {
|
|
1585
|
-
valid: true,
|
|
1586
|
-
data: newArray
|
|
1587
|
-
};
|
|
1588
|
-
}
|
|
1589
|
-
return {
|
|
1590
|
-
valid: false,
|
|
1591
|
-
mergeErrorPath: []
|
|
1592
|
-
};
|
|
1593
|
-
}
|
|
1594
|
-
function handleIntersectionResults(result, left, right) {
|
|
1595
|
-
if (left.issues.length) result.issues.push(...left.issues);
|
|
1596
|
-
if (right.issues.length) result.issues.push(...right.issues);
|
|
1597
|
-
if (aborted(result)) return result;
|
|
1598
|
-
const merged = mergeValues(left.value, right.value);
|
|
1599
|
-
if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
1600
|
-
result.value = merged.data;
|
|
1601
|
-
return result;
|
|
1602
|
-
}
|
|
1603
|
-
const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
1604
|
-
$ZodType.init(inst, def);
|
|
1605
|
-
const values = getEnumValues(def.entries);
|
|
1606
|
-
inst._zod.values = new Set(values);
|
|
1607
|
-
inst._zod.pattern = /* @__PURE__ */ new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
1608
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
1609
|
-
const input = payload.value;
|
|
1610
|
-
if (inst._zod.values.has(input)) return payload;
|
|
1611
|
-
payload.issues.push({
|
|
1612
|
-
code: "invalid_value",
|
|
1613
|
-
values,
|
|
1614
|
-
input,
|
|
1615
|
-
inst
|
|
1616
|
-
});
|
|
1617
|
-
return payload;
|
|
1618
|
-
};
|
|
1619
|
-
});
|
|
1620
|
-
const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
1621
|
-
$ZodType.init(inst, def);
|
|
1622
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
1623
|
-
const _out = def.transform(payload.value, payload);
|
|
1624
|
-
if (_ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
|
|
1625
|
-
payload.value = output;
|
|
1626
|
-
return payload;
|
|
1627
|
-
});
|
|
1628
|
-
if (_out instanceof Promise) throw new $ZodAsyncError();
|
|
1629
|
-
payload.value = _out;
|
|
1630
|
-
return payload;
|
|
1631
|
-
};
|
|
1632
|
-
});
|
|
1633
|
-
const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
1634
|
-
$ZodType.init(inst, def);
|
|
1635
|
-
inst._zod.optin = "optional";
|
|
1636
|
-
inst._zod.optout = "optional";
|
|
1637
|
-
defineLazy(inst._zod, "values", () => {
|
|
1638
|
-
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
|
|
1639
|
-
});
|
|
1640
|
-
defineLazy(inst._zod, "pattern", () => {
|
|
1641
|
-
const pattern = def.innerType._zod.pattern;
|
|
1642
|
-
return pattern ? /* @__PURE__ */ new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
1643
|
-
});
|
|
1644
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1645
|
-
if (def.innerType._zod.optin === "optional") return def.innerType._zod.run(payload, ctx);
|
|
1646
|
-
if (payload.value === void 0) return payload;
|
|
1647
|
-
return def.innerType._zod.run(payload, ctx);
|
|
1648
|
-
};
|
|
1649
|
-
});
|
|
1650
|
-
const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
1651
|
-
$ZodType.init(inst, def);
|
|
1652
|
-
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1653
|
-
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1654
|
-
defineLazy(inst._zod, "pattern", () => {
|
|
1655
|
-
const pattern = def.innerType._zod.pattern;
|
|
1656
|
-
return pattern ? /* @__PURE__ */ new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
|
|
1657
|
-
});
|
|
1658
|
-
defineLazy(inst._zod, "values", () => {
|
|
1659
|
-
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
|
|
1660
|
-
});
|
|
1661
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1662
|
-
if (payload.value === null) return payload;
|
|
1663
|
-
return def.innerType._zod.run(payload, ctx);
|
|
1664
|
-
};
|
|
1665
|
-
});
|
|
1666
|
-
const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
|
|
1667
|
-
$ZodType.init(inst, def);
|
|
1668
|
-
inst._zod.optin = "optional";
|
|
1669
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1670
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1671
|
-
if (payload.value === void 0) {
|
|
1672
|
-
payload.value = def.defaultValue;
|
|
1673
|
-
/**
|
|
1674
|
-
* $ZodDefault always returns the default value immediately.
|
|
1675
|
-
* It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
|
|
1676
|
-
return payload;
|
|
1677
|
-
}
|
|
1678
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
1679
|
-
if (result instanceof Promise) return result.then((result$1) => handleDefaultResult(result$1, def));
|
|
1680
|
-
return handleDefaultResult(result, def);
|
|
1681
|
-
};
|
|
1682
|
-
});
|
|
1683
|
-
function handleDefaultResult(payload, def) {
|
|
1684
|
-
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
1685
|
-
return payload;
|
|
1686
|
-
}
|
|
1687
|
-
const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
1688
|
-
$ZodType.init(inst, def);
|
|
1689
|
-
inst._zod.optin = "optional";
|
|
1690
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1691
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1692
|
-
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
1693
|
-
return def.innerType._zod.run(payload, ctx);
|
|
1694
|
-
};
|
|
1695
|
-
});
|
|
1696
|
-
const $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
1697
|
-
$ZodType.init(inst, def);
|
|
1698
|
-
defineLazy(inst._zod, "values", () => {
|
|
1699
|
-
const v = def.innerType._zod.values;
|
|
1700
|
-
return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
|
|
1701
|
-
});
|
|
1702
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1703
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
1704
|
-
if (result instanceof Promise) return result.then((result$1) => handleNonOptionalResult(result$1, inst));
|
|
1705
|
-
return handleNonOptionalResult(result, inst);
|
|
1706
|
-
};
|
|
1707
|
-
});
|
|
1708
|
-
function handleNonOptionalResult(payload, inst) {
|
|
1709
|
-
if (!payload.issues.length && payload.value === void 0) payload.issues.push({
|
|
1710
|
-
code: "invalid_type",
|
|
1711
|
-
expected: "nonoptional",
|
|
1712
|
-
input: payload.value,
|
|
1713
|
-
inst
|
|
1714
|
-
});
|
|
1715
|
-
return payload;
|
|
1716
|
-
}
|
|
1717
|
-
const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
1718
|
-
$ZodType.init(inst, def);
|
|
1719
|
-
inst._zod.optin = "optional";
|
|
1720
|
-
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1721
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1722
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1723
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
1724
|
-
if (result instanceof Promise) return result.then((result$1) => {
|
|
1725
|
-
payload.value = result$1.value;
|
|
1726
|
-
if (result$1.issues.length) {
|
|
1727
|
-
payload.value = def.catchValue({
|
|
1728
|
-
...payload,
|
|
1729
|
-
error: { issues: result$1.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
1730
|
-
input: payload.value
|
|
1731
|
-
});
|
|
1732
|
-
payload.issues = [];
|
|
1733
|
-
}
|
|
1734
|
-
return payload;
|
|
1735
|
-
});
|
|
1736
|
-
payload.value = result.value;
|
|
1737
|
-
if (result.issues.length) {
|
|
1738
|
-
payload.value = def.catchValue({
|
|
1739
|
-
...payload,
|
|
1740
|
-
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
1741
|
-
input: payload.value
|
|
1742
|
-
});
|
|
1743
|
-
payload.issues = [];
|
|
1744
|
-
}
|
|
1745
|
-
return payload;
|
|
1746
|
-
};
|
|
1747
|
-
});
|
|
1748
|
-
const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
|
|
1749
|
-
$ZodType.init(inst, def);
|
|
1750
|
-
defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
1751
|
-
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
1752
|
-
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
1753
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1754
|
-
const left = def.in._zod.run(payload, ctx);
|
|
1755
|
-
if (left instanceof Promise) return left.then((left$1) => handlePipeResult(left$1, def, ctx));
|
|
1756
|
-
return handlePipeResult(left, def, ctx);
|
|
1757
|
-
};
|
|
1758
|
-
});
|
|
1759
|
-
function handlePipeResult(left, def, ctx) {
|
|
1760
|
-
if (aborted(left)) return left;
|
|
1761
|
-
return def.out._zod.run({
|
|
1762
|
-
value: left.value,
|
|
1763
|
-
issues: left.issues
|
|
1764
|
-
}, ctx);
|
|
1765
|
-
}
|
|
1766
|
-
const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
|
|
1767
|
-
$ZodType.init(inst, def);
|
|
1768
|
-
defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
1769
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1770
|
-
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1771
|
-
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1772
|
-
inst._zod.parse = (payload, ctx) => {
|
|
1773
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
1774
|
-
if (result instanceof Promise) return result.then(handleReadonlyResult);
|
|
1775
|
-
return handleReadonlyResult(result);
|
|
1776
|
-
};
|
|
1777
|
-
});
|
|
1778
|
-
function handleReadonlyResult(payload) {
|
|
1779
|
-
payload.value = Object.freeze(payload.value);
|
|
1780
|
-
return payload;
|
|
1781
|
-
}
|
|
1782
|
-
const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
1783
|
-
$ZodCheck.init(inst, def);
|
|
1784
|
-
$ZodType.init(inst, def);
|
|
1785
|
-
inst._zod.parse = (payload, _) => {
|
|
1786
|
-
return payload;
|
|
1787
|
-
};
|
|
1788
|
-
inst._zod.check = (payload) => {
|
|
1789
|
-
const input = payload.value;
|
|
1790
|
-
const r = def.fn(input);
|
|
1791
|
-
if (r instanceof Promise) return r.then((r$1) => handleRefineResult(r$1, payload, input, inst));
|
|
1792
|
-
handleRefineResult(r, payload, input, inst);
|
|
1793
|
-
};
|
|
1794
|
-
});
|
|
1795
|
-
function handleRefineResult(result, payload, input, inst) {
|
|
1796
|
-
if (!result) {
|
|
1797
|
-
const _iss = {
|
|
1798
|
-
code: "custom",
|
|
1799
|
-
input,
|
|
1800
|
-
inst,
|
|
1801
|
-
path: [...inst._zod.def.path ?? []],
|
|
1802
|
-
continue: !inst._zod.def.abort
|
|
1803
|
-
};
|
|
1804
|
-
if (inst._zod.def.params) _iss.params = inst._zod.def.params;
|
|
1805
|
-
payload.issues.push(issue(_iss));
|
|
1806
|
-
}
|
|
1807
|
-
}
|
|
1808
|
-
|
|
1809
|
-
//#endregion
|
|
1810
|
-
//#region node_modules/.pnpm/zod@4.0.1/node_modules/zod/v4/core/registries.js
|
|
1811
|
-
const $output = Symbol("ZodOutput");
|
|
1812
|
-
const $input = Symbol("ZodInput");
|
|
1813
|
-
var $ZodRegistry = class {
|
|
1814
|
-
constructor() {
|
|
1815
|
-
this._map = /* @__PURE__ */ new Map();
|
|
1816
|
-
this._idmap = /* @__PURE__ */ new Map();
|
|
1817
|
-
}
|
|
1818
|
-
add(schema, ..._meta) {
|
|
1819
|
-
const meta = _meta[0];
|
|
1820
|
-
this._map.set(schema, meta);
|
|
1821
|
-
if (meta && typeof meta === "object" && "id" in meta) {
|
|
1822
|
-
if (this._idmap.has(meta.id)) throw new Error(`ID ${meta.id} already exists in the registry`);
|
|
1823
|
-
this._idmap.set(meta.id, schema);
|
|
1824
|
-
}
|
|
1825
|
-
return this;
|
|
1826
|
-
}
|
|
1827
|
-
clear() {
|
|
1828
|
-
this._map = /* @__PURE__ */ new Map();
|
|
1829
|
-
this._idmap = /* @__PURE__ */ new Map();
|
|
1830
|
-
return this;
|
|
1831
|
-
}
|
|
1832
|
-
remove(schema) {
|
|
1833
|
-
const meta = this._map.get(schema);
|
|
1834
|
-
if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
|
|
1835
|
-
this._map.delete(schema);
|
|
1836
|
-
return this;
|
|
1837
|
-
}
|
|
1838
|
-
get(schema) {
|
|
1839
|
-
const p = schema._zod.parent;
|
|
1840
|
-
if (p) {
|
|
1841
|
-
const pm = { ...this.get(p) ?? {} };
|
|
1842
|
-
delete pm.id;
|
|
1843
|
-
return {
|
|
1844
|
-
...pm,
|
|
1845
|
-
...this._map.get(schema)
|
|
1846
|
-
};
|
|
1847
|
-
}
|
|
1848
|
-
return this._map.get(schema);
|
|
1849
|
-
}
|
|
1850
|
-
has(schema) {
|
|
1851
|
-
return this._map.has(schema);
|
|
1852
|
-
}
|
|
1853
|
-
};
|
|
1854
|
-
function registry() {
|
|
1855
|
-
return new $ZodRegistry();
|
|
1856
|
-
}
|
|
1857
|
-
const globalRegistry = /* @__PURE__ */ registry();
|
|
1858
|
-
|
|
1859
|
-
//#endregion
|
|
1860
|
-
//#region node_modules/.pnpm/zod@4.0.1/node_modules/zod/v4/core/api.js
|
|
1861
|
-
function _unknown(Class) {
|
|
1862
|
-
return new Class({ type: "unknown" });
|
|
1863
|
-
}
|
|
1864
|
-
function _never(Class, params) {
|
|
1865
|
-
return new Class({
|
|
1866
|
-
type: "never",
|
|
1867
|
-
...normalizeParams(params)
|
|
1868
|
-
});
|
|
1869
|
-
}
|
|
1870
|
-
function _maxLength(maximum, params) {
|
|
1871
|
-
return new $ZodCheckMaxLength({
|
|
1872
|
-
check: "max_length",
|
|
1873
|
-
...normalizeParams(params),
|
|
1874
|
-
maximum
|
|
1875
|
-
});
|
|
1876
|
-
}
|
|
1877
|
-
function _minLength(minimum, params) {
|
|
1878
|
-
return new $ZodCheckMinLength({
|
|
1879
|
-
check: "min_length",
|
|
1880
|
-
...normalizeParams(params),
|
|
1881
|
-
minimum
|
|
1882
|
-
});
|
|
1883
|
-
}
|
|
1884
|
-
function _length(length, params) {
|
|
1885
|
-
return new $ZodCheckLengthEquals({
|
|
1886
|
-
check: "length_equals",
|
|
1887
|
-
...normalizeParams(params),
|
|
1888
|
-
length
|
|
1889
|
-
});
|
|
1890
|
-
}
|
|
1891
|
-
function _overwrite(tx) {
|
|
1892
|
-
return new $ZodCheckOverwrite({
|
|
1893
|
-
check: "overwrite",
|
|
1894
|
-
tx
|
|
1895
|
-
});
|
|
1896
|
-
}
|
|
1897
|
-
function _array(Class, element, params) {
|
|
1898
|
-
return new Class({
|
|
1899
|
-
type: "array",
|
|
1900
|
-
element,
|
|
1901
|
-
...normalizeParams(params)
|
|
1902
|
-
});
|
|
1903
|
-
}
|
|
1904
|
-
function _refine(Class, fn, _params) {
|
|
1905
|
-
return new Class({
|
|
1906
|
-
type: "custom",
|
|
1907
|
-
check: "custom",
|
|
1908
|
-
fn,
|
|
1909
|
-
...normalizeParams(_params)
|
|
1910
|
-
});
|
|
1911
|
-
}
|
|
1912
|
-
|
|
1913
|
-
//#endregion
|
|
1914
|
-
//#region node_modules/.pnpm/zod@4.0.1/node_modules/zod/v4/classic/errors.js
|
|
1915
|
-
const initializer = (inst, issues) => {
|
|
1916
|
-
$ZodError.init(inst, issues);
|
|
1917
|
-
inst.name = "ZodError";
|
|
1918
|
-
Object.defineProperties(inst, {
|
|
1919
|
-
format: { value: (mapper) => formatError(inst, mapper) },
|
|
1920
|
-
flatten: { value: (mapper) => flattenError(inst, mapper) },
|
|
1921
|
-
addIssue: { value: (issue$1) => inst.issues.push(issue$1) },
|
|
1922
|
-
addIssues: { value: (issues$1) => inst.issues.push(...issues$1) },
|
|
1923
|
-
isEmpty: { get() {
|
|
1924
|
-
return inst.issues.length === 0;
|
|
1925
|
-
} }
|
|
1926
|
-
});
|
|
1927
|
-
};
|
|
1928
|
-
const ZodError = $constructor("ZodError", initializer);
|
|
1929
|
-
const ZodRealError = $constructor("ZodError", initializer, { Parent: Error });
|
|
1930
|
-
|
|
1931
|
-
//#endregion
|
|
1932
|
-
//#region node_modules/.pnpm/zod@4.0.1/node_modules/zod/v4/classic/parse.js
|
|
1933
|
-
const parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
1934
|
-
const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
1935
|
-
const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
1936
|
-
const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
1937
|
-
|
|
1938
|
-
//#endregion
|
|
1939
|
-
//#region node_modules/.pnpm/zod@4.0.1/node_modules/zod/v4/classic/schemas.js
|
|
1940
|
-
const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
1941
|
-
$ZodType.init(inst, def);
|
|
1942
|
-
inst.def = def;
|
|
1943
|
-
Object.defineProperty(inst, "_def", { value: def });
|
|
1944
|
-
inst.check = (...checks) => {
|
|
1945
|
-
return inst.clone({
|
|
1946
|
-
...def,
|
|
1947
|
-
checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
|
|
1948
|
-
check: ch,
|
|
1949
|
-
def: { check: "custom" },
|
|
1950
|
-
onattach: []
|
|
1951
|
-
} } : ch)]
|
|
1952
|
-
});
|
|
1953
|
-
};
|
|
1954
|
-
inst.clone = (def$1, params) => clone(inst, def$1, params);
|
|
1955
|
-
inst.brand = () => inst;
|
|
1956
|
-
inst.register = ((reg, meta) => {
|
|
1957
|
-
reg.add(inst, meta);
|
|
1958
|
-
return inst;
|
|
1959
|
-
});
|
|
1960
|
-
inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
|
|
1961
|
-
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
1962
|
-
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
1963
|
-
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
1964
|
-
inst.spa = inst.safeParseAsync;
|
|
1965
|
-
inst.refine = (check$1, params) => inst.check(refine(check$1, params));
|
|
1966
|
-
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
|
1967
|
-
inst.overwrite = (fn) => inst.check(_overwrite(fn));
|
|
1968
|
-
inst.optional = () => optional(inst);
|
|
1969
|
-
inst.nullable = () => nullable(inst);
|
|
1970
|
-
inst.nullish = () => optional(nullable(inst));
|
|
1971
|
-
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
1972
|
-
inst.array = () => array(inst);
|
|
1973
|
-
inst.or = (arg) => union([inst, arg]);
|
|
1974
|
-
inst.and = (arg) => intersection(inst, arg);
|
|
1975
|
-
inst.transform = (tx) => pipe(inst, transform(tx));
|
|
1976
|
-
inst.default = (def$1) => _default(inst, def$1);
|
|
1977
|
-
inst.prefault = (def$1) => prefault(inst, def$1);
|
|
1978
|
-
inst.catch = (params) => _catch(inst, params);
|
|
1979
|
-
inst.pipe = (target) => pipe(inst, target);
|
|
1980
|
-
inst.readonly = () => readonly(inst);
|
|
1981
|
-
inst.describe = (description) => {
|
|
1982
|
-
const cl = inst.clone();
|
|
1983
|
-
globalRegistry.add(cl, { description });
|
|
1984
|
-
return cl;
|
|
1985
|
-
};
|
|
1986
|
-
Object.defineProperty(inst, "description", {
|
|
1987
|
-
get() {
|
|
1988
|
-
return globalRegistry.get(inst)?.description;
|
|
1989
|
-
},
|
|
1990
|
-
configurable: true
|
|
1991
|
-
});
|
|
1992
|
-
inst.meta = (...args) => {
|
|
1993
|
-
if (args.length === 0) return globalRegistry.get(inst);
|
|
1994
|
-
const cl = inst.clone();
|
|
1995
|
-
globalRegistry.add(cl, args[0]);
|
|
1996
|
-
return cl;
|
|
1997
|
-
};
|
|
1998
|
-
inst.isOptional = () => inst.safeParse(void 0).success;
|
|
1999
|
-
inst.isNullable = () => inst.safeParse(null).success;
|
|
2000
|
-
return inst;
|
|
2001
|
-
});
|
|
2002
|
-
const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
2003
|
-
$ZodUnknown.init(inst, def);
|
|
2004
|
-
ZodType.init(inst, def);
|
|
2005
|
-
});
|
|
2006
|
-
function unknown() {
|
|
2007
|
-
return _unknown(ZodUnknown);
|
|
2008
|
-
}
|
|
2009
|
-
const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
2010
|
-
$ZodNever.init(inst, def);
|
|
2011
|
-
ZodType.init(inst, def);
|
|
2012
|
-
});
|
|
2013
|
-
function never(params) {
|
|
2014
|
-
return _never(ZodNever, params);
|
|
2015
|
-
}
|
|
2016
|
-
const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
2017
|
-
$ZodArray.init(inst, def);
|
|
2018
|
-
ZodType.init(inst, def);
|
|
2019
|
-
inst.element = def.element;
|
|
2020
|
-
inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
|
|
2021
|
-
inst.nonempty = (params) => inst.check(_minLength(1, params));
|
|
2022
|
-
inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
|
|
2023
|
-
inst.length = (len, params) => inst.check(_length(len, params));
|
|
2024
|
-
inst.unwrap = () => inst.element;
|
|
2025
|
-
});
|
|
2026
|
-
function array(element, params) {
|
|
2027
|
-
return _array(ZodArray, element, params);
|
|
2028
|
-
}
|
|
2029
|
-
const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
2030
|
-
$ZodObject.init(inst, def);
|
|
2031
|
-
ZodType.init(inst, def);
|
|
2032
|
-
defineLazy(inst, "shape", () => def.shape);
|
|
2033
|
-
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
2034
|
-
inst.catchall = (catchall) => inst.clone({
|
|
2035
|
-
...inst._zod.def,
|
|
2036
|
-
catchall
|
|
2037
|
-
});
|
|
2038
|
-
inst.passthrough = () => inst.clone({
|
|
2039
|
-
...inst._zod.def,
|
|
2040
|
-
catchall: unknown()
|
|
2041
|
-
});
|
|
2042
|
-
inst.loose = () => inst.clone({
|
|
2043
|
-
...inst._zod.def,
|
|
2044
|
-
catchall: unknown()
|
|
2045
|
-
});
|
|
2046
|
-
inst.strict = () => inst.clone({
|
|
2047
|
-
...inst._zod.def,
|
|
2048
|
-
catchall: never()
|
|
2049
|
-
});
|
|
2050
|
-
inst.strip = () => inst.clone({
|
|
2051
|
-
...inst._zod.def,
|
|
2052
|
-
catchall: void 0
|
|
2053
|
-
});
|
|
2054
|
-
inst.extend = (incoming) => {
|
|
2055
|
-
return extend(inst, incoming);
|
|
2056
|
-
};
|
|
2057
|
-
inst.merge = (other) => merge(inst, other);
|
|
2058
|
-
inst.pick = (mask) => pick(inst, mask);
|
|
2059
|
-
inst.omit = (mask) => omit(inst, mask);
|
|
2060
|
-
inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
|
|
2061
|
-
inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
|
|
2062
|
-
});
|
|
2063
|
-
const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
2064
|
-
$ZodUnion.init(inst, def);
|
|
2065
|
-
ZodType.init(inst, def);
|
|
2066
|
-
inst.options = def.options;
|
|
2067
|
-
});
|
|
2068
|
-
function union(options, params) {
|
|
2069
|
-
return new ZodUnion({
|
|
2070
|
-
type: "union",
|
|
2071
|
-
options,
|
|
2072
|
-
...normalizeParams(params)
|
|
2073
|
-
});
|
|
2074
|
-
}
|
|
2075
|
-
const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
2076
|
-
$ZodIntersection.init(inst, def);
|
|
2077
|
-
ZodType.init(inst, def);
|
|
2078
|
-
});
|
|
2079
|
-
function intersection(left, right) {
|
|
2080
|
-
return new ZodIntersection({
|
|
2081
|
-
type: "intersection",
|
|
2082
|
-
left,
|
|
2083
|
-
right
|
|
2084
|
-
});
|
|
2085
|
-
}
|
|
2086
|
-
const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
2087
|
-
$ZodEnum.init(inst, def);
|
|
2088
|
-
ZodType.init(inst, def);
|
|
2089
|
-
inst.enum = def.entries;
|
|
2090
|
-
inst.options = Object.values(def.entries);
|
|
2091
|
-
const keys = new Set(Object.keys(def.entries));
|
|
2092
|
-
inst.extract = (values, params) => {
|
|
2093
|
-
const newEntries = {};
|
|
2094
|
-
for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
|
|
2095
|
-
else throw new Error(`Key ${value} not found in enum`);
|
|
2096
|
-
return new ZodEnum({
|
|
2097
|
-
...def,
|
|
2098
|
-
checks: [],
|
|
2099
|
-
...normalizeParams(params),
|
|
2100
|
-
entries: newEntries
|
|
2101
|
-
});
|
|
2102
|
-
};
|
|
2103
|
-
inst.exclude = (values, params) => {
|
|
2104
|
-
const newEntries = { ...def.entries };
|
|
2105
|
-
for (const value of values) if (keys.has(value)) delete newEntries[value];
|
|
2106
|
-
else throw new Error(`Key ${value} not found in enum`);
|
|
2107
|
-
return new ZodEnum({
|
|
2108
|
-
...def,
|
|
2109
|
-
checks: [],
|
|
2110
|
-
...normalizeParams(params),
|
|
2111
|
-
entries: newEntries
|
|
2112
|
-
});
|
|
2113
|
-
};
|
|
2114
|
-
});
|
|
2115
|
-
function _enum(values, params) {
|
|
2116
|
-
return new ZodEnum({
|
|
2117
|
-
type: "enum",
|
|
2118
|
-
entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values,
|
|
2119
|
-
...normalizeParams(params)
|
|
2120
|
-
});
|
|
2121
|
-
}
|
|
2122
|
-
const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
2123
|
-
$ZodTransform.init(inst, def);
|
|
2124
|
-
ZodType.init(inst, def);
|
|
2125
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
2126
|
-
payload.addIssue = (issue$1) => {
|
|
2127
|
-
if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
|
|
2128
|
-
else {
|
|
2129
|
-
const _issue = issue$1;
|
|
2130
|
-
if (_issue.fatal) _issue.continue = false;
|
|
2131
|
-
_issue.code ?? (_issue.code = "custom");
|
|
2132
|
-
_issue.input ?? (_issue.input = payload.value);
|
|
2133
|
-
_issue.inst ?? (_issue.inst = inst);
|
|
2134
|
-
_issue.continue ?? (_issue.continue = true);
|
|
2135
|
-
payload.issues.push(issue(_issue));
|
|
2136
|
-
}
|
|
2137
|
-
};
|
|
2138
|
-
const output = def.transform(payload.value, payload);
|
|
2139
|
-
if (output instanceof Promise) return output.then((output$1) => {
|
|
2140
|
-
payload.value = output$1;
|
|
2141
|
-
return payload;
|
|
2142
|
-
});
|
|
2143
|
-
payload.value = output;
|
|
2144
|
-
return payload;
|
|
2145
|
-
};
|
|
2146
|
-
});
|
|
2147
|
-
function transform(fn) {
|
|
2148
|
-
return new ZodTransform({
|
|
2149
|
-
type: "transform",
|
|
2150
|
-
transform: fn
|
|
2151
|
-
});
|
|
2152
|
-
}
|
|
2153
|
-
const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
2154
|
-
$ZodOptional.init(inst, def);
|
|
2155
|
-
ZodType.init(inst, def);
|
|
2156
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
2157
|
-
});
|
|
2158
|
-
function optional(innerType) {
|
|
2159
|
-
return new ZodOptional({
|
|
2160
|
-
type: "optional",
|
|
2161
|
-
innerType
|
|
2162
|
-
});
|
|
2163
|
-
}
|
|
2164
|
-
const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
2165
|
-
$ZodNullable.init(inst, def);
|
|
2166
|
-
ZodType.init(inst, def);
|
|
2167
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
2168
|
-
});
|
|
2169
|
-
function nullable(innerType) {
|
|
2170
|
-
return new ZodNullable({
|
|
2171
|
-
type: "nullable",
|
|
2172
|
-
innerType
|
|
2173
|
-
});
|
|
2174
|
-
}
|
|
2175
|
-
const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
2176
|
-
$ZodDefault.init(inst, def);
|
|
2177
|
-
ZodType.init(inst, def);
|
|
2178
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
2179
|
-
inst.removeDefault = inst.unwrap;
|
|
2180
|
-
});
|
|
2181
|
-
function _default(innerType, defaultValue) {
|
|
2182
|
-
return new ZodDefault({
|
|
2183
|
-
type: "default",
|
|
2184
|
-
innerType,
|
|
2185
|
-
get defaultValue() {
|
|
2186
|
-
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
2187
|
-
}
|
|
2188
|
-
});
|
|
2189
|
-
}
|
|
2190
|
-
const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
2191
|
-
$ZodPrefault.init(inst, def);
|
|
2192
|
-
ZodType.init(inst, def);
|
|
2193
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
2194
|
-
});
|
|
2195
|
-
function prefault(innerType, defaultValue) {
|
|
2196
|
-
return new ZodPrefault({
|
|
2197
|
-
type: "prefault",
|
|
2198
|
-
innerType,
|
|
2199
|
-
get defaultValue() {
|
|
2200
|
-
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
2201
|
-
}
|
|
2202
|
-
});
|
|
2203
|
-
}
|
|
2204
|
-
const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
2205
|
-
$ZodNonOptional.init(inst, def);
|
|
2206
|
-
ZodType.init(inst, def);
|
|
2207
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
2208
|
-
});
|
|
2209
|
-
function nonoptional(innerType, params) {
|
|
2210
|
-
return new ZodNonOptional({
|
|
2211
|
-
type: "nonoptional",
|
|
2212
|
-
innerType,
|
|
2213
|
-
...normalizeParams(params)
|
|
2214
|
-
});
|
|
2215
|
-
}
|
|
2216
|
-
const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
2217
|
-
$ZodCatch.init(inst, def);
|
|
2218
|
-
ZodType.init(inst, def);
|
|
2219
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
2220
|
-
inst.removeCatch = inst.unwrap;
|
|
2221
|
-
});
|
|
2222
|
-
function _catch(innerType, catchValue) {
|
|
2223
|
-
return new ZodCatch({
|
|
2224
|
-
type: "catch",
|
|
2225
|
-
innerType,
|
|
2226
|
-
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
2227
|
-
});
|
|
2228
|
-
}
|
|
2229
|
-
const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
2230
|
-
$ZodPipe.init(inst, def);
|
|
2231
|
-
ZodType.init(inst, def);
|
|
2232
|
-
inst.in = def.in;
|
|
2233
|
-
inst.out = def.out;
|
|
2234
|
-
});
|
|
2235
|
-
function pipe(in_, out) {
|
|
2236
|
-
return new ZodPipe({
|
|
2237
|
-
type: "pipe",
|
|
2238
|
-
in: in_,
|
|
2239
|
-
out
|
|
2240
|
-
});
|
|
2241
|
-
}
|
|
2242
|
-
const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
2243
|
-
$ZodReadonly.init(inst, def);
|
|
2244
|
-
ZodType.init(inst, def);
|
|
2245
|
-
});
|
|
2246
|
-
function readonly(innerType) {
|
|
2247
|
-
return new ZodReadonly({
|
|
2248
|
-
type: "readonly",
|
|
2249
|
-
innerType
|
|
2250
|
-
});
|
|
2251
|
-
}
|
|
2252
|
-
const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
2253
|
-
$ZodCustom.init(inst, def);
|
|
2254
|
-
ZodType.init(inst, def);
|
|
2255
|
-
});
|
|
2256
|
-
function check(fn) {
|
|
2257
|
-
const ch = new $ZodCheck({ check: "custom" });
|
|
2258
|
-
ch._zod.check = fn;
|
|
2259
|
-
return ch;
|
|
2260
|
-
}
|
|
2261
|
-
function refine(fn, _params = {}) {
|
|
2262
|
-
return _refine(ZodCustom, fn, _params);
|
|
2263
|
-
}
|
|
2264
|
-
function superRefine(fn) {
|
|
2265
|
-
const ch = check((payload) => {
|
|
2266
|
-
payload.addIssue = (issue$1) => {
|
|
2267
|
-
if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
|
|
2268
|
-
else {
|
|
2269
|
-
const _issue = issue$1;
|
|
2270
|
-
if (_issue.fatal) _issue.continue = false;
|
|
2271
|
-
_issue.code ?? (_issue.code = "custom");
|
|
2272
|
-
_issue.input ?? (_issue.input = payload.value);
|
|
2273
|
-
_issue.inst ?? (_issue.inst = ch);
|
|
2274
|
-
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
2275
|
-
payload.issues.push(issue(_issue));
|
|
2276
|
-
}
|
|
2277
|
-
};
|
|
2278
|
-
return fn(payload.value, payload);
|
|
2279
|
-
});
|
|
2280
|
-
return ch;
|
|
2281
|
-
}
|
|
2282
|
-
|
|
2283
616
|
//#endregion
|
|
2284
617
|
//#region src/openapi.ts
|
|
2285
618
|
const paths = {};
|
|
@@ -2319,14 +652,14 @@ function getRequestBody(options) {
|
|
|
2319
652
|
const shape = options.body.shape;
|
|
2320
653
|
if (!shape) return void 0;
|
|
2321
654
|
const properties = {};
|
|
2322
|
-
const required
|
|
655
|
+
const required = [];
|
|
2323
656
|
Object.entries(shape).forEach(([key, value]) => {
|
|
2324
657
|
if (value instanceof ZodObject) {
|
|
2325
658
|
properties[key] = {
|
|
2326
659
|
type: getTypeFromZodType(value),
|
|
2327
660
|
description: value.description
|
|
2328
661
|
};
|
|
2329
|
-
if (!(value instanceof ZodOptional)) required
|
|
662
|
+
if (!(value instanceof ZodOptional)) required.push(key);
|
|
2330
663
|
}
|
|
2331
664
|
});
|
|
2332
665
|
return {
|
|
@@ -2334,7 +667,7 @@ function getRequestBody(options) {
|
|
|
2334
667
|
content: { "application/json": { schema: {
|
|
2335
668
|
type: "object",
|
|
2336
669
|
properties,
|
|
2337
|
-
required
|
|
670
|
+
required
|
|
2338
671
|
} } }
|
|
2339
672
|
};
|
|
2340
673
|
}
|
|
@@ -2388,7 +721,7 @@ function getResponse(responses) {
|
|
|
2388
721
|
...responses
|
|
2389
722
|
};
|
|
2390
723
|
}
|
|
2391
|
-
async function generator(endpoints, config
|
|
724
|
+
async function generator(endpoints, config) {
|
|
2392
725
|
const components = { schemas: {} };
|
|
2393
726
|
Object.entries(endpoints).forEach(([_, value]) => {
|
|
2394
727
|
const options = value.options;
|
|
@@ -2426,7 +759,7 @@ async function generator(endpoints, config$1) {
|
|
|
2426
759
|
},
|
|
2427
760
|
components,
|
|
2428
761
|
security: [{ apiKeyCookie: [] }],
|
|
2429
|
-
servers: [{ url: config
|
|
762
|
+
servers: [{ url: config?.url }],
|
|
2430
763
|
tags: [{
|
|
2431
764
|
name: "Default",
|
|
2432
765
|
description: "Default endpoints that are included with Better Auth by default. These endpoints are not part of any plugin."
|
|
@@ -2434,7 +767,7 @@ async function generator(endpoints, config$1) {
|
|
|
2434
767
|
paths
|
|
2435
768
|
};
|
|
2436
769
|
}
|
|
2437
|
-
const getHTML = (apiReference, config
|
|
770
|
+
const getHTML = (apiReference, config) => `<!doctype html>
|
|
2438
771
|
<html>
|
|
2439
772
|
<head>
|
|
2440
773
|
<title>Scalar API Reference</title>
|
|
@@ -2451,11 +784,11 @@ const getHTML = (apiReference, config$1) => `<!doctype html>
|
|
|
2451
784
|
<\/script>
|
|
2452
785
|
<script>
|
|
2453
786
|
var configuration = {
|
|
2454
|
-
favicon: ${config
|
|
2455
|
-
theme: ${config
|
|
787
|
+
favicon: ${config?.logo ? `data:image/svg+xml;utf8,${encodeURIComponent(config.logo)}` : void 0} ,
|
|
788
|
+
theme: ${config?.theme || "saturn"},
|
|
2456
789
|
metaData: {
|
|
2457
|
-
title: ${config
|
|
2458
|
-
description: ${config
|
|
790
|
+
title: ${config?.title || "Open API Reference"},
|
|
791
|
+
description: ${config?.description || "Better Call Open API"},
|
|
2459
792
|
}
|
|
2460
793
|
}
|
|
2461
794
|
document.getElementById('api-reference').dataset.configuration =
|
|
@@ -2467,11 +800,11 @@ const getHTML = (apiReference, config$1) => `<!doctype html>
|
|
|
2467
800
|
|
|
2468
801
|
//#endregion
|
|
2469
802
|
//#region src/router.ts
|
|
2470
|
-
const createRouter = (endpoints, config
|
|
2471
|
-
if (!config
|
|
803
|
+
const createRouter = (endpoints, config) => {
|
|
804
|
+
if (!config?.openapi?.disabled) {
|
|
2472
805
|
const openapi = {
|
|
2473
806
|
path: "/api/reference",
|
|
2474
|
-
...config
|
|
807
|
+
...config?.openapi
|
|
2475
808
|
};
|
|
2476
809
|
endpoints["openapi"] = createEndpoint(openapi.path, { method: "GET" }, async (c) => {
|
|
2477
810
|
const schema = await generator(endpoints);
|
|
@@ -2486,11 +819,11 @@ const createRouter = (endpoints, config$1) => {
|
|
|
2486
819
|
const methods = Array.isArray(endpoint.options?.method) ? endpoint.options.method : [endpoint.options?.method];
|
|
2487
820
|
for (const method of methods) addRoute(router, method, endpoint.path, endpoint);
|
|
2488
821
|
}
|
|
2489
|
-
if (config
|
|
822
|
+
if (config?.routerMiddleware?.length) for (const { path, middleware } of config.routerMiddleware) addRoute(middlewareRouter, "*", path, middleware);
|
|
2490
823
|
const processRequest = async (request) => {
|
|
2491
824
|
const url = new URL(request.url);
|
|
2492
|
-
const path = config
|
|
2493
|
-
if (index !== 0) if (index > 1) acc.push(`${config
|
|
825
|
+
const path = config?.basePath ? url.pathname.split(config.basePath).reduce((acc, curr, index) => {
|
|
826
|
+
if (index !== 0) if (index > 1) acc.push(`${config.basePath}${curr}`);
|
|
2494
827
|
else acc.push(curr);
|
|
2495
828
|
return acc;
|
|
2496
829
|
}, []).join("") : url.pathname;
|
|
@@ -2511,7 +844,7 @@ const createRouter = (endpoints, config$1) => {
|
|
|
2511
844
|
});
|
|
2512
845
|
const handler = route.data;
|
|
2513
846
|
try {
|
|
2514
|
-
const allowedMediaTypes = handler.options.metadata?.allowedMediaTypes || config
|
|
847
|
+
const allowedMediaTypes = handler.options.metadata?.allowedMediaTypes || config?.allowedMediaTypes;
|
|
2515
848
|
const context = {
|
|
2516
849
|
path,
|
|
2517
850
|
method: request.method,
|
|
@@ -2522,7 +855,7 @@ const createRouter = (endpoints, config$1) => {
|
|
|
2522
855
|
query,
|
|
2523
856
|
_flag: "router",
|
|
2524
857
|
asResponse: true,
|
|
2525
|
-
context: config
|
|
858
|
+
context: config?.routerContext
|
|
2526
859
|
};
|
|
2527
860
|
const middlewareRoutes = findAllRoutes(middlewareRouter, "*", path);
|
|
2528
861
|
if (middlewareRoutes?.length) for (const { data: middleware, params } of middlewareRoutes) {
|
|
@@ -2535,14 +868,14 @@ const createRouter = (endpoints, config$1) => {
|
|
|
2535
868
|
}
|
|
2536
869
|
return await handler(context);
|
|
2537
870
|
} catch (error) {
|
|
2538
|
-
if (config
|
|
2539
|
-
const errorResponse = await config
|
|
871
|
+
if (config?.onError) try {
|
|
872
|
+
const errorResponse = await config.onError(error);
|
|
2540
873
|
if (errorResponse instanceof Response) return toResponse(errorResponse);
|
|
2541
874
|
} catch (error$1) {
|
|
2542
875
|
if (isAPIError(error$1)) return toResponse(error$1);
|
|
2543
876
|
throw error$1;
|
|
2544
877
|
}
|
|
2545
|
-
if (config
|
|
878
|
+
if (config?.throwError) throw error;
|
|
2546
879
|
if (isAPIError(error)) return toResponse(error);
|
|
2547
880
|
console.error(`# SERVER_ERROR: `, error);
|
|
2548
881
|
return new Response(null, {
|
|
@@ -2553,10 +886,10 @@ const createRouter = (endpoints, config$1) => {
|
|
|
2553
886
|
};
|
|
2554
887
|
return {
|
|
2555
888
|
handler: async (request) => {
|
|
2556
|
-
const onReq = await config
|
|
889
|
+
const onReq = await config?.onRequest?.(request);
|
|
2557
890
|
if (onReq instanceof Response) return onReq;
|
|
2558
891
|
const res = await processRequest(onReq instanceof Request ? onReq : request);
|
|
2559
|
-
const onRes = await config
|
|
892
|
+
const onRes = await config?.onResponse?.(res);
|
|
2560
893
|
if (onRes instanceof Response) return onRes;
|
|
2561
894
|
return res;
|
|
2562
895
|
},
|