Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@neo4j/cypher-builder

Package Overview
Dependencies
Maintainers
6
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@neo4j/cypher-builder - npm Package Compare versions

Comparing version 1.20.1 to 1.21.0

dist/references/Label.d.ts

6

dist/clauses/Match.d.ts

@@ -28,2 +28,3 @@ import type { CypherEnvironment } from "../Environment";

private _optional;
private shortestStatement;
constructor(pattern: Pattern | QuantifiedPath);

@@ -57,4 +58,9 @@ /** @deprecated Use {@link Pattern} instead of node: `new Cypher.Match(new Cypher.Pattern(node))` */

optionalMatch(pattern: NodeRef | Pattern): OptionalMatch;
shortest(k: number): this;
shortestGroups(k: number): this;
allShortest(): this;
any(): this;
/** @internal */
getCypher(env: CypherEnvironment): string;
private getShortestStatement;
}

@@ -61,0 +67,0 @@ /**

44

dist/clauses/Match.js

@@ -92,2 +92,28 @@ "use strict";

}
shortest(k) {
this.shortestStatement = {
type: "SHORTEST",
k,
};
return this;
}
shortestGroups(k) {
this.shortestStatement = {
type: "SHORTEST_GROUPS",
k,
};
return this;
}
allShortest() {
this.shortestStatement = {
type: "ALL SHORTEST",
};
return this;
}
any() {
this.shortestStatement = {
type: "ANY",
};
return this;
}
/** @internal */

@@ -103,4 +129,20 @@ getCypher(env) {

const optionalMatch = this._optional ? "OPTIONAL " : "";
return `${optionalMatch}MATCH ${pathAssignStr}${patternCypher}${whereCypher}${setCypher}${removeCypher}${deleteCypher}${nextClause}`;
const shortestStatement = this.getShortestStatement();
return `${optionalMatch}MATCH ${shortestStatement}${pathAssignStr}${patternCypher}${whereCypher}${setCypher}${removeCypher}${deleteCypher}${nextClause}`;
}
getShortestStatement() {
if (!this.shortestStatement) {
return "";
}
switch (this.shortestStatement.type) {
case "SHORTEST":
return `SHORTEST ${this.shortestStatement.k} `;
case "ALL SHORTEST":
return "ALL SHORTEST ";
case "SHORTEST_GROUPS":
return `SHORTEST ${this.shortestStatement.k} GROUPS `;
case "ANY":
return "ANY ";
}
}
};

@@ -107,0 +149,0 @@ exports.Match = Match;

3

dist/clauses/mixins/sub-clauses/WithRemove.d.ts

@@ -0,1 +1,2 @@

import type { Label } from "../../..";
import type { PropertyRef } from "../../../references/PropertyRef";

@@ -9,3 +10,3 @@ import { RemoveClause } from "../../sub-clauses/Remove";

*/
remove(...properties: PropertyRef[]): this;
remove(...properties: Array<PropertyRef | Label>): this;
}

@@ -0,10 +1,10 @@

