Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { IsJSON } from 'class-validator';
import { Entity, Index, PrimaryColumn } from 'typeorm';
import { Column } from 'typeorm';
@Entity('options')
@Index(['key'])
export class Option {
// constructor(input?: DeepPartial<option>) {
// }
@Column({ type: 'varchar', length: 100 })
@PrimaryColumn()
key: string;
@Column('json', {
nullable: true,
comment: '元信息值',
})
@IsJSON()
value?: any;
@Column('varchar', {
nullable: true,</option>
sender: User;
recipient: User;
senderMeta: OrderMeta;
recipientMeta: OrderMeta;
contexts: [OrderContext, OrderContext];
};
@Entity({ name: "orders" })
@Initializers({
contexts: () => [],
id: () => generateId(IdPrefix.Transaction),
currentStatusDate: () => moment().toDate(),
expirationDate: () => moment().add(10, "minutes").toDate() // opened expiration
})
@Index(["offerId", "nonce"])
@Index(["offerId", "status"])
@Register
class OrderImpl extends CreationDateModel implements Order {
@Column()
public readonly origin!: OrderOrigin;
@Column("simple-json", { name: "blockchain_data", nullable: true })
public blockchainData!: BlockchainData;
@OneToMany(type => OrderContext, context => context.order, {
cascadeInsert: true,
cascadeUpdate: true
})
public contexts!: OrderContext[];
@Index()
@Column({ name: "offer_id" })
This file and project is licensed under the MIT license
See file LICENSE in the root of this project or go to for full license details.
*/
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, BaseEntity, Index, ManyToOne, JoinColumn, OneToOne, AfterLoad } from 'typeorm';
import Player from './player';
import PlanetBuildings from './planet-buildings';
import IPlanetData from '../../game/data-types/planet-data';
import { IResourcesAndEnergy } from '../../game/data-types/resources';
import IEconomyData from '../../game/data-types/economy-data';
import EconomyCalculator from '../../game/core/services/economy-calculator';
import Defense from './defense';
import Ships from './ships';
@Entity()
@Index(['galaxy', 'system', 'position'], { unique: true })
export default class Planet extends BaseEntity implements IResourcesAndEnergy {
//TODO: Zone
public get energy(): number {
return this.economyData.energy.production;
}
public get usedEnergy(): number {
return this.economyData.energy.usage;
}
public get usedFields(): number {
const buildingsList = this.buildings.getBuildingsList();
const totalBuildings = buildingsList.reduce((previous, current) => {
return previous + current.level;
}, 0);
return totalBuildings;
}
public get metalPerHour(): number {
import { Index, Entity, Column } from 'typeorm';
import { ObjectType, Field, Int } from 'type-graphql';
import { AxAttachmentsObject } from '@leaa/common/src/dtos/ax';
import { Base } from '@leaa/common/src/entrys';
@Entity('axs')
@Index('axs_title_unique', ['title'], { unique: true })
@Index('axs_slug_unique', ['slug'], { unique: true })
@ObjectType()
export class Ax extends Base {
@Column({ type: 'varchar', length: 32, unique: true })
@Field(() => String)
title!: string;
@Column({ type: 'varchar', length: 32, unique: true, default: null })
@Field(() => String, { nullable: true })
slug?: string;
@Column({ type: 'text', nullable: true })
@Field(() => String, { nullable: true })
description?: string;
@Column({ type: 'int', default: 0 })
Index,
UpdateDateColumn,
CreateDateColumn,
OneToOne,
JoinColumn,
ManyToOne,
getRepository
} from 'typeorm';
import Post from './Post';
import Series from './Series';
import DataLoader from 'dataloader';
@Entity('series_posts', {
synchronize: false
})
@Index(['fk_series_id', 'fk_post_id'])
export default class SeriesPosts {
@PrimaryGeneratedColumn('uuid')
id!: string;
@Index()
@Column('uuid')
fk_series_id!: string;
@Index()
@Column('uuid')
fk_post_id!: string;
@Column('int4')
index!: number;
@Column('timestampz')
@Column() isFeatured: boolean
@Column() callsHome: boolean
@Column() callsThirdParty: boolean
@OneToMany(() => ReleaseAuthor, author => author.release) authors: Promise
@Column({type: "enum", enum: getEnumNames(CategoryType)}) category: keyof CategoryType
@OneToMany(() => ReleaseCategory, category => category.release) minorCategories: Promise
@OneToMany(() => ReleaseVersion, version => version.release) versions: Promise
@OneToMany(() => ReleasePermission, version => version.release) permissions: Promise
@OneToMany(() => ReleaseCommand, version => version.release) commands: Promise
}
@Entity()
@Index(["author", "release"], {unique: true})
export class ReleaseAuthor implements IReleaseAuthor{
@PrimaryGeneratedColumn() id: number
@ManyToOne(() => User) author: Promise
@ManyToOne(() => Release, release => release.authors) release: Promise
@Column({type: "enum", enum: getEnumNames(AuthorType)}) type: keyof AuthorType
}
@Entity()
export class ReleaseCategory implements IReleaseCategory{
@PrimaryGeneratedColumn() id: number
@ManyToOne(() => Release, release => release.minorCategories) release: Promise
@Column({type: "enum", enum: getEnumNames(CategoryType)}) category: keyof CategoryType
}
@Entity()
export class ReleasePermission implements IReleasePermission{
@Entity({
name: 'current',
})
export class CurrentRecordEntity {
@PrimaryGeneratedColumn({
type: 'int',
})
id!: number;
@Column({
name: 'keyword',
type: 'varchar',
nullable: false,
})
@Index('current_keyword_uindex',{
unique: true
})
keyword!: string;
@Column({
name: 'dict',
type: 'text',
nullable: false
})
value!: string;
}
resolve(body);
});
});
}
export class EventSubscriberAttrs {
url: string;
project: string;
receiverType?: string;
eventNames?: string[];
lastBlock?: number;
interval?: number;
}
@Entity()
@Index('URL_PROJECT_INDEX', ['url', 'project'], { unique: true })
export class EventSubscription extends BaseEntity {
@PrimaryGeneratedColumn('uuid') id: string;
@Column() url: string;
@Column() project: string;
@Column() receiverType: string;
@Column('simple-array') eventNames: string[];
@Column('bigint') lastBlock: number;
@Column('int') interval: number;
@Column('int') errorCount: number;
@CreateDateColumn() createdDate: Date;
private contractInstance: any;
private contractEntity: Contract;
private asyncPolls: any = {};
static DEFAULT_INTERVAL = 30 * SECONDS;
import "reflect-metadata";
import {Entity, Column, OneToMany, ManyToOne, Index} from "typeorm";
import {MediaFile} from "./MediaFile";
import {MetaData} from "./MetaData";
import {AbsMetaData} from "./AbsMetaData";
import {UserEpisode} from "./UserEpisode";
import {TorrentFile} from "./TorrentFile";
@Entity("Episode")
@Index(["season", "episode", "metaData"], { unique: true })
export class Episode extends AbsMetaData {
@Column({type: "int", nullable: true})
public season?: number;
@Column({type: "int"})
public episode: number;
@Index()
@Column({type: "varchar", length: 255, nullable: true})
public imdbSeriesId?: string;
@OneToMany(() => MediaFile, mediaFile => mediaFile.episode, {eager: true})
public mediaFiles: MediaFile[];
@OneToMany(() => TorrentFile, torrentFile => torrentFile.episode, {eager: true})
import { User as IUser } from '../contract';
import { Entity, Unique, Index, PrimaryGeneratedColumn, Column } from 'typeorm';
import {
IsBoolean,
IsEmail,
IsLowercase,
IsNotEmpty,
IsOptional,
IsUrl,
MaxLength,
Matches,
} from 'class-validator';
@Entity('user')
@Unique('unique_user_username', ['username'])
@Unique('unique_user_email', ['email'])
@Index('index_user_username', ['username'])
@Index('index_user_email', ['email'])
export class User implements IUser {
@PrimaryGeneratedColumn()
id: number;
@Matches(RegExp('^[a-zA-Z0-9\\-]+$'))
@MaxLength(32)
@IsLowercase()
@Column('text')
username: string;
@IsEmail()
@Column('text')
email: string;
@IsNotEmpty()