prisma-guard 1.26.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
|
@@ -4460,10 +4460,30 @@ function isGuardShape(obj) {
|
|
|
4460
4460
|
function isSingleShape(input) {
|
|
4461
4461
|
return typeof input === "function" || isGuardShape(input);
|
|
4462
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
|
+
}
|
|
4463
4482
|
function requireBody(body) {
|
|
4464
|
-
|
|
4483
|
+
const normalized = toPlainObject(body);
|
|
4484
|
+
if (!isPlainObject(normalized))
|
|
4465
4485
|
throw new ShapeError("Request body must be an object");
|
|
4466
|
-
return
|
|
4486
|
+
return normalized;
|
|
4467
4487
|
}
|
|
4468
4488
|
function resolveDynamicShape(fn, contextFn) {
|
|
4469
4489
|
const ctx = validateContext(contextFn());
|