@dxv-systems/mail-graph 0.7.1 → 0.9.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 +14 -2
- package/dist/http.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/mailbox.d.ts +8 -1
- package/dist/mailbox.js +49 -16
- package/dist/types.d.ts +7 -1
- package/docs/app-integration.md +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ npm i @dxv-systems/mail-graph
|
|
|
10
10
|
|
|
11
11
|
## Never deletes customer mail
|
|
12
12
|
|
|
13
|
-
There is no delete except `deleteDraft`, which
|
|
13
|
+
There is no delete except `deleteDraft` and `removeAttachment`, which both refuse anything that is not a draft. The general request layer accepts only `GET`, `POST` and `PATCH`; anything else throws `GraphUsageError` (`MethodNotAllowed`) before a request is made. The one `PUT` is a chunk of an attachment upload session, sent to the `uploadUrl` Graph returned for that session. Customer mail is moved (`moveMessage`), never removed.
|
|
14
14
|
|
|
15
15
|
`deleteDraft(draftId)` is for drafts the helpdesk created itself. It first reads `isDraft`; unless that is exactly `true` it returns `{ status: "not_draft" }` and sends no DELETE. It returns `{ status: "gone" }` on a 404 (at the read or at the DELETE) and `{ status: "deleted" }` after a successful DELETE. A 429 or 503 on the DELETE is retried (a repeat is harmless); a network error is not. Per Graph's documentation a DELETE moves the item to Deleted Items; that is unverified until the real-tenant test. There is a small window: if someone sends the draft from Outlook between the read and the DELETE, the sent copy could end up in Deleted Items. Tests prove every DELETE is preceded by an `isDraft: true` read of the same message.
|
|
16
16
|
|
|
@@ -71,7 +71,7 @@ Only links on `https://graph.microsoft.com/v1.0/` are followed. Any other link t
|
|
|
71
71
|
|
|
72
72
|
```ts
|
|
73
73
|
const message = await support.getMessage(id, { bodyType: "text", includeHeaders: true });
|
|
74
|
-
// message.body, conversationId, internetMessageId, toRecipients…
|
|
74
|
+
// message.body, conversationId, internetMessageId, toRecipients, ccRecipients, bccRecipients (0.8; only the sender's own copy has Bcc)…
|
|
75
75
|
// with includeHeaders: inReplyTo, references[] (null when the message is gone)
|
|
76
76
|
const attachments = await support.listAttachments(id); // id, name, contentType, size, isInline, kind, contentId (file attachments: the `cid:` the HTML body uses)
|
|
77
77
|
const bytes = await support.downloadAttachment(id, attachments[0].id); // Uint8Array
|
|
@@ -98,6 +98,15 @@ await support.sendDraft(draft.id); // lands i
|
|
|
98
98
|
|
|
99
99
|
`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.
|
|
100
100
|
|
|
101
|
+
## Editing a draft
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
await support.updateDraft(draftId, { to, cc, bcc, subject }); // only the fields given; { status: "updated" | "gone" | "not_draft" }
|
|
105
|
+
await support.removeAttachment(draftId, attachmentId); // { status: "removed" | "gone" | "not_draft" }
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
For any draft in the mailbox, also one made in Outlook. Both read `isDraft` first, like `deleteDraft`, and write nothing unless it is exactly `true`; a 404 at the read or the write is `gone`. `updateDraft` refuses an empty `to` and an empty change; an empty `cc` or `bcc` clears it. `updateDraftBody` still sets the body; `listAttachments` gives the ids for `removeAttachment`.
|
|
109
|
+
|
|
101
110
|
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.
|
|
102
111
|
|
|
103
112
|
## State, folders, sending
|
|
@@ -109,6 +118,7 @@ await support.listFolders("inbox"); // children of the inbox; "root" fo
|
|
|
109
118
|
await support.listChildFolders(folderId); // children of any folder (id or well-known name)
|
|
110
119
|
await support.getWellKnownFolderIds(); // { inbox, archive, deleteditems, sentitems, drafts, junkemail }: id or null
|
|
111
120
|
await support.listFolderMessages(folderId); // one page, newest first: { items, nextLink }; pass { link: nextLink } for older mail
|
|
121
|
+
await support.listFolderMessages(folderId, { search: "frank" }); // 0.8: every word in sender, To/Cc/Bcc, subject or body
|
|
112
122
|
await support.getInboxFolderId();
|
|
113
123
|
await support.createInboxFolder("Handled");
|
|
114
124
|
await support.moveMessage(id, folderId); // or a well-known name: "archive", "deleteditems", "inbox"; the id stays the same
|
|
@@ -118,6 +128,8 @@ await support.sendMail({ to, subject, body: { contentType: "html", content }, at
|
|
|
118
128
|
|
|
119
129
|
`listConversation(conversationId)` returns every message of a conversation in any folder (Inbox, Sent Items, Archive, the mailbox's own folders), oldest first. Each has `uniqueBody`: only the text that message adds, without the quoted history, as plain text by default (`{ bodyType: "html" }` for HTML). Graph refuses `$orderby` with this filter, so the package sorts. Drafts and Deleted Items are included; filter on `isDraft` and `parentFolderId` as needed.
|
|
120
130
|
|
|
131
|
+
Folder page items (0.8) also carry `toRecipients` and `ccRecipients`, so a Sent Items list can show who each mail went to without a GET per message. `search` uses Graph's `$search` (KQL): each word is matched as free text (sender, subject, body) or as `recipients:` (To, Cc, Bcc), lowercased and stripped of KQL characters so user text cannot change the query. Graph refuses `$orderby` with `$search`, so a search page comes in Graph's own order, newest first. Exchange matches whole words and word prefixes, not substrings.
|
|
132
|
+
|
|
121
133
|
Message summaries (delta, folder pages, `getMessage`) carry `bodyPreview`: Graph's first 255 characters of the body as plain text. `getMessage` and `listFolderMessages` also carry `lastVerb` (0.7): `{ verb: "reply" | "replyAll" | "forward", at }` when the message was replied to or forwarded, in Outlook or through `createReply`/`createForward` and `sendDraft` (Exchange records it on the original), else null. It is read with `$expand=singleValueExtendedProperties` (PidTagLastVerbExecuted and its time), which needs no permission beyond reading mail. Graph answers 400 to that expand on `messages/delta`, so delta items never carry it: a reply or forward does make the original show up in delta as changed, and `getLastVerbs(ids)` reads the verb of such messages (one GET each; an id that no longer exists is left out).
|
|
122
134
|
|
|
123
135
|
"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`.
|
package/dist/http.js
CHANGED
|
@@ -137,8 +137,8 @@ function createHttp(options) {
|
|
|
137
137
|
});
|
|
138
138
|
},
|
|
139
139
|
async deleteMessage(spec) {
|
|
140
|
-
if (!/^\/users\/[^/?#]+\/messages\/[^/?#]
|
|
141
|
-
throw new errors_1.GraphUsageError("InvalidArgument", "deleteMessage only accepts /users/{mailbox}/messages/{id}.");
|
|
140
|
+
if (!/^\/users\/[^/?#]+\/messages\/[^/?#]+(\/attachments\/[^/?#]+)?$/.test(spec.path)) {
|
|
141
|
+
throw new errors_1.GraphUsageError("InvalidArgument", "deleteMessage only accepts /users/{mailbox}/messages/{id}[/attachments/{id}].");
|
|
142
142
|
}
|
|
143
143
|
return execute({
|
|
144
144
|
mailbox: spec.mailbox,
|
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, LastVerb, MailAddress, MailFolder, Message, MessageBody, MessageSummary, OutgoingAttachment, Recipient, SendMailInput, CreateDraftInput, CreateForwardOptions, DraftOverrides, ConversationMessage, ListConversationOptions, WellKnownFolder, WellKnownFolderIds, } from "./types";
|
|
9
|
+
export type { AccessCheckResult, AccessStatus, AttachmentInfo, AttachmentKind, BodyType, CreateReplyOptions, DeltaItem, DeltaOptions, DeltaPage, FolderMessagesOptions, FolderMessage, FolderMessagesPage, ForwardInput, GetMessageOptions, InternetMessageHeader, LastVerb, MailAddress, MailFolder, Message, MessageBody, MessageSummary, OutgoingAttachment, Recipient, SendMailInput, CreateDraftInput, CreateForwardOptions, DraftOverrides, ConversationMessage, ListConversationOptions, WellKnownFolder, WellKnownFolderIds, } from "./types";
|
package/dist/mailbox.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Http } from "./http";
|
|
2
|
-
import type { AccessCheckResult, AttachmentInfo, CreateForwardOptions, CreateReplyOptions, DeltaOptions, DeltaPage, FolderMessagesOptions, FolderMessagesPage, ForwardInput, GetMessageOptions, LastVerb, MailFolder, Message, MessageBody, OutgoingAttachment, SendMailInput, CreateDraftInput, ConversationMessage, ListConversationOptions, WellKnownFolderIds } from "./types";
|
|
2
|
+
import type { AccessCheckResult, AttachmentInfo, CreateForwardOptions, CreateReplyOptions, DraftOverrides, DeltaOptions, DeltaPage, FolderMessagesOptions, FolderMessagesPage, ForwardInput, GetMessageOptions, LastVerb, MailFolder, Message, MessageBody, OutgoingAttachment, SendMailInput, CreateDraftInput, ConversationMessage, ListConversationOptions, WellKnownFolderIds } from "./types";
|
|
3
3
|
export declare const LARGE_ATTACHMENT_THRESHOLD: number;
|
|
4
4
|
interface RawExtendedProperty {
|
|
5
5
|
id?: string;
|
|
6
6
|
value?: string;
|
|
7
7
|
}
|
|
8
8
|
export declare function parseLastVerb(props: RawExtendedProperty[] | undefined): LastVerb | null;
|
|
9
|
+
export declare function searchQuery(text: string): string;
|
|
9
10
|
export interface MailboxClient {
|
|
10
11
|
readonly address: string;
|
|
11
12
|
checkAccess(): Promise<{
|
|
@@ -19,9 +20,15 @@ export interface MailboxClient {
|
|
|
19
20
|
createReply(messageId: string, options?: CreateReplyOptions): Promise<Message>;
|
|
20
21
|
createForward(messageId: string, options?: CreateForwardOptions): Promise<Message>;
|
|
21
22
|
updateDraftBody(draftId: string, body: MessageBody): Promise<void>;
|
|
23
|
+
updateDraft(draftId: string, changes: DraftOverrides): Promise<{
|
|
24
|
+
status: "updated" | "gone" | "not_draft";
|
|
25
|
+
}>;
|
|
22
26
|
addAttachment(draftId: string, attachment: OutgoingAttachment): Promise<{
|
|
23
27
|
id?: string;
|
|
24
28
|
}>;
|
|
29
|
+
removeAttachment(draftId: string, attachmentId: string): Promise<{
|
|
30
|
+
status: "removed" | "gone" | "not_draft";
|
|
31
|
+
}>;
|
|
25
32
|
sendDraft(draftId: string): Promise<void>;
|
|
26
33
|
markRead(messageId: string, isRead?: boolean): Promise<void>;
|
|
27
34
|
setCategories(messageId: string, categories: string[]): Promise<void>;
|
package/dist/mailbox.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LARGE_ATTACHMENT_THRESHOLD = void 0;
|
|
4
4
|
exports.parseLastVerb = parseLastVerb;
|
|
5
|
+
exports.searchQuery = searchQuery;
|
|
5
6
|
exports.createMailboxClient = createMailboxClient;
|
|
6
7
|
const errors_1 = require("./errors");
|
|
7
8
|
exports.LARGE_ATTACHMENT_THRESHOLD = 3 * 1024 * 1024;
|
|
@@ -73,6 +74,7 @@ function toMessage(raw, includeHeaders) {
|
|
|
73
74
|
body: { contentType, content: raw.body?.content ?? "" },
|
|
74
75
|
toRecipients: toAddresses(raw.toRecipients),
|
|
75
76
|
ccRecipients: toAddresses(raw.ccRecipients),
|
|
77
|
+
bccRecipients: toAddresses(raw.bccRecipients),
|
|
76
78
|
replyTo: toAddresses(raw.replyTo),
|
|
77
79
|
};
|
|
78
80
|
if (raw.sentDateTime !== undefined)
|
|
@@ -130,6 +132,19 @@ function query(params) {
|
|
|
130
132
|
.map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`);
|
|
131
133
|
return parts.length ? `?${parts.join("&")}` : "";
|
|
132
134
|
}
|
|
135
|
+
const MAX_SEARCH_WORDS = 8;
|
|
136
|
+
function searchQuery(text) {
|
|
137
|
+
const words = text
|
|
138
|
+
.toLowerCase()
|
|
139
|
+
.replace(/["\\():*<>=+]/g, " ")
|
|
140
|
+
.split(/\s+/)
|
|
141
|
+
.map((w) => w.replace(/^-+/, "").slice(0, 100))
|
|
142
|
+
.filter(Boolean)
|
|
143
|
+
.slice(0, MAX_SEARCH_WORDS);
|
|
144
|
+
if (words.length === 0)
|
|
145
|
+
throw new errors_1.GraphUsageError("InvalidArgument", "search needs at least one word.");
|
|
146
|
+
return `"${words.map((w) => `(${w} OR recipients:${w})`).join(" AND ")}"`;
|
|
147
|
+
}
|
|
133
148
|
function toBase64(bytes) {
|
|
134
149
|
return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
|
|
135
150
|
}
|
|
@@ -152,6 +167,20 @@ function createMailboxClient(http, address) {
|
|
|
152
167
|
const result = await http.request({ mailbox: address, method: "GET", path, prefer });
|
|
153
168
|
return (result.data ?? {});
|
|
154
169
|
}
|
|
170
|
+
async function onDraft(path, done, write) {
|
|
171
|
+
try {
|
|
172
|
+
const current = await getJson(`${path}${query({ $select: "isDraft" })}`);
|
|
173
|
+
if (current.isDraft !== true)
|
|
174
|
+
return { status: "not_draft" };
|
|
175
|
+
await write();
|
|
176
|
+
return { status: done };
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
if (error instanceof errors_1.GraphError && error.status === 404)
|
|
180
|
+
return { status: "gone" };
|
|
181
|
+
throw error;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
155
184
|
async function createDraftFrom(messageId, action, options) {
|
|
156
185
|
const message = draftOverrides(options);
|
|
157
186
|
const body = {
|
|
@@ -306,7 +335,7 @@ function createMailboxClient(http, address) {
|
|
|
306
335
|
},
|
|
307
336
|
async getMessage(id, options = {}) {
|
|
308
337
|
const bodyType = options.bodyType ?? "html";
|
|
309
|
-
const select = `${SUMMARY_SELECT},body,sentDateTime,toRecipients,ccRecipients,replyTo${options.includeHeaders ? ",internetMessageHeaders" : ""}`;
|
|
338
|
+
const select = `${SUMMARY_SELECT},body,sentDateTime,toRecipients,ccRecipients,bccRecipients,replyTo${options.includeHeaders ? ",internetMessageHeaders" : ""}`;
|
|
310
339
|
try {
|
|
311
340
|
const raw = await getJson(`${user}/messages/${requireId(id, "message id")}${query({ $select: select, $expand: LAST_VERB_EXPAND })}`, [
|
|
312
341
|
`outlook.body-content-type="${bodyType}"`,
|
|
@@ -458,20 +487,23 @@ function createMailboxClient(http, address) {
|
|
|
458
487
|
});
|
|
459
488
|
},
|
|
460
489
|
async listFolderMessages(folderId, options = {}) {
|
|
490
|
+
const search = options.link || options.search === undefined ? undefined : searchQuery(options.search);
|
|
461
491
|
const result = options.link
|
|
462
492
|
? await http.request({ mailbox: address, method: "GET", link: options.link })
|
|
463
493
|
: await http.request({
|
|
464
494
|
mailbox: address,
|
|
465
495
|
method: "GET",
|
|
466
496
|
path: `${user}/mailFolders/${requireId(folderId, "folder id")}/messages${query({
|
|
467
|
-
$select: SUMMARY_SELECT,
|
|
468
|
-
$orderby: "receivedDateTime desc",
|
|
497
|
+
$select: `${SUMMARY_SELECT},toRecipients,ccRecipients`,
|
|
498
|
+
$orderby: search ? undefined : "receivedDateTime desc",
|
|
499
|
+
$search: search,
|
|
469
500
|
$expand: LAST_VERB_EXPAND,
|
|
470
501
|
$top: Math.min(100, Math.max(1, Math.floor(options.pageSize ?? 50))),
|
|
471
502
|
})}`,
|
|
472
503
|
});
|
|
473
504
|
const page = (result.data ?? {});
|
|
474
|
-
|
|
505
|
+
const items = (page.value ?? []).map((m) => ({ ...withLastVerb(toSummary(m), m), toRecipients: toAddresses(m.toRecipients), ccRecipients: toAddresses(m.ccRecipients) }));
|
|
506
|
+
return { items, nextLink: page["@odata.nextLink"] ?? null };
|
|
475
507
|
},
|
|
476
508
|
async getInboxFolderId() {
|
|
477
509
|
const folder = await getJson(`${user}/mailFolders/inbox${query({ $select: "id" })}`);
|
|
@@ -503,18 +535,19 @@ function createMailboxClient(http, address) {
|
|
|
503
535
|
},
|
|
504
536
|
async deleteDraft(draftId) {
|
|
505
537
|
const path = `${user}/messages/${requireId(draftId, "draft id")}`;
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
}
|
|
538
|
+
return onDraft(path, "deleted", () => http.deleteMessage({ mailbox: address, path }));
|
|
539
|
+
},
|
|
540
|
+
async updateDraft(draftId, changes) {
|
|
541
|
+
const path = `${user}/messages/${requireId(draftId, "draft id")}`;
|
|
542
|
+
const body = draftOverrides(changes);
|
|
543
|
+
if (!body)
|
|
544
|
+
throw new errors_1.GraphUsageError("InvalidArgument", "updateDraft needs at least one of to, cc, bcc and subject.");
|
|
545
|
+
return onDraft(path, "updated", () => http.request({ mailbox: address, method: "PATCH", path, body }));
|
|
546
|
+
},
|
|
547
|
+
async removeAttachment(draftId, attachmentId) {
|
|
548
|
+
const path = `${user}/messages/${requireId(draftId, "draft id")}`;
|
|
549
|
+
const attachmentPath = `${path}/attachments/${requireId(attachmentId, "attachment id")}`;
|
|
550
|
+
return onDraft(path, "removed", () => http.deleteMessage({ mailbox: address, path: attachmentPath }));
|
|
518
551
|
},
|
|
519
552
|
async forward(messageId, input) {
|
|
520
553
|
await http.request({
|
package/dist/types.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export interface Message extends MessageSummary {
|
|
|
51
51
|
sentDateTime?: string;
|
|
52
52
|
toRecipients: MailAddress[];
|
|
53
53
|
ccRecipients: MailAddress[];
|
|
54
|
+
bccRecipients: MailAddress[];
|
|
54
55
|
replyTo: MailAddress[];
|
|
55
56
|
internetMessageHeaders?: InternetMessageHeader[];
|
|
56
57
|
inReplyTo?: string;
|
|
@@ -109,9 +110,14 @@ export type WellKnownFolderIds = Record<WellKnownFolder, string | null>;
|
|
|
109
110
|
export interface FolderMessagesOptions {
|
|
110
111
|
link?: string;
|
|
111
112
|
pageSize?: number;
|
|
113
|
+
search?: string;
|
|
114
|
+
}
|
|
115
|
+
export interface FolderMessage extends MessageSummary {
|
|
116
|
+
toRecipients: MailAddress[];
|
|
117
|
+
ccRecipients: MailAddress[];
|
|
112
118
|
}
|
|
113
119
|
export interface FolderMessagesPage {
|
|
114
|
-
items:
|
|
120
|
+
items: FolderMessage[];
|
|
115
121
|
nextLink: string | null;
|
|
116
122
|
}
|
|
117
123
|
export interface ForwardInput {
|
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.9.0 @dxv-systems/helpdesk@0.18.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.
|
|
@@ -308,7 +308,7 @@ export const helpdeskReplyAttachments = pgTable(
|
|
|
308
308
|
);
|
|
309
309
|
```
|
|
310
310
|
|
|
311
|
-
Every column maps one field of the package types (`M365Connection`, `SyncState`, `Thread` incl. `dismissedBy`, `StoredMessage`, `DraftRun`, `SendIntent`, `ReplyAttachment`); `assignee_id`, `assignment_note` and `assigned_by` are the inbox's assignment, `seq` orders draft runs, `sync_lease_until` guards cron overlap. Then run `npm run db:generate`, review the SQL (ten `CREATE TABLE`s, foreign keys, nine indexes, no `DROP`) and commit it with its snapshot and journal entry. An app on helpdesk 0.2 upgrades with one generated migration: `direction` on `helpdesk_messages` (default `inbound`) and `sent_link`, `sent_last_received_at` on `helpdesk_sync_states` (see the helpdesk README, Upgrading from 0.2). An app on helpdesk 0.4 upgrades with one generated migration too: `assignment_note` and `assigned_by` on `helpdesk_threads`, both nullable (see the helpdesk README, Upgrading from 0.4). An app on helpdesk 0.5 upgrades with one generated migration: `from_name`, `preview`, `has_attachments`, `is_read` and `location` on `helpdesk_messages`, all nullable, and its store's `markMessageRemoved` becomes `updateMessageState`. Add `update helpdesk_sync_states set link = null, sent_link = null;` to the end of that generated migration, so the next sync fills the new fields of mail already stored (see the helpdesk README, Upgrading from 0.5). An app on helpdesk 0.11 upgrades with one generated migration: the table `helpdesk_history_states` and `history_lease_until` on `helpdesk_settings`, nothing dropped (see the helpdesk README, Upgrading from 0.11). An app on helpdesk 0.13 upgrades with one generated migration: the table `helpdesk_distill_states` and `distill_lease_until` on `helpdesk_settings`, nothing dropped; then add the store methods, `claimDistillLease`, the distiller in `deps.ts`, the distill cron and the settings card below (see the helpdesk README, Upgrading from 0.13.0). An app on helpdesk 0.14 upgrades with one generated migration: `to_recipients` and `cc_recipients` (jsonb, nullable) on `helpdesk_messages`, and two lines in `toMessage` (see the helpdesk README, Upgrading from 0.14.0). An app on helpdesk 0.15 upgrades with one generated migration: `last_verb` (jsonb, nullable) on `helpdesk_messages`, and one line in `toMessage` (see the helpdesk README, Upgrading from 0.15.0). An app on helpdesk 0.16 upgrades with one generated migration: `draft_mode` (varchar, not null, default `on_request`) on `helpdesk_settings`, nothing dropped; then add the draft mode to `settings.ts`, the actions, the settings form and page, the drafter in `deps.ts`, and `collectDrafts` in the sync cron below (see the helpdesk README, Upgrading from 0.16.0). The store, the crons and `vercel.json` do not change.
|
|
311
|
+
Every column maps one field of the package types (`M365Connection`, `SyncState`, `Thread` incl. `dismissedBy`, `StoredMessage`, `DraftRun`, `SendIntent`, `ReplyAttachment`); `assignee_id`, `assignment_note` and `assigned_by` are the inbox's assignment, `seq` orders draft runs, `sync_lease_until` guards cron overlap. Then run `npm run db:generate`, review the SQL (ten `CREATE TABLE`s, foreign keys, nine indexes, no `DROP`) and commit it with its snapshot and journal entry. An app on helpdesk 0.2 upgrades with one generated migration: `direction` on `helpdesk_messages` (default `inbound`) and `sent_link`, `sent_last_received_at` on `helpdesk_sync_states` (see the helpdesk README, Upgrading from 0.2). An app on helpdesk 0.4 upgrades with one generated migration too: `assignment_note` and `assigned_by` on `helpdesk_threads`, both nullable (see the helpdesk README, Upgrading from 0.4). An app on helpdesk 0.5 upgrades with one generated migration: `from_name`, `preview`, `has_attachments`, `is_read` and `location` on `helpdesk_messages`, all nullable, and its store's `markMessageRemoved` becomes `updateMessageState`. Add `update helpdesk_sync_states set link = null, sent_link = null;` to the end of that generated migration, so the next sync fills the new fields of mail already stored (see the helpdesk README, Upgrading from 0.5). An app on helpdesk 0.11 upgrades with one generated migration: the table `helpdesk_history_states` and `history_lease_until` on `helpdesk_settings`, nothing dropped (see the helpdesk README, Upgrading from 0.11). An app on helpdesk 0.13 upgrades with one generated migration: the table `helpdesk_distill_states` and `distill_lease_until` on `helpdesk_settings`, nothing dropped; then add the store methods, `claimDistillLease`, the distiller in `deps.ts`, the distill cron and the settings card below (see the helpdesk README, Upgrading from 0.13.0). An app on helpdesk 0.14 upgrades with one generated migration: `to_recipients` and `cc_recipients` (jsonb, nullable) on `helpdesk_messages`, and two lines in `toMessage` (see the helpdesk README, Upgrading from 0.14.0). An app on helpdesk 0.15 upgrades with one generated migration: `last_verb` (jsonb, nullable) on `helpdesk_messages`, and one line in `toMessage` (see the helpdesk README, Upgrading from 0.15.0). An app on helpdesk 0.16 upgrades with one generated migration: `draft_mode` (varchar, not null, default `on_request`) on `helpdesk_settings`, nothing dropped; then add the draft mode to `settings.ts`, the actions, the settings form and page, the drafter in `deps.ts`, and `collectDrafts` in the sync cron below (see the helpdesk README, Upgrading from 0.16.0). An app on helpdesk 0.17 upgrades without a migration: install mail-graph 0.8.0 with it (the gateway now requires recipients and search), then use `to`/`cc` on folder messages, `bcc` on a message body and `q` on the folder route where the app's screens want them (see the helpdesk README, Upgrading from 0.17.0). The store, the crons and `vercel.json` do not change.
|
|
312
312
|
|
|
313
313
|
## 5. `src/lib/m365/` (Graph sign-in and the guided setup)
|
|
314
314
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxv-systems/mail-graph",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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",
|