@naturalcycles/db-lib
Advanced tools
Comparing version 9.24.2 to 9.25.0
@@ -971,3 +971,15 @@ "use strict"; | ||
// Joi | ||
const start = performance.now(); | ||
const vr = (0, nodejs_lib_1.getValidationResult)(obj, schema, objectName); | ||
const end = performance.now(); | ||
const tookMillis = end - start; | ||
if (this.cfg.debugValidationTimeThreshhold && | ||
tookMillis >= this.cfg.debugValidationTimeThreshhold) { | ||
this.cfg.onValidationTimeThreshold?.({ | ||
tookMillis, | ||
error: !!vr.error, | ||
table, | ||
obj, | ||
}); | ||
} | ||
error = vr.error; | ||
@@ -974,0 +986,0 @@ convertedValue = vr.value; |
@@ -1,2 +0,2 @@ | ||
import { BaseDBEntity, CommonLogger, ErrorMode, Promisable, UnixTimestamp, ZodError, ZodSchema } from '@naturalcycles/js-lib'; | ||
import { AnyObject, BaseDBEntity, CommonLogger, ErrorMode, NumberOfMilliseconds, Promisable, UnixTimestamp, ZodError, ZodSchema } from '@naturalcycles/js-lib'; | ||
import { AjvSchema, AjvValidationError, JoiValidationError, ObjectSchema, TransformLogProgressOptions, TransformMapOptions } from '@naturalcycles/nodejs-lib'; | ||
@@ -115,2 +115,11 @@ import { CommonDB } from '../common.db'; | ||
/** | ||
* Defaults to undefined == disabled. | ||
* If set - enable the monitoring of validation time and will alert on crossing the threshold. | ||
*/ | ||
debugValidationTimeThreshhold?: NumberOfMilliseconds; | ||
/** | ||
* Called when debugValidationTimeThreshhold is crossed. | ||
*/ | ||
onValidationTimeThreshold?: (info: AnyObject) => void; | ||
/** | ||
* Defaults to false. | ||
@@ -117,0 +126,0 @@ * Setting it to true will set saveMethod to `insert` for save/saveBatch, which will |
@@ -46,5 +46,5 @@ { | ||
"engines": { | ||
"node": ">=20.13" | ||
"node": ">=22.10.0" | ||
}, | ||
"version": "9.24.2", | ||
"version": "9.25.0", | ||
"description": "Lowest Common Denominator API to supported Databases", | ||
@@ -51,0 +51,0 @@ "keywords": [ |
import { | ||
AnyObject, | ||
BaseDBEntity, | ||
CommonLogger, | ||
ErrorMode, | ||
NumberOfMilliseconds, | ||
Promisable, | ||
@@ -150,2 +152,13 @@ UnixTimestamp, | ||
/** | ||
* Defaults to undefined == disabled. | ||
* If set - enable the monitoring of validation time and will alert on crossing the threshold. | ||
*/ | ||
debugValidationTimeThreshhold?: NumberOfMilliseconds | ||
/** | ||
* Called when debugValidationTimeThreshhold is crossed. | ||
*/ | ||
onValidationTimeThreshold?: (info: AnyObject) => void | ||
/** | ||
* Defaults to false. | ||
@@ -152,0 +165,0 @@ * Setting it to true will set saveMethod to `insert` for save/saveBatch, which will |
@@ -1260,3 +1260,19 @@ import { Transform } from 'node:stream' | ||
// Joi | ||
const start = performance.now() | ||
const vr = getValidationResult(obj, schema, objectName) | ||
const end = performance.now() | ||
const tookMillis = end - start | ||
if ( | ||
this.cfg.debugValidationTimeThreshhold && | ||
tookMillis >= this.cfg.debugValidationTimeThreshhold | ||
) { | ||
this.cfg.onValidationTimeThreshold?.({ | ||
tookMillis, | ||
error: !!vr.error, | ||
table, | ||
obj, | ||
}) | ||
} | ||
error = vr.error | ||
@@ -1263,0 +1279,0 @@ convertedValue = vr.value |
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
436658
11474