@aiaiai-pt/martha-cli 0.63.0 → 0.64.0
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/CHANGELOG.md +23 -0
- package/dist/index.js +3842 -157
- package/package.json +1 -1
- package/skills/martha-cli/SKILL.md +1 -0
package/dist/index.js
CHANGED
|
@@ -9531,7 +9531,7 @@ class MarthaAPIClient {
|
|
|
9531
9531
|
const tenant = this.tenantFor(token);
|
|
9532
9532
|
return {
|
|
9533
9533
|
Authorization: `Bearer ${token}`,
|
|
9534
|
-
...tenant ? { "X-
|
|
9534
|
+
...tenant ? { "X-Tenant-Id": tenant } : {}
|
|
9535
9535
|
};
|
|
9536
9536
|
}
|
|
9537
9537
|
log(msg) {
|
|
@@ -11244,7 +11244,7 @@ init_config();
|
|
|
11244
11244
|
init_errors();
|
|
11245
11245
|
|
|
11246
11246
|
// src/version.ts
|
|
11247
|
-
var CLI_VERSION = "0.
|
|
11247
|
+
var CLI_VERSION = "0.64.0";
|
|
11248
11248
|
|
|
11249
11249
|
// src/commands/sessions.ts
|
|
11250
11250
|
function relativeTime(iso) {
|
|
@@ -17720,7 +17720,41 @@ var triggersConfig = {
|
|
|
17720
17720
|
// src/commands/documents.ts
|
|
17721
17721
|
import fs10 from "node:fs";
|
|
17722
17722
|
init_errors();
|
|
17723
|
-
|
|
17723
|
+
|
|
17724
|
+
// src/lib/document-lifecycle.ts
|
|
17725
|
+
function formatDocumentLifecycle(value) {
|
|
17726
|
+
const lines = [
|
|
17727
|
+
`Document: ${value.document_id}`,
|
|
17728
|
+
`Searchable: ${value.searchable ? "yes" : "no"}`,
|
|
17729
|
+
...value.searchability_reasons.map((reason) => ` ${reason}`)
|
|
17730
|
+
];
|
|
17731
|
+
for (const region of value.regions) {
|
|
17732
|
+
lines.push(`
|
|
17733
|
+
${region.kind}: ${region.state ?? "Not recorded"} (${region.mode})`);
|
|
17734
|
+
for (const event of region.events) {
|
|
17735
|
+
lines.push(` ${event.event} → ${event.to_state}: ${event.allowed ? "allowed" : `unavailable (${event.reason ?? "not authorized"})`}`);
|
|
17736
|
+
}
|
|
17737
|
+
}
|
|
17738
|
+
lines.push(`
|
|
17739
|
+
Sync sources:`);
|
|
17740
|
+
if (!value.sync_sources.length)
|
|
17741
|
+
lines.push(" None");
|
|
17742
|
+
for (const source of value.sync_sources) {
|
|
17743
|
+
lines.push(` ${source.id}: ${source.provider}, ${source.status}; last synced ${source.last_synced_at ?? "never"}`);
|
|
17744
|
+
}
|
|
17745
|
+
lines.push(`
|
|
17746
|
+
History:`);
|
|
17747
|
+
if (!value.history.length)
|
|
17748
|
+
lines.push(" No recorded transitions");
|
|
17749
|
+
for (const row of value.history) {
|
|
17750
|
+
lines.push(` ${row.seq} ${row.created_at} ${row.kind}: ${row.from_state ?? "∅"} → ${row.to_state} (${row.event}, ${row.actor_kind}:${row.actor_id ?? "unknown"})`);
|
|
17751
|
+
}
|
|
17752
|
+
return lines.join(`
|
|
17753
|
+
`);
|
|
17754
|
+
}
|
|
17755
|
+
|
|
17756
|
+
// src/commands/documents.ts
|
|
17757
|
+
var TERMINAL_STATUSES2 = new Set(["ready", "error", "skipped"]);
|
|
17724
17758
|
var SPINNER_FRAMES2 = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
17725
17759
|
var spinnerIdx = 0;
|
|
17726
17760
|
function nextSpinner() {
|
|
@@ -17850,6 +17884,8 @@ Detached. Check status with: martha documents status ${documentId}`));
|
|
|
17850
17884
|
if (TERMINAL_STATUSES2.has(status.ingestion_status)) {
|
|
17851
17885
|
if (status.ingestion_status === "ready") {
|
|
17852
17886
|
lines.push(source_default.green("Ingestion complete"));
|
|
17887
|
+
} else if (status.ingestion_status === "skipped") {
|
|
17888
|
+
lines.push("Ingestion skipped (store-only document)");
|
|
17853
17889
|
} else {
|
|
17854
17890
|
lines.push(source_default.red(`Error: ${status.error ?? "unknown error"}`));
|
|
17855
17891
|
}
|
|
@@ -17869,6 +17905,8 @@ Detached. Check status with: martha documents status ${documentId}`));
|
|
|
17869
17905
|
if (!isJson && !isTTY) {
|
|
17870
17906
|
if (status.ingestion_status === "ready") {
|
|
17871
17907
|
console.log(`Ingestion complete. ${status.chunk_count ?? 0} chunks created.`);
|
|
17908
|
+
} else if (status.ingestion_status === "skipped") {
|
|
17909
|
+
console.log("Ingestion skipped (store-only document).");
|
|
17872
17910
|
} else {
|
|
17873
17911
|
console.error(`Ingestion failed: ${status.error ?? "unknown error"}`);
|
|
17874
17912
|
process.exitCode = 1 /* Error */;
|
|
@@ -17898,6 +17936,10 @@ function registerDocumentCommands(program) {
|
|
|
17898
17936
|
function isJson() {
|
|
17899
17937
|
return !!program.opts().json;
|
|
17900
17938
|
}
|
|
17939
|
+
cmd.command("lifecycle <document-id>").description("Explain document states, search eligibility, event permissions and history").action(async (documentId) => {
|
|
17940
|
+
const value = await getCtx().api.get(`/api/admin/documents/${encodeURIComponent(documentId)}/lifecycle`);
|
|
17941
|
+
console.log(isJson() ? JSON.stringify(value, null, 2) : formatDocumentLifecycle(value));
|
|
17942
|
+
});
|
|
17901
17943
|
async function resolveCollection(ctx, ref) {
|
|
17902
17944
|
const looksLikeUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(ref);
|
|
17903
17945
|
if (looksLikeUuid) {
|
|
@@ -18124,11 +18166,15 @@ ${items.length} collections`));
|
|
|
18124
18166
|
console.log(source_default.dim(`Uploaded ${result.filename}. Waiting for ingestion...`));
|
|
18125
18167
|
}
|
|
18126
18168
|
const final = await pollIngestionUntilDone(ctx, result.id);
|
|
18169
|
+
if (final.ingestion_status === "error")
|
|
18170
|
+
process.exitCode = 1 /* Error */;
|
|
18127
18171
|
if (isJson()) {
|
|
18128
18172
|
console.log(JSON.stringify(final));
|
|
18129
18173
|
} else {
|
|
18130
18174
|
if (final.ingestion_status === "ready") {
|
|
18131
18175
|
console.log(`Ingestion complete. ${final.chunk_count ?? 0} chunks created.`);
|
|
18176
|
+
} else if (final.ingestion_status === "skipped") {
|
|
18177
|
+
console.log("Ingestion skipped (store-only document).");
|
|
18132
18178
|
} else {
|
|
18133
18179
|
console.error(`Ingestion failed: ${final.error ?? "unknown error"}`);
|
|
18134
18180
|
process.exitCode = 1 /* Error */;
|
|
@@ -18307,11 +18353,15 @@ ${items.length} documents`));
|
|
|
18307
18353
|
console.log(source_default.dim(`Re-ingestion triggered. Waiting for completion...`));
|
|
18308
18354
|
}
|
|
18309
18355
|
const final = await pollIngestionUntilDone(ctx, documentId);
|
|
18356
|
+
if (final.ingestion_status === "error")
|
|
18357
|
+
process.exitCode = 1 /* Error */;
|
|
18310
18358
|
if (isJson()) {
|
|
18311
18359
|
console.log(JSON.stringify(final));
|
|
18312
18360
|
} else {
|
|
18313
18361
|
if (final.ingestion_status === "ready") {
|
|
18314
18362
|
console.log(`Ingestion complete. ${final.chunk_count ?? 0} chunks created.`);
|
|
18363
|
+
} else if (final.ingestion_status === "skipped") {
|
|
18364
|
+
console.log("Ingestion skipped (store-only document).");
|
|
18315
18365
|
} else {
|
|
18316
18366
|
console.error(`Ingestion failed: ${final.error ?? "unknown error"}`);
|
|
18317
18367
|
process.exitCode = 1 /* Error */;
|
|
@@ -20507,13 +20557,10 @@ function registerMessagingCommands(program) {
|
|
|
20507
20557
|
});
|
|
20508
20558
|
cmd.command("send-sms").description("Send a test SMS").requiredOption("--to <number>", "Destination phone number (E.164)").requiredOption("--from <sender>", "Sender ID or number").requiredOption("--content <text>", "Message content").action(async (opts) => {
|
|
20509
20559
|
const ctx = getCtx();
|
|
20510
|
-
const data = await
|
|
20511
|
-
|
|
20512
|
-
|
|
20513
|
-
|
|
20514
|
-
from_number: opts.from,
|
|
20515
|
-
content: opts.content
|
|
20516
|
-
}
|
|
20560
|
+
const data = await ctx.api.post("/api/messaging/send/sms", {
|
|
20561
|
+
to: opts.to,
|
|
20562
|
+
from_number: opts.from,
|
|
20563
|
+
content: opts.content
|
|
20517
20564
|
});
|
|
20518
20565
|
if (isJson()) {
|
|
20519
20566
|
console.log(JSON.stringify(data, null, 2));
|
|
@@ -21877,176 +21924,3814 @@ function registerBudgetCommands(program) {
|
|
|
21877
21924
|
|
|
21878
21925
|
// src/commands/wiki.ts
|
|
21879
21926
|
import fs11 from "node:fs";
|
|
21880
|
-
init_errors();
|
|
21881
21927
|
|
|
21882
|
-
//
|
|
21883
|
-
|
|
21884
|
-
|
|
21885
|
-
|
|
21886
|
-
|
|
21887
|
-
|
|
21928
|
+
// node_modules/zod/v4/core/core.js
|
|
21929
|
+
var NEVER = Object.freeze({
|
|
21930
|
+
status: "aborted"
|
|
21931
|
+
});
|
|
21932
|
+
function $constructor(name, initializer, params) {
|
|
21933
|
+
function init(inst, def) {
|
|
21934
|
+
if (!inst._zod) {
|
|
21935
|
+
Object.defineProperty(inst, "_zod", {
|
|
21936
|
+
value: {
|
|
21937
|
+
def,
|
|
21938
|
+
constr: _,
|
|
21939
|
+
traits: new Set
|
|
21940
|
+
},
|
|
21941
|
+
enumerable: false
|
|
21942
|
+
});
|
|
21943
|
+
}
|
|
21944
|
+
if (inst._zod.traits.has(name)) {
|
|
21945
|
+
return;
|
|
21946
|
+
}
|
|
21947
|
+
inst._zod.traits.add(name);
|
|
21948
|
+
initializer(inst, def);
|
|
21949
|
+
const proto = _.prototype;
|
|
21950
|
+
const keys = Object.keys(proto);
|
|
21951
|
+
for (let i = 0;i < keys.length; i++) {
|
|
21952
|
+
const k = keys[i];
|
|
21953
|
+
if (!(k in inst)) {
|
|
21954
|
+
inst[k] = proto[k].bind(inst);
|
|
21955
|
+
}
|
|
21956
|
+
}
|
|
21888
21957
|
}
|
|
21889
|
-
const
|
|
21890
|
-
|
|
21958
|
+
const Parent = params?.Parent ?? Object;
|
|
21959
|
+
|
|
21960
|
+
class Definition extends Parent {
|
|
21961
|
+
}
|
|
21962
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
21963
|
+
function _(def) {
|
|
21964
|
+
var _a;
|
|
21965
|
+
const inst = params?.Parent ? new Definition : this;
|
|
21966
|
+
init(inst, def);
|
|
21967
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
21968
|
+
for (const fn of inst._zod.deferred) {
|
|
21969
|
+
fn();
|
|
21970
|
+
}
|
|
21971
|
+
return inst;
|
|
21972
|
+
}
|
|
21973
|
+
Object.defineProperty(_, "init", { value: init });
|
|
21974
|
+
Object.defineProperty(_, Symbol.hasInstance, {
|
|
21975
|
+
value: (inst) => {
|
|
21976
|
+
if (params?.Parent && inst instanceof params.Parent)
|
|
21977
|
+
return true;
|
|
21978
|
+
return inst?._zod?.traits?.has(name);
|
|
21979
|
+
}
|
|
21891
21980
|
});
|
|
21892
|
-
|
|
21893
|
-
|
|
21894
|
-
return bySlug.id;
|
|
21895
|
-
const byName = all.find((c) => c.name === ref);
|
|
21896
|
-
if (byName)
|
|
21897
|
-
return byName.id;
|
|
21898
|
-
throw new CLIError(`Collection '${ref}' not found (tried UUID, slug, and name).`, 3 /* NotFound */, "Run `martha documents collections --tree` to see available collections.");
|
|
21981
|
+
Object.defineProperty(_, "name", { value: name });
|
|
21982
|
+
return _;
|
|
21899
21983
|
}
|
|
21984
|
+
var $brand = Symbol("zod_brand");
|
|
21900
21985
|
|
|
21901
|
-
|
|
21902
|
-
|
|
21903
|
-
|
|
21904
|
-
const source = explicit ?? name ?? "";
|
|
21905
|
-
const slug = source.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
21906
|
-
if (!slug) {
|
|
21907
|
-
throw new CLIError(explicit ? `--slug '${explicit}' is not a valid slug (needs a letter or digit).` : `Cannot derive a slug from name '${name}' — pass --slug explicitly.`, 4 /* Validation */);
|
|
21986
|
+
class $ZodAsyncError extends Error {
|
|
21987
|
+
constructor() {
|
|
21988
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
21908
21989
|
}
|
|
21909
|
-
return slug;
|
|
21910
21990
|
}
|
|
21911
|
-
|
|
21912
|
-
|
|
21913
|
-
|
|
21914
|
-
|
|
21991
|
+
|
|
21992
|
+
class $ZodEncodeError extends Error {
|
|
21993
|
+
constructor(name) {
|
|
21994
|
+
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
21995
|
+
this.name = "ZodEncodeError";
|
|
21996
|
+
}
|
|
21997
|
+
}
|
|
21998
|
+
var globalConfig = {};
|
|
21999
|
+
function config(newConfig) {
|
|
22000
|
+
if (newConfig)
|
|
22001
|
+
Object.assign(globalConfig, newConfig);
|
|
22002
|
+
return globalConfig;
|
|
22003
|
+
}
|
|
22004
|
+
// node_modules/zod/v4/core/util.js
|
|
22005
|
+
function getEnumValues(entries) {
|
|
22006
|
+
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
22007
|
+
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
22008
|
+
return values;
|
|
22009
|
+
}
|
|
22010
|
+
function jsonStringifyReplacer(_, value) {
|
|
22011
|
+
if (typeof value === "bigint")
|
|
22012
|
+
return value.toString();
|
|
22013
|
+
return value;
|
|
21915
22014
|
}
|
|
21916
|
-
function
|
|
21917
|
-
const
|
|
21918
|
-
|
|
21919
|
-
|
|
21920
|
-
|
|
21921
|
-
|
|
21922
|
-
|
|
21923
|
-
|
|
21924
|
-
|
|
21925
|
-
|
|
22015
|
+
function cached(getter) {
|
|
22016
|
+
const set = false;
|
|
22017
|
+
return {
|
|
22018
|
+
get value() {
|
|
22019
|
+
if (!set) {
|
|
22020
|
+
const value = getter();
|
|
22021
|
+
Object.defineProperty(this, "value", { value });
|
|
22022
|
+
return value;
|
|
22023
|
+
}
|
|
22024
|
+
throw new Error("cached value already set");
|
|
22025
|
+
}
|
|
22026
|
+
};
|
|
22027
|
+
}
|
|
22028
|
+
function nullish(input) {
|
|
22029
|
+
return input === null || input === undefined;
|
|
22030
|
+
}
|
|
22031
|
+
function cleanRegex(source) {
|
|
22032
|
+
const start = source.startsWith("^") ? 1 : 0;
|
|
22033
|
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
22034
|
+
return source.slice(start, end);
|
|
22035
|
+
}
|
|
22036
|
+
var EVALUATING = Symbol("evaluating");
|
|
22037
|
+
function defineLazy(object, key, getter) {
|
|
22038
|
+
let value = undefined;
|
|
22039
|
+
Object.defineProperty(object, key, {
|
|
22040
|
+
get() {
|
|
22041
|
+
if (value === EVALUATING) {
|
|
22042
|
+
return;
|
|
22043
|
+
}
|
|
22044
|
+
if (value === undefined) {
|
|
22045
|
+
value = EVALUATING;
|
|
22046
|
+
value = getter();
|
|
22047
|
+
}
|
|
22048
|
+
return value;
|
|
22049
|
+
},
|
|
22050
|
+
set(v) {
|
|
22051
|
+
Object.defineProperty(object, key, {
|
|
22052
|
+
value: v
|
|
22053
|
+
});
|
|
22054
|
+
},
|
|
22055
|
+
configurable: true
|
|
22056
|
+
});
|
|
22057
|
+
}
|
|
22058
|
+
function assignProp(target, prop, value) {
|
|
22059
|
+
Object.defineProperty(target, prop, {
|
|
22060
|
+
value,
|
|
22061
|
+
writable: true,
|
|
22062
|
+
enumerable: true,
|
|
22063
|
+
configurable: true
|
|
22064
|
+
});
|
|
22065
|
+
}
|
|
22066
|
+
function mergeDefs(...defs) {
|
|
22067
|
+
const mergedDescriptors = {};
|
|
22068
|
+
for (const def of defs) {
|
|
22069
|
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
22070
|
+
Object.assign(mergedDescriptors, descriptors);
|
|
21926
22071
|
}
|
|
21927
|
-
|
|
21928
|
-
|
|
22072
|
+
return Object.defineProperties({}, mergedDescriptors);
|
|
22073
|
+
}
|
|
22074
|
+
function esc(str) {
|
|
22075
|
+
return JSON.stringify(str);
|
|
22076
|
+
}
|
|
22077
|
+
function slugify(input) {
|
|
22078
|
+
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
22079
|
+
}
|
|
22080
|
+
var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
22081
|
+
function isObject(data) {
|
|
22082
|
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
22083
|
+
}
|
|
22084
|
+
var allowsEval = cached(() => {
|
|
22085
|
+
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
|
|
22086
|
+
return false;
|
|
21929
22087
|
}
|
|
21930
|
-
|
|
21931
|
-
const
|
|
21932
|
-
|
|
21933
|
-
|
|
21934
|
-
|
|
21935
|
-
|
|
21936
|
-
|
|
21937
|
-
|
|
21938
|
-
|
|
21939
|
-
|
|
21940
|
-
|
|
21941
|
-
|
|
21942
|
-
|
|
21943
|
-
|
|
21944
|
-
|
|
21945
|
-
|
|
21946
|
-
|
|
21947
|
-
|
|
21948
|
-
|
|
21949
|
-
|
|
21950
|
-
|
|
21951
|
-
|
|
22088
|
+
try {
|
|
22089
|
+
const F = Function;
|
|
22090
|
+
new F("");
|
|
22091
|
+
return true;
|
|
22092
|
+
} catch (_) {
|
|
22093
|
+
return false;
|
|
22094
|
+
}
|
|
22095
|
+
});
|
|
22096
|
+
function isPlainObject2(o) {
|
|
22097
|
+
if (isObject(o) === false)
|
|
22098
|
+
return false;
|
|
22099
|
+
const ctor = o.constructor;
|
|
22100
|
+
if (ctor === undefined)
|
|
22101
|
+
return true;
|
|
22102
|
+
if (typeof ctor !== "function")
|
|
22103
|
+
return true;
|
|
22104
|
+
const prot = ctor.prototype;
|
|
22105
|
+
if (isObject(prot) === false)
|
|
22106
|
+
return false;
|
|
22107
|
+
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
22108
|
+
return false;
|
|
22109
|
+
}
|
|
22110
|
+
return true;
|
|
22111
|
+
}
|
|
22112
|
+
function shallowClone(o) {
|
|
22113
|
+
if (isPlainObject2(o))
|
|
22114
|
+
return { ...o };
|
|
22115
|
+
if (Array.isArray(o))
|
|
22116
|
+
return [...o];
|
|
22117
|
+
return o;
|
|
22118
|
+
}
|
|
22119
|
+
var propertyKeyTypes = new Set(["string", "number", "symbol"]);
|
|
22120
|
+
var primitiveTypes = new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
|
|
22121
|
+
function escapeRegex(str) {
|
|
22122
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
22123
|
+
}
|
|
22124
|
+
function clone(inst, def, params) {
|
|
22125
|
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
22126
|
+
if (!def || params?.parent)
|
|
22127
|
+
cl._zod.parent = inst;
|
|
22128
|
+
return cl;
|
|
22129
|
+
}
|
|
22130
|
+
function normalizeParams(_params) {
|
|
22131
|
+
const params = _params;
|
|
22132
|
+
if (!params)
|
|
22133
|
+
return {};
|
|
22134
|
+
if (typeof params === "string")
|
|
22135
|
+
return { error: () => params };
|
|
22136
|
+
if (params?.message !== undefined) {
|
|
22137
|
+
if (params?.error !== undefined)
|
|
22138
|
+
throw new Error("Cannot specify both `message` and `error` params");
|
|
22139
|
+
params.error = params.message;
|
|
22140
|
+
}
|
|
22141
|
+
delete params.message;
|
|
22142
|
+
if (typeof params.error === "string")
|
|
22143
|
+
return { ...params, error: () => params.error };
|
|
22144
|
+
return params;
|
|
22145
|
+
}
|
|
22146
|
+
function optionalKeys(shape) {
|
|
22147
|
+
return Object.keys(shape).filter((k) => {
|
|
22148
|
+
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
22149
|
+
});
|
|
22150
|
+
}
|
|
22151
|
+
var NUMBER_FORMAT_RANGES = {
|
|
22152
|
+
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
22153
|
+
int32: [-2147483648, 2147483647],
|
|
22154
|
+
uint32: [0, 4294967295],
|
|
22155
|
+
float32: [-340282346638528860000000000000000000000, 340282346638528860000000000000000000000],
|
|
22156
|
+
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
22157
|
+
};
|
|
22158
|
+
function pick(schema, mask) {
|
|
22159
|
+
const currDef = schema._zod.def;
|
|
22160
|
+
const checks = currDef.checks;
|
|
22161
|
+
const hasChecks = checks && checks.length > 0;
|
|
22162
|
+
if (hasChecks) {
|
|
22163
|
+
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
22164
|
+
}
|
|
22165
|
+
const def = mergeDefs(schema._zod.def, {
|
|
22166
|
+
get shape() {
|
|
22167
|
+
const newShape = {};
|
|
22168
|
+
for (const key in mask) {
|
|
22169
|
+
if (!(key in currDef.shape)) {
|
|
22170
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
22171
|
+
}
|
|
22172
|
+
if (!mask[key])
|
|
22173
|
+
continue;
|
|
22174
|
+
newShape[key] = currDef.shape[key];
|
|
21952
22175
|
}
|
|
21953
|
-
|
|
21954
|
-
|
|
21955
|
-
|
|
21956
|
-
|
|
21957
|
-
console.log(source_default.dim("-".repeat(header.length)));
|
|
21958
|
-
for (const w of wikis) {
|
|
21959
|
-
console.log(columns.map((col, i) => col.accessor(w).padEnd(widths[i])).join(" "));
|
|
21960
|
-
}
|
|
21961
|
-
console.log(source_default.dim(`
|
|
21962
|
-
${wikis.length} wiki${wikis.length === 1 ? "" : "s"}`));
|
|
22176
|
+
assignProp(this, "shape", newShape);
|
|
22177
|
+
return newShape;
|
|
22178
|
+
},
|
|
22179
|
+
checks: []
|
|
21963
22180
|
});
|
|
21964
|
-
|
|
21965
|
-
|
|
21966
|
-
|
|
21967
|
-
|
|
21968
|
-
|
|
21969
|
-
|
|
21970
|
-
|
|
21971
|
-
|
|
21972
|
-
|
|
21973
|
-
|
|
21974
|
-
|
|
21975
|
-
|
|
21976
|
-
|
|
21977
|
-
|
|
21978
|
-
|
|
21979
|
-
|
|
21980
|
-
|
|
21981
|
-
|
|
21982
|
-
|
|
22181
|
+
return clone(schema, def);
|
|
22182
|
+
}
|
|
22183
|
+
function omit(schema, mask) {
|
|
22184
|
+
const currDef = schema._zod.def;
|
|
22185
|
+
const checks = currDef.checks;
|
|
22186
|
+
const hasChecks = checks && checks.length > 0;
|
|
22187
|
+
if (hasChecks) {
|
|
22188
|
+
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
22189
|
+
}
|
|
22190
|
+
const def = mergeDefs(schema._zod.def, {
|
|
22191
|
+
get shape() {
|
|
22192
|
+
const newShape = { ...schema._zod.def.shape };
|
|
22193
|
+
for (const key in mask) {
|
|
22194
|
+
if (!(key in currDef.shape)) {
|
|
22195
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
22196
|
+
}
|
|
22197
|
+
if (!mask[key])
|
|
22198
|
+
continue;
|
|
22199
|
+
delete newShape[key];
|
|
22200
|
+
}
|
|
22201
|
+
assignProp(this, "shape", newShape);
|
|
22202
|
+
return newShape;
|
|
22203
|
+
},
|
|
22204
|
+
checks: []
|
|
21983
22205
|
});
|
|
21984
|
-
|
|
21985
|
-
|
|
21986
|
-
|
|
21987
|
-
|
|
22206
|
+
return clone(schema, def);
|
|
22207
|
+
}
|
|
22208
|
+
function extend(schema, shape) {
|
|
22209
|
+
if (!isPlainObject2(shape)) {
|
|
22210
|
+
throw new Error("Invalid input to extend: expected a plain object");
|
|
22211
|
+
}
|
|
22212
|
+
const checks = schema._zod.def.checks;
|
|
22213
|
+
const hasChecks = checks && checks.length > 0;
|
|
22214
|
+
if (hasChecks) {
|
|
22215
|
+
const existingShape = schema._zod.def.shape;
|
|
22216
|
+
for (const key in shape) {
|
|
22217
|
+
if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
|
|
22218
|
+
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
22219
|
+
}
|
|
21988
22220
|
}
|
|
21989
|
-
|
|
21990
|
-
|
|
21991
|
-
|
|
21992
|
-
|
|
21993
|
-
|
|
22221
|
+
}
|
|
22222
|
+
const def = mergeDefs(schema._zod.def, {
|
|
22223
|
+
get shape() {
|
|
22224
|
+
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
22225
|
+
assignProp(this, "shape", _shape);
|
|
22226
|
+
return _shape;
|
|
21994
22227
|
}
|
|
21995
22228
|
});
|
|
21996
|
-
|
|
21997
|
-
|
|
21998
|
-
|
|
21999
|
-
|
|
22000
|
-
|
|
22001
|
-
|
|
22002
|
-
|
|
22003
|
-
|
|
22004
|
-
|
|
22005
|
-
|
|
22006
|
-
|
|
22007
|
-
return;
|
|
22229
|
+
return clone(schema, def);
|
|
22230
|
+
}
|
|
22231
|
+
function safeExtend(schema, shape) {
|
|
22232
|
+
if (!isPlainObject2(shape)) {
|
|
22233
|
+
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
22234
|
+
}
|
|
22235
|
+
const def = mergeDefs(schema._zod.def, {
|
|
22236
|
+
get shape() {
|
|
22237
|
+
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
22238
|
+
assignProp(this, "shape", _shape);
|
|
22239
|
+
return _shape;
|
|
22008
22240
|
}
|
|
22009
|
-
|
|
22010
|
-
|
|
22011
|
-
|
|
22012
|
-
|
|
22013
|
-
|
|
22014
|
-
|
|
22015
|
-
|
|
22241
|
+
});
|
|
22242
|
+
return clone(schema, def);
|
|
22243
|
+
}
|
|
22244
|
+
function merge(a, b) {
|
|
22245
|
+
const def = mergeDefs(a._zod.def, {
|
|
22246
|
+
get shape() {
|
|
22247
|
+
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
|
22248
|
+
assignProp(this, "shape", _shape);
|
|
22249
|
+
return _shape;
|
|
22250
|
+
},
|
|
22251
|
+
get catchall() {
|
|
22252
|
+
return b._zod.def.catchall;
|
|
22253
|
+
},
|
|
22254
|
+
checks: []
|
|
22255
|
+
});
|
|
22256
|
+
return clone(a, def);
|
|
22257
|
+
}
|
|
22258
|
+
function partial(Class, schema, mask) {
|
|
22259
|
+
const currDef = schema._zod.def;
|
|
22260
|
+
const checks = currDef.checks;
|
|
22261
|
+
const hasChecks = checks && checks.length > 0;
|
|
22262
|
+
if (hasChecks) {
|
|
22263
|
+
throw new Error(".partial() cannot be used on object schemas containing refinements");
|
|
22264
|
+
}
|
|
22265
|
+
const def = mergeDefs(schema._zod.def, {
|
|
22266
|
+
get shape() {
|
|
22267
|
+
const oldShape = schema._zod.def.shape;
|
|
22268
|
+
const shape = { ...oldShape };
|
|
22269
|
+
if (mask) {
|
|
22270
|
+
for (const key in mask) {
|
|
22271
|
+
if (!(key in oldShape)) {
|
|
22272
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
22273
|
+
}
|
|
22274
|
+
if (!mask[key])
|
|
22275
|
+
continue;
|
|
22276
|
+
shape[key] = Class ? new Class({
|
|
22277
|
+
type: "optional",
|
|
22278
|
+
innerType: oldShape[key]
|
|
22279
|
+
}) : oldShape[key];
|
|
22280
|
+
}
|
|
22281
|
+
} else {
|
|
22282
|
+
for (const key in oldShape) {
|
|
22283
|
+
shape[key] = Class ? new Class({
|
|
22284
|
+
type: "optional",
|
|
22285
|
+
innerType: oldShape[key]
|
|
22286
|
+
}) : oldShape[key];
|
|
22287
|
+
}
|
|
22016
22288
|
}
|
|
22017
|
-
|
|
22018
|
-
|
|
22019
|
-
|
|
22020
|
-
|
|
22021
|
-
console.log(source_default.dim("-".repeat(header.length)));
|
|
22022
|
-
for (const p of pages) {
|
|
22023
|
-
console.log(columns.map((col, i) => col.accessor(p).padEnd(widths[i])).join(" "));
|
|
22024
|
-
}
|
|
22025
|
-
console.log(source_default.dim(`
|
|
22026
|
-
${pages.length} pages`));
|
|
22289
|
+
assignProp(this, "shape", shape);
|
|
22290
|
+
return shape;
|
|
22291
|
+
},
|
|
22292
|
+
checks: []
|
|
22027
22293
|
});
|
|
22028
|
-
|
|
22029
|
-
|
|
22030
|
-
|
|
22031
|
-
|
|
22032
|
-
|
|
22033
|
-
|
|
22034
|
-
|
|
22035
|
-
|
|
22036
|
-
|
|
22037
|
-
|
|
22294
|
+
return clone(schema, def);
|
|
22295
|
+
}
|
|
22296
|
+
function required(Class, schema, mask) {
|
|
22297
|
+
const def = mergeDefs(schema._zod.def, {
|
|
22298
|
+
get shape() {
|
|
22299
|
+
const oldShape = schema._zod.def.shape;
|
|
22300
|
+
const shape = { ...oldShape };
|
|
22301
|
+
if (mask) {
|
|
22302
|
+
for (const key in mask) {
|
|
22303
|
+
if (!(key in shape)) {
|
|
22304
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
22305
|
+
}
|
|
22306
|
+
if (!mask[key])
|
|
22307
|
+
continue;
|
|
22308
|
+
shape[key] = new Class({
|
|
22309
|
+
type: "nonoptional",
|
|
22310
|
+
innerType: oldShape[key]
|
|
22311
|
+
});
|
|
22312
|
+
}
|
|
22313
|
+
} else {
|
|
22314
|
+
for (const key in oldShape) {
|
|
22315
|
+
shape[key] = new Class({
|
|
22316
|
+
type: "nonoptional",
|
|
22317
|
+
innerType: oldShape[key]
|
|
22318
|
+
});
|
|
22319
|
+
}
|
|
22320
|
+
}
|
|
22321
|
+
assignProp(this, "shape", shape);
|
|
22322
|
+
return shape;
|
|
22038
22323
|
}
|
|
22039
|
-
|
|
22040
|
-
|
|
22041
|
-
|
|
22324
|
+
});
|
|
22325
|
+
return clone(schema, def);
|
|
22326
|
+
}
|
|
22327
|
+
function aborted(x, startIndex = 0) {
|
|
22328
|
+
if (x.aborted === true)
|
|
22329
|
+
return true;
|
|
22330
|
+
for (let i = startIndex;i < x.issues.length; i++) {
|
|
22331
|
+
if (x.issues[i]?.continue !== true) {
|
|
22332
|
+
return true;
|
|
22042
22333
|
}
|
|
22043
|
-
|
|
22334
|
+
}
|
|
22335
|
+
return false;
|
|
22336
|
+
}
|
|
22337
|
+
function prefixIssues(path, issues) {
|
|
22338
|
+
return issues.map((iss) => {
|
|
22339
|
+
var _a;
|
|
22340
|
+
(_a = iss).path ?? (_a.path = []);
|
|
22341
|
+
iss.path.unshift(path);
|
|
22342
|
+
return iss;
|
|
22343
|
+
});
|
|
22344
|
+
}
|
|
22345
|
+
function unwrapMessage(message) {
|
|
22346
|
+
return typeof message === "string" ? message : message?.message;
|
|
22347
|
+
}
|
|
22348
|
+
function finalizeIssue(iss, ctx, config) {
|
|
22349
|
+
const full = { ...iss, path: iss.path ?? [] };
|
|
22350
|
+
if (!iss.message) {
|
|
22351
|
+
const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
|
|
22352
|
+
full.message = message;
|
|
22353
|
+
}
|
|
22354
|
+
delete full.inst;
|
|
22355
|
+
delete full.continue;
|
|
22356
|
+
if (!ctx?.reportInput) {
|
|
22357
|
+
delete full.input;
|
|
22358
|
+
}
|
|
22359
|
+
return full;
|
|
22360
|
+
}
|
|
22361
|
+
function getLengthableOrigin(input) {
|
|
22362
|
+
if (Array.isArray(input))
|
|
22363
|
+
return "array";
|
|
22364
|
+
if (typeof input === "string")
|
|
22365
|
+
return "string";
|
|
22366
|
+
return "unknown";
|
|
22367
|
+
}
|
|
22368
|
+
function issue(...args) {
|
|
22369
|
+
const [iss, input, inst] = args;
|
|
22370
|
+
if (typeof iss === "string") {
|
|
22371
|
+
return {
|
|
22372
|
+
message: iss,
|
|
22373
|
+
code: "custom",
|
|
22374
|
+
input,
|
|
22375
|
+
inst
|
|
22376
|
+
};
|
|
22377
|
+
}
|
|
22378
|
+
return { ...iss };
|
|
22379
|
+
}
|
|
22380
|
+
|
|
22381
|
+
// node_modules/zod/v4/core/errors.js
|
|
22382
|
+
var initializer = (inst, def) => {
|
|
22383
|
+
inst.name = "$ZodError";
|
|
22384
|
+
Object.defineProperty(inst, "_zod", {
|
|
22385
|
+
value: inst._zod,
|
|
22386
|
+
enumerable: false
|
|
22387
|
+
});
|
|
22388
|
+
Object.defineProperty(inst, "issues", {
|
|
22389
|
+
value: def,
|
|
22390
|
+
enumerable: false
|
|
22391
|
+
});
|
|
22392
|
+
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
22393
|
+
Object.defineProperty(inst, "toString", {
|
|
22394
|
+
value: () => inst.message,
|
|
22395
|
+
enumerable: false
|
|
22396
|
+
});
|
|
22397
|
+
};
|
|
22398
|
+
var $ZodError = $constructor("$ZodError", initializer);
|
|
22399
|
+
var $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
|
|
22400
|
+
function flattenError(error, mapper = (issue) => issue.message) {
|
|
22401
|
+
const fieldErrors = {};
|
|
22402
|
+
const formErrors = [];
|
|
22403
|
+
for (const sub of error.issues) {
|
|
22404
|
+
if (sub.path.length > 0) {
|
|
22405
|
+
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
22406
|
+
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
22407
|
+
} else {
|
|
22408
|
+
formErrors.push(mapper(sub));
|
|
22409
|
+
}
|
|
22410
|
+
}
|
|
22411
|
+
return { formErrors, fieldErrors };
|
|
22412
|
+
}
|
|
22413
|
+
function formatError(error, mapper = (issue) => issue.message) {
|
|
22414
|
+
const fieldErrors = { _errors: [] };
|
|
22415
|
+
const processError = (error) => {
|
|
22416
|
+
for (const issue of error.issues) {
|
|
22417
|
+
if (issue.code === "invalid_union" && issue.errors.length) {
|
|
22418
|
+
issue.errors.map((issues) => processError({ issues }));
|
|
22419
|
+
} else if (issue.code === "invalid_key") {
|
|
22420
|
+
processError({ issues: issue.issues });
|
|
22421
|
+
} else if (issue.code === "invalid_element") {
|
|
22422
|
+
processError({ issues: issue.issues });
|
|
22423
|
+
} else if (issue.path.length === 0) {
|
|
22424
|
+
fieldErrors._errors.push(mapper(issue));
|
|
22425
|
+
} else {
|
|
22426
|
+
let curr = fieldErrors;
|
|
22427
|
+
let i = 0;
|
|
22428
|
+
while (i < issue.path.length) {
|
|
22429
|
+
const el = issue.path[i];
|
|
22430
|
+
const terminal = i === issue.path.length - 1;
|
|
22431
|
+
if (!terminal) {
|
|
22432
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
22433
|
+
} else {
|
|
22434
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
22435
|
+
curr[el]._errors.push(mapper(issue));
|
|
22436
|
+
}
|
|
22437
|
+
curr = curr[el];
|
|
22438
|
+
i++;
|
|
22439
|
+
}
|
|
22440
|
+
}
|
|
22441
|
+
}
|
|
22442
|
+
};
|
|
22443
|
+
processError(error);
|
|
22444
|
+
return fieldErrors;
|
|
22445
|
+
}
|
|
22446
|
+
|
|
22447
|
+
// node_modules/zod/v4/core/parse.js
|
|
22448
|
+
var _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
22449
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
|
|
22450
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
22451
|
+
if (result instanceof Promise) {
|
|
22452
|
+
throw new $ZodAsyncError;
|
|
22453
|
+
}
|
|
22454
|
+
if (result.issues.length) {
|
|
22455
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
22456
|
+
captureStackTrace(e, _params?.callee);
|
|
22457
|
+
throw e;
|
|
22458
|
+
}
|
|
22459
|
+
return result.value;
|
|
22460
|
+
};
|
|
22461
|
+
var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
22462
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
22463
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
22464
|
+
if (result instanceof Promise)
|
|
22465
|
+
result = await result;
|
|
22466
|
+
if (result.issues.length) {
|
|
22467
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
22468
|
+
captureStackTrace(e, params?.callee);
|
|
22469
|
+
throw e;
|
|
22470
|
+
}
|
|
22471
|
+
return result.value;
|
|
22472
|
+
};
|
|
22473
|
+
var _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
22474
|
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
22475
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
22476
|
+
if (result instanceof Promise) {
|
|
22477
|
+
throw new $ZodAsyncError;
|
|
22478
|
+
}
|
|
22479
|
+
return result.issues.length ? {
|
|
22480
|
+
success: false,
|
|
22481
|
+
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
22482
|
+
} : { success: true, data: result.value };
|
|
22483
|
+
};
|
|
22484
|
+
var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
22485
|
+
var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
22486
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
22487
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
22488
|
+
if (result instanceof Promise)
|
|
22489
|
+
result = await result;
|
|
22490
|
+
return result.issues.length ? {
|
|
22491
|
+
success: false,
|
|
22492
|
+
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
22493
|
+
} : { success: true, data: result.value };
|
|
22494
|
+
};
|
|
22495
|
+
var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
22496
|
+
var _encode = (_Err) => (schema, value, _ctx) => {
|
|
22497
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
22498
|
+
return _parse(_Err)(schema, value, ctx);
|
|
22499
|
+
};
|
|
22500
|
+
var _decode = (_Err) => (schema, value, _ctx) => {
|
|
22501
|
+
return _parse(_Err)(schema, value, _ctx);
|
|
22502
|
+
};
|
|
22503
|
+
var _encodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
22504
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
22505
|
+
return _parseAsync(_Err)(schema, value, ctx);
|
|
22506
|
+
};
|
|
22507
|
+
var _decodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
22508
|
+
return _parseAsync(_Err)(schema, value, _ctx);
|
|
22509
|
+
};
|
|
22510
|
+
var _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
22511
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
22512
|
+
return _safeParse(_Err)(schema, value, ctx);
|
|
22513
|
+
};
|
|
22514
|
+
var _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
22515
|
+
return _safeParse(_Err)(schema, value, _ctx);
|
|
22516
|
+
};
|
|
22517
|
+
var _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
22518
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
22519
|
+
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
22520
|
+
};
|
|
22521
|
+
var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
22522
|
+
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
22523
|
+
};
|
|
22524
|
+
// node_modules/zod/v4/core/regexes.js
|
|
22525
|
+
var cuid = /^[cC][^\s-]{8,}$/;
|
|
22526
|
+
var cuid2 = /^[0-9a-z]+$/;
|
|
22527
|
+
var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
|
22528
|
+
var xid = /^[0-9a-vA-V]{20}$/;
|
|
22529
|
+
var ksuid = /^[A-Za-z0-9]{27}$/;
|
|
22530
|
+
var nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
22531
|
+
var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
22532
|
+
var guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
22533
|
+
var uuid = (version) => {
|
|
22534
|
+
if (!version)
|
|
22535
|
+
return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
|
|
22536
|
+
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
22537
|
+
};
|
|
22538
|
+
var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
22539
|
+
var _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
22540
|
+
function emoji() {
|
|
22541
|
+
return new RegExp(_emoji, "u");
|
|
22542
|
+
}
|
|
22543
|
+
var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
22544
|
+
var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
|
|
22545
|
+
var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
22546
|
+
var cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
22547
|
+
var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
22548
|
+
var base64url = /^[A-Za-z0-9_-]*$/;
|
|
22549
|
+
var e164 = /^\+[1-9]\d{6,14}$/;
|
|
22550
|
+
var dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
|
22551
|
+
var date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
|
|
22552
|
+
function timeSource(args) {
|
|
22553
|
+
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
22554
|
+
const regex = typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
22555
|
+
return regex;
|
|
22556
|
+
}
|
|
22557
|
+
function time(args) {
|
|
22558
|
+
return new RegExp(`^${timeSource(args)}$`);
|
|
22559
|
+
}
|
|
22560
|
+
function datetime(args) {
|
|
22561
|
+
const time = timeSource({ precision: args.precision });
|
|
22562
|
+
const opts = ["Z"];
|
|
22563
|
+
if (args.local)
|
|
22564
|
+
opts.push("");
|
|
22565
|
+
if (args.offset)
|
|
22566
|
+
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
22567
|
+
const timeRegex = `${time}(?:${opts.join("|")})`;
|
|
22568
|
+
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
22569
|
+
}
|
|
22570
|
+
var string = (params) => {
|
|
22571
|
+
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
22572
|
+
return new RegExp(`^${regex}$`);
|
|
22573
|
+
};
|
|
22574
|
+
var lowercase = /^[^A-Z]*$/;
|
|
22575
|
+
var uppercase = /^[^a-z]*$/;
|
|
22576
|
+
|
|
22577
|
+
// node_modules/zod/v4/core/checks.js
|
|
22578
|
+
var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
22579
|
+
var _a;
|
|
22580
|
+
inst._zod ?? (inst._zod = {});
|
|
22581
|
+
inst._zod.def = def;
|
|
22582
|
+
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
22583
|
+
});
|
|
22584
|
+
var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
22585
|
+
var _a;
|
|
22586
|
+
$ZodCheck.init(inst, def);
|
|
22587
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
22588
|
+
const val = payload.value;
|
|
22589
|
+
return !nullish(val) && val.length !== undefined;
|
|
22590
|
+
});
|
|
22591
|
+
inst._zod.onattach.push((inst) => {
|
|
22592
|
+
const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
22593
|
+
if (def.maximum < curr)
|
|
22594
|
+
inst._zod.bag.maximum = def.maximum;
|
|
22595
|
+
});
|
|
22596
|
+
inst._zod.check = (payload) => {
|
|
22597
|
+
const input = payload.value;
|
|
22598
|
+
const length = input.length;
|
|
22599
|
+
if (length <= def.maximum)
|
|
22600
|
+
return;
|
|
22601
|
+
const origin = getLengthableOrigin(input);
|
|
22602
|
+
payload.issues.push({
|
|
22603
|
+
origin,
|
|
22604
|
+
code: "too_big",
|
|
22605
|
+
maximum: def.maximum,
|
|
22606
|
+
inclusive: true,
|
|
22607
|
+
input,
|
|
22608
|
+
inst,
|
|
22609
|
+
continue: !def.abort
|
|
22610
|
+
});
|
|
22611
|
+
};
|
|
22612
|
+
});
|
|
22613
|
+
var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
22614
|
+
var _a;
|
|
22615
|
+
$ZodCheck.init(inst, def);
|
|
22616
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
22617
|
+
const val = payload.value;
|
|
22618
|
+
return !nullish(val) && val.length !== undefined;
|
|
22619
|
+
});
|
|
22620
|
+
inst._zod.onattach.push((inst) => {
|
|
22621
|
+
const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
22622
|
+
if (def.minimum > curr)
|
|
22623
|
+
inst._zod.bag.minimum = def.minimum;
|
|
22624
|
+
});
|
|
22625
|
+
inst._zod.check = (payload) => {
|
|
22626
|
+
const input = payload.value;
|
|
22627
|
+
const length = input.length;
|
|
22628
|
+
if (length >= def.minimum)
|
|
22629
|
+
return;
|
|
22630
|
+
const origin = getLengthableOrigin(input);
|
|
22631
|
+
payload.issues.push({
|
|
22632
|
+
origin,
|
|
22633
|
+
code: "too_small",
|
|
22634
|
+
minimum: def.minimum,
|
|
22635
|
+
inclusive: true,
|
|
22636
|
+
input,
|
|
22637
|
+
inst,
|
|
22638
|
+
continue: !def.abort
|
|
22639
|
+
});
|
|
22640
|
+
};
|
|
22641
|
+
});
|
|
22642
|
+
var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
22643
|
+
var _a;
|
|
22644
|
+
$ZodCheck.init(inst, def);
|
|
22645
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
22646
|
+
const val = payload.value;
|
|
22647
|
+
return !nullish(val) && val.length !== undefined;
|
|
22648
|
+
});
|
|
22649
|
+
inst._zod.onattach.push((inst) => {
|
|
22650
|
+
const bag = inst._zod.bag;
|
|
22651
|
+
bag.minimum = def.length;
|
|
22652
|
+
bag.maximum = def.length;
|
|
22653
|
+
bag.length = def.length;
|
|
22654
|
+
});
|
|
22655
|
+
inst._zod.check = (payload) => {
|
|
22656
|
+
const input = payload.value;
|
|
22657
|
+
const length = input.length;
|
|
22658
|
+
if (length === def.length)
|
|
22659
|
+
return;
|
|
22660
|
+
const origin = getLengthableOrigin(input);
|
|
22661
|
+
const tooBig = length > def.length;
|
|
22662
|
+
payload.issues.push({
|
|
22663
|
+
origin,
|
|
22664
|
+
...tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length },
|
|
22665
|
+
inclusive: true,
|
|
22666
|
+
exact: true,
|
|
22667
|
+
input: payload.value,
|
|
22668
|
+
inst,
|
|
22669
|
+
continue: !def.abort
|
|
22670
|
+
});
|
|
22671
|
+
};
|
|
22672
|
+
});
|
|
22673
|
+
var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
22674
|
+
var _a, _b;
|
|
22675
|
+
$ZodCheck.init(inst, def);
|
|
22676
|
+
inst._zod.onattach.push((inst) => {
|
|
22677
|
+
const bag = inst._zod.bag;
|
|
22678
|
+
bag.format = def.format;
|
|
22679
|
+
if (def.pattern) {
|
|
22680
|
+
bag.patterns ?? (bag.patterns = new Set);
|
|
22681
|
+
bag.patterns.add(def.pattern);
|
|
22682
|
+
}
|
|
22683
|
+
});
|
|
22684
|
+
if (def.pattern)
|
|
22685
|
+
(_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
22686
|
+
def.pattern.lastIndex = 0;
|
|
22687
|
+
if (def.pattern.test(payload.value))
|
|
22688
|
+
return;
|
|
22689
|
+
payload.issues.push({
|
|
22690
|
+
origin: "string",
|
|
22691
|
+
code: "invalid_format",
|
|
22692
|
+
format: def.format,
|
|
22693
|
+
input: payload.value,
|
|
22694
|
+
...def.pattern ? { pattern: def.pattern.toString() } : {},
|
|
22695
|
+
inst,
|
|
22696
|
+
continue: !def.abort
|
|
22697
|
+
});
|
|
22698
|
+
});
|
|
22699
|
+
else
|
|
22700
|
+
(_b = inst._zod).check ?? (_b.check = () => {});
|
|
22701
|
+
});
|
|
22702
|
+
var $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
|
|
22703
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
22704
|
+
inst._zod.check = (payload) => {
|
|
22705
|
+
def.pattern.lastIndex = 0;
|
|
22706
|
+
if (def.pattern.test(payload.value))
|
|
22707
|
+
return;
|
|
22708
|
+
payload.issues.push({
|
|
22709
|
+
origin: "string",
|
|
22710
|
+
code: "invalid_format",
|
|
22711
|
+
format: "regex",
|
|
22712
|
+
input: payload.value,
|
|
22713
|
+
pattern: def.pattern.toString(),
|
|
22714
|
+
inst,
|
|
22715
|
+
continue: !def.abort
|
|
22716
|
+
});
|
|
22717
|
+
};
|
|
22718
|
+
});
|
|
22719
|
+
var $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
|
|
22720
|
+
def.pattern ?? (def.pattern = lowercase);
|
|
22721
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
22722
|
+
});
|
|
22723
|
+
var $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
|
|
22724
|
+
def.pattern ?? (def.pattern = uppercase);
|
|
22725
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
22726
|
+
});
|
|
22727
|
+
var $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
22728
|
+
$ZodCheck.init(inst, def);
|
|
22729
|
+
const escapedRegex = escapeRegex(def.includes);
|
|
22730
|
+
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
|
|
22731
|
+
def.pattern = pattern;
|
|
22732
|
+
inst._zod.onattach.push((inst) => {
|
|
22733
|
+
const bag = inst._zod.bag;
|
|
22734
|
+
bag.patterns ?? (bag.patterns = new Set);
|
|
22735
|
+
bag.patterns.add(pattern);
|
|
22736
|
+
});
|
|
22737
|
+
inst._zod.check = (payload) => {
|
|
22738
|
+
if (payload.value.includes(def.includes, def.position))
|
|
22739
|
+
return;
|
|
22740
|
+
payload.issues.push({
|
|
22741
|
+
origin: "string",
|
|
22742
|
+
code: "invalid_format",
|
|
22743
|
+
format: "includes",
|
|
22744
|
+
includes: def.includes,
|
|
22745
|
+
input: payload.value,
|
|
22746
|
+
inst,
|
|
22747
|
+
continue: !def.abort
|
|
22748
|
+
});
|
|
22749
|
+
};
|
|
22750
|
+
});
|
|
22751
|
+
var $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
|
|
22752
|
+
$ZodCheck.init(inst, def);
|
|
22753
|
+
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
22754
|
+
def.pattern ?? (def.pattern = pattern);
|
|
22755
|
+
inst._zod.onattach.push((inst) => {
|
|
22756
|
+
const bag = inst._zod.bag;
|
|
22757
|
+
bag.patterns ?? (bag.patterns = new Set);
|
|
22758
|
+
bag.patterns.add(pattern);
|
|
22759
|
+
});
|
|
22760
|
+
inst._zod.check = (payload) => {
|
|
22761
|
+
if (payload.value.startsWith(def.prefix))
|
|
22762
|
+
return;
|
|
22763
|
+
payload.issues.push({
|
|
22764
|
+
origin: "string",
|
|
22765
|
+
code: "invalid_format",
|
|
22766
|
+
format: "starts_with",
|
|
22767
|
+
prefix: def.prefix,
|
|
22768
|
+
input: payload.value,
|
|
22769
|
+
inst,
|
|
22770
|
+
continue: !def.abort
|
|
22771
|
+
});
|
|
22772
|
+
};
|
|
22773
|
+
});
|
|
22774
|
+
var $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
|
|
22775
|
+
$ZodCheck.init(inst, def);
|
|
22776
|
+
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
22777
|
+
def.pattern ?? (def.pattern = pattern);
|
|
22778
|
+
inst._zod.onattach.push((inst) => {
|
|
22779
|
+
const bag = inst._zod.bag;
|
|
22780
|
+
bag.patterns ?? (bag.patterns = new Set);
|
|
22781
|
+
bag.patterns.add(pattern);
|
|
22782
|
+
});
|
|
22783
|
+
inst._zod.check = (payload) => {
|
|
22784
|
+
if (payload.value.endsWith(def.suffix))
|
|
22785
|
+
return;
|
|
22786
|
+
payload.issues.push({
|
|
22787
|
+
origin: "string",
|
|
22788
|
+
code: "invalid_format",
|
|
22789
|
+
format: "ends_with",
|
|
22790
|
+
suffix: def.suffix,
|
|
22791
|
+
input: payload.value,
|
|
22792
|
+
inst,
|
|
22793
|
+
continue: !def.abort
|
|
22794
|
+
});
|
|
22795
|
+
};
|
|
22796
|
+
});
|
|
22797
|
+
var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
22798
|
+
$ZodCheck.init(inst, def);
|
|
22799
|
+
inst._zod.check = (payload) => {
|
|
22800
|
+
payload.value = def.tx(payload.value);
|
|
22801
|
+
};
|
|
22802
|
+
});
|
|
22803
|
+
|
|
22804
|
+
// node_modules/zod/v4/core/doc.js
|
|
22805
|
+
class Doc {
|
|
22806
|
+
constructor(args = []) {
|
|
22807
|
+
this.content = [];
|
|
22808
|
+
this.indent = 0;
|
|
22809
|
+
if (this)
|
|
22810
|
+
this.args = args;
|
|
22811
|
+
}
|
|
22812
|
+
indented(fn) {
|
|
22813
|
+
this.indent += 1;
|
|
22814
|
+
fn(this);
|
|
22815
|
+
this.indent -= 1;
|
|
22816
|
+
}
|
|
22817
|
+
write(arg) {
|
|
22818
|
+
if (typeof arg === "function") {
|
|
22819
|
+
arg(this, { execution: "sync" });
|
|
22820
|
+
arg(this, { execution: "async" });
|
|
22821
|
+
return;
|
|
22822
|
+
}
|
|
22823
|
+
const content = arg;
|
|
22824
|
+
const lines = content.split(`
|
|
22825
|
+
`).filter((x) => x);
|
|
22826
|
+
const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
|
|
22827
|
+
const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
|
|
22828
|
+
for (const line of dedented) {
|
|
22829
|
+
this.content.push(line);
|
|
22830
|
+
}
|
|
22831
|
+
}
|
|
22832
|
+
compile() {
|
|
22833
|
+
const F = Function;
|
|
22834
|
+
const args = this?.args;
|
|
22835
|
+
const content = this?.content ?? [``];
|
|
22836
|
+
const lines = [...content.map((x) => ` ${x}`)];
|
|
22837
|
+
return new F(...args, lines.join(`
|
|
22838
|
+
`));
|
|
22839
|
+
}
|
|
22840
|
+
}
|
|
22841
|
+
|
|
22842
|
+
// node_modules/zod/v4/core/versions.js
|
|
22843
|
+
var version = {
|
|
22844
|
+
major: 4,
|
|
22845
|
+
minor: 3,
|
|
22846
|
+
patch: 6
|
|
22847
|
+
};
|
|
22848
|
+
|
|
22849
|
+
// node_modules/zod/v4/core/schemas.js
|
|
22850
|
+
var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
22851
|
+
var _a;
|
|
22852
|
+
inst ?? (inst = {});
|
|
22853
|
+
inst._zod.def = def;
|
|
22854
|
+
inst._zod.bag = inst._zod.bag || {};
|
|
22855
|
+
inst._zod.version = version;
|
|
22856
|
+
const checks = [...inst._zod.def.checks ?? []];
|
|
22857
|
+
if (inst._zod.traits.has("$ZodCheck")) {
|
|
22858
|
+
checks.unshift(inst);
|
|
22859
|
+
}
|
|
22860
|
+
for (const ch of checks) {
|
|
22861
|
+
for (const fn of ch._zod.onattach) {
|
|
22862
|
+
fn(inst);
|
|
22863
|
+
}
|
|
22864
|
+
}
|
|
22865
|
+
if (checks.length === 0) {
|
|
22866
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
22867
|
+
inst._zod.deferred?.push(() => {
|
|
22868
|
+
inst._zod.run = inst._zod.parse;
|
|
22869
|
+
});
|
|
22870
|
+
} else {
|
|
22871
|
+
const runChecks = (payload, checks, ctx) => {
|
|
22872
|
+
let isAborted = aborted(payload);
|
|
22873
|
+
let asyncResult;
|
|
22874
|
+
for (const ch of checks) {
|
|
22875
|
+
if (ch._zod.def.when) {
|
|
22876
|
+
const shouldRun = ch._zod.def.when(payload);
|
|
22877
|
+
if (!shouldRun)
|
|
22878
|
+
continue;
|
|
22879
|
+
} else if (isAborted) {
|
|
22880
|
+
continue;
|
|
22881
|
+
}
|
|
22882
|
+
const currLen = payload.issues.length;
|
|
22883
|
+
const _ = ch._zod.check(payload);
|
|
22884
|
+
if (_ instanceof Promise && ctx?.async === false) {
|
|
22885
|
+
throw new $ZodAsyncError;
|
|
22886
|
+
}
|
|
22887
|
+
if (asyncResult || _ instanceof Promise) {
|
|
22888
|
+
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
22889
|
+
await _;
|
|
22890
|
+
const nextLen = payload.issues.length;
|
|
22891
|
+
if (nextLen === currLen)
|
|
22892
|
+
return;
|
|
22893
|
+
if (!isAborted)
|
|
22894
|
+
isAborted = aborted(payload, currLen);
|
|
22895
|
+
});
|
|
22896
|
+
} else {
|
|
22897
|
+
const nextLen = payload.issues.length;
|
|
22898
|
+
if (nextLen === currLen)
|
|
22899
|
+
continue;
|
|
22900
|
+
if (!isAborted)
|
|
22901
|
+
isAborted = aborted(payload, currLen);
|
|
22902
|
+
}
|
|
22903
|
+
}
|
|
22904
|
+
if (asyncResult) {
|
|
22905
|
+
return asyncResult.then(() => {
|
|
22906
|
+
return payload;
|
|
22907
|
+
});
|
|
22908
|
+
}
|
|
22909
|
+
return payload;
|
|
22910
|
+
};
|
|
22911
|
+
const handleCanaryResult = (canary, payload, ctx) => {
|
|
22912
|
+
if (aborted(canary)) {
|
|
22913
|
+
canary.aborted = true;
|
|
22914
|
+
return canary;
|
|
22915
|
+
}
|
|
22916
|
+
const checkResult = runChecks(payload, checks, ctx);
|
|
22917
|
+
if (checkResult instanceof Promise) {
|
|
22918
|
+
if (ctx.async === false)
|
|
22919
|
+
throw new $ZodAsyncError;
|
|
22920
|
+
return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
|
|
22921
|
+
}
|
|
22922
|
+
return inst._zod.parse(checkResult, ctx);
|
|
22923
|
+
};
|
|
22924
|
+
inst._zod.run = (payload, ctx) => {
|
|
22925
|
+
if (ctx.skipChecks) {
|
|
22926
|
+
return inst._zod.parse(payload, ctx);
|
|
22927
|
+
}
|
|
22928
|
+
if (ctx.direction === "backward") {
|
|
22929
|
+
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
|
|
22930
|
+
if (canary instanceof Promise) {
|
|
22931
|
+
return canary.then((canary) => {
|
|
22932
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
22933
|
+
});
|
|
22934
|
+
}
|
|
22935
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
22936
|
+
}
|
|
22937
|
+
const result = inst._zod.parse(payload, ctx);
|
|
22938
|
+
if (result instanceof Promise) {
|
|
22939
|
+
if (ctx.async === false)
|
|
22940
|
+
throw new $ZodAsyncError;
|
|
22941
|
+
return result.then((result) => runChecks(result, checks, ctx));
|
|
22942
|
+
}
|
|
22943
|
+
return runChecks(result, checks, ctx);
|
|
22944
|
+
};
|
|
22945
|
+
}
|
|
22946
|
+
defineLazy(inst, "~standard", () => ({
|
|
22947
|
+
validate: (value) => {
|
|
22948
|
+
try {
|
|
22949
|
+
const r = safeParse(inst, value);
|
|
22950
|
+
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
22951
|
+
} catch (_) {
|
|
22952
|
+
return safeParseAsync(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
|
|
22953
|
+
}
|
|
22954
|
+
},
|
|
22955
|
+
vendor: "zod",
|
|
22956
|
+
version: 1
|
|
22957
|
+
}));
|
|
22958
|
+
});
|
|
22959
|
+
var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
22960
|
+
$ZodType.init(inst, def);
|
|
22961
|
+
inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string(inst._zod.bag);
|
|
22962
|
+
inst._zod.parse = (payload, _) => {
|
|
22963
|
+
if (def.coerce)
|
|
22964
|
+
try {
|
|
22965
|
+
payload.value = String(payload.value);
|
|
22966
|
+
} catch (_) {}
|
|
22967
|
+
if (typeof payload.value === "string")
|
|
22968
|
+
return payload;
|
|
22969
|
+
payload.issues.push({
|
|
22970
|
+
expected: "string",
|
|
22971
|
+
code: "invalid_type",
|
|
22972
|
+
input: payload.value,
|
|
22973
|
+
inst
|
|
22974
|
+
});
|
|
22975
|
+
return payload;
|
|
22976
|
+
};
|
|
22977
|
+
});
|
|
22978
|
+
var $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
|
|
22979
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
22980
|
+
$ZodString.init(inst, def);
|
|
22981
|
+
});
|
|
22982
|
+
var $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
|
|
22983
|
+
def.pattern ?? (def.pattern = guid);
|
|
22984
|
+
$ZodStringFormat.init(inst, def);
|
|
22985
|
+
});
|
|
22986
|
+
var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
|
|
22987
|
+
if (def.version) {
|
|
22988
|
+
const versionMap = {
|
|
22989
|
+
v1: 1,
|
|
22990
|
+
v2: 2,
|
|
22991
|
+
v3: 3,
|
|
22992
|
+
v4: 4,
|
|
22993
|
+
v5: 5,
|
|
22994
|
+
v6: 6,
|
|
22995
|
+
v7: 7,
|
|
22996
|
+
v8: 8
|
|
22997
|
+
};
|
|
22998
|
+
const v = versionMap[def.version];
|
|
22999
|
+
if (v === undefined)
|
|
23000
|
+
throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
23001
|
+
def.pattern ?? (def.pattern = uuid(v));
|
|
23002
|
+
} else
|
|
23003
|
+
def.pattern ?? (def.pattern = uuid());
|
|
23004
|
+
$ZodStringFormat.init(inst, def);
|
|
23005
|
+
});
|
|
23006
|
+
var $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
|
|
23007
|
+
def.pattern ?? (def.pattern = email);
|
|
23008
|
+
$ZodStringFormat.init(inst, def);
|
|
23009
|
+
});
|
|
23010
|
+
var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
23011
|
+
$ZodStringFormat.init(inst, def);
|
|
23012
|
+
inst._zod.check = (payload) => {
|
|
23013
|
+
try {
|
|
23014
|
+
const trimmed = payload.value.trim();
|
|
23015
|
+
const url = new URL(trimmed);
|
|
23016
|
+
if (def.hostname) {
|
|
23017
|
+
def.hostname.lastIndex = 0;
|
|
23018
|
+
if (!def.hostname.test(url.hostname)) {
|
|
23019
|
+
payload.issues.push({
|
|
23020
|
+
code: "invalid_format",
|
|
23021
|
+
format: "url",
|
|
23022
|
+
note: "Invalid hostname",
|
|
23023
|
+
pattern: def.hostname.source,
|
|
23024
|
+
input: payload.value,
|
|
23025
|
+
inst,
|
|
23026
|
+
continue: !def.abort
|
|
23027
|
+
});
|
|
23028
|
+
}
|
|
23029
|
+
}
|
|
23030
|
+
if (def.protocol) {
|
|
23031
|
+
def.protocol.lastIndex = 0;
|
|
23032
|
+
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
|
|
23033
|
+
payload.issues.push({
|
|
23034
|
+
code: "invalid_format",
|
|
23035
|
+
format: "url",
|
|
23036
|
+
note: "Invalid protocol",
|
|
23037
|
+
pattern: def.protocol.source,
|
|
23038
|
+
input: payload.value,
|
|
23039
|
+
inst,
|
|
23040
|
+
continue: !def.abort
|
|
23041
|
+
});
|
|
23042
|
+
}
|
|
23043
|
+
}
|
|
23044
|
+
if (def.normalize) {
|
|
23045
|
+
payload.value = url.href;
|
|
23046
|
+
} else {
|
|
23047
|
+
payload.value = trimmed;
|
|
23048
|
+
}
|
|
23049
|
+
return;
|
|
23050
|
+
} catch (_) {
|
|
23051
|
+
payload.issues.push({
|
|
23052
|
+
code: "invalid_format",
|
|
23053
|
+
format: "url",
|
|
23054
|
+
input: payload.value,
|
|
23055
|
+
inst,
|
|
23056
|
+
continue: !def.abort
|
|
23057
|
+
});
|
|
23058
|
+
}
|
|
23059
|
+
};
|
|
23060
|
+
});
|
|
23061
|
+
var $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
|
|
23062
|
+
def.pattern ?? (def.pattern = emoji());
|
|
23063
|
+
$ZodStringFormat.init(inst, def);
|
|
23064
|
+
});
|
|
23065
|
+
var $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
|
|
23066
|
+
def.pattern ?? (def.pattern = nanoid);
|
|
23067
|
+
$ZodStringFormat.init(inst, def);
|
|
23068
|
+
});
|
|
23069
|
+
var $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
|
|
23070
|
+
def.pattern ?? (def.pattern = cuid);
|
|
23071
|
+
$ZodStringFormat.init(inst, def);
|
|
23072
|
+
});
|
|
23073
|
+
var $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
|
|
23074
|
+
def.pattern ?? (def.pattern = cuid2);
|
|
23075
|
+
$ZodStringFormat.init(inst, def);
|
|
23076
|
+
});
|
|
23077
|
+
var $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
|
|
23078
|
+
def.pattern ?? (def.pattern = ulid);
|
|
23079
|
+
$ZodStringFormat.init(inst, def);
|
|
23080
|
+
});
|
|
23081
|
+
var $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
|
|
23082
|
+
def.pattern ?? (def.pattern = xid);
|
|
23083
|
+
$ZodStringFormat.init(inst, def);
|
|
23084
|
+
});
|
|
23085
|
+
var $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
|
|
23086
|
+
def.pattern ?? (def.pattern = ksuid);
|
|
23087
|
+
$ZodStringFormat.init(inst, def);
|
|
23088
|
+
});
|
|
23089
|
+
var $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
|
|
23090
|
+
def.pattern ?? (def.pattern = datetime(def));
|
|
23091
|
+
$ZodStringFormat.init(inst, def);
|
|
23092
|
+
});
|
|
23093
|
+
var $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
|
|
23094
|
+
def.pattern ?? (def.pattern = date);
|
|
23095
|
+
$ZodStringFormat.init(inst, def);
|
|
23096
|
+
});
|
|
23097
|
+
var $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
|
|
23098
|
+
def.pattern ?? (def.pattern = time(def));
|
|
23099
|
+
$ZodStringFormat.init(inst, def);
|
|
23100
|
+
});
|
|
23101
|
+
var $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
|
|
23102
|
+
def.pattern ?? (def.pattern = duration);
|
|
23103
|
+
$ZodStringFormat.init(inst, def);
|
|
23104
|
+
});
|
|
23105
|
+
var $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
|
|
23106
|
+
def.pattern ?? (def.pattern = ipv4);
|
|
23107
|
+
$ZodStringFormat.init(inst, def);
|
|
23108
|
+
inst._zod.bag.format = `ipv4`;
|
|
23109
|
+
});
|
|
23110
|
+
var $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
|
|
23111
|
+
def.pattern ?? (def.pattern = ipv6);
|
|
23112
|
+
$ZodStringFormat.init(inst, def);
|
|
23113
|
+
inst._zod.bag.format = `ipv6`;
|
|
23114
|
+
inst._zod.check = (payload) => {
|
|
23115
|
+
try {
|
|
23116
|
+
new URL(`http://[${payload.value}]`);
|
|
23117
|
+
} catch {
|
|
23118
|
+
payload.issues.push({
|
|
23119
|
+
code: "invalid_format",
|
|
23120
|
+
format: "ipv6",
|
|
23121
|
+
input: payload.value,
|
|
23122
|
+
inst,
|
|
23123
|
+
continue: !def.abort
|
|
23124
|
+
});
|
|
23125
|
+
}
|
|
23126
|
+
};
|
|
23127
|
+
});
|
|
23128
|
+
var $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
23129
|
+
def.pattern ?? (def.pattern = cidrv4);
|
|
23130
|
+
$ZodStringFormat.init(inst, def);
|
|
23131
|
+
});
|
|
23132
|
+
var $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
23133
|
+
def.pattern ?? (def.pattern = cidrv6);
|
|
23134
|
+
$ZodStringFormat.init(inst, def);
|
|
23135
|
+
inst._zod.check = (payload) => {
|
|
23136
|
+
const parts = payload.value.split("/");
|
|
23137
|
+
try {
|
|
23138
|
+
if (parts.length !== 2)
|
|
23139
|
+
throw new Error;
|
|
23140
|
+
const [address, prefix] = parts;
|
|
23141
|
+
if (!prefix)
|
|
23142
|
+
throw new Error;
|
|
23143
|
+
const prefixNum = Number(prefix);
|
|
23144
|
+
if (`${prefixNum}` !== prefix)
|
|
23145
|
+
throw new Error;
|
|
23146
|
+
if (prefixNum < 0 || prefixNum > 128)
|
|
23147
|
+
throw new Error;
|
|
23148
|
+
new URL(`http://[${address}]`);
|
|
23149
|
+
} catch {
|
|
23150
|
+
payload.issues.push({
|
|
23151
|
+
code: "invalid_format",
|
|
23152
|
+
format: "cidrv6",
|
|
23153
|
+
input: payload.value,
|
|
23154
|
+
inst,
|
|
23155
|
+
continue: !def.abort
|
|
23156
|
+
});
|
|
23157
|
+
}
|
|
23158
|
+
};
|
|
23159
|
+
});
|
|
23160
|
+
function isValidBase64(data) {
|
|
23161
|
+
if (data === "")
|
|
23162
|
+
return true;
|
|
23163
|
+
if (data.length % 4 !== 0)
|
|
23164
|
+
return false;
|
|
23165
|
+
try {
|
|
23166
|
+
atob(data);
|
|
23167
|
+
return true;
|
|
23168
|
+
} catch {
|
|
23169
|
+
return false;
|
|
23170
|
+
}
|
|
23171
|
+
}
|
|
23172
|
+
var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
23173
|
+
def.pattern ?? (def.pattern = base64);
|
|
23174
|
+
$ZodStringFormat.init(inst, def);
|
|
23175
|
+
inst._zod.bag.contentEncoding = "base64";
|
|
23176
|
+
inst._zod.check = (payload) => {
|
|
23177
|
+
if (isValidBase64(payload.value))
|
|
23178
|
+
return;
|
|
23179
|
+
payload.issues.push({
|
|
23180
|
+
code: "invalid_format",
|
|
23181
|
+
format: "base64",
|
|
23182
|
+
input: payload.value,
|
|
23183
|
+
inst,
|
|
23184
|
+
continue: !def.abort
|
|
23185
|
+
});
|
|
23186
|
+
};
|
|
23187
|
+
});
|
|
23188
|
+
function isValidBase64URL(data) {
|
|
23189
|
+
if (!base64url.test(data))
|
|
23190
|
+
return false;
|
|
23191
|
+
const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
23192
|
+
const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
|
|
23193
|
+
return isValidBase64(padded);
|
|
23194
|
+
}
|
|
23195
|
+
var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
|
|
23196
|
+
def.pattern ?? (def.pattern = base64url);
|
|
23197
|
+
$ZodStringFormat.init(inst, def);
|
|
23198
|
+
inst._zod.bag.contentEncoding = "base64url";
|
|
23199
|
+
inst._zod.check = (payload) => {
|
|
23200
|
+
if (isValidBase64URL(payload.value))
|
|
23201
|
+
return;
|
|
23202
|
+
payload.issues.push({
|
|
23203
|
+
code: "invalid_format",
|
|
23204
|
+
format: "base64url",
|
|
23205
|
+
input: payload.value,
|
|
23206
|
+
inst,
|
|
23207
|
+
continue: !def.abort
|
|
23208
|
+
});
|
|
23209
|
+
};
|
|
23210
|
+
});
|
|
23211
|
+
var $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
|
|
23212
|
+
def.pattern ?? (def.pattern = e164);
|
|
23213
|
+
$ZodStringFormat.init(inst, def);
|
|
23214
|
+
});
|
|
23215
|
+
function isValidJWT(token, algorithm = null) {
|
|
23216
|
+
try {
|
|
23217
|
+
const tokensParts = token.split(".");
|
|
23218
|
+
if (tokensParts.length !== 3)
|
|
23219
|
+
return false;
|
|
23220
|
+
const [header] = tokensParts;
|
|
23221
|
+
if (!header)
|
|
23222
|
+
return false;
|
|
23223
|
+
const parsedHeader = JSON.parse(atob(header));
|
|
23224
|
+
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
|
|
23225
|
+
return false;
|
|
23226
|
+
if (!parsedHeader.alg)
|
|
23227
|
+
return false;
|
|
23228
|
+
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
|
|
23229
|
+
return false;
|
|
23230
|
+
return true;
|
|
23231
|
+
} catch {
|
|
23232
|
+
return false;
|
|
23233
|
+
}
|
|
23234
|
+
}
|
|
23235
|
+
var $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
|
|
23236
|
+
$ZodStringFormat.init(inst, def);
|
|
23237
|
+
inst._zod.check = (payload) => {
|
|
23238
|
+
if (isValidJWT(payload.value, def.alg))
|
|
23239
|
+
return;
|
|
23240
|
+
payload.issues.push({
|
|
23241
|
+
code: "invalid_format",
|
|
23242
|
+
format: "jwt",
|
|
23243
|
+
input: payload.value,
|
|
23244
|
+
inst,
|
|
23245
|
+
continue: !def.abort
|
|
23246
|
+
});
|
|
23247
|
+
};
|
|
23248
|
+
});
|
|
23249
|
+
var $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
|
|
23250
|
+
$ZodType.init(inst, def);
|
|
23251
|
+
inst._zod.parse = (payload) => payload;
|
|
23252
|
+
});
|
|
23253
|
+
var $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
|
|
23254
|
+
$ZodType.init(inst, def);
|
|
23255
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
23256
|
+
payload.issues.push({
|
|
23257
|
+
expected: "never",
|
|
23258
|
+
code: "invalid_type",
|
|
23259
|
+
input: payload.value,
|
|
23260
|
+
inst
|
|
23261
|
+
});
|
|
23262
|
+
return payload;
|
|
23263
|
+
};
|
|
23264
|
+
});
|
|
23265
|
+
function handleArrayResult(result, final, index) {
|
|
23266
|
+
if (result.issues.length) {
|
|
23267
|
+
final.issues.push(...prefixIssues(index, result.issues));
|
|
23268
|
+
}
|
|
23269
|
+
final.value[index] = result.value;
|
|
23270
|
+
}
|
|
23271
|
+
var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
23272
|
+
$ZodType.init(inst, def);
|
|
23273
|
+
inst._zod.parse = (payload, ctx) => {
|
|
23274
|
+
const input = payload.value;
|
|
23275
|
+
if (!Array.isArray(input)) {
|
|
23276
|
+
payload.issues.push({
|
|
23277
|
+
expected: "array",
|
|
23278
|
+
code: "invalid_type",
|
|
23279
|
+
input,
|
|
23280
|
+
inst
|
|
23281
|
+
});
|
|
23282
|
+
return payload;
|
|
23283
|
+
}
|
|
23284
|
+
payload.value = Array(input.length);
|
|
23285
|
+
const proms = [];
|
|
23286
|
+
for (let i = 0;i < input.length; i++) {
|
|
23287
|
+
const item = input[i];
|
|
23288
|
+
const result = def.element._zod.run({
|
|
23289
|
+
value: item,
|
|
23290
|
+
issues: []
|
|
23291
|
+
}, ctx);
|
|
23292
|
+
if (result instanceof Promise) {
|
|
23293
|
+
proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
|
23294
|
+
} else {
|
|
23295
|
+
handleArrayResult(result, payload, i);
|
|
23296
|
+
}
|
|
23297
|
+
}
|
|
23298
|
+
if (proms.length) {
|
|
23299
|
+
return Promise.all(proms).then(() => payload);
|
|
23300
|
+
}
|
|
23301
|
+
return payload;
|
|
23302
|
+
};
|
|
23303
|
+
});
|
|
23304
|
+
function handlePropertyResult(result, final, key, input, isOptionalOut) {
|
|
23305
|
+
if (result.issues.length) {
|
|
23306
|
+
if (isOptionalOut && !(key in input)) {
|
|
23307
|
+
return;
|
|
23308
|
+
}
|
|
23309
|
+
final.issues.push(...prefixIssues(key, result.issues));
|
|
23310
|
+
}
|
|
23311
|
+
if (result.value === undefined) {
|
|
23312
|
+
if (key in input) {
|
|
23313
|
+
final.value[key] = undefined;
|
|
23314
|
+
}
|
|
23315
|
+
} else {
|
|
23316
|
+
final.value[key] = result.value;
|
|
23317
|
+
}
|
|
23318
|
+
}
|
|
23319
|
+
function normalizeDef(def) {
|
|
23320
|
+
const keys = Object.keys(def.shape);
|
|
23321
|
+
for (const k of keys) {
|
|
23322
|
+
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
|
|
23323
|
+
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
23324
|
+
}
|
|
23325
|
+
}
|
|
23326
|
+
const okeys = optionalKeys(def.shape);
|
|
23327
|
+
return {
|
|
23328
|
+
...def,
|
|
23329
|
+
keys,
|
|
23330
|
+
keySet: new Set(keys),
|
|
23331
|
+
numKeys: keys.length,
|
|
23332
|
+
optionalKeys: new Set(okeys)
|
|
23333
|
+
};
|
|
23334
|
+
}
|
|
23335
|
+
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
23336
|
+
const unrecognized = [];
|
|
23337
|
+
const keySet = def.keySet;
|
|
23338
|
+
const _catchall = def.catchall._zod;
|
|
23339
|
+
const t = _catchall.def.type;
|
|
23340
|
+
const isOptionalOut = _catchall.optout === "optional";
|
|
23341
|
+
for (const key in input) {
|
|
23342
|
+
if (keySet.has(key))
|
|
23343
|
+
continue;
|
|
23344
|
+
if (t === "never") {
|
|
23345
|
+
unrecognized.push(key);
|
|
23346
|
+
continue;
|
|
23347
|
+
}
|
|
23348
|
+
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
23349
|
+
if (r instanceof Promise) {
|
|
23350
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
|
|
23351
|
+
} else {
|
|
23352
|
+
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
23353
|
+
}
|
|
23354
|
+
}
|
|
23355
|
+
if (unrecognized.length) {
|
|
23356
|
+
payload.issues.push({
|
|
23357
|
+
code: "unrecognized_keys",
|
|
23358
|
+
keys: unrecognized,
|
|
23359
|
+
input,
|
|
23360
|
+
inst
|
|
23361
|
+
});
|
|
23362
|
+
}
|
|
23363
|
+
if (!proms.length)
|
|
23364
|
+
return payload;
|
|
23365
|
+
return Promise.all(proms).then(() => {
|
|
23366
|
+
return payload;
|
|
23367
|
+
});
|
|
23368
|
+
}
|
|
23369
|
+
var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
23370
|
+
$ZodType.init(inst, def);
|
|
23371
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
23372
|
+
if (!desc?.get) {
|
|
23373
|
+
const sh = def.shape;
|
|
23374
|
+
Object.defineProperty(def, "shape", {
|
|
23375
|
+
get: () => {
|
|
23376
|
+
const newSh = { ...sh };
|
|
23377
|
+
Object.defineProperty(def, "shape", {
|
|
23378
|
+
value: newSh
|
|
23379
|
+
});
|
|
23380
|
+
return newSh;
|
|
23381
|
+
}
|
|
23382
|
+
});
|
|
23383
|
+
}
|
|
23384
|
+
const _normalized = cached(() => normalizeDef(def));
|
|
23385
|
+
defineLazy(inst._zod, "propValues", () => {
|
|
23386
|
+
const shape = def.shape;
|
|
23387
|
+
const propValues = {};
|
|
23388
|
+
for (const key in shape) {
|
|
23389
|
+
const field = shape[key]._zod;
|
|
23390
|
+
if (field.values) {
|
|
23391
|
+
propValues[key] ?? (propValues[key] = new Set);
|
|
23392
|
+
for (const v of field.values)
|
|
23393
|
+
propValues[key].add(v);
|
|
23394
|
+
}
|
|
23395
|
+
}
|
|
23396
|
+
return propValues;
|
|
23397
|
+
});
|
|
23398
|
+
const isObject2 = isObject;
|
|
23399
|
+
const catchall = def.catchall;
|
|
23400
|
+
let value;
|
|
23401
|
+
inst._zod.parse = (payload, ctx) => {
|
|
23402
|
+
value ?? (value = _normalized.value);
|
|
23403
|
+
const input = payload.value;
|
|
23404
|
+
if (!isObject2(input)) {
|
|
23405
|
+
payload.issues.push({
|
|
23406
|
+
expected: "object",
|
|
23407
|
+
code: "invalid_type",
|
|
23408
|
+
input,
|
|
23409
|
+
inst
|
|
23410
|
+
});
|
|
23411
|
+
return payload;
|
|
23412
|
+
}
|
|
23413
|
+
payload.value = {};
|
|
23414
|
+
const proms = [];
|
|
23415
|
+
const shape = value.shape;
|
|
23416
|
+
for (const key of value.keys) {
|
|
23417
|
+
const el = shape[key];
|
|
23418
|
+
const isOptionalOut = el._zod.optout === "optional";
|
|
23419
|
+
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
23420
|
+
if (r instanceof Promise) {
|
|
23421
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
|
|
23422
|
+
} else {
|
|
23423
|
+
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
23424
|
+
}
|
|
23425
|
+
}
|
|
23426
|
+
if (!catchall) {
|
|
23427
|
+
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
23428
|
+
}
|
|
23429
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
23430
|
+
};
|
|
23431
|
+
});
|
|
23432
|
+
var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
23433
|
+
$ZodObject.init(inst, def);
|
|
23434
|
+
const superParse = inst._zod.parse;
|
|
23435
|
+
const _normalized = cached(() => normalizeDef(def));
|
|
23436
|
+
const generateFastpass = (shape) => {
|
|
23437
|
+
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
23438
|
+
const normalized = _normalized.value;
|
|
23439
|
+
const parseStr = (key) => {
|
|
23440
|
+
const k = esc(key);
|
|
23441
|
+
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
23442
|
+
};
|
|
23443
|
+
doc.write(`const input = payload.value;`);
|
|
23444
|
+
const ids = Object.create(null);
|
|
23445
|
+
let counter = 0;
|
|
23446
|
+
for (const key of normalized.keys) {
|
|
23447
|
+
ids[key] = `key_${counter++}`;
|
|
23448
|
+
}
|
|
23449
|
+
doc.write(`const newResult = {};`);
|
|
23450
|
+
for (const key of normalized.keys) {
|
|
23451
|
+
const id = ids[key];
|
|
23452
|
+
const k = esc(key);
|
|
23453
|
+
const schema = shape[key];
|
|
23454
|
+
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
23455
|
+
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
23456
|
+
if (isOptionalOut) {
|
|
23457
|
+
doc.write(`
|
|
23458
|
+
if (${id}.issues.length) {
|
|
23459
|
+
if (${k} in input) {
|
|
23460
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
23461
|
+
...iss,
|
|
23462
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
23463
|
+
})));
|
|
23464
|
+
}
|
|
23465
|
+
}
|
|
23466
|
+
|
|
23467
|
+
if (${id}.value === undefined) {
|
|
23468
|
+
if (${k} in input) {
|
|
23469
|
+
newResult[${k}] = undefined;
|
|
23470
|
+
}
|
|
23471
|
+
} else {
|
|
23472
|
+
newResult[${k}] = ${id}.value;
|
|
23473
|
+
}
|
|
23474
|
+
|
|
23475
|
+
`);
|
|
23476
|
+
} else {
|
|
23477
|
+
doc.write(`
|
|
23478
|
+
if (${id}.issues.length) {
|
|
23479
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
23480
|
+
...iss,
|
|
23481
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
23482
|
+
})));
|
|
23483
|
+
}
|
|
23484
|
+
|
|
23485
|
+
if (${id}.value === undefined) {
|
|
23486
|
+
if (${k} in input) {
|
|
23487
|
+
newResult[${k}] = undefined;
|
|
23488
|
+
}
|
|
23489
|
+
} else {
|
|
23490
|
+
newResult[${k}] = ${id}.value;
|
|
23491
|
+
}
|
|
23492
|
+
|
|
23493
|
+
`);
|
|
23494
|
+
}
|
|
23495
|
+
}
|
|
23496
|
+
doc.write(`payload.value = newResult;`);
|
|
23497
|
+
doc.write(`return payload;`);
|
|
23498
|
+
const fn = doc.compile();
|
|
23499
|
+
return (payload, ctx) => fn(shape, payload, ctx);
|
|
23500
|
+
};
|
|
23501
|
+
let fastpass;
|
|
23502
|
+
const isObject2 = isObject;
|
|
23503
|
+
const jit = !globalConfig.jitless;
|
|
23504
|
+
const allowsEval2 = allowsEval;
|
|
23505
|
+
const fastEnabled = jit && allowsEval2.value;
|
|
23506
|
+
const catchall = def.catchall;
|
|
23507
|
+
let value;
|
|
23508
|
+
inst._zod.parse = (payload, ctx) => {
|
|
23509
|
+
value ?? (value = _normalized.value);
|
|
23510
|
+
const input = payload.value;
|
|
23511
|
+
if (!isObject2(input)) {
|
|
23512
|
+
payload.issues.push({
|
|
23513
|
+
expected: "object",
|
|
23514
|
+
code: "invalid_type",
|
|
23515
|
+
input,
|
|
23516
|
+
inst
|
|
23517
|
+
});
|
|
23518
|
+
return payload;
|
|
23519
|
+
}
|
|
23520
|
+
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
|
23521
|
+
if (!fastpass)
|
|
23522
|
+
fastpass = generateFastpass(def.shape);
|
|
23523
|
+
payload = fastpass(payload, ctx);
|
|
23524
|
+
if (!catchall)
|
|
23525
|
+
return payload;
|
|
23526
|
+
return handleCatchall([], input, payload, ctx, value, inst);
|
|
23527
|
+
}
|
|
23528
|
+
return superParse(payload, ctx);
|
|
23529
|
+
};
|
|
23530
|
+
});
|
|
23531
|
+
function handleUnionResults(results, final, inst, ctx) {
|
|
23532
|
+
for (const result of results) {
|
|
23533
|
+
if (result.issues.length === 0) {
|
|
23534
|
+
final.value = result.value;
|
|
23535
|
+
return final;
|
|
23536
|
+
}
|
|
23537
|
+
}
|
|
23538
|
+
const nonaborted = results.filter((r) => !aborted(r));
|
|
23539
|
+
if (nonaborted.length === 1) {
|
|
23540
|
+
final.value = nonaborted[0].value;
|
|
23541
|
+
return nonaborted[0];
|
|
23542
|
+
}
|
|
23543
|
+
final.issues.push({
|
|
23544
|
+
code: "invalid_union",
|
|
23545
|
+
input: final.value,
|
|
23546
|
+
inst,
|
|
23547
|
+
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
23548
|
+
});
|
|
23549
|
+
return final;
|
|
23550
|
+
}
|
|
23551
|
+
var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
23552
|
+
$ZodType.init(inst, def);
|
|
23553
|
+
defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined);
|
|
23554
|
+
defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
|
|
23555
|
+
defineLazy(inst._zod, "values", () => {
|
|
23556
|
+
if (def.options.every((o) => o._zod.values)) {
|
|
23557
|
+
return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
23558
|
+
}
|
|
23559
|
+
return;
|
|
23560
|
+
});
|
|
23561
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
23562
|
+
if (def.options.every((o) => o._zod.pattern)) {
|
|
23563
|
+
const patterns = def.options.map((o) => o._zod.pattern);
|
|
23564
|
+
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
23565
|
+
}
|
|
23566
|
+
return;
|
|
23567
|
+
});
|
|
23568
|
+
const single = def.options.length === 1;
|
|
23569
|
+
const first = def.options[0]._zod.run;
|
|
23570
|
+
inst._zod.parse = (payload, ctx) => {
|
|
23571
|
+
if (single) {
|
|
23572
|
+
return first(payload, ctx);
|
|
23573
|
+
}
|
|
23574
|
+
let async = false;
|
|
23575
|
+
const results = [];
|
|
23576
|
+
for (const option of def.options) {
|
|
23577
|
+
const result = option._zod.run({
|
|
23578
|
+
value: payload.value,
|
|
23579
|
+
issues: []
|
|
23580
|
+
}, ctx);
|
|
23581
|
+
if (result instanceof Promise) {
|
|
23582
|
+
results.push(result);
|
|
23583
|
+
async = true;
|
|
23584
|
+
} else {
|
|
23585
|
+
if (result.issues.length === 0)
|
|
23586
|
+
return result;
|
|
23587
|
+
results.push(result);
|
|
23588
|
+
}
|
|
23589
|
+
}
|
|
23590
|
+
if (!async)
|
|
23591
|
+
return handleUnionResults(results, payload, inst, ctx);
|
|
23592
|
+
return Promise.all(results).then((results) => {
|
|
23593
|
+
return handleUnionResults(results, payload, inst, ctx);
|
|
23594
|
+
});
|
|
23595
|
+
};
|
|
23596
|
+
});
|
|
23597
|
+
var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
|
|
23598
|
+
$ZodType.init(inst, def);
|
|
23599
|
+
inst._zod.parse = (payload, ctx) => {
|
|
23600
|
+
const input = payload.value;
|
|
23601
|
+
const left = def.left._zod.run({ value: input, issues: [] }, ctx);
|
|
23602
|
+
const right = def.right._zod.run({ value: input, issues: [] }, ctx);
|
|
23603
|
+
const async = left instanceof Promise || right instanceof Promise;
|
|
23604
|
+
if (async) {
|
|
23605
|
+
return Promise.all([left, right]).then(([left, right]) => {
|
|
23606
|
+
return handleIntersectionResults(payload, left, right);
|
|
23607
|
+
});
|
|
23608
|
+
}
|
|
23609
|
+
return handleIntersectionResults(payload, left, right);
|
|
23610
|
+
};
|
|
23611
|
+
});
|
|
23612
|
+
function mergeValues(a, b) {
|
|
23613
|
+
if (a === b) {
|
|
23614
|
+
return { valid: true, data: a };
|
|
23615
|
+
}
|
|
23616
|
+
if (a instanceof Date && b instanceof Date && +a === +b) {
|
|
23617
|
+
return { valid: true, data: a };
|
|
23618
|
+
}
|
|
23619
|
+
if (isPlainObject2(a) && isPlainObject2(b)) {
|
|
23620
|
+
const bKeys = Object.keys(b);
|
|
23621
|
+
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
23622
|
+
const newObj = { ...a, ...b };
|
|
23623
|
+
for (const key of sharedKeys) {
|
|
23624
|
+
const sharedValue = mergeValues(a[key], b[key]);
|
|
23625
|
+
if (!sharedValue.valid) {
|
|
23626
|
+
return {
|
|
23627
|
+
valid: false,
|
|
23628
|
+
mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
|
|
23629
|
+
};
|
|
23630
|
+
}
|
|
23631
|
+
newObj[key] = sharedValue.data;
|
|
23632
|
+
}
|
|
23633
|
+
return { valid: true, data: newObj };
|
|
23634
|
+
}
|
|
23635
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
23636
|
+
if (a.length !== b.length) {
|
|
23637
|
+
return { valid: false, mergeErrorPath: [] };
|
|
23638
|
+
}
|
|
23639
|
+
const newArray = [];
|
|
23640
|
+
for (let index = 0;index < a.length; index++) {
|
|
23641
|
+
const itemA = a[index];
|
|
23642
|
+
const itemB = b[index];
|
|
23643
|
+
const sharedValue = mergeValues(itemA, itemB);
|
|
23644
|
+
if (!sharedValue.valid) {
|
|
23645
|
+
return {
|
|
23646
|
+
valid: false,
|
|
23647
|
+
mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
|
|
23648
|
+
};
|
|
23649
|
+
}
|
|
23650
|
+
newArray.push(sharedValue.data);
|
|
23651
|
+
}
|
|
23652
|
+
return { valid: true, data: newArray };
|
|
23653
|
+
}
|
|
23654
|
+
return { valid: false, mergeErrorPath: [] };
|
|
23655
|
+
}
|
|
23656
|
+
function handleIntersectionResults(result, left, right) {
|
|
23657
|
+
const unrecKeys = new Map;
|
|
23658
|
+
let unrecIssue;
|
|
23659
|
+
for (const iss of left.issues) {
|
|
23660
|
+
if (iss.code === "unrecognized_keys") {
|
|
23661
|
+
unrecIssue ?? (unrecIssue = iss);
|
|
23662
|
+
for (const k of iss.keys) {
|
|
23663
|
+
if (!unrecKeys.has(k))
|
|
23664
|
+
unrecKeys.set(k, {});
|
|
23665
|
+
unrecKeys.get(k).l = true;
|
|
23666
|
+
}
|
|
23667
|
+
} else {
|
|
23668
|
+
result.issues.push(iss);
|
|
23669
|
+
}
|
|
23670
|
+
}
|
|
23671
|
+
for (const iss of right.issues) {
|
|
23672
|
+
if (iss.code === "unrecognized_keys") {
|
|
23673
|
+
for (const k of iss.keys) {
|
|
23674
|
+
if (!unrecKeys.has(k))
|
|
23675
|
+
unrecKeys.set(k, {});
|
|
23676
|
+
unrecKeys.get(k).r = true;
|
|
23677
|
+
}
|
|
23678
|
+
} else {
|
|
23679
|
+
result.issues.push(iss);
|
|
23680
|
+
}
|
|
23681
|
+
}
|
|
23682
|
+
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
23683
|
+
if (bothKeys.length && unrecIssue) {
|
|
23684
|
+
result.issues.push({ ...unrecIssue, keys: bothKeys });
|
|
23685
|
+
}
|
|
23686
|
+
if (aborted(result))
|
|
23687
|
+
return result;
|
|
23688
|
+
const merged = mergeValues(left.value, right.value);
|
|
23689
|
+
if (!merged.valid) {
|
|
23690
|
+
throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
|
|
23691
|
+
}
|
|
23692
|
+
result.value = merged.data;
|
|
23693
|
+
return result;
|
|
23694
|
+
}
|
|
23695
|
+
var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
23696
|
+
$ZodType.init(inst, def);
|
|
23697
|
+
const values = getEnumValues(def.entries);
|
|
23698
|
+
const valuesSet = new Set(values);
|
|
23699
|
+
inst._zod.values = valuesSet;
|
|
23700
|
+
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
23701
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
23702
|
+
const input = payload.value;
|
|
23703
|
+
if (valuesSet.has(input)) {
|
|
23704
|
+
return payload;
|
|
23705
|
+
}
|
|
23706
|
+
payload.issues.push({
|
|
23707
|
+
code: "invalid_value",
|
|
23708
|
+
values,
|
|
23709
|
+
input,
|
|
23710
|
+
inst
|
|
23711
|
+
});
|
|
23712
|
+
return payload;
|
|
23713
|
+
};
|
|
23714
|
+
});
|
|
23715
|
+
var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
23716
|
+
$ZodType.init(inst, def);
|
|
23717
|
+
inst._zod.parse = (payload, ctx) => {
|
|
23718
|
+
if (ctx.direction === "backward") {
|
|
23719
|
+
throw new $ZodEncodeError(inst.constructor.name);
|
|
23720
|
+
}
|
|
23721
|
+
const _out = def.transform(payload.value, payload);
|
|
23722
|
+
if (ctx.async) {
|
|
23723
|
+
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
23724
|
+
return output.then((output) => {
|
|
23725
|
+
payload.value = output;
|
|
23726
|
+
return payload;
|
|
23727
|
+
});
|
|
23728
|
+
}
|
|
23729
|
+
if (_out instanceof Promise) {
|
|
23730
|
+
throw new $ZodAsyncError;
|
|
23731
|
+
}
|
|
23732
|
+
payload.value = _out;
|
|
23733
|
+
return payload;
|
|
23734
|
+
};
|
|
23735
|
+
});
|
|
23736
|
+
function handleOptionalResult(result, input) {
|
|
23737
|
+
if (result.issues.length && input === undefined) {
|
|
23738
|
+
return { issues: [], value: undefined };
|
|
23739
|
+
}
|
|
23740
|
+
return result;
|
|
23741
|
+
}
|
|
23742
|
+
var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
23743
|
+
$ZodType.init(inst, def);
|
|
23744
|
+
inst._zod.optin = "optional";
|
|
23745
|
+
inst._zod.optout = "optional";
|
|
23746
|
+
defineLazy(inst._zod, "values", () => {
|
|
23747
|
+
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
|
|
23748
|
+
});
|
|
23749
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
23750
|
+
const pattern = def.innerType._zod.pattern;
|
|
23751
|
+
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : undefined;
|
|
23752
|
+
});
|
|
23753
|
+
inst._zod.parse = (payload, ctx) => {
|
|
23754
|
+
if (def.innerType._zod.optin === "optional") {
|
|
23755
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
23756
|
+
if (result instanceof Promise)
|
|
23757
|
+
return result.then((r) => handleOptionalResult(r, payload.value));
|
|
23758
|
+
return handleOptionalResult(result, payload.value);
|
|
23759
|
+
}
|
|
23760
|
+
if (payload.value === undefined) {
|
|
23761
|
+
return payload;
|
|
23762
|
+
}
|
|
23763
|
+
return def.innerType._zod.run(payload, ctx);
|
|
23764
|
+
};
|
|
23765
|
+
});
|
|
23766
|
+
var $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
|
|
23767
|
+
$ZodOptional.init(inst, def);
|
|
23768
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
23769
|
+
defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
|
|
23770
|
+
inst._zod.parse = (payload, ctx) => {
|
|
23771
|
+
return def.innerType._zod.run(payload, ctx);
|
|
23772
|
+
};
|
|
23773
|
+
});
|
|
23774
|
+
var $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
23775
|
+
$ZodType.init(inst, def);
|
|
23776
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
23777
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
23778
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
23779
|
+
const pattern = def.innerType._zod.pattern;
|
|
23780
|
+
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : undefined;
|
|
23781
|
+
});
|
|
23782
|
+
defineLazy(inst._zod, "values", () => {
|
|
23783
|
+
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
|
|
23784
|
+
});
|
|
23785
|
+
inst._zod.parse = (payload, ctx) => {
|
|
23786
|
+
if (payload.value === null)
|
|
23787
|
+
return payload;
|
|
23788
|
+
return def.innerType._zod.run(payload, ctx);
|
|
23789
|
+
};
|
|
23790
|
+
});
|
|
23791
|
+
var $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
|
|
23792
|
+
$ZodType.init(inst, def);
|
|
23793
|
+
inst._zod.optin = "optional";
|
|
23794
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
23795
|
+
inst._zod.parse = (payload, ctx) => {
|
|
23796
|
+
if (ctx.direction === "backward") {
|
|
23797
|
+
return def.innerType._zod.run(payload, ctx);
|
|
23798
|
+
}
|
|
23799
|
+
if (payload.value === undefined) {
|
|
23800
|
+
payload.value = def.defaultValue;
|
|
23801
|
+
return payload;
|
|
23802
|
+
}
|
|
23803
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
23804
|
+
if (result instanceof Promise) {
|
|
23805
|
+
return result.then((result) => handleDefaultResult(result, def));
|
|
23806
|
+
}
|
|
23807
|
+
return handleDefaultResult(result, def);
|
|
23808
|
+
};
|
|
23809
|
+
});
|
|
23810
|
+
function handleDefaultResult(payload, def) {
|
|
23811
|
+
if (payload.value === undefined) {
|
|
23812
|
+
payload.value = def.defaultValue;
|
|
23813
|
+
}
|
|
23814
|
+
return payload;
|
|
23815
|
+
}
|
|
23816
|
+
var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
23817
|
+
$ZodType.init(inst, def);
|
|
23818
|
+
inst._zod.optin = "optional";
|
|
23819
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
23820
|
+
inst._zod.parse = (payload, ctx) => {
|
|
23821
|
+
if (ctx.direction === "backward") {
|
|
23822
|
+
return def.innerType._zod.run(payload, ctx);
|
|
23823
|
+
}
|
|
23824
|
+
if (payload.value === undefined) {
|
|
23825
|
+
payload.value = def.defaultValue;
|
|
23826
|
+
}
|
|
23827
|
+
return def.innerType._zod.run(payload, ctx);
|
|
23828
|
+
};
|
|
23829
|
+
});
|
|
23830
|
+
var $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
23831
|
+
$ZodType.init(inst, def);
|
|
23832
|
+
defineLazy(inst._zod, "values", () => {
|
|
23833
|
+
const v = def.innerType._zod.values;
|
|
23834
|
+
return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
|
|
23835
|
+
});
|
|
23836
|
+
inst._zod.parse = (payload, ctx) => {
|
|
23837
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
23838
|
+
if (result instanceof Promise) {
|
|
23839
|
+
return result.then((result) => handleNonOptionalResult(result, inst));
|
|
23840
|
+
}
|
|
23841
|
+
return handleNonOptionalResult(result, inst);
|
|
23842
|
+
};
|
|
23843
|
+
});
|
|
23844
|
+
function handleNonOptionalResult(payload, inst) {
|
|
23845
|
+
if (!payload.issues.length && payload.value === undefined) {
|
|
23846
|
+
payload.issues.push({
|
|
23847
|
+
code: "invalid_type",
|
|
23848
|
+
expected: "nonoptional",
|
|
23849
|
+
input: payload.value,
|
|
23850
|
+
inst
|
|
23851
|
+
});
|
|
23852
|
+
}
|
|
23853
|
+
return payload;
|
|
23854
|
+
}
|
|
23855
|
+
var $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
23856
|
+
$ZodType.init(inst, def);
|
|
23857
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
23858
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
23859
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
23860
|
+
inst._zod.parse = (payload, ctx) => {
|
|
23861
|
+
if (ctx.direction === "backward") {
|
|
23862
|
+
return def.innerType._zod.run(payload, ctx);
|
|
23863
|
+
}
|
|
23864
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
23865
|
+
if (result instanceof Promise) {
|
|
23866
|
+
return result.then((result) => {
|
|
23867
|
+
payload.value = result.value;
|
|
23868
|
+
if (result.issues.length) {
|
|
23869
|
+
payload.value = def.catchValue({
|
|
23870
|
+
...payload,
|
|
23871
|
+
error: {
|
|
23872
|
+
issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
23873
|
+
},
|
|
23874
|
+
input: payload.value
|
|
23875
|
+
});
|
|
23876
|
+
payload.issues = [];
|
|
23877
|
+
}
|
|
23878
|
+
return payload;
|
|
23879
|
+
});
|
|
23880
|
+
}
|
|
23881
|
+
payload.value = result.value;
|
|
23882
|
+
if (result.issues.length) {
|
|
23883
|
+
payload.value = def.catchValue({
|
|
23884
|
+
...payload,
|
|
23885
|
+
error: {
|
|
23886
|
+
issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
23887
|
+
},
|
|
23888
|
+
input: payload.value
|
|
23889
|
+
});
|
|
23890
|
+
payload.issues = [];
|
|
23891
|
+
}
|
|
23892
|
+
return payload;
|
|
23893
|
+
};
|
|
23894
|
+
});
|
|
23895
|
+
var $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
|
|
23896
|
+
$ZodType.init(inst, def);
|
|
23897
|
+
defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
23898
|
+
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
23899
|
+
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
23900
|
+
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
23901
|
+
inst._zod.parse = (payload, ctx) => {
|
|
23902
|
+
if (ctx.direction === "backward") {
|
|
23903
|
+
const right = def.out._zod.run(payload, ctx);
|
|
23904
|
+
if (right instanceof Promise) {
|
|
23905
|
+
return right.then((right) => handlePipeResult(right, def.in, ctx));
|
|
23906
|
+
}
|
|
23907
|
+
return handlePipeResult(right, def.in, ctx);
|
|
23908
|
+
}
|
|
23909
|
+
const left = def.in._zod.run(payload, ctx);
|
|
23910
|
+
if (left instanceof Promise) {
|
|
23911
|
+
return left.then((left) => handlePipeResult(left, def.out, ctx));
|
|
23912
|
+
}
|
|
23913
|
+
return handlePipeResult(left, def.out, ctx);
|
|
23914
|
+
};
|
|
23915
|
+
});
|
|
23916
|
+
function handlePipeResult(left, next, ctx) {
|
|
23917
|
+
if (left.issues.length) {
|
|
23918
|
+
left.aborted = true;
|
|
23919
|
+
return left;
|
|
23920
|
+
}
|
|
23921
|
+
return next._zod.run({ value: left.value, issues: left.issues }, ctx);
|
|
23922
|
+
}
|
|
23923
|
+
var $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
|
|
23924
|
+
$ZodType.init(inst, def);
|
|
23925
|
+
defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
23926
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
23927
|
+
defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
|
|
23928
|
+
defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
|
|
23929
|
+
inst._zod.parse = (payload, ctx) => {
|
|
23930
|
+
if (ctx.direction === "backward") {
|
|
23931
|
+
return def.innerType._zod.run(payload, ctx);
|
|
23932
|
+
}
|
|
23933
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
23934
|
+
if (result instanceof Promise) {
|
|
23935
|
+
return result.then(handleReadonlyResult);
|
|
23936
|
+
}
|
|
23937
|
+
return handleReadonlyResult(result);
|
|
23938
|
+
};
|
|
23939
|
+
});
|
|
23940
|
+
function handleReadonlyResult(payload) {
|
|
23941
|
+
payload.value = Object.freeze(payload.value);
|
|
23942
|
+
return payload;
|
|
23943
|
+
}
|
|
23944
|
+
var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
23945
|
+
$ZodCheck.init(inst, def);
|
|
23946
|
+
$ZodType.init(inst, def);
|
|
23947
|
+
inst._zod.parse = (payload, _) => {
|
|
23948
|
+
return payload;
|
|
23949
|
+
};
|
|
23950
|
+
inst._zod.check = (payload) => {
|
|
23951
|
+
const input = payload.value;
|
|
23952
|
+
const r = def.fn(input);
|
|
23953
|
+
if (r instanceof Promise) {
|
|
23954
|
+
return r.then((r) => handleRefineResult(r, payload, input, inst));
|
|
23955
|
+
}
|
|
23956
|
+
handleRefineResult(r, payload, input, inst);
|
|
23957
|
+
return;
|
|
23958
|
+
};
|
|
23959
|
+
});
|
|
23960
|
+
function handleRefineResult(result, payload, input, inst) {
|
|
23961
|
+
if (!result) {
|
|
23962
|
+
const _iss = {
|
|
23963
|
+
code: "custom",
|
|
23964
|
+
input,
|
|
23965
|
+
inst,
|
|
23966
|
+
path: [...inst._zod.def.path ?? []],
|
|
23967
|
+
continue: !inst._zod.def.abort
|
|
23968
|
+
};
|
|
23969
|
+
if (inst._zod.def.params)
|
|
23970
|
+
_iss.params = inst._zod.def.params;
|
|
23971
|
+
payload.issues.push(issue(_iss));
|
|
23972
|
+
}
|
|
23973
|
+
}
|
|
23974
|
+
// node_modules/zod/v4/core/registries.js
|
|
23975
|
+
var _a;
|
|
23976
|
+
var $output = Symbol("ZodOutput");
|
|
23977
|
+
var $input = Symbol("ZodInput");
|
|
23978
|
+
|
|
23979
|
+
class $ZodRegistry {
|
|
23980
|
+
constructor() {
|
|
23981
|
+
this._map = new WeakMap;
|
|
23982
|
+
this._idmap = new Map;
|
|
23983
|
+
}
|
|
23984
|
+
add(schema, ..._meta) {
|
|
23985
|
+
const meta = _meta[0];
|
|
23986
|
+
this._map.set(schema, meta);
|
|
23987
|
+
if (meta && typeof meta === "object" && "id" in meta) {
|
|
23988
|
+
this._idmap.set(meta.id, schema);
|
|
23989
|
+
}
|
|
23990
|
+
return this;
|
|
23991
|
+
}
|
|
23992
|
+
clear() {
|
|
23993
|
+
this._map = new WeakMap;
|
|
23994
|
+
this._idmap = new Map;
|
|
23995
|
+
return this;
|
|
23996
|
+
}
|
|
23997
|
+
remove(schema) {
|
|
23998
|
+
const meta = this._map.get(schema);
|
|
23999
|
+
if (meta && typeof meta === "object" && "id" in meta) {
|
|
24000
|
+
this._idmap.delete(meta.id);
|
|
24001
|
+
}
|
|
24002
|
+
this._map.delete(schema);
|
|
24003
|
+
return this;
|
|
24004
|
+
}
|
|
24005
|
+
get(schema) {
|
|
24006
|
+
const p = schema._zod.parent;
|
|
24007
|
+
if (p) {
|
|
24008
|
+
const pm = { ...this.get(p) ?? {} };
|
|
24009
|
+
delete pm.id;
|
|
24010
|
+
const f = { ...pm, ...this._map.get(schema) };
|
|
24011
|
+
return Object.keys(f).length ? f : undefined;
|
|
24012
|
+
}
|
|
24013
|
+
return this._map.get(schema);
|
|
24014
|
+
}
|
|
24015
|
+
has(schema) {
|
|
24016
|
+
return this._map.has(schema);
|
|
24017
|
+
}
|
|
24018
|
+
}
|
|
24019
|
+
function registry() {
|
|
24020
|
+
return new $ZodRegistry;
|
|
24021
|
+
}
|
|
24022
|
+
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
|
24023
|
+
var globalRegistry = globalThis.__zod_globalRegistry;
|
|
24024
|
+
// node_modules/zod/v4/core/api.js
|
|
24025
|
+
function _string(Class, params) {
|
|
24026
|
+
return new Class({
|
|
24027
|
+
type: "string",
|
|
24028
|
+
...normalizeParams(params)
|
|
24029
|
+
});
|
|
24030
|
+
}
|
|
24031
|
+
function _email(Class, params) {
|
|
24032
|
+
return new Class({
|
|
24033
|
+
type: "string",
|
|
24034
|
+
format: "email",
|
|
24035
|
+
check: "string_format",
|
|
24036
|
+
abort: false,
|
|
24037
|
+
...normalizeParams(params)
|
|
24038
|
+
});
|
|
24039
|
+
}
|
|
24040
|
+
function _guid(Class, params) {
|
|
24041
|
+
return new Class({
|
|
24042
|
+
type: "string",
|
|
24043
|
+
format: "guid",
|
|
24044
|
+
check: "string_format",
|
|
24045
|
+
abort: false,
|
|
24046
|
+
...normalizeParams(params)
|
|
24047
|
+
});
|
|
24048
|
+
}
|
|
24049
|
+
function _uuid(Class, params) {
|
|
24050
|
+
return new Class({
|
|
24051
|
+
type: "string",
|
|
24052
|
+
format: "uuid",
|
|
24053
|
+
check: "string_format",
|
|
24054
|
+
abort: false,
|
|
24055
|
+
...normalizeParams(params)
|
|
24056
|
+
});
|
|
24057
|
+
}
|
|
24058
|
+
function _uuidv4(Class, params) {
|
|
24059
|
+
return new Class({
|
|
24060
|
+
type: "string",
|
|
24061
|
+
format: "uuid",
|
|
24062
|
+
check: "string_format",
|
|
24063
|
+
abort: false,
|
|
24064
|
+
version: "v4",
|
|
24065
|
+
...normalizeParams(params)
|
|
24066
|
+
});
|
|
24067
|
+
}
|
|
24068
|
+
function _uuidv6(Class, params) {
|
|
24069
|
+
return new Class({
|
|
24070
|
+
type: "string",
|
|
24071
|
+
format: "uuid",
|
|
24072
|
+
check: "string_format",
|
|
24073
|
+
abort: false,
|
|
24074
|
+
version: "v6",
|
|
24075
|
+
...normalizeParams(params)
|
|
24076
|
+
});
|
|
24077
|
+
}
|
|
24078
|
+
function _uuidv7(Class, params) {
|
|
24079
|
+
return new Class({
|
|
24080
|
+
type: "string",
|
|
24081
|
+
format: "uuid",
|
|
24082
|
+
check: "string_format",
|
|
24083
|
+
abort: false,
|
|
24084
|
+
version: "v7",
|
|
24085
|
+
...normalizeParams(params)
|
|
24086
|
+
});
|
|
24087
|
+
}
|
|
24088
|
+
function _url(Class, params) {
|
|
24089
|
+
return new Class({
|
|
24090
|
+
type: "string",
|
|
24091
|
+
format: "url",
|
|
24092
|
+
check: "string_format",
|
|
24093
|
+
abort: false,
|
|
24094
|
+
...normalizeParams(params)
|
|
24095
|
+
});
|
|
24096
|
+
}
|
|
24097
|
+
function _emoji2(Class, params) {
|
|
24098
|
+
return new Class({
|
|
24099
|
+
type: "string",
|
|
24100
|
+
format: "emoji",
|
|
24101
|
+
check: "string_format",
|
|
24102
|
+
abort: false,
|
|
24103
|
+
...normalizeParams(params)
|
|
24104
|
+
});
|
|
24105
|
+
}
|
|
24106
|
+
function _nanoid(Class, params) {
|
|
24107
|
+
return new Class({
|
|
24108
|
+
type: "string",
|
|
24109
|
+
format: "nanoid",
|
|
24110
|
+
check: "string_format",
|
|
24111
|
+
abort: false,
|
|
24112
|
+
...normalizeParams(params)
|
|
24113
|
+
});
|
|
24114
|
+
}
|
|
24115
|
+
function _cuid(Class, params) {
|
|
24116
|
+
return new Class({
|
|
24117
|
+
type: "string",
|
|
24118
|
+
format: "cuid",
|
|
24119
|
+
check: "string_format",
|
|
24120
|
+
abort: false,
|
|
24121
|
+
...normalizeParams(params)
|
|
24122
|
+
});
|
|
24123
|
+
}
|
|
24124
|
+
function _cuid2(Class, params) {
|
|
24125
|
+
return new Class({
|
|
24126
|
+
type: "string",
|
|
24127
|
+
format: "cuid2",
|
|
24128
|
+
check: "string_format",
|
|
24129
|
+
abort: false,
|
|
24130
|
+
...normalizeParams(params)
|
|
24131
|
+
});
|
|
24132
|
+
}
|
|
24133
|
+
function _ulid(Class, params) {
|
|
24134
|
+
return new Class({
|
|
24135
|
+
type: "string",
|
|
24136
|
+
format: "ulid",
|
|
24137
|
+
check: "string_format",
|
|
24138
|
+
abort: false,
|
|
24139
|
+
...normalizeParams(params)
|
|
24140
|
+
});
|
|
24141
|
+
}
|
|
24142
|
+
function _xid(Class, params) {
|
|
24143
|
+
return new Class({
|
|
24144
|
+
type: "string",
|
|
24145
|
+
format: "xid",
|
|
24146
|
+
check: "string_format",
|
|
24147
|
+
abort: false,
|
|
24148
|
+
...normalizeParams(params)
|
|
24149
|
+
});
|
|
24150
|
+
}
|
|
24151
|
+
function _ksuid(Class, params) {
|
|
24152
|
+
return new Class({
|
|
24153
|
+
type: "string",
|
|
24154
|
+
format: "ksuid",
|
|
24155
|
+
check: "string_format",
|
|
24156
|
+
abort: false,
|
|
24157
|
+
...normalizeParams(params)
|
|
24158
|
+
});
|
|
24159
|
+
}
|
|
24160
|
+
function _ipv4(Class, params) {
|
|
24161
|
+
return new Class({
|
|
24162
|
+
type: "string",
|
|
24163
|
+
format: "ipv4",
|
|
24164
|
+
check: "string_format",
|
|
24165
|
+
abort: false,
|
|
24166
|
+
...normalizeParams(params)
|
|
24167
|
+
});
|
|
24168
|
+
}
|
|
24169
|
+
function _ipv6(Class, params) {
|
|
24170
|
+
return new Class({
|
|
24171
|
+
type: "string",
|
|
24172
|
+
format: "ipv6",
|
|
24173
|
+
check: "string_format",
|
|
24174
|
+
abort: false,
|
|
24175
|
+
...normalizeParams(params)
|
|
24176
|
+
});
|
|
24177
|
+
}
|
|
24178
|
+
function _cidrv4(Class, params) {
|
|
24179
|
+
return new Class({
|
|
24180
|
+
type: "string",
|
|
24181
|
+
format: "cidrv4",
|
|
24182
|
+
check: "string_format",
|
|
24183
|
+
abort: false,
|
|
24184
|
+
...normalizeParams(params)
|
|
24185
|
+
});
|
|
24186
|
+
}
|
|
24187
|
+
function _cidrv6(Class, params) {
|
|
24188
|
+
return new Class({
|
|
24189
|
+
type: "string",
|
|
24190
|
+
format: "cidrv6",
|
|
24191
|
+
check: "string_format",
|
|
24192
|
+
abort: false,
|
|
24193
|
+
...normalizeParams(params)
|
|
24194
|
+
});
|
|
24195
|
+
}
|
|
24196
|
+
function _base64(Class, params) {
|
|
24197
|
+
return new Class({
|
|
24198
|
+
type: "string",
|
|
24199
|
+
format: "base64",
|
|
24200
|
+
check: "string_format",
|
|
24201
|
+
abort: false,
|
|
24202
|
+
...normalizeParams(params)
|
|
24203
|
+
});
|
|
24204
|
+
}
|
|
24205
|
+
function _base64url(Class, params) {
|
|
24206
|
+
return new Class({
|
|
24207
|
+
type: "string",
|
|
24208
|
+
format: "base64url",
|
|
24209
|
+
check: "string_format",
|
|
24210
|
+
abort: false,
|
|
24211
|
+
...normalizeParams(params)
|
|
24212
|
+
});
|
|
24213
|
+
}
|
|
24214
|
+
function _e164(Class, params) {
|
|
24215
|
+
return new Class({
|
|
24216
|
+
type: "string",
|
|
24217
|
+
format: "e164",
|
|
24218
|
+
check: "string_format",
|
|
24219
|
+
abort: false,
|
|
24220
|
+
...normalizeParams(params)
|
|
24221
|
+
});
|
|
24222
|
+
}
|
|
24223
|
+
function _jwt(Class, params) {
|
|
24224
|
+
return new Class({
|
|
24225
|
+
type: "string",
|
|
24226
|
+
format: "jwt",
|
|
24227
|
+
check: "string_format",
|
|
24228
|
+
abort: false,
|
|
24229
|
+
...normalizeParams(params)
|
|
24230
|
+
});
|
|
24231
|
+
}
|
|
24232
|
+
function _isoDateTime(Class, params) {
|
|
24233
|
+
return new Class({
|
|
24234
|
+
type: "string",
|
|
24235
|
+
format: "datetime",
|
|
24236
|
+
check: "string_format",
|
|
24237
|
+
offset: false,
|
|
24238
|
+
local: false,
|
|
24239
|
+
precision: null,
|
|
24240
|
+
...normalizeParams(params)
|
|
24241
|
+
});
|
|
24242
|
+
}
|
|
24243
|
+
function _isoDate(Class, params) {
|
|
24244
|
+
return new Class({
|
|
24245
|
+
type: "string",
|
|
24246
|
+
format: "date",
|
|
24247
|
+
check: "string_format",
|
|
24248
|
+
...normalizeParams(params)
|
|
24249
|
+
});
|
|
24250
|
+
}
|
|
24251
|
+
function _isoTime(Class, params) {
|
|
24252
|
+
return new Class({
|
|
24253
|
+
type: "string",
|
|
24254
|
+
format: "time",
|
|
24255
|
+
check: "string_format",
|
|
24256
|
+
precision: null,
|
|
24257
|
+
...normalizeParams(params)
|
|
24258
|
+
});
|
|
24259
|
+
}
|
|
24260
|
+
function _isoDuration(Class, params) {
|
|
24261
|
+
return new Class({
|
|
24262
|
+
type: "string",
|
|
24263
|
+
format: "duration",
|
|
24264
|
+
check: "string_format",
|
|
24265
|
+
...normalizeParams(params)
|
|
24266
|
+
});
|
|
24267
|
+
}
|
|
24268
|
+
function _unknown(Class) {
|
|
24269
|
+
return new Class({
|
|
24270
|
+
type: "unknown"
|
|
24271
|
+
});
|
|
24272
|
+
}
|
|
24273
|
+
function _never(Class, params) {
|
|
24274
|
+
return new Class({
|
|
24275
|
+
type: "never",
|
|
24276
|
+
...normalizeParams(params)
|
|
24277
|
+
});
|
|
24278
|
+
}
|
|
24279
|
+
function _maxLength(maximum, params) {
|
|
24280
|
+
const ch = new $ZodCheckMaxLength({
|
|
24281
|
+
check: "max_length",
|
|
24282
|
+
...normalizeParams(params),
|
|
24283
|
+
maximum
|
|
24284
|
+
});
|
|
24285
|
+
return ch;
|
|
24286
|
+
}
|
|
24287
|
+
function _minLength(minimum, params) {
|
|
24288
|
+
return new $ZodCheckMinLength({
|
|
24289
|
+
check: "min_length",
|
|
24290
|
+
...normalizeParams(params),
|
|
24291
|
+
minimum
|
|
24292
|
+
});
|
|
24293
|
+
}
|
|
24294
|
+
function _length(length, params) {
|
|
24295
|
+
return new $ZodCheckLengthEquals({
|
|
24296
|
+
check: "length_equals",
|
|
24297
|
+
...normalizeParams(params),
|
|
24298
|
+
length
|
|
24299
|
+
});
|
|
24300
|
+
}
|
|
24301
|
+
function _regex(pattern, params) {
|
|
24302
|
+
return new $ZodCheckRegex({
|
|
24303
|
+
check: "string_format",
|
|
24304
|
+
format: "regex",
|
|
24305
|
+
...normalizeParams(params),
|
|
24306
|
+
pattern
|
|
24307
|
+
});
|
|
24308
|
+
}
|
|
24309
|
+
function _lowercase(params) {
|
|
24310
|
+
return new $ZodCheckLowerCase({
|
|
24311
|
+
check: "string_format",
|
|
24312
|
+
format: "lowercase",
|
|
24313
|
+
...normalizeParams(params)
|
|
24314
|
+
});
|
|
24315
|
+
}
|
|
24316
|
+
function _uppercase(params) {
|
|
24317
|
+
return new $ZodCheckUpperCase({
|
|
24318
|
+
check: "string_format",
|
|
24319
|
+
format: "uppercase",
|
|
24320
|
+
...normalizeParams(params)
|
|
24321
|
+
});
|
|
24322
|
+
}
|
|
24323
|
+
function _includes(includes, params) {
|
|
24324
|
+
return new $ZodCheckIncludes({
|
|
24325
|
+
check: "string_format",
|
|
24326
|
+
format: "includes",
|
|
24327
|
+
...normalizeParams(params),
|
|
24328
|
+
includes
|
|
24329
|
+
});
|
|
24330
|
+
}
|
|
24331
|
+
function _startsWith(prefix, params) {
|
|
24332
|
+
return new $ZodCheckStartsWith({
|
|
24333
|
+
check: "string_format",
|
|
24334
|
+
format: "starts_with",
|
|
24335
|
+
...normalizeParams(params),
|
|
24336
|
+
prefix
|
|
24337
|
+
});
|
|
24338
|
+
}
|
|
24339
|
+
function _endsWith(suffix, params) {
|
|
24340
|
+
return new $ZodCheckEndsWith({
|
|
24341
|
+
check: "string_format",
|
|
24342
|
+
format: "ends_with",
|
|
24343
|
+
...normalizeParams(params),
|
|
24344
|
+
suffix
|
|
24345
|
+
});
|
|
24346
|
+
}
|
|
24347
|
+
function _overwrite(tx) {
|
|
24348
|
+
return new $ZodCheckOverwrite({
|
|
24349
|
+
check: "overwrite",
|
|
24350
|
+
tx
|
|
24351
|
+
});
|
|
24352
|
+
}
|
|
24353
|
+
function _normalize(form) {
|
|
24354
|
+
return _overwrite((input) => input.normalize(form));
|
|
24355
|
+
}
|
|
24356
|
+
function _trim() {
|
|
24357
|
+
return _overwrite((input) => input.trim());
|
|
24358
|
+
}
|
|
24359
|
+
function _toLowerCase() {
|
|
24360
|
+
return _overwrite((input) => input.toLowerCase());
|
|
24361
|
+
}
|
|
24362
|
+
function _toUpperCase() {
|
|
24363
|
+
return _overwrite((input) => input.toUpperCase());
|
|
24364
|
+
}
|
|
24365
|
+
function _slugify() {
|
|
24366
|
+
return _overwrite((input) => slugify(input));
|
|
24367
|
+
}
|
|
24368
|
+
function _array(Class, element, params) {
|
|
24369
|
+
return new Class({
|
|
24370
|
+
type: "array",
|
|
24371
|
+
element,
|
|
24372
|
+
...normalizeParams(params)
|
|
24373
|
+
});
|
|
24374
|
+
}
|
|
24375
|
+
function _refine(Class, fn, _params) {
|
|
24376
|
+
const schema = new Class({
|
|
24377
|
+
type: "custom",
|
|
24378
|
+
check: "custom",
|
|
24379
|
+
fn,
|
|
24380
|
+
...normalizeParams(_params)
|
|
24381
|
+
});
|
|
24382
|
+
return schema;
|
|
24383
|
+
}
|
|
24384
|
+
function _superRefine(fn) {
|
|
24385
|
+
const ch = _check((payload) => {
|
|
24386
|
+
payload.addIssue = (issue2) => {
|
|
24387
|
+
if (typeof issue2 === "string") {
|
|
24388
|
+
payload.issues.push(issue(issue2, payload.value, ch._zod.def));
|
|
24389
|
+
} else {
|
|
24390
|
+
const _issue = issue2;
|
|
24391
|
+
if (_issue.fatal)
|
|
24392
|
+
_issue.continue = false;
|
|
24393
|
+
_issue.code ?? (_issue.code = "custom");
|
|
24394
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
24395
|
+
_issue.inst ?? (_issue.inst = ch);
|
|
24396
|
+
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
24397
|
+
payload.issues.push(issue(_issue));
|
|
24398
|
+
}
|
|
24399
|
+
};
|
|
24400
|
+
return fn(payload.value, payload);
|
|
24401
|
+
});
|
|
24402
|
+
return ch;
|
|
24403
|
+
}
|
|
24404
|
+
function _check(fn, params) {
|
|
24405
|
+
const ch = new $ZodCheck({
|
|
24406
|
+
check: "custom",
|
|
24407
|
+
...normalizeParams(params)
|
|
24408
|
+
});
|
|
24409
|
+
ch._zod.check = fn;
|
|
24410
|
+
return ch;
|
|
24411
|
+
}
|
|
24412
|
+
// node_modules/zod/v4/core/to-json-schema.js
|
|
24413
|
+
function initializeContext(params) {
|
|
24414
|
+
let target = params?.target ?? "draft-2020-12";
|
|
24415
|
+
if (target === "draft-4")
|
|
24416
|
+
target = "draft-04";
|
|
24417
|
+
if (target === "draft-7")
|
|
24418
|
+
target = "draft-07";
|
|
24419
|
+
return {
|
|
24420
|
+
processors: params.processors ?? {},
|
|
24421
|
+
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
24422
|
+
target,
|
|
24423
|
+
unrepresentable: params?.unrepresentable ?? "throw",
|
|
24424
|
+
override: params?.override ?? (() => {}),
|
|
24425
|
+
io: params?.io ?? "output",
|
|
24426
|
+
counter: 0,
|
|
24427
|
+
seen: new Map,
|
|
24428
|
+
cycles: params?.cycles ?? "ref",
|
|
24429
|
+
reused: params?.reused ?? "inline",
|
|
24430
|
+
external: params?.external ?? undefined
|
|
24431
|
+
};
|
|
24432
|
+
}
|
|
24433
|
+
function process3(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
24434
|
+
var _a;
|
|
24435
|
+
const def = schema._zod.def;
|
|
24436
|
+
const seen = ctx.seen.get(schema);
|
|
24437
|
+
if (seen) {
|
|
24438
|
+
seen.count++;
|
|
24439
|
+
const isCycle = _params.schemaPath.includes(schema);
|
|
24440
|
+
if (isCycle) {
|
|
24441
|
+
seen.cycle = _params.path;
|
|
24442
|
+
}
|
|
24443
|
+
return seen.schema;
|
|
24444
|
+
}
|
|
24445
|
+
const result = { schema: {}, count: 1, cycle: undefined, path: _params.path };
|
|
24446
|
+
ctx.seen.set(schema, result);
|
|
24447
|
+
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
24448
|
+
if (overrideSchema) {
|
|
24449
|
+
result.schema = overrideSchema;
|
|
24450
|
+
} else {
|
|
24451
|
+
const params = {
|
|
24452
|
+
..._params,
|
|
24453
|
+
schemaPath: [..._params.schemaPath, schema],
|
|
24454
|
+
path: _params.path
|
|
24455
|
+
};
|
|
24456
|
+
if (schema._zod.processJSONSchema) {
|
|
24457
|
+
schema._zod.processJSONSchema(ctx, result.schema, params);
|
|
24458
|
+
} else {
|
|
24459
|
+
const _json = result.schema;
|
|
24460
|
+
const processor = ctx.processors[def.type];
|
|
24461
|
+
if (!processor) {
|
|
24462
|
+
throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
|
|
24463
|
+
}
|
|
24464
|
+
processor(schema, ctx, _json, params);
|
|
24465
|
+
}
|
|
24466
|
+
const parent = schema._zod.parent;
|
|
24467
|
+
if (parent) {
|
|
24468
|
+
if (!result.ref)
|
|
24469
|
+
result.ref = parent;
|
|
24470
|
+
process3(parent, ctx, params);
|
|
24471
|
+
ctx.seen.get(parent).isParent = true;
|
|
24472
|
+
}
|
|
24473
|
+
}
|
|
24474
|
+
const meta = ctx.metadataRegistry.get(schema);
|
|
24475
|
+
if (meta)
|
|
24476
|
+
Object.assign(result.schema, meta);
|
|
24477
|
+
if (ctx.io === "input" && isTransforming(schema)) {
|
|
24478
|
+
delete result.schema.examples;
|
|
24479
|
+
delete result.schema.default;
|
|
24480
|
+
}
|
|
24481
|
+
if (ctx.io === "input" && result.schema._prefault)
|
|
24482
|
+
(_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
|
24483
|
+
delete result.schema._prefault;
|
|
24484
|
+
const _result = ctx.seen.get(schema);
|
|
24485
|
+
return _result.schema;
|
|
24486
|
+
}
|
|
24487
|
+
function extractDefs(ctx, schema) {
|
|
24488
|
+
const root = ctx.seen.get(schema);
|
|
24489
|
+
if (!root)
|
|
24490
|
+
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
24491
|
+
const idToSchema = new Map;
|
|
24492
|
+
for (const entry of ctx.seen.entries()) {
|
|
24493
|
+
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
24494
|
+
if (id) {
|
|
24495
|
+
const existing = idToSchema.get(id);
|
|
24496
|
+
if (existing && existing !== entry[0]) {
|
|
24497
|
+
throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
24498
|
+
}
|
|
24499
|
+
idToSchema.set(id, entry[0]);
|
|
24500
|
+
}
|
|
24501
|
+
}
|
|
24502
|
+
const makeURI = (entry) => {
|
|
24503
|
+
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
24504
|
+
if (ctx.external) {
|
|
24505
|
+
const externalId = ctx.external.registry.get(entry[0])?.id;
|
|
24506
|
+
const uriGenerator = ctx.external.uri ?? ((id) => id);
|
|
24507
|
+
if (externalId) {
|
|
24508
|
+
return { ref: uriGenerator(externalId) };
|
|
24509
|
+
}
|
|
24510
|
+
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
24511
|
+
entry[1].defId = id;
|
|
24512
|
+
return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
|
|
24513
|
+
}
|
|
24514
|
+
if (entry[1] === root) {
|
|
24515
|
+
return { ref: "#" };
|
|
24516
|
+
}
|
|
24517
|
+
const uriPrefix = `#`;
|
|
24518
|
+
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
|
24519
|
+
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
24520
|
+
return { defId, ref: defUriPrefix + defId };
|
|
24521
|
+
};
|
|
24522
|
+
const extractToDef = (entry) => {
|
|
24523
|
+
if (entry[1].schema.$ref) {
|
|
24524
|
+
return;
|
|
24525
|
+
}
|
|
24526
|
+
const seen = entry[1];
|
|
24527
|
+
const { ref, defId } = makeURI(entry);
|
|
24528
|
+
seen.def = { ...seen.schema };
|
|
24529
|
+
if (defId)
|
|
24530
|
+
seen.defId = defId;
|
|
24531
|
+
const schema = seen.schema;
|
|
24532
|
+
for (const key in schema) {
|
|
24533
|
+
delete schema[key];
|
|
24534
|
+
}
|
|
24535
|
+
schema.$ref = ref;
|
|
24536
|
+
};
|
|
24537
|
+
if (ctx.cycles === "throw") {
|
|
24538
|
+
for (const entry of ctx.seen.entries()) {
|
|
24539
|
+
const seen = entry[1];
|
|
24540
|
+
if (seen.cycle) {
|
|
24541
|
+
throw new Error("Cycle detected: " + `#/${seen.cycle?.join("/")}/<root>` + '\n\nSet the `cycles` parameter to `"ref"` to resolve cyclical schemas with defs.');
|
|
24542
|
+
}
|
|
24543
|
+
}
|
|
24544
|
+
}
|
|
24545
|
+
for (const entry of ctx.seen.entries()) {
|
|
24546
|
+
const seen = entry[1];
|
|
24547
|
+
if (schema === entry[0]) {
|
|
24548
|
+
extractToDef(entry);
|
|
24549
|
+
continue;
|
|
24550
|
+
}
|
|
24551
|
+
if (ctx.external) {
|
|
24552
|
+
const ext = ctx.external.registry.get(entry[0])?.id;
|
|
24553
|
+
if (schema !== entry[0] && ext) {
|
|
24554
|
+
extractToDef(entry);
|
|
24555
|
+
continue;
|
|
24556
|
+
}
|
|
24557
|
+
}
|
|
24558
|
+
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
24559
|
+
if (id) {
|
|
24560
|
+
extractToDef(entry);
|
|
24561
|
+
continue;
|
|
24562
|
+
}
|
|
24563
|
+
if (seen.cycle) {
|
|
24564
|
+
extractToDef(entry);
|
|
24565
|
+
continue;
|
|
24566
|
+
}
|
|
24567
|
+
if (seen.count > 1) {
|
|
24568
|
+
if (ctx.reused === "ref") {
|
|
24569
|
+
extractToDef(entry);
|
|
24570
|
+
continue;
|
|
24571
|
+
}
|
|
24572
|
+
}
|
|
24573
|
+
}
|
|
24574
|
+
}
|
|
24575
|
+
function finalize(ctx, schema) {
|
|
24576
|
+
const root = ctx.seen.get(schema);
|
|
24577
|
+
if (!root)
|
|
24578
|
+
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
24579
|
+
const flattenRef = (zodSchema) => {
|
|
24580
|
+
const seen = ctx.seen.get(zodSchema);
|
|
24581
|
+
if (seen.ref === null)
|
|
24582
|
+
return;
|
|
24583
|
+
const schema = seen.def ?? seen.schema;
|
|
24584
|
+
const _cached = { ...schema };
|
|
24585
|
+
const ref = seen.ref;
|
|
24586
|
+
seen.ref = null;
|
|
24587
|
+
if (ref) {
|
|
24588
|
+
flattenRef(ref);
|
|
24589
|
+
const refSeen = ctx.seen.get(ref);
|
|
24590
|
+
const refSchema = refSeen.schema;
|
|
24591
|
+
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
24592
|
+
schema.allOf = schema.allOf ?? [];
|
|
24593
|
+
schema.allOf.push(refSchema);
|
|
24594
|
+
} else {
|
|
24595
|
+
Object.assign(schema, refSchema);
|
|
24596
|
+
}
|
|
24597
|
+
Object.assign(schema, _cached);
|
|
24598
|
+
const isParentRef = zodSchema._zod.parent === ref;
|
|
24599
|
+
if (isParentRef) {
|
|
24600
|
+
for (const key in schema) {
|
|
24601
|
+
if (key === "$ref" || key === "allOf")
|
|
24602
|
+
continue;
|
|
24603
|
+
if (!(key in _cached)) {
|
|
24604
|
+
delete schema[key];
|
|
24605
|
+
}
|
|
24606
|
+
}
|
|
24607
|
+
}
|
|
24608
|
+
if (refSchema.$ref && refSeen.def) {
|
|
24609
|
+
for (const key in schema) {
|
|
24610
|
+
if (key === "$ref" || key === "allOf")
|
|
24611
|
+
continue;
|
|
24612
|
+
if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) {
|
|
24613
|
+
delete schema[key];
|
|
24614
|
+
}
|
|
24615
|
+
}
|
|
24616
|
+
}
|
|
24617
|
+
}
|
|
24618
|
+
const parent = zodSchema._zod.parent;
|
|
24619
|
+
if (parent && parent !== ref) {
|
|
24620
|
+
flattenRef(parent);
|
|
24621
|
+
const parentSeen = ctx.seen.get(parent);
|
|
24622
|
+
if (parentSeen?.schema.$ref) {
|
|
24623
|
+
schema.$ref = parentSeen.schema.$ref;
|
|
24624
|
+
if (parentSeen.def) {
|
|
24625
|
+
for (const key in schema) {
|
|
24626
|
+
if (key === "$ref" || key === "allOf")
|
|
24627
|
+
continue;
|
|
24628
|
+
if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) {
|
|
24629
|
+
delete schema[key];
|
|
24630
|
+
}
|
|
24631
|
+
}
|
|
24632
|
+
}
|
|
24633
|
+
}
|
|
24634
|
+
}
|
|
24635
|
+
ctx.override({
|
|
24636
|
+
zodSchema,
|
|
24637
|
+
jsonSchema: schema,
|
|
24638
|
+
path: seen.path ?? []
|
|
24639
|
+
});
|
|
24640
|
+
};
|
|
24641
|
+
for (const entry of [...ctx.seen.entries()].reverse()) {
|
|
24642
|
+
flattenRef(entry[0]);
|
|
24643
|
+
}
|
|
24644
|
+
const result = {};
|
|
24645
|
+
if (ctx.target === "draft-2020-12") {
|
|
24646
|
+
result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
24647
|
+
} else if (ctx.target === "draft-07") {
|
|
24648
|
+
result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
24649
|
+
} else if (ctx.target === "draft-04") {
|
|
24650
|
+
result.$schema = "http://json-schema.org/draft-04/schema#";
|
|
24651
|
+
} else if (ctx.target === "openapi-3.0") {}
|
|
24652
|
+
if (ctx.external?.uri) {
|
|
24653
|
+
const id = ctx.external.registry.get(schema)?.id;
|
|
24654
|
+
if (!id)
|
|
24655
|
+
throw new Error("Schema is missing an `id` property");
|
|
24656
|
+
result.$id = ctx.external.uri(id);
|
|
24657
|
+
}
|
|
24658
|
+
Object.assign(result, root.def ?? root.schema);
|
|
24659
|
+
const defs = ctx.external?.defs ?? {};
|
|
24660
|
+
for (const entry of ctx.seen.entries()) {
|
|
24661
|
+
const seen = entry[1];
|
|
24662
|
+
if (seen.def && seen.defId) {
|
|
24663
|
+
defs[seen.defId] = seen.def;
|
|
24664
|
+
}
|
|
24665
|
+
}
|
|
24666
|
+
if (ctx.external) {} else {
|
|
24667
|
+
if (Object.keys(defs).length > 0) {
|
|
24668
|
+
if (ctx.target === "draft-2020-12") {
|
|
24669
|
+
result.$defs = defs;
|
|
24670
|
+
} else {
|
|
24671
|
+
result.definitions = defs;
|
|
24672
|
+
}
|
|
24673
|
+
}
|
|
24674
|
+
}
|
|
24675
|
+
try {
|
|
24676
|
+
const finalized = JSON.parse(JSON.stringify(result));
|
|
24677
|
+
Object.defineProperty(finalized, "~standard", {
|
|
24678
|
+
value: {
|
|
24679
|
+
...schema["~standard"],
|
|
24680
|
+
jsonSchema: {
|
|
24681
|
+
input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
|
|
24682
|
+
output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
|
|
24683
|
+
}
|
|
24684
|
+
},
|
|
24685
|
+
enumerable: false,
|
|
24686
|
+
writable: false
|
|
24687
|
+
});
|
|
24688
|
+
return finalized;
|
|
24689
|
+
} catch (_err) {
|
|
24690
|
+
throw new Error("Error converting schema to JSON.");
|
|
24691
|
+
}
|
|
24692
|
+
}
|
|
24693
|
+
function isTransforming(_schema, _ctx) {
|
|
24694
|
+
const ctx = _ctx ?? { seen: new Set };
|
|
24695
|
+
if (ctx.seen.has(_schema))
|
|
24696
|
+
return false;
|
|
24697
|
+
ctx.seen.add(_schema);
|
|
24698
|
+
const def = _schema._zod.def;
|
|
24699
|
+
if (def.type === "transform")
|
|
24700
|
+
return true;
|
|
24701
|
+
if (def.type === "array")
|
|
24702
|
+
return isTransforming(def.element, ctx);
|
|
24703
|
+
if (def.type === "set")
|
|
24704
|
+
return isTransforming(def.valueType, ctx);
|
|
24705
|
+
if (def.type === "lazy")
|
|
24706
|
+
return isTransforming(def.getter(), ctx);
|
|
24707
|
+
if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") {
|
|
24708
|
+
return isTransforming(def.innerType, ctx);
|
|
24709
|
+
}
|
|
24710
|
+
if (def.type === "intersection") {
|
|
24711
|
+
return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
|
24712
|
+
}
|
|
24713
|
+
if (def.type === "record" || def.type === "map") {
|
|
24714
|
+
return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
24715
|
+
}
|
|
24716
|
+
if (def.type === "pipe") {
|
|
24717
|
+
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
24718
|
+
}
|
|
24719
|
+
if (def.type === "object") {
|
|
24720
|
+
for (const key in def.shape) {
|
|
24721
|
+
if (isTransforming(def.shape[key], ctx))
|
|
24722
|
+
return true;
|
|
24723
|
+
}
|
|
24724
|
+
return false;
|
|
24725
|
+
}
|
|
24726
|
+
if (def.type === "union") {
|
|
24727
|
+
for (const option of def.options) {
|
|
24728
|
+
if (isTransforming(option, ctx))
|
|
24729
|
+
return true;
|
|
24730
|
+
}
|
|
24731
|
+
return false;
|
|
24732
|
+
}
|
|
24733
|
+
if (def.type === "tuple") {
|
|
24734
|
+
for (const item of def.items) {
|
|
24735
|
+
if (isTransforming(item, ctx))
|
|
24736
|
+
return true;
|
|
24737
|
+
}
|
|
24738
|
+
if (def.rest && isTransforming(def.rest, ctx))
|
|
24739
|
+
return true;
|
|
24740
|
+
return false;
|
|
24741
|
+
}
|
|
24742
|
+
return false;
|
|
24743
|
+
}
|
|
24744
|
+
var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
24745
|
+
const ctx = initializeContext({ ...params, processors });
|
|
24746
|
+
process3(schema, ctx);
|
|
24747
|
+
extractDefs(ctx, schema);
|
|
24748
|
+
return finalize(ctx, schema);
|
|
24749
|
+
};
|
|
24750
|
+
var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
24751
|
+
const { libraryOptions, target } = params ?? {};
|
|
24752
|
+
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
24753
|
+
process3(schema, ctx);
|
|
24754
|
+
extractDefs(ctx, schema);
|
|
24755
|
+
return finalize(ctx, schema);
|
|
24756
|
+
};
|
|
24757
|
+
// node_modules/zod/v4/core/json-schema-processors.js
|
|
24758
|
+
var formatMap = {
|
|
24759
|
+
guid: "uuid",
|
|
24760
|
+
url: "uri",
|
|
24761
|
+
datetime: "date-time",
|
|
24762
|
+
json_string: "json-string",
|
|
24763
|
+
regex: ""
|
|
24764
|
+
};
|
|
24765
|
+
var stringProcessor = (schema, ctx, _json, _params) => {
|
|
24766
|
+
const json = _json;
|
|
24767
|
+
json.type = "string";
|
|
24768
|
+
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
|
|
24769
|
+
if (typeof minimum === "number")
|
|
24770
|
+
json.minLength = minimum;
|
|
24771
|
+
if (typeof maximum === "number")
|
|
24772
|
+
json.maxLength = maximum;
|
|
24773
|
+
if (format) {
|
|
24774
|
+
json.format = formatMap[format] ?? format;
|
|
24775
|
+
if (json.format === "")
|
|
24776
|
+
delete json.format;
|
|
24777
|
+
if (format === "time") {
|
|
24778
|
+
delete json.format;
|
|
24779
|
+
}
|
|
24780
|
+
}
|
|
24781
|
+
if (contentEncoding)
|
|
24782
|
+
json.contentEncoding = contentEncoding;
|
|
24783
|
+
if (patterns && patterns.size > 0) {
|
|
24784
|
+
const regexes = [...patterns];
|
|
24785
|
+
if (regexes.length === 1)
|
|
24786
|
+
json.pattern = regexes[0].source;
|
|
24787
|
+
else if (regexes.length > 1) {
|
|
24788
|
+
json.allOf = [
|
|
24789
|
+
...regexes.map((regex) => ({
|
|
24790
|
+
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
24791
|
+
pattern: regex.source
|
|
24792
|
+
}))
|
|
24793
|
+
];
|
|
24794
|
+
}
|
|
24795
|
+
}
|
|
24796
|
+
};
|
|
24797
|
+
var neverProcessor = (_schema, _ctx, json, _params) => {
|
|
24798
|
+
json.not = {};
|
|
24799
|
+
};
|
|
24800
|
+
var unknownProcessor = (_schema, _ctx, _json, _params) => {};
|
|
24801
|
+
var enumProcessor = (schema, _ctx, json, _params) => {
|
|
24802
|
+
const def = schema._zod.def;
|
|
24803
|
+
const values = getEnumValues(def.entries);
|
|
24804
|
+
if (values.every((v) => typeof v === "number"))
|
|
24805
|
+
json.type = "number";
|
|
24806
|
+
if (values.every((v) => typeof v === "string"))
|
|
24807
|
+
json.type = "string";
|
|
24808
|
+
json.enum = values;
|
|
24809
|
+
};
|
|
24810
|
+
var customProcessor = (_schema, ctx, _json, _params) => {
|
|
24811
|
+
if (ctx.unrepresentable === "throw") {
|
|
24812
|
+
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
24813
|
+
}
|
|
24814
|
+
};
|
|
24815
|
+
var transformProcessor = (_schema, ctx, _json, _params) => {
|
|
24816
|
+
if (ctx.unrepresentable === "throw") {
|
|
24817
|
+
throw new Error("Transforms cannot be represented in JSON Schema");
|
|
24818
|
+
}
|
|
24819
|
+
};
|
|
24820
|
+
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
24821
|
+
const json = _json;
|
|
24822
|
+
const def = schema._zod.def;
|
|
24823
|
+
const { minimum, maximum } = schema._zod.bag;
|
|
24824
|
+
if (typeof minimum === "number")
|
|
24825
|
+
json.minItems = minimum;
|
|
24826
|
+
if (typeof maximum === "number")
|
|
24827
|
+
json.maxItems = maximum;
|
|
24828
|
+
json.type = "array";
|
|
24829
|
+
json.items = process3(def.element, ctx, { ...params, path: [...params.path, "items"] });
|
|
24830
|
+
};
|
|
24831
|
+
var objectProcessor = (schema, ctx, _json, params) => {
|
|
24832
|
+
const json = _json;
|
|
24833
|
+
const def = schema._zod.def;
|
|
24834
|
+
json.type = "object";
|
|
24835
|
+
json.properties = {};
|
|
24836
|
+
const shape = def.shape;
|
|
24837
|
+
for (const key in shape) {
|
|
24838
|
+
json.properties[key] = process3(shape[key], ctx, {
|
|
24839
|
+
...params,
|
|
24840
|
+
path: [...params.path, "properties", key]
|
|
24841
|
+
});
|
|
24842
|
+
}
|
|
24843
|
+
const allKeys = new Set(Object.keys(shape));
|
|
24844
|
+
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
24845
|
+
const v = def.shape[key]._zod;
|
|
24846
|
+
if (ctx.io === "input") {
|
|
24847
|
+
return v.optin === undefined;
|
|
24848
|
+
} else {
|
|
24849
|
+
return v.optout === undefined;
|
|
24850
|
+
}
|
|
24851
|
+
}));
|
|
24852
|
+
if (requiredKeys.size > 0) {
|
|
24853
|
+
json.required = Array.from(requiredKeys);
|
|
24854
|
+
}
|
|
24855
|
+
if (def.catchall?._zod.def.type === "never") {
|
|
24856
|
+
json.additionalProperties = false;
|
|
24857
|
+
} else if (!def.catchall) {
|
|
24858
|
+
if (ctx.io === "output")
|
|
24859
|
+
json.additionalProperties = false;
|
|
24860
|
+
} else if (def.catchall) {
|
|
24861
|
+
json.additionalProperties = process3(def.catchall, ctx, {
|
|
24862
|
+
...params,
|
|
24863
|
+
path: [...params.path, "additionalProperties"]
|
|
24864
|
+
});
|
|
24865
|
+
}
|
|
24866
|
+
};
|
|
24867
|
+
var unionProcessor = (schema, ctx, json, params) => {
|
|
24868
|
+
const def = schema._zod.def;
|
|
24869
|
+
const isExclusive = def.inclusive === false;
|
|
24870
|
+
const options = def.options.map((x, i) => process3(x, ctx, {
|
|
24871
|
+
...params,
|
|
24872
|
+
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
24873
|
+
}));
|
|
24874
|
+
if (isExclusive) {
|
|
24875
|
+
json.oneOf = options;
|
|
24876
|
+
} else {
|
|
24877
|
+
json.anyOf = options;
|
|
24878
|
+
}
|
|
24879
|
+
};
|
|
24880
|
+
var intersectionProcessor = (schema, ctx, json, params) => {
|
|
24881
|
+
const def = schema._zod.def;
|
|
24882
|
+
const a = process3(def.left, ctx, {
|
|
24883
|
+
...params,
|
|
24884
|
+
path: [...params.path, "allOf", 0]
|
|
24885
|
+
});
|
|
24886
|
+
const b = process3(def.right, ctx, {
|
|
24887
|
+
...params,
|
|
24888
|
+
path: [...params.path, "allOf", 1]
|
|
24889
|
+
});
|
|
24890
|
+
const isSimpleIntersection = (val) => ("allOf" in val) && Object.keys(val).length === 1;
|
|
24891
|
+
const allOf = [
|
|
24892
|
+
...isSimpleIntersection(a) ? a.allOf : [a],
|
|
24893
|
+
...isSimpleIntersection(b) ? b.allOf : [b]
|
|
24894
|
+
];
|
|
24895
|
+
json.allOf = allOf;
|
|
24896
|
+
};
|
|
24897
|
+
var nullableProcessor = (schema, ctx, json, params) => {
|
|
24898
|
+
const def = schema._zod.def;
|
|
24899
|
+
const inner = process3(def.innerType, ctx, params);
|
|
24900
|
+
const seen = ctx.seen.get(schema);
|
|
24901
|
+
if (ctx.target === "openapi-3.0") {
|
|
24902
|
+
seen.ref = def.innerType;
|
|
24903
|
+
json.nullable = true;
|
|
24904
|
+
} else {
|
|
24905
|
+
json.anyOf = [inner, { type: "null" }];
|
|
24906
|
+
}
|
|
24907
|
+
};
|
|
24908
|
+
var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
24909
|
+
const def = schema._zod.def;
|
|
24910
|
+
process3(def.innerType, ctx, params);
|
|
24911
|
+
const seen = ctx.seen.get(schema);
|
|
24912
|
+
seen.ref = def.innerType;
|
|
24913
|
+
};
|
|
24914
|
+
var defaultProcessor = (schema, ctx, json, params) => {
|
|
24915
|
+
const def = schema._zod.def;
|
|
24916
|
+
process3(def.innerType, ctx, params);
|
|
24917
|
+
const seen = ctx.seen.get(schema);
|
|
24918
|
+
seen.ref = def.innerType;
|
|
24919
|
+
json.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
24920
|
+
};
|
|
24921
|
+
var prefaultProcessor = (schema, ctx, json, params) => {
|
|
24922
|
+
const def = schema._zod.def;
|
|
24923
|
+
process3(def.innerType, ctx, params);
|
|
24924
|
+
const seen = ctx.seen.get(schema);
|
|
24925
|
+
seen.ref = def.innerType;
|
|
24926
|
+
if (ctx.io === "input")
|
|
24927
|
+
json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
24928
|
+
};
|
|
24929
|
+
var catchProcessor = (schema, ctx, json, params) => {
|
|
24930
|
+
const def = schema._zod.def;
|
|
24931
|
+
process3(def.innerType, ctx, params);
|
|
24932
|
+
const seen = ctx.seen.get(schema);
|
|
24933
|
+
seen.ref = def.innerType;
|
|
24934
|
+
let catchValue;
|
|
24935
|
+
try {
|
|
24936
|
+
catchValue = def.catchValue(undefined);
|
|
24937
|
+
} catch {
|
|
24938
|
+
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
24939
|
+
}
|
|
24940
|
+
json.default = catchValue;
|
|
24941
|
+
};
|
|
24942
|
+
var pipeProcessor = (schema, ctx, _json, params) => {
|
|
24943
|
+
const def = schema._zod.def;
|
|
24944
|
+
const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
|
|
24945
|
+
process3(innerType, ctx, params);
|
|
24946
|
+
const seen = ctx.seen.get(schema);
|
|
24947
|
+
seen.ref = innerType;
|
|
24948
|
+
};
|
|
24949
|
+
var readonlyProcessor = (schema, ctx, json, params) => {
|
|
24950
|
+
const def = schema._zod.def;
|
|
24951
|
+
process3(def.innerType, ctx, params);
|
|
24952
|
+
const seen = ctx.seen.get(schema);
|
|
24953
|
+
seen.ref = def.innerType;
|
|
24954
|
+
json.readOnly = true;
|
|
24955
|
+
};
|
|
24956
|
+
var optionalProcessor = (schema, ctx, _json, params) => {
|
|
24957
|
+
const def = schema._zod.def;
|
|
24958
|
+
process3(def.innerType, ctx, params);
|
|
24959
|
+
const seen = ctx.seen.get(schema);
|
|
24960
|
+
seen.ref = def.innerType;
|
|
24961
|
+
};
|
|
24962
|
+
// node_modules/zod/v4/classic/iso.js
|
|
24963
|
+
var ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
|
|
24964
|
+
$ZodISODateTime.init(inst, def);
|
|
24965
|
+
ZodStringFormat.init(inst, def);
|
|
24966
|
+
});
|
|
24967
|
+
function datetime2(params) {
|
|
24968
|
+
return _isoDateTime(ZodISODateTime, params);
|
|
24969
|
+
}
|
|
24970
|
+
var ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
|
|
24971
|
+
$ZodISODate.init(inst, def);
|
|
24972
|
+
ZodStringFormat.init(inst, def);
|
|
24973
|
+
});
|
|
24974
|
+
function date2(params) {
|
|
24975
|
+
return _isoDate(ZodISODate, params);
|
|
24976
|
+
}
|
|
24977
|
+
var ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
|
|
24978
|
+
$ZodISOTime.init(inst, def);
|
|
24979
|
+
ZodStringFormat.init(inst, def);
|
|
24980
|
+
});
|
|
24981
|
+
function time2(params) {
|
|
24982
|
+
return _isoTime(ZodISOTime, params);
|
|
24983
|
+
}
|
|
24984
|
+
var ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
|
|
24985
|
+
$ZodISODuration.init(inst, def);
|
|
24986
|
+
ZodStringFormat.init(inst, def);
|
|
24987
|
+
});
|
|
24988
|
+
function duration2(params) {
|
|
24989
|
+
return _isoDuration(ZodISODuration, params);
|
|
24990
|
+
}
|
|
24991
|
+
|
|
24992
|
+
// node_modules/zod/v4/classic/errors.js
|
|
24993
|
+
var initializer2 = (inst, issues) => {
|
|
24994
|
+
$ZodError.init(inst, issues);
|
|
24995
|
+
inst.name = "ZodError";
|
|
24996
|
+
Object.defineProperties(inst, {
|
|
24997
|
+
format: {
|
|
24998
|
+
value: (mapper) => formatError(inst, mapper)
|
|
24999
|
+
},
|
|
25000
|
+
flatten: {
|
|
25001
|
+
value: (mapper) => flattenError(inst, mapper)
|
|
25002
|
+
},
|
|
25003
|
+
addIssue: {
|
|
25004
|
+
value: (issue) => {
|
|
25005
|
+
inst.issues.push(issue);
|
|
25006
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
25007
|
+
}
|
|
25008
|
+
},
|
|
25009
|
+
addIssues: {
|
|
25010
|
+
value: (issues) => {
|
|
25011
|
+
inst.issues.push(...issues);
|
|
25012
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
25013
|
+
}
|
|
25014
|
+
},
|
|
25015
|
+
isEmpty: {
|
|
25016
|
+
get() {
|
|
25017
|
+
return inst.issues.length === 0;
|
|
25018
|
+
}
|
|
25019
|
+
}
|
|
25020
|
+
});
|
|
25021
|
+
};
|
|
25022
|
+
var ZodError = $constructor("ZodError", initializer2);
|
|
25023
|
+
var ZodRealError = $constructor("ZodError", initializer2, {
|
|
25024
|
+
Parent: Error
|
|
25025
|
+
});
|
|
25026
|
+
|
|
25027
|
+
// node_modules/zod/v4/classic/parse.js
|
|
25028
|
+
var parse3 = /* @__PURE__ */ _parse(ZodRealError);
|
|
25029
|
+
var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
25030
|
+
var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
25031
|
+
var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
25032
|
+
var encode = /* @__PURE__ */ _encode(ZodRealError);
|
|
25033
|
+
var decode = /* @__PURE__ */ _decode(ZodRealError);
|
|
25034
|
+
var encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
|
|
25035
|
+
var decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
|
|
25036
|
+
var safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
|
|
25037
|
+
var safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
|
|
25038
|
+
var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
25039
|
+
var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
25040
|
+
|
|
25041
|
+
// node_modules/zod/v4/classic/schemas.js
|
|
25042
|
+
var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
25043
|
+
$ZodType.init(inst, def);
|
|
25044
|
+
Object.assign(inst["~standard"], {
|
|
25045
|
+
jsonSchema: {
|
|
25046
|
+
input: createStandardJSONSchemaMethod(inst, "input"),
|
|
25047
|
+
output: createStandardJSONSchemaMethod(inst, "output")
|
|
25048
|
+
}
|
|
25049
|
+
});
|
|
25050
|
+
inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
|
|
25051
|
+
inst.def = def;
|
|
25052
|
+
inst.type = def.type;
|
|
25053
|
+
Object.defineProperty(inst, "_def", { value: def });
|
|
25054
|
+
inst.check = (...checks) => {
|
|
25055
|
+
return inst.clone(mergeDefs(def, {
|
|
25056
|
+
checks: [
|
|
25057
|
+
...def.checks ?? [],
|
|
25058
|
+
...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
|
|
25059
|
+
]
|
|
25060
|
+
}), {
|
|
25061
|
+
parent: true
|
|
25062
|
+
});
|
|
25063
|
+
};
|
|
25064
|
+
inst.with = inst.check;
|
|
25065
|
+
inst.clone = (def, params) => clone(inst, def, params);
|
|
25066
|
+
inst.brand = () => inst;
|
|
25067
|
+
inst.register = (reg, meta) => {
|
|
25068
|
+
reg.add(inst, meta);
|
|
25069
|
+
return inst;
|
|
25070
|
+
};
|
|
25071
|
+
inst.parse = (data, params) => parse3(inst, data, params, { callee: inst.parse });
|
|
25072
|
+
inst.safeParse = (data, params) => safeParse2(inst, data, params);
|
|
25073
|
+
inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
|
|
25074
|
+
inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
|
|
25075
|
+
inst.spa = inst.safeParseAsync;
|
|
25076
|
+
inst.encode = (data, params) => encode(inst, data, params);
|
|
25077
|
+
inst.decode = (data, params) => decode(inst, data, params);
|
|
25078
|
+
inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
|
|
25079
|
+
inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
|
|
25080
|
+
inst.safeEncode = (data, params) => safeEncode(inst, data, params);
|
|
25081
|
+
inst.safeDecode = (data, params) => safeDecode(inst, data, params);
|
|
25082
|
+
inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
|
|
25083
|
+
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
|
|
25084
|
+
inst.refine = (check, params) => inst.check(refine(check, params));
|
|
25085
|
+
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
|
25086
|
+
inst.overwrite = (fn) => inst.check(_overwrite(fn));
|
|
25087
|
+
inst.optional = () => optional(inst);
|
|
25088
|
+
inst.exactOptional = () => exactOptional(inst);
|
|
25089
|
+
inst.nullable = () => nullable(inst);
|
|
25090
|
+
inst.nullish = () => optional(nullable(inst));
|
|
25091
|
+
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
25092
|
+
inst.array = () => array(inst);
|
|
25093
|
+
inst.or = (arg) => union([inst, arg]);
|
|
25094
|
+
inst.and = (arg) => intersection(inst, arg);
|
|
25095
|
+
inst.transform = (tx) => pipe(inst, transform(tx));
|
|
25096
|
+
inst.default = (def) => _default(inst, def);
|
|
25097
|
+
inst.prefault = (def) => prefault(inst, def);
|
|
25098
|
+
inst.catch = (params) => _catch(inst, params);
|
|
25099
|
+
inst.pipe = (target) => pipe(inst, target);
|
|
25100
|
+
inst.readonly = () => readonly(inst);
|
|
25101
|
+
inst.describe = (description) => {
|
|
25102
|
+
const cl = inst.clone();
|
|
25103
|
+
globalRegistry.add(cl, { description });
|
|
25104
|
+
return cl;
|
|
25105
|
+
};
|
|
25106
|
+
Object.defineProperty(inst, "description", {
|
|
25107
|
+
get() {
|
|
25108
|
+
return globalRegistry.get(inst)?.description;
|
|
25109
|
+
},
|
|
25110
|
+
configurable: true
|
|
25111
|
+
});
|
|
25112
|
+
inst.meta = (...args) => {
|
|
25113
|
+
if (args.length === 0) {
|
|
25114
|
+
return globalRegistry.get(inst);
|
|
25115
|
+
}
|
|
25116
|
+
const cl = inst.clone();
|
|
25117
|
+
globalRegistry.add(cl, args[0]);
|
|
25118
|
+
return cl;
|
|
25119
|
+
};
|
|
25120
|
+
inst.isOptional = () => inst.safeParse(undefined).success;
|
|
25121
|
+
inst.isNullable = () => inst.safeParse(null).success;
|
|
25122
|
+
inst.apply = (fn) => fn(inst);
|
|
25123
|
+
return inst;
|
|
25124
|
+
});
|
|
25125
|
+
var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
25126
|
+
$ZodString.init(inst, def);
|
|
25127
|
+
ZodType.init(inst, def);
|
|
25128
|
+
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
|
|
25129
|
+
const bag = inst._zod.bag;
|
|
25130
|
+
inst.format = bag.format ?? null;
|
|
25131
|
+
inst.minLength = bag.minimum ?? null;
|
|
25132
|
+
inst.maxLength = bag.maximum ?? null;
|
|
25133
|
+
inst.regex = (...args) => inst.check(_regex(...args));
|
|
25134
|
+
inst.includes = (...args) => inst.check(_includes(...args));
|
|
25135
|
+
inst.startsWith = (...args) => inst.check(_startsWith(...args));
|
|
25136
|
+
inst.endsWith = (...args) => inst.check(_endsWith(...args));
|
|
25137
|
+
inst.min = (...args) => inst.check(_minLength(...args));
|
|
25138
|
+
inst.max = (...args) => inst.check(_maxLength(...args));
|
|
25139
|
+
inst.length = (...args) => inst.check(_length(...args));
|
|
25140
|
+
inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
|
|
25141
|
+
inst.lowercase = (params) => inst.check(_lowercase(params));
|
|
25142
|
+
inst.uppercase = (params) => inst.check(_uppercase(params));
|
|
25143
|
+
inst.trim = () => inst.check(_trim());
|
|
25144
|
+
inst.normalize = (...args) => inst.check(_normalize(...args));
|
|
25145
|
+
inst.toLowerCase = () => inst.check(_toLowerCase());
|
|
25146
|
+
inst.toUpperCase = () => inst.check(_toUpperCase());
|
|
25147
|
+
inst.slugify = () => inst.check(_slugify());
|
|
25148
|
+
});
|
|
25149
|
+
var ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
|
|
25150
|
+
$ZodString.init(inst, def);
|
|
25151
|
+
_ZodString.init(inst, def);
|
|
25152
|
+
inst.email = (params) => inst.check(_email(ZodEmail, params));
|
|
25153
|
+
inst.url = (params) => inst.check(_url(ZodURL, params));
|
|
25154
|
+
inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
|
|
25155
|
+
inst.emoji = (params) => inst.check(_emoji2(ZodEmoji, params));
|
|
25156
|
+
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
25157
|
+
inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
|
|
25158
|
+
inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
|
|
25159
|
+
inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
|
|
25160
|
+
inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
|
|
25161
|
+
inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
|
|
25162
|
+
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
25163
|
+
inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
|
|
25164
|
+
inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
|
|
25165
|
+
inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
|
|
25166
|
+
inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
|
|
25167
|
+
inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
|
|
25168
|
+
inst.xid = (params) => inst.check(_xid(ZodXID, params));
|
|
25169
|
+
inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
|
|
25170
|
+
inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
|
|
25171
|
+
inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
|
|
25172
|
+
inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
|
|
25173
|
+
inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
|
|
25174
|
+
inst.e164 = (params) => inst.check(_e164(ZodE164, params));
|
|
25175
|
+
inst.datetime = (params) => inst.check(datetime2(params));
|
|
25176
|
+
inst.date = (params) => inst.check(date2(params));
|
|
25177
|
+
inst.time = (params) => inst.check(time2(params));
|
|
25178
|
+
inst.duration = (params) => inst.check(duration2(params));
|
|
25179
|
+
});
|
|
25180
|
+
function string2(params) {
|
|
25181
|
+
return _string(ZodString, params);
|
|
25182
|
+
}
|
|
25183
|
+
var ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
|
|
25184
|
+
$ZodStringFormat.init(inst, def);
|
|
25185
|
+
_ZodString.init(inst, def);
|
|
25186
|
+
});
|
|
25187
|
+
var ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (inst, def) => {
|
|
25188
|
+
$ZodEmail.init(inst, def);
|
|
25189
|
+
ZodStringFormat.init(inst, def);
|
|
25190
|
+
});
|
|
25191
|
+
var ZodGUID = /* @__PURE__ */ $constructor("ZodGUID", (inst, def) => {
|
|
25192
|
+
$ZodGUID.init(inst, def);
|
|
25193
|
+
ZodStringFormat.init(inst, def);
|
|
25194
|
+
});
|
|
25195
|
+
var ZodUUID = /* @__PURE__ */ $constructor("ZodUUID", (inst, def) => {
|
|
25196
|
+
$ZodUUID.init(inst, def);
|
|
25197
|
+
ZodStringFormat.init(inst, def);
|
|
25198
|
+
});
|
|
25199
|
+
var ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
|
|
25200
|
+
$ZodURL.init(inst, def);
|
|
25201
|
+
ZodStringFormat.init(inst, def);
|
|
25202
|
+
});
|
|
25203
|
+
var ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
|
|
25204
|
+
$ZodEmoji.init(inst, def);
|
|
25205
|
+
ZodStringFormat.init(inst, def);
|
|
25206
|
+
});
|
|
25207
|
+
var ZodNanoID = /* @__PURE__ */ $constructor("ZodNanoID", (inst, def) => {
|
|
25208
|
+
$ZodNanoID.init(inst, def);
|
|
25209
|
+
ZodStringFormat.init(inst, def);
|
|
25210
|
+
});
|
|
25211
|
+
var ZodCUID = /* @__PURE__ */ $constructor("ZodCUID", (inst, def) => {
|
|
25212
|
+
$ZodCUID.init(inst, def);
|
|
25213
|
+
ZodStringFormat.init(inst, def);
|
|
25214
|
+
});
|
|
25215
|
+
var ZodCUID2 = /* @__PURE__ */ $constructor("ZodCUID2", (inst, def) => {
|
|
25216
|
+
$ZodCUID2.init(inst, def);
|
|
25217
|
+
ZodStringFormat.init(inst, def);
|
|
25218
|
+
});
|
|
25219
|
+
var ZodULID = /* @__PURE__ */ $constructor("ZodULID", (inst, def) => {
|
|
25220
|
+
$ZodULID.init(inst, def);
|
|
25221
|
+
ZodStringFormat.init(inst, def);
|
|
25222
|
+
});
|
|
25223
|
+
var ZodXID = /* @__PURE__ */ $constructor("ZodXID", (inst, def) => {
|
|
25224
|
+
$ZodXID.init(inst, def);
|
|
25225
|
+
ZodStringFormat.init(inst, def);
|
|
25226
|
+
});
|
|
25227
|
+
var ZodKSUID = /* @__PURE__ */ $constructor("ZodKSUID", (inst, def) => {
|
|
25228
|
+
$ZodKSUID.init(inst, def);
|
|
25229
|
+
ZodStringFormat.init(inst, def);
|
|
25230
|
+
});
|
|
25231
|
+
var ZodIPv4 = /* @__PURE__ */ $constructor("ZodIPv4", (inst, def) => {
|
|
25232
|
+
$ZodIPv4.init(inst, def);
|
|
25233
|
+
ZodStringFormat.init(inst, def);
|
|
25234
|
+
});
|
|
25235
|
+
var ZodIPv6 = /* @__PURE__ */ $constructor("ZodIPv6", (inst, def) => {
|
|
25236
|
+
$ZodIPv6.init(inst, def);
|
|
25237
|
+
ZodStringFormat.init(inst, def);
|
|
25238
|
+
});
|
|
25239
|
+
var ZodCIDRv4 = /* @__PURE__ */ $constructor("ZodCIDRv4", (inst, def) => {
|
|
25240
|
+
$ZodCIDRv4.init(inst, def);
|
|
25241
|
+
ZodStringFormat.init(inst, def);
|
|
25242
|
+
});
|
|
25243
|
+
var ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (inst, def) => {
|
|
25244
|
+
$ZodCIDRv6.init(inst, def);
|
|
25245
|
+
ZodStringFormat.init(inst, def);
|
|
25246
|
+
});
|
|
25247
|
+
var ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
|
|
25248
|
+
$ZodBase64.init(inst, def);
|
|
25249
|
+
ZodStringFormat.init(inst, def);
|
|
25250
|
+
});
|
|
25251
|
+
var ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
|
|
25252
|
+
$ZodBase64URL.init(inst, def);
|
|
25253
|
+
ZodStringFormat.init(inst, def);
|
|
25254
|
+
});
|
|
25255
|
+
var ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
|
|
25256
|
+
$ZodE164.init(inst, def);
|
|
25257
|
+
ZodStringFormat.init(inst, def);
|
|
25258
|
+
});
|
|
25259
|
+
var ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
|
|
25260
|
+
$ZodJWT.init(inst, def);
|
|
25261
|
+
ZodStringFormat.init(inst, def);
|
|
25262
|
+
});
|
|
25263
|
+
var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
25264
|
+
$ZodUnknown.init(inst, def);
|
|
25265
|
+
ZodType.init(inst, def);
|
|
25266
|
+
inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
|
|
25267
|
+
});
|
|
25268
|
+
function unknown() {
|
|
25269
|
+
return _unknown(ZodUnknown);
|
|
25270
|
+
}
|
|
25271
|
+
var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
25272
|
+
$ZodNever.init(inst, def);
|
|
25273
|
+
ZodType.init(inst, def);
|
|
25274
|
+
inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
|
|
25275
|
+
});
|
|
25276
|
+
function never(params) {
|
|
25277
|
+
return _never(ZodNever, params);
|
|
25278
|
+
}
|
|
25279
|
+
var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
25280
|
+
$ZodArray.init(inst, def);
|
|
25281
|
+
ZodType.init(inst, def);
|
|
25282
|
+
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
25283
|
+
inst.element = def.element;
|
|
25284
|
+
inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
|
|
25285
|
+
inst.nonempty = (params) => inst.check(_minLength(1, params));
|
|
25286
|
+
inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
|
|
25287
|
+
inst.length = (len, params) => inst.check(_length(len, params));
|
|
25288
|
+
inst.unwrap = () => inst.element;
|
|
25289
|
+
});
|
|
25290
|
+
function array(element, params) {
|
|
25291
|
+
return _array(ZodArray, element, params);
|
|
25292
|
+
}
|
|
25293
|
+
var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
25294
|
+
$ZodObjectJIT.init(inst, def);
|
|
25295
|
+
ZodType.init(inst, def);
|
|
25296
|
+
inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
|
|
25297
|
+
defineLazy(inst, "shape", () => {
|
|
25298
|
+
return def.shape;
|
|
25299
|
+
});
|
|
25300
|
+
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
25301
|
+
inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
|
|
25302
|
+
inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
25303
|
+
inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
|
|
25304
|
+
inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
|
|
25305
|
+
inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
|
|
25306
|
+
inst.extend = (incoming) => {
|
|
25307
|
+
return extend(inst, incoming);
|
|
25308
|
+
};
|
|
25309
|
+
inst.safeExtend = (incoming) => {
|
|
25310
|
+
return safeExtend(inst, incoming);
|
|
25311
|
+
};
|
|
25312
|
+
inst.merge = (other) => merge(inst, other);
|
|
25313
|
+
inst.pick = (mask) => pick(inst, mask);
|
|
25314
|
+
inst.omit = (mask) => omit(inst, mask);
|
|
25315
|
+
inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
|
|
25316
|
+
inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
|
|
25317
|
+
});
|
|
25318
|
+
function object(shape, params) {
|
|
25319
|
+
const def = {
|
|
25320
|
+
type: "object",
|
|
25321
|
+
shape: shape ?? {},
|
|
25322
|
+
...normalizeParams(params)
|
|
25323
|
+
};
|
|
25324
|
+
return new ZodObject(def);
|
|
25325
|
+
}
|
|
25326
|
+
var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
25327
|
+
$ZodUnion.init(inst, def);
|
|
25328
|
+
ZodType.init(inst, def);
|
|
25329
|
+
inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
|
|
25330
|
+
inst.options = def.options;
|
|
25331
|
+
});
|
|
25332
|
+
function union(options, params) {
|
|
25333
|
+
return new ZodUnion({
|
|
25334
|
+
type: "union",
|
|
25335
|
+
options,
|
|
25336
|
+
...normalizeParams(params)
|
|
25337
|
+
});
|
|
25338
|
+
}
|
|
25339
|
+
var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
25340
|
+
$ZodIntersection.init(inst, def);
|
|
25341
|
+
ZodType.init(inst, def);
|
|
25342
|
+
inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
|
|
25343
|
+
});
|
|
25344
|
+
function intersection(left, right) {
|
|
25345
|
+
return new ZodIntersection({
|
|
25346
|
+
type: "intersection",
|
|
25347
|
+
left,
|
|
25348
|
+
right
|
|
25349
|
+
});
|
|
25350
|
+
}
|
|
25351
|
+
var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
25352
|
+
$ZodEnum.init(inst, def);
|
|
25353
|
+
ZodType.init(inst, def);
|
|
25354
|
+
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
|
|
25355
|
+
inst.enum = def.entries;
|
|
25356
|
+
inst.options = Object.values(def.entries);
|
|
25357
|
+
const keys = new Set(Object.keys(def.entries));
|
|
25358
|
+
inst.extract = (values, params) => {
|
|
25359
|
+
const newEntries = {};
|
|
25360
|
+
for (const value of values) {
|
|
25361
|
+
if (keys.has(value)) {
|
|
25362
|
+
newEntries[value] = def.entries[value];
|
|
25363
|
+
} else
|
|
25364
|
+
throw new Error(`Key ${value} not found in enum`);
|
|
25365
|
+
}
|
|
25366
|
+
return new ZodEnum({
|
|
25367
|
+
...def,
|
|
25368
|
+
checks: [],
|
|
25369
|
+
...normalizeParams(params),
|
|
25370
|
+
entries: newEntries
|
|
25371
|
+
});
|
|
25372
|
+
};
|
|
25373
|
+
inst.exclude = (values, params) => {
|
|
25374
|
+
const newEntries = { ...def.entries };
|
|
25375
|
+
for (const value of values) {
|
|
25376
|
+
if (keys.has(value)) {
|
|
25377
|
+
delete newEntries[value];
|
|
25378
|
+
} else
|
|
25379
|
+
throw new Error(`Key ${value} not found in enum`);
|
|
25380
|
+
}
|
|
25381
|
+
return new ZodEnum({
|
|
25382
|
+
...def,
|
|
25383
|
+
checks: [],
|
|
25384
|
+
...normalizeParams(params),
|
|
25385
|
+
entries: newEntries
|
|
25386
|
+
});
|
|
25387
|
+
};
|
|
25388
|
+
});
|
|
25389
|
+
function _enum(values, params) {
|
|
25390
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
25391
|
+
return new ZodEnum({
|
|
25392
|
+
type: "enum",
|
|
25393
|
+
entries,
|
|
25394
|
+
...normalizeParams(params)
|
|
25395
|
+
});
|
|
25396
|
+
}
|
|
25397
|
+
var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
25398
|
+
$ZodTransform.init(inst, def);
|
|
25399
|
+
ZodType.init(inst, def);
|
|
25400
|
+
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
|
|
25401
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
25402
|
+
if (_ctx.direction === "backward") {
|
|
25403
|
+
throw new $ZodEncodeError(inst.constructor.name);
|
|
25404
|
+
}
|
|
25405
|
+
payload.addIssue = (issue2) => {
|
|
25406
|
+
if (typeof issue2 === "string") {
|
|
25407
|
+
payload.issues.push(issue(issue2, payload.value, def));
|
|
25408
|
+
} else {
|
|
25409
|
+
const _issue = issue2;
|
|
25410
|
+
if (_issue.fatal)
|
|
25411
|
+
_issue.continue = false;
|
|
25412
|
+
_issue.code ?? (_issue.code = "custom");
|
|
25413
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
25414
|
+
_issue.inst ?? (_issue.inst = inst);
|
|
25415
|
+
payload.issues.push(issue(_issue));
|
|
25416
|
+
}
|
|
25417
|
+
};
|
|
25418
|
+
const output = def.transform(payload.value, payload);
|
|
25419
|
+
if (output instanceof Promise) {
|
|
25420
|
+
return output.then((output) => {
|
|
25421
|
+
payload.value = output;
|
|
25422
|
+
return payload;
|
|
25423
|
+
});
|
|
25424
|
+
}
|
|
25425
|
+
payload.value = output;
|
|
25426
|
+
return payload;
|
|
25427
|
+
};
|
|
25428
|
+
});
|
|
25429
|
+
function transform(fn) {
|
|
25430
|
+
return new ZodTransform({
|
|
25431
|
+
type: "transform",
|
|
25432
|
+
transform: fn
|
|
25433
|
+
});
|
|
25434
|
+
}
|
|
25435
|
+
var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
25436
|
+
$ZodOptional.init(inst, def);
|
|
25437
|
+
ZodType.init(inst, def);
|
|
25438
|
+
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
25439
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
25440
|
+
});
|
|
25441
|
+
function optional(innerType) {
|
|
25442
|
+
return new ZodOptional({
|
|
25443
|
+
type: "optional",
|
|
25444
|
+
innerType
|
|
25445
|
+
});
|
|
25446
|
+
}
|
|
25447
|
+
var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
25448
|
+
$ZodExactOptional.init(inst, def);
|
|
25449
|
+
ZodType.init(inst, def);
|
|
25450
|
+
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
25451
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
25452
|
+
});
|
|
25453
|
+
function exactOptional(innerType) {
|
|
25454
|
+
return new ZodExactOptional({
|
|
25455
|
+
type: "optional",
|
|
25456
|
+
innerType
|
|
25457
|
+
});
|
|
25458
|
+
}
|
|
25459
|
+
var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
25460
|
+
$ZodNullable.init(inst, def);
|
|
25461
|
+
ZodType.init(inst, def);
|
|
25462
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
|
|
25463
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
25464
|
+
});
|
|
25465
|
+
function nullable(innerType) {
|
|
25466
|
+
return new ZodNullable({
|
|
25467
|
+
type: "nullable",
|
|
25468
|
+
innerType
|
|
25469
|
+
});
|
|
25470
|
+
}
|
|
25471
|
+
var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
25472
|
+
$ZodDefault.init(inst, def);
|
|
25473
|
+
ZodType.init(inst, def);
|
|
25474
|
+
inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
|
|
25475
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
25476
|
+
inst.removeDefault = inst.unwrap;
|
|
25477
|
+
});
|
|
25478
|
+
function _default(innerType, defaultValue) {
|
|
25479
|
+
return new ZodDefault({
|
|
25480
|
+
type: "default",
|
|
25481
|
+
innerType,
|
|
25482
|
+
get defaultValue() {
|
|
25483
|
+
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
25484
|
+
}
|
|
25485
|
+
});
|
|
25486
|
+
}
|
|
25487
|
+
var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
25488
|
+
$ZodPrefault.init(inst, def);
|
|
25489
|
+
ZodType.init(inst, def);
|
|
25490
|
+
inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
|
|
25491
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
25492
|
+
});
|
|
25493
|
+
function prefault(innerType, defaultValue) {
|
|
25494
|
+
return new ZodPrefault({
|
|
25495
|
+
type: "prefault",
|
|
25496
|
+
innerType,
|
|
25497
|
+
get defaultValue() {
|
|
25498
|
+
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
25499
|
+
}
|
|
25500
|
+
});
|
|
25501
|
+
}
|
|
25502
|
+
var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
25503
|
+
$ZodNonOptional.init(inst, def);
|
|
25504
|
+
ZodType.init(inst, def);
|
|
25505
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
|
|
25506
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
25507
|
+
});
|
|
25508
|
+
function nonoptional(innerType, params) {
|
|
25509
|
+
return new ZodNonOptional({
|
|
25510
|
+
type: "nonoptional",
|
|
25511
|
+
innerType,
|
|
25512
|
+
...normalizeParams(params)
|
|
25513
|
+
});
|
|
25514
|
+
}
|
|
25515
|
+
var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
25516
|
+
$ZodCatch.init(inst, def);
|
|
25517
|
+
ZodType.init(inst, def);
|
|
25518
|
+
inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
|
|
25519
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
25520
|
+
inst.removeCatch = inst.unwrap;
|
|
25521
|
+
});
|
|
25522
|
+
function _catch(innerType, catchValue) {
|
|
25523
|
+
return new ZodCatch({
|
|
25524
|
+
type: "catch",
|
|
25525
|
+
innerType,
|
|
25526
|
+
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
25527
|
+
});
|
|
25528
|
+
}
|
|
25529
|
+
var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
25530
|
+
$ZodPipe.init(inst, def);
|
|
25531
|
+
ZodType.init(inst, def);
|
|
25532
|
+
inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
|
|
25533
|
+
inst.in = def.in;
|
|
25534
|
+
inst.out = def.out;
|
|
25535
|
+
});
|
|
25536
|
+
function pipe(in_, out) {
|
|
25537
|
+
return new ZodPipe({
|
|
25538
|
+
type: "pipe",
|
|
25539
|
+
in: in_,
|
|
25540
|
+
out
|
|
25541
|
+
});
|
|
25542
|
+
}
|
|
25543
|
+
var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
25544
|
+
$ZodReadonly.init(inst, def);
|
|
25545
|
+
ZodType.init(inst, def);
|
|
25546
|
+
inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
|
|
25547
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
25548
|
+
});
|
|
25549
|
+
function readonly(innerType) {
|
|
25550
|
+
return new ZodReadonly({
|
|
25551
|
+
type: "readonly",
|
|
25552
|
+
innerType
|
|
25553
|
+
});
|
|
25554
|
+
}
|
|
25555
|
+
var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
25556
|
+
$ZodCustom.init(inst, def);
|
|
25557
|
+
ZodType.init(inst, def);
|
|
25558
|
+
inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
|
|
25559
|
+
});
|
|
25560
|
+
function refine(fn, _params = {}) {
|
|
25561
|
+
return _refine(ZodCustom, fn, _params);
|
|
25562
|
+
}
|
|
25563
|
+
function superRefine(fn) {
|
|
25564
|
+
return _superRefine(fn);
|
|
25565
|
+
}
|
|
25566
|
+
// src/commands/wiki.ts
|
|
25567
|
+
init_errors();
|
|
25568
|
+
|
|
25569
|
+
// src/lib/collections.ts
|
|
25570
|
+
init_errors();
|
|
25571
|
+
var UUID_RE2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
25572
|
+
async function resolveCollectionIdForGrant(ctx, ref) {
|
|
25573
|
+
if (UUID_RE2.test(ref)) {
|
|
25574
|
+
return ref;
|
|
25575
|
+
}
|
|
25576
|
+
const all = await ctx.api.get("/api/admin/collections", {
|
|
25577
|
+
params: { active_only: "false" }
|
|
25578
|
+
});
|
|
25579
|
+
const bySlug = all.find((c) => c.slug === ref);
|
|
25580
|
+
if (bySlug)
|
|
25581
|
+
return bySlug.id;
|
|
25582
|
+
const byName = all.find((c) => c.name === ref);
|
|
25583
|
+
if (byName)
|
|
25584
|
+
return byName.id;
|
|
25585
|
+
throw new CLIError(`Collection '${ref}' not found (tried UUID, slug, and name).`, 3 /* NotFound */, "Run `martha documents collections --tree` to see available collections.");
|
|
25586
|
+
}
|
|
25587
|
+
|
|
25588
|
+
// src/commands/wiki.ts
|
|
25589
|
+
var DEFAULT_WIKI_SLUG = "default";
|
|
25590
|
+
function deriveWikiSlug(name, explicit) {
|
|
25591
|
+
const source = explicit ?? name ?? "";
|
|
25592
|
+
const slug = source.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
25593
|
+
if (!slug) {
|
|
25594
|
+
throw new CLIError(explicit ? `--slug '${explicit}' is not a valid slug (needs a letter or digit).` : `Cannot derive a slug from name '${name}' — pass --slug explicitly.`, 4 /* Validation */);
|
|
25595
|
+
}
|
|
25596
|
+
return slug;
|
|
25597
|
+
}
|
|
25598
|
+
function parseCollectionRefs(csv) {
|
|
25599
|
+
if (!csv)
|
|
25600
|
+
return [];
|
|
25601
|
+
return csv.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
25602
|
+
}
|
|
25603
|
+
function registerWikiCommands(program) {
|
|
25604
|
+
const cmd = program.command("wiki").description("Manage wikis: list/create/delete wikis, browse pages, search, schema, settings (#631)");
|
|
25605
|
+
function getCtx() {
|
|
25606
|
+
const ctx = createContext({
|
|
25607
|
+
profileOverride: program.opts().profile,
|
|
25608
|
+
verbose: program.opts().verbose
|
|
25609
|
+
});
|
|
25610
|
+
if (program.opts().apiUrl)
|
|
25611
|
+
ctx.profile.api_url = program.opts().apiUrl;
|
|
25612
|
+
return ctx;
|
|
25613
|
+
}
|
|
25614
|
+
function isJson() {
|
|
25615
|
+
return !!program.opts().json;
|
|
25616
|
+
}
|
|
25617
|
+
cmd.command("list").description("List the tenant's wikis (only those you can see)").action(async () => {
|
|
25618
|
+
const ctx = getCtx();
|
|
25619
|
+
const resp = await ctx.api.get("/api/wiki/wikis");
|
|
25620
|
+
const wikis = resp.wikis ?? [];
|
|
25621
|
+
if (isJson()) {
|
|
25622
|
+
console.log(JSON.stringify(wikis, null, 2));
|
|
25623
|
+
return;
|
|
25624
|
+
}
|
|
25625
|
+
if (wikis.length === 0) {
|
|
25626
|
+
console.log(source_default.dim("No wikis. Create one: martha wiki create --name <name> --collections <a,b,c>"));
|
|
25627
|
+
return;
|
|
25628
|
+
}
|
|
25629
|
+
const columns = [
|
|
25630
|
+
{ header: "SLUG", accessor: (w) => w.slug },
|
|
25631
|
+
{ header: "NAME", accessor: (w) => w.name.slice(0, 40) },
|
|
25632
|
+
{
|
|
25633
|
+
header: "COLLECTIONS",
|
|
25634
|
+
accessor: (w) => String(w.source_collection_ids.length)
|
|
25635
|
+
},
|
|
25636
|
+
{
|
|
25637
|
+
header: "CREATED",
|
|
25638
|
+
accessor: (w) => w.created_at ? w.created_at.slice(0, 10) : "-"
|
|
25639
|
+
}
|
|
25640
|
+
];
|
|
25641
|
+
const widths = columns.map((col) => Math.max(col.header.length, ...wikis.map((w) => col.accessor(w).length)));
|
|
25642
|
+
const header = columns.map((col, i) => col.header.padEnd(widths[i])).join(" ");
|
|
25643
|
+
console.log(source_default.bold(header));
|
|
25644
|
+
console.log(source_default.dim("-".repeat(header.length)));
|
|
25645
|
+
for (const w of wikis) {
|
|
25646
|
+
console.log(columns.map((col, i) => col.accessor(w).padEnd(widths[i])).join(" "));
|
|
25647
|
+
}
|
|
25648
|
+
console.log(source_default.dim(`
|
|
25649
|
+
${wikis.length} wiki${wikis.length === 1 ? "" : "s"}`));
|
|
25650
|
+
});
|
|
25651
|
+
cmd.command("create").description("Create a wiki scoped to a set of source collections (admin only)").requiredOption("--name <name>", "Human-readable wiki name").option("--slug <slug>", "URL slug (default: derived from --name)").option("--collections <refs>", "Comma-separated collections (UUID, slug, or name) the wiki compiles from AND its visibility boundary; empty = visible-to-all, compiles nothing").action(async (opts) => {
|
|
25652
|
+
const ctx = getCtx();
|
|
25653
|
+
const slug = deriveWikiSlug(opts.name, opts.slug);
|
|
25654
|
+
const refs = parseCollectionRefs(opts.collections);
|
|
25655
|
+
const source_collection_ids = [];
|
|
25656
|
+
for (const ref of refs) {
|
|
25657
|
+
source_collection_ids.push(await resolveCollectionIdForGrant(ctx, ref));
|
|
25658
|
+
}
|
|
25659
|
+
const wiki = await ctx.api.post("/api/wiki/wikis", {
|
|
25660
|
+
name: opts.name,
|
|
25661
|
+
slug,
|
|
25662
|
+
source_collection_ids
|
|
25663
|
+
});
|
|
25664
|
+
if (isJson()) {
|
|
25665
|
+
console.log(JSON.stringify(wiki, null, 2));
|
|
25666
|
+
return;
|
|
25667
|
+
}
|
|
25668
|
+
console.log(source_default.green(`✓ created wiki '${wiki.slug}'`));
|
|
25669
|
+
console.log(source_default.dim(` id=${wiki.id} name=${wiki.name} collections=${wiki.source_collection_ids.length}`));
|
|
25670
|
+
});
|
|
25671
|
+
cmd.command("delete <slug>").description("Soft-delete a wiki and its pages (admin only)").option("--yes", "Skip confirmation").action(async (slug, opts) => {
|
|
25672
|
+
const ctx = getCtx();
|
|
25673
|
+
if (!opts.yes) {
|
|
25674
|
+
await confirmInteractive(`Delete wiki '${slug}' and all its compiled pages?`);
|
|
25675
|
+
}
|
|
25676
|
+
await ctx.api.del(`/api/wiki/wikis/${encodeURIComponent(slug)}`);
|
|
25677
|
+
if (isJson()) {
|
|
25678
|
+
console.log(JSON.stringify({ slug, deleted: true }));
|
|
25679
|
+
} else {
|
|
25680
|
+
console.log(source_default.green(`✓ deleted wiki '${slug}'`));
|
|
25681
|
+
}
|
|
25682
|
+
});
|
|
25683
|
+
cmd.command("pages").description("List compiled wiki pages (--wiki scopes to one wiki)").option("--wiki <slug>", "Wiki slug (default: the tenant default wiki)").action(async (opts) => {
|
|
25684
|
+
const ctx = getCtx();
|
|
25685
|
+
const slug = encodeURIComponent(opts.wiki ?? DEFAULT_WIKI_SLUG);
|
|
25686
|
+
const resp = await ctx.api.get(`/api/wiki/${slug}/pages`);
|
|
25687
|
+
const pages = resp.pages ?? [];
|
|
25688
|
+
if (isJson()) {
|
|
25689
|
+
console.log(JSON.stringify(pages, null, 2));
|
|
25690
|
+
return;
|
|
25691
|
+
}
|
|
25692
|
+
if (pages.length === 0) {
|
|
25693
|
+
console.log(source_default.dim("No wiki pages compiled yet."));
|
|
25694
|
+
return;
|
|
25695
|
+
}
|
|
25696
|
+
const columns = [
|
|
25697
|
+
{ header: "PATH", accessor: (p) => p.path },
|
|
25698
|
+
{ header: "TITLE", accessor: (p) => p.title.slice(0, 60) },
|
|
25699
|
+
{ header: "SOURCES", accessor: (p) => String(p.sources_count) },
|
|
25700
|
+
{
|
|
25701
|
+
header: "COMPILED",
|
|
25702
|
+
accessor: (p) => p.last_compiled_at ? new Date(p.last_compiled_at).toISOString().slice(0, 19).replace("T", " ") : "-"
|
|
25703
|
+
}
|
|
25704
|
+
];
|
|
25705
|
+
const widths = columns.map((col) => Math.max(col.header.length, ...pages.map((p) => col.accessor(p).length)));
|
|
25706
|
+
const header = columns.map((col, i) => col.header.padEnd(widths[i])).join(" ");
|
|
25707
|
+
console.log(source_default.bold(header));
|
|
25708
|
+
console.log(source_default.dim("-".repeat(header.length)));
|
|
25709
|
+
for (const p of pages) {
|
|
25710
|
+
console.log(columns.map((col, i) => col.accessor(p).padEnd(widths[i])).join(" "));
|
|
25711
|
+
}
|
|
25712
|
+
console.log(source_default.dim(`
|
|
25713
|
+
${pages.length} pages`));
|
|
25714
|
+
});
|
|
25715
|
+
cmd.command("get <path>").description("Fetch the raw markdown body of a wiki page").option("--wiki <slug>", "Wiki slug (default: the tenant default wiki)").option("--out <file>", "Write body to file instead of stdout").action(async (path, opts) => {
|
|
25716
|
+
const ctx = getCtx();
|
|
25717
|
+
const safe = path.split("/").map(encodeURIComponent).join("/");
|
|
25718
|
+
const slug = encodeURIComponent(opts.wiki ?? DEFAULT_WIKI_SLUG);
|
|
25719
|
+
const endpoint = `/api/wiki/${slug}/pages/${safe}`;
|
|
25720
|
+
const resp = await ctx.api.getRaw(endpoint, {
|
|
25721
|
+
headers: { Accept: "application/json" }
|
|
25722
|
+
});
|
|
25723
|
+
const page = object({ body: string2() }).safeParse(await resp.json());
|
|
25724
|
+
if (!page.success) {
|
|
25725
|
+
throw new CLIError("Invalid wiki page response: missing markdown body", 1 /* Error */);
|
|
25726
|
+
}
|
|
25727
|
+
const body = page.data.body;
|
|
25728
|
+
const bytes = Buffer.byteLength(body, "utf8");
|
|
22044
25729
|
if (opts.out) {
|
|
22045
25730
|
fs11.writeFileSync(opts.out, body);
|
|
22046
25731
|
if (!isJson()) {
|
|
22047
|
-
console.log(source_default.dim(`wrote ${
|
|
25732
|
+
console.log(source_default.dim(`wrote ${bytes} bytes to ${opts.out}`));
|
|
22048
25733
|
} else {
|
|
22049
|
-
console.log(JSON.stringify({ path, bytes
|
|
25734
|
+
console.log(JSON.stringify({ path, bytes, file: opts.out }));
|
|
22050
25735
|
}
|
|
22051
25736
|
return;
|
|
22052
25737
|
}
|
|
@@ -23933,7 +27618,7 @@ function authHeaders(ctx, token) {
|
|
|
23933
27618
|
const tenant = ctx.tenantFor(token);
|
|
23934
27619
|
return {
|
|
23935
27620
|
Authorization: `Bearer ${token}`,
|
|
23936
|
-
...tenant ? { "X-
|
|
27621
|
+
...tenant ? { "X-Tenant-Id": tenant } : {}
|
|
23937
27622
|
};
|
|
23938
27623
|
}
|
|
23939
27624
|
function apiUrl(ctx, path) {
|
|
@@ -24396,7 +28081,7 @@ function registerUpdateCommand(program) {
|
|
|
24396
28081
|
|
|
24397
28082
|
// src/index.ts
|
|
24398
28083
|
var program2 = new Command2;
|
|
24399
|
-
program2.name("martha").description("Terminal-first client for the Martha AI platform").version(CLI_VERSION).option("--profile <name>", "Use a named profile").option("--json", "Machine-readable JSON output").option("--quiet", "Suppress non-essential output").option("--verbose", "Verbose logging").option("--no-color", "Disable color output").option("--api-url <url>", "Override API base URL").option("--org <tenant>", "Organization to act in (X-
|
|
28084
|
+
program2.name("martha").description("Terminal-first client for the Martha AI platform").version(CLI_VERSION).option("--profile <name>", "Use a named profile").option("--json", "Machine-readable JSON output").option("--quiet", "Suppress non-essential output").option("--verbose", "Verbose logging").option("--no-color", "Disable color output").option("--api-url <url>", "Override API base URL").option("--org <tenant>", "Organization to act in (X-Tenant-Id); needed when your token authorizes several");
|
|
24400
28085
|
registerOrgSelection(program2);
|
|
24401
28086
|
program2.command("status").description("Check connection and auth status").action(async () => {
|
|
24402
28087
|
const ctx = createContext({
|