@decocms/apps 0.26.0 → 0.27.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/package.json +2 -1
- package/resend/mod.ts +53 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/apps",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Deco commerce apps for TanStack Start - Shopify, VTEX, commerce types, analytics utils",
|
|
6
6
|
"exports": {
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"./vtex/middleware": "./vtex/middleware.ts",
|
|
40
40
|
"./vtex/invoke": "./vtex/invoke.ts",
|
|
41
41
|
"./resend": "./resend/index.ts",
|
|
42
|
+
"./resend/mod": "./resend/mod.ts",
|
|
42
43
|
"./resend/client": "./resend/client.ts",
|
|
43
44
|
"./resend/types": "./resend/types.ts",
|
|
44
45
|
"./resend/actions/send": "./resend/actions/send.ts"
|
package/resend/mod.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resend app module — standard autoconfig contract.
|
|
3
|
+
*
|
|
4
|
+
* Each Deco app exports:
|
|
5
|
+
* - `configure(blockData, resolveSecret)` — set up the client from CMS block data
|
|
6
|
+
* - `handlers` — record of invoke handler keys → handler functions
|
|
7
|
+
*
|
|
8
|
+
* The framework's `autoconfigApps()` calls these generically — no hardcoded
|
|
9
|
+
* app knowledge needed in the framework.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { configureResend } from "./client";
|
|
13
|
+
import { sendEmail } from "./actions/send";
|
|
14
|
+
|
|
15
|
+
export interface AppModContract {
|
|
16
|
+
configure: (
|
|
17
|
+
blockData: any,
|
|
18
|
+
resolveSecret: (value: unknown, envKey: string) => Promise<string | null>,
|
|
19
|
+
) => Promise<boolean>;
|
|
20
|
+
handlers: Record<string, (props: any, request: Request) => Promise<any>>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Configure Resend from CMS block data.
|
|
25
|
+
* Returns true if configured successfully, false if missing credentials.
|
|
26
|
+
*/
|
|
27
|
+
export async function configure(
|
|
28
|
+
block: any,
|
|
29
|
+
resolveSecret: (value: unknown, envKey: string) => Promise<string | null>,
|
|
30
|
+
): Promise<boolean> {
|
|
31
|
+
const apiKey = await resolveSecret(block.apiKey, "RESEND_API_KEY");
|
|
32
|
+
if (!apiKey) return false;
|
|
33
|
+
|
|
34
|
+
configureResend({
|
|
35
|
+
apiKey,
|
|
36
|
+
emailFrom: block.emailFrom
|
|
37
|
+
? `${block.emailFrom.name || "Contact"} <${block.emailFrom.domain || "onboarding@resend.dev"}>`
|
|
38
|
+
: undefined,
|
|
39
|
+
emailTo: block.emailTo,
|
|
40
|
+
subject: block.subject,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Invoke handlers registered under /deco/invoke/{key}.
|
|
48
|
+
* Both with and without .ts suffix for compatibility.
|
|
49
|
+
*/
|
|
50
|
+
export const handlers: Record<string, (props: any, request: Request) => Promise<any>> = {
|
|
51
|
+
"resend/actions/emails/send": (props) => sendEmail(props),
|
|
52
|
+
"resend/actions/emails/send.ts": (props) => sendEmail(props),
|
|
53
|
+
};
|