import App from './app.js'; import AppAuthClient from './app-auth-client.js'; import Base from './base.js'; class AppConfig extends Base { static tableName = 'app_configs'; static get idColumn() { return 'key'; } static jsonSchema = { type: 'object', required: ['key'], properties: { id: { type: 'string', format: 'uuid' }, key: { type: 'string' }, useOnlyPredefinedAuthClients: { type: 'boolean', default: false }, disabled: { type: 'boolean', default: false }, createdAt: { type: 'string' }, updatedAt: { type: 'string' }, }, }; static relationMappings = () => ({ appAuthClients: { relation: Base.HasManyRelation, modelClass: AppAuthClient, join: { from: 'app_configs.key', to: 'app_auth_clients.app_key', }, }, }); async getApp() { if (!this.key) return null; return await App.findOneByKey(this.key); } } export default AppConfig;