@marlinjai/email-mcp 1.3.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/dist/index.js +907 -573
- package/dist/index.js.map +4 -4
- package/dist/setup/wizard.js +315 -127
- package/dist/setup/wizard.js.map +3 -3
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -3197,27 +3197,27 @@ var require_utils = __commonJS({
|
|
|
3197
3197
|
"use strict";
|
|
3198
3198
|
var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
3199
3199
|
var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
3200
|
-
function stringArrayToHexStripped(
|
|
3200
|
+
function stringArrayToHexStripped(input2) {
|
|
3201
3201
|
let acc = "";
|
|
3202
3202
|
let code = 0;
|
|
3203
3203
|
let i = 0;
|
|
3204
|
-
for (i = 0; i <
|
|
3205
|
-
code =
|
|
3204
|
+
for (i = 0; i < input2.length; i++) {
|
|
3205
|
+
code = input2[i].charCodeAt(0);
|
|
3206
3206
|
if (code === 48) {
|
|
3207
3207
|
continue;
|
|
3208
3208
|
}
|
|
3209
3209
|
if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) {
|
|
3210
3210
|
return "";
|
|
3211
3211
|
}
|
|
3212
|
-
acc +=
|
|
3212
|
+
acc += input2[i];
|
|
3213
3213
|
break;
|
|
3214
3214
|
}
|
|
3215
|
-
for (i += 1; i <
|
|
3216
|
-
code =
|
|
3215
|
+
for (i += 1; i < input2.length; i++) {
|
|
3216
|
+
code = input2[i].charCodeAt(0);
|
|
3217
3217
|
if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) {
|
|
3218
3218
|
return "";
|
|
3219
3219
|
}
|
|
3220
|
-
acc +=
|
|
3220
|
+
acc += input2[i];
|
|
3221
3221
|
}
|
|
3222
3222
|
return acc;
|
|
3223
3223
|
}
|
|
@@ -3226,29 +3226,29 @@ var require_utils = __commonJS({
|
|
|
3226
3226
|
buffer.length = 0;
|
|
3227
3227
|
return true;
|
|
3228
3228
|
}
|
|
3229
|
-
function consumeHextets(buffer, address,
|
|
3229
|
+
function consumeHextets(buffer, address, output2) {
|
|
3230
3230
|
if (buffer.length) {
|
|
3231
3231
|
const hex3 = stringArrayToHexStripped(buffer);
|
|
3232
3232
|
if (hex3 !== "") {
|
|
3233
3233
|
address.push(hex3);
|
|
3234
3234
|
} else {
|
|
3235
|
-
|
|
3235
|
+
output2.error = true;
|
|
3236
3236
|
return false;
|
|
3237
3237
|
}
|
|
3238
3238
|
buffer.length = 0;
|
|
3239
3239
|
}
|
|
3240
3240
|
return true;
|
|
3241
3241
|
}
|
|
3242
|
-
function getIPV6(
|
|
3242
|
+
function getIPV6(input2) {
|
|
3243
3243
|
let tokenCount = 0;
|
|
3244
|
-
const
|
|
3244
|
+
const output2 = { error: false, address: "", zone: "" };
|
|
3245
3245
|
const address = [];
|
|
3246
3246
|
const buffer = [];
|
|
3247
3247
|
let endipv6Encountered = false;
|
|
3248
3248
|
let endIpv6 = false;
|
|
3249
3249
|
let consume = consumeHextets;
|
|
3250
|
-
for (let i = 0; i <
|
|
3251
|
-
const cursor =
|
|
3250
|
+
for (let i = 0; i < input2.length; i++) {
|
|
3251
|
+
const cursor = input2[i];
|
|
3252
3252
|
if (cursor === "[" || cursor === "]") {
|
|
3253
3253
|
continue;
|
|
3254
3254
|
}
|
|
@@ -3256,20 +3256,20 @@ var require_utils = __commonJS({
|
|
|
3256
3256
|
if (endipv6Encountered === true) {
|
|
3257
3257
|
endIpv6 = true;
|
|
3258
3258
|
}
|
|
3259
|
-
if (!consume(buffer, address,
|
|
3259
|
+
if (!consume(buffer, address, output2)) {
|
|
3260
3260
|
break;
|
|
3261
3261
|
}
|
|
3262
3262
|
if (++tokenCount > 7) {
|
|
3263
|
-
|
|
3263
|
+
output2.error = true;
|
|
3264
3264
|
break;
|
|
3265
3265
|
}
|
|
3266
|
-
if (i > 0 &&
|
|
3266
|
+
if (i > 0 && input2[i - 1] === ":") {
|
|
3267
3267
|
endipv6Encountered = true;
|
|
3268
3268
|
}
|
|
3269
3269
|
address.push(":");
|
|
3270
3270
|
continue;
|
|
3271
3271
|
} else if (cursor === "%") {
|
|
3272
|
-
if (!consume(buffer, address,
|
|
3272
|
+
if (!consume(buffer, address, output2)) {
|
|
3273
3273
|
break;
|
|
3274
3274
|
}
|
|
3275
3275
|
consume = consumeIsZone;
|
|
@@ -3280,15 +3280,15 @@ var require_utils = __commonJS({
|
|
|
3280
3280
|
}
|
|
3281
3281
|
if (buffer.length) {
|
|
3282
3282
|
if (consume === consumeIsZone) {
|
|
3283
|
-
|
|
3283
|
+
output2.zone = buffer.join("");
|
|
3284
3284
|
} else if (endIpv6) {
|
|
3285
3285
|
address.push(buffer.join(""));
|
|
3286
3286
|
} else {
|
|
3287
3287
|
address.push(stringArrayToHexStripped(buffer));
|
|
3288
3288
|
}
|
|
3289
3289
|
}
|
|
3290
|
-
|
|
3291
|
-
return
|
|
3290
|
+
output2.address = address.join("");
|
|
3291
|
+
return output2;
|
|
3292
3292
|
}
|
|
3293
3293
|
function normalizeIPv6(host) {
|
|
3294
3294
|
if (findToken(host, ":") < 2) {
|
|
@@ -3315,79 +3315,79 @@ var require_utils = __commonJS({
|
|
|
3315
3315
|
return ind;
|
|
3316
3316
|
}
|
|
3317
3317
|
function removeDotSegments(path3) {
|
|
3318
|
-
let
|
|
3319
|
-
const
|
|
3318
|
+
let input2 = path3;
|
|
3319
|
+
const output2 = [];
|
|
3320
3320
|
let nextSlash = -1;
|
|
3321
3321
|
let len = 0;
|
|
3322
|
-
while (len =
|
|
3322
|
+
while (len = input2.length) {
|
|
3323
3323
|
if (len === 1) {
|
|
3324
|
-
if (
|
|
3324
|
+
if (input2 === ".") {
|
|
3325
3325
|
break;
|
|
3326
|
-
} else if (
|
|
3327
|
-
|
|
3326
|
+
} else if (input2 === "/") {
|
|
3327
|
+
output2.push("/");
|
|
3328
3328
|
break;
|
|
3329
3329
|
} else {
|
|
3330
|
-
|
|
3330
|
+
output2.push(input2);
|
|
3331
3331
|
break;
|
|
3332
3332
|
}
|
|
3333
3333
|
} else if (len === 2) {
|
|
3334
|
-
if (
|
|
3335
|
-
if (
|
|
3334
|
+
if (input2[0] === ".") {
|
|
3335
|
+
if (input2[1] === ".") {
|
|
3336
3336
|
break;
|
|
3337
|
-
} else if (
|
|
3338
|
-
|
|
3337
|
+
} else if (input2[1] === "/") {
|
|
3338
|
+
input2 = input2.slice(2);
|
|
3339
3339
|
continue;
|
|
3340
3340
|
}
|
|
3341
|
-
} else if (
|
|
3342
|
-
if (
|
|
3343
|
-
|
|
3341
|
+
} else if (input2[0] === "/") {
|
|
3342
|
+
if (input2[1] === "." || input2[1] === "/") {
|
|
3343
|
+
output2.push("/");
|
|
3344
3344
|
break;
|
|
3345
3345
|
}
|
|
3346
3346
|
}
|
|
3347
3347
|
} else if (len === 3) {
|
|
3348
|
-
if (
|
|
3349
|
-
if (
|
|
3350
|
-
|
|
3348
|
+
if (input2 === "/..") {
|
|
3349
|
+
if (output2.length !== 0) {
|
|
3350
|
+
output2.pop();
|
|
3351
3351
|
}
|
|
3352
|
-
|
|
3352
|
+
output2.push("/");
|
|
3353
3353
|
break;
|
|
3354
3354
|
}
|
|
3355
3355
|
}
|
|
3356
|
-
if (
|
|
3357
|
-
if (
|
|
3358
|
-
if (
|
|
3359
|
-
|
|
3356
|
+
if (input2[0] === ".") {
|
|
3357
|
+
if (input2[1] === ".") {
|
|
3358
|
+
if (input2[2] === "/") {
|
|
3359
|
+
input2 = input2.slice(3);
|
|
3360
3360
|
continue;
|
|
3361
3361
|
}
|
|
3362
|
-
} else if (
|
|
3363
|
-
|
|
3362
|
+
} else if (input2[1] === "/") {
|
|
3363
|
+
input2 = input2.slice(2);
|
|
3364
3364
|
continue;
|
|
3365
3365
|
}
|
|
3366
|
-
} else if (
|
|
3367
|
-
if (
|
|
3368
|
-
if (
|
|
3369
|
-
|
|
3366
|
+
} else if (input2[0] === "/") {
|
|
3367
|
+
if (input2[1] === ".") {
|
|
3368
|
+
if (input2[2] === "/") {
|
|
3369
|
+
input2 = input2.slice(2);
|
|
3370
3370
|
continue;
|
|
3371
|
-
} else if (
|
|
3372
|
-
if (
|
|
3373
|
-
|
|
3374
|
-
if (
|
|
3375
|
-
|
|
3371
|
+
} else if (input2[2] === ".") {
|
|
3372
|
+
if (input2[3] === "/") {
|
|
3373
|
+
input2 = input2.slice(3);
|
|
3374
|
+
if (output2.length !== 0) {
|
|
3375
|
+
output2.pop();
|
|
3376
3376
|
}
|
|
3377
3377
|
continue;
|
|
3378
3378
|
}
|
|
3379
3379
|
}
|
|
3380
3380
|
}
|
|
3381
3381
|
}
|
|
3382
|
-
if ((nextSlash =
|
|
3383
|
-
|
|
3382
|
+
if ((nextSlash = input2.indexOf("/", 1)) === -1) {
|
|
3383
|
+
output2.push(input2);
|
|
3384
3384
|
break;
|
|
3385
3385
|
} else {
|
|
3386
|
-
|
|
3387
|
-
|
|
3386
|
+
output2.push(input2.slice(0, nextSlash));
|
|
3387
|
+
input2 = input2.slice(nextSlash);
|
|
3388
3388
|
}
|
|
3389
3389
|
}
|
|
3390
|
-
return
|
|
3390
|
+
return output2.join("");
|
|
3391
3391
|
}
|
|
3392
3392
|
function normalizeComponentEncoding(component, esc2) {
|
|
3393
3393
|
const func = esc2 !== true ? escape : unescape;
|
|
@@ -7463,6 +7463,74 @@ var init_adapter = __esm({
|
|
|
7463
7463
|
messageCount: label.messagesTotal ?? 0
|
|
7464
7464
|
}));
|
|
7465
7465
|
}
|
|
7466
|
+
/**
|
|
7467
|
+
* Trains Gmail's own spam filter — the same signal the "Report spam" UI
|
|
7468
|
+
* button sends (add SPAM, drop INBOX). Not an abuse report to Google.
|
|
7469
|
+
*/
|
|
7470
|
+
async reportSpam(emailId, _sourceFolder) {
|
|
7471
|
+
const gmail = this.ensureConnected();
|
|
7472
|
+
await gmail.users.messages.modify({
|
|
7473
|
+
userId: "me",
|
|
7474
|
+
id: emailId,
|
|
7475
|
+
requestBody: { addLabelIds: ["SPAM"], removeLabelIds: ["INBOX"] }
|
|
7476
|
+
});
|
|
7477
|
+
}
|
|
7478
|
+
async createBlockRule(rule) {
|
|
7479
|
+
const gmail = this.ensureConnected();
|
|
7480
|
+
const criteria = {};
|
|
7481
|
+
switch (rule.matchType) {
|
|
7482
|
+
case "senderDomain":
|
|
7483
|
+
criteria.from = `@${rule.value}`;
|
|
7484
|
+
break;
|
|
7485
|
+
case "senderAddress":
|
|
7486
|
+
criteria.from = rule.value;
|
|
7487
|
+
break;
|
|
7488
|
+
case "subjectContains":
|
|
7489
|
+
criteria.subject = rule.value;
|
|
7490
|
+
break;
|
|
7491
|
+
case "headerContains":
|
|
7492
|
+
criteria.query = rule.value;
|
|
7493
|
+
break;
|
|
7494
|
+
}
|
|
7495
|
+
const action = rule.action === "delete" ? { addLabelIds: ["TRASH"] } : { addLabelIds: ["SPAM"], removeLabelIds: ["INBOX"] };
|
|
7496
|
+
const res = await gmail.users.settings.filters.create({
|
|
7497
|
+
userId: "me",
|
|
7498
|
+
requestBody: { criteria, action }
|
|
7499
|
+
});
|
|
7500
|
+
return { id: res.data.id || "" };
|
|
7501
|
+
}
|
|
7502
|
+
async listBlockRules() {
|
|
7503
|
+
const gmail = this.ensureConnected();
|
|
7504
|
+
const res = await gmail.users.settings.filters.list({ userId: "me" });
|
|
7505
|
+
return (res.data.filter || []).map((f) => {
|
|
7506
|
+
const criteria = f.criteria || {};
|
|
7507
|
+
const addLabelIds = f.action?.addLabelIds || [];
|
|
7508
|
+
let matchType = "headerContains";
|
|
7509
|
+
let value = criteria.query || "";
|
|
7510
|
+
if (typeof criteria.from === "string" && criteria.from.startsWith("@")) {
|
|
7511
|
+
matchType = "senderDomain";
|
|
7512
|
+
value = criteria.from.slice(1);
|
|
7513
|
+
} else if (criteria.from) {
|
|
7514
|
+
matchType = "senderAddress";
|
|
7515
|
+
value = criteria.from;
|
|
7516
|
+
} else if (criteria.subject) {
|
|
7517
|
+
matchType = "subjectContains";
|
|
7518
|
+
value = criteria.subject;
|
|
7519
|
+
}
|
|
7520
|
+
return {
|
|
7521
|
+
id: f.id || "",
|
|
7522
|
+
matchType,
|
|
7523
|
+
value,
|
|
7524
|
+
action: addLabelIds.includes("TRASH") ? "delete" : "moveToJunk",
|
|
7525
|
+
createdAt: ""
|
|
7526
|
+
// Gmail's filter API does not expose a creation timestamp
|
|
7527
|
+
};
|
|
7528
|
+
});
|
|
7529
|
+
}
|
|
7530
|
+
async deleteBlockRule(ruleId) {
|
|
7531
|
+
const gmail = this.ensureConnected();
|
|
7532
|
+
await gmail.users.settings.filters.delete({ userId: "me", id: ruleId });
|
|
7533
|
+
}
|
|
7466
7534
|
buildRfc2822(params) {
|
|
7467
7535
|
const lines = [];
|
|
7468
7536
|
lines.push(`From: ${this.email}`);
|
|
@@ -8059,6 +8127,86 @@ var init_adapter2 = __esm({
|
|
|
8059
8127
|
}
|
|
8060
8128
|
return result;
|
|
8061
8129
|
}
|
|
8130
|
+
/**
|
|
8131
|
+
* Trains Outlook's own spam filter — the same signal "Report Junk" sends
|
|
8132
|
+
* in the UI (move to the Junk Email well-known folder). Not an abuse
|
|
8133
|
+
* report to Microsoft's security team.
|
|
8134
|
+
*/
|
|
8135
|
+
async reportSpam(emailId, _sourceFolder) {
|
|
8136
|
+
const client = this.ensureClient();
|
|
8137
|
+
await client.api(`/me/messages/${encodeURIComponent(emailId)}/move`).post({
|
|
8138
|
+
destinationId: "junkemail"
|
|
8139
|
+
});
|
|
8140
|
+
}
|
|
8141
|
+
/**
|
|
8142
|
+
* Requires the `MailboxSettings.ReadWrite` delegated scope, confirmed by
|
|
8143
|
+
* Microsoft's own docs to be supported for personal Microsoft accounts
|
|
8144
|
+
* (outlook.com/hotmail), not just work/school. Accounts authenticated
|
|
8145
|
+
* before this scope was added need to re-run the setup wizard to
|
|
8146
|
+
* re-consent — old tokens will 403 on this call until then.
|
|
8147
|
+
*/
|
|
8148
|
+
async createBlockRule(rule) {
|
|
8149
|
+
const client = this.ensureClient();
|
|
8150
|
+
const conditions = {};
|
|
8151
|
+
switch (rule.matchType) {
|
|
8152
|
+
case "senderDomain":
|
|
8153
|
+
case "senderAddress":
|
|
8154
|
+
conditions.senderContains = [rule.value];
|
|
8155
|
+
break;
|
|
8156
|
+
case "subjectContains":
|
|
8157
|
+
conditions.subjectContains = [rule.value];
|
|
8158
|
+
break;
|
|
8159
|
+
case "headerContains":
|
|
8160
|
+
conditions.headerContains = [rule.value];
|
|
8161
|
+
break;
|
|
8162
|
+
}
|
|
8163
|
+
const actions = { stopProcessingRules: true };
|
|
8164
|
+
if (rule.action === "delete") {
|
|
8165
|
+
actions.delete = true;
|
|
8166
|
+
} else {
|
|
8167
|
+
actions.moveToFolder = await this.resolveFolder("junkemail");
|
|
8168
|
+
}
|
|
8169
|
+
const existing = await this.listBlockRules();
|
|
8170
|
+
const result = await client.api("/me/mailFolders/inbox/messageRules").post({
|
|
8171
|
+
displayName: `email-mcp: ${rule.matchType} "${rule.value}"`.slice(0, 255),
|
|
8172
|
+
sequence: existing.length + 1,
|
|
8173
|
+
isEnabled: true,
|
|
8174
|
+
conditions,
|
|
8175
|
+
actions
|
|
8176
|
+
});
|
|
8177
|
+
return { id: result.id };
|
|
8178
|
+
}
|
|
8179
|
+
async listBlockRules() {
|
|
8180
|
+
const client = this.ensureClient();
|
|
8181
|
+
const response = await client.api("/me/mailFolders/inbox/messageRules").get();
|
|
8182
|
+
return (response.value || []).map((r) => {
|
|
8183
|
+
const conditions = r.conditions || {};
|
|
8184
|
+
let matchType = "headerContains";
|
|
8185
|
+
let value = "";
|
|
8186
|
+
if (conditions.senderContains?.length) {
|
|
8187
|
+
value = conditions.senderContains[0];
|
|
8188
|
+
matchType = value.includes("@") ? "senderAddress" : "senderDomain";
|
|
8189
|
+
} else if (conditions.subjectContains?.length) {
|
|
8190
|
+
matchType = "subjectContains";
|
|
8191
|
+
value = conditions.subjectContains[0];
|
|
8192
|
+
} else if (conditions.headerContains?.length) {
|
|
8193
|
+
matchType = "headerContains";
|
|
8194
|
+
value = conditions.headerContains[0];
|
|
8195
|
+
}
|
|
8196
|
+
return {
|
|
8197
|
+
id: r.id,
|
|
8198
|
+
matchType,
|
|
8199
|
+
value,
|
|
8200
|
+
action: r.actions?.delete ? "delete" : "moveToJunk",
|
|
8201
|
+
createdAt: ""
|
|
8202
|
+
// Graph's messageRule resource has no creation timestamp field
|
|
8203
|
+
};
|
|
8204
|
+
});
|
|
8205
|
+
}
|
|
8206
|
+
async deleteBlockRule(ruleId) {
|
|
8207
|
+
const client = this.ensureClient();
|
|
8208
|
+
await client.api(`/me/mailFolders/inbox/messageRules/${encodeURIComponent(ruleId)}`).delete();
|
|
8209
|
+
}
|
|
8062
8210
|
async getCategories() {
|
|
8063
8211
|
const client = this.ensureClient();
|
|
8064
8212
|
const response = await client.api("/me/outlook/masterCategories").get();
|
|
@@ -8122,7 +8270,10 @@ var init_auth2 = __esm({
|
|
|
8122
8270
|
DEFAULT_CACHE_FILE = path2.join(DEFAULT_CACHE_DIR, "msal-cache.json");
|
|
8123
8271
|
OutlookAuth = class _OutlookAuth {
|
|
8124
8272
|
static AUTHORITY = "https://login.microsoftonline.com/consumers";
|
|
8125
|
-
|
|
8273
|
+
// MailboxSettings.ReadWrite is required for the messageRules API (block
|
|
8274
|
+
// rules) — confirmed by Microsoft's own docs to be supported for personal
|
|
8275
|
+
// Microsoft accounts (not just work/school), not just Mail.ReadWrite/Send.
|
|
8276
|
+
static SCOPES = ["Mail.ReadWrite", "Mail.Send", "MailboxSettings.ReadWrite", "offline_access"];
|
|
8126
8277
|
pca;
|
|
8127
8278
|
cryptoProvider;
|
|
8128
8279
|
constructor(clientId, cacheFilePath) {
|
|
@@ -8745,6 +8896,30 @@ var init_adapter3 = __esm({
|
|
|
8745
8896
|
lock.release();
|
|
8746
8897
|
}
|
|
8747
8898
|
}
|
|
8899
|
+
/**
|
|
8900
|
+
* Best-effort only: generic IMAP has no server-side ML classifier to
|
|
8901
|
+
* train, so this just moves the message to the account's Junk-typed
|
|
8902
|
+
* folder (via the same alias resolution `deleteEmail` uses for Trash).
|
|
8903
|
+
* No standing block-rule mechanism exists across IMAP servers (Sieve
|
|
8904
|
+
* exists on some but isn't universal), so `createBlockRule` is
|
|
8905
|
+
* intentionally left unimplemented for this provider.
|
|
8906
|
+
*/
|
|
8907
|
+
async reportSpam(emailId, sourceFolder) {
|
|
8908
|
+
if (!this.client) throw new Error("Not connected");
|
|
8909
|
+
const folder = sourceFolder || "INBOX";
|
|
8910
|
+
const junkFolder = await this.resolveFolder("junk");
|
|
8911
|
+
let lock;
|
|
8912
|
+
try {
|
|
8913
|
+
lock = await this.client.getMailboxLock(folder);
|
|
8914
|
+
} catch (error48) {
|
|
8915
|
+
throw formatImapError(error48, `Failed to open folder "${folder}"`);
|
|
8916
|
+
}
|
|
8917
|
+
try {
|
|
8918
|
+
await this.client.messageMove(emailId, junkFolder, { uid: true });
|
|
8919
|
+
} finally {
|
|
8920
|
+
lock.release();
|
|
8921
|
+
}
|
|
8922
|
+
}
|
|
8748
8923
|
async deleteEmail(emailId, permanent, sourceFolder) {
|
|
8749
8924
|
if (!this.client) throw new Error("Not connected");
|
|
8750
8925
|
const folder = sourceFolder ? await this.resolveFolder(sourceFolder) : "INBOX";
|
|
@@ -9116,6 +9291,107 @@ var init_account_manager = __esm({
|
|
|
9116
9291
|
}
|
|
9117
9292
|
});
|
|
9118
9293
|
|
|
9294
|
+
// src/setup/prompts.ts
|
|
9295
|
+
import readline from "node:readline/promises";
|
|
9296
|
+
import { stdin as input, stdout as output } from "node:process";
|
|
9297
|
+
function getInterface() {
|
|
9298
|
+
if (!sharedInterface) {
|
|
9299
|
+
sharedInterface = readline.createInterface({ input, output });
|
|
9300
|
+
}
|
|
9301
|
+
return sharedInterface;
|
|
9302
|
+
}
|
|
9303
|
+
function closePrompts() {
|
|
9304
|
+
sharedInterface?.close();
|
|
9305
|
+
sharedInterface = null;
|
|
9306
|
+
}
|
|
9307
|
+
async function askText(message, defaultValue) {
|
|
9308
|
+
const rl = getInterface();
|
|
9309
|
+
const suffix = defaultValue ? ` (${defaultValue})` : "";
|
|
9310
|
+
const answer = await rl.question(`${message}${suffix} `);
|
|
9311
|
+
const trimmed = answer.trim();
|
|
9312
|
+
return trimmed.length > 0 ? trimmed : defaultValue ?? "";
|
|
9313
|
+
}
|
|
9314
|
+
async function askValidated(message, defaultValue, validate) {
|
|
9315
|
+
for (; ; ) {
|
|
9316
|
+
const value = await askText(message, defaultValue);
|
|
9317
|
+
const result = validate(value);
|
|
9318
|
+
if (result === true) return value;
|
|
9319
|
+
console.log(` ${result}`);
|
|
9320
|
+
}
|
|
9321
|
+
}
|
|
9322
|
+
async function askConfirm(message, defaultValue = false) {
|
|
9323
|
+
const suffix = defaultValue ? "Y/n" : "y/N";
|
|
9324
|
+
const answer = await askText(`${message} (${suffix})`);
|
|
9325
|
+
if (!answer) return defaultValue;
|
|
9326
|
+
return /^y/i.test(answer);
|
|
9327
|
+
}
|
|
9328
|
+
async function askChoice(message, choices) {
|
|
9329
|
+
console.log(message);
|
|
9330
|
+
choices.forEach((c, i) => console.log(` ${i + 1}) ${c.name}`));
|
|
9331
|
+
for (; ; ) {
|
|
9332
|
+
const answer = await askText("Enter a number:");
|
|
9333
|
+
const idx = parseInt(answer, 10) - 1;
|
|
9334
|
+
if (idx >= 0 && idx < choices.length) return choices[idx].value;
|
|
9335
|
+
console.log(` Please enter a number between 1 and ${choices.length}.`);
|
|
9336
|
+
}
|
|
9337
|
+
}
|
|
9338
|
+
function askPassword(message) {
|
|
9339
|
+
return new Promise((resolve) => {
|
|
9340
|
+
output.write(`${message} `);
|
|
9341
|
+
if (!input.isTTY || typeof input.setRawMode !== "function") {
|
|
9342
|
+
const rl = getInterface();
|
|
9343
|
+
rl.question("").then(resolve);
|
|
9344
|
+
return;
|
|
9345
|
+
}
|
|
9346
|
+
let value = "";
|
|
9347
|
+
input.setRawMode(true);
|
|
9348
|
+
input.resume();
|
|
9349
|
+
input.setEncoding("utf8");
|
|
9350
|
+
const cleanup = () => {
|
|
9351
|
+
input.setRawMode(false);
|
|
9352
|
+
input.pause();
|
|
9353
|
+
input.removeListener("data", onData);
|
|
9354
|
+
};
|
|
9355
|
+
const onData = (char) => {
|
|
9356
|
+
switch (char) {
|
|
9357
|
+
case "\n":
|
|
9358
|
+
case "\r":
|
|
9359
|
+
case CTRL_D:
|
|
9360
|
+
cleanup();
|
|
9361
|
+
output.write("\n");
|
|
9362
|
+
resolve(value);
|
|
9363
|
+
break;
|
|
9364
|
+
case CTRL_C:
|
|
9365
|
+
cleanup();
|
|
9366
|
+
output.write("\n");
|
|
9367
|
+
process.exit(130);
|
|
9368
|
+
break;
|
|
9369
|
+
case BACKSPACE:
|
|
9370
|
+
case "\b":
|
|
9371
|
+
if (value.length > 0) {
|
|
9372
|
+
value = value.slice(0, -1);
|
|
9373
|
+
output.write("\b \b");
|
|
9374
|
+
}
|
|
9375
|
+
break;
|
|
9376
|
+
default:
|
|
9377
|
+
value += char;
|
|
9378
|
+
output.write("*");
|
|
9379
|
+
}
|
|
9380
|
+
};
|
|
9381
|
+
input.on("data", onData);
|
|
9382
|
+
});
|
|
9383
|
+
}
|
|
9384
|
+
var CTRL_C, CTRL_D, BACKSPACE, sharedInterface;
|
|
9385
|
+
var init_prompts = __esm({
|
|
9386
|
+
"src/setup/prompts.ts"() {
|
|
9387
|
+
"use strict";
|
|
9388
|
+
CTRL_C = "";
|
|
9389
|
+
CTRL_D = "";
|
|
9390
|
+
BACKSPACE = "\x7F";
|
|
9391
|
+
sharedInterface = null;
|
|
9392
|
+
}
|
|
9393
|
+
});
|
|
9394
|
+
|
|
9119
9395
|
// src/auth/oauth-server.ts
|
|
9120
9396
|
import http from "node:http";
|
|
9121
9397
|
var SUCCESS_HTML, ERROR_HTML, OAuthCallbackServer;
|
|
@@ -9213,7 +9489,6 @@ var init_oauth_server = __esm({
|
|
|
9213
9489
|
var wizard_exports = {};
|
|
9214
9490
|
import crypto4 from "node:crypto";
|
|
9215
9491
|
import { exec } from "node:child_process";
|
|
9216
|
-
import inquirer from "inquirer";
|
|
9217
9492
|
function openBrowser(url2) {
|
|
9218
9493
|
const platform = process.platform;
|
|
9219
9494
|
let cmd;
|
|
@@ -9254,15 +9529,7 @@ async function testAndSave(creds) {
|
|
|
9254
9529
|
}
|
|
9255
9530
|
}
|
|
9256
9531
|
async function promptAccountName(defaultName) {
|
|
9257
|
-
|
|
9258
|
-
{
|
|
9259
|
-
type: "input",
|
|
9260
|
-
name: "name",
|
|
9261
|
-
message: "Account name:",
|
|
9262
|
-
default: defaultName
|
|
9263
|
-
}
|
|
9264
|
-
]);
|
|
9265
|
-
return name;
|
|
9532
|
+
return askText("Account name:", defaultName);
|
|
9266
9533
|
}
|
|
9267
9534
|
async function setupGmail() {
|
|
9268
9535
|
console.log("\n--- Gmail Setup ---");
|
|
@@ -9354,30 +9621,25 @@ async function setupICloud() {
|
|
|
9354
9621
|
console.log(
|
|
9355
9622
|
"You need an app-specific password for iCloud Mail.\nGenerate one at https://appleid.apple.com/account/manage\n(Sign In & Security > App-Specific Passwords)\n"
|
|
9356
9623
|
);
|
|
9357
|
-
const
|
|
9358
|
-
|
|
9359
|
-
|
|
9360
|
-
|
|
9361
|
-
|
|
9362
|
-
|
|
9363
|
-
|
|
9364
|
-
|
|
9365
|
-
|
|
9366
|
-
|
|
9367
|
-
message: "App-specific password:",
|
|
9368
|
-
mask: "*",
|
|
9369
|
-
validate: (v) => v.trim().length > 0 || "Password is required"
|
|
9370
|
-
}
|
|
9371
|
-
]);
|
|
9624
|
+
const email3 = await askValidated(
|
|
9625
|
+
"iCloud email address:",
|
|
9626
|
+
void 0,
|
|
9627
|
+
(v) => v.includes("@") || "Enter a valid email address"
|
|
9628
|
+
);
|
|
9629
|
+
let password = await askPassword("App-specific password:");
|
|
9630
|
+
while (password.trim().length === 0) {
|
|
9631
|
+
console.log(" Password is required");
|
|
9632
|
+
password = await askPassword("App-specific password:");
|
|
9633
|
+
}
|
|
9372
9634
|
const name = await promptAccountName("iCloud");
|
|
9373
9635
|
const id = crypto4.randomUUID();
|
|
9374
9636
|
const creds = {
|
|
9375
9637
|
id,
|
|
9376
9638
|
name,
|
|
9377
9639
|
provider: ProviderType.ICloud,
|
|
9378
|
-
email:
|
|
9640
|
+
email: email3.trim(),
|
|
9379
9641
|
password: {
|
|
9380
|
-
password
|
|
9642
|
+
password,
|
|
9381
9643
|
host: "imap.mail.me.com",
|
|
9382
9644
|
port: 993,
|
|
9383
9645
|
tls: true,
|
|
@@ -9389,72 +9651,26 @@ async function setupICloud() {
|
|
|
9389
9651
|
}
|
|
9390
9652
|
async function setupIMAP() {
|
|
9391
9653
|
console.log("\n--- Generic IMAP Setup ---\n");
|
|
9392
|
-
const
|
|
9393
|
-
|
|
9394
|
-
|
|
9395
|
-
|
|
9396
|
-
|
|
9397
|
-
|
|
9398
|
-
|
|
9399
|
-
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
|
|
9403
|
-
|
|
9404
|
-
|
|
9405
|
-
|
|
9406
|
-
type: "input",
|
|
9407
|
-
name: "port",
|
|
9408
|
-
message: "IMAP port:",
|
|
9409
|
-
default: "993",
|
|
9410
|
-
validate: (v) => {
|
|
9411
|
-
const n = parseInt(v, 10);
|
|
9412
|
-
return n > 0 && n <= 65535 || "Enter a valid port number (1-65535)";
|
|
9413
|
-
}
|
|
9414
|
-
},
|
|
9415
|
-
{
|
|
9416
|
-
type: "confirm",
|
|
9417
|
-
name: "tls",
|
|
9418
|
-
message: "Use TLS?",
|
|
9419
|
-
default: true
|
|
9420
|
-
},
|
|
9421
|
-
{
|
|
9422
|
-
type: "password",
|
|
9423
|
-
name: "password",
|
|
9424
|
-
message: "Password:",
|
|
9425
|
-
mask: "*",
|
|
9426
|
-
validate: (v) => v.trim().length > 0 || "Password is required"
|
|
9427
|
-
},
|
|
9428
|
-
{
|
|
9429
|
-
type: "confirm",
|
|
9430
|
-
name: "configureSmtp",
|
|
9431
|
-
message: "Configure SMTP (for sending)?",
|
|
9432
|
-
default: false
|
|
9433
|
-
}
|
|
9434
|
-
]);
|
|
9654
|
+
const portValidator = (v) => {
|
|
9655
|
+
const n = parseInt(v, 10);
|
|
9656
|
+
return n > 0 && n <= 65535 || "Enter a valid port number (1-65535)";
|
|
9657
|
+
};
|
|
9658
|
+
const email3 = await askValidated("Email address:", void 0, (v) => v.includes("@") || "Enter a valid email address");
|
|
9659
|
+
const host = await askValidated("IMAP host:", void 0, (v) => v.trim().length > 0 || "Host is required");
|
|
9660
|
+
const portStr = await askValidated("IMAP port:", "993", portValidator);
|
|
9661
|
+
const tls = await askConfirm("Use TLS?", true);
|
|
9662
|
+
let password = await askPassword("Password:");
|
|
9663
|
+
while (password.trim().length === 0) {
|
|
9664
|
+
console.log(" Password is required");
|
|
9665
|
+
password = await askPassword("Password:");
|
|
9666
|
+
}
|
|
9667
|
+
const configureSmtp = await askConfirm("Configure SMTP (for sending)?", false);
|
|
9435
9668
|
let smtpHost;
|
|
9436
9669
|
let smtpPort;
|
|
9437
|
-
if (
|
|
9438
|
-
|
|
9439
|
-
|
|
9440
|
-
|
|
9441
|
-
name: "smtpHost",
|
|
9442
|
-
message: "SMTP host:",
|
|
9443
|
-
validate: (v) => v.trim().length > 0 || "SMTP host is required"
|
|
9444
|
-
},
|
|
9445
|
-
{
|
|
9446
|
-
type: "input",
|
|
9447
|
-
name: "smtpPort",
|
|
9448
|
-
message: "SMTP port:",
|
|
9449
|
-
default: "587",
|
|
9450
|
-
validate: (v) => {
|
|
9451
|
-
const n = parseInt(v, 10);
|
|
9452
|
-
return n > 0 && n <= 65535 || "Enter a valid port number (1-65535)";
|
|
9453
|
-
}
|
|
9454
|
-
}
|
|
9455
|
-
]);
|
|
9456
|
-
smtpHost = smtp.smtpHost.trim();
|
|
9457
|
-
smtpPort = parseInt(smtp.smtpPort, 10);
|
|
9670
|
+
if (configureSmtp) {
|
|
9671
|
+
smtpHost = await askValidated("SMTP host:", void 0, (v) => v.trim().length > 0 || "SMTP host is required");
|
|
9672
|
+
const smtpPortStr = await askValidated("SMTP port:", "587", portValidator);
|
|
9673
|
+
smtpPort = parseInt(smtpPortStr, 10);
|
|
9458
9674
|
}
|
|
9459
9675
|
const name = await promptAccountName("IMAP");
|
|
9460
9676
|
const id = crypto4.randomUUID();
|
|
@@ -9462,12 +9678,12 @@ async function setupIMAP() {
|
|
|
9462
9678
|
id,
|
|
9463
9679
|
name,
|
|
9464
9680
|
provider: ProviderType.IMAP,
|
|
9465
|
-
email:
|
|
9681
|
+
email: email3.trim(),
|
|
9466
9682
|
password: {
|
|
9467
|
-
password
|
|
9468
|
-
host:
|
|
9469
|
-
port: parseInt(
|
|
9470
|
-
tls
|
|
9683
|
+
password,
|
|
9684
|
+
host: host.trim(),
|
|
9685
|
+
port: parseInt(portStr, 10),
|
|
9686
|
+
tls,
|
|
9471
9687
|
smtpHost,
|
|
9472
9688
|
smtpPort
|
|
9473
9689
|
}
|
|
@@ -9497,14 +9713,7 @@ async function removeAccount(id) {
|
|
|
9497
9713
|
console.error(`Account not found: ${id}`);
|
|
9498
9714
|
process.exit(1);
|
|
9499
9715
|
}
|
|
9500
|
-
const
|
|
9501
|
-
{
|
|
9502
|
-
type: "confirm",
|
|
9503
|
-
name: "confirm",
|
|
9504
|
-
message: `Remove account "${acct.name}" (${acct.email})?`,
|
|
9505
|
-
default: false
|
|
9506
|
-
}
|
|
9507
|
-
]);
|
|
9716
|
+
const confirm = await askConfirm(`Remove account "${acct.name}" (${acct.email})?`, false);
|
|
9508
9717
|
if (confirm) {
|
|
9509
9718
|
await store.remove(id);
|
|
9510
9719
|
console.log(`Account "${acct.name}" removed.`);
|
|
@@ -9531,18 +9740,11 @@ async function main() {
|
|
|
9531
9740
|
console.log("@marlinjai/email-mcp Account Setup\n");
|
|
9532
9741
|
let addMore = true;
|
|
9533
9742
|
while (addMore) {
|
|
9534
|
-
const
|
|
9535
|
-
{
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
choices: [
|
|
9540
|
-
{ name: "Gmail", value: "gmail" },
|
|
9541
|
-
{ name: "Outlook", value: "outlook" },
|
|
9542
|
-
{ name: "iCloud", value: "icloud" },
|
|
9543
|
-
{ name: "Other IMAP", value: "imap" }
|
|
9544
|
-
]
|
|
9545
|
-
}
|
|
9743
|
+
const provider = await askChoice("Select provider:", [
|
|
9744
|
+
{ name: "Gmail", value: "gmail" },
|
|
9745
|
+
{ name: "Outlook", value: "outlook" },
|
|
9746
|
+
{ name: "iCloud", value: "icloud" },
|
|
9747
|
+
{ name: "Other IMAP", value: "imap" }
|
|
9546
9748
|
]);
|
|
9547
9749
|
switch (provider) {
|
|
9548
9750
|
case ProviderType.Gmail:
|
|
@@ -9561,15 +9763,7 @@ async function main() {
|
|
|
9561
9763
|
console.error(`Unknown provider: ${provider}`);
|
|
9562
9764
|
process.exit(1);
|
|
9563
9765
|
}
|
|
9564
|
-
|
|
9565
|
-
{
|
|
9566
|
-
type: "confirm",
|
|
9567
|
-
name: "another",
|
|
9568
|
-
message: "Would you like to add another email account?",
|
|
9569
|
-
default: false
|
|
9570
|
-
}
|
|
9571
|
-
]);
|
|
9572
|
-
addMore = another;
|
|
9766
|
+
addMore = await askConfirm("Would you like to add another email account?", false);
|
|
9573
9767
|
}
|
|
9574
9768
|
console.log("\nSetup complete! You can now use the email tools in Claude Code.");
|
|
9575
9769
|
}
|
|
@@ -9577,6 +9771,7 @@ var store, manager;
|
|
|
9577
9771
|
var init_wizard = __esm({
|
|
9578
9772
|
"src/setup/wizard.ts"() {
|
|
9579
9773
|
"use strict";
|
|
9774
|
+
init_prompts();
|
|
9580
9775
|
init_credential_store();
|
|
9581
9776
|
init_oauth_server();
|
|
9582
9777
|
init_auth();
|
|
@@ -9590,7 +9785,7 @@ var init_wizard = __esm({
|
|
|
9590
9785
|
console.error(`
|
|
9591
9786
|
Setup failed: ${err.message}`);
|
|
9592
9787
|
process.exit(1);
|
|
9593
|
-
});
|
|
9788
|
+
}).finally(closePrompts);
|
|
9594
9789
|
}
|
|
9595
9790
|
});
|
|
9596
9791
|
|
|
@@ -10136,41 +10331,41 @@ var ZodType = class {
|
|
|
10136
10331
|
get description() {
|
|
10137
10332
|
return this._def.description;
|
|
10138
10333
|
}
|
|
10139
|
-
_getType(
|
|
10140
|
-
return getParsedType(
|
|
10334
|
+
_getType(input2) {
|
|
10335
|
+
return getParsedType(input2.data);
|
|
10141
10336
|
}
|
|
10142
|
-
_getOrReturnCtx(
|
|
10337
|
+
_getOrReturnCtx(input2, ctx) {
|
|
10143
10338
|
return ctx || {
|
|
10144
|
-
common:
|
|
10145
|
-
data:
|
|
10146
|
-
parsedType: getParsedType(
|
|
10339
|
+
common: input2.parent.common,
|
|
10340
|
+
data: input2.data,
|
|
10341
|
+
parsedType: getParsedType(input2.data),
|
|
10147
10342
|
schemaErrorMap: this._def.errorMap,
|
|
10148
|
-
path:
|
|
10149
|
-
parent:
|
|
10343
|
+
path: input2.path,
|
|
10344
|
+
parent: input2.parent
|
|
10150
10345
|
};
|
|
10151
10346
|
}
|
|
10152
|
-
_processInputParams(
|
|
10347
|
+
_processInputParams(input2) {
|
|
10153
10348
|
return {
|
|
10154
10349
|
status: new ParseStatus(),
|
|
10155
10350
|
ctx: {
|
|
10156
|
-
common:
|
|
10157
|
-
data:
|
|
10158
|
-
parsedType: getParsedType(
|
|
10351
|
+
common: input2.parent.common,
|
|
10352
|
+
data: input2.data,
|
|
10353
|
+
parsedType: getParsedType(input2.data),
|
|
10159
10354
|
schemaErrorMap: this._def.errorMap,
|
|
10160
|
-
path:
|
|
10161
|
-
parent:
|
|
10355
|
+
path: input2.path,
|
|
10356
|
+
parent: input2.parent
|
|
10162
10357
|
}
|
|
10163
10358
|
};
|
|
10164
10359
|
}
|
|
10165
|
-
_parseSync(
|
|
10166
|
-
const result = this._parse(
|
|
10360
|
+
_parseSync(input2) {
|
|
10361
|
+
const result = this._parse(input2);
|
|
10167
10362
|
if (isAsync(result)) {
|
|
10168
10363
|
throw new Error("Synchronous parse encountered promise.");
|
|
10169
10364
|
}
|
|
10170
10365
|
return result;
|
|
10171
10366
|
}
|
|
10172
|
-
_parseAsync(
|
|
10173
|
-
const result = this._parse(
|
|
10367
|
+
_parseAsync(input2) {
|
|
10368
|
+
const result = this._parse(input2);
|
|
10174
10369
|
return Promise.resolve(result);
|
|
10175
10370
|
}
|
|
10176
10371
|
parse(data, params) {
|
|
@@ -10496,13 +10691,13 @@ function isValidCidr(ip, version2) {
|
|
|
10496
10691
|
return false;
|
|
10497
10692
|
}
|
|
10498
10693
|
var ZodString = class _ZodString2 extends ZodType {
|
|
10499
|
-
_parse(
|
|
10694
|
+
_parse(input2) {
|
|
10500
10695
|
if (this._def.coerce) {
|
|
10501
|
-
|
|
10696
|
+
input2.data = String(input2.data);
|
|
10502
10697
|
}
|
|
10503
|
-
const parsedType2 = this._getType(
|
|
10698
|
+
const parsedType2 = this._getType(input2);
|
|
10504
10699
|
if (parsedType2 !== ZodParsedType.string) {
|
|
10505
|
-
const ctx2 = this._getOrReturnCtx(
|
|
10700
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
10506
10701
|
addIssueToContext(ctx2, {
|
|
10507
10702
|
code: ZodIssueCode.invalid_type,
|
|
10508
10703
|
expected: ZodParsedType.string,
|
|
@@ -10514,8 +10709,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10514
10709
|
let ctx = void 0;
|
|
10515
10710
|
for (const check2 of this._def.checks) {
|
|
10516
10711
|
if (check2.kind === "min") {
|
|
10517
|
-
if (
|
|
10518
|
-
ctx = this._getOrReturnCtx(
|
|
10712
|
+
if (input2.data.length < check2.value) {
|
|
10713
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10519
10714
|
addIssueToContext(ctx, {
|
|
10520
10715
|
code: ZodIssueCode.too_small,
|
|
10521
10716
|
minimum: check2.value,
|
|
@@ -10527,8 +10722,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10527
10722
|
status.dirty();
|
|
10528
10723
|
}
|
|
10529
10724
|
} else if (check2.kind === "max") {
|
|
10530
|
-
if (
|
|
10531
|
-
ctx = this._getOrReturnCtx(
|
|
10725
|
+
if (input2.data.length > check2.value) {
|
|
10726
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10532
10727
|
addIssueToContext(ctx, {
|
|
10533
10728
|
code: ZodIssueCode.too_big,
|
|
10534
10729
|
maximum: check2.value,
|
|
@@ -10540,10 +10735,10 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10540
10735
|
status.dirty();
|
|
10541
10736
|
}
|
|
10542
10737
|
} else if (check2.kind === "length") {
|
|
10543
|
-
const tooBig =
|
|
10544
|
-
const tooSmall =
|
|
10738
|
+
const tooBig = input2.data.length > check2.value;
|
|
10739
|
+
const tooSmall = input2.data.length < check2.value;
|
|
10545
10740
|
if (tooBig || tooSmall) {
|
|
10546
|
-
ctx = this._getOrReturnCtx(
|
|
10741
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10547
10742
|
if (tooBig) {
|
|
10548
10743
|
addIssueToContext(ctx, {
|
|
10549
10744
|
code: ZodIssueCode.too_big,
|
|
@@ -10566,8 +10761,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10566
10761
|
status.dirty();
|
|
10567
10762
|
}
|
|
10568
10763
|
} else if (check2.kind === "email") {
|
|
10569
|
-
if (!emailRegex.test(
|
|
10570
|
-
ctx = this._getOrReturnCtx(
|
|
10764
|
+
if (!emailRegex.test(input2.data)) {
|
|
10765
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10571
10766
|
addIssueToContext(ctx, {
|
|
10572
10767
|
validation: "email",
|
|
10573
10768
|
code: ZodIssueCode.invalid_string,
|
|
@@ -10579,8 +10774,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10579
10774
|
if (!emojiRegex) {
|
|
10580
10775
|
emojiRegex = new RegExp(_emojiRegex, "u");
|
|
10581
10776
|
}
|
|
10582
|
-
if (!emojiRegex.test(
|
|
10583
|
-
ctx = this._getOrReturnCtx(
|
|
10777
|
+
if (!emojiRegex.test(input2.data)) {
|
|
10778
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10584
10779
|
addIssueToContext(ctx, {
|
|
10585
10780
|
validation: "emoji",
|
|
10586
10781
|
code: ZodIssueCode.invalid_string,
|
|
@@ -10589,8 +10784,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10589
10784
|
status.dirty();
|
|
10590
10785
|
}
|
|
10591
10786
|
} else if (check2.kind === "uuid") {
|
|
10592
|
-
if (!uuidRegex.test(
|
|
10593
|
-
ctx = this._getOrReturnCtx(
|
|
10787
|
+
if (!uuidRegex.test(input2.data)) {
|
|
10788
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10594
10789
|
addIssueToContext(ctx, {
|
|
10595
10790
|
validation: "uuid",
|
|
10596
10791
|
code: ZodIssueCode.invalid_string,
|
|
@@ -10599,8 +10794,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10599
10794
|
status.dirty();
|
|
10600
10795
|
}
|
|
10601
10796
|
} else if (check2.kind === "nanoid") {
|
|
10602
|
-
if (!nanoidRegex.test(
|
|
10603
|
-
ctx = this._getOrReturnCtx(
|
|
10797
|
+
if (!nanoidRegex.test(input2.data)) {
|
|
10798
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10604
10799
|
addIssueToContext(ctx, {
|
|
10605
10800
|
validation: "nanoid",
|
|
10606
10801
|
code: ZodIssueCode.invalid_string,
|
|
@@ -10609,8 +10804,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10609
10804
|
status.dirty();
|
|
10610
10805
|
}
|
|
10611
10806
|
} else if (check2.kind === "cuid") {
|
|
10612
|
-
if (!cuidRegex.test(
|
|
10613
|
-
ctx = this._getOrReturnCtx(
|
|
10807
|
+
if (!cuidRegex.test(input2.data)) {
|
|
10808
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10614
10809
|
addIssueToContext(ctx, {
|
|
10615
10810
|
validation: "cuid",
|
|
10616
10811
|
code: ZodIssueCode.invalid_string,
|
|
@@ -10619,8 +10814,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10619
10814
|
status.dirty();
|
|
10620
10815
|
}
|
|
10621
10816
|
} else if (check2.kind === "cuid2") {
|
|
10622
|
-
if (!cuid2Regex.test(
|
|
10623
|
-
ctx = this._getOrReturnCtx(
|
|
10817
|
+
if (!cuid2Regex.test(input2.data)) {
|
|
10818
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10624
10819
|
addIssueToContext(ctx, {
|
|
10625
10820
|
validation: "cuid2",
|
|
10626
10821
|
code: ZodIssueCode.invalid_string,
|
|
@@ -10629,8 +10824,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10629
10824
|
status.dirty();
|
|
10630
10825
|
}
|
|
10631
10826
|
} else if (check2.kind === "ulid") {
|
|
10632
|
-
if (!ulidRegex.test(
|
|
10633
|
-
ctx = this._getOrReturnCtx(
|
|
10827
|
+
if (!ulidRegex.test(input2.data)) {
|
|
10828
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10634
10829
|
addIssueToContext(ctx, {
|
|
10635
10830
|
validation: "ulid",
|
|
10636
10831
|
code: ZodIssueCode.invalid_string,
|
|
@@ -10640,9 +10835,9 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10640
10835
|
}
|
|
10641
10836
|
} else if (check2.kind === "url") {
|
|
10642
10837
|
try {
|
|
10643
|
-
new URL(
|
|
10838
|
+
new URL(input2.data);
|
|
10644
10839
|
} catch {
|
|
10645
|
-
ctx = this._getOrReturnCtx(
|
|
10840
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10646
10841
|
addIssueToContext(ctx, {
|
|
10647
10842
|
validation: "url",
|
|
10648
10843
|
code: ZodIssueCode.invalid_string,
|
|
@@ -10652,9 +10847,9 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10652
10847
|
}
|
|
10653
10848
|
} else if (check2.kind === "regex") {
|
|
10654
10849
|
check2.regex.lastIndex = 0;
|
|
10655
|
-
const testResult = check2.regex.test(
|
|
10850
|
+
const testResult = check2.regex.test(input2.data);
|
|
10656
10851
|
if (!testResult) {
|
|
10657
|
-
ctx = this._getOrReturnCtx(
|
|
10852
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10658
10853
|
addIssueToContext(ctx, {
|
|
10659
10854
|
validation: "regex",
|
|
10660
10855
|
code: ZodIssueCode.invalid_string,
|
|
@@ -10663,10 +10858,10 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10663
10858
|
status.dirty();
|
|
10664
10859
|
}
|
|
10665
10860
|
} else if (check2.kind === "trim") {
|
|
10666
|
-
|
|
10861
|
+
input2.data = input2.data.trim();
|
|
10667
10862
|
} else if (check2.kind === "includes") {
|
|
10668
|
-
if (!
|
|
10669
|
-
ctx = this._getOrReturnCtx(
|
|
10863
|
+
if (!input2.data.includes(check2.value, check2.position)) {
|
|
10864
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10670
10865
|
addIssueToContext(ctx, {
|
|
10671
10866
|
code: ZodIssueCode.invalid_string,
|
|
10672
10867
|
validation: { includes: check2.value, position: check2.position },
|
|
@@ -10675,12 +10870,12 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10675
10870
|
status.dirty();
|
|
10676
10871
|
}
|
|
10677
10872
|
} else if (check2.kind === "toLowerCase") {
|
|
10678
|
-
|
|
10873
|
+
input2.data = input2.data.toLowerCase();
|
|
10679
10874
|
} else if (check2.kind === "toUpperCase") {
|
|
10680
|
-
|
|
10875
|
+
input2.data = input2.data.toUpperCase();
|
|
10681
10876
|
} else if (check2.kind === "startsWith") {
|
|
10682
|
-
if (!
|
|
10683
|
-
ctx = this._getOrReturnCtx(
|
|
10877
|
+
if (!input2.data.startsWith(check2.value)) {
|
|
10878
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10684
10879
|
addIssueToContext(ctx, {
|
|
10685
10880
|
code: ZodIssueCode.invalid_string,
|
|
10686
10881
|
validation: { startsWith: check2.value },
|
|
@@ -10689,8 +10884,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10689
10884
|
status.dirty();
|
|
10690
10885
|
}
|
|
10691
10886
|
} else if (check2.kind === "endsWith") {
|
|
10692
|
-
if (!
|
|
10693
|
-
ctx = this._getOrReturnCtx(
|
|
10887
|
+
if (!input2.data.endsWith(check2.value)) {
|
|
10888
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10694
10889
|
addIssueToContext(ctx, {
|
|
10695
10890
|
code: ZodIssueCode.invalid_string,
|
|
10696
10891
|
validation: { endsWith: check2.value },
|
|
@@ -10700,8 +10895,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10700
10895
|
}
|
|
10701
10896
|
} else if (check2.kind === "datetime") {
|
|
10702
10897
|
const regex = datetimeRegex(check2);
|
|
10703
|
-
if (!regex.test(
|
|
10704
|
-
ctx = this._getOrReturnCtx(
|
|
10898
|
+
if (!regex.test(input2.data)) {
|
|
10899
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10705
10900
|
addIssueToContext(ctx, {
|
|
10706
10901
|
code: ZodIssueCode.invalid_string,
|
|
10707
10902
|
validation: "datetime",
|
|
@@ -10711,8 +10906,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10711
10906
|
}
|
|
10712
10907
|
} else if (check2.kind === "date") {
|
|
10713
10908
|
const regex = dateRegex;
|
|
10714
|
-
if (!regex.test(
|
|
10715
|
-
ctx = this._getOrReturnCtx(
|
|
10909
|
+
if (!regex.test(input2.data)) {
|
|
10910
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10716
10911
|
addIssueToContext(ctx, {
|
|
10717
10912
|
code: ZodIssueCode.invalid_string,
|
|
10718
10913
|
validation: "date",
|
|
@@ -10722,8 +10917,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10722
10917
|
}
|
|
10723
10918
|
} else if (check2.kind === "time") {
|
|
10724
10919
|
const regex = timeRegex(check2);
|
|
10725
|
-
if (!regex.test(
|
|
10726
|
-
ctx = this._getOrReturnCtx(
|
|
10920
|
+
if (!regex.test(input2.data)) {
|
|
10921
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10727
10922
|
addIssueToContext(ctx, {
|
|
10728
10923
|
code: ZodIssueCode.invalid_string,
|
|
10729
10924
|
validation: "time",
|
|
@@ -10732,8 +10927,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10732
10927
|
status.dirty();
|
|
10733
10928
|
}
|
|
10734
10929
|
} else if (check2.kind === "duration") {
|
|
10735
|
-
if (!durationRegex.test(
|
|
10736
|
-
ctx = this._getOrReturnCtx(
|
|
10930
|
+
if (!durationRegex.test(input2.data)) {
|
|
10931
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10737
10932
|
addIssueToContext(ctx, {
|
|
10738
10933
|
validation: "duration",
|
|
10739
10934
|
code: ZodIssueCode.invalid_string,
|
|
@@ -10742,8 +10937,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10742
10937
|
status.dirty();
|
|
10743
10938
|
}
|
|
10744
10939
|
} else if (check2.kind === "ip") {
|
|
10745
|
-
if (!isValidIP(
|
|
10746
|
-
ctx = this._getOrReturnCtx(
|
|
10940
|
+
if (!isValidIP(input2.data, check2.version)) {
|
|
10941
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10747
10942
|
addIssueToContext(ctx, {
|
|
10748
10943
|
validation: "ip",
|
|
10749
10944
|
code: ZodIssueCode.invalid_string,
|
|
@@ -10752,8 +10947,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10752
10947
|
status.dirty();
|
|
10753
10948
|
}
|
|
10754
10949
|
} else if (check2.kind === "jwt") {
|
|
10755
|
-
if (!isValidJWT(
|
|
10756
|
-
ctx = this._getOrReturnCtx(
|
|
10950
|
+
if (!isValidJWT(input2.data, check2.alg)) {
|
|
10951
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10757
10952
|
addIssueToContext(ctx, {
|
|
10758
10953
|
validation: "jwt",
|
|
10759
10954
|
code: ZodIssueCode.invalid_string,
|
|
@@ -10762,8 +10957,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10762
10957
|
status.dirty();
|
|
10763
10958
|
}
|
|
10764
10959
|
} else if (check2.kind === "cidr") {
|
|
10765
|
-
if (!isValidCidr(
|
|
10766
|
-
ctx = this._getOrReturnCtx(
|
|
10960
|
+
if (!isValidCidr(input2.data, check2.version)) {
|
|
10961
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10767
10962
|
addIssueToContext(ctx, {
|
|
10768
10963
|
validation: "cidr",
|
|
10769
10964
|
code: ZodIssueCode.invalid_string,
|
|
@@ -10772,8 +10967,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10772
10967
|
status.dirty();
|
|
10773
10968
|
}
|
|
10774
10969
|
} else if (check2.kind === "base64") {
|
|
10775
|
-
if (!base64Regex.test(
|
|
10776
|
-
ctx = this._getOrReturnCtx(
|
|
10970
|
+
if (!base64Regex.test(input2.data)) {
|
|
10971
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10777
10972
|
addIssueToContext(ctx, {
|
|
10778
10973
|
validation: "base64",
|
|
10779
10974
|
code: ZodIssueCode.invalid_string,
|
|
@@ -10782,8 +10977,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10782
10977
|
status.dirty();
|
|
10783
10978
|
}
|
|
10784
10979
|
} else if (check2.kind === "base64url") {
|
|
10785
|
-
if (!base64urlRegex.test(
|
|
10786
|
-
ctx = this._getOrReturnCtx(
|
|
10980
|
+
if (!base64urlRegex.test(input2.data)) {
|
|
10981
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
10787
10982
|
addIssueToContext(ctx, {
|
|
10788
10983
|
validation: "base64url",
|
|
10789
10984
|
code: ZodIssueCode.invalid_string,
|
|
@@ -10795,7 +10990,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
10795
10990
|
util.assertNever(check2);
|
|
10796
10991
|
}
|
|
10797
10992
|
}
|
|
10798
|
-
return { status: status.value, value:
|
|
10993
|
+
return { status: status.value, value: input2.data };
|
|
10799
10994
|
}
|
|
10800
10995
|
_regex(regex, validation, message) {
|
|
10801
10996
|
return this.refinement((data) => regex.test(data), {
|
|
@@ -11056,13 +11251,13 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
11056
11251
|
this.max = this.lte;
|
|
11057
11252
|
this.step = this.multipleOf;
|
|
11058
11253
|
}
|
|
11059
|
-
_parse(
|
|
11254
|
+
_parse(input2) {
|
|
11060
11255
|
if (this._def.coerce) {
|
|
11061
|
-
|
|
11256
|
+
input2.data = Number(input2.data);
|
|
11062
11257
|
}
|
|
11063
|
-
const parsedType2 = this._getType(
|
|
11258
|
+
const parsedType2 = this._getType(input2);
|
|
11064
11259
|
if (parsedType2 !== ZodParsedType.number) {
|
|
11065
|
-
const ctx2 = this._getOrReturnCtx(
|
|
11260
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
11066
11261
|
addIssueToContext(ctx2, {
|
|
11067
11262
|
code: ZodIssueCode.invalid_type,
|
|
11068
11263
|
expected: ZodParsedType.number,
|
|
@@ -11074,8 +11269,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
11074
11269
|
const status = new ParseStatus();
|
|
11075
11270
|
for (const check2 of this._def.checks) {
|
|
11076
11271
|
if (check2.kind === "int") {
|
|
11077
|
-
if (!util.isInteger(
|
|
11078
|
-
ctx = this._getOrReturnCtx(
|
|
11272
|
+
if (!util.isInteger(input2.data)) {
|
|
11273
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
11079
11274
|
addIssueToContext(ctx, {
|
|
11080
11275
|
code: ZodIssueCode.invalid_type,
|
|
11081
11276
|
expected: "integer",
|
|
@@ -11085,9 +11280,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
11085
11280
|
status.dirty();
|
|
11086
11281
|
}
|
|
11087
11282
|
} else if (check2.kind === "min") {
|
|
11088
|
-
const tooSmall = check2.inclusive ?
|
|
11283
|
+
const tooSmall = check2.inclusive ? input2.data < check2.value : input2.data <= check2.value;
|
|
11089
11284
|
if (tooSmall) {
|
|
11090
|
-
ctx = this._getOrReturnCtx(
|
|
11285
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
11091
11286
|
addIssueToContext(ctx, {
|
|
11092
11287
|
code: ZodIssueCode.too_small,
|
|
11093
11288
|
minimum: check2.value,
|
|
@@ -11099,9 +11294,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
11099
11294
|
status.dirty();
|
|
11100
11295
|
}
|
|
11101
11296
|
} else if (check2.kind === "max") {
|
|
11102
|
-
const tooBig = check2.inclusive ?
|
|
11297
|
+
const tooBig = check2.inclusive ? input2.data > check2.value : input2.data >= check2.value;
|
|
11103
11298
|
if (tooBig) {
|
|
11104
|
-
ctx = this._getOrReturnCtx(
|
|
11299
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
11105
11300
|
addIssueToContext(ctx, {
|
|
11106
11301
|
code: ZodIssueCode.too_big,
|
|
11107
11302
|
maximum: check2.value,
|
|
@@ -11113,8 +11308,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
11113
11308
|
status.dirty();
|
|
11114
11309
|
}
|
|
11115
11310
|
} else if (check2.kind === "multipleOf") {
|
|
11116
|
-
if (floatSafeRemainder(
|
|
11117
|
-
ctx = this._getOrReturnCtx(
|
|
11311
|
+
if (floatSafeRemainder(input2.data, check2.value) !== 0) {
|
|
11312
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
11118
11313
|
addIssueToContext(ctx, {
|
|
11119
11314
|
code: ZodIssueCode.not_multiple_of,
|
|
11120
11315
|
multipleOf: check2.value,
|
|
@@ -11123,8 +11318,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
11123
11318
|
status.dirty();
|
|
11124
11319
|
}
|
|
11125
11320
|
} else if (check2.kind === "finite") {
|
|
11126
|
-
if (!Number.isFinite(
|
|
11127
|
-
ctx = this._getOrReturnCtx(
|
|
11321
|
+
if (!Number.isFinite(input2.data)) {
|
|
11322
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
11128
11323
|
addIssueToContext(ctx, {
|
|
11129
11324
|
code: ZodIssueCode.not_finite,
|
|
11130
11325
|
message: check2.message
|
|
@@ -11135,7 +11330,7 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
11135
11330
|
util.assertNever(check2);
|
|
11136
11331
|
}
|
|
11137
11332
|
}
|
|
11138
|
-
return { status: status.value, value:
|
|
11333
|
+
return { status: status.value, value: input2.data };
|
|
11139
11334
|
}
|
|
11140
11335
|
gte(value, message) {
|
|
11141
11336
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
@@ -11287,25 +11482,25 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
11287
11482
|
this.min = this.gte;
|
|
11288
11483
|
this.max = this.lte;
|
|
11289
11484
|
}
|
|
11290
|
-
_parse(
|
|
11485
|
+
_parse(input2) {
|
|
11291
11486
|
if (this._def.coerce) {
|
|
11292
11487
|
try {
|
|
11293
|
-
|
|
11488
|
+
input2.data = BigInt(input2.data);
|
|
11294
11489
|
} catch {
|
|
11295
|
-
return this._getInvalidInput(
|
|
11490
|
+
return this._getInvalidInput(input2);
|
|
11296
11491
|
}
|
|
11297
11492
|
}
|
|
11298
|
-
const parsedType2 = this._getType(
|
|
11493
|
+
const parsedType2 = this._getType(input2);
|
|
11299
11494
|
if (parsedType2 !== ZodParsedType.bigint) {
|
|
11300
|
-
return this._getInvalidInput(
|
|
11495
|
+
return this._getInvalidInput(input2);
|
|
11301
11496
|
}
|
|
11302
11497
|
let ctx = void 0;
|
|
11303
11498
|
const status = new ParseStatus();
|
|
11304
11499
|
for (const check2 of this._def.checks) {
|
|
11305
11500
|
if (check2.kind === "min") {
|
|
11306
|
-
const tooSmall = check2.inclusive ?
|
|
11501
|
+
const tooSmall = check2.inclusive ? input2.data < check2.value : input2.data <= check2.value;
|
|
11307
11502
|
if (tooSmall) {
|
|
11308
|
-
ctx = this._getOrReturnCtx(
|
|
11503
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
11309
11504
|
addIssueToContext(ctx, {
|
|
11310
11505
|
code: ZodIssueCode.too_small,
|
|
11311
11506
|
type: "bigint",
|
|
@@ -11316,9 +11511,9 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
11316
11511
|
status.dirty();
|
|
11317
11512
|
}
|
|
11318
11513
|
} else if (check2.kind === "max") {
|
|
11319
|
-
const tooBig = check2.inclusive ?
|
|
11514
|
+
const tooBig = check2.inclusive ? input2.data > check2.value : input2.data >= check2.value;
|
|
11320
11515
|
if (tooBig) {
|
|
11321
|
-
ctx = this._getOrReturnCtx(
|
|
11516
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
11322
11517
|
addIssueToContext(ctx, {
|
|
11323
11518
|
code: ZodIssueCode.too_big,
|
|
11324
11519
|
type: "bigint",
|
|
@@ -11329,8 +11524,8 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
11329
11524
|
status.dirty();
|
|
11330
11525
|
}
|
|
11331
11526
|
} else if (check2.kind === "multipleOf") {
|
|
11332
|
-
if (
|
|
11333
|
-
ctx = this._getOrReturnCtx(
|
|
11527
|
+
if (input2.data % check2.value !== BigInt(0)) {
|
|
11528
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
11334
11529
|
addIssueToContext(ctx, {
|
|
11335
11530
|
code: ZodIssueCode.not_multiple_of,
|
|
11336
11531
|
multipleOf: check2.value,
|
|
@@ -11342,10 +11537,10 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
11342
11537
|
util.assertNever(check2);
|
|
11343
11538
|
}
|
|
11344
11539
|
}
|
|
11345
|
-
return { status: status.value, value:
|
|
11540
|
+
return { status: status.value, value: input2.data };
|
|
11346
11541
|
}
|
|
11347
|
-
_getInvalidInput(
|
|
11348
|
-
const ctx = this._getOrReturnCtx(
|
|
11542
|
+
_getInvalidInput(input2) {
|
|
11543
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
11349
11544
|
addIssueToContext(ctx, {
|
|
11350
11545
|
code: ZodIssueCode.invalid_type,
|
|
11351
11546
|
expected: ZodParsedType.bigint,
|
|
@@ -11454,13 +11649,13 @@ ZodBigInt.create = (params) => {
|
|
|
11454
11649
|
});
|
|
11455
11650
|
};
|
|
11456
11651
|
var ZodBoolean = class extends ZodType {
|
|
11457
|
-
_parse(
|
|
11652
|
+
_parse(input2) {
|
|
11458
11653
|
if (this._def.coerce) {
|
|
11459
|
-
|
|
11654
|
+
input2.data = Boolean(input2.data);
|
|
11460
11655
|
}
|
|
11461
|
-
const parsedType2 = this._getType(
|
|
11656
|
+
const parsedType2 = this._getType(input2);
|
|
11462
11657
|
if (parsedType2 !== ZodParsedType.boolean) {
|
|
11463
|
-
const ctx = this._getOrReturnCtx(
|
|
11658
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
11464
11659
|
addIssueToContext(ctx, {
|
|
11465
11660
|
code: ZodIssueCode.invalid_type,
|
|
11466
11661
|
expected: ZodParsedType.boolean,
|
|
@@ -11468,7 +11663,7 @@ var ZodBoolean = class extends ZodType {
|
|
|
11468
11663
|
});
|
|
11469
11664
|
return INVALID;
|
|
11470
11665
|
}
|
|
11471
|
-
return OK(
|
|
11666
|
+
return OK(input2.data);
|
|
11472
11667
|
}
|
|
11473
11668
|
};
|
|
11474
11669
|
ZodBoolean.create = (params) => {
|
|
@@ -11479,13 +11674,13 @@ ZodBoolean.create = (params) => {
|
|
|
11479
11674
|
});
|
|
11480
11675
|
};
|
|
11481
11676
|
var ZodDate = class _ZodDate extends ZodType {
|
|
11482
|
-
_parse(
|
|
11677
|
+
_parse(input2) {
|
|
11483
11678
|
if (this._def.coerce) {
|
|
11484
|
-
|
|
11679
|
+
input2.data = new Date(input2.data);
|
|
11485
11680
|
}
|
|
11486
|
-
const parsedType2 = this._getType(
|
|
11681
|
+
const parsedType2 = this._getType(input2);
|
|
11487
11682
|
if (parsedType2 !== ZodParsedType.date) {
|
|
11488
|
-
const ctx2 = this._getOrReturnCtx(
|
|
11683
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
11489
11684
|
addIssueToContext(ctx2, {
|
|
11490
11685
|
code: ZodIssueCode.invalid_type,
|
|
11491
11686
|
expected: ZodParsedType.date,
|
|
@@ -11493,8 +11688,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
11493
11688
|
});
|
|
11494
11689
|
return INVALID;
|
|
11495
11690
|
}
|
|
11496
|
-
if (Number.isNaN(
|
|
11497
|
-
const ctx2 = this._getOrReturnCtx(
|
|
11691
|
+
if (Number.isNaN(input2.data.getTime())) {
|
|
11692
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
11498
11693
|
addIssueToContext(ctx2, {
|
|
11499
11694
|
code: ZodIssueCode.invalid_date
|
|
11500
11695
|
});
|
|
@@ -11504,8 +11699,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
11504
11699
|
let ctx = void 0;
|
|
11505
11700
|
for (const check2 of this._def.checks) {
|
|
11506
11701
|
if (check2.kind === "min") {
|
|
11507
|
-
if (
|
|
11508
|
-
ctx = this._getOrReturnCtx(
|
|
11702
|
+
if (input2.data.getTime() < check2.value) {
|
|
11703
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
11509
11704
|
addIssueToContext(ctx, {
|
|
11510
11705
|
code: ZodIssueCode.too_small,
|
|
11511
11706
|
message: check2.message,
|
|
@@ -11517,8 +11712,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
11517
11712
|
status.dirty();
|
|
11518
11713
|
}
|
|
11519
11714
|
} else if (check2.kind === "max") {
|
|
11520
|
-
if (
|
|
11521
|
-
ctx = this._getOrReturnCtx(
|
|
11715
|
+
if (input2.data.getTime() > check2.value) {
|
|
11716
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
11522
11717
|
addIssueToContext(ctx, {
|
|
11523
11718
|
code: ZodIssueCode.too_big,
|
|
11524
11719
|
message: check2.message,
|
|
@@ -11535,7 +11730,7 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
11535
11730
|
}
|
|
11536
11731
|
return {
|
|
11537
11732
|
status: status.value,
|
|
11538
|
-
value: new Date(
|
|
11733
|
+
value: new Date(input2.data.getTime())
|
|
11539
11734
|
};
|
|
11540
11735
|
}
|
|
11541
11736
|
_addCheck(check2) {
|
|
@@ -11588,10 +11783,10 @@ ZodDate.create = (params) => {
|
|
|
11588
11783
|
});
|
|
11589
11784
|
};
|
|
11590
11785
|
var ZodSymbol = class extends ZodType {
|
|
11591
|
-
_parse(
|
|
11592
|
-
const parsedType2 = this._getType(
|
|
11786
|
+
_parse(input2) {
|
|
11787
|
+
const parsedType2 = this._getType(input2);
|
|
11593
11788
|
if (parsedType2 !== ZodParsedType.symbol) {
|
|
11594
|
-
const ctx = this._getOrReturnCtx(
|
|
11789
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
11595
11790
|
addIssueToContext(ctx, {
|
|
11596
11791
|
code: ZodIssueCode.invalid_type,
|
|
11597
11792
|
expected: ZodParsedType.symbol,
|
|
@@ -11599,7 +11794,7 @@ var ZodSymbol = class extends ZodType {
|
|
|
11599
11794
|
});
|
|
11600
11795
|
return INVALID;
|
|
11601
11796
|
}
|
|
11602
|
-
return OK(
|
|
11797
|
+
return OK(input2.data);
|
|
11603
11798
|
}
|
|
11604
11799
|
};
|
|
11605
11800
|
ZodSymbol.create = (params) => {
|
|
@@ -11609,10 +11804,10 @@ ZodSymbol.create = (params) => {
|
|
|
11609
11804
|
});
|
|
11610
11805
|
};
|
|
11611
11806
|
var ZodUndefined = class extends ZodType {
|
|
11612
|
-
_parse(
|
|
11613
|
-
const parsedType2 = this._getType(
|
|
11807
|
+
_parse(input2) {
|
|
11808
|
+
const parsedType2 = this._getType(input2);
|
|
11614
11809
|
if (parsedType2 !== ZodParsedType.undefined) {
|
|
11615
|
-
const ctx = this._getOrReturnCtx(
|
|
11810
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
11616
11811
|
addIssueToContext(ctx, {
|
|
11617
11812
|
code: ZodIssueCode.invalid_type,
|
|
11618
11813
|
expected: ZodParsedType.undefined,
|
|
@@ -11620,7 +11815,7 @@ var ZodUndefined = class extends ZodType {
|
|
|
11620
11815
|
});
|
|
11621
11816
|
return INVALID;
|
|
11622
11817
|
}
|
|
11623
|
-
return OK(
|
|
11818
|
+
return OK(input2.data);
|
|
11624
11819
|
}
|
|
11625
11820
|
};
|
|
11626
11821
|
ZodUndefined.create = (params) => {
|
|
@@ -11630,10 +11825,10 @@ ZodUndefined.create = (params) => {
|
|
|
11630
11825
|
});
|
|
11631
11826
|
};
|
|
11632
11827
|
var ZodNull = class extends ZodType {
|
|
11633
|
-
_parse(
|
|
11634
|
-
const parsedType2 = this._getType(
|
|
11828
|
+
_parse(input2) {
|
|
11829
|
+
const parsedType2 = this._getType(input2);
|
|
11635
11830
|
if (parsedType2 !== ZodParsedType.null) {
|
|
11636
|
-
const ctx = this._getOrReturnCtx(
|
|
11831
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
11637
11832
|
addIssueToContext(ctx, {
|
|
11638
11833
|
code: ZodIssueCode.invalid_type,
|
|
11639
11834
|
expected: ZodParsedType.null,
|
|
@@ -11641,7 +11836,7 @@ var ZodNull = class extends ZodType {
|
|
|
11641
11836
|
});
|
|
11642
11837
|
return INVALID;
|
|
11643
11838
|
}
|
|
11644
|
-
return OK(
|
|
11839
|
+
return OK(input2.data);
|
|
11645
11840
|
}
|
|
11646
11841
|
};
|
|
11647
11842
|
ZodNull.create = (params) => {
|
|
@@ -11655,8 +11850,8 @@ var ZodAny = class extends ZodType {
|
|
|
11655
11850
|
super(...arguments);
|
|
11656
11851
|
this._any = true;
|
|
11657
11852
|
}
|
|
11658
|
-
_parse(
|
|
11659
|
-
return OK(
|
|
11853
|
+
_parse(input2) {
|
|
11854
|
+
return OK(input2.data);
|
|
11660
11855
|
}
|
|
11661
11856
|
};
|
|
11662
11857
|
ZodAny.create = (params) => {
|
|
@@ -11670,8 +11865,8 @@ var ZodUnknown = class extends ZodType {
|
|
|
11670
11865
|
super(...arguments);
|
|
11671
11866
|
this._unknown = true;
|
|
11672
11867
|
}
|
|
11673
|
-
_parse(
|
|
11674
|
-
return OK(
|
|
11868
|
+
_parse(input2) {
|
|
11869
|
+
return OK(input2.data);
|
|
11675
11870
|
}
|
|
11676
11871
|
};
|
|
11677
11872
|
ZodUnknown.create = (params) => {
|
|
@@ -11681,8 +11876,8 @@ ZodUnknown.create = (params) => {
|
|
|
11681
11876
|
});
|
|
11682
11877
|
};
|
|
11683
11878
|
var ZodNever = class extends ZodType {
|
|
11684
|
-
_parse(
|
|
11685
|
-
const ctx = this._getOrReturnCtx(
|
|
11879
|
+
_parse(input2) {
|
|
11880
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
11686
11881
|
addIssueToContext(ctx, {
|
|
11687
11882
|
code: ZodIssueCode.invalid_type,
|
|
11688
11883
|
expected: ZodParsedType.never,
|
|
@@ -11698,10 +11893,10 @@ ZodNever.create = (params) => {
|
|
|
11698
11893
|
});
|
|
11699
11894
|
};
|
|
11700
11895
|
var ZodVoid = class extends ZodType {
|
|
11701
|
-
_parse(
|
|
11702
|
-
const parsedType2 = this._getType(
|
|
11896
|
+
_parse(input2) {
|
|
11897
|
+
const parsedType2 = this._getType(input2);
|
|
11703
11898
|
if (parsedType2 !== ZodParsedType.undefined) {
|
|
11704
|
-
const ctx = this._getOrReturnCtx(
|
|
11899
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
11705
11900
|
addIssueToContext(ctx, {
|
|
11706
11901
|
code: ZodIssueCode.invalid_type,
|
|
11707
11902
|
expected: ZodParsedType.void,
|
|
@@ -11709,7 +11904,7 @@ var ZodVoid = class extends ZodType {
|
|
|
11709
11904
|
});
|
|
11710
11905
|
return INVALID;
|
|
11711
11906
|
}
|
|
11712
|
-
return OK(
|
|
11907
|
+
return OK(input2.data);
|
|
11713
11908
|
}
|
|
11714
11909
|
};
|
|
11715
11910
|
ZodVoid.create = (params) => {
|
|
@@ -11719,8 +11914,8 @@ ZodVoid.create = (params) => {
|
|
|
11719
11914
|
});
|
|
11720
11915
|
};
|
|
11721
11916
|
var ZodArray = class _ZodArray extends ZodType {
|
|
11722
|
-
_parse(
|
|
11723
|
-
const { ctx, status } = this._processInputParams(
|
|
11917
|
+
_parse(input2) {
|
|
11918
|
+
const { ctx, status } = this._processInputParams(input2);
|
|
11724
11919
|
const def = this._def;
|
|
11725
11920
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
11726
11921
|
addIssueToContext(ctx, {
|
|
@@ -11860,10 +12055,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
11860
12055
|
this._cached = { shape, keys };
|
|
11861
12056
|
return this._cached;
|
|
11862
12057
|
}
|
|
11863
|
-
_parse(
|
|
11864
|
-
const parsedType2 = this._getType(
|
|
12058
|
+
_parse(input2) {
|
|
12059
|
+
const parsedType2 = this._getType(input2);
|
|
11865
12060
|
if (parsedType2 !== ZodParsedType.object) {
|
|
11866
|
-
const ctx2 = this._getOrReturnCtx(
|
|
12061
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
11867
12062
|
addIssueToContext(ctx2, {
|
|
11868
12063
|
code: ZodIssueCode.invalid_type,
|
|
11869
12064
|
expected: ZodParsedType.object,
|
|
@@ -11871,7 +12066,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
11871
12066
|
});
|
|
11872
12067
|
return INVALID;
|
|
11873
12068
|
}
|
|
11874
|
-
const { status, ctx } = this._processInputParams(
|
|
12069
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
11875
12070
|
const { shape, keys: shapeKeys } = this._getCached();
|
|
11876
12071
|
const extraKeys = [];
|
|
11877
12072
|
if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
|
|
@@ -12184,8 +12379,8 @@ ZodObject.lazycreate = (shape, params) => {
|
|
|
12184
12379
|
});
|
|
12185
12380
|
};
|
|
12186
12381
|
var ZodUnion = class extends ZodType {
|
|
12187
|
-
_parse(
|
|
12188
|
-
const { ctx } = this._processInputParams(
|
|
12382
|
+
_parse(input2) {
|
|
12383
|
+
const { ctx } = this._processInputParams(input2);
|
|
12189
12384
|
const options = this._def.options;
|
|
12190
12385
|
function handleResults(results) {
|
|
12191
12386
|
for (const result of results) {
|
|
@@ -12306,8 +12501,8 @@ var getDiscriminator = (type) => {
|
|
|
12306
12501
|
}
|
|
12307
12502
|
};
|
|
12308
12503
|
var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
12309
|
-
_parse(
|
|
12310
|
-
const { ctx } = this._processInputParams(
|
|
12504
|
+
_parse(input2) {
|
|
12505
|
+
const { ctx } = this._processInputParams(input2);
|
|
12311
12506
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
12312
12507
|
addIssueToContext(ctx, {
|
|
12313
12508
|
code: ZodIssueCode.invalid_type,
|
|
@@ -12420,8 +12615,8 @@ function mergeValues(a, b) {
|
|
|
12420
12615
|
}
|
|
12421
12616
|
}
|
|
12422
12617
|
var ZodIntersection = class extends ZodType {
|
|
12423
|
-
_parse(
|
|
12424
|
-
const { status, ctx } = this._processInputParams(
|
|
12618
|
+
_parse(input2) {
|
|
12619
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
12425
12620
|
const handleParsed = (parsedLeft, parsedRight) => {
|
|
12426
12621
|
if (isAborted(parsedLeft) || isAborted(parsedRight)) {
|
|
12427
12622
|
return INVALID;
|
|
@@ -12473,8 +12668,8 @@ ZodIntersection.create = (left, right, params) => {
|
|
|
12473
12668
|
});
|
|
12474
12669
|
};
|
|
12475
12670
|
var ZodTuple = class _ZodTuple extends ZodType {
|
|
12476
|
-
_parse(
|
|
12477
|
-
const { status, ctx } = this._processInputParams(
|
|
12671
|
+
_parse(input2) {
|
|
12672
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
12478
12673
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
12479
12674
|
addIssueToContext(ctx, {
|
|
12480
12675
|
code: ZodIssueCode.invalid_type,
|
|
@@ -12546,8 +12741,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
|
12546
12741
|
get valueSchema() {
|
|
12547
12742
|
return this._def.valueType;
|
|
12548
12743
|
}
|
|
12549
|
-
_parse(
|
|
12550
|
-
const { status, ctx } = this._processInputParams(
|
|
12744
|
+
_parse(input2) {
|
|
12745
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
12551
12746
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
12552
12747
|
addIssueToContext(ctx, {
|
|
12553
12748
|
code: ZodIssueCode.invalid_type,
|
|
@@ -12599,8 +12794,8 @@ var ZodMap = class extends ZodType {
|
|
|
12599
12794
|
get valueSchema() {
|
|
12600
12795
|
return this._def.valueType;
|
|
12601
12796
|
}
|
|
12602
|
-
_parse(
|
|
12603
|
-
const { status, ctx } = this._processInputParams(
|
|
12797
|
+
_parse(input2) {
|
|
12798
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
12604
12799
|
if (ctx.parsedType !== ZodParsedType.map) {
|
|
12605
12800
|
addIssueToContext(ctx, {
|
|
12606
12801
|
code: ZodIssueCode.invalid_type,
|
|
@@ -12659,8 +12854,8 @@ ZodMap.create = (keyType, valueType, params) => {
|
|
|
12659
12854
|
});
|
|
12660
12855
|
};
|
|
12661
12856
|
var ZodSet = class _ZodSet extends ZodType {
|
|
12662
|
-
_parse(
|
|
12663
|
-
const { status, ctx } = this._processInputParams(
|
|
12857
|
+
_parse(input2) {
|
|
12858
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
12664
12859
|
if (ctx.parsedType !== ZodParsedType.set) {
|
|
12665
12860
|
addIssueToContext(ctx, {
|
|
12666
12861
|
code: ZodIssueCode.invalid_type,
|
|
@@ -12748,8 +12943,8 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
12748
12943
|
super(...arguments);
|
|
12749
12944
|
this.validate = this.implement;
|
|
12750
12945
|
}
|
|
12751
|
-
_parse(
|
|
12752
|
-
const { ctx } = this._processInputParams(
|
|
12946
|
+
_parse(input2) {
|
|
12947
|
+
const { ctx } = this._processInputParams(input2);
|
|
12753
12948
|
if (ctx.parsedType !== ZodParsedType.function) {
|
|
12754
12949
|
addIssueToContext(ctx, {
|
|
12755
12950
|
code: ZodIssueCode.invalid_type,
|
|
@@ -12852,8 +13047,8 @@ var ZodLazy = class extends ZodType {
|
|
|
12852
13047
|
get schema() {
|
|
12853
13048
|
return this._def.getter();
|
|
12854
13049
|
}
|
|
12855
|
-
_parse(
|
|
12856
|
-
const { ctx } = this._processInputParams(
|
|
13050
|
+
_parse(input2) {
|
|
13051
|
+
const { ctx } = this._processInputParams(input2);
|
|
12857
13052
|
const lazySchema = this._def.getter();
|
|
12858
13053
|
return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
|
|
12859
13054
|
}
|
|
@@ -12866,9 +13061,9 @@ ZodLazy.create = (getter, params) => {
|
|
|
12866
13061
|
});
|
|
12867
13062
|
};
|
|
12868
13063
|
var ZodLiteral = class extends ZodType {
|
|
12869
|
-
_parse(
|
|
12870
|
-
if (
|
|
12871
|
-
const ctx = this._getOrReturnCtx(
|
|
13064
|
+
_parse(input2) {
|
|
13065
|
+
if (input2.data !== this._def.value) {
|
|
13066
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
12872
13067
|
addIssueToContext(ctx, {
|
|
12873
13068
|
received: ctx.data,
|
|
12874
13069
|
code: ZodIssueCode.invalid_literal,
|
|
@@ -12876,7 +13071,7 @@ var ZodLiteral = class extends ZodType {
|
|
|
12876
13071
|
});
|
|
12877
13072
|
return INVALID;
|
|
12878
13073
|
}
|
|
12879
|
-
return { status: "valid", value:
|
|
13074
|
+
return { status: "valid", value: input2.data };
|
|
12880
13075
|
}
|
|
12881
13076
|
get value() {
|
|
12882
13077
|
return this._def.value;
|
|
@@ -12897,9 +13092,9 @@ function createZodEnum(values, params) {
|
|
|
12897
13092
|
});
|
|
12898
13093
|
}
|
|
12899
13094
|
var ZodEnum = class _ZodEnum extends ZodType {
|
|
12900
|
-
_parse(
|
|
12901
|
-
if (typeof
|
|
12902
|
-
const ctx = this._getOrReturnCtx(
|
|
13095
|
+
_parse(input2) {
|
|
13096
|
+
if (typeof input2.data !== "string") {
|
|
13097
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
12903
13098
|
const expectedValues = this._def.values;
|
|
12904
13099
|
addIssueToContext(ctx, {
|
|
12905
13100
|
expected: util.joinValues(expectedValues),
|
|
@@ -12911,8 +13106,8 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
12911
13106
|
if (!this._cache) {
|
|
12912
13107
|
this._cache = new Set(this._def.values);
|
|
12913
13108
|
}
|
|
12914
|
-
if (!this._cache.has(
|
|
12915
|
-
const ctx = this._getOrReturnCtx(
|
|
13109
|
+
if (!this._cache.has(input2.data)) {
|
|
13110
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
12916
13111
|
const expectedValues = this._def.values;
|
|
12917
13112
|
addIssueToContext(ctx, {
|
|
12918
13113
|
received: ctx.data,
|
|
@@ -12921,7 +13116,7 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
12921
13116
|
});
|
|
12922
13117
|
return INVALID;
|
|
12923
13118
|
}
|
|
12924
|
-
return OK(
|
|
13119
|
+
return OK(input2.data);
|
|
12925
13120
|
}
|
|
12926
13121
|
get options() {
|
|
12927
13122
|
return this._def.values;
|
|
@@ -12962,9 +13157,9 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
12962
13157
|
};
|
|
12963
13158
|
ZodEnum.create = createZodEnum;
|
|
12964
13159
|
var ZodNativeEnum = class extends ZodType {
|
|
12965
|
-
_parse(
|
|
13160
|
+
_parse(input2) {
|
|
12966
13161
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
12967
|
-
const ctx = this._getOrReturnCtx(
|
|
13162
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
12968
13163
|
if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
|
|
12969
13164
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
12970
13165
|
addIssueToContext(ctx, {
|
|
@@ -12977,7 +13172,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
12977
13172
|
if (!this._cache) {
|
|
12978
13173
|
this._cache = new Set(util.getValidEnumValues(this._def.values));
|
|
12979
13174
|
}
|
|
12980
|
-
if (!this._cache.has(
|
|
13175
|
+
if (!this._cache.has(input2.data)) {
|
|
12981
13176
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
12982
13177
|
addIssueToContext(ctx, {
|
|
12983
13178
|
received: ctx.data,
|
|
@@ -12986,7 +13181,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
12986
13181
|
});
|
|
12987
13182
|
return INVALID;
|
|
12988
13183
|
}
|
|
12989
|
-
return OK(
|
|
13184
|
+
return OK(input2.data);
|
|
12990
13185
|
}
|
|
12991
13186
|
get enum() {
|
|
12992
13187
|
return this._def.values;
|
|
@@ -13003,8 +13198,8 @@ var ZodPromise = class extends ZodType {
|
|
|
13003
13198
|
unwrap() {
|
|
13004
13199
|
return this._def.type;
|
|
13005
13200
|
}
|
|
13006
|
-
_parse(
|
|
13007
|
-
const { ctx } = this._processInputParams(
|
|
13201
|
+
_parse(input2) {
|
|
13202
|
+
const { ctx } = this._processInputParams(input2);
|
|
13008
13203
|
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
|
|
13009
13204
|
addIssueToContext(ctx, {
|
|
13010
13205
|
code: ZodIssueCode.invalid_type,
|
|
@@ -13036,8 +13231,8 @@ var ZodEffects = class extends ZodType {
|
|
|
13036
13231
|
sourceType() {
|
|
13037
13232
|
return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
13038
13233
|
}
|
|
13039
|
-
_parse(
|
|
13040
|
-
const { status, ctx } = this._processInputParams(
|
|
13234
|
+
_parse(input2) {
|
|
13235
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
13041
13236
|
const effect = this._def.effect || null;
|
|
13042
13237
|
const checkCtx = {
|
|
13043
13238
|
addIssue: (arg) => {
|
|
@@ -13169,12 +13364,12 @@ ZodEffects.createWithPreprocess = (preprocess2, schema, params) => {
|
|
|
13169
13364
|
});
|
|
13170
13365
|
};
|
|
13171
13366
|
var ZodOptional = class extends ZodType {
|
|
13172
|
-
_parse(
|
|
13173
|
-
const parsedType2 = this._getType(
|
|
13367
|
+
_parse(input2) {
|
|
13368
|
+
const parsedType2 = this._getType(input2);
|
|
13174
13369
|
if (parsedType2 === ZodParsedType.undefined) {
|
|
13175
13370
|
return OK(void 0);
|
|
13176
13371
|
}
|
|
13177
|
-
return this._def.innerType._parse(
|
|
13372
|
+
return this._def.innerType._parse(input2);
|
|
13178
13373
|
}
|
|
13179
13374
|
unwrap() {
|
|
13180
13375
|
return this._def.innerType;
|
|
@@ -13188,12 +13383,12 @@ ZodOptional.create = (type, params) => {
|
|
|
13188
13383
|
});
|
|
13189
13384
|
};
|
|
13190
13385
|
var ZodNullable = class extends ZodType {
|
|
13191
|
-
_parse(
|
|
13192
|
-
const parsedType2 = this._getType(
|
|
13386
|
+
_parse(input2) {
|
|
13387
|
+
const parsedType2 = this._getType(input2);
|
|
13193
13388
|
if (parsedType2 === ZodParsedType.null) {
|
|
13194
13389
|
return OK(null);
|
|
13195
13390
|
}
|
|
13196
|
-
return this._def.innerType._parse(
|
|
13391
|
+
return this._def.innerType._parse(input2);
|
|
13197
13392
|
}
|
|
13198
13393
|
unwrap() {
|
|
13199
13394
|
return this._def.innerType;
|
|
@@ -13207,8 +13402,8 @@ ZodNullable.create = (type, params) => {
|
|
|
13207
13402
|
});
|
|
13208
13403
|
};
|
|
13209
13404
|
var ZodDefault = class extends ZodType {
|
|
13210
|
-
_parse(
|
|
13211
|
-
const { ctx } = this._processInputParams(
|
|
13405
|
+
_parse(input2) {
|
|
13406
|
+
const { ctx } = this._processInputParams(input2);
|
|
13212
13407
|
let data = ctx.data;
|
|
13213
13408
|
if (ctx.parsedType === ZodParsedType.undefined) {
|
|
13214
13409
|
data = this._def.defaultValue();
|
|
@@ -13232,8 +13427,8 @@ ZodDefault.create = (type, params) => {
|
|
|
13232
13427
|
});
|
|
13233
13428
|
};
|
|
13234
13429
|
var ZodCatch = class extends ZodType {
|
|
13235
|
-
_parse(
|
|
13236
|
-
const { ctx } = this._processInputParams(
|
|
13430
|
+
_parse(input2) {
|
|
13431
|
+
const { ctx } = this._processInputParams(input2);
|
|
13237
13432
|
const newCtx = {
|
|
13238
13433
|
...ctx,
|
|
13239
13434
|
common: {
|
|
@@ -13285,10 +13480,10 @@ ZodCatch.create = (type, params) => {
|
|
|
13285
13480
|
});
|
|
13286
13481
|
};
|
|
13287
13482
|
var ZodNaN = class extends ZodType {
|
|
13288
|
-
_parse(
|
|
13289
|
-
const parsedType2 = this._getType(
|
|
13483
|
+
_parse(input2) {
|
|
13484
|
+
const parsedType2 = this._getType(input2);
|
|
13290
13485
|
if (parsedType2 !== ZodParsedType.nan) {
|
|
13291
|
-
const ctx = this._getOrReturnCtx(
|
|
13486
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
13292
13487
|
addIssueToContext(ctx, {
|
|
13293
13488
|
code: ZodIssueCode.invalid_type,
|
|
13294
13489
|
expected: ZodParsedType.nan,
|
|
@@ -13296,7 +13491,7 @@ var ZodNaN = class extends ZodType {
|
|
|
13296
13491
|
});
|
|
13297
13492
|
return INVALID;
|
|
13298
13493
|
}
|
|
13299
|
-
return { status: "valid", value:
|
|
13494
|
+
return { status: "valid", value: input2.data };
|
|
13300
13495
|
}
|
|
13301
13496
|
};
|
|
13302
13497
|
ZodNaN.create = (params) => {
|
|
@@ -13306,8 +13501,8 @@ ZodNaN.create = (params) => {
|
|
|
13306
13501
|
});
|
|
13307
13502
|
};
|
|
13308
13503
|
var ZodBranded = class extends ZodType {
|
|
13309
|
-
_parse(
|
|
13310
|
-
const { ctx } = this._processInputParams(
|
|
13504
|
+
_parse(input2) {
|
|
13505
|
+
const { ctx } = this._processInputParams(input2);
|
|
13311
13506
|
const data = ctx.data;
|
|
13312
13507
|
return this._def.type._parse({
|
|
13313
13508
|
data,
|
|
@@ -13320,8 +13515,8 @@ var ZodBranded = class extends ZodType {
|
|
|
13320
13515
|
}
|
|
13321
13516
|
};
|
|
13322
13517
|
var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
13323
|
-
_parse(
|
|
13324
|
-
const { status, ctx } = this._processInputParams(
|
|
13518
|
+
_parse(input2) {
|
|
13519
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
13325
13520
|
if (ctx.common.async) {
|
|
13326
13521
|
const handleAsync = async () => {
|
|
13327
13522
|
const inResult = await this._def.in._parseAsync({
|
|
@@ -13375,8 +13570,8 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
13375
13570
|
}
|
|
13376
13571
|
};
|
|
13377
13572
|
var ZodReadonly = class extends ZodType {
|
|
13378
|
-
_parse(
|
|
13379
|
-
const result = this._def.innerType._parse(
|
|
13573
|
+
_parse(input2) {
|
|
13574
|
+
const result = this._def.innerType._parse(input2);
|
|
13380
13575
|
const freeze = (data) => {
|
|
13381
13576
|
if (isValid(data)) {
|
|
13382
13577
|
data.value = Object.freeze(data.value);
|
|
@@ -13931,8 +14126,8 @@ function cached(getter) {
|
|
|
13931
14126
|
}
|
|
13932
14127
|
};
|
|
13933
14128
|
}
|
|
13934
|
-
function nullish(
|
|
13935
|
-
return
|
|
14129
|
+
function nullish(input2) {
|
|
14130
|
+
return input2 === null || input2 === void 0;
|
|
13936
14131
|
}
|
|
13937
14132
|
function cleanRegex(source) {
|
|
13938
14133
|
const start = source.startsWith("^") ? 1 : 0;
|
|
@@ -14026,8 +14221,8 @@ function randomString(length = 10) {
|
|
|
14026
14221
|
function esc(str) {
|
|
14027
14222
|
return JSON.stringify(str);
|
|
14028
14223
|
}
|
|
14029
|
-
function slugify(
|
|
14030
|
-
return
|
|
14224
|
+
function slugify(input2) {
|
|
14225
|
+
return input2.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
14031
14226
|
}
|
|
14032
14227
|
var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
|
|
14033
14228
|
};
|
|
@@ -14409,19 +14604,19 @@ function finalizeIssue(iss, ctx, config2) {
|
|
|
14409
14604
|
}
|
|
14410
14605
|
return full;
|
|
14411
14606
|
}
|
|
14412
|
-
function getSizableOrigin(
|
|
14413
|
-
if (
|
|
14607
|
+
function getSizableOrigin(input2) {
|
|
14608
|
+
if (input2 instanceof Set)
|
|
14414
14609
|
return "set";
|
|
14415
|
-
if (
|
|
14610
|
+
if (input2 instanceof Map)
|
|
14416
14611
|
return "map";
|
|
14417
|
-
if (
|
|
14612
|
+
if (input2 instanceof File)
|
|
14418
14613
|
return "file";
|
|
14419
14614
|
return "unknown";
|
|
14420
14615
|
}
|
|
14421
|
-
function getLengthableOrigin(
|
|
14422
|
-
if (Array.isArray(
|
|
14616
|
+
function getLengthableOrigin(input2) {
|
|
14617
|
+
if (Array.isArray(input2))
|
|
14423
14618
|
return "array";
|
|
14424
|
-
if (typeof
|
|
14619
|
+
if (typeof input2 === "string")
|
|
14425
14620
|
return "string";
|
|
14426
14621
|
return "unknown";
|
|
14427
14622
|
}
|
|
@@ -14447,12 +14642,12 @@ function parsedType(data) {
|
|
|
14447
14642
|
return t;
|
|
14448
14643
|
}
|
|
14449
14644
|
function issue(...args) {
|
|
14450
|
-
const [iss,
|
|
14645
|
+
const [iss, input2, inst] = args;
|
|
14451
14646
|
if (typeof iss === "string") {
|
|
14452
14647
|
return {
|
|
14453
14648
|
message: iss,
|
|
14454
14649
|
code: "custom",
|
|
14455
|
-
input,
|
|
14650
|
+
input: input2,
|
|
14456
14651
|
inst
|
|
14457
14652
|
};
|
|
14458
14653
|
}
|
|
@@ -14991,23 +15186,23 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
14991
15186
|
bag.pattern = integer;
|
|
14992
15187
|
});
|
|
14993
15188
|
inst._zod.check = (payload) => {
|
|
14994
|
-
const
|
|
15189
|
+
const input2 = payload.value;
|
|
14995
15190
|
if (isInt) {
|
|
14996
|
-
if (!Number.isInteger(
|
|
15191
|
+
if (!Number.isInteger(input2)) {
|
|
14997
15192
|
payload.issues.push({
|
|
14998
15193
|
expected: origin,
|
|
14999
15194
|
format: def.format,
|
|
15000
15195
|
code: "invalid_type",
|
|
15001
15196
|
continue: false,
|
|
15002
|
-
input,
|
|
15197
|
+
input: input2,
|
|
15003
15198
|
inst
|
|
15004
15199
|
});
|
|
15005
15200
|
return;
|
|
15006
15201
|
}
|
|
15007
|
-
if (!Number.isSafeInteger(
|
|
15008
|
-
if (
|
|
15202
|
+
if (!Number.isSafeInteger(input2)) {
|
|
15203
|
+
if (input2 > 0) {
|
|
15009
15204
|
payload.issues.push({
|
|
15010
|
-
input,
|
|
15205
|
+
input: input2,
|
|
15011
15206
|
code: "too_big",
|
|
15012
15207
|
maximum: Number.MAX_SAFE_INTEGER,
|
|
15013
15208
|
note: "Integers must be within the safe integer range.",
|
|
@@ -15018,7 +15213,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
15018
15213
|
});
|
|
15019
15214
|
} else {
|
|
15020
15215
|
payload.issues.push({
|
|
15021
|
-
input,
|
|
15216
|
+
input: input2,
|
|
15022
15217
|
code: "too_small",
|
|
15023
15218
|
minimum: Number.MIN_SAFE_INTEGER,
|
|
15024
15219
|
note: "Integers must be within the safe integer range.",
|
|
@@ -15031,10 +15226,10 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
15031
15226
|
return;
|
|
15032
15227
|
}
|
|
15033
15228
|
}
|
|
15034
|
-
if (
|
|
15229
|
+
if (input2 < minimum) {
|
|
15035
15230
|
payload.issues.push({
|
|
15036
15231
|
origin: "number",
|
|
15037
|
-
input,
|
|
15232
|
+
input: input2,
|
|
15038
15233
|
code: "too_small",
|
|
15039
15234
|
minimum,
|
|
15040
15235
|
inclusive: true,
|
|
@@ -15042,10 +15237,10 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
15042
15237
|
continue: !def.abort
|
|
15043
15238
|
});
|
|
15044
15239
|
}
|
|
15045
|
-
if (
|
|
15240
|
+
if (input2 > maximum) {
|
|
15046
15241
|
payload.issues.push({
|
|
15047
15242
|
origin: "number",
|
|
15048
|
-
input,
|
|
15243
|
+
input: input2,
|
|
15049
15244
|
code: "too_big",
|
|
15050
15245
|
maximum,
|
|
15051
15246
|
inclusive: true,
|
|
@@ -15065,11 +15260,11 @@ var $ZodCheckBigIntFormat = /* @__PURE__ */ $constructor("$ZodCheckBigIntFormat"
|
|
|
15065
15260
|
bag.maximum = maximum;
|
|
15066
15261
|
});
|
|
15067
15262
|
inst._zod.check = (payload) => {
|
|
15068
|
-
const
|
|
15069
|
-
if (
|
|
15263
|
+
const input2 = payload.value;
|
|
15264
|
+
if (input2 < minimum) {
|
|
15070
15265
|
payload.issues.push({
|
|
15071
15266
|
origin: "bigint",
|
|
15072
|
-
input,
|
|
15267
|
+
input: input2,
|
|
15073
15268
|
code: "too_small",
|
|
15074
15269
|
minimum,
|
|
15075
15270
|
inclusive: true,
|
|
@@ -15077,10 +15272,10 @@ var $ZodCheckBigIntFormat = /* @__PURE__ */ $constructor("$ZodCheckBigIntFormat"
|
|
|
15077
15272
|
continue: !def.abort
|
|
15078
15273
|
});
|
|
15079
15274
|
}
|
|
15080
|
-
if (
|
|
15275
|
+
if (input2 > maximum) {
|
|
15081
15276
|
payload.issues.push({
|
|
15082
15277
|
origin: "bigint",
|
|
15083
|
-
input,
|
|
15278
|
+
input: input2,
|
|
15084
15279
|
code: "too_big",
|
|
15085
15280
|
maximum,
|
|
15086
15281
|
inclusive: true,
|
|
@@ -15103,16 +15298,16 @@ var $ZodCheckMaxSize = /* @__PURE__ */ $constructor("$ZodCheckMaxSize", (inst, d
|
|
|
15103
15298
|
inst2._zod.bag.maximum = def.maximum;
|
|
15104
15299
|
});
|
|
15105
15300
|
inst._zod.check = (payload) => {
|
|
15106
|
-
const
|
|
15107
|
-
const size =
|
|
15301
|
+
const input2 = payload.value;
|
|
15302
|
+
const size = input2.size;
|
|
15108
15303
|
if (size <= def.maximum)
|
|
15109
15304
|
return;
|
|
15110
15305
|
payload.issues.push({
|
|
15111
|
-
origin: getSizableOrigin(
|
|
15306
|
+
origin: getSizableOrigin(input2),
|
|
15112
15307
|
code: "too_big",
|
|
15113
15308
|
maximum: def.maximum,
|
|
15114
15309
|
inclusive: true,
|
|
15115
|
-
input,
|
|
15310
|
+
input: input2,
|
|
15116
15311
|
inst,
|
|
15117
15312
|
continue: !def.abort
|
|
15118
15313
|
});
|
|
@@ -15131,16 +15326,16 @@ var $ZodCheckMinSize = /* @__PURE__ */ $constructor("$ZodCheckMinSize", (inst, d
|
|
|
15131
15326
|
inst2._zod.bag.minimum = def.minimum;
|
|
15132
15327
|
});
|
|
15133
15328
|
inst._zod.check = (payload) => {
|
|
15134
|
-
const
|
|
15135
|
-
const size =
|
|
15329
|
+
const input2 = payload.value;
|
|
15330
|
+
const size = input2.size;
|
|
15136
15331
|
if (size >= def.minimum)
|
|
15137
15332
|
return;
|
|
15138
15333
|
payload.issues.push({
|
|
15139
|
-
origin: getSizableOrigin(
|
|
15334
|
+
origin: getSizableOrigin(input2),
|
|
15140
15335
|
code: "too_small",
|
|
15141
15336
|
minimum: def.minimum,
|
|
15142
15337
|
inclusive: true,
|
|
15143
|
-
input,
|
|
15338
|
+
input: input2,
|
|
15144
15339
|
inst,
|
|
15145
15340
|
continue: !def.abort
|
|
15146
15341
|
});
|
|
@@ -15160,13 +15355,13 @@ var $ZodCheckSizeEquals = /* @__PURE__ */ $constructor("$ZodCheckSizeEquals", (i
|
|
|
15160
15355
|
bag.size = def.size;
|
|
15161
15356
|
});
|
|
15162
15357
|
inst._zod.check = (payload) => {
|
|
15163
|
-
const
|
|
15164
|
-
const size =
|
|
15358
|
+
const input2 = payload.value;
|
|
15359
|
+
const size = input2.size;
|
|
15165
15360
|
if (size === def.size)
|
|
15166
15361
|
return;
|
|
15167
15362
|
const tooBig = size > def.size;
|
|
15168
15363
|
payload.issues.push({
|
|
15169
|
-
origin: getSizableOrigin(
|
|
15364
|
+
origin: getSizableOrigin(input2),
|
|
15170
15365
|
...tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size },
|
|
15171
15366
|
inclusive: true,
|
|
15172
15367
|
exact: true,
|
|
@@ -15189,17 +15384,17 @@ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (ins
|
|
|
15189
15384
|
inst2._zod.bag.maximum = def.maximum;
|
|
15190
15385
|
});
|
|
15191
15386
|
inst._zod.check = (payload) => {
|
|
15192
|
-
const
|
|
15193
|
-
const length =
|
|
15387
|
+
const input2 = payload.value;
|
|
15388
|
+
const length = input2.length;
|
|
15194
15389
|
if (length <= def.maximum)
|
|
15195
15390
|
return;
|
|
15196
|
-
const origin = getLengthableOrigin(
|
|
15391
|
+
const origin = getLengthableOrigin(input2);
|
|
15197
15392
|
payload.issues.push({
|
|
15198
15393
|
origin,
|
|
15199
15394
|
code: "too_big",
|
|
15200
15395
|
maximum: def.maximum,
|
|
15201
15396
|
inclusive: true,
|
|
15202
|
-
input,
|
|
15397
|
+
input: input2,
|
|
15203
15398
|
inst,
|
|
15204
15399
|
continue: !def.abort
|
|
15205
15400
|
});
|
|
@@ -15218,17 +15413,17 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
|
|
|
15218
15413
|
inst2._zod.bag.minimum = def.minimum;
|
|
15219
15414
|
});
|
|
15220
15415
|
inst._zod.check = (payload) => {
|
|
15221
|
-
const
|
|
15222
|
-
const length =
|
|
15416
|
+
const input2 = payload.value;
|
|
15417
|
+
const length = input2.length;
|
|
15223
15418
|
if (length >= def.minimum)
|
|
15224
15419
|
return;
|
|
15225
|
-
const origin = getLengthableOrigin(
|
|
15420
|
+
const origin = getLengthableOrigin(input2);
|
|
15226
15421
|
payload.issues.push({
|
|
15227
15422
|
origin,
|
|
15228
15423
|
code: "too_small",
|
|
15229
15424
|
minimum: def.minimum,
|
|
15230
15425
|
inclusive: true,
|
|
15231
|
-
input,
|
|
15426
|
+
input: input2,
|
|
15232
15427
|
inst,
|
|
15233
15428
|
continue: !def.abort
|
|
15234
15429
|
});
|
|
@@ -15248,11 +15443,11 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
|
|
|
15248
15443
|
bag.length = def.length;
|
|
15249
15444
|
});
|
|
15250
15445
|
inst._zod.check = (payload) => {
|
|
15251
|
-
const
|
|
15252
|
-
const length =
|
|
15446
|
+
const input2 = payload.value;
|
|
15447
|
+
const length = input2.length;
|
|
15253
15448
|
if (length === def.length)
|
|
15254
15449
|
return;
|
|
15255
|
-
const origin = getLengthableOrigin(
|
|
15450
|
+
const origin = getLengthableOrigin(input2);
|
|
15256
15451
|
const tooBig = length > def.length;
|
|
15257
15452
|
payload.issues.push({
|
|
15258
15453
|
origin,
|
|
@@ -15906,15 +16101,15 @@ var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
|
15906
16101
|
payload.value = Number(payload.value);
|
|
15907
16102
|
} catch (_) {
|
|
15908
16103
|
}
|
|
15909
|
-
const
|
|
15910
|
-
if (typeof
|
|
16104
|
+
const input2 = payload.value;
|
|
16105
|
+
if (typeof input2 === "number" && !Number.isNaN(input2) && Number.isFinite(input2)) {
|
|
15911
16106
|
return payload;
|
|
15912
16107
|
}
|
|
15913
|
-
const received = typeof
|
|
16108
|
+
const received = typeof input2 === "number" ? Number.isNaN(input2) ? "NaN" : !Number.isFinite(input2) ? "Infinity" : void 0 : void 0;
|
|
15914
16109
|
payload.issues.push({
|
|
15915
16110
|
expected: "number",
|
|
15916
16111
|
code: "invalid_type",
|
|
15917
|
-
input,
|
|
16112
|
+
input: input2,
|
|
15918
16113
|
inst,
|
|
15919
16114
|
...received ? { received } : {}
|
|
15920
16115
|
});
|
|
@@ -15934,13 +16129,13 @@ var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
|
|
|
15934
16129
|
payload.value = Boolean(payload.value);
|
|
15935
16130
|
} catch (_) {
|
|
15936
16131
|
}
|
|
15937
|
-
const
|
|
15938
|
-
if (typeof
|
|
16132
|
+
const input2 = payload.value;
|
|
16133
|
+
if (typeof input2 === "boolean")
|
|
15939
16134
|
return payload;
|
|
15940
16135
|
payload.issues.push({
|
|
15941
16136
|
expected: "boolean",
|
|
15942
16137
|
code: "invalid_type",
|
|
15943
|
-
input,
|
|
16138
|
+
input: input2,
|
|
15944
16139
|
inst
|
|
15945
16140
|
});
|
|
15946
16141
|
return payload;
|
|
@@ -15973,13 +16168,13 @@ var $ZodBigIntFormat = /* @__PURE__ */ $constructor("$ZodBigIntFormat", (inst, d
|
|
|
15973
16168
|
var $ZodSymbol = /* @__PURE__ */ $constructor("$ZodSymbol", (inst, def) => {
|
|
15974
16169
|
$ZodType.init(inst, def);
|
|
15975
16170
|
inst._zod.parse = (payload, _ctx) => {
|
|
15976
|
-
const
|
|
15977
|
-
if (typeof
|
|
16171
|
+
const input2 = payload.value;
|
|
16172
|
+
if (typeof input2 === "symbol")
|
|
15978
16173
|
return payload;
|
|
15979
16174
|
payload.issues.push({
|
|
15980
16175
|
expected: "symbol",
|
|
15981
16176
|
code: "invalid_type",
|
|
15982
|
-
input,
|
|
16177
|
+
input: input2,
|
|
15983
16178
|
inst
|
|
15984
16179
|
});
|
|
15985
16180
|
return payload;
|
|
@@ -15992,13 +16187,13 @@ var $ZodUndefined = /* @__PURE__ */ $constructor("$ZodUndefined", (inst, def) =>
|
|
|
15992
16187
|
inst._zod.optin = "optional";
|
|
15993
16188
|
inst._zod.optout = "optional";
|
|
15994
16189
|
inst._zod.parse = (payload, _ctx) => {
|
|
15995
|
-
const
|
|
15996
|
-
if (typeof
|
|
16190
|
+
const input2 = payload.value;
|
|
16191
|
+
if (typeof input2 === "undefined")
|
|
15997
16192
|
return payload;
|
|
15998
16193
|
payload.issues.push({
|
|
15999
16194
|
expected: "undefined",
|
|
16000
16195
|
code: "invalid_type",
|
|
16001
|
-
input,
|
|
16196
|
+
input: input2,
|
|
16002
16197
|
inst
|
|
16003
16198
|
});
|
|
16004
16199
|
return payload;
|
|
@@ -16009,13 +16204,13 @@ var $ZodNull = /* @__PURE__ */ $constructor("$ZodNull", (inst, def) => {
|
|
|
16009
16204
|
inst._zod.pattern = _null;
|
|
16010
16205
|
inst._zod.values = /* @__PURE__ */ new Set([null]);
|
|
16011
16206
|
inst._zod.parse = (payload, _ctx) => {
|
|
16012
|
-
const
|
|
16013
|
-
if (
|
|
16207
|
+
const input2 = payload.value;
|
|
16208
|
+
if (input2 === null)
|
|
16014
16209
|
return payload;
|
|
16015
16210
|
payload.issues.push({
|
|
16016
16211
|
expected: "null",
|
|
16017
16212
|
code: "invalid_type",
|
|
16018
|
-
input,
|
|
16213
|
+
input: input2,
|
|
16019
16214
|
inst
|
|
16020
16215
|
});
|
|
16021
16216
|
return payload;
|
|
@@ -16044,13 +16239,13 @@ var $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
|
|
|
16044
16239
|
var $ZodVoid = /* @__PURE__ */ $constructor("$ZodVoid", (inst, def) => {
|
|
16045
16240
|
$ZodType.init(inst, def);
|
|
16046
16241
|
inst._zod.parse = (payload, _ctx) => {
|
|
16047
|
-
const
|
|
16048
|
-
if (typeof
|
|
16242
|
+
const input2 = payload.value;
|
|
16243
|
+
if (typeof input2 === "undefined")
|
|
16049
16244
|
return payload;
|
|
16050
16245
|
payload.issues.push({
|
|
16051
16246
|
expected: "void",
|
|
16052
16247
|
code: "invalid_type",
|
|
16053
|
-
input,
|
|
16248
|
+
input: input2,
|
|
16054
16249
|
inst
|
|
16055
16250
|
});
|
|
16056
16251
|
return payload;
|
|
@@ -16065,15 +16260,15 @@ var $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
|
|
|
16065
16260
|
} catch (_err) {
|
|
16066
16261
|
}
|
|
16067
16262
|
}
|
|
16068
|
-
const
|
|
16069
|
-
const isDate =
|
|
16070
|
-
const isValidDate = isDate && !Number.isNaN(
|
|
16263
|
+
const input2 = payload.value;
|
|
16264
|
+
const isDate = input2 instanceof Date;
|
|
16265
|
+
const isValidDate = isDate && !Number.isNaN(input2.getTime());
|
|
16071
16266
|
if (isValidDate)
|
|
16072
16267
|
return payload;
|
|
16073
16268
|
payload.issues.push({
|
|
16074
16269
|
expected: "date",
|
|
16075
16270
|
code: "invalid_type",
|
|
16076
|
-
input,
|
|
16271
|
+
input: input2,
|
|
16077
16272
|
...isDate ? { received: "Invalid Date" } : {},
|
|
16078
16273
|
inst
|
|
16079
16274
|
});
|
|
@@ -16089,20 +16284,20 @@ function handleArrayResult(result, final, index) {
|
|
|
16089
16284
|
var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
16090
16285
|
$ZodType.init(inst, def);
|
|
16091
16286
|
inst._zod.parse = (payload, ctx) => {
|
|
16092
|
-
const
|
|
16093
|
-
if (!Array.isArray(
|
|
16287
|
+
const input2 = payload.value;
|
|
16288
|
+
if (!Array.isArray(input2)) {
|
|
16094
16289
|
payload.issues.push({
|
|
16095
16290
|
expected: "array",
|
|
16096
16291
|
code: "invalid_type",
|
|
16097
|
-
input,
|
|
16292
|
+
input: input2,
|
|
16098
16293
|
inst
|
|
16099
16294
|
});
|
|
16100
16295
|
return payload;
|
|
16101
16296
|
}
|
|
16102
|
-
payload.value = Array(
|
|
16297
|
+
payload.value = Array(input2.length);
|
|
16103
16298
|
const proms = [];
|
|
16104
|
-
for (let i = 0; i <
|
|
16105
|
-
const item =
|
|
16299
|
+
for (let i = 0; i < input2.length; i++) {
|
|
16300
|
+
const item = input2[i];
|
|
16106
16301
|
const result = def.element._zod.run({
|
|
16107
16302
|
value: item,
|
|
16108
16303
|
issues: []
|
|
@@ -16119,15 +16314,15 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
16119
16314
|
return payload;
|
|
16120
16315
|
};
|
|
16121
16316
|
});
|
|
16122
|
-
function handlePropertyResult(result, final, key,
|
|
16317
|
+
function handlePropertyResult(result, final, key, input2, isOptionalOut) {
|
|
16123
16318
|
if (result.issues.length) {
|
|
16124
|
-
if (isOptionalOut && !(key in
|
|
16319
|
+
if (isOptionalOut && !(key in input2)) {
|
|
16125
16320
|
return;
|
|
16126
16321
|
}
|
|
16127
16322
|
final.issues.push(...prefixIssues(key, result.issues));
|
|
16128
16323
|
}
|
|
16129
16324
|
if (result.value === void 0) {
|
|
16130
|
-
if (key in
|
|
16325
|
+
if (key in input2) {
|
|
16131
16326
|
final.value[key] = void 0;
|
|
16132
16327
|
}
|
|
16133
16328
|
} else {
|
|
@@ -16150,31 +16345,31 @@ function normalizeDef(def) {
|
|
|
16150
16345
|
optionalKeys: new Set(okeys)
|
|
16151
16346
|
};
|
|
16152
16347
|
}
|
|
16153
|
-
function handleCatchall(proms,
|
|
16348
|
+
function handleCatchall(proms, input2, payload, ctx, def, inst) {
|
|
16154
16349
|
const unrecognized = [];
|
|
16155
16350
|
const keySet = def.keySet;
|
|
16156
16351
|
const _catchall = def.catchall._zod;
|
|
16157
16352
|
const t = _catchall.def.type;
|
|
16158
16353
|
const isOptionalOut = _catchall.optout === "optional";
|
|
16159
|
-
for (const key in
|
|
16354
|
+
for (const key in input2) {
|
|
16160
16355
|
if (keySet.has(key))
|
|
16161
16356
|
continue;
|
|
16162
16357
|
if (t === "never") {
|
|
16163
16358
|
unrecognized.push(key);
|
|
16164
16359
|
continue;
|
|
16165
16360
|
}
|
|
16166
|
-
const r = _catchall.run({ value:
|
|
16361
|
+
const r = _catchall.run({ value: input2[key], issues: [] }, ctx);
|
|
16167
16362
|
if (r instanceof Promise) {
|
|
16168
|
-
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key,
|
|
16363
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input2, isOptionalOut)));
|
|
16169
16364
|
} else {
|
|
16170
|
-
handlePropertyResult(r, payload, key,
|
|
16365
|
+
handlePropertyResult(r, payload, key, input2, isOptionalOut);
|
|
16171
16366
|
}
|
|
16172
16367
|
}
|
|
16173
16368
|
if (unrecognized.length) {
|
|
16174
16369
|
payload.issues.push({
|
|
16175
16370
|
code: "unrecognized_keys",
|
|
16176
16371
|
keys: unrecognized,
|
|
16177
|
-
input,
|
|
16372
|
+
input: input2,
|
|
16178
16373
|
inst
|
|
16179
16374
|
});
|
|
16180
16375
|
}
|
|
@@ -16218,12 +16413,12 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
16218
16413
|
let value;
|
|
16219
16414
|
inst._zod.parse = (payload, ctx) => {
|
|
16220
16415
|
value ?? (value = _normalized.value);
|
|
16221
|
-
const
|
|
16222
|
-
if (!isObject2(
|
|
16416
|
+
const input2 = payload.value;
|
|
16417
|
+
if (!isObject2(input2)) {
|
|
16223
16418
|
payload.issues.push({
|
|
16224
16419
|
expected: "object",
|
|
16225
16420
|
code: "invalid_type",
|
|
16226
|
-
input,
|
|
16421
|
+
input: input2,
|
|
16227
16422
|
inst
|
|
16228
16423
|
});
|
|
16229
16424
|
return payload;
|
|
@@ -16234,17 +16429,17 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
16234
16429
|
for (const key of value.keys) {
|
|
16235
16430
|
const el = shape[key];
|
|
16236
16431
|
const isOptionalOut = el._zod.optout === "optional";
|
|
16237
|
-
const r = el._zod.run({ value:
|
|
16432
|
+
const r = el._zod.run({ value: input2[key], issues: [] }, ctx);
|
|
16238
16433
|
if (r instanceof Promise) {
|
|
16239
|
-
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key,
|
|
16434
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input2, isOptionalOut)));
|
|
16240
16435
|
} else {
|
|
16241
|
-
handlePropertyResult(r, payload, key,
|
|
16436
|
+
handlePropertyResult(r, payload, key, input2, isOptionalOut);
|
|
16242
16437
|
}
|
|
16243
16438
|
}
|
|
16244
16439
|
if (!catchall) {
|
|
16245
16440
|
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
16246
16441
|
}
|
|
16247
|
-
return handleCatchall(proms,
|
|
16442
|
+
return handleCatchall(proms, input2, payload, ctx, _normalized.value, inst);
|
|
16248
16443
|
};
|
|
16249
16444
|
});
|
|
16250
16445
|
var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
@@ -16325,12 +16520,12 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
16325
16520
|
let value;
|
|
16326
16521
|
inst._zod.parse = (payload, ctx) => {
|
|
16327
16522
|
value ?? (value = _normalized.value);
|
|
16328
|
-
const
|
|
16329
|
-
if (!isObject2(
|
|
16523
|
+
const input2 = payload.value;
|
|
16524
|
+
if (!isObject2(input2)) {
|
|
16330
16525
|
payload.issues.push({
|
|
16331
16526
|
expected: "object",
|
|
16332
16527
|
code: "invalid_type",
|
|
16333
|
-
input,
|
|
16528
|
+
input: input2,
|
|
16334
16529
|
inst
|
|
16335
16530
|
});
|
|
16336
16531
|
return payload;
|
|
@@ -16341,7 +16536,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
16341
16536
|
payload = fastpass(payload, ctx);
|
|
16342
16537
|
if (!catchall)
|
|
16343
16538
|
return payload;
|
|
16344
|
-
return handleCatchall([],
|
|
16539
|
+
return handleCatchall([], input2, payload, ctx, value, inst);
|
|
16345
16540
|
}
|
|
16346
16541
|
return superParse(payload, ctx);
|
|
16347
16542
|
};
|
|
@@ -16503,17 +16698,17 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
16503
16698
|
return map2;
|
|
16504
16699
|
});
|
|
16505
16700
|
inst._zod.parse = (payload, ctx) => {
|
|
16506
|
-
const
|
|
16507
|
-
if (!isObject(
|
|
16701
|
+
const input2 = payload.value;
|
|
16702
|
+
if (!isObject(input2)) {
|
|
16508
16703
|
payload.issues.push({
|
|
16509
16704
|
code: "invalid_type",
|
|
16510
16705
|
expected: "object",
|
|
16511
|
-
input,
|
|
16706
|
+
input: input2,
|
|
16512
16707
|
inst
|
|
16513
16708
|
});
|
|
16514
16709
|
return payload;
|
|
16515
16710
|
}
|
|
16516
|
-
const opt = disc.value.get(
|
|
16711
|
+
const opt = disc.value.get(input2?.[def.discriminator]);
|
|
16517
16712
|
if (opt) {
|
|
16518
16713
|
return opt._zod.run(payload, ctx);
|
|
16519
16714
|
}
|
|
@@ -16525,7 +16720,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
16525
16720
|
errors: [],
|
|
16526
16721
|
note: "No matching discriminator",
|
|
16527
16722
|
discriminator: def.discriminator,
|
|
16528
|
-
input,
|
|
16723
|
+
input: input2,
|
|
16529
16724
|
path: [def.discriminator],
|
|
16530
16725
|
inst
|
|
16531
16726
|
});
|
|
@@ -16535,9 +16730,9 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
16535
16730
|
var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
|
|
16536
16731
|
$ZodType.init(inst, def);
|
|
16537
16732
|
inst._zod.parse = (payload, ctx) => {
|
|
16538
|
-
const
|
|
16539
|
-
const left = def.left._zod.run({ value:
|
|
16540
|
-
const right = def.right._zod.run({ value:
|
|
16733
|
+
const input2 = payload.value;
|
|
16734
|
+
const left = def.left._zod.run({ value: input2, issues: [] }, ctx);
|
|
16735
|
+
const right = def.right._zod.run({ value: input2, issues: [] }, ctx);
|
|
16541
16736
|
const async = left instanceof Promise || right instanceof Promise;
|
|
16542
16737
|
if (async) {
|
|
16543
16738
|
return Promise.all([left, right]).then(([left2, right2]) => {
|
|
@@ -16634,10 +16829,10 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
16634
16829
|
$ZodType.init(inst, def);
|
|
16635
16830
|
const items = def.items;
|
|
16636
16831
|
inst._zod.parse = (payload, ctx) => {
|
|
16637
|
-
const
|
|
16638
|
-
if (!Array.isArray(
|
|
16832
|
+
const input2 = payload.value;
|
|
16833
|
+
if (!Array.isArray(input2)) {
|
|
16639
16834
|
payload.issues.push({
|
|
16640
|
-
input,
|
|
16835
|
+
input: input2,
|
|
16641
16836
|
inst,
|
|
16642
16837
|
expected: "tuple",
|
|
16643
16838
|
code: "invalid_type"
|
|
@@ -16649,12 +16844,12 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
16649
16844
|
const reversedIndex = [...items].reverse().findIndex((item) => item._zod.optin !== "optional");
|
|
16650
16845
|
const optStart = reversedIndex === -1 ? 0 : items.length - reversedIndex;
|
|
16651
16846
|
if (!def.rest) {
|
|
16652
|
-
const tooBig =
|
|
16653
|
-
const tooSmall =
|
|
16847
|
+
const tooBig = input2.length > items.length;
|
|
16848
|
+
const tooSmall = input2.length < optStart - 1;
|
|
16654
16849
|
if (tooBig || tooSmall) {
|
|
16655
16850
|
payload.issues.push({
|
|
16656
16851
|
...tooBig ? { code: "too_big", maximum: items.length, inclusive: true } : { code: "too_small", minimum: items.length },
|
|
16657
|
-
input,
|
|
16852
|
+
input: input2,
|
|
16658
16853
|
inst,
|
|
16659
16854
|
origin: "array"
|
|
16660
16855
|
});
|
|
@@ -16664,12 +16859,12 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
16664
16859
|
let i = -1;
|
|
16665
16860
|
for (const item of items) {
|
|
16666
16861
|
i++;
|
|
16667
|
-
if (i >=
|
|
16862
|
+
if (i >= input2.length) {
|
|
16668
16863
|
if (i >= optStart)
|
|
16669
16864
|
continue;
|
|
16670
16865
|
}
|
|
16671
16866
|
const result = item._zod.run({
|
|
16672
|
-
value:
|
|
16867
|
+
value: input2[i],
|
|
16673
16868
|
issues: []
|
|
16674
16869
|
}, ctx);
|
|
16675
16870
|
if (result instanceof Promise) {
|
|
@@ -16679,7 +16874,7 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
16679
16874
|
}
|
|
16680
16875
|
}
|
|
16681
16876
|
if (def.rest) {
|
|
16682
|
-
const rest =
|
|
16877
|
+
const rest = input2.slice(items.length);
|
|
16683
16878
|
for (const el of rest) {
|
|
16684
16879
|
i++;
|
|
16685
16880
|
const result = def.rest._zod.run({
|
|
@@ -16707,12 +16902,12 @@ function handleTupleResult(result, final, index) {
|
|
|
16707
16902
|
var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
16708
16903
|
$ZodType.init(inst, def);
|
|
16709
16904
|
inst._zod.parse = (payload, ctx) => {
|
|
16710
|
-
const
|
|
16711
|
-
if (!isPlainObject(
|
|
16905
|
+
const input2 = payload.value;
|
|
16906
|
+
if (!isPlainObject(input2)) {
|
|
16712
16907
|
payload.issues.push({
|
|
16713
16908
|
expected: "record",
|
|
16714
16909
|
code: "invalid_type",
|
|
16715
|
-
input,
|
|
16910
|
+
input: input2,
|
|
16716
16911
|
inst
|
|
16717
16912
|
});
|
|
16718
16913
|
return payload;
|
|
@@ -16725,7 +16920,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
16725
16920
|
for (const key of values) {
|
|
16726
16921
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
16727
16922
|
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
16728
|
-
const result = def.valueType._zod.run({ value:
|
|
16923
|
+
const result = def.valueType._zod.run({ value: input2[key], issues: [] }, ctx);
|
|
16729
16924
|
if (result instanceof Promise) {
|
|
16730
16925
|
proms.push(result.then((result2) => {
|
|
16731
16926
|
if (result2.issues.length) {
|
|
@@ -16742,7 +16937,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
16742
16937
|
}
|
|
16743
16938
|
}
|
|
16744
16939
|
let unrecognized;
|
|
16745
|
-
for (const key in
|
|
16940
|
+
for (const key in input2) {
|
|
16746
16941
|
if (!recordKeys.has(key)) {
|
|
16747
16942
|
unrecognized = unrecognized ?? [];
|
|
16748
16943
|
unrecognized.push(key);
|
|
@@ -16751,14 +16946,14 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
16751
16946
|
if (unrecognized && unrecognized.length > 0) {
|
|
16752
16947
|
payload.issues.push({
|
|
16753
16948
|
code: "unrecognized_keys",
|
|
16754
|
-
input,
|
|
16949
|
+
input: input2,
|
|
16755
16950
|
inst,
|
|
16756
16951
|
keys: unrecognized
|
|
16757
16952
|
});
|
|
16758
16953
|
}
|
|
16759
16954
|
} else {
|
|
16760
16955
|
payload.value = {};
|
|
16761
|
-
for (const key of Reflect.ownKeys(
|
|
16956
|
+
for (const key of Reflect.ownKeys(input2)) {
|
|
16762
16957
|
if (key === "__proto__")
|
|
16763
16958
|
continue;
|
|
16764
16959
|
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
@@ -16777,7 +16972,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
16777
16972
|
}
|
|
16778
16973
|
if (keyResult.issues.length) {
|
|
16779
16974
|
if (def.mode === "loose") {
|
|
16780
|
-
payload.value[key] =
|
|
16975
|
+
payload.value[key] = input2[key];
|
|
16781
16976
|
} else {
|
|
16782
16977
|
payload.issues.push({
|
|
16783
16978
|
code: "invalid_key",
|
|
@@ -16790,7 +16985,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
16790
16985
|
}
|
|
16791
16986
|
continue;
|
|
16792
16987
|
}
|
|
16793
|
-
const result = def.valueType._zod.run({ value:
|
|
16988
|
+
const result = def.valueType._zod.run({ value: input2[key], issues: [] }, ctx);
|
|
16794
16989
|
if (result instanceof Promise) {
|
|
16795
16990
|
proms.push(result.then((result2) => {
|
|
16796
16991
|
if (result2.issues.length) {
|
|
@@ -16815,27 +17010,27 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
16815
17010
|
var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
|
|
16816
17011
|
$ZodType.init(inst, def);
|
|
16817
17012
|
inst._zod.parse = (payload, ctx) => {
|
|
16818
|
-
const
|
|
16819
|
-
if (!(
|
|
17013
|
+
const input2 = payload.value;
|
|
17014
|
+
if (!(input2 instanceof Map)) {
|
|
16820
17015
|
payload.issues.push({
|
|
16821
17016
|
expected: "map",
|
|
16822
17017
|
code: "invalid_type",
|
|
16823
|
-
input,
|
|
17018
|
+
input: input2,
|
|
16824
17019
|
inst
|
|
16825
17020
|
});
|
|
16826
17021
|
return payload;
|
|
16827
17022
|
}
|
|
16828
17023
|
const proms = [];
|
|
16829
17024
|
payload.value = /* @__PURE__ */ new Map();
|
|
16830
|
-
for (const [key, value] of
|
|
17025
|
+
for (const [key, value] of input2) {
|
|
16831
17026
|
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
16832
17027
|
const valueResult = def.valueType._zod.run({ value, issues: [] }, ctx);
|
|
16833
17028
|
if (keyResult instanceof Promise || valueResult instanceof Promise) {
|
|
16834
17029
|
proms.push(Promise.all([keyResult, valueResult]).then(([keyResult2, valueResult2]) => {
|
|
16835
|
-
handleMapResult(keyResult2, valueResult2, payload, key,
|
|
17030
|
+
handleMapResult(keyResult2, valueResult2, payload, key, input2, inst, ctx);
|
|
16836
17031
|
}));
|
|
16837
17032
|
} else {
|
|
16838
|
-
handleMapResult(keyResult, valueResult, payload, key,
|
|
17033
|
+
handleMapResult(keyResult, valueResult, payload, key, input2, inst, ctx);
|
|
16839
17034
|
}
|
|
16840
17035
|
}
|
|
16841
17036
|
if (proms.length)
|
|
@@ -16843,7 +17038,7 @@ var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
|
|
|
16843
17038
|
return payload;
|
|
16844
17039
|
};
|
|
16845
17040
|
});
|
|
16846
|
-
function handleMapResult(keyResult, valueResult, final, key,
|
|
17041
|
+
function handleMapResult(keyResult, valueResult, final, key, input2, inst, ctx) {
|
|
16847
17042
|
if (keyResult.issues.length) {
|
|
16848
17043
|
if (propertyKeyTypes.has(typeof key)) {
|
|
16849
17044
|
final.issues.push(...prefixIssues(key, keyResult.issues));
|
|
@@ -16851,7 +17046,7 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
|
16851
17046
|
final.issues.push({
|
|
16852
17047
|
code: "invalid_key",
|
|
16853
17048
|
origin: "map",
|
|
16854
|
-
input,
|
|
17049
|
+
input: input2,
|
|
16855
17050
|
inst,
|
|
16856
17051
|
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
16857
17052
|
});
|
|
@@ -16864,7 +17059,7 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
|
16864
17059
|
final.issues.push({
|
|
16865
17060
|
origin: "map",
|
|
16866
17061
|
code: "invalid_element",
|
|
16867
|
-
input,
|
|
17062
|
+
input: input2,
|
|
16868
17063
|
inst,
|
|
16869
17064
|
key,
|
|
16870
17065
|
issues: valueResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
@@ -16876,10 +17071,10 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
|
16876
17071
|
var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
|
|
16877
17072
|
$ZodType.init(inst, def);
|
|
16878
17073
|
inst._zod.parse = (payload, ctx) => {
|
|
16879
|
-
const
|
|
16880
|
-
if (!(
|
|
17074
|
+
const input2 = payload.value;
|
|
17075
|
+
if (!(input2 instanceof Set)) {
|
|
16881
17076
|
payload.issues.push({
|
|
16882
|
-
input,
|
|
17077
|
+
input: input2,
|
|
16883
17078
|
inst,
|
|
16884
17079
|
expected: "set",
|
|
16885
17080
|
code: "invalid_type"
|
|
@@ -16888,7 +17083,7 @@ var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
|
|
|
16888
17083
|
}
|
|
16889
17084
|
const proms = [];
|
|
16890
17085
|
payload.value = /* @__PURE__ */ new Set();
|
|
16891
|
-
for (const item of
|
|
17086
|
+
for (const item of input2) {
|
|
16892
17087
|
const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
|
|
16893
17088
|
if (result instanceof Promise) {
|
|
16894
17089
|
proms.push(result.then((result2) => handleSetResult(result2, payload)));
|
|
@@ -16913,14 +17108,14 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
16913
17108
|
inst._zod.values = valuesSet;
|
|
16914
17109
|
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
16915
17110
|
inst._zod.parse = (payload, _ctx) => {
|
|
16916
|
-
const
|
|
16917
|
-
if (valuesSet.has(
|
|
17111
|
+
const input2 = payload.value;
|
|
17112
|
+
if (valuesSet.has(input2)) {
|
|
16918
17113
|
return payload;
|
|
16919
17114
|
}
|
|
16920
17115
|
payload.issues.push({
|
|
16921
17116
|
code: "invalid_value",
|
|
16922
17117
|
values,
|
|
16923
|
-
input,
|
|
17118
|
+
input: input2,
|
|
16924
17119
|
inst
|
|
16925
17120
|
});
|
|
16926
17121
|
return payload;
|
|
@@ -16935,14 +17130,14 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
|
16935
17130
|
inst._zod.values = values;
|
|
16936
17131
|
inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
|
|
16937
17132
|
inst._zod.parse = (payload, _ctx) => {
|
|
16938
|
-
const
|
|
16939
|
-
if (values.has(
|
|
17133
|
+
const input2 = payload.value;
|
|
17134
|
+
if (values.has(input2)) {
|
|
16940
17135
|
return payload;
|
|
16941
17136
|
}
|
|
16942
17137
|
payload.issues.push({
|
|
16943
17138
|
code: "invalid_value",
|
|
16944
17139
|
values: def.values,
|
|
16945
|
-
input,
|
|
17140
|
+
input: input2,
|
|
16946
17141
|
inst
|
|
16947
17142
|
});
|
|
16948
17143
|
return payload;
|
|
@@ -16951,13 +17146,13 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
|
16951
17146
|
var $ZodFile = /* @__PURE__ */ $constructor("$ZodFile", (inst, def) => {
|
|
16952
17147
|
$ZodType.init(inst, def);
|
|
16953
17148
|
inst._zod.parse = (payload, _ctx) => {
|
|
16954
|
-
const
|
|
16955
|
-
if (
|
|
17149
|
+
const input2 = payload.value;
|
|
17150
|
+
if (input2 instanceof File)
|
|
16956
17151
|
return payload;
|
|
16957
17152
|
payload.issues.push({
|
|
16958
17153
|
expected: "file",
|
|
16959
17154
|
code: "invalid_type",
|
|
16960
|
-
input,
|
|
17155
|
+
input: input2,
|
|
16961
17156
|
inst
|
|
16962
17157
|
});
|
|
16963
17158
|
return payload;
|
|
@@ -16971,9 +17166,9 @@ var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) =>
|
|
|
16971
17166
|
}
|
|
16972
17167
|
const _out = def.transform(payload.value, payload);
|
|
16973
17168
|
if (ctx.async) {
|
|
16974
|
-
const
|
|
16975
|
-
return
|
|
16976
|
-
payload.value =
|
|
17169
|
+
const output2 = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
17170
|
+
return output2.then((output3) => {
|
|
17171
|
+
payload.value = output3;
|
|
16977
17172
|
return payload;
|
|
16978
17173
|
});
|
|
16979
17174
|
}
|
|
@@ -16984,8 +17179,8 @@ var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) =>
|
|
|
16984
17179
|
return payload;
|
|
16985
17180
|
};
|
|
16986
17181
|
});
|
|
16987
|
-
function handleOptionalResult(result,
|
|
16988
|
-
if (result.issues.length &&
|
|
17182
|
+
function handleOptionalResult(result, input2) {
|
|
17183
|
+
if (result.issues.length && input2 === void 0) {
|
|
16989
17184
|
return { issues: [], value: void 0 };
|
|
16990
17185
|
}
|
|
16991
17186
|
return result;
|
|
@@ -17386,12 +17581,12 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
|
|
|
17386
17581
|
output: inst._def.output
|
|
17387
17582
|
});
|
|
17388
17583
|
};
|
|
17389
|
-
inst.output = (
|
|
17584
|
+
inst.output = (output2) => {
|
|
17390
17585
|
const F = inst.constructor;
|
|
17391
17586
|
return new F({
|
|
17392
17587
|
type: "function",
|
|
17393
17588
|
input: inst._def.input,
|
|
17394
|
-
output
|
|
17589
|
+
output: output2
|
|
17395
17590
|
});
|
|
17396
17591
|
};
|
|
17397
17592
|
return inst;
|
|
@@ -17421,20 +17616,20 @@ var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
|
17421
17616
|
return payload;
|
|
17422
17617
|
};
|
|
17423
17618
|
inst._zod.check = (payload) => {
|
|
17424
|
-
const
|
|
17425
|
-
const r = def.fn(
|
|
17619
|
+
const input2 = payload.value;
|
|
17620
|
+
const r = def.fn(input2);
|
|
17426
17621
|
if (r instanceof Promise) {
|
|
17427
|
-
return r.then((r2) => handleRefineResult(r2, payload,
|
|
17622
|
+
return r.then((r2) => handleRefineResult(r2, payload, input2, inst));
|
|
17428
17623
|
}
|
|
17429
|
-
handleRefineResult(r, payload,
|
|
17624
|
+
handleRefineResult(r, payload, input2, inst);
|
|
17430
17625
|
return;
|
|
17431
17626
|
};
|
|
17432
17627
|
});
|
|
17433
|
-
function handleRefineResult(result, payload,
|
|
17628
|
+
function handleRefineResult(result, payload, input2, inst) {
|
|
17434
17629
|
if (!result) {
|
|
17435
17630
|
const _iss = {
|
|
17436
17631
|
code: "custom",
|
|
17437
|
-
input,
|
|
17632
|
+
input: input2,
|
|
17438
17633
|
inst,
|
|
17439
17634
|
// incorporates params.error into issue reporting
|
|
17440
17635
|
path: [...inst._zod.def.path ?? []],
|
|
@@ -23744,23 +23939,23 @@ function _overwrite(tx) {
|
|
|
23744
23939
|
}
|
|
23745
23940
|
// @__NO_SIDE_EFFECTS__
|
|
23746
23941
|
function _normalize(form) {
|
|
23747
|
-
return /* @__PURE__ */ _overwrite((
|
|
23942
|
+
return /* @__PURE__ */ _overwrite((input2) => input2.normalize(form));
|
|
23748
23943
|
}
|
|
23749
23944
|
// @__NO_SIDE_EFFECTS__
|
|
23750
23945
|
function _trim() {
|
|
23751
|
-
return /* @__PURE__ */ _overwrite((
|
|
23946
|
+
return /* @__PURE__ */ _overwrite((input2) => input2.trim());
|
|
23752
23947
|
}
|
|
23753
23948
|
// @__NO_SIDE_EFFECTS__
|
|
23754
23949
|
function _toLowerCase() {
|
|
23755
|
-
return /* @__PURE__ */ _overwrite((
|
|
23950
|
+
return /* @__PURE__ */ _overwrite((input2) => input2.toLowerCase());
|
|
23756
23951
|
}
|
|
23757
23952
|
// @__NO_SIDE_EFFECTS__
|
|
23758
23953
|
function _toUpperCase() {
|
|
23759
|
-
return /* @__PURE__ */ _overwrite((
|
|
23954
|
+
return /* @__PURE__ */ _overwrite((input2) => input2.toUpperCase());
|
|
23760
23955
|
}
|
|
23761
23956
|
// @__NO_SIDE_EFFECTS__
|
|
23762
23957
|
function _slugify() {
|
|
23763
|
-
return /* @__PURE__ */ _overwrite((
|
|
23958
|
+
return /* @__PURE__ */ _overwrite((input2) => slugify(input2));
|
|
23764
23959
|
}
|
|
23765
23960
|
// @__NO_SIDE_EFFECTS__
|
|
23766
23961
|
function _array(Class2, element, params) {
|
|
@@ -24065,8 +24260,8 @@ function _stringbool(Classes, _params) {
|
|
|
24065
24260
|
type: "pipe",
|
|
24066
24261
|
in: stringSchema,
|
|
24067
24262
|
out: booleanSchema,
|
|
24068
|
-
transform: ((
|
|
24069
|
-
let data =
|
|
24263
|
+
transform: ((input2, payload) => {
|
|
24264
|
+
let data = input2;
|
|
24070
24265
|
if (params.case !== "sensitive")
|
|
24071
24266
|
data = data.toLowerCase();
|
|
24072
24267
|
if (truthySet.has(data)) {
|
|
@@ -24085,8 +24280,8 @@ function _stringbool(Classes, _params) {
|
|
|
24085
24280
|
return {};
|
|
24086
24281
|
}
|
|
24087
24282
|
}),
|
|
24088
|
-
reverseTransform: ((
|
|
24089
|
-
if (
|
|
24283
|
+
reverseTransform: ((input2, _payload) => {
|
|
24284
|
+
if (input2 === true) {
|
|
24090
24285
|
return truthyArray[0] || "true";
|
|
24091
24286
|
} else {
|
|
24092
24287
|
return falsyArray[0] || "false";
|
|
@@ -24982,9 +25177,9 @@ var allProcessors = {
|
|
|
24982
25177
|
optional: optionalProcessor,
|
|
24983
25178
|
lazy: lazyProcessor
|
|
24984
25179
|
};
|
|
24985
|
-
function toJSONSchema(
|
|
24986
|
-
if ("_idmap" in
|
|
24987
|
-
const registry2 =
|
|
25180
|
+
function toJSONSchema(input2, params) {
|
|
25181
|
+
if ("_idmap" in input2) {
|
|
25182
|
+
const registry2 = input2;
|
|
24988
25183
|
const ctx2 = initializeContext({ ...params, processors: allProcessors });
|
|
24989
25184
|
const defs = {};
|
|
24990
25185
|
for (const entry of registry2._idmap.entries()) {
|
|
@@ -25012,9 +25207,9 @@ function toJSONSchema(input, params) {
|
|
|
25012
25207
|
return { schemas };
|
|
25013
25208
|
}
|
|
25014
25209
|
const ctx = initializeContext({ ...params, processors: allProcessors });
|
|
25015
|
-
process2(
|
|
25016
|
-
extractDefs(ctx,
|
|
25017
|
-
return finalize(ctx,
|
|
25210
|
+
process2(input2, ctx);
|
|
25211
|
+
extractDefs(ctx, input2);
|
|
25212
|
+
return finalize(ctx, input2);
|
|
25018
25213
|
}
|
|
25019
25214
|
|
|
25020
25215
|
// node_modules/zod/v4/core/json-schema-generator.js
|
|
@@ -26618,14 +26813,14 @@ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
|
26618
26813
|
payload.issues.push(util_exports.issue(_issue));
|
|
26619
26814
|
}
|
|
26620
26815
|
};
|
|
26621
|
-
const
|
|
26622
|
-
if (
|
|
26623
|
-
return
|
|
26624
|
-
payload.value =
|
|
26816
|
+
const output2 = def.transform(payload.value, payload);
|
|
26817
|
+
if (output2 instanceof Promise) {
|
|
26818
|
+
return output2.then((output3) => {
|
|
26819
|
+
payload.value = output3;
|
|
26625
26820
|
return payload;
|
|
26626
26821
|
});
|
|
26627
26822
|
}
|
|
26628
|
-
payload.value =
|
|
26823
|
+
payload.value = output2;
|
|
26629
26824
|
return payload;
|
|
26630
26825
|
};
|
|
26631
26826
|
});
|
|
@@ -31275,12 +31470,12 @@ var AjvJsonSchemaValidator = class {
|
|
|
31275
31470
|
*/
|
|
31276
31471
|
getValidator(schema) {
|
|
31277
31472
|
const ajvValidator = "$id" in schema && typeof schema.$id === "string" ? this._ajv.getSchema(schema.$id) ?? this._ajv.compile(schema) : this._ajv.compile(schema);
|
|
31278
|
-
return (
|
|
31279
|
-
const valid = ajvValidator(
|
|
31473
|
+
return (input2) => {
|
|
31474
|
+
const valid = ajvValidator(input2);
|
|
31280
31475
|
if (valid) {
|
|
31281
31476
|
return {
|
|
31282
31477
|
valid: true,
|
|
31283
|
-
data:
|
|
31478
|
+
data: input2,
|
|
31284
31479
|
errorMessage: void 0
|
|
31285
31480
|
};
|
|
31286
31481
|
} else {
|
|
@@ -33492,6 +33687,144 @@ function registerOrganizingTools(server, accountManager) {
|
|
|
33492
33687
|
);
|
|
33493
33688
|
}
|
|
33494
33689
|
|
|
33690
|
+
// src/tools/moderation.ts
|
|
33691
|
+
function jsonResult5(data) {
|
|
33692
|
+
return { content: [{ type: "text", text: JSON.stringify(data) }] };
|
|
33693
|
+
}
|
|
33694
|
+
var BLOCK_RULE_MATCH_TYPES = ["senderDomain", "senderAddress", "subjectContains", "headerContains"];
|
|
33695
|
+
var BLOCK_RULE_ACTIONS = ["delete", "moveToJunk"];
|
|
33696
|
+
function registerModerationTools(server, accountManager) {
|
|
33697
|
+
server.tool(
|
|
33698
|
+
"email_report_spam",
|
|
33699
|
+
`Report an email as spam/junk, training the provider's own spam filter (the same signal the "Report Junk" button sends in Gmail/Outlook). This is different from email_delete, which removes the message but teaches the filter nothing. Not an abuse report to the provider's security team \u2014 it only trains this account's filter.`,
|
|
33700
|
+
{
|
|
33701
|
+
accountId: external_exports3.string(),
|
|
33702
|
+
emailId: external_exports3.string(),
|
|
33703
|
+
sourceFolder: external_exports3.string().optional().describe("Source folder (required for IMAP/iCloud when email is not in INBOX)")
|
|
33704
|
+
},
|
|
33705
|
+
async (args) => {
|
|
33706
|
+
try {
|
|
33707
|
+
const provider = await accountManager.getProvider(args.accountId);
|
|
33708
|
+
if (!provider.reportSpam) {
|
|
33709
|
+
return jsonResult5({ success: false, error: "email_report_spam is not supported on this provider" });
|
|
33710
|
+
}
|
|
33711
|
+
await provider.reportSpam(args.emailId, args.sourceFolder);
|
|
33712
|
+
return jsonResult5({ success: true });
|
|
33713
|
+
} catch (error48) {
|
|
33714
|
+
return jsonResult5({ success: false, error: error48.message });
|
|
33715
|
+
}
|
|
33716
|
+
}
|
|
33717
|
+
);
|
|
33718
|
+
server.tool(
|
|
33719
|
+
"email_batch_report_spam",
|
|
33720
|
+
"Report multiple emails as spam/junk at once. Much faster than individual calls.",
|
|
33721
|
+
{
|
|
33722
|
+
accountId: external_exports3.string(),
|
|
33723
|
+
emailIds: external_exports3.array(external_exports3.string()).min(1).describe("Array of email IDs to report as spam"),
|
|
33724
|
+
sourceFolder: external_exports3.string().optional().describe("Source folder (required for IMAP/iCloud when emails are not in INBOX)")
|
|
33725
|
+
},
|
|
33726
|
+
async (args) => {
|
|
33727
|
+
try {
|
|
33728
|
+
const provider = await accountManager.getProvider(args.accountId);
|
|
33729
|
+
if (!provider.reportSpam) {
|
|
33730
|
+
return jsonResult5({ success: false, error: "email_batch_report_spam is not supported on this provider" });
|
|
33731
|
+
}
|
|
33732
|
+
const result = { succeeded: [], failed: [] };
|
|
33733
|
+
for (const id of args.emailIds) {
|
|
33734
|
+
try {
|
|
33735
|
+
await provider.reportSpam(id, args.sourceFolder);
|
|
33736
|
+
result.succeeded.push(id);
|
|
33737
|
+
} catch (e) {
|
|
33738
|
+
result.failed.push({ id, error: e.message });
|
|
33739
|
+
}
|
|
33740
|
+
}
|
|
33741
|
+
return jsonResult5({ success: true, ...result });
|
|
33742
|
+
} catch (error48) {
|
|
33743
|
+
return jsonResult5({ success: false, error: error48.message });
|
|
33744
|
+
}
|
|
33745
|
+
}
|
|
33746
|
+
);
|
|
33747
|
+
server.tool(
|
|
33748
|
+
"email_create_block_rule",
|
|
33749
|
+
'Create a standing rule that intercepts future mail matching a pattern, before it reaches the inbox. Use headerContains (e.g. matching a Reply-To domain) to block a spam template family whose visible "From" domain rotates \u2014 matching the rotating domain directly stops working within days. Not supported on iCloud/generic IMAP (no standard server-side rule mechanism exists across IMAP servers). Outlook requires the MailboxSettings.ReadWrite scope \u2014 accounts authenticated before this tool existed need to re-run the setup wizard once to re-consent.',
|
|
33750
|
+
{
|
|
33751
|
+
accountId: external_exports3.string(),
|
|
33752
|
+
matchType: external_exports3.enum(BLOCK_RULE_MATCH_TYPES).describe(
|
|
33753
|
+
"senderDomain/senderAddress: match the From address. subjectContains: match the subject. headerContains: match any header's raw content \u2014 the right choice for a stable element (e.g. a Reply-To domain) when the From domain rotates."
|
|
33754
|
+
),
|
|
33755
|
+
value: external_exports3.string().describe("The domain, address, or text to match"),
|
|
33756
|
+
action: external_exports3.enum(BLOCK_RULE_ACTIONS).describe("delete: discard on arrival. moveToJunk: file straight to Junk/Spam without notifying.")
|
|
33757
|
+
},
|
|
33758
|
+
async (args) => {
|
|
33759
|
+
try {
|
|
33760
|
+
const provider = await accountManager.getProvider(args.accountId);
|
|
33761
|
+
if (!provider.createBlockRule) {
|
|
33762
|
+
return jsonResult5({
|
|
33763
|
+
success: false,
|
|
33764
|
+
error: "email_create_block_rule is not supported on this provider",
|
|
33765
|
+
supportedProviders: ["gmail", "outlook"]
|
|
33766
|
+
});
|
|
33767
|
+
}
|
|
33768
|
+
const result = await provider.createBlockRule({
|
|
33769
|
+
matchType: args.matchType,
|
|
33770
|
+
value: args.value,
|
|
33771
|
+
action: args.action
|
|
33772
|
+
});
|
|
33773
|
+
return jsonResult5({ success: true, data: result });
|
|
33774
|
+
} catch (error48) {
|
|
33775
|
+
return jsonResult5({ success: false, error: error48.message });
|
|
33776
|
+
}
|
|
33777
|
+
}
|
|
33778
|
+
);
|
|
33779
|
+
server.tool(
|
|
33780
|
+
"email_list_block_rules",
|
|
33781
|
+
"List the standing block rules on an account, for auditing or before deleting one.",
|
|
33782
|
+
{
|
|
33783
|
+
accountId: external_exports3.string()
|
|
33784
|
+
},
|
|
33785
|
+
async (args) => {
|
|
33786
|
+
try {
|
|
33787
|
+
const provider = await accountManager.getProvider(args.accountId);
|
|
33788
|
+
if (!provider.listBlockRules) {
|
|
33789
|
+
return jsonResult5({
|
|
33790
|
+
success: false,
|
|
33791
|
+
error: "email_list_block_rules is not supported on this provider",
|
|
33792
|
+
supportedProviders: ["gmail", "outlook"]
|
|
33793
|
+
});
|
|
33794
|
+
}
|
|
33795
|
+
const rules = await provider.listBlockRules();
|
|
33796
|
+
return jsonResult5({ success: true, data: rules });
|
|
33797
|
+
} catch (error48) {
|
|
33798
|
+
return jsonResult5({ success: false, error: error48.message });
|
|
33799
|
+
}
|
|
33800
|
+
}
|
|
33801
|
+
);
|
|
33802
|
+
server.tool(
|
|
33803
|
+
"email_delete_block_rule",
|
|
33804
|
+
"Delete a standing block rule \u2014 use this to undo a rule that turned out to be too broad (e.g. it blocked a domain a real correspondent also uses).",
|
|
33805
|
+
{
|
|
33806
|
+
accountId: external_exports3.string(),
|
|
33807
|
+
ruleId: external_exports3.string()
|
|
33808
|
+
},
|
|
33809
|
+
async (args) => {
|
|
33810
|
+
try {
|
|
33811
|
+
const provider = await accountManager.getProvider(args.accountId);
|
|
33812
|
+
if (!provider.deleteBlockRule) {
|
|
33813
|
+
return jsonResult5({
|
|
33814
|
+
success: false,
|
|
33815
|
+
error: "email_delete_block_rule is not supported on this provider",
|
|
33816
|
+
supportedProviders: ["gmail", "outlook"]
|
|
33817
|
+
});
|
|
33818
|
+
}
|
|
33819
|
+
await provider.deleteBlockRule(args.ruleId);
|
|
33820
|
+
return jsonResult5({ success: true });
|
|
33821
|
+
} catch (error48) {
|
|
33822
|
+
return jsonResult5({ success: false, error: error48.message });
|
|
33823
|
+
}
|
|
33824
|
+
}
|
|
33825
|
+
);
|
|
33826
|
+
}
|
|
33827
|
+
|
|
33495
33828
|
// src/server.ts
|
|
33496
33829
|
async function createServer(accountManager) {
|
|
33497
33830
|
const mgr = accountManager ?? new AccountManager();
|
|
@@ -33503,6 +33836,7 @@ async function createServer(accountManager) {
|
|
|
33503
33836
|
registerReadingTools(server, mgr);
|
|
33504
33837
|
registerSendingTools(server, mgr);
|
|
33505
33838
|
registerOrganizingTools(server, mgr);
|
|
33839
|
+
registerModerationTools(server, mgr);
|
|
33506
33840
|
return { server, accountManager: mgr };
|
|
33507
33841
|
}
|
|
33508
33842
|
async function startServer() {
|