@travetto/email 7.0.0-rc.2 → 7.0.0-rc.4

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": "@travetto/email",
3
- "version": "7.0.0-rc.2",
3
+ "version": "7.0.0-rc.4",
4
4
  "description": "Email transmission module.",
5
5
  "keywords": [
6
6
  "email",
@@ -23,9 +23,9 @@
23
23
  "directory": "module/email"
24
24
  },
25
25
  "dependencies": {
26
- "@travetto/config": "^7.0.0-rc.2",
27
- "@travetto/di": "^7.0.0-rc.2",
28
- "@travetto/runtime": "^7.0.0-rc.2",
26
+ "@travetto/config": "^7.0.0-rc.4",
27
+ "@travetto/di": "^7.0.0-rc.4",
28
+ "@travetto/runtime": "^7.0.0-rc.4",
29
29
  "@types/mustache": "^4.2.6",
30
30
  "mustache": "^4.2.0"
31
31
  },
package/src/service.ts CHANGED
@@ -17,6 +17,7 @@ export class MailService {
17
17
  #compiled = new Map<string, EmailCompiled>();
18
18
  #transport: MailTransport;
19
19
  #interpolator: MailInterpolator;
20
+ #cacheResults = true;
20
21
 
21
22
  constructor(
22
23
  transport: MailTransport,
@@ -26,18 +27,23 @@ export class MailService {
26
27
  this.#transport = transport;
27
28
  }
28
29
 
30
+ setCacheState(active: boolean): void {
31
+ this.#cacheResults = active;
32
+ }
33
+
29
34
  /**
30
35
  * Get compiled content by key
31
36
  */
32
37
  async getCompiled(key: string): Promise<EmailCompiled> {
33
- if (Runtime.dynamic || !this.#compiled.has(key)) {
38
+ if (!this.#compiled.has(key)) {
34
39
  const [html, text, subject] = await Promise.all([
35
40
  RuntimeResources.read(`${key}.compiled.html`),
36
41
  RuntimeResources.read(`${key}.compiled.text`),
37
42
  RuntimeResources.read(`${key}.compiled.subject`)
38
43
  ].map(file => file.then(MailUtil.purgeBrand)));
39
-
40
- this.#compiled.set(key, { html, text, subject });
44
+ if (this.#cacheResults) {
45
+ this.#compiled.set(key, { html, text, subject });
46
+ }
41
47
  }
42
48
  return this.#compiled.get(key)!;
43
49
  }
package/src/template.ts CHANGED
@@ -10,8 +10,8 @@ import { RuntimeResources } from '@travetto/runtime';
10
10
  */
11
11
  export interface MailInterpolator {
12
12
  /**
13
- * Resolved nested templates
14
- */
13
+ * Resolved nested templates
14
+ */
15
15
  resolveNested(template: string): Promise<string>;
16
16
 
17
17
  /**