import type { QueryResultValidator } from '../core/query-tree/validation.js'; export declare const aqlConfig: { enableIndentationForCode: boolean; }; export interface AQLCodeOptions { /** * Whether to collect the query tree variable indices of the variables (see * associateWithQueryTreeVariable()) */ readonly collectQueryTreeVariableIndices?: boolean; } export declare class AQLCodeBuildingContext { private readonly boundValues; private readonly boundCollectionNames; private variableBindings; private preExecInjectedVariablesMap; private nextIndexPerLabel; private readonly queryTreeVariableIndices; indentationLevel: number; constructor(options?: AQLCodeOptions); private static getBoundValueName; private static DEFAULT_LABEL; private static getSafeLabel; private static getVarName; bindValue(value: any): string; bindCollectionName(collectionName: string): string; getOrAddVariable(token: AQLVariable): string; getBoundValueMap(): { [key: string]: unknown; }; getPreExecInjectedVariablesMap(): Map; /** * The query tree variable indices by AQL variable name (only if collectQueryTreeVariableIndices is set) */ getQueryTreeVariableIndices(): { readonly [variableName: string]: number; } | undefined; } export declare abstract class AQLFragment { toString(): string; toColoredString(): string; getCode(options?: AQLCodeOptions): { code: string; boundValues: { [key: string]: unknown; }; usedResultVariables: Map; queryTreeVariableIndices: { readonly [variableName: string]: number; } | undefined; }; isEmpty(): boolean; /** * Whether this fragment contains a subquery (a fragment created with aql.subquery() or marked * with aql.markAsSubquery()) * * Subqueries must not be used within array inline expressions ([* FILTER ...], [* RETURN ...]): * ArangoDB evaluates them before the enclosing statement, where CURRENT is not defined. This * results in internal errors ("variable not found") or, if the optimizer moves the filter into a * collection scan, in wrong results. */ containsSubquery(): boolean; abstract toStringWithContext(context: AQLCodeBuildingContext): string; abstract toColoredStringWithContext(context: AQLCodeBuildingContext): string; abstract getCodeWithContext(context: AQLCodeBuildingContext): string; } export declare class AQLCodeFragment extends AQLFragment { readonly aql: string; constructor(aql: string); isEmpty(): boolean; toStringWithContext(context: AQLCodeBuildingContext): string; toColoredStringWithContext(context: AQLCodeBuildingContext): string; getCodeWithContext(context: AQLCodeBuildingContext): string; } /** * Records that an AQLVariable represents a query tree variable (unless it already represents one) */ export declare function associateWithQueryTreeVariable(variable: AQLVariable, queryTreeVariableIndex: number): void; export declare class AQLVariable extends AQLFragment { readonly label?: string | undefined; constructor(label?: string | undefined); getCodeWithContext(context: AQLCodeBuildingContext): string; toStringWithContext(context: AQLCodeBuildingContext): string; toColoredStringWithContext(context: AQLCodeBuildingContext): string; } export declare class AQLQueryResultVariable extends AQLVariable { getCodeWithContext(context: AQLCodeBuildingContext): string; } export declare class AQLBoundValue extends AQLFragment { readonly value: any; constructor(value: any); toStringWithContext(context: AQLCodeBuildingContext): string; toColoredStringWithContext(): string; getCodeWithContext(context: AQLCodeBuildingContext): string; } export declare class AQLCollection extends AQLFragment { readonly collectionName: string; constructor(collectionName: string); toStringWithContext(context: AQLCodeBuildingContext): string; toColoredStringWithContext(): string; getCodeWithContext(context: AQLCodeBuildingContext): string; } export declare class AQLCompoundFragment extends AQLFragment { readonly fragments: ReadonlyArray; private _containsSubquery; constructor(fragments: ReadonlyArray); isEmpty(): boolean; containsSubquery(): boolean; toStringWithContext(context: AQLCodeBuildingContext): string; toColoredStringWithContext(context: AQLCodeBuildingContext): string; getCodeWithContext(context: AQLCodeBuildingContext): string; } export declare class AQLIndentationFragment extends AQLFragment { readonly fragment: AQLFragment; constructor(fragment: AQLFragment); isEmpty(): boolean; containsSubquery(): boolean; toStringWithContext(context: AQLCodeBuildingContext): string; toColoredStringWithContext(context: AQLCodeBuildingContext): string; getCodeWithContext(context: AQLCodeBuildingContext): string; } /** * Wraps a fragment that is a subquery (including its parentheses) without changing how it is * rendered, so containsSubquery() can detect it */ export declare class AQLSubqueryFragment extends AQLFragment { readonly fragment: AQLFragment; constructor(fragment: AQLFragment); isEmpty(): boolean; containsSubquery(): boolean; toStringWithContext(context: AQLCodeBuildingContext): string; toColoredStringWithContext(context: AQLCodeBuildingContext): string; getCodeWithContext(context: AQLCodeBuildingContext): string; } export declare function aql(strings: ReadonlyArray, ...values: (AQLFragment | string | number | boolean)[]): AQLFragment; export declare namespace aql { function concat(fragments: ReadonlyArray): AQLCompoundFragment; function join(fragments: ReadonlyArray, separator: AQLFragment): AQLFragment; function code(code: string): AQLFragment; function lines(...fragments: ReadonlyArray): AQLFragment; function indent(fragment: AQLFragment): AQLIndentationFragment; /** * Creates a subquery: the given lines, indented and wrapped in parentheses */ function subquery(...lines: ReadonlyArray): AQLFragment; /** * Marks a fragment as a subquery (it should include the parentheses) without changing it * * Use aql.subquery() instead if possible. This is for subqueries that are written inline. */ function markAsSubquery(fragment: AQLFragment): AQLFragment; function variable(label?: string): AQLFragment; function value(value: any): AQLFragment; function queryResultVariable(label?: string): AQLQueryResultVariable; function collection(name: string): AQLFragment; function identifier(name: string): AQLFragment; /** * Should be used when fairly certain that string can't be malicious * * As the string is json-encoded, it *should* be fine in any case, but still, user-supplied strings in queries is scary */ function string(str: string): AQLFragment; function integer(number: number): AQLFragment; /** * Caution: should only use in .identifier() and NOT .code() because it does not account for keywords */ function isSafeIdentifier(str: string): false | RegExpMatchArray | null; } /** * A node in an AQL transaction tree * * This is an intermediate representation in the process of converting a query tree to an AQL transaction. The * transaction tree's root is the root query. Children of a transaction node are the direct preExec queries of a query. * Thus, the query tree is reduced to WithPreExecQueryNodes as nodes, all other kinds of nodes are already processed * into AQLFragments. */ export declare class AQLCompoundQuery extends AQLFragment { readonly preExecQueries: ReadonlyArray; readonly aqlQuery: AQLFragment; readonly resultVar: AQLQueryResultVariable | undefined; readonly resultValidator: QueryResultValidator | undefined; readonly readAccessedCollections: ReadonlyArray; readonly writeAccessedCollections: ReadonlyArray; constructor(preExecQueries: ReadonlyArray, aqlQuery: AQLFragment, resultVar: AQLQueryResultVariable | undefined, resultValidator: QueryResultValidator | undefined, readAccessedCollections: ReadonlyArray, writeAccessedCollections: ReadonlyArray); /** * Gets the linear AQL transaction for this transaction tree * * The returned transaction steps are to be executed sequentially. */ getExecutableQueries(options?: AQLCodeOptions): ReadonlyArray; private getExecutableQueriesRecursive; toStringWithContext(context: AQLCodeBuildingContext): string; toColoredStringWithContext(context: AQLCodeBuildingContext): string; getCodeWithContext(context: AQLCodeBuildingContext): string; } /** * A step in an AQL transaction */ export declare class AQLExecutableQuery { readonly code: string; readonly boundValues: { [p: string]: any; }; readonly usedPreExecResultNames: { [p: string]: string; }; readonly resultName?: string | undefined; readonly resultValidator?: { [name: string]: any; } | undefined; /** * The query tree variable indices (VariableQueryNode.index) by AQL variable name * * Only set if collectQueryTreeVariableIndices was specified. */ readonly queryTreeVariableIndices?: { readonly [variableName: string]: number; } | undefined; constructor(code: string, boundValues: { [p: string]: any; }, usedPreExecResultNames: { [p: string]: string; }, resultName?: string | undefined, resultValidator?: { [name: string]: any; } | undefined, /** * The query tree variable indices (VariableQueryNode.index) by AQL variable name * * Only set if collectQueryTreeVariableIndices was specified. */ queryTreeVariableIndices?: { readonly [variableName: string]: number; } | undefined); }