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
+2 -2
View File
@@ -89,7 +89,7 @@ describe('AIAutofill Workflow', () => {
mockActivities.getAssetActivity.mockResolvedValue({
id: 'asset-1',
key: 'test.mp4',
storageKey: { key: 'test.mp4' },
mediaType: 'video/mp4',
project: { id: 'proj-1', teamId: 'team-1' },
})
@@ -140,7 +140,7 @@ describe('AIAutofill Workflow', () => {
mockActivities.getAssetActivity.mockResolvedValue({
id: 'asset-1',
key: 'test.mp4',
storageKey: { key: 'test.mp4' },
mediaType: 'video/mp4',
project: { id: 'proj-1', teamId: 'team-1' },
})
+4 -3
View File
@@ -47,7 +47,8 @@ export async function aiAutofillMedia(task: WorkflowTask): Promise<void> {
// 1. Get Asset
const asset = await executeActivity(TaskQueueDb, getAssetActivity, task.assetId)
if (!asset || !asset.project) {
const key = asset?.storageKey?.key
if (!asset || !asset.project || !key) {
throw new Error('Asset or project not found')
}
const teamId = asset.project.teamId
@@ -63,13 +64,13 @@ export async function aiAutofillMedia(task: WorkflowTask): Promise<void> {
)
const download = await executeActivity(transcodeWorkerQueue, downloadMediaToTmpActivity, {
assetKey: asset.key || '',
assetKey: key,
})
const { filePath } = download
tmpDir = download.tmpDir
const generatedFiles = await executeActivity(transcodeWorkerQueue, extractAiMetadataActivity, {
assetKey: asset.key || '',
assetKey: key,
filePath,
type: 'autofill',
isImage,
+4 -3
View File
@@ -42,7 +42,8 @@ export async function aiTranscriptionMedia(task: WorkflowTask): Promise<void> {
// 1. Get Asset
const asset = await executeActivity(TaskQueueDb, getAssetActivity, task.assetId)
if (!asset || !asset.key) {
const key = asset?.storageKey?.key
if (!asset || !key) {
throw new Error('Asset not found')
}
@@ -53,13 +54,13 @@ export async function aiTranscriptionMedia(task: WorkflowTask): Promise<void> {
)
const download = await executeActivity(transcodeWorkerQueue, downloadMediaToTmpActivity, {
assetKey: asset.key,
assetKey: key,
})
const { filePath } = download
tmpDir = download.tmpDir
const generatedFiles = await executeActivity(transcodeWorkerQueue, extractAiMetadataActivity, {
assetKey: asset.key,
assetKey: key,
filePath,
type: 'transcription',
isImage: false,