@qrvey/formula-lang 0.4.0 → 0.5.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/.vscode/launch.json +15 -0
- package/CHANGELOG.md +12 -0
- package/dist/bundle.js +23152 -0
- package/dist/cjs/constants/index.d.ts +53 -0
- package/dist/cjs/constants/index.js +117 -0
- package/dist/cjs/constants/index.js.map +1 -0
- package/dist/cjs/constants/interfaces.d.ts +91 -0
- package/dist/cjs/constants/interfaces.js +3 -0
- package/dist/cjs/constants/interfaces.js.map +1 -0
- package/dist/cjs/errors/definitions.d.ts +43 -0
- package/dist/cjs/errors/definitions.js +91 -0
- package/dist/cjs/errors/definitions.js.map +1 -0
- package/dist/cjs/errors/elasticsearch.d.ts +24 -0
- package/dist/cjs/errors/elasticsearch.js +30 -0
- package/dist/cjs/errors/elasticsearch.js.map +1 -0
- package/dist/cjs/errors/engineErrors.d.ts +2 -0
- package/dist/cjs/errors/engineErrors.js +25 -0
- package/dist/cjs/errors/engineErrors.js.map +1 -0
- package/dist/cjs/errors/index.d.ts +2 -0
- package/dist/cjs/errors/index.js +21 -0
- package/dist/cjs/errors/index.js.map +1 -0
- package/dist/cjs/errors/snowflake.d.ts +15 -0
- package/dist/cjs/errors/snowflake.js +20 -0
- package/dist/cjs/errors/snowflake.js.map +1 -0
- package/dist/cjs/functions/abs.d.ts +5 -0
- package/dist/cjs/functions/abs.js +38 -0
- package/dist/cjs/functions/abs.js.map +1 -0
- package/dist/cjs/functions/datedif.d.ts +5 -0
- package/dist/cjs/functions/datedif.js +64 -0
- package/dist/cjs/functions/datedif.js.map +1 -0
- package/dist/cjs/functions/day.d.ts +5 -0
- package/dist/cjs/functions/day.js +39 -0
- package/dist/cjs/functions/day.js.map +1 -0
- package/dist/cjs/functions/hour.d.ts +5 -0
- package/dist/cjs/functions/hour.js +39 -0
- package/dist/cjs/functions/hour.js.map +1 -0
- package/dist/cjs/functions/if.d.ts +5 -0
- package/dist/cjs/functions/if.js +52 -0
- package/dist/cjs/functions/if.js.map +1 -0
- package/dist/cjs/functions/ifs.d.ts +5 -0
- package/dist/cjs/functions/ifs.js +74 -0
- package/dist/cjs/functions/ifs.js.map +1 -0
- package/dist/cjs/functions/index.d.ts +4 -0
- package/dist/cjs/functions/index.js +33 -0
- package/dist/cjs/functions/index.js.map +1 -0
- package/dist/cjs/functions/mid.d.ts +5 -0
- package/dist/cjs/functions/mid.js +54 -0
- package/dist/cjs/functions/mid.js.map +1 -0
- package/dist/cjs/functions/minute.d.ts +5 -0
- package/dist/cjs/functions/minute.js +39 -0
- package/dist/cjs/functions/minute.js.map +1 -0
- package/dist/cjs/functions/month.d.ts +5 -0
- package/dist/cjs/functions/month.js +39 -0
- package/dist/cjs/functions/month.js.map +1 -0
- package/dist/cjs/functions/second.d.ts +5 -0
- package/dist/cjs/functions/second.js +39 -0
- package/dist/cjs/functions/second.js.map +1 -0
- package/dist/cjs/functions/year.d.ts +5 -0
- package/dist/cjs/functions/year.js +39 -0
- package/dist/cjs/functions/year.js.map +1 -0
- package/dist/cjs/grammar/generated/qformula.lang.d.ts +13 -0
- package/dist/cjs/grammar/generated/qformula.lang.js +50 -0
- package/dist/cjs/grammar/generated/qformula.lang.js.map +1 -0
- package/dist/cjs/grammar/qformula.grammar.d.ts +1 -0
- package/dist/cjs/grammar/qformula.grammar.js +18 -0
- package/dist/cjs/grammar/qformula.grammar.js.map +1 -0
- package/dist/cjs/index.d.ts +10 -0
- package/dist/cjs/index.js +33 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/main.d.ts +1 -0
- package/dist/cjs/main.js +69 -0
- package/dist/cjs/main.js.map +1 -0
- package/dist/cjs/parser/json-parser.d.ts +3 -0
- package/dist/cjs/parser/json-parser.js +201 -0
- package/dist/cjs/parser/json-parser.js.map +1 -0
- package/dist/cjs/parser/syntax-errors.d.ts +3 -0
- package/dist/cjs/parser/syntax-errors.js +28 -0
- package/dist/cjs/parser/syntax-errors.js.map +1 -0
- package/dist/cjs/transpiler/columnTranspilation.d.ts +3 -0
- package/dist/cjs/transpiler/columnTranspilation.js +29 -0
- package/dist/cjs/transpiler/columnTranspilation.js.map +1 -0
- package/dist/cjs/transpiler/index.d.ts +18 -0
- package/dist/cjs/transpiler/index.js +107 -0
- package/dist/cjs/transpiler/index.js.map +1 -0
- package/dist/cjs/transpiler/unshiftCustomFunctions.d.ts +2 -0
- package/dist/cjs/transpiler/unshiftCustomFunctions.js +14 -0
- package/dist/cjs/transpiler/unshiftCustomFunctions.js.map +1 -0
- package/dist/cjs/transpiler/validateFuncStructure.d.ts +2 -0
- package/dist/cjs/transpiler/validateFuncStructure.js +41 -0
- package/dist/cjs/transpiler/validateFuncStructure.js.map +1 -0
- package/dist/cjs/utils/customFunctions.d.ts +4 -0
- package/dist/cjs/utils/customFunctions.js +35 -0
- package/dist/cjs/utils/customFunctions.js.map +1 -0
- package/dist/cjs/utils/elasticsearch/index.d.ts +2 -0
- package/dist/cjs/utils/elasticsearch/index.js +22 -0
- package/dist/cjs/utils/elasticsearch/index.js.map +1 -0
- package/dist/cjs/utils/elasticsearch/scripts.d.ts +11 -0
- package/dist/cjs/utils/elasticsearch/scripts.js +57 -0
- package/dist/cjs/utils/elasticsearch/scripts.js.map +1 -0
- package/dist/cjs/utils/getMonthMaxDayAllowed.d.ts +7 -0
- package/dist/cjs/utils/getMonthMaxDayAllowed.js +26 -0
- package/dist/cjs/utils/getMonthMaxDayAllowed.js.map +1 -0
- package/dist/cjs/utils/getNodeValue.d.ts +2 -0
- package/dist/cjs/utils/getNodeValue.js +13 -0
- package/dist/cjs/utils/getNodeValue.js.map +1 -0
- package/dist/cjs/utils/getVariableType.d.ts +3 -0
- package/dist/cjs/utils/getVariableType.js +19 -0
- package/dist/cjs/utils/getVariableType.js.map +1 -0
- package/dist/cjs/utils/index.d.ts +10 -0
- package/dist/cjs/utils/index.js +29 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/isDateParam.d.ts +2 -0
- package/dist/cjs/utils/isDateParam.js +12 -0
- package/dist/cjs/utils/isDateParam.js.map +1 -0
- package/dist/cjs/utils/isNumberParam.d.ts +2 -0
- package/dist/cjs/utils/isNumberParam.js +12 -0
- package/dist/cjs/utils/isNumberParam.js.map +1 -0
- package/dist/cjs/utils/isPositiveNumberParam.d.ts +2 -0
- package/dist/cjs/utils/isPositiveNumberParam.js +12 -0
- package/dist/cjs/utils/isPositiveNumberParam.js.map +1 -0
- package/dist/cjs/utils/isStringParam.d.ts +2 -0
- package/dist/cjs/utils/isStringParam.js +12 -0
- package/dist/cjs/utils/isStringParam.js.map +1 -0
- package/dist/cjs/utils/isValidDate.d.ts +1 -0
- package/dist/cjs/utils/isValidDate.js +8 -0
- package/dist/cjs/utils/isValidDate.js.map +1 -0
- package/dist/cjs/utils/sql/index.d.ts +1 -0
- package/dist/cjs/utils/sql/index.js +6 -0
- package/dist/cjs/utils/sql/index.js.map +1 -0
- package/dist/cjs/utils/sql/scripts.d.ts +3 -0
- package/dist/cjs/utils/sql/scripts.js +44 -0
- package/dist/cjs/utils/sql/scripts.js.map +1 -0
- package/dist/constants/index.d.ts +11 -2
- package/dist/constants/index.js +11 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/interfaces.d.ts +13 -3
- package/dist/errors/definitions.d.ts +20 -3
- package/dist/errors/definitions.js +20 -2
- package/dist/errors/definitions.js.map +1 -1
- package/dist/grammar/generated/qformula.lang.d.ts +9 -0
- package/dist/grammar/generated/qformula.lang.js +5 -4
- package/dist/grammar/generated/qformula.lang.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.html +21 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +1 -0
- package/dist/main.js +65 -0
- package/dist/main.js.map +1 -0
- package/dist/module/constants/index.d.ts +53 -0
- package/dist/module/constants/index.js +114 -0
- package/dist/module/constants/index.js.map +1 -0
- package/dist/module/constants/interfaces.d.ts +91 -0
- package/dist/module/constants/interfaces.js +2 -0
- package/dist/module/constants/interfaces.js.map +1 -0
- package/dist/module/errors/definitions.d.ts +43 -0
- package/dist/module/errors/definitions.js +78 -0
- package/dist/module/errors/definitions.js.map +1 -0
- package/dist/module/errors/elasticsearch.d.ts +24 -0
- package/dist/module/errors/elasticsearch.js +27 -0
- package/dist/module/errors/elasticsearch.js.map +1 -0
- package/dist/module/errors/engineErrors.d.ts +2 -0
- package/dist/module/errors/engineErrors.js +21 -0
- package/dist/module/errors/engineErrors.js.map +1 -0
- package/dist/module/errors/index.d.ts +2 -0
- package/dist/module/errors/index.js +5 -0
- package/dist/module/errors/index.js.map +1 -0
- package/dist/module/errors/snowflake.d.ts +15 -0
- package/dist/module/errors/snowflake.js +17 -0
- package/dist/module/errors/snowflake.js.map +1 -0
- package/dist/module/functions/abs.d.ts +5 -0
- package/dist/module/functions/abs.js +35 -0
- package/dist/module/functions/abs.js.map +1 -0
- package/dist/module/functions/datedif.d.ts +5 -0
- package/dist/module/functions/datedif.js +61 -0
- package/dist/module/functions/datedif.js.map +1 -0
- package/dist/module/functions/day.d.ts +5 -0
- package/dist/module/functions/day.js +36 -0
- package/dist/module/functions/day.js.map +1 -0
- package/dist/module/functions/hour.d.ts +5 -0
- package/dist/module/functions/hour.js +36 -0
- package/dist/module/functions/hour.js.map +1 -0
- package/dist/module/functions/if.d.ts +5 -0
- package/dist/module/functions/if.js +49 -0
- package/dist/module/functions/if.js.map +1 -0
- package/dist/module/functions/ifs.d.ts +5 -0
- package/dist/module/functions/ifs.js +71 -0
- package/dist/module/functions/ifs.js.map +1 -0
- package/dist/module/functions/index.d.ts +4 -0
- package/dist/module/functions/index.js +29 -0
- package/dist/module/functions/index.js.map +1 -0
- package/dist/module/functions/mid.d.ts +5 -0
- package/dist/module/functions/mid.js +51 -0
- package/dist/module/functions/mid.js.map +1 -0
- package/dist/module/functions/minute.d.ts +5 -0
- package/dist/module/functions/minute.js +36 -0
- package/dist/module/functions/minute.js.map +1 -0
- package/dist/module/functions/month.d.ts +5 -0
- package/dist/module/functions/month.js +36 -0
- package/dist/module/functions/month.js.map +1 -0
- package/dist/module/functions/second.d.ts +5 -0
- package/dist/module/functions/second.js +36 -0
- package/dist/module/functions/second.js.map +1 -0
- package/dist/module/functions/year.d.ts +5 -0
- package/dist/module/functions/year.js +36 -0
- package/dist/module/functions/year.js.map +1 -0
- package/dist/module/grammar/generated/qformula.lang.d.ts +13 -0
- package/dist/module/grammar/generated/qformula.lang.js +45 -0
- package/dist/module/grammar/generated/qformula.lang.js.map +1 -0
- package/dist/module/grammar/qformula.grammar.d.ts +1 -0
- package/dist/module/grammar/qformula.grammar.js +2 -0
- package/dist/module/grammar/qformula.grammar.js.map +1 -0
- package/dist/module/index.d.ts +10 -0
- package/dist/module/index.js +20 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/main.d.ts +1 -0
- package/dist/module/main.js +67 -0
- package/dist/module/main.js.map +1 -0
- package/dist/module/parser/json-parser.d.ts +3 -0
- package/dist/module/parser/json-parser.js +197 -0
- package/dist/module/parser/json-parser.js.map +1 -0
- package/dist/module/parser/syntax-errors.d.ts +3 -0
- package/dist/module/parser/syntax-errors.js +24 -0
- package/dist/module/parser/syntax-errors.js.map +1 -0
- package/dist/module/transpiler/columnTranspilation.d.ts +3 -0
- package/dist/module/transpiler/columnTranspilation.js +25 -0
- package/dist/module/transpiler/columnTranspilation.js.map +1 -0
- package/dist/module/transpiler/index.d.ts +18 -0
- package/dist/module/transpiler/index.js +102 -0
- package/dist/module/transpiler/index.js.map +1 -0
- package/dist/module/transpiler/unshiftCustomFunctions.d.ts +2 -0
- package/dist/module/transpiler/unshiftCustomFunctions.js +10 -0
- package/dist/module/transpiler/unshiftCustomFunctions.js.map +1 -0
- package/dist/module/transpiler/validateFuncStructure.d.ts +2 -0
- package/dist/module/transpiler/validateFuncStructure.js +37 -0
- package/dist/module/transpiler/validateFuncStructure.js.map +1 -0
- package/dist/module/utils/customFunctions.d.ts +4 -0
- package/dist/module/utils/customFunctions.js +29 -0
- package/dist/module/utils/customFunctions.js.map +1 -0
- package/dist/module/utils/elasticsearch/index.d.ts +2 -0
- package/dist/module/utils/elasticsearch/index.js +16 -0
- package/dist/module/utils/elasticsearch/index.js.map +1 -0
- package/dist/module/utils/elasticsearch/scripts.d.ts +11 -0
- package/dist/module/utils/elasticsearch/scripts.js +46 -0
- package/dist/module/utils/elasticsearch/scripts.js.map +1 -0
- package/dist/module/utils/getMonthMaxDayAllowed.d.ts +7 -0
- package/dist/module/utils/getMonthMaxDayAllowed.js +22 -0
- package/dist/module/utils/getMonthMaxDayAllowed.js.map +1 -0
- package/dist/module/utils/getNodeValue.d.ts +2 -0
- package/dist/module/utils/getNodeValue.js +9 -0
- package/dist/module/utils/getNodeValue.js.map +1 -0
- package/dist/module/utils/getVariableType.d.ts +3 -0
- package/dist/module/utils/getVariableType.js +14 -0
- package/dist/module/utils/getVariableType.js.map +1 -0
- package/dist/module/utils/index.d.ts +10 -0
- package/dist/module/utils/index.js +11 -0
- package/dist/module/utils/index.js.map +1 -0
- package/dist/module/utils/isDateParam.d.ts +2 -0
- package/dist/module/utils/isDateParam.js +8 -0
- package/dist/module/utils/isDateParam.js.map +1 -0
- package/dist/module/utils/isNumberParam.d.ts +2 -0
- package/dist/module/utils/isNumberParam.js +8 -0
- package/dist/module/utils/isNumberParam.js.map +1 -0
- package/dist/module/utils/isPositiveNumberParam.d.ts +2 -0
- package/dist/module/utils/isPositiveNumberParam.js +8 -0
- package/dist/module/utils/isPositiveNumberParam.js.map +1 -0
- package/dist/module/utils/isStringParam.d.ts +2 -0
- package/dist/module/utils/isStringParam.js +8 -0
- package/dist/module/utils/isStringParam.js.map +1 -0
- package/dist/module/utils/isValidDate.d.ts +1 -0
- package/dist/module/utils/isValidDate.js +4 -0
- package/dist/module/utils/isValidDate.js.map +1 -0
- package/dist/module/utils/sql/index.d.ts +1 -0
- package/dist/module/utils/sql/index.js +2 -0
- package/dist/module/utils/sql/index.js.map +1 -0
- package/dist/module/utils/sql/scripts.d.ts +3 -0
- package/dist/module/utils/sql/scripts.js +39 -0
- package/dist/module/utils/sql/scripts.js.map +1 -0
- package/dist/parser/json-parser.js +26 -15
- package/dist/parser/json-parser.js.map +1 -1
- package/dist/parser/syntax-errors.d.ts +3 -0
- package/dist/parser/syntax-errors.js +20 -0
- package/dist/parser/syntax-errors.js.map +1 -0
- package/dist/transpiler/columnTranspilation.d.ts +2 -2
- package/dist/transpiler/columnTranspilation.js +10 -4
- package/dist/transpiler/columnTranspilation.js.map +1 -1
- package/dist/transpiler/index.d.ts +4 -4
- package/dist/transpiler/index.js +28 -20
- package/dist/transpiler/index.js.map +1 -1
- package/dist/transpiler/unshiftCustomFunctions.d.ts +2 -0
- package/dist/transpiler/unshiftCustomFunctions.js +10 -0
- package/dist/transpiler/unshiftCustomFunctions.js.map +1 -0
- package/dist/utils/customFunctions.d.ts +1 -0
- package/dist/utils/customFunctions.js +10 -2
- package/dist/utils/customFunctions.js.map +1 -1
- package/dist/utils/elasticsearch/index.d.ts +1 -1
- package/dist/utils/elasticsearch/index.js +1 -1
- package/dist/utils/elasticsearch/index.js.map +1 -1
- package/dist/utils/elasticsearch/scripts.d.ts +1 -0
- package/dist/utils/elasticsearch/scripts.js +14 -4
- package/dist/utils/elasticsearch/scripts.js.map +1 -1
- package/jest.config.ts +6 -0
- package/package.json +21 -6
- package/__tests__/integration/__mocks__/context.ts +0 -23
- package/__tests__/integration/__mocks__/elasticsearchScripts.ts +0 -28
- package/__tests__/integration/__mocks__/sqlScripts.ts +0 -21
- package/__tests__/integration/elasticsearch.test.ts +0 -172
- package/__tests__/integration/expression.test.ts +0 -56
- package/__tests__/integration/redshift.test.ts +0 -142
- package/__tests__/integration/sonwflake.test.ts +0 -138
- package/__tests__/unit/parser.test.ts +0 -236
- package/__tests__/unit/transpiler.test.ts +0 -128
- package/bitbucket-pipelines.yml +0 -63
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export declare enum ENGINES {
|
|
2
|
+
ELASTICSEARCH = "elasticsearch",
|
|
3
|
+
SNOWFLAKE = "snowflake",
|
|
4
|
+
REDSHIFT = "redshift"
|
|
5
|
+
}
|
|
6
|
+
export declare enum AST_TYPES {
|
|
7
|
+
program = "Program",
|
|
8
|
+
binaryExpression = "BinaryExpression",
|
|
9
|
+
unaryExpression = "UnaryExpression",
|
|
10
|
+
functionCall = "FunctionCall",
|
|
11
|
+
variable = "Variable",
|
|
12
|
+
column = "Column",
|
|
13
|
+
token = "Token",
|
|
14
|
+
literal = "Literal",
|
|
15
|
+
unknown = "Unknown"
|
|
16
|
+
}
|
|
17
|
+
export declare enum ERROR_LIST {
|
|
18
|
+
arguments = "arguments",
|
|
19
|
+
nulls = "nulls",
|
|
20
|
+
floatingPoint = "floatingPoint",
|
|
21
|
+
missingString = "missingString",
|
|
22
|
+
missingNumber = "missingNumber",
|
|
23
|
+
missingDate = "missingDate",
|
|
24
|
+
greaterThanZero = "greaterThanZero",
|
|
25
|
+
missingArg = "missingArg",
|
|
26
|
+
missingParenthesis = "missingParenthesis",
|
|
27
|
+
unknownFunction = "unknownFunction",
|
|
28
|
+
unknown = "unknown",
|
|
29
|
+
customDateDifParams = "customDateDifParams",
|
|
30
|
+
tooManyArguments = "tooManyArguments",
|
|
31
|
+
unknownExpression = "unknownExpression",
|
|
32
|
+
unknownToken = "unknownToken",
|
|
33
|
+
notAllowedExpression = "notAllowedExpression"
|
|
34
|
+
}
|
|
35
|
+
type iErrorsType = {
|
|
36
|
+
[key in ERROR_LIST]: IErrorDictionary;
|
|
37
|
+
};
|
|
38
|
+
interface IErrorDictionary {
|
|
39
|
+
message: string;
|
|
40
|
+
code: string;
|
|
41
|
+
}
|
|
42
|
+
export declare const ERROR_DICTIONARY: iErrorsType;
|
|
43
|
+
export type CustomEngineOperators = {
|
|
44
|
+
[key in ENGINES]?: {
|
|
45
|
+
[T: string]: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export declare const CustomOperators: CustomEngineOperators;
|
|
49
|
+
export declare enum ELASTICSEARCH_SCRIPT_NAMES {
|
|
50
|
+
dateFormat = "DATE_FORMAT_SCRIPT",
|
|
51
|
+
setTimezone = "SET_TIMEZONE_SCRIPT"
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ELASTICSEARCH_SCRIPT_NAMES = exports.CustomOperators = exports.ERROR_DICTIONARY = exports.ERROR_LIST = exports.AST_TYPES = exports.ENGINES = void 0;
|
|
4
|
+
var ENGINES;
|
|
5
|
+
(function (ENGINES) {
|
|
6
|
+
ENGINES["ELASTICSEARCH"] = "elasticsearch";
|
|
7
|
+
ENGINES["SNOWFLAKE"] = "snowflake";
|
|
8
|
+
ENGINES["REDSHIFT"] = "redshift";
|
|
9
|
+
})(ENGINES = exports.ENGINES || (exports.ENGINES = {}));
|
|
10
|
+
var AST_TYPES;
|
|
11
|
+
(function (AST_TYPES) {
|
|
12
|
+
AST_TYPES["program"] = "Program";
|
|
13
|
+
AST_TYPES["binaryExpression"] = "BinaryExpression";
|
|
14
|
+
AST_TYPES["unaryExpression"] = "UnaryExpression";
|
|
15
|
+
AST_TYPES["functionCall"] = "FunctionCall";
|
|
16
|
+
AST_TYPES["variable"] = "Variable";
|
|
17
|
+
AST_TYPES["column"] = "Column";
|
|
18
|
+
AST_TYPES["token"] = "Token";
|
|
19
|
+
AST_TYPES["literal"] = "Literal";
|
|
20
|
+
AST_TYPES["unknown"] = "Unknown";
|
|
21
|
+
})(AST_TYPES = exports.AST_TYPES || (exports.AST_TYPES = {}));
|
|
22
|
+
var ERROR_LIST;
|
|
23
|
+
(function (ERROR_LIST) {
|
|
24
|
+
ERROR_LIST["arguments"] = "arguments";
|
|
25
|
+
ERROR_LIST["nulls"] = "nulls";
|
|
26
|
+
ERROR_LIST["floatingPoint"] = "floatingPoint";
|
|
27
|
+
ERROR_LIST["missingString"] = "missingString";
|
|
28
|
+
ERROR_LIST["missingNumber"] = "missingNumber";
|
|
29
|
+
ERROR_LIST["missingDate"] = "missingDate";
|
|
30
|
+
ERROR_LIST["greaterThanZero"] = "greaterThanZero";
|
|
31
|
+
ERROR_LIST["missingArg"] = "missingArg";
|
|
32
|
+
ERROR_LIST["missingParenthesis"] = "missingParenthesis";
|
|
33
|
+
ERROR_LIST["unknownFunction"] = "unknownFunction";
|
|
34
|
+
ERROR_LIST["unknown"] = "unknown";
|
|
35
|
+
ERROR_LIST["customDateDifParams"] = "customDateDifParams";
|
|
36
|
+
ERROR_LIST["tooManyArguments"] = "tooManyArguments";
|
|
37
|
+
ERROR_LIST["unknownExpression"] = "unknownExpression";
|
|
38
|
+
ERROR_LIST["unknownToken"] = "unknownToken";
|
|
39
|
+
ERROR_LIST["notAllowedExpression"] = "notAllowedExpression";
|
|
40
|
+
})(ERROR_LIST = exports.ERROR_LIST || (exports.ERROR_LIST = {}));
|
|
41
|
+
exports.ERROR_DICTIONARY = {
|
|
42
|
+
[ERROR_LIST.arguments]: {
|
|
43
|
+
message: 'Ilegal number of arguments for function',
|
|
44
|
+
code: 'NUMBER_ARGS',
|
|
45
|
+
},
|
|
46
|
+
[ERROR_LIST.nulls]: {
|
|
47
|
+
message: 'Can not apply function with null values',
|
|
48
|
+
code: 'NULL_FOUNDS',
|
|
49
|
+
},
|
|
50
|
+
[ERROR_LIST.floatingPoint]: {
|
|
51
|
+
message: 'Invalid floating point operation to integer',
|
|
52
|
+
code: 'FLOATING_POINT',
|
|
53
|
+
},
|
|
54
|
+
[ERROR_LIST.missingString]: {
|
|
55
|
+
message: 'Element has to be a String',
|
|
56
|
+
code: 'MISSING_STRING',
|
|
57
|
+
},
|
|
58
|
+
[ERROR_LIST.missingNumber]: {
|
|
59
|
+
message: 'Element has to be a Number',
|
|
60
|
+
code: 'MISSING_NUMBER',
|
|
61
|
+
},
|
|
62
|
+
[ERROR_LIST.missingDate]: {
|
|
63
|
+
message: 'Element has to be a Date',
|
|
64
|
+
code: 'MISSING_DATE',
|
|
65
|
+
},
|
|
66
|
+
[ERROR_LIST.greaterThanZero]: {
|
|
67
|
+
message: 'Element has to be greater than 0',
|
|
68
|
+
code: 'GREATER_THAN_ZERO',
|
|
69
|
+
},
|
|
70
|
+
[ERROR_LIST.missingArg]: {
|
|
71
|
+
message: 'Missing arguments',
|
|
72
|
+
code: 'MISSING_ARG',
|
|
73
|
+
},
|
|
74
|
+
[ERROR_LIST.missingParenthesis]: {
|
|
75
|
+
message: 'Missing parenthesis',
|
|
76
|
+
code: 'MISSING_PARENTHESIS',
|
|
77
|
+
},
|
|
78
|
+
[ERROR_LIST.unknownToken]: {
|
|
79
|
+
message: 'Unknown token',
|
|
80
|
+
code: 'UNKNOWN_TOKEN',
|
|
81
|
+
},
|
|
82
|
+
[ERROR_LIST.unknownFunction]: {
|
|
83
|
+
message: 'Unknown function',
|
|
84
|
+
code: 'UNKNOWN_FUNCTION',
|
|
85
|
+
},
|
|
86
|
+
[ERROR_LIST.unknown]: {
|
|
87
|
+
message: 'Unknown error',
|
|
88
|
+
code: 'UNKNOWN',
|
|
89
|
+
},
|
|
90
|
+
[ERROR_LIST.tooManyArguments]: {
|
|
91
|
+
message: 'Too many arguments',
|
|
92
|
+
code: 'TOO_MANY_ARGUMENTS',
|
|
93
|
+
},
|
|
94
|
+
[ERROR_LIST.customDateDifParams]: {
|
|
95
|
+
message: 'Unit param have to be equal to: "Y", "M", "D"',
|
|
96
|
+
code: 'DATE_DIF_UNIT_PARAM',
|
|
97
|
+
},
|
|
98
|
+
[ERROR_LIST.unknownExpression]: {
|
|
99
|
+
message: 'Unknown expression',
|
|
100
|
+
code: 'UNKNOWN_EXPRESSION',
|
|
101
|
+
},
|
|
102
|
+
[ERROR_LIST.notAllowedExpression]: {
|
|
103
|
+
message: 'Expression not allowed',
|
|
104
|
+
code: 'NOT_ALLOWED_EXPRESSION',
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
exports.CustomOperators = {
|
|
108
|
+
[ENGINES.ELASTICSEARCH]: {
|
|
109
|
+
'=': '==',
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
var ELASTICSEARCH_SCRIPT_NAMES;
|
|
113
|
+
(function (ELASTICSEARCH_SCRIPT_NAMES) {
|
|
114
|
+
ELASTICSEARCH_SCRIPT_NAMES["dateFormat"] = "DATE_FORMAT_SCRIPT";
|
|
115
|
+
ELASTICSEARCH_SCRIPT_NAMES["setTimezone"] = "SET_TIMEZONE_SCRIPT";
|
|
116
|
+
})(ELASTICSEARCH_SCRIPT_NAMES = exports.ELASTICSEARCH_SCRIPT_NAMES || (exports.ELASTICSEARCH_SCRIPT_NAMES = {}));
|
|
117
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":";;;AAAA,IAAY,OAIX;AAJD,WAAY,OAAO;IACf,0CAA+B,CAAA;IAC/B,kCAAuB,CAAA;IACvB,gCAAqB,CAAA;AACzB,CAAC,EAJW,OAAO,GAAP,eAAO,KAAP,eAAO,QAIlB;AAED,IAAY,SAUX;AAVD,WAAY,SAAS;IACjB,gCAAmB,CAAA;IACnB,kDAAqC,CAAA;IACrC,gDAAmC,CAAA;IACnC,0CAA6B,CAAA;IAC7B,kCAAqB,CAAA;IACrB,8BAAiB,CAAA;IACjB,4BAAe,CAAA;IACf,gCAAmB,CAAA;IACnB,gCAAmB,CAAA;AACvB,CAAC,EAVW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAUpB;AAED,IAAY,UAiBX;AAjBD,WAAY,UAAU;IAClB,qCAAuB,CAAA;IACvB,6BAAe,CAAA;IACf,6CAA+B,CAAA;IAC/B,6CAA+B,CAAA;IAC/B,6CAA+B,CAAA;IAC/B,yCAA2B,CAAA;IAC3B,iDAAmC,CAAA;IACnC,uCAAyB,CAAA;IACzB,uDAAyC,CAAA;IACzC,iDAAm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U,CAAC,eAAe,CAAC,EAAE;QAC1B,OAAO,EAAE,kBAAkB;QAC3B,IAAI,EAAE,kBAAkB;KAC3B;IACD,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;QAClB,OAAO,EAAE,eAAe;QACxB,IAAI,EAAE,SAAS;KAClB;IACD,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QAC3B,OAAO,EAAE,oBAAoB;QAC7B,IAAI,EAAE,oBAAoB;KAC7B;IACD,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE;QAC9B,OAAO,EAAE,+CAA+C;QACxD,IAAI,EAAE,qBAAqB;KAC9B;IACD,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE;QAC5B,OAAO,EAAE,oBAAoB;QAC7B,IAAI,EAAE,oBAAoB;KAC7B;IACD,CAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE;QAC/B,OAAO,EAAE,wBAAwB;QACjC,IAAI,EAAE,wBAAwB;KACjC;CACJ,CAAC;AAMW,QAAA,eAAe,GAA0B;IAClD,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACrB,GAAG,EAAE,IAAI;KACZ;CACJ,CAAC;AAEF,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IAClC,+DAAiC,CAAA;IACjC,iEAAmC,CAAA;AACvC,CAAC,EAHW,0BAA0B,GAA1B,kCAA0B,KAA1B,kCAA0B,QAGrC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ENGINES, AST_TYPES } from '.';
|
|
2
|
+
import { BaseError } from '../errors';
|
|
3
|
+
interface FunctionElementDefinition {
|
|
4
|
+
identifier: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export interface FunctionDefinition extends FunctionElementDefinition {
|
|
8
|
+
recursiveStartIn?: number;
|
|
9
|
+
transpiler: TranspilerEnginesFunction;
|
|
10
|
+
parameters?: Array<FunctionParameters>;
|
|
11
|
+
}
|
|
12
|
+
export type TranspilerEnginesFunction = {
|
|
13
|
+
[key in ENGINES]: Function;
|
|
14
|
+
};
|
|
15
|
+
interface FunctionParameters extends FunctionElementDefinition {
|
|
16
|
+
type: string;
|
|
17
|
+
optional: boolean;
|
|
18
|
+
validator: Array<ValidatorFunctionParameter>;
|
|
19
|
+
}
|
|
20
|
+
export interface ProcessNodeResult {
|
|
21
|
+
value: any;
|
|
22
|
+
dataType?: string;
|
|
23
|
+
}
|
|
24
|
+
interface ValidatorFunctionParameter {
|
|
25
|
+
(value: any, dataType: string | undefined): ValidatorResponse;
|
|
26
|
+
}
|
|
27
|
+
export interface ValidatorResponse {
|
|
28
|
+
valid: boolean;
|
|
29
|
+
code?: string;
|
|
30
|
+
message?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface TranspilationResponse {
|
|
33
|
+
valid: boolean;
|
|
34
|
+
expression?: string;
|
|
35
|
+
errors?: BaseError[];
|
|
36
|
+
}
|
|
37
|
+
export interface FunctionList {
|
|
38
|
+
[identifier: string]: FunctionDefinition;
|
|
39
|
+
}
|
|
40
|
+
export interface CommonAST {
|
|
41
|
+
type: AST_TYPES;
|
|
42
|
+
from: number;
|
|
43
|
+
to: number;
|
|
44
|
+
}
|
|
45
|
+
export interface ProgramAST extends CommonAST {
|
|
46
|
+
exp: string;
|
|
47
|
+
lang: string;
|
|
48
|
+
version: string;
|
|
49
|
+
body?: CommonAST;
|
|
50
|
+
errors?: BaseError[];
|
|
51
|
+
}
|
|
52
|
+
export interface UnaryExpressionAST extends CommonAST {
|
|
53
|
+
operator: string;
|
|
54
|
+
right: CommonAST;
|
|
55
|
+
}
|
|
56
|
+
export interface BinaryExpressionAST extends UnaryExpressionAST {
|
|
57
|
+
left: CommonAST;
|
|
58
|
+
}
|
|
59
|
+
export interface FunctionCallAST extends CommonAST {
|
|
60
|
+
name: string;
|
|
61
|
+
arguments: Array<CommonAST>;
|
|
62
|
+
}
|
|
63
|
+
export type ValueASTType = string | boolean | number | CommonAST[] | null | Date;
|
|
64
|
+
export interface CommonValueAST extends CommonAST {
|
|
65
|
+
value: ValueASTType;
|
|
66
|
+
}
|
|
67
|
+
export interface UnknownAST extends CommonAST {
|
|
68
|
+
text: string;
|
|
69
|
+
}
|
|
70
|
+
export interface VariableAST extends CommonValueAST {
|
|
71
|
+
context?: VariableContextDefinition;
|
|
72
|
+
}
|
|
73
|
+
export interface LiteralAST extends CommonValueAST {
|
|
74
|
+
dataType: string;
|
|
75
|
+
}
|
|
76
|
+
export interface VariableContextDefinition {
|
|
77
|
+
label: string;
|
|
78
|
+
id: string;
|
|
79
|
+
replacement?: string;
|
|
80
|
+
type: string;
|
|
81
|
+
}
|
|
82
|
+
export interface FormulaContext {
|
|
83
|
+
model?: VariableContextDefinition[];
|
|
84
|
+
timezone?: TimezoneDefinition;
|
|
85
|
+
}
|
|
86
|
+
interface TimezoneDefinition {
|
|
87
|
+
offset: string;
|
|
88
|
+
}
|
|
89
|
+
export type VariableASTType = AST_TYPES.variable | AST_TYPES.column | AST_TYPES.token;
|
|
90
|
+
export type DateDifUnitParam = 'Y' | 'M' | 'D';
|
|
91
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/constants/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CommonAST, FunctionCallAST, UnknownAST, ValidatorResponse } from '../constants/interfaces';
|
|
2
|
+
export declare class BaseError extends Error {
|
|
3
|
+
code: string;
|
|
4
|
+
message: string;
|
|
5
|
+
node?: FunctionCallAST | CommonAST | undefined;
|
|
6
|
+
constructor(code: string, message: string, node?: FunctionCallAST | CommonAST | undefined);
|
|
7
|
+
toString(): string;
|
|
8
|
+
}
|
|
9
|
+
export declare class GenericError extends BaseError {
|
|
10
|
+
constructor(message?: string);
|
|
11
|
+
}
|
|
12
|
+
export declare class UnknownFunctionError extends BaseError {
|
|
13
|
+
node: FunctionCallAST;
|
|
14
|
+
constructor(node: FunctionCallAST);
|
|
15
|
+
}
|
|
16
|
+
export declare class MissingArgumentError extends BaseError {
|
|
17
|
+
node: FunctionCallAST;
|
|
18
|
+
constructor(node: FunctionCallAST);
|
|
19
|
+
}
|
|
20
|
+
export declare class MissingParenthesisError extends BaseError {
|
|
21
|
+
node: FunctionCallAST;
|
|
22
|
+
constructor(node: FunctionCallAST);
|
|
23
|
+
}
|
|
24
|
+
export declare class UnknownTokenError extends BaseError {
|
|
25
|
+
node: UnknownAST;
|
|
26
|
+
constructor(node: UnknownAST);
|
|
27
|
+
}
|
|
28
|
+
export declare class NotAllowedExpressionError extends BaseError {
|
|
29
|
+
node: CommonAST;
|
|
30
|
+
constructor(node: CommonAST);
|
|
31
|
+
}
|
|
32
|
+
export declare class TooManyArgumentsError extends BaseError {
|
|
33
|
+
node: FunctionCallAST;
|
|
34
|
+
constructor(node: FunctionCallAST);
|
|
35
|
+
}
|
|
36
|
+
export declare class InvalidArgumentError extends BaseError {
|
|
37
|
+
node: FunctionCallAST;
|
|
38
|
+
constructor(node: FunctionCallAST, validatorResponse: ValidatorResponse);
|
|
39
|
+
}
|
|
40
|
+
export declare class UnknownExpressionError extends BaseError {
|
|
41
|
+
expression: CommonAST;
|
|
42
|
+
constructor(expression: CommonAST);
|
|
43
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnknownExpressionError = exports.InvalidArgumentError = exports.TooManyArgumentsError = exports.NotAllowedExpressionError = exports.UnknownTokenError = exports.MissingParenthesisError = exports.MissingArgumentError = exports.UnknownFunctionError = exports.GenericError = exports.BaseError = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
class BaseError extends Error {
|
|
6
|
+
constructor(code, message, node) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.message = message;
|
|
10
|
+
this.node = node;
|
|
11
|
+
this.code = code;
|
|
12
|
+
this.node = node;
|
|
13
|
+
}
|
|
14
|
+
toString() {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
if (this.node === undefined) {
|
|
17
|
+
return `${this.code}: ${this.message}`;
|
|
18
|
+
}
|
|
19
|
+
else if ('name' in this.node) {
|
|
20
|
+
return `${this.code}: ${this.message} ${(_a = this.node) === null || _a === void 0 ? void 0 : _a.name}`;
|
|
21
|
+
}
|
|
22
|
+
else if ('type' in this.node) {
|
|
23
|
+
return `${this.code}: ${this.message} ${(_b = this.node) === null || _b === void 0 ? void 0 : _b.type}`;
|
|
24
|
+
}
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.BaseError = BaseError;
|
|
29
|
+
class GenericError extends BaseError {
|
|
30
|
+
constructor(message = constants_1.ERROR_DICTIONARY[constants_1.ERROR_LIST.unknown].message) {
|
|
31
|
+
super(constants_1.ERROR_DICTIONARY[constants_1.ERROR_LIST.unknown].code, message);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.GenericError = GenericError;
|
|
35
|
+
class UnknownFunctionError extends BaseError {
|
|
36
|
+
constructor(node) {
|
|
37
|
+
super(constants_1.ERROR_DICTIONARY[constants_1.ERROR_LIST.unknownFunction].code, constants_1.ERROR_DICTIONARY[constants_1.ERROR_LIST.unknownFunction].message, node);
|
|
38
|
+
this.node = node;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.UnknownFunctionError = UnknownFunctionError;
|
|
42
|
+
class MissingArgumentError extends BaseError {
|
|
43
|
+
constructor(node) {
|
|
44
|
+
super(constants_1.ERROR_DICTIONARY[constants_1.ERROR_LIST.missingArg].code, constants_1.ERROR_DICTIONARY[constants_1.ERROR_LIST.missingArg].message, node);
|
|
45
|
+
this.node = node;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.MissingArgumentError = MissingArgumentError;
|
|
49
|
+
class MissingParenthesisError extends BaseError {
|
|
50
|
+
constructor(node) {
|
|
51
|
+
super(constants_1.ERROR_DICTIONARY[constants_1.ERROR_LIST.missingParenthesis].code, constants_1.ERROR_DICTIONARY[constants_1.ERROR_LIST.missingParenthesis].message, node);
|
|
52
|
+
this.node = node;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.MissingParenthesisError = MissingParenthesisError;
|
|
56
|
+
class UnknownTokenError extends BaseError {
|
|
57
|
+
constructor(node) {
|
|
58
|
+
super(constants_1.ERROR_DICTIONARY[constants_1.ERROR_LIST.unknownToken].code, constants_1.ERROR_DICTIONARY[constants_1.ERROR_LIST.unknownToken].message, node);
|
|
59
|
+
this.node = node;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.UnknownTokenError = UnknownTokenError;
|
|
63
|
+
class NotAllowedExpressionError extends BaseError {
|
|
64
|
+
constructor(node) {
|
|
65
|
+
super(constants_1.ERROR_DICTIONARY[constants_1.ERROR_LIST.notAllowedExpression].code, constants_1.ERROR_DICTIONARY[constants_1.ERROR_LIST.notAllowedExpression].message, node);
|
|
66
|
+
this.node = node;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.NotAllowedExpressionError = NotAllowedExpressionError;
|
|
70
|
+
class TooManyArgumentsError extends BaseError {
|
|
71
|
+
constructor(node) {
|
|
72
|
+
super(constants_1.ERROR_DICTIONARY[constants_1.ERROR_LIST.tooManyArguments].code, constants_1.ERROR_DICTIONARY[constants_1.ERROR_LIST.tooManyArguments].message, node);
|
|
73
|
+
this.node = node;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.TooManyArgumentsError = TooManyArgumentsError;
|
|
77
|
+
class InvalidArgumentError extends BaseError {
|
|
78
|
+
constructor(node, validatorResponse) {
|
|
79
|
+
super((validatorResponse === null || validatorResponse === void 0 ? void 0 : validatorResponse.code) || '', (validatorResponse === null || validatorResponse === void 0 ? void 0 : validatorResponse.message) || '', node);
|
|
80
|
+
this.node = node;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.InvalidArgumentError = InvalidArgumentError;
|
|
84
|
+
class UnknownExpressionError extends BaseError {
|
|
85
|
+
constructor(expression) {
|
|
86
|
+
super(constants_1.ERROR_DICTIONARY[constants_1.ERROR_LIST.unknownExpression].code, constants_1.ERROR_DICTIONARY[constants_1.ERROR_LIST.unknownExpression].message, expression);
|
|
87
|
+
this.expression = expression;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.UnknownExpressionError = UnknownExpressionError;
|
|
91
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../../src/errors/definitions.ts"],"names":[],"mappings":";;;AAAA,4CAA4D;AAQ5D,MAAa,SAAU,SAAQ,KAAK;IAChC,YACW,IAAY,EACZ,OAAe,EACf,IAA8C;QAErD,KAAK,CAAC,OAAO,CAAC,CAAC;QAJR,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAQ;QACf,SAAI,GAAJ,IAAI,CAA0C;QAGrD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,QAAQ;;QACJ,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;YACzB,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;SAC1C;aAAM,IAAI,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE;YAC5B,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,IAAI,MAAA,IAAI,CAAC,IAAI,0CAAE,IAAI,EAAE,CAAC;SAC7D;aAAM,IAAI,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE;YAC5B,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,IAAI,MAAA,IAAI,CAAC,IAAI,0CAAE,IAAI,EAAE,CAAC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AMxC,CAAC;CACJ;AARD,wDAQC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ERROR_LIST } from '../constants';
|
|
2
|
+
export declare const errorRegex: ({
|
|
3
|
+
unknownFunction: {
|
|
4
|
+
regex: RegExp;
|
|
5
|
+
value: ERROR_LIST;
|
|
6
|
+
};
|
|
7
|
+
missingArguments: {
|
|
8
|
+
regex: RegExp;
|
|
9
|
+
value: ERROR_LIST;
|
|
10
|
+
};
|
|
11
|
+
} | {
|
|
12
|
+
arguments: {
|
|
13
|
+
regex: RegExp;
|
|
14
|
+
value: ERROR_LIST;
|
|
15
|
+
};
|
|
16
|
+
state: {
|
|
17
|
+
regex: RegExp;
|
|
18
|
+
value: ERROR_LIST;
|
|
19
|
+
};
|
|
20
|
+
null_pointer: {
|
|
21
|
+
regex: RegExp;
|
|
22
|
+
value: ERROR_LIST;
|
|
23
|
+
};
|
|
24
|
+
})[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.errorRegex = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const reasonsRegex = {
|
|
6
|
+
unknownFunction: {
|
|
7
|
+
regex: /Unknown call \[.*\] with/,
|
|
8
|
+
value: constants_1.ERROR_LIST.unknownFunction,
|
|
9
|
+
},
|
|
10
|
+
missingArguments: {
|
|
11
|
+
regex: /static method \[.*\] not found/,
|
|
12
|
+
value: constants_1.ERROR_LIST.arguments,
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
const typesRegex = {
|
|
16
|
+
arguments: {
|
|
17
|
+
regex: /illegal_argument_exception/,
|
|
18
|
+
value: constants_1.ERROR_LIST.arguments,
|
|
19
|
+
},
|
|
20
|
+
state: {
|
|
21
|
+
regex: /illegal_state_exception/,
|
|
22
|
+
value: constants_1.ERROR_LIST.nulls,
|
|
23
|
+
},
|
|
24
|
+
null_pointer: {
|
|
25
|
+
regex: /null_pointer_exception/,
|
|
26
|
+
value: constants_1.ERROR_LIST.nulls,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
exports.errorRegex = [reasonsRegex, typesRegex];
|
|
30
|
+
//# sourceMappingURL=elasticsearch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elasticsearch.js","sourceRoot":"","sources":["../../../src/errors/elasticsearch.ts"],"names":[],"mappings":";;;AAAA,4CAA0C;AAE1C,MAAM,YAAY,GAAG;IACjB,eAAe,EAAE;QACb,KAAK,EAAE,0BAA0B;QACjC,KAAK,EAAE,sBAAU,CAAC,eAAe;KACpC;IACD,gBAAgB,EAAE;QACd,KAAK,EAAE,gCAAgC;QACvC,KAAK,EAAE,sBAAU,CAAC,SAAS;KAC9B;CACJ,CAAC;AAEF,MAAM,UAAU,GAAG;IACf,SAAS,EAAE;QACP,KAAK,EAAE,4BAA4B;QACnC,KAAK,EAAE,sBAAU,CAAC,SAAS;KAC9B;IACD,KAAK,EAAE;QACH,KAAK,EAAE,yBAAyB;QAChC,KAAK,EAAE,sBAAU,CAAC,KAAK;KAC1B;IACD,YAAY,EAAE;QACV,KAAK,EAAE,wBAAwB;QAC/B,KAAK,EAAE,sBAAU,CAAC,KAAK;KAC1B;CACJ,CAAC;AAEW,QAAA,UAAU,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.engineErrors = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
function engineErrors(messages, regexs) {
|
|
6
|
+
const loopParams = (obj, str) => {
|
|
7
|
+
for (const key in obj) {
|
|
8
|
+
const regex = new RegExp(obj[key].regex, 'g');
|
|
9
|
+
if (regex.test(str)) {
|
|
10
|
+
return obj[key].value;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
let value;
|
|
15
|
+
messages.forEach((message) => {
|
|
16
|
+
regexs.forEach((regex) => {
|
|
17
|
+
value = loopParams(regex, message);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
if (!value)
|
|
21
|
+
value = constants_1.ERROR_LIST.unknown;
|
|
22
|
+
return Object.assign({ valid: false }, constants_1.ERROR_DICTIONARY[value]);
|
|
23
|
+
}
|
|
24
|
+
exports.engineErrors = engineErrors;
|
|
25
|
+
//# sourceMappingURL=engineErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineErrors.js","sourceRoot":"","sources":["../../../src/errors/engineErrors.ts"],"names":[],"mappings":";;;AAAA,4CAA4D;AAG5D,SAAgB,YAAY,CACxB,QAAuB,EACvB,MAAqB;IAErB,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAE,GAAW,EAAE,EAAE;QACzC,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE;YACnB,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC9C,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;gBACjB,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;aACzB;SACJ;IACL,CAAC,CAAC;IAEF,IAAI,KAAK,CAAC;IACV,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QACzB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YACrB,KAAK,GAAG,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,KAAK;QAAE,KAAK,GAAG,sBAAU,CAAC,OAAO,CAAC;IACvC,uBAAS,KAAK,EAAE,KAAK,IAAK,4BAAgB,CAAC,KAAK,CAAC,EAAG;AACxD,CAAC;AArBD,oCAqBC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./definitions"), exports);
|
|
18
|
+
//export * from './elasticsearch';
|
|
19
|
+
__exportStar(require("./engineErrors"), exports);
|
|
20
|
+
//export * from './snowflake';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/errors/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,kCAAkC;AAClC,iDAA+B;AAC/B,8BAA8B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ERROR_LIST } from '../constants';
|
|
2
|
+
export declare const errorRegex: {
|
|
3
|
+
missingArguments: {
|
|
4
|
+
regex: RegExp;
|
|
5
|
+
value: ERROR_LIST;
|
|
6
|
+
};
|
|
7
|
+
floatingPoint: {
|
|
8
|
+
regex: RegExp;
|
|
9
|
+
value: ERROR_LIST;
|
|
10
|
+
};
|
|
11
|
+
unknownFunction: {
|
|
12
|
+
regex: RegExp;
|
|
13
|
+
value: ERROR_LIST;
|
|
14
|
+
};
|
|
15
|
+
}[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.errorRegex = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const reasonsRegex = {
|
|
6
|
+
missingArguments: {
|
|
7
|
+
regex: /not enough arguments for function/,
|
|
8
|
+
value: constants_1.ERROR_LIST.arguments,
|
|
9
|
+
},
|
|
10
|
+
floatingPoint: {
|
|
11
|
+
regex: /Invalid floating point operation/,
|
|
12
|
+
value: constants_1.ERROR_LIST.floatingPoint,
|
|
13
|
+
},
|
|
14
|
+
unknownFunction: {
|
|
15
|
+
regex: /Unknown function/,
|
|
16
|
+
value: constants_1.ERROR_LIST.unknownFunction,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
exports.errorRegex = [reasonsRegex];
|
|
20
|
+
//# sourceMappingURL=snowflake.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snowflake.js","sourceRoot":"","sources":["../../../src/errors/snowflake.ts"],"names":[],"mappings":";;;AAAA,4CAA0C;AAE1C,MAAM,YAAY,GAAG;IACjB,gBAAgB,EAAE;QACd,KAAK,EAAE,mCAAmC;QAC1C,KAAK,EAAE,sBAAU,CAAC,SAAS;KAC9B;IACD,aAAa,EAAE;QACX,KAAK,EAAE,kCAAkC;QACzC,KAAK,EAAE,sBAAU,CAAC,aAAa;KAClC;IACD,eAAe,EAAE;QACb,KAAK,EAAE,kBAAkB;QACzB,KAAK,EAAE,sBAAU,CAAC,eAAe;KACpC;CACJ,CAAC;AAEW,QAAA,UAAU,GAAG,CAAC,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ABS = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
/**
|
|
6
|
+
* `ABS` Returns the absolute value of a number.
|
|
7
|
+
*/
|
|
8
|
+
exports.ABS = {
|
|
9
|
+
identifier: 'ABS',
|
|
10
|
+
name: 'ABS',
|
|
11
|
+
parameters: [
|
|
12
|
+
{
|
|
13
|
+
identifier: 'VALUE',
|
|
14
|
+
name: 'value',
|
|
15
|
+
type: 'Number',
|
|
16
|
+
optional: false,
|
|
17
|
+
validator: [utils_1.isNumberParam],
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
transpiler: {
|
|
21
|
+
elasticsearch,
|
|
22
|
+
snowflake,
|
|
23
|
+
redshift,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
function elasticsearch(value) {
|
|
27
|
+
return `Math.abs(${value})`;
|
|
28
|
+
}
|
|
29
|
+
function SQL(value) {
|
|
30
|
+
return `ABS(${value})`;
|
|
31
|
+
}
|
|
32
|
+
function snowflake(value) {
|
|
33
|
+
return SQL(value);
|
|
34
|
+
}
|
|
35
|
+
function redshift(value) {
|
|
36
|
+
return SQL(value);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=abs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abs.js","sourceRoot":"","sources":["../../../src/functions/abs.ts"],"names":[],"mappings":";;;AACA,oCAAyC;AAEzC;;GAEG;AACU,QAAA,GAAG,GAAuB;IACnC,UAAU,EAAE,KAAK;IACjB,IAAI,EAAE,KAAK;IACX,UAAU,EAAE;QACR;YACI,UAAU,EAAE,OAAO;YACnB,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,qBAAa,CAAC;SAC7B;KACJ;IACD,UAAU,EAAE;QACR,aAAa;QACb,SAAS;QACT,QAAQ;KACX;CACJ,CAAC;AAEF,SAAS,aAAa,CAAC,KAAa;IAChC,OAAO,YAAY,KAAK,GAAG,CAAC;AAChC,CAAC;AAED,SAAS,GAAG,CAAC,KAAa;IACtB,OAAO,OAAO,KAAK,GAAG,CAAC;AAC3B,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC5B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC3B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC"}
|