Arguments
On this page
Declaring a signature, and reading the values that arrive.
interface ArgumentConstraints
Section titled âinterface ArgumentConstraintsâexport interface ArgumentConstraintsDescription
Raw per-argument constraint declarations, as authored on a functionâs argument descriptor. Encoded into the pre-computed {@link ArgumentSpec} constraint fields via {@link constraintSpecFields}.
Fields
choicesreadonly unknown[]optionalClosed set of allowed values (JSON-encoded into
vgi_choices).genumberoptionalInclusive lower bound (
>=).lenumberoptionalInclusive upper bound (
<=).gtnumberoptionalExclusive lower bound (
>).ltnumberoptionalExclusive upper bound (
<).patternstringoptionalRegex the value must match (surfaced as
vgi_pattern, as-is).defaultunknownoptionalDefault value (JSON-encoded into
vgi_default); optional args only.
class Arguments
Section titled âclass Argumentsâexport class ArgumentsProperties
property positional
Section titled âproperty positionalâreadonly positional: (any | null)[];property argumentsSchema
Section titled âproperty argumentsSchemaâreadonly argumentsSchema: VgiSchema | null;Schema of the arguments batch (preserves original Arrow types).
Methods
method get
Section titled âmethod getâget(position: number | string, defaultValue?: any): anyGet an argument by position (number) or name (string).
interface ArgumentSpec
Section titled âinterface ArgumentSpecâexport interface ArgumentSpecFields
namestringpositionnumber | stringarrowTypeVgiDataTypeisTableInputbooleanoptionalisAnyTypebooleanoptionalisVarargsbooleanoptionalisConstbooleanoptionaldocstringoptionaldefaultJsonstringoptionalDiscovery-facing constraint metadata, pre-encoded to their surfaced UTF-8 forms (presence-only â
undefinedmeans the constraint is absent and the corresponding field-metadata key is omitted entirely). Mirrors PythonâsArgumentSpec.default_json/choices_json/range_notation/patternsoargumentSpecsToSchema/schemaToArgumentSpecsround-trip symmetrically.choicesJsonstringoptionalrangeNotationstringoptionalpatternstringoptional
function argumentSpecsToSchema
Section titled âfunction argumentSpecsToSchemaâexport function argumentSpecsToSchema(specs: ArgumentSpec[]): VgiSchemaDescription
Convert ArgumentSpecs to an Arrow Schema with VGI metadata keys. Positional arguments come first (in order), named arguments follow.
function constraintSpecFields
Section titled âfunction constraintSpecFieldsâexport function constraintSpecFields(constraints: ArgumentConstraints | undefined,): Pick<ArgumentSpec, "defaultJson" | "choicesJson" | "rangeNotation" | "pattern">Description
Encode raw {@link ArgumentConstraints} into the pre-computed constraint
fields of an {@link ArgumentSpec} (presence-only â absent constraints yield
no field). Mirrors Pythonâs _constraint_kwargs.
function formatRange
Section titled âfunction formatRangeâexport function formatRange(ge?: number,le?: number,gt?: number,lt?: number,): string | undefinedDescription
Build interval notation from an argumentâs numeric bounds.
Inclusive bounds (ge/le) render as square brackets, exclusive bounds
(gt/lt) as parentheses, and an open side as -inf/+inf. Returns
undefined when the argument has no numeric bound at all.
Examples: ge=0,le=10 -> "[0, 10]"; gt=0 -> "(0, +inf)";
ge=1,lt=10 -> "[1, 10)".
function macroArgumentsSchema
Section titled âfunction macroArgumentsSchemaâexport function macroArgumentsSchema(parameters: string[],parameterDefaultValues?: Uint8Array | null,parameterDocs?: Record<string, string>,): VgiSchemaDescription
Build a macro arguments_schema describing macro parameters.
Mirrors the function arguments_schema mechanism: one Arrow field per macro
parameter, in parameters order, each nullable. The per-parameter
description is carried via the same vgi_doc field-metadata key functions use
(UTF-8, presence-only â the key is omitted entirely when there is no doc). A
parameterâs field type is the type of its default value when one is known
(decoded from parameterDefaultValues, a one-row RecordBatch serialized as
IPC bytes), else nullType().
Returns
Arrow schema with one nullable field per parameter, in order.
function macroParameterDocsFromSchema
Section titled âfunction macroParameterDocsFromSchemaâexport function macroParameterDocsFromSchema(schema: VgiSchema): Record<string, string>Description
Extract per-parameter descriptions from a macro arguments_schema.
Inverse of {@link macroArgumentsSchema}âs vgi_doc handling: reads the
vgi_doc field metadata (UTF-8) for each field. Fields without the key
(undocumented) are omitted from the result.
Returns
Mapping of parameter name to description, for documented parameters only.
function schemaToArgumentSpecs
Section titled âfunction schemaToArgumentSpecsâexport function schemaToArgumentSpecs(schema: VgiSchema): ArgumentSpec[]Description
Convert an Arrow Schema back to ArgumentSpecs.