Skip to content

Commit ec1af19

Browse files
authored
Commit neo4j-driver-deno to the repository (#1004)
The `deno driver` is generated using a custom script made for this repository. This script doesn't have any tests linked to it. So the only way this changes are tested is by running the `deno driver` test suite. For guarantee the behaviour of this driver, we should version commit the generated driver to the repository. This changes introduce the first committed version of the driver. Adding the verification if the committed deno driver is in sync with the lite driver is also part of the this scope.
1 parent 1418f42 commit ec1af19

File tree

118 files changed

+21480
-8
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+21480
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"scripts": {
4141
"clean": "lerna clean -y && lerna run clean",
4242
"build": "lerna bootstrap --ci",
43-
"build::deno": "(cd ./packages/neo4j-driver-deno && deno run --allow-read --allow-write --allow-net ./generate.ts --version=5.0.0-dev)",
43+
"build::deno": "cd ./packages/neo4j-driver-deno && deno run --allow-read --allow-write --allow-net ./generate.ts --version=5.0.0-dev",
4444
"build::notci": "lerna bootstrap",
4545
"docs": "lerna run docs --stream --concurrency 1",
4646
"test::unit": "lerna run test::unit --stream",

packages/neo4j-driver-deno/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
lib/
21
.vscode/
2+
lib2/

packages/neo4j-driver-deno/generate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const isDir = (path: string) => {
2727
////////////////////////////////////////////////////////////////////////////////
2828
// Parse arguments
2929
const parsedArgs = parse(Deno.args, {
30-
string: ["version"],
30+
string: ["version", "output"],
3131
boolean: ["transform"], // Pass --no-transform to disable
3232
default: { transform: true },
3333
unknown: (arg) => {
@@ -42,7 +42,7 @@ const version = parsedArgs.version ?? "0.0.0dev";
4242

4343
////////////////////////////////////////////////////////////////////////////////
4444
// Clear out the destination folder
45-
const rootOutDir = "lib/";
45+
const rootOutDir = parsedArgs.output ?? "lib/";
4646
await ensureDir(rootOutDir); // Make sure it exists
4747
for await (const existingFile of Deno.readDir(rootOutDir)) {
4848
await Deno.remove(`${rootOutDir}${existingFile.name}`, { recursive: true });
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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 { newError } from '../../core/index.ts'
20+
// eslint-disable-next-line no-unused-vars
21+
import { ResultStreamObserver } from './stream-observers.js'
22+
23+
/**
24+
* @param {TxConfig} txConfig the auto-commit transaction configuration.
25+
* @param {function(error: string)} onProtocolError called when the txConfig is not empty.
26+
* @param {ResultStreamObserver} observer the response observer.
27+
*/
28+
function assertTxConfigIsEmpty (txConfig, onProtocolError = () => {}, observer) {
29+
if (txConfig && !txConfig.isEmpty()) {
30+
const error = newError(
31+
'Driver is connected to the database that does not support transaction configuration. ' +
32+
'Please upgrade to neo4j 3.5.0 or later in order to use this functionality'
33+
)
34+
35+
// unsupported API was used, consider this a fatal error for the current connection
36+
onProtocolError(error.message)
37+
observer.onError(error)
38+
throw error
39+
}
40+
}
41+
42+
/**
43+
* Asserts that the passed-in database name is empty.
44+
* @param {string} database
45+
* @param {fuction(err: String)} onProtocolError Called when it doesn't have database set
46+
*/
47+
function assertDatabaseIsEmpty (database, onProtocolError = () => {}, observer) {
48+
if (database) {
49+
const error = newError(
50+
'Driver is connected to the database that does not support multiple databases. ' +
51+
'Please upgrade to neo4j 4.0.0 or later in order to use this functionality'
52+
)
53+
54+
// unsupported API was used, consider this a fatal error for the current connection
55+
onProtocolError(error.message)
56+
observer.onError(error)
57+
throw error
58+
}
59+
}
60+
61+
/**
62+
* Asserts that the passed-in impersonated user is empty
63+
* @param {string} impersonatedUser
64+
* @param {function (err:Error)} onProtocolError Called when it does have impersonated user set
65+
* @param {any} observer
66+
*/
67+
function assertImpersonatedUserIsEmpty (impersonatedUser, onProtocolError = () => {}, observer) {
68+
if (impersonatedUser) {
69+
const error = newError(
70+
'Driver is connected to the database that does not support user impersonation. ' +
71+
'Please upgrade to neo4j 4.4.0 or later in order to use this functionality. ' +
72+
`Trying to impersonate ${impersonatedUser}.`
73+
)
74+
75+
// unsupported API was used, consider this a fatal error for the current connection
76+
onProtocolError(error.message)
77+
observer.onError(error)
78+
throw error
79+
}
80+
}
81+
82+
export { assertDatabaseIsEmpty, assertTxConfigIsEmpty, assertImpersonatedUserIsEmpty }

0 commit comments

Comments
 (0)