import type { Label } from "../../references/Label";
import { CypherASTNode } from "../../CypherASTNode";
import type { CypherEnvironment } from "../../Environment";
import type { PropertyRef } from "../../references/PropertyRef";
export type RemoveInput = Array<PropertyRef>;
export declare class RemoveClause extends CypherASTNode {
private removeInput;
constructor(parent: CypherASTNode | undefined, removeInput: RemoveInput);
constructor(parent: CypherASTNode | undefined, removeInput: Array<PropertyRef | Label>);
/** @internal */
getCypher(env: CypherEnvironment): string;
}
import { CypherASTNode } from "../../CypherASTNode";
import type { CypherEnvironment } from "../../Environment";
import type { MapExpr } from "../../expressions/map/MapExpr";
import type { MapProjection } from "../../expressions/map/MapProjection";
import { Label } from "../../references/Label";
import type { PropertyRef } from "../../references/PropertyRef";
import type { Expr } from "../../types";
import type { MapProjection } from "../../expressions/map/MapProjection";
export type SetParam = [PropertyRef, Exclude<Expr, MapExpr | MapProjection>];
export type SetParam = [PropertyRef, Exclude<Expr, MapExpr | MapProjection>] | Label;
export declare class SetClause extends CypherASTNode {

@@ -9,0 +10,0 @@ protected params: SetParam[];

@@ -23,2 +23,3 @@ "use strict";

const CypherASTNode_1 = require("../../CypherASTNode");
const Label_1 = require("../../references/Label");
const pad_block_1 = require("../../utils/pad-block");

@@ -44,6 +45,12 @@ class SetClause extends CypherASTNode_1.CypherASTNode {

}
composeParam(env, [ref, param]) {
return `${ref.getCypher(env)} = ${param.getCypher(env)}`;
composeParam(env, setParam) {
if (setParam instanceof Label_1.Label) {
return setParam.getCypher(env);
}
else {
const [ref, param] = setParam;
return `${ref.getCypher(env)} = ${param.getCypher(env)}`;
}
}
}
exports.SetClause = SetClause;

@@ -71,4 +71,5 @@ export { Call } from "./clauses/Call";

export type { Yield } from "./procedures/Yield";
export type { Label } from "./references/Label";
export type { CypherResult, Expr, NormalizationType, Operation, Predicate } from "./types";
export type { InputArgument } from "./utils/normalize-variable";
export * as utils from "./utils/utils";
import type { Environment } from "../..";
import type { CypherCompilable } from "../../types";
export type LabelOperator = "&" | "|" | "!" | "%";
type Label = string | LabelExpr;
/**

@@ -17,3 +16,3 @@ * Label Expression

abstract getCypher(env: Environment): string;
protected compileLabel(expr: Label, env: Environment): string;
protected compileLabel(expr: string | LabelExpr, env: Environment): string;
}

@@ -32,3 +31,3 @@ declare class WildcardLabelExpr extends LabelExpr {

*/
declare function labelAnd(...labels: Label[]): LabelExpr;
declare function labelAnd(...labels: Array<string | LabelExpr>): LabelExpr;
/** Generates an `|` operator between labels or types

@@ -39,3 +38,3 @@ * @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/syntax/expressions/#label-expressions)

*/
declare function labelOr(...labels: Label[]): LabelExpr;
declare function labelOr(...labels: Array<string | LabelExpr>): LabelExpr;
/** Generates an `!` operator for a label or type

@@ -46,3 +45,3 @@ * @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/syntax/expressions/#label-expressions)

*/
declare function labelNot(label: Label): LabelExpr;
declare function labelNot(label: string | LabelExpr): LabelExpr;
export declare const labelExpr: {

@@ -49,0 +48,0 @@ and: typeof labelAnd;

import type { Expr } from "..";
import { HasLabel } from "../expressions/HasLabel";
import { LabelExpr } from "../expressions/labels/label-expressions";
import { Label } from "./Label";
import type { NamedReference } from "./Variable";

@@ -20,2 +21,3 @@ import { Variable } from "./Variable";

hasLabel(label: string | LabelExpr): HasLabel;
label(label: string): Label;
private parseLabels;

@@ -22,0 +24,0 @@ }

@@ -24,2 +24,3 @@ "use strict";

const label_expressions_1 = require("../expressions/labels/label-expressions");
const Label_1 = require("./Label");
const Variable_1 = require("./Variable");

@@ -46,2 +47,5 @@ /** Represents a node reference

}
label(label) {
return new Label_1.Label(this, label);
}
parseLabels(labelsOption) {

@@ -48,0 +52,0 @@ if (labelsOption instanceof label_expressions_1.LabelExpr)

@@ -0,1 +1,2 @@

/** Generates a string with all the labels. For example `:Movie&Film` */
export declare function addLabelToken(andToken: ":" | "&", ...labels: string[]): string;

@@ -22,2 +22,3 @@ "use strict";

exports.addLabelToken = addLabelToken;
/** Generates a string with all the labels. For example `:Movie&Film` */
function addLabelToken(andToken, ...labels) {

@@ -24,0 +25,0 @@ const firstLabel = labels.shift();

{
"name": "@neo4j/cypher-builder",
"version": "1.20.1",
"version": "1.21.0",
"description": "A programmatic API for building Cypher queries for Neo4j",

@@ -5,0 +5,0 @@ "exports": "./dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc