UNPKG

@sheetxl/models

Version:

Models - A Headless javascript spreadsheet library.

145 lines 4.11 kB
import { CellType } from "../cell"; /** * A type of value with an additional argument indicating * if this is an array. */ export interface FunctionValueType { /** * The type of result. */ type: CellType | string; /** * If scalar than this is a single value, if matrix than 2d. * @defaultValue 'scalar` */ dimensionality?: `scalar` | `matrix`; /** * A human readable description use to present help to the user. */ description?: string; } /** * An input to a function */ export interface FunctionParameter { /** * Should be provided but not required. */ name?: string; /** * If required then function will fail without the parameter. * @defaultValue true */ required?: boolean; /** * The data type */ type: CellType | FunctionValueType; /** * If true than this argument is a rest parameter. * @remarks * * This is only allowed for the last parameter. * * If restParam is true then the parameter is also required. */ restParam?: boolean; } /** * Types of options supported. */ export interface FunctionOptions { /** * Indicates that the function can be cancel. * @defaultValue false */ cancelable?: boolean; /** * Indicates the function is a streaming function that is continuously updated. * This flag cannot be set on a function that is also declared as volatile. * @defaultValue false */ stream?: boolean; /** * Indicates the function requires the cell address of the calling cell. * This flag cannot be set on a function that is also declared as a streaming function. * @defaultValue false */ requiresAddress?: boolean; /** * Indicates the function should recalculate each time the graph recalculates. * This flag cannot be set on a function that is also declared as a streaming function. * @defaultValue If there are not arguments than than a function is treated as volatile by default. */ volatile?: boolean; } export interface FunctionDescriptor { /** * The key used to identify the function. * These should be globally unique. * All non builtIn functions will be prepended a UUID. */ id: string; /** * Named of the actual function in code. * This should be camelCased with no special characters to keep it compatible across languages. */ name: string; /** * The type of value returned. Must be a value? * // TODO - review. Can this be void */ returnType: FunctionValueType; /** * The inputs to the function. * @remarks * If not specified than assumed to be a volatile function. */ parameters?: FunctionParameter[]; /** * A human readable description use to present help to the user. */ description?: string; /** * A possible category that function may belong to. * @defaultValue custom */ category?: string; /** * A location to find detailed help about the function. */ helpUrl?: string; /** * The language the function is written in. * @defaultValue typescript */ language?: string; /** * Additional function options */ options?: FunctionOptions; } export interface FunctionDescriptorAndScript { /** * An optional name for the script. */ name?: string; /** * A list of all function descriptors contained with the script. * @remarks * This can be empty but then the script may have comments. */ descriptors: FunctionDescriptor[]; /** * The script as a string. * @remarks * This is the human readable version of the script. If this is * still missing than the script will not able to be shown to the user * but can still be executed. */ source?: string; /** * This is the script that has been compiled. * If this is missing than it will be compiled on demand if possible. */ compiled?: string; } //# sourceMappingURL=types.d.ts.map