@wecode-ai/weibo-openclaw-plugin 2.2.3 → 2.2.4
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/node_modules/tar/dist/commonjs/index.min.js +3 -3
- package/node_modules/tar/dist/commonjs/index.min.js.map +3 -3
- package/node_modules/tar/dist/commonjs/pack.d.ts +3 -1
- package/node_modules/tar/dist/commonjs/pack.d.ts.map +1 -1
- package/node_modules/tar/dist/commonjs/pack.js +33 -7
- package/node_modules/tar/dist/commonjs/pack.js.map +1 -1
- package/node_modules/tar/dist/esm/index.min.js +3 -3
- package/node_modules/tar/dist/esm/index.min.js.map +3 -3
- package/node_modules/tar/dist/esm/pack.d.ts +3 -1
- package/node_modules/tar/dist/esm/pack.d.ts.map +1 -1
- package/node_modules/tar/dist/esm/pack.js +33 -7
- package/node_modules/tar/dist/esm/pack.js.map +1 -1
- package/node_modules/tar/package.json +4 -4
- package/node_modules/zod/README.md +1 -18
- package/node_modules/zod/locales/package.json +2 -1
- package/node_modules/zod/mini/package.json +2 -1
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/src/v3/tests/all-errors.test.ts +3 -3
- package/node_modules/zod/src/v3/tests/object.test.ts +5 -5
- package/node_modules/zod/src/v3/tests/partials.test.ts +3 -3
- package/node_modules/zod/src/v4/classic/errors.ts +2 -2
- package/node_modules/zod/src/v4/classic/external.ts +1 -0
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +39 -23
- package/node_modules/zod/src/v4/classic/parse.ts +6 -6
- package/node_modules/zod/src/v4/classic/schemas.ts +414 -151
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +6 -0
- package/node_modules/zod/src/v4/classic/tests/catch.test.ts +50 -0
- package/node_modules/zod/src/v4/classic/tests/codec.test.ts +142 -1
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +1 -1
- package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +1 -1
- package/node_modules/zod/src/v4/classic/tests/default.test.ts +44 -0
- package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +197 -0
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +34 -1
- package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +214 -2
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +161 -0
- package/node_modules/zod/src/v4/classic/tests/function.test.ts +6 -6
- package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +39 -0
- package/node_modules/zod/src/v4/classic/tests/index.test.ts +2 -2
- package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +46 -0
- package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +29 -0
- package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +24 -0
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +55 -0
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +83 -6
- package/node_modules/zod/src/v4/classic/tests/optional.test.ts +114 -4
- package/node_modules/zod/src/v4/classic/tests/partial.test.ts +24 -1
- package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +1 -1
- package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +26 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +69 -0
- package/node_modules/zod/src/v4/classic/tests/record.test.ts +85 -0
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +49 -0
- package/node_modules/zod/src/v4/classic/tests/refine.test.ts +63 -0
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +50 -1
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +4 -4
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +150 -15
- package/node_modules/zod/src/v4/classic/tests/transform.test.ts +17 -0
- package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +315 -2
- package/node_modules/zod/src/v4/classic/tests/union.test.ts +54 -0
- package/node_modules/zod/src/v4/core/api.ts +31 -6
- package/node_modules/zod/src/v4/core/checks.ts +1 -1
- package/node_modules/zod/src/v4/core/core.ts +17 -2
- package/node_modules/zod/src/v4/core/errors.ts +31 -24
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +17 -18
- package/node_modules/zod/src/v4/core/parse.ts +7 -7
- package/node_modules/zod/src/v4/core/regexes.ts +8 -1
- package/node_modules/zod/src/v4/core/schemas.ts +263 -71
- package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +215 -0
- package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +72 -0
- package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
- package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +22 -0
- package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +58 -0
- package/node_modules/zod/src/v4/core/to-json-schema.ts +10 -1
- package/node_modules/zod/src/v4/core/util.ts +52 -35
- package/node_modules/zod/src/v4/core/versions.ts +2 -2
- package/node_modules/zod/src/v4/locales/el.ts +121 -0
- package/node_modules/zod/src/v4/locales/en.ts +4 -0
- package/node_modules/zod/src/v4/locales/fr.ts +24 -8
- package/node_modules/zod/src/v4/locales/hr.ts +131 -0
- package/node_modules/zod/src/v4/locales/index.ts +3 -0
- package/node_modules/zod/src/v4/locales/it.ts +1 -1
- package/node_modules/zod/src/v4/locales/ka.ts +8 -8
- package/node_modules/zod/src/v4/locales/ro.ts +129 -0
- package/node_modules/zod/src/v4/locales/uz.ts +1 -0
- package/node_modules/zod/src/v4/mini/external.ts +1 -0
- package/node_modules/zod/src/v4/mini/schemas.ts +56 -25
- package/node_modules/zod/src/v4/mini/tests/codec.test.ts +19 -0
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +32 -2
- package/node_modules/zod/src/v4/mini/tests/object.test.ts +9 -9
- package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +51 -1
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +5 -0
- package/node_modules/zod/v3/package.json +2 -1
- package/node_modules/zod/v4/classic/errors.js +2 -2
- package/node_modules/zod/v4/classic/external.d.cts +1 -0
- package/node_modules/zod/v4/classic/external.d.ts +1 -0
- package/node_modules/zod/v4/classic/from-json-schema.cjs +31 -16
- package/node_modules/zod/v4/classic/from-json-schema.js +31 -16
- package/node_modules/zod/v4/classic/package.json +2 -1
- package/node_modules/zod/v4/classic/schemas.cjs +358 -119
- package/node_modules/zod/v4/classic/schemas.d.cts +42 -14
- package/node_modules/zod/v4/classic/schemas.d.ts +42 -14
- package/node_modules/zod/v4/classic/schemas.js +356 -118
- package/node_modules/zod/v4/core/api.cjs +7 -2
- package/node_modules/zod/v4/core/api.d.cts +26 -5
- package/node_modules/zod/v4/core/api.d.ts +26 -5
- package/node_modules/zod/v4/core/api.js +7 -2
- package/node_modules/zod/v4/core/checks.d.cts +1 -1
- package/node_modules/zod/v4/core/checks.d.ts +1 -1
- package/node_modules/zod/v4/core/core.cjs +3 -1
- package/node_modules/zod/v4/core/core.js +4 -2
- package/node_modules/zod/v4/core/errors.cjs +26 -23
- package/node_modules/zod/v4/core/errors.d.cts +1 -0
- package/node_modules/zod/v4/core/errors.d.ts +1 -0
- package/node_modules/zod/v4/core/errors.js +26 -23
- package/node_modules/zod/v4/core/json-schema-processors.cjs +16 -20
- package/node_modules/zod/v4/core/json-schema-processors.js +16 -20
- package/node_modules/zod/v4/core/package.json +2 -1
- package/node_modules/zod/v4/core/parse.cjs +7 -7
- package/node_modules/zod/v4/core/parse.js +7 -7
- package/node_modules/zod/v4/core/regexes.cjs +9 -3
- package/node_modules/zod/v4/core/regexes.d.cts +6 -0
- package/node_modules/zod/v4/core/regexes.d.ts +6 -0
- package/node_modules/zod/v4/core/regexes.js +7 -1
- package/node_modules/zod/v4/core/schemas.cjs +211 -65
- package/node_modules/zod/v4/core/schemas.d.cts +39 -1
- package/node_modules/zod/v4/core/schemas.d.ts +39 -1
- package/node_modules/zod/v4/core/schemas.js +210 -64
- package/node_modules/zod/v4/core/to-json-schema.cjs +12 -1
- package/node_modules/zod/v4/core/to-json-schema.js +12 -1
- package/node_modules/zod/v4/core/util.cjs +54 -30
- package/node_modules/zod/v4/core/util.d.cts +1 -0
- package/node_modules/zod/v4/core/util.d.ts +1 -0
- package/node_modules/zod/v4/core/util.js +55 -32
- package/node_modules/zod/v4/core/versions.cjs +2 -2
- package/node_modules/zod/v4/core/versions.d.cts +1 -1
- package/node_modules/zod/v4/core/versions.d.ts +1 -1
- package/node_modules/zod/v4/core/versions.js +2 -2
- package/node_modules/zod/v4/locales/el.cjs +136 -0
- package/node_modules/zod/v4/locales/el.d.cts +5 -0
- package/node_modules/zod/v4/locales/el.d.ts +4 -0
- package/node_modules/zod/v4/locales/el.js +109 -0
- package/node_modules/zod/v4/locales/en.cjs +4 -0
- package/node_modules/zod/v4/locales/en.js +4 -0
- package/node_modules/zod/v4/locales/fr.cjs +24 -7
- package/node_modules/zod/v4/locales/fr.js +24 -7
- package/node_modules/zod/v4/locales/hr.cjs +149 -0
- package/node_modules/zod/v4/locales/hr.d.cts +5 -0
- package/node_modules/zod/v4/locales/hr.d.ts +4 -0
- package/node_modules/zod/v4/locales/hr.js +122 -0
- package/node_modules/zod/v4/locales/index.cjs +8 -1
- package/node_modules/zod/v4/locales/index.d.cts +3 -0
- package/node_modules/zod/v4/locales/index.d.ts +3 -0
- package/node_modules/zod/v4/locales/index.js +3 -0
- package/node_modules/zod/v4/locales/it.cjs +1 -1
- package/node_modules/zod/v4/locales/it.js +1 -1
- package/node_modules/zod/v4/locales/ka.cjs +8 -8
- package/node_modules/zod/v4/locales/ka.js +8 -8
- package/node_modules/zod/v4/locales/package.json +2 -1
- package/node_modules/zod/v4/locales/ro.cjs +146 -0
- package/node_modules/zod/v4/locales/ro.d.cts +5 -0
- package/node_modules/zod/v4/locales/ro.d.ts +4 -0
- package/node_modules/zod/v4/locales/ro.js +119 -0
- package/node_modules/zod/v4/locales/uz.cjs +1 -0
- package/node_modules/zod/v4/locales/uz.js +1 -0
- package/node_modules/zod/v4/mini/external.d.cts +1 -0
- package/node_modules/zod/v4/mini/external.d.ts +1 -0
- package/node_modules/zod/v4/mini/package.json +2 -1
- package/node_modules/zod/v4/mini/schemas.cjs +41 -4
- package/node_modules/zod/v4/mini/schemas.d.cts +28 -10
- package/node_modules/zod/v4/mini/schemas.d.ts +28 -10
- package/node_modules/zod/v4/mini/schemas.js +40 -4
- package/node_modules/zod/v4/package.json +2 -1
- package/node_modules/zod/v4-mini/package.json +2 -1
- package/package.json +2 -1
- package/src/accounts.js +1 -1
- package/src/accounts.js.map +1 -1
- package/src/channel.js +1 -1
- package/src/channel.js.map +1 -1
- package/src/outbound.d.ts.map +1 -1
- package/src/outbound.js +82 -4
- package/src/outbound.js.map +1 -1
- package/src/send.d.ts +23 -0
- package/src/send.d.ts.map +1 -1
- package/src/send.js +54 -2
- package/src/send.js.map +1 -1
- package/src/token.d.ts +8 -0
- package/src/token.d.ts.map +1 -1
- package/src/token.js +16 -1
- package/src/token.js.map +1 -1
|
@@ -5,6 +5,54 @@ import { createStandardJSONSchemaMethod, createToJSONSchemaMethod } from "../cor
|
|
|
5
5
|
import * as checks from "./checks.js";
|
|
6
6
|
import * as iso from "./iso.js";
|
|
7
7
|
import * as parse from "./parse.js";
|
|
8
|
+
// Lazy-bind builder methods.
|
|
9
|
+
//
|
|
10
|
+
// Builder methods (`.optional`, `.array`, `.refine`, ...) live as
|
|
11
|
+
// non-enumerable getters on each concrete schema constructor's
|
|
12
|
+
// prototype. On first access from an instance the getter allocates
|
|
13
|
+
// `fn.bind(this)` and caches it as an own property on that instance,
|
|
14
|
+
// so detached usage (`const m = schema.optional; m()`) still works
|
|
15
|
+
// and the per-instance allocation only happens for methods actually
|
|
16
|
+
// touched.
|
|
17
|
+
//
|
|
18
|
+
// One install per (prototype, group), memoized by `_installedGroups`.
|
|
19
|
+
const _installedGroups = /* @__PURE__ */ new WeakMap();
|
|
20
|
+
function _installLazyMethods(inst, group, methods) {
|
|
21
|
+
const proto = Object.getPrototypeOf(inst);
|
|
22
|
+
let installed = _installedGroups.get(proto);
|
|
23
|
+
if (!installed) {
|
|
24
|
+
installed = new Set();
|
|
25
|
+
_installedGroups.set(proto, installed);
|
|
26
|
+
}
|
|
27
|
+
if (installed.has(group))
|
|
28
|
+
return;
|
|
29
|
+
installed.add(group);
|
|
30
|
+
for (const key in methods) {
|
|
31
|
+
const fn = methods[key];
|
|
32
|
+
Object.defineProperty(proto, key, {
|
|
33
|
+
configurable: true,
|
|
34
|
+
enumerable: false,
|
|
35
|
+
get() {
|
|
36
|
+
const bound = fn.bind(this);
|
|
37
|
+
Object.defineProperty(this, key, {
|
|
38
|
+
configurable: true,
|
|
39
|
+
writable: true,
|
|
40
|
+
enumerable: true,
|
|
41
|
+
value: bound,
|
|
42
|
+
});
|
|
43
|
+
return bound;
|
|
44
|
+
},
|
|
45
|
+
set(v) {
|
|
46
|
+
Object.defineProperty(this, key, {
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
enumerable: true,
|
|
50
|
+
value: v,
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
8
56
|
export const ZodType = /*@__PURE__*/ core.$constructor("ZodType", (inst, def) => {
|
|
9
57
|
core.$ZodType.init(inst, def);
|
|
10
58
|
Object.assign(inst["~standard"], {
|
|
@@ -17,31 +65,16 @@ export const ZodType = /*@__PURE__*/ core.$constructor("ZodType", (inst, def) =>
|
|
|
17
65
|
inst.def = def;
|
|
18
66
|
inst.type = def.type;
|
|
19
67
|
Object.defineProperty(inst, "_def", { value: def });
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
|
|
26
|
-
],
|
|
27
|
-
}), {
|
|
28
|
-
parent: true,
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
inst.with = inst.check;
|
|
32
|
-
inst.clone = (def, params) => core.clone(inst, def, params);
|
|
33
|
-
inst.brand = () => inst;
|
|
34
|
-
inst.register = ((reg, meta) => {
|
|
35
|
-
reg.add(inst, meta);
|
|
36
|
-
return inst;
|
|
37
|
-
});
|
|
38
|
-
// parsing
|
|
68
|
+
// Parse-family is intentionally kept as per-instance closures: these are
|
|
69
|
+
// the hot path AND the most-detached methods (`arr.map(schema.parse)`,
|
|
70
|
+
// `const { parse } = schema`, etc.). Eager closures here mean callers pay
|
|
71
|
+
// ~12 closure allocations per schema but get monomorphic call sites and
|
|
72
|
+
// detached usage that "just works".
|
|
39
73
|
inst.parse = (data, params) => parse.parse(inst, data, params, { callee: inst.parse });
|
|
40
74
|
inst.safeParse = (data, params) => parse.safeParse(inst, data, params);
|
|
41
75
|
inst.parseAsync = async (data, params) => parse.parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
42
76
|
inst.safeParseAsync = async (data, params) => parse.safeParseAsync(inst, data, params);
|
|
43
77
|
inst.spa = inst.safeParseAsync;
|
|
44
|
-
// encoding/decoding
|
|
45
78
|
inst.encode = (data, params) => parse.encode(inst, data, params);
|
|
46
79
|
inst.decode = (data, params) => parse.decode(inst, data, params);
|
|
47
80
|
inst.encodeAsync = async (data, params) => parse.encodeAsync(inst, data, params);
|
|
@@ -50,50 +83,118 @@ export const ZodType = /*@__PURE__*/ core.$constructor("ZodType", (inst, def) =>
|
|
|
50
83
|
inst.safeDecode = (data, params) => parse.safeDecode(inst, data, params);
|
|
51
84
|
inst.safeEncodeAsync = async (data, params) => parse.safeEncodeAsync(inst, data, params);
|
|
52
85
|
inst.safeDecodeAsync = async (data, params) => parse.safeDecodeAsync(inst, data, params);
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
inst
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
// All builder methods are placed on the internal prototype as lazy-bind
|
|
87
|
+
// getters. On first access per-instance, a bound thunk is allocated and
|
|
88
|
+
// cached as an own property; subsequent accesses skip the getter. This
|
|
89
|
+
// means: no per-instance allocation for unused methods, full
|
|
90
|
+
// detachability preserved (`const m = schema.optional; m()` works), and
|
|
91
|
+
// shared underlying function references across all instances.
|
|
92
|
+
_installLazyMethods(inst, "ZodType", {
|
|
93
|
+
check(...chks) {
|
|
94
|
+
const def = this.def;
|
|
95
|
+
return this.clone(util.mergeDefs(def, {
|
|
96
|
+
checks: [
|
|
97
|
+
...(def.checks ?? []),
|
|
98
|
+
...chks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
|
|
99
|
+
],
|
|
100
|
+
}), { parent: true });
|
|
101
|
+
},
|
|
102
|
+
with(...chks) {
|
|
103
|
+
return this.check(...chks);
|
|
104
|
+
},
|
|
105
|
+
clone(def, params) {
|
|
106
|
+
return core.clone(this, def, params);
|
|
107
|
+
},
|
|
108
|
+
brand() {
|
|
109
|
+
return this;
|
|
110
|
+
},
|
|
111
|
+
register(reg, meta) {
|
|
112
|
+
reg.add(this, meta);
|
|
113
|
+
return this;
|
|
114
|
+
},
|
|
115
|
+
refine(check, params) {
|
|
116
|
+
return this.check(refine(check, params));
|
|
117
|
+
},
|
|
118
|
+
superRefine(refinement, params) {
|
|
119
|
+
return this.check(superRefine(refinement, params));
|
|
120
|
+
},
|
|
121
|
+
overwrite(fn) {
|
|
122
|
+
return this.check(checks.overwrite(fn));
|
|
123
|
+
},
|
|
124
|
+
optional() {
|
|
125
|
+
return optional(this);
|
|
126
|
+
},
|
|
127
|
+
exactOptional() {
|
|
128
|
+
return exactOptional(this);
|
|
129
|
+
},
|
|
130
|
+
nullable() {
|
|
131
|
+
return nullable(this);
|
|
132
|
+
},
|
|
133
|
+
nullish() {
|
|
134
|
+
return optional(nullable(this));
|
|
135
|
+
},
|
|
136
|
+
nonoptional(params) {
|
|
137
|
+
return nonoptional(this, params);
|
|
138
|
+
},
|
|
139
|
+
array() {
|
|
140
|
+
return array(this);
|
|
141
|
+
},
|
|
142
|
+
or(arg) {
|
|
143
|
+
return union([this, arg]);
|
|
144
|
+
},
|
|
145
|
+
and(arg) {
|
|
146
|
+
return intersection(this, arg);
|
|
147
|
+
},
|
|
148
|
+
transform(tx) {
|
|
149
|
+
return pipe(this, transform(tx));
|
|
150
|
+
},
|
|
151
|
+
default(d) {
|
|
152
|
+
return _default(this, d);
|
|
153
|
+
},
|
|
154
|
+
prefault(d) {
|
|
155
|
+
return prefault(this, d);
|
|
156
|
+
},
|
|
157
|
+
catch(params) {
|
|
158
|
+
return _catch(this, params);
|
|
159
|
+
},
|
|
160
|
+
pipe(target) {
|
|
161
|
+
return pipe(this, target);
|
|
162
|
+
},
|
|
163
|
+
readonly() {
|
|
164
|
+
return readonly(this);
|
|
165
|
+
},
|
|
166
|
+
describe(description) {
|
|
167
|
+
const cl = this.clone();
|
|
168
|
+
core.globalRegistry.add(cl, { description });
|
|
169
|
+
return cl;
|
|
170
|
+
},
|
|
171
|
+
meta(...args) {
|
|
172
|
+
// overloaded: meta() returns the registered metadata, meta(data)
|
|
173
|
+
// returns a clone with `data` registered. The mapped type picks
|
|
174
|
+
// up the second overload, so we accept variadic any-args and
|
|
175
|
+
// return `any` to satisfy both at runtime.
|
|
176
|
+
if (args.length === 0)
|
|
177
|
+
return core.globalRegistry.get(this);
|
|
178
|
+
const cl = this.clone();
|
|
179
|
+
core.globalRegistry.add(cl, args[0]);
|
|
180
|
+
return cl;
|
|
181
|
+
},
|
|
182
|
+
isOptional() {
|
|
183
|
+
return this.safeParse(undefined).success;
|
|
184
|
+
},
|
|
185
|
+
isNullable() {
|
|
186
|
+
return this.safeParse(null).success;
|
|
187
|
+
},
|
|
188
|
+
apply(fn) {
|
|
189
|
+
return fn(this);
|
|
190
|
+
},
|
|
191
|
+
});
|
|
79
192
|
Object.defineProperty(inst, "description", {
|
|
80
193
|
get() {
|
|
81
194
|
return core.globalRegistry.get(inst)?.description;
|
|
82
195
|
},
|
|
83
196
|
configurable: true,
|
|
84
197
|
});
|
|
85
|
-
inst.meta = (...args) => {
|
|
86
|
-
if (args.length === 0) {
|
|
87
|
-
return core.globalRegistry.get(inst);
|
|
88
|
-
}
|
|
89
|
-
const cl = inst.clone();
|
|
90
|
-
core.globalRegistry.add(cl, args[0]);
|
|
91
|
-
return cl;
|
|
92
|
-
};
|
|
93
|
-
// helpers
|
|
94
|
-
inst.isOptional = () => inst.safeParse(undefined).success;
|
|
95
|
-
inst.isNullable = () => inst.safeParse(null).success;
|
|
96
|
-
inst.apply = (fn) => fn(inst);
|
|
97
198
|
return inst;
|
|
98
199
|
});
|
|
99
200
|
/** @internal */
|
|
@@ -105,23 +206,53 @@ export const _ZodString = /*@__PURE__*/ core.$constructor("_ZodString", (inst, d
|
|
|
105
206
|
inst.format = bag.format ?? null;
|
|
106
207
|
inst.minLength = bag.minimum ?? null;
|
|
107
208
|
inst.maxLength = bag.maximum ?? null;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
209
|
+
_installLazyMethods(inst, "_ZodString", {
|
|
210
|
+
regex(...args) {
|
|
211
|
+
return this.check(checks.regex(...args));
|
|
212
|
+
},
|
|
213
|
+
includes(...args) {
|
|
214
|
+
return this.check(checks.includes(...args));
|
|
215
|
+
},
|
|
216
|
+
startsWith(...args) {
|
|
217
|
+
return this.check(checks.startsWith(...args));
|
|
218
|
+
},
|
|
219
|
+
endsWith(...args) {
|
|
220
|
+
return this.check(checks.endsWith(...args));
|
|
221
|
+
},
|
|
222
|
+
min(...args) {
|
|
223
|
+
return this.check(checks.minLength(...args));
|
|
224
|
+
},
|
|
225
|
+
max(...args) {
|
|
226
|
+
return this.check(checks.maxLength(...args));
|
|
227
|
+
},
|
|
228
|
+
length(...args) {
|
|
229
|
+
return this.check(checks.length(...args));
|
|
230
|
+
},
|
|
231
|
+
nonempty(...args) {
|
|
232
|
+
return this.check(checks.minLength(1, ...args));
|
|
233
|
+
},
|
|
234
|
+
lowercase(params) {
|
|
235
|
+
return this.check(checks.lowercase(params));
|
|
236
|
+
},
|
|
237
|
+
uppercase(params) {
|
|
238
|
+
return this.check(checks.uppercase(params));
|
|
239
|
+
},
|
|
240
|
+
trim() {
|
|
241
|
+
return this.check(checks.trim());
|
|
242
|
+
},
|
|
243
|
+
normalize(...args) {
|
|
244
|
+
return this.check(checks.normalize(...args));
|
|
245
|
+
},
|
|
246
|
+
toLowerCase() {
|
|
247
|
+
return this.check(checks.toLowerCase());
|
|
248
|
+
},
|
|
249
|
+
toUpperCase() {
|
|
250
|
+
return this.check(checks.toUpperCase());
|
|
251
|
+
},
|
|
252
|
+
slugify() {
|
|
253
|
+
return this.check(checks.slugify());
|
|
254
|
+
},
|
|
255
|
+
});
|
|
125
256
|
});
|
|
126
257
|
export const ZodString = /*@__PURE__*/ core.$constructor("ZodString", (inst, def) => {
|
|
127
258
|
core.$ZodString.init(inst, def);
|
|
@@ -207,7 +338,7 @@ export function url(params) {
|
|
|
207
338
|
}
|
|
208
339
|
export function httpUrl(params) {
|
|
209
340
|
return core._url(ZodURL, {
|
|
210
|
-
protocol:
|
|
341
|
+
protocol: core.regexes.httpProtocol,
|
|
211
342
|
hostname: core.regexes.domain,
|
|
212
343
|
...util.normalizeParams(params),
|
|
213
344
|
});
|
|
@@ -228,11 +359,23 @@ export const ZodNanoID = /*@__PURE__*/ core.$constructor("ZodNanoID", (inst, def
|
|
|
228
359
|
export function nanoid(params) {
|
|
229
360
|
return core._nanoid(ZodNanoID, params);
|
|
230
361
|
}
|
|
362
|
+
/**
|
|
363
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
364
|
+
* (timestamps embedded in the id). Use {@link ZodCUID2} instead.
|
|
365
|
+
* See https://github.com/paralleldrive/cuid.
|
|
366
|
+
*/
|
|
231
367
|
export const ZodCUID = /*@__PURE__*/ core.$constructor("ZodCUID", (inst, def) => {
|
|
232
368
|
// ZodStringFormat.init(inst, def);
|
|
233
369
|
core.$ZodCUID.init(inst, def);
|
|
234
370
|
ZodStringFormat.init(inst, def);
|
|
235
371
|
});
|
|
372
|
+
/**
|
|
373
|
+
* Validates a CUID v1 string.
|
|
374
|
+
*
|
|
375
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
376
|
+
* (timestamps embedded in the id). Use {@link cuid2 | `z.cuid2()`} instead.
|
|
377
|
+
* See https://github.com/paralleldrive/cuid.
|
|
378
|
+
*/
|
|
236
379
|
export function cuid(params) {
|
|
237
380
|
return core._cuid(ZodCUID, params);
|
|
238
381
|
}
|
|
@@ -364,22 +507,53 @@ export const ZodNumber = /*@__PURE__*/ core.$constructor("ZodNumber", (inst, def
|
|
|
364
507
|
core.$ZodNumber.init(inst, def);
|
|
365
508
|
ZodType.init(inst, def);
|
|
366
509
|
inst._zod.processJSONSchema = (ctx, json, params) => processors.numberProcessor(inst, ctx, json, params);
|
|
367
|
-
inst
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
510
|
+
_installLazyMethods(inst, "ZodNumber", {
|
|
511
|
+
gt(value, params) {
|
|
512
|
+
return this.check(checks.gt(value, params));
|
|
513
|
+
},
|
|
514
|
+
gte(value, params) {
|
|
515
|
+
return this.check(checks.gte(value, params));
|
|
516
|
+
},
|
|
517
|
+
min(value, params) {
|
|
518
|
+
return this.check(checks.gte(value, params));
|
|
519
|
+
},
|
|
520
|
+
lt(value, params) {
|
|
521
|
+
return this.check(checks.lt(value, params));
|
|
522
|
+
},
|
|
523
|
+
lte(value, params) {
|
|
524
|
+
return this.check(checks.lte(value, params));
|
|
525
|
+
},
|
|
526
|
+
max(value, params) {
|
|
527
|
+
return this.check(checks.lte(value, params));
|
|
528
|
+
},
|
|
529
|
+
int(params) {
|
|
530
|
+
return this.check(int(params));
|
|
531
|
+
},
|
|
532
|
+
safe(params) {
|
|
533
|
+
return this.check(int(params));
|
|
534
|
+
},
|
|
535
|
+
positive(params) {
|
|
536
|
+
return this.check(checks.gt(0, params));
|
|
537
|
+
},
|
|
538
|
+
nonnegative(params) {
|
|
539
|
+
return this.check(checks.gte(0, params));
|
|
540
|
+
},
|
|
541
|
+
negative(params) {
|
|
542
|
+
return this.check(checks.lt(0, params));
|
|
543
|
+
},
|
|
544
|
+
nonpositive(params) {
|
|
545
|
+
return this.check(checks.lte(0, params));
|
|
546
|
+
},
|
|
547
|
+
multipleOf(value, params) {
|
|
548
|
+
return this.check(checks.multipleOf(value, params));
|
|
549
|
+
},
|
|
550
|
+
step(value, params) {
|
|
551
|
+
return this.check(checks.multipleOf(value, params));
|
|
552
|
+
},
|
|
553
|
+
finite() {
|
|
554
|
+
return this;
|
|
555
|
+
},
|
|
556
|
+
});
|
|
383
557
|
const bag = inst._zod.bag;
|
|
384
558
|
inst.minValue =
|
|
385
559
|
Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
@@ -533,11 +707,23 @@ export const ZodArray = /*@__PURE__*/ core.$constructor("ZodArray", (inst, def)
|
|
|
533
707
|
ZodType.init(inst, def);
|
|
534
708
|
inst._zod.processJSONSchema = (ctx, json, params) => processors.arrayProcessor(inst, ctx, json, params);
|
|
535
709
|
inst.element = def.element;
|
|
536
|
-
inst
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
710
|
+
_installLazyMethods(inst, "ZodArray", {
|
|
711
|
+
min(n, params) {
|
|
712
|
+
return this.check(checks.minLength(n, params));
|
|
713
|
+
},
|
|
714
|
+
nonempty(params) {
|
|
715
|
+
return this.check(checks.minLength(1, params));
|
|
716
|
+
},
|
|
717
|
+
max(n, params) {
|
|
718
|
+
return this.check(checks.maxLength(n, params));
|
|
719
|
+
},
|
|
720
|
+
length(n, params) {
|
|
721
|
+
return this.check(checks.length(n, params));
|
|
722
|
+
},
|
|
723
|
+
unwrap() {
|
|
724
|
+
return this.element;
|
|
725
|
+
},
|
|
726
|
+
});
|
|
541
727
|
});
|
|
542
728
|
export function array(element, params) {
|
|
543
729
|
return core._array(ZodArray, element, params);
|
|
@@ -554,23 +740,47 @@ export const ZodObject = /*@__PURE__*/ core.$constructor("ZodObject", (inst, def
|
|
|
554
740
|
util.defineLazy(inst, "shape", () => {
|
|
555
741
|
return def.shape;
|
|
556
742
|
});
|
|
557
|
-
inst
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
743
|
+
_installLazyMethods(inst, "ZodObject", {
|
|
744
|
+
keyof() {
|
|
745
|
+
return _enum(Object.keys(this._zod.def.shape));
|
|
746
|
+
},
|
|
747
|
+
catchall(catchall) {
|
|
748
|
+
return this.clone({ ...this._zod.def, catchall: catchall });
|
|
749
|
+
},
|
|
750
|
+
passthrough() {
|
|
751
|
+
return this.clone({ ...this._zod.def, catchall: unknown() });
|
|
752
|
+
},
|
|
753
|
+
loose() {
|
|
754
|
+
return this.clone({ ...this._zod.def, catchall: unknown() });
|
|
755
|
+
},
|
|
756
|
+
strict() {
|
|
757
|
+
return this.clone({ ...this._zod.def, catchall: never() });
|
|
758
|
+
},
|
|
759
|
+
strip() {
|
|
760
|
+
return this.clone({ ...this._zod.def, catchall: undefined });
|
|
761
|
+
},
|
|
762
|
+
extend(incoming) {
|
|
763
|
+
return util.extend(this, incoming);
|
|
764
|
+
},
|
|
765
|
+
safeExtend(incoming) {
|
|
766
|
+
return util.safeExtend(this, incoming);
|
|
767
|
+
},
|
|
768
|
+
merge(other) {
|
|
769
|
+
return util.merge(this, other);
|
|
770
|
+
},
|
|
771
|
+
pick(mask) {
|
|
772
|
+
return util.pick(this, mask);
|
|
773
|
+
},
|
|
774
|
+
omit(mask) {
|
|
775
|
+
return util.omit(this, mask);
|
|
776
|
+
},
|
|
777
|
+
partial(...args) {
|
|
778
|
+
return util.partial(ZodOptional, this, args[0]);
|
|
779
|
+
},
|
|
780
|
+
required(...args) {
|
|
781
|
+
return util.required(ZodNonOptional, this, args[0]);
|
|
782
|
+
},
|
|
783
|
+
});
|
|
574
784
|
});
|
|
575
785
|
export function object(shape, params) {
|
|
576
786
|
const def = {
|
|
@@ -681,6 +891,15 @@ export const ZodRecord = /*@__PURE__*/ core.$constructor("ZodRecord", (inst, def
|
|
|
681
891
|
inst.valueType = def.valueType;
|
|
682
892
|
});
|
|
683
893
|
export function record(keyType, valueType, params) {
|
|
894
|
+
// v3-compat: z.record(valueType, params?) — defaults keyType to z.string()
|
|
895
|
+
if (!valueType || !valueType._zod) {
|
|
896
|
+
return new ZodRecord({
|
|
897
|
+
type: "record",
|
|
898
|
+
keyType: string(),
|
|
899
|
+
valueType: keyType,
|
|
900
|
+
...util.normalizeParams(valueType),
|
|
901
|
+
});
|
|
902
|
+
}
|
|
684
903
|
return new ZodRecord({
|
|
685
904
|
type: "record",
|
|
686
905
|
keyType,
|
|
@@ -866,10 +1085,12 @@ export const ZodTransform = /*@__PURE__*/ core.$constructor("ZodTransform", (ins
|
|
|
866
1085
|
if (output instanceof Promise) {
|
|
867
1086
|
return output.then((output) => {
|
|
868
1087
|
payload.value = output;
|
|
1088
|
+
payload.fallback = true;
|
|
869
1089
|
return payload;
|
|
870
1090
|
});
|
|
871
1091
|
}
|
|
872
1092
|
payload.value = output;
|
|
1093
|
+
payload.fallback = true;
|
|
873
1094
|
return payload;
|
|
874
1095
|
};
|
|
875
1096
|
});
|
|
@@ -1026,6 +1247,20 @@ export function codec(in_, out, params) {
|
|
|
1026
1247
|
reverseTransform: params.encode,
|
|
1027
1248
|
});
|
|
1028
1249
|
}
|
|
1250
|
+
export function invertCodec(codec) {
|
|
1251
|
+
const def = codec._zod.def;
|
|
1252
|
+
return new ZodCodec({
|
|
1253
|
+
type: "pipe",
|
|
1254
|
+
in: def.out,
|
|
1255
|
+
out: def.in,
|
|
1256
|
+
transform: def.reverseTransform,
|
|
1257
|
+
reverseTransform: def.transform,
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
export const ZodPreprocess = /*@__PURE__*/ core.$constructor("ZodPreprocess", (inst, def) => {
|
|
1261
|
+
ZodPipe.init(inst, def);
|
|
1262
|
+
core.$ZodPreprocess.init(inst, def);
|
|
1263
|
+
});
|
|
1029
1264
|
export const ZodReadonly = /*@__PURE__*/ core.$constructor("ZodReadonly", (inst, def) => {
|
|
1030
1265
|
core.$ZodReadonly.init(inst, def);
|
|
1031
1266
|
ZodType.init(inst, def);
|
|
@@ -1108,8 +1343,8 @@ export function refine(fn, _params = {}) {
|
|
|
1108
1343
|
return core._refine(ZodCustom, fn, _params);
|
|
1109
1344
|
}
|
|
1110
1345
|
// superRefine
|
|
1111
|
-
export function superRefine(fn) {
|
|
1112
|
-
return core._superRefine(fn);
|
|
1346
|
+
export function superRefine(fn, params) {
|
|
1347
|
+
return core._superRefine(fn, params);
|
|
1113
1348
|
}
|
|
1114
1349
|
// Re-export describe and meta from core
|
|
1115
1350
|
export const describe = core.describe;
|
|
@@ -1151,7 +1386,10 @@ export function json(params) {
|
|
|
1151
1386
|
return jsonSchema;
|
|
1152
1387
|
}
|
|
1153
1388
|
// preprocess
|
|
1154
|
-
// /** @deprecated Use `z.pipe()` and `z.transform()` instead. */
|
|
1155
1389
|
export function preprocess(fn, schema) {
|
|
1156
|
-
return
|
|
1390
|
+
return new ZodPreprocess({
|
|
1391
|
+
type: "pipe",
|
|
1392
|
+
in: transform(fn),
|
|
1393
|
+
out: schema,
|
|
1394
|
+
});
|
|
1157
1395
|
}
|
|
@@ -256,6 +256,11 @@ function _nanoid(Class, params) {
|
|
|
256
256
|
...util.normalizeParams(params),
|
|
257
257
|
});
|
|
258
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
261
|
+
* (timestamps embedded in the id). Use {@link _cuid2} instead.
|
|
262
|
+
* See https://github.com/paralleldrive/cuid.
|
|
263
|
+
*/
|
|
259
264
|
// @__NO_SIDE_EFFECTS__
|
|
260
265
|
function _cuid(Class, params) {
|
|
261
266
|
return new Class({
|
|
@@ -1094,7 +1099,7 @@ function _refine(Class, fn, _params) {
|
|
|
1094
1099
|
return schema;
|
|
1095
1100
|
}
|
|
1096
1101
|
// @__NO_SIDE_EFFECTS__
|
|
1097
|
-
function _superRefine(fn) {
|
|
1102
|
+
function _superRefine(fn, params) {
|
|
1098
1103
|
const ch = _check((payload) => {
|
|
1099
1104
|
payload.addIssue = (issue) => {
|
|
1100
1105
|
if (typeof issue === "string") {
|
|
@@ -1113,7 +1118,7 @@ function _superRefine(fn) {
|
|
|
1113
1118
|
}
|
|
1114
1119
|
};
|
|
1115
1120
|
return fn(payload.value, payload);
|
|
1116
|
-
});
|
|
1121
|
+
}, params);
|
|
1117
1122
|
return ch;
|
|
1118
1123
|
}
|
|
1119
1124
|
// @__NO_SIDE_EFFECTS__
|