Skip to content

Commit bef4127

Browse files
committed
Small JSDoc improvements
* refined some type definitions * fixed couple links * made internal functions private
1 parent 37e6382 commit bef4127

File tree

8 files changed

+37
-25
lines changed

8 files changed

+37
-25
lines changed

src/v1/driver.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import {DirectConnectionProvider} from './internal/connection-providers';
2626

2727
const READ = 'READ', WRITE = 'WRITE';
2828
/**
29-
* A driver maintains one or more {@link Session sessions} with a remote
30-
* Neo4j instance. Through the {@link Session sessions} you can send statements
29+
* A driver maintains one or more {@link Session}s with a remote
30+
* Neo4j instance. Through the {@link Session}s you can send statements
3131
* and retrieve results from the database.
3232
*
3333
* Drivers are reasonably expensive to create - you should strive to keep one
@@ -103,7 +103,7 @@ class Driver {
103103
* will be pulling a session out of the common pool.
104104
*
105105
* This comes with some responsibility - make sure you always call
106-
* {@link Session#close()} when you are done using a session, and likewise,
106+
* {@link close} when you are done using a session, and likewise,
107107
* make sure you don't close your session before you are done using it. Once
108108
* it is returned to the pool, the session will be reset to a clean state and
109109
* made available for others to use.

src/v1/error.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,17 @@
2020
// A common place for constructing error objects, to keep them
2121
// uniform across the driver surface.
2222

23+
/**
24+
* @type {string}
25+
*/
2326
const SERVICE_UNAVAILABLE = 'ServiceUnavailable';
27+
/**
28+
* @type {string}
29+
*/
2430
const SESSION_EXPIRED = 'SessionExpired';
31+
/**
32+
* @type {string}
33+
*/
2534
const PROTOCOL_ERROR = 'ProtocolError';
2635

