From 5602c228614ca82b61440f65ab81f5a837302908 Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Thu, 9 Nov 2023 04:34:25 +0100 Subject: [PATCH] Don't import Decimal from internal libraries This was causing the project build to not work properly. --- server/api/orders/[id]/work.post.ts | 4 ++-- server/utils/prismaToWeb.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/api/orders/[id]/work.post.ts b/server/api/orders/[id]/work.post.ts index eec5c67..8ada127 100644 --- a/server/api/orders/[id]/work.post.ts +++ b/server/api/orders/[id]/work.post.ts @@ -1,5 +1,5 @@ import { defineEventHandler, readBody, setResponseStatus } from "h3"; -import { Decimal } from "@prisma/client/runtime/library"; +import { Prisma } from "@prisma/client"; import { checkIsWork } from "../../orders.post"; import { orderExists } from "../[id].get"; @@ -24,7 +24,7 @@ export default defineEventHandler(async (e) => { notes: body.notes, offerId: BigInt(body.offerId), orderId: BigInt(body.orderId), - price: new Decimal(body.price), + price: new Prisma.Decimal(body.price), }, }); diff --git a/server/utils/prismaToWeb.ts b/server/utils/prismaToWeb.ts index d307e5d..518ab8e 100644 --- a/server/utils/prismaToWeb.ts +++ b/server/utils/prismaToWeb.ts @@ -1,4 +1,4 @@ -import { Decimal } from "@prisma/client/runtime/library"; +import { Prisma } from "@prisma/client"; type func = (...args: any[]) => any | Function; @@ -8,7 +8,7 @@ export type replaceJsonUnparsableToString = [K in keyof T]: T[K] extends null ? null : T[K] extends func ? never - : T[K] extends Decimal ? `${number}` + : T[K] extends Prisma.Decimal ? `${number}` : T[K] extends Array ? Array> : T[K] extends object ? replaceJsonUnparsableToString : T[K] extends bigint ? `${bigint}` @@ -34,7 +34,7 @@ export function prismaToWeb(ivalue: T): replaceJsonUnparsableToString { const current = ivalue[i]; if (current === null) rvalue[i] = null; else if (typeof current === 'function') continue; - else if (current instanceof Decimal) rvalue[i] = current.toString(); + else if (current instanceof Prisma.Decimal) rvalue[i] = current.toString(); else if (current instanceof Array) rvalue[i] = arrayPrismaToWeb(current); else if (typeof current === 'object') rvalue[i] = prismaToWeb(current); else if (typeof current === 'bigint') rvalue[i] = current.toString();