@forestadmin/datasource-customizer 1.40.4 → 1.41.0

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.
Files changed (49) hide show
  1. package/dist/decorators/search/collection-search-context.d.ts +26 -0
  2. package/dist/decorators/search/collection-search-context.js +14 -0
  3. package/dist/decorators/search/collection.d.ts +5 -5
  4. package/dist/decorators/search/collection.js +50 -47
  5. package/dist/decorators/search/custom-parser/condition-tree-query-walker.d.ts +27 -0
  6. package/dist/decorators/search/custom-parser/condition-tree-query-walker.js +125 -0
  7. package/dist/decorators/search/custom-parser/custom-error-strategy.d.ts +5 -0
  8. package/dist/decorators/search/custom-parser/custom-error-strategy.js +11 -0
  9. package/dist/decorators/search/custom-parser/custom-query-parser.d.ts +6 -0
  10. package/dist/decorators/search/custom-parser/custom-query-parser.js +15 -0
  11. package/dist/decorators/search/custom-parser/fields-query-walker.d.ts +7 -0
  12. package/dist/decorators/search/custom-parser/fields-query-walker.js +17 -0
  13. package/dist/decorators/search/filter-builder/build-basic-array-field-filter.d.ts +3 -0
  14. package/dist/decorators/search/filter-builder/build-basic-array-field-filter.js +25 -0
  15. package/dist/decorators/search/filter-builder/build-boolean-field-filter.d.ts +3 -0
  16. package/dist/decorators/search/filter-builder/build-boolean-field-filter.js +27 -0
  17. package/dist/decorators/search/filter-builder/build-date-field-filter.d.ts +10 -0
  18. package/dist/decorators/search/filter-builder/build-date-field-filter.js +164 -0
  19. package/dist/decorators/search/filter-builder/build-enum-array-field-filter.d.ts +3 -0
  20. package/dist/decorators/search/filter-builder/build-enum-array-field-filter.js +16 -0
  21. package/dist/decorators/search/filter-builder/build-enum-field-filter.d.ts +3 -0
  22. package/dist/decorators/search/filter-builder/build-enum-field-filter.js +27 -0
  23. package/dist/decorators/search/filter-builder/build-number-array-field-filter.d.ts +3 -0
  24. package/dist/decorators/search/filter-builder/build-number-array-field-filter.js +14 -0
  25. package/dist/decorators/search/filter-builder/build-number-field-filter.d.ts +3 -0
  26. package/dist/decorators/search/filter-builder/build-number-field-filter.js +39 -0
  27. package/dist/decorators/search/filter-builder/build-string-array-field-filter.d.ts +3 -0
  28. package/dist/decorators/search/filter-builder/build-string-array-field-filter.js +11 -0
  29. package/dist/decorators/search/filter-builder/build-string-field-filter.d.ts +3 -0
  30. package/dist/decorators/search/filter-builder/build-string-field-filter.js +37 -0
  31. package/dist/decorators/search/filter-builder/build-uuid-field-filter.d.ts +3 -0
  32. package/dist/decorators/search/filter-builder/build-uuid-field-filter.js +24 -0
  33. package/dist/decorators/search/filter-builder/index.d.ts +3 -0
  34. package/dist/decorators/search/filter-builder/index.js +65 -0
  35. package/dist/decorators/search/filter-builder/utils/build-default-condition.d.ts +3 -0
  36. package/dist/decorators/search/filter-builder/utils/build-default-condition.js +8 -0
  37. package/dist/decorators/search/filter-builder/utils/find-enum-value.d.ts +3 -0
  38. package/dist/decorators/search/filter-builder/utils/find-enum-value.js +12 -0
  39. package/dist/decorators/search/generated-parser/QueryLexer.d.ts +33 -0
  40. package/dist/decorators/search/generated-parser/QueryLexer.js +98 -0
  41. package/dist/decorators/search/generated-parser/QueryListener.d.ts +129 -0
  42. package/dist/decorators/search/generated-parser/QueryListener.js +12 -0
  43. package/dist/decorators/search/generated-parser/QueryParser.d.ts +162 -0
  44. package/dist/decorators/search/generated-parser/QueryParser.js +1025 -0
  45. package/dist/decorators/search/normalize-name.d.ts +2 -0
  46. package/dist/decorators/search/normalize-name.js +7 -0
  47. package/dist/decorators/search/parse-query.d.ts +6 -0
  48. package/dist/decorators/search/parse-query.js +47 -0
  49. package/package.json +4 -2
@@ -0,0 +1,2 @@
1
+ export default function normalizeName(value: string): string;
2
+ //# sourceMappingURL=normalize-name.d.ts.map
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function normalizeName(value) {
4
+ return value.toLocaleLowerCase().replace(/[-_]/g, '');
5
+ }
6
+ exports.default = normalizeName;
7
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm9ybWFsaXplLW5hbWUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvZGVjb3JhdG9ycy9zZWFyY2gvbm9ybWFsaXplLW5hbWUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxTQUF3QixhQUFhLENBQUMsS0FBYTtJQUNqRCxPQUFPLEtBQUssQ0FBQyxpQkFBaUIsRUFBRSxDQUFDLE9BQU8sQ0FBQyxPQUFPLEVBQUUsRUFBRSxDQUFDLENBQUM7QUFDeEQsQ0FBQztBQUZELGdDQUVDIn0=
@@ -0,0 +1,6 @@
1
+ import { Caller, ColumnSchema, ConditionTree } from '@forestadmin/datasource-toolkit';
2
+ import { QueryContext } from './generated-parser/QueryParser';
3
+ export declare function parseQuery(query: string): QueryContext;
4
+ export declare function generateConditionTree(caller: Caller, tree: QueryContext, fields: [string, ColumnSchema][]): ConditionTree;
5
+ export declare function extractSpecifiedFields(tree: QueryContext): string[];
6
+ //# sourceMappingURL=parse-query.d.ts.map
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.extractSpecifiedFields = exports.generateConditionTree = exports.parseQuery = void 0;
7
+ const antlr4_1 = require("antlr4");
8
+ const condition_tree_query_walker_1 = __importDefault(require("./custom-parser/condition-tree-query-walker"));
9
+ const custom_query_parser_1 = __importDefault(require("./custom-parser/custom-query-parser"));
10
+ /**
11
+ * All these classes are generated by antlr (the command line)
12
+ * In order to support new syntax:
13
+ * 1. Update the grammar file (src/parser/Query.g4)
14
+ * 2. Run `yarn build:parser` to generate the new classes
15
+ * 3. Manually update the parser to add `override` on the EOF line (needed by TS)
16
+ *
17
+ * The grammar syntax is documented here: https://www.antlr.org/
18
+ * And can be tested online here: http://lab.antlr.org/
19
+ */
20
+ const fields_query_walker_1 = __importDefault(require("./custom-parser/fields-query-walker"));
21
+ const QueryLexer_1 = __importDefault(require("./generated-parser/QueryLexer"));
22
+ function parseQuery(query) {
23
+ const chars = new antlr4_1.CharStream(query?.trim()); // replace this with a FileStream as required
24
+ const lexer = new QueryLexer_1.default(chars);
25
+ const tokens = new antlr4_1.CommonTokenStream(lexer);
26
+ const parser = new custom_query_parser_1.default(tokens);
27
+ return parser.query();
28
+ }
29
+ exports.parseQuery = parseQuery;
30
+ function generateConditionTree(caller, tree, fields) {
31
+ const walker = new condition_tree_query_walker_1.default(caller, fields);
32
+ antlr4_1.ParseTreeWalker.DEFAULT.walk(walker, tree);
33
+ const result = walker.conditionTree;
34
+ if (result) {
35
+ return result;
36
+ }
37
+ // Parsing error, fallback
38
+ return walker.generateDefaultFilter(tree.getText());
39
+ }
40
+ exports.generateConditionTree = generateConditionTree;
41
+ function extractSpecifiedFields(tree) {
42
+ const walker = new fields_query_walker_1.default();
43
+ antlr4_1.ParseTreeWalker.DEFAULT.walk(walker, tree);
44
+ return walker.fields;
45
+ }
46
+ exports.extractSpecifiedFields = extractSpecifiedFields;
47
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFyc2UtcXVlcnkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvZGVjb3JhdG9ycy9zZWFyY2gvcGFyc2UtcXVlcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQ0EsbUNBQXdFO0FBRXhFLDhHQUFtRjtBQUNuRiw4RkFBb0U7QUFDcEU7Ozs7Ozs7OztHQVNHO0FBQ0gsOEZBQW9FO0FBQ3BFLCtFQUF1RDtBQUd2RCxTQUFnQixVQUFVLENBQUMsS0FBYTtJQUN0QyxNQUFNLEtBQUssR0FBRyxJQUFJLG1CQUFVLENBQUMsS0FBS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QUM7QUFDdkIsQ0FBQztBQUxELHdEQUtDIn0=
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forestadmin/datasource-customizer",
3
- "version": "1.40.4",
3
+ "version": "1.41.0",
4
4
  "main": "dist/index.js",
5
5
  "license": "GPL-3.0",
6
6
  "publishConfig": {
@@ -16,6 +16,7 @@
16
16
  "dist/**/*.d.ts"
17
17
  ],
18
18
  "scripts": {
19
+ "build:parser": "antlr4 -Xexact-output-dir -o src/decorators/search/generated-parser -Dlanguage=TypeScript src/decorators/search/Query.g4",
19
20
  "build": "tsc",
20
21
  "build:watch": "tsc --watch",
21
22
  "clean": "rm -rf coverage dist",
@@ -28,7 +29,8 @@
28
29
  "@types/uuid": "^9.0.0"
29
30
  },
30
31
  "dependencies": {
31
- "@forestadmin/datasource-toolkit": "1.29.2",
32
+ "@forestadmin/datasource-toolkit": "1.30.0",
33
+ "antlr4": "^4.13.1-patch-1",
32
34
  "file-type": "^16.5.4",
33
35
  "luxon": "^3.2.1",
34
36
  "object-hash": "^3.0.0",