@dxv-systems/mail-graph 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/dist/index.d.ts +1 -1
- package/dist/mailbox.d.ts +2 -1
- package/dist/mailbox.js +20 -1
- package/dist/types.d.ts +1 -0
- package/docs/app-integration.md +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -86,6 +86,18 @@ await support.addAttachment(draft.id, { name, contentType, content }); // 3 MB a
|
|
|
86
86
|
await support.sendDraft(draft.id); // threads natively, lands in Sent Items
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
+
## New mail with large files
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
const draft = await support.createDraft({ to, cc, bcc, subject, body: { contentType: "html", content } }); // in Drafts
|
|
93
|
+
await support.addAttachment(draft.id, { name, contentType, content }); // 3 MB and up: upload session, up to 150 MB per file
|
|
94
|
+
await support.sendDraft(draft.id); // lands in Sent Items
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`createDraft` takes `sendMail`'s fields without attachments. It is not retried on `503`, so an unclear answer never leaves a second draft. If sending fails, `deleteDraft(draft.id)` removes the draft.
|
|
98
|
+
|
|
99
|
+
150 MB is Graph's limit per upload. The mailbox's own maximum send size still applies: 35 MB by default in Exchange Online, raised per mailbox by the tenant's admin (`Set-Mailbox -MaxSendSize`). Receiving servers may accept less.
|
|
100
|
+
|
|
89
101
|
## State, folders, sending
|
|
90
102
|
|
|
91
103
|
```ts
|
|
@@ -106,7 +118,7 @@ Message summaries (delta, folder pages, `getMessage`) carry `bodyPreview`: Graph
|
|
|
106
118
|
|
|
107
119
|
"Delete" for customer mail is `moveMessage(id, "deleteditems")`, the same as Delete in Outlook. `listFolderMessages` is for folders a caller reads live (Archive, Deleted Items, custom folders); the Inbox and Sent Items go through `delta`.
|
|
108
120
|
|
|
109
|
-
`sendMail` attachments must total under 3 MB (a Graph request limit); for larger files
|
|
121
|
+
`sendMail` attachments must total under 3 MB (a Graph request limit); for larger files use `createDraft` (above), reply, or forward.
|
|
110
122
|
|
|
111
123
|
### Access check
|
|
112
124
|
|
package/dist/index.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export { LARGE_ATTACHMENT_THRESHOLD } from "./mailbox";
|
|
|
6
6
|
export type { MailboxClient } from "./mailbox";
|
|
7
7
|
export { GraphAuthError, GraphDeltaExpiredError, GraphError, GraphUsageError } from "./errors";
|
|
8
8
|
export type { GraphErrorInit, UsageErrorCode } from "./errors";
|
|
9
|
-
export type { AccessCheckResult, AccessStatus, AttachmentInfo, AttachmentKind, BodyType, CreateReplyOptions, DeltaItem, DeltaOptions, DeltaPage, FolderMessagesOptions, FolderMessagesPage, ForwardInput, GetMessageOptions, InternetMessageHeader, MailAddress, MailFolder, Message, MessageBody, MessageSummary, OutgoingAttachment, Recipient, SendMailInput, WellKnownFolder, WellKnownFolderIds, } from "./types";
|
|
9
|
+
export type { AccessCheckResult, AccessStatus, AttachmentInfo, AttachmentKind, BodyType, CreateReplyOptions, DeltaItem, DeltaOptions, DeltaPage, FolderMessagesOptions, FolderMessagesPage, ForwardInput, GetMessageOptions, InternetMessageHeader, MailAddress, MailFolder, Message, MessageBody, MessageSummary, OutgoingAttachment, Recipient, SendMailInput, CreateDraftInput, WellKnownFolder, WellKnownFolderIds, } from "./types";
|
package/dist/mailbox.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Http } from "./http";
|
|
2
|
-
import type { AccessCheckResult, AttachmentInfo, CreateReplyOptions, DeltaOptions, DeltaPage, FolderMessagesOptions, FolderMessagesPage, ForwardInput, GetMessageOptions, MailFolder, Message, MessageBody, OutgoingAttachment, SendMailInput, WellKnownFolderIds } from "./types";
|
|
2
|
+
import type { AccessCheckResult, AttachmentInfo, CreateReplyOptions, DeltaOptions, DeltaPage, FolderMessagesOptions, FolderMessagesPage, ForwardInput, GetMessageOptions, MailFolder, Message, MessageBody, OutgoingAttachment, SendMailInput, CreateDraftInput, WellKnownFolderIds } from "./types";
|
|
3
3
|
export declare const LARGE_ATTACHMENT_THRESHOLD: number;
|
|
4
4
|
export interface MailboxClient {
|
|
5
5
|
readonly address: string;
|
|
@@ -32,6 +32,7 @@ export interface MailboxClient {
|
|
|
32
32
|
status: "deleted" | "gone" | "not_draft";
|
|
33
33
|
}>;
|
|
34
34
|
sendMail(input: SendMailInput): Promise<void>;
|
|
35
|
+
createDraft(input: CreateDraftInput): Promise<Message>;
|
|
35
36
|
getMailboxPurpose(): Promise<string | null>;
|
|
36
37
|
listInboxRules(): Promise<InboxRuleInfo[] | null>;
|
|
37
38
|
}
|
package/dist/mailbox.js
CHANGED
|
@@ -446,7 +446,7 @@ function createMailboxClient(http, address) {
|
|
|
446
446
|
const attachments = input.attachments ?? [];
|
|
447
447
|
const total = attachments.reduce((sum, a) => sum + a.content.byteLength, 0);
|
|
448
448
|
if (total >= exports.LARGE_ATTACHMENT_THRESHOLD) {
|
|
449
|
-
throw new errors_1.GraphUsageError("AttachmentTooLarge", "sendMail attachments must stay under 3 MB in total;
|
|
449
|
+
throw new errors_1.GraphUsageError("AttachmentTooLarge", "sendMail attachments must stay under 3 MB in total; use createDraft and addAttachment instead.");
|
|
450
450
|
}
|
|
451
451
|
await http.request({
|
|
452
452
|
mailbox: address,
|
|
@@ -466,5 +466,24 @@ function createMailboxClient(http, address) {
|
|
|
466
466
|
retryOn503: false,
|
|
467
467
|
});
|
|
468
468
|
},
|
|
469
|
+
async createDraft(input) {
|
|
470
|
+
const result = await http.request({
|
|
471
|
+
mailbox: address,
|
|
472
|
+
method: "POST",
|
|
473
|
+
path: `${user}/messages`,
|
|
474
|
+
body: {
|
|
475
|
+
subject: input.subject,
|
|
476
|
+
body: graphBody(input.body),
|
|
477
|
+
toRecipients: requireRecipients(input.to),
|
|
478
|
+
ccRecipients: toRecipients(input.cc),
|
|
479
|
+
bccRecipients: toRecipients(input.bcc),
|
|
480
|
+
},
|
|
481
|
+
retryOn503: false,
|
|
482
|
+
});
|
|
483
|
+
const raw = result.data;
|
|
484
|
+
if (!raw?.id)
|
|
485
|
+
throw new errors_1.GraphError({ message: "createDraft returned no draft.", status: result.status, code: "InvalidResponse" });
|
|
486
|
+
return toMessage(raw, false);
|
|
487
|
+
},
|
|
469
488
|
};
|
|
470
489
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -104,6 +104,7 @@ export interface SendMailInput {
|
|
|
104
104
|
body: MessageBody;
|
|
105
105
|
attachments?: OutgoingAttachment[];
|
|
106
106
|
}
|
|
107
|
+
export type CreateDraftInput = Omit<SendMailInput, "attachments">;
|
|
107
108
|
export type AccessStatus = "ok" | "denied" | "not_found";
|
|
108
109
|
export interface AccessCheckResult {
|
|
109
110
|
status: AccessStatus;
|
package/docs/app-integration.md
CHANGED
|
@@ -17,7 +17,7 @@ The code below was compiled, linted, knip-checked, built and tested against a fr
|
|
|
17
17
|
## 1. Install
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
npm install --save-exact @dxv-systems/mail-graph@0.
|
|
20
|
+
npm install --save-exact @dxv-systems/mail-graph@0.4.0 @dxv-systems/helpdesk@0.13.0 @vercel/oidc@4.0.1
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
Use the published versions (exact, never a range; upgrading is a deliberate change). **Vendored variant** (before publication, e.g. the rehearsal): `npm pack` each package into `vendor/` and install `file:vendor/dxv-systems-mail-graph-<version>.tgz file:vendor/dxv-systems-helpdesk-<version>.tgz` instead; commit the tarballs with `package.json` and the lockfile.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxv-systems/mail-graph",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Microsoft Graph mail for DXV apps — app-only auth via a caller-supplied client assertion (federated or certificate), per-mailbox delta sync, messages, attachments, threaded replies, folders, forward and send. Never deletes. Guided Microsoft 365 setup (route handlers and a React page) under ./setup. Zero runtime dependencies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dxv",
|