import { SqrlExecutable } from "../execute/SqrlExecutable"; import { SqrlInstance as _Instance } from "../function/Instance"; import { Context } from "./ctx"; import { Ast, CallAst, CustomCallAst } from "../ast/Ast"; import { LogProperties } from "./log"; import { CompileState } from "./parse"; import { ArgumentCheck } from "./arg"; import { SourcePrinter } from "./executable"; import { SqrlObject, AssertService } from "sqrl-common"; import { SqrlKey } from "./object"; import { Config } from "./config"; export declare const STANDARD_LIBRARY = "sqrl"; export interface ExecutionErrorProperties { functionName?: string; fatal?: boolean; } export interface LogService { log(manipulator: Manipulator, message: string): any; } export interface FunctionServices { assert?: AssertService; log?: LogService; } export declare type ManipulatorCallback = (ctx: Context) => Promise; export declare abstract class Manipulator { constructor(); codedWarnings: string[]; codedErrors: string[]; abstract getCurrentHumanOutput(): any; abstract addCallback(cb: ManipulatorCallback): any; abstract mutate(ctx: Context): Promise; abstract logError(err: Error, props: ExecutionErrorProperties): void; abstract throwFirstError(): void; trackSqrlKey(key: SqrlKey): void; } export interface ExecutableOptions { instance: Instance; } export interface FeatureMap { [feature: string]: any; } export interface FunctionInfo { name: string; argstring: string | null; docstring: string | null; package: string | null; } export declare function createInstance(props?: { config?: Config; services?: FunctionServices; }): Instance; export interface MinimalFunctionOptions { argstring?: string; docstring?: string; } export interface FunctionOptions extends MinimalFunctionOptions { args?: ArgumentCheck[]; } export interface ImplementedFunctionOptions extends FunctionOptions { allowNull?: boolean; allowSqrlObjects?: boolean; pure?: boolean; } export declare class Instance { private config; _instance: _Instance; readonly packageName: string; private mergedConfig; constructor(config: Config, _instance: _Instance, packageName?: string); createPackageInstance(name: string): Instance; importFromPackage(name: string, importedPackage: any): Promise; getConfig(): Config; listFunctions(): FunctionInfo[]; register(func: (state: Execution, ...args: any) => Promise, options?: ImplementedFunctionOptions): void; registerSync(func: (...args: any) => any, options?: ImplementedFunctionOptions): void; registerStatement(statementFeature: string, func: (state: Execution, ...args: any) => Promise, options?: ImplementedFunctionOptions): void; registerCustom(transform: (state: CompileState, ast: CustomCallAst) => Ast, options?: MinimalFunctionOptions): void; registerTransform(transform: (state: CompileState, ast: CallAst) => Ast, options?: FunctionOptions): void; } export declare class Executable { _wrapped: SqrlExecutable; constructor(_wrapped: SqrlExecutable); execute(ctx: Context, options?: { manipulator?: Manipulator; inputs?: FeatureMap; featureTimeoutMs?: number; }): Promise; getSourcePrinter(): SourcePrinter; getFeatures(): string[]; getRequiredFeatures(): string[]; } export interface Execution { readonly ctx: Context; readonly manipulator: Manipulator; get(symbol: symbol, defaultValue?: T): T; set(symbol: symbol, value: T): void; setDefault(symbol: symbol, defaultValue?: T): T; fetchFeature(featureName: string): Promise; fetchValue(featureName: string): Promise; getSourcePrinter(): SourcePrinter; getClockMs(): number; trace(props: LogProperties, format: string, ...param: any[]): any; debug(props: LogProperties, format: string, ...param: any[]): any; info(props: LogProperties, format: string, ...param: any[]): any; warn(props: LogProperties, format: string, ...param: any[]): any; error(props: LogProperties, format: string, ...param: any[]): any; fatal(props: LogProperties, format: string, ...param: any[]): any; }