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

@neo4j/cypher-builder

Package Overview
Dependencies
Maintainers
7
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.7.4 to 1.8.0

dist/clauses/sub-clauses/OnMatch.d.ts

2

dist/clauses/Merge.d.ts

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

private onCreateClause;
private onMatchClause;
constructor(pattern: NodeRef | Pattern);

@@ -29,2 +30,3 @@ /**

onCreateSet(...onCreateParams: OnCreateParam[]): this;
onMatchSet(...onMatchParams: OnCreateParam[]): this;
/** Add a {@link Merge} clause

@@ -31,0 +33,0 @@ * @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/clauses/merge/)

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

const OnCreate_1 = require("./sub-clauses/OnCreate");
const OnMatch_1 = require("./sub-clauses/OnMatch");
const mixin_1 = require("./utils/mixin");

@@ -56,2 +57,3 @@ /**

this.onCreateClause = new OnCreate_1.OnCreate(this);
this.onMatchClause = new OnMatch_1.OnMatch(this);
}

@@ -69,2 +71,6 @@ /**

}
onMatchSet(...onMatchParams) {
this.onMatchClause.addParams(...onMatchParams);
return this;
}
merge(clauseOrPattern) {

@@ -85,6 +91,7 @@ if (clauseOrPattern instanceof Merge_1) {

const onCreateCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.onCreateClause, env, { prefix: "\n" });
const onMatchCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.onMatchClause, env, { prefix: "\n" });
const deleteCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.deleteClause, env, { prefix: "\n" });
const removeCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.removeClause, env, { prefix: "\n" });
const nextClause = this.compileNextClause(env);
return `${mergeStr}${onCreateCypher}${setCypher}${removeCypher}${deleteCypher}${nextClause}`;
return `${mergeStr}${onMatchCypher}${onCreateCypher}${setCypher}${removeCypher}${deleteCypher}${nextClause}`;
}

@@ -91,0 +98,0 @@ };

10

dist/expressions/HasLabel.d.ts

@@ -0,6 +1,8 @@

import type { LabelExpr } from "..";
import { CypherASTNode } from "../CypherASTNode";
import type { CypherEnvironment } from "../Environment";
import type { NodeRef } from "../references/NodeRef";
/** Generates a predicate to check if a node has a label
* @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/syntax/expressions/#existential-subqueries)
import type { RelationshipRef } from "../references/RelationshipRef";
/** Generates a predicate to check if a node has a label or a relationship has a type
* @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/clauses/where/#filter-on-node-label)
* @group Other

@@ -19,5 +21,7 @@ * @example

*/
constructor(node: NodeRef, expectedLabels: string[]);
constructor(node: NodeRef | RelationshipRef, expectedLabels: string[] | LabelExpr);
/** @internal */
getCypher(env: CypherEnvironment): string;
private generateLabelExpressionStr;
private validateLabelsInput;
}

@@ -23,5 +23,6 @@ "use strict";

const CypherASTNode_1 = require("../CypherASTNode");
const add_label_token_1 = require("../utils/add-label-token");
const escape_1 = require("../utils/escape");
/** Generates a predicate to check if a node has a label
* @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/syntax/expressions/#existential-subqueries)
/** Generates a predicate to check if a node has a label or a relationship has a type
* @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/clauses/where/#filter-on-node-label)
* @group Other

@@ -40,4 +41,3 @@ * @example

super();
if (expectedLabels.length === 0)
throw new Error("HasLabel needs at least 1 label");
this.validateLabelsInput(expectedLabels);
this.node = node;

@@ -49,10 +49,20 @@ this.expectedLabels = expectedLabels;

const nodeId = this.node.getCypher(env);
const labelsStr = this.expectedLabels
.map((label) => {
return `:${(0, escape_1.escapeLabel)(label)}`;
})
.join("");
const labelsStr = this.generateLabelExpressionStr(env);
return `${nodeId}${labelsStr}`;
}
generateLabelExpressionStr(env) {
if (Array.isArray(this.expectedLabels)) {
const escapedLabels = this.expectedLabels.map((label) => (0, escape_1.escapeLabel)(label));
return (0, add_label_token_1.addLabelToken)(...escapedLabels);
}
else {
return (0, add_label_token_1.addLabelToken)(this.expectedLabels.getCypher(env));
}
}
validateLabelsInput(expectedLabels) {
if (Array.isArray(expectedLabels) && expectedLabels.length === 0) {
throw new Error("HasLabel needs at least 1 label");
}
}
}
exports.HasLabel = HasLabel;

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

const RelationshipRef_1 = require("../references/RelationshipRef");
const add_label_token_1 = require("../utils/add-label-token");
const escape_1 = require("../utils/escape");

@@ -75,11 +76,13 @@ const PartialPattern_1 = require("./PartialPattern");

const labelsStr = labels.getCypher(env);
if (!labelsStr)
if (!labelsStr) {
return "";
return `:${labels.getCypher(env)}`;
}
return (0, add_label_token_1.addLabelToken)(labels.getCypher(env));
}
else {
const escapedLabels = labels.map(escape_1.escapeLabel);
if (escapedLabels.length === 0)
if (escapedLabels.length === 0) {
return "";
return `:${escapedLabels.join(":")}`;
}
return (0, add_label_token_1.addLabelToken)(...escapedLabels);
}

@@ -86,0 +89,0 @@ }

@@ -17,3 +17,3 @@ import type { Expr } from "..";

hasLabels(...labels: string[]): HasLabel;
hasLabel(label: string): HasLabel;
hasLabel(label: string | LabelExpr): HasLabel;
private parseLabels;

@@ -20,0 +20,0 @@ }

@@ -38,3 +38,8 @@ "use strict";

hasLabel(label) {
return new HasLabel_1.HasLabel(this, [label]);
if (typeof label === "string") {
return new HasLabel_1.HasLabel(this, [label]);
}
else {
return new HasLabel_1.HasLabel(this, label);
}
}

@@ -41,0 +46,0 @@ parseLabels(labelsOption) {

@@ -1,3 +0,4 @@

import type { Expr } from "..";
import { HasLabel } from "../expressions/HasLabel";
import type { LabelExpr } from "../expressions/labels/label-expressions";
import type { Expr } from "../types";
import type { NodeRef } from "./NodeRef";

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

constructor(input?: RelationshipRefOptions);
hasType(label: string | LabelExpr): HasLabel;
get type(): string | LabelExpr | undefined;

@@ -23,0 +25,0 @@ }

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

exports.NamedRelationship = exports.RelationshipRef = void 0;
const HasLabel_1 = require("../expressions/HasLabel");
const Variable_1 = require("./Variable");

@@ -33,2 +34,10 @@ /** Reference to a relationship property

}
hasType(label) {
if (typeof label === "string") {
return new HasLabel_1.HasLabel(this, [label]);
}
else {
return new HasLabel_1.HasLabel(this, label);
}
}
get type() {

@@ -35,0 +44,0 @@ return this._type;

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

@@ -45,3 +45,3 @@ "exports": "./dist/index.js",

"devDependencies": {
"@changesets/changelog-github": "^0.4.8",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.26.2",

@@ -48,0 +48,0 @@ "@tsconfig/node16": "^16.1.0",

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