@storyshelf/notify-email 0.6.2 → 0.7.0

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
@@ -19,13 +19,22 @@ const sender = smtpPreset({ host: "mail.example.com", port: 587, from: "shelf@ex
19
19
  const app = createShelfApp({
20
20
  database,
21
21
  storage,
22
- notifiers: [createEmailNotifier(sender, { from: "shelf@example.com" })],
22
+ notifications: { notifiers: [createEmailNotifier(sender, { from: "shelf@example.com" })] },
23
23
  // Optional: invites and password resets share the same transport.
24
24
  // auth: createShelfAuth({ db, secret, baseURL, emailSender: sender }),
25
25
  });
26
26
  ```
27
27
 
28
- Presets: `smtpPreset` (corporate relay, Postfix, SES-over-SMTP), `mailpitPreset` (local dev, `localhost:1025`), `logPreset` (tests/unconfigured), `httpPreset` (Resend/Postmark-style JSON endpoint). See [Notifications](/guides/notifications/).
28
+ ## Presets
29
+
30
+ | Preset | Use for |
31
+ | --------------- | ---------------------------------------------------------------------------------------------------------------- |
32
+ | `smtpPreset` | A corporate relay, Postfix, or SES over SMTP. `smtpPresetFromEnv` reads the settings from environment variables. |
33
+ | `mailpitPreset` | Local development against Mailpit (`localhost:1025`). |
34
+ | `httpPreset` | A Resend- or Postmark-style JSON HTTP endpoint. |
35
+ | `logPreset` | Tests and unconfigured setups — messages are written to the log. |
36
+
37
+ See [Notifications](https://storyshelf.js.org/guides/notifications/) for how email channels, subscriptions, and auth mail fit together.
29
38
 
30
39
  ## Install notes
31
40
 
package/dist/email.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import __tsdown_shims_path from 'node:path';
2
2
  import __tsdown_shims_url from 'node:url';
3
3
  import { EmailSender } from "@storyshelf/core/adapter/email-sender";
4
- import { NotifierProvider } from "@storyshelf/core/adapter/notifier";
4
+ import { MessageNotifierProvider } from "@storyshelf/core/adapter/notifier";
5
5
  import { Logger } from "@storyshelf/core/logger";
6
6
  //#region src/email.d.ts
7
7
  /** Defaults applied when a channel omits sender identity. */
@@ -15,9 +15,9 @@ interface EmailNotifierDefaults {
15
15
  */
16
16
  declare function createEmailNotifier(sender: EmailSender, defaults?: EmailNotifierDefaults & {
17
17
  logger?: Logger;
18
- }): NotifierProvider;
18
+ }): MessageNotifierProvider;
19
19
  /** Describe the email provider (name, version, config schema). */
20
- declare function getMetadata(): NotifierProvider["metadata"];
20
+ declare function getMetadata(): MessageNotifierProvider["metadata"];
21
21
  //#endregion
22
22
  export { EmailNotifierDefaults, createEmailNotifier, getMetadata };
23
23
  //# sourceMappingURL=email.d.mts.map
package/dist/email.mjs CHANGED
@@ -38,7 +38,7 @@ function createEmailNotifier(sender, defaults = {}) {
38
38
  function getMetadata() {
39
39
  return {
40
40
  name: "Email",
41
- version: globalThis.__PKG_VERSION__ ?? "0.0.0",
41
+ version: "0.7.0",
42
42
  description: "Email notifications over a shared SMTP/HTTP transport",
43
43
  kind: "email",
44
44
  category: "notifier",
@@ -1 +1 @@
1
- {"version":3,"file":"email.mjs","names":[],"sources":["../src/email.ts"],"sourcesContent":["import type { EmailSender } from \"@storyshelf/core/adapter/email-sender\";\nimport type { NotifierAdapter, NotifierProvider } from \"@storyshelf/core/adapter/notifier\";\nimport type { Logger } from \"@storyshelf/core/logger\";\nimport { emailChannelConfigSchema } from \"./types.ts\";\n\ndeclare const __PKG_VERSION__: string | undefined;\n\n/** Defaults applied when a channel omits sender identity. */\nexport interface EmailNotifierDefaults {\n from?: string;\n replyTo?: string;\n}\n\n/**\n * Create the `email` channel provider over a shared transport.\n * The same {@link EmailSender} can also serve auth mail (invites, resets).\n */\nexport function createEmailNotifier(\n sender: EmailSender,\n defaults: EmailNotifierDefaults & { logger?: Logger } = {},\n): NotifierProvider {\n return {\n metadata: getMetadata(),\n create(opts: { config: unknown; secret?: string; logger?: Logger }): NotifierAdapter {\n const config = emailChannelConfigSchema.parse(opts.config);\n const logger = (opts.logger ?? defaults.logger)?.child({ component: \"notify-email\" });\n return {\n metadata: getMetadata(),\n async send(input): Promise<void> {\n logger?.debug({ channelId: input.channel.id }, \"sending email notification\");\n await sender.send({\n to: config.to,\n subject: input.formatted.subject,\n text: input.formatted.text,\n html: input.formatted.html,\n from: config.from ?? defaults.from,\n replyTo: config.replyTo ?? defaults.replyTo,\n });\n logger?.info({ channelId: input.channel.id, to: config.to }, \"email sent\");\n },\n };\n },\n };\n}\n\n/** Describe the email provider (name, version, config schema). */\nexport function getMetadata(): NotifierProvider[\"metadata\"] {\n return {\n name: \"Email\",\n version: (globalThis as unknown as { __PKG_VERSION__?: string }).__PKG_VERSION__ ?? \"0.0.0\",\n description: \"Email notifications over a shared SMTP/HTTP transport\",\n kind: \"email\",\n category: \"notifier\",\n schema: emailChannelConfigSchema,\n };\n}\n"],"mappings":";;;;;;;;;AAiBA,SAAgB,oBACd,QACA,WAAwD,CAAC,GACvC;CAClB,OAAO;EACL,UAAU,YAAY;EACtB,OAAO,MAA8E;GACnF,MAAM,SAAS,yBAAyB,MAAM,KAAK,MAAM;GACzD,MAAM,UAAU,KAAK,UAAU,SAAS,OAAA,EAAS,MAAM,EAAE,WAAW,eAAe,CAAC;GACpF,OAAO;IACL,UAAU,YAAY;IACtB,MAAM,KAAK,OAAsB;KAC/B,QAAQ,MAAM,EAAE,WAAW,MAAM,QAAQ,GAAG,GAAG,4BAA4B;KAC3E,MAAM,OAAO,KAAK;MAChB,IAAI,OAAO;MACX,SAAS,MAAM,UAAU;MACzB,MAAM,MAAM,UAAU;MACtB,MAAM,MAAM,UAAU;MACtB,MAAM,OAAO,QAAQ,SAAS;MAC9B,SAAS,OAAO,WAAW,SAAS;KACtC,CAAC;KACD,QAAQ,KAAK;MAAE,WAAW,MAAM,QAAQ;MAAI,IAAI,OAAO;KAAG,GAAG,YAAY;IAC3E;GACF;EACF;CACF;AACF;;AAGA,SAAgB,cAA4C;CAC1D,OAAO;EACL,MAAM;EACN,SAAU,WAAuD,mBAAmB;EACpF,aAAa;EACb,MAAM;EACN,UAAU;EACV,QAAQ;CACV;AACF"}
1
+ {"version":3,"file":"email.mjs","names":[],"sources":["../src/email.ts"],"sourcesContent":["import type { EmailSender } from \"@storyshelf/core/adapter/email-sender\";\nimport type {\n MessageNotifierAdapter,\n MessageNotifierProvider,\n} from \"@storyshelf/core/adapter/notifier\";\nimport type { Logger } from \"@storyshelf/core/logger\";\nimport { emailChannelConfigSchema } from \"./types.ts\";\n\ndeclare const __PKG_VERSION__: string | undefined;\n\n/** Defaults applied when a channel omits sender identity. */\nexport interface EmailNotifierDefaults {\n from?: string;\n replyTo?: string;\n}\n\n/**\n * Create the `email` channel provider over a shared transport.\n * The same {@link EmailSender} can also serve auth mail (invites, resets).\n */\nexport function createEmailNotifier(\n sender: EmailSender,\n defaults: EmailNotifierDefaults & { logger?: Logger } = {},\n): MessageNotifierProvider {\n return {\n metadata: getMetadata(),\n create(opts: { config: unknown; secret?: string; logger?: Logger }): MessageNotifierAdapter {\n const config = emailChannelConfigSchema.parse(opts.config);\n const logger = (opts.logger ?? defaults.logger)?.child({ component: \"notify-email\" });\n return {\n metadata: getMetadata(),\n async send(input): Promise<void> {\n logger?.debug({ channelId: input.channel.id }, \"sending email notification\");\n await sender.send({\n to: config.to,\n subject: input.formatted.subject,\n text: input.formatted.text,\n html: input.formatted.html,\n from: config.from ?? defaults.from,\n replyTo: config.replyTo ?? defaults.replyTo,\n });\n logger?.info({ channelId: input.channel.id, to: config.to }, \"email sent\");\n },\n };\n },\n };\n}\n\n/** Describe the email provider (name, version, config schema). */\nexport function getMetadata(): MessageNotifierProvider[\"metadata\"] {\n return {\n name: \"Email\",\n version: typeof __PKG_VERSION__ === \"string\" ? __PKG_VERSION__ : \"0.0.0\",\n description: \"Email notifications over a shared SMTP/HTTP transport\",\n kind: \"email\",\n category: \"notifier\",\n schema: emailChannelConfigSchema,\n };\n}\n"],"mappings":";;;;;;;;;AAoBA,SAAgB,oBACd,QACA,WAAwD,CAAC,GAChC;CACzB,OAAO;EACL,UAAU,YAAY;EACtB,OAAO,MAAqF;GAC1F,MAAM,SAAS,yBAAyB,MAAM,KAAK,MAAM;GACzD,MAAM,UAAU,KAAK,UAAU,SAAS,OAAA,EAAS,MAAM,EAAE,WAAW,eAAe,CAAC;GACpF,OAAO;IACL,UAAU,YAAY;IACtB,MAAM,KAAK,OAAsB;KAC/B,QAAQ,MAAM,EAAE,WAAW,MAAM,QAAQ,GAAG,GAAG,4BAA4B;KAC3E,MAAM,OAAO,KAAK;MAChB,IAAI,OAAO;MACX,SAAS,MAAM,UAAU;MACzB,MAAM,MAAM,UAAU;MACtB,MAAM,MAAM,UAAU;MACtB,MAAM,OAAO,QAAQ,SAAS;MAC9B,SAAS,OAAO,WAAW,SAAS;KACtC,CAAC;KACD,QAAQ,KAAK;MAAE,WAAW,MAAM,QAAQ;MAAI,IAAI,OAAO;KAAG,GAAG,YAAY;IAC3E;GACF;EACF;CACF;AACF;;AAGA,SAAgB,cAAmD;CACjE,OAAO;EACL,MAAM;EACN,SAAA;EACA,aAAa;EACb,MAAM;EACN,UAAU;EACV,QAAQ;CACV;AACF"}
package/dist/version.mjs CHANGED
@@ -4,7 +4,7 @@ import.meta.url;
4
4
  //#region src/version.ts
5
5
  /** Package version injected at build via __PKG_VERSION__. */
6
6
  function version() {
7
- return globalThis.__PKG_VERSION__ ?? "0.0.0";
7
+ return "0.7.0";
8
8
  }
9
9
  //#endregion
10
10
  export { version };
@@ -1 +1 @@
1
- {"version":3,"file":"version.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["declare const __PKG_VERSION__: string | undefined;\n\n/** Package version injected at build via __PKG_VERSION__. */\nexport function version(): string {\n return (globalThis as unknown as { __PKG_VERSION__?: string }).__PKG_VERSION__ ?? \"0.0.0\";\n}\n"],"mappings":";;;;;AAGA,SAAgB,UAAkB;CAChC,OAAQ,WAAuD,mBAAmB;AACpF"}
1
+ {"version":3,"file":"version.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["declare const __PKG_VERSION__: string | undefined;\n\n/** Package version injected at build via __PKG_VERSION__. */\nexport function version(): string {\n return typeof __PKG_VERSION__ === \"string\" ? __PKG_VERSION__ : \"0.0.0\";\n}\n"],"mappings":";;;;;AAGA,SAAgB,UAAkB;CAChC,OAAA;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyshelf/notify-email",
3
- "version": "0.6.2",
3
+ "version": "0.7.0",
4
4
  "description": "Email notification transport for StoryShelf (SMTP, Mailpit, log, HTTP APIs).",
5
5
  "keywords": [
6
6
  "email",
@@ -27,9 +27,6 @@
27
27
  "dist"
28
28
  ],
29
29
  "type": "module",
30
- "engines": {
31
- "node": ">=24"
32
- },
33
30
  "sideEffects": false,
34
31
  "types": "./dist/index.d.mts",
35
32
  "exports": {
@@ -80,7 +77,7 @@
80
77
  "prepublishOnly": "nub run build"
81
78
  },
82
79
  "dependencies": {
83
- "@storyshelf/core": "0.6.2",
80
+ "@storyshelf/core": "0.7.0",
84
81
  "zod": "^4.2.0"
85
82
  },
86
83
  "devDependencies": {
@@ -103,6 +100,9 @@
103
100
  "optional": true
104
101
  }
105
102
  },
103
+ "engines": {
104
+ "node": ">=24"
105
+ },
106
106
  "jsr": {
107
107
  "runtimeCompat": {
108
108
  "node": true,