Home Reference Source Repository

src/typedefs.js

/**
 * A container for data that also includes information about the project and schema.
 * @typedef {Object} DataInfo
 * @property {String} projectId      The id of the project
 * @property {String} projectName    The name of the project
 * @property {Number} projectVersion The version of the project
 * @property {String} schemaId       The id of the schema
 * @property {String} schemaName     The name of the schema
 * @property {Object} item           An object containing the data
 */

/**
 * An object containing actual data, the keys are the column names and the values are depending on the column type.
 * @typedef {Object} Item
 * @property {*} value Test
 */

/**
 * A project
 * @typedef {Object} Project
 * @property {String} name
 * @property {Number} version
 * @property {Object} schemas         An object of schemas where the key is the unique id for the schema and the value is an object of type Schema
 */

/**
 * A schema describing the properties of data.
 * @typedef {Object} Schema
 * @property {String} name            The name of the schema
 * @property {String|Array} primary   The id of the column, or an array of ids that indicate as the primary key
 * @property {Object} columns         An object of columns where the key is the unique id for the column and the value is an object of type Column
 */

/**
 * A column describing a single property of data.
 * @typedef {Object} Column
 * @property {String} name The name of the column
 * @property {String} type The type of the column
 */

/**
 * A change indicating a modification to a schema or column.
 * @typedef {Object} Change
 * @property {String} projectId The id of the project that this change applies to
 * @property {String} schemaId The id of the schema that this change applies to
 * @property {String} change A string indicating the type of change,
 * this can be any of:
 *  - project.create
 *  - project.rename
 *  - project.remove
 *  - project.tag
 *  - schema.create
 *  - schema.rename
 *  - schema.remove
 *  - column.create
 *  - column.rename
 *  - column.remove
 *  - column.typechange
 */

/**
 * An array of changes containing items of type Change
 * @typedef {Array} Changes
 */

/**
 * A change indicating a project has been created
 * @typedef {Object} ProjectCreateChange
 * @property {String} projectId The id of the project that has been created
 * @property {Project} project The project that has been created
 */

/**
 * A change indicating a project has been removed
 * @typedef {Object} ProjectRemoveChange
 * @property {String} projectId The id of the project that has been removed
 * @property {Project} oldProject The project that has been removed
 */

/**
 * A change indicating a project has been renamed
 * @typedef {Object} ProjectRenameChange
 * @property {String} projectId The id of the project that has been renamed
 * @property {String} name The new name for the project
 * @property {String} oldName The old name for the project
 */

/**
 * A change indicating a project has been tagged
 * @typedef {Object} ProjectTagChange
 * @property {String} projectId The id of the project that has been tagged
 * @property {String} version The new version for the project
 * @property {String} oldVersion The old version of the project
 */

/**
 * A change indicating a schema has been created.
 * @typedef {Object} SchemaCreateChange
 * @property {String} projectId The id of the project that this change applies to
 * @property {String} schemaId The id of the schema that has been created
 * @property {Schema} schema The schema that has been created
 */

/**
 * A change indicating a schema has been removed.
 * @typedef {Object} SchemaRemoveChange
 * @property {String} projectId The id of the project that this change applies to
 * @property {String} schemaId The id of the schema that has been removed
 * @property {Schema} oldSchema The schema that has been removed
 */

/**
 * A change indicating a schema has been renamed.
 * @typedef {Object} SchemaRenameChange
 * @property {String} projectId The id of the project that this change applies to
 * @property {String} schemaId The id of the schema that has been renamed
 * @property {String} name The new name of the column
 * @property {String} oldName The old name of the column
 */

/**
 * A change indicating a column has been created.
 * @typedef {Object} ColumnCreateChange
 * @property {String} projectId The id of the project that this change applies to
 * @property {String} schemaId The id of the schema that this change applies to
 * @property {String} columnId The id of the column that has been created
 * @property {Schema} column The column that has been created
 */

/**
 * A change indicating a column has been removed.
 * @typedef {Object} ColumnRemoveChange
 * @property {String} projectId The id of the project that this change applies to
 * @property {String} schemaId The id of the schema that this change applies to
 * @property {String} columnId The id of the column that has been removed
 * @property {Column} oldColumn The column that has been removed
 */

/**
 * A change indicating a column has been renamed.
 * @typedef {Object} ColumnRenameChange
 * @property {String} projectId The id of the project that this change applies to
 * @property {String} schemaId The id of the schema that this change applies to
 * @property {String} columnId The id of the column that has been renamed
 * @property {String} name The new name of the column
 * @property {String} oldName The old name of the column
 */

/**
 * A change indicating the type of a column has changed.
 * @typedef {Object} ColumnTypechangeChange
 * @property {String} projectId The id of the project that this change applies to
 * @property {String} schemaId The id of the schema that this change applies to
 * @property {String} columnId The id of the column that has changed
 * @property {String} columnName The name of the the column that has changed
 * @property {String} type The new type of the column
 * @property {String} oldType The old type of the column
 */

/**
 * A result of the validation containing errors when failed.
 * @typedef {Object} ValidationResult
 * @property {Boolean} success Whether the validation was successfull or not
 * @property {Array} errors    An array of error objects
 */