Home Reference Source Repository
import ProjectCollection from 'schema-mapper-project-collection'
public class | source

ProjectCollection

ProjectCollection for manipulating and syncyng projects with ease

Constructor Summary

Public Constructor
public

constructor(allProjects: Object, differ: Differ)

Create a new ProjectCollection instance.

Member Summary

Public Members
public

All projects

public

All projects with resolved extend's

public

Differ

Method Summary

Public Methods
public

changeColumnType(projectId: String, schemaId: String, columnId: String, type: String)

Change type of a column

public

extendProject(projectId: String, extend: String)

Extend from another project

public

extendSchema(projectId: String, schemaId: String, extend: String)

Extend from another schema

public

Retrieve all projects

public

Retrieve all resolved projects

public

Group changes by their projectId

public

Get the current project (highest version) minimum version being 1

public

Retrieve a unique array of projectId's, extracted from staging changes

public

Retrieve a unique array of projects that have staging changes

public

Get a unique array of projectId's, extracted from changes

public

Get version of a project

public

Same as getCurrentProjects but extend's are resolved.

public

Same as getStagingProjects but extend's are resolved.

public

Retrieve staging changes

public

Retrieve staging changes grouped by their projectId

public

Get the staging project (version 0) for every project

public

Retrieve project versions of all projects

public

putColumn(projectId: String, schemaId: String, columnId: String, column: Column)

Create or update a column

public

putProject(projectId: String, project: Project)

Create or update a project

public

putSchema(projectId: String, schemaId: String, schema: Schema)

Create or update a schema

public

Remove all projects

public

removeColumn(projectId: String, schemaId: String, columnId: String)

Remove a column

public

removeProject(projectId: String)

Remove a project

public

removeSchema(projectId: String, schemaId: String)

Remove a schema

public

renameColumn(projectId: String, schemaId: String, columnId: String, name: String)

Rename a column

public

renameProject(projectId: String, name: String)

Rename a project

public

renameSchema(projectId: String, schemaId: String, name: String)

Rename a schema

public

Get all projects with resolved extends

public

Resolve extends in a project

public

stageChange(change: Change)

Stage change

public

stageChanges(changes: Changes)

Stage changes

public

tagProject(projectId: String, version: Number)

Tag a project

Protected Methods
protected

applyChange(change: Change)

Apply change

protected

applyChanges(changes: Changes)

Apply changes

protected

applyTagProject(projectId: String)

Apply tag project change

protected

Retrieve staging changes by comparing the projects with extend's resolved This produces more detailed changes that are used by storage drivers

Public Constructors

public constructor(allProjects: Object, differ: Differ) source

Create a new ProjectCollection instance.

Params:

NameTypeAttributeDescription
allProjects Object

An object containing all projects

differ Differ

schema-mapper-differ instance

Public Members

public allProjects: Object source

All projects

public allResolvedProjects: Object source

All projects with resolved extend's

public differ: Differ source

Differ

Public Methods

public changeColumnType(projectId: String, schemaId: String, columnId: String, type: String) source

Change type of a column

Params:

NameTypeAttributeDescription
projectId String

Project id

schemaId String

Schema id

columnId String

Column id

type String

New type for column

public extendProject(projectId: String, extend: String) source

Extend from another project

Params:

NameTypeAttributeDescription
projectId String

Project id

extend String

String indicating from what project (and version) to extend from, in this form: 'projectId:projectVersion'

public extendSchema(projectId: String, schemaId: String, extend: String) source

Extend from another schema

Params:

NameTypeAttributeDescription
projectId String

Project id

schemaId String

Schema id

extend String

String indicating what schema to extend from in this form: 'projectId:projectVersion:schemaId'

public getAllProjects(): Object source

Retrieve all projects

Return:

Object

An object containing all projects

public getAllResolvedProjects(): Object source

Retrieve all resolved projects

Return:

Object

An object containing all projects with the 'extend's already resolved

public getChangesPerProject(changes: Changes): Object source

Group changes by their projectId

Params:

NameTypeAttributeDescription
changes Changes

The changes to group

Return:

Object

Grouped changes (key being the projectId)

public getCurrentProjects(): Projects source

Get the current project (highest version) minimum version being 1

Return:

Projects

Projects at highest version (excluding projects that are only staging)

public getDirtyStagingProjectIds(): Array source

