UNPKG

@grouparoo/core

Version:
79 lines (78 loc) 3.44 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.Mapping = void 0; const sequelize_typescript_1 = require("sequelize-typescript"); const Property_1 = require("./Property"); const Destination_1 = require("./Destination"); const Source_1 = require("./Source"); const apiData_1 = require("../modules/apiData"); const commonModel_1 = require("../classes/commonModel"); let Mapping = class Mapping extends commonModel_1.CommonModel { constructor() { super(...arguments); this.uniqueIdentifier = ["ownerId", "ownerType", "remoteKey"]; } idPrefix() { return "map"; } async apiData() { return { id: this.id, ownerId: this.ownerId, ownerType: this.ownerType, propertyId: this.propertyId, remoteKey: this.remoteKey, createdAt: apiData_1.APIData.formatDate(this.createdAt), updatedAt: apiData_1.APIData.formatDate(this.updatedAt), }; } }; __decorate([ (0, sequelize_typescript_1.AllowNull)(false), (0, sequelize_typescript_1.ForeignKey)(() => Destination_1.Destination), (0, sequelize_typescript_1.ForeignKey)(() => Source_1.Source), sequelize_typescript_1.Column, __metadata("design:type", String) ], Mapping.prototype, "ownerId", void 0); __decorate([ (0, sequelize_typescript_1.AllowNull)(false), sequelize_typescript_1.Column, __metadata("design:type", String) ], Mapping.prototype, "ownerType", void 0); __decorate([ (0, sequelize_typescript_1.AllowNull)(false), (0, sequelize_typescript_1.ForeignKey)(() => Property_1.Property), sequelize_typescript_1.Column, __metadata("design:type", String) ], Mapping.prototype, "propertyId", void 0); __decorate([ (0, sequelize_typescript_1.AllowNull)(false), (0, sequelize_typescript_1.Length)({ min: 1, max: 191 }), sequelize_typescript_1.Column, __metadata("design:type", String) ], Mapping.prototype, "remoteKey", void 0); __decorate([ (0, sequelize_typescript_1.BelongsTo)(() => Destination_1.Destination), __metadata("design:type", Destination_1.Destination) ], Mapping.prototype, "destination", void 0); __decorate([ (0, sequelize_typescript_1.BelongsTo)(() => Source_1.Source), __metadata("design:type", Source_1.Source) ], Mapping.prototype, "source", void 0); __decorate([ (0, sequelize_typescript_1.BelongsTo)(() => Property_1.Property), __metadata("design:type", Property_1.Property) ], Mapping.prototype, "property", void 0); Mapping = __decorate([ (0, sequelize_typescript_1.Table)({ tableName: "mappings", paranoid: false }) ], Mapping); exports.Mapping = Mapping;