Module: lib/include

Classes

SchemaParserError
SchemaValidationError

Methods

(static) barescriptTypeModel() → {Object}

Get the BareScript type model

Source:
Returns:

The BareScript type model

Type
Object

(static) barescriptValidateExpression(expr) → {Object}

Validate an expression model

Parameters:
Name Type Description
expr Object

The expression model

Source:
Throws:
Returns:

The validated expression model

Type
Object

(static) barescriptValidateScript(script) → {Object}

Validate a BareScript model

Parameters:
Name Type Description
script Object

The BareScript model

Source:
Throws:
Returns:

The validated BareScript model

Type
Object

(static) dataAggregate(data, aggregation) → {Array.<Object>}

Aggregate a data array

Parameters:
Name Type Description
data Array.<Object>

The data array

aggregation Object

The aggregation model

Source:
Returns:

The aggregated data array

Type
Array.<Object>

(static) dataCalculatedField(data, fieldName, expr, variablesopt, nullable) → {Array.<Object>}

Add a calculated field to a data array

Parameters:
Name Type Attributes Default Description
data Array.<Object>

The data array

fieldName string

The calculated field name

expr string

The calculated field expression

variables Object <optional>
<nullable>
null

The expression variables object

Source:
Returns:

The updated data array

Type
Array.<Object>

(static) dataFilter(data, expr, variablesopt, nullable) → {Array.<Object>}

Filter a data array

Parameters:
Name Type Attributes Default Description
data Array.<Object>

The data array

expr string

The filter expression

variables Object <optional>
<nullable>
null

The expression variables object

Source:
Returns:

The filtered data array

Type
Array.<Object>

(static) dataJoin(leftData, rightData, joinExpr, rightExpropt, nullable, isLeftJoinopt, nullable, variablesopt, nullable) → {Array.<Object>}

Join two data arrays

Parameters:
Name Type Attributes Default Description
leftData Array.<Object>

The left data array

rightData Array.<Object>

The right data array

joinExpr string

The join expression

rightExpr string <optional>
<nullable>
null

The right join expression

isLeftJoin boolean <optional>
<nullable>
null

If true, perform a left join (always include left row)

variables Object <optional>
<nullable>
null

The join expression variables object

Source:
Returns:

The joined data array

Type
Array.<Object>

(static) dataLineChartElements(data, lineChart, optionsopt, nullable) → {Object}

Render a line chart as an element model

Parameters:
Name Type Attributes Default Description
data Array.<Object>

The data array

lineChart Object

The line chart model

options Object <optional>
<nullable>
null

The line chart options object

Source:
Returns:

The line chart element model

Type
Object

(static) dataLineChartValidate(lineChart) → {Object}

Validate a line chart model

Parameters:
Name Type Description
lineChart Object

The line chart model

Source:
Throws:
Returns:

The validated line chart model

Type
Object

(static) dataParseCSV(text) → {Array.<Object>}

Parse CSV text to a data array

Parameters:
Name Type Description
text string | Array.<string>

The CSV text or array of CSV text

Source:
Returns:

The data array

Type
Array.<Object>

(static) dataSort(data, sorts) → {Array.<Object>}

Sort a data array

Parameters:
Name Type Description
data Array.<Object>

The data array

sorts Array.<Array>

The array of sort tuples, [field] or [field, descending]

Source:
Returns:

The sorted data array

Type
Array.<Object>

(static) dataTableElements(data, dataTableopt, nullable) → {Object}

Render a data table as an element model

Parameters:
Name Type Attributes Default Description
data Array.<Object>

The data array

dataTable Object <optional>
<nullable>
null

The data table model

Source:
Returns:

The data table element model

Type
Object

(static) dataTableMarkdown(data, modelopt, nullable) → {Array.<string>}

Create the array of Markdown table line strings

Parameters:
Name Type Attributes Default Description
data Array.<Object>

The array of row objects

model Object <optional>
<nullable>
null

The data table model

Source:
Returns:

The array of Markdown table line strings

Type
Array.<string>

(static) dataTableValidate(dataTable) → {Object}

