Skip to content

Commit

Permalink
Remove @prisma/internals as a dependency to fix Next.js actions
Browse files Browse the repository at this point in the history
  • Loading branch information
exAspArk committed Apr 16, 2024
1 parent 2d6b2cd commit 18b1e64
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"homepage": "https://github.com/BemiHQ/bemi-prisma#readme",
"dependencies": {
"@prisma/driver-adapter-utils": "^5.9.1",
"@prisma/internals": "^5.9.1",
"commander": "^11.1.0",
"kleur": "^4.1.5",
"pg": "^8.11.5",
"postgres-array": "^3.0.2"
},
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Request, Response, NextFunction } from "express";

import { PrismaPg } from './pg-adapter';
import { isContextComment, isWriteQuery, contextToSqlComment } from './pg-utils'
import { log } from './logger'
import { logger } from './logger'

const WRITE_OPERATIONS = ["create", "update", "upsert", "delete", "createMany", "updateMany", "deleteMany"]
const EXECUTE_OPERATIONS = ["$executeRaw", "$executeRawUnsafe"]
Expand Down Expand Up @@ -37,7 +37,7 @@ export const withPgAdapter = <PrismaClientType>(originalPrisma: PrismaClientType
const context = ASYNC_LOCAL_STORAGE.getStore()
if (!context || context.constructor !== Object) return query(args)

log('EXTENSION:', operation, args)
logger.debug('EXTENSION:', operation, args)

// The PG adapter will remove the transaction and add the comment
// to the query directly to be executed as a single SQL statement
Expand Down
22 changes: 17 additions & 5 deletions src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
export const log = (...args: any[]) => {
if (process.env.BEMI_DEBUG === 'true') {
const [message, ...rest] = args
console.log(`>>[Bemi] ${message}`, ...rest);
}
import { blue } from 'kleur/colors'

export const logger = {
tags: {
info: blue('prisma:query'),
},

log: (...args: any[]) => {
console.log(...args);
},

debug: (...args: any[]) => {
if (process.env.BEMI_DEBUG === 'true') {
const [message, ...rest] = args
console.log(`>>[Bemi] ${message}`, ...rest);
}
},
}
5 changes: 2 additions & 3 deletions src/pg-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import { fieldToColumnType, fixArrayBufferValues, UnsupportedNativeDataType } fr
const debug = Debug('prisma:driver-adapter:pg')

// PATCH: Import additional things
import { logger } from '@prisma/internals'
import { log } from './logger'
import { logger } from './logger'
import {
StdClient,
TransactionClient,
Expand Down Expand Up @@ -134,7 +133,7 @@ class PgQueryable<ClientT extends StdClient | TransactionClient> implements Quer

// Modify the execution
if (this.client.logQueries && !catchingUp) {
log('QUERY:', sql, previousQueries ? previousQueries.length : '')
logger.debug('QUERY:', sql, previousQueries ? previousQueries.length : '')
}

// Transaction queries
Expand Down

0 comments on commit 18b1e64

Please sign in to comment.