@open-pencil/cloud 0.17.0-beta.4 → 0.17.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/bin/server.mjs +1 -1
- package/dist/bin/server.mjs.map +1 -1
- package/dist/bin/services.mjs +1 -1
- package/dist/bin/services.mjs.map +1 -1
- package/dist/client.d.ts +296 -27
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +649 -295
- package/dist/client.js.map +1 -1
- package/dist/contract.d.ts +2 -2
- package/dist/contract.js +2 -2
- package/dist/contract2.js +331 -21
- package/dist/contract2.js.map +1 -1
- package/dist/email.d.ts +1773 -32
- package/dist/email.d.ts.map +1 -1
- package/dist/email.js +3478 -288
- package/dist/email.js.map +1 -1
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +48 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +466 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index2.d.ts +35 -0
- package/dist/index2.d.ts.map +1 -0
- package/dist/listen.mjs +447 -290
- package/dist/listen.mjs.map +1 -1
- package/dist/runtime-cloudflare.d.ts +89 -0
- package/dist/runtime-cloudflare.d.ts.map +1 -0
- package/dist/runtime-cloudflare.js +15667 -0
- package/dist/runtime-cloudflare.js.map +1 -0
- package/dist/runtime-node.d.mts +2963 -294
- package/dist/runtime-node.d.mts.map +1 -1
- package/dist/server.d.ts +3473 -842
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +12187 -8244
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +7739 -3548
- package/dist/server.mjs.map +1 -1
- package/dist/server2.mjs +5 -5
- package/dist/server2.mjs.map +1 -1
- package/package.json +22 -5
- package/src/admin/audit/service.ts +2 -2
- package/src/admin/documents/service.ts +76 -6
- package/src/admin/reports/service.ts +7 -1
- package/src/client/api.ts +23 -471
- package/src/client/auth/client.ts +22 -3
- package/src/client/billing.ts +80 -0
- package/src/client/community.ts +40 -0
- package/src/client/discovery.ts +35 -9
- package/src/client/documents.ts +160 -0
- package/src/client/index.ts +7 -0
- package/src/client/portal/account.ts +54 -2
- package/src/client/portal/request.ts +2 -0
- package/src/client/response.ts +21 -0
- package/src/client/schema.ts +8 -0
- package/src/client/services.ts +23 -18
- package/src/client/sharing.ts +262 -0
- package/src/client/versions.ts +104 -0
- package/src/contract/account.ts +50 -0
- package/src/contract/billing.ts +166 -0
- package/src/contract/collaboration.ts +5 -0
- package/src/contract/community.ts +60 -0
- package/src/contract/discovery.ts +63 -2
- package/src/contract/entitlements.ts +10 -0
- package/src/contract/index.ts +54 -5
- package/src/contract/links.ts +57 -4
- package/src/contract/locale.ts +27 -0
- package/src/contract/portal.ts +12 -1
- package/src/contract/routes.ts +10 -0
- package/src/contract/services.ts +18 -16
- package/src/email/i18n.ts +174 -0
- package/src/email/index.ts +13 -2
- package/src/email/locales/ar.json +141 -0
- package/src/email/locales/de.json +141 -0
- package/src/email/locales/es.json +141 -0
- package/src/email/locales/fr.json +141 -0
- package/src/email/locales/it.json +141 -0
- package/src/email/locales/ja.json +141 -0
- package/src/email/locales/pl.json +141 -0
- package/src/email/locales/pt-br.json +141 -0
- package/src/email/locales/ru.json +141 -0
- package/src/email/locales/zh-cn.json +141 -0
- package/src/email/messages.ts +200 -0
- package/src/email/render.ts +142 -276
- package/src/email/samples.ts +115 -0
- package/src/email/schema.ts +70 -6
- package/src/email/templates/BrandEmail.vue +54 -0
- package/src/email/templates/DocumentBlocked.vue +45 -0
- package/src/email/templates/DocumentInvitation.vue +24 -0
- package/src/email/templates/DocumentReport.vue +32 -0
- package/src/email/templates/DocumentReportDecided.vue +36 -0
- package/src/email/templates/DocumentReportReceived.vue +18 -0
- package/src/email/templates/DocumentRestored.vue +24 -0
- package/src/email/templates/EmailChangeRequested.vue +24 -0
- package/src/email/templates/EmailRoot.vue +19 -0
- package/src/email/templates/EmailText.vue +9 -0
- package/src/email/templates/EmailVerification.vue +38 -0
- package/src/email/templates/EnrollmentNotification.vue +24 -0
- package/src/email/templates/EnrollmentUpdate.vue +52 -0
- package/src/email/templates/NewSignIn.vue +37 -0
- package/src/email/templates/PasswordChanged.vue +22 -0
- package/src/email/templates/PasswordReset.vue +23 -0
- package/src/email/templates/StorageLimitReached.vue +28 -0
- package/src/email/templates/TwoStepChanged.vue +32 -0
- package/src/email/templates/WaitlistConfirmation.vue +29 -0
- package/src/email/templates/WorkspaceInvitation.vue +28 -0
- package/src/email/templates/brand.ts +9 -61
- package/src/email/templates/localization.ts +17 -0
- package/src/errors/index.ts +6 -0
- package/src/global.d.ts +7 -0
- package/src/runtime/cloudflare/relay/index.ts +7 -1
- package/src/runtime/cloudflare/tsconfig.json +2 -1
- package/src/runtime/cloudflare/worker.ts +8 -1
- package/src/runtime/node/cleanup.ts +5 -1
- package/src/runtime/node/email/transport.ts +13 -10
- package/src/runtime/node/main.ts +1 -1
- package/src/runtime/node/server.ts +12 -2
- package/src/runtime/node/services/main.ts +1 -1
- package/src/runtime/posthog/errors.ts +2 -1
- package/src/runtime/s3/objects.ts +17 -0
- package/src/runtime/site/community.ts +101 -0
- package/src/runtime/site/server.ts +17 -1
- package/src/server/account/deletion.ts +2 -0
- package/src/server/account/routes.ts +271 -240
- package/src/server/account/tokens.ts +57 -0
- package/src/server/api/router.ts +23 -0
- package/src/server/app/checks.ts +84 -0
- package/src/server/app/editors.ts +20 -0
- package/src/server/app/index.ts +128 -0
- package/src/server/app/indexing.ts +40 -0
- package/src/server/app/limiters.ts +53 -0
- package/src/server/app/routes.ts +114 -0
- package/src/server/app/services.ts +185 -0
- package/src/server/auth/access-tokens.ts +62 -0
- package/src/server/auth/adapter.ts +21 -1
- package/src/server/auth/email.ts +4 -1
- package/src/server/auth/enrollment.ts +116 -0
- package/src/server/auth/factory.ts +88 -131
- package/src/server/auth/logger.ts +23 -0
- package/src/server/auth/mfa-assurance.ts +51 -0
- package/src/server/auth/passwords.ts +43 -0
- package/src/server/auth/session.ts +2 -0
- package/src/server/billing/index.ts +6 -0
- package/src/server/billing/routes.ts +27 -0
- package/src/server/billing/tokens.ts +37 -0
- package/src/server/cleanup/configured.ts +16 -3
- package/src/server/cleanup/worker.ts +10 -1
- package/src/server/collaboration/relay/hub.ts +25 -142
- package/src/server/collaboration/relay/room.ts +154 -0
- package/src/server/collaboration/service.ts +21 -2
- package/src/server/community/index.ts +2 -0
- package/src/server/community/routes.ts +93 -0
- package/src/server/community/service.ts +134 -0
- package/src/server/config/deployment.ts +17 -5
- package/src/server/config/index.ts +1 -1
- package/src/server/config/public.ts +7 -1
- package/src/server/config/schema.ts +40 -292
- package/src/server/config/toml/schema.ts +307 -0
- package/src/server/db/index.ts +1 -0
- package/src/server/db/migrate.ts +13 -1
- package/src/server/db/migrations/009_access_tokens.ts +47 -0
- package/src/server/db/migrations/010_storage_limit_notices.ts +50 -0
- package/src/server/db/migrations/011_account_ids.ts +30 -0
- package/src/server/db/migrations/012_email_locales.ts +34 -0
- package/src/server/db/migrations/013_document_block_emails.ts +40 -0
- package/src/server/db/migrations/014_report_replies.ts +28 -0
- package/src/server/db/migrations/schema.ts +26 -1
- package/src/server/db/tables.ts +30 -1
- package/src/server/db/users.ts +22 -0
- package/src/server/documents/index.ts +1 -1
- package/src/server/documents/limits.ts +7 -1
- package/src/server/documents/service.ts +12 -402
- package/src/server/documents/uploads.ts +450 -0
- package/src/server/documents/versions/service.ts +81 -24
- package/src/server/email/invitations.ts +1 -0
- package/src/server/email/service.ts +31 -4
- package/src/server/email/types.ts +12 -0
- package/src/server/errors/index.ts +1 -9
- package/src/server/index.ts +12 -5
- package/src/server/invitations/types.ts +5 -1
- package/src/server/objects/types.ts +5 -0
- package/src/server/policy/configured.ts +9 -3
- package/src/server/policy/database.ts +13 -2
- package/src/server/policy/policy.ts +39 -12
- package/src/server/policy/service.ts +71 -52
- package/src/server/policy/storage.ts +33 -0
- package/src/server/quota/index.ts +6 -0
- package/src/server/quota/notices.ts +121 -0
- package/src/server/quota/storage.ts +5 -0
- package/src/server/rate-limit/middleware.ts +4 -0
- package/src/server/reports/index.ts +1 -0
- package/src/server/reports/replies.ts +55 -0
- package/src/server/reports/routes.ts +3 -1
- package/src/server/reports/service.ts +24 -2
- package/src/server/sharing/capabilities/service.ts +2 -3
- package/src/server/sharing/invitations/service.ts +14 -4
- package/src/server/validation.ts +3 -0
- package/src/server/workspaces/members.ts +7 -19
- package/src/services/app.ts +1 -3
- package/src/services/config.ts +1 -0
- package/src/services/usage.ts +6 -14
- package/src/email/templates/document-invitation.ts +0 -35
- package/src/email/templates/enrollment.ts +0 -27
- package/src/email/templates/layout.ts +0 -18
- package/src/server/app.ts +0 -453
- /package/src/{server/errors → errors}/posthog.ts +0 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import {
|
|
2
|
+
acceptedInvitationSchema,
|
|
3
|
+
createInvitationContinuationSchema,
|
|
4
|
+
documentDownloadSchema,
|
|
5
|
+
documentGrantSchema,
|
|
6
|
+
documentInvitationSchema,
|
|
7
|
+
documentShareSchema,
|
|
8
|
+
invitationContinuationSchema,
|
|
9
|
+
invitationPreviewSchema,
|
|
10
|
+
resolvedDocumentShareSchema,
|
|
11
|
+
type AcceptDocumentInvitationInput,
|
|
12
|
+
type CollaborationTicket,
|
|
13
|
+
type CreateInvitationContinuationInput,
|
|
14
|
+
type InvitationContinuation,
|
|
15
|
+
type CreateDocumentInvitationInput,
|
|
16
|
+
type CreateDocumentShareInput,
|
|
17
|
+
type DocumentGrant,
|
|
18
|
+
type DocumentInvitation,
|
|
19
|
+
type DocumentShare,
|
|
20
|
+
type InvitationPreview,
|
|
21
|
+
type PutDocumentGrantInput,
|
|
22
|
+
type ResolveDocumentShareInput,
|
|
23
|
+
fileDocumentReportResponseSchema,
|
|
24
|
+
type FileDocumentReportInput,
|
|
25
|
+
type UpdateDocumentShareInput,
|
|
26
|
+
type AcceptedInvitation
|
|
27
|
+
} from '#cloud/contract'
|
|
28
|
+
import type { CloudAPI, PublicCloudAPI } from '#cloud/server/api'
|
|
29
|
+
import type { hc } from 'hono/client'
|
|
30
|
+
import * as v from 'valibot'
|
|
31
|
+
|
|
32
|
+
import { parseResponse, responseBody, type CloudClientDiagnostic } from './response'
|
|
33
|
+
import { collaborationTicketResponseSchema } from './schema'
|
|
34
|
+
|
|
35
|
+
const sharesResponseSchema = v.object({ shares: v.array(documentShareSchema) })
|
|
36
|
+
const shareResponseSchema = v.object({ share: documentShareSchema })
|
|
37
|
+
const shareCapabilityResponseSchema = v.object({
|
|
38
|
+
share: documentShareSchema,
|
|
39
|
+
secret: v.string(),
|
|
40
|
+
path: v.string()
|
|
41
|
+
})
|
|
42
|
+
const grantsResponseSchema = v.object({ grants: v.array(documentGrantSchema) })
|
|
43
|
+
const grantResponseSchema = v.object({ grant: documentGrantSchema })
|
|
44
|
+
const acceptedResponseSchema = v.object({ accepted: acceptedInvitationSchema })
|
|
45
|
+
const invitationPreviewResponseSchema = v.object({ invitation: invitationPreviewSchema })
|
|
46
|
+
const invitationsResponseSchema = v.object({ invitations: v.array(documentInvitationSchema) })
|
|
47
|
+
const invitationCapabilityResponseSchema = v.object({
|
|
48
|
+
invitation: documentInvitationSchema,
|
|
49
|
+
token: v.string()
|
|
50
|
+
})
|
|
51
|
+
const resolvedShareResponseSchema = v.object({ resolution: resolvedDocumentShareSchema })
|
|
52
|
+
const sharedDocumentResponseSchema = v.object({
|
|
53
|
+
resolution: resolvedDocumentShareSchema,
|
|
54
|
+
document: documentDownloadSchema
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
/** Sharing a document: its links, grants, and invitations, and opening what someone shared. */
|
|
58
|
+
export function createSharingRequests(
|
|
59
|
+
client: ReturnType<typeof hc<CloudAPI>>,
|
|
60
|
+
publicClient: ReturnType<typeof hc<PublicCloudAPI>>,
|
|
61
|
+
onDiagnostic?: CloudClientDiagnostic
|
|
62
|
+
) {
|
|
63
|
+
return {
|
|
64
|
+
async listDocumentShares(documentId: string): Promise<DocumentShare[]> {
|
|
65
|
+
const response = await parseResponse(
|
|
66
|
+
client.documents[':documentId'].shares.$get({ param: { documentId } }),
|
|
67
|
+
sharesResponseSchema,
|
|
68
|
+
onDiagnostic
|
|
69
|
+
)
|
|
70
|
+
return response.shares
|
|
71
|
+
},
|
|
72
|
+
async createDocumentShare(documentId: string, input: CreateDocumentShareInput) {
|
|
73
|
+
return parseResponse(
|
|
74
|
+
client.documents[':documentId'].shares.$post({
|
|
75
|
+
param: { documentId },
|
|
76
|
+
json: input
|
|
77
|
+
}),
|
|
78
|
+
shareCapabilityResponseSchema,
|
|
79
|
+
onDiagnostic
|
|
80
|
+
)
|
|
81
|
+
},
|
|
82
|
+
async updateDocumentShare(
|
|
83
|
+
documentId: string,
|
|
84
|
+
shareId: string,
|
|
85
|
+
input: UpdateDocumentShareInput
|
|
86
|
+
): Promise<DocumentShare> {
|
|
87
|
+
const response = await parseResponse(
|
|
88
|
+
client.documents[':documentId'].shares[':shareId'].$patch({
|
|
89
|
+
param: { documentId, shareId },
|
|
90
|
+
json: input
|
|
91
|
+
}),
|
|
92
|
+
shareResponseSchema,
|
|
93
|
+
onDiagnostic
|
|
94
|
+
)
|
|
95
|
+
return response.share
|
|
96
|
+
},
|
|
97
|
+
async rotateDocumentShare(documentId: string, shareId: string) {
|
|
98
|
+
return parseResponse(
|
|
99
|
+
client.documents[':documentId'].shares[':shareId'].rotate.$post({
|
|
100
|
+
param: { documentId, shareId }
|
|
101
|
+
}),
|
|
102
|
+
shareCapabilityResponseSchema,
|
|
103
|
+
onDiagnostic
|
|
104
|
+
)
|
|
105
|
+
},
|
|
106
|
+
async revokeDocumentShare(documentId: string, shareId: string): Promise<void> {
|
|
107
|
+
await responseBody(
|
|
108
|
+
await client.documents[':documentId'].shares[':shareId'].$delete({
|
|
109
|
+
param: { documentId, shareId }
|
|
110
|
+
}),
|
|
111
|
+
onDiagnostic
|
|
112
|
+
)
|
|
113
|
+
},
|
|
114
|
+
async listDocumentGrants(documentId: string): Promise<DocumentGrant[]> {
|
|
115
|
+
const response = await parseResponse(
|
|
116
|
+
client.documents[':documentId'].grants.$get({ param: { documentId } }),
|
|
117
|
+
grantsResponseSchema,
|
|
118
|
+
onDiagnostic
|
|
119
|
+
)
|
|
120
|
+
return response.grants
|
|
121
|
+
},
|
|
122
|
+
async putDocumentGrant(
|
|
123
|
+
documentId: string,
|
|
124
|
+
userId: string,
|
|
125
|
+
input: PutDocumentGrantInput
|
|
126
|
+
): Promise<DocumentGrant> {
|
|
127
|
+
const response = await parseResponse(
|
|
128
|
+
client.documents[':documentId'].grants[':userId'].$put({
|
|
129
|
+
param: { documentId, userId },
|
|
130
|
+
json: input
|
|
131
|
+
}),
|
|
132
|
+
grantResponseSchema,
|
|
133
|
+
onDiagnostic
|
|
134
|
+
)
|
|
135
|
+
return response.grant
|
|
136
|
+
},
|
|
137
|
+
async revokeDocumentGrant(documentId: string, userId: string): Promise<void> {
|
|
138
|
+
await responseBody(
|
|
139
|
+
await client.documents[':documentId'].grants[':userId'].$delete({
|
|
140
|
+
param: { documentId, userId }
|
|
141
|
+
}),
|
|
142
|
+
onDiagnostic
|
|
143
|
+
)
|
|
144
|
+
},
|
|
145
|
+
async listDocumentInvitations(documentId: string): Promise<DocumentInvitation[]> {
|
|
146
|
+
const response = await parseResponse(
|
|
147
|
+
client.documents[':documentId'].invitations.$get({ param: { documentId } }),
|
|
148
|
+
invitationsResponseSchema,
|
|
149
|
+
onDiagnostic
|
|
150
|
+
)
|
|
151
|
+
return response.invitations
|
|
152
|
+
},
|
|
153
|
+
async createDocumentInvitation(documentId: string, input: CreateDocumentInvitationInput) {
|
|
154
|
+
return parseResponse(
|
|
155
|
+
client.documents[':documentId'].invitations.$post({
|
|
156
|
+
param: { documentId },
|
|
157
|
+
json: input
|
|
158
|
+
}),
|
|
159
|
+
invitationCapabilityResponseSchema,
|
|
160
|
+
onDiagnostic
|
|
161
|
+
)
|
|
162
|
+
},
|
|
163
|
+
async createInvitationContinuation(
|
|
164
|
+
input: CreateInvitationContinuationInput
|
|
165
|
+
): Promise<InvitationContinuation> {
|
|
166
|
+
return parseResponse(
|
|
167
|
+
publicClient.invitations.continuations.$post({ json: input }),
|
|
168
|
+
invitationContinuationSchema,
|
|
169
|
+
onDiagnostic
|
|
170
|
+
)
|
|
171
|
+
},
|
|
172
|
+
async consumeInvitationContinuation(id: string): Promise<CreateInvitationContinuationInput> {
|
|
173
|
+
return parseResponse(
|
|
174
|
+
publicClient.invitations.continuations[':continuationId'].consume.$post({
|
|
175
|
+
param: { continuationId: id }
|
|
176
|
+
}),
|
|
177
|
+
createInvitationContinuationSchema,
|
|
178
|
+
onDiagnostic
|
|
179
|
+
)
|
|
180
|
+
},
|
|
181
|
+
async previewInvitation(
|
|
182
|
+
invitationId: string,
|
|
183
|
+
input: AcceptDocumentInvitationInput
|
|
184
|
+
): Promise<InvitationPreview> {
|
|
185
|
+
const response = await parseResponse(
|
|
186
|
+
publicClient.invitations[':invitationId'].preview.$post({
|
|
187
|
+
param: { invitationId },
|
|
188
|
+
json: input
|
|
189
|
+
}),
|
|
190
|
+
invitationPreviewResponseSchema,
|
|
191
|
+
onDiagnostic
|
|
192
|
+
)
|
|
193
|
+
return response.invitation
|
|
194
|
+
},
|
|
195
|
+
/** Accepts a document or workspace invitation, and says which it was. */
|
|
196
|
+
async acceptInvitation(
|
|
197
|
+
invitationId: string,
|
|
198
|
+
input: AcceptDocumentInvitationInput
|
|
199
|
+
): Promise<AcceptedInvitation> {
|
|
200
|
+
const response = await parseResponse(
|
|
201
|
+
client.invitations[':invitationId'].accept.$post({
|
|
202
|
+
param: { invitationId },
|
|
203
|
+
json: input
|
|
204
|
+
}),
|
|
205
|
+
acceptedResponseSchema,
|
|
206
|
+
onDiagnostic
|
|
207
|
+
)
|
|
208
|
+
return response.accepted
|
|
209
|
+
},
|
|
210
|
+
async revokeDocumentInvitation(documentId: string, invitationId: string): Promise<void> {
|
|
211
|
+
await responseBody(
|
|
212
|
+
await client.documents[':documentId'].invitations[':invitationId'].$delete({
|
|
213
|
+
param: { documentId, invitationId }
|
|
214
|
+
}),
|
|
215
|
+
onDiagnostic
|
|
216
|
+
)
|
|
217
|
+
},
|
|
218
|
+
/** Reports the document a share link opens to the server's administrators. */
|
|
219
|
+
async fileDocumentReport(shareId: string, input: FileDocumentReportInput): Promise<void> {
|
|
220
|
+
await parseResponse(
|
|
221
|
+
publicClient.shares[':shareId'].reports.$post({ param: { shareId }, json: input }),
|
|
222
|
+
fileDocumentReportResponseSchema,
|
|
223
|
+
onDiagnostic
|
|
224
|
+
)
|
|
225
|
+
},
|
|
226
|
+
async resolveDocumentShare(shareId: string, input: ResolveDocumentShareInput) {
|
|
227
|
+
const response = await parseResponse(
|
|
228
|
+
publicClient.shares[':shareId'].resolve.$post({
|
|
229
|
+
param: { shareId },
|
|
230
|
+
json: input
|
|
231
|
+
}),
|
|
232
|
+
resolvedShareResponseSchema,
|
|
233
|
+
onDiagnostic
|
|
234
|
+
)
|
|
235
|
+
return response.resolution
|
|
236
|
+
},
|
|
237
|
+
async getSharedDocument(shareId: string, input: ResolveDocumentShareInput) {
|
|
238
|
+
return parseResponse(
|
|
239
|
+
publicClient.shares[':shareId'].document.$post({
|
|
240
|
+
param: { shareId },
|
|
241
|
+
json: input
|
|
242
|
+
}),
|
|
243
|
+
sharedDocumentResponseSchema,
|
|
244
|
+
onDiagnostic
|
|
245
|
+
)
|
|
246
|
+
},
|
|
247
|
+
async getSharedCollaborationTicket(
|
|
248
|
+
shareId: string,
|
|
249
|
+
input: ResolveDocumentShareInput
|
|
250
|
+
): Promise<CollaborationTicket> {
|
|
251
|
+
const response = await parseResponse(
|
|
252
|
+
publicClient.shares[':shareId']['collaboration-ticket'].$post({
|
|
253
|
+
param: { shareId },
|
|
254
|
+
json: input
|
|
255
|
+
}),
|
|
256
|
+
collaborationTicketResponseSchema,
|
|
257
|
+
onDiagnostic
|
|
258
|
+
)
|
|
259
|
+
return response.ticket
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
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(page, (value) => value !== undefined)
|
|
36
|
+
}),
|
|
37
|
+
documentVersionsSchema,
|
|
38
|
+
onDiagnostic
|
|
39
|
+
)
|
|
40
|
+
},
|
|
41
|
+
async saveDocumentVersion(
|
|
42
|
+
documentId: string,
|
|
43
|
+
input: SaveDocumentVersionInput
|
|
44
|
+
): Promise<DocumentVersion> {
|
|
45
|
+
const response = await parseResponse(
|
|
46
|
+
client.documents[':documentId'].versions.$post({ param: { documentId }, json: input }),
|
|
47
|
+
documentVersionResponseSchema,
|
|
48
|
+
onDiagnostic
|
|
49
|
+
)
|
|
50
|
+
return response.version
|
|
51
|
+
},
|
|
52
|
+
async updateDocumentVersion(
|
|
53
|
+
documentId: string,
|
|
54
|
+
versionId: string,
|
|
55
|
+
input: UpdateDocumentVersionInput
|
|
56
|
+
): Promise<DocumentVersion> {
|
|
57
|
+
const response = await parseResponse(
|
|
58
|
+
client.documents[':documentId'].versions[':versionId'].$patch({
|
|
59
|
+
param: { documentId, versionId },
|
|
60
|
+
json: input
|
|
61
|
+
}),
|
|
62
|
+
documentVersionResponseSchema,
|
|
63
|
+
onDiagnostic
|
|
64
|
+
)
|
|
65
|
+
return response.version
|
|
66
|
+
},
|
|
67
|
+
async getDocumentVersion(
|
|
68
|
+
documentId: string,
|
|
69
|
+
versionId: string
|
|
70
|
+
): Promise<DocumentVersionDownload> {
|
|
71
|
+
return parseResponse(
|
|
72
|
+
client.documents[':documentId'].versions[':versionId'].$get({
|
|
73
|
+
param: { documentId, versionId }
|
|
74
|
+
}),
|
|
75
|
+
documentVersionDownloadSchema,
|
|
76
|
+
onDiagnostic
|
|
77
|
+
)
|
|
78
|
+
},
|
|
79
|
+
async restoreDocumentVersion(documentId: string, versionId: string) {
|
|
80
|
+
return parseResponse(
|
|
81
|
+
client.documents[':documentId'].versions[':versionId'].restore.$post({
|
|
82
|
+
param: { documentId, versionId }
|
|
83
|
+
}),
|
|
84
|
+
restoredDocumentSchema,
|
|
85
|
+
onDiagnostic
|
|
86
|
+
)
|
|
87
|
+
},
|
|
88
|
+
async duplicateDocumentVersion(
|
|
89
|
+
documentId: string,
|
|
90
|
+
versionId: string,
|
|
91
|
+
input: DuplicateDocumentVersionInput
|
|
92
|
+
): Promise<DocumentSummary> {
|
|
93
|
+
const response = await parseResponse(
|
|
94
|
+
client.documents[':documentId'].versions[':versionId'].duplicate.$post({
|
|
95
|
+
param: { documentId, versionId },
|
|
96
|
+
json: input
|
|
97
|
+
}),
|
|
98
|
+
documentResponseSchema,
|
|
99
|
+
onDiagnostic
|
|
100
|
+
)
|
|
101
|
+
return response.document
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
package/src/contract/account.ts
CHANGED
|
@@ -95,6 +95,54 @@ export const cloudPasskeySchema = v.object({
|
|
|
95
95
|
export const cloudPasskeysResponseSchema = v.object({ passkeys: v.array(cloudPasskeySchema) })
|
|
96
96
|
export const cloudPasskeyDeleteSchema = v.object({ id: v.string() })
|
|
97
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Personal access tokens: an account's own credentials for scripts and CI, sent as
|
|
100
|
+
* `Authorization: Bearer <token>`. A token acts as its account on the document API only; it never
|
|
101
|
+
* changes how the account is reached, makes other tokens, or reaches administration.
|
|
102
|
+
*/
|
|
103
|
+
export const CLOUD_ACCESS_TOKEN_PREFIX = 'opc_'
|
|
104
|
+
export const CLOUD_ACCESS_TOKEN_NAME_MAX_LENGTH = 64
|
|
105
|
+
export const CLOUD_ACCESS_TOKEN_MAX_DAYS = 365
|
|
106
|
+
export const cloudAccessTokenSchema = v.object({
|
|
107
|
+
id: v.string(),
|
|
108
|
+
name: v.string(),
|
|
109
|
+
/** The token's first characters, prefix included, to tell tokens apart; never the whole token. */
|
|
110
|
+
start: v.nullable(v.string()),
|
|
111
|
+
createdAt: v.string(),
|
|
112
|
+
expiresAt: v.nullable(v.string()),
|
|
113
|
+
lastUsedAt: v.nullable(v.string())
|
|
114
|
+
})
|
|
115
|
+
export const cloudAccessTokensResponseSchema = v.object({
|
|
116
|
+
tokens: v.array(cloudAccessTokenSchema)
|
|
117
|
+
})
|
|
118
|
+
export const cloudAccessTokenCreateSchema = v.object({
|
|
119
|
+
name: v.pipe(
|
|
120
|
+
v.string(),
|
|
121
|
+
v.trim(),
|
|
122
|
+
v.minLength(1),
|
|
123
|
+
v.maxLength(CLOUD_ACCESS_TOKEN_NAME_MAX_LENGTH)
|
|
124
|
+
),
|
|
125
|
+
expiresInDays: v.pipe(
|
|
126
|
+
v.number(),
|
|
127
|
+
v.integer(),
|
|
128
|
+
v.minValue(1),
|
|
129
|
+
v.maxValue(CLOUD_ACCESS_TOKEN_MAX_DAYS)
|
|
130
|
+
)
|
|
131
|
+
})
|
|
132
|
+
/** A new token, the only time the whole of it is shown. */
|
|
133
|
+
export const cloudAccessTokenCreatedResponseSchema = v.object({
|
|
134
|
+
token: v.pipe(v.string(), v.startsWith(CLOUD_ACCESS_TOKEN_PREFIX)),
|
|
135
|
+
accessToken: cloudAccessTokenSchema
|
|
136
|
+
})
|
|
137
|
+
export const cloudAccessTokenRevokeSchema = v.object({ id: v.pipe(v.string(), v.minLength(1)) })
|
|
138
|
+
|
|
139
|
+
export function parseCloudAccessTokenCreate(input: unknown) {
|
|
140
|
+
return v.parse(cloudAccessTokenCreateSchema, input)
|
|
141
|
+
}
|
|
142
|
+
export function parseCloudAccessTokenRevoke(input: unknown) {
|
|
143
|
+
return v.parse(cloudAccessTokenRevokeSchema, input)
|
|
144
|
+
}
|
|
145
|
+
|
|
98
146
|
export function parseCloudTermsAcceptance(input: unknown) {
|
|
99
147
|
return v.parse(cloudTermsAcceptanceSchema, input)
|
|
100
148
|
}
|
|
@@ -254,6 +302,8 @@ export type CloudAuthenticationMethods = v.InferOutput<
|
|
|
254
302
|
|
|
255
303
|
export type CloudAccountStatus = v.InferOutput<typeof cloudAccountStatusResponseSchema>
|
|
256
304
|
export type CloudProfile = v.InferOutput<typeof cloudProfileSchema>
|
|
305
|
+
export type CloudAccessToken = v.InferOutput<typeof cloudAccessTokenSchema>
|
|
306
|
+
export type CloudAccessTokenCreate = v.InferOutput<typeof cloudAccessTokenCreateSchema>
|
|
257
307
|
export type CloudSignInMethod = v.InferOutput<typeof cloudSignInMethodSchema>
|
|
258
308
|
export type CloudAccountSession = v.InferOutput<typeof cloudAccountSessionSchema>
|
|
259
309
|
export type CloudSignIn = v.InferOutput<typeof cloudSignInSchema>
|
|
@@ -0,0 +1,166 @@
|
|
|
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
|
+
/** Where the billing service answers, below the discovered `endpoint`. */
|
|
27
|
+
export const CLOUD_BILLING_API_PATHS = {
|
|
28
|
+
base: '/v1',
|
|
29
|
+
catalog: '/v1/catalog',
|
|
30
|
+
account: '/v1/account',
|
|
31
|
+
checkout: '/v1/checkout',
|
|
32
|
+
portal: '/v1/portal'
|
|
33
|
+
} as const
|
|
34
|
+
|
|
35
|
+
const urlSchema = v.pipe(v.string(), v.url())
|
|
36
|
+
const idSchema = v.pipe(v.string(), v.regex(/^[a-z0-9][a-z0-9-]{0,62}$/))
|
|
37
|
+
const centsSchema = v.pipe(v.number(), v.integer(), v.minValue(0))
|
|
38
|
+
const bytesSchema = v.pipe(v.number(), v.integer(), v.minValue(0))
|
|
39
|
+
const creditsSchema = v.pipe(v.number(), v.integer(), v.minValue(0))
|
|
40
|
+
|
|
41
|
+
export const cloudBillingDiscoverySchema = v.object({
|
|
42
|
+
endpoint: urlSchema,
|
|
43
|
+
contractVersion: v.literal(CLOUD_BILLING_CONTRACT_VERSION)
|
|
44
|
+
})
|
|
45
|
+
export type CloudBillingDiscovery = v.InferOutput<typeof cloudBillingDiscoverySchema>
|
|
46
|
+
|
|
47
|
+
export const billingTokenSchema = v.object({
|
|
48
|
+
token: v.pipe(v.string(), v.minLength(1)),
|
|
49
|
+
expiresAt: v.pipe(v.string(), v.isoTimestamp())
|
|
50
|
+
})
|
|
51
|
+
export type BillingToken = v.InferOutput<typeof billingTokenSchema>
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* What the billing service may rely on once a token's signature, issuer, audience, and expiry
|
|
55
|
+
* check. The account is the signed-in user, who buys and manages only their own plan.
|
|
56
|
+
*/
|
|
57
|
+
export const billingTokenClaimsSchema = v.object({
|
|
58
|
+
iss: urlSchema,
|
|
59
|
+
aud: v.literal(CLOUD_BILLING_TOKEN_AUDIENCE),
|
|
60
|
+
/** The account: the Cloud user whose plan and credits these are. */
|
|
61
|
+
sub: v.pipe(v.string(), v.minLength(1)),
|
|
62
|
+
/** Where the payment provider sends receipts and invoices. */
|
|
63
|
+
email: v.pipe(v.string(), v.email()),
|
|
64
|
+
iat: v.pipe(v.number(), v.integer()),
|
|
65
|
+
exp: v.pipe(v.number(), v.integer())
|
|
66
|
+
})
|
|
67
|
+
export type BillingTokenClaims = v.InferOutput<typeof billingTokenClaimsSchema>
|
|
68
|
+
|
|
69
|
+
/** A plan an account subscribes to, billed every month in US dollars before tax. */
|
|
70
|
+
export const billingPlanSchema = v.object({
|
|
71
|
+
id: idSchema,
|
|
72
|
+
name: v.pipe(v.string(), v.minLength(1)),
|
|
73
|
+
monthlyPriceCents: centsSchema,
|
|
74
|
+
storageBytes: bytesSchema,
|
|
75
|
+
monthlyCredits: creditsSchema
|
|
76
|
+
})
|
|
77
|
+
export type BillingPlan = v.InferOutput<typeof billingPlanSchema>
|
|
78
|
+
|
|
79
|
+
/** Credits an account on a plan buys once, in US dollars before tax. */
|
|
80
|
+
export const creditPackSchema = v.object({
|
|
81
|
+
id: idSchema,
|
|
82
|
+
credits: creditsSchema,
|
|
83
|
+
priceCents: centsSchema,
|
|
84
|
+
/** How long the credits last from purchase. */
|
|
85
|
+
validDays: v.pipe(v.number(), v.integer(), v.minValue(1))
|
|
86
|
+
})
|
|
87
|
+
export type CreditPack = v.InferOutput<typeof creditPackSchema>
|
|
88
|
+
|
|
89
|
+
/** What the service sells; an account without a plan has its deployment's free entitlements. */
|
|
90
|
+
export const billingCatalogSchema = v.object({
|
|
91
|
+
plans: v.array(billingPlanSchema),
|
|
92
|
+
creditPacks: v.array(creditPackSchema)
|
|
93
|
+
})
|
|
94
|
+
export type BillingCatalog = v.InferOutput<typeof billingCatalogSchema>
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The account's subscription as the payment provider holds it, or `null` without one. A
|
|
98
|
+
* `past_due` plan keeps its entitlements while payment is retried.
|
|
99
|
+
*/
|
|
100
|
+
export const billingAccountSchema = v.object({
|
|
101
|
+
subscription: v.nullable(
|
|
102
|
+
v.object({
|
|
103
|
+
planId: idSchema,
|
|
104
|
+
status: v.picklist(['active', 'past_due']),
|
|
105
|
+
/** When the current period ends: the next charge, or the end of a cancelled plan. */
|
|
106
|
+
currentPeriodEnd: v.pipe(v.string(), v.isoTimestamp()),
|
|
107
|
+
/** Whether the plan ends at `currentPeriodEnd` instead of renewing. */
|
|
108
|
+
cancelsAtPeriodEnd: v.boolean()
|
|
109
|
+
})
|
|
110
|
+
)
|
|
111
|
+
})
|
|
112
|
+
export type BillingAccount = v.InferOutput<typeof billingAccountSchema>
|
|
113
|
+
|
|
114
|
+
/** What to buy: a plan to subscribe to, or a credit pack. */
|
|
115
|
+
export const checkoutRequestSchema = v.union([
|
|
116
|
+
v.object({ planId: idSchema }),
|
|
117
|
+
v.object({ creditPackId: idSchema })
|
|
118
|
+
])
|
|
119
|
+
export type CheckoutRequest = v.InferOutput<typeof checkoutRequestSchema>
|
|
120
|
+
|
|
121
|
+
/** Where to send the person: the payment provider's checkout or account portal. */
|
|
122
|
+
export const billingRedirectSchema = v.object({
|
|
123
|
+
// Only the payment provider's own pages, never a scheme a browser would run.
|
|
124
|
+
url: v.pipe(urlSchema, v.regex(/^https:\/\//i, 'Billing sends people to an HTTPS page'))
|
|
125
|
+
})
|
|
126
|
+
export type BillingRedirect = v.InferOutput<typeof billingRedirectSchema>
|
|
127
|
+
|
|
128
|
+
export const billingErrorCodeSchema = v.picklist([
|
|
129
|
+
'invalid_request',
|
|
130
|
+
'unauthorized',
|
|
131
|
+
/** A credit pack for an account without a plan, or a plan it already has. */
|
|
132
|
+
'not_allowed',
|
|
133
|
+
'provider_unavailable'
|
|
134
|
+
])
|
|
135
|
+
export type BillingErrorCode = v.InferOutput<typeof billingErrorCodeSchema>
|
|
136
|
+
|
|
137
|
+
/** The HTTP status billing answers each error with. */
|
|
138
|
+
export const BILLING_ERROR_STATUS = {
|
|
139
|
+
invalid_request: 400,
|
|
140
|
+
unauthorized: 401,
|
|
141
|
+
not_allowed: 409,
|
|
142
|
+
provider_unavailable: 502
|
|
143
|
+
} as const satisfies Record<BillingErrorCode, number>
|
|
144
|
+
|
|
145
|
+
export const billingErrorSchema = v.object({
|
|
146
|
+
error: v.object({ code: billingErrorCodeSchema, message: v.optional(v.string()) })
|
|
147
|
+
})
|
|
148
|
+
export type BillingError = v.InferOutput<typeof billingErrorSchema>
|
|
149
|
+
|
|
150
|
+
/** The billing service's routes, for a typed Hono client (`hc<CloudBillingAPI>`). */
|
|
151
|
+
export type CloudBillingSchema = JSONRoute<
|
|
152
|
+
'get',
|
|
153
|
+
typeof CLOUD_BILLING_API_PATHS.catalog,
|
|
154
|
+
BlankInput,
|
|
155
|
+
BillingCatalog
|
|
156
|
+
> &
|
|
157
|
+
JSONRoute<'get', typeof CLOUD_BILLING_API_PATHS.account, BlankInput, BillingAccount> &
|
|
158
|
+
JSONRoute<
|
|
159
|
+
'post',
|
|
160
|
+
typeof CLOUD_BILLING_API_PATHS.checkout,
|
|
161
|
+
{ json: CheckoutRequest },
|
|
162
|
+
BillingRedirect
|
|
163
|
+
> &
|
|
164
|
+
JSONRoute<'post', typeof CLOUD_BILLING_API_PATHS.portal, BlankInput, BillingRedirect>
|
|
165
|
+
|
|
166
|
+
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(),
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as v from 'valibot'
|
|
2
|
+
|
|
3
|
+
import { documentDownloadSchema, documentKindSchema } from './documents'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Where a community document's thumbnail is served, by its document and revision: the address
|
|
7
|
+
* changes with each save, so a cached copy never shows an older state.
|
|
8
|
+
*/
|
|
9
|
+
export const COMMUNITY_THUMBNAIL_PATH = '/api/community/thumbnails'
|
|
10
|
+
|
|
11
|
+
export function communityThumbnailPath(documentId: string, revisionId: string): string {
|
|
12
|
+
return `${COMMUNITY_THUMBNAIL_PATH}/${documentId}/${revisionId}`
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** A version of a community document someone named, such as the release it was published for. */
|
|
16
|
+
export const communityVersionSchema = v.object({
|
|
17
|
+
id: v.pipe(v.string(), v.uuid()),
|
|
18
|
+
name: v.string(),
|
|
19
|
+
description: v.nullable(v.string()),
|
|
20
|
+
createdAt: v.string(),
|
|
21
|
+
/** Whether the document holds this version now, with nothing changed since it was named. */
|
|
22
|
+
current: v.boolean()
|
|
23
|
+
})
|
|
24
|
+
export type CommunityVersion = v.InferOutput<typeof communityVersionSchema>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A document in the deployment's community workspace, which anyone may open read-only: its name,
|
|
28
|
+
* when it last changed, its thumbnail's path on the server, and its named versions, newest first.
|
|
29
|
+
*/
|
|
30
|
+
export const communityDocumentSchema = v.object({
|
|
31
|
+
id: v.pipe(v.string(), v.uuid()),
|
|
32
|
+
name: v.string(),
|
|
33
|
+
kind: documentKindSchema,
|
|
34
|
+
updatedAt: v.string(),
|
|
35
|
+
revisionId: v.pipe(v.string(), v.uuid()),
|
|
36
|
+
thumbnailPath: v.string(),
|
|
37
|
+
versions: v.array(communityVersionSchema)
|
|
38
|
+
})
|
|
39
|
+
export type CommunityDocument = v.InferOutput<typeof communityDocumentSchema>
|
|
40
|
+
|
|
41
|
+
/** The community workspace's documents, most recently changed first. */
|
|
42
|
+
export const communityDocumentsSchema = v.object({ documents: v.array(communityDocumentSchema) })
|
|
43
|
+
export type CommunityDocuments = v.InferOutput<typeof communityDocumentsSchema>
|
|
44
|
+
|
|
45
|
+
/** Which state of a community document to open: a named version, or else the latest. */
|
|
46
|
+
export const communityDownloadQuerySchema = v.object({
|
|
47
|
+
version: v.optional(v.pipe(v.string(), v.uuid()))
|
|
48
|
+
})
|
|
49
|
+
export type CommunityDownloadQuery = v.InferOutput<typeof communityDownloadQuerySchema>
|
|
50
|
+
|
|
51
|
+
export function parseCommunityDownloadQuery(input: unknown): CommunityDownloadQuery {
|
|
52
|
+
return v.parse(communityDownloadQuerySchema, input)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** A community document, or one of its named versions, with where to download it. */
|
|
56
|
+
export const communityDownloadSchema = v.object({
|
|
57
|
+
document: documentDownloadSchema,
|
|
58
|
+
version: v.nullable(communityVersionSchema)
|
|
59
|
+
})
|
|
60
|
+
export type CommunityDownload = v.InferOutput<typeof communityDownloadSchema>
|