69 lines
2.3 KiB
TypeScript
69 lines
2.3 KiB
TypeScript
import {
|
|
characterCheckLabels,
|
|
type CharacterCheckResult,
|
|
type ImageValidationResult
|
|
} from '@/features/subject-images/validation'
|
|
import type { SubjectImageGenerationPreview } from '@/features/subject-images/types'
|
|
|
|
/**
|
|
* 构造完整的只读预览契约,仅供测试使用。
|
|
* @param subjectFormId 测试形态编号
|
|
* @returns 带来源版本的输入预览
|
|
*/
|
|
export function imagePreviewFixture(subjectFormId = 'form-db-1'): SubjectImageGenerationPreview {
|
|
return {
|
|
subjectFormId,
|
|
provider: 'qwen-image',
|
|
model: 'qwen-image-3.0-pro',
|
|
providerPrompt: '当前完整画面描述',
|
|
generationConfig: { options: { size: '2048*2048' } },
|
|
previewFingerprint: 'a'.repeat(64),
|
|
referenceImages: [],
|
|
references: []
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 返回绑定当前图库图像的只读审核来源。
|
|
* @param url 正式预检路径
|
|
* @param sourceCurrent 来源是否仍有效
|
|
* @returns 对应当前图片的预检响应
|
|
*/
|
|
export function validationPreviewResponse(url: string, sourceCurrent = true) {
|
|
const [, subjectFormId, imageId] = url.match(/subject-forms\/([^/]+)\/images\/([^/]+)\/validate\/preview$/) ?? []
|
|
return new Response(
|
|
JSON.stringify({
|
|
data: {
|
|
subjectFormId,
|
|
imageId,
|
|
sourceCurrent,
|
|
canValidate: sourceCurrent,
|
|
sourceStaleReason: sourceCurrent ? null : '本次机位采用的几何已过期',
|
|
providerInputSnapshot: null,
|
|
providerInputFingerprint: null
|
|
}
|
|
})
|
|
)
|
|
}
|
|
/**
|
|
* 模拟已通过明确审核的角色候选。
|
|
* @param imageId 当前候选
|
|
* @returns 四项完整的像素审核证据
|
|
*/
|
|
export function approvedCharacter(imageId: string): ImageValidationResult {
|
|
return {
|
|
subjectId: 'subject-db-1',
|
|
imageId,
|
|
passed: true,
|
|
sourceRequirementsPassed: true,
|
|
sourceVisualRequirements: [],
|
|
summary: '已核对图像',
|
|
issues: [],
|
|
characterCheckResults: (Object.keys(characterCheckLabels) as CharacterCheckResult['check'][]).map(check => ({
|
|
check,
|
|
status: check.endsWith('References') ? 'not_applicable' : 'passed',
|
|
evidence: '具体观察结果'
|
|
}))
|
|
}
|
|
}
|