@neo4j/cypher-builder
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -8,3 +8,4 @@ import type { CypherEnvironment } from "../Environment"; | ||
import { WithReturn } from "./mixins/WithReturn"; | ||
export interface Merge extends WithReturn { | ||
import { WithSet } from "./mixins/WithSet"; | ||
export interface Merge extends WithReturn, WithSet { | ||
} | ||
@@ -11,0 +12,0 @@ export declare class Merge<T extends NodeRef | RelationshipRef = any> extends Clause { |
@@ -34,2 +34,4 @@ "use strict"; | ||
const mixin_1 = require("./utils/mixin"); | ||
const WithSet_1 = require("./mixins/WithSet"); | ||
const compile_cypher_if_exists_1 = require("../utils/compile-cypher-if-exists"); | ||
let Merge = class Merge extends Clause_1.Clause { | ||
@@ -52,2 +54,3 @@ constructor(element, params = {}) { | ||
const mergeStr = `MERGE ${this.pattern.getCypher(env)}`; | ||
const setCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.setSubClause, env, { prefix: "\n" }); | ||
const onCreateStatement = this.onCreateClause.getCypher(env); | ||
@@ -59,9 +62,9 @@ const separator = onCreateStatement ? "\n" : ""; | ||
} | ||
return `${mergeStr}${separator}${onCreateStatement}${returnCypher}`; | ||
return `${mergeStr}${separator}${setCypher}${onCreateStatement}${returnCypher}`; | ||
} | ||
}; | ||
Merge = __decorate([ | ||
(0, mixin_1.mixin)(WithReturn_1.WithReturn) | ||
(0, mixin_1.mixin)(WithReturn_1.WithReturn, WithSet_1.WithSet) | ||
], Merge); | ||
exports.Merge = Merge; | ||
//# sourceMappingURL=Merge.js.map |
@@ -5,2 +5,3 @@ export { Match, OptionalMatch } from "./clauses/Match"; | ||
export { Call } from "./clauses/Call"; | ||
export { CallProcedure } from "./clauses/CallProcedure"; | ||
export { Return } from "./clauses/Return"; | ||
@@ -24,2 +25,3 @@ export { RawCypher } from "./clauses/RawCypher"; | ||
export { PatternComprehension } from "./expressions/list/PatternComprehension"; | ||
export { ListExpr as List } from "./expressions/list/ListExpr"; | ||
export { MapExpr as Map } from "./expressions/map/MapExpr"; | ||
@@ -30,3 +32,3 @@ export { MapProjection } from "./expressions/map/MapProjection"; | ||
export { plus, minus } from "./expressions/operations/math"; | ||
export { coalesce, point, distance, pointDistance, cypherDatetime as datetime, labels, count, min, max, avg, sum, } from "./expressions/functions/CypherFunction"; | ||
export { coalesce, point, distance, pointDistance, cypherDatetime as datetime, cypherDate as date, cypherLocalTime as localtime, cypherLocalDatetime as localdatetime, cypherTime as time, labels, count, min, max, avg, sum, randomUUID } from "./expressions/functions/CypherFunction"; | ||
export * from "./expressions/functions/ListFunctions"; | ||
@@ -33,0 +35,0 @@ export { any, all, exists, single } from "./expressions/functions/PredicateFunctions"; |
@@ -47,4 +47,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.pointDistance = exports.distance = exports.point = exports.coalesce = exports.minus = exports.plus = exports.matches = exports.endsWith = exports.startsWith = exports.contains = exports.in = exports.isNotNull = exports.isNull = exports.lte = exports.lt = exports.gte = exports.gt = exports.eq = exports.not = exports.and = exports.or = exports.MapProjection = exports.Map = exports.PatternComprehension = exports.ListComprehension = exports.apoc = exports.db = exports.Case = exports.Exists = exports.Null = exports.Literal = exports.Variable = exports.NamedVariable = exports.NamedParam = exports.Param = exports.Relationship = exports.NamedNode = exports.Node = exports.concat = exports.Foreach = exports.Union = exports.Unwind = exports.With = exports.RawCypher = exports.Return = exports.Call = exports.Merge = exports.Create = exports.OptionalMatch = exports.Match = void 0; | ||
exports.utils = exports.single = exports.exists = exports.all = exports.any = exports.sum = exports.avg = exports.max = exports.min = exports.count = exports.labels = exports.datetime = void 0; | ||
exports.point = exports.coalesce = exports.minus = exports.plus = exports.matches = exports.endsWith = exports.startsWith = exports.contains = exports.in = exports.isNotNull = exports.isNull = exports.lte = exports.lt = exports.gte = exports.gt = exports.eq = exports.not = exports.and = exports.or = exports.MapProjection = exports.Map = exports.List = exports.PatternComprehension = exports.ListComprehension = exports.apoc = exports.db = exports.Case = exports.Exists = exports.Null = exports.Literal = exports.Variable = exports.NamedVariable = exports.NamedParam = exports.Param = exports.Relationship = exports.NamedNode = exports.Node = exports.concat = exports.Foreach = exports.Union = exports.Unwind = exports.With = exports.RawCypher = exports.Return = exports.CallProcedure = exports.Call = exports.Merge = exports.Create = exports.OptionalMatch = exports.Match = void 0; | ||
exports.utils = exports.single = exports.exists = exports.all = exports.any = exports.randomUUID = exports.sum = exports.avg = exports.max = exports.min = exports.count = exports.labels = exports.time = exports.localdatetime = exports.localtime = exports.date = exports.datetime = exports.pointDistance = exports.distance = void 0; | ||
// Clauses | ||
@@ -60,2 +60,4 @@ var Match_1 = require("./clauses/Match"); | ||
Object.defineProperty(exports, "Call", { enumerable: true, get: function () { return Call_1.Call; } }); | ||
var CallProcedure_1 = require("./clauses/CallProcedure"); | ||
Object.defineProperty(exports, "CallProcedure", { enumerable: true, get: function () { return CallProcedure_1.CallProcedure; } }); | ||
var Return_1 = require("./clauses/Return"); | ||
@@ -103,2 +105,4 @@ Object.defineProperty(exports, "Return", { enumerable: true, get: function () { return Return_1.Return; } }); | ||
Object.defineProperty(exports, "PatternComprehension", { enumerable: true, get: function () { return PatternComprehension_1.PatternComprehension; } }); | ||
var ListExpr_1 = require("./expressions/list/ListExpr"); | ||
Object.defineProperty(exports, "List", { enumerable: true, get: function () { return ListExpr_1.ListExpr; } }); | ||
// --Map | ||
@@ -137,2 +141,6 @@ var MapExpr_1 = require("./expressions/map/MapExpr"); | ||
Object.defineProperty(exports, "datetime", { enumerable: true, get: function () { return CypherFunction_1.cypherDatetime; } }); | ||
Object.defineProperty(exports, "date", { enumerable: true, get: function () { return CypherFunction_1.cypherDate; } }); | ||
Object.defineProperty(exports, "localtime", { enumerable: true, get: function () { return CypherFunction_1.cypherLocalTime; } }); | ||
Object.defineProperty(exports, "localdatetime", { enumerable: true, get: function () { return CypherFunction_1.cypherLocalDatetime; } }); | ||
Object.defineProperty(exports, "time", { enumerable: true, get: function () { return CypherFunction_1.cypherTime; } }); | ||
Object.defineProperty(exports, "labels", { enumerable: true, get: function () { return CypherFunction_1.labels; } }); | ||
@@ -144,2 +152,3 @@ Object.defineProperty(exports, "count", { enumerable: true, get: function () { return CypherFunction_1.count; } }); | ||
Object.defineProperty(exports, "sum", { enumerable: true, get: function () { return CypherFunction_1.sum; } }); | ||
Object.defineProperty(exports, "randomUUID", { enumerable: true, get: function () { return CypherFunction_1.randomUUID; } }); | ||
__exportStar(require("./expressions/functions/ListFunctions"), exports); | ||
@@ -154,4 +163,4 @@ var PredicateFunctions_1 = require("./expressions/functions/PredicateFunctions"); | ||
exports.utils = { | ||
escapeLabel: escape_label_1.escapeLabel, | ||
escapeLabel: escape_label_1.escapeLabel | ||
}; | ||
//# sourceMappingURL=Cypher.js.map |
@@ -17,2 +17,6 @@ import type { Variable } from "../../variables/Variable"; | ||
export declare function cypherDatetime(): CypherFunction; | ||
export declare function cypherDate(): CypherFunction; | ||
export declare function cypherLocalDatetime(): CypherFunction; | ||
export declare function cypherLocalTime(): CypherFunction; | ||
export declare function cypherTime(): CypherFunction; | ||
export declare function count(expr: Expr): CypherFunction; | ||
@@ -23,2 +27,3 @@ export declare function min(expr: Expr): CypherFunction; | ||
export declare function sum(expr: Expr): CypherFunction; | ||
export declare function randomUUID(): CypherFunction; | ||
//# sourceMappingURL=CypherFunction.d.ts.map |
@@ -21,3 +21,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sum = exports.avg = exports.max = exports.min = exports.count = exports.cypherDatetime = exports.labels = exports.pointDistance = exports.distance = exports.point = exports.coalesce = exports.CypherFunction = void 0; | ||
exports.randomUUID = exports.sum = exports.avg = exports.max = exports.min = exports.count = exports.cypherTime = exports.cypherLocalTime = exports.cypherLocalDatetime = exports.cypherDate = exports.cypherDatetime = exports.labels = exports.pointDistance = exports.distance = exports.point = exports.coalesce = exports.CypherFunction = void 0; | ||
const CypherASTNode_1 = require("../../CypherASTNode"); | ||
@@ -65,2 +65,19 @@ class CypherFunction extends CypherASTNode_1.CypherASTNode { | ||
exports.cypherDatetime = cypherDatetime; | ||
// TODO: Add optional input to date functions - https://neo4j.com/docs/cypher-manual/current/functions/#header-query-functions-temporal-instant-types | ||
function cypherDate() { | ||
return new CypherFunction("date"); | ||
} | ||
exports.cypherDate = cypherDate; | ||
function cypherLocalDatetime() { | ||
return new CypherFunction("localdatetime"); | ||
} | ||
exports.cypherLocalDatetime = cypherLocalDatetime; | ||
function cypherLocalTime() { | ||
return new CypherFunction("localtime"); | ||
} | ||
exports.cypherLocalTime = cypherLocalTime; | ||
function cypherTime() { | ||
return new CypherFunction("time"); | ||
} | ||
exports.cypherTime = cypherTime; | ||
function count(expr) { | ||
@@ -86,2 +103,6 @@ return new CypherFunction("count", [expr]); | ||
exports.sum = sum; | ||
function randomUUID() { | ||
return new CypherFunction("randomUUID"); | ||
} | ||
exports.randomUUID = randomUUID; | ||
//# sourceMappingURL=CypherFunction.js.map |
import type { CypherEnvironment } from "../../Environment"; | ||
import type { CypherCompilable, Expr } from "../../types"; | ||
import { Variable } from "../../variables/Variable"; | ||
import type { Variable } from "../../variables/Variable"; | ||
/** Represents a Map projection https://neo4j.com/docs/cypher-manual/current/syntax/maps/#cypher-map-projection */ | ||
@@ -9,6 +9,6 @@ export declare class MapProjection implements CypherCompilable { | ||
private projection; | ||
constructor(variable: Variable, projection: Array<Variable>, extraValues?: Record<string, Expr>); | ||
set(values: Record<string, Expr> | Variable): void; | ||
constructor(variable: Variable, projection: string[], extraValues?: Record<string, Expr>); | ||
set(values: Record<string, Expr> | string): void; | ||
getCypher(env: CypherEnvironment): string; | ||
} | ||
//# sourceMappingURL=MapProjection.d.ts.map |
@@ -23,3 +23,2 @@ "use strict"; | ||
const serialize_map_1 = require("../../utils/serialize-map"); | ||
const Variable_1 = require("../../variables/Variable"); | ||
/** Represents a Map projection https://neo4j.com/docs/cypher-manual/current/syntax/maps/#cypher-map-projection */ | ||
@@ -33,3 +32,3 @@ class MapProjection { | ||
set(values) { | ||
if (values instanceof Variable_1.Variable) { | ||
if (values instanceof String) { | ||
this.projection.push(values); | ||
@@ -44,3 +43,3 @@ } | ||
const extraValuesStr = (0, serialize_map_1.serializeMap)(env, this.extraValues, true); | ||
const projectionStr = this.projection.map((v) => `.${v.getCypher(env)}`).join(", "); | ||
const projectionStr = this.projection.join(", "); | ||
const commaStr = extraValuesStr && projectionStr ? ", " : ""; | ||
@@ -47,0 +46,0 @@ return `${variableStr} { ${projectionStr}${commaStr}${extraValuesStr} }`; |
import type { CypherEnvironment } from "../../../Environment"; | ||
import { CypherASTNode } from "../../../CypherASTNode"; | ||
import type { PropertyRef, Variable } from "../../.."; | ||
import type { PropertyRef } from "../../../variables/PropertyRef"; | ||
import type { Variable } from "../../../variables/Variable"; | ||
export declare class ConvertFormat extends CypherASTNode { | ||
@@ -5,0 +6,0 @@ private temporalParam; |
@@ -13,4 +13,5 @@ import type { CypherEnvironment } from "../../Environment"; | ||
private phrase; | ||
private scoreVar; | ||
private whereClause; | ||
constructor(targetNode: NodeRef, indexName: string, phrase: Variable, parent?: Clause); | ||
constructor(targetNode: NodeRef, indexName: string, phrase: Variable, scoreVar?: Variable, parent?: Clause); | ||
where(input: Predicate): this; | ||
@@ -17,0 +18,0 @@ getCypher(env: CypherEnvironment): string; |
@@ -34,3 +34,3 @@ "use strict"; | ||
let FullTextQueryNodes = class FullTextQueryNodes extends Clause_1.Clause { | ||
constructor(targetNode, indexName, phrase, parent) { | ||
constructor(targetNode, indexName, phrase, scoreVar, parent) { | ||
super(parent); | ||
@@ -40,2 +40,3 @@ this.targetNode = targetNode; | ||
this.phrase = phrase; | ||
this.scoreVar = scoreVar; | ||
} | ||
@@ -54,6 +55,7 @@ where(input) { | ||
getCypher(env) { | ||
const targetId = env.getReferenceId(this.targetNode); | ||
const targetId = this.targetNode.getCypher(env); | ||
const scoreYield = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.scoreVar, env, { prefix: ", score AS " }); | ||
const textSearchStr = `CALL db.index.fulltext.queryNodes("${this.indexName}", ${this.phrase.getCypher(env)}) YIELD node AS ${targetId}${scoreYield}`; | ||
const whereStr = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.whereClause, env, { prefix: "\n" }); | ||
const returnStr = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.returnStatement, env, { prefix: "\n" }); | ||
const textSearchStr = `CALL db.index.fulltext.queryNodes("${this.indexName}", ${this.phrase.getCypher(env)}) YIELD node as ${targetId}`; | ||
return `${textSearchStr}${whereStr}${returnStr}`; | ||
@@ -60,0 +62,0 @@ } |
@@ -11,3 +11,3 @@ import type { PropertyRef } from "./variables/PropertyRef"; | ||
import type { PredicateFunction } from "./expressions/functions/PredicateFunctions"; | ||
import type { ApocExpr, ApocPredicate } from "./expressions/procedures/apoc/apoc"; | ||
import type { ApocExpr, ApocPredicate, ValidatePredicate } from "./expressions/procedures/apoc/apoc"; | ||
import type { Case } from "./expressions/Case"; | ||
@@ -17,3 +17,4 @@ import type { MathOp } from "./expressions/operations/math"; | ||
import type { PatternComprehension } from "./expressions/list/PatternComprehension"; | ||
import type { MapProjection } from "."; | ||
import type { ListExpr } from "./expressions/list/ListExpr"; | ||
import type { MapProjection } from "./expressions/map/MapProjection"; | ||
import type { HasLabel } from "./expressions/HasLabel"; | ||
@@ -23,5 +24,7 @@ import type { Reference } from "./variables/Reference"; | ||
export declare type VariableLike = Reference | Literal | PropertyRef; | ||
export declare type Expr = Operation | VariableLike | CypherFunction | Predicate | ListComprehension | PatternComprehension | MapExpr | MapProjection | ApocExpr; | ||
export declare type Expr = Operation | VariableLike | CypherFunction | Predicate | ListComprehension | PatternComprehension | MapExpr | MapProjection | ListExpr | ApocExpr; | ||
/** Represents a predicate statement (i.e returns a boolean). Note that RawCypher is only added for compatibility */ | ||
export declare type Predicate = BooleanOp | ComparisonOp | RawCypher | Exists | PredicateFunction | ApocPredicate | Literal<boolean> | Case | HasLabel; | ||
/** Represents a procedure invocable with the CALL statement */ | ||
export declare type Procedure = ValidatePredicate; | ||
export declare type CypherResult = { | ||
@@ -28,0 +31,0 @@ cypher: string; |
{ | ||
"name": "@neo4j/cypher-builder", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Neo4j Cypher query builder", | ||
@@ -35,3 +35,3 @@ "exports": "./dist/index.js", | ||
"devDependencies": { | ||
"@types/jest": "29.2.0", | ||
"@types/jest": "29.2.1", | ||
"@types/node": "18.11.5", | ||
@@ -38,0 +38,0 @@ "jest": "29.2.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
327399
283
4488