
- auth clients are always shared, cannot be disabled - custom connections are enabled by default, can be disabled - any existing connections can be reconnected regardless of its AppConfig or AppAuthClient states
45 lines
972 B
JavaScript
45 lines
972 B
JavaScript
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;
|