@pallasoft/ps-mail 1.5.0 → 1.6.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.
Files changed (29) hide show
  1. package/dist/sandbox/constants/index.d.ts +2 -0
  2. package/dist/sandbox/constants/index.js +18 -0
  3. package/dist/sandbox/constants/mail-driver.d.ts +4 -0
  4. package/dist/sandbox/constants/mail-driver.js +8 -0
  5. package/dist/sandbox/constants/sandbox-mail-config.d.ts +38 -0
  6. package/dist/sandbox/constants/sandbox-mail-config.js +34 -0
  7. package/dist/sandbox/index.d.ts +3 -0
  8. package/dist/sandbox/index.js +11 -0
  9. package/dist/sandbox/models/index.d.ts +4 -0
  10. package/dist/sandbox/models/index.js +2 -0
  11. package/dist/sandbox/models/sandbox-capture-input.d.ts +13 -0
  12. package/dist/sandbox/models/sandbox-capture-input.js +2 -0
  13. package/dist/sandbox/models/sandbox-captured-mail-data.d.ts +13 -0
  14. package/dist/sandbox/models/sandbox-captured-mail-data.js +2 -0
  15. package/dist/sandbox/models/sandbox-inbound-input.d.ts +10 -0
  16. package/dist/sandbox/models/sandbox-inbound-input.js +2 -0
  17. package/dist/sandbox/models/sandbox-outbox-row-data.d.ts +4 -0
  18. package/dist/sandbox/models/sandbox-outbox-row-data.js +2 -0
  19. package/dist/sandbox/services/index.d.ts +4 -0
  20. package/dist/sandbox/services/index.js +20 -0
  21. package/dist/sandbox/services/mail-driver-service.d.ts +6 -0
  22. package/dist/sandbox/services/mail-driver-service.js +27 -0
  23. package/dist/sandbox/services/sandbox-capture-service.d.ts +8 -0
  24. package/dist/sandbox/services/sandbox-capture-service.js +71 -0
  25. package/dist/sandbox/services/sandbox-inbound-service.d.ts +6 -0
  26. package/dist/sandbox/services/sandbox-inbound-service.js +58 -0
  27. package/dist/sandbox/services/sandbox-mail-service.d.ts +11 -0
  28. package/dist/sandbox/services/sandbox-mail-service.js +47 -0
  29. package/package.json +9 -2
