Skip to content

Commit neo4j-driver-deno to the repository #1004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"scripts": {
"clean": "lerna clean -y && lerna run clean",
"build": "lerna bootstrap --ci",
"build::deno": "(cd ./packages/neo4j-driver-deno && deno run --allow-read --allow-write --allow-net ./generate.ts --version=5.0.0-dev)",
"build::deno": "cd ./packages/neo4j-driver-deno && deno run --allow-read --allow-write --allow-net ./generate.ts --version=5.0.0-dev",
"build::notci": "lerna bootstrap",
"docs": "lerna run docs --stream --concurrency 1",
"test::unit": "lerna run test::unit --stream",
Expand Down
2 changes: 1 addition & 1 deletion packages/neo4j-driver-deno/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
lib/
.vscode/
lib2/
4 changes: 2 additions & 2 deletions packages/neo4j-driver-deno/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const isDir = (path: string) => {
////////////////////////////////////////////////////////////////////////////////
// Parse arguments
const parsedArgs = parse(Deno.args, {
string: ["version"],
string: ["version", "output"],
boolean: ["transform"], // Pass --no-transform to disable
default: { transform: true },
unknown: (arg) => {
Expand All @@ -42,7 +42,7 @@ const version = parsedArgs.version ?? "0.0.0dev";

////////////////////////////////////////////////////////////////////////////////
// Clear out the destination folder
const rootOutDir = "lib/";
const rootOutDir = parsedArgs.output ?? "lib/";
await ensureDir(rootOutDir); // Make sure it exists
for await (const existingFile of Deno.readDir(rootOutDir)) {
await Deno.remove(`${rootOutDir}${existingFile.name}`, { recursive: true });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { newError } from '../../core/index.ts'
// eslint-disable-next-line no-unused-vars
import { ResultStreamObserver } from './stream-observers.js'

/**
* @param {TxConfig} txConfig the auto-commit transaction configuration.
* @param {function(error: string)} onProtocolError called when the txConfig is not empty.
* @param {ResultStreamObserver} observer the response observer.
*/
function assertTxConfigIsEmpty (txConfig, onProtocolError = () => {}, observer) {
if (txConfig && !txConfig.isEmpty()) {
const error = newError(
'Driver is connected to the database that does not support transaction configuration. ' +
'Please upgrade to neo4j 3.5.0 or later in order to use this functionality'
)

// unsupported API was used, consider this a fatal error for the current connection
onProtocolError(error.message)
observer.onError(error)
throw error
}
}

/**
* Asserts that the passed-in database name is empty.
* @param {string} database
* @param {fuction(err: String)} onProtocolError Called when it doesn't have database set
*/
function assertDatabaseIsEmpty (database, onProtocolError = () => {}, observer) {
if (database) {
const error = newError(
'Driver is connected to the database that does not support multiple databases. ' +
'Please upgrade to neo4j 4.0.0 or later in order to use this functionality'
)

// unsupported API was used, consider this a fatal error for the current connection
onProtocolError(error.message)
observer.onError(error)
throw error
}
}

/**
* Asserts that the passed-in impersonated user is empty
* @param {string} impersonatedUser
* @param {function (err:Error)} onProtocolError Called when it does have impersonated user set
* @param {any} observer
*/
function assertImpersonatedUserIsEmpty (impersonatedUser, onProtocolError = () => {}, observer) {
if (impersonatedUser) {
const error = newError(
'Driver is connected to the database that does not support user impersonation. ' +
'Please upgrade to neo4j 4.4.0 or later in order to use this functionality. ' +
`Trying to impersonate ${impersonatedUser}.`
)

// unsupported API was used, consider this a fatal error for the current connection
onProtocolError(error.message)
observer.onError(error)
throw error
}
}

export { assertDatabaseIsEmpty, assertTxConfigIsEmpty, assertImpersonatedUserIsEmpty }
Loading