feat(permissions): Adds server permissions
This commit is contained in:
parent
d46bbd84c5
commit
cf9c88a2d6
24 changed files with 415 additions and 69 deletions
|
|
@ -7,6 +7,17 @@ import deepmerge from "deepmerge";
|
|||
import {isPlainObject} from "is-plain-object";
|
||||
import {Nullable} from "../types/Nullable";
|
||||
import {ConfigurationTransformer, TransformerResults} from "./ConfigurationTransformer";
|
||||
import _ from "lodash";
|
||||
|
||||
export enum PathConfigurationFrom {
|
||||
Database,
|
||||
Default
|
||||
}
|
||||
|
||||
export type PathConfiguration = {
|
||||
value: TransformerResults,
|
||||
from: PathConfigurationFrom
|
||||
}
|
||||
|
||||
export class ConfigurationHandler<
|
||||
TProviderModel extends ConfigurationModel = ConfigurationModel,
|
||||
|
|
@ -48,22 +59,27 @@ export class ConfigurationHandler<
|
|||
)
|
||||
}
|
||||
|
||||
public getConfigurationByPath(path: string): Nullable<TransformerResults> {
|
||||
public getConfigurationByPath(path: string): PathConfiguration {
|
||||
const configuration = this.provider.get(path);
|
||||
if (!configuration) {
|
||||
return;
|
||||
return {
|
||||
value: _.get(this.provider.defaults, path, null),
|
||||
from: PathConfigurationFrom.Default
|
||||
};
|
||||
}
|
||||
|
||||
return this.transformer.getValue(configuration);
|
||||
return {
|
||||
value: this.transformer.getValue(configuration),
|
||||
from: PathConfigurationFrom.Database
|
||||
};
|
||||
}
|
||||
|
||||
private getCompleteDatabaseConfig(): Partial<TRuntimeConfiguration> {
|
||||
const values = this.provider.getAll();
|
||||
const configuration: Partial<TRuntimeConfiguration> = {};
|
||||
|
||||
values.forEach((configValue) => {
|
||||
const value = this.transformer.getValue(configValue);
|
||||
setPath(configuration, configValue.key, value);
|
||||
_.set(configuration, configValue.key, value);
|
||||
})
|
||||
|
||||
return configuration;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue