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.js
CHANGED
|
@@ -4429,10 +4429,30 @@ function isGuardShape(obj) {
|
|
|
4429
4429
|
function isSingleShape(input) {
|
|
4430
4430
|
return typeof input === "function" || isGuardShape(input);
|
|
4431
4431
|
}
|
|
4432
|
+
function toPlainObject(value) {
|
|
4433
|
+
if (value === null || typeof value !== "object")
|
|
4434
|
+
return value;
|
|
4435
|
+
if (Array.isArray(value))
|
|
4436
|
+
return value.map(toPlainObject);
|
|
4437
|
+
if (value instanceof Date)
|
|
4438
|
+
return value;
|
|
4439
|
+
if (value instanceof Uint8Array)
|
|
4440
|
+
return value;
|
|
4441
|
+
if (value instanceof RegExp)
|
|
4442
|
+
return value;
|
|
4443
|
+
if (typeof value.toFixed === "function" && typeof value.toNumber === "function")
|
|
4444
|
+
return value;
|
|
4445
|
+
const result = {};
|
|
4446
|
+
for (const [k, v] of Object.entries(value)) {
|
|
4447
|
+
result[k] = toPlainObject(v);
|
|
4448
|
+
}
|
|
4449
|
+
return result;
|
|
4450
|
+
}
|
|
4432
4451
|
function requireBody(body) {
|
|
4433
|
-
|
|
4452
|
+
const normalized = toPlainObject(body);
|
|
4453
|
+
if (!isPlainObject(normalized))
|
|
4434
4454
|
throw new ShapeError("Request body must be an object");
|
|
4435
|
-
return
|
|
4455
|
+
return normalized;
|
|
4436
4456
|
}
|
|
4437
4457
|
function resolveDynamicShape(fn, contextFn) {
|
|
4438
4458
|
const ctx = validateContext(contextFn());
|