@barchart/common-js
Version:
Library of common JavaScript utilities
77 lines (76 loc) • 2.54 kB
TypeScript
/**
* A fluent interface for building a {@link Schema} instance.
*
* @public
*/
export default class SchemaBuilder {
/**
* Creates a new {@link SchemaBuilder}.
*
* @public
* @static
* @param {string} name
* @returns {SchemaBuilder}
*/
public static withName(name: string): SchemaBuilder;
/**
* @param {string} name - The name of the schema
*/
constructor(name: string);
/**
* The {@link Schema} current schema instance.
*
* @public
* @returns {Schema}
*/
public get schema(): Schema;
/**
* Adds a new {@link Field} to the schema and returns the current instance.
*
* @public
* @param {string} name - The name of the new field.
* @param {DataType} dataType - The type of the new field.
* @param {boolean=} optional - If true, the field is not required and may be omitted.
* @returns {SchemaBuilder}
*/
public withField(name: string, dataType: DataType, optional?: boolean | undefined): SchemaBuilder;
/**
* Adds a new {@link Field} to the schema (where the field is an array) and returns the current instance.
*
* @public
* @param {string} name - The name of the new field.
* @param {DataType} dataType - The type of the new field.
* @param {boolean=} optional - If true, the field is not required and may be omitted.
* @returns {SchemaBuilder}
*/
public withArray(name: string, dataType: DataType, optional?: boolean | undefined): SchemaBuilder;
/**
* Adds a new {@link Component} to the schema and returns the current instance.
*
* @public
* @param {Component} component - The new component to add.
* @returns {SchemaBuilder}
*/
public withComponent(component: Component): SchemaBuilder;
/**
* Adds a new {@link Component} to the schema, using a {@link ComponentBuilder}
* and returns the current instance.
*
* @public
* @param {string} name - The name of the new component.
* @param {Function} callback - A callback to which the {@link ComponentBuilder} is passed synchronously.
* @returns {SchemaBuilder}
*/
public withComponentBuilder(name: string, callback: Function): SchemaBuilder;
/**
* Returns a string representation.
*
* @public
* @returns {string}
*/
public toString(): string;
#private;
}
import Schema from './../Schema.js';
import DataType from './../DataType.js';
import Component from './../Component.js';