@h3ravel/mail 8.0.2 → 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.2",
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,194 +0,0 @@
1
- # @h3ravel/mail
2
-
3
- ## 8.0.2
4
-
5
- ### Patch Changes
6
-
7
- - fix: nothing at all
8
-
9
- ## 8.0.0
10
-
11
- ### Minor Changes
12
-
13
- - 79f4045: feat: add add exports to package.json
14
-
15
- ### Patch Changes
16
-
17
- - Updated dependencies [79f4045]
18
- - @h3ravel/core@1.4.0
19
-
20
- ## 7.0.0
21
-
22
- ### Minor Changes
23
-
24
- - feat: implement full IoC container resolution
25
-
26
- ### Patch Changes
27
-
28
- - Updated dependencies
29
- - @h3ravel/core@1.3.0
30
-
31
- ## 6.0.2
32
-
33
- ### Patch Changes
34
-
35
- - feat: add homepage and repository to all packages.
36
- - Updated dependencies
37
- - @h3ravel/core@1.2.2
38
-
39
- ## 6.0.1
40
-
41
- ### Patch Changes
42
-
43
- - chore: update readme accros all packages
44
- - Updated dependencies
45
- - @h3ravel/core@1.2.1
46
-
47
- ## 6.0.0
48
-
49
- ### Patch Changes
50
-
51
- - Updated dependencies [d07ff49]
52
- - @h3ravel/core@1.2.0
53
-
54
- ## 5.0.4
55
-
56
- ### Patch Changes
57
-
58
- - db0dd70: chore: revert to old workspace core dependency
59
-
60
- ## 5.0.3
61
-
62
- ### Patch Changes
63
-
64
- - version: explicitly set the latest version as pearDependency in requiring packages.
65
-
66
- ## 5.0.2
67
-
68
- ### Patch Changes
69
-
70
- - chore: require the latest dependencies from the framework
71
- - Updated dependencies
72
- - @h3ravel/core@1.1.2
73
-
74
- ## 5.0.1
75
-
76
- ### Patch Changes
77
-
78
- - @h3ravel/core@1.1.1
79
-
80
- ## 5.0.0
81
-
82
- ### Patch Changes
83
-
84
- - Updated dependencies [6e249fe]
85
- - @h3ravel/core@1.1.0
86
-
87
- ## 4.0.9
88
-
89
- ### Patch Changes
90
-
91
- - chore: regularize all interfaces.
92
- - Updated dependencies
93
- - @h3ravel/core@1.0.9
94
-
95
- ## 4.0.8
96
-
97
- ### Patch Changes
98
-
99
- - @h3ravel/core@1.0.8
100
-
101
- ## 4.0.7
102
-
103
- ### Patch Changes
104
-
105
- - @h3ravel/core@1.0.7
106
-
107
- ## 4.0.6
108
-
109
- ### Patch Changes
110
-
111
- - @h3ravel/core@1.0.6
112
-
113
- ## 4.0.5
114
-
115
- ### Patch Changes
116
-
117
- - @h3ravel/core@1.0.5
118
-
119
- ## 4.0.4
120
-
121
- ### Patch Changes
122
-
123
- - @h3ravel/core@1.0.4
124
-
125
- ## 4.0.3
126
-
127
- ### Patch Changes
128
-
129
- - chore: add download count to readme
130
- - Updated dependencies
131
- - @h3ravel/core@1.0.3
132
-
133
- ## 4.0.2
134
-
135
- ### Patch Changes
136
-
137
- - @h3ravel/core@1.0.2
138
-
139
- ## 4.0.0
140
-
141
- ### Minor Changes
142
-
143
- - b40caeb: feat: make service providers sortable and unique while only loading the core providers by default.
144
- Service providers are no longer loaded by default, asides the ones provided by @h3ravel/core
145
- Service provides are sorted by an optional order and priority property.
146
-
147
- ### Patch Changes
148
-
149
- - Updated dependencies [b40caeb]
150
- - @h3ravel/core@1.0.0
151
-
152
- ## 3.0.0
153
-
154
- ### Minor Changes
155
-
156
- - rebuild all dependencies
157
-
158
- ### Patch Changes
159
-
160
- - Updated dependencies
161
- - @h3ravel/core@0.5.0
162
-
163
- ## 2.0.0
164
-
165
- ### Patch Changes
166
-
167
- - a27f452: chore: fix all linting issues.
168
- - c906050: chore: migrate tests suite to jest
169
- - Updated dependencies [8ceb2c1]
170
- - Updated dependencies [a27f452]
171
- - Updated dependencies [c906050]
172
- - @h3ravel/core@0.4.0
173
-
174
- ## 1.0.0
175
-
176
- ### Minor Changes
177
-
178
- - 3ff97bf: refactor: add a shared package to be extended by others to avoid cyclic dependency issues.
179
-
180
- ### Patch Changes
181
-
182
- - Updated dependencies [3ff97bf]
183
- - @h3ravel/core@0.3.0
184
-
185
- ## 0.2.0
186
-
187
- ### Minor Changes
188
-
189
- - aea734f: Fix all known bugs and improved interdependecy between packages.
190
-
191
- ### Patch Changes
192
-
193
- - Updated dependencies [aea734f]
194
- - @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
- }