Retrieve a unique array of projectId's, extracted from staging changes

Return:

Array

Project id's

public getDirtyStagingProjects(): Array source

Retrieve a unique array of projects that have staging changes

Return:

Array

Project id's

public getProjectIdsFromChanges(changes: Changes): Array source

Get a unique array of projectId's, extracted from changes

Params:

NameTypeAttributeDescription
changes Changes

Changes

Return:

Array

Project id's

public getProjectVersion(projectId: String): Number source

Get version of a project

Params:

NameTypeAttributeDescription
projectId String

Project id

Return:

Number

Project version

public getResolvedCurrentProjects(): Projects source

Same as getCurrentProjects but extend's are resolved.

Return:

Projects

public getResolvedStagingProjects(): Projects source

Same as getStagingProjects but extend's are resolved.

Return:

Projects

public getStagingChanges(): Changes source

Retrieve staging changes

Return:

Changes

Staged changes

public getStagingChangesPerProject(): Object source

Retrieve staging changes grouped by their projectId

Return:

Object

Grouped staging changes (key being the projectId)

public getStagingProjects(): Projects source

Get the staging project (version 0) for every project

Return:

Projects

Projects at staging version

public getVersions(): Object source

Retrieve project versions of all projects

Return:

Object

An object where the key is the projectId and the value is the project's version

public putColumn(projectId: String, schemaId: String, columnId: String, column: Column) source

Create or update a column

Params:

NameTypeAttributeDescription
projectId String

Project id

schemaId String

Schema id

columnId String

Column id

column Column

Column

public putProject(projectId: String, project: Project) source

Create or update a project

Params:

NameTypeAttributeDescription
projectId String

Project id

project Project

The project

public putSchema(projectId: String, schemaId: String, schema: Schema) source

Create or update a schema

Params:

NameTypeAttributeDescription
projectId String

Project id

schemaId String

Schema id

schema Schema

Schema

public removeAllProjects() source

Remove all projects

public removeColumn(projectId: String, schemaId: String, columnId: String) source

Remove a column

Params:

NameTypeAttributeDescription
projectId String

Project id

schemaId String

Schema id

columnId String

Column id

public removeProject(projectId: String) source

Remove a project

Params:

NameTypeAttributeDescription
projectId String

Project id

public removeSchema(projectId: String, schemaId: String) source

Remove a schema

Params:

NameTypeAttributeDescription
projectId String

Project id

schemaId String

Schema id

public renameColumn(projectId: String, schemaId: String, columnId: String, name: String) source

Rename a column

Params:

NameTypeAttributeDescription
projectId String

Project id

schemaId String

Schema id

columnId String

Column id

name String

New name for column

public renameProject(projectId: String, name: String) source

Rename a project

Params:

NameTypeAttributeDescription
projectId String

Project id

name String

New project name

public renameSchema(projectId: String, schemaId: String, name: String) source

Rename a schema

Params:

NameTypeAttributeDescription
projectId String

Project id

schemaId String

Schema id

name String

New name for schema

public resolveAllProjects(): Object source

Get all projects with resolved extends

Return:

Object

Object containing all resolved projects (key is projectId)

public resolveProject(project: Project): Project source

Resolve extends in a project

Params:

NameTypeAttributeDescription
project Project

Return:

Project

The resolved project

public stageChange(change: Change) source

Stage change

Params:

NameTypeAttributeDescription
change Change

The change to stage

public stageChanges(changes: Changes) source

Stage changes

Params:

NameTypeAttributeDescription
changes Changes

The changes to stage

public tagProject(projectId: String, version: Number) source

Tag a project

Params:

NameTypeAttributeDescription
projectId String

Project id

version Number

New version for the project

Protected Methods

protected applyChange(change: Change) source

Apply change

Params:

NameTypeAttributeDescription
change Change

The change to apply

protected applyChanges(changes: Changes) source

Apply changes

Params:

NameTypeAttributeDescription
changes Changes

The changes to apply

protected applyTagProject(projectId: String) source

Apply tag project change

Params:

NameTypeAttributeDescription
projectId String

Project id

protected getResolvedStagingChanges(): Changes source

Retrieve staging changes by comparing the projects with extend's resolved This produces more detailed changes that are used by storage drivers

Return:

Changes

Staged changes that have resolved extend's