@dbx-tools/email 0.1.17 → 0.1.19

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @dbx-tools/node-email
1
+ # @dbx-tools/email
2
2
 
3
3
  Server-side email runtime, Mastra tool, and AppKit plugin.
4
4
 
@@ -24,8 +24,8 @@ Key features:
24
24
 
25
25
  ```ts
26
26
  import { createApp, lakebase, server } from "@databricks/appkit";
27
- import { plugin as emailPlugin, tool as emailTool } from "@dbx-tools/node-email";
28
- import { agents, plugin as mastraPlugin } from "@dbx-tools/node-appkit-mastra";
27
+ import { plugin as emailPlugin, tool as emailTool } from "@dbx-tools/email";
28
+ import { agents, plugin as mastraPlugin } from "@dbx-tools/appkit-mastra";
29
29
 
30
30
  const support = agents.createAgent({
31
31
  instructions: "Draft emails, but wait for approval before sending.",
@@ -56,7 +56,7 @@ approval card and compose components.
56
56
  ## Send Without An Agent
57
57
 
58
58
  ```ts
59
- import { transport } from "@dbx-tools/node-email";
59
+ import { transport } from "@dbx-tools/email";
60
60
 
61
61
  const result = await transport.sendEmail(
62
62
  {
@@ -76,7 +76,7 @@ involved. The same resolved runtime is used by the AppKit plugin and tool.
76
76
  ## Resolve SMTP Or Outbox Mode
77
77
 
78
78
  ```ts
79
- import { config, transport } from "@dbx-tools/node-email";
79
+ import { config, transport } from "@dbx-tools/email";
80
80
 
81
81
  const resolved = config.resolveEmailConfig({
82
82
  smtp: { host: "smtp.example.com", user: "apikey", password: secret },
@@ -115,7 +115,7 @@ shown, the server can still derive the sender from the active user and config.
115
115
  ## Derive And Restrict Senders
116
116
 
117
117
  ```ts
118
- import { sender } from "@dbx-tools/node-email";
118
+ import { sender } from "@dbx-tools/email";
119
119
 
120
120
  const from = sender.resolveSenderAddress({
121
121
  userEmail: "alice@databricks.com",
@@ -132,7 +132,7 @@ current user, which is what the AppKit plugin exposes to clients.
132
132
  ## Render Markdown Email
133
133
 
134
134
  ```ts
135
- import { emailHtml, markdown } from "@dbx-tools/node-email";
135
+ import { emailHtml, markdown } from "@dbx-tools/email";
136
136
 
137
137
  const html = emailHtml.renderEmailHtml({
138
138
  subject: "Incident update",
@@ -147,7 +147,7 @@ the rendered body in the package layout and inlines CSS for mail clients.
147
147
  ## Use The Outbox In Tests
148
148
 
149
149
  ```ts
150
- import { outbox } from "@dbx-tools/node-email";
150
+ import { outbox } from "@dbx-tools/email";
151
151
 
152
152
  await outbox.writeOutboxEmail({
153
153
  dir: "tmp/email-outbox",
package/package.json CHANGED
@@ -19,12 +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.1.17",
23
- "@dbx-tools/shared-email": "0.1.17"
22
+ "@dbx-tools/shared-core": "0.1.19",
23
+ "@dbx-tools/shared-email": "0.1.19"
24
24
  },
25
25
  "main": "index.ts",
26
26
  "license": "UNLICENSED",
27
- "version": "0.1.17",
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "version": "0.1.19",
28
31
  "types": "index.ts",
29
32
  "type": "module",
30
33
  "exports": {
package/src/config.ts CHANGED
@@ -22,6 +22,7 @@
22
22
  */
23
23
  import type { BasePluginConfig } from "@databricks/appkit";
24
24
  import type { JSONSchema7 } from "json-schema";
25
+ import { object } from "@dbx-tools/shared-core";
25
26
  import { resolve } from "node:path";
26
27
  import { parseAllowedSenders } from "./sender";
27
28
 
@@ -149,15 +150,12 @@ export const EMAIL_CONFIG_SCHEMA: JSONSchema7 = {
149
150
  /** Parse the `SMTP_SECURE` env / config flag, defaulting to `port === 465`. */
150
151
  function resolveSecure(flag: boolean | undefined, port: number): boolean {
151
152
  if (typeof flag === "boolean") return flag;
152
- const env = process.env["SMTP_SECURE"];
153
- if (env !== undefined) return /^(1|true|yes)$/i.test(env.trim());
154
- return port === 465;
153
+ return object.toBoolean(process.env["SMTP_SECURE"]) ?? port === 465;
155
154
  }
156
155
 
157
156
  /** Whether `EMAIL_OUTBOX_MODE` explicitly opts into the file/outbox fallback. */
158
157
  function isOutboxModeEnabled(): boolean {
159
- const env = process.env["EMAIL_OUTBOX_MODE"];
160
- return env !== undefined && /^(1|true|yes)$/i.test(env.trim());
158
+ return object.toBoolean(process.env["EMAIL_OUTBOX_MODE"]) ?? false;
161
159
  }
162
160
 
163
161
  const SMTP_REQUIRED_FIELDS = ["SMTP_HOST", "SMTP_USER", "SMTP_PASSWORD"] as const;
package/src/outbox.ts CHANGED
@@ -12,18 +12,14 @@
12
12
  */
13
13
 
14
14
  import type { EmailMessage } from "@dbx-tools/shared-email";
15
+ import { string } from "@dbx-tools/shared-core";
15
16
  import { mkdir, writeFile } from "node:fs/promises";
16
17
  import { join, resolve } from "node:path";
17
18
  import { renderEmailHtml } from "./email-html";
18
19
 
19
20
  /** Filesystem-safe slug of the subject for the file name. */
20
21
  function subjectSlug(subject: string): string {
21
- const slug = subject
22
- .trim()
23
- .toLowerCase()
24
- .replace(/[^a-z0-9]+/g, "-")
25
- .replace(/^-+|-+$/g, "");
26
- return (slug || "email").slice(0, 48);
22
+ return string.toSlugWithOptions({ maxLength: 48 }, subject) || "email";
27
23
  }
28
24
 
29
25
  /** The envelope rows shown above the body in the preview file. */
package/src/tool.ts CHANGED
@@ -36,7 +36,7 @@ export interface EmailToolOptions {
36
36
  *
37
37
  * @example
38
38
  * ```ts
39
- * import { emailTool } from "@dbx-tools/appkit-email";
39
+ * import { emailTool } from "@dbx-tools/email";
40
40
  * import { createAgent } from "@dbx-tools/appkit-mastra";
41
41
  *
42
42
  * const support = createAgent({