Validate a data table model

Parameters:
Name Type Description
dataTable Object

The data table model

Source:
Throws:
Returns:

The validated data table model

Type
Object

(static) dataTop(data, countopt, nullable, categoryFieldsopt, nullable) → {Array.<Object>}

Keep the top rows for each category

Parameters:
Name Type Attributes Default Description
data Array.<Object>

The data array

count number <optional>
<nullable>
null

The number of rows to keep (default is 1)

categoryFields Array.<string> <optional>
<nullable>
null

The category fields

Source:
Returns:

The top data array

Type
Array.<Object>

(static) dataValidate(data, csvopt, nullable) → {Object}

Validate a data array

Parameters:
Name Type Attributes Default Description
data Array.<Object>

The data array

csv boolean <optional>
<nullable>
null

If true, parse value strings

Source:
Throws:
Returns:

The map of field name to field type

Type
Object

(static) elementModelToString(elementsnullable, indentopt, nullable) → {string}

Render an element model to an HTML or SVG string

Parameters:
Name Type Attributes Default Description
elements Object | Array <nullable>

The element model

indent string | number <optional>
<nullable>
null

The indentation string or number of spaces

Source:
Returns:

The HTML or SVG string

Type
string

(static) elementModelValidate(elementsnullable) → (nullable) {Object|Array}

Validate an element model

Parameters:
Name Type Attributes Description
elements Object | Array <nullable>

The element model

Source:
Throws:
Returns:

The validated element model

Type
Object | Array

(static) includeSetLogFn(logFnnullable)

Set the include library stub function log function. Include library logging is debug-level, so setting a log function also enables debug logging for the stub function calls.

Parameters:
Name Type Attributes Description
logFn function <nullable>

The log function, or null to disable logging

Source:

(static) markdownElements(markdown, optionsopt, nullable) → {Array.<Object>}

Generate an element model from a Markdown model

Parameters:
Name Type Attributes Default Description
markdown Object

The Markdown model

options Object <optional>
<nullable>
null

The Markdown elements options object

Source:
Returns:

The Markdown's element model

Type
Array.<Object>

(static) markdownElementsAsync(markdown, optionsopt, nullable) → {Array.<Object>}

Generate an element model from a Markdown model

Parameters:
Name Type Attributes Default Description
markdown Object

The Markdown model

options Object <optional>
<nullable>
null

The Markdown elements options object

Source:
Returns:

The Markdown's element model

Type
Array.<Object>

(static) markdownEscape(text) → {string}

Escape a string for inclusion in Markdown text

Parameters:
Name Type Description
text string

The text to escape

Source:
Returns:

The escaped text

Type
string

(static) markdownHeaderId(text) → {string}

Generate a Markdown header ID from text

Parameters:
Name Type Description
text string

The text

Source:
Returns:

The header element ID

Type
string

(static) markdownParagraphText(paragraph) → {string}

Get a Markdown paragraph model's text

Parameters:
Name Type Description
paragraph Object

The Markdown paragraph model

Source:
Returns:

The paragraph text string

Type
string

(static) markdownParse(text) → {Object}

Parse Markdown text into a Markdown model

Parameters:
Name Type Description
text string | Array.<string>

The Markdown text

Source:
Returns:

The Markdown model

Type
Object

(static) markdownTitle(markdown) → (nullable) {string}

Get a Markdown model's title

Parameters:
Name Type Description
markdown Object

The Markdown model

Source:
Returns:

The title string or null

Type
string

(static) markdownValidate(markdown) → {Object}

Validate a Markdown model

Parameters:
Name Type Description
markdown Object

The Markdown model

Source:
Throws:
Returns:

The validated Markdown model

Type
Object

(static) qrcodeElements(message, size, levelopt, nullable) → {Object}

Generate the element model for a QR code

Parameters:
Name Type Attributes Default Description
message string | Array.<Array>

The QR code message or the QR code matrix

size number

The size of the QR code, in pixels

level string <optional>
<nullable>
null

The error correction level: 'low', 'medium', 'quartile', or 'high'

Source:
Returns:

