@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.
Files changed (280) hide show
  1. package/README.md +2 -1
  2. package/dist/bin/server.mjs +1 -1
  3. package/dist/bin/server.mjs.map +1 -1
  4. package/dist/bin/services.mjs +1 -1
  5. package/dist/bin/services.mjs.map +1 -1
  6. package/dist/client.d.ts +783 -47
  7. package/dist/client.d.ts.map +1 -1
  8. package/dist/client.js +1651 -382
  9. package/dist/client.js.map +1 -1
  10. package/dist/contract.d.ts +2 -2
  11. package/dist/contract.js +2 -2
  12. package/dist/contract2.js +701 -45
  13. package/dist/contract2.js.map +1 -1
  14. package/dist/email.d.ts +2138 -34
  15. package/dist/email.d.ts.map +1 -1
  16. package/dist/email.js +4343 -306
  17. package/dist/email.js.map +1 -1
  18. package/dist/errors.d.ts +2 -0
  19. package/dist/errors.js +61 -0
  20. package/dist/errors.js.map +1 -0
  21. package/dist/index.d.ts +1338 -44
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index2.d.ts +45 -0
  24. package/dist/index2.d.ts.map +1 -0
  25. package/dist/listen.mjs +958 -340
  26. package/dist/listen.mjs.map +1 -1
  27. package/dist/runtime-cloudflare.d.ts +93 -0
  28. package/dist/runtime-cloudflare.d.ts.map +1 -0
  29. package/dist/runtime-cloudflare.js +18032 -0
  30. package/dist/runtime-cloudflare.js.map +1 -0
  31. package/dist/runtime-node.d.mts +12615 -5249
  32. package/dist/runtime-node.d.mts.map +1 -1
  33. package/dist/server.d.ts +17367 -8567
  34. package/dist/server.d.ts.map +1 -1
  35. package/dist/server.js +13587 -7333
  36. package/dist/server.js.map +1 -1
  37. package/dist/server.mjs +11601 -5401
  38. package/dist/server.mjs.map +1 -1
  39. package/dist/server2.mjs +84 -62
  40. package/dist/server2.mjs.map +1 -1
  41. package/package.json +31 -5
  42. package/src/admin/api/routes.ts +263 -190
  43. package/src/admin/audit/service.ts +11 -3
  44. package/src/admin/bootstrap.ts +86 -0
  45. package/src/admin/documents/service.ts +195 -10
  46. package/src/admin/email/service.ts +2 -1
  47. package/src/admin/enrollment/email.ts +17 -3
  48. package/src/admin/enrollment/service.ts +71 -10
  49. package/src/admin/errors.ts +5 -0
  50. package/src/admin/index.ts +1 -0
  51. package/src/admin/reports/service.ts +15 -3
  52. package/src/admin/schema.ts +6 -5
  53. package/src/admin/users/service.ts +173 -16
  54. package/src/client/api.ts +52 -473
  55. package/src/client/auth/client.ts +22 -3
  56. package/src/client/comments.ts +205 -0
  57. package/src/client/community.ts +40 -0
  58. package/src/client/device-authorization.ts +4 -20
  59. package/src/client/discovery.ts +39 -11
  60. package/src/client/documents.ts +160 -0
  61. package/src/client/files/archive.ts +60 -0
  62. package/src/client/files/checksum.ts +7 -0
  63. package/src/client/files/download.ts +122 -0
  64. package/src/client/files/images.ts +89 -0
  65. package/src/client/files/index.ts +15 -0
  66. package/src/client/files/objects.ts +173 -0
  67. package/src/client/files/save.ts +79 -0
  68. package/src/client/index.ts +4 -0
  69. package/src/client/portal/account.ts +73 -3
  70. package/src/client/portal/administration.ts +52 -5
  71. package/src/client/portal/request.ts +6 -2
  72. package/src/client/response.ts +21 -0
  73. package/src/client/schema.ts +8 -0
  74. package/src/client/services.ts +23 -18
  75. package/src/client/sharing.ts +262 -0
  76. package/src/client/tour.ts +44 -0
  77. package/src/client/versions.ts +110 -0
  78. package/src/contract/account.ts +111 -11
  79. package/src/contract/admin/index.ts +48 -3
  80. package/src/contract/billing.ts +235 -0
  81. package/src/contract/collaboration.ts +5 -0
  82. package/src/contract/comments.ts +223 -0
  83. package/src/contract/community.ts +60 -0
  84. package/src/contract/discovery.ts +94 -5
  85. package/src/contract/entitlements.ts +10 -0
  86. package/src/contract/index.ts +64 -5
  87. package/src/contract/links.ts +62 -4
  88. package/src/contract/locale.ts +27 -0
  89. package/src/contract/portal.ts +12 -1
  90. package/src/contract/relay.ts +3 -1
  91. package/src/contract/routes.ts +10 -0
  92. package/src/contract/services.ts +62 -20
  93. package/src/contract/workspaces.ts +5 -0
  94. package/src/email/i18n.ts +174 -0
  95. package/src/email/index.ts +13 -2
  96. package/src/email/locales/ar.json +169 -0
  97. package/src/email/locales/de.json +169 -0
  98. package/src/email/locales/es.json +169 -0
  99. package/src/email/locales/fr.json +169 -0
  100. package/src/email/locales/it.json +169 -0
  101. package/src/email/locales/ja.json +169 -0
  102. package/src/email/locales/pl.json +169 -0
  103. package/src/email/locales/pt-br.json +169 -0
  104. package/src/email/locales/ru.json +169 -0
  105. package/src/email/locales/zh-cn.json +169 -0
  106. package/src/email/messages.ts +235 -0
  107. package/src/email/render.ts +160 -276
  108. package/src/email/samples.ts +142 -0
  109. package/src/email/schema.ts +98 -8
  110. package/src/email/templates/BrandEmail.vue +56 -0
  111. package/src/email/templates/CommentNotification.vue +39 -0
  112. package/src/email/templates/DocumentBlocked.vue +45 -0
  113. package/src/email/templates/DocumentInvitation.vue +24 -0
  114. package/src/email/templates/DocumentReport.vue +32 -0
  115. package/src/email/templates/DocumentReportDecided.vue +36 -0
  116. package/src/email/templates/DocumentReportReceived.vue +18 -0
  117. package/src/email/templates/DocumentRestored.vue +24 -0
  118. package/src/email/templates/EmailChangeRequested.vue +24 -0
  119. package/src/email/templates/EmailRoot.vue +19 -0
  120. package/src/email/templates/EmailText.vue +9 -0
  121. package/src/email/templates/EmailVerification.vue +38 -0
  122. package/src/email/templates/EnrollmentInvitation.vue +53 -0
  123. package/src/email/templates/EnrollmentNotification.vue +24 -0
  124. package/src/email/templates/EnrollmentUpdate.vue +52 -0
  125. package/src/email/templates/NewSignIn.vue +37 -0
  126. package/src/email/templates/PasswordChanged.vue +22 -0
  127. package/src/email/templates/PasswordReset.vue +23 -0
  128. package/src/email/templates/StorageLimitReached.vue +28 -0
  129. package/src/email/templates/TwoStepChanged.vue +47 -0
  130. package/src/email/templates/WaitlistConfirmation.vue +29 -0
  131. package/src/email/templates/WorkspaceInvitation.vue +28 -0
  132. package/src/email/templates/brand.ts +15 -61
  133. package/src/email/templates/localization.ts +17 -0
  134. package/src/errors/index.ts +6 -0
  135. package/src/{server/errors → errors}/posthog.ts +28 -4
  136. package/src/global.d.ts +7 -0
  137. package/src/runtime/cloudflare/email.ts +2 -0
  138. package/src/runtime/cloudflare/relay/index.ts +28 -7
  139. package/src/runtime/cloudflare/tsconfig.json +2 -1
  140. package/src/runtime/cloudflare/worker.ts +14 -1
  141. package/src/runtime/cloudflare/xml.ts +12 -0
  142. package/src/runtime/node/admin.ts +51 -47
  143. package/src/runtime/node/cleanup.ts +5 -1
  144. package/src/runtime/node/email/runtime.ts +1 -0
  145. package/src/runtime/node/email/transport.ts +14 -10
  146. package/src/runtime/node/main.ts +1 -1
  147. package/src/runtime/node/server.ts +20 -4
  148. package/src/runtime/node/services/main.ts +1 -1
  149. package/src/runtime/posthog/errors.ts +5 -2
  150. package/src/runtime/s3/objects.ts +17 -0
  151. package/src/runtime/site/community.ts +101 -0
  152. package/src/runtime/site/server.ts +17 -1
  153. package/src/server/account/actions.ts +3 -1
  154. package/src/server/account/deletion.ts +40 -4
  155. package/src/server/account/routes.ts +305 -253
  156. package/src/server/account/tokens.ts +57 -0
  157. package/src/server/api/router.ts +44 -6
  158. package/src/server/app/checks.ts +89 -0
  159. package/src/server/app/cors.ts +44 -0
  160. package/src/server/app/editors.ts +20 -0
  161. package/src/server/app/index.ts +128 -0
  162. package/src/server/app/indexing.ts +40 -0
  163. package/src/server/app/limiters.ts +53 -0
  164. package/src/server/app/routes.ts +123 -0
  165. package/src/server/app/services.ts +219 -0
  166. package/src/server/auth/access-control.ts +13 -8
  167. package/src/server/auth/access-tokens.ts +62 -0
  168. package/src/server/auth/account.ts +13 -12
  169. package/src/server/auth/activity.ts +7 -2
  170. package/src/server/auth/adapter.ts +36 -3
  171. package/src/server/auth/email.ts +33 -18
  172. package/src/server/auth/endpoints.ts +4 -0
  173. package/src/server/auth/enrollment.ts +116 -0
  174. package/src/server/auth/factory.ts +165 -189
  175. package/src/server/auth/index.ts +1 -1
  176. package/src/server/auth/logger.ts +23 -0
  177. package/src/server/auth/methods.ts +162 -0
  178. package/src/server/auth/mfa-assurance.ts +190 -2
  179. package/src/server/auth/passwords.ts +43 -0
  180. package/src/server/auth/rate-limit.ts +31 -0
  181. package/src/server/auth/runtime.ts +19 -5
  182. package/src/server/auth/session.ts +2 -0
  183. package/src/server/auth/social-providers.ts +70 -24
  184. package/src/server/billing/index.ts +8 -0
  185. package/src/server/billing/notify.ts +55 -0
  186. package/src/server/billing/routes.ts +27 -0
  187. package/src/server/billing/seats.ts +17 -0
  188. package/src/server/billing/tokens.ts +37 -0
  189. package/src/server/cleanup/configured.ts +16 -3
  190. package/src/server/cleanup/documents.ts +5 -2
  191. package/src/server/cleanup/revisions.ts +6 -3
  192. package/src/server/cleanup/uploads.ts +2 -1
  193. package/src/server/cleanup/worker.ts +10 -1
  194. package/src/server/collaboration/relay/connection.ts +7 -2
  195. package/src/server/collaboration/relay/hub.ts +80 -166
  196. package/src/server/collaboration/relay/room.ts +154 -0
  197. package/src/server/collaboration/routes.ts +8 -5
  198. package/src/server/collaboration/service.ts +21 -2
  199. package/src/server/comments/index.ts +9 -0
  200. package/src/server/comments/notify.ts +277 -0
  201. package/src/server/comments/routes.ts +352 -0
  202. package/src/server/comments/rows.ts +249 -0
  203. package/src/server/comments/service.ts +570 -0
  204. package/src/server/community/index.ts +2 -0
  205. package/src/server/community/routes.ts +93 -0
  206. package/src/server/community/service.ts +134 -0
  207. package/src/server/config/deployment.ts +35 -10
  208. package/src/server/config/index.ts +2 -2
  209. package/src/server/config/public.ts +25 -6
  210. package/src/server/config/schema.ts +53 -293
  211. package/src/server/config/toml/schema.ts +330 -0
  212. package/src/server/db/index.ts +3 -1
  213. package/src/server/db/migrate.ts +33 -1
  214. package/src/server/db/migrations/009_access_tokens.ts +47 -0
  215. package/src/server/db/migrations/010_storage_limit_notices.ts +50 -0
  216. package/src/server/db/migrations/011_account_ids.ts +30 -0
  217. package/src/server/db/migrations/012_email_locales.ts +34 -0
  218. package/src/server/db/migrations/013_document_block_emails.ts +40 -0
  219. package/src/server/db/migrations/014_report_replies.ts +28 -0
  220. package/src/server/db/migrations/015_comments.ts +57 -0
  221. package/src/server/db/migrations/016_comment_notifications.ts +76 -0
  222. package/src/server/db/migrations/017_invitation_emails.ts +19 -0
  223. package/src/server/db/migrations/018_enrollment_source.ts +17 -0
  224. package/src/server/db/migrations/schema.ts +26 -1
  225. package/src/server/db/tables.ts +122 -3
  226. package/src/server/db/users.ts +22 -0
  227. package/src/server/documents/access.ts +17 -0
  228. package/src/server/documents/images.ts +6 -1
  229. package/src/server/documents/index.ts +1 -1
  230. package/src/server/documents/limits.ts +7 -1
  231. package/src/server/documents/routes.ts +12 -12
  232. package/src/server/documents/service.ts +31 -407
  233. package/src/server/documents/summary.ts +15 -0
  234. package/src/server/documents/uploads.ts +450 -0
  235. package/src/server/documents/versions/routes.ts +7 -8
  236. package/src/server/documents/versions/service.ts +86 -26
  237. package/src/server/email/invitations.ts +1 -0
  238. package/src/server/email/service.ts +39 -6
  239. package/src/server/email/types.ts +13 -0
  240. package/src/server/errors/index.ts +49 -12
  241. package/src/server/index.ts +27 -6
  242. package/src/server/internal/routes.ts +8 -2
  243. package/src/server/internal/service.ts +10 -0
  244. package/src/server/invitations/budget.ts +3 -1
  245. package/src/server/invitations/index.ts +1 -0
  246. package/src/server/invitations/links.ts +6 -0
  247. package/src/server/invitations/types.ts +5 -1
  248. package/src/server/objects/types.ts +5 -0
  249. package/src/server/pictures/service.ts +3 -1
  250. package/src/server/policy/configured.ts +9 -3
  251. package/src/server/policy/database.ts +13 -2
  252. package/src/server/policy/policy.ts +39 -12
  253. package/src/server/policy/service.ts +71 -52
  254. package/src/server/policy/storage.ts +33 -0
  255. package/src/server/policy/workspace.ts +5 -2
  256. package/src/server/quota/index.ts +6 -0
  257. package/src/server/quota/notices.ts +121 -0
  258. package/src/server/quota/storage.ts +5 -0
  259. package/src/server/rate-limit/middleware.ts +4 -0
  260. package/src/server/reports/index.ts +1 -0
  261. package/src/server/reports/replies.ts +55 -0
  262. package/src/server/reports/routes.ts +5 -3
  263. package/src/server/reports/service.ts +27 -3
  264. package/src/server/services/routes.ts +2 -2
  265. package/src/server/sharing/capabilities/service.ts +3 -4
  266. package/src/server/sharing/document-routes.ts +3 -3
  267. package/src/server/sharing/invitations/service.ts +17 -8
  268. package/src/server/sharing/routes.ts +15 -15
  269. package/src/server/validation.ts +35 -24
  270. package/src/server/workspaces/members.ts +57 -31
  271. package/src/server/workspaces/repository.ts +23 -12
  272. package/src/server/workspaces/routes.ts +8 -8
  273. package/src/services/app.ts +31 -22
  274. package/src/services/config.ts +48 -8
  275. package/src/services/metering.ts +15 -27
  276. package/src/services/usage.ts +6 -14
  277. package/src/email/templates/document-invitation.ts +0 -35
  278. package/src/email/templates/enrollment.ts +0 -27
  279. package/src/email/templates/layout.ts +0 -18
  280. package/src/server/app.ts +0 -453
