@modootoday/datalab-extension-mcp 1.5.1 → 1.7.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/README.en.md +4 -4
- package/README.md +4 -4
- package/dist/{chunk-XSYBSML4.js → chunk-NYUIYZG6.js} +1125 -619
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,10 @@ import {
|
|
|
2
2
|
__export
|
|
3
3
|
} from "./chunk-MLKGABMK.js";
|
|
4
4
|
|
|
5
|
-
// ../mcp-server/dist/chunk-
|
|
5
|
+
// ../mcp-server/dist/chunk-U4D7XAUO.js
|
|
6
|
+
import { createHash, randomUUID } from "crypto";
|
|
7
|
+
import { mkdir, readFile, readdir, rm, writeFile } from "fs/promises";
|
|
8
|
+
import { join } from "path";
|
|
6
9
|
import {
|
|
7
10
|
createServer
|
|
8
11
|
} from "http";
|
|
@@ -17,11 +20,12 @@ import {
|
|
|
17
20
|
statSync
|
|
18
21
|
} from "fs";
|
|
19
22
|
import { homedir } from "os";
|
|
20
|
-
import { join } from "path";
|
|
23
|
+
import { join as join2 } from "path";
|
|
21
24
|
import { createConnection } from "net";
|
|
22
25
|
import { spawn } from "child_process";
|
|
23
26
|
import { closeSync } from "fs";
|
|
24
27
|
import { createRequire } from "module";
|
|
28
|
+
import { join as join3 } from "path";
|
|
25
29
|
var __defProp = Object.defineProperty;
|
|
26
30
|
var __export2 = (target, all) => {
|
|
27
31
|
for (var name in all)
|
|
@@ -783,8 +787,8 @@ function mergeDefs(...defs) {
|
|
|
783
787
|
}
|
|
784
788
|
return Object.defineProperties({}, mergedDescriptors);
|
|
785
789
|
}
|
|
786
|
-
function cloneDef(
|
|
787
|
-
return mergeDefs(
|
|
790
|
+
function cloneDef(schema2) {
|
|
791
|
+
return mergeDefs(schema2._zod.def);
|
|
788
792
|
}
|
|
789
793
|
function getElementAtPath(obj, path) {
|
|
790
794
|
if (!path)
|
|
@@ -1006,14 +1010,14 @@ var BIGINT_FORMAT_RANGES = {
|
|
|
1006
1010
|
int64: [/* @__PURE__ */ BigInt("-9223372036854775808"), /* @__PURE__ */ BigInt("9223372036854775807")],
|
|
1007
1011
|
uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")]
|
|
1008
1012
|
};
|
|
1009
|
-
function pick(
|
|
1010
|
-
const currDef =
|
|
1013
|
+
function pick(schema2, mask) {
|
|
1014
|
+
const currDef = schema2._zod.def;
|
|
1011
1015
|
const checks = currDef.checks;
|
|
1012
1016
|
const hasChecks = checks && checks.length > 0;
|
|
1013
1017
|
if (hasChecks) {
|
|
1014
1018
|
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
1015
1019
|
}
|
|
1016
|
-
const def = mergeDefs(
|
|
1020
|
+
const def = mergeDefs(schema2._zod.def, {
|
|
1017
1021
|
get shape() {
|
|
1018
1022
|
const newShape = {};
|
|
1019
1023
|
for (const key in mask) {
|
|
@@ -1029,18 +1033,18 @@ function pick(schema, mask) {
|
|
|
1029
1033
|
},
|
|
1030
1034
|
checks: []
|
|
1031
1035
|
});
|
|
1032
|
-
return clone(
|
|
1036
|
+
return clone(schema2, def);
|
|
1033
1037
|
}
|
|
1034
|
-
function omit(
|
|
1035
|
-
const currDef =
|
|
1038
|
+
function omit(schema2, mask) {
|
|
1039
|
+
const currDef = schema2._zod.def;
|
|
1036
1040
|
const checks = currDef.checks;
|
|
1037
1041
|
const hasChecks = checks && checks.length > 0;
|
|
1038
1042
|
if (hasChecks) {
|
|
1039
1043
|
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
1040
1044
|
}
|
|
1041
|
-
const def = mergeDefs(
|
|
1045
|
+
const def = mergeDefs(schema2._zod.def, {
|
|
1042
1046
|
get shape() {
|
|
1043
|
-
const newShape = { ...
|
|
1047
|
+
const newShape = { ...schema2._zod.def.shape };
|
|
1044
1048
|
for (const key in mask) {
|
|
1045
1049
|
if (!(key in currDef.shape)) {
|
|
1046
1050
|
throw new Error(`Unrecognized key: "${key}"`);
|
|
@@ -1054,43 +1058,43 @@ function omit(schema, mask) {
|
|
|
1054
1058
|
},
|
|
1055
1059
|
checks: []
|
|
1056
1060
|
});
|
|
1057
|
-
return clone(
|
|
1061
|
+
return clone(schema2, def);
|
|
1058
1062
|
}
|
|
1059
|
-
function extend(
|
|
1063
|
+
function extend(schema2, shape) {
|
|
1060
1064
|
if (!isPlainObject(shape)) {
|
|
1061
1065
|
throw new Error("Invalid input to extend: expected a plain object");
|
|
1062
1066
|
}
|
|
1063
|
-
const checks =
|
|
1067
|
+
const checks = schema2._zod.def.checks;
|
|
1064
1068
|
const hasChecks = checks && checks.length > 0;
|
|
1065
1069
|
if (hasChecks) {
|
|
1066
|
-
const existingShape =
|
|
1070
|
+
const existingShape = schema2._zod.def.shape;
|
|
1067
1071
|
for (const key in shape) {
|
|
1068
1072
|
if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) {
|
|
1069
1073
|
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
1070
1074
|
}
|
|
1071
1075
|
}
|
|
1072
1076
|
}
|
|
1073
|
-
const def = mergeDefs(
|
|
1077
|
+
const def = mergeDefs(schema2._zod.def, {
|
|
1074
1078
|
get shape() {
|
|
1075
|
-
const _shape = { ...
|
|
1079
|
+
const _shape = { ...schema2._zod.def.shape, ...shape };
|
|
1076
1080
|
assignProp(this, "shape", _shape);
|
|
1077
1081
|
return _shape;
|
|
1078
1082
|
}
|
|
1079
1083
|
});
|
|
1080
|
-
return clone(
|
|
1084
|
+
return clone(schema2, def);
|
|
1081
1085
|
}
|
|
1082
|
-
function safeExtend(
|
|
1086
|
+
function safeExtend(schema2, shape) {
|
|
1083
1087
|
if (!isPlainObject(shape)) {
|
|
1084
1088
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
1085
1089
|
}
|
|
1086
|
-
const def = mergeDefs(
|
|
1090
|
+
const def = mergeDefs(schema2._zod.def, {
|
|
1087
1091
|
get shape() {
|
|
1088
|
-
const _shape = { ...
|
|
1092
|
+
const _shape = { ...schema2._zod.def.shape, ...shape };
|
|
1089
1093
|
assignProp(this, "shape", _shape);
|
|
1090
1094
|
return _shape;
|
|
1091
1095
|
}
|
|
1092
1096
|
});
|
|
1093
|
-
return clone(
|
|
1097
|
+
return clone(schema2, def);
|
|
1094
1098
|
}
|
|
1095
1099
|
function merge(a, b) {
|
|
1096
1100
|
if (a._zod.def.checks?.length) {
|
|
@@ -1109,16 +1113,16 @@ function merge(a, b) {
|
|
|
1109
1113
|
});
|
|
1110
1114
|
return clone(a, def);
|
|
1111
1115
|
}
|
|
1112
|
-
function partial(Class22,
|
|
1113
|
-
const currDef =
|
|
1116
|
+
function partial(Class22, schema2, mask) {
|
|
1117
|
+
const currDef = schema2._zod.def;
|
|
1114
1118
|
const checks = currDef.checks;
|
|
1115
1119
|
const hasChecks = checks && checks.length > 0;
|
|
1116
1120
|
if (hasChecks) {
|
|
1117
1121
|
throw new Error(".partial() cannot be used on object schemas containing refinements");
|
|
1118
1122
|
}
|
|
1119
|
-
const def = mergeDefs(
|
|
1123
|
+
const def = mergeDefs(schema2._zod.def, {
|
|
1120
1124
|
get shape() {
|
|
1121
|
-
const oldShape =
|
|
1125
|
+
const oldShape = schema2._zod.def.shape;
|
|
1122
1126
|
const shape = { ...oldShape };
|
|
1123
1127
|
if (mask) {
|
|
1124
1128
|
for (const key in mask) {
|
|
@@ -1145,12 +1149,12 @@ function partial(Class22, schema, mask) {
|
|
|
1145
1149
|
},
|
|
1146
1150
|
checks: []
|
|
1147
1151
|
});
|
|
1148
|
-
return clone(
|
|
1152
|
+
return clone(schema2, def);
|
|
1149
1153
|
}
|
|
1150
|
-
function required(Class22,
|
|
1151
|
-
const def = mergeDefs(
|
|
1154
|
+
function required(Class22, schema2, mask) {
|
|
1155
|
+
const def = mergeDefs(schema2._zod.def, {
|
|
1152
1156
|
get shape() {
|
|
1153
|
-
const oldShape =
|
|
1157
|
+
const oldShape = schema2._zod.def.shape;
|
|
1154
1158
|
const shape = { ...oldShape };
|
|
1155
1159
|
if (mask) {
|
|
1156
1160
|
for (const key in mask) {
|
|
@@ -1176,7 +1180,7 @@ function required(Class22, schema, mask) {
|
|
|
1176
1180
|
return shape;
|
|
1177
1181
|
}
|
|
1178
1182
|
});
|
|
1179
|
-
return clone(
|
|
1183
|
+
return clone(schema2, def);
|
|
1180
1184
|
}
|
|
1181
1185
|
function aborted(x, startIndex = 0) {
|
|
1182
1186
|
if (x.aborted === true)
|
|
@@ -1451,9 +1455,9 @@ function prettifyError(error512) {
|
|
|
1451
1455
|
}
|
|
1452
1456
|
return lines.join("\n");
|
|
1453
1457
|
}
|
|
1454
|
-
var _parse = (_Err) => (
|
|
1458
|
+
var _parse = (_Err) => (schema2, value, _ctx, _params) => {
|
|
1455
1459
|
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
1456
|
-
const result =
|
|
1460
|
+
const result = schema2._zod.run({ value, issues: [] }, ctx);
|
|
1457
1461
|
if (result instanceof Promise) {
|
|
1458
1462
|
throw new $ZodAsyncError();
|
|
1459
1463
|
}
|
|
@@ -1465,9 +1469,9 @@ var _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
|
1465
1469
|
return result.value;
|
|
1466
1470
|
};
|
|
1467
1471
|
var parse = /* @__PURE__ */ _parse($ZodRealError);
|
|
1468
|
-
var _parseAsync = (_Err) => async (
|
|
1472
|
+
var _parseAsync = (_Err) => async (schema2, value, _ctx, params) => {
|
|
1469
1473
|
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
1470
|
-
let result =
|
|
1474
|
+
let result = schema2._zod.run({ value, issues: [] }, ctx);
|
|
1471
1475
|
if (result instanceof Promise)
|
|
1472
1476
|
result = await result;
|
|
1473
1477
|
if (result.issues.length) {
|
|
@@ -1478,9 +1482,9 @@ var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
|
1478
1482
|
return result.value;
|
|
1479
1483
|
};
|
|
1480
1484
|
var parseAsync = /* @__PURE__ */ _parseAsync($ZodRealError);
|
|
1481
|
-
var _safeParse = (_Err) => (
|
|
1485
|
+
var _safeParse = (_Err) => (schema2, value, _ctx) => {
|
|
1482
1486
|
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
1483
|
-
const result =
|
|
1487
|
+
const result = schema2._zod.run({ value, issues: [] }, ctx);
|
|
1484
1488
|
if (result instanceof Promise) {
|
|
1485
1489
|
throw new $ZodAsyncError();
|
|
1486
1490
|
}
|
|
@@ -1490,9 +1494,9 @@ var _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
|
1490
1494
|
} : { success: true, data: result.value };
|
|
1491
1495
|
};
|
|
1492
1496
|
var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
1493
|
-
var _safeParseAsync = (_Err) => async (
|
|
1497
|
+
var _safeParseAsync = (_Err) => async (schema2, value, _ctx) => {
|
|
1494
1498
|
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
1495
|
-
let result =
|
|
1499
|
+
let result = schema2._zod.run({ value, issues: [] }, ctx);
|
|
1496
1500
|
if (result instanceof Promise)
|
|
1497
1501
|
result = await result;
|
|
1498
1502
|
return result.issues.length ? {
|
|
@@ -1501,40 +1505,40 @@ var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
1501
1505
|
} : { success: true, data: result.value };
|
|
1502
1506
|
};
|
|
1503
1507
|
var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
1504
|
-
var _encode = (_Err) => (
|
|
1508
|
+
var _encode = (_Err) => (schema2, value, _ctx) => {
|
|
1505
1509
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
1506
|
-
return _parse(_Err)(
|
|
1510
|
+
return _parse(_Err)(schema2, value, ctx);
|
|
1507
1511
|
};
|
|
1508
1512
|
var encode = /* @__PURE__ */ _encode($ZodRealError);
|
|
1509
|
-
var _decode = (_Err) => (
|
|
1510
|
-
return _parse(_Err)(
|
|
1513
|
+
var _decode = (_Err) => (schema2, value, _ctx) => {
|
|
1514
|
+
return _parse(_Err)(schema2, value, _ctx);
|
|
1511
1515
|
};
|
|
1512
1516
|
var decode = /* @__PURE__ */ _decode($ZodRealError);
|
|
1513
|
-
var _encodeAsync = (_Err) => async (
|
|
1517
|
+
var _encodeAsync = (_Err) => async (schema2, value, _ctx) => {
|
|
1514
1518
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
1515
|
-
return _parseAsync(_Err)(
|
|
1519
|
+
return _parseAsync(_Err)(schema2, value, ctx);
|
|
1516
1520
|
};
|
|
1517
1521
|
var encodeAsync = /* @__PURE__ */ _encodeAsync($ZodRealError);
|
|
1518
|
-
var _decodeAsync = (_Err) => async (
|
|
1519
|
-
return _parseAsync(_Err)(
|
|
1522
|
+
var _decodeAsync = (_Err) => async (schema2, value, _ctx) => {
|
|
1523
|
+
return _parseAsync(_Err)(schema2, value, _ctx);
|
|
1520
1524
|
};
|
|
1521
1525
|
var decodeAsync = /* @__PURE__ */ _decodeAsync($ZodRealError);
|
|
1522
|
-
var _safeEncode = (_Err) => (
|
|
1526
|
+
var _safeEncode = (_Err) => (schema2, value, _ctx) => {
|
|
1523
1527
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
1524
|
-
return _safeParse(_Err)(
|
|
1528
|
+
return _safeParse(_Err)(schema2, value, ctx);
|
|
1525
1529
|
};
|
|
1526
1530
|
var safeEncode = /* @__PURE__ */ _safeEncode($ZodRealError);
|
|
1527
|
-
var _safeDecode = (_Err) => (
|
|
1528
|
-
return _safeParse(_Err)(
|
|
1531
|
+
var _safeDecode = (_Err) => (schema2, value, _ctx) => {
|
|
1532
|
+
return _safeParse(_Err)(schema2, value, _ctx);
|
|
1529
1533
|
};
|
|
1530
1534
|
var safeDecode = /* @__PURE__ */ _safeDecode($ZodRealError);
|
|
1531
|
-
var _safeEncodeAsync = (_Err) => async (
|
|
1535
|
+
var _safeEncodeAsync = (_Err) => async (schema2, value, _ctx) => {
|
|
1532
1536
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
1533
|
-
return _safeParseAsync(_Err)(
|
|
1537
|
+
return _safeParseAsync(_Err)(schema2, value, ctx);
|
|
1534
1538
|
};
|
|
1535
1539
|
var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync($ZodRealError);
|
|
1536
|
-
var _safeDecodeAsync = (_Err) => async (
|
|
1537
|
-
return _safeParseAsync(_Err)(
|
|
1540
|
+
var _safeDecodeAsync = (_Err) => async (schema2, value, _ctx) => {
|
|
1541
|
+
return _safeParseAsync(_Err)(schema2, value, _ctx);
|
|
1538
1542
|
};
|
|
1539
1543
|
var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
|
|
1540
1544
|
var regexes_exports = {};
|
|
@@ -3100,9 +3104,9 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3100
3104
|
for (const key of normalized.keys) {
|
|
3101
3105
|
const id = ids[key];
|
|
3102
3106
|
const k = esc(key);
|
|
3103
|
-
const
|
|
3104
|
-
const isOptionalIn =
|
|
3105
|
-
const isOptionalOut =
|
|
3107
|
+
const schema2 = shape[key];
|
|
3108
|
+
const isOptionalIn = schema2?._zod?.optin === "optional";
|
|
3109
|
+
const isOptionalOut = schema2?._zod?.optout === "optional";
|
|
3106
3110
|
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
3107
3111
|
if (isOptionalIn && isOptionalOut) {
|
|
3108
3112
|
doc.write(`
|
|
@@ -10227,11 +10231,11 @@ var $ZodRegistry = class {
|
|
|
10227
10231
|
this._map = /* @__PURE__ */ new WeakMap();
|
|
10228
10232
|
this._idmap = /* @__PURE__ */ new Map();
|
|
10229
10233
|
}
|
|
10230
|
-
add(
|
|
10234
|
+
add(schema2, ..._meta) {
|
|
10231
10235
|
const meta32 = _meta[0];
|
|
10232
|
-
this._map.set(
|
|
10236
|
+
this._map.set(schema2, meta32);
|
|
10233
10237
|
if (meta32 && typeof meta32 === "object" && "id" in meta32) {
|
|
10234
|
-
this._idmap.set(meta32.id,
|
|
10238
|
+
this._idmap.set(meta32.id, schema2);
|
|
10235
10239
|
}
|
|
10236
10240
|
return this;
|
|
10237
10241
|
}
|
|
@@ -10240,26 +10244,26 @@ var $ZodRegistry = class {
|
|
|
10240
10244
|
this._idmap = /* @__PURE__ */ new Map();
|
|
10241
10245
|
return this;
|
|
10242
10246
|
}
|
|
10243
|
-
remove(
|
|
10244
|
-
const meta32 = this._map.get(
|
|
10247
|
+
remove(schema2) {
|
|
10248
|
+
const meta32 = this._map.get(schema2);
|
|
10245
10249
|
if (meta32 && typeof meta32 === "object" && "id" in meta32) {
|
|
10246
10250
|
this._idmap.delete(meta32.id);
|
|
10247
10251
|
}
|
|
10248
|
-
this._map.delete(
|
|
10252
|
+
this._map.delete(schema2);
|
|
10249
10253
|
return this;
|
|
10250
10254
|
}
|
|
10251
|
-
get(
|
|
10252
|
-
const p =
|
|
10255
|
+
get(schema2) {
|
|
10256
|
+
const p = schema2._zod.parent;
|
|
10253
10257
|
if (p) {
|
|
10254
10258
|
const pm = { ...this.get(p) ?? {} };
|
|
10255
10259
|
delete pm.id;
|
|
10256
|
-
const f = { ...pm, ...this._map.get(
|
|
10260
|
+
const f = { ...pm, ...this._map.get(schema2) };
|
|
10257
10261
|
return Object.keys(f).length ? f : void 0;
|
|
10258
10262
|
}
|
|
10259
|
-
return this._map.get(
|
|
10263
|
+
return this._map.get(schema2);
|
|
10260
10264
|
}
|
|
10261
|
-
has(
|
|
10262
|
-
return this._map.has(
|
|
10265
|
+
has(schema2) {
|
|
10266
|
+
return this._map.has(schema2);
|
|
10263
10267
|
}
|
|
10264
10268
|
};
|
|
10265
10269
|
function registry() {
|
|
@@ -10910,11 +10914,11 @@ function _endsWith(suffix, params) {
|
|
|
10910
10914
|
});
|
|
10911
10915
|
}
|
|
10912
10916
|
// @__NO_SIDE_EFFECTS__
|
|
10913
|
-
function _property(property,
|
|
10917
|
+
function _property(property, schema2, params) {
|
|
10914
10918
|
return new $ZodCheckProperty({
|
|
10915
10919
|
check: "property",
|
|
10916
10920
|
property,
|
|
10917
|
-
schema,
|
|
10921
|
+
schema: schema2,
|
|
10918
10922
|
...normalizeParams(params)
|
|
10919
10923
|
});
|
|
10920
10924
|
}
|
|
@@ -11162,23 +11166,23 @@ function _promise(Class22, innerType) {
|
|
|
11162
11166
|
function _custom(Class22, fn, _params) {
|
|
11163
11167
|
const norm = normalizeParams(_params);
|
|
11164
11168
|
norm.abort ?? (norm.abort = true);
|
|
11165
|
-
const
|
|
11169
|
+
const schema2 = new Class22({
|
|
11166
11170
|
type: "custom",
|
|
11167
11171
|
check: "custom",
|
|
11168
11172
|
fn,
|
|
11169
11173
|
...norm
|
|
11170
11174
|
});
|
|
11171
|
-
return
|
|
11175
|
+
return schema2;
|
|
11172
11176
|
}
|
|
11173
11177
|
// @__NO_SIDE_EFFECTS__
|
|
11174
11178
|
function _refine(Class22, fn, _params) {
|
|
11175
|
-
const
|
|
11179
|
+
const schema2 = new Class22({
|
|
11176
11180
|
type: "custom",
|
|
11177
11181
|
check: "custom",
|
|
11178
11182
|
fn,
|
|
11179
11183
|
...normalizeParams(_params)
|
|
11180
11184
|
});
|
|
11181
|
-
return
|
|
11185
|
+
return schema2;
|
|
11182
11186
|
}
|
|
11183
11187
|
// @__NO_SIDE_EFFECTS__
|
|
11184
11188
|
function _superRefine(fn, params) {
|
|
@@ -11325,40 +11329,40 @@ function initializeContext(params) {
|
|
|
11325
11329
|
external: params?.external ?? void 0
|
|
11326
11330
|
};
|
|
11327
11331
|
}
|
|
11328
|
-
function process2(
|
|
11332
|
+
function process2(schema2, ctx, _params = { path: [], schemaPath: [] }) {
|
|
11329
11333
|
var _a32;
|
|
11330
|
-
const def =
|
|
11331
|
-
const seen = ctx.seen.get(
|
|
11334
|
+
const def = schema2._zod.def;
|
|
11335
|
+
const seen = ctx.seen.get(schema2);
|
|
11332
11336
|
if (seen) {
|
|
11333
11337
|
seen.count++;
|
|
11334
|
-
const isCycle = _params.schemaPath.includes(
|
|
11338
|
+
const isCycle = _params.schemaPath.includes(schema2);
|
|
11335
11339
|
if (isCycle) {
|
|
11336
11340
|
seen.cycle = _params.path;
|
|
11337
11341
|
}
|
|
11338
11342
|
return seen.schema;
|
|
11339
11343
|
}
|
|
11340
11344
|
const result = { schema: {}, count: 1, cycle: void 0, path: _params.path };
|
|
11341
|
-
ctx.seen.set(
|
|
11342
|
-
const overrideSchema =
|
|
11345
|
+
ctx.seen.set(schema2, result);
|
|
11346
|
+
const overrideSchema = schema2._zod.toJSONSchema?.();
|
|
11343
11347
|
if (overrideSchema) {
|
|
11344
11348
|
result.schema = overrideSchema;
|
|
11345
11349
|
} else {
|
|
11346
11350
|
const params = {
|
|
11347
11351
|
..._params,
|
|
11348
|
-
schemaPath: [..._params.schemaPath,
|
|
11352
|
+
schemaPath: [..._params.schemaPath, schema2],
|
|
11349
11353
|
path: _params.path
|
|
11350
11354
|
};
|
|
11351
|
-
if (
|
|
11352
|
-
|
|
11355
|
+
if (schema2._zod.processJSONSchema) {
|
|
11356
|
+
schema2._zod.processJSONSchema(ctx, result.schema, params);
|
|
11353
11357
|
} else {
|
|
11354
11358
|
const _json = result.schema;
|
|
11355
11359
|
const processor = ctx.processors[def.type];
|
|
11356
11360
|
if (!processor) {
|
|
11357
11361
|
throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
|
|
11358
11362
|
}
|
|
11359
|
-
processor(
|
|
11363
|
+
processor(schema2, ctx, _json, params);
|
|
11360
11364
|
}
|
|
11361
|
-
const parent =
|
|
11365
|
+
const parent = schema2._zod.parent;
|
|
11362
11366
|
if (parent) {
|
|
11363
11367
|
if (!result.ref)
|
|
11364
11368
|
result.ref = parent;
|
|
@@ -11366,21 +11370,21 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
11366
11370
|
ctx.seen.get(parent).isParent = true;
|
|
11367
11371
|
}
|
|
11368
11372
|
}
|
|
11369
|
-
const meta32 = ctx.metadataRegistry.get(
|
|
11373
|
+
const meta32 = ctx.metadataRegistry.get(schema2);
|
|
11370
11374
|
if (meta32)
|
|
11371
11375
|
Object.assign(result.schema, meta32);
|
|
11372
|
-
if (ctx.io === "input" && isTransforming(
|
|
11376
|
+
if (ctx.io === "input" && isTransforming(schema2)) {
|
|
11373
11377
|
delete result.schema.examples;
|
|
11374
11378
|
delete result.schema.default;
|
|
11375
11379
|
}
|
|
11376
11380
|
if (ctx.io === "input" && "_prefault" in result.schema)
|
|
11377
11381
|
(_a32 = result.schema).default ?? (_a32.default = result.schema._prefault);
|
|
11378
11382
|
delete result.schema._prefault;
|
|
11379
|
-
const _result = ctx.seen.get(
|
|
11383
|
+
const _result = ctx.seen.get(schema2);
|
|
11380
11384
|
return _result.schema;
|
|
11381
11385
|
}
|
|
11382
|
-
function extractDefs(ctx,
|
|
11383
|
-
const root = ctx.seen.get(
|
|
11386
|
+
function extractDefs(ctx, schema2) {
|
|
11387
|
+
const root = ctx.seen.get(schema2);
|
|
11384
11388
|
if (!root)
|
|
11385
11389
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
11386
11390
|
const idToSchema = /* @__PURE__ */ new Map();
|
|
@@ -11423,11 +11427,11 @@ function extractDefs(ctx, schema) {
|
|
|
11423
11427
|
seen.def = { ...seen.schema };
|
|
11424
11428
|
if (defId)
|
|
11425
11429
|
seen.defId = defId;
|
|
11426
|
-
const
|
|
11427
|
-
for (const key in
|
|
11428
|
-
delete
|
|
11430
|
+
const schema3 = seen.schema;
|
|
11431
|
+
for (const key in schema3) {
|
|
11432
|
+
delete schema3[key];
|
|
11429
11433
|
}
|
|
11430
|
-
|
|
11434
|
+
schema3.$ref = ref;
|
|
11431
11435
|
};
|
|
11432
11436
|
if (ctx.cycles === "throw") {
|
|
11433
11437
|
for (const entry of ctx.seen.entries()) {
|
|
@@ -11441,13 +11445,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11441
11445
|
}
|
|
11442
11446
|
for (const entry of ctx.seen.entries()) {
|
|
11443
11447
|
const seen = entry[1];
|
|
11444
|
-
if (
|
|
11448
|
+
if (schema2 === entry[0]) {
|
|
11445
11449
|
extractToDef(entry);
|
|
11446
11450
|
continue;
|
|
11447
11451
|
}
|
|
11448
11452
|
if (ctx.external) {
|
|
11449
11453
|
const ext = ctx.external.registry.get(entry[0])?.id;
|
|
11450
|
-
if (
|
|
11454
|
+
if (schema2 !== entry[0] && ext) {
|
|
11451
11455
|
extractToDef(entry);
|
|
11452
11456
|
continue;
|
|
11453
11457
|
}
|
|
@@ -11469,16 +11473,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11469
11473
|
}
|
|
11470
11474
|
}
|
|
11471
11475
|
}
|
|
11472
|
-
function finalize(ctx,
|
|
11473
|
-
const root = ctx.seen.get(
|
|
11476
|
+
function finalize(ctx, schema2) {
|
|
11477
|
+
const root = ctx.seen.get(schema2);
|
|
11474
11478
|
if (!root)
|
|
11475
11479
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
11476
11480
|
const flattenRef = (zodSchema) => {
|
|
11477
11481
|
const seen = ctx.seen.get(zodSchema);
|
|
11478
11482
|
if (seen.ref === null)
|
|
11479
11483
|
return;
|
|
11480
|
-
const
|
|
11481
|
-
const _cached = { ...
|
|
11484
|
+
const schema3 = seen.def ?? seen.schema;
|
|
11485
|
+
const _cached = { ...schema3 };
|
|
11482
11486
|
const ref = seen.ref;
|
|
11483
11487
|
seen.ref = null;
|
|
11484
11488
|
if (ref) {
|
|
@@ -11486,28 +11490,28 @@ function finalize(ctx, schema) {
|
|
|
11486
11490
|
const refSeen = ctx.seen.get(ref);
|
|
11487
11491
|
const refSchema = refSeen.schema;
|
|
11488
11492
|
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
11489
|
-
|
|
11490
|
-
|
|
11493
|
+
schema3.allOf = schema3.allOf ?? [];
|
|
11494
|
+
schema3.allOf.push(refSchema);
|
|
11491
11495
|
} else {
|
|
11492
|
-
Object.assign(
|
|
11496
|
+
Object.assign(schema3, refSchema);
|
|
11493
11497
|
}
|
|
11494
|
-
Object.assign(
|
|
11498
|
+
Object.assign(schema3, _cached);
|
|
11495
11499
|
const isParentRef = zodSchema._zod.parent === ref;
|
|
11496
11500
|
if (isParentRef) {
|
|
11497
|
-
for (const key in
|
|
11501
|
+
for (const key in schema3) {
|
|
11498
11502
|
if (key === "$ref" || key === "allOf")
|
|
11499
11503
|
continue;
|
|
11500
11504
|
if (!(key in _cached)) {
|
|
11501
|
-
delete
|
|
11505
|
+
delete schema3[key];
|
|
11502
11506
|
}
|
|
11503
11507
|
}
|
|
11504
11508
|
}
|
|
11505
11509
|
if (refSchema.$ref && refSeen.def) {
|
|
11506
|
-
for (const key in
|
|
11510
|
+
for (const key in schema3) {
|
|
11507
11511
|
if (key === "$ref" || key === "allOf")
|
|
11508
11512
|
continue;
|
|
11509
|
-
if (key in refSeen.def && JSON.stringify(
|
|
11510
|
-
delete
|
|
11513
|
+
if (key in refSeen.def && JSON.stringify(schema3[key]) === JSON.stringify(refSeen.def[key])) {
|
|
11514
|
+
delete schema3[key];
|
|
11511
11515
|
}
|
|
11512
11516
|
}
|
|
11513
11517
|
}
|
|
@@ -11517,13 +11521,13 @@ function finalize(ctx, schema) {
|
|
|
11517
11521
|
flattenRef(parent);
|
|
11518
11522
|
const parentSeen = ctx.seen.get(parent);
|
|
11519
11523
|
if (parentSeen?.schema.$ref) {
|
|
11520
|
-
|
|
11524
|
+
schema3.$ref = parentSeen.schema.$ref;
|
|
11521
11525
|
if (parentSeen.def) {
|
|
11522
|
-
for (const key in
|
|
11526
|
+
for (const key in schema3) {
|
|
11523
11527
|
if (key === "$ref" || key === "allOf")
|
|
11524
11528
|
continue;
|
|
11525
|
-
if (key in parentSeen.def && JSON.stringify(
|
|
11526
|
-
delete
|
|
11529
|
+
if (key in parentSeen.def && JSON.stringify(schema3[key]) === JSON.stringify(parentSeen.def[key])) {
|
|
11530
|
+
delete schema3[key];
|
|
11527
11531
|
}
|
|
11528
11532
|
}
|
|
11529
11533
|
}
|
|
@@ -11531,7 +11535,7 @@ function finalize(ctx, schema) {
|
|
|
11531
11535
|
}
|
|
11532
11536
|
ctx.override({
|
|
11533
11537
|
zodSchema,
|
|
11534
|
-
jsonSchema:
|
|
11538
|
+
jsonSchema: schema3,
|
|
11535
11539
|
path: seen.path ?? []
|
|
11536
11540
|
});
|
|
11537
11541
|
};
|
|
@@ -11549,13 +11553,13 @@ function finalize(ctx, schema) {
|
|
|
11549
11553
|
} else {
|
|
11550
11554
|
}
|
|
11551
11555
|
if (ctx.external?.uri) {
|
|
11552
|
-
const id = ctx.external.registry.get(
|
|
11556
|
+
const id = ctx.external.registry.get(schema2)?.id;
|
|
11553
11557
|
if (!id)
|
|
11554
11558
|
throw new Error("Schema is missing an `id` property");
|
|
11555
11559
|
result.$id = ctx.external.uri(id);
|
|
11556
11560
|
}
|
|
11557
11561
|
Object.assign(result, root.def ?? root.schema);
|
|
11558
|
-
const rootMetaId = ctx.metadataRegistry.get(
|
|
11562
|
+
const rootMetaId = ctx.metadataRegistry.get(schema2)?.id;
|
|
11559
11563
|
if (rootMetaId !== void 0 && result.id === rootMetaId)
|
|
11560
11564
|
delete result.id;
|
|
11561
11565
|
const defs = ctx.external?.defs ?? {};
|
|
@@ -11581,10 +11585,10 @@ function finalize(ctx, schema) {
|
|
|
11581
11585
|
const finalized = JSON.parse(JSON.stringify(result));
|
|
11582
11586
|
Object.defineProperty(finalized, "~standard", {
|
|
11583
11587
|
value: {
|
|
11584
|
-
...
|
|
11588
|
+
...schema2["~standard"],
|
|
11585
11589
|
jsonSchema: {
|
|
11586
|
-
input: createStandardJSONSchemaMethod(
|
|
11587
|
-
output: createStandardJSONSchemaMethod(
|
|
11590
|
+
input: createStandardJSONSchemaMethod(schema2, "input", ctx.processors),
|
|
11591
|
+
output: createStandardJSONSchemaMethod(schema2, "output", ctx.processors)
|
|
11588
11592
|
}
|
|
11589
11593
|
},
|
|
11590
11594
|
enumerable: false,
|
|
@@ -11648,18 +11652,18 @@ function isTransforming(_schema, _ctx) {
|
|
|
11648
11652
|
}
|
|
11649
11653
|
return false;
|
|
11650
11654
|
}
|
|
11651
|
-
var createToJSONSchemaMethod = (
|
|
11655
|
+
var createToJSONSchemaMethod = (schema2, processors = {}) => (params) => {
|
|
11652
11656
|
const ctx = initializeContext({ ...params, processors });
|
|
11653
|
-
process2(
|
|
11654
|
-
extractDefs(ctx,
|
|
11655
|
-
return finalize(ctx,
|
|
11657
|
+
process2(schema2, ctx);
|
|
11658
|
+
extractDefs(ctx, schema2);
|
|
11659
|
+
return finalize(ctx, schema2);
|
|
11656
11660
|
};
|
|
11657
|
-
var createStandardJSONSchemaMethod = (
|
|
11661
|
+
var createStandardJSONSchemaMethod = (schema2, io, processors = {}) => (params) => {
|
|
11658
11662
|
const { libraryOptions, target } = params ?? {};
|
|
11659
11663
|
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
11660
|
-
process2(
|
|
11661
|
-
extractDefs(ctx,
|
|
11662
|
-
return finalize(ctx,
|
|
11664
|
+
process2(schema2, ctx);
|
|
11665
|
+
extractDefs(ctx, schema2);
|
|
11666
|
+
return finalize(ctx, schema2);
|
|
11663
11667
|
};
|
|
11664
11668
|
var formatMap = {
|
|
11665
11669
|
guid: "uuid",
|
|
@@ -11669,10 +11673,10 @@ var formatMap = {
|
|
|
11669
11673
|
regex: ""
|
|
11670
11674
|
// do not set
|
|
11671
11675
|
};
|
|
11672
|
-
var stringProcessor = (
|
|
11676
|
+
var stringProcessor = (schema2, ctx, _json, _params) => {
|
|
11673
11677
|
const json32 = _json;
|
|
11674
11678
|
json32.type = "string";
|
|
11675
|
-
const { minimum, maximum, format, patterns, contentEncoding } =
|
|
11679
|
+
const { minimum, maximum, format, patterns, contentEncoding } = schema2._zod.bag;
|
|
11676
11680
|
if (typeof minimum === "number")
|
|
11677
11681
|
json32.minLength = minimum;
|
|
11678
11682
|
if (typeof maximum === "number")
|
|
@@ -11701,9 +11705,9 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
11701
11705
|
}
|
|
11702
11706
|
}
|
|
11703
11707
|
};
|
|
11704
|
-
var numberProcessor = (
|
|
11708
|
+
var numberProcessor = (schema2, ctx, _json, _params) => {
|
|
11705
11709
|
const json32 = _json;
|
|
11706
|
-
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } =
|
|
11710
|
+
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema2._zod.bag;
|
|
11707
11711
|
if (typeof format === "string" && format.includes("int"))
|
|
11708
11712
|
json32.type = "integer";
|
|
11709
11713
|
else
|
|
@@ -11778,8 +11782,8 @@ var dateProcessor = (_schema, ctx, _json, _params) => {
|
|
|
11778
11782
|
throw new Error("Date cannot be represented in JSON Schema");
|
|
11779
11783
|
}
|
|
11780
11784
|
};
|
|
11781
|
-
var enumProcessor = (
|
|
11782
|
-
const def =
|
|
11785
|
+
var enumProcessor = (schema2, _ctx, json32, _params) => {
|
|
11786
|
+
const def = schema2._zod.def;
|
|
11783
11787
|
const values = getEnumValues(def.entries);
|
|
11784
11788
|
if (values.every((v) => typeof v === "number"))
|
|
11785
11789
|
json32.type = "number";
|
|
@@ -11787,8 +11791,8 @@ var enumProcessor = (schema, _ctx, json32, _params) => {
|
|
|
11787
11791
|
json32.type = "string";
|
|
11788
11792
|
json32.enum = values;
|
|
11789
11793
|
};
|
|
11790
|
-
var literalProcessor = (
|
|
11791
|
-
const def =
|
|
11794
|
+
var literalProcessor = (schema2, ctx, json32, _params) => {
|
|
11795
|
+
const def = schema2._zod.def;
|
|
11792
11796
|
const vals = [];
|
|
11793
11797
|
for (const val of def.values) {
|
|
11794
11798
|
if (val === void 0) {
|
|
@@ -11832,22 +11836,22 @@ var nanProcessor = (_schema, ctx, _json, _params) => {
|
|
|
11832
11836
|
throw new Error("NaN cannot be represented in JSON Schema");
|
|
11833
11837
|
}
|
|
11834
11838
|
};
|
|
11835
|
-
var templateLiteralProcessor = (
|
|
11839
|
+
var templateLiteralProcessor = (schema2, _ctx, json32, _params) => {
|
|
11836
11840
|
const _json = json32;
|
|
11837
|
-
const pattern =
|
|
11841
|
+
const pattern = schema2._zod.pattern;
|
|
11838
11842
|
if (!pattern)
|
|
11839
11843
|
throw new Error("Pattern not found in template literal");
|
|
11840
11844
|
_json.type = "string";
|
|
11841
11845
|
_json.pattern = pattern.source;
|
|
11842
11846
|
};
|
|
11843
|
-
var fileProcessor = (
|
|
11847
|
+
var fileProcessor = (schema2, _ctx, json32, _params) => {
|
|
11844
11848
|
const _json = json32;
|
|
11845
11849
|
const file22 = {
|
|
11846
11850
|
type: "string",
|
|
11847
11851
|
format: "binary",
|
|
11848
11852
|
contentEncoding: "binary"
|
|
11849
11853
|
};
|
|
11850
|
-
const { minimum, maximum, mime } =
|
|
11854
|
+
const { minimum, maximum, mime } = schema2._zod.bag;
|
|
11851
11855
|
if (minimum !== void 0)
|
|
11852
11856
|
file22.minLength = minimum;
|
|
11853
11857
|
if (maximum !== void 0)
|
|
@@ -11892,10 +11896,10 @@ var setProcessor = (_schema, ctx, _json, _params) => {
|
|
|
11892
11896
|
throw new Error("Set cannot be represented in JSON Schema");
|
|
11893
11897
|
}
|
|
11894
11898
|
};
|
|
11895
|
-
var arrayProcessor = (
|
|
11899
|
+
var arrayProcessor = (schema2, ctx, _json, params) => {
|
|
11896
11900
|
const json32 = _json;
|
|
11897
|
-
const def =
|
|
11898
|
-
const { minimum, maximum } =
|
|
11901
|
+
const def = schema2._zod.def;
|
|
11902
|
+
const { minimum, maximum } = schema2._zod.bag;
|
|
11899
11903
|
if (typeof minimum === "number")
|
|
11900
11904
|
json32.minItems = minimum;
|
|
11901
11905
|
if (typeof maximum === "number")
|
|
@@ -11906,9 +11910,9 @@ var arrayProcessor = (schema, ctx, _json, params) => {
|
|
|
11906
11910
|
path: [...params.path, "items"]
|
|
11907
11911
|
});
|
|
11908
11912
|
};
|
|
11909
|
-
var objectProcessor = (
|
|
11913
|
+
var objectProcessor = (schema2, ctx, _json, params) => {
|
|
11910
11914
|
const json32 = _json;
|
|
11911
|
-
const def =
|
|
11915
|
+
const def = schema2._zod.def;
|
|
11912
11916
|
json32.type = "object";
|
|
11913
11917
|
json32.properties = {};
|
|
11914
11918
|
const shape = def.shape;
|
|
@@ -11942,8 +11946,8 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
11942
11946
|
});
|
|
11943
11947
|
}
|
|
11944
11948
|
};
|
|
11945
|
-
var unionProcessor = (
|
|
11946
|
-
const def =
|
|
11949
|
+
var unionProcessor = (schema2, ctx, json32, params) => {
|
|
11950
|
+
const def = schema2._zod.def;
|
|
11947
11951
|
const isExclusive = def.inclusive === false;
|
|
11948
11952
|
const options = def.options.map((x, i) => process2(x, ctx, {
|
|
11949
11953
|
...params,
|
|
@@ -11955,8 +11959,8 @@ var unionProcessor = (schema, ctx, json32, params) => {
|
|
|
11955
11959
|
json32.anyOf = options;
|
|
11956
11960
|
}
|
|
11957
11961
|
};
|
|
11958
|
-
var intersectionProcessor = (
|
|
11959
|
-
const def =
|
|
11962
|
+
var intersectionProcessor = (schema2, ctx, json32, params) => {
|
|
11963
|
+
const def = schema2._zod.def;
|
|
11960
11964
|
const a = process2(def.left, ctx, {
|
|
11961
11965
|
...params,
|
|
11962
11966
|
path: [...params.path, "allOf", 0]
|
|
@@ -11972,9 +11976,9 @@ var intersectionProcessor = (schema, ctx, json32, params) => {
|
|
|
11972
11976
|
];
|
|
11973
11977
|
json32.allOf = allOf;
|
|
11974
11978
|
};
|
|
11975
|
-
var tupleProcessor = (
|
|
11979
|
+
var tupleProcessor = (schema2, ctx, _json, params) => {
|
|
11976
11980
|
const json32 = _json;
|
|
11977
|
-
const def =
|
|
11981
|
+
const def = schema2._zod.def;
|
|
11978
11982
|
json32.type = "array";
|
|
11979
11983
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
11980
11984
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
@@ -12008,15 +12012,15 @@ var tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
12008
12012
|
json32.additionalItems = rest;
|
|
12009
12013
|
}
|
|
12010
12014
|
}
|
|
12011
|
-
const { minimum, maximum } =
|
|
12015
|
+
const { minimum, maximum } = schema2._zod.bag;
|
|
12012
12016
|
if (typeof minimum === "number")
|
|
12013
12017
|
json32.minItems = minimum;
|
|
12014
12018
|
if (typeof maximum === "number")
|
|
12015
12019
|
json32.maxItems = maximum;
|
|
12016
12020
|
};
|
|
12017
|
-
var recordProcessor = (
|
|
12021
|
+
var recordProcessor = (schema2, ctx, _json, params) => {
|
|
12018
12022
|
const json32 = _json;
|
|
12019
|
-
const def =
|
|
12023
|
+
const def = schema2._zod.def;
|
|
12020
12024
|
json32.type = "object";
|
|
12021
12025
|
const keyType = def.keyType;
|
|
12022
12026
|
const keyBag = keyType._zod.bag;
|
|
@@ -12050,10 +12054,10 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
12050
12054
|
}
|
|
12051
12055
|
}
|
|
12052
12056
|
};
|
|
12053
|
-
var nullableProcessor = (
|
|
12054
|
-
const def =
|
|
12057
|
+
var nullableProcessor = (schema2, ctx, json32, params) => {
|
|
12058
|
+
const def = schema2._zod.def;
|
|
12055
12059
|
const inner = process2(def.innerType, ctx, params);
|
|
12056
|
-
const seen = ctx.seen.get(
|
|
12060
|
+
const seen = ctx.seen.get(schema2);
|
|
12057
12061
|
if (ctx.target === "openapi-3.0") {
|
|
12058
12062
|
seen.ref = def.innerType;
|
|
12059
12063
|
json32.nullable = true;
|
|
@@ -12061,31 +12065,31 @@ var nullableProcessor = (schema, ctx, json32, params) => {
|
|
|
12061
12065
|
json32.anyOf = [inner, { type: "null" }];
|
|
12062
12066
|
}
|
|
12063
12067
|
};
|
|
12064
|
-
var nonoptionalProcessor = (
|
|
12065
|
-
const def =
|
|
12068
|
+
var nonoptionalProcessor = (schema2, ctx, _json, params) => {
|
|
12069
|
+
const def = schema2._zod.def;
|
|
12066
12070
|
process2(def.innerType, ctx, params);
|
|
12067
|
-
const seen = ctx.seen.get(
|
|
12071
|
+
const seen = ctx.seen.get(schema2);
|
|
12068
12072
|
seen.ref = def.innerType;
|
|
12069
12073
|
};
|
|
12070
|
-
var defaultProcessor = (
|
|
12071
|
-
const def =
|
|
12074
|
+
var defaultProcessor = (schema2, ctx, json32, params) => {
|
|
12075
|
+
const def = schema2._zod.def;
|
|
12072
12076
|
process2(def.innerType, ctx, params);
|
|
12073
|
-
const seen = ctx.seen.get(
|
|
12077
|
+
const seen = ctx.seen.get(schema2);
|
|
12074
12078
|
seen.ref = def.innerType;
|
|
12075
12079
|
json32.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
12076
12080
|
};
|
|
12077
|
-
var prefaultProcessor = (
|
|
12078
|
-
const def =
|
|
12081
|
+
var prefaultProcessor = (schema2, ctx, json32, params) => {
|
|
12082
|
+
const def = schema2._zod.def;
|
|
12079
12083
|
process2(def.innerType, ctx, params);
|
|
12080
|
-
const seen = ctx.seen.get(
|
|
12084
|
+
const seen = ctx.seen.get(schema2);
|
|
12081
12085
|
seen.ref = def.innerType;
|
|
12082
12086
|
if (ctx.io === "input")
|
|
12083
12087
|
json32._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
12084
12088
|
};
|
|
12085
|
-
var catchProcessor = (
|
|
12086
|
-
const def =
|
|
12089
|
+
var catchProcessor = (schema2, ctx, json32, params) => {
|
|
12090
|
+
const def = schema2._zod.def;
|
|
12087
12091
|
process2(def.innerType, ctx, params);
|
|
12088
|
-
const seen = ctx.seen.get(
|
|
12092
|
+
const seen = ctx.seen.get(schema2);
|
|
12089
12093
|
seen.ref = def.innerType;
|
|
12090
12094
|
let catchValue;
|
|
12091
12095
|
try {
|
|
@@ -12095,37 +12099,37 @@ var catchProcessor = (schema, ctx, json32, params) => {
|
|
|
12095
12099
|
}
|
|
12096
12100
|
json32.default = catchValue;
|
|
12097
12101
|
};
|
|
12098
|
-
var pipeProcessor = (
|
|
12099
|
-
const def =
|
|
12102
|
+
var pipeProcessor = (schema2, ctx, _json, params) => {
|
|
12103
|
+
const def = schema2._zod.def;
|
|
12100
12104
|
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
12101
12105
|
const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
|
|
12102
12106
|
process2(innerType, ctx, params);
|
|
12103
|
-
const seen = ctx.seen.get(
|
|
12107
|
+
const seen = ctx.seen.get(schema2);
|
|
12104
12108
|
seen.ref = innerType;
|
|
12105
12109
|
};
|
|
12106
|
-
var readonlyProcessor = (
|
|
12107
|
-
const def =
|
|
12110
|
+
var readonlyProcessor = (schema2, ctx, json32, params) => {
|
|
12111
|
+
const def = schema2._zod.def;
|
|
12108
12112
|
process2(def.innerType, ctx, params);
|
|
12109
|
-
const seen = ctx.seen.get(
|
|
12113
|
+
const seen = ctx.seen.get(schema2);
|
|
12110
12114
|
seen.ref = def.innerType;
|
|
12111
12115
|
json32.readOnly = true;
|
|
12112
12116
|
};
|
|
12113
|
-
var promiseProcessor = (
|
|
12114
|
-
const def =
|
|
12117
|
+
var promiseProcessor = (schema2, ctx, _json, params) => {
|
|
12118
|
+
const def = schema2._zod.def;
|
|
12115
12119
|
process2(def.innerType, ctx, params);
|
|
12116
|
-
const seen = ctx.seen.get(
|
|
12120
|
+
const seen = ctx.seen.get(schema2);
|
|
12117
12121
|
seen.ref = def.innerType;
|
|
12118
12122
|
};
|
|
12119
|
-
var optionalProcessor = (
|
|
12120
|
-
const def =
|
|
12123
|
+
var optionalProcessor = (schema2, ctx, _json, params) => {
|
|
12124
|
+
const def = schema2._zod.def;
|
|
12121
12125
|
process2(def.innerType, ctx, params);
|
|
12122
|
-
const seen = ctx.seen.get(
|
|
12126
|
+
const seen = ctx.seen.get(schema2);
|
|
12123
12127
|
seen.ref = def.innerType;
|
|
12124
12128
|
};
|
|
12125
|
-
var lazyProcessor = (
|
|
12126
|
-
const innerType =
|
|
12129
|
+
var lazyProcessor = (schema2, ctx, _json, params) => {
|
|
12130
|
+
const innerType = schema2._zod.innerType;
|
|
12127
12131
|
process2(innerType, ctx, params);
|
|
12128
|
-
const seen = ctx.seen.get(
|
|
12132
|
+
const seen = ctx.seen.get(schema2);
|
|
12129
12133
|
seen.ref = innerType;
|
|
12130
12134
|
};
|
|
12131
12135
|
var allProcessors = {
|
|
@@ -12175,8 +12179,8 @@ function toJSONSchema(input, params) {
|
|
|
12175
12179
|
const ctx2 = initializeContext({ ...params, processors: allProcessors });
|
|
12176
12180
|
const defs = {};
|
|
12177
12181
|
for (const entry of registry22._idmap.entries()) {
|
|
12178
|
-
const [_,
|
|
12179
|
-
process2(
|
|
12182
|
+
const [_, schema2] = entry;
|
|
12183
|
+
process2(schema2, ctx2);
|
|
12180
12184
|
}
|
|
12181
12185
|
const schemas = {};
|
|
12182
12186
|
const external = {
|
|
@@ -12186,9 +12190,9 @@ function toJSONSchema(input, params) {
|
|
|
12186
12190
|
};
|
|
12187
12191
|
ctx2.external = external;
|
|
12188
12192
|
for (const entry of registry22._idmap.entries()) {
|
|
12189
|
-
const [key,
|
|
12190
|
-
extractDefs(ctx2,
|
|
12191
|
-
schemas[key] = finalize(ctx2,
|
|
12193
|
+
const [key, schema2] = entry;
|
|
12194
|
+
extractDefs(ctx2, schema2);
|
|
12195
|
+
schemas[key] = finalize(ctx2, schema2);
|
|
12192
12196
|
}
|
|
12193
12197
|
if (Object.keys(defs).length > 0) {
|
|
12194
12198
|
const defsSegment = ctx2.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
@@ -12254,14 +12258,14 @@ var JSONSchemaGenerator = class {
|
|
|
12254
12258
|
* Process a schema to prepare it for JSON Schema generation.
|
|
12255
12259
|
* This must be called before emit().
|
|
12256
12260
|
*/
|
|
12257
|
-
process(
|
|
12258
|
-
return process2(
|
|
12261
|
+
process(schema2, _params = { path: [], schemaPath: [] }) {
|
|
12262
|
+
return process2(schema2, this.ctx, _params);
|
|
12259
12263
|
}
|
|
12260
12264
|
/**
|
|
12261
12265
|
* Emit the final JSON Schema after processing.
|
|
12262
12266
|
* Must call process() first.
|
|
12263
12267
|
*/
|
|
12264
|
-
emit(
|
|
12268
|
+
emit(schema2, _params) {
|
|
12265
12269
|
if (_params) {
|
|
12266
12270
|
if (_params.cycles)
|
|
12267
12271
|
this.ctx.cycles = _params.cycles;
|
|
@@ -12270,8 +12274,8 @@ var JSONSchemaGenerator = class {
|
|
|
12270
12274
|
if (_params.external)
|
|
12271
12275
|
this.ctx.external = _params.external;
|
|
12272
12276
|
}
|
|
12273
|
-
extractDefs(this.ctx,
|
|
12274
|
-
const result = finalize(this.ctx,
|
|
12277
|
+
extractDefs(this.ctx, schema2);
|
|
12278
|
+
const result = finalize(this.ctx, schema2);
|
|
12275
12279
|
const { "~standard": _, ...plainResult } = result;
|
|
12276
12280
|
return plainResult;
|
|
12277
12281
|
}
|
|
@@ -13222,8 +13226,8 @@ var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
|
13222
13226
|
function array(element, params) {
|
|
13223
13227
|
return /* @__PURE__ */ _array(ZodArray, element, params);
|
|
13224
13228
|
}
|
|
13225
|
-
function keyof(
|
|
13226
|
-
const shape =
|
|
13229
|
+
function keyof(schema2) {
|
|
13230
|
+
const shape = schema2._zod.def.shape;
|
|
13227
13231
|
return _enum2(Object.keys(shape));
|
|
13228
13232
|
}
|
|
13229
13233
|
var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
@@ -13848,11 +13852,11 @@ function json(params) {
|
|
|
13848
13852
|
});
|
|
13849
13853
|
return jsonSchema;
|
|
13850
13854
|
}
|
|
13851
|
-
function preprocess(fn,
|
|
13855
|
+
function preprocess(fn, schema2) {
|
|
13852
13856
|
return new ZodPreprocess({
|
|
13853
13857
|
type: "pipe",
|
|
13854
13858
|
in: transform(fn),
|
|
13855
|
-
out:
|
|
13859
|
+
out: schema2
|
|
13856
13860
|
});
|
|
13857
13861
|
}
|
|
13858
13862
|
var ZodIssueCode = {
|
|
@@ -13955,8 +13959,8 @@ var RECOGNIZED_KEYS = /* @__PURE__ */ new Set([
|
|
|
13955
13959
|
"nullable",
|
|
13956
13960
|
"readOnly"
|
|
13957
13961
|
]);
|
|
13958
|
-
function detectVersion(
|
|
13959
|
-
const $schema =
|
|
13962
|
+
function detectVersion(schema2, defaultTarget) {
|
|
13963
|
+
const $schema = schema2.$schema;
|
|
13960
13964
|
if ($schema === "https://json-schema.org/draft/2020-12/schema") {
|
|
13961
13965
|
return "draft-2020-12";
|
|
13962
13966
|
}
|
|
@@ -13986,27 +13990,27 @@ function resolveRef(ref, ctx) {
|
|
|
13986
13990
|
}
|
|
13987
13991
|
throw new Error(`Reference not found: ${ref}`);
|
|
13988
13992
|
}
|
|
13989
|
-
function convertBaseSchema(
|
|
13990
|
-
if (
|
|
13991
|
-
if (typeof
|
|
13993
|
+
function convertBaseSchema(schema2, ctx) {
|
|
13994
|
+
if (schema2.not !== void 0) {
|
|
13995
|
+
if (typeof schema2.not === "object" && Object.keys(schema2.not).length === 0) {
|
|
13992
13996
|
return z.never();
|
|
13993
13997
|
}
|
|
13994
13998
|
throw new Error("not is not supported in Zod (except { not: {} } for never)");
|
|
13995
13999
|
}
|
|
13996
|
-
if (
|
|
14000
|
+
if (schema2.unevaluatedItems !== void 0) {
|
|
13997
14001
|
throw new Error("unevaluatedItems is not supported");
|
|
13998
14002
|
}
|
|
13999
|
-
if (
|
|
14003
|
+
if (schema2.unevaluatedProperties !== void 0) {
|
|
14000
14004
|
throw new Error("unevaluatedProperties is not supported");
|
|
14001
14005
|
}
|
|
14002
|
-
if (
|
|
14006
|
+
if (schema2.if !== void 0 || schema2.then !== void 0 || schema2.else !== void 0) {
|
|
14003
14007
|
throw new Error("Conditional schemas (if/then/else) are not supported");
|
|
14004
14008
|
}
|
|
14005
|
-
if (
|
|
14009
|
+
if (schema2.dependentSchemas !== void 0 || schema2.dependentRequired !== void 0) {
|
|
14006
14010
|
throw new Error("dependentSchemas and dependentRequired are not supported");
|
|
14007
14011
|
}
|
|
14008
|
-
if (
|
|
14009
|
-
const refPath =
|
|
14012
|
+
if (schema2.$ref) {
|
|
14013
|
+
const refPath = schema2.$ref;
|
|
14010
14014
|
if (ctx.refs.has(refPath)) {
|
|
14011
14015
|
return ctx.refs.get(refPath);
|
|
14012
14016
|
}
|
|
@@ -14025,9 +14029,9 @@ function convertBaseSchema(schema, ctx) {
|
|
|
14025
14029
|
ctx.processing.delete(refPath);
|
|
14026
14030
|
return zodSchema2;
|
|
14027
14031
|
}
|
|
14028
|
-
if (
|
|
14029
|
-
const enumValues =
|
|
14030
|
-
if (ctx.version === "openapi-3.0" &&
|
|
14032
|
+
if (schema2.enum !== void 0) {
|
|
14033
|
+
const enumValues = schema2.enum;
|
|
14034
|
+
if (ctx.version === "openapi-3.0" && schema2.nullable === true && enumValues.length === 1 && enumValues[0] === null) {
|
|
14031
14035
|
return z.null();
|
|
14032
14036
|
}
|
|
14033
14037
|
if (enumValues.length === 0) {
|
|
@@ -14045,13 +14049,13 @@ function convertBaseSchema(schema, ctx) {
|
|
|
14045
14049
|
}
|
|
14046
14050
|
return z.union([literalSchemas[0], literalSchemas[1], ...literalSchemas.slice(2)]);
|
|
14047
14051
|
}
|
|
14048
|
-
if (
|
|
14049
|
-
return z.literal(
|
|
14052
|
+
if (schema2.const !== void 0) {
|
|
14053
|
+
return z.literal(schema2.const);
|
|
14050
14054
|
}
|
|
14051
|
-
const type =
|
|
14055
|
+
const type = schema2.type;
|
|
14052
14056
|
if (Array.isArray(type)) {
|
|
14053
14057
|
const typeSchemas = type.map((t) => {
|
|
14054
|
-
const typeSchema = { ...
|
|
14058
|
+
const typeSchema = { ...schema2, type: t };
|
|
14055
14059
|
return convertBaseSchema(typeSchema, ctx);
|
|
14056
14060
|
});
|
|
14057
14061
|
if (typeSchemas.length === 0) {
|
|
@@ -14069,8 +14073,8 @@ function convertBaseSchema(schema, ctx) {
|
|
|
14069
14073
|
switch (type) {
|
|
14070
14074
|
case "string": {
|
|
14071
14075
|
let stringSchema = z.string();
|
|
14072
|
-
if (
|
|
14073
|
-
const format =
|
|
14076
|
+
if (schema2.format) {
|
|
14077
|
+
const format = schema2.format;
|
|
14074
14078
|
if (format === "email") {
|
|
14075
14079
|
stringSchema = stringSchema.check(z.email());
|
|
14076
14080
|
} else if (format === "uri" || format === "uri-reference") {
|
|
@@ -14119,14 +14123,14 @@ function convertBaseSchema(schema, ctx) {
|
|
|
14119
14123
|
stringSchema = stringSchema.check(z.ksuid());
|
|
14120
14124
|
}
|
|
14121
14125
|
}
|
|
14122
|
-
if (typeof
|
|
14123
|
-
stringSchema = stringSchema.min(
|
|
14126
|
+
if (typeof schema2.minLength === "number") {
|
|
14127
|
+
stringSchema = stringSchema.min(schema2.minLength);
|
|
14124
14128
|
}
|
|
14125
|
-
if (typeof
|
|
14126
|
-
stringSchema = stringSchema.max(
|
|
14129
|
+
if (typeof schema2.maxLength === "number") {
|
|
14130
|
+
stringSchema = stringSchema.max(schema2.maxLength);
|
|
14127
14131
|
}
|
|
14128
|
-
if (
|
|
14129
|
-
stringSchema = stringSchema.regex(new RegExp(
|
|
14132
|
+
if (schema2.pattern) {
|
|
14133
|
+
stringSchema = stringSchema.regex(new RegExp(schema2.pattern));
|
|
14130
14134
|
}
|
|
14131
14135
|
zodSchema = stringSchema;
|
|
14132
14136
|
break;
|
|
@@ -14134,24 +14138,24 @@ function convertBaseSchema(schema, ctx) {
|
|
|
14134
14138
|
case "number":
|
|
14135
14139
|
case "integer": {
|
|
14136
14140
|
let numberSchema = type === "integer" ? z.number().int() : z.number();
|
|
14137
|
-
if (typeof
|
|
14138
|
-
numberSchema = numberSchema.min(
|
|
14141
|
+
if (typeof schema2.minimum === "number") {
|
|
14142
|
+
numberSchema = numberSchema.min(schema2.minimum);
|
|
14139
14143
|
}
|
|
14140
|
-
if (typeof
|
|
14141
|
-
numberSchema = numberSchema.max(
|
|
14144
|
+
if (typeof schema2.maximum === "number") {
|
|
14145
|
+
numberSchema = numberSchema.max(schema2.maximum);
|
|
14142
14146
|
}
|
|
14143
|
-
if (typeof
|
|
14144
|
-
numberSchema = numberSchema.gt(
|
|
14145
|
-
} else if (
|
|
14146
|
-
numberSchema = numberSchema.gt(
|
|
14147
|
+
if (typeof schema2.exclusiveMinimum === "number") {
|
|
14148
|
+
numberSchema = numberSchema.gt(schema2.exclusiveMinimum);
|
|
14149
|
+
} else if (schema2.exclusiveMinimum === true && typeof schema2.minimum === "number") {
|
|
14150
|
+
numberSchema = numberSchema.gt(schema2.minimum);
|
|
14147
14151
|
}
|
|
14148
|
-
if (typeof
|
|
14149
|
-
numberSchema = numberSchema.lt(
|
|
14150
|
-
} else if (
|
|
14151
|
-
numberSchema = numberSchema.lt(
|
|
14152
|
+
if (typeof schema2.exclusiveMaximum === "number") {
|
|
14153
|
+
numberSchema = numberSchema.lt(schema2.exclusiveMaximum);
|
|
14154
|
+
} else if (schema2.exclusiveMaximum === true && typeof schema2.maximum === "number") {
|
|
14155
|
+
numberSchema = numberSchema.lt(schema2.maximum);
|
|
14152
14156
|
}
|
|
14153
|
-
if (typeof
|
|
14154
|
-
numberSchema = numberSchema.multipleOf(
|
|
14157
|
+
if (typeof schema2.multipleOf === "number") {
|
|
14158
|
+
numberSchema = numberSchema.multipleOf(schema2.multipleOf);
|
|
14155
14159
|
}
|
|
14156
14160
|
zodSchema = numberSchema;
|
|
14157
14161
|
break;
|
|
@@ -14166,15 +14170,15 @@ function convertBaseSchema(schema, ctx) {
|
|
|
14166
14170
|
}
|
|
14167
14171
|
case "object": {
|
|
14168
14172
|
const shape = {};
|
|
14169
|
-
const properties =
|
|
14170
|
-
const requiredSet = new Set(
|
|
14173
|
+
const properties = schema2.properties || {};
|
|
14174
|
+
const requiredSet = new Set(schema2.required || []);
|
|
14171
14175
|
for (const [key, propSchema] of Object.entries(properties)) {
|
|
14172
14176
|
const propZodSchema = convertSchema(propSchema, ctx);
|
|
14173
14177
|
shape[key] = requiredSet.has(key) ? propZodSchema : propZodSchema.optional();
|
|
14174
14178
|
}
|
|
14175
|
-
if (
|
|
14176
|
-
const keySchema = convertSchema(
|
|
14177
|
-
const valueSchema =
|
|
14179
|
+
if (schema2.propertyNames) {
|
|
14180
|
+
const keySchema = convertSchema(schema2.propertyNames, ctx);
|
|
14181
|
+
const valueSchema = schema2.additionalProperties && typeof schema2.additionalProperties === "object" ? convertSchema(schema2.additionalProperties, ctx) : z.any();
|
|
14178
14182
|
if (Object.keys(shape).length === 0) {
|
|
14179
14183
|
zodSchema = z.record(keySchema, valueSchema);
|
|
14180
14184
|
break;
|
|
@@ -14184,8 +14188,8 @@ function convertBaseSchema(schema, ctx) {
|
|
|
14184
14188
|
zodSchema = z.intersection(objectSchema2, recordSchema);
|
|
14185
14189
|
break;
|
|
14186
14190
|
}
|
|
14187
|
-
if (
|
|
14188
|
-
const patternProps =
|
|
14191
|
+
if (schema2.patternProperties) {
|
|
14192
|
+
const patternProps = schema2.patternProperties;
|
|
14189
14193
|
const patternKeys = Object.keys(patternProps);
|
|
14190
14194
|
const looseRecords = [];
|
|
14191
14195
|
for (const pattern of patternKeys) {
|
|
@@ -14212,18 +14216,18 @@ function convertBaseSchema(schema, ctx) {
|
|
|
14212
14216
|
break;
|
|
14213
14217
|
}
|
|
14214
14218
|
const objectSchema = z.object(shape);
|
|
14215
|
-
if (
|
|
14219
|
+
if (schema2.additionalProperties === false) {
|
|
14216
14220
|
zodSchema = objectSchema.strict();
|
|
14217
|
-
} else if (typeof
|
|
14218
|
-
zodSchema = objectSchema.catchall(convertSchema(
|
|
14221
|
+
} else if (typeof schema2.additionalProperties === "object") {
|
|
14222
|
+
zodSchema = objectSchema.catchall(convertSchema(schema2.additionalProperties, ctx));
|
|
14219
14223
|
} else {
|
|
14220
14224
|
zodSchema = objectSchema.passthrough();
|
|
14221
14225
|
}
|
|
14222
14226
|
break;
|
|
14223
14227
|
}
|
|
14224
14228
|
case "array": {
|
|
14225
|
-
const prefixItems =
|
|
14226
|
-
const items =
|
|
14229
|
+
const prefixItems = schema2.prefixItems;
|
|
14230
|
+
const items = schema2.items;
|
|
14227
14231
|
if (prefixItems && Array.isArray(prefixItems)) {
|
|
14228
14232
|
const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
|
|
14229
14233
|
const rest = items && typeof items === "object" && !Array.isArray(items) ? convertSchema(items, ctx) : void 0;
|
|
@@ -14232,34 +14236,34 @@ function convertBaseSchema(schema, ctx) {
|
|
|
14232
14236
|
} else {
|
|
14233
14237
|
zodSchema = z.tuple(tupleItems);
|
|
14234
14238
|
}
|
|
14235
|
-
if (typeof
|
|
14236
|
-
zodSchema = zodSchema.check(z.minLength(
|
|
14239
|
+
if (typeof schema2.minItems === "number") {
|
|
14240
|
+
zodSchema = zodSchema.check(z.minLength(schema2.minItems));
|
|
14237
14241
|
}
|
|
14238
|
-
if (typeof
|
|
14239
|
-
zodSchema = zodSchema.check(z.maxLength(
|
|
14242
|
+
if (typeof schema2.maxItems === "number") {
|
|
14243
|
+
zodSchema = zodSchema.check(z.maxLength(schema2.maxItems));
|
|
14240
14244
|
}
|
|
14241
14245
|
} else if (Array.isArray(items)) {
|
|
14242
14246
|
const tupleItems = items.map((item) => convertSchema(item, ctx));
|
|
14243
|
-
const rest =
|
|
14247
|
+
const rest = schema2.additionalItems && typeof schema2.additionalItems === "object" ? convertSchema(schema2.additionalItems, ctx) : void 0;
|
|
14244
14248
|
if (rest) {
|
|
14245
14249
|
zodSchema = z.tuple(tupleItems).rest(rest);
|
|
14246
14250
|
} else {
|
|
14247
14251
|
zodSchema = z.tuple(tupleItems);
|
|
14248
14252
|
}
|
|
14249
|
-
if (typeof
|
|
14250
|
-
zodSchema = zodSchema.check(z.minLength(
|
|
14253
|
+
if (typeof schema2.minItems === "number") {
|
|
14254
|
+
zodSchema = zodSchema.check(z.minLength(schema2.minItems));
|
|
14251
14255
|
}
|
|
14252
|
-
if (typeof
|
|
14253
|
-
zodSchema = zodSchema.check(z.maxLength(
|
|
14256
|
+
if (typeof schema2.maxItems === "number") {
|
|
14257
|
+
zodSchema = zodSchema.check(z.maxLength(schema2.maxItems));
|
|
14254
14258
|
}
|
|
14255
14259
|
} else if (items !== void 0) {
|
|
14256
14260
|
const element = convertSchema(items, ctx);
|
|
14257
14261
|
let arraySchema = z.array(element);
|
|
14258
|
-
if (typeof
|
|
14259
|
-
arraySchema = arraySchema.min(
|
|
14262
|
+
if (typeof schema2.minItems === "number") {
|
|
14263
|
+
arraySchema = arraySchema.min(schema2.minItems);
|
|
14260
14264
|
}
|
|
14261
|
-
if (typeof
|
|
14262
|
-
arraySchema = arraySchema.max(
|
|
14265
|
+
if (typeof schema2.maxItems === "number") {
|
|
14266
|
+
arraySchema = arraySchema.max(schema2.maxItems);
|
|
14263
14267
|
}
|
|
14264
14268
|
zodSchema = arraySchema;
|
|
14265
14269
|
} else {
|
|
@@ -14272,76 +14276,76 @@ function convertBaseSchema(schema, ctx) {
|
|
|
14272
14276
|
}
|
|
14273
14277
|
return zodSchema;
|
|
14274
14278
|
}
|
|
14275
|
-
function convertSchema(
|
|
14276
|
-
if (typeof
|
|
14277
|
-
return
|
|
14279
|
+
function convertSchema(schema2, ctx) {
|
|
14280
|
+
if (typeof schema2 === "boolean") {
|
|
14281
|
+
return schema2 ? z.any() : z.never();
|
|
14278
14282
|
}
|
|
14279
|
-
let baseSchema = convertBaseSchema(
|
|
14280
|
-
const hasExplicitType =
|
|
14281
|
-
if (
|
|
14282
|
-
const options =
|
|
14283
|
+
let baseSchema = convertBaseSchema(schema2, ctx);
|
|
14284
|
+
const hasExplicitType = schema2.type || schema2.enum !== void 0 || schema2.const !== void 0;
|
|
14285
|
+
if (schema2.anyOf && Array.isArray(schema2.anyOf)) {
|
|
14286
|
+
const options = schema2.anyOf.map((s) => convertSchema(s, ctx));
|
|
14283
14287
|
const anyOfUnion = z.union(options);
|
|
14284
14288
|
baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
|
|
14285
14289
|
}
|
|
14286
|
-
if (
|
|
14287
|
-
const options =
|
|
14290
|
+
if (schema2.oneOf && Array.isArray(schema2.oneOf)) {
|
|
14291
|
+
const options = schema2.oneOf.map((s) => convertSchema(s, ctx));
|
|
14288
14292
|
const oneOfUnion = z.xor(options);
|
|
14289
14293
|
baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
|
|
14290
14294
|
}
|
|
14291
|
-
if (
|
|
14292
|
-
if (
|
|
14295
|
+
if (schema2.allOf && Array.isArray(schema2.allOf)) {
|
|
14296
|
+
if (schema2.allOf.length === 0) {
|
|
14293
14297
|
baseSchema = hasExplicitType ? baseSchema : z.any();
|
|
14294
14298
|
} else {
|
|
14295
|
-
let result = hasExplicitType ? baseSchema : convertSchema(
|
|
14299
|
+
let result = hasExplicitType ? baseSchema : convertSchema(schema2.allOf[0], ctx);
|
|
14296
14300
|
const startIdx = hasExplicitType ? 0 : 1;
|
|
14297
|
-
for (let i = startIdx; i <
|
|
14298
|
-
result = z.intersection(result, convertSchema(
|
|
14301
|
+
for (let i = startIdx; i < schema2.allOf.length; i++) {
|
|
14302
|
+
result = z.intersection(result, convertSchema(schema2.allOf[i], ctx));
|
|
14299
14303
|
}
|
|
14300
14304
|
baseSchema = result;
|
|
14301
14305
|
}
|
|
14302
14306
|
}
|
|
14303
|
-
if (
|
|
14307
|
+
if (schema2.nullable === true && ctx.version === "openapi-3.0") {
|
|
14304
14308
|
baseSchema = z.nullable(baseSchema);
|
|
14305
14309
|
}
|
|
14306
|
-
if (
|
|
14310
|
+
if (schema2.readOnly === true) {
|
|
14307
14311
|
baseSchema = z.readonly(baseSchema);
|
|
14308
14312
|
}
|
|
14309
|
-
if (
|
|
14310
|
-
baseSchema = baseSchema.default(
|
|
14313
|
+
if (schema2.default !== void 0) {
|
|
14314
|
+
baseSchema = baseSchema.default(schema2.default);
|
|
14311
14315
|
}
|
|
14312
14316
|
const extraMeta = {};
|
|
14313
14317
|
const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
|
|
14314
14318
|
for (const key of coreMetadataKeys) {
|
|
14315
|
-
if (key in
|
|
14316
|
-
extraMeta[key] =
|
|
14319
|
+
if (key in schema2) {
|
|
14320
|
+
extraMeta[key] = schema2[key];
|
|
14317
14321
|
}
|
|
14318
14322
|
}
|
|
14319
14323
|
const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
|
|
14320
14324
|
for (const key of contentMetadataKeys) {
|
|
14321
|
-
if (key in
|
|
14322
|
-
extraMeta[key] =
|
|
14325
|
+
if (key in schema2) {
|
|
14326
|
+
extraMeta[key] = schema2[key];
|
|
14323
14327
|
}
|
|
14324
14328
|
}
|
|
14325
|
-
for (const key of Object.keys(
|
|
14329
|
+
for (const key of Object.keys(schema2)) {
|
|
14326
14330
|
if (!RECOGNIZED_KEYS.has(key)) {
|
|
14327
|
-
extraMeta[key] =
|
|
14331
|
+
extraMeta[key] = schema2[key];
|
|
14328
14332
|
}
|
|
14329
14333
|
}
|
|
14330
14334
|
if (Object.keys(extraMeta).length > 0) {
|
|
14331
14335
|
ctx.registry.add(baseSchema, extraMeta);
|
|
14332
14336
|
}
|
|
14333
|
-
if (
|
|
14334
|
-
baseSchema = baseSchema.describe(
|
|
14337
|
+
if (schema2.description) {
|
|
14338
|
+
baseSchema = baseSchema.describe(schema2.description);
|
|
14335
14339
|
}
|
|
14336
14340
|
return baseSchema;
|
|
14337
14341
|
}
|
|
14338
|
-
function fromJSONSchema(
|
|
14339
|
-
if (typeof
|
|
14340
|
-
return
|
|
14342
|
+
function fromJSONSchema(schema2, params) {
|
|
14343
|
+
if (typeof schema2 === "boolean") {
|
|
14344
|
+
return schema2 ? z.any() : z.never();
|
|
14341
14345
|
}
|
|
14342
14346
|
let normalized;
|
|
14343
14347
|
try {
|
|
14344
|
-
normalized = JSON.parse(JSON.stringify(
|
|
14348
|
+
normalized = JSON.parse(JSON.stringify(schema2));
|
|
14345
14349
|
} catch {
|
|
14346
14350
|
throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
|
|
14347
14351
|
}
|
|
@@ -14464,19 +14468,24 @@ var BridgeRequestSchema = external_exports.discriminatedUnion("method", [
|
|
|
14464
14468
|
args: external_exports.record(external_exports.string(), external_exports.unknown())
|
|
14465
14469
|
})
|
|
14466
14470
|
]);
|
|
14471
|
+
var elapsedMs = external_exports.number().nonnegative().optional();
|
|
14467
14472
|
var BridgeResultSchema = external_exports.union([
|
|
14468
14473
|
external_exports.object({
|
|
14469
14474
|
t: external_exports.literal("res"),
|
|
14470
14475
|
id: external_exports.string(),
|
|
14471
14476
|
ok: external_exports.literal(true),
|
|
14472
|
-
result: external_exports.unknown()
|
|
14477
|
+
result: external_exports.unknown(),
|
|
14478
|
+
ms: elapsedMs
|
|
14473
14479
|
}),
|
|
14474
14480
|
external_exports.object({
|
|
14475
14481
|
t: external_exports.literal("res"),
|
|
14476
14482
|
id: external_exports.string(),
|
|
14477
14483
|
ok: external_exports.literal(false),
|
|
14478
14484
|
reason: external_exports.string(),
|
|
14479
|
-
message: external_exports.string()
|
|
14485
|
+
message: external_exports.string(),
|
|
14486
|
+
// 🔴 Carried on failure too: the timing of a call that FAILED is exactly
|
|
14487
|
+
// what tells a timeout apart from a refusal.
|
|
14488
|
+
ms: elapsedMs
|
|
14480
14489
|
})
|
|
14481
14490
|
]);
|
|
14482
14491
|
var BridgeHeartbeatSchema = external_exports.object({
|
|
@@ -14499,7 +14508,7 @@ var BridgeUpstreamSchema = external_exports.union([
|
|
|
14499
14508
|
]);
|
|
14500
14509
|
var UPSTREAM_FRAME_TYPES = ["res", "tools"];
|
|
14501
14510
|
var FrameEnvelopeSchema = external_exports.object({ t: external_exports.string() });
|
|
14502
|
-
function classifyFrame(
|
|
14511
|
+
function classifyFrame(schema2, knownTypes, raw) {
|
|
14503
14512
|
const envelope = FrameEnvelopeSchema.safeParse(raw);
|
|
14504
14513
|
if (!envelope.success) {
|
|
14505
14514
|
return { kind: "malformed", message: "frame has no string `t` field" };
|
|
@@ -14507,7 +14516,7 @@ function classifyFrame(schema, knownTypes, raw) {
|
|
|
14507
14516
|
if (!knownTypes.includes(envelope.data.t)) {
|
|
14508
14517
|
return { kind: "unknown", frameType: envelope.data.t };
|
|
14509
14518
|
}
|
|
14510
|
-
const parsed =
|
|
14519
|
+
const parsed = schema2.safeParse(raw);
|
|
14511
14520
|
if (!parsed.success) {
|
|
14512
14521
|
return {
|
|
14513
14522
|
kind: "malformed",
|
|
@@ -14833,7 +14842,12 @@ var TOOL_TIERS = Object.freeze({
|
|
|
14833
14842
|
video_image_add_from_gallery: "write",
|
|
14834
14843
|
video_scene_update: "write",
|
|
14835
14844
|
video_background_set: "write",
|
|
14836
|
-
|
|
14845
|
+
// 🔴 destructive, unlike the photo editor's same-named tool. There it
|
|
14846
|
+
// retargets the page you are looking at; here the encoder reads one size off
|
|
14847
|
+
// the first scene and renders the whole video at it, so one wrong value
|
|
14848
|
+
// reflows every scene. Bulk is what makes it destructive, and no tool here
|
|
14849
|
+
// can undo it — the agent has no undo to call.
|
|
14850
|
+
video_canvas_resize: "destructive",
|
|
14837
14851
|
video_scene_reorder: "write",
|
|
14838
14852
|
video_text_add: "write",
|
|
14839
14853
|
video_image_add: "write",
|
|
@@ -14869,6 +14883,12 @@ var TOOL_TIERS = Object.freeze({
|
|
|
14869
14883
|
// 🔴 Insertion appends, so it never passes through the overwrite prompt; the
|
|
14870
14884
|
// tier is the only barrier, and the user approves each image's source.
|
|
14871
14885
|
editor_insert_image: "destructive",
|
|
14886
|
+
// 🔴 destructive, and one confirm covers the whole plan on purpose. What the
|
|
14887
|
+
// user approves is "make the post look like this", not each keystroke inside
|
|
14888
|
+
// it — and asking per step would defeat the unattended sequence this exists
|
|
14889
|
+
// for. Reach is the five document-assembly steps; the runner refuses anything
|
|
14890
|
+
// else.
|
|
14891
|
+
editor_apply_manifest: "destructive",
|
|
14872
14892
|
editor_set_title: "write",
|
|
14873
14893
|
editor_undo: "write",
|
|
14874
14894
|
editor_replace: "destructive"
|
|
@@ -14940,7 +14960,14 @@ var REASON_POLICY = Object.freeze({
|
|
|
14940
14960
|
editor_busy: Object.freeze({ retryable: false }),
|
|
14941
14961
|
// --- The connection itself must be repaired ---
|
|
14942
14962
|
not_connected: Object.freeze({ retryable: false }),
|
|
14943
|
-
unauthorized: Object.freeze({ retryable: false })
|
|
14963
|
+
unauthorized: Object.freeze({ retryable: false }),
|
|
14964
|
+
// --- Staging: the request must change, except where nobody knows yet ---
|
|
14965
|
+
stale_fence: Object.freeze({ retryable: false }),
|
|
14966
|
+
already_sealed: Object.freeze({ retryable: false }),
|
|
14967
|
+
hash_mismatch: Object.freeze({ retryable: false }),
|
|
14968
|
+
upload_expired: Object.freeze({ retryable: false }),
|
|
14969
|
+
capacity_unavailable: Object.freeze({ retryable: true }),
|
|
14970
|
+
uploads_unproven: Object.freeze({ retryable: true })
|
|
14944
14971
|
});
|
|
14945
14972
|
function policyFor(reason) {
|
|
14946
14973
|
return Object.hasOwn(REASON_POLICY, reason) ? REASON_POLICY[reason] : { retryable: false };
|
|
@@ -15066,6 +15093,9 @@ var EDITOR_CONTROL = [
|
|
|
15066
15093
|
// names the tool to use instead when the body is occupied.
|
|
15067
15094
|
"editor_place_draft",
|
|
15068
15095
|
"editor_set_title",
|
|
15096
|
+
// The whole plan in one call, for a run nobody is watching. Same group as the
|
|
15097
|
+
// steps it contains — a model that reached for those should see this too.
|
|
15098
|
+
"editor_apply_manifest",
|
|
15069
15099
|
// Both act on the open draft: title_optimize proposes titles for it, and
|
|
15070
15100
|
// internal_links reads it.
|
|
15071
15101
|
"title_optimize",
|
|
@@ -15317,7 +15347,7 @@ function discoveryDescriptors(entries) {
|
|
|
15317
15347
|
function sessionStateDescriptor() {
|
|
15318
15348
|
return {
|
|
15319
15349
|
name: SESSION_STATE_TOOL,
|
|
15320
|
-
description: "\uC9C0\uAE08 \uC774 \uBE0C\uB77C\uC6B0\uC800\uC5D0\uC11C \uD655\uC778 \uCC3D \uC5C6\uC774 \uC5BC\uB9C8\uB098 \uB354 \uC791\uC5C5\uD560 \uC218 \uC788\uB294\uC9C0 \uC54C\uB824\uC900\uB2E4. \uC5EC\uB7EC \uBC88\uC758 \uD3B8\uC9D1\uC774\uB098 \uBC30\uCE58\uB97C \uC2DC\uC791\uD558\uAE30 \uC804\uC5D0 \uBA3C\uC800 \uBD80\uB978\uB2E4 \u2014 \uB0A8\uC740 \uC2DC\uAC04\uC774 \uC9E7\uC73C\uBA74 \uB3C4\uC911\uC5D0 \uD655\uC778 \uCC3D\uC774 \uB728\uAE30 \uC2DC\uC791\uD558\uACE0, \uC0AC\uC6A9\uC790\uAC00 \uC790\uB9AC\uC5D0 \uC5C6\uC73C\uBA74 \uAC70\uAE30\uC11C \uBA48\uCD98\uB2E4.",
|
|
15350
|
+
description: "\uC9C0\uAE08 \uC774 \uBE0C\uB77C\uC6B0\uC800\uC5D0\uC11C \uD655\uC778 \uCC3D \uC5C6\uC774 \uC5BC\uB9C8\uB098 \uB354 \uC791\uC5C5\uD560 \uC218 \uC788\uB294\uC9C0, \uADF8\uB9AC\uACE0 \uC791\uC5C5\uD560 \uB300\uC0C1\uC774 \uC2E4\uC81C\uB85C \uC5F4\uB824 \uC788\uB294\uC9C0 \uC54C\uB824\uC900\uB2E4. \uC5EC\uB7EC \uBC88\uC758 \uD3B8\uC9D1\uC774\uB098 \uBC30\uCE58\uB97C \uC2DC\uC791\uD558\uAE30 \uC804\uC5D0 \uBA3C\uC800 \uBD80\uB978\uB2E4 \u2014 \uB0A8\uC740 \uC2DC\uAC04\uC774 \uC9E7\uC73C\uBA74 \uB3C4\uC911\uC5D0 \uD655\uC778 \uCC3D\uC774 \uB728\uAE30 \uC2DC\uC791\uD558\uACE0, \uC0AC\uC6A9\uC790\uAC00 \uC790\uB9AC\uC5D0 \uC5C6\uC73C\uBA74 \uAC70\uAE30\uC11C \uBA48\uCD98\uB2E4. surfaces \uB294 \uAE00\uC4F0\uAE30 \uCC3D\xB7\uC0AC\uC9C4 \uD3B8\uC9D1\uAE30\xB7\uC601\uC0C1 \uD3B8\uC9D1\uAE30\uAC00 \uAC01\uAC01 \uC900\uBE44\uB410\uB294\uC9C0 \uB9D0\uD574\uC900\uB2E4. ready \uAC00 \uC544\uB2CC \uD45C\uBA74\uC744 \uC4F0\uB294 \uACC4\uD68D\uC740 \uB9E4 \uD638\uCD9C\uC774 \uC2E4\uD328\uD558\uB2C8, \uACC4\uD68D\uC744 \uC138\uC6B0\uAE30 \uC804\uC5D0 \uD655\uC778\uD558\uACE0 \uD544\uC694\uD558\uBA74 \uC0AC\uC6A9\uC790\uC5D0\uAC8C \uC5F4\uC5B4 \uB2EC\uB77C\uACE0 \uC548\uB0B4\uD55C\uB2E4.",
|
|
15321
15351
|
inputSchema: {
|
|
15322
15352
|
type: "object",
|
|
15323
15353
|
properties: {},
|
|
@@ -15632,12 +15662,17 @@ var Bridge = class {
|
|
|
15632
15662
|
return;
|
|
15633
15663
|
}
|
|
15634
15664
|
if (frame.ok) {
|
|
15635
|
-
this.#pending.settle(frame.id, {
|
|
15665
|
+
this.#pending.settle(frame.id, {
|
|
15666
|
+
ok: true,
|
|
15667
|
+
result: frame.result,
|
|
15668
|
+
...frame.ms === void 0 ? {} : { ms: frame.ms }
|
|
15669
|
+
});
|
|
15636
15670
|
} else {
|
|
15637
15671
|
this.#pending.settle(frame.id, {
|
|
15638
15672
|
ok: false,
|
|
15639
15673
|
reason: frame.reason,
|
|
15640
|
-
message: frame.message
|
|
15674
|
+
message: frame.message,
|
|
15675
|
+
...frame.ms === void 0 ? {} : { ms: frame.ms }
|
|
15641
15676
|
});
|
|
15642
15677
|
}
|
|
15643
15678
|
}
|
|
@@ -15675,15 +15710,33 @@ var Bridge = class {
|
|
|
15675
15710
|
}
|
|
15676
15711
|
return { tools, rejected: rejected.map((r) => r.name) };
|
|
15677
15712
|
}
|
|
15678
|
-
/**
|
|
15713
|
+
/**
|
|
15714
|
+
* Invoke a tool by name. The server never inspects or executes it.
|
|
15715
|
+
*
|
|
15716
|
+
* 🔴 Returns timing beside the result rather than folded into it. `toolMs` is
|
|
15717
|
+
* what the panel spent executing; `bridgeMs` is this whole round trip, so
|
|
15718
|
+
* `bridgeMs - toolMs` is the transport and the queue. A single total cannot
|
|
15719
|
+
* tell a slow tool from a slow wire, and that is the question being asked.
|
|
15720
|
+
*/
|
|
15679
15721
|
async callTool(name, args) {
|
|
15722
|
+
const startedAt = (this.#deps.now ?? Date.now)();
|
|
15680
15723
|
const out = await this.#request({
|
|
15681
15724
|
method: "tools/call",
|
|
15682
15725
|
name,
|
|
15683
15726
|
args
|
|
15684
15727
|
});
|
|
15685
|
-
|
|
15686
|
-
|
|
15728
|
+
const bridgeMs = (this.#deps.now ?? Date.now)() - startedAt;
|
|
15729
|
+
if (!out.ok) {
|
|
15730
|
+
throw new BridgeError(out.reason, out.message, {
|
|
15731
|
+
...out.ms === void 0 ? {} : { toolMs: out.ms },
|
|
15732
|
+
bridgeMs
|
|
15733
|
+
});
|
|
15734
|
+
}
|
|
15735
|
+
return {
|
|
15736
|
+
result: out.result,
|
|
15737
|
+
...out.ms === void 0 ? {} : { toolMs: out.ms },
|
|
15738
|
+
bridgeMs
|
|
15739
|
+
};
|
|
15687
15740
|
}
|
|
15688
15741
|
/**
|
|
15689
15742
|
* Refill-then-take on the session's token bucket. The refill is computed
|
|
@@ -15739,12 +15792,360 @@ var Bridge = class {
|
|
|
15739
15792
|
};
|
|
15740
15793
|
var BridgeError = class extends Error {
|
|
15741
15794
|
reason;
|
|
15742
|
-
|
|
15795
|
+
/** Optional so every existing throw site still compiles unchanged. */
|
|
15796
|
+
timing;
|
|
15797
|
+
constructor(reason, message, timing) {
|
|
15743
15798
|
super(message);
|
|
15744
15799
|
this.name = "BridgeError";
|
|
15745
15800
|
this.reason = reason;
|
|
15801
|
+
if (timing) this.timing = timing;
|
|
15802
|
+
}
|
|
15803
|
+
};
|
|
15804
|
+
var MAX_STAGE_BYTES = 10 * 1024 * 1024;
|
|
15805
|
+
var DEFAULT_TOKEN_TTL_MS = 30 * 60 * 1e3;
|
|
15806
|
+
var STAGE_CAPABILITY = "datalab-mcp-stage-v1";
|
|
15807
|
+
function refuse(reason, retryable, message) {
|
|
15808
|
+
return { state: "REFUSED", reason, retryable, message };
|
|
15809
|
+
}
|
|
15810
|
+
function segment(...parts) {
|
|
15811
|
+
return createHash("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
15812
|
+
}
|
|
15813
|
+
function createMediaStage(opts) {
|
|
15814
|
+
const now = opts.now ?? Date.now;
|
|
15815
|
+
const ttl = opts.tokenTtlMs ?? DEFAULT_TOKEN_TTL_MS;
|
|
15816
|
+
const ledgerDir = join(opts.root, "ledger");
|
|
15817
|
+
const blobDir = join(opts.root, "blob");
|
|
15818
|
+
const tokens = /* @__PURE__ */ new Map();
|
|
15819
|
+
const active = /* @__PURE__ */ new Map();
|
|
15820
|
+
const keyOf = (j) => segment(j.blogId, j.runId, j.actionId, j.jobId);
|
|
15821
|
+
const ledgerPath = (key) => join(ledgerDir, `${key}.json`);
|
|
15822
|
+
const blobPath = (key) => join(blobDir, key);
|
|
15823
|
+
async function readRow(key) {
|
|
15824
|
+
try {
|
|
15825
|
+
const raw = await readFile(ledgerPath(key), "utf8");
|
|
15826
|
+
return JSON.parse(raw);
|
|
15827
|
+
} catch (err) {
|
|
15828
|
+
if (err.code === "ENOENT") return null;
|
|
15829
|
+
return "unreadable";
|
|
15830
|
+
}
|
|
15746
15831
|
}
|
|
15747
|
-
|
|
15832
|
+
async function writeRow(key, row) {
|
|
15833
|
+
await mkdir(ledgerDir, { recursive: true });
|
|
15834
|
+
await writeFile(ledgerPath(key), JSON.stringify(row), "utf8");
|
|
15835
|
+
}
|
|
15836
|
+
return {
|
|
15837
|
+
async begin(req) {
|
|
15838
|
+
const key = keyOf(req);
|
|
15839
|
+
const row = await readRow(key);
|
|
15840
|
+
if (row === "unreadable") {
|
|
15841
|
+
return refuse("uploads_unproven", true, "\uC791\uC5C5 \uC0C1\uD0DC\uB97C \uC77D\uC9C0 \uBABB\uD588\uC5B4\uC694.");
|
|
15842
|
+
}
|
|
15843
|
+
if (row) {
|
|
15844
|
+
if (req.fence < row.fence) {
|
|
15845
|
+
return refuse(
|
|
15846
|
+
"stale_fence",
|
|
15847
|
+
false,
|
|
15848
|
+
"\uB354 \uC0C8\uB85C\uC6B4 \uC2DC\uB3C4\uAC00 \uC774\uBBF8 \uC9C4\uD589\uB410\uC5B4\uC694."
|
|
15849
|
+
);
|
|
15850
|
+
}
|
|
15851
|
+
if (row.state === "SEALED") {
|
|
15852
|
+
return refuse("already_sealed", false, "\uC774\uBBF8 \uBD09\uC778\uB41C \uC790\uC0B0\uC774\uC5D0\uC694.");
|
|
15853
|
+
}
|
|
15854
|
+
if (row.state === "OPEN") {
|
|
15855
|
+
for (const [token2, held] of tokens) {
|
|
15856
|
+
if (held.key === key && held.expiresAt > now()) {
|
|
15857
|
+
return {
|
|
15858
|
+
state: "OPEN",
|
|
15859
|
+
jobId: req.jobId,
|
|
15860
|
+
uploadToken: token2,
|
|
15861
|
+
expiresAt: held.expiresAt,
|
|
15862
|
+
capabilityVersion: STAGE_CAPABILITY
|
|
15863
|
+
};
|
|
15864
|
+
}
|
|
15865
|
+
}
|
|
15866
|
+
}
|
|
15867
|
+
}
|
|
15868
|
+
const token = randomUUID();
|
|
15869
|
+
const expiresAt = now() + ttl;
|
|
15870
|
+
tokens.set(token, { key, expiresAt });
|
|
15871
|
+
await writeRow(key, {
|
|
15872
|
+
state: "OPEN",
|
|
15873
|
+
fence: req.fence,
|
|
15874
|
+
jobId: req.jobId,
|
|
15875
|
+
at: now()
|
|
15876
|
+
});
|
|
15877
|
+
return {
|
|
15878
|
+
state: "OPEN",
|
|
15879
|
+
jobId: req.jobId,
|
|
15880
|
+
uploadToken: token,
|
|
15881
|
+
expiresAt,
|
|
15882
|
+
capabilityVersion: STAGE_CAPABILITY
|
|
15883
|
+
};
|
|
15884
|
+
},
|
|
15885
|
+
async receiveUpload(token, body) {
|
|
15886
|
+
const held = tokens.get(token);
|
|
15887
|
+
if (!held) return { ok: false, reason: "upload_expired" };
|
|
15888
|
+
if (held.expiresAt <= now()) {
|
|
15889
|
+
tokens.delete(token);
|
|
15890
|
+
return { ok: false, reason: "upload_expired" };
|
|
15891
|
+
}
|
|
15892
|
+
active.set(held.key, (active.get(held.key) ?? 0) + 1);
|
|
15893
|
+
try {
|
|
15894
|
+
await mkdir(blobDir, { recursive: true });
|
|
15895
|
+
const chunks = [];
|
|
15896
|
+
let total = 0;
|
|
15897
|
+
for await (const chunk of body) {
|
|
15898
|
+
const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
15899
|
+
total += buf.byteLength;
|
|
15900
|
+
if (total > MAX_STAGE_BYTES) {
|
|
15901
|
+
return { ok: false, reason: "too_large" };
|
|
15902
|
+
}
|
|
15903
|
+
chunks.push(buf);
|
|
15904
|
+
}
|
|
15905
|
+
await writeFile(blobPath(held.key), Buffer.concat(chunks));
|
|
15906
|
+
return { ok: true, bytes: total };
|
|
15907
|
+
} finally {
|
|
15908
|
+
const left = (active.get(held.key) ?? 1) - 1;
|
|
15909
|
+
if (left <= 0) active.delete(held.key);
|
|
15910
|
+
else active.set(held.key, left);
|
|
15911
|
+
}
|
|
15912
|
+
},
|
|
15913
|
+
async commit(req) {
|
|
15914
|
+
const key = keyOf(req);
|
|
15915
|
+
const row = await readRow(key);
|
|
15916
|
+
if (row === "unreadable") {
|
|
15917
|
+
return refuse("uploads_unproven", true, "\uC791\uC5C5 \uC0C1\uD0DC\uB97C \uC77D\uC9C0 \uBABB\uD588\uC5B4\uC694.");
|
|
15918
|
+
}
|
|
15919
|
+
if (!row) return refuse("upload_expired", false, "\uC5F4\uB9B0 \uC790\uB9AC\uAC00 \uC5C6\uC5B4\uC694.");
|
|
15920
|
+
if (req.fence < row.fence) {
|
|
15921
|
+
return refuse(
|
|
15922
|
+
"stale_fence",
|
|
15923
|
+
false,
|
|
15924
|
+
"\uB354 \uC0C8\uB85C\uC6B4 \uC2DC\uB3C4\uAC00 \uC774\uBBF8 \uC9C4\uD589\uB410\uC5B4\uC694."
|
|
15925
|
+
);
|
|
15926
|
+
}
|
|
15927
|
+
if (row.state === "SEALED") {
|
|
15928
|
+
if (row.sha256 === req.sha256 && row.handle) {
|
|
15929
|
+
return {
|
|
15930
|
+
state: "SEALED",
|
|
15931
|
+
handle: row.handle,
|
|
15932
|
+
bytes: row.bytes ?? 0,
|
|
15933
|
+
sha256: row.sha256,
|
|
15934
|
+
capabilityVersion: STAGE_CAPABILITY
|
|
15935
|
+
};
|
|
15936
|
+
}
|
|
15937
|
+
return refuse("already_sealed", false, "\uC774\uBBF8 \uBD09\uC778\uB41C \uC790\uC0B0\uC774\uC5D0\uC694.");
|
|
15938
|
+
}
|
|
15939
|
+
let received;
|
|
15940
|
+
try {
|
|
15941
|
+
received = await readFile(blobPath(key));
|
|
15942
|
+
} catch {
|
|
15943
|
+
return refuse("upload_expired", false, "\uBC1B\uC740 \uBC14\uC774\uD2B8\uAC00 \uC5C6\uC5B4\uC694.");
|
|
15944
|
+
}
|
|
15945
|
+
const actual = createHash("sha256").update(received).digest("hex");
|
|
15946
|
+
if (actual !== req.sha256 || received.byteLength !== req.bytes) {
|
|
15947
|
+
return refuse(
|
|
15948
|
+
"hash_mismatch",
|
|
15949
|
+
false,
|
|
15950
|
+
"\uBC1B\uC740 \uBC14\uC774\uD2B8\uAC00 \uC54C\uB824\uC8FC\uC2E0 \uAC83\uACFC \uB2EC\uB77C\uC694."
|
|
15951
|
+
);
|
|
15952
|
+
}
|
|
15953
|
+
const handle = `stage:${key}`;
|
|
15954
|
+
await writeRow(key, {
|
|
15955
|
+
state: "SEALED",
|
|
15956
|
+
fence: req.fence,
|
|
15957
|
+
jobId: req.jobId,
|
|
15958
|
+
sha256: actual,
|
|
15959
|
+
bytes: received.byteLength,
|
|
15960
|
+
handle,
|
|
15961
|
+
at: now()
|
|
15962
|
+
});
|
|
15963
|
+
return {
|
|
15964
|
+
state: "SEALED",
|
|
15965
|
+
handle,
|
|
15966
|
+
bytes: received.byteLength,
|
|
15967
|
+
sha256: actual,
|
|
15968
|
+
capabilityVersion: STAGE_CAPABILITY
|
|
15969
|
+
};
|
|
15970
|
+
},
|
|
15971
|
+
async status(req) {
|
|
15972
|
+
const key = keyOf(req);
|
|
15973
|
+
const row = await readRow(key);
|
|
15974
|
+
const base = {
|
|
15975
|
+
jobId: req.jobId,
|
|
15976
|
+
activeUploads: active.get(key) ?? 0,
|
|
15977
|
+
capabilityVersion: STAGE_CAPABILITY
|
|
15978
|
+
};
|
|
15979
|
+
if (row === "unreadable") {
|
|
15980
|
+
return { ...base, state: "STATE_UNKNOWN", bytesReceived: 0 };
|
|
15981
|
+
}
|
|
15982
|
+
let bytesReceived = 0;
|
|
15983
|
+
try {
|
|
15984
|
+
bytesReceived = (await readFile(blobPath(key))).byteLength;
|
|
15985
|
+
} catch {
|
|
15986
|
+
bytesReceived = 0;
|
|
15987
|
+
}
|
|
15988
|
+
if (!row) return { ...base, state: "STATE_UNKNOWN", bytesReceived };
|
|
15989
|
+
return { ...base, state: row.state, bytesReceived };
|
|
15990
|
+
},
|
|
15991
|
+
async cancel(req) {
|
|
15992
|
+
const key = keyOf(req);
|
|
15993
|
+
const row = await readRow(key);
|
|
15994
|
+
if (row === "unreadable") {
|
|
15995
|
+
return {
|
|
15996
|
+
state: "STATE_UNKNOWN",
|
|
15997
|
+
reason: "uploads_unproven",
|
|
15998
|
+
retryable: true
|
|
15999
|
+
};
|
|
16000
|
+
}
|
|
16001
|
+
if (row?.state === "SEALED") {
|
|
16002
|
+
return refuse("already_sealed", false, "\uC774\uBBF8 \uBD09\uC778\uB41C \uC790\uC0B0\uC774\uC5D0\uC694.");
|
|
16003
|
+
}
|
|
16004
|
+
if ((active.get(key) ?? 0) > 0) {
|
|
16005
|
+
return {
|
|
16006
|
+
state: "STATE_UNKNOWN",
|
|
16007
|
+
reason: "uploads_unproven",
|
|
16008
|
+
retryable: true
|
|
16009
|
+
};
|
|
16010
|
+
}
|
|
16011
|
+
await writeRow(key, {
|
|
16012
|
+
state: "CANCELLED",
|
|
16013
|
+
fence: req.fence,
|
|
16014
|
+
jobId: req.jobId,
|
|
16015
|
+
at: now()
|
|
16016
|
+
});
|
|
16017
|
+
await rm(blobPath(key), { force: true });
|
|
16018
|
+
return {
|
|
16019
|
+
state: "CANCELLED",
|
|
16020
|
+
activeUploads: 0,
|
|
16021
|
+
capabilityVersion: STAGE_CAPABILITY
|
|
16022
|
+
};
|
|
16023
|
+
},
|
|
16024
|
+
async readSealed(handle) {
|
|
16025
|
+
return readFile(blobPath(handle.replace(/^stage:/, "")));
|
|
16026
|
+
},
|
|
16027
|
+
async assetCount() {
|
|
16028
|
+
try {
|
|
16029
|
+
return (await readdir(blobDir)).length;
|
|
16030
|
+
} catch {
|
|
16031
|
+
return 0;
|
|
16032
|
+
}
|
|
16033
|
+
},
|
|
16034
|
+
async debugWrittenPaths() {
|
|
16035
|
+
const out = [];
|
|
16036
|
+
for (const dir of [ledgerDir, blobDir]) {
|
|
16037
|
+
try {
|
|
16038
|
+
for (const name of await readdir(dir)) out.push(join(dir, name));
|
|
16039
|
+
} catch {
|
|
16040
|
+
}
|
|
16041
|
+
}
|
|
16042
|
+
return out;
|
|
16043
|
+
}
|
|
16044
|
+
};
|
|
16045
|
+
}
|
|
16046
|
+
var MEDIA_TOOL_NAMES = [
|
|
16047
|
+
"media_stage_begin",
|
|
16048
|
+
"media_stage_commit",
|
|
16049
|
+
"media_stage_status",
|
|
16050
|
+
"media_stage_cancel"
|
|
16051
|
+
];
|
|
16052
|
+
function isMediaTool(name) {
|
|
16053
|
+
return MEDIA_TOOL_NAMES.includes(name);
|
|
16054
|
+
}
|
|
16055
|
+
var JOB_PROPERTIES = {
|
|
16056
|
+
blogId: { type: "string" },
|
|
16057
|
+
runId: { type: "string" },
|
|
16058
|
+
slot: { type: "string" },
|
|
16059
|
+
actionId: { type: "string" },
|
|
16060
|
+
fence: { type: "integer", description: "\uC2DC\uB3C4 \uBC88\uD638. \uD074\uC218\uB85D \uC0C8\uAC83" },
|
|
16061
|
+
jobId: { type: "string", description: "\uC790\uC0B0 \uD558\uB098\uC758 \uC2DD\uBCC4\uC790" }
|
|
16062
|
+
};
|
|
16063
|
+
var JOB_REQUIRED = [
|
|
16064
|
+
"blogId",
|
|
16065
|
+
"runId",
|
|
16066
|
+
"slot",
|
|
16067
|
+
"actionId",
|
|
16068
|
+
"fence",
|
|
16069
|
+
"jobId"
|
|
16070
|
+
];
|
|
16071
|
+
var schema = (extra = {}, more = []) => ({
|
|
16072
|
+
type: "object",
|
|
16073
|
+
properties: { ...JOB_PROPERTIES, ...extra },
|
|
16074
|
+
required: [...JOB_REQUIRED, ...more],
|
|
16075
|
+
additionalProperties: false
|
|
16076
|
+
});
|
|
16077
|
+
function mediaToolDescriptors() {
|
|
16078
|
+
return [
|
|
16079
|
+
{
|
|
16080
|
+
name: "media_stage_begin",
|
|
16081
|
+
description: "\uC774\uBBF8\uC9C0\uB97C \uC62C\uB9B4 \uC790\uB9AC\uB97C \uC5F0\uB2E4. \uBC14\uC774\uD2B8\uB294 \uC5EC\uAE30\uB85C \uBCF4\uB0B4\uC9C0 \uC54A\uACE0, \uB3CC\uB824\uBC1B\uC740 uploadUrl \uC5D0 uploadToken \uC744 \uC2E4\uC5B4 \uC2A4\uD2B8\uB9BC\uC73C\uB85C \uBCF4\uB0B8\uB2E4. \uAC19\uC740 jobId \uB85C \uB2E4\uC2DC \uBD88\uB7EC\uB3C4 \uC790\uB9AC\uB294 \uD558\uB098\uB2E4.",
|
|
16082
|
+
inputSchema: schema(
|
|
16083
|
+
{
|
|
16084
|
+
declaredBytes: { type: "integer" },
|
|
16085
|
+
declaredMime: { type: "string" }
|
|
16086
|
+
},
|
|
16087
|
+
["declaredBytes"]
|
|
16088
|
+
)
|
|
16089
|
+
},
|
|
16090
|
+
{
|
|
16091
|
+
name: "media_stage_commit",
|
|
16092
|
+
description: "\uC62C\uB9B0 \uBC14\uC774\uD2B8\uB97C \uAC80\uC99D\uD558\uACE0 \uBD09\uC778\uD55C\uB2E4. \uBC1B\uC740 \uAC83\uC774 \uC54C\uB824\uC900 \uD574\uC2DC\xB7\uD06C\uAE30\uC640 \uB2E4\uB974\uBA74 \uBD09\uC778\uD558\uC9C0 \uC54A\uB294\uB2E4. \uAC19\uC740 \uBC14\uC774\uD2B8\uB85C \uB2E4\uC2DC \uBD80\uB974\uBA74 \uAC19\uC740 handle \uC744 \uB3CC\uB824\uC900\uB2E4.",
|
|
16093
|
+
inputSchema: schema(
|
|
16094
|
+
{ sha256: { type: "string" }, bytes: { type: "integer" } },
|
|
16095
|
+
["sha256", "bytes"]
|
|
16096
|
+
)
|
|
16097
|
+
},
|
|
16098
|
+
{
|
|
16099
|
+
name: "media_stage_status",
|
|
16100
|
+
description: "\uC774 \uC790\uC0B0\uC774 \uC9C0\uAE08 \uC5B4\uB5A4 \uC0C1\uD0DC\uC778\uC9C0 \uBB3B\uB294\uB2E4. \uC0C1\uD0DC\uB97C \uD655\uC778\uD560 \uC218 \uC5C6\uC73C\uBA74 STATE_UNKNOWN \uC744 \uB3CC\uB824\uC8FC\uBA70, \uADF8\uAC83\uC740 \uC2E4\uD328\uAC00 \uC544\uB2C8\uB77C \uBAA8\uB978\uB2E4\uB294 \uB73B\uC774\uB2E4.",
|
|
16101
|
+
inputSchema: schema()
|
|
16102
|
+
},
|
|
16103
|
+
{
|
|
16104
|
+
name: "media_stage_cancel",
|
|
16105
|
+
description: "\uC790\uB9AC\uB97C \uCDE8\uC18C\uD55C\uB2E4. \uC62C\uB77C\uC624\uB294 \uC911\uC778 \uC2A4\uD2B8\uB9BC\uC774 \uBAA8\uB450 \uB2EB\uD614\uC74C\uC744 \uD655\uC778\uD588\uC744 \uB54C\uB9CC \uC131\uACF5\uC774\uACE0, \uD655\uC778\uD558\uC9C0 \uBABB\uD558\uBA74 STATE_UNKNOWN \uC774\uB2E4. \uC774\uBBF8 \uBD09\uC778\uB41C \uAC83\uC740 \uCDE8\uC18C\uB418\uC9C0 \uC54A\uB294\uB2E4.",
|
|
16106
|
+
inputSchema: schema()
|
|
16107
|
+
}
|
|
16108
|
+
];
|
|
16109
|
+
}
|
|
16110
|
+
function jobFrom(args) {
|
|
16111
|
+
const str = (k) => typeof args[k] === "string" && args[k] ? args[k] : null;
|
|
16112
|
+
const blogId = str("blogId");
|
|
16113
|
+
const runId = str("runId");
|
|
16114
|
+
const slot = str("slot");
|
|
16115
|
+
const actionId = str("actionId");
|
|
16116
|
+
const jobId = str("jobId");
|
|
16117
|
+
const fence = args["fence"];
|
|
16118
|
+
if (!blogId || !runId || !slot || !actionId || !jobId) return null;
|
|
16119
|
+
if (typeof fence !== "number" || !Number.isInteger(fence)) return null;
|
|
16120
|
+
return { blogId, runId, slot, actionId, jobId, fence };
|
|
16121
|
+
}
|
|
16122
|
+
async function callMediaTool(stage, name, args) {
|
|
16123
|
+
const job = jobFrom(args);
|
|
16124
|
+
if (!job) {
|
|
16125
|
+
return {
|
|
16126
|
+
state: "REFUSED",
|
|
16127
|
+
reason: "invalid_args",
|
|
16128
|
+
retryable: false,
|
|
16129
|
+
message: "\uC5EC\uC12F \uAC1C \uC2DD\uBCC4\uC790\uAC00 \uBAA8\uB450 \uD544\uC694\uD574\uC694.",
|
|
16130
|
+
capabilityVersion: STAGE_CAPABILITY
|
|
16131
|
+
};
|
|
16132
|
+
}
|
|
16133
|
+
switch (name) {
|
|
16134
|
+
case "media_stage_begin": {
|
|
16135
|
+
const declaredBytes = typeof args["declaredBytes"] === "number" ? args["declaredBytes"] : 0;
|
|
16136
|
+
return stage.begin({ ...job, declaredBytes });
|
|
16137
|
+
}
|
|
16138
|
+
case "media_stage_commit": {
|
|
16139
|
+
const sha256 = typeof args["sha256"] === "string" ? args["sha256"] : "";
|
|
16140
|
+
const bytes = typeof args["bytes"] === "number" ? args["bytes"] : -1;
|
|
16141
|
+
return stage.commit({ ...job, sha256, bytes });
|
|
16142
|
+
}
|
|
16143
|
+
case "media_stage_status":
|
|
16144
|
+
return stage.status(job);
|
|
16145
|
+
case "media_stage_cancel":
|
|
16146
|
+
return stage.cancel(job);
|
|
16147
|
+
}
|
|
16148
|
+
}
|
|
15748
16149
|
var CODE_METHOD_NOT_FOUND = -32601;
|
|
15749
16150
|
var CODE_INVALID_PARAMS = -32602;
|
|
15750
16151
|
var CODE_INTERNAL = -32603;
|
|
@@ -15754,6 +16155,22 @@ function bridgeErrorText(err) {
|
|
|
15754
16155
|
}
|
|
15755
16156
|
return err.message;
|
|
15756
16157
|
}
|
|
16158
|
+
var CAPABILITY = "datalab-mcp-timing-v1";
|
|
16159
|
+
function timingMeta(timing) {
|
|
16160
|
+
return {
|
|
16161
|
+
_meta: {
|
|
16162
|
+
capabilityVersion: CAPABILITY,
|
|
16163
|
+
bridgeMs: timing.bridgeMs,
|
|
16164
|
+
...timing.toolMs === void 0 ? {} : { toolMs: timing.toolMs },
|
|
16165
|
+
// What the wire and the queue cost, which is the whole reason the two
|
|
16166
|
+
// numbers are reported apart.
|
|
16167
|
+
...timing.toolMs === void 0 ? {} : { transportMs: Math.max(0, timing.bridgeMs - timing.toolMs) }
|
|
16168
|
+
}
|
|
16169
|
+
};
|
|
16170
|
+
}
|
|
16171
|
+
function ownTools(stage) {
|
|
16172
|
+
return stage ? mediaToolDescriptors() : [];
|
|
16173
|
+
}
|
|
15757
16174
|
function rpcToolError(id, err) {
|
|
15758
16175
|
const policy = policyFor(err.reason);
|
|
15759
16176
|
const payload = {
|
|
@@ -15765,7 +16182,8 @@ function rpcToolError(id, err) {
|
|
|
15765
16182
|
};
|
|
15766
16183
|
return rpcResult(id, {
|
|
15767
16184
|
content: [{ type: "text", text: JSON.stringify(payload) }],
|
|
15768
|
-
isError: true
|
|
16185
|
+
isError: true,
|
|
16186
|
+
...err.timing ? timingMeta(err.timing) : {}
|
|
15769
16187
|
});
|
|
15770
16188
|
}
|
|
15771
16189
|
function frameMcpResponse(payload, accept) {
|
|
@@ -15802,26 +16220,35 @@ function rpcResult(id, result) {
|
|
|
15802
16220
|
function rpcError(id, code, message) {
|
|
15803
16221
|
return { jsonrpc: "2.0", id: id ?? null, error: { code, message } };
|
|
15804
16222
|
}
|
|
15805
|
-
async function handleMcpRequest(bridge, body, accept) {
|
|
16223
|
+
async function handleMcpRequest(bridge, body, accept, stage) {
|
|
15806
16224
|
const req = typeof body === "object" && body !== null ? body : {};
|
|
15807
16225
|
const id = req.id;
|
|
15808
16226
|
const method = req.method;
|
|
15809
16227
|
if (method === "tools/list") {
|
|
15810
16228
|
if (!bridge.connected) {
|
|
15811
|
-
|
|
16229
|
+
const own = ownTools(stage);
|
|
16230
|
+
if (bridge.lastKnownTools.length === 0 && own.length === 0) {
|
|
16231
|
+
return coldCatalog(id, accept);
|
|
16232
|
+
}
|
|
15812
16233
|
return frameMcpResponse(
|
|
15813
|
-
rpcResult(id, { tools: bridge.lastKnownTools }),
|
|
16234
|
+
rpcResult(id, { tools: [...bridge.lastKnownTools, ...own] }),
|
|
15814
16235
|
accept
|
|
15815
16236
|
);
|
|
15816
16237
|
}
|
|
15817
16238
|
try {
|
|
15818
16239
|
const { tools } = await bridge.listTools();
|
|
15819
|
-
return frameMcpResponse(
|
|
16240
|
+
return frameMcpResponse(
|
|
16241
|
+
rpcResult(id, { tools: [...tools, ...ownTools(stage)] }),
|
|
16242
|
+
accept
|
|
16243
|
+
);
|
|
15820
16244
|
} catch (err) {
|
|
15821
16245
|
if (err instanceof BridgeError) {
|
|
15822
|
-
|
|
16246
|
+
const own = ownTools(stage);
|
|
16247
|
+
if (bridge.lastKnownTools.length === 0 && own.length === 0) {
|
|
16248
|
+
return coldCatalog(id, accept);
|
|
16249
|
+
}
|
|
15823
16250
|
return frameMcpResponse(
|
|
15824
|
-
rpcResult(id, { tools: bridge.lastKnownTools }),
|
|
16251
|
+
rpcResult(id, { tools: [...bridge.lastKnownTools, ...own] }),
|
|
15825
16252
|
accept
|
|
15826
16253
|
);
|
|
15827
16254
|
}
|
|
@@ -15838,11 +16265,26 @@ async function handleMcpRequest(bridge, body, accept) {
|
|
|
15838
16265
|
);
|
|
15839
16266
|
}
|
|
15840
16267
|
const args = typeof params.arguments === "object" && params.arguments !== null ? params.arguments : {};
|
|
16268
|
+
if (stage && isMediaTool(params.name)) {
|
|
16269
|
+
const startedAt = Date.now();
|
|
16270
|
+
const result = await callMediaTool(stage, params.name, args);
|
|
16271
|
+
return frameMcpResponse(
|
|
16272
|
+
rpcResult(id, {
|
|
16273
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
16274
|
+
...timingMeta({
|
|
16275
|
+
toolMs: Date.now() - startedAt,
|
|
16276
|
+
bridgeMs: Date.now() - startedAt
|
|
16277
|
+
})
|
|
16278
|
+
}),
|
|
16279
|
+
accept
|
|
16280
|
+
);
|
|
16281
|
+
}
|
|
15841
16282
|
try {
|
|
15842
|
-
const
|
|
16283
|
+
const call = await bridge.callTool(params.name, args);
|
|
15843
16284
|
return frameMcpResponse(
|
|
15844
16285
|
rpcResult(id, {
|
|
15845
|
-
content: [{ type: "text", text: JSON.stringify(result) }]
|
|
16286
|
+
content: [{ type: "text", text: JSON.stringify(call.result) }],
|
|
16287
|
+
...timingMeta(call)
|
|
15846
16288
|
}),
|
|
15847
16289
|
accept
|
|
15848
16290
|
);
|
|
@@ -16031,11 +16473,23 @@ function createHttpBridge(opts) {
|
|
|
16031
16473
|
const origin = req.headers.origin;
|
|
16032
16474
|
if (req.method === "POST" && url22.pathname === "/mcp") {
|
|
16033
16475
|
lifecycle?.bump?.();
|
|
16034
|
-
void readJson(req, MAX_MCP_BODY_BYTES2).then(
|
|
16476
|
+
void readJson(req, MAX_MCP_BODY_BYTES2).then(
|
|
16477
|
+
(body) => handleMcpRequest(
|
|
16478
|
+
opts.bridge,
|
|
16479
|
+
body,
|
|
16480
|
+
req.headers.accept,
|
|
16481
|
+
opts.mediaStage
|
|
16482
|
+
)
|
|
16483
|
+
).catch(
|
|
16035
16484
|
() => (
|
|
16036
16485
|
// An unparseable or oversized body still owes a JSON-RPC answer, not
|
|
16037
16486
|
// a dropped socket; a null body routes through as method-not-found.
|
|
16038
|
-
handleMcpRequest(
|
|
16487
|
+
handleMcpRequest(
|
|
16488
|
+
opts.bridge,
|
|
16489
|
+
null,
|
|
16490
|
+
req.headers.accept,
|
|
16491
|
+
opts.mediaStage
|
|
16492
|
+
)
|
|
16039
16493
|
)
|
|
16040
16494
|
).then((out) => {
|
|
16041
16495
|
writeSafely(res, out.status, out.headers, out.body);
|
|
@@ -16159,6 +16613,33 @@ function createHttpBridge(opts) {
|
|
|
16159
16613
|
});
|
|
16160
16614
|
return;
|
|
16161
16615
|
}
|
|
16616
|
+
if (req.method === "POST" && url22.pathname === "/media/upload") {
|
|
16617
|
+
const stage = opts.mediaStage;
|
|
16618
|
+
if (!stage) {
|
|
16619
|
+
json2(res, 404, { error: "not found" });
|
|
16620
|
+
return;
|
|
16621
|
+
}
|
|
16622
|
+
const auth = req.headers.authorization ?? "";
|
|
16623
|
+
const token = auth.startsWith("Bearer ") ? auth.slice(7).trim() : "";
|
|
16624
|
+
if (!token) {
|
|
16625
|
+
json2(res, 403, { error: "unauthorized" });
|
|
16626
|
+
return;
|
|
16627
|
+
}
|
|
16628
|
+
void stage.receiveUpload(token, req).then((out) => {
|
|
16629
|
+
if (out.ok) {
|
|
16630
|
+
json2(res, 202, { ok: true, bytes: out.bytes });
|
|
16631
|
+
return;
|
|
16632
|
+
}
|
|
16633
|
+
const status = out.reason === "upload_expired" ? 403 : 400;
|
|
16634
|
+
json2(res, status, { error: out.reason });
|
|
16635
|
+
}).catch((err) => {
|
|
16636
|
+
opts.log?.(
|
|
16637
|
+
`media upload failed: ${err instanceof Error ? err.message : String(err)}`
|
|
16638
|
+
);
|
|
16639
|
+
json2(res, 500, { error: "upload_failed" });
|
|
16640
|
+
});
|
|
16641
|
+
return;
|
|
16642
|
+
}
|
|
16162
16643
|
if (req.method === "POST" && url22.pathname === "/bridge/result") {
|
|
16163
16644
|
if (!opts.bridge.connected) {
|
|
16164
16645
|
json2(res, 403, { error: "handshake required" });
|
|
@@ -16279,10 +16760,10 @@ var LOG_MAX_BYTES = 1024 * 1024;
|
|
|
16279
16760
|
var DIR_NAME = ".datalab-mcp";
|
|
16280
16761
|
var FILE_NAME = "connector.log";
|
|
16281
16762
|
function logDir(home = homedir()) {
|
|
16282
|
-
return
|
|
16763
|
+
return join2(home, DIR_NAME);
|
|
16283
16764
|
}
|
|
16284
16765
|
function logPath(home = homedir()) {
|
|
16285
|
-
return
|
|
16766
|
+
return join2(logDir(home), FILE_NAME);
|
|
16286
16767
|
}
|
|
16287
16768
|
function rolledLogPath(home = homedir()) {
|
|
16288
16769
|
return `${logPath(home)}.1`;
|
|
@@ -16458,10 +16939,12 @@ function runDaemon(env, deps = {}) {
|
|
|
16458
16939
|
rateLimit: deps.rateLimit,
|
|
16459
16940
|
log
|
|
16460
16941
|
});
|
|
16942
|
+
const mediaStage = createMediaStage({ root: join3(logDir(), "media") });
|
|
16461
16943
|
const http = createHttpBridge({
|
|
16462
16944
|
bridge,
|
|
16463
16945
|
port,
|
|
16464
16946
|
host,
|
|
16947
|
+
mediaStage,
|
|
16465
16948
|
heartbeatMs: deps.heartbeatMs,
|
|
16466
16949
|
identity: { name: NAME, version: version22 },
|
|
16467
16950
|
log,
|
|
@@ -17283,8 +17766,8 @@ function mergeDefs2(...defs) {
|
|
|
17283
17766
|
}
|
|
17284
17767
|
return Object.defineProperties({}, mergedDescriptors);
|
|
17285
17768
|
}
|
|
17286
|
-
function cloneDef2(
|
|
17287
|
-
return mergeDefs2(
|
|
17769
|
+
function cloneDef2(schema2) {
|
|
17770
|
+
return mergeDefs2(schema2._zod.def);
|
|
17288
17771
|
}
|
|
17289
17772
|
function getElementAtPath2(obj, path) {
|
|
17290
17773
|
if (!path)
|
|
@@ -17506,14 +17989,14 @@ var BIGINT_FORMAT_RANGES2 = {
|
|
|
17506
17989
|
int64: [/* @__PURE__ */ BigInt("-9223372036854775808"), /* @__PURE__ */ BigInt("9223372036854775807")],
|
|
17507
17990
|
uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")]
|
|
17508
17991
|
};
|
|
17509
|
-
function pick2(
|
|
17510
|
-
const currDef =
|
|
17992
|
+
function pick2(schema2, mask) {
|
|
17993
|
+
const currDef = schema2._zod.def;
|
|
17511
17994
|
const checks = currDef.checks;
|
|
17512
17995
|
const hasChecks = checks && checks.length > 0;
|
|
17513
17996
|
if (hasChecks) {
|
|
17514
17997
|
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
17515
17998
|
}
|
|
17516
|
-
const def = mergeDefs2(
|
|
17999
|
+
const def = mergeDefs2(schema2._zod.def, {
|
|
17517
18000
|
get shape() {
|
|
17518
18001
|
const newShape = {};
|
|
17519
18002
|
for (const key in mask) {
|
|
@@ -17529,18 +18012,18 @@ function pick2(schema, mask) {
|
|
|
17529
18012
|
},
|
|
17530
18013
|
checks: []
|
|
17531
18014
|
});
|
|
17532
|
-
return clone2(
|
|
18015
|
+
return clone2(schema2, def);
|
|
17533
18016
|
}
|
|
17534
|
-
function omit2(
|
|
17535
|
-
const currDef =
|
|
18017
|
+
function omit2(schema2, mask) {
|
|
18018
|
+
const currDef = schema2._zod.def;
|
|
17536
18019
|
const checks = currDef.checks;
|
|
17537
18020
|
const hasChecks = checks && checks.length > 0;
|
|
17538
18021
|
if (hasChecks) {
|
|
17539
18022
|
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
17540
18023
|
}
|
|
17541
|
-
const def = mergeDefs2(
|
|
18024
|
+
const def = mergeDefs2(schema2._zod.def, {
|
|
17542
18025
|
get shape() {
|
|
17543
|
-
const newShape = { ...
|
|
18026
|
+
const newShape = { ...schema2._zod.def.shape };
|
|
17544
18027
|
for (const key in mask) {
|
|
17545
18028
|
if (!(key in currDef.shape)) {
|
|
17546
18029
|
throw new Error(`Unrecognized key: "${key}"`);
|
|
@@ -17554,43 +18037,43 @@ function omit2(schema, mask) {
|
|
|
17554
18037
|
},
|
|
17555
18038
|
checks: []
|
|
17556
18039
|
});
|
|
17557
|
-
return clone2(
|
|
18040
|
+
return clone2(schema2, def);
|
|
17558
18041
|
}
|
|
17559
|
-
function extend2(
|
|
18042
|
+
function extend2(schema2, shape) {
|
|
17560
18043
|
if (!isPlainObject2(shape)) {
|
|
17561
18044
|
throw new Error("Invalid input to extend: expected a plain object");
|
|
17562
18045
|
}
|
|
17563
|
-
const checks =
|
|
18046
|
+
const checks = schema2._zod.def.checks;
|
|
17564
18047
|
const hasChecks = checks && checks.length > 0;
|
|
17565
18048
|
if (hasChecks) {
|
|
17566
|
-
const existingShape =
|
|
18049
|
+
const existingShape = schema2._zod.def.shape;
|
|
17567
18050
|
for (const key in shape) {
|
|
17568
18051
|
if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) {
|
|
17569
18052
|
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
17570
18053
|
}
|
|
17571
18054
|
}
|
|
17572
18055
|
}
|
|
17573
|
-
const def = mergeDefs2(
|
|
18056
|
+
const def = mergeDefs2(schema2._zod.def, {
|
|
17574
18057
|
get shape() {
|
|
17575
|
-
const _shape = { ...
|
|
18058
|
+
const _shape = { ...schema2._zod.def.shape, ...shape };
|
|
17576
18059
|
assignProp2(this, "shape", _shape);
|
|
17577
18060
|
return _shape;
|
|
17578
18061
|
}
|
|
17579
18062
|
});
|
|
17580
|
-
return clone2(
|
|
18063
|
+
return clone2(schema2, def);
|
|
17581
18064
|
}
|
|
17582
|
-
function safeExtend2(
|
|
18065
|
+
function safeExtend2(schema2, shape) {
|
|
17583
18066
|
if (!isPlainObject2(shape)) {
|
|
17584
18067
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
17585
18068
|
}
|
|
17586
|
-
const def = mergeDefs2(
|
|
18069
|
+
const def = mergeDefs2(schema2._zod.def, {
|
|
17587
18070
|
get shape() {
|
|
17588
|
-
const _shape = { ...
|
|
18071
|
+
const _shape = { ...schema2._zod.def.shape, ...shape };
|
|
17589
18072
|
assignProp2(this, "shape", _shape);
|
|
17590
18073
|
return _shape;
|
|
17591
18074
|
}
|
|
17592
18075
|
});
|
|
17593
|
-
return clone2(
|
|
18076
|
+
return clone2(schema2, def);
|
|
17594
18077
|
}
|
|
17595
18078
|
function merge2(a, b) {
|
|
17596
18079
|
if (a._zod.def.checks?.length) {
|
|
@@ -17609,16 +18092,16 @@ function merge2(a, b) {
|
|
|
17609
18092
|
});
|
|
17610
18093
|
return clone2(a, def);
|
|
17611
18094
|
}
|
|
17612
|
-
function partial2(Class3,
|
|
17613
|
-
const currDef =
|
|
18095
|
+
function partial2(Class3, schema2, mask) {
|
|
18096
|
+
const currDef = schema2._zod.def;
|
|
17614
18097
|
const checks = currDef.checks;
|
|
17615
18098
|
const hasChecks = checks && checks.length > 0;
|
|
17616
18099
|
if (hasChecks) {
|
|
17617
18100
|
throw new Error(".partial() cannot be used on object schemas containing refinements");
|
|
17618
18101
|
}
|
|
17619
|
-
const def = mergeDefs2(
|
|
18102
|
+
const def = mergeDefs2(schema2._zod.def, {
|
|
17620
18103
|
get shape() {
|
|
17621
|
-
const oldShape =
|
|
18104
|
+
const oldShape = schema2._zod.def.shape;
|
|
17622
18105
|
const shape = { ...oldShape };
|
|
17623
18106
|
if (mask) {
|
|
17624
18107
|
for (const key in mask) {
|
|
@@ -17645,12 +18128,12 @@ function partial2(Class3, schema, mask) {
|
|
|
17645
18128
|
},
|
|
17646
18129
|
checks: []
|
|
17647
18130
|
});
|
|
17648
|
-
return clone2(
|
|
18131
|
+
return clone2(schema2, def);
|
|
17649
18132
|
}
|
|
17650
|
-
function required2(Class3,
|
|
17651
|
-
const def = mergeDefs2(
|
|
18133
|
+
function required2(Class3, schema2, mask) {
|
|
18134
|
+
const def = mergeDefs2(schema2._zod.def, {
|
|
17652
18135
|
get shape() {
|
|
17653
|
-
const oldShape =
|
|
18136
|
+
const oldShape = schema2._zod.def.shape;
|
|
17654
18137
|
const shape = { ...oldShape };
|
|
17655
18138
|
if (mask) {
|
|
17656
18139
|
for (const key in mask) {
|
|
@@ -17676,7 +18159,7 @@ function required2(Class3, schema, mask) {
|
|
|
17676
18159
|
return shape;
|
|
17677
18160
|
}
|
|
17678
18161
|
});
|
|
17679
|
-
return clone2(
|
|
18162
|
+
return clone2(schema2, def);
|
|
17680
18163
|
}
|
|
17681
18164
|
function aborted2(x, startIndex = 0) {
|
|
17682
18165
|
if (x.aborted === true)
|
|
@@ -17955,9 +18438,9 @@ function prettifyError2(error101) {
|
|
|
17955
18438
|
}
|
|
17956
18439
|
|
|
17957
18440
|
// ../node_modules/zod/v4/core/parse.js
|
|
17958
|
-
var _parse2 = (_Err) => (
|
|
18441
|
+
var _parse2 = (_Err) => (schema2, value, _ctx, _params) => {
|
|
17959
18442
|
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
17960
|
-
const result =
|
|
18443
|
+
const result = schema2._zod.run({ value, issues: [] }, ctx);
|
|
17961
18444
|
if (result instanceof Promise) {
|
|
17962
18445
|
throw new $ZodAsyncError2();
|
|
17963
18446
|
}
|
|
@@ -17969,9 +18452,9 @@ var _parse2 = (_Err) => (schema, value, _ctx, _params) => {
|
|
|
17969
18452
|
return result.value;
|
|
17970
18453
|
};
|
|
17971
18454
|
var parse3 = /* @__PURE__ */ _parse2($ZodRealError2);
|
|
17972
|
-
var _parseAsync2 = (_Err) => async (
|
|
18455
|
+
var _parseAsync2 = (_Err) => async (schema2, value, _ctx, params) => {
|
|
17973
18456
|
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
17974
|
-
let result =
|
|
18457
|
+
let result = schema2._zod.run({ value, issues: [] }, ctx);
|
|
17975
18458
|
if (result instanceof Promise)
|
|
17976
18459
|
result = await result;
|
|
17977
18460
|
if (result.issues.length) {
|
|
@@ -17982,9 +18465,9 @@ var _parseAsync2 = (_Err) => async (schema, value, _ctx, params) => {
|
|
|
17982
18465
|
return result.value;
|
|
17983
18466
|
};
|
|
17984
18467
|
var parseAsync3 = /* @__PURE__ */ _parseAsync2($ZodRealError2);
|
|
17985
|
-
var _safeParse2 = (_Err) => (
|
|
18468
|
+
var _safeParse2 = (_Err) => (schema2, value, _ctx) => {
|
|
17986
18469
|
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
17987
|
-
const result =
|
|
18470
|
+
const result = schema2._zod.run({ value, issues: [] }, ctx);
|
|
17988
18471
|
if (result instanceof Promise) {
|
|
17989
18472
|
throw new $ZodAsyncError2();
|
|
17990
18473
|
}
|
|
@@ -17994,9 +18477,9 @@ var _safeParse2 = (_Err) => (schema, value, _ctx) => {
|
|
|
17994
18477
|
} : { success: true, data: result.value };
|
|
17995
18478
|
};
|
|
17996
18479
|
var safeParse3 = /* @__PURE__ */ _safeParse2($ZodRealError2);
|
|
17997
|
-
var _safeParseAsync2 = (_Err) => async (
|
|
18480
|
+
var _safeParseAsync2 = (_Err) => async (schema2, value, _ctx) => {
|
|
17998
18481
|
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
17999
|
-
let result =
|
|
18482
|
+
let result = schema2._zod.run({ value, issues: [] }, ctx);
|
|
18000
18483
|
if (result instanceof Promise)
|
|
18001
18484
|
result = await result;
|
|
18002
18485
|
return result.issues.length ? {
|
|
@@ -18005,40 +18488,40 @@ var _safeParseAsync2 = (_Err) => async (schema, value, _ctx) => {
|
|
|
18005
18488
|
} : { success: true, data: result.value };
|
|
18006
18489
|
};
|
|
18007
18490
|
var safeParseAsync3 = /* @__PURE__ */ _safeParseAsync2($ZodRealError2);
|
|
18008
|
-
var _encode2 = (_Err) => (
|
|
18491
|
+
var _encode2 = (_Err) => (schema2, value, _ctx) => {
|
|
18009
18492
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
18010
|
-
return _parse2(_Err)(
|
|
18493
|
+
return _parse2(_Err)(schema2, value, ctx);
|
|
18011
18494
|
};
|
|
18012
18495
|
var encode3 = /* @__PURE__ */ _encode2($ZodRealError2);
|
|
18013
|
-
var _decode2 = (_Err) => (
|
|
18014
|
-
return _parse2(_Err)(
|
|
18496
|
+
var _decode2 = (_Err) => (schema2, value, _ctx) => {
|
|
18497
|
+
return _parse2(_Err)(schema2, value, _ctx);
|
|
18015
18498
|
};
|
|
18016
18499
|
var decode3 = /* @__PURE__ */ _decode2($ZodRealError2);
|
|
18017
|
-
var _encodeAsync2 = (_Err) => async (
|
|
18500
|
+
var _encodeAsync2 = (_Err) => async (schema2, value, _ctx) => {
|
|
18018
18501
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
18019
|
-
return _parseAsync2(_Err)(
|
|
18502
|
+
return _parseAsync2(_Err)(schema2, value, ctx);
|
|
18020
18503
|
};
|
|
18021
18504
|
var encodeAsync3 = /* @__PURE__ */ _encodeAsync2($ZodRealError2);
|
|
18022
|
-
var _decodeAsync2 = (_Err) => async (
|
|
18023
|
-
return _parseAsync2(_Err)(
|
|
18505
|
+
var _decodeAsync2 = (_Err) => async (schema2, value, _ctx) => {
|
|
18506
|
+
return _parseAsync2(_Err)(schema2, value, _ctx);
|
|
18024
18507
|
};
|
|
18025
18508
|
var decodeAsync3 = /* @__PURE__ */ _decodeAsync2($ZodRealError2);
|
|
18026
|
-
var _safeEncode2 = (_Err) => (
|
|
18509
|
+
var _safeEncode2 = (_Err) => (schema2, value, _ctx) => {
|
|
18027
18510
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
18028
|
-
return _safeParse2(_Err)(
|
|
18511
|
+
return _safeParse2(_Err)(schema2, value, ctx);
|
|
18029
18512
|
};
|
|
18030
18513
|
var safeEncode3 = /* @__PURE__ */ _safeEncode2($ZodRealError2);
|
|
18031
|
-
var _safeDecode2 = (_Err) => (
|
|
18032
|
-
return _safeParse2(_Err)(
|
|
18514
|
+
var _safeDecode2 = (_Err) => (schema2, value, _ctx) => {
|
|
18515
|
+
return _safeParse2(_Err)(schema2, value, _ctx);
|
|
18033
18516
|
};
|
|
18034
18517
|
var safeDecode3 = /* @__PURE__ */ _safeDecode2($ZodRealError2);
|
|
18035
|
-
var _safeEncodeAsync2 = (_Err) => async (
|
|
18518
|
+
var _safeEncodeAsync2 = (_Err) => async (schema2, value, _ctx) => {
|
|
18036
18519
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
18037
|
-
return _safeParseAsync2(_Err)(
|
|
18520
|
+
return _safeParseAsync2(_Err)(schema2, value, ctx);
|
|
18038
18521
|
};
|
|
18039
18522
|
var safeEncodeAsync3 = /* @__PURE__ */ _safeEncodeAsync2($ZodRealError2);
|
|
18040
|
-
var _safeDecodeAsync2 = (_Err) => async (
|
|
18041
|
-
return _safeParseAsync2(_Err)(
|
|
18523
|
+
var _safeDecodeAsync2 = (_Err) => async (schema2, value, _ctx) => {
|
|
18524
|
+
return _safeParseAsync2(_Err)(schema2, value, _ctx);
|
|
18042
18525
|
};
|
|
18043
18526
|
var safeDecodeAsync3 = /* @__PURE__ */ _safeDecodeAsync2($ZodRealError2);
|
|
18044
18527
|
|
|
@@ -19614,9 +20097,9 @@ var $ZodObjectJIT2 = /* @__PURE__ */ $constructor2("$ZodObjectJIT", (inst, def)
|
|
|
19614
20097
|
for (const key of normalized.keys) {
|
|
19615
20098
|
const id = ids[key];
|
|
19616
20099
|
const k = esc2(key);
|
|
19617
|
-
const
|
|
19618
|
-
const isOptionalIn =
|
|
19619
|
-
const isOptionalOut =
|
|
20100
|
+
const schema2 = shape[key];
|
|
20101
|
+
const isOptionalIn = schema2?._zod?.optin === "optional";
|
|
20102
|
+
const isOptionalOut = schema2?._zod?.optout === "optional";
|
|
19620
20103
|
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
19621
20104
|
if (isOptionalIn && isOptionalOut) {
|
|
19622
20105
|
doc.write(`
|
|
@@ -26849,11 +27332,11 @@ var $ZodRegistry2 = class {
|
|
|
26849
27332
|
this._map = /* @__PURE__ */ new WeakMap();
|
|
26850
27333
|
this._idmap = /* @__PURE__ */ new Map();
|
|
26851
27334
|
}
|
|
26852
|
-
add(
|
|
27335
|
+
add(schema2, ..._meta) {
|
|
26853
27336
|
const meta5 = _meta[0];
|
|
26854
|
-
this._map.set(
|
|
27337
|
+
this._map.set(schema2, meta5);
|
|
26855
27338
|
if (meta5 && typeof meta5 === "object" && "id" in meta5) {
|
|
26856
|
-
this._idmap.set(meta5.id,
|
|
27339
|
+
this._idmap.set(meta5.id, schema2);
|
|
26857
27340
|
}
|
|
26858
27341
|
return this;
|
|
26859
27342
|
}
|
|
@@ -26862,26 +27345,26 @@ var $ZodRegistry2 = class {
|
|
|
26862
27345
|
this._idmap = /* @__PURE__ */ new Map();
|
|
26863
27346
|
return this;
|
|
26864
27347
|
}
|
|
26865
|
-
remove(
|
|
26866
|
-
const meta5 = this._map.get(
|
|
27348
|
+
remove(schema2) {
|
|
27349
|
+
const meta5 = this._map.get(schema2);
|
|
26867
27350
|
if (meta5 && typeof meta5 === "object" && "id" in meta5) {
|
|
26868
27351
|
this._idmap.delete(meta5.id);
|
|
26869
27352
|
}
|
|
26870
|
-
this._map.delete(
|
|
27353
|
+
this._map.delete(schema2);
|
|
26871
27354
|
return this;
|
|
26872
27355
|
}
|
|
26873
|
-
get(
|
|
26874
|
-
const p =
|
|
27356
|
+
get(schema2) {
|
|
27357
|
+
const p = schema2._zod.parent;
|
|
26875
27358
|
if (p) {
|
|
26876
27359
|
const pm = { ...this.get(p) ?? {} };
|
|
26877
27360
|
delete pm.id;
|
|
26878
|
-
const f = { ...pm, ...this._map.get(
|
|
27361
|
+
const f = { ...pm, ...this._map.get(schema2) };
|
|
26879
27362
|
return Object.keys(f).length ? f : void 0;
|
|
26880
27363
|
}
|
|
26881
|
-
return this._map.get(
|
|
27364
|
+
return this._map.get(schema2);
|
|
26882
27365
|
}
|
|
26883
|
-
has(
|
|
26884
|
-
return this._map.has(
|
|
27366
|
+
has(schema2) {
|
|
27367
|
+
return this._map.has(schema2);
|
|
26885
27368
|
}
|
|
26886
27369
|
};
|
|
26887
27370
|
function registry2() {
|
|
@@ -27534,11 +28017,11 @@ function _endsWith2(suffix, params) {
|
|
|
27534
28017
|
});
|
|
27535
28018
|
}
|
|
27536
28019
|
// @__NO_SIDE_EFFECTS__
|
|
27537
|
-
function _property2(property,
|
|
28020
|
+
function _property2(property, schema2, params) {
|
|
27538
28021
|
return new $ZodCheckProperty2({
|
|
27539
28022
|
check: "property",
|
|
27540
28023
|
property,
|
|
27541
|
-
schema,
|
|
28024
|
+
schema: schema2,
|
|
27542
28025
|
...normalizeParams2(params)
|
|
27543
28026
|
});
|
|
27544
28027
|
}
|
|
@@ -27786,23 +28269,23 @@ function _promise2(Class3, innerType) {
|
|
|
27786
28269
|
function _custom2(Class3, fn, _params) {
|
|
27787
28270
|
const norm = normalizeParams2(_params);
|
|
27788
28271
|
norm.abort ?? (norm.abort = true);
|
|
27789
|
-
const
|
|
28272
|
+
const schema2 = new Class3({
|
|
27790
28273
|
type: "custom",
|
|
27791
28274
|
check: "custom",
|
|
27792
28275
|
fn,
|
|
27793
28276
|
...norm
|
|
27794
28277
|
});
|
|
27795
|
-
return
|
|
28278
|
+
return schema2;
|
|
27796
28279
|
}
|
|
27797
28280
|
// @__NO_SIDE_EFFECTS__
|
|
27798
28281
|
function _refine2(Class3, fn, _params) {
|
|
27799
|
-
const
|
|
28282
|
+
const schema2 = new Class3({
|
|
27800
28283
|
type: "custom",
|
|
27801
28284
|
check: "custom",
|
|
27802
28285
|
fn,
|
|
27803
28286
|
...normalizeParams2(_params)
|
|
27804
28287
|
});
|
|
27805
|
-
return
|
|
28288
|
+
return schema2;
|
|
27806
28289
|
}
|
|
27807
28290
|
// @__NO_SIDE_EFFECTS__
|
|
27808
28291
|
function _superRefine2(fn, params) {
|
|
@@ -27951,40 +28434,40 @@ function initializeContext2(params) {
|
|
|
27951
28434
|
external: params?.external ?? void 0
|
|
27952
28435
|
};
|
|
27953
28436
|
}
|
|
27954
|
-
function process3(
|
|
28437
|
+
function process3(schema2, ctx, _params = { path: [], schemaPath: [] }) {
|
|
27955
28438
|
var _a5;
|
|
27956
|
-
const def =
|
|
27957
|
-
const seen = ctx.seen.get(
|
|
28439
|
+
const def = schema2._zod.def;
|
|
28440
|
+
const seen = ctx.seen.get(schema2);
|
|
27958
28441
|
if (seen) {
|
|
27959
28442
|
seen.count++;
|
|
27960
|
-
const isCycle = _params.schemaPath.includes(
|
|
28443
|
+
const isCycle = _params.schemaPath.includes(schema2);
|
|
27961
28444
|
if (isCycle) {
|
|
27962
28445
|
seen.cycle = _params.path;
|
|
27963
28446
|
}
|
|
27964
28447
|
return seen.schema;
|
|
27965
28448
|
}
|
|
27966
28449
|
const result = { schema: {}, count: 1, cycle: void 0, path: _params.path };
|
|
27967
|
-
ctx.seen.set(
|
|
27968
|
-
const overrideSchema =
|
|
28450
|
+
ctx.seen.set(schema2, result);
|
|
28451
|
+
const overrideSchema = schema2._zod.toJSONSchema?.();
|
|
27969
28452
|
if (overrideSchema) {
|
|
27970
28453
|
result.schema = overrideSchema;
|
|
27971
28454
|
} else {
|
|
27972
28455
|
const params = {
|
|
27973
28456
|
..._params,
|
|
27974
|
-
schemaPath: [..._params.schemaPath,
|
|
28457
|
+
schemaPath: [..._params.schemaPath, schema2],
|
|
27975
28458
|
path: _params.path
|
|
27976
28459
|
};
|
|
27977
|
-
if (
|
|
27978
|
-
|
|
28460
|
+
if (schema2._zod.processJSONSchema) {
|
|
28461
|
+
schema2._zod.processJSONSchema(ctx, result.schema, params);
|
|
27979
28462
|
} else {
|
|
27980
28463
|
const _json = result.schema;
|
|
27981
28464
|
const processor = ctx.processors[def.type];
|
|
27982
28465
|
if (!processor) {
|
|
27983
28466
|
throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
|
|
27984
28467
|
}
|
|
27985
|
-
processor(
|
|
28468
|
+
processor(schema2, ctx, _json, params);
|
|
27986
28469
|
}
|
|
27987
|
-
const parent =
|
|
28470
|
+
const parent = schema2._zod.parent;
|
|
27988
28471
|
if (parent) {
|
|
27989
28472
|
if (!result.ref)
|
|
27990
28473
|
result.ref = parent;
|
|
@@ -27992,21 +28475,21 @@ function process3(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
27992
28475
|
ctx.seen.get(parent).isParent = true;
|
|
27993
28476
|
}
|
|
27994
28477
|
}
|
|
27995
|
-
const meta5 = ctx.metadataRegistry.get(
|
|
28478
|
+
const meta5 = ctx.metadataRegistry.get(schema2);
|
|
27996
28479
|
if (meta5)
|
|
27997
28480
|
Object.assign(result.schema, meta5);
|
|
27998
|
-
if (ctx.io === "input" && isTransforming2(
|
|
28481
|
+
if (ctx.io === "input" && isTransforming2(schema2)) {
|
|
27999
28482
|
delete result.schema.examples;
|
|
28000
28483
|
delete result.schema.default;
|
|
28001
28484
|
}
|
|
28002
28485
|
if (ctx.io === "input" && "_prefault" in result.schema)
|
|
28003
28486
|
(_a5 = result.schema).default ?? (_a5.default = result.schema._prefault);
|
|
28004
28487
|
delete result.schema._prefault;
|
|
28005
|
-
const _result = ctx.seen.get(
|
|
28488
|
+
const _result = ctx.seen.get(schema2);
|
|
28006
28489
|
return _result.schema;
|
|
28007
28490
|
}
|
|
28008
|
-
function extractDefs2(ctx,
|
|
28009
|
-
const root = ctx.seen.get(
|
|
28491
|
+
function extractDefs2(ctx, schema2) {
|
|
28492
|
+
const root = ctx.seen.get(schema2);
|
|
28010
28493
|
if (!root)
|
|
28011
28494
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
28012
28495
|
const idToSchema = /* @__PURE__ */ new Map();
|
|
@@ -28049,11 +28532,11 @@ function extractDefs2(ctx, schema) {
|
|
|
28049
28532
|
seen.def = { ...seen.schema };
|
|
28050
28533
|
if (defId)
|
|
28051
28534
|
seen.defId = defId;
|
|
28052
|
-
const
|
|
28053
|
-
for (const key in
|
|
28054
|
-
delete
|
|
28535
|
+
const schema3 = seen.schema;
|
|
28536
|
+
for (const key in schema3) {
|
|
28537
|
+
delete schema3[key];
|
|
28055
28538
|
}
|
|
28056
|
-
|
|
28539
|
+
schema3.$ref = ref;
|
|
28057
28540
|
};
|
|
28058
28541
|
if (ctx.cycles === "throw") {
|
|
28059
28542
|
for (const entry of ctx.seen.entries()) {
|
|
@@ -28067,13 +28550,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
28067
28550
|
}
|
|
28068
28551
|
for (const entry of ctx.seen.entries()) {
|
|
28069
28552
|
const seen = entry[1];
|
|
28070
|
-
if (
|
|
28553
|
+
if (schema2 === entry[0]) {
|
|
28071
28554
|
extractToDef(entry);
|
|
28072
28555
|
continue;
|
|
28073
28556
|
}
|
|
28074
28557
|
if (ctx.external) {
|
|
28075
28558
|
const ext = ctx.external.registry.get(entry[0])?.id;
|
|
28076
|
-
if (
|
|
28559
|
+
if (schema2 !== entry[0] && ext) {
|
|
28077
28560
|
extractToDef(entry);
|
|
28078
28561
|
continue;
|
|
28079
28562
|
}
|
|
@@ -28095,16 +28578,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
28095
28578
|
}
|
|
28096
28579
|
}
|
|
28097
28580
|
}
|
|
28098
|
-
function finalize2(ctx,
|
|
28099
|
-
const root = ctx.seen.get(
|
|
28581
|
+
function finalize2(ctx, schema2) {
|
|
28582
|
+
const root = ctx.seen.get(schema2);
|
|
28100
28583
|
if (!root)
|
|
28101
28584
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
28102
28585
|
const flattenRef = (zodSchema) => {
|
|
28103
28586
|
const seen = ctx.seen.get(zodSchema);
|
|
28104
28587
|
if (seen.ref === null)
|
|
28105
28588
|
return;
|
|
28106
|
-
const
|
|
28107
|
-
const _cached = { ...
|
|
28589
|
+
const schema3 = seen.def ?? seen.schema;
|
|
28590
|
+
const _cached = { ...schema3 };
|
|
28108
28591
|
const ref = seen.ref;
|
|
28109
28592
|
seen.ref = null;
|
|
28110
28593
|
if (ref) {
|
|
@@ -28112,28 +28595,28 @@ function finalize2(ctx, schema) {
|
|
|
28112
28595
|
const refSeen = ctx.seen.get(ref);
|
|
28113
28596
|
const refSchema = refSeen.schema;
|
|
28114
28597
|
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
28115
|
-
|
|
28116
|
-
|
|
28598
|
+
schema3.allOf = schema3.allOf ?? [];
|
|
28599
|
+
schema3.allOf.push(refSchema);
|
|
28117
28600
|
} else {
|
|
28118
|
-
Object.assign(
|
|
28601
|
+
Object.assign(schema3, refSchema);
|
|
28119
28602
|
}
|
|
28120
|
-
Object.assign(
|
|
28603
|
+
Object.assign(schema3, _cached);
|
|
28121
28604
|
const isParentRef = zodSchema._zod.parent === ref;
|
|
28122
28605
|
if (isParentRef) {
|
|
28123
|
-
for (const key in
|
|
28606
|
+
for (const key in schema3) {
|
|
28124
28607
|
if (key === "$ref" || key === "allOf")
|
|
28125
28608
|
continue;
|
|
28126
28609
|
if (!(key in _cached)) {
|
|
28127
|
-
delete
|
|
28610
|
+
delete schema3[key];
|
|
28128
28611
|
}
|
|
28129
28612
|
}
|
|
28130
28613
|
}
|
|
28131
28614
|
if (refSchema.$ref && refSeen.def) {
|
|
28132
|
-
for (const key in
|
|
28615
|
+
for (const key in schema3) {
|
|
28133
28616
|
if (key === "$ref" || key === "allOf")
|
|
28134
28617
|
continue;
|
|
28135
|
-
if (key in refSeen.def && JSON.stringify(
|
|
28136
|
-
delete
|
|
28618
|
+
if (key in refSeen.def && JSON.stringify(schema3[key]) === JSON.stringify(refSeen.def[key])) {
|
|
28619
|
+
delete schema3[key];
|
|
28137
28620
|
}
|
|
28138
28621
|
}
|
|
28139
28622
|
}
|
|
@@ -28143,13 +28626,13 @@ function finalize2(ctx, schema) {
|
|
|
28143
28626
|
flattenRef(parent);
|
|
28144
28627
|
const parentSeen = ctx.seen.get(parent);
|
|
28145
28628
|
if (parentSeen?.schema.$ref) {
|
|
28146
|
-
|
|
28629
|
+
schema3.$ref = parentSeen.schema.$ref;
|
|
28147
28630
|
if (parentSeen.def) {
|
|
28148
|
-
for (const key in
|
|
28631
|
+
for (const key in schema3) {
|
|
28149
28632
|
if (key === "$ref" || key === "allOf")
|
|
28150
28633
|
continue;
|
|
28151
|
-
if (key in parentSeen.def && JSON.stringify(
|
|
28152
|
-
delete
|
|
28634
|
+
if (key in parentSeen.def && JSON.stringify(schema3[key]) === JSON.stringify(parentSeen.def[key])) {
|
|
28635
|
+
delete schema3[key];
|
|
28153
28636
|
}
|
|
28154
28637
|
}
|
|
28155
28638
|
}
|
|
@@ -28157,7 +28640,7 @@ function finalize2(ctx, schema) {
|
|
|
28157
28640
|
}
|
|
28158
28641
|
ctx.override({
|
|
28159
28642
|
zodSchema,
|
|
28160
|
-
jsonSchema:
|
|
28643
|
+
jsonSchema: schema3,
|
|
28161
28644
|
path: seen.path ?? []
|
|
28162
28645
|
});
|
|
28163
28646
|
};
|
|
@@ -28175,13 +28658,13 @@ function finalize2(ctx, schema) {
|
|
|
28175
28658
|
} else {
|
|
28176
28659
|
}
|
|
28177
28660
|
if (ctx.external?.uri) {
|
|
28178
|
-
const id = ctx.external.registry.get(
|
|
28661
|
+
const id = ctx.external.registry.get(schema2)?.id;
|
|
28179
28662
|
if (!id)
|
|
28180
28663
|
throw new Error("Schema is missing an `id` property");
|
|
28181
28664
|
result.$id = ctx.external.uri(id);
|
|
28182
28665
|
}
|
|
28183
28666
|
Object.assign(result, root.def ?? root.schema);
|
|
28184
|
-
const rootMetaId = ctx.metadataRegistry.get(
|
|
28667
|
+
const rootMetaId = ctx.metadataRegistry.get(schema2)?.id;
|
|
28185
28668
|
if (rootMetaId !== void 0 && result.id === rootMetaId)
|
|
28186
28669
|
delete result.id;
|
|
28187
28670
|
const defs = ctx.external?.defs ?? {};
|
|
@@ -28207,10 +28690,10 @@ function finalize2(ctx, schema) {
|
|
|
28207
28690
|
const finalized = JSON.parse(JSON.stringify(result));
|
|
28208
28691
|
Object.defineProperty(finalized, "~standard", {
|
|
28209
28692
|
value: {
|
|
28210
|
-
...
|
|
28693
|
+
...schema2["~standard"],
|
|
28211
28694
|
jsonSchema: {
|
|
28212
|
-
input: createStandardJSONSchemaMethod2(
|
|
28213
|
-
output: createStandardJSONSchemaMethod2(
|
|
28695
|
+
input: createStandardJSONSchemaMethod2(schema2, "input", ctx.processors),
|
|
28696
|
+
output: createStandardJSONSchemaMethod2(schema2, "output", ctx.processors)
|
|
28214
28697
|
}
|
|
28215
28698
|
},
|
|
28216
28699
|
enumerable: false,
|
|
@@ -28274,18 +28757,18 @@ function isTransforming2(_schema, _ctx) {
|
|
|
28274
28757
|
}
|
|
28275
28758
|
return false;
|
|
28276
28759
|
}
|
|
28277
|
-
var createToJSONSchemaMethod2 = (
|
|
28760
|
+
var createToJSONSchemaMethod2 = (schema2, processors = {}) => (params) => {
|
|
28278
28761
|
const ctx = initializeContext2({ ...params, processors });
|
|
28279
|
-
process3(
|
|
28280
|
-
extractDefs2(ctx,
|
|
28281
|
-
return finalize2(ctx,
|
|
28762
|
+
process3(schema2, ctx);
|
|
28763
|
+
extractDefs2(ctx, schema2);
|
|
28764
|
+
return finalize2(ctx, schema2);
|
|
28282
28765
|
};
|
|
28283
|
-
var createStandardJSONSchemaMethod2 = (
|
|
28766
|
+
var createStandardJSONSchemaMethod2 = (schema2, io, processors = {}) => (params) => {
|
|
28284
28767
|
const { libraryOptions, target } = params ?? {};
|
|
28285
28768
|
const ctx = initializeContext2({ ...libraryOptions ?? {}, target, io, processors });
|
|
28286
|
-
process3(
|
|
28287
|
-
extractDefs2(ctx,
|
|
28288
|
-
return finalize2(ctx,
|
|
28769
|
+
process3(schema2, ctx);
|
|
28770
|
+
extractDefs2(ctx, schema2);
|
|
28771
|
+
return finalize2(ctx, schema2);
|
|
28289
28772
|
};
|
|
28290
28773
|
|
|
28291
28774
|
// ../node_modules/zod/v4/core/json-schema-processors.js
|
|
@@ -28297,10 +28780,10 @@ var formatMap2 = {
|
|
|
28297
28780
|
regex: ""
|
|
28298
28781
|
// do not set
|
|
28299
28782
|
};
|
|
28300
|
-
var stringProcessor2 = (
|
|
28783
|
+
var stringProcessor2 = (schema2, ctx, _json, _params) => {
|
|
28301
28784
|
const json4 = _json;
|
|
28302
28785
|
json4.type = "string";
|
|
28303
|
-
const { minimum, maximum, format, patterns, contentEncoding } =
|
|
28786
|
+
const { minimum, maximum, format, patterns, contentEncoding } = schema2._zod.bag;
|
|
28304
28787
|
if (typeof minimum === "number")
|
|
28305
28788
|
json4.minLength = minimum;
|
|
28306
28789
|
if (typeof maximum === "number")
|
|
@@ -28329,9 +28812,9 @@ var stringProcessor2 = (schema, ctx, _json, _params) => {
|
|
|
28329
28812
|
}
|
|
28330
28813
|
}
|
|
28331
28814
|
};
|
|
28332
|
-
var numberProcessor2 = (
|
|
28815
|
+
var numberProcessor2 = (schema2, ctx, _json, _params) => {
|
|
28333
28816
|
const json4 = _json;
|
|
28334
|
-
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } =
|
|
28817
|
+
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema2._zod.bag;
|
|
28335
28818
|
if (typeof format === "string" && format.includes("int"))
|
|
28336
28819
|
json4.type = "integer";
|
|
28337
28820
|
else
|
|
@@ -28406,8 +28889,8 @@ var dateProcessor2 = (_schema, ctx, _json, _params) => {
|
|
|
28406
28889
|
throw new Error("Date cannot be represented in JSON Schema");
|
|
28407
28890
|
}
|
|
28408
28891
|
};
|
|
28409
|
-
var enumProcessor2 = (
|
|
28410
|
-
const def =
|
|
28892
|
+
var enumProcessor2 = (schema2, _ctx, json4, _params) => {
|
|
28893
|
+
const def = schema2._zod.def;
|
|
28411
28894
|
const values = getEnumValues2(def.entries);
|
|
28412
28895
|
if (values.every((v) => typeof v === "number"))
|
|
28413
28896
|
json4.type = "number";
|
|
@@ -28415,8 +28898,8 @@ var enumProcessor2 = (schema, _ctx, json4, _params) => {
|
|
|
28415
28898
|
json4.type = "string";
|
|
28416
28899
|
json4.enum = values;
|
|
28417
28900
|
};
|
|
28418
|
-
var literalProcessor2 = (
|
|
28419
|
-
const def =
|
|
28901
|
+
var literalProcessor2 = (schema2, ctx, json4, _params) => {
|
|
28902
|
+
const def = schema2._zod.def;
|
|
28420
28903
|
const vals = [];
|
|
28421
28904
|
for (const val of def.values) {
|
|
28422
28905
|
if (val === void 0) {
|
|
@@ -28460,22 +28943,22 @@ var nanProcessor2 = (_schema, ctx, _json, _params) => {
|
|
|
28460
28943
|
throw new Error("NaN cannot be represented in JSON Schema");
|
|
28461
28944
|
}
|
|
28462
28945
|
};
|
|
28463
|
-
var templateLiteralProcessor2 = (
|
|
28946
|
+
var templateLiteralProcessor2 = (schema2, _ctx, json4, _params) => {
|
|
28464
28947
|
const _json = json4;
|
|
28465
|
-
const pattern =
|
|
28948
|
+
const pattern = schema2._zod.pattern;
|
|
28466
28949
|
if (!pattern)
|
|
28467
28950
|
throw new Error("Pattern not found in template literal");
|
|
28468
28951
|
_json.type = "string";
|
|
28469
28952
|
_json.pattern = pattern.source;
|
|
28470
28953
|
};
|
|
28471
|
-
var fileProcessor2 = (
|
|
28954
|
+
var fileProcessor2 = (schema2, _ctx, json4, _params) => {
|
|
28472
28955
|
const _json = json4;
|
|
28473
28956
|
const file3 = {
|
|
28474
28957
|
type: "string",
|
|
28475
28958
|
format: "binary",
|
|
28476
28959
|
contentEncoding: "binary"
|
|
28477
28960
|
};
|
|
28478
|
-
const { minimum, maximum, mime } =
|
|
28961
|
+
const { minimum, maximum, mime } = schema2._zod.bag;
|
|
28479
28962
|
if (minimum !== void 0)
|
|
28480
28963
|
file3.minLength = minimum;
|
|
28481
28964
|
if (maximum !== void 0)
|
|
@@ -28520,10 +29003,10 @@ var setProcessor2 = (_schema, ctx, _json, _params) => {
|
|
|
28520
29003
|
throw new Error("Set cannot be represented in JSON Schema");
|
|
28521
29004
|
}
|
|
28522
29005
|
};
|
|
28523
|
-
var arrayProcessor2 = (
|
|
29006
|
+
var arrayProcessor2 = (schema2, ctx, _json, params) => {
|
|
28524
29007
|
const json4 = _json;
|
|
28525
|
-
const def =
|
|
28526
|
-
const { minimum, maximum } =
|
|
29008
|
+
const def = schema2._zod.def;
|
|
29009
|
+
const { minimum, maximum } = schema2._zod.bag;
|
|
28527
29010
|
if (typeof minimum === "number")
|
|
28528
29011
|
json4.minItems = minimum;
|
|
28529
29012
|
if (typeof maximum === "number")
|
|
@@ -28534,9 +29017,9 @@ var arrayProcessor2 = (schema, ctx, _json, params) => {
|
|
|
28534
29017
|
path: [...params.path, "items"]
|
|
28535
29018
|
});
|
|
28536
29019
|
};
|
|
28537
|
-
var objectProcessor2 = (
|
|
29020
|
+
var objectProcessor2 = (schema2, ctx, _json, params) => {
|
|
28538
29021
|
const json4 = _json;
|
|
28539
|
-
const def =
|
|
29022
|
+
const def = schema2._zod.def;
|
|
28540
29023
|
json4.type = "object";
|
|
28541
29024
|
json4.properties = {};
|
|
28542
29025
|
const shape = def.shape;
|
|
@@ -28570,8 +29053,8 @@ var objectProcessor2 = (schema, ctx, _json, params) => {
|
|
|
28570
29053
|
});
|
|
28571
29054
|
}
|
|
28572
29055
|
};
|
|
28573
|
-
var unionProcessor2 = (
|
|
28574
|
-
const def =
|
|
29056
|
+
var unionProcessor2 = (schema2, ctx, json4, params) => {
|
|
29057
|
+
const def = schema2._zod.def;
|
|
28575
29058
|
const isExclusive = def.inclusive === false;
|
|
28576
29059
|
const options = def.options.map((x, i) => process3(x, ctx, {
|
|
28577
29060
|
...params,
|
|
@@ -28583,8 +29066,8 @@ var unionProcessor2 = (schema, ctx, json4, params) => {
|
|
|
28583
29066
|
json4.anyOf = options;
|
|
28584
29067
|
}
|
|
28585
29068
|
};
|
|
28586
|
-
var intersectionProcessor2 = (
|
|
28587
|
-
const def =
|
|
29069
|
+
var intersectionProcessor2 = (schema2, ctx, json4, params) => {
|
|
29070
|
+
const def = schema2._zod.def;
|
|
28588
29071
|
const a = process3(def.left, ctx, {
|
|
28589
29072
|
...params,
|
|
28590
29073
|
path: [...params.path, "allOf", 0]
|
|
@@ -28600,9 +29083,9 @@ var intersectionProcessor2 = (schema, ctx, json4, params) => {
|
|
|
28600
29083
|
];
|
|
28601
29084
|
json4.allOf = allOf;
|
|
28602
29085
|
};
|
|
28603
|
-
var tupleProcessor2 = (
|
|
29086
|
+
var tupleProcessor2 = (schema2, ctx, _json, params) => {
|
|
28604
29087
|
const json4 = _json;
|
|
28605
|
-
const def =
|
|
29088
|
+
const def = schema2._zod.def;
|
|
28606
29089
|
json4.type = "array";
|
|
28607
29090
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
28608
29091
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
@@ -28636,15 +29119,15 @@ var tupleProcessor2 = (schema, ctx, _json, params) => {
|
|
|
28636
29119
|
json4.additionalItems = rest;
|
|
28637
29120
|
}
|
|
28638
29121
|
}
|
|
28639
|
-
const { minimum, maximum } =
|
|
29122
|
+
const { minimum, maximum } = schema2._zod.bag;
|
|
28640
29123
|
if (typeof minimum === "number")
|
|
28641
29124
|
json4.minItems = minimum;
|
|
28642
29125
|
if (typeof maximum === "number")
|
|
28643
29126
|
json4.maxItems = maximum;
|
|
28644
29127
|
};
|
|
28645
|
-
var recordProcessor2 = (
|
|
29128
|
+
var recordProcessor2 = (schema2, ctx, _json, params) => {
|
|
28646
29129
|
const json4 = _json;
|
|
28647
|
-
const def =
|
|
29130
|
+
const def = schema2._zod.def;
|
|
28648
29131
|
json4.type = "object";
|
|
28649
29132
|
const keyType = def.keyType;
|
|
28650
29133
|
const keyBag = keyType._zod.bag;
|
|
@@ -28678,10 +29161,10 @@ var recordProcessor2 = (schema, ctx, _json, params) => {
|
|
|
28678
29161
|
}
|
|
28679
29162
|
}
|
|
28680
29163
|
};
|
|
28681
|
-
var nullableProcessor2 = (
|
|
28682
|
-
const def =
|
|
29164
|
+
var nullableProcessor2 = (schema2, ctx, json4, params) => {
|
|
29165
|
+
const def = schema2._zod.def;
|
|
28683
29166
|
const inner = process3(def.innerType, ctx, params);
|
|
28684
|
-
const seen = ctx.seen.get(
|
|
29167
|
+
const seen = ctx.seen.get(schema2);
|
|
28685
29168
|
if (ctx.target === "openapi-3.0") {
|
|
28686
29169
|
seen.ref = def.innerType;
|
|
28687
29170
|
json4.nullable = true;
|
|
@@ -28689,31 +29172,31 @@ var nullableProcessor2 = (schema, ctx, json4, params) => {
|
|
|
28689
29172
|
json4.anyOf = [inner, { type: "null" }];
|
|
28690
29173
|
}
|
|
28691
29174
|
};
|
|
28692
|
-
var nonoptionalProcessor2 = (
|
|
28693
|
-
const def =
|
|
29175
|
+
var nonoptionalProcessor2 = (schema2, ctx, _json, params) => {
|
|
29176
|
+
const def = schema2._zod.def;
|
|
28694
29177
|
process3(def.innerType, ctx, params);
|
|
28695
|
-
const seen = ctx.seen.get(
|
|
29178
|
+
const seen = ctx.seen.get(schema2);
|
|
28696
29179
|
seen.ref = def.innerType;
|
|
28697
29180
|
};
|
|
28698
|
-
var defaultProcessor2 = (
|
|
28699
|
-
const def =
|
|
29181
|
+
var defaultProcessor2 = (schema2, ctx, json4, params) => {
|
|
29182
|
+
const def = schema2._zod.def;
|
|
28700
29183
|
process3(def.innerType, ctx, params);
|
|
28701
|
-
const seen = ctx.seen.get(
|
|
29184
|
+
const seen = ctx.seen.get(schema2);
|
|
28702
29185
|
seen.ref = def.innerType;
|
|
28703
29186
|
json4.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
28704
29187
|
};
|
|
28705
|
-
var prefaultProcessor2 = (
|
|
28706
|
-
const def =
|
|
29188
|
+
var prefaultProcessor2 = (schema2, ctx, json4, params) => {
|
|
29189
|
+
const def = schema2._zod.def;
|
|
28707
29190
|
process3(def.innerType, ctx, params);
|
|
28708
|
-
const seen = ctx.seen.get(
|
|
29191
|
+
const seen = ctx.seen.get(schema2);
|
|
28709
29192
|
seen.ref = def.innerType;
|
|
28710
29193
|
if (ctx.io === "input")
|
|
28711
29194
|
json4._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
28712
29195
|
};
|
|
28713
|
-
var catchProcessor2 = (
|
|
28714
|
-
const def =
|
|
29196
|
+
var catchProcessor2 = (schema2, ctx, json4, params) => {
|
|
29197
|
+
const def = schema2._zod.def;
|
|
28715
29198
|
process3(def.innerType, ctx, params);
|
|
28716
|
-
const seen = ctx.seen.get(
|
|
29199
|
+
const seen = ctx.seen.get(schema2);
|
|
28717
29200
|
seen.ref = def.innerType;
|
|
28718
29201
|
let catchValue;
|
|
28719
29202
|
try {
|
|
@@ -28723,37 +29206,37 @@ var catchProcessor2 = (schema, ctx, json4, params) => {
|
|
|
28723
29206
|
}
|
|
28724
29207
|
json4.default = catchValue;
|
|
28725
29208
|
};
|
|
28726
|
-
var pipeProcessor2 = (
|
|
28727
|
-
const def =
|
|
29209
|
+
var pipeProcessor2 = (schema2, ctx, _json, params) => {
|
|
29210
|
+
const def = schema2._zod.def;
|
|
28728
29211
|
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
28729
29212
|
const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
|
|
28730
29213
|
process3(innerType, ctx, params);
|
|
28731
|
-
const seen = ctx.seen.get(
|
|
29214
|
+
const seen = ctx.seen.get(schema2);
|
|
28732
29215
|
seen.ref = innerType;
|
|
28733
29216
|
};
|
|
28734
|
-
var readonlyProcessor2 = (
|
|
28735
|
-
const def =
|
|
29217
|
+
var readonlyProcessor2 = (schema2, ctx, json4, params) => {
|
|
29218
|
+
const def = schema2._zod.def;
|
|
28736
29219
|
process3(def.innerType, ctx, params);
|
|
28737
|
-
const seen = ctx.seen.get(
|
|
29220
|
+
const seen = ctx.seen.get(schema2);
|
|
28738
29221
|
seen.ref = def.innerType;
|
|
28739
29222
|
json4.readOnly = true;
|
|
28740
29223
|
};
|
|
28741
|
-
var promiseProcessor2 = (
|
|
28742
|
-
const def =
|
|
29224
|
+
var promiseProcessor2 = (schema2, ctx, _json, params) => {
|
|
29225
|
+
const def = schema2._zod.def;
|
|
28743
29226
|
process3(def.innerType, ctx, params);
|
|
28744
|
-
const seen = ctx.seen.get(
|
|
29227
|
+
const seen = ctx.seen.get(schema2);
|
|
28745
29228
|
seen.ref = def.innerType;
|
|
28746
29229
|
};
|
|
28747
|
-
var optionalProcessor2 = (
|
|
28748
|
-
const def =
|
|
29230
|
+
var optionalProcessor2 = (schema2, ctx, _json, params) => {
|
|
29231
|
+
const def = schema2._zod.def;
|
|
28749
29232
|
process3(def.innerType, ctx, params);
|
|
28750
|
-
const seen = ctx.seen.get(
|
|
29233
|
+
const seen = ctx.seen.get(schema2);
|
|
28751
29234
|
seen.ref = def.innerType;
|
|
28752
29235
|
};
|
|
28753
|
-
var lazyProcessor2 = (
|
|
28754
|
-
const innerType =
|
|
29236
|
+
var lazyProcessor2 = (schema2, ctx, _json, params) => {
|
|
29237
|
+
const innerType = schema2._zod.innerType;
|
|
28755
29238
|
process3(innerType, ctx, params);
|
|
28756
|
-
const seen = ctx.seen.get(
|
|
29239
|
+
const seen = ctx.seen.get(schema2);
|
|
28757
29240
|
seen.ref = innerType;
|
|
28758
29241
|
};
|
|
28759
29242
|
var allProcessors2 = {
|
|
@@ -28803,8 +29286,8 @@ function toJSONSchema2(input, params) {
|
|
|
28803
29286
|
const ctx2 = initializeContext2({ ...params, processors: allProcessors2 });
|
|
28804
29287
|
const defs = {};
|
|
28805
29288
|
for (const entry of registry3._idmap.entries()) {
|
|
28806
|
-
const [_,
|
|
28807
|
-
process3(
|
|
29289
|
+
const [_, schema2] = entry;
|
|
29290
|
+
process3(schema2, ctx2);
|
|
28808
29291
|
}
|
|
28809
29292
|
const schemas = {};
|
|
28810
29293
|
const external = {
|
|
@@ -28814,9 +29297,9 @@ function toJSONSchema2(input, params) {
|
|
|
28814
29297
|
};
|
|
28815
29298
|
ctx2.external = external;
|
|
28816
29299
|
for (const entry of registry3._idmap.entries()) {
|
|
28817
|
-
const [key,
|
|
28818
|
-
extractDefs2(ctx2,
|
|
28819
|
-
schemas[key] = finalize2(ctx2,
|
|
29300
|
+
const [key, schema2] = entry;
|
|
29301
|
+
extractDefs2(ctx2, schema2);
|
|
29302
|
+
schemas[key] = finalize2(ctx2, schema2);
|
|
28820
29303
|
}
|
|
28821
29304
|
if (Object.keys(defs).length > 0) {
|
|
28822
29305
|
const defsSegment = ctx2.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
@@ -28884,14 +29367,14 @@ var JSONSchemaGenerator2 = class {
|
|
|
28884
29367
|
* Process a schema to prepare it for JSON Schema generation.
|
|
28885
29368
|
* This must be called before emit().
|
|
28886
29369
|
*/
|
|
28887
|
-
process(
|
|
28888
|
-
return process3(
|
|
29370
|
+
process(schema2, _params = { path: [], schemaPath: [] }) {
|
|
29371
|
+
return process3(schema2, this.ctx, _params);
|
|
28889
29372
|
}
|
|
28890
29373
|
/**
|
|
28891
29374
|
* Emit the final JSON Schema after processing.
|
|
28892
29375
|
* Must call process() first.
|
|
28893
29376
|
*/
|
|
28894
|
-
emit(
|
|
29377
|
+
emit(schema2, _params) {
|
|
28895
29378
|
if (_params) {
|
|
28896
29379
|
if (_params.cycles)
|
|
28897
29380
|
this.ctx.cycles = _params.cycles;
|
|
@@ -28900,8 +29383,8 @@ var JSONSchemaGenerator2 = class {
|
|
|
28900
29383
|
if (_params.external)
|
|
28901
29384
|
this.ctx.external = _params.external;
|
|
28902
29385
|
}
|
|
28903
|
-
extractDefs2(this.ctx,
|
|
28904
|
-
const result = finalize2(this.ctx,
|
|
29386
|
+
extractDefs2(this.ctx, schema2);
|
|
29387
|
+
const result = finalize2(this.ctx, schema2);
|
|
28905
29388
|
const { "~standard": _, ...plainResult } = result;
|
|
28906
29389
|
return plainResult;
|
|
28907
29390
|
}
|
|
@@ -29866,8 +30349,8 @@ var ZodArray2 = /* @__PURE__ */ $constructor2("ZodArray", (inst, def) => {
|
|
|
29866
30349
|
function array2(element, params) {
|
|
29867
30350
|
return _array2(ZodArray2, element, params);
|
|
29868
30351
|
}
|
|
29869
|
-
function keyof2(
|
|
29870
|
-
const shape =
|
|
30352
|
+
function keyof2(schema2) {
|
|
30353
|
+
const shape = schema2._zod.def.shape;
|
|
29871
30354
|
return _enum4(Object.keys(shape));
|
|
29872
30355
|
}
|
|
29873
30356
|
var ZodObject2 = /* @__PURE__ */ $constructor2("ZodObject", (inst, def) => {
|
|
@@ -30492,11 +30975,11 @@ function json3(params) {
|
|
|
30492
30975
|
});
|
|
30493
30976
|
return jsonSchema;
|
|
30494
30977
|
}
|
|
30495
|
-
function preprocess2(fn,
|
|
30978
|
+
function preprocess2(fn, schema2) {
|
|
30496
30979
|
return new ZodPreprocess2({
|
|
30497
30980
|
type: "pipe",
|
|
30498
30981
|
in: transform2(fn),
|
|
30499
|
-
out:
|
|
30982
|
+
out: schema2
|
|
30500
30983
|
});
|
|
30501
30984
|
}
|
|
30502
30985
|
|
|
@@ -30603,8 +31086,8 @@ var RECOGNIZED_KEYS2 = /* @__PURE__ */ new Set([
|
|
|
30603
31086
|
"nullable",
|
|
30604
31087
|
"readOnly"
|
|
30605
31088
|
]);
|
|
30606
|
-
function detectVersion2(
|
|
30607
|
-
const $schema =
|
|
31089
|
+
function detectVersion2(schema2, defaultTarget) {
|
|
31090
|
+
const $schema = schema2.$schema;
|
|
30608
31091
|
if ($schema === "https://json-schema.org/draft/2020-12/schema") {
|
|
30609
31092
|
return "draft-2020-12";
|
|
30610
31093
|
}
|
|
@@ -30634,27 +31117,27 @@ function resolveRef2(ref, ctx) {
|
|
|
30634
31117
|
}
|
|
30635
31118
|
throw new Error(`Reference not found: ${ref}`);
|
|
30636
31119
|
}
|
|
30637
|
-
function convertBaseSchema2(
|
|
30638
|
-
if (
|
|
30639
|
-
if (typeof
|
|
31120
|
+
function convertBaseSchema2(schema2, ctx) {
|
|
31121
|
+
if (schema2.not !== void 0) {
|
|
31122
|
+
if (typeof schema2.not === "object" && Object.keys(schema2.not).length === 0) {
|
|
30640
31123
|
return z2.never();
|
|
30641
31124
|
}
|
|
30642
31125
|
throw new Error("not is not supported in Zod (except { not: {} } for never)");
|
|
30643
31126
|
}
|
|
30644
|
-
if (
|
|
31127
|
+
if (schema2.unevaluatedItems !== void 0) {
|
|
30645
31128
|
throw new Error("unevaluatedItems is not supported");
|
|
30646
31129
|
}
|
|
30647
|
-
if (
|
|
31130
|
+
if (schema2.unevaluatedProperties !== void 0) {
|
|
30648
31131
|
throw new Error("unevaluatedProperties is not supported");
|
|
30649
31132
|
}
|
|
30650
|
-
if (
|
|
31133
|
+
if (schema2.if !== void 0 || schema2.then !== void 0 || schema2.else !== void 0) {
|
|
30651
31134
|
throw new Error("Conditional schemas (if/then/else) are not supported");
|
|
30652
31135
|
}
|
|
30653
|
-
if (
|
|
31136
|
+
if (schema2.dependentSchemas !== void 0 || schema2.dependentRequired !== void 0) {
|
|
30654
31137
|
throw new Error("dependentSchemas and dependentRequired are not supported");
|
|
30655
31138
|
}
|
|
30656
|
-
if (
|
|
30657
|
-
const refPath =
|
|
31139
|
+
if (schema2.$ref) {
|
|
31140
|
+
const refPath = schema2.$ref;
|
|
30658
31141
|
if (ctx.refs.has(refPath)) {
|
|
30659
31142
|
return ctx.refs.get(refPath);
|
|
30660
31143
|
}
|
|
@@ -30673,9 +31156,9 @@ function convertBaseSchema2(schema, ctx) {
|
|
|
30673
31156
|
ctx.processing.delete(refPath);
|
|
30674
31157
|
return zodSchema2;
|
|
30675
31158
|
}
|
|
30676
|
-
if (
|
|
30677
|
-
const enumValues =
|
|
30678
|
-
if (ctx.version === "openapi-3.0" &&
|
|
31159
|
+
if (schema2.enum !== void 0) {
|
|
31160
|
+
const enumValues = schema2.enum;
|
|
31161
|
+
if (ctx.version === "openapi-3.0" && schema2.nullable === true && enumValues.length === 1 && enumValues[0] === null) {
|
|
30679
31162
|
return z2.null();
|
|
30680
31163
|
}
|
|
30681
31164
|
if (enumValues.length === 0) {
|
|
@@ -30693,13 +31176,13 @@ function convertBaseSchema2(schema, ctx) {
|
|
|
30693
31176
|
}
|
|
30694
31177
|
return z2.union([literalSchemas[0], literalSchemas[1], ...literalSchemas.slice(2)]);
|
|
30695
31178
|
}
|
|
30696
|
-
if (
|
|
30697
|
-
return z2.literal(
|
|
31179
|
+
if (schema2.const !== void 0) {
|
|
31180
|
+
return z2.literal(schema2.const);
|
|
30698
31181
|
}
|
|
30699
|
-
const type =
|
|
31182
|
+
const type = schema2.type;
|
|
30700
31183
|
if (Array.isArray(type)) {
|
|
30701
31184
|
const typeSchemas = type.map((t) => {
|
|
30702
|
-
const typeSchema = { ...
|
|
31185
|
+
const typeSchema = { ...schema2, type: t };
|
|
30703
31186
|
return convertBaseSchema2(typeSchema, ctx);
|
|
30704
31187
|
});
|
|
30705
31188
|
if (typeSchemas.length === 0) {
|
|
@@ -30717,8 +31200,8 @@ function convertBaseSchema2(schema, ctx) {
|
|
|
30717
31200
|
switch (type) {
|
|
30718
31201
|
case "string": {
|
|
30719
31202
|
let stringSchema = z2.string();
|
|
30720
|
-
if (
|
|
30721
|
-
const format =
|
|
31203
|
+
if (schema2.format) {
|
|
31204
|
+
const format = schema2.format;
|
|
30722
31205
|
if (format === "email") {
|
|
30723
31206
|
stringSchema = stringSchema.check(z2.email());
|
|
30724
31207
|
} else if (format === "uri" || format === "uri-reference") {
|
|
@@ -30767,14 +31250,14 @@ function convertBaseSchema2(schema, ctx) {
|
|
|
30767
31250
|
stringSchema = stringSchema.check(z2.ksuid());
|
|
30768
31251
|
}
|
|
30769
31252
|
}
|
|
30770
|
-
if (typeof
|
|
30771
|
-
stringSchema = stringSchema.min(
|
|
31253
|
+
if (typeof schema2.minLength === "number") {
|
|
31254
|
+
stringSchema = stringSchema.min(schema2.minLength);
|
|
30772
31255
|
}
|
|
30773
|
-
if (typeof
|
|
30774
|
-
stringSchema = stringSchema.max(
|
|
31256
|
+
if (typeof schema2.maxLength === "number") {
|
|
31257
|
+
stringSchema = stringSchema.max(schema2.maxLength);
|
|
30775
31258
|
}
|
|
30776
|
-
if (
|
|
30777
|
-
stringSchema = stringSchema.regex(new RegExp(
|
|
31259
|
+
if (schema2.pattern) {
|
|
31260
|
+
stringSchema = stringSchema.regex(new RegExp(schema2.pattern));
|
|
30778
31261
|
}
|
|
30779
31262
|
zodSchema = stringSchema;
|
|
30780
31263
|
break;
|
|
@@ -30782,24 +31265,24 @@ function convertBaseSchema2(schema, ctx) {
|
|
|
30782
31265
|
case "number":
|
|
30783
31266
|
case "integer": {
|
|
30784
31267
|
let numberSchema = type === "integer" ? z2.number().int() : z2.number();
|
|
30785
|
-
if (typeof
|
|
30786
|
-
numberSchema = numberSchema.min(
|
|
31268
|
+
if (typeof schema2.minimum === "number") {
|
|
31269
|
+
numberSchema = numberSchema.min(schema2.minimum);
|
|
30787
31270
|
}
|
|
30788
|
-
if (typeof
|
|
30789
|
-
numberSchema = numberSchema.max(
|
|
31271
|
+
if (typeof schema2.maximum === "number") {
|
|
31272
|
+
numberSchema = numberSchema.max(schema2.maximum);
|
|
30790
31273
|
}
|
|
30791
|
-
if (typeof
|
|
30792
|
-
numberSchema = numberSchema.gt(
|
|
30793
|
-
} else if (
|
|
30794
|
-
numberSchema = numberSchema.gt(
|
|
31274
|
+
if (typeof schema2.exclusiveMinimum === "number") {
|
|
31275
|
+
numberSchema = numberSchema.gt(schema2.exclusiveMinimum);
|
|
31276
|
+
} else if (schema2.exclusiveMinimum === true && typeof schema2.minimum === "number") {
|
|
31277
|
+
numberSchema = numberSchema.gt(schema2.minimum);
|
|
30795
31278
|
}
|
|
30796
|
-
if (typeof
|
|
30797
|
-
numberSchema = numberSchema.lt(
|
|
30798
|
-
} else if (
|
|
30799
|
-
numberSchema = numberSchema.lt(
|
|
31279
|
+
if (typeof schema2.exclusiveMaximum === "number") {
|
|
31280
|
+
numberSchema = numberSchema.lt(schema2.exclusiveMaximum);
|
|
31281
|
+
} else if (schema2.exclusiveMaximum === true && typeof schema2.maximum === "number") {
|
|
31282
|
+
numberSchema = numberSchema.lt(schema2.maximum);
|
|
30800
31283
|
}
|
|
30801
|
-
if (typeof
|
|
30802
|
-
numberSchema = numberSchema.multipleOf(
|
|
31284
|
+
if (typeof schema2.multipleOf === "number") {
|
|
31285
|
+
numberSchema = numberSchema.multipleOf(schema2.multipleOf);
|
|
30803
31286
|
}
|
|
30804
31287
|
zodSchema = numberSchema;
|
|
30805
31288
|
break;
|
|
@@ -30814,15 +31297,15 @@ function convertBaseSchema2(schema, ctx) {
|
|
|
30814
31297
|
}
|
|
30815
31298
|
case "object": {
|
|
30816
31299
|
const shape = {};
|
|
30817
|
-
const properties =
|
|
30818
|
-
const requiredSet = new Set(
|
|
31300
|
+
const properties = schema2.properties || {};
|
|
31301
|
+
const requiredSet = new Set(schema2.required || []);
|
|
30819
31302
|
for (const [key, propSchema] of Object.entries(properties)) {
|
|
30820
31303
|
const propZodSchema = convertSchema2(propSchema, ctx);
|
|
30821
31304
|
shape[key] = requiredSet.has(key) ? propZodSchema : propZodSchema.optional();
|
|
30822
31305
|
}
|
|
30823
|
-
if (
|
|
30824
|
-
const keySchema = convertSchema2(
|
|
30825
|
-
const valueSchema =
|
|
31306
|
+
if (schema2.propertyNames) {
|
|
31307
|
+
const keySchema = convertSchema2(schema2.propertyNames, ctx);
|
|
31308
|
+
const valueSchema = schema2.additionalProperties && typeof schema2.additionalProperties === "object" ? convertSchema2(schema2.additionalProperties, ctx) : z2.any();
|
|
30826
31309
|
if (Object.keys(shape).length === 0) {
|
|
30827
31310
|
zodSchema = z2.record(keySchema, valueSchema);
|
|
30828
31311
|
break;
|
|
@@ -30832,8 +31315,8 @@ function convertBaseSchema2(schema, ctx) {
|
|
|
30832
31315
|
zodSchema = z2.intersection(objectSchema2, recordSchema);
|
|
30833
31316
|
break;
|
|
30834
31317
|
}
|
|
30835
|
-
if (
|
|
30836
|
-
const patternProps =
|
|
31318
|
+
if (schema2.patternProperties) {
|
|
31319
|
+
const patternProps = schema2.patternProperties;
|
|
30837
31320
|
const patternKeys = Object.keys(patternProps);
|
|
30838
31321
|
const looseRecords = [];
|
|
30839
31322
|
for (const pattern of patternKeys) {
|
|
@@ -30860,18 +31343,18 @@ function convertBaseSchema2(schema, ctx) {
|
|
|
30860
31343
|
break;
|
|
30861
31344
|
}
|
|
30862
31345
|
const objectSchema = z2.object(shape);
|
|
30863
|
-
if (
|
|
31346
|
+
if (schema2.additionalProperties === false) {
|
|
30864
31347
|
zodSchema = objectSchema.strict();
|
|
30865
|
-
} else if (typeof
|
|
30866
|
-
zodSchema = objectSchema.catchall(convertSchema2(
|
|
31348
|
+
} else if (typeof schema2.additionalProperties === "object") {
|
|
31349
|
+
zodSchema = objectSchema.catchall(convertSchema2(schema2.additionalProperties, ctx));
|
|
30867
31350
|
} else {
|
|
30868
31351
|
zodSchema = objectSchema.passthrough();
|
|
30869
31352
|
}
|
|
30870
31353
|
break;
|
|
30871
31354
|
}
|
|
30872
31355
|
case "array": {
|
|
30873
|
-
const prefixItems =
|
|
30874
|
-
const items =
|
|
31356
|
+
const prefixItems = schema2.prefixItems;
|
|
31357
|
+
const items = schema2.items;
|
|
30875
31358
|
if (prefixItems && Array.isArray(prefixItems)) {
|
|
30876
31359
|
const tupleItems = prefixItems.map((item) => convertSchema2(item, ctx));
|
|
30877
31360
|
const rest = items && typeof items === "object" && !Array.isArray(items) ? convertSchema2(items, ctx) : void 0;
|
|
@@ -30880,34 +31363,34 @@ function convertBaseSchema2(schema, ctx) {
|
|
|
30880
31363
|
} else {
|
|
30881
31364
|
zodSchema = z2.tuple(tupleItems);
|
|
30882
31365
|
}
|
|
30883
|
-
if (typeof
|
|
30884
|
-
zodSchema = zodSchema.check(z2.minLength(
|
|
31366
|
+
if (typeof schema2.minItems === "number") {
|
|
31367
|
+
zodSchema = zodSchema.check(z2.minLength(schema2.minItems));
|
|
30885
31368
|
}
|
|
30886
|
-
if (typeof
|
|
30887
|
-
zodSchema = zodSchema.check(z2.maxLength(
|
|
31369
|
+
if (typeof schema2.maxItems === "number") {
|
|
31370
|
+
zodSchema = zodSchema.check(z2.maxLength(schema2.maxItems));
|
|
30888
31371
|
}
|
|
30889
31372
|
} else if (Array.isArray(items)) {
|
|
30890
31373
|
const tupleItems = items.map((item) => convertSchema2(item, ctx));
|
|
30891
|
-
const rest =
|
|
31374
|
+
const rest = schema2.additionalItems && typeof schema2.additionalItems === "object" ? convertSchema2(schema2.additionalItems, ctx) : void 0;
|
|
30892
31375
|
if (rest) {
|
|
30893
31376
|
zodSchema = z2.tuple(tupleItems).rest(rest);
|
|
30894
31377
|
} else {
|
|
30895
31378
|
zodSchema = z2.tuple(tupleItems);
|
|
30896
31379
|
}
|
|
30897
|
-
if (typeof
|
|
30898
|
-
zodSchema = zodSchema.check(z2.minLength(
|
|
31380
|
+
if (typeof schema2.minItems === "number") {
|
|
31381
|
+
zodSchema = zodSchema.check(z2.minLength(schema2.minItems));
|
|
30899
31382
|
}
|
|
30900
|
-
if (typeof
|
|
30901
|
-
zodSchema = zodSchema.check(z2.maxLength(
|
|
31383
|
+
if (typeof schema2.maxItems === "number") {
|
|
31384
|
+
zodSchema = zodSchema.check(z2.maxLength(schema2.maxItems));
|
|
30902
31385
|
}
|
|
30903
31386
|
} else if (items !== void 0) {
|
|
30904
31387
|
const element = convertSchema2(items, ctx);
|
|
30905
31388
|
let arraySchema = z2.array(element);
|
|
30906
|
-
if (typeof
|
|
30907
|
-
arraySchema = arraySchema.min(
|
|
31389
|
+
if (typeof schema2.minItems === "number") {
|
|
31390
|
+
arraySchema = arraySchema.min(schema2.minItems);
|
|
30908
31391
|
}
|
|
30909
|
-
if (typeof
|
|
30910
|
-
arraySchema = arraySchema.max(
|
|
31392
|
+
if (typeof schema2.maxItems === "number") {
|
|
31393
|
+
arraySchema = arraySchema.max(schema2.maxItems);
|
|
30911
31394
|
}
|
|
30912
31395
|
zodSchema = arraySchema;
|
|
30913
31396
|
} else {
|
|
@@ -30920,76 +31403,76 @@ function convertBaseSchema2(schema, ctx) {
|
|
|
30920
31403
|
}
|
|
30921
31404
|
return zodSchema;
|
|
30922
31405
|
}
|
|
30923
|
-
function convertSchema2(
|
|
30924
|
-
if (typeof
|
|
30925
|
-
return
|
|
31406
|
+
function convertSchema2(schema2, ctx) {
|
|
31407
|
+
if (typeof schema2 === "boolean") {
|
|
31408
|
+
return schema2 ? z2.any() : z2.never();
|
|
30926
31409
|
}
|
|
30927
|
-
let baseSchema = convertBaseSchema2(
|
|
30928
|
-
const hasExplicitType =
|
|
30929
|
-
if (
|
|
30930
|
-
const options =
|
|
31410
|
+
let baseSchema = convertBaseSchema2(schema2, ctx);
|
|
31411
|
+
const hasExplicitType = schema2.type || schema2.enum !== void 0 || schema2.const !== void 0;
|
|
31412
|
+
if (schema2.anyOf && Array.isArray(schema2.anyOf)) {
|
|
31413
|
+
const options = schema2.anyOf.map((s) => convertSchema2(s, ctx));
|
|
30931
31414
|
const anyOfUnion = z2.union(options);
|
|
30932
31415
|
baseSchema = hasExplicitType ? z2.intersection(baseSchema, anyOfUnion) : anyOfUnion;
|
|
30933
31416
|
}
|
|
30934
|
-
if (
|
|
30935
|
-
const options =
|
|
31417
|
+
if (schema2.oneOf && Array.isArray(schema2.oneOf)) {
|
|
31418
|
+
const options = schema2.oneOf.map((s) => convertSchema2(s, ctx));
|
|
30936
31419
|
const oneOfUnion = z2.xor(options);
|
|
30937
31420
|
baseSchema = hasExplicitType ? z2.intersection(baseSchema, oneOfUnion) : oneOfUnion;
|
|
30938
31421
|
}
|
|
30939
|
-
if (
|
|
30940
|
-
if (
|
|
31422
|
+
if (schema2.allOf && Array.isArray(schema2.allOf)) {
|
|
31423
|
+
if (schema2.allOf.length === 0) {
|
|
30941
31424
|
baseSchema = hasExplicitType ? baseSchema : z2.any();
|
|
30942
31425
|
} else {
|
|
30943
|
-
let result = hasExplicitType ? baseSchema : convertSchema2(
|
|
31426
|
+
let result = hasExplicitType ? baseSchema : convertSchema2(schema2.allOf[0], ctx);
|
|
30944
31427
|
const startIdx = hasExplicitType ? 0 : 1;
|
|
30945
|
-
for (let i = startIdx; i <
|
|
30946
|
-
result = z2.intersection(result, convertSchema2(
|
|
31428
|
+
for (let i = startIdx; i < schema2.allOf.length; i++) {
|
|
31429
|
+
result = z2.intersection(result, convertSchema2(schema2.allOf[i], ctx));
|
|
30947
31430
|
}
|
|
30948
31431
|
baseSchema = result;
|
|
30949
31432
|
}
|
|
30950
31433
|
}
|
|
30951
|
-
if (
|
|
31434
|
+
if (schema2.nullable === true && ctx.version === "openapi-3.0") {
|
|
30952
31435
|
baseSchema = z2.nullable(baseSchema);
|
|
30953
31436
|
}
|
|
30954
|
-
if (
|
|
31437
|
+
if (schema2.readOnly === true) {
|
|
30955
31438
|
baseSchema = z2.readonly(baseSchema);
|
|
30956
31439
|
}
|
|
30957
|
-
if (
|
|
30958
|
-
baseSchema = baseSchema.default(
|
|
31440
|
+
if (schema2.default !== void 0) {
|
|
31441
|
+
baseSchema = baseSchema.default(schema2.default);
|
|
30959
31442
|
}
|
|
30960
31443
|
const extraMeta = {};
|
|
30961
31444
|
const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
|
|
30962
31445
|
for (const key of coreMetadataKeys) {
|
|
30963
|
-
if (key in
|
|
30964
|
-
extraMeta[key] =
|
|
31446
|
+
if (key in schema2) {
|
|
31447
|
+
extraMeta[key] = schema2[key];
|
|
30965
31448
|
}
|
|
30966
31449
|
}
|
|
30967
31450
|
const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
|
|
30968
31451
|
for (const key of contentMetadataKeys) {
|
|
30969
|
-
if (key in
|
|
30970
|
-
extraMeta[key] =
|
|
31452
|
+
if (key in schema2) {
|
|
31453
|
+
extraMeta[key] = schema2[key];
|
|
30971
31454
|
}
|
|
30972
31455
|
}
|
|
30973
|
-
for (const key of Object.keys(
|
|
31456
|
+
for (const key of Object.keys(schema2)) {
|
|
30974
31457
|
if (!RECOGNIZED_KEYS2.has(key)) {
|
|
30975
|
-
extraMeta[key] =
|
|
31458
|
+
extraMeta[key] = schema2[key];
|
|
30976
31459
|
}
|
|
30977
31460
|
}
|
|
30978
31461
|
if (Object.keys(extraMeta).length > 0) {
|
|
30979
31462
|
ctx.registry.add(baseSchema, extraMeta);
|
|
30980
31463
|
}
|
|
30981
|
-
if (
|
|
30982
|
-
baseSchema = baseSchema.describe(
|
|
31464
|
+
if (schema2.description) {
|
|
31465
|
+
baseSchema = baseSchema.describe(schema2.description);
|
|
30983
31466
|
}
|
|
30984
31467
|
return baseSchema;
|
|
30985
31468
|
}
|
|
30986
|
-
function fromJSONSchema2(
|
|
30987
|
-
if (typeof
|
|
30988
|
-
return
|
|
31469
|
+
function fromJSONSchema2(schema2, params) {
|
|
31470
|
+
if (typeof schema2 === "boolean") {
|
|
31471
|
+
return schema2 ? z2.any() : z2.never();
|
|
30989
31472
|
}
|
|
30990
31473
|
let normalized;
|
|
30991
31474
|
try {
|
|
30992
|
-
normalized = JSON.parse(JSON.stringify(
|
|
31475
|
+
normalized = JSON.parse(JSON.stringify(schema2));
|
|
30993
31476
|
} catch {
|
|
30994
31477
|
throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
|
|
30995
31478
|
}
|
|
@@ -31116,19 +31599,24 @@ var BridgeRequestSchema2 = external_exports2.discriminatedUnion("method", [
|
|
|
31116
31599
|
args: external_exports2.record(external_exports2.string(), external_exports2.unknown())
|
|
31117
31600
|
})
|
|
31118
31601
|
]);
|
|
31602
|
+
var elapsedMs2 = external_exports2.number().nonnegative().optional();
|
|
31119
31603
|
var BridgeResultSchema2 = external_exports2.union([
|
|
31120
31604
|
external_exports2.object({
|
|
31121
31605
|
t: external_exports2.literal("res"),
|
|
31122
31606
|
id: external_exports2.string(),
|
|
31123
31607
|
ok: external_exports2.literal(true),
|
|
31124
|
-
result: external_exports2.unknown()
|
|
31608
|
+
result: external_exports2.unknown(),
|
|
31609
|
+
ms: elapsedMs2
|
|
31125
31610
|
}),
|
|
31126
31611
|
external_exports2.object({
|
|
31127
31612
|
t: external_exports2.literal("res"),
|
|
31128
31613
|
id: external_exports2.string(),
|
|
31129
31614
|
ok: external_exports2.literal(false),
|
|
31130
31615
|
reason: external_exports2.string(),
|
|
31131
|
-
message: external_exports2.string()
|
|
31616
|
+
message: external_exports2.string(),
|
|
31617
|
+
// 🔴 Carried on failure too: the timing of a call that FAILED is exactly
|
|
31618
|
+
// what tells a timeout apart from a refusal.
|
|
31619
|
+
ms: elapsedMs2
|
|
31132
31620
|
})
|
|
31133
31621
|
]);
|
|
31134
31622
|
var BridgeHeartbeatSchema2 = external_exports2.object({
|
|
@@ -31383,7 +31871,12 @@ var TOOL_TIERS2 = Object.freeze({
|
|
|
31383
31871
|
video_image_add_from_gallery: "write",
|
|
31384
31872
|
video_scene_update: "write",
|
|
31385
31873
|
video_background_set: "write",
|
|
31386
|
-
|
|
31874
|
+
// 🔴 destructive, unlike the photo editor's same-named tool. There it
|
|
31875
|
+
// retargets the page you are looking at; here the encoder reads one size off
|
|
31876
|
+
// the first scene and renders the whole video at it, so one wrong value
|
|
31877
|
+
// reflows every scene. Bulk is what makes it destructive, and no tool here
|
|
31878
|
+
// can undo it — the agent has no undo to call.
|
|
31879
|
+
video_canvas_resize: "destructive",
|
|
31387
31880
|
video_scene_reorder: "write",
|
|
31388
31881
|
video_text_add: "write",
|
|
31389
31882
|
video_image_add: "write",
|
|
@@ -31419,6 +31912,12 @@ var TOOL_TIERS2 = Object.freeze({
|
|
|
31419
31912
|
// 🔴 Insertion appends, so it never passes through the overwrite prompt; the
|
|
31420
31913
|
// tier is the only barrier, and the user approves each image's source.
|
|
31421
31914
|
editor_insert_image: "destructive",
|
|
31915
|
+
// 🔴 destructive, and one confirm covers the whole plan on purpose. What the
|
|
31916
|
+
// user approves is "make the post look like this", not each keystroke inside
|
|
31917
|
+
// it — and asking per step would defeat the unattended sequence this exists
|
|
31918
|
+
// for. Reach is the five document-assembly steps; the runner refuses anything
|
|
31919
|
+
// else.
|
|
31920
|
+
editor_apply_manifest: "destructive",
|
|
31422
31921
|
editor_set_title: "write",
|
|
31423
31922
|
editor_undo: "write",
|
|
31424
31923
|
editor_replace: "destructive"
|
|
@@ -31490,7 +31989,14 @@ var REASON_POLICY2 = Object.freeze({
|
|
|
31490
31989
|
editor_busy: Object.freeze({ retryable: false }),
|
|
31491
31990
|
// --- The connection itself must be repaired ---
|
|
31492
31991
|
not_connected: Object.freeze({ retryable: false }),
|
|
31493
|
-
unauthorized: Object.freeze({ retryable: false })
|
|
31992
|
+
unauthorized: Object.freeze({ retryable: false }),
|
|
31993
|
+
// --- Staging: the request must change, except where nobody knows yet ---
|
|
31994
|
+
stale_fence: Object.freeze({ retryable: false }),
|
|
31995
|
+
already_sealed: Object.freeze({ retryable: false }),
|
|
31996
|
+
hash_mismatch: Object.freeze({ retryable: false }),
|
|
31997
|
+
upload_expired: Object.freeze({ retryable: false }),
|
|
31998
|
+
capacity_unavailable: Object.freeze({ retryable: true }),
|
|
31999
|
+
uploads_unproven: Object.freeze({ retryable: true })
|
|
31494
32000
|
});
|
|
31495
32001
|
var BRIDGE_USER_MESSAGES2 = Object.freeze({
|
|
31496
32002
|
/** Tool call arrived while no panel is connected. */
|