@neo4j/cypher-builder
Advanced tools
Comparing version 1.13.0 to 1.14.0
@@ -35,3 +35,3 @@ export { Call } from "./clauses/Call"; | ||
export { and, not, or, xor } from "./expressions/operations/boolean"; | ||
export { contains, endsWith, eq, gt, gte, inOp as in, isNotNull, isNull, lt, lte, matches, neq, startsWith, } from "./expressions/operations/comparison"; | ||
export { contains, endsWith, eq, gt, gte, inOp as in, isNormalized, isNotNormalized, isNotNull, isNull, lt, lte, matches, neq, startsWith, } from "./expressions/operations/comparison"; | ||
export { divide, minus, mod, multiply, plus, pow } from "./expressions/operations/math"; | ||
@@ -64,4 +64,4 @@ export { CypherFunction as Function } from "./expressions/functions/CypherFunctions"; | ||
export type { Yield } from "./procedures/Yield"; | ||
export type { CypherResult, Expr, Operation, Predicate } from "./types"; | ||
export type { CypherResult, Expr, NormalizationType, Operation, Predicate } from "./types"; | ||
export type { InputArgument } from "./utils/normalize-variable"; | ||
export * as utils from "./utils/utils"; |
@@ -48,4 +48,4 @@ "use strict"; | ||
exports.contains = exports.xor = exports.or = exports.not = exports.and = exports.MapProjection = exports.Map = exports.PatternComprehension = exports.List = exports.ListComprehension = exports.cdc = exports.apoc = exports.Exists = exports.Count = exports.Collect = exports.isType = exports.isNotType = exports.TYPE = exports.Case = exports.Variable = exports.NamedVariable = exports.Relationship = exports.NamedRelationship = exports.Property = exports.Path = exports.NamedPath = exports.Param = exports.NamedParam = exports.Node = exports.NamedNode = exports.true = exports.false = exports.Null = exports.Literal = exports.Pattern = exports.labelExpr = exports.concat = exports.With = exports.Use = exports.Unwind = exports.Union = exports.Return = exports.RawCypher = exports.Raw = exports.Merge = exports.OptionalMatch = exports.Match = exports.Foreach = exports.Create = exports.Call = void 0; | ||
exports.round = exports.rand = exports.radians = exports.pi = exports.log10 = exports.log = exports.isNaN = exports.haversin = exports.floor = exports.exp = exports.e = exports.degrees = exports.cot = exports.cos = exports.ceil = exports.atan2 = exports.atan = exports.asin = exports.acos = exports.abs = exports.graph = exports.sum = exports.stDevP = exports.stDev = exports.percentileDisc = exports.percentileCont = exports.min = exports.max = exports.count = exports.collect = exports.avg = exports.Function = exports.pow = exports.plus = exports.multiply = exports.mod = exports.minus = exports.divide = exports.startsWith = exports.neq = exports.matches = exports.lte = exports.lt = exports.isNull = exports.isNotNull = exports.in = exports.gte = exports.gt = exports.eq = exports.endsWith = void 0; | ||
exports.utils = exports.db = exports.VoidProcedure = exports.Procedure = exports.single = exports.none = exports.isEmpty = exports.exists = exports.any = exports.all = exports.time = exports.localtime = exports.localdatetime = exports.duration = exports.datetime = exports.date = exports.tan = exports.sqrt = exports.sin = exports.sign = void 0; | ||
exports.radians = exports.pi = exports.log10 = exports.log = exports.isNaN = exports.haversin = exports.floor = exports.exp = exports.e = exports.degrees = exports.cot = exports.cos = exports.ceil = exports.atan2 = exports.atan = exports.asin = exports.acos = exports.abs = exports.graph = exports.sum = exports.stDevP = exports.stDev = exports.percentileDisc = exports.percentileCont = exports.min = exports.max = exports.count = exports.collect = exports.avg = exports.Function = exports.pow = exports.plus = exports.multiply = exports.mod = exports.minus = exports.divide = exports.startsWith = exports.neq = exports.matches = exports.lte = exports.lt = exports.isNull = exports.isNotNull = exports.isNotNormalized = exports.isNormalized = exports.in = exports.gte = exports.gt = exports.eq = exports.endsWith = void 0; | ||
exports.utils = exports.db = exports.VoidProcedure = exports.Procedure = exports.single = exports.none = exports.isEmpty = exports.exists = exports.any = exports.all = exports.time = exports.localtime = exports.localdatetime = exports.duration = exports.datetime = exports.date = exports.tan = exports.sqrt = exports.sin = exports.sign = exports.round = exports.rand = void 0; | ||
// Clauses | ||
@@ -149,2 +149,4 @@ var Call_1 = require("./clauses/Call"); | ||
Object.defineProperty(exports, "in", { enumerable: true, get: function () { return comparison_1.inOp; } }); | ||
Object.defineProperty(exports, "isNormalized", { enumerable: true, get: function () { return comparison_1.isNormalized; } }); | ||
Object.defineProperty(exports, "isNotNormalized", { enumerable: true, get: function () { return comparison_1.isNotNormalized; } }); | ||
Object.defineProperty(exports, "isNotNull", { enumerable: true, get: function () { return comparison_1.isNotNull; } }); | ||
@@ -151,0 +153,0 @@ Object.defineProperty(exports, "isNull", { enumerable: true, get: function () { return comparison_1.isNull; } }); |
@@ -1,2 +0,2 @@ | ||
import type { Expr } from "../../types"; | ||
import type { Expr, NormalizationType } from "../../types"; | ||
import { CypherFunction } from "./CypherFunctions"; | ||
@@ -19,3 +19,11 @@ /** | ||
* @category String | ||
* @param normalForm - A string with the normal form to use or a Cypher expression | ||
* @example `Cypher.normalize(param, "NFC")` | ||
*/ | ||
export declare function normalize(input: Expr, normalForm?: NormalizationType | Expr): CypherFunction; | ||
/** | ||
* @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/functions/string/) | ||
* @group Cypher Functions | ||
* @category String | ||
*/ | ||
export declare function replace(original: Expr, search: Expr, replace: Expr): CypherFunction; | ||
@@ -22,0 +30,0 @@ /** |
@@ -21,4 +21,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.trim = exports.toUpper = exports.toStringOrNull = exports.toString = exports.toLower = exports.substring = exports.split = exports.rTrim = exports.right = exports.replace = exports.lTrim = exports.left = void 0; | ||
exports.trim = exports.toUpper = exports.toStringOrNull = exports.toString = exports.toLower = exports.substring = exports.split = exports.rTrim = exports.right = exports.replace = exports.normalize = exports.lTrim = exports.left = void 0; | ||
const filter_truthy_1 = require("../../utils/filter-truthy"); | ||
const normalize_variable_1 = require("../../utils/normalize-variable"); | ||
const CypherFunctions_1 = require("./CypherFunctions"); | ||
@@ -47,3 +48,15 @@ /** | ||
* @category String | ||
* @param normalForm - A string with the normal form to use or a Cypher expression | ||
* @example `Cypher.normalize(param, "NFC")` | ||
*/ | ||
function normalize(input, normalForm) { | ||
const normalFormExpr = normalForm ? (0, normalize_variable_1.normalizeExpr)(normalForm) : undefined; | ||
return new CypherFunctions_1.CypherFunction("normalize", (0, filter_truthy_1.filterTruthy)([input, normalFormExpr])); | ||
} | ||
exports.normalize = normalize; | ||
/** | ||
* @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/functions/string/) | ||
* @group Cypher Functions | ||
* @category String | ||
*/ | ||
function replace(original, search, replace) { | ||
@@ -50,0 +63,0 @@ return new CypherFunctions_1.CypherFunction("replace", [original, search, replace]); |
@@ -1,5 +0,5 @@ | ||
import type { Expr } from "../../types"; | ||
import { CypherASTNode } from "../../CypherASTNode"; | ||
import type { CypherEnvironment } from "../../Environment"; | ||
import { CypherASTNode } from "../../CypherASTNode"; | ||
type ComparisonOperator = "=" | "<" | ">" | "<>" | "<=" | ">=" | "IS NULL" | "IS NOT NULL" | "IN" | "CONTAINS" | "STARTS WITH" | "ENDS WITH" | "=~"; | ||
import type { Expr, NormalizationType } from "../../types"; | ||
type ComparisonOperator = "=" | "<" | ">" | "<>" | "<=" | ">=" | "IS NULL" | "IS NOT NULL" | "IN" | "CONTAINS" | "STARTS WITH" | "ENDS WITH" | "=~" | "IS NORMALIZED" | "IS NOT NORMALIZED"; | ||
/** | ||
@@ -9,5 +9,5 @@ * @group Internal | ||
export declare class ComparisonOp extends CypherASTNode { | ||
private operator; | ||
private leftExpr; | ||
private rightExpr; | ||
protected operator: ComparisonOperator; | ||
protected leftExpr: Expr; | ||
protected rightExpr: Expr | undefined; | ||
constructor(operator: ComparisonOperator, left: Expr, right: Expr | undefined); | ||
@@ -19,2 +19,10 @@ /** | ||
} | ||
export declare class NormalizationOperator extends ComparisonOp { | ||
private normalizationType; | ||
constructor(operator: "IS NORMALIZED" | "IS NOT NORMALIZED", left: Expr, normalizationType: NormalizationType | undefined); | ||
/** | ||
* @hidden | ||
*/ | ||
getCypher(env: CypherEnvironment): string; | ||
} | ||
/** Equality (=) operator | ||
@@ -106,2 +114,14 @@ * @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/syntax/operators/#query-operators-comparison) | ||
export declare function matches(leftExpr: Expr, rightExpr: Expr): ComparisonOp; | ||
/** `IS NORMALIZED` operator | ||
* @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/syntax/operators/#query-operators-comparison) | ||
* @group Operators | ||
* @category Comparison | ||
*/ | ||
export declare function isNormalized(leftExpr: Expr, normalizationType?: NormalizationType): ComparisonOp; | ||
/** `IS NOT NORMALIZED` operator | ||
* @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/syntax/operators/#query-operators-comparison) | ||
* @group Operators | ||
* @category Comparison | ||
*/ | ||
export declare function isNotNormalized(leftExpr: Expr, normalizationType?: NormalizationType): ComparisonOp; | ||
export {}; |
@@ -21,3 +21,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.matches = exports.endsWith = exports.startsWith = exports.contains = exports.inOp = exports.isNotNull = exports.isNull = exports.lte = exports.lt = exports.gte = exports.gt = exports.neq = exports.eq = exports.ComparisonOp = void 0; | ||
exports.isNotNormalized = exports.isNormalized = exports.matches = exports.endsWith = exports.startsWith = exports.contains = exports.inOp = exports.isNotNull = exports.isNull = exports.lte = exports.lt = exports.gte = exports.gt = exports.neq = exports.eq = exports.NormalizationOperator = exports.ComparisonOp = void 0; | ||
const CypherASTNode_1 = require("../../CypherASTNode"); | ||
@@ -44,2 +44,18 @@ /** | ||
exports.ComparisonOp = ComparisonOp; | ||
class NormalizationOperator extends ComparisonOp { | ||
constructor(operator, left, normalizationType) { | ||
super(operator, left, undefined); | ||
this.normalizationType = normalizationType; | ||
} | ||
/** | ||
* @hidden | ||
*/ | ||
getCypher(env) { | ||
const leftStr = `${this.leftExpr.getCypher(env)} `; | ||
const notStr = this.operator === "IS NOT NORMALIZED" ? "NOT " : ""; | ||
const typeStr = this.normalizationType ? `${this.normalizationType} ` : ""; | ||
return `${leftStr}IS ${notStr}${typeStr}NORMALIZED`; | ||
} | ||
} | ||
exports.NormalizationOperator = NormalizationOperator; | ||
function createOp(op, leftExpr, rightExpr) { | ||
@@ -173,1 +189,19 @@ return new ComparisonOp(op, leftExpr, rightExpr); | ||
exports.matches = matches; | ||
/** `IS NORMALIZED` operator | ||
* @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/syntax/operators/#query-operators-comparison) | ||
* @group Operators | ||
* @category Comparison | ||
*/ | ||
function isNormalized(leftExpr, normalizationType) { | ||
return new NormalizationOperator("IS NORMALIZED", leftExpr, normalizationType); | ||
} | ||
exports.isNormalized = isNormalized; | ||
/** `IS NOT NORMALIZED` operator | ||
* @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/syntax/operators/#query-operators-comparison) | ||
* @group Operators | ||
* @category Comparison | ||
*/ | ||
function isNotNormalized(leftExpr, normalizationType) { | ||
return new NormalizationOperator("IS NOT NORMALIZED", leftExpr, normalizationType); | ||
} | ||
exports.isNotNormalized = isNotNormalized; |
@@ -6,2 +6,3 @@ import type { Expr } from "../.."; | ||
* @group Procedures | ||
* @deprecated Use {@link db.cdc.current} instead | ||
*/ | ||
@@ -12,2 +13,3 @@ export declare function current(): CypherProcedure<"id">; | ||
* @group Procedures | ||
* @deprecated Use {@link db.cdc.earliest} instead | ||
*/ | ||
@@ -18,3 +20,4 @@ export declare function earliest(): CypherProcedure<"id">; | ||
* @group Procedures | ||
* @deprecated Use {@link db.cdc.query} instead | ||
*/ | ||
export declare function query(from: string | Expr, selectors?: Array<Expr>): CypherProcedure<"id" | "txId" | "seq" | "metadata" | "event">; |
@@ -27,2 +27,3 @@ "use strict"; | ||
* @group Procedures | ||
* @deprecated Use {@link db.cdc.current} instead | ||
*/ | ||
@@ -36,2 +37,3 @@ function current() { | ||
* @group Procedures | ||
* @deprecated Use {@link db.cdc.earliest} instead | ||
*/ | ||
@@ -45,2 +47,3 @@ function earliest() { | ||
* @group Procedures | ||
* @deprecated Use {@link db.cdc.query} instead | ||
*/ | ||
@@ -47,0 +50,0 @@ function query(from, selectors = []) { |
import { CypherFunction } from "../../expressions/functions/CypherFunctions"; | ||
import { CypherProcedure } from "../../procedures/CypherProcedure"; | ||
import type { Expr } from "../../types"; | ||
export * as cdc from "./cdc"; | ||
export * as index from "./dbIndex"; | ||
@@ -5,0 +6,0 @@ /** Returns all labels in the database |
@@ -44,6 +44,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.nameFromElementId = exports.labels = exports.index = void 0; | ||
exports.nameFromElementId = exports.labels = exports.index = exports.cdc = void 0; | ||
const CypherFunctions_1 = require("../../expressions/functions/CypherFunctions"); | ||
const CypherProcedure_1 = require("../../procedures/CypherProcedure"); | ||
const normalize_variable_1 = require("../../utils/normalize-variable"); | ||
exports.cdc = __importStar(require("./cdc")); | ||
exports.index = __importStar(require("./dbIndex")); | ||
@@ -50,0 +51,0 @@ /** Returns all labels in the database |
@@ -34,2 +34,3 @@ import type { Raw, RawCypher } from "."; | ||
}; | ||
export type NormalizationType = "NFC" | "NFD" | "NFKC" | "NFKD"; | ||
/** Defines the interface for a class that can be compiled into Cypher */ | ||
@@ -36,0 +37,0 @@ export interface CypherCompilable { |
{ | ||
"name": "@neo4j/cypher-builder", | ||
"version": "1.13.0", | ||
"version": "1.14.0", | ||
"description": "A programmatic API for building Cypher queries for Neo4j", | ||
@@ -5,0 +5,0 @@ "exports": "./dist/index.js", |
418152
219
10212