mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(core): reimplement blocking workflow updates on interim changes (#4446)
* 📘 Update request type * 📘 Update FE types * ⚡ Adjust store * ⚡ Set received hash * ⚡ Send and load hash * ⚡ Make helper more flexible * 🗃️ Add new field to entity * 🚨 Add check to endpoint * 🧪 Add tests * ⚡ Add `forceSave` flag * 🐛 Fix workflow update failing on new workflow * 🧪 Add more tests * ⚡ Move check to `updateWorkflow()` * ⚡ Refactor to accommodate latest changes * 🧪 Refactor tests to keep them passing * ⚡ Improve syntax
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import crypto from 'crypto';
|
||||
import { Length } from 'class-validator';
|
||||
|
||||
import type {
|
||||
@@ -10,6 +11,9 @@ import type {
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
AfterLoad,
|
||||
AfterUpdate,
|
||||
AfterInsert,
|
||||
Column,
|
||||
Entity,
|
||||
Index,
|
||||
@@ -84,6 +88,30 @@ export class WorkflowEntity extends AbstractEntity implements IWorkflowDb {
|
||||
transformer: sqlite.jsonColumn,
|
||||
})
|
||||
pinData: ISimplifiedPinData;
|
||||
|
||||
/**
|
||||
* Hash of editable workflow state.
|
||||
*/
|
||||
hash: string;
|
||||
|
||||
@AfterLoad()
|
||||
@AfterUpdate()
|
||||
@AfterInsert()
|
||||
setHash(): void {
|
||||
const { name, active, nodes, connections, settings, staticData, pinData } = this;
|
||||
|
||||
const state = JSON.stringify({
|
||||
name,
|
||||
active,
|
||||
nodes,
|
||||
connections,
|
||||
settings,
|
||||
staticData,
|
||||
pinData,
|
||||
});
|
||||
|
||||
this.hash = crypto.createHash('md5').update(state).digest('hex');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user