Namespace: clbStorage¶
Member Of Module: clb-storage
Description¶
The clbStorage service provides utility functions to ease the interaction
of apps with storage.
Function: getEntity¶
Get an entity (e.g.: a project, a file or a folder) using a locator. The only accepted locator at this time is the entity UUID.
- the entity UUID
- an entity representation with
{_uuid: ENTITY_UUID} - the entity related context
{ctx: CONTEXT_UUID} - the entity collab ID
{collab: COLLAB_ID} - the entity absolute path
-
getEntity(locator)¶ Arguments: - locator (any) – Describe the entity to retrieve (see description).
Return Promise: Return a
module-clb-storage.EntityDescriptorwhen fulfilled or reject a Class: ClbError
Function: getAbsolutePath¶
Return the absolute path of the entity
-
getAbsolutePath(entity)¶ Arguments: - entity (object|UUID) – UUID or descriptor
Return Promise: return a path string when fulfilled.
Function: runOnce¶
Ensure there is only one async fn run named k at once. subsequent call to runOnce with the same k value will return the promise of the running async function.
-
runOnce(k, fn)¶ Arguments: - k (string) – The key
- fn (function) – The function that retrieve a Promise
Return Promise: Resolve to the function result
Function: getEntityByUUID¶
-
getEntityByUUID(uuid)¶ Arguments: - uuid (string) – Entity UUID
Return Promise: Resolve to the entity Descriptor
Function: query¶
Query entities by attributes or metadata.
-
query(params)¶ Arguments: - params (object) – Query Parameters
Return Promise: Return the results
Function: metadataKey¶
Retrieve the key to lookup for on entities given the ctx
-
metadataKey(ctx)¶ Arguments: - ctx (string) – application context UUID
Return string: name of the entity attribute that should be used
Function: addMetadata¶
Add metadata to the provided entity and returns a promise that resolves to an object containing all the new metadata. The promise fails if one of the metadata already exists.
-
addMetadata(entity, metadata)¶ Arguments: - entity (object) – Entity Descriptor
- metadata (object) – key/value store where keys are the metadata name to set
Return Promise: Resolves after the operation is completed
Function: deleteMetadata¶
Delete metadata keys in input from the provided entity and returns a promise that resolves to an object containing all the remaining metadata. The promise fails if one of the metadata doesn’t exist.
-
deleteMetadata(entity, metadataKeys)¶ Arguments: - entity (object) – Entity Descriptor
- metadataKeys (array) – Array of metatdata keys to delete
Return Promise: Resolve to the metadata
Function: create¶
Create a new entity.
-
create(type, parent, name, options)¶ Arguments: - type (string) – Entity Type (e.g.: file, folder, project)
- parent (string|object) – Parent UUID or entity descriptor
- name (string) – File name
- options (object) – Extend the entity descriptor with those data
Return Promise: Resolve once done
Function: copy¶
Copy a file to a destination folder
-
copy(srcId, destFolderId)¶ Arguments: - srcId (string) – UUID of the entity to copy
- destFolderId (string) – UUID of the target directory
Return Promise: Resolves when done
Function: getContent¶
Retrieves the content of a file given its id.
-
getContent(id[, customConfig])¶ Arguments: - id (string) – FileEntity UUID
- customConfig (object) – contains extra configuration
Return Promise: The raw content
Function: getUserAccess¶
Get current user access right to the provided entity.
The returned promise will be resolved with an object literal containing three boolean flags corresponding the user access:
- canRead
- canWrite
- canManage
-
getUserAccess(entity)¶ :param module:clb-storage.EntityDescriptor entity: The entity to retrieve user access for :return object: Contains
{boolean} canRead,{boolean} canWrite,{boolean} canManage
Function: getChildren¶
Retrieve children entities of a ‘parent’ entity according to the options and add them to the children list. The returned promise will be resolved with the list of fetched children and a flag indicating if more results are available in the queried direction.
-
getChildren(parent[, options][, options.accept][, options.acceptLink][, options.sort][, options.filter][, options.until][, options.from][, options.pageSize])¶ :param module:clb-storage.EntityDescriptor parent: The parent entity :param object options: Options to make the query :param array/string options.accept: Array of accepted _entityType :param boolean|array/string options.acceptLink:
trueor an array of accepted linked _entityType :param string options.sort: Property to sort on :param string options.filter: The result based on Acls. Values:read(default),write:param UUID options.until: Fetch results until the given id (exclusive with from) :param UUID options.from: Fetch results from the given id (exclusive with until) :param int options.pageSize: The number of results per page. Default is provided by the service. Set to 0 to fetch all the records. :return Promise: When fulfilled, return a paginated result set. You can also access it immediately usingpromise.instance
Function: upload¶
Create file entity and upload the content of the given file.
options should contain a parent key containing the parent entity.
Possible error causes:
- FileTooBig
- UploadError - generic error for content upload requests
- EntityCreationError - generic error for entity creation requests
- FileAlreadyExistError
-
upload(file, options)¶ Arguments: - file (File) – The file descriptor to upload
- options (Object) – The list of options
Return Promise: a Promise that notify about progress and resolve with the new entity object.
Function: downloadUrl¶
Asynchronously ask for a short-lived (a few seconds), presigned URL that can be used to access and download a file without authentication headers.
-
downloadUrl(entity)¶ :param module:clb-storage.EntityDescriptor entity: The file to download :return Promise: Return a string containing the URL once the Promise
is fulfilled.
Member: setContextMetadata: the function links the contextId with the doc browser entity in input
by setting a specific metadata on the entity.
Entity object in input must contain the following properties: - _entityType - _uuid
In case of error, the promise is rejected with a HbpError instance.
Member: deleteContextMetadata: the function unlink the contextId from the entity in input
by deleting the context metadata.
Entity object in input must contain the following properties: - _entityType - _uuid
In case of error, the promise is rejected with a HbpError instance.
Member: updateContextMetadata: the function delete the contextId from the oldEntity metadata and add
it as newEntity metadata.
Entity objects in input must contain the following properties: - _entityType - _uuid
In case of error, the promise is rejected with a HbpError instance.