neo4j-driver 4.4.8 → 5.0.0-beta01

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _resultRx = _interopRequireDefault(require("./result-rx"));
15
+
16
+ var _transactionRx = _interopRequireDefault(require("./transaction-rx"));
17
+
18
+ /**
19
+ * Copyright (c) "Neo4j"
20
+ * Neo4j Sweden AB [http://neo4j.com]
21
+ *
22
+ * This file is part of Neo4j.
23
+ *
24
+ * Licensed under the Apache License, Version 2.0 (the "License");
25
+ * you may not use this file except in compliance with the License.
26
+ * You may obtain a copy of the License at
27
+ *
28
+ * http://www.apache.org/licenses/LICENSE-2.0
29
+ *
30
+ * Unless required by applicable law or agreed to in writing, software
31
+ * distributed under the License is distributed on an "AS IS" BASIS,
32
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33
+ * See the License for the specific language governing permissions and
34
+ * limitations under the License.
35
+ */
36
+ // eslint-disable-next-line no-unused-vars
37
+ // eslint-disable-next-line no-unused-vars
38
+
39
+ /**
40
+ * Represents a rx transaction that is managed by the transaction executor.
41
+ *
42
+ * @public
43
+ */
44
+ var RxManagedTransaction = /*#__PURE__*/function () {
45
+ /**
46
+ * @private
47
+ */
48
+ function RxManagedTransaction(_ref) {
49
+ var run = _ref.run;
50
+ (0, _classCallCheck2["default"])(this, RxManagedTransaction);
51
+ this._run = run;
52
+ }
53
+ /**
54
+ * @private
55
+ * @param {RxTransaction} txc - The transaction to be wrapped
56
+ * @returns {RxManagedTransaction} The managed transaction
57
+ */
58
+
59
+
60
+ (0, _createClass2["default"])(RxManagedTransaction, [{
61
+ key: "run",
62
+ value:
63
+ /**
64
+ * Creates a reactive result that will execute the query in this transaction, with the provided parameters.
65
+ *
66
+ * @public
67
+ * @param {string} query - Query to be executed.
68
+ * @param {Object} parameters - Parameter values to use in query execution.
69
+ * @returns {RxResult} - A reactive result
70
+ */
71
+ function run(query, parameters) {
72
+ return this._run(query, parameters);
73
+ }
74
+ }], [{
75
+ key: "fromTransaction",
76
+ value: function fromTransaction(txc) {
77
+ return new RxManagedTransaction({
78
+ run: txc.run.bind(txc)
79
+ });
80
+ }
81
+ }]);
82
+ return RxManagedTransaction;
83
+ }();
84
+
85
+ var _default = RxManagedTransaction;
86
+ exports["default"] = _default;
@@ -35,6 +35,7 @@ var _neo4jDriverCore = _interopRequireDefault(require("neo4j-driver-core"));
35
35
  * See the License for the specific language governing permissions and
36
36
  * limitations under the License.
37
37
  */
38
+ // eslint-disable-next-line no-unused-vars
38
39
 
39
40
  /**
40
41
  * A reactive transaction, which provides the same functionality as {@link Transaction} but through a Reactive API.
@@ -115,6 +116,16 @@ var RxTransaction = /*#__PURE__*/function () {
115
116
  });
116
117
  });
117
118
  }
119
+ /**
120
+ * Check if this transaction is active, which means commit and rollback did not happen.
121
+ * @return {boolean} `true` when not committed and not rolled back, `false` otherwise.
122
+ */
123
+
124
+ }, {
125
+ key: "isOpen",
126
+ value: function isOpen() {
127
+ return this._txc.isOpen();
128
+ }
118
129
  /**
119
130
  * Closes the transaction
120
131
  *
package/lib/version.js CHANGED
@@ -31,5 +31,5 @@ exports["default"] = void 0;
31
31
  // This is set up this way to keep the version in the code in
32
32
  // sync with the npm package version, and to allow the build
33
33
  // system to control version names at packaging time.
34
- var _default = '4.4.8';
34
+ var _default = '5.0.0-beta01';
35
35
  exports["default"] = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo4j-driver",
3
- "version": "4.4.8",
3
+ "version": "5.0.0-beta01",
4
4
  "description": "Connect to Neo4j 3.5.0 and up from JavaScript",
5
5
  "author": "Neo4j",
6
6
  "license": "Apache-2.0",
@@ -10,7 +10,6 @@
10
10
  },
11
11
  "scripts": {
12
12
  "lint": "eslint --fix --ext .js ./",
13
- "format": "prettier-eslint '**/*.js' '**/*.json' '**/*.md' '**/*.ts' '**/*.html' --write",
14
13
  "test": "gulp test",
15
14
  "test::unit": "gulp test-nodejs-unit && gulp run-ts-declaration-tests",
16
15
  "test::browser": "gulp test-browser",
@@ -27,17 +26,6 @@
27
26
  "prepare": "npm run build",
28
27
  "clean": "rm -fr node_modules lib build"
29
28
  },
30
- "husky": {
31
- "hooks": {
32
- "pre-commit": "lint-staged"
33
- }
34
- },
35
- "lint-staged": {
36
- "*.{js,json,ts,md,html}": [
37
- "prettier-eslint --write",
38
- "git add"
39
- ]
40
- },
41
29
  "main": "lib/index.js",
42
30
  "browser": {
43
31
  "./lib/internal/node/index.js": "./lib/internal/browser/index.js"
@@ -46,33 +34,26 @@
46
34
  "jsdelivr": "lib/browser/neo4j-web.js",
47
35
  "types": "types/index.d.ts",
48
36
  "devDependencies": {
49
- "@babel/core": "^7.5.5",
50
- "@babel/plugin-transform-runtime": "^7.5.5",
51
- "@babel/preset-env": "^7.5.5",
52
- "@babel/register": "^7.5.5",
53
- "@istanbuljs/nyc-config-babel": "^2.1.1",
54
- "async": "^3.2.1",
55
- "babel-eslint": "^10.0.3",
56
- "babel-plugin-istanbul": "^5.2.0",
37
+ "@babel/core": "^7.17.8",
38
+ "@babel/eslint-parser": "^7.17.0",
39
+ "@babel/plugin-transform-runtime": "^7.17.0",
40
+ "@babel/preset-env": "^7.16.11",
41
+ "@babel/register": "^7.17.7",
42
+ "@istanbuljs/nyc-config-babel": "^3.0.0",
43
+ "async": "^3.2.3",
44
+ "babel-plugin-istanbul": "^6.1.1",
57
45
  "babelify": "^10.0.0",
58
- "browserify": "^16.5.0",
46
+ "browserify": "^17.0.0",
59
47
  "browserify-transform-tools": "^1.7.0",
60
48
  "esdoc": "^1.1.0",
61
49
  "esdoc-importpath-plugin": "^1.0.2",
62
50
  "esdoc-standard-plugin": "^1.0.0",
63
- "eslint": "^6.8.0",
64
- "eslint-config-standard": "^14.1.1",
65
- "eslint-plugin-import": "^2.25.2",
66
- "eslint-plugin-jasmine": "^2.10.1",
67
- "eslint-plugin-node": "^9.2.0",
68
- "eslint-plugin-promise": "^4.2.1",
69
- "eslint-plugin-standard": "^4.0.1",
70
- "fancy-log": "^1.3.3",
71
- "fs-extra": "^8.1.0",
51
+ "fancy-log": "^2.0.0",
52
+ "fs-extra": "^10.0.1",
72
53
  "gulp": "^4.0.2",
73
54
  "gulp-babel": "^8.0.0",
74
55
  "gulp-batch": "^1.0.5",
75
- "gulp-decompress": "^2.0.3",
56
+ "gulp-decompress": "^3.0.0",
76
57
  "gulp-download": "^0.0.1",
77
58
  "gulp-file": "^0.4.0",
78
59
  "gulp-install": "^1.1.0",
@@ -81,39 +62,32 @@
81
62
  "gulp-typescript": "^5.0.1",
82
63
  "gulp-uglify": "^3.0.2",
83
64
  "gulp-watch": "^5.0.1",
84
- "husky": "^3.1.0",
85
65
  "istanbul": "^0.4.5",
86
- "jasmine-spec-reporter": "^4.2.1",
87
- "karma": "^4.4.1",
88
- "karma-browserify": "^6.1.0",
89
- "karma-chrome-launcher": "^3.1.0",
66
+ "jasmine-spec-reporter": "^7.0.0",
67
+ "karma": "^6.3.17",
68
+ "karma-browserify": "^8.1.0",
69
+ "karma-chrome-launcher": "^3.1.1",
90
70
  "karma-edge-launcher": "^0.4.2",
91
- "karma-firefox-launcher": "^1.3.0",
71
+ "karma-firefox-launcher": "^2.1.2",
92
72
  "karma-ie-launcher": "^1.0.0",
93
- "karma-jasmine": "^2.0.1",
73
+ "karma-jasmine": "^4.0.2",
94
74
  "karma-source-map-support": "^1.4.0",
95
- "karma-spec-reporter": "^0.0.32",
96
- "lint-staged": "^9.5.0",
97
- "lodash": "^4.17.20",
98
- "lolex": "^4.2.0",
99
- "minimist": "^1.2.5",
100
- "mustache": "^3.2.1",
101
- "nyc": "^14.1.1",
102
- "prettier-eslint": "^9.0.2",
103
- "prettier-eslint-cli": "^5.0.0",
104
- "run-sequence": "^2.2.1",
105
- "semver": "^6.3.0",
106
- "tmp": "0.1.0",
107
- "typescript": "^3.9.10",
75
+ "karma-spec-reporter": "^0.0.33",
76
+ "lolex": "^6.0.0",
77
+ "minimist": "^1.2.6",
78
+ "nyc": "^15.1.0",
79
+ "semver": "^7.3.5",
80
+ "tmp": "0.2.1",
81
+ "typescript": "^4.6.3",
108
82
  "vinyl-buffer": "^1.0.1",
109
83
  "vinyl-source-stream": "^2.0.0",
110
- "webpack": "^4.44.2"
84
+ "webpack": "^5.70.0"
111
85
  },
112
86
  "dependencies": {
113
- "@babel/runtime": "^7.5.5",
114
- "neo4j-driver-bolt-connection": "^4.4.8",
115
- "neo4j-driver-core": "^4.4.8",
116
- "rxjs": "^6.6.3"
87
+ "@babel/runtime": "^7.17.8",
88
+ "neo4j-driver-bolt-connection": "^5.0.0-beta01",
89
+ "neo4j-driver-core": "^5.0.0-beta01",
90
+ "rxjs": "^7.5.5"
117
91
  },
118
- "gitHead": "289c1ba147c03d3354aee413e1078ccad95d6dbb"
92
+ "gitHead": "5de1012246d52452b4cfef304ea34f2ff1d7a88e"
119
93
  }
