@gooddata/maql-antlr4ts 0.2.1-001666cb.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.
package/README.md ADDED
@@ -0,0 +1,97 @@
1
+ # MAQL ANTLR4TS npm package
2
+
3
+ The module bundles TypeScript MAQL lexer and parser generated from MAQL grammar,
4
+ a visitor to create MAQL AST, and an abstract AST visitor to work with MAQL AST.
5
+
6
+ The package antlr4ts is required on use, but is not bundled along with this package
7
+ and must be provided externally.
8
+
9
+ Example usage:
10
+
11
+ ```typescript
12
+ import { CommonTokenStream } from "antlr4ts";
13
+
14
+ import {
15
+ CaseInsensitiveCharStream,
16
+ MaqlLexer,
17
+ MaqlParser,
18
+ MaqlAstVisitor,
19
+ AstNormalizer,
20
+ } from "@gooddata/maql-antlr4ts";
21
+
22
+ const maql = "parse metric SELECT SUM(0.81 * {fact/price} * {fact/quantity}) BY {attribute/country} WITHOUT PF";
23
+ const charStream = new CaseInsensitiveCharStream(maql);
24
+ const lexer = new MaqlLexer(charStream);
25
+ const tokenStream = new CommonTokenStream(lexer);
26
+ const parser = new MaqlParser(tokenStream);
27
+ const parseTree = parser.maql();
28
+ const astVisitor = new MaqlAstVisitor(workspace);
29
+ const ast = astVisitor.visit(parseTree);
30
+ const normalizer = new AstNormalizer();
31
+ const normalizedAst = normalizer.visit(ast);
32
+ ```
33
+
34
+ ## Local development
35
+
36
+ > Requirements: [`yarn`](https://yarnpkg.com)
37
+
38
+ | command | effect |
39
+ |------------------|-------------------------------------------------------------------|
40
+ | `yarn install` | install all dependencies |
41
+ | `yarn build` | generate source files, compile files, bundle files into a package |
42
+ | `yarn antlr4ts` | generate source files from MAQL grammar |
43
+ | `yarn funcdef` | generate source files from MAQL function definitions |
44
+ | `yarn compile` | compile TypeScript |
45
+ | `yarn rollup -c` | bundle files into a package |
46
+ | `yarn test` | run ESLint, Prettier, and all tests |
47
+ | `yarn test-ci` | run `yarn test` with CI options and junit.xml output file |
48
+ | `yarn fix` | automatically fix ESLint and Prettier errors |
49
+
50
+ ## Linking the package to other modules
51
+
52
+ First build and bundle the module.
53
+
54
+ `yarn build`
55
+
56
+ > Warning: Do not use `yarn link` or `npm link`.
57
+ >
58
+ > Currently, there exists an issue which causes a runtime error when symbolically linking
59
+ > this package using `yarn` or `npm`. The error seems to involve the `antlr4ts` library,
60
+ > because it results in every single token having index of -1.
61
+
62
+ Use [yalc](https://github.com/wclr/yalc) to link the package to other repositories.
63
+
64
+ 1. Run `yalc publish` in the current directory.
65
+ 2. Run `yalc add @gooddata/maql-antlr4ts` in the target directory
66
+ 3. Once you are done with testing run `yalc remove @gooddata/maql-antlr4ts` or `yalc remove --all`
67
+
68
+ ## Publishing
69
+
70
+ The package is published automatically after merging to master branch.
71
+
72
+ ### Manual publishing
73
+
74
+ > Unless you have a good reason to do so (i.e. you cannot test a feature otherwise)
75
+ **do not** publish the package manually.
76
+
77
+ Create a GitLab access token with `api` permissions and store it
78
+ in the `NPM_TOKEN` environment variable.
79
+
80
+ `export NPM_TOKEN=<your acces token>`
81
+
82
+ Build and publish the package. You must first set a new version of the package. You must choose one that is not yet
83
+ taken
84
+ (or delete the existing package). You can use
85
+ `yarn bump` or `yarn version <new version>`.
86
+
87
+ Then you should build the package
88
+
89
+ `yarn build`
90
+
91
+ and publish.
92
+
93
+ `npm publish`
94
+
95
+ You should now be able to see the package in the GitLab project registry.
96
+
97
+ The id of the project is set to `16539767`