Skip to content

Commit

Permalink
feat: upgraded the driver, added extra logs on querying the labels st…
Browse files Browse the repository at this point in the history
…ep, cleaned up the redundant dependencies
  • Loading branch information
chulanovskyi-bs committed Oct 21, 2024
1 parent 936f081 commit 0193621
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 231 deletions.
25 changes: 6 additions & 19 deletions forward_engineering/api.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
const { dependencies, setDependencies } = require('./helpers/appDependencies');
const _ = require('lodash');
const applyToInstanceHelper = require('./helpers/applyToInstance');
let _;
const setAppDependencies = ({ lodash }) => (_ = lodash);

module.exports = {
generateContainerScript(data, logger, cb, app) {
setDependencies(app);
setAppDependencies(dependencies);
generateContainerScript(data, logger, cb) {
let { collections, relationships, jsonData } = data;
const dbVersion = data.modelData[0]?.dbVersion;
logger.clear();
Expand All @@ -24,7 +20,6 @@ module.exports = {
setTimeout(() => {
cb({ message: e.message, stack: e.stack });
}, 150);
return;
}
},

Expand Down Expand Up @@ -133,13 +128,12 @@ module.exports = {
},

applyToInstance(connectionInfo, logger, callback, app) {
setDependencies(app);
logger.clear();
logger.log('info', connectionInfo, 'connectionInfo', connectionInfo.hiddenKeys);
const sshService = app.require('@hackolade/ssh-service');

applyToInstanceHelper
.applyToInstance(connectionInfo, dependencies, logger, sshService)
.applyToInstance(connectionInfo, logger, sshService)
.then(result => {
callback(null, result);
})
Expand All @@ -149,11 +143,10 @@ module.exports = {
},

testConnection(connectionInfo, logger, callback, app) {
setDependencies(app);
logger.log('info', connectionInfo, 'connectionInfo', connectionInfo.hiddenKeys);
const sshService = app.require('@hackolade/ssh-service');

applyToInstanceHelper.testConnection(connectionInfo, dependencies, sshService).then(callback, err => {
applyToInstanceHelper.testConnection(connectionInfo, sshService).then(callback, err => {
logger.log('error', err, 'Neo4j test connection error');
callback({ ...err, type: 'simpleError' });
});
Expand Down Expand Up @@ -246,9 +239,7 @@ module.exports = {
parent,
relationship,
child,
bidirectional:
relationship?.customProperties?.biDirectional &&
child.GUID !== parent.GUID,
bidirectional: relationship?.customProperties?.biDirectional && child.GUID !== parent.GUID,
});
});
} else if (!hasRelationship[parent.GUID]) {
Expand Down Expand Up @@ -488,10 +479,7 @@ module.exports = {
if (entity.index) {
entity.index.forEach(index => {
if (index.key) {
const fields = this.findFields(
entity,
index.key.map(getId),
);
const fields = this.findFields(entity, index.key.map(getId));
if (fields.length) {
const indexScript = getIndex({
entity,
Expand Down Expand Up @@ -630,7 +618,6 @@ module.exports = {
const screen = s => `\`${s}\``;

const getProperty = (schema, field) => {
setAppDependencies(dependencies);
if (_.has(schema, `properties.${field}`)) {
return schema.properties[field];
} else if (_.has(schema, `allOf.${field}`)) {
Expand Down
10 changes: 0 additions & 10 deletions forward_engineering/helpers/appDependencies.js

This file was deleted.

6 changes: 2 additions & 4 deletions forward_engineering/helpers/applyToInstance.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const neo4jHelper = require('../../reverse_engineering/neo4jHelper');

const applyToInstanceHelper = {
async applyToInstance(connectionInfo, dependencies, logger, sshService) {
async applyToInstance(connectionInfo, logger, sshService) {
try {
logger.log(
'info',
Expand All @@ -11,7 +11,6 @@ const applyToInstanceHelper = {
'Neo4j script',
);

neo4jHelper.setDependencies(dependencies);
await neo4jHelper.connect(connectionInfo, () => Promise.resolve(), sshService);
const instanceSupportMultiDb = await neo4jHelper.supportsMultiDb();
const dbData = connectionInfo.containerData?.[0];
Expand Down Expand Up @@ -66,8 +65,7 @@ const applyToInstanceHelper = {
}
},

async testConnection(connectionInfo, dependencies, sshService) {
neo4jHelper.setDependencies(dependencies);
async testConnection(connectionInfo, sshService) {
await neo4jHelper.connect(connectionInfo, () => Promise.resolve(), sshService);
await neo4jHelper.close(sshService);
},
Expand Down
78 changes: 29 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
"description": "Hackolade plugin for Neo4j",
"disabled": false,
"dependencies": {
"async": "3.2.6",
"lodash": "4.17.21",
"neo4j-driver": "4.4.10"
"neo4j-driver": "5.26.0"
},
"lint-staged": {
"*.{js,json}": "prettier --write"
Expand Down Expand Up @@ -80,4 +81,4 @@
"prettier": "3.2.5",
"simple-git-hooks": "2.11.1"
}
}
}
95 changes: 0 additions & 95 deletions patches/neo4j-driver-bolt-connection+4.4.11.patch

This file was deleted.

Loading

0 comments on commit 0193621

Please sign in to comment.