@wecode-ai/weibo-openclaw-plugin 2.2.2 → 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/skills/manifest.json +1 -1
- package/skills/weibo-crowd/SKILL.md +127 -11
- package/skills/weibo-crowd/references/SILICON-TEAHOUSE-RULES.md +6 -19
- package/skills/weibo-crowd/scripts/weibo-crowd.js +90 -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
|
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.ZodLiteral = exports.ZodEnum = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodXor = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodDate = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodBigIntFormat = exports.ZodBigInt = exports.ZodBoolean = exports.ZodNumberFormat = exports.ZodNumber = exports.ZodCustomStringFormat = exports.ZodJWT = exports.ZodE164 = exports.ZodBase64URL = exports.ZodBase64 = exports.ZodCIDRv6 = exports.ZodCIDRv4 = exports.ZodIPv6 = exports.ZodMAC = exports.ZodIPv4 = exports.ZodKSUID = exports.ZodXID = exports.ZodULID = exports.ZodCUID2 = exports.ZodCUID = exports.ZodNanoID = exports.ZodEmoji = exports.ZodURL = exports.ZodUUID = exports.ZodGUID = exports.ZodEmail = exports.ZodStringFormat = exports.ZodString = exports._ZodString = exports.ZodType = void 0;
|
|
27
|
-
exports.stringbool = exports.meta = exports.describe = exports.ZodCustom = exports.ZodFunction = exports.ZodPromise = exports.ZodLazy = exports.ZodTemplateLiteral = exports.ZodReadonly = exports.ZodCodec = exports.ZodPipe = exports.ZodNaN = exports.ZodCatch = exports.ZodSuccess = exports.ZodNonOptional = exports.ZodPrefault = exports.ZodDefault = exports.ZodNullable = exports.ZodExactOptional = exports.ZodOptional = exports.ZodTransform = exports.ZodFile = void 0;
|
|
27
|
+
exports.stringbool = exports.meta = exports.describe = exports.ZodCustom = exports.ZodFunction = exports.ZodPromise = exports.ZodLazy = exports.ZodTemplateLiteral = exports.ZodReadonly = exports.ZodPreprocess = exports.ZodCodec = exports.ZodPipe = exports.ZodNaN = exports.ZodCatch = exports.ZodSuccess = exports.ZodNonOptional = exports.ZodPrefault = exports.ZodDefault = exports.ZodNullable = exports.ZodExactOptional = exports.ZodOptional = exports.ZodTransform = exports.ZodFile = void 0;
|
|
28
28
|
exports.string = string;
|
|
29
29
|
exports.email = email;
|
|
30
30
|
exports.guid = guid;
|
|
@@ -104,6 +104,7 @@ exports.catch = _catch;
|
|
|
104
104
|
exports.nan = nan;
|
|
105
105
|
exports.pipe = pipe;
|
|
106
106
|
exports.codec = codec;
|
|
107
|
+
exports.invertCodec = invertCodec;
|
|
107
108
|
exports.readonly = readonly;
|
|
108
109
|
exports.templateLiteral = templateLiteral;
|
|
109
110
|
exports.lazy = lazy;
|
|
@@ -126,6 +127,54 @@ const to_json_schema_js_1 = require("../core/to-json-schema.cjs");
|
|
|
126
127
|
const checks = __importStar(require("./checks.cjs"));
|
|
127
128
|
const iso = __importStar(require("./iso.cjs"));
|
|
128
129
|
const parse = __importStar(require("./parse.cjs"));
|
|
130
|
+
// Lazy-bind builder methods.
|
|
131
|
+
//
|
|
132
|
+
// Builder methods (`.optional`, `.array`, `.refine`, ...) live as
|
|
133
|
+
// non-enumerable getters on each concrete schema constructor's
|
|
134
|
+
// prototype. On first access from an instance the getter allocates
|
|
135
|
+
// `fn.bind(this)` and caches it as an own property on that instance,
|
|
136
|
+
// so detached usage (`const m = schema.optional; m()`) still works
|
|
137
|
+
// and the per-instance allocation only happens for methods actually
|
|
138
|
+
// touched.
|
|
139
|
+
//
|
|
140
|
+
// One install per (prototype, group), memoized by `_installedGroups`.
|
|
141
|
+
const _installedGroups = /* @__PURE__ */ new WeakMap();
|
|
142
|
+
function _installLazyMethods(inst, group, methods) {
|
|
143
|
+
const proto = Object.getPrototypeOf(inst);
|
|
144
|
+
let installed = _installedGroups.get(proto);
|
|
145
|
+
if (!installed) {
|
|
146
|
+
installed = new Set();
|
|
147
|
+
_installedGroups.set(proto, installed);
|
|
148
|
+
}
|
|
149
|
+
if (installed.has(group))
|
|
150
|
+
return;
|
|
151
|
+
installed.add(group);
|
|
152
|
+
for (const key in methods) {
|
|
153
|
+
const fn = methods[key];
|
|
154
|
+
Object.defineProperty(proto, key, {
|
|
155
|
+
configurable: true,
|
|
156
|
+
enumerable: false,
|
|
157
|
+
get() {
|
|
158
|
+
const bound = fn.bind(this);
|
|
159
|
+
Object.defineProperty(this, key, {
|
|
160
|
+
configurable: true,
|
|
161
|
+
writable: true,
|
|
162
|
+
enumerable: true,
|
|
163
|
+
value: bound,
|
|
164
|
+
});
|
|
165
|
+
return bound;
|
|
166
|
+
},
|
|
167
|
+
set(v) {
|
|
168
|
+
Object.defineProperty(this, key, {
|
|
169
|
+
configurable: true,
|
|
170
|
+
writable: true,
|
|
171
|
+
enumerable: true,
|
|
172
|
+
value: v,
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
129
178
|
exports.ZodType = core.$constructor("ZodType", (inst, def) => {
|
|
130
179
|
core.$ZodType.init(inst, def);
|
|
131
180
|
Object.assign(inst["~standard"], {
|
|
@@ -138,31 +187,16 @@ exports.ZodType = core.$constructor("ZodType", (inst, def) => {
|
|
|
138
187
|
inst.def = def;
|
|
139
188
|
inst.type = def.type;
|
|
140
189
|
Object.defineProperty(inst, "_def", { value: def });
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
|
|
147
|
-
],
|
|
148
|
-
}), {
|
|
149
|
-
parent: true,
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
inst.with = inst.check;
|
|
153
|
-
inst.clone = (def, params) => core.clone(inst, def, params);
|
|
154
|
-
inst.brand = () => inst;
|
|
155
|
-
inst.register = ((reg, meta) => {
|
|
156
|
-
reg.add(inst, meta);
|
|
157
|
-
return inst;
|
|
158
|
-
});
|
|
159
|
-
// parsing
|
|
190
|
+
// Parse-family is intentionally kept as per-instance closures: these are
|
|
191
|
+
// the hot path AND the most-detached methods (`arr.map(schema.parse)`,
|
|
192
|
+
// `const { parse } = schema`, etc.). Eager closures here mean callers pay
|
|
193
|
+
// ~12 closure allocations per schema but get monomorphic call sites and
|
|
194
|
+
// detached usage that "just works".
|
|
160
195
|
inst.parse = (data, params) => parse.parse(inst, data, params, { callee: inst.parse });
|
|
161
196
|
inst.safeParse = (data, params) => parse.safeParse(inst, data, params);
|
|
162
197
|
inst.parseAsync = async (data, params) => parse.parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
163
198
|
inst.safeParseAsync = async (data, params) => parse.safeParseAsync(inst, data, params);
|
|
164
199
|
inst.spa = inst.safeParseAsync;
|
|
165
|
-
// encoding/decoding
|
|
166
200
|
inst.encode = (data, params) => parse.encode(inst, data, params);
|
|
167
201
|
inst.decode = (data, params) => parse.decode(inst, data, params);
|
|
168
202
|
inst.encodeAsync = async (data, params) => parse.encodeAsync(inst, data, params);
|
|
@@ -171,50 +205,118 @@ exports.ZodType = core.$constructor("ZodType", (inst, def) => {
|
|
|
171
205
|
inst.safeDecode = (data, params) => parse.safeDecode(inst, data, params);
|
|
172
206
|
inst.safeEncodeAsync = async (data, params) => parse.safeEncodeAsync(inst, data, params);
|
|
173
207
|
inst.safeDecodeAsync = async (data, params) => parse.safeDecodeAsync(inst, data, params);
|
|
174
|
-
//
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
//
|
|
179
|
-
|
|
180
|
-
inst
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
208
|
+
// All builder methods are placed on the internal prototype as lazy-bind
|
|
209
|
+
// getters. On first access per-instance, a bound thunk is allocated and
|
|
210
|
+
// cached as an own property; subsequent accesses skip the getter. This
|
|
211
|
+
// means: no per-instance allocation for unused methods, full
|
|
212
|
+
// detachability preserved (`const m = schema.optional; m()` works), and
|
|
213
|
+
// shared underlying function references across all instances.
|
|
214
|
+
_installLazyMethods(inst, "ZodType", {
|
|
215
|
+
check(...chks) {
|
|
216
|
+
const def = this.def;
|
|
217
|
+
return this.clone(index_js_1.util.mergeDefs(def, {
|
|
218
|
+
checks: [
|
|
219
|
+
...(def.checks ?? []),
|
|
220
|
+
...chks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
|
|
221
|
+
],
|
|
222
|
+
}), { parent: true });
|
|
223
|
+
},
|
|
224
|
+
with(...chks) {
|
|
225
|
+
return this.check(...chks);
|
|
226
|
+
},
|
|
227
|
+
clone(def, params) {
|
|
228
|
+
return core.clone(this, def, params);
|
|
229
|
+
},
|
|
230
|
+
brand() {
|
|
231
|
+
return this;
|
|
232
|
+
},
|
|
233
|
+
register(reg, meta) {
|
|
234
|
+
reg.add(this, meta);
|
|
235
|
+
return this;
|
|
236
|
+
},
|
|
237
|
+
refine(check, params) {
|
|
238
|
+
return this.check(refine(check, params));
|
|
239
|
+
},
|
|
240
|
+
superRefine(refinement, params) {
|
|
241
|
+
return this.check(superRefine(refinement, params));
|
|
242
|
+
},
|
|
243
|
+
overwrite(fn) {
|
|
244
|
+
return this.check(checks.overwrite(fn));
|
|
245
|
+
},
|
|
246
|
+
optional() {
|
|
247
|
+
return optional(this);
|
|
248
|
+
},
|
|
249
|
+
exactOptional() {
|
|
250
|
+
return exactOptional(this);
|
|
251
|
+
},
|
|
252
|
+
nullable() {
|
|
253
|
+
return nullable(this);
|
|
254
|
+
},
|
|
255
|
+
nullish() {
|
|
256
|
+
return optional(nullable(this));
|
|
257
|
+
},
|
|
258
|
+
nonoptional(params) {
|
|
259
|
+
return nonoptional(this, params);
|
|
260
|
+
},
|
|
261
|
+
array() {
|
|
262
|
+
return array(this);
|
|
263
|
+
},
|
|
264
|
+
or(arg) {
|
|
265
|
+
return union([this, arg]);
|
|
266
|
+
},
|
|
267
|
+
and(arg) {
|
|
268
|
+
return intersection(this, arg);
|
|
269
|
+
},
|
|
270
|
+
transform(tx) {
|
|
271
|
+
return pipe(this, transform(tx));
|
|
272
|
+
},
|
|
273
|
+
default(d) {
|
|
274
|
+
return _default(this, d);
|
|
275
|
+
},
|
|
276
|
+
prefault(d) {
|
|
277
|
+
return prefault(this, d);
|
|
278
|
+
},
|
|
279
|
+
catch(params) {
|
|
280
|
+
return _catch(this, params);
|
|
281
|
+
},
|
|
282
|
+
pipe(target) {
|
|
283
|
+
return pipe(this, target);
|
|
284
|
+
},
|
|
285
|
+
readonly() {
|
|
286
|
+
return readonly(this);
|
|
287
|
+
},
|
|
288
|
+
describe(description) {
|
|
289
|
+
const cl = this.clone();
|
|
290
|
+
core.globalRegistry.add(cl, { description });
|
|
291
|
+
return cl;
|
|
292
|
+
},
|
|
293
|
+
meta(...args) {
|
|
294
|
+
// overloaded: meta() returns the registered metadata, meta(data)
|
|
295
|
+
// returns a clone with `data` registered. The mapped type picks
|
|
296
|
+
// up the second overload, so we accept variadic any-args and
|
|
297
|
+
// return `any` to satisfy both at runtime.
|
|
298
|
+
if (args.length === 0)
|
|
299
|
+
return core.globalRegistry.get(this);
|
|
300
|
+
const cl = this.clone();
|
|
301
|
+
core.globalRegistry.add(cl, args[0]);
|
|
302
|
+
return cl;
|
|
303
|
+
},
|
|
304
|
+
isOptional() {
|
|
305
|
+
return this.safeParse(undefined).success;
|
|
306
|
+
},
|
|
307
|
+
isNullable() {
|
|
308
|
+
return this.safeParse(null).success;
|
|
309
|
+
},
|
|
310
|
+
apply(fn) {
|
|
311
|
+
return fn(this);
|
|
312
|
+
},
|
|
313
|
+
});
|
|
200
314
|
Object.defineProperty(inst, "description", {
|
|
201
315
|
get() {
|
|
202
316
|
return core.globalRegistry.get(inst)?.description;
|
|
203
317
|
},
|
|
204
318
|
configurable: true,
|
|
205
319
|
});
|
|
206
|
-
inst.meta = (...args) => {
|
|
207
|
-
if (args.length === 0) {
|
|
208
|
-
return core.globalRegistry.get(inst);
|
|
209
|
-
}
|
|
210
|
-
const cl = inst.clone();
|
|
211
|
-
core.globalRegistry.add(cl, args[0]);
|
|
212
|
-
return cl;
|
|
213
|
-
};
|
|
214
|
-
// helpers
|
|
215
|
-
inst.isOptional = () => inst.safeParse(undefined).success;
|
|
216
|
-
inst.isNullable = () => inst.safeParse(null).success;
|
|
217
|
-
inst.apply = (fn) => fn(inst);
|
|
218
320
|
return inst;
|
|
219
321
|
});
|
|
220
322
|
/** @internal */
|
|
@@ -226,23 +328,53 @@ exports._ZodString = core.$constructor("_ZodString", (inst, def) => {
|
|
|
226
328
|
inst.format = bag.format ?? null;
|
|
227
329
|
inst.minLength = bag.minimum ?? null;
|
|
228
330
|
inst.maxLength = bag.maximum ?? null;
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
331
|
+
_installLazyMethods(inst, "_ZodString", {
|
|
332
|
+
regex(...args) {
|
|
333
|
+
return this.check(checks.regex(...args));
|
|
334
|
+
},
|
|
335
|
+
includes(...args) {
|
|
336
|
+
return this.check(checks.includes(...args));
|
|
337
|
+
},
|
|
338
|
+
startsWith(...args) {
|
|
339
|
+
return this.check(checks.startsWith(...args));
|
|
340
|
+
},
|
|
341
|
+
endsWith(...args) {
|
|
342
|
+
return this.check(checks.endsWith(...args));
|
|
343
|
+
},
|
|
344
|
+
min(...args) {
|
|
345
|
+
return this.check(checks.minLength(...args));
|
|
346
|
+
},
|
|
347
|
+
max(...args) {
|
|
348
|
+
return this.check(checks.maxLength(...args));
|
|
349
|
+
},
|
|
350
|
+
length(...args) {
|
|
351
|
+
return this.check(checks.length(...args));
|
|
352
|
+
},
|
|
353
|
+
nonempty(...args) {
|
|
354
|
+
return this.check(checks.minLength(1, ...args));
|
|
355
|
+
},
|
|
356
|
+
lowercase(params) {
|
|
357
|
+
return this.check(checks.lowercase(params));
|
|
358
|
+
},
|
|
359
|
+
uppercase(params) {
|
|
360
|
+
return this.check(checks.uppercase(params));
|
|
361
|
+
},
|
|
362
|
+
trim() {
|
|
363
|
+
return this.check(checks.trim());
|
|
364
|
+
},
|
|
365
|
+
normalize(...args) {
|
|
366
|
+
return this.check(checks.normalize(...args));
|
|
367
|
+
},
|
|
368
|
+
toLowerCase() {
|
|
369
|
+
return this.check(checks.toLowerCase());
|
|
370
|
+
},
|
|
371
|
+
toUpperCase() {
|
|
372
|
+
return this.check(checks.toUpperCase());
|
|
373
|
+
},
|
|
374
|
+
slugify() {
|
|
375
|
+
return this.check(checks.slugify());
|
|
376
|
+
},
|
|
377
|
+
});
|
|
246
378
|
});
|
|
247
379
|
exports.ZodString = core.$constructor("ZodString", (inst, def) => {
|
|
248
380
|
core.$ZodString.init(inst, def);
|
|
@@ -328,7 +460,7 @@ function url(params) {
|
|
|
328
460
|
}
|
|
329
461
|
function httpUrl(params) {
|
|
330
462
|
return core._url(exports.ZodURL, {
|
|
331
|
-
protocol:
|
|
463
|
+
protocol: core.regexes.httpProtocol,
|
|
332
464
|
hostname: core.regexes.domain,
|
|
333
465
|
...index_js_1.util.normalizeParams(params),
|
|
334
466
|
});
|
|
@@ -349,11 +481,23 @@ exports.ZodNanoID = core.$constructor("ZodNanoID", (inst, def) => {
|
|
|
349
481
|
function nanoid(params) {
|
|
350
482
|
return core._nanoid(exports.ZodNanoID, params);
|
|
351
483
|
}
|
|
484
|
+
/**
|
|
485
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
486
|
+
* (timestamps embedded in the id). Use {@link ZodCUID2} instead.
|
|
487
|
+
* See https://github.com/paralleldrive/cuid.
|
|
488
|
+
*/
|
|
352
489
|
exports.ZodCUID = core.$constructor("ZodCUID", (inst, def) => {
|
|
353
490
|
// ZodStringFormat.init(inst, def);
|
|
354
491
|
core.$ZodCUID.init(inst, def);
|
|
355
492
|
exports.ZodStringFormat.init(inst, def);
|
|
356
493
|
});
|
|
494
|
+
/**
|
|
495
|
+
* Validates a CUID v1 string.
|
|
496
|
+
*
|
|
497
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
498
|
+
* (timestamps embedded in the id). Use {@link cuid2 | `z.cuid2()`} instead.
|
|
499
|
+
* See https://github.com/paralleldrive/cuid.
|
|
500
|
+
*/
|
|
357
501
|
function cuid(params) {
|
|
358
502
|
return core._cuid(exports.ZodCUID, params);
|
|
359
503
|
}
|
|
@@ -485,22 +629,53 @@ exports.ZodNumber = core.$constructor("ZodNumber", (inst, def) => {
|
|
|
485
629
|
core.$ZodNumber.init(inst, def);
|
|
486
630
|
exports.ZodType.init(inst, def);
|
|
487
631
|
inst._zod.processJSONSchema = (ctx, json, params) => processors.numberProcessor(inst, ctx, json, params);
|
|
488
|
-
inst
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
632
|
+
_installLazyMethods(inst, "ZodNumber", {
|
|
633
|
+
gt(value, params) {
|
|
634
|
+
return this.check(checks.gt(value, params));
|
|
635
|
+
},
|
|
636
|
+
gte(value, params) {
|
|
637
|
+
return this.check(checks.gte(value, params));
|
|
638
|
+
},
|
|
639
|
+
min(value, params) {
|
|
640
|
+
return this.check(checks.gte(value, params));
|
|
641
|
+
},
|
|
642
|
+
lt(value, params) {
|
|
643
|
+
return this.check(checks.lt(value, params));
|
|
644
|
+
},
|
|
645
|
+
lte(value, params) {
|
|
646
|
+
return this.check(checks.lte(value, params));
|
|
647
|
+
},
|
|
648
|
+
max(value, params) {
|
|
649
|
+
return this.check(checks.lte(value, params));
|
|
650
|
+
},
|
|
651
|
+
int(params) {
|
|
652
|
+
return this.check(int(params));
|
|
653
|
+
},
|
|
654
|
+
safe(params) {
|
|
655
|
+
return this.check(int(params));
|
|
656
|
+
},
|
|
657
|
+
positive(params) {
|
|
658
|
+
return this.check(checks.gt(0, params));
|
|
659
|
+
},
|
|
660
|
+
nonnegative(params) {
|
|
661
|
+
return this.check(checks.gte(0, params));
|
|
662
|
+
},
|
|
663
|
+
negative(params) {
|
|
664
|
+
return this.check(checks.lt(0, params));
|
|
665
|
+
},
|
|
666
|
+
nonpositive(params) {
|
|
667
|
+
return this.check(checks.lte(0, params));
|
|
668
|
+
},
|
|
669
|
+
multipleOf(value, params) {
|
|
670
|
+
return this.check(checks.multipleOf(value, params));
|
|
671
|
+
},
|
|
672
|
+
step(value, params) {
|
|
673
|
+
return this.check(checks.multipleOf(value, params));
|
|
674
|
+
},
|
|
675
|
+
finite() {
|
|
676
|
+
return this;
|
|
677
|
+
},
|
|
678
|
+
});
|
|
504
679
|
const bag = inst._zod.bag;
|
|
505
680
|
inst.minValue =
|
|
506
681
|
Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
@@ -651,11 +826,23 @@ exports.ZodArray = core.$constructor("ZodArray", (inst, def) => {
|
|
|
651
826
|
exports.ZodType.init(inst, def);
|
|
652
827
|
inst._zod.processJSONSchema = (ctx, json, params) => processors.arrayProcessor(inst, ctx, json, params);
|
|
653
828
|
inst.element = def.element;
|
|
654
|
-
inst
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
829
|
+
_installLazyMethods(inst, "ZodArray", {
|
|
830
|
+
min(n, params) {
|
|
831
|
+
return this.check(checks.minLength(n, params));
|
|
832
|
+
},
|
|
833
|
+
nonempty(params) {
|
|
834
|
+
return this.check(checks.minLength(1, params));
|
|
835
|
+
},
|
|
836
|
+
max(n, params) {
|
|
837
|
+
return this.check(checks.maxLength(n, params));
|
|
838
|
+
},
|
|
839
|
+
length(n, params) {
|
|
840
|
+
return this.check(checks.length(n, params));
|
|
841
|
+
},
|
|
842
|
+
unwrap() {
|
|
843
|
+
return this.element;
|
|
844
|
+
},
|
|
845
|
+
});
|
|
659
846
|
});
|
|
660
847
|
function array(element, params) {
|
|
661
848
|
return core._array(exports.ZodArray, element, params);
|
|
@@ -672,23 +859,47 @@ exports.ZodObject = core.$constructor("ZodObject", (inst, def) => {
|
|
|
672
859
|
index_js_1.util.defineLazy(inst, "shape", () => {
|
|
673
860
|
return def.shape;
|
|
674
861
|
});
|
|
675
|
-
inst
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
862
|
+
_installLazyMethods(inst, "ZodObject", {
|
|
863
|
+
keyof() {
|
|
864
|
+
return _enum(Object.keys(this._zod.def.shape));
|
|
865
|
+
},
|
|
866
|
+
catchall(catchall) {
|
|
867
|
+
return this.clone({ ...this._zod.def, catchall: catchall });
|
|
868
|
+
},
|
|
869
|
+
passthrough() {
|
|
870
|
+
return this.clone({ ...this._zod.def, catchall: unknown() });
|
|
871
|
+
},
|
|
872
|
+
loose() {
|
|
873
|
+
return this.clone({ ...this._zod.def, catchall: unknown() });
|
|
874
|
+
},
|
|
875
|
+
strict() {
|
|
876
|
+
return this.clone({ ...this._zod.def, catchall: never() });
|
|
877
|
+
},
|
|
878
|
+
strip() {
|
|
879
|
+
return this.clone({ ...this._zod.def, catchall: undefined });
|
|
880
|
+
},
|
|
881
|
+
extend(incoming) {
|
|
882
|
+
return index_js_1.util.extend(this, incoming);
|
|
883
|
+
},
|
|
884
|
+
safeExtend(incoming) {
|
|
885
|
+
return index_js_1.util.safeExtend(this, incoming);
|
|
886
|
+
},
|
|
887
|
+
merge(other) {
|
|
888
|
+
return index_js_1.util.merge(this, other);
|
|
889
|
+
},
|
|
890
|
+
pick(mask) {
|
|
891
|
+
return index_js_1.util.pick(this, mask);
|
|
892
|
+
},
|
|
893
|
+
omit(mask) {
|
|
894
|
+
return index_js_1.util.omit(this, mask);
|
|
895
|
+
},
|
|
896
|
+
partial(...args) {
|
|
897
|
+
return index_js_1.util.partial(exports.ZodOptional, this, args[0]);
|
|
898
|
+
},
|
|
899
|
+
required(...args) {
|
|
900
|
+
return index_js_1.util.required(exports.ZodNonOptional, this, args[0]);
|
|
901
|
+
},
|
|
902
|
+
});
|
|
692
903
|
});
|
|
693
904
|
function object(shape, params) {
|
|
694
905
|
const def = {
|
|
@@ -799,6 +1010,15 @@ exports.ZodRecord = core.$constructor("ZodRecord", (inst, def) => {
|
|
|
799
1010
|
inst.valueType = def.valueType;
|
|
800
1011
|
});
|
|
801
1012
|
function record(keyType, valueType, params) {
|
|
1013
|
+
// v3-compat: z.record(valueType, params?) — defaults keyType to z.string()
|
|
1014
|
+
if (!valueType || !valueType._zod) {
|
|
1015
|
+
return new exports.ZodRecord({
|
|
1016
|
+
type: "record",
|
|
1017
|
+
keyType: string(),
|
|
1018
|
+
valueType: keyType,
|
|
1019
|
+
...index_js_1.util.normalizeParams(valueType),
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
802
1022
|
return new exports.ZodRecord({
|
|
803
1023
|
type: "record",
|
|
804
1024
|
keyType,
|
|
@@ -983,10 +1203,12 @@ exports.ZodTransform = core.$constructor("ZodTransform", (inst, def) => {
|
|
|
983
1203
|
if (output instanceof Promise) {
|
|
984
1204
|
return output.then((output) => {
|
|
985
1205
|
payload.value = output;
|
|
1206
|
+
payload.fallback = true;
|
|
986
1207
|
return payload;
|
|
987
1208
|
});
|
|
988
1209
|
}
|
|
989
1210
|
payload.value = output;
|
|
1211
|
+
payload.fallback = true;
|
|
990
1212
|
return payload;
|
|
991
1213
|
};
|
|
992
1214
|
});
|
|
@@ -1142,6 +1364,20 @@ function codec(in_, out, params) {
|
|
|
1142
1364
|
reverseTransform: params.encode,
|
|
1143
1365
|
});
|
|
1144
1366
|
}
|
|
1367
|
+
function invertCodec(codec) {
|
|
1368
|
+
const def = codec._zod.def;
|
|
1369
|
+
return new exports.ZodCodec({
|
|
1370
|
+
type: "pipe",
|
|
1371
|
+
in: def.out,
|
|
1372
|
+
out: def.in,
|
|
1373
|
+
transform: def.reverseTransform,
|
|
1374
|
+
reverseTransform: def.transform,
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
exports.ZodPreprocess = core.$constructor("ZodPreprocess", (inst, def) => {
|
|
1378
|
+
exports.ZodPipe.init(inst, def);
|
|
1379
|
+
core.$ZodPreprocess.init(inst, def);
|
|
1380
|
+
});
|
|
1145
1381
|
exports.ZodReadonly = core.$constructor("ZodReadonly", (inst, def) => {
|
|
1146
1382
|
core.$ZodReadonly.init(inst, def);
|
|
1147
1383
|
exports.ZodType.init(inst, def);
|
|
@@ -1223,8 +1459,8 @@ function refine(fn, _params = {}) {
|
|
|
1223
1459
|
return core._refine(exports.ZodCustom, fn, _params);
|
|
1224
1460
|
}
|
|
1225
1461
|
// superRefine
|
|
1226
|
-
function superRefine(fn) {
|
|
1227
|
-
return core._superRefine(fn);
|
|
1462
|
+
function superRefine(fn, params) {
|
|
1463
|
+
return core._superRefine(fn, params);
|
|
1228
1464
|
}
|
|
1229
1465
|
// Re-export describe and meta from core
|
|
1230
1466
|
exports.describe = core.describe;
|
|
@@ -1266,7 +1502,10 @@ function json(params) {
|
|
|
1266
1502
|
return jsonSchema;
|
|
1267
1503
|
}
|
|
1268
1504
|
// preprocess
|
|
1269
|
-
// /** @deprecated Use `z.pipe()` and `z.transform()` instead. */
|
|
1270
1505
|
function preprocess(fn, schema) {
|
|
1271
|
-
return
|
|
1506
|
+
return new exports.ZodPreprocess({
|
|
1507
|
+
type: "pipe",
|
|
1508
|
+
in: transform(fn),
|
|
1509
|
+
out: schema,
|
|
1510
|
+
});
|
|
1272
1511
|
}
|