Reference Source
public class | source

Context

Runtime context methods (browser/server, locales, i18n).

Example:

	API:
		->constructor(arg_runtime):nothing - constructor.

 PATHS API:
		->get_base_dir():string - Get project base directory, the root directory of the project.
		->get_world_dir():string - Get topology  world resources directory, by default: the root directory of the project.

		->get_absolute_path(arg_relative_path1, arg_relative_path2, arg_relative_path3):string - Get absolute path of given relative path.
				Search strategy:
				1-Joining given ordered paths
				2-Joining base directory and given ordered paths
				3-Joining world resources directory and given ordered paths

		->get_absolute_plugin_path(arg_relative_plugin, arg_relative_path1, arg_relative_path2):string - Get absolute path of given relative plugin name.
				Call get_absolute_path(arg_relative_plugin, arg_relative_path1, arg_relative_path2)

		->get_absolute_package_path(arg_relative_pkg, arg_relative_path1, arg_relative_path2):string - Get absolute path of given relative package name.
				Call get_absolute_path(arg_relative_pkg, arg_relative_path1, arg_relative_path2)
				Call get_absolute_path( path.join('../../../node_modules', arg_relative_pkg), arg_relative_path1, arg_relative_path2)
				Call get_absolute_path( path.join('../../node_modules', arg_relative_pkg), arg_relative_path1, arg_relative_path2)
				Call get_absolute_path( path.join('../node_modules', arg_relative_pkg), arg_relative_path1, arg_relative_path2)
				Call get_absolute_path( path.join('node_modules', arg_relative_pkg), arg_relative_path1, arg_relative_path2)

		->get_absolute_public_path(arg_relative_public, arg_relative_path1, arg_relative_path2):string - Get absolute path of given relative public path.
				Call get_absolute_path(arg_relative_public, arg_relative_path1, arg_relative_path2)
				If not found, search with prefixes [base_public, world_public, 'public', '..', '../public', '../..', '../../public', '../../..', '../../../public']
				Call get_absolute_path( join(prefix, arg_relative_public), arg_relative_path1, arg_relative_path2)

		->get_absolute_resources_path(arg_relative_resource, arg_relative_path1, arg_relative_path2):string - Get absolute path of given relative resource file.
				Call get_absolute_path( path.join('resources', arg_relative_resource), arg_relative_path1, arg_relative_path2)

	CREDENTIALS API:
		->get_credentials(arg_request):object - Get credentials.
		->get_credentials_string(arg_credentials):string - Get credentials string as 'username=...&password=...&token=...'.
		->get_url_with_credentials(arg_url, arg_request):string - Get given url augmented with credentials string.

		->render_credentials_template(arg_html, arg_request_or_credentials):string - Render credentials template.
				Call  mustache.render(arg_html, credentials_datas)
				with const credentials_datas = credentials_obj.get_credentials_for_template()
					credentials_datas.credentials_str = credentials_str
					credentials_datas.credentials_url = credentials_url
					credentials_datas.credentials_basic_base64 = base64_encoded
					credentials_datas.url = '{{url}}'

Constructor Summary

Public Constructor
public

constructor(arg_runtime: object): nothing

Create a context instance.

Member Summary

Public Members
public

$runtime: Runtime

Runtime instance.

public

Class type flag.

Method Summary

Public Methods
public

get_absolute_package_path(arg_relative_pkg: string, arg_relative_path1: string, arg_relative_path2: string): string

Get absolute path of given relative package name.

public

get_absolute_path(arg_relative_path1: string, arg_relative_path2: string, arg_relative_path3: string): string

Get absolute path of given relative path.

public

get_absolute_plugin_path(arg_relative_plugin: string, arg_relative_path1: string, arg_relative_path2: string): string

Get absolute path of given relative plugin name.

public

get_absolute_public_path(arg_relative_public: string, arg_relative_path1: string, arg_relative_path2: string): string

Get absolute path of given relative public path.

public

get_absolute_resources_path(arg_relative_resource: string, arg_relative_path1: string, arg_relative_path2: string): string

Get absolute path of given relative resource file.

public

Get project base directory, the root directory of the project.

public

get_credentials(arg_request: object): object

Get credentials.

public

get_credentials_string(arg_credentials: object): string

Get credentials string.

public

get_url_with_credentials(arg_url: string, arg_request_or_credentials: object | Credentials): string

Get given url augmented with credentials string.

public

Get topology world resources directory, by default: the root directory of the project.

public

render_credentials_template(arg_html: string, arg_request_or_credentials: Request | Credentials): string

Render credentials template.

Public Constructors

public constructor(arg_runtime: object): nothing source

Create a context instance.

Params:

NameTypeAttributeDescription
arg_runtime object

current runtime.

Return:

nothing

Public Members

public $runtime: Runtime source

Runtime instance.

public is_context: boolean source

Class type flag.

Public Methods

public get_absolute_package_path(arg_relative_pkg: string, arg_relative_path1: string, arg_relative_path2: string): string source

Get absolute path of given relative package name.

Params:

NameTypeAttributeDescription
arg_relative_pkg string

package name.

arg_relative_path1 string

relative path 1.

arg_relative_path2 string

relative path 2.

Return:

string

absolute path.

public get_absolute_path(arg_relative_path1: string, arg_relative_path2: string, arg_relative_path3: string): string source

Get absolute path of given relative path.

Params:

NameTypeAttributeDescription
arg_relative_path1 string

relative path 1.

arg_relative_path2 string

relative path 2.

arg_relative_path3 string

relative path 3.

Return:

string

absolute path.

public get_absolute_plugin_path(arg_relative_plugin: string, arg_relative_path1: string, arg_relative_path2: string): string source

Get absolute path of given relative plugin name.

Params:

NameTypeAttributeDescription
arg_relative_plugin string

plugin name.

arg_relative_path1 string

relative path 1.

arg_relative_path2 string

relative path 2.

Return:

string

absolute path.

public get_absolute_public_path(arg_relative_public: string, arg_relative_path1: string, arg_relative_path2: string): string source

Get absolute path of given relative public path.

Params:

NameTypeAttributeDescription
arg_relative_public string

public path.

arg_relative_path1 string

relative path 1.

arg_relative_path2 string

relative path 2.

Return:

string

absolute path.

public get_absolute_resources_path(arg_relative_resource: string, arg_relative_path1: string, arg_relative_path2: string): string source

Get absolute path of given relative resource file.

Params:

NameTypeAttributeDescription
arg_relative_resource string

resource file name.

arg_relative_path1 string

relative path 1.

arg_relative_path2 string

relative path 2.

Return:

string

absolute path.

public get_base_dir(): string source

Get project base directory, the root directory of the project.

Return:

string

absolute root directory path.

public get_credentials(arg_request: object): object source

Get credentials.

Params:

NameTypeAttributeDescription
arg_request object

request object.

Return:

object

credentials plain object.

public get_credentials_string(arg_credentials: object): string source

Get credentials string.

Params:

NameTypeAttributeDescription
arg_credentials object

Credetials object.

Return:

string

credentials string.

public get_url_with_credentials(arg_url: string, arg_request_or_credentials: object | Credentials): string source

Get given url augmented with credentials string.

Params:

NameTypeAttributeDescription
arg_url string

image asset relative url.

arg_request_or_credentials object | Credentials

request object or Credentials instance.

Return:

string

absolute url.

public get_world_dir(): string source

Get topology world resources directory, by default: the root directory of the project.

Return:

string

absolute root directory path.

public render_credentials_template(arg_html: string, arg_request_or_credentials: Request | Credentials): string source

Render credentials template.

Params:

NameTypeAttributeDescription
arg_html string

template html string.

arg_request_or_credentials Request | Credentials

request object.

Return:

string

rendered template.