1 import { AllowNull, Column, CreatedAt, DataType, HasMany, Model, Table, UpdatedAt } from 'sequelize-typescript'
2 import { AttributesOnly } from '@shared/typescript-utils'
3 import { OAuthTokenModel } from './oauth-token'
6 tableName: 'oAuthClient',
9 fields: [ 'clientId' ],
13 fields: [ 'clientId', 'clientSecret' ],
18 export class OAuthClientModel extends Model<Partial<AttributesOnly<OAuthClientModel>>> {
28 @Column(DataType.ARRAY(DataType.STRING))
31 @Column(DataType.ARRAY(DataType.STRING))
32 redirectUris: string[]
40 @HasMany(() => OAuthTokenModel, {
43 OAuthTokens: OAuthTokenModel[]
45 static countTotal () {
46 return OAuthClientModel.count()
49 static loadFirstClient () {
50 return OAuthClientModel.findOne()
53 static getByIdAndSecret (clientId: string, clientSecret: string) {
57 clientSecret: clientSecret
61 return OAuthClientModel.findOne(query)