yap2app 1.1.3 → 1.1.5
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/bin/cli.bundle.js +503 -486
- package/bin/cli.js +503 -486
- package/bridge.js +147 -18
- package/package.json +1 -1
- package/polyfills.js +48 -5
package/bin/cli.bundle.js
CHANGED
|
@@ -76,12 +76,12 @@ var require_code = __commonJS({
|
|
|
76
76
|
return item === "" || item === '""';
|
|
77
77
|
}
|
|
78
78
|
get str() {
|
|
79
|
-
var
|
|
80
|
-
return (
|
|
79
|
+
var _a3;
|
|
80
|
+
return (_a3 = this._str) !== null && _a3 !== void 0 ? _a3 : this._str = this._items.reduce((s, c) => `${s}${c}`, "");
|
|
81
81
|
}
|
|
82
82
|
get names() {
|
|
83
|
-
var
|
|
84
|
-
return (
|
|
83
|
+
var _a3;
|
|
84
|
+
return (_a3 = this._names) !== null && _a3 !== void 0 ? _a3 : this._names = this._items.reduce((names, c) => {
|
|
85
85
|
if (c instanceof Name)
|
|
86
86
|
names[c.str] = (names[c.str] || 0) + 1;
|
|
87
87
|
return names;
|
|
@@ -227,8 +227,8 @@ var require_scope = __commonJS({
|
|
|
227
227
|
return `${prefix}${ng.index++}`;
|
|
228
228
|
}
|
|
229
229
|
_nameGroup(prefix) {
|
|
230
|
-
var
|
|
231
|
-
if (((_b = (
|
|
230
|
+
var _a3, _b;
|
|
231
|
+
if (((_b = (_a3 = this._parent) === null || _a3 === void 0 ? void 0 : _a3._prefixes) === null || _b === void 0 ? void 0 : _b.has(prefix)) || this._prefixes && !this._prefixes.has(prefix)) {
|
|
232
232
|
throw new Error(`CodeGen: prefix "${prefix}" is not allowed in this scope`);
|
|
233
233
|
}
|
|
234
234
|
return this._names[prefix] = { prefix, index: 0 };
|
|
@@ -261,12 +261,12 @@ var require_scope = __commonJS({
|
|
|
261
261
|
return new ValueScopeName(prefix, this._newName(prefix));
|
|
262
262
|
}
|
|
263
263
|
value(nameOrPrefix, value) {
|
|
264
|
-
var
|
|
264
|
+
var _a3;
|
|
265
265
|
if (value.ref === void 0)
|
|
266
266
|
throw new Error("CodeGen: ref must be passed in value");
|
|
267
267
|
const name = this.toName(nameOrPrefix);
|
|
268
268
|
const { prefix } = name;
|
|
269
|
-
const valueKey = (
|
|
269
|
+
const valueKey = (_a3 = value.key) !== null && _a3 !== void 0 ? _a3 : value.ref;
|
|
270
270
|
let vs = this._values[prefix];
|
|
271
271
|
if (vs) {
|
|
272
272
|
const _name = vs.get(valueKey);
|
|
@@ -584,8 +584,8 @@ var require_codegen = __commonJS({
|
|
|
584
584
|
return this;
|
|
585
585
|
}
|
|
586
586
|
optimizeNames(names, constants) {
|
|
587
|
-
var
|
|
588
|
-
this.else = (
|
|
587
|
+
var _a3;
|
|
588
|
+
this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants);
|
|
589
589
|
if (!(super.optimizeNames(names, constants) || this.else))
|
|
590
590
|
return;
|
|
591
591
|
this.condition = optimizeExpr(this.condition, names, constants);
|
|
@@ -689,16 +689,16 @@ var require_codegen = __commonJS({
|
|
|
689
689
|
return code;
|
|
690
690
|
}
|
|
691
691
|
optimizeNodes() {
|
|
692
|
-
var
|
|
692
|
+
var _a3, _b;
|
|
693
693
|
super.optimizeNodes();
|
|
694
|
-
(
|
|
694
|
+
(_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNodes();
|
|
695
695
|
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
|
|
696
696
|
return this;
|
|
697
697
|
}
|
|
698
698
|
optimizeNames(names, constants) {
|
|
699
|
-
var
|
|
699
|
+
var _a3, _b;
|
|
700
700
|
super.optimizeNames(names, constants);
|
|
701
|
-
(
|
|
701
|
+
(_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants);
|
|
702
702
|
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants);
|
|
703
703
|
return this;
|
|
704
704
|
}
|
|
@@ -1478,8 +1478,8 @@ var require_applicability = __commonJS({
|
|
|
1478
1478
|
}
|
|
1479
1479
|
exports2.shouldUseGroup = shouldUseGroup;
|
|
1480
1480
|
function shouldUseRule(schema, rule) {
|
|
1481
|
-
var
|
|
1482
|
-
return schema[rule.keyword] !== void 0 || ((
|
|
1481
|
+
var _a3;
|
|
1482
|
+
return schema[rule.keyword] !== void 0 || ((_a3 = rule.definition.implements) === null || _a3 === void 0 ? void 0 : _a3.some((kwd) => schema[kwd] !== void 0));
|
|
1483
1483
|
}
|
|
1484
1484
|
exports2.shouldUseRule = shouldUseRule;
|
|
1485
1485
|
}
|
|
@@ -1867,14 +1867,14 @@ var require_keyword = __commonJS({
|
|
|
1867
1867
|
}
|
|
1868
1868
|
exports2.macroKeywordCode = macroKeywordCode;
|
|
1869
1869
|
function funcKeywordCode(cxt, def) {
|
|
1870
|
-
var
|
|
1870
|
+
var _a3;
|
|
1871
1871
|
const { gen, keyword, schema, parentSchema, $data, it } = cxt;
|
|
1872
1872
|
checkAsyncKeyword(it, def);
|
|
1873
1873
|
const validate = !$data && def.compile ? def.compile.call(it.self, schema, parentSchema, it) : def.validate;
|
|
1874
1874
|
const validateRef = useKeyword(gen, keyword, validate);
|
|
1875
1875
|
const valid = gen.let("valid");
|
|
1876
1876
|
cxt.block$data(valid, validateKeyword);
|
|
1877
|
-
cxt.ok((
|
|
1877
|
+
cxt.ok((_a3 = def.valid) !== null && _a3 !== void 0 ? _a3 : valid);
|
|
1878
1878
|
function validateKeyword() {
|
|
1879
1879
|
if (def.errors === false) {
|
|
1880
1880
|
assignValid();
|
|
@@ -1905,8 +1905,8 @@ var require_keyword = __commonJS({
|
|
|
1905
1905
|
gen.assign(valid, (0, codegen_1._)`${_await}${(0, code_1.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def.modifying);
|
|
1906
1906
|
}
|
|
1907
1907
|
function reportErrs(errors) {
|
|
1908
|
-
var
|
|
1909
|
-
gen.if((0, codegen_1.not)((
|
|
1908
|
+
var _a4;
|
|
1909
|
+
gen.if((0, codegen_1.not)((_a4 = def.valid) !== null && _a4 !== void 0 ? _a4 : valid), errors);
|
|
1910
1910
|
}
|
|
1911
1911
|
}
|
|
1912
1912
|
exports2.funcKeywordCode = funcKeywordCode;
|
|
@@ -2874,7 +2874,7 @@ var require_compile = __commonJS({
|
|
|
2874
2874
|
var validate_1 = require_validate();
|
|
2875
2875
|
var SchemaEnv = class {
|
|
2876
2876
|
constructor(env) {
|
|
2877
|
-
var
|
|
2877
|
+
var _a3;
|
|
2878
2878
|
this.refs = {};
|
|
2879
2879
|
this.dynamicAnchors = {};
|
|
2880
2880
|
let schema;
|
|
@@ -2883,7 +2883,7 @@ var require_compile = __commonJS({
|
|
|
2883
2883
|
this.schema = env.schema;
|
|
2884
2884
|
this.schemaId = env.schemaId;
|
|
2885
2885
|
this.root = env.root || this;
|
|
2886
|
-
this.baseId = (
|
|
2886
|
+
this.baseId = (_a3 = env.baseId) !== null && _a3 !== void 0 ? _a3 : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env.schemaId || "$id"]);
|
|
2887
2887
|
this.schemaPath = env.schemaPath;
|
|
2888
2888
|
this.localRefs = env.localRefs;
|
|
2889
2889
|
this.meta = env.meta;
|
|
@@ -2979,14 +2979,14 @@ var require_compile = __commonJS({
|
|
|
2979
2979
|
}
|
|
2980
2980
|
exports2.compileSchema = compileSchema;
|
|
2981
2981
|
function resolveRef(root, baseId, ref) {
|
|
2982
|
-
var
|
|
2982
|
+
var _a3;
|
|
2983
2983
|
ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
|
|
2984
2984
|
const schOrFunc = root.refs[ref];
|
|
2985
2985
|
if (schOrFunc)
|
|
2986
2986
|
return schOrFunc;
|
|
2987
2987
|
let _sch = resolve.call(this, root, ref);
|
|
2988
2988
|
if (_sch === void 0) {
|
|
2989
|
-
const schema = (
|
|
2989
|
+
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
2990
2990
|
const { schemaId } = this.opts;
|
|
2991
2991
|
if (schema)
|
|
2992
2992
|
_sch = new SchemaEnv({ schema, schemaId, root, baseId });
|
|
@@ -3055,8 +3055,8 @@ var require_compile = __commonJS({
|
|
|
3055
3055
|
"definitions"
|
|
3056
3056
|
]);
|
|
3057
3057
|
function getJsonPointer(parsedRef, { baseId, schema, root }) {
|
|
3058
|
-
var
|
|
3059
|
-
if (((
|
|
3058
|
+
var _a3;
|
|
3059
|
+
if (((_a3 = parsedRef.fragment) === null || _a3 === void 0 ? void 0 : _a3[0]) !== "/")
|
|
3060
3060
|
return;
|
|
3061
3061
|
for (const part of parsedRef.fragment.slice(1).split("/")) {
|
|
3062
3062
|
if (typeof schema === "boolean")
|
|
@@ -3551,7 +3551,7 @@ var require_schemes = __commonJS({
|
|
|
3551
3551
|
serialize: httpSerialize
|
|
3552
3552
|
}
|
|
3553
3553
|
);
|
|
3554
|
-
var
|
|
3554
|
+
var https2 = (
|
|
3555
3555
|
/** @type {SchemeHandler} */
|
|
3556
3556
|
{
|
|
3557
3557
|
scheme: "https",
|
|
@@ -3600,7 +3600,7 @@ var require_schemes = __commonJS({
|
|
|
3600
3600
|
/** @type {Record<SchemeName, SchemeHandler>} */
|
|
3601
3601
|
{
|
|
3602
3602
|
http: http2,
|
|
3603
|
-
https,
|
|
3603
|
+
https: https2,
|
|
3604
3604
|
ws,
|
|
3605
3605
|
wss,
|
|
3606
3606
|
urn,
|
|
@@ -4030,9 +4030,9 @@ var require_core = __commonJS({
|
|
|
4030
4030
|
};
|
|
4031
4031
|
var MAX_EXPRESSION = 200;
|
|
4032
4032
|
function requiredOptions(o) {
|
|
4033
|
-
var
|
|
4033
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
4034
4034
|
const s = o.strict;
|
|
4035
|
-
const _optz = (
|
|
4035
|
+
const _optz = (_a3 = o.code) === null || _a3 === void 0 ? void 0 : _a3.optimize;
|
|
4036
4036
|
const optimize = _optz === true || _optz === void 0 ? 1 : _optz || 0;
|
|
4037
4037
|
const regExp = (_c = (_b = o.code) === null || _b === void 0 ? void 0 : _b.regExp) !== null && _c !== void 0 ? _c : defaultRegExp;
|
|
4038
4038
|
const uriResolver = (_d = o.uriResolver) !== null && _d !== void 0 ? _d : uri_1.default;
|
|
@@ -4506,7 +4506,7 @@ var require_core = __commonJS({
|
|
|
4506
4506
|
}
|
|
4507
4507
|
}
|
|
4508
4508
|
function addRule(keyword, definition, dataType) {
|
|
4509
|
-
var
|
|
4509
|
+
var _a3;
|
|
4510
4510
|
const post = definition === null || definition === void 0 ? void 0 : definition.post;
|
|
4511
4511
|
if (dataType && post)
|
|
4512
4512
|
throw new Error('keyword with "post" flag cannot have "type"');
|
|
@@ -4532,7 +4532,7 @@ var require_core = __commonJS({
|
|
|
4532
4532
|
else
|
|
4533
4533
|
ruleGroup.rules.push(rule);
|
|
4534
4534
|
RULES.all[keyword] = rule;
|
|
4535
|
-
(
|
|
4535
|
+
(_a3 = definition.implements) === null || _a3 === void 0 ? void 0 : _a3.forEach((kwd) => this.addKeyword(kwd));
|
|
4536
4536
|
}
|
|
4537
4537
|
function addBeforeRule(ruleGroup, rule, before) {
|
|
4538
4538
|
const i = ruleGroup.rules.findIndex((_rule) => _rule.keyword === before);
|
|
@@ -4666,10 +4666,10 @@ var require_ref = __commonJS({
|
|
|
4666
4666
|
gen.assign(names_1.default.errors, (0, codegen_1._)`${names_1.default.vErrors}.length`);
|
|
4667
4667
|
}
|
|
4668
4668
|
function addEvaluatedFrom(source) {
|
|
4669
|
-
var
|
|
4669
|
+
var _a3;
|
|
4670
4670
|
if (!it.opts.unevaluated)
|
|
4671
4671
|
return;
|
|
4672
|
-
const schEvaluated = (
|
|
4672
|
+
const schEvaluated = (_a3 = sch === null || sch === void 0 ? void 0 : sch.validate) === null || _a3 === void 0 ? void 0 : _a3.evaluated;
|
|
4673
4673
|
if (it.props !== true) {
|
|
4674
4674
|
if (schEvaluated && !schEvaluated.dynamicProps) {
|
|
4675
4675
|
if (schEvaluated.props !== void 0) {
|
|
@@ -6320,7 +6320,7 @@ var require_discriminator = __commonJS({
|
|
|
6320
6320
|
return _valid;
|
|
6321
6321
|
}
|
|
6322
6322
|
function getMapping() {
|
|
6323
|
-
var
|
|
6323
|
+
var _a3;
|
|
6324
6324
|
const oneOfMapping = {};
|
|
6325
6325
|
const topRequired = hasRequired(parentSchema);
|
|
6326
6326
|
let tagRequired = true;
|
|
@@ -6334,7 +6334,7 @@ var require_discriminator = __commonJS({
|
|
|
6334
6334
|
if (sch === void 0)
|
|
6335
6335
|
throw new ref_error_1.default(it.opts.uriResolver, it.baseId, ref);
|
|
6336
6336
|
}
|
|
6337
|
-
const propSch = (
|
|
6337
|
+
const propSch = (_a3 = sch === null || sch === void 0 ? void 0 : sch.properties) === null || _a3 === void 0 ? void 0 : _a3[tagName];
|
|
6338
6338
|
if (typeof propSch != "object") {
|
|
6339
6339
|
throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${tagName}"`);
|
|
6340
6340
|
}
|
|
@@ -6903,9 +6903,9 @@ var require_dist = __commonJS({
|
|
|
6903
6903
|
return f;
|
|
6904
6904
|
};
|
|
6905
6905
|
function addFormats(ajv, list, fs4, exportName) {
|
|
6906
|
-
var
|
|
6906
|
+
var _a3;
|
|
6907
6907
|
var _b;
|
|
6908
|
-
(
|
|
6908
|
+
(_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
6909
6909
|
for (const f of list)
|
|
6910
6910
|
ajv.addFormat(f, fs4[f]);
|
|
6911
6911
|
}
|
|
@@ -6916,6 +6916,25 @@ var require_dist = __commonJS({
|
|
|
6916
6916
|
});
|
|
6917
6917
|
|
|
6918
6918
|
// polyfills.js
|
|
6919
|
+
if (typeof process !== "undefined" && process.emitWarning) {
|
|
6920
|
+
_originalEmitWarning = process.emitWarning;
|
|
6921
|
+
process.emitWarning = function(warning) {
|
|
6922
|
+
if (typeof warning === "string") {
|
|
6923
|
+
if (warning.includes("punycode") || warning.includes("ExperimentalWarning") || warning.includes("DEP0040")) {
|
|
6924
|
+
return;
|
|
6925
|
+
}
|
|
6926
|
+
} else if (warning && typeof warning === "object") {
|
|
6927
|
+
if (warning.code === "DEP0040" || warning.name === "ExperimentalWarning") {
|
|
6928
|
+
return;
|
|
6929
|
+
}
|
|
6930
|
+
if (String(warning.message || "").includes("punycode")) {
|
|
6931
|
+
return;
|
|
6932
|
+
}
|
|
6933
|
+
}
|
|
6934
|
+
return _originalEmitWarning.apply(process, arguments);
|
|
6935
|
+
};
|
|
6936
|
+
}
|
|
6937
|
+
var _originalEmitWarning;
|
|
6919
6938
|
if (typeof globalThis === "undefined") {
|
|
6920
6939
|
if (typeof global !== "undefined") {
|
|
6921
6940
|
global.globalThis = global;
|
|
@@ -6929,8 +6948,9 @@ if (typeof Object.fromEntries === "undefined") {
|
|
|
6929
6948
|
Object.fromEntries = function(entries) {
|
|
6930
6949
|
if (!entries) return {};
|
|
6931
6950
|
var obj = {};
|
|
6932
|
-
|
|
6933
|
-
|
|
6951
|
+
var arr = Array.isArray(entries) ? entries : Array.from(entries);
|
|
6952
|
+
for (var i = 0; i < arr.length; i++) {
|
|
6953
|
+
var pair = arr[i];
|
|
6934
6954
|
if (pair && pair.length >= 2) {
|
|
6935
6955
|
obj[pair[0]] = pair[1];
|
|
6936
6956
|
}
|
|
@@ -6967,6 +6987,25 @@ if (!String.prototype.replaceAll) {
|
|
|
6967
6987
|
return this.split(search).join(replacement);
|
|
6968
6988
|
};
|
|
6969
6989
|
}
|
|
6990
|
+
if (!String.prototype.matchAll) {
|
|
6991
|
+
String.prototype.matchAll = function(regexp) {
|
|
6992
|
+
var flags = regexp.flags;
|
|
6993
|
+
if (!flags.includes("g")) {
|
|
6994
|
+
flags += "g";
|
|
6995
|
+
}
|
|
6996
|
+
var rx = new RegExp(regexp.source, flags);
|
|
6997
|
+
var str = String(this);
|
|
6998
|
+
var matches = [];
|
|
6999
|
+
var match;
|
|
7000
|
+
while ((match = rx.exec(str)) !== null) {
|
|
7001
|
+
matches.push(match);
|
|
7002
|
+
if (match.index === rx.lastIndex) {
|
|
7003
|
+
rx.lastIndex++;
|
|
7004
|
+
}
|
|
7005
|
+
}
|
|
7006
|
+
return matches[Symbol.iterator] ? matches[Symbol.iterator]() : matches;
|
|
7007
|
+
};
|
|
7008
|
+
}
|
|
6970
7009
|
if (!Promise.allSettled) {
|
|
6971
7010
|
Promise.allSettled = function(promises) {
|
|
6972
7011
|
return Promise.all(
|
|
@@ -6986,6 +7025,7 @@ if (!Promise.allSettled) {
|
|
|
6986
7025
|
|
|
6987
7026
|
// bridge.js
|
|
6988
7027
|
var import_http = __toESM(require("http"));
|
|
7028
|
+
var import_https = __toESM(require("https"));
|
|
6989
7029
|
var import_fs2 = __toESM(require("fs"));
|
|
6990
7030
|
var import_path2 = __toESM(require("path"));
|
|
6991
7031
|
var import_util2 = __toESM(require("util"));
|
|
@@ -7369,12 +7409,11 @@ async function extractComponentSignatures(projectRoot, allFiles) {
|
|
|
7369
7409
|
return catalog;
|
|
7370
7410
|
}
|
|
7371
7411
|
function extractPathAliases(manifests) {
|
|
7372
|
-
var _a5;
|
|
7373
7412
|
if (manifests["tsconfig.json"]) {
|
|
7374
7413
|
try {
|
|
7375
7414
|
const cleaned = manifests["tsconfig.json"].replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
7376
7415
|
const parsed = JSON.parse(cleaned);
|
|
7377
|
-
const paths =
|
|
7416
|
+
const paths = parsed.compilerOptions?.paths || {};
|
|
7378
7417
|
const firstKey = Object.keys(paths)[0];
|
|
7379
7418
|
if (firstKey) {
|
|
7380
7419
|
return firstKey.replace("*", "");
|
|
@@ -7532,17 +7571,60 @@ var fs2 = import_fs2.default.promises || {
|
|
|
7532
7571
|
mkdir: import_util2.default.promisify(import_fs2.default.mkdir),
|
|
7533
7572
|
stat: import_util2.default.promisify(import_fs2.default.stat)
|
|
7534
7573
|
};
|
|
7535
|
-
var PORT = process.env.YAP2APP_PORT || 10420;
|
|
7574
|
+
var PORT = Number(process.env.YAP2APP_PORT) || 10420;
|
|
7536
7575
|
var PROJECT_ROOT = process.cwd();
|
|
7576
|
+
var CLOUD_RELAY_URL = process.env.YAP2APP_CLOUD_URL || "https://yap2app-dot-cybage-hackathon.uc.r.appspot.com";
|
|
7577
|
+
var PAIR_CODE = (process.env.YAP2APP_PAIR_CODE || "CYB-" + Math.floor(100 + Math.random() * 900)).toUpperCase();
|
|
7578
|
+
function sendCloudRelayRequest(method, endpoint, payload) {
|
|
7579
|
+
return new Promise((resolve) => {
|
|
7580
|
+
try {
|
|
7581
|
+
const url = new URL(`${CLOUD_RELAY_URL}${endpoint}`);
|
|
7582
|
+
const body = payload ? JSON.stringify(payload) : "";
|
|
7583
|
+
const req = import_https.default.request({
|
|
7584
|
+
hostname: url.hostname,
|
|
7585
|
+
port: 443,
|
|
7586
|
+
path: url.pathname + url.search,
|
|
7587
|
+
method,
|
|
7588
|
+
headers: {
|
|
7589
|
+
"Content-Type": "application/json",
|
|
7590
|
+
"Content-Length": Buffer.byteLength(body),
|
|
7591
|
+
"User-Agent": "yap2app-cli/1.1.5"
|
|
7592
|
+
},
|
|
7593
|
+
timeout: 6e3
|
|
7594
|
+
}, (res) => {
|
|
7595
|
+
let respData = "";
|
|
7596
|
+
res.on("data", (chunk) => respData += chunk);
|
|
7597
|
+
res.on("end", () => {
|
|
7598
|
+
try {
|
|
7599
|
+
resolve({ ok: res.statusCode >= 200 && res.statusCode < 300, status: res.statusCode, data: JSON.parse(respData || "{}") });
|
|
7600
|
+
} catch {
|
|
7601
|
+
resolve({ ok: false, status: res.statusCode, data: null });
|
|
7602
|
+
}
|
|
7603
|
+
});
|
|
7604
|
+
});
|
|
7605
|
+
req.on("error", () => resolve({ ok: false, status: 0, data: null }));
|
|
7606
|
+
req.on("timeout", () => {
|
|
7607
|
+
req.destroy();
|
|
7608
|
+
resolve({ ok: false, status: 0, data: null });
|
|
7609
|
+
});
|
|
7610
|
+
if (body) req.write(body);
|
|
7611
|
+
req.end();
|
|
7612
|
+
} catch {
|
|
7613
|
+
resolve({ ok: false, status: 0, data: null });
|
|
7614
|
+
}
|
|
7615
|
+
});
|
|
7616
|
+
}
|
|
7537
7617
|
function getCorsHeaders(req) {
|
|
7538
|
-
|
|
7539
|
-
const
|
|
7618
|
+
const origin = req?.headers?.origin || "*";
|
|
7619
|
+
const requestedHeaders = req?.headers?.["access-control-request-headers"] || "*";
|
|
7540
7620
|
return {
|
|
7541
7621
|
"Access-Control-Allow-Origin": origin,
|
|
7542
|
-
"Access-Control-Allow-Methods": "GET, POST, OPTIONS, PUT, DELETE, HEAD",
|
|
7543
|
-
"Access-Control-Allow-Headers":
|
|
7622
|
+
"Access-Control-Allow-Methods": "GET, POST, OPTIONS, PUT, DELETE, HEAD, PATCH",
|
|
7623
|
+
"Access-Control-Allow-Headers": requestedHeaders === "*" ? "Content-Type, Authorization, Access-Control-Request-Private-Network, X-Requested-With, Accept, Origin, *" : requestedHeaders,
|
|
7544
7624
|
"Access-Control-Allow-Private-Network": "true",
|
|
7625
|
+
"Access-Control-Allow-Credentials": "true",
|
|
7545
7626
|
"Access-Control-Max-Age": "86400",
|
|
7627
|
+
"Vary": "Origin, Access-Control-Request-Headers, Access-Control-Request-Private-Network",
|
|
7546
7628
|
"Content-Type": "application/json"
|
|
7547
7629
|
};
|
|
7548
7630
|
}
|
|
@@ -7587,22 +7669,32 @@ var server = import_http.default.createServer(async (req, res) => {
|
|
|
7587
7669
|
res.end();
|
|
7588
7670
|
return;
|
|
7589
7671
|
}
|
|
7590
|
-
|
|
7672
|
+
let pathname = "/";
|
|
7673
|
+
let searchParams = new URLSearchParams();
|
|
7674
|
+
try {
|
|
7675
|
+
const parsedUrl = new URL(req.url, `http://${req.headers.host || "127.0.0.1:10420"}`);
|
|
7676
|
+
pathname = parsedUrl.pathname.replace(/\/+$/, "") || "/";
|
|
7677
|
+
searchParams = parsedUrl.searchParams;
|
|
7678
|
+
} catch {
|
|
7679
|
+
pathname = (req.url || "/").split("?")[0].replace(/\/+$/, "") || "/";
|
|
7680
|
+
}
|
|
7681
|
+
if (req.method === "GET" && (pathname === "/" || pathname === "/health" || pathname === "/api/health" || pathname === "/ping" || pathname === "/api/ping")) {
|
|
7591
7682
|
res.writeHead(200, headers);
|
|
7592
7683
|
res.end(JSON.stringify({
|
|
7593
7684
|
status: "healthy",
|
|
7594
7685
|
service: "Yap2App-Localhost-Bridge",
|
|
7595
|
-
version: "1.
|
|
7686
|
+
version: "1.1.5",
|
|
7596
7687
|
port: PORT,
|
|
7688
|
+
pair_code: PAIR_CODE,
|
|
7597
7689
|
project_root: PROJECT_ROOT,
|
|
7598
|
-
project_name: import_path2.default.basename(PROJECT_ROOT)
|
|
7690
|
+
project_name: import_path2.default.basename(PROJECT_ROOT),
|
|
7691
|
+
ready: true
|
|
7599
7692
|
}));
|
|
7600
7693
|
return;
|
|
7601
7694
|
}
|
|
7602
|
-
if (req.method === "GET" &&
|
|
7695
|
+
if (req.method === "GET" && (pathname === "/api/context" || pathname === "/context")) {
|
|
7603
7696
|
try {
|
|
7604
|
-
const
|
|
7605
|
-
const promptQuery = parsedUrl.searchParams.get("q") || "";
|
|
7697
|
+
const promptQuery = searchParams.get("q") || "";
|
|
7606
7698
|
console.log(`[Yap2App Bridge] \u{1F50D} Scanning shallow codebase context in: ${PROJECT_ROOT}${promptQuery ? ` (ranking for query: "${promptQuery}")` : ""}`);
|
|
7607
7699
|
const context = await scanCodebase(PROJECT_ROOT, promptQuery);
|
|
7608
7700
|
res.writeHead(200, headers);
|
|
@@ -7614,7 +7706,7 @@ var server = import_http.default.createServer(async (req, res) => {
|
|
|
7614
7706
|
}
|
|
7615
7707
|
return;
|
|
7616
7708
|
}
|
|
7617
|
-
if (req.method === "POST" &&
|
|
7709
|
+
if (req.method === "POST" && (pathname === "/api/diff" || pathname === "/diff")) {
|
|
7618
7710
|
let body = "";
|
|
7619
7711
|
req.on("data", (chunk) => body += chunk.toString());
|
|
7620
7712
|
req.on("end", async () => {
|
|
@@ -7654,7 +7746,7 @@ var server = import_http.default.createServer(async (req, res) => {
|
|
|
7654
7746
|
});
|
|
7655
7747
|
return;
|
|
7656
7748
|
}
|
|
7657
|
-
if (req.method === "POST" &&
|
|
7749
|
+
if (req.method === "POST" && (pathname === "/api/write" || pathname === "/write")) {
|
|
7658
7750
|
let body = "";
|
|
7659
7751
|
req.on("data", (chunk) => body += chunk.toString());
|
|
7660
7752
|
req.on("end", async () => {
|
|
@@ -7686,21 +7778,83 @@ var server = import_http.default.createServer(async (req, res) => {
|
|
|
7686
7778
|
return;
|
|
7687
7779
|
}
|
|
7688
7780
|
res.writeHead(404, headers);
|
|
7689
|
-
res.end(JSON.stringify({ error: "Endpoint Not Found" }));
|
|
7781
|
+
res.end(JSON.stringify({ error: "Endpoint Not Found", path: pathname }));
|
|
7782
|
+
});
|
|
7783
|
+
server.on("error", (err) => {
|
|
7784
|
+
if (err && err.code === "EADDRINUSE") {
|
|
7785
|
+
console.log(`
|
|
7786
|
+
===============================================================`);
|
|
7787
|
+
console.log(`\u{1F4E1} Localhost port ${PORT} is active. Cloud Relay continues seamlessly!`);
|
|
7788
|
+
console.log(`\u{1F4C1} Active Workspace: ${PROJECT_ROOT}`);
|
|
7789
|
+
console.log(`\u{1F511} Pairing Code: ${PAIR_CODE}`);
|
|
7790
|
+
console.log(`\u{1F310} Web Studio: ${CLOUD_RELAY_URL}`);
|
|
7791
|
+
console.log(`===============================================================
|
|
7792
|
+
`);
|
|
7793
|
+
return;
|
|
7794
|
+
}
|
|
7795
|
+
console.error("[Yap2App Bridge Error]:", err);
|
|
7690
7796
|
});
|
|
7691
|
-
function startBridge(port = PORT) {
|
|
7692
|
-
server.listen(port, () => {
|
|
7797
|
+
async function startBridge(port = PORT) {
|
|
7798
|
+
server.listen(port, "0.0.0.0", () => {
|
|
7693
7799
|
console.log(`
|
|
7694
7800
|
===============================================================`);
|
|
7695
|
-
console.log(`\u{1F680} Yap2App Localhost Bridge &
|
|
7696
|
-
console.log(`\u{1F4E1}
|
|
7801
|
+
console.log(`\u{1F680} Yap2App Localhost Bridge & Telemetry is ACTIVE!`);
|
|
7802
|
+
console.log(`\u{1F4E1} Local Endpoint: http://127.0.0.1:${port}`);
|
|
7697
7803
|
console.log(`\u{1F4C1} Active Workspace: ${PROJECT_ROOT}`);
|
|
7698
|
-
console.log(`\u{
|
|
7804
|
+
console.log(`\u{1F511} Pairing Code: ${PAIR_CODE}`);
|
|
7805
|
+
console.log(`\u{1F310} Connected to Web Studio: ${CLOUD_RELAY_URL}`);
|
|
7806
|
+
console.log(`\u{1F6E1}\uFE0F Enterprise Diff, W3C PNA & Cloud Relay Enabled`);
|
|
7699
7807
|
console.log(`===============================================================
|
|
7700
7808
|
`);
|
|
7701
7809
|
console.log(`Ready for 1-click sync from Yap2App Web Studio UI...
|
|
7702
7810
|
`);
|
|
7703
7811
|
});
|
|
7812
|
+
try {
|
|
7813
|
+
const initialContext = await scanCodebase(PROJECT_ROOT);
|
|
7814
|
+
await sendCloudRelayRequest("POST", "/api/v1/bridge/heartbeat", {
|
|
7815
|
+
pair_code: PAIR_CODE,
|
|
7816
|
+
project_name: import_path2.default.basename(PROJECT_ROOT),
|
|
7817
|
+
project_root: PROJECT_ROOT,
|
|
7818
|
+
framework: initialContext.framework,
|
|
7819
|
+
context: initialContext,
|
|
7820
|
+
version: "1.1.5"
|
|
7821
|
+
});
|
|
7822
|
+
} catch (e) {
|
|
7823
|
+
}
|
|
7824
|
+
setInterval(async () => {
|
|
7825
|
+
try {
|
|
7826
|
+
const context = await scanCodebase(PROJECT_ROOT);
|
|
7827
|
+
const hbResult = await sendCloudRelayRequest("POST", "/api/v1/bridge/heartbeat", {
|
|
7828
|
+
pair_code: PAIR_CODE,
|
|
7829
|
+
project_name: import_path2.default.basename(PROJECT_ROOT),
|
|
7830
|
+
project_root: PROJECT_ROOT,
|
|
7831
|
+
framework: context.framework,
|
|
7832
|
+
context,
|
|
7833
|
+
version: "1.1.5"
|
|
7834
|
+
});
|
|
7835
|
+
if (hbResult && hbResult.data && hbResult.data.pending_writes_count > 0) {
|
|
7836
|
+
const pollResult = await sendCloudRelayRequest("GET", `/api/v1/bridge/poll-writes?pair_code=${PAIR_CODE}`);
|
|
7837
|
+
const tasks = pollResult.data && pollResult.data.pending_tasks || [];
|
|
7838
|
+
for (const task of tasks) {
|
|
7839
|
+
const written = [];
|
|
7840
|
+
for (const file of task.files || []) {
|
|
7841
|
+
const fullPath = import_path2.default.join(PROJECT_ROOT, file.path);
|
|
7842
|
+
await fs2.mkdir(import_path2.default.dirname(fullPath), { recursive: true });
|
|
7843
|
+
await fs2.writeFile(fullPath, file.content, "utf8");
|
|
7844
|
+
console.log(`[Yap2App Bridge] \u270D\uFE0F Wrote approved file: ${file.path}`);
|
|
7845
|
+
written.push(file.path);
|
|
7846
|
+
}
|
|
7847
|
+
await sendCloudRelayRequest("POST", "/api/v1/bridge/complete-write", {
|
|
7848
|
+
task_id: task.task_id,
|
|
7849
|
+
success: true,
|
|
7850
|
+
written,
|
|
7851
|
+
message: `Wrote ${written.length} file(s) directly to ${import_path2.default.basename(PROJECT_ROOT)}`
|
|
7852
|
+
});
|
|
7853
|
+
}
|
|
7854
|
+
}
|
|
7855
|
+
} catch {
|
|
7856
|
+
}
|
|
7857
|
+
}, 3500);
|
|
7704
7858
|
}
|
|
7705
7859
|
var isDirectRun = Boolean(typeof process !== "undefined" && process.argv && process.argv[1] && (process.argv[1].endsWith("bridge.js") || process.argv[1].endsWith("bridge")));
|
|
7706
7860
|
if (isDirectRun) {
|
|
@@ -7711,7 +7865,6 @@ if (isDirectRun) {
|
|
|
7711
7865
|
var _a;
|
|
7712
7866
|
// @__NO_SIDE_EFFECTS__
|
|
7713
7867
|
function $constructor(name, initializer3, params) {
|
|
7714
|
-
var _a5;
|
|
7715
7868
|
function init(inst, def) {
|
|
7716
7869
|
if (!inst._zod) {
|
|
7717
7870
|
Object.defineProperty(inst, "_zod", {
|
|
@@ -7737,16 +7890,15 @@ function $constructor(name, initializer3, params) {
|
|
|
7737
7890
|
}
|
|
7738
7891
|
}
|
|
7739
7892
|
}
|
|
7740
|
-
const Parent =
|
|
7893
|
+
const Parent = params?.Parent ?? Object;
|
|
7741
7894
|
class Definition extends Parent {
|
|
7742
7895
|
}
|
|
7743
7896
|
Object.defineProperty(Definition, "name", { value: name });
|
|
7744
7897
|
function _(def) {
|
|
7745
|
-
var
|
|
7746
|
-
|
|
7747
|
-
const inst = (params == null ? void 0 : params.Parent) ? new Definition() : this;
|
|
7898
|
+
var _a3;
|
|
7899
|
+
const inst = params?.Parent ? new Definition() : this;
|
|
7748
7900
|
init(inst, def);
|
|
7749
|
-
(
|
|
7901
|
+
(_a3 = inst._zod).deferred ?? (_a3.deferred = []);
|
|
7750
7902
|
for (const fn of inst._zod.deferred) {
|
|
7751
7903
|
fn();
|
|
7752
7904
|
}
|
|
@@ -7755,10 +7907,9 @@ function $constructor(name, initializer3, params) {
|
|
|
7755
7907
|
Object.defineProperty(_, "init", { value: init });
|
|
7756
7908
|
Object.defineProperty(_, Symbol.hasInstance, {
|
|
7757
7909
|
value: (inst) => {
|
|
7758
|
-
|
|
7759
|
-
if ((params == null ? void 0 : params.Parent) && inst instanceof params.Parent)
|
|
7910
|
+
if (params?.Parent && inst instanceof params.Parent)
|
|
7760
7911
|
return true;
|
|
7761
|
-
return
|
|
7912
|
+
return inst?._zod?.traits?.has(name);
|
|
7762
7913
|
}
|
|
7763
7914
|
});
|
|
7764
7915
|
Object.defineProperty(_, "name", { value: name });
|
|
@@ -7775,8 +7926,7 @@ var $ZodEncodeError = class extends Error {
|
|
|
7775
7926
|
this.name = "ZodEncodeError";
|
|
7776
7927
|
}
|
|
7777
7928
|
};
|
|
7778
|
-
|
|
7779
|
-
(_a2 = (_a = globalThis).__zod_globalConfig) != null ? _a2 : _a.__zod_globalConfig = {};
|
|
7929
|
+
(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
|
|
7780
7930
|
var globalConfig = globalThis.__zod_globalConfig;
|
|
7781
7931
|
function config(newConfig) {
|
|
7782
7932
|
if (newConfig)
|
|
@@ -7954,7 +8104,7 @@ function cloneDef(schema) {
|
|
|
7954
8104
|
function getElementAtPath(obj, path4) {
|
|
7955
8105
|
if (!path4)
|
|
7956
8106
|
return obj;
|
|
7957
|
-
return path4.reduce((acc, key) => acc
|
|
8107
|
+
return path4.reduce((acc, key) => acc?.[key], obj);
|
|
7958
8108
|
}
|
|
7959
8109
|
function promiseAllObject(promisesObj) {
|
|
7960
8110
|
const keys = Object.keys(promisesObj);
|
|
@@ -7987,11 +8137,10 @@ function isObject(data) {
|
|
|
7987
8137
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
7988
8138
|
}
|
|
7989
8139
|
var allowsEval = /* @__PURE__ */ cached(() => {
|
|
7990
|
-
var _a5;
|
|
7991
8140
|
if (globalConfig.jitless) {
|
|
7992
8141
|
return false;
|
|
7993
8142
|
}
|
|
7994
|
-
if (typeof navigator !== "undefined" &&
|
|
8143
|
+
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
|
|
7995
8144
|
return false;
|
|
7996
8145
|
}
|
|
7997
8146
|
try {
|
|
@@ -8095,8 +8244,8 @@ function escapeRegex(str) {
|
|
|
8095
8244
|
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
8096
8245
|
}
|
|
8097
8246
|
function clone(inst, def, params) {
|
|
8098
|
-
const cl = new inst._zod.constr(def
|
|
8099
|
-
if (!def ||
|
|
8247
|
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
8248
|
+
if (!def || params?.parent)
|
|
8100
8249
|
cl._zod.parent = inst;
|
|
8101
8250
|
return cl;
|
|
8102
8251
|
}
|
|
@@ -8106,8 +8255,8 @@ function normalizeParams(_params) {
|
|
|
8106
8255
|
return {};
|
|
8107
8256
|
if (typeof params === "string")
|
|
8108
8257
|
return { error: () => params };
|
|
8109
|
-
if (
|
|
8110
|
-
if (
|
|
8258
|
+
if (params?.message !== void 0) {
|
|
8259
|
+
if (params?.error !== void 0)
|
|
8111
8260
|
throw new Error("Cannot specify both `message` and `error` params");
|
|
8112
8261
|
params.error = params.message;
|
|
8113
8262
|
}
|
|
@@ -8120,31 +8269,31 @@ function createTransparentProxy(getter) {
|
|
|
8120
8269
|
let target;
|
|
8121
8270
|
return new Proxy({}, {
|
|
8122
8271
|
get(_, prop, receiver) {
|
|
8123
|
-
target
|
|
8272
|
+
target ?? (target = getter());
|
|
8124
8273
|
return Reflect.get(target, prop, receiver);
|
|
8125
8274
|
},
|
|
8126
8275
|
set(_, prop, value, receiver) {
|
|
8127
|
-
target
|
|
8276
|
+
target ?? (target = getter());
|
|
8128
8277
|
return Reflect.set(target, prop, value, receiver);
|
|
8129
8278
|
},
|
|
8130
8279
|
has(_, prop) {
|
|
8131
|
-
target
|
|
8280
|
+
target ?? (target = getter());
|
|
8132
8281
|
return Reflect.has(target, prop);
|
|
8133
8282
|
},
|
|
8134
8283
|
deleteProperty(_, prop) {
|
|
8135
|
-
target
|
|
8284
|
+
target ?? (target = getter());
|
|
8136
8285
|
return Reflect.deleteProperty(target, prop);
|
|
8137
8286
|
},
|
|
8138
8287
|
ownKeys(_) {
|
|
8139
|
-
target
|
|
8288
|
+
target ?? (target = getter());
|
|
8140
8289
|
return Reflect.ownKeys(target);
|
|
8141
8290
|
},
|
|
8142
8291
|
getOwnPropertyDescriptor(_, prop) {
|
|
8143
|
-
target
|
|
8292
|
+
target ?? (target = getter());
|
|
8144
8293
|
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
8145
8294
|
},
|
|
8146
8295
|
defineProperty(_, prop, descriptor) {
|
|
8147
|
-
target
|
|
8296
|
+
target ?? (target = getter());
|
|
8148
8297
|
return Reflect.defineProperty(target, prop, descriptor);
|
|
8149
8298
|
}
|
|
8150
8299
|
});
|
|
@@ -8259,8 +8408,7 @@ function safeExtend(schema, shape) {
|
|
|
8259
8408
|
return clone(schema, def);
|
|
8260
8409
|
}
|
|
8261
8410
|
function merge(a, b) {
|
|
8262
|
-
|
|
8263
|
-
if ((_a5 = a._zod.def.checks) == null ? void 0 : _a5.length) {
|
|
8411
|
+
if (a._zod.def.checks?.length) {
|
|
8264
8412
|
throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
8265
8413
|
}
|
|
8266
8414
|
const def = mergeDefs(a._zod.def, {
|
|
@@ -8272,7 +8420,7 @@ function merge(a, b) {
|
|
|
8272
8420
|
get catchall() {
|
|
8273
8421
|
return b._zod.def.catchall;
|
|
8274
8422
|
},
|
|
8275
|
-
checks:
|
|
8423
|
+
checks: b._zod.def.checks ?? []
|
|
8276
8424
|
});
|
|
8277
8425
|
return clone(a, def);
|
|
8278
8426
|
}
|
|
@@ -8346,22 +8494,20 @@ function required(Class2, schema, mask) {
|
|
|
8346
8494
|
return clone(schema, def);
|
|
8347
8495
|
}
|
|
8348
8496
|
function aborted(x, startIndex = 0) {
|
|
8349
|
-
var _a5;
|
|
8350
8497
|
if (x.aborted === true)
|
|
8351
8498
|
return true;
|
|
8352
8499
|
for (let i = startIndex; i < x.issues.length; i++) {
|
|
8353
|
-
if (
|
|
8500
|
+
if (x.issues[i]?.continue !== true) {
|
|
8354
8501
|
return true;
|
|
8355
8502
|
}
|
|
8356
8503
|
}
|
|
8357
8504
|
return false;
|
|
8358
8505
|
}
|
|
8359
8506
|
function explicitlyAborted(x, startIndex = 0) {
|
|
8360
|
-
var _a5;
|
|
8361
8507
|
if (x.aborted === true)
|
|
8362
8508
|
return true;
|
|
8363
8509
|
for (let i = startIndex; i < x.issues.length; i++) {
|
|
8364
|
-
if (
|
|
8510
|
+
if (x.issues[i]?.continue === false) {
|
|
8365
8511
|
return true;
|
|
8366
8512
|
}
|
|
8367
8513
|
}
|
|
@@ -8369,23 +8515,21 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
8369
8515
|
}
|
|
8370
8516
|
function prefixIssues(path4, issues) {
|
|
8371
8517
|
return issues.map((iss) => {
|
|
8372
|
-
var
|
|
8373
|
-
|
|
8374
|
-
(_a6 = (_a5 = iss).path) != null ? _a6 : _a5.path = [];
|
|
8518
|
+
var _a3;
|
|
8519
|
+
(_a3 = iss).path ?? (_a3.path = []);
|
|
8375
8520
|
iss.path.unshift(path4);
|
|
8376
8521
|
return iss;
|
|
8377
8522
|
});
|
|
8378
8523
|
}
|
|
8379
8524
|
function unwrapMessage(message) {
|
|
8380
|
-
return typeof message === "string" ? message : message
|
|
8525
|
+
return typeof message === "string" ? message : message?.message;
|
|
8381
8526
|
}
|
|
8382
8527
|
function finalizeIssue(iss, ctx, config2) {
|
|
8383
|
-
|
|
8384
|
-
const message = iss.message ? iss.message : (_j = (_i = (_g = (_e = unwrapMessage((_c = (_b = (_a5 = iss.inst) == null ? void 0 : _a5._zod.def) == null ? void 0 : _b.error) == null ? void 0 : _c.call(_b, iss))) != null ? _e : unwrapMessage((_d = ctx == null ? void 0 : ctx.error) == null ? void 0 : _d.call(ctx, iss))) != null ? _g : unwrapMessage((_f = config2.customError) == null ? void 0 : _f.call(config2, iss))) != null ? _i : unwrapMessage((_h = config2.localeError) == null ? void 0 : _h.call(config2, iss))) != null ? _j : "Invalid input";
|
|
8528
|
+
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
|
|
8385
8529
|
const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
|
|
8386
|
-
|
|
8530
|
+
rest.path ?? (rest.path = []);
|
|
8387
8531
|
rest.message = message;
|
|
8388
|
-
if (ctx
|
|
8532
|
+
if (ctx?.reportInput) {
|
|
8389
8533
|
rest.input = _input;
|
|
8390
8534
|
}
|
|
8391
8535
|
return rest;
|
|
@@ -8557,28 +8701,26 @@ function formatError(error2, mapper = (issue2) => issue2.message) {
|
|
|
8557
8701
|
|
|
8558
8702
|
// node_modules/zod/v4/core/parse.js
|
|
8559
8703
|
var _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
8560
|
-
var _a5;
|
|
8561
8704
|
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
8562
8705
|
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
8563
8706
|
if (result instanceof Promise) {
|
|
8564
8707
|
throw new $ZodAsyncError();
|
|
8565
8708
|
}
|
|
8566
8709
|
if (result.issues.length) {
|
|
8567
|
-
const e = new (
|
|
8568
|
-
captureStackTrace(e, _params
|
|
8710
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
8711
|
+
captureStackTrace(e, _params?.callee);
|
|
8569
8712
|
throw e;
|
|
8570
8713
|
}
|
|
8571
8714
|
return result.value;
|
|
8572
8715
|
};
|
|
8573
8716
|
var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
8574
|
-
var _a5;
|
|
8575
8717
|
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
8576
8718
|
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
8577
8719
|
if (result instanceof Promise)
|
|
8578
8720
|
result = await result;
|
|
8579
8721
|
if (result.issues.length) {
|
|
8580
|
-
const e = new (
|
|
8581
|
-
captureStackTrace(e, params
|
|
8722
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
8723
|
+
captureStackTrace(e, params?.callee);
|
|
8582
8724
|
throw e;
|
|
8583
8725
|
}
|
|
8584
8726
|
return result.value;
|
|
@@ -8591,7 +8733,7 @@ var _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
|
8591
8733
|
}
|
|
8592
8734
|
return result.issues.length ? {
|
|
8593
8735
|
success: false,
|
|
8594
|
-
error: new (_Err
|
|
8736
|
+
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
8595
8737
|
} : { success: true, data: result.value };
|
|
8596
8738
|
};
|
|
8597
8739
|
var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
@@ -8683,8 +8825,7 @@ function datetime(args) {
|
|
|
8683
8825
|
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
8684
8826
|
}
|
|
8685
8827
|
var string = (params) => {
|
|
8686
|
-
|
|
8687
|
-
const regex = params ? `[\\s\\S]{${(_a5 = params == null ? void 0 : params.minimum) != null ? _a5 : 0},${(_b = params == null ? void 0 : params.maximum) != null ? _b : ""}}` : `[\\s\\S]*`;
|
|
8828
|
+
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
8688
8829
|
return new RegExp(`^${regex}$`);
|
|
8689
8830
|
};
|
|
8690
8831
|
var integer = /^-?\d+$/;
|
|
@@ -8696,11 +8837,10 @@ var uppercase = /^[^a-z]*$/;
|
|
|
8696
8837
|
|
|
8697
8838
|
// node_modules/zod/v4/core/checks.js
|
|
8698
8839
|
var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
8699
|
-
var
|
|
8700
|
-
|
|
8701
|
-
(_a6 = inst._zod) != null ? _a6 : inst._zod = {};
|
|
8840
|
+
var _a3;
|
|
8841
|
+
inst._zod ?? (inst._zod = {});
|
|
8702
8842
|
inst._zod.def = def;
|
|
8703
|
-
(
|
|
8843
|
+
(_a3 = inst._zod).onattach ?? (_a3.onattach = []);
|
|
8704
8844
|
});
|
|
8705
8845
|
var numericOriginMap = {
|
|
8706
8846
|
number: "number",
|
|
@@ -8711,9 +8851,8 @@ var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst,
|
|
|
8711
8851
|
$ZodCheck.init(inst, def);
|
|
8712
8852
|
const origin = numericOriginMap[typeof def.value];
|
|
8713
8853
|
inst._zod.onattach.push((inst2) => {
|
|
8714
|
-
var _a5;
|
|
8715
8854
|
const bag = inst2._zod.bag;
|
|
8716
|
-
const curr = (
|
|
8855
|
+
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
8717
8856
|
if (def.value < curr) {
|
|
8718
8857
|
if (def.inclusive)
|
|
8719
8858
|
bag.maximum = def.value;
|
|
@@ -8740,9 +8879,8 @@ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan",
|
|
|
8740
8879
|
$ZodCheck.init(inst, def);
|
|
8741
8880
|
const origin = numericOriginMap[typeof def.value];
|
|
8742
8881
|
inst._zod.onattach.push((inst2) => {
|
|
8743
|
-
var _a5;
|
|
8744
8882
|
const bag = inst2._zod.bag;
|
|
8745
|
-
const curr = (
|
|
8883
|
+
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
8746
8884
|
if (def.value > curr) {
|
|
8747
8885
|
if (def.inclusive)
|
|
8748
8886
|
bag.minimum = def.value;
|
|
@@ -8768,9 +8906,8 @@ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan",
|
|
|
8768
8906
|
var $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
8769
8907
|
$ZodCheck.init(inst, def);
|
|
8770
8908
|
inst._zod.onattach.push((inst2) => {
|
|
8771
|
-
var
|
|
8772
|
-
|
|
8773
|
-
(_a6 = (_a5 = inst2._zod.bag).multipleOf) != null ? _a6 : _a5.multipleOf = def.value;
|
|
8909
|
+
var _a3;
|
|
8910
|
+
(_a3 = inst2._zod.bag).multipleOf ?? (_a3.multipleOf = def.value);
|
|
8774
8911
|
});
|
|
8775
8912
|
inst._zod.check = (payload) => {
|
|
8776
8913
|
if (typeof payload.value !== typeof def.value)
|
|
@@ -8789,10 +8926,9 @@ var $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (i
|
|
|
8789
8926
|
};
|
|
8790
8927
|
});
|
|
8791
8928
|
var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat", (inst, def) => {
|
|
8792
|
-
var _a5;
|
|
8793
8929
|
$ZodCheck.init(inst, def);
|
|
8794
8930
|
def.format = def.format || "float64";
|
|
8795
|
-
const isInt =
|
|
8931
|
+
const isInt = def.format?.includes("int");
|
|
8796
8932
|
const origin = isInt ? "int" : "number";
|
|
8797
8933
|
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
8798
8934
|
inst._zod.onattach.push((inst2) => {
|
|
@@ -8869,16 +9005,14 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
8869
9005
|
};
|
|
8870
9006
|
});
|
|
8871
9007
|
var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
8872
|
-
var
|
|
8873
|
-
var _a5;
|
|
9008
|
+
var _a3;
|
|
8874
9009
|
$ZodCheck.init(inst, def);
|
|
8875
|
-
(
|
|
9010
|
+
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
|
|
8876
9011
|
const val = payload.value;
|
|
8877
9012
|
return !nullish(val) && val.length !== void 0;
|
|
8878
|
-
};
|
|
9013
|
+
});
|
|
8879
9014
|
inst._zod.onattach.push((inst2) => {
|
|
8880
|
-
|
|
8881
|
-
const curr = (_a7 = inst2._zod.bag.maximum) != null ? _a7 : Number.POSITIVE_INFINITY;
|
|
9015
|
+
const curr = inst2._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
8882
9016
|
if (def.maximum < curr)
|
|
8883
9017
|
inst2._zod.bag.maximum = def.maximum;
|
|
8884
9018
|
});
|
|
@@ -8900,16 +9034,14 @@ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (ins
|
|
|
8900
9034
|
};
|
|
8901
9035
|
});
|
|
8902
9036
|
var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
8903
|
-
var
|
|
8904
|
-
var _a5;
|
|
9037
|
+
var _a3;
|
|
8905
9038
|
$ZodCheck.init(inst, def);
|
|
8906
|
-
(
|
|
9039
|
+
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
|
|
8907
9040
|
const val = payload.value;
|
|
8908
9041
|
return !nullish(val) && val.length !== void 0;
|
|
8909
|
-
};
|
|
9042
|
+
});
|
|
8910
9043
|
inst._zod.onattach.push((inst2) => {
|
|
8911
|
-
|
|
8912
|
-
const curr = (_a7 = inst2._zod.bag.minimum) != null ? _a7 : Number.NEGATIVE_INFINITY;
|
|
9044
|
+
const curr = inst2._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
8913
9045
|
if (def.minimum > curr)
|
|
8914
9046
|
inst2._zod.bag.minimum = def.minimum;
|
|
8915
9047
|
});
|
|
@@ -8931,13 +9063,12 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
|
|
|
8931
9063
|
};
|
|
8932
9064
|
});
|
|
8933
9065
|
var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
8934
|
-
var
|
|
8935
|
-
var _a5;
|
|
9066
|
+
var _a3;
|
|
8936
9067
|
$ZodCheck.init(inst, def);
|
|
8937
|
-
(
|
|
9068
|
+
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
|
|
8938
9069
|
const val = payload.value;
|
|
8939
9070
|
return !nullish(val) && val.length !== void 0;
|
|
8940
|
-
};
|
|
9071
|
+
});
|
|
8941
9072
|
inst._zod.onattach.push((inst2) => {
|
|
8942
9073
|
const bag = inst2._zod.bag;
|
|
8943
9074
|
bag.minimum = def.length;
|
|
@@ -8963,20 +9094,18 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
|
|
|
8963
9094
|
};
|
|
8964
9095
|
});
|
|
8965
9096
|
var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
8966
|
-
var
|
|
8967
|
-
var _a5, _b;
|
|
9097
|
+
var _a3, _b;
|
|
8968
9098
|
$ZodCheck.init(inst, def);
|
|
8969
9099
|
inst._zod.onattach.push((inst2) => {
|
|
8970
|
-
var _a7;
|
|
8971
9100
|
const bag = inst2._zod.bag;
|
|
8972
9101
|
bag.format = def.format;
|
|
8973
9102
|
if (def.pattern) {
|
|
8974
|
-
|
|
9103
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
8975
9104
|
bag.patterns.add(def.pattern);
|
|
8976
9105
|
}
|
|
8977
9106
|
});
|
|
8978
9107
|
if (def.pattern)
|
|
8979
|
-
(
|
|
9108
|
+
(_a3 = inst._zod).check ?? (_a3.check = (payload) => {
|
|
8980
9109
|
def.pattern.lastIndex = 0;
|
|
8981
9110
|
if (def.pattern.test(payload.value))
|
|
8982
9111
|
return;
|
|
@@ -8989,10 +9118,10 @@ var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat"
|
|
|
8989
9118
|
inst,
|
|
8990
9119
|
continue: !def.abort
|
|
8991
9120
|
});
|
|
8992
|
-
};
|
|
9121
|
+
});
|
|
8993
9122
|
else
|
|
8994
|
-
(
|
|
8995
|
-
};
|
|
9123
|
+
(_b = inst._zod).check ?? (_b.check = () => {
|
|
9124
|
+
});
|
|
8996
9125
|
});
|
|
8997
9126
|
var $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
|
|
8998
9127
|
$ZodCheckStringFormat.init(inst, def);
|
|
@@ -9012,13 +9141,11 @@ var $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def)
|
|
|
9012
9141
|
};
|
|
9013
9142
|
});
|
|
9014
9143
|
var $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
|
|
9015
|
-
|
|
9016
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = lowercase;
|
|
9144
|
+
def.pattern ?? (def.pattern = lowercase);
|
|
9017
9145
|
$ZodCheckStringFormat.init(inst, def);
|
|
9018
9146
|
});
|
|
9019
9147
|
var $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
|
|
9020
|
-
|
|
9021
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = uppercase;
|
|
9148
|
+
def.pattern ?? (def.pattern = uppercase);
|
|
9022
9149
|
$ZodCheckStringFormat.init(inst, def);
|
|
9023
9150
|
});
|
|
9024
9151
|
var $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
@@ -9027,9 +9154,8 @@ var $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst,
|
|
|
9027
9154
|
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
|
|
9028
9155
|
def.pattern = pattern;
|
|
9029
9156
|
inst._zod.onattach.push((inst2) => {
|
|
9030
|
-
var _a5;
|
|
9031
9157
|
const bag = inst2._zod.bag;
|
|
9032
|
-
|
|
9158
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
9033
9159
|
bag.patterns.add(pattern);
|
|
9034
9160
|
});
|
|
9035
9161
|
inst._zod.check = (payload) => {
|
|
@@ -9047,14 +9173,12 @@ var $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst,
|
|
|
9047
9173
|
};
|
|
9048
9174
|
});
|
|
9049
9175
|
var $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
|
|
9050
|
-
var _a5;
|
|
9051
9176
|
$ZodCheck.init(inst, def);
|
|
9052
9177
|
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
9053
|
-
|
|
9178
|
+
def.pattern ?? (def.pattern = pattern);
|
|
9054
9179
|
inst._zod.onattach.push((inst2) => {
|
|
9055
|
-
var _a6;
|
|
9056
9180
|
const bag = inst2._zod.bag;
|
|
9057
|
-
|
|
9181
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
9058
9182
|
bag.patterns.add(pattern);
|
|
9059
9183
|
});
|
|
9060
9184
|
inst._zod.check = (payload) => {
|
|
@@ -9072,14 +9196,12 @@ var $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (i
|
|
|
9072
9196
|
};
|
|
9073
9197
|
});
|
|
9074
9198
|
var $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
|
|
9075
|
-
var _a5;
|
|
9076
9199
|
$ZodCheck.init(inst, def);
|
|
9077
9200
|
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
9078
|
-
|
|
9201
|
+
def.pattern ?? (def.pattern = pattern);
|
|
9079
9202
|
inst._zod.onattach.push((inst2) => {
|
|
9080
|
-
var _a6;
|
|
9081
9203
|
const bag = inst2._zod.bag;
|
|
9082
|
-
|
|
9204
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
9083
9205
|
bag.patterns.add(pattern);
|
|
9084
9206
|
});
|
|
9085
9207
|
inst._zod.check = (payload) => {
|
|
@@ -9131,10 +9253,9 @@ var Doc = class {
|
|
|
9131
9253
|
}
|
|
9132
9254
|
}
|
|
9133
9255
|
compile() {
|
|
9134
|
-
var _a5;
|
|
9135
9256
|
const F = Function;
|
|
9136
|
-
const args = this
|
|
9137
|
-
const content =
|
|
9257
|
+
const args = this?.args;
|
|
9258
|
+
const content = this?.content ?? [``];
|
|
9138
9259
|
const lines = [...content.map((x) => ` ${x}`)];
|
|
9139
9260
|
return new F(...args, lines.join("\n"));
|
|
9140
9261
|
}
|
|
@@ -9149,13 +9270,12 @@ var version = {
|
|
|
9149
9270
|
|
|
9150
9271
|
// node_modules/zod/v4/core/schemas.js
|
|
9151
9272
|
var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
9152
|
-
var
|
|
9153
|
-
|
|
9154
|
-
inst != null ? inst : inst = {};
|
|
9273
|
+
var _a3;
|
|
9274
|
+
inst ?? (inst = {});
|
|
9155
9275
|
inst._zod.def = def;
|
|
9156
9276
|
inst._zod.bag = inst._zod.bag || {};
|
|
9157
9277
|
inst._zod.version = version;
|
|
9158
|
-
const checks = [...
|
|
9278
|
+
const checks = [...inst._zod.def.checks ?? []];
|
|
9159
9279
|
if (inst._zod.traits.has("$ZodCheck")) {
|
|
9160
9280
|
checks.unshift(inst);
|
|
9161
9281
|
}
|
|
@@ -9165,8 +9285,8 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
9165
9285
|
}
|
|
9166
9286
|
}
|
|
9167
9287
|
if (checks.length === 0) {
|
|
9168
|
-
(
|
|
9169
|
-
|
|
9288
|
+
(_a3 = inst._zod).deferred ?? (_a3.deferred = []);
|
|
9289
|
+
inst._zod.deferred?.push(() => {
|
|
9170
9290
|
inst._zod.run = inst._zod.parse;
|
|
9171
9291
|
});
|
|
9172
9292
|
} else {
|
|
@@ -9185,11 +9305,11 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
9185
9305
|
}
|
|
9186
9306
|
const currLen = payload.issues.length;
|
|
9187
9307
|
const _ = ch._zod.check(payload);
|
|
9188
|
-
if (_ instanceof Promise &&
|
|
9308
|
+
if (_ instanceof Promise && ctx?.async === false) {
|
|
9189
9309
|
throw new $ZodAsyncError();
|
|
9190
9310
|
}
|
|
9191
9311
|
if (asyncResult || _ instanceof Promise) {
|
|
9192
|
-
asyncResult = (asyncResult
|
|
9312
|
+
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
9193
9313
|
await _;
|
|
9194
9314
|
const nextLen = payload.issues.length;
|
|
9195
9315
|
if (nextLen === currLen)
|
|
@@ -9249,15 +9369,11 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
9249
9369
|
}
|
|
9250
9370
|
defineLazy(inst, "~standard", () => ({
|
|
9251
9371
|
validate: (value) => {
|
|
9252
|
-
var _a7;
|
|
9253
9372
|
try {
|
|
9254
9373
|
const r = safeParse(inst, value);
|
|
9255
|
-
return r.success ? { value: r.data } : { issues:
|
|
9374
|
+
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
9256
9375
|
} catch (_) {
|
|
9257
|
-
return safeParseAsync(inst, value).then((r) => {
|
|
9258
|
-
var _a8;
|
|
9259
|
-
return r.success ? { value: r.data } : { issues: (_a8 = r.error) == null ? void 0 : _a8.issues };
|
|
9260
|
-
});
|
|
9376
|
+
return safeParseAsync(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
|
|
9261
9377
|
}
|
|
9262
9378
|
},
|
|
9263
9379
|
vendor: "zod",
|
|
@@ -9265,9 +9381,8 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
9265
9381
|
}));
|
|
9266
9382
|
});
|
|
9267
9383
|
var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
9268
|
-
var _a5, _b, _c;
|
|
9269
9384
|
$ZodType.init(inst, def);
|
|
9270
|
-
inst._zod.pattern =
|
|
9385
|
+
inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string(inst._zod.bag);
|
|
9271
9386
|
inst._zod.parse = (payload, _) => {
|
|
9272
9387
|
if (def.coerce)
|
|
9273
9388
|
try {
|
|
@@ -9290,12 +9405,10 @@ var $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, d
|
|
|
9290
9405
|
$ZodString.init(inst, def);
|
|
9291
9406
|
});
|
|
9292
9407
|
var $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
|
|
9293
|
-
|
|
9294
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = guid;
|
|
9408
|
+
def.pattern ?? (def.pattern = guid);
|
|
9295
9409
|
$ZodStringFormat.init(inst, def);
|
|
9296
9410
|
});
|
|
9297
9411
|
var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
|
|
9298
|
-
var _a5, _b;
|
|
9299
9412
|
if (def.version) {
|
|
9300
9413
|
const versionMap = {
|
|
9301
9414
|
v1: 1,
|
|
@@ -9310,23 +9423,21 @@ var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
|
|
|
9310
9423
|
const v = versionMap[def.version];
|
|
9311
9424
|
if (v === void 0)
|
|
9312
9425
|
throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
9313
|
-
|
|
9426
|
+
def.pattern ?? (def.pattern = uuid(v));
|
|
9314
9427
|
} else
|
|
9315
|
-
|
|
9428
|
+
def.pattern ?? (def.pattern = uuid());
|
|
9316
9429
|
$ZodStringFormat.init(inst, def);
|
|
9317
9430
|
});
|
|
9318
9431
|
var $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
|
|
9319
|
-
|
|
9320
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = email;
|
|
9432
|
+
def.pattern ?? (def.pattern = email);
|
|
9321
9433
|
$ZodStringFormat.init(inst, def);
|
|
9322
9434
|
});
|
|
9323
9435
|
var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
9324
9436
|
$ZodStringFormat.init(inst, def);
|
|
9325
9437
|
inst._zod.check = (payload) => {
|
|
9326
|
-
var _a5;
|
|
9327
9438
|
try {
|
|
9328
9439
|
const trimmed = payload.value.trim();
|
|
9329
|
-
if (!def.normalize &&
|
|
9440
|
+
if (!def.normalize && def.protocol?.source === httpProtocol.source) {
|
|
9330
9441
|
if (!/^https?:\/\//i.test(trimmed)) {
|
|
9331
9442
|
payload.issues.push({
|
|
9332
9443
|
code: "invalid_format",
|
|
@@ -9386,69 +9497,56 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
|
9386
9497
|
};
|
|
9387
9498
|
});
|
|
9388
9499
|
var $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
|
|
9389
|
-
|
|
9390
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = emoji();
|
|
9500
|
+
def.pattern ?? (def.pattern = emoji());
|
|
9391
9501
|
$ZodStringFormat.init(inst, def);
|
|
9392
9502
|
});
|
|
9393
9503
|
var $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
|
|
9394
|
-
|
|
9395
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = nanoid;
|
|
9504
|
+
def.pattern ?? (def.pattern = nanoid);
|
|
9396
9505
|
$ZodStringFormat.init(inst, def);
|
|
9397
9506
|
});
|
|
9398
9507
|
var $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
|
|
9399
|
-
|
|
9400
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = cuid;
|
|
9508
|
+
def.pattern ?? (def.pattern = cuid);
|
|
9401
9509
|
$ZodStringFormat.init(inst, def);
|
|
9402
9510
|
});
|
|
9403
9511
|
var $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
|
|
9404
|
-
|
|
9405
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = cuid2;
|
|
9512
|
+
def.pattern ?? (def.pattern = cuid2);
|
|
9406
9513
|
$ZodStringFormat.init(inst, def);
|
|
9407
9514
|
});
|
|
9408
9515
|
var $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
|
|
9409
|
-
|
|
9410
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = ulid;
|
|
9516
|
+
def.pattern ?? (def.pattern = ulid);
|
|
9411
9517
|
$ZodStringFormat.init(inst, def);
|
|
9412
9518
|
});
|
|
9413
9519
|
var $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
|
|
9414
|
-
|
|
9415
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = xid;
|
|
9520
|
+
def.pattern ?? (def.pattern = xid);
|
|
9416
9521
|
$ZodStringFormat.init(inst, def);
|
|
9417
9522
|
});
|
|
9418
9523
|
var $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
|
|
9419
|
-
|
|
9420
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = ksuid;
|
|
9524
|
+
def.pattern ?? (def.pattern = ksuid);
|
|
9421
9525
|
$ZodStringFormat.init(inst, def);
|
|
9422
9526
|
});
|
|
9423
9527
|
var $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
|
|
9424
|
-
|
|
9425
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = datetime(def);
|
|
9528
|
+
def.pattern ?? (def.pattern = datetime(def));
|
|
9426
9529
|
$ZodStringFormat.init(inst, def);
|
|
9427
9530
|
});
|
|
9428
9531
|
var $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
|
|
9429
|
-
|
|
9430
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = date;
|
|
9532
|
+
def.pattern ?? (def.pattern = date);
|
|
9431
9533
|
$ZodStringFormat.init(inst, def);
|
|
9432
9534
|
});
|
|
9433
9535
|
var $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
|
|
9434
|
-
|
|
9435
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = time(def);
|
|
9536
|
+
def.pattern ?? (def.pattern = time(def));
|
|
9436
9537
|
$ZodStringFormat.init(inst, def);
|
|
9437
9538
|
});
|
|
9438
9539
|
var $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
|
|
9439
|
-
|
|
9440
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = duration;
|
|
9540
|
+
def.pattern ?? (def.pattern = duration);
|
|
9441
9541
|
$ZodStringFormat.init(inst, def);
|
|
9442
9542
|
});
|
|
9443
9543
|
var $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
|
|
9444
|
-
|
|
9445
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = ipv4;
|
|
9544
|
+
def.pattern ?? (def.pattern = ipv4);
|
|
9446
9545
|
$ZodStringFormat.init(inst, def);
|
|
9447
9546
|
inst._zod.bag.format = `ipv4`;
|
|
9448
9547
|
});
|
|
9449
9548
|
var $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
|
|
9450
|
-
|
|
9451
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = ipv6;
|
|
9549
|
+
def.pattern ?? (def.pattern = ipv6);
|
|
9452
9550
|
$ZodStringFormat.init(inst, def);
|
|
9453
9551
|
inst._zod.bag.format = `ipv6`;
|
|
9454
9552
|
inst._zod.check = (payload) => {
|
|
@@ -9466,13 +9564,11 @@ var $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
|
|
|
9466
9564
|
};
|
|
9467
9565
|
});
|
|
9468
9566
|
var $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
9469
|
-
|
|
9470
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = cidrv4;
|
|
9567
|
+
def.pattern ?? (def.pattern = cidrv4);
|
|
9471
9568
|
$ZodStringFormat.init(inst, def);
|
|
9472
9569
|
});
|
|
9473
9570
|
var $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
9474
|
-
|
|
9475
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = cidrv6;
|
|
9571
|
+
def.pattern ?? (def.pattern = cidrv6);
|
|
9476
9572
|
$ZodStringFormat.init(inst, def);
|
|
9477
9573
|
inst._zod.check = (payload) => {
|
|
9478
9574
|
const parts = payload.value.split("/");
|
|
@@ -9514,8 +9610,7 @@ function isValidBase64(data) {
|
|
|
9514
9610
|
}
|
|
9515
9611
|
}
|
|
9516
9612
|
var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
9517
|
-
|
|
9518
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = base64;
|
|
9613
|
+
def.pattern ?? (def.pattern = base64);
|
|
9519
9614
|
$ZodStringFormat.init(inst, def);
|
|
9520
9615
|
inst._zod.bag.contentEncoding = "base64";
|
|
9521
9616
|
inst._zod.check = (payload) => {
|
|
@@ -9538,8 +9633,7 @@ function isValidBase64URL(data) {
|
|
|
9538
9633
|
return isValidBase64(padded);
|
|
9539
9634
|
}
|
|
9540
9635
|
var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
|
|
9541
|
-
|
|
9542
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = base64url;
|
|
9636
|
+
def.pattern ?? (def.pattern = base64url);
|
|
9543
9637
|
$ZodStringFormat.init(inst, def);
|
|
9544
9638
|
inst._zod.bag.contentEncoding = "base64url";
|
|
9545
9639
|
inst._zod.check = (payload) => {
|
|
@@ -9555,8 +9649,7 @@ var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) =>
|
|
|
9555
9649
|
};
|
|
9556
9650
|
});
|
|
9557
9651
|
var $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
|
|
9558
|
-
|
|
9559
|
-
(_a5 = def.pattern) != null ? _a5 : def.pattern = e164;
|
|
9652
|
+
def.pattern ?? (def.pattern = e164);
|
|
9560
9653
|
$ZodStringFormat.init(inst, def);
|
|
9561
9654
|
});
|
|
9562
9655
|
function isValidJWT(token, algorithm = null) {
|
|
@@ -9568,7 +9661,7 @@ function isValidJWT(token, algorithm = null) {
|
|
|
9568
9661
|
if (!header)
|
|
9569
9662
|
return false;
|
|
9570
9663
|
const parsedHeader = JSON.parse(atob(header));
|
|
9571
|
-
if ("typ" in parsedHeader &&
|
|
9664
|
+
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
|
|
9572
9665
|
return false;
|
|
9573
9666
|
if (!parsedHeader.alg)
|
|
9574
9667
|
return false;
|
|
@@ -9594,9 +9687,8 @@ var $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
|
|
|
9594
9687
|
};
|
|
9595
9688
|
});
|
|
9596
9689
|
var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
9597
|
-
var _a5;
|
|
9598
9690
|
$ZodType.init(inst, def);
|
|
9599
|
-
inst._zod.pattern =
|
|
9691
|
+
inst._zod.pattern = inst._zod.bag.pattern ?? number;
|
|
9600
9692
|
inst._zod.parse = (payload, _ctx) => {
|
|
9601
9693
|
if (def.coerce)
|
|
9602
9694
|
try {
|
|
@@ -9743,10 +9835,9 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
|
|
|
9743
9835
|
}
|
|
9744
9836
|
}
|
|
9745
9837
|
function normalizeDef(def) {
|
|
9746
|
-
var _a5, _b, _c, _d;
|
|
9747
9838
|
const keys = Object.keys(def.shape);
|
|
9748
9839
|
for (const k of keys) {
|
|
9749
|
-
if (!
|
|
9840
|
+
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
|
|
9750
9841
|
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
9751
9842
|
}
|
|
9752
9843
|
}
|
|
@@ -9799,7 +9890,7 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
9799
9890
|
var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
9800
9891
|
$ZodType.init(inst, def);
|
|
9801
9892
|
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
9802
|
-
if (!
|
|
9893
|
+
if (!desc?.get) {
|
|
9803
9894
|
const sh = def.shape;
|
|
9804
9895
|
Object.defineProperty(def, "shape", {
|
|
9805
9896
|
get: () => {
|
|
@@ -9813,13 +9904,12 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
9813
9904
|
}
|
|
9814
9905
|
const _normalized = cached(() => normalizeDef(def));
|
|
9815
9906
|
defineLazy(inst._zod, "propValues", () => {
|
|
9816
|
-
var _a5;
|
|
9817
9907
|
const shape = def.shape;
|
|
9818
9908
|
const propValues = {};
|
|
9819
9909
|
for (const key in shape) {
|
|
9820
9910
|
const field = shape[key]._zod;
|
|
9821
9911
|
if (field.values) {
|
|
9822
|
-
|
|
9912
|
+
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
9823
9913
|
for (const v of field.values)
|
|
9824
9914
|
propValues[key].add(v);
|
|
9825
9915
|
}
|
|
@@ -9830,7 +9920,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
9830
9920
|
const catchall = def.catchall;
|
|
9831
9921
|
let value;
|
|
9832
9922
|
inst._zod.parse = (payload, ctx) => {
|
|
9833
|
-
value
|
|
9923
|
+
value ?? (value = _normalized.value);
|
|
9834
9924
|
const input = payload.value;
|
|
9835
9925
|
if (!isObject2(input)) {
|
|
9836
9926
|
payload.issues.push({
|
|
@@ -9866,7 +9956,6 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
9866
9956
|
const superParse = inst._zod.parse;
|
|
9867
9957
|
const _normalized = cached(() => normalizeDef(def));
|
|
9868
9958
|
const generateFastpass = (shape) => {
|
|
9869
|
-
var _a5, _b;
|
|
9870
9959
|
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
9871
9960
|
const normalized = _normalized.value;
|
|
9872
9961
|
const parseStr = (key) => {
|
|
@@ -9884,8 +9973,8 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
9884
9973
|
const id = ids[key];
|
|
9885
9974
|
const k = esc(key);
|
|
9886
9975
|
const schema = shape[key];
|
|
9887
|
-
const isOptionalIn =
|
|
9888
|
-
const isOptionalOut =
|
|
9976
|
+
const isOptionalIn = schema?._zod?.optin === "optional";
|
|
9977
|
+
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
9889
9978
|
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
9890
9979
|
if (isOptionalIn && isOptionalOut) {
|
|
9891
9980
|
doc.write(`
|
|
@@ -9967,7 +10056,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
9967
10056
|
const catchall = def.catchall;
|
|
9968
10057
|
let value;
|
|
9969
10058
|
inst._zod.parse = (payload, ctx) => {
|
|
9970
|
-
value
|
|
10059
|
+
value ?? (value = _normalized.value);
|
|
9971
10060
|
const input = payload.value;
|
|
9972
10061
|
if (!isObject2(input)) {
|
|
9973
10062
|
payload.issues.push({
|
|
@@ -9978,7 +10067,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
9978
10067
|
});
|
|
9979
10068
|
return payload;
|
|
9980
10069
|
}
|
|
9981
|
-
if (jit && fastEnabled &&
|
|
10070
|
+
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
|
9982
10071
|
if (!fastpass)
|
|
9983
10072
|
fastpass = generateFastpass(def.shape);
|
|
9984
10073
|
payload = fastpass(payload, ctx);
|
|
@@ -10075,11 +10164,10 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
10075
10164
|
return propValues;
|
|
10076
10165
|
});
|
|
10077
10166
|
const disc = cached(() => {
|
|
10078
|
-
var _a5;
|
|
10079
10167
|
const opts = def.options;
|
|
10080
10168
|
const map = /* @__PURE__ */ new Map();
|
|
10081
10169
|
for (const o of opts) {
|
|
10082
|
-
const values =
|
|
10170
|
+
const values = o._zod.propValues?.[def.discriminator];
|
|
10083
10171
|
if (!values || values.size === 0)
|
|
10084
10172
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
10085
10173
|
for (const v of values) {
|
|
@@ -10102,7 +10190,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
10102
10190
|
});
|
|
10103
10191
|
return payload;
|
|
10104
10192
|
}
|
|
10105
|
-
const opt = disc.value.get(input
|
|
10193
|
+
const opt = disc.value.get(input?.[def.discriminator]);
|
|
10106
10194
|
if (opt) {
|
|
10107
10195
|
return opt._zod.run(payload, ctx);
|
|
10108
10196
|
}
|
|
@@ -10186,7 +10274,7 @@ function handleIntersectionResults(result, left, right) {
|
|
|
10186
10274
|
let unrecIssue;
|
|
10187
10275
|
for (const iss of left.issues) {
|
|
10188
10276
|
if (iss.code === "unrecognized_keys") {
|
|
10189
|
-
unrecIssue
|
|
10277
|
+
unrecIssue ?? (unrecIssue = iss);
|
|
10190
10278
|
for (const k of iss.keys) {
|
|
10191
10279
|
if (!unrecKeys.has(k))
|
|
10192
10280
|
unrecKeys.set(k, {});
|
|
@@ -10276,7 +10364,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
10276
10364
|
let unrecognized;
|
|
10277
10365
|
for (const key in input) {
|
|
10278
10366
|
if (!recordKeys.has(key)) {
|
|
10279
|
-
unrecognized = unrecognized
|
|
10367
|
+
unrecognized = unrecognized ?? [];
|
|
10280
10368
|
unrecognized.push(key);
|
|
10281
10369
|
}
|
|
10282
10370
|
}
|
|
@@ -10609,14 +10697,8 @@ var $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
|
|
|
10609
10697
|
$ZodType.init(inst, def);
|
|
10610
10698
|
defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
10611
10699
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
10612
|
-
defineLazy(inst._zod, "optin", () =>
|
|
10613
|
-
|
|
10614
|
-
return (_b = (_a5 = def.innerType) == null ? void 0 : _a5._zod) == null ? void 0 : _b.optin;
|
|
10615
|
-
});
|
|
10616
|
-
defineLazy(inst._zod, "optout", () => {
|
|
10617
|
-
var _a5, _b;
|
|
10618
|
-
return (_b = (_a5 = def.innerType) == null ? void 0 : _a5._zod) == null ? void 0 : _b.optout;
|
|
10619
|
-
});
|
|
10700
|
+
defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
|
|
10701
|
+
defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
|
|
10620
10702
|
inst._zod.parse = (payload, ctx) => {
|
|
10621
10703
|
if (ctx.direction === "backward") {
|
|
10622
10704
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -10649,14 +10731,13 @@ var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
|
10649
10731
|
};
|
|
10650
10732
|
});
|
|
10651
10733
|
function handleRefineResult(result, payload, input, inst) {
|
|
10652
|
-
var _a5;
|
|
10653
10734
|
if (!result) {
|
|
10654
10735
|
const _iss = {
|
|
10655
10736
|
code: "custom",
|
|
10656
10737
|
input,
|
|
10657
10738
|
inst,
|
|
10658
10739
|
// incorporates params.error into issue reporting
|
|
10659
|
-
path: [...
|
|
10740
|
+
path: [...inst._zod.def.path ?? []],
|
|
10660
10741
|
// incorporates params.error into issue reporting
|
|
10661
10742
|
continue: !inst._zod.def.abort
|
|
10662
10743
|
// params: inst._zod.def.params,
|
|
@@ -10677,8 +10758,7 @@ var error = () => {
|
|
|
10677
10758
|
map: { unit: "entries", verb: "to have" }
|
|
10678
10759
|
};
|
|
10679
10760
|
function getSizing(origin) {
|
|
10680
|
-
|
|
10681
|
-
return (_a5 = Sizable[origin]) != null ? _a5 : null;
|
|
10761
|
+
return Sizable[origin] ?? null;
|
|
10682
10762
|
}
|
|
10683
10763
|
const FormatDictionary = {
|
|
10684
10764
|
regex: "input",
|
|
@@ -10717,12 +10797,11 @@ var error = () => {
|
|
|
10717
10797
|
// All other type names omitted - they fall back to raw values via ?? operator
|
|
10718
10798
|
};
|
|
10719
10799
|
return (issue2) => {
|
|
10720
|
-
var _a5, _b, _c, _d, _e, _f;
|
|
10721
10800
|
switch (issue2.code) {
|
|
10722
10801
|
case "invalid_type": {
|
|
10723
|
-
const expected =
|
|
10802
|
+
const expected = TypeDictionary[issue2.expected] ?? issue2.expected;
|
|
10724
10803
|
const receivedType = parsedType(issue2.input);
|
|
10725
|
-
const received =
|
|
10804
|
+
const received = TypeDictionary[receivedType] ?? receivedType;
|
|
10726
10805
|
return `Invalid input: expected ${expected}, received ${received}`;
|
|
10727
10806
|
}
|
|
10728
10807
|
case "invalid_value":
|
|
@@ -10733,8 +10812,8 @@ var error = () => {
|
|
|
10733
10812
|
const adj = issue2.inclusive ? "<=" : "<";
|
|
10734
10813
|
const sizing = getSizing(issue2.origin);
|
|
10735
10814
|
if (sizing)
|
|
10736
|
-
return `Too big: expected ${
|
|
10737
|
-
return `Too big: expected ${
|
|
10815
|
+
return `Too big: expected ${issue2.origin ?? "value"} to have ${adj}${issue2.maximum.toString()} ${sizing.unit ?? "elements"}`;
|
|
10816
|
+
return `Too big: expected ${issue2.origin ?? "value"} to be ${adj}${issue2.maximum.toString()}`;
|
|
10738
10817
|
}
|
|
10739
10818
|
case "too_small": {
|
|
10740
10819
|
const adj = issue2.inclusive ? ">=" : ">";
|
|
@@ -10755,7 +10834,7 @@ var error = () => {
|
|
|
10755
10834
|
return `Invalid string: must include "${_issue.includes}"`;
|
|
10756
10835
|
if (_issue.format === "regex")
|
|
10757
10836
|
return `Invalid string: must match pattern ${_issue.pattern}`;
|
|
10758
|
-
return `Invalid ${
|
|
10837
|
+
return `Invalid ${FormatDictionary[_issue.format] ?? issue2.format}`;
|
|
10759
10838
|
}
|
|
10760
10839
|
case "not_multiple_of":
|
|
10761
10840
|
return `Invalid number: must be a multiple of ${issue2.divisor}`;
|
|
@@ -10783,7 +10862,7 @@ function en_default() {
|
|
|
10783
10862
|
}
|
|
10784
10863
|
|
|
10785
10864
|
// node_modules/zod/v4/core/registries.js
|
|
10786
|
-
var
|
|
10865
|
+
var _a2;
|
|
10787
10866
|
var $ZodRegistry = class {
|
|
10788
10867
|
constructor() {
|
|
10789
10868
|
this._map = /* @__PURE__ */ new WeakMap();
|
|
@@ -10811,10 +10890,9 @@ var $ZodRegistry = class {
|
|
|
10811
10890
|
return this;
|
|
10812
10891
|
}
|
|
10813
10892
|
get(schema) {
|
|
10814
|
-
var _a5;
|
|
10815
10893
|
const p = schema._zod.parent;
|
|
10816
10894
|
if (p) {
|
|
10817
|
-
const pm = { ...
|
|
10895
|
+
const pm = { ...this.get(p) ?? {} };
|
|
10818
10896
|
delete pm.id;
|
|
10819
10897
|
const f = { ...pm, ...this._map.get(schema) };
|
|
10820
10898
|
return Object.keys(f).length ? f : void 0;
|
|
@@ -10828,8 +10906,7 @@ var $ZodRegistry = class {
|
|
|
10828
10906
|
function registry() {
|
|
10829
10907
|
return new $ZodRegistry();
|
|
10830
10908
|
}
|
|
10831
|
-
|
|
10832
|
-
(_a4 = (_a3 = globalThis).__zod_globalRegistry) != null ? _a4 : _a3.__zod_globalRegistry = registry();
|
|
10909
|
+
(_a2 = globalThis).__zod_globalRegistry ?? (_a2.__zod_globalRegistry = registry());
|
|
10833
10910
|
var globalRegistry = globalThis.__zod_globalRegistry;
|
|
10834
10911
|
|
|
10835
10912
|
// node_modules/zod/v4/core/api.js
|
|
@@ -11309,9 +11386,8 @@ function _array(Class2, element, params) {
|
|
|
11309
11386
|
}
|
|
11310
11387
|
// @__NO_SIDE_EFFECTS__
|
|
11311
11388
|
function _custom(Class2, fn, _params) {
|
|
11312
|
-
var _a5;
|
|
11313
11389
|
const norm = normalizeParams(_params);
|
|
11314
|
-
|
|
11390
|
+
norm.abort ?? (norm.abort = true);
|
|
11315
11391
|
const schema = new Class2({
|
|
11316
11392
|
type: "custom",
|
|
11317
11393
|
check: "custom",
|
|
@@ -11334,17 +11410,16 @@ function _refine(Class2, fn, _params) {
|
|
|
11334
11410
|
function _superRefine(fn, params) {
|
|
11335
11411
|
const ch = /* @__PURE__ */ _check((payload) => {
|
|
11336
11412
|
payload.addIssue = (issue2) => {
|
|
11337
|
-
var _a5, _b, _c, _d;
|
|
11338
11413
|
if (typeof issue2 === "string") {
|
|
11339
11414
|
payload.issues.push(issue(issue2, payload.value, ch._zod.def));
|
|
11340
11415
|
} else {
|
|
11341
11416
|
const _issue = issue2;
|
|
11342
11417
|
if (_issue.fatal)
|
|
11343
11418
|
_issue.continue = false;
|
|
11344
|
-
|
|
11345
|
-
|
|
11346
|
-
|
|
11347
|
-
|
|
11419
|
+
_issue.code ?? (_issue.code = "custom");
|
|
11420
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
11421
|
+
_issue.inst ?? (_issue.inst = ch);
|
|
11422
|
+
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
11348
11423
|
payload.issues.push(issue(_issue));
|
|
11349
11424
|
}
|
|
11350
11425
|
};
|
|
@@ -11364,30 +11439,28 @@ function _check(fn, params) {
|
|
|
11364
11439
|
|
|
11365
11440
|
// node_modules/zod/v4/core/to-json-schema.js
|
|
11366
11441
|
function initializeContext(params) {
|
|
11367
|
-
|
|
11368
|
-
let target = (_a5 = params == null ? void 0 : params.target) != null ? _a5 : "draft-2020-12";
|
|
11442
|
+
let target = params?.target ?? "draft-2020-12";
|
|
11369
11443
|
if (target === "draft-4")
|
|
11370
11444
|
target = "draft-04";
|
|
11371
11445
|
if (target === "draft-7")
|
|
11372
11446
|
target = "draft-07";
|
|
11373
11447
|
return {
|
|
11374
|
-
processors:
|
|
11375
|
-
metadataRegistry:
|
|
11448
|
+
processors: params.processors ?? {},
|
|
11449
|
+
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
11376
11450
|
target,
|
|
11377
|
-
unrepresentable:
|
|
11378
|
-
override:
|
|
11451
|
+
unrepresentable: params?.unrepresentable ?? "throw",
|
|
11452
|
+
override: params?.override ?? (() => {
|
|
11379
11453
|
}),
|
|
11380
|
-
io:
|
|
11454
|
+
io: params?.io ?? "output",
|
|
11381
11455
|
counter: 0,
|
|
11382
11456
|
seen: /* @__PURE__ */ new Map(),
|
|
11383
|
-
cycles:
|
|
11384
|
-
reused:
|
|
11385
|
-
external:
|
|
11457
|
+
cycles: params?.cycles ?? "ref",
|
|
11458
|
+
reused: params?.reused ?? "inline",
|
|
11459
|
+
external: params?.external ?? void 0
|
|
11386
11460
|
};
|
|
11387
11461
|
}
|
|
11388
11462
|
function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
11389
|
-
var
|
|
11390
|
-
var _a5;
|
|
11463
|
+
var _a3;
|
|
11391
11464
|
const def = schema._zod.def;
|
|
11392
11465
|
const seen = ctx.seen.get(schema);
|
|
11393
11466
|
if (seen) {
|
|
@@ -11400,7 +11473,7 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
11400
11473
|
}
|
|
11401
11474
|
const result = { schema: {}, count: 1, cycle: void 0, path: _params.path };
|
|
11402
11475
|
ctx.seen.set(schema, result);
|
|
11403
|
-
const overrideSchema =
|
|
11476
|
+
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
11404
11477
|
if (overrideSchema) {
|
|
11405
11478
|
result.schema = overrideSchema;
|
|
11406
11479
|
} else {
|
|
@@ -11435,19 +11508,18 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
11435
11508
|
delete result.schema.default;
|
|
11436
11509
|
}
|
|
11437
11510
|
if (ctx.io === "input" && "_prefault" in result.schema)
|
|
11438
|
-
(
|
|
11511
|
+
(_a3 = result.schema).default ?? (_a3.default = result.schema._prefault);
|
|
11439
11512
|
delete result.schema._prefault;
|
|
11440
11513
|
const _result = ctx.seen.get(schema);
|
|
11441
11514
|
return _result.schema;
|
|
11442
11515
|
}
|
|
11443
11516
|
function extractDefs(ctx, schema) {
|
|
11444
|
-
var _a5, _b, _c, _d;
|
|
11445
11517
|
const root = ctx.seen.get(schema);
|
|
11446
11518
|
if (!root)
|
|
11447
11519
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
11448
11520
|
const idToSchema = /* @__PURE__ */ new Map();
|
|
11449
11521
|
for (const entry of ctx.seen.entries()) {
|
|
11450
|
-
const id =
|
|
11522
|
+
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
11451
11523
|
if (id) {
|
|
11452
11524
|
const existing = idToSchema.get(id);
|
|
11453
11525
|
if (existing && existing !== entry[0]) {
|
|
@@ -11457,15 +11529,14 @@ function extractDefs(ctx, schema) {
|
|
|
11457
11529
|
}
|
|
11458
11530
|
}
|
|
11459
11531
|
const makeURI = (entry) => {
|
|
11460
|
-
var _a6, _b2, _c2, _d2, _e;
|
|
11461
11532
|
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
11462
11533
|
if (ctx.external) {
|
|
11463
|
-
const externalId =
|
|
11464
|
-
const uriGenerator =
|
|
11534
|
+
const externalId = ctx.external.registry.get(entry[0])?.id;
|
|
11535
|
+
const uriGenerator = ctx.external.uri ?? ((id2) => id2);
|
|
11465
11536
|
if (externalId) {
|
|
11466
11537
|
return { ref: uriGenerator(externalId) };
|
|
11467
11538
|
}
|
|
11468
|
-
const id =
|
|
11539
|
+
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
11469
11540
|
entry[1].defId = id;
|
|
11470
11541
|
return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
|
|
11471
11542
|
}
|
|
@@ -11474,7 +11545,7 @@ function extractDefs(ctx, schema) {
|
|
|
11474
11545
|
}
|
|
11475
11546
|
const uriPrefix = `#`;
|
|
11476
11547
|
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
|
11477
|
-
const defId =
|
|
11548
|
+
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
11478
11549
|
return { defId, ref: defUriPrefix + defId };
|
|
11479
11550
|
};
|
|
11480
11551
|
const extractToDef = (entry) => {
|
|
@@ -11496,7 +11567,7 @@ function extractDefs(ctx, schema) {
|
|
|
11496
11567
|
for (const entry of ctx.seen.entries()) {
|
|
11497
11568
|
const seen = entry[1];
|
|
11498
11569
|
if (seen.cycle) {
|
|
11499
|
-
throw new Error(`Cycle detected: #/${
|
|
11570
|
+
throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
|
|
11500
11571
|
|
|
11501
11572
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
|
|
11502
11573
|
}
|
|
@@ -11509,13 +11580,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11509
11580
|
continue;
|
|
11510
11581
|
}
|
|
11511
11582
|
if (ctx.external) {
|
|
11512
|
-
const ext =
|
|
11583
|
+
const ext = ctx.external.registry.get(entry[0])?.id;
|
|
11513
11584
|
if (schema !== entry[0] && ext) {
|
|
11514
11585
|
extractToDef(entry);
|
|
11515
11586
|
continue;
|
|
11516
11587
|
}
|
|
11517
11588
|
}
|
|
11518
|
-
const id =
|
|
11589
|
+
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
11519
11590
|
if (id) {
|
|
11520
11591
|
extractToDef(entry);
|
|
11521
11592
|
continue;
|
|
@@ -11533,16 +11604,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11533
11604
|
}
|
|
11534
11605
|
}
|
|
11535
11606
|
function finalize(ctx, schema) {
|
|
11536
|
-
var _a5, _b, _c, _d, _e, _f;
|
|
11537
11607
|
const root = ctx.seen.get(schema);
|
|
11538
11608
|
if (!root)
|
|
11539
11609
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
11540
11610
|
const flattenRef = (zodSchema) => {
|
|
11541
|
-
var _a6, _b2, _c2;
|
|
11542
11611
|
const seen = ctx.seen.get(zodSchema);
|
|
11543
11612
|
if (seen.ref === null)
|
|
11544
11613
|
return;
|
|
11545
|
-
const schema2 =
|
|
11614
|
+
const schema2 = seen.def ?? seen.schema;
|
|
11546
11615
|
const _cached = { ...schema2 };
|
|
11547
11616
|
const ref = seen.ref;
|
|
11548
11617
|
seen.ref = null;
|
|
@@ -11551,7 +11620,7 @@ function finalize(ctx, schema) {
|
|
|
11551
11620
|
const refSeen = ctx.seen.get(ref);
|
|
11552
11621
|
const refSchema = refSeen.schema;
|
|
11553
11622
|
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
11554
|
-
schema2.allOf =
|
|
11623
|
+
schema2.allOf = schema2.allOf ?? [];
|
|
11555
11624
|
schema2.allOf.push(refSchema);
|
|
11556
11625
|
} else {
|
|
11557
11626
|
Object.assign(schema2, refSchema);
|
|
@@ -11581,7 +11650,7 @@ function finalize(ctx, schema) {
|
|
|
11581
11650
|
if (parent && parent !== ref) {
|
|
11582
11651
|
flattenRef(parent);
|
|
11583
11652
|
const parentSeen = ctx.seen.get(parent);
|
|
11584
|
-
if (parentSeen
|
|
11653
|
+
if (parentSeen?.schema.$ref) {
|
|
11585
11654
|
schema2.$ref = parentSeen.schema.$ref;
|
|
11586
11655
|
if (parentSeen.def) {
|
|
11587
11656
|
for (const key in schema2) {
|
|
@@ -11597,7 +11666,7 @@ function finalize(ctx, schema) {
|
|
|
11597
11666
|
ctx.override({
|
|
11598
11667
|
zodSchema,
|
|
11599
11668
|
jsonSchema: schema2,
|
|
11600
|
-
path:
|
|
11669
|
+
path: seen.path ?? []
|
|
11601
11670
|
});
|
|
11602
11671
|
};
|
|
11603
11672
|
for (const entry of [...ctx.seen.entries()].reverse()) {
|
|
@@ -11613,17 +11682,17 @@ function finalize(ctx, schema) {
|
|
|
11613
11682
|
} else if (ctx.target === "openapi-3.0") {
|
|
11614
11683
|
} else {
|
|
11615
11684
|
}
|
|
11616
|
-
if (
|
|
11617
|
-
const id =
|
|
11685
|
+
if (ctx.external?.uri) {
|
|
11686
|
+
const id = ctx.external.registry.get(schema)?.id;
|
|
11618
11687
|
if (!id)
|
|
11619
11688
|
throw new Error("Schema is missing an `id` property");
|
|
11620
11689
|
result.$id = ctx.external.uri(id);
|
|
11621
11690
|
}
|
|
11622
|
-
Object.assign(result,
|
|
11623
|
-
const rootMetaId =
|
|
11691
|
+
Object.assign(result, root.def ?? root.schema);
|
|
11692
|
+
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
11624
11693
|
if (rootMetaId !== void 0 && result.id === rootMetaId)
|
|
11625
11694
|
delete result.id;
|
|
11626
|
-
const defs =
|
|
11695
|
+
const defs = ctx.external?.defs ?? {};
|
|
11627
11696
|
for (const entry of ctx.seen.entries()) {
|
|
11628
11697
|
const seen = entry[1];
|
|
11629
11698
|
if (seen.def && seen.defId) {
|
|
@@ -11661,7 +11730,7 @@ function finalize(ctx, schema) {
|
|
|
11661
11730
|
}
|
|
11662
11731
|
}
|
|
11663
11732
|
function isTransforming(_schema, _ctx) {
|
|
11664
|
-
const ctx = _ctx
|
|
11733
|
+
const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
|
|
11665
11734
|
if (ctx.seen.has(_schema))
|
|
11666
11735
|
return false;
|
|
11667
11736
|
ctx.seen.add(_schema);
|
|
@@ -11720,8 +11789,8 @@ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
|
11720
11789
|
return finalize(ctx, schema);
|
|
11721
11790
|
};
|
|
11722
11791
|
var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
11723
|
-
const { libraryOptions, target } = params
|
|
11724
|
-
const ctx = initializeContext({ ...libraryOptions
|
|
11792
|
+
const { libraryOptions, target } = params ?? {};
|
|
11793
|
+
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
11725
11794
|
process2(schema, ctx);
|
|
11726
11795
|
extractDefs(ctx, schema);
|
|
11727
11796
|
return finalize(ctx, schema);
|
|
@@ -11737,7 +11806,6 @@ var formatMap = {
|
|
|
11737
11806
|
// do not set
|
|
11738
11807
|
};
|
|
11739
11808
|
var stringProcessor = (schema, ctx, _json, _params) => {
|
|
11740
|
-
var _a5;
|
|
11741
11809
|
const json = _json;
|
|
11742
11810
|
json.type = "string";
|
|
11743
11811
|
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
|
|
@@ -11746,7 +11814,7 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
11746
11814
|
if (typeof maximum === "number")
|
|
11747
11815
|
json.maxLength = maximum;
|
|
11748
11816
|
if (format) {
|
|
11749
|
-
json.format =
|
|
11817
|
+
json.format = formatMap[format] ?? format;
|
|
11750
11818
|
if (json.format === "")
|
|
11751
11819
|
delete json.format;
|
|
11752
11820
|
if (format === "time") {
|
|
@@ -11776,8 +11844,8 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
11776
11844
|
json.type = "integer";
|
|
11777
11845
|
else
|
|
11778
11846
|
json.type = "number";
|
|
11779
|
-
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum
|
|
11780
|
-
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum
|
|
11847
|
+
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
11848
|
+
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
11781
11849
|
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
11782
11850
|
if (exMin) {
|
|
11783
11851
|
if (legacy) {
|
|
@@ -11893,7 +11961,6 @@ var arrayProcessor = (schema, ctx, _json, params) => {
|
|
|
11893
11961
|
});
|
|
11894
11962
|
};
|
|
11895
11963
|
var objectProcessor = (schema, ctx, _json, params) => {
|
|
11896
|
-
var _a5;
|
|
11897
11964
|
const json = _json;
|
|
11898
11965
|
const def = schema._zod.def;
|
|
11899
11966
|
json.type = "object";
|
|
@@ -11917,7 +11984,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
11917
11984
|
if (requiredKeys.size > 0) {
|
|
11918
11985
|
json.required = Array.from(requiredKeys);
|
|
11919
11986
|
}
|
|
11920
|
-
if (
|
|
11987
|
+
if (def.catchall?._zod.def.type === "never") {
|
|
11921
11988
|
json.additionalProperties = false;
|
|
11922
11989
|
} else if (!def.catchall) {
|
|
11923
11990
|
if (ctx.io === "output")
|
|
@@ -11965,7 +12032,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
11965
12032
|
json.type = "object";
|
|
11966
12033
|
const keyType = def.keyType;
|
|
11967
12034
|
const keyBag = keyType._zod.bag;
|
|
11968
|
-
const patterns = keyBag
|
|
12035
|
+
const patterns = keyBag?.patterns;
|
|
11969
12036
|
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
11970
12037
|
const valueSchema = process2(def.valueType, ctx, {
|
|
11971
12038
|
...params,
|
|
@@ -12077,13 +12144,12 @@ function safeParse2(schema, data) {
|
|
|
12077
12144
|
return result;
|
|
12078
12145
|
}
|
|
12079
12146
|
function getObjectShape(schema) {
|
|
12080
|
-
var _a5, _b;
|
|
12081
12147
|
if (!schema)
|
|
12082
12148
|
return void 0;
|
|
12083
12149
|
let rawShape;
|
|
12084
12150
|
if (isZ4Schema(schema)) {
|
|
12085
12151
|
const v4Schema = schema;
|
|
12086
|
-
rawShape =
|
|
12152
|
+
rawShape = v4Schema._zod?.def?.shape;
|
|
12087
12153
|
} else {
|
|
12088
12154
|
const v3Schema = schema;
|
|
12089
12155
|
rawShape = v3Schema.shape;
|
|
@@ -12100,10 +12166,9 @@ function getObjectShape(schema) {
|
|
|
12100
12166
|
return rawShape;
|
|
12101
12167
|
}
|
|
12102
12168
|
function getLiteralValue(schema) {
|
|
12103
|
-
var _a5;
|
|
12104
12169
|
if (isZ4Schema(schema)) {
|
|
12105
12170
|
const v4Schema = schema;
|
|
12106
|
-
const def2 =
|
|
12171
|
+
const def2 = v4Schema._zod?.def;
|
|
12107
12172
|
if (def2) {
|
|
12108
12173
|
if (def2.value !== void 0)
|
|
12109
12174
|
return def2.value;
|
|
@@ -12286,11 +12351,10 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
12286
12351
|
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync2(inst, data, params);
|
|
12287
12352
|
_installLazyMethods(inst, "ZodType", {
|
|
12288
12353
|
check(...chks) {
|
|
12289
|
-
var _a5;
|
|
12290
12354
|
const def2 = this.def;
|
|
12291
12355
|
return this.clone(util_exports.mergeDefs(def2, {
|
|
12292
12356
|
checks: [
|
|
12293
|
-
...
|
|
12357
|
+
...def2.checks ?? [],
|
|
12294
12358
|
...chks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
|
|
12295
12359
|
]
|
|
12296
12360
|
}), { parent: true });
|
|
@@ -12383,22 +12447,20 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
12383
12447
|
});
|
|
12384
12448
|
Object.defineProperty(inst, "description", {
|
|
12385
12449
|
get() {
|
|
12386
|
-
|
|
12387
|
-
return (_a5 = globalRegistry.get(inst)) == null ? void 0 : _a5.description;
|
|
12450
|
+
return globalRegistry.get(inst)?.description;
|
|
12388
12451
|
},
|
|
12389
12452
|
configurable: true
|
|
12390
12453
|
});
|
|
12391
12454
|
return inst;
|
|
12392
12455
|
});
|
|
12393
12456
|
var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
12394
|
-
var _a5, _b, _c;
|
|
12395
12457
|
$ZodString.init(inst, def);
|
|
12396
12458
|
ZodType.init(inst, def);
|
|
12397
12459
|
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
|
|
12398
12460
|
const bag = inst._zod.bag;
|
|
12399
|
-
inst.format =
|
|
12400
|
-
inst.minLength =
|
|
12401
|
-
inst.maxLength =
|
|
12461
|
+
inst.format = bag.format ?? null;
|
|
12462
|
+
inst.minLength = bag.minimum ?? null;
|
|
12463
|
+
inst.maxLength = bag.maximum ?? null;
|
|
12402
12464
|
_installLazyMethods(inst, "_ZodString", {
|
|
12403
12465
|
regex(...args) {
|
|
12404
12466
|
return this.check(_regex(...args));
|
|
@@ -12562,7 +12624,6 @@ var ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
|
|
|
12562
12624
|
ZodStringFormat.init(inst, def);
|
|
12563
12625
|
});
|
|
12564
12626
|
var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
12565
|
-
var _a5, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
12566
12627
|
$ZodNumber.init(inst, def);
|
|
12567
12628
|
ZodType.init(inst, def);
|
|
12568
12629
|
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
|
|
@@ -12614,11 +12675,11 @@ var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
|
12614
12675
|
}
|
|
12615
12676
|
});
|
|
12616
12677
|
const bag = inst._zod.bag;
|
|
12617
|
-
inst.minValue =
|
|
12618
|
-
inst.maxValue =
|
|
12619
|
-
inst.isInt = (
|
|
12678
|
+
inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
12679
|
+
inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
12680
|
+
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
|
|
12620
12681
|
inst.isFinite = true;
|
|
12621
|
-
inst.format =
|
|
12682
|
+
inst.format = bag.format ?? null;
|
|
12622
12683
|
});
|
|
12623
12684
|
function number2(params) {
|
|
12624
12685
|
return _number(ZodNumber, params);
|
|
@@ -12740,7 +12801,7 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
12740
12801
|
function object2(shape, params) {
|
|
12741
12802
|
const def = {
|
|
12742
12803
|
type: "object",
|
|
12743
|
-
shape: shape
|
|
12804
|
+
shape: shape ?? {},
|
|
12744
12805
|
...util_exports.normalizeParams(params)
|
|
12745
12806
|
};
|
|
12746
12807
|
return new ZodObject(def);
|
|
@@ -12889,16 +12950,15 @@ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
|
12889
12950
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
12890
12951
|
}
|
|
12891
12952
|
payload.addIssue = (issue2) => {
|
|
12892
|
-
var _a5, _b, _c;
|
|
12893
12953
|
if (typeof issue2 === "string") {
|
|
12894
12954
|
payload.issues.push(util_exports.issue(issue2, payload.value, def));
|
|
12895
12955
|
} else {
|
|
12896
12956
|
const _issue = issue2;
|
|
12897
12957
|
if (_issue.fatal)
|
|
12898
12958
|
_issue.continue = false;
|
|
12899
|
-
|
|
12900
|
-
|
|
12901
|
-
|
|
12959
|
+
_issue.code ?? (_issue.code = "custom");
|
|
12960
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
12961
|
+
_issue.inst ?? (_issue.inst = inst);
|
|
12902
12962
|
payload.issues.push(util_exports.issue(_issue));
|
|
12903
12963
|
}
|
|
12904
12964
|
};
|
|
@@ -13052,7 +13112,7 @@ var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
|
13052
13112
|
inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
|
|
13053
13113
|
});
|
|
13054
13114
|
function custom(fn, _params) {
|
|
13055
|
-
return _custom(ZodCustom, fn
|
|
13115
|
+
return _custom(ZodCustom, fn ?? (() => true), _params);
|
|
13056
13116
|
}
|
|
13057
13117
|
function refine(fn, _params = {}) {
|
|
13058
13118
|
return _refine(ZodCustom, fn, _params);
|
|
@@ -14586,8 +14646,7 @@ var UrlElicitationRequiredError = class extends McpError {
|
|
|
14586
14646
|
});
|
|
14587
14647
|
}
|
|
14588
14648
|
get elicitations() {
|
|
14589
|
-
|
|
14590
|
-
return (_b = (_a5 = this.data) == null ? void 0 : _a5.elicitations) != null ? _b : [];
|
|
14649
|
+
return this.data?.elicitations ?? [];
|
|
14591
14650
|
}
|
|
14592
14651
|
};
|
|
14593
14652
|
|
|
@@ -14602,7 +14661,7 @@ var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0
|
|
|
14602
14661
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
|
|
14603
14662
|
function getMethodLiteral(schema) {
|
|
14604
14663
|
const shape = getObjectShape(schema);
|
|
14605
|
-
const methodSchema = shape
|
|
14664
|
+
const methodSchema = shape?.method;
|
|
14606
14665
|
if (!methodSchema) {
|
|
14607
14666
|
throw new Error("Schema is missing a method literal");
|
|
14608
14667
|
}
|
|
@@ -14646,8 +14705,8 @@ var Protocol = class {
|
|
|
14646
14705
|
// Automatic pong by default.
|
|
14647
14706
|
(_request) => ({})
|
|
14648
14707
|
);
|
|
14649
|
-
this._taskStore = _options
|
|
14650
|
-
this._taskMessageQueue = _options
|
|
14708
|
+
this._taskStore = _options?.taskStore;
|
|
14709
|
+
this._taskMessageQueue = _options?.taskMessageQueue;
|
|
14651
14710
|
if (this._taskStore) {
|
|
14652
14711
|
this.setRequestHandler(GetTaskRequestSchema, async (request, extra) => {
|
|
14653
14712
|
const task = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
@@ -14660,7 +14719,6 @@ var Protocol = class {
|
|
|
14660
14719
|
});
|
|
14661
14720
|
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
|
|
14662
14721
|
const handleTaskResult = async () => {
|
|
14663
|
-
var _a5;
|
|
14664
14722
|
const taskId = request.params.taskId;
|
|
14665
14723
|
if (this._taskMessageQueue) {
|
|
14666
14724
|
let queuedMessage;
|
|
@@ -14684,7 +14742,7 @@ var Protocol = class {
|
|
|
14684
14742
|
}
|
|
14685
14743
|
continue;
|
|
14686
14744
|
}
|
|
14687
|
-
await
|
|
14745
|
+
await this._transport?.send(queuedMessage.message, { relatedRequestId: extra.requestId });
|
|
14688
14746
|
}
|
|
14689
14747
|
}
|
|
14690
14748
|
const task = await this._taskStore.getTask(taskId, extra.sessionId);
|
|
@@ -14713,9 +14771,8 @@ var Protocol = class {
|
|
|
14713
14771
|
return await handleTaskResult();
|
|
14714
14772
|
});
|
|
14715
14773
|
this.setRequestHandler(ListTasksRequestSchema, async (request, extra) => {
|
|
14716
|
-
var _a5;
|
|
14717
14774
|
try {
|
|
14718
|
-
const { tasks, nextCursor } = await this._taskStore.listTasks(
|
|
14775
|
+
const { tasks, nextCursor } = await this._taskStore.listTasks(request.params?.cursor, extra.sessionId);
|
|
14719
14776
|
return {
|
|
14720
14777
|
tasks,
|
|
14721
14778
|
nextCursor,
|
|
@@ -14758,7 +14815,7 @@ var Protocol = class {
|
|
|
14758
14815
|
return;
|
|
14759
14816
|
}
|
|
14760
14817
|
const controller = this._requestHandlerAbortControllers.get(notification.params.requestId);
|
|
14761
|
-
controller
|
|
14818
|
+
controller?.abort(notification.params.reason);
|
|
14762
14819
|
}
|
|
14763
14820
|
_setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
|
|
14764
14821
|
this._timeoutInfo.set(messageId, {
|
|
@@ -14799,24 +14856,23 @@ var Protocol = class {
|
|
|
14799
14856
|
* The Protocol object assumes ownership of the Transport, replacing any callbacks that have already been set, and expects that it is the only user of the Transport instance going forward.
|
|
14800
14857
|
*/
|
|
14801
14858
|
async connect(transport) {
|
|
14802
|
-
var _a5, _b, _c;
|
|
14803
14859
|
if (this._transport) {
|
|
14804
14860
|
throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");
|
|
14805
14861
|
}
|
|
14806
14862
|
this._transport = transport;
|
|
14807
|
-
const _onclose =
|
|
14863
|
+
const _onclose = this.transport?.onclose;
|
|
14808
14864
|
this._transport.onclose = () => {
|
|
14809
|
-
_onclose
|
|
14865
|
+
_onclose?.();
|
|
14810
14866
|
this._onclose();
|
|
14811
14867
|
};
|
|
14812
|
-
const _onerror =
|
|
14868
|
+
const _onerror = this.transport?.onerror;
|
|
14813
14869
|
this._transport.onerror = (error2) => {
|
|
14814
|
-
_onerror
|
|
14870
|
+
_onerror?.(error2);
|
|
14815
14871
|
this._onerror(error2);
|
|
14816
14872
|
};
|
|
14817
|
-
const _onmessage =
|
|
14873
|
+
const _onmessage = this._transport?.onmessage;
|
|
14818
14874
|
this._transport.onmessage = (message, extra) => {
|
|
14819
|
-
_onmessage
|
|
14875
|
+
_onmessage?.(message, extra);
|
|
14820
14876
|
if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) {
|
|
14821
14877
|
this._onresponse(message);
|
|
14822
14878
|
} else if (isJSONRPCRequest(message)) {
|
|
@@ -14830,7 +14886,6 @@ var Protocol = class {
|
|
|
14830
14886
|
await this._transport.start();
|
|
14831
14887
|
}
|
|
14832
14888
|
_onclose() {
|
|
14833
|
-
var _a5;
|
|
14834
14889
|
const responseHandlers = this._responseHandlers;
|
|
14835
14890
|
this._responseHandlers = /* @__PURE__ */ new Map();
|
|
14836
14891
|
this._progressHandlers.clear();
|
|
@@ -14846,28 +14901,25 @@ var Protocol = class {
|
|
|
14846
14901
|
this._requestHandlerAbortControllers.clear();
|
|
14847
14902
|
const error2 = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
|
|
14848
14903
|
this._transport = void 0;
|
|
14849
|
-
|
|
14904
|
+
this.onclose?.();
|
|
14850
14905
|
for (const handler of responseHandlers.values()) {
|
|
14851
14906
|
handler(error2);
|
|
14852
14907
|
}
|
|
14853
14908
|
}
|
|
14854
14909
|
_onerror(error2) {
|
|
14855
|
-
|
|
14856
|
-
(_a5 = this.onerror) == null ? void 0 : _a5.call(this, error2);
|
|
14910
|
+
this.onerror?.(error2);
|
|
14857
14911
|
}
|
|
14858
14912
|
_onnotification(notification) {
|
|
14859
|
-
|
|
14860
|
-
const handler = (_a5 = this._notificationHandlers.get(notification.method)) != null ? _a5 : this.fallbackNotificationHandler;
|
|
14913
|
+
const handler = this._notificationHandlers.get(notification.method) ?? this.fallbackNotificationHandler;
|
|
14861
14914
|
if (handler === void 0) {
|
|
14862
14915
|
return;
|
|
14863
14916
|
}
|
|
14864
14917
|
Promise.resolve().then(() => handler(notification)).catch((error2) => this._onerror(new Error(`Uncaught error in notification handler: ${error2}`)));
|
|
14865
14918
|
}
|
|
14866
14919
|
_onrequest(request, extra) {
|
|
14867
|
-
|
|
14868
|
-
const handler = (_a5 = this._requestHandlers.get(request.method)) != null ? _a5 : this.fallbackRequestHandler;
|
|
14920
|
+
const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
|
|
14869
14921
|
const capturedTransport = this._transport;
|
|
14870
|
-
const relatedTaskId =
|
|
14922
|
+
const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
14871
14923
|
if (handler === void 0) {
|
|
14872
14924
|
const errorResponse = {
|
|
14873
14925
|
jsonrpc: "2.0",
|
|
@@ -14882,20 +14934,20 @@ var Protocol = class {
|
|
|
14882
14934
|
type: "error",
|
|
14883
14935
|
message: errorResponse,
|
|
14884
14936
|
timestamp: Date.now()
|
|
14885
|
-
}, capturedTransport
|
|
14937
|
+
}, capturedTransport?.sessionId).catch((error2) => this._onerror(new Error(`Failed to enqueue error response: ${error2}`)));
|
|
14886
14938
|
} else {
|
|
14887
|
-
capturedTransport
|
|
14939
|
+
capturedTransport?.send(errorResponse).catch((error2) => this._onerror(new Error(`Failed to send an error response: ${error2}`)));
|
|
14888
14940
|
}
|
|
14889
14941
|
return;
|
|
14890
14942
|
}
|
|
14891
14943
|
const abortController = new AbortController();
|
|
14892
14944
|
this._requestHandlerAbortControllers.set(request.id, abortController);
|
|
14893
14945
|
const taskCreationParams = isTaskAugmentedRequestParams(request.params) ? request.params.task : void 0;
|
|
14894
|
-
const taskStore = this._taskStore ? this.requestTaskStore(request, capturedTransport
|
|
14946
|
+
const taskStore = this._taskStore ? this.requestTaskStore(request, capturedTransport?.sessionId) : void 0;
|
|
14895
14947
|
const fullExtra = {
|
|
14896
14948
|
signal: abortController.signal,
|
|
14897
|
-
sessionId: capturedTransport
|
|
14898
|
-
_meta:
|
|
14949
|
+
sessionId: capturedTransport?.sessionId,
|
|
14950
|
+
_meta: request.params?._meta,
|
|
14899
14951
|
sendNotification: async (notification) => {
|
|
14900
14952
|
if (abortController.signal.aborted)
|
|
14901
14953
|
return;
|
|
@@ -14906,7 +14958,6 @@ var Protocol = class {
|
|
|
14906
14958
|
await this.notification(notification, notificationOptions);
|
|
14907
14959
|
},
|
|
14908
14960
|
sendRequest: async (r, resultSchema, options) => {
|
|
14909
|
-
var _a6, _b2;
|
|
14910
14961
|
if (abortController.signal.aborted) {
|
|
14911
14962
|
throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
|
|
14912
14963
|
}
|
|
@@ -14914,20 +14965,20 @@ var Protocol = class {
|
|
|
14914
14965
|
if (relatedTaskId && !requestOptions.relatedTask) {
|
|
14915
14966
|
requestOptions.relatedTask = { taskId: relatedTaskId };
|
|
14916
14967
|
}
|
|
14917
|
-
const effectiveTaskId =
|
|
14968
|
+
const effectiveTaskId = requestOptions.relatedTask?.taskId ?? relatedTaskId;
|
|
14918
14969
|
if (effectiveTaskId && taskStore) {
|
|
14919
14970
|
await taskStore.updateTaskStatus(effectiveTaskId, "input_required");
|
|
14920
14971
|
}
|
|
14921
14972
|
return await this.request(r, resultSchema, requestOptions);
|
|
14922
14973
|
},
|
|
14923
|
-
authInfo: extra
|
|
14974
|
+
authInfo: extra?.authInfo,
|
|
14924
14975
|
requestId: request.id,
|
|
14925
|
-
requestInfo: extra
|
|
14976
|
+
requestInfo: extra?.requestInfo,
|
|
14926
14977
|
taskId: relatedTaskId,
|
|
14927
14978
|
taskStore,
|
|
14928
|
-
taskRequestedTtl: taskCreationParams
|
|
14929
|
-
closeSSEStream: extra
|
|
14930
|
-
closeStandaloneSSEStream: extra
|
|
14979
|
+
taskRequestedTtl: taskCreationParams?.ttl,
|
|
14980
|
+
closeSSEStream: extra?.closeSSEStream,
|
|
14981
|
+
closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
|
|
14931
14982
|
};
|
|
14932
14983
|
Promise.resolve().then(() => {
|
|
14933
14984
|
if (taskCreationParams) {
|
|
@@ -14947,12 +14998,11 @@ var Protocol = class {
|
|
|
14947
14998
|
type: "response",
|
|
14948
14999
|
message: response,
|
|
14949
15000
|
timestamp: Date.now()
|
|
14950
|
-
}, capturedTransport
|
|
15001
|
+
}, capturedTransport?.sessionId);
|
|
14951
15002
|
} else {
|
|
14952
|
-
await
|
|
15003
|
+
await capturedTransport?.send(response);
|
|
14953
15004
|
}
|
|
14954
15005
|
}, async (error2) => {
|
|
14955
|
-
var _a6;
|
|
14956
15006
|
if (abortController.signal.aborted) {
|
|
14957
15007
|
return;
|
|
14958
15008
|
}
|
|
@@ -14961,7 +15011,7 @@ var Protocol = class {
|
|
|
14961
15011
|
id: request.id,
|
|
14962
15012
|
error: {
|
|
14963
15013
|
code: Number.isSafeInteger(error2["code"]) ? error2["code"] : ErrorCode.InternalError,
|
|
14964
|
-
message:
|
|
15014
|
+
message: error2.message ?? "Internal error",
|
|
14965
15015
|
...error2["data"] !== void 0 && { data: error2["data"] }
|
|
14966
15016
|
}
|
|
14967
15017
|
};
|
|
@@ -14970,9 +15020,9 @@ var Protocol = class {
|
|
|
14970
15020
|
type: "error",
|
|
14971
15021
|
message: errorResponse,
|
|
14972
15022
|
timestamp: Date.now()
|
|
14973
|
-
}, capturedTransport
|
|
15023
|
+
}, capturedTransport?.sessionId);
|
|
14974
15024
|
} else {
|
|
14975
|
-
await
|
|
15025
|
+
await capturedTransport?.send(errorResponse);
|
|
14976
15026
|
}
|
|
14977
15027
|
}).catch((error2) => this._onerror(new Error(`Failed to send response: ${error2}`))).finally(() => {
|
|
14978
15028
|
if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
|
|
@@ -15051,8 +15101,7 @@ var Protocol = class {
|
|
|
15051
15101
|
* Closes the connection.
|
|
15052
15102
|
*/
|
|
15053
15103
|
async close() {
|
|
15054
|
-
|
|
15055
|
-
await ((_a5 = this._transport) == null ? void 0 : _a5.close());
|
|
15104
|
+
await this._transport?.close();
|
|
15056
15105
|
}
|
|
15057
15106
|
/**
|
|
15058
15107
|
* Sends a request and returns an AsyncGenerator that yields response messages.
|
|
@@ -15082,8 +15131,7 @@ var Protocol = class {
|
|
|
15082
15131
|
* @experimental Use `client.experimental.tasks.requestStream()` to access this method.
|
|
15083
15132
|
*/
|
|
15084
15133
|
async *requestStream(request, resultSchema, options) {
|
|
15085
|
-
|
|
15086
|
-
const { task } = options != null ? options : {};
|
|
15134
|
+
const { task } = options ?? {};
|
|
15087
15135
|
if (!task) {
|
|
15088
15136
|
try {
|
|
15089
15137
|
const result = await this.request(request, resultSchema, options);
|
|
@@ -15130,9 +15178,9 @@ var Protocol = class {
|
|
|
15130
15178
|
yield { type: "result", result };
|
|
15131
15179
|
return;
|
|
15132
15180
|
}
|
|
15133
|
-
const pollInterval =
|
|
15181
|
+
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
15134
15182
|
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
15135
|
-
|
|
15183
|
+
options?.signal?.throwIfAborted();
|
|
15136
15184
|
}
|
|
15137
15185
|
} catch (error2) {
|
|
15138
15186
|
yield {
|
|
@@ -15147,9 +15195,8 @@ var Protocol = class {
|
|
|
15147
15195
|
* Do not use this method to emit notifications! Use notification() instead.
|
|
15148
15196
|
*/
|
|
15149
15197
|
request(request, resultSchema, options) {
|
|
15150
|
-
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options
|
|
15198
|
+
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
15151
15199
|
return new Promise((resolve, reject) => {
|
|
15152
|
-
var _a5, _b, _c, _d, _e, _f, _g;
|
|
15153
15200
|
const earlyReject = (error2) => {
|
|
15154
15201
|
reject(error2);
|
|
15155
15202
|
};
|
|
@@ -15157,7 +15204,7 @@ var Protocol = class {
|
|
|
15157
15204
|
earlyReject(new Error("Not connected"));
|
|
15158
15205
|
return;
|
|
15159
15206
|
}
|
|
15160
|
-
if (
|
|
15207
|
+
if (this._options?.enforceStrictCapabilities === true) {
|
|
15161
15208
|
try {
|
|
15162
15209
|
this.assertCapabilityForMethod(request.method);
|
|
15163
15210
|
if (task) {
|
|
@@ -15168,19 +15215,19 @@ var Protocol = class {
|
|
|
15168
15215
|
return;
|
|
15169
15216
|
}
|
|
15170
15217
|
}
|
|
15171
|
-
|
|
15218
|
+
options?.signal?.throwIfAborted();
|
|
15172
15219
|
const messageId = this._requestMessageId++;
|
|
15173
15220
|
const jsonrpcRequest = {
|
|
15174
15221
|
...request,
|
|
15175
15222
|
jsonrpc: "2.0",
|
|
15176
15223
|
id: messageId
|
|
15177
15224
|
};
|
|
15178
|
-
if (options
|
|
15225
|
+
if (options?.onprogress) {
|
|
15179
15226
|
this._progressHandlers.set(messageId, options.onprogress);
|
|
15180
15227
|
jsonrpcRequest.params = {
|
|
15181
15228
|
...request.params,
|
|
15182
15229
|
_meta: {
|
|
15183
|
-
...
|
|
15230
|
+
...request.params?._meta || {},
|
|
15184
15231
|
progressToken: messageId
|
|
15185
15232
|
}
|
|
15186
15233
|
};
|
|
@@ -15195,17 +15242,16 @@ var Protocol = class {
|
|
|
15195
15242
|
jsonrpcRequest.params = {
|
|
15196
15243
|
...jsonrpcRequest.params,
|
|
15197
15244
|
_meta: {
|
|
15198
|
-
...
|
|
15245
|
+
...jsonrpcRequest.params?._meta || {},
|
|
15199
15246
|
[RELATED_TASK_META_KEY]: relatedTask
|
|
15200
15247
|
}
|
|
15201
15248
|
};
|
|
15202
15249
|
}
|
|
15203
15250
|
const cancel = (reason) => {
|
|
15204
|
-
var _a6;
|
|
15205
15251
|
this._responseHandlers.delete(messageId);
|
|
15206
15252
|
this._progressHandlers.delete(messageId);
|
|
15207
15253
|
this._cleanupTimeout(messageId);
|
|
15208
|
-
|
|
15254
|
+
this._transport?.send({
|
|
15209
15255
|
jsonrpc: "2.0",
|
|
15210
15256
|
method: "notifications/cancelled",
|
|
15211
15257
|
params: {
|
|
@@ -15217,8 +15263,7 @@ var Protocol = class {
|
|
|
15217
15263
|
reject(error2);
|
|
15218
15264
|
};
|
|
15219
15265
|
this._responseHandlers.set(messageId, (response) => {
|
|
15220
|
-
|
|
15221
|
-
if ((_a6 = options == null ? void 0 : options.signal) == null ? void 0 : _a6.aborted) {
|
|
15266
|
+
if (options?.signal?.aborted) {
|
|
15222
15267
|
return;
|
|
15223
15268
|
}
|
|
15224
15269
|
if (response instanceof Error) {
|
|
@@ -15235,14 +15280,13 @@ var Protocol = class {
|
|
|
15235
15280
|
reject(error2);
|
|
15236
15281
|
}
|
|
15237
15282
|
});
|
|
15238
|
-
|
|
15239
|
-
|
|
15240
|
-
cancel((_a6 = options == null ? void 0 : options.signal) == null ? void 0 : _a6.reason);
|
|
15283
|
+
options?.signal?.addEventListener("abort", () => {
|
|
15284
|
+
cancel(options?.signal?.reason);
|
|
15241
15285
|
});
|
|
15242
|
-
const timeout =
|
|
15286
|
+
const timeout = options?.timeout ?? DEFAULT_REQUEST_TIMEOUT_MSEC;
|
|
15243
15287
|
const timeoutHandler = () => cancel(McpError.fromError(ErrorCode.RequestTimeout, "Request timed out", { timeout }));
|
|
15244
|
-
this._setupTimeout(messageId, timeout, options
|
|
15245
|
-
const relatedTaskId = relatedTask
|
|
15288
|
+
this._setupTimeout(messageId, timeout, options?.maxTotalTimeout, timeoutHandler, options?.resetTimeoutOnProgress ?? false);
|
|
15289
|
+
const relatedTaskId = relatedTask?.taskId;
|
|
15246
15290
|
if (relatedTaskId) {
|
|
15247
15291
|
const responseResolver = (response) => {
|
|
15248
15292
|
const handler = this._responseHandlers.get(messageId);
|
|
@@ -15305,12 +15349,11 @@ var Protocol = class {
|
|
|
15305
15349
|
* Emits a notification, which is a one-way message that does not expect a response.
|
|
15306
15350
|
*/
|
|
15307
15351
|
async notification(notification, options) {
|
|
15308
|
-
var _a5, _b, _c, _d, _e;
|
|
15309
15352
|
if (!this._transport) {
|
|
15310
15353
|
throw new Error("Not connected");
|
|
15311
15354
|
}
|
|
15312
15355
|
this.assertNotificationCapability(notification.method);
|
|
15313
|
-
const relatedTaskId =
|
|
15356
|
+
const relatedTaskId = options?.relatedTask?.taskId;
|
|
15314
15357
|
if (relatedTaskId) {
|
|
15315
15358
|
const jsonrpcNotification2 = {
|
|
15316
15359
|
...notification,
|
|
@@ -15318,7 +15361,7 @@ var Protocol = class {
|
|
|
15318
15361
|
params: {
|
|
15319
15362
|
...notification.params,
|
|
15320
15363
|
_meta: {
|
|
15321
|
-
...
|
|
15364
|
+
...notification.params?._meta || {},
|
|
15322
15365
|
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
15323
15366
|
}
|
|
15324
15367
|
}
|
|
@@ -15330,15 +15373,14 @@ var Protocol = class {
|
|
|
15330
15373
|
});
|
|
15331
15374
|
return;
|
|
15332
15375
|
}
|
|
15333
|
-
const debouncedMethods =
|
|
15334
|
-
const canDebounce = debouncedMethods.includes(notification.method) && !notification.params && !
|
|
15376
|
+
const debouncedMethods = this._options?.debouncedNotificationMethods ?? [];
|
|
15377
|
+
const canDebounce = debouncedMethods.includes(notification.method) && !notification.params && !options?.relatedRequestId && !options?.relatedTask;
|
|
15335
15378
|
if (canDebounce) {
|
|
15336
15379
|
if (this._pendingDebouncedNotifications.has(notification.method)) {
|
|
15337
15380
|
return;
|
|
15338
15381
|
}
|
|
15339
15382
|
this._pendingDebouncedNotifications.add(notification.method);
|
|
15340
15383
|
Promise.resolve().then(() => {
|
|
15341
|
-
var _a6, _b2;
|
|
15342
15384
|
this._pendingDebouncedNotifications.delete(notification.method);
|
|
15343
15385
|
if (!this._transport) {
|
|
15344
15386
|
return;
|
|
@@ -15347,19 +15389,19 @@ var Protocol = class {
|
|
|
15347
15389
|
...notification,
|
|
15348
15390
|
jsonrpc: "2.0"
|
|
15349
15391
|
};
|
|
15350
|
-
if (options
|
|
15392
|
+
if (options?.relatedTask) {
|
|
15351
15393
|
jsonrpcNotification2 = {
|
|
15352
15394
|
...jsonrpcNotification2,
|
|
15353
15395
|
params: {
|
|
15354
15396
|
...jsonrpcNotification2.params,
|
|
15355
15397
|
_meta: {
|
|
15356
|
-
...
|
|
15398
|
+
...jsonrpcNotification2.params?._meta || {},
|
|
15357
15399
|
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
15358
15400
|
}
|
|
15359
15401
|
}
|
|
15360
15402
|
};
|
|
15361
15403
|
}
|
|
15362
|
-
|
|
15404
|
+
this._transport?.send(jsonrpcNotification2, options).catch((error2) => this._onerror(error2));
|
|
15363
15405
|
});
|
|
15364
15406
|
return;
|
|
15365
15407
|
}
|
|
@@ -15367,13 +15409,13 @@ var Protocol = class {
|
|
|
15367
15409
|
...notification,
|
|
15368
15410
|
jsonrpc: "2.0"
|
|
15369
15411
|
};
|
|
15370
|
-
if (options
|
|
15412
|
+
if (options?.relatedTask) {
|
|
15371
15413
|
jsonrpcNotification = {
|
|
15372
15414
|
...jsonrpcNotification,
|
|
15373
15415
|
params: {
|
|
15374
15416
|
...jsonrpcNotification.params,
|
|
15375
15417
|
_meta: {
|
|
15376
|
-
...
|
|
15418
|
+
...jsonrpcNotification.params?._meta || {},
|
|
15377
15419
|
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
15378
15420
|
}
|
|
15379
15421
|
}
|
|
@@ -15449,11 +15491,10 @@ var Protocol = class {
|
|
|
15449
15491
|
* simply propagates the error.
|
|
15450
15492
|
*/
|
|
15451
15493
|
async _enqueueTaskMessage(taskId, message, sessionId) {
|
|
15452
|
-
var _a5;
|
|
15453
15494
|
if (!this._taskStore || !this._taskMessageQueue) {
|
|
15454
15495
|
throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
15455
15496
|
}
|
|
15456
|
-
const maxQueueSize =
|
|
15497
|
+
const maxQueueSize = this._options?.maxTaskQueueSize;
|
|
15457
15498
|
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
15458
15499
|
}
|
|
15459
15500
|
/**
|
|
@@ -15486,11 +15527,10 @@ var Protocol = class {
|
|
|
15486
15527
|
* @returns Promise that resolves when an update occurs or rejects if aborted
|
|
15487
15528
|
*/
|
|
15488
15529
|
async _waitForTaskUpdate(taskId, signal) {
|
|
15489
|
-
|
|
15490
|
-
let interval = (_b = (_a5 = this._options) == null ? void 0 : _a5.defaultTaskPollInterval) != null ? _b : 1e3;
|
|
15530
|
+
let interval = this._options?.defaultTaskPollInterval ?? 1e3;
|
|
15491
15531
|
try {
|
|
15492
|
-
const task = await
|
|
15493
|
-
if (task
|
|
15532
|
+
const task = await this._taskStore?.getTask(taskId);
|
|
15533
|
+
if (task?.pollInterval) {
|
|
15494
15534
|
interval = task.pollInterval;
|
|
15495
15535
|
}
|
|
15496
15536
|
} catch {
|
|
@@ -15629,7 +15669,7 @@ var AjvJsonSchemaValidator = class {
|
|
|
15629
15669
|
* ```
|
|
15630
15670
|
*/
|
|
15631
15671
|
constructor(ajv) {
|
|
15632
|
-
this._ajv = ajv
|
|
15672
|
+
this._ajv = ajv ?? createDefaultAjvInstance();
|
|
15633
15673
|
}
|
|
15634
15674
|
/**
|
|
15635
15675
|
* Create a validator for the given JSON Schema
|
|
@@ -15641,8 +15681,7 @@ var AjvJsonSchemaValidator = class {
|
|
|
15641
15681
|
* @returns A validator function that validates input data
|
|
15642
15682
|
*/
|
|
15643
15683
|
getValidator(schema) {
|
|
15644
|
-
|
|
15645
|
-
const ajvValidator = "$id" in schema && typeof schema.$id === "string" ? (_a5 = this._ajv.getSchema(schema.$id)) != null ? _a5 : this._ajv.compile(schema) : this._ajv.compile(schema);
|
|
15684
|
+
const ajvValidator = "$id" in schema && typeof schema.$id === "string" ? this._ajv.getSchema(schema.$id) ?? this._ajv.compile(schema) : this._ajv.compile(schema);
|
|
15646
15685
|
return (input) => {
|
|
15647
15686
|
const valid = ajvValidator(input);
|
|
15648
15687
|
if (valid) {
|
|
@@ -15728,9 +15767,8 @@ var ExperimentalServerTasks = class {
|
|
|
15728
15767
|
* @experimental
|
|
15729
15768
|
*/
|
|
15730
15769
|
createMessageStream(params, options) {
|
|
15731
|
-
var _a5;
|
|
15732
15770
|
const clientCapabilities = this._server.getClientCapabilities();
|
|
15733
|
-
if ((params.tools || params.toolChoice) && !
|
|
15771
|
+
if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
|
|
15734
15772
|
throw new Error("Client does not support sampling tools capability.");
|
|
15735
15773
|
}
|
|
15736
15774
|
if (params.messages.length > 0) {
|
|
@@ -15804,18 +15842,17 @@ var ExperimentalServerTasks = class {
|
|
|
15804
15842
|
* @experimental
|
|
15805
15843
|
*/
|
|
15806
15844
|
elicitInputStream(params, options) {
|
|
15807
|
-
var _a5, _b, _c;
|
|
15808
15845
|
const clientCapabilities = this._server.getClientCapabilities();
|
|
15809
|
-
const mode =
|
|
15846
|
+
const mode = params.mode ?? "form";
|
|
15810
15847
|
switch (mode) {
|
|
15811
15848
|
case "url": {
|
|
15812
|
-
if (!
|
|
15849
|
+
if (!clientCapabilities?.elicitation?.url) {
|
|
15813
15850
|
throw new Error("Client does not support url elicitation.");
|
|
15814
15851
|
}
|
|
15815
15852
|
break;
|
|
15816
15853
|
}
|
|
15817
15854
|
case "form": {
|
|
15818
|
-
if (!
|
|
15855
|
+
if (!clientCapabilities?.elicitation?.form) {
|
|
15819
15856
|
throw new Error("Client does not support form elicitation.");
|
|
15820
15857
|
}
|
|
15821
15858
|
break;
|
|
@@ -15879,13 +15916,12 @@ var ExperimentalServerTasks = class {
|
|
|
15879
15916
|
|
|
15880
15917
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
|
|
15881
15918
|
function assertToolsCallTaskCapability(requests, method, entityName) {
|
|
15882
|
-
var _a5;
|
|
15883
15919
|
if (!requests) {
|
|
15884
15920
|
throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
15885
15921
|
}
|
|
15886
15922
|
switch (method) {
|
|
15887
15923
|
case "tools/call":
|
|
15888
|
-
if (!
|
|
15924
|
+
if (!requests.tools?.call) {
|
|
15889
15925
|
throw new Error(`${entityName} does not support task creation for tools/call (required for ${method})`);
|
|
15890
15926
|
}
|
|
15891
15927
|
break;
|
|
@@ -15894,18 +15930,17 @@ function assertToolsCallTaskCapability(requests, method, entityName) {
|
|
|
15894
15930
|
}
|
|
15895
15931
|
}
|
|
15896
15932
|
function assertClientRequestTaskCapability(requests, method, entityName) {
|
|
15897
|
-
var _a5, _b;
|
|
15898
15933
|
if (!requests) {
|
|
15899
15934
|
throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
15900
15935
|
}
|
|
15901
15936
|
switch (method) {
|
|
15902
15937
|
case "sampling/createMessage":
|
|
15903
|
-
if (!
|
|
15938
|
+
if (!requests.sampling?.createMessage) {
|
|
15904
15939
|
throw new Error(`${entityName} does not support task creation for sampling/createMessage (required for ${method})`);
|
|
15905
15940
|
}
|
|
15906
15941
|
break;
|
|
15907
15942
|
case "elicitation/create":
|
|
15908
|
-
if (!
|
|
15943
|
+
if (!requests.elicitation?.create) {
|
|
15909
15944
|
throw new Error(`${entityName} does not support task creation for elicitation/create (required for ${method})`);
|
|
15910
15945
|
}
|
|
15911
15946
|
break;
|
|
@@ -15920,7 +15955,6 @@ var Server = class extends Protocol {
|
|
|
15920
15955
|
* Initializes this server with the given name and version information.
|
|
15921
15956
|
*/
|
|
15922
15957
|
constructor(_serverInfo, options) {
|
|
15923
|
-
var _a5, _b;
|
|
15924
15958
|
super(options);
|
|
15925
15959
|
this._serverInfo = _serverInfo;
|
|
15926
15960
|
this._loggingLevels = /* @__PURE__ */ new Map();
|
|
@@ -15929,18 +15963,14 @@ var Server = class extends Protocol {
|
|
|
15929
15963
|
const currentLevel = this._loggingLevels.get(sessionId);
|
|
15930
15964
|
return currentLevel ? this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(currentLevel) : false;
|
|
15931
15965
|
};
|
|
15932
|
-
this._capabilities =
|
|
15933
|
-
this._instructions = options
|
|
15934
|
-
this._jsonSchemaValidator =
|
|
15966
|
+
this._capabilities = options?.capabilities ?? {};
|
|
15967
|
+
this._instructions = options?.instructions;
|
|
15968
|
+
this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator();
|
|
15935
15969
|
this.setRequestHandler(InitializeRequestSchema, (request) => this._oninitialize(request));
|
|
15936
|
-
this.setNotificationHandler(InitializedNotificationSchema, () =>
|
|
15937
|
-
var _a6;
|
|
15938
|
-
return (_a6 = this.oninitialized) == null ? void 0 : _a6.call(this);
|
|
15939
|
-
});
|
|
15970
|
+
this.setNotificationHandler(InitializedNotificationSchema, () => this.oninitialized?.());
|
|
15940
15971
|
if (this._capabilities.logging) {
|
|
15941
15972
|
this.setRequestHandler(SetLevelRequestSchema, async (request, extra) => {
|
|
15942
|
-
|
|
15943
|
-
const transportSessionId = extra.sessionId || ((_a6 = extra.requestInfo) == null ? void 0 : _a6.headers["mcp-session-id"]) || void 0;
|
|
15973
|
+
const transportSessionId = extra.sessionId || extra.requestInfo?.headers["mcp-session-id"] || void 0;
|
|
15944
15974
|
const { level } = request.params;
|
|
15945
15975
|
const parseResult = LoggingLevelSchema.safeParse(level);
|
|
15946
15976
|
if (parseResult.success) {
|
|
@@ -15981,7 +16011,7 @@ var Server = class extends Protocol {
|
|
|
15981
16011
|
*/
|
|
15982
16012
|
setRequestHandler(requestSchema, handler) {
|
|
15983
16013
|
const shape = getObjectShape(requestSchema);
|
|
15984
|
-
const methodSchema = shape
|
|
16014
|
+
const methodSchema = shape?.method;
|
|
15985
16015
|
if (!methodSchema) {
|
|
15986
16016
|
throw new Error("Schema is missing a method literal");
|
|
15987
16017
|
}
|
|
@@ -16019,20 +16049,19 @@ var Server = class extends Protocol {
|
|
|
16019
16049
|
return super.setRequestHandler(requestSchema, handler);
|
|
16020
16050
|
}
|
|
16021
16051
|
assertCapabilityForMethod(method) {
|
|
16022
|
-
var _a5, _b, _c;
|
|
16023
16052
|
switch (method) {
|
|
16024
16053
|
case "sampling/createMessage":
|
|
16025
|
-
if (!
|
|
16054
|
+
if (!this._clientCapabilities?.sampling) {
|
|
16026
16055
|
throw new Error(`Client does not support sampling (required for ${method})`);
|
|
16027
16056
|
}
|
|
16028
16057
|
break;
|
|
16029
16058
|
case "elicitation/create":
|
|
16030
|
-
if (!
|
|
16059
|
+
if (!this._clientCapabilities?.elicitation) {
|
|
16031
16060
|
throw new Error(`Client does not support elicitation (required for ${method})`);
|
|
16032
16061
|
}
|
|
16033
16062
|
break;
|
|
16034
16063
|
case "roots/list":
|
|
16035
|
-
if (!
|
|
16064
|
+
if (!this._clientCapabilities?.roots) {
|
|
16036
16065
|
throw new Error(`Client does not support listing roots (required for ${method})`);
|
|
16037
16066
|
}
|
|
16038
16067
|
break;
|
|
@@ -16041,7 +16070,6 @@ var Server = class extends Protocol {
|
|
|
16041
16070
|
}
|
|
16042
16071
|
}
|
|
16043
16072
|
assertNotificationCapability(method) {
|
|
16044
|
-
var _a5, _b;
|
|
16045
16073
|
switch (method) {
|
|
16046
16074
|
case "notifications/message":
|
|
16047
16075
|
if (!this._capabilities.logging) {
|
|
@@ -16065,7 +16093,7 @@ var Server = class extends Protocol {
|
|
|
16065
16093
|
}
|
|
16066
16094
|
break;
|
|
16067
16095
|
case "notifications/elicitation/complete":
|
|
16068
|
-
if (!
|
|
16096
|
+
if (!this._clientCapabilities?.elicitation?.url) {
|
|
16069
16097
|
throw new Error(`Client does not support URL elicitation (required for ${method})`);
|
|
16070
16098
|
}
|
|
16071
16099
|
break;
|
|
@@ -16123,15 +16151,13 @@ var Server = class extends Protocol {
|
|
|
16123
16151
|
}
|
|
16124
16152
|
}
|
|
16125
16153
|
assertTaskCapability(method) {
|
|
16126
|
-
|
|
16127
|
-
assertClientRequestTaskCapability((_b = (_a5 = this._clientCapabilities) == null ? void 0 : _a5.tasks) == null ? void 0 : _b.requests, method, "Client");
|
|
16154
|
+
assertClientRequestTaskCapability(this._clientCapabilities?.tasks?.requests, method, "Client");
|
|
16128
16155
|
}
|
|
16129
16156
|
assertTaskHandlerCapability(method) {
|
|
16130
|
-
var _a5;
|
|
16131
16157
|
if (!this._capabilities) {
|
|
16132
16158
|
return;
|
|
16133
16159
|
}
|
|
16134
|
-
assertToolsCallTaskCapability(
|
|
16160
|
+
assertToolsCallTaskCapability(this._capabilities.tasks?.requests, method, "Server");
|
|
16135
16161
|
}
|
|
16136
16162
|
async _oninitialize(request) {
|
|
16137
16163
|
const requestedVersion = request.params.protocolVersion;
|
|
@@ -16165,9 +16191,8 @@ var Server = class extends Protocol {
|
|
|
16165
16191
|
}
|
|
16166
16192
|
// Implementation
|
|
16167
16193
|
async createMessage(params, options) {
|
|
16168
|
-
var _a5, _b;
|
|
16169
16194
|
if (params.tools || params.toolChoice) {
|
|
16170
|
-
if (!
|
|
16195
|
+
if (!this._clientCapabilities?.sampling?.tools) {
|
|
16171
16196
|
throw new Error("Client does not support sampling tools capability.");
|
|
16172
16197
|
}
|
|
16173
16198
|
}
|
|
@@ -16207,18 +16232,17 @@ var Server = class extends Protocol {
|
|
|
16207
16232
|
* @returns The result of the elicitation request.
|
|
16208
16233
|
*/
|
|
16209
16234
|
async elicitInput(params, options) {
|
|
16210
|
-
|
|
16211
|
-
const mode = (_a5 = params.mode) != null ? _a5 : "form";
|
|
16235
|
+
const mode = params.mode ?? "form";
|
|
16212
16236
|
switch (mode) {
|
|
16213
16237
|
case "url": {
|
|
16214
|
-
if (!
|
|
16238
|
+
if (!this._clientCapabilities?.elicitation?.url) {
|
|
16215
16239
|
throw new Error("Client does not support url elicitation.");
|
|
16216
16240
|
}
|
|
16217
16241
|
const urlParams = params;
|
|
16218
16242
|
return this.request({ method: "elicitation/create", params: urlParams }, ElicitResultSchema, options);
|
|
16219
16243
|
}
|
|
16220
16244
|
case "form": {
|
|
16221
|
-
if (!
|
|
16245
|
+
if (!this._clientCapabilities?.elicitation?.form) {
|
|
16222
16246
|
throw new Error("Client does not support form elicitation.");
|
|
16223
16247
|
}
|
|
16224
16248
|
const formParams = params.mode === "form" ? params : { ...params, mode: "form" };
|
|
@@ -16250,8 +16274,7 @@ var Server = class extends Protocol {
|
|
|
16250
16274
|
* @returns A function that emits the completion notification when awaited.
|
|
16251
16275
|
*/
|
|
16252
16276
|
createElicitationCompletionNotifier(elicitationId, options) {
|
|
16253
|
-
|
|
16254
|
-
if (!((_b = (_a5 = this._clientCapabilities) == null ? void 0 : _a5.elicitation) == null ? void 0 : _b.url)) {
|
|
16277
|
+
if (!this._clientCapabilities?.elicitation?.url) {
|
|
16255
16278
|
throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");
|
|
16256
16279
|
}
|
|
16257
16280
|
return () => this.notification({
|
|
@@ -16298,18 +16321,16 @@ var Server = class extends Protocol {
|
|
|
16298
16321
|
};
|
|
16299
16322
|
|
|
16300
16323
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
16301
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
16324
|
+
var import_node_process = __toESM(require("node:process"), 1);
|
|
16302
16325
|
|
|
16303
16326
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
|
|
16304
16327
|
var STDIO_DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
|
|
16305
16328
|
var ReadBuffer = class {
|
|
16306
16329
|
constructor(options) {
|
|
16307
|
-
|
|
16308
|
-
this._maxBufferSize = (_a5 = options == null ? void 0 : options.maxBufferSize) != null ? _a5 : STDIO_DEFAULT_MAX_BUFFER_SIZE;
|
|
16330
|
+
this._maxBufferSize = options?.maxBufferSize ?? STDIO_DEFAULT_MAX_BUFFER_SIZE;
|
|
16309
16331
|
}
|
|
16310
16332
|
append(chunk) {
|
|
16311
|
-
|
|
16312
|
-
const newSize = ((_b = (_a5 = this._buffer) == null ? void 0 : _a5.length) != null ? _b : 0) + chunk.length;
|
|
16333
|
+
const newSize = (this._buffer?.length ?? 0) + chunk.length;
|
|
16313
16334
|
if (newSize > this._maxBufferSize) {
|
|
16314
16335
|
this.clear();
|
|
16315
16336
|
throw new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);
|
|
@@ -16346,21 +16367,19 @@ var StdioServerTransport = class {
|
|
|
16346
16367
|
this._stdout = _stdout;
|
|
16347
16368
|
this._started = false;
|
|
16348
16369
|
this._ondata = (chunk) => {
|
|
16349
|
-
var _a5;
|
|
16350
16370
|
try {
|
|
16351
16371
|
this._readBuffer.append(chunk);
|
|
16352
16372
|
this.processReadBuffer();
|
|
16353
16373
|
} catch (error2) {
|
|
16354
|
-
|
|
16374
|
+
this.onerror?.(error2);
|
|
16355
16375
|
this.close().catch(() => {
|
|
16356
16376
|
});
|
|
16357
16377
|
}
|
|
16358
16378
|
};
|
|
16359
16379
|
this._onerror = (error2) => {
|
|
16360
|
-
|
|
16361
|
-
(_a5 = this.onerror) == null ? void 0 : _a5.call(this, error2);
|
|
16380
|
+
this.onerror?.(error2);
|
|
16362
16381
|
};
|
|
16363
|
-
this._readBuffer = new ReadBuffer({ maxBufferSize: options
|
|
16382
|
+
this._readBuffer = new ReadBuffer({ maxBufferSize: options?.maxBufferSize });
|
|
16364
16383
|
}
|
|
16365
16384
|
/**
|
|
16366
16385
|
* Starts listening for messages on stdin.
|
|
@@ -16374,21 +16393,19 @@ var StdioServerTransport = class {
|
|
|
16374
16393
|
this._stdin.on("error", this._onerror);
|
|
16375
16394
|
}
|
|
16376
16395
|
processReadBuffer() {
|
|
16377
|
-
var _a5, _b;
|
|
16378
16396
|
while (true) {
|
|
16379
16397
|
try {
|
|
16380
16398
|
const message = this._readBuffer.readMessage();
|
|
16381
16399
|
if (message === null) {
|
|
16382
16400
|
break;
|
|
16383
16401
|
}
|
|
16384
|
-
|
|
16402
|
+
this.onmessage?.(message);
|
|
16385
16403
|
} catch (error2) {
|
|
16386
|
-
|
|
16404
|
+
this.onerror?.(error2);
|
|
16387
16405
|
}
|
|
16388
16406
|
}
|
|
16389
16407
|
}
|
|
16390
16408
|
async close() {
|
|
16391
|
-
var _a5;
|
|
16392
16409
|
this._stdin.off("data", this._ondata);
|
|
16393
16410
|
this._stdin.off("error", this._onerror);
|
|
16394
16411
|
const remainingDataListeners = this._stdin.listenerCount("data");
|
|
@@ -16396,7 +16413,7 @@ var StdioServerTransport = class {
|
|
|
16396
16413
|
this._stdin.pause();
|
|
16397
16414
|
}
|
|
16398
16415
|
this._readBuffer.clear();
|
|
16399
|
-
|
|
16416
|
+
this.onclose?.();
|
|
16400
16417
|
}
|
|
16401
16418
|
send(message) {
|
|
16402
16419
|
return new Promise((resolve) => {
|
|
@@ -16490,8 +16507,8 @@ server2.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
16490
16507
|
}
|
|
16491
16508
|
}
|
|
16492
16509
|
if (name === "yap2app_suggest_placement") {
|
|
16493
|
-
const componentName =
|
|
16494
|
-
const granularity =
|
|
16510
|
+
const componentName = args?.componentName || "CustomComponent";
|
|
16511
|
+
const granularity = args?.granularity || "organism";
|
|
16495
16512
|
let subfolder = "components/organisms";
|
|
16496
16513
|
if (granularity === "atom") subfolder = "components/ui";
|
|
16497
16514
|
else if (granularity === "molecule") subfolder = "components/molecules";
|