prisma-query-log
Advanced tools
Comparing version 3.1.0 to 3.1.1
50
index.js
@@ -5,3 +5,2 @@ var __defProp = Object.defineProperty; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); | ||
var __export = (target, all) => { | ||
@@ -11,15 +10,11 @@ for (var name in all) | ||
}; | ||
var __reExport = (target, module2, copyDefault, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default")) | ||
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable }); | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
return to; | ||
}; | ||
var __toCommonJS = /* @__PURE__ */ ((cache) => { | ||
return (module2, temp) => { | ||
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp); | ||
}; | ||
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
@@ -31,2 +26,3 @@ // src/index.ts | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
@@ -60,15 +56,17 @@ // src/options.ts | ||
const eventParams = event.params.replace(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.?\d* UTC/g, (date) => `"${date}"`); | ||
const params = JSON.parse(eventParams); | ||
let query = event.query; | ||
const parameters = parseParameters(eventParams); | ||
if (unescape) { | ||
query = unescapeQuery(query); | ||
} | ||
query = query.replace(/(\?|\$\d+)/g, (match, p1, offset, string) => { | ||
let parameter = JSON.stringify(params.shift()); | ||
const previousChar = string.charAt(offset - 1); | ||
if (colorQuery && colorParameter) { | ||
parameter = colorParameter + parameter + "[0m" + colorQuery; | ||
} | ||
return (previousChar === "," ? " " : "") + parameter; | ||
}); | ||
if (parameters.length > 0) { | ||
query = query.replace(/(\?|\$\d+)/g, (match, p1, offset, string) => { | ||
let parameter = JSON.stringify(parameters.shift()); | ||
const previousChar = string.charAt(offset - 1); | ||
if (colorQuery && colorParameter) { | ||
parameter = colorParameter + parameter + "\x1B[0m" + colorQuery; | ||
} | ||
return (previousChar === "," ? " " : "") + parameter; | ||
}); | ||
} | ||
if (format) { | ||
@@ -81,3 +79,3 @@ if (!formatter) { | ||
if (colorQuery && colorParameter) { | ||
query = colorQuery + query + "[0m"; | ||
query = colorQuery + query + "\x1B[0m"; | ||
} | ||
@@ -87,2 +85,9 @@ logger(query); | ||
} | ||
function parseParameters(parameters) { | ||
try { | ||
return JSON.parse(parameters); | ||
} catch (e) { | ||
return []; | ||
} | ||
} | ||
function unescapeQuery(query) { | ||
@@ -110,3 +115,2 @@ const regex = /(?<quote>["`])\w+["`](\.["`]\w+["`])?(\.["`]\w+["`])?/g; | ||
} | ||
module.exports = __toCommonJS(src_exports); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -113,0 +117,0 @@ 0 && (module.exports = { |
{ | ||
"name": "prisma-query-log", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"license": "MIT", | ||
@@ -11,3 +11,3 @@ "description": "Log prisma query event", | ||
"test": "npm run tscheck && npm run eslint && npm run test:r", | ||
"test:r": "vitest run src/index.spec.ts", | ||
"test:r": "vitest src/index.spec.ts", | ||
"test:w": "npm run test:r -- --watch", | ||
@@ -36,32 +36,32 @@ "eslint": "node node_modules/eslint/bin/eslint \"src/**/*.{ts,tsx}\"", | ||
"devDependencies": { | ||
"@commitlint/cli": "^15.0.0", | ||
"@commitlint/config-conventional": "^15.0.0", | ||
"@prisma/client": "^3.7.0", | ||
"@commitlint/cli": "^16.2.3", | ||
"@commitlint/config-conventional": "^16.2.1", | ||
"@prisma/client": "^3.11.0", | ||
"@semantic-release/changelog": "^6.0.1", | ||
"@semantic-release/git": "^10.0.1", | ||
"@types/node": "^17.0.2", | ||
"@typescript-eslint/eslint-plugin": "^5.8.0", | ||
"@typescript-eslint/parser": "^5.8.0", | ||
"@types/node": "^17.0.21", | ||
"@typescript-eslint/eslint-plugin": "^5.15.0", | ||
"@typescript-eslint/parser": "^5.15.0", | ||
"commitizen": "^4.2.4", | ||
"conventional-changelog-conventionalcommits": "^4.6.1", | ||
"conventional-changelog-conventionalcommits": "^4.6.3", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"eslint": "^8.5.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-etc": "^2.0.1", | ||
"eslint": "^8.11.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-etc": "^2.0.2", | ||
"eslint-plugin-only-warn": "^1.0.3", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-unicorn": "^39.0.0", | ||
"expect": "^27.4.2", | ||
"eslint-plugin-unicorn": "^41.0.1", | ||
"precise-commits": "^1.0.2", | ||
"prettier": "^2.5.1", | ||
"prisma": "^3.7.0", | ||
"semantic-release": "^18.0.1", | ||
"prettier": "^2.6.0", | ||
"prisma": "^3.11.0", | ||
"request": "^2.88.2", | ||
"semantic-release": "^19.0.2", | ||
"strip-ansi": "6.X", | ||
"ts-node": "^10.4.0", | ||
"ts-node": "^10.7.0", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.5.4", | ||
"vite": "^2.7.4", | ||
"vitest": "0.0.105", | ||
"typescript": "^4.6.2", | ||
"vite": "^2.8.6", | ||
"vitest": "0.7.3", | ||
"watchexec-bin": "^1.0.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
164
10769