@open-mercato/storage-s3 0.6.7-develop.6860.1.f796b22e80 → 0.6.7
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/.turbo/turbo-build.log +1 -1
- package/dist/modules/storage_s3/api/delete/storage-providers/s3/delete.js +5 -20
- package/dist/modules/storage_s3/api/delete/storage-providers/s3/delete.js.map +2 -2
- package/dist/modules/storage_s3/api/get/storage-providers/s3/download.js +5 -7
- package/dist/modules/storage_s3/api/get/storage-providers/s3/download.js.map +2 -2
- package/dist/modules/storage_s3/api/get/storage-providers/s3/list.js +4 -6
- package/dist/modules/storage_s3/api/get/storage-providers/s3/list.js.map +2 -2
- package/dist/modules/storage_s3/api/post/storage-providers/s3/signed-url.js +8 -70
- package/dist/modules/storage_s3/api/post/storage-providers/s3/signed-url.js.map +3 -3
- package/dist/modules/storage_s3/api/post/storage-providers/s3/upload.js +15 -92
- package/dist/modules/storage_s3/api/post/storage-providers/s3/upload.js.map +2 -2
- package/dist/modules/storage_s3/di.js +2 -6
- package/dist/modules/storage_s3/di.js.map +2 -2
- package/dist/modules/storage_s3/integration.js +1 -1
- package/dist/modules/storage_s3/integration.js.map +1 -1
- package/dist/modules/storage_s3/lib/health.js +1 -18
- package/dist/modules/storage_s3/lib/health.js.map +2 -2
- package/dist/modules/storage_s3/lib/key-scope.js +4 -4
- package/dist/modules/storage_s3/lib/key-scope.js.map +2 -2
- package/dist/modules/storage_s3/lib/s3-driver.js +15 -44
- package/dist/modules/storage_s3/lib/s3-driver.js.map +2 -2
- package/dist/modules/storage_s3/lib/storage-service.js +22 -126
- package/dist/modules/storage_s3/lib/storage-service.js.map +3 -3
- package/jest.config.cjs +0 -1
- package/package.json +6 -13
- package/src/modules/storage_s3/__tests__/s3Driver.test.ts +8 -23
- package/src/modules/storage_s3/__tests__/s3ListRoute.test.ts +1 -7
- package/src/modules/storage_s3/__tests__/s3Routes.test.ts +0 -26
- package/src/modules/storage_s3/__tests__/storageService.test.ts +5 -20
- package/src/modules/storage_s3/api/delete/storage-providers/s3/delete.ts +5 -22
- package/src/modules/storage_s3/api/get/storage-providers/s3/download.ts +5 -7
- package/src/modules/storage_s3/api/get/storage-providers/s3/list.ts +4 -6
- package/src/modules/storage_s3/api/post/storage-providers/s3/signed-url.ts +6 -77
- package/src/modules/storage_s3/api/post/storage-providers/s3/upload.ts +16 -101
- package/src/modules/storage_s3/di.ts +2 -14
- package/src/modules/storage_s3/integration.ts +1 -1
- package/src/modules/storage_s3/lib/health.ts +0 -18
- package/src/modules/storage_s3/lib/key-scope.ts +4 -4
- package/src/modules/storage_s3/lib/s3-driver.ts +10 -65
- package/src/modules/storage_s3/lib/storage-service.ts +22 -131
- package/dist/modules/storage_s3/api/put/storage-providers/s3/signed-upload/[token].js +0 -145
- package/dist/modules/storage_s3/api/put/storage-providers/s3/signed-upload/[token].js.map +0 -7
- package/dist/modules/storage_s3/lib/endpoint-safety.js +0 -133
- package/dist/modules/storage_s3/lib/endpoint-safety.js.map +0 -7
- package/dist/modules/storage_s3/lib/quota-accounting.js +0 -24
- package/dist/modules/storage_s3/lib/quota-accounting.js.map +0 -7
- package/dist/modules/storage_s3/lib/quota-recovery-queue.js +0 -9
- package/dist/modules/storage_s3/lib/quota-recovery-queue.js.map +0 -7
- package/dist/modules/storage_s3/workers/quota-recovery.js +0 -70
- package/dist/modules/storage_s3/workers/quota-recovery.js.map +0 -7
- package/src/modules/storage_s3/__tests__/endpoint-safety.test.ts +0 -71
- package/src/modules/storage_s3/__tests__/health.test.ts +0 -38
- package/src/modules/storage_s3/__tests__/i18nPackageExports.test.ts +0 -13
- package/src/modules/storage_s3/__tests__/quota-lifecycle.test.ts +0 -216
- package/src/modules/storage_s3/__tests__/quota-recovery.test.ts +0 -83
- package/src/modules/storage_s3/__tests__/upload.test.ts +0 -93
- package/src/modules/storage_s3/api/put/storage-providers/s3/signed-upload/[token].ts +0 -150
- package/src/modules/storage_s3/i18n/de.json +0 -17
- package/src/modules/storage_s3/i18n/en.json +0 -17
- package/src/modules/storage_s3/i18n/es.json +0 -17
- package/src/modules/storage_s3/i18n/ko.json +0 -17
- package/src/modules/storage_s3/i18n/pl.json +0 -17
- package/src/modules/storage_s3/lib/endpoint-safety.ts +0 -179
- package/src/modules/storage_s3/lib/quota-accounting.ts +0 -29
- package/src/modules/storage_s3/lib/quota-recovery-queue.ts +0 -17
- package/src/modules/storage_s3/workers/quota-recovery.ts +0 -82
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { JobContext, QueuedJob, WorkerMeta } from '@open-mercato/queue'
|
|
2
|
-
import type { AttachmentQuotaService } from '@open-mercato/core/modules/attachments/lib/quota-service'
|
|
3
|
-
import { S3StorageDriver } from '../lib/s3-driver'
|
|
4
|
-
import { scheduleStorageS3QuotaRecovery, type StorageS3QuotaRecoveryJob } from '../lib/quota-recovery-queue'
|
|
5
|
-
|
|
6
|
-
export const metadata: WorkerMeta = {
|
|
7
|
-
queue: 'storage-s3-quota-recovery',
|
|
8
|
-
id: 'storage_s3:quota-recovery',
|
|
9
|
-
concurrency: 2,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
type HandlerContext = JobContext & { resolve: <T = unknown>(name: string) => T }
|
|
13
|
-
|
|
14
|
-
type IntegrationCredentialsService = {
|
|
15
|
-
resolve(integrationId: string, scope: { tenantId: string; organizationId: string }): Promise<Record<string, unknown> | null>
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default async function handle(
|
|
19
|
-
job: QueuedJob<StorageS3QuotaRecoveryJob>,
|
|
20
|
-
ctx: HandlerContext,
|
|
21
|
-
): Promise<void> {
|
|
22
|
-
const quotaService = ctx.resolve<AttachmentQuotaService>('attachmentQuotaService')
|
|
23
|
-
const scope = {
|
|
24
|
-
tenantId: job.payload.tenantId,
|
|
25
|
-
organizationId: job.payload.organizationId,
|
|
26
|
-
}
|
|
27
|
-
const record = await quotaService.getReservation(job.payload.reservationId, scope)
|
|
28
|
-
if (!record || record.status === 'committed') return
|
|
29
|
-
if (record.expiresAt && record.expiresAt.getTime() > Date.now()) {
|
|
30
|
-
await scheduleStorageS3QuotaRecovery(job.payload, record.expiresAt.getTime() - Date.now())
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const claimed = await quotaService.claimExpired(record.id, scope)
|
|
35
|
-
if (!claimed) return
|
|
36
|
-
try {
|
|
37
|
-
const credentialsService = ctx.resolve<IntegrationCredentialsService>('integrationCredentialsService')
|
|
38
|
-
const credentials = await credentialsService.resolve('storage_s3', {
|
|
39
|
-
tenantId: claimed.tenantId,
|
|
40
|
-
organizationId: claimed.organizationId,
|
|
41
|
-
})
|
|
42
|
-
if (!credentials) throw new Error('S3 integration is not configured for quota recovery.')
|
|
43
|
-
const driver = new S3StorageDriver({
|
|
44
|
-
...credentials,
|
|
45
|
-
organizationId: claimed.organizationId,
|
|
46
|
-
tenantId: claimed.tenantId,
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
if (claimed.source === 'storage_s3_signed') {
|
|
50
|
-
const listed = await driver.listObjects(claimed.storagePath, 1)
|
|
51
|
-
const object = listed.files.find((file) => file.key === claimed.storagePath)
|
|
52
|
-
if (!object) {
|
|
53
|
-
if (record.status === 'storing' && (job.payload.absenceCheck ?? 0) === 0 && claimed.expiresAt) {
|
|
54
|
-
await scheduleStorageS3QuotaRecovery({
|
|
55
|
-
...job.payload,
|
|
56
|
-
absenceCheck: 1,
|
|
57
|
-
},
|
|
58
|
-
claimed.expiresAt.getTime() - Date.now(),
|
|
59
|
-
)
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
await quotaService.release(claimed.id, claimed.leaseToken)
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
const validSize = claimed.uploadTokenHash
|
|
66
|
-
? object.size <= claimed.reservedBytes
|
|
67
|
-
: object.size === claimed.reservedBytes
|
|
68
|
-
if (validSize) {
|
|
69
|
-
await quotaService.commitRecoveredStandalone(claimed.id, claimed.leaseToken, object.size)
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
await driver.deleteStrict('', claimed.storagePath)
|
|
75
|
-
await quotaService.release(claimed.id, claimed.leaseToken)
|
|
76
|
-
} catch (error) {
|
|
77
|
-
if (claimed.expiresAt) {
|
|
78
|
-
await scheduleStorageS3QuotaRecovery(job.payload, claimed.expiresAt.getTime() - Date.now())
|
|
79
|
-
}
|
|
80
|
-
throw error
|
|
81
|
-
}
|
|
82
|
-
}
|