@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.
Files changed (206) 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 +296 -27
  7. package/dist/client.d.ts.map +1 -1
  8. package/dist/client.js +649 -295
  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 +331 -21
  13. package/dist/contract2.js.map +1 -1
  14. package/dist/email.d.ts +1773 -32
  15. package/dist/email.d.ts.map +1 -1
  16. package/dist/email.js +3478 -288
  17. package/dist/email.js.map +1 -1
  18. package/dist/errors.d.ts +2 -0
  19. package/dist/errors.js +48 -0
  20. package/dist/errors.js.map +1 -0
  21. package/dist/index.d.ts +466 -13
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index2.d.ts +35 -0
  24. package/dist/index2.d.ts.map +1 -0
  25. package/dist/listen.mjs +447 -290
  26. package/dist/listen.mjs.map +1 -1
  27. package/dist/runtime-cloudflare.d.ts +89 -0
  28. package/dist/runtime-cloudflare.d.ts.map +1 -0
  29. package/dist/runtime-cloudflare.js +15667 -0
  30. package/dist/runtime-cloudflare.js.map +1 -0
  31. package/dist/runtime-node.d.mts +2963 -294
  32. package/dist/runtime-node.d.mts.map +1 -1
  33. package/dist/server.d.ts +3473 -842
  34. package/dist/server.d.ts.map +1 -1
  35. package/dist/server.js +12187 -8244
  36. package/dist/server.js.map +1 -1
  37. package/dist/server.mjs +7739 -3548
  38. package/dist/server.mjs.map +1 -1
  39. package/dist/server2.mjs +5 -5
  40. package/dist/server2.mjs.map +1 -1
  41. package/package.json +22 -5
  42. package/src/admin/audit/service.ts +2 -2
  43. package/src/admin/documents/service.ts +76 -6
  44. package/src/admin/reports/service.ts +7 -1
  45. package/src/client/api.ts +23 -471
  46. package/src/client/auth/client.ts +22 -3
  47. package/src/client/billing.ts +80 -0
  48. package/src/client/community.ts +40 -0
  49. package/src/client/discovery.ts +35 -9
  50. package/src/client/documents.ts +160 -0
  51. package/src/client/index.ts +7 -0
  52. package/src/client/portal/account.ts +54 -2
  53. package/src/client/portal/request.ts +2 -0
  54. package/src/client/response.ts +21 -0
  55. package/src/client/schema.ts +8 -0
  56. package/src/client/services.ts +23 -18
  57. package/src/client/sharing.ts +262 -0
  58. package/src/client/versions.ts +104 -0
  59. package/src/contract/account.ts +50 -0
  60. package/src/contract/billing.ts +166 -0
  61. package/src/contract/collaboration.ts +5 -0
  62. package/src/contract/community.ts +60 -0
  63. package/src/contract/discovery.ts +63 -2
  64. package/src/contract/entitlements.ts +10 -0
  65. package/src/contract/index.ts +54 -5
  66. package/src/contract/links.ts +57 -4
  67. package/src/contract/locale.ts +27 -0
  68. package/src/contract/portal.ts +12 -1
  69. package/src/contract/routes.ts +10 -0
  70. package/src/contract/services.ts +18 -16
  71. package/src/email/i18n.ts +174 -0
  72. package/src/email/index.ts +13 -2
  73. package/src/email/locales/ar.json +141 -0
  74. package/src/email/locales/de.json +141 -0
  75. package/src/email/locales/es.json +141 -0
  76. package/src/email/locales/fr.json +141 -0
  77. package/src/email/locales/it.json +141 -0
  78. package/src/email/locales/ja.json +141 -0
  79. package/src/email/locales/pl.json +141 -0
  80. package/src/email/locales/pt-br.json +141 -0
  81. package/src/email/locales/ru.json +141 -0
  82. package/src/email/locales/zh-cn.json +141 -0
  83. package/src/email/messages.ts +200 -0
  84. package/src/email/render.ts +142 -276
  85. package/src/email/samples.ts +115 -0
  86. package/src/email/schema.ts +70 -6
  87. package/src/email/templates/BrandEmail.vue +54 -0
  88. package/src/email/templates/DocumentBlocked.vue +45 -0
  89. package/src/email/templates/DocumentInvitation.vue +24 -0
  90. package/src/email/templates/DocumentReport.vue +32 -0
  91. package/src/email/templates/DocumentReportDecided.vue +36 -0
  92. package/src/email/templates/DocumentReportReceived.vue +18 -0
  93. package/src/email/templates/DocumentRestored.vue +24 -0
  94. package/src/email/templates/EmailChangeRequested.vue +24 -0
  95. package/src/email/templates/EmailRoot.vue +19 -0
  96. package/src/email/templates/EmailText.vue +9 -0
  97. package/src/email/templates/EmailVerification.vue +38 -0
  98. package/src/email/templates/EnrollmentNotification.vue +24 -0
  99. package/src/email/templates/EnrollmentUpdate.vue +52 -0
  100. package/src/email/templates/NewSignIn.vue +37 -0
  101. package/src/email/templates/PasswordChanged.vue +22 -0
  102. package/src/email/templates/PasswordReset.vue +23 -0
  103. package/src/email/templates/StorageLimitReached.vue +28 -0
  104. package/src/email/templates/TwoStepChanged.vue +32 -0
  105. package/src/email/templates/WaitlistConfirmation.vue +29 -0
  106. package/src/email/templates/WorkspaceInvitation.vue +28 -0
  107. package/src/email/templates/brand.ts +9 -61
  108. package/src/email/templates/localization.ts +17 -0
  109. package/src/errors/index.ts +6 -0
  110. package/src/global.d.ts +7 -0
  111. package/src/runtime/cloudflare/relay/index.ts +7 -1
  112. package/src/runtime/cloudflare/tsconfig.json +2 -1
  113. package/src/runtime/cloudflare/worker.ts +8 -1
  114. package/src/runtime/node/cleanup.ts +5 -1
  115. package/src/runtime/node/email/transport.ts +13 -10
  116. package/src/runtime/node/main.ts +1 -1
  117. package/src/runtime/node/server.ts +12 -2
  118. package/src/runtime/node/services/main.ts +1 -1
  119. package/src/runtime/posthog/errors.ts +2 -1
  120. package/src/runtime/s3/objects.ts +17 -0
  121. package/src/runtime/site/community.ts +101 -0
  122. package/src/runtime/site/server.ts +17 -1
  123. package/src/server/account/deletion.ts +2 -0
  124. package/src/server/account/routes.ts +271 -240
  125. package/src/server/account/tokens.ts +57 -0
  126. package/src/server/api/router.ts +23 -0
  127. package/src/server/app/checks.ts +84 -0
  128. package/src/server/app/editors.ts +20 -0
  129. package/src/server/app/index.ts +128 -0
  130. package/src/server/app/indexing.ts +40 -0
  131. package/src/server/app/limiters.ts +53 -0
  132. package/src/server/app/routes.ts +114 -0
  133. package/src/server/app/services.ts +185 -0
  134. package/src/server/auth/access-tokens.ts +62 -0
  135. package/src/server/auth/adapter.ts +21 -1
  136. package/src/server/auth/email.ts +4 -1
  137. package/src/server/auth/enrollment.ts +116 -0
  138. package/src/server/auth/factory.ts +88 -131
  139. package/src/server/auth/logger.ts +23 -0
  140. package/src/server/auth/mfa-assurance.ts +51 -0
  141. package/src/server/auth/passwords.ts +43 -0
  142. package/src/server/auth/session.ts +2 -0
  143. package/src/server/billing/index.ts +6 -0
  144. package/src/server/billing/routes.ts +27 -0
  145. package/src/server/billing/tokens.ts +37 -0
  146. package/src/server/cleanup/configured.ts +16 -3
  147. package/src/server/cleanup/worker.ts +10 -1
  148. package/src/server/collaboration/relay/hub.ts +25 -142
  149. package/src/server/collaboration/relay/room.ts +154 -0
  150. package/src/server/collaboration/service.ts +21 -2
  151. package/src/server/community/index.ts +2 -0
  152. package/src/server/community/routes.ts +93 -0
  153. package/src/server/community/service.ts +134 -0
  154. package/src/server/config/deployment.ts +17 -5
  155. package/src/server/config/index.ts +1 -1
  156. package/src/server/config/public.ts +7 -1
  157. package/src/server/config/schema.ts +40 -292
  158. package/src/server/config/toml/schema.ts +307 -0
  159. package/src/server/db/index.ts +1 -0
  160. package/src/server/db/migrate.ts +13 -1
  161. package/src/server/db/migrations/009_access_tokens.ts +47 -0
  162. package/src/server/db/migrations/010_storage_limit_notices.ts +50 -0
  163. package/src/server/db/migrations/011_account_ids.ts +30 -0
  164. package/src/server/db/migrations/012_email_locales.ts +34 -0
  165. package/src/server/db/migrations/013_document_block_emails.ts +40 -0
  166. package/src/server/db/migrations/014_report_replies.ts +28 -0
  167. package/src/server/db/migrations/schema.ts +26 -1
  168. package/src/server/db/tables.ts +30 -1
  169. package/src/server/db/users.ts +22 -0
  170. package/src/server/documents/index.ts +1 -1
  171. package/src/server/documents/limits.ts +7 -1
  172. package/src/server/documents/service.ts +12 -402
  173. package/src/server/documents/uploads.ts +450 -0
  174. package/src/server/documents/versions/service.ts +81 -24
  175. package/src/server/email/invitations.ts +1 -0
  176. package/src/server/email/service.ts +31 -4
  177. package/src/server/email/types.ts +12 -0
  178. package/src/server/errors/index.ts +1 -9
  179. package/src/server/index.ts +12 -5
  180. package/src/server/invitations/types.ts +5 -1
  181. package/src/server/objects/types.ts +5 -0
  182. package/src/server/policy/configured.ts +9 -3
  183. package/src/server/policy/database.ts +13 -2
  184. package/src/server/policy/policy.ts +39 -12
  185. package/src/server/policy/service.ts +71 -52
  186. package/src/server/policy/storage.ts +33 -0
  187. package/src/server/quota/index.ts +6 -0
  188. package/src/server/quota/notices.ts +121 -0
  189. package/src/server/quota/storage.ts +5 -0
  190. package/src/server/rate-limit/middleware.ts +4 -0
  191. package/src/server/reports/index.ts +1 -0
  192. package/src/server/reports/replies.ts +55 -0
  193. package/src/server/reports/routes.ts +3 -1
  194. package/src/server/reports/service.ts +24 -2
  195. package/src/server/sharing/capabilities/service.ts +2 -3
  196. package/src/server/sharing/invitations/service.ts +14 -4
  197. package/src/server/validation.ts +3 -0
  198. package/src/server/workspaces/members.ts +7 -19
  199. package/src/services/app.ts +1 -3
  200. package/src/services/config.ts +1 -0
  201. package/src/services/usage.ts +6 -14
  202. package/src/email/templates/document-invitation.ts +0 -35
  203. package/src/email/templates/enrollment.ts +0 -27
  204. package/src/email/templates/layout.ts +0 -18
  205. package/src/server/app.ts +0 -453
  206. /package/src/{server/errors → errors}/posthog.ts +0 -0