@@ -1,4 +1,8 @@
1
- import { documentPermissionSchema, workspaceRoleSchema } from '#cloud/contract'
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 =
@@ -9,6 +13,7 @@ export type TransactionalEmailKind =
9
13
  | 'enrollment-approved'
10
14
  | 'enrollment-rejected'
11
15
  | 'enrollment-revoked'
16
+ | 'enrollment-invited'
12
17
  | 'email-verification'
13
18
  | 'password-reset'
14
19
  | 'password-changed'
@@ -16,9 +21,16 @@ export type TransactionalEmailKind =
16
21
  | 'new-sign-in'
17
22
  | 'two-step-changed'
18
23
  | 'document-report'
24
+ | 'storage-limit-reached'
25
+ | 'document-blocked'
26
+ | 'document-restored'
27
+ | 'document-report-received'
28
+ | 'document-report-decided'
29
+ | 'comment-notification'
19
30
 
20
31
  const documentInvitationEmailPayloadSchema = v.object({
21
- inviterName: v.string(),
32
+ /** Null when the inviter's account is gone, so the email says someone invited you. */
33
+ inviterName: v.nullable(v.string()),
22
34
  documentName: v.string(),
23
35
  permission: documentPermissionSchema,
24
36
  expiresAt: v.string(),
@@ -26,7 +38,8 @@ const documentInvitationEmailPayloadSchema = v.object({
26
38
  })
27
39
 
28
40
  const workspaceInvitationEmailPayloadSchema = v.object({
29
- inviterName: v.string(),
41
+ /** Null when the inviter's account is gone, so the email says someone invited you. */
42
+ inviterName: v.nullable(v.string()),
30
43
  workspaceName: v.string(),
31
44
  role: workspaceRoleSchema,
32
45
  expiresAt: v.string(),
@@ -34,8 +47,11 @@ const workspaceInvitationEmailPayloadSchema = v.object({
34
47
  })
35
48
 
36
49
  const enrollmentEmailPayloadSchema = v.object({
37
- name: v.string(),
38
- actionURL: v.string()
50
+ /** Null when the request named no one, so the email greets no one by name. */
51
+ name: v.nullable(v.string()),
52
+ actionURL: v.string(),
53
+ /** An invitation letter to someone from openpencil.dev's waitlist, who asked nowhere else. */
54
+ waitlist: v.optional(v.literal(true))
39
55
  })
40
56
 
41
57
  const adminEnrollmentNotificationPayloadSchema = v.object({
@@ -47,11 +63,67 @@ const adminEnrollmentNotificationPayloadSchema = v.object({
47
63
 
48
64
  const documentReportPayloadSchema = v.object({
49
65
  documentName: v.string(),
50
- reason: v.string(),
66
+ reason: documentReportReasonSchema,
51
67
  description: v.string(),
52
68
  actionURL: v.string()
53
69
  })
54
70
 
71
+ const storageLimitReachedPayloadSchema = v.object({
72
+ name: v.string(),
73
+ usedBytes: v.number(),
74
+ limitBytes: v.number(),
75
+ /** Whether the server sells plans, so the account can get more storage rather than only free it. */
76
+ upgradable: v.boolean(),
77
+ actionURL: v.string()
78
+ })
79
+
80
+ /** To a workspace's owner: an administrator took one of its documents down. */
81
+ const documentBlockedPayloadSchema = v.object({
82
+ /** The owner's name, or null when the account has none. */
83
+ name: v.nullable(v.string()),
84
+ documentName: v.string(),
85
+ /** Why, as the administrator wrote it, or null when they gave no reason. */
86
+ reason: v.nullable(v.string()),
87
+ /** Where to write to contest it: the deployment's abuse address, or null without one. */
88
+ contactEmail: v.nullable(v.pipe(v.string(), v.email())),
89
+ actionURL: v.string()
90
+ })
91
+
92
+ /** To a workspace's owner: a document taken down is back. */
93
+ const documentRestoredPayloadSchema = v.object({
94
+ name: v.nullable(v.string()),
95
+ documentName: v.string(),
96
+ actionURL: v.string()
97
+ })
98
+
99
+ /** To whoever reported a document: their report arrived. */
100
+ const documentReportReceivedPayloadSchema = v.object({ documentName: v.string() })
101
+
102
+ /** To whoever reported a document: what the administrators decided. */
103
+ const documentReportDecidedPayloadSchema = v.object({
104
+ documentName: v.string(),
105
+ /** The document blocked, the report acted on some other way, or the document left as it was. */
106
+ outcome: v.picklist(['blocked', 'actioned', 'dismissed']),
107
+ /** Where to write to disagree: the deployment's abuse address, or null without one. */
108
+ contactEmail: v.nullable(v.pipe(v.string(), v.email()))
109
+ })
110
+
111
+ /** To someone a comment names, or who takes part in its thread: what it says, and where. */
112
+ const commentNotificationPayloadSchema = v.object({
113
+ /** The recipient's name, or null when the account has none. */
114
+ name: v.nullable(v.string()),
115
+ /** Who wrote the comment, or null when the account has no name. */
116
+ authorName: v.nullable(v.string()),
117
+ documentName: v.string(),
118
+ /** The comment names the recipient, or answers a thread they take part in. */
119
+ reason: v.picklist(['mention', 'reply']),
120
+ /** The start of what the comment says. */
121
+ excerpt: v.string(),
122
+ actionURL: v.string(),
123
+ /** Where the recipient chooses which comments they hear about. */
124
+ settingsURL: v.string()
125
+ })
126
+
55
127
  const authenticationEmailPayloadSchema = v.object({
56
128
  name: v.string(),
57
129
  actionURL: v.optional(v.string()),
@@ -81,12 +153,15 @@ export const twoStepChangeSchema = v.picklist([
81
153
  'authenticator-off',
82
154
  'passkey-added',
83
155
  'passkey-removed',
84
- 'reset-by-administrator'
156
+ 'reset-by-administrator',
157
+ 'sign-in-method-removed'
85
158
  ])
86
159
 
87
160
  const twoStepChangedPayloadSchema = v.object({
88
161
  name: v.string(),
89
162
  change: twoStepChangeSchema,
163
+ /** For a removed sign-in method, which: `credential` for a password, or a provider. */
164
+ method: v.optional(v.string()),
90
165
  actionURL: v.string()
91
166
  })
92
167
 
@@ -105,13 +180,20 @@ export const transactionalEmailContentSchema = v.variant('kind', [
105
180
  content('enrollment-approved', enrollmentEmailPayloadSchema),
106
181
  content('enrollment-rejected', enrollmentEmailPayloadSchema),
107
182
  content('enrollment-revoked', enrollmentEmailPayloadSchema),
183
+ content('enrollment-invited', enrollmentEmailPayloadSchema),
108
184
  content('email-verification', authenticationEmailPayloadSchema),
109
185
  content('password-reset', authenticationEmailPayloadSchema),
110
186
  content('password-changed', authenticationEmailPayloadSchema),
111
187
  content('email-change-requested', emailChangeRequestedPayloadSchema),
112
188
  content('new-sign-in', newSignInPayloadSchema),
113
189
  content('two-step-changed', twoStepChangedPayloadSchema),
114
- content('document-report', documentReportPayloadSchema)
190
+ content('document-report', documentReportPayloadSchema),
191
+ content('storage-limit-reached', storageLimitReachedPayloadSchema),
192
+ content('document-blocked', documentBlockedPayloadSchema),
193
+ content('document-restored', documentRestoredPayloadSchema),
194
+ content('document-report-received', documentReportReceivedPayloadSchema),
195
+ content('document-report-decided', documentReportDecidedPayloadSchema),
196
+ content('comment-notification', commentNotificationPayloadSchema)
115
197
  ])
116
198
 
117
199
  /** A transactional email's kind with the payload that kind renders. */
@@ -152,3 +234,11 @@ export type RenderedTransactionalEmail = {
152
234
  text: string
153
235
  }
154
236
  export type DocumentReportPayload = v.InferOutput<typeof documentReportPayloadSchema>
237
+ export type StorageLimitReachedPayload = v.InferOutput<typeof storageLimitReachedPayloadSchema>
238
+ export type DocumentBlockedPayload = v.InferOutput<typeof documentBlockedPayloadSchema>
239
+ export type DocumentRestoredPayload = v.InferOutput<typeof documentRestoredPayloadSchema>
240
+ export type DocumentReportReceivedPayload = v.InferOutput<
241
+ typeof documentReportReceivedPayloadSchema
242
+ >
243
+ export type DocumentReportDecidedPayload = v.InferOutput<typeof documentReportDecidedPayloadSchema>
244
+ export type CommentNotificationPayload = v.InferOutput<typeof commentNotificationPayloadSchema>
@@ -0,0 +1,56 @@
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, the sender's name in `signature` when a
23
+ * person writes, and small print in `note`.
24
+ */
25
+ const { preview, heading, action } = defineProps<{
26
+ /** The line mail clients show beside the subject. */
27
+ preview: string
28
+ heading: string
29
+ /** The one thing the email asks the reader to do, if there is one. */
30
+ action?: { label: string; url: string }
31
+ }>()
32
+
33
+ const { locale, dir, t } = useEmailLocalization()
34
+ </script>
35
+
36
+ <template>
37
+ <HTML :lang="locale" :dir="dir">
38
+ <Head />
39
+ <Preview>{{ preview }}</Preview>
40
+ <Body :style="styles.body">
41
+ <Container :style="styles.card">
42
+ <Img :src="LOGO_URL" :width="44" :height="44" alt="OpenPencil" :style="styles.logo" />
43
+ <Heading as="h1" :style="styles.heading">{{ heading }}</Heading>
44
+ <slot />
45
+ <Section v-if="action" :style="styles.action">
46
+ <Button :href="action.url" :style="styles.button">{{ action.label }}</Button>
47
+ </Section>
48
+ <Text v-if="$slots.signature" :style="styles.signature"><slot name="signature" /></Text>
49
+ <Text v-if="$slots.note" :style="styles.note"><slot name="note" /></Text>
50
+ </Container>
51
+ <Text :style="styles.footer">
52
+ {{ t.footer }} · <Link :href="SITE_URL" :style="styles.footerLink">openpencil.dev</Link>
53
+ </Text>
54
+ </Body>
55
+ </HTML>
56
+ </template>
@@ -0,0 +1,39 @@
1
+ <script setup lang="ts">
2
+ import { Link } from '@vue-email/components'
3
+
4
+ import type { CommentNotificationPayload } 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
+ /** To someone a comment names, or who takes part in its thread: who wrote what, and where. */
11
+ const { payload } = defineProps<{ payload: CommentNotificationPayload }>()
12
+
13
+ const localization = useEmailLocalization()
14
+ const { t } = localization
15
+ const words = {
16
+ author: payload.authorName ?? t.commentSomeone,
17
+ document: payload.documentName
18
+ }
19
+ const lead = payload.reason === 'mention' ? t.commentMention(words) : t.commentReply(words)
20
+ // The translation places the link inside its sentence, where `{link}` is.
21
+ const [beforeLink = '', afterLink = ''] = t.commentSettings.split('{link}')
22
+ </script>
23
+
24
+ <template>
25
+ <BrandEmail
26
+ :preview="payload.excerpt"
27
+ :heading="payload.reason === 'mention' ? t.commentMentionHeading : t.commentReplyHeading"
28
+ :action="{ label: t.openComment, url: payload.actionURL }"
29
+ >
30
+ <EmailText>{{ greeting(localization, payload.name) }}</EmailText>
31
+ <EmailText>{{ lead }}</EmailText>
32
+ <EmailText>“{{ payload.excerpt }}”</EmailText>
33
+ <template #note>
34
+ {{ beforeLink
35
+ }}<Link :href="payload.settingsURL" :style="styles.link">{{ t.commentSettingsLink }}</Link
36
+ >{{ afterLink }}
37
+ </template>
38
+ </BrandEmail>
39
+ </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,9 @@
1
+ <script setup lang="ts">
2
+ import { Text } from '@vue-email/components'
3
+
4
+ import { styles } from './brand'
5
+ </script>
6
+
7
+ <template>
8
+ <Text :style="styles.text"><slot /></Text>
9
+ </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,53 @@
1
+ <script setup lang="ts">
2
+ import { Link } from '@vue-email/components'
3
+
4
+ import type { EnrollmentEmailPayload } from '../schema'
5
+ import { BUG_REPORT_URL, DESKTOP_BETA_URL, styles } from './brand'
6
+ import BrandEmail from './BrandEmail.vue'
7
+ import EmailText from './EmailText.vue'
8
+ import { greeting, useEmailLocalization } from './localization'
9
+
10
+ /**
11
+ * A letter from OpenPencil's founder to someone who asked for the official Cloud before it opened,
12
+ * or joined its waitlist on openpencil.dev: thanks for waiting, it is a beta, and where to say what
13
+ * breaks. Replies reach a person, through the deployment's reply address. The waitlist gave no
14
+ * name, so its letter opens with the thanks rather than a greeting.
15
+ */
16
+ const { payload } = defineProps<{ payload: EnrollmentEmailPayload }>()
17
+
18
+ const localization = useEmailLocalization()
19
+ const { t } = localization
20
+ // Each translation places its link inside the sentence, where `{link}` is.
21
+ // The waitlist letter already says Cloud is open, so its beta paragraph starts at the beta.
22
+ const beta = payload.waitlist ? t.invitationWaitlistBeta : t.invitationBeta
23
+ const [beforeIssue = '', afterIssue = ''] = beta.split('{link}')
24
+ const [beforeDownload = '', afterDownload = ''] = t.invitationDesktop.split('{link}')
25
+ </script>
26
+
27
+ <template>
28
+ <BrandEmail
29
+ :preview="payload.waitlist ? t.invitationWaitlistPreview : t.invitationPreview"
30
+ :heading="t.invitationHeading"
31
+ :action="{ label: t.invitationAction, url: payload.actionURL }"
32
+ >
33
+ <EmailText v-if="payload.waitlist">{{ t.invitationWaitlistThanks }}</EmailText>
34
+ <template v-else>
35
+ <EmailText>{{ greeting(localization, payload.name) }}</EmailText>
36
+ <EmailText>{{ t.invitationThanks }}</EmailText>
37
+ </template>
38
+ <EmailText>
39
+ {{ beforeIssue
40
+ }}<Link :href="BUG_REPORT_URL" :style="styles.link">{{ t.invitationIssueLink }}</Link
41
+ >{{ afterIssue }}
42
+ </EmailText>
43
+ <EmailText>
44
+ {{ beforeDownload
45
+ }}<Link :href="DESKTOP_BETA_URL" :style="styles.link">{{ t.invitationDownloadLink }}</Link
46
+ >{{ afterDownload }}
47
+ </EmailText>
48
+ <template #signature>
49
+ {{ t.invitationSignatureName }}<br />
50
+ {{ t.invitationSignatureRole }}
51
+ </template>
52
+ </BrandEmail>
53
+ </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>