@open-pencil/cloud 0.17.0-beta.4 → 0.17.0-beta.6
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 +783 -47
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1651 -382
- package/dist/client.js.map +1 -1
- package/dist/contract.d.ts +2 -2
- package/dist/contract.js +2 -2
- package/dist/contract2.js +701 -45
- package/dist/contract2.js.map +1 -1
- package/dist/email.d.ts +2138 -34
- package/dist/email.d.ts.map +1 -1
- package/dist/email.js +4343 -306
- package/dist/email.js.map +1 -1
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +61 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +1338 -44
- package/dist/index.d.ts.map +1 -1
- package/dist/index2.d.ts +45 -0
- package/dist/index2.d.ts.map +1 -0
- package/dist/listen.mjs +958 -340
- package/dist/listen.mjs.map +1 -1
- package/dist/runtime-cloudflare.d.ts +93 -0
- package/dist/runtime-cloudflare.d.ts.map +1 -0
- package/dist/runtime-cloudflare.js +18032 -0
- package/dist/runtime-cloudflare.js.map +1 -0
- package/dist/runtime-node.d.mts +12615 -5249
- package/dist/runtime-node.d.mts.map +1 -1
- package/dist/server.d.ts +17367 -8567
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +13587 -7333
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +11601 -5401
- package/dist/server.mjs.map +1 -1
- package/dist/server2.mjs +84 -62
- package/dist/server2.mjs.map +1 -1
- package/package.json +31 -5
- package/src/admin/api/routes.ts +263 -190
- package/src/admin/audit/service.ts +11 -3
- package/src/admin/bootstrap.ts +86 -0
- package/src/admin/documents/service.ts +195 -10
- package/src/admin/email/service.ts +2 -1
- package/src/admin/enrollment/email.ts +17 -3
- package/src/admin/enrollment/service.ts +71 -10
- package/src/admin/errors.ts +5 -0
- package/src/admin/index.ts +1 -0
- package/src/admin/reports/service.ts +15 -3
- package/src/admin/schema.ts +6 -5
- package/src/admin/users/service.ts +173 -16
- package/src/client/api.ts +52 -473
- package/src/client/auth/client.ts +22 -3
- package/src/client/comments.ts +205 -0
- package/src/client/community.ts +40 -0
- package/src/client/device-authorization.ts +4 -20
- package/src/client/discovery.ts +39 -11
- package/src/client/documents.ts +160 -0
- package/src/client/files/archive.ts +60 -0
- package/src/client/files/checksum.ts +7 -0
- package/src/client/files/download.ts +122 -0
- package/src/client/files/images.ts +89 -0
- package/src/client/files/index.ts +15 -0
- package/src/client/files/objects.ts +173 -0
- package/src/client/files/save.ts +79 -0
- package/src/client/index.ts +4 -0
- package/src/client/portal/account.ts +73 -3
- package/src/client/portal/administration.ts +52 -5
- package/src/client/portal/request.ts +6 -2
- 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/tour.ts +44 -0
- package/src/client/versions.ts +110 -0
- package/src/contract/account.ts +111 -11
- package/src/contract/admin/index.ts +48 -3
- package/src/contract/billing.ts +235 -0
- package/src/contract/collaboration.ts +5 -0
- package/src/contract/comments.ts +223 -0
- package/src/contract/community.ts +60 -0
- package/src/contract/discovery.ts +94 -5
- package/src/contract/entitlements.ts +10 -0
- package/src/contract/index.ts +64 -5
- package/src/contract/links.ts +62 -4
- package/src/contract/locale.ts +27 -0
- package/src/contract/portal.ts +12 -1
- package/src/contract/relay.ts +3 -1
- package/src/contract/routes.ts +10 -0
- package/src/contract/services.ts +62 -20
- package/src/contract/workspaces.ts +5 -0
- package/src/email/i18n.ts +174 -0
- package/src/email/index.ts +13 -2
- package/src/email/locales/ar.json +169 -0
- package/src/email/locales/de.json +169 -0
- package/src/email/locales/es.json +169 -0
- package/src/email/locales/fr.json +169 -0
- package/src/email/locales/it.json +169 -0
- package/src/email/locales/ja.json +169 -0
- package/src/email/locales/pl.json +169 -0
- package/src/email/locales/pt-br.json +169 -0
- package/src/email/locales/ru.json +169 -0
- package/src/email/locales/zh-cn.json +169 -0
- package/src/email/messages.ts +235 -0
- package/src/email/render.ts +160 -276
- package/src/email/samples.ts +142 -0
- package/src/email/schema.ts +98 -8
- package/src/email/templates/BrandEmail.vue +56 -0
- package/src/email/templates/CommentNotification.vue +39 -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/EnrollmentInvitation.vue +53 -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 +47 -0
- package/src/email/templates/WaitlistConfirmation.vue +29 -0
- package/src/email/templates/WorkspaceInvitation.vue +28 -0
- package/src/email/templates/brand.ts +15 -61
- package/src/email/templates/localization.ts +17 -0
- package/src/errors/index.ts +6 -0
- package/src/{server/errors → errors}/posthog.ts +28 -4
- package/src/global.d.ts +7 -0
- package/src/runtime/cloudflare/email.ts +2 -0
- package/src/runtime/cloudflare/relay/index.ts +28 -7
- package/src/runtime/cloudflare/tsconfig.json +2 -1
- package/src/runtime/cloudflare/worker.ts +14 -1
- package/src/runtime/cloudflare/xml.ts +12 -0
- package/src/runtime/node/admin.ts +51 -47
- package/src/runtime/node/cleanup.ts +5 -1
- package/src/runtime/node/email/runtime.ts +1 -0
- package/src/runtime/node/email/transport.ts +14 -10
- package/src/runtime/node/main.ts +1 -1
- package/src/runtime/node/server.ts +20 -4
- package/src/runtime/node/services/main.ts +1 -1
- package/src/runtime/posthog/errors.ts +5 -2
- 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/actions.ts +3 -1
- package/src/server/account/deletion.ts +40 -4
- package/src/server/account/routes.ts +305 -253
- package/src/server/account/tokens.ts +57 -0
- package/src/server/api/router.ts +44 -6
- package/src/server/app/checks.ts +89 -0
- package/src/server/app/cors.ts +44 -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 +123 -0
- package/src/server/app/services.ts +219 -0
- package/src/server/auth/access-control.ts +13 -8
- package/src/server/auth/access-tokens.ts +62 -0
- package/src/server/auth/account.ts +13 -12
- package/src/server/auth/activity.ts +7 -2
- package/src/server/auth/adapter.ts +36 -3
- package/src/server/auth/email.ts +33 -18
- package/src/server/auth/endpoints.ts +4 -0
- package/src/server/auth/enrollment.ts +116 -0
- package/src/server/auth/factory.ts +165 -189
- package/src/server/auth/index.ts +1 -1
- package/src/server/auth/logger.ts +23 -0
- package/src/server/auth/methods.ts +162 -0
- package/src/server/auth/mfa-assurance.ts +190 -2
- package/src/server/auth/passwords.ts +43 -0
- package/src/server/auth/rate-limit.ts +31 -0
- package/src/server/auth/runtime.ts +19 -5
- package/src/server/auth/session.ts +2 -0
- package/src/server/auth/social-providers.ts +70 -24
- package/src/server/billing/index.ts +8 -0
- package/src/server/billing/notify.ts +55 -0
- package/src/server/billing/routes.ts +27 -0
- package/src/server/billing/seats.ts +17 -0
- package/src/server/billing/tokens.ts +37 -0
- package/src/server/cleanup/configured.ts +16 -3
- package/src/server/cleanup/documents.ts +5 -2
- package/src/server/cleanup/revisions.ts +6 -3
- package/src/server/cleanup/uploads.ts +2 -1
- package/src/server/cleanup/worker.ts +10 -1
- package/src/server/collaboration/relay/connection.ts +7 -2
- package/src/server/collaboration/relay/hub.ts +80 -166
- package/src/server/collaboration/relay/room.ts +154 -0
- package/src/server/collaboration/routes.ts +8 -5
- package/src/server/collaboration/service.ts +21 -2
- package/src/server/comments/index.ts +9 -0
- package/src/server/comments/notify.ts +277 -0
- package/src/server/comments/routes.ts +352 -0
- package/src/server/comments/rows.ts +249 -0
- package/src/server/comments/service.ts +570 -0
- 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 +35 -10
- package/src/server/config/index.ts +2 -2
- package/src/server/config/public.ts +25 -6
- package/src/server/config/schema.ts +53 -293
- package/src/server/config/toml/schema.ts +330 -0
- package/src/server/db/index.ts +3 -1
- package/src/server/db/migrate.ts +33 -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/015_comments.ts +57 -0
- package/src/server/db/migrations/016_comment_notifications.ts +76 -0
- package/src/server/db/migrations/017_invitation_emails.ts +19 -0
- package/src/server/db/migrations/018_enrollment_source.ts +17 -0
- package/src/server/db/migrations/schema.ts +26 -1
- package/src/server/db/tables.ts +122 -3
- package/src/server/db/users.ts +22 -0
- package/src/server/documents/access.ts +17 -0
- package/src/server/documents/images.ts +6 -1
- package/src/server/documents/index.ts +1 -1
- package/src/server/documents/limits.ts +7 -1
- package/src/server/documents/routes.ts +12 -12
- package/src/server/documents/service.ts +31 -407
- package/src/server/documents/summary.ts +15 -0
- package/src/server/documents/uploads.ts +450 -0
- package/src/server/documents/versions/routes.ts +7 -8
- package/src/server/documents/versions/service.ts +86 -26
- package/src/server/email/invitations.ts +1 -0
- package/src/server/email/service.ts +39 -6
- package/src/server/email/types.ts +13 -0
- package/src/server/errors/index.ts +49 -12
- package/src/server/index.ts +27 -6
- package/src/server/internal/routes.ts +8 -2
- package/src/server/internal/service.ts +10 -0
- package/src/server/invitations/budget.ts +3 -1
- package/src/server/invitations/index.ts +1 -0
- package/src/server/invitations/links.ts +6 -0
- package/src/server/invitations/types.ts +5 -1
- package/src/server/objects/types.ts +5 -0
- package/src/server/pictures/service.ts +3 -1
- 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/policy/workspace.ts +5 -2
- 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 +5 -3
- package/src/server/reports/service.ts +27 -3
- package/src/server/services/routes.ts +2 -2
- package/src/server/sharing/capabilities/service.ts +3 -4
- package/src/server/sharing/document-routes.ts +3 -3
- package/src/server/sharing/invitations/service.ts +17 -8
- package/src/server/sharing/routes.ts +15 -15
- package/src/server/validation.ts +35 -24
- package/src/server/workspaces/members.ts +57 -31
- package/src/server/workspaces/repository.ts +23 -12
- package/src/server/workspaces/routes.ts +8 -8
- package/src/services/app.ts +31 -22
- package/src/services/config.ts +48 -8
- package/src/services/metering.ts +15 -27
- 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
|
@@ -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>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { CLOUD_SOCIAL_PROVIDER_NAMES, isKnownSocialProvider } from '#cloud/contract'
|
|
3
|
+
|
|
4
|
+
import type { TwoStepChange, TwoStepChangedPayload } from '../schema'
|
|
5
|
+
import BrandEmail from './BrandEmail.vue'
|
|
6
|
+
import EmailText from './EmailText.vue'
|
|
7
|
+
import { greeting, useEmailLocalization } from './localization'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* How the account proves it's its owner's changed: an authenticator app, a passkey, or a way to
|
|
11
|
+
* sign in an administrator removed.
|
|
12
|
+
*/
|
|
13
|
+
const { payload } = defineProps<{ payload: TwoStepChangedPayload }>()
|
|
14
|
+
|
|
15
|
+
const localization = useEmailLocalization()
|
|
16
|
+
const { t } = localization
|
|
17
|
+
// Provider names stay as their owners write them; a password is named in the reader's words.
|
|
18
|
+
function methodName(provider: string): string {
|
|
19
|
+
if (provider === 'credential') return t.signInMethodPassword
|
|
20
|
+
return isKnownSocialProvider(provider) ? CLOUD_SOCIAL_PROVIDER_NAMES[provider] : provider
|
|
21
|
+
}
|
|
22
|
+
const method = payload.method ? methodName(payload.method) : ''
|
|
23
|
+
const changes: Record<TwoStepChange, { heading: string; message: string }> = {
|
|
24
|
+
'authenticator-on': { heading: t.authenticatorOnHeading, message: t.authenticatorOn },
|
|
25
|
+
'authenticator-off': { heading: t.authenticatorOffHeading, message: t.authenticatorOff },
|
|
26
|
+
'passkey-added': { heading: t.passkeyAddedHeading, message: t.passkeyAdded },
|
|
27
|
+
'passkey-removed': { heading: t.passkeyRemovedHeading, message: t.passkeyRemoved },
|
|
28
|
+
'reset-by-administrator': { heading: t.twoStepResetHeading, message: t.twoStepReset },
|
|
29
|
+
'sign-in-method-removed': {
|
|
30
|
+
heading: t.signInMethodRemovedHeading,
|
|
31
|
+
message: t.signInMethodRemoved({ method })
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const change = changes[payload.change]
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<template>
|
|
38
|
+
<BrandEmail
|
|
39
|
+
:preview="change.message"
|
|
40
|
+
:heading="change.heading"
|
|
41
|
+
:action="{ label: t.reviewSecurity, url: payload.actionURL }"
|
|
42
|
+
>
|
|
43
|
+
<EmailText>{{ greeting(localization, payload.name) }}</EmailText>
|
|
44
|
+
<EmailText>{{ change.message }}</EmailText>
|
|
45
|
+
<EmailText>{{ t.twoStepNotYou }}</EmailText>
|
|
46
|
+
</BrandEmail>
|
|
47
|
+
</template>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { Link } from '@vue-email/components'
|
|
3
|
+
|
|
4
|
+
import { styles } from './brand'
|
|
5
|
+
import BrandEmail from './BrandEmail.vue'
|
|
6
|
+
import EmailText from './EmailText.vue'
|
|
7
|
+
import { useEmailLocalization } from './localization'
|
|
8
|
+
|
|
9
|
+
/** Asks a waitlist sign-up to confirm its address; its links carry the sign-up's token only. */
|
|
10
|
+
const { confirmURL, leaveURL } = defineProps<{ confirmURL: string; leaveURL: string }>()
|
|
11
|
+
|
|
12
|
+
const { t } = useEmailLocalization()
|
|
13
|
+
// The translation places the link inside its sentence, where `{link}` is.
|
|
14
|
+
const [beforeLink = '', afterLink = ''] = t.waitlistNote.split('{link}')
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<BrandEmail
|
|
19
|
+
:preview="t.waitlistPreview"
|
|
20
|
+
:heading="t.waitlistHeading"
|
|
21
|
+
:action="{ label: t.waitlistAction, url: confirmURL }"
|
|
22
|
+
>
|
|
23
|
+
<EmailText>{{ t.waitlist }}</EmailText>
|
|
24
|
+
<template #note>
|
|
25
|
+
{{ beforeLink }}<Link :href="leaveURL" :style="styles.link">{{ t.waitlistLeave }}</Link
|
|
26
|
+
>{{ afterLink }}
|
|
27
|
+
</template>
|
|
28
|
+
</BrandEmail>
|
|
29
|
+
</template>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { WorkspaceInvitationEmailPayload } 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: WorkspaceInvitationEmailPayload }>()
|
|
8
|
+
|
|
9
|
+
const { t, dateTime } = useEmailLocalization()
|
|
10
|
+
const names = { inviter: payload.inviterName ?? t.someone, workspace: payload.workspaceName }
|
|
11
|
+
const message = {
|
|
12
|
+
admin: t.workspaceInvitationAdmin,
|
|
13
|
+
editor: t.workspaceInvitationEditor,
|
|
14
|
+
viewer: t.workspaceInvitationViewer
|
|
15
|
+
}[payload.role](names)
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<BrandEmail
|
|
20
|
+
:preview="t.workspaceInvitationSubject(names)"
|
|
21
|
+
:heading="t.workspaceInvitationHeading(names)"
|
|
22
|
+
:action="{ label: t.workspaceInvitationAction, url: payload.acceptanceURL }"
|
|
23
|
+
>
|
|
24
|
+
<EmailText>{{ message }}</EmailText>
|
|
25
|
+
<EmailText>{{ t.workspaceInvitationHome }}</EmailText>
|
|
26
|
+
<template #note>{{ t.invitationExpires({ date: dateTime(payload.expiresAt) }) }}</template>
|
|
27
|
+
</BrandEmail>
|
|
28
|
+
</template>
|
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
Body,
|
|
3
|
-
Button,
|
|
4
|
-
Container,
|
|
5
|
-
Head,
|
|
6
|
-
Heading,
|
|
7
|
-
// eslint-disable-next-line @open-pencil/structure/no-mixed-case-acronym-identifiers -- Upstream export spelling.
|
|
8
|
-
Html as HTML,
|
|
9
|
-
Img,
|
|
10
|
-
Link,
|
|
11
|
-
Preview,
|
|
12
|
-
Section,
|
|
13
|
-
Text
|
|
14
|
-
} from '@vue-email/components'
|
|
15
|
-
import { h, type VNode } from 'vue'
|
|
1
|
+
/** The brand every OpenPencil email shares, from the waitlist to Cloud: its colors and type. */
|
|
16
2
|
|
|
17
3
|
/** The ivory app-icon tile, served as PNG because mail clients do not draw SVG. */
|
|
18
|
-
const LOGO_URL = 'https://openpencil.dev/brand/app-icon-1024.png'
|
|
19
|
-
const SITE_URL = 'https://openpencil.dev'
|
|
4
|
+
export const LOGO_URL = 'https://openpencil.dev/brand/app-icon-1024.png'
|
|
5
|
+
export const SITE_URL = 'https://openpencil.dev'
|
|
6
|
+
/** The download page's beta section, with the newest desktop beta's installers. */
|
|
7
|
+
export const DESKTOP_BETA_URL = 'https://openpencil.dev/download#beta'
|
|
8
|
+
/** The repository's bug report form. */
|
|
9
|
+
export const BUG_REPORT_URL =
|
|
10
|
+
'https://github.com/open-pencil/open-pencil/issues/new?template=bug_report.yml'
|
|
20
11
|
|
|
21
12
|
const FONT = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'
|
|
22
13
|
const INK = '#171717'
|
|
@@ -24,7 +15,8 @@ const MUTED = '#6B6B6B'
|
|
|
24
15
|
/** Deep teal from the mark; white text on it passes WCAG AA. */
|
|
25
16
|
const TEAL = '#0A6C65'
|
|
26
17
|
|
|
27
|
-
|
|
18
|
+
/** Inline styles, since mail clients drop most stylesheets. */
|
|
19
|
+
export const styles = {
|
|
28
20
|
body: { backgroundColor: '#F5F5EF', fontFamily: FONT, margin: '0', padding: '40px 16px' },
|
|
29
21
|
card: {
|
|
30
22
|
maxWidth: '480px',
|
|
@@ -42,7 +34,8 @@ const styles = {
|
|
|
42
34
|
lineHeight: '1.3',
|
|
43
35
|
margin: '0 0 12px'
|
|
44
36
|
},
|
|
45
|
-
text: { color: '#404040', fontSize: '15px', lineHeight: '1.6', margin: '0 0
|
|
37
|
+
text: { color: '#404040', fontSize: '15px', lineHeight: '1.6', margin: '0 0 16px' },
|
|
38
|
+
action: { paddingTop: '8px' },
|
|
46
39
|
button: {
|
|
47
40
|
backgroundColor: TEAL,
|
|
48
41
|
borderRadius: '10px',
|
|
@@ -52,6 +45,7 @@ const styles = {
|
|
|
52
45
|
padding: '12px 22px',
|
|
53
46
|
textDecoration: 'none'
|
|
54
47
|
},
|
|
48
|
+
signature: { color: '#404040', fontSize: '15px', lineHeight: '1.6', margin: '28px 0 0' },
|
|
55
49
|
note: { color: MUTED, fontSize: '13px', lineHeight: '1.6', margin: '28px 0 0' },
|
|
56
50
|
link: { color: TEAL, textDecoration: 'underline' },
|
|
57
51
|
footer: {
|
|
@@ -60,46 +54,6 @@ const styles = {
|
|
|
60
54
|
lineHeight: '1.6',
|
|
61
55
|
textAlign: 'center' as const,
|
|
62
56
|
margin: '24px 0 0'
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export type EmailLayoutProps = {
|
|
67
|
-
/** The line mail clients show beside the subject. */
|
|
68
|
-
preview: string
|
|
69
|
-
heading: string
|
|
70
|
-
message: string
|
|
71
|
-
actionLabel: string
|
|
72
|
-
actionURL: string
|
|
73
|
-
/** Small print under the button, with an optional link at its end. */
|
|
74
|
-
note?: { text: string; link?: { label: string; url: string } }
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function noteContent(note: NonNullable<EmailLayoutProps['note']>) {
|
|
78
|
-
if (!note.link) return note.text
|
|
79
|
-
const { label, url } = note.link
|
|
80
|
-
return [`${note.text} `, h(Link, { href: url, style: styles.link }, () => label), '.']
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/** The branded email every OpenPencil service sends: the waitlist and Cloud alike. */
|
|
84
|
-
export function emailLayout(props: EmailLayoutProps): VNode {
|
|
85
|
-
const { note } = props
|
|
86
|
-
return h(HTML, { lang: 'en' }, () => [
|
|
87
|
-
h(Head),
|
|
88
|
-
h(Preview, () => props.preview),
|
|
89
|
-
h(Body, { style: styles.body }, () => [
|
|
90
|
-
h(Container, { style: styles.card }, () => [
|
|
91
|
-
h(Img, { src: LOGO_URL, width: 44, height: 44, alt: 'OpenPencil', style: styles.logo }),
|
|
92
|
-
h(Heading, { as: 'h1', style: styles.heading }, () => props.heading),
|
|
93
|
-
h(Text, { style: styles.text }, () => props.message),
|
|
94
|
-
h(Section, () =>
|
|
95
|
-
h(Button, { href: props.actionURL, style: styles.button }, () => props.actionLabel)
|
|
96
|
-
),
|
|
97
|
-
note ? h(Text, { style: styles.note }, () => noteContent(note)) : null
|
|
98
|
-
]),
|
|
99
|
-
h(Text, { style: styles.footer }, () => [
|
|
100
|
-
'OpenPencil, the open-source design editor · ',
|
|
101
|
-
h(Link, { href: SITE_URL, style: { color: MUTED } }, () => 'openpencil.dev')
|
|
102
|
-
])
|
|
103
|
-
])
|
|
104
|
-
])
|
|
57
|
+
},
|
|
58
|
+
footerLink: { color: MUTED }
|
|
105
59
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { inject, type InjectionKey } from 'vue'
|
|
2
|
+
|
|
3
|
+
import type { EmailLocalization } from '../i18n'
|
|
4
|
+
|
|
5
|
+
/** The reader's language, which every email and its layout write in. */
|
|
6
|
+
export const EMAIL_LOCALIZATION: InjectionKey<EmailLocalization> = Symbol('email-localization')
|
|
7
|
+
|
|
8
|
+
export function useEmailLocalization(): EmailLocalization {
|
|
9
|
+
const localization = inject(EMAIL_LOCALIZATION)
|
|
10
|
+
if (!localization) throw new Error('An email renders inside EmailRoot, which gives its language')
|
|
11
|
+
return localization
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** "Hi Ada," or, when the account has no name, "Hi,". */
|
|
15
|
+
export function greeting({ t }: EmailLocalization, name: string | null): string {
|
|
16
|
+
return name ? t.greeting({ name }) : t.greetingWithoutName
|
|
17
|
+
}
|
|
@@ -9,6 +9,10 @@ export type ErrorReportContext<Source extends string = string> = {
|
|
|
9
9
|
requestId?: string
|
|
10
10
|
/** What failed, as the server's log says it; not sent to PostHog, whose report has the error. */
|
|
11
11
|
message?: string
|
|
12
|
+
/** The signed-in user the error happened for, by account ID. */
|
|
13
|
+
userId?: string
|
|
14
|
+
/** The records involved, by kind, such as `{ documentId }`; IDs only, never their contents. */
|
|
15
|
+
resources?: Readonly<Record<string, string>>
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
/** Sends a caught error where it is seen; it never rejects. */
|
|
@@ -17,12 +21,27 @@ export type ErrorReporter<Source extends string = string> = (
|
|
|
17
21
|
context: ErrorReportContext<Source>
|
|
18
22
|
) => Promise<void>
|
|
19
23
|
|
|
24
|
+
/** A record kind as PostHog's properties name it: `documentId` as `document_id`. */
|
|
25
|
+
function propertyName(kind: string): string {
|
|
26
|
+
return kind.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The context's record IDs as report properties. */
|
|
30
|
+
function resourceProperties(resources: Readonly<Record<string, string>> = {}) {
|
|
31
|
+
return Object.fromEntries(Object.entries(resources).map(([kind, id]) => [propertyName(kind), id]))
|
|
32
|
+
}
|
|
33
|
+
|
|
20
34
|
export type PostHogErrorReporterOptions = {
|
|
21
35
|
/** The project API key, or how to read it; a key that cannot be read yet is read again later. */
|
|
22
36
|
key: string | (() => Promise<string>)
|
|
23
37
|
host: string
|
|
24
|
-
/** Sent with every report: which service and deployment report
|
|
38
|
+
/** Sent with every report: which service and deployment report. */
|
|
25
39
|
properties: Record<string, string>
|
|
40
|
+
/**
|
|
41
|
+
* Also send the context's account and record IDs: the user as the report's `distinct_id`, the
|
|
42
|
+
* records as `document_id` and the like. Off, a report names neither, as it always did.
|
|
43
|
+
*/
|
|
44
|
+
includeIds?: boolean
|
|
26
45
|
/** The property that names the context's `source`, such as `cloud_source`. */
|
|
27
46
|
sourceProperty: string
|
|
28
47
|
/** Names the service in its own log, such as `Cloud`. */
|
|
@@ -33,7 +52,8 @@ export type PostHogErrorReporterOptions = {
|
|
|
33
52
|
/**
|
|
34
53
|
* Reports errors to PostHog error tracking, each as it is caught, as a `$exception` with no person
|
|
35
54
|
* profile and no GeoIP. A report carries `properties`, the source, and a request's method and
|
|
36
|
-
* matched route and ID;
|
|
55
|
+
* matched route and ID; with `includeIds`, also the account and record IDs involved. Never a name,
|
|
56
|
+
* an email, an address, or what a request carried.
|
|
37
57
|
*/
|
|
38
58
|
export function createPostHogErrorReporter<Source extends string>(
|
|
39
59
|
options: PostHogErrorReporterOptions
|
|
@@ -65,13 +85,17 @@ export function createPostHogErrorReporter<Source extends string>(
|
|
|
65
85
|
return async (error, context) => {
|
|
66
86
|
try {
|
|
67
87
|
const client = await posthog()
|
|
88
|
+
const ids = options.includeIds === true
|
|
68
89
|
// Undefined request fields are left out of the event's JSON.
|
|
69
|
-
await client.captureExceptionImmediate(error, undefined, {
|
|
90
|
+
await client.captureExceptionImmediate(error, ids ? context.userId : undefined, {
|
|
70
91
|
...options.properties,
|
|
71
92
|
[options.sourceProperty]: context.source,
|
|
72
93
|
http_method: context.method,
|
|
73
94
|
http_route: context.route,
|
|
74
|
-
request_id: context.requestId
|
|
95
|
+
request_id: context.requestId,
|
|
96
|
+
...(ids ? resourceProperties(context.resources) : {}),
|
|
97
|
+
// A user's ID names the report's user, never a person profile in PostHog.
|
|
98
|
+
$process_person_profile: false
|
|
75
99
|
})
|
|
76
100
|
} catch (failure) {
|
|
77
101
|
console.error(`[${logName}] Reporting an error failed:`, failure)
|
package/src/global.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Single-file components as plain TypeScript sees them; vue-tsc reads the components themselves
|
|
2
|
+
// (`bun run typecheck`).
|
|
3
|
+
declare module '*.vue' {
|
|
4
|
+
import type { DefineComponent } from 'vue'
|
|
5
|
+
const component: DefineComponent<object, object, unknown>
|
|
6
|
+
export default component
|
|
7
|
+
}
|
|
@@ -10,6 +10,7 @@ export type CloudflareEmailBinding = {
|
|
|
10
10
|
send(message: {
|
|
11
11
|
to: string
|
|
12
12
|
from: string
|
|
13
|
+
replyTo?: string
|
|
13
14
|
subject: string
|
|
14
15
|
html: string
|
|
15
16
|
text: string
|
|
@@ -50,6 +51,7 @@ export function createCloudflareEmailTransport(
|
|
|
50
51
|
const result = await binding.send({
|
|
51
52
|
to: message.to,
|
|
52
53
|
from: message.from,
|
|
54
|
+
...(message.replyTo ? { replyTo: message.replyTo } : {}),
|
|
53
55
|
subject: message.subject,
|
|
54
56
|
html: message.html,
|
|
55
57
|
text: message.text,
|
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
createConfiguredCloudPolicy,
|
|
8
8
|
relayDocumentLookups,
|
|
9
9
|
reportCloudError,
|
|
10
|
-
type CollaborationRelay
|
|
10
|
+
type CollaborationRelay,
|
|
11
|
+
type CollaborationRelayOptions
|
|
11
12
|
} from '#cloud/server'
|
|
12
13
|
import { DurableObject } from 'cloudflare:workers'
|
|
13
14
|
import type { Context } from 'hono'
|
|
@@ -25,8 +26,16 @@ export interface CollaborationRelayRPC extends DurableObject<CloudflareCloudEnvi
|
|
|
25
26
|
closeDocument(documentId: string): Promise<void>
|
|
26
27
|
/** Tells the document's live rooms its version history changed. */
|
|
27
28
|
announceVersions(documentId: string): Promise<void>
|
|
29
|
+
/** Tells the document's live rooms one of its comment threads changed. */
|
|
30
|
+
announceComments(documentId: string, threadId: string): Promise<void>
|
|
28
31
|
}
|
|
29
32
|
|
|
33
|
+
/** The Durable Object class a Worker exports for collaboration rooms. */
|
|
34
|
+
export type CollaborationRelayObjectClass = new (
|
|
35
|
+
ctx: DurableObjectState,
|
|
36
|
+
env: CloudflareCloudEnvironment
|
|
37
|
+
) => CollaborationRelayRPC
|
|
38
|
+
|
|
30
39
|
const documentIdSchema = v.pipe(v.string(), v.uuid())
|
|
31
40
|
|
|
32
41
|
/**
|
|
@@ -69,7 +78,7 @@ export function relayRoute(jurisdiction?: DurableObjectJurisdiction) {
|
|
|
69
78
|
function configuredRelay(
|
|
70
79
|
{ config }: PreparedCloudflareCloud,
|
|
71
80
|
documentId: string,
|
|
72
|
-
onError:
|
|
81
|
+
onError: NonNullable<CollaborationRelayOptions['onError']>
|
|
73
82
|
): CollaborationRelay {
|
|
74
83
|
// Hyperdrive keeps no session settings and ends queries past its own limit.
|
|
75
84
|
const database = createPostgresCloudDatabase({
|
|
@@ -99,7 +108,7 @@ function configuredRelay(
|
|
|
99
108
|
*/
|
|
100
109
|
export function createCloudflareRelayObject(
|
|
101
110
|
prepare: (env: CloudflareCloudEnvironment) => Promise<PreparedCloudflareCloud>
|
|
102
|
-
) {
|
|
111
|
+
): CollaborationRelayObjectClass {
|
|
103
112
|
return class CollaborationRelayObject
|
|
104
113
|
extends DurableObject<CloudflareCloudEnvironment>
|
|
105
114
|
implements CollaborationRelayRPC
|
|
@@ -116,10 +125,17 @@ export function createCloudflareRelayObject(
|
|
|
116
125
|
sockets: () => this.ctx.getWebSockets(),
|
|
117
126
|
createRelay: async (documentId) => {
|
|
118
127
|
const prepared = await prepare(this.env)
|
|
119
|
-
return configuredRelay(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
)
|
|
128
|
+
return configuredRelay(
|
|
129
|
+
prepared,
|
|
130
|
+
documentId,
|
|
131
|
+
(message, error, { userId, ...resources } = {}) =>
|
|
132
|
+
this.ctx.waitUntil(
|
|
133
|
+
reportCloudError(prepared.reportError, message, error, {
|
|
134
|
+
source: 'relay',
|
|
135
|
+
resources,
|
|
136
|
+
...(userId && { userId })
|
|
137
|
+
})
|
|
138
|
+
)
|
|
123
139
|
)
|
|
124
140
|
}
|
|
125
141
|
})
|
|
@@ -172,5 +188,10 @@ export function createCloudflareRelayObject(
|
|
|
172
188
|
if (!this.#sockets.active) return
|
|
173
189
|
;(await this.#sockets.open(documentId)).announceVersions(documentId)
|
|
174
190
|
}
|
|
191
|
+
|
|
192
|
+
async announceComments(documentId: string, threadId: string) {
|
|
193
|
+
if (!this.#sockets.active) return
|
|
194
|
+
;(await this.#sockets.open(documentId)).announceComments(documentId, threadId)
|
|
195
|
+
}
|
|
175
196
|
}
|
|
176
197
|
}
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"skipLibCheck": true,
|
|
14
14
|
"types": ["@cloudflare/workers-types"],
|
|
15
15
|
"paths": {
|
|
16
|
-
"#cloud/*": ["../../*"]
|
|
16
|
+
"#cloud/*": ["../../*"],
|
|
17
|
+
"@open-pencil/cloud/runtime/cloudflare": ["./index.ts"]
|
|
17
18
|
}
|
|
18
19
|
},
|
|
19
20
|
"include": ["./**/*.ts", "../../../deploy/**/*.ts"],
|
|
@@ -30,6 +30,7 @@ import { cloudflareRayId } from './logging'
|
|
|
30
30
|
import { inMaintenance, maintenanceResponse } from './maintenance'
|
|
31
31
|
import { createCloudflareRelayObject, relayFor, relayRoute } from './relay'
|
|
32
32
|
import { assetSiteFiles } from './site'
|
|
33
|
+
import { provideXMLParser } from './xml'
|
|
33
34
|
|
|
34
35
|
function emailTransport({ config }: PreparedCloudflareCloud, env: CloudflareCloudEnvironment) {
|
|
35
36
|
if (config.emailTransport !== 'cloudflare') return undefined
|
|
@@ -73,6 +74,7 @@ function cloudServices(
|
|
|
73
74
|
const queued = createTransactionalEmailService(database, {
|
|
74
75
|
encryptionSecret: config.authSecret,
|
|
75
76
|
from: config.emailFrom ?? '',
|
|
77
|
+
replyTo: config.emailReplyTo,
|
|
76
78
|
transport
|
|
77
79
|
})
|
|
78
80
|
// Mail is sent once the request is done rather than by a polling worker, so sign-in links
|
|
@@ -130,7 +132,14 @@ async function runScheduled(
|
|
|
130
132
|
if (config.cleanupEnabled) {
|
|
131
133
|
const policy = createConfiguredCloudPolicy(config, database)
|
|
132
134
|
await runCleanup(
|
|
133
|
-
createCleanupServices(
|
|
135
|
+
createCleanupServices(
|
|
136
|
+
config,
|
|
137
|
+
database,
|
|
138
|
+
objects,
|
|
139
|
+
policy,
|
|
140
|
+
services.reporter,
|
|
141
|
+
services.transport ? services.email : undefined
|
|
142
|
+
),
|
|
134
143
|
cleanupPassOptions(config)
|
|
135
144
|
)
|
|
136
145
|
}
|
|
@@ -157,6 +166,7 @@ export function createCloudflareCloud(
|
|
|
157
166
|
configSource: string,
|
|
158
167
|
{ relayJurisdiction }: CloudflareCloudOptions = {}
|
|
159
168
|
) {
|
|
169
|
+
provideXMLParser()
|
|
160
170
|
const { prepare, reporter } = cloudflareCloudSetup(configSource)
|
|
161
171
|
const relay = (env: CloudflareCloudEnvironment, documentId: string) =>
|
|
162
172
|
relayFor(env, documentId, relayJurisdiction)
|
|
@@ -191,6 +201,9 @@ export function createCloudflareCloud(
|
|
|
191
201
|
runInBackground(relay(c.env, documentId).closeDocument(documentId)),
|
|
192
202
|
onDocumentVersionsChanged: (documentId) =>
|
|
193
203
|
runInBackground(relay(c.env, documentId).announceVersions(documentId)),
|
|
204
|
+
onDocumentCommentsChanged: (documentId, threadId) =>
|
|
205
|
+
runInBackground(relay(c.env, documentId).announceComments(documentId, threadId)),
|
|
206
|
+
runInBackground,
|
|
194
207
|
reportError: services.reporter,
|
|
195
208
|
forwardedRequestId: cloudflareRayId
|
|
196
209
|
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DOMParser, Node } from '@xmldom/xmldom'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Gives the AWS SDK the XML parser it reads S3's answers with. Wrangler bundles the SDK's browser
|
|
5
|
+
* build, which parses XML with the browser's `DOMParser` and `Node`; workerd has neither, so every
|
|
6
|
+
* S3 error would surface as a `ReferenceError` instead of its code. A runtime that has a
|
|
7
|
+
* `DOMParser` keeps its own.
|
|
8
|
+
*/
|
|
9
|
+
export function provideXMLParser(): void {
|
|
10
|
+
if ('DOMParser' in globalThis) return
|
|
11
|
+
Object.assign(globalThis, { DOMParser, Node })
|
|
12
|
+
}
|