Class: SafeStorage

Server:SafeStorage~SafeStorage(database, logger, gmeConfig, gmeAuth)

new SafeStorage(database, logger, gmeConfig, gmeAuth)

Parameters:
Name Type Description
database
logger
gmeConfig
gmeAuth
Source:

Methods

_getProject(data, callback) → {*}

Authorization: read access

Parameters:
Name Type Description
data
callback
Source:
Returns:
Type
*

createBranch(data, callback) → {*}

Authorization: write access for data.projectId

Parameters:
Name Type Description
data
callback
Source:
Returns:
Type
*

createProject(data, callbackopt) → {promise}

Creates a project and assigns a projectId by concatenating the username and the provided project name. The user with the given username becomes the owner of the project.

Authorization level: canCreate

Parameters:
Name Type Attributes Description
data object

input parameters

Properties
Name Type Attributes Default Description
projectName string

name of new project.

username string <optional>
gmeConfig.authentication.guestAccount
ownerId string <optional>
data.username
kind string <optional>

Category of project typically based on meta.

callback function <optional>
Source:
Returns:

//TODO: jsdocify this

Type
promise

createTag(data, callback) → {*}

Authorization: write access for data.projectId

Parameters:
Name Type Description
data
callback
Source:
Returns:
Type
*

deleteBranch(data, callback) → {*}

Authorization: write access for data.projectId

Parameters:
Name Type Description
data
callback
Source:
Returns:
Type
*

deleteProject(data, callbackopt) → {Promise}

Deletes a project from the _projects collection, deletes the collection for the the project and removes the rights from all users.

Authorization level: delete access for project

Parameters:
Name Type Attributes Description
data object

input parameters

Properties
Name Type Attributes Default Description
projectId string

identifier for project.

username string <optional>
gmeConfig.authentication.guestAccount
callback function <optional>
Source:
Returns:

//TODO: jsdocify this

Type
Promise

deleteTag(data, callback) → {*}

Authorization: delete access for data.projectId

Parameters:
Name Type Description
data
callback
Source:
Returns:
Type
*

duplicateProject(data, callbackopt) → {promise}

Duplicates a project including all data-objects, commits, branches etc.

Authorization level: canCreate and read access for project

Parameters:
Name Type Attributes Description
data object

input parameters

Properties
Name Type Attributes Default Description
projectId string

id of existing project that will be duplicated.

projectName string

name of new project.

username string <optional>
gmeConfig.authentication.guestAccount
ownerId string <optional>
data.username
callback function <optional>
Source:
Returns:

//TODO: jsdocify this

Type
promise

getBranchHash(data, callback) → {*}

Authorization: read access for data.projectId

Parameters:
Name Type Description
data
callback
Source:
Returns:
Type
*

getBranches(data, callbackopt) → {promise}

Returns a dictionary with all the branches and their hashes within a project. Example: { master: '#someHash', b1: '#someOtherHash' }

Authorization level: read access for project

Parameters:
Name Type Attributes Description
data object

input parameters

Properties
Name Type Attributes Default Description
projectId string

identifier for project.

username string <optional>
gmeConfig.authentication.guestAccount
callback function <optional>
Source:
Returns:

//TODO: jsdocify this

Type
promise

getCommits(data, callbackopt) → {promise}

Returns an array of commits for a project ordered by their timestamp.

Authorization level: read access for project

Parameters:
Name Type Attributes Description
data object

input parameters

Properties
Name Type Attributes Default Description
projectId string

identifier for project.

number number

maximum number of commits to load.

before number | string

timestamp or commitHash to load history from. When number given it will load data.number of commits strictly before data.before, when commitHash is given it will return that commit too.

username string <optional>
gmeConfig.authentication.guestAccount
callback function <optional>
Source:
Returns:

//TODO: jsdocify this

Type
promise

getCommonAncestorCommit(data, callback) → {*}

Authorization: read access for data.projectId

Parameters:
Name Type Description
data
callback
Source:
Returns:
Type
*

getHistory(data, callbackopt) → {promise}

Returns an array of commits starting from either a branch(es) or commitHash(es). They are ordered by the rules (applied in order)

  1. Descendants are always before their ancestors
  2. By their timestamp

Authorization level: read access for project

Parameters:
Name Type Attributes Description
data object

input parameters

