@open-pencil/cloud 0.17.0-beta.2 → 0.17.0-beta.5
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 +3 -2
- package/dist/bin/server.mjs +1 -1
- package/dist/bin/server.mjs.map +1 -1
- package/dist/bin/{ai-relay.mjs → services.mjs} +9 -9
- package/dist/bin/services.mjs.map +1 -0
- package/dist/client.d.ts +525 -66
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1257 -654
- package/dist/client.js.map +1 -1
- package/dist/contract.d.ts +2 -2
- package/dist/contract.js +2 -2
- package/dist/contract2.js +1028 -481
- package/dist/contract2.js.map +1 -1
- package/dist/email.d.ts +1780 -31
- package/dist/email.d.ts.map +1 -1
- package/dist/email.js +3556 -325
- package/dist/email.js.map +1 -1
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +48 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +929 -72
- package/dist/index.d.ts.map +1 -1
- package/dist/index2.d.ts +35 -0
- package/dist/index2.d.ts.map +1 -0
- package/dist/listen.mjs +802 -927
- package/dist/listen.mjs.map +1 -1
- package/dist/runtime-cloudflare.d.ts +89 -0
- package/dist/runtime-cloudflare.d.ts.map +1 -0
- package/dist/runtime-cloudflare.js +15667 -0
- package/dist/runtime-cloudflare.js.map +1 -0
- package/dist/runtime-node.d.mts +7166 -3101
- package/dist/runtime-node.d.mts.map +1 -1
- package/dist/runtime-node.mjs +6 -5
- package/dist/runtime-node.mjs.map +1 -1
- package/dist/server.d.ts +6525 -2205
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +12500 -7613
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +8625 -2878
- package/dist/server.mjs.map +1 -1
- package/dist/server2.mjs +101 -79
- package/dist/server2.mjs.map +1 -1
- package/package.json +27 -9
- package/src/admin/api/routes.ts +59 -0
- package/src/admin/audit/service.ts +27 -8
- package/src/admin/documents/service.ts +431 -0
- package/src/admin/errors.ts +9 -1
- package/src/admin/index.ts +6 -0
- package/src/admin/operations/service.ts +7 -0
- package/src/admin/reports/service.ts +153 -0
- package/src/admin/schema.ts +6 -0
- package/src/client/api.ts +28 -461
- package/src/client/auth/client.ts +22 -3
- package/src/client/auth/navigation.ts +6 -5
- package/src/client/billing.ts +80 -0
- package/src/client/community.ts +40 -0
- package/src/client/discovery.ts +35 -9
- package/src/client/documents.ts +160 -0
- package/src/client/index.ts +14 -7
- package/src/client/portal/account.ts +79 -2
- package/src/client/portal/administration.ts +56 -0
- package/src/client/portal/request.ts +2 -0
- package/src/client/response.ts +21 -0
- package/src/client/schema.ts +8 -0
- package/src/client/services.ts +118 -0
- package/src/client/sharing.ts +262 -0
- package/src/client/versions.ts +104 -0
- package/src/contract/account.ts +108 -2
- package/src/contract/admin/index.ts +67 -3
- package/src/contract/billing.ts +166 -0
- package/src/contract/collaboration.ts +11 -1
- package/src/contract/community.ts +60 -0
- package/src/contract/discovery.ts +83 -4
- package/src/contract/documents.ts +27 -0
- package/src/contract/entitlements.ts +12 -2
- package/src/contract/index.ts +114 -39
- package/src/contract/links.ts +57 -4
- package/src/contract/locale.ts +27 -0
- package/src/contract/portal.ts +12 -1
- package/src/contract/relay.ts +6 -0
- package/src/contract/reports.ts +42 -0
- package/src/contract/routes.ts +10 -0
- package/src/contract/services.ts +235 -0
- package/src/contract/sharing.ts +3 -9
- package/src/email/i18n.ts +174 -0
- package/src/email/index.ts +13 -2
- package/src/email/locales/ar.json +141 -0
- package/src/email/locales/de.json +141 -0
- package/src/email/locales/es.json +141 -0
- package/src/email/locales/fr.json +141 -0
- package/src/email/locales/it.json +141 -0
- package/src/email/locales/ja.json +141 -0
- package/src/email/locales/pl.json +141 -0
- package/src/email/locales/pt-br.json +141 -0
- package/src/email/locales/ru.json +141 -0
- package/src/email/locales/zh-cn.json +141 -0
- package/src/email/messages.ts +200 -0
- package/src/email/render.ts +138 -246
- package/src/email/samples.ts +115 -0
- package/src/email/schema.ts +79 -5
- package/src/email/templates/BrandEmail.vue +54 -0
- package/src/email/templates/DocumentBlocked.vue +45 -0
- package/src/email/templates/DocumentInvitation.vue +24 -0
- package/src/email/templates/DocumentReport.vue +32 -0
- package/src/email/templates/DocumentReportDecided.vue +36 -0
- package/src/email/templates/DocumentReportReceived.vue +18 -0
- package/src/email/templates/DocumentRestored.vue +24 -0
- package/src/email/templates/EmailChangeRequested.vue +24 -0
- package/src/email/templates/EmailRoot.vue +19 -0
- package/src/email/templates/EmailText.vue +9 -0
- package/src/email/templates/EmailVerification.vue +38 -0
- package/src/email/templates/EnrollmentNotification.vue +24 -0
- package/src/email/templates/EnrollmentUpdate.vue +52 -0
- package/src/email/templates/NewSignIn.vue +37 -0
- package/src/email/templates/PasswordChanged.vue +22 -0
- package/src/email/templates/PasswordReset.vue +23 -0
- package/src/email/templates/StorageLimitReached.vue +28 -0
- package/src/email/templates/TwoStepChanged.vue +32 -0
- package/src/email/templates/WaitlistConfirmation.vue +29 -0
- package/src/email/templates/WorkspaceInvitation.vue +28 -0
- package/src/email/templates/brand.ts +9 -61
- package/src/email/templates/localization.ts +17 -0
- package/src/errors/index.ts +6 -0
- package/src/errors/posthog.ts +80 -0
- package/src/global.d.ts +7 -0
- package/src/runtime/cloudflare/environment.ts +22 -11
- package/src/runtime/cloudflare/index.ts +1 -1
- package/src/runtime/cloudflare/logging.ts +15 -0
- package/src/runtime/cloudflare/maintenance.ts +31 -0
- package/src/runtime/cloudflare/relay/index.ts +69 -15
- package/src/runtime/cloudflare/tsconfig.json +2 -1
- package/src/runtime/cloudflare/worker.ts +46 -13
- package/src/runtime/node/application.ts +5 -3
- package/src/runtime/node/bootstrap.ts +15 -4
- package/src/runtime/node/cleanup.ts +20 -3
- package/src/runtime/node/email/transport.ts +13 -10
- package/src/runtime/node/entitlements/main.ts +14 -11
- package/src/runtime/node/index.ts +1 -1
- package/src/runtime/node/main.ts +1 -1
- package/src/runtime/node/migrate.ts +5 -1
- package/src/runtime/node/relay.ts +8 -2
- package/src/runtime/node/request-id.ts +13 -0
- package/src/runtime/node/server.ts +50 -16
- package/src/runtime/node/{ai-relay → services}/main.ts +7 -7
- package/src/runtime/node/{ai-relay → services}/server.ts +18 -18
- package/src/runtime/postgres/database.ts +20 -1
- package/src/runtime/posthog/errors.ts +15 -30
- package/src/runtime/s3/objects.ts +41 -1
- package/src/runtime/site/community.ts +101 -0
- package/src/runtime/site/server.ts +49 -6
- package/src/server/account/actions.ts +5 -0
- package/src/server/account/deletion.ts +304 -0
- package/src/server/account/routes.ts +281 -206
- package/src/server/account/terms.ts +42 -0
- package/src/server/account/tokens.ts +57 -0
- package/src/server/api/router.ts +32 -5
- package/src/server/api/types.ts +2 -0
- package/src/server/app/checks.ts +84 -0
- package/src/server/app/editors.ts +20 -0
- package/src/server/app/index.ts +128 -0
- package/src/server/app/indexing.ts +40 -0
- package/src/server/app/limiters.ts +53 -0
- package/src/server/app/routes.ts +114 -0
- package/src/server/app/services.ts +185 -0
- package/src/server/auth/access-control.ts +63 -0
- package/src/server/auth/access-tokens.ts +62 -0
- package/src/server/auth/adapter.ts +32 -1
- package/src/server/auth/email.ts +4 -1
- package/src/server/auth/endpoints.ts +5 -1
- package/src/server/auth/enrollment.ts +116 -0
- package/src/server/auth/factory.ts +116 -132
- package/src/server/auth/index.ts +10 -1
- package/src/server/auth/logger.ts +23 -0
- package/src/server/auth/mfa-assurance.ts +51 -0
- package/src/server/auth/passwords.ts +43 -0
- package/src/server/auth/session.ts +2 -0
- package/src/server/billing/index.ts +6 -0
- package/src/server/billing/routes.ts +27 -0
- package/src/server/billing/tokens.ts +37 -0
- package/src/server/cleanup/configured.ts +27 -7
- package/src/server/cleanup/documents.ts +165 -71
- package/src/server/cleanup/revisions.ts +16 -5
- package/src/server/cleanup/uploads.ts +8 -2
- package/src/server/cleanup/worker.ts +15 -3
- package/src/server/collaboration/relay/connection.ts +4 -3
- package/src/server/collaboration/relay/documents.ts +13 -10
- package/src/server/collaboration/relay/hub.ts +77 -122
- package/src/server/collaboration/relay/log.ts +5 -2
- package/src/server/collaboration/relay/room.ts +154 -0
- package/src/server/collaboration/service.ts +48 -33
- package/src/server/community/index.ts +2 -0
- package/src/server/community/routes.ts +93 -0
- package/src/server/community/service.ts +134 -0
- package/src/server/config/deployment.ts +41 -9
- package/src/server/config/index.ts +1 -1
- package/src/server/config/public.ts +11 -4
- package/src/server/config/schema.ts +91 -277
- package/src/server/config/toml/schema.ts +307 -0
- package/src/server/db/expressions.ts +15 -1
- package/src/server/db/index.ts +1 -0
- package/src/server/db/migrate.ts +46 -116
- package/src/server/db/migrations/001_accounts.ts +79 -0
- package/src/server/db/migrations/002_workspaces.ts +48 -0
- package/src/server/db/migrations/003_storage.ts +44 -0
- package/src/server/db/migrations/004_documents.ts +193 -0
- package/src/server/db/migrations/005_sharing.ts +95 -0
- package/src/server/db/migrations/006_operations.ts +110 -0
- package/src/server/db/migrations/007_trash.ts +33 -0
- package/src/server/db/migrations/008_terms.ts +18 -0
- package/src/server/db/migrations/009_access_tokens.ts +47 -0
- package/src/server/db/migrations/010_storage_limit_notices.ts +50 -0
- package/src/server/db/migrations/011_account_ids.ts +30 -0
- package/src/server/db/migrations/012_email_locales.ts +34 -0
- package/src/server/db/migrations/013_document_block_emails.ts +40 -0
- package/src/server/db/migrations/014_report_replies.ts +28 -0
- package/src/server/db/migrations/schema.ts +96 -0
- package/src/server/db/tables.ts +82 -4
- package/src/server/db/users.ts +22 -0
- package/src/server/documents/access.ts +66 -55
- package/src/server/documents/errors.ts +7 -0
- package/src/server/documents/images.ts +2 -1
- package/src/server/documents/index.ts +1 -1
- package/src/server/documents/limits.ts +14 -8
- package/src/server/documents/purge.ts +75 -0
- package/src/server/documents/repository.ts +2 -0
- package/src/server/documents/routes.ts +26 -0
- package/src/server/documents/service.ts +30 -406
- package/src/server/documents/summary.ts +1 -0
- package/src/server/documents/trash.ts +203 -0
- package/src/server/documents/uploads.ts +450 -0
- package/src/server/documents/versions/checkpoint.ts +2 -1
- package/src/server/documents/versions/history.ts +11 -7
- package/src/server/documents/versions/service.ts +94 -28
- package/src/server/email/invitations.ts +1 -0
- package/src/server/email/service.ts +31 -4
- package/src/server/email/types.ts +12 -0
- package/src/server/errors/index.ts +51 -16
- package/src/server/index.ts +52 -16
- package/src/server/internal/index.ts +3 -3
- package/src/server/internal/routes.ts +7 -10
- package/src/server/internal/schema.ts +1 -1
- package/src/server/internal/service.ts +17 -23
- package/src/server/invitations/budget.ts +66 -0
- package/src/server/invitations/index.ts +1 -0
- package/src/server/invitations/types.ts +5 -1
- package/src/server/logging.ts +76 -0
- package/src/server/objects/types.ts +5 -0
- package/src/server/pictures/service.ts +2 -1
- package/src/server/policy/configured.ts +9 -3
- package/src/server/policy/database.ts +52 -27
- package/src/server/policy/index.ts +2 -1
- package/src/server/policy/keys.ts +5 -2
- package/src/server/policy/policy.ts +40 -12
- package/src/server/policy/schema.ts +2 -2
- package/src/server/policy/service.ts +78 -56
- package/src/server/policy/static.ts +5 -5
- package/src/server/policy/storage.ts +33 -0
- package/src/server/policy/workspace.ts +41 -0
- package/src/server/quota/index.ts +6 -0
- package/src/server/quota/notices.ts +121 -0
- package/src/server/quota/reconcile.ts +2 -0
- package/src/server/quota/storage.ts +74 -31
- package/src/server/rate-limit/cleanup.ts +17 -5
- package/src/server/rate-limit/middleware.ts +6 -2
- package/src/server/reports/index.ts +9 -0
- package/src/server/reports/replies.ts +55 -0
- package/src/server/reports/routes.ts +39 -0
- package/src/server/reports/service.ts +145 -0
- package/src/server/services/errors.ts +7 -0
- package/src/server/services/index.ts +8 -0
- package/src/server/{ai → services}/keys.ts +11 -11
- package/src/server/services/routes.ts +47 -0
- package/src/server/{ai/service.ts → services/tokens.ts} +23 -20
- package/src/server/sharing/capabilities/service.ts +68 -23
- package/src/server/sharing/grants/service.ts +11 -18
- package/src/server/sharing/http.ts +4 -0
- package/src/server/sharing/invitations/service.ts +35 -15
- package/src/server/sharing/policy.ts +9 -14
- package/src/server/sharing/routes.ts +0 -16
- package/src/server/sharing/service.ts +1 -17
- package/src/server/validation.ts +4 -0
- package/src/server/workspaces/index.ts +1 -0
- package/src/server/workspaces/members.ts +91 -52
- package/src/server/workspaces/repository.ts +2 -1
- package/src/server/workspaces/routes.ts +4 -0
- package/src/{ai-relay → services}/app.ts +46 -44
- package/src/{ai-relay → services}/config.ts +26 -19
- package/src/services/db/index.ts +10 -0
- package/src/services/db/migrate.ts +37 -0
- package/src/{ai-relay/db/migrations/001_usage.ts → services/db/migrations/001_baseline.ts} +18 -7
- package/src/services/db/schema.ts +22 -0
- package/src/services/index.ts +18 -0
- package/src/{ai-relay → services}/metering.ts +2 -2
- package/src/{ai-relay → services}/usage.ts +35 -19
- package/dist/bin/ai-relay.mjs.map +0 -1
- package/src/ai-relay/db/index.ts +0 -10
- package/src/ai-relay/db/migrate.ts +0 -32
- package/src/ai-relay/db/schema.ts +0 -20
- package/src/ai-relay/index.ts +0 -18
- package/src/client/ai.ts +0 -96
- package/src/contract/ai.ts +0 -150
- package/src/email/templates/document-invitation.ts +0 -35
- package/src/email/templates/enrollment.ts +0 -27
- package/src/email/templates/layout.ts +0 -18
- package/src/server/ai/errors.ts +0 -7
- package/src/server/ai/index.ts +0 -4
- package/src/server/ai/routes.ts +0 -43
- package/src/server/app.ts +0 -379
- package/src/server/auth/workspace-access.ts +0 -23
- package/src/server/db/migrations/001_foundation.ts +0 -164
- package/src/server/db/migrations/002_upload_cleanup_claims.ts +0 -34
- package/src/server/db/migrations/003_document_cleanup_claims.ts +0 -23
- package/src/server/db/migrations/004_document_sharing.ts +0 -82
- package/src/server/db/migrations/005_document_collaboration_epoch.ts +0 -13
- package/src/server/db/migrations/006_invitation_continuation.ts +0 -27
- package/src/server/db/migrations/007_collaboration_state.ts +0 -25
- package/src/server/db/migrations/008_storage_reservations.ts +0 -37
- package/src/server/db/migrations/009_workspace_entitlements.ts +0 -22
- package/src/server/db/migrations/010_upload_finalization.ts +0 -22
- package/src/server/db/migrations/011_upload_finalization_lease.ts +0 -12
- package/src/server/db/migrations/012_transactional_email.ts +0 -48
- package/src/server/db/migrations/013_admin_enrollment.ts +0 -54
- package/src/server/db/migrations/014_enrollment_email_kinds.ts +0 -30
- package/src/server/db/migrations/015_cloud_rate_limit.ts +0 -22
- package/src/server/db/migrations/016_auth_schema.ts +0 -16
- package/src/server/db/migrations/017_authentication_email_kinds.ts +0 -32
- package/src/server/db/migrations/018_authentication_mfa.ts +0 -78
- package/src/server/db/migrations/019_better_auth_account_issuer.ts +0 -42
- package/src/server/db/migrations/020_workspace_invitations.ts +0 -57
- package/src/server/db/migrations/021_document_versions.ts +0 -66
- package/src/server/db/migrations/022_entitlement_external_version.ts +0 -17
- package/src/server/db/migrations/023_document_images.ts +0 -61
- package/src/server/db/migrations/024_account_activity.ts +0 -66
- package/src/server/db/migrations/025_table_names.ts +0 -58
- package/src/server/db/migrations/026_user_picture.ts +0 -30
- package/src/server/db/migrations/027_document_kind.ts +0 -19
- package/src/server/db/migrations/028_collaboration_updates.ts +0 -84
- package/src/server/db/migrations/helpers.ts +0 -78
- /package/dist/bin/{ai-relay.d.mts → services.d.mts} +0 -0
package/src/email/render.ts
CHANGED
|
@@ -1,276 +1,168 @@
|
|
|
1
1
|
import { render } from '@vue-email/render'
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import type { Component } from 'vue'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
emailLocalization,
|
|
6
|
+
type EmailLocale,
|
|
7
|
+
type EmailLocalization,
|
|
8
|
+
type EmailMessages
|
|
9
|
+
} from './i18n'
|
|
4
10
|
import type {
|
|
5
|
-
AdminEnrollmentNotificationPayload,
|
|
6
|
-
AuthenticationEmailPayload,
|
|
7
11
|
DocumentInvitationEmailPayload,
|
|
8
|
-
EmailChangeRequestedPayload,
|
|
9
|
-
EnrollmentEmailPayload,
|
|
10
|
-
NewSignInPayload,
|
|
11
12
|
RenderedTransactionalEmail,
|
|
12
13
|
TransactionalEmailContent,
|
|
13
14
|
TransactionalEmailKind,
|
|
14
|
-
|
|
15
|
-
TwoStepChangedPayload,
|
|
16
|
-
WorkspaceInvitationEmailPayload
|
|
15
|
+
TransactionalEmailPayloadByKind
|
|
17
16
|
} from './schema'
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
import DocumentBlocked from './templates/DocumentBlocked.vue'
|
|
18
|
+
import DocumentInvitation from './templates/DocumentInvitation.vue'
|
|
19
|
+
import DocumentReport from './templates/DocumentReport.vue'
|
|
20
|
+
import DocumentReportDecided from './templates/DocumentReportDecided.vue'
|
|
21
|
+
import DocumentReportReceived from './templates/DocumentReportReceived.vue'
|
|
22
|
+
import DocumentRestored from './templates/DocumentRestored.vue'
|
|
23
|
+
import EmailChangeRequested from './templates/EmailChangeRequested.vue'
|
|
24
|
+
import EmailRoot from './templates/EmailRoot.vue'
|
|
25
|
+
import EmailVerification from './templates/EmailVerification.vue'
|
|
26
|
+
import EnrollmentNotification from './templates/EnrollmentNotification.vue'
|
|
27
|
+
import EnrollmentUpdate from './templates/EnrollmentUpdate.vue'
|
|
28
|
+
import NewSignIn from './templates/NewSignIn.vue'
|
|
29
|
+
import PasswordChanged from './templates/PasswordChanged.vue'
|
|
30
|
+
import PasswordReset from './templates/PasswordReset.vue'
|
|
31
|
+
import StorageLimitReached from './templates/StorageLimitReached.vue'
|
|
32
|
+
import TwoStepChanged from './templates/TwoStepChanged.vue'
|
|
33
|
+
import WaitlistConfirmation from './templates/WaitlistConfirmation.vue'
|
|
34
|
+
import WorkspaceInvitation from './templates/WorkspaceInvitation.vue'
|
|
35
|
+
|
|
36
|
+
/** One kind of email: the component that draws it from its payload, and its subject line. */
|
|
37
|
+
type EmailDefinition<Payload> = {
|
|
38
|
+
component: Component
|
|
39
|
+
/** What the component takes besides `payload`. */
|
|
40
|
+
props?: Record<string, unknown>
|
|
41
|
+
subject: (payload: Payload, t: EmailMessages) => string
|
|
31
42
|
}
|
|
32
43
|
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
inviterName: payload.inviterName,
|
|
39
|
-
documentName: payload.documentName,
|
|
40
|
-
permissionLabel,
|
|
41
|
-
expiresAt: new Date(payload.expiresAt).toUTCString(),
|
|
42
|
-
acceptanceURL: payload.acceptanceURL
|
|
43
|
-
},
|
|
44
|
-
`${payload.inviterName} invited you to ${permissionLabel} ${payload.documentName}`
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const WORKSPACE_ROLE_LABELS = { admin: 'manage', editor: 'edit in', viewer: 'view' } as const
|
|
49
|
-
|
|
50
|
-
async function renderWorkspaceInvitation(payload: WorkspaceInvitationEmailPayload) {
|
|
51
|
-
const action = WORKSPACE_ROLE_LABELS[payload.role]
|
|
52
|
-
return rendered(
|
|
53
|
-
EnrollmentEmail,
|
|
54
|
-
{
|
|
55
|
-
heading: `Join ${payload.workspaceName}`,
|
|
56
|
-
preview: `${payload.inviterName} invited you to ${payload.workspaceName}`,
|
|
57
|
-
message: `${payload.inviterName} invited you to ${action} the workspace “${payload.workspaceName}” on OpenPencil Cloud. You will see its documents on Home once you join.`,
|
|
58
|
-
actionLabel: 'Join workspace',
|
|
59
|
-
actionURL: payload.acceptanceURL,
|
|
60
|
-
footer: `This invitation expires ${new Date(payload.expiresAt).toUTCString()}.`
|
|
61
|
-
},
|
|
62
|
-
`${payload.inviterName} invited you to ${payload.workspaceName}`
|
|
63
|
-
)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
type EnrollmentMessageKind = Exclude<
|
|
67
|
-
TransactionalEmailKind,
|
|
68
|
-
| 'document-invitation'
|
|
69
|
-
| 'workspace-invitation'
|
|
70
|
-
| 'admin-enrollment-notification'
|
|
71
|
-
| 'email-verification'
|
|
72
|
-
| 'password-reset'
|
|
73
|
-
| 'password-changed'
|
|
74
|
-
| 'email-change-requested'
|
|
75
|
-
| 'new-sign-in'
|
|
76
|
-
| 'two-step-changed'
|
|
77
|
-
>
|
|
78
|
-
|
|
79
|
-
type EnrollmentCopy = {
|
|
80
|
-
subject: string
|
|
81
|
-
heading: string
|
|
82
|
-
preview: string
|
|
83
|
-
message: string
|
|
84
|
-
actionLabel: string
|
|
44
|
+
function documentInvitationSubject(payload: DocumentInvitationEmailPayload, t: EmailMessages) {
|
|
45
|
+
const names = { inviter: payload.inviterName ?? t.someone, document: payload.documentName }
|
|
46
|
+
return payload.permission === 'edit'
|
|
47
|
+
? t.documentInvitationEditSubject(names)
|
|
48
|
+
: t.documentInvitationViewSubject(names)
|
|
85
49
|
}
|
|
86
50
|
|
|
87
|
-
const
|
|
51
|
+
const EMAILS: {
|
|
52
|
+
[Kind in TransactionalEmailKind]: EmailDefinition<TransactionalEmailPayloadByKind[Kind]>
|
|
53
|
+
} = {
|
|
54
|
+
'document-invitation': { component: DocumentInvitation, subject: documentInvitationSubject },
|
|
55
|
+
'workspace-invitation': {
|
|
56
|
+
component: WorkspaceInvitation,
|
|
57
|
+
subject: (payload, t) =>
|
|
58
|
+
t.workspaceInvitationSubject({
|
|
59
|
+
inviter: payload.inviterName ?? t.someone,
|
|
60
|
+
workspace: payload.workspaceName
|
|
61
|
+
})
|
|
62
|
+
},
|
|
88
63
|
'enrollment-requested': {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
actionLabel: 'Open OpenPencil Cloud'
|
|
64
|
+
component: EnrollmentUpdate,
|
|
65
|
+
props: { kind: 'requested' },
|
|
66
|
+
subject: (_payload, t) => t.enrollmentRequestedSubject
|
|
93
67
|
},
|
|
94
68
|
'enrollment-approved': {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
actionLabel: 'Sign in'
|
|
69
|
+
component: EnrollmentUpdate,
|
|
70
|
+
props: { kind: 'approved' },
|
|
71
|
+
subject: (_payload, t) => t.enrollmentApprovedSubject
|
|
99
72
|
},
|
|
100
73
|
'enrollment-rejected': {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
actionLabel: 'Request access again'
|
|
74
|
+
component: EnrollmentUpdate,
|
|
75
|
+
props: { kind: 'rejected' },
|
|
76
|
+
subject: (_payload, t) => t.enrollmentRejectedSubject
|
|
105
77
|
},
|
|
106
78
|
'enrollment-revoked': {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
actionURL: payload.actionURL
|
|
139
|
-
},
|
|
140
|
-
'New OpenPencil Cloud access request'
|
|
141
|
-
)
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
async function renderAuthentication(
|
|
145
|
-
kind: 'email-verification' | 'password-reset' | 'password-changed',
|
|
146
|
-
payload: AuthenticationEmailPayload
|
|
147
|
-
) {
|
|
148
|
-
const copy = {
|
|
149
|
-
'email-verification':
|
|
150
|
-
payload.purpose === 'change'
|
|
151
|
-
? {
|
|
152
|
-
subject: 'Confirm your new OpenPencil Cloud email',
|
|
153
|
-
heading: 'Confirm your new email',
|
|
154
|
-
preview: 'One click to move your OpenPencil Cloud account to this address.',
|
|
155
|
-
message: `Hi ${payload.name}, confirm this address to make it your OpenPencil Cloud account’s email. Your old address stays until you do.`,
|
|
156
|
-
actionLabel: 'Confirm email',
|
|
157
|
-
footer: 'Didn’t ask for this? Ignore this email and nothing changes.'
|
|
158
|
-
}
|
|
159
|
-
: {
|
|
160
|
-
subject: 'Confirm your OpenPencil Cloud email',
|
|
161
|
-
heading: 'Confirm your email',
|
|
162
|
-
preview: 'One click to finish creating your OpenPencil Cloud account.',
|
|
163
|
-
message: `Hi ${payload.name}, confirm this address to finish creating your OpenPencil Cloud account. Then go back to OpenPencil; it signs you in by itself.`,
|
|
164
|
-
actionLabel: 'Confirm email',
|
|
165
|
-
footer: 'Didn’t create an account? Ignore this email and nothing happens.'
|
|
166
|
-
},
|
|
167
|
-
'password-reset': {
|
|
168
|
-
subject: 'Reset your OpenPencil Cloud password',
|
|
169
|
-
heading: 'Reset your password',
|
|
170
|
-
preview: 'Use this secure link to choose a new password.',
|
|
171
|
-
message: `Hi ${payload.name}, use the link below to choose a new password.`,
|
|
172
|
-
actionLabel: 'Reset password',
|
|
173
|
-
footer: 'Didn’t ask for this? Ignore this email and your password stays the same.'
|
|
174
|
-
},
|
|
175
|
-
'password-changed': {
|
|
176
|
-
subject: 'Your OpenPencil Cloud password changed',
|
|
177
|
-
heading: 'Password changed',
|
|
178
|
-
preview: 'Your OpenPencil Cloud password was changed.',
|
|
179
|
-
message: `Hi ${payload.name}, your password was changed. If this was not you, contact your administrator.`,
|
|
180
|
-
actionLabel: 'Open OpenPencil Cloud'
|
|
181
|
-
}
|
|
182
|
-
}[kind]
|
|
183
|
-
return rendered(EnrollmentEmail, { ...copy, actionURL: payload.actionURL ?? '#' }, copy.subject)
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
async function renderEmailChangeRequested(payload: EmailChangeRequestedPayload) {
|
|
187
|
-
return rendered(
|
|
188
|
-
EnrollmentEmail,
|
|
189
|
-
{
|
|
190
|
-
heading: 'Your email is changing',
|
|
191
|
-
preview: `Your OpenPencil Cloud email is changing to ${payload.newEmail}.`,
|
|
192
|
-
message: `Hi ${payload.name}, someone signed in to your account asked to change its email to ${payload.newEmail}. It changes once that address confirms it. If this wasn’t you, change your password and sign out of your other sessions.`,
|
|
193
|
-
actionLabel: 'Review your account',
|
|
194
|
-
actionURL: payload.actionURL
|
|
195
|
-
},
|
|
196
|
-
'Your OpenPencil Cloud email is changing'
|
|
197
|
-
)
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
async function renderNewSignIn(payload: NewSignInPayload) {
|
|
201
|
-
const device = payload.desktop
|
|
202
|
-
? 'the OpenPencil app'
|
|
203
|
-
: compact([payload.browser, payload.system]).join(' on ') || 'an unknown browser'
|
|
204
|
-
const place = payload.ipAddress ? ` from ${payload.ipAddress}` : ''
|
|
205
|
-
return rendered(
|
|
206
|
-
EnrollmentEmail,
|
|
207
|
-
{
|
|
208
|
-
heading: 'New sign-in to your account',
|
|
209
|
-
preview: `Your OpenPencil Cloud account was signed in to with ${device}.`,
|
|
210
|
-
message: `Hi ${payload.name}, your account was signed in to with ${device}${place} on ${new Date(payload.signedInAt).toUTCString()}. If this was you, there’s nothing to do. If it wasn’t, sign that session out and change your password.`,
|
|
211
|
-
actionLabel: 'Review sessions',
|
|
212
|
-
actionURL: payload.actionURL
|
|
213
|
-
},
|
|
214
|
-
'New sign-in to your OpenPencil Cloud account'
|
|
215
|
-
)
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const TWO_STEP_COPY: Record<TwoStepChange, { heading: string; message: string }> = {
|
|
219
|
-
'authenticator-on': {
|
|
220
|
-
heading: 'Authenticator app turned on',
|
|
221
|
-
message: 'an authenticator app now confirms your sign-ins.'
|
|
79
|
+
component: EnrollmentUpdate,
|
|
80
|
+
props: { kind: 'revoked' },
|
|
81
|
+
subject: (_payload, t) => t.enrollmentRevokedSubject
|
|
82
|
+
},
|
|
83
|
+
'admin-enrollment-notification': {
|
|
84
|
+
component: EnrollmentNotification,
|
|
85
|
+
subject: (_payload, t) => t.enrollmentNotificationSubject
|
|
86
|
+
},
|
|
87
|
+
'email-verification': {
|
|
88
|
+
component: EmailVerification,
|
|
89
|
+
subject: (payload, t) =>
|
|
90
|
+
payload.purpose === 'change' ? t.verifyChangeSubject : t.verifyAccountSubject
|
|
91
|
+
},
|
|
92
|
+
'password-reset': { component: PasswordReset, subject: (_payload, t) => t.passwordResetSubject },
|
|
93
|
+
'password-changed': {
|
|
94
|
+
component: PasswordChanged,
|
|
95
|
+
subject: (_payload, t) => t.passwordChangedSubject
|
|
96
|
+
},
|
|
97
|
+
'email-change-requested': {
|
|
98
|
+
component: EmailChangeRequested,
|
|
99
|
+
subject: (_payload, t) => t.emailChangeSubject
|
|
100
|
+
},
|
|
101
|
+
'new-sign-in': { component: NewSignIn, subject: (_payload, t) => t.newSignInSubject },
|
|
102
|
+
'two-step-changed': { component: TwoStepChanged, subject: (_payload, t) => t.twoStepSubject },
|
|
103
|
+
'document-report': {
|
|
104
|
+
component: DocumentReport,
|
|
105
|
+
subject: (_payload, t) => t.documentReportSubject
|
|
106
|
+
},
|
|
107
|
+
'storage-limit-reached': {
|
|
108
|
+
component: StorageLimitReached,
|
|
109
|
+
subject: (_payload, t) => t.storageFullSubject
|
|
222
110
|
},
|
|
223
|
-
'
|
|
224
|
-
|
|
225
|
-
|
|
111
|
+
'document-blocked': {
|
|
112
|
+
component: DocumentBlocked,
|
|
113
|
+
subject: (payload, t) => t.documentBlockedSubject({ document: payload.documentName })
|
|
226
114
|
},
|
|
227
|
-
'
|
|
228
|
-
|
|
229
|
-
|
|
115
|
+
'document-restored': {
|
|
116
|
+
component: DocumentRestored,
|
|
117
|
+
subject: (payload, t) => t.documentRestoredSubject({ document: payload.documentName })
|
|
230
118
|
},
|
|
231
|
-
'
|
|
232
|
-
|
|
233
|
-
|
|
119
|
+
'document-report-received': {
|
|
120
|
+
component: DocumentReportReceived,
|
|
121
|
+
subject: (payload, t) => t.reportReceivedSubject({ document: payload.documentName })
|
|
234
122
|
},
|
|
235
|
-
'
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
'an administrator removed your authenticator app, recovery codes, and passkeys, so you can set them up again.'
|
|
123
|
+
'document-report-decided': {
|
|
124
|
+
component: DocumentReportDecided,
|
|
125
|
+
subject: (payload, t) => t.reportDecidedSubject({ document: payload.documentName })
|
|
239
126
|
}
|
|
240
127
|
}
|
|
241
128
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
|
|
129
|
+
/** Renders an email component as HTML and as plain text, in its reader's language. */
|
|
130
|
+
async function renderComponent(
|
|
131
|
+
email: Component,
|
|
132
|
+
props: Record<string, unknown>,
|
|
133
|
+
subject: string,
|
|
134
|
+
localization: EmailLocalization
|
|
135
|
+
): Promise<RenderedTransactionalEmail> {
|
|
136
|
+
const root = { email, props, localization }
|
|
137
|
+
const [html, text] = await Promise.all([
|
|
138
|
+
render(EmailRoot, root),
|
|
139
|
+
render(EmailRoot, root, { plainText: true })
|
|
140
|
+
])
|
|
141
|
+
return { subject, html, text }
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function renderKind<Kind extends TransactionalEmailKind>(
|
|
145
|
+
kind: Kind,
|
|
146
|
+
payload: TransactionalEmailPayloadByKind[Kind],
|
|
147
|
+
localization: EmailLocalization
|
|
148
|
+
) {
|
|
149
|
+
const { component, props, subject } = EMAILS[kind]
|
|
150
|
+
const content = { ...props, payload }
|
|
151
|
+
return renderComponent(component, content, subject(payload, localization.t), localization)
|
|
255
152
|
}
|
|
256
153
|
|
|
257
154
|
export async function renderTransactionalEmail(
|
|
258
|
-
content: TransactionalEmailContent
|
|
155
|
+
content: TransactionalEmailContent,
|
|
156
|
+
locale: EmailLocale
|
|
259
157
|
): Promise<RenderedTransactionalEmail> {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
)
|
|
270
|
-
return renderAuthentication(content.kind, content.payload)
|
|
271
|
-
}
|
|
272
|
-
if (content.kind === 'email-change-requested') return renderEmailChangeRequested(content.payload)
|
|
273
|
-
if (content.kind === 'new-sign-in') return renderNewSignIn(content.payload)
|
|
274
|
-
if (content.kind === 'two-step-changed') return renderTwoStepChanged(content.payload)
|
|
275
|
-
return renderEnrollment(content.kind, content.payload)
|
|
158
|
+
return renderKind(content.kind, content.payload, emailLocalization(locale))
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** The waitlist's confirmation email, which the feedback service sends rather than Cloud. */
|
|
162
|
+
export async function renderWaitlistConfirmation(
|
|
163
|
+
links: { confirmURL: string; leaveURL: string },
|
|
164
|
+
locale: EmailLocale
|
|
165
|
+
): Promise<RenderedTransactionalEmail> {
|
|
166
|
+
const localization = emailLocalization(locale)
|
|
167
|
+
return renderComponent(WaitlistConfirmation, links, localization.t.waitlistSubject, localization)
|
|
276
168
|
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { TransactionalEmailContent } from './schema'
|
|
2
|
+
|
|
3
|
+
/** Where every sample's button goes. */
|
|
4
|
+
export const EMAIL_SAMPLE_URL = 'https://cloud.example.com/next'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One email of every kind, with every optional part filled, as previews and tests show them. Its
|
|
8
|
+
* names and addresses are made up.
|
|
9
|
+
*/
|
|
10
|
+
export const EMAIL_SAMPLES: TransactionalEmailContent[] = [
|
|
11
|
+
{
|
|
12
|
+
kind: 'document-invitation',
|
|
13
|
+
payload: {
|
|
14
|
+
inviterName: 'Ada',
|
|
15
|
+
documentName: 'Homepage',
|
|
16
|
+
permission: 'edit',
|
|
17
|
+
expiresAt: '2026-11-20T10:00:00.000Z',
|
|
18
|
+
acceptanceURL: EMAIL_SAMPLE_URL
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
kind: 'workspace-invitation',
|
|
23
|
+
payload: {
|
|
24
|
+
inviterName: null,
|
|
25
|
+
workspaceName: 'Studio',
|
|
26
|
+
role: 'viewer',
|
|
27
|
+
expiresAt: '2026-11-20T10:00:00.000Z',
|
|
28
|
+
acceptanceURL: EMAIL_SAMPLE_URL
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
...(
|
|
32
|
+
[
|
|
33
|
+
'enrollment-requested',
|
|
34
|
+
'enrollment-approved',
|
|
35
|
+
'enrollment-rejected',
|
|
36
|
+
'enrollment-revoked'
|
|
37
|
+
] as const
|
|
38
|
+
).map((kind): TransactionalEmailContent => ({
|
|
39
|
+
kind,
|
|
40
|
+
payload: { name: 'Ada', actionURL: EMAIL_SAMPLE_URL }
|
|
41
|
+
})),
|
|
42
|
+
{
|
|
43
|
+
kind: 'admin-enrollment-notification',
|
|
44
|
+
payload: {
|
|
45
|
+
requesterEmail: 'ada@example.com',
|
|
46
|
+
requesterName: 'Ada',
|
|
47
|
+
reason: 'Design',
|
|
48
|
+
actionURL: EMAIL_SAMPLE_URL
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
kind: 'email-verification',
|
|
53
|
+
payload: { name: 'Ada', actionURL: EMAIL_SAMPLE_URL, purpose: 'change' }
|
|
54
|
+
},
|
|
55
|
+
{ kind: 'password-reset', payload: { name: 'Ada', actionURL: EMAIL_SAMPLE_URL } },
|
|
56
|
+
{ kind: 'password-changed', payload: { name: 'Ada', actionURL: EMAIL_SAMPLE_URL } },
|
|
57
|
+
{
|
|
58
|
+
kind: 'email-change-requested',
|
|
59
|
+
payload: { name: 'Ada', newEmail: 'ada@new.example.com', actionURL: EMAIL_SAMPLE_URL }
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
kind: 'new-sign-in',
|
|
63
|
+
payload: {
|
|
64
|
+
name: 'Ada',
|
|
65
|
+
signedInAt: '2026-11-13T10:00:00.000Z',
|
|
66
|
+
ipAddress: '203.0.113.9',
|
|
67
|
+
browser: 'Firefox',
|
|
68
|
+
system: 'Linux',
|
|
69
|
+
desktop: false,
|
|
70
|
+
actionURL: EMAIL_SAMPLE_URL
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
kind: 'two-step-changed',
|
|
75
|
+
payload: { name: 'Ada', change: 'passkey-added', actionURL: EMAIL_SAMPLE_URL }
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
kind: 'document-report',
|
|
79
|
+
payload: {
|
|
80
|
+
documentName: 'Homepage',
|
|
81
|
+
reason: 'copyright',
|
|
82
|
+
description: 'Copied',
|
|
83
|
+
actionURL: EMAIL_SAMPLE_URL
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
kind: 'storage-limit-reached',
|
|
88
|
+
payload: {
|
|
89
|
+
name: 'Ada',
|
|
90
|
+
usedBytes: 310 * 1024 ** 2,
|
|
91
|
+
limitBytes: 300 * 1024 ** 2,
|
|
92
|
+
upgradable: true,
|
|
93
|
+
actionURL: EMAIL_SAMPLE_URL
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
kind: 'document-blocked',
|
|
98
|
+
payload: {
|
|
99
|
+
name: 'Ada',
|
|
100
|
+
documentName: 'Homepage',
|
|
101
|
+
reason: 'Phishing page imitating a bank',
|
|
102
|
+
contactEmail: 'abuse@example.com',
|
|
103
|
+
actionURL: EMAIL_SAMPLE_URL
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
kind: 'document-restored',
|
|
108
|
+
payload: { name: 'Ada', documentName: 'Homepage', actionURL: EMAIL_SAMPLE_URL }
|
|
109
|
+
},
|
|
110
|
+
{ kind: 'document-report-received', payload: { documentName: 'Homepage' } },
|
|
111
|
+
{
|
|
112
|
+
kind: 'document-report-decided',
|
|
113
|
+
payload: { documentName: 'Homepage', outcome: 'blocked', contactEmail: 'abuse@example.com' }
|
|
114
|
+
}
|
|
115
|
+
]
|
package/src/email/schema.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
documentPermissionSchema,
|
|
3
|
+
documentReportReasonSchema,
|
|
4
|
+
workspaceRoleSchema
|
|
5
|
+
} from '#cloud/contract'
|
|
2
6
|
import * as v from 'valibot'
|
|
3
7
|
|
|
4
8
|
export type TransactionalEmailKind =
|
|
@@ -15,9 +19,16 @@ export type TransactionalEmailKind =
|
|
|
15
19
|
| 'email-change-requested'
|
|
16
20
|
| 'new-sign-in'
|
|
17
21
|
| 'two-step-changed'
|
|
22
|
+
| 'document-report'
|
|
23
|
+
| 'storage-limit-reached'
|
|
24
|
+
| 'document-blocked'
|
|
25
|
+
| 'document-restored'
|
|
26
|
+
| 'document-report-received'
|
|
27
|
+
| 'document-report-decided'
|
|
18
28
|
|
|
19
29
|
const documentInvitationEmailPayloadSchema = v.object({
|
|
20
|
-
|
|
30
|
+
/** Null when the inviter's account is gone, so the email says someone invited you. */
|
|
31
|
+
inviterName: v.nullable(v.string()),
|
|
21
32
|
documentName: v.string(),
|
|
22
33
|
permission: documentPermissionSchema,
|
|
23
34
|
expiresAt: v.string(),
|
|
@@ -25,7 +36,8 @@ const documentInvitationEmailPayloadSchema = v.object({
|
|
|
25
36
|
})
|
|
26
37
|
|
|
27
38
|
const workspaceInvitationEmailPayloadSchema = v.object({
|
|
28
|
-
|
|
39
|
+
/** Null when the inviter's account is gone, so the email says someone invited you. */
|
|
40
|
+
inviterName: v.nullable(v.string()),
|
|
29
41
|
workspaceName: v.string(),
|
|
30
42
|
role: workspaceRoleSchema,
|
|
31
43
|
expiresAt: v.string(),
|
|
@@ -33,7 +45,8 @@ const workspaceInvitationEmailPayloadSchema = v.object({
|
|
|
33
45
|
})
|
|
34
46
|
|
|
35
47
|
const enrollmentEmailPayloadSchema = v.object({
|
|
36
|
-
name
|
|
48
|
+
/** Null when the request named no one, so the email greets no one by name. */
|
|
49
|
+
name: v.nullable(v.string()),
|
|
37
50
|
actionURL: v.string()
|
|
38
51
|
})
|
|
39
52
|
|
|
@@ -44,6 +57,53 @@ const adminEnrollmentNotificationPayloadSchema = v.object({
|
|
|
44
57
|
actionURL: v.string()
|
|
45
58
|
})
|
|
46
59
|
|
|
60
|
+
const documentReportPayloadSchema = v.object({
|
|
61
|
+
documentName: v.string(),
|
|
62
|
+
reason: documentReportReasonSchema,
|
|
63
|
+
description: v.string(),
|
|
64
|
+
actionURL: v.string()
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const storageLimitReachedPayloadSchema = v.object({
|
|
68
|
+
name: v.string(),
|
|
69
|
+
usedBytes: v.number(),
|
|
70
|
+
limitBytes: v.number(),
|
|
71
|
+
/** Whether the server sells plans, so the account can get more storage rather than only free it. */
|
|
72
|
+
upgradable: v.boolean(),
|
|
73
|
+
actionURL: v.string()
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
/** To a workspace's owner: an administrator took one of its documents down. */
|
|
77
|
+
const documentBlockedPayloadSchema = v.object({
|
|
78
|
+
/** The owner's name, or null when the account has none. */
|
|
79
|
+
name: v.nullable(v.string()),
|
|
80
|
+
documentName: v.string(),
|
|
81
|
+
/** Why, as the administrator wrote it, or null when they gave no reason. */
|
|
82
|
+
reason: v.nullable(v.string()),
|
|
83
|
+
/** Where to write to contest it: the deployment's abuse address, or null without one. */
|
|
84
|
+
contactEmail: v.nullable(v.pipe(v.string(), v.email())),
|
|
85
|
+
actionURL: v.string()
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
/** To a workspace's owner: a document taken down is back. */
|
|
89
|
+
const documentRestoredPayloadSchema = v.object({
|
|
90
|
+
name: v.nullable(v.string()),
|
|
91
|
+
documentName: v.string(),
|
|
92
|
+
actionURL: v.string()
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
/** To whoever reported a document: their report arrived. */
|
|
96
|
+
const documentReportReceivedPayloadSchema = v.object({ documentName: v.string() })
|
|
97
|
+
|
|
98
|
+
/** To whoever reported a document: what the administrators decided. */
|
|
99
|
+
const documentReportDecidedPayloadSchema = v.object({
|
|
100
|
+
documentName: v.string(),
|
|
101
|
+
/** The document blocked, the report acted on some other way, or the document left as it was. */
|
|
102
|
+
outcome: v.picklist(['blocked', 'actioned', 'dismissed']),
|
|
103
|
+
/** Where to write to disagree: the deployment's abuse address, or null without one. */
|
|
104
|
+
contactEmail: v.nullable(v.pipe(v.string(), v.email()))
|
|
105
|
+
})
|
|
106
|
+
|
|
47
107
|
const authenticationEmailPayloadSchema = v.object({
|
|
48
108
|
name: v.string(),
|
|
49
109
|
actionURL: v.optional(v.string()),
|
|
@@ -102,7 +162,13 @@ export const transactionalEmailContentSchema = v.variant('kind', [
|
|
|
102
162
|
content('password-changed', authenticationEmailPayloadSchema),
|
|
103
163
|
content('email-change-requested', emailChangeRequestedPayloadSchema),
|
|
104
164
|
content('new-sign-in', newSignInPayloadSchema),
|
|
105
|
-
content('two-step-changed', twoStepChangedPayloadSchema)
|
|
165
|
+
content('two-step-changed', twoStepChangedPayloadSchema),
|
|
166
|
+
content('document-report', documentReportPayloadSchema),
|
|
167
|
+
content('storage-limit-reached', storageLimitReachedPayloadSchema),
|
|
168
|
+
content('document-blocked', documentBlockedPayloadSchema),
|
|
169
|
+
content('document-restored', documentRestoredPayloadSchema),
|
|
170
|
+
content('document-report-received', documentReportReceivedPayloadSchema),
|
|
171
|
+
content('document-report-decided', documentReportDecidedPayloadSchema)
|
|
106
172
|
])
|
|
107
173
|
|
|
108
174
|
/** A transactional email's kind with the payload that kind renders. */
|
|
@@ -142,3 +208,11 @@ export type RenderedTransactionalEmail = {
|
|
|
142
208
|
html: string
|
|
143
209
|
text: string
|
|
144
210
|
}
|
|
211
|
+
export type DocumentReportPayload = v.InferOutput<typeof documentReportPayloadSchema>
|
|
212
|
+
export type StorageLimitReachedPayload = v.InferOutput<typeof storageLimitReachedPayloadSchema>
|
|
213
|
+
export type DocumentBlockedPayload = v.InferOutput<typeof documentBlockedPayloadSchema>
|
|
214
|
+
export type DocumentRestoredPayload = v.InferOutput<typeof documentRestoredPayloadSchema>
|
|
215
|
+
export type DocumentReportReceivedPayload = v.InferOutput<
|
|
216
|
+
typeof documentReportReceivedPayloadSchema
|
|
217
|
+
>
|
|
218
|
+
export type DocumentReportDecidedPayload = v.InferOutput<typeof documentReportDecidedPayloadSchema>
|