@istarry/dsh-assistant-profile 0.4.5 → 0.5.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/lib/client.js +139 -4273
- package/lib/client.js.map +1 -1
- package/lib/index.js +141 -356
- package/package.json +1 -5
- package/lib/typert.host.d.ts +0 -3
- package/lib/typert.host.js +0 -285
- package/lib/typert.remote-client.d.ts +0 -32
- package/lib/typert.remote-client.js +0 -202
package/lib/client.js
CHANGED
|
@@ -494,7 +494,7 @@ window.__ModuleLoader__.load({
|
|
|
494
494
|
* @param value - 设置通道解出的 section。
|
|
495
495
|
* @returns 完整档案。
|
|
496
496
|
*/
|
|
497
|
-
function merge
|
|
497
|
+
function merge(value) {
|
|
498
498
|
if (typeof value !== "object" || value === null) return EMPTY_VALUES;
|
|
499
499
|
const record = value;
|
|
500
500
|
const pick = (key) => {
|
|
@@ -529,7 +529,7 @@ window.__ModuleLoader__.load({
|
|
|
529
529
|
const state = form.getSnapshot();
|
|
530
530
|
snapshot = {
|
|
531
531
|
status: state.status,
|
|
532
|
-
values: merge
|
|
532
|
+
values: merge(state.value),
|
|
533
533
|
customs: customsOf(state.value),
|
|
534
534
|
writable: state.writable,
|
|
535
535
|
pending,
|
|
@@ -719,28 +719,24 @@ window.__ModuleLoader__.load({
|
|
|
719
719
|
/**
|
|
720
720
|
* 「Agent记忆」设置页。
|
|
721
721
|
*
|
|
722
|
-
*
|
|
723
|
-
*
|
|
722
|
+
* 两块:两个互锁的开关,一个记忆编辑框。全部走设置通道,保存即落盘。
|
|
723
|
+
* 「从聊天记录提炼」不在这里——它在聊天消息的动作行上,属于另一件事。
|
|
724
724
|
*
|
|
725
725
|
* @module @istarry/dsh-assistant-profile/client/MemorySection
|
|
726
726
|
*/
|
|
727
727
|
/** 渲染设置页。 */
|
|
728
|
-
function MemorySection({ useMemorySection, toggle, setDraft, save,
|
|
728
|
+
function MemorySection({ useMemorySection, toggle, setDraft, save, t }) {
|
|
729
729
|
const state = useMemorySection((value) => value);
|
|
730
730
|
const [busy, setBusy] = (0, react.useState)(null);
|
|
731
|
-
const [pickerText, setPickerText] = (0, react.useState)("");
|
|
732
|
-
(0, react.useEffect)(() => {
|
|
733
|
-
load();
|
|
734
|
-
}, [load]);
|
|
735
731
|
const ready = state.status === "ready";
|
|
736
|
-
const memoryOn = state.
|
|
732
|
+
const memoryOn = state.config.memoryEnabled;
|
|
733
|
+
const { saveState, error } = state;
|
|
737
734
|
const flip = (field, next) => {
|
|
738
735
|
setBusy(field);
|
|
739
736
|
toggle(field, next).finally(() => {
|
|
740
737
|
setBusy(null);
|
|
741
738
|
});
|
|
742
739
|
};
|
|
743
|
-
const { editor, remember: rememberState } = state;
|
|
744
740
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
745
741
|
className: MemorySection_module_css_default.page,
|
|
746
742
|
children: [
|
|
@@ -802,4261 +798,154 @@ window.__ModuleLoader__.load({
|
|
|
802
798
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
803
799
|
type: "button",
|
|
804
800
|
role: "switch",
|
|
805
|
-
"aria-checked": state.
|
|
801
|
+
"aria-checked": state.config.autoMemory,
|
|
806
802
|
"aria-label": t("memory.auto.title"),
|
|
807
|
-
className: state.
|
|
803
|
+
className: state.config.autoMemory ? `${MemorySection_module_css_default.switch} ${MemorySection_module_css_default.on}` : MemorySection_module_css_default.switch,
|
|
808
804
|
disabled: !ready || !memoryOn || busy === "autoMemory",
|
|
809
805
|
onClick: () => {
|
|
810
|
-
flip("autoMemory", !state.
|
|
806
|
+
flip("autoMemory", !state.config.autoMemory);
|
|
811
807
|
},
|
|
812
808
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: MemorySection_module_css_default.knob })
|
|
813
809
|
})]
|
|
814
|
-
})
|
|
815
|
-
]
|
|
816
|
-
}),
|
|
817
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
818
|
-
className: MemorySection_module_css_default.group,
|
|
819
|
-
children: [
|
|
820
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
821
|
-
className: MemorySection_module_css_default.
|
|
822
|
-
children:
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
children: t("memory.
|
|
859
|
-
})
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
}),
|
|
865
|
-
editor.saveState === "failed" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
866
|
-
className: MemorySection_module_css_default.error,
|
|
867
|
-
role: "alert",
|
|
868
|
-
children: editor.error ?? t("memory.saveFailed")
|
|
869
|
-
}),
|
|
870
|
-
rememberState.state === "done" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
871
|
-
className: MemorySection_module_css_default.ok,
|
|
872
|
-
role: "status",
|
|
873
|
-
children: [
|
|
874
|
-
t("memory.remembered"),
|
|
875
|
-
" ",
|
|
876
|
-
rememberState.message
|
|
877
|
-
]
|
|
878
|
-
}),
|
|
879
|
-
rememberState.state === "failed" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
880
|
-
className: MemorySection_module_css_default.error,
|
|
881
|
-
role: "alert",
|
|
882
|
-
children: rememberState.message
|
|
883
|
-
})
|
|
884
|
-
]
|
|
885
|
-
})
|
|
886
|
-
]
|
|
887
|
-
}),
|
|
888
|
-
state.picker && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
889
|
-
className: MemorySection_module_css_default.overlay,
|
|
890
|
-
role: "dialog",
|
|
891
|
-
"aria-modal": "true",
|
|
892
|
-
"aria-label": t("memory.picker.title"),
|
|
893
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
894
|
-
className: MemorySection_module_css_default.dialog,
|
|
895
|
-
children: [
|
|
896
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
897
|
-
className: MemorySection_module_css_default.dialogTitle,
|
|
898
|
-
children: t("memory.picker.title")
|
|
899
|
-
}),
|
|
900
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
901
|
-
className: MemorySection_module_css_default.rowDesc,
|
|
902
|
-
children: t("memory.picker.hint")
|
|
903
|
-
}),
|
|
904
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
905
|
-
className: MemorySection_module_css_default.textarea,
|
|
906
|
-
value: pickerText,
|
|
907
|
-
placeholder: t("memory.picker.placeholder"),
|
|
908
|
-
rows: 6,
|
|
909
|
-
onChange: (event) => {
|
|
910
|
-
setPickerText(event.target.value);
|
|
911
|
-
}
|
|
912
|
-
}),
|
|
913
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
914
|
-
className: MemorySection_module_css_default.actions,
|
|
915
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
916
|
-
type: "button",
|
|
917
|
-
className: MemorySection_module_css_default.primary,
|
|
918
|
-
disabled: rememberState.state === "running" || pickerText.trim() === "" || state.sessions.length === 0,
|
|
919
|
-
onClick: () => {
|
|
920
|
-
const first = state.sessions[0];
|
|
921
|
-
if (first !== void 0) remember(first.id, pickerText);
|
|
922
|
-
},
|
|
923
|
-
children: rememberState.state === "running" ? t("memory.running") : t("memory.picker.run")
|
|
924
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
925
|
-
type: "button",
|
|
926
|
-
className: MemorySection_module_css_default.secondary,
|
|
927
|
-
onClick: closePicker,
|
|
928
|
-
children: t("memory.picker.cancel")
|
|
929
|
-
})]
|
|
930
|
-
}),
|
|
931
|
-
state.sessions.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
932
|
-
className: MemorySection_module_css_default.error,
|
|
933
|
-
children: t("memory.picker.noSessions")
|
|
934
|
-
})
|
|
935
|
-
]
|
|
936
|
-
})
|
|
937
|
-
})
|
|
938
|
-
]
|
|
939
|
-
});
|
|
940
|
-
}
|
|
941
|
-
//#endregion
|
|
942
|
-
//#region ../src/client/memoryStore.ts
|
|
943
|
-
/** 把持久化的开关段解码成两个开关(形状不对时全关)。 */
|
|
944
|
-
function decodeSwitches(section) {
|
|
945
|
-
const source = typeof section === "object" && section !== null && !Array.isArray(section) ? section : {};
|
|
946
|
-
return {
|
|
947
|
-
memoryEnabled: source.memoryEnabled === true,
|
|
948
|
-
autoMemory: source.autoMemory === true
|
|
949
|
-
};
|
|
950
|
-
}
|
|
951
|
-
/** 设置页控制器(每个浏览器页面一个)。 */
|
|
952
|
-
var MemorySettingsController = class {
|
|
953
|
-
form;
|
|
954
|
-
resolveRemote;
|
|
955
|
-
resolveSessions;
|
|
956
|
-
store = (0, _deepseek_ai_dsh_client_store.createSnapshotStore)({
|
|
957
|
-
status: "loading",
|
|
958
|
-
switches: decodeSwitches(void 0),
|
|
959
|
-
editor: {
|
|
960
|
-
text: "",
|
|
961
|
-
saveState: "idle",
|
|
962
|
-
error: null
|
|
963
|
-
},
|
|
964
|
-
picker: false,
|
|
965
|
-
sessions: [],
|
|
966
|
-
remember: {
|
|
967
|
-
state: "idle",
|
|
968
|
-
message: null
|
|
969
|
-
}
|
|
970
|
-
});
|
|
971
|
-
unsubscribe;
|
|
972
|
-
/**
|
|
973
|
-
* @param form - 本插件在设置通道里的配置表。
|
|
974
|
-
* @param resolveRemote - 调用时解析 `assistantProfile` Remote 命名空间。
|
|
975
|
-
* @param resolveSessions - 调用时解析会话列表快照。
|
|
976
|
-
*/
|
|
977
|
-
constructor(form, resolveRemote, resolveSessions) {
|
|
978
|
-
this.form = form;
|
|
979
|
-
this.resolveRemote = resolveRemote;
|
|
980
|
-
this.resolveSessions = resolveSessions;
|
|
981
|
-
this.unsubscribe = form.subscribe(() => {
|
|
982
|
-
this.deriveSwitches();
|
|
983
|
-
});
|
|
984
|
-
this.deriveSwitches();
|
|
985
|
-
}
|
|
986
|
-
/** 释放订阅。 */
|
|
987
|
-
dispose() {
|
|
988
|
-
this.unsubscribe();
|
|
989
|
-
}
|
|
990
|
-
/** 切换一个开关。 */
|
|
991
|
-
async toggle(field, next) {
|
|
992
|
-
await this.form.set(field, next);
|
|
993
|
-
}
|
|
994
|
-
/** 更新编辑框草稿(只在客户端,保存前不落盘)。 */
|
|
995
|
-
setDraft(text) {
|
|
996
|
-
const snapshot = this.store.getSnapshot();
|
|
997
|
-
this.store.set({
|
|
998
|
-
...snapshot,
|
|
999
|
-
editor: {
|
|
1000
|
-
...snapshot.editor,
|
|
1001
|
-
text,
|
|
1002
|
-
saveState: "idle"
|
|
1003
|
-
}
|
|
1004
|
-
});
|
|
1005
|
-
}
|
|
1006
|
-
/** 载入记忆文档。 */
|
|
1007
|
-
async load() {
|
|
1008
|
-
const remote = this.resolveRemote();
|
|
1009
|
-
if (remote === void 0) {
|
|
1010
|
-
this.failEditor("assistantProfile namespace is not mounted");
|
|
1011
|
-
return;
|
|
1012
|
-
}
|
|
1013
|
-
try {
|
|
1014
|
-
const read = await remote.readGlobal();
|
|
1015
|
-
if (!read.ok) throw new Error(read.error?.message ?? "read failed");
|
|
1016
|
-
this.store.set({
|
|
1017
|
-
...this.store.getSnapshot(),
|
|
1018
|
-
editor: {
|
|
1019
|
-
text: read.value ?? "",
|
|
1020
|
-
saveState: "idle",
|
|
1021
|
-
error: null
|
|
1022
|
-
}
|
|
1023
|
-
});
|
|
1024
|
-
} catch (error) {
|
|
1025
|
-
this.failEditor(error instanceof Error ? error.message : String(error));
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
/** 保存编辑框内容。 */
|
|
1029
|
-
async save() {
|
|
1030
|
-
const remote = this.resolveRemote();
|
|
1031
|
-
if (remote === void 0) {
|
|
1032
|
-
this.failEditor("assistantProfile namespace is not mounted");
|
|
1033
|
-
return;
|
|
1034
|
-
}
|
|
1035
|
-
const current = this.store.getSnapshot();
|
|
1036
|
-
this.store.set({
|
|
1037
|
-
...current,
|
|
1038
|
-
editor: {
|
|
1039
|
-
...current.editor,
|
|
1040
|
-
saveState: "saving",
|
|
1041
|
-
error: null
|
|
1042
|
-
}
|
|
1043
|
-
});
|
|
1044
|
-
try {
|
|
1045
|
-
const written = await remote.writeGlobal(current.editor.text);
|
|
1046
|
-
if (!written.ok) throw new Error(written.error?.message ?? "write failed");
|
|
1047
|
-
this.store.set({
|
|
1048
|
-
...this.store.getSnapshot(),
|
|
1049
|
-
editor: {
|
|
1050
|
-
...this.store.getSnapshot().editor,
|
|
1051
|
-
saveState: "saved"
|
|
1052
|
-
}
|
|
1053
|
-
});
|
|
1054
|
-
} catch (error) {
|
|
1055
|
-
this.failEditor(error instanceof Error ? error.message : String(error));
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
/** 打开提炼弹窗(顺带刷新会话列表)。 */
|
|
1059
|
-
openPicker() {
|
|
1060
|
-
const current = this.store.getSnapshot();
|
|
1061
|
-
this.store.set({
|
|
1062
|
-
...current,
|
|
1063
|
-
picker: true,
|
|
1064
|
-
sessions: this.resolveSessions(),
|
|
1065
|
-
remember: {
|
|
1066
|
-
state: "idle",
|
|
1067
|
-
message: null
|
|
1068
|
-
}
|
|
1069
|
-
});
|
|
1070
|
-
}
|
|
1071
|
-
/** 关闭提炼弹窗。 */
|
|
1072
|
-
closePicker() {
|
|
1073
|
-
const current = this.store.getSnapshot();
|
|
1074
|
-
this.store.set({
|
|
1075
|
-
...current,
|
|
1076
|
-
picker: false
|
|
1077
|
-
});
|
|
1078
|
-
}
|
|
1079
|
-
/**
|
|
1080
|
-
* 从一个会话提炼记忆。
|
|
1081
|
-
* @param sessionId - 要提炼的会话。
|
|
1082
|
-
* @param text - 该会话里选中的对话文本。
|
|
1083
|
-
*/
|
|
1084
|
-
async remember(sessionId, text) {
|
|
1085
|
-
const remote = this.resolveRemote();
|
|
1086
|
-
if (remote === void 0) {
|
|
1087
|
-
this.failRemember("assistantProfile namespace is not mounted");
|
|
1088
|
-
return;
|
|
1089
|
-
}
|
|
1090
|
-
this.store.set({
|
|
1091
|
-
...this.store.getSnapshot(),
|
|
1092
|
-
remember: {
|
|
1093
|
-
state: "running",
|
|
1094
|
-
message: null
|
|
1095
|
-
}
|
|
1096
|
-
});
|
|
1097
|
-
try {
|
|
1098
|
-
const result = await remote.remember(sessionId, text);
|
|
1099
|
-
if (!result.ok) throw new Error(result.error?.message ?? "remember failed");
|
|
1100
|
-
const value = result.value;
|
|
1101
|
-
if (value === void 0) throw new Error("empty response");
|
|
1102
|
-
if (value.saved) {
|
|
1103
|
-
const count = value.entries?.length ?? 0;
|
|
1104
|
-
this.store.set({
|
|
1105
|
-
...this.store.getSnapshot(),
|
|
1106
|
-
picker: false,
|
|
1107
|
-
remember: {
|
|
1108
|
-
state: "done",
|
|
1109
|
-
message: `+${count}`
|
|
1110
|
-
}
|
|
1111
|
-
});
|
|
1112
|
-
await this.load();
|
|
1113
|
-
} else this.failRemember(value.outcome);
|
|
1114
|
-
} catch (error) {
|
|
1115
|
-
this.failRemember(error instanceof Error ? error.message : String(error));
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
failEditor(message) {
|
|
1119
|
-
const current = this.store.getSnapshot();
|
|
1120
|
-
this.store.set({
|
|
1121
|
-
...current,
|
|
1122
|
-
editor: {
|
|
1123
|
-
...current.editor,
|
|
1124
|
-
saveState: "failed",
|
|
1125
|
-
error: message
|
|
1126
|
-
}
|
|
1127
|
-
});
|
|
1128
|
-
}
|
|
1129
|
-
failRemember(message) {
|
|
1130
|
-
this.store.set({
|
|
1131
|
-
...this.store.getSnapshot(),
|
|
1132
|
-
remember: {
|
|
1133
|
-
state: "failed",
|
|
1134
|
-
message
|
|
1135
|
-
}
|
|
1136
|
-
});
|
|
1137
|
-
}
|
|
1138
|
-
deriveSwitches() {
|
|
1139
|
-
const snapshot = this.form.getSnapshot();
|
|
1140
|
-
this.store.set({
|
|
1141
|
-
...this.store.getSnapshot(),
|
|
1142
|
-
status: snapshot.status === "ready" ? "ready" : snapshot.status === "loading" ? "loading" : "unavailable",
|
|
1143
|
-
switches: decodeSwitches(snapshot.value)
|
|
1144
|
-
});
|
|
1145
|
-
}
|
|
1146
|
-
};
|
|
1147
|
-
/** 把会话列表快照折成弹窗选项(跳过子代理会话)。 */
|
|
1148
|
-
function sessionOptions(snapshot) {
|
|
1149
|
-
const ids = snapshot.order ?? Object.keys(snapshot.byId);
|
|
1150
|
-
const options = [];
|
|
1151
|
-
for (const id of ids) {
|
|
1152
|
-
const entry = snapshot.byId[id];
|
|
1153
|
-
if (entry === void 0) continue;
|
|
1154
|
-
options.push({
|
|
1155
|
-
id,
|
|
1156
|
-
title: entry.displayTitle ?? id
|
|
1157
|
-
});
|
|
1158
|
-
}
|
|
1159
|
-
return options;
|
|
1160
|
-
}
|
|
1161
|
-
//#endregion
|
|
1162
|
-
//#region ../src/node_modules/zod/v4/core/core.js
|
|
1163
|
-
var _a$1;
|
|
1164
|
-
function $constructor(name, initializer, params) {
|
|
1165
|
-
function init(inst, def) {
|
|
1166
|
-
if (!inst._zod) Object.defineProperty(inst, "_zod", {
|
|
1167
|
-
value: {
|
|
1168
|
-
def,
|
|
1169
|
-
constr: _,
|
|
1170
|
-
traits: /* @__PURE__ */ new Set()
|
|
1171
|
-
},
|
|
1172
|
-
enumerable: false
|
|
1173
|
-
});
|
|
1174
|
-
if (inst._zod.traits.has(name)) return;
|
|
1175
|
-
inst._zod.traits.add(name);
|
|
1176
|
-
initializer(inst, def);
|
|
1177
|
-
const proto = _.prototype;
|
|
1178
|
-
const keys = Object.keys(proto);
|
|
1179
|
-
for (let i = 0; i < keys.length; i++) {
|
|
1180
|
-
const k = keys[i];
|
|
1181
|
-
if (!(k in inst)) inst[k] = proto[k].bind(inst);
|
|
1182
|
-
}
|
|
1183
|
-
}
|
|
1184
|
-
const Parent = params?.Parent ?? Object;
|
|
1185
|
-
class Definition extends Parent {}
|
|
1186
|
-
Object.defineProperty(Definition, "name", { value: name });
|
|
1187
|
-
function _(def) {
|
|
1188
|
-
var _a;
|
|
1189
|
-
const inst = params?.Parent ? new Definition() : this;
|
|
1190
|
-
init(inst, def);
|
|
1191
|
-
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
1192
|
-
for (const fn of inst._zod.deferred) fn();
|
|
1193
|
-
return inst;
|
|
1194
|
-
}
|
|
1195
|
-
Object.defineProperty(_, "init", { value: init });
|
|
1196
|
-
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
|
|
1197
|
-
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
1198
|
-
return inst?._zod?.traits?.has(name);
|
|
1199
|
-
} });
|
|
1200
|
-
Object.defineProperty(_, "name", { value: name });
|
|
1201
|
-
return _;
|
|
1202
|
-
}
|
|
1203
|
-
var $ZodAsyncError = class extends Error {
|
|
1204
|
-
constructor() {
|
|
1205
|
-
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
1206
|
-
}
|
|
1207
|
-
};
|
|
1208
|
-
var $ZodEncodeError = class extends Error {
|
|
1209
|
-
constructor(name) {
|
|
1210
|
-
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
1211
|
-
this.name = "ZodEncodeError";
|
|
1212
|
-
}
|
|
1213
|
-
};
|
|
1214
|
-
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
|
|
1215
|
-
const globalConfig = globalThis.__zod_globalConfig;
|
|
1216
|
-
function config(newConfig) {
|
|
1217
|
-
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
1218
|
-
return globalConfig;
|
|
1219
|
-
}
|
|
1220
|
-
//#endregion
|
|
1221
|
-
//#region ../src/node_modules/zod/v4/core/util.js
|
|
1222
|
-
function getEnumValues(entries) {
|
|
1223
|
-
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
1224
|
-
return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
1225
|
-
}
|
|
1226
|
-
function jsonStringifyReplacer(_, value) {
|
|
1227
|
-
if (typeof value === "bigint") return value.toString();
|
|
1228
|
-
return value;
|
|
1229
|
-
}
|
|
1230
|
-
function cached(getter) {
|
|
1231
|
-
return { get value() {
|
|
1232
|
-
{
|
|
1233
|
-
const value = getter();
|
|
1234
|
-
Object.defineProperty(this, "value", { value });
|
|
1235
|
-
return value;
|
|
1236
|
-
}
|
|
1237
|
-
throw new Error("cached value already set");
|
|
1238
|
-
} };
|
|
1239
|
-
}
|
|
1240
|
-
function nullish(input) {
|
|
1241
|
-
return input === null || input === void 0;
|
|
1242
|
-
}
|
|
1243
|
-
function cleanRegex(source) {
|
|
1244
|
-
const start = source.startsWith("^") ? 1 : 0;
|
|
1245
|
-
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
1246
|
-
return source.slice(start, end);
|
|
1247
|
-
}
|
|
1248
|
-
const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
|
|
1249
|
-
function defineLazy(object, key, getter) {
|
|
1250
|
-
let value = void 0;
|
|
1251
|
-
Object.defineProperty(object, key, {
|
|
1252
|
-
get() {
|
|
1253
|
-
if (value === EVALUATING) return;
|
|
1254
|
-
if (value === void 0) {
|
|
1255
|
-
value = EVALUATING;
|
|
1256
|
-
value = getter();
|
|
1257
|
-
}
|
|
1258
|
-
return value;
|
|
1259
|
-
},
|
|
1260
|
-
set(v) {
|
|
1261
|
-
Object.defineProperty(object, key, { value: v });
|
|
1262
|
-
},
|
|
1263
|
-
configurable: true
|
|
1264
|
-
});
|
|
1265
|
-
}
|
|
1266
|
-
function assignProp(target, prop, value) {
|
|
1267
|
-
Object.defineProperty(target, prop, {
|
|
1268
|
-
value,
|
|
1269
|
-
writable: true,
|
|
1270
|
-
enumerable: true,
|
|
1271
|
-
configurable: true
|
|
1272
|
-
});
|
|
1273
|
-
}
|
|
1274
|
-
function mergeDefs(...defs) {
|
|
1275
|
-
const mergedDescriptors = {};
|
|
1276
|
-
for (const def of defs) {
|
|
1277
|
-
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
1278
|
-
Object.assign(mergedDescriptors, descriptors);
|
|
1279
|
-
}
|
|
1280
|
-
return Object.defineProperties({}, mergedDescriptors);
|
|
1281
|
-
}
|
|
1282
|
-
function esc(str) {
|
|
1283
|
-
return JSON.stringify(str);
|
|
1284
|
-
}
|
|
1285
|
-
function slugify(input) {
|
|
1286
|
-
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
1287
|
-
}
|
|
1288
|
-
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
1289
|
-
function isObject(data) {
|
|
1290
|
-
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
1291
|
-
}
|
|
1292
|
-
const allowsEval = /* @__PURE__*/ cached(() => {
|
|
1293
|
-
if (globalConfig.jitless) return false;
|
|
1294
|
-
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
|
|
1295
|
-
try {
|
|
1296
|
-
new Function("");
|
|
1297
|
-
return true;
|
|
1298
|
-
} catch (_) {
|
|
1299
|
-
return false;
|
|
1300
|
-
}
|
|
1301
|
-
});
|
|
1302
|
-
function isPlainObject(o) {
|
|
1303
|
-
if (isObject(o) === false) return false;
|
|
1304
|
-
const ctor = o.constructor;
|
|
1305
|
-
if (ctor === void 0) return true;
|
|
1306
|
-
if (typeof ctor !== "function") return true;
|
|
1307
|
-
const prot = ctor.prototype;
|
|
1308
|
-
if (isObject(prot) === false) return false;
|
|
1309
|
-
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
|
|
1310
|
-
return true;
|
|
1311
|
-
}
|
|
1312
|
-
function shallowClone(o) {
|
|
1313
|
-
if (isPlainObject(o)) return { ...o };
|
|
1314
|
-
if (Array.isArray(o)) return [...o];
|
|
1315
|
-
if (o instanceof Map) return new Map(o);
|
|
1316
|
-
if (o instanceof Set) return new Set(o);
|
|
1317
|
-
return o;
|
|
1318
|
-
}
|
|
1319
|
-
const propertyKeyTypes = /* @__PURE__*/ new Set([
|
|
1320
|
-
"string",
|
|
1321
|
-
"number",
|
|
1322
|
-
"symbol"
|
|
1323
|
-
]);
|
|
1324
|
-
function escapeRegex(str) {
|
|
1325
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1326
|
-
}
|
|
1327
|
-
function clone(inst, def, params) {
|
|
1328
|
-
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
1329
|
-
if (!def || params?.parent) cl._zod.parent = inst;
|
|
1330
|
-
return cl;
|
|
1331
|
-
}
|
|
1332
|
-
function normalizeParams(_params) {
|
|
1333
|
-
const params = _params;
|
|
1334
|
-
if (!params) return {};
|
|
1335
|
-
if (typeof params === "string") return { error: () => params };
|
|
1336
|
-
if (params?.message !== void 0) {
|
|
1337
|
-
if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
|
|
1338
|
-
params.error = params.message;
|
|
1339
|
-
}
|
|
1340
|
-
delete params.message;
|
|
1341
|
-
if (typeof params.error === "string") return {
|
|
1342
|
-
...params,
|
|
1343
|
-
error: () => params.error
|
|
1344
|
-
};
|
|
1345
|
-
return params;
|
|
1346
|
-
}
|
|
1347
|
-
function optionalKeys(shape) {
|
|
1348
|
-
return Object.keys(shape).filter((k) => {
|
|
1349
|
-
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
|
|
1350
|
-
});
|
|
1351
|
-
}
|
|
1352
|
-
Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, -Number.MAX_VALUE, Number.MAX_VALUE;
|
|
1353
|
-
function pick(schema, mask) {
|
|
1354
|
-
const currDef = schema._zod.def;
|
|
1355
|
-
const checks = currDef.checks;
|
|
1356
|
-
if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
1357
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
1358
|
-
get shape() {
|
|
1359
|
-
const newShape = {};
|
|
1360
|
-
for (const key in mask) {
|
|
1361
|
-
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
1362
|
-
if (!mask[key]) continue;
|
|
1363
|
-
newShape[key] = currDef.shape[key];
|
|
1364
|
-
}
|
|
1365
|
-
assignProp(this, "shape", newShape);
|
|
1366
|
-
return newShape;
|
|
1367
|
-
},
|
|
1368
|
-
checks: []
|
|
1369
|
-
}));
|
|
1370
|
-
}
|
|
1371
|
-
function omit(schema, mask) {
|
|
1372
|
-
const currDef = schema._zod.def;
|
|
1373
|
-
const checks = currDef.checks;
|
|
1374
|
-
if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
1375
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
1376
|
-
get shape() {
|
|
1377
|
-
const newShape = { ...schema._zod.def.shape };
|
|
1378
|
-
for (const key in mask) {
|
|
1379
|
-
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
1380
|
-
if (!mask[key]) continue;
|
|
1381
|
-
delete newShape[key];
|
|
1382
|
-
}
|
|
1383
|
-
assignProp(this, "shape", newShape);
|
|
1384
|
-
return newShape;
|
|
1385
|
-
},
|
|
1386
|
-
checks: []
|
|
1387
|
-
}));
|
|
1388
|
-
}
|
|
1389
|
-
function extend(schema, shape) {
|
|
1390
|
-
if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
|
|
1391
|
-
const checks = schema._zod.def.checks;
|
|
1392
|
-
if (checks && checks.length > 0) {
|
|
1393
|
-
const existingShape = schema._zod.def.shape;
|
|
1394
|
-
for (const key in shape) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
1395
|
-
}
|
|
1396
|
-
return clone(schema, mergeDefs(schema._zod.def, { get shape() {
|
|
1397
|
-
const _shape = {
|
|
1398
|
-
...schema._zod.def.shape,
|
|
1399
|
-
...shape
|
|
1400
|
-
};
|
|
1401
|
-
assignProp(this, "shape", _shape);
|
|
1402
|
-
return _shape;
|
|
1403
|
-
} }));
|
|
1404
|
-
}
|
|
1405
|
-
function safeExtend(schema, shape) {
|
|
1406
|
-
if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
1407
|
-
return clone(schema, mergeDefs(schema._zod.def, { get shape() {
|
|
1408
|
-
const _shape = {
|
|
1409
|
-
...schema._zod.def.shape,
|
|
1410
|
-
...shape
|
|
1411
|
-
};
|
|
1412
|
-
assignProp(this, "shape", _shape);
|
|
1413
|
-
return _shape;
|
|
1414
|
-
} }));
|
|
1415
|
-
}
|
|
1416
|
-
function merge(a, b) {
|
|
1417
|
-
if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
1418
|
-
return clone(a, mergeDefs(a._zod.def, {
|
|
1419
|
-
get shape() {
|
|
1420
|
-
const _shape = {
|
|
1421
|
-
...a._zod.def.shape,
|
|
1422
|
-
...b._zod.def.shape
|
|
1423
|
-
};
|
|
1424
|
-
assignProp(this, "shape", _shape);
|
|
1425
|
-
return _shape;
|
|
1426
|
-
},
|
|
1427
|
-
get catchall() {
|
|
1428
|
-
return b._zod.def.catchall;
|
|
1429
|
-
},
|
|
1430
|
-
checks: b._zod.def.checks ?? []
|
|
1431
|
-
}));
|
|
1432
|
-
}
|
|
1433
|
-
function partial(Class, schema, mask) {
|
|
1434
|
-
const checks = schema._zod.def.checks;
|
|
1435
|
-
if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
|
|
1436
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
1437
|
-
get shape() {
|
|
1438
|
-
const oldShape = schema._zod.def.shape;
|
|
1439
|
-
const shape = { ...oldShape };
|
|
1440
|
-
if (mask) for (const key in mask) {
|
|
1441
|
-
if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
1442
|
-
if (!mask[key]) continue;
|
|
1443
|
-
shape[key] = Class ? new Class({
|
|
1444
|
-
type: "optional",
|
|
1445
|
-
innerType: oldShape[key]
|
|
1446
|
-
}) : oldShape[key];
|
|
1447
|
-
}
|
|
1448
|
-
else for (const key in oldShape) shape[key] = Class ? new Class({
|
|
1449
|
-
type: "optional",
|
|
1450
|
-
innerType: oldShape[key]
|
|
1451
|
-
}) : oldShape[key];
|
|
1452
|
-
assignProp(this, "shape", shape);
|
|
1453
|
-
return shape;
|
|
1454
|
-
},
|
|
1455
|
-
checks: []
|
|
1456
|
-
}));
|
|
1457
|
-
}
|
|
1458
|
-
function required(Class, schema, mask) {
|
|
1459
|
-
return clone(schema, mergeDefs(schema._zod.def, { get shape() {
|
|
1460
|
-
const oldShape = schema._zod.def.shape;
|
|
1461
|
-
const shape = { ...oldShape };
|
|
1462
|
-
if (mask) for (const key in mask) {
|
|
1463
|
-
if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
1464
|
-
if (!mask[key]) continue;
|
|
1465
|
-
shape[key] = new Class({
|
|
1466
|
-
type: "nonoptional",
|
|
1467
|
-
innerType: oldShape[key]
|
|
1468
|
-
});
|
|
1469
|
-
}
|
|
1470
|
-
else for (const key in oldShape) shape[key] = new Class({
|
|
1471
|
-
type: "nonoptional",
|
|
1472
|
-
innerType: oldShape[key]
|
|
1473
|
-
});
|
|
1474
|
-
assignProp(this, "shape", shape);
|
|
1475
|
-
return shape;
|
|
1476
|
-
} }));
|
|
1477
|
-
}
|
|
1478
|
-
function aborted(x, startIndex = 0) {
|
|
1479
|
-
if (x.aborted === true) return true;
|
|
1480
|
-
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
|
|
1481
|
-
return false;
|
|
1482
|
-
}
|
|
1483
|
-
function explicitlyAborted(x, startIndex = 0) {
|
|
1484
|
-
if (x.aborted === true) return true;
|
|
1485
|
-
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue === false) return true;
|
|
1486
|
-
return false;
|
|
1487
|
-
}
|
|
1488
|
-
function prefixIssues(path, issues) {
|
|
1489
|
-
return issues.map((iss) => {
|
|
1490
|
-
var _a;
|
|
1491
|
-
(_a = iss).path ?? (_a.path = []);
|
|
1492
|
-
iss.path.unshift(path);
|
|
1493
|
-
return iss;
|
|
1494
|
-
});
|
|
1495
|
-
}
|
|
1496
|
-
function unwrapMessage(message) {
|
|
1497
|
-
return typeof message === "string" ? message : message?.message;
|
|
1498
|
-
}
|
|
1499
|
-
function finalizeIssue(iss, ctx, config) {
|
|
1500
|
-
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
|
|
1501
|
-
const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
|
|
1502
|
-
rest.path ?? (rest.path = []);
|
|
1503
|
-
rest.message = message;
|
|
1504
|
-
if (ctx?.reportInput) rest.input = _input;
|
|
1505
|
-
return rest;
|
|
1506
|
-
}
|
|
1507
|
-
function getLengthableOrigin(input) {
|
|
1508
|
-
if (Array.isArray(input)) return "array";
|
|
1509
|
-
if (typeof input === "string") return "string";
|
|
1510
|
-
return "unknown";
|
|
1511
|
-
}
|
|
1512
|
-
function issue(...args) {
|
|
1513
|
-
const [iss, input, inst] = args;
|
|
1514
|
-
if (typeof iss === "string") return {
|
|
1515
|
-
message: iss,
|
|
1516
|
-
code: "custom",
|
|
1517
|
-
input,
|
|
1518
|
-
inst
|
|
1519
|
-
};
|
|
1520
|
-
return { ...iss };
|
|
1521
|
-
}
|
|
1522
|
-
//#endregion
|
|
1523
|
-
//#region ../src/node_modules/zod/v4/core/errors.js
|
|
1524
|
-
const initializer$1 = (inst, def) => {
|
|
1525
|
-
inst.name = "$ZodError";
|
|
1526
|
-
Object.defineProperty(inst, "_zod", {
|
|
1527
|
-
value: inst._zod,
|
|
1528
|
-
enumerable: false
|
|
1529
|
-
});
|
|
1530
|
-
Object.defineProperty(inst, "issues", {
|
|
1531
|
-
value: def,
|
|
1532
|
-
enumerable: false
|
|
1533
|
-
});
|
|
1534
|
-
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
1535
|
-
Object.defineProperty(inst, "toString", {
|
|
1536
|
-
value: () => inst.message,
|
|
1537
|
-
enumerable: false
|
|
1538
|
-
});
|
|
1539
|
-
};
|
|
1540
|
-
const $ZodError = $constructor("$ZodError", initializer$1);
|
|
1541
|
-
const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
|
|
1542
|
-
function flattenError(error, mapper = (issue) => issue.message) {
|
|
1543
|
-
const fieldErrors = {};
|
|
1544
|
-
const formErrors = [];
|
|
1545
|
-
for (const sub of error.issues) if (sub.path.length > 0) {
|
|
1546
|
-
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
1547
|
-
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
1548
|
-
} else formErrors.push(mapper(sub));
|
|
1549
|
-
return {
|
|
1550
|
-
formErrors,
|
|
1551
|
-
fieldErrors
|
|
1552
|
-
};
|
|
1553
|
-
}
|
|
1554
|
-
function formatError(error, mapper = (issue) => issue.message) {
|
|
1555
|
-
const fieldErrors = { _errors: [] };
|
|
1556
|
-
const processError = (error, path = []) => {
|
|
1557
|
-
for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
|
|
1558
|
-
else if (issue.code === "invalid_key") processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
1559
|
-
else if (issue.code === "invalid_element") processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
1560
|
-
else {
|
|
1561
|
-
const fullpath = [...path, ...issue.path];
|
|
1562
|
-
if (fullpath.length === 0) fieldErrors._errors.push(mapper(issue));
|
|
1563
|
-
else {
|
|
1564
|
-
let curr = fieldErrors;
|
|
1565
|
-
let i = 0;
|
|
1566
|
-
while (i < fullpath.length) {
|
|
1567
|
-
const el = fullpath[i];
|
|
1568
|
-
if (!(i === fullpath.length - 1)) curr[el] = curr[el] || { _errors: [] };
|
|
1569
|
-
else {
|
|
1570
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
1571
|
-
curr[el]._errors.push(mapper(issue));
|
|
1572
|
-
}
|
|
1573
|
-
curr = curr[el];
|
|
1574
|
-
i++;
|
|
1575
|
-
}
|
|
1576
|
-
}
|
|
1577
|
-
}
|
|
1578
|
-
};
|
|
1579
|
-
processError(error);
|
|
1580
|
-
return fieldErrors;
|
|
1581
|
-
}
|
|
1582
|
-
//#endregion
|
|
1583
|
-
//#region ../src/node_modules/zod/v4/core/parse.js
|
|
1584
|
-
const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
1585
|
-
const ctx = _ctx ? {
|
|
1586
|
-
..._ctx,
|
|
1587
|
-
async: false
|
|
1588
|
-
} : { async: false };
|
|
1589
|
-
const result = schema._zod.run({
|
|
1590
|
-
value,
|
|
1591
|
-
issues: []
|
|
1592
|
-
}, ctx);
|
|
1593
|
-
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
1594
|
-
if (result.issues.length) {
|
|
1595
|
-
const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
1596
|
-
captureStackTrace(e, _params?.callee);
|
|
1597
|
-
throw e;
|
|
1598
|
-
}
|
|
1599
|
-
return result.value;
|
|
1600
|
-
};
|
|
1601
|
-
const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
1602
|
-
const ctx = _ctx ? {
|
|
1603
|
-
..._ctx,
|
|
1604
|
-
async: true
|
|
1605
|
-
} : { async: true };
|
|
1606
|
-
let result = schema._zod.run({
|
|
1607
|
-
value,
|
|
1608
|
-
issues: []
|
|
1609
|
-
}, ctx);
|
|
1610
|
-
if (result instanceof Promise) result = await result;
|
|
1611
|
-
if (result.issues.length) {
|
|
1612
|
-
const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
1613
|
-
captureStackTrace(e, params?.callee);
|
|
1614
|
-
throw e;
|
|
1615
|
-
}
|
|
1616
|
-
return result.value;
|
|
1617
|
-
};
|
|
1618
|
-
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
1619
|
-
const ctx = _ctx ? {
|
|
1620
|
-
..._ctx,
|
|
1621
|
-
async: false
|
|
1622
|
-
} : { async: false };
|
|
1623
|
-
const result = schema._zod.run({
|
|
1624
|
-
value,
|
|
1625
|
-
issues: []
|
|
1626
|
-
}, ctx);
|
|
1627
|
-
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
1628
|
-
return result.issues.length ? {
|
|
1629
|
-
success: false,
|
|
1630
|
-
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
1631
|
-
} : {
|
|
1632
|
-
success: true,
|
|
1633
|
-
data: result.value
|
|
1634
|
-
};
|
|
1635
|
-
};
|
|
1636
|
-
const safeParse$1 = /* @__PURE__*/ _safeParse($ZodRealError);
|
|
1637
|
-
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
1638
|
-
const ctx = _ctx ? {
|
|
1639
|
-
..._ctx,
|
|
1640
|
-
async: true
|
|
1641
|
-
} : { async: true };
|
|
1642
|
-
let result = schema._zod.run({
|
|
1643
|
-
value,
|
|
1644
|
-
issues: []
|
|
1645
|
-
}, ctx);
|
|
1646
|
-
if (result instanceof Promise) result = await result;
|
|
1647
|
-
return result.issues.length ? {
|
|
1648
|
-
success: false,
|
|
1649
|
-
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
1650
|
-
} : {
|
|
1651
|
-
success: true,
|
|
1652
|
-
data: result.value
|
|
1653
|
-
};
|
|
1654
|
-
};
|
|
1655
|
-
const safeParseAsync$1 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
|
|
1656
|
-
const _encode = (_Err) => (schema, value, _ctx) => {
|
|
1657
|
-
const ctx = _ctx ? {
|
|
1658
|
-
..._ctx,
|
|
1659
|
-
direction: "backward"
|
|
1660
|
-
} : { direction: "backward" };
|
|
1661
|
-
return _parse(_Err)(schema, value, ctx);
|
|
1662
|
-
};
|
|
1663
|
-
const _decode = (_Err) => (schema, value, _ctx) => {
|
|
1664
|
-
return _parse(_Err)(schema, value, _ctx);
|
|
1665
|
-
};
|
|
1666
|
-
const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
1667
|
-
const ctx = _ctx ? {
|
|
1668
|
-
..._ctx,
|
|
1669
|
-
direction: "backward"
|
|
1670
|
-
} : { direction: "backward" };
|
|
1671
|
-
return _parseAsync(_Err)(schema, value, ctx);
|
|
1672
|
-
};
|
|
1673
|
-
const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
1674
|
-
return _parseAsync(_Err)(schema, value, _ctx);
|
|
1675
|
-
};
|
|
1676
|
-
const _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
1677
|
-
const ctx = _ctx ? {
|
|
1678
|
-
..._ctx,
|
|
1679
|
-
direction: "backward"
|
|
1680
|
-
} : { direction: "backward" };
|
|
1681
|
-
return _safeParse(_Err)(schema, value, ctx);
|
|
1682
|
-
};
|
|
1683
|
-
const _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
1684
|
-
return _safeParse(_Err)(schema, value, _ctx);
|
|
1685
|
-
};
|
|
1686
|
-
const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
1687
|
-
const ctx = _ctx ? {
|
|
1688
|
-
..._ctx,
|
|
1689
|
-
direction: "backward"
|
|
1690
|
-
} : { direction: "backward" };
|
|
1691
|
-
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
1692
|
-
};
|
|
1693
|
-
const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
1694
|
-
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
1695
|
-
};
|
|
1696
|
-
//#endregion
|
|
1697
|
-
//#region ../src/node_modules/zod/v4/core/regexes.js
|
|
1698
|
-
/**
|
|
1699
|
-
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
1700
|
-
* (timestamps embedded in the id). Use {@link cuid2} instead.
|
|
1701
|
-
* See https://github.com/paralleldrive/cuid.
|
|
1702
|
-
*/
|
|
1703
|
-
const cuid = /^[cC][0-9a-z]{6,}$/;
|
|
1704
|
-
const cuid2 = /^[0-9a-z]+$/;
|
|
1705
|
-
const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
|
1706
|
-
const xid = /^[0-9a-vA-V]{20}$/;
|
|
1707
|
-
const ksuid = /^[A-Za-z0-9]{27}$/;
|
|
1708
|
-
const nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
1709
|
-
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
|
|
1710
|
-
const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
1711
|
-
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
|
1712
|
-
const 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})$/;
|
|
1713
|
-
/** Returns a regex for validating an RFC 9562/4122 UUID.
|
|
1714
|
-
*
|
|
1715
|
-
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
|
1716
|
-
const uuid = (version) => {
|
|
1717
|
-
if (!version) 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)$/;
|
|
1718
|
-
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
1719
|
-
};
|
|
1720
|
-
/** Practical email validation */
|
|
1721
|
-
const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
1722
|
-
const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
1723
|
-
function emoji() {
|
|
1724
|
-
return new RegExp(_emoji$1, "u");
|
|
1725
|
-
}
|
|
1726
|
-
const 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])$/;
|
|
1727
|
-
const 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}|:))$/;
|
|
1728
|
-
const 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])$/;
|
|
1729
|
-
const 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])$/;
|
|
1730
|
-
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
1731
|
-
const base64url = /^[A-Za-z0-9_-]*$/;
|
|
1732
|
-
const httpProtocol = /^https?$/;
|
|
1733
|
-
const e164 = /^\+[1-9]\d{6,14}$/;
|
|
1734
|
-
const 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])))`;
|
|
1735
|
-
const date$1 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
|
|
1736
|
-
function timeSource(args) {
|
|
1737
|
-
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
1738
|
-
return 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+)?)?`;
|
|
1739
|
-
}
|
|
1740
|
-
function time$1(args) {
|
|
1741
|
-
return new RegExp(`^${timeSource(args)}$`);
|
|
1742
|
-
}
|
|
1743
|
-
function datetime$1(args) {
|
|
1744
|
-
const time = timeSource({ precision: args.precision });
|
|
1745
|
-
const opts = ["Z"];
|
|
1746
|
-
if (args.local) opts.push("");
|
|
1747
|
-
if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
1748
|
-
const timeRegex = `${time}(?:${opts.join("|")})`;
|
|
1749
|
-
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
1750
|
-
}
|
|
1751
|
-
const string$1 = (params) => {
|
|
1752
|
-
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
1753
|
-
return new RegExp(`^${regex}$`);
|
|
1754
|
-
};
|
|
1755
|
-
const boolean$1 = /^(?:true|false)$/i;
|
|
1756
|
-
const lowercase = /^[^A-Z]*$/;
|
|
1757
|
-
const uppercase = /^[^a-z]*$/;
|
|
1758
|
-
//#endregion
|
|
1759
|
-
//#region ../src/node_modules/zod/v4/core/checks.js
|
|
1760
|
-
const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
|
|
1761
|
-
var _a;
|
|
1762
|
-
inst._zod ?? (inst._zod = {});
|
|
1763
|
-
inst._zod.def = def;
|
|
1764
|
-
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
1765
|
-
});
|
|
1766
|
-
const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
1767
|
-
var _a;
|
|
1768
|
-
$ZodCheck.init(inst, def);
|
|
1769
|
-
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
1770
|
-
const val = payload.value;
|
|
1771
|
-
return !nullish(val) && val.length !== void 0;
|
|
1772
|
-
});
|
|
1773
|
-
inst._zod.onattach.push((inst) => {
|
|
1774
|
-
const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
1775
|
-
if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
|
|
1776
|
-
});
|
|
1777
|
-
inst._zod.check = (payload) => {
|
|
1778
|
-
const input = payload.value;
|
|
1779
|
-
if (input.length <= def.maximum) return;
|
|
1780
|
-
const origin = getLengthableOrigin(input);
|
|
1781
|
-
payload.issues.push({
|
|
1782
|
-
origin,
|
|
1783
|
-
code: "too_big",
|
|
1784
|
-
maximum: def.maximum,
|
|
1785
|
-
inclusive: true,
|
|
1786
|
-
input,
|
|
1787
|
-
inst,
|
|
1788
|
-
continue: !def.abort
|
|
1789
|
-
});
|
|
1790
|
-
};
|
|
1791
|
-
});
|
|
1792
|
-
const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
1793
|
-
var _a;
|
|
1794
|
-
$ZodCheck.init(inst, def);
|
|
1795
|
-
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
1796
|
-
const val = payload.value;
|
|
1797
|
-
return !nullish(val) && val.length !== void 0;
|
|
1798
|
-
});
|
|
1799
|
-
inst._zod.onattach.push((inst) => {
|
|
1800
|
-
const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
1801
|
-
if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
|
|
1802
|
-
});
|
|
1803
|
-
inst._zod.check = (payload) => {
|
|
1804
|
-
const input = payload.value;
|
|
1805
|
-
if (input.length >= def.minimum) return;
|
|
1806
|
-
const origin = getLengthableOrigin(input);
|
|
1807
|
-
payload.issues.push({
|
|
1808
|
-
origin,
|
|
1809
|
-
code: "too_small",
|
|
1810
|
-
minimum: def.minimum,
|
|
1811
|
-
inclusive: true,
|
|
1812
|
-
input,
|
|
1813
|
-
inst,
|
|
1814
|
-
continue: !def.abort
|
|
1815
|
-
});
|
|
1816
|
-
};
|
|
1817
|
-
});
|
|
1818
|
-
const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
1819
|
-
var _a;
|
|
1820
|
-
$ZodCheck.init(inst, def);
|
|
1821
|
-
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
1822
|
-
const val = payload.value;
|
|
1823
|
-
return !nullish(val) && val.length !== void 0;
|
|
1824
|
-
});
|
|
1825
|
-
inst._zod.onattach.push((inst) => {
|
|
1826
|
-
const bag = inst._zod.bag;
|
|
1827
|
-
bag.minimum = def.length;
|
|
1828
|
-
bag.maximum = def.length;
|
|
1829
|
-
bag.length = def.length;
|
|
1830
|
-
});
|
|
1831
|
-
inst._zod.check = (payload) => {
|
|
1832
|
-
const input = payload.value;
|
|
1833
|
-
const length = input.length;
|
|
1834
|
-
if (length === def.length) return;
|
|
1835
|
-
const origin = getLengthableOrigin(input);
|
|
1836
|
-
const tooBig = length > def.length;
|
|
1837
|
-
payload.issues.push({
|
|
1838
|
-
origin,
|
|
1839
|
-
...tooBig ? {
|
|
1840
|
-
code: "too_big",
|
|
1841
|
-
maximum: def.length
|
|
1842
|
-
} : {
|
|
1843
|
-
code: "too_small",
|
|
1844
|
-
minimum: def.length
|
|
1845
|
-
},
|
|
1846
|
-
inclusive: true,
|
|
1847
|
-
exact: true,
|
|
1848
|
-
input: payload.value,
|
|
1849
|
-
inst,
|
|
1850
|
-
continue: !def.abort
|
|
1851
|
-
});
|
|
1852
|
-
};
|
|
1853
|
-
});
|
|
1854
|
-
const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
1855
|
-
var _a, _b;
|
|
1856
|
-
$ZodCheck.init(inst, def);
|
|
1857
|
-
inst._zod.onattach.push((inst) => {
|
|
1858
|
-
const bag = inst._zod.bag;
|
|
1859
|
-
bag.format = def.format;
|
|
1860
|
-
if (def.pattern) {
|
|
1861
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1862
|
-
bag.patterns.add(def.pattern);
|
|
1863
|
-
}
|
|
1864
|
-
});
|
|
1865
|
-
if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
1866
|
-
def.pattern.lastIndex = 0;
|
|
1867
|
-
if (def.pattern.test(payload.value)) return;
|
|
1868
|
-
payload.issues.push({
|
|
1869
|
-
origin: "string",
|
|
1870
|
-
code: "invalid_format",
|
|
1871
|
-
format: def.format,
|
|
1872
|
-
input: payload.value,
|
|
1873
|
-
...def.pattern ? { pattern: def.pattern.toString() } : {},
|
|
1874
|
-
inst,
|
|
1875
|
-
continue: !def.abort
|
|
1876
|
-
});
|
|
1877
|
-
});
|
|
1878
|
-
else (_b = inst._zod).check ?? (_b.check = () => {});
|
|
1879
|
-
});
|
|
1880
|
-
const $ZodCheckRegex = /*@__PURE__*/ $constructor("$ZodCheckRegex", (inst, def) => {
|
|
1881
|
-
$ZodCheckStringFormat.init(inst, def);
|
|
1882
|
-
inst._zod.check = (payload) => {
|
|
1883
|
-
def.pattern.lastIndex = 0;
|
|
1884
|
-
if (def.pattern.test(payload.value)) return;
|
|
1885
|
-
payload.issues.push({
|
|
1886
|
-
origin: "string",
|
|
1887
|
-
code: "invalid_format",
|
|
1888
|
-
format: "regex",
|
|
1889
|
-
input: payload.value,
|
|
1890
|
-
pattern: def.pattern.toString(),
|
|
1891
|
-
inst,
|
|
1892
|
-
continue: !def.abort
|
|
1893
|
-
});
|
|
1894
|
-
};
|
|
1895
|
-
});
|
|
1896
|
-
const $ZodCheckLowerCase = /*@__PURE__*/ $constructor("$ZodCheckLowerCase", (inst, def) => {
|
|
1897
|
-
def.pattern ?? (def.pattern = lowercase);
|
|
1898
|
-
$ZodCheckStringFormat.init(inst, def);
|
|
1899
|
-
});
|
|
1900
|
-
const $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (inst, def) => {
|
|
1901
|
-
def.pattern ?? (def.pattern = uppercase);
|
|
1902
|
-
$ZodCheckStringFormat.init(inst, def);
|
|
1903
|
-
});
|
|
1904
|
-
const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
1905
|
-
$ZodCheck.init(inst, def);
|
|
1906
|
-
const escapedRegex = escapeRegex(def.includes);
|
|
1907
|
-
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
|
|
1908
|
-
def.pattern = pattern;
|
|
1909
|
-
inst._zod.onattach.push((inst) => {
|
|
1910
|
-
const bag = inst._zod.bag;
|
|
1911
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1912
|
-
bag.patterns.add(pattern);
|
|
1913
|
-
});
|
|
1914
|
-
inst._zod.check = (payload) => {
|
|
1915
|
-
if (payload.value.includes(def.includes, def.position)) return;
|
|
1916
|
-
payload.issues.push({
|
|
1917
|
-
origin: "string",
|
|
1918
|
-
code: "invalid_format",
|
|
1919
|
-
format: "includes",
|
|
1920
|
-
includes: def.includes,
|
|
1921
|
-
input: payload.value,
|
|
1922
|
-
inst,
|
|
1923
|
-
continue: !def.abort
|
|
1924
|
-
});
|
|
1925
|
-
};
|
|
1926
|
-
});
|
|
1927
|
-
const $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (inst, def) => {
|
|
1928
|
-
$ZodCheck.init(inst, def);
|
|
1929
|
-
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
1930
|
-
def.pattern ?? (def.pattern = pattern);
|
|
1931
|
-
inst._zod.onattach.push((inst) => {
|
|
1932
|
-
const bag = inst._zod.bag;
|
|
1933
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1934
|
-
bag.patterns.add(pattern);
|
|
1935
|
-
});
|
|
1936
|
-
inst._zod.check = (payload) => {
|
|
1937
|
-
if (payload.value.startsWith(def.prefix)) return;
|
|
1938
|
-
payload.issues.push({
|
|
1939
|
-
origin: "string",
|
|
1940
|
-
code: "invalid_format",
|
|
1941
|
-
format: "starts_with",
|
|
1942
|
-
prefix: def.prefix,
|
|
1943
|
-
input: payload.value,
|
|
1944
|
-
inst,
|
|
1945
|
-
continue: !def.abort
|
|
1946
|
-
});
|
|
1947
|
-
};
|
|
1948
|
-
});
|
|
1949
|
-
const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst, def) => {
|
|
1950
|
-
$ZodCheck.init(inst, def);
|
|
1951
|
-
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
1952
|
-
def.pattern ?? (def.pattern = pattern);
|
|
1953
|
-
inst._zod.onattach.push((inst) => {
|
|
1954
|
-
const bag = inst._zod.bag;
|
|
1955
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1956
|
-
bag.patterns.add(pattern);
|
|
1957
|
-
});
|
|
1958
|
-
inst._zod.check = (payload) => {
|
|
1959
|
-
if (payload.value.endsWith(def.suffix)) return;
|
|
1960
|
-
payload.issues.push({
|
|
1961
|
-
origin: "string",
|
|
1962
|
-
code: "invalid_format",
|
|
1963
|
-
format: "ends_with",
|
|
1964
|
-
suffix: def.suffix,
|
|
1965
|
-
input: payload.value,
|
|
1966
|
-
inst,
|
|
1967
|
-
continue: !def.abort
|
|
1968
|
-
});
|
|
1969
|
-
};
|
|
1970
|
-
});
|
|
1971
|
-
const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
1972
|
-
$ZodCheck.init(inst, def);
|
|
1973
|
-
inst._zod.check = (payload) => {
|
|
1974
|
-
payload.value = def.tx(payload.value);
|
|
1975
|
-
};
|
|
1976
|
-
});
|
|
1977
|
-
//#endregion
|
|
1978
|
-
//#region ../src/node_modules/zod/v4/core/doc.js
|
|
1979
|
-
var Doc = class {
|
|
1980
|
-
constructor(args = []) {
|
|
1981
|
-
this.content = [];
|
|
1982
|
-
this.indent = 0;
|
|
1983
|
-
if (this) this.args = args;
|
|
1984
|
-
}
|
|
1985
|
-
indented(fn) {
|
|
1986
|
-
this.indent += 1;
|
|
1987
|
-
fn(this);
|
|
1988
|
-
this.indent -= 1;
|
|
1989
|
-
}
|
|
1990
|
-
write(arg) {
|
|
1991
|
-
if (typeof arg === "function") {
|
|
1992
|
-
arg(this, { execution: "sync" });
|
|
1993
|
-
arg(this, { execution: "async" });
|
|
1994
|
-
return;
|
|
1995
|
-
}
|
|
1996
|
-
const lines = arg.split("\n").filter((x) => x);
|
|
1997
|
-
const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
|
|
1998
|
-
const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
|
|
1999
|
-
for (const line of dedented) this.content.push(line);
|
|
2000
|
-
}
|
|
2001
|
-
compile() {
|
|
2002
|
-
const F = Function;
|
|
2003
|
-
const args = this?.args;
|
|
2004
|
-
const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
|
|
2005
|
-
return new F(...args, lines.join("\n"));
|
|
2006
|
-
}
|
|
2007
|
-
};
|
|
2008
|
-
//#endregion
|
|
2009
|
-
//#region ../src/node_modules/zod/v4/core/versions.js
|
|
2010
|
-
const version = {
|
|
2011
|
-
major: 4,
|
|
2012
|
-
minor: 4,
|
|
2013
|
-
patch: 3
|
|
2014
|
-
};
|
|
2015
|
-
//#endregion
|
|
2016
|
-
//#region ../src/node_modules/zod/v4/core/schemas.js
|
|
2017
|
-
const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
2018
|
-
var _a;
|
|
2019
|
-
inst ?? (inst = {});
|
|
2020
|
-
inst._zod.def = def;
|
|
2021
|
-
inst._zod.bag = inst._zod.bag || {};
|
|
2022
|
-
inst._zod.version = version;
|
|
2023
|
-
const checks = [...inst._zod.def.checks ?? []];
|
|
2024
|
-
if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
|
|
2025
|
-
for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
|
|
2026
|
-
if (checks.length === 0) {
|
|
2027
|
-
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
2028
|
-
inst._zod.deferred?.push(() => {
|
|
2029
|
-
inst._zod.run = inst._zod.parse;
|
|
2030
|
-
});
|
|
2031
|
-
} else {
|
|
2032
|
-
const runChecks = (payload, checks, ctx) => {
|
|
2033
|
-
let isAborted = aborted(payload);
|
|
2034
|
-
let asyncResult;
|
|
2035
|
-
for (const ch of checks) {
|
|
2036
|
-
if (ch._zod.def.when) {
|
|
2037
|
-
if (explicitlyAborted(payload)) continue;
|
|
2038
|
-
if (!ch._zod.def.when(payload)) continue;
|
|
2039
|
-
} else if (isAborted) continue;
|
|
2040
|
-
const currLen = payload.issues.length;
|
|
2041
|
-
const _ = ch._zod.check(payload);
|
|
2042
|
-
if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
|
|
2043
|
-
if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
2044
|
-
await _;
|
|
2045
|
-
if (payload.issues.length === currLen) return;
|
|
2046
|
-
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
2047
|
-
});
|
|
2048
|
-
else {
|
|
2049
|
-
if (payload.issues.length === currLen) continue;
|
|
2050
|
-
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
2051
|
-
}
|
|
2052
|
-
}
|
|
2053
|
-
if (asyncResult) return asyncResult.then(() => {
|
|
2054
|
-
return payload;
|
|
2055
|
-
});
|
|
2056
|
-
return payload;
|
|
2057
|
-
};
|
|
2058
|
-
const handleCanaryResult = (canary, payload, ctx) => {
|
|
2059
|
-
if (aborted(canary)) {
|
|
2060
|
-
canary.aborted = true;
|
|
2061
|
-
return canary;
|
|
2062
|
-
}
|
|
2063
|
-
const checkResult = runChecks(payload, checks, ctx);
|
|
2064
|
-
if (checkResult instanceof Promise) {
|
|
2065
|
-
if (ctx.async === false) throw new $ZodAsyncError();
|
|
2066
|
-
return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
|
|
2067
|
-
}
|
|
2068
|
-
return inst._zod.parse(checkResult, ctx);
|
|
2069
|
-
};
|
|
2070
|
-
inst._zod.run = (payload, ctx) => {
|
|
2071
|
-
if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
|
|
2072
|
-
if (ctx.direction === "backward") {
|
|
2073
|
-
const canary = inst._zod.parse({
|
|
2074
|
-
value: payload.value,
|
|
2075
|
-
issues: []
|
|
2076
|
-
}, {
|
|
2077
|
-
...ctx,
|
|
2078
|
-
skipChecks: true
|
|
2079
|
-
});
|
|
2080
|
-
if (canary instanceof Promise) return canary.then((canary) => {
|
|
2081
|
-
return handleCanaryResult(canary, payload, ctx);
|
|
2082
|
-
});
|
|
2083
|
-
return handleCanaryResult(canary, payload, ctx);
|
|
2084
|
-
}
|
|
2085
|
-
const result = inst._zod.parse(payload, ctx);
|
|
2086
|
-
if (result instanceof Promise) {
|
|
2087
|
-
if (ctx.async === false) throw new $ZodAsyncError();
|
|
2088
|
-
return result.then((result) => runChecks(result, checks, ctx));
|
|
2089
|
-
}
|
|
2090
|
-
return runChecks(result, checks, ctx);
|
|
2091
|
-
};
|
|
2092
|
-
}
|
|
2093
|
-
defineLazy(inst, "~standard", () => ({
|
|
2094
|
-
validate: (value) => {
|
|
2095
|
-
try {
|
|
2096
|
-
const r = safeParse$1(inst, value);
|
|
2097
|
-
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
2098
|
-
} catch (_) {
|
|
2099
|
-
return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
|
|
2100
|
-
}
|
|
2101
|
-
},
|
|
2102
|
-
vendor: "zod",
|
|
2103
|
-
version: 1
|
|
2104
|
-
}));
|
|
2105
|
-
});
|
|
2106
|
-
const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
|
|
2107
|
-
$ZodType.init(inst, def);
|
|
2108
|
-
inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
|
|
2109
|
-
inst._zod.parse = (payload, _) => {
|
|
2110
|
-
if (def.coerce) try {
|
|
2111
|
-
payload.value = String(payload.value);
|
|
2112
|
-
} catch (_) {}
|
|
2113
|
-
if (typeof payload.value === "string") return payload;
|
|
2114
|
-
payload.issues.push({
|
|
2115
|
-
expected: "string",
|
|
2116
|
-
code: "invalid_type",
|
|
2117
|
-
input: payload.value,
|
|
2118
|
-
inst
|
|
2119
|
-
});
|
|
2120
|
-
return payload;
|
|
2121
|
-
};
|
|
2122
|
-
});
|
|
2123
|
-
const $ZodStringFormat = /*@__PURE__*/ $constructor("$ZodStringFormat", (inst, def) => {
|
|
2124
|
-
$ZodCheckStringFormat.init(inst, def);
|
|
2125
|
-
$ZodString.init(inst, def);
|
|
2126
|
-
});
|
|
2127
|
-
const $ZodGUID = /*@__PURE__*/ $constructor("$ZodGUID", (inst, def) => {
|
|
2128
|
-
def.pattern ?? (def.pattern = guid);
|
|
2129
|
-
$ZodStringFormat.init(inst, def);
|
|
2130
|
-
});
|
|
2131
|
-
const $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (inst, def) => {
|
|
2132
|
-
if (def.version) {
|
|
2133
|
-
const v = {
|
|
2134
|
-
v1: 1,
|
|
2135
|
-
v2: 2,
|
|
2136
|
-
v3: 3,
|
|
2137
|
-
v4: 4,
|
|
2138
|
-
v5: 5,
|
|
2139
|
-
v6: 6,
|
|
2140
|
-
v7: 7,
|
|
2141
|
-
v8: 8
|
|
2142
|
-
}[def.version];
|
|
2143
|
-
if (v === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
2144
|
-
def.pattern ?? (def.pattern = uuid(v));
|
|
2145
|
-
} else def.pattern ?? (def.pattern = uuid());
|
|
2146
|
-
$ZodStringFormat.init(inst, def);
|
|
2147
|
-
});
|
|
2148
|
-
const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
|
|
2149
|
-
def.pattern ?? (def.pattern = email);
|
|
2150
|
-
$ZodStringFormat.init(inst, def);
|
|
2151
|
-
});
|
|
2152
|
-
const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
|
|
2153
|
-
$ZodStringFormat.init(inst, def);
|
|
2154
|
-
inst._zod.check = (payload) => {
|
|
2155
|
-
try {
|
|
2156
|
-
const trimmed = payload.value.trim();
|
|
2157
|
-
if (!def.normalize && def.protocol?.source === httpProtocol.source) {
|
|
2158
|
-
if (!/^https?:\/\//i.test(trimmed)) {
|
|
2159
|
-
payload.issues.push({
|
|
2160
|
-
code: "invalid_format",
|
|
2161
|
-
format: "url",
|
|
2162
|
-
note: "Invalid URL format",
|
|
2163
|
-
input: payload.value,
|
|
2164
|
-
inst,
|
|
2165
|
-
continue: !def.abort
|
|
2166
|
-
});
|
|
2167
|
-
return;
|
|
2168
|
-
}
|
|
2169
|
-
}
|
|
2170
|
-
const url = new URL(trimmed);
|
|
2171
|
-
if (def.hostname) {
|
|
2172
|
-
def.hostname.lastIndex = 0;
|
|
2173
|
-
if (!def.hostname.test(url.hostname)) payload.issues.push({
|
|
2174
|
-
code: "invalid_format",
|
|
2175
|
-
format: "url",
|
|
2176
|
-
note: "Invalid hostname",
|
|
2177
|
-
pattern: def.hostname.source,
|
|
2178
|
-
input: payload.value,
|
|
2179
|
-
inst,
|
|
2180
|
-
continue: !def.abort
|
|
2181
|
-
});
|
|
2182
|
-
}
|
|
2183
|
-
if (def.protocol) {
|
|
2184
|
-
def.protocol.lastIndex = 0;
|
|
2185
|
-
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
|
|
2186
|
-
code: "invalid_format",
|
|
2187
|
-
format: "url",
|
|
2188
|
-
note: "Invalid protocol",
|
|
2189
|
-
pattern: def.protocol.source,
|
|
2190
|
-
input: payload.value,
|
|
2191
|
-
inst,
|
|
2192
|
-
continue: !def.abort
|
|
2193
|
-
});
|
|
2194
|
-
}
|
|
2195
|
-
if (def.normalize) payload.value = url.href;
|
|
2196
|
-
else payload.value = trimmed;
|
|
2197
|
-
return;
|
|
2198
|
-
} catch (_) {
|
|
2199
|
-
payload.issues.push({
|
|
2200
|
-
code: "invalid_format",
|
|
2201
|
-
format: "url",
|
|
2202
|
-
input: payload.value,
|
|
2203
|
-
inst,
|
|
2204
|
-
continue: !def.abort
|
|
2205
|
-
});
|
|
2206
|
-
}
|
|
2207
|
-
};
|
|
2208
|
-
});
|
|
2209
|
-
const $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def) => {
|
|
2210
|
-
def.pattern ?? (def.pattern = emoji());
|
|
2211
|
-
$ZodStringFormat.init(inst, def);
|
|
2212
|
-
});
|
|
2213
|
-
const $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
|
|
2214
|
-
def.pattern ?? (def.pattern = nanoid);
|
|
2215
|
-
$ZodStringFormat.init(inst, def);
|
|
2216
|
-
});
|
|
2217
|
-
/**
|
|
2218
|
-
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
2219
|
-
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
2220
|
-
* See https://github.com/paralleldrive/cuid.
|
|
2221
|
-
*/
|
|
2222
|
-
const $ZodCUID = /*@__PURE__*/ $constructor("$ZodCUID", (inst, def) => {
|
|
2223
|
-
def.pattern ?? (def.pattern = cuid);
|
|
2224
|
-
$ZodStringFormat.init(inst, def);
|
|
2225
|
-
});
|
|
2226
|
-
const $ZodCUID2 = /*@__PURE__*/ $constructor("$ZodCUID2", (inst, def) => {
|
|
2227
|
-
def.pattern ?? (def.pattern = cuid2);
|
|
2228
|
-
$ZodStringFormat.init(inst, def);
|
|
2229
|
-
});
|
|
2230
|
-
const $ZodULID = /*@__PURE__*/ $constructor("$ZodULID", (inst, def) => {
|
|
2231
|
-
def.pattern ?? (def.pattern = ulid);
|
|
2232
|
-
$ZodStringFormat.init(inst, def);
|
|
2233
|
-
});
|
|
2234
|
-
const $ZodXID = /*@__PURE__*/ $constructor("$ZodXID", (inst, def) => {
|
|
2235
|
-
def.pattern ?? (def.pattern = xid);
|
|
2236
|
-
$ZodStringFormat.init(inst, def);
|
|
2237
|
-
});
|
|
2238
|
-
const $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
|
|
2239
|
-
def.pattern ?? (def.pattern = ksuid);
|
|
2240
|
-
$ZodStringFormat.init(inst, def);
|
|
2241
|
-
});
|
|
2242
|
-
const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
|
|
2243
|
-
def.pattern ?? (def.pattern = datetime$1(def));
|
|
2244
|
-
$ZodStringFormat.init(inst, def);
|
|
2245
|
-
});
|
|
2246
|
-
const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
|
|
2247
|
-
def.pattern ?? (def.pattern = date$1);
|
|
2248
|
-
$ZodStringFormat.init(inst, def);
|
|
2249
|
-
});
|
|
2250
|
-
const $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
|
|
2251
|
-
def.pattern ?? (def.pattern = time$1(def));
|
|
2252
|
-
$ZodStringFormat.init(inst, def);
|
|
2253
|
-
});
|
|
2254
|
-
const $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
|
|
2255
|
-
def.pattern ?? (def.pattern = duration$1);
|
|
2256
|
-
$ZodStringFormat.init(inst, def);
|
|
2257
|
-
});
|
|
2258
|
-
const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
|
|
2259
|
-
def.pattern ?? (def.pattern = ipv4);
|
|
2260
|
-
$ZodStringFormat.init(inst, def);
|
|
2261
|
-
inst._zod.bag.format = `ipv4`;
|
|
2262
|
-
});
|
|
2263
|
-
const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
|
|
2264
|
-
def.pattern ?? (def.pattern = ipv6);
|
|
2265
|
-
$ZodStringFormat.init(inst, def);
|
|
2266
|
-
inst._zod.bag.format = `ipv6`;
|
|
2267
|
-
inst._zod.check = (payload) => {
|
|
2268
|
-
try {
|
|
2269
|
-
new URL(`http://[${payload.value}]`);
|
|
2270
|
-
} catch {
|
|
2271
|
-
payload.issues.push({
|
|
2272
|
-
code: "invalid_format",
|
|
2273
|
-
format: "ipv6",
|
|
2274
|
-
input: payload.value,
|
|
2275
|
-
inst,
|
|
2276
|
-
continue: !def.abort
|
|
2277
|
-
});
|
|
2278
|
-
}
|
|
2279
|
-
};
|
|
2280
|
-
});
|
|
2281
|
-
const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
2282
|
-
def.pattern ?? (def.pattern = cidrv4);
|
|
2283
|
-
$ZodStringFormat.init(inst, def);
|
|
2284
|
-
});
|
|
2285
|
-
const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
2286
|
-
def.pattern ?? (def.pattern = cidrv6);
|
|
2287
|
-
$ZodStringFormat.init(inst, def);
|
|
2288
|
-
inst._zod.check = (payload) => {
|
|
2289
|
-
const parts = payload.value.split("/");
|
|
2290
|
-
try {
|
|
2291
|
-
if (parts.length !== 2) throw new Error();
|
|
2292
|
-
const [address, prefix] = parts;
|
|
2293
|
-
if (!prefix) throw new Error();
|
|
2294
|
-
const prefixNum = Number(prefix);
|
|
2295
|
-
if (`${prefixNum}` !== prefix) throw new Error();
|
|
2296
|
-
if (prefixNum < 0 || prefixNum > 128) throw new Error();
|
|
2297
|
-
new URL(`http://[${address}]`);
|
|
2298
|
-
} catch {
|
|
2299
|
-
payload.issues.push({
|
|
2300
|
-
code: "invalid_format",
|
|
2301
|
-
format: "cidrv6",
|
|
2302
|
-
input: payload.value,
|
|
2303
|
-
inst,
|
|
2304
|
-
continue: !def.abort
|
|
2305
|
-
});
|
|
2306
|
-
}
|
|
2307
|
-
};
|
|
2308
|
-
});
|
|
2309
|
-
function isValidBase64(data) {
|
|
2310
|
-
if (data === "") return true;
|
|
2311
|
-
if (/\s/.test(data)) return false;
|
|
2312
|
-
if (data.length % 4 !== 0) return false;
|
|
2313
|
-
try {
|
|
2314
|
-
atob(data);
|
|
2315
|
-
return true;
|
|
2316
|
-
} catch {
|
|
2317
|
-
return false;
|
|
2318
|
-
}
|
|
2319
|
-
}
|
|
2320
|
-
const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
|
|
2321
|
-
def.pattern ?? (def.pattern = base64);
|
|
2322
|
-
$ZodStringFormat.init(inst, def);
|
|
2323
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
2324
|
-
inst._zod.check = (payload) => {
|
|
2325
|
-
if (isValidBase64(payload.value)) return;
|
|
2326
|
-
payload.issues.push({
|
|
2327
|
-
code: "invalid_format",
|
|
2328
|
-
format: "base64",
|
|
2329
|
-
input: payload.value,
|
|
2330
|
-
inst,
|
|
2331
|
-
continue: !def.abort
|
|
2332
|
-
});
|
|
2333
|
-
};
|
|
2334
|
-
});
|
|
2335
|
-
function isValidBase64URL(data) {
|
|
2336
|
-
if (!base64url.test(data)) return false;
|
|
2337
|
-
const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
2338
|
-
return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
|
|
2339
|
-
}
|
|
2340
|
-
const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
|
|
2341
|
-
def.pattern ?? (def.pattern = base64url);
|
|
2342
|
-
$ZodStringFormat.init(inst, def);
|
|
2343
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
2344
|
-
inst._zod.check = (payload) => {
|
|
2345
|
-
if (isValidBase64URL(payload.value)) return;
|
|
2346
|
-
payload.issues.push({
|
|
2347
|
-
code: "invalid_format",
|
|
2348
|
-
format: "base64url",
|
|
2349
|
-
input: payload.value,
|
|
2350
|
-
inst,
|
|
2351
|
-
continue: !def.abort
|
|
2352
|
-
});
|
|
2353
|
-
};
|
|
2354
|
-
});
|
|
2355
|
-
const $ZodE164 = /*@__PURE__*/ $constructor("$ZodE164", (inst, def) => {
|
|
2356
|
-
def.pattern ?? (def.pattern = e164);
|
|
2357
|
-
$ZodStringFormat.init(inst, def);
|
|
2358
|
-
});
|
|
2359
|
-
function isValidJWT(token, algorithm = null) {
|
|
2360
|
-
try {
|
|
2361
|
-
const tokensParts = token.split(".");
|
|
2362
|
-
if (tokensParts.length !== 3) return false;
|
|
2363
|
-
const [header] = tokensParts;
|
|
2364
|
-
if (!header) return false;
|
|
2365
|
-
const parsedHeader = JSON.parse(atob(header));
|
|
2366
|
-
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
|
|
2367
|
-
if (!parsedHeader.alg) return false;
|
|
2368
|
-
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
|
|
2369
|
-
return true;
|
|
2370
|
-
} catch {
|
|
2371
|
-
return false;
|
|
2372
|
-
}
|
|
2373
|
-
}
|
|
2374
|
-
const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
|
|
2375
|
-
$ZodStringFormat.init(inst, def);
|
|
2376
|
-
inst._zod.check = (payload) => {
|
|
2377
|
-
if (isValidJWT(payload.value, def.alg)) return;
|
|
2378
|
-
payload.issues.push({
|
|
2379
|
-
code: "invalid_format",
|
|
2380
|
-
format: "jwt",
|
|
2381
|
-
input: payload.value,
|
|
2382
|
-
inst,
|
|
2383
|
-
continue: !def.abort
|
|
2384
|
-
});
|
|
2385
|
-
};
|
|
2386
|
-
});
|
|
2387
|
-
const $ZodBoolean = /*@__PURE__*/ $constructor("$ZodBoolean", (inst, def) => {
|
|
2388
|
-
$ZodType.init(inst, def);
|
|
2389
|
-
inst._zod.pattern = boolean$1;
|
|
2390
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
2391
|
-
if (def.coerce) try {
|
|
2392
|
-
payload.value = Boolean(payload.value);
|
|
2393
|
-
} catch (_) {}
|
|
2394
|
-
const input = payload.value;
|
|
2395
|
-
if (typeof input === "boolean") return payload;
|
|
2396
|
-
payload.issues.push({
|
|
2397
|
-
expected: "boolean",
|
|
2398
|
-
code: "invalid_type",
|
|
2399
|
-
input,
|
|
2400
|
-
inst
|
|
2401
|
-
});
|
|
2402
|
-
return payload;
|
|
2403
|
-
};
|
|
2404
|
-
});
|
|
2405
|
-
const $ZodUnknown = /*@__PURE__*/ $constructor("$ZodUnknown", (inst, def) => {
|
|
2406
|
-
$ZodType.init(inst, def);
|
|
2407
|
-
inst._zod.parse = (payload) => payload;
|
|
2408
|
-
});
|
|
2409
|
-
const $ZodNever = /*@__PURE__*/ $constructor("$ZodNever", (inst, def) => {
|
|
2410
|
-
$ZodType.init(inst, def);
|
|
2411
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
2412
|
-
payload.issues.push({
|
|
2413
|
-
expected: "never",
|
|
2414
|
-
code: "invalid_type",
|
|
2415
|
-
input: payload.value,
|
|
2416
|
-
inst
|
|
2417
|
-
});
|
|
2418
|
-
return payload;
|
|
2419
|
-
};
|
|
2420
|
-
});
|
|
2421
|
-
const $ZodVoid = /*@__PURE__*/ $constructor("$ZodVoid", (inst, def) => {
|
|
2422
|
-
$ZodType.init(inst, def);
|
|
2423
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
2424
|
-
const input = payload.value;
|
|
2425
|
-
if (typeof input === "undefined") return payload;
|
|
2426
|
-
payload.issues.push({
|
|
2427
|
-
expected: "void",
|
|
2428
|
-
code: "invalid_type",
|
|
2429
|
-
input,
|
|
2430
|
-
inst
|
|
2431
|
-
});
|
|
2432
|
-
return payload;
|
|
2433
|
-
};
|
|
2434
|
-
});
|
|
2435
|
-
function handleArrayResult(result, final, index) {
|
|
2436
|
-
if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
|
|
2437
|
-
final.value[index] = result.value;
|
|
2438
|
-
}
|
|
2439
|
-
const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
|
|
2440
|
-
$ZodType.init(inst, def);
|
|
2441
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2442
|
-
const input = payload.value;
|
|
2443
|
-
if (!Array.isArray(input)) {
|
|
2444
|
-
payload.issues.push({
|
|
2445
|
-
expected: "array",
|
|
2446
|
-
code: "invalid_type",
|
|
2447
|
-
input,
|
|
2448
|
-
inst
|
|
2449
|
-
});
|
|
2450
|
-
return payload;
|
|
2451
|
-
}
|
|
2452
|
-
payload.value = Array(input.length);
|
|
2453
|
-
const proms = [];
|
|
2454
|
-
for (let i = 0; i < input.length; i++) {
|
|
2455
|
-
const item = input[i];
|
|
2456
|
-
const result = def.element._zod.run({
|
|
2457
|
-
value: item,
|
|
2458
|
-
issues: []
|
|
2459
|
-
}, ctx);
|
|
2460
|
-
if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
|
2461
|
-
else handleArrayResult(result, payload, i);
|
|
2462
|
-
}
|
|
2463
|
-
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
2464
|
-
return payload;
|
|
2465
|
-
};
|
|
2466
|
-
});
|
|
2467
|
-
function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
|
|
2468
|
-
const isPresent = key in input;
|
|
2469
|
-
if (result.issues.length) {
|
|
2470
|
-
if (isOptionalIn && isOptionalOut && !isPresent) return;
|
|
2471
|
-
final.issues.push(...prefixIssues(key, result.issues));
|
|
2472
|
-
}
|
|
2473
|
-
if (!isPresent && !isOptionalIn) {
|
|
2474
|
-
if (!result.issues.length) final.issues.push({
|
|
2475
|
-
code: "invalid_type",
|
|
2476
|
-
expected: "nonoptional",
|
|
2477
|
-
input: void 0,
|
|
2478
|
-
path: [key]
|
|
2479
|
-
});
|
|
2480
|
-
return;
|
|
2481
|
-
}
|
|
2482
|
-
if (result.value === void 0) {
|
|
2483
|
-
if (isPresent) final.value[key] = void 0;
|
|
2484
|
-
} else final.value[key] = result.value;
|
|
2485
|
-
}
|
|
2486
|
-
function normalizeDef(def) {
|
|
2487
|
-
const keys = Object.keys(def.shape);
|
|
2488
|
-
for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
2489
|
-
const okeys = optionalKeys(def.shape);
|
|
2490
|
-
return {
|
|
2491
|
-
...def,
|
|
2492
|
-
keys,
|
|
2493
|
-
keySet: new Set(keys),
|
|
2494
|
-
numKeys: keys.length,
|
|
2495
|
-
optionalKeys: new Set(okeys)
|
|
2496
|
-
};
|
|
2497
|
-
}
|
|
2498
|
-
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
2499
|
-
const unrecognized = [];
|
|
2500
|
-
const keySet = def.keySet;
|
|
2501
|
-
const _catchall = def.catchall._zod;
|
|
2502
|
-
const t = _catchall.def.type;
|
|
2503
|
-
const isOptionalIn = _catchall.optin === "optional";
|
|
2504
|
-
const isOptionalOut = _catchall.optout === "optional";
|
|
2505
|
-
for (const key in input) {
|
|
2506
|
-
if (key === "__proto__") continue;
|
|
2507
|
-
if (keySet.has(key)) continue;
|
|
2508
|
-
if (t === "never") {
|
|
2509
|
-
unrecognized.push(key);
|
|
2510
|
-
continue;
|
|
2511
|
-
}
|
|
2512
|
-
const r = _catchall.run({
|
|
2513
|
-
value: input[key],
|
|
2514
|
-
issues: []
|
|
2515
|
-
}, ctx);
|
|
2516
|
-
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
2517
|
-
else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
2518
|
-
}
|
|
2519
|
-
if (unrecognized.length) payload.issues.push({
|
|
2520
|
-
code: "unrecognized_keys",
|
|
2521
|
-
keys: unrecognized,
|
|
2522
|
-
input,
|
|
2523
|
-
inst
|
|
2524
|
-
});
|
|
2525
|
-
if (!proms.length) return payload;
|
|
2526
|
-
return Promise.all(proms).then(() => {
|
|
2527
|
-
return payload;
|
|
2528
|
-
});
|
|
2529
|
-
}
|
|
2530
|
-
const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
2531
|
-
$ZodType.init(inst, def);
|
|
2532
|
-
if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
|
|
2533
|
-
const sh = def.shape;
|
|
2534
|
-
Object.defineProperty(def, "shape", { get: () => {
|
|
2535
|
-
const newSh = { ...sh };
|
|
2536
|
-
Object.defineProperty(def, "shape", { value: newSh });
|
|
2537
|
-
return newSh;
|
|
2538
|
-
} });
|
|
2539
|
-
}
|
|
2540
|
-
const _normalized = cached(() => normalizeDef(def));
|
|
2541
|
-
defineLazy(inst._zod, "propValues", () => {
|
|
2542
|
-
const shape = def.shape;
|
|
2543
|
-
const propValues = {};
|
|
2544
|
-
for (const key in shape) {
|
|
2545
|
-
const field = shape[key]._zod;
|
|
2546
|
-
if (field.values) {
|
|
2547
|
-
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
2548
|
-
for (const v of field.values) propValues[key].add(v);
|
|
2549
|
-
}
|
|
2550
|
-
}
|
|
2551
|
-
return propValues;
|
|
2552
|
-
});
|
|
2553
|
-
const isObject$2 = isObject;
|
|
2554
|
-
const catchall = def.catchall;
|
|
2555
|
-
let value;
|
|
2556
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2557
|
-
value ?? (value = _normalized.value);
|
|
2558
|
-
const input = payload.value;
|
|
2559
|
-
if (!isObject$2(input)) {
|
|
2560
|
-
payload.issues.push({
|
|
2561
|
-
expected: "object",
|
|
2562
|
-
code: "invalid_type",
|
|
2563
|
-
input,
|
|
2564
|
-
inst
|
|
2565
|
-
});
|
|
2566
|
-
return payload;
|
|
2567
|
-
}
|
|
2568
|
-
payload.value = {};
|
|
2569
|
-
const proms = [];
|
|
2570
|
-
const shape = value.shape;
|
|
2571
|
-
for (const key of value.keys) {
|
|
2572
|
-
const el = shape[key];
|
|
2573
|
-
const isOptionalIn = el._zod.optin === "optional";
|
|
2574
|
-
const isOptionalOut = el._zod.optout === "optional";
|
|
2575
|
-
const r = el._zod.run({
|
|
2576
|
-
value: input[key],
|
|
2577
|
-
issues: []
|
|
2578
|
-
}, ctx);
|
|
2579
|
-
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
2580
|
-
else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
2581
|
-
}
|
|
2582
|
-
if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
2583
|
-
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
2584
|
-
};
|
|
2585
|
-
});
|
|
2586
|
-
const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
2587
|
-
$ZodObject.init(inst, def);
|
|
2588
|
-
const superParse = inst._zod.parse;
|
|
2589
|
-
const _normalized = cached(() => normalizeDef(def));
|
|
2590
|
-
const generateFastpass = (shape) => {
|
|
2591
|
-
const doc = new Doc([
|
|
2592
|
-
"shape",
|
|
2593
|
-
"payload",
|
|
2594
|
-
"ctx"
|
|
2595
|
-
]);
|
|
2596
|
-
const normalized = _normalized.value;
|
|
2597
|
-
const parseStr = (key) => {
|
|
2598
|
-
const k = esc(key);
|
|
2599
|
-
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
2600
|
-
};
|
|
2601
|
-
doc.write(`const input = payload.value;`);
|
|
2602
|
-
const ids = Object.create(null);
|
|
2603
|
-
let counter = 0;
|
|
2604
|
-
for (const key of normalized.keys) ids[key] = `key_${counter++}`;
|
|
2605
|
-
doc.write(`const newResult = {};`);
|
|
2606
|
-
for (const key of normalized.keys) {
|
|
2607
|
-
const id = ids[key];
|
|
2608
|
-
const k = esc(key);
|
|
2609
|
-
const schema = shape[key];
|
|
2610
|
-
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
2611
|
-
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
2612
|
-
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
2613
|
-
if (isOptionalIn && isOptionalOut) doc.write(`
|
|
2614
|
-
if (${id}.issues.length) {
|
|
2615
|
-
if (${k} in input) {
|
|
2616
|
-
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
2617
|
-
...iss,
|
|
2618
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
2619
|
-
})));
|
|
2620
|
-
}
|
|
2621
|
-
}
|
|
2622
|
-
|
|
2623
|
-
if (${id}.value === undefined) {
|
|
2624
|
-
if (${k} in input) {
|
|
2625
|
-
newResult[${k}] = undefined;
|
|
2626
|
-
}
|
|
2627
|
-
} else {
|
|
2628
|
-
newResult[${k}] = ${id}.value;
|
|
2629
|
-
}
|
|
2630
|
-
|
|
2631
|
-
`);
|
|
2632
|
-
else if (!isOptionalIn) doc.write(`
|
|
2633
|
-
const ${id}_present = ${k} in input;
|
|
2634
|
-
if (${id}.issues.length) {
|
|
2635
|
-
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
2636
|
-
...iss,
|
|
2637
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
2638
|
-
})));
|
|
2639
|
-
}
|
|
2640
|
-
if (!${id}_present && !${id}.issues.length) {
|
|
2641
|
-
payload.issues.push({
|
|
2642
|
-
code: "invalid_type",
|
|
2643
|
-
expected: "nonoptional",
|
|
2644
|
-
input: undefined,
|
|
2645
|
-
path: [${k}]
|
|
2646
|
-
});
|
|
2647
|
-
}
|
|
2648
|
-
|
|
2649
|
-
if (${id}_present) {
|
|
2650
|
-
if (${id}.value === undefined) {
|
|
2651
|
-
newResult[${k}] = undefined;
|
|
2652
|
-
} else {
|
|
2653
|
-
newResult[${k}] = ${id}.value;
|
|
2654
|
-
}
|
|
2655
|
-
}
|
|
2656
|
-
|
|
2657
|
-
`);
|
|
2658
|
-
else doc.write(`
|
|
2659
|
-
if (${id}.issues.length) {
|
|
2660
|
-
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
2661
|
-
...iss,
|
|
2662
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
2663
|
-
})));
|
|
2664
|
-
}
|
|
2665
|
-
|
|
2666
|
-
if (${id}.value === undefined) {
|
|
2667
|
-
if (${k} in input) {
|
|
2668
|
-
newResult[${k}] = undefined;
|
|
2669
|
-
}
|
|
2670
|
-
} else {
|
|
2671
|
-
newResult[${k}] = ${id}.value;
|
|
2672
|
-
}
|
|
2673
|
-
|
|
2674
|
-
`);
|
|
2675
|
-
}
|
|
2676
|
-
doc.write(`payload.value = newResult;`);
|
|
2677
|
-
doc.write(`return payload;`);
|
|
2678
|
-
const fn = doc.compile();
|
|
2679
|
-
return (payload, ctx) => fn(shape, payload, ctx);
|
|
2680
|
-
};
|
|
2681
|
-
let fastpass;
|
|
2682
|
-
const isObject$1 = isObject;
|
|
2683
|
-
const jit = !globalConfig.jitless;
|
|
2684
|
-
const fastEnabled = jit && allowsEval.value;
|
|
2685
|
-
const catchall = def.catchall;
|
|
2686
|
-
let value;
|
|
2687
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2688
|
-
value ?? (value = _normalized.value);
|
|
2689
|
-
const input = payload.value;
|
|
2690
|
-
if (!isObject$1(input)) {
|
|
2691
|
-
payload.issues.push({
|
|
2692
|
-
expected: "object",
|
|
2693
|
-
code: "invalid_type",
|
|
2694
|
-
input,
|
|
2695
|
-
inst
|
|
2696
|
-
});
|
|
2697
|
-
return payload;
|
|
2698
|
-
}
|
|
2699
|
-
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
|
2700
|
-
if (!fastpass) fastpass = generateFastpass(def.shape);
|
|
2701
|
-
payload = fastpass(payload, ctx);
|
|
2702
|
-
if (!catchall) return payload;
|
|
2703
|
-
return handleCatchall([], input, payload, ctx, value, inst);
|
|
2704
|
-
}
|
|
2705
|
-
return superParse(payload, ctx);
|
|
2706
|
-
};
|
|
2707
|
-
});
|
|
2708
|
-
function handleUnionResults(results, final, inst, ctx) {
|
|
2709
|
-
for (const result of results) if (result.issues.length === 0) {
|
|
2710
|
-
final.value = result.value;
|
|
2711
|
-
return final;
|
|
2712
|
-
}
|
|
2713
|
-
const nonaborted = results.filter((r) => !aborted(r));
|
|
2714
|
-
if (nonaborted.length === 1) {
|
|
2715
|
-
final.value = nonaborted[0].value;
|
|
2716
|
-
return nonaborted[0];
|
|
2717
|
-
}
|
|
2718
|
-
final.issues.push({
|
|
2719
|
-
code: "invalid_union",
|
|
2720
|
-
input: final.value,
|
|
2721
|
-
inst,
|
|
2722
|
-
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
2723
|
-
});
|
|
2724
|
-
return final;
|
|
2725
|
-
}
|
|
2726
|
-
const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
|
|
2727
|
-
$ZodType.init(inst, def);
|
|
2728
|
-
defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
|
|
2729
|
-
defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
|
|
2730
|
-
defineLazy(inst._zod, "values", () => {
|
|
2731
|
-
if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
2732
|
-
});
|
|
2733
|
-
defineLazy(inst._zod, "pattern", () => {
|
|
2734
|
-
if (def.options.every((o) => o._zod.pattern)) {
|
|
2735
|
-
const patterns = def.options.map((o) => o._zod.pattern);
|
|
2736
|
-
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
2737
|
-
}
|
|
2738
|
-
});
|
|
2739
|
-
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
2740
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2741
|
-
if (first) return first(payload, ctx);
|
|
2742
|
-
let async = false;
|
|
2743
|
-
const results = [];
|
|
2744
|
-
for (const option of def.options) {
|
|
2745
|
-
const result = option._zod.run({
|
|
2746
|
-
value: payload.value,
|
|
2747
|
-
issues: []
|
|
2748
|
-
}, ctx);
|
|
2749
|
-
if (result instanceof Promise) {
|
|
2750
|
-
results.push(result);
|
|
2751
|
-
async = true;
|
|
2752
|
-
} else {
|
|
2753
|
-
if (result.issues.length === 0) return result;
|
|
2754
|
-
results.push(result);
|
|
2755
|
-
}
|
|
2756
|
-
}
|
|
2757
|
-
if (!async) return handleUnionResults(results, payload, inst, ctx);
|
|
2758
|
-
return Promise.all(results).then((results) => {
|
|
2759
|
-
return handleUnionResults(results, payload, inst, ctx);
|
|
2760
|
-
});
|
|
2761
|
-
};
|
|
2762
|
-
});
|
|
2763
|
-
const $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (inst, def) => {
|
|
2764
|
-
$ZodType.init(inst, def);
|
|
2765
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2766
|
-
const input = payload.value;
|
|
2767
|
-
const left = def.left._zod.run({
|
|
2768
|
-
value: input,
|
|
2769
|
-
issues: []
|
|
2770
|
-
}, ctx);
|
|
2771
|
-
const right = def.right._zod.run({
|
|
2772
|
-
value: input,
|
|
2773
|
-
issues: []
|
|
2774
|
-
}, ctx);
|
|
2775
|
-
if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left, right]) => {
|
|
2776
|
-
return handleIntersectionResults(payload, left, right);
|
|
2777
|
-
});
|
|
2778
|
-
return handleIntersectionResults(payload, left, right);
|
|
2779
|
-
};
|
|
2780
|
-
});
|
|
2781
|
-
function mergeValues(a, b) {
|
|
2782
|
-
if (a === b) return {
|
|
2783
|
-
valid: true,
|
|
2784
|
-
data: a
|
|
2785
|
-
};
|
|
2786
|
-
if (a instanceof Date && b instanceof Date && +a === +b) return {
|
|
2787
|
-
valid: true,
|
|
2788
|
-
data: a
|
|
2789
|
-
};
|
|
2790
|
-
if (isPlainObject(a) && isPlainObject(b)) {
|
|
2791
|
-
const bKeys = Object.keys(b);
|
|
2792
|
-
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
2793
|
-
const newObj = {
|
|
2794
|
-
...a,
|
|
2795
|
-
...b
|
|
2796
|
-
};
|
|
2797
|
-
for (const key of sharedKeys) {
|
|
2798
|
-
const sharedValue = mergeValues(a[key], b[key]);
|
|
2799
|
-
if (!sharedValue.valid) return {
|
|
2800
|
-
valid: false,
|
|
2801
|
-
mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
|
|
2802
|
-
};
|
|
2803
|
-
newObj[key] = sharedValue.data;
|
|
2804
|
-
}
|
|
2805
|
-
return {
|
|
2806
|
-
valid: true,
|
|
2807
|
-
data: newObj
|
|
2808
|
-
};
|
|
2809
|
-
}
|
|
2810
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
2811
|
-
if (a.length !== b.length) return {
|
|
2812
|
-
valid: false,
|
|
2813
|
-
mergeErrorPath: []
|
|
2814
|
-
};
|
|
2815
|
-
const newArray = [];
|
|
2816
|
-
for (let index = 0; index < a.length; index++) {
|
|
2817
|
-
const itemA = a[index];
|
|
2818
|
-
const itemB = b[index];
|
|
2819
|
-
const sharedValue = mergeValues(itemA, itemB);
|
|
2820
|
-
if (!sharedValue.valid) return {
|
|
2821
|
-
valid: false,
|
|
2822
|
-
mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
|
|
2823
|
-
};
|
|
2824
|
-
newArray.push(sharedValue.data);
|
|
2825
|
-
}
|
|
2826
|
-
return {
|
|
2827
|
-
valid: true,
|
|
2828
|
-
data: newArray
|
|
2829
|
-
};
|
|
2830
|
-
}
|
|
2831
|
-
return {
|
|
2832
|
-
valid: false,
|
|
2833
|
-
mergeErrorPath: []
|
|
2834
|
-
};
|
|
2835
|
-
}
|
|
2836
|
-
function handleIntersectionResults(result, left, right) {
|
|
2837
|
-
const unrecKeys = /* @__PURE__ */ new Map();
|
|
2838
|
-
let unrecIssue;
|
|
2839
|
-
for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
|
|
2840
|
-
unrecIssue ?? (unrecIssue = iss);
|
|
2841
|
-
for (const k of iss.keys) {
|
|
2842
|
-
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
2843
|
-
unrecKeys.get(k).l = true;
|
|
2844
|
-
}
|
|
2845
|
-
} else result.issues.push(iss);
|
|
2846
|
-
for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
|
|
2847
|
-
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
2848
|
-
unrecKeys.get(k).r = true;
|
|
2849
|
-
}
|
|
2850
|
-
else result.issues.push(iss);
|
|
2851
|
-
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
2852
|
-
if (bothKeys.length && unrecIssue) result.issues.push({
|
|
2853
|
-
...unrecIssue,
|
|
2854
|
-
keys: bothKeys
|
|
2855
|
-
});
|
|
2856
|
-
if (aborted(result)) return result;
|
|
2857
|
-
const merged = mergeValues(left.value, right.value);
|
|
2858
|
-
if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
2859
|
-
result.value = merged.data;
|
|
2860
|
-
return result;
|
|
2861
|
-
}
|
|
2862
|
-
const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
|
|
2863
|
-
$ZodType.init(inst, def);
|
|
2864
|
-
const values = getEnumValues(def.entries);
|
|
2865
|
-
const valuesSet = new Set(values);
|
|
2866
|
-
inst._zod.values = valuesSet;
|
|
2867
|
-
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
2868
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
2869
|
-
const input = payload.value;
|
|
2870
|
-
if (valuesSet.has(input)) return payload;
|
|
2871
|
-
payload.issues.push({
|
|
2872
|
-
code: "invalid_value",
|
|
2873
|
-
values,
|
|
2874
|
-
input,
|
|
2875
|
-
inst
|
|
2876
|
-
});
|
|
2877
|
-
return payload;
|
|
2878
|
-
};
|
|
2879
|
-
});
|
|
2880
|
-
const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
|
|
2881
|
-
$ZodType.init(inst, def);
|
|
2882
|
-
inst._zod.optin = "optional";
|
|
2883
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2884
|
-
if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
|
|
2885
|
-
const _out = def.transform(payload.value, payload);
|
|
2886
|
-
if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
|
|
2887
|
-
payload.value = output;
|
|
2888
|
-
payload.fallback = true;
|
|
2889
|
-
return payload;
|
|
2890
|
-
});
|
|
2891
|
-
if (_out instanceof Promise) throw new $ZodAsyncError();
|
|
2892
|
-
payload.value = _out;
|
|
2893
|
-
payload.fallback = true;
|
|
2894
|
-
return payload;
|
|
2895
|
-
};
|
|
2896
|
-
});
|
|
2897
|
-
function handleOptionalResult(result, input) {
|
|
2898
|
-
if (input === void 0 && (result.issues.length || result.fallback)) return {
|
|
2899
|
-
issues: [],
|
|
2900
|
-
value: void 0
|
|
2901
|
-
};
|
|
2902
|
-
return result;
|
|
2903
|
-
}
|
|
2904
|
-
const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
|
|
2905
|
-
$ZodType.init(inst, def);
|
|
2906
|
-
inst._zod.optin = "optional";
|
|
2907
|
-
inst._zod.optout = "optional";
|
|
2908
|
-
defineLazy(inst._zod, "values", () => {
|
|
2909
|
-
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
|
|
2910
|
-
});
|
|
2911
|
-
defineLazy(inst._zod, "pattern", () => {
|
|
2912
|
-
const pattern = def.innerType._zod.pattern;
|
|
2913
|
-
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
2914
|
-
});
|
|
2915
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2916
|
-
if (def.innerType._zod.optin === "optional") {
|
|
2917
|
-
const input = payload.value;
|
|
2918
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
2919
|
-
if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, input));
|
|
2920
|
-
return handleOptionalResult(result, input);
|
|
2921
|
-
}
|
|
2922
|
-
if (payload.value === void 0) return payload;
|
|
2923
|
-
return def.innerType._zod.run(payload, ctx);
|
|
2924
|
-
};
|
|
2925
|
-
});
|
|
2926
|
-
const $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
|
|
2927
|
-
$ZodOptional.init(inst, def);
|
|
2928
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2929
|
-
defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
|
|
2930
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2931
|
-
return def.innerType._zod.run(payload, ctx);
|
|
2932
|
-
};
|
|
2933
|
-
});
|
|
2934
|
-
const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
|
|
2935
|
-
$ZodType.init(inst, def);
|
|
2936
|
-
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
2937
|
-
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
2938
|
-
defineLazy(inst._zod, "pattern", () => {
|
|
2939
|
-
const pattern = def.innerType._zod.pattern;
|
|
2940
|
-
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
|
|
2941
|
-
});
|
|
2942
|
-
defineLazy(inst._zod, "values", () => {
|
|
2943
|
-
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
|
|
2944
|
-
});
|
|
2945
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2946
|
-
if (payload.value === null) return payload;
|
|
2947
|
-
return def.innerType._zod.run(payload, ctx);
|
|
2948
|
-
};
|
|
2949
|
-
});
|
|
2950
|
-
const $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
|
|
2951
|
-
$ZodType.init(inst, def);
|
|
2952
|
-
inst._zod.optin = "optional";
|
|
2953
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2954
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2955
|
-
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2956
|
-
if (payload.value === void 0) {
|
|
2957
|
-
payload.value = def.defaultValue;
|
|
2958
|
-
/**
|
|
2959
|
-
* $ZodDefault returns the default value immediately in forward direction.
|
|
2960
|
-
* It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
|
|
2961
|
-
return payload;
|
|
2962
|
-
}
|
|
2963
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
2964
|
-
if (result instanceof Promise) return result.then((result) => handleDefaultResult(result, def));
|
|
2965
|
-
return handleDefaultResult(result, def);
|
|
2966
|
-
};
|
|
2967
|
-
});
|
|
2968
|
-
function handleDefaultResult(payload, def) {
|
|
2969
|
-
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
2970
|
-
return payload;
|
|
2971
|
-
}
|
|
2972
|
-
const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
|
|
2973
|
-
$ZodType.init(inst, def);
|
|
2974
|
-
inst._zod.optin = "optional";
|
|
2975
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2976
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2977
|
-
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2978
|
-
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
2979
|
-
return def.innerType._zod.run(payload, ctx);
|
|
2980
|
-
};
|
|
2981
|
-
});
|
|
2982
|
-
const $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
|
|
2983
|
-
$ZodType.init(inst, def);
|
|
2984
|
-
defineLazy(inst._zod, "values", () => {
|
|
2985
|
-
const v = def.innerType._zod.values;
|
|
2986
|
-
return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
|
|
2987
|
-
});
|
|
2988
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2989
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
2990
|
-
if (result instanceof Promise) return result.then((result) => handleNonOptionalResult(result, inst));
|
|
2991
|
-
return handleNonOptionalResult(result, inst);
|
|
2992
|
-
};
|
|
2993
|
-
});
|
|
2994
|
-
function handleNonOptionalResult(payload, inst) {
|
|
2995
|
-
if (!payload.issues.length && payload.value === void 0) payload.issues.push({
|
|
2996
|
-
code: "invalid_type",
|
|
2997
|
-
expected: "nonoptional",
|
|
2998
|
-
input: payload.value,
|
|
2999
|
-
inst
|
|
3000
|
-
});
|
|
3001
|
-
return payload;
|
|
3002
|
-
}
|
|
3003
|
-
const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
|
|
3004
|
-
$ZodType.init(inst, def);
|
|
3005
|
-
inst._zod.optin = "optional";
|
|
3006
|
-
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
3007
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
3008
|
-
inst._zod.parse = (payload, ctx) => {
|
|
3009
|
-
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
3010
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
3011
|
-
if (result instanceof Promise) return result.then((result) => {
|
|
3012
|
-
payload.value = result.value;
|
|
3013
|
-
if (result.issues.length) {
|
|
3014
|
-
payload.value = def.catchValue({
|
|
3015
|
-
...payload,
|
|
3016
|
-
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
3017
|
-
input: payload.value
|
|
3018
|
-
});
|
|
3019
|
-
payload.issues = [];
|
|
3020
|
-
payload.fallback = true;
|
|
3021
|
-
}
|
|
3022
|
-
return payload;
|
|
3023
|
-
});
|
|
3024
|
-
payload.value = result.value;
|
|
3025
|
-
if (result.issues.length) {
|
|
3026
|
-
payload.value = def.catchValue({
|
|
3027
|
-
...payload,
|
|
3028
|
-
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
3029
|
-
input: payload.value
|
|
3030
|
-
});
|
|
3031
|
-
payload.issues = [];
|
|
3032
|
-
payload.fallback = true;
|
|
3033
|
-
}
|
|
3034
|
-
return payload;
|
|
3035
|
-
};
|
|
3036
|
-
});
|
|
3037
|
-
const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
|
|
3038
|
-
$ZodType.init(inst, def);
|
|
3039
|
-
defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
3040
|
-
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
3041
|
-
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
3042
|
-
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
3043
|
-
inst._zod.parse = (payload, ctx) => {
|
|
3044
|
-
if (ctx.direction === "backward") {
|
|
3045
|
-
const right = def.out._zod.run(payload, ctx);
|
|
3046
|
-
if (right instanceof Promise) return right.then((right) => handlePipeResult(right, def.in, ctx));
|
|
3047
|
-
return handlePipeResult(right, def.in, ctx);
|
|
3048
|
-
}
|
|
3049
|
-
const left = def.in._zod.run(payload, ctx);
|
|
3050
|
-
if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def.out, ctx));
|
|
3051
|
-
return handlePipeResult(left, def.out, ctx);
|
|
3052
|
-
};
|
|
3053
|
-
});
|
|
3054
|
-
function handlePipeResult(left, next, ctx) {
|
|
3055
|
-
if (left.issues.length) {
|
|
3056
|
-
left.aborted = true;
|
|
3057
|
-
return left;
|
|
3058
|
-
}
|
|
3059
|
-
return next._zod.run({
|
|
3060
|
-
value: left.value,
|
|
3061
|
-
issues: left.issues,
|
|
3062
|
-
fallback: left.fallback
|
|
3063
|
-
}, ctx);
|
|
3064
|
-
}
|
|
3065
|
-
const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
|
|
3066
|
-
$ZodType.init(inst, def);
|
|
3067
|
-
defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
3068
|
-
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
3069
|
-
defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
|
|
3070
|
-
defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
|
|
3071
|
-
inst._zod.parse = (payload, ctx) => {
|
|
3072
|
-
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
3073
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
3074
|
-
if (result instanceof Promise) return result.then(handleReadonlyResult);
|
|
3075
|
-
return handleReadonlyResult(result);
|
|
3076
|
-
};
|
|
3077
|
-
});
|
|
3078
|
-
function handleReadonlyResult(payload) {
|
|
3079
|
-
payload.value = Object.freeze(payload.value);
|
|
3080
|
-
return payload;
|
|
3081
|
-
}
|
|
3082
|
-
const $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
|
|
3083
|
-
$ZodCheck.init(inst, def);
|
|
3084
|
-
$ZodType.init(inst, def);
|
|
3085
|
-
inst._zod.parse = (payload, _) => {
|
|
3086
|
-
return payload;
|
|
3087
|
-
};
|
|
3088
|
-
inst._zod.check = (payload) => {
|
|
3089
|
-
const input = payload.value;
|
|
3090
|
-
const r = def.fn(input);
|
|
3091
|
-
if (r instanceof Promise) return r.then((r) => handleRefineResult(r, payload, input, inst));
|
|
3092
|
-
handleRefineResult(r, payload, input, inst);
|
|
3093
|
-
};
|
|
3094
|
-
});
|
|
3095
|
-
function handleRefineResult(result, payload, input, inst) {
|
|
3096
|
-
if (!result) {
|
|
3097
|
-
const _iss = {
|
|
3098
|
-
code: "custom",
|
|
3099
|
-
input,
|
|
3100
|
-
inst,
|
|
3101
|
-
path: [...inst._zod.def.path ?? []],
|
|
3102
|
-
continue: !inst._zod.def.abort
|
|
3103
|
-
};
|
|
3104
|
-
if (inst._zod.def.params) _iss.params = inst._zod.def.params;
|
|
3105
|
-
payload.issues.push(issue(_iss));
|
|
3106
|
-
}
|
|
3107
|
-
}
|
|
3108
|
-
//#endregion
|
|
3109
|
-
//#region ../src/node_modules/zod/v4/core/registries.js
|
|
3110
|
-
var _a;
|
|
3111
|
-
var $ZodRegistry = class {
|
|
3112
|
-
constructor() {
|
|
3113
|
-
this._map = /* @__PURE__ */ new WeakMap();
|
|
3114
|
-
this._idmap = /* @__PURE__ */ new Map();
|
|
3115
|
-
}
|
|
3116
|
-
add(schema, ..._meta) {
|
|
3117
|
-
const meta = _meta[0];
|
|
3118
|
-
this._map.set(schema, meta);
|
|
3119
|
-
if (meta && typeof meta === "object" && "id" in meta) this._idmap.set(meta.id, schema);
|
|
3120
|
-
return this;
|
|
3121
|
-
}
|
|
3122
|
-
clear() {
|
|
3123
|
-
this._map = /* @__PURE__ */ new WeakMap();
|
|
3124
|
-
this._idmap = /* @__PURE__ */ new Map();
|
|
3125
|
-
return this;
|
|
3126
|
-
}
|
|
3127
|
-
remove(schema) {
|
|
3128
|
-
const meta = this._map.get(schema);
|
|
3129
|
-
if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
|
|
3130
|
-
this._map.delete(schema);
|
|
3131
|
-
return this;
|
|
3132
|
-
}
|
|
3133
|
-
get(schema) {
|
|
3134
|
-
const p = schema._zod.parent;
|
|
3135
|
-
if (p) {
|
|
3136
|
-
const pm = { ...this.get(p) ?? {} };
|
|
3137
|
-
delete pm.id;
|
|
3138
|
-
const f = {
|
|
3139
|
-
...pm,
|
|
3140
|
-
...this._map.get(schema)
|
|
3141
|
-
};
|
|
3142
|
-
return Object.keys(f).length ? f : void 0;
|
|
3143
|
-
}
|
|
3144
|
-
return this._map.get(schema);
|
|
3145
|
-
}
|
|
3146
|
-
has(schema) {
|
|
3147
|
-
return this._map.has(schema);
|
|
3148
|
-
}
|
|
3149
|
-
};
|
|
3150
|
-
function registry() {
|
|
3151
|
-
return new $ZodRegistry();
|
|
3152
|
-
}
|
|
3153
|
-
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
|
3154
|
-
const globalRegistry = globalThis.__zod_globalRegistry;
|
|
3155
|
-
//#endregion
|
|
3156
|
-
//#region ../src/node_modules/zod/v4/core/api.js
|
|
3157
|
-
// @__NO_SIDE_EFFECTS__
|
|
3158
|
-
function _string(Class, params) {
|
|
3159
|
-
return new Class({
|
|
3160
|
-
type: "string",
|
|
3161
|
-
...normalizeParams(params)
|
|
3162
|
-
});
|
|
3163
|
-
}
|
|
3164
|
-
// @__NO_SIDE_EFFECTS__
|
|
3165
|
-
function _email(Class, params) {
|
|
3166
|
-
return new Class({
|
|
3167
|
-
type: "string",
|
|
3168
|
-
format: "email",
|
|
3169
|
-
check: "string_format",
|
|
3170
|
-
abort: false,
|
|
3171
|
-
...normalizeParams(params)
|
|
3172
|
-
});
|
|
3173
|
-
}
|
|
3174
|
-
// @__NO_SIDE_EFFECTS__
|
|
3175
|
-
function _guid(Class, params) {
|
|
3176
|
-
return new Class({
|
|
3177
|
-
type: "string",
|
|
3178
|
-
format: "guid",
|
|
3179
|
-
check: "string_format",
|
|
3180
|
-
abort: false,
|
|
3181
|
-
...normalizeParams(params)
|
|
3182
|
-
});
|
|
3183
|
-
}
|
|
3184
|
-
// @__NO_SIDE_EFFECTS__
|
|
3185
|
-
function _uuid(Class, params) {
|
|
3186
|
-
return new Class({
|
|
3187
|
-
type: "string",
|
|
3188
|
-
format: "uuid",
|
|
3189
|
-
check: "string_format",
|
|
3190
|
-
abort: false,
|
|
3191
|
-
...normalizeParams(params)
|
|
3192
|
-
});
|
|
3193
|
-
}
|
|
3194
|
-
// @__NO_SIDE_EFFECTS__
|
|
3195
|
-
function _uuidv4(Class, params) {
|
|
3196
|
-
return new Class({
|
|
3197
|
-
type: "string",
|
|
3198
|
-
format: "uuid",
|
|
3199
|
-
check: "string_format",
|
|
3200
|
-
abort: false,
|
|
3201
|
-
version: "v4",
|
|
3202
|
-
...normalizeParams(params)
|
|
3203
|
-
});
|
|
3204
|
-
}
|
|
3205
|
-
// @__NO_SIDE_EFFECTS__
|
|
3206
|
-
function _uuidv6(Class, params) {
|
|
3207
|
-
return new Class({
|
|
3208
|
-
type: "string",
|
|
3209
|
-
format: "uuid",
|
|
3210
|
-
check: "string_format",
|
|
3211
|
-
abort: false,
|
|
3212
|
-
version: "v6",
|
|
3213
|
-
...normalizeParams(params)
|
|
3214
|
-
});
|
|
3215
|
-
}
|
|
3216
|
-
// @__NO_SIDE_EFFECTS__
|
|
3217
|
-
function _uuidv7(Class, params) {
|
|
3218
|
-
return new Class({
|
|
3219
|
-
type: "string",
|
|
3220
|
-
format: "uuid",
|
|
3221
|
-
check: "string_format",
|
|
3222
|
-
abort: false,
|
|
3223
|
-
version: "v7",
|
|
3224
|
-
...normalizeParams(params)
|
|
3225
|
-
});
|
|
3226
|
-
}
|
|
3227
|
-
// @__NO_SIDE_EFFECTS__
|
|
3228
|
-
function _url(Class, params) {
|
|
3229
|
-
return new Class({
|
|
3230
|
-
type: "string",
|
|
3231
|
-
format: "url",
|
|
3232
|
-
check: "string_format",
|
|
3233
|
-
abort: false,
|
|
3234
|
-
...normalizeParams(params)
|
|
3235
|
-
});
|
|
3236
|
-
}
|
|
3237
|
-
// @__NO_SIDE_EFFECTS__
|
|
3238
|
-
function _emoji(Class, params) {
|
|
3239
|
-
return new Class({
|
|
3240
|
-
type: "string",
|
|
3241
|
-
format: "emoji",
|
|
3242
|
-
check: "string_format",
|
|
3243
|
-
abort: false,
|
|
3244
|
-
...normalizeParams(params)
|
|
3245
|
-
});
|
|
3246
|
-
}
|
|
3247
|
-
// @__NO_SIDE_EFFECTS__
|
|
3248
|
-
function _nanoid(Class, params) {
|
|
3249
|
-
return new Class({
|
|
3250
|
-
type: "string",
|
|
3251
|
-
format: "nanoid",
|
|
3252
|
-
check: "string_format",
|
|
3253
|
-
abort: false,
|
|
3254
|
-
...normalizeParams(params)
|
|
3255
|
-
});
|
|
3256
|
-
}
|
|
3257
|
-
/**
|
|
3258
|
-
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
3259
|
-
* (timestamps embedded in the id). Use {@link _cuid2} instead.
|
|
3260
|
-
* See https://github.com/paralleldrive/cuid.
|
|
3261
|
-
*/
|
|
3262
|
-
// @__NO_SIDE_EFFECTS__
|
|
3263
|
-
function _cuid(Class, params) {
|
|
3264
|
-
return new Class({
|
|
3265
|
-
type: "string",
|
|
3266
|
-
format: "cuid",
|
|
3267
|
-
check: "string_format",
|
|
3268
|
-
abort: false,
|
|
3269
|
-
...normalizeParams(params)
|
|
3270
|
-
});
|
|
3271
|
-
}
|
|
3272
|
-
// @__NO_SIDE_EFFECTS__
|
|
3273
|
-
function _cuid2(Class, params) {
|
|
3274
|
-
return new Class({
|
|
3275
|
-
type: "string",
|
|
3276
|
-
format: "cuid2",
|
|
3277
|
-
check: "string_format",
|
|
3278
|
-
abort: false,
|
|
3279
|
-
...normalizeParams(params)
|
|
3280
|
-
});
|
|
3281
|
-
}
|
|
3282
|
-
// @__NO_SIDE_EFFECTS__
|
|
3283
|
-
function _ulid(Class, params) {
|
|
3284
|
-
return new Class({
|
|
3285
|
-
type: "string",
|
|
3286
|
-
format: "ulid",
|
|
3287
|
-
check: "string_format",
|
|
3288
|
-
abort: false,
|
|
3289
|
-
...normalizeParams(params)
|
|
3290
|
-
});
|
|
3291
|
-
}
|
|
3292
|
-
// @__NO_SIDE_EFFECTS__
|
|
3293
|
-
function _xid(Class, params) {
|
|
3294
|
-
return new Class({
|
|
3295
|
-
type: "string",
|
|
3296
|
-
format: "xid",
|
|
3297
|
-
check: "string_format",
|
|
3298
|
-
abort: false,
|
|
3299
|
-
...normalizeParams(params)
|
|
3300
|
-
});
|
|
3301
|
-
}
|
|
3302
|
-
// @__NO_SIDE_EFFECTS__
|
|
3303
|
-
function _ksuid(Class, params) {
|
|
3304
|
-
return new Class({
|
|
3305
|
-
type: "string",
|
|
3306
|
-
format: "ksuid",
|
|
3307
|
-
check: "string_format",
|
|
3308
|
-
abort: false,
|
|
3309
|
-
...normalizeParams(params)
|
|
3310
|
-
});
|
|
3311
|
-
}
|
|
3312
|
-
// @__NO_SIDE_EFFECTS__
|
|
3313
|
-
function _ipv4(Class, params) {
|
|
3314
|
-
return new Class({
|
|
3315
|
-
type: "string",
|
|
3316
|
-
format: "ipv4",
|
|
3317
|
-
check: "string_format",
|
|
3318
|
-
abort: false,
|
|
3319
|
-
...normalizeParams(params)
|
|
3320
|
-
});
|
|
3321
|
-
}
|
|
3322
|
-
// @__NO_SIDE_EFFECTS__
|
|
3323
|
-
function _ipv6(Class, params) {
|
|
3324
|
-
return new Class({
|
|
3325
|
-
type: "string",
|
|
3326
|
-
format: "ipv6",
|
|
3327
|
-
check: "string_format",
|
|
3328
|
-
abort: false,
|
|
3329
|
-
...normalizeParams(params)
|
|
3330
|
-
});
|
|
3331
|
-
}
|
|
3332
|
-
// @__NO_SIDE_EFFECTS__
|
|
3333
|
-
function _cidrv4(Class, params) {
|
|
3334
|
-
return new Class({
|
|
3335
|
-
type: "string",
|
|
3336
|
-
format: "cidrv4",
|
|
3337
|
-
check: "string_format",
|
|
3338
|
-
abort: false,
|
|
3339
|
-
...normalizeParams(params)
|
|
3340
|
-
});
|
|
3341
|
-
}
|
|
3342
|
-
// @__NO_SIDE_EFFECTS__
|
|
3343
|
-
function _cidrv6(Class, params) {
|
|
3344
|
-
return new Class({
|
|
3345
|
-
type: "string",
|
|
3346
|
-
format: "cidrv6",
|
|
3347
|
-
check: "string_format",
|
|
3348
|
-
abort: false,
|
|
3349
|
-
...normalizeParams(params)
|
|
3350
|
-
});
|
|
3351
|
-
}
|
|
3352
|
-
// @__NO_SIDE_EFFECTS__
|
|
3353
|
-
function _base64(Class, params) {
|
|
3354
|
-
return new Class({
|
|
3355
|
-
type: "string",
|
|
3356
|
-
format: "base64",
|
|
3357
|
-
check: "string_format",
|
|
3358
|
-
abort: false,
|
|
3359
|
-
...normalizeParams(params)
|
|
3360
|
-
});
|
|
3361
|
-
}
|
|
3362
|
-
// @__NO_SIDE_EFFECTS__
|
|
3363
|
-
function _base64url(Class, params) {
|
|
3364
|
-
return new Class({
|
|
3365
|
-
type: "string",
|
|
3366
|
-
format: "base64url",
|
|
3367
|
-
check: "string_format",
|
|
3368
|
-
abort: false,
|
|
3369
|
-
...normalizeParams(params)
|
|
3370
|
-
});
|
|
3371
|
-
}
|
|
3372
|
-
// @__NO_SIDE_EFFECTS__
|
|
3373
|
-
function _e164(Class, params) {
|
|
3374
|
-
return new Class({
|
|
3375
|
-
type: "string",
|
|
3376
|
-
format: "e164",
|
|
3377
|
-
check: "string_format",
|
|
3378
|
-
abort: false,
|
|
3379
|
-
...normalizeParams(params)
|
|
3380
|
-
});
|
|
3381
|
-
}
|
|
3382
|
-
// @__NO_SIDE_EFFECTS__
|
|
3383
|
-
function _jwt(Class, params) {
|
|
3384
|
-
return new Class({
|
|
3385
|
-
type: "string",
|
|
3386
|
-
format: "jwt",
|
|
3387
|
-
check: "string_format",
|
|
3388
|
-
abort: false,
|
|
3389
|
-
...normalizeParams(params)
|
|
3390
|
-
});
|
|
3391
|
-
}
|
|
3392
|
-
// @__NO_SIDE_EFFECTS__
|
|
3393
|
-
function _isoDateTime(Class, params) {
|
|
3394
|
-
return new Class({
|
|
3395
|
-
type: "string",
|
|
3396
|
-
format: "datetime",
|
|
3397
|
-
check: "string_format",
|
|
3398
|
-
offset: false,
|
|
3399
|
-
local: false,
|
|
3400
|
-
precision: null,
|
|
3401
|
-
...normalizeParams(params)
|
|
3402
|
-
});
|
|
3403
|
-
}
|
|
3404
|
-
// @__NO_SIDE_EFFECTS__
|
|
3405
|
-
function _isoDate(Class, params) {
|
|
3406
|
-
return new Class({
|
|
3407
|
-
type: "string",
|
|
3408
|
-
format: "date",
|
|
3409
|
-
check: "string_format",
|
|
3410
|
-
...normalizeParams(params)
|
|
3411
|
-
});
|
|
3412
|
-
}
|
|
3413
|
-
// @__NO_SIDE_EFFECTS__
|
|
3414
|
-
function _isoTime(Class, params) {
|
|
3415
|
-
return new Class({
|
|
3416
|
-
type: "string",
|
|
3417
|
-
format: "time",
|
|
3418
|
-
check: "string_format",
|
|
3419
|
-
precision: null,
|
|
3420
|
-
...normalizeParams(params)
|
|
3421
|
-
});
|
|
3422
|
-
}
|
|
3423
|
-
// @__NO_SIDE_EFFECTS__
|
|
3424
|
-
function _isoDuration(Class, params) {
|
|
3425
|
-
return new Class({
|
|
3426
|
-
type: "string",
|
|
3427
|
-
format: "duration",
|
|
3428
|
-
check: "string_format",
|
|
3429
|
-
...normalizeParams(params)
|
|
3430
|
-
});
|
|
3431
|
-
}
|
|
3432
|
-
// @__NO_SIDE_EFFECTS__
|
|
3433
|
-
function _boolean(Class, params) {
|
|
3434
|
-
return new Class({
|
|
3435
|
-
type: "boolean",
|
|
3436
|
-
...normalizeParams(params)
|
|
3437
|
-
});
|
|
3438
|
-
}
|
|
3439
|
-
// @__NO_SIDE_EFFECTS__
|
|
3440
|
-
function _unknown(Class) {
|
|
3441
|
-
return new Class({ type: "unknown" });
|
|
3442
|
-
}
|
|
3443
|
-
// @__NO_SIDE_EFFECTS__
|
|
3444
|
-
function _never(Class, params) {
|
|
3445
|
-
return new Class({
|
|
3446
|
-
type: "never",
|
|
3447
|
-
...normalizeParams(params)
|
|
3448
|
-
});
|
|
3449
|
-
}
|
|
3450
|
-
// @__NO_SIDE_EFFECTS__
|
|
3451
|
-
function _void$1(Class, params) {
|
|
3452
|
-
return new Class({
|
|
3453
|
-
type: "void",
|
|
3454
|
-
...normalizeParams(params)
|
|
3455
|
-
});
|
|
3456
|
-
}
|
|
3457
|
-
// @__NO_SIDE_EFFECTS__
|
|
3458
|
-
function _maxLength(maximum, params) {
|
|
3459
|
-
return new $ZodCheckMaxLength({
|
|
3460
|
-
check: "max_length",
|
|
3461
|
-
...normalizeParams(params),
|
|
3462
|
-
maximum
|
|
3463
|
-
});
|
|
3464
|
-
}
|
|
3465
|
-
// @__NO_SIDE_EFFECTS__
|
|
3466
|
-
function _minLength(minimum, params) {
|
|
3467
|
-
return new $ZodCheckMinLength({
|
|
3468
|
-
check: "min_length",
|
|
3469
|
-
...normalizeParams(params),
|
|
3470
|
-
minimum
|
|
3471
|
-
});
|
|
3472
|
-
}
|
|
3473
|
-
// @__NO_SIDE_EFFECTS__
|
|
3474
|
-
function _length(length, params) {
|
|
3475
|
-
return new $ZodCheckLengthEquals({
|
|
3476
|
-
check: "length_equals",
|
|
3477
|
-
...normalizeParams(params),
|
|
3478
|
-
length
|
|
3479
|
-
});
|
|
3480
|
-
}
|
|
3481
|
-
// @__NO_SIDE_EFFECTS__
|
|
3482
|
-
function _regex(pattern, params) {
|
|
3483
|
-
return new $ZodCheckRegex({
|
|
3484
|
-
check: "string_format",
|
|
3485
|
-
format: "regex",
|
|
3486
|
-
...normalizeParams(params),
|
|
3487
|
-
pattern
|
|
3488
|
-
});
|
|
3489
|
-
}
|
|
3490
|
-
// @__NO_SIDE_EFFECTS__
|
|
3491
|
-
function _lowercase(params) {
|
|
3492
|
-
return new $ZodCheckLowerCase({
|
|
3493
|
-
check: "string_format",
|
|
3494
|
-
format: "lowercase",
|
|
3495
|
-
...normalizeParams(params)
|
|
3496
|
-
});
|
|
3497
|
-
}
|
|
3498
|
-
// @__NO_SIDE_EFFECTS__
|
|
3499
|
-
function _uppercase(params) {
|
|
3500
|
-
return new $ZodCheckUpperCase({
|
|
3501
|
-
check: "string_format",
|
|
3502
|
-
format: "uppercase",
|
|
3503
|
-
...normalizeParams(params)
|
|
3504
|
-
});
|
|
3505
|
-
}
|
|
3506
|
-
// @__NO_SIDE_EFFECTS__
|
|
3507
|
-
function _includes(includes, params) {
|
|
3508
|
-
return new $ZodCheckIncludes({
|
|
3509
|
-
check: "string_format",
|
|
3510
|
-
format: "includes",
|
|
3511
|
-
...normalizeParams(params),
|
|
3512
|
-
includes
|
|
3513
|
-
});
|
|
3514
|
-
}
|
|
3515
|
-
// @__NO_SIDE_EFFECTS__
|
|
3516
|
-
function _startsWith(prefix, params) {
|
|
3517
|
-
return new $ZodCheckStartsWith({
|
|
3518
|
-
check: "string_format",
|
|
3519
|
-
format: "starts_with",
|
|
3520
|
-
...normalizeParams(params),
|
|
3521
|
-
prefix
|
|
3522
|
-
});
|
|
3523
|
-
}
|
|
3524
|
-
// @__NO_SIDE_EFFECTS__
|
|
3525
|
-
function _endsWith(suffix, params) {
|
|
3526
|
-
return new $ZodCheckEndsWith({
|
|
3527
|
-
check: "string_format",
|
|
3528
|
-
format: "ends_with",
|
|
3529
|
-
...normalizeParams(params),
|
|
3530
|
-
suffix
|
|
3531
|
-
});
|
|
3532
|
-
}
|
|
3533
|
-
// @__NO_SIDE_EFFECTS__
|
|
3534
|
-
function _overwrite(tx) {
|
|
3535
|
-
return new $ZodCheckOverwrite({
|
|
3536
|
-
check: "overwrite",
|
|
3537
|
-
tx
|
|
3538
|
-
});
|
|
3539
|
-
}
|
|
3540
|
-
// @__NO_SIDE_EFFECTS__
|
|
3541
|
-
function _normalize(form) {
|
|
3542
|
-
return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
|
|
3543
|
-
}
|
|
3544
|
-
// @__NO_SIDE_EFFECTS__
|
|
3545
|
-
function _trim() {
|
|
3546
|
-
return /* @__PURE__ */ _overwrite((input) => input.trim());
|
|
3547
|
-
}
|
|
3548
|
-
// @__NO_SIDE_EFFECTS__
|
|
3549
|
-
function _toLowerCase() {
|
|
3550
|
-
return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
|
|
3551
|
-
}
|
|
3552
|
-
// @__NO_SIDE_EFFECTS__
|
|
3553
|
-
function _toUpperCase() {
|
|
3554
|
-
return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
|
|
3555
|
-
}
|
|
3556
|
-
// @__NO_SIDE_EFFECTS__
|
|
3557
|
-
function _slugify() {
|
|
3558
|
-
return /* @__PURE__ */ _overwrite((input) => slugify(input));
|
|
3559
|
-
}
|
|
3560
|
-
// @__NO_SIDE_EFFECTS__
|
|
3561
|
-
function _array(Class, element, params) {
|
|
3562
|
-
return new Class({
|
|
3563
|
-
type: "array",
|
|
3564
|
-
element,
|
|
3565
|
-
...normalizeParams(params)
|
|
3566
|
-
});
|
|
3567
|
-
}
|
|
3568
|
-
// @__NO_SIDE_EFFECTS__
|
|
3569
|
-
function _refine(Class, fn, _params) {
|
|
3570
|
-
return new Class({
|
|
3571
|
-
type: "custom",
|
|
3572
|
-
check: "custom",
|
|
3573
|
-
fn,
|
|
3574
|
-
...normalizeParams(_params)
|
|
3575
|
-
});
|
|
3576
|
-
}
|
|
3577
|
-
// @__NO_SIDE_EFFECTS__
|
|
3578
|
-
function _superRefine(fn, params) {
|
|
3579
|
-
const ch = /* @__PURE__ */ _check((payload) => {
|
|
3580
|
-
payload.addIssue = (issue$2) => {
|
|
3581
|
-
if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
|
|
3582
|
-
else {
|
|
3583
|
-
const _issue = issue$2;
|
|
3584
|
-
if (_issue.fatal) _issue.continue = false;
|
|
3585
|
-
_issue.code ?? (_issue.code = "custom");
|
|
3586
|
-
_issue.input ?? (_issue.input = payload.value);
|
|
3587
|
-
_issue.inst ?? (_issue.inst = ch);
|
|
3588
|
-
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
3589
|
-
payload.issues.push(issue(_issue));
|
|
3590
|
-
}
|
|
3591
|
-
};
|
|
3592
|
-
return fn(payload.value, payload);
|
|
3593
|
-
}, params);
|
|
3594
|
-
return ch;
|
|
3595
|
-
}
|
|
3596
|
-
// @__NO_SIDE_EFFECTS__
|
|
3597
|
-
function _check(fn, params) {
|
|
3598
|
-
const ch = new $ZodCheck({
|
|
3599
|
-
check: "custom",
|
|
3600
|
-
...normalizeParams(params)
|
|
3601
|
-
});
|
|
3602
|
-
ch._zod.check = fn;
|
|
3603
|
-
return ch;
|
|
3604
|
-
}
|
|
3605
|
-
//#endregion
|
|
3606
|
-
//#region ../src/node_modules/zod/v4/core/to-json-schema.js
|
|
3607
|
-
function initializeContext(params) {
|
|
3608
|
-
let target = params?.target ?? "draft-2020-12";
|
|
3609
|
-
if (target === "draft-4") target = "draft-04";
|
|
3610
|
-
if (target === "draft-7") target = "draft-07";
|
|
3611
|
-
return {
|
|
3612
|
-
processors: params.processors ?? {},
|
|
3613
|
-
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
3614
|
-
target,
|
|
3615
|
-
unrepresentable: params?.unrepresentable ?? "throw",
|
|
3616
|
-
override: params?.override ?? (() => {}),
|
|
3617
|
-
io: params?.io ?? "output",
|
|
3618
|
-
counter: 0,
|
|
3619
|
-
seen: /* @__PURE__ */ new Map(),
|
|
3620
|
-
cycles: params?.cycles ?? "ref",
|
|
3621
|
-
reused: params?.reused ?? "inline",
|
|
3622
|
-
external: params?.external ?? void 0
|
|
3623
|
-
};
|
|
3624
|
-
}
|
|
3625
|
-
function process(schema, ctx, _params = {
|
|
3626
|
-
path: [],
|
|
3627
|
-
schemaPath: []
|
|
3628
|
-
}) {
|
|
3629
|
-
var _a;
|
|
3630
|
-
const def = schema._zod.def;
|
|
3631
|
-
const seen = ctx.seen.get(schema);
|
|
3632
|
-
if (seen) {
|
|
3633
|
-
seen.count++;
|
|
3634
|
-
if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
|
|
3635
|
-
return seen.schema;
|
|
3636
|
-
}
|
|
3637
|
-
const result = {
|
|
3638
|
-
schema: {},
|
|
3639
|
-
count: 1,
|
|
3640
|
-
cycle: void 0,
|
|
3641
|
-
path: _params.path
|
|
3642
|
-
};
|
|
3643
|
-
ctx.seen.set(schema, result);
|
|
3644
|
-
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
3645
|
-
if (overrideSchema) result.schema = overrideSchema;
|
|
3646
|
-
else {
|
|
3647
|
-
const params = {
|
|
3648
|
-
..._params,
|
|
3649
|
-
schemaPath: [..._params.schemaPath, schema],
|
|
3650
|
-
path: _params.path
|
|
3651
|
-
};
|
|
3652
|
-
if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
|
|
3653
|
-
else {
|
|
3654
|
-
const _json = result.schema;
|
|
3655
|
-
const processor = ctx.processors[def.type];
|
|
3656
|
-
if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
|
|
3657
|
-
processor(schema, ctx, _json, params);
|
|
3658
|
-
}
|
|
3659
|
-
const parent = schema._zod.parent;
|
|
3660
|
-
if (parent) {
|
|
3661
|
-
if (!result.ref) result.ref = parent;
|
|
3662
|
-
process(parent, ctx, params);
|
|
3663
|
-
ctx.seen.get(parent).isParent = true;
|
|
3664
|
-
}
|
|
3665
|
-
}
|
|
3666
|
-
const meta = ctx.metadataRegistry.get(schema);
|
|
3667
|
-
if (meta) Object.assign(result.schema, meta);
|
|
3668
|
-
if (ctx.io === "input" && isTransforming(schema)) {
|
|
3669
|
-
delete result.schema.examples;
|
|
3670
|
-
delete result.schema.default;
|
|
3671
|
-
}
|
|
3672
|
-
if (ctx.io === "input" && "_prefault" in result.schema) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
|
3673
|
-
delete result.schema._prefault;
|
|
3674
|
-
return ctx.seen.get(schema).schema;
|
|
3675
|
-
}
|
|
3676
|
-
function extractDefs(ctx, schema) {
|
|
3677
|
-
const root = ctx.seen.get(schema);
|
|
3678
|
-
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
3679
|
-
const idToSchema = /* @__PURE__ */ new Map();
|
|
3680
|
-
for (const entry of ctx.seen.entries()) {
|
|
3681
|
-
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
3682
|
-
if (id) {
|
|
3683
|
-
const existing = idToSchema.get(id);
|
|
3684
|
-
if (existing && existing !== entry[0]) throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
3685
|
-
idToSchema.set(id, entry[0]);
|
|
3686
|
-
}
|
|
3687
|
-
}
|
|
3688
|
-
const makeURI = (entry) => {
|
|
3689
|
-
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
3690
|
-
if (ctx.external) {
|
|
3691
|
-
const externalId = ctx.external.registry.get(entry[0])?.id;
|
|
3692
|
-
const uriGenerator = ctx.external.uri ?? ((id) => id);
|
|
3693
|
-
if (externalId) return { ref: uriGenerator(externalId) };
|
|
3694
|
-
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
3695
|
-
entry[1].defId = id;
|
|
3696
|
-
return {
|
|
3697
|
-
defId: id,
|
|
3698
|
-
ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
|
|
3699
|
-
};
|
|
3700
|
-
}
|
|
3701
|
-
if (entry[1] === root) return { ref: "#" };
|
|
3702
|
-
const defUriPrefix = `#/${defsSegment}/`;
|
|
3703
|
-
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
3704
|
-
return {
|
|
3705
|
-
defId,
|
|
3706
|
-
ref: defUriPrefix + defId
|
|
3707
|
-
};
|
|
3708
|
-
};
|
|
3709
|
-
const extractToDef = (entry) => {
|
|
3710
|
-
if (entry[1].schema.$ref) return;
|
|
3711
|
-
const seen = entry[1];
|
|
3712
|
-
const { ref, defId } = makeURI(entry);
|
|
3713
|
-
seen.def = { ...seen.schema };
|
|
3714
|
-
if (defId) seen.defId = defId;
|
|
3715
|
-
const schema = seen.schema;
|
|
3716
|
-
for (const key in schema) delete schema[key];
|
|
3717
|
-
schema.$ref = ref;
|
|
3718
|
-
};
|
|
3719
|
-
if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
|
|
3720
|
-
const seen = entry[1];
|
|
3721
|
-
if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
|
|
3722
|
-
|
|
3723
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
|
|
3724
|
-
}
|
|
3725
|
-
for (const entry of ctx.seen.entries()) {
|
|
3726
|
-
const seen = entry[1];
|
|
3727
|
-
if (schema === entry[0]) {
|
|
3728
|
-
extractToDef(entry);
|
|
3729
|
-
continue;
|
|
3730
|
-
}
|
|
3731
|
-
if (ctx.external) {
|
|
3732
|
-
const ext = ctx.external.registry.get(entry[0])?.id;
|
|
3733
|
-
if (schema !== entry[0] && ext) {
|
|
3734
|
-
extractToDef(entry);
|
|
3735
|
-
continue;
|
|
3736
|
-
}
|
|
3737
|
-
}
|
|
3738
|
-
if (ctx.metadataRegistry.get(entry[0])?.id) {
|
|
3739
|
-
extractToDef(entry);
|
|
3740
|
-
continue;
|
|
3741
|
-
}
|
|
3742
|
-
if (seen.cycle) {
|
|
3743
|
-
extractToDef(entry);
|
|
3744
|
-
continue;
|
|
3745
|
-
}
|
|
3746
|
-
if (seen.count > 1) {
|
|
3747
|
-
if (ctx.reused === "ref") {
|
|
3748
|
-
extractToDef(entry);
|
|
3749
|
-
continue;
|
|
3750
|
-
}
|
|
3751
|
-
}
|
|
3752
|
-
}
|
|
3753
|
-
}
|
|
3754
|
-
function finalize(ctx, schema) {
|
|
3755
|
-
const root = ctx.seen.get(schema);
|
|
3756
|
-
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
3757
|
-
const flattenRef = (zodSchema) => {
|
|
3758
|
-
const seen = ctx.seen.get(zodSchema);
|
|
3759
|
-
if (seen.ref === null) return;
|
|
3760
|
-
const schema = seen.def ?? seen.schema;
|
|
3761
|
-
const _cached = { ...schema };
|
|
3762
|
-
const ref = seen.ref;
|
|
3763
|
-
seen.ref = null;
|
|
3764
|
-
if (ref) {
|
|
3765
|
-
flattenRef(ref);
|
|
3766
|
-
const refSeen = ctx.seen.get(ref);
|
|
3767
|
-
const refSchema = refSeen.schema;
|
|
3768
|
-
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
3769
|
-
schema.allOf = schema.allOf ?? [];
|
|
3770
|
-
schema.allOf.push(refSchema);
|
|
3771
|
-
} else Object.assign(schema, refSchema);
|
|
3772
|
-
Object.assign(schema, _cached);
|
|
3773
|
-
if (zodSchema._zod.parent === ref) for (const key in schema) {
|
|
3774
|
-
if (key === "$ref" || key === "allOf") continue;
|
|
3775
|
-
if (!(key in _cached)) delete schema[key];
|
|
3776
|
-
}
|
|
3777
|
-
if (refSchema.$ref && refSeen.def) for (const key in schema) {
|
|
3778
|
-
if (key === "$ref" || key === "allOf") continue;
|
|
3779
|
-
if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) delete schema[key];
|
|
3780
|
-
}
|
|
3781
|
-
}
|
|
3782
|
-
const parent = zodSchema._zod.parent;
|
|
3783
|
-
if (parent && parent !== ref) {
|
|
3784
|
-
flattenRef(parent);
|
|
3785
|
-
const parentSeen = ctx.seen.get(parent);
|
|
3786
|
-
if (parentSeen?.schema.$ref) {
|
|
3787
|
-
schema.$ref = parentSeen.schema.$ref;
|
|
3788
|
-
if (parentSeen.def) for (const key in schema) {
|
|
3789
|
-
if (key === "$ref" || key === "allOf") continue;
|
|
3790
|
-
if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) delete schema[key];
|
|
3791
|
-
}
|
|
3792
|
-
}
|
|
3793
|
-
}
|
|
3794
|
-
ctx.override({
|
|
3795
|
-
zodSchema,
|
|
3796
|
-
jsonSchema: schema,
|
|
3797
|
-
path: seen.path ?? []
|
|
3798
|
-
});
|
|
3799
|
-
};
|
|
3800
|
-
for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
|
|
3801
|
-
const result = {};
|
|
3802
|
-
if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
3803
|
-
else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
3804
|
-
else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
|
|
3805
|
-
else if (ctx.target === "openapi-3.0") {}
|
|
3806
|
-
if (ctx.external?.uri) {
|
|
3807
|
-
const id = ctx.external.registry.get(schema)?.id;
|
|
3808
|
-
if (!id) throw new Error("Schema is missing an `id` property");
|
|
3809
|
-
result.$id = ctx.external.uri(id);
|
|
3810
|
-
}
|
|
3811
|
-
Object.assign(result, root.def ?? root.schema);
|
|
3812
|
-
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
3813
|
-
if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
|
|
3814
|
-
const defs = ctx.external?.defs ?? {};
|
|
3815
|
-
for (const entry of ctx.seen.entries()) {
|
|
3816
|
-
const seen = entry[1];
|
|
3817
|
-
if (seen.def && seen.defId) {
|
|
3818
|
-
if (seen.def.id === seen.defId) delete seen.def.id;
|
|
3819
|
-
defs[seen.defId] = seen.def;
|
|
3820
|
-
}
|
|
3821
|
-
}
|
|
3822
|
-
if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
|
|
3823
|
-
else result.definitions = defs;
|
|
3824
|
-
try {
|
|
3825
|
-
const finalized = JSON.parse(JSON.stringify(result));
|
|
3826
|
-
Object.defineProperty(finalized, "~standard", {
|
|
3827
|
-
value: {
|
|
3828
|
-
...schema["~standard"],
|
|
3829
|
-
jsonSchema: {
|
|
3830
|
-
input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
|
|
3831
|
-
output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
|
|
3832
|
-
}
|
|
3833
|
-
},
|
|
3834
|
-
enumerable: false,
|
|
3835
|
-
writable: false
|
|
3836
|
-
});
|
|
3837
|
-
return finalized;
|
|
3838
|
-
} catch (_err) {
|
|
3839
|
-
throw new Error("Error converting schema to JSON.");
|
|
3840
|
-
}
|
|
3841
|
-
}
|
|
3842
|
-
function isTransforming(_schema, _ctx) {
|
|
3843
|
-
const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
|
|
3844
|
-
if (ctx.seen.has(_schema)) return false;
|
|
3845
|
-
ctx.seen.add(_schema);
|
|
3846
|
-
const def = _schema._zod.def;
|
|
3847
|
-
if (def.type === "transform") return true;
|
|
3848
|
-
if (def.type === "array") return isTransforming(def.element, ctx);
|
|
3849
|
-
if (def.type === "set") return isTransforming(def.valueType, ctx);
|
|
3850
|
-
if (def.type === "lazy") return isTransforming(def.getter(), ctx);
|
|
3851
|
-
if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
|
|
3852
|
-
if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
|
3853
|
-
if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
3854
|
-
if (def.type === "pipe") {
|
|
3855
|
-
if (_schema._zod.traits.has("$ZodCodec")) return true;
|
|
3856
|
-
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
3857
|
-
}
|
|
3858
|
-
if (def.type === "object") {
|
|
3859
|
-
for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
|
|
3860
|
-
return false;
|
|
3861
|
-
}
|
|
3862
|
-
if (def.type === "union") {
|
|
3863
|
-
for (const option of def.options) if (isTransforming(option, ctx)) return true;
|
|
3864
|
-
return false;
|
|
3865
|
-
}
|
|
3866
|
-
if (def.type === "tuple") {
|
|
3867
|
-
for (const item of def.items) if (isTransforming(item, ctx)) return true;
|
|
3868
|
-
if (def.rest && isTransforming(def.rest, ctx)) return true;
|
|
3869
|
-
return false;
|
|
3870
|
-
}
|
|
3871
|
-
return false;
|
|
3872
|
-
}
|
|
3873
|
-
/**
|
|
3874
|
-
* Creates a toJSONSchema method for a schema instance.
|
|
3875
|
-
* This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
|
|
3876
|
-
*/
|
|
3877
|
-
const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
3878
|
-
const ctx = initializeContext({
|
|
3879
|
-
...params,
|
|
3880
|
-
processors
|
|
3881
|
-
});
|
|
3882
|
-
process(schema, ctx);
|
|
3883
|
-
extractDefs(ctx, schema);
|
|
3884
|
-
return finalize(ctx, schema);
|
|
3885
|
-
};
|
|
3886
|
-
const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
3887
|
-
const { libraryOptions, target } = params ?? {};
|
|
3888
|
-
const ctx = initializeContext({
|
|
3889
|
-
...libraryOptions ?? {},
|
|
3890
|
-
target,
|
|
3891
|
-
io,
|
|
3892
|
-
processors
|
|
3893
|
-
});
|
|
3894
|
-
process(schema, ctx);
|
|
3895
|
-
extractDefs(ctx, schema);
|
|
3896
|
-
return finalize(ctx, schema);
|
|
3897
|
-
};
|
|
3898
|
-
//#endregion
|
|
3899
|
-
//#region ../src/node_modules/zod/v4/core/json-schema-processors.js
|
|
3900
|
-
const formatMap = {
|
|
3901
|
-
guid: "uuid",
|
|
3902
|
-
url: "uri",
|
|
3903
|
-
datetime: "date-time",
|
|
3904
|
-
json_string: "json-string",
|
|
3905
|
-
regex: ""
|
|
3906
|
-
};
|
|
3907
|
-
const stringProcessor = (schema, ctx, _json, _params) => {
|
|
3908
|
-
const json = _json;
|
|
3909
|
-
json.type = "string";
|
|
3910
|
-
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
|
|
3911
|
-
if (typeof minimum === "number") json.minLength = minimum;
|
|
3912
|
-
if (typeof maximum === "number") json.maxLength = maximum;
|
|
3913
|
-
if (format) {
|
|
3914
|
-
json.format = formatMap[format] ?? format;
|
|
3915
|
-
if (json.format === "") delete json.format;
|
|
3916
|
-
if (format === "time") delete json.format;
|
|
3917
|
-
}
|
|
3918
|
-
if (contentEncoding) json.contentEncoding = contentEncoding;
|
|
3919
|
-
if (patterns && patterns.size > 0) {
|
|
3920
|
-
const regexes = [...patterns];
|
|
3921
|
-
if (regexes.length === 1) json.pattern = regexes[0].source;
|
|
3922
|
-
else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
|
|
3923
|
-
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
3924
|
-
pattern: regex.source
|
|
3925
|
-
}))];
|
|
3926
|
-
}
|
|
3927
|
-
};
|
|
3928
|
-
const booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
3929
|
-
json.type = "boolean";
|
|
3930
|
-
};
|
|
3931
|
-
const voidProcessor = (_schema, ctx, _json, _params) => {
|
|
3932
|
-
if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
|
|
3933
|
-
};
|
|
3934
|
-
const neverProcessor = (_schema, _ctx, json, _params) => {
|
|
3935
|
-
json.not = {};
|
|
3936
|
-
};
|
|
3937
|
-
const enumProcessor = (schema, _ctx, json, _params) => {
|
|
3938
|
-
const def = schema._zod.def;
|
|
3939
|
-
const values = getEnumValues(def.entries);
|
|
3940
|
-
if (values.every((v) => typeof v === "number")) json.type = "number";
|
|
3941
|
-
if (values.every((v) => typeof v === "string")) json.type = "string";
|
|
3942
|
-
json.enum = values;
|
|
3943
|
-
};
|
|
3944
|
-
const customProcessor = (_schema, ctx, _json, _params) => {
|
|
3945
|
-
if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
|
|
3946
|
-
};
|
|
3947
|
-
const transformProcessor = (_schema, ctx, _json, _params) => {
|
|
3948
|
-
if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
|
|
3949
|
-
};
|
|
3950
|
-
const arrayProcessor = (schema, ctx, _json, params) => {
|
|
3951
|
-
const json = _json;
|
|
3952
|
-
const def = schema._zod.def;
|
|
3953
|
-
const { minimum, maximum } = schema._zod.bag;
|
|
3954
|
-
if (typeof minimum === "number") json.minItems = minimum;
|
|
3955
|
-
if (typeof maximum === "number") json.maxItems = maximum;
|
|
3956
|
-
json.type = "array";
|
|
3957
|
-
json.items = process(def.element, ctx, {
|
|
3958
|
-
...params,
|
|
3959
|
-
path: [...params.path, "items"]
|
|
3960
|
-
});
|
|
3961
|
-
};
|
|
3962
|
-
const objectProcessor = (schema, ctx, _json, params) => {
|
|
3963
|
-
const json = _json;
|
|
3964
|
-
const def = schema._zod.def;
|
|
3965
|
-
json.type = "object";
|
|
3966
|
-
json.properties = {};
|
|
3967
|
-
const shape = def.shape;
|
|
3968
|
-
for (const key in shape) json.properties[key] = process(shape[key], ctx, {
|
|
3969
|
-
...params,
|
|
3970
|
-
path: [
|
|
3971
|
-
...params.path,
|
|
3972
|
-
"properties",
|
|
3973
|
-
key
|
|
3974
|
-
]
|
|
3975
|
-
});
|
|
3976
|
-
const allKeys = new Set(Object.keys(shape));
|
|
3977
|
-
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
3978
|
-
const v = def.shape[key]._zod;
|
|
3979
|
-
if (ctx.io === "input") return v.optin === void 0;
|
|
3980
|
-
else return v.optout === void 0;
|
|
3981
|
-
}));
|
|
3982
|
-
if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
|
|
3983
|
-
if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
|
|
3984
|
-
else if (!def.catchall) {
|
|
3985
|
-
if (ctx.io === "output") json.additionalProperties = false;
|
|
3986
|
-
} else if (def.catchall) json.additionalProperties = process(def.catchall, ctx, {
|
|
3987
|
-
...params,
|
|
3988
|
-
path: [...params.path, "additionalProperties"]
|
|
3989
|
-
});
|
|
3990
|
-
};
|
|
3991
|
-
const unionProcessor = (schema, ctx, json, params) => {
|
|
3992
|
-
const def = schema._zod.def;
|
|
3993
|
-
const isExclusive = def.inclusive === false;
|
|
3994
|
-
const options = def.options.map((x, i) => process(x, ctx, {
|
|
3995
|
-
...params,
|
|
3996
|
-
path: [
|
|
3997
|
-
...params.path,
|
|
3998
|
-
isExclusive ? "oneOf" : "anyOf",
|
|
3999
|
-
i
|
|
4000
|
-
]
|
|
4001
|
-
}));
|
|
4002
|
-
if (isExclusive) json.oneOf = options;
|
|
4003
|
-
else json.anyOf = options;
|
|
4004
|
-
};
|
|
4005
|
-
const intersectionProcessor = (schema, ctx, json, params) => {
|
|
4006
|
-
const def = schema._zod.def;
|
|
4007
|
-
const a = process(def.left, ctx, {
|
|
4008
|
-
...params,
|
|
4009
|
-
path: [
|
|
4010
|
-
...params.path,
|
|
4011
|
-
"allOf",
|
|
4012
|
-
0
|
|
4013
|
-
]
|
|
4014
|
-
});
|
|
4015
|
-
const b = process(def.right, ctx, {
|
|
4016
|
-
...params,
|
|
4017
|
-
path: [
|
|
4018
|
-
...params.path,
|
|
4019
|
-
"allOf",
|
|
4020
|
-
1
|
|
810
|
+
})
|
|
811
|
+
]
|
|
812
|
+
}),
|
|
813
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
814
|
+
className: MemorySection_module_css_default.group,
|
|
815
|
+
children: [
|
|
816
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
817
|
+
className: MemorySection_module_css_default.groupHead,
|
|
818
|
+
children: t("memory.editor")
|
|
819
|
+
}),
|
|
820
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
821
|
+
className: MemorySection_module_css_default.rowDesc,
|
|
822
|
+
children: t("memory.editor.hint")
|
|
823
|
+
}),
|
|
824
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
825
|
+
className: MemorySection_module_css_default.textarea,
|
|
826
|
+
value: state.draft,
|
|
827
|
+
placeholder: t("memory.editor.placeholder"),
|
|
828
|
+
rows: 12,
|
|
829
|
+
disabled: !ready || saveState === "saving",
|
|
830
|
+
onChange: (event) => {
|
|
831
|
+
setDraft(event.target.value);
|
|
832
|
+
}
|
|
833
|
+
}),
|
|
834
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
835
|
+
className: MemorySection_module_css_default.actions,
|
|
836
|
+
children: [
|
|
837
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
838
|
+
type: "button",
|
|
839
|
+
className: MemorySection_module_css_default.primary,
|
|
840
|
+
disabled: !ready || saveState === "saving",
|
|
841
|
+
onClick: () => {
|
|
842
|
+
save();
|
|
843
|
+
},
|
|
844
|
+
children: saveState === "saving" ? t("memory.saving") : t("memory.save")
|
|
845
|
+
}),
|
|
846
|
+
saveState === "saved" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
847
|
+
className: MemorySection_module_css_default.ok,
|
|
848
|
+
role: "status",
|
|
849
|
+
children: t("memory.saved")
|
|
850
|
+
}),
|
|
851
|
+
saveState === "failed" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
852
|
+
className: MemorySection_module_css_default.error,
|
|
853
|
+
role: "alert",
|
|
854
|
+
children: error ?? t("memory.saveFailed")
|
|
855
|
+
})
|
|
856
|
+
]
|
|
857
|
+
})
|
|
858
|
+
]
|
|
859
|
+
})
|
|
4021
860
|
]
|
|
4022
861
|
});
|
|
4023
|
-
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
4024
|
-
json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
|
|
4025
|
-
};
|
|
4026
|
-
const nullableProcessor = (schema, ctx, json, params) => {
|
|
4027
|
-
const def = schema._zod.def;
|
|
4028
|
-
const inner = process(def.innerType, ctx, params);
|
|
4029
|
-
const seen = ctx.seen.get(schema);
|
|
4030
|
-
if (ctx.target === "openapi-3.0") {
|
|
4031
|
-
seen.ref = def.innerType;
|
|
4032
|
-
json.nullable = true;
|
|
4033
|
-
} else json.anyOf = [inner, { type: "null" }];
|
|
4034
|
-
};
|
|
4035
|
-
const nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
4036
|
-
const def = schema._zod.def;
|
|
4037
|
-
process(def.innerType, ctx, params);
|
|
4038
|
-
const seen = ctx.seen.get(schema);
|
|
4039
|
-
seen.ref = def.innerType;
|
|
4040
|
-
};
|
|
4041
|
-
const defaultProcessor = (schema, ctx, json, params) => {
|
|
4042
|
-
const def = schema._zod.def;
|
|
4043
|
-
process(def.innerType, ctx, params);
|
|
4044
|
-
const seen = ctx.seen.get(schema);
|
|
4045
|
-
seen.ref = def.innerType;
|
|
4046
|
-
json.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
4047
|
-
};
|
|
4048
|
-
const prefaultProcessor = (schema, ctx, json, params) => {
|
|
4049
|
-
const def = schema._zod.def;
|
|
4050
|
-
process(def.innerType, ctx, params);
|
|
4051
|
-
const seen = ctx.seen.get(schema);
|
|
4052
|
-
seen.ref = def.innerType;
|
|
4053
|
-
if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
4054
|
-
};
|
|
4055
|
-
const catchProcessor = (schema, ctx, json, params) => {
|
|
4056
|
-
const def = schema._zod.def;
|
|
4057
|
-
process(def.innerType, ctx, params);
|
|
4058
|
-
const seen = ctx.seen.get(schema);
|
|
4059
|
-
seen.ref = def.innerType;
|
|
4060
|
-
let catchValue;
|
|
4061
|
-
try {
|
|
4062
|
-
catchValue = def.catchValue(void 0);
|
|
4063
|
-
} catch {
|
|
4064
|
-
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
4065
|
-
}
|
|
4066
|
-
json.default = catchValue;
|
|
4067
|
-
};
|
|
4068
|
-
const pipeProcessor = (schema, ctx, _json, params) => {
|
|
4069
|
-
const def = schema._zod.def;
|
|
4070
|
-
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
4071
|
-
const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
|
|
4072
|
-
process(innerType, ctx, params);
|
|
4073
|
-
const seen = ctx.seen.get(schema);
|
|
4074
|
-
seen.ref = innerType;
|
|
4075
|
-
};
|
|
4076
|
-
const readonlyProcessor = (schema, ctx, json, params) => {
|
|
4077
|
-
const def = schema._zod.def;
|
|
4078
|
-
process(def.innerType, ctx, params);
|
|
4079
|
-
const seen = ctx.seen.get(schema);
|
|
4080
|
-
seen.ref = def.innerType;
|
|
4081
|
-
json.readOnly = true;
|
|
4082
|
-
};
|
|
4083
|
-
const optionalProcessor = (schema, ctx, _json, params) => {
|
|
4084
|
-
const def = schema._zod.def;
|
|
4085
|
-
process(def.innerType, ctx, params);
|
|
4086
|
-
const seen = ctx.seen.get(schema);
|
|
4087
|
-
seen.ref = def.innerType;
|
|
4088
|
-
};
|
|
4089
|
-
//#endregion
|
|
4090
|
-
//#region ../src/node_modules/zod/v4/classic/iso.js
|
|
4091
|
-
const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
4092
|
-
$ZodISODateTime.init(inst, def);
|
|
4093
|
-
ZodStringFormat.init(inst, def);
|
|
4094
|
-
});
|
|
4095
|
-
function datetime(params) {
|
|
4096
|
-
return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
|
|
4097
|
-
}
|
|
4098
|
-
const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
|
|
4099
|
-
$ZodISODate.init(inst, def);
|
|
4100
|
-
ZodStringFormat.init(inst, def);
|
|
4101
|
-
});
|
|
4102
|
-
function date(params) {
|
|
4103
|
-
return /* @__PURE__ */ _isoDate(ZodISODate, params);
|
|
4104
|
-
}
|
|
4105
|
-
const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
|
|
4106
|
-
$ZodISOTime.init(inst, def);
|
|
4107
|
-
ZodStringFormat.init(inst, def);
|
|
4108
|
-
});
|
|
4109
|
-
function time(params) {
|
|
4110
|
-
return /* @__PURE__ */ _isoTime(ZodISOTime, params);
|
|
4111
|
-
}
|
|
4112
|
-
const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
|
|
4113
|
-
$ZodISODuration.init(inst, def);
|
|
4114
|
-
ZodStringFormat.init(inst, def);
|
|
4115
|
-
});
|
|
4116
|
-
function duration(params) {
|
|
4117
|
-
return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
|
|
4118
862
|
}
|
|
4119
863
|
//#endregion
|
|
4120
|
-
//#region ../src/
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
864
|
+
//#region ../src/client/memoryStore.ts
|
|
865
|
+
/** 把持久化配置解码成三个字段(形状不对时给安全默认值)。 */
|
|
866
|
+
function decodeConfig(section) {
|
|
867
|
+
const source = typeof section === "object" && section !== null && !Array.isArray(section) ? section : {};
|
|
868
|
+
return {
|
|
869
|
+
memoryEnabled: source.memoryEnabled === true,
|
|
870
|
+
autoMemory: source.autoMemory === true,
|
|
871
|
+
memoryText: typeof source.memoryText === "string" ? source.memoryText : ""
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
/** 设置页控制器(每个浏览器页面一个)。 */
|
|
875
|
+
var MemorySettingsController = class {
|
|
876
|
+
form;
|
|
877
|
+
store = (0, _deepseek_ai_dsh_client_store.createSnapshotStore)({
|
|
878
|
+
status: "loading",
|
|
879
|
+
config: decodeConfig(void 0),
|
|
880
|
+
draft: "",
|
|
881
|
+
saveState: "idle",
|
|
882
|
+
error: null
|
|
4138
883
|
});
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
|
|
4150
|
-
const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
|
|
4151
|
-
const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
|
|
4152
|
-
const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
|
|
4153
|
-
const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
4154
|
-
const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
4155
|
-
//#endregion
|
|
4156
|
-
//#region ../src/node_modules/zod/v4/classic/schemas.js
|
|
4157
|
-
const _installedGroups = /* @__PURE__ */ new WeakMap();
|
|
4158
|
-
function _installLazyMethods(inst, group, methods) {
|
|
4159
|
-
const proto = Object.getPrototypeOf(inst);
|
|
4160
|
-
let installed = _installedGroups.get(proto);
|
|
4161
|
-
if (!installed) {
|
|
4162
|
-
installed = /* @__PURE__ */ new Set();
|
|
4163
|
-
_installedGroups.set(proto, installed);
|
|
884
|
+
unsubscribe;
|
|
885
|
+
/**
|
|
886
|
+
* @param form - 本插件在设置通道里的配置表。
|
|
887
|
+
*/
|
|
888
|
+
constructor(form) {
|
|
889
|
+
this.form = form;
|
|
890
|
+
this.unsubscribe = form.subscribe(() => {
|
|
891
|
+
this.derive();
|
|
892
|
+
});
|
|
893
|
+
this.derive();
|
|
4164
894
|
}
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
},
|
|
4182
|
-
set(v) {
|
|
4183
|
-
Object.defineProperty(this, key, {
|
|
4184
|
-
configurable: true,
|
|
4185
|
-
writable: true,
|
|
4186
|
-
enumerable: true,
|
|
4187
|
-
value: v
|
|
4188
|
-
});
|
|
4189
|
-
}
|
|
895
|
+
/** 释放订阅。 */
|
|
896
|
+
dispose() {
|
|
897
|
+
this.unsubscribe();
|
|
898
|
+
}
|
|
899
|
+
/** 切换一个开关。 */
|
|
900
|
+
async toggle(field, next) {
|
|
901
|
+
await this.form.set(field, next);
|
|
902
|
+
}
|
|
903
|
+
/** 更新编辑框草稿(保存前不写配置)。 */
|
|
904
|
+
setDraft(text) {
|
|
905
|
+
const snapshot = this.store.getSnapshot();
|
|
906
|
+
this.store.set({
|
|
907
|
+
...snapshot,
|
|
908
|
+
draft: text,
|
|
909
|
+
saveState: "idle",
|
|
910
|
+
error: null
|
|
4190
911
|
});
|
|
4191
912
|
}
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
4206
|
-
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
4207
|
-
inst.spa = inst.safeParseAsync;
|
|
4208
|
-
inst.encode = (data, params) => encode(inst, data, params);
|
|
4209
|
-
inst.decode = (data, params) => decode(inst, data, params);
|
|
4210
|
-
inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
|
|
4211
|
-
inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
|
|
4212
|
-
inst.safeEncode = (data, params) => safeEncode(inst, data, params);
|
|
4213
|
-
inst.safeDecode = (data, params) => safeDecode(inst, data, params);
|
|
4214
|
-
inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
|
|
4215
|
-
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
|
|
4216
|
-
_installLazyMethods(inst, "ZodType", {
|
|
4217
|
-
check(...chks) {
|
|
4218
|
-
const def = this.def;
|
|
4219
|
-
return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
|
|
4220
|
-
check: ch,
|
|
4221
|
-
def: { check: "custom" },
|
|
4222
|
-
onattach: []
|
|
4223
|
-
} } : ch)] }), { parent: true });
|
|
4224
|
-
},
|
|
4225
|
-
with(...chks) {
|
|
4226
|
-
return this.check(...chks);
|
|
4227
|
-
},
|
|
4228
|
-
clone(def, params) {
|
|
4229
|
-
return clone(this, def, params);
|
|
4230
|
-
},
|
|
4231
|
-
brand() {
|
|
4232
|
-
return this;
|
|
4233
|
-
},
|
|
4234
|
-
register(reg, meta) {
|
|
4235
|
-
reg.add(this, meta);
|
|
4236
|
-
return this;
|
|
4237
|
-
},
|
|
4238
|
-
refine(check, params) {
|
|
4239
|
-
return this.check(refine(check, params));
|
|
4240
|
-
},
|
|
4241
|
-
superRefine(refinement, params) {
|
|
4242
|
-
return this.check(superRefine(refinement, params));
|
|
4243
|
-
},
|
|
4244
|
-
overwrite(fn) {
|
|
4245
|
-
return this.check(/* @__PURE__ */ _overwrite(fn));
|
|
4246
|
-
},
|
|
4247
|
-
optional() {
|
|
4248
|
-
return optional(this);
|
|
4249
|
-
},
|
|
4250
|
-
exactOptional() {
|
|
4251
|
-
return exactOptional(this);
|
|
4252
|
-
},
|
|
4253
|
-
nullable() {
|
|
4254
|
-
return nullable(this);
|
|
4255
|
-
},
|
|
4256
|
-
nullish() {
|
|
4257
|
-
return optional(nullable(this));
|
|
4258
|
-
},
|
|
4259
|
-
nonoptional(params) {
|
|
4260
|
-
return nonoptional(this, params);
|
|
4261
|
-
},
|
|
4262
|
-
array() {
|
|
4263
|
-
return array(this);
|
|
4264
|
-
},
|
|
4265
|
-
or(arg) {
|
|
4266
|
-
return union([this, arg]);
|
|
4267
|
-
},
|
|
4268
|
-
and(arg) {
|
|
4269
|
-
return intersection(this, arg);
|
|
4270
|
-
},
|
|
4271
|
-
transform(tx) {
|
|
4272
|
-
return pipe(this, transform(tx));
|
|
4273
|
-
},
|
|
4274
|
-
default(d) {
|
|
4275
|
-
return _default(this, d);
|
|
4276
|
-
},
|
|
4277
|
-
prefault(d) {
|
|
4278
|
-
return prefault(this, d);
|
|
4279
|
-
},
|
|
4280
|
-
catch(params) {
|
|
4281
|
-
return _catch(this, params);
|
|
4282
|
-
},
|
|
4283
|
-
pipe(target) {
|
|
4284
|
-
return pipe(this, target);
|
|
4285
|
-
},
|
|
4286
|
-
readonly() {
|
|
4287
|
-
return readonly(this);
|
|
4288
|
-
},
|
|
4289
|
-
describe(description) {
|
|
4290
|
-
const cl = this.clone();
|
|
4291
|
-
globalRegistry.add(cl, { description });
|
|
4292
|
-
return cl;
|
|
4293
|
-
},
|
|
4294
|
-
meta(...args) {
|
|
4295
|
-
if (args.length === 0) return globalRegistry.get(this);
|
|
4296
|
-
const cl = this.clone();
|
|
4297
|
-
globalRegistry.add(cl, args[0]);
|
|
4298
|
-
return cl;
|
|
4299
|
-
},
|
|
4300
|
-
isOptional() {
|
|
4301
|
-
return this.safeParse(void 0).success;
|
|
4302
|
-
},
|
|
4303
|
-
isNullable() {
|
|
4304
|
-
return this.safeParse(null).success;
|
|
4305
|
-
},
|
|
4306
|
-
apply(fn) {
|
|
4307
|
-
return fn(this);
|
|
4308
|
-
}
|
|
4309
|
-
});
|
|
4310
|
-
Object.defineProperty(inst, "description", {
|
|
4311
|
-
get() {
|
|
4312
|
-
return globalRegistry.get(inst)?.description;
|
|
4313
|
-
},
|
|
4314
|
-
configurable: true
|
|
4315
|
-
});
|
|
4316
|
-
return inst;
|
|
4317
|
-
});
|
|
4318
|
-
/** @internal */
|
|
4319
|
-
const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
|
|
4320
|
-
$ZodString.init(inst, def);
|
|
4321
|
-
ZodType.init(inst, def);
|
|
4322
|
-
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
|
|
4323
|
-
const bag = inst._zod.bag;
|
|
4324
|
-
inst.format = bag.format ?? null;
|
|
4325
|
-
inst.minLength = bag.minimum ?? null;
|
|
4326
|
-
inst.maxLength = bag.maximum ?? null;
|
|
4327
|
-
_installLazyMethods(inst, "_ZodString", {
|
|
4328
|
-
regex(...args) {
|
|
4329
|
-
return this.check(/* @__PURE__ */ _regex(...args));
|
|
4330
|
-
},
|
|
4331
|
-
includes(...args) {
|
|
4332
|
-
return this.check(/* @__PURE__ */ _includes(...args));
|
|
4333
|
-
},
|
|
4334
|
-
startsWith(...args) {
|
|
4335
|
-
return this.check(/* @__PURE__ */ _startsWith(...args));
|
|
4336
|
-
},
|
|
4337
|
-
endsWith(...args) {
|
|
4338
|
-
return this.check(/* @__PURE__ */ _endsWith(...args));
|
|
4339
|
-
},
|
|
4340
|
-
min(...args) {
|
|
4341
|
-
return this.check(/* @__PURE__ */ _minLength(...args));
|
|
4342
|
-
},
|
|
4343
|
-
max(...args) {
|
|
4344
|
-
return this.check(/* @__PURE__ */ _maxLength(...args));
|
|
4345
|
-
},
|
|
4346
|
-
length(...args) {
|
|
4347
|
-
return this.check(/* @__PURE__ */ _length(...args));
|
|
4348
|
-
},
|
|
4349
|
-
nonempty(...args) {
|
|
4350
|
-
return this.check(/* @__PURE__ */ _minLength(1, ...args));
|
|
4351
|
-
},
|
|
4352
|
-
lowercase(params) {
|
|
4353
|
-
return this.check(/* @__PURE__ */ _lowercase(params));
|
|
4354
|
-
},
|
|
4355
|
-
uppercase(params) {
|
|
4356
|
-
return this.check(/* @__PURE__ */ _uppercase(params));
|
|
4357
|
-
},
|
|
4358
|
-
trim() {
|
|
4359
|
-
return this.check(/* @__PURE__ */ _trim());
|
|
4360
|
-
},
|
|
4361
|
-
normalize(...args) {
|
|
4362
|
-
return this.check(/* @__PURE__ */ _normalize(...args));
|
|
4363
|
-
},
|
|
4364
|
-
toLowerCase() {
|
|
4365
|
-
return this.check(/* @__PURE__ */ _toLowerCase());
|
|
4366
|
-
},
|
|
4367
|
-
toUpperCase() {
|
|
4368
|
-
return this.check(/* @__PURE__ */ _toUpperCase());
|
|
4369
|
-
},
|
|
4370
|
-
slugify() {
|
|
4371
|
-
return this.check(/* @__PURE__ */ _slugify());
|
|
4372
|
-
}
|
|
4373
|
-
});
|
|
4374
|
-
});
|
|
4375
|
-
const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
|
|
4376
|
-
$ZodString.init(inst, def);
|
|
4377
|
-
_ZodString.init(inst, def);
|
|
4378
|
-
inst.email = (params) => inst.check(/* @__PURE__ */ _email(ZodEmail, params));
|
|
4379
|
-
inst.url = (params) => inst.check(/* @__PURE__ */ _url(ZodURL, params));
|
|
4380
|
-
inst.jwt = (params) => inst.check(/* @__PURE__ */ _jwt(ZodJWT, params));
|
|
4381
|
-
inst.emoji = (params) => inst.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
|
|
4382
|
-
inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
|
|
4383
|
-
inst.uuid = (params) => inst.check(/* @__PURE__ */ _uuid(ZodUUID, params));
|
|
4384
|
-
inst.uuidv4 = (params) => inst.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
|
|
4385
|
-
inst.uuidv6 = (params) => inst.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
|
|
4386
|
-
inst.uuidv7 = (params) => inst.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
|
|
4387
|
-
inst.nanoid = (params) => inst.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
|
|
4388
|
-
inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
|
|
4389
|
-
inst.cuid = (params) => inst.check(/* @__PURE__ */ _cuid(ZodCUID, params));
|
|
4390
|
-
inst.cuid2 = (params) => inst.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
|
|
4391
|
-
inst.ulid = (params) => inst.check(/* @__PURE__ */ _ulid(ZodULID, params));
|
|
4392
|
-
inst.base64 = (params) => inst.check(/* @__PURE__ */ _base64(ZodBase64, params));
|
|
4393
|
-
inst.base64url = (params) => inst.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
|
|
4394
|
-
inst.xid = (params) => inst.check(/* @__PURE__ */ _xid(ZodXID, params));
|
|
4395
|
-
inst.ksuid = (params) => inst.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
|
|
4396
|
-
inst.ipv4 = (params) => inst.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
|
|
4397
|
-
inst.ipv6 = (params) => inst.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
|
|
4398
|
-
inst.cidrv4 = (params) => inst.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
|
|
4399
|
-
inst.cidrv6 = (params) => inst.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
|
|
4400
|
-
inst.e164 = (params) => inst.check(/* @__PURE__ */ _e164(ZodE164, params));
|
|
4401
|
-
inst.datetime = (params) => inst.check(datetime(params));
|
|
4402
|
-
inst.date = (params) => inst.check(date(params));
|
|
4403
|
-
inst.time = (params) => inst.check(time(params));
|
|
4404
|
-
inst.duration = (params) => inst.check(duration(params));
|
|
4405
|
-
});
|
|
4406
|
-
function string(params) {
|
|
4407
|
-
return /* @__PURE__ */ _string(ZodString, params);
|
|
4408
|
-
}
|
|
4409
|
-
const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def) => {
|
|
4410
|
-
$ZodStringFormat.init(inst, def);
|
|
4411
|
-
_ZodString.init(inst, def);
|
|
4412
|
-
});
|
|
4413
|
-
const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
|
|
4414
|
-
$ZodEmail.init(inst, def);
|
|
4415
|
-
ZodStringFormat.init(inst, def);
|
|
4416
|
-
});
|
|
4417
|
-
const ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (inst, def) => {
|
|
4418
|
-
$ZodGUID.init(inst, def);
|
|
4419
|
-
ZodStringFormat.init(inst, def);
|
|
4420
|
-
});
|
|
4421
|
-
const ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (inst, def) => {
|
|
4422
|
-
$ZodUUID.init(inst, def);
|
|
4423
|
-
ZodStringFormat.init(inst, def);
|
|
4424
|
-
});
|
|
4425
|
-
const ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def) => {
|
|
4426
|
-
$ZodURL.init(inst, def);
|
|
4427
|
-
ZodStringFormat.init(inst, def);
|
|
4428
|
-
});
|
|
4429
|
-
const ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (inst, def) => {
|
|
4430
|
-
$ZodEmoji.init(inst, def);
|
|
4431
|
-
ZodStringFormat.init(inst, def);
|
|
4432
|
-
});
|
|
4433
|
-
const ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (inst, def) => {
|
|
4434
|
-
$ZodNanoID.init(inst, def);
|
|
4435
|
-
ZodStringFormat.init(inst, def);
|
|
4436
|
-
});
|
|
4437
|
-
/**
|
|
4438
|
-
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
4439
|
-
* (timestamps embedded in the id). Use {@link ZodCUID2} instead.
|
|
4440
|
-
* See https://github.com/paralleldrive/cuid.
|
|
4441
|
-
*/
|
|
4442
|
-
const ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (inst, def) => {
|
|
4443
|
-
$ZodCUID.init(inst, def);
|
|
4444
|
-
ZodStringFormat.init(inst, def);
|
|
4445
|
-
});
|
|
4446
|
-
const ZodCUID2 = /*@__PURE__*/ $constructor("ZodCUID2", (inst, def) => {
|
|
4447
|
-
$ZodCUID2.init(inst, def);
|
|
4448
|
-
ZodStringFormat.init(inst, def);
|
|
4449
|
-
});
|
|
4450
|
-
const ZodULID = /*@__PURE__*/ $constructor("ZodULID", (inst, def) => {
|
|
4451
|
-
$ZodULID.init(inst, def);
|
|
4452
|
-
ZodStringFormat.init(inst, def);
|
|
4453
|
-
});
|
|
4454
|
-
const ZodXID = /*@__PURE__*/ $constructor("ZodXID", (inst, def) => {
|
|
4455
|
-
$ZodXID.init(inst, def);
|
|
4456
|
-
ZodStringFormat.init(inst, def);
|
|
4457
|
-
});
|
|
4458
|
-
const ZodKSUID = /*@__PURE__*/ $constructor("ZodKSUID", (inst, def) => {
|
|
4459
|
-
$ZodKSUID.init(inst, def);
|
|
4460
|
-
ZodStringFormat.init(inst, def);
|
|
4461
|
-
});
|
|
4462
|
-
const ZodIPv4 = /*@__PURE__*/ $constructor("ZodIPv4", (inst, def) => {
|
|
4463
|
-
$ZodIPv4.init(inst, def);
|
|
4464
|
-
ZodStringFormat.init(inst, def);
|
|
4465
|
-
});
|
|
4466
|
-
const ZodIPv6 = /*@__PURE__*/ $constructor("ZodIPv6", (inst, def) => {
|
|
4467
|
-
$ZodIPv6.init(inst, def);
|
|
4468
|
-
ZodStringFormat.init(inst, def);
|
|
4469
|
-
});
|
|
4470
|
-
const ZodCIDRv4 = /*@__PURE__*/ $constructor("ZodCIDRv4", (inst, def) => {
|
|
4471
|
-
$ZodCIDRv4.init(inst, def);
|
|
4472
|
-
ZodStringFormat.init(inst, def);
|
|
4473
|
-
});
|
|
4474
|
-
const ZodCIDRv6 = /*@__PURE__*/ $constructor("ZodCIDRv6", (inst, def) => {
|
|
4475
|
-
$ZodCIDRv6.init(inst, def);
|
|
4476
|
-
ZodStringFormat.init(inst, def);
|
|
4477
|
-
});
|
|
4478
|
-
const ZodBase64 = /*@__PURE__*/ $constructor("ZodBase64", (inst, def) => {
|
|
4479
|
-
$ZodBase64.init(inst, def);
|
|
4480
|
-
ZodStringFormat.init(inst, def);
|
|
4481
|
-
});
|
|
4482
|
-
const ZodBase64URL = /*@__PURE__*/ $constructor("ZodBase64URL", (inst, def) => {
|
|
4483
|
-
$ZodBase64URL.init(inst, def);
|
|
4484
|
-
ZodStringFormat.init(inst, def);
|
|
4485
|
-
});
|
|
4486
|
-
const ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (inst, def) => {
|
|
4487
|
-
$ZodE164.init(inst, def);
|
|
4488
|
-
ZodStringFormat.init(inst, def);
|
|
4489
|
-
});
|
|
4490
|
-
const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
|
|
4491
|
-
$ZodJWT.init(inst, def);
|
|
4492
|
-
ZodStringFormat.init(inst, def);
|
|
4493
|
-
});
|
|
4494
|
-
const ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (inst, def) => {
|
|
4495
|
-
$ZodBoolean.init(inst, def);
|
|
4496
|
-
ZodType.init(inst, def);
|
|
4497
|
-
inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
|
|
4498
|
-
});
|
|
4499
|
-
function boolean(params) {
|
|
4500
|
-
return /* @__PURE__ */ _boolean(ZodBoolean, params);
|
|
4501
|
-
}
|
|
4502
|
-
const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
|
|
4503
|
-
$ZodUnknown.init(inst, def);
|
|
4504
|
-
ZodType.init(inst, def);
|
|
4505
|
-
inst._zod.processJSONSchema = (ctx, json, params) => void 0;
|
|
4506
|
-
});
|
|
4507
|
-
function unknown() {
|
|
4508
|
-
return /* @__PURE__ */ _unknown(ZodUnknown);
|
|
4509
|
-
}
|
|
4510
|
-
const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
|
|
4511
|
-
$ZodNever.init(inst, def);
|
|
4512
|
-
ZodType.init(inst, def);
|
|
4513
|
-
inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
|
|
4514
|
-
});
|
|
4515
|
-
function never(params) {
|
|
4516
|
-
return /* @__PURE__ */ _never(ZodNever, params);
|
|
4517
|
-
}
|
|
4518
|
-
const ZodVoid = /*@__PURE__*/ $constructor("ZodVoid", (inst, def) => {
|
|
4519
|
-
$ZodVoid.init(inst, def);
|
|
4520
|
-
ZodType.init(inst, def);
|
|
4521
|
-
inst._zod.processJSONSchema = (ctx, json, params) => voidProcessor(inst, ctx, json, params);
|
|
4522
|
-
});
|
|
4523
|
-
function _void(params) {
|
|
4524
|
-
return /* @__PURE__ */ _void$1(ZodVoid, params);
|
|
4525
|
-
}
|
|
4526
|
-
const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
|
|
4527
|
-
$ZodArray.init(inst, def);
|
|
4528
|
-
ZodType.init(inst, def);
|
|
4529
|
-
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
4530
|
-
inst.element = def.element;
|
|
4531
|
-
_installLazyMethods(inst, "ZodArray", {
|
|
4532
|
-
min(n, params) {
|
|
4533
|
-
return this.check(/* @__PURE__ */ _minLength(n, params));
|
|
4534
|
-
},
|
|
4535
|
-
nonempty(params) {
|
|
4536
|
-
return this.check(/* @__PURE__ */ _minLength(1, params));
|
|
4537
|
-
},
|
|
4538
|
-
max(n, params) {
|
|
4539
|
-
return this.check(/* @__PURE__ */ _maxLength(n, params));
|
|
4540
|
-
},
|
|
4541
|
-
length(n, params) {
|
|
4542
|
-
return this.check(/* @__PURE__ */ _length(n, params));
|
|
4543
|
-
},
|
|
4544
|
-
unwrap() {
|
|
4545
|
-
return this.element;
|
|
4546
|
-
}
|
|
4547
|
-
});
|
|
4548
|
-
});
|
|
4549
|
-
function array(element, params) {
|
|
4550
|
-
return /* @__PURE__ */ _array(ZodArray, element, params);
|
|
4551
|
-
}
|
|
4552
|
-
const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
|
|
4553
|
-
$ZodObjectJIT.init(inst, def);
|
|
4554
|
-
ZodType.init(inst, def);
|
|
4555
|
-
inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
|
|
4556
|
-
defineLazy(inst, "shape", () => {
|
|
4557
|
-
return def.shape;
|
|
4558
|
-
});
|
|
4559
|
-
_installLazyMethods(inst, "ZodObject", {
|
|
4560
|
-
keyof() {
|
|
4561
|
-
return _enum(Object.keys(this._zod.def.shape));
|
|
4562
|
-
},
|
|
4563
|
-
catchall(catchall) {
|
|
4564
|
-
return this.clone({
|
|
4565
|
-
...this._zod.def,
|
|
4566
|
-
catchall
|
|
4567
|
-
});
|
|
4568
|
-
},
|
|
4569
|
-
passthrough() {
|
|
4570
|
-
return this.clone({
|
|
4571
|
-
...this._zod.def,
|
|
4572
|
-
catchall: unknown()
|
|
4573
|
-
});
|
|
4574
|
-
},
|
|
4575
|
-
loose() {
|
|
4576
|
-
return this.clone({
|
|
4577
|
-
...this._zod.def,
|
|
4578
|
-
catchall: unknown()
|
|
4579
|
-
});
|
|
4580
|
-
},
|
|
4581
|
-
strict() {
|
|
4582
|
-
return this.clone({
|
|
4583
|
-
...this._zod.def,
|
|
4584
|
-
catchall: never()
|
|
913
|
+
/** 保存草稿到 memoryText。 */
|
|
914
|
+
async save() {
|
|
915
|
+
const snapshot = this.store.getSnapshot();
|
|
916
|
+
this.store.set({
|
|
917
|
+
...snapshot,
|
|
918
|
+
saveState: "saving",
|
|
919
|
+
error: null
|
|
920
|
+
});
|
|
921
|
+
try {
|
|
922
|
+
await this.form.set("memoryText", snapshot.draft);
|
|
923
|
+
this.store.set({
|
|
924
|
+
...this.store.getSnapshot(),
|
|
925
|
+
saveState: "saved"
|
|
4585
926
|
});
|
|
4586
|
-
}
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
927
|
+
} catch (error) {
|
|
928
|
+
this.store.set({
|
|
929
|
+
...this.store.getSnapshot(),
|
|
930
|
+
saveState: "failed",
|
|
931
|
+
error: error instanceof Error ? error.message : String(error)
|
|
4591
932
|
});
|
|
4592
|
-
},
|
|
4593
|
-
extend(incoming) {
|
|
4594
|
-
return extend(this, incoming);
|
|
4595
|
-
},
|
|
4596
|
-
safeExtend(incoming) {
|
|
4597
|
-
return safeExtend(this, incoming);
|
|
4598
|
-
},
|
|
4599
|
-
merge(other) {
|
|
4600
|
-
return merge(this, other);
|
|
4601
|
-
},
|
|
4602
|
-
pick(mask) {
|
|
4603
|
-
return pick(this, mask);
|
|
4604
|
-
},
|
|
4605
|
-
omit(mask) {
|
|
4606
|
-
return omit(this, mask);
|
|
4607
|
-
},
|
|
4608
|
-
partial(...args) {
|
|
4609
|
-
return partial(ZodOptional, this, args[0]);
|
|
4610
|
-
},
|
|
4611
|
-
required(...args) {
|
|
4612
|
-
return required(ZodNonOptional, this, args[0]);
|
|
4613
933
|
}
|
|
4614
|
-
}
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
|
|
4628
|
-
inst.options = def.options;
|
|
4629
|
-
});
|
|
4630
|
-
function union(options, params) {
|
|
4631
|
-
return new ZodUnion({
|
|
4632
|
-
type: "union",
|
|
4633
|
-
options,
|
|
4634
|
-
...normalizeParams(params)
|
|
4635
|
-
});
|
|
4636
|
-
}
|
|
4637
|
-
const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
|
|
4638
|
-
$ZodIntersection.init(inst, def);
|
|
4639
|
-
ZodType.init(inst, def);
|
|
4640
|
-
inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
|
|
4641
|
-
});
|
|
4642
|
-
function intersection(left, right) {
|
|
4643
|
-
return new ZodIntersection({
|
|
4644
|
-
type: "intersection",
|
|
4645
|
-
left,
|
|
4646
|
-
right
|
|
4647
|
-
});
|
|
4648
|
-
}
|
|
4649
|
-
const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
|
|
4650
|
-
$ZodEnum.init(inst, def);
|
|
4651
|
-
ZodType.init(inst, def);
|
|
4652
|
-
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
|
|
4653
|
-
inst.enum = def.entries;
|
|
4654
|
-
inst.options = Object.values(def.entries);
|
|
4655
|
-
const keys = new Set(Object.keys(def.entries));
|
|
4656
|
-
inst.extract = (values, params) => {
|
|
4657
|
-
const newEntries = {};
|
|
4658
|
-
for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
|
|
4659
|
-
else throw new Error(`Key ${value} not found in enum`);
|
|
4660
|
-
return new ZodEnum({
|
|
4661
|
-
...def,
|
|
4662
|
-
checks: [],
|
|
4663
|
-
...normalizeParams(params),
|
|
4664
|
-
entries: newEntries
|
|
4665
|
-
});
|
|
4666
|
-
};
|
|
4667
|
-
inst.exclude = (values, params) => {
|
|
4668
|
-
const newEntries = { ...def.entries };
|
|
4669
|
-
for (const value of values) if (keys.has(value)) delete newEntries[value];
|
|
4670
|
-
else throw new Error(`Key ${value} not found in enum`);
|
|
4671
|
-
return new ZodEnum({
|
|
4672
|
-
...def,
|
|
4673
|
-
checks: [],
|
|
4674
|
-
...normalizeParams(params),
|
|
4675
|
-
entries: newEntries
|
|
4676
|
-
});
|
|
4677
|
-
};
|
|
4678
|
-
});
|
|
4679
|
-
function _enum(values, params) {
|
|
4680
|
-
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
4681
|
-
return new ZodEnum({
|
|
4682
|
-
type: "enum",
|
|
4683
|
-
entries,
|
|
4684
|
-
...normalizeParams(params)
|
|
4685
|
-
});
|
|
4686
|
-
}
|
|
4687
|
-
const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
|
|
4688
|
-
$ZodTransform.init(inst, def);
|
|
4689
|
-
ZodType.init(inst, def);
|
|
4690
|
-
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
|
|
4691
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
4692
|
-
if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
|
|
4693
|
-
payload.addIssue = (issue$1) => {
|
|
4694
|
-
if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
|
|
4695
|
-
else {
|
|
4696
|
-
const _issue = issue$1;
|
|
4697
|
-
if (_issue.fatal) _issue.continue = false;
|
|
4698
|
-
_issue.code ?? (_issue.code = "custom");
|
|
4699
|
-
_issue.input ?? (_issue.input = payload.value);
|
|
4700
|
-
_issue.inst ?? (_issue.inst = inst);
|
|
4701
|
-
payload.issues.push(issue(_issue));
|
|
4702
|
-
}
|
|
4703
|
-
};
|
|
4704
|
-
const output = def.transform(payload.value, payload);
|
|
4705
|
-
if (output instanceof Promise) return output.then((output) => {
|
|
4706
|
-
payload.value = output;
|
|
4707
|
-
payload.fallback = true;
|
|
4708
|
-
return payload;
|
|
934
|
+
}
|
|
935
|
+
/** 把配置快照映射进页面状态;用户没在编辑时,草稿跟着配置走。 */
|
|
936
|
+
derive() {
|
|
937
|
+
const snapshot = this.form.getSnapshot();
|
|
938
|
+
const config = decodeConfig(snapshot.value);
|
|
939
|
+
const current = this.store.getSnapshot();
|
|
940
|
+
const dirty = current.draft !== current.config.memoryText && current.saveState !== "saved";
|
|
941
|
+
this.store.set({
|
|
942
|
+
status: snapshot.status === "ready" ? "ready" : snapshot.status === "loading" ? "loading" : "unavailable",
|
|
943
|
+
config,
|
|
944
|
+
draft: dirty ? current.draft : config.memoryText,
|
|
945
|
+
saveState: snapshot.status === "ready" ? current.saveState : "idle",
|
|
946
|
+
error: current.error
|
|
4709
947
|
});
|
|
4710
|
-
|
|
4711
|
-
payload.fallback = true;
|
|
4712
|
-
return payload;
|
|
4713
|
-
};
|
|
4714
|
-
});
|
|
4715
|
-
function transform(fn) {
|
|
4716
|
-
return new ZodTransform({
|
|
4717
|
-
type: "transform",
|
|
4718
|
-
transform: fn
|
|
4719
|
-
});
|
|
4720
|
-
}
|
|
4721
|
-
const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
|
|
4722
|
-
$ZodOptional.init(inst, def);
|
|
4723
|
-
ZodType.init(inst, def);
|
|
4724
|
-
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
4725
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
4726
|
-
});
|
|
4727
|
-
function optional(innerType) {
|
|
4728
|
-
return new ZodOptional({
|
|
4729
|
-
type: "optional",
|
|
4730
|
-
innerType
|
|
4731
|
-
});
|
|
4732
|
-
}
|
|
4733
|
-
const ZodExactOptional = /*@__PURE__*/ $constructor("ZodExactOptional", (inst, def) => {
|
|
4734
|
-
$ZodExactOptional.init(inst, def);
|
|
4735
|
-
ZodType.init(inst, def);
|
|
4736
|
-
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
4737
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
4738
|
-
});
|
|
4739
|
-
function exactOptional(innerType) {
|
|
4740
|
-
return new ZodExactOptional({
|
|
4741
|
-
type: "optional",
|
|
4742
|
-
innerType
|
|
4743
|
-
});
|
|
4744
|
-
}
|
|
4745
|
-
const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
|
|
4746
|
-
$ZodNullable.init(inst, def);
|
|
4747
|
-
ZodType.init(inst, def);
|
|
4748
|
-
inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
|
|
4749
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
4750
|
-
});
|
|
4751
|
-
function nullable(innerType) {
|
|
4752
|
-
return new ZodNullable({
|
|
4753
|
-
type: "nullable",
|
|
4754
|
-
innerType
|
|
4755
|
-
});
|
|
4756
|
-
}
|
|
4757
|
-
const ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (inst, def) => {
|
|
4758
|
-
$ZodDefault.init(inst, def);
|
|
4759
|
-
ZodType.init(inst, def);
|
|
4760
|
-
inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
|
|
4761
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
4762
|
-
inst.removeDefault = inst.unwrap;
|
|
4763
|
-
});
|
|
4764
|
-
function _default(innerType, defaultValue) {
|
|
4765
|
-
return new ZodDefault({
|
|
4766
|
-
type: "default",
|
|
4767
|
-
innerType,
|
|
4768
|
-
get defaultValue() {
|
|
4769
|
-
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
4770
|
-
}
|
|
4771
|
-
});
|
|
4772
|
-
}
|
|
4773
|
-
const ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (inst, def) => {
|
|
4774
|
-
$ZodPrefault.init(inst, def);
|
|
4775
|
-
ZodType.init(inst, def);
|
|
4776
|
-
inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
|
|
4777
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
4778
|
-
});
|
|
4779
|
-
function prefault(innerType, defaultValue) {
|
|
4780
|
-
return new ZodPrefault({
|
|
4781
|
-
type: "prefault",
|
|
4782
|
-
innerType,
|
|
4783
|
-
get defaultValue() {
|
|
4784
|
-
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
4785
|
-
}
|
|
4786
|
-
});
|
|
4787
|
-
}
|
|
4788
|
-
const ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (inst, def) => {
|
|
4789
|
-
$ZodNonOptional.init(inst, def);
|
|
4790
|
-
ZodType.init(inst, def);
|
|
4791
|
-
inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
|
|
4792
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
4793
|
-
});
|
|
4794
|
-
function nonoptional(innerType, params) {
|
|
4795
|
-
return new ZodNonOptional({
|
|
4796
|
-
type: "nonoptional",
|
|
4797
|
-
innerType,
|
|
4798
|
-
...normalizeParams(params)
|
|
4799
|
-
});
|
|
4800
|
-
}
|
|
4801
|
-
const ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (inst, def) => {
|
|
4802
|
-
$ZodCatch.init(inst, def);
|
|
4803
|
-
ZodType.init(inst, def);
|
|
4804
|
-
inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
|
|
4805
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
4806
|
-
inst.removeCatch = inst.unwrap;
|
|
4807
|
-
});
|
|
4808
|
-
function _catch(innerType, catchValue) {
|
|
4809
|
-
return new ZodCatch({
|
|
4810
|
-
type: "catch",
|
|
4811
|
-
innerType,
|
|
4812
|
-
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
4813
|
-
});
|
|
4814
|
-
}
|
|
4815
|
-
const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
|
|
4816
|
-
$ZodPipe.init(inst, def);
|
|
4817
|
-
ZodType.init(inst, def);
|
|
4818
|
-
inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
|
|
4819
|
-
inst.in = def.in;
|
|
4820
|
-
inst.out = def.out;
|
|
4821
|
-
});
|
|
4822
|
-
function pipe(in_, out) {
|
|
4823
|
-
return new ZodPipe({
|
|
4824
|
-
type: "pipe",
|
|
4825
|
-
in: in_,
|
|
4826
|
-
out
|
|
4827
|
-
});
|
|
4828
|
-
}
|
|
4829
|
-
const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
|
|
4830
|
-
$ZodReadonly.init(inst, def);
|
|
4831
|
-
ZodType.init(inst, def);
|
|
4832
|
-
inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
|
|
4833
|
-
inst.unwrap = () => inst._zod.def.innerType;
|
|
4834
|
-
});
|
|
4835
|
-
function readonly(innerType) {
|
|
4836
|
-
return new ZodReadonly({
|
|
4837
|
-
type: "readonly",
|
|
4838
|
-
innerType
|
|
4839
|
-
});
|
|
4840
|
-
}
|
|
4841
|
-
const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
|
|
4842
|
-
$ZodCustom.init(inst, def);
|
|
4843
|
-
ZodType.init(inst, def);
|
|
4844
|
-
inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
|
|
4845
|
-
});
|
|
4846
|
-
function refine(fn, _params = {}) {
|
|
4847
|
-
return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
|
|
4848
|
-
}
|
|
4849
|
-
function superRefine(fn, params) {
|
|
4850
|
-
return /* @__PURE__ */ _superRefine(fn, params);
|
|
4851
|
-
}
|
|
4852
|
-
//#endregion
|
|
4853
|
-
//#region ../src/client/typertRemote.js
|
|
4854
|
-
let _deepseek_ai_dsh_agent_memory_assistantProfile_purgeAgent_parameter_0$schema$value;
|
|
4855
|
-
const _deepseek_ai_dsh_agent_memory_assistantProfile_purgeAgent_parameter_0$schema = () => _deepseek_ai_dsh_agent_memory_assistantProfile_purgeAgent_parameter_0$schema$value ??= string();
|
|
4856
|
-
let _deepseek_ai_dsh_agent_memory_assistantProfile_purgeAgent_result$schema$value;
|
|
4857
|
-
const _deepseek_ai_dsh_agent_memory_assistantProfile_purgeAgent_result$schema = () => _deepseek_ai_dsh_agent_memory_assistantProfile_purgeAgent_result$schema$value ??= _void();
|
|
4858
|
-
let _deepseek_ai_dsh_agent_memory_assistantProfile_readAgent_parameter_0$schema$value;
|
|
4859
|
-
const _deepseek_ai_dsh_agent_memory_assistantProfile_readAgent_parameter_0$schema = () => _deepseek_ai_dsh_agent_memory_assistantProfile_readAgent_parameter_0$schema$value ??= string();
|
|
4860
|
-
let _deepseek_ai_dsh_agent_memory_assistantProfile_readAgent_result$schema$value;
|
|
4861
|
-
const _deepseek_ai_dsh_agent_memory_assistantProfile_readAgent_result$schema = () => _deepseek_ai_dsh_agent_memory_assistantProfile_readAgent_result$schema$value ??= string();
|
|
4862
|
-
let _deepseek_ai_dsh_agent_memory_assistantProfile_readGlobal_result$schema$value;
|
|
4863
|
-
const _deepseek_ai_dsh_agent_memory_assistantProfile_readGlobal_result$schema = () => _deepseek_ai_dsh_agent_memory_assistantProfile_readGlobal_result$schema$value ??= string();
|
|
4864
|
-
let _deepseek_ai_dsh_agent_memory_assistantProfile_remember_parameter_0$schema$value;
|
|
4865
|
-
const _deepseek_ai_dsh_agent_memory_assistantProfile_remember_parameter_0$schema = () => _deepseek_ai_dsh_agent_memory_assistantProfile_remember_parameter_0$schema$value ??= string();
|
|
4866
|
-
let _deepseek_ai_dsh_agent_memory_assistantProfile_remember_parameter_1$schema$value;
|
|
4867
|
-
const _deepseek_ai_dsh_agent_memory_assistantProfile_remember_parameter_1$schema = () => _deepseek_ai_dsh_agent_memory_assistantProfile_remember_parameter_1$schema$value ??= string();
|
|
4868
|
-
let _deepseek_ai_dsh_agent_memory_assistantProfile_remember_result$schema$value;
|
|
4869
|
-
const _deepseek_ai_dsh_agent_memory_assistantProfile_remember_result$schema = () => _deepseek_ai_dsh_agent_memory_assistantProfile_remember_result$schema$value ??= object({
|
|
4870
|
-
"saved": boolean().readonly(),
|
|
4871
|
-
"agentId": string().readonly().optional(),
|
|
4872
|
-
"outcome": string().readonly().optional(),
|
|
4873
|
-
"entries": array(string()).readonly().optional()
|
|
4874
|
-
});
|
|
4875
|
-
let _deepseek_ai_dsh_agent_memory_assistantProfile_writeAgent_parameter_0$schema$value;
|
|
4876
|
-
const _deepseek_ai_dsh_agent_memory_assistantProfile_writeAgent_parameter_0$schema = () => _deepseek_ai_dsh_agent_memory_assistantProfile_writeAgent_parameter_0$schema$value ??= string();
|
|
4877
|
-
let _deepseek_ai_dsh_agent_memory_assistantProfile_writeAgent_parameter_1$schema$value;
|
|
4878
|
-
const _deepseek_ai_dsh_agent_memory_assistantProfile_writeAgent_parameter_1$schema = () => _deepseek_ai_dsh_agent_memory_assistantProfile_writeAgent_parameter_1$schema$value ??= string();
|
|
4879
|
-
let _deepseek_ai_dsh_agent_memory_assistantProfile_writeAgent_result$schema$value;
|
|
4880
|
-
const _deepseek_ai_dsh_agent_memory_assistantProfile_writeAgent_result$schema = () => _deepseek_ai_dsh_agent_memory_assistantProfile_writeAgent_result$schema$value ??= _void();
|
|
4881
|
-
let _deepseek_ai_dsh_agent_memory_assistantProfile_writeGlobal_parameter_0$schema$value;
|
|
4882
|
-
const _deepseek_ai_dsh_agent_memory_assistantProfile_writeGlobal_parameter_0$schema = () => _deepseek_ai_dsh_agent_memory_assistantProfile_writeGlobal_parameter_0$schema$value ??= string();
|
|
4883
|
-
let _deepseek_ai_dsh_agent_memory_assistantProfile_writeGlobal_result$schema$value;
|
|
4884
|
-
const _deepseek_ai_dsh_agent_memory_assistantProfile_writeGlobal_result$schema = () => _deepseek_ai_dsh_agent_memory_assistantProfile_writeGlobal_result$schema$value ??= _void();
|
|
4885
|
-
const TYPERT_REMOTE = {
|
|
4886
|
-
package: "@istarry/dsh-assistant-profile",
|
|
4887
|
-
descriptors: [
|
|
4888
|
-
{
|
|
4889
|
-
id: "@istarry/dsh-assistant-profile#assistantProfile/purgeAgent",
|
|
4890
|
-
service: "assistantProfile",
|
|
4891
|
-
namespace: "assistantProfile",
|
|
4892
|
-
method: "purgeAgent",
|
|
4893
|
-
invocation: { kind: "direct" },
|
|
4894
|
-
parameters: [{
|
|
4895
|
-
name: "agentId",
|
|
4896
|
-
wire: "agentId",
|
|
4897
|
-
source: "json",
|
|
4898
|
-
codec: {
|
|
4899
|
-
mode: "strict",
|
|
4900
|
-
typeSymbol: "@istarry/dsh-assistant-profile#assistantProfile/purgeAgent:agentId",
|
|
4901
|
-
create: _deepseek_ai_dsh_agent_memory_assistantProfile_purgeAgent_parameter_0$schema
|
|
4902
|
-
}
|
|
4903
|
-
}],
|
|
4904
|
-
result: {
|
|
4905
|
-
mode: "strict",
|
|
4906
|
-
typeSymbol: "@istarry/dsh-assistant-profile#assistantProfile/purgeAgent:result",
|
|
4907
|
-
create: _deepseek_ai_dsh_agent_memory_assistantProfile_purgeAgent_result$schema
|
|
4908
|
-
},
|
|
4909
|
-
sourceLocation: {
|
|
4910
|
-
"file": "packages/preset/agent-memory/src/index.ts",
|
|
4911
|
-
"line": 325,
|
|
4912
|
-
"column": 3
|
|
4913
|
-
}
|
|
4914
|
-
},
|
|
4915
|
-
{
|
|
4916
|
-
id: "@istarry/dsh-assistant-profile#assistantProfile/readAgent",
|
|
4917
|
-
service: "assistantProfile",
|
|
4918
|
-
namespace: "assistantProfile",
|
|
4919
|
-
method: "readAgent",
|
|
4920
|
-
invocation: { kind: "direct" },
|
|
4921
|
-
parameters: [{
|
|
4922
|
-
name: "agentId",
|
|
4923
|
-
wire: "agentId",
|
|
4924
|
-
source: "json",
|
|
4925
|
-
codec: {
|
|
4926
|
-
mode: "strict",
|
|
4927
|
-
typeSymbol: "@istarry/dsh-assistant-profile#assistantProfile/readAgent:agentId",
|
|
4928
|
-
create: _deepseek_ai_dsh_agent_memory_assistantProfile_readAgent_parameter_0$schema
|
|
4929
|
-
}
|
|
4930
|
-
}],
|
|
4931
|
-
result: {
|
|
4932
|
-
mode: "strict",
|
|
4933
|
-
typeSymbol: "@istarry/dsh-assistant-profile#assistantProfile/readAgent:result",
|
|
4934
|
-
create: _deepseek_ai_dsh_agent_memory_assistantProfile_readAgent_result$schema
|
|
4935
|
-
},
|
|
4936
|
-
sourceLocation: {
|
|
4937
|
-
"file": "packages/preset/agent-memory/src/index.ts",
|
|
4938
|
-
"line": 313,
|
|
4939
|
-
"column": 3
|
|
4940
|
-
}
|
|
4941
|
-
},
|
|
4942
|
-
{
|
|
4943
|
-
id: "@istarry/dsh-assistant-profile#assistantProfile/readGlobal",
|
|
4944
|
-
service: "assistantProfile",
|
|
4945
|
-
namespace: "assistantProfile",
|
|
4946
|
-
method: "readGlobal",
|
|
4947
|
-
invocation: { kind: "direct" },
|
|
4948
|
-
parameters: [],
|
|
4949
|
-
result: {
|
|
4950
|
-
mode: "strict",
|
|
4951
|
-
typeSymbol: "@istarry/dsh-assistant-profile#assistantProfile/readGlobal:result",
|
|
4952
|
-
create: _deepseek_ai_dsh_agent_memory_assistantProfile_readGlobal_result$schema
|
|
4953
|
-
},
|
|
4954
|
-
sourceLocation: {
|
|
4955
|
-
"file": "packages/preset/agent-memory/src/index.ts",
|
|
4956
|
-
"line": 301,
|
|
4957
|
-
"column": 3
|
|
4958
|
-
}
|
|
4959
|
-
},
|
|
4960
|
-
{
|
|
4961
|
-
id: "@istarry/dsh-assistant-profile#assistantProfile/remember",
|
|
4962
|
-
service: "assistantProfile",
|
|
4963
|
-
namespace: "assistantProfile",
|
|
4964
|
-
method: "remember",
|
|
4965
|
-
invocation: { kind: "direct" },
|
|
4966
|
-
parameters: [{
|
|
4967
|
-
name: "sessionId",
|
|
4968
|
-
wire: "sessionId",
|
|
4969
|
-
source: "json",
|
|
4970
|
-
codec: {
|
|
4971
|
-
mode: "strict",
|
|
4972
|
-
typeSymbol: "@istarry/dsh-assistant-profile#assistantProfile/remember:sessionId",
|
|
4973
|
-
create: _deepseek_ai_dsh_agent_memory_assistantProfile_remember_parameter_0$schema
|
|
4974
|
-
}
|
|
4975
|
-
}, {
|
|
4976
|
-
name: "text",
|
|
4977
|
-
wire: "text",
|
|
4978
|
-
source: "json",
|
|
4979
|
-
codec: {
|
|
4980
|
-
mode: "strict",
|
|
4981
|
-
typeSymbol: "@istarry/dsh-assistant-profile#assistantProfile/remember:text",
|
|
4982
|
-
create: _deepseek_ai_dsh_agent_memory_assistantProfile_remember_parameter_1$schema
|
|
4983
|
-
}
|
|
4984
|
-
}],
|
|
4985
|
-
result: {
|
|
4986
|
-
mode: "strict",
|
|
4987
|
-
typeSymbol: "@istarry/dsh-assistant-profile/types#RememberValue",
|
|
4988
|
-
create: _deepseek_ai_dsh_agent_memory_assistantProfile_remember_result$schema
|
|
4989
|
-
},
|
|
4990
|
-
sourceLocation: {
|
|
4991
|
-
"file": "packages/preset/agent-memory/src/index.ts",
|
|
4992
|
-
"line": 347,
|
|
4993
|
-
"column": 9
|
|
4994
|
-
}
|
|
4995
|
-
},
|
|
4996
|
-
{
|
|
4997
|
-
id: "@istarry/dsh-assistant-profile#assistantProfile/writeAgent",
|
|
4998
|
-
service: "assistantProfile",
|
|
4999
|
-
namespace: "assistantProfile",
|
|
5000
|
-
method: "writeAgent",
|
|
5001
|
-
invocation: { kind: "direct" },
|
|
5002
|
-
parameters: [{
|
|
5003
|
-
name: "agentId",
|
|
5004
|
-
wire: "agentId",
|
|
5005
|
-
source: "json",
|
|
5006
|
-
codec: {
|
|
5007
|
-
mode: "strict",
|
|
5008
|
-
typeSymbol: "@istarry/dsh-assistant-profile#assistantProfile/writeAgent:agentId",
|
|
5009
|
-
create: _deepseek_ai_dsh_agent_memory_assistantProfile_writeAgent_parameter_0$schema
|
|
5010
|
-
}
|
|
5011
|
-
}, {
|
|
5012
|
-
name: "text",
|
|
5013
|
-
wire: "text",
|
|
5014
|
-
source: "json",
|
|
5015
|
-
codec: {
|
|
5016
|
-
mode: "strict",
|
|
5017
|
-
typeSymbol: "@istarry/dsh-assistant-profile#assistantProfile/writeAgent:text",
|
|
5018
|
-
create: _deepseek_ai_dsh_agent_memory_assistantProfile_writeAgent_parameter_1$schema
|
|
5019
|
-
}
|
|
5020
|
-
}],
|
|
5021
|
-
result: {
|
|
5022
|
-
mode: "strict",
|
|
5023
|
-
typeSymbol: "@istarry/dsh-assistant-profile#assistantProfile/writeAgent:result",
|
|
5024
|
-
create: _deepseek_ai_dsh_agent_memory_assistantProfile_writeAgent_result$schema
|
|
5025
|
-
},
|
|
5026
|
-
sourceLocation: {
|
|
5027
|
-
"file": "packages/preset/agent-memory/src/index.ts",
|
|
5028
|
-
"line": 319,
|
|
5029
|
-
"column": 3
|
|
5030
|
-
}
|
|
5031
|
-
},
|
|
5032
|
-
{
|
|
5033
|
-
id: "@istarry/dsh-assistant-profile#assistantProfile/writeGlobal",
|
|
5034
|
-
service: "assistantProfile",
|
|
5035
|
-
namespace: "assistantProfile",
|
|
5036
|
-
method: "writeGlobal",
|
|
5037
|
-
invocation: { kind: "direct" },
|
|
5038
|
-
parameters: [{
|
|
5039
|
-
name: "text",
|
|
5040
|
-
wire: "text",
|
|
5041
|
-
source: "json",
|
|
5042
|
-
codec: {
|
|
5043
|
-
mode: "strict",
|
|
5044
|
-
typeSymbol: "@istarry/dsh-assistant-profile#assistantProfile/writeGlobal:text",
|
|
5045
|
-
create: _deepseek_ai_dsh_agent_memory_assistantProfile_writeGlobal_parameter_0$schema
|
|
5046
|
-
}
|
|
5047
|
-
}],
|
|
5048
|
-
result: {
|
|
5049
|
-
mode: "strict",
|
|
5050
|
-
typeSymbol: "@istarry/dsh-assistant-profile#assistantProfile/writeGlobal:result",
|
|
5051
|
-
create: _deepseek_ai_dsh_agent_memory_assistantProfile_writeGlobal_result$schema
|
|
5052
|
-
},
|
|
5053
|
-
sourceLocation: {
|
|
5054
|
-
"file": "packages/preset/agent-memory/src/index.ts",
|
|
5055
|
-
"line": 307,
|
|
5056
|
-
"column": 3
|
|
5057
|
-
}
|
|
5058
|
-
}
|
|
5059
|
-
]
|
|
948
|
+
}
|
|
5060
949
|
};
|
|
5061
950
|
//#endregion
|
|
5062
951
|
//#region ../src/client/locales.ts
|
|
@@ -5202,22 +1091,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5202
1091
|
en
|
|
5203
1092
|
}), "assistant-profile: dictionaries");
|
|
5204
1093
|
const t = ctx.locale.bind(NS);
|
|
5205
|
-
const implementation = /* @__PURE__ */ new Set([
|
|
5206
|
-
"readGlobal",
|
|
5207
|
-
"writeGlobal",
|
|
5208
|
-
"remember"
|
|
5209
|
-
]);
|
|
5210
|
-
const mounted = {
|
|
5211
|
-
...TYPERT_REMOTE,
|
|
5212
|
-
descriptors: TYPERT_REMOTE.descriptors.filter((descriptor) => implementation.has(String(descriptor.method)))
|
|
5213
|
-
};
|
|
5214
|
-
try {
|
|
5215
|
-
Promise.resolve(ctx.remote.$mount(mounted)).catch((error) => {
|
|
5216
|
-
console.warn("assistant-profile: remote mount failed", error);
|
|
5217
|
-
});
|
|
5218
|
-
} catch (error) {
|
|
5219
|
-
console.warn("assistant-profile: remote mount failed", error);
|
|
5220
|
-
}
|
|
5221
1094
|
const profile = createProfileStore(ctx);
|
|
5222
1095
|
ctx.effect(() => mountNameplate(profile), "assistant-profile: nameplate");
|
|
5223
1096
|
ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
|
|
@@ -5233,7 +1106,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5233
1106
|
locale: NS,
|
|
5234
1107
|
inject: () => ({ profile })
|
|
5235
1108
|
}, ProfilePage));
|
|
5236
|
-
const controller = new MemorySettingsController(ctx.configForms.get(PANEL_ID)
|
|
1109
|
+
const controller = new MemorySettingsController(ctx.configForms.get(PANEL_ID));
|
|
5237
1110
|
ctx.effect(() => () => {
|
|
5238
1111
|
controller.dispose();
|
|
5239
1112
|
}, "assistant-profile: memory form");
|
|
@@ -5250,14 +1123,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
5250
1123
|
controller.setDraft(text);
|
|
5251
1124
|
},
|
|
5252
1125
|
save: () => controller.save(),
|
|
5253
|
-
load: () => controller.load()
|
|
5254
|
-
openPicker: () => {
|
|
5255
|
-
controller.openPicker();
|
|
5256
|
-
},
|
|
5257
|
-
closePicker: () => {
|
|
5258
|
-
controller.closePicker();
|
|
5259
|
-
},
|
|
5260
|
-
remember: (sessionId, text) => controller.remember(sessionId, text)
|
|
1126
|
+
load: () => controller.load()
|
|
5261
1127
|
})
|
|
5262
1128
|
}, MemorySection));
|
|
5263
1129
|
}
|