@neo4j/cypher-builder
Version:
A programmatic API for building Cypher queries for Neo4j
73 lines (72 loc) • 2.62 kB
TypeScript
import { CypherASTNode } from "../CypherASTNode";
import { CypherEnvironment } from "../Environment";
import type { CypherResult } from "../types";
declare const customInspectSymbol: unique symbol;
/** Config fields of the .build() method
* @group Clauses
*/
export type BuildConfig = Partial<{
/** Defines the default operator for adding multiple labels in a Pattern. Defaults to `":"`
*
* If the target Cypher is version 5 or above, `"&"` is recommended
*
* @example
* `MATCH (this:Movie:Film)`
* `MATCH (this:Movie&Film)`
*
*/
labelOperator: ":" | "&";
/** Will prefix generated queries with the Cypher version
* @example `CYPHER 5` */
cypherVersion: "5";
/** Prefix variables with given string.
*
* This is useful to avoid name collisions if separate Cypher queries are generated and merged after generating the strings.
* @example `myPrefix_this0`
*
*/
prefix: string;
/** Extra parameters to be added to the result of `.build`. */
extraParams: Record<string, unknown>;
/** Options for disabling automatic escaping of potentially unsafe strings.
*
* **WARNING**: Changing these options may lead to code injection and unsafe Cypher.
*/
unsafeEscapeOptions: Partial<{
/** Disables automatic escaping of node labels.
*
* If disabled, any labels passed should be properly escaped with `utils.escapeLabel`.
*
* **WARNING**: Disabling label escaping may lead to code injection and unsafe Cypher.
*/
disableNodeLabelEscaping: boolean;
/** Disables automatic escaping of relationship types.
*
* If disabled, any types passed should be properly escaped with `utils.escapeType`.
*
* **WARNING**: Disabling type escaping may lead to code injection and unsafe Cypher.
*/
disableRelationshipTypeEscaping: boolean;
}>;
}>;
/** Represents a clause AST node
* @group Clauses
*/
export declare abstract class Clause extends CypherASTNode {
protected nextClause: Clause | undefined;
/** Compiles a clause into Cypher and params */
build(config?: BuildConfig): CypherResult;
private getEnv;
private prependCypherVersionClause;
/** Custom string for browsers and templating
* @hidden
*/
toString(): string;
/** Custom log for console.log in Node
* @hidden
*/
[customInspectSymbol](): string;
protected addNextClause(clause: Clause): void;
protected compileNextClause(env: CypherEnvironment): string;
}
export {};