"use strict";
+
+/**
+ * @typedef {import('./node')} Node
+ */
+
/**
* An edge connecting two nodes.
*/
class Edge {
/**
* Builds an Edge object.
- * @constructor
* @param {Node} srcNode - Source node of the edge.
* @param {string} relation - Relationship type of the edge.
* @param {Node} destNode - Destination node of the edge.
@@ -49,7 +53,7 @@ Source: edge.js
/**
* Sets the edge ID.
- * @param {int} id
+ * @param {number} id (integer)
*/
setId(id) {
this.id = id;
@@ -74,13 +78,13 @@ Source: edge.js
diff --git a/docs/global.html b/docs/global.html
index a955408722..510847a8d9 100644
--- a/docs/global.html
+++ b/docs/global.html
@@ -98,7 +98,7 @@ Members
-Label
+(readonly) Label :string
@@ -109,6 +109,555 @@ LabelType:
+
+ -
+
+string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+(constant) ResultSetColumnTypes :number
+
+
+
+
+
+
+ Type:
+
+ -
+
+number
+
+
+
+
+
+
+
+
+
+ Properties:
+
+
+
+
+
+
+
+ Name
+
+
+ Type
+
+
+
+
+
+ Description
+
+
+
+
+
+
+
+
+ COLUMN_UNKNOWN
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ COLUMN_SCALAR
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ COLUMN_NODE
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ COLUMN_RELATION
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+ -
+ resultSet.js, line 18
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+(constant) ResultSetValueTypes :number
+
+
+
+
+
+
+ Type:
+
+ -
+
+number
+
+
+
+
+
+
+
+
+
+ Properties:
+
+
+
+
+
+
+
+ Name
+
+
+ Type
+
+
+
+
+
+ Description
+
+
+
+
+
+
+
+
+ VALUE_UNKNOWN
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ VALUE_NULL
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ VALUE_STRING
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ VALUE_INTEGER
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ VALUE_BOOLEAN
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ VALUE_DOUBLE
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ VALUE_ARRAY
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ VALUE_EDGE
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ VALUE_NODE
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ VALUE_PATH
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ VALUE_MAP
+
+
+
+
+
+number
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -142,7 +691,7 @@ LabelSource:
-
- label.js, line 5
+ resultSet.js, line 29
@@ -176,13 +725,13 @@ Label
diff --git a/docs/graph.js.html b/docs/graph.js.html
index f2eaa07f98..83d7b10544 100644
--- a/docs/graph.js.html
+++ b/docs/graph.js.html
@@ -27,7 +27,9 @@ Source: graph.js
"use strict";
+
const redis = require("redis"),
+ // @ts-ignore
util = require("util"),
ResultSet = require("./resultSet");
@@ -40,9 +42,9 @@ Source: graph.js
* See: node_redis for more options on createClient
*
* @param {string} graphId the graph id
- * @param {string | RedisClient} [host] Redis host or node_redis client
- * @param {string | int} [port] Redis port
- * @param {ClientOpts} [options] node_redis options
+ * @param {string | redis.RedisClient} [host] Redis host or node_redis client TODO RedisClient
+ * @param {string | number} [port] Redis port (integer)
+ * @param {Object} [options] node_redis options
*/
constructor(graphId, host, port, options) {
this._graphId = graphId; // Graph ID
@@ -83,7 +85,7 @@ Source: graph.js
/**
* Transforms a parameter value to string.
- * @param {object} paramValue
+ * @param {*} paramValue
* @returns {string} the string representation of paramValue.
*/
paramToString(paramValue) {
@@ -128,7 +130,7 @@ Source: graph.js
* @async
* @param {string} query Cypher query
* @param {Map} [params] Parameters map
- * @returns {ResultSet} a promise contains a result set
+ * @returns {Promise<ResultSet>} a promise contains a result set
*/
async query(query, params) {
if (params) {
@@ -146,7 +148,7 @@ Source: graph.js
/**
* Deletes the entire graph
* @async
- * @returns {ResultSet} a promise contains the delete operation running time statistics
+ * @returns {Promise<ResultSet>} a promise contains the delete operation running time statistics
*/
async deleteGraph() {
var res = await this._sendCommand("graph.DELETE", [this._graphId]);
@@ -163,7 +165,7 @@ Source: graph.js
* @param {string} procedure Procedure to call
* @param {string[]} [args] Arguments to pass
* @param {string[]} [y] Yield outputs
- * @returns {ResultSet} a promise contains the procedure result set data
+ * @returns {Promise<ResultSet>} a promise contains the procedure result set data
*/
callProcedure(procedure, args = new Array(), y = new Array()) {
let q = "CALL " + procedure + "(" + args.join(",") + ")" + y.join(" ");
@@ -226,7 +228,7 @@ Source: graph.js
/**
* Retrieves label by ID.
- * @param {int} id internal ID of label.
+ * @param {number} id internal ID of label. (integer)
* @returns {string} String label.
*/
getLabel(id) {
@@ -236,8 +238,8 @@ Source: graph.js
/**
* Retrieve all the labels from the graph and returns the wanted label
* @async
- * @param {int} id internal ID of label.
- * @returns {string} String label.
+ * @param {number} id internal ID of label. (integer)
+ * @returns {Promise<string>} String label.
*/
async fetchAndGetLabel(id) {
await this.labels();
@@ -246,8 +248,8 @@ Source: graph.js
/**
* Retrieves relationship type by ID.
- * @param {int} id internal ID of relationship type.
- * @return String relationship type.
+ * @param {number} id internal ID of relationship type. (integer)
+ * @returns {string} relationship type.
*/
getRelationship(id) {
return this._relationshipTypes[id];
@@ -256,8 +258,8 @@ Source: graph.js
/**
* Retrieves al the relationships types from the graph, and returns the wanted type
* @async
- * @param {int} id internal ID of relationship type.
- * @returns {string} String relationship type.
+ * @param {number} id internal ID of relationship type. (integer)
+ * @returns {Promise<string>} String relationship type.
*/
async fetchAndGetRelationship(id) {
await this.relationshipTypes();
@@ -266,7 +268,7 @@ Source: graph.js
/**
* Retrieves property name by ID.
- * @param {int} id internal ID of property.
+ * @param {number} id internal ID of property. (integer)
* @returns {string} String property.
*/
getProperty(id) {
@@ -275,9 +277,9 @@ Source: graph.js
/**
* Retrieves al the properties from the graph, and returns the wanted property
- * @async
- * @param {int} id internal ID of property.
- * @returns {string} String property.
+ * @asyncTODO
+ * @param {number} id internal ID of property. (integer)
+ * @returns {Promise<string>} String property.
*/
async fetchAndGetProperty(id) {
await this.propertyKeys();
@@ -296,13 +298,13 @@ Source: graph.js
diff --git a/docs/index.html b/docs/index.html
index c51eb37e60..45c451b13a 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -119,13 +119,13 @@ License
diff --git a/docs/label.js.html b/docs/label.js.html
index 1a677128b1..4c5405dba8 100644
--- a/docs/label.js.html
+++ b/docs/label.js.html
@@ -27,8 +27,11 @@ Source: label.js
"use strict";
+
/**
* Different Statistics labels
+ * @readonly
+ * @enum {string}
*/
var Label = Object.freeze({
LABELS_ADDED: "Labels added",
@@ -54,13 +57,13 @@ Source: label.js
diff --git a/docs/node.js.html b/docs/node.js.html
index 3beeb1d796..5beb75c29c 100644
--- a/docs/node.js.html
+++ b/docs/node.js.html
@@ -27,13 +27,14 @@ Source: node.js
"use strict";
+
/**
- * A node within the garph.
+ * A node within the graph.
*/
class Node {
/**
* Builds a node object.
- * @constructor
+ *
* @param {string} label - node label.
* @param {Map} properties - properties map.
*/
@@ -45,7 +46,7 @@ Source: node.js
/**
* Sets the node id.
- * @param {int} id
+ * @param {number} id (integer)
*/
setId(id) {
this.id = id;
@@ -70,13 +71,13 @@ Source: node.js
diff --git a/docs/path.js.html b/docs/path.js.html
index 03d7bbd318..e12949658f 100644
--- a/docs/path.js.html
+++ b/docs/path.js.html
@@ -27,9 +27,17 @@ Source: path.js
"use strict";
+
+/**
+ * @typedef {import('./node')} Node
+ */
+
+/**
+ * @typedef {import('./edge')} Edge
+ */
+
class Path {
/**
- * @constructor
* @param {Node[]} nodes - path's node list.
* @param {Edge[]} edges - path's edge list.
*/
@@ -56,7 +64,7 @@ Source: path.js
/**
* Returns a node in a given index.
- * @param {int} index
+ * @param {number} index (integer)
* @returns {Node} node in the given index.
*/
getNode(index) {
@@ -65,7 +73,7 @@ Source: path.js
/**
* Returns an edge in a given index.
- * @param {int} index
+ * @param {number} index (integer)
* @returns {Edge} edge in a given index.
*/
getEdge(index) {
@@ -90,7 +98,7 @@ Source: path.js
/**
* Returns the amount of nodes in th path.
- * @returns {int} amount of nodes.
+ * @returns {number} amount of nodes. (integer)
*/
get nodeCount() {
return this.nodes.length;
@@ -98,7 +106,7 @@ Source: path.js
/**
* Returns the amount of edges in the path.
- * @returns {int} amount of edges.
+ * @returns {number} amount of edges. (integer)
*/
get edgeCount() {
return this.edges.length;
@@ -124,13 +132,13 @@ Source: path.js
diff --git a/docs/record.js.html b/docs/record.js.html
index b5f168fecf..94d02e2a17 100644
--- a/docs/record.js.html
+++ b/docs/record.js.html
@@ -27,13 +27,14 @@ Source: record.js
"use strict";
+
/**
* Hold a query record
*/
class Record {
/**
* Builds a Record object
- * @constructor
+ *
* @param {string[]} header
* @param {object[]} values
*/
@@ -44,7 +45,7 @@ Source: record.js
/**
* Returns a value of the given schema key or in the given position.
- * @param {string | int} key
+ * @param {string | number} key (integer)
* @returns {object} Requested value.
*/
get(key) {
@@ -57,7 +58,7 @@ Source: record.js
/**
* Returns a string representation for the value of the given schema key or in the given position.
- * @param {string | int} key
+ * @param {string | number} key (integer)
* @returns {string} Requested string representation of the value.
*/
getString(key) {
@@ -98,7 +99,7 @@ Source: record.js
}
/**
- * @returns {int} The amount of values in the record.
+ * @returns {number} The amount of values in the record. (integer)
*/
size() {
return this._header.length;
@@ -116,13 +117,13 @@ Source: record.js
diff --git a/docs/resultSet.js.html b/docs/resultSet.js.html
index 8772a3729e..6f85663082 100644
--- a/docs/resultSet.js.html
+++ b/docs/resultSet.js.html
@@ -27,6 +27,11 @@ Source: resultSet.js
"use strict";
+
+/**
+ * @typedef {import('./graph')} Graph
+ */
+
const Statistics = require("./statistics"),
Record = require("./record"),
Node = require("./node"),
@@ -34,6 +39,10 @@ Source: resultSet.js
Path = require("./path"),
ReplyError = require("redis").ReplyError;
+/**
+ * @enum {number}
+ * @readonly
+ */
const ResultSetColumnTypes = {
COLUMN_UNKNOWN: 0,
COLUMN_SCALAR: 1,
@@ -41,6 +50,10 @@ Source: resultSet.js
COLUMN_RELATION: 3,
};
+/**
+ * @enum {number}
+ * @readonly
+ */
const ResultSetValueTypes = {
VALUE_UNKNOWN: 0,
VALUE_NULL: 1,
@@ -61,7 +74,7 @@ Source: resultSet.js
class ResultSet {
/**
* Builds an empty ResultSet object.
- * @constructor
+ *
* @param {Graph} graph
*/
constructor(graph) {
@@ -160,7 +173,7 @@ Source: resultSet.js
* Parse raw entity properties representation into a Map
* @async
* @param {object[]} props raw properties representation
- * @returns {Map} Map with the parsed properties.
+ * @returns {Promise<object>} Map with the parsed properties.
*/
async parseEntityProperties(props) {
// [[name, value, value type] X N]
@@ -191,7 +204,7 @@ Source: resultSet.js
* Parse raw node representation into a Node object.
* @async
* @param {object[]} cell raw node representation.
- * @returns {Node} Node object.
+ * @returns {Promise<Node>} Node object.
*/
async parseNode(cell) {
// Node ID (integer),
@@ -221,7 +234,7 @@ Source: resultSet.js
* Parse a raw edge representation into an Edge object.
* @async
* @param {object[]} cell raw edge representation
- * @returns {Edge} Edge object.
+ * @returns {Promise<Edge>} Edge object.
*/
async parseEdge(cell) {
// Edge ID (integer),
@@ -256,7 +269,7 @@ Source: resultSet.js
* Parse and in-place replace raw array into an array of values or objects.
* @async
* @param {object[]} rawArray raw array representation
- * @returns {object[]} Parsed array.
+ * @returns {Promise<object[]>} Parsed array.
*/
async parseArray(rawArray) {
for (var i = 0; i < rawArray.length; i++) {
@@ -269,7 +282,7 @@ Source: resultSet.js
* Parse a raw path representation into Path object.
* @async
* @param {object[]} rawPath raw path representation
- * @returns {Path} Path object.
+ * @returns {Promise<Path>} Path object.
*/
async parsePath(rawPath) {
let nodes = await this.parseScalar(rawPath[0]);
@@ -281,7 +294,7 @@ Source: resultSet.js
* Parse a raw map representation into Map object.
* @async
* @param {object[]} rawMap raw map representation
- * @returns {Map} Map object.
+ * @returns {Promise<object>} Map object.
*/
async parseMap(rawMap) {
let m = {};
@@ -297,7 +310,7 @@ Source: resultSet.js
* Parse a raw value into its actual value.
* @async
* @param {object[]} cell raw value representation
- * @returns {object} Actual value - scalar, array, Node, Edge, Path
+ * @returns {Promise<object>} Actual value - scalar, array, Node, Edge, Path
*/
async parseScalar(cell) {
let scalar_type = cell[0];
@@ -377,7 +390,7 @@ Source: resultSet.js
}
/**
- * @returns {int} Result set size.
+ * @returns {number} Result set size. (integer)
*/
size() {
return this._resultsCount;
@@ -395,13 +408,13 @@ Source: resultSet.js
diff --git a/docs/statistics.js.html b/docs/statistics.js.html
index 607db84675..11397568f6 100644
--- a/docs/statistics.js.html
+++ b/docs/statistics.js.html
@@ -27,6 +27,7 @@ Source: statistics.js
"use strict";
+
const Label = require("./label");
class Statistics {
@@ -41,7 +42,7 @@ Source: statistics.js
/**
* Returns a statistics value according to the statistics label.
- * @param {Label} label - Statistics label.
+ * @param {import('./label')} label - Statistics label.
*/
getStringValue(label) {
return this.getStatistics()[label];
@@ -49,7 +50,7 @@ Source: statistics.js
/**
* Return the query statistics
- * @return {Statistics} statistics object
+ * @return {Object<string, string>} statistics object
*/
getStatistics() {
if (!this._statistics) {
@@ -64,8 +65,8 @@ Source: statistics.js
/**
* Returns the integer value of a requested label.
- * @param {Label} label
- * @returns {int} The actual value if exists, 0 otherwise.
+ * @param {import('./label')} label
+ * @returns {number} The actual value if exists, 0 otherwise. (integer)
*/
getIntValue(label) {
let value = this.getStringValue(label);
@@ -74,8 +75,8 @@ Source: statistics.js
/**
* Returns the float value of a requested label.
- * @param {Label} label
- * @returns {float} The actual value if exists, 0 otherwise.
+ * @param {import('./label')} label
+ * @returns {number} The actual value if exists, 0 otherwise.
*/
getFloatValue(label) {
let value = this.getStringValue(label);
@@ -83,56 +84,56 @@ Source: statistics.js
}
/**
- * @returns {int} The amount of nodes created by th query.
+ * @returns {number} The amount of nodes created by th query. (integer)
*/
nodesCreated() {
return this.getIntValue(Label.NODES_CREATED);
}
/**
- * @returns {int} The amount of nodes deleted by the query.
+ * @returns {number} The amount of nodes deleted by the query. (integer)
*/
nodesDeleted() {
return this.getIntValue(Label.NODES_DELETED);
}
/**
- * @returns {int} The amount of labels created by the query.
+ * @returns {number} The amount of labels created by the query. (integer)
*/
labelsAdded() {
return this.getIntValue(Label.LABELS_ADDED);
}
/**
- * @returns {int} The amount of relationships deleted by the query.
+ * @returns {number} The amount of relationships deleted by the query. (integer)
*/
relationshipsDeleted() {
return this.getIntValue(Label.RELATIONSHIPS_DELETED);
}
/**
- * @returns {int} The amount of relationships created by the query.
+ * @returns {number} The amount of relationships created by the query. (integer)
*/
relationshipsCreated() {
return this.getIntValue(Label.RELATIONSHIPS_CREATED);
}
/**
- * @returns {int} The amount of properties set by the query.
+ * @returns {number} The amount of properties set by the query. (integer)
*/
propertiesSet() {
return this.getIntValue(Label.PROPERTIES_SET);
}
/**
- * @returns {int} The amount of indices created by the query.
+ * @returns {number} The amount of indices created by the query. (integer)
*/
indicesCreated() {
return this.getIntValue(Label.INDICES_CREATED);
}
/**
- * @returns {int} The amount of indices deleted by the query.
+ * @returns {number} The amount of indices deleted by the query. (integer)
*/
indicesDeleted() {
return this.getIntValue(Label.INDICES_DELETED);
@@ -146,7 +147,7 @@ Source: statistics.js
}
/**
- * @returns {float} The query execution time in ms.
+ * @returns {number} The query execution time in ms.
*/
queryExecutionTime() {
return this.getFloatValue(Label.QUERY_INTERNAL_EXECUTION_TIME);
@@ -164,13 +165,13 @@ Source: statistics.js
diff --git a/examples/package.json b/examples/package.json
index e4bcb55f1c..c531f6ad11 100644
--- a/examples/package.json
+++ b/examples/package.json
@@ -11,5 +11,8 @@
"dependencies": {
"redisgraph.js": "../"
},
- "main": "redisGraphExample.js"
+ "main": "redisGraphExample.js",
+ "devDependencies": {
+ "@types/node": "^14.14.28"
+ }
}
diff --git a/examples/redisGraphExample.ts b/examples/redisGraphExample.ts
new file mode 100644
index 0000000000..afc973c8b4
--- /dev/null
+++ b/examples/redisGraphExample.ts
@@ -0,0 +1,45 @@
+const RedisGraph = require("redisgraph.js").Graph;
+
+let graph = new RedisGraph("social");
+
+try {
+ (async () => {
+ await graph.query("CREATE (:person{name:'roi',age:32})");
+ await graph.query("CREATE (:person{name:'amit',age:30})");
+ await graph.query(
+ "MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[:knows]->(b)"
+ );
+
+ // Match query.
+ let res = await graph.query(
+ "MATCH (a:person)-[:knows]->(:person) RETURN a.name"
+ );
+ while (res.hasNext()) {
+ let record = res.next();
+ console.log(record.get("a.name"));
+ }
+ console.log(res.getStatistics().queryExecutionTime());
+
+ // Match with parameters.
+ let param = { age: 30 };
+ res = await graph.query("MATCH (a {age: $age}) return a.name", param);
+ while (res.hasNext()) {
+ let record = res.next();
+ console.log(record.get("a.name"));
+ }
+
+ // Named paths matching.
+ res = await graph.query(
+ "MATCH p = (a:person)-[:knows]->(:person) RETURN p"
+ );
+ while (res.hasNext()) {
+ let record = res.next();
+ // See path.js for more path API.
+ console.log(record.get("p").nodeCount);
+ }
+ graph.deleteGraph();
+ graph.close();
+ })();
+} catch (err) {
+ console.log(err);
+}
diff --git a/jsdoc.conf.json b/jsdoc.conf.json
new file mode 100644
index 0000000000..a073de315c
--- /dev/null
+++ b/jsdoc.conf.json
@@ -0,0 +1,6 @@
+{
+ "plugins": ["jsdoc-ts-utils"],
+ "tsUtils": {
+ "typeScriptUtilityTypes": false
+ }
+}
diff --git a/package.json b/package.json
index e001e8a86b..4383b11a90 100644
--- a/package.json
+++ b/package.json
@@ -13,11 +13,14 @@
"redis": "^3.0.2"
},
"devDependencies": {
+ "jsdoc-ts-utils": "^1.1.2",
"mocha": "^7.0.1",
"typescript": "^4.1.5"
},
"scripts": {
- "test": "mocha --exit"
+ "test": "mocha --exit",
+ "types": "tsc",
+ "docs": "jsdoc -c jsdoc.conf.json ./src -r -d ./docs -R ./README.md"
},
"main": "index.js",
"types": "./types"
diff --git a/src/edge.js b/src/edge.js
index da769ffc72..4d950b62d6 100644
--- a/src/edge.js
+++ b/src/edge.js
@@ -1,14 +1,18 @@
"use strict";
-/*
+
+/**
+ * @typedef {import('./node')} Node
+ */
+
+/**
* An edge connecting two nodes.
*/
class Edge {
/**
* Builds an Edge object.
- * @constructor
- * @param {import('./node')} srcNode - Source node of the edge.
+ * @param {Node} srcNode - Source node of the edge.
* @param {string} relation - Relationship type of the edge.
- * @param {import('./node')} destNode - Destination node of the edge.
+ * @param {Node} destNode - Destination node of the edge.
* @param {Map} properties - Properties map of the edge.
*/
constructor(srcNode, relation, destNode, properties) {
diff --git a/src/graph.js b/src/graph.js
index 929bf84c24..b9c1c4b23f 100644
--- a/src/graph.js
+++ b/src/graph.js
@@ -1,4 +1,5 @@
"use strict";
+
const redis = require("redis"),
// @ts-ignore
util = require("util"),
@@ -13,7 +14,7 @@ class Graph {
* See: node_redis for more options on createClient
*
* @param {string} graphId the graph id
- * @param {string | import('redis').RedisClient} [host] Redis host or node_redis client
+ * @param {string | redis.RedisClient} [host] Redis host or node_redis client
* @param {string | number} [port] Redis port (integer)
* @param {Object} [options] node_redis options
*/
@@ -43,7 +44,7 @@ class Graph {
/**
* Auxiliary function to extract string(s) data from procedures such as:
* db.labels, db.propertyKeys and db.relationshipTypes
- * @param {import('./resultSet')} resultSet - a procedure result set
+ * @param {ResultSet} resultSet - a procedure result set
* @returns {string[]} strings array.
*/
_extractStrings(resultSet) {
@@ -101,7 +102,7 @@ class Graph {
* @async
* @param {string} query Cypher query
* @param {Map} [params] Parameters map
- * @returns {Promise} a promise contains a result set
+ * @returns {Promise} a promise contains a result set
*/
async query(query, params) {
if (params) {
@@ -119,7 +120,7 @@ class Graph {
/**
* Deletes the entire graph
* @async
- * @returns {Promise} a promise contains the delete operation running time statistics
+ * @returns {Promise} a promise contains the delete operation running time statistics
*/
async deleteGraph() {
var res = await this._sendCommand("graph.DELETE", [this._graphId]);
@@ -136,7 +137,7 @@ class Graph {
* @param {string} procedure Procedure to call
* @param {string[]} [args] Arguments to pass
* @param {string[]} [y] Yield outputs
- * @returns {Promise} a promise contains the procedure result set data
+ * @returns {Promise} a promise contains the procedure result set data
*/
callProcedure(procedure, args = new Array(), y = new Array()) {
let q = "CALL " + procedure + "(" + args.join(",") + ")" + y.join(" ");
diff --git a/src/label.js b/src/label.js
index fc8d32cd04..547115621c 100644
--- a/src/label.js
+++ b/src/label.js
@@ -1,4 +1,5 @@
"use strict";
+
/**
* Different Statistics labels
* @readonly
diff --git a/src/node.js b/src/node.js
index ef17945d13..2541d5ce2b 100644
--- a/src/node.js
+++ b/src/node.js
@@ -1,11 +1,12 @@
"use strict";
+
/**
- * A node within the garph.
+ * A node within the graph.
*/
class Node {
/**
* Builds a node object.
- * @constructor
+ *
* @param {string} label - node label.
* @param {Map} properties - properties map.
*/
diff --git a/src/path.js b/src/path.js
index 7a7bfc36ef..23ca0894c3 100644
--- a/src/path.js
+++ b/src/path.js
@@ -1,9 +1,17 @@
"use strict";
+
+/**
+ * @typedef {import('./node')} Node
+ */
+
+/**
+ * @typedef {import('./edge')} Edge
+ */
+
class Path {
/**
- * @constructor
- * @param {import('./node')[]} nodes - path's node list.
- * @param {import('./edge')[]} edges - path's edge list.
+ * @param {Node[]} nodes - path's node list.
+ * @param {Edge[]} edges - path's edge list.
*/
constructor(nodes, edges) {
this.nodes = nodes;
@@ -12,7 +20,7 @@ class Path {
/**
* Returns the path's nodes as list.
- * @returns {import('./node')[]} path's nodes.
+ * @returns {Node[]} path's nodes.
*/
get Nodes() {
return this.nodes;
@@ -20,7 +28,7 @@ class Path {
/**
* Returns the path's edges as list.
- * @returns {import('./edge')[]} paths' edges.
+ * @returns {Edge[]} paths' edges.
*/
get Edges() {
return this.edges;
@@ -29,7 +37,7 @@ class Path {
/**
* Returns a node in a given index.
* @param {number} index (integer)
- * @returns {import('./node')} node in the given index.
+ * @returns {Node} node in the given index.
*/
getNode(index) {
return this.nodes[index];
@@ -38,7 +46,7 @@ class Path {
/**
* Returns an edge in a given index.
* @param {number} index (integer)
- * @returns {import('./edge')} edge in a given index.
+ * @returns {Edge} edge in a given index.
*/
getEdge(index) {
return this.edges[index];
@@ -46,7 +54,7 @@ class Path {
/**
* Returns the path's first node.
- * @returns {import('./node')} first node.
+ * @returns {Node} first node.
*/
get firstNode() {
return this.nodes[0];
@@ -54,7 +62,7 @@ class Path {
/**
* Returns the last node of the path.
- * @returns {import('./node')} last node.
+ * @returns {Node} last node.
*/
get lastNode() {
return this.nodes[this.nodes.length - 1];
diff --git a/src/record.js b/src/record.js
index d0d5b3da1b..8be18bd7bd 100644
--- a/src/record.js
+++ b/src/record.js
@@ -1,11 +1,12 @@
"use strict";
+
/**
* Hold a query record
*/
class Record {
/**
* Builds a Record object
- * @constructor
+ *
* @param {string[]} header
* @param {object[]} values
*/
diff --git a/src/resultSet.js b/src/resultSet.js
index d4a830eb64..7cc108f74c 100644
--- a/src/resultSet.js
+++ b/src/resultSet.js
@@ -1,4 +1,9 @@
"use strict";
+
+/**
+ * @typedef {import('./graph')} Graph
+ */
+
const Statistics = require("./statistics"),
Record = require("./record"),
Node = require("./node"),
@@ -41,8 +46,8 @@ const ResultSetValueTypes = {
class ResultSet {
/**
* Builds an empty ResultSet object.
- * @constructor
- * @param {import('./graph')} graph
+ *
+ * @param {Graph} graph
*/
constructor(graph) {
this._graph = graph; //_graph is graph api
@@ -171,7 +176,7 @@ class ResultSet {
* Parse raw node representation into a Node object.
* @async
* @param {object[]} cell raw node representation.
- * @returns {Promise} Node object.
+ * @returns {Promise} Node object.
*/
async parseNode(cell) {
// Node ID (integer),
@@ -201,7 +206,7 @@ class ResultSet {
* Parse a raw edge representation into an Edge object.
* @async
* @param {object[]} cell raw edge representation
- * @returns {Promise} Edge object.
+ * @returns {Promise} Edge object.
*/
async parseEdge(cell) {
// Edge ID (integer),
@@ -249,7 +254,7 @@ class ResultSet {
* Parse a raw path representation into Path object.
* @async
* @param {object[]} rawPath raw path representation
- * @returns {Promise} Path object.
+ * @returns {Promise} Path object.
*/
async parsePath(rawPath) {
let nodes = await this.parseScalar(rawPath[0]);
diff --git a/src/statistics.js b/src/statistics.js
index 891b5685ec..4c89758c49 100644
--- a/src/statistics.js
+++ b/src/statistics.js
@@ -1,4 +1,5 @@
"use strict";
+
const Label = require("./label");
class Statistics {
diff --git a/types/src/edge.d.ts b/types/src/edge.d.ts
index 56086f9d0f..2333d68c99 100644
--- a/types/src/edge.d.ts
+++ b/types/src/edge.d.ts
@@ -1,14 +1,19 @@
export = Edge;
+/**
+ * @typedef {import('./node')} Node
+ */
+/**
+ * An edge connecting two nodes.
+ */
declare class Edge {
/**
* Builds an Edge object.
- * @constructor
- * @param {import('./node')} srcNode - Source node of the edge.
+ * @param {Node} srcNode - Source node of the edge.
* @param {string} relation - Relationship type of the edge.
- * @param {import('./node')} destNode - Destination node of the edge.
+ * @param {Node} destNode - Destination node of the edge.
* @param {Map} properties - Properties map of the edge.
*/
- constructor(srcNode: import('./node'), relation: string, destNode: import('./node'), properties: Map);
+ constructor(srcNode: Node, relation: string, destNode: Node, properties: Map);
id: number;
relation: string;
srcNode: import("./node");
@@ -24,3 +29,7 @@ declare class Edge {
*/
toString(): string;
}
+declare namespace Edge {
+ export { Node };
+}
+type Node = import("./node");
diff --git a/types/src/graph.d.ts b/types/src/graph.d.ts
index c152c00a2b..63ae5bce8b 100644
--- a/types/src/graph.d.ts
+++ b/types/src/graph.d.ts
@@ -8,11 +8,11 @@ declare class Graph {
* See: node_redis for more options on createClient
*
* @param {string} graphId the graph id
- * @param {string | import('redis').RedisClient} [host] Redis host or node_redis client
+ * @param {string | redis.RedisClient} [host] Redis host or node_redis client
* @param {string | number} [port] Redis port (integer)
* @param {Object} [options] node_redis options
*/
- constructor(graphId: string, host?: string | import('redis').RedisClient, port?: string | number, options?: any);
+ constructor(graphId: string, host?: string | any, port?: string | number, options?: any);
_graphId: string;
_labels: any[];
_relationshipTypes: any[];
@@ -29,10 +29,10 @@ declare class Graph {
/**
* Auxiliary function to extract string(s) data from procedures such as:
* db.labels, db.propertyKeys and db.relationshipTypes
- * @param {import('./resultSet')} resultSet - a procedure result set
+ * @param {ResultSet} resultSet - a procedure result set
* @returns {string[]} strings array.
*/
- _extractStrings(resultSet: import('./resultSet')): string[];
+ _extractStrings(resultSet: ResultSet): string[];
/**
* Transforms a parameter value to string.
* @param {*} paramValue
@@ -50,23 +50,23 @@ declare class Graph {
* @async
* @param {string} query Cypher query
* @param {Map} [params] Parameters map
- * @returns {Promise} a promise contains a result set
+ * @returns {Promise} a promise contains a result set
*/
- query(query: string, params?: Map): Promise;
+ query(query: string, params?: Map): Promise;
/**
* Deletes the entire graph
* @async
- * @returns {Promise} a promise contains the delete operation running time statistics
+ * @returns {Promise} a promise contains the delete operation running time statistics
*/
- deleteGraph(): Promise;
+ deleteGraph(): Promise;
/**
* Calls procedure
* @param {string} procedure Procedure to call
* @param {string[]} [args] Arguments to pass
* @param {string[]} [y] Yield outputs
- * @returns {Promise} a promise contains the procedure result set data
+ * @returns {Promise} a promise contains the procedure result set data
*/
- callProcedure(procedure: string, args?: string[], y?: string[]): Promise;
+ callProcedure(procedure: string, args?: string[], y?: string[]): Promise;
/**
* Retrieves all labels in graph.
* @async
@@ -122,3 +122,4 @@ declare class Graph {
*/
fetchAndGetProperty(id: number): Promise;
}
+import ResultSet = require("./resultSet");
diff --git a/types/src/node.d.ts b/types/src/node.d.ts
index 4115aae93a..354d540b68 100644
--- a/types/src/node.d.ts
+++ b/types/src/node.d.ts
@@ -1,11 +1,11 @@
export = Node;
/**
- * A node within the garph.
+ * A node within the graph.
*/
declare class Node {
/**
* Builds a node object.
- * @constructor
+ *
* @param {string} label - node label.
* @param {Map} properties - properties map.
*/
diff --git a/types/src/path.d.ts b/types/src/path.d.ts
index 0c54fcb982..57178effc0 100644
--- a/types/src/path.d.ts
+++ b/types/src/path.d.ts
@@ -1,43 +1,48 @@
export = Path;
+/**
+ * @typedef {import('./node')} Node
+ */
+/**
+ * @typedef {import('./edge')} Edge
+ */
declare class Path {
/**
- * @constructor
- * @param {import('./node')[]} nodes - path's node list.
- * @param {import('./edge')[]} edges - path's edge list.
+ * @param {Node[]} nodes - path's node list.
+ * @param {Edge[]} edges - path's edge list.
*/
- constructor(nodes: import('./node')[], edges: import('./edge')[]);
+ constructor(nodes: Node[], edges: Edge[]);
nodes: import("./node")[];
edges: import("./edge")[];
/**
* Returns the path's nodes as list.
- * @returns {import('./node')[]} path's nodes.
+ * @returns {Node[]} path's nodes.
*/
get Nodes(): import("./node")[];
/**
* Returns the path's edges as list.
- * @returns {import('./edge')[]} paths' edges.
+ * @returns {Edge[]} paths' edges.
*/
get Edges(): import("./edge")[];
/**
* Returns a node in a given index.
* @param {number} index (integer)
- * @returns {import('./node')} node in the given index.
+ * @returns {Node} node in the given index.
*/
- getNode(index: number): import('./node');
+ getNode(index: number): Node;
/**
* Returns an edge in a given index.
* @param {number} index (integer)
- * @returns {import('./edge')} edge in a given index.
+ * @returns {Edge} edge in a given index.
*/
- getEdge(index: number): import('./edge');
+ getEdge(index: number): Edge;
/**
* Returns the path's first node.
- * @returns {import('./node')} first node.
+ * @returns {Node} first node.
*/
get firstNode(): import("./node");
/**
* Returns the last node of the path.
- * @returns {import('./node')} last node.
+ * @returns {Node} last node.
*/
get lastNode(): import("./node");
/**
@@ -56,3 +61,8 @@ declare class Path {
*/
toString(): string;
}
+declare namespace Path {
+ export { Node, Edge };
+}
+type Node = import("./node");
+type Edge = import("./edge");
diff --git a/types/src/record.d.ts b/types/src/record.d.ts
index 5ac08e3bcd..ed716c5604 100644
--- a/types/src/record.d.ts
+++ b/types/src/record.d.ts
@@ -5,7 +5,7 @@ export = Record;
declare class Record {
/**
* Builds a Record object
- * @constructor
+ *
* @param {string[]} header
* @param {object[]} values
*/
diff --git a/types/src/resultSet.d.ts b/types/src/resultSet.d.ts
index d9f0434e4c..c61954fd1e 100644
--- a/types/src/resultSet.d.ts
+++ b/types/src/resultSet.d.ts
@@ -5,10 +5,10 @@ export = ResultSet;
declare class ResultSet {
/**
* Builds an empty ResultSet object.
- * @constructor
- * @param {import('./graph')} graph
+ *
+ * @param {Graph} graph
*/
- constructor(graph: import('./graph'));
+ constructor(graph: Graph);
_graph: import("./graph");
_position: number;
_resultsCount: number;
@@ -20,7 +20,7 @@ declare class ResultSet {
* @param {object[]} resp - raw response representation - the raw representation of response is at most 3 lists of objects.
* The last list is the statistics list.
*/
- parseResponse(resp: object[]): Promise;
+ parseResponse(resp: object[]): Promise;
_statistics: Statistics;
/**
* Parse a raw response body into header an records.
@@ -54,16 +54,16 @@ declare class ResultSet {
* Parse raw node representation into a Node object.
* @async
* @param {object[]} cell raw node representation.
- * @returns {Promise} Node object.
+ * @returns {Promise} Node object.
*/
- parseNode(cell: object[]): Promise;
+ parseNode(cell: object[]): Promise;
/**
* Parse a raw edge representation into an Edge object.
* @async
* @param {object[]} cell raw edge representation
- * @returns {Promise} Edge object.
+ * @returns {Promise} Edge object.
*/
- parseEdge(cell: object[]): Promise;
+ parseEdge(cell: object[]): Promise;
/**
* Parse and in-place replace raw array into an array of values or objects.
* @async
@@ -75,9 +75,9 @@ declare class ResultSet {
* Parse a raw path representation into Path object.
* @async
* @param {object[]} rawPath raw path representation
- * @returns {Promise} Path object.
+ * @returns {Promise} Path object.
*/
- parsePath(rawPath: object[]): Promise;
+ parsePath(rawPath: object[]): Promise;
/**
* Parse a raw map representation into Map object.
* @async
@@ -113,5 +113,12 @@ declare class ResultSet {
*/
size(): number;
}
+declare namespace ResultSet {
+ export { Graph };
+}
import Statistics = require("./statistics");
+import Node = require("./node");
+import Edge = require("./edge");
+import Path = require("./path");
import Record = require("./record");
+type Graph = import("./graph");