UNPKG

@authup/server-api

Version:

This is a standalone application.

90 lines 3.79 kB
"use strict"; /* * Copyright (c) 2021-2021. * Author Peter Placzek (tada5hi) * For the full copyright and license information, * view the LICENSE file that was distributed with this source code. */ 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.RobotEntity = void 0; const typeorm_1 = require("typeorm"); const core_1 = require("@authup/core"); const realm_1 = require("../realm"); const user_1 = require("../user"); let RobotEntity = class RobotEntity { // ------------------------------------------------------------------ setName() { if (!this.name || this.name.length === 0) { this.name = (0, core_1.createNanoID)(36); } } }; exports.RobotEntity = RobotEntity; __decorate([ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'), __metadata("design:type", String) ], RobotEntity.prototype, "id", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'varchar', length: 256, select: false }), __metadata("design:type", String) ], RobotEntity.prototype, "secret", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'varchar', length: 128 }), __metadata("design:type", String) ], RobotEntity.prototype, "name", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'text', nullable: true }), __metadata("design:type", String) ], RobotEntity.prototype, "description", void 0); __decorate([ (0, typeorm_1.Column)({ type: 'boolean', default: true }), __metadata("design:type", Boolean) ], RobotEntity.prototype, "active", void 0); __decorate([ (0, typeorm_1.CreateDateColumn)(), __metadata("design:type", Date) ], RobotEntity.prototype, "created_at", void 0); __decorate([ (0, typeorm_1.UpdateDateColumn)(), __metadata("design:type", Date) ], RobotEntity.prototype, "updated_at", void 0); __decorate([ (0, typeorm_1.Column)({ nullable: true, default: null }), __metadata("design:type", Object) ], RobotEntity.prototype, "user_id", void 0); __decorate([ (0, typeorm_1.ManyToOne)(() => user_1.UserEntity, { onDelete: 'CASCADE', nullable: true }), (0, typeorm_1.JoinColumn)({ name: 'user_id' }), __metadata("design:type", Object) ], RobotEntity.prototype, "user", void 0); __decorate([ (0, typeorm_1.Index)(), (0, typeorm_1.Column)(), __metadata("design:type", Object) ], RobotEntity.prototype, "realm_id", void 0); __decorate([ (0, typeorm_1.ManyToOne)(() => realm_1.RealmEntity, { onDelete: 'CASCADE' }), (0, typeorm_1.JoinColumn)({ name: 'realm_id' }), __metadata("design:type", Object) ], RobotEntity.prototype, "realm", void 0); __decorate([ (0, typeorm_1.BeforeUpdate)(), (0, typeorm_1.BeforeInsert)(), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], RobotEntity.prototype, "setName", null); exports.RobotEntity = RobotEntity = __decorate([ (0, typeorm_1.Entity)({ name: 'auth_robots' }), (0, typeorm_1.Unique)(['name', 'realm_id']) ], RobotEntity); //# sourceMappingURL=entity.js.map