mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-26 19:04:23 +00:00
fix(workflow): map sizeByte BigInt to Number in getAssetActivity for Temporal serialization
This commit is contained in:
@@ -102,6 +102,11 @@ describe('S3 API', () => {
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
expect(await res.text()).toBe('OK')
|
||||
expect(mockPut).toHaveBeenCalledWith('b1', 'test.webp', expect.any(ReadableStream), body.byteLength)
|
||||
expect(mockPut).toHaveBeenCalledWith(
|
||||
'b1',
|
||||
'test.webp',
|
||||
expect.any(ReadableStream),
|
||||
body.byteLength,
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -4,6 +4,12 @@ import { PrismaClient, WorkflowTask } from './generated/prisma/client'
|
||||
import { PrismaTestingHelper } from './prisma-testing-helper'
|
||||
import { generateNgrams } from './utils/ngram'
|
||||
|
||||
// Ensure BigInt serializes to JSON number gracefully for Temporal/HTTP payloads
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
;(BigInt.prototype as any).toJSON = function () {
|
||||
return Number(this)
|
||||
}
|
||||
|
||||
// Global callback for workflow task creation (decouples db package from workflow engine)
|
||||
type WorkflowTriggerCallback = (task: WorkflowTask) => Promise<void>
|
||||
let onWorkflowTaskCreated: WorkflowTriggerCallback | null = null
|
||||
|
||||
@@ -49,12 +49,18 @@ export async function getAssetActivity(assetId: string) {
|
||||
if (latestVersion) {
|
||||
return {
|
||||
...latestVersion,
|
||||
sizeByte: Number(latestVersion.sizeByte),
|
||||
project: latestVersion.project ?? asset.project,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return asset
|
||||
if (!asset) return null
|
||||
|
||||
return {
|
||||
...asset,
|
||||
sizeByte: Number(asset.sizeByte),
|
||||
}
|
||||
}
|
||||
|
||||
export interface UpdateTaskStatusParams {
|
||||
|
||||
Reference in New Issue
Block a user