UNPKG

easy-api.ts

Version:

A powerful library to create your own API with ease.

55 lines (54 loc) 1.97 kB
import { APIFunction, ParameterDefinition, CompileParam } from "../structures/APIFunction"; import { FunctionToken } from "../core/Compiler"; import { Data } from "../structures/Data"; /** * This class holds the data of a compiled function. */ export declare class CompiledFunction { private data; private metadata; constructor(data: Data, metadata: FunctionToken); /** * Retrieves the source code of this function. * @returns {APIFunction | undefined} */ getData(): APIFunction | undefined; /** * Get the list of allowed values at the given parameter index. * @param arg - Parameter index to retrieve the values from. * @returns {?string[]} */ getAllowedValues(arg?: number): string[] | null; /** * Gets a functions content using the provided reference. * @param index - Field index to retrieve functions from. * @param reference - Reference to take functions from. */ getFunctions(index: number, ref: string | APIFunction | CompiledFunction | FunctionToken): FunctionToken[]; /** * Retrieves a function from the given reference. * @param index - Index to retrieves functions from. * @param reference - Reference to take functions from. */ getFunction(index: number, reference: string | APIFunction | CompiledFunction | FunctionToken): FunctionToken | undefined; /** * Resolve compiled fields with types. */ resolveTypedFields<Params extends readonly ParameterDefinition[] = ParameterDefinition[]>(): Promise<{ [K in keyof Params]: CompileParam<Params[K]["type"]>; }>; /** * Retrieves the function name. */ get name(): string; /** * Returns the compiled function fields. */ get fields(): string[]; /** * Returns the content inside the function as string. */ get inside(): string; /** * Returns the compiled function as string. */ get image(): string; }