@open-pencil/cloud 0.17.0-beta.2 → 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 +3 -2
- package/dist/bin/server.mjs +1 -1
- package/dist/bin/server.mjs.map +1 -1
- package/dist/bin/{ai-relay.mjs → services.mjs} +9 -9
- package/dist/bin/services.mjs.map +1 -0
- package/dist/client.d.ts +525 -66
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1257 -654
- package/dist/client.js.map +1 -1
- package/dist/contract.d.ts +2 -2
- package/dist/contract.js +2 -2
- package/dist/contract2.js +1028 -481
- package/dist/contract2.js.map +1 -1
- package/dist/email.d.ts +1780 -31
- package/dist/email.d.ts.map +1 -1
- package/dist/email.js +3556 -325
- 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 +929 -72
- 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 +802 -927
- 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 +7166 -3101
- 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 +6525 -2205
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +12500 -7613
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +8625 -2878
- package/dist/server.mjs.map +1 -1
- package/dist/server2.mjs +101 -79
- package/dist/server2.mjs.map +1 -1
- package/package.json +27 -9
- package/src/admin/api/routes.ts +59 -0
- package/src/admin/audit/service.ts +27 -8
- package/src/admin/documents/service.ts +431 -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 +153 -0
- package/src/admin/schema.ts +6 -0
- package/src/client/api.ts +28 -461
- package/src/client/auth/client.ts +22 -3
- package/src/client/auth/navigation.ts +6 -5
- 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 +14 -7
- package/src/client/portal/account.ts +79 -2
- package/src/client/portal/administration.ts +56 -0
- 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 +118 -0
- package/src/client/sharing.ts +262 -0
- package/src/client/versions.ts +104 -0
- package/src/contract/account.ts +108 -2
- package/src/contract/admin/index.ts +67 -3
- package/src/contract/billing.ts +166 -0
- package/src/contract/collaboration.ts +11 -1
- package/src/contract/community.ts +60 -0
- package/src/contract/discovery.ts +83 -4
- package/src/contract/documents.ts +27 -0
- package/src/contract/entitlements.ts +12 -2
- package/src/contract/index.ts +114 -39
- package/src/contract/links.ts +57 -4
- package/src/contract/locale.ts +27 -0
- package/src/contract/portal.ts +12 -1
- package/src/contract/relay.ts +6 -0
- package/src/contract/reports.ts +42 -0
- package/src/contract/routes.ts +10 -0
- package/src/contract/services.ts +235 -0
- package/src/contract/sharing.ts +3 -9
- 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 +138 -246
- package/src/email/samples.ts +115 -0
- package/src/email/schema.ts +79 -5
- 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/errors/posthog.ts +80 -0
- package/src/global.d.ts +7 -0
- package/src/runtime/cloudflare/environment.ts +22 -11
- 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 +69 -15
- package/src/runtime/cloudflare/tsconfig.json +2 -1
- package/src/runtime/cloudflare/worker.ts +46 -13
- package/src/runtime/node/application.ts +5 -3
- package/src/runtime/node/bootstrap.ts +15 -4
- package/src/runtime/node/cleanup.ts +20 -3
- package/src/runtime/node/email/transport.ts +13 -10
- package/src/runtime/node/entitlements/main.ts +14 -11
- package/src/runtime/node/index.ts +1 -1
- package/src/runtime/node/main.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 +50 -16
- package/src/runtime/node/{ai-relay → services}/main.ts +7 -7
- 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 +15 -30
- package/src/runtime/s3/objects.ts +41 -1
- package/src/runtime/site/community.ts +101 -0
- package/src/runtime/site/server.ts +49 -6
- package/src/server/account/actions.ts +5 -0
- package/src/server/account/deletion.ts +304 -0
- package/src/server/account/routes.ts +281 -206
- package/src/server/account/terms.ts +42 -0
- package/src/server/account/tokens.ts +57 -0
- package/src/server/api/router.ts +32 -5
- package/src/server/api/types.ts +2 -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-control.ts +63 -0
- package/src/server/auth/access-tokens.ts +62 -0
- package/src/server/auth/adapter.ts +32 -1
- package/src/server/auth/email.ts +4 -1
- package/src/server/auth/endpoints.ts +5 -1
- package/src/server/auth/enrollment.ts +116 -0
- package/src/server/auth/factory.ts +116 -132
- package/src/server/auth/index.ts +10 -1
- 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 +27 -7
- package/src/server/cleanup/documents.ts +165 -71
- package/src/server/cleanup/revisions.ts +16 -5
- package/src/server/cleanup/uploads.ts +8 -2
- package/src/server/cleanup/worker.ts +15 -3
- package/src/server/collaboration/relay/connection.ts +4 -3
- package/src/server/collaboration/relay/documents.ts +13 -10
- package/src/server/collaboration/relay/hub.ts +77 -122
- package/src/server/collaboration/relay/log.ts +5 -2
- package/src/server/collaboration/relay/room.ts +154 -0
- package/src/server/collaboration/service.ts +48 -33
- 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 +41 -9
- package/src/server/config/index.ts +1 -1
- package/src/server/config/public.ts +11 -4
- package/src/server/config/schema.ts +91 -277
- package/src/server/config/toml/schema.ts +307 -0
- package/src/server/db/expressions.ts +15 -1
- package/src/server/db/index.ts +1 -0
- package/src/server/db/migrate.ts +46 -116
- 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/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 +96 -0
- package/src/server/db/tables.ts +82 -4
- package/src/server/db/users.ts +22 -0
- 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/index.ts +1 -1
- package/src/server/documents/limits.ts +14 -8
- package/src/server/documents/purge.ts +75 -0
- package/src/server/documents/repository.ts +2 -0
- package/src/server/documents/routes.ts +26 -0
- package/src/server/documents/service.ts +30 -406
- package/src/server/documents/summary.ts +1 -0
- package/src/server/documents/trash.ts +203 -0
- package/src/server/documents/uploads.ts +450 -0
- package/src/server/documents/versions/checkpoint.ts +2 -1
- package/src/server/documents/versions/history.ts +11 -7
- package/src/server/documents/versions/service.ts +94 -28
- 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 +51 -16
- package/src/server/index.ts +52 -16
- package/src/server/internal/index.ts +3 -3
- package/src/server/internal/routes.ts +7 -10
- 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/invitations/types.ts +5 -1
- package/src/server/logging.ts +76 -0
- package/src/server/objects/types.ts +5 -0
- package/src/server/pictures/service.ts +2 -1
- package/src/server/policy/configured.ts +9 -3
- package/src/server/policy/database.ts +52 -27
- package/src/server/policy/index.ts +2 -1
- package/src/server/policy/keys.ts +5 -2
- package/src/server/policy/policy.ts +40 -12
- package/src/server/policy/schema.ts +2 -2
- package/src/server/policy/service.ts +78 -56
- package/src/server/policy/static.ts +5 -5
- package/src/server/policy/storage.ts +33 -0
- package/src/server/policy/workspace.ts +41 -0
- package/src/server/quota/index.ts +6 -0
- package/src/server/quota/notices.ts +121 -0
- package/src/server/quota/reconcile.ts +2 -0
- package/src/server/quota/storage.ts +74 -31
- package/src/server/rate-limit/cleanup.ts +17 -5
- package/src/server/rate-limit/middleware.ts +6 -2
- package/src/server/reports/index.ts +9 -0
- package/src/server/reports/replies.ts +55 -0
- package/src/server/reports/routes.ts +39 -0
- package/src/server/reports/service.ts +145 -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 -23
- package/src/server/sharing/grants/service.ts +11 -18
- package/src/server/sharing/http.ts +4 -0
- package/src/server/sharing/invitations/service.ts +35 -15
- package/src/server/sharing/policy.ts +9 -14
- package/src/server/sharing/routes.ts +0 -16
- package/src/server/sharing/service.ts +1 -17
- package/src/server/validation.ts +4 -0
- package/src/server/workspaces/index.ts +1 -0
- package/src/server/workspaces/members.ts +91 -52
- package/src/server/workspaces/repository.ts +2 -1
- package/src/server/workspaces/routes.ts +4 -0
- package/src/{ai-relay → services}/app.ts +46 -44
- package/src/{ai-relay → services}/config.ts +26 -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 +35 -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/client/ai.ts +0 -96
- package/src/contract/ai.ts +0 -150
- 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/ai/errors.ts +0 -7
- package/src/server/ai/index.ts +0 -4
- package/src/server/ai/routes.ts +0 -43
- package/src/server/app.ts +0 -379
- 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/028_collaboration_updates.ts +0 -84
- package/src/server/db/migrations/helpers.ts +0 -78
- /package/dist/bin/{ai-relay.d.mts → services.d.mts} +0 -0
|
@@ -51,6 +51,7 @@ export async function listDocuments(
|
|
|
51
51
|
])
|
|
52
52
|
.where('workspaceId', '=', workspaceId)
|
|
53
53
|
.where('deletedAt', 'is', null)
|
|
54
|
+
.where('disabledAt', 'is', null)
|
|
54
55
|
.orderBy('updatedAt', 'desc')
|
|
55
56
|
.execute()
|
|
56
57
|
return rows.map(documentSummary)
|
|
@@ -82,6 +83,7 @@ export async function listSharedDocuments(
|
|
|
82
83
|
.where('documentGrant.userId', '=', userId)
|
|
83
84
|
.where('documentGrant.revokedAt', 'is', null)
|
|
84
85
|
.where('document.deletedAt', 'is', null)
|
|
86
|
+
.where('document.disabledAt', 'is', null)
|
|
85
87
|
.where((expression) =>
|
|
86
88
|
expression.not(
|
|
87
89
|
expression.exists(
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
DocumentConflictError,
|
|
13
13
|
DocumentForbiddenError,
|
|
14
14
|
DocumentNotFoundError,
|
|
15
|
+
DocumentPurgeFailedError,
|
|
15
16
|
UploadInvalidError
|
|
16
17
|
} from '#cloud/server/documents/errors'
|
|
17
18
|
import type { DocumentService } from '#cloud/server/documents/service'
|
|
@@ -50,6 +51,10 @@ export function documentDomainError(context: Context, error: unknown): Response
|
|
|
50
51
|
if (error instanceof StorageQuotaExceededError) {
|
|
51
52
|
return context.json({ error: { code: 'storage_quota_exceeded' as const } }, 409)
|
|
52
53
|
}
|
|
54
|
+
// Reported where cleanup failed, so the request handler doesn't report it again.
|
|
55
|
+
if (error instanceof DocumentPurgeFailedError) {
|
|
56
|
+
return context.json({ error: { code: 'purge_failed' as const } }, 503)
|
|
57
|
+
}
|
|
53
58
|
if (error instanceof UploadInvalidError) {
|
|
54
59
|
return context.json({ error: { code: 'invalid_upload' as const } }, 422)
|
|
55
60
|
}
|
|
@@ -111,6 +116,27 @@ export function createDocumentRoutes(
|
|
|
111
116
|
.get('/shared-documents', async (context) =>
|
|
112
117
|
context.json({ documents: await service.listShared(context.get('actor').userId) })
|
|
113
118
|
)
|
|
119
|
+
.get('/trash', async (context) =>
|
|
120
|
+
context.json({ documents: await service.trash.list(context.get('actor').userId) })
|
|
121
|
+
)
|
|
122
|
+
.post('/trash/:documentId/restore', documentParams, (context) =>
|
|
123
|
+
documentResponse(context, async () => {
|
|
124
|
+
await service.trash.restore(
|
|
125
|
+
context.get('actor').userId,
|
|
126
|
+
context.req.valid('param').documentId
|
|
127
|
+
)
|
|
128
|
+
return context.body(null, 204)
|
|
129
|
+
})
|
|
130
|
+
)
|
|
131
|
+
.delete('/trash/:documentId', documentParams, (context) =>
|
|
132
|
+
documentResponse(context, async () => {
|
|
133
|
+
await service.trash.purge(
|
|
134
|
+
context.get('actor').userId,
|
|
135
|
+
context.req.valid('param').documentId
|
|
136
|
+
)
|
|
137
|
+
return context.body(null, 204)
|
|
138
|
+
})
|
|
139
|
+
)
|
|
114
140
|
.get('/workspaces/:workspaceId/documents', workspaceParams, async (context) => {
|
|
115
141
|
const documents = await service.list(
|
|
116
142
|
context.get('actor').userId,
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
CommitImageUploadsInput,
|
|
3
|
-
CommitUploadInput,
|
|
4
2
|
CreateDocumentInput,
|
|
5
|
-
CreateUploadInput,
|
|
6
3
|
DocumentDownload,
|
|
7
4
|
DocumentSummary,
|
|
8
|
-
ImageUploadOffer,
|
|
9
|
-
RequestImageUploadsInput,
|
|
10
5
|
SharedDocument
|
|
11
6
|
} from '#cloud/contract'
|
|
7
|
+
import { workspaceRoleCan } from '#cloud/server/auth/access-control'
|
|
12
8
|
import { createUploadCleanupService } from '#cloud/server/cleanup'
|
|
13
9
|
import type { CloudDatabase } from '#cloud/server/db'
|
|
14
10
|
import {
|
|
@@ -16,19 +12,13 @@ import {
|
|
|
16
12
|
canEditDocument,
|
|
17
13
|
resolveDocumentAccess
|
|
18
14
|
} from '#cloud/server/documents/access'
|
|
19
|
-
import {
|
|
20
|
-
DocumentConflictError,
|
|
21
|
-
DocumentForbiddenError,
|
|
22
|
-
DocumentNotFoundError,
|
|
23
|
-
UploadInvalidError
|
|
24
|
-
} from '#cloud/server/documents/errors'
|
|
15
|
+
import { DocumentForbiddenError, DocumentNotFoundError } from '#cloud/server/documents/errors'
|
|
25
16
|
import {
|
|
26
17
|
createDocumentImages,
|
|
27
18
|
currentImageUsage,
|
|
28
19
|
documentImageLinks,
|
|
29
20
|
revisionImageDownloads
|
|
30
21
|
} from '#cloud/server/documents/images'
|
|
31
|
-
import { writableDocument } from '#cloud/server/documents/limits'
|
|
32
22
|
import {
|
|
33
23
|
findDocument,
|
|
34
24
|
insertDocument,
|
|
@@ -37,37 +27,30 @@ import {
|
|
|
37
27
|
workspaceRole
|
|
38
28
|
} from '#cloud/server/documents/repository'
|
|
39
29
|
import { documentSummary, getDocumentSummaryRow } from '#cloud/server/documents/summary'
|
|
40
|
-
import
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
import {
|
|
31
|
+
createDocumentTrash,
|
|
32
|
+
DEFAULT_TRASH_OPTIONS,
|
|
33
|
+
type DocumentTrashOptions
|
|
34
|
+
} from '#cloud/server/documents/trash'
|
|
35
|
+
import { createDocumentUploads } from '#cloud/server/documents/uploads'
|
|
36
|
+
import type { CloudErrorReporter } from '#cloud/server/errors'
|
|
37
|
+
import type { ObjectStore } from '#cloud/server/objects'
|
|
43
38
|
import type { CloudPolicy } from '#cloud/server/policy/policy'
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import type { Kysely
|
|
39
|
+
import { storageLimitReached } from '#cloud/server/policy/storage'
|
|
40
|
+
import { createStorageQuotaService, StorageQuotaExceededError } from '#cloud/server/quota'
|
|
41
|
+
import type { Kysely } from 'kysely'
|
|
47
42
|
|
|
48
43
|
const DOWNLOAD_LIFETIME_MS = 5 * 60 * 1000
|
|
49
|
-
const UPLOAD_LIFETIME_MS = 15 * 60 * 1000
|
|
50
|
-
/** How many of a save's images are checked and landed at once. */
|
|
51
|
-
const IMAGE_COMMIT_CONCURRENCY = 8
|
|
52
|
-
const WRITABLE_ROLES = new Set(['admin', 'editor'])
|
|
53
44
|
|
|
54
45
|
export type DocumentServiceOptions = {
|
|
55
46
|
policy?: CloudPolicy
|
|
56
47
|
technicalMaximumUploadBytes?: number
|
|
57
48
|
/** Called once a save adds a checkpoint to the document's history. */
|
|
58
49
|
onVersionsChanged?: (documentId: string) => void
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
stored: { checksum: string; byteSize: number; contentType: string },
|
|
64
|
-
upload: { checksum: string; byteSize: number | string | bigint; contentType: string }
|
|
65
|
-
): boolean {
|
|
66
|
-
return (
|
|
67
|
-
stored.checksum === upload.checksum &&
|
|
68
|
-
stored.byteSize === Number(upload.byteSize) &&
|
|
69
|
-
stored.contentType === upload.contentType
|
|
70
|
-
)
|
|
50
|
+
/** How long Trash keeps documents, the grace of one deleted forever, and the cleanup lease. */
|
|
51
|
+
trash?: DocumentTrashOptions
|
|
52
|
+
/** Where cleanup the service runs itself, such as of expired uploads, reports a failure. */
|
|
53
|
+
reportError?: CloudErrorReporter
|
|
71
54
|
}
|
|
72
55
|
|
|
73
56
|
export function createDocumentService(
|
|
@@ -75,112 +58,11 @@ export function createDocumentService(
|
|
|
75
58
|
objects: ObjectStore,
|
|
76
59
|
options: DocumentServiceOptions = {}
|
|
77
60
|
) {
|
|
78
|
-
const cleanup = createUploadCleanupService(database, objects)
|
|
61
|
+
const cleanup = createUploadCleanupService(database, objects, options.reportError)
|
|
79
62
|
const quota = createStorageQuotaService(database)
|
|
80
63
|
const images = createDocumentImages(database, objects, quota)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
* Makes a committed upload the document's current revision, unless it already was, and records
|
|
84
|
-
* the checkpoint the save adds, if any. Whether the history gained one.
|
|
85
|
-
*/
|
|
86
|
-
async function landRevision(
|
|
87
|
-
transaction: Transaction<CloudDatabase>,
|
|
88
|
-
{
|
|
89
|
-
userId,
|
|
90
|
-
uploadId,
|
|
91
|
-
upload,
|
|
92
|
-
stored,
|
|
93
|
-
revisionId,
|
|
94
|
-
storageObjectId,
|
|
95
|
-
images: revisionImages,
|
|
96
|
-
name,
|
|
97
|
-
kind
|
|
98
|
-
}: {
|
|
99
|
-
userId: string
|
|
100
|
-
uploadId: string
|
|
101
|
-
upload: {
|
|
102
|
-
documentId: string
|
|
103
|
-
workspaceId: string
|
|
104
|
-
baseRevisionId: string | null
|
|
105
|
-
objectKey: string
|
|
106
|
-
}
|
|
107
|
-
stored: { checksum: string; byteSize: number; contentType: string }
|
|
108
|
-
revisionId: string
|
|
109
|
-
storageObjectId: string
|
|
110
|
-
images: CommitUploadInput['images']
|
|
111
|
-
name: CommitUploadInput['name']
|
|
112
|
-
kind: CommitUploadInput['kind']
|
|
113
|
-
}
|
|
114
|
-
): Promise<boolean> {
|
|
115
|
-
const lockedUpload = await transaction
|
|
116
|
-
.selectFrom('upload')
|
|
117
|
-
.select('status')
|
|
118
|
-
.where('id', '=', uploadId)
|
|
119
|
-
.forUpdate()
|
|
120
|
-
.executeTakeFirstOrThrow()
|
|
121
|
-
if (lockedUpload.status === 'committed') return false
|
|
122
|
-
if (lockedUpload.status !== 'finalizing') throw new UploadInvalidError()
|
|
123
|
-
const document = await transaction
|
|
124
|
-
.selectFrom('document')
|
|
125
|
-
.select(['currentRevisionId'])
|
|
126
|
-
.where('id', '=', upload.documentId)
|
|
127
|
-
.forUpdate()
|
|
128
|
-
.executeTakeFirstOrThrow()
|
|
129
|
-
if (document.currentRevisionId !== upload.baseRevisionId) {
|
|
130
|
-
throw new DocumentConflictError()
|
|
131
|
-
}
|
|
132
|
-
await transaction
|
|
133
|
-
.insertInto('storageObject')
|
|
134
|
-
.values({
|
|
135
|
-
id: storageObjectId,
|
|
136
|
-
objectKey: upload.objectKey,
|
|
137
|
-
checksum: stored.checksum,
|
|
138
|
-
byteSize: stored.byteSize,
|
|
139
|
-
contentType: stored.contentType
|
|
140
|
-
})
|
|
141
|
-
.execute()
|
|
142
|
-
await transaction
|
|
143
|
-
.insertInto('documentRevision')
|
|
144
|
-
.values({
|
|
145
|
-
id: revisionId,
|
|
146
|
-
documentId: upload.documentId,
|
|
147
|
-
parentRevisionId: upload.baseRevisionId,
|
|
148
|
-
storageObjectId,
|
|
149
|
-
createdBy: userId
|
|
150
|
-
})
|
|
151
|
-
.execute()
|
|
152
|
-
const attached = await images.attachInTransaction(transaction, {
|
|
153
|
-
workspaceId: upload.workspaceId,
|
|
154
|
-
revisionId,
|
|
155
|
-
images: revisionImages
|
|
156
|
-
})
|
|
157
|
-
if (!attached) throw new UploadInvalidError()
|
|
158
|
-
await transaction
|
|
159
|
-
.updateTable('document')
|
|
160
|
-
.set({
|
|
161
|
-
// A revision may also retitle its document, or say the file it holds is a board.
|
|
162
|
-
...omitBy({ name, kind }, isUndefined),
|
|
163
|
-
currentRevisionId: revisionId,
|
|
164
|
-
version: (expression) => expression('version', '+', 1)
|
|
165
|
-
})
|
|
166
|
-
.where('id', '=', upload.documentId)
|
|
167
|
-
.execute()
|
|
168
|
-
const checkpointed = await recordCheckpoint(transaction, {
|
|
169
|
-
documentId: upload.documentId,
|
|
170
|
-
previousRevisionId: document.currentRevisionId,
|
|
171
|
-
revisionId,
|
|
172
|
-
userId,
|
|
173
|
-
now: new Date()
|
|
174
|
-
})
|
|
175
|
-
await transaction
|
|
176
|
-
.updateTable('upload')
|
|
177
|
-
.set({ status: 'committed', finalizationStartedAt: null })
|
|
178
|
-
.where('id', '=', uploadId)
|
|
179
|
-
.execute()
|
|
180
|
-
await quota.commitInTransaction(transaction, uploadId)
|
|
181
|
-
return checkpointed
|
|
182
|
-
}
|
|
183
|
-
|
|
64
|
+
const trash = createDocumentTrash(database, objects, options.trash ?? DEFAULT_TRASH_OPTIONS)
|
|
65
|
+
const uploads = createDocumentUploads(database, objects, { quota, images, options })
|
|
184
66
|
/** Links for images a live room names, by checksum. */
|
|
185
67
|
async function imageLinksOf(documentId: string, checksums: string[]) {
|
|
186
68
|
const expiresAt = new Date(Date.now() + DOWNLOAD_LIFETIME_MS)
|
|
@@ -219,130 +101,6 @@ export function createDocumentService(
|
|
|
219
101
|
}
|
|
220
102
|
}
|
|
221
103
|
|
|
222
|
-
/** What committing an upload reads of it and its document. */
|
|
223
|
-
function selectUploads() {
|
|
224
|
-
return database
|
|
225
|
-
.selectFrom('upload')
|
|
226
|
-
.innerJoin('document', 'document.id', 'upload.documentId')
|
|
227
|
-
.select([
|
|
228
|
-
'upload.id',
|
|
229
|
-
'upload.documentId',
|
|
230
|
-
'upload.kind',
|
|
231
|
-
'document.workspaceId',
|
|
232
|
-
'upload.baseRevisionId',
|
|
233
|
-
'upload.objectKey',
|
|
234
|
-
'upload.checksum',
|
|
235
|
-
'upload.byteSize',
|
|
236
|
-
'upload.contentType',
|
|
237
|
-
'upload.multipartUploadId',
|
|
238
|
-
'upload.status',
|
|
239
|
-
'upload.expiresAt'
|
|
240
|
-
])
|
|
241
|
-
}
|
|
242
|
-
type UploadRow = Awaited<ReturnType<ReturnType<typeof selectUploads>['executeTakeFirstOrThrow']>>
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Claims a pending upload, completes it when it came in parts, checks the store holds the file
|
|
246
|
-
* it declared, and lands it with `land`. An upload that fails goes back to pending, so its
|
|
247
|
-
* commit can be tried again.
|
|
248
|
-
*/
|
|
249
|
-
async function finalizeUpload<T>(
|
|
250
|
-
upload: UploadRow,
|
|
251
|
-
multipart: CommitUploadInput['multipart'],
|
|
252
|
-
land: (stored: StoredObject) => Promise<T>
|
|
253
|
-
): Promise<T> {
|
|
254
|
-
if (upload.status !== 'pending' || new Date(upload.expiresAt).getTime() <= Date.now()) {
|
|
255
|
-
throw new UploadInvalidError()
|
|
256
|
-
}
|
|
257
|
-
const claimed = await database
|
|
258
|
-
.updateTable('upload')
|
|
259
|
-
.set({ status: 'finalizing', finalizationStartedAt: new Date() })
|
|
260
|
-
.where('id', '=', upload.id)
|
|
261
|
-
.where('status', '=', 'pending')
|
|
262
|
-
.returning('id')
|
|
263
|
-
.executeTakeFirst()
|
|
264
|
-
if (!claimed) throw new UploadInvalidError()
|
|
265
|
-
try {
|
|
266
|
-
if (multipart) {
|
|
267
|
-
if (
|
|
268
|
-
!objects.capabilities.multipartUpload ||
|
|
269
|
-
multipart.uploadId !== upload.multipartUploadId
|
|
270
|
-
) {
|
|
271
|
-
throw new UploadInvalidError()
|
|
272
|
-
}
|
|
273
|
-
await objects.completeUpload({
|
|
274
|
-
key: upload.objectKey,
|
|
275
|
-
uploadId: multipart.uploadId,
|
|
276
|
-
parts: multipart.parts
|
|
277
|
-
})
|
|
278
|
-
}
|
|
279
|
-
const stored = await objects.head(upload.objectKey)
|
|
280
|
-
if (!stored || !matchesUpload(stored, upload)) throw new UploadInvalidError()
|
|
281
|
-
return await land(stored)
|
|
282
|
-
} catch (error) {
|
|
283
|
-
await database
|
|
284
|
-
.updateTable('upload')
|
|
285
|
-
.set({ status: 'pending', finalizationStartedAt: null })
|
|
286
|
-
.where('id', '=', upload.id)
|
|
287
|
-
.where('status', '=', 'finalizing')
|
|
288
|
-
.execute()
|
|
289
|
-
throw error
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function landImage(upload: UploadRow, stored: StoredObject): Promise<void> {
|
|
294
|
-
return database.transaction().execute((transaction) =>
|
|
295
|
-
images.landInTransaction(transaction, {
|
|
296
|
-
uploadId: upload.id,
|
|
297
|
-
workspaceId: upload.workspaceId,
|
|
298
|
-
objectKey: upload.objectKey,
|
|
299
|
-
stored
|
|
300
|
-
})
|
|
301
|
-
)
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
async function commitUpload(
|
|
305
|
-
userId: string,
|
|
306
|
-
uploadId: string,
|
|
307
|
-
input: CommitUploadInput
|
|
308
|
-
): Promise<DocumentSummary> {
|
|
309
|
-
const upload = await selectUploads()
|
|
310
|
-
.where('upload.id', '=', uploadId)
|
|
311
|
-
.where('upload.createdBy', '=', userId)
|
|
312
|
-
.executeTakeFirst()
|
|
313
|
-
if (!upload) throw new DocumentNotFoundError()
|
|
314
|
-
const access = await resolveDocumentAccess(database, userId, upload.documentId)
|
|
315
|
-
if (!access) throw new DocumentNotFoundError()
|
|
316
|
-
if (!canEditDocument(access)) throw new DocumentForbiddenError()
|
|
317
|
-
if (input.checksum !== upload.checksum) throw new UploadInvalidError()
|
|
318
|
-
if (upload.status !== 'committed') {
|
|
319
|
-
const checkpointed =
|
|
320
|
-
upload.kind === 'image'
|
|
321
|
-
? await finalizeUpload(upload, input.multipart, (stored) =>
|
|
322
|
-
landImage(upload, stored).then(() => false)
|
|
323
|
-
)
|
|
324
|
-
: await finalizeUpload(upload, input.multipart, (stored) =>
|
|
325
|
-
database.transaction().execute((transaction) =>
|
|
326
|
-
landRevision(transaction, {
|
|
327
|
-
userId,
|
|
328
|
-
uploadId,
|
|
329
|
-
upload,
|
|
330
|
-
stored,
|
|
331
|
-
revisionId: crypto.randomUUID(),
|
|
332
|
-
storageObjectId: crypto.randomUUID(),
|
|
333
|
-
images: input.images,
|
|
334
|
-
name: input.name,
|
|
335
|
-
kind: input.kind
|
|
336
|
-
})
|
|
337
|
-
)
|
|
338
|
-
)
|
|
339
|
-
if (checkpointed) announceVersions(options.onVersionsChanged, upload.documentId)
|
|
340
|
-
}
|
|
341
|
-
const document = await findDocument(database, userId, upload.documentId)
|
|
342
|
-
if (!document) throw new DocumentNotFoundError()
|
|
343
|
-
return document
|
|
344
|
-
}
|
|
345
|
-
|
|
346
104
|
return {
|
|
347
105
|
async cleanupExpiredUploads(now = new Date()): Promise<number> {
|
|
348
106
|
const result = await cleanup.cleanupExpiredUploads({
|
|
@@ -362,6 +120,9 @@ export function createDocumentService(
|
|
|
362
120
|
return listSharedDocuments(database, userId)
|
|
363
121
|
},
|
|
364
122
|
|
|
123
|
+
/** Trash: list what the person may restore, restore it, or delete it for good. */
|
|
124
|
+
trash,
|
|
125
|
+
|
|
365
126
|
async usage(userId: string, workspaceId: string) {
|
|
366
127
|
const role = await workspaceRole(database, userId, workspaceId)
|
|
367
128
|
if (!role) throw new DocumentNotFoundError()
|
|
@@ -423,7 +184,7 @@ export function createDocumentService(
|
|
|
423
184
|
}
|
|
424
185
|
await database
|
|
425
186
|
.updateTable('document')
|
|
426
|
-
.set({ deletedAt: new Date() })
|
|
187
|
+
.set({ deletedAt: new Date(), deletedBy: userId })
|
|
427
188
|
.where('id', '=', documentId)
|
|
428
189
|
.where('deletedAt', 'is', null)
|
|
429
190
|
.execute()
|
|
@@ -436,7 +197,10 @@ export function createDocumentService(
|
|
|
436
197
|
): Promise<DocumentSummary> {
|
|
437
198
|
const role = await workspaceRole(database, userId, workspaceId)
|
|
438
199
|
if (!role) throw new DocumentNotFoundError()
|
|
439
|
-
if (!
|
|
200
|
+
if (!workspaceRoleCan(role, { document: ['create'] })) throw new DocumentForbiddenError()
|
|
201
|
+
if (await storageLimitReached(database, options.policy, { workspaceId })) {
|
|
202
|
+
throw new StorageQuotaExceededError('The owner holds their whole storage allowance')
|
|
203
|
+
}
|
|
440
204
|
const documentId = input.id ?? crypto.randomUUID()
|
|
441
205
|
await insertDocument(database, {
|
|
442
206
|
id: documentId,
|
|
@@ -449,148 +213,8 @@ export function createDocumentService(
|
|
|
449
213
|
if (!document) throw new DocumentNotFoundError()
|
|
450
214
|
return document
|
|
451
215
|
},
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
userId: string,
|
|
455
|
-
documentId: string,
|
|
456
|
-
input: CreateUploadInput
|
|
457
|
-
): Promise<CreateDocumentUploadResult> {
|
|
458
|
-
const { document, maximumFileBytes, maximumStorageBytes } = await writableDocument(
|
|
459
|
-
database,
|
|
460
|
-
options,
|
|
461
|
-
userId,
|
|
462
|
-
documentId
|
|
463
|
-
)
|
|
464
|
-
if (document.currentRevisionId !== input.baseRevisionId) throw new DocumentConflictError()
|
|
465
|
-
if (input.byteSize > maximumFileBytes) throw new UploadInvalidError()
|
|
466
|
-
const uploadId = crypto.randomUUID()
|
|
467
|
-
const objectKey = `documents/${document.workspaceId}/${documentId}/uploads/${uploadId}.fig`
|
|
468
|
-
const expiresAt = new Date(Date.now() + UPLOAD_LIFETIME_MS)
|
|
469
|
-
await database.transaction().execute(async (transaction) => {
|
|
470
|
-
await transaction
|
|
471
|
-
.insertInto('upload')
|
|
472
|
-
.values({
|
|
473
|
-
id: uploadId,
|
|
474
|
-
documentId,
|
|
475
|
-
baseRevisionId: input.baseRevisionId,
|
|
476
|
-
objectKey,
|
|
477
|
-
checksum: input.checksum,
|
|
478
|
-
byteSize: input.byteSize,
|
|
479
|
-
contentType: input.contentType,
|
|
480
|
-
multipartUploadId: null,
|
|
481
|
-
status: 'pending',
|
|
482
|
-
finalizationStartedAt: null,
|
|
483
|
-
createdBy: userId,
|
|
484
|
-
expiresAt
|
|
485
|
-
})
|
|
486
|
-
.execute()
|
|
487
|
-
await quota.reserveInTransaction(transaction, {
|
|
488
|
-
workspaceId: document.workspaceId,
|
|
489
|
-
uploadId,
|
|
490
|
-
bytes: input.byteSize,
|
|
491
|
-
expiresAt,
|
|
492
|
-
maximumBytes: maximumStorageBytes
|
|
493
|
-
})
|
|
494
|
-
})
|
|
495
|
-
let objectUpload
|
|
496
|
-
try {
|
|
497
|
-
objectUpload = await objects.createUpload({
|
|
498
|
-
key: objectKey,
|
|
499
|
-
byteSize: input.byteSize,
|
|
500
|
-
checksum: input.checksum,
|
|
501
|
-
contentType: input.contentType,
|
|
502
|
-
expiresAt
|
|
503
|
-
})
|
|
504
|
-
} catch (error) {
|
|
505
|
-
await quota.release(uploadId)
|
|
506
|
-
await database
|
|
507
|
-
.updateTable('upload')
|
|
508
|
-
.set({ status: 'abandoned' })
|
|
509
|
-
.where('id', '=', uploadId)
|
|
510
|
-
.execute()
|
|
511
|
-
throw error
|
|
512
|
-
}
|
|
513
|
-
if (objectUpload.kind === 'multipart') {
|
|
514
|
-
await database
|
|
515
|
-
.updateTable('upload')
|
|
516
|
-
.set({ multipartUploadId: objectUpload.uploadId })
|
|
517
|
-
.where('id', '=', uploadId)
|
|
518
|
-
.execute()
|
|
519
|
-
}
|
|
520
|
-
return { id: uploadId, upload: objectUpload }
|
|
521
|
-
},
|
|
522
|
-
|
|
523
|
-
/** Uploads for the images a save of the document will name that its workspace lacks. */
|
|
524
|
-
async requestImageUploads(
|
|
525
|
-
userId: string,
|
|
526
|
-
documentId: string,
|
|
527
|
-
input: RequestImageUploadsInput
|
|
528
|
-
): Promise<{ uploads: ImageUploadOffer[] }> {
|
|
529
|
-
const { document, maximumFileBytes, maximumStorageBytes } = await writableDocument(
|
|
530
|
-
database,
|
|
531
|
-
options,
|
|
532
|
-
userId,
|
|
533
|
-
documentId
|
|
534
|
-
)
|
|
535
|
-
if (input.images.some((image) => image.byteSize > maximumFileBytes)) {
|
|
536
|
-
throw new UploadInvalidError()
|
|
537
|
-
}
|
|
538
|
-
return {
|
|
539
|
-
uploads: await images.requestUploads({
|
|
540
|
-
userId,
|
|
541
|
-
documentId,
|
|
542
|
-
workspaceId: document.workspaceId,
|
|
543
|
-
images: input.images,
|
|
544
|
-
expiresAt: new Date(Date.now() + UPLOAD_LIFETIME_MS),
|
|
545
|
-
maximumBytes: maximumStorageBytes
|
|
546
|
-
})
|
|
547
|
-
}
|
|
548
|
-
},
|
|
549
|
-
commitUpload,
|
|
550
|
-
|
|
551
|
-
/**
|
|
552
|
-
* Commits the image uploads a save asked for in one request, however many there are: each
|
|
553
|
-
* must be an image upload this person made for the document.
|
|
554
|
-
*/
|
|
555
|
-
async commitImageUploads(
|
|
556
|
-
userId: string,
|
|
557
|
-
documentId: string,
|
|
558
|
-
uploads: CommitImageUploadsInput['uploads']
|
|
559
|
-
): Promise<void> {
|
|
560
|
-
const access = await resolveDocumentAccess(database, userId, documentId)
|
|
561
|
-
if (!access) throw new DocumentNotFoundError()
|
|
562
|
-
if (!canEditDocument(access)) throw new DocumentForbiddenError()
|
|
563
|
-
const ids = uniq(uploads.map((upload) => upload.uploadId))
|
|
564
|
-
const rows = new Map(
|
|
565
|
-
(
|
|
566
|
-
await selectUploads()
|
|
567
|
-
.where('upload.id', 'in', ids)
|
|
568
|
-
.where('upload.documentId', '=', documentId)
|
|
569
|
-
.where('upload.createdBy', '=', userId)
|
|
570
|
-
.execute()
|
|
571
|
-
).map((row) => [row.id, row])
|
|
572
|
-
)
|
|
573
|
-
if (rows.size !== ids.length || [...rows.values()].some((row) => row.kind !== 'image')) {
|
|
574
|
-
throw new UploadInvalidError()
|
|
575
|
-
}
|
|
576
|
-
for (const commit of uploads) {
|
|
577
|
-
if (rows.get(commit.uploadId)?.checksum !== commit.checksum) throw new UploadInvalidError()
|
|
578
|
-
}
|
|
579
|
-
// Each image is its own object, so a few are checked and landed at once, each once however
|
|
580
|
-
// often the request names it.
|
|
581
|
-
const land = limitAsync(
|
|
582
|
-
(upload: UploadRow, multipart: CommitUploadInput['multipart']) =>
|
|
583
|
-
finalizeUpload(upload, multipart, (stored) => landImage(upload, stored)),
|
|
584
|
-
IMAGE_COMMIT_CONCURRENCY
|
|
585
|
-
)
|
|
586
|
-
await Promise.all(
|
|
587
|
-
uniqBy(uploads, (commit) => commit.uploadId).map(async (commit) => {
|
|
588
|
-
const upload = rows.get(commit.uploadId)
|
|
589
|
-
if (!upload) throw new UploadInvalidError()
|
|
590
|
-
if (upload.status !== 'committed') await land(upload, commit.multipart)
|
|
591
|
-
})
|
|
592
|
-
)
|
|
593
|
-
}
|
|
216
|
+
/** Saving: uploads of revisions and their images, and committing them. */
|
|
217
|
+
...uploads
|
|
594
218
|
}
|
|
595
219
|
}
|
|
596
220
|
|