UNPKG

n8n

Version:

n8n Workflow Automation Tool

54 lines 3.04 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); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.InstalledPackagesRepository = void 0; const typedi_1 = require("typedi"); const typeorm_1 = require("@n8n/typeorm"); const InstalledPackages_1 = require("../entities/InstalledPackages"); const installedNodes_repository_1 = require("./installedNodes.repository"); let InstalledPackagesRepository = class InstalledPackagesRepository extends typeorm_1.Repository { constructor(dataSource, installedNodesRepository) { super(InstalledPackages_1.InstalledPackages, dataSource.manager); this.installedNodesRepository = installedNodesRepository; } async saveInstalledPackageWithNodes(packageLoader) { const { packageJson, nodeTypes, loadedNodes } = packageLoader; const { name: packageName, version: installedVersion, author } = packageJson; let installedPackage; await this.manager.transaction(async (manager) => { installedPackage = await manager.save(this.create({ packageName, installedVersion, authorName: author === null || author === void 0 ? void 0 : author.name, authorEmail: author === null || author === void 0 ? void 0 : author.email, })); installedPackage.installedNodes = []; for (const loadedNode of loadedNodes) { const installedNode = this.installedNodesRepository.create({ name: nodeTypes[loadedNode.name].type.description.displayName, type: loadedNode.name, latestVersion: loadedNode.version.toString(), package: { packageName }, }); installedPackage.installedNodes.push(installedNode); await manager.save(installedNode); } }); return installedPackage; } }; exports.InstalledPackagesRepository = InstalledPackagesRepository; exports.InstalledPackagesRepository = InstalledPackagesRepository = __decorate([ (0, typedi_1.Service)(), __metadata("design:paramtypes", [typeorm_1.DataSource, installedNodes_repository_1.InstalledNodesRepository]) ], InstalledPackagesRepository); //# sourceMappingURL=installedPackages.repository.js.map