UNPKG

n8n

Version:

n8n Workflow Automation Tool

55 lines 2.55 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.VersionMismatchCheck = void 0; const decorators_1 = require("@n8n/decorators"); const CHECK_CODE = 'cluster.version-mismatch'; const AUDIT_DETECTED = 'n8n.audit.cluster.version-mismatch.detected'; const AUDIT_RESOLVED = 'n8n.audit.cluster.version-mismatch.resolved'; function computeFingerprint(instances) { const versions = [...new Set([...instances].map((i) => i.version))].sort(); return versions.length > 1 ? versions.join('|') : ''; } let VersionMismatchCheck = class VersionMismatchCheck { constructor() { this.checkDescription = { name: 'version-mismatch', displayName: 'Version mismatch', }; } async run(context) { const currentFingerprint = computeFingerprint(context.currentState.values()); const previousFingerprint = computeFingerprint(context.previousState.values()); if (currentFingerprint === '') { if (previousFingerprint !== '') { return { auditEvents: [{ eventName: AUDIT_RESOLVED, payload: {} }] }; } return {}; } const versions = currentFingerprint.split('|'); const result = { warnings: [ { code: CHECK_CODE, message: `Detected multiple n8n versions in the cluster: ${versions.join(', ')}`, severity: 'error', context: { versions }, }, ], }; if (currentFingerprint !== previousFingerprint) { result.auditEvents = [{ eventName: AUDIT_DETECTED, payload: { versions } }]; } return result; } }; exports.VersionMismatchCheck = VersionMismatchCheck; exports.VersionMismatchCheck = VersionMismatchCheck = __decorate([ (0, decorators_1.ClusterCheck)() ], VersionMismatchCheck); //# sourceMappingURL=version-mismatch.check.js.map