prisma-guard 1.25.0 → 1.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/runtime/index.cjs
CHANGED
|
@@ -1582,6 +1582,18 @@ function createWhereBuilder(typeMap, enumMap, scalarBase, uniqueMap = {}) {
|
|
|
1582
1582
|
scalarConditions
|
|
1583
1583
|
);
|
|
1584
1584
|
}
|
|
1585
|
+
for (const key of Object.keys(scalarConditions)) {
|
|
1586
|
+
if (COMBINATOR_KEYS.has(key))
|
|
1587
|
+
continue;
|
|
1588
|
+
if (!(key in fieldSchemas)) {
|
|
1589
|
+
fieldSchemas[key] = import_zod4.z.object({}).strict().optional();
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
for (const key of Object.keys(relationForced)) {
|
|
1593
|
+
if (!(key in fieldSchemas)) {
|
|
1594
|
+
fieldSchemas[key] = import_zod4.z.object({}).strict().optional();
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1585
1597
|
const schema = Object.keys(fieldSchemas).length > 0 ? import_zod4.z.object(fieldSchemas).strict().optional() : null;
|
|
1586
1598
|
const forcedOnlyKeys = /* @__PURE__ */ new Set();
|
|
1587
1599
|
for (const key of Object.keys(whereConfig)) {
|
|
@@ -1991,7 +2003,12 @@ function createWhereBuilder(typeMap, enumMap, scalarBase, uniqueMap = {}) {
|
|
|
1991
2003
|
fieldSchemas[key] = directSchema;
|
|
1992
2004
|
continue;
|
|
1993
2005
|
}
|
|
1994
|
-
forcedConditions[key] = parseForcedUniqueValue(
|
|
2006
|
+
forcedConditions[key] = parseForcedUniqueValue(
|
|
2007
|
+
model,
|
|
2008
|
+
key,
|
|
2009
|
+
fieldMeta,
|
|
2010
|
+
value
|
|
2011
|
+
);
|
|
1995
2012
|
forcedOnlyKeys.add(key);
|
|
1996
2013
|
}
|
|
1997
2014
|
return {
|
|
@@ -4443,10 +4460,30 @@ function isGuardShape(obj) {
|
|
|
4443
4460
|
function isSingleShape(input) {
|
|
4444
4461
|
return typeof input === "function" || isGuardShape(input);
|
|
4445
4462
|
}
|
|
4463
|
+
function toPlainObject(value) {
|
|
4464
|
+
if (value === null || typeof value !== "object")
|
|
4465
|
+
return value;
|
|
4466
|
+
if (Array.isArray(value))
|
|
4467
|
+
return value.map(toPlainObject);
|
|
4468
|
+
if (value instanceof Date)
|
|
4469
|
+
return value;
|
|
4470
|
+
if (value instanceof Uint8Array)
|
|
4471
|
+
return value;
|
|
4472
|
+
if (value instanceof RegExp)
|
|
4473
|
+
return value;
|
|
4474
|
+
if (typeof value.toFixed === "function" && typeof value.toNumber === "function")
|
|
4475
|
+
return value;
|
|
4476
|
+
const result = {};
|
|
4477
|
+
for (const [k, v] of Object.entries(value)) {
|
|
4478
|
+
result[k] = toPlainObject(v);
|
|
4479
|
+
}
|
|
4480
|
+
return result;
|
|
4481
|
+
}
|
|
4446
4482
|
function requireBody(body) {
|
|
4447
|
-
|
|
4483
|
+
const normalized = toPlainObject(body);
|
|
4484
|
+
if (!isPlainObject(normalized))
|
|
4448
4485
|
throw new ShapeError("Request body must be an object");
|
|
4449
|
-
return
|
|
4486
|
+
return normalized;
|
|
4450
4487
|
}
|
|
4451
4488
|
function resolveDynamicShape(fn, contextFn) {
|
|
4452
4489
|
const ctx = validateContext(contextFn());
|