Skip to content

Commit

Permalink
Feature/hck 3426 re couchbase 7 instance re (#5)
Browse files Browse the repository at this point in the history
* package: add lodash library

* RE: update re modal config

* RE: implement get document kinds method

* RE: add types for document kind data methods

* package: add async library

* RE: create rest api helper

* RE: add retrive collections by doc kind using rest api

* RE: implement retrive documents from default collection

* RE: implement retrive documents for scopes and collections

* RE: fix typo

* package: install antler

* RE: implement antlr parser

* RE: implement collection indexes reversing

* RE: fix incorrect error message

* RE: add constant for default key name

* RE: implement re from n1ql files

* RE: add split default scope names to avoid their combining

* package: add parser folder to eslint ignore

* package: remove unneded libs

* config: add container level keys config

* RE: add document kinds value to db collections data

* RE: add logging for test connection

* RE: add safety getting scopes for document kinds

* package: install hackolade couchbase deps

* parser: remove license data

* RE: fix names of params

* RE: add require of couchbase lib

* RE: replace complex iterations by async reduce

* RE: reduce complexity for retriving doc kinds by manual infer

* types: fix typing for some methods

* package: uninstall redundant couchbase types lib

* package: add exact lib versions

* RE: fix create of empty scopes after reversing from file

* package: remove couchbase native module

* build: add .ts files to excluded extensions

* package: add types lib to dev dependencies

* RE: add retrive selected bucket collections if selected collections are not specifed

---------

Co-authored-by: Ugo Bechameil <[email protected]>
  • Loading branch information
serhii-filonenko and bigorn0 authored Feb 7, 2024
1 parent 4bec104 commit a4b6668
Show file tree
Hide file tree
Showing 31 changed files with 34,596 additions and 195 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.idea
node_modules
reverse_engineering/node_modules
reverse_engineering/antlr/parser
forward_engineering/node_modules
build
release
2 changes: 1 addition & 1 deletion buildConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path');

const DEFAULT_RELEASE_FOLDER_PATH = path.resolve(__dirname, 'release');

const EXCLUDED_EXTENSIONS = ['.js', '.g4', '.interp', '.tokens'];
const EXCLUDED_EXTENSIONS = ['.js', '.g4', '.interp', '.tokens', '.ts'];
const EXCLUDED_FILES = [
'.github',
'.DS_Store',
Expand Down
2 changes: 1 addition & 1 deletion localization/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"MODAL_WINDOW___SUBDOCUMENT_IN_CHILD": "Sub-document in child",
"MODAL_WINDOW___ARRAY_IN_PARENT": "Array in parent",
"MODAL_WINDOW___CREATE_COLLECTION": "Create Couchbase Collection",
"MODAL_WINDOW___INCLUDE_EMPTY_COLLECTION": "Include empty documents",
"MODAL_WINDOW___INCLUDE_EMPTY_COLLECTION": "Include empty collections",
"MODAL_WINDOW___CREATE_BUCKET": "Create Couchbase Scope",
"MODAL_WINDOW___ALL_COLLECTIONS": "and all nested collections",
"MODAL_WINDOW___COLLECTION_NAME_ERROR": "Collection name is empty or is a reserved word",
Expand Down
48 changes: 48 additions & 0 deletions package-lock.json

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

20 changes: 7 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,8 @@
]
},
"features": {
"nestedCollections": false,
"forwardEngineering": {
"jsonSchema": {
"keepParentType": {
"binary": {}
}
}
},
"enableReverseEngineering": true,
"enableForwardEngineering": true,
"enableReverseEngineeringDetectionSchemaByContent": false,
"enableReversingDateTypeAsISODate": true,
"supportInferRelationships": true,
"enableREQueryAndSortCriteria": true
"enableArrayCollections": false
}
},
"description": "Hackolade plugin for Couchbase v7+ with scopes and collections",
Expand All @@ -46,6 +34,7 @@
},
"devDependencies": {
"@hackolade/hck-esbuild-plugins-pack": "0.0.1",
"@types/couchbase": "2.4.9",
"esbuild": "0.19.12",
"esbuild-plugin-clean": "1.0.1",
"eslint": "8.56.0",
Expand All @@ -54,5 +43,10 @@
"lint-staged": "14.0.1",
"prettier": "3.2.4",
"simple-git-hooks": "2.9.0"
},
"dependencies": {
"antlr4": "4.9.2",
"async": "3.2.5",
"lodash": "4.17.21"
}
}
18 changes: 17 additions & 1 deletion properties_pane/container_level/containerLevelConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ making sure that you maintain a proper JSON format.
[
{
"lowerTab": "Details",
"containerLevelKeys": [],
"structure": [
{
"propertyKeyword": "name",
Expand Down Expand Up @@ -342,6 +341,23 @@ making sure that you maintain a proper JSON format.
"shouldValidate": false,
"propertyType": "checkbox"
}
],
"containerLevelKeys": [
{
"labelName": "Key",
"propertyName": "Key",
"propertyKeyword": "key",
"defaultName": "KEY",
"propertyPrimaryKey": true,
"propertyType": "text",
"typeName": "type",
"typeOptions": ["string"],
"defaultType": "string",
"disabledFieldOption": true,
"validation": {
"disableNameValidationForReservedWords": true
}
}
]
}
]
9 changes: 9 additions & 0 deletions reverse_engineering/antlr/antlrErrorListener.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const antlr4 = require('antlr4');

class ExprErrorListener extends antlr4.error.ErrorListener {
syntaxError(recognizer, offendingSymbol, line, column, msg, err) {
throw new Error(`line ${line}:${column} ${msg}`);
}
}

module.exports = ExprErrorListener;
23 changes: 23 additions & 0 deletions reverse_engineering/antlr/buildParser.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# * run with `sh buildParser.sh`

# !important: don't forget to change `import` and `export` to `require` and `module.exports` after the parser is built

# https://www.antlr.org/download/antlr-4.9.2-complete.jar
#
# set antlr4 aliases
# export CLASSPATH=".:/usr/local/lib/antlr-4.9.2-complete.jar:$CLASSPATH"
# alias antlr4='java -jar /usr/local/lib/antlr-4.9.2-complete.jar'
# alias grun='java org.antlr.v4.gui.TestRig'

# build parser
java -jar /usr/local/lib/antlr-4.9.2-complete.jar -Dlanguage=JavaScript \
-lib grammars \
-o parser/ \
-visitor \
-no-listener \
-Xexact-output-dir \
grammars/n1ql.g4

npx prettier --write ./parser/**/*.js
Loading

0 comments on commit a4b6668

Please sign in to comment.