diff --git a/src/services/asset/asset.test.ts b/src/services/asset/asset.test.ts index 69602c7a..d972129e 100644 --- a/src/services/asset/asset.test.ts +++ b/src/services/asset/asset.test.ts @@ -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({ diff --git a/src/services/asset/asset.ts b/src/services/asset/asset.ts index b490ff7b..c45efc7d 100644 --- a/src/services/asset/asset.ts +++ b/src/services/asset/asset.ts @@ -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] }