@open-pencil/cloud 0.17.0-beta.1 → 0.17.0-beta.4
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 +1 -1
- package/dist/bin/{ai-relay.mjs → services.mjs} +8 -8
- package/dist/bin/services.mjs.map +1 -0
- package/dist/client.d.ts +236 -46
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +649 -400
- package/dist/client.js.map +1 -1
- package/dist/contract.d.ts +2 -2
- package/dist/contract.js +2 -2
- package/dist/contract2.js +680 -443
- package/dist/contract2.js.map +1 -1
- package/dist/email.d.ts +9 -1
- package/dist/email.d.ts.map +1 -1
- package/dist/email.js +99 -58
- package/dist/email.js.map +1 -1
- package/dist/index.d.ts +468 -64
- package/dist/index.d.ts.map +1 -1
- package/dist/listen.mjs +575 -738
- package/dist/listen.mjs.map +1 -1
- package/dist/runtime-node.d.mts +6564 -2934
- package/dist/runtime-node.d.mts.map +1 -1
- package/dist/runtime-node.mjs +6 -5
- package/dist/runtime-node.mjs.map +1 -1
- package/dist/server.d.ts +8931 -4198
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +5260 -3859
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +5686 -3736
- package/dist/server.mjs.map +1 -1
- package/dist/server2.mjs +101 -79
- package/dist/server2.mjs.map +1 -1
- package/package.json +9 -6
- package/src/admin/api/routes.ts +103 -33
- package/src/admin/audit/service.ts +25 -6
- package/src/admin/documents/service.ts +361 -0
- package/src/admin/errors.ts +9 -1
- package/src/admin/index.ts +6 -0
- package/src/admin/operations/service.ts +7 -0
- package/src/admin/reports/service.ts +147 -0
- package/src/admin/schema.ts +6 -0
- package/src/client/api.ts +36 -21
- package/src/client/auth/navigation.ts +6 -5
- package/src/client/index.ts +7 -7
- package/src/client/portal/account.ts +25 -0
- package/src/client/portal/administration.ts +56 -0
- package/src/client/{ai.ts → services.ts} +44 -27
- package/src/contract/account.ts +58 -2
- package/src/contract/admin/index.ts +67 -3
- package/src/contract/collaboration.ts +6 -1
- package/src/contract/discovery.ts +22 -4
- package/src/contract/documents.ts +27 -0
- package/src/contract/entitlements.ts +2 -2
- package/src/contract/index.ts +63 -37
- package/src/contract/relay.ts +6 -0
- package/src/contract/reports.ts +42 -0
- package/src/contract/services.ts +233 -0
- package/src/contract/sharing.ts +3 -9
- package/src/email/render.ts +26 -0
- package/src/email/schema.ts +11 -1
- package/src/email/templates/brand.ts +1 -1
- package/src/runtime/cloudflare/environment.ts +31 -6
- package/src/runtime/cloudflare/index.ts +1 -1
- package/src/runtime/cloudflare/logging.ts +15 -0
- package/src/runtime/cloudflare/maintenance.ts +31 -0
- package/src/runtime/cloudflare/relay/index.ts +176 -0
- package/src/runtime/cloudflare/relay/sockets.ts +112 -0
- package/src/runtime/cloudflare/worker.ts +89 -26
- package/src/runtime/node/application.ts +5 -3
- package/src/runtime/node/bootstrap.ts +20 -4
- package/src/runtime/node/cleanup.ts +16 -3
- package/src/runtime/node/entitlements/main.ts +14 -11
- package/src/runtime/node/index.ts +1 -1
- package/src/runtime/node/migrate.ts +5 -1
- package/src/runtime/node/relay.ts +8 -2
- package/src/runtime/node/request-id.ts +13 -0
- package/src/runtime/node/server.ts +71 -15
- package/src/runtime/node/{ai-relay → services}/main.ts +6 -6
- package/src/runtime/node/{ai-relay → services}/server.ts +18 -18
- package/src/runtime/postgres/database.ts +20 -1
- package/src/runtime/posthog/errors.ts +32 -0
- package/src/runtime/s3/objects.ts +50 -1
- package/src/runtime/site/server.ts +33 -4
- package/src/server/account/actions.ts +5 -0
- package/src/server/account/deletion.ts +302 -0
- package/src/server/account/routes.ts +47 -3
- package/src/server/account/terms.ts +42 -0
- package/src/server/api/router.ts +12 -7
- package/src/server/api/types.ts +9 -0
- package/src/server/app.ts +93 -15
- package/src/server/auth/access-control.ts +63 -0
- package/src/server/auth/adapter.ts +11 -0
- package/src/server/auth/endpoints.ts +5 -1
- package/src/server/auth/factory.ts +30 -3
- package/src/server/auth/index.ts +10 -1
- package/src/server/cleanup/configured.ts +12 -5
- package/src/server/cleanup/documents.ts +165 -71
- package/src/server/cleanup/objects.ts +10 -2
- package/src/server/cleanup/revisions.ts +24 -7
- package/src/server/cleanup/uploads.ts +8 -2
- package/src/server/cleanup/worker.ts +5 -2
- package/src/server/collaboration/index.ts +3 -0
- package/src/server/collaboration/relay/connection.ts +196 -0
- package/src/server/collaboration/relay/documents.ts +13 -10
- package/src/server/collaboration/relay/hub.ts +279 -195
- package/src/server/collaboration/relay/index.ts +3 -1
- package/src/server/collaboration/relay/log.ts +79 -0
- package/src/server/collaboration/relay/persistence.ts +147 -22
- package/src/server/collaboration/relay/resume.ts +28 -0
- package/src/server/collaboration/routes.ts +27 -16
- package/src/server/collaboration/service.ts +27 -31
- package/src/server/config/deployment.ts +35 -4
- package/src/server/config/public.ts +5 -4
- package/src/server/config/schema.ts +104 -16
- package/src/server/db/expressions.ts +15 -1
- package/src/server/db/migrate.ts +34 -114
- package/src/server/db/migrations/001_accounts.ts +79 -0
- package/src/server/db/migrations/002_workspaces.ts +48 -0
- package/src/server/db/migrations/003_storage.ts +44 -0
- package/src/server/db/migrations/004_documents.ts +193 -0
- package/src/server/db/migrations/005_sharing.ts +95 -0
- package/src/server/db/migrations/006_operations.ts +110 -0
- package/src/server/db/migrations/007_trash.ts +33 -0
- package/src/server/db/migrations/008_terms.ts +18 -0
- package/src/server/db/migrations/schema.ts +71 -0
- package/src/server/db/tables.ts +70 -7
- package/src/server/documents/access.ts +66 -55
- package/src/server/documents/errors.ts +7 -0
- package/src/server/documents/images.ts +2 -1
- package/src/server/documents/limits.ts +9 -9
- package/src/server/documents/purge.ts +75 -0
- package/src/server/documents/repository.ts +2 -0
- package/src/server/documents/routes.ts +132 -80
- package/src/server/documents/service.ts +18 -4
- package/src/server/documents/summary.ts +1 -0
- package/src/server/documents/trash.ts +203 -0
- package/src/server/documents/versions/checkpoint.ts +2 -1
- package/src/server/documents/versions/history.ts +11 -7
- package/src/server/documents/versions/routes.ts +36 -25
- package/src/server/documents/versions/service.ts +22 -4
- package/src/server/errors/index.ts +99 -0
- package/src/server/errors/posthog.ts +80 -0
- package/src/server/index.ts +56 -16
- package/src/server/internal/index.ts +3 -3
- package/src/server/internal/routes.ts +7 -15
- package/src/server/internal/schema.ts +1 -1
- package/src/server/internal/service.ts +17 -23
- package/src/server/invitations/budget.ts +66 -0
- package/src/server/invitations/index.ts +1 -0
- package/src/server/logging.ts +76 -0
- package/src/server/objects/types.ts +12 -0
- package/src/server/pictures/routes.ts +4 -2
- package/src/server/pictures/service.ts +2 -1
- package/src/server/policy/database.ts +39 -25
- package/src/server/policy/index.ts +2 -1
- package/src/server/policy/keys.ts +5 -2
- package/src/server/policy/policy.ts +1 -0
- package/src/server/policy/schema.ts +2 -2
- package/src/server/policy/service.ts +12 -9
- package/src/server/policy/static.ts +5 -5
- package/src/server/policy/workspace.ts +41 -0
- package/src/server/quota/reconcile.ts +2 -0
- package/src/server/quota/storage.ts +69 -31
- package/src/server/rate-limit/cleanup.ts +17 -5
- package/src/server/rate-limit/index.ts +4 -1
- package/src/server/rate-limit/middleware.ts +100 -12
- package/src/server/reports/index.ts +8 -0
- package/src/server/reports/routes.ts +37 -0
- package/src/server/reports/service.ts +123 -0
- package/src/server/services/errors.ts +7 -0
- package/src/server/services/index.ts +8 -0
- package/src/server/{ai → services}/keys.ts +11 -11
- package/src/server/services/routes.ts +47 -0
- package/src/server/{ai/service.ts → services/tokens.ts} +23 -20
- package/src/server/sharing/capabilities/service.ts +68 -22
- package/src/server/sharing/document-routes.ts +30 -22
- package/src/server/sharing/grants/service.ts +11 -18
- package/src/server/sharing/http.ts +4 -0
- package/src/server/sharing/invitations/service.ts +21 -11
- package/src/server/sharing/policy.ts +9 -14
- package/src/server/sharing/routes.ts +108 -85
- package/src/server/sharing/service.ts +1 -17
- package/src/server/validation.ts +59 -2
- package/src/server/workspaces/index.ts +1 -0
- package/src/server/workspaces/members.ts +89 -38
- package/src/server/workspaces/repository.ts +2 -1
- package/src/server/workspaces/routes.ts +67 -45
- package/src/{ai-relay → services}/app.ts +48 -44
- package/src/{ai-relay → services}/config.ts +25 -19
- package/src/services/db/index.ts +10 -0
- package/src/services/db/migrate.ts +37 -0
- package/src/{ai-relay/db/migrations/001_usage.ts → services/db/migrations/001_baseline.ts} +18 -7
- package/src/services/db/schema.ts +22 -0
- package/src/services/index.ts +18 -0
- package/src/{ai-relay → services}/metering.ts +2 -2
- package/src/{ai-relay → services}/usage.ts +43 -19
- package/dist/bin/ai-relay.mjs.map +0 -1
- package/src/ai-relay/db/index.ts +0 -10
- package/src/ai-relay/db/migrate.ts +0 -32
- package/src/ai-relay/db/schema.ts +0 -20
- package/src/ai-relay/index.ts +0 -18
- package/src/contract/ai.ts +0 -150
- package/src/runtime/cloudflare/relay.ts +0 -136
- package/src/server/ai/errors.ts +0 -7
- package/src/server/ai/index.ts +0 -4
- package/src/server/ai/routes.ts +0 -43
- package/src/server/auth/workspace-access.ts +0 -23
- package/src/server/db/migrations/001_foundation.ts +0 -164
- package/src/server/db/migrations/002_upload_cleanup_claims.ts +0 -34
- package/src/server/db/migrations/003_document_cleanup_claims.ts +0 -23
- package/src/server/db/migrations/004_document_sharing.ts +0 -82
- package/src/server/db/migrations/005_document_collaboration_epoch.ts +0 -13
- package/src/server/db/migrations/006_invitation_continuation.ts +0 -27
- package/src/server/db/migrations/007_collaboration_state.ts +0 -25
- package/src/server/db/migrations/008_storage_reservations.ts +0 -37
- package/src/server/db/migrations/009_workspace_entitlements.ts +0 -22
- package/src/server/db/migrations/010_upload_finalization.ts +0 -22
- package/src/server/db/migrations/011_upload_finalization_lease.ts +0 -12
- package/src/server/db/migrations/012_transactional_email.ts +0 -48
- package/src/server/db/migrations/013_admin_enrollment.ts +0 -54
- package/src/server/db/migrations/014_enrollment_email_kinds.ts +0 -30
- package/src/server/db/migrations/015_cloud_rate_limit.ts +0 -22
- package/src/server/db/migrations/016_auth_schema.ts +0 -16
- package/src/server/db/migrations/017_authentication_email_kinds.ts +0 -32
- package/src/server/db/migrations/018_authentication_mfa.ts +0 -78
- package/src/server/db/migrations/019_better_auth_account_issuer.ts +0 -42
- package/src/server/db/migrations/020_workspace_invitations.ts +0 -57
- package/src/server/db/migrations/021_document_versions.ts +0 -66
- package/src/server/db/migrations/022_entitlement_external_version.ts +0 -17
- package/src/server/db/migrations/023_document_images.ts +0 -61
- package/src/server/db/migrations/024_account_activity.ts +0 -66
- package/src/server/db/migrations/025_table_names.ts +0 -58
- package/src/server/db/migrations/026_user_picture.ts +0 -30
- package/src/server/db/migrations/027_document_kind.ts +0 -19
- package/src/server/db/migrations/helpers.ts +0 -78
- /package/dist/bin/{ai-relay.d.mts → services.d.mts} +0 -0
|
@@ -18,18 +18,19 @@ export function cloudEditorReturnURL(discovery: CloudDiscovery, value: string):
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* The server's sign-in page, coming back to `returnURL` on its
|
|
22
|
-
* starts that provider's sign-in at once, while the server's pages
|
|
23
|
-
* and approval before the return.
|
|
21
|
+
* The server's sign-in page, or with `page` its sign-up page, coming back to `returnURL` on its
|
|
22
|
+
* editor afterwards. A `provider` starts that provider's sign-in at once, while the server's pages
|
|
23
|
+
* still handle two-step sign-in and approval before the return.
|
|
24
24
|
*/
|
|
25
25
|
export function cloudSignInURL(
|
|
26
26
|
discovery: CloudDiscovery,
|
|
27
27
|
returnURL: string,
|
|
28
|
-
provider?: CloudSocialProvider
|
|
28
|
+
provider?: CloudSocialProvider,
|
|
29
|
+
page: 'sign-in' | 'sign-up' = 'sign-in'
|
|
29
30
|
): string {
|
|
30
31
|
const offered = provider && discovery.authentication.socialProviders.includes(provider)
|
|
31
32
|
// The pages are at the server's root, whatever path the auth API has.
|
|
32
|
-
return withQuery(new URL(
|
|
33
|
+
return withQuery(new URL(`/auth/${page}`, discovery.authURL).href, {
|
|
33
34
|
redirect: withQuery('/auth/return', { editor: cloudEditorReturnURL(discovery, returnURL) }),
|
|
34
35
|
provider: offered ? provider : undefined
|
|
35
36
|
})
|
package/src/client/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
type
|
|
8
|
-
} from './
|
|
2
|
+
CloudServiceError,
|
|
3
|
+
cloudServicesFetch,
|
|
4
|
+
createCloudServicesClient,
|
|
5
|
+
type CloudServicesClient,
|
|
6
|
+
type CloudServicesClientOptions,
|
|
7
|
+
type CloudServicesTokenSource
|
|
8
|
+
} from './services'
|
|
9
9
|
export { cloudEditorReturnURL, cloudRedirectPath, cloudSignInURL } from './auth/navigation'
|
|
10
10
|
export {
|
|
11
11
|
CloudAPIError,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
cloudAccountDeletionResponseSchema,
|
|
2
3
|
cloudAccountMutationResponseSchema,
|
|
3
4
|
cloudAccountSessionsResponseSchema,
|
|
4
5
|
cloudAccountStatusResponseSchema,
|
|
@@ -25,6 +26,14 @@ export function createAccountAPI(call: CloudCall, { account }: PortalRouteClient
|
|
|
25
26
|
signal
|
|
26
27
|
)
|
|
27
28
|
},
|
|
29
|
+
/** Accepts the server's terms at `version`, the one its discovery names. */
|
|
30
|
+
acceptTerms(version: string, signal?: AbortSignal) {
|
|
31
|
+
return call(
|
|
32
|
+
(options) => account.terms.$post({ json: { version } }, options),
|
|
33
|
+
cloudAccountMutationResponseSchema,
|
|
34
|
+
signal
|
|
35
|
+
)
|
|
36
|
+
},
|
|
28
37
|
authenticationMethods(signal?: AbortSignal) {
|
|
29
38
|
return call(
|
|
30
39
|
(options) => account.authentication.$get(undefined, options),
|
|
@@ -172,6 +181,22 @@ export function createAccountAPI(call: CloudCall, { account }: PortalRouteClient
|
|
|
172
181
|
signal
|
|
173
182
|
)
|
|
174
183
|
},
|
|
184
|
+
/** What deleting the account takes, and the workspaces that stop it. */
|
|
185
|
+
accountDeletion(signal?: AbortSignal) {
|
|
186
|
+
return call(
|
|
187
|
+
(options) => account.deletion.$get(undefined, options),
|
|
188
|
+
cloudAccountDeletionResponseSchema,
|
|
189
|
+
signal
|
|
190
|
+
)
|
|
191
|
+
},
|
|
192
|
+
/** Deletes the account; a session that signed in a while ago gives its password. */
|
|
193
|
+
deleteAccount(password?: string, signal?: AbortSignal) {
|
|
194
|
+
return call(
|
|
195
|
+
(options) => account.delete.$post({ json: { password } }, options),
|
|
196
|
+
cloudAccountMutationResponseSchema,
|
|
197
|
+
signal
|
|
198
|
+
)
|
|
199
|
+
},
|
|
175
200
|
unlinkAuthenticationMethod(methodId: string, signal?: AbortSignal) {
|
|
176
201
|
return call(
|
|
177
202
|
(options) => account.authentication.unlink.$post({ json: { methodId } }, options),
|
|
@@ -3,12 +3,16 @@ import {
|
|
|
3
3
|
adminEmailResponseSchema,
|
|
4
4
|
adminMutationResponseSchema,
|
|
5
5
|
adminOperationsResponseSchema,
|
|
6
|
+
cloudAdminDocumentsResponseSchema,
|
|
7
|
+
cloudAdminReportsResponseSchema,
|
|
6
8
|
cloudAdminSessionResponseSchema,
|
|
7
9
|
cloudAdminUserDetailSchema,
|
|
8
10
|
cloudAdminUsersResponseSchema,
|
|
9
11
|
enrollmentReviewResponseSchema,
|
|
10
12
|
enrollmentsResponseSchema,
|
|
11
13
|
type CloudAdminAuditFilter,
|
|
14
|
+
type CloudAdminDocumentFilter,
|
|
15
|
+
type CloudAdminReportFilter,
|
|
12
16
|
type CloudAdminEmailFilter,
|
|
13
17
|
type CloudAdminUserFilter,
|
|
14
18
|
type EnrollmentStatus
|
|
@@ -119,6 +123,58 @@ export function createAdministrationAPI(call: CloudCall, { admin, api }: PortalR
|
|
|
119
123
|
signal
|
|
120
124
|
)
|
|
121
125
|
},
|
|
126
|
+
reports(request: AdminListRequest<CloudAdminReportFilter>, signal?: AbortSignal) {
|
|
127
|
+
return call(
|
|
128
|
+
(options) => admin.reports.$get(listQuery(request), options),
|
|
129
|
+
cloudAdminReportsResponseSchema,
|
|
130
|
+
signal
|
|
131
|
+
)
|
|
132
|
+
},
|
|
133
|
+
/** Closes a report: dismissed, or acted on outside a takedown. */
|
|
134
|
+
resolveReport(id: string, action: 'dismiss' | 'action', signal?: AbortSignal) {
|
|
135
|
+
return call(
|
|
136
|
+
(options) => admin.reports[':id'][action].$post({ param: { id } }, options),
|
|
137
|
+
adminMutationResponseSchema,
|
|
138
|
+
signal
|
|
139
|
+
)
|
|
140
|
+
},
|
|
141
|
+
documents(request: AdminListRequest<CloudAdminDocumentFilter>, signal?: AbortSignal) {
|
|
142
|
+
return call(
|
|
143
|
+
(options) => admin.documents.$get(listQuery(request), options),
|
|
144
|
+
cloudAdminDocumentsResponseSchema,
|
|
145
|
+
signal
|
|
146
|
+
)
|
|
147
|
+
},
|
|
148
|
+
/** Takes a document down, or puts it back. */
|
|
149
|
+
documentAction(
|
|
150
|
+
id: string,
|
|
151
|
+
action: 'disable' | 'enable' | 'undelete',
|
|
152
|
+
reason?: string,
|
|
153
|
+
signal?: AbortSignal
|
|
154
|
+
) {
|
|
155
|
+
return call(
|
|
156
|
+
(options) => {
|
|
157
|
+
if (action === 'disable') {
|
|
158
|
+
return admin.documents[':id'].disable.$post(
|
|
159
|
+
{ param: { id }, json: { reason } },
|
|
160
|
+
options
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
return action === 'enable'
|
|
164
|
+
? admin.documents[':id'].enable.$post({ param: { id } }, options)
|
|
165
|
+
: admin.documents[':id'].undelete.$post({ param: { id } }, options)
|
|
166
|
+
},
|
|
167
|
+
adminMutationResponseSchema,
|
|
168
|
+
signal
|
|
169
|
+
)
|
|
170
|
+
},
|
|
171
|
+
revokeShare(id: string, signal?: AbortSignal) {
|
|
172
|
+
return call(
|
|
173
|
+
(options) => admin.shares[':id'].revoke.$post({ param: { id } }, options),
|
|
174
|
+
adminMutationResponseSchema,
|
|
175
|
+
signal
|
|
176
|
+
)
|
|
177
|
+
},
|
|
122
178
|
operations(signal?: AbortSignal) {
|
|
123
179
|
return call(
|
|
124
180
|
(options) => admin.operations.$get(undefined, options),
|
|
@@ -1,30 +1,35 @@
|
|
|
1
1
|
import type { CloudFetch } from '#cloud/client/discovery'
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
type
|
|
9
|
-
type
|
|
3
|
+
serviceCatalogSchema,
|
|
4
|
+
serviceErrorSchema,
|
|
5
|
+
creditWalletSchema,
|
|
6
|
+
searchResponseSchema,
|
|
7
|
+
CLOUD_SERVICES_API_PATHS,
|
|
8
|
+
type ServiceCatalog,
|
|
9
|
+
type ServiceErrorCode,
|
|
10
|
+
type CreditWallet,
|
|
11
|
+
type SearchRequestInput,
|
|
12
|
+
type SearchResponse,
|
|
13
|
+
type CloudServicesAPI
|
|
10
14
|
} from '#cloud/contract'
|
|
15
|
+
import { hc } from 'hono/client'
|
|
11
16
|
import * as v from 'valibot'
|
|
12
17
|
|
|
13
18
|
/** Where a request gets the token it sends, and how it drops one the service refused. */
|
|
14
|
-
export type
|
|
19
|
+
export type CloudServicesTokenSource = {
|
|
15
20
|
token(): Promise<string>
|
|
16
21
|
/** Forgets `token`, so the next call signs a new one. */
|
|
17
22
|
invalidate(token: string): void
|
|
18
23
|
}
|
|
19
24
|
|
|
20
|
-
export class
|
|
21
|
-
override readonly name = '
|
|
25
|
+
export class CloudServiceError extends Error {
|
|
26
|
+
override readonly name = 'CloudServiceError'
|
|
22
27
|
|
|
23
28
|
constructor(
|
|
24
29
|
readonly status: number,
|
|
25
|
-
readonly code?:
|
|
30
|
+
readonly code?: ServiceErrorCode
|
|
26
31
|
) {
|
|
27
|
-
super(`OpenPencil
|
|
32
|
+
super(`OpenPencil services request failed with HTTP ${status}`)
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
35
|
|
|
@@ -39,7 +44,10 @@ function replayable(input: RequestInfo | URL, body: RequestInit['body']): boolea
|
|
|
39
44
|
* by a key Cloud has since replaced, is dropped and a request that can be replayed is sent once
|
|
40
45
|
* more with a new one.
|
|
41
46
|
*/
|
|
42
|
-
export function
|
|
47
|
+
export function cloudServicesFetch(
|
|
48
|
+
tokens: CloudServicesTokenSource,
|
|
49
|
+
fetch: CloudFetch
|
|
50
|
+
): CloudFetch {
|
|
43
51
|
const send = async (input: RequestInfo | URL, init: RequestInit | undefined, token: string) => {
|
|
44
52
|
const headers = new Headers(init?.headers)
|
|
45
53
|
headers.set('Authorization', `Bearer ${token}`)
|
|
@@ -55,42 +63,51 @@ export function cloudAIFetch(tokens: CloudAITokenSource, fetch: CloudFetch): Clo
|
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
65
|
|
|
58
|
-
const errorBodySchema = v.pipe(v.string(), v.parseJson(),
|
|
66
|
+
const errorBodySchema = v.pipe(v.string(), v.parseJson(), serviceErrorSchema)
|
|
59
67
|
|
|
60
68
|
async function parsed<TSchema extends v.GenericSchema>(
|
|
61
|
-
response: Response,
|
|
69
|
+
response: Pick<Response, 'ok' | 'status' | 'text'>,
|
|
62
70
|
schema: TSchema
|
|
63
71
|
): Promise<v.InferOutput<TSchema>> {
|
|
64
72
|
const text = await response.text()
|
|
65
73
|
if (!response.ok) {
|
|
66
74
|
const error = v.safeParse(errorBodySchema, text)
|
|
67
|
-
throw new
|
|
75
|
+
throw new CloudServiceError(
|
|
76
|
+
response.status,
|
|
77
|
+
error.success ? error.output.error.code : undefined
|
|
78
|
+
)
|
|
68
79
|
}
|
|
69
80
|
return v.parse(v.pipe(v.string(), v.parseJson(), schema), text)
|
|
70
81
|
}
|
|
71
82
|
|
|
72
|
-
export type
|
|
83
|
+
export type CloudServicesClientOptions = {
|
|
73
84
|
/** The service's endpoint, as Cloud's discovery names it. */
|
|
74
85
|
endpoint: string
|
|
75
|
-
tokens:
|
|
86
|
+
tokens: CloudServicesTokenSource
|
|
76
87
|
fetch: CloudFetch
|
|
77
88
|
}
|
|
78
89
|
|
|
79
|
-
/** The
|
|
80
|
-
export function
|
|
90
|
+
/** The services a Cloud advertises: the model API base URL, catalog, wallet, and search. */
|
|
91
|
+
export function createCloudServicesClient(options: CloudServicesClientOptions) {
|
|
81
92
|
const endpoint = options.endpoint.replace(/\/+$/, '')
|
|
82
|
-
const fetch =
|
|
93
|
+
const fetch = cloudServicesFetch(options.tokens, options.fetch)
|
|
94
|
+
// Answers are parsed rather than trusted: the service is deployed apart from this client.
|
|
95
|
+
const { v1 } = hc<CloudServicesAPI>(endpoint, { fetch })
|
|
83
96
|
return {
|
|
84
97
|
/** The base URL an OpenAI-compatible client sends chat completions below. */
|
|
85
|
-
modelBaseURL: `${endpoint}${
|
|
98
|
+
modelBaseURL: `${endpoint}${CLOUD_SERVICES_API_PATHS.base}`,
|
|
86
99
|
fetch,
|
|
87
|
-
async catalog(): Promise<
|
|
88
|
-
return parsed(await
|
|
100
|
+
async catalog(): Promise<ServiceCatalog> {
|
|
101
|
+
return parsed(await v1.catalog.$get(), serviceCatalogSchema)
|
|
102
|
+
},
|
|
103
|
+
async wallet(): Promise<CreditWallet> {
|
|
104
|
+
return parsed(await v1.wallet.$get(), creditWalletSchema)
|
|
89
105
|
},
|
|
90
|
-
|
|
91
|
-
|
|
106
|
+
/** A web search, charged to the workspace; only when the catalog lists `search`. */
|
|
107
|
+
async search(input: SearchRequestInput): Promise<SearchResponse> {
|
|
108
|
+
return parsed(await v1.search.$post({ json: input }), searchResponseSchema)
|
|
92
109
|
}
|
|
93
110
|
}
|
|
94
111
|
}
|
|
95
112
|
|
|
96
|
-
export type
|
|
113
|
+
export type CloudServicesClient = ReturnType<typeof createCloudServicesClient>
|
package/src/contract/account.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { isValid as isBase64 } from 'js-base64'
|
|
2
2
|
import * as v from 'valibot'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
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.
|
|
7
|
+
*/
|
|
8
|
+
export const cloudAccountStateSchema = v.picklist([
|
|
9
|
+
'active',
|
|
10
|
+
'pending',
|
|
11
|
+
'rejected',
|
|
12
|
+
'revoked',
|
|
13
|
+
'terms'
|
|
14
|
+
])
|
|
5
15
|
export const cloudIdentitySchema = v.object({
|
|
6
16
|
userId: v.string(),
|
|
7
17
|
email: v.pipe(v.string(), v.email()),
|
|
@@ -16,6 +26,9 @@ export const cloudAccountStatusResponseSchema = v.object({
|
|
|
16
26
|
state: cloudAccountStateSchema
|
|
17
27
|
})
|
|
18
28
|
|
|
29
|
+
/** Accepting the server's terms: the version the person read, which must be the current one. */
|
|
30
|
+
export const cloudTermsAcceptanceSchema = v.object({ version: v.pipe(v.string(), v.minLength(1)) })
|
|
31
|
+
|
|
19
32
|
export const cloudAuthenticationProviderSchema = v.picklist(['credential', 'google', 'apple'])
|
|
20
33
|
export const cloudAuthenticationMethodSchema = v.object({
|
|
21
34
|
id: v.string(),
|
|
@@ -47,7 +60,10 @@ export const accountSecurityErrorCodeSchema = v.picklist([
|
|
|
47
60
|
'email_unchanged',
|
|
48
61
|
'email_change_unavailable',
|
|
49
62
|
'current_session',
|
|
50
|
-
'picture_invalid'
|
|
63
|
+
'picture_invalid',
|
|
64
|
+
'account_sole_admin',
|
|
65
|
+
'last_admin_required',
|
|
66
|
+
'terms_changed'
|
|
51
67
|
])
|
|
52
68
|
export const accountSecurityErrorResponseSchema = v.object({
|
|
53
69
|
error: v.object({ code: accountSecurityErrorCodeSchema })
|
|
@@ -79,6 +95,9 @@ export const cloudPasskeySchema = v.object({
|
|
|
79
95
|
export const cloudPasskeysResponseSchema = v.object({ passkeys: v.array(cloudPasskeySchema) })
|
|
80
96
|
export const cloudPasskeyDeleteSchema = v.object({ id: v.string() })
|
|
81
97
|
|
|
98
|
+
export function parseCloudTermsAcceptance(input: unknown) {
|
|
99
|
+
return v.parse(cloudTermsAcceptanceSchema, input)
|
|
100
|
+
}
|
|
82
101
|
export function parseCloudMFAEnable(input: unknown) {
|
|
83
102
|
return v.parse(cloudMFAEnableSchema, input)
|
|
84
103
|
}
|
|
@@ -177,6 +196,39 @@ export const cloudSignInSchema = v.object({
|
|
|
177
196
|
})
|
|
178
197
|
export const cloudSignInsResponseSchema = v.object({ signIns: v.array(cloudSignInSchema) })
|
|
179
198
|
|
|
199
|
+
/** A workspace an account deletion reads: one it would delete, or one that stops it. */
|
|
200
|
+
export const cloudAccountDeletionWorkspaceSchema = v.object({
|
|
201
|
+
id: v.pipe(v.string(), v.uuid()),
|
|
202
|
+
name: v.string()
|
|
203
|
+
})
|
|
204
|
+
/** A document the account would lose, which Download all saves first. */
|
|
205
|
+
export const cloudAccountDeletionDocumentSchema = v.object({
|
|
206
|
+
id: v.pipe(v.string(), v.uuid()),
|
|
207
|
+
name: v.string(),
|
|
208
|
+
workspaceName: v.string()
|
|
209
|
+
})
|
|
210
|
+
/**
|
|
211
|
+
* What deleting the account takes: the workspaces only it belongs to, which go with their
|
|
212
|
+
* documents; the ones it leaves to their other members; the ones it alone administers for other
|
|
213
|
+
* members, which stop the deletion until it makes someone else an admin; and the documents it
|
|
214
|
+
* would lose, those workspaces' and the ones it created in workspaces it leaves.
|
|
215
|
+
*/
|
|
216
|
+
export const cloudAccountDeletionSchema = v.object({
|
|
217
|
+
/** The account is the deployment's only administrator, which also stops the deletion. */
|
|
218
|
+
lastAdministrator: v.boolean(),
|
|
219
|
+
blockedBy: v.array(cloudAccountDeletionWorkspaceSchema),
|
|
220
|
+
deletes: v.array(cloudAccountDeletionWorkspaceSchema),
|
|
221
|
+
leaves: v.array(cloudAccountDeletionWorkspaceSchema),
|
|
222
|
+
documents: v.array(cloudAccountDeletionDocumentSchema)
|
|
223
|
+
})
|
|
224
|
+
export const cloudAccountDeletionResponseSchema = v.object({
|
|
225
|
+
deletion: cloudAccountDeletionSchema
|
|
226
|
+
})
|
|
227
|
+
/** The password, for a session that signed in too long ago to delete the account on its own. */
|
|
228
|
+
export const cloudAccountDeleteSchema = v.object({
|
|
229
|
+
password: v.optional(v.pipe(v.string(), v.minLength(1)))
|
|
230
|
+
})
|
|
231
|
+
|
|
180
232
|
export function parseCloudProfileUpdate(input: unknown) {
|
|
181
233
|
return v.parse(cloudProfileUpdateSchema, input)
|
|
182
234
|
}
|
|
@@ -186,6 +238,9 @@ export function parseCloudPictureUpload(input: unknown) {
|
|
|
186
238
|
export function parseCloudEmailChange(input: unknown) {
|
|
187
239
|
return v.parse(cloudEmailChangeSchema, input)
|
|
188
240
|
}
|
|
241
|
+
export function parseCloudAccountDelete(input: unknown) {
|
|
242
|
+
return v.parse(cloudAccountDeleteSchema, input)
|
|
243
|
+
}
|
|
189
244
|
export function parseCloudSessionRevoke(input: unknown) {
|
|
190
245
|
return v.parse(cloudSessionRevokeSchema, input)
|
|
191
246
|
}
|
|
@@ -202,3 +257,4 @@ export type CloudProfile = v.InferOutput<typeof cloudProfileSchema>
|
|
|
202
257
|
export type CloudSignInMethod = v.InferOutput<typeof cloudSignInMethodSchema>
|
|
203
258
|
export type CloudAccountSession = v.InferOutput<typeof cloudAccountSessionSchema>
|
|
204
259
|
export type CloudSignIn = v.InferOutput<typeof cloudSignInSchema>
|
|
260
|
+
export type CloudAccountDeletion = v.InferOutput<typeof cloudAccountDeletionSchema>
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
cloudPersonSchema,
|
|
8
8
|
cloudSignInSchema
|
|
9
9
|
} from '../account'
|
|
10
|
+
import { documentReportReasonSchema } from '../reports'
|
|
10
11
|
import { workspaceRoleSchema } from '../workspaces'
|
|
11
12
|
|
|
12
13
|
const timestampSchema = v.pipe(v.string(), v.isoTimestamp())
|
|
@@ -39,7 +40,9 @@ export const adminErrorCodeSchema = v.picklist([
|
|
|
39
40
|
'last_admin_required',
|
|
40
41
|
'self_admin_action_forbidden',
|
|
41
42
|
'email_regeneration_unavailable',
|
|
42
|
-
'mfa_required'
|
|
43
|
+
'mfa_required',
|
|
44
|
+
'document_not_restorable',
|
|
45
|
+
'workspace_gone'
|
|
43
46
|
])
|
|
44
47
|
|
|
45
48
|
export const adminErrorResponseSchema = v.object({
|
|
@@ -147,23 +150,79 @@ export const adminAuditEventSchema = v.object({
|
|
|
147
150
|
id: v.string(),
|
|
148
151
|
actor: auditPartySchema,
|
|
149
152
|
action: v.string(),
|
|
150
|
-
/** What the event is about: an account, an access request, or
|
|
153
|
+
/** What the event is about: an account, an access request, an email, or a document. */
|
|
151
154
|
subject: v.object({ ...auditPartySchema.entries, type: v.string() }),
|
|
152
155
|
metadata: v.unknown(),
|
|
153
156
|
createdAt: timestampSchema
|
|
154
157
|
})
|
|
155
158
|
/** Which events a list of activity shows, by what they are about. */
|
|
156
|
-
export const cloudAdminAuditFilterSchema = v.picklist([
|
|
159
|
+
export const cloudAdminAuditFilterSchema = v.picklist([
|
|
160
|
+
'all',
|
|
161
|
+
'accounts',
|
|
162
|
+
'requests',
|
|
163
|
+
'email',
|
|
164
|
+
'documents'
|
|
165
|
+
])
|
|
157
166
|
export const adminAuditResponseSchema = v.object({
|
|
158
167
|
events: v.array(adminAuditEventSchema),
|
|
159
168
|
...listTotals(cloudAdminAuditFilterSchema.options)
|
|
160
169
|
})
|
|
161
170
|
|
|
171
|
+
/** A document as the console shows it: where it lives, who made it, and whether it is taken down. */
|
|
172
|
+
export const cloudAdminDocumentSchema = v.object({
|
|
173
|
+
id: v.string(),
|
|
174
|
+
name: v.string(),
|
|
175
|
+
workspace: v.object({ id: v.string(), name: v.string() }),
|
|
176
|
+
/** Who made it, while the server knows them. */
|
|
177
|
+
owner: v.nullable(v.object({ id: v.string(), name: v.string(), email: v.string() })),
|
|
178
|
+
createdAt: timestampSchema,
|
|
179
|
+
updatedAt: timestampSchema,
|
|
180
|
+
disabledAt: nullableTimestampSchema,
|
|
181
|
+
disabledReason: v.nullable(v.string()),
|
|
182
|
+
/** Reports about it still waiting for a decision. */
|
|
183
|
+
openReports: countSchema,
|
|
184
|
+
/**
|
|
185
|
+
* When someone deleted it forever, and when cleanup destroys it; until then an administrator
|
|
186
|
+
* can still restore it. Servers from before Trash send neither.
|
|
187
|
+
*/
|
|
188
|
+
purgedAt: v.optional(nullableTimestampSchema, null),
|
|
189
|
+
destroyedAt: v.optional(nullableTimestampSchema, null)
|
|
190
|
+
})
|
|
191
|
+
/** Which documents a list shows: live ones, or those deleted forever an administrator can restore. */
|
|
192
|
+
export const cloudAdminDocumentFilterSchema = v.picklist(['all', 'reported', 'disabled', 'purged'])
|
|
193
|
+
export const cloudAdminDocumentsResponseSchema = v.object({
|
|
194
|
+
documents: v.array(cloudAdminDocumentSchema),
|
|
195
|
+
...listTotals(cloudAdminDocumentFilterSchema.options)
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
export const cloudAdminReportStatusSchema = v.picklist(['open', 'dismissed', 'actioned'])
|
|
199
|
+
export const cloudAdminReportSchema = v.object({
|
|
200
|
+
id: v.string(),
|
|
201
|
+
reason: documentReportReasonSchema,
|
|
202
|
+
description: v.string(),
|
|
203
|
+
status: cloudAdminReportStatusSchema,
|
|
204
|
+
/** The account that filed it, or null for a guest. */
|
|
205
|
+
reporter: v.nullable(v.object({ id: v.string(), name: v.nullable(v.string()) })),
|
|
206
|
+
replyEmail: v.nullable(v.string()),
|
|
207
|
+
createdAt: timestampSchema,
|
|
208
|
+
resolvedAt: nullableTimestampSchema,
|
|
209
|
+
document: cloudAdminDocumentSchema,
|
|
210
|
+
/** The link it was opened from, and whether that link still works. */
|
|
211
|
+
share: v.nullable(v.object({ id: v.string(), revoked: v.boolean() }))
|
|
212
|
+
})
|
|
213
|
+
/** Which reports a list shows, by where they stand. */
|
|
214
|
+
export const cloudAdminReportFilterSchema = v.picklist(['open', 'actioned', 'dismissed', 'all'])
|
|
215
|
+
export const cloudAdminReportsResponseSchema = v.object({
|
|
216
|
+
reports: v.array(cloudAdminReportSchema),
|
|
217
|
+
...listTotals(cloudAdminReportFilterSchema.options)
|
|
218
|
+
})
|
|
219
|
+
|
|
162
220
|
export const adminOperationsResponseSchema = v.object({
|
|
163
221
|
deployment: v.picklist(['official', 'self-hosted']),
|
|
164
222
|
enrollmentMode: v.picklist(['open', 'approval', 'closed']),
|
|
165
223
|
emailTransport: v.picklist(['none', 'smtp', 'cloudflare']),
|
|
166
224
|
pendingEnrollment: v.pipe(v.number(), v.integer(), v.minValue(0)),
|
|
225
|
+
openReports: countSchema,
|
|
167
226
|
pendingEmail: v.pipe(v.number(), v.integer(), v.minValue(0)),
|
|
168
227
|
failedEmail: v.pipe(v.number(), v.integer(), v.minValue(0)),
|
|
169
228
|
accounts: countSchema,
|
|
@@ -185,3 +244,8 @@ export type CloudAdminUserDetail = v.InferOutput<typeof cloudAdminUserDetailSche
|
|
|
185
244
|
export type TransactionalEmailAdmin = v.InferOutput<typeof transactionalEmailAdminSchema>
|
|
186
245
|
export type AdminAuditEvent = v.InferOutput<typeof adminAuditEventSchema>
|
|
187
246
|
export type AdminOperations = v.InferOutput<typeof adminOperationsResponseSchema>
|
|
247
|
+
export type CloudAdminDocument = v.InferOutput<typeof cloudAdminDocumentSchema>
|
|
248
|
+
export type CloudAdminDocumentFilter = v.InferOutput<typeof cloudAdminDocumentFilterSchema>
|
|
249
|
+
export type CloudAdminReport = v.InferOutput<typeof cloudAdminReportSchema>
|
|
250
|
+
export type CloudAdminReportFilter = v.InferOutput<typeof cloudAdminReportFilterSchema>
|
|
251
|
+
export type CloudAdminReportStatus = v.InferOutput<typeof cloudAdminReportStatusSchema>
|
|
@@ -40,6 +40,11 @@ export const collaborationTicketSchema = v.object({
|
|
|
40
40
|
permission: documentPermissionSchema,
|
|
41
41
|
roomEpoch: v.pipe(v.number(), v.integer(), v.minValue(0)),
|
|
42
42
|
expiresAt: v.string(),
|
|
43
|
-
serverEnforcedWrites: v.boolean()
|
|
43
|
+
serverEnforcedWrites: v.boolean(),
|
|
44
|
+
/**
|
|
45
|
+
* Whether the relay answers `RELAY_HEARTBEAT`. A relay from before it takes a ping for a
|
|
46
|
+
* malformed frame and turns the peer away, so editors ask only a relay that says it answers.
|
|
47
|
+
*/
|
|
48
|
+
relayHeartbeat: v.optional(v.boolean(), false)
|
|
44
49
|
})
|
|
45
50
|
export type CollaborationTicket = v.InferOutput<typeof collaborationTicketSchema>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as v from 'valibot'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { cloudServicesDiscoverySchema, cloudBillingDiscoverySchema } from './services'
|
|
4
4
|
|
|
5
5
|
export const CLOUD_PROTOCOL_VERSION = '1' as const
|
|
6
6
|
export const CLOUD_DISCOVERY_PATH = '/.well-known/openpencil' as const
|
|
@@ -54,6 +54,23 @@ export const cloudEditorVersionSchema = v.pipe(v.string(), v.regex(/^\d+\.\d+\.\
|
|
|
54
54
|
export const cloudListingSchema = v.object({ minimumEditorVersion: cloudEditorVersionSchema })
|
|
55
55
|
export type CloudListing = v.InferOutput<typeof cloudListingSchema>
|
|
56
56
|
|
|
57
|
+
const legalURLSchema = v.pipe(v.string(), v.url())
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The operator's legal links, which clients show at sign-up and in account pages. A server that
|
|
61
|
+
* names none shows none; `requireAcceptance` means an account accepts `termsVersion` before it uses
|
|
62
|
+
* the server.
|
|
63
|
+
*/
|
|
64
|
+
export const cloudLegalDiscoverySchema = v.object({
|
|
65
|
+
termsURL: v.optional(legalURLSchema),
|
|
66
|
+
privacyURL: v.optional(legalURLSchema),
|
|
67
|
+
termsVersion: v.optional(v.string()),
|
|
68
|
+
requireAcceptance: v.boolean(),
|
|
69
|
+
abuseEmail: v.optional(v.pipe(v.string(), v.email())),
|
|
70
|
+
minimumAge: v.optional(v.pipe(v.number(), v.integer()))
|
|
71
|
+
})
|
|
72
|
+
export type CloudLegalDiscovery = v.InferOutput<typeof cloudLegalDiscoverySchema>
|
|
73
|
+
|
|
57
74
|
export const cloudDiscoverySchema = v.object({
|
|
58
75
|
protocolVersion: v.literal(CLOUD_PROTOCOL_VERSION),
|
|
59
76
|
deployment: cloudDeploymentSchema,
|
|
@@ -64,10 +81,11 @@ export const cloudDiscoverySchema = v.object({
|
|
|
64
81
|
authentication: cloudAuthenticationSchema,
|
|
65
82
|
capabilities: cloudCapabilitiesSchema,
|
|
66
83
|
listing: v.optional(cloudListingSchema),
|
|
67
|
-
/** The
|
|
68
|
-
|
|
84
|
+
/** The services editors reach with Cloud-signed tokens; absent when the deployment has none. */
|
|
85
|
+
services: v.optional(cloudServicesDiscoverySchema),
|
|
69
86
|
/** Where people manage their plan and buy credits; absent when the deployment does not bill. */
|
|
70
|
-
billing: v.optional(cloudBillingDiscoverySchema)
|
|
87
|
+
billing: v.optional(cloudBillingDiscoverySchema),
|
|
88
|
+
legal: v.optional(cloudLegalDiscoverySchema)
|
|
71
89
|
})
|
|
72
90
|
export type CloudDiscovery = v.InferOutput<typeof cloudDiscoverySchema>
|
|
73
91
|
|
|
@@ -12,6 +12,14 @@ export function isCloudChecksum(value: string): boolean {
|
|
|
12
12
|
/** The most images one revision, or one request for image uploads, may name. */
|
|
13
13
|
export const CLOUD_MAX_DOCUMENT_IMAGES = 10_000
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* The most a Cloud API request body may hold; a server refuses anything past it before reading
|
|
17
|
+
* it. Files go to the object store, never through the API, so only lists grow large: a save's
|
|
18
|
+
* images fit with room to spare, and a client commits image uploads, whose part lists can run
|
|
19
|
+
* long, in batches under half of it.
|
|
20
|
+
*/
|
|
21
|
+
export const CLOUD_API_MAX_BODY_BYTES = 8 * 1024 * 1024
|
|
22
|
+
|
|
15
23
|
/**
|
|
16
24
|
* An image's name inside a `.fig` file that Cloud stores apart from it: the SHA-1 Figma names it
|
|
17
25
|
* by, or an older plain name. A client leaves images under other names inside the file.
|
|
@@ -89,6 +97,25 @@ export const sharedDocumentSchema = v.object({
|
|
|
89
97
|
})
|
|
90
98
|
export type SharedDocument = v.InferOutput<typeof sharedDocumentSchema>
|
|
91
99
|
|
|
100
|
+
/**
|
|
101
|
+
* A document in Trash the person may restore: who deleted it and when, and when it goes for good.
|
|
102
|
+
* `canPurge` says whether they may also delete it for good before then.
|
|
103
|
+
*/
|
|
104
|
+
export const trashedDocumentSchema = v.object({
|
|
105
|
+
id: v.pipe(v.string(), v.uuid()),
|
|
106
|
+
workspaceId: v.pipe(v.string(), v.uuid()),
|
|
107
|
+
workspaceName: v.string(),
|
|
108
|
+
name: v.string(),
|
|
109
|
+
kind: v.optional(documentKindSchema, 'design'),
|
|
110
|
+
deletedAt: v.string(),
|
|
111
|
+
deletedBy: v.nullable(v.object({ name: v.string() })),
|
|
112
|
+
purgeAt: v.string(),
|
|
113
|
+
canPurge: v.boolean()
|
|
114
|
+
})
|
|
115
|
+
export type TrashedDocument = v.InferOutput<typeof trashedDocumentSchema>
|
|
116
|
+
|
|
117
|
+
export const trashSchema = v.object({ documents: v.array(trashedDocumentSchema) })
|
|
118
|
+
|
|
92
119
|
export const documentDownloadSchema = v.object({
|
|
93
120
|
document: documentSummarySchema,
|
|
94
121
|
revisionId: v.pipe(v.string(), v.uuid()),
|
|
@@ -8,8 +8,8 @@ export const workspaceEntitlementsSchema = v.object({
|
|
|
8
8
|
guestPresence: v.boolean(),
|
|
9
9
|
collaboration: v.boolean(),
|
|
10
10
|
revisionHistory: v.boolean(),
|
|
11
|
-
// Optional so editors keep reading servers released before
|
|
12
|
-
|
|
11
|
+
// Optional so editors keep reading servers released before services.
|
|
12
|
+
cloudServices: v.optional(v.boolean(), false)
|
|
13
13
|
}),
|
|
14
14
|
limits: v.object({
|
|
15
15
|
maximumFileBytes: v.pipe(v.number(), v.integer(), v.minValue(1)),
|