feat(asset): decouple logical assets from physical storage with StorageKey and implement O(1) copy

This commit is contained in:
yiling
2026-05-25 00:52:45 +08:00
parent c5fba746be
commit 5dc3bdb38e
33 changed files with 2203 additions and 273 deletions
+32 -12
View File
@@ -101,10 +101,15 @@ describe('UploadService', () => {
data: {
name: 'video.mp4',
type: AssetType.file,
projectId,
parentId,
project: { connect: { id: projectId } },
parent: { connect: { id: parentId } },
status: AssetStatus.uploading,
key: 'test-key',
storageKey: {
connectOrCreate: {
where: { key: 'test-key' },
create: { key: 'test-key' },
},
},
mediaType: 'video/mp4',
},
})
@@ -134,10 +139,15 @@ describe('UploadService', () => {
data: {
name: 'image.png',
type: AssetType.file,
projectId,
parentId,
project: { connect: { id: projectId } },
parent: { connect: { id: parentId } },
status: AssetStatus.uploading,
key: 'test-key',
storageKey: {
connectOrCreate: {
where: { key: 'test-key' },
create: { key: 'test-key' },
},
},
mediaType: 'image/png',
},
})
@@ -162,10 +172,15 @@ describe('UploadService', () => {
data: {
name: 'file.txt',
type: AssetType.file,
projectId,
parentId,
project: { connect: { id: projectId } },
parent: { connect: { id: parentId } },
status: AssetStatus.uploading,
key: 'test-key',
storageKey: {
connectOrCreate: {
where: { key: 'test-key' },
create: { key: 'test-key' },
},
},
mediaType: 'text/plain',
},
})
@@ -259,10 +274,15 @@ describe('UploadService', () => {
data: {
name: 'v2.txt',
type: AssetType.file,
projectId,
parentId: stack.id,
project: { connect: { id: projectId } },
parent: { connect: { id: stack.id } },
status: AssetStatus.uploading,
key: 'v2-key',
storageKey: {
connectOrCreate: {
where: { key: 'v2-key' },
create: { key: 'v2-key' },
},
},
sizeByte: 2000,
},
})