@fdcn/sourcefed 0.2.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/LICENSE +21 -0
- package/README.md +51 -0
- package/dist/chunk-B7T6IZYS.js +5155 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/chunk-NGJ6F5ST.js +766 -0
- package/dist/cli.js +30491 -0
- package/dist/core-storage.js +13 -0
- package/dist/core.js +643 -0
- package/dist/daemon.js +5190 -0
- package/dist/data/core/SKILL.md +71 -0
- package/dist/data/core/references/commands.md +75 -0
- package/dist/data/sourcefed/SKILL.md +31 -0
- package/dist/guidance.md +71 -0
- package/dist/mcp.js +4800 -0
- package/dist/opencode.js +12646 -0
- package/dist/pi.js +249 -0
- package/dist/tui-compiled.mjs +4096 -0
- package/dist.dts/adapters/opencode/bridge.d.ts +20 -0
- package/dist.dts/adapters/opencode/index.d.ts +3 -0
- package/dist.dts/adapters/opencode/tool-result.d.ts +1 -0
- package/dist.dts/adapters/opencode/tools/monitor_create.d.ts +3 -0
- package/dist.dts/adapters/opencode/tools/monitor_list.d.ts +3 -0
- package/dist.dts/adapters/opencode/tools/monitor_start.d.ts +3 -0
- package/dist.dts/adapters/opencode/tools/monitor_status.d.ts +3 -0
- package/dist.dts/adapters/opencode/tools/monitor_stop.d.ts +3 -0
- package/dist.dts/adapters/opencode/tui/plugin.d.ts +3 -0
- package/dist.dts/adapters/opencode/tui/sidebar.d.ts +13 -0
- package/dist.dts/adapters/opencode/tui.d.ts +7 -0
- package/dist.dts/adapters/pi/src/dialog.d.ts +12 -0
- package/dist.dts/adapters/pi/src/index.d.ts +2 -0
- package/dist.dts/index.d.ts +1 -0
- package/dist.dts/packages/cli/src/index.d.ts +2 -0
- package/dist.dts/packages/cli/src/skills/command.d.ts +1 -0
- package/dist.dts/packages/cli/src/skills/discovery.d.ts +7 -0
- package/dist.dts/packages/cli/src/skills/frontmatter.d.ts +5 -0
- package/dist.dts/packages/cli/src/skills/index.d.ts +1 -0
- package/dist.dts/packages/core/src/events.d.ts +24 -0
- package/dist.dts/packages/core/src/events.test.d.ts +1 -0
- package/dist.dts/packages/core/src/index.d.ts +9 -0
- package/dist.dts/packages/core/src/monitors/index.d.ts +6 -0
- package/dist.dts/packages/core/src/monitors/monitor.d.ts +26 -0
- package/dist.dts/packages/core/src/monitors/poll/index.d.ts +1 -0
- package/dist.dts/packages/core/src/monitors/poll/monitor.d.ts +12 -0
- package/dist.dts/packages/core/src/monitors/poll/types/index.d.ts +2 -0
- package/dist.dts/packages/core/src/monitors/poll/types/poll-monitor-options.d.ts +6 -0
- package/dist.dts/packages/core/src/monitors/poll/types/poll-runner.d.ts +3 -0
- package/dist.dts/packages/core/src/monitors/poll/types/routed-event-cursor.d.ts +2 -0
- package/dist.dts/packages/core/src/monitors/poll/utils/event-delivery-id.d.ts +2 -0
- package/dist.dts/packages/core/src/monitors/poll/utils/tick.d.ts +2 -0
- package/dist.dts/packages/core/src/monitors/schema.d.ts +37 -0
- package/dist.dts/packages/core/src/monitors/service.d.ts +35 -0
- package/dist.dts/packages/core/src/monitors/service.test.d.ts +1 -0
- package/dist.dts/packages/core/src/monitors/transport.test.d.ts +1 -0
- package/dist.dts/packages/core/src/monitors/types/index.d.ts +2 -0
- package/dist.dts/packages/core/src/monitors/types/monitor-record.d.ts +3 -0
- package/dist.dts/packages/core/src/monitors/types/monitor-registry.d.ts +3 -0
- package/dist.dts/packages/core/src/monitors/utils/monitor-identity.d.ts +5 -0
- package/dist.dts/packages/core/src/monitors/utils/monitor-identity.test.d.ts +1 -0
- package/dist.dts/packages/core/src/monitors/webhook/index.d.ts +1 -0
- package/dist.dts/packages/core/src/monitors/webhook/monitor.d.ts +24 -0
- package/dist.dts/packages/core/src/monitors/webhook/types/index.d.ts +3 -0
- package/dist.dts/packages/core/src/monitors/webhook/types/pending-webhook-event.d.ts +19 -0
- package/dist.dts/packages/core/src/monitors/webhook/types/webhook-monitor-options.d.ts +13 -0
- package/dist.dts/packages/core/src/monitors/webhook/utils/constants.d.ts +2 -0
- package/dist.dts/packages/core/src/monitors/webhook/utils/deliver-webhook.d.ts +3 -0
- package/dist.dts/packages/core/src/monitors/webhook/utils/handle-webhook.d.ts +2 -0
- package/dist.dts/packages/core/src/monitors/webhook/utils/handle-webhook.test.d.ts +1 -0
- package/dist.dts/packages/core/src/monitors/webhook/utils/heartbeat-webhooks.d.ts +3 -0
- package/dist.dts/packages/core/src/runtime.d.ts +23 -0
- package/dist.dts/packages/core/src/runtime.test.d.ts +1 -0
- package/dist.dts/packages/core/src/sources/index.d.ts +1 -0
- package/dist.dts/packages/core/src/sources/schema.d.ts +4 -0
- package/dist.dts/packages/core/src/sources/types/index.d.ts +3 -0
- package/dist.dts/packages/core/src/sources/types/monitor-source.d.ts +3 -0
- package/dist.dts/packages/core/src/sources/types/source-input.d.ts +4 -0
- package/dist.dts/packages/core/src/sources/types/source-registry.d.ts +2 -0
- package/dist.dts/packages/core/src/storage/in-memory-monitor-store.d.ts +8 -0
- package/dist.dts/packages/core/src/storage/index.d.ts +2 -0
- package/dist.dts/packages/core/src/storage/json.d.ts +30 -0
- package/dist.dts/packages/core/src/storage/json.test.d.ts +1 -0
- package/dist.dts/packages/core/src/types/delivery.d.ts +1 -0
- package/dist.dts/packages/core/src/types/event-sink.d.ts +12 -0
- package/dist.dts/packages/core/src/types/index.d.ts +11 -0
- package/dist.dts/packages/core/src/types/monitor-context.d.ts +10 -0
- package/dist.dts/packages/core/src/types/monitor-create-input.d.ts +8 -0
- package/dist.dts/packages/core/src/types/monitor-event-queue.d.ts +18 -0
- package/dist.dts/packages/core/src/types/monitor-event.d.ts +10 -0
- package/dist.dts/packages/core/src/types/monitor-options.d.ts +7 -0
- package/dist.dts/packages/core/src/types/monitor-store.d.ts +6 -0
- package/dist.dts/packages/core/src/types/monitor-target.d.ts +4 -0
- package/dist.dts/packages/core/src/types/source-event.d.ts +9 -0
- package/dist.dts/packages/core/src/types/source-poll-result.d.ts +6 -0
- package/dist.dts/packages/core/src/utils/event-to-text.d.ts +2 -0
- package/dist.dts/packages/core/src/utils/to-monitor-event.d.ts +3 -0
- package/dist.dts/packages/daemon/src/client.d.ts +2 -0
- package/dist.dts/packages/daemon/src/client.test.d.ts +1 -0
- package/dist.dts/packages/daemon/src/daemon.d.ts +36 -0
- package/dist.dts/packages/daemon/src/daemon.test.d.ts +1 -0
- package/dist.dts/packages/daemon/src/dispatch.d.ts +2 -0
- package/dist.dts/packages/daemon/src/http.d.ts +5 -0
- package/dist.dts/packages/daemon/src/index.d.ts +8 -0
- package/dist.dts/packages/daemon/src/registry.d.ts +14 -0
- package/dist.dts/packages/daemon/src/types/client.d.ts +21 -0
- package/dist.dts/packages/daemon/src/types/daemon.d.ts +58 -0
- package/dist.dts/packages/daemon/src/types/index.d.ts +3 -0
- package/dist.dts/packages/daemon/src/types/protocol.d.ts +21 -0
- package/dist.dts/packages/daemon/src/utils/env.d.ts +1 -0
- package/dist.dts/packages/daemon/src/utils/http-server.d.ts +10 -0
- package/dist.dts/packages/daemon/src/utils/index.d.ts +6 -0
- package/dist.dts/packages/daemon/src/utils/request-router.d.ts +11 -0
- package/dist.dts/packages/daemon/src/utils/sink.d.ts +13 -0
- package/dist.dts/packages/daemon/src/utils/spawn.d.ts +19 -0
- package/dist.dts/packages/daemon/src/utils/target.d.ts +4 -0
- package/dist.dts/packages/mcp/src/index.d.ts +2 -0
- package/dist.dts/packages/mcp/src/server.d.ts +14 -0
- package/dist.dts/packages/mcp/src/server.test.d.ts +1 -0
- package/dist.dts/packages/mcp/src/uris.d.ts +3 -0
- package/dist.dts/packages/sourcefed/src/server.d.ts +7 -0
- package/dist.dts/providers/github/src/api/client.d.ts +3 -0
- package/dist.dts/providers/github/src/api/comments.d.ts +1 -0
- package/dist.dts/providers/github/src/api/github-api.test.d.ts +1 -0
- package/dist.dts/providers/github/src/api/index.d.ts +4 -0
- package/dist.dts/providers/github/src/api/logs.d.ts +5 -0
- package/dist.dts/providers/github/src/api/pr.d.ts +8 -0
- package/dist.dts/providers/github/src/github.test.d.ts +1 -0
- package/dist.dts/providers/github/src/index.d.ts +2 -0
- package/dist.dts/providers/github/src/monitor.d.ts +15 -0
- package/dist.dts/providers/github/src/poll/index.d.ts +2 -0
- package/dist.dts/providers/github/src/poll/monitor.d.ts +3 -0
- package/dist.dts/providers/github/src/poll/utils/append-comments.d.ts +2 -0
- package/dist.dts/providers/github/src/poll/utils/append-github-ci-event.d.ts +2 -0
- package/dist.dts/providers/github/src/poll/utils/append-github-conflict-event.d.ts +2 -0
- package/dist.dts/providers/github/src/poll/utils/append-github-reviews.d.ts +2 -0
- package/dist.dts/providers/github/src/poll/utils/append-github-state-event.d.ts +2 -0
- package/dist.dts/providers/github/src/poll/utils/ci-failure-detail.d.ts +1 -0
- package/dist.dts/providers/github/src/poll/utils/clean-ci-log.d.ts +1 -0
- package/dist.dts/providers/github/src/poll/utils/confirm-still-failing.d.ts +1 -0
- package/dist.dts/providers/github/src/poll/utils/empty-cursor.d.ts +2 -0
- package/dist.dts/providers/github/src/poll/utils/failure-run-ids.d.ts +1 -0
- package/dist.dts/providers/github/src/poll/utils/failure-run-log.d.ts +1 -0
- package/dist.dts/providers/github/src/poll/utils/format-failed-check.d.ts +1 -0
- package/dist.dts/providers/github/src/poll/utils/index.d.ts +1 -0
- package/dist.dts/providers/github/src/poll/utils/poll-github.d.ts +6 -0
- package/dist.dts/providers/github/src/poll/utils/poll-helpers.test.d.ts +1 -0
- package/dist.dts/providers/github/src/schema.d.ts +17 -0
- package/dist.dts/providers/github/src/types/cursor.d.ts +11 -0
- package/dist.dts/providers/github/src/types/event.d.ts +11 -0
- package/dist.dts/providers/github/src/types/index.d.ts +3 -0
- package/dist.dts/providers/github/src/types/source-record.d.ts +5 -0
- package/dist.dts/providers/github/src/webhook/index.d.ts +3 -0
- package/dist.dts/providers/github/src/webhook/monitor.d.ts +3 -0
- package/dist.dts/providers/github/src/webhook/types/context.d.ts +7 -0
- package/dist.dts/providers/github/src/webhook/types/event-handler.d.ts +3 -0
- package/dist.dts/providers/github/src/webhook/types/event-shape.d.ts +7 -0
- package/dist.dts/providers/github/src/webhook/types/index.d.ts +1 -0
- package/dist.dts/providers/github/src/webhook/utils/fallback-github-event.d.ts +3 -0
- package/dist.dts/providers/github/src/webhook/utils/github-event-handlers.d.ts +2 -0
- package/dist.dts/providers/github/src/webhook/utils/index.d.ts +2 -0
- package/dist.dts/providers/github/src/webhook/utils/parse-check-run.d.ts +3 -0
- package/dist.dts/providers/github/src/webhook/utils/parse-check-suite.d.ts +3 -0
- package/dist.dts/providers/github/src/webhook/utils/parse-github-comment.d.ts +3 -0
- package/dist.dts/providers/github/src/webhook/utils/parse-github-webhook.d.ts +2 -0
- package/dist.dts/providers/github/src/webhook/utils/parse-pull-request-review.d.ts +3 -0
- package/dist.dts/providers/github/src/webhook/utils/parse-pull-request.d.ts +3 -0
- package/dist.dts/providers/github/src/webhook/utils/pull-request-number.d.ts +1 -0
- package/dist.dts/providers/github/src/webhook/utils/update-github-cursor.d.ts +3 -0
- package/dist.dts/providers/github/src/webhook/utils/verify-github-webhook.d.ts +1 -0
- package/dist.dts/providers/github/src/webhook/utils/verify-hmac.d.ts +1 -0
- package/dist.dts/providers/jira/src/index.d.ts +2 -0
- package/dist.dts/providers/jira/src/monitor.d.ts +14 -0
- package/dist.dts/providers/jira/src/poll/index.d.ts +2 -0
- package/dist.dts/providers/jira/src/poll/monitor.d.ts +3 -0
- package/dist.dts/providers/jira/src/poll/utils/adf-text.d.ts +1 -0
- package/dist.dts/providers/jira/src/poll/utils/append-jira-changelog.d.ts +2 -0
- package/dist.dts/providers/jira/src/poll/utils/append-jira-comments.d.ts +2 -0
- package/dist.dts/providers/jira/src/poll/utils/append-jira-description.d.ts +2 -0
- package/dist.dts/providers/jira/src/poll/utils/empty-cursor.d.ts +2 -0
- package/dist.dts/providers/jira/src/poll/utils/format-jira-changelog-item.d.ts +1 -0
- package/dist.dts/providers/jira/src/poll/utils/index.d.ts +1 -0
- package/dist.dts/providers/jira/src/poll/utils/is-terminal-status.d.ts +1 -0
- package/dist.dts/providers/jira/src/poll/utils/jira-auth.d.ts +1 -0
- package/dist.dts/providers/jira/src/poll/utils/jira-change-value.d.ts +1 -0
- package/dist.dts/providers/jira/src/poll/utils/jira-changelog-event.d.ts +2 -0
- package/dist.dts/providers/jira/src/poll/utils/jira-fetch.d.ts +1 -0
- package/dist.dts/providers/jira/src/poll/utils/meaningful-changelog-items.d.ts +1 -0
- package/dist.dts/providers/jira/src/poll/utils/poll-helpers.test.d.ts +1 -0
- package/dist.dts/providers/jira/src/poll/utils/poll-jira.d.ts +6 -0
- package/dist.dts/providers/jira/src/schema.d.ts +10 -0
- package/dist.dts/providers/jira/src/types/cursor.d.ts +5 -0
- package/dist.dts/providers/jira/src/types/event.d.ts +11 -0
- package/dist.dts/providers/jira/src/types/index.d.ts +3 -0
- package/dist.dts/providers/jira/src/types/source-record.d.ts +4 -0
- package/dist.dts/providers/slack/src/index.d.ts +2 -0
- package/dist.dts/providers/slack/src/monitor.d.ts +15 -0
- package/dist.dts/providers/slack/src/poll/index.d.ts +2 -0
- package/dist.dts/providers/slack/src/poll/monitor.d.ts +3 -0
- package/dist.dts/providers/slack/src/poll/utils/index.d.ts +2 -0
- package/dist.dts/providers/slack/src/poll/utils/parse-slack-read-result.d.ts +5 -0
- package/dist.dts/providers/slack/src/poll/utils/poll-slack.d.ts +6 -0
- package/dist.dts/providers/slack/src/poll/utils/slack-api.d.ts +4 -0
- package/dist.dts/providers/slack/src/schema.d.ts +11 -0
- package/dist.dts/providers/slack/src/slack.test.d.ts +1 -0
- package/dist.dts/providers/slack/src/types/cursor.d.ts +5 -0
- package/dist.dts/providers/slack/src/types/event.d.ts +8 -0
- package/dist.dts/providers/slack/src/types/index.d.ts +4 -0
- package/dist.dts/providers/slack/src/types/message.d.ts +6 -0
- package/dist.dts/providers/slack/src/types/read-result.d.ts +10 -0
- package/dist.dts/providers/slack/src/types/source-record.d.ts +5 -0
- package/dist.dts/providers/slack/src/utils/index.d.ts +2 -0
- package/dist.dts/providers/slack/src/utils/message-at.d.ts +1 -0
- package/dist.dts/providers/slack/src/utils/message-timestamp.d.ts +1 -0
- package/dist.dts/providers/slack/src/webhook/index.d.ts +2 -0
- package/dist.dts/providers/slack/src/webhook/monitor.d.ts +3 -0
- package/dist.dts/providers/slack/src/webhook/utils/index.d.ts +3 -0
- package/dist.dts/providers/slack/src/webhook/utils/parse-slack-webhook.d.ts +2 -0
- package/dist.dts/providers/slack/src/webhook/utils/slack-signature.d.ts +1 -0
- package/dist.dts/providers/slack/src/webhook/utils/update-slack-cursor.d.ts +3 -0
- package/dist.dts/providers/slack/src/webhook/utils/valid-slack-signature.d.ts +1 -0
- package/dist.dts/tui.d.ts +1 -0
- package/package.json +68 -0
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,4800 @@
|
|
|
1
|
+
import {
|
|
2
|
+
decodeTarget,
|
|
3
|
+
encodeTarget
|
|
4
|
+
} from "./chunk-B7T6IZYS.js";
|
|
5
|
+
import {
|
|
6
|
+
__export
|
|
7
|
+
} from "./chunk-MLKGABMK.js";
|
|
8
|
+
|
|
9
|
+
// packages/mcp/src/server.ts
|
|
10
|
+
import { createMcpHandler, McpServer, ResourceTemplate } from "@modelcontextprotocol/server";
|
|
11
|
+
|
|
12
|
+
// node_modules/zod/v4/core/core.js
|
|
13
|
+
var _a;
|
|
14
|
+
// @__NO_SIDE_EFFECTS__
|
|
15
|
+
function $constructor(name, initializer3, params) {
|
|
16
|
+
function init(inst, def) {
|
|
17
|
+
if (!inst._zod) {
|
|
18
|
+
Object.defineProperty(inst, "_zod", {
|
|
19
|
+
value: {
|
|
20
|
+
def,
|
|
21
|
+
constr: _,
|
|
22
|
+
traits: /* @__PURE__ */ new Set()
|
|
23
|
+
},
|
|
24
|
+
enumerable: false
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (inst._zod.traits.has(name)) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
inst._zod.traits.add(name);
|
|
31
|
+
initializer3(inst, def);
|
|
32
|
+
const proto = _.prototype;
|
|
33
|
+
const keys = Object.keys(proto);
|
|
34
|
+
for (let i = 0; i < keys.length; i++) {
|
|
35
|
+
const k = keys[i];
|
|
36
|
+
if (!(k in inst)) {
|
|
37
|
+
inst[k] = proto[k].bind(inst);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const Parent = params?.Parent ?? Object;
|
|
42
|
+
class Definition extends Parent {
|
|
43
|
+
}
|
|
44
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
45
|
+
function _(def) {
|
|
46
|
+
var _a3;
|
|
47
|
+
const inst = params?.Parent ? new Definition() : this;
|
|
48
|
+
init(inst, def);
|
|
49
|
+
(_a3 = inst._zod).deferred ?? (_a3.deferred = []);
|
|
50
|
+
for (const fn of inst._zod.deferred) {
|
|
51
|
+
fn();
|
|
52
|
+
}
|
|
53
|
+
return inst;
|
|
54
|
+
}
|
|
55
|
+
Object.defineProperty(_, "init", { value: init });
|
|
56
|
+
Object.defineProperty(_, Symbol.hasInstance, {
|
|
57
|
+
value: (inst) => {
|
|
58
|
+
if (params?.Parent && inst instanceof params.Parent)
|
|
59
|
+
return true;
|
|
60
|
+
return inst?._zod?.traits?.has(name);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(_, "name", { value: name });
|
|
64
|
+
return _;
|
|
65
|
+
}
|
|
66
|
+
var $brand = Symbol("zod_brand");
|
|
67
|
+
var $ZodAsyncError = class extends Error {
|
|
68
|
+
constructor() {
|
|
69
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var $ZodEncodeError = class extends Error {
|
|
73
|
+
constructor(name) {
|
|
74
|
+
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
75
|
+
this.name = "ZodEncodeError";
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
|
|
79
|
+
var globalConfig = globalThis.__zod_globalConfig;
|
|
80
|
+
function config(newConfig) {
|
|
81
|
+
if (newConfig)
|
|
82
|
+
Object.assign(globalConfig, newConfig);
|
|
83
|
+
return globalConfig;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// node_modules/zod/v4/core/util.js
|
|
87
|
+
var util_exports = {};
|
|
88
|
+
__export(util_exports, {
|
|
89
|
+
BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
|
|
90
|
+
Class: () => Class,
|
|
91
|
+
NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
|
|
92
|
+
aborted: () => aborted,
|
|
93
|
+
allowsEval: () => allowsEval,
|
|
94
|
+
assert: () => assert,
|
|
95
|
+
assertEqual: () => assertEqual,
|
|
96
|
+
assertIs: () => assertIs,
|
|
97
|
+
assertNever: () => assertNever,
|
|
98
|
+
assertNotEqual: () => assertNotEqual,
|
|
99
|
+
assignProp: () => assignProp,
|
|
100
|
+
base64ToUint8Array: () => base64ToUint8Array,
|
|
101
|
+
base64urlToUint8Array: () => base64urlToUint8Array,
|
|
102
|
+
cached: () => cached,
|
|
103
|
+
captureStackTrace: () => captureStackTrace,
|
|
104
|
+
cleanEnum: () => cleanEnum,
|
|
105
|
+
cleanRegex: () => cleanRegex,
|
|
106
|
+
clone: () => clone,
|
|
107
|
+
cloneDef: () => cloneDef,
|
|
108
|
+
createTransparentProxy: () => createTransparentProxy,
|
|
109
|
+
defineLazy: () => defineLazy,
|
|
110
|
+
esc: () => esc,
|
|
111
|
+
escapeRegex: () => escapeRegex,
|
|
112
|
+
explicitlyAborted: () => explicitlyAborted,
|
|
113
|
+
extend: () => extend,
|
|
114
|
+
finalizeIssue: () => finalizeIssue,
|
|
115
|
+
floatSafeRemainder: () => floatSafeRemainder,
|
|
116
|
+
getElementAtPath: () => getElementAtPath,
|
|
117
|
+
getEnumValues: () => getEnumValues,
|
|
118
|
+
getLengthableOrigin: () => getLengthableOrigin,
|
|
119
|
+
getParsedType: () => getParsedType,
|
|
120
|
+
getSizableOrigin: () => getSizableOrigin,
|
|
121
|
+
hexToUint8Array: () => hexToUint8Array,
|
|
122
|
+
isObject: () => isObject,
|
|
123
|
+
isPlainObject: () => isPlainObject,
|
|
124
|
+
issue: () => issue,
|
|
125
|
+
joinValues: () => joinValues,
|
|
126
|
+
jsonStringifyReplacer: () => jsonStringifyReplacer,
|
|
127
|
+
merge: () => merge,
|
|
128
|
+
mergeDefs: () => mergeDefs,
|
|
129
|
+
normalizeParams: () => normalizeParams,
|
|
130
|
+
nullish: () => nullish,
|
|
131
|
+
numKeys: () => numKeys,
|
|
132
|
+
objectClone: () => objectClone,
|
|
133
|
+
omit: () => omit,
|
|
134
|
+
optionalKeys: () => optionalKeys,
|
|
135
|
+
parsedType: () => parsedType,
|
|
136
|
+
partial: () => partial,
|
|
137
|
+
pick: () => pick,
|
|
138
|
+
prefixIssues: () => prefixIssues,
|
|
139
|
+
primitiveTypes: () => primitiveTypes,
|
|
140
|
+
promiseAllObject: () => promiseAllObject,
|
|
141
|
+
propertyKeyTypes: () => propertyKeyTypes,
|
|
142
|
+
randomString: () => randomString,
|
|
143
|
+
required: () => required,
|
|
144
|
+
safeExtend: () => safeExtend,
|
|
145
|
+
shallowClone: () => shallowClone,
|
|
146
|
+
slugify: () => slugify,
|
|
147
|
+
stringifyPrimitive: () => stringifyPrimitive,
|
|
148
|
+
uint8ArrayToBase64: () => uint8ArrayToBase64,
|
|
149
|
+
uint8ArrayToBase64url: () => uint8ArrayToBase64url,
|
|
150
|
+
uint8ArrayToHex: () => uint8ArrayToHex,
|
|
151
|
+
unwrapMessage: () => unwrapMessage
|
|
152
|
+
});
|
|
153
|
+
function assertEqual(val) {
|
|
154
|
+
return val;
|
|
155
|
+
}
|
|
156
|
+
function assertNotEqual(val) {
|
|
157
|
+
return val;
|
|
158
|
+
}
|
|
159
|
+
function assertIs(_arg) {
|
|
160
|
+
}
|
|
161
|
+
function assertNever(_x) {
|
|
162
|
+
throw new Error("Unexpected value in exhaustive check");
|
|
163
|
+
}
|
|
164
|
+
function assert(_) {
|
|
165
|
+
}
|
|
166
|
+
function getEnumValues(entries) {
|
|
167
|
+
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
168
|
+
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
169
|
+
return values;
|
|
170
|
+
}
|
|
171
|
+
function joinValues(array2, separator = "|") {
|
|
172
|
+
return array2.map((val) => stringifyPrimitive(val)).join(separator);
|
|
173
|
+
}
|
|
174
|
+
function jsonStringifyReplacer(_, value) {
|
|
175
|
+
if (typeof value === "bigint")
|
|
176
|
+
return value.toString();
|
|
177
|
+
return value;
|
|
178
|
+
}
|
|
179
|
+
function cached(getter) {
|
|
180
|
+
const set = false;
|
|
181
|
+
return {
|
|
182
|
+
get value() {
|
|
183
|
+
if (!set) {
|
|
184
|
+
const value = getter();
|
|
185
|
+
Object.defineProperty(this, "value", { value });
|
|
186
|
+
return value;
|
|
187
|
+
}
|
|
188
|
+
throw new Error("cached value already set");
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function nullish(input) {
|
|
193
|
+
return input === null || input === void 0;
|
|
194
|
+
}
|
|
195
|
+
function cleanRegex(source) {
|
|
196
|
+
const start = source.startsWith("^") ? 1 : 0;
|
|
197
|
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
198
|
+
return source.slice(start, end);
|
|
199
|
+
}
|
|
200
|
+
function floatSafeRemainder(val, step) {
|
|
201
|
+
const ratio = val / step;
|
|
202
|
+
const roundedRatio = Math.round(ratio);
|
|
203
|
+
const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
204
|
+
if (Math.abs(ratio - roundedRatio) < tolerance)
|
|
205
|
+
return 0;
|
|
206
|
+
return ratio - roundedRatio;
|
|
207
|
+
}
|
|
208
|
+
var EVALUATING = /* @__PURE__ */ Symbol("evaluating");
|
|
209
|
+
function defineLazy(object2, key, getter) {
|
|
210
|
+
let value = void 0;
|
|
211
|
+
Object.defineProperty(object2, key, {
|
|
212
|
+
get() {
|
|
213
|
+
if (value === EVALUATING) {
|
|
214
|
+
return void 0;
|
|
215
|
+
}
|
|
216
|
+
if (value === void 0) {
|
|
217
|
+
value = EVALUATING;
|
|
218
|
+
value = getter();
|
|
219
|
+
}
|
|
220
|
+
return value;
|
|
221
|
+
},
|
|
222
|
+
set(v) {
|
|
223
|
+
Object.defineProperty(object2, key, {
|
|
224
|
+
value: v
|
|
225
|
+
// configurable: true,
|
|
226
|
+
});
|
|
227
|
+
},
|
|
228
|
+
configurable: true
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
function objectClone(obj) {
|
|
232
|
+
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
|
|
233
|
+
}
|
|
234
|
+
function assignProp(target, prop, value) {
|
|
235
|
+
Object.defineProperty(target, prop, {
|
|
236
|
+
value,
|
|
237
|
+
writable: true,
|
|
238
|
+
enumerable: true,
|
|
239
|
+
configurable: true
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
function mergeDefs(...defs) {
|
|
243
|
+
const mergedDescriptors = {};
|
|
244
|
+
for (const def of defs) {
|
|
245
|
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
246
|
+
Object.assign(mergedDescriptors, descriptors);
|
|
247
|
+
}
|
|
248
|
+
return Object.defineProperties({}, mergedDescriptors);
|
|
249
|
+
}
|
|
250
|
+
function cloneDef(schema) {
|
|
251
|
+
return mergeDefs(schema._zod.def);
|
|
252
|
+
}
|
|
253
|
+
function getElementAtPath(obj, path) {
|
|
254
|
+
if (!path)
|
|
255
|
+
return obj;
|
|
256
|
+
return path.reduce((acc, key) => acc?.[key], obj);
|
|
257
|
+
}
|
|
258
|
+
function promiseAllObject(promisesObj) {
|
|
259
|
+
const keys = Object.keys(promisesObj);
|
|
260
|
+
const promises = keys.map((key) => promisesObj[key]);
|
|
261
|
+
return Promise.all(promises).then((results) => {
|
|
262
|
+
const resolvedObj = {};
|
|
263
|
+
for (let i = 0; i < keys.length; i++) {
|
|
264
|
+
resolvedObj[keys[i]] = results[i];
|
|
265
|
+
}
|
|
266
|
+
return resolvedObj;
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
function randomString(length = 10) {
|
|
270
|
+
const chars = "abcdefghijklmnopqrstuvwxyz";
|
|
271
|
+
let str = "";
|
|
272
|
+
for (let i = 0; i < length; i++) {
|
|
273
|
+
str += chars[Math.floor(Math.random() * chars.length)];
|
|
274
|
+
}
|
|
275
|
+
return str;
|
|
276
|
+
}
|
|
277
|
+
function esc(str) {
|
|
278
|
+
return JSON.stringify(str);
|
|
279
|
+
}
|
|
280
|
+
function slugify(input) {
|
|
281
|
+
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
282
|
+
}
|
|
283
|
+
var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
|
|
284
|
+
};
|
|
285
|
+
function isObject(data) {
|
|
286
|
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
287
|
+
}
|
|
288
|
+
var allowsEval = /* @__PURE__ */ cached(() => {
|
|
289
|
+
if (globalConfig.jitless) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
try {
|
|
296
|
+
const F = Function;
|
|
297
|
+
new F("");
|
|
298
|
+
return true;
|
|
299
|
+
} catch (_) {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
function isPlainObject(o) {
|
|
304
|
+
if (isObject(o) === false)
|
|
305
|
+
return false;
|
|
306
|
+
const ctor = o.constructor;
|
|
307
|
+
if (ctor === void 0)
|
|
308
|
+
return true;
|
|
309
|
+
if (typeof ctor !== "function")
|
|
310
|
+
return true;
|
|
311
|
+
const prot = ctor.prototype;
|
|
312
|
+
if (isObject(prot) === false)
|
|
313
|
+
return false;
|
|
314
|
+
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
function shallowClone(o) {
|
|
320
|
+
if (isPlainObject(o))
|
|
321
|
+
return { ...o };
|
|
322
|
+
if (Array.isArray(o))
|
|
323
|
+
return [...o];
|
|
324
|
+
if (o instanceof Map)
|
|
325
|
+
return new Map(o);
|
|
326
|
+
if (o instanceof Set)
|
|
327
|
+
return new Set(o);
|
|
328
|
+
return o;
|
|
329
|
+
}
|
|
330
|
+
function numKeys(data) {
|
|
331
|
+
let keyCount = 0;
|
|
332
|
+
for (const key in data) {
|
|
333
|
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
334
|
+
keyCount++;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return keyCount;
|
|
338
|
+
}
|
|
339
|
+
var getParsedType = (data) => {
|
|
340
|
+
const t = typeof data;
|
|
341
|
+
switch (t) {
|
|
342
|
+
case "undefined":
|
|
343
|
+
return "undefined";
|
|
344
|
+
case "string":
|
|
345
|
+
return "string";
|
|
346
|
+
case "number":
|
|
347
|
+
return Number.isNaN(data) ? "nan" : "number";
|
|
348
|
+
case "boolean":
|
|
349
|
+
return "boolean";
|
|
350
|
+
case "function":
|
|
351
|
+
return "function";
|
|
352
|
+
case "bigint":
|
|
353
|
+
return "bigint";
|
|
354
|
+
case "symbol":
|
|
355
|
+
return "symbol";
|
|
356
|
+
case "object":
|
|
357
|
+
if (Array.isArray(data)) {
|
|
358
|
+
return "array";
|
|
359
|
+
}
|
|
360
|
+
if (data === null) {
|
|
361
|
+
return "null";
|
|
362
|
+
}
|
|
363
|
+
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
|
364
|
+
return "promise";
|
|
365
|
+
}
|
|
366
|
+
if (typeof Map !== "undefined" && data instanceof Map) {
|
|
367
|
+
return "map";
|
|
368
|
+
}
|
|
369
|
+
if (typeof Set !== "undefined" && data instanceof Set) {
|
|
370
|
+
return "set";
|
|
371
|
+
}
|
|
372
|
+
if (typeof Date !== "undefined" && data instanceof Date) {
|
|
373
|
+
return "date";
|
|
374
|
+
}
|
|
375
|
+
if (typeof File !== "undefined" && data instanceof File) {
|
|
376
|
+
return "file";
|
|
377
|
+
}
|
|
378
|
+
return "object";
|
|
379
|
+
default:
|
|
380
|
+
throw new Error(`Unknown data type: ${t}`);
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
var propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
|
|
384
|
+
var primitiveTypes = /* @__PURE__ */ new Set([
|
|
385
|
+
"string",
|
|
386
|
+
"number",
|
|
387
|
+
"bigint",
|
|
388
|
+
"boolean",
|
|
389
|
+
"symbol",
|
|
390
|
+
"undefined"
|
|
391
|
+
]);
|
|
392
|
+
function escapeRegex(str) {
|
|
393
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
394
|
+
}
|
|
395
|
+
function clone(inst, def, params) {
|
|
396
|
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
397
|
+
if (!def || params?.parent)
|
|
398
|
+
cl._zod.parent = inst;
|
|
399
|
+
return cl;
|
|
400
|
+
}
|
|
401
|
+
function normalizeParams(_params) {
|
|
402
|
+
const params = _params;
|
|
403
|
+
if (!params)
|
|
404
|
+
return {};
|
|
405
|
+
if (typeof params === "string")
|
|
406
|
+
return { error: () => params };
|
|
407
|
+
if (params?.message !== void 0) {
|
|
408
|
+
if (params?.error !== void 0)
|
|
409
|
+
throw new Error("Cannot specify both `message` and `error` params");
|
|
410
|
+
params.error = params.message;
|
|
411
|
+
}
|
|
412
|
+
delete params.message;
|
|
413
|
+
if (typeof params.error === "string")
|
|
414
|
+
return { ...params, error: () => params.error };
|
|
415
|
+
return params;
|
|
416
|
+
}
|
|
417
|
+
function createTransparentProxy(getter) {
|
|
418
|
+
let target;
|
|
419
|
+
return new Proxy({}, {
|
|
420
|
+
get(_, prop, receiver) {
|
|
421
|
+
target ?? (target = getter());
|
|
422
|
+
return Reflect.get(target, prop, receiver);
|
|
423
|
+
},
|
|
424
|
+
set(_, prop, value, receiver) {
|
|
425
|
+
target ?? (target = getter());
|
|
426
|
+
return Reflect.set(target, prop, value, receiver);
|
|
427
|
+
},
|
|
428
|
+
has(_, prop) {
|
|
429
|
+
target ?? (target = getter());
|
|
430
|
+
return Reflect.has(target, prop);
|
|
431
|
+
},
|
|
432
|
+
deleteProperty(_, prop) {
|
|
433
|
+
target ?? (target = getter());
|
|
434
|
+
return Reflect.deleteProperty(target, prop);
|
|
435
|
+
},
|
|
436
|
+
ownKeys(_) {
|
|
437
|
+
target ?? (target = getter());
|
|
438
|
+
return Reflect.ownKeys(target);
|
|
439
|
+
},
|
|
440
|
+
getOwnPropertyDescriptor(_, prop) {
|
|
441
|
+
target ?? (target = getter());
|
|
442
|
+
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
443
|
+
},
|
|
444
|
+
defineProperty(_, prop, descriptor) {
|
|
445
|
+
target ?? (target = getter());
|
|
446
|
+
return Reflect.defineProperty(target, prop, descriptor);
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
function stringifyPrimitive(value) {
|
|
451
|
+
if (typeof value === "bigint")
|
|
452
|
+
return value.toString() + "n";
|
|
453
|
+
if (typeof value === "string")
|
|
454
|
+
return `"${value}"`;
|
|
455
|
+
return `${value}`;
|
|
456
|
+
}
|
|
457
|
+
function optionalKeys(shape) {
|
|
458
|
+
return Object.keys(shape).filter((k) => {
|
|
459
|
+
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
var NUMBER_FORMAT_RANGES = {
|
|
463
|
+
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
464
|
+
int32: [-2147483648, 2147483647],
|
|
465
|
+
uint32: [0, 4294967295],
|
|
466
|
+
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
467
|
+
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
468
|
+
};
|
|
469
|
+
var BIGINT_FORMAT_RANGES = {
|
|
470
|
+
int64: [/* @__PURE__ */ BigInt("-9223372036854775808"), /* @__PURE__ */ BigInt("9223372036854775807")],
|
|
471
|
+
uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")]
|
|
472
|
+
};
|
|
473
|
+
function pick(schema, mask) {
|
|
474
|
+
const currDef = schema._zod.def;
|
|
475
|
+
const checks = currDef.checks;
|
|
476
|
+
const hasChecks = checks && checks.length > 0;
|
|
477
|
+
if (hasChecks) {
|
|
478
|
+
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
479
|
+
}
|
|
480
|
+
const def = mergeDefs(schema._zod.def, {
|
|
481
|
+
get shape() {
|
|
482
|
+
const newShape = {};
|
|
483
|
+
for (const key in mask) {
|
|
484
|
+
if (!(key in currDef.shape)) {
|
|
485
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
486
|
+
}
|
|
487
|
+
if (!mask[key])
|
|
488
|
+
continue;
|
|
489
|
+
newShape[key] = currDef.shape[key];
|
|
490
|
+
}
|
|
491
|
+
assignProp(this, "shape", newShape);
|
|
492
|
+
return newShape;
|
|
493
|
+
},
|
|
494
|
+
checks: []
|
|
495
|
+
});
|
|
496
|
+
return clone(schema, def);
|
|
497
|
+
}
|
|
498
|
+
function omit(schema, mask) {
|
|
499
|
+
const currDef = schema._zod.def;
|
|
500
|
+
const checks = currDef.checks;
|
|
501
|
+
const hasChecks = checks && checks.length > 0;
|
|
502
|
+
if (hasChecks) {
|
|
503
|
+
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
504
|
+
}
|
|
505
|
+
const def = mergeDefs(schema._zod.def, {
|
|
506
|
+
get shape() {
|
|
507
|
+
const newShape = { ...schema._zod.def.shape };
|
|
508
|
+
for (const key in mask) {
|
|
509
|
+
if (!(key in currDef.shape)) {
|
|
510
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
511
|
+
}
|
|
512
|
+
if (!mask[key])
|
|
513
|
+
continue;
|
|
514
|
+
delete newShape[key];
|
|
515
|
+
}
|
|
516
|
+
assignProp(this, "shape", newShape);
|
|
517
|
+
return newShape;
|
|
518
|
+
},
|
|
519
|
+
checks: []
|
|
520
|
+
});
|
|
521
|
+
return clone(schema, def);
|
|
522
|
+
}
|
|
523
|
+
function extend(schema, shape) {
|
|
524
|
+
if (!isPlainObject(shape)) {
|
|
525
|
+
throw new Error("Invalid input to extend: expected a plain object");
|
|
526
|
+
}
|
|
527
|
+
const checks = schema._zod.def.checks;
|
|
528
|
+
const hasChecks = checks && checks.length > 0;
|
|
529
|
+
if (hasChecks) {
|
|
530
|
+
const existingShape = schema._zod.def.shape;
|
|
531
|
+
for (const key in shape) {
|
|
532
|
+
if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) {
|
|
533
|
+
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
const def = mergeDefs(schema._zod.def, {
|
|
538
|
+
get shape() {
|
|
539
|
+
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
540
|
+
assignProp(this, "shape", _shape);
|
|
541
|
+
return _shape;
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
return clone(schema, def);
|
|
545
|
+
}
|
|
546
|
+
function safeExtend(schema, shape) {
|
|
547
|
+
if (!isPlainObject(shape)) {
|
|
548
|
+
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
549
|
+
}
|
|
550
|
+
const def = mergeDefs(schema._zod.def, {
|
|
551
|
+
get shape() {
|
|
552
|
+
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
553
|
+
assignProp(this, "shape", _shape);
|
|
554
|
+
return _shape;
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
return clone(schema, def);
|
|
558
|
+
}
|
|
559
|
+
function merge(a, b) {
|
|
560
|
+
if (a._zod.def.checks?.length) {
|
|
561
|
+
throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
562
|
+
}
|
|
563
|
+
const def = mergeDefs(a._zod.def, {
|
|
564
|
+
get shape() {
|
|
565
|
+
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
|
566
|
+
assignProp(this, "shape", _shape);
|
|
567
|
+
return _shape;
|
|
568
|
+
},
|
|
569
|
+
get catchall() {
|
|
570
|
+
return b._zod.def.catchall;
|
|
571
|
+
},
|
|
572
|
+
checks: b._zod.def.checks ?? []
|
|
573
|
+
});
|
|
574
|
+
return clone(a, def);
|
|
575
|
+
}
|
|
576
|
+
function partial(Class2, schema, mask) {
|
|
577
|
+
const currDef = schema._zod.def;
|
|
578
|
+
const checks = currDef.checks;
|
|
579
|
+
const hasChecks = checks && checks.length > 0;
|
|
580
|
+
if (hasChecks) {
|
|
581
|
+
throw new Error(".partial() cannot be used on object schemas containing refinements");
|
|
582
|
+
}
|
|
583
|
+
const def = mergeDefs(schema._zod.def, {
|
|
584
|
+
get shape() {
|
|
585
|
+
const oldShape = schema._zod.def.shape;
|
|
586
|
+
const shape = { ...oldShape };
|
|
587
|
+
if (mask) {
|
|
588
|
+
for (const key in mask) {
|
|
589
|
+
if (!(key in oldShape)) {
|
|
590
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
591
|
+
}
|
|
592
|
+
if (!mask[key])
|
|
593
|
+
continue;
|
|
594
|
+
shape[key] = Class2 ? new Class2({
|
|
595
|
+
type: "optional",
|
|
596
|
+
innerType: oldShape[key]
|
|
597
|
+
}) : oldShape[key];
|
|
598
|
+
}
|
|
599
|
+
} else {
|
|
600
|
+
for (const key in oldShape) {
|
|
601
|
+
shape[key] = Class2 ? new Class2({
|
|
602
|
+
type: "optional",
|
|
603
|
+
innerType: oldShape[key]
|
|
604
|
+
}) : oldShape[key];
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
assignProp(this, "shape", shape);
|
|
608
|
+
return shape;
|
|
609
|
+
},
|
|
610
|
+
checks: []
|
|
611
|
+
});
|
|
612
|
+
return clone(schema, def);
|
|
613
|
+
}
|
|
614
|
+
function required(Class2, schema, mask) {
|
|
615
|
+
const def = mergeDefs(schema._zod.def, {
|
|
616
|
+
get shape() {
|
|
617
|
+
const oldShape = schema._zod.def.shape;
|
|
618
|
+
const shape = { ...oldShape };
|
|
619
|
+
if (mask) {
|
|
620
|
+
for (const key in mask) {
|
|
621
|
+
if (!(key in shape)) {
|
|
622
|
+
throw new Error(`Unrecognized key: "${key}"`);
|
|
623
|
+
}
|
|
624
|
+
if (!mask[key])
|
|
625
|
+
continue;
|
|
626
|
+
shape[key] = new Class2({
|
|
627
|
+
type: "nonoptional",
|
|
628
|
+
innerType: oldShape[key]
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
} else {
|
|
632
|
+
for (const key in oldShape) {
|
|
633
|
+
shape[key] = new Class2({
|
|
634
|
+
type: "nonoptional",
|
|
635
|
+
innerType: oldShape[key]
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
assignProp(this, "shape", shape);
|
|
640
|
+
return shape;
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
return clone(schema, def);
|
|
644
|
+
}
|
|
645
|
+
function aborted(x, startIndex = 0) {
|
|
646
|
+
if (x.aborted === true)
|
|
647
|
+
return true;
|
|
648
|
+
for (let i = startIndex; i < x.issues.length; i++) {
|
|
649
|
+
if (x.issues[i]?.continue !== true) {
|
|
650
|
+
return true;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
return false;
|
|
654
|
+
}
|
|
655
|
+
function explicitlyAborted(x, startIndex = 0) {
|
|
656
|
+
if (x.aborted === true)
|
|
657
|
+
return true;
|
|
658
|
+
for (let i = startIndex; i < x.issues.length; i++) {
|
|
659
|
+
if (x.issues[i]?.continue === false) {
|
|
660
|
+
return true;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
return false;
|
|
664
|
+
}
|
|
665
|
+
function prefixIssues(path, issues) {
|
|
666
|
+
return issues.map((iss) => {
|
|
667
|
+
var _a3;
|
|
668
|
+
(_a3 = iss).path ?? (_a3.path = []);
|
|
669
|
+
iss.path.unshift(path);
|
|
670
|
+
return iss;
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
function unwrapMessage(message) {
|
|
674
|
+
return typeof message === "string" ? message : message?.message;
|
|
675
|
+
}
|
|
676
|
+
function finalizeIssue(iss, ctx, config2) {
|
|
677
|
+
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
|
|
678
|
+
const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
|
|
679
|
+
rest.path ?? (rest.path = []);
|
|
680
|
+
rest.message = message;
|
|
681
|
+
if (ctx?.reportInput) {
|
|
682
|
+
rest.input = _input;
|
|
683
|
+
}
|
|
684
|
+
return rest;
|
|
685
|
+
}
|
|
686
|
+
function getSizableOrigin(input) {
|
|
687
|
+
if (input instanceof Set)
|
|
688
|
+
return "set";
|
|
689
|
+
if (input instanceof Map)
|
|
690
|
+
return "map";
|
|
691
|
+
if (input instanceof File)
|
|
692
|
+
return "file";
|
|
693
|
+
return "unknown";
|
|
694
|
+
}
|
|
695
|
+
function getLengthableOrigin(input) {
|
|
696
|
+
if (Array.isArray(input))
|
|
697
|
+
return "array";
|
|
698
|
+
if (typeof input === "string")
|
|
699
|
+
return "string";
|
|
700
|
+
return "unknown";
|
|
701
|
+
}
|
|
702
|
+
function parsedType(data) {
|
|
703
|
+
const t = typeof data;
|
|
704
|
+
switch (t) {
|
|
705
|
+
case "number": {
|
|
706
|
+
return Number.isNaN(data) ? "nan" : "number";
|
|
707
|
+
}
|
|
708
|
+
case "object": {
|
|
709
|
+
if (data === null) {
|
|
710
|
+
return "null";
|
|
711
|
+
}
|
|
712
|
+
if (Array.isArray(data)) {
|
|
713
|
+
return "array";
|
|
714
|
+
}
|
|
715
|
+
const obj = data;
|
|
716
|
+
if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
|
|
717
|
+
return obj.constructor.name;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
return t;
|
|
722
|
+
}
|
|
723
|
+
function issue(...args) {
|
|
724
|
+
const [iss, input, inst] = args;
|
|
725
|
+
if (typeof iss === "string") {
|
|
726
|
+
return {
|
|
727
|
+
message: iss,
|
|
728
|
+
code: "custom",
|
|
729
|
+
input,
|
|
730
|
+
inst
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
return { ...iss };
|
|
734
|
+
}
|
|
735
|
+
function cleanEnum(obj) {
|
|
736
|
+
return Object.entries(obj).filter(([k, _]) => {
|
|
737
|
+
return Number.isNaN(Number.parseInt(k, 10));
|
|
738
|
+
}).map((el) => el[1]);
|
|
739
|
+
}
|
|
740
|
+
function base64ToUint8Array(base642) {
|
|
741
|
+
const binaryString = atob(base642);
|
|
742
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
743
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
744
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
745
|
+
}
|
|
746
|
+
return bytes;
|
|
747
|
+
}
|
|
748
|
+
function uint8ArrayToBase64(bytes) {
|
|
749
|
+
let binaryString = "";
|
|
750
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
751
|
+
binaryString += String.fromCharCode(bytes[i]);
|
|
752
|
+
}
|
|
753
|
+
return btoa(binaryString);
|
|
754
|
+
}
|
|
755
|
+
function base64urlToUint8Array(base64url2) {
|
|
756
|
+
const base642 = base64url2.replace(/-/g, "+").replace(/_/g, "/");
|
|
757
|
+
const padding = "=".repeat((4 - base642.length % 4) % 4);
|
|
758
|
+
return base64ToUint8Array(base642 + padding);
|
|
759
|
+
}
|
|
760
|
+
function uint8ArrayToBase64url(bytes) {
|
|
761
|
+
return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
762
|
+
}
|
|
763
|
+
function hexToUint8Array(hex) {
|
|
764
|
+
const cleanHex = hex.replace(/^0x/, "");
|
|
765
|
+
if (cleanHex.length % 2 !== 0) {
|
|
766
|
+
throw new Error("Invalid hex string length");
|
|
767
|
+
}
|
|
768
|
+
const bytes = new Uint8Array(cleanHex.length / 2);
|
|
769
|
+
for (let i = 0; i < cleanHex.length; i += 2) {
|
|
770
|
+
bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
|
|
771
|
+
}
|
|
772
|
+
return bytes;
|
|
773
|
+
}
|
|
774
|
+
function uint8ArrayToHex(bytes) {
|
|
775
|
+
return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
776
|
+
}
|
|
777
|
+
var Class = class {
|
|
778
|
+
constructor(..._args) {
|
|
779
|
+
}
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
// node_modules/zod/v4/core/errors.js
|
|
783
|
+
var initializer = (inst, def) => {
|
|
784
|
+
inst.name = "$ZodError";
|
|
785
|
+
Object.defineProperty(inst, "_zod", {
|
|
786
|
+
value: inst._zod,
|
|
787
|
+
enumerable: false
|
|
788
|
+
});
|
|
789
|
+
Object.defineProperty(inst, "issues", {
|
|
790
|
+
value: def,
|
|
791
|
+
enumerable: false
|
|
792
|
+
});
|
|
793
|
+
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
794
|
+
Object.defineProperty(inst, "toString", {
|
|
795
|
+
value: () => inst.message,
|
|
796
|
+
enumerable: false
|
|
797
|
+
});
|
|
798
|
+
};
|
|
799
|
+
var $ZodError = $constructor("$ZodError", initializer);
|
|
800
|
+
var $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
|
|
801
|
+
function flattenError(error, mapper = (issue2) => issue2.message) {
|
|
802
|
+
const fieldErrors = {};
|
|
803
|
+
const formErrors = [];
|
|
804
|
+
for (const sub of error.issues) {
|
|
805
|
+
if (sub.path.length > 0) {
|
|
806
|
+
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
807
|
+
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
808
|
+
} else {
|
|
809
|
+
formErrors.push(mapper(sub));
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
return { formErrors, fieldErrors };
|
|
813
|
+
}
|
|
814
|
+
function formatError(error, mapper = (issue2) => issue2.message) {
|
|
815
|
+
const fieldErrors = { _errors: [] };
|
|
816
|
+
const processError = (error2, path = []) => {
|
|
817
|
+
for (const issue2 of error2.issues) {
|
|
818
|
+
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
819
|
+
issue2.errors.map((issues) => processError({ issues }, [...path, ...issue2.path]));
|
|
820
|
+
} else if (issue2.code === "invalid_key") {
|
|
821
|
+
processError({ issues: issue2.issues }, [...path, ...issue2.path]);
|
|
822
|
+
} else if (issue2.code === "invalid_element") {
|
|
823
|
+
processError({ issues: issue2.issues }, [...path, ...issue2.path]);
|
|
824
|
+
} else {
|
|
825
|
+
const fullpath = [...path, ...issue2.path];
|
|
826
|
+
if (fullpath.length === 0) {
|
|
827
|
+
fieldErrors._errors.push(mapper(issue2));
|
|
828
|
+
} else {
|
|
829
|
+
let curr = fieldErrors;
|
|
830
|
+
let i = 0;
|
|
831
|
+
while (i < fullpath.length) {
|
|
832
|
+
const el = fullpath[i];
|
|
833
|
+
const terminal = i === fullpath.length - 1;
|
|
834
|
+
if (!terminal) {
|
|
835
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
836
|
+
} else {
|
|
837
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
838
|
+
curr[el]._errors.push(mapper(issue2));
|
|
839
|
+
}
|
|
840
|
+
curr = curr[el];
|
|
841
|
+
i++;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
processError(error);
|
|
848
|
+
return fieldErrors;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
// node_modules/zod/v4/core/parse.js
|
|
852
|
+
var _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
853
|
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
854
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
855
|
+
if (result instanceof Promise) {
|
|
856
|
+
throw new $ZodAsyncError();
|
|
857
|
+
}
|
|
858
|
+
if (result.issues.length) {
|
|
859
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
860
|
+
captureStackTrace(e, _params?.callee);
|
|
861
|
+
throw e;
|
|
862
|
+
}
|
|
863
|
+
return result.value;
|
|
864
|
+
};
|
|
865
|
+
var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
866
|
+
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
867
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
868
|
+
if (result instanceof Promise)
|
|
869
|
+
result = await result;
|
|
870
|
+
if (result.issues.length) {
|
|
871
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
872
|
+
captureStackTrace(e, params?.callee);
|
|
873
|
+
throw e;
|
|
874
|
+
}
|
|
875
|
+
return result.value;
|
|
876
|
+
};
|
|
877
|
+
var _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
878
|
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
879
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
880
|
+
if (result instanceof Promise) {
|
|
881
|
+
throw new $ZodAsyncError();
|
|
882
|
+
}
|
|
883
|
+
return result.issues.length ? {
|
|
884
|
+
success: false,
|
|
885
|
+
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
886
|
+
} : { success: true, data: result.value };
|
|
887
|
+
};
|
|
888
|
+
var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
889
|
+
var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
890
|
+
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
891
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
892
|
+
if (result instanceof Promise)
|
|
893
|
+
result = await result;
|
|
894
|
+
return result.issues.length ? {
|
|
895
|
+
success: false,
|
|
896
|
+
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
897
|
+
} : { success: true, data: result.value };
|
|
898
|
+
};
|
|
899
|
+
var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
900
|
+
var _encode = (_Err) => (schema, value, _ctx) => {
|
|
901
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
902
|
+
return _parse(_Err)(schema, value, ctx);
|
|
903
|
+
};
|
|
904
|
+
var _decode = (_Err) => (schema, value, _ctx) => {
|
|
905
|
+
return _parse(_Err)(schema, value, _ctx);
|
|
906
|
+
};
|
|
907
|
+
var _encodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
908
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
909
|
+
return _parseAsync(_Err)(schema, value, ctx);
|
|
910
|
+
};
|
|
911
|
+
var _decodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
912
|
+
return _parseAsync(_Err)(schema, value, _ctx);
|
|
913
|
+
};
|
|
914
|
+
var _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
915
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
916
|
+
return _safeParse(_Err)(schema, value, ctx);
|
|
917
|
+
};
|
|
918
|
+
var _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
919
|
+
return _safeParse(_Err)(schema, value, _ctx);
|
|
920
|
+
};
|
|
921
|
+
var _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
922
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
923
|
+
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
924
|
+
};
|
|
925
|
+
var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
926
|
+
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
927
|
+
};
|
|
928
|
+
|
|
929
|
+
// node_modules/zod/v4/core/regexes.js
|
|
930
|
+
var cuid = /^[cC][0-9a-z]{6,}$/;
|
|
931
|
+
var cuid2 = /^[0-9a-z]+$/;
|
|
932
|
+
var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
|
933
|
+
var xid = /^[0-9a-vA-V]{20}$/;
|
|
934
|
+
var ksuid = /^[A-Za-z0-9]{27}$/;
|
|
935
|
+
var nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
936
|
+
var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
937
|
+
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})$/;
|
|
938
|
+
var uuid = (version2) => {
|
|
939
|
+
if (!version2)
|
|
940
|
+
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)$/;
|
|
941
|
+
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version2}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
942
|
+
};
|
|
943
|
+
var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
944
|
+
var _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
945
|
+
function emoji() {
|
|
946
|
+
return new RegExp(_emoji, "u");
|
|
947
|
+
}
|
|
948
|
+
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])$/;
|
|
949
|
+
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}|:))$/;
|
|
950
|
+
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])$/;
|
|
951
|
+
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])$/;
|
|
952
|
+
var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
953
|
+
var base64url = /^[A-Za-z0-9_-]*$/;
|
|
954
|
+
var httpProtocol = /^https?$/;
|
|
955
|
+
var e164 = /^\+[1-9]\d{6,14}$/;
|
|
956
|
+
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])))`;
|
|
957
|
+
var date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
|
|
958
|
+
function timeSource(args) {
|
|
959
|
+
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
960
|
+
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+)?)?`;
|
|
961
|
+
return regex;
|
|
962
|
+
}
|
|
963
|
+
function time(args) {
|
|
964
|
+
return new RegExp(`^${timeSource(args)}$`);
|
|
965
|
+
}
|
|
966
|
+
function datetime(args) {
|
|
967
|
+
const time3 = timeSource({ precision: args.precision });
|
|
968
|
+
const opts = ["Z"];
|
|
969
|
+
if (args.local)
|
|
970
|
+
opts.push("");
|
|
971
|
+
if (args.offset)
|
|
972
|
+
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
973
|
+
const timeRegex = `${time3}(?:${opts.join("|")})`;
|
|
974
|
+
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
975
|
+
}
|
|
976
|
+
var string = (params) => {
|
|
977
|
+
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
978
|
+
return new RegExp(`^${regex}$`);
|
|
979
|
+
};
|
|
980
|
+
var integer = /^-?\d+$/;
|
|
981
|
+
var number = /^-?\d+(?:\.\d+)?$/;
|
|
982
|
+
var lowercase = /^[^A-Z]*$/;
|
|
983
|
+
var uppercase = /^[^a-z]*$/;
|
|
984
|
+
|
|
985
|
+
// node_modules/zod/v4/core/checks.js
|
|
986
|
+
var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
987
|
+
var _a3;
|
|
988
|
+
inst._zod ?? (inst._zod = {});
|
|
989
|
+
inst._zod.def = def;
|
|
990
|
+
(_a3 = inst._zod).onattach ?? (_a3.onattach = []);
|
|
991
|
+
});
|
|
992
|
+
var numericOriginMap = {
|
|
993
|
+
number: "number",
|
|
994
|
+
bigint: "bigint",
|
|
995
|
+
object: "date"
|
|
996
|
+
};
|
|
997
|
+
var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
998
|
+
$ZodCheck.init(inst, def);
|
|
999
|
+
const origin = numericOriginMap[typeof def.value];
|
|
1000
|
+
inst._zod.onattach.push((inst2) => {
|
|
1001
|
+
const bag = inst2._zod.bag;
|
|
1002
|
+
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
1003
|
+
if (def.value < curr) {
|
|
1004
|
+
if (def.inclusive)
|
|
1005
|
+
bag.maximum = def.value;
|
|
1006
|
+
else
|
|
1007
|
+
bag.exclusiveMaximum = def.value;
|
|
1008
|
+
}
|
|
1009
|
+
});
|
|
1010
|
+
inst._zod.check = (payload) => {
|
|
1011
|
+
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
payload.issues.push({
|
|
1015
|
+
origin,
|
|
1016
|
+
code: "too_big",
|
|
1017
|
+
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
1018
|
+
input: payload.value,
|
|
1019
|
+
inclusive: def.inclusive,
|
|
1020
|
+
inst,
|
|
1021
|
+
continue: !def.abort
|
|
1022
|
+
});
|
|
1023
|
+
};
|
|
1024
|
+
});
|
|
1025
|
+
var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
1026
|
+
$ZodCheck.init(inst, def);
|
|
1027
|
+
const origin = numericOriginMap[typeof def.value];
|
|
1028
|
+
inst._zod.onattach.push((inst2) => {
|
|
1029
|
+
const bag = inst2._zod.bag;
|
|
1030
|
+
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
1031
|
+
if (def.value > curr) {
|
|
1032
|
+
if (def.inclusive)
|
|
1033
|
+
bag.minimum = def.value;
|
|
1034
|
+
else
|
|
1035
|
+
bag.exclusiveMinimum = def.value;
|
|
1036
|
+
}
|
|
1037
|
+
});
|
|
1038
|
+
inst._zod.check = (payload) => {
|
|
1039
|
+
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
|
|
1040
|
+
return;
|
|
1041
|
+
}
|
|
1042
|
+
payload.issues.push({
|
|
1043
|
+
origin,
|
|
1044
|
+
code: "too_small",
|
|
1045
|
+
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
1046
|
+
input: payload.value,
|
|
1047
|
+
inclusive: def.inclusive,
|
|
1048
|
+
inst,
|
|
1049
|
+
continue: !def.abort
|
|
1050
|
+
});
|
|
1051
|
+
};
|
|
1052
|
+
});
|
|
1053
|
+
var $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
1054
|
+
$ZodCheck.init(inst, def);
|
|
1055
|
+
inst._zod.onattach.push((inst2) => {
|
|
1056
|
+
var _a3;
|
|
1057
|
+
(_a3 = inst2._zod.bag).multipleOf ?? (_a3.multipleOf = def.value);
|
|
1058
|
+
});
|
|
1059
|
+
inst._zod.check = (payload) => {
|
|
1060
|
+
if (typeof payload.value !== typeof def.value)
|
|
1061
|
+
throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
1062
|
+
const isMultiple = typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0;
|
|
1063
|
+
if (isMultiple)
|
|
1064
|
+
return;
|
|
1065
|
+
payload.issues.push({
|
|
1066
|
+
origin: typeof payload.value,
|
|
1067
|
+
code: "not_multiple_of",
|
|
1068
|
+
divisor: def.value,
|
|
1069
|
+
input: payload.value,
|
|
1070
|
+
inst,
|
|
1071
|
+
continue: !def.abort
|
|
1072
|
+
});
|
|
1073
|
+
};
|
|
1074
|
+
});
|
|
1075
|
+
var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat", (inst, def) => {
|
|
1076
|
+
$ZodCheck.init(inst, def);
|
|
1077
|
+
def.format = def.format || "float64";
|
|
1078
|
+
const isInt = def.format?.includes("int");
|
|
1079
|
+
const origin = isInt ? "int" : "number";
|
|
1080
|
+
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
1081
|
+
inst._zod.onattach.push((inst2) => {
|
|
1082
|
+
const bag = inst2._zod.bag;
|
|
1083
|
+
bag.format = def.format;
|
|
1084
|
+
bag.minimum = minimum;
|
|
1085
|
+
bag.maximum = maximum;
|
|
1086
|
+
if (isInt)
|
|
1087
|
+
bag.pattern = integer;
|
|
1088
|
+
});
|
|
1089
|
+
inst._zod.check = (payload) => {
|
|
1090
|
+
const input = payload.value;
|
|
1091
|
+
if (isInt) {
|
|
1092
|
+
if (!Number.isInteger(input)) {
|
|
1093
|
+
payload.issues.push({
|
|
1094
|
+
expected: origin,
|
|
1095
|
+
format: def.format,
|
|
1096
|
+
code: "invalid_type",
|
|
1097
|
+
continue: false,
|
|
1098
|
+
input,
|
|
1099
|
+
inst
|
|
1100
|
+
});
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
if (!Number.isSafeInteger(input)) {
|
|
1104
|
+
if (input > 0) {
|
|
1105
|
+
payload.issues.push({
|
|
1106
|
+
input,
|
|
1107
|
+
code: "too_big",
|
|
1108
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
1109
|
+
note: "Integers must be within the safe integer range.",
|
|
1110
|
+
inst,
|
|
1111
|
+
origin,
|
|
1112
|
+
inclusive: true,
|
|
1113
|
+
continue: !def.abort
|
|
1114
|
+
});
|
|
1115
|
+
} else {
|
|
1116
|
+
payload.issues.push({
|
|
1117
|
+
input,
|
|
1118
|
+
code: "too_small",
|
|
1119
|
+
minimum: Number.MIN_SAFE_INTEGER,
|
|
1120
|
+
note: "Integers must be within the safe integer range.",
|
|
1121
|
+
inst,
|
|
1122
|
+
origin,
|
|
1123
|
+
inclusive: true,
|
|
1124
|
+
continue: !def.abort
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
if (input < minimum) {
|
|
1131
|
+
payload.issues.push({
|
|
1132
|
+
origin: "number",
|
|
1133
|
+
input,
|
|
1134
|
+
code: "too_small",
|
|
1135
|
+
minimum,
|
|
1136
|
+
inclusive: true,
|
|
1137
|
+
inst,
|
|
1138
|
+
continue: !def.abort
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
if (input > maximum) {
|
|
1142
|
+
payload.issues.push({
|
|
1143
|
+
origin: "number",
|
|
1144
|
+
input,
|
|
1145
|
+
code: "too_big",
|
|
1146
|
+
maximum,
|
|
1147
|
+
inclusive: true,
|
|
1148
|
+
inst,
|
|
1149
|
+
continue: !def.abort
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
});
|
|
1154
|
+
var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
1155
|
+
var _a3;
|
|
1156
|
+
$ZodCheck.init(inst, def);
|
|
1157
|
+
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
|
|
1158
|
+
const val = payload.value;
|
|
1159
|
+
return !nullish(val) && val.length !== void 0;
|
|
1160
|
+
});
|
|
1161
|
+
inst._zod.onattach.push((inst2) => {
|
|
1162
|
+
const curr = inst2._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
1163
|
+
if (def.maximum < curr)
|
|
1164
|
+
inst2._zod.bag.maximum = def.maximum;
|
|
1165
|
+
});
|
|
1166
|
+
inst._zod.check = (payload) => {
|
|
1167
|
+
const input = payload.value;
|
|
1168
|
+
const length = input.length;
|
|
1169
|
+
if (length <= def.maximum)
|
|
1170
|
+
return;
|
|
1171
|
+
const origin = getLengthableOrigin(input);
|
|
1172
|
+
payload.issues.push({
|
|
1173
|
+
origin,
|
|
1174
|
+
code: "too_big",
|
|
1175
|
+
maximum: def.maximum,
|
|
1176
|
+
inclusive: true,
|
|
1177
|
+
input,
|
|
1178
|
+
inst,
|
|
1179
|
+
continue: !def.abort
|
|
1180
|
+
});
|
|
1181
|
+
};
|
|
1182
|
+
});
|
|
1183
|
+
var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
1184
|
+
var _a3;
|
|
1185
|
+
$ZodCheck.init(inst, def);
|
|
1186
|
+
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
|
|
1187
|
+
const val = payload.value;
|
|
1188
|
+
return !nullish(val) && val.length !== void 0;
|
|
1189
|
+
});
|
|
1190
|
+
inst._zod.onattach.push((inst2) => {
|
|
1191
|
+
const curr = inst2._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
1192
|
+
if (def.minimum > curr)
|
|
1193
|
+
inst2._zod.bag.minimum = def.minimum;
|
|
1194
|
+
});
|
|
1195
|
+
inst._zod.check = (payload) => {
|
|
1196
|
+
const input = payload.value;
|
|
1197
|
+
const length = input.length;
|
|
1198
|
+
if (length >= def.minimum)
|
|
1199
|
+
return;
|
|
1200
|
+
const origin = getLengthableOrigin(input);
|
|
1201
|
+
payload.issues.push({
|
|
1202
|
+
origin,
|
|
1203
|
+
code: "too_small",
|
|
1204
|
+
minimum: def.minimum,
|
|
1205
|
+
inclusive: true,
|
|
1206
|
+
input,
|
|
1207
|
+
inst,
|
|
1208
|
+
continue: !def.abort
|
|
1209
|
+
});
|
|
1210
|
+
};
|
|
1211
|
+
});
|
|
1212
|
+
var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
1213
|
+
var _a3;
|
|
1214
|
+
$ZodCheck.init(inst, def);
|
|
1215
|
+
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
|
|
1216
|
+
const val = payload.value;
|
|
1217
|
+
return !nullish(val) && val.length !== void 0;
|
|
1218
|
+
});
|
|
1219
|
+
inst._zod.onattach.push((inst2) => {
|
|
1220
|
+
const bag = inst2._zod.bag;
|
|
1221
|
+
bag.minimum = def.length;
|
|
1222
|
+
bag.maximum = def.length;
|
|
1223
|
+
bag.length = def.length;
|
|
1224
|
+
});
|
|
1225
|
+
inst._zod.check = (payload) => {
|
|
1226
|
+
const input = payload.value;
|
|
1227
|
+
const length = input.length;
|
|
1228
|
+
if (length === def.length)
|
|
1229
|
+
return;
|
|
1230
|
+
const origin = getLengthableOrigin(input);
|
|
1231
|
+
const tooBig = length > def.length;
|
|
1232
|
+
payload.issues.push({
|
|
1233
|
+
origin,
|
|
1234
|
+
...tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length },
|
|
1235
|
+
inclusive: true,
|
|
1236
|
+
exact: true,
|
|
1237
|
+
input: payload.value,
|
|
1238
|
+
inst,
|
|
1239
|
+
continue: !def.abort
|
|
1240
|
+
});
|
|
1241
|
+
};
|
|
1242
|
+
});
|
|
1243
|
+
var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
1244
|
+
var _a3, _b;
|
|
1245
|
+
$ZodCheck.init(inst, def);
|
|
1246
|
+
inst._zod.onattach.push((inst2) => {
|
|
1247
|
+
const bag = inst2._zod.bag;
|
|
1248
|
+
bag.format = def.format;
|
|
1249
|
+
if (def.pattern) {
|
|
1250
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1251
|
+
bag.patterns.add(def.pattern);
|
|
1252
|
+
}
|
|
1253
|
+
});
|
|
1254
|
+
if (def.pattern)
|
|
1255
|
+
(_a3 = inst._zod).check ?? (_a3.check = (payload) => {
|
|
1256
|
+
def.pattern.lastIndex = 0;
|
|
1257
|
+
if (def.pattern.test(payload.value))
|
|
1258
|
+
return;
|
|
1259
|
+
payload.issues.push({
|
|
1260
|
+
origin: "string",
|
|
1261
|
+
code: "invalid_format",
|
|
1262
|
+
format: def.format,
|
|
1263
|
+
input: payload.value,
|
|
1264
|
+
...def.pattern ? { pattern: def.pattern.toString() } : {},
|
|
1265
|
+
inst,
|
|
1266
|
+
continue: !def.abort
|
|
1267
|
+
});
|
|
1268
|
+
});
|
|
1269
|
+
else
|
|
1270
|
+
(_b = inst._zod).check ?? (_b.check = () => {
|
|
1271
|
+
});
|
|
1272
|
+
});
|
|
1273
|
+
var $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
|
|
1274
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
1275
|
+
inst._zod.check = (payload) => {
|
|
1276
|
+
def.pattern.lastIndex = 0;
|
|
1277
|
+
if (def.pattern.test(payload.value))
|
|
1278
|
+
return;
|
|
1279
|
+
payload.issues.push({
|
|
1280
|
+
origin: "string",
|
|
1281
|
+
code: "invalid_format",
|
|
1282
|
+
format: "regex",
|
|
1283
|
+
input: payload.value,
|
|
1284
|
+
pattern: def.pattern.toString(),
|
|
1285
|
+
inst,
|
|
1286
|
+
continue: !def.abort
|
|
1287
|
+
});
|
|
1288
|
+
};
|
|
1289
|
+
});
|
|
1290
|
+
var $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
|
|
1291
|
+
def.pattern ?? (def.pattern = lowercase);
|
|
1292
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
1293
|
+
});
|
|
1294
|
+
var $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
|
|
1295
|
+
def.pattern ?? (def.pattern = uppercase);
|
|
1296
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
1297
|
+
});
|
|
1298
|
+
var $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
1299
|
+
$ZodCheck.init(inst, def);
|
|
1300
|
+
const escapedRegex = escapeRegex(def.includes);
|
|
1301
|
+
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
|
|
1302
|
+
def.pattern = pattern;
|
|
1303
|
+
inst._zod.onattach.push((inst2) => {
|
|
1304
|
+
const bag = inst2._zod.bag;
|
|
1305
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1306
|
+
bag.patterns.add(pattern);
|
|
1307
|
+
});
|
|
1308
|
+
inst._zod.check = (payload) => {
|
|
1309
|
+
if (payload.value.includes(def.includes, def.position))
|
|
1310
|
+
return;
|
|
1311
|
+
payload.issues.push({
|
|
1312
|
+
origin: "string",
|
|
1313
|
+
code: "invalid_format",
|
|
1314
|
+
format: "includes",
|
|
1315
|
+
includes: def.includes,
|
|
1316
|
+
input: payload.value,
|
|
1317
|
+
inst,
|
|
1318
|
+
continue: !def.abort
|
|
1319
|
+
});
|
|
1320
|
+
};
|
|
1321
|
+
});
|
|
1322
|
+
var $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
|
|
1323
|
+
$ZodCheck.init(inst, def);
|
|
1324
|
+
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
1325
|
+
def.pattern ?? (def.pattern = pattern);
|
|
1326
|
+
inst._zod.onattach.push((inst2) => {
|
|
1327
|
+
const bag = inst2._zod.bag;
|
|
1328
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1329
|
+
bag.patterns.add(pattern);
|
|
1330
|
+
});
|
|
1331
|
+
inst._zod.check = (payload) => {
|
|
1332
|
+
if (payload.value.startsWith(def.prefix))
|
|
1333
|
+
return;
|
|
1334
|
+
payload.issues.push({
|
|
1335
|
+
origin: "string",
|
|
1336
|
+
code: "invalid_format",
|
|
1337
|
+
format: "starts_with",
|
|
1338
|
+
prefix: def.prefix,
|
|
1339
|
+
input: payload.value,
|
|
1340
|
+
inst,
|
|
1341
|
+
continue: !def.abort
|
|
1342
|
+
});
|
|
1343
|
+
};
|
|
1344
|
+
});
|
|
1345
|
+
var $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
|
|
1346
|
+
$ZodCheck.init(inst, def);
|
|
1347
|
+
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
1348
|
+
def.pattern ?? (def.pattern = pattern);
|
|
1349
|
+
inst._zod.onattach.push((inst2) => {
|
|
1350
|
+
const bag = inst2._zod.bag;
|
|
1351
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1352
|
+
bag.patterns.add(pattern);
|
|
1353
|
+
});
|
|
1354
|
+
inst._zod.check = (payload) => {
|
|
1355
|
+
if (payload.value.endsWith(def.suffix))
|
|
1356
|
+
return;
|
|
1357
|
+
payload.issues.push({
|
|
1358
|
+
origin: "string",
|
|
1359
|
+
code: "invalid_format",
|
|
1360
|
+
format: "ends_with",
|
|
1361
|
+
suffix: def.suffix,
|
|
1362
|
+
input: payload.value,
|
|
1363
|
+
inst,
|
|
1364
|
+
continue: !def.abort
|
|
1365
|
+
});
|
|
1366
|
+
};
|
|
1367
|
+
});
|
|
1368
|
+
var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
1369
|
+
$ZodCheck.init(inst, def);
|
|
1370
|
+
inst._zod.check = (payload) => {
|
|
1371
|
+
payload.value = def.tx(payload.value);
|
|
1372
|
+
};
|
|
1373
|
+
});
|
|
1374
|
+
|
|
1375
|
+
// node_modules/zod/v4/core/doc.js
|
|
1376
|
+
var Doc = class {
|
|
1377
|
+
constructor(args = []) {
|
|
1378
|
+
this.content = [];
|
|
1379
|
+
this.indent = 0;
|
|
1380
|
+
if (this)
|
|
1381
|
+
this.args = args;
|
|
1382
|
+
}
|
|
1383
|
+
indented(fn) {
|
|
1384
|
+
this.indent += 1;
|
|
1385
|
+
fn(this);
|
|
1386
|
+
this.indent -= 1;
|
|
1387
|
+
}
|
|
1388
|
+
write(arg) {
|
|
1389
|
+
if (typeof arg === "function") {
|
|
1390
|
+
arg(this, { execution: "sync" });
|
|
1391
|
+
arg(this, { execution: "async" });
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
const content = arg;
|
|
1395
|
+
const lines = content.split("\n").filter((x) => x);
|
|
1396
|
+
const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
|
|
1397
|
+
const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
|
|
1398
|
+
for (const line of dedented) {
|
|
1399
|
+
this.content.push(line);
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
compile() {
|
|
1403
|
+
const F = Function;
|
|
1404
|
+
const args = this?.args;
|
|
1405
|
+
const content = this?.content ?? [``];
|
|
1406
|
+
const lines = [...content.map((x) => ` ${x}`)];
|
|
1407
|
+
return new F(...args, lines.join("\n"));
|
|
1408
|
+
}
|
|
1409
|
+
};
|
|
1410
|
+
|
|
1411
|
+
// node_modules/zod/v4/core/versions.js
|
|
1412
|
+
var version = {
|
|
1413
|
+
major: 4,
|
|
1414
|
+
minor: 4,
|
|
1415
|
+
patch: 3
|
|
1416
|
+
};
|
|
1417
|
+
|
|
1418
|
+
// node_modules/zod/v4/core/schemas.js
|
|
1419
|
+
var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
1420
|
+
var _a3;
|
|
1421
|
+
inst ?? (inst = {});
|
|
1422
|
+
inst._zod.def = def;
|
|
1423
|
+
inst._zod.bag = inst._zod.bag || {};
|
|
1424
|
+
inst._zod.version = version;
|
|
1425
|
+
const checks = [...inst._zod.def.checks ?? []];
|
|
1426
|
+
if (inst._zod.traits.has("$ZodCheck")) {
|
|
1427
|
+
checks.unshift(inst);
|
|
1428
|
+
}
|
|
1429
|
+
for (const ch of checks) {
|
|
1430
|
+
for (const fn of ch._zod.onattach) {
|
|
1431
|
+
fn(inst);
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
if (checks.length === 0) {
|
|
1435
|
+
(_a3 = inst._zod).deferred ?? (_a3.deferred = []);
|
|
1436
|
+
inst._zod.deferred?.push(() => {
|
|
1437
|
+
inst._zod.run = inst._zod.parse;
|
|
1438
|
+
});
|
|
1439
|
+
} else {
|
|
1440
|
+
const runChecks = (payload, checks2, ctx) => {
|
|
1441
|
+
let isAborted = aborted(payload);
|
|
1442
|
+
let asyncResult;
|
|
1443
|
+
for (const ch of checks2) {
|
|
1444
|
+
if (ch._zod.def.when) {
|
|
1445
|
+
if (explicitlyAborted(payload))
|
|
1446
|
+
continue;
|
|
1447
|
+
const shouldRun = ch._zod.def.when(payload);
|
|
1448
|
+
if (!shouldRun)
|
|
1449
|
+
continue;
|
|
1450
|
+
} else if (isAborted) {
|
|
1451
|
+
continue;
|
|
1452
|
+
}
|
|
1453
|
+
const currLen = payload.issues.length;
|
|
1454
|
+
const _ = ch._zod.check(payload);
|
|
1455
|
+
if (_ instanceof Promise && ctx?.async === false) {
|
|
1456
|
+
throw new $ZodAsyncError();
|
|
1457
|
+
}
|
|
1458
|
+
if (asyncResult || _ instanceof Promise) {
|
|
1459
|
+
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
1460
|
+
await _;
|
|
1461
|
+
const nextLen = payload.issues.length;
|
|
1462
|
+
if (nextLen === currLen)
|
|
1463
|
+
return;
|
|
1464
|
+
if (!isAborted)
|
|
1465
|
+
isAborted = aborted(payload, currLen);
|
|
1466
|
+
});
|
|
1467
|
+
} else {
|
|
1468
|
+
const nextLen = payload.issues.length;
|
|
1469
|
+
if (nextLen === currLen)
|
|
1470
|
+
continue;
|
|
1471
|
+
if (!isAborted)
|
|
1472
|
+
isAborted = aborted(payload, currLen);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
if (asyncResult) {
|
|
1476
|
+
return asyncResult.then(() => {
|
|
1477
|
+
return payload;
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
return payload;
|
|
1481
|
+
};
|
|
1482
|
+
const handleCanaryResult = (canary, payload, ctx) => {
|
|
1483
|
+
if (aborted(canary)) {
|
|
1484
|
+
canary.aborted = true;
|
|
1485
|
+
return canary;
|
|
1486
|
+
}
|
|
1487
|
+
const checkResult = runChecks(payload, checks, ctx);
|
|
1488
|
+
if (checkResult instanceof Promise) {
|
|
1489
|
+
if (ctx.async === false)
|
|
1490
|
+
throw new $ZodAsyncError();
|
|
1491
|
+
return checkResult.then((checkResult2) => inst._zod.parse(checkResult2, ctx));
|
|
1492
|
+
}
|
|
1493
|
+
return inst._zod.parse(checkResult, ctx);
|
|
1494
|
+
};
|
|
1495
|
+
inst._zod.run = (payload, ctx) => {
|
|
1496
|
+
if (ctx.skipChecks) {
|
|
1497
|
+
return inst._zod.parse(payload, ctx);
|
|
1498
|
+
}
|
|
1499
|
+
if (ctx.direction === "backward") {
|
|
1500
|
+
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
|
|
1501
|
+
if (canary instanceof Promise) {
|
|
1502
|
+
return canary.then((canary2) => {
|
|
1503
|
+
return handleCanaryResult(canary2, payload, ctx);
|
|
1504
|
+
});
|
|
1505
|
+
}
|
|
1506
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
1507
|
+
}
|
|
1508
|
+
const result = inst._zod.parse(payload, ctx);
|
|
1509
|
+
if (result instanceof Promise) {
|
|
1510
|
+
if (ctx.async === false)
|
|
1511
|
+
throw new $ZodAsyncError();
|
|
1512
|
+
return result.then((result2) => runChecks(result2, checks, ctx));
|
|
1513
|
+
}
|
|
1514
|
+
return runChecks(result, checks, ctx);
|
|
1515
|
+
};
|
|
1516
|
+
}
|
|
1517
|
+
defineLazy(inst, "~standard", () => ({
|
|
1518
|
+
validate: (value) => {
|
|
1519
|
+
try {
|
|
1520
|
+
const r = safeParse(inst, value);
|
|
1521
|
+
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
1522
|
+
} catch (_) {
|
|
1523
|
+
return safeParseAsync(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
|
|
1524
|
+
}
|
|
1525
|
+
},
|
|
1526
|
+
vendor: "zod",
|
|
1527
|
+
version: 1
|
|
1528
|
+
}));
|
|
1529
|
+
});
|
|
1530
|
+
var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
1531
|
+
$ZodType.init(inst, def);
|
|
1532
|
+
inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string(inst._zod.bag);
|
|
1533
|
+
inst._zod.parse = (payload, _) => {
|
|
1534
|
+
if (def.coerce)
|
|
1535
|
+
try {
|
|
1536
|
+
payload.value = String(payload.value);
|
|
1537
|
+
} catch (_2) {
|
|
1538
|
+
}
|
|
1539
|
+
if (typeof payload.value === "string")
|
|
1540
|
+
return payload;
|
|
1541
|
+
payload.issues.push({
|
|
1542
|
+
expected: "string",
|
|
1543
|
+
code: "invalid_type",
|
|
1544
|
+
input: payload.value,
|
|
1545
|
+
inst
|
|
1546
|
+
});
|
|
1547
|
+
return payload;
|
|
1548
|
+
};
|
|
1549
|
+
});
|
|
1550
|
+
var $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
|
|
1551
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
1552
|
+
$ZodString.init(inst, def);
|
|
1553
|
+
});
|
|
1554
|
+
var $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
|
|
1555
|
+
def.pattern ?? (def.pattern = guid);
|
|
1556
|
+
$ZodStringFormat.init(inst, def);
|
|
1557
|
+
});
|
|
1558
|
+
var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
|
|
1559
|
+
if (def.version) {
|
|
1560
|
+
const versionMap = {
|
|
1561
|
+
v1: 1,
|
|
1562
|
+
v2: 2,
|
|
1563
|
+
v3: 3,
|
|
1564
|
+
v4: 4,
|
|
1565
|
+
v5: 5,
|
|
1566
|
+
v6: 6,
|
|
1567
|
+
v7: 7,
|
|
1568
|
+
v8: 8
|
|
1569
|
+
};
|
|
1570
|
+
const v = versionMap[def.version];
|
|
1571
|
+
if (v === void 0)
|
|
1572
|
+
throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
1573
|
+
def.pattern ?? (def.pattern = uuid(v));
|
|
1574
|
+
} else
|
|
1575
|
+
def.pattern ?? (def.pattern = uuid());
|
|
1576
|
+
$ZodStringFormat.init(inst, def);
|
|
1577
|
+
});
|
|
1578
|
+
var $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
|
|
1579
|
+
def.pattern ?? (def.pattern = email);
|
|
1580
|
+
$ZodStringFormat.init(inst, def);
|
|
1581
|
+
});
|
|
1582
|
+
var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
1583
|
+
$ZodStringFormat.init(inst, def);
|
|
1584
|
+
inst._zod.check = (payload) => {
|
|
1585
|
+
try {
|
|
1586
|
+
const trimmed = payload.value.trim();
|
|
1587
|
+
if (!def.normalize && def.protocol?.source === httpProtocol.source) {
|
|
1588
|
+
if (!/^https?:\/\//i.test(trimmed)) {
|
|
1589
|
+
payload.issues.push({
|
|
1590
|
+
code: "invalid_format",
|
|
1591
|
+
format: "url",
|
|
1592
|
+
note: "Invalid URL format",
|
|
1593
|
+
input: payload.value,
|
|
1594
|
+
inst,
|
|
1595
|
+
continue: !def.abort
|
|
1596
|
+
});
|
|
1597
|
+
return;
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
const url = new URL(trimmed);
|
|
1601
|
+
if (def.hostname) {
|
|
1602
|
+
def.hostname.lastIndex = 0;
|
|
1603
|
+
if (!def.hostname.test(url.hostname)) {
|
|
1604
|
+
payload.issues.push({
|
|
1605
|
+
code: "invalid_format",
|
|
1606
|
+
format: "url",
|
|
1607
|
+
note: "Invalid hostname",
|
|
1608
|
+
pattern: def.hostname.source,
|
|
1609
|
+
input: payload.value,
|
|
1610
|
+
inst,
|
|
1611
|
+
continue: !def.abort
|
|
1612
|
+
});
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
if (def.protocol) {
|
|
1616
|
+
def.protocol.lastIndex = 0;
|
|
1617
|
+
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
|
|
1618
|
+
payload.issues.push({
|
|
1619
|
+
code: "invalid_format",
|
|
1620
|
+
format: "url",
|
|
1621
|
+
note: "Invalid protocol",
|
|
1622
|
+
pattern: def.protocol.source,
|
|
1623
|
+
input: payload.value,
|
|
1624
|
+
inst,
|
|
1625
|
+
continue: !def.abort
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
if (def.normalize) {
|
|
1630
|
+
payload.value = url.href;
|
|
1631
|
+
} else {
|
|
1632
|
+
payload.value = trimmed;
|
|
1633
|
+
}
|
|
1634
|
+
return;
|
|
1635
|
+
} catch (_) {
|
|
1636
|
+
payload.issues.push({
|
|
1637
|
+
code: "invalid_format",
|
|
1638
|
+
format: "url",
|
|
1639
|
+
input: payload.value,
|
|
1640
|
+
inst,
|
|
1641
|
+
continue: !def.abort
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
};
|
|
1645
|
+
});
|
|
1646
|
+
var $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
|
|
1647
|
+
def.pattern ?? (def.pattern = emoji());
|
|
1648
|
+
$ZodStringFormat.init(inst, def);
|
|
1649
|
+
});
|
|
1650
|
+
var $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
|
|
1651
|
+
def.pattern ?? (def.pattern = nanoid);
|
|
1652
|
+
$ZodStringFormat.init(inst, def);
|
|
1653
|
+
});
|
|
1654
|
+
var $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
|
|
1655
|
+
def.pattern ?? (def.pattern = cuid);
|
|
1656
|
+
$ZodStringFormat.init(inst, def);
|
|
1657
|
+
});
|
|
1658
|
+
var $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
|
|
1659
|
+
def.pattern ?? (def.pattern = cuid2);
|
|
1660
|
+
$ZodStringFormat.init(inst, def);
|
|
1661
|
+
});
|
|
1662
|
+
var $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
|
|
1663
|
+
def.pattern ?? (def.pattern = ulid);
|
|
1664
|
+
$ZodStringFormat.init(inst, def);
|
|
1665
|
+
});
|
|
1666
|
+
var $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
|
|
1667
|
+
def.pattern ?? (def.pattern = xid);
|
|
1668
|
+
$ZodStringFormat.init(inst, def);
|
|
1669
|
+
});
|
|
1670
|
+
var $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
|
|
1671
|
+
def.pattern ?? (def.pattern = ksuid);
|
|
1672
|
+
$ZodStringFormat.init(inst, def);
|
|
1673
|
+
});
|
|
1674
|
+
var $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
|
|
1675
|
+
def.pattern ?? (def.pattern = datetime(def));
|
|
1676
|
+
$ZodStringFormat.init(inst, def);
|
|
1677
|
+
});
|
|
1678
|
+
var $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
|
|
1679
|
+
def.pattern ?? (def.pattern = date);
|
|
1680
|
+
$ZodStringFormat.init(inst, def);
|
|
1681
|
+
});
|
|
1682
|
+
var $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
|
|
1683
|
+
def.pattern ?? (def.pattern = time(def));
|
|
1684
|
+
$ZodStringFormat.init(inst, def);
|
|
1685
|
+
});
|
|
1686
|
+
var $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
|
|
1687
|
+
def.pattern ?? (def.pattern = duration);
|
|
1688
|
+
$ZodStringFormat.init(inst, def);
|
|
1689
|
+
});
|
|
1690
|
+
var $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
|
|
1691
|
+
def.pattern ?? (def.pattern = ipv4);
|
|
1692
|
+
$ZodStringFormat.init(inst, def);
|
|
1693
|
+
inst._zod.bag.format = `ipv4`;
|
|
1694
|
+
});
|
|
1695
|
+
var $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
|
|
1696
|
+
def.pattern ?? (def.pattern = ipv6);
|
|
1697
|
+
$ZodStringFormat.init(inst, def);
|
|
1698
|
+
inst._zod.bag.format = `ipv6`;
|
|
1699
|
+
inst._zod.check = (payload) => {
|
|
1700
|
+
try {
|
|
1701
|
+
new URL(`http://[${payload.value}]`);
|
|
1702
|
+
} catch {
|
|
1703
|
+
payload.issues.push({
|
|
1704
|
+
code: "invalid_format",
|
|
1705
|
+
format: "ipv6",
|
|
1706
|
+
input: payload.value,
|
|
1707
|
+
inst,
|
|
1708
|
+
continue: !def.abort
|
|
1709
|
+
});
|
|
1710
|
+
}
|
|
1711
|
+
};
|
|
1712
|
+
});
|
|
1713
|
+
var $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
1714
|
+
def.pattern ?? (def.pattern = cidrv4);
|
|
1715
|
+
$ZodStringFormat.init(inst, def);
|
|
1716
|
+
});
|
|
1717
|
+
var $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
1718
|
+
def.pattern ?? (def.pattern = cidrv6);
|
|
1719
|
+
$ZodStringFormat.init(inst, def);
|
|
1720
|
+
inst._zod.check = (payload) => {
|
|
1721
|
+
const parts = payload.value.split("/");
|
|
1722
|
+
try {
|
|
1723
|
+
if (parts.length !== 2)
|
|
1724
|
+
throw new Error();
|
|
1725
|
+
const [address, prefix] = parts;
|
|
1726
|
+
if (!prefix)
|
|
1727
|
+
throw new Error();
|
|
1728
|
+
const prefixNum = Number(prefix);
|
|
1729
|
+
if (`${prefixNum}` !== prefix)
|
|
1730
|
+
throw new Error();
|
|
1731
|
+
if (prefixNum < 0 || prefixNum > 128)
|
|
1732
|
+
throw new Error();
|
|
1733
|
+
new URL(`http://[${address}]`);
|
|
1734
|
+
} catch {
|
|
1735
|
+
payload.issues.push({
|
|
1736
|
+
code: "invalid_format",
|
|
1737
|
+
format: "cidrv6",
|
|
1738
|
+
input: payload.value,
|
|
1739
|
+
inst,
|
|
1740
|
+
continue: !def.abort
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
};
|
|
1744
|
+
});
|
|
1745
|
+
function isValidBase64(data) {
|
|
1746
|
+
if (data === "")
|
|
1747
|
+
return true;
|
|
1748
|
+
if (/\s/.test(data))
|
|
1749
|
+
return false;
|
|
1750
|
+
if (data.length % 4 !== 0)
|
|
1751
|
+
return false;
|
|
1752
|
+
try {
|
|
1753
|
+
atob(data);
|
|
1754
|
+
return true;
|
|
1755
|
+
} catch {
|
|
1756
|
+
return false;
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
1760
|
+
def.pattern ?? (def.pattern = base64);
|
|
1761
|
+
$ZodStringFormat.init(inst, def);
|
|
1762
|
+
inst._zod.bag.contentEncoding = "base64";
|
|
1763
|
+
inst._zod.check = (payload) => {
|
|
1764
|
+
if (isValidBase64(payload.value))
|
|
1765
|
+
return;
|
|
1766
|
+
payload.issues.push({
|
|
1767
|
+
code: "invalid_format",
|
|
1768
|
+
format: "base64",
|
|
1769
|
+
input: payload.value,
|
|
1770
|
+
inst,
|
|
1771
|
+
continue: !def.abort
|
|
1772
|
+
});
|
|
1773
|
+
};
|
|
1774
|
+
});
|
|
1775
|
+
function isValidBase64URL(data) {
|
|
1776
|
+
if (!base64url.test(data))
|
|
1777
|
+
return false;
|
|
1778
|
+
const base642 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
1779
|
+
const padded = base642.padEnd(Math.ceil(base642.length / 4) * 4, "=");
|
|
1780
|
+
return isValidBase64(padded);
|
|
1781
|
+
}
|
|
1782
|
+
var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
|
|
1783
|
+
def.pattern ?? (def.pattern = base64url);
|
|
1784
|
+
$ZodStringFormat.init(inst, def);
|
|
1785
|
+
inst._zod.bag.contentEncoding = "base64url";
|
|
1786
|
+
inst._zod.check = (payload) => {
|
|
1787
|
+
if (isValidBase64URL(payload.value))
|
|
1788
|
+
return;
|
|
1789
|
+
payload.issues.push({
|
|
1790
|
+
code: "invalid_format",
|
|
1791
|
+
format: "base64url",
|
|
1792
|
+
input: payload.value,
|
|
1793
|
+
inst,
|
|
1794
|
+
continue: !def.abort
|
|
1795
|
+
});
|
|
1796
|
+
};
|
|
1797
|
+
});
|
|
1798
|
+
var $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
|
|
1799
|
+
def.pattern ?? (def.pattern = e164);
|
|
1800
|
+
$ZodStringFormat.init(inst, def);
|
|
1801
|
+
});
|
|
1802
|
+
function isValidJWT(token, algorithm = null) {
|
|
1803
|
+
try {
|
|
1804
|
+
const tokensParts = token.split(".");
|
|
1805
|
+
if (tokensParts.length !== 3)
|
|
1806
|
+
return false;
|
|
1807
|
+
const [header] = tokensParts;
|
|
1808
|
+
if (!header)
|
|
1809
|
+
return false;
|
|
1810
|
+
const parsedHeader = JSON.parse(atob(header));
|
|
1811
|
+
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
|
|
1812
|
+
return false;
|
|
1813
|
+
if (!parsedHeader.alg)
|
|
1814
|
+
return false;
|
|
1815
|
+
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
|
|
1816
|
+
return false;
|
|
1817
|
+
return true;
|
|
1818
|
+
} catch {
|
|
1819
|
+
return false;
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
var $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
|
|
1823
|
+
$ZodStringFormat.init(inst, def);
|
|
1824
|
+
inst._zod.check = (payload) => {
|
|
1825
|
+
if (isValidJWT(payload.value, def.alg))
|
|
1826
|
+
return;
|
|
1827
|
+
payload.issues.push({
|
|
1828
|
+
code: "invalid_format",
|
|
1829
|
+
format: "jwt",
|
|
1830
|
+
input: payload.value,
|
|
1831
|
+
inst,
|
|
1832
|
+
continue: !def.abort
|
|
1833
|
+
});
|
|
1834
|
+
};
|
|
1835
|
+
});
|
|
1836
|
+
var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
1837
|
+
$ZodType.init(inst, def);
|
|
1838
|
+
inst._zod.pattern = inst._zod.bag.pattern ?? number;
|
|
1839
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1840
|
+
if (def.coerce)
|
|
1841
|
+
try {
|
|
1842
|
+
payload.value = Number(payload.value);
|
|
1843
|
+
} catch (_) {
|
|
1844
|
+
}
|
|
1845
|
+
const input = payload.value;
|
|
1846
|
+
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
|
|
1847
|
+
return payload;
|
|
1848
|
+
}
|
|
1849
|
+
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
|
|
1850
|
+
payload.issues.push({
|
|
1851
|
+
expected: "number",
|
|
1852
|
+
code: "invalid_type",
|
|
1853
|
+
input,
|
|
1854
|
+
inst,
|
|
1855
|
+
...received ? { received } : {}
|
|
1856
|
+
});
|
|
1857
|
+
return payload;
|
|
1858
|
+
};
|
|
1859
|
+
});
|
|
1860
|
+
var $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, def) => {
|
|
1861
|
+
$ZodCheckNumberFormat.init(inst, def);
|
|
1862
|
+
$ZodNumber.init(inst, def);
|
|
1863
|
+
});
|
|
1864
|
+
var $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
|
|
1865
|
+
$ZodType.init(inst, def);
|
|
1866
|
+
inst._zod.parse = (payload) => payload;
|
|
1867
|
+
});
|
|
1868
|
+
var $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
|
|
1869
|
+
$ZodType.init(inst, def);
|
|
1870
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1871
|
+
payload.issues.push({
|
|
1872
|
+
expected: "never",
|
|
1873
|
+
code: "invalid_type",
|
|
1874
|
+
input: payload.value,
|
|
1875
|
+
inst
|
|
1876
|
+
});
|
|
1877
|
+
return payload;
|
|
1878
|
+
};
|
|
1879
|
+
});
|
|
1880
|
+
function handleArrayResult(result, final, index) {
|
|
1881
|
+
if (result.issues.length) {
|
|
1882
|
+
final.issues.push(...prefixIssues(index, result.issues));
|
|
1883
|
+
}
|
|
1884
|
+
final.value[index] = result.value;
|
|
1885
|
+
}
|
|
1886
|
+
var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
1887
|
+
$ZodType.init(inst, def);
|
|
1888
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1889
|
+
const input = payload.value;
|
|
1890
|
+
if (!Array.isArray(input)) {
|
|
1891
|
+
payload.issues.push({
|
|
1892
|
+
expected: "array",
|
|
1893
|
+
code: "invalid_type",
|
|
1894
|
+
input,
|
|
1895
|
+
inst
|
|
1896
|
+
});
|
|
1897
|
+
return payload;
|
|
1898
|
+
}
|
|
1899
|
+
payload.value = Array(input.length);
|
|
1900
|
+
const proms = [];
|
|
1901
|
+
for (let i = 0; i < input.length; i++) {
|
|
1902
|
+
const item = input[i];
|
|
1903
|
+
const result = def.element._zod.run({
|
|
1904
|
+
value: item,
|
|
1905
|
+
issues: []
|
|
1906
|
+
}, ctx);
|
|
1907
|
+
if (result instanceof Promise) {
|
|
1908
|
+
proms.push(result.then((result2) => handleArrayResult(result2, payload, i)));
|
|
1909
|
+
} else {
|
|
1910
|
+
handleArrayResult(result, payload, i);
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
if (proms.length) {
|
|
1914
|
+
return Promise.all(proms).then(() => payload);
|
|
1915
|
+
}
|
|
1916
|
+
return payload;
|
|
1917
|
+
};
|
|
1918
|
+
});
|
|
1919
|
+
function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
|
|
1920
|
+
const isPresent = key in input;
|
|
1921
|
+
if (result.issues.length) {
|
|
1922
|
+
if (isOptionalIn && isOptionalOut && !isPresent) {
|
|
1923
|
+
return;
|
|
1924
|
+
}
|
|
1925
|
+
final.issues.push(...prefixIssues(key, result.issues));
|
|
1926
|
+
}
|
|
1927
|
+
if (!isPresent && !isOptionalIn) {
|
|
1928
|
+
if (!result.issues.length) {
|
|
1929
|
+
final.issues.push({
|
|
1930
|
+
code: "invalid_type",
|
|
1931
|
+
expected: "nonoptional",
|
|
1932
|
+
input: void 0,
|
|
1933
|
+
path: [key]
|
|
1934
|
+
});
|
|
1935
|
+
}
|
|
1936
|
+
return;
|
|
1937
|
+
}
|
|
1938
|
+
if (result.value === void 0) {
|
|
1939
|
+
if (isPresent) {
|
|
1940
|
+
final.value[key] = void 0;
|
|
1941
|
+
}
|
|
1942
|
+
} else {
|
|
1943
|
+
final.value[key] = result.value;
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
function normalizeDef(def) {
|
|
1947
|
+
const keys = Object.keys(def.shape);
|
|
1948
|
+
for (const k of keys) {
|
|
1949
|
+
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
|
|
1950
|
+
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
const okeys = optionalKeys(def.shape);
|
|
1954
|
+
return {
|
|
1955
|
+
...def,
|
|
1956
|
+
keys,
|
|
1957
|
+
keySet: new Set(keys),
|
|
1958
|
+
numKeys: keys.length,
|
|
1959
|
+
optionalKeys: new Set(okeys)
|
|
1960
|
+
};
|
|
1961
|
+
}
|
|
1962
|
+
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
1963
|
+
const unrecognized = [];
|
|
1964
|
+
const keySet = def.keySet;
|
|
1965
|
+
const _catchall = def.catchall._zod;
|
|
1966
|
+
const t = _catchall.def.type;
|
|
1967
|
+
const isOptionalIn = _catchall.optin === "optional";
|
|
1968
|
+
const isOptionalOut = _catchall.optout === "optional";
|
|
1969
|
+
for (const key in input) {
|
|
1970
|
+
if (key === "__proto__")
|
|
1971
|
+
continue;
|
|
1972
|
+
if (keySet.has(key))
|
|
1973
|
+
continue;
|
|
1974
|
+
if (t === "never") {
|
|
1975
|
+
unrecognized.push(key);
|
|
1976
|
+
continue;
|
|
1977
|
+
}
|
|
1978
|
+
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
1979
|
+
if (r instanceof Promise) {
|
|
1980
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
1981
|
+
} else {
|
|
1982
|
+
handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
if (unrecognized.length) {
|
|
1986
|
+
payload.issues.push({
|
|
1987
|
+
code: "unrecognized_keys",
|
|
1988
|
+
keys: unrecognized,
|
|
1989
|
+
input,
|
|
1990
|
+
inst
|
|
1991
|
+
});
|
|
1992
|
+
}
|
|
1993
|
+
if (!proms.length)
|
|
1994
|
+
return payload;
|
|
1995
|
+
return Promise.all(proms).then(() => {
|
|
1996
|
+
return payload;
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1999
|
+
var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
2000
|
+
$ZodType.init(inst, def);
|
|
2001
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
2002
|
+
if (!desc?.get) {
|
|
2003
|
+
const sh = def.shape;
|
|
2004
|
+
Object.defineProperty(def, "shape", {
|
|
2005
|
+
get: () => {
|
|
2006
|
+
const newSh = { ...sh };
|
|
2007
|
+
Object.defineProperty(def, "shape", {
|
|
2008
|
+
value: newSh
|
|
2009
|
+
});
|
|
2010
|
+
return newSh;
|
|
2011
|
+
}
|
|
2012
|
+
});
|
|
2013
|
+
}
|
|
2014
|
+
const _normalized = cached(() => normalizeDef(def));
|
|
2015
|
+
defineLazy(inst._zod, "propValues", () => {
|
|
2016
|
+
const shape = def.shape;
|
|
2017
|
+
const propValues = {};
|
|
2018
|
+
for (const key in shape) {
|
|
2019
|
+
const field = shape[key]._zod;
|
|
2020
|
+
if (field.values) {
|
|
2021
|
+
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
2022
|
+
for (const v of field.values)
|
|
2023
|
+
propValues[key].add(v);
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
return propValues;
|
|
2027
|
+
});
|
|
2028
|
+
const isObject2 = isObject;
|
|
2029
|
+
const catchall = def.catchall;
|
|
2030
|
+
let value;
|
|
2031
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2032
|
+
value ?? (value = _normalized.value);
|
|
2033
|
+
const input = payload.value;
|
|
2034
|
+
if (!isObject2(input)) {
|
|
2035
|
+
payload.issues.push({
|
|
2036
|
+
expected: "object",
|
|
2037
|
+
code: "invalid_type",
|
|
2038
|
+
input,
|
|
2039
|
+
inst
|
|
2040
|
+
});
|
|
2041
|
+
return payload;
|
|
2042
|
+
}
|
|
2043
|
+
payload.value = {};
|
|
2044
|
+
const proms = [];
|
|
2045
|
+
const shape = value.shape;
|
|
2046
|
+
for (const key of value.keys) {
|
|
2047
|
+
const el = shape[key];
|
|
2048
|
+
const isOptionalIn = el._zod.optin === "optional";
|
|
2049
|
+
const isOptionalOut = el._zod.optout === "optional";
|
|
2050
|
+
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
2051
|
+
if (r instanceof Promise) {
|
|
2052
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
2053
|
+
} else {
|
|
2054
|
+
handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
if (!catchall) {
|
|
2058
|
+
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
2059
|
+
}
|
|
2060
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
2061
|
+
};
|
|
2062
|
+
});
|
|
2063
|
+
var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
2064
|
+
$ZodObject.init(inst, def);
|
|
2065
|
+
const superParse = inst._zod.parse;
|
|
2066
|
+
const _normalized = cached(() => normalizeDef(def));
|
|
2067
|
+
const generateFastpass = (shape) => {
|
|
2068
|
+
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
2069
|
+
const normalized = _normalized.value;
|
|
2070
|
+
const parseStr = (key) => {
|
|
2071
|
+
const k = esc(key);
|
|
2072
|
+
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
2073
|
+
};
|
|
2074
|
+
doc.write(`const input = payload.value;`);
|
|
2075
|
+
const ids = /* @__PURE__ */ Object.create(null);
|
|
2076
|
+
let counter = 0;
|
|
2077
|
+
for (const key of normalized.keys) {
|
|
2078
|
+
ids[key] = `key_${counter++}`;
|
|
2079
|
+
}
|
|
2080
|
+
doc.write(`const newResult = {};`);
|
|
2081
|
+
for (const key of normalized.keys) {
|
|
2082
|
+
const id = ids[key];
|
|
2083
|
+
const k = esc(key);
|
|
2084
|
+
const schema = shape[key];
|
|
2085
|
+
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
2086
|
+
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
2087
|
+
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
2088
|
+
if (isOptionalIn && isOptionalOut) {
|
|
2089
|
+
doc.write(`
|
|
2090
|
+
if (${id}.issues.length) {
|
|
2091
|
+
if (${k} in input) {
|
|
2092
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
2093
|
+
...iss,
|
|
2094
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
2095
|
+
})));
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
if (${id}.value === undefined) {
|
|
2100
|
+
if (${k} in input) {
|
|
2101
|
+
newResult[${k}] = undefined;
|
|
2102
|
+
}
|
|
2103
|
+
} else {
|
|
2104
|
+
newResult[${k}] = ${id}.value;
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
`);
|
|
2108
|
+
} else if (!isOptionalIn) {
|
|
2109
|
+
doc.write(`
|
|
2110
|
+
const ${id}_present = ${k} in input;
|
|
2111
|
+
if (${id}.issues.length) {
|
|
2112
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
2113
|
+
...iss,
|
|
2114
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
2115
|
+
})));
|
|
2116
|
+
}
|
|
2117
|
+
if (!${id}_present && !${id}.issues.length) {
|
|
2118
|
+
payload.issues.push({
|
|
2119
|
+
code: "invalid_type",
|
|
2120
|
+
expected: "nonoptional",
|
|
2121
|
+
input: undefined,
|
|
2122
|
+
path: [${k}]
|
|
2123
|
+
});
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
if (${id}_present) {
|
|
2127
|
+
if (${id}.value === undefined) {
|
|
2128
|
+
newResult[${k}] = undefined;
|
|
2129
|
+
} else {
|
|
2130
|
+
newResult[${k}] = ${id}.value;
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
`);
|
|
2135
|
+
} else {
|
|
2136
|
+
doc.write(`
|
|
2137
|
+
if (${id}.issues.length) {
|
|
2138
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
2139
|
+
...iss,
|
|
2140
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
2141
|
+
})));
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
if (${id}.value === undefined) {
|
|
2145
|
+
if (${k} in input) {
|
|
2146
|
+
newResult[${k}] = undefined;
|
|
2147
|
+
}
|
|
2148
|
+
} else {
|
|
2149
|
+
newResult[${k}] = ${id}.value;
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
`);
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
doc.write(`payload.value = newResult;`);
|
|
2156
|
+
doc.write(`return payload;`);
|
|
2157
|
+
const fn = doc.compile();
|
|
2158
|
+
return (payload, ctx) => fn(shape, payload, ctx);
|
|
2159
|
+
};
|
|
2160
|
+
let fastpass;
|
|
2161
|
+
const isObject2 = isObject;
|
|
2162
|
+
const jit = !globalConfig.jitless;
|
|
2163
|
+
const allowsEval2 = allowsEval;
|
|
2164
|
+
const fastEnabled = jit && allowsEval2.value;
|
|
2165
|
+
const catchall = def.catchall;
|
|
2166
|
+
let value;
|
|
2167
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2168
|
+
value ?? (value = _normalized.value);
|
|
2169
|
+
const input = payload.value;
|
|
2170
|
+
if (!isObject2(input)) {
|
|
2171
|
+
payload.issues.push({
|
|
2172
|
+
expected: "object",
|
|
2173
|
+
code: "invalid_type",
|
|
2174
|
+
input,
|
|
2175
|
+
inst
|
|
2176
|
+
});
|
|
2177
|
+
return payload;
|
|
2178
|
+
}
|
|
2179
|
+
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
|
2180
|
+
if (!fastpass)
|
|
2181
|
+
fastpass = generateFastpass(def.shape);
|
|
2182
|
+
payload = fastpass(payload, ctx);
|
|
2183
|
+
if (!catchall)
|
|
2184
|
+
return payload;
|
|
2185
|
+
return handleCatchall([], input, payload, ctx, value, inst);
|
|
2186
|
+
}
|
|
2187
|
+
return superParse(payload, ctx);
|
|
2188
|
+
};
|
|
2189
|
+
});
|
|
2190
|
+
function handleUnionResults(results, final, inst, ctx) {
|
|
2191
|
+
for (const result of results) {
|
|
2192
|
+
if (result.issues.length === 0) {
|
|
2193
|
+
final.value = result.value;
|
|
2194
|
+
return final;
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
const nonaborted = results.filter((r) => !aborted(r));
|
|
2198
|
+
if (nonaborted.length === 1) {
|
|
2199
|
+
final.value = nonaborted[0].value;
|
|
2200
|
+
return nonaborted[0];
|
|
2201
|
+
}
|
|
2202
|
+
final.issues.push({
|
|
2203
|
+
code: "invalid_union",
|
|
2204
|
+
input: final.value,
|
|
2205
|
+
inst,
|
|
2206
|
+
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
2207
|
+
});
|
|
2208
|
+
return final;
|
|
2209
|
+
}
|
|
2210
|
+
var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
2211
|
+
$ZodType.init(inst, def);
|
|
2212
|
+
defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
|
|
2213
|
+
defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
|
|
2214
|
+
defineLazy(inst._zod, "values", () => {
|
|
2215
|
+
if (def.options.every((o) => o._zod.values)) {
|
|
2216
|
+
return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
2217
|
+
}
|
|
2218
|
+
return void 0;
|
|
2219
|
+
});
|
|
2220
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
2221
|
+
if (def.options.every((o) => o._zod.pattern)) {
|
|
2222
|
+
const patterns = def.options.map((o) => o._zod.pattern);
|
|
2223
|
+
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
2224
|
+
}
|
|
2225
|
+
return void 0;
|
|
2226
|
+
});
|
|
2227
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
2228
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2229
|
+
if (first) {
|
|
2230
|
+
return first(payload, ctx);
|
|
2231
|
+
}
|
|
2232
|
+
let async = false;
|
|
2233
|
+
const results = [];
|
|
2234
|
+
for (const option of def.options) {
|
|
2235
|
+
const result = option._zod.run({
|
|
2236
|
+
value: payload.value,
|
|
2237
|
+
issues: []
|
|
2238
|
+
}, ctx);
|
|
2239
|
+
if (result instanceof Promise) {
|
|
2240
|
+
results.push(result);
|
|
2241
|
+
async = true;
|
|
2242
|
+
} else {
|
|
2243
|
+
if (result.issues.length === 0)
|
|
2244
|
+
return result;
|
|
2245
|
+
results.push(result);
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
if (!async)
|
|
2249
|
+
return handleUnionResults(results, payload, inst, ctx);
|
|
2250
|
+
return Promise.all(results).then((results2) => {
|
|
2251
|
+
return handleUnionResults(results2, payload, inst, ctx);
|
|
2252
|
+
});
|
|
2253
|
+
};
|
|
2254
|
+
});
|
|
2255
|
+
var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
|
|
2256
|
+
$ZodType.init(inst, def);
|
|
2257
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2258
|
+
const input = payload.value;
|
|
2259
|
+
const left = def.left._zod.run({ value: input, issues: [] }, ctx);
|
|
2260
|
+
const right = def.right._zod.run({ value: input, issues: [] }, ctx);
|
|
2261
|
+
const async = left instanceof Promise || right instanceof Promise;
|
|
2262
|
+
if (async) {
|
|
2263
|
+
return Promise.all([left, right]).then(([left2, right2]) => {
|
|
2264
|
+
return handleIntersectionResults(payload, left2, right2);
|
|
2265
|
+
});
|
|
2266
|
+
}
|
|
2267
|
+
return handleIntersectionResults(payload, left, right);
|
|
2268
|
+
};
|
|
2269
|
+
});
|
|
2270
|
+
function mergeValues(a, b) {
|
|
2271
|
+
if (a === b) {
|
|
2272
|
+
return { valid: true, data: a };
|
|
2273
|
+
}
|
|
2274
|
+
if (a instanceof Date && b instanceof Date && +a === +b) {
|
|
2275
|
+
return { valid: true, data: a };
|
|
2276
|
+
}
|
|
2277
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
2278
|
+
const bKeys = Object.keys(b);
|
|
2279
|
+
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
2280
|
+
const newObj = { ...a, ...b };
|
|
2281
|
+
for (const key of sharedKeys) {
|
|
2282
|
+
const sharedValue = mergeValues(a[key], b[key]);
|
|
2283
|
+
if (!sharedValue.valid) {
|
|
2284
|
+
return {
|
|
2285
|
+
valid: false,
|
|
2286
|
+
mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
|
|
2287
|
+
};
|
|
2288
|
+
}
|
|
2289
|
+
newObj[key] = sharedValue.data;
|
|
2290
|
+
}
|
|
2291
|
+
return { valid: true, data: newObj };
|
|
2292
|
+
}
|
|
2293
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
2294
|
+
if (a.length !== b.length) {
|
|
2295
|
+
return { valid: false, mergeErrorPath: [] };
|
|
2296
|
+
}
|
|
2297
|
+
const newArray = [];
|
|
2298
|
+
for (let index = 0; index < a.length; index++) {
|
|
2299
|
+
const itemA = a[index];
|
|
2300
|
+
const itemB = b[index];
|
|
2301
|
+
const sharedValue = mergeValues(itemA, itemB);
|
|
2302
|
+
if (!sharedValue.valid) {
|
|
2303
|
+
return {
|
|
2304
|
+
valid: false,
|
|
2305
|
+
mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
|
|
2306
|
+
};
|
|
2307
|
+
}
|
|
2308
|
+
newArray.push(sharedValue.data);
|
|
2309
|
+
}
|
|
2310
|
+
return { valid: true, data: newArray };
|
|
2311
|
+
}
|
|
2312
|
+
return { valid: false, mergeErrorPath: [] };
|
|
2313
|
+
}
|
|
2314
|
+
function handleIntersectionResults(result, left, right) {
|
|
2315
|
+
const unrecKeys = /* @__PURE__ */ new Map();
|
|
2316
|
+
let unrecIssue;
|
|
2317
|
+
for (const iss of left.issues) {
|
|
2318
|
+
if (iss.code === "unrecognized_keys") {
|
|
2319
|
+
unrecIssue ?? (unrecIssue = iss);
|
|
2320
|
+
for (const k of iss.keys) {
|
|
2321
|
+
if (!unrecKeys.has(k))
|
|
2322
|
+
unrecKeys.set(k, {});
|
|
2323
|
+
unrecKeys.get(k).l = true;
|
|
2324
|
+
}
|
|
2325
|
+
} else {
|
|
2326
|
+
result.issues.push(iss);
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
for (const iss of right.issues) {
|
|
2330
|
+
if (iss.code === "unrecognized_keys") {
|
|
2331
|
+
for (const k of iss.keys) {
|
|
2332
|
+
if (!unrecKeys.has(k))
|
|
2333
|
+
unrecKeys.set(k, {});
|
|
2334
|
+
unrecKeys.get(k).r = true;
|
|
2335
|
+
}
|
|
2336
|
+
} else {
|
|
2337
|
+
result.issues.push(iss);
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
2341
|
+
if (bothKeys.length && unrecIssue) {
|
|
2342
|
+
result.issues.push({ ...unrecIssue, keys: bothKeys });
|
|
2343
|
+
}
|
|
2344
|
+
if (aborted(result))
|
|
2345
|
+
return result;
|
|
2346
|
+
const merged = mergeValues(left.value, right.value);
|
|
2347
|
+
if (!merged.valid) {
|
|
2348
|
+
throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
2349
|
+
}
|
|
2350
|
+
result.value = merged.data;
|
|
2351
|
+
return result;
|
|
2352
|
+
}
|
|
2353
|
+
var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
2354
|
+
$ZodType.init(inst, def);
|
|
2355
|
+
const values = getEnumValues(def.entries);
|
|
2356
|
+
const valuesSet = new Set(values);
|
|
2357
|
+
inst._zod.values = valuesSet;
|
|
2358
|
+
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
2359
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
2360
|
+
const input = payload.value;
|
|
2361
|
+
if (valuesSet.has(input)) {
|
|
2362
|
+
return payload;
|
|
2363
|
+
}
|
|
2364
|
+
payload.issues.push({
|
|
2365
|
+
code: "invalid_value",
|
|
2366
|
+
values,
|
|
2367
|
+
input,
|
|
2368
|
+
inst
|
|
2369
|
+
});
|
|
2370
|
+
return payload;
|
|
2371
|
+
};
|
|
2372
|
+
});
|
|
2373
|
+
var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
2374
|
+
$ZodType.init(inst, def);
|
|
2375
|
+
inst._zod.optin = "optional";
|
|
2376
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2377
|
+
if (ctx.direction === "backward") {
|
|
2378
|
+
throw new $ZodEncodeError(inst.constructor.name);
|
|
2379
|
+
}
|
|
2380
|
+
const _out = def.transform(payload.value, payload);
|
|
2381
|
+
if (ctx.async) {
|
|
2382
|
+
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
2383
|
+
return output.then((output2) => {
|
|
2384
|
+
payload.value = output2;
|
|
2385
|
+
payload.fallback = true;
|
|
2386
|
+
return payload;
|
|
2387
|
+
});
|
|
2388
|
+
}
|
|
2389
|
+
if (_out instanceof Promise) {
|
|
2390
|
+
throw new $ZodAsyncError();
|
|
2391
|
+
}
|
|
2392
|
+
payload.value = _out;
|
|
2393
|
+
payload.fallback = true;
|
|
2394
|
+
return payload;
|
|
2395
|
+
};
|
|
2396
|
+
});
|
|
2397
|
+
function handleOptionalResult(result, input) {
|
|
2398
|
+
if (input === void 0 && (result.issues.length || result.fallback)) {
|
|
2399
|
+
return { issues: [], value: void 0 };
|
|
2400
|
+
}
|
|
2401
|
+
return result;
|
|
2402
|
+
}
|
|
2403
|
+
var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
2404
|
+
$ZodType.init(inst, def);
|
|
2405
|
+
inst._zod.optin = "optional";
|
|
2406
|
+
inst._zod.optout = "optional";
|
|
2407
|
+
defineLazy(inst._zod, "values", () => {
|
|
2408
|
+
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
|
|
2409
|
+
});
|
|
2410
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
2411
|
+
const pattern = def.innerType._zod.pattern;
|
|
2412
|
+
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
2413
|
+
});
|
|
2414
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2415
|
+
if (def.innerType._zod.optin === "optional") {
|
|
2416
|
+
const input = payload.value;
|
|
2417
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
2418
|
+
if (result instanceof Promise)
|
|
2419
|
+
return result.then((r) => handleOptionalResult(r, input));
|
|
2420
|
+
return handleOptionalResult(result, input);
|
|
2421
|
+
}
|
|
2422
|
+
if (payload.value === void 0) {
|
|
2423
|
+
return payload;
|
|
2424
|
+
}
|
|
2425
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2426
|
+
};
|
|
2427
|
+
});
|
|
2428
|
+
var $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
|
|
2429
|
+
$ZodOptional.init(inst, def);
|
|
2430
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2431
|
+
defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
|
|
2432
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2433
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2434
|
+
};
|
|
2435
|
+
});
|
|
2436
|
+
var $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
2437
|
+
$ZodType.init(inst, def);
|
|
2438
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
2439
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
2440
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
2441
|
+
const pattern = def.innerType._zod.pattern;
|
|
2442
|
+
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
|
|
2443
|
+
});
|
|
2444
|
+
defineLazy(inst._zod, "values", () => {
|
|
2445
|
+
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
|
|
2446
|
+
});
|
|
2447
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2448
|
+
if (payload.value === null)
|
|
2449
|
+
return payload;
|
|
2450
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2451
|
+
};
|
|
2452
|
+
});
|
|
2453
|
+
var $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
|
|
2454
|
+
$ZodType.init(inst, def);
|
|
2455
|
+
inst._zod.optin = "optional";
|
|
2456
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2457
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2458
|
+
if (ctx.direction === "backward") {
|
|
2459
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2460
|
+
}
|
|
2461
|
+
if (payload.value === void 0) {
|
|
2462
|
+
payload.value = def.defaultValue;
|
|
2463
|
+
return payload;
|
|
2464
|
+
}
|
|
2465
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
2466
|
+
if (result instanceof Promise) {
|
|
2467
|
+
return result.then((result2) => handleDefaultResult(result2, def));
|
|
2468
|
+
}
|
|
2469
|
+
return handleDefaultResult(result, def);
|
|
2470
|
+
};
|
|
2471
|
+
});
|
|
2472
|
+
function handleDefaultResult(payload, def) {
|
|
2473
|
+
if (payload.value === void 0) {
|
|
2474
|
+
payload.value = def.defaultValue;
|
|
2475
|
+
}
|
|
2476
|
+
return payload;
|
|
2477
|
+
}
|
|
2478
|
+
var $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
2479
|
+
$ZodType.init(inst, def);
|
|
2480
|
+
inst._zod.optin = "optional";
|
|
2481
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2482
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2483
|
+
if (ctx.direction === "backward") {
|
|
2484
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2485
|
+
}
|
|
2486
|
+
if (payload.value === void 0) {
|
|
2487
|
+
payload.value = def.defaultValue;
|
|
2488
|
+
}
|
|
2489
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2490
|
+
};
|
|
2491
|
+
});
|
|
2492
|
+
var $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
2493
|
+
$ZodType.init(inst, def);
|
|
2494
|
+
defineLazy(inst._zod, "values", () => {
|
|
2495
|
+
const v = def.innerType._zod.values;
|
|
2496
|
+
return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
|
|
2497
|
+
});
|
|
2498
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2499
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
2500
|
+
if (result instanceof Promise) {
|
|
2501
|
+
return result.then((result2) => handleNonOptionalResult(result2, inst));
|
|
2502
|
+
}
|
|
2503
|
+
return handleNonOptionalResult(result, inst);
|
|
2504
|
+
};
|
|
2505
|
+
});
|
|
2506
|
+
function handleNonOptionalResult(payload, inst) {
|
|
2507
|
+
if (!payload.issues.length && payload.value === void 0) {
|
|
2508
|
+
payload.issues.push({
|
|
2509
|
+
code: "invalid_type",
|
|
2510
|
+
expected: "nonoptional",
|
|
2511
|
+
input: payload.value,
|
|
2512
|
+
inst
|
|
2513
|
+
});
|
|
2514
|
+
}
|
|
2515
|
+
return payload;
|
|
2516
|
+
}
|
|
2517
|
+
var $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
2518
|
+
$ZodType.init(inst, def);
|
|
2519
|
+
inst._zod.optin = "optional";
|
|
2520
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
2521
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2522
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2523
|
+
if (ctx.direction === "backward") {
|
|
2524
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2525
|
+
}
|
|
2526
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
2527
|
+
if (result instanceof Promise) {
|
|
2528
|
+
return result.then((result2) => {
|
|
2529
|
+
payload.value = result2.value;
|
|
2530
|
+
if (result2.issues.length) {
|
|
2531
|
+
payload.value = def.catchValue({
|
|
2532
|
+
...payload,
|
|
2533
|
+
error: {
|
|
2534
|
+
issues: result2.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
2535
|
+
},
|
|
2536
|
+
input: payload.value
|
|
2537
|
+
});
|
|
2538
|
+
payload.issues = [];
|
|
2539
|
+
payload.fallback = true;
|
|
2540
|
+
}
|
|
2541
|
+
return payload;
|
|
2542
|
+
});
|
|
2543
|
+
}
|
|
2544
|
+
payload.value = result.value;
|
|
2545
|
+
if (result.issues.length) {
|
|
2546
|
+
payload.value = def.catchValue({
|
|
2547
|
+
...payload,
|
|
2548
|
+
error: {
|
|
2549
|
+
issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
2550
|
+
},
|
|
2551
|
+
input: payload.value
|
|
2552
|
+
});
|
|
2553
|
+
payload.issues = [];
|
|
2554
|
+
payload.fallback = true;
|
|
2555
|
+
}
|
|
2556
|
+
return payload;
|
|
2557
|
+
};
|
|
2558
|
+
});
|
|
2559
|
+
var $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
|
|
2560
|
+
$ZodType.init(inst, def);
|
|
2561
|
+
defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
2562
|
+
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
2563
|
+
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
2564
|
+
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
2565
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2566
|
+
if (ctx.direction === "backward") {
|
|
2567
|
+
const right = def.out._zod.run(payload, ctx);
|
|
2568
|
+
if (right instanceof Promise) {
|
|
2569
|
+
return right.then((right2) => handlePipeResult(right2, def.in, ctx));
|
|
2570
|
+
}
|
|
2571
|
+
return handlePipeResult(right, def.in, ctx);
|
|
2572
|
+
}
|
|
2573
|
+
const left = def.in._zod.run(payload, ctx);
|
|
2574
|
+
if (left instanceof Promise) {
|
|
2575
|
+
return left.then((left2) => handlePipeResult(left2, def.out, ctx));
|
|
2576
|
+
}
|
|
2577
|
+
return handlePipeResult(left, def.out, ctx);
|
|
2578
|
+
};
|
|
2579
|
+
});
|
|
2580
|
+
function handlePipeResult(left, next, ctx) {
|
|
2581
|
+
if (left.issues.length) {
|
|
2582
|
+
left.aborted = true;
|
|
2583
|
+
return left;
|
|
2584
|
+
}
|
|
2585
|
+
return next._zod.run({ value: left.value, issues: left.issues, fallback: left.fallback }, ctx);
|
|
2586
|
+
}
|
|
2587
|
+
var $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
|
|
2588
|
+
$ZodType.init(inst, def);
|
|
2589
|
+
defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
2590
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2591
|
+
defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
|
|
2592
|
+
defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
|
|
2593
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2594
|
+
if (ctx.direction === "backward") {
|
|
2595
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2596
|
+
}
|
|
2597
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
2598
|
+
if (result instanceof Promise) {
|
|
2599
|
+
return result.then(handleReadonlyResult);
|
|
2600
|
+
}
|
|
2601
|
+
return handleReadonlyResult(result);
|
|
2602
|
+
};
|
|
2603
|
+
});
|
|
2604
|
+
function handleReadonlyResult(payload) {
|
|
2605
|
+
payload.value = Object.freeze(payload.value);
|
|
2606
|
+
return payload;
|
|
2607
|
+
}
|
|
2608
|
+
var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
2609
|
+
$ZodCheck.init(inst, def);
|
|
2610
|
+
$ZodType.init(inst, def);
|
|
2611
|
+
inst._zod.parse = (payload, _) => {
|
|
2612
|
+
return payload;
|
|
2613
|
+
};
|
|
2614
|
+
inst._zod.check = (payload) => {
|
|
2615
|
+
const input = payload.value;
|
|
2616
|
+
const r = def.fn(input);
|
|
2617
|
+
if (r instanceof Promise) {
|
|
2618
|
+
return r.then((r2) => handleRefineResult(r2, payload, input, inst));
|
|
2619
|
+
}
|
|
2620
|
+
handleRefineResult(r, payload, input, inst);
|
|
2621
|
+
return;
|
|
2622
|
+
};
|
|
2623
|
+
});
|
|
2624
|
+
function handleRefineResult(result, payload, input, inst) {
|
|
2625
|
+
if (!result) {
|
|
2626
|
+
const _iss = {
|
|
2627
|
+
code: "custom",
|
|
2628
|
+
input,
|
|
2629
|
+
inst,
|
|
2630
|
+
// incorporates params.error into issue reporting
|
|
2631
|
+
path: [...inst._zod.def.path ?? []],
|
|
2632
|
+
// incorporates params.error into issue reporting
|
|
2633
|
+
continue: !inst._zod.def.abort
|
|
2634
|
+
// params: inst._zod.def.params,
|
|
2635
|
+
};
|
|
2636
|
+
if (inst._zod.def.params)
|
|
2637
|
+
_iss.params = inst._zod.def.params;
|
|
2638
|
+
payload.issues.push(issue(_iss));
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
|
|
2642
|
+
// node_modules/zod/v4/core/registries.js
|
|
2643
|
+
var _a2;
|
|
2644
|
+
var $output = Symbol("ZodOutput");
|
|
2645
|
+
var $input = Symbol("ZodInput");
|
|
2646
|
+
var $ZodRegistry = class {
|
|
2647
|
+
constructor() {
|
|
2648
|
+
this._map = /* @__PURE__ */ new WeakMap();
|
|
2649
|
+
this._idmap = /* @__PURE__ */ new Map();
|
|
2650
|
+
}
|
|
2651
|
+
add(schema, ..._meta) {
|
|
2652
|
+
const meta2 = _meta[0];
|
|
2653
|
+
this._map.set(schema, meta2);
|
|
2654
|
+
if (meta2 && typeof meta2 === "object" && "id" in meta2) {
|
|
2655
|
+
this._idmap.set(meta2.id, schema);
|
|
2656
|
+
}
|
|
2657
|
+
return this;
|
|
2658
|
+
}
|
|
2659
|
+
clear() {
|
|
2660
|
+
this._map = /* @__PURE__ */ new WeakMap();
|
|
2661
|
+
this._idmap = /* @__PURE__ */ new Map();
|
|
2662
|
+
return this;
|
|
2663
|
+
}
|
|
2664
|
+
remove(schema) {
|
|
2665
|
+
const meta2 = this._map.get(schema);
|
|
2666
|
+
if (meta2 && typeof meta2 === "object" && "id" in meta2) {
|
|
2667
|
+
this._idmap.delete(meta2.id);
|
|
2668
|
+
}
|
|
2669
|
+
this._map.delete(schema);
|
|
2670
|
+
return this;
|
|
2671
|
+
}
|
|
2672
|
+
get(schema) {
|
|
2673
|
+
const p = schema._zod.parent;
|
|
2674
|
+
if (p) {
|
|
2675
|
+
const pm = { ...this.get(p) ?? {} };
|
|
2676
|
+
delete pm.id;
|
|
2677
|
+
const f = { ...pm, ...this._map.get(schema) };
|
|
2678
|
+
return Object.keys(f).length ? f : void 0;
|
|
2679
|
+
}
|
|
2680
|
+
return this._map.get(schema);
|
|
2681
|
+
}
|
|
2682
|
+
has(schema) {
|
|
2683
|
+
return this._map.has(schema);
|
|
2684
|
+
}
|
|
2685
|
+
};
|
|
2686
|
+
function registry() {
|
|
2687
|
+
return new $ZodRegistry();
|
|
2688
|
+
}
|
|
2689
|
+
(_a2 = globalThis).__zod_globalRegistry ?? (_a2.__zod_globalRegistry = registry());
|
|
2690
|
+
var globalRegistry = globalThis.__zod_globalRegistry;
|
|
2691
|
+
|
|
2692
|
+
// node_modules/zod/v4/core/api.js
|
|
2693
|
+
// @__NO_SIDE_EFFECTS__
|
|
2694
|
+
function _string(Class2, params) {
|
|
2695
|
+
return new Class2({
|
|
2696
|
+
type: "string",
|
|
2697
|
+
...normalizeParams(params)
|
|
2698
|
+
});
|
|
2699
|
+
}
|
|
2700
|
+
// @__NO_SIDE_EFFECTS__
|
|
2701
|
+
function _email(Class2, params) {
|
|
2702
|
+
return new Class2({
|
|
2703
|
+
type: "string",
|
|
2704
|
+
format: "email",
|
|
2705
|
+
check: "string_format",
|
|
2706
|
+
abort: false,
|
|
2707
|
+
...normalizeParams(params)
|
|
2708
|
+
});
|
|
2709
|
+
}
|
|
2710
|
+
// @__NO_SIDE_EFFECTS__
|
|
2711
|
+
function _guid(Class2, params) {
|
|
2712
|
+
return new Class2({
|
|
2713
|
+
type: "string",
|
|
2714
|
+
format: "guid",
|
|
2715
|
+
check: "string_format",
|
|
2716
|
+
abort: false,
|
|
2717
|
+
...normalizeParams(params)
|
|
2718
|
+
});
|
|
2719
|
+
}
|
|
2720
|
+
// @__NO_SIDE_EFFECTS__
|
|
2721
|
+
function _uuid(Class2, params) {
|
|
2722
|
+
return new Class2({
|
|
2723
|
+
type: "string",
|
|
2724
|
+
format: "uuid",
|
|
2725
|
+
check: "string_format",
|
|
2726
|
+
abort: false,
|
|
2727
|
+
...normalizeParams(params)
|
|
2728
|
+
});
|
|
2729
|
+
}
|
|
2730
|
+
// @__NO_SIDE_EFFECTS__
|
|
2731
|
+
function _uuidv4(Class2, params) {
|
|
2732
|
+
return new Class2({
|
|
2733
|
+
type: "string",
|
|
2734
|
+
format: "uuid",
|
|
2735
|
+
check: "string_format",
|
|
2736
|
+
abort: false,
|
|
2737
|
+
version: "v4",
|
|
2738
|
+
...normalizeParams(params)
|
|
2739
|
+
});
|
|
2740
|
+
}
|
|
2741
|
+
// @__NO_SIDE_EFFECTS__
|
|
2742
|
+
function _uuidv6(Class2, params) {
|
|
2743
|
+
return new Class2({
|
|
2744
|
+
type: "string",
|
|
2745
|
+
format: "uuid",
|
|
2746
|
+
check: "string_format",
|
|
2747
|
+
abort: false,
|
|
2748
|
+
version: "v6",
|
|
2749
|
+
...normalizeParams(params)
|
|
2750
|
+
});
|
|
2751
|
+
}
|
|
2752
|
+
// @__NO_SIDE_EFFECTS__
|
|
2753
|
+
function _uuidv7(Class2, params) {
|
|
2754
|
+
return new Class2({
|
|
2755
|
+
type: "string",
|
|
2756
|
+
format: "uuid",
|
|
2757
|
+
check: "string_format",
|
|
2758
|
+
abort: false,
|
|
2759
|
+
version: "v7",
|
|
2760
|
+
...normalizeParams(params)
|
|
2761
|
+
});
|
|
2762
|
+
}
|
|
2763
|
+
// @__NO_SIDE_EFFECTS__
|
|
2764
|
+
function _url(Class2, params) {
|
|
2765
|
+
return new Class2({
|
|
2766
|
+
type: "string",
|
|
2767
|
+
format: "url",
|
|
2768
|
+
check: "string_format",
|
|
2769
|
+
abort: false,
|
|
2770
|
+
...normalizeParams(params)
|
|
2771
|
+
});
|
|
2772
|
+
}
|
|
2773
|
+
// @__NO_SIDE_EFFECTS__
|
|
2774
|
+
function _emoji2(Class2, params) {
|
|
2775
|
+
return new Class2({
|
|
2776
|
+
type: "string",
|
|
2777
|
+
format: "emoji",
|
|
2778
|
+
check: "string_format",
|
|
2779
|
+
abort: false,
|
|
2780
|
+
...normalizeParams(params)
|
|
2781
|
+
});
|
|
2782
|
+
}
|
|
2783
|
+
// @__NO_SIDE_EFFECTS__
|
|
2784
|
+
function _nanoid(Class2, params) {
|
|
2785
|
+
return new Class2({
|
|
2786
|
+
type: "string",
|
|
2787
|
+
format: "nanoid",
|
|
2788
|
+
check: "string_format",
|
|
2789
|
+
abort: false,
|
|
2790
|
+
...normalizeParams(params)
|
|
2791
|
+
});
|
|
2792
|
+
}
|
|
2793
|
+
// @__NO_SIDE_EFFECTS__
|
|
2794
|
+
function _cuid(Class2, params) {
|
|
2795
|
+
return new Class2({
|
|
2796
|
+
type: "string",
|
|
2797
|
+
format: "cuid",
|
|
2798
|
+
check: "string_format",
|
|
2799
|
+
abort: false,
|
|
2800
|
+
...normalizeParams(params)
|
|
2801
|
+
});
|
|
2802
|
+
}
|
|
2803
|
+
// @__NO_SIDE_EFFECTS__
|
|
2804
|
+
function _cuid2(Class2, params) {
|
|
2805
|
+
return new Class2({
|
|
2806
|
+
type: "string",
|
|
2807
|
+
format: "cuid2",
|
|
2808
|
+
check: "string_format",
|
|
2809
|
+
abort: false,
|
|
2810
|
+
...normalizeParams(params)
|
|
2811
|
+
});
|
|
2812
|
+
}
|
|
2813
|
+
// @__NO_SIDE_EFFECTS__
|
|
2814
|
+
function _ulid(Class2, params) {
|
|
2815
|
+
return new Class2({
|
|
2816
|
+
type: "string",
|
|
2817
|
+
format: "ulid",
|
|
2818
|
+
check: "string_format",
|
|
2819
|
+
abort: false,
|
|
2820
|
+
...normalizeParams(params)
|
|
2821
|
+
});
|
|
2822
|
+
}
|
|
2823
|
+
// @__NO_SIDE_EFFECTS__
|
|
2824
|
+
function _xid(Class2, params) {
|
|
2825
|
+
return new Class2({
|
|
2826
|
+
type: "string",
|
|
2827
|
+
format: "xid",
|
|
2828
|
+
check: "string_format",
|
|
2829
|
+
abort: false,
|
|
2830
|
+
...normalizeParams(params)
|
|
2831
|
+
});
|
|
2832
|
+
}
|
|
2833
|
+
// @__NO_SIDE_EFFECTS__
|
|
2834
|
+
function _ksuid(Class2, params) {
|
|
2835
|
+
return new Class2({
|
|
2836
|
+
type: "string",
|
|
2837
|
+
format: "ksuid",
|
|
2838
|
+
check: "string_format",
|
|
2839
|
+
abort: false,
|
|
2840
|
+
...normalizeParams(params)
|
|
2841
|
+
});
|
|
2842
|
+
}
|
|
2843
|
+
// @__NO_SIDE_EFFECTS__
|
|
2844
|
+
function _ipv4(Class2, params) {
|
|
2845
|
+
return new Class2({
|
|
2846
|
+
type: "string",
|
|
2847
|
+
format: "ipv4",
|
|
2848
|
+
check: "string_format",
|
|
2849
|
+
abort: false,
|
|
2850
|
+
...normalizeParams(params)
|
|
2851
|
+
});
|
|
2852
|
+
}
|
|
2853
|
+
// @__NO_SIDE_EFFECTS__
|
|
2854
|
+
function _ipv6(Class2, params) {
|
|
2855
|
+
return new Class2({
|
|
2856
|
+
type: "string",
|
|
2857
|
+
format: "ipv6",
|
|
2858
|
+
check: "string_format",
|
|
2859
|
+
abort: false,
|
|
2860
|
+
...normalizeParams(params)
|
|
2861
|
+
});
|
|
2862
|
+
}
|
|
2863
|
+
// @__NO_SIDE_EFFECTS__
|
|
2864
|
+
function _cidrv4(Class2, params) {
|
|
2865
|
+
return new Class2({
|
|
2866
|
+
type: "string",
|
|
2867
|
+
format: "cidrv4",
|
|
2868
|
+
check: "string_format",
|
|
2869
|
+
abort: false,
|
|
2870
|
+
...normalizeParams(params)
|
|
2871
|
+
});
|
|
2872
|
+
}
|
|
2873
|
+
// @__NO_SIDE_EFFECTS__
|
|
2874
|
+
function _cidrv6(Class2, params) {
|
|
2875
|
+
return new Class2({
|
|
2876
|
+
type: "string",
|
|
2877
|
+
format: "cidrv6",
|
|
2878
|
+
check: "string_format",
|
|
2879
|
+
abort: false,
|
|
2880
|
+
...normalizeParams(params)
|
|
2881
|
+
});
|
|
2882
|
+
}
|
|
2883
|
+
// @__NO_SIDE_EFFECTS__
|
|
2884
|
+
function _base64(Class2, params) {
|
|
2885
|
+
return new Class2({
|
|
2886
|
+
type: "string",
|
|
2887
|
+
format: "base64",
|
|
2888
|
+
check: "string_format",
|
|
2889
|
+
abort: false,
|
|
2890
|
+
...normalizeParams(params)
|
|
2891
|
+
});
|
|
2892
|
+
}
|
|
2893
|
+
// @__NO_SIDE_EFFECTS__
|
|
2894
|
+
function _base64url(Class2, params) {
|
|
2895
|
+
return new Class2({
|
|
2896
|
+
type: "string",
|
|
2897
|
+
format: "base64url",
|
|
2898
|
+
check: "string_format",
|
|
2899
|
+
abort: false,
|
|
2900
|
+
...normalizeParams(params)
|
|
2901
|
+
});
|
|
2902
|
+
}
|
|
2903
|
+
// @__NO_SIDE_EFFECTS__
|
|
2904
|
+
function _e164(Class2, params) {
|
|
2905
|
+
return new Class2({
|
|
2906
|
+
type: "string",
|
|
2907
|
+
format: "e164",
|
|
2908
|
+
check: "string_format",
|
|
2909
|
+
abort: false,
|
|
2910
|
+
...normalizeParams(params)
|
|
2911
|
+
});
|
|
2912
|
+
}
|
|
2913
|
+
// @__NO_SIDE_EFFECTS__
|
|
2914
|
+
function _jwt(Class2, params) {
|
|
2915
|
+
return new Class2({
|
|
2916
|
+
type: "string",
|
|
2917
|
+
format: "jwt",
|
|
2918
|
+
check: "string_format",
|
|
2919
|
+
abort: false,
|
|
2920
|
+
...normalizeParams(params)
|
|
2921
|
+
});
|
|
2922
|
+
}
|
|
2923
|
+
// @__NO_SIDE_EFFECTS__
|
|
2924
|
+
function _isoDateTime(Class2, params) {
|
|
2925
|
+
return new Class2({
|
|
2926
|
+
type: "string",
|
|
2927
|
+
format: "datetime",
|
|
2928
|
+
check: "string_format",
|
|
2929
|
+
offset: false,
|
|
2930
|
+
local: false,
|
|
2931
|
+
precision: null,
|
|
2932
|
+
...normalizeParams(params)
|
|
2933
|
+
});
|
|
2934
|
+
}
|
|
2935
|
+
// @__NO_SIDE_EFFECTS__
|
|
2936
|
+
function _isoDate(Class2, params) {
|
|
2937
|
+
return new Class2({
|
|
2938
|
+
type: "string",
|
|
2939
|
+
format: "date",
|
|
2940
|
+
check: "string_format",
|
|
2941
|
+
...normalizeParams(params)
|
|
2942
|
+
});
|
|
2943
|
+
}
|
|
2944
|
+
// @__NO_SIDE_EFFECTS__
|
|
2945
|
+
function _isoTime(Class2, params) {
|
|
2946
|
+
return new Class2({
|
|
2947
|
+
type: "string",
|
|
2948
|
+
format: "time",
|
|
2949
|
+
check: "string_format",
|
|
2950
|
+
precision: null,
|
|
2951
|
+
...normalizeParams(params)
|
|
2952
|
+
});
|
|
2953
|
+
}
|
|
2954
|
+
// @__NO_SIDE_EFFECTS__
|
|
2955
|
+
function _isoDuration(Class2, params) {
|
|
2956
|
+
return new Class2({
|
|
2957
|
+
type: "string",
|
|
2958
|
+
format: "duration",
|
|
2959
|
+
check: "string_format",
|
|
2960
|
+
...normalizeParams(params)
|
|
2961
|
+
});
|
|
2962
|
+
}
|
|
2963
|
+
// @__NO_SIDE_EFFECTS__
|
|
2964
|
+
function _number(Class2, params) {
|
|
2965
|
+
return new Class2({
|
|
2966
|
+
type: "number",
|
|
2967
|
+
checks: [],
|
|
2968
|
+
...normalizeParams(params)
|
|
2969
|
+
});
|
|
2970
|
+
}
|
|
2971
|
+
// @__NO_SIDE_EFFECTS__
|
|
2972
|
+
function _int(Class2, params) {
|
|
2973
|
+
return new Class2({
|
|
2974
|
+
type: "number",
|
|
2975
|
+
check: "number_format",
|
|
2976
|
+
abort: false,
|
|
2977
|
+
format: "safeint",
|
|
2978
|
+
...normalizeParams(params)
|
|
2979
|
+
});
|
|
2980
|
+
}
|
|
2981
|
+
// @__NO_SIDE_EFFECTS__
|
|
2982
|
+
function _unknown(Class2) {
|
|
2983
|
+
return new Class2({
|
|
2984
|
+
type: "unknown"
|
|
2985
|
+
});
|
|
2986
|
+
}
|
|
2987
|
+
// @__NO_SIDE_EFFECTS__
|
|
2988
|
+
function _never(Class2, params) {
|
|
2989
|
+
return new Class2({
|
|
2990
|
+
type: "never",
|
|
2991
|
+
...normalizeParams(params)
|
|
2992
|
+
});
|
|
2993
|
+
}
|
|
2994
|
+
// @__NO_SIDE_EFFECTS__
|
|
2995
|
+
function _lt(value, params) {
|
|
2996
|
+
return new $ZodCheckLessThan({
|
|
2997
|
+
check: "less_than",
|
|
2998
|
+
...normalizeParams(params),
|
|
2999
|
+
value,
|
|
3000
|
+
inclusive: false
|
|
3001
|
+
});
|
|
3002
|
+
}
|
|
3003
|
+
// @__NO_SIDE_EFFECTS__
|
|
3004
|
+
function _lte(value, params) {
|
|
3005
|
+
return new $ZodCheckLessThan({
|
|
3006
|
+
check: "less_than",
|
|
3007
|
+
...normalizeParams(params),
|
|
3008
|
+
value,
|
|
3009
|
+
inclusive: true
|
|
3010
|
+
});
|
|
3011
|
+
}
|
|
3012
|
+
// @__NO_SIDE_EFFECTS__
|
|
3013
|
+
function _gt(value, params) {
|
|
3014
|
+
return new $ZodCheckGreaterThan({
|
|
3015
|
+
check: "greater_than",
|
|
3016
|
+
...normalizeParams(params),
|
|
3017
|
+
value,
|
|
3018
|
+
inclusive: false
|
|
3019
|
+
});
|
|
3020
|
+
}
|
|
3021
|
+
// @__NO_SIDE_EFFECTS__
|
|
3022
|
+
function _gte(value, params) {
|
|
3023
|
+
return new $ZodCheckGreaterThan({
|
|
3024
|
+
check: "greater_than",
|
|
3025
|
+
...normalizeParams(params),
|
|
3026
|
+
value,
|
|
3027
|
+
inclusive: true
|
|
3028
|
+
});
|
|
3029
|
+
}
|
|
3030
|
+
// @__NO_SIDE_EFFECTS__
|
|
3031
|
+
function _multipleOf(value, params) {
|
|
3032
|
+
return new $ZodCheckMultipleOf({
|
|
3033
|
+
check: "multiple_of",
|
|
3034
|
+
...normalizeParams(params),
|
|
3035
|
+
value
|
|
3036
|
+
});
|
|
3037
|
+
}
|
|
3038
|
+
// @__NO_SIDE_EFFECTS__
|
|
3039
|
+
function _maxLength(maximum, params) {
|
|
3040
|
+
const ch = new $ZodCheckMaxLength({
|
|
3041
|
+
check: "max_length",
|
|
3042
|
+
...normalizeParams(params),
|
|
3043
|
+
maximum
|
|
3044
|
+
});
|
|
3045
|
+
return ch;
|
|
3046
|
+
}
|
|
3047
|
+
// @__NO_SIDE_EFFECTS__
|
|
3048
|
+
function _minLength(minimum, params) {
|
|
3049
|
+
return new $ZodCheckMinLength({
|
|
3050
|
+
check: "min_length",
|
|
3051
|
+
...normalizeParams(params),
|
|
3052
|
+
minimum
|
|
3053
|
+
});
|
|
3054
|
+
}
|
|
3055
|
+
// @__NO_SIDE_EFFECTS__
|
|
3056
|
+
function _length(length, params) {
|
|
3057
|
+
return new $ZodCheckLengthEquals({
|
|
3058
|
+
check: "length_equals",
|
|
3059
|
+
...normalizeParams(params),
|
|
3060
|
+
length
|
|
3061
|
+
});
|
|
3062
|
+
}
|
|
3063
|
+
// @__NO_SIDE_EFFECTS__
|
|
3064
|
+
function _regex(pattern, params) {
|
|
3065
|
+
return new $ZodCheckRegex({
|
|
3066
|
+
check: "string_format",
|
|
3067
|
+
format: "regex",
|
|
3068
|
+
...normalizeParams(params),
|
|
3069
|
+
pattern
|
|
3070
|
+
});
|
|
3071
|
+
}
|
|
3072
|
+
// @__NO_SIDE_EFFECTS__
|
|
3073
|
+
function _lowercase(params) {
|
|
3074
|
+
return new $ZodCheckLowerCase({
|
|
3075
|
+
check: "string_format",
|
|
3076
|
+
format: "lowercase",
|
|
3077
|
+
...normalizeParams(params)
|
|
3078
|
+
});
|
|
3079
|
+
}
|
|
3080
|
+
// @__NO_SIDE_EFFECTS__
|
|
3081
|
+
function _uppercase(params) {
|
|
3082
|
+
return new $ZodCheckUpperCase({
|
|
3083
|
+
check: "string_format",
|
|
3084
|
+
format: "uppercase",
|
|
3085
|
+
...normalizeParams(params)
|
|
3086
|
+
});
|
|
3087
|
+
}
|
|
3088
|
+
// @__NO_SIDE_EFFECTS__
|
|
3089
|
+
function _includes(includes, params) {
|
|
3090
|
+
return new $ZodCheckIncludes({
|
|
3091
|
+
check: "string_format",
|
|
3092
|
+
format: "includes",
|
|
3093
|
+
...normalizeParams(params),
|
|
3094
|
+
includes
|
|
3095
|
+
});
|
|
3096
|
+
}
|
|
3097
|
+
// @__NO_SIDE_EFFECTS__
|
|
3098
|
+
function _startsWith(prefix, params) {
|
|
3099
|
+
return new $ZodCheckStartsWith({
|
|
3100
|
+
check: "string_format",
|
|
3101
|
+
format: "starts_with",
|
|
3102
|
+
...normalizeParams(params),
|
|
3103
|
+
prefix
|
|
3104
|
+
});
|
|
3105
|
+
}
|
|
3106
|
+
// @__NO_SIDE_EFFECTS__
|
|
3107
|
+
function _endsWith(suffix, params) {
|
|
3108
|
+
return new $ZodCheckEndsWith({
|
|
3109
|
+
check: "string_format",
|
|
3110
|
+
format: "ends_with",
|
|
3111
|
+
...normalizeParams(params),
|
|
3112
|
+
suffix
|
|
3113
|
+
});
|
|
3114
|
+
}
|
|
3115
|
+
// @__NO_SIDE_EFFECTS__
|
|
3116
|
+
function _overwrite(tx) {
|
|
3117
|
+
return new $ZodCheckOverwrite({
|
|
3118
|
+
check: "overwrite",
|
|
3119
|
+
tx
|
|
3120
|
+
});
|
|
3121
|
+
}
|
|
3122
|
+
// @__NO_SIDE_EFFECTS__
|
|
3123
|
+
function _normalize(form) {
|
|
3124
|
+
return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
|
|
3125
|
+
}
|
|
3126
|
+
// @__NO_SIDE_EFFECTS__
|
|
3127
|
+
function _trim() {
|
|
3128
|
+
return /* @__PURE__ */ _overwrite((input) => input.trim());
|
|
3129
|
+
}
|
|
3130
|
+
// @__NO_SIDE_EFFECTS__
|
|
3131
|
+
function _toLowerCase() {
|
|
3132
|
+
return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
|
|
3133
|
+
}
|
|
3134
|
+
// @__NO_SIDE_EFFECTS__
|
|
3135
|
+
function _toUpperCase() {
|
|
3136
|
+
return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
|
|
3137
|
+
}
|
|
3138
|
+
// @__NO_SIDE_EFFECTS__
|
|
3139
|
+
function _slugify() {
|
|
3140
|
+
return /* @__PURE__ */ _overwrite((input) => slugify(input));
|
|
3141
|
+
}
|
|
3142
|
+
// @__NO_SIDE_EFFECTS__
|
|
3143
|
+
function _array(Class2, element, params) {
|
|
3144
|
+
return new Class2({
|
|
3145
|
+
type: "array",
|
|
3146
|
+
element,
|
|
3147
|
+
// get element() {
|
|
3148
|
+
// return element;
|
|
3149
|
+
// },
|
|
3150
|
+
...normalizeParams(params)
|
|
3151
|
+
});
|
|
3152
|
+
}
|
|
3153
|
+
// @__NO_SIDE_EFFECTS__
|
|
3154
|
+
function _refine(Class2, fn, _params) {
|
|
3155
|
+
const schema = new Class2({
|
|
3156
|
+
type: "custom",
|
|
3157
|
+
check: "custom",
|
|
3158
|
+
fn,
|
|
3159
|
+
...normalizeParams(_params)
|
|
3160
|
+
});
|
|
3161
|
+
return schema;
|
|
3162
|
+
}
|
|
3163
|
+
// @__NO_SIDE_EFFECTS__
|
|
3164
|
+
function _superRefine(fn, params) {
|
|
3165
|
+
const ch = /* @__PURE__ */ _check((payload) => {
|
|
3166
|
+
payload.addIssue = (issue2) => {
|
|
3167
|
+
if (typeof issue2 === "string") {
|
|
3168
|
+
payload.issues.push(issue(issue2, payload.value, ch._zod.def));
|
|
3169
|
+
} else {
|
|
3170
|
+
const _issue = issue2;
|
|
3171
|
+
if (_issue.fatal)
|
|
3172
|
+
_issue.continue = false;
|
|
3173
|
+
_issue.code ?? (_issue.code = "custom");
|
|
3174
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
3175
|
+
_issue.inst ?? (_issue.inst = ch);
|
|
3176
|
+
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
3177
|
+
payload.issues.push(issue(_issue));
|
|
3178
|
+
}
|
|
3179
|
+
};
|
|
3180
|
+
return fn(payload.value, payload);
|
|
3181
|
+
}, params);
|
|
3182
|
+
return ch;
|
|
3183
|
+
}
|
|
3184
|
+
// @__NO_SIDE_EFFECTS__
|
|
3185
|
+
function _check(fn, params) {
|
|
3186
|
+
const ch = new $ZodCheck({
|
|
3187
|
+
check: "custom",
|
|
3188
|
+
...normalizeParams(params)
|
|
3189
|
+
});
|
|
3190
|
+
ch._zod.check = fn;
|
|
3191
|
+
return ch;
|
|
3192
|
+
}
|
|
3193
|
+
|
|
3194
|
+
// node_modules/zod/v4/core/to-json-schema.js
|
|
3195
|
+
function initializeContext(params) {
|
|
3196
|
+
let target = params?.target ?? "draft-2020-12";
|
|
3197
|
+
if (target === "draft-4")
|
|
3198
|
+
target = "draft-04";
|
|
3199
|
+
if (target === "draft-7")
|
|
3200
|
+
target = "draft-07";
|
|
3201
|
+
return {
|
|
3202
|
+
processors: params.processors ?? {},
|
|
3203
|
+
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
3204
|
+
target,
|
|
3205
|
+
unrepresentable: params?.unrepresentable ?? "throw",
|
|
3206
|
+
override: params?.override ?? (() => {
|
|
3207
|
+
}),
|
|
3208
|
+
io: params?.io ?? "output",
|
|
3209
|
+
counter: 0,
|
|
3210
|
+
seen: /* @__PURE__ */ new Map(),
|
|
3211
|
+
cycles: params?.cycles ?? "ref",
|
|
3212
|
+
reused: params?.reused ?? "inline",
|
|
3213
|
+
external: params?.external ?? void 0
|
|
3214
|
+
};
|
|
3215
|
+
}
|
|
3216
|
+
function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
3217
|
+
var _a3;
|
|
3218
|
+
const def = schema._zod.def;
|
|
3219
|
+
const seen = ctx.seen.get(schema);
|
|
3220
|
+
if (seen) {
|
|
3221
|
+
seen.count++;
|
|
3222
|
+
const isCycle = _params.schemaPath.includes(schema);
|
|
3223
|
+
if (isCycle) {
|
|
3224
|
+
seen.cycle = _params.path;
|
|
3225
|
+
}
|
|
3226
|
+
return seen.schema;
|
|
3227
|
+
}
|
|
3228
|
+
const result = { schema: {}, count: 1, cycle: void 0, path: _params.path };
|
|
3229
|
+
ctx.seen.set(schema, result);
|
|
3230
|
+
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
3231
|
+
if (overrideSchema) {
|
|
3232
|
+
result.schema = overrideSchema;
|
|
3233
|
+
} else {
|
|
3234
|
+
const params = {
|
|
3235
|
+
..._params,
|
|
3236
|
+
schemaPath: [..._params.schemaPath, schema],
|
|
3237
|
+
path: _params.path
|
|
3238
|
+
};
|
|
3239
|
+
if (schema._zod.processJSONSchema) {
|
|
3240
|
+
schema._zod.processJSONSchema(ctx, result.schema, params);
|
|
3241
|
+
} else {
|
|
3242
|
+
const _json = result.schema;
|
|
3243
|
+
const processor = ctx.processors[def.type];
|
|
3244
|
+
if (!processor) {
|
|
3245
|
+
throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
|
|
3246
|
+
}
|
|
3247
|
+
processor(schema, ctx, _json, params);
|
|
3248
|
+
}
|
|
3249
|
+
const parent = schema._zod.parent;
|
|
3250
|
+
if (parent) {
|
|
3251
|
+
if (!result.ref)
|
|
3252
|
+
result.ref = parent;
|
|
3253
|
+
process(parent, ctx, params);
|
|
3254
|
+
ctx.seen.get(parent).isParent = true;
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
const meta2 = ctx.metadataRegistry.get(schema);
|
|
3258
|
+
if (meta2)
|
|
3259
|
+
Object.assign(result.schema, meta2);
|
|
3260
|
+
if (ctx.io === "input" && isTransforming(schema)) {
|
|
3261
|
+
delete result.schema.examples;
|
|
3262
|
+
delete result.schema.default;
|
|
3263
|
+
}
|
|
3264
|
+
if (ctx.io === "input" && "_prefault" in result.schema)
|
|
3265
|
+
(_a3 = result.schema).default ?? (_a3.default = result.schema._prefault);
|
|
3266
|
+
delete result.schema._prefault;
|
|
3267
|
+
const _result = ctx.seen.get(schema);
|
|
3268
|
+
return _result.schema;
|
|
3269
|
+
}
|
|
3270
|
+
function extractDefs(ctx, schema) {
|
|
3271
|
+
const root = ctx.seen.get(schema);
|
|
3272
|
+
if (!root)
|
|
3273
|
+
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
3274
|
+
const idToSchema = /* @__PURE__ */ new Map();
|
|
3275
|
+
for (const entry of ctx.seen.entries()) {
|
|
3276
|
+
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
3277
|
+
if (id) {
|
|
3278
|
+
const existing = idToSchema.get(id);
|
|
3279
|
+
if (existing && existing !== entry[0]) {
|
|
3280
|
+
throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
3281
|
+
}
|
|
3282
|
+
idToSchema.set(id, entry[0]);
|
|
3283
|
+
}
|
|
3284
|
+
}
|
|
3285
|
+
const makeURI = (entry) => {
|
|
3286
|
+
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
3287
|
+
if (ctx.external) {
|
|
3288
|
+
const externalId = ctx.external.registry.get(entry[0])?.id;
|
|
3289
|
+
const uriGenerator = ctx.external.uri ?? ((id2) => id2);
|
|
3290
|
+
if (externalId) {
|
|
3291
|
+
return { ref: uriGenerator(externalId) };
|
|
3292
|
+
}
|
|
3293
|
+
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
3294
|
+
entry[1].defId = id;
|
|
3295
|
+
return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
|
|
3296
|
+
}
|
|
3297
|
+
if (entry[1] === root) {
|
|
3298
|
+
return { ref: "#" };
|
|
3299
|
+
}
|
|
3300
|
+
const uriPrefix = `#`;
|
|
3301
|
+
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
|
3302
|
+
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
3303
|
+
return { defId, ref: defUriPrefix + defId };
|
|
3304
|
+
};
|
|
3305
|
+
const extractToDef = (entry) => {
|
|
3306
|
+
if (entry[1].schema.$ref) {
|
|
3307
|
+
return;
|
|
3308
|
+
}
|
|
3309
|
+
const seen = entry[1];
|
|
3310
|
+
const { ref, defId } = makeURI(entry);
|
|
3311
|
+
seen.def = { ...seen.schema };
|
|
3312
|
+
if (defId)
|
|
3313
|
+
seen.defId = defId;
|
|
3314
|
+
const schema2 = seen.schema;
|
|
3315
|
+
for (const key in schema2) {
|
|
3316
|
+
delete schema2[key];
|
|
3317
|
+
}
|
|
3318
|
+
schema2.$ref = ref;
|
|
3319
|
+
};
|
|
3320
|
+
if (ctx.cycles === "throw") {
|
|
3321
|
+
for (const entry of ctx.seen.entries()) {
|
|
3322
|
+
const seen = entry[1];
|
|
3323
|
+
if (seen.cycle) {
|
|
3324
|
+
throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
|
|
3325
|
+
|
|
3326
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3329
|
+
}
|
|
3330
|
+
for (const entry of ctx.seen.entries()) {
|
|
3331
|
+
const seen = entry[1];
|
|
3332
|
+
if (schema === entry[0]) {
|
|
3333
|
+
extractToDef(entry);
|
|
3334
|
+
continue;
|
|
3335
|
+
}
|
|
3336
|
+
if (ctx.external) {
|
|
3337
|
+
const ext = ctx.external.registry.get(entry[0])?.id;
|
|
3338
|
+
if (schema !== entry[0] && ext) {
|
|
3339
|
+
extractToDef(entry);
|
|
3340
|
+
continue;
|
|
3341
|
+
}
|
|
3342
|
+
}
|
|
3343
|
+
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
3344
|
+
if (id) {
|
|
3345
|
+
extractToDef(entry);
|
|
3346
|
+
continue;
|
|
3347
|
+
}
|
|
3348
|
+
if (seen.cycle) {
|
|
3349
|
+
extractToDef(entry);
|
|
3350
|
+
continue;
|
|
3351
|
+
}
|
|
3352
|
+
if (seen.count > 1) {
|
|
3353
|
+
if (ctx.reused === "ref") {
|
|
3354
|
+
extractToDef(entry);
|
|
3355
|
+
continue;
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
}
|
|
3359
|
+
}
|
|
3360
|
+
function finalize(ctx, schema) {
|
|
3361
|
+
const root = ctx.seen.get(schema);
|
|
3362
|
+
if (!root)
|
|
3363
|
+
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
3364
|
+
const flattenRef = (zodSchema) => {
|
|
3365
|
+
const seen = ctx.seen.get(zodSchema);
|
|
3366
|
+
if (seen.ref === null)
|
|
3367
|
+
return;
|
|
3368
|
+
const schema2 = seen.def ?? seen.schema;
|
|
3369
|
+
const _cached = { ...schema2 };
|
|
3370
|
+
const ref = seen.ref;
|
|
3371
|
+
seen.ref = null;
|
|
3372
|
+
if (ref) {
|
|
3373
|
+
flattenRef(ref);
|
|
3374
|
+
const refSeen = ctx.seen.get(ref);
|
|
3375
|
+
const refSchema = refSeen.schema;
|
|
3376
|
+
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
3377
|
+
schema2.allOf = schema2.allOf ?? [];
|
|
3378
|
+
schema2.allOf.push(refSchema);
|
|
3379
|
+
} else {
|
|
3380
|
+
Object.assign(schema2, refSchema);
|
|
3381
|
+
}
|
|
3382
|
+
Object.assign(schema2, _cached);
|
|
3383
|
+
const isParentRef = zodSchema._zod.parent === ref;
|
|
3384
|
+
if (isParentRef) {
|
|
3385
|
+
for (const key in schema2) {
|
|
3386
|
+
if (key === "$ref" || key === "allOf")
|
|
3387
|
+
continue;
|
|
3388
|
+
if (!(key in _cached)) {
|
|
3389
|
+
delete schema2[key];
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
if (refSchema.$ref && refSeen.def) {
|
|
3394
|
+
for (const key in schema2) {
|
|
3395
|
+
if (key === "$ref" || key === "allOf")
|
|
3396
|
+
continue;
|
|
3397
|
+
if (key in refSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(refSeen.def[key])) {
|
|
3398
|
+
delete schema2[key];
|
|
3399
|
+
}
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
const parent = zodSchema._zod.parent;
|
|
3404
|
+
if (parent && parent !== ref) {
|
|
3405
|
+
flattenRef(parent);
|
|
3406
|
+
const parentSeen = ctx.seen.get(parent);
|
|
3407
|
+
if (parentSeen?.schema.$ref) {
|
|
3408
|
+
schema2.$ref = parentSeen.schema.$ref;
|
|
3409
|
+
if (parentSeen.def) {
|
|
3410
|
+
for (const key in schema2) {
|
|
3411
|
+
if (key === "$ref" || key === "allOf")
|
|
3412
|
+
continue;
|
|
3413
|
+
if (key in parentSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(parentSeen.def[key])) {
|
|
3414
|
+
delete schema2[key];
|
|
3415
|
+
}
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3419
|
+
}
|
|
3420
|
+
ctx.override({
|
|
3421
|
+
zodSchema,
|
|
3422
|
+
jsonSchema: schema2,
|
|
3423
|
+
path: seen.path ?? []
|
|
3424
|
+
});
|
|
3425
|
+
};
|
|
3426
|
+
for (const entry of [...ctx.seen.entries()].reverse()) {
|
|
3427
|
+
flattenRef(entry[0]);
|
|
3428
|
+
}
|
|
3429
|
+
const result = {};
|
|
3430
|
+
if (ctx.target === "draft-2020-12") {
|
|
3431
|
+
result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
3432
|
+
} else if (ctx.target === "draft-07") {
|
|
3433
|
+
result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
3434
|
+
} else if (ctx.target === "draft-04") {
|
|
3435
|
+
result.$schema = "http://json-schema.org/draft-04/schema#";
|
|
3436
|
+
} else if (ctx.target === "openapi-3.0") {
|
|
3437
|
+
} else {
|
|
3438
|
+
}
|
|
3439
|
+
if (ctx.external?.uri) {
|
|
3440
|
+
const id = ctx.external.registry.get(schema)?.id;
|
|
3441
|
+
if (!id)
|
|
3442
|
+
throw new Error("Schema is missing an `id` property");
|
|
3443
|
+
result.$id = ctx.external.uri(id);
|
|
3444
|
+
}
|
|
3445
|
+
Object.assign(result, root.def ?? root.schema);
|
|
3446
|
+
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
3447
|
+
if (rootMetaId !== void 0 && result.id === rootMetaId)
|
|
3448
|
+
delete result.id;
|
|
3449
|
+
const defs = ctx.external?.defs ?? {};
|
|
3450
|
+
for (const entry of ctx.seen.entries()) {
|
|
3451
|
+
const seen = entry[1];
|
|
3452
|
+
if (seen.def && seen.defId) {
|
|
3453
|
+
if (seen.def.id === seen.defId)
|
|
3454
|
+
delete seen.def.id;
|
|
3455
|
+
defs[seen.defId] = seen.def;
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3458
|
+
if (ctx.external) {
|
|
3459
|
+
} else {
|
|
3460
|
+
if (Object.keys(defs).length > 0) {
|
|
3461
|
+
if (ctx.target === "draft-2020-12") {
|
|
3462
|
+
result.$defs = defs;
|
|
3463
|
+
} else {
|
|
3464
|
+
result.definitions = defs;
|
|
3465
|
+
}
|
|
3466
|
+
}
|
|
3467
|
+
}
|
|
3468
|
+
try {
|
|
3469
|
+
const finalized = JSON.parse(JSON.stringify(result));
|
|
3470
|
+
Object.defineProperty(finalized, "~standard", {
|
|
3471
|
+
value: {
|
|
3472
|
+
...schema["~standard"],
|
|
3473
|
+
jsonSchema: {
|
|
3474
|
+
input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
|
|
3475
|
+
output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
|
|
3476
|
+
}
|
|
3477
|
+
},
|
|
3478
|
+
enumerable: false,
|
|
3479
|
+
writable: false
|
|
3480
|
+
});
|
|
3481
|
+
return finalized;
|
|
3482
|
+
} catch (_err) {
|
|
3483
|
+
throw new Error("Error converting schema to JSON.");
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
function isTransforming(_schema, _ctx) {
|
|
3487
|
+
const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
|
|
3488
|
+
if (ctx.seen.has(_schema))
|
|
3489
|
+
return false;
|
|
3490
|
+
ctx.seen.add(_schema);
|
|
3491
|
+
const def = _schema._zod.def;
|
|
3492
|
+
if (def.type === "transform")
|
|
3493
|
+
return true;
|
|
3494
|
+
if (def.type === "array")
|
|
3495
|
+
return isTransforming(def.element, ctx);
|
|
3496
|
+
if (def.type === "set")
|
|
3497
|
+
return isTransforming(def.valueType, ctx);
|
|
3498
|
+
if (def.type === "lazy")
|
|
3499
|
+
return isTransforming(def.getter(), ctx);
|
|
3500
|
+
if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") {
|
|
3501
|
+
return isTransforming(def.innerType, ctx);
|
|
3502
|
+
}
|
|
3503
|
+
if (def.type === "intersection") {
|
|
3504
|
+
return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
|
3505
|
+
}
|
|
3506
|
+
if (def.type === "record" || def.type === "map") {
|
|
3507
|
+
return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
3508
|
+
}
|
|
3509
|
+
if (def.type === "pipe") {
|
|
3510
|
+
if (_schema._zod.traits.has("$ZodCodec"))
|
|
3511
|
+
return true;
|
|
3512
|
+
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
3513
|
+
}
|
|
3514
|
+
if (def.type === "object") {
|
|
3515
|
+
for (const key in def.shape) {
|
|
3516
|
+
if (isTransforming(def.shape[key], ctx))
|
|
3517
|
+
return true;
|
|
3518
|
+
}
|
|
3519
|
+
return false;
|
|
3520
|
+
}
|
|
3521
|
+
if (def.type === "union") {
|
|
3522
|
+
for (const option of def.options) {
|
|
3523
|
+
if (isTransforming(option, ctx))
|
|
3524
|
+
return true;
|
|
3525
|
+
}
|
|
3526
|
+
return false;
|
|
3527
|
+
}
|
|
3528
|
+
if (def.type === "tuple") {
|
|
3529
|
+
for (const item of def.items) {
|
|
3530
|
+
if (isTransforming(item, ctx))
|
|
3531
|
+
return true;
|
|
3532
|
+
}
|
|
3533
|
+
if (def.rest && isTransforming(def.rest, ctx))
|
|
3534
|
+
return true;
|
|
3535
|
+
return false;
|
|
3536
|
+
}
|
|
3537
|
+
return false;
|
|
3538
|
+
}
|
|
3539
|
+
var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
3540
|
+
const ctx = initializeContext({ ...params, processors });
|
|
3541
|
+
process(schema, ctx);
|
|
3542
|
+
extractDefs(ctx, schema);
|
|
3543
|
+
return finalize(ctx, schema);
|
|
3544
|
+
};
|
|
3545
|
+
var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
3546
|
+
const { libraryOptions, target } = params ?? {};
|
|
3547
|
+
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
3548
|
+
process(schema, ctx);
|
|
3549
|
+
extractDefs(ctx, schema);
|
|
3550
|
+
return finalize(ctx, schema);
|
|
3551
|
+
};
|
|
3552
|
+
|
|
3553
|
+
// node_modules/zod/v4/core/json-schema-processors.js
|
|
3554
|
+
var formatMap = {
|
|
3555
|
+
guid: "uuid",
|
|
3556
|
+
url: "uri",
|
|
3557
|
+
datetime: "date-time",
|
|
3558
|
+
json_string: "json-string",
|
|
3559
|
+
regex: ""
|
|
3560
|
+
// do not set
|
|
3561
|
+
};
|
|
3562
|
+
var stringProcessor = (schema, ctx, _json, _params) => {
|
|
3563
|
+
const json = _json;
|
|
3564
|
+
json.type = "string";
|
|
3565
|
+
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
|
|
3566
|
+
if (typeof minimum === "number")
|
|
3567
|
+
json.minLength = minimum;
|
|
3568
|
+
if (typeof maximum === "number")
|
|
3569
|
+
json.maxLength = maximum;
|
|
3570
|
+
if (format) {
|
|
3571
|
+
json.format = formatMap[format] ?? format;
|
|
3572
|
+
if (json.format === "")
|
|
3573
|
+
delete json.format;
|
|
3574
|
+
if (format === "time") {
|
|
3575
|
+
delete json.format;
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
if (contentEncoding)
|
|
3579
|
+
json.contentEncoding = contentEncoding;
|
|
3580
|
+
if (patterns && patterns.size > 0) {
|
|
3581
|
+
const regexes = [...patterns];
|
|
3582
|
+
if (regexes.length === 1)
|
|
3583
|
+
json.pattern = regexes[0].source;
|
|
3584
|
+
else if (regexes.length > 1) {
|
|
3585
|
+
json.allOf = [
|
|
3586
|
+
...regexes.map((regex) => ({
|
|
3587
|
+
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
3588
|
+
pattern: regex.source
|
|
3589
|
+
}))
|
|
3590
|
+
];
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
};
|
|
3594
|
+
var numberProcessor = (schema, ctx, _json, _params) => {
|
|
3595
|
+
const json = _json;
|
|
3596
|
+
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
3597
|
+
if (typeof format === "string" && format.includes("int"))
|
|
3598
|
+
json.type = "integer";
|
|
3599
|
+
else
|
|
3600
|
+
json.type = "number";
|
|
3601
|
+
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
3602
|
+
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
3603
|
+
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
3604
|
+
if (exMin) {
|
|
3605
|
+
if (legacy) {
|
|
3606
|
+
json.minimum = exclusiveMinimum;
|
|
3607
|
+
json.exclusiveMinimum = true;
|
|
3608
|
+
} else {
|
|
3609
|
+
json.exclusiveMinimum = exclusiveMinimum;
|
|
3610
|
+
}
|
|
3611
|
+
} else if (typeof minimum === "number") {
|
|
3612
|
+
json.minimum = minimum;
|
|
3613
|
+
}
|
|
3614
|
+
if (exMax) {
|
|
3615
|
+
if (legacy) {
|
|
3616
|
+
json.maximum = exclusiveMaximum;
|
|
3617
|
+
json.exclusiveMaximum = true;
|
|
3618
|
+
} else {
|
|
3619
|
+
json.exclusiveMaximum = exclusiveMaximum;
|
|
3620
|
+
}
|
|
3621
|
+
} else if (typeof maximum === "number") {
|
|
3622
|
+
json.maximum = maximum;
|
|
3623
|
+
}
|
|
3624
|
+
if (typeof multipleOf === "number")
|
|
3625
|
+
json.multipleOf = multipleOf;
|
|
3626
|
+
};
|
|
3627
|
+
var neverProcessor = (_schema, _ctx, json, _params) => {
|
|
3628
|
+
json.not = {};
|
|
3629
|
+
};
|
|
3630
|
+
var unknownProcessor = (_schema, _ctx, _json, _params) => {
|
|
3631
|
+
};
|
|
3632
|
+
var enumProcessor = (schema, _ctx, json, _params) => {
|
|
3633
|
+
const def = schema._zod.def;
|
|
3634
|
+
const values = getEnumValues(def.entries);
|
|
3635
|
+
if (values.every((v) => typeof v === "number"))
|
|
3636
|
+
json.type = "number";
|
|
3637
|
+
if (values.every((v) => typeof v === "string"))
|
|
3638
|
+
json.type = "string";
|
|
3639
|
+
json.enum = values;
|
|
3640
|
+
};
|
|
3641
|
+
var customProcessor = (_schema, ctx, _json, _params) => {
|
|
3642
|
+
if (ctx.unrepresentable === "throw") {
|
|
3643
|
+
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
3644
|
+
}
|
|
3645
|
+
};
|
|
3646
|
+
var transformProcessor = (_schema, ctx, _json, _params) => {
|
|
3647
|
+
if (ctx.unrepresentable === "throw") {
|
|
3648
|
+
throw new Error("Transforms cannot be represented in JSON Schema");
|
|
3649
|
+
}
|
|
3650
|
+
};
|
|
3651
|
+
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
3652
|
+
const json = _json;
|
|
3653
|
+
const def = schema._zod.def;
|
|
3654
|
+
const { minimum, maximum } = schema._zod.bag;
|
|
3655
|
+
if (typeof minimum === "number")
|
|
3656
|
+
json.minItems = minimum;
|
|
3657
|
+
if (typeof maximum === "number")
|
|
3658
|
+
json.maxItems = maximum;
|
|
3659
|
+
json.type = "array";
|
|
3660
|
+
json.items = process(def.element, ctx, {
|
|
3661
|
+
...params,
|
|
3662
|
+
path: [...params.path, "items"]
|
|
3663
|
+
});
|
|
3664
|
+
};
|
|
3665
|
+
var objectProcessor = (schema, ctx, _json, params) => {
|
|
3666
|
+
const json = _json;
|
|
3667
|
+
const def = schema._zod.def;
|
|
3668
|
+
json.type = "object";
|
|
3669
|
+
json.properties = {};
|
|
3670
|
+
const shape = def.shape;
|
|
3671
|
+
for (const key in shape) {
|
|
3672
|
+
json.properties[key] = process(shape[key], ctx, {
|
|
3673
|
+
...params,
|
|
3674
|
+
path: [...params.path, "properties", key]
|
|
3675
|
+
});
|
|
3676
|
+
}
|
|
3677
|
+
const allKeys = new Set(Object.keys(shape));
|
|
3678
|
+
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
3679
|
+
const v = def.shape[key]._zod;
|
|
3680
|
+
if (ctx.io === "input") {
|
|
3681
|
+
return v.optin === void 0;
|
|
3682
|
+
} else {
|
|
3683
|
+
return v.optout === void 0;
|
|
3684
|
+
}
|
|
3685
|
+
}));
|
|
3686
|
+
if (requiredKeys.size > 0) {
|
|
3687
|
+
json.required = Array.from(requiredKeys);
|
|
3688
|
+
}
|
|
3689
|
+
if (def.catchall?._zod.def.type === "never") {
|
|
3690
|
+
json.additionalProperties = false;
|
|
3691
|
+
} else if (!def.catchall) {
|
|
3692
|
+
if (ctx.io === "output")
|
|
3693
|
+
json.additionalProperties = false;
|
|
3694
|
+
} else if (def.catchall) {
|
|
3695
|
+
json.additionalProperties = process(def.catchall, ctx, {
|
|
3696
|
+
...params,
|
|
3697
|
+
path: [...params.path, "additionalProperties"]
|
|
3698
|
+
});
|
|
3699
|
+
}
|
|
3700
|
+
};
|
|
3701
|
+
var unionProcessor = (schema, ctx, json, params) => {
|
|
3702
|
+
const def = schema._zod.def;
|
|
3703
|
+
const isExclusive = def.inclusive === false;
|
|
3704
|
+
const options = def.options.map((x, i) => process(x, ctx, {
|
|
3705
|
+
...params,
|
|
3706
|
+
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
3707
|
+
}));
|
|
3708
|
+
if (isExclusive) {
|
|
3709
|
+
json.oneOf = options;
|
|
3710
|
+
} else {
|
|
3711
|
+
json.anyOf = options;
|
|
3712
|
+
}
|
|
3713
|
+
};
|
|
3714
|
+
var intersectionProcessor = (schema, ctx, json, params) => {
|
|
3715
|
+
const def = schema._zod.def;
|
|
3716
|
+
const a = process(def.left, ctx, {
|
|
3717
|
+
...params,
|
|
3718
|
+
path: [...params.path, "allOf", 0]
|
|
3719
|
+
});
|
|
3720
|
+
const b = process(def.right, ctx, {
|
|
3721
|
+
...params,
|
|
3722
|
+
path: [...params.path, "allOf", 1]
|
|
3723
|
+
});
|
|
3724
|
+
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
3725
|
+
const allOf = [
|
|
3726
|
+
...isSimpleIntersection(a) ? a.allOf : [a],
|
|
3727
|
+
...isSimpleIntersection(b) ? b.allOf : [b]
|
|
3728
|
+
];
|
|
3729
|
+
json.allOf = allOf;
|
|
3730
|
+
};
|
|
3731
|
+
var nullableProcessor = (schema, ctx, json, params) => {
|
|
3732
|
+
const def = schema._zod.def;
|
|
3733
|
+
const inner = process(def.innerType, ctx, params);
|
|
3734
|
+
const seen = ctx.seen.get(schema);
|
|
3735
|
+
if (ctx.target === "openapi-3.0") {
|
|
3736
|
+
seen.ref = def.innerType;
|
|
3737
|
+
json.nullable = true;
|
|
3738
|
+
} else {
|
|
3739
|
+
json.anyOf = [inner, { type: "null" }];
|
|
3740
|
+
}
|
|
3741
|
+
};
|
|
3742
|
+
var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
3743
|
+
const def = schema._zod.def;
|
|
3744
|
+
process(def.innerType, ctx, params);
|
|
3745
|
+
const seen = ctx.seen.get(schema);
|
|
3746
|
+
seen.ref = def.innerType;
|
|
3747
|
+
};
|
|
3748
|
+
var defaultProcessor = (schema, ctx, json, params) => {
|
|
3749
|
+
const def = schema._zod.def;
|
|
3750
|
+
process(def.innerType, ctx, params);
|
|
3751
|
+
const seen = ctx.seen.get(schema);
|
|
3752
|
+
seen.ref = def.innerType;
|
|
3753
|
+
json.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
3754
|
+
};
|
|
3755
|
+
var prefaultProcessor = (schema, ctx, json, params) => {
|
|
3756
|
+
const def = schema._zod.def;
|
|
3757
|
+
process(def.innerType, ctx, params);
|
|
3758
|
+
const seen = ctx.seen.get(schema);
|
|
3759
|
+
seen.ref = def.innerType;
|
|
3760
|
+
if (ctx.io === "input")
|
|
3761
|
+
json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
3762
|
+
};
|
|
3763
|
+
var catchProcessor = (schema, ctx, json, params) => {
|
|
3764
|
+
const def = schema._zod.def;
|
|
3765
|
+
process(def.innerType, ctx, params);
|
|
3766
|
+
const seen = ctx.seen.get(schema);
|
|
3767
|
+
seen.ref = def.innerType;
|
|
3768
|
+
let catchValue;
|
|
3769
|
+
try {
|
|
3770
|
+
catchValue = def.catchValue(void 0);
|
|
3771
|
+
} catch {
|
|
3772
|
+
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
3773
|
+
}
|
|
3774
|
+
json.default = catchValue;
|
|
3775
|
+
};
|
|
3776
|
+
var pipeProcessor = (schema, ctx, _json, params) => {
|
|
3777
|
+
const def = schema._zod.def;
|
|
3778
|
+
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
3779
|
+
const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
|
|
3780
|
+
process(innerType, ctx, params);
|
|
3781
|
+
const seen = ctx.seen.get(schema);
|
|
3782
|
+
seen.ref = innerType;
|
|
3783
|
+
};
|
|
3784
|
+
var readonlyProcessor = (schema, ctx, json, params) => {
|
|
3785
|
+
const def = schema._zod.def;
|
|
3786
|
+
process(def.innerType, ctx, params);
|
|
3787
|
+
const seen = ctx.seen.get(schema);
|
|
3788
|
+
seen.ref = def.innerType;
|
|
3789
|
+
json.readOnly = true;
|
|
3790
|
+
};
|
|
3791
|
+
var optionalProcessor = (schema, ctx, _json, params) => {
|
|
3792
|
+
const def = schema._zod.def;
|
|
3793
|
+
process(def.innerType, ctx, params);
|
|
3794
|
+
const seen = ctx.seen.get(schema);
|
|
3795
|
+
seen.ref = def.innerType;
|
|
3796
|
+
};
|
|
3797
|
+
|
|
3798
|
+
// node_modules/zod/v4/classic/iso.js
|
|
3799
|
+
var ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
|
|
3800
|
+
$ZodISODateTime.init(inst, def);
|
|
3801
|
+
ZodStringFormat.init(inst, def);
|
|
3802
|
+
});
|
|
3803
|
+
function datetime2(params) {
|
|
3804
|
+
return _isoDateTime(ZodISODateTime, params);
|
|
3805
|
+
}
|
|
3806
|
+
var ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
|
|
3807
|
+
$ZodISODate.init(inst, def);
|
|
3808
|
+
ZodStringFormat.init(inst, def);
|
|
3809
|
+
});
|
|
3810
|
+
function date2(params) {
|
|
3811
|
+
return _isoDate(ZodISODate, params);
|
|
3812
|
+
}
|
|
3813
|
+
var ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
|
|
3814
|
+
$ZodISOTime.init(inst, def);
|
|
3815
|
+
ZodStringFormat.init(inst, def);
|
|
3816
|
+
});
|
|
3817
|
+
function time2(params) {
|
|
3818
|
+
return _isoTime(ZodISOTime, params);
|
|
3819
|
+
}
|
|
3820
|
+
var ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
|
|
3821
|
+
$ZodISODuration.init(inst, def);
|
|
3822
|
+
ZodStringFormat.init(inst, def);
|
|
3823
|
+
});
|
|
3824
|
+
function duration2(params) {
|
|
3825
|
+
return _isoDuration(ZodISODuration, params);
|
|
3826
|
+
}
|
|
3827
|
+
|
|
3828
|
+
// node_modules/zod/v4/classic/errors.js
|
|
3829
|
+
var initializer2 = (inst, issues) => {
|
|
3830
|
+
$ZodError.init(inst, issues);
|
|
3831
|
+
inst.name = "ZodError";
|
|
3832
|
+
Object.defineProperties(inst, {
|
|
3833
|
+
format: {
|
|
3834
|
+
value: (mapper) => formatError(inst, mapper)
|
|
3835
|
+
// enumerable: false,
|
|
3836
|
+
},
|
|
3837
|
+
flatten: {
|
|
3838
|
+
value: (mapper) => flattenError(inst, mapper)
|
|
3839
|
+
// enumerable: false,
|
|
3840
|
+
},
|
|
3841
|
+
addIssue: {
|
|
3842
|
+
value: (issue2) => {
|
|
3843
|
+
inst.issues.push(issue2);
|
|
3844
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
3845
|
+
}
|
|
3846
|
+
// enumerable: false,
|
|
3847
|
+
},
|
|
3848
|
+
addIssues: {
|
|
3849
|
+
value: (issues2) => {
|
|
3850
|
+
inst.issues.push(...issues2);
|
|
3851
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
3852
|
+
}
|
|
3853
|
+
// enumerable: false,
|
|
3854
|
+
},
|
|
3855
|
+
isEmpty: {
|
|
3856
|
+
get() {
|
|
3857
|
+
return inst.issues.length === 0;
|
|
3858
|
+
}
|
|
3859
|
+
// enumerable: false,
|
|
3860
|
+
}
|
|
3861
|
+
});
|
|
3862
|
+
};
|
|
3863
|
+
var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, {
|
|
3864
|
+
Parent: Error
|
|
3865
|
+
});
|
|
3866
|
+
|
|
3867
|
+
// node_modules/zod/v4/classic/parse.js
|
|
3868
|
+
var parse2 = /* @__PURE__ */ _parse(ZodRealError);
|
|
3869
|
+
var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
3870
|
+
var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
3871
|
+
var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
3872
|
+
var encode = /* @__PURE__ */ _encode(ZodRealError);
|
|
3873
|
+
var decode = /* @__PURE__ */ _decode(ZodRealError);
|
|
3874
|
+
var encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
|
|
3875
|
+
var decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
|
|
3876
|
+
var safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
|
|
3877
|
+
var safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
|
|
3878
|
+
var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
3879
|
+
var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
3880
|
+
|
|
3881
|
+
// node_modules/zod/v4/classic/schemas.js
|
|
3882
|
+
var _installedGroups = /* @__PURE__ */ new WeakMap();
|
|
3883
|
+
function _installLazyMethods(inst, group, methods) {
|
|
3884
|
+
const proto = Object.getPrototypeOf(inst);
|
|
3885
|
+
let installed = _installedGroups.get(proto);
|
|
3886
|
+
if (!installed) {
|
|
3887
|
+
installed = /* @__PURE__ */ new Set();
|
|
3888
|
+
_installedGroups.set(proto, installed);
|
|
3889
|
+
}
|
|
3890
|
+
if (installed.has(group))
|
|
3891
|
+
return;
|
|
3892
|
+
installed.add(group);
|
|
3893
|
+
for (const key in methods) {
|
|
3894
|
+
const fn = methods[key];
|
|
3895
|
+
Object.defineProperty(proto, key, {
|
|
3896
|
+
configurable: true,
|
|
3897
|
+
enumerable: false,
|
|
3898
|
+
get() {
|
|
3899
|
+
const bound = fn.bind(this);
|
|
3900
|
+
Object.defineProperty(this, key, {
|
|
3901
|
+
configurable: true,
|
|
3902
|
+
writable: true,
|
|
3903
|
+
enumerable: true,
|
|
3904
|
+
value: bound
|
|
3905
|
+
});
|
|
3906
|
+
return bound;
|
|
3907
|
+
},
|
|
3908
|
+
set(v) {
|
|
3909
|
+
Object.defineProperty(this, key, {
|
|
3910
|
+
configurable: true,
|
|
3911
|
+
writable: true,
|
|
3912
|
+
enumerable: true,
|
|
3913
|
+
value: v
|
|
3914
|
+
});
|
|
3915
|
+
}
|
|
3916
|
+
});
|
|
3917
|
+
}
|
|
3918
|
+
}
|
|
3919
|
+
var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
3920
|
+
$ZodType.init(inst, def);
|
|
3921
|
+
Object.assign(inst["~standard"], {
|
|
3922
|
+
jsonSchema: {
|
|
3923
|
+
input: createStandardJSONSchemaMethod(inst, "input"),
|
|
3924
|
+
output: createStandardJSONSchemaMethod(inst, "output")
|
|
3925
|
+
}
|
|
3926
|
+
});
|
|
3927
|
+
inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
|
|
3928
|
+
inst.def = def;
|
|
3929
|
+
inst.type = def.type;
|
|
3930
|
+
Object.defineProperty(inst, "_def", { value: def });
|
|
3931
|
+
inst.parse = (data, params) => parse2(inst, data, params, { callee: inst.parse });
|
|
3932
|
+
inst.safeParse = (data, params) => safeParse2(inst, data, params);
|
|
3933
|
+
inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
|
|
3934
|
+
inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
|
|
3935
|
+
inst.spa = inst.safeParseAsync;
|
|
3936
|
+
inst.encode = (data, params) => encode(inst, data, params);
|
|
3937
|
+
inst.decode = (data, params) => decode(inst, data, params);
|
|
3938
|
+
inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
|
|
3939
|
+
inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
|
|
3940
|
+
inst.safeEncode = (data, params) => safeEncode(inst, data, params);
|
|
3941
|
+
inst.safeDecode = (data, params) => safeDecode(inst, data, params);
|
|
3942
|
+
inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
|
|
3943
|
+
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
|
|
3944
|
+
_installLazyMethods(inst, "ZodType", {
|
|
3945
|
+
check(...chks) {
|
|
3946
|
+
const def2 = this.def;
|
|
3947
|
+
return this.clone(util_exports.mergeDefs(def2, {
|
|
3948
|
+
checks: [
|
|
3949
|
+
...def2.checks ?? [],
|
|
3950
|
+
...chks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
|
|
3951
|
+
]
|
|
3952
|
+
}), { parent: true });
|
|
3953
|
+
},
|
|
3954
|
+
with(...chks) {
|
|
3955
|
+
return this.check(...chks);
|
|
3956
|
+
},
|
|
3957
|
+
clone(def2, params) {
|
|
3958
|
+
return clone(this, def2, params);
|
|
3959
|
+
},
|
|
3960
|
+
brand() {
|
|
3961
|
+
return this;
|
|
3962
|
+
},
|
|
3963
|
+
register(reg, meta2) {
|
|
3964
|
+
reg.add(this, meta2);
|
|
3965
|
+
return this;
|
|
3966
|
+
},
|
|
3967
|
+
refine(check, params) {
|
|
3968
|
+
return this.check(refine(check, params));
|
|
3969
|
+
},
|
|
3970
|
+
superRefine(refinement, params) {
|
|
3971
|
+
return this.check(superRefine(refinement, params));
|
|
3972
|
+
},
|
|
3973
|
+
overwrite(fn) {
|
|
3974
|
+
return this.check(_overwrite(fn));
|
|
3975
|
+
},
|
|
3976
|
+
optional() {
|
|
3977
|
+
return optional(this);
|
|
3978
|
+
},
|
|
3979
|
+
exactOptional() {
|
|
3980
|
+
return exactOptional(this);
|
|
3981
|
+
},
|
|
3982
|
+
nullable() {
|
|
3983
|
+
return nullable(this);
|
|
3984
|
+
},
|
|
3985
|
+
nullish() {
|
|
3986
|
+
return optional(nullable(this));
|
|
3987
|
+
},
|
|
3988
|
+
nonoptional(params) {
|
|
3989
|
+
return nonoptional(this, params);
|
|
3990
|
+
},
|
|
3991
|
+
array() {
|
|
3992
|
+
return array(this);
|
|
3993
|
+
},
|
|
3994
|
+
or(arg) {
|
|
3995
|
+
return union([this, arg]);
|
|
3996
|
+
},
|
|
3997
|
+
and(arg) {
|
|
3998
|
+
return intersection(this, arg);
|
|
3999
|
+
},
|
|
4000
|
+
transform(tx) {
|
|
4001
|
+
return pipe(this, transform(tx));
|
|
4002
|
+
},
|
|
4003
|
+
default(d) {
|
|
4004
|
+
return _default(this, d);
|
|
4005
|
+
},
|
|
4006
|
+
prefault(d) {
|
|
4007
|
+
return prefault(this, d);
|
|
4008
|
+
},
|
|
4009
|
+
catch(params) {
|
|
4010
|
+
return _catch(this, params);
|
|
4011
|
+
},
|
|
4012
|
+
pipe(target) {
|
|
4013
|
+
return pipe(this, target);
|
|
4014
|
+
},
|
|
4015
|
+
readonly() {
|
|
4016
|
+
return readonly(this);
|
|
4017
|
+
},
|
|
4018
|
+
describe(description) {
|
|
4019
|
+
const cl = this.clone();
|
|
4020
|
+
globalRegistry.add(cl, { description });
|
|
4021
|
+
return cl;
|
|
4022
|
+
},
|
|
4023
|
+
meta(...args) {
|
|
4024
|
+
if (args.length === 0)
|
|
4025
|
+
return globalRegistry.get(this);
|
|
4026
|
+
const cl = this.clone();
|
|
4027
|
+
globalRegistry.add(cl, args[0]);
|
|
4028
|
+
return cl;
|
|
4029
|
+
},
|
|
4030
|
+
isOptional() {
|
|
4031
|
+
return this.safeParse(void 0).success;
|
|
4032
|
+
},
|
|
4033
|
+
isNullable() {
|
|
4034
|
+
return this.safeParse(null).success;
|
|
4035
|
+
},
|
|
4036
|
+
apply(fn) {
|
|
4037
|
+
return fn(this);
|
|
4038
|
+
}
|
|
4039
|
+
});
|
|
4040
|
+
Object.defineProperty(inst, "description", {
|
|
4041
|
+
get() {
|
|
4042
|
+
return globalRegistry.get(inst)?.description;
|
|
4043
|
+
},
|
|
4044
|
+
configurable: true
|
|
4045
|
+
});
|
|
4046
|
+
return inst;
|
|
4047
|
+
});
|
|
4048
|
+
var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
4049
|
+
$ZodString.init(inst, def);
|
|
4050
|
+
ZodType.init(inst, def);
|
|
4051
|
+
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
|
|
4052
|
+
const bag = inst._zod.bag;
|
|
4053
|
+
inst.format = bag.format ?? null;
|
|
4054
|
+
inst.minLength = bag.minimum ?? null;
|
|
4055
|
+
inst.maxLength = bag.maximum ?? null;
|
|
4056
|
+
_installLazyMethods(inst, "_ZodString", {
|
|
4057
|
+
regex(...args) {
|
|
4058
|
+
return this.check(_regex(...args));
|
|
4059
|
+
},
|
|
4060
|
+
includes(...args) {
|
|
4061
|
+
return this.check(_includes(...args));
|
|
4062
|
+
},
|
|
4063
|
+
startsWith(...args) {
|
|
4064
|
+
return this.check(_startsWith(...args));
|
|
4065
|
+
},
|
|
4066
|
+
endsWith(...args) {
|
|
4067
|
+
return this.check(_endsWith(...args));
|
|
4068
|
+
},
|
|
4069
|
+
min(...args) {
|
|
4070
|
+
return this.check(_minLength(...args));
|
|
4071
|
+
},
|
|
4072
|
+
max(...args) {
|
|
4073
|
+
return this.check(_maxLength(...args));
|
|
4074
|
+
},
|
|
4075
|
+
length(...args) {
|
|
4076
|
+
return this.check(_length(...args));
|
|
4077
|
+
},
|
|
4078
|
+
nonempty(...args) {
|
|
4079
|
+
return this.check(_minLength(1, ...args));
|
|
4080
|
+
},
|
|
4081
|
+
lowercase(params) {
|
|
4082
|
+
return this.check(_lowercase(params));
|
|
4083
|
+
},
|
|
4084
|
+
uppercase(params) {
|
|
4085
|
+
return this.check(_uppercase(params));
|
|
4086
|
+
},
|
|
4087
|
+
trim() {
|
|
4088
|
+
return this.check(_trim());
|
|
4089
|
+
},
|
|
4090
|
+
normalize(...args) {
|
|
4091
|
+
return this.check(_normalize(...args));
|
|
4092
|
+
},
|
|
4093
|
+
toLowerCase() {
|
|
4094
|
+
return this.check(_toLowerCase());
|
|
4095
|
+
},
|
|
4096
|
+
toUpperCase() {
|
|
4097
|
+
return this.check(_toUpperCase());
|
|
4098
|
+
},
|
|
4099
|
+
slugify() {
|
|
4100
|
+
return this.check(_slugify());
|
|
4101
|
+
}
|
|
4102
|
+
});
|
|
4103
|
+
});
|
|
4104
|
+
var ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
|
|
4105
|
+
$ZodString.init(inst, def);
|
|
4106
|
+
_ZodString.init(inst, def);
|
|
4107
|
+
inst.email = (params) => inst.check(_email(ZodEmail, params));
|
|
4108
|
+
inst.url = (params) => inst.check(_url(ZodURL, params));
|
|
4109
|
+
inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
|
|
4110
|
+
inst.emoji = (params) => inst.check(_emoji2(ZodEmoji, params));
|
|
4111
|
+
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
4112
|
+
inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
|
|
4113
|
+
inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
|
|
4114
|
+
inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
|
|
4115
|
+
inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
|
|
4116
|
+
inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
|
|
4117
|
+
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
4118
|
+
inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
|
|
4119
|
+
inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
|
|
4120
|
+
inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
|
|
4121
|
+
inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
|
|
4122
|
+
inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
|
|
4123
|
+
inst.xid = (params) => inst.check(_xid(ZodXID, params));
|
|
4124
|
+
inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
|
|
4125
|
+
inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
|
|
4126
|
+
inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
|
|
4127
|
+
inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
|
|
4128
|
+
inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
|
|
4129
|
+
inst.e164 = (params) => inst.check(_e164(ZodE164, params));
|
|
4130
|
+
inst.datetime = (params) => inst.check(datetime2(params));
|
|
4131
|
+
inst.date = (params) => inst.check(date2(params));
|
|
4132
|
+
inst.time = (params) => inst.check(time2(params));
|
|
4133
|
+
inst.duration = (params) => inst.check(duration2(params));
|
|
4134
|
+
});
|
|
4135
|
+
function string2(params) {
|
|
4136
|
+
return _string(ZodString, params);
|
|
4137
|
+
}
|
|
4138
|
+
var ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
|
|
4139
|
+
$ZodStringFormat.init(inst, def);
|
|
4140
|
+
_ZodString.init(inst, def);
|
|
4141
|
+
});
|
|
4142
|
+
var ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (inst, def) => {
|
|
4143
|
+
$ZodEmail.init(inst, def);
|
|
4144
|
+
ZodStringFormat.init(inst, def);
|
|
4145
|
+
});
|
|
4146
|
+
var ZodGUID = /* @__PURE__ */ $constructor("ZodGUID", (inst, def) => {
|
|
4147
|
+
$ZodGUID.init(inst, def);
|
|
4148
|
+
ZodStringFormat.init(inst, def);
|
|
4149
|
+
});
|
|
4150
|
+
var ZodUUID = /* @__PURE__ */ $constructor("ZodUUID", (inst, def) => {
|
|
4151
|
+
$ZodUUID.init(inst, def);
|
|
4152
|
+
ZodStringFormat.init(inst, def);
|
|
4153
|
+
});
|
|
4154
|
+
var ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
|
|
4155
|
+
$ZodURL.init(inst, def);
|
|
4156
|
+
ZodStringFormat.init(inst, def);
|
|
4157
|
+
});
|
|
4158
|
+
var ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
|
|
4159
|
+
$ZodEmoji.init(inst, def);
|
|
4160
|
+
ZodStringFormat.init(inst, def);
|
|
4161
|
+
});
|
|
4162
|
+
var ZodNanoID = /* @__PURE__ */ $constructor("ZodNanoID", (inst, def) => {
|
|
4163
|
+
$ZodNanoID.init(inst, def);
|
|
4164
|
+
ZodStringFormat.init(inst, def);
|
|
4165
|
+
});
|
|
4166
|
+
var ZodCUID = /* @__PURE__ */ $constructor("ZodCUID", (inst, def) => {
|
|
4167
|
+
$ZodCUID.init(inst, def);
|
|
4168
|
+
ZodStringFormat.init(inst, def);
|
|
4169
|
+
});
|
|
4170
|
+
var ZodCUID2 = /* @__PURE__ */ $constructor("ZodCUID2", (inst, def) => {
|
|
4171
|
+
$ZodCUID2.init(inst, def);
|
|
4172
|
+
ZodStringFormat.init(inst, def);
|
|
4173
|
+
});
|
|
4174
|
+
var ZodULID = /* @__PURE__ */ $constructor("ZodULID", (inst, def) => {
|
|
4175
|
+
$ZodULID.init(inst, def);
|
|
4176
|
+
ZodStringFormat.init(inst, def);
|
|
4177
|
+
});
|
|
4178
|
+
var ZodXID = /* @__PURE__ */ $constructor("ZodXID", (inst, def) => {
|
|
4179
|
+
$ZodXID.init(inst, def);
|
|
4180
|
+
ZodStringFormat.init(inst, def);
|
|
4181
|
+
});
|
|
4182
|
+
var ZodKSUID = /* @__PURE__ */ $constructor("ZodKSUID", (inst, def) => {
|
|
4183
|
+
$ZodKSUID.init(inst, def);
|
|
4184
|
+
ZodStringFormat.init(inst, def);
|
|
4185
|
+
});
|
|
4186
|
+
var ZodIPv4 = /* @__PURE__ */ $constructor("ZodIPv4", (inst, def) => {
|
|
4187
|
+
$ZodIPv4.init(inst, def);
|
|
4188
|
+
ZodStringFormat.init(inst, def);
|
|
4189
|
+
});
|
|
4190
|
+
var ZodIPv6 = /* @__PURE__ */ $constructor("ZodIPv6", (inst, def) => {
|
|
4191
|
+
$ZodIPv6.init(inst, def);
|
|
4192
|
+
ZodStringFormat.init(inst, def);
|
|
4193
|
+
});
|
|
4194
|
+
var ZodCIDRv4 = /* @__PURE__ */ $constructor("ZodCIDRv4", (inst, def) => {
|
|
4195
|
+
$ZodCIDRv4.init(inst, def);
|
|
4196
|
+
ZodStringFormat.init(inst, def);
|
|
4197
|
+
});
|
|
4198
|
+
var ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (inst, def) => {
|
|
4199
|
+
$ZodCIDRv6.init(inst, def);
|
|
4200
|
+
ZodStringFormat.init(inst, def);
|
|
4201
|
+
});
|
|
4202
|
+
var ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
|
|
4203
|
+
$ZodBase64.init(inst, def);
|
|
4204
|
+
ZodStringFormat.init(inst, def);
|
|
4205
|
+
});
|
|
4206
|
+
var ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
|
|
4207
|
+
$ZodBase64URL.init(inst, def);
|
|
4208
|
+
ZodStringFormat.init(inst, def);
|
|
4209
|
+
});
|
|
4210
|
+
var ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
|
|
4211
|
+
$ZodE164.init(inst, def);
|
|
4212
|
+
ZodStringFormat.init(inst, def);
|
|
4213
|
+
});
|
|
4214
|
+
var ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
|
|
4215
|
+
$ZodJWT.init(inst, def);
|
|
4216
|
+
ZodStringFormat.init(inst, def);
|
|
4217
|
+
});
|
|
4218
|
+
var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
4219
|
+
$ZodNumber.init(inst, def);
|
|
4220
|
+
ZodType.init(inst, def);
|
|
4221
|
+
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
|
|
4222
|
+
_installLazyMethods(inst, "ZodNumber", {
|
|
4223
|
+
gt(value, params) {
|
|
4224
|
+
return this.check(_gt(value, params));
|
|
4225
|
+
},
|
|
4226
|
+
gte(value, params) {
|
|
4227
|
+
return this.check(_gte(value, params));
|
|
4228
|
+
},
|
|
4229
|
+
min(value, params) {
|
|
4230
|
+
return this.check(_gte(value, params));
|
|
4231
|
+
},
|
|
4232
|
+
lt(value, params) {
|
|
4233
|
+
return this.check(_lt(value, params));
|
|
4234
|
+
},
|
|
4235
|
+
lte(value, params) {
|
|
4236
|
+
return this.check(_lte(value, params));
|
|
4237
|
+
},
|
|
4238
|
+
max(value, params) {
|
|
4239
|
+
return this.check(_lte(value, params));
|
|
4240
|
+
},
|
|
4241
|
+
int(params) {
|
|
4242
|
+
return this.check(int(params));
|
|
4243
|
+
},
|
|
4244
|
+
safe(params) {
|
|
4245
|
+
return this.check(int(params));
|
|
4246
|
+
},
|
|
4247
|
+
positive(params) {
|
|
4248
|
+
return this.check(_gt(0, params));
|
|
4249
|
+
},
|
|
4250
|
+
nonnegative(params) {
|
|
4251
|
+
return this.check(_gte(0, params));
|
|
4252
|
+
},
|
|
4253
|
+
negative(params) {
|
|
4254
|
+
return this.check(_lt(0, params));
|
|
4255
|
+
},
|
|
4256
|
+
nonpositive(params) {
|
|
4257
|
+
return this.check(_lte(0, params));
|
|
4258
|
+
},
|
|
4259
|
+
multipleOf(value, params) {
|
|
4260
|
+
return this.check(_multipleOf(value, params));
|
|
4261
|
+
},
|
|
4262
|
+
step(value, params) {
|
|
4263
|
+
return this.check(_multipleOf(value, params));
|
|
4264
|
+
},
|
|
4265
|
+
finite() {
|
|
4266
|
+
return this;
|
|
4267
|
+
}
|
|
4268
|
+
});
|
|
4269
|
+
const bag = inst._zod.bag;
|
|
4270
|
+
inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
4271
|
+
inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
4272
|
+
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
|
|
4273
|
+
inst.isFinite = true;
|
|
4274
|
+
inst.format = bag.format ?? null;
|
|
4275
|
+
});
|
|
4276
|
+
function number2(params) {
|
|
4277
|
+
return _number(ZodNumber, params);
|
|
4278
|
+
}
|
|
4279
|
+
var ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
|
|
4280
|
+
$ZodNumberFormat.init(inst, def);
|
|
4281
|
+
ZodNumber.init(inst, def);
|
|
4282
|
+
});
|
|
4283
|
+
function int(params) {
|
|
4284
|
+
return _int(ZodNumberFormat, params);
|
|
4285
|
+
}
|
|
4286
|
+
var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
4287
|
+
$ZodUnknown.init(inst, def);
|
|
4288
|
+
ZodType.init(inst, def);
|
|
4289
|
+
inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
|
|
4290
|
+
});
|
|
4291
|
+
function unknown() {
|
|
4292
|
+
return _unknown(ZodUnknown);
|
|
4293
|
+
}
|
|
4294
|
+
var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
4295
|
+
$ZodNever.init(inst, def);
|
|
4296
|
+
ZodType.init(inst, def);
|
|
4297
|
+
inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
|
|
4298
|
+
});
|
|
4299
|
+
function never(params) {
|
|
4300
|
+
return _never(ZodNever, params);
|
|
4301
|
+
}
|
|
4302
|
+
var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
4303
|
+
$ZodArray.init(inst, def);
|
|
4304
|
+
ZodType.init(inst, def);
|
|
4305
|
+
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
4306
|
+
inst.element = def.element;
|
|
4307
|
+
_installLazyMethods(inst, "ZodArray", {
|
|
4308
|
+
min(n, params) {
|
|
4309
|
+
return this.check(_minLength(n, params));
|
|
4310
|
+
},
|
|
4311
|
+
nonempty(params) {
|
|
4312
|
+
return this.check(_minLength(1, params));
|
|
4313
|
+
},
|
|
4314
|
+
max(n, params) {
|
|
4315
|
+
return this.check(_maxLength(n, params));
|
|
4316
|
+
},
|
|
4317
|
+
length(n, params) {
|
|
4318
|
+
return this.check(_length(n, params));
|
|
4319
|
+
},
|
|
4320
|
+
unwrap() {
|
|
4321
|
+
return this.element;
|
|
4322
|
+
}
|
|
4323
|
+
});
|
|
4324
|
+
});
|
|
4325
|
+
function array(element, params) {
|
|
4326
|
+
return _array(ZodArray, element, params);
|
|
4327
|
+
}
|
|
4328
|
+
var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
4329
|
+
$ZodObjectJIT.init(inst, def);
|
|
4330
|
+
ZodType.init(inst, def);
|
|
4331
|
+
inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
|
|
4332
|
+
util_exports.defineLazy(inst, "shape", () => {
|
|
4333
|
+
return def.shape;
|
|
4334
|
+
});
|
|
4335
|
+
_installLazyMethods(inst, "ZodObject", {
|
|
4336
|
+
keyof() {
|
|
4337
|
+
return _enum(Object.keys(this._zod.def.shape));
|
|
4338
|
+
},
|
|
4339
|
+
catchall(catchall) {
|
|
4340
|
+
return this.clone({ ...this._zod.def, catchall });
|
|
4341
|
+
},
|
|
4342
|
+
passthrough() {
|
|
4343
|
+
return this.clone({ ...this._zod.def, catchall: unknown() });
|
|
4344
|
+
},
|
|
4345
|
+
loose() {
|
|
4346
|
+
return this.clone({ ...this._zod.def, catchall: unknown() });
|
|
4347
|
+
},
|
|
4348
|
+
strict() {
|
|
4349
|
+
return this.clone({ ...this._zod.def, catchall: never() });
|
|
4350
|
+
},
|
|
4351
|
+
strip() {
|
|
4352
|
+
return this.clone({ ...this._zod.def, catchall: void 0 });
|
|
4353
|
+
},
|
|
4354
|
+
extend(incoming) {
|
|
4355
|
+
return util_exports.extend(this, incoming);
|
|
4356
|
+
},
|
|
4357
|
+
safeExtend(incoming) {
|
|
4358
|
+
return util_exports.safeExtend(this, incoming);
|
|
4359
|
+
},
|
|
4360
|
+
merge(other) {
|
|
4361
|
+
return util_exports.merge(this, other);
|
|
4362
|
+
},
|
|
4363
|
+
pick(mask) {
|
|
4364
|
+
return util_exports.pick(this, mask);
|
|
4365
|
+
},
|
|
4366
|
+
omit(mask) {
|
|
4367
|
+
return util_exports.omit(this, mask);
|
|
4368
|
+
},
|
|
4369
|
+
partial(...args) {
|
|
4370
|
+
return util_exports.partial(ZodOptional, this, args[0]);
|
|
4371
|
+
},
|
|
4372
|
+
required(...args) {
|
|
4373
|
+
return util_exports.required(ZodNonOptional, this, args[0]);
|
|
4374
|
+
}
|
|
4375
|
+
});
|
|
4376
|
+
});
|
|
4377
|
+
function object(shape, params) {
|
|
4378
|
+
const def = {
|
|
4379
|
+
type: "object",
|
|
4380
|
+
shape: shape ?? {},
|
|
4381
|
+
...util_exports.normalizeParams(params)
|
|
4382
|
+
};
|
|
4383
|
+
return new ZodObject(def);
|
|
4384
|
+
}
|
|
4385
|
+
var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
4386
|
+
$ZodUnion.init(inst, def);
|
|
4387
|
+
ZodType.init(inst, def);
|
|
4388
|
+
inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
|
|
4389
|
+
inst.options = def.options;
|
|
4390
|
+
});
|
|
4391
|
+
function union(options, params) {
|
|
4392
|
+
return new ZodUnion({
|
|
4393
|
+
type: "union",
|
|
4394
|
+
options,
|
|
4395
|
+
...util_exports.normalizeParams(params)
|
|
4396
|
+
});
|
|
4397
|
+
}
|
|
4398
|
+
var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
4399
|
+
$ZodIntersection.init(inst, def);
|
|
4400
|
+
ZodType.init(inst, def);
|
|
4401
|
+
inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
|
|
4402
|
+
});
|
|
4403
|
+
function intersection(left, right) {
|
|
4404
|
+
return new ZodIntersection({
|
|
4405
|
+
type: "intersection",
|
|
4406
|
+
left,
|
|
4407
|
+
right
|
|
4408
|
+
});
|
|
4409
|
+
}
|
|
4410
|
+
var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
4411
|
+
$ZodEnum.init(inst, def);
|
|
4412
|
+
ZodType.init(inst, def);
|
|
4413
|
+
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
|
|
4414
|
+
inst.enum = def.entries;
|
|
4415
|
+
inst.options = Object.values(def.entries);
|
|
4416
|
+
const keys = new Set(Object.keys(def.entries));
|
|
4417
|
+
inst.extract = (values, params) => {
|
|
4418
|
+
const newEntries = {};
|
|
4419
|
+
for (const value of values) {
|
|
4420
|
+
if (keys.has(value)) {
|
|
4421
|
+
newEntries[value] = def.entries[value];
|
|
4422
|
+
} else
|
|
4423
|
+
throw new Error(`Key ${value} not found in enum`);
|
|
4424
|
+
}
|
|
4425
|
+
return new ZodEnum({
|
|
4426
|
+
...def,
|
|
4427
|
+
checks: [],
|
|
4428
|
+
...util_exports.normalizeParams(params),
|
|
4429
|
+
entries: newEntries
|
|
4430
|
+
});
|
|
4431
|
+
};
|
|
4432
|
+
inst.exclude = (values, params) => {
|
|
4433
|
+
const newEntries = { ...def.entries };
|
|
4434
|
+
for (const value of values) {
|
|
4435
|
+
if (keys.has(value)) {
|
|
4436
|
+
delete newEntries[value];
|
|
4437
|
+
} else
|
|
4438
|
+
throw new Error(`Key ${value} not found in enum`);
|
|
4439
|
+
}
|
|
4440
|
+
return new ZodEnum({
|
|
4441
|
+
...def,
|
|
4442
|
+
checks: [],
|
|
4443
|
+
...util_exports.normalizeParams(params),
|
|
4444
|
+
entries: newEntries
|
|
4445
|
+
});
|
|
4446
|
+
};
|
|
4447
|
+
});
|
|
4448
|
+
function _enum(values, params) {
|
|
4449
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
4450
|
+
return new ZodEnum({
|
|
4451
|
+
type: "enum",
|
|
4452
|
+
entries,
|
|
4453
|
+
...util_exports.normalizeParams(params)
|
|
4454
|
+
});
|
|
4455
|
+
}
|
|
4456
|
+
var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
4457
|
+
$ZodTransform.init(inst, def);
|
|
4458
|
+
ZodType.init(inst, def);
|
|
4459
|
+
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
|
|
4460
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
4461
|
+
if (_ctx.direction === "backward") {
|
|
4462
|
+
throw new $ZodEncodeError(inst.constructor.name);
|
|
4463
|
+
}
|
|
4464
|
+
payload.addIssue = (issue2) => {
|
|
4465
|
+
if (typeof issue2 === "string") {
|
|
4466
|
+
payload.issues.push(util_exports.issue(issue2, payload.value, def));
|
|
4467
|
+
} else {
|
|
4468
|
+
const _issue = issue2;
|
|
4469
|
+
if (_issue.fatal)
|
|
4470
|
+
_issue.continue = false;
|
|
4471
|
+
_issue.code ?? (_issue.code = "custom");
|
|
4472
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
4473
|
+
_issue.inst ?? (_issue.inst = inst);
|
|
4474
|
+
payload.issues.push(util_exports.issue(_issue));
|
|
4475
|
+
}
|
|
4476
|
+
};
|
|
4477
|
+
const output = def.transform(payload.value, payload);
|
|
4478
|
+
if (output instanceof Promise) {
|
|
4479
|
+
return output.then((output2) => {
|
|
4480
|
+
payload.value = output2;
|
|
4481
|
+
payload.fallback = true;
|
|
4482
|
+
return payload;
|
|
4483
|
+
});
|
|
4484
|
+
}
|
|
4485
|
+
payload.value = output;
|
|
4486
|
+
payload.fallback = true;
|
|
4487
|
+
return payload;
|
|
4488
|
+
};
|
|
4489
|
+
});
|
|
4490
|
+
function transform(fn) {
|
|
4491
|
+
return new ZodTransform({
|
|
4492
|
+
type: "transform",
|
|
4493
|
+
transform: fn
|
|
4494
|
+
});
|
|
4495
|
+
}
|
|
4496
|
+
var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
4497
|
+
$ZodOptional.init(inst, def);
|
|
4498
|
+
ZodType.init(inst, def);
|
|
4499
|
+
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
4500
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
4501
|
+
});
|
|
4502
|
+
function optional(innerType) {
|
|
4503
|
+
return new ZodOptional({
|
|
4504
|
+
type: "optional",
|
|
4505
|
+
innerType
|
|
4506
|
+
});
|
|
4507
|
+
}
|
|
4508
|
+
var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
4509
|
+
$ZodExactOptional.init(inst, def);
|
|
4510
|
+
ZodType.init(inst, def);
|
|
4511
|
+
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
4512
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
4513
|
+
});
|
|
4514
|
+
function exactOptional(innerType) {
|
|
4515
|
+
return new ZodExactOptional({
|
|
4516
|
+
type: "optional",
|
|
4517
|
+
innerType
|
|
4518
|
+
});
|
|
4519
|
+
}
|
|
4520
|
+
var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
4521
|
+
$ZodNullable.init(inst, def);
|
|
4522
|
+
ZodType.init(inst, def);
|
|
4523
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
|
|
4524
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
4525
|
+
});
|
|
4526
|
+
function nullable(innerType) {
|
|
4527
|
+
return new ZodNullable({
|
|
4528
|
+
type: "nullable",
|
|
4529
|
+
innerType
|
|
4530
|
+
});
|
|
4531
|
+
}
|
|
4532
|
+
var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
4533
|
+
$ZodDefault.init(inst, def);
|
|
4534
|
+
ZodType.init(inst, def);
|
|
4535
|
+
inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
|
|
4536
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
4537
|
+
inst.removeDefault = inst.unwrap;
|
|
4538
|
+
});
|
|
4539
|
+
function _default(innerType, defaultValue) {
|
|
4540
|
+
return new ZodDefault({
|
|
4541
|
+
type: "default",
|
|
4542
|
+
innerType,
|
|
4543
|
+
get defaultValue() {
|
|
4544
|
+
return typeof defaultValue === "function" ? defaultValue() : util_exports.shallowClone(defaultValue);
|
|
4545
|
+
}
|
|
4546
|
+
});
|
|
4547
|
+
}
|
|
4548
|
+
var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
4549
|
+
$ZodPrefault.init(inst, def);
|
|
4550
|
+
ZodType.init(inst, def);
|
|
4551
|
+
inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
|
|
4552
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
4553
|
+
});
|
|
4554
|
+
function prefault(innerType, defaultValue) {
|
|
4555
|
+
return new ZodPrefault({
|
|
4556
|
+
type: "prefault",
|
|
4557
|
+
innerType,
|
|
4558
|
+
get defaultValue() {
|
|
4559
|
+
return typeof defaultValue === "function" ? defaultValue() : util_exports.shallowClone(defaultValue);
|
|
4560
|
+
}
|
|
4561
|
+
});
|
|
4562
|
+
}
|
|
4563
|
+
var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
4564
|
+
$ZodNonOptional.init(inst, def);
|
|
4565
|
+
ZodType.init(inst, def);
|
|
4566
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
|
|
4567
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
4568
|
+
});
|
|
4569
|
+
function nonoptional(innerType, params) {
|
|
4570
|
+
return new ZodNonOptional({
|
|
4571
|
+
type: "nonoptional",
|
|
4572
|
+
innerType,
|
|
4573
|
+
...util_exports.normalizeParams(params)
|
|
4574
|
+
});
|
|
4575
|
+
}
|
|
4576
|
+
var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
4577
|
+
$ZodCatch.init(inst, def);
|
|
4578
|
+
ZodType.init(inst, def);
|
|
4579
|
+
inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
|
|
4580
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
4581
|
+
inst.removeCatch = inst.unwrap;
|
|
4582
|
+
});
|
|
4583
|
+
function _catch(innerType, catchValue) {
|
|
4584
|
+
return new ZodCatch({
|
|
4585
|
+
type: "catch",
|
|
4586
|
+
innerType,
|
|
4587
|
+
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
4588
|
+
});
|
|
4589
|
+
}
|
|
4590
|
+
var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
4591
|
+
$ZodPipe.init(inst, def);
|
|
4592
|
+
ZodType.init(inst, def);
|
|
4593
|
+
inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
|
|
4594
|
+
inst.in = def.in;
|
|
4595
|
+
inst.out = def.out;
|
|
4596
|
+
});
|
|
4597
|
+
function pipe(in_, out) {
|
|
4598
|
+
return new ZodPipe({
|
|
4599
|
+
type: "pipe",
|
|
4600
|
+
in: in_,
|
|
4601
|
+
out
|
|
4602
|
+
// ...util.normalizeParams(params),
|
|
4603
|
+
});
|
|
4604
|
+
}
|
|
4605
|
+
var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
4606
|
+
$ZodReadonly.init(inst, def);
|
|
4607
|
+
ZodType.init(inst, def);
|
|
4608
|
+
inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
|
|
4609
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
4610
|
+
});
|
|
4611
|
+
function readonly(innerType) {
|
|
4612
|
+
return new ZodReadonly({
|
|
4613
|
+
type: "readonly",
|
|
4614
|
+
innerType
|
|
4615
|
+
});
|
|
4616
|
+
}
|
|
4617
|
+
var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
4618
|
+
$ZodCustom.init(inst, def);
|
|
4619
|
+
ZodType.init(inst, def);
|
|
4620
|
+
inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
|
|
4621
|
+
});
|
|
4622
|
+
function refine(fn, _params = {}) {
|
|
4623
|
+
return _refine(ZodCustom, fn, _params);
|
|
4624
|
+
}
|
|
4625
|
+
function superRefine(fn, params) {
|
|
4626
|
+
return _superRefine(fn, params);
|
|
4627
|
+
}
|
|
4628
|
+
|
|
4629
|
+
// packages/mcp/src/uris.ts
|
|
4630
|
+
var PREFIX = "sourcefed://targets/";
|
|
4631
|
+
function eventResourceUri(target) {
|
|
4632
|
+
return `${PREFIX}${encodeTarget(target)}/events`;
|
|
4633
|
+
}
|
|
4634
|
+
|
|
4635
|
+
// packages/mcp/src/server.ts
|
|
4636
|
+
function createSourcefedMcp(daemon) {
|
|
4637
|
+
const handler = createMcpHandler(() => buildServer(daemon), { legacy: "stateless" });
|
|
4638
|
+
const unobserve = daemon.observe((target) => handler.notify.resourceUpdated(eventResourceUri(target)));
|
|
4639
|
+
return {
|
|
4640
|
+
runtime: daemon.runtime,
|
|
4641
|
+
handler,
|
|
4642
|
+
close: async () => {
|
|
4643
|
+
unobserve();
|
|
4644
|
+
await daemon.stop();
|
|
4645
|
+
}
|
|
4646
|
+
};
|
|
4647
|
+
}
|
|
4648
|
+
function createSourcefedStdio(daemon) {
|
|
4649
|
+
const servers = /* @__PURE__ */ new Set();
|
|
4650
|
+
const unobserve = daemon.observe((target) => {
|
|
4651
|
+
const uri = eventResourceUri(target);
|
|
4652
|
+
for (const server of servers) {
|
|
4653
|
+
void server.server.sendResourceUpdated({ uri }).catch(() => {
|
|
4654
|
+
});
|
|
4655
|
+
}
|
|
4656
|
+
});
|
|
4657
|
+
return {
|
|
4658
|
+
runtime: daemon.runtime,
|
|
4659
|
+
factory: () => {
|
|
4660
|
+
const server = buildServer(daemon);
|
|
4661
|
+
servers.add(server);
|
|
4662
|
+
return server;
|
|
4663
|
+
},
|
|
4664
|
+
close: async () => {
|
|
4665
|
+
unobserve();
|
|
4666
|
+
await daemon.stop();
|
|
4667
|
+
servers.clear();
|
|
4668
|
+
}
|
|
4669
|
+
};
|
|
4670
|
+
}
|
|
4671
|
+
function buildServer(daemon) {
|
|
4672
|
+
const targetSchema = object({ kind: string2().min(1), id: string2().min(1) });
|
|
4673
|
+
const sourceTypeSchema = _enum(daemon.sourceTypes);
|
|
4674
|
+
const createSchema = object({
|
|
4675
|
+
name: string2().min(1),
|
|
4676
|
+
sourceType: sourceTypeSchema,
|
|
4677
|
+
issueKey: string2().optional(),
|
|
4678
|
+
repo: string2().optional(),
|
|
4679
|
+
prNumber: number2().int().positive().optional(),
|
|
4680
|
+
channelId: string2().optional(),
|
|
4681
|
+
threadTs: string2().optional(),
|
|
4682
|
+
threadUrl: string2().optional(),
|
|
4683
|
+
pollIntervalSec: number2().min(15).optional(),
|
|
4684
|
+
target: targetSchema
|
|
4685
|
+
});
|
|
4686
|
+
const scopedSchema = object({ target: targetSchema });
|
|
4687
|
+
const statusSchema = object({ target: targetSchema, id: string2().min(1) });
|
|
4688
|
+
const ackSchema = object({ target: targetSchema, eventIDs: array(string2().min(1)).min(1) });
|
|
4689
|
+
const server = new McpServer(
|
|
4690
|
+
{ name: "sourcefed", version: "0.2.0" },
|
|
4691
|
+
{ capabilities: { resources: { subscribe: true } } }
|
|
4692
|
+
);
|
|
4693
|
+
server.registerTool(
|
|
4694
|
+
"monitor_create",
|
|
4695
|
+
{
|
|
4696
|
+
description: "Create or reuse a monitor for a Jira issue, GitHub pull request, or Slack thread.",
|
|
4697
|
+
inputSchema: createSchema,
|
|
4698
|
+
annotations: { idempotentHint: true, readOnlyHint: false }
|
|
4699
|
+
},
|
|
4700
|
+
async (input) => {
|
|
4701
|
+
const result = await daemon.createMonitor(input.target, input);
|
|
4702
|
+
if (!result.ok) return errorResult(result.error);
|
|
4703
|
+
return jsonResult({ ok: true, created: result.created, monitor: result.monitor });
|
|
4704
|
+
}
|
|
4705
|
+
);
|
|
4706
|
+
server.registerTool(
|
|
4707
|
+
"monitor_list",
|
|
4708
|
+
{
|
|
4709
|
+
description: "List active and stopped monitors for a target.",
|
|
4710
|
+
inputSchema: scopedSchema,
|
|
4711
|
+
annotations: { readOnlyHint: true }
|
|
4712
|
+
},
|
|
4713
|
+
async ({ target }) => {
|
|
4714
|
+
const result = await daemon.listMonitors(target);
|
|
4715
|
+
return jsonResult({ monitors: result.ok ? result.monitors : [] });
|
|
4716
|
+
}
|
|
4717
|
+
);
|
|
4718
|
+
server.registerTool(
|
|
4719
|
+
"monitor_status",
|
|
4720
|
+
{
|
|
4721
|
+
description: "Read one monitor owned by a target.",
|
|
4722
|
+
inputSchema: statusSchema,
|
|
4723
|
+
annotations: { readOnlyHint: true }
|
|
4724
|
+
},
|
|
4725
|
+
async ({ target, id }) => {
|
|
4726
|
+
const result = await daemon.getMonitor(target, id);
|
|
4727
|
+
if (!result.ok) return errorResult(result.error);
|
|
4728
|
+
return jsonResult({ monitor: result.monitor });
|
|
4729
|
+
}
|
|
4730
|
+
);
|
|
4731
|
+
server.registerTool(
|
|
4732
|
+
"monitor_stop",
|
|
4733
|
+
{
|
|
4734
|
+
description: "Stop one monitor owned by a target.",
|
|
4735
|
+
inputSchema: statusSchema,
|
|
4736
|
+
annotations: { destructiveHint: true, readOnlyHint: false }
|
|
4737
|
+
},
|
|
4738
|
+
async ({ target, id }) => {
|
|
4739
|
+
const result = await daemon.stopMonitor(target, id);
|
|
4740
|
+
if (!result.ok) return errorResult(result.error);
|
|
4741
|
+
return jsonResult({ monitor: result.monitor });
|
|
4742
|
+
}
|
|
4743
|
+
);
|
|
4744
|
+
server.registerTool(
|
|
4745
|
+
"monitor_start",
|
|
4746
|
+
{
|
|
4747
|
+
description: "Start (re-enable) a stopped monitor owned by a target.",
|
|
4748
|
+
inputSchema: statusSchema,
|
|
4749
|
+
annotations: { destructiveHint: true, readOnlyHint: false, idempotentHint: true }
|
|
4750
|
+
},
|
|
4751
|
+
async ({ target, id }) => {
|
|
4752
|
+
const result = await daemon.startMonitor(target, id);
|
|
4753
|
+
if (!result.ok) return errorResult(result.error);
|
|
4754
|
+
return jsonResult({ monitor: result.monitor });
|
|
4755
|
+
}
|
|
4756
|
+
);
|
|
4757
|
+
server.registerTool(
|
|
4758
|
+
"monitor_events_ack",
|
|
4759
|
+
{
|
|
4760
|
+
description: "Acknowledge monitor events after the host has delivered them.",
|
|
4761
|
+
inputSchema: ackSchema,
|
|
4762
|
+
annotations: { destructiveHint: true, readOnlyHint: false, idempotentHint: true }
|
|
4763
|
+
},
|
|
4764
|
+
async ({ target, eventIDs }) => {
|
|
4765
|
+
const result = await daemon.acknowledgeEvents(target, eventIDs);
|
|
4766
|
+
return jsonResult({ ok: result.ok, acknowledged: result.ok ? result.acknowledged : eventIDs });
|
|
4767
|
+
}
|
|
4768
|
+
);
|
|
4769
|
+
server.registerResource(
|
|
4770
|
+
"target-events",
|
|
4771
|
+
new ResourceTemplate("sourcefed://targets/{targetId}/events", { list: void 0 }),
|
|
4772
|
+
{
|
|
4773
|
+
title: "Sourcefed monitor events",
|
|
4774
|
+
description: "Pending monitor events for one host target.",
|
|
4775
|
+
mimeType: "application/json"
|
|
4776
|
+
},
|
|
4777
|
+
async (uri, variables) => {
|
|
4778
|
+
const target = decodeTarget(String(variables.targetId));
|
|
4779
|
+
if (!target) throw new Error("invalid Sourcefed target resource");
|
|
4780
|
+
const events = await daemon.readEvents(target);
|
|
4781
|
+
return {
|
|
4782
|
+
contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify({ events }) }]
|
|
4783
|
+
};
|
|
4784
|
+
}
|
|
4785
|
+
);
|
|
4786
|
+
return server;
|
|
4787
|
+
}
|
|
4788
|
+
function jsonResult(value) {
|
|
4789
|
+
return { content: [{ type: "text", text: JSON.stringify(value) }], structuredContent: value };
|
|
4790
|
+
}
|
|
4791
|
+
function errorResult(error) {
|
|
4792
|
+
return { content: [{ type: "text", text: error }], isError: true };
|
|
4793
|
+
}
|
|
4794
|
+
export {
|
|
4795
|
+
createSourcefedMcp,
|
|
4796
|
+
createSourcefedStdio,
|
|
4797
|
+
decodeTarget,
|
|
4798
|
+
encodeTarget,
|
|
4799
|
+
eventResourceUri
|
|
4800
|
+
};
|