@chrischall/gemini-mcp 1.6.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/dist/blob-store.js +18 -2
- package/dist/bundle.js +942 -617
- package/dist/client.js +31 -2
- package/dist/errors.js +120 -0
- package/dist/index.js +6 -25
- package/dist/job-store.js +138 -0
- package/dist/jobs.js +257 -12
- package/dist/media-url.js +10 -3
- package/dist/registrars.js +50 -0
- package/dist/session.js +5 -4
- package/dist/signed-url.js +42 -0
- package/dist/storage/media.js +76 -3
- package/dist/tools/files.js +49 -0
- package/dist/tools/jobs.js +5 -1
- package/dist/tools/shared.js +13 -3
- package/dist/tools/uploads.js +42 -19
- package/dist/upload-url.js +24 -4
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/bundle.js
CHANGED
|
@@ -639,12 +639,12 @@ function isValidCidr(ip, version2) {
|
|
|
639
639
|
}
|
|
640
640
|
return false;
|
|
641
641
|
}
|
|
642
|
-
function floatSafeRemainder(val,
|
|
642
|
+
function floatSafeRemainder(val, step2) {
|
|
643
643
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
644
|
-
const stepDecCount = (
|
|
644
|
+
const stepDecCount = (step2.toString().split(".")[1] || "").length;
|
|
645
645
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
646
646
|
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
647
|
-
const stepInt = Number.parseInt(
|
|
647
|
+
const stepInt = Number.parseInt(step2.toFixed(decCount).replace(".", ""));
|
|
648
648
|
return valInt % stepInt / 10 ** decCount;
|
|
649
649
|
}
|
|
650
650
|
function deepPartialify(schema) {
|
|
@@ -4178,8 +4178,8 @@ function cleanRegex(source) {
|
|
|
4178
4178
|
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
4179
4179
|
return source.slice(start, end);
|
|
4180
4180
|
}
|
|
4181
|
-
function floatSafeRemainder2(val,
|
|
4182
|
-
const ratio = val /
|
|
4181
|
+
function floatSafeRemainder2(val, step2) {
|
|
4182
|
+
const ratio = val / step2;
|
|
4183
4183
|
const roundedRatio = Math.round(ratio);
|
|
4184
4184
|
const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
4185
4185
|
if (Math.abs(ratio - roundedRatio) < tolerance)
|
|
@@ -5174,9 +5174,9 @@ var init_regexes = __esm({
|
|
|
5174
5174
|
});
|
|
5175
5175
|
|
|
5176
5176
|
// node_modules/zod/v4/core/checks.js
|
|
5177
|
-
function handleCheckPropertyResult(result,
|
|
5177
|
+
function handleCheckPropertyResult(result, payload, property) {
|
|
5178
5178
|
if (result.issues.length) {
|
|
5179
|
-
|
|
5179
|
+
payload.issues.push(...prefixIssues(property, result.issues));
|
|
5180
5180
|
}
|
|
5181
5181
|
}
|
|
5182
5182
|
var $ZodCheck, numericOriginMap, $ZodCheckLessThan, $ZodCheckGreaterThan, $ZodCheckMultipleOf, $ZodCheckNumberFormat, $ZodCheckBigIntFormat, $ZodCheckMaxSize, $ZodCheckMinSize, $ZodCheckSizeEquals, $ZodCheckMaxLength, $ZodCheckMinLength, $ZodCheckLengthEquals, $ZodCheckStringFormat, $ZodCheckRegex, $ZodCheckLowerCase, $ZodCheckUpperCase, $ZodCheckIncludes, $ZodCheckStartsWith, $ZodCheckEndsWith, $ZodCheckProperty, $ZodCheckMimeType, $ZodCheckOverwrite;
|
|
@@ -5209,15 +5209,15 @@ var init_checks = __esm({
|
|
|
5209
5209
|
bag.exclusiveMaximum = def.value;
|
|
5210
5210
|
}
|
|
5211
5211
|
});
|
|
5212
|
-
inst._zod.check = (
|
|
5213
|
-
if (def.inclusive ?
|
|
5212
|
+
inst._zod.check = (payload) => {
|
|
5213
|
+
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
|
|
5214
5214
|
return;
|
|
5215
5215
|
}
|
|
5216
|
-
|
|
5216
|
+
payload.issues.push({
|
|
5217
5217
|
origin,
|
|
5218
5218
|
code: "too_big",
|
|
5219
5219
|
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
5220
|
-
input:
|
|
5220
|
+
input: payload.value,
|
|
5221
5221
|
inclusive: def.inclusive,
|
|
5222
5222
|
inst,
|
|
5223
5223
|
continue: !def.abort
|
|
@@ -5237,15 +5237,15 @@ var init_checks = __esm({
|
|
|
5237
5237
|
bag.exclusiveMinimum = def.value;
|
|
5238
5238
|
}
|
|
5239
5239
|
});
|
|
5240
|
-
inst._zod.check = (
|
|
5241
|
-
if (def.inclusive ?
|
|
5240
|
+
inst._zod.check = (payload) => {
|
|
5241
|
+
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
|
|
5242
5242
|
return;
|
|
5243
5243
|
}
|
|
5244
|
-
|
|
5244
|
+
payload.issues.push({
|
|
5245
5245
|
origin,
|
|
5246
5246
|
code: "too_small",
|
|
5247
5247
|
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
5248
|
-
input:
|
|
5248
|
+
input: payload.value,
|
|
5249
5249
|
inclusive: def.inclusive,
|
|
5250
5250
|
inst,
|
|
5251
5251
|
continue: !def.abort
|
|
@@ -5258,17 +5258,17 @@ var init_checks = __esm({
|
|
|
5258
5258
|
var _a3;
|
|
5259
5259
|
(_a3 = inst2._zod.bag).multipleOf ?? (_a3.multipleOf = def.value);
|
|
5260
5260
|
});
|
|
5261
|
-
inst._zod.check = (
|
|
5262
|
-
if (typeof
|
|
5261
|
+
inst._zod.check = (payload) => {
|
|
5262
|
+
if (typeof payload.value !== typeof def.value)
|
|
5263
5263
|
throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
5264
|
-
const isMultiple = typeof
|
|
5264
|
+
const isMultiple = typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder2(payload.value, def.value) === 0;
|
|
5265
5265
|
if (isMultiple)
|
|
5266
5266
|
return;
|
|
5267
|
-
|
|
5268
|
-
origin: typeof
|
|
5267
|
+
payload.issues.push({
|
|
5268
|
+
origin: typeof payload.value,
|
|
5269
5269
|
code: "not_multiple_of",
|
|
5270
5270
|
divisor: def.value,
|
|
5271
|
-
input:
|
|
5271
|
+
input: payload.value,
|
|
5272
5272
|
inst,
|
|
5273
5273
|
continue: !def.abort
|
|
5274
5274
|
});
|
|
@@ -5288,11 +5288,11 @@ var init_checks = __esm({
|
|
|
5288
5288
|
if (isInt)
|
|
5289
5289
|
bag.pattern = integer;
|
|
5290
5290
|
});
|
|
5291
|
-
inst._zod.check = (
|
|
5292
|
-
const input =
|
|
5291
|
+
inst._zod.check = (payload) => {
|
|
5292
|
+
const input = payload.value;
|
|
5293
5293
|
if (isInt) {
|
|
5294
5294
|
if (!Number.isInteger(input)) {
|
|
5295
|
-
|
|
5295
|
+
payload.issues.push({
|
|
5296
5296
|
expected: origin,
|
|
5297
5297
|
format: def.format,
|
|
5298
5298
|
code: "invalid_type",
|
|
@@ -5304,7 +5304,7 @@ var init_checks = __esm({
|
|
|
5304
5304
|
}
|
|
5305
5305
|
if (!Number.isSafeInteger(input)) {
|
|
5306
5306
|
if (input > 0) {
|
|
5307
|
-
|
|
5307
|
+
payload.issues.push({
|
|
5308
5308
|
input,
|
|
5309
5309
|
code: "too_big",
|
|
5310
5310
|
maximum: Number.MAX_SAFE_INTEGER,
|
|
@@ -5315,7 +5315,7 @@ var init_checks = __esm({
|
|
|
5315
5315
|
continue: !def.abort
|
|
5316
5316
|
});
|
|
5317
5317
|
} else {
|
|
5318
|
-
|
|
5318
|
+
payload.issues.push({
|
|
5319
5319
|
input,
|
|
5320
5320
|
code: "too_small",
|
|
5321
5321
|
minimum: Number.MIN_SAFE_INTEGER,
|
|
@@ -5330,7 +5330,7 @@ var init_checks = __esm({
|
|
|
5330
5330
|
}
|
|
5331
5331
|
}
|
|
5332
5332
|
if (input < minimum) {
|
|
5333
|
-
|
|
5333
|
+
payload.issues.push({
|
|
5334
5334
|
origin: "number",
|
|
5335
5335
|
input,
|
|
5336
5336
|
code: "too_small",
|
|
@@ -5341,7 +5341,7 @@ var init_checks = __esm({
|
|
|
5341
5341
|
});
|
|
5342
5342
|
}
|
|
5343
5343
|
if (input > maximum) {
|
|
5344
|
-
|
|
5344
|
+
payload.issues.push({
|
|
5345
5345
|
origin: "number",
|
|
5346
5346
|
input,
|
|
5347
5347
|
code: "too_big",
|
|
@@ -5362,10 +5362,10 @@ var init_checks = __esm({
|
|
|
5362
5362
|
bag.minimum = minimum;
|
|
5363
5363
|
bag.maximum = maximum;
|
|
5364
5364
|
});
|
|
5365
|
-
inst._zod.check = (
|
|
5366
|
-
const input =
|
|
5365
|
+
inst._zod.check = (payload) => {
|
|
5366
|
+
const input = payload.value;
|
|
5367
5367
|
if (input < minimum) {
|
|
5368
|
-
|
|
5368
|
+
payload.issues.push({
|
|
5369
5369
|
origin: "bigint",
|
|
5370
5370
|
input,
|
|
5371
5371
|
code: "too_small",
|
|
@@ -5376,7 +5376,7 @@ var init_checks = __esm({
|
|
|
5376
5376
|
});
|
|
5377
5377
|
}
|
|
5378
5378
|
if (input > maximum) {
|
|
5379
|
-
|
|
5379
|
+
payload.issues.push({
|
|
5380
5380
|
origin: "bigint",
|
|
5381
5381
|
input,
|
|
5382
5382
|
code: "too_big",
|
|
@@ -5391,8 +5391,8 @@ var init_checks = __esm({
|
|
|
5391
5391
|
$ZodCheckMaxSize = /* @__PURE__ */ $constructor("$ZodCheckMaxSize", (inst, def) => {
|
|
5392
5392
|
var _a3;
|
|
5393
5393
|
$ZodCheck.init(inst, def);
|
|
5394
|
-
(_a3 = inst._zod.def).when ?? (_a3.when = (
|
|
5395
|
-
const val =
|
|
5394
|
+
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
|
|
5395
|
+
const val = payload.value;
|
|
5396
5396
|
return !nullish(val) && val.size !== void 0;
|
|
5397
5397
|
});
|
|
5398
5398
|
inst._zod.onattach.push((inst2) => {
|
|
@@ -5400,12 +5400,12 @@ var init_checks = __esm({
|
|
|
5400
5400
|
if (def.maximum < curr)
|
|
5401
5401
|
inst2._zod.bag.maximum = def.maximum;
|
|
5402
5402
|
});
|
|
5403
|
-
inst._zod.check = (
|
|
5404
|
-
const input =
|
|
5403
|
+
inst._zod.check = (payload) => {
|
|
5404
|
+
const input = payload.value;
|
|
5405
5405
|
const size = input.size;
|
|
5406
5406
|
if (size <= def.maximum)
|
|
5407
5407
|
return;
|
|
5408
|
-
|
|
5408
|
+
payload.issues.push({
|
|
5409
5409
|
origin: getSizableOrigin(input),
|
|
5410
5410
|
code: "too_big",
|
|
5411
5411
|
maximum: def.maximum,
|
|
@@ -5419,8 +5419,8 @@ var init_checks = __esm({
|
|
|
5419
5419
|
$ZodCheckMinSize = /* @__PURE__ */ $constructor("$ZodCheckMinSize", (inst, def) => {
|
|
5420
5420
|
var _a3;
|
|
5421
5421
|
$ZodCheck.init(inst, def);
|
|
5422
|
-
(_a3 = inst._zod.def).when ?? (_a3.when = (
|
|
5423
|
-
const val =
|
|
5422
|
+
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
|
|
5423
|
+
const val = payload.value;
|
|
5424
5424
|
return !nullish(val) && val.size !== void 0;
|
|
5425
5425
|
});
|
|
5426
5426
|
inst._zod.onattach.push((inst2) => {
|
|
@@ -5428,12 +5428,12 @@ var init_checks = __esm({
|
|
|
5428
5428
|
if (def.minimum > curr)
|
|
5429
5429
|
inst2._zod.bag.minimum = def.minimum;
|
|
5430
5430
|
});
|
|
5431
|
-
inst._zod.check = (
|
|
5432
|
-
const input =
|
|
5431
|
+
inst._zod.check = (payload) => {
|
|
5432
|
+
const input = payload.value;
|
|
5433
5433
|
const size = input.size;
|
|
5434
5434
|
if (size >= def.minimum)
|
|
5435
5435
|
return;
|
|
5436
|
-
|
|
5436
|
+
payload.issues.push({
|
|
5437
5437
|
origin: getSizableOrigin(input),
|
|
5438
5438
|
code: "too_small",
|
|
5439
5439
|
minimum: def.minimum,
|
|
@@ -5447,8 +5447,8 @@ var init_checks = __esm({
|
|
|
5447
5447
|
$ZodCheckSizeEquals = /* @__PURE__ */ $constructor("$ZodCheckSizeEquals", (inst, def) => {
|
|
5448
5448
|
var _a3;
|
|
5449
5449
|
$ZodCheck.init(inst, def);
|
|
5450
|
-
(_a3 = inst._zod.def).when ?? (_a3.when = (
|
|
5451
|
-
const val =
|
|
5450
|
+
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
|
|
5451
|
+
const val = payload.value;
|
|
5452
5452
|
return !nullish(val) && val.size !== void 0;
|
|
5453
5453
|
});
|
|
5454
5454
|
inst._zod.onattach.push((inst2) => {
|
|
@@ -5457,18 +5457,18 @@ var init_checks = __esm({
|
|
|
5457
5457
|
bag.maximum = def.size;
|
|
5458
5458
|
bag.size = def.size;
|
|
5459
5459
|
});
|
|
5460
|
-
inst._zod.check = (
|
|
5461
|
-
const input =
|
|
5460
|
+
inst._zod.check = (payload) => {
|
|
5461
|
+
const input = payload.value;
|
|
5462
5462
|
const size = input.size;
|
|
5463
5463
|
if (size === def.size)
|
|
5464
5464
|
return;
|
|
5465
5465
|
const tooBig2 = size > def.size;
|
|
5466
|
-
|
|
5466
|
+
payload.issues.push({
|
|
5467
5467
|
origin: getSizableOrigin(input),
|
|
5468
5468
|
...tooBig2 ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size },
|
|
5469
5469
|
inclusive: true,
|
|
5470
5470
|
exact: true,
|
|
5471
|
-
input:
|
|
5471
|
+
input: payload.value,
|
|
5472
5472
|
inst,
|
|
5473
5473
|
continue: !def.abort
|
|
5474
5474
|
});
|
|
@@ -5477,8 +5477,8 @@ var init_checks = __esm({
|
|
|
5477
5477
|
$ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
5478
5478
|
var _a3;
|
|
5479
5479
|
$ZodCheck.init(inst, def);
|
|
5480
|
-
(_a3 = inst._zod.def).when ?? (_a3.when = (
|
|
5481
|
-
const val =
|
|
5480
|
+
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
|
|
5481
|
+
const val = payload.value;
|
|
5482
5482
|
return !nullish(val) && val.length !== void 0;
|
|
5483
5483
|
});
|
|
5484
5484
|
inst._zod.onattach.push((inst2) => {
|
|
@@ -5486,13 +5486,13 @@ var init_checks = __esm({
|
|
|
5486
5486
|
if (def.maximum < curr)
|
|
5487
5487
|
inst2._zod.bag.maximum = def.maximum;
|
|
5488
5488
|
});
|
|
5489
|
-
inst._zod.check = (
|
|
5490
|
-
const input =
|
|
5489
|
+
inst._zod.check = (payload) => {
|
|
5490
|
+
const input = payload.value;
|
|
5491
5491
|
const length = input.length;
|
|
5492
5492
|
if (length <= def.maximum)
|
|
5493
5493
|
return;
|
|
5494
5494
|
const origin = getLengthableOrigin(input);
|
|
5495
|
-
|
|
5495
|
+
payload.issues.push({
|
|
5496
5496
|
origin,
|
|
5497
5497
|
code: "too_big",
|
|
5498
5498
|
maximum: def.maximum,
|
|
@@ -5506,8 +5506,8 @@ var init_checks = __esm({
|
|
|
5506
5506
|
$ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
5507
5507
|
var _a3;
|
|
5508
5508
|
$ZodCheck.init(inst, def);
|
|
5509
|
-
(_a3 = inst._zod.def).when ?? (_a3.when = (
|
|
5510
|
-
const val =
|
|
5509
|
+
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
|
|
5510
|
+
const val = payload.value;
|
|
5511
5511
|
return !nullish(val) && val.length !== void 0;
|
|
5512
5512
|
});
|
|
5513
5513
|
inst._zod.onattach.push((inst2) => {
|
|
@@ -5515,13 +5515,13 @@ var init_checks = __esm({
|
|
|
5515
5515
|
if (def.minimum > curr)
|
|
5516
5516
|
inst2._zod.bag.minimum = def.minimum;
|
|
5517
5517
|
});
|
|
5518
|
-
inst._zod.check = (
|
|
5519
|
-
const input =
|
|
5518
|
+
inst._zod.check = (payload) => {
|
|
5519
|
+
const input = payload.value;
|
|
5520
5520
|
const length = input.length;
|
|
5521
5521
|
if (length >= def.minimum)
|
|
5522
5522
|
return;
|
|
5523
5523
|
const origin = getLengthableOrigin(input);
|
|
5524
|
-
|
|
5524
|
+
payload.issues.push({
|
|
5525
5525
|
origin,
|
|
5526
5526
|
code: "too_small",
|
|
5527
5527
|
minimum: def.minimum,
|
|
@@ -5535,8 +5535,8 @@ var init_checks = __esm({
|
|
|
5535
5535
|
$ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
5536
5536
|
var _a3;
|
|
5537
5537
|
$ZodCheck.init(inst, def);
|
|
5538
|
-
(_a3 = inst._zod.def).when ?? (_a3.when = (
|
|
5539
|
-
const val =
|
|
5538
|
+
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
|
|
5539
|
+
const val = payload.value;
|
|
5540
5540
|
return !nullish(val) && val.length !== void 0;
|
|
5541
5541
|
});
|
|
5542
5542
|
inst._zod.onattach.push((inst2) => {
|
|
@@ -5545,19 +5545,19 @@ var init_checks = __esm({
|
|
|
5545
5545
|
bag.maximum = def.length;
|
|
5546
5546
|
bag.length = def.length;
|
|
5547
5547
|
});
|
|
5548
|
-
inst._zod.check = (
|
|
5549
|
-
const input =
|
|
5548
|
+
inst._zod.check = (payload) => {
|
|
5549
|
+
const input = payload.value;
|
|
5550
5550
|
const length = input.length;
|
|
5551
5551
|
if (length === def.length)
|
|
5552
5552
|
return;
|
|
5553
5553
|
const origin = getLengthableOrigin(input);
|
|
5554
5554
|
const tooBig2 = length > def.length;
|
|
5555
|
-
|
|
5555
|
+
payload.issues.push({
|
|
5556
5556
|
origin,
|
|
5557
5557
|
...tooBig2 ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length },
|
|
5558
5558
|
inclusive: true,
|
|
5559
5559
|
exact: true,
|
|
5560
|
-
input:
|
|
5560
|
+
input: payload.value,
|
|
5561
5561
|
inst,
|
|
5562
5562
|
continue: !def.abort
|
|
5563
5563
|
});
|
|
@@ -5575,15 +5575,15 @@ var init_checks = __esm({
|
|
|
5575
5575
|
}
|
|
5576
5576
|
});
|
|
5577
5577
|
if (def.pattern)
|
|
5578
|
-
(_a3 = inst._zod).check ?? (_a3.check = (
|
|
5578
|
+
(_a3 = inst._zod).check ?? (_a3.check = (payload) => {
|
|
5579
5579
|
def.pattern.lastIndex = 0;
|
|
5580
|
-
if (def.pattern.test(
|
|
5580
|
+
if (def.pattern.test(payload.value))
|
|
5581
5581
|
return;
|
|
5582
|
-
|
|
5582
|
+
payload.issues.push({
|
|
5583
5583
|
origin: "string",
|
|
5584
5584
|
code: "invalid_format",
|
|
5585
5585
|
format: def.format,
|
|
5586
|
-
input:
|
|
5586
|
+
input: payload.value,
|
|
5587
5587
|
...def.pattern ? { pattern: def.pattern.toString() } : {},
|
|
5588
5588
|
inst,
|
|
5589
5589
|
continue: !def.abort
|
|
@@ -5595,15 +5595,15 @@ var init_checks = __esm({
|
|
|
5595
5595
|
});
|
|
5596
5596
|
$ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
|
|
5597
5597
|
$ZodCheckStringFormat.init(inst, def);
|
|
5598
|
-
inst._zod.check = (
|
|
5598
|
+
inst._zod.check = (payload) => {
|
|
5599
5599
|
def.pattern.lastIndex = 0;
|
|
5600
|
-
if (def.pattern.test(
|
|
5600
|
+
if (def.pattern.test(payload.value))
|
|
5601
5601
|
return;
|
|
5602
|
-
|
|
5602
|
+
payload.issues.push({
|
|
5603
5603
|
origin: "string",
|
|
5604
5604
|
code: "invalid_format",
|
|
5605
5605
|
format: "regex",
|
|
5606
|
-
input:
|
|
5606
|
+
input: payload.value,
|
|
5607
5607
|
pattern: def.pattern.toString(),
|
|
5608
5608
|
inst,
|
|
5609
5609
|
continue: !def.abort
|
|
@@ -5628,15 +5628,15 @@ var init_checks = __esm({
|
|
|
5628
5628
|
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
5629
5629
|
bag.patterns.add(pattern);
|
|
5630
5630
|
});
|
|
5631
|
-
inst._zod.check = (
|
|
5632
|
-
if (
|
|
5631
|
+
inst._zod.check = (payload) => {
|
|
5632
|
+
if (payload.value.includes(def.includes, def.position))
|
|
5633
5633
|
return;
|
|
5634
|
-
|
|
5634
|
+
payload.issues.push({
|
|
5635
5635
|
origin: "string",
|
|
5636
5636
|
code: "invalid_format",
|
|
5637
5637
|
format: "includes",
|
|
5638
5638
|
includes: def.includes,
|
|
5639
|
-
input:
|
|
5639
|
+
input: payload.value,
|
|
5640
5640
|
inst,
|
|
5641
5641
|
continue: !def.abort
|
|
5642
5642
|
});
|
|
@@ -5651,15 +5651,15 @@ var init_checks = __esm({
|
|
|
5651
5651
|
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
5652
5652
|
bag.patterns.add(pattern);
|
|
5653
5653
|
});
|
|
5654
|
-
inst._zod.check = (
|
|
5655
|
-
if (
|
|
5654
|
+
inst._zod.check = (payload) => {
|
|
5655
|
+
if (payload.value.startsWith(def.prefix))
|
|
5656
5656
|
return;
|
|
5657
|
-
|
|
5657
|
+
payload.issues.push({
|
|
5658
5658
|
origin: "string",
|
|
5659
5659
|
code: "invalid_format",
|
|
5660
5660
|
format: "starts_with",
|
|
5661
5661
|
prefix: def.prefix,
|
|
5662
|
-
input:
|
|
5662
|
+
input: payload.value,
|
|
5663
5663
|
inst,
|
|
5664
5664
|
continue: !def.abort
|
|
5665
5665
|
});
|
|
@@ -5674,15 +5674,15 @@ var init_checks = __esm({
|
|
|
5674
5674
|
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
5675
5675
|
bag.patterns.add(pattern);
|
|
5676
5676
|
});
|
|
5677
|
-
inst._zod.check = (
|
|
5678
|
-
if (
|
|
5677
|
+
inst._zod.check = (payload) => {
|
|
5678
|
+
if (payload.value.endsWith(def.suffix))
|
|
5679
5679
|
return;
|
|
5680
|
-
|
|
5680
|
+
payload.issues.push({
|
|
5681
5681
|
origin: "string",
|
|
5682
5682
|
code: "invalid_format",
|
|
5683
5683
|
format: "ends_with",
|
|
5684
5684
|
suffix: def.suffix,
|
|
5685
|
-
input:
|
|
5685
|
+
input: payload.value,
|
|
5686
5686
|
inst,
|
|
5687
5687
|
continue: !def.abort
|
|
5688
5688
|
});
|
|
@@ -5690,15 +5690,15 @@ var init_checks = __esm({
|
|
|
5690
5690
|
});
|
|
5691
5691
|
$ZodCheckProperty = /* @__PURE__ */ $constructor("$ZodCheckProperty", (inst, def) => {
|
|
5692
5692
|
$ZodCheck.init(inst, def);
|
|
5693
|
-
inst._zod.check = (
|
|
5693
|
+
inst._zod.check = (payload) => {
|
|
5694
5694
|
const result = def.schema._zod.run({
|
|
5695
|
-
value:
|
|
5695
|
+
value: payload.value[def.property],
|
|
5696
5696
|
issues: []
|
|
5697
5697
|
}, {});
|
|
5698
5698
|
if (result instanceof Promise) {
|
|
5699
|
-
return result.then((result2) => handleCheckPropertyResult(result2,
|
|
5699
|
+
return result.then((result2) => handleCheckPropertyResult(result2, payload, def.property));
|
|
5700
5700
|
}
|
|
5701
|
-
handleCheckPropertyResult(result,
|
|
5701
|
+
handleCheckPropertyResult(result, payload, def.property);
|
|
5702
5702
|
return;
|
|
5703
5703
|
};
|
|
5704
5704
|
});
|
|
@@ -5708,13 +5708,13 @@ var init_checks = __esm({
|
|
|
5708
5708
|
inst._zod.onattach.push((inst2) => {
|
|
5709
5709
|
inst2._zod.bag.mime = def.mime;
|
|
5710
5710
|
});
|
|
5711
|
-
inst._zod.check = (
|
|
5712
|
-
if (mimeSet.has(
|
|
5711
|
+
inst._zod.check = (payload) => {
|
|
5712
|
+
if (mimeSet.has(payload.value.type))
|
|
5713
5713
|
return;
|
|
5714
|
-
|
|
5714
|
+
payload.issues.push({
|
|
5715
5715
|
code: "invalid_value",
|
|
5716
5716
|
values: def.mime,
|
|
5717
|
-
input:
|
|
5717
|
+
input: payload.value.type,
|
|
5718
5718
|
inst,
|
|
5719
5719
|
continue: !def.abort
|
|
5720
5720
|
});
|
|
@@ -5722,8 +5722,8 @@ var init_checks = __esm({
|
|
|
5722
5722
|
});
|
|
5723
5723
|
$ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
5724
5724
|
$ZodCheck.init(inst, def);
|
|
5725
|
-
inst._zod.check = (
|
|
5726
|
-
|
|
5725
|
+
inst._zod.check = (payload) => {
|
|
5726
|
+
payload.value = def.tx(payload.value);
|
|
5727
5727
|
};
|
|
5728
5728
|
});
|
|
5729
5729
|
}
|
|
@@ -5873,7 +5873,7 @@ function normalizeDef(def) {
|
|
|
5873
5873
|
optionalKeys: new Set(okeys)
|
|
5874
5874
|
};
|
|
5875
5875
|
}
|
|
5876
|
-
function handleCatchall(proms, input,
|
|
5876
|
+
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
5877
5877
|
const unrecognized = [];
|
|
5878
5878
|
const keySet = def.keySet;
|
|
5879
5879
|
const _catchall = def.catchall._zod;
|
|
@@ -5891,13 +5891,13 @@ function handleCatchall(proms, input, payload2, ctx, def, inst) {
|
|
|
5891
5891
|
}
|
|
5892
5892
|
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
5893
5893
|
if (r instanceof Promise) {
|
|
5894
|
-
proms.push(r.then((r2) => handlePropertyResult(r2,
|
|
5894
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
5895
5895
|
} else {
|
|
5896
|
-
handlePropertyResult(r,
|
|
5896
|
+
handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
5897
5897
|
}
|
|
5898
5898
|
}
|
|
5899
5899
|
if (unrecognized.length) {
|
|
5900
|
-
|
|
5900
|
+
payload.issues.push({
|
|
5901
5901
|
code: "unrecognized_keys",
|
|
5902
5902
|
keys: unrecognized,
|
|
5903
5903
|
input,
|
|
@@ -5905,9 +5905,9 @@ function handleCatchall(proms, input, payload2, ctx, def, inst) {
|
|
|
5905
5905
|
});
|
|
5906
5906
|
}
|
|
5907
5907
|
if (!proms.length)
|
|
5908
|
-
return
|
|
5908
|
+
return payload;
|
|
5909
5909
|
return Promise.all(proms).then(() => {
|
|
5910
|
-
return
|
|
5910
|
+
return payload;
|
|
5911
5911
|
});
|
|
5912
5912
|
}
|
|
5913
5913
|
function handleUnionResults(results, final, inst, ctx) {
|
|
@@ -6114,22 +6114,22 @@ function handleOptionalResult(result, input) {
|
|
|
6114
6114
|
}
|
|
6115
6115
|
return result;
|
|
6116
6116
|
}
|
|
6117
|
-
function handleDefaultResult(
|
|
6118
|
-
if (
|
|
6119
|
-
|
|
6117
|
+
function handleDefaultResult(payload, def) {
|
|
6118
|
+
if (payload.value === void 0) {
|
|
6119
|
+
payload.value = def.defaultValue;
|
|
6120
6120
|
}
|
|
6121
|
-
return
|
|
6121
|
+
return payload;
|
|
6122
6122
|
}
|
|
6123
|
-
function handleNonOptionalResult(
|
|
6124
|
-
if (!
|
|
6125
|
-
|
|
6123
|
+
function handleNonOptionalResult(payload, inst) {
|
|
6124
|
+
if (!payload.issues.length && payload.value === void 0) {
|
|
6125
|
+
payload.issues.push({
|
|
6126
6126
|
code: "invalid_type",
|
|
6127
6127
|
expected: "nonoptional",
|
|
6128
|
-
input:
|
|
6128
|
+
input: payload.value,
|
|
6129
6129
|
inst
|
|
6130
6130
|
});
|
|
6131
6131
|
}
|
|
6132
|
-
return
|
|
6132
|
+
return payload;
|
|
6133
6133
|
}
|
|
6134
6134
|
function handlePipeResult(left, next, ctx) {
|
|
6135
6135
|
if (left.issues.length) {
|
|
@@ -6165,11 +6165,11 @@ function handleCodecTxResult(left, value, nextSchema, ctx) {
|
|
|
6165
6165
|
}
|
|
6166
6166
|
return nextSchema._zod.run({ value, issues: left.issues }, ctx);
|
|
6167
6167
|
}
|
|
6168
|
-
function handleReadonlyResult(
|
|
6169
|
-
|
|
6170
|
-
return
|
|
6168
|
+
function handleReadonlyResult(payload) {
|
|
6169
|
+
payload.value = Object.freeze(payload.value);
|
|
6170
|
+
return payload;
|
|
6171
6171
|
}
|
|
6172
|
-
function handleRefineResult(result,
|
|
6172
|
+
function handleRefineResult(result, payload, input, inst) {
|
|
6173
6173
|
if (!result) {
|
|
6174
6174
|
const _iss = {
|
|
6175
6175
|
code: "custom",
|
|
@@ -6183,7 +6183,7 @@ function handleRefineResult(result, payload2, input, inst) {
|
|
|
6183
6183
|
};
|
|
6184
6184
|
if (inst._zod.def.params)
|
|
6185
6185
|
_iss.params = inst._zod.def.params;
|
|
6186
|
-
|
|
6186
|
+
payload.issues.push(issue(_iss));
|
|
6187
6187
|
}
|
|
6188
6188
|
}
|
|
6189
6189
|
var $ZodType, $ZodString, $ZodStringFormat, $ZodGUID, $ZodUUID, $ZodEmail, $ZodURL, $ZodEmoji, $ZodNanoID, $ZodCUID, $ZodCUID2, $ZodULID, $ZodXID, $ZodKSUID, $ZodISODateTime, $ZodISODate, $ZodISOTime, $ZodISODuration, $ZodIPv4, $ZodIPv6, $ZodMAC, $ZodCIDRv4, $ZodCIDRv6, $ZodBase64, $ZodBase64URL, $ZodE164, $ZodJWT, $ZodCustomStringFormat, $ZodNumber, $ZodNumberFormat, $ZodBoolean, $ZodBigInt, $ZodBigIntFormat, $ZodSymbol, $ZodUndefined, $ZodNull, $ZodAny, $ZodUnknown, $ZodNever, $ZodVoid, $ZodDate, $ZodArray, $ZodObject, $ZodObjectJIT, $ZodUnion, $ZodXor, $ZodDiscriminatedUnion, $ZodIntersection, $ZodTuple, $ZodRecord, $ZodMap, $ZodSet, $ZodEnum, $ZodLiteral, $ZodFile, $ZodTransform, $ZodOptional, $ZodExactOptional, $ZodNullable, $ZodDefault, $ZodPrefault, $ZodNonOptional, $ZodSuccess, $ZodCatch, $ZodNaN, $ZodPipe, $ZodCodec, $ZodPreprocess, $ZodReadonly, $ZodTemplateLiteral, $ZodFunction, $ZodPromise, $ZodLazy, $ZodCustom;
|
|
@@ -6218,54 +6218,54 @@ var init_schemas = __esm({
|
|
|
6218
6218
|
inst._zod.run = inst._zod.parse;
|
|
6219
6219
|
});
|
|
6220
6220
|
} else {
|
|
6221
|
-
const runChecks = (
|
|
6222
|
-
let isAborted2 = aborted(
|
|
6221
|
+
const runChecks = (payload, checks2, ctx) => {
|
|
6222
|
+
let isAborted2 = aborted(payload);
|
|
6223
6223
|
let asyncResult;
|
|
6224
6224
|
for (const ch of checks2) {
|
|
6225
6225
|
if (ch._zod.def.when) {
|
|
6226
|
-
if (explicitlyAborted(
|
|
6226
|
+
if (explicitlyAborted(payload))
|
|
6227
6227
|
continue;
|
|
6228
|
-
const shouldRun = ch._zod.def.when(
|
|
6228
|
+
const shouldRun = ch._zod.def.when(payload);
|
|
6229
6229
|
if (!shouldRun)
|
|
6230
6230
|
continue;
|
|
6231
6231
|
} else if (isAborted2) {
|
|
6232
6232
|
continue;
|
|
6233
6233
|
}
|
|
6234
|
-
const currLen =
|
|
6235
|
-
const _ = ch._zod.check(
|
|
6234
|
+
const currLen = payload.issues.length;
|
|
6235
|
+
const _ = ch._zod.check(payload);
|
|
6236
6236
|
if (_ instanceof Promise && ctx?.async === false) {
|
|
6237
6237
|
throw new $ZodAsyncError();
|
|
6238
6238
|
}
|
|
6239
6239
|
if (asyncResult || _ instanceof Promise) {
|
|
6240
6240
|
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
6241
6241
|
await _;
|
|
6242
|
-
const nextLen =
|
|
6242
|
+
const nextLen = payload.issues.length;
|
|
6243
6243
|
if (nextLen === currLen)
|
|
6244
6244
|
return;
|
|
6245
6245
|
if (!isAborted2)
|
|
6246
|
-
isAborted2 = aborted(
|
|
6246
|
+
isAborted2 = aborted(payload, currLen);
|
|
6247
6247
|
});
|
|
6248
6248
|
} else {
|
|
6249
|
-
const nextLen =
|
|
6249
|
+
const nextLen = payload.issues.length;
|
|
6250
6250
|
if (nextLen === currLen)
|
|
6251
6251
|
continue;
|
|
6252
6252
|
if (!isAborted2)
|
|
6253
|
-
isAborted2 = aborted(
|
|
6253
|
+
isAborted2 = aborted(payload, currLen);
|
|
6254
6254
|
}
|
|
6255
6255
|
}
|
|
6256
6256
|
if (asyncResult) {
|
|
6257
6257
|
return asyncResult.then(() => {
|
|
6258
|
-
return
|
|
6258
|
+
return payload;
|
|
6259
6259
|
});
|
|
6260
6260
|
}
|
|
6261
|
-
return
|
|
6261
|
+
return payload;
|
|
6262
6262
|
};
|
|
6263
|
-
const handleCanaryResult = (canary,
|
|
6263
|
+
const handleCanaryResult = (canary, payload, ctx) => {
|
|
6264
6264
|
if (aborted(canary)) {
|
|
6265
6265
|
canary.aborted = true;
|
|
6266
6266
|
return canary;
|
|
6267
6267
|
}
|
|
6268
|
-
const checkResult = runChecks(
|
|
6268
|
+
const checkResult = runChecks(payload, checks, ctx);
|
|
6269
6269
|
if (checkResult instanceof Promise) {
|
|
6270
6270
|
if (ctx.async === false)
|
|
6271
6271
|
throw new $ZodAsyncError();
|
|
@@ -6273,20 +6273,20 @@ var init_schemas = __esm({
|
|
|
6273
6273
|
}
|
|
6274
6274
|
return inst._zod.parse(checkResult, ctx);
|
|
6275
6275
|
};
|
|
6276
|
-
inst._zod.run = (
|
|
6276
|
+
inst._zod.run = (payload, ctx) => {
|
|
6277
6277
|
if (ctx.skipChecks) {
|
|
6278
|
-
return inst._zod.parse(
|
|
6278
|
+
return inst._zod.parse(payload, ctx);
|
|
6279
6279
|
}
|
|
6280
6280
|
if (ctx.direction === "backward") {
|
|
6281
|
-
const canary = inst._zod.parse({ value:
|
|
6281
|
+
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
|
|
6282
6282
|
if (canary instanceof Promise) {
|
|
6283
6283
|
return canary.then((canary2) => {
|
|
6284
|
-
return handleCanaryResult(canary2,
|
|
6284
|
+
return handleCanaryResult(canary2, payload, ctx);
|
|
6285
6285
|
});
|
|
6286
6286
|
}
|
|
6287
|
-
return handleCanaryResult(canary,
|
|
6287
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
6288
6288
|
}
|
|
6289
|
-
const result = inst._zod.parse(
|
|
6289
|
+
const result = inst._zod.parse(payload, ctx);
|
|
6290
6290
|
if (result instanceof Promise) {
|
|
6291
6291
|
if (ctx.async === false)
|
|
6292
6292
|
throw new $ZodAsyncError();
|
|
@@ -6311,21 +6311,21 @@ var init_schemas = __esm({
|
|
|
6311
6311
|
$ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
6312
6312
|
$ZodType.init(inst, def);
|
|
6313
6313
|
inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string(inst._zod.bag);
|
|
6314
|
-
inst._zod.parse = (
|
|
6314
|
+
inst._zod.parse = (payload, _) => {
|
|
6315
6315
|
if (def.coerce)
|
|
6316
6316
|
try {
|
|
6317
|
-
|
|
6317
|
+
payload.value = String(payload.value);
|
|
6318
6318
|
} catch (_2) {
|
|
6319
6319
|
}
|
|
6320
|
-
if (typeof
|
|
6321
|
-
return
|
|
6322
|
-
|
|
6320
|
+
if (typeof payload.value === "string")
|
|
6321
|
+
return payload;
|
|
6322
|
+
payload.issues.push({
|
|
6323
6323
|
expected: "string",
|
|
6324
6324
|
code: "invalid_type",
|
|
6325
|
-
input:
|
|
6325
|
+
input: payload.value,
|
|
6326
6326
|
inst
|
|
6327
6327
|
});
|
|
6328
|
-
return
|
|
6328
|
+
return payload;
|
|
6329
6329
|
};
|
|
6330
6330
|
});
|
|
6331
6331
|
$ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
|
|
@@ -6362,16 +6362,16 @@ var init_schemas = __esm({
|
|
|
6362
6362
|
});
|
|
6363
6363
|
$ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
6364
6364
|
$ZodStringFormat.init(inst, def);
|
|
6365
|
-
inst._zod.check = (
|
|
6365
|
+
inst._zod.check = (payload) => {
|
|
6366
6366
|
try {
|
|
6367
|
-
const trimmed =
|
|
6367
|
+
const trimmed = payload.value.trim();
|
|
6368
6368
|
if (!def.normalize && def.protocol?.source === httpProtocol.source) {
|
|
6369
6369
|
if (!/^https?:\/\//i.test(trimmed)) {
|
|
6370
|
-
|
|
6370
|
+
payload.issues.push({
|
|
6371
6371
|
code: "invalid_format",
|
|
6372
6372
|
format: "url",
|
|
6373
6373
|
note: "Invalid URL format",
|
|
6374
|
-
input:
|
|
6374
|
+
input: payload.value,
|
|
6375
6375
|
inst,
|
|
6376
6376
|
continue: !def.abort
|
|
6377
6377
|
});
|
|
@@ -6382,12 +6382,12 @@ var init_schemas = __esm({
|
|
|
6382
6382
|
if (def.hostname) {
|
|
6383
6383
|
def.hostname.lastIndex = 0;
|
|
6384
6384
|
if (!def.hostname.test(url2.hostname)) {
|
|
6385
|
-
|
|
6385
|
+
payload.issues.push({
|
|
6386
6386
|
code: "invalid_format",
|
|
6387
6387
|
format: "url",
|
|
6388
6388
|
note: "Invalid hostname",
|
|
6389
6389
|
pattern: def.hostname.source,
|
|
6390
|
-
input:
|
|
6390
|
+
input: payload.value,
|
|
6391
6391
|
inst,
|
|
6392
6392
|
continue: !def.abort
|
|
6393
6393
|
});
|
|
@@ -6396,28 +6396,28 @@ var init_schemas = __esm({
|
|
|
6396
6396
|
if (def.protocol) {
|
|
6397
6397
|
def.protocol.lastIndex = 0;
|
|
6398
6398
|
if (!def.protocol.test(url2.protocol.endsWith(":") ? url2.protocol.slice(0, -1) : url2.protocol)) {
|
|
6399
|
-
|
|
6399
|
+
payload.issues.push({
|
|
6400
6400
|
code: "invalid_format",
|
|
6401
6401
|
format: "url",
|
|
6402
6402
|
note: "Invalid protocol",
|
|
6403
6403
|
pattern: def.protocol.source,
|
|
6404
|
-
input:
|
|
6404
|
+
input: payload.value,
|
|
6405
6405
|
inst,
|
|
6406
6406
|
continue: !def.abort
|
|
6407
6407
|
});
|
|
6408
6408
|
}
|
|
6409
6409
|
}
|
|
6410
6410
|
if (def.normalize) {
|
|
6411
|
-
|
|
6411
|
+
payload.value = url2.href;
|
|
6412
6412
|
} else {
|
|
6413
|
-
|
|
6413
|
+
payload.value = trimmed;
|
|
6414
6414
|
}
|
|
6415
6415
|
return;
|
|
6416
6416
|
} catch (_) {
|
|
6417
|
-
|
|
6417
|
+
payload.issues.push({
|
|
6418
6418
|
code: "invalid_format",
|
|
6419
6419
|
format: "url",
|
|
6420
|
-
input:
|
|
6420
|
+
input: payload.value,
|
|
6421
6421
|
inst,
|
|
6422
6422
|
continue: !def.abort
|
|
6423
6423
|
});
|
|
@@ -6477,14 +6477,14 @@ var init_schemas = __esm({
|
|
|
6477
6477
|
def.pattern ?? (def.pattern = ipv6);
|
|
6478
6478
|
$ZodStringFormat.init(inst, def);
|
|
6479
6479
|
inst._zod.bag.format = `ipv6`;
|
|
6480
|
-
inst._zod.check = (
|
|
6480
|
+
inst._zod.check = (payload) => {
|
|
6481
6481
|
try {
|
|
6482
|
-
new URL(`http://[${
|
|
6482
|
+
new URL(`http://[${payload.value}]`);
|
|
6483
6483
|
} catch {
|
|
6484
|
-
|
|
6484
|
+
payload.issues.push({
|
|
6485
6485
|
code: "invalid_format",
|
|
6486
6486
|
format: "ipv6",
|
|
6487
|
-
input:
|
|
6487
|
+
input: payload.value,
|
|
6488
6488
|
inst,
|
|
6489
6489
|
continue: !def.abort
|
|
6490
6490
|
});
|
|
@@ -6503,8 +6503,8 @@ var init_schemas = __esm({
|
|
|
6503
6503
|
$ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
6504
6504
|
def.pattern ?? (def.pattern = cidrv6);
|
|
6505
6505
|
$ZodStringFormat.init(inst, def);
|
|
6506
|
-
inst._zod.check = (
|
|
6507
|
-
const parts =
|
|
6506
|
+
inst._zod.check = (payload) => {
|
|
6507
|
+
const parts = payload.value.split("/");
|
|
6508
6508
|
try {
|
|
6509
6509
|
if (parts.length !== 2)
|
|
6510
6510
|
throw new Error();
|
|
@@ -6518,10 +6518,10 @@ var init_schemas = __esm({
|
|
|
6518
6518
|
throw new Error();
|
|
6519
6519
|
new URL(`http://[${address}]`);
|
|
6520
6520
|
} catch {
|
|
6521
|
-
|
|
6521
|
+
payload.issues.push({
|
|
6522
6522
|
code: "invalid_format",
|
|
6523
6523
|
format: "cidrv6",
|
|
6524
|
-
input:
|
|
6524
|
+
input: payload.value,
|
|
6525
6525
|
inst,
|
|
6526
6526
|
continue: !def.abort
|
|
6527
6527
|
});
|
|
@@ -6532,13 +6532,13 @@ var init_schemas = __esm({
|
|
|
6532
6532
|
def.pattern ?? (def.pattern = base64);
|
|
6533
6533
|
$ZodStringFormat.init(inst, def);
|
|
6534
6534
|
inst._zod.bag.contentEncoding = "base64";
|
|
6535
|
-
inst._zod.check = (
|
|
6536
|
-
if (isValidBase64(
|
|
6535
|
+
inst._zod.check = (payload) => {
|
|
6536
|
+
if (isValidBase64(payload.value))
|
|
6537
6537
|
return;
|
|
6538
|
-
|
|
6538
|
+
payload.issues.push({
|
|
6539
6539
|
code: "invalid_format",
|
|
6540
6540
|
format: "base64",
|
|
6541
|
-
input:
|
|
6541
|
+
input: payload.value,
|
|
6542
6542
|
inst,
|
|
6543
6543
|
continue: !def.abort
|
|
6544
6544
|
});
|
|
@@ -6548,13 +6548,13 @@ var init_schemas = __esm({
|
|
|
6548
6548
|
def.pattern ?? (def.pattern = base64url);
|
|
6549
6549
|
$ZodStringFormat.init(inst, def);
|
|
6550
6550
|
inst._zod.bag.contentEncoding = "base64url";
|
|
6551
|
-
inst._zod.check = (
|
|
6552
|
-
if (isValidBase64URL(
|
|
6551
|
+
inst._zod.check = (payload) => {
|
|
6552
|
+
if (isValidBase64URL(payload.value))
|
|
6553
6553
|
return;
|
|
6554
|
-
|
|
6554
|
+
payload.issues.push({
|
|
6555
6555
|
code: "invalid_format",
|
|
6556
6556
|
format: "base64url",
|
|
6557
|
-
input:
|
|
6557
|
+
input: payload.value,
|
|
6558
6558
|
inst,
|
|
6559
6559
|
continue: !def.abort
|
|
6560
6560
|
});
|
|
@@ -6566,13 +6566,13 @@ var init_schemas = __esm({
|
|
|
6566
6566
|
});
|
|
6567
6567
|
$ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
|
|
6568
6568
|
$ZodStringFormat.init(inst, def);
|
|
6569
|
-
inst._zod.check = (
|
|
6570
|
-
if (isValidJWT2(
|
|
6569
|
+
inst._zod.check = (payload) => {
|
|
6570
|
+
if (isValidJWT2(payload.value, def.alg))
|
|
6571
6571
|
return;
|
|
6572
|
-
|
|
6572
|
+
payload.issues.push({
|
|
6573
6573
|
code: "invalid_format",
|
|
6574
6574
|
format: "jwt",
|
|
6575
|
-
input:
|
|
6575
|
+
input: payload.value,
|
|
6576
6576
|
inst,
|
|
6577
6577
|
continue: !def.abort
|
|
6578
6578
|
});
|
|
@@ -6580,13 +6580,13 @@ var init_schemas = __esm({
|
|
|
6580
6580
|
});
|
|
6581
6581
|
$ZodCustomStringFormat = /* @__PURE__ */ $constructor("$ZodCustomStringFormat", (inst, def) => {
|
|
6582
6582
|
$ZodStringFormat.init(inst, def);
|
|
6583
|
-
inst._zod.check = (
|
|
6584
|
-
if (def.fn(
|
|
6583
|
+
inst._zod.check = (payload) => {
|
|
6584
|
+
if (def.fn(payload.value))
|
|
6585
6585
|
return;
|
|
6586
|
-
|
|
6586
|
+
payload.issues.push({
|
|
6587
6587
|
code: "invalid_format",
|
|
6588
6588
|
format: def.format,
|
|
6589
|
-
input:
|
|
6589
|
+
input: payload.value,
|
|
6590
6590
|
inst,
|
|
6591
6591
|
continue: !def.abort
|
|
6592
6592
|
});
|
|
@@ -6595,25 +6595,25 @@ var init_schemas = __esm({
|
|
|
6595
6595
|
$ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
6596
6596
|
$ZodType.init(inst, def);
|
|
6597
6597
|
inst._zod.pattern = inst._zod.bag.pattern ?? number;
|
|
6598
|
-
inst._zod.parse = (
|
|
6598
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
6599
6599
|
if (def.coerce)
|
|
6600
6600
|
try {
|
|
6601
|
-
|
|
6601
|
+
payload.value = Number(payload.value);
|
|
6602
6602
|
} catch (_) {
|
|
6603
6603
|
}
|
|
6604
|
-
const input =
|
|
6604
|
+
const input = payload.value;
|
|
6605
6605
|
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
|
|
6606
|
-
return
|
|
6606
|
+
return payload;
|
|
6607
6607
|
}
|
|
6608
6608
|
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
|
|
6609
|
-
|
|
6609
|
+
payload.issues.push({
|
|
6610
6610
|
expected: "number",
|
|
6611
6611
|
code: "invalid_type",
|
|
6612
6612
|
input,
|
|
6613
6613
|
inst,
|
|
6614
6614
|
...received ? { received } : {}
|
|
6615
6615
|
});
|
|
6616
|
-
return
|
|
6616
|
+
return payload;
|
|
6617
6617
|
};
|
|
6618
6618
|
});
|
|
6619
6619
|
$ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, def) => {
|
|
@@ -6623,42 +6623,42 @@ var init_schemas = __esm({
|
|
|
6623
6623
|
$ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
|
|
6624
6624
|
$ZodType.init(inst, def);
|
|
6625
6625
|
inst._zod.pattern = boolean;
|
|
6626
|
-
inst._zod.parse = (
|
|
6626
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
6627
6627
|
if (def.coerce)
|
|
6628
6628
|
try {
|
|
6629
|
-
|
|
6629
|
+
payload.value = Boolean(payload.value);
|
|
6630
6630
|
} catch (_) {
|
|
6631
6631
|
}
|
|
6632
|
-
const input =
|
|
6632
|
+
const input = payload.value;
|
|
6633
6633
|
if (typeof input === "boolean")
|
|
6634
|
-
return
|
|
6635
|
-
|
|
6634
|
+
return payload;
|
|
6635
|
+
payload.issues.push({
|
|
6636
6636
|
expected: "boolean",
|
|
6637
6637
|
code: "invalid_type",
|
|
6638
6638
|
input,
|
|
6639
6639
|
inst
|
|
6640
6640
|
});
|
|
6641
|
-
return
|
|
6641
|
+
return payload;
|
|
6642
6642
|
};
|
|
6643
6643
|
});
|
|
6644
6644
|
$ZodBigInt = /* @__PURE__ */ $constructor("$ZodBigInt", (inst, def) => {
|
|
6645
6645
|
$ZodType.init(inst, def);
|
|
6646
6646
|
inst._zod.pattern = bigint;
|
|
6647
|
-
inst._zod.parse = (
|
|
6647
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
6648
6648
|
if (def.coerce)
|
|
6649
6649
|
try {
|
|
6650
|
-
|
|
6650
|
+
payload.value = BigInt(payload.value);
|
|
6651
6651
|
} catch (_) {
|
|
6652
6652
|
}
|
|
6653
|
-
if (typeof
|
|
6654
|
-
return
|
|
6655
|
-
|
|
6653
|
+
if (typeof payload.value === "bigint")
|
|
6654
|
+
return payload;
|
|
6655
|
+
payload.issues.push({
|
|
6656
6656
|
expected: "bigint",
|
|
6657
6657
|
code: "invalid_type",
|
|
6658
|
-
input:
|
|
6658
|
+
input: payload.value,
|
|
6659
6659
|
inst
|
|
6660
6660
|
});
|
|
6661
|
-
return
|
|
6661
|
+
return payload;
|
|
6662
6662
|
};
|
|
6663
6663
|
});
|
|
6664
6664
|
$ZodBigIntFormat = /* @__PURE__ */ $constructor("$ZodBigIntFormat", (inst, def) => {
|
|
@@ -6667,126 +6667,126 @@ var init_schemas = __esm({
|
|
|
6667
6667
|
});
|
|
6668
6668
|
$ZodSymbol = /* @__PURE__ */ $constructor("$ZodSymbol", (inst, def) => {
|
|
6669
6669
|
$ZodType.init(inst, def);
|
|
6670
|
-
inst._zod.parse = (
|
|
6671
|
-
const input =
|
|
6670
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
6671
|
+
const input = payload.value;
|
|
6672
6672
|
if (typeof input === "symbol")
|
|
6673
|
-
return
|
|
6674
|
-
|
|
6673
|
+
return payload;
|
|
6674
|
+
payload.issues.push({
|
|
6675
6675
|
expected: "symbol",
|
|
6676
6676
|
code: "invalid_type",
|
|
6677
6677
|
input,
|
|
6678
6678
|
inst
|
|
6679
6679
|
});
|
|
6680
|
-
return
|
|
6680
|
+
return payload;
|
|
6681
6681
|
};
|
|
6682
6682
|
});
|
|
6683
6683
|
$ZodUndefined = /* @__PURE__ */ $constructor("$ZodUndefined", (inst, def) => {
|
|
6684
6684
|
$ZodType.init(inst, def);
|
|
6685
6685
|
inst._zod.pattern = _undefined;
|
|
6686
6686
|
inst._zod.values = /* @__PURE__ */ new Set([void 0]);
|
|
6687
|
-
inst._zod.parse = (
|
|
6688
|
-
const input =
|
|
6687
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
6688
|
+
const input = payload.value;
|
|
6689
6689
|
if (typeof input === "undefined")
|
|
6690
|
-
return
|
|
6691
|
-
|
|
6690
|
+
return payload;
|
|
6691
|
+
payload.issues.push({
|
|
6692
6692
|
expected: "undefined",
|
|
6693
6693
|
code: "invalid_type",
|
|
6694
6694
|
input,
|
|
6695
6695
|
inst
|
|
6696
6696
|
});
|
|
6697
|
-
return
|
|
6697
|
+
return payload;
|
|
6698
6698
|
};
|
|
6699
6699
|
});
|
|
6700
6700
|
$ZodNull = /* @__PURE__ */ $constructor("$ZodNull", (inst, def) => {
|
|
6701
6701
|
$ZodType.init(inst, def);
|
|
6702
6702
|
inst._zod.pattern = _null;
|
|
6703
6703
|
inst._zod.values = /* @__PURE__ */ new Set([null]);
|
|
6704
|
-
inst._zod.parse = (
|
|
6705
|
-
const input =
|
|
6704
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
6705
|
+
const input = payload.value;
|
|
6706
6706
|
if (input === null)
|
|
6707
|
-
return
|
|
6708
|
-
|
|
6707
|
+
return payload;
|
|
6708
|
+
payload.issues.push({
|
|
6709
6709
|
expected: "null",
|
|
6710
6710
|
code: "invalid_type",
|
|
6711
6711
|
input,
|
|
6712
6712
|
inst
|
|
6713
6713
|
});
|
|
6714
|
-
return
|
|
6714
|
+
return payload;
|
|
6715
6715
|
};
|
|
6716
6716
|
});
|
|
6717
6717
|
$ZodAny = /* @__PURE__ */ $constructor("$ZodAny", (inst, def) => {
|
|
6718
6718
|
$ZodType.init(inst, def);
|
|
6719
|
-
inst._zod.parse = (
|
|
6719
|
+
inst._zod.parse = (payload) => payload;
|
|
6720
6720
|
});
|
|
6721
6721
|
$ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
|
|
6722
6722
|
$ZodType.init(inst, def);
|
|
6723
|
-
inst._zod.parse = (
|
|
6723
|
+
inst._zod.parse = (payload) => payload;
|
|
6724
6724
|
});
|
|
6725
6725
|
$ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
|
|
6726
6726
|
$ZodType.init(inst, def);
|
|
6727
|
-
inst._zod.parse = (
|
|
6728
|
-
|
|
6727
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
6728
|
+
payload.issues.push({
|
|
6729
6729
|
expected: "never",
|
|
6730
6730
|
code: "invalid_type",
|
|
6731
|
-
input:
|
|
6731
|
+
input: payload.value,
|
|
6732
6732
|
inst
|
|
6733
6733
|
});
|
|
6734
|
-
return
|
|
6734
|
+
return payload;
|
|
6735
6735
|
};
|
|
6736
6736
|
});
|
|
6737
6737
|
$ZodVoid = /* @__PURE__ */ $constructor("$ZodVoid", (inst, def) => {
|
|
6738
6738
|
$ZodType.init(inst, def);
|
|
6739
|
-
inst._zod.parse = (
|
|
6740
|
-
const input =
|
|
6739
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
6740
|
+
const input = payload.value;
|
|
6741
6741
|
if (typeof input === "undefined")
|
|
6742
|
-
return
|
|
6743
|
-
|
|
6742
|
+
return payload;
|
|
6743
|
+
payload.issues.push({
|
|
6744
6744
|
expected: "void",
|
|
6745
6745
|
code: "invalid_type",
|
|
6746
6746
|
input,
|
|
6747
6747
|
inst
|
|
6748
6748
|
});
|
|
6749
|
-
return
|
|
6749
|
+
return payload;
|
|
6750
6750
|
};
|
|
6751
6751
|
});
|
|
6752
6752
|
$ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
|
|
6753
6753
|
$ZodType.init(inst, def);
|
|
6754
|
-
inst._zod.parse = (
|
|
6754
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
6755
6755
|
if (def.coerce) {
|
|
6756
6756
|
try {
|
|
6757
|
-
|
|
6757
|
+
payload.value = new Date(payload.value);
|
|
6758
6758
|
} catch (_err) {
|
|
6759
6759
|
}
|
|
6760
6760
|
}
|
|
6761
|
-
const input =
|
|
6761
|
+
const input = payload.value;
|
|
6762
6762
|
const isDate = input instanceof Date;
|
|
6763
6763
|
const isValidDate = isDate && !Number.isNaN(input.getTime());
|
|
6764
6764
|
if (isValidDate)
|
|
6765
|
-
return
|
|
6766
|
-
|
|
6765
|
+
return payload;
|
|
6766
|
+
payload.issues.push({
|
|
6767
6767
|
expected: "date",
|
|
6768
6768
|
code: "invalid_type",
|
|
6769
6769
|
input,
|
|
6770
6770
|
...isDate ? { received: "Invalid Date" } : {},
|
|
6771
6771
|
inst
|
|
6772
6772
|
});
|
|
6773
|
-
return
|
|
6773
|
+
return payload;
|
|
6774
6774
|
};
|
|
6775
6775
|
});
|
|
6776
6776
|
$ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
6777
6777
|
$ZodType.init(inst, def);
|
|
6778
|
-
inst._zod.parse = (
|
|
6779
|
-
const input =
|
|
6778
|
+
inst._zod.parse = (payload, ctx) => {
|
|
6779
|
+
const input = payload.value;
|
|
6780
6780
|
if (!Array.isArray(input)) {
|
|
6781
|
-
|
|
6781
|
+
payload.issues.push({
|
|
6782
6782
|
expected: "array",
|
|
6783
6783
|
code: "invalid_type",
|
|
6784
6784
|
input,
|
|
6785
6785
|
inst
|
|
6786
6786
|
});
|
|
6787
|
-
return
|
|
6787
|
+
return payload;
|
|
6788
6788
|
}
|
|
6789
|
-
|
|
6789
|
+
payload.value = Array(input.length);
|
|
6790
6790
|
const proms = [];
|
|
6791
6791
|
for (let i = 0; i < input.length; i++) {
|
|
6792
6792
|
const item = input[i];
|
|
@@ -6795,15 +6795,15 @@ var init_schemas = __esm({
|
|
|
6795
6795
|
issues: []
|
|
6796
6796
|
}, ctx);
|
|
6797
6797
|
if (result instanceof Promise) {
|
|
6798
|
-
proms.push(result.then((result2) => handleArrayResult(result2,
|
|
6798
|
+
proms.push(result.then((result2) => handleArrayResult(result2, payload, i)));
|
|
6799
6799
|
} else {
|
|
6800
|
-
handleArrayResult(result,
|
|
6800
|
+
handleArrayResult(result, payload, i);
|
|
6801
6801
|
}
|
|
6802
6802
|
}
|
|
6803
6803
|
if (proms.length) {
|
|
6804
|
-
return Promise.all(proms).then(() =>
|
|
6804
|
+
return Promise.all(proms).then(() => payload);
|
|
6805
6805
|
}
|
|
6806
|
-
return
|
|
6806
|
+
return payload;
|
|
6807
6807
|
};
|
|
6808
6808
|
});
|
|
6809
6809
|
$ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
@@ -6838,19 +6838,19 @@ var init_schemas = __esm({
|
|
|
6838
6838
|
const isObject2 = isObject;
|
|
6839
6839
|
const catchall = def.catchall;
|
|
6840
6840
|
let value;
|
|
6841
|
-
inst._zod.parse = (
|
|
6841
|
+
inst._zod.parse = (payload, ctx) => {
|
|
6842
6842
|
value ?? (value = _normalized.value);
|
|
6843
|
-
const input =
|
|
6843
|
+
const input = payload.value;
|
|
6844
6844
|
if (!isObject2(input)) {
|
|
6845
|
-
|
|
6845
|
+
payload.issues.push({
|
|
6846
6846
|
expected: "object",
|
|
6847
6847
|
code: "invalid_type",
|
|
6848
6848
|
input,
|
|
6849
6849
|
inst
|
|
6850
6850
|
});
|
|
6851
|
-
return
|
|
6851
|
+
return payload;
|
|
6852
6852
|
}
|
|
6853
|
-
|
|
6853
|
+
payload.value = {};
|
|
6854
6854
|
const proms = [];
|
|
6855
6855
|
const shape = value.shape;
|
|
6856
6856
|
for (const key of value.keys) {
|
|
@@ -6859,15 +6859,15 @@ var init_schemas = __esm({
|
|
|
6859
6859
|
const isOptionalOut = el._zod.optout === "optional";
|
|
6860
6860
|
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
6861
6861
|
if (r instanceof Promise) {
|
|
6862
|
-
proms.push(r.then((r2) => handlePropertyResult(r2,
|
|
6862
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalIn, isOptionalOut)));
|
|
6863
6863
|
} else {
|
|
6864
|
-
handlePropertyResult(r,
|
|
6864
|
+
handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
|
|
6865
6865
|
}
|
|
6866
6866
|
}
|
|
6867
6867
|
if (!catchall) {
|
|
6868
|
-
return proms.length ? Promise.all(proms).then(() =>
|
|
6868
|
+
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
6869
6869
|
}
|
|
6870
|
-
return handleCatchall(proms, input,
|
|
6870
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
6871
6871
|
};
|
|
6872
6872
|
});
|
|
6873
6873
|
$ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
@@ -6965,7 +6965,7 @@ var init_schemas = __esm({
|
|
|
6965
6965
|
doc.write(`payload.value = newResult;`);
|
|
6966
6966
|
doc.write(`return payload;`);
|
|
6967
6967
|
const fn = doc.compile();
|
|
6968
|
-
return (
|
|
6968
|
+
return (payload, ctx) => fn(shape, payload, ctx);
|
|
6969
6969
|
};
|
|
6970
6970
|
let fastpass;
|
|
6971
6971
|
const isObject2 = isObject;
|
|
@@ -6974,27 +6974,27 @@ var init_schemas = __esm({
|
|
|
6974
6974
|
const fastEnabled = jit && allowsEval2.value;
|
|
6975
6975
|
const catchall = def.catchall;
|
|
6976
6976
|
let value;
|
|
6977
|
-
inst._zod.parse = (
|
|
6977
|
+
inst._zod.parse = (payload, ctx) => {
|
|
6978
6978
|
value ?? (value = _normalized.value);
|
|
6979
|
-
const input =
|
|
6979
|
+
const input = payload.value;
|
|
6980
6980
|
if (!isObject2(input)) {
|
|
6981
|
-
|
|
6981
|
+
payload.issues.push({
|
|
6982
6982
|
expected: "object",
|
|
6983
6983
|
code: "invalid_type",
|
|
6984
6984
|
input,
|
|
6985
6985
|
inst
|
|
6986
6986
|
});
|
|
6987
|
-
return
|
|
6987
|
+
return payload;
|
|
6988
6988
|
}
|
|
6989
6989
|
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
|
6990
6990
|
if (!fastpass)
|
|
6991
6991
|
fastpass = generateFastpass(def.shape);
|
|
6992
|
-
|
|
6992
|
+
payload = fastpass(payload, ctx);
|
|
6993
6993
|
if (!catchall)
|
|
6994
|
-
return
|
|
6995
|
-
return handleCatchall([], input,
|
|
6994
|
+
return payload;
|
|
6995
|
+
return handleCatchall([], input, payload, ctx, value, inst);
|
|
6996
6996
|
}
|
|
6997
|
-
return superParse(
|
|
6997
|
+
return superParse(payload, ctx);
|
|
6998
6998
|
};
|
|
6999
6999
|
});
|
|
7000
7000
|
$ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
@@ -7015,15 +7015,15 @@ var init_schemas = __esm({
|
|
|
7015
7015
|
return void 0;
|
|
7016
7016
|
});
|
|
7017
7017
|
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
7018
|
-
inst._zod.parse = (
|
|
7018
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7019
7019
|
if (first) {
|
|
7020
|
-
return first(
|
|
7020
|
+
return first(payload, ctx);
|
|
7021
7021
|
}
|
|
7022
7022
|
let async = false;
|
|
7023
7023
|
const results = [];
|
|
7024
7024
|
for (const option of def.options) {
|
|
7025
7025
|
const result = option._zod.run({
|
|
7026
|
-
value:
|
|
7026
|
+
value: payload.value,
|
|
7027
7027
|
issues: []
|
|
7028
7028
|
}, ctx);
|
|
7029
7029
|
if (result instanceof Promise) {
|
|
@@ -7036,9 +7036,9 @@ var init_schemas = __esm({
|
|
|
7036
7036
|
}
|
|
7037
7037
|
}
|
|
7038
7038
|
if (!async)
|
|
7039
|
-
return handleUnionResults(results,
|
|
7039
|
+
return handleUnionResults(results, payload, inst, ctx);
|
|
7040
7040
|
return Promise.all(results).then((results2) => {
|
|
7041
|
-
return handleUnionResults(results2,
|
|
7041
|
+
return handleUnionResults(results2, payload, inst, ctx);
|
|
7042
7042
|
});
|
|
7043
7043
|
};
|
|
7044
7044
|
});
|
|
@@ -7046,15 +7046,15 @@ var init_schemas = __esm({
|
|
|
7046
7046
|
$ZodUnion.init(inst, def);
|
|
7047
7047
|
def.inclusive = false;
|
|
7048
7048
|
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
7049
|
-
inst._zod.parse = (
|
|
7049
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7050
7050
|
if (first) {
|
|
7051
|
-
return first(
|
|
7051
|
+
return first(payload, ctx);
|
|
7052
7052
|
}
|
|
7053
7053
|
let async = false;
|
|
7054
7054
|
const results = [];
|
|
7055
7055
|
for (const option of def.options) {
|
|
7056
7056
|
const result = option._zod.run({
|
|
7057
|
-
value:
|
|
7057
|
+
value: payload.value,
|
|
7058
7058
|
issues: []
|
|
7059
7059
|
}, ctx);
|
|
7060
7060
|
if (result instanceof Promise) {
|
|
@@ -7065,9 +7065,9 @@ var init_schemas = __esm({
|
|
|
7065
7065
|
}
|
|
7066
7066
|
}
|
|
7067
7067
|
if (!async)
|
|
7068
|
-
return handleExclusiveUnionResults(results,
|
|
7068
|
+
return handleExclusiveUnionResults(results, payload, inst, ctx);
|
|
7069
7069
|
return Promise.all(results).then((results2) => {
|
|
7070
|
-
return handleExclusiveUnionResults(results2,
|
|
7070
|
+
return handleExclusiveUnionResults(results2, payload, inst, ctx);
|
|
7071
7071
|
});
|
|
7072
7072
|
};
|
|
7073
7073
|
});
|
|
@@ -7107,25 +7107,25 @@ var init_schemas = __esm({
|
|
|
7107
7107
|
}
|
|
7108
7108
|
return map2;
|
|
7109
7109
|
});
|
|
7110
|
-
inst._zod.parse = (
|
|
7111
|
-
const input =
|
|
7110
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7111
|
+
const input = payload.value;
|
|
7112
7112
|
if (!isObject(input)) {
|
|
7113
|
-
|
|
7113
|
+
payload.issues.push({
|
|
7114
7114
|
code: "invalid_type",
|
|
7115
7115
|
expected: "object",
|
|
7116
7116
|
input,
|
|
7117
7117
|
inst
|
|
7118
7118
|
});
|
|
7119
|
-
return
|
|
7119
|
+
return payload;
|
|
7120
7120
|
}
|
|
7121
7121
|
const opt = disc.value.get(input?.[def.discriminator]);
|
|
7122
7122
|
if (opt) {
|
|
7123
|
-
return opt._zod.run(
|
|
7123
|
+
return opt._zod.run(payload, ctx);
|
|
7124
7124
|
}
|
|
7125
7125
|
if (def.unionFallback || ctx.direction === "backward") {
|
|
7126
|
-
return _super(
|
|
7126
|
+
return _super(payload, ctx);
|
|
7127
7127
|
}
|
|
7128
|
-
|
|
7128
|
+
payload.issues.push({
|
|
7129
7129
|
code: "invalid_union",
|
|
7130
7130
|
errors: [],
|
|
7131
7131
|
note: "No matching discriminator",
|
|
@@ -7135,45 +7135,45 @@ var init_schemas = __esm({
|
|
|
7135
7135
|
path: [def.discriminator],
|
|
7136
7136
|
inst
|
|
7137
7137
|
});
|
|
7138
|
-
return
|
|
7138
|
+
return payload;
|
|
7139
7139
|
};
|
|
7140
7140
|
});
|
|
7141
7141
|
$ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
|
|
7142
7142
|
$ZodType.init(inst, def);
|
|
7143
|
-
inst._zod.parse = (
|
|
7144
|
-
const input =
|
|
7143
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7144
|
+
const input = payload.value;
|
|
7145
7145
|
const left = def.left._zod.run({ value: input, issues: [] }, ctx);
|
|
7146
7146
|
const right = def.right._zod.run({ value: input, issues: [] }, ctx);
|
|
7147
7147
|
const async = left instanceof Promise || right instanceof Promise;
|
|
7148
7148
|
if (async) {
|
|
7149
7149
|
return Promise.all([left, right]).then(([left2, right2]) => {
|
|
7150
|
-
return handleIntersectionResults(
|
|
7150
|
+
return handleIntersectionResults(payload, left2, right2);
|
|
7151
7151
|
});
|
|
7152
7152
|
}
|
|
7153
|
-
return handleIntersectionResults(
|
|
7153
|
+
return handleIntersectionResults(payload, left, right);
|
|
7154
7154
|
};
|
|
7155
7155
|
});
|
|
7156
7156
|
$ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
7157
7157
|
$ZodType.init(inst, def);
|
|
7158
7158
|
const items = def.items;
|
|
7159
|
-
inst._zod.parse = (
|
|
7160
|
-
const input =
|
|
7159
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7160
|
+
const input = payload.value;
|
|
7161
7161
|
if (!Array.isArray(input)) {
|
|
7162
|
-
|
|
7162
|
+
payload.issues.push({
|
|
7163
7163
|
input,
|
|
7164
7164
|
inst,
|
|
7165
7165
|
expected: "tuple",
|
|
7166
7166
|
code: "invalid_type"
|
|
7167
7167
|
});
|
|
7168
|
-
return
|
|
7168
|
+
return payload;
|
|
7169
7169
|
}
|
|
7170
|
-
|
|
7170
|
+
payload.value = [];
|
|
7171
7171
|
const proms = [];
|
|
7172
7172
|
const optinStart = getTupleOptStart(items, "optin");
|
|
7173
7173
|
const optoutStart = getTupleOptStart(items, "optout");
|
|
7174
7174
|
if (!def.rest) {
|
|
7175
7175
|
if (input.length < optinStart) {
|
|
7176
|
-
|
|
7176
|
+
payload.issues.push({
|
|
7177
7177
|
code: "too_small",
|
|
7178
7178
|
minimum: optinStart,
|
|
7179
7179
|
inclusive: true,
|
|
@@ -7181,10 +7181,10 @@ var init_schemas = __esm({
|
|
|
7181
7181
|
inst,
|
|
7182
7182
|
origin: "array"
|
|
7183
7183
|
});
|
|
7184
|
-
return
|
|
7184
|
+
return payload;
|
|
7185
7185
|
}
|
|
7186
7186
|
if (input.length > items.length) {
|
|
7187
|
-
|
|
7187
|
+
payload.issues.push({
|
|
7188
7188
|
code: "too_big",
|
|
7189
7189
|
maximum: items.length,
|
|
7190
7190
|
inclusive: true,
|
|
@@ -7212,35 +7212,35 @@ var init_schemas = __esm({
|
|
|
7212
7212
|
i++;
|
|
7213
7213
|
const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
|
|
7214
7214
|
if (result instanceof Promise) {
|
|
7215
|
-
proms.push(result.then((r) => handleTupleResult(r,
|
|
7215
|
+
proms.push(result.then((r) => handleTupleResult(r, payload, i)));
|
|
7216
7216
|
} else {
|
|
7217
|
-
handleTupleResult(result,
|
|
7217
|
+
handleTupleResult(result, payload, i);
|
|
7218
7218
|
}
|
|
7219
7219
|
}
|
|
7220
7220
|
}
|
|
7221
7221
|
if (proms.length) {
|
|
7222
|
-
return Promise.all(proms).then(() => handleTupleResults(itemResults,
|
|
7222
|
+
return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
|
|
7223
7223
|
}
|
|
7224
|
-
return handleTupleResults(itemResults,
|
|
7224
|
+
return handleTupleResults(itemResults, payload, items, input, optoutStart);
|
|
7225
7225
|
};
|
|
7226
7226
|
});
|
|
7227
7227
|
$ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
7228
7228
|
$ZodType.init(inst, def);
|
|
7229
|
-
inst._zod.parse = (
|
|
7230
|
-
const input =
|
|
7229
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7230
|
+
const input = payload.value;
|
|
7231
7231
|
if (!isPlainObject(input)) {
|
|
7232
|
-
|
|
7232
|
+
payload.issues.push({
|
|
7233
7233
|
expected: "record",
|
|
7234
7234
|
code: "invalid_type",
|
|
7235
7235
|
input,
|
|
7236
7236
|
inst
|
|
7237
7237
|
});
|
|
7238
|
-
return
|
|
7238
|
+
return payload;
|
|
7239
7239
|
}
|
|
7240
7240
|
const proms = [];
|
|
7241
7241
|
const values = def.keyType._zod.values;
|
|
7242
7242
|
if (values) {
|
|
7243
|
-
|
|
7243
|
+
payload.value = {};
|
|
7244
7244
|
const recordKeys = /* @__PURE__ */ new Set();
|
|
7245
7245
|
for (const key of values) {
|
|
7246
7246
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
@@ -7250,7 +7250,7 @@ var init_schemas = __esm({
|
|
|
7250
7250
|
throw new Error("Async schemas not supported in object keys currently");
|
|
7251
7251
|
}
|
|
7252
7252
|
if (keyResult.issues.length) {
|
|
7253
|
-
|
|
7253
|
+
payload.issues.push({
|
|
7254
7254
|
code: "invalid_key",
|
|
7255
7255
|
origin: "record",
|
|
7256
7256
|
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
@@ -7265,15 +7265,15 @@ var init_schemas = __esm({
|
|
|
7265
7265
|
if (result instanceof Promise) {
|
|
7266
7266
|
proms.push(result.then((result2) => {
|
|
7267
7267
|
if (result2.issues.length) {
|
|
7268
|
-
|
|
7268
|
+
payload.issues.push(...prefixIssues(key, result2.issues));
|
|
7269
7269
|
}
|
|
7270
|
-
|
|
7270
|
+
payload.value[outKey] = result2.value;
|
|
7271
7271
|
}));
|
|
7272
7272
|
} else {
|
|
7273
7273
|
if (result.issues.length) {
|
|
7274
|
-
|
|
7274
|
+
payload.issues.push(...prefixIssues(key, result.issues));
|
|
7275
7275
|
}
|
|
7276
|
-
|
|
7276
|
+
payload.value[outKey] = result.value;
|
|
7277
7277
|
}
|
|
7278
7278
|
}
|
|
7279
7279
|
}
|
|
@@ -7285,7 +7285,7 @@ var init_schemas = __esm({
|
|
|
7285
7285
|
}
|
|
7286
7286
|
}
|
|
7287
7287
|
if (unrecognized && unrecognized.length > 0) {
|
|
7288
|
-
|
|
7288
|
+
payload.issues.push({
|
|
7289
7289
|
code: "unrecognized_keys",
|
|
7290
7290
|
input,
|
|
7291
7291
|
inst,
|
|
@@ -7293,7 +7293,7 @@ var init_schemas = __esm({
|
|
|
7293
7293
|
});
|
|
7294
7294
|
}
|
|
7295
7295
|
} else {
|
|
7296
|
-
|
|
7296
|
+
payload.value = {};
|
|
7297
7297
|
for (const key of Reflect.ownKeys(input)) {
|
|
7298
7298
|
if (key === "__proto__")
|
|
7299
7299
|
continue;
|
|
@@ -7315,9 +7315,9 @@ var init_schemas = __esm({
|
|
|
7315
7315
|
}
|
|
7316
7316
|
if (keyResult.issues.length) {
|
|
7317
7317
|
if (def.mode === "loose") {
|
|
7318
|
-
|
|
7318
|
+
payload.value[key] = input[key];
|
|
7319
7319
|
} else {
|
|
7320
|
-
|
|
7320
|
+
payload.issues.push({
|
|
7321
7321
|
code: "invalid_key",
|
|
7322
7322
|
origin: "record",
|
|
7323
7323
|
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
@@ -7332,80 +7332,80 @@ var init_schemas = __esm({
|
|
|
7332
7332
|
if (result instanceof Promise) {
|
|
7333
7333
|
proms.push(result.then((result2) => {
|
|
7334
7334
|
if (result2.issues.length) {
|
|
7335
|
-
|
|
7335
|
+
payload.issues.push(...prefixIssues(key, result2.issues));
|
|
7336
7336
|
}
|
|
7337
|
-
|
|
7337
|
+
payload.value[keyResult.value] = result2.value;
|
|
7338
7338
|
}));
|
|
7339
7339
|
} else {
|
|
7340
7340
|
if (result.issues.length) {
|
|
7341
|
-
|
|
7341
|
+
payload.issues.push(...prefixIssues(key, result.issues));
|
|
7342
7342
|
}
|
|
7343
|
-
|
|
7343
|
+
payload.value[keyResult.value] = result.value;
|
|
7344
7344
|
}
|
|
7345
7345
|
}
|
|
7346
7346
|
}
|
|
7347
7347
|
if (proms.length) {
|
|
7348
|
-
return Promise.all(proms).then(() =>
|
|
7348
|
+
return Promise.all(proms).then(() => payload);
|
|
7349
7349
|
}
|
|
7350
|
-
return
|
|
7350
|
+
return payload;
|
|
7351
7351
|
};
|
|
7352
7352
|
});
|
|
7353
7353
|
$ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
|
|
7354
7354
|
$ZodType.init(inst, def);
|
|
7355
|
-
inst._zod.parse = (
|
|
7356
|
-
const input =
|
|
7355
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7356
|
+
const input = payload.value;
|
|
7357
7357
|
if (!(input instanceof Map)) {
|
|
7358
|
-
|
|
7358
|
+
payload.issues.push({
|
|
7359
7359
|
expected: "map",
|
|
7360
7360
|
code: "invalid_type",
|
|
7361
7361
|
input,
|
|
7362
7362
|
inst
|
|
7363
7363
|
});
|
|
7364
|
-
return
|
|
7364
|
+
return payload;
|
|
7365
7365
|
}
|
|
7366
7366
|
const proms = [];
|
|
7367
|
-
|
|
7367
|
+
payload.value = /* @__PURE__ */ new Map();
|
|
7368
7368
|
for (const [key, value] of input) {
|
|
7369
7369
|
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
7370
7370
|
const valueResult = def.valueType._zod.run({ value, issues: [] }, ctx);
|
|
7371
7371
|
if (keyResult instanceof Promise || valueResult instanceof Promise) {
|
|
7372
7372
|
proms.push(Promise.all([keyResult, valueResult]).then(([keyResult2, valueResult2]) => {
|
|
7373
|
-
handleMapResult(keyResult2, valueResult2,
|
|
7373
|
+
handleMapResult(keyResult2, valueResult2, payload, key, input, inst, ctx);
|
|
7374
7374
|
}));
|
|
7375
7375
|
} else {
|
|
7376
|
-
handleMapResult(keyResult, valueResult,
|
|
7376
|
+
handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
|
|
7377
7377
|
}
|
|
7378
7378
|
}
|
|
7379
7379
|
if (proms.length)
|
|
7380
|
-
return Promise.all(proms).then(() =>
|
|
7381
|
-
return
|
|
7380
|
+
return Promise.all(proms).then(() => payload);
|
|
7381
|
+
return payload;
|
|
7382
7382
|
};
|
|
7383
7383
|
});
|
|
7384
7384
|
$ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
|
|
7385
7385
|
$ZodType.init(inst, def);
|
|
7386
|
-
inst._zod.parse = (
|
|
7387
|
-
const input =
|
|
7386
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7387
|
+
const input = payload.value;
|
|
7388
7388
|
if (!(input instanceof Set)) {
|
|
7389
|
-
|
|
7389
|
+
payload.issues.push({
|
|
7390
7390
|
input,
|
|
7391
7391
|
inst,
|
|
7392
7392
|
expected: "set",
|
|
7393
7393
|
code: "invalid_type"
|
|
7394
7394
|
});
|
|
7395
|
-
return
|
|
7395
|
+
return payload;
|
|
7396
7396
|
}
|
|
7397
7397
|
const proms = [];
|
|
7398
|
-
|
|
7398
|
+
payload.value = /* @__PURE__ */ new Set();
|
|
7399
7399
|
for (const item of input) {
|
|
7400
7400
|
const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
|
|
7401
7401
|
if (result instanceof Promise) {
|
|
7402
|
-
proms.push(result.then((result2) => handleSetResult(result2,
|
|
7402
|
+
proms.push(result.then((result2) => handleSetResult(result2, payload)));
|
|
7403
7403
|
} else
|
|
7404
|
-
handleSetResult(result,
|
|
7404
|
+
handleSetResult(result, payload);
|
|
7405
7405
|
}
|
|
7406
7406
|
if (proms.length)
|
|
7407
|
-
return Promise.all(proms).then(() =>
|
|
7408
|
-
return
|
|
7407
|
+
return Promise.all(proms).then(() => payload);
|
|
7408
|
+
return payload;
|
|
7409
7409
|
};
|
|
7410
7410
|
});
|
|
7411
7411
|
$ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
@@ -7414,18 +7414,18 @@ var init_schemas = __esm({
|
|
|
7414
7414
|
const valuesSet = new Set(values);
|
|
7415
7415
|
inst._zod.values = valuesSet;
|
|
7416
7416
|
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
7417
|
-
inst._zod.parse = (
|
|
7418
|
-
const input =
|
|
7417
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
7418
|
+
const input = payload.value;
|
|
7419
7419
|
if (valuesSet.has(input)) {
|
|
7420
|
-
return
|
|
7420
|
+
return payload;
|
|
7421
7421
|
}
|
|
7422
|
-
|
|
7422
|
+
payload.issues.push({
|
|
7423
7423
|
code: "invalid_value",
|
|
7424
7424
|
values,
|
|
7425
7425
|
input,
|
|
7426
7426
|
inst
|
|
7427
7427
|
});
|
|
7428
|
-
return
|
|
7428
|
+
return payload;
|
|
7429
7429
|
};
|
|
7430
7430
|
});
|
|
7431
7431
|
$ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
@@ -7436,57 +7436,57 @@ var init_schemas = __esm({
|
|
|
7436
7436
|
const values = new Set(def.values);
|
|
7437
7437
|
inst._zod.values = values;
|
|
7438
7438
|
inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
|
|
7439
|
-
inst._zod.parse = (
|
|
7440
|
-
const input =
|
|
7439
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
7440
|
+
const input = payload.value;
|
|
7441
7441
|
if (values.has(input)) {
|
|
7442
|
-
return
|
|
7442
|
+
return payload;
|
|
7443
7443
|
}
|
|
7444
|
-
|
|
7444
|
+
payload.issues.push({
|
|
7445
7445
|
code: "invalid_value",
|
|
7446
7446
|
values: def.values,
|
|
7447
7447
|
input,
|
|
7448
7448
|
inst
|
|
7449
7449
|
});
|
|
7450
|
-
return
|
|
7450
|
+
return payload;
|
|
7451
7451
|
};
|
|
7452
7452
|
});
|
|
7453
7453
|
$ZodFile = /* @__PURE__ */ $constructor("$ZodFile", (inst, def) => {
|
|
7454
7454
|
$ZodType.init(inst, def);
|
|
7455
|
-
inst._zod.parse = (
|
|
7456
|
-
const input =
|
|
7455
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
7456
|
+
const input = payload.value;
|
|
7457
7457
|
if (input instanceof File)
|
|
7458
|
-
return
|
|
7459
|
-
|
|
7458
|
+
return payload;
|
|
7459
|
+
payload.issues.push({
|
|
7460
7460
|
expected: "file",
|
|
7461
7461
|
code: "invalid_type",
|
|
7462
7462
|
input,
|
|
7463
7463
|
inst
|
|
7464
7464
|
});
|
|
7465
|
-
return
|
|
7465
|
+
return payload;
|
|
7466
7466
|
};
|
|
7467
7467
|
});
|
|
7468
7468
|
$ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
7469
7469
|
$ZodType.init(inst, def);
|
|
7470
7470
|
inst._zod.optin = "optional";
|
|
7471
|
-
inst._zod.parse = (
|
|
7471
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7472
7472
|
if (ctx.direction === "backward") {
|
|
7473
7473
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
7474
7474
|
}
|
|
7475
|
-
const _out = def.transform(
|
|
7475
|
+
const _out = def.transform(payload.value, payload);
|
|
7476
7476
|
if (ctx.async) {
|
|
7477
7477
|
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
7478
7478
|
return output.then((output2) => {
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
return
|
|
7479
|
+
payload.value = output2;
|
|
7480
|
+
payload.fallback = true;
|
|
7481
|
+
return payload;
|
|
7482
7482
|
});
|
|
7483
7483
|
}
|
|
7484
7484
|
if (_out instanceof Promise) {
|
|
7485
7485
|
throw new $ZodAsyncError();
|
|
7486
7486
|
}
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
return
|
|
7487
|
+
payload.value = _out;
|
|
7488
|
+
payload.fallback = true;
|
|
7489
|
+
return payload;
|
|
7490
7490
|
};
|
|
7491
7491
|
});
|
|
7492
7492
|
$ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
@@ -7500,26 +7500,26 @@ var init_schemas = __esm({
|
|
|
7500
7500
|
const pattern = def.innerType._zod.pattern;
|
|
7501
7501
|
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
7502
7502
|
});
|
|
7503
|
-
inst._zod.parse = (
|
|
7503
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7504
7504
|
if (def.innerType._zod.optin === "optional") {
|
|
7505
|
-
const input =
|
|
7506
|
-
const result = def.innerType._zod.run(
|
|
7505
|
+
const input = payload.value;
|
|
7506
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
7507
7507
|
if (result instanceof Promise)
|
|
7508
7508
|
return result.then((r) => handleOptionalResult(r, input));
|
|
7509
7509
|
return handleOptionalResult(result, input);
|
|
7510
7510
|
}
|
|
7511
|
-
if (
|
|
7512
|
-
return
|
|
7511
|
+
if (payload.value === void 0) {
|
|
7512
|
+
return payload;
|
|
7513
7513
|
}
|
|
7514
|
-
return def.innerType._zod.run(
|
|
7514
|
+
return def.innerType._zod.run(payload, ctx);
|
|
7515
7515
|
};
|
|
7516
7516
|
});
|
|
7517
7517
|
$ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
|
|
7518
7518
|
$ZodOptional.init(inst, def);
|
|
7519
7519
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
7520
7520
|
defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
|
|
7521
|
-
inst._zod.parse = (
|
|
7522
|
-
return def.innerType._zod.run(
|
|
7521
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7522
|
+
return def.innerType._zod.run(payload, ctx);
|
|
7523
7523
|
};
|
|
7524
7524
|
});
|
|
7525
7525
|
$ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
@@ -7533,25 +7533,25 @@ var init_schemas = __esm({
|
|
|
7533
7533
|
defineLazy(inst._zod, "values", () => {
|
|
7534
7534
|
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
|
|
7535
7535
|
});
|
|
7536
|
-
inst._zod.parse = (
|
|
7537
|
-
if (
|
|
7538
|
-
return
|
|
7539
|
-
return def.innerType._zod.run(
|
|
7536
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7537
|
+
if (payload.value === null)
|
|
7538
|
+
return payload;
|
|
7539
|
+
return def.innerType._zod.run(payload, ctx);
|
|
7540
7540
|
};
|
|
7541
7541
|
});
|
|
7542
7542
|
$ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
|
|
7543
7543
|
$ZodType.init(inst, def);
|
|
7544
7544
|
inst._zod.optin = "optional";
|
|
7545
7545
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
7546
|
-
inst._zod.parse = (
|
|
7546
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7547
7547
|
if (ctx.direction === "backward") {
|
|
7548
|
-
return def.innerType._zod.run(
|
|
7548
|
+
return def.innerType._zod.run(payload, ctx);
|
|
7549
7549
|
}
|
|
7550
|
-
if (
|
|
7551
|
-
|
|
7552
|
-
return
|
|
7550
|
+
if (payload.value === void 0) {
|
|
7551
|
+
payload.value = def.defaultValue;
|
|
7552
|
+
return payload;
|
|
7553
7553
|
}
|
|
7554
|
-
const result = def.innerType._zod.run(
|
|
7554
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
7555
7555
|
if (result instanceof Promise) {
|
|
7556
7556
|
return result.then((result2) => handleDefaultResult(result2, def));
|
|
7557
7557
|
}
|
|
@@ -7562,14 +7562,14 @@ var init_schemas = __esm({
|
|
|
7562
7562
|
$ZodType.init(inst, def);
|
|
7563
7563
|
inst._zod.optin = "optional";
|
|
7564
7564
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
7565
|
-
inst._zod.parse = (
|
|
7565
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7566
7566
|
if (ctx.direction === "backward") {
|
|
7567
|
-
return def.innerType._zod.run(
|
|
7567
|
+
return def.innerType._zod.run(payload, ctx);
|
|
7568
7568
|
}
|
|
7569
|
-
if (
|
|
7570
|
-
|
|
7569
|
+
if (payload.value === void 0) {
|
|
7570
|
+
payload.value = def.defaultValue;
|
|
7571
7571
|
}
|
|
7572
|
-
return def.innerType._zod.run(
|
|
7572
|
+
return def.innerType._zod.run(payload, ctx);
|
|
7573
7573
|
};
|
|
7574
7574
|
});
|
|
7575
7575
|
$ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
@@ -7578,8 +7578,8 @@ var init_schemas = __esm({
|
|
|
7578
7578
|
const v = def.innerType._zod.values;
|
|
7579
7579
|
return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
|
|
7580
7580
|
});
|
|
7581
|
-
inst._zod.parse = (
|
|
7582
|
-
const result = def.innerType._zod.run(
|
|
7581
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7582
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
7583
7583
|
if (result instanceof Promise) {
|
|
7584
7584
|
return result.then((result2) => handleNonOptionalResult(result2, inst));
|
|
7585
7585
|
}
|
|
@@ -7588,19 +7588,19 @@ var init_schemas = __esm({
|
|
|
7588
7588
|
});
|
|
7589
7589
|
$ZodSuccess = /* @__PURE__ */ $constructor("$ZodSuccess", (inst, def) => {
|
|
7590
7590
|
$ZodType.init(inst, def);
|
|
7591
|
-
inst._zod.parse = (
|
|
7591
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7592
7592
|
if (ctx.direction === "backward") {
|
|
7593
7593
|
throw new $ZodEncodeError("ZodSuccess");
|
|
7594
7594
|
}
|
|
7595
|
-
const result = def.innerType._zod.run(
|
|
7595
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
7596
7596
|
if (result instanceof Promise) {
|
|
7597
7597
|
return result.then((result2) => {
|
|
7598
|
-
|
|
7599
|
-
return
|
|
7598
|
+
payload.value = result2.issues.length === 0;
|
|
7599
|
+
return payload;
|
|
7600
7600
|
});
|
|
7601
7601
|
}
|
|
7602
|
-
|
|
7603
|
-
return
|
|
7602
|
+
payload.value = result.issues.length === 0;
|
|
7603
|
+
return payload;
|
|
7604
7604
|
};
|
|
7605
7605
|
});
|
|
7606
7606
|
$ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
@@ -7608,56 +7608,56 @@ var init_schemas = __esm({
|
|
|
7608
7608
|
inst._zod.optin = "optional";
|
|
7609
7609
|
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
7610
7610
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
7611
|
-
inst._zod.parse = (
|
|
7611
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7612
7612
|
if (ctx.direction === "backward") {
|
|
7613
|
-
return def.innerType._zod.run(
|
|
7613
|
+
return def.innerType._zod.run(payload, ctx);
|
|
7614
7614
|
}
|
|
7615
|
-
const result = def.innerType._zod.run(
|
|
7615
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
7616
7616
|
if (result instanceof Promise) {
|
|
7617
7617
|
return result.then((result2) => {
|
|
7618
|
-
|
|
7618
|
+
payload.value = result2.value;
|
|
7619
7619
|
if (result2.issues.length) {
|
|
7620
|
-
|
|
7621
|
-
...
|
|
7620
|
+
payload.value = def.catchValue({
|
|
7621
|
+
...payload,
|
|
7622
7622
|
error: {
|
|
7623
7623
|
issues: result2.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
7624
7624
|
},
|
|
7625
|
-
input:
|
|
7625
|
+
input: payload.value
|
|
7626
7626
|
});
|
|
7627
|
-
|
|
7628
|
-
|
|
7627
|
+
payload.issues = [];
|
|
7628
|
+
payload.fallback = true;
|
|
7629
7629
|
}
|
|
7630
|
-
return
|
|
7630
|
+
return payload;
|
|
7631
7631
|
});
|
|
7632
7632
|
}
|
|
7633
|
-
|
|
7633
|
+
payload.value = result.value;
|
|
7634
7634
|
if (result.issues.length) {
|
|
7635
|
-
|
|
7636
|
-
...
|
|
7635
|
+
payload.value = def.catchValue({
|
|
7636
|
+
...payload,
|
|
7637
7637
|
error: {
|
|
7638
7638
|
issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
7639
7639
|
},
|
|
7640
|
-
input:
|
|
7640
|
+
input: payload.value
|
|
7641
7641
|
});
|
|
7642
|
-
|
|
7643
|
-
|
|
7642
|
+
payload.issues = [];
|
|
7643
|
+
payload.fallback = true;
|
|
7644
7644
|
}
|
|
7645
|
-
return
|
|
7645
|
+
return payload;
|
|
7646
7646
|
};
|
|
7647
7647
|
});
|
|
7648
7648
|
$ZodNaN = /* @__PURE__ */ $constructor("$ZodNaN", (inst, def) => {
|
|
7649
7649
|
$ZodType.init(inst, def);
|
|
7650
|
-
inst._zod.parse = (
|
|
7651
|
-
if (typeof
|
|
7652
|
-
|
|
7653
|
-
input:
|
|
7650
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
7651
|
+
if (typeof payload.value !== "number" || !Number.isNaN(payload.value)) {
|
|
7652
|
+
payload.issues.push({
|
|
7653
|
+
input: payload.value,
|
|
7654
7654
|
inst,
|
|
7655
7655
|
expected: "nan",
|
|
7656
7656
|
code: "invalid_type"
|
|
7657
7657
|
});
|
|
7658
|
-
return
|
|
7658
|
+
return payload;
|
|
7659
7659
|
}
|
|
7660
|
-
return
|
|
7660
|
+
return payload;
|
|
7661
7661
|
};
|
|
7662
7662
|
});
|
|
7663
7663
|
$ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
|
|
@@ -7666,15 +7666,15 @@ var init_schemas = __esm({
|
|
|
7666
7666
|
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
7667
7667
|
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
7668
7668
|
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
7669
|
-
inst._zod.parse = (
|
|
7669
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7670
7670
|
if (ctx.direction === "backward") {
|
|
7671
|
-
const right = def.out._zod.run(
|
|
7671
|
+
const right = def.out._zod.run(payload, ctx);
|
|
7672
7672
|
if (right instanceof Promise) {
|
|
7673
7673
|
return right.then((right2) => handlePipeResult(right2, def.in, ctx));
|
|
7674
7674
|
}
|
|
7675
7675
|
return handlePipeResult(right, def.in, ctx);
|
|
7676
7676
|
}
|
|
7677
|
-
const left = def.in._zod.run(
|
|
7677
|
+
const left = def.in._zod.run(payload, ctx);
|
|
7678
7678
|
if (left instanceof Promise) {
|
|
7679
7679
|
return left.then((left2) => handlePipeResult(left2, def.out, ctx));
|
|
7680
7680
|
}
|
|
@@ -7687,16 +7687,16 @@ var init_schemas = __esm({
|
|
|
7687
7687
|
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
7688
7688
|
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
7689
7689
|
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
7690
|
-
inst._zod.parse = (
|
|
7690
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7691
7691
|
const direction = ctx.direction || "forward";
|
|
7692
7692
|
if (direction === "forward") {
|
|
7693
|
-
const left = def.in._zod.run(
|
|
7693
|
+
const left = def.in._zod.run(payload, ctx);
|
|
7694
7694
|
if (left instanceof Promise) {
|
|
7695
7695
|
return left.then((left2) => handleCodecAResult(left2, def, ctx));
|
|
7696
7696
|
}
|
|
7697
7697
|
return handleCodecAResult(left, def, ctx);
|
|
7698
7698
|
} else {
|
|
7699
|
-
const right = def.out._zod.run(
|
|
7699
|
+
const right = def.out._zod.run(payload, ctx);
|
|
7700
7700
|
if (right instanceof Promise) {
|
|
7701
7701
|
return right.then((right2) => handleCodecAResult(right2, def, ctx));
|
|
7702
7702
|
}
|
|
@@ -7713,11 +7713,11 @@ var init_schemas = __esm({
|
|
|
7713
7713
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
7714
7714
|
defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
|
|
7715
7715
|
defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
|
|
7716
|
-
inst._zod.parse = (
|
|
7716
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7717
7717
|
if (ctx.direction === "backward") {
|
|
7718
|
-
return def.innerType._zod.run(
|
|
7718
|
+
return def.innerType._zod.run(payload, ctx);
|
|
7719
7719
|
}
|
|
7720
|
-
const result = def.innerType._zod.run(
|
|
7720
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
7721
7721
|
if (result instanceof Promise) {
|
|
7722
7722
|
return result.then(handleReadonlyResult);
|
|
7723
7723
|
}
|
|
@@ -7745,28 +7745,28 @@ var init_schemas = __esm({
|
|
|
7745
7745
|
}
|
|
7746
7746
|
}
|
|
7747
7747
|
inst._zod.pattern = new RegExp(`^${regexParts.join("")}$`);
|
|
7748
|
-
inst._zod.parse = (
|
|
7749
|
-
if (typeof
|
|
7750
|
-
|
|
7751
|
-
input:
|
|
7748
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
7749
|
+
if (typeof payload.value !== "string") {
|
|
7750
|
+
payload.issues.push({
|
|
7751
|
+
input: payload.value,
|
|
7752
7752
|
inst,
|
|
7753
7753
|
expected: "string",
|
|
7754
7754
|
code: "invalid_type"
|
|
7755
7755
|
});
|
|
7756
|
-
return
|
|
7756
|
+
return payload;
|
|
7757
7757
|
}
|
|
7758
7758
|
inst._zod.pattern.lastIndex = 0;
|
|
7759
|
-
if (!inst._zod.pattern.test(
|
|
7760
|
-
|
|
7761
|
-
input:
|
|
7759
|
+
if (!inst._zod.pattern.test(payload.value)) {
|
|
7760
|
+
payload.issues.push({
|
|
7761
|
+
input: payload.value,
|
|
7762
7762
|
inst,
|
|
7763
7763
|
code: "invalid_format",
|
|
7764
7764
|
format: def.format ?? "template_literal",
|
|
7765
7765
|
pattern: inst._zod.pattern.source
|
|
7766
7766
|
});
|
|
7767
|
-
return
|
|
7767
|
+
return payload;
|
|
7768
7768
|
}
|
|
7769
|
-
return
|
|
7769
|
+
return payload;
|
|
7770
7770
|
};
|
|
7771
7771
|
});
|
|
7772
7772
|
$ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
|
|
@@ -7799,23 +7799,23 @@ var init_schemas = __esm({
|
|
|
7799
7799
|
return result;
|
|
7800
7800
|
};
|
|
7801
7801
|
};
|
|
7802
|
-
inst._zod.parse = (
|
|
7803
|
-
if (typeof
|
|
7804
|
-
|
|
7802
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
7803
|
+
if (typeof payload.value !== "function") {
|
|
7804
|
+
payload.issues.push({
|
|
7805
7805
|
code: "invalid_type",
|
|
7806
7806
|
expected: "function",
|
|
7807
|
-
input:
|
|
7807
|
+
input: payload.value,
|
|
7808
7808
|
inst
|
|
7809
7809
|
});
|
|
7810
|
-
return
|
|
7810
|
+
return payload;
|
|
7811
7811
|
}
|
|
7812
7812
|
const hasPromiseOutput = inst._def.output && inst._def.output._zod.def.type === "promise";
|
|
7813
7813
|
if (hasPromiseOutput) {
|
|
7814
|
-
|
|
7814
|
+
payload.value = inst.implementAsync(payload.value);
|
|
7815
7815
|
} else {
|
|
7816
|
-
|
|
7816
|
+
payload.value = inst.implement(payload.value);
|
|
7817
7817
|
}
|
|
7818
|
-
return
|
|
7818
|
+
return payload;
|
|
7819
7819
|
};
|
|
7820
7820
|
inst.input = (...args) => {
|
|
7821
7821
|
const F = inst.constructor;
|
|
@@ -7848,8 +7848,8 @@ var init_schemas = __esm({
|
|
|
7848
7848
|
});
|
|
7849
7849
|
$ZodPromise = /* @__PURE__ */ $constructor("$ZodPromise", (inst, def) => {
|
|
7850
7850
|
$ZodType.init(inst, def);
|
|
7851
|
-
inst._zod.parse = (
|
|
7852
|
-
return Promise.resolve(
|
|
7851
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7852
|
+
return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] }, ctx));
|
|
7853
7853
|
};
|
|
7854
7854
|
});
|
|
7855
7855
|
$ZodLazy = /* @__PURE__ */ $constructor("$ZodLazy", (inst, def) => {
|
|
@@ -7864,24 +7864,24 @@ var init_schemas = __esm({
|
|
|
7864
7864
|
defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
|
|
7865
7865
|
defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? void 0);
|
|
7866
7866
|
defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? void 0);
|
|
7867
|
-
inst._zod.parse = (
|
|
7867
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7868
7868
|
const inner = inst._zod.innerType;
|
|
7869
|
-
return inner._zod.run(
|
|
7869
|
+
return inner._zod.run(payload, ctx);
|
|
7870
7870
|
};
|
|
7871
7871
|
});
|
|
7872
7872
|
$ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
7873
7873
|
$ZodCheck.init(inst, def);
|
|
7874
7874
|
$ZodType.init(inst, def);
|
|
7875
|
-
inst._zod.parse = (
|
|
7876
|
-
return
|
|
7875
|
+
inst._zod.parse = (payload, _) => {
|
|
7876
|
+
return payload;
|
|
7877
7877
|
};
|
|
7878
|
-
inst._zod.check = (
|
|
7879
|
-
const input =
|
|
7878
|
+
inst._zod.check = (payload) => {
|
|
7879
|
+
const input = payload.value;
|
|
7880
7880
|
const r = def.fn(input);
|
|
7881
7881
|
if (r instanceof Promise) {
|
|
7882
|
-
return r.then((r2) => handleRefineResult(r2,
|
|
7882
|
+
return r.then((r2) => handleRefineResult(r2, payload, input, inst));
|
|
7883
7883
|
}
|
|
7884
|
-
handleRefineResult(r,
|
|
7884
|
+
handleRefineResult(r, payload, input, inst);
|
|
7885
7885
|
return;
|
|
7886
7886
|
};
|
|
7887
7887
|
});
|
|
@@ -15172,22 +15172,22 @@ function _refine(Class2, fn, _params) {
|
|
|
15172
15172
|
}
|
|
15173
15173
|
// @__NO_SIDE_EFFECTS__
|
|
15174
15174
|
function _superRefine(fn, params) {
|
|
15175
|
-
const ch = /* @__PURE__ */ _check((
|
|
15176
|
-
|
|
15175
|
+
const ch = /* @__PURE__ */ _check((payload) => {
|
|
15176
|
+
payload.addIssue = (issue2) => {
|
|
15177
15177
|
if (typeof issue2 === "string") {
|
|
15178
|
-
|
|
15178
|
+
payload.issues.push(issue(issue2, payload.value, ch._zod.def));
|
|
15179
15179
|
} else {
|
|
15180
15180
|
const _issue = issue2;
|
|
15181
15181
|
if (_issue.fatal)
|
|
15182
15182
|
_issue.continue = false;
|
|
15183
15183
|
_issue.code ?? (_issue.code = "custom");
|
|
15184
|
-
_issue.input ?? (_issue.input =
|
|
15184
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
15185
15185
|
_issue.inst ?? (_issue.inst = ch);
|
|
15186
15186
|
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
15187
|
-
|
|
15187
|
+
payload.issues.push(issue(_issue));
|
|
15188
15188
|
}
|
|
15189
15189
|
};
|
|
15190
|
-
return fn(
|
|
15190
|
+
return fn(payload.value, payload);
|
|
15191
15191
|
}, params);
|
|
15192
15192
|
return ch;
|
|
15193
15193
|
}
|
|
@@ -15246,7 +15246,7 @@ function _stringbool(Classes, _params) {
|
|
|
15246
15246
|
type: "pipe",
|
|
15247
15247
|
in: stringSchema,
|
|
15248
15248
|
out: booleanSchema,
|
|
15249
|
-
transform: ((input,
|
|
15249
|
+
transform: ((input, payload) => {
|
|
15250
15250
|
let data = input;
|
|
15251
15251
|
if (params.case !== "sensitive")
|
|
15252
15252
|
data = data.toLowerCase();
|
|
@@ -15255,11 +15255,11 @@ function _stringbool(Classes, _params) {
|
|
|
15255
15255
|
} else if (falsySet.has(data)) {
|
|
15256
15256
|
return false;
|
|
15257
15257
|
} else {
|
|
15258
|
-
|
|
15258
|
+
payload.issues.push({
|
|
15259
15259
|
code: "invalid_value",
|
|
15260
15260
|
expected: "stringbool",
|
|
15261
15261
|
values: [...truthySet, ...falsySet],
|
|
15262
|
-
input:
|
|
15262
|
+
input: payload.value,
|
|
15263
15263
|
inst: codec2,
|
|
15264
15264
|
continue: false
|
|
15265
15265
|
});
|
|
@@ -17693,12 +17693,12 @@ function _instanceof(cls, params = {}) {
|
|
|
17693
17693
|
...util_exports.normalizeParams(params)
|
|
17694
17694
|
});
|
|
17695
17695
|
inst._zod.bag.Class = cls;
|
|
17696
|
-
inst._zod.check = (
|
|
17697
|
-
if (!(
|
|
17698
|
-
|
|
17696
|
+
inst._zod.check = (payload) => {
|
|
17697
|
+
if (!(payload.value instanceof cls)) {
|
|
17698
|
+
payload.issues.push({
|
|
17699
17699
|
code: "invalid_type",
|
|
17700
17700
|
expected: cls.name,
|
|
17701
|
-
input:
|
|
17701
|
+
input: payload.value,
|
|
17702
17702
|
inst,
|
|
17703
17703
|
path: [...inst._zod.def.path ?? []]
|
|
17704
17704
|
});
|
|
@@ -18365,34 +18365,34 @@ var init_schemas3 = __esm({
|
|
|
18365
18365
|
$ZodTransform.init(inst, def);
|
|
18366
18366
|
ZodType2.init(inst, def);
|
|
18367
18367
|
inst._zod.processJSONSchema = (ctx, json2, params) => transformProcessor(inst, ctx, json2, params);
|
|
18368
|
-
inst._zod.parse = (
|
|
18368
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
18369
18369
|
if (_ctx.direction === "backward") {
|
|
18370
18370
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
18371
18371
|
}
|
|
18372
|
-
|
|
18372
|
+
payload.addIssue = (issue2) => {
|
|
18373
18373
|
if (typeof issue2 === "string") {
|
|
18374
|
-
|
|
18374
|
+
payload.issues.push(util_exports.issue(issue2, payload.value, def));
|
|
18375
18375
|
} else {
|
|
18376
18376
|
const _issue = issue2;
|
|
18377
18377
|
if (_issue.fatal)
|
|
18378
18378
|
_issue.continue = false;
|
|
18379
18379
|
_issue.code ?? (_issue.code = "custom");
|
|
18380
|
-
_issue.input ?? (_issue.input =
|
|
18380
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
18381
18381
|
_issue.inst ?? (_issue.inst = inst);
|
|
18382
|
-
|
|
18382
|
+
payload.issues.push(util_exports.issue(_issue));
|
|
18383
18383
|
}
|
|
18384
18384
|
};
|
|
18385
|
-
const output = def.transform(
|
|
18385
|
+
const output = def.transform(payload.value, payload);
|
|
18386
18386
|
if (output instanceof Promise) {
|
|
18387
18387
|
return output.then((output2) => {
|
|
18388
|
-
|
|
18389
|
-
|
|
18390
|
-
return
|
|
18388
|
+
payload.value = output2;
|
|
18389
|
+
payload.fallback = true;
|
|
18390
|
+
return payload;
|
|
18391
18391
|
});
|
|
18392
18392
|
}
|
|
18393
|
-
|
|
18394
|
-
|
|
18395
|
-
return
|
|
18393
|
+
payload.value = output;
|
|
18394
|
+
payload.fallback = true;
|
|
18395
|
+
return payload;
|
|
18396
18396
|
};
|
|
18397
18397
|
});
|
|
18398
18398
|
ZodOptional2 = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
@@ -32825,88 +32825,6 @@ var init_clipboard = __esm({
|
|
|
32825
32825
|
}
|
|
32826
32826
|
});
|
|
32827
32827
|
|
|
32828
|
-
// src/media-url.ts
|
|
32829
|
-
var media_url_exports = {};
|
|
32830
|
-
__export(media_url_exports, {
|
|
32831
|
-
MEDIA_URL_TTL_MS: () => MEDIA_URL_TTL_MS,
|
|
32832
|
-
SIGNING_SECRET_KV_KEY: () => SIGNING_SECRET_KV_KEY,
|
|
32833
|
-
base64UrlDecode: () => base64UrlDecode,
|
|
32834
|
-
base64UrlEncode: () => base64UrlEncode,
|
|
32835
|
-
buildMediaUrl: () => buildMediaUrl,
|
|
32836
|
-
loadSigningKey: () => loadSigningKey,
|
|
32837
|
-
resolveSigningKey: () => resolveSigningKey,
|
|
32838
|
-
signMediaKey: () => signMediaKey,
|
|
32839
|
-
verifyMediaSignature: () => verifyMediaSignature
|
|
32840
|
-
});
|
|
32841
|
-
function base64UrlEncode(bytes) {
|
|
32842
|
-
const view = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
|
|
32843
|
-
let binary = "";
|
|
32844
|
-
for (let i = 0; i < view.length; i++) binary += String.fromCharCode(view[i]);
|
|
32845
|
-
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
32846
|
-
}
|
|
32847
|
-
function base64UrlDecode(text) {
|
|
32848
|
-
const padded = text.replace(/-/g, "+").replace(/_/g, "/").padEnd(Math.ceil(text.length / 4) * 4, "=");
|
|
32849
|
-
const binary = atob(padded);
|
|
32850
|
-
const out = new Uint8Array(binary.length);
|
|
32851
|
-
for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i);
|
|
32852
|
-
return out;
|
|
32853
|
-
}
|
|
32854
|
-
async function importKey(material) {
|
|
32855
|
-
return crypto.subtle.importKey("raw", new TextEncoder().encode(material), { name: "HMAC", hash: "SHA-256" }, false, [
|
|
32856
|
-
"sign",
|
|
32857
|
-
"verify"
|
|
32858
|
-
]);
|
|
32859
|
-
}
|
|
32860
|
-
async function resolveSigningKey(secret, store) {
|
|
32861
|
-
let material = secret?.trim();
|
|
32862
|
-
if (!material) {
|
|
32863
|
-
material = await store.get(SIGNING_SECRET_KV_KEY) ?? void 0;
|
|
32864
|
-
if (!material) {
|
|
32865
|
-
const generated = base64UrlEncode(crypto.getRandomValues(new Uint8Array(32)));
|
|
32866
|
-
await store.put(SIGNING_SECRET_KV_KEY, generated);
|
|
32867
|
-
material = await store.get(SIGNING_SECRET_KV_KEY) ?? generated;
|
|
32868
|
-
}
|
|
32869
|
-
}
|
|
32870
|
-
return importKey(material);
|
|
32871
|
-
}
|
|
32872
|
-
async function loadSigningKey(secret, store) {
|
|
32873
|
-
const material = secret?.trim() || await store.get(SIGNING_SECRET_KV_KEY);
|
|
32874
|
-
return material ? importKey(material) : void 0;
|
|
32875
|
-
}
|
|
32876
|
-
function payload(key, expiresAtMs2) {
|
|
32877
|
-
return new TextEncoder().encode(`${key}
|
|
32878
|
-
${expiresAtMs2}`);
|
|
32879
|
-
}
|
|
32880
|
-
async function signMediaKey(signingKey, key, expiresAtMs2) {
|
|
32881
|
-
return base64UrlEncode(await crypto.subtle.sign("HMAC", signingKey, payload(key, expiresAtMs2)));
|
|
32882
|
-
}
|
|
32883
|
-
async function verifyMediaSignature(signingKey, key, exp, sig, nowMs) {
|
|
32884
|
-
if (!exp || !sig) return { ok: false, reason: "missing" };
|
|
32885
|
-
const expiresAtMs2 = Number(exp);
|
|
32886
|
-
if (!Number.isFinite(expiresAtMs2)) return { ok: false, reason: "invalid" };
|
|
32887
|
-
let valid;
|
|
32888
|
-
try {
|
|
32889
|
-
valid = await crypto.subtle.verify("HMAC", signingKey, base64UrlDecode(sig), payload(key, expiresAtMs2));
|
|
32890
|
-
} catch {
|
|
32891
|
-
return { ok: false, reason: "invalid" };
|
|
32892
|
-
}
|
|
32893
|
-
if (!valid) return { ok: false, reason: "invalid" };
|
|
32894
|
-
if (nowMs > expiresAtMs2) return { ok: false, reason: "expired" };
|
|
32895
|
-
return { ok: true };
|
|
32896
|
-
}
|
|
32897
|
-
function buildMediaUrl(baseUrl, key, expiresAtMs2, signature) {
|
|
32898
|
-
const path = key.split("/").map(encodeURIComponent).join("/");
|
|
32899
|
-
return `${baseUrl.replace(/\/+$/, "")}/${path}?exp=${expiresAtMs2}&sig=${signature}`;
|
|
32900
|
-
}
|
|
32901
|
-
var MEDIA_URL_TTL_MS, SIGNING_SECRET_KV_KEY;
|
|
32902
|
-
var init_media_url = __esm({
|
|
32903
|
-
"src/media-url.ts"() {
|
|
32904
|
-
"use strict";
|
|
32905
|
-
MEDIA_URL_TTL_MS = 48 * 60 * 60 * 1e3;
|
|
32906
|
-
SIGNING_SECRET_KV_KEY = "media:url-signing-secret";
|
|
32907
|
-
}
|
|
32908
|
-
});
|
|
32909
|
-
|
|
32910
32828
|
// src/index.ts
|
|
32911
32829
|
init_dist();
|
|
32912
32830
|
|
|
@@ -32920,7 +32838,65 @@ async function loadStdioDotenv() {
|
|
|
32920
32838
|
}
|
|
32921
32839
|
|
|
32922
32840
|
// src/version.ts
|
|
32923
|
-
var VERSION = "1.
|
|
32841
|
+
var VERSION = "1.7.0";
|
|
32842
|
+
|
|
32843
|
+
// src/errors.ts
|
|
32844
|
+
init_dist();
|
|
32845
|
+
var MAX_CAUSE_DEPTH = 5;
|
|
32846
|
+
function describeError(err) {
|
|
32847
|
+
const seen = /* @__PURE__ */ new Set();
|
|
32848
|
+
const describe3 = (value, depth) => {
|
|
32849
|
+
if (!(value instanceof Error)) {
|
|
32850
|
+
if (typeof value === "string") return value;
|
|
32851
|
+
try {
|
|
32852
|
+
return typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
|
|
32853
|
+
} catch {
|
|
32854
|
+
return String(value);
|
|
32855
|
+
}
|
|
32856
|
+
}
|
|
32857
|
+
const named = value.name && value.name !== "Error" && value.name !== "McpToolError" ? `${value.name}: ${value.message}` : value.message;
|
|
32858
|
+
const hint = value instanceof McpToolError && value.hint && !value.message.includes(value.hint) ? ` ${value.hint}` : "";
|
|
32859
|
+
const cause = value.cause;
|
|
32860
|
+
if (cause === void 0 || cause === null || depth >= MAX_CAUSE_DEPTH || seen.has(cause)) {
|
|
32861
|
+
return `${named}${hint}`;
|
|
32862
|
+
}
|
|
32863
|
+
seen.add(cause);
|
|
32864
|
+
return `${named}${hint} [caused by: ${describe3(cause, depth + 1)}]`;
|
|
32865
|
+
};
|
|
32866
|
+
seen.add(err);
|
|
32867
|
+
return describe3(err, 0);
|
|
32868
|
+
}
|
|
32869
|
+
async function step(label, run) {
|
|
32870
|
+
try {
|
|
32871
|
+
return await run();
|
|
32872
|
+
} catch (err) {
|
|
32873
|
+
if (err instanceof StepError) throw err;
|
|
32874
|
+
throw new StepError(`${label}: ${describeError(err)}`, err);
|
|
32875
|
+
}
|
|
32876
|
+
}
|
|
32877
|
+
var StepError = class extends McpToolError {
|
|
32878
|
+
constructor(message, cause) {
|
|
32879
|
+
super(message, { cause });
|
|
32880
|
+
this.name = "McpToolError";
|
|
32881
|
+
}
|
|
32882
|
+
};
|
|
32883
|
+
function surfaceToolErrors(server) {
|
|
32884
|
+
return new Proxy(server, {
|
|
32885
|
+
get(target, prop, receiver) {
|
|
32886
|
+
const value = Reflect.get(target, prop, receiver);
|
|
32887
|
+
if (prop !== "registerTool" || typeof value !== "function") {
|
|
32888
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
32889
|
+
}
|
|
32890
|
+
return (name, config2, handler) => value.call(target, name, config2, async (...args) => {
|
|
32891
|
+
try {
|
|
32892
|
+
return await handler(...args);
|
|
32893
|
+
} catch (err) {
|
|
32894
|
+
throw new McpToolError(`${name} failed: ${describeError(err)}`, { cause: err });
|
|
32895
|
+
}
|
|
32896
|
+
});
|
|
32897
|
+
}
|
|
32898
|
+
});
|
|
32899
|
+
}
|
|
32924
32900
|
|
|
32925
32901
|
// src/tools/models.ts
|
|
32926
32902
|
init_dist();
|
|
@@ -33355,6 +33331,22 @@ init_zod();
|
|
|
33355
33331
|
init_dist();
|
|
33356
33332
|
init_images();
|
|
33357
33333
|
|
|
33334
|
+
// src/signed-url.ts
|
|
33335
|
+
function signedObjectUrl(baseUrl, key, params) {
|
|
33336
|
+
const path = key.split("/").map(encodeURIComponent).join("/");
|
|
33337
|
+
const query = new URLSearchParams();
|
|
33338
|
+
for (const [name, value] of Object.entries(params)) query.set(name, String(value));
|
|
33339
|
+
return `${baseUrl.replace(/\/+$/, "")}/${path}?${query}`;
|
|
33340
|
+
}
|
|
33341
|
+
function signedLinks(baseUrl) {
|
|
33342
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
33343
|
+
return {
|
|
33344
|
+
base,
|
|
33345
|
+
media: (key, expiresAtMs2, signature) => signedObjectUrl(base, key, { exp: expiresAtMs2, sig: signature }),
|
|
33346
|
+
upload: (key, contentType, expiresAtMs2, signature) => signedObjectUrl(base, key, { ct: contentType.toLowerCase(), exp: expiresAtMs2, sig: signature })
|
|
33347
|
+
};
|
|
33348
|
+
}
|
|
33349
|
+
|
|
33358
33350
|
// src/storage/media.ts
|
|
33359
33351
|
function createDiskSink() {
|
|
33360
33352
|
return {
|
|
@@ -33375,6 +33367,14 @@ async function tenantIdFor(secret) {
|
|
|
33375
33367
|
return [...new Uint8Array(digest).slice(0, 6)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
33376
33368
|
}
|
|
33377
33369
|
var KEY_PREFIX_DEFAULT = "gen";
|
|
33370
|
+
var MAX_LIST_PAGES = 10;
|
|
33371
|
+
function parseMediaKey(key, prefix) {
|
|
33372
|
+
const rest = key.slice(prefix.length);
|
|
33373
|
+
const match = /^(\d{4}-\d{2}-\d{2})\/(.+)$/.exec(rest);
|
|
33374
|
+
if (!match) return void 0;
|
|
33375
|
+
const name = match[2].replace(/^[0-9a-f]{4,}-/i, "").replace(/\.[A-Za-z0-9]+$/, "");
|
|
33376
|
+
return { day: match[1], name: name || match[2] };
|
|
33377
|
+
}
|
|
33378
33378
|
function safeKeySegment(base) {
|
|
33379
33379
|
const cleaned = base.replace(/[^A-Za-z0-9._-]+/g, "-").replace(/\.{2,}/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "");
|
|
33380
33380
|
return cleaned || "media";
|
|
@@ -33384,7 +33384,7 @@ function createR2Sink(bucket, opts) {
|
|
|
33384
33384
|
const now = opts.now ?? (() => /* @__PURE__ */ new Date());
|
|
33385
33385
|
const randomId = opts.randomId ?? (() => crypto.randomUUID().slice(0, 8));
|
|
33386
33386
|
const publicBase = opts.publicBaseUrl?.replace(/\/+$/, "");
|
|
33387
|
-
const signedBase = opts.signedBaseUrl?.replace(/\/+$/, "");
|
|
33387
|
+
const signedBase = opts.links?.base ?? opts.signedBaseUrl?.replace(/\/+$/, "");
|
|
33388
33388
|
const ttlMs = opts.urlTtlMs ?? 0;
|
|
33389
33389
|
const readPrefixes = [prefix, ...opts.readPrefixes ?? []];
|
|
33390
33390
|
let tenantCache;
|
|
@@ -33410,6 +33410,40 @@ function createR2Sink(bucket, opts) {
|
|
|
33410
33410
|
mimeType: object3.httpMetadata?.contentType ?? "application/octet-stream"
|
|
33411
33411
|
};
|
|
33412
33412
|
},
|
|
33413
|
+
async listRecent(opts2 = {}) {
|
|
33414
|
+
return (await this.listRecentPage(opts2)).media;
|
|
33415
|
+
},
|
|
33416
|
+
async listRecentPage({ limit = 20, sinceDay } = {}) {
|
|
33417
|
+
if (!bucket.list) return { media: [], truncated: false, scannedPages: 0 };
|
|
33418
|
+
const prefix2 = await ownPrefix();
|
|
33419
|
+
const found = [];
|
|
33420
|
+
let cursor;
|
|
33421
|
+
let truncated = false;
|
|
33422
|
+
let scannedPages = 0;
|
|
33423
|
+
for (let page2 = 0; page2 < MAX_LIST_PAGES; page2++) {
|
|
33424
|
+
scannedPages = page2 + 1;
|
|
33425
|
+
const listed = await bucket.list({ prefix: prefix2, cursor, limit: 1e3 });
|
|
33426
|
+
for (const obj of listed.objects) {
|
|
33427
|
+
const parsed = parseMediaKey(obj.key, prefix2);
|
|
33428
|
+
if (!parsed) continue;
|
|
33429
|
+
if (sinceDay && parsed.day < sinceDay) continue;
|
|
33430
|
+
found.push({ ...parsed, key: obj.key, ...obj.size !== void 0 ? { sizeBytes: obj.size } : {} });
|
|
33431
|
+
}
|
|
33432
|
+
if (!listed.truncated || !listed.cursor) break;
|
|
33433
|
+
cursor = listed.cursor;
|
|
33434
|
+
if (page2 === MAX_LIST_PAGES - 1) truncated = true;
|
|
33435
|
+
}
|
|
33436
|
+
found.sort((a, b) => a.day < b.day ? 1 : a.day > b.day ? -1 : a.key < b.key ? 1 : -1);
|
|
33437
|
+
const page = found.slice(0, limit);
|
|
33438
|
+
const expiresAtMs2 = now().getTime() + ttlMs;
|
|
33439
|
+
const media = await Promise.all(
|
|
33440
|
+
page.map(async (entry) => {
|
|
33441
|
+
const link = await describe3(entry.key, expiresAtMs2);
|
|
33442
|
+
return { ...entry, ...link.unavailable ? {} : { url: link.ref, expiresAt: link.expiresAt } };
|
|
33443
|
+
})
|
|
33444
|
+
);
|
|
33445
|
+
return { media, truncated: truncated || found.length > limit, scannedPages };
|
|
33446
|
+
},
|
|
33413
33447
|
async resign(key) {
|
|
33414
33448
|
if (!await owned(key)) return void 0;
|
|
33415
33449
|
if (bucket.get && !await bucket.get(key)) return void 0;
|
|
@@ -33434,9 +33468,9 @@ function createR2Sink(bucket, opts) {
|
|
|
33434
33468
|
async function describe3(key, expiresAtMs2) {
|
|
33435
33469
|
if (publicBase) return { ref: `${publicBase}/${key}`, key };
|
|
33436
33470
|
if (signedBase && opts.sign) {
|
|
33437
|
-
const { buildMediaUrl: buildMediaUrl2 } = await Promise.resolve().then(() => (init_media_url(), media_url_exports));
|
|
33438
33471
|
const signature = await opts.sign(key, expiresAtMs2);
|
|
33439
|
-
|
|
33472
|
+
const link = (opts.links ?? signedLinks(signedBase)).media(key, expiresAtMs2, signature);
|
|
33473
|
+
return { ref: link, key, expiresAt: new Date(expiresAtMs2).toISOString() };
|
|
33440
33474
|
}
|
|
33441
33475
|
return { ref: key, key, unavailable: true };
|
|
33442
33476
|
}
|
|
@@ -33551,7 +33585,7 @@ var idempotencyKeySchema = external_exports.string().min(1).optional().describe(
|
|
|
33551
33585
|
"Opaque idempotency key: a repeat call with the same key returns the recorded result (reused: true) instead of billing a new generation. Set it when retrying after a host timeout (-32001) to avoid a duplicate charge."
|
|
33552
33586
|
);
|
|
33553
33587
|
var asyncSchema = external_exports.boolean().optional().describe(
|
|
33554
|
-
"Run in the background and return a job_id immediately instead of the image, so a long (Pro/4K) generation cannot hit the host tools/call timeout (-32001). Poll gemini_get_result with the job_id to fetch the result
|
|
33588
|
+
"Run in the background and return a job_id immediately instead of the image, so a long (Pro/4K) generation cannot hit the host tools/call timeout (-32001). Poll gemini_get_result with the job_id to fetch the result. PREFER `max_wait_ms` on the hosted connector: it runs where the executor is only guaranteed to stay alive while the request is open, so this option is served there as a bounded wait rather than an immediate hand-off."
|
|
33555
33589
|
);
|
|
33556
33590
|
var maxWaitMsSchema = external_exports.number().int().positive().max(6e5).optional().describe(
|
|
33557
33591
|
'Wait up to this many ms for the result; if generation is still running when the budget expires, return { job_id, status: "running" } immediately instead (poll gemini_get_result). Keeps fast results in-band while a slow batch can never trip the host tools/call timeout (-32001) \u2014 e.g. 20000 for multi-image sets. Ignored when async is set.'
|
|
@@ -33716,7 +33750,7 @@ function timeoutRiskHint(opts) {
|
|
|
33716
33750
|
const why = [proModel && "Pro model", fourK && "4K output", multi && `count=${opts.count}`].filter(Boolean).join(" + ");
|
|
33717
33751
|
const lead = `Slow config (${why}) can exceed a host's tools/call timeout (e.g. Claude Desktop ~30s, error -32001). `;
|
|
33718
33752
|
if (opts.persistsFiles === false) {
|
|
33719
|
-
return lead + `This connector has no filesystem, so a lost response cannot be recovered from disk \u2014 there is no output dir and no <image>.json sidecar.
|
|
33753
|
+
return lead + `This connector has no filesystem, so a lost response cannot be recovered from disk \u2014 there is no output dir and no <image>.json sidecar. Set \`max_wait_ms\` (e.g. 240000): keeping the request open is also what keeps the generation running here, and a batch that outlives the budget hands back a job_id to poll with gemini_get_result. For a faster in-band result use a Flash model or drop image_size to 1K/2K. If a result is ever lost, list what was already generated with gemini_list_recent_media before paying for it again.`;
|
|
33720
33754
|
}
|
|
33721
33755
|
return lead + `If the host gives up mid-generation the image is still written to disk (and gemini_interact leaves an <image>.json sidecar with the interaction id) \u2014 no rerun needed, just look in the output dir. For a faster in-band result use a Flash model, drop image_size to 1K/2K, or \u2014 in Claude Code \u2014 set MCP_TOOL_TIMEOUT.`;
|
|
33722
33756
|
}
|
|
@@ -33818,14 +33852,73 @@ function assertLocalInputsAvailable(sink, args) {
|
|
|
33818
33852
|
|
|
33819
33853
|
// src/jobs.ts
|
|
33820
33854
|
init_dist();
|
|
33821
|
-
import { randomUUID, createHash } from "node:crypto";
|
|
33855
|
+
import { randomUUID, createHash as createHash2 } from "node:crypto";
|
|
33856
|
+
|
|
33857
|
+
// src/job-store.ts
|
|
33858
|
+
import { createHash } from "node:crypto";
|
|
33859
|
+
var HEARTBEAT_MS = 6e4;
|
|
33860
|
+
var EXECUTOR_LOST_AFTER_MS = 3 * HEARTBEAT_MS;
|
|
33861
|
+
var PREFIX = "jobs";
|
|
33862
|
+
function keyHash(idempotencyKey) {
|
|
33863
|
+
return createHash("sha256").update(idempotencyKey).digest("hex").slice(0, 32);
|
|
33864
|
+
}
|
|
33865
|
+
function createBlobJobStore(bucket, opts) {
|
|
33866
|
+
const now = opts.now ?? (() => Date.now());
|
|
33867
|
+
const tenantOf = async () => typeof opts.tenant === "function" ? opts.tenant() : opts.tenant;
|
|
33868
|
+
const recordKey = async (jobId) => `${PREFIX}/${await tenantOf()}/${encodeURIComponent(jobId)}.json`;
|
|
33869
|
+
const pointerKey = async (k) => `${PREFIX}/${await tenantOf()}/keys/${keyHash(k)}.json`;
|
|
33870
|
+
async function writeJson(key, value) {
|
|
33871
|
+
try {
|
|
33872
|
+
await bucket.put(key, JSON.stringify(value), { httpMetadata: { contentType: "application/json" } });
|
|
33873
|
+
} catch {
|
|
33874
|
+
}
|
|
33875
|
+
}
|
|
33876
|
+
async function readJson(key) {
|
|
33877
|
+
try {
|
|
33878
|
+
const obj = await bucket.get(key);
|
|
33879
|
+
if (!obj) return void 0;
|
|
33880
|
+
return JSON.parse(new TextDecoder().decode(await obj.arrayBuffer()));
|
|
33881
|
+
} catch {
|
|
33882
|
+
return void 0;
|
|
33883
|
+
}
|
|
33884
|
+
}
|
|
33885
|
+
return {
|
|
33886
|
+
async put(record2) {
|
|
33887
|
+
await writeJson(await recordKey(record2.jobId), record2);
|
|
33888
|
+
},
|
|
33889
|
+
async get(jobId) {
|
|
33890
|
+
const record2 = await readJson(await recordKey(jobId));
|
|
33891
|
+
if (!record2 || typeof record2.status !== "string") return void 0;
|
|
33892
|
+
if (record2.status !== "running") return record2;
|
|
33893
|
+
if (now() - record2.updatedAt <= EXECUTOR_LOST_AFTER_MS) return record2;
|
|
33894
|
+
return {
|
|
33895
|
+
...record2,
|
|
33896
|
+
status: "failed",
|
|
33897
|
+
error: {
|
|
33898
|
+
message: `Job "${jobId}" was lost: its executor stopped reporting ${Math.round((now() - record2.updatedAt) / 1e3)}s ago, before the generation finished. This connector runs on a machine that stops when no request is in flight, so background work started with \`async: true\` does not reliably survive.`,
|
|
33899
|
+
hint: "Re-run with `max_wait_ms` (e.g. 240000) instead of `async: true` \u2014 holding the request open keeps the executor alive. Any images the lost run did finish are still stored: list them with gemini_list_recent_media before paying for a regeneration."
|
|
33900
|
+
}
|
|
33901
|
+
};
|
|
33902
|
+
},
|
|
33903
|
+
async putKey(idempotencyKey, jobId) {
|
|
33904
|
+
await writeJson(await pointerKey(idempotencyKey), { jobId });
|
|
33905
|
+
},
|
|
33906
|
+
async jobIdForKey(idempotencyKey) {
|
|
33907
|
+
const pointer = await readJson(await pointerKey(idempotencyKey));
|
|
33908
|
+
return typeof pointer?.jobId === "string" ? pointer.jobId : void 0;
|
|
33909
|
+
}
|
|
33910
|
+
};
|
|
33911
|
+
}
|
|
33912
|
+
|
|
33913
|
+
// src/jobs.ts
|
|
33822
33914
|
var JOB_TTL_MS = 6e5;
|
|
33915
|
+
var DURABLE_JOB_REUSE_MS = 24 * 60 * 60 * 1e3;
|
|
33823
33916
|
var JOB_MAX = 64;
|
|
33824
33917
|
function isExpired(entry, now) {
|
|
33825
33918
|
return entry.settledAt !== void 0 && now - entry.settledAt > JOB_TTL_MS;
|
|
33826
33919
|
}
|
|
33827
33920
|
function fingerprintRequest(toolName, parts) {
|
|
33828
|
-
return
|
|
33921
|
+
return createHash2("sha256").update(`${toolName}\0${JSON.stringify(parts)}`).digest("hex");
|
|
33829
33922
|
}
|
|
33830
33923
|
async function refreshMedia(result, sink) {
|
|
33831
33924
|
const first = result.content?.[0];
|
|
@@ -33904,13 +33997,23 @@ function annotateReused(result, jobId) {
|
|
|
33904
33997
|
content: [{ type: "text", text: JSON.stringify({ reused: true, reused_job_id: jobId }, null, 2) }, ...content]
|
|
33905
33998
|
};
|
|
33906
33999
|
}
|
|
33907
|
-
function jobHandle(jobId, status) {
|
|
34000
|
+
function jobHandle(jobId, status, durable = false) {
|
|
33908
34001
|
return textResult({
|
|
33909
34002
|
job_id: jobId,
|
|
33910
34003
|
status,
|
|
33911
|
-
hint: `Generation running in the background. Poll gemini_get_result with job_id "${jobId}" until status is "done" (results are per-process and expire ~10 min after completion).`
|
|
34004
|
+
hint: durable ? `Generation running in the background. Poll gemini_get_result with job_id "${jobId}" until status is "done". The job record is stored durably, so a poll still works if this connector restarts \u2014 but background work is NOT restarted, so a long generation is safer with max_wait_ms than with async.` : `Generation running in the background. Poll gemini_get_result with job_id "${jobId}" until status is "done" (results are per-process and expire ~10 min after completion).`
|
|
33912
34005
|
});
|
|
33913
34006
|
}
|
|
34007
|
+
var MAX_PERSISTED_RESULT_BYTES = 64 * 1024;
|
|
34008
|
+
function persistableResult(result) {
|
|
34009
|
+
if ((result.content ?? []).some((block) => block.type !== "text")) return { resultOmitted: "inline" };
|
|
34010
|
+
try {
|
|
34011
|
+
if (JSON.stringify(result).length > MAX_PERSISTED_RESULT_BYTES) return { resultOmitted: "too_large" };
|
|
34012
|
+
} catch {
|
|
34013
|
+
return { resultOmitted: "too_large" };
|
|
34014
|
+
}
|
|
34015
|
+
return { result };
|
|
34016
|
+
}
|
|
33914
34017
|
function awaitWithBudget(promise2, waitMs) {
|
|
33915
34018
|
return new Promise((resolve2, reject) => {
|
|
33916
34019
|
const timer = setTimeout(() => resolve2(void 0), waitMs);
|
|
@@ -33934,16 +34037,112 @@ var JobRegistry = class {
|
|
|
33934
34037
|
* never expire.
|
|
33935
34038
|
*/
|
|
33936
34039
|
resigner;
|
|
34040
|
+
/**
|
|
34041
|
+
* Durable backing for this registry, when the deployment has somewhere to put
|
|
34042
|
+
* it. Absent on a local stdio install, where the process that starts a
|
|
34043
|
+
* generation is the process that finishes it and a `Map` is the whole truth.
|
|
34044
|
+
*
|
|
34045
|
+
* Present on the hosted connector, where it is load-bearing: see the header of
|
|
34046
|
+
* `src/job-store.ts` for why an in-memory-only registry cannot work on a
|
|
34047
|
+
* machine that stops whenever no request is in flight.
|
|
34048
|
+
*/
|
|
34049
|
+
store;
|
|
34050
|
+
/**
|
|
34051
|
+
* When set, `async: true` is served as a bounded in-band wait instead of an
|
|
34052
|
+
* immediate hand-off.
|
|
34053
|
+
*
|
|
34054
|
+
* Set by the hosted client, because there the two are not the trade-off they
|
|
34055
|
+
* look like. Returning immediately releases the request, and the released
|
|
34056
|
+
* request is the thing keeping the executor alive — so `async: true` is
|
|
34057
|
+
* precisely the way to get a generation killed. Waiting holds the machine up
|
|
34058
|
+
* until the work is done. If the budget still expires the caller gets the same
|
|
34059
|
+
* job handle it asked for, now backed by a durable record.
|
|
34060
|
+
*/
|
|
34061
|
+
asyncWaitFallbackMs;
|
|
34062
|
+
/** Injectable clock (tests). */
|
|
34063
|
+
now = () => Date.now();
|
|
33937
34064
|
jobs = /* @__PURE__ */ new Map();
|
|
33938
34065
|
byKey = /* @__PURE__ */ new Map();
|
|
33939
34066
|
// idempotencyKey -> jobId
|
|
33940
34067
|
runningByFingerprint = /* @__PURE__ */ new Map();
|
|
33941
34068
|
// fingerprint -> jobId (only while running)
|
|
34069
|
+
/** Durable bookkeeping still in flight — awaited by `drain()` in tests. */
|
|
34070
|
+
pending = /* @__PURE__ */ new Set();
|
|
34071
|
+
heartbeatTimer;
|
|
33942
34072
|
/** Drop every job. Used by `SessionState.reset()` (tests) — not by handlers. */
|
|
33943
34073
|
reset() {
|
|
33944
34074
|
this.jobs.clear();
|
|
33945
34075
|
this.byKey.clear();
|
|
33946
34076
|
this.runningByFingerprint.clear();
|
|
34077
|
+
this.stopHeartbeat();
|
|
34078
|
+
}
|
|
34079
|
+
/** Await outstanding durable writes. Tests only — handlers never need it. */
|
|
34080
|
+
async drain() {
|
|
34081
|
+
for (let round = 0; round < 50; round++) {
|
|
34082
|
+
await new Promise((resolve2) => setTimeout(resolve2, 0));
|
|
34083
|
+
if (!this.pending.size) return;
|
|
34084
|
+
await Promise.allSettled([...this.pending]);
|
|
34085
|
+
}
|
|
34086
|
+
}
|
|
34087
|
+
/**
|
|
34088
|
+
* Re-stamp every running job's durable record.
|
|
34089
|
+
*
|
|
34090
|
+
* This is what separates "still working" from "the machine went away": a
|
|
34091
|
+
* reader compares the stamp against `EXECUTOR_LOST_AFTER_MS`, so a 12-scene
|
|
34092
|
+
* set that legitimately runs for ten minutes stays `running` while a job whose
|
|
34093
|
+
* child was killed goes terminal within three missed beats.
|
|
34094
|
+
*/
|
|
34095
|
+
async beat() {
|
|
34096
|
+
if (!this.store) return;
|
|
34097
|
+
await Promise.allSettled(
|
|
34098
|
+
[...this.jobs.values()].filter((e) => e.status === "running").map((e) => this.writeRecord(e, { onlyWhileRunning: true }))
|
|
34099
|
+
);
|
|
34100
|
+
}
|
|
34101
|
+
/**
|
|
34102
|
+
* Queue one durable write for `entry`, after any write already in flight for
|
|
34103
|
+
* it. `onlyWhileRunning` drops the write if the job settled in the meantime —
|
|
34104
|
+
* which is what makes a late heartbeat a no-op rather than a resurrection.
|
|
34105
|
+
*/
|
|
34106
|
+
writeRecord(entry, opts = {}) {
|
|
34107
|
+
const next = (entry.writeChain ?? Promise.resolve()).then(async () => {
|
|
34108
|
+
if (opts.onlyWhileRunning && entry.status !== "running") return;
|
|
34109
|
+
await this.store.put(this.recordFor(entry, this.now()));
|
|
34110
|
+
}, () => void 0);
|
|
34111
|
+
entry.writeChain = next;
|
|
34112
|
+
return next;
|
|
34113
|
+
}
|
|
34114
|
+
recordFor(entry, updatedAt) {
|
|
34115
|
+
return {
|
|
34116
|
+
jobId: entry.jobId,
|
|
34117
|
+
toolName: entry.toolName,
|
|
34118
|
+
fingerprint: entry.fingerprint,
|
|
34119
|
+
...entry.idempotencyKey !== void 0 ? { idempotencyKey: entry.idempotencyKey } : {},
|
|
34120
|
+
status: entry.status,
|
|
34121
|
+
createdAt: entry.createdAt,
|
|
34122
|
+
updatedAt,
|
|
34123
|
+
...entry.error ? { error: entry.error } : {},
|
|
34124
|
+
...entry.status === "done" && entry.result ? persistableResult(entry.result) : {}
|
|
34125
|
+
};
|
|
34126
|
+
}
|
|
34127
|
+
/** Run `p` as durable bookkeeping: tracked for `drain()`, never thrown from. */
|
|
34128
|
+
track(p) {
|
|
34129
|
+
const wrapped = p.catch(() => void 0).finally(() => this.pending.delete(wrapped));
|
|
34130
|
+
this.pending.add(wrapped);
|
|
34131
|
+
}
|
|
34132
|
+
startHeartbeat() {
|
|
34133
|
+
if (this.heartbeatTimer || !this.store) return;
|
|
34134
|
+
this.heartbeatTimer = setInterval(() => {
|
|
34135
|
+
if (![...this.jobs.values()].some((e) => e.status === "running")) {
|
|
34136
|
+
this.stopHeartbeat();
|
|
34137
|
+
return;
|
|
34138
|
+
}
|
|
34139
|
+
this.track(this.beat());
|
|
34140
|
+
}, HEARTBEAT_MS);
|
|
34141
|
+
this.heartbeatTimer.unref?.();
|
|
34142
|
+
}
|
|
34143
|
+
stopHeartbeat() {
|
|
34144
|
+
if (this.heartbeatTimer) clearInterval(this.heartbeatTimer);
|
|
34145
|
+
this.heartbeatTimer = void 0;
|
|
33947
34146
|
}
|
|
33948
34147
|
/** Drop expired entries, then enforce JOB_MAX by evicting oldest-settled first. */
|
|
33949
34148
|
evict(now) {
|
|
@@ -33979,8 +34178,11 @@ var JobRegistry = class {
|
|
|
33979
34178
|
* different registry and therefore a genuinely separate generation.
|
|
33980
34179
|
*/
|
|
33981
34180
|
async dispatch(opts, work) {
|
|
33982
|
-
const { toolName, fingerprint, idempotencyKey
|
|
33983
|
-
const
|
|
34181
|
+
const { toolName, fingerprint, idempotencyKey } = opts;
|
|
34182
|
+
const degrade = opts.async === true && this.asyncWaitFallbackMs !== void 0;
|
|
34183
|
+
const async = degrade ? false : opts.async;
|
|
34184
|
+
const waitMs = degrade ? opts.waitMs ?? this.asyncWaitFallbackMs : opts.waitMs;
|
|
34185
|
+
const now = this.now();
|
|
33984
34186
|
let hit;
|
|
33985
34187
|
if (idempotencyKey !== void 0) {
|
|
33986
34188
|
const id = this.byKey.get(idempotencyKey);
|
|
@@ -33991,6 +34193,10 @@ var JobRegistry = class {
|
|
|
33991
34193
|
const entry2 = id ? this.jobs.get(id) : void 0;
|
|
33992
34194
|
if (entry2 && entry2.status === "running") hit = entry2;
|
|
33993
34195
|
}
|
|
34196
|
+
if (!hit && idempotencyKey !== void 0 && this.store) {
|
|
34197
|
+
const durable = await this.durableByKey(idempotencyKey, fingerprint);
|
|
34198
|
+
if (durable) return durable;
|
|
34199
|
+
}
|
|
33994
34200
|
if (hit) {
|
|
33995
34201
|
if (async) return jobHandle(hit.jobId, hit.status);
|
|
33996
34202
|
const settled = waitMs !== void 0 && hit.status === "running" ? await awaitWithBudget(hit.promise, waitMs) : await hit.promise;
|
|
@@ -34004,27 +34210,53 @@ var JobRegistry = class {
|
|
|
34004
34210
|
this.jobs.set(jobId, entry);
|
|
34005
34211
|
if (idempotencyKey !== void 0) this.byKey.set(idempotencyKey, jobId);
|
|
34006
34212
|
this.runningByFingerprint.set(fingerprint, jobId);
|
|
34007
|
-
|
|
34213
|
+
if (this.store) {
|
|
34214
|
+
this.track(this.writeRecord(entry));
|
|
34215
|
+
if (idempotencyKey !== void 0) this.track(this.store.putKey(idempotencyKey, jobId));
|
|
34216
|
+
this.startHeartbeat();
|
|
34217
|
+
}
|
|
34218
|
+
const settle = promise2.then(
|
|
34008
34219
|
(res) => {
|
|
34009
34220
|
entry.status = "done";
|
|
34010
34221
|
entry.result = res;
|
|
34011
|
-
entry.settledAt =
|
|
34222
|
+
entry.settledAt = this.now();
|
|
34012
34223
|
},
|
|
34013
34224
|
(err) => {
|
|
34014
34225
|
entry.status = "failed";
|
|
34015
34226
|
entry.error = { message: err instanceof Error ? err.message : String(err), hint: err?.hint };
|
|
34016
|
-
entry.settledAt =
|
|
34227
|
+
entry.settledAt = this.now();
|
|
34017
34228
|
}
|
|
34018
34229
|
).finally(() => {
|
|
34019
34230
|
if (this.runningByFingerprint.get(fingerprint) === jobId) this.runningByFingerprint.delete(fingerprint);
|
|
34020
34231
|
});
|
|
34021
|
-
if (
|
|
34232
|
+
if (this.store) void settle.then(() => this.track(this.writeRecord(entry)));
|
|
34233
|
+
if (async) return jobHandle(jobId, "running", this.store !== void 0);
|
|
34022
34234
|
if (waitMs !== void 0) {
|
|
34023
34235
|
const settled = await awaitWithBudget(promise2, waitMs);
|
|
34024
|
-
return settled ?? jobHandle(jobId, "running");
|
|
34236
|
+
return settled ?? jobHandle(jobId, "running", this.store !== void 0);
|
|
34025
34237
|
}
|
|
34026
34238
|
return promise2;
|
|
34027
34239
|
}
|
|
34240
|
+
/**
|
|
34241
|
+
* Resolve an idempotency key against the durable store — the path a retry
|
|
34242
|
+
* takes when the child that ran the original job is gone.
|
|
34243
|
+
*
|
|
34244
|
+
* `undefined` means "nothing durable to reuse", which includes a job that
|
|
34245
|
+
* FAILED: a retry after an error must really retry. A job still recorded as
|
|
34246
|
+
* running belongs to an executor this process cannot await, so the caller gets
|
|
34247
|
+
* the handle back rather than a promise that would never settle.
|
|
34248
|
+
*/
|
|
34249
|
+
async durableByKey(idempotencyKey, fingerprint) {
|
|
34250
|
+
const id = await this.store.jobIdForKey(idempotencyKey);
|
|
34251
|
+
if (!id) return void 0;
|
|
34252
|
+
const record2 = await this.store.get(id);
|
|
34253
|
+
if (!record2) return void 0;
|
|
34254
|
+
if (record2.fingerprint !== fingerprint) return void 0;
|
|
34255
|
+
if (this.now() - record2.updatedAt > DURABLE_JOB_REUSE_MS) return void 0;
|
|
34256
|
+
if (record2.status === "running") return jobHandle(id, "running", true);
|
|
34257
|
+
if (record2.status !== "done" || !record2.result) return void 0;
|
|
34258
|
+
return annotateReused(await refreshMedia(record2.result, this.resigner), id);
|
|
34259
|
+
}
|
|
34028
34260
|
/**
|
|
34029
34261
|
* Retrieve an async job by id (backs the `gemini_get_result` tool):
|
|
34030
34262
|
* `running` → a status handle; `done` → the recorded result payload;
|
|
@@ -34034,21 +34266,52 @@ var JobRegistry = class {
|
|
|
34034
34266
|
* the unknown-id path — the poll tool cannot be used to read another user's
|
|
34035
34267
|
* result even if they know the uuid.
|
|
34036
34268
|
*/
|
|
34037
|
-
getResult(jobId) {
|
|
34269
|
+
async getResult(jobId) {
|
|
34038
34270
|
const entry = this.jobs.get(jobId);
|
|
34039
34271
|
if (!entry) {
|
|
34040
|
-
|
|
34041
|
-
|
|
34042
|
-
|
|
34272
|
+
const durable = this.store ? await this.store.get(jobId) : void 0;
|
|
34273
|
+
if (durable) return this.fromRecord(durable);
|
|
34274
|
+
throw new McpToolError(
|
|
34275
|
+
this.store ? `No job "${jobId}" \u2014 no record of it exists. Either the id is wrong, or the job is older than the ${JOB_RECORD_RETENTION_LABEL} job records are kept.` : `No job "${jobId}" \u2014 unknown or expired.`,
|
|
34276
|
+
{
|
|
34277
|
+
hint: this.store ? "Job records are stored durably here, so a restart alone does not lose one \u2014 an id with no record was never started under this account. Images from a completed run are listed by gemini_list_recent_media." : "Jobs live with your session and are evicted ~10 min after completion (or on server restart). If the generation likely finished, check the output dir / <image>.json sidecar instead of polling."
|
|
34278
|
+
}
|
|
34279
|
+
);
|
|
34043
34280
|
}
|
|
34044
|
-
if (entry.status === "running") return jobHandle(jobId, "running");
|
|
34281
|
+
if (entry.status === "running") return jobHandle(jobId, "running", this.store !== void 0);
|
|
34045
34282
|
if (entry.status === "failed") {
|
|
34046
34283
|
throw new McpToolError(entry.error?.message ?? "Job failed.", entry.error?.hint ? { hint: entry.error.hint } : void 0);
|
|
34047
34284
|
}
|
|
34048
34285
|
if (!entry.result) throw new McpToolError(`Job "${jobId}" completed without a recorded result.`);
|
|
34049
34286
|
return entry.result;
|
|
34050
34287
|
}
|
|
34288
|
+
/**
|
|
34289
|
+
* Render a durable record as a poll answer — the path taken when the child
|
|
34290
|
+
* that ran the job is gone.
|
|
34291
|
+
*
|
|
34292
|
+
* The three outcomes are kept distinct on purpose. Collapsing "your job
|
|
34293
|
+
* failed", "your job was killed" and "no such job" into one message is what
|
|
34294
|
+
* made the original bug read as an expiry problem when it was a machine
|
|
34295
|
+
* lifecycle problem.
|
|
34296
|
+
*/
|
|
34297
|
+
async fromRecord(record2) {
|
|
34298
|
+
if (record2.status === "running") return jobHandle(record2.jobId, "running", true);
|
|
34299
|
+
if (record2.status === "failed") {
|
|
34300
|
+
throw new McpToolError(record2.error?.message ?? "Job failed.", record2.error?.hint ? { hint: record2.error.hint } : void 0);
|
|
34301
|
+
}
|
|
34302
|
+
if (record2.resultOmitted) {
|
|
34303
|
+
throw new McpToolError(
|
|
34304
|
+
record2.resultOmitted === "inline" ? `Job "${record2.jobId}" finished, but its result was returned inline (base64 image data) and inline results are not stored, so there is nothing to replay. Re-run without \`inline: true\` so the media is stored and returned as URLs, which a poll can replay.` : `Job "${record2.jobId}" finished, but its result was too large to store (over ${Math.round(MAX_PERSISTED_RESULT_BYTES / 1024)} KB), so there is nothing to replay.`,
|
|
34305
|
+
{
|
|
34306
|
+
hint: "The generation itself completed \u2014 list what it produced with gemini_list_recent_media rather than paying for it again."
|
|
34307
|
+
}
|
|
34308
|
+
);
|
|
34309
|
+
}
|
|
34310
|
+
if (!record2.result) throw new McpToolError(`Job "${record2.jobId}" completed without a recorded result.`);
|
|
34311
|
+
return refreshMedia(record2.result, this.resigner);
|
|
34312
|
+
}
|
|
34051
34313
|
};
|
|
34314
|
+
var JOB_RECORD_RETENTION_LABEL = "30 days";
|
|
34052
34315
|
|
|
34053
34316
|
// src/tools/_confirm.ts
|
|
34054
34317
|
init_dist();
|
|
@@ -34504,20 +34767,24 @@ function createR2Library(bucket, opts) {
|
|
|
34504
34767
|
};
|
|
34505
34768
|
}
|
|
34506
34769
|
|
|
34770
|
+
// src/media-url.ts
|
|
34771
|
+
var MEDIA_URL_TTL_MS = 48 * 60 * 60 * 1e3;
|
|
34772
|
+
|
|
34507
34773
|
// src/upload-url.ts
|
|
34508
|
-
init_media_url();
|
|
34509
34774
|
var UPLOAD_URL_TTL_MS = 10 * 60 * 1e3;
|
|
34510
34775
|
var UPLOAD_MAX_BYTES = 15 * 1024 * 1024;
|
|
34511
34776
|
var UPLOAD_KEY_PREFIX = "up";
|
|
34512
|
-
function buildUploadUrl(baseUrl, key, contentType, expiresAtMs2, signature) {
|
|
34513
|
-
const path = key.split("/").map(encodeURIComponent).join("/");
|
|
34514
|
-
return `${baseUrl.replace(/\/+$/, "")}/${path}?ct=${encodeURIComponent(contentType.toLowerCase())}&exp=${expiresAtMs2}&sig=${signature}`;
|
|
34515
|
-
}
|
|
34516
34777
|
var RASTER_IMAGE_TYPE_PATTERN = /^image\/(jpeg|png|webp|gif|avif|heic|heif|bmp|tiff)$/i;
|
|
34517
34778
|
function acceptableUploadType(contentType) {
|
|
34518
34779
|
return RASTER_IMAGE_TYPE_PATTERN.test(contentType);
|
|
34519
34780
|
}
|
|
34520
34781
|
function createUploadUrlMinter(opts) {
|
|
34782
|
+
const links = opts.links ?? (opts.baseUrl ? signedLinks(opts.baseUrl) : void 0);
|
|
34783
|
+
if (!links) {
|
|
34784
|
+
throw new Error(
|
|
34785
|
+
"createUploadUrlMinter requires `links` (preferred) or `baseUrl`: there is nowhere to point a signed upload URL. Hosted, both come from the blob store \u2014 check MCP_BLOB_BASE_URL is set on the deployment."
|
|
34786
|
+
);
|
|
34787
|
+
}
|
|
34521
34788
|
const now = opts.now ?? (() => /* @__PURE__ */ new Date());
|
|
34522
34789
|
const randomId = opts.randomId ?? (() => crypto.randomUUID().slice(0, 8));
|
|
34523
34790
|
const ttlMs = opts.ttlMs ?? UPLOAD_URL_TTL_MS;
|
|
@@ -34534,7 +34801,7 @@ function createUploadUrlMinter(opts) {
|
|
|
34534
34801
|
const key = `${UPLOAD_KEY_PREFIX}/${tenant}/${day}/${randomId()}-${safeKeySegment(filename)}`;
|
|
34535
34802
|
const expiresAtMs2 = now().getTime() + ttlMs;
|
|
34536
34803
|
const signature = await opts.sign(key, ct, expiresAtMs2);
|
|
34537
|
-
return { url:
|
|
34804
|
+
return { url: links.upload(key, ct, expiresAtMs2, signature), key, contentType: ct, expiresAtMs: expiresAtMs2 };
|
|
34538
34805
|
}
|
|
34539
34806
|
};
|
|
34540
34807
|
}
|
|
@@ -34551,7 +34818,7 @@ var DEFAULT_TTL_MS = 60 * 60 * 1e3;
|
|
|
34551
34818
|
function base64url3(bytes) {
|
|
34552
34819
|
return Buffer.from(bytes).toString("base64url");
|
|
34553
34820
|
}
|
|
34554
|
-
async function hmac(secret,
|
|
34821
|
+
async function hmac(secret, payload) {
|
|
34555
34822
|
const key = await crypto.subtle.importKey(
|
|
34556
34823
|
"raw",
|
|
34557
34824
|
new TextEncoder().encode(secret),
|
|
@@ -34559,10 +34826,18 @@ async function hmac(secret, payload2) {
|
|
|
34559
34826
|
false,
|
|
34560
34827
|
["sign"]
|
|
34561
34828
|
);
|
|
34562
|
-
return base64url3(await crypto.subtle.sign("HMAC", key, new TextEncoder().encode(
|
|
34829
|
+
return base64url3(await crypto.subtle.sign("HMAC", key, new TextEncoder().encode(payload)));
|
|
34563
34830
|
}
|
|
34564
34831
|
function prefixFromBaseUrl(baseUrl) {
|
|
34565
|
-
|
|
34832
|
+
let parsed;
|
|
34833
|
+
try {
|
|
34834
|
+
parsed = new URL(baseUrl);
|
|
34835
|
+
} catch {
|
|
34836
|
+
throw new Error(
|
|
34837
|
+
`MCP_BLOB_BASE_URL is not a valid URL (got ${JSON.stringify(baseUrl)}). It should look like https://<host>/b/<registrationId> \u2014 check the deployment's environment.`
|
|
34838
|
+
);
|
|
34839
|
+
}
|
|
34840
|
+
const path = parsed.pathname.replace(/^\/+|\/+$/g, "");
|
|
34566
34841
|
const marker = path.startsWith("b/") ? path.slice(2) : path;
|
|
34567
34842
|
return marker;
|
|
34568
34843
|
}
|
|
@@ -34574,8 +34849,8 @@ function createBlobBucket(opts) {
|
|
|
34574
34849
|
const now = opts.now ?? (() => Date.now());
|
|
34575
34850
|
const full = (key) => `${prefix}/${key}`;
|
|
34576
34851
|
const encode3 = (key) => key.split("/").map(encodeURIComponent).join("/");
|
|
34577
|
-
async function signedUrl(key,
|
|
34578
|
-
const sig = await hmac(opts.signingKey,
|
|
34852
|
+
async function signedUrl(key, payload, exp) {
|
|
34853
|
+
const sig = await hmac(opts.signingKey, payload);
|
|
34579
34854
|
return `${base}/${encode3(key)}?exp=${exp}&sig=${encodeURIComponent(sig)}`;
|
|
34580
34855
|
}
|
|
34581
34856
|
return {
|
|
@@ -34590,8 +34865,8 @@ function createBlobBucket(opts) {
|
|
|
34590
34865
|
const contentType = options?.httpMetadata?.contentType ?? "application/octet-stream";
|
|
34591
34866
|
const exp = now() + ttl;
|
|
34592
34867
|
const permanent = key.startsWith(`${PERMANENT_PREFIX}/`);
|
|
34593
|
-
const
|
|
34594
|
-
const url2 = await signedUrl(key,
|
|
34868
|
+
const payload = permanent ? WRITE_PERMANENT(full(key), contentType, exp) : WRITE(full(key), contentType, exp);
|
|
34869
|
+
const url2 = await signedUrl(key, payload, exp) + (permanent ? "&retain=permanent" : "");
|
|
34595
34870
|
const body = typeof value === "string" ? value : toArrayBuffer(value);
|
|
34596
34871
|
const res = await doFetch(url2, { method: "PUT", headers: { "content-type": contentType }, body });
|
|
34597
34872
|
if (!res.ok) throw new Error(`blob put failed (${res.status}) for ${key}`);
|
|
@@ -34643,7 +34918,7 @@ function blobStoreFromEnv(env = process.env, overrides = {}) {
|
|
|
34643
34918
|
const signingKey = overrides.signingKey ?? env.MCP_BLOB_SIGNING_KEY;
|
|
34644
34919
|
if (!baseUrl || !signingKey) return void 0;
|
|
34645
34920
|
const bucket = createBlobBucket({ ...overrides, baseUrl, signingKey });
|
|
34646
|
-
return { bucket, baseUrl, signRead: bucket.signRead, signWrite: bucket.signWrite };
|
|
34921
|
+
return { bucket, baseUrl, links: signedLinks(baseUrl), signRead: bucket.signRead, signWrite: bucket.signWrite };
|
|
34647
34922
|
}
|
|
34648
34923
|
|
|
34649
34924
|
// src/session.ts
|
|
@@ -34806,6 +35081,8 @@ var GeminiClient = class {
|
|
|
34806
35081
|
this.library = opts.library;
|
|
34807
35082
|
this.uploadUrls = opts.uploadUrls;
|
|
34808
35083
|
this.session.jobs.resigner = this.mediaSink;
|
|
35084
|
+
this.session.jobs.store = opts.jobStore;
|
|
35085
|
+
if (opts.jobStore) this.session.jobs.asyncWaitFallbackMs = HOSTED_ASYNC_WAIT_MS;
|
|
34809
35086
|
this.explicitApiKey = opts.apiKey?.trim() || void 0;
|
|
34810
35087
|
this.fetchImpl = opts.fetchImpl ?? ((...args) => fetch(...args));
|
|
34811
35088
|
this.sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
@@ -35275,19 +35552,19 @@ var GeminiClient = class {
|
|
|
35275
35552
|
const textParts = [];
|
|
35276
35553
|
const searchQueries = [];
|
|
35277
35554
|
const searchSuggestions = /* @__PURE__ */ new Set();
|
|
35278
|
-
for (const
|
|
35279
|
-
if (
|
|
35280
|
-
for (const q of
|
|
35555
|
+
for (const step2 of data.steps ?? []) {
|
|
35556
|
+
if (step2.type === "google_search_call") {
|
|
35557
|
+
for (const q of step2.arguments?.queries ?? []) if (q?.trim()) searchQueries.push(q);
|
|
35281
35558
|
continue;
|
|
35282
35559
|
}
|
|
35283
|
-
if (
|
|
35560
|
+
if (step2.type === "google_search_result") {
|
|
35284
35561
|
if (searchTypes?.includes("image_search")) {
|
|
35285
|
-
for (const r of
|
|
35562
|
+
for (const r of step2.result ?? []) if (r.search_suggestions?.trim()) searchSuggestions.add(r.search_suggestions);
|
|
35286
35563
|
}
|
|
35287
35564
|
continue;
|
|
35288
35565
|
}
|
|
35289
|
-
if (
|
|
35290
|
-
for (const parts of [
|
|
35566
|
+
if (step2.type !== "model_output") continue;
|
|
35567
|
+
for (const parts of [step2.content ?? [], step2.summary ?? []]) {
|
|
35291
35568
|
for (const part of parts) {
|
|
35292
35569
|
const mime = part.mime_type ?? part.mimeType;
|
|
35293
35570
|
if (part.data) {
|
|
@@ -35315,7 +35592,11 @@ function hostedStorage() {
|
|
|
35315
35592
|
const tenant = () => tenantIdFor(readEnvVar("GEMINI_API_KEY") ?? "local");
|
|
35316
35593
|
return {
|
|
35317
35594
|
mediaSink: createR2Sink(blob.bucket, {
|
|
35318
|
-
|
|
35595
|
+
// The SAME `links` object the minter gets below. Media GETs and upload
|
|
35596
|
+
// PUTs are one store reached two ways; handing each its own base URL is
|
|
35597
|
+
// how the re-host moved the media links to /b/<registrationId>/ and left
|
|
35598
|
+
// the upload links behind. One object, two shapes, no second edit.
|
|
35599
|
+
links: blob.links,
|
|
35319
35600
|
sign: blob.signRead,
|
|
35320
35601
|
urlTtlMs: BLOB_URL_TTL_MS,
|
|
35321
35602
|
// Hard ceiling on any PER-PERSIST override. `gemini_image_set` asks for
|
|
@@ -35331,9 +35612,14 @@ function hostedStorage() {
|
|
|
35331
35612
|
tenant
|
|
35332
35613
|
}),
|
|
35333
35614
|
library: createR2Library(blob.bucket, { tenant }),
|
|
35334
|
-
uploadUrls: createUploadUrlMinter({
|
|
35615
|
+
uploadUrls: createUploadUrlMinter({ links: blob.links, sign: blob.signWrite, tenant }),
|
|
35616
|
+
// Job records go in the same store as the media, for the same reason: this
|
|
35617
|
+
// runtime's machine stops whenever no request is in flight, taking the
|
|
35618
|
+
// child — and an in-memory registry — with it (src/job-store.ts).
|
|
35619
|
+
jobStore: createBlobJobStore(blob.bucket, { tenant })
|
|
35335
35620
|
};
|
|
35336
35621
|
}
|
|
35622
|
+
var HOSTED_ASYNC_WAIT_MS = 24e4;
|
|
35337
35623
|
var BLOB_URL_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
35338
35624
|
var BLOB_MAX_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
35339
35625
|
var client = new GeminiClient(hostedStorage());
|
|
@@ -35740,7 +36026,7 @@ function registerJobTools(server, client2) {
|
|
|
35740
36026
|
server.registerTool(
|
|
35741
36027
|
"gemini_get_result",
|
|
35742
36028
|
{
|
|
35743
|
-
description: 'Retrieve
|
|
36029
|
+
description: 'Retrieve a generation started with `async: true` or handed off by `max_wait_ms`. Pass the returned `job_id`: while running it reports status "running"; on completion it returns the normal result (image URLs/paths + meta); on failure it raises the recorded error, including the case where the generation was killed before it finished. On the hosted connector job records are stored durably and survive a restart; on a local stdio server they live with the process and expire ~10 min after completion, where the output dir / <image>.json sidecar is the fallback.',
|
|
35744
36030
|
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
35745
36031
|
inputSchema: {
|
|
35746
36032
|
job_id: external_exports.string().min(1).describe("The job_id returned by a generation tool called with async: true")
|
|
@@ -35920,6 +36206,43 @@ function registerFileTools(server, client2) {
|
|
|
35920
36206
|
});
|
|
35921
36207
|
}
|
|
35922
36208
|
);
|
|
36209
|
+
server.registerTool(
|
|
36210
|
+
"gemini_list_recent_media",
|
|
36211
|
+
{
|
|
36212
|
+
description: "List images/video/audio this connector recently generated for your account, newest first, with fresh openable URLs. Use it when a result was lost \u2014 a generation whose response never arrived, or an async job whose id came back unknown \u2014 to find what already exists BEFORE re-running (and re-paying for) it. Keywords: lost result, orphaned job, missing image, what did I generate, recover, recent media.",
|
|
36213
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
36214
|
+
inputSchema: {
|
|
36215
|
+
limit: external_exports.number().int().positive().max(100).optional().describe("How many to return (default 20, newest first)"),
|
|
36216
|
+
since_day: external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional().describe('Only media stored on or after this UTC day, e.g. "2026-08-18"')
|
|
36217
|
+
}
|
|
36218
|
+
},
|
|
36219
|
+
async (args) => {
|
|
36220
|
+
const sink = client2.mediaSink;
|
|
36221
|
+
if (!sink?.listRecent) {
|
|
36222
|
+
throw new McpToolError("This server writes generated files to disk \u2014 list the output directory instead.", {
|
|
36223
|
+
hint: "gemini_list_recent_media applies to the hosted connector only."
|
|
36224
|
+
});
|
|
36225
|
+
}
|
|
36226
|
+
const limit = args.limit ?? 20;
|
|
36227
|
+
const page = sink.listRecentPage ? await sink.listRecentPage({ limit, sinceDay: args.since_day }) : { media: await sink.listRecent({ limit, sinceDay: args.since_day }), truncated: false };
|
|
36228
|
+
const found = page.media;
|
|
36229
|
+
return textResult({
|
|
36230
|
+
count: found.length,
|
|
36231
|
+
// Never let a bounded walk pass for the whole picture: concluding an
|
|
36232
|
+
// image is gone is what makes someone pay to generate it twice.
|
|
36233
|
+
...page.truncated ? { truncated: true } : {},
|
|
36234
|
+
media: found.map((m) => ({
|
|
36235
|
+
r2_key: m.key,
|
|
36236
|
+
day: m.day,
|
|
36237
|
+
name: m.name,
|
|
36238
|
+
...m.sizeBytes !== void 0 ? { size_bytes: m.sizeBytes } : {},
|
|
36239
|
+
...m.url ? { url: m.url, curl_hint: `curl -sS -o ${downloadFilename(m.key)} "${m.url}"` } : {},
|
|
36240
|
+
...m.expiresAt ? { expires_at: m.expiresAt } : {}
|
|
36241
|
+
})),
|
|
36242
|
+
hint: found.length ? "Ordered by the day each object was stored (the store keeps no finer timestamp), newest first. Re-sign any expired link with gemini_sign_media." + (page.truncated ? " More media exists than is listed here \u2014 narrow with since_day, or raise limit, before concluding something is missing." : "") : "Nothing stored in that window. Media is swept on a retention schedule, so an older generation may already be gone."
|
|
36243
|
+
});
|
|
36244
|
+
}
|
|
36245
|
+
);
|
|
35923
36246
|
}
|
|
35924
36247
|
server.registerTool(
|
|
35925
36248
|
"gemini_delete_file",
|
|
@@ -35949,7 +36272,7 @@ function registerUploadUrlTools(server, client2) {
|
|
|
35949
36272
|
server.registerTool(
|
|
35950
36273
|
"gemini_get_upload_url",
|
|
35951
36274
|
{
|
|
35952
|
-
description: `Mint a short-lived (~10 min) signed PUT URL for uploading one reference image to this connector with NO auth headers \u2014 usable from any shell: curl -sS -X PUT -H "Content-Type: image/jpeg" --data-binary @photo.jpg "<upload_url>".
|
|
36275
|
+
description: `Mint a short-lived (~10 min) signed PUT URL for uploading one reference image to this connector with NO auth headers \u2014 usable from any shell: curl -sS -X PUT -H "Content-Type: image/jpeg" --data-binary @photo.jpg "<upload_url>". A 2xx from that PUT means the bytes are stored; the key to reference them is the \`r2_key\` in THIS result (the PUT itself returns no useful body). Pass that r2_key in \`images_r2_keys\` on generation tools, save it permanently with gemini_save_character, or convert it to a ~48h Files API reference with gemini_upload_file({ r2_key }). Prefer this over images_base64 (which costs ~14k tokens per photo) whenever the caller has a shell. Images only, up to ${wholeMb(UPLOAD_MAX_BYTES)}MB. The PUT must send exactly the Content-Type this URL was minted for \u2014 the signature covers it, so a mismatched header is rejected.`,
|
|
35953
36276
|
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
35954
36277
|
inputSchema: {
|
|
35955
36278
|
filename: external_exports.string().min(1).max(120).describe('Filename of the upload (e.g. "finn.jpg") \u2014 sanitized into the object key and the suggested curl command'),
|
|
@@ -35957,12 +36280,10 @@ function registerUploadUrlTools(server, client2) {
|
|
|
35957
36280
|
}
|
|
35958
36281
|
},
|
|
35959
36282
|
async (args) => {
|
|
35960
|
-
|
|
35961
|
-
|
|
35962
|
-
|
|
35963
|
-
|
|
35964
|
-
throw new McpToolError(err instanceof Error ? err.message : String(err));
|
|
35965
|
-
}
|
|
36283
|
+
const minted = await step(
|
|
36284
|
+
`minting a signed upload URL for ${args.filename} (${args.content_type})`,
|
|
36285
|
+
() => minter.mint(args.filename, args.content_type)
|
|
36286
|
+
);
|
|
35966
36287
|
return textResult({
|
|
35967
36288
|
upload_url: minted.url,
|
|
35968
36289
|
method: "PUT",
|
|
@@ -35971,7 +36292,10 @@ function registerUploadUrlTools(server, client2) {
|
|
|
35971
36292
|
expires_at: new Date(minted.expiresAtMs).toISOString(),
|
|
35972
36293
|
max_bytes: UPLOAD_MAX_BYTES,
|
|
35973
36294
|
curl_hint: `curl -sS -X PUT -H "Content-Type: ${minted.contentType}" --data-binary @${args.filename} "${minted.url}"`,
|
|
35974
|
-
|
|
36295
|
+
// Named for what it is: the PUT's own body is the object store's, not
|
|
36296
|
+
// this connector's, so 2xx is the whole success signal.
|
|
36297
|
+
success_is: "any 2xx from the PUT; the response body is not part of the contract and carries no r2_key",
|
|
36298
|
+
hint: "PUT the raw bytes within ~10 minutes with exactly the Content-Type above; no Authorization header is needed (the signature in the URL is the auth, and it covers the content type). On a 2xx, reference the `r2_key` from THIS result \u2014 not the PUT response: images_r2_keys on generation tools (master_images_r2_keys on gemini_image_set), gemini_save_character to keep it with no expiry, or gemini_upload_file({ r2_key }) for a ~48h files/\u2026 reference. Uploads themselves follow the media retention schedule (default 7 days)."
|
|
35975
36299
|
});
|
|
35976
36300
|
}
|
|
35977
36301
|
);
|
|
@@ -36152,26 +36476,27 @@ function registerLibraryTools(server, client2) {
|
|
|
36152
36476
|
);
|
|
36153
36477
|
}
|
|
36154
36478
|
|
|
36479
|
+
// src/registrars.ts
|
|
36480
|
+
var reporting = (register) => (server, deps) => register(surfaceToolErrors(server), deps);
|
|
36481
|
+
var TOOL_REGISTRARS = [
|
|
36482
|
+
registerModelTools,
|
|
36483
|
+
registerGenerateTools,
|
|
36484
|
+
registerSetTools,
|
|
36485
|
+
registerInteractTools,
|
|
36486
|
+
registerVideoTools,
|
|
36487
|
+
registerMusicTools,
|
|
36488
|
+
registerJobTools,
|
|
36489
|
+
registerFileTools,
|
|
36490
|
+
registerUploadUrlTools,
|
|
36491
|
+
registerLibraryTools
|
|
36492
|
+
].map(reporting);
|
|
36493
|
+
|
|
36155
36494
|
// src/index.ts
|
|
36156
36495
|
await loadStdioDotenv();
|
|
36157
36496
|
await runMcp({
|
|
36158
36497
|
name: "gemini-mcp",
|
|
36159
36498
|
version: VERSION,
|
|
36160
36499
|
banner: "[gemini-mcp] This project was developed and is maintained by AI (Claude). Use at your own discretion.",
|
|
36161
|
-
tools:
|
|
36162
|
-
registerModelTools,
|
|
36163
|
-
registerGenerateTools,
|
|
36164
|
-
registerSetTools,
|
|
36165
|
-
registerInteractTools,
|
|
36166
|
-
registerVideoTools,
|
|
36167
|
-
registerMusicTools,
|
|
36168
|
-
registerJobTools,
|
|
36169
|
-
registerFileTools,
|
|
36170
|
-
// Both gate on the client having somewhere to put bytes: hosted with a
|
|
36171
|
-
// blob store they register, and on a local install they no-op rather than
|
|
36172
|
-
// advertising a tool that cannot work.
|
|
36173
|
-
registerUploadUrlTools,
|
|
36174
|
-
registerLibraryTools
|
|
36175
|
-
],
|
|
36500
|
+
tools: TOOL_REGISTRARS,
|
|
36176
36501
|
deps: client
|
|
36177
36502
|
});
|