1
- // Type definitions for node-email-templates 7.1
1
+ // Type definitions for node-email-templates 8.0
2
2
// Project: https://github.com/forwardemail/email-templates
3
3
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
4
4
// Matus Gura <https://github.com/gurisko>
@@ -20,8 +20,9 @@ import SESTransport = require('nodemailer/lib/ses-transport');
20
20
import SMTPPool = require( 'nodemailer/lib/smtp-pool' ) ;
21
21
import SMTPTransport = require( 'nodemailer/lib/smtp-transport' ) ;
22
22
import StreamTransport = require( 'nodemailer/lib/stream-transport' ) ;
23
+ import juice = require( 'juice' ) ;
23
24
24
- declare namespace EmailTemplate {
25
+ declare namespace Email {
25
26
// email-templates accepts nodemailer.createTransport options directly
26
27
// too and calls createTransport if given a non-function, thus a lot
27
28
// of different types accepted for transport
@@ -92,69 +93,81 @@ declare namespace EmailTemplate {
92
93
}
93
94
94
95
interface EmailConfig < T = any > {
95
- /**
96
- * The message <Nodemailer.com/message/>
97
- */
98
- message : Mail . Options ;
99
- /**
100
- * The nodemailer Transport created via nodemailer.createTransport
101
- */
102
- transport ?: NodeMailerTransportOptions ;
103
- /**
104
- * The email template directory and engine information
105
- */
106
- views ?: View ;
107
- /**
108
- * Do you really want to send, false for test or development
109
- */
110
- send ?: boolean ;
111
- /**
112
- * Preview the email
113
- */
114
- preview ?: boolean | PreviewEmailOpts ;
115
- /**
116
- * Set to object to configure and Enable <https://github.com/ladjs/il8n>
117
- */
118
- i18n ?: any ;
119
- /**
120
- * defaults to false, unless you pass your own render function,
121
- * and in that case it will be automatically set to true.
122
- * @default false
123
- */
124
- customRender ?: boolean ;
125
- /**
126
- * Pass a custom render function if necessary
127
- */
128
- render ?: ( view : string , locals ?: T ) => Promise < any > ;
129
- /**
130
- * force text-only rendering of template (disregards template folder)
131
- */
132
- textOnly ?: boolean ;
133
- /**
134
- * <Https://github.com/werk85/node-html-to-text>
135
- *
136
- * configuration object for html-to-text
137
- */
138
- htmlToText ?: HtmlToTextOptions | false ;
139
- /**
140
- * You can pass an option to prefix subject lines with a string
141
- * env === 'production' ? false : `[${env.toUpperCase()}] `; // <--- HERE
142
- */
143
- subjectPrefix ?: string | false ;
144
- /**
145
- * <https://github.com/Automattic/juice>
146
- */
147
- juice ?: boolean ;
148
- /**
149
- * <https://github.com/Automattic/juice>
150
- */
151
- juiceResources ?: any ;
152
- /**
153
- * a function that returns the path to a template file
154
- * @default (path: string, template: string) => string
155
- */
156
- getPath ?: ( path : string , template : string , locals : any ) => string ;
157
- }
96
+ /**
97
+ * The message <Nodemailer.com/message/>
98
+ */
99
+ message : Mail . Options ;
100
+ /**
101
+ * The nodemailer Transport created via nodemailer.createTransport
102
+ */
103
+ transport ?: NodeMailerTransportOptions ;
104
+ /**
105
+ * The email template directory and engine information
106
+ */
107
+ views ?: View ;
108
+ /**
109
+ * Do you really want to send, false for test or development
110
+ */
111
+ send ?: boolean ;
112
+ /**
113
+ * Preview the email
114
+ */
115
+ preview ?: boolean | PreviewEmailOpts ;
116
+ /**
117
+ * Set to object to configure and Enable <https://github.com/ladjs/il8n>
118
+ */
119
+ i18n ?: any ;
120
+ /**
121
+ * defaults to false, unless you pass your own render function,
122
+ * and in that case it will be automatically set to true.
123
+ * @default false
124
+ */
125
+ customRender ?: boolean ;
126
+ /**
127
+ * Pass a custom render function if necessary
128
+ */
129
+ render ?: ( view : string , locals ?: T ) => Promise < any > ;
130
+ /**
131
+ * force text-only rendering of template (disregards template folder)
132
+ */
133
+ textOnly ?: boolean ;
134
+ /**
135
+ * <Https://github.com/werk85/node-html-to-text>
136
+ *
137
+ * configuration object for html-to-text
138
+ */
139
+ htmlToText ?: HtmlToTextOptions | false ;
140
+ /**
141
+ * You can pass an option to prefix subject lines with a string
142
+ * env === 'production' ? false : `[${env.toUpperCase()}] `; // <--- HERE
143
+ */
144
+ subjectPrefix ?: string | false ;
145
+ /**
146
+ * <https://github.com/Automattic/juice>
147
+ */
148
+ juice ?: boolean ;
149
+ juiceSettings ?: JuiceGlobalConfig ;
150
+ /**
151
+ * <https://github.com/Automattic/juice>
152
+ */
153
+ juiceResources ?: juice . Options ;
154
+ /**
155
+ * a function that returns the path to a template file
156
+ * @default (path: string, template: string) => string
157
+ */
158
+ getPath ?: ( path : string , template : string , locals : any ) => string ;
159
+ }
160
+
161
+ type JuiceGlobalConfig = Partial < {
162
+ codeBlocks : typeof juice . codeBlocks ;
163
+ excludedProperties : typeof juice . excludedProperties ;
164
+ heightElements : string [ ] ;
165
+ ignoredPseudos : typeof juice . ignoredPseudos ;
166
+ nonVisualElements : typeof juice . nonVisualElements ;
167
+ styleToAttribute : typeof juice . styleToAttribute ;
168
+ tableElements : string [ ] ;
169
+ widthElements : string [ ] ;
170
+ } > ;
158
171
159
172
interface EmailOptions < T = any > {
160
173
/**
@@ -180,31 +193,35 @@ declare namespace EmailTemplate {
180
193
}
181
194
}
182
195
183
- declare class EmailTemplate < T = any > {
184
- constructor ( config : EmailTemplate . EmailConfig ) ;
196
+ declare class Email < T = any > {
197
+ constructor ( config ?: Email . EmailConfig ) ;
198
+
185
199
/**
186
200
* shorthand use of `juiceResources` with the config
187
201
* mainly for custom renders like from a database).
188
202
*/
189
- juiceResources ( html : string ) : Promise < string > ;
203
+ juiceResources ( html : string , options ?: juice . Options ) : Promise < string > ;
204
+
190
205
/**
191
206
*
192
207
* @param view The Html pug to render
193
208
* @param locals The template Variables
194
209
*/
195
210
render ( view : string , locals ?: T ) : Promise < string > ;
211
+
196
212
/**
197
213
* Render all available template files for a given email
198
214
* template (e.g. `html.pug`, `text.pug`, and `subject.pug`)
199
215
*
200
216
* @param view Name of the template
201
217
* @param locals The template variables
202
218
*/
203
- renderAll ( view : string , locals ?: T ) : Promise < Partial < EmailTemplate . EmailMessage > > ;
219
+ renderAll ( view : string , locals ?: T ) : Promise < Partial < Email . EmailMessage > > ;
220
+
204
221
/**
205
222
* Send the Email
206
223
*/
207
- send ( options : EmailTemplate . EmailOptions < T > ) : Promise < any > ;
224
+ send ( options : Email . EmailOptions < T > ) : Promise < any > ;
208
225
}
209
226
210
- export = EmailTemplate ;
227
+ export = Email ;
0 commit comments