@dbx-tools/email 0.3.22 → 0.3.24

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
@@ -19,15 +19,15 @@
19
19
  "juice": "^12.1.1",
20
20
  "marked": "^18.0.5",
21
21
  "nodemailer": "^7.0.13",
22
- "@dbx-tools/shared-core": "0.3.22",
23
- "@dbx-tools/shared-email": "0.3.22"
22
+ "@dbx-tools/shared-core": "0.3.24",
23
+ "@dbx-tools/shared-email": "0.3.24"
24
24
  },
25
25
  "main": "index.ts",
26
26
  "license": "UNLICENSED",
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "version": "0.3.22",
30
+ "version": "0.3.24",
31
31
  "types": "index.ts",
32
32
  "type": "module",
33
33
  "exports": {
package/src/outbox.ts CHANGED
@@ -13,10 +13,10 @@
13
13
  * @module
14
14
  */
15
15
 
16
- import type { EmailMessage } from "@dbx-tools/shared-email";
17
- import { string } from "@dbx-tools/shared-core";
18
16
  import { mkdir, writeFile } from "node:fs/promises";
19
17
  import { join, resolve } from "node:path";
18
+ import { string } from "@dbx-tools/shared-core";
19
+ import type { EmailMessage } from "@dbx-tools/shared-email";
20
20
  import type { EmailBrand } from "./brand";
21
21
  import { renderEmailHtml } from "./email-html";
22
22
 
package/src/plugin.ts CHANGED
@@ -27,8 +27,8 @@ import {
27
27
  type IAppRouter,
28
28
  type PluginManifest,
29
29
  } from "@databricks/appkit";
30
- import type { EmailMessage, EmailResult, EmailSenders } from "@dbx-tools/shared-email";
31
30
  import { error, log } from "@dbx-tools/shared-core";
31
+ import type { EmailMessage, EmailResult, EmailSenders } from "@dbx-tools/shared-email";
32
32
  import type express from "express";
33
33
  import { EMAIL_CONFIG_SCHEMA, type EmailPluginConfig } from "./config";
34
34
  import { isSenderAllowed, listSenderOptions, resolveSenderAddress } from "./sender";
package/src/tool.ts CHANGED
@@ -13,8 +13,8 @@
13
13
  */
14
14
 
15
15
  import { getExecutionContext } from "@databricks/appkit";
16
- import { email, type EmailMessage } from "@dbx-tools/shared-email";
17
16
  import { log, string } from "@dbx-tools/shared-core";
17
+ import { email, type EmailMessage } from "@dbx-tools/shared-email";
18
18
  import { createTool } from "@mastra/core/tools";
19
19
  import { resolveSenderAddress } from "./sender";
20
20
  import { getEmailRuntime, sendEmail } from "./transport";
@@ -0,0 +1,46 @@
1
+ import assert from "node:assert/strict";
2
+ import { describe, it } from "node:test";
3
+ import { brand } from "@dbx-tools/shared-core";
4
+ import { defaultEmailBrand, emailBrandFromContext } from "../src/brand";
5
+ import { renderEmailHtml } from "../src/email-html";
6
+
7
+ describe("email brand", () => {
8
+ it("derives accent, font, and name from a brand context", () => {
9
+ const b = emailBrandFromContext(brand.defaultBrandContext);
10
+ assert.equal(b.accent, brand.defaultBrandContext.colors.primary);
11
+ assert.equal(b.fontFamily, brand.defaultBrandContext.typography.sans);
12
+ assert.equal(b.name, brand.defaultBrandContext.name);
13
+ });
14
+
15
+ it("drops a logo that is not a fetchable URL (package-export path)", () => {
16
+ // The default brand's logo is an `@dbx-tools/ui-branding/...svg` export
17
+ // path, which can't load in a mail client, so no logoUrl is emitted.
18
+ assert.equal(defaultEmailBrand.logoUrl, undefined);
19
+ });
20
+
21
+ it("keeps an http(s) or data URL logo", () => {
22
+ const ctx = brand.parseBrandContext({
23
+ assets: { logo: { light: "https://ex.com/l.svg", dark: "https://ex.com/d.svg" } },
24
+ });
25
+ // Dark logo wins - the header band is dark.
26
+ assert.equal(emailBrandFromContext(ctx).logoUrl, "https://ex.com/d.svg");
27
+ });
28
+ });
29
+
30
+ describe("renderEmailHtml branding", () => {
31
+ it("inlines the brand accent and font, not the default blue", () => {
32
+ const html = renderEmailHtml({ subject: "S", body: "b", brand: defaultEmailBrand });
33
+ assert.ok(html.includes(defaultEmailBrand.accent));
34
+ assert.ok(html.includes("Inter"));
35
+ assert.ok(!html.includes("#0b6bcb"));
36
+ });
37
+
38
+ it("renders an <img> when the brand supplies a URL logo", () => {
39
+ const b = { ...defaultEmailBrand, logoUrl: "https://ex.com/logo.svg" };
40
+ assert.ok(renderEmailHtml({ subject: "S", body: "b", brand: b }).includes("<img"));
41
+ });
42
+
43
+ it("falls back to the neutral default palette with no brand", () => {
44
+ assert.ok(renderEmailHtml({ subject: "S", body: "b" }).includes("#0b6bcb"));
45
+ });
46
+ });
@@ -0,0 +1,14 @@
1
+ // ~~ Generated by projen. To modify, edit .projenrc.js and run "pnpm exec projen".
2
+ {
3
+ "extends": "../tsconfig.json",
4
+ "compilerOptions": {
5
+ "noEmit": true,
6
+ "rootDir": ".."
7
+ },
8
+ "include": [
9
+ "**/*.ts"
10
+ ],
11
+ "exclude": [
12
+ "node_modules"
13
+ ]
14
+ }