From 25f70171fe44a7e0c5ce6eb2cdfbe33788d7ee8c Mon Sep 17 00:00:00 2001 From: angrykoala Date: Thu, 8 Jun 2023 09:21:33 +0100 Subject: [PATCH 1/2] Updates compileCypher method so it properly exports its typings --- src/utils/compile-cypher-if-exists.ts | 5 +++-- src/utils/compile-cypher.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/utils/compile-cypher-if-exists.ts b/src/utils/compile-cypher-if-exists.ts index 61830f06..aa3f43b4 100644 --- a/src/utils/compile-cypher-if-exists.ts +++ b/src/utils/compile-cypher-if-exists.ts @@ -18,12 +18,13 @@ */ import type { CypherEnvironment } from "../Environment"; -import type { CypherCompilable } from "../types"; +import { Clause } from "../clauses/Clause"; +import { Expr } from "../types"; import { compileCypher } from "./compile-cypher"; /** Compiles the cypher of an element, if the resulting cypher is not empty adds a prefix */ export function compileCypherIfExists( - element: CypherCompilable | undefined, + element: Expr | Clause | undefined, env: CypherEnvironment, options: { prefix?: string; suffix?: string } = {} ): string { diff --git a/src/utils/compile-cypher.ts b/src/utils/compile-cypher.ts index 32356c7c..b558edec 100644 --- a/src/utils/compile-cypher.ts +++ b/src/utils/compile-cypher.ts @@ -18,7 +18,8 @@ */ import type { CypherEnvironment } from "../Environment"; -import type { CypherCompilable } from "../types"; +import { Clause } from "../clauses/Clause"; +import type { Expr } from "../types"; import { isCypherCompilable } from "./is-cypher-compilable"; /** Compiles a clause or expression to a Cypher string, adding optional prefix or suffix. To be used in a RawCypher callback @@ -26,7 +27,7 @@ import { isCypherCompilable } from "./is-cypher-compilable"; * The prefix and suffix will only be added if the resulting Cypher is **not** an empty string */ export function compileCypher( - element: CypherCompilable, + element: Expr | Clause, env: CypherEnvironment, { prefix = "", suffix = "" }: { prefix?: string; suffix?: string } = {} ): string { From cc144e15d44a90141dc88f2992569f5bd9e4d731 Mon Sep 17 00:00:00 2001 From: angrykoala Date: Thu, 8 Jun 2023 09:33:10 +0100 Subject: [PATCH 2/2] Change typings for compileCypherIfExists --- src/utils/compile-cypher-if-exists.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils/compile-cypher-if-exists.ts b/src/utils/compile-cypher-if-exists.ts index aa3f43b4..f0679712 100644 --- a/src/utils/compile-cypher-if-exists.ts +++ b/src/utils/compile-cypher-if-exists.ts @@ -18,16 +18,16 @@ */ import type { CypherEnvironment } from "../Environment"; -import { Clause } from "../clauses/Clause"; -import { Expr } from "../types"; -import { compileCypher } from "./compile-cypher"; +import { CypherCompilable } from "../types"; /** Compiles the cypher of an element, if the resulting cypher is not empty adds a prefix */ export function compileCypherIfExists( - element: Expr | Clause | undefined, + element: CypherCompilable | undefined, env: CypherEnvironment, - options: { prefix?: string; suffix?: string } = {} + { prefix = "", suffix = "" }: { prefix?: string; suffix?: string } = {} ): string { if (!element) return ""; - return compileCypher(element, env, options); + const cypher = element.getCypher(env); + if (!cypher) return ""; + return `${prefix}${cypher}${suffix}`; }