@travetto/email 5.0.0-rc.0 → 5.0.0-rc.10

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": "5.0.0-rc.0",
3
+ "version": "5.0.0-rc.10",
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/base": "^5.0.0-rc.0",
27
- "@travetto/config": "^5.0.0-rc.0",
28
- "@travetto/di": "^5.0.0-rc.0",
26
+ "@travetto/runtime": "^5.0.0-rc.9",
27
+ "@travetto/config": "^5.0.0-rc.10",
28
+ "@travetto/di": "^5.0.0-rc.9",
29
29
  "@types/mustache": "^4.2.5",
30
30
  "mustache": "^4.2.0"
31
31
  },
package/src/resource.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { AppError, Env, FileLoader } from '@travetto/base';
2
- import { RuntimeIndex } from '@travetto/manifest';
1
+ import { AppError, Env, FileLoader, Runtime, RuntimeIndex } from '@travetto/runtime';
3
2
 
4
3
  /** Build a resource loader that looks into a module and it's dependencies */
5
4
  export class EmailResourceLoader extends FileLoader {
@@ -14,6 +13,6 @@ export class EmailResourceLoader extends FileLoader {
14
13
  ...RuntimeIndex.getDependentModules(mod, 'children').map(x => `${x.name}#resources`),
15
14
  '@@#resources',
16
15
  ...globalResources ?? []
17
- ]);
16
+ ].map(v => Runtime.modulePath(v)));
18
17
  }
19
18
  }
package/src/service.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Env, RuntimeResources } from '@travetto/base';
1
+ import { Runtime, RuntimeResources } from '@travetto/runtime';
2
2
  import { Injectable } from '@travetto/di';
3
3
 
4
4
  import { EmailCompiled, EmailOptions, SentEmail } from './types';
@@ -30,7 +30,7 @@ export class MailService {
30
30
  * Get compiled content by key
31
31
  */
32
32
  async getCompiled(key: string): Promise<EmailCompiled> {
33
- if (Env.dynamic || !this.#compiled.has(key)) {
33
+ if (Runtime.dynamic || !this.#compiled.has(key)) {
34
34
  const [html, text, subject] = await Promise.all([
35
35
  RuntimeResources.read(`${key}.compiled.html`),
36
36
  RuntimeResources.read(`${key}.compiled.text`),
@@ -48,7 +48,7 @@ export class MailService {
48
48
  * @param ctx
49
49
  * @returns
50
50
  */
51
- async renderMessage(keyOrMessage: string | EmailCompiled, ctx: Record<string, unknown>): Promise<EmailCompiled> {
51
+ async renderMessage(keyOrMessage: string | EmailCompiled | EmailOptions, ctx: Record<string, unknown>): Promise<EmailCompiled> {
52
52
  const tpl = (typeof keyOrMessage === 'string' ? await this.getCompiled(keyOrMessage) : keyOrMessage);
53
53
 
54
54
  const [html, text, subject] = await Promise.all([
@@ -78,8 +78,7 @@ export class MailService {
78
78
  ): Promise<S> {
79
79
  const keyOrMessage = key ?? ('html' in message ? message : '') ?? '';
80
80
  const context = ctx ?? (('context' in message) ? message.context : {}) ?? {};
81
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
82
- const compiled = await this.renderMessage(keyOrMessage as EmailCompiled, context);
81
+ const compiled = await this.renderMessage(keyOrMessage, context);
83
82
 
84
83
  const final = { ...base, ...message, ...compiled, context };
85
84
 
package/src/template.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import mustache from 'mustache';
2
2
 
3
3
  import { Injectable } from '@travetto/di';
4
- import { RuntimeResources } from '@travetto/base';
4
+ import { RuntimeResources } from '@travetto/runtime';
5
5
 
6
6
  /**
7
7
  * Mail interpolation engine
package/src/transport.ts CHANGED
@@ -14,7 +14,6 @@ export interface MailTransport {
14
14
  */
15
15
  export class NullTransport implements MailTransport {
16
16
  async send<S extends SentEmail = SentEmail>(mail: EmailOptions): Promise<S> {
17
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
18
- return {} as S;
17
+ return undefined! ?? {};
19
18
  }
20
19
  }
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FileLoader } from '@travetto/base';
1
+ import { FileLoader } from '@travetto/runtime';
2
2
  import { Readable } from 'node:stream';
3
3
  import { Url } from 'node:url';
4
4
 
package/src/util.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { RuntimeContext } from '@travetto/manifest';
1
+ import { Util, Runtime } from '@travetto/runtime';
2
2
 
3
3
  import { EmailAttachment, EmailIdentity, EmailIdentityList, EmailOptions } from './types';
4
- import { Util } from '@travetto/base';
5
4
 
6
5
  /**
7
6
  * Utilities for email
@@ -16,7 +15,7 @@ export class MailUtil {
16
15
  static buildBrand(file: string, content: string, compile?: string): string {
17
16
  const out = [
18
17
  'WARNING: Do not modify.',
19
- `File is generated from "${file.replace(RuntimeContext.workspace.path, '.')}"`,
18
+ `File is generated from "${file.replace(Runtime.workspace.path, '.')}"`,
20
19
  compile ? `Run \`${compile.replaceAll('\n', ' ')}\` to regenerate` : ''
21
20
  ];
22
21
  return `<!-- ${out.join(' ').trim()} -->\n${content}`;