/workspace
The Workspace API module exports the getKeyMethod() which returns a method from the keyMethods{} object.
- layer
- locale
- locales
- roles
The workspace typedef object has templates, locale, locales, dbs, and roles properties. The workspace will be cached in the process by the workspace/cache module.
Requires
Methods
(async, inner) getKeyMethod(req, res)
The cached workspace requested from the workspaceCache() will be assigned to the workspace variable declared in the module scope.
The method checks whether the req.params.key matches a keyMethods property and returns the matching method.
Name | Type | Description |
---|---|---|
req.params | Object | HTTP request params. |
params.key | string | Workspace API method requested. |
(async, inner) layer(req, res) → {res}
The method requests a JSON layer from the getLayer module.
Name | Type | Attributes | Description |
---|---|---|---|
req.params | Object | HTTP request params. | |
params.locale | string | <optional> | Locale key. |
params.layer | boolean | <optional> | Layer key. |
params.user | Object | <optional> | User requesting the layer. |
The HTTP response with either an error.message or the JSON layer.
- Type:
- res
(async, inner) locale(req, res) → {res}
The method requests a JSON locale from the getLocale module.
All locale layers are requested from the getLayer module with params.layers
flag.
The locale.layers{} object is reduced to an array of layer keys without the params.layers
flag.
Name | Type | Attributes | Description |
---|---|---|---|
req.params | Object | HTTP request params. | |
params.locale | string | <optional> | Locale key. |
params.layers | boolean | <optional> | Whether layer objects should be returned with the locale. |
params.user | Object | <optional> | User requesting the locale. |
The HTTP response with either an error.message or the JSON locale.
- Type:
- res
(inner) locales(req, res) → {res}
The locales method reduces the workspace.locales{} object to an array locales with only the key and name properties.
The locales are not merged with templates and only roles defined inside the workspace.locales{} locale object are considered for access.
Name | Type | Attributes | Description |
---|---|---|---|
req.params | Object | HTTP request params. | |
params.user | Object | <optional> | User requesting the locales. |
The HTTP response with either an error.message or JSON array of locales in workspace.
- Type:
- res
(inner) removeRoles(obj) → {object}
Recursively removes all 'roles' objects from the provided object [locale, layer]. This function is designed to sanitize locale configuration objects before sending to the client, ensuring that role-based permissions data is not exposed.
Name | Type | Description |
---|---|---|
obj | object | A locale or layer JSON object. |
- Type:
- object
(inner) roles(req, res) → {Array|Object}
The roles method returns an array of roles returned from the roles utility.
An object with detailed workspace.roles{} can be requested with the detail=true
url parameter for the workspace/roles request.
Name | Type | Description |
---|---|---|
req.params | Object | HTTP request parameter. |
params.detail | Boolean | Whether the roles should be returned as an object with details. |
Returns either an array of roles as string, or an object with roles as properties.
- Type:
- Array |
Object
(inner) templateUse(obj, test)
Iterates through all nested object properties. Test properties found in the test.properties Set. Removes template keys from test.unused_templates Set. Add template keys to test.used_templates Array.
Name | Type | Description |
---|---|---|
obj | Object | The object to test. |
test | Object | The test config object. |
Name | Type | Description |
---|---|---|
test.properties | Set | Set of properties to test ['template', 'templates', 'query'] |
test.workspace_templates | Set | Set of templates _type=workspace templates. |
test.unused_templates | Set | Set of templates not (yet) used. |
test.overwritten_templates | Set | Set of _type=workspace templates which have been overwritten. |
test.used_templates | Array | Array of template keys for each usage. |
(inner) test(req, res)
The workspace/test method which is only available to user with admin credentials requests all locales in workspace.
The cached workspace will be flushed for the test method.
Requesting all locales should add any additional templates to the workspace.
The test method will iterate over all workspace.templates and get from the getTemplate method to check whether any errors are logged on a template in regards to its src parameter.
A flat array of template.err will be returned from the workspace/test method.
Name | Type | Description |
---|---|---|
req.params | Object | HTTP request parameter. |
params.user | Object | The user requesting the test method. |
user.admin | Boolean | The user is required to have admin priviliges. |