New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@douglasgabr/cypher-builder

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@douglasgabr/cypher-builder - npm Package Compare versions

Comparing version 3.6.0 to 3.7.0

9

CHANGELOG.md

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

# 3.7.0 / 2022-09-22
- feat(clauses): add [hint clauses](https://neo4j.com/docs/cypher-manual/current/query-tuning/using/) to query builder
- `usingIndex`
- `usingIndexSeek`
- `usingScan`
- `usingJoinOn`
- [`callInTransactions`](https://neo4j.com/docs/cypher-manual/current/clauses/call-subquery/#subquery-call-in-transactions) (previously [`USING PERIODIC COMMIT`](https://neo4j.com/docs/cypher-manual/current/query-tuning/using/#query-using-periodic-commit-hint))
# 3.6.0 / 2022-08-31

@@ -2,0 +11,0 @@

4

dist/clauses/call.clause.d.ts

@@ -7,3 +7,5 @@ import { Builder } from '..';

protected internalBuilder: Builder;
constructor(internalBuilder: Builder);
protected inTransactions: boolean;
protected inTransactionsRowsCount: number | null;
constructor(internalBuilder: Builder, inTransactions: boolean, inTransactionsRowsCount: number | null);
}

@@ -10,0 +12,0 @@ export declare class CallClauseStringBuilder extends CallClause implements StringBuilder, ShouldBeAdded {

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

class CallClause extends base_clause_1.Clause {
constructor(internalBuilder) {
constructor(internalBuilder, inTransactions, inTransactionsRowsCount) {
super('CALL');
this.internalBuilder = internalBuilder;
this.inTransactions = inTransactions;
this.inTransactionsRowsCount = inTransactionsRowsCount;
}

@@ -19,5 +21,11 @@ }

build() {
return `${this.prefix} {\n${this.internalBuilder.build()}\n}`;
const inTransactionsString = this.inTransactions
? ` IN TRANSACTIONS${typeof this.inTransactionsRowsCount === 'number' &&
this.inTransactionsRowsCount > 0
? ` OF ${this.inTransactionsRowsCount} ROWS`
: ''}`
: '';
return `${this.prefix} {\n${this.internalBuilder.build()}\n}${inTransactionsString}`;
}
}
exports.CallClauseStringBuilder = CallClauseStringBuilder;
import { StringBuilder } from '../../types/string-builder';
import { Clause } from '../base-clause';
declare type PlannerHintPrefix = 'USING INDEX' | 'USING INDEX SEEK' | 'USING SCAN' | 'USING JOIN ON' | 'USING PERIODIC COMMIT';
declare type PlannerHintPrefix = 'USING INDEX' | 'USING INDEX SEEK' | 'USING SCAN' | 'USING JOIN ON';
export declare abstract class PlannerHintClause extends Clause {

@@ -5,0 +5,0 @@ protected value: string;

@@ -0,5 +1,7 @@

import { ShouldBeAdded } from '../../types/should-be-added';
import { StringBuilder } from '../../types/string-builder';
import { PlannerHintClauseStringBuilder } from './planner-hint.clause';
export declare class UsingIndexSeekClauseStringBuilder extends PlannerHintClauseStringBuilder implements StringBuilder {
export declare class UsingIndexSeekClauseStringBuilder extends PlannerHintClauseStringBuilder implements StringBuilder, ShouldBeAdded {
__shouldBeAdded: boolean;
constructor(variable: string, label: string, fields: string[]);
}

@@ -18,4 +18,5 @@ "use strict";

super('USING INDEX SEEK', new UsingIndexSeekValueBuilder(variable, label, fields));
this.__shouldBeAdded = true;
}
}
exports.UsingIndexSeekClauseStringBuilder = UsingIndexSeekClauseStringBuilder;

@@ -0,5 +1,7 @@

import { ShouldBeAdded } from '../../types/should-be-added';
import { StringBuilder } from '../../types/string-builder';
import { PlannerHintClauseStringBuilder } from './planner-hint.clause';
export declare class UsingIndexClauseStringBuilder extends PlannerHintClauseStringBuilder implements StringBuilder {
export declare class UsingIndexClauseStringBuilder extends PlannerHintClauseStringBuilder implements StringBuilder, ShouldBeAdded {
__shouldBeAdded: boolean;
constructor(variable: string, label: string, fields: string[]);
}

@@ -18,4 +18,5 @@ "use strict";

super('USING INDEX', new UsingIndexValueBuilder(variable, label, fields));
this.__shouldBeAdded = true;
}
}
exports.UsingIndexClauseStringBuilder = UsingIndexClauseStringBuilder;

@@ -0,5 +1,7 @@

import { ShouldBeAdded } from '../../types/should-be-added';
import { StringBuilder } from '../../types/string-builder';
import { PlannerHintClauseStringBuilder } from './planner-hint.clause';
export declare class UsingJoinOnClauseStringBuilder extends PlannerHintClauseStringBuilder implements StringBuilder {
export declare class UsingJoinOnClauseStringBuilder extends PlannerHintClauseStringBuilder implements StringBuilder, ShouldBeAdded {
__shouldBeAdded: boolean;
constructor(variable: string);
}

@@ -8,4 +8,5 @@ "use strict";

super('USING JOIN ON', variable);
this.__shouldBeAdded = true;
}
}
exports.UsingJoinOnClauseStringBuilder = UsingJoinOnClauseStringBuilder;