2736
function newError(message, code="N/A") {

src/v1/graph-types.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Node {
2424
/**
2525
* @constructor
2626
* @param {Integer} identity - Unique identity
27-
* @param {Array} labels - Array for all labels
27+
* @param {Array<string>} labels - Array for all labels
2828
* @param {Object} properties - Map with node properties
2929
*/
3030
constructor(identity, labels, properties) {
@@ -161,7 +161,7 @@ class Path {
161161
* @constructor
162162
* @param {Node} start - start node
163163
* @param {Node} end - end node
164-
* @param {Array} segments - Array of Segments
164+
* @param {Array<PathSegment>} segments - Array of Segments
165165
*/
166166
constructor(start, end, segments) {
167167
this.start = start;

src/v1/record.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* limitations under the License.
1818
*/
1919

20-
import {newError} from "./error";
20+
import {newError} from './error';
2121

2222
function generateFieldLookup( keys ) {
2323
let lookup = {};
@@ -68,7 +68,7 @@ class Record {
6868
* will get three arguments - the value, the key and this record, in that
6969
* order.
7070
*
71-
* @param visitor
71+
* @param {function(value: Object, key: string, record: Record)} visitor the function to apply to each field.
7272
*/
7373
forEach( visitor ) {
7474
for(let i=0;i<this.keys.length;i++) {

src/v1/result-summary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class ProfiledPlan {
107107
}
108108

109109
/**
110-
* Get statistical information for a {Result}.
110+
* Get statistical information for a {@link Result}.
111111
* @access public
112112
*/
113113
class StatementStatistics {

src/v1/routing-driver.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {LoadBalancer} from './internal/connection-providers';
2424

2525
/**
2626
* A driver that supports routing in a core-edge cluster.
27+
* @private
2728
*/
2829
class RoutingDriver extends Driver {
2930

src/v1/session.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class Session {
9090
* While a transaction is open the session cannot be used to run statements outside the transaction.
9191
*
9292
* @param {string} bookmark - a reference to a previous transaction. DEPRECATED: This parameter is deprecated in
93-
* favour of {@link Driver#session(string)} that accepts an initial bookmark. Session will ensure that all nested
93+
* favour of {@link Driver#session} that accepts an initial bookmark. Session will ensure that all nested
9494
* transactions are chained with bookmarks to guarantee causal consistency.
9595
* @returns {Transaction} - New Transaction
9696
*/
@@ -123,14 +123,14 @@ class Session {
123123
/**
124124
* Return the bookmark received following the last completed {@link Transaction}.
125125
*
126-
* @return a reference to a previous transac'tion
126+
* @return a reference to a previous transaction
127127
*/
128128
lastBookmark() {
129129
return this._lastBookmark;
130130
}
131131

132132
/**
133-
* Execute given unit of work in a {@link Driver#READ} transaction.
133+
* Execute given unit of work in a {@link READ} transaction.
134134
*
135135
* Transaction will automatically be committed unless the given function throws or returns a rejected promise.
136136
* Some failures of the given function or the commit itself will be retried with exponential backoff with initial
@@ -147,7 +147,7 @@ class Session {
147147
}
148148

149149
/**
150-
* Execute given unit of work in a {@link Driver#WRITE} transaction.
150+
* Execute given unit of work in a {@link WRITE} transaction.
151151
*
152152
* Transaction will automatically be committed unless the given function throws or returns a rejected promise.
153153
* Some failures of the given function or the commit itself will be retried with exponential backoff with initial

src/v1/transaction.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Transaction {
5757

5858
/**
5959
* Run Cypher statement
60-
* Could be called with a statement object i.e.: {statement: "MATCH ...", parameters: {param: 1}}
60+
* Could be called with a statement object i.e.: <code>{statement: "MATCH ...", parameters: {param: 1}}</code>
6161
* or with the statement and parameters as separate arguments.
6262
* @param {mixed} statement - Cypher statement to execute
6363
* @param {Object} parameters - Map with parameters to use in statement
@@ -179,7 +179,7 @@ let _states = {
179179
conn.sync();
180180
}).catch(error => observer.onError(error));
181181

182-
return newRunResult(observer, statement, parameters, () => observer.serverMeta());
182+
return _newRunResult(observer, statement, parameters, () => observer.serverMeta());
183183
}
184184
},
185185

@@ -192,19 +192,19 @@ let _states = {
192192
"transaction has failed and the transaction has been rolled back. Please start a new" +
193193
" transaction to run another statement."
194194
});
195-
return {result: newDummyResult(observer, "COMMIT", {}), state: _states.FAILED};
195+
return {result: _newDummyResult(observer, "COMMIT", {}), state: _states.FAILED};
196196
},
197197
rollback: (connectionHolder, observer) => {
198198
observer.onError({error:
199199
"Cannot rollback transaction, because previous statements in the " +
200200
"transaction has failed and the transaction has already been rolled back."});
201-
return {result: newDummyResult(observer, "ROLLBACK", {}), state: _states.FAILED};
201+
return {result: _newDummyResult(observer, "ROLLBACK", {}), state: _states.FAILED};
202202
},
203203
run: (connectionHolder, observer, statement, parameters) => {
204204
observer.onError({error:
205205
"Cannot run statement, because previous statements in the " +
206206
"transaction has failed and the transaction has already been rolled back."});
207-
return newDummyResult(observer, statement, parameters);
207+
return _newDummyResult(observer, statement, parameters);
208208
}
209209
},
210210

@@ -215,17 +215,17 @@ let _states = {
215215
error: "Cannot commit statements in this transaction, because commit has already been successfully called on the transaction and transaction has been closed. Please start a new" +
216216
" transaction to run another statement."
217217
});
218-
return {result: newDummyResult(observer, "COMMIT", {}), state: _states.SUCCEEDED};
218+
return {result: _newDummyResult(observer, "COMMIT", {}), state: _states.SUCCEEDED};
219219
},
220220
rollback: (connectionHolder, observer) => {
221221
observer.onError({error:
222222
"Cannot rollback transaction, because transaction has already been successfully closed."});
223-
return {result: newDummyResult(observer, "ROLLBACK", {}), state: _states.SUCCEEDED};
223+
return {result: _newDummyResult(observer, "ROLLBACK", {}), state: _states.SUCCEEDED};
224224
},
225225
run: (connectionHolder, observer, statement, parameters) => {
226226
observer.onError({error:
227227
"Cannot run statement, because transaction has already been successfully closed."});
228-
return newDummyResult(observer, statement, parameters);
228+
return _newDummyResult(observer, statement, parameters);
229229
}
230230
},
231231

@@ -235,17 +235,17 @@ let _states = {
235235
observer.onError({
236236
error: "Cannot commit this transaction, because it has already been rolled back."
237237
});
238-
return {result: newDummyResult(observer, "COMMIT", {}), state: _states.ROLLED_BACK};
238+
return {result: _newDummyResult(observer, "COMMIT", {}), state: _states.ROLLED_BACK};
239239
},
240240
rollback: (connectionHolder, observer) => {
241241
observer.onError({error:
242242
"Cannot rollback transaction, because transaction has already been rolled back."});
243-
return {result: newDummyResult(observer, "ROLLBACK", {}), state: _states.ROLLED_BACK};
243+
return {result: _newDummyResult(observer, "ROLLBACK", {}), state: _states.ROLLED_BACK};
244244
},
245245
run: (connectionHolder, observer, statement, parameters) => {
246246
observer.onError({error:
247247
"Cannot run statement, because transaction has already been rolled back."});
248-
return newDummyResult(observer, statement, parameters);
248+
return _newDummyResult(observer, statement, parameters);
249249
}
250250
}
251251
};
@@ -274,8 +274,9 @@ function _runPullAll(msg, connectionHolder, observer) {
274274
* @param {object} parameters - the parameters for cypher statement that produced the result.
275275
* @param {function} metadataSupplier - the function that returns a metadata object.
276276
* @return {Result} new result.
277+
* @private
277278
*/
278-
function newRunResult(observer, statement, parameters, metadataSupplier) {
279+
function _newRunResult(observer, statement, parameters, metadataSupplier) {
279280
return new Result(observer, statement, parameters, metadataSupplier, EMPTY_CONNECTION_HOLDER);
280281
}
281282

@@ -287,8 +288,9 @@ function newRunResult(observer, statement, parameters, metadataSupplier) {
287288
* @param {string} statement - the cypher statement that produced the result.
288289
* @param {object} parameters - the parameters for cypher statement that produced the result.
289290
* @return {Result} new result.
291+
* @private
290292
*/
291-
function newDummyResult(observer, statement, parameters) {
293+
function _newDummyResult(observer, statement, parameters) {
292294
return new Result(observer, statement, parameters, emptyMetadataSupplier, EMPTY_CONNECTION_HOLDER);
293295
}
294296

0 commit comments

Comments
 (0)