UNPKG

n8n

Version:

n8n Workflow Automation Tool

120 lines 4.34 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.WorkflowEntity = void 0; const class_validator_1 = require("class-validator"); const typeorm_1 = require("typeorm"); const config = require("../../../config"); const TagEntity_1 = require("./TagEntity"); function resolveDataType(dataType) { var _a; const dbType = config.get('database.type'); const typeMap = { sqlite: { json: 'simple-json', }, postgresdb: { datetime: 'timestamptz', }, mysqldb: {}, mariadb: {}, }; return (_a = typeMap[dbType][dataType]) !== null && _a !== void 0 ? _a : dataType; } function getTimestampSyntax() { const dbType = config.get('database.type'); const map = { sqlite: "STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')", postgresdb: 'CURRENT_TIMESTAMP(3)', mysqldb: 'CURRENT_TIMESTAMP(3)', mariadb: 'CURRENT_TIMESTAMP(3)', }; return map[dbType]; } let WorkflowEntity = class WorkflowEntity { setUpdateDate() { this.updatedAt = new Date(); } }; __decorate([ typeorm_1.PrimaryGeneratedColumn(), __metadata("design:type", Number) ], WorkflowEntity.prototype, "id", void 0); __decorate([ typeorm_1.Index({ unique: true }), class_validator_1.Length(1, 128, { message: 'Workflow name must be 1 to 128 characters long.' }), typeorm_1.Column({ length: 128 }), __metadata("design:type", String) ], WorkflowEntity.prototype, "name", void 0); __decorate([ typeorm_1.Column(), __metadata("design:type", Boolean) ], WorkflowEntity.prototype, "active", void 0); __decorate([ typeorm_1.Column(resolveDataType('json')), __metadata("design:type", Array) ], WorkflowEntity.prototype, "nodes", void 0); __decorate([ typeorm_1.Column(resolveDataType('json')), __metadata("design:type", Object) ], WorkflowEntity.prototype, "connections", void 0); __decorate([ typeorm_1.CreateDateColumn({ precision: 3, default: () => getTimestampSyntax() }), __metadata("design:type", Date) ], WorkflowEntity.prototype, "createdAt", void 0); __decorate([ typeorm_1.UpdateDateColumn({ precision: 3, default: () => getTimestampSyntax(), onUpdate: getTimestampSyntax(), }), __metadata("design:type", Date) ], WorkflowEntity.prototype, "updatedAt", void 0); __decorate([ typeorm_1.Column({ type: resolveDataType('json'), nullable: true, }), __metadata("design:type", Object) ], WorkflowEntity.prototype, "settings", void 0); __decorate([ typeorm_1.Column({ type: resolveDataType('json'), nullable: true, }), __metadata("design:type", Object) ], WorkflowEntity.prototype, "staticData", void 0); __decorate([ typeorm_1.ManyToMany(() => TagEntity_1.TagEntity, (tag) => tag.workflows), typeorm_1.JoinTable({ name: 'workflows_tags', joinColumn: { name: 'workflowId', referencedColumnName: 'id', }, inverseJoinColumn: { name: 'tagId', referencedColumnName: 'id', }, }), __metadata("design:type", Array) ], WorkflowEntity.prototype, "tags", void 0); __decorate([ typeorm_1.BeforeUpdate(), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], WorkflowEntity.prototype, "setUpdateDate", null); WorkflowEntity = __decorate([ typeorm_1.Entity() ], WorkflowEntity); exports.WorkflowEntity = WorkflowEntity; //# sourceMappingURL=WorkflowEntity.js.map