feat(transcode): trigger ai metadata autofill post transcode

This commit is contained in:
yiling
2026-07-28 20:19:10 +08:00
parent d0d29b34ed
commit e51d86e8f0
11 changed files with 185 additions and 31 deletions
@@ -38,6 +38,9 @@ describe('transcodeImageWorkflow', () => {
createEmbeddingTaskIfEnabledActivity: Object.assign(vi.fn(), {
_activityName: 'createEmbeddingTaskIfEnabledActivity',
}),
createAutofillTaskIfEnabledActivity: Object.assign(vi.fn(), {
_activityName: 'createAutofillTaskIfEnabledActivity',
}),
}
beforeEach(() => {
@@ -145,5 +148,11 @@ describe('transcodeImageWorkflow', () => {
teamId: 'team-1',
projectId: 'proj-1',
})
expect(mockActivities.createAutofillTaskIfEnabledActivity).toHaveBeenCalledWith({
assetId: 'asset-image',
teamId: 'team-1',
projectId: 'proj-1',
})
})
})
@@ -23,6 +23,7 @@ export async function transcodeImageWorkflow(task: WorkflowTask): Promise<void>
updateAssetMediaActivity,
downloadMediaToTmpActivity,
createEmbeddingTaskIfEnabledActivity,
createAutofillTaskIfEnabledActivity,
} = getActivities()
await executeActivity(workerQueue, updateAssetStatusActivity, {
@@ -96,6 +97,12 @@ export async function transcodeImageWorkflow(task: WorkflowTask): Promise<void>
projectId: task.projectId,
})
await executeActivity(workerQueue, createAutofillTaskIfEnabledActivity, {
assetId: asset.id,
teamId: task.teamId,
projectId: task.projectId,
})
await completeTask(workerQueue, task.id)
} catch (err) {
console.error(`transcodeImageWorkflow failed for task ${task.id}:`, err)
@@ -41,6 +41,9 @@ describe('transcodePdfWorkflow', () => {
createEmbeddingTaskIfEnabledActivity: Object.assign(vi.fn(), {
_activityName: 'createEmbeddingTaskIfEnabledActivity',
}),
createAutofillTaskIfEnabledActivity: Object.assign(vi.fn(), {
_activityName: 'createAutofillTaskIfEnabledActivity',
}),
}
beforeEach(() => {
@@ -150,5 +153,11 @@ describe('transcodePdfWorkflow', () => {
assetId: 'asset-pdf',
status: AssetStatus.processed,
})
expect(mockActivities.createAutofillTaskIfEnabledActivity).toHaveBeenCalledWith({
assetId: 'asset-pdf',
teamId: 'team-1',
projectId: 'proj-1',
})
})
})
@@ -24,6 +24,7 @@ export async function transcodePdfWorkflow(task: WorkflowTask): Promise<void> {
downloadMediaToTmpActivity,
generatePdfProxyActivity,
createEmbeddingTaskIfEnabledActivity,
createAutofillTaskIfEnabledActivity,
} = getActivities()
await executeActivity(workerQueue, updateAssetStatusActivity, {
@@ -108,6 +109,12 @@ export async function transcodePdfWorkflow(task: WorkflowTask): Promise<void> {
projectId: task.projectId,
})
await executeActivity(workerQueue, createAutofillTaskIfEnabledActivity, {
assetId: asset.id,
teamId: task.teamId,
projectId: task.projectId,
})
await completeTask(workerQueue, task.id)
} catch (err) {
console.error(`transcodePdfWorkflow failed for task ${task.id}:`, err)
@@ -41,6 +41,9 @@ describe('transcodeVideoWorkflow', () => {
createEmbeddingTaskIfEnabledActivity: Object.assign(vi.fn(), {
_activityName: 'createEmbeddingTaskIfEnabledActivity',
}),
createAutofillTaskIfEnabledActivity: Object.assign(vi.fn(), {
_activityName: 'createAutofillTaskIfEnabledActivity',
}),
}
beforeEach(() => {
@@ -151,6 +154,12 @@ describe('transcodeVideoWorkflow', () => {
projectId: 'proj-1',
})
expect(mockActivities.createAutofillTaskIfEnabledActivity).toHaveBeenCalledWith({
assetId: 'asset-1',
teamId: 'team-1',
projectId: 'proj-1',
})
expect(mockActivities.updateTaskStatusActivity).toHaveBeenCalledWith({
taskId: 'task-1',
status: WorkflowTaskStatus.completed,
@@ -27,6 +27,7 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
updateAssetMediaActivity,
downloadMediaToTmpActivity,
createEmbeddingTaskIfEnabledActivity,
createAutofillTaskIfEnabledActivity,
} = getActivities()
await executeActivity(workerQueue, updateAssetStatusActivity, {
@@ -161,6 +162,12 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
projectId: task.projectId,
})
await executeActivity(workerQueue, createAutofillTaskIfEnabledActivity, {
assetId: asset.id,
teamId: task.teamId,
projectId: task.projectId,
})
await completeTask(workerQueue, task.id)
} catch (err) {
console.error(`transcodeVideoWorkflow failed for task ${task.id}:`, err)