Skip to content

Commit b92e7e0

Browse files
committed
Use ./generated Prisma folder, update types to fix issues
1 parent 33a9778 commit b92e7e0

File tree

8 files changed

+45
-16
lines changed

8 files changed

+45
-16
lines changed

apps/webapp/app/db.server.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import {
22
Prisma,
33
PrismaClient,
4-
PrismaClientOrTransaction,
5-
PrismaReplicaClient,
6-
PrismaTransactionClient,
7-
PrismaTransactionOptions,
4+
$transaction as transac,
5+
type PrismaClientOrTransaction,
6+
type PrismaReplicaClient,
7+
type PrismaTransactionClient,
8+
type PrismaTransactionOptions,
89
} from "@trigger.dev/database";
910
import invariant from "tiny-invariant";
1011
import { z } from "zod";
1112
import { env } from "./env.server";
1213
import { logger } from "./services/logger.server";
1314
import { isValidDatabaseUrl } from "./utils/db";
1415
import { singleton } from "./utils/singleton";
15-
import { $transaction as transac } from "@trigger.dev/database";
1616
import { startActiveSpan } from "./v3/tracer.server";
1717
import { Span } from "@opentelemetry/api";
1818

apps/webapp/app/routes/api.v1.projects.$projectRef.background-workers.$envSlug.$version.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
8282
});
8383
}
8484

85-
function decompressContent(compressedBuffer: Buffer): string {
86-
// First, we need to decode the base64 Buffer to get the actual compressed data
87-
const decodedBuffer = Buffer.from(compressedBuffer.toString("utf-8"), "base64");
85+
function decompressContent(compressedBuffer: Uint8Array): string {
86+
// Convert Uint8Array to Buffer and decode base64 in one step
87+
const decodedBuffer = Buffer.from(Buffer.from(compressedBuffer).toString("utf-8"), "base64");
8888

8989
// Decompress the data
9090
const decompressedData = zlib.inflateSync(decodedBuffer);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
node_modules
22
# Ensure the .env symlink is not removed by accident
33
!.env
4+
5+
generated/prisma

internal-packages/database/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",
77
"dependencies": {
8-
"@prisma/client": "6.14.0"
8+
"@prisma/client": "6.14.0",
9+
"decimal.js": "^10.6.0"
910
},
1011
"devDependencies": {
12+
"@types/decimal.js": "^7.4.3",
1113
"prisma": "6.14.0",
1214
"rimraf": "6.0.1"
1315
},

internal-packages/database/prisma/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ datasource db {
66

77
generator client {
88
provider = "prisma-client-js"
9-
output = "../node_modules/.prisma/client"
9+
output = "../generated/prisma"
1010
binaryTargets = ["native", "debian-openssl-1.1.x"]
1111
previewFeatures = ["metrics"]
1212
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from "@prisma/client";
1+
export * from "../generated/prisma";
22
export * from "./transaction";

internal-packages/database/src/transaction.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import { Prisma, PrismaClient } from "@prisma/client";
1+
import { PrismaClient } from "../generated/prisma";
2+
import { Decimal } from "decimal.js";
3+
import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library";
4+
5+
// Define the isolation levels manually
6+
type TransactionIsolationLevel =
7+
| "ReadUncommitted"
8+
| "ReadCommitted"
9+
| "RepeatableRead"
10+
| "Serializable";
211

312
export type PrismaTransactionClient = Omit<
413
PrismaClient,
@@ -9,13 +18,13 @@ export type PrismaClientOrTransaction = PrismaClient | PrismaTransactionClient;
918

1019
export type PrismaReplicaClient = Omit<PrismaClient, "$transaction">;
1120

12-
export const Decimal = Prisma.Decimal;
21+
export { Decimal };
1322

1423
function isTransactionClient(prisma: PrismaClientOrTransaction): prisma is PrismaTransactionClient {
1524
return !("$transaction" in prisma);
1625
}
1726

18-
export function isPrismaKnownError(error: unknown): error is Prisma.PrismaClientKnownRequestError {
27+
export function isPrismaKnownError(error: unknown): error is PrismaClientKnownRequestError {
1928
return (
2029
typeof error === "object" && error !== null && "code" in error && typeof error.code === "string"
2130
);
@@ -55,7 +64,7 @@ export type PrismaTransactionOptions = {
5564
timeout?: number;
5665

5766
/** Sets the transaction isolation level. By default this is set to the value currently configured in your database. */
58-
isolationLevel?: Prisma.TransactionIsolationLevel;
67+
isolationLevel?: TransactionIsolationLevel;
5968

6069
swallowPrismaErrors?: boolean;
6170

@@ -70,7 +79,7 @@ export type PrismaTransactionOptions = {
7079
export async function $transaction<R>(
7180
prisma: PrismaClientOrTransaction,
7281
fn: (prisma: PrismaTransactionClient) => Promise<R>,
73-
prismaError: (error: Prisma.PrismaClientKnownRequestError) => void,
82+
prismaError: (error: PrismaClientKnownRequestError) => void,
7483
options?: PrismaTransactionOptions,
7584
attempt = 0
7685
): Promise<R | undefined> {

pnpm-lock.yaml

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)