@qualifyze/airtable-formulator
Version:
Airtable Formula Manipulator
21 lines (20 loc) • 1.18 kB
TypeScript
import { functions, operators } from "./airtable-formula-reference.json";
import Ajv, { ErrorObject, JSONSchemaType, ValidateFunction } from "ajv";
export declare type FunctionName = keyof typeof functions;
export declare type OperatorSymbol = keyof typeof operators;
export declare function isFunctionName(name: string): name is FunctionName;
export declare function isOperatorSymbol(symbol: string): symbol is OperatorSymbol;
declare type Literal = string | number | boolean;
export declare type FieldReference = {
field: string;
};
declare type ArrayNotation<T extends string> = [T, ...Formula[]];
export declare type FunctionCall = ArrayNotation<FunctionName>;
export declare type Operation = ArrayNotation<OperatorSymbol>;
export declare type Formula = FunctionCall | Operation | Literal | FieldReference;
export declare const schema: JSONSchemaType<Formula>;
export declare function createValidator(ajv?: Ajv): ValidateFunction<Formula>;
export declare function isFunctionCall(formula: Formula): formula is FunctionCall;
export declare function isOperation(formula: Formula): formula is Operation;
export declare function validate<T>(data: T): ErrorObject[];
export {};