168 lines
5.7 KiB
TypeScript
168 lines
5.7 KiB
TypeScript
import type { ImageAuthorizationList } from '../../src/features/image-authorization/types'
|
|
import type {
|
|
VideoAuditEvidence,
|
|
VideoAuditView,
|
|
VideoExecutionDetail
|
|
} from '../../src/features/production/video-audit.types'
|
|
import { imageCatalog, generationProfile } from './generation'
|
|
|
|
/** 统一隔离模型目录,保留其它供应方用于切换确认。 */
|
|
export const billingCatalog = {
|
|
...imageCatalog,
|
|
defaults: { ...imageCatalog.defaults, imageProvider: 'openai-image' },
|
|
images: [
|
|
...imageCatalog.images.map(item => ({ ...item, isDefault: false })),
|
|
{
|
|
...imageCatalog.images[0]!,
|
|
provider: 'openai-image',
|
|
providerLabel: 'OpenAI',
|
|
model: 'gpt-image-2.5-flare',
|
|
modelLabel: 'GPT Image',
|
|
isDefault: true
|
|
}
|
|
]
|
|
}
|
|
/** 隔离项目保留明确的 OpenAI 配置。 */
|
|
export const billingProfile = {
|
|
...generationProfile('billing-project'),
|
|
imageProvider: 'openai-image',
|
|
imageModel: 'gpt-image-2.5-flare'
|
|
}
|
|
/**
|
|
* 创建每个用例独立的授权与余额。
|
|
* @returns 不连接真实账户的正式投影
|
|
*/
|
|
export function imageAuthorizationsFixture(): ImageAuthorizationList {
|
|
return {
|
|
authorizations: [
|
|
{
|
|
id: 'grant',
|
|
status: 'approved',
|
|
expired: false,
|
|
usedRequests: 0,
|
|
remainingRequests: 10,
|
|
accountedMicros: 0,
|
|
remainingMicros: 5_000_000,
|
|
billingBlocked: false,
|
|
input: {
|
|
idempotencyKey: 'fixture',
|
|
mode: 'standing',
|
|
provider: 'openai-image',
|
|
models: ['gpt-image-2.5-flare'],
|
|
scopes: ['identity', 'form', 'keyframe', 'layout'],
|
|
currency: 'USD',
|
|
budgetMicros: 5_000_000,
|
|
perRequestMicros: 500_000,
|
|
maxRequests: 10,
|
|
expiresAt: '2099-01-01T00:00:00Z',
|
|
acknowledgeVariableBilling: true,
|
|
approvedBy: '隔离批准人',
|
|
approvalNote: '仅供 Mock 测试'
|
|
}
|
|
}
|
|
],
|
|
requests: [],
|
|
billingBlocked: false,
|
|
blockingRequestIds: []
|
|
}
|
|
}
|
|
/**
|
|
* 构造跨版本原质检任务与原审计,默认完全未知。
|
|
* @returns 隔离审计和原任务
|
|
*/
|
|
export function videoAuditFixture() {
|
|
const identity = {
|
|
taskId: 'audit-task',
|
|
workflowExecutionId: 'audit-workflow',
|
|
requestId: 'local-request',
|
|
requestFingerprint: 'a'.repeat(64),
|
|
planFingerprint: 'b'.repeat(64),
|
|
sourceFingerprint: 'c'.repeat(64),
|
|
videoId: 'audit-video',
|
|
provider: 'vision-provider',
|
|
model: 'vision-model'
|
|
}
|
|
const audit: VideoAuditView = {
|
|
projectId: 'billing-project',
|
|
shotId: 'audit-shot',
|
|
taskId: identity.taskId,
|
|
workflowExecutionId: identity.workflowExecutionId,
|
|
currency: 'USD',
|
|
taskFingerprint: 'd'.repeat(64),
|
|
originalTaskStatus: 'failed',
|
|
originalWorkflowStatus: 'failed',
|
|
billingBlocked: true,
|
|
steps: [
|
|
{
|
|
name: 'spatialInteractionResult',
|
|
requestStatus: 'unresolved',
|
|
identity,
|
|
originalProviderRequestId: null,
|
|
originalSdkReceiptId: null,
|
|
hasOriginalReceipt: false,
|
|
evidenceSetFingerprint: 'e'.repeat(64),
|
|
reviewFingerprint: 'f'.repeat(64),
|
|
status: 'unreviewed',
|
|
released: false,
|
|
reviewId: null,
|
|
evidence: [],
|
|
reviews: []
|
|
}
|
|
],
|
|
history: { evidence: [], reviews: [] }
|
|
}
|
|
const original: VideoExecutionDetail = {
|
|
taskId: identity.taskId,
|
|
taskStatus: 'failed',
|
|
executionId: identity.workflowExecutionId,
|
|
videoId: identity.videoId,
|
|
needsReview: true,
|
|
billingBlocked: true,
|
|
workflowStatus: 'failed',
|
|
current: false,
|
|
staleReason: '动作规划已变化',
|
|
plan: {
|
|
purpose: 'video_validation',
|
|
projectId: audit.projectId,
|
|
shotId: audit.shotId,
|
|
videoId: identity.videoId,
|
|
fingerprint: identity.planFingerprint
|
|
},
|
|
output: {
|
|
billing: { actualAmount: null, reason: '原费用未知' },
|
|
result: { passed: false, qualityDecision: 'needs_review' },
|
|
steps: [{ name: 'spatialInteractionResult', status: 'unresolved' }]
|
|
}
|
|
}
|
|
return { audit, original }
|
|
}
|
|
/**
|
|
* 构造仅供隔离测试的完整材料声明,绝不提交正式历史任务。
|
|
* @returns 可供人工核验交互测试的证据包
|
|
*/
|
|
export function videoEvidenceFixture(): VideoAuditEvidence {
|
|
return {
|
|
identity: videoAuditFixture().audit.steps[0]!.identity,
|
|
correlation: 'unique',
|
|
providerRequestId: 'mock-provider-request',
|
|
artifacts: [
|
|
{
|
|
id: 'execution',
|
|
kind: 'provider-execution',
|
|
recordId: 'mock-execution',
|
|
sha256: '1'.repeat(64),
|
|
reference: '隔离执行原件'
|
|
},
|
|
{
|
|
id: 'bill',
|
|
kind: 'provider-billing',
|
|
recordId: 'mock-bill',
|
|
sha256: '2'.repeat(64),
|
|
reference: '隔离账单原件'
|
|
}
|
|
],
|
|
execution: { outcome: 'failed', evidenceIds: ['execution'] },
|
|
billing: { finding: 'charged', amount: 0.12, currency: 'USD', evidenceIds: ['bill'] }
|
|
}
|
|
}
|