@agent-native/core 0.138.0 → 0.140.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/corpus/README.md +1 -1
- package/corpus/templates/analytics/server/lib/dashboard-report.ts +2 -0
- package/corpus/templates/analytics/server/lib/emails.ts +51 -0
- package/corpus/templates/analytics/server/plugins/transactional-emails.ts +5 -0
- package/corpus/templates/calendar/server/lib/booking-emails.ts +154 -70
- package/corpus/templates/calendar/server/lib/emails.ts +167 -0
- package/corpus/templates/calendar/server/lib/event-guest-notifications.ts +64 -28
- package/corpus/templates/calendar/server/plugins/transactional-emails.ts +5 -0
- package/corpus/templates/clips/actions/invite-member.ts +39 -15
- package/corpus/templates/clips/server/lib/emails.ts +256 -0
- package/corpus/templates/clips/server/lib/transactional-email-templates.ts +24 -0
- package/corpus/templates/clips/server/plugins/transactional-email-catalog.ts +5 -0
- package/corpus/templates/content/server/lib/comment-notifications.ts +57 -26
- package/corpus/templates/content/server/lib/emails.ts +70 -0
- package/corpus/templates/content/server/plugins/transactional-emails.ts +5 -0
- package/corpus/templates/design/.agents/skills/design-systems/SKILL.md +44 -1
- package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +265 -1
- package/corpus/templates/design/actions/create-design-system.ts +9 -10
- package/corpus/templates/design/actions/get-design-system.ts +53 -0
- package/corpus/templates/design/actions/import-design-tokens.ts +5 -71
- package/corpus/templates/design/actions/index-design-tokens.ts +61 -80
- package/corpus/templates/design/actions/update-design-system.ts +7 -10
- package/corpus/templates/design/app/components/design/EditPanel.tsx +45 -2
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +12 -0
- package/corpus/templates/design/app/components/design/edit-panel/design-system-swatches.ts +215 -0
- package/corpus/templates/design/app/components/design/edit-panel/document-colors.ts +10 -6
- package/corpus/templates/design/app/components/design/edit-panel/effects-properties.tsx +19 -3
- package/corpus/templates/design/app/components/design/edit-panel/fill-properties.tsx +36 -10
- package/corpus/templates/design/app/components/design/edit-panel/interaction-state-helpers.ts +15 -0
- package/corpus/templates/design/app/components/design/edit-panel/panel-primitives.tsx +19 -1
- package/corpus/templates/design/app/components/design/edit-panel/position-helpers.ts +6 -0
- package/corpus/templates/design/app/components/design/edit-panel/stroke-properties.tsx +53 -10
- package/corpus/templates/design/app/components/design/inspector/DesignColorPicker.tsx +142 -4
- package/corpus/templates/design/app/components/design/types.ts +6 -0
- package/corpus/templates/design/app/i18n-data.ts +20 -0
- package/corpus/templates/design/app/pages/DesignSystemSetup.tsx +1 -1
- package/corpus/templates/design/app/pages/DesignSystems.tsx +78 -1
- package/corpus/templates/design/app/pages/design-editor/html-layer-positioning.ts +6 -1
- package/corpus/templates/design/changelog/2026-08-04-design-system-tokens-show-by-name-in-the-editor.md +6 -0
- package/corpus/templates/design/e2e/helpers.ts +17 -0
- package/corpus/templates/design/server/lib/design-system-tokens.ts +35 -0
- package/corpus/templates/design/shared/authored-color-styles.ts +401 -0
- package/corpus/templates/design/shared/resolve-tweaks.ts +10 -18
- package/corpus/templates/dispatch/app/routes/transactional-email.$appId.$id.tsx +4 -0
- package/corpus/templates/dispatch/app/routes/transactional-email.tsx +4 -0
- package/corpus/templates/forms/server/lib/emails.ts +52 -0
- package/corpus/templates/forms/server/lib/response-email.ts +2 -0
- package/corpus/templates/forms/server/plugins/transactional-emails.ts +5 -0
- package/corpus/templates/plan/actions/request-plan-access.ts +33 -12
- package/corpus/templates/plan/server/lib/comment-notifications.ts +53 -27
- package/corpus/templates/plan/server/lib/emails.ts +67 -0
- package/corpus/templates/plan/server/plugins/transactional-emails.ts +5 -0
- package/corpus/templates/slides/server/lib/comment-notifications.ts +44 -21
- package/corpus/templates/slides/server/lib/emails.ts +40 -0
- package/corpus/templates/slides/server/plugins/transactional-emails.ts +5 -0
- package/dist/brand-kit/index.d.ts +1 -0
- package/dist/brand-kit/index.js +1 -0
- package/dist/brand-kit/tokens.d.ts +92 -0
- package/dist/brand-kit/tokens.js +280 -0
- package/dist/brand-kit/types.d.ts +25 -0
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/routes.d.ts +2 -2
- package/dist/email-catalog/actions/list-email-activity.d.ts +6 -0
- package/dist/email-catalog/actions/list-email-activity.js +15 -0
- package/dist/email-catalog/actions/list-email-engagement.d.ts +6 -0
- package/dist/email-catalog/actions/list-email-engagement.js +15 -0
- package/dist/email-catalog/actions/list-email-log.d.ts +8 -0
- package/dist/email-catalog/actions/list-email-log.js +22 -0
- package/dist/email-catalog/actions/list-transactional-emails.d.ts +23 -0
- package/dist/email-catalog/actions/list-transactional-emails.js +61 -0
- package/dist/email-catalog/actions/render-transactional-email-preview.d.ts +10 -0
- package/dist/email-catalog/actions/render-transactional-email-preview.js +24 -0
- package/dist/email-catalog/authorize.d.ts +2 -0
- package/dist/email-catalog/authorize.js +10 -0
- package/dist/email-catalog/log.d.ts +57 -0
- package/dist/email-catalog/log.js +117 -0
- package/dist/email-catalog/provider-metrics.d.ts +34 -0
- package/dist/email-catalog/provider-metrics.js +165 -0
- package/dist/email-catalog/registry.d.ts +79 -0
- package/dist/email-catalog/registry.js +71 -0
- package/dist/email-catalog/schema.d.ts +212 -0
- package/dist/email-catalog/schema.js +49 -0
- package/dist/email-catalog/system-emails.d.ts +14 -0
- package/dist/email-catalog/system-emails.js +68 -0
- package/dist/localization/default-messages.d.ts +45 -0
- package/dist/localization/default-messages.js +45 -0
- package/dist/notifications/routes.d.ts +6 -6
- package/dist/org/handlers.js +8 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +7 -7
- package/dist/provider-api/actions/provider-api.d.ts +7 -7
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/server/action-discovery.js +22 -0
- package/dist/server/better-auth-instance.js +17 -2
- package/dist/server/email.d.ts +9 -0
- package/dist/server/email.js +44 -3
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drizzle schema for the transactional email send log.
|
|
3
|
+
*
|
|
4
|
+
* One row per `sendEmail` attempt, written by the transport itself so every
|
|
5
|
+
* send is recorded regardless of which app or code path triggered it. This is
|
|
6
|
+
* the durable record of "did we send it": the provider's own activity feed ages
|
|
7
|
+
* out (SendGrid keeps 3 days without the extended-retention add-on), so send
|
|
8
|
+
* counts and last-sent must not depend on it.
|
|
9
|
+
*
|
|
10
|
+
* Engagement (opens, clicks, bounces) is deliberately NOT stored here. Only the
|
|
11
|
+
* provider knows it, and mirroring it would go stale the moment a recipient
|
|
12
|
+
* opens an old message. Dispatch reads engagement live from the provider and
|
|
13
|
+
* joins on `template_id`.
|
|
14
|
+
*/
|
|
15
|
+
import { table, text, integer } from "../db/schema.js";
|
|
16
|
+
export const emailLog = table("email_log", {
|
|
17
|
+
id: text("id").primaryKey(),
|
|
18
|
+
/** Registered transactional email id, e.g. "calendar.booking-confirmed". */
|
|
19
|
+
templateId: text("template_id"),
|
|
20
|
+
/** App slug that sent it. */
|
|
21
|
+
app: text("app"),
|
|
22
|
+
/** Recipient address. */
|
|
23
|
+
recipient: text("recipient").notNull(),
|
|
24
|
+
/** Resolved From address, after app-sender branding is applied. */
|
|
25
|
+
sender: text("sender").notNull(),
|
|
26
|
+
subject: text("subject").notNull(),
|
|
27
|
+
/** "sent" once the provider accepted it, or "failed". Never optimistic. */
|
|
28
|
+
status: text("status", { enum: ["sent", "failed"] }).notNull(),
|
|
29
|
+
/** Provider error text when status is "failed". */
|
|
30
|
+
error: text("error"),
|
|
31
|
+
/** "resend" | "sendgrid" | "dev". */
|
|
32
|
+
provider: text("provider").notNull(),
|
|
33
|
+
createdAt: integer("created_at").notNull(),
|
|
34
|
+
});
|
|
35
|
+
export const EMAIL_LOG_CREATE_SQL = `CREATE TABLE IF NOT EXISTS email_log (
|
|
36
|
+
id TEXT PRIMARY KEY,
|
|
37
|
+
template_id TEXT,
|
|
38
|
+
app TEXT,
|
|
39
|
+
recipient TEXT NOT NULL,
|
|
40
|
+
sender TEXT NOT NULL,
|
|
41
|
+
subject TEXT NOT NULL,
|
|
42
|
+
status TEXT NOT NULL,
|
|
43
|
+
error TEXT,
|
|
44
|
+
provider TEXT NOT NULL,
|
|
45
|
+
created_at INTEGER NOT NULL
|
|
46
|
+
)`;
|
|
47
|
+
export const EMAIL_LOG_TEMPLATE_INDEX_SQL = `CREATE INDEX IF NOT EXISTS email_log_template_created_idx
|
|
48
|
+
ON email_log (template_id, created_at)`;
|
|
49
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catalog entries for the framework's own system emails.
|
|
3
|
+
*
|
|
4
|
+
* These ship with every app rather than belonging to one, so they register
|
|
5
|
+
* under the `core` app instead of the running app's slug. Importing this module
|
|
6
|
+
* performs the registration; `register-system-emails.ts` is the single import
|
|
7
|
+
* site so the emails appear in every app's catalog without each template
|
|
8
|
+
* remembering to opt in.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CORE_INVITE_EMAIL_ID = "core.organization-invite";
|
|
11
|
+
export declare const CORE_VERIFY_SIGNUP_EMAIL_ID = "core.verify-signup";
|
|
12
|
+
export declare const CORE_RESET_PASSWORD_EMAIL_ID = "core.reset-password";
|
|
13
|
+
export declare function registerCoreSystemEmails(): void;
|
|
14
|
+
//# sourceMappingURL=system-emails.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catalog entries for the framework's own system emails.
|
|
3
|
+
*
|
|
4
|
+
* These ship with every app rather than belonging to one, so they register
|
|
5
|
+
* under the `core` app instead of the running app's slug. Importing this module
|
|
6
|
+
* performs the registration; `register-system-emails.ts` is the single import
|
|
7
|
+
* site so the emails appear in every app's catalog without each template
|
|
8
|
+
* remembering to opt in.
|
|
9
|
+
*/
|
|
10
|
+
import { renderInviteEmail, renderResetPasswordEmail, renderVerifySignupEmail, } from "../server/email-templates.js";
|
|
11
|
+
import { defineTransactionalEmail } from "./registry.js";
|
|
12
|
+
/** Obviously-fake sample data — these render in a preview pane, never send. */
|
|
13
|
+
const SAMPLE_URL = "https://example.com/accept/sample-token";
|
|
14
|
+
const SAMPLE_EMAIL = "sam.rivera@example.com";
|
|
15
|
+
export const CORE_INVITE_EMAIL_ID = "core.organization-invite";
|
|
16
|
+
export const CORE_VERIFY_SIGNUP_EMAIL_ID = "core.verify-signup";
|
|
17
|
+
export const CORE_RESET_PASSWORD_EMAIL_ID = "core.reset-password";
|
|
18
|
+
let registered = false;
|
|
19
|
+
export function registerCoreSystemEmails() {
|
|
20
|
+
if (registered)
|
|
21
|
+
return;
|
|
22
|
+
registered = true;
|
|
23
|
+
defineTransactionalEmail({
|
|
24
|
+
id: CORE_INVITE_EMAIL_ID,
|
|
25
|
+
app: "core",
|
|
26
|
+
name: "Organization invitation",
|
|
27
|
+
trigger: "A member invites someone to their organization from the team settings page.",
|
|
28
|
+
recipientLabel: "Invited address",
|
|
29
|
+
recipient: "The address typed into the invite form. One email per invited address.",
|
|
30
|
+
senderLabel: "Default, app-branded",
|
|
31
|
+
sender: "The configured EMAIL_FROM. On first-party agent-native.com deployments the display name becomes the app's own, with reply-to agent-native@builder.io.",
|
|
32
|
+
preview: () => renderInviteEmail({
|
|
33
|
+
invitee: SAMPLE_EMAIL,
|
|
34
|
+
orgName: "Northwind Design",
|
|
35
|
+
acceptUrl: SAMPLE_URL,
|
|
36
|
+
inviter: "alex.chen@example.com",
|
|
37
|
+
}),
|
|
38
|
+
});
|
|
39
|
+
defineTransactionalEmail({
|
|
40
|
+
id: CORE_VERIFY_SIGNUP_EMAIL_ID,
|
|
41
|
+
app: "core",
|
|
42
|
+
name: "Verify signup",
|
|
43
|
+
trigger: "A new account is created with email and password, before the account can be used.",
|
|
44
|
+
recipientLabel: "New account address",
|
|
45
|
+
recipient: "The address the account was registered with.",
|
|
46
|
+
senderLabel: "Default, app-branded",
|
|
47
|
+
sender: "The configured EMAIL_FROM, branded with the app name the signup happened in.",
|
|
48
|
+
preview: () => renderVerifySignupEmail({
|
|
49
|
+
email: SAMPLE_EMAIL,
|
|
50
|
+
verifyUrl: SAMPLE_URL,
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
defineTransactionalEmail({
|
|
54
|
+
id: CORE_RESET_PASSWORD_EMAIL_ID,
|
|
55
|
+
app: "core",
|
|
56
|
+
name: "Reset password",
|
|
57
|
+
trigger: "A user requests a password reset from the sign-in screen. The link expires after one hour.",
|
|
58
|
+
recipientLabel: "Account address",
|
|
59
|
+
recipient: "The account address the reset was requested for, never an address supplied in the request body.",
|
|
60
|
+
senderLabel: "Default, app-branded",
|
|
61
|
+
sender: "The configured EMAIL_FROM, branded with the app name the reset was requested from.",
|
|
62
|
+
preview: () => renderResetPasswordEmail({
|
|
63
|
+
email: SAMPLE_EMAIL,
|
|
64
|
+
resetUrl: SAMPLE_URL,
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=system-emails.js.map
|
|
@@ -175,6 +175,7 @@ declare const messages: {
|
|
|
175
175
|
resources: string;
|
|
176
176
|
messaging: string;
|
|
177
177
|
destinations: string;
|
|
178
|
+
transactionalEmail: string;
|
|
178
179
|
identities: string;
|
|
179
180
|
approvals: string;
|
|
180
181
|
automations: string;
|
|
@@ -205,6 +206,50 @@ declare const messages: {
|
|
|
205
206
|
suggestionRouteSlack: string;
|
|
206
207
|
suggestionGrantKey: string;
|
|
207
208
|
};
|
|
209
|
+
transactionalEmail: {
|
|
210
|
+
title: string;
|
|
211
|
+
description: string;
|
|
212
|
+
retentionTitle: string;
|
|
213
|
+
retentionNote: string;
|
|
214
|
+
openRatesUnavailable: string;
|
|
215
|
+
sharedProviderMetricsUnavailable: string;
|
|
216
|
+
catalogFanoutFailed: string;
|
|
217
|
+
retry: string;
|
|
218
|
+
noApps: string;
|
|
219
|
+
catalogUnreadable: string;
|
|
220
|
+
countsUnreadable: string;
|
|
221
|
+
appSendsNoEmail: string;
|
|
222
|
+
emailNotFound: string;
|
|
223
|
+
emailNotFoundDescription: string;
|
|
224
|
+
sharedTitle: string;
|
|
225
|
+
sharedSubtitle: string;
|
|
226
|
+
email: string;
|
|
227
|
+
trigger: string;
|
|
228
|
+
sends: string;
|
|
229
|
+
openRate: string;
|
|
230
|
+
lastSent: string;
|
|
231
|
+
sendLogUnread: string;
|
|
232
|
+
failedCount: string;
|
|
233
|
+
failuresUnknown: string;
|
|
234
|
+
noProviderRecord: string;
|
|
235
|
+
noDeliveredMail: string;
|
|
236
|
+
neverSent: string;
|
|
237
|
+
lastSentUnknown: string;
|
|
238
|
+
preview: string;
|
|
239
|
+
previewDescription: string;
|
|
240
|
+
previewFailed: string;
|
|
241
|
+
previewFrameTitle: string;
|
|
242
|
+
subject: string;
|
|
243
|
+
activityLink: string;
|
|
244
|
+
activityTitle: string;
|
|
245
|
+
activityUnavailable: string;
|
|
246
|
+
activityEmpty: string;
|
|
247
|
+
recipient: string;
|
|
248
|
+
sender: string;
|
|
249
|
+
status: string;
|
|
250
|
+
opens: string;
|
|
251
|
+
lastEvent: string;
|
|
252
|
+
};
|
|
208
253
|
pages: {
|
|
209
254
|
appsDescription: string;
|
|
210
255
|
appsDescriptionWithWorkspace: string;
|
|
@@ -180,6 +180,7 @@ const messages = {
|
|
|
180
180
|
resources: "Resources",
|
|
181
181
|
messaging: "Messaging",
|
|
182
182
|
destinations: "Destinations",
|
|
183
|
+
transactionalEmail: "Transactional email",
|
|
183
184
|
identities: "Identities",
|
|
184
185
|
approvals: "Approvals",
|
|
185
186
|
automations: "Automations",
|
|
@@ -210,6 +211,50 @@ const messages = {
|
|
|
210
211
|
suggestionRouteSlack: "Route Slack mentions to my analytics app",
|
|
211
212
|
suggestionGrantKey: "Grant my OpenAI key to this app",
|
|
212
213
|
},
|
|
214
|
+
transactionalEmail: {
|
|
215
|
+
title: "Transactional email",
|
|
216
|
+
description: "Every transactional email each app in this workspace can send, with its trigger, recipients, and delivery metrics.",
|
|
217
|
+
retentionTitle: "Activity feed retention is short",
|
|
218
|
+
retentionNote: "The email provider's activity feed only retains recent messages, so an empty activity list does not mean nothing was sent.",
|
|
219
|
+
openRatesUnavailable: "Open rates unavailable",
|
|
220
|
+
sharedProviderMetricsUnavailable: "Provider metrics vary by sending app. Expand an app to see its provider data.",
|
|
221
|
+
catalogFanoutFailed: "Could not load app email catalogs",
|
|
222
|
+
retry: "Retry",
|
|
223
|
+
noApps: "No ready apps reported a transactional email catalog.",
|
|
224
|
+
catalogUnreadable: "This app's email catalog could not be read",
|
|
225
|
+
countsUnreadable: "Send counts could not be read",
|
|
226
|
+
appSendsNoEmail: "This app sends no transactional email of its own.",
|
|
227
|
+
emailNotFound: "Email not found",
|
|
228
|
+
emailNotFoundDescription: "This email is not in the app's catalog.",
|
|
229
|
+
sharedTitle: "Shared system email",
|
|
230
|
+
sharedSubtitle: "sent by every app",
|
|
231
|
+
email: "Email",
|
|
232
|
+
trigger: "Trigger",
|
|
233
|
+
sends: "Sends",
|
|
234
|
+
openRate: "Open rate",
|
|
235
|
+
lastSent: "Last sent",
|
|
236
|
+
sendLogUnread: "The send log could not be read, so the number of sends is unknown.",
|
|
237
|
+
failedCount: "{{count}} failed",
|
|
238
|
+
failuresUnknown: "failures unknown",
|
|
239
|
+
noProviderRecord: "The provider reported no record for this email in the window.",
|
|
240
|
+
noDeliveredMail: "No delivered mail yet",
|
|
241
|
+
neverSent: "Never sent",
|
|
242
|
+
lastSentUnknown: "The send log could not be read, so the last send time is unknown.",
|
|
243
|
+
preview: "Preview",
|
|
244
|
+
previewDescription: "Rendered with dummy data. Scripts are disabled in this preview.",
|
|
245
|
+
previewFailed: "Preview could not be rendered",
|
|
246
|
+
previewFrameTitle: "Preview of {{name}}",
|
|
247
|
+
subject: "Subject",
|
|
248
|
+
activityLink: "Activity log",
|
|
249
|
+
activityTitle: "Activity for {{name}}",
|
|
250
|
+
activityUnavailable: "Activity feed unavailable",
|
|
251
|
+
activityEmpty: "No recent activity in the provider's retention window.",
|
|
252
|
+
recipient: "Recipient",
|
|
253
|
+
sender: "Sender",
|
|
254
|
+
status: "Status",
|
|
255
|
+
opens: "Opens",
|
|
256
|
+
lastEvent: "Last event",
|
|
257
|
+
},
|
|
213
258
|
pages: {
|
|
214
259
|
appsDescription: "Open workspace apps and start new app creation from Dispatch.",
|
|
215
260
|
appsDescriptionWithWorkspace: 'Apps in the "{{workspace}}" workspace. Each app gets its own route under this workspace and shares its database, auth, and agent chat.',
|
|
@@ -11,24 +11,24 @@
|
|
|
11
11
|
* DELETE /_agent-native/notifications/:id — delete
|
|
12
12
|
*/
|
|
13
13
|
export declare function createNotificationsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<"" | import("./types.js").Notification[] | {
|
|
14
|
+
error?: undefined;
|
|
14
15
|
count: number;
|
|
15
16
|
updated?: undefined;
|
|
16
17
|
ok?: undefined;
|
|
17
|
-
error?: undefined;
|
|
18
18
|
} | {
|
|
19
|
-
updated: number;
|
|
20
|
-
ok?: undefined;
|
|
21
19
|
error?: undefined;
|
|
22
20
|
count?: undefined;
|
|
21
|
+
updated: number;
|
|
22
|
+
ok?: undefined;
|
|
23
23
|
} | {
|
|
24
|
+
count?: undefined;
|
|
24
25
|
updated?: undefined;
|
|
25
26
|
error: string;
|
|
26
27
|
ok?: undefined;
|
|
27
|
-
count?: undefined;
|
|
28
28
|
} | {
|
|
29
|
-
updated?: undefined;
|
|
30
|
-
ok: boolean;
|
|
31
29
|
error?: undefined;
|
|
32
30
|
count?: undefined;
|
|
31
|
+
updated?: undefined;
|
|
32
|
+
ok: boolean;
|
|
33
33
|
}>>;
|
|
34
34
|
//# sourceMappingURL=routes.d.ts.map
|
package/dist/org/handlers.js
CHANGED
|
@@ -28,6 +28,7 @@ function extractMemberEmail(event) {
|
|
|
28
28
|
const nanoid = () => globalThis.crypto?.randomUUID?.().replace(/-/g, "") ??
|
|
29
29
|
Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
30
30
|
import { getDbExec, isPostgres } from "../db/client.js";
|
|
31
|
+
import { CORE_INVITE_EMAIL_ID } from "../email-catalog/system-emails.js";
|
|
31
32
|
import { ssrfSafeFetch } from "../extensions/url-safety.js";
|
|
32
33
|
import { getAppProductionUrl } from "../server/app-url.js";
|
|
33
34
|
import { getSession } from "../server/auth.js";
|
|
@@ -275,7 +276,13 @@ async function inviteOne(ctx, rawEmail, role, event) {
|
|
|
275
276
|
acceptUrl: getInviteAppUrl(event),
|
|
276
277
|
inviter: ctx.email,
|
|
277
278
|
});
|
|
278
|
-
await sendEmail({
|
|
279
|
+
await sendEmail({
|
|
280
|
+
to: email,
|
|
281
|
+
subject,
|
|
282
|
+
html,
|
|
283
|
+
text,
|
|
284
|
+
templateId: CORE_INVITE_EMAIL_ID,
|
|
285
|
+
});
|
|
279
286
|
emailSent = true;
|
|
280
287
|
}
|
|
281
288
|
catch (err) {
|
|
@@ -76,9 +76,7 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
|
|
|
76
76
|
}>>;
|
|
77
77
|
}, z.core.$strip>>, {
|
|
78
78
|
id?: undefined;
|
|
79
|
-
provider?: undefined;
|
|
80
79
|
deleted?: undefined;
|
|
81
|
-
found?: undefined;
|
|
82
80
|
providers: {
|
|
83
81
|
id: string;
|
|
84
82
|
label: string;
|
|
@@ -89,6 +87,8 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
|
|
|
89
87
|
updatedAt: number;
|
|
90
88
|
}[];
|
|
91
89
|
count: number;
|
|
90
|
+
provider?: undefined;
|
|
91
|
+
found?: undefined;
|
|
92
92
|
registered?: undefined;
|
|
93
93
|
label?: undefined;
|
|
94
94
|
message?: undefined;
|
|
@@ -103,31 +103,31 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
|
|
|
103
103
|
label?: undefined;
|
|
104
104
|
message?: undefined;
|
|
105
105
|
} | {
|
|
106
|
-
provider?: undefined;
|
|
107
106
|
deleted?: undefined;
|
|
108
107
|
providers?: undefined;
|
|
109
108
|
count?: undefined;
|
|
109
|
+
provider?: undefined;
|
|
110
110
|
found: boolean;
|
|
111
111
|
id: string;
|
|
112
112
|
registered?: undefined;
|
|
113
113
|
label?: undefined;
|
|
114
114
|
message?: undefined;
|
|
115
115
|
} | {
|
|
116
|
-
provider?: undefined;
|
|
117
|
-
found?: undefined;
|
|
118
116
|
providers?: undefined;
|
|
119
117
|
count?: undefined;
|
|
118
|
+
provider?: undefined;
|
|
119
|
+
found?: undefined;
|
|
120
120
|
deleted: boolean;
|
|
121
121
|
id: string;
|
|
122
122
|
registered?: undefined;
|
|
123
123
|
label?: undefined;
|
|
124
124
|
message?: undefined;
|
|
125
125
|
} | {
|
|
126
|
-
provider?: undefined;
|
|
127
126
|
deleted?: undefined;
|
|
128
|
-
found?: undefined;
|
|
129
127
|
providers?: undefined;
|
|
130
128
|
count?: undefined;
|
|
129
|
+
provider?: undefined;
|
|
130
|
+
found?: undefined;
|
|
131
131
|
registered: boolean;
|
|
132
132
|
id: string;
|
|
133
133
|
label: string;
|
|
@@ -314,8 +314,6 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
|
|
|
314
314
|
id?: undefined;
|
|
315
315
|
provider?: undefined;
|
|
316
316
|
deleted?: undefined;
|
|
317
|
-
found?: undefined;
|
|
318
|
-
message?: undefined;
|
|
319
317
|
providers: {
|
|
320
318
|
id: string;
|
|
321
319
|
label: string;
|
|
@@ -326,44 +324,46 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
|
|
|
326
324
|
updatedAt: number;
|
|
327
325
|
}[];
|
|
328
326
|
count: number;
|
|
327
|
+
found?: undefined;
|
|
329
328
|
registered?: undefined;
|
|
330
329
|
label?: undefined;
|
|
330
|
+
message?: undefined;
|
|
331
331
|
} | {
|
|
332
332
|
id?: undefined;
|
|
333
333
|
count?: undefined;
|
|
334
334
|
deleted?: undefined;
|
|
335
|
-
message?: undefined;
|
|
336
335
|
providers?: undefined;
|
|
337
336
|
found: boolean;
|
|
338
337
|
provider: import("../custom-registry.js").CustomProviderConfig;
|
|
339
338
|
registered?: undefined;
|
|
340
339
|
label?: undefined;
|
|
340
|
+
message?: undefined;
|
|
341
341
|
} | {
|
|
342
342
|
count?: undefined;
|
|
343
343
|
provider?: undefined;
|
|
344
344
|
deleted?: undefined;
|
|
345
|
-
message?: undefined;
|
|
346
345
|
providers?: undefined;
|
|
347
346
|
found: boolean;
|
|
348
347
|
id: string;
|
|
349
348
|
registered?: undefined;
|
|
350
349
|
label?: undefined;
|
|
350
|
+
message?: undefined;
|
|
351
351
|
} | {
|
|
352
352
|
count?: undefined;
|
|
353
353
|
provider?: undefined;
|
|
354
|
-
found?: undefined;
|
|
355
|
-
message?: undefined;
|
|
356
354
|
providers?: undefined;
|
|
355
|
+
found?: undefined;
|
|
357
356
|
deleted: boolean;
|
|
358
357
|
id: string;
|
|
359
358
|
registered?: undefined;
|
|
360
359
|
label?: undefined;
|
|
360
|
+
message?: undefined;
|
|
361
361
|
} | {
|
|
362
362
|
count?: undefined;
|
|
363
363
|
provider?: undefined;
|
|
364
364
|
deleted?: undefined;
|
|
365
|
-
found?: undefined;
|
|
366
365
|
providers?: undefined;
|
|
366
|
+
found?: undefined;
|
|
367
367
|
registered: boolean;
|
|
368
368
|
id: string;
|
|
369
369
|
label: string;
|
|
@@ -73,7 +73,6 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
|
|
|
73
73
|
offset?: unknown;
|
|
74
74
|
limit?: unknown;
|
|
75
75
|
}, {
|
|
76
|
-
deleted?: undefined;
|
|
77
76
|
jobs: {
|
|
78
77
|
id: string;
|
|
79
78
|
name: string;
|
|
@@ -84,6 +83,7 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
|
|
|
84
83
|
updatedAt: string;
|
|
85
84
|
}[];
|
|
86
85
|
total: number;
|
|
86
|
+
deleted?: undefined;
|
|
87
87
|
jobId?: undefined;
|
|
88
88
|
} | {
|
|
89
89
|
jobs?: undefined;
|
|
@@ -91,9 +91,9 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
|
|
|
91
91
|
deleted: boolean;
|
|
92
92
|
jobId: string;
|
|
93
93
|
} | {
|
|
94
|
-
deleted?: undefined;
|
|
95
94
|
jobs?: undefined;
|
|
96
95
|
total?: undefined;
|
|
96
|
+
deleted?: undefined;
|
|
97
97
|
jobId?: undefined;
|
|
98
98
|
hits: Record<string, unknown>[];
|
|
99
99
|
offset: number;
|
|
@@ -48,8 +48,8 @@ export declare function handleUpdateResource(event: any): Promise<import("./stor
|
|
|
48
48
|
}>;
|
|
49
49
|
/** DELETE /_agent-native/resources/:id — delete a resource */
|
|
50
50
|
export declare function handleDeleteResource(event: any): Promise<{
|
|
51
|
-
error: string;
|
|
52
51
|
ok?: undefined;
|
|
52
|
+
error: string;
|
|
53
53
|
} | {
|
|
54
54
|
error?: undefined;
|
|
55
55
|
ok: boolean;
|
|
@@ -517,6 +517,28 @@ export async function mergeCoreSharingActions(registry) {
|
|
|
517
517
|
() => import("../sharing/actions/create-agent-resource-link.js"),
|
|
518
518
|
],
|
|
519
519
|
["upload-image", () => import("../file-upload/actions/upload-image.js")],
|
|
520
|
+
// Transactional email catalog — mounted everywhere so Dispatch can ask any
|
|
521
|
+
// app what it sends without that app opting in.
|
|
522
|
+
[
|
|
523
|
+
"list-transactional-emails",
|
|
524
|
+
() => import("../email-catalog/actions/list-transactional-emails.js"),
|
|
525
|
+
],
|
|
526
|
+
[
|
|
527
|
+
"render-transactional-email-preview",
|
|
528
|
+
() => import("../email-catalog/actions/render-transactional-email-preview.js"),
|
|
529
|
+
],
|
|
530
|
+
[
|
|
531
|
+
"list-email-log",
|
|
532
|
+
() => import("../email-catalog/actions/list-email-log.js"),
|
|
533
|
+
],
|
|
534
|
+
[
|
|
535
|
+
"list-email-activity",
|
|
536
|
+
() => import("../email-catalog/actions/list-email-activity.js"),
|
|
537
|
+
],
|
|
538
|
+
[
|
|
539
|
+
"list-email-engagement",
|
|
540
|
+
() => import("../email-catalog/actions/list-email-engagement.js"),
|
|
541
|
+
],
|
|
520
542
|
[
|
|
521
543
|
"get-feature-flags",
|
|
522
544
|
() => import("../feature-flags/actions/get-feature-flags.js"),
|
|
@@ -18,6 +18,7 @@ import { TEMPLATES } from "../cli/templates-meta.js";
|
|
|
18
18
|
import { getDbExec, isPostgres } from "../db/client.js";
|
|
19
19
|
import { getDialect, getDatabaseUrl, getDatabaseAuthToken, closePgliteClients, getPgliteClient, isPgliteUrl, loadPgliteDrizzle, pgPoolOptions, neonPoolMax, attachNeonPoolErrorLogger, sharedDbPool, onSharedDbPoolsClosed, onSharedDbPoolReplaced, } from "../db/client.js";
|
|
20
20
|
import { ensureTableExists } from "../db/ddl-guard.js";
|
|
21
|
+
import { CORE_RESET_PASSWORD_EMAIL_ID, CORE_VERIFY_SIGNUP_EMAIL_ID, } from "../email-catalog/system-emails.js";
|
|
21
22
|
import { saveOAuthTokens } from "../oauth-tokens/store.js";
|
|
22
23
|
import { acceptPendingInvitationsForEmail } from "../org/accept-pending.js";
|
|
23
24
|
import { getAuthEmailForUserId, getRequiredAuthProviderForEmail, } from "../org/auth-policy.js";
|
|
@@ -918,7 +919,14 @@ async function createBetterAuthInstance(config) {
|
|
|
918
919
|
email: user.email,
|
|
919
920
|
resetUrl,
|
|
920
921
|
});
|
|
921
|
-
await sendEmail({
|
|
922
|
+
await sendEmail({
|
|
923
|
+
to: user.email,
|
|
924
|
+
subject,
|
|
925
|
+
html,
|
|
926
|
+
text,
|
|
927
|
+
appSender,
|
|
928
|
+
templateId: CORE_RESET_PASSWORD_EMAIL_ID,
|
|
929
|
+
});
|
|
922
930
|
},
|
|
923
931
|
},
|
|
924
932
|
emailVerification: {
|
|
@@ -942,7 +950,14 @@ async function createBetterAuthInstance(config) {
|
|
|
942
950
|
email: user.email,
|
|
943
951
|
verifyUrl,
|
|
944
952
|
});
|
|
945
|
-
await sendEmail({
|
|
953
|
+
await sendEmail({
|
|
954
|
+
to: user.email,
|
|
955
|
+
subject,
|
|
956
|
+
html,
|
|
957
|
+
text,
|
|
958
|
+
appSender,
|
|
959
|
+
templateId: CORE_VERIFY_SIGNUP_EMAIL_ID,
|
|
960
|
+
});
|
|
946
961
|
},
|
|
947
962
|
},
|
|
948
963
|
socialProviders,
|
package/dist/server/email.d.ts
CHANGED
|
@@ -58,6 +58,15 @@ export interface SendEmailArgs {
|
|
|
58
58
|
references?: string;
|
|
59
59
|
attachments?: EmailAttachment[];
|
|
60
60
|
timeoutMs?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Registered transactional email id (see `defineTransactionalEmail`), e.g.
|
|
63
|
+
* `calendar.booking-confirmed`. Tags the message at the provider so delivery
|
|
64
|
+
* and open metrics attribute to one email instead of to the whole account,
|
|
65
|
+
* and keys the row written to `email_log`. Omit for genuinely one-off sends.
|
|
66
|
+
*/
|
|
67
|
+
templateId?: string;
|
|
68
|
+
/** App slug that owns the send. Defaults to the running app. */
|
|
69
|
+
app?: string;
|
|
61
70
|
}
|
|
62
71
|
export declare function isEmailConfigured(): Promise<boolean>;
|
|
63
72
|
/**
|
package/dist/server/email.js
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* so the reset-password flow still works end-to-end for local development.
|
|
11
11
|
*/
|
|
12
12
|
import { FAVICON_PNG_BASE64 } from "../assets/branding/favicon-base64.js";
|
|
13
|
+
import { recordEmailSend } from "../email-catalog/log.js";
|
|
14
|
+
import { getAppSlug } from "./app-name.js";
|
|
13
15
|
import { resolveSecret } from "./credential-provider.js";
|
|
14
16
|
import { AGENT_NATIVE_EMAIL_LOGO_CONTENT_ID } from "./email-template.js";
|
|
15
17
|
let cachedAgentNativeLogo;
|
|
@@ -154,7 +156,7 @@ function resolveAppSender(configuredFrom, appSender) {
|
|
|
154
156
|
replyTo: appSender.replyTo,
|
|
155
157
|
};
|
|
156
158
|
}
|
|
157
|
-
async function
|
|
159
|
+
async function deliverEmail(args, signal) {
|
|
158
160
|
const config = await resolveEmailTransport();
|
|
159
161
|
signal?.throwIfAborted();
|
|
160
162
|
const provider = config.provider;
|
|
@@ -206,7 +208,7 @@ async function sendEmailWithSignal(args, signal) {
|
|
|
206
208
|
const body = await res.text().catch(() => "");
|
|
207
209
|
throw new Error(`Resend error ${res.status}: ${body}`);
|
|
208
210
|
}
|
|
209
|
-
return;
|
|
211
|
+
return { provider, from };
|
|
210
212
|
}
|
|
211
213
|
if (provider === "sendgrid") {
|
|
212
214
|
const personalization = {
|
|
@@ -227,6 +229,12 @@ async function sendEmailWithSignal(args, signal) {
|
|
|
227
229
|
};
|
|
228
230
|
if (replyTo)
|
|
229
231
|
sgPayload.reply_to = parseSendGridFrom(replyTo);
|
|
232
|
+
// Categories are how per-email delivery/open stats are attributed. Without
|
|
233
|
+
// them every send lands in one undifferentiated account-wide bucket, which
|
|
234
|
+
// is indistinguishable from an email that never sent.
|
|
235
|
+
const categories = [args.templateId, args.app ?? getAppSlug()].filter((value) => Boolean(value));
|
|
236
|
+
if (categories.length)
|
|
237
|
+
sgPayload.categories = categories;
|
|
230
238
|
const sgHeaders = {};
|
|
231
239
|
if (args.inReplyTo)
|
|
232
240
|
sgHeaders["In-Reply-To"] = args.inReplyTo;
|
|
@@ -258,7 +266,7 @@ async function sendEmailWithSignal(args, signal) {
|
|
|
258
266
|
const body = await res.text().catch(() => "");
|
|
259
267
|
throw new Error(`SendGrid error ${res.status}: ${body}`);
|
|
260
268
|
}
|
|
261
|
-
return;
|
|
269
|
+
return { provider, from };
|
|
262
270
|
}
|
|
263
271
|
// Dev fallback — no provider configured. Logging the full body exposes
|
|
264
272
|
// reset tokens, so only do it outside production. In production, refuse
|
|
@@ -270,6 +278,39 @@ async function sendEmailWithSignal(args, signal) {
|
|
|
270
278
|
`Save RESEND_API_KEY or SENDGRID_API_KEY in settings to send real emails.\n` +
|
|
271
279
|
`---\nTo: ${args.to}\nFrom: ${from}\nSubject: ${args.subject}\n\n` +
|
|
272
280
|
`${args.text || stripHtml(args.html)}\n---\n`);
|
|
281
|
+
return { provider, from };
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Deliver, then record the attempt. Recording lives here rather than in each
|
|
285
|
+
* provider branch so a new transport cannot be added without being logged.
|
|
286
|
+
*/
|
|
287
|
+
async function sendEmailWithSignal(args, signal) {
|
|
288
|
+
let outcome;
|
|
289
|
+
try {
|
|
290
|
+
outcome = await deliverEmail(args, signal);
|
|
291
|
+
}
|
|
292
|
+
catch (error) {
|
|
293
|
+
await recordEmailSend({
|
|
294
|
+
templateId: args.templateId,
|
|
295
|
+
app: args.app ?? getAppSlug() ?? "unknown",
|
|
296
|
+
recipient: args.to,
|
|
297
|
+
sender: outcome?.from ?? args.from ?? "unknown",
|
|
298
|
+
subject: args.subject,
|
|
299
|
+
status: "failed",
|
|
300
|
+
error: error instanceof Error ? error.message : String(error),
|
|
301
|
+
provider: outcome?.provider ?? "unknown",
|
|
302
|
+
});
|
|
303
|
+
throw error;
|
|
304
|
+
}
|
|
305
|
+
await recordEmailSend({
|
|
306
|
+
templateId: args.templateId,
|
|
307
|
+
app: args.app ?? getAppSlug() ?? "unknown",
|
|
308
|
+
recipient: args.to,
|
|
309
|
+
sender: outcome.from,
|
|
310
|
+
subject: args.subject,
|
|
311
|
+
status: "sent",
|
|
312
|
+
provider: outcome.provider,
|
|
313
|
+
});
|
|
273
314
|
}
|
|
274
315
|
export async function sendEmail(args) {
|
|
275
316
|
const requestedTimeoutMs = Number(args.timeoutMs);
|
package/dist/server/index.d.ts
CHANGED
|
@@ -66,6 +66,7 @@ export { builderDesignSystemUrl, builderProjectBranchUrl, buildBuilderDesignSyst
|
|
|
66
66
|
export { getBuilderBranchProjectId, isBuilderBranchingEnabled, requestBuilderBrowserConnection, resolveBuilderBranchProjectId, resolveIsBuilderBranchingEnabled, runBuilderAgent, type RunBuilderAgentResult, } from "./builder-browser.js";
|
|
67
67
|
export { ensureFusionContainer, sendFusionBranchMessage, pushFusionBranch, reserveFusionHostingSlug, deployFusionProject, getFusionDeploys, getFusionBranchEditorUrl, getFusionHostingUrl, type FusionBranchRef, type EnsureFusionContainerResult, type SendFusionMessageResult, } from "./fusion-app.js";
|
|
68
68
|
export { sendEmail, isEmailConfigured, getEmailProvider, type EmailAttachment, type EmailProvider, type SendEmailArgs, } from "./email.js";
|
|
69
|
+
export { defineTransactionalEmail, listTransactionalEmails, getTransactionalEmail, renderTransactionalEmailPreview, type TransactionalEmailDefinition, type RegisteredTransactionalEmail, } from "../email-catalog/registry.js";
|
|
69
70
|
export { notifyActivity, runActivityNotification, resolveActivityRecipients, type ActivityDeliveryFailure, type ActivityNotificationResult, type ActivityNotificationStatus, type NotifyActivityInput, type ResolveActivityRecipientsInput, } from "./activity-notifications.js";
|
|
70
71
|
export { renderEmail, emailStrong, emailLink, type RenderEmailArgs, type RenderedEmail, type EmailCta, } from "./email-template.js";
|
|
71
72
|
export { getAppProductionUrl, getFirstPartyProdUrl } from "./app-url.js";
|
package/dist/server/index.js
CHANGED
|
@@ -67,6 +67,7 @@ export { builderDesignSystemUrl, builderProjectBranchUrl, buildBuilderDesignSyst
|
|
|
67
67
|
export { getBuilderBranchProjectId, isBuilderBranchingEnabled, requestBuilderBrowserConnection, resolveBuilderBranchProjectId, resolveIsBuilderBranchingEnabled, runBuilderAgent, } from "./builder-browser.js";
|
|
68
68
|
export { ensureFusionContainer, sendFusionBranchMessage, pushFusionBranch, reserveFusionHostingSlug, deployFusionProject, getFusionDeploys, getFusionBranchEditorUrl, getFusionHostingUrl, } from "./fusion-app.js";
|
|
69
69
|
export { sendEmail, isEmailConfigured, getEmailProvider, } from "./email.js";
|
|
70
|
+
export { defineTransactionalEmail, listTransactionalEmails, getTransactionalEmail, renderTransactionalEmailPreview, } from "../email-catalog/registry.js";
|
|
70
71
|
export { notifyActivity, runActivityNotification, resolveActivityRecipients, } from "./activity-notifications.js";
|
|
71
72
|
export { renderEmail, emailStrong, emailLink, } from "./email-template.js";
|
|
72
73
|
export { getAppProductionUrl, getFirstPartyProdUrl } from "./app-url.js";
|