Properties
Name Type Attributes Default Description
projectId string

identifier for project.

number number

maximum number of commits to load.

start string | Array.<string>

BranchName or commitHash, or an array of such.

username string <optional>
gmeConfig.authentication.guestAccount
callback function <optional>
Source:
Returns:

//TODO: jsdocify this

Type
promise

getLatestCommitData(data, callbackopt) → {promise}

Returns the latest commit data for a branch within the project. (This is the same data that is provided during a BRANCH_UPDATE event.)

Example: { projectId: 'guest+TestProject', branchName: 'master', commitObject: { _id: '#someCommitHash', root: '#someNodeHash', parents: ['#someOtherCommitHash'], update: ['guest'], time: 1430169614741, message: 'createChild(/1/2)', type: 'commit' }, coreObject: [{coreObj}, ..., {coreObj}], }

Authorization level: read access for project

Parameters:
Name Type Attributes Description
data object

input parameters

Properties
Name Type Attributes Default Description
projectId string

identifier for project.

branchName string

name of the branch.

username string <optional>
gmeConfig.authentication.guestAccount
callback function <optional>
Source:
Returns:

//TODO: jsdocify this

Type
promise

getProjects(data, callbackopt) → {Promise}

Returns and array of dictionaries for each project the user has at least read access to. If branches is set, the returned array will be filtered based on if the projects really do exist as collections on their own. If branches is not set, there is no guarantee that the returned projects really exist.

Authorization level: read access for each returned project.

Parameters:
Name Type Attributes Description
data object

input parameters

Properties
Name Type Attributes Default Description
info boolean <optional>

include the info field from the _projects collection.

rights boolean <optional>

include users' authorization information for each project.

branches boolean <optional>

include a dictionary with all branches and their hash.

hooks boolean <optional>

include the dictionary with all hooks.

projectId string <optional>

if given will return only single matching project.

username string <optional>
gmeConfig.authentication.guestAccount
callback function <optional>
Source:
Returns:

//TODO: jsdocify this

Type
Promise

getTags(data, callbackopt) → {*}

Returns a dictionary with all the tags and their commitHashes within a project. Example: { tag1: '#someHash', taggen: '#someOtherHash' }

Authorization level: read access for project

Parameters:
Name Type Attributes Description
data object

input parameters

Properties
Name Type Attributes Default Description
projectId string

identifier for project.

username string <optional>
gmeConfig.authentication.guestAccount
callback function <optional>
Source:
Returns:
Type
*

loadObjects(data, callback) → {*}

Authorization: TODO: read access for data.projectId

Parameters:
Name Type Description
data
callback
Source:
Returns:
Type
*

loadPaths(data, callbackopt) → {promise}

Returns a dictionary with all the hashes needed to load the containment of the input paths.

Authorization level: read access for data.projectId

Parameters:
Name Type Attributes Description
data object

input parameters.

Properties
Name Type Attributes Default Description
projectId string

identifier for project.

username string <optional>
gmeConfig.authentication.guestAccount
pathsInfo Array.<object>

list of objects with parentHash and path.

excludes Array.<string> <optional>

list of known object hashes that should not be returned.

excludeParents boolean <optional>

if true will only return the data for the node at the path.

callback function <optional>
Source:
Returns:

//TODO: jsdocify this

Type
promise

makeCommit(data, callback) → {*}

Authorization: write access for data.projectId

Parameters:
Name Type Description
data
callback
Source:
Returns:
Type
*

openProject(data, callback) → {*}

Authorization: read access

Parameters:
Name Type Description
data
callback
Source:
Returns:
Type
*

setBranchHash(data, callback) → {*}

Authorization: write access for data.projectId

Parameters:
Name Type Description
data
callback
Source:
Returns:
Type
*

squashCommits(data, callback) → {*}

Authorization: write access for data.projectId

Parameters:
Name Type Description
data object

input parameters

Properties
Name Type Attributes Default Description
projectId string

identifier for project.

fromCommit string

starting point of the squash.

toCommitOrBranch string

branch or commit where the endpoint of squash can be found.

username string <optional>
gmeConfig.authentication.guestAccount
callback
Source:
Returns:
Type
*

transferProject(data, callback) → {*}

Authorization level: canCreate and delete access for project

Parameters:
Name Type Description
data
callback
Source:
Returns:
Type
*