@@ -1,4 +1,5 @@
1
1
  import type { FileDocumentReportInput } from '#cloud/contract'
2
+ import type { EmailLocale } from '#cloud/email'
2
3
  import type { CloudActor } from '#cloud/server/auth'
3
4
  import type { CloudDatabase } from '#cloud/server/db'
4
5
  import type { TransactionalEmailService } from '#cloud/server/email'
@@ -41,7 +42,13 @@ export function createDocumentReportService(
41
42
  * tells the deployment's administrators. It answers nothing about the document, so a report
42
43
  * never tells its reporter more than the link already did.
43
44
  */
44
- async file(shareId: string, input: FileDocumentReportInput, actor?: CloudActor): Promise<void> {
45
+ async file(
46
+ shareId: string,
47
+ input: FileDocumentReportInput,
48
+ actor?: CloudActor,
49
+ /** The language the reporter's browser asked for, to reply in without an account's own. */
50
+ replyLocale: EmailLocale | null = null
51
+ ): Promise<void> {
45
52
  const resolved = await options.sharing.resolveShare(
46
53
  shareId,
47
54
  { secret: input.secret, guestId: input.guestId },
@@ -80,6 +87,7 @@ export function createDocumentReportService(
80
87
  throw new DocumentReportLimitError()
81
88
  }
82
89
  const id = crypto.randomUUID()
90
+ const replyEmail = input.replyEmail ?? actor?.email ?? null
83
91
  await transaction
84
92
  .insertInto('documentReport')
85
93
  .values({
@@ -88,7 +96,8 @@ export function createDocumentReportService(
88
96
  shareId,
89
97
  reporterUserId,
90
98
  reporterGuestId,
91
- replyEmail: input.replyEmail ?? actor?.email ?? null,
99
+ replyEmail,
100
+ replyLocale,
92
101
  reason: input.reason,
93
102
  description: input.description
94
103
  })
@@ -99,6 +108,19 @@ export function createDocumentReportService(
99
108
  .select('name')
100
109
  .where('id', '=', resolved.documentId)
101
110
  .executeTakeFirstOrThrow()
111
+ // Whoever left an address hears that the report arrived, and later what was decided.
112
+ if (replyEmail) {
113
+ await options.email.enqueue(
114
+ {
115
+ idempotencyKey: `document-report-received/${id}`,
116
+ kind: 'document-report-received',
117
+ recipientEmail: replyEmail,
118
+ fallbackLocale: replyLocale,
119
+ payload: { documentName: document.name }
120
+ },
121
+ transaction
122
+ )
123
+ }
102
124
  for (const recipientEmail of options.adminRecipients) {
103
125
  await options.email.enqueue(
104
126
  {
@@ -6,7 +6,7 @@ import type {
6
6
  UpdateDocumentShareInput
7
7
  } from '#cloud/contract'
8
8
  import type { CloudActor } from '#cloud/server/auth'
9
- import type { CloudDatabase } from '#cloud/server/db'
9
+ import { isBannedNow, type CloudDatabase } from '#cloud/server/db'
10
10
  import { DocumentNotFoundError } from '#cloud/server/documents/errors'
11
11
  import { CLOUD_FEATURE_KEYS } from '#cloud/server/policy/keys'
12
12
  import type { CloudPolicy } from '#cloud/server/policy/policy'
@@ -39,8 +39,7 @@ async function anyBanned(database: Kysely<CloudDatabase>, userIds: string[]): Pr
39
39
  .selectFrom('user')
40
40
  .select('id')
41
41
  .where('id', 'in', accounts)
42
- .where('banned', '=', true)
43
- .where((user) => user.or([user('banExpires', 'is', null), user('banExpires', '>', new Date())]))
42
+ .where(isBannedNow)
44
43
  .executeTakeFirst()
45
44
  return banned !== undefined
46
45
  }
@@ -13,6 +13,7 @@ import type { CloudDatabase } from '#cloud/server/db'
13
13
  import { DocumentNotFoundError } from '#cloud/server/documents/errors'
14
14
  import {
15
15
  spendInvitationBudget,
16
+ type DocumentInvitationMessage,
16
17
  type InvitationDelivery,
17
18
  type InvitationOutbox
18
19
  } from '#cloud/server/invitations'
@@ -140,26 +141,35 @@ export function createInvitationService(
140
141
  ? await Promise.all([
141
142
  database
142
143
  .selectFrom('user')
143
- .select('name')
144
+ .select(['name', 'locale'])
144
145
  .where('id', '=', userId)
145
146
  .executeTakeFirst(),
146
147
  database
147
148
  .selectFrom('document')
148
149
  .select('name')
149
150
  .where('id', '=', documentId)
150
- .executeTakeFirstOrThrow()
151
+ .executeTakeFirstOrThrow(),
152
+ database
153
+ .selectFrom('user')
154
+ .select('locale')
155
+ .where((expression) =>
156
+ expression(expression.fn('lower', [expression.ref('email')]), '=', input.email)
157
+ )
158
+ .executeTakeFirst()
151
159
  ])
152
160
  : null
153
161
  const acceptanceURL =
154
162
  deliveryContext && options.publicURL
155
163
  ? cloudInvitationURL(options.publicURL, id, token)
156
164
  : null
157
- const message =
165
+ const message: DocumentInvitationMessage | null =
158
166
  deliveryContext && acceptanceURL
159
167
  ? {
160
168
  deliveryId: id,
161
169
  recipientEmail: input.email,
162
- inviterName: deliveryContext[0]?.name ?? 'An OpenPencil user',
170
+ // Someone without an account yet reads the inviter's language.
171
+ locale: deliveryContext[2]?.locale ?? deliveryContext[0]?.locale ?? 'en',
172
+ inviterName: deliveryContext[0]?.name ?? null,
163
173
  documentName: deliveryContext[1].name,
164
174
  permission: input.permission,
165
175
  expiresAt: expiresAt.toISOString(),
@@ -68,6 +68,9 @@ export const workspaceMemberParams = validatedParams(
68
68
  )
69
69
  export const accountParams = validatedParams(v.object({ userId: uuidParamSchema }))
70
70
  export const shareParams = validatedParams(v.object({ shareId: uuidParamSchema }))
71
+ export const communityThumbnailParams = validatedParams(
72
+ v.object({ documentId: uuidParamSchema, revisionId: uuidParamSchema })
73
+ )
71
74
  export const invitationParams = validatedParams(v.object({ invitationId: uuidParamSchema }))
72
75
  export const invitationContinuationParams = validatedParams(
73
76
  v.object({ continuationId: textParamSchema })
@@ -10,7 +10,7 @@ import type {
10
10
  import { cloudInvitationURL } from '#cloud/contract'
11
11
  import type { CloudActor } from '#cloud/server/auth'
12
12
  import { workspaceRoleCan, type AccessRequest } from '#cloud/server/auth/access-control'
13
- import type { CloudDatabase } from '#cloud/server/db'
13
+ import { userIdText, type CloudDatabase } from '#cloud/server/db'
14
14
  import type { TransactionalEmailService } from '#cloud/server/email/types'
15
15
  import { spendInvitationBudget } from '#cloud/server/invitations'
16
16
  import { lockStorageAllowance } from '#cloud/server/quota/storage'
@@ -199,15 +199,7 @@ export function createWorkspaceMemberService(
199
199
  function memberUsers(workspaceId: string) {
200
200
  return database
201
201
  .selectFrom('workspaceMember')
202
- .innerJoin('user', (join) =>
203
- join.on((expression) =>
204
- expression(
205
- expression.cast(expression.ref('user.id'), 'text'),
206
- '=',
207
- expression.ref('workspaceMember.userId')
208
- )
209
- )
210
- )
202
+ .innerJoin('user', (join) => join.onRef(userIdText, '=', 'workspaceMember.userId'))
211
203
  .where('workspaceMember.workspaceId', '=', workspaceId)
212
204
  }
213
205
 
@@ -231,7 +223,7 @@ export function createWorkspaceMemberService(
231
223
  if (existing) throw new WorkspaceAlreadyMemberError()
232
224
  const inviter = await database
233
225
  .selectFrom('user')
234
- .select('name')
226
+ .select(['name', 'locale'])
235
227
  .where('id', '=', userId)
236
228
  .executeTakeFirst()
237
229
  const id = crypto.randomUUID()
@@ -268,8 +260,10 @@ export function createWorkspaceMemberService(
268
260
  idempotencyKey: `workspace-invitation/${id}`,
269
261
  kind: 'workspace-invitation',
270
262
  recipientEmail: input.email,
263
+ // Someone without an account yet reads the inviter's language.
264
+ fallbackLocale: inviter?.locale,
271
265
  payload: {
272
- inviterName: inviter?.name ?? 'An OpenPencil user',
266
+ inviterName: inviter?.name ?? null,
273
267
  workspaceName: workspace.name,
274
268
  role: input.role,
275
269
  expiresAt: expiresAt.toISOString(),
@@ -314,13 +308,7 @@ export function createWorkspaceMemberService(
314
308
  ? await database
315
309
  .selectFrom('workspaceInvitation')
316
310
  .leftJoin('user', (join) =>
317
- join.on((expression) =>
318
- expression(
319
- expression.cast(expression.ref('user.id'), 'text'),
320
- '=',
321
- expression.ref('workspaceInvitation.invitedBy')
322
- )
323
- )
311
+ join.onRef(userIdText, '=', 'workspaceInvitation.invitedBy')
324
312
  )
325
313
  .select([
326
314
  'workspaceInvitation.id',
@@ -232,9 +232,7 @@ export function createServicesApp(services: ServicesAppDependencies) {
232
232
  await usage.record({
233
233
  id: crypto.randomUUID(),
234
234
  workspaceId: claims.workspaceId,
235
- // A token from a Cloud without accounts names none; the row then counts for its
236
- // workspace, and once Cloud upgrades, for that workspace's owner as well.
237
- accountId: claims.accountId ?? null,
235
+ accountId: claims.accountId,
238
236
  userId: claims.sub,
239
237
  modelId: model.id,
240
238
  inputTokens: tokens.inputTokens,
@@ -112,6 +112,7 @@ export function parseServicesConfig(
112
112
  maximumConcurrentRequests: config.relay.max_concurrent_requests,
113
113
  maximumRequestBytes: config.relay.max_request_bytes,
114
114
  databaseURL: requiredSecret(environment, config.database.url.from_env),
115
+ // Every trailing slash: ufo's withoutTrailingSlash removes only one.
115
116
  upstreamURL: config.upstream.base_url.replace(/\/+$/, ''),
116
117
  upstreamKey: requiredSecret(environment, config.upstream.api_key.from_env),
117
118
  catalog: catalogFrom(config.catalog)
@@ -38,29 +38,21 @@ export class ServicesUsageCursorError extends Error {
38
38
  }
39
39
  }
40
40
 
41
- /**
42
- * Who a request spends for: the account whose allowance it draws on, and the workspace it came
43
- * from, whose requests recorded before accounts carry no account and still count this month.
44
- */
41
+ /** Who a request spends for: the account whose allowance it draws on, and its workspace. */
45
42
  export type CreditSpender = { accountId: string; workspaceId: string }
46
43
 
47
- /** The spender a token names; a token without an account spends its workspace's allowance. */
48
- export function spender(claims: { accountId?: string; workspaceId: string }): CreditSpender {
49
- return { accountId: claims.accountId ?? claims.workspaceId, workspaceId: claims.workspaceId }
44
+ /** The spender a token names. */
45
+ export function spender(claims: CreditSpender): CreditSpender {
46
+ return { accountId: claims.accountId, workspaceId: claims.workspaceId }
50
47
  }
51
48
 
52
49
  export function createServicesUsageStore(database: Kysely<ServicesDatabase>) {
53
- async function spent({ accountId, workspaceId }: CreditSpender, now: Date): Promise<number> {
50
+ async function spent({ accountId }: CreditSpender, now: Date): Promise<number> {
54
51
  const { start, end } = usagePeriod(now)
55
52
  const row = await database
56
53
  .selectFrom('servicesUsage')
57
54
  .select((query) => query.fn.sum<string | number | null>('credits').as('credits'))
58
- .where((usage) =>
59
- usage.or([
60
- usage('accountId', '=', accountId),
61
- usage.and([usage('accountId', 'is', null), usage('workspaceId', '=', workspaceId)])
62
- ])
63
- )
55
+ .where('accountId', '=', accountId)
64
56
  .where('createdAt', '>=', start)
65
57
  .where('createdAt', '<', end)
66
58
  .executeTakeFirst()
@@ -1,35 +0,0 @@
1
- import { defineComponent, type PropType } from 'vue'
2
-
3
- import { transactionalEmailLayout } from './layout'
4
-
5
- export type DocumentInvitationEmailProps = {
6
- inviterName: string
7
- documentName: string
8
- permissionLabel: string
9
- expiresAt: string
10
- acceptanceURL: string
11
- }
12
-
13
- export const DocumentInvitationEmail = defineComponent({
14
- props: {
15
- inviterName: { type: String, required: true },
16
- documentName: { type: String, required: true },
17
- permissionLabel: { type: String, required: true },
18
- expiresAt: { type: String, required: true },
19
- acceptanceURL: { type: String, required: true }
20
- } satisfies Record<
21
- keyof DocumentInvitationEmailProps,
22
- { type: PropType<string>; required: true }
23
- >,
24
- setup(props) {
25
- return () =>
26
- transactionalEmailLayout({
27
- preview: `${props.inviterName} invited you to ${props.permissionLabel} a document`,
28
- heading: 'OpenPencil invitation',
29
- message: `${props.inviterName} invited you to ${props.permissionLabel} “${props.documentName}”.`,
30
- actionLabel: 'Open document',
31
- actionURL: props.acceptanceURL,
32
- footer: `This invitation expires ${props.expiresAt}.`
33
- })
34
- }
35
- })
@@ -1,27 +0,0 @@
1
- import { defineComponent, type PropType } from 'vue'
2
-
3
- import { transactionalEmailLayout } from './layout'
4
-
5
- export type EnrollmentEmailProps = {
6
- heading: string
7
- preview: string
8
- message: string
9
- actionLabel: string
10
- actionURL: string
11
- /** Small print under the button. */
12
- footer?: string
13
- }
14
-
15
- export const EnrollmentEmail = defineComponent({
16
- props: {
17
- heading: { type: String, required: true },
18
- preview: { type: String, required: true },
19
- message: { type: String, required: true },
20
- actionLabel: { type: String, required: true },
21
- actionURL: { type: String, required: true },
22
- footer: { type: String, required: false }
23
- } satisfies Record<keyof EnrollmentEmailProps, { type: PropType<string>; required: boolean }>,
24
- setup(props) {
25
- return () => transactionalEmailLayout(props)
26
- }
27
- })
@@ -1,18 +0,0 @@
1
- import type { VNode } from 'vue'
2
-
3
- import { emailLayout } from './brand'
4
-
5
- export type TransactionalEmailLayout = {
6
- preview: string
7
- heading: string
8
- message: string
9
- actionLabel: string
10
- actionURL: string
11
- footer?: string
12
- }
13
-
14
- /** Cloud's mail in the same branded layout as the waitlist's, so people know who wrote. */
15
- export function transactionalEmailLayout(props: TransactionalEmailLayout): VNode {
16
- const { footer, ...content } = props
17
- return emailLayout({ ...content, note: footer ? { text: footer } : undefined })
18
- }