prisma-guard 1.6.0 → 1.6.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 +14 -17
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.js +14 -17
- package/dist/runtime/index.js.map +1 -1
- package/package.json +1 -1
package/dist/runtime/index.cjs
CHANGED
|
@@ -735,28 +735,25 @@ function mergeUniqueWhereForced(where, forced) {
|
|
|
735
735
|
}
|
|
736
736
|
function applyBuiltShape(built, body, isUniqueMethod) {
|
|
737
737
|
let parseable = body;
|
|
738
|
+
const hasWhereInSchema = "where" in built.zodSchema.shape;
|
|
738
739
|
if (isPlainObject(body)) {
|
|
739
740
|
const bodyObj = body;
|
|
740
|
-
if (
|
|
741
|
-
|
|
742
|
-
let modified = false;
|
|
743
|
-
if (built.forcedOnlyWhereKeys.size > 0) {
|
|
744
|
-
for (const key of built.forcedOnlyWhereKeys) {
|
|
745
|
-
if (key in where) {
|
|
746
|
-
delete where[key];
|
|
747
|
-
modified = true;
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
if (Object.keys(where).length === 0 && hasWhereForced(built.forcedWhere)) {
|
|
741
|
+
if ("where" in bodyObj) {
|
|
742
|
+
if (!hasWhereInSchema) {
|
|
752
743
|
const { where: _, ...rest } = bodyObj;
|
|
753
744
|
parseable = rest;
|
|
754
|
-
} else if (
|
|
755
|
-
|
|
745
|
+
} else if (built.forcedOnlyWhereKeys.size > 0 && isPlainObject(bodyObj.where)) {
|
|
746
|
+
const where = { ...bodyObj.where };
|
|
747
|
+
for (const key of built.forcedOnlyWhereKeys) {
|
|
748
|
+
delete where[key];
|
|
749
|
+
}
|
|
750
|
+
if (Object.keys(where).length === 0 && hasWhereForced(built.forcedWhere)) {
|
|
751
|
+
const { where: _, ...rest } = bodyObj;
|
|
752
|
+
parseable = rest;
|
|
753
|
+
} else {
|
|
754
|
+
parseable = { ...bodyObj, where };
|
|
755
|
+
}
|
|
756
756
|
}
|
|
757
|
-
} else if ("where" in bodyObj && hasWhereForced(built.forcedWhere) && !built.zodSchema.shape.where) {
|
|
758
|
-
const { where: _, ...rest } = bodyObj;
|
|
759
|
-
parseable = rest;
|
|
760
757
|
}
|
|
761
758
|
}
|
|
762
759
|
const validated = built.zodSchema.parse(parseable);
|