fix(asset): resolve lint and type errors in cleanup refactor

This commit is contained in:
yiling
2026-05-25 10:14:22 +08:00
parent 4949b92be8
commit a1cc7229e2
2 changed files with 6 additions and 8 deletions
+2 -2
View File
@@ -2,7 +2,7 @@ import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest'
import { prisma } from '@/db'
import { setupTestDbHooks } from '@/db-test-hooks'
import { AssetType, AssetStatus } from '@/generated/prisma/client.ts'
import { AssetType, AssetStatus, Prisma } from '@/generated/prisma/client.ts'
import { AssetService } from './asset'
vi.mock('@/services/s3/s3', () => ({
@@ -1302,7 +1302,7 @@ describe('AssetService', () => {
for (const data of childData) {
const asset = await prisma.asset.create({
data: data as any,
data: data as unknown as Prisma.AssetCreateInput,
include: { storageKey: true },
})
await prisma.storageKey.update({
+4 -6
View File
@@ -18,12 +18,10 @@ import {
UpdateAssetOrderRequest,
UserInfo,
} from '@/dtos/asset'
import { Asset, AssetStatus, AssetType, Prisma, StorageKey, StorageKeyStatus } from '@/generated/prisma/client.ts'
import { Asset, AssetStatus, AssetType, Prisma, StorageKey } from '@/generated/prisma/client.ts'
import { PaginatedData, paginateQuery, PaginationParams } from '@/services/pagination'
import { s3Service } from '@/services/s3/s3'
import { generateKeyBetween } from 'jittered-fractional-indexing'
import * as path from 'path'
import { ulid } from 'ulid'
type AssetWithIncludes = Prisma.AssetGetPayload<{
include: {
@@ -356,7 +354,7 @@ export class AssetService {
sizeByte: asset.sizeByte,
status: asset.status,
transcodeTaskId: asset.transcodeTaskId,
media: (asset.media as any) || undefined,
media: (asset.media as unknown as PrismaJson.MediaInfo) || undefined,
isDeleted: asset.isDeleted,
deletedAt: asset.deletedAt,
sortIndex: sortIndex,
@@ -697,7 +695,7 @@ export class AssetService {
if (parent) data.parent = { connect: { id: parent.id } }
if (sortIndex) data.sortIndex = sortIndex
if (req.key) {
;(data as any).storageKey = {
data.storageKey = {
connectOrCreate: {
where: { key: req.key },
create: { key: req.key },
@@ -892,7 +890,7 @@ export class AssetService {
storageKey: true,
},
})
const infos = await this.toAssetInfos([asset as any])
const infos = await this.toAssetInfos([asset as unknown as AssetWithIncludes])
return infos[0]
}