/workspace/getLayer

The getLayer module exports the getLayer method which is required by the query and workspace modules.

Requires

Methods

(async, inner) getLayer(params, localeopt) → {Promise.<(Object|Error)>}

A layer will primarily be requested from a locale.

The getLocale method will err if the requesting user does not have access to the locale.

If a layer is not part of a locale an attempt to get the layer directly from the workspace templates will be made.

The locale object can be provided as an additional param. The getLocale method of the workspace API may request any layer in the locale after the locale has already been retrieved. This will prevent a loopback to the locale for every layer in the locale.

The mergeTemplate module will be called to merge templates into the locale object and substitute SRC_* xyzEnvironment variables.

A role check is performed to check whether the requesting user has access to the layer object.

Role objects in the layer are merged with their respective parent objects.

The layer.key and layer.name will be assigned if missing.

The layer.dbs will be assigned from the locale is missing.

Template properties will be removed as these are not required by the MAPP API but only for the composition of workspace objects.

Parameters:
NameTypeAttributesDescription
paramsObject
localelocale<optional>

An optional workspace locale can be provided to prevent a roundtrip to the getLocale method.

Properties
NameTypeAttributesDescription
params.localestring<optional>

Locale key.

params.layerstring<optional>

Layer key.

params.userObject<optional>

Requesting user.

user.rolesArray<optional>

User roles.

Returns:

JSON Layer.

Type: 
Promise.<(Object|Error)>