The QR code SVG element model

Type
Object

(static) qrcodeMatrix(message, levelopt, nullable) → {Array.<Array>}

Generate a QR code pixel matrix

Parameters:
Name Type Attributes Default Description
message string

The QR code message

level string <optional>
<nullable>
null

The error correction level: 'low', 'medium', 'quartile', or 'high'

Source:
Returns:

The QR code pixel matrix

Type
Array.<Array>

(static) schemaDocMarkdown(types, typeName, optionsopt, nullable) → {Array.<string>}

Generate the Schema Markdown user type documentation as an array of Markdown text lines

Parameters:
Name Type Attributes Default Description
types Object

The schema's type model

typeName string

The type name

options Object <optional>
<nullable>
null

The schema documentation options object

Source:
Returns:

The array of Markdown text lines

Type
Array.<string>

(static) schemaGetEnumValues(types, enumModel) → {Array.<Object>}

Get an enum's values (inherited values first)

Parameters:
Name Type Description
types Object

The schema's type model

enumModel Object

The enum model

Source:
Returns:

The array of enum value models

Type
Array.<Object>

(static) schemaGetReferencedTypes(types, typeName, referencedTypesopt, nullable) → {Object}

Get a user type's referenced type model

Parameters:
Name Type Attributes Default Description
types Object

The schema's type model

typeName string

The type name

referencedTypes Object <optional>
<nullable>
null

A map of referenced user type name to user type model to update

Source:
Returns:

The referenced type model

Type
Object

(static) schemaGetStructMembers(types, struct) → {Array.<Object>}

Get a struct's members (inherited members first)

Parameters:
Name Type Description
types Object

The schema's type model

struct Object

The struct model

Source:
Returns:

The array of struct member models

Type
Array.<Object>

(static) schemaParse(text, typesopt, nullable, filenameopt, nullable, validateopt, nullable) → {Object}

Parse Schema Markdown text

Parameters:
Name Type Attributes Default Description
text string | Array.<string>

The Schema Markdown text

types Object <optional>
<nullable>
null

The schema's type model to update

filename string <optional>
<nullable>
null

The file name (for error messages)

validate boolean <optional>
<nullable>
null

If true (the default), validate the type model after parsing

Source:
Throws:
Returns:

The schema's type model

Type
Object

(static) schemaTypeModel() → {Object}

Get the Schema Markdown type model

Source:
Returns:

The Schema Markdown type model

Type
Object

(static) schemaTypeModelValidate(types) → {Object}

Validate a Schema Markdown type model

Parameters:
Name Type Description
types Object

The schema's type model to validate

Source:
Throws:
Returns:

The validated type model

Type
Object

(static) schemaValidate(types, typeName, value, memberFqnopt, nullable) → {*}

Validate a value using a schema type model

Parameters:
Name Type Attributes Default Description
types Object

The schema's type model

typeName string

The type name

value *

The value to validate

memberFqn string <optional>
<nullable>
null

The fully-qualified member name (for error messages)

Source:
Throws:
Returns:

The validated, transformed value

Type
*

(static) urlDecodeComponent(string) → (nullable) {string}

Decode a percent-encoded string component

Parameters:
Name Type Description
string string

The string component to decode

Source:
Returns:

The decoded string, or null on failure

Type
string

(static) urlDecodeQueryString(queryString) → (nullable) {Object}

Decode a URL query string to an object

Parameters:
Name Type Description
queryString string

The query string to decode

Source:
Returns:

The decoded query string object, or null on failure

Type
Object

(static) urlEncode(url) → {string}

Encode a URL

Parameters:
Name Type Description
url string

The URL to encode

Source:
Returns:

The encoded URL

Type
string

(static) urlEncodeComponent(url) → {string}

Encode a URL component

Parameters:
Name Type Description
url string

The URL component to encode

Source:
Returns:

The encoded URL component

Type
string

(static) urlEncodeQueryString(obj) → {string}

Encode an object as a URL query string

Parameters:
Name Type Description
obj Object

The object to encode

Source:
Returns:

The encoded query string

Type
string