velocious 1.0.705 → 1.0.706
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/build/database/record/auditing.js +16 -4
- package/build/database/record/index.js +3 -2
- package/build/src/database/record/auditing.d.ts +4 -1
- package/build/src/database/record/auditing.d.ts.map +1 -1
- package/build/src/database/record/auditing.js +14 -5
- package/build/src/database/record/index.d.ts +8 -2
- package/build/src/database/record/index.d.ts.map +1 -1
- package/build/src/database/record/index.js +4 -3
- package/package.json +1 -1
- package/src/database/record/auditing.js +16 -4
- package/src/database/record/index.js +3 -2
package/package.json
CHANGED
|
@@ -420,14 +420,18 @@ function modelParamKey(modelClass) {
|
|
|
420
420
|
* Table detection and relationship registration happen lazily on first usage.
|
|
421
421
|
* Called synchronously from Model.audited() at module-load time.
|
|
422
422
|
* @param {AuditedModelClass} modelClass - Model class to audit.
|
|
423
|
+
* @param {{except?: string[]}} [options] - Audit options: `except` lists attribute names never written to the audit trail (e.g. high-frequency telemetry columns).
|
|
423
424
|
* @returns {void}
|
|
424
425
|
*/
|
|
425
|
-
function registerAuditing(modelClass) {
|
|
426
|
+
function registerAuditing(modelClass, options = {}) {
|
|
426
427
|
if (Object.prototype.hasOwnProperty.call(modelClass, "_auditLifecycleCallbacksRegistered") && modelClass._auditLifecycleCallbacksRegistered) {
|
|
427
428
|
return
|
|
428
429
|
}
|
|
429
430
|
|
|
430
|
-
|
|
431
|
+
const auditableModelClass = /** @type {AuditedModelClass & {_auditExcludedAttributes?: Set<string>}} */ (modelClass)
|
|
432
|
+
|
|
433
|
+
auditableModelClass._auditLifecycleCallbacksRegistered = true
|
|
434
|
+
auditableModelClass._auditExcludedAttributes = new Set(options.except || [])
|
|
431
435
|
registerAuditRelationship(modelClass)
|
|
432
436
|
modelClass.beforeCreate("captureCreateAuditChanges")
|
|
433
437
|
modelClass.afterCreate("createCreateAudit")
|
|
@@ -801,10 +805,18 @@ function auditChangesForCurrentChanges(record) {
|
|
|
801
805
|
const changes = record.changes()
|
|
802
806
|
/** @type {AuditChanges} */
|
|
803
807
|
const auditedChanges = {}
|
|
804
|
-
const
|
|
808
|
+
const modelClass = /** @type {AuditedModelClass & {_auditExcludedAttributes?: Set<string>}} */ (record.getModelClass())
|
|
809
|
+
const columnNameToAttributeName = modelClass.getColumnNameToAttributeNameMap()
|
|
810
|
+
const excludedAttributes = modelClass._auditExcludedAttributes
|
|
805
811
|
|
|
806
812
|
for (const [attributeName, change] of Object.entries(changes)) {
|
|
807
|
-
|
|
813
|
+
const auditedAttributeName = columnNameToAttributeName[attributeName] || attributeName
|
|
814
|
+
|
|
815
|
+
if (excludedAttributes && (excludedAttributes.has(auditedAttributeName) || excludedAttributes.has(attributeName))) {
|
|
816
|
+
continue
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
auditedChanges[auditedAttributeName] = change[1]
|
|
808
820
|
}
|
|
809
821
|
|
|
810
822
|
return auditedChanges
|
|
@@ -734,10 +734,11 @@ class VelociousDatabaseRecord {
|
|
|
734
734
|
|
|
735
735
|
/**
|
|
736
736
|
* Enables automatic create/update/destroy auditing for this model.
|
|
737
|
+
* @param {{except?: string[]}} [options] - Audit options: `except` lists attribute names that must never be written to the audit trail. Use it for high-frequency telemetry columns (heartbeats, progress counters) whose write volume turns the audit table into a deadlock partner for the parent row.
|
|
737
738
|
* @returns {void}
|
|
738
739
|
*/
|
|
739
|
-
static audited() {
|
|
740
|
-
registerAuditing(this)
|
|
740
|
+
static audited(options = {}) {
|
|
741
|
+
registerAuditing(this, options)
|
|
741
742
|
}
|
|
742
743
|
|
|
743
744
|
/**
|