prisma-mock
Advanced tools
Comparing version 0.5.5 to 0.6.0
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ResetCuid = void 0; | ||
const pad_1 = __importDefault(require("../utils/pad")); | ||
let ciud_cache = 0; | ||
function pad(s, size) { | ||
while (s.length < (size || 2)) { | ||
s = "0" + s; | ||
} | ||
return s; | ||
} | ||
// Format from: https://cuid.marcoonroad.dev/ | ||
const Cuid = () => { | ||
ciud_cache++; | ||
return `c00p6qup2${pad(String(ciud_cache), 4)}ckkzslahp5pn`; | ||
return `c00p6qup2${(0, pad_1.default)(String(ciud_cache), 4)}ckkzslahp5pn`; | ||
}; | ||
@@ -16,0 +14,0 @@ function ResetCuid() { |
@@ -33,2 +33,3 @@ "use strict"; | ||
const now_1 = __importDefault(require("./now")); | ||
const uuid_1 = __importStar(require("./uuid")); | ||
// const registry = new Map<string, (string, Prisma.DMMF.Field, PrismaMockData) => any>(); | ||
@@ -38,2 +39,3 @@ const registry = new Map(); | ||
registry.set("cuid", cuid_1.default); | ||
registry.set("uuid", uuid_1.default); | ||
registry.set("now", now_1.default); | ||
@@ -49,3 +51,4 @@ function HandleDefault(prop, field, data) { | ||
(0, cuid_1.ResetCuid)(); | ||
(0, uuid_1.ResetUuid)(); | ||
} | ||
exports.ResetDefaults = ResetDefaults; |
@@ -27,3 +27,2 @@ "use strict"; | ||
const client_1 = require("@prisma/client"); | ||
const runtime_1 = require("@prisma/client/runtime"); | ||
const jest_mock_extended_1 = require("jest-mock-extended"); | ||
@@ -44,5 +43,5 @@ const defaults_1 = __importStar(require("./defaults")); | ||
let error; | ||
if (runtime_1.PrismaClientKnownRequestError.length === 2) { | ||
if (client_1.Prisma.PrismaClientKnownRequestError.length === 2) { | ||
// @ts-ignore | ||
error = new runtime_1.PrismaClientKnownRequestError(message, { | ||
error = new client_1.Prisma.PrismaClientKnownRequestError(message, { | ||
code, | ||
@@ -54,3 +53,3 @@ clientVersion, | ||
// @ts-ignore | ||
error = new runtime_1.PrismaClientKnownRequestError(message, code, | ||
error = new client_1.Prisma.PrismaClientKnownRequestError(message, code, | ||
// @ts-ignore | ||
@@ -179,3 +178,3 @@ clientVersion); | ||
if (keys.length > 1) { | ||
throw new runtime_1.PrismaClientValidationError(`Argument orderBy of needs exactly one argument, but you provided ${keys.join(" and ")}. Please choose one.`); | ||
throw new client_1.Prisma.PrismaClientValidationError(`Argument orderBy of needs exactly one argument, but you provided ${keys.join(" and ")}. Please choose one.`); | ||
} | ||
@@ -704,3 +703,3 @@ const incl = includes({ | ||
if (!found) { | ||
throw new runtime_1.PrismaClientKnownRequestError(`No ${prop.slice(0, 1).toUpperCase()}${prop.slice(1)} found`, "P2025", | ||
throw new client_1.Prisma.PrismaClientKnownRequestError(`No ${prop.slice(0, 1).toUpperCase()}${prop.slice(1)} found`, "P2025", | ||
// @ts-ignore | ||
@@ -707,0 +706,0 @@ "1.2.3"); |
{ | ||
"name": "prisma-mock", | ||
"version": "0.5.5", | ||
"version": "0.6.0", | ||
"description": "Mock prisma for unit testing database", | ||
@@ -21,3 +21,4 @@ "main": "lib/index.js", | ||
"ts-jest": "^27.0.7", | ||
"typescript": "^4.4.4" | ||
"typescript": "^4.4.4", | ||
"uuid": "^9.0.0" | ||
}, | ||
@@ -24,0 +25,0 @@ "scripts": { |
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
60591
23
1232
10