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 bf2f402
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bemi-db/prisma",
"version": "0.3.0",
"version": "0.3.1-rc.2",
"description": "Automatic data change tracking for Prisma",
"main": "dist/index.js",
"module": "./dist/index.mjs",
Expand All @@ -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 bf2f402

Please sign in to comment.