@wisemen/nestjs-mail 0.0.0 → 0.0.2
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/LICENSE.md +59 -0
- package/README.md +34 -0
- package/dist/clients/mail-client.factory.d.ts +4 -0
- package/dist/clients/mail-client.factory.js +22 -0
- package/dist/clients/mail-client.factory.js.map +1 -0
- package/dist/clients/mail.client.d.ts +26 -0
- package/dist/clients/mail.client.js +19 -0
- package/dist/clients/mail.client.js.map +1 -0
- package/dist/clients/mailpit-mail.client.d.ts +14 -0
- package/dist/clients/mailpit-mail.client.js +68 -0
- package/dist/clients/mailpit-mail.client.js.map +1 -0
- package/dist/clients/mock-mail.client.d.ts +4 -0
- package/dist/clients/mock-mail.client.js +18 -0
- package/dist/clients/mock-mail.client.js.map +1 -0
- package/dist/clients/scaleway-mail.client.d.ts +11 -0
- package/dist/clients/scaleway-mail.client.js +75 -0
- package/dist/clients/scaleway-mail.client.js.map +1 -0
- package/dist/clients/sendgrid-mail.client.d.ts +10 -0
- package/dist/clients/sendgrid-mail.client.js +87 -0
- package/dist/clients/sendgrid-mail.client.js.map +1 -0
- package/dist/enums/mail-provider.enum.d.ts +4 -0
- package/dist/enums/mail-provider.enum.js +6 -0
- package/dist/enums/mail-provider.enum.js.map +1 -0
- package/dist/errors/mail-api.error.d.ts +6 -0
- package/dist/errors/mail-api.error.js +13 -0
- package/dist/errors/mail-api.error.js.map +1 -0
- package/dist/errors/mail-unavailable.error.d.ts +5 -0
- package/dist/errors/mail-unavailable.error.js +21 -0
- package/dist/errors/mail-unavailable.error.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/mail.module-definitions.d.ts +3 -0
- package/dist/modules/mail.module-definitions.js +8 -0
- package/dist/modules/mail.module-definitions.js.map +1 -0
- package/dist/modules/mail.module-options.d.ts +88 -0
- package/dist/modules/mail.module-options.js +2 -0
- package/dist/modules/mail.module-options.js.map +1 -0
- package/dist/modules/mail.module.d.ts +9 -0
- package/dist/modules/mail.module.js +63 -0
- package/dist/modules/mail.module.js.map +1 -0
- package/dist/queue/mail-queue-name.d.ts +1 -0
- package/dist/queue/mail-queue-name.js +2 -0
- package/dist/queue/mail-queue-name.js.map +1 -0
- package/dist/queue/mail-queue.module-options.d.ts +11 -0
- package/dist/queue/mail-queue.module-options.js +2 -0
- package/dist/queue/mail-queue.module-options.js.map +1 -0
- package/dist/queue/mail-queue.module.d.ts +5 -0
- package/dist/queue/mail-queue.module.js +27 -0
- package/dist/queue/mail-queue.module.js.map +1 -0
- package/dist/queue/send-html-mail.job-handler.d.ts +8 -0
- package/dist/queue/send-html-mail.job-handler.js +39 -0
- package/dist/queue/send-html-mail.job-handler.js.map +1 -0
- package/dist/queue/send-html-mail.job.d.ts +15 -0
- package/dist/queue/send-html-mail.job.js +22 -0
- package/dist/queue/send-html-mail.job.js.map +1 -0
- package/dist/queue/send-template-mail.job-handler.d.ts +10 -0
- package/dist/queue/send-template-mail.job-handler.js +47 -0
- package/dist/queue/send-template-mail.job-handler.js.map +1 -0
- package/dist/queue/send-template-mail.job.d.ts +15 -0
- package/dist/queue/send-template-mail.job.js +22 -0
- package/dist/queue/send-template-mail.job.js.map +1 -0
- package/dist/utils/exhaustive-check.d.ts +1 -0
- package/dist/utils/exhaustive-check.js +4 -0
- package/dist/utils/exhaustive-check.js.map +1 -0
- package/package.json +40 -3
- package/skills/getting-started/SKILL.md +65 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# PolyForm Strict License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/strict/1.0.0>
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
|
|
8
|
+
|
|
9
|
+
## Copyright License
|
|
10
|
+
|
|
11
|
+
The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose, other than distributing the software or making changes or new works based on the software.
|
|
12
|
+
|
|
13
|
+
## Patent License
|
|
14
|
+
|
|
15
|
+
The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
|
|
16
|
+
|
|
17
|
+
## Noncommercial Purposes
|
|
18
|
+
|
|
19
|
+
Any noncommercial purpose is a permitted purpose.
|
|
20
|
+
|
|
21
|
+
## Personal Uses
|
|
22
|
+
|
|
23
|
+
Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
|
|
24
|
+
|
|
25
|
+
## Noncommercial Organizations
|
|
26
|
+
|
|
27
|
+
Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
|
|
28
|
+
|
|
29
|
+
## Fair Use
|
|
30
|
+
|
|
31
|
+
You may have "fair use" rights for the software under the law. These terms do not limit them.
|
|
32
|
+
|
|
33
|
+
## No Other Rights
|
|
34
|
+
|
|
35
|
+
These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
|
|
36
|
+
|
|
37
|
+
## Patent Defense
|
|
38
|
+
|
|
39
|
+
If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
40
|
+
|
|
41
|
+
## Violations
|
|
42
|
+
|
|
43
|
+
The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
|
|
44
|
+
|
|
45
|
+
## No Liability
|
|
46
|
+
|
|
47
|
+
***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
|
|
48
|
+
|
|
49
|
+
## Definitions
|
|
50
|
+
|
|
51
|
+
The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
|
|
52
|
+
|
|
53
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
54
|
+
|
|
55
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
56
|
+
|
|
57
|
+
**Your licenses** are all the licenses granted to you for the software under these terms.
|
|
58
|
+
|
|
59
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# `@wisemen/nestjs-mail`
|
|
2
|
+
|
|
3
|
+
Reusable NestJS mail infrastructure for Wisemen services.
|
|
4
|
+
|
|
5
|
+
## What it provides
|
|
6
|
+
|
|
7
|
+
- `MailModule.forRoot()` and `MailModule.forRootAsync()` for DI-friendly mail client wiring
|
|
8
|
+
- `HandlebarsRenderer` integration through `@wisemen/nestjs-handlebars`
|
|
9
|
+
- Mail providers for MailPit, Scaleway, and SendGrid
|
|
10
|
+
- Shared mail errors, enums, and message types
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { Module } from '@nestjs/common'
|
|
16
|
+
import { MailModule } from '@wisemen/nestjs-mail'
|
|
17
|
+
|
|
18
|
+
@Module({
|
|
19
|
+
imports: [
|
|
20
|
+
MailModule.forRoot({
|
|
21
|
+
templateRootPath: process.cwd() + '/dist/src/modules',
|
|
22
|
+
client: {
|
|
23
|
+
type: 'mailpit',
|
|
24
|
+
url: 'http://127.0.0.1:8025'
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
]
|
|
28
|
+
})
|
|
29
|
+
export class AppModule {}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Project-specific policy belongs outside the package. In larger apps, use `forRootAsync()` and resolve the `client` options from environment variables, feature flags, secrets, or test doubles in your own factory.
|
|
33
|
+
|
|
34
|
+
Install `@wisemen/nestjs-handlebars` alongside this package when you want to inject `HandlebarsRenderer` for template-based mail rendering.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { MailModuleOptions } from '../modules/mail.module-options.js';
|
|
2
|
+
import type { MailClient } from './mail.client.js';
|
|
3
|
+
export declare function createMailClient(options: MailModuleOptions['client']): MailClient;
|
|
4
|
+
export declare const mailClientFactory: typeof createMailClient;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MailProvider } from '../enums/mail-provider.enum.js';
|
|
2
|
+
import { exhaustiveCheck } from '../utils/exhaustive-check.js';
|
|
3
|
+
import { MailPitMailClient } from './mailpit-mail.client.js';
|
|
4
|
+
import { MockMailClient } from './mock-mail.client.js';
|
|
5
|
+
import { ScalewayMailClient } from './scaleway-mail.client.js';
|
|
6
|
+
import { SendGridMailClient } from './sendgrid-mail.client.js';
|
|
7
|
+
export function createMailClient(options) {
|
|
8
|
+
switch (options.type) {
|
|
9
|
+
case 'mailpit':
|
|
10
|
+
return new MailPitMailClient(options);
|
|
11
|
+
case 'mock':
|
|
12
|
+
return new MockMailClient();
|
|
13
|
+
case MailProvider.SCALEWAY:
|
|
14
|
+
return new ScalewayMailClient(options);
|
|
15
|
+
case MailProvider.SEND_GRID:
|
|
16
|
+
return new SendGridMailClient(options);
|
|
17
|
+
default:
|
|
18
|
+
exhaustiveCheck(options);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export const mailClientFactory = createMailClient;
|
|
22
|
+
//# sourceMappingURL=mail-client.factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mail-client.factory.js","sourceRoot":"","sources":["../../lib/clients/mail-client.factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAE9D,MAAM,UAAU,gBAAgB,CAAE,OAAoC;IACpE,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,SAAS;YACZ,OAAO,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAA;QACvC,KAAK,MAAM;YACT,OAAO,IAAI,cAAc,EAAE,CAAA;QAC7B,KAAK,YAAY,CAAC,QAAQ;YACxB,OAAO,IAAI,kBAAkB,CAAC,OAAO,CAAC,CAAA;QACxC,KAAK,YAAY,CAAC,SAAS;YACzB,OAAO,IAAI,kBAAkB,CAAC,OAAO,CAAC,CAAA;QACxC;YACE,eAAe,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare enum MailFileExtension {
|
|
2
|
+
PDF = "pdf",
|
|
3
|
+
CSV = "csv"
|
|
4
|
+
}
|
|
5
|
+
export interface MailAttachment {
|
|
6
|
+
file: {
|
|
7
|
+
name: string;
|
|
8
|
+
ext: MailFileExtension;
|
|
9
|
+
};
|
|
10
|
+
buffer: Buffer;
|
|
11
|
+
}
|
|
12
|
+
export interface SendMailOptions {
|
|
13
|
+
to: string | string[];
|
|
14
|
+
cc?: string | string[];
|
|
15
|
+
bcc?: string | string[];
|
|
16
|
+
from?: string;
|
|
17
|
+
subject: string;
|
|
18
|
+
text?: string;
|
|
19
|
+
html?: string;
|
|
20
|
+
attachments?: MailAttachment[];
|
|
21
|
+
replyTo?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare abstract class MailClient {
|
|
24
|
+
abstract sendMail(sendMailOptions: SendMailOptions): Promise<void>;
|
|
25
|
+
protected getMimeTypeForAttachmentExt(ext: MailFileExtension): string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { exhaustiveCheck } from '../utils/exhaustive-check.js';
|
|
2
|
+
export var MailFileExtension;
|
|
3
|
+
(function (MailFileExtension) {
|
|
4
|
+
MailFileExtension["PDF"] = "pdf";
|
|
5
|
+
MailFileExtension["CSV"] = "csv";
|
|
6
|
+
})(MailFileExtension || (MailFileExtension = {}));
|
|
7
|
+
export class MailClient {
|
|
8
|
+
getMimeTypeForAttachmentExt(ext) {
|
|
9
|
+
switch (ext) {
|
|
10
|
+
case MailFileExtension.CSV:
|
|
11
|
+
return 'text/csv';
|
|
12
|
+
case MailFileExtension.PDF:
|
|
13
|
+
return 'application/pdf';
|
|
14
|
+
default:
|
|
15
|
+
exhaustiveCheck(ext);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=mail.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mail.client.js","sourceRoot":"","sources":["../../lib/clients/mail.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAE9D,MAAM,CAAN,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,gCAAW,CAAA;IACX,gCAAW,CAAA;AACb,CAAC,EAHW,iBAAiB,KAAjB,iBAAiB,QAG5B;AAmBD,MAAM,OAAgB,UAAU;IAGpB,2BAA2B,CAAE,GAAsB;QAC3D,QAAQ,GAAG,EAAE,CAAC;YACZ,KAAK,iBAAiB,CAAC,GAAG;gBACxB,OAAO,UAAU,CAAA;YACnB,KAAK,iBAAiB,CAAC,GAAG;gBACxB,OAAO,iBAAiB,CAAA;YAC1B;gBACE,eAAe,CAAC,GAAG,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MailpitClient } from 'mailpit-api';
|
|
2
|
+
import type { MailPitMailClientOptions } from '../modules/mail.module-options.js';
|
|
3
|
+
import { MailClient, type SendMailOptions } from './mail.client.js';
|
|
4
|
+
export declare class MailPitMailClient extends MailClient {
|
|
5
|
+
private _client?;
|
|
6
|
+
private defaultFrom;
|
|
7
|
+
private tag?;
|
|
8
|
+
constructor(options: MailPitMailClientOptions);
|
|
9
|
+
get client(): MailpitClient;
|
|
10
|
+
sendMail(options: SendMailOptions): Promise<void>;
|
|
11
|
+
private mapToEmailAddressRequests;
|
|
12
|
+
private mapToEmails;
|
|
13
|
+
private mapAttachments;
|
|
14
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Injectable } from '@nestjs/common';
|
|
11
|
+
import { MailpitClient } from 'mailpit-api';
|
|
12
|
+
import { MailUnavailableError } from '../errors/mail-unavailable.error.js';
|
|
13
|
+
import { MailClient } from './mail.client.js';
|
|
14
|
+
let MailPitMailClient = class MailPitMailClient extends MailClient {
|
|
15
|
+
_client;
|
|
16
|
+
defaultFrom;
|
|
17
|
+
tag;
|
|
18
|
+
constructor(options) {
|
|
19
|
+
super();
|
|
20
|
+
this.defaultFrom = options.defaultFrom ?? 'test@wisemen.digital';
|
|
21
|
+
this.tag = options.tag;
|
|
22
|
+
this._client = new MailpitClient(options.url, { auth: options.auth });
|
|
23
|
+
}
|
|
24
|
+
get client() {
|
|
25
|
+
if (this._client == null) {
|
|
26
|
+
throw new MailUnavailableError('MailPit client is not configured');
|
|
27
|
+
}
|
|
28
|
+
return this._client;
|
|
29
|
+
}
|
|
30
|
+
async sendMail(options) {
|
|
31
|
+
await this.client.sendMessage({
|
|
32
|
+
From: { Email: options.from ?? this.defaultFrom },
|
|
33
|
+
To: this.mapToEmailAddressRequests(options.to),
|
|
34
|
+
Cc: options.cc !== undefined ? this.mapToEmailAddressRequests(options.cc) : undefined,
|
|
35
|
+
Bcc: options.bcc !== undefined ? this.mapToEmails(options.bcc) : undefined,
|
|
36
|
+
Subject: options.subject,
|
|
37
|
+
Text: options.text,
|
|
38
|
+
HTML: options.html,
|
|
39
|
+
ReplyTo: options.replyTo !== undefined
|
|
40
|
+
? this.mapToEmailAddressRequests(options.replyTo)
|
|
41
|
+
: undefined,
|
|
42
|
+
Attachments: options.attachments !== undefined
|
|
43
|
+
? this.mapAttachments(options.attachments)
|
|
44
|
+
: undefined,
|
|
45
|
+
Tags: this.tag !== undefined ? [this.tag] : undefined
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
mapToEmailAddressRequests(value) {
|
|
49
|
+
const emails = Array.isArray(value) ? value : [value];
|
|
50
|
+
return emails.map(email => ({ Email: email }));
|
|
51
|
+
}
|
|
52
|
+
mapToEmails(value) {
|
|
53
|
+
return Array.isArray(value) ? value : [value];
|
|
54
|
+
}
|
|
55
|
+
mapAttachments(attachments) {
|
|
56
|
+
return attachments.map(attachment => ({
|
|
57
|
+
Filename: `${attachment.file.name}.${attachment.file.ext}`,
|
|
58
|
+
Content: attachment.buffer.toString('base64'),
|
|
59
|
+
ContentType: this.getMimeTypeForAttachmentExt(attachment.file.ext)
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
MailPitMailClient = __decorate([
|
|
64
|
+
Injectable(),
|
|
65
|
+
__metadata("design:paramtypes", [Object])
|
|
66
|
+
], MailPitMailClient);
|
|
67
|
+
export { MailPitMailClient };
|
|
68
|
+
//# sourceMappingURL=mailpit-mail.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailpit-mail.client.js","sourceRoot":"","sources":["../../lib/clients/mailpit-mail.client.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAkE,MAAM,aAAa,CAAA;AAC3G,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAE1E,OAAO,EAAE,UAAU,EAA6C,MAAM,kBAAkB,CAAA;AAGjF,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU;IACvC,OAAO,CAAgB;IACvB,WAAW,CAAQ;IACnB,GAAG,CAAS;IAEpB,YACE,OAAiC;QAEjC,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,sBAAsB,CAAA;QAChE,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;IACvE,CAAC;IAED,IAAI,MAAM;QACR,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;YACzB,MAAM,IAAI,oBAAoB,CAAC,kCAAkC,CAAC,CAAA;QACpE,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,Q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AC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;IAChD,CAAC;IAEO,WAAW,CAAE,KAAwB;QAC3C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IAC/C,CAAC;IAEO,cAAc,CAAE,WAA6B;QACnD,OAAO,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YACpC,QAAQ,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE;YAC1D,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAC7C,WAAW,EAAE,IAAI,CAAC,2BAA2B,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC;SACnE,CAAC,CAAC,CAAA;IACL,CAAC;CACF,CAAA;AA1DY,iBAAiB;IAD7B,UAAU,EAAE;;GACA,iBAAiB,CA0D7B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Injectable } from '@nestjs/common';
|
|
8
|
+
import { MailClient } from './mail.client.js';
|
|
9
|
+
let MockMailClient = class MockMailClient extends MailClient {
|
|
10
|
+
async sendMail(params) {
|
|
11
|
+
await Promise.resolve(params);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
MockMailClient = __decorate([
|
|
15
|
+
Injectable()
|
|
16
|
+
], MockMailClient);
|
|
17
|
+
export { MockMailClient };
|
|
18
|
+
//# sourceMappingURL=mock-mail.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-mail.client.js","sourceRoot":"","sources":["../../lib/clients/mock-mail.client.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAwB,MAAM,kBAAkB,CAAA;AAG5D,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAC5C,KAAK,CAAC,QAAQ,CAAE,MAAuB;QACrC,MAAM,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAC/B,CAAC;CACF,CAAA;AAJY,cAAc;IAD1B,UAAU,EAAE;GACA,cAAc,CAI1B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ScalewayMailClientOptions } from '../modules/mail.module-options.js';
|
|
2
|
+
import { MailClient, type SendMailOptions } from './mail.client.js';
|
|
3
|
+
export declare class ScalewayMailClient extends MailClient {
|
|
4
|
+
private region;
|
|
5
|
+
private projectId;
|
|
6
|
+
private from;
|
|
7
|
+
private headers;
|
|
8
|
+
constructor(options: ScalewayMailClientOptions);
|
|
9
|
+
sendMail(options: SendMailOptions): Promise<void>;
|
|
10
|
+
private buildPayload;
|
|
11
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Injectable } from '@nestjs/common';
|
|
11
|
+
import { MailApiError } from '../errors/mail-api.error.js';
|
|
12
|
+
import { MailClient } from './mail.client.js';
|
|
13
|
+
let ScalewayMailClient = class ScalewayMailClient extends MailClient {
|
|
14
|
+
region;
|
|
15
|
+
projectId;
|
|
16
|
+
from;
|
|
17
|
+
headers;
|
|
18
|
+
constructor(options) {
|
|
19
|
+
super();
|
|
20
|
+
this.region = options.region ?? 'fr-par';
|
|
21
|
+
this.projectId = options.projectId;
|
|
22
|
+
this.from = options.from;
|
|
23
|
+
this.headers = {
|
|
24
|
+
'X-Auth-Token': options.apiKey,
|
|
25
|
+
'Content-Type': 'application/json'
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async sendMail(options) {
|
|
29
|
+
const response = await fetch(`https://api.scaleway.com/transactional-email/v1alpha1/regions/${this.region}/emails`, {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
headers: this.headers,
|
|
32
|
+
body: JSON.stringify(this.buildPayload(options))
|
|
33
|
+
});
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
const body = await response.text();
|
|
36
|
+
throw new MailApiError('Scaleway', response.status, body);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
buildPayload(options) {
|
|
40
|
+
const from = { email: options.from ?? this.from };
|
|
41
|
+
const to = [options.to].flat().map(email => ({ email }));
|
|
42
|
+
const cc = options.cc === undefined
|
|
43
|
+
? undefined
|
|
44
|
+
: [options.cc].flat().map(email => ({ email }));
|
|
45
|
+
const bcc = options.bcc === undefined
|
|
46
|
+
? undefined
|
|
47
|
+
: [options.bcc].flat().map(email => ({ email }));
|
|
48
|
+
const attachments = options.attachments?.map(attachment => ({
|
|
49
|
+
name: `${attachment.file.name}.${attachment.file.ext}`,
|
|
50
|
+
content: attachment.buffer.toString('base64'),
|
|
51
|
+
type: this.getMimeTypeForAttachmentExt(attachment.file.ext)
|
|
52
|
+
}));
|
|
53
|
+
const additionalHeaders = options.replyTo !== undefined
|
|
54
|
+
? [{ key: 'Reply-To', value: options.replyTo }]
|
|
55
|
+
: undefined;
|
|
56
|
+
return {
|
|
57
|
+
from,
|
|
58
|
+
to,
|
|
59
|
+
cc,
|
|
60
|
+
bcc,
|
|
61
|
+
subject: options.subject,
|
|
62
|
+
text: options.text,
|
|
63
|
+
html: options.html,
|
|
64
|
+
attachments,
|
|
65
|
+
additional_headers: additionalHeaders,
|
|
66
|
+
project_id: this.projectId
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
ScalewayMailClient = __decorate([
|
|
71
|
+
Injectable(),
|
|
72
|
+
__metadata("design:paramtypes", [Object])
|
|
73
|
+
], ScalewayMailClient);
|
|
74
|
+
export { ScalewayMailClient };
|
|
75
|
+
//# sourceMappingURL=scaleway-mail.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaleway-mail.client.js","sourceRoot":"","sources":["../../lib/clients/scaleway-mail.client.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAE1D,OAAO,EAAE,UAAU,EAAwB,MAAM,kBAAkB,CAAA;AAG5D,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,UAAU;IACxC,MAAM,CAAQ;IACd,SAAS,CAAQ;IACjB,IAAI,CAAQ;IACZ,OAAO,CAAwB;IAEvC,YACE,OAAkC;QAElC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,M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
|
2
|
+
import { MailClient, type SendMailOptions } from './mail.client.js';
|
|
3
|
+
export declare class SendGridMailClient extends MailClient {
|
|
4
|
+
private defaultFrom;
|
|
5
|
+
private headers;
|
|
6
|
+
constructor(options: SendGridMailClientOptions);
|
|
7
|
+
sendMail(options: SendMailOptions): Promise<void>;
|
|
8
|
+
private buildPayload;
|
|
9
|
+
private mapEmailAddresses;
|
|
10
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
11
|
+
import { Injectable } from '@nestjs/common';
|
|
12
|
+
import { MailApiError } from '../errors/mail-api.error.js';
|
|
13
|
+
import { MailClient } from './mail.client.js';
|
|
14
|
+
let SendGridMailClient = class SendGridMailClient extends MailClient {
|
|
15
|
+
defaultFrom;
|
|
16
|
+
headers;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
super();
|
|
19
|
+
this.headers = {
|
|
20
|
+
'Authorization': 'Bearer ' + options.apiToken,
|
|
21
|
+
'Content-Type': 'application/json'
|
|
22
|
+
};
|
|
23
|
+
this.defaultFrom = options.defaultFrom;
|
|
24
|
+
}
|
|
25
|
+
async sendMail(options) {
|
|
26
|
+
const response = await fetch('https://api.sendgrid.com/v3/mail/send', {
|
|
27
|
+
method: 'POST',
|
|
28
|
+
headers: this.headers,
|
|
29
|
+
body: JSON.stringify(this.buildPayload(options))
|
|
30
|
+
});
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
const body = await response.text();
|
|
33
|
+
throw new MailApiError('SendGrid', response.status, body);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
buildPayload(options) {
|
|
37
|
+
if (options.html == null && options.text == null) {
|
|
38
|
+
throw new Error('Either html or text content must be provided');
|
|
39
|
+
}
|
|
40
|
+
const content = [];
|
|
41
|
+
if (options.text !== undefined) {
|
|
42
|
+
content.push({
|
|
43
|
+
type: 'text/plain',
|
|
44
|
+
value: options.text
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (options.html !== undefined) {
|
|
48
|
+
content.push({
|
|
49
|
+
type: 'text/html',
|
|
50
|
+
value: options.html
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
personalizations: [
|
|
55
|
+
{
|
|
56
|
+
to: this.mapEmailAddresses(options.to),
|
|
57
|
+
cc: this.mapEmailAddresses(options.cc),
|
|
58
|
+
bcc: this.mapEmailAddresses(options.bcc),
|
|
59
|
+
subject: options.subject
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
from: {
|
|
63
|
+
email: options.from ?? this.defaultFrom
|
|
64
|
+
},
|
|
65
|
+
reply_to: options.replyTo !== undefined ? { email: options.replyTo } : undefined,
|
|
66
|
+
content,
|
|
67
|
+
attachments: options.attachments?.map(attachment => ({
|
|
68
|
+
content: attachment.buffer.toString('base64'),
|
|
69
|
+
filename: `${attachment.file.name}.${attachment.file.ext}`,
|
|
70
|
+
type: this.getMimeTypeForAttachmentExt(attachment.file.ext),
|
|
71
|
+
disposition: 'attachment'
|
|
72
|
+
}))
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
mapEmailAddresses(value) {
|
|
76
|
+
if (value === undefined) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
return [value].flat().map(email => ({ email }));
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
SendGridMailClient = __decorate([
|
|
83
|
+
Injectable(),
|
|
84
|
+
__metadata("design:paramtypes", [Object])
|
|
85
|
+
], SendGridMailClient);
|
|
86
|
+
export { SendGridMailClient };
|
|
87
|
+
//# sourceMappingURL=sendgrid-mail.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendgrid-mail.client.js","sourceRoot":"","sources":["../../lib/clients/sendgrid-mail.client.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yDAAyD;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAE1D,OAAO,EAAE,UAAU,EAAwB,MAAM,kBAAkB,CAAA;AAoE5D,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,UAAU;IACxC,WAAW,CAAQ;IACnB,OAAO,CAAwB;IAEvC,YACE,OAAkC;QAElC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,OAAO,GAAG;YACb,eAAe,EAAE,SAAS,GAAG,OAAO,CAAC,QAAQ;YAC7C,cAAc,EAAE,kBAAkB;SACnC,CAAA;QACD,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;IACxC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAE,OAAwB;QACtC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,uCAAuC,EAAE;YACpE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;SACjD,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,GAAG,MAAM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;YACP,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;gBACnD,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBAC7C,QAAQ,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE;gBAC1D,IAAI,EAAE,IAAI,CAAC,2BAA2B,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC;gBAC3D,WAAW,EAAE,YAAY;aAC1B,CAAC,CAAC;SACJ,CAAA;IACH,CAAC;IAQO,iBAAiB,CACvB,KAAoC;QAEpC,IAAG,KAAK,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;IACjD,CAAC;CACF,CAAA;AAvFY,kBAAkB;IAD9B,UAAU,EAAE;;GACA,kBAAkB,CAuF9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mail-provider.enum.js","sourceRoot":"","sources":["../../lib/enums/mail-provider.enum.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,uCAAuB,CAAA;IACvB,qCAAqB,CAAA;AACvB,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class MailApiError extends Error {
|
|
2
|
+
provider;
|
|
3
|
+
status;
|
|
4
|
+
body;
|
|
5
|
+
constructor(provider, status, body) {
|
|
6
|
+
super(`${provider} responded with ${status}: ${body}`);
|
|
7
|
+
this.provider = provider;
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.body = body;
|
|
10
|
+
this.name = 'MailApiError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=mail-api.error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mail-api.error.js","sourceRoot":"","sources":["../../lib/errors/mail-api.error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAa,SAAQ,KAAK;IAE1B;IACA;IACA;IAHX,YACW,QAAgB,EAChB,MAAc,EACd,IAAY;QAErB,KAAK,CAAC,GAAG,QAAQ,mBAAmB,MAAM,KAAK,IAAI,EAAE,CAAC,CAAA;QAJ7C,aAAQ,GAAR,QAAQ,CAAQ;QAChB,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QAGrB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAA;IAC5B,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { ApiErrorCode, ServiceUnavailableApiError } from '@wisemen/api-error';
|
|
11
|
+
export class MailUnavailableError extends ServiceUnavailableApiError {
|
|
12
|
+
code = 'mail_unavailable';
|
|
13
|
+
constructor(detail) {
|
|
14
|
+
super(detail);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
__decorate([
|
|
18
|
+
ApiErrorCode('mail_unavailable'),
|
|
19
|
+
__metadata("design:type", Object)
|
|
20
|
+
], MailUnavailableError.prototype, "code", void 0);
|
|
21
|
+
//# sourceMappingURL=mail-unavailable.error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mail-unavailable.error.js","sourceRoot":"","sources":["../../lib/errors/mail-unavailable.error.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAA;AAE7E,MAAM,OAAO,oBAAqB,SAAQ,0BAA0B;IAEzD,IAAI,GAAG,kBAAkB,CAAA;IAElC,YAAa,MAAc;QACzB,KAAK,CAAC,MAAM,CAAC,CAAA;IACf,CAAC;CACF;AALU;IADR,YAAY,CAAC,kBAAkB,CAAC;;kDACC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { createMailClient, mailClientFactory } from './clients/mail-client.factory.js';
|
|
2
|
+
export { MailClient, MailFileExtension, type MailAttachment, type SendMailOptions } from './clients/mail.client.js';
|
|
3
|
+
export { MailPitMailClient } from './clients/mailpit-mail.client.js';
|
|
4
|
+
export { MockMailClient } from './clients/mock-mail.client.js';
|
|
5
|
+
export { ScalewayMailClient } from './clients/scaleway-mail.client.js';
|
|
6
|
+
export { SendGridMailClient } from './clients/sendgrid-mail.client.js';
|
|
7
|
+
export { MailApiError } from './errors/mail-api.error.js';
|
|
8
|
+
export { MailUnavailableError } from './errors/mail-unavailable.error.js';
|
|
9
|
+
export { MailProvider } from './enums/mail-provider.enum.js';
|
|
10
|
+
export { MailModule } from './modules/mail.module.js';
|
|
11
|
+
export { type MailClientOptions, type MailModuleAsyncOptions, type MailModuleOptions, type MailPitMailClientOptions, type MockMailClientOptions, type ScalewayMailClientOptions, type SendGridMailClientOptions } from './modules/mail.module-options.js';
|
|
12
|
+
export { MAIL_QUEUE_NAME } from './queue/mail-queue-name.js';
|
|
13
|
+
export { MailQueueModule } from './queue/mail-queue.module.js';
|
|
14
|
+
export { type MailQueueModuleOptions } from './queue/mail-queue.module-options.js';
|
|
15
|
+
export { SendHtmlMailJob, type SendHtmlMailJobData } from './queue/send-html-mail.job.js';
|
|
16
|
+
export { SendTemplateMailJob, type SendTemplateMailJobData } from './queue/send-template-mail.job.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { createMailClient, mailClientFactory } from './clients/mail-client.factory.js';
|
|
2
|
+
export { MailClient, MailFileExtension } from './clients/mail.client.js';
|
|
3
|
+
export { MailPitMailClient } from './clients/mailpit-mail.client.js';
|
|
4
|
+
export { MockMailClient } from './clients/mock-mail.client.js';
|
|
5
|
+
export { ScalewayMailClient } from './clients/scaleway-mail.client.js';
|
|
6
|
+
export { SendGridMailClient } from './clients/sendgrid-mail.client.js';
|
|
7
|
+
export { MailApiError } from './errors/mail-api.error.js';
|
|
8
|
+
export { MailUnavailableError } from './errors/mail-unavailable.error.js';
|
|
9
|
+
export { MailProvider } from './enums/mail-provider.enum.js';
|
|
10
|
+
export { MailModule } from './modules/mail.module.js';
|
|
11
|
+
export { MAIL_QUEUE_NAME } from './queue/mail-queue-name.js';
|
|
12
|
+
export { MailQueueModule } from './queue/mail-queue.module.js';
|
|
13
|
+
export { SendHtmlMailJob } from './queue/send-html-mail.job.js';
|
|
14
|
+
export { SendTemplateMailJob } from './queue/send-template-mail.job.js';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACtF,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAA6C,MAAM,0BAA0B,CAAA;AACnH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAUrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAE9D,OAAO,EAAE,eAAe,EAA4B,MAAM,+BAA+B,CAAA;AACzF,OAAO,EAAE,mBAAmB,EAAgC,MAAM,mCAAmC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const MAIL_MODULE_OPTIONS = 'wisemen.nestjs-mail.module.options';
|
|
2
|
+
export function getTemplateRootPath(options) {
|
|
3
|
+
return options.templateRootPath ?? defaultTemplateRootPath();
|
|
4
|
+
}
|
|
5
|
+
function defaultTemplateRootPath() {
|
|
6
|
+
return process.cwd() + '/dist/src/modules';
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=mail.module-definitions.js.map
|