Skip to content

Commit

Permalink
Merge pull request #327 from neo4j/remove-internal-cypher-namespace-u…
Browse files Browse the repository at this point in the history
…sage

Remove internal Cypher namespace usage
  • Loading branch information
angrykoala committed Apr 18, 2024
2 parents 36819b2 + ebd903e commit 54fd43a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/clauses/mixins/clauses/WithMatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* limitations under the License.
*/

import type { OptionalMatch, Pattern } from "../../..";
import Cypher, { Match } from "../../..";
import type { Pattern } from "../../..";
import { Match, OptionalMatch } from "../../..";
import type { NodeRef } from "../../../references/NodeRef";
import { MixinClause } from "../Mixin";

Expand All @@ -34,7 +34,7 @@ export abstract class WithMatch extends MixinClause {
return clauseOrPattern;
}

const matchClause = new Cypher.Match(clauseOrPattern);
const matchClause = new Match(clauseOrPattern);
this.addNextClause(matchClause);

return matchClause;
Expand All @@ -44,7 +44,7 @@ export abstract class WithMatch extends MixinClause {
* @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/clauses/optional-match/)
*/
public optionalMatch(pattern: NodeRef | Pattern): OptionalMatch {
const matchClause = new Cypher.OptionalMatch(pattern);
const matchClause = new OptionalMatch(pattern);
this.addNextClause(matchClause);

return matchClause;
Expand Down
16 changes: 8 additions & 8 deletions src/expressions/IsType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/

import type Cypher from "..";
import type { Environment, Expr } from "..";
import { CypherASTNode } from "../CypherASTNode";
import { asArray } from "../utils/as-array";
import type { ValueOf } from "../utils/type-helpers";
Expand Down Expand Up @@ -72,7 +72,7 @@ export const CypherTypes = {
* val IS :: INTEGER
* ```
*/
export function isType(expr: Cypher.Expr, type: Type | Type[]): IsType {
export function isType(expr: Expr, type: Type | Type[]): IsType {
return new IsType(expr, asArray(type));
}

Expand All @@ -84,7 +84,7 @@ export function isType(expr: Cypher.Expr, type: Type | Type[]): IsType {
* val IS NOT :: INTEGER
* ```
*/
export function isNotType(expr: Cypher.Expr, type: Type | Type[]): IsType {
export function isNotType(expr: Expr, type: Type | Type[]): IsType {
return new IsType(expr, asArray(type), true);
}

Expand All @@ -101,7 +101,7 @@ class ListType {
return this;
}

public getCypher(env: Cypher.Environment): string {
public getCypher(env: Environment): string {
// Note that all types must be nullable or non nullable
const notNullStr = this._notNull ? " NOT NULL" : "";
const typesStr = this.types
Expand All @@ -117,12 +117,12 @@ class ListType {
}

export class IsType extends CypherASTNode {
private expr: Cypher.Expr;
private expr: Expr;
private types: Type[];
private not: boolean;
private _notNull: boolean = false;

public constructor(expr: Cypher.Expr, type: Type[], not = false) {
public constructor(expr: Expr, type: Type[], not = false) {
super();
this.expr = expr;
this.types = type;
Expand All @@ -134,7 +134,7 @@ export class IsType extends CypherASTNode {
return this;
}

public getCypher(env: Cypher.Environment): string {
public getCypher(env: Environment): string {
const exprCypher = env.compile(this.expr);
const isStr = this.not ? "IS NOT" : "IS";

Expand All @@ -154,7 +154,7 @@ export class IsType extends CypherASTNode {

type Type = ValueOf<typeof BaseTypes> | ListType;

function compileType(type: Type, env: Cypher.Environment): string {
function compileType(type: Type, env: Environment): string {
if (type instanceof ListType) {
return env.compile(type);
} else {
Expand Down
15 changes: 6 additions & 9 deletions src/namespaces/apoc/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
* limitations under the License.
*/

import Cypher from "../..";
import type { Expr } from "../..";
import { Literal, toString } from "../..";
import { CypherFunction } from "../../expressions/functions/CypherFunctions";

/**
Expand All @@ -32,14 +33,10 @@ import { CypherFunction } from "../../expressions/functions/CypherFunctions";
* )
*```
*/
export function convertFormat(
temporalParam: Cypher.Expr,
currentFormat: string,
convertTo = "yyyy-MM-dd"
): CypherFunction {
export function convertFormat(temporalParam: Expr, currentFormat: string, convertTo = "yyyy-MM-dd"): CypherFunction {
return new CypherFunction("apoc.date.convertFormat", [
Cypher.toString(temporalParam), // NOTE: should this be `toString` by default?
new Cypher.Literal(currentFormat),
new Cypher.Literal(convertTo),
toString(temporalParam), // NOTE: should this be `toString` by default?
new Literal(currentFormat),
new Literal(convertTo),
]);
}

0 comments on commit 54fd43a

Please sign in to comment.