@open-pencil/cloud 0.17.0-beta.4 → 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 +2 -1
- package/dist/bin/server.mjs +1 -1
- package/dist/bin/server.mjs.map +1 -1
- package/dist/bin/services.mjs +1 -1
- package/dist/bin/services.mjs.map +1 -1
- package/dist/client.d.ts +296 -27
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +649 -295
- package/dist/client.js.map +1 -1
- package/dist/contract.d.ts +2 -2
- package/dist/contract.js +2 -2
- package/dist/contract2.js +331 -21
- package/dist/contract2.js.map +1 -1
- package/dist/email.d.ts +1773 -32
- package/dist/email.d.ts.map +1 -1
- package/dist/email.js +3478 -288
- 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 +466 -13
- 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 +447 -290
- 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 +2963 -294
- package/dist/runtime-node.d.mts.map +1 -1
- package/dist/server.d.ts +3473 -842
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +12187 -8244
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +7739 -3548
- package/dist/server.mjs.map +1 -1
- package/dist/server2.mjs +5 -5
- package/dist/server2.mjs.map +1 -1
- package/package.json +22 -5
- package/src/admin/audit/service.ts +2 -2
- package/src/admin/documents/service.ts +76 -6
- package/src/admin/reports/service.ts +7 -1
- package/src/client/api.ts +23 -471
- package/src/client/auth/client.ts +22 -3
- 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 +7 -0
- package/src/client/portal/account.ts +54 -2
- 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 +23 -18
- package/src/client/sharing.ts +262 -0
- package/src/client/versions.ts +104 -0
- package/src/contract/account.ts +50 -0
- package/src/contract/billing.ts +166 -0
- package/src/contract/collaboration.ts +5 -0
- package/src/contract/community.ts +60 -0
- package/src/contract/discovery.ts +63 -2
- package/src/contract/entitlements.ts +10 -0
- package/src/contract/index.ts +54 -5
- package/src/contract/links.ts +57 -4
- package/src/contract/locale.ts +27 -0
- package/src/contract/portal.ts +12 -1
- package/src/contract/routes.ts +10 -0
- package/src/contract/services.ts +18 -16
- 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 +142 -276
- package/src/email/samples.ts +115 -0
- package/src/email/schema.ts +70 -6
- 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/global.d.ts +7 -0
- package/src/runtime/cloudflare/relay/index.ts +7 -1
- package/src/runtime/cloudflare/tsconfig.json +2 -1
- package/src/runtime/cloudflare/worker.ts +8 -1
- package/src/runtime/node/cleanup.ts +5 -1
- package/src/runtime/node/email/transport.ts +13 -10
- package/src/runtime/node/main.ts +1 -1
- package/src/runtime/node/server.ts +12 -2
- package/src/runtime/node/services/main.ts +1 -1
- package/src/runtime/posthog/errors.ts +2 -1
- package/src/runtime/s3/objects.ts +17 -0
- package/src/runtime/site/community.ts +101 -0
- package/src/runtime/site/server.ts +17 -1
- package/src/server/account/deletion.ts +2 -0
- package/src/server/account/routes.ts +271 -240
- package/src/server/account/tokens.ts +57 -0
- package/src/server/api/router.ts +23 -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-tokens.ts +62 -0
- package/src/server/auth/adapter.ts +21 -1
- package/src/server/auth/email.ts +4 -1
- package/src/server/auth/enrollment.ts +116 -0
- package/src/server/auth/factory.ts +88 -131
- 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 +16 -3
- package/src/server/cleanup/worker.ts +10 -1
- package/src/server/collaboration/relay/hub.ts +25 -142
- package/src/server/collaboration/relay/room.ts +154 -0
- package/src/server/collaboration/service.ts +21 -2
- 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 +17 -5
- package/src/server/config/index.ts +1 -1
- package/src/server/config/public.ts +7 -1
- package/src/server/config/schema.ts +40 -292
- package/src/server/config/toml/schema.ts +307 -0
- package/src/server/db/index.ts +1 -0
- package/src/server/db/migrate.ts +13 -1
- 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 +26 -1
- package/src/server/db/tables.ts +30 -1
- package/src/server/db/users.ts +22 -0
- package/src/server/documents/index.ts +1 -1
- package/src/server/documents/limits.ts +7 -1
- package/src/server/documents/service.ts +12 -402
- package/src/server/documents/uploads.ts +450 -0
- package/src/server/documents/versions/service.ts +81 -24
- 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 +1 -9
- package/src/server/index.ts +12 -5
- package/src/server/invitations/types.ts +5 -1
- package/src/server/objects/types.ts +5 -0
- package/src/server/policy/configured.ts +9 -3
- package/src/server/policy/database.ts +13 -2
- package/src/server/policy/policy.ts +39 -12
- package/src/server/policy/service.ts +71 -52
- package/src/server/policy/storage.ts +33 -0
- package/src/server/quota/index.ts +6 -0
- package/src/server/quota/notices.ts +121 -0
- package/src/server/quota/storage.ts +5 -0
- package/src/server/rate-limit/middleware.ts +4 -0
- package/src/server/reports/index.ts +1 -0
- package/src/server/reports/replies.ts +55 -0
- package/src/server/reports/routes.ts +3 -1
- package/src/server/reports/service.ts +24 -2
- package/src/server/sharing/capabilities/service.ts +2 -3
- package/src/server/sharing/invitations/service.ts +14 -4
- package/src/server/validation.ts +3 -0
- package/src/server/workspaces/members.ts +7 -19
- package/src/services/app.ts +1 -3
- package/src/services/config.ts +1 -0
- package/src/services/usage.ts +6 -14
- 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/app.ts +0 -453
- /package/src/{server/errors → errors}/posthog.ts +0 -0
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 =
|
|
@@ -16,9 +20,15 @@ export type TransactionalEmailKind =
|
|
|
16
20
|
| 'new-sign-in'
|
|
17
21
|
| 'two-step-changed'
|
|
18
22
|
| 'document-report'
|
|
23
|
+
| 'storage-limit-reached'
|
|
24
|
+
| 'document-blocked'
|
|
25
|
+
| 'document-restored'
|
|
26
|
+
| 'document-report-received'
|
|
27
|
+
| 'document-report-decided'
|
|
19
28
|
|
|
20
29
|
const documentInvitationEmailPayloadSchema = v.object({
|
|
21
|
-
|
|
30
|
+
/** Null when the inviter's account is gone, so the email says someone invited you. */
|
|
31
|
+
inviterName: v.nullable(v.string()),
|
|
22
32
|
documentName: v.string(),
|
|
23
33
|
permission: documentPermissionSchema,
|
|
24
34
|
expiresAt: v.string(),
|
|
@@ -26,7 +36,8 @@ const documentInvitationEmailPayloadSchema = v.object({
|
|
|
26
36
|
})
|
|
27
37
|
|
|
28
38
|
const workspaceInvitationEmailPayloadSchema = v.object({
|
|
29
|
-
|
|
39
|
+
/** Null when the inviter's account is gone, so the email says someone invited you. */
|
|
40
|
+
inviterName: v.nullable(v.string()),
|
|
30
41
|
workspaceName: v.string(),
|
|
31
42
|
role: workspaceRoleSchema,
|
|
32
43
|
expiresAt: v.string(),
|
|
@@ -34,7 +45,8 @@ const workspaceInvitationEmailPayloadSchema = v.object({
|
|
|
34
45
|
})
|
|
35
46
|
|
|
36
47
|
const enrollmentEmailPayloadSchema = v.object({
|
|
37
|
-
name
|
|
48
|
+
/** Null when the request named no one, so the email greets no one by name. */
|
|
49
|
+
name: v.nullable(v.string()),
|
|
38
50
|
actionURL: v.string()
|
|
39
51
|
})
|
|
40
52
|
|
|
@@ -47,11 +59,51 @@ const adminEnrollmentNotificationPayloadSchema = v.object({
|
|
|
47
59
|
|
|
48
60
|
const documentReportPayloadSchema = v.object({
|
|
49
61
|
documentName: v.string(),
|
|
50
|
-
reason:
|
|
62
|
+
reason: documentReportReasonSchema,
|
|
51
63
|
description: v.string(),
|
|
52
64
|
actionURL: v.string()
|
|
53
65
|
})
|
|
54
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
|
+
|
|
55
107
|
const authenticationEmailPayloadSchema = v.object({
|
|
56
108
|
name: v.string(),
|
|
57
109
|
actionURL: v.optional(v.string()),
|
|
@@ -111,7 +163,12 @@ export const transactionalEmailContentSchema = v.variant('kind', [
|
|
|
111
163
|
content('email-change-requested', emailChangeRequestedPayloadSchema),
|
|
112
164
|
content('new-sign-in', newSignInPayloadSchema),
|
|
113
165
|
content('two-step-changed', twoStepChangedPayloadSchema),
|
|
114
|
-
content('document-report', documentReportPayloadSchema)
|
|
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)
|
|
115
172
|
])
|
|
116
173
|
|
|
117
174
|
/** A transactional email's kind with the payload that kind renders. */
|
|
@@ -152,3 +209,10 @@ export type RenderedTransactionalEmail = {
|
|
|
152
209
|
text: string
|
|
153
210
|
}
|
|
154
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>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
Body,
|
|
4
|
+
Button,
|
|
5
|
+
Container,
|
|
6
|
+
Head,
|
|
7
|
+
Heading,
|
|
8
|
+
// eslint-disable-next-line @open-pencil/structure/no-mixed-case-acronym-identifiers -- Upstream export spelling.
|
|
9
|
+
Html as HTML,
|
|
10
|
+
Img,
|
|
11
|
+
Link,
|
|
12
|
+
Preview,
|
|
13
|
+
Section,
|
|
14
|
+
Text
|
|
15
|
+
} from '@vue-email/components'
|
|
16
|
+
|
|
17
|
+
import { LOGO_URL, SITE_URL, styles } from './brand'
|
|
18
|
+
import { useEmailLocalization } from './localization'
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The branded email every OpenPencil service sends, in its reader's language and direction: a
|
|
22
|
+
* heading, the paragraphs in the default slot, one button, and small print in `note`.
|
|
23
|
+
*/
|
|
24
|
+
const { preview, heading, action } = defineProps<{
|
|
25
|
+
/** The line mail clients show beside the subject. */
|
|
26
|
+
preview: string
|
|
27
|
+
heading: string
|
|
28
|
+
/** The one thing the email asks the reader to do, if there is one. */
|
|
29
|
+
action?: { label: string; url: string }
|
|
30
|
+
}>()
|
|
31
|
+
|
|
32
|
+
const { locale, dir, t } = useEmailLocalization()
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<HTML :lang="locale" :dir="dir">
|
|
37
|
+
<Head />
|
|
38
|
+
<Preview>{{ preview }}</Preview>
|
|
39
|
+
<Body :style="styles.body">
|
|
40
|
+
<Container :style="styles.card">
|
|
41
|
+
<Img :src="LOGO_URL" :width="44" :height="44" alt="OpenPencil" :style="styles.logo" />
|
|
42
|
+
<Heading as="h1" :style="styles.heading">{{ heading }}</Heading>
|
|
43
|
+
<slot />
|
|
44
|
+
<Section v-if="action" :style="styles.action">
|
|
45
|
+
<Button :href="action.url" :style="styles.button">{{ action.label }}</Button>
|
|
46
|
+
</Section>
|
|
47
|
+
<Text v-if="$slots.note" :style="styles.note"><slot name="note" /></Text>
|
|
48
|
+
</Container>
|
|
49
|
+
<Text :style="styles.footer">
|
|
50
|
+
{{ t.footer }} · <Link :href="SITE_URL" :style="styles.footerLink">openpencil.dev</Link>
|
|
51
|
+
</Text>
|
|
52
|
+
</Body>
|
|
53
|
+
</HTML>
|
|
54
|
+
</template>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { Link } from '@vue-email/components'
|
|
3
|
+
|
|
4
|
+
import type { DocumentBlockedPayload } from '../schema'
|
|
5
|
+
import { styles } from './brand'
|
|
6
|
+
import BrandEmail from './BrandEmail.vue'
|
|
7
|
+
import EmailText from './EmailText.vue'
|
|
8
|
+
import { greeting, useEmailLocalization } from './localization'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* To a workspace's owner: an administrator took one of its documents down. It says why, when the
|
|
12
|
+
* administrator gave a reason, and where to contest it.
|
|
13
|
+
*/
|
|
14
|
+
const { payload } = defineProps<{ payload: DocumentBlockedPayload }>()
|
|
15
|
+
|
|
16
|
+
const localization = useEmailLocalization()
|
|
17
|
+
const { t } = localization
|
|
18
|
+
const document = { document: payload.documentName }
|
|
19
|
+
// The translation places the address inside its sentence, where `{email}` is.
|
|
20
|
+
const [beforeEmail = '', afterEmail = ''] = t
|
|
21
|
+
.documentBlockedContest({ email: '{email}' })
|
|
22
|
+
.split('{email}')
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<BrandEmail
|
|
27
|
+
:preview="t.documentBlocked(document)"
|
|
28
|
+
:heading="t.documentBlockedHeading"
|
|
29
|
+
:action="{ label: t.openHome, url: payload.actionURL }"
|
|
30
|
+
>
|
|
31
|
+
<EmailText>{{ greeting(localization, payload.name) }}</EmailText>
|
|
32
|
+
<EmailText>{{ t.documentBlocked(document) }}</EmailText>
|
|
33
|
+
<EmailText v-if="payload.reason">
|
|
34
|
+
{{ t.documentBlockedReason({ reason: payload.reason }) }}
|
|
35
|
+
</EmailText>
|
|
36
|
+
<EmailText v-if="payload.contactEmail">
|
|
37
|
+
{{ beforeEmail
|
|
38
|
+
}}<Link :href="`mailto:${payload.contactEmail}`" :style="styles.link">{{
|
|
39
|
+
payload.contactEmail
|
|
40
|
+
}}</Link
|
|
41
|
+
>{{ afterEmail }}
|
|
42
|
+
</EmailText>
|
|
43
|
+
<EmailText v-else>{{ t.documentBlockedContestAdministrators }}</EmailText>
|
|
44
|
+
</BrandEmail>
|
|
45
|
+
</template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { DocumentInvitationEmailPayload } from '../schema'
|
|
3
|
+
import BrandEmail from './BrandEmail.vue'
|
|
4
|
+
import EmailText from './EmailText.vue'
|
|
5
|
+
import { useEmailLocalization } from './localization'
|
|
6
|
+
|
|
7
|
+
const { payload } = defineProps<{ payload: DocumentInvitationEmailPayload }>()
|
|
8
|
+
|
|
9
|
+
const { t, dateTime } = useEmailLocalization()
|
|
10
|
+
const names = { inviter: payload.inviterName ?? t.someone, document: payload.documentName }
|
|
11
|
+
const message =
|
|
12
|
+
payload.permission === 'edit' ? t.documentInvitationEdit(names) : t.documentInvitationView(names)
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<BrandEmail
|
|
17
|
+
:preview="message"
|
|
18
|
+
:heading="t.documentInvitationHeading"
|
|
19
|
+
:action="{ label: t.documentInvitationAction, url: payload.acceptanceURL }"
|
|
20
|
+
>
|
|
21
|
+
<EmailText>{{ message }}</EmailText>
|
|
22
|
+
<template #note>{{ t.invitationExpires({ date: dateTime(payload.expiresAt) }) }}</template>
|
|
23
|
+
</BrandEmail>
|
|
24
|
+
</template>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { DocumentReportReason } from '#cloud/contract'
|
|
3
|
+
|
|
4
|
+
import type { DocumentReportPayload } from '../schema'
|
|
5
|
+
import BrandEmail from './BrandEmail.vue'
|
|
6
|
+
import EmailText from './EmailText.vue'
|
|
7
|
+
import { useEmailLocalization } from './localization'
|
|
8
|
+
|
|
9
|
+
/** To administrators: someone reported a shared document, in their own words. */
|
|
10
|
+
const { payload } = defineProps<{ payload: DocumentReportPayload }>()
|
|
11
|
+
|
|
12
|
+
const { t } = useEmailLocalization()
|
|
13
|
+
const reasons: Record<DocumentReportReason, string> = {
|
|
14
|
+
'spam-phishing': t.reportReasonSpamPhishing,
|
|
15
|
+
illegal: t.reportReasonIllegal,
|
|
16
|
+
copyright: t.reportReasonCopyright,
|
|
17
|
+
harassment: t.reportReasonHarassment,
|
|
18
|
+
other: t.reportReasonOther
|
|
19
|
+
}
|
|
20
|
+
const report = { document: payload.documentName, reason: reasons[payload.reason] }
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<BrandEmail
|
|
25
|
+
:preview="t.documentReportPreview(report)"
|
|
26
|
+
:heading="t.documentReportHeading"
|
|
27
|
+
:action="{ label: t.documentReportAction, url: payload.actionURL }"
|
|
28
|
+
>
|
|
29
|
+
<EmailText>{{ t.documentReport(report) }}</EmailText>
|
|
30
|
+
<EmailText>{{ payload.description }}</EmailText>
|
|
31
|
+
</BrandEmail>
|
|
32
|
+
</template>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { Link } from '@vue-email/components'
|
|
3
|
+
|
|
4
|
+
import type { DocumentReportDecidedPayload } from '../schema'
|
|
5
|
+
import { styles } from './brand'
|
|
6
|
+
import BrandEmail from './BrandEmail.vue'
|
|
7
|
+
import EmailText from './EmailText.vue'
|
|
8
|
+
import { useEmailLocalization } from './localization'
|
|
9
|
+
|
|
10
|
+
/** To whoever reported a document: what the administrators decided, and where to disagree. */
|
|
11
|
+
const { payload } = defineProps<{ payload: DocumentReportDecidedPayload }>()
|
|
12
|
+
|
|
13
|
+
const { t } = useEmailLocalization()
|
|
14
|
+
const document = { document: payload.documentName }
|
|
15
|
+
const decision = {
|
|
16
|
+
blocked: { heading: t.reportBlockedHeading, message: t.reportBlocked(document) },
|
|
17
|
+
actioned: { heading: t.reportActionedHeading, message: t.reportActioned(document) },
|
|
18
|
+
dismissed: { heading: t.reportDismissedHeading, message: t.reportDismissed(document) }
|
|
19
|
+
}[payload.outcome]
|
|
20
|
+
// The translation places the address inside its sentence, where `{email}` is.
|
|
21
|
+
const [beforeEmail = '', afterEmail = ''] = t.reportDisagree({ email: '{email}' }).split('{email}')
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<BrandEmail :preview="decision.message" :heading="decision.heading">
|
|
26
|
+
<EmailText>{{ decision.message }}</EmailText>
|
|
27
|
+
<EmailText v-if="payload.contactEmail">
|
|
28
|
+
{{ beforeEmail
|
|
29
|
+
}}<Link :href="`mailto:${payload.contactEmail}`" :style="styles.link">{{
|
|
30
|
+
payload.contactEmail
|
|
31
|
+
}}</Link
|
|
32
|
+
>{{ afterEmail }}
|
|
33
|
+
</EmailText>
|
|
34
|
+
<EmailText v-else>{{ t.reportDisagreeAdministrators }}</EmailText>
|
|
35
|
+
</BrandEmail>
|
|
36
|
+
</template>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { DocumentReportReceivedPayload } from '../schema'
|
|
3
|
+
import BrandEmail from './BrandEmail.vue'
|
|
4
|
+
import EmailText from './EmailText.vue'
|
|
5
|
+
import { useEmailLocalization } from './localization'
|
|
6
|
+
|
|
7
|
+
/** To whoever reported a document: their report arrived, and they'll hear the decision. */
|
|
8
|
+
const { payload } = defineProps<{ payload: DocumentReportReceivedPayload }>()
|
|
9
|
+
|
|
10
|
+
const { t } = useEmailLocalization()
|
|
11
|
+
const document = { document: payload.documentName }
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<BrandEmail :preview="t.reportReceived(document)" :heading="t.reportReceivedHeading">
|
|
16
|
+
<EmailText>{{ t.reportReceived(document) }}</EmailText>
|
|
17
|
+
</BrandEmail>
|
|
18
|
+
</template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { DocumentRestoredPayload } from '../schema'
|
|
3
|
+
import BrandEmail from './BrandEmail.vue'
|
|
4
|
+
import EmailText from './EmailText.vue'
|
|
5
|
+
import { greeting, useEmailLocalization } from './localization'
|
|
6
|
+
|
|
7
|
+
/** To a workspace's owner: a document an administrator took down is back. */
|
|
8
|
+
const { payload } = defineProps<{ payload: DocumentRestoredPayload }>()
|
|
9
|
+
|
|
10
|
+
const localization = useEmailLocalization()
|
|
11
|
+
const { t } = localization
|
|
12
|
+
const document = { document: payload.documentName }
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<BrandEmail
|
|
17
|
+
:preview="t.documentRestored(document)"
|
|
18
|
+
:heading="t.documentRestoredHeading"
|
|
19
|
+
:action="{ label: t.openHome, url: payload.actionURL }"
|
|
20
|
+
>
|
|
21
|
+
<EmailText>{{ greeting(localization, payload.name) }}</EmailText>
|
|
22
|
+
<EmailText>{{ t.documentRestored(document) }}</EmailText>
|
|
23
|
+
</BrandEmail>
|
|
24
|
+
</template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { EmailChangeRequestedPayload } from '../schema'
|
|
3
|
+
import BrandEmail from './BrandEmail.vue'
|
|
4
|
+
import EmailText from './EmailText.vue'
|
|
5
|
+
import { greeting, useEmailLocalization } from './localization'
|
|
6
|
+
|
|
7
|
+
/** To the address being replaced: which address is taking over, before it confirms. */
|
|
8
|
+
const { payload } = defineProps<{ payload: EmailChangeRequestedPayload }>()
|
|
9
|
+
|
|
10
|
+
const localization = useEmailLocalization()
|
|
11
|
+
const { t } = localization
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<BrandEmail
|
|
16
|
+
:preview="t.emailChangePreview({ email: payload.newEmail })"
|
|
17
|
+
:heading="t.emailChangeHeading"
|
|
18
|
+
:action="{ label: t.reviewAccount, url: payload.actionURL }"
|
|
19
|
+
>
|
|
20
|
+
<EmailText>{{ greeting(localization, payload.name) }}</EmailText>
|
|
21
|
+
<EmailText>{{ t.emailChange({ email: payload.newEmail }) }}</EmailText>
|
|
22
|
+
<EmailText>{{ t.emailChangeNotYou }}</EmailText>
|
|
23
|
+
</BrandEmail>
|
|
24
|
+
</template>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { provide, type Component } from 'vue'
|
|
3
|
+
|
|
4
|
+
import type { EmailLocalization } from '../i18n'
|
|
5
|
+
import { EMAIL_LOCALIZATION } from './localization'
|
|
6
|
+
|
|
7
|
+
/** Renders an email in its reader's language, which it and its layout read. */
|
|
8
|
+
const { email, props, localization } = defineProps<{
|
|
9
|
+
email: Component
|
|
10
|
+
props: Record<string, unknown>
|
|
11
|
+
localization: EmailLocalization
|
|
12
|
+
}>()
|
|
13
|
+
|
|
14
|
+
provide(EMAIL_LOCALIZATION, localization)
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<component :is="email" v-bind="props" />
|
|
19
|
+
</template>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { AuthenticationEmailPayload } from '../schema'
|
|
3
|
+
import BrandEmail from './BrandEmail.vue'
|
|
4
|
+
import EmailText from './EmailText.vue'
|
|
5
|
+
import { greeting, useEmailLocalization } from './localization'
|
|
6
|
+
|
|
7
|
+
/** Confirms the address a new account signed up with, or one an account is moving to. */
|
|
8
|
+
const { payload } = defineProps<{ payload: AuthenticationEmailPayload }>()
|
|
9
|
+
|
|
10
|
+
const localization = useEmailLocalization()
|
|
11
|
+
const { t } = localization
|
|
12
|
+
const copy =
|
|
13
|
+
payload.purpose === 'change'
|
|
14
|
+
? {
|
|
15
|
+
preview: t.verifyChangePreview,
|
|
16
|
+
heading: t.verifyChangeHeading,
|
|
17
|
+
message: t.verifyChange,
|
|
18
|
+
note: t.verifyChangeNote
|
|
19
|
+
}
|
|
20
|
+
: {
|
|
21
|
+
preview: t.verifyAccountPreview,
|
|
22
|
+
heading: t.verifyAccountHeading,
|
|
23
|
+
message: t.verifyAccount,
|
|
24
|
+
note: t.verifyAccountNote
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<BrandEmail
|
|
30
|
+
:preview="copy.preview"
|
|
31
|
+
:heading="copy.heading"
|
|
32
|
+
:action="{ label: t.verifyAction, url: payload.actionURL ?? '#' }"
|
|
33
|
+
>
|
|
34
|
+
<EmailText>{{ greeting(localization, payload.name) }}</EmailText>
|
|
35
|
+
<EmailText>{{ copy.message }}</EmailText>
|
|
36
|
+
<template #note>{{ copy.note }}</template>
|
|
37
|
+
</BrandEmail>
|
|
38
|
+
</template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { AdminEnrollmentNotificationPayload } from '../schema'
|
|
3
|
+
import BrandEmail from './BrandEmail.vue'
|
|
4
|
+
import EmailText from './EmailText.vue'
|
|
5
|
+
import { useEmailLocalization } from './localization'
|
|
6
|
+
|
|
7
|
+
/** To administrators: someone asked for access, in their own words. */
|
|
8
|
+
const { payload } = defineProps<{ payload: AdminEnrollmentNotificationPayload }>()
|
|
9
|
+
|
|
10
|
+
const { t } = useEmailLocalization()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<BrandEmail
|
|
15
|
+
:preview="t.enrollmentNotificationPreview({ email: payload.requesterEmail })"
|
|
16
|
+
:heading="t.enrollmentNotificationHeading"
|
|
17
|
+
:action="{ label: t.enrollmentNotificationAction, url: payload.actionURL }"
|
|
18
|
+
>
|
|
19
|
+
<EmailText>
|
|
20
|
+
{{ t.enrollmentNotification({ name: payload.requesterName, email: payload.requesterEmail }) }}
|
|
21
|
+
</EmailText>
|
|
22
|
+
<EmailText>{{ payload.reason }}</EmailText>
|
|
23
|
+
</BrandEmail>
|
|
24
|
+
</template>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { EnrollmentEmailPayload } from '../schema'
|
|
3
|
+
import BrandEmail from './BrandEmail.vue'
|
|
4
|
+
import EmailText from './EmailText.vue'
|
|
5
|
+
import { greeting, useEmailLocalization } from './localization'
|
|
6
|
+
|
|
7
|
+
/** Where an access request stands, to the person who made it. */
|
|
8
|
+
const { kind, payload } = defineProps<{
|
|
9
|
+
kind: 'requested' | 'approved' | 'rejected' | 'revoked'
|
|
10
|
+
payload: EnrollmentEmailPayload
|
|
11
|
+
}>()
|
|
12
|
+
|
|
13
|
+
const localization = useEmailLocalization()
|
|
14
|
+
const { t } = localization
|
|
15
|
+
const copy = {
|
|
16
|
+
requested: {
|
|
17
|
+
preview: t.enrollmentRequestedPreview,
|
|
18
|
+
heading: t.enrollmentRequestedHeading,
|
|
19
|
+
message: t.enrollmentRequested,
|
|
20
|
+
action: t.openCloud
|
|
21
|
+
},
|
|
22
|
+
approved: {
|
|
23
|
+
preview: t.enrollmentApprovedPreview,
|
|
24
|
+
heading: t.enrollmentApprovedHeading,
|
|
25
|
+
message: t.enrollmentApproved,
|
|
26
|
+
action: t.enrollmentApprovedAction
|
|
27
|
+
},
|
|
28
|
+
rejected: {
|
|
29
|
+
preview: t.enrollmentRejectedPreview,
|
|
30
|
+
heading: t.enrollmentRejectedHeading,
|
|
31
|
+
message: t.enrollmentRejected,
|
|
32
|
+
action: t.enrollmentRejectedAction
|
|
33
|
+
},
|
|
34
|
+
revoked: {
|
|
35
|
+
preview: t.enrollmentRevokedPreview,
|
|
36
|
+
heading: t.enrollmentRevokedHeading,
|
|
37
|
+
message: t.enrollmentRevoked,
|
|
38
|
+
action: t.enrollmentRevokedAction
|
|
39
|
+
}
|
|
40
|
+
}[kind]
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<template>
|
|
44
|
+
<BrandEmail
|
|
45
|
+
:preview="copy.preview"
|
|
46
|
+
:heading="copy.heading"
|
|
47
|
+
:action="{ label: copy.action, url: payload.actionURL }"
|
|
48
|
+
>
|
|
49
|
+
<EmailText>{{ greeting(localization, payload.name) }}</EmailText>
|
|
50
|
+
<EmailText>{{ copy.message }}</EmailText>
|
|
51
|
+
</BrandEmail>
|
|
52
|
+
</template>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { NewSignInPayload } from '../schema'
|
|
3
|
+
import BrandEmail from './BrandEmail.vue'
|
|
4
|
+
import EmailText from './EmailText.vue'
|
|
5
|
+
import { greeting, useEmailLocalization } from './localization'
|
|
6
|
+
|
|
7
|
+
/** An account was signed in to from somewhere it never was before. */
|
|
8
|
+
const { payload } = defineProps<{ payload: NewSignInPayload }>()
|
|
9
|
+
|
|
10
|
+
const localization = useEmailLocalization()
|
|
11
|
+
const { t, dateTime } = localization
|
|
12
|
+
|
|
13
|
+
function signedInWith(): string {
|
|
14
|
+
if (payload.desktop) return t.newSignInApp
|
|
15
|
+
const { browser, system } = payload
|
|
16
|
+
if (browser && system) return t.newSignInBrowser({ browser, system })
|
|
17
|
+
return browser ?? system ?? t.newSignInUnknownBrowser
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const device = signedInWith()
|
|
21
|
+
const date = dateTime(payload.signedInAt)
|
|
22
|
+
const message = payload.ipAddress
|
|
23
|
+
? t.newSignInFrom({ device, address: payload.ipAddress, date })
|
|
24
|
+
: t.newSignIn({ device, date })
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<BrandEmail
|
|
29
|
+
:preview="t.newSignInPreview({ device })"
|
|
30
|
+
:heading="t.newSignInHeading"
|
|
31
|
+
:action="{ label: t.reviewSessions, url: payload.actionURL }"
|
|
32
|
+
>
|
|
33
|
+
<EmailText>{{ greeting(localization, payload.name) }}</EmailText>
|
|
34
|
+
<EmailText>{{ message }}</EmailText>
|
|
35
|
+
<EmailText>{{ t.newSignInNotYou }}</EmailText>
|
|
36
|
+
</BrandEmail>
|
|
37
|
+
</template>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { AuthenticationEmailPayload } from '../schema'
|
|
3
|
+
import BrandEmail from './BrandEmail.vue'
|
|
4
|
+
import EmailText from './EmailText.vue'
|
|
5
|
+
import { greeting, useEmailLocalization } from './localization'
|
|
6
|
+
|
|
7
|
+
const { payload } = defineProps<{ payload: AuthenticationEmailPayload }>()
|
|
8
|
+
|
|
9
|
+
const localization = useEmailLocalization()
|
|
10
|
+
const { t } = localization
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<BrandEmail
|
|
15
|
+
:preview="t.passwordChangedPreview"
|
|
16
|
+
:heading="t.passwordChangedHeading"
|
|
17
|
+
:action="{ label: t.openCloud, url: payload.actionURL ?? '#' }"
|
|
18
|
+
>
|
|
19
|
+
<EmailText>{{ greeting(localization, payload.name) }}</EmailText>
|
|
20
|
+
<EmailText>{{ t.passwordChanged }}</EmailText>
|
|
21
|
+
</BrandEmail>
|
|
22
|
+
</template>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { AuthenticationEmailPayload } from '../schema'
|
|
3
|
+
import BrandEmail from './BrandEmail.vue'
|
|
4
|
+
import EmailText from './EmailText.vue'
|
|
5
|
+
import { greeting, useEmailLocalization } from './localization'
|
|
6
|
+
|
|
7
|
+
const { payload } = defineProps<{ payload: AuthenticationEmailPayload }>()
|
|
8
|
+
|
|
9
|
+
const localization = useEmailLocalization()
|
|
10
|
+
const { t } = localization
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<BrandEmail
|
|
15
|
+
:preview="t.passwordResetPreview"
|
|
16
|
+
:heading="t.passwordResetHeading"
|
|
17
|
+
:action="{ label: t.passwordResetAction, url: payload.actionURL ?? '#' }"
|
|
18
|
+
>
|
|
19
|
+
<EmailText>{{ greeting(localization, payload.name) }}</EmailText>
|
|
20
|
+
<EmailText>{{ t.passwordReset }}</EmailText>
|
|
21
|
+
<template #note>{{ t.passwordResetNote }}</template>
|
|
22
|
+
</BrandEmail>
|
|
23
|
+
</template>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { StorageLimitReachedPayload } from '../schema'
|
|
3
|
+
import BrandEmail from './BrandEmail.vue'
|
|
4
|
+
import EmailText from './EmailText.vue'
|
|
5
|
+
import { greeting, useEmailLocalization } from './localization'
|
|
6
|
+
|
|
7
|
+
/** The account holds all the storage its plan includes, so its workspaces are read-only. */
|
|
8
|
+
const { payload } = defineProps<{ payload: StorageLimitReachedPayload }>()
|
|
9
|
+
|
|
10
|
+
const localization = useEmailLocalization()
|
|
11
|
+
const { t, storage } = localization
|
|
12
|
+
const amounts = { used: storage(payload.usedBytes), limit: storage(payload.limitBytes) }
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<BrandEmail
|
|
17
|
+
:preview="t.storageFullPreview(amounts)"
|
|
18
|
+
:heading="t.storageFullHeading"
|
|
19
|
+
:action="{
|
|
20
|
+
label: payload.upgradable ? t.storageFullAction : t.openCloud,
|
|
21
|
+
url: payload.actionURL
|
|
22
|
+
}"
|
|
23
|
+
>
|
|
24
|
+
<EmailText>{{ greeting(localization, payload.name) }}</EmailText>
|
|
25
|
+
<EmailText>{{ t.storageFull(amounts) }}</EmailText>
|
|
26
|
+
<EmailText>{{ payload.upgradable ? t.storageFullUpgrade : t.storageFullFreeSpace }}</EmailText>
|
|
27
|
+
</BrandEmail>
|
|
28
|
+
</template>
|