@@ -0,0 +1,2 @@
1
+ export * from './mail-driver';
2
+ export * from './sandbox-mail-config';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./mail-driver"), exports);
18
+ __exportStar(require("./sandbox-mail-config"), exports);
@@ -0,0 +1,4 @@
1
+ export declare enum MailDriver {
2
+ Graph = "graph",
3
+ Sandbox = "sandbox"
4
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MailDriver = void 0;
4
+ var MailDriver;
5
+ (function (MailDriver) {
6
+ MailDriver["Graph"] = "graph";
7
+ MailDriver["Sandbox"] = "sandbox";
8
+ })(MailDriver || (exports.MailDriver = MailDriver = {}));
@@ -0,0 +1,38 @@
1
+ export declare const SandboxMailConfig: {
2
+ readonly outboxLimit: 200;
3
+ readonly connection: {
4
+ readonly tenantId: "sandbox-tenant";
5
+ readonly clientId: "sandbox-client";
6
+ readonly clientSecret: "sandbox-secret";
7
+ };
8
+ readonly subscription: {
9
+ readonly idPrefix: "sandbox-subscription";
10
+ readonly resource: "sandbox/mailFolders/inbox/messages";
11
+ readonly lifetimeHours: 70;
12
+ };
13
+ readonly deltaLinkPrefix: "sandbox-delta";
14
+ readonly messageIdPrefix: "sandbox-message";
15
+ readonly internetMessageIdDomain: "sandbox.test";
16
+ readonly headers: {
17
+ readonly inReplyTo: "In-Reply-To";
18
+ readonly references: "References";
19
+ };
20
+ readonly millisecondsPerHour: 3600000;
21
+ readonly productionDriverError: "MAIL_DRIVER=sandbox is not allowed in production, mail must go through the real provider";
22
+ readonly unknownDriverError: "MAIL_DRIVER must be graph or sandbox";
23
+ readonly tagPattern: RegExp;
24
+ readonly breakPattern: RegExp;
25
+ readonly stylePattern: RegExp;
26
+ readonly whitespacePattern: RegExp;
27
+ readonly blankLinesPattern: RegExp;
28
+ readonly entityPattern: RegExp;
29
+ readonly lineEdgePattern: RegExp;
30
+ readonly entities: {
31
+ readonly ' ': " ";
32
+ readonly '&': "&";
33
+ readonly '&lt;': "<";
34
+ readonly '&gt;': ">";
35
+ readonly '&quot;': "\"";
36
+ readonly '&#39;': "'";
37
+ };
38
+ };
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SandboxMailConfig = void 0;
4
+ exports.SandboxMailConfig = {
5
+ outboxLimit: 200,
6
+ connection: {
7
+ tenantId: 'sandbox-tenant',
8
+ clientId: 'sandbox-client',
9
+ clientSecret: 'sandbox-secret',
10
+ },
11
+ subscription: {
12
+ idPrefix: 'sandbox-subscription',
13
+ resource: 'sandbox/mailFolders/inbox/messages',
14
+ lifetimeHours: 70,
15
+ },
16
+ deltaLinkPrefix: 'sandbox-delta',
17
+ messageIdPrefix: 'sandbox-message',
18
+ internetMessageIdDomain: 'sandbox.test',
19
+ headers: {
20
+ inReplyTo: 'In-Reply-To',
21
+ references: 'References',
22
+ },
23
+ millisecondsPerHour: 3600000,
24
+ productionDriverError: 'MAIL_DRIVER=sandbox is not allowed in production, mail must go through the real provider',
25
+ unknownDriverError: 'MAIL_DRIVER must be graph or sandbox',
26
+ tagPattern: /<[^>]*>/g,
27
+ breakPattern: /<\s*(br|\/p|\/div|\/tr|\/li|\/h[1-6])\s*\/?>/gi,
28
+ stylePattern: /<(style|script|head)[\s\S]*?<\/\1>/gi,
29
+ whitespacePattern: /[ \t]+/g,
30
+ blankLinesPattern: /\n{3,}/g,
31
+ entityPattern: /&(nbsp|amp|lt|gt|quot|#39);/g,
32
+ lineEdgePattern: / ?\n ?/g,
33
+ entities: { '&nbsp;': ' ', '&amp;': '&', '&lt;': '<', '&gt;': '>', '&quot;': '"', '&#39;': "'" },
34
+ };
@@ -0,0 +1,3 @@
1
+ export { MailDriver, SandboxMailConfig } from './constants';
2
+ export type { SandboxCaptureInput, SandboxCapturedMailData, SandboxInboundInput, SandboxOutboxRowData, } from './models';
3
+ export { MailDriverService, SandboxCaptureService, SandboxInboundService, SandboxMailService, } from './services';
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SandboxMailService = exports.SandboxInboundService = exports.SandboxCaptureService = exports.MailDriverService = exports.SandboxMailConfig = exports.MailDriver = void 0;
4
+ var constants_1 = require("./constants");
5
+ Object.defineProperty(exports, "MailDriver", { enumerable: true, get: function () { return constants_1.MailDriver; } });
6
+ Object.defineProperty(exports, "SandboxMailConfig", { enumerable: true, get: function () { return constants_1.SandboxMailConfig; } });
7
+ var services_1 = require("./services");
8
+ Object.defineProperty(exports, "MailDriverService", { enumerable: true, get: function () { return services_1.MailDriverService; } });
9
+ Object.defineProperty(exports, "SandboxCaptureService", { enumerable: true, get: function () { return services_1.SandboxCaptureService; } });
10
+ Object.defineProperty(exports, "SandboxInboundService", { enumerable: true, get: function () { return services_1.SandboxInboundService; } });
11
+ Object.defineProperty(exports, "SandboxMailService", { enumerable: true, get: function () { return services_1.SandboxMailService; } });
@@ -0,0 +1,4 @@
1
+ export type { SandboxCaptureInput } from './sandbox-capture-input';
2
+ export type { SandboxCapturedMailData } from './sandbox-captured-mail-data';
3
+ export type { SandboxInboundInput } from './sandbox-inbound-input';
4
+ export type { SandboxOutboxRowData } from './sandbox-outbox-row-data';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ import type { GraphMailBodyData } from '../../microsoft/models/graph-mail-body-data';
2
+ import type { MailAddressData } from '../../models/mail-address-data';
3
+ export interface SandboxCaptureInput {
4
+ mailbox: string;
5
+ fromName?: string;
6
+ to: MailAddressData[];
7
+ cc?: MailAddressData[];
8
+ subject: string;
9
+ body: GraphMailBodyData;
10
+ kind?: string;
11
+ ticketId?: string;
12
+ createdAt?: Date;
13
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ import type { MailAddressData } from '../../models/mail-address-data';
2
+ export interface SandboxCapturedMailData {
3
+ mailbox: string;
4
+ from: MailAddressData;
5
+ to: MailAddressData[];
6
+ cc: MailAddressData[];
7
+ subject: string;
8
+ html: string | null;
9
+ text: string;
10
+ kind: string | null;
11
+ ticketId: string | null;
12
+ createdAt: string;
13
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ export interface SandboxInboundInput {
2
+ mailbox: string;
3
+ fromAddress: string;
4
+ fromName?: string;
5
+ subject: string;
6
+ body: string;
7
+ inReplyToMessageId?: string;
8
+ receivedAt?: Date;
9
+ id?: string;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ export interface SandboxOutboxRowData {
2
+ id: string;
3
+ createdAt: Date | string;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ export * from './mail-driver-service';
2
+ export * from './sandbox-capture-service';
3
+ export * from './sandbox-inbound-service';
4
+ export * from './sandbox-mail-service';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./mail-driver-service"), exports);
18
+ __exportStar(require("./sandbox-capture-service"), exports);
19
+ __exportStar(require("./sandbox-inbound-service"), exports);
20
+ __exportStar(require("./sandbox-mail-service"), exports);
@@ -0,0 +1,6 @@
1
+ import { MailDriver } from '../constants/mail-driver';
2
+ export declare class MailDriverService {
3
+ static resolve(value: string | undefined | null): MailDriver;
4
+ static assertAllowed(driver: MailDriver, isProduction: boolean): MailDriver;
5
+ static isSandbox(value: string | undefined | null): boolean;
6
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MailDriverService = void 0;
4
+ var mail_driver_1 = require("../constants/mail-driver");
5
+ var sandbox_mail_config_1 = require("../constants/sandbox-mail-config");
6
+ var MailDriverService = /** @class */ (function () {
7
+ function MailDriverService() {
8
+ }
9
+ MailDriverService.resolve = function (value) {
10
+ var normalized = typeof value === 'string' ? value.trim().toLowerCase() : '';
11
+ if (normalized === '' || normalized === mail_driver_1.MailDriver.Graph)
12
+ return mail_driver_1.MailDriver.Graph;
13
+ if (normalized === mail_driver_1.MailDriver.Sandbox)
14
+ return mail_driver_1.MailDriver.Sandbox;
15
+ throw new Error(sandbox_mail_config_1.SandboxMailConfig.unknownDriverError);
16
+ };
17
+ MailDriverService.assertAllowed = function (driver, isProduction) {
18
+ if (isProduction && driver === mail_driver_1.MailDriver.Sandbox)
19
+ throw new Error(sandbox_mail_config_1.SandboxMailConfig.productionDriverError);
20
+ return driver;
21
+ };
22
+ MailDriverService.isSandbox = function (value) {
23
+ return this.resolve(value) === mail_driver_1.MailDriver.Sandbox;
24
+ };
25
+ return MailDriverService;
26
+ }());
27
+ exports.MailDriverService = MailDriverService;
@@ -0,0 +1,8 @@
1
+ import type { SandboxCaptureInput } from '../models/sandbox-capture-input';
2
+ import type { SandboxCapturedMailData } from '../models/sandbox-captured-mail-data';
3
+ import type { SandboxOutboxRowData } from '../models/sandbox-outbox-row-data';
4
+ export declare class SandboxCaptureService {
5
+ static capture(input: SandboxCaptureInput): SandboxCapturedMailData;
6
+ static htmlToText(html: string): string;
7
+ static overflowIds(rows: SandboxOutboxRowData[], limit?: number): string[];
8
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
+ if (ar || !(i in from)) {
16
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
+ ar[i] = from[i];
18
+ }
19
+ }
20
+ return to.concat(ar || Array.prototype.slice.call(from));
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.SandboxCaptureService = void 0;
24
+ var graph_mail_body_type_1 = require("../../microsoft/constants/graph-mail-body-type");
25
+ var sandbox_mail_config_1 = require("../constants/sandbox-mail-config");
26
+ var SandboxCaptureService = /** @class */ (function () {
27
+ function SandboxCaptureService() {
28
+ }
29
+ SandboxCaptureService.capture = function (input) {
30
+ var isHtml = input.body.contentType === graph_mail_body_type_1.GraphMailBodyType.Html;
31
+ var created = input.createdAt === undefined ? new Date() : input.createdAt;
32
+ return {
33
+ mailbox: input.mailbox,
34
+ from: __assign({ address: input.mailbox }, (input.fromName === undefined ? {} : { name: input.fromName })),
35
+ to: input.to,
36
+ cc: input.cc === undefined ? [] : input.cc,
37
+ subject: input.subject,
38
+ html: isHtml ? input.body.content : null,
39
+ text: isHtml ? this.htmlToText(input.body.content) : input.body.content,
40
+ kind: input.kind === undefined ? null : input.kind,
41
+ ticketId: input.ticketId === undefined ? null : input.ticketId,
42
+ createdAt: created.toISOString(),
43
+ };
44
+ };
45
+ SandboxCaptureService.htmlToText = function (html) {
46
+ var decoded = html
47
+ .replace(sandbox_mail_config_1.SandboxMailConfig.stylePattern, '')
48
+ .replace(sandbox_mail_config_1.SandboxMailConfig.breakPattern, '\n')
49
+ .replace(sandbox_mail_config_1.SandboxMailConfig.tagPattern, '');
50
+ var entities = sandbox_mail_config_1.SandboxMailConfig.entities;
51
+ var text = decoded.replace(sandbox_mail_config_1.SandboxMailConfig.entityPattern, function (match) {
52
+ var replacement = entities[match];
53
+ return replacement === undefined ? match : replacement;
54
+ });
55
+ return text
56
+ .replace(sandbox_mail_config_1.SandboxMailConfig.whitespacePattern, ' ')
57
+ .replace(sandbox_mail_config_1.SandboxMailConfig.lineEdgePattern, '\n')
58
+ .replace(sandbox_mail_config_1.SandboxMailConfig.blankLinesPattern, '\n\n')
59
+ .trim();
60
+ };
61
+ SandboxCaptureService.overflowIds = function (rows, limit) {
62
+ if (limit === void 0) { limit = sandbox_mail_config_1.SandboxMailConfig.outboxLimit; }
63
+ if (rows.length <= limit)
64
+ return [];
65
+ return __spreadArray([], rows, true).sort(function (a, b) { return new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(); })
66
+ .slice(limit)
67
+ .map(function (row) { return row.id; });
68
+ };
69
+ return SandboxCaptureService;
70
+ }());
71
+ exports.SandboxCaptureService = SandboxCaptureService;
@@ -0,0 +1,6 @@
1
+ import type { GraphMailMessageData } from '../../microsoft/models/graph-mail-message-data';
2
+ import type { SandboxInboundInput } from '../models/sandbox-inbound-input';
3
+ export declare class SandboxInboundService {
4
+ static build(input: SandboxInboundInput): GraphMailMessageData;
5
+ private static _id;
6
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.SandboxInboundService = void 0;
15
+ var graph_mail_body_type_1 = require("../../microsoft/constants/graph-mail-body-type");
16
+ var sandbox_mail_config_1 = require("../constants/sandbox-mail-config");
17
+ var SandboxInboundService = /** @class */ (function () {
18
+ function SandboxInboundService() {
19
+ }
20
+ SandboxInboundService.build = function (input) {
21
+ var received = (input.receivedAt === undefined ? new Date() : input.receivedAt).toISOString();
22
+ var id = input.id === undefined ? this._id(received) : input.id;
23
+ var sender = {
24
+ emailAddress: __assign({ address: input.fromAddress }, (input.fromName === undefined ? {} : { name: input.fromName })),
25
+ };
26
+ var headers = input.inReplyToMessageId === undefined
27
+ ? []
28
+ : [
29
+ { name: sandbox_mail_config_1.SandboxMailConfig.headers.inReplyTo, value: input.inReplyToMessageId },
30
+ { name: sandbox_mail_config_1.SandboxMailConfig.headers.references, value: input.inReplyToMessageId },
31
+ ];
32
+ return {
33
+ id: id,
34
+ conversationId: id,
35
+ internetMessageId: "<".concat(id, "@").concat(sandbox_mail_config_1.SandboxMailConfig.internetMessageIdDomain, ">"),
36
+ subject: input.subject,
37
+ from: sender,
38
+ sender: sender,
39
+ toRecipients: [{ emailAddress: { address: input.mailbox } }],
40
+ ccRecipients: [],
41
+ replyTo: [],
42
+ receivedDateTime: received,
43
+ sentDateTime: received,
44
+ hasAttachments: false,
45
+ isDraft: false,
46
+ categories: [],
47
+ bodyPreview: input.body.slice(0, 255),
48
+ body: { contentType: graph_mail_body_type_1.GraphMailBodyType.Text, content: input.body },
49
+ uniqueBody: { contentType: graph_mail_body_type_1.GraphMailBodyType.Text, content: input.body },
50
+ internetMessageHeaders: headers,
51
+ };
52
+ };
53
+ SandboxInboundService._id = function (received) {
54
+ return "".concat(sandbox_mail_config_1.SandboxMailConfig.messageIdPrefix, "-").concat(received, "-").concat(crypto.randomUUID());
55
+ };
56
+ return SandboxInboundService;
57
+ }());
58
+ exports.SandboxInboundService = SandboxInboundService;
@@ -0,0 +1,11 @@
1
+ import type { GraphMailConnection } from '../../microsoft/models/graph-mail-connection';
2
+ import type { GraphMailDeltaData } from '../../microsoft/models/graph-mail-delta-data';
3
+ import type { GraphMailDeltaPageData } from '../../microsoft/models/graph-mail-delta-page-data';
4
+ import type { GraphMailSubscriptionData } from '../../microsoft/models/graph-mail-subscription-data';
5
+ export declare class SandboxMailService {
6
+ static connection(mailbox: string): GraphMailConnection;
7
+ static deltaLink(mailbox: string): string;
8
+ static deltaPage(mailbox: string): GraphMailDeltaPageData;
9
+ static delta(mailbox: string): GraphMailDeltaData;
10
+ static subscription(mailbox: string, now?: Date): GraphMailSubscriptionData;
11
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.SandboxMailService = void 0;
15
+ var sandbox_mail_config_1 = require("../constants/sandbox-mail-config");
16
+ var SandboxMailService = /** @class */ (function () {
17
+ function SandboxMailService() {
18
+ }
19
+ SandboxMailService.connection = function (mailbox) {
20
+ return __assign(__assign({}, sandbox_mail_config_1.SandboxMailConfig.connection), { mailbox: mailbox });
21
+ };
22
+ SandboxMailService.deltaLink = function (mailbox) {
23
+ return "".concat(sandbox_mail_config_1.SandboxMailConfig.deltaLinkPrefix, ":").concat(mailbox);
24
+ };
25
+ SandboxMailService.deltaPage = function (mailbox) {
26
+ return {
27
+ messages: [],
28
+ removedIds: [],
29
+ nextLink: null,
30
+ deltaLink: this.deltaLink(mailbox),
31
+ };
32
+ };
33
+ SandboxMailService.delta = function (mailbox) {
34
+ return { messages: [], removedIds: [], deltaLink: this.deltaLink(mailbox) };
35
+ };
36
+ SandboxMailService.subscription = function (mailbox, now) {
37
+ if (now === void 0) { now = new Date(); }
38
+ var lifetime = sandbox_mail_config_1.SandboxMailConfig.subscription.lifetimeHours * sandbox_mail_config_1.SandboxMailConfig.millisecondsPerHour;
39
+ return {
40
+ id: "".concat(sandbox_mail_config_1.SandboxMailConfig.subscription.idPrefix, ":").concat(mailbox),
41
+ resource: sandbox_mail_config_1.SandboxMailConfig.subscription.resource,
42
+ expirationDateTime: new Date(now.getTime() + lifetime).toISOString(),
43
+ };
44
+ };
45
+ return SandboxMailService;
46
+ }());
47
+ exports.SandboxMailService = SandboxMailService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pallasoft/ps-mail",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -17,7 +17,11 @@
17
17
  "types": "./dist/resend/index.d.ts",
18
18
  "default": "./dist/resend/index.js"
19
19
  },
20
- "./package.json": "./package.json"
20
+ "./package.json": "./package.json",
21
+ "./sandbox": {
22
+ "types": "./dist/sandbox/index.d.ts",
23
+ "default": "./dist/sandbox/index.js"
24
+ }
21
25
  },
22
26
  "typesVersions": {
23
27
  "*": {
@@ -26,6 +30,9 @@
26
30
  ],
27
31
  "resend": [
28
32
  "./dist/resend/index.d.ts"
33
+ ],
34
+ "sandbox": [
35
+ "./dist/sandbox/index.d.ts"
29
36
  ]
30
37
  }
31
38
  },