diff --git a/apps/backend/src/app/api/latest/emails/send-email/route.tsx b/apps/backend/src/app/api/latest/emails/send-email/route.tsx index aa2f14d5a6..77ccf24a30 100644 --- a/apps/backend/src/app/api/latest/emails/send-email/route.tsx +++ b/apps/backend/src/app/api/latest/emails/send-email/route.tsx @@ -27,7 +27,9 @@ export const POST = createSmartRouteHandler({ }).defined(), body: yupObject({ user_ids: yupArray(yupString().defined()).defined(), - theme_id: templateThemeIdSchema.nullable().label("The theme to use for the email. If not specified, the default theme will be used."), + theme_id: templateThemeIdSchema.nullable().meta({ + openapiField: { description: "The theme to use for the email. If not specified, the default theme will be used." } + }), html: yupString().optional(), subject: yupString().optional(), notification_category_name: yupString().optional(), diff --git a/apps/backend/src/lib/email-rendering.tsx b/apps/backend/src/lib/email-rendering.tsx index 82fc4c5037..b58622e0c1 100644 --- a/apps/backend/src/lib/email-rendering.tsx +++ b/apps/backend/src/lib/email-rendering.tsx @@ -65,14 +65,6 @@ export async function renderEmailWithTemplate( throw new StackAssertionError("Project is required when not in preview mode", { user, project, variables }); } - if (["development", "test"].includes(getNodeEnvironment()) && apiKey === "mock_stack_freestyle_key") { - return Result.ok({ - html: `
Mock api key detected, \n\ntemplateComponent: ${templateComponent}\n\nthemeComponent: ${themeComponent}\n\n variables: ${JSON.stringify(variables)}
`, - text: `
Mock api key detected, \n\ntemplateComponent: ${templateComponent}\n\nthemeComponent: ${themeComponent}\n\n variables: ${JSON.stringify(variables)}
`, - subject: `Mock subject, ${templateComponent.match(/]*\/>/g)?.[0]}`, - notificationCategory: "mock notification category", - }); - } const result = await bundleJavaScript({ "/utils.tsx": findComponentValueUtil, "/theme.tsx": themeComponent, @@ -124,6 +116,7 @@ export async function renderEmailWithTemplate( const freestyle = new Freestyle({ apiKey }); const nodeModules = { + "react": "19.1.1", "@react-email/components": "0.1.1", "arktype": "2.1.20", }; diff --git a/apps/backend/src/lib/freestyle.tsx b/apps/backend/src/lib/freestyle.tsx index 5f763a9bc2..b6b0ea6ceb 100644 --- a/apps/backend/src/lib/freestyle.tsx +++ b/apps/backend/src/lib/freestyle.tsx @@ -1,12 +1,20 @@ +import { traceSpan } from '@/utils/telemetry'; +import { getNodeEnvironment } from '@stackframe/stack-shared/dist/utils/env'; import { StackAssertionError, captureError, errorToNiceString } from '@stackframe/stack-shared/dist/utils/errors'; -import { traceSpan } from '@stackframe/stack-shared/dist/utils/telemetry'; import { FreestyleSandboxes } from 'freestyle-sandboxes'; export class Freestyle { private freestyle: FreestyleSandboxes; constructor(options: { apiKey: string }) { - this.freestyle = new FreestyleSandboxes(options); + let baseUrl = undefined; + if (["development", "test"].includes(getNodeEnvironment()) && options.apiKey === "mock_stack_freestyle_key") { + baseUrl = "http://localhost:8122"; + } + this.freestyle = new FreestyleSandboxes({ + apiKey: options.apiKey, + baseUrl, + }); } async executeScript(script: string, options?: Parameters[1]) { diff --git a/apps/dev-launchpad/public/index.html b/apps/dev-launchpad/public/index.html index 41fc2ee64d..37e69a11e7 100644 --- a/apps/dev-launchpad/public/index.html +++ b/apps/dev-launchpad/public/index.html @@ -111,7 +111,7 @@

Background services

4318: OTel collector
  • - 8119: Freestyle mock + 8122: Freestyle mock
  • 8121: S3 mock diff --git a/apps/e2e/tests/backend/endpoints/api/v1/auth/otp/send-sign-in-code.test.ts b/apps/e2e/tests/backend/endpoints/api/v1/auth/otp/send-sign-in-code.test.ts index 36478179ba..e857c5b301 100644 --- a/apps/e2e/tests/backend/endpoints/api/v1/auth/otp/send-sign-in-code.test.ts +++ b/apps/e2e/tests/backend/endpoints/api/v1/auth/otp/send-sign-in-code.test.ts @@ -8,7 +8,7 @@ it("should send a sign-in code per e-mail", async ({ expect }) => { [ MailboxMessage { "from": "Stack Dashboard ", - "subject": "Mock subject, \\"", + "subject": "Sign in to Stack Dashboard: Your code is ", "to": ["@stack-generated.example.com>"],