@netgrif/components-core
Version:
Netgrif Application engine frontend core Angular library
117 lines (116 loc) • 5.95 kB
TypeScript
import { NetgrifApplicationEngine, Services, View } from '../../commons/schema';
import { Observable } from 'rxjs';
import { ApplicationConfiguration } from './application-configuration';
import { ConfigurationResourceService } from '../resources/engine-endpoint/configuration-resource.service';
export declare abstract class ConfigurationService {
protected configuration: NetgrifApplicationEngine;
protected _configurationResource: ConfigurationResourceService;
protected _applicationConfiguration: ApplicationConfiguration;
private _dataFieldConfiguration;
private readonly APPLICATION_CONFIG;
private readonly _config$;
readonly config$: Observable<NetgrifApplicationEngine | null>;
readonly loaded$: Observable<boolean>;
protected constructor(configuration: NetgrifApplicationEngine, _configurationResource: ConfigurationResourceService, _applicationConfiguration: ApplicationConfiguration);
get snapshot(): NetgrifApplicationEngine | null;
private initialize;
getAsync(): Observable<NetgrifApplicationEngine>;
/**
* Calls to this method should be avoided as creating a deep copy of the configuration has a large overhead
*
* @returns a deep copy of the entire configuration object
*/
get(): NetgrifApplicationEngine;
/**
* Get view configuration from nae.json for view at given config path.
* @param viewConfigPath configuration path to the requested view. No leading backslash.
* @return requested configuration if it exists. `undefined` otherwise.
*/
getViewByPath(viewConfigPath: string): View | undefined;
/**
* Get view configuration from nae.json for view at given url.
* @param url to the requested view. Necessary backslash.
* @return requested configuration if it exists. `undefined` otherwise.
*/
getViewByUrl(url: string): View | undefined;
private getChildren;
/**
* Get all URLs/paths of views with specified layout.
* @param layout Search views with this layout
* @returns Paths with prefixed '/' of all views with specified layout, empty array otherwise.
*/
getPathsByView(layout: string): Array<string>;
getConfigurationSubtreeByPath(path: string): any | undefined;
/**
* @param pathSegments the keys specifying the path trough the configuration that should be accessed
* @returns a deep copy of a specified subsection of the configuration object, or `undefined` if such subsection doesn't exist.
* Calling this method with an empty array as argument is equivalent to calling the [get()]{@link ConfigurationService#get} method.
*/
getConfigurationSubtree(pathSegments: Array<string>): any | undefined;
/**
* @returns the appropriate template configuration for data fields, or `undefined` if such configuration is not present.
*/
getDatafieldConfiguration(): Services['dataFields'] | undefined;
/**
* Resolves the URL addresses of backend endpoints based on the provided configuration.
*
* If the URLs begin with either `http://`, or `https://` the provided URL will be used.
*
* If not, then the URLs are considered to be relative to the location of the frontend application and it's URL will be used
* as the base path. `/api` is appended automatically.
*/
protected resolveEndpointURLs(): void;
/**
* Resolves a single URL address.
*
* If the URL begins with either `http://`, or `https://` the provided URL will be used.
*
* If not, then the URL is considered to be relative to the location of the frontend application and it's URL will be used
* as the base path. `/api` is appended automatically.
*
* @param configURL value from the configuration file
* @returns the resolved URL
*/
protected resolveURL(configURL: string): string;
/**
* @returns the services configuration, or `undefined` if such configuration is not present.
*/
getServicesConfiguration(): Services | undefined;
/**
* @returns the value stored in the [onLogoutRedirect]{@link Services#auth.onLogoutRedirect} attribute if defined.
* If not and the deprecated attribute [logoutRedirect]{@link Services#auth.logoutRedirect} is defined then its value is returned.
* Otherwise, `undefined` is returned.
*/
getOnLogoutPath(): string | undefined;
/**
* @returns the value stored in the [toLoginRedirect]{@link Services#auth.toLoginRedirect} attribute if defined.
* If not and the deprecated attribute [loginRedirect]{@link Services#auth.loginRedirect} is defined then its value is returned.
* Otherwise, `undefined` is returned.
*/
getToLoginPath(): string | undefined;
/**
* @returns the value stored in the [onLoginRedirect]{@link Services#auth.onLoginRedirect} attribute if defined.
* Otherwise, `undefined` is returned.
*/
getOnLoginPath(): string | undefined;
private getView;
/**
* @param endpointKey the attribute name of the endpoint address in `nae.json`
* @returns the endpoint address or `undefined` if such endpoint is not defined in `nae.json`
*/
resolveProvidersEndpoint(endpointKey: string): string;
/**
* Loads and initializes application configuration from the backend.
* If configuration resolution is disabled in APPLICATION_CONFIG, returns null Observable.
* Otherwise fetches public configuration via ConfigurationResourceService.
*
* @returns Observable<any> that emits null if resolution is disabled, otherwise emits the loaded configuration
* @fires initialize() Upon successful configuration load to setup endpoints and data field configurations
* @see ApplicationConfiguration
* @see NetgrifApplicationEngine
*/
loadConfiguration(): Observable<void>;
private createConfigurationCopy;
private getViewsCopy;
private deepCopy;
}