dbgate-tools 5.0.5 → 5.0.6-alpha.2
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.
- package/lib/filterName.d.ts +4 -1
- package/lib/filterName.js +16 -3
- package/package.json +3 -3
package/lib/filterName.d.ts
CHANGED
package/lib/filterName.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.filterName = void 0;
|
|
7
7
|
const compact_1 = __importDefault(require("lodash/compact"));
|
|
8
|
+
const isString_1 = __importDefault(require("lodash/isString"));
|
|
8
9
|
// original C# variant
|
|
9
10
|
// public bool Match(string value)
|
|
10
11
|
// {
|
|
@@ -61,11 +62,23 @@ function filterName(filter, ...names) {
|
|
|
61
62
|
// const camelVariants = [name.replace(/[^A-Z]/g, '')]
|
|
62
63
|
const tokens = filter.split(' ').map(x => x.trim());
|
|
63
64
|
const namesCompacted = (0, compact_1.default)(names);
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
const namesOwn = namesCompacted.filter(x => (0, isString_1.default)(x));
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
const namesChild = namesCompacted.filter(x => x.childName).map(x => x.childName);
|
|
64
69
|
for (const token of tokens) {
|
|
65
70
|
const tokenUpper = token.toUpperCase();
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
if (tokenUpper.startsWith('#')) {
|
|
72
|
+
const tokenUpperSub = tokenUpper.substring(1);
|
|
73
|
+
const found = namesChild.find(name => fuzzysearch(tokenUpperSub, name.toUpperCase()));
|
|
74
|
+
if (!found)
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
const found = namesOwn.find(name => fuzzysearch(tokenUpper, name.toUpperCase()));
|
|
79
|
+
if (!found)
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
69
82
|
}
|
|
70
83
|
return true;
|
|
71
84
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.0.
|
|
2
|
+
"version": "5.0.6-alpha.2",
|
|
3
3
|
"name": "dbgate-tools",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"typings": "lib/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
],
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^13.7.0",
|
|
28
|
-
"dbgate-types": "^5.0.
|
|
28
|
+
"dbgate-types": "^5.0.6-alpha.2",
|
|
29
29
|
"jest": "^24.9.0",
|
|
30
30
|
"ts-jest": "^25.2.1",
|
|
31
31
|
"typescript": "^4.4.3"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"lodash": "^4.17.21",
|
|
35
35
|
"dbgate-query-splitter": "^4.9.0",
|
|
36
|
-
"dbgate-sqltree": "^5.0.
|
|
36
|
+
"dbgate-sqltree": "^5.0.6-alpha.2",
|
|
37
37
|
"uuid": "^3.4.0"
|
|
38
38
|
}
|
|
39
39
|
}
|