@@ -0,5 +1,7 @@

import { ShouldBeAdded } from '../../types/should-be-added';
import { StringBuilder } from '../../types/string-builder';
import { PlannerHintClauseStringBuilder } from './planner-hint.clause';
export declare class UsingScanClauseStringBuilder extends PlannerHintClauseStringBuilder implements StringBuilder {
export declare class UsingScanClauseStringBuilder extends PlannerHintClauseStringBuilder implements StringBuilder, ShouldBeAdded {
__shouldBeAdded: boolean;
constructor(variable: string, label: string);
}

@@ -17,4 +17,5 @@ "use strict";

super('USING SCAN', new UsingScanValueBuilder(variable, label));
this.__shouldBeAdded = true;
}
}
exports.UsingScanClauseStringBuilder = UsingScanClauseStringBuilder;

@@ -5,2 +5,3 @@ import { WhereClause } from './clauses/where.clause';

import { PatternBuilder } from './patterns/PatternBuilder';
import { CypherBuilderNodes, CypherBuilderRelationships } from './types/labels-and-properties';
export * from './types/labels-and-properties';

@@ -124,2 +125,16 @@ export { literal } from './utils/literal';

/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/clauses/call-subquery/#subquery-call-in-transactions CALL IN TRANSACTIONS}
* @example
* .callInTransactions(...)
* // CALL { ... } IN TRANSACTIONS
*/
callInTransactions(builder: BuilderParameter<Builder>): this;
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/clauses/call-subquery/#_batching CALL IN TRANSACTIONS OF n ROWS}
* @example
* .callInTransactions(5, ...)
* // CALL { ... } IN TRANSACTIONS OF 5 ROWS
*/
callInTransactions(rowCount: number, builder: BuilderParameter<Builder>): this;
/**
* @param items items to order by

@@ -164,2 +179,9 @@ * @see [ORDER BY](https://neo4j.com/docs/cypher-manual/current/clauses/order-by/)

addParameter(value: unknown, alias: string): this;
usingIndex<Type extends keyof CypherBuilderRelationships & string, Fields extends keyof CypherBuilderRelationships[Type] & string>(variable: string, type: Type, fields: Fields[]): this;
usingIndex<Label extends keyof CypherBuilderNodes & string, Fields extends keyof CypherBuilderNodes[Label] & string>(variable: string, label: Label, fields: Fields[]): this;
usingIndexSeek<Type extends keyof CypherBuilderRelationships & string, Fields extends keyof CypherBuilderRelationships[Type] & string>(variable: string, type: Type, fields: Fields[]): this;
usingIndexSeek<Label extends keyof CypherBuilderNodes & string, Fields extends keyof CypherBuilderNodes[Label] & string>(variable: string, label: Label, fields: Fields[]): this;
usingScan<Type extends keyof CypherBuilderRelationships & string>(variable: string, type: Type): this;
usingScan<Label extends keyof CypherBuilderNodes & string>(variable: string, label: Label): this;
usingJoinOn(variable: string): this;
build(): string;

@@ -166,0 +188,0 @@ buildQueryObject(): {

@@ -17,3 +17,3 @@ "use strict";

};
var _Builder_instances, _Builder_addClause;
var _Builder_instances, _Builder_call, _Builder_addClause;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -40,2 +40,6 @@ exports.Builder = exports.literal = void 0;

const call_clause_1 = require("./clauses/call.clause");
const using_index_clause_1 = require("./clauses/planner-hint-clauses/using-index.clause");
const using_scan_clause_1 = require("./clauses/planner-hint-clauses/using-scan.clause");
const using_join_on_clause_1 = require("./clauses/planner-hint-clauses/using-join-on.clause");
const using_index_seek_clause_1 = require("./clauses/planner-hint-clauses/using-index-seek.clause");
__exportStar(require("./types/labels-and-properties"), exports);

@@ -186,10 +190,10 @@ var literal_1 = require("./utils/literal");

call(builder) {
const internalBuilder = new Builder();
internalBuilder.parametersBag = this.parametersBag;
internalBuilder.indent = this.indent + 2;
builder(internalBuilder);
const clause = new call_clause_1.CallClauseStringBuilder(internalBuilder);
__classPrivateFieldGet(this, _Builder_instances, "m", _Builder_addClause).call(this, clause);
return this;
return __classPrivateFieldGet(this, _Builder_instances, "m", _Builder_call).call(this, builder, false, null);
}
callInTransactions(builderOrCount, builderFallback) {
const [count, builder] = typeof builderOrCount === 'number'
? [builderOrCount, builderFallback]
: [null, builderOrCount];
return __classPrivateFieldGet(this, _Builder_instances, "m", _Builder_call).call(this, builder, true, count);
}
/**

@@ -239,2 +243,22 @@ * @param items items to order by

}
usingIndex(variable, labelOrType, fields) {
const clause = new using_index_clause_1.UsingIndexClauseStringBuilder(variable, labelOrType, fields);
__classPrivateFieldGet(this, _Builder_instances, "m", _Builder_addClause).call(this, clause);
return this;
}
usingIndexSeek(variable, labelOrType, fields) {
const clause = new using_index_seek_clause_1.UsingIndexSeekClauseStringBuilder(variable, labelOrType, fields);
__classPrivateFieldGet(this, _Builder_instances, "m", _Builder_addClause).call(this, clause);
return this;
}
usingScan(variable, labelOrType) {
const clause = new using_scan_clause_1.UsingScanClauseStringBuilder(variable, labelOrType);
__classPrivateFieldGet(this, _Builder_instances, "m", _Builder_addClause).call(this, clause);
return this;
}
usingJoinOn(variable) {
const clause = new using_join_on_clause_1.UsingJoinOnClauseStringBuilder(variable);
__classPrivateFieldGet(this, _Builder_instances, "m", _Builder_addClause).call(this, clause);
return this;
}
build() {

@@ -257,3 +281,11 @@ return this.clauses

exports.Builder = Builder;
_Builder_instances = new WeakSet(), _Builder_addClause = function _Builder_addClause(clause) {
_Builder_instances = new WeakSet(), _Builder_call = function _Builder_call(builder, inTransactions, inTransactionsRowsCount) {
const internalBuilder = new Builder();
internalBuilder.parametersBag = this.parametersBag;
internalBuilder.indent = this.indent + 2;
builder(internalBuilder);
const clause = new call_clause_1.CallClauseStringBuilder(internalBuilder, inTransactions, inTransactionsRowsCount);
__classPrivateFieldGet(this, _Builder_instances, "m", _Builder_addClause).call(this, clause);
return this;
}, _Builder_addClause = function _Builder_addClause(clause) {
if (clause.__shouldBeAdded) {

@@ -260,0 +292,0 @@ this.clauses.push(clause);

{
"name": "@douglasgabr/cypher-builder",
"version": "3.6.0",
"version": "3.7.0",
"description": "Fluent CQL builder for Neo4j",

@@ -5,0 +5,0 @@ "main": "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