package/tsconfig.json CHANGED
@@ -4,7 +4,9 @@
4
4
  "target": "es6",
5
5
  "noImplicitAny": true,
6
6
  "noImplicitReturns": true,
7
+ "strictNullChecks": true,
7
8
  "moduleResolution": "node",
8
9
  "types": []
9
- }
10
+ },
11
+ "include": ["types/**/*.ts", "test/types/**/*.ts"]
10
12
  }
package/types/driver.d.ts CHANGED
@@ -19,10 +19,9 @@
19
19
 
20
20
  import RxSession from './session-rx'
21
21
  import {
22
- ServerInfo,
23
- Session,
24
22
  Driver as CoreDriver,
25
- types
23
+ types,
24
+ SessionConfig
26
25
  } from 'neo4j-driver-core'
27
26
 
28
27
  declare type AuthToken = types.AuthToken
@@ -36,17 +35,7 @@ declare const READ: SessionMode
36
35
  declare const WRITE: SessionMode
37
36
 
38
37
  declare interface Driver extends CoreDriver {
39
- rxSession({
40
- defaultAccessMode,
41
- bookmarks,
42
- database,
43
- fetchSize
44
- }?: {
45
- defaultAccessMode?: SessionMode
46
- bookmarks?: string | string[]
47
- fetchSize?: number
48
- database?: string
49
- }): RxSession
38
+ rxSession: (sessionParams?: SessionConfig) => RxSession
50
39
  }
51
40
 
52
41
  export {
package/types/index.d.ts CHANGED
@@ -19,6 +19,7 @@
19
19
 
20
20
  import {
21
21
  Neo4jError,
22
+ isRetriableError,
22
23
  error,
23
24
  Integer,
24
25
  inSafeRange,
@@ -57,8 +58,13 @@ import {
57
58
  ResultObserver,
58
59
  QueryResult,
59
60
  Transaction,
61
+ ManagedTransaction,
60
62
  Session,
61
- ConnectionProvider
63
+ ConnectionProvider,
64
+ BookmarkManager,
65
+ bookmarkManager,
66
+ BookmarkManagerConfig,
67
+ SessionConfig
62
68
  } from 'neo4j-driver-core'
63
69
  import {
64
70
  AuthToken,
@@ -72,6 +78,7 @@ import {
72
78
  } from './driver'
73
79
  import RxSession from './session-rx'
74
80
  import RxTransaction from './transaction-rx'
81
+ import RxManagedTransaction from './transaction-managed-rx'
75
82
  import RxResult from './result-rx'
76
83
  import { Parameters } from './query-runner'
77
84
 
@@ -91,12 +98,17 @@ declare const auth: {
91
98
  ) => AuthToken
92
99
  }
93
100
 
94
- declare function driver(
101
+ declare function driver (
95
102
  url: string,
96
103
  authToken?: AuthToken,
97
104
  config?: Config
98
105
  ): Driver
99
106
 
107
+ declare function hasReachableServer (
108
+ url: string,
109
+ config?: Pick<Config, 'logging'>
110
+ ): Promise<true>
111
+
100
112
  declare const types: {
101
113
  Node: typeof Node
102
114
  Relationship: typeof Relationship
@@ -116,6 +128,7 @@ declare const types: {
116
128
  Integer: typeof Integer
117
129
  RxSession: RxSession
118
130
  RxTransaction: RxTransaction
131
+ RxManagedTransaction: RxManagedTransaction
119
132
  RxResult: RxResult
120
133
  }
121
134
 
@@ -154,6 +167,7 @@ declare const temporal: {
154
167
 
155
168
  declare const forExport: {
156
169
  driver: typeof driver
170
+ hasReachableServer: typeof hasReachableServer
157
171
  int: typeof int
158
172
  isInt: typeof isInt
159
173
  integer: typeof integer
@@ -170,6 +184,7 @@ declare const forExport: {
170
184
  TrustStrategy: TrustStrategy
171
185
  SessionMode: SessionMode
172
186
  Neo4jError: Neo4jError
187
+ isRetriableError: typeof isRetriableError
173
188
  Node: Node
174
189
  Relationship: Relationship
175
190
  UnboundRelationship: UnboundRelationship
@@ -189,6 +204,7 @@ declare const forExport: {
189
204
  NotificationPosition: NotificationPosition
190
205
  Session: Session
191
206
  Transaction: Transaction
207
+ ManagedTransaction: ManagedTransaction
192
208
  Point: Point
193
209
  isPoint: typeof isPoint
194
210
  Duration: Duration
@@ -199,6 +215,7 @@ declare const forExport: {
199
215
  DateTime: DateTime
200
216
  RxSession: RxSession
201
217
  RxTransaction: RxTransaction
218
+ RxManagedTransaction: RxManagedTransaction
202
219
  RxResult: RxResult
203
220
  ConnectionProvider: ConnectionProvider
204
221
  isDuration: typeof isDuration
@@ -207,10 +224,12 @@ declare const forExport: {
207
224
  isDate: typeof isDate
208
225
  isLocalDateTime: typeof isLocalDateTime
209
226
  isDateTime: typeof isDateTime
227
+ bookmarkManager: typeof bookmarkManager
210
228
  }
211
229
 
212
230
  export {
213
231
  driver,
232
+ hasReachableServer,
214
233
  int,
215
234
  isInt,
216
235
  integer,
@@ -227,6 +246,7 @@ export {
227
246
  TrustStrategy,
228
247
  SessionMode,
229
248
  Neo4jError,
249
+ isRetriableError,
230
250
  Node,
231
251
  Relationship,
232
252
  UnboundRelationship,
@@ -246,6 +266,7 @@ export {
246
266
  NotificationPosition,
247
267
  Session,
248
268
  Transaction,
269
+ ManagedTransaction,
249
270
  Point,
250
271
  isPoint,
251
272
  Duration,
@@ -256,6 +277,7 @@ export {
256
277
  DateTime,
257
278
  RxSession,
258
279
  RxTransaction,
280
+ RxManagedTransaction,
259
281
  RxResult,
260
282
  ConnectionProvider,
261
283
  isDuration,
@@ -263,7 +285,14 @@ export {
263
285
  isTime,
264
286
  isDate,
265
287
  isLocalDateTime,
266
- isDateTime
288
+ isDateTime,
289
+ bookmarkManager
290
+ }
291
+
292
+ export type {
293
+ BookmarkManager,
294
+ BookmarkManagerConfig,
295
+ SessionConfig
267
296
  }
268
297
 
269
298
  export default forExport
@@ -21,7 +21,7 @@ import { Result, types } from 'neo4j-driver-core'
21
21
 
22
22
  declare type Parameters = types.Parameters
23
23
  declare interface QueryRunner {
24
- run(query: string, parameters?: Parameters): Result
24
+ run: (query: string, parameters?: Parameters) => Result
25
25
  }
26
26
 
27
27
  export { Parameters }
@@ -20,11 +20,17 @@ import { Observable } from 'rxjs'
20
20
  import { Record, ResultSummary } from 'neo4j-driver-core'
21
21
 
22
22
  declare interface RxResult {
23
- keys(): Observable<string[]>
23
+ keys: () => Observable<string[]>
24
24
 
25
- records(): Observable<Record>
25
+ records: () => Observable<Record>
26
26
 
27
- consume(): Observable<ResultSummary>
27
+ consume: () => Observable<ResultSummary>
28
+
29
+ pause: () => void
30
+
31
+ resume: () => Promise<void>
32
+
33
+ push: () => Promise<void>
28
34
  }
29
35
 
30
36
  export default RxResult
@@ -25,27 +25,43 @@ import { Observable } from 'rxjs'
25
25
  declare type RxTransactionWork<T> = (tx: RxTransaction) => Observable<T>
26
26
 
27
27
  declare interface RxSession {
28
- run(
28
+ run: (
29
29
  query: string,
30
30
  parameters?: Parameters,
31
31
  config?: TransactionConfig
32
- ): RxResult
32
+ ) => RxResult
33
33
 
34
- beginTransaction(config?: TransactionConfig): Observable<RxTransaction>
34
+ beginTransaction: (config?: TransactionConfig) => Observable<RxTransaction>
35
35
 
36
- lastBookmark(): string[]
36
+ lastBookmarks: () => string[]
37
+ lastBookmark: () => string[]
38
+ /**
39
+ * @deprecated This method will be removed in version 6.0. Please, use {@link RxSession#executeRead} instead.
40
+ */
41
+ readTransaction: <T>(
42
+ work: RxTransactionWork<T>,
43
+ config?: TransactionConfig
44
+ ) => Observable<T>
45
+
46
+ /**
47
+ * @deprecated This method will be removed in version 6.0. Please, use {@link RxSession#executeWrite} instead.
48
+ */
49
+ writeTransaction: <T>(
50
+ work: RxTransactionWork<T>,
51
+ config?: TransactionConfig
52
+ ) => Observable<T>
37
53
 
38
- readTransaction<T>(
54
+ executeRead: <T>(
39
55
  work: RxTransactionWork<T>,
40
56
  config?: TransactionConfig
41
- ): Observable<T>
57
+ ) => Observable<T>
42
58
 
43
- writeTransaction<T>(
59
+ executeWrite: <T>(
44
60
  work: RxTransactionWork<T>,
45
61
  config?: TransactionConfig
46
- ): Observable<T>
62
+ ) => Observable<T>
47
63
 
48
- close(): Observable<any>
64
+ close: () => Observable<any>
49
65
  }
50
66
 
51
67
  export default RxSession
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) "Neo4j"
3
+ * Neo4j Sweden AB [http://neo4j.com]
4
+ *
5
+ * This file is part of Neo4j.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ import { Parameters } from './query-runner'
20
+ import RxResult from './result-rx'
21
+
22
+ declare interface RxManagedTransaction {
23
+ run: (query: string, parameters?: Parameters) => RxResult
24
+ }
25
+
26
+ export default RxManagedTransaction
@@ -21,13 +21,15 @@ import { Parameters } from './query-runner'
21
21
  import RxResult from './result-rx'
22
22
 
23
23
  declare interface RxTransaction {
24
- run(query: string, parameters?: Parameters): RxResult
24
+ run: (query: string, parameters?: Parameters) => RxResult
25
25
 
26
- commit(): Observable<any>
26
+ isOpen: () => boolean
27
27
 
28
- rollback(): Observable<any>
28
+ commit: () => Observable<any>
29
29
 
30
- close(): Observable<any>
30
+ rollback: () => Observable<any>
31
+
32
+ close: () => Observable<any>
31
33
  }
32
34
 
33
35
  export default RxTransaction
package/.eslintrc.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "parser": "babel-eslint",
3
- "env": {
4
- "browser": true,
5
- "es6": true,
6
- "node": true,
7
- "jasmine": true,
8
- "jest": true
9
- },
10
- "extends": "standard",
11
- "globals": {
12
- "Atomics": "readonly",
13
- "SharedArrayBuffer": "readonly"
14
- },
15
- "parserOptions": {
16
- "ecmaVersion": 6,
17
- "sourceType": "module"
18
- },
19
- "rules": {},
20
- "plugins": ["jasmine"]
21
- }