@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
@@ -0,0 +1,110 @@
1
+ import {
2
+ documentVersionDownloadSchema,
3
+ documentVersionResponseSchema,
4
+ documentVersionsSchema,
5
+ restoredDocumentSchema,
6
+ type DocumentSummary,
7
+ type DocumentVersion,
8
+ type DocumentVersionDownload,
9
+ type DocumentVersions,
10
+ type DuplicateDocumentVersionInput,
11
+ type SaveDocumentVersionInput,
12
+ type UpdateDocumentVersionInput
13
+ } from '#cloud/contract'
14
+ import type { CloudAPI } from '#cloud/server/api'
15
+ import { pickBy } from 'es-toolkit/object'
16
+ import type { hc } from 'hono/client'
17
+
18
+ import { parseResponse, type CloudClientDiagnostic } from './response'
19
+ import { documentResponseSchema } from './schema'
20
+
21
+ /** A document’s version history: listing, naming, opening, restoring, and duplicating. */
22
+ export function createVersionRequests(
23
+ client: ReturnType<typeof hc<CloudAPI>>,
24
+ onDiagnostic?: CloudClientDiagnostic
25
+ ) {
26
+ return {
27
+ /** A page of the document's version history, newest first. */
28
+ async listDocumentVersions(
29
+ documentId: string,
30
+ page: { before?: string; limit?: number } = {}
31
+ ): Promise<DocumentVersions> {
32
+ return parseResponse(
33
+ client.documents[':documentId'].versions.$get({
34
+ param: { documentId },
35
+ query: pickBy(
36
+ {
37
+ before: page.before,
38
+ limit: page.limit === undefined ? undefined : String(page.limit)
39
+ },
40
+ (value) => value !== undefined
41
+ )
42
+ }),
43
+ documentVersionsSchema,
44
+ onDiagnostic
45
+ )
46
+ },
47
+ async saveDocumentVersion(
48
+ documentId: string,
49
+ input: SaveDocumentVersionInput
50
+ ): Promise<DocumentVersion> {
51
+ const response = await parseResponse(
52
+ client.documents[':documentId'].versions.$post({ param: { documentId }, json: input }),
53
+ documentVersionResponseSchema,
54
+ onDiagnostic
55
+ )
56
+ return response.version
57
+ },
58
+ async updateDocumentVersion(
59
+ documentId: string,
60
+ versionId: string,
61
+ input: UpdateDocumentVersionInput
62
+ ): Promise<DocumentVersion> {
63
+ const response = await parseResponse(
64
+ client.documents[':documentId'].versions[':versionId'].$patch({
65
+ param: { documentId, versionId },
66
+ json: input
67
+ }),
68
+ documentVersionResponseSchema,
69
+ onDiagnostic
70
+ )
71
+ return response.version
72
+ },
73
+ async getDocumentVersion(
74
+ documentId: string,
75
+ versionId: string
76
+ ): Promise<DocumentVersionDownload> {
77
+ return parseResponse(
78
+ client.documents[':documentId'].versions[':versionId'].$get({
79
+ param: { documentId, versionId }
80
+ }),
81
+ documentVersionDownloadSchema,
82
+ onDiagnostic
83
+ )
84
+ },
85
+ async restoreDocumentVersion(documentId: string, versionId: string) {
86
+ return parseResponse(
87
+ client.documents[':documentId'].versions[':versionId'].restore.$post({
88
+ param: { documentId, versionId }
89
+ }),
90
+ restoredDocumentSchema,
91
+ onDiagnostic
92
+ )
93
+ },
94
+ async duplicateDocumentVersion(
95
+ documentId: string,
96
+ versionId: string,
97
+ input: DuplicateDocumentVersionInput
98
+ ): Promise<DocumentSummary> {
99
+ const response = await parseResponse(
100
+ client.documents[':documentId'].versions[':versionId'].duplicate.$post({
101
+ param: { documentId, versionId },
102
+ json: input
103
+ }),
104
+ documentResponseSchema,
105
+ onDiagnostic
106
+ )
107
+ return response.document
108
+ }
109
+ }
110
+ }
@@ -3,13 +3,15 @@ import * as v from 'valibot'
3
3
 
4
4
  /**
5
5
  * Where an account stands: it may use the server, waits for an administrator, was refused or had
6
- * its access taken back, or has to accept the server's current terms first.
6
+ * its access taken back, has to prove its second step in this session, as after signing in through
7
+ * a linked account such as Google, or has to accept the server's current terms first.
7
8
  */
8
9
  export const cloudAccountStateSchema = v.picklist([
9
10
  'active',
10
11
  'pending',
11
12
  'rejected',
12
13
  'revoked',
14
+ 'two-step',
13
15
  'terms'
14
16
  ])
15
17
  export const cloudIdentitySchema = v.object({
@@ -29,23 +31,64 @@ export const cloudAccountStatusResponseSchema = v.object({
29
31
  /** Accepting the server's terms: the version the person read, which must be the current one. */
30
32
  export const cloudTermsAcceptanceSchema = v.object({ version: v.pipe(v.string(), v.minLength(1)) })
31
33
 
32
- export const cloudAuthenticationProviderSchema = v.picklist(['credential', 'google', 'apple'])
34
+ /**
35
+ * The providers a person can sign in with besides a password, which this editor has buttons for,
36
+ * in the order it shows them. Every list of providers in Cloud derives from this one.
37
+ */
38
+ export const CLOUD_SOCIAL_PROVIDERS = ['google', 'apple', 'github'] as const
39
+ export const cloudSocialProviderSchema = v.picklist(CLOUD_SOCIAL_PROVIDERS)
40
+ export type CloudSocialProvider = v.InferOutput<typeof cloudSocialProviderSchema>
41
+ /** Each provider's name, as its owner writes it in every language. */
42
+ export const CLOUD_SOCIAL_PROVIDER_NAMES: Record<CloudSocialProvider, string> = {
43
+ google: 'Google',
44
+ apple: 'Apple',
45
+ github: 'GitHub'
46
+ }
47
+ export const cloudAuthenticationProviderSchema = v.picklist([
48
+ 'credential',
49
+ ...CLOUD_SOCIAL_PROVIDERS
50
+ ])
33
51
  export const cloudAuthenticationMethodSchema = v.object({
34
52
  id: v.string(),
35
53
  provider: cloudAuthenticationProviderSchema,
36
54
  createdAt: v.string(),
37
55
  canUnlink: v.boolean()
38
56
  })
57
+
58
+ /** Whether this editor knows `provider`, so a newer server's other providers can be left out. */
59
+ export function isKnownSocialProvider(provider: string): provider is CloudSocialProvider {
60
+ return (CLOUD_SOCIAL_PROVIDERS as readonly string[]).includes(provider)
61
+ }
62
+
63
+ /** Whether `provider` is a way to sign in this editor knows: a password or a known provider. */
64
+ export function isKnownAuthenticationProvider(
65
+ provider: string
66
+ ): provider is CloudAuthenticationProvider {
67
+ return provider === 'credential' || isKnownSocialProvider(provider)
68
+ }
69
+
70
+ /**
71
+ * A newer server may list a provider this editor has no words or button for: those entries are
72
+ * left out rather than failing the whole response, and anything else malformed still fails.
73
+ */
39
74
  export const cloudAuthenticationMethodsResponseSchema = v.object({
40
- methods: v.array(cloudAuthenticationMethodSchema),
41
- availableSocialProviders: v.array(v.picklist(['google', 'apple']))
75
+ methods: v.pipe(
76
+ v.array(v.looseObject({ provider: v.string() })),
77
+ v.filterItems((method) => isKnownAuthenticationProvider(method.provider)),
78
+ v.array(cloudAuthenticationMethodSchema)
79
+ ),
80
+ availableSocialProviders: v.pipe(
81
+ v.array(v.string()),
82
+ v.filterItems(isKnownSocialProvider),
83
+ v.array(cloudSocialProviderSchema)
84
+ )
42
85
  })
43
86
  export const cloudPasswordChangeSchema = v.object({
44
87
  currentPassword: v.string(),
45
88
  newPassword: v.string()
46
89
  })
47
90
  export const cloudSocialLinkSchema = v.object({
48
- provider: v.picklist(['google', 'apple']),
91
+ provider: cloudSocialProviderSchema,
49
92
  callbackURL: v.pipe(v.string(), v.url())
50
93
  })
51
94
  export const cloudSocialLinkResponseSchema = v.object({ url: v.pipe(v.string(), v.url()) })
@@ -57,6 +100,7 @@ export const accountSecurityErrorCodeSchema = v.picklist([
57
100
  'last_authentication_method',
58
101
  'session_not_fresh',
59
102
  'authentication_method_failed',
103
+ 'code_invalid',
60
104
  'email_unchanged',
61
105
  'email_change_unavailable',
62
106
  'current_session',
@@ -95,6 +139,54 @@ export const cloudPasskeySchema = v.object({
95
139
  export const cloudPasskeysResponseSchema = v.object({ passkeys: v.array(cloudPasskeySchema) })
96
140
  export const cloudPasskeyDeleteSchema = v.object({ id: v.string() })
97
141
 
142
+ /**
143
+ * Personal access tokens: an account's own credentials for scripts and CI, sent as
144
+ * `Authorization: Bearer <token>`. A token acts as its account on the document API only; it never
145
+ * changes how the account is reached, makes other tokens, or reaches administration.
146
+ */
147
+ export const CLOUD_ACCESS_TOKEN_PREFIX = 'opc_'
148
+ export const CLOUD_ACCESS_TOKEN_NAME_MAX_LENGTH = 64
149
+ export const CLOUD_ACCESS_TOKEN_MAX_DAYS = 365
150
+ export const cloudAccessTokenSchema = v.object({
151
+ id: v.string(),
152
+ name: v.string(),
153
+ /** The token's first characters, prefix included, to tell tokens apart; never the whole token. */
154
+ start: v.nullable(v.string()),
155
+ createdAt: v.string(),
156
+ expiresAt: v.nullable(v.string()),
157
+ lastUsedAt: v.nullable(v.string())
158
+ })
159
+ export const cloudAccessTokensResponseSchema = v.object({
160
+ tokens: v.array(cloudAccessTokenSchema)
161
+ })
162
+ export const cloudAccessTokenCreateSchema = v.object({
163
+ name: v.pipe(
164
+ v.string(),
165
+ v.trim(),
166
+ v.minLength(1),
167
+ v.maxLength(CLOUD_ACCESS_TOKEN_NAME_MAX_LENGTH)
168
+ ),
169
+ expiresInDays: v.pipe(
170
+ v.number(),
171
+ v.integer(),
172
+ v.minValue(1),
173
+ v.maxValue(CLOUD_ACCESS_TOKEN_MAX_DAYS)
174
+ )
175
+ })
176
+ /** A new token, the only time the whole of it is shown. */
177
+ export const cloudAccessTokenCreatedResponseSchema = v.object({
178
+ token: v.pipe(v.string(), v.startsWith(CLOUD_ACCESS_TOKEN_PREFIX)),
179
+ accessToken: cloudAccessTokenSchema
180
+ })
181
+ export const cloudAccessTokenRevokeSchema = v.object({ id: v.pipe(v.string(), v.minLength(1)) })
182
+
183
+ export function parseCloudAccessTokenCreate(input: unknown) {
184
+ return v.parse(cloudAccessTokenCreateSchema, input)
185
+ }
186
+ export function parseCloudAccessTokenRevoke(input: unknown) {
187
+ return v.parse(cloudAccessTokenRevokeSchema, input)
188
+ }
189
+
98
190
  export function parseCloudTermsAcceptance(input: unknown) {
99
191
  return v.parse(cloudTermsAcceptanceSchema, input)
100
192
  }
@@ -158,21 +250,27 @@ export const cloudEmailChangeSchema = v.object({
158
250
  })
159
251
 
160
252
  /** How a sign-in was made: the method it used, or the desktop app's approved code. */
161
- export const cloudSignInMethodSchema = v.picklist([
253
+ const SIGN_IN_METHODS = [
162
254
  'password',
163
- 'google',
164
- 'apple',
255
+ ...CLOUD_SOCIAL_PROVIDERS,
165
256
  'passkey',
166
257
  'two-step',
167
258
  'email-link',
168
259
  'desktop',
169
260
  'other'
170
- ])
261
+ ] as const
262
+ export const cloudSignInMethodSchema = v.picklist(SIGN_IN_METHODS)
263
+ /** A method a newer server names that this editor does not know reads as `other`; a value that is
264
+ * not a method name at all still fails. */
265
+ const signInMethodResponseSchema = v.pipe(
266
+ v.string(),
267
+ v.transform((method) => (v.is(cloudSignInMethodSchema, method) ? method : ('other' as const)))
268
+ )
171
269
  export const cloudAccountSessionSchema = v.object({
172
270
  id: v.string(),
173
271
  /** The session this request was made with. */
174
272
  current: v.boolean(),
175
- method: v.nullable(cloudSignInMethodSchema),
273
+ method: v.nullable(signInMethodResponseSchema),
176
274
  ipAddress: v.nullable(v.string()),
177
275
  /** The browser and system the server read from the client's user agent, such as `Chrome 141`. */
178
276
  browser: v.nullable(v.string()),
@@ -187,7 +285,7 @@ export const cloudAccountSessionsResponseSchema = v.object({
187
285
  export const cloudSessionRevokeSchema = v.object({ sessionId: v.pipe(v.string(), v.minLength(1)) })
188
286
  export const cloudSignInSchema = v.object({
189
287
  id: v.string(),
190
- method: cloudSignInMethodSchema,
288
+ method: signInMethodResponseSchema,
191
289
  ipAddress: v.nullable(v.string()),
192
290
  /** The browser and system the server read from the client's user agent, such as `Chrome 141`. */
193
291
  browser: v.nullable(v.string()),
@@ -254,6 +352,8 @@ export type CloudAuthenticationMethods = v.InferOutput<
254
352
 
255
353
  export type CloudAccountStatus = v.InferOutput<typeof cloudAccountStatusResponseSchema>
256
354
  export type CloudProfile = v.InferOutput<typeof cloudProfileSchema>
355
+ export type CloudAccessToken = v.InferOutput<typeof cloudAccessTokenSchema>
356
+ export type CloudAccessTokenCreate = v.InferOutput<typeof cloudAccessTokenCreateSchema>
257
357
  export type CloudSignInMethod = v.InferOutput<typeof cloudSignInMethodSchema>
258
358
  export type CloudAccountSession = v.InferOutput<typeof cloudAccountSessionSchema>
259
359
  export type CloudSignIn = v.InferOutput<typeof cloudSignInSchema>
@@ -2,11 +2,13 @@ import { zipObject } from 'es-toolkit'
2
2
  import * as v from 'valibot'
3
3
 
4
4
  import {
5
+ CLOUD_SOCIAL_PROVIDERS,
5
6
  cloudIdentitySchema,
6
7
  cloudAccountSessionSchema,
7
8
  cloudPersonSchema,
8
9
  cloudSignInSchema
9
10
  } from '../account'
11
+ import { documentKindSchema } from '../documents'
10
12
  import { documentReportReasonSchema } from '../reports'
11
13
  import { workspaceRoleSchema } from '../workspaces'
12
14
 
@@ -39,8 +41,14 @@ export const adminErrorCodeSchema = v.picklist([
39
41
  'invalid_enrollment_transition',
40
42
  'last_admin_required',
41
43
  'self_admin_action_forbidden',
44
+ // The sign-in method is the account's last, so removing it would lock its owner out.
45
+ 'last_authentication_method',
46
+ // Only an account whose request was never approved can be deleted from the console.
47
+ 'account_approved',
42
48
  'email_regeneration_unavailable',
43
49
  'mfa_required',
50
+ // Two-step is on, but this session has not proved it lately; confirming it lets it back in.
51
+ 'two_step_unconfirmed',
44
52
  'document_not_restorable',
45
53
  'workspace_gone'
46
54
  ])
@@ -71,6 +79,10 @@ export const enrollmentsResponseSchema = v.object({
71
79
  ...listTotals(enrollmentStatusSchema.options)
72
80
  })
73
81
  export const enrollmentReviewResponseSchema = v.object({ enrollment: enrollmentSchema })
82
+ /** How many waiting requests were approved with the official deployment's invitation letter. */
83
+ export const enrollmentInviteResponseSchema = v.object({
84
+ invited: v.pipe(v.number(), v.integer(), v.minValue(0))
85
+ })
74
86
 
75
87
  export const cloudAdminSessionResponseSchema = v.object({ user: cloudIdentitySchema })
76
88
 
@@ -84,7 +96,14 @@ export const cloudAdminUserSchema = v.object({
84
96
  twoStep: v.boolean(),
85
97
  /** When one of the account's sessions was last used, or null when none is left. */
86
98
  lastActiveAt: nullableTimestampSchema,
87
- workspaceCount: countSchema
99
+ workspaceCount: countSchema,
100
+ /** How the account signs in: `credential` for a password, or a provider such as `google`. */
101
+ methods: v.array(v.string()),
102
+ /**
103
+ * On a server that approves people, where this account's request to join stands: an account
104
+ * exists from its first sign-in, before anyone approved it. Absent where everyone may join.
105
+ */
106
+ request: v.optional(v.nullable(enrollmentStatusSchema))
88
107
  })
89
108
 
90
109
  /** Which accounts a list of people shows. */
@@ -94,6 +113,8 @@ export const cloudAdminUserFilterSchema = v.picklist([
94
113
  'suspended',
95
114
  'without-two-step'
96
115
  ])
116
+ /** Narrows a list of people, under any filter, to those who sign in a given way. */
117
+ export const cloudAdminUserMethodSchema = v.picklist(['password', ...CLOUD_SOCIAL_PROVIDERS])
97
118
  export const cloudAdminUsersResponseSchema = v.object({
98
119
  users: v.array(cloudAdminUserSchema),
99
120
  ...listTotals(cloudAdminUserFilterSchema.options)
@@ -104,7 +125,15 @@ export const cloudAdminUserDetailSchema = v.object({
104
125
  ...cloudAdminUserSchema.entries,
105
126
  emailVerified: v.boolean()
106
127
  }),
107
- methods: v.array(v.object({ provider: v.string(), createdAt: timestampSchema })),
128
+ /** `canRemove`: the account keeps a way in that still works without it. */
129
+ methods: v.array(
130
+ v.object({
131
+ id: v.string(),
132
+ provider: v.string(),
133
+ createdAt: timestampSchema,
134
+ canRemove: v.boolean()
135
+ })
136
+ ),
108
137
  authenticator: v.boolean(),
109
138
  passkeyCount: countSchema,
110
139
  sessions: v.array(cloudAccountSessionSchema),
@@ -172,6 +201,8 @@ export const adminAuditResponseSchema = v.object({
172
201
  export const cloudAdminDocumentSchema = v.object({
173
202
  id: v.string(),
174
203
  name: v.string(),
204
+ /** A design or a board. Servers from before send none, and had only designs. */
205
+ kind: v.optional(documentKindSchema, 'design'),
175
206
  workspace: v.object({ id: v.string(), name: v.string() }),
176
207
  /** Who made it, while the server knows them. */
177
208
  owner: v.nullable(v.object({ id: v.string(), name: v.string(), email: v.string() })),
@@ -186,7 +217,20 @@ export const cloudAdminDocumentSchema = v.object({
186
217
  * can still restore it. Servers from before Trash send neither.
187
218
  */
188
219
  purgedAt: v.optional(nullableTimestampSchema, null),
189
- destroyedAt: v.optional(nullableTimestampSchema, null)
220
+ destroyedAt: v.optional(nullableTimestampSchema, null),
221
+ /**
222
+ * The saved revision whose thumbnail previews it; null before its first save. Servers from
223
+ * before previews send none.
224
+ */
225
+ revisionId: v.optional(v.nullable(v.string()), null),
226
+ /**
227
+ * Who beyond its workspace can open it: anyone, in the community gallery, and whoever holds one
228
+ * of its live share links, `editLinks` of which let them edit. Servers from before send none.
229
+ */
230
+ exposure: v.optional(
231
+ v.object({ community: v.boolean(), links: countSchema, editLinks: countSchema }),
232
+ { community: false, links: 0, editLinks: 0 }
233
+ )
190
234
  })
191
235
  /** Which documents a list shows: live ones, or those deleted forever an administrator can restore. */
192
236
  export const cloudAdminDocumentFilterSchema = v.picklist(['all', 'reported', 'disabled', 'purged'])
@@ -236,6 +280,7 @@ export type Enrollment = v.InferOutput<typeof enrollmentSchema>
236
280
  export type CloudAdminSessionResponse = v.InferOutput<typeof cloudAdminSessionResponseSchema>
237
281
  export type CloudAdminUser = v.InferOutput<typeof cloudAdminUserSchema>
238
282
  export type CloudAdminUserFilter = v.InferOutput<typeof cloudAdminUserFilterSchema>
283
+ export type CloudAdminUserMethod = v.InferOutput<typeof cloudAdminUserMethodSchema>
239
284
  export type CloudAdminEmailFilter = v.InferOutput<typeof cloudAdminEmailFilterSchema>
240
285
  export type CloudAdminAuditFilter = v.InferOutput<typeof cloudAdminAuditFilterSchema>
241
286
  export type EnrollmentStatus = v.InferOutput<typeof enrollmentStatusSchema>
@@ -0,0 +1,235 @@
1
+ import type { Hono } from 'hono'
2
+ import type { BlankEnv, BlankInput } from 'hono/types'
3
+ import * as v from 'valibot'
4
+
5
+ import type { JSONRoute } from './routes'
6
+
7
+ /**
8
+ * The contract between Cloud, its editors, and the billing service a deployment advertises: what
9
+ * plans and credit packs it sells, and where an account buys them or manages what it has. Cloud
10
+ * only advertises the service and signs short-lived tokens for an account; the service talks to
11
+ * the payment provider, and sets the account's entitlements and credits as it is paid.
12
+ */
13
+ export const CLOUD_BILLING_CONTRACT_VERSION = '1' as const
14
+ /**
15
+ * The `aud` of the tokens Cloud signs for its billing service, with the services' signing key,
16
+ * whose public keys it publishes at `CLOUD_SERVICES_JWKS_PATH`.
17
+ */
18
+ export const CLOUD_BILLING_TOKEN_AUDIENCE = 'openpencil-billing' as const
19
+
20
+ /**
21
+ * The page of a Cloud server where the signed-in person sees their plan, buys a plan or credits,
22
+ * and manages what they pay for; editors link to it whenever the server advertises billing.
23
+ */
24
+ export const CLOUD_ACCOUNT_PLAN_PATH = '/account/plan' as const
25
+
26
+ /**
27
+ * The plan page with billing's own pages opening at once: where billing sends someone whose
28
+ * session there ended, so Cloud signs them in to billing again.
29
+ */
30
+ export const CLOUD_ACCOUNT_BILLING_PATH = `${CLOUD_ACCOUNT_PLAN_PATH}?open=billing` as const
31
+
32
+ /**
33
+ * The billing service's own pages, below the discovered `endpoint`: where Cloud's plan page sends
34
+ * the signed-in person, posting a billing token as the form field `token` to `session`, and the
35
+ * public pricing page. The service answers that post with `303 See Other`, never `307` or `308`,
36
+ * which a browser follows by posting the same body, the token, again to wherever they point.
37
+ */
38
+ export const CLOUD_BILLING_PAGE_PATHS = {
39
+ session: '/session',
40
+ pricing: '/pricing'
41
+ } as const
42
+
43
+ /**
44
+ * Where the billing service answers, below the discovered `endpoint`. Cloud posts to `seats`,
45
+ * with a billing token for the account as its bearer, whenever the people who can edit in that
46
+ * account's workspaces change; the service reads the count from Cloud's internal API.
47
+ */
48
+ export const CLOUD_BILLING_API_PATHS = {
49
+ base: '/v1',
50
+ catalog: '/v1/catalog',
51
+ seats: '/v1/seats',
52
+ account: '/v1/account',
53
+ checkout: '/v1/checkout',
54
+ portal: '/v1/portal'
55
+ } as const
56
+
57
+ const urlSchema = v.pipe(v.string(), v.url())
58
+ const idSchema = v.pipe(v.string(), v.regex(/^[a-z0-9][a-z0-9-]{0,62}$/))
59
+ const centsSchema = v.pipe(v.number(), v.integer(), v.minValue(0))
60
+ const bytesSchema = v.pipe(v.number(), v.integer(), v.minValue(0))
61
+ const creditsSchema = v.pipe(v.number(), v.integer(), v.minValue(0))
62
+
63
+ /**
64
+ * What an account without a plan has: the deployment's free plan, which a pricing page compares
65
+ * the plans with.
66
+ */
67
+ export const billingFreePlanSchema = v.object({
68
+ /** The storage an account may use, or `null` for no limit. */
69
+ storageBytes: v.nullable(bytesSchema),
70
+ /** Whether the free plan includes services, such as AI and search. */
71
+ services: v.boolean(),
72
+ /** Credits granted each month with services, or `null` for no monthly limit. */
73
+ monthlyCredits: v.nullable(creditsSchema)
74
+ })
75
+ export type BillingFreePlan = v.InferOutput<typeof billingFreePlanSchema>
76
+
77
+ export const cloudBillingDiscoverySchema = v.object({
78
+ endpoint: urlSchema,
79
+ contractVersion: v.literal(CLOUD_BILLING_CONTRACT_VERSION),
80
+ freePlan: v.optional(billingFreePlanSchema)
81
+ })
82
+ export type CloudBillingDiscovery = v.InferOutput<typeof cloudBillingDiscoverySchema>
83
+
84
+ export const billingTokenSchema = v.object({
85
+ token: v.pipe(v.string(), v.minLength(1)),
86
+ expiresAt: v.pipe(v.string(), v.isoTimestamp())
87
+ })
88
+ export type BillingToken = v.InferOutput<typeof billingTokenSchema>
89
+
90
+ /**
91
+ * What the billing service may rely on once a token's signature, issuer, audience, and expiry
92
+ * check. The account is the signed-in user, who buys and manages only their own plan.
93
+ */
94
+ export const billingTokenClaimsSchema = v.object({
95
+ iss: urlSchema,
96
+ aud: v.literal(CLOUD_BILLING_TOKEN_AUDIENCE),
97
+ /** The account: the Cloud user whose plan and credits these are. */
98
+ sub: v.pipe(v.string(), v.minLength(1)),
99
+ /** Where the payment provider sends receipts and invoices. */
100
+ email: v.pipe(v.string(), v.email()),
101
+ iat: v.pipe(v.number(), v.integer()),
102
+ exp: v.pipe(v.number(), v.integer())
103
+ })
104
+ export type BillingTokenClaims = v.InferOutput<typeof billingTokenClaimsSchema>
105
+
106
+ const seatCountSchema = v.pipe(v.number(), v.integer(), v.minValue(1))
107
+
108
+ /**
109
+ * A plan priced by the seat: everyone who can edit in the account's workspaces takes one, and the
110
+ * account pays for at least `minimum`. Every seat costs the price of the tier its count reaches,
111
+ * and adds its storage and credits to what the account shares.
112
+ */
113
+ export const billingSeatPricingSchema = v.object({
114
+ minimum: seatCountSchema,
115
+ /** From the fewest seats up: the first from 1, each later one from more seats. */
116
+ tiers: v.pipe(
117
+ v.array(v.object({ fromSeats: seatCountSchema, unitPriceCents: centsSchema })),
118
+ v.minLength(1),
119
+ v.check((tiers) => tiers[0]?.fromSeats === 1, 'The first seat tier starts at one seat'),
120
+ v.check(
121
+ (tiers) =>
122
+ tiers.every(
123
+ (tier, index) => index === 0 || tier.fromSeats > (tiers[index - 1]?.fromSeats ?? 0)
124
+ ),
125
+ 'Seat tiers start at more seats each'
126
+ )
127
+ ),
128
+ storageBytesPerSeat: bytesSchema,
129
+ monthlyCreditsPerSeat: creditsSchema
130
+ })
131
+ export type BillingSeatPricing = v.InferOutput<typeof billingSeatPricingSchema>
132
+
133
+ /**
134
+ * A plan an account subscribes to, billed every month in US dollars before tax. A plan priced by
135
+ * the seat states its price, storage, and credits at its minimum, so an editor that reads no
136
+ * `seats` still shows what it starts at.
137
+ */
138
+ export const billingPlanSchema = v.object({
139
+ id: idSchema,
140
+ name: v.pipe(v.string(), v.minLength(1)),
141
+ monthlyPriceCents: centsSchema,
142
+ storageBytes: bytesSchema,
143
+ monthlyCredits: creditsSchema,
144
+ seats: v.optional(billingSeatPricingSchema)
145
+ })
146
+ export type BillingPlan = v.InferOutput<typeof billingPlanSchema>
147
+
148
+ /** Credits an account on a plan buys once, in US dollars before tax. */
149
+ export const creditPackSchema = v.object({
150
+ id: idSchema,
151
+ credits: creditsSchema,
152
+ priceCents: centsSchema,
153
+ /** How long the credits last from purchase. */
154
+ validDays: v.pipe(v.number(), v.integer(), v.minValue(1))
155
+ })
156
+ export type CreditPack = v.InferOutput<typeof creditPackSchema>
157
+
158
+ /** What the service sells; an account without a plan has its deployment's free entitlements. */
159
+ export const billingCatalogSchema = v.object({
160
+ plans: v.array(billingPlanSchema),
161
+ creditPacks: v.array(creditPackSchema)
162
+ })
163
+ export type BillingCatalog = v.InferOutput<typeof billingCatalogSchema>
164
+
165
+ /**
166
+ * The account's subscription as the payment provider holds it, or `null` without one. A
167
+ * `past_due` plan keeps its entitlements while payment is retried.
168
+ */
169
+ export const billingAccountSchema = v.object({
170
+ subscription: v.nullable(
171
+ v.object({
172
+ planId: idSchema,
173
+ status: v.picklist(['active', 'past_due']),
174
+ /** When the current period ends: the next charge, or the end of a cancelled plan. */
175
+ currentPeriodEnd: v.pipe(v.string(), v.isoTimestamp()),
176
+ /** Whether the plan ends at `currentPeriodEnd` instead of renewing. */
177
+ cancelsAtPeriodEnd: v.boolean()
178
+ })
179
+ )
180
+ })
181
+ export type BillingAccount = v.InferOutput<typeof billingAccountSchema>
182
+
183
+ /** What to buy: a plan to subscribe to, or a credit pack. */
184
+ export const checkoutRequestSchema = v.union([
185
+ v.object({ planId: idSchema }),
186
+ v.object({ creditPackId: idSchema })
187
+ ])
188
+ export type CheckoutRequest = v.InferOutput<typeof checkoutRequestSchema>
189
+
190
+ /** Where to send the person: the payment provider's checkout or account portal. */
191
+ export const billingRedirectSchema = v.object({
192
+ // Only the payment provider's own pages, never a scheme a browser would run.
193
+ url: v.pipe(urlSchema, v.regex(/^https:\/\//i, 'Billing sends people to an HTTPS page'))
194
+ })
195
+ export type BillingRedirect = v.InferOutput<typeof billingRedirectSchema>
196
+
197
+ export const billingErrorCodeSchema = v.picklist([
198
+ 'invalid_request',
199
+ 'unauthorized',
200
+ /** A credit pack for an account without a plan, or a plan it already has. */
201
+ 'not_allowed',
202
+ 'provider_unavailable'
203
+ ])
204
+ export type BillingErrorCode = v.InferOutput<typeof billingErrorCodeSchema>
205
+
206
+ /** The HTTP status billing answers each error with. */
207
+ export const BILLING_ERROR_STATUS = {
208
+ invalid_request: 400,
209
+ unauthorized: 401,
210
+ not_allowed: 409,
211
+ provider_unavailable: 502
212
+ } as const satisfies Record<BillingErrorCode, number>
213
+
214
+ export const billingErrorSchema = v.object({
215
+ error: v.object({ code: billingErrorCodeSchema, message: v.optional(v.string()) })
216
+ })
217
+ export type BillingError = v.InferOutput<typeof billingErrorSchema>
218
+
219
+ /** The billing service's routes, for a typed Hono client (`hc<CloudBillingAPI>`). */
220
+ export type CloudBillingSchema = JSONRoute<
221
+ 'get',
222
+ typeof CLOUD_BILLING_API_PATHS.catalog,
223
+ BlankInput,
224
+ BillingCatalog
225
+ > &
226
+ JSONRoute<'get', typeof CLOUD_BILLING_API_PATHS.account, BlankInput, BillingAccount> &
227
+ JSONRoute<
228
+ 'post',
229
+ typeof CLOUD_BILLING_API_PATHS.checkout,
230
+ { json: CheckoutRequest },
231
+ BillingRedirect
232
+ > &
233
+ JSONRoute<'post', typeof CLOUD_BILLING_API_PATHS.portal, BlankInput, BillingRedirect>
234
+
235
+ export type CloudBillingAPI = Hono<BlankEnv, CloudBillingSchema>
@@ -38,6 +38,11 @@ export const collaborationTicketSchema = v.object({
38
38
  roomKey: v.pipe(v.string(), v.minLength(43), v.maxLength(128)),
39
39
  principal: collaborationPrincipalSchema,
40
40
  permission: documentPermissionSchema,
41
+ /**
42
+ * Why a peer whose access would let them edit may only view: `storage-limit` when the document's
43
+ * owner holds their whole storage allowance, until they free space or their plan grows.
44
+ */
45
+ readOnly: v.optional(v.picklist(['storage-limit'])),
41
46
  roomEpoch: v.pipe(v.number(), v.integer(), v.minValue(0)),
42
47
  expiresAt: v.string(),
43
48
  serverEnforcedWrites: v.boolean(),