UNPKG

n8n

Version:

n8n Workflow Automation Tool

69 lines 3.27 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; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SettingsRepository = void 0; const constants_1 = require("../../ExternalSecrets/constants"); const typedi_1 = require("typedi"); const typeorm_1 = require("@n8n/typeorm"); const n8n_workflow_1 = require("n8n-workflow"); const Settings_1 = require("../entities/Settings"); const config_1 = __importDefault(require("../../config")); let SettingsRepository = class SettingsRepository extends typeorm_1.Repository { constructor(dataSource) { super(Settings_1.Settings, dataSource.manager); } async getEncryptedSecretsProviderSettings() { var _a, _b; return (_b = (_a = (await this.findByKey(constants_1.EXTERNAL_SECRETS_DB_KEY))) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : null; } async findByKey(key) { return await this.findOneBy({ key }); } async saveEncryptedSecretsProviderSettings(data) { await this.upsert({ key: constants_1.EXTERNAL_SECRETS_DB_KEY, value: data, loadOnStartup: false, }, ['key']); } async dismissBanner({ bannerName }) { const key = 'ui.banners.dismissed'; const dismissedBannersSetting = await this.findOneBy({ key }); try { let value; if (dismissedBannersSetting) { const dismissedBanners = JSON.parse(dismissedBannersSetting.value); const updatedValue = [...new Set([...dismissedBanners, bannerName].sort())]; value = JSON.stringify(updatedValue); await this.update({ key }, { value, loadOnStartup: true }); } else { value = JSON.stringify([bannerName]); await this.save({ key, value, loadOnStartup: true }, { transaction: false }); } config_1.default.set(key, value); return { success: true }; } catch (error) { n8n_workflow_1.ErrorReporterProxy.error(error); } return { success: false }; } }; exports.SettingsRepository = SettingsRepository; exports.SettingsRepository = SettingsRepository = __decorate([ (0, typedi_1.Service)(), __metadata("design:paramtypes", [typeorm_1.DataSource]) ], SettingsRepository); //# sourceMappingURL=settings.repository.js.map