@pallasoft/ps-mail 1.1.0 → 1.3.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 +3 -0
- package/dist/microsoft/constants/graph-mail-config.d.ts +9 -0
- package/dist/microsoft/constants/graph-mail-config.js +9 -0
- package/dist/microsoft/constants/graph-mail-lifecycle-event.d.ts +5 -0
- package/dist/microsoft/constants/graph-mail-lifecycle-event.js +9 -0
- package/dist/microsoft/constants/index.d.ts +1 -0
- package/dist/microsoft/constants/index.js +1 -0
- package/dist/microsoft/index.d.ts +2 -2
- package/dist/microsoft/index.js +2 -1
- package/dist/microsoft/models/graph-mail-draft-data.d.ts +1 -0
- package/dist/microsoft/models/graph-mail-located-data.d.ts +6 -0
- package/dist/microsoft/models/graph-mail-located-data.js +2 -0
- package/dist/microsoft/models/graph-mail-notification-data.d.ts +7 -0
- package/dist/microsoft/models/graph-mail-notification-data.js +2 -0
- package/dist/microsoft/models/graph-mail-notification-payload-data.d.ts +4 -0
- package/dist/microsoft/models/graph-mail-notification-payload-data.js +2 -0
- package/dist/microsoft/models/graph-mail-outgoing-message-data.d.ts +1 -0
- package/dist/microsoft/models/graph-mail-reply-data.d.ts +3 -0
- package/dist/microsoft/models/graph-mail-subscription-data.d.ts +5 -0
- package/dist/microsoft/models/graph-mail-subscription-data.js +2 -0
- package/dist/microsoft/models/graph-mail-subscription-options.d.ts +6 -0
- package/dist/microsoft/models/graph-mail-subscription-options.js +2 -0
- package/dist/microsoft/models/graph-mail-subscription-renew-request.d.ts +3 -0
- package/dist/microsoft/models/graph-mail-subscription-renew-request.js +2 -0
- package/dist/microsoft/models/graph-mail-subscription-request.d.ts +8 -0
- package/dist/microsoft/models/graph-mail-subscription-request.js +2 -0
- package/dist/microsoft/models/index.d.ts +7 -0
- package/dist/microsoft/services/graph-mail-service.d.ts +10 -0
- package/dist/microsoft/services/graph-mail-service.js +129 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,9 @@ permissions `Mail.ReadWrite` and `Mail.Send`).
|
|
|
13
13
|
- `GraphMailService.sendMail`, `createAndSend` and `reply` send mail from the mailbox; `reply` stays
|
|
14
14
|
in the conversation.
|
|
15
15
|
- `GraphMailService.setCategories` tags a message for people working in Outlook.
|
|
16
|
+
- `GraphMailService.subscribe` / `renewSubscription` / `deleteSubscription` manage Graph change
|
|
17
|
+
notification subscriptions for a folder (`GraphMailLifecycleEvent` names the lifecycle events;
|
|
18
|
+
`GraphMailNotificationPayloadData` is the webhook body).
|
|
16
19
|
- `GraphMailErrorService.isSyncStateExpired(error)` tells the caller to drop its delta link and
|
|
17
20
|
resync. Throttling (429/503 with `Retry-After`) and an expired token (401) are retried inside.
|
|
18
21
|
|
|
@@ -15,6 +15,7 @@ export declare const GraphMailConfig: {
|
|
|
15
15
|
readonly messages: "messages";
|
|
16
16
|
readonly send: "send";
|
|
17
17
|
readonly sendMail: "sendMail";
|
|
18
|
+
readonly subscriptions: "subscriptions";
|
|
18
19
|
readonly users: "users";
|
|
19
20
|
readonly value: "$value";
|
|
20
21
|
};
|
|
@@ -22,6 +23,8 @@ export declare const GraphMailConfig: {
|
|
|
22
23
|
readonly filter: "$filter";
|
|
23
24
|
readonly select: "$select";
|
|
24
25
|
readonly receivedSinceFilter: "receivedDateTime ge ";
|
|
26
|
+
readonly internetMessageIdFilter: "internetMessageId eq ";
|
|
27
|
+
readonly top: "$top";
|
|
25
28
|
};
|
|
26
29
|
readonly prefer: {
|
|
27
30
|
readonly immutableIds: "IdType=\"ImmutableId\"";
|
|
@@ -32,6 +35,9 @@ export declare const GraphMailConfig: {
|
|
|
32
35
|
readonly deltaPageSize: 50;
|
|
33
36
|
readonly deltaFields: readonly ["id", "conversationId", "internetMessageId", "subject", "from", "sender", "toRecipients", "ccRecipients", "replyTo", "receivedDateTime", "sentDateTime", "hasAttachments", "isDraft", "categories", "bodyPreview"];
|
|
34
37
|
readonly messageFields: readonly ["id", "conversationId", "internetMessageId", "subject", "from", "sender", "toRecipients", "ccRecipients", "replyTo", "receivedDateTime", "sentDateTime", "hasAttachments", "isDraft", "categories", "bodyPreview", "body", "uniqueBody", "internetMessageHeaders"];
|
|
38
|
+
readonly filterQuote: "'";
|
|
39
|
+
readonly locateFields: readonly ["id", "isDraft", "conversationId", "internetMessageId"];
|
|
40
|
+
readonly locateTop: "1";
|
|
35
41
|
readonly attachmentFields: readonly ["id", "name", "contentType", "size", "isInline"];
|
|
36
42
|
readonly syncResetErrorCodes: readonly ["syncstatenotfound", "syncstateinvalid", "resyncrequired"];
|
|
37
43
|
readonly retry: {
|
|
@@ -48,4 +54,7 @@ export declare const GraphMailConfig: {
|
|
|
48
54
|
readonly rangeUnit: "bytes ";
|
|
49
55
|
};
|
|
50
56
|
readonly saveToSentItems: true;
|
|
57
|
+
readonly subscription: {
|
|
58
|
+
readonly changeType: "created,updated";
|
|
59
|
+
};
|
|
51
60
|
};
|
|
@@ -18,6 +18,7 @@ exports.GraphMailConfig = {
|
|
|
18
18
|
messages: 'messages',
|
|
19
19
|
send: 'send',
|
|
20
20
|
sendMail: 'sendMail',
|
|
21
|
+
subscriptions: 'subscriptions',
|
|
21
22
|
users: 'users',
|
|
22
23
|
value: '$value',
|
|
23
24
|
},
|
|
@@ -25,6 +26,8 @@ exports.GraphMailConfig = {
|
|
|
25
26
|
filter: '$filter',
|
|
26
27
|
select: '$select',
|
|
27
28
|
receivedSinceFilter: 'receivedDateTime ge ',
|
|
29
|
+
internetMessageIdFilter: 'internetMessageId eq ',
|
|
30
|
+
top: '$top',
|
|
28
31
|
},
|
|
29
32
|
prefer: {
|
|
30
33
|
immutableIds: 'IdType="ImmutableId"',
|
|
@@ -70,6 +73,9 @@ exports.GraphMailConfig = {
|
|
|
70
73
|
'uniqueBody',
|
|
71
74
|
'internetMessageHeaders',
|
|
72
75
|
],
|
|
76
|
+
filterQuote: "'",
|
|
77
|
+
locateFields: ['id', 'isDraft', 'conversationId', 'internetMessageId'],
|
|
78
|
+
locateTop: '1',
|
|
73
79
|
attachmentFields: ['id', 'name', 'contentType', 'size', 'isInline'],
|
|
74
80
|
syncResetErrorCodes: ['syncstatenotfound', 'syncstateinvalid', 'resyncrequired'],
|
|
75
81
|
retry: {
|
|
@@ -86,4 +92,7 @@ exports.GraphMailConfig = {
|
|
|
86
92
|
rangeUnit: 'bytes ',
|
|
87
93
|
},
|
|
88
94
|
saveToSentItems: true,
|
|
95
|
+
subscription: {
|
|
96
|
+
changeType: 'created,updated',
|
|
97
|
+
},
|
|
89
98
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GraphMailLifecycleEvent = void 0;
|
|
4
|
+
var GraphMailLifecycleEvent;
|
|
5
|
+
(function (GraphMailLifecycleEvent) {
|
|
6
|
+
GraphMailLifecycleEvent["Missed"] = "missed";
|
|
7
|
+
GraphMailLifecycleEvent["ReauthorizationRequired"] = "reauthorizationRequired";
|
|
8
|
+
GraphMailLifecycleEvent["SubscriptionRemoved"] = "subscriptionRemoved";
|
|
9
|
+
})(GraphMailLifecycleEvent || (exports.GraphMailLifecycleEvent = GraphMailLifecycleEvent = {}));
|
|
@@ -19,3 +19,4 @@ __exportStar(require("./graph-mail-config"), exports);
|
|
|
19
19
|
__exportStar(require("./graph-mail-error-messages"), exports);
|
|
20
20
|
__exportStar(require("./graph-mail-error-reason"), exports);
|
|
21
21
|
__exportStar(require("./graph-mail-folder"), exports);
|
|
22
|
+
__exportStar(require("./graph-mail-lifecycle-event"), exports);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { GraphMailBodyType, GraphMailErrorReason, GraphMailFolder } from './constants';
|
|
1
|
+
export { GraphMailBodyType, GraphMailErrorReason, GraphMailFolder, GraphMailLifecycleEvent, } from './constants';
|
|
2
2
|
export { GraphMailErrorService, GraphMailService } from './services';
|
|
3
|
-
export type { GraphCredentials, GraphMailBodyData, GraphMailConnection, GraphMailDeltaData, GraphMailDeltaOptions, GraphMailDeltaPageData, GraphMailDraftData, GraphMailErrorData, GraphMailFileData, GraphMailHeaderData, GraphMailMessageData, GraphMailRecipientData, GraphMailRemovedData, GraphMailReplyData, GraphMailUploadSessionData, } from './models';
|
|
3
|
+
export type { GraphCredentials, GraphMailBodyData, GraphMailConnection, GraphMailDeltaData, GraphMailDeltaOptions, GraphMailDeltaPageData, GraphMailDraftData, GraphMailErrorData, GraphMailFileData, GraphMailHeaderData, GraphMailLocatedData, GraphMailMessageData, GraphMailNotificationData, GraphMailNotificationPayloadData, GraphMailRecipientData, GraphMailRemovedData, GraphMailReplyData, GraphMailSubscriptionData, GraphMailSubscriptionOptions, GraphMailUploadSessionData, } from './models';
|
package/dist/microsoft/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GraphMailService = exports.GraphMailErrorService = exports.GraphMailFolder = exports.GraphMailErrorReason = exports.GraphMailBodyType = void 0;
|
|
3
|
+
exports.GraphMailService = exports.GraphMailErrorService = exports.GraphMailLifecycleEvent = exports.GraphMailFolder = exports.GraphMailErrorReason = exports.GraphMailBodyType = void 0;
|
|
4
4
|
var constants_1 = require("./constants");
|
|
5
5
|
Object.defineProperty(exports, "GraphMailBodyType", { enumerable: true, get: function () { return constants_1.GraphMailBodyType; } });
|
|
6
6
|
Object.defineProperty(exports, "GraphMailErrorReason", { enumerable: true, get: function () { return constants_1.GraphMailErrorReason; } });
|
|
7
7
|
Object.defineProperty(exports, "GraphMailFolder", { enumerable: true, get: function () { return constants_1.GraphMailFolder; } });
|
|
8
|
+
Object.defineProperty(exports, "GraphMailLifecycleEvent", { enumerable: true, get: function () { return constants_1.GraphMailLifecycleEvent; } });
|
|
8
9
|
var services_1 = require("./services");
|
|
9
10
|
Object.defineProperty(exports, "GraphMailErrorService", { enumerable: true, get: function () { return services_1.GraphMailErrorService; } });
|
|
10
11
|
Object.defineProperty(exports, "GraphMailService", { enumerable: true, get: function () { return services_1.GraphMailService; } });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { MailAddressData } from '../../models/mail-address-data';
|
|
2
2
|
import type { GraphMailBodyData } from './graph-mail-body-data';
|
|
3
3
|
import type { GraphMailFileData } from './graph-mail-file-data';
|
|
4
|
+
import type { GraphMailHeaderData } from './graph-mail-header-data';
|
|
4
5
|
export interface GraphMailReplyData {
|
|
5
6
|
body: GraphMailBodyData;
|
|
6
7
|
subject?: string;
|
|
@@ -8,4 +9,6 @@ export interface GraphMailReplyData {
|
|
|
8
9
|
cc?: MailAddressData[];
|
|
9
10
|
replyTo?: MailAddressData[];
|
|
10
11
|
attachments?: GraphMailFileData[];
|
|
12
|
+
headers?: GraphMailHeaderData[];
|
|
13
|
+
internetMessageId?: string;
|
|
11
14
|
}
|
|
@@ -15,13 +15,20 @@ export type { GraphMailErrorData } from './graph-mail-error-data';
|
|
|
15
15
|
export type { GraphMailFileAttachmentRequest } from './graph-mail-file-attachment-request';
|
|
16
16
|
export type { GraphMailFileData } from './graph-mail-file-data';
|
|
17
17
|
export type { GraphMailHeaderData } from './graph-mail-header-data';
|
|
18
|
+
export type { GraphMailLocatedData } from './graph-mail-located-data';
|
|
18
19
|
export type { GraphMailMessageData } from './graph-mail-message-data';
|
|
20
|
+
export type { GraphMailNotificationData } from './graph-mail-notification-data';
|
|
21
|
+
export type { GraphMailNotificationPayloadData } from './graph-mail-notification-payload-data';
|
|
19
22
|
export type { GraphMailOutgoingMessageData } from './graph-mail-outgoing-message-data';
|
|
20
23
|
export type { GraphMailRecipientData } from './graph-mail-recipient-data';
|
|
21
24
|
export type { GraphMailRemovedData } from './graph-mail-removed-data';
|
|
22
25
|
export type { GraphMailReplyData } from './graph-mail-reply-data';
|
|
23
26
|
export type { GraphMailReplyRequest } from './graph-mail-reply-request';
|
|
24
27
|
export type { GraphMailSendRequest } from './graph-mail-send-request';
|
|
28
|
+
export type { GraphMailSubscriptionData } from './graph-mail-subscription-data';
|
|
29
|
+
export type { GraphMailSubscriptionOptions } from './graph-mail-subscription-options';
|
|
30
|
+
export type { GraphMailSubscriptionRenewRequest } from './graph-mail-subscription-renew-request';
|
|
31
|
+
export type { GraphMailSubscriptionRequest } from './graph-mail-subscription-request';
|
|
25
32
|
export type { GraphMailUploadItemData } from './graph-mail-upload-item-data';
|
|
26
33
|
export type { GraphMailUploadSessionData } from './graph-mail-upload-session-data';
|
|
27
34
|
export type { GraphMailUploadSessionRequest } from './graph-mail-upload-session-request';
|
|
@@ -8,8 +8,11 @@ import type { GraphMailDeltaOptions } from '../models/graph-mail-delta-options';
|
|
|
8
8
|
import type { GraphMailDeltaPageData } from '../models/graph-mail-delta-page-data';
|
|
9
9
|
import type { GraphMailDraftData } from '../models/graph-mail-draft-data';
|
|
10
10
|
import type { GraphMailFileData } from '../models/graph-mail-file-data';
|
|
11
|
+
import type { GraphMailLocatedData } from '../models/graph-mail-located-data';
|
|
11
12
|
import type { GraphMailMessageData } from '../models/graph-mail-message-data';
|
|
12
13
|
import type { GraphMailReplyData } from '../models/graph-mail-reply-data';
|
|
14
|
+
import type { GraphMailSubscriptionData } from '../models/graph-mail-subscription-data';
|
|
15
|
+
import type { GraphMailSubscriptionOptions } from '../models/graph-mail-subscription-options';
|
|
13
16
|
import type { GraphMailUploadSessionData } from '../models/graph-mail-upload-session-data';
|
|
14
17
|
export declare class GraphMailService {
|
|
15
18
|
static deltaPage(connection: GraphMailConnection, folder: GraphMailFolder, link: string | null, options?: GraphMailDeltaOptions): Promise<GraphMailDeltaPageData>;
|
|
@@ -19,10 +22,17 @@ export declare class GraphMailService {
|
|
|
19
22
|
static downloadAttachment(connection: GraphMailConnection, messageId: string, attachmentId: string): Promise<MailAttachmentContentData>;
|
|
20
23
|
static sendMail(connection: GraphMailConnection, draft: GraphMailDraftData): Promise<void>;
|
|
21
24
|
static createAndSend(connection: GraphMailConnection, draft: GraphMailDraftData): Promise<MailSentData>;
|
|
25
|
+
static createDraft(connection: GraphMailConnection, draft: GraphMailDraftData): Promise<MailSentData>;
|
|
26
|
+
static createReplyDraft(connection: GraphMailConnection, messageId: string, reply: GraphMailReplyData): Promise<MailSentData>;
|
|
27
|
+
static sendDraft(connection: GraphMailConnection, messageId: string): Promise<void>;
|
|
28
|
+
static locate(connection: GraphMailConnection, internetMessageId: string): Promise<GraphMailLocatedData | null>;
|
|
22
29
|
static addAttachment(connection: GraphMailConnection, messageId: string, file: GraphMailFileData): Promise<void>;
|
|
23
30
|
static createUploadSession(connection: GraphMailConnection, messageId: string, file: GraphMailFileData): Promise<GraphMailUploadSessionData>;
|
|
24
31
|
static reply(connection: GraphMailConnection, messageId: string, reply: GraphMailReplyData): Promise<MailSentData>;
|
|
25
32
|
static setCategories(connection: GraphMailConnection, messageId: string, categories: string[]): Promise<void>;
|
|
33
|
+
static subscribe(connection: GraphMailConnection, folder: GraphMailFolder, options: GraphMailSubscriptionOptions): Promise<GraphMailSubscriptionData>;
|
|
34
|
+
static renewSubscription(connection: GraphMailConnection, subscriptionId: string, expiresAt: Date): Promise<GraphMailSubscriptionData>;
|
|
35
|
+
static deleteSubscription(connection: GraphMailConnection, subscriptionId: string): Promise<void>;
|
|
26
36
|
private static _attach;
|
|
27
37
|
private static _send;
|
|
28
38
|
private static _deltaStart;
|
|
@@ -216,6 +216,22 @@ var GraphMailService = /** @class */ (function () {
|
|
|
216
216
|
});
|
|
217
217
|
};
|
|
218
218
|
GraphMailService.createAndSend = function (connection, draft) {
|
|
219
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
220
|
+
var created;
|
|
221
|
+
return __generator(this, function (_a) {
|
|
222
|
+
switch (_a.label) {
|
|
223
|
+
case 0: return [4 /*yield*/, this.createDraft(connection, draft)];
|
|
224
|
+
case 1:
|
|
225
|
+
created = _a.sent();
|
|
226
|
+
return [4 /*yield*/, this.sendDraft(connection, created.id)];
|
|
227
|
+
case 2:
|
|
228
|
+
_a.sent();
|
|
229
|
+
return [2 /*return*/, created];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
GraphMailService.createDraft = function (connection, draft) {
|
|
219
235
|
return __awaiter(this, void 0, void 0, function () {
|
|
220
236
|
var created;
|
|
221
237
|
return __generator(this, function (_a) {
|
|
@@ -230,14 +246,78 @@ var GraphMailService = /** @class */ (function () {
|
|
|
230
246
|
return [4 /*yield*/, this._attach(connection, created.id, draft.attachments)];
|
|
231
247
|
case 2:
|
|
232
248
|
_a.sent();
|
|
233
|
-
return [
|
|
234
|
-
|
|
249
|
+
return [2 /*return*/, this._sent(created)];
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
};
|
|
254
|
+
GraphMailService.createReplyDraft = function (connection, messageId, reply) {
|
|
255
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
256
|
+
var request, created;
|
|
257
|
+
return __generator(this, function (_a) {
|
|
258
|
+
switch (_a.label) {
|
|
259
|
+
case 0:
|
|
260
|
+
request = { message: this._outgoing(reply) };
|
|
261
|
+
return [4 /*yield*/, graph_request_service_1.GraphRequestService.json(connection, {
|
|
262
|
+
method: ps_utilities_1.HttpMethod.Post,
|
|
263
|
+
url: mail_url_service_1.MailUrlService.path(this._messagePath(connection, messageId), graph_mail_config_1.GraphMailConfig.paths.createReply),
|
|
264
|
+
body: request,
|
|
265
|
+
})];
|
|
266
|
+
case 1:
|
|
267
|
+
created = _a.sent();
|
|
268
|
+
return [4 /*yield*/, this._attach(connection, created.id, reply.attachments)];
|
|
269
|
+
case 2:
|
|
235
270
|
_a.sent();
|
|
236
271
|
return [2 /*return*/, this._sent(created)];
|
|
237
272
|
}
|
|
238
273
|
});
|
|
239
274
|
});
|
|
240
275
|
};
|
|
276
|
+
GraphMailService.sendDraft = function (connection, messageId) {
|
|
277
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
278
|
+
return __generator(this, function (_a) {
|
|
279
|
+
switch (_a.label) {
|
|
280
|
+
case 0: return [4 /*yield*/, this._send(connection, messageId)];
|
|
281
|
+
case 1:
|
|
282
|
+
_a.sent();
|
|
283
|
+
return [2 /*return*/];
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
};
|
|
288
|
+
GraphMailService.locate = function (connection, internetMessageId) {
|
|
289
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
290
|
+
var quote, page, found;
|
|
291
|
+
return __generator(this, function (_a) {
|
|
292
|
+
switch (_a.label) {
|
|
293
|
+
case 0:
|
|
294
|
+
quote = graph_mail_config_1.GraphMailConfig.filterQuote;
|
|
295
|
+
return [4 /*yield*/, graph_request_service_1.GraphRequestService.json(connection, {
|
|
296
|
+
method: ps_utilities_1.HttpMethod.Get,
|
|
297
|
+
url: mail_url_service_1.MailUrlService.withQuery(mail_url_service_1.MailUrlService.path(this._mailboxPath(connection), graph_mail_config_1.GraphMailConfig.paths.messages), [
|
|
298
|
+
{
|
|
299
|
+
key: graph_mail_config_1.GraphMailConfig.query.filter,
|
|
300
|
+
value: "".concat(graph_mail_config_1.GraphMailConfig.query.internetMessageIdFilter).concat(quote).concat(internetMessageId.split(quote).join(quote + quote)).concat(quote),
|
|
301
|
+
},
|
|
302
|
+
this._select(graph_mail_config_1.GraphMailConfig.locateFields),
|
|
303
|
+
{ key: graph_mail_config_1.GraphMailConfig.query.top, value: graph_mail_config_1.GraphMailConfig.locateTop },
|
|
304
|
+
]),
|
|
305
|
+
})];
|
|
306
|
+
case 1:
|
|
307
|
+
page = _a.sent();
|
|
308
|
+
found = page.value[0];
|
|
309
|
+
if (found === undefined)
|
|
310
|
+
return [2 /*return*/, null];
|
|
311
|
+
return [2 /*return*/, {
|
|
312
|
+
id: found.id,
|
|
313
|
+
isDraft: found.isDraft === true,
|
|
314
|
+
conversationId: typeof found.conversationId === 'string' ? found.conversationId : null,
|
|
315
|
+
internetMessageId: typeof found.internetMessageId === 'string' ? found.internetMessageId : null,
|
|
316
|
+
}];
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
};
|
|
241
321
|
GraphMailService.addAttachment = function (connection, messageId, file) {
|
|
242
322
|
return __awaiter(this, void 0, void 0, function () {
|
|
243
323
|
var _a, _b, _c, request, _d, _e, _f, _g;
|
|
@@ -295,25 +375,16 @@ var GraphMailService = /** @class */ (function () {
|
|
|
295
375
|
};
|
|
296
376
|
GraphMailService.reply = function (connection, messageId, reply) {
|
|
297
377
|
return __awaiter(this, void 0, void 0, function () {
|
|
298
|
-
var
|
|
378
|
+
var created;
|
|
299
379
|
return __generator(this, function (_a) {
|
|
300
380
|
switch (_a.label) {
|
|
301
|
-
case 0:
|
|
302
|
-
request = { message: this._outgoing(reply) };
|
|
303
|
-
return [4 /*yield*/, graph_request_service_1.GraphRequestService.json(connection, {
|
|
304
|
-
method: ps_utilities_1.HttpMethod.Post,
|
|
305
|
-
url: mail_url_service_1.MailUrlService.path(this._messagePath(connection, messageId), graph_mail_config_1.GraphMailConfig.paths.createReply),
|
|
306
|
-
body: request,
|
|
307
|
-
})];
|
|
381
|
+
case 0: return [4 /*yield*/, this.createReplyDraft(connection, messageId, reply)];
|
|
308
382
|
case 1:
|
|
309
383
|
created = _a.sent();
|
|
310
|
-
return [4 /*yield*/, this.
|
|
384
|
+
return [4 /*yield*/, this.sendDraft(connection, created.id)];
|
|
311
385
|
case 2:
|
|
312
386
|
_a.sent();
|
|
313
|
-
return [
|
|
314
|
-
case 3:
|
|
315
|
-
_a.sent();
|
|
316
|
-
return [2 /*return*/, this._sent(created)];
|
|
387
|
+
return [2 /*return*/, created];
|
|
317
388
|
}
|
|
318
389
|
});
|
|
319
390
|
});
|
|
@@ -337,6 +408,46 @@ var GraphMailService = /** @class */ (function () {
|
|
|
337
408
|
});
|
|
338
409
|
});
|
|
339
410
|
};
|
|
411
|
+
GraphMailService.subscribe = function (connection, folder, options) {
|
|
412
|
+
var request = {
|
|
413
|
+
changeType: graph_mail_config_1.GraphMailConfig.subscription.changeType,
|
|
414
|
+
clientState: options.clientState,
|
|
415
|
+
expirationDateTime: options.expiresAt.toISOString(),
|
|
416
|
+
lifecycleNotificationUrl: options.lifecycleNotificationUrl,
|
|
417
|
+
notificationUrl: options.notificationUrl,
|
|
418
|
+
resource: mail_url_service_1.MailUrlService.path(this._mailboxPath(connection), graph_mail_config_1.GraphMailConfig.paths.mailFolders, folder, graph_mail_config_1.GraphMailConfig.paths.messages).slice(mail_http_config_1.MailHttpConfig.pathSeparator.length),
|
|
419
|
+
};
|
|
420
|
+
return graph_request_service_1.GraphRequestService.json(connection, {
|
|
421
|
+
method: ps_utilities_1.HttpMethod.Post,
|
|
422
|
+
url: mail_url_service_1.MailUrlService.path('', graph_mail_config_1.GraphMailConfig.paths.subscriptions),
|
|
423
|
+
body: request,
|
|
424
|
+
});
|
|
425
|
+
};
|
|
426
|
+
GraphMailService.renewSubscription = function (connection, subscriptionId, expiresAt) {
|
|
427
|
+
var request = {
|
|
428
|
+
expirationDateTime: expiresAt.toISOString(),
|
|
429
|
+
};
|
|
430
|
+
return graph_request_service_1.GraphRequestService.json(connection, {
|
|
431
|
+
method: ps_utilities_1.HttpMethod.Patch,
|
|
432
|
+
url: mail_url_service_1.MailUrlService.path('', graph_mail_config_1.GraphMailConfig.paths.subscriptions, subscriptionId),
|
|
433
|
+
body: request,
|
|
434
|
+
});
|
|
435
|
+
};
|
|
436
|
+
GraphMailService.deleteSubscription = function (connection, subscriptionId) {
|
|
437
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
438
|
+
return __generator(this, function (_a) {
|
|
439
|
+
switch (_a.label) {
|
|
440
|
+
case 0: return [4 /*yield*/, graph_request_service_1.GraphRequestService.send(connection, {
|
|
441
|
+
method: ps_utilities_1.HttpMethod.Delete,
|
|
442
|
+
url: mail_url_service_1.MailUrlService.path('', graph_mail_config_1.GraphMailConfig.paths.subscriptions, subscriptionId),
|
|
443
|
+
})];
|
|
444
|
+
case 1:
|
|
445
|
+
_a.sent();
|
|
446
|
+
return [2 /*return*/];
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
});
|
|
450
|
+
};
|
|
340
451
|
GraphMailService._attach = function (connection, messageId, files) {
|
|
341
452
|
return __awaiter(this, void 0, void 0, function () {
|
|
342
453
|
var _i, files_1, file;
|
|
@@ -396,8 +507,10 @@ var GraphMailService = /** @class */ (function () {
|
|
|
396
507
|
outgoing.ccRecipients = this._recipients(message.cc);
|
|
397
508
|
if (message.replyTo !== undefined)
|
|
398
509
|
outgoing.replyTo = this._recipients(message.replyTo);
|
|
399
|
-
if (
|
|
510
|
+
if (message.headers !== undefined)
|
|
400
511
|
outgoing.internetMessageHeaders = message.headers;
|
|
512
|
+
if (message.internetMessageId !== undefined)
|
|
513
|
+
outgoing.internetMessageId = message.internetMessageId;
|
|
401
514
|
return outgoing;
|
|
402
515
|
};
|
|
403
516
|
GraphMailService._recipients = function (addresses) {
|