emdash-smtp 0.2.2 → 0.3.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/CHANGELOG.md +0 -11
- package/README.md +2 -2
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +21 -27
- package/dist/plugin.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.2.1
|
|
4
|
-
|
|
5
|
-
- Strengthened README and package metadata messaging directing installers to `emdash-smtp` rather than the internal `emdash-smtp-core`/`emdash-smtp-node-transports` packages
|
|
6
|
-
- Refreshed interdependency pins to the matching 0.2.1 releases
|
|
7
|
-
|
|
8
|
-
## 0.2.0
|
|
9
|
-
|
|
10
|
-
- Renamed the trusted npm package to the unscoped `emdash-smtp`
|
|
11
|
-
- Kept the same EmDash plugin ID and `astro.config.mjs` registration flow
|
|
12
|
-
- Clarified the split between trusted npm installs and marketplace publication
|
|
13
|
-
|
|
14
3
|
## 0.1.0
|
|
15
4
|
|
|
16
5
|
- Initial trusted EmDash SMTP release
|
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ pnpm add emdash-smtp
|
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
25
|
import { defineConfig } from "astro/config";
|
|
26
|
-
import emdash from "emdash/astro";
|
|
26
|
+
import { emdash } from "emdash/astro";
|
|
27
27
|
import { emdashSmtp } from "emdash-smtp";
|
|
28
28
|
|
|
29
29
|
export default defineConfig({
|
|
@@ -49,7 +49,7 @@ Choose the trusted package if you need any of the following:
|
|
|
49
49
|
Choose one runtime path per site:
|
|
50
50
|
|
|
51
51
|
- `emdash-smtp` for trusted/npm installs
|
|
52
|
-
- `emdash-smtp-marketplace` for marketplace
|
|
52
|
+
- `emdash-smtp-marketplace` for marketplace/sandbox installs
|
|
53
53
|
- both distributions identify as `emdash-smtp` inside EmDash
|
|
54
54
|
|
|
55
55
|
If you need a user-installable marketplace listing and a first-party npm install path, publish both packages as a split pair.
|
package/dist/plugin.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;iBAkFgB,YAAA,CAAA,GAAgB,cAAA"}
|
package/dist/plugin.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SMTP_ADMIN_PAGES, SMTP_ADMIN_WIDGETS, SMTP_PLUGIN_ID, SMTP_PLUGIN_VERSION, collectAllowedHosts, createDeliveryLogRecord, deliverWithConfiguredProvider, handleAdminInteraction,
|
|
1
|
+
import { SMTP_ADMIN_PAGES, SMTP_ADMIN_WIDGETS, SMTP_PLUGIN_ID, SMTP_PLUGIN_VERSION, collectAllowedHosts, createDeliveryLogRecord, deliverWithConfiguredProvider, handleAdminInteraction, writeDeliveryLog } from "emdash-smtp-core";
|
|
2
2
|
import { definePlugin } from "emdash";
|
|
3
3
|
import { sendmailSend, smtpSend } from "emdash-smtp-node-transports";
|
|
4
4
|
|
|
@@ -53,35 +53,29 @@ function createPlugin() {
|
|
|
53
53
|
pages: [...SMTP_ADMIN_PAGES],
|
|
54
54
|
widgets: [...SMTP_ADMIN_WIDGETS]
|
|
55
55
|
},
|
|
56
|
-
hooks: {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
throw err;
|
|
72
|
-
}
|
|
56
|
+
hooks: { "email:deliver": {
|
|
57
|
+
exclusive: true,
|
|
58
|
+
handler: async (event, ctx) => {
|
|
59
|
+
const source = event.source || ctx.plugin.id;
|
|
60
|
+
try {
|
|
61
|
+
await logSuccessfulDelivery(ctx, event, source, await deliverWithConfiguredProvider({
|
|
62
|
+
ctx,
|
|
63
|
+
runtime: createTrustedRuntime(ctx),
|
|
64
|
+
message: event.message,
|
|
65
|
+
source
|
|
66
|
+
}));
|
|
67
|
+
} catch (error) {
|
|
68
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
69
|
+
await logFailedDelivery(ctx, event, source, err);
|
|
70
|
+
throw err;
|
|
73
71
|
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
runtime: createTrustedRuntime(ctx)
|
|
78
|
-
}) }
|
|
79
|
-
},
|
|
80
|
-
routes: { admin: { handler: (async (routeCtx) => {
|
|
72
|
+
}
|
|
73
|
+
} },
|
|
74
|
+
routes: { admin: { handler: (async (routeCtx, ctx) => {
|
|
81
75
|
return handleAdminInteraction({
|
|
82
|
-
ctx
|
|
76
|
+
ctx,
|
|
83
77
|
variant: "trusted",
|
|
84
|
-
runtime: createTrustedRuntime(
|
|
78
|
+
runtime: createTrustedRuntime(ctx),
|
|
85
79
|
interaction: routeCtx.input ?? {
|
|
86
80
|
type: "page_load",
|
|
87
81
|
page: "/providers"
|
package/dist/plugin.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import { definePlugin } from \"emdash\";\nimport type { PluginContext, ResolvedPlugin } from \"emdash\";\n\nimport {\n\tcollectAllowedHosts,\n\tcreateDeliveryLogRecord,\n\tdeliverWithConfiguredProvider,\n\thandleAdminInteraction,\n\
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import { definePlugin } from \"emdash\";\nimport type { PluginContext, ResolvedPlugin } from \"emdash\";\n\nimport {\n\tcollectAllowedHosts,\n\tcreateDeliveryLogRecord,\n\tdeliverWithConfiguredProvider,\n\thandleAdminInteraction,\n\tSMTP_ADMIN_PAGES,\n\tSMTP_ADMIN_WIDGETS,\n\tSMTP_PLUGIN_ID,\n\tSMTP_PLUGIN_VERSION,\n\ttype AdminInteraction,\n\ttype DeliveryRuntime,\n\ttype SmtpPluginContextLike,\n\twriteDeliveryLog,\n} from \"emdash-smtp-core\";\nimport { sendmailSend, smtpSend } from \"emdash-smtp-node-transports\";\n\nfunction createTrustedRuntime(ctx: PluginContext): DeliveryRuntime {\n\treturn {\n\t\tvariant: \"trusted\",\n\t\tfetch: ctx.http ? (url, init) => ctx.http!.fetch(url, init) : undefined,\n\t\tsmtpSend,\n\t\tsendmailSend,\n\t};\n}\n\ninterface TrustedEmailDeliverEvent {\n\tmessage: {\n\t\tto: string;\n\t\tsubject: string;\n\t\ttext: string;\n\t\thtml?: string;\n\t};\n\tsource: string;\n}\n\nasync function logSuccessfulDelivery(\n\tctx: SmtpPluginContextLike,\n\tevent: TrustedEmailDeliverEvent,\n\tsource: string,\n\tresult: Awaited<ReturnType<typeof deliverWithConfiguredProvider>>,\n): Promise<void> {\n\tawait writeDeliveryLog(\n\t\tctx,\n\t\tcreateDeliveryLogRecord({\n\t\t\tproviderId: result.providerId,\n\t\t\tstatus: \"sent\",\n\t\t\tmessage: {\n\t\t\t\tto: event.message.to,\n\t\t\t\tsubject: event.message.subject,\n\t\t\t},\n\t\t\tsource,\n\t\t\tdurationMs: result.durationMs,\n\t\t\tremoteMessageId: result.remoteMessageId,\n\t\t}),\n\t);\n}\n\nasync function logFailedDelivery(\n\tctx: SmtpPluginContextLike,\n\tevent: TrustedEmailDeliverEvent,\n\tsource: string,\n\terror: Error,\n): Promise<void> {\n\tawait writeDeliveryLog(\n\t\tctx,\n\t\tcreateDeliveryLogRecord({\n\t\t\tproviderId: \"unknown\",\n\t\t\tstatus: \"failed\",\n\t\t\tmessage: {\n\t\t\t\tto: event.message.to,\n\t\t\t\tsubject: event.message.subject,\n\t\t\t},\n\t\t\tsource,\n\t\t\tdurationMs: 0,\n\t\t\terrorMessage: error.message,\n\t\t}),\n\t);\n}\n\nexport function createPlugin(): ResolvedPlugin {\n\treturn definePlugin({\n\t\tid: SMTP_PLUGIN_ID,\n\t\tversion: SMTP_PLUGIN_VERSION,\n\t\tcapabilities: [\"email:provide\", \"network:fetch\"],\n\t\tallowedHosts: collectAllowedHosts(\"trusted\"),\n\t\tstorage: {\n\t\t\tdeliveryLogs: {\n\t\t\t\tindexes: [\"providerId\", \"status\", \"createdAt\", \"source\"],\n\t\t\t},\n\t\t},\n\t\tadmin: {\n\t\t\tpages: [...SMTP_ADMIN_PAGES],\n\t\t\twidgets: [...SMTP_ADMIN_WIDGETS],\n\t\t},\n\t\thooks: {\n\t\t\t\"email:deliver\": {\n\t\t\t\texclusive: true,\n\t\t\t\thandler: async (event: TrustedEmailDeliverEvent, ctx: PluginContext) => {\n\t\t\t\t\tconst source = event.source || ctx.plugin.id;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await deliverWithConfiguredProvider({\n\t\t\t\t\t\t\tctx: ctx as unknown as SmtpPluginContextLike,\n\t\t\t\t\t\t\truntime: createTrustedRuntime(ctx),\n\t\t\t\t\t\t\tmessage: event.message,\n\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tawait logSuccessfulDelivery(\n\t\t\t\t\t\t\tctx as unknown as SmtpPluginContextLike,\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\tresult,\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\t\t\tawait logFailedDelivery(ctx as unknown as SmtpPluginContextLike, event, source, err);\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\troutes: {\n\t\t\tadmin: {\n\t\t\t\thandler: (async (\n\t\t\t\t\trouteCtx: { input: unknown; request: unknown },\n\t\t\t\t\tctx: PluginContext,\n\t\t\t\t) => {\n\t\t\t\t\treturn handleAdminInteraction({\n\t\t\t\t\t\tctx: ctx as unknown as SmtpPluginContextLike,\n\t\t\t\t\t\tvariant: \"trusted\",\n\t\t\t\t\t\truntime: createTrustedRuntime(ctx),\n\t\t\t\t\t\tinteraction: (routeCtx.input ?? { type: \"page_load\", page: \"/providers\" }) as AdminInteraction,\n\t\t\t\t\t});\n\t\t\t\t}) as never,\n\t\t\t},\n\t\t},\n\t});\n}\n\nexport default createPlugin;\n"],"mappings":";;;;;AAmBA,SAAS,qBAAqB,KAAqC;AAClE,QAAO;EACN,SAAS;EACT,OAAO,IAAI,QAAQ,KAAK,SAAS,IAAI,KAAM,MAAM,KAAK,KAAK,GAAG;EAC9D;EACA;EACA;;AAaF,eAAe,sBACd,KACA,OACA,QACA,QACgB;AAChB,OAAM,iBACL,KACA,wBAAwB;EACvB,YAAY,OAAO;EACnB,QAAQ;EACR,SAAS;GACR,IAAI,MAAM,QAAQ;GAClB,SAAS,MAAM,QAAQ;GACvB;EACD;EACA,YAAY,OAAO;EACnB,iBAAiB,OAAO;EACxB,CAAC,CACF;;AAGF,eAAe,kBACd,KACA,OACA,QACA,OACgB;AAChB,OAAM,iBACL,KACA,wBAAwB;EACvB,YAAY;EACZ,QAAQ;EACR,SAAS;GACR,IAAI,MAAM,QAAQ;GAClB,SAAS,MAAM,QAAQ;GACvB;EACD;EACA,YAAY;EACZ,cAAc,MAAM;EACpB,CAAC,CACF;;AAGF,SAAgB,eAA+B;AAC9C,QAAO,aAAa;EACnB,IAAI;EACJ,SAAS;EACT,cAAc,CAAC,iBAAiB,gBAAgB;EAChD,cAAc,oBAAoB,UAAU;EAC5C,SAAS,EACR,cAAc,EACb,SAAS;GAAC;GAAc;GAAU;GAAa;GAAS,EACxD,EACD;EACD,OAAO;GACN,OAAO,CAAC,GAAG,iBAAiB;GAC5B,SAAS,CAAC,GAAG,mBAAmB;GAChC;EACD,OAAO,EACN,iBAAiB;GAChB,WAAW;GACX,SAAS,OAAO,OAAiC,QAAuB;IACvE,MAAM,SAAS,MAAM,UAAU,IAAI,OAAO;AAC1C,QAAI;AAOH,WAAM,sBACL,KACA,OACA,QATc,MAAM,8BAA8B;MAC7C;MACL,SAAS,qBAAqB,IAAI;MAClC,SAAS,MAAM;MACf;MACA,CAAC,CAMD;aACO,OAAO;KACf,MAAM,MAAM,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC;AACrE,WAAM,kBAAkB,KAAyC,OAAO,QAAQ,IAAI;AACpF,WAAM;;;GAGR,EACD;EACD,QAAQ,EACP,OAAO,EACN,UAAU,OACT,UACA,QACI;AACJ,UAAO,uBAAuB;IACxB;IACL,SAAS;IACT,SAAS,qBAAqB,IAAI;IAClC,aAAc,SAAS,SAAS;KAAE,MAAM;KAAa,MAAM;KAAc;IACzE,CAAC;MAEH,EACD;EACD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emdash-smtp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Trusted full-parity SMTP and transactional email plugin for EmDash",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"keywords": ["emdash", "emdash-plugin", "smtp", "email", "transactional-email"],
|
|
26
26
|
"author": "Mason James",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"emdash-smtp-core": "
|
|
29
|
-
"emdash-smtp-node-transports": "
|
|
28
|
+
"emdash-smtp-core": "workspace:*",
|
|
29
|
+
"emdash-smtp-node-transports": "workspace:*"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"emdash": ">=0.1.0"
|