/workspace
The Workspace API module exports the getKeyMethod() which returns a method from the keyMethods{} object.
- Source
Requires
- module:/workspace/cache
- module:/workspace/getLocale
- module:/workspace/getLayer
- module:/workspace/getTemplate
- module:crypto
Methods
(inner) assignChecksum(obj)
The method assigns a checksum to an object.
| Name | Type | Description |
|---|---|---|
obj | object | Object for the checksum |
- Source
(inner) compose(req, res)
The compose method returns a fully composed workspace object with all templates, locales, and layers resolved.
| Name | Type | Description |
|---|---|---|
req | req | HTTP request. |
res | res | HTTP response. |
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
req.params | Object | HTTP request params. | ||||||
params.user | Object | User requesting the compose method. Properties
|
- Source
(async, inner) composeWorkspace() → {Promise.<Object>}
The composeWorkspace method returns a fully composed workspace object with all templates, locales, and layers resolved.
The workspaceCache() is called to retrieve the cached workspace. The cacheSources() method is called to ensure that all sources are cached and any errors are logged.
The nestedLocales() method is called for each locale in the cached workspace to ensure that all nested locales are loaded and checked for user access.
- Source
The fully composed workspace object.
- Type:
- Promise.<Object>
(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 | req | HTTP request. |
res | res | HTTP response. |
| Name | Type | Description |
|---|---|---|
req.params | Object | HTTP request params. |
params.key | string | Workspace API method requested. |
- Source
(async, inner) getNestedLocales(req, res)
The getNestedLocales is returned if the locales method is called with a locale property.
The locale will be requested from the getLocale module. An array of nested locales defined in the locales property of the locale is checked for user access.
Nested locales accessible to the user are returned. The key for a nested locale is an array left to right. For [UK,London] the London locale will be nested in the UK locale. The name for a nested locale will be concatenated like so UK/London.
| Name | Type | Description |
|---|---|---|
req | req | HTTP request. |
res | res | HTTP response. |
| Name | Type | Attributes | Description |
|---|---|---|---|
req.params | Object | HTTP request params. | |
params.locale | string | Request nested locales for the locale. | |
params.user | Object | <optional> | User requesting the locales. |
- Source
(async, inner) layer(req, res) → {res}
The method requests a JSON layer from the getLayer module.
The layer is checked for user role access and will return an error if access is denied.
All role information is removed from the layer before being returned to the client.
| Name | Type | Description |
|---|---|---|
req | req | HTTP request. |
res | res | HTTP response. |
| Name | Type | Attributes | Description |
|---|---|---|---|
req.params | Object | HTTP request params. | |
params.locale | string | <optional> | Locale key. |
params.layer | string | Layer key. | |
params.user | Object | <optional> | User requesting the layer. |
- Source
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.
The getLocale method will load all layers in the locale and check for user role access with the boolean layers property in the request params.
| Name | Type | Description |
|---|---|---|
req | req | HTTP request. |
res | res | HTTP response. |
| 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. |
- Source
The HTTP response with either an error.message or the JSON locale.
- Type:
- res
(async, inner) locales(req, res)
The locales method returns an array of fully resolved locale objects from the workspace.
Each locale is retrieved via the getLocale method, which merges templates and applies proper role-based access control. Any locales that return errors (e.g., due to access restrictions) are filtered out of the response.
The nestedLocales method will be returned if a locale property is provided in the request params.
| Name | Type | Description |
|---|---|---|
req | req | HTTP request. |
res | res | HTTP response. |
| Name | Type | Attributes | Description |
|---|---|---|---|
req.params | Object | HTTP request params. | |
params.locale | string | <optional> | Request nested locales for the locale. |
params.user | Object | <optional> | User requesting the locales. |
- Source
(async, inner) nestedLocales(locale, user)
The nestedLocales method iterates the locale.locales array property and requests each nested locale from the getLocale method.
The nestedLocales method is called recursively to check for further nested locales.
| Name | Type | Description |
|---|---|---|
locale | Object | The locale object. |
user | Object | The user requesting the nested locales. |
| Name | Type | Attributes | Description |
|---|---|---|---|
locale.locales | Array | <optional> | An array of nested locale keys. |
- Source
(inner) parseWarnings(warnings, obj)
The parseWarnings method recursively iterates an object and collects any warn[] arrays into a single warnings array.
| Name | Type | Description |
|---|---|---|
warnings | Array | The array to collect warnings. |
obj | Object | The object to iterate for warn[] arrays. |
- Source
(inner) roles(req, res)
The roles method is deprecated. Use the scopes method instead.
| Name | Type | Description |
|---|---|---|
req | req | HTTP request. |
res | res | HTTP response. |
- Source
(async, inner) scopes(req, res)
The scopes method returns an array of scopes which are the templateScopes assigned to each template in the workspace.templates{} object.
| Name | Type | Description |
|---|---|---|
req | req | HTTP request. |
res | res | HTTP response. |
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
req.params | Object | HTTP request parameter. | ||||||
params.user | Object | User requesting the scopes. Properties
|
- Source
(inner) test(req, res)
The test method is an admin-only endpoint that checks the workspace sources for errors and warnings.
| Name | Type | Description |
|---|---|---|
req | req | HTTP request. |
res | req | HTTP response. |
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
req.params | Object | HTTP request params. | ||||||
params.user | Object | User requesting the test method. Properties
|
- Source