fluxmail 0.29.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accounts/microsoftAuth.js +1 -1
- package/dist/accounts/microsoftAuth.js.map +1 -1
- package/dist/cliMail.d.ts.map +1 -1
- package/dist/cliMail.js +64 -0
- package/dist/cliMail.js.map +1 -1
- package/dist/cliMailBackend.d.ts +16 -0
- package/dist/cliMailBackend.d.ts.map +1 -1
- package/dist/cliMailBackend.js +44 -0
- package/dist/cliMailBackend.js.map +1 -1
- package/dist/http/rest.d.ts.map +1 -1
- package/dist/http/rest.js +210 -1
- package/dist/http/rest.js.map +1 -1
- package/dist/mcp/buildServer.d.ts.map +1 -1
- package/dist/mcp/buildServer.js +46 -5
- package/dist/mcp/buildServer.js.map +1 -1
- package/dist/mcp/outputSchemas.d.ts +46 -0
- package/dist/mcp/outputSchemas.d.ts.map +1 -1
- package/dist/mcp/outputSchemas.js +15 -0
- package/dist/mcp/outputSchemas.js.map +1 -1
- package/dist/mcp/productTools.d.ts +7 -0
- package/dist/mcp/productTools.d.ts.map +1 -0
- package/dist/mcp/productTools.js +8 -0
- package/dist/mcp/productTools.js.map +1 -0
- package/dist/permissions.d.ts.map +1 -1
- package/dist/permissions.js +1 -1
- package/dist/permissions.js.map +1 -1
- package/dist/service/emailService.d.ts +11 -1
- package/dist/service/emailService.d.ts.map +1 -1
- package/dist/service/emailService.js +52 -0
- package/dist/service/emailService.js.map +1 -1
- package/dist/service/modifyRejections.d.ts +24 -0
- package/dist/service/modifyRejections.d.ts.map +1 -0
- package/dist/service/modifyRejections.js +92 -0
- package/dist/service/modifyRejections.js.map +1 -0
- package/dist/service/publicErrors.d.ts +14 -1
- package/dist/service/publicErrors.d.ts.map +1 -1
- package/dist/service/publicErrors.js +25 -0
- package/dist/service/publicErrors.js.map +1 -1
- package/dist/storage/imapState.d.ts +1 -0
- package/dist/storage/imapState.d.ts.map +1 -1
- package/dist/storage/imapState.js +25 -1
- package/dist/storage/imapState.js.map +1 -1
- package/package.json +5 -5
package/dist/http/rest.js
CHANGED
|
@@ -19,7 +19,7 @@ import { recordAdminAuditEvent } from '../storage/adminAudit.js';
|
|
|
19
19
|
import { identityOperationId, registerIdentityRoutes } from './identity.js';
|
|
20
20
|
import { operationProperties } from './operationTelemetry.js';
|
|
21
21
|
import { logCodedFailure, logFailure } from '../logging.js';
|
|
22
|
-
import { attachmentTooLarge, ClientInputError, isAttachmentSizeError, MissingCapabilityError, publicError, } from '../service/publicErrors.js';
|
|
22
|
+
import { attachmentTooLarge, ClientInputError, folderDestination, isAttachmentSizeError, MissingCapabilityError, publicError, } from '../service/publicErrors.js';
|
|
23
23
|
const id = z.string().trim().min(1);
|
|
24
24
|
const accountId = id.openapi({ example: 'acct_123' });
|
|
25
25
|
const messageId = id.openapi({ example: 'msg_123' });
|
|
@@ -44,6 +44,22 @@ const messageParams = z.object({ accountId, messageId }).strict();
|
|
|
44
44
|
const threadParams = z.object({ accountId, threadId }).strict();
|
|
45
45
|
const draftParams = z.object({ accountId, draftId }).strict();
|
|
46
46
|
const scheduleParams = z.object({ accountId, scheduleId }).strict();
|
|
47
|
+
const folderParams = z
|
|
48
|
+
.object({
|
|
49
|
+
accountId,
|
|
50
|
+
folderId: id
|
|
51
|
+
.describe('Folder ID from the folder list, or the folder name. URL-encode it, since folder IDs can contain a slash.')
|
|
52
|
+
.openapi({ example: 'Receipts' }),
|
|
53
|
+
})
|
|
54
|
+
.strict();
|
|
55
|
+
const labelParams = z
|
|
56
|
+
.object({
|
|
57
|
+
accountId,
|
|
58
|
+
labelId: id
|
|
59
|
+
.describe('Label ID from the label list, or the label name. URL-encode it, since label names can contain a slash.')
|
|
60
|
+
.openapi({ example: 'Receipts' }),
|
|
61
|
+
})
|
|
62
|
+
.strict();
|
|
47
63
|
const attachmentParams = z.object({ accountId, messageId, attachmentId }).strict();
|
|
48
64
|
const EmailAddressSchema = z
|
|
49
65
|
.object({ email: z.string().email(), name: z.string().min(1).optional() })
|
|
@@ -437,6 +453,16 @@ const modifyActionNames = [
|
|
|
437
453
|
'addLabels',
|
|
438
454
|
'removeLabels',
|
|
439
455
|
];
|
|
456
|
+
const CreateLabelRequestSchema = z
|
|
457
|
+
.object({
|
|
458
|
+
name: z
|
|
459
|
+
.string()
|
|
460
|
+
.min(1)
|
|
461
|
+
.max(512)
|
|
462
|
+
.describe('Label or category name. For a nested Gmail label, give the full path, such as Projects/2026.'),
|
|
463
|
+
})
|
|
464
|
+
.strict()
|
|
465
|
+
.openapi('CreateLabelRequest');
|
|
440
466
|
const CreateFolderRequestSchema = z
|
|
441
467
|
.object({
|
|
442
468
|
name: z
|
|
@@ -447,6 +473,31 @@ const CreateFolderRequestSchema = z
|
|
|
447
473
|
})
|
|
448
474
|
.strict()
|
|
449
475
|
.openapi('CreateFolderRequest');
|
|
476
|
+
const RenameFolderRequestSchema = z
|
|
477
|
+
.object({
|
|
478
|
+
name: z
|
|
479
|
+
.string()
|
|
480
|
+
.min(1)
|
|
481
|
+
.max(512)
|
|
482
|
+
.describe('New name for the folder itself, without its parent path. For Projects/2025, send 2026 to get Projects/2026.'),
|
|
483
|
+
})
|
|
484
|
+
.strict()
|
|
485
|
+
.openapi('RenameFolderRequest');
|
|
486
|
+
const MoveFolderRequestSchema = z
|
|
487
|
+
.object({
|
|
488
|
+
parent: z
|
|
489
|
+
.string()
|
|
490
|
+
.min(1)
|
|
491
|
+
.max(512)
|
|
492
|
+
.optional()
|
|
493
|
+
.describe('ID or name of the folder to move it under. Leave out when topLevel is true.'),
|
|
494
|
+
topLevel: z
|
|
495
|
+
.boolean()
|
|
496
|
+
.optional()
|
|
497
|
+
.describe('Set to true to move the folder to the top level of the account. Leave out when parent is given.'),
|
|
498
|
+
})
|
|
499
|
+
.strict()
|
|
500
|
+
.openapi('MoveFolderRequest');
|
|
450
501
|
const ModifyRequestSchema = z
|
|
451
502
|
.object({
|
|
452
503
|
messageIds: z
|
|
@@ -1300,6 +1351,111 @@ export function createRestApi(deps) {
|
|
|
1300
1351
|
data: await c.get('restService').createFolder(accountId, name),
|
|
1301
1352
|
}));
|
|
1302
1353
|
});
|
|
1354
|
+
const deleteFolderRoute = createRoute({
|
|
1355
|
+
method: 'delete',
|
|
1356
|
+
path: '/api/v1/accounts/{accountId}/folders/{folderId}',
|
|
1357
|
+
operationId: 'deleteFolder',
|
|
1358
|
+
summary: 'Delete an empty folder',
|
|
1359
|
+
description: "Delete a folder that has no messages and no subfolders. Move or trash its mail, and delete its subfolders, first. In Gmail, where the folder is a label, remove the label from its messages. System folders such as Inbox, Sent and Trash can't be deleted, and neither can a folder the account settings use as one.",
|
|
1360
|
+
request: { params: folderParams },
|
|
1361
|
+
...protectedRoute,
|
|
1362
|
+
responses: {
|
|
1363
|
+
200: {
|
|
1364
|
+
content: {
|
|
1365
|
+
'application/json': {
|
|
1366
|
+
schema: dataEnvelope(z.object({ deleted: z.object({ id: z.string(), name: z.string() }).strict() }).strict()),
|
|
1367
|
+
},
|
|
1368
|
+
},
|
|
1369
|
+
description: 'The deleted folder',
|
|
1370
|
+
},
|
|
1371
|
+
...errorResponses,
|
|
1372
|
+
},
|
|
1373
|
+
});
|
|
1374
|
+
app.openapi(deleteFolderRoute, (c) => {
|
|
1375
|
+
const { accountId, folderId } = c.req.valid('param');
|
|
1376
|
+
return runJson(c, deps, { operation: 'deleteFolder', capabilities: ['mail.organize'] }, async () => {
|
|
1377
|
+
const deleted = await c.get('restService').deleteFolder(accountId, folderId);
|
|
1378
|
+
return { data: { deleted: { id: deleted.id, name: deleted.name } } };
|
|
1379
|
+
});
|
|
1380
|
+
});
|
|
1381
|
+
const renameFolderRoute = createRoute({
|
|
1382
|
+
method: 'patch',
|
|
1383
|
+
path: '/api/v1/accounts/{accountId}/folders/{folderId}',
|
|
1384
|
+
operationId: 'renameFolder',
|
|
1385
|
+
summary: 'Rename a folder',
|
|
1386
|
+
description: "Rename a folder. Give the new name on its own, without the parent path: the folder stays under the same parent and keeps its messages and subfolders. The new name must not be one another folder has. In Gmail, where the folder is a label, the labels nested under it are renamed to match. System folders such as Inbox, Sent and Trash can't be renamed, and neither can a folder the account settings use as one. In an IMAP mailbox, the folder and its subfolders get new IDs. Message IDs normally stay the same. If one stops working, list the folder again.",
|
|
1387
|
+
request: {
|
|
1388
|
+
params: folderParams,
|
|
1389
|
+
body: { required: true, content: { 'application/json': { schema: RenameFolderRequestSchema } } },
|
|
1390
|
+
},
|
|
1391
|
+
...protectedRoute,
|
|
1392
|
+
responses: {
|
|
1393
|
+
200: {
|
|
1394
|
+
content: {
|
|
1395
|
+
'application/json': {
|
|
1396
|
+
schema: dataEnvelope(z
|
|
1397
|
+
.object({
|
|
1398
|
+
folder: z.object({ id: z.string(), name: z.string() }).strict(),
|
|
1399
|
+
previous: z.object({ id: z.string(), name: z.string() }).strict(),
|
|
1400
|
+
})
|
|
1401
|
+
.strict()),
|
|
1402
|
+
},
|
|
1403
|
+
},
|
|
1404
|
+
description: 'The folder as it is listed now, and as it was listed before',
|
|
1405
|
+
},
|
|
1406
|
+
...errorResponses,
|
|
1407
|
+
},
|
|
1408
|
+
});
|
|
1409
|
+
app.openapi(renameFolderRoute, (c) => {
|
|
1410
|
+
const { accountId, folderId } = c.req.valid('param');
|
|
1411
|
+
const { name } = c.req.valid('json');
|
|
1412
|
+
return runJson(c, deps, { operation: 'renameFolder', capabilities: ['mail.organize'] }, async () => {
|
|
1413
|
+
const { folder, previous } = await c.get('restService').renameFolder(accountId, folderId, name);
|
|
1414
|
+
return {
|
|
1415
|
+
data: { folder: { id: folder.id, name: folder.name }, previous: { id: previous.id, name: previous.name } },
|
|
1416
|
+
};
|
|
1417
|
+
});
|
|
1418
|
+
});
|
|
1419
|
+
const moveFolderRoute = createRoute({
|
|
1420
|
+
method: 'post',
|
|
1421
|
+
path: '/api/v1/accounts/{accountId}/folders/{folderId}/move',
|
|
1422
|
+
operationId: 'moveFolder',
|
|
1423
|
+
summary: 'Move a folder',
|
|
1424
|
+
description: "Move a folder under another folder, or to the top level of the account. The folder keeps its own name, its messages and its subfolders. Send either `parent` or `topLevel: true`, not both. The destination can't be the folder itself, one of its subfolders, or the trash, and it can't already hold a folder with the same name. In Gmail, where the folder is a label, the labels nested under it move with it. System folders such as Inbox, Sent and Trash can't be moved, and neither can a folder the account settings use as one. Use the folder ID in the response afterwards: in an IMAP mailbox the folder and its subfolders always get new IDs. Message IDs normally stay the same. If one stops working, list the folder again.",
|
|
1425
|
+
request: {
|
|
1426
|
+
params: folderParams,
|
|
1427
|
+
body: { required: true, content: { 'application/json': { schema: MoveFolderRequestSchema } } },
|
|
1428
|
+
},
|
|
1429
|
+
...protectedRoute,
|
|
1430
|
+
responses: {
|
|
1431
|
+
200: {
|
|
1432
|
+
content: {
|
|
1433
|
+
'application/json': {
|
|
1434
|
+
schema: dataEnvelope(z
|
|
1435
|
+
.object({
|
|
1436
|
+
folder: z.object({ id: z.string(), name: z.string() }).strict(),
|
|
1437
|
+
previous: z.object({ id: z.string(), name: z.string() }).strict(),
|
|
1438
|
+
})
|
|
1439
|
+
.strict()),
|
|
1440
|
+
},
|
|
1441
|
+
},
|
|
1442
|
+
description: 'The folder as it is listed now, and as it was listed before',
|
|
1443
|
+
},
|
|
1444
|
+
...errorResponses,
|
|
1445
|
+
},
|
|
1446
|
+
});
|
|
1447
|
+
app.openapi(moveFolderRoute, (c) => {
|
|
1448
|
+
const { accountId, folderId } = c.req.valid('param');
|
|
1449
|
+
const { parent, topLevel } = c.req.valid('json');
|
|
1450
|
+
return runJson(c, deps, { operation: 'moveFolder', capabilities: ['mail.organize'] }, async () => {
|
|
1451
|
+
const { folder, previous } = await c
|
|
1452
|
+
.get('restService')
|
|
1453
|
+
.moveFolder(accountId, folderId, folderDestination(parent, topLevel));
|
|
1454
|
+
return {
|
|
1455
|
+
data: { folder: { id: folder.id, name: folder.name }, previous: { id: previous.id, name: previous.name } },
|
|
1456
|
+
};
|
|
1457
|
+
});
|
|
1458
|
+
});
|
|
1303
1459
|
const labelsRoute = createRoute({
|
|
1304
1460
|
method: 'get',
|
|
1305
1461
|
path: '/api/v1/accounts/{accountId}/labels',
|
|
@@ -1319,6 +1475,59 @@ export function createRestApi(deps) {
|
|
|
1319
1475
|
data: await c.get('restService').listLabels(accountId),
|
|
1320
1476
|
}));
|
|
1321
1477
|
});
|
|
1478
|
+
const createLabelRoute = createRoute({
|
|
1479
|
+
method: 'post',
|
|
1480
|
+
path: '/api/v1/accounts/{accountId}/labels',
|
|
1481
|
+
operationId: 'createLabel',
|
|
1482
|
+
summary: 'Create a label',
|
|
1483
|
+
description: "Create a Gmail label or an Outlook category, or return the existing one with that name. In Gmail, a name such as Projects/2026 creates a nested label and any missing parent labels, and the label also works as a folder. Gmail refuses names it uses for system labels and folders, such as Inbox, Archive and Starred. A new Outlook category has no color. IMAP accounts don't have labels.",
|
|
1484
|
+
request: {
|
|
1485
|
+
params: accountParams,
|
|
1486
|
+
body: { required: true, content: { 'application/json': { schema: CreateLabelRequestSchema } } },
|
|
1487
|
+
},
|
|
1488
|
+
...protectedRoute,
|
|
1489
|
+
responses: {
|
|
1490
|
+
200: {
|
|
1491
|
+
content: { 'application/json': { schema: dataEnvelope(LabelSchema) } },
|
|
1492
|
+
description: 'The new label, or the existing label with that name',
|
|
1493
|
+
},
|
|
1494
|
+
...errorResponses,
|
|
1495
|
+
},
|
|
1496
|
+
});
|
|
1497
|
+
app.openapi(createLabelRoute, (c) => {
|
|
1498
|
+
const { accountId } = c.req.valid('param');
|
|
1499
|
+
const { name } = c.req.valid('json');
|
|
1500
|
+
return runJson(c, deps, { operation: 'createLabel', capabilities: ['mail.organize'] }, async () => ({
|
|
1501
|
+
data: await c.get('restService').createLabel(accountId, name),
|
|
1502
|
+
}));
|
|
1503
|
+
});
|
|
1504
|
+
const deleteLabelRoute = createRoute({
|
|
1505
|
+
method: 'delete',
|
|
1506
|
+
path: '/api/v1/accounts/{accountId}/labels/{labelId}',
|
|
1507
|
+
operationId: 'deleteLabel',
|
|
1508
|
+
summary: 'Delete a label',
|
|
1509
|
+
description: "Delete a Gmail label or an Outlook category. In Gmail, the label is removed from its messages, which stay in the account, and a label with nested labels can't be deleted until they are. Gmail system labels such as Inbox and Starred can't be deleted. In Outlook, the category leaves the account's category list, but messages that have it keep its name.",
|
|
1510
|
+
request: { params: labelParams },
|
|
1511
|
+
...protectedRoute,
|
|
1512
|
+
responses: {
|
|
1513
|
+
200: {
|
|
1514
|
+
content: {
|
|
1515
|
+
'application/json': {
|
|
1516
|
+
schema: dataEnvelope(z.object({ deleted: z.object({ id: z.string(), name: z.string() }).strict() }).strict()),
|
|
1517
|
+
},
|
|
1518
|
+
},
|
|
1519
|
+
description: 'The deleted label',
|
|
1520
|
+
},
|
|
1521
|
+
...errorResponses,
|
|
1522
|
+
},
|
|
1523
|
+
});
|
|
1524
|
+
app.openapi(deleteLabelRoute, (c) => {
|
|
1525
|
+
const { accountId, labelId } = c.req.valid('param');
|
|
1526
|
+
return runJson(c, deps, { operation: 'deleteLabel', capabilities: ['mail.organize'] }, async () => {
|
|
1527
|
+
const deleted = await c.get('restService').deleteLabel(accountId, labelId);
|
|
1528
|
+
return { data: { deleted: { id: deleted.id, name: deleted.name } } };
|
|
1529
|
+
});
|
|
1530
|
+
});
|
|
1322
1531
|
const listSendAsRoute = createRoute({
|
|
1323
1532
|
method: 'get',
|
|
1324
1533
|
path: '/api/v1/accounts/{accountId}/send-as',
|