vulcain-corejs
Version:
Vulcain micro-service framework
217 lines (216 loc) • 5.44 kB
TypeScript
import { VulcainLogger } from './../log/vulcainLogger';
import { VulcainManifest } from './../dependencies/annotations';
import { IDynamicProperty } from '../dynamicProperty';
import { MockManager } from '../../commands/mocks/mockManager';
/**
* Static class providing service helper methods
*
* @export
* @class System
*/
export declare class System {
private static _vulcainServer;
private static _vulcainToken;
private static _vulcainConfig;
private static logger;
private static _environment;
private static _serviceName;
private static _serviceVersion;
private static _domainName;
private static crypter;
private static _environmentMode;
private static _manifest;
private static _mocksManager;
static defaultDomainName: string;
/**
* Get the application manifest when the application runs in developement mode
*
* @readonly
* @static
*
* @memberOf System
*/
static readonly manifest: VulcainManifest;
/**
* UTC date as string.
*
* @static
* @returns
*
* @memberOf System
*/
static nowAsString(): string;
/**
* Calculate a diff with a date from now in seconds using moment
*
* @static
* @param {string} date in utc string format
* @returns
*
* @memberOf System
*/
static diffFromNow(date: string): number;
/**
* Acces to logger
*
* @static
*
* @memberOf System
*/
static readonly log: VulcainLogger;
/**
* Default tenant
*
* @readonly
* @static
*
* @memberOf System
*/
static readonly defaultTenant: any;
static readonly hasMocks: boolean;
static readonly mocks: MockManager;
/**
* Read configurations from .vulcain file
* Set env type from environment variable then .vulcain config
*
* @private
*/
private static readEnvironmentContext();
/**
* Check if the service is running in local mode (on developper desktop)
* by checking if a '.vulcain' file exists in the working directory
*
* @readonly
* @static
*
* @memberOf System
*/
static readonly isDevelopment: boolean;
/**
* Check if the current service is running in a test environnement (VULCAIN_TEST=true)
*
* @static
* @returns
*
* @memberOf System
*/
static readonly isTestEnvironnment: boolean;
/**
* Resolve un alias (configuration key shared/$alternates/name-version)
*
* @param {string} name
* @param {string} [version]
* @returns null if no alias exists
*
* @memberOf System
*/
static resolveAlias(name: string, version?: string): string;
/**
* Create container endpoint from service name and version
*
* @readonly
* @static
*/
static createContainerEndpoint(serviceName: string, version: string): string;
/**
* Get current environment
*
* @readonly
* @static
*
* @memberOf System
*/
static readonly environment: string;
/**
* Get vulcain server used for getting configurations
*
* @readonly
* @static
*
* @memberOf System
*/
static readonly vulcainServer: string;
/**
* Get token for getting properties (must have configurations:read scope)
*
* @readonly
* @static
*
* @memberOf System
*/
static readonly vulcainToken: string;
/**
* Get service name
*
* @readonly
* @static
*
* @memberOf System
*/
static readonly serviceName: string;
/**
* Get service version
*
* @readonly
* @static
*
* @memberOf System
*/
static readonly serviceVersion: string;
/**
* Get current domain name
*
* @readonly
* @static
*
* @memberOf System
*/
static readonly domainName: string;
private static readonly crypto;
/**
* Encrypt a value
*
* @static
* @param {any} value
* @returns {string}
*
* @memberOf System
*/
static encrypt(value: any): string;
/**
* Decrypt a value
*
* @static
* @param {string} value
* @returns
*
* @memberOf System
*/
static decrypt(value: string): string;
/**
* create a shared property
* @param name
* @param defaultValue
* @returns {IDynamicProperty<T>}
*/
static createSharedConfigurationProperty<T>(name: string, defaultValue?: T): IDynamicProperty<T>;
/**
* create a new chained property for the current service. Properties chain is: service.version.name->service.name->team.namespace->name
* @param name property name
* @param defaultValue
* @returns {IDynamicProperty<T>}
*/
static createServiceConfigurationProperty<T>(name: string, defaultValue?: T): IDynamicProperty<T>;
/**
* create an url from segments
* Segments of type string are concatened to provide the path
* Segments of type object are appending in the query string
* Null segments are ignored.
* @protected
* @param {string} base url
* @param {(...Array<string|any>)} urlSegments
* @returns an url
*/
static createUrl(baseurl: string, ...urlSegments: Array<string | any>): string;
static removePasswordFromUrl(url: string): string;
}