@open-kappa/myjson
Version:
A simple JSON management library.
101 lines (100 loc) • 4.63 kB
TypeScript
import { MyJson, MyJsonArray, MyJsonFixed, MyJsonFlex, MyJsonMap, MyJsonValue } from "./myjsonImpl";
/**
* @brief Support factory class.
*/
declare class MyJsonFactory {
/**
* @brief Constructor.
*/
constructor();
/**
* @brief Build an array object.
* @typeparam Element The element of the object.
* @param {Element} element The validator element.
* @param {boolean} isMandatory Whether the property is mandatory.
* @param {string} name The property name.
* @return {MyJsonArray<Element>} The built property.
*/
makeArray<Element extends MyJson>(element: Element, isMandatory: boolean, name: string): MyJsonArray<Element>;
/**
* @brief Build a fixed object.
* @param {boolean} isMandatory Whether the property is mandatory.
* @param {string} name The property name.
* @param {Array<MyJson>} elementsList The list of properties to add.
* @return {MyJsonFixed} The built property.
*/
makeFixed(isMandatory: boolean, name: string, elementsList?: Array<MyJson>): MyJsonFixed;
/**
* @brief Build a flex object.
* @typeparam Element The element of the object.
* @param {Element} element The validator element.
* @param {boolean} isMandatory Whether the property is mandatory.
* @param {string} name The property name.
* @param {Array<MyJson>} elementsList The list of properties to add.
* @return {MyJsonFlex<Element>} The built property.
*/
makeFlex<Element extends MyJson>(element: Element, isMandatory: boolean, name: string, elementsList?: Array<MyJson>): MyJsonFlex<Element>;
/**
* @brief Build a map object.
* @typeparam Element The element of the object.
* @param {Element} element The validator element.
* @param {boolean} isMandatory Whether the property is mandatory.
* @param {string} name The property name.
* @return {MyJsonMap<Element>} The built property.
*/
makeMap<Element extends MyJson>(element: Element, isMandatory: boolean, name: string): MyJsonMap<Element>;
/**
* @brief Build a value object.
* @typeparam Element The element of the value.
* @param {Element} element The defaut value.
* @param {boolean} isMandatory Whether the property is mandatory.
* @param {string} name The property name.
* @return {MyJsonValue<Element>} The built property.
*/
makeValue<Element>(element: Element, isMandatory: boolean, name: string): MyJsonValue<Element>;
/**
* @brief Build a value string object.
* @param {boolean} isMandatory Whether the property is mandatory.
* @param {string} name The property name.
* @param {string} [value=""] The defaut value.
* @return {MyJsonValue<string>} The built property.
*/
makeString(isMandatory: boolean, name: string, value?: string): MyJsonValue<string>;
/**
* @brief Build a value number object.
* @param {boolean} isMandatory Whether the property is mandatory.
* @param {string} name The property name.
* @param {string} [value=0] The defaut value.
* @return {MyJsonValue<number>} The built property.
*/
makeNumber(isMandatory: boolean, name: string, value?: number): MyJsonValue<number>;
/**
* @brief Build a value string object.
* @param {boolean} isMandatory Whether the property is mandatory.
* @param {string} name The property name.
* @param {boolean} [value=false] The defaut value.
* @return {MyJsonValue<boolean>} The built property.
*/
makeBoolean(isMandatory: boolean, name: string, value?: boolean): MyJsonValue<boolean>;
/**
* @brief Create and return a enum constraint.
* @typeparam Element The type of enum values.
* @param {Array<Element>} values The enum values.
* @return {(ref: MyJson) => string} The contraint method.
*/
getEnumConstraint<Element>(values: Array<Element>): (ref: MyJson) => string;
/**
* @brief Create and return a field constraint.
* If the first field exists and holds the given value, then the fields in
* the list must exists.
* @typeparam Element The type of the value.
* @param {string} field1 The field to check.
* @param {Element | null} value1 The reference value. If null, the value is
* not checked.
* @param {Array<string>} fieldsList The fields to check.
* @return {(ref: MyJson) => string} The contraint method.
*/
getFieldConstraint<Element>(field1: string, value1: Element | null, fieldsList: Array<string>): (ref: MyJson) => string;
}
export { MyJsonFactory };
export default MyJsonFactory;