Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Column, DataType, Default, Model, PrimaryKey, Table } from 'sequelize-typescript';
@Table({ timestamps: true })
export class ContentRelease extends Model {
@PrimaryKey
@Default(DataType.UUIDV4)
@Column(DataType.UUID)
public id: any;
@Column
public name: string;
@Column
public description: string;
@Column
public scheduledAt: Date;
@Column
public publishedAt: Date;
@Column(DataType.UUID)
flag: 'us',
master: true,
};
const masterLocale = [].concat(settings.locales).find((locale: any) => locale && locale.master);
if (!masterLocale) {
settings.locales.push(defaultLocale);
}
settings.masterLocale = [].concat(settings.locales).find((locale: any) => locale && locale.master);
return settings;
}
@PrimaryKey
@Default(DataType.UUIDV4)
@Column(DataType.UUID)
public id: any;
@Column(DataType.JSONB)
public data: any;
@Column(DataType.UUID)
public userId;
@CreatedAt
@Column
public createdAt: Date;
@UpdatedAt
@Column
public updatedAt: Date;
import { Model, Column, Table, HasMany, PrimaryKey, DataType } from 'sequelize-typescript';
import { ContentEntry } from './ContentEntry';
import { ContentTypeField } from './ContentTypeField';
@Table
export class ContentType extends Model {
@PrimaryKey
@Column({
type: DataType.UUID,
defaultValue: DataType.UUIDV4
})
id;
@Column
name: string;
@HasMany(() => ContentEntry)
contentEntry: ContentEntry;
@HasMany(() => ContentTypeField)
fields: ContentTypeField[];
}
import { BelongsTo, Column, DataType, Default, Model, PrimaryKey, Table } from 'sequelize-typescript';
import { Webhook } from './Webhook';
@Table
export class WebhookCall extends Model {
@PrimaryKey
@Default(DataType.UUIDV4)
@Column(DataType.UUID)
public id;
@Column(DataType.UUID)
public webhookId: any;
@Column(DataType.BOOLEAN)
public success: any;
@Column(DataType.INTEGER)
public status: number;
@Column(DataType.JSONB)
public request: any;
@Column(DataType.JSONB)
@Scopes({
contentType: {
include: [{
model: () => ContentType,
through: { attributes: [] },
}],
},
})
@Table
export class ContentEntry extends Model {
@PrimaryKey
@Column({
type: DataType.UUID,
defaultValue: DataType.UUIDV4
})
id;
@Column(DataType.UUID)
@ForeignKey(() => ContentType)
contentTypeId;
@Column
language: string;
@Column(DataType.JSON)
data;
@BelongsTo(() => ContentType)
contentType: ContentType;
}
import { Column, DataType, Model, PrimaryKey, Table } from 'sequelize-typescript';
@Table
export class Navigation extends Model {
@PrimaryKey
@Column({
type: DataType.UUID,
defaultValue: DataType.UUIDV4,
})
public id;
@Column(DataType.UUID)
public parentNavigationId;
@Column(DataType.STRING)
public name: string;
@Column(DataType.UUID)
public contentTypeId: string;
@Column(DataType.UUID)
public contentEntryId: string;
@Column(DataType.BOOLEAN)
Model,
PrimaryKey,
Table,
Unique,
} from 'sequelize-typescript';
@Table({ timestamps: true })
export class User extends Model {
@BeforeCreate
public static HASH_PASSWORD(instance: User) {
instance.password = bcrypt.hashSync(instance.password, 10);
}
@PrimaryKey
@Column({
type: DataType.UUID,
defaultValue: DataType.UUIDV4,
})
public id;
@Column
public firstname: string;
@Column
public lastname: string;
@Column
public displayName: string;
@Column
public avatarUrl: string;
@IsEmail
import { JSON } from 'sequelize';
import { BelongsTo, Column, DataType, Default, ForeignKey, Model, PrimaryKey, Table } from 'sequelize-typescript';
import { fields } from '../fields';
import { ContentType } from './ContentType';
@Table
export class ContentTypeField extends Model {
@PrimaryKey
@Column({
type: DataType.UUID,
defaultValue: DataType.UUIDV4,
})
public id: string;
@Column
public name: string;
@Column
public title: string;
@Column
public description: string;
@Column
public type: string;
@Default('Main')
public static async GET_RANDOM_ID() {
const entryId = hashid.encode(+new Date());
const count = await ContentEntry.count({
where: {
entryId,
},
});
return count === 0 ? entryId : ContentEntry.GET_RANDOM_ID();
}
@Column(DataType.STRING)
public entryId: string;
@PrimaryKey
@Default(DataType.UUIDV4)
@Column(DataType.UUID)
public versionId: any;
@ForeignKey(() => ContentType)
@Column(DataType.UUID)
public contentTypeId: any;
@ForeignKey(() => ContentRelease)
@Column(DataType.UUID)
public contentReleaseId: any;
@Default('en')
@Column
public language: string;
@Column