@h3ravel/mail 8.0.0 → 8.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h3ravel/mail",
3
- "version": "8.0.0",
3
+ "version": "8.0.3",
4
4
  "description": "Mail drivers and templates system for H3ravel.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -13,6 +13,9 @@
13
13
  "types": "./dist/index.d.ts"
14
14
  }
15
15
  },
16
+ "files": [
17
+ "dist"
18
+ ],
16
19
  "publishConfig": {
17
20
  "access": "public"
18
21
  },
@@ -23,7 +26,7 @@
23
26
  "directory": "packages/mail"
24
27
  },
25
28
  "peerDependencies": {
26
- "@h3ravel/core": "^1.4.0"
29
+ "@h3ravel/core": "^1.4.1"
27
30
  },
28
31
  "devDependencies": {
29
32
  "@types/nodemailer": "^6.4.17",
package/CHANGELOG.md DELETED
@@ -1,188 +0,0 @@
1
- # @h3ravel/mail
2
-
3
- ## 8.0.0
4
-
5
- ### Minor Changes
6
-
7
- - 79f4045: feat: add add exports to package.json
8
-
9
- ### Patch Changes
10
-
11
- - Updated dependencies [79f4045]
12
- - @h3ravel/core@1.4.0
13
-
14
- ## 7.0.0
15
-
16
- ### Minor Changes
17
-
18
- - feat: implement full IoC container resolution
19
-
20
- ### Patch Changes
21
-
22
- - Updated dependencies
23
- - @h3ravel/core@1.3.0
24
-
25
- ## 6.0.2
26
-
27
- ### Patch Changes
28
-
29
- - feat: add homepage and repository to all packages.
30
- - Updated dependencies
31
- - @h3ravel/core@1.2.2
32
-
33
- ## 6.0.1
34
-
35
- ### Patch Changes
36
-
37
- - chore: update readme accros all packages
38
- - Updated dependencies
39
- - @h3ravel/core@1.2.1
40
-
41
- ## 6.0.0
42
-
43
- ### Patch Changes
44
-
45
- - Updated dependencies [d07ff49]
46
- - @h3ravel/core@1.2.0
47
-
48
- ## 5.0.4
49
-
50
- ### Patch Changes
51
-
52
- - db0dd70: chore: revert to old workspace core dependency
53
-
54
- ## 5.0.3
55
-
56
- ### Patch Changes
57
-
58
- - version: explicitly set the latest version as pearDependency in requiring packages.
59
-
60
- ## 5.0.2
61
-
62
- ### Patch Changes
63
-
64
- - chore: require the latest dependencies from the framework
65
- - Updated dependencies
66
- - @h3ravel/core@1.1.2
67
-
68
- ## 5.0.1
69
-
70
- ### Patch Changes
71
-
72
- - @h3ravel/core@1.1.1
73
-
74
- ## 5.0.0
75
-
76
- ### Patch Changes
77
-
78
- - Updated dependencies [6e249fe]
79
- - @h3ravel/core@1.1.0
80
-
81
- ## 4.0.9
82
-
83
- ### Patch Changes
84
-
85
- - chore: regularize all interfaces.
86
- - Updated dependencies
87
- - @h3ravel/core@1.0.9
88
-
89
- ## 4.0.8
90
-
91
- ### Patch Changes
92
-
93
- - @h3ravel/core@1.0.8
94
-
95
- ## 4.0.7
96
-
97
- ### Patch Changes
98
-
99
- - @h3ravel/core@1.0.7
100
-
101
- ## 4.0.6
102
-
103
- ### Patch Changes
104
-
105
- - @h3ravel/core@1.0.6
106
-
107
- ## 4.0.5
108
-
109
- ### Patch Changes
110
-
111
- - @h3ravel/core@1.0.5
112
-
113
- ## 4.0.4
114
-
115
- ### Patch Changes
116
-
117
- - @h3ravel/core@1.0.4
118
-
119
- ## 4.0.3
120
-
121
- ### Patch Changes
122
-
123
- - chore: add download count to readme
124
- - Updated dependencies
125
- - @h3ravel/core@1.0.3
126
-
127
- ## 4.0.2
128
-
129
- ### Patch Changes
130
-
131
- - @h3ravel/core@1.0.2
132
-
133
- ## 4.0.0
134
-
135
- ### Minor Changes
136
-
137
- - b40caeb: feat: make service providers sortable and unique while only loading the core providers by default.
138
- Service providers are no longer loaded by default, asides the ones provided by @h3ravel/core
139
- Service provides are sorted by an optional order and priority property.
140
-
141
- ### Patch Changes
142
-
143
- - Updated dependencies [b40caeb]
144
- - @h3ravel/core@1.0.0
145
-
146
- ## 3.0.0
147
-
148
- ### Minor Changes
149
-
150
- - rebuild all dependencies
151
-
152
- ### Patch Changes
153
-
154
- - Updated dependencies
155
- - @h3ravel/core@0.5.0
156
-
157
- ## 2.0.0
158
-
159
- ### Patch Changes
160
-
161
- - a27f452: chore: fix all linting issues.
162
- - c906050: chore: migrate tests suite to jest
163
- - Updated dependencies [8ceb2c1]
164
- - Updated dependencies [a27f452]
165
- - Updated dependencies [c906050]
166
- - @h3ravel/core@0.4.0
167
-
168
- ## 1.0.0
169
-
170
- ### Minor Changes
171
-
172
- - 3ff97bf: refactor: add a shared package to be extended by others to avoid cyclic dependency issues.
173
-
174
- ### Patch Changes
175
-
176
- - Updated dependencies [3ff97bf]
177
- - @h3ravel/core@0.3.0
178
-
179
- ## 0.2.0
180
-
181
- ### Minor Changes
182
-
183
- - aea734f: Fix all known bugs and improved interdependecy between packages.
184
-
185
- ### Patch Changes
186
-
187
- - Updated dependencies [aea734f]
188
- - @h3ravel/core@0.2.0
@@ -1,20 +0,0 @@
1
- import type { SendMailOptions as NodeMailerSendMailOptions } from "nodemailer";
2
- import SMTPConnection from "nodemailer/lib/smtp-connection";
3
-
4
- export interface SendMailOptions extends NodeMailerSendMailOptions {
5
- viewPath?: string,
6
- viewData?: Record<string, any>
7
- }
8
-
9
- export interface SMTPConfig extends SMTPConnection.Options {
10
- host: string;
11
- port: number;
12
- auth: {
13
- user: string;
14
- pass: string;
15
- };
16
- }
17
-
18
- export interface MailDriverContract {
19
- send (options: NodeMailerSendMailOptions): Promise<any>;
20
- }
@@ -1 +0,0 @@
1
- export default class { }
@@ -1,31 +0,0 @@
1
- import nodemailer, { type SendMailOptions, type TransportOptions } from 'nodemailer';
2
-
3
- import { MailDriverContract, SMTPConfig } from '../Contracts/Mailer';
4
-
5
- export class SMTPDriver implements MailDriverContract {
6
- private transporter;
7
-
8
- constructor(config: SMTPConfig) {
9
- this.transporter = nodemailer.createTransport({
10
- host: config.host,
11
- port: config.port,
12
- secure: config.port === 465, // auto decide based on port
13
- auth: {
14
- user: config.auth.user,
15
- pass: config.auth.pass
16
- }
17
- });
18
- }
19
-
20
- async send (options: SendMailOptions) {
21
- return await this.transporter.sendMail({
22
- to: options.to,
23
- cc: options.cc,
24
- bcc: options.bcc,
25
- subject: options.subject,
26
- html: options.html,
27
- text: options.text,
28
- attachments: options.attachments
29
- });
30
- }
31
- }
package/src/Helpers.ts DELETED
@@ -1 +0,0 @@
1
- export default class { }
package/src/Mailable.ts DELETED
@@ -1,77 +0,0 @@
1
- import type { SendMailOptions } from "./Contracts/Mailer";
2
-
3
- export abstract class Mailable {
4
- protected toAddress?: string;
5
- protected ccAddresses?: string[];
6
- protected bccAddresses?: string[];
7
- protected subjectText?: string;
8
- protected htmlContent?: string;
9
- protected textContent?: string;
10
- protected viewPath?: string;
11
- protected viewData?: Record<string, any>;
12
- protected attachmentsList?: SendMailOptions['attachments'];
13
-
14
- to (address: string) {
15
- this.toAddress = address;
16
- return this;
17
- }
18
-
19
- cc (...addresses: string[]) {
20
- this.ccAddresses = addresses;
21
- return this;
22
- }
23
-
24
- bcc (...addresses: string[]) {
25
- this.bccAddresses = addresses;
26
- return this;
27
- }
28
-
29
- subject (subject: string) {
30
- this.subjectText = subject;
31
- return this;
32
- }
33
-
34
- html (html: string) {
35
- this.htmlContent = html;
36
- return this;
37
- }
38
-
39
- text (text: string) {
40
- this.textContent = text;
41
- return this;
42
- }
43
-
44
- view (path: string, data: Record<string, any> = {}) {
45
- this.viewPath = path;
46
- this.viewData = data;
47
- return this;
48
- }
49
-
50
- attach (filename: string, filePath: string) {
51
- if (!this.attachmentsList) this.attachmentsList = [];
52
- this.attachmentsList.push({ filename, path: filePath });
53
- return this;
54
- }
55
-
56
- /**
57
- * Child classes should define build() like in Laravel
58
- */
59
- abstract build (): Promise<this> | this;
60
-
61
- /**
62
- * Called internally by Mailer
63
- */
64
- getMessageOptions (): SendMailOptions {
65
- return {
66
- to: this.toAddress,
67
- cc: this.ccAddresses,
68
- bcc: this.bccAddresses,
69
- subject: this.subjectText,
70
- html: this.htmlContent,
71
- text: this.textContent,
72
- viewPath: this.viewPath,
73
- viewData: this.viewData,
74
- attachments: this.attachmentsList
75
- };
76
- }
77
- }
package/src/Mailer.ts DELETED
@@ -1,21 +0,0 @@
1
- import { MailDriverContract } from './Contracts/Mailer';
2
- import { Mailable } from './Mailable';
3
-
4
- export class Mailer {
5
- constructor(
6
- private driver: MailDriverContract,
7
- private edgeRenderer: (viewPath: string, data: Record<string, any>) => Promise<string>
8
- ) { }
9
-
10
- async send (mailable: Mailable) {
11
- await mailable.build();
12
-
13
- const options = mailable.getMessageOptions();
14
-
15
- if (options.viewPath && !options.html) {
16
- options.html = await this.edgeRenderer(options.viewPath, options.viewData || {});
17
- }
18
-
19
- return this.driver.send(options);
20
- }
21
- }
@@ -1,50 +0,0 @@
1
- import { Mailer } from '../Mailer';
2
- import { SMTPConfig } from '../Contracts/Mailer';
3
- import { SMTPDriver } from '../Drivers/SMTPDriver';
4
- import { ServiceProvider } from '@h3ravel/core';
5
-
6
- /**
7
- * Mail delivery setup.
8
- *
9
- * Bind Mailer service.
10
- * Load mail drivers (SMTP, SES, etc.).
11
- * Register Mail facade.
12
- *
13
- */
14
- export class MailServiceProvider extends ServiceProvider {
15
- public static priority = 990;
16
- register () {
17
- /**
18
- * Register Mailer instance
19
- */
20
-
21
- this.app.singleton<any>('mailer', () => {
22
- // this.app.bind(Mailer, () => {
23
- const view = this.app.make('view');
24
- const config = this.app.make('config');
25
-
26
- const smtpConfig: SMTPConfig = {
27
- host: config.get('mail.mailers.smtp.host', 'smtp.mailtrap.io'),
28
- port: Number(config.get('mail.mailers.smtp.port', 2525)),
29
- auth: {
30
- user: config.get('mail.mailers.smtp.username', ''),
31
- pass: config.get('mail.mailers.smtp.password', ''),
32
- },
33
- opportunisticTLS: config.get('mail.mailers.smtp.encryption') === 'tls',
34
- connectionTimeout: config.get('mail.mailers.smtp.timeout'),
35
- debug: false,
36
- };
37
-
38
- return new Mailer(
39
- new SMTPDriver(smtpConfig),
40
- async (viewPath, data) => await view(viewPath, data)
41
- );
42
- });
43
- }
44
-
45
- boot () {
46
- /**
47
- * Add logic here for global mail "from" address and others
48
- */
49
- }
50
- }
package/src/index.ts DELETED
@@ -1,11 +0,0 @@
1
- /**
2
- * @file Automatically generated by barrelsby.
3
- */
4
-
5
- export * from './Helpers';
6
- export * from './Mailable';
7
- export * from './Mailer';
8
- export * from './Contracts/Mailer';
9
- export * from './Drivers/SES';
10
- export * from './Drivers/SMTPDriver';
11
- export * from './Providers/MailServiceProvider';
package/tests/.gitkeep DELETED
File without changes
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../shared/tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "dist"
5
- },
6
- "include": ["src"],
7
- "exclude": ["dist", "node_modules"]
8
- }