/workspace/cache

The module exports the default checkWorkspaceCache method which returns the async cacheWorkspace method which resolves into a JSON workspace.

Default templates can be overwritten in the workspace or by providing a CUSTOM_TEMPLATES xyzEnvironment variable which references a JSON with templates to be merged into the workspace.

Requires

Methods

(inner) assign_workspace_templates(workspace_templates, templates_object, typeopt) → {Object}

The method assigns objects in a templates object to the workspace.templates provided as workspace_templates param.

Parameters:
NameTypeAttributesDefaultDescription
workspace_templatesobject

The workspace.templates object.

templates_objectObject

An object of templates to be assigned with the template key to the workspace templates.

typestring<optional>
'core'

The type value to assign to the template to identify the origin.

Returns:

templates_object with _core: true property.

Type: 
Object

(async, inner) cacheWorkspace() → {Promise.<workspace>}

The workspace is retrived from the source defined in the WORKSPACE xyzEnvironment variable.

Templates defined in the CUSTOM_TEMPLATES xyzEnvironment variable are spread into the default workspace.templates{}.

Each locale from the workspace.locale{} is merged into the workspace.locale{} template.

Locale objects get their key and name properties assigned if falsy.

The workspace is assigned to the module scope workspacePromise variable and the timestamp is recorded.

Returns:

Resolves to the JSON workspace.

Type: 
Promise.<workspace>

(inner) checkWorkspaceCache(forceopt) → {Promise.<workspace>}

The async cacheWorkspace method is assigned to the module scope workspacePromise variable. The variable is re-assigned if the WORKSPACE_AGE xyzEnvironment variable is exceeded or the force param is true.

Parameters:
NameTypeAttributesDescription
forceboolean<optional>

The workspace cache will be cleared with the force param flag.

Returns:

Resolves to the JSON workspace.

Type: 
Promise.<workspace>