@qrvey/formula-lang 0.1.2 → 0.2.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 (252) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/__tests__/integration/__mocks__/elasticsearchScripts.ts +21 -0
  3. package/__tests__/integration/__mocks__/sqlScripts.ts +20 -0
  4. package/__tests__/integration/elasticsearch.test.ts +158 -0
  5. package/__tests__/integration/expression.test.ts +22 -0
  6. package/__tests__/integration/redshift.test.ts +127 -0
  7. package/__tests__/integration/sonwflake.test.ts +123 -0
  8. package/__tests__/unit/parser.test.ts +106 -0
  9. package/__tests__/{src → unit}/transpiler.test.ts +0 -17
  10. package/bitbucket-pipelines.yml +63 -0
  11. package/dist/constants/index.d.ts +12 -2
  12. package/dist/constants/index.js +21 -1
  13. package/dist/constants/index.js.map +1 -1
  14. package/dist/constants/interfaces.d.ts +8 -2
  15. package/dist/errors/definitions.d.ts +20 -5
  16. package/dist/errors/definitions.js +28 -5
  17. package/dist/errors/definitions.js.map +1 -1
  18. package/dist/errors/engineErrors.d.ts +2 -0
  19. package/dist/errors/engineErrors.js +21 -0
  20. package/dist/errors/engineErrors.js.map +1 -0
  21. package/dist/errors/index.d.ts +2 -5
  22. package/dist/errors/index.js +4 -38
  23. package/dist/errors/index.js.map +1 -1
  24. package/dist/functions/abs.d.ts +5 -0
  25. package/dist/functions/abs.js +35 -0
  26. package/dist/functions/abs.js.map +1 -0
  27. package/dist/functions/datedif.d.ts +5 -0
  28. package/dist/functions/datedif.js +61 -0
  29. package/dist/functions/datedif.js.map +1 -0
  30. package/dist/functions/day.d.ts +5 -0
  31. package/dist/functions/day.js +36 -0
  32. package/dist/functions/day.js.map +1 -0
  33. package/dist/functions/hour.d.ts +5 -0
  34. package/dist/functions/hour.js +36 -0
  35. package/dist/functions/hour.js.map +1 -0
  36. package/dist/functions/if.d.ts +5 -0
  37. package/dist/functions/if.js +49 -0
  38. package/dist/functions/if.js.map +1 -0
  39. package/dist/functions/ifs.d.ts +5 -0
  40. package/dist/functions/ifs.js +71 -0
  41. package/dist/functions/ifs.js.map +1 -0
  42. package/dist/functions/index.js +20 -0
  43. package/dist/functions/index.js.map +1 -1
  44. package/dist/functions/mid.d.ts +3 -0
  45. package/dist/functions/mid.js +15 -12
  46. package/dist/functions/mid.js.map +1 -1
  47. package/dist/functions/minute.d.ts +5 -0
  48. package/dist/functions/minute.js +36 -0
  49. package/dist/functions/minute.js.map +1 -0
  50. package/dist/functions/month.d.ts +5 -0
  51. package/dist/functions/month.js +36 -0
  52. package/dist/functions/month.js.map +1 -0
  53. package/dist/functions/second.d.ts +5 -0
  54. package/dist/functions/second.js +36 -0
  55. package/dist/functions/second.js.map +1 -0
  56. package/dist/functions/year.d.ts +5 -0
  57. package/dist/functions/year.js +36 -0
  58. package/dist/functions/year.js.map +1 -0
  59. package/dist/grammar/generated/qformula.lang.js +10 -10
  60. package/dist/grammar/generated/qformula.lang.js.map +1 -1
  61. package/dist/parser/json-parser.js +42 -6
  62. package/dist/parser/json-parser.js.map +1 -1
  63. package/dist/transpiler/index.d.ts +9 -7
  64. package/dist/transpiler/index.js +38 -27
  65. package/dist/transpiler/index.js.map +1 -1
  66. package/dist/transpiler/validateFuncStructure.d.ts +2 -0
  67. package/dist/transpiler/validateFuncStructure.js +37 -0
  68. package/dist/transpiler/validateFuncStructure.js.map +1 -0
  69. package/dist/utils/customFunctions.d.ts +3 -0
  70. package/dist/utils/customFunctions.js +21 -0
  71. package/dist/utils/customFunctions.js.map +1 -0
  72. package/dist/utils/elasticsearch/index.d.ts +2 -0
  73. package/dist/utils/elasticsearch/index.js +16 -0
  74. package/dist/utils/elasticsearch/index.js.map +1 -0
  75. package/dist/utils/elasticsearch/scripts.d.ts +10 -0
  76. package/dist/utils/elasticsearch/scripts.js +36 -0
  77. package/dist/utils/elasticsearch/scripts.js.map +1 -0
  78. package/dist/utils/getMonthMaxDayAllowed.d.ts +7 -0
  79. package/dist/utils/getMonthMaxDayAllowed.js +22 -0
  80. package/dist/utils/getMonthMaxDayAllowed.js.map +1 -0
  81. package/dist/utils/getNodeValue.d.ts +2 -0
  82. package/dist/utils/getNodeValue.js +9 -0
  83. package/dist/utils/getNodeValue.js.map +1 -0
  84. package/dist/utils/index.d.ts +9 -4
  85. package/dist/utils/index.js +9 -3
  86. package/dist/utils/index.js.map +1 -1
  87. package/dist/utils/isDateParam.d.ts +2 -0
  88. package/dist/utils/isDateParam.js +8 -0
  89. package/dist/utils/isDateParam.js.map +1 -0
  90. package/dist/utils/isNumberParam.d.ts +2 -0
  91. package/dist/utils/isNumberParam.js +8 -0
  92. package/dist/utils/isNumberParam.js.map +1 -0
  93. package/dist/utils/isPositiveNumberParam.d.ts +2 -0
  94. package/dist/utils/isPositiveNumberParam.js +8 -0
  95. package/dist/utils/isPositiveNumberParam.js.map +1 -0
  96. package/dist/utils/isStringParam.d.ts +2 -0
  97. package/dist/utils/isStringParam.js +8 -0
  98. package/dist/utils/isStringParam.js.map +1 -0
  99. package/dist/utils/isValidDate.d.ts +1 -0
  100. package/dist/utils/isValidDate.js +4 -0
  101. package/dist/utils/isValidDate.js.map +1 -0
  102. package/dist/utils/sql/index.d.ts +1 -0
  103. package/dist/utils/sql/index.js +2 -0
  104. package/dist/utils/sql/index.js.map +1 -0
  105. package/dist/utils/sql/scripts.d.ts +3 -0
  106. package/dist/utils/sql/scripts.js +39 -0
  107. package/dist/utils/sql/scripts.js.map +1 -0
  108. package/package.json +4 -1
  109. package/pkg/dist/constants/index.d.ts +42 -0
  110. package/pkg/dist/constants/index.js +86 -0
  111. package/pkg/dist/constants/index.js.map +1 -0
  112. package/pkg/dist/constants/interfaces.d.ts +62 -0
  113. package/pkg/dist/constants/interfaces.js +2 -0
  114. package/pkg/dist/constants/interfaces.js.map +1 -0
  115. package/pkg/dist/errors/definitions.d.ts +26 -0
  116. package/pkg/dist/errors/definitions.js +42 -0
  117. package/pkg/dist/errors/definitions.js.map +1 -0
  118. package/pkg/dist/errors/elasticsearch.d.ts +24 -0
  119. package/pkg/dist/errors/elasticsearch.js +27 -0
  120. package/pkg/dist/errors/elasticsearch.js.map +1 -0
  121. package/pkg/dist/errors/engineErrors.d.ts +2 -0
  122. package/pkg/dist/errors/engineErrors.js +21 -0
  123. package/pkg/dist/errors/engineErrors.js.map +1 -0
  124. package/pkg/dist/errors/index.d.ts +2 -0
  125. package/pkg/dist/errors/index.js +5 -0
  126. package/pkg/dist/errors/index.js.map +1 -0
  127. package/pkg/dist/errors/snowflake.d.ts +15 -0
  128. package/pkg/dist/errors/snowflake.js +17 -0
  129. package/pkg/dist/errors/snowflake.js.map +1 -0
  130. package/pkg/dist/functions/abs.d.ts +5 -0
  131. package/pkg/dist/functions/abs.js +35 -0
  132. package/pkg/dist/functions/abs.js.map +1 -0
  133. package/pkg/dist/functions/datedif.d.ts +5 -0
  134. package/pkg/dist/functions/datedif.js +58 -0
  135. package/pkg/dist/functions/datedif.js.map +1 -0
  136. package/pkg/dist/functions/day.d.ts +5 -0
  137. package/pkg/dist/functions/day.js +36 -0
  138. package/pkg/dist/functions/day.js.map +1 -0
  139. package/pkg/dist/functions/hour.d.ts +5 -0
  140. package/pkg/dist/functions/hour.js +36 -0
  141. package/pkg/dist/functions/hour.js.map +1 -0
  142. package/pkg/dist/functions/if.d.ts +5 -0
  143. package/pkg/dist/functions/if.js +49 -0
  144. package/pkg/dist/functions/if.js.map +1 -0
  145. package/pkg/dist/functions/ifs.d.ts +5 -0
  146. package/pkg/dist/functions/ifs.js +71 -0
  147. package/pkg/dist/functions/ifs.js.map +1 -0
  148. package/pkg/dist/functions/index.d.ts +4 -0
  149. package/pkg/dist/functions/index.js +29 -0
  150. package/pkg/dist/functions/index.js.map +1 -0
  151. package/pkg/dist/functions/mid.d.ts +5 -0
  152. package/pkg/dist/functions/mid.js +51 -0
  153. package/pkg/dist/functions/mid.js.map +1 -0
  154. package/pkg/dist/functions/minute.d.ts +5 -0
  155. package/pkg/dist/functions/minute.js +36 -0
  156. package/pkg/dist/functions/minute.js.map +1 -0
  157. package/pkg/dist/functions/month.d.ts +5 -0
  158. package/pkg/dist/functions/month.js +36 -0
  159. package/pkg/dist/functions/month.js.map +1 -0
  160. package/pkg/dist/functions/second.d.ts +5 -0
  161. package/pkg/dist/functions/second.js +36 -0
  162. package/pkg/dist/functions/second.js.map +1 -0
  163. package/pkg/dist/functions/year.d.ts +5 -0
  164. package/pkg/dist/functions/year.js +36 -0
  165. package/pkg/dist/functions/year.js.map +1 -0
  166. package/pkg/dist/grammar/generated/qformula.lang.js +43 -0
  167. package/pkg/dist/grammar/generated/qformula.lang.js.map +1 -0
  168. package/pkg/dist/grammar/qformula.grammar.d.ts +1 -0
  169. package/pkg/dist/grammar/qformula.grammar.js +2 -0
  170. package/pkg/dist/grammar/qformula.grammar.js.map +1 -0
  171. package/pkg/dist/index.js +29 -0
  172. package/pkg/dist/index.js.map +1 -0
  173. package/pkg/dist/parser/json-parser.js +139 -0
  174. package/pkg/dist/parser/json-parser.js.map +1 -0
  175. package/pkg/dist/transpiler/index.d.ts +17 -0
  176. package/pkg/dist/transpiler/index.js +82 -0
  177. package/pkg/dist/transpiler/index.js.map +1 -0
  178. package/pkg/dist/transpiler/validateFuncStructure.d.ts +2 -0
  179. package/pkg/dist/transpiler/validateFuncStructure.js +35 -0
  180. package/pkg/dist/transpiler/validateFuncStructure.js.map +1 -0
  181. package/pkg/dist/utils/customFunctions.d.ts +2 -0
  182. package/pkg/dist/utils/customFunctions.js +11 -0
  183. package/pkg/dist/utils/customFunctions.js.map +1 -0
  184. package/pkg/dist/utils/elasticsearch/index.d.ts +1 -0
  185. package/pkg/dist/utils/elasticsearch/index.js +15 -0
  186. package/pkg/dist/utils/elasticsearch/index.js.map +1 -0
  187. package/pkg/dist/utils/elasticsearch/scripts.d.ts +9 -0
  188. package/pkg/dist/utils/elasticsearch/scripts.js +33 -0
  189. package/pkg/dist/utils/elasticsearch/scripts.js.map +1 -0
  190. package/pkg/dist/utils/getMonthMaxDayAllowed.d.ts +7 -0
  191. package/pkg/dist/utils/getMonthMaxDayAllowed.js +22 -0
  192. package/pkg/dist/utils/getMonthMaxDayAllowed.js.map +1 -0
  193. package/pkg/dist/utils/getNodeValue.d.ts +2 -0
  194. package/pkg/dist/utils/getNodeValue.js +9 -0
  195. package/pkg/dist/utils/getNodeValue.js.map +1 -0
  196. package/pkg/dist/utils/index.d.ts +8 -0
  197. package/pkg/dist/utils/index.js +9 -0
  198. package/pkg/dist/utils/index.js.map +1 -0
  199. package/pkg/dist/utils/isDateParam.d.ts +2 -0
  200. package/pkg/dist/utils/isDateParam.js +10 -0
  201. package/pkg/dist/utils/isDateParam.js.map +1 -0
  202. package/pkg/dist/utils/isNumberParam.d.ts +2 -0
  203. package/pkg/dist/utils/isNumberParam.js +8 -0
  204. package/pkg/dist/utils/isNumberParam.js.map +1 -0
  205. package/pkg/dist/utils/isPositiveNumberParam.d.ts +2 -0
  206. package/pkg/dist/utils/isPositiveNumberParam.js +8 -0
  207. package/pkg/dist/utils/isPositiveNumberParam.js.map +1 -0
  208. package/pkg/dist/utils/isStringParam.d.ts +2 -0
  209. package/pkg/dist/utils/isStringParam.js +8 -0
  210. package/pkg/dist/utils/isStringParam.js.map +1 -0
  211. package/pkg/dist/utils/isValidDate.d.ts +1 -0
  212. package/pkg/dist/utils/isValidDate.js +4 -0
  213. package/pkg/dist/utils/isValidDate.js.map +1 -0
  214. package/pkg/dist/utils/sql/scripts.d.ts +2 -0
  215. package/pkg/dist/utils/sql/scripts.js +39 -0
  216. package/pkg/dist/utils/sql/scripts.js.map +1 -0
  217. package/__tests__/src/parser.test.ts +0 -29
  218. package/coverage/clover.xml +0 -228
  219. package/coverage/coverage-final.json +0 -12
  220. package/coverage/lcov-report/base.css +0 -224
  221. package/coverage/lcov-report/block-navigation.js +0 -87
  222. package/coverage/lcov-report/favicon.png +0 -0
  223. package/coverage/lcov-report/index.html +0 -236
  224. package/coverage/lcov-report/prettify.css +0 -1
  225. package/coverage/lcov-report/prettify.js +0 -2
  226. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  227. package/coverage/lcov-report/sorter.js +0 -196
  228. package/coverage/lcov-report/src/constants/index.html +0 -116
  229. package/coverage/lcov-report/src/constants/index.ts.html +0 -307
  230. package/coverage/lcov-report/src/errors/definitions.ts.html +0 -154
  231. package/coverage/lcov-report/src/errors/index.html +0 -131
  232. package/coverage/lcov-report/src/errors/index.ts.html +0 -217
  233. package/coverage/lcov-report/src/functions/index.html +0 -131
  234. package/coverage/lcov-report/src/functions/index.ts.html +0 -103
  235. package/coverage/lcov-report/src/functions/mid.ts.html +0 -238
  236. package/coverage/lcov-report/src/grammar/generated/index.html +0 -116
  237. package/coverage/lcov-report/src/grammar/generated/qformula.lang.js.html +0 -220
  238. package/coverage/lcov-report/src/grammar/index.html +0 -116
  239. package/coverage/lcov-report/src/grammar/qformula.grammar.ts.html +0 -88
  240. package/coverage/lcov-report/src/index.html +0 -116
  241. package/coverage/lcov-report/src/index.ts.html +0 -160
  242. package/coverage/lcov-report/src/parser/index.html +0 -116
  243. package/coverage/lcov-report/src/parser/json-parser.ts.html +0 -475
  244. package/coverage/lcov-report/src/transpiler/index.html +0 -116
  245. package/coverage/lcov-report/src/transpiler/index.ts.html +0 -412
  246. package/coverage/lcov-report/src/utils/index.html +0 -116
  247. package/coverage/lcov-report/src/utils/index.ts.html +0 -103
  248. package/coverage/lcov.info +0 -405
  249. package/dist/models/ast.models.d.ts +0 -29
  250. package/dist/models/ast.models.js +0 -1
  251. package/dist/utils/utils.d.ts +0 -4
  252. package/dist/utils/utils.js +0 -3
@@ -0,0 +1,86 @@
1
+ export var ENGINES;
2
+ (function (ENGINES) {
3
+ ENGINES["ELASTICSEARCH"] = "elasticsearch";
4
+ ENGINES["SNOWFLAKE"] = "snowflake";
5
+ ENGINES["REDSHIFT"] = "redshift";
6
+ })(ENGINES || (ENGINES = {}));
7
+ export var AST_TYPES;
8
+ (function (AST_TYPES) {
9
+ AST_TYPES["program"] = "Program";
10
+ AST_TYPES["binaryExpression"] = "BinaryExpression";
11
+ AST_TYPES["unaryExpression"] = "UnaryExpression";
12
+ AST_TYPES["functionCall"] = "FunctionCall";
13
+ AST_TYPES["variable"] = "Variable";
14
+ AST_TYPES["literal"] = "Literal";
15
+ })(AST_TYPES || (AST_TYPES = {}));
16
+ export var ERROR_LIST;
17
+ (function (ERROR_LIST) {
18
+ ERROR_LIST["arguments"] = "arguments";
19
+ ERROR_LIST["nulls"] = "nulls";
20
+ ERROR_LIST["floatingPoint"] = "floatingPoint";
21
+ ERROR_LIST["missingString"] = "missingString";
22
+ ERROR_LIST["missingNumber"] = "missingNumber";
23
+ ERROR_LIST["missingDate"] = "missingDate";
24
+ ERROR_LIST["greaterThanZero"] = "greaterThanZero";
25
+ ERROR_LIST["missingArg"] = "missingArg";
26
+ ERROR_LIST["unknownFunction"] = "unknownFunction";
27
+ ERROR_LIST["unknown"] = "unknown";
28
+ ERROR_LIST["customDateDifParams"] = "customDateDifParams";
29
+ ERROR_LIST["tooManyArguments"] = "tooManyArguments";
30
+ })(ERROR_LIST || (ERROR_LIST = {}));
31
+ export const ERROR_DICTIONARY = {
32
+ [ERROR_LIST.arguments]: {
33
+ message: 'Ilegal number of arguments for function',
34
+ code: 'NUMBER_ARGS',
35
+ },
36
+ [ERROR_LIST.nulls]: {
37
+ message: 'Can not apply function with null values',
38
+ code: 'NULL_FOUNDS',
39
+ },
40
+ [ERROR_LIST.floatingPoint]: {
41
+ message: 'Invalid floating point operation to integer',
42
+ code: 'FLOATING_POINT',
43
+ },
44
+ [ERROR_LIST.missingString]: {
45
+ message: 'Element has to be a String',
46
+ code: 'MISSING_STRING',
47
+ },
48
+ [ERROR_LIST.missingNumber]: {
49
+ message: 'Element has to be a Number',
50
+ code: 'MISSING_NUMBER',
51
+ },
52
+ [ERROR_LIST.missingDate]: {
53
+ message: 'Element has to be a Date',
54
+ code: 'MISSING_DATE',
55
+ },
56
+ [ERROR_LIST.greaterThanZero]: {
57
+ message: 'Element has to be greater than 0',
58
+ code: 'GREATER_THAN_ZERO',
59
+ },
60
+ [ERROR_LIST.missingArg]: {
61
+ message: 'Missing arguments',
62
+ code: 'MISSING_ARG',
63
+ },
64
+ [ERROR_LIST.unknownFunction]: {
65
+ message: 'Unknown function',
66
+ code: 'UNKNOWN_FUNCTION',
67
+ },
68
+ [ERROR_LIST.unknown]: {
69
+ message: 'Unknown error',
70
+ code: 'UNKNOWN',
71
+ },
72
+ [ERROR_LIST.tooManyArguments]: {
73
+ message: 'Too many arguments',
74
+ code: 'TOO_MANY_ARGUMENTS',
75
+ },
76
+ [ERROR_LIST.customDateDifParams]: {
77
+ message: 'Unit param have to be equal to: "Y", "M", "D"',
78
+ code: 'DATE_DIF_UNIT_PARAM',
79
+ },
80
+ };
81
+ export const CustomOperators = {
82
+ [ENGINES.ELASTICSEARCH]: {
83
+ '=': '==',
84
+ },
85
+ };
86
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,OAIX;AAJD,WAAY,OAAO;IACf,0CAA+B,CAAA;IAC/B,kCAAuB,CAAA;IACvB,gCAAqB,CAAA;AACzB,CAAC,EAJW,OAAO,KAAP,OAAO,QAIlB;AAED,MAAM,CAAN,IAAY,SAOX;AAPD,WAAY,SAAS;IACjB,gCAAmB,CAAA;IACnB,kDAAqC,CAAA;IACrC,gDAAmC,CAAA;IACnC,0CAA6B,CAAA;IAC7B,kCAAqB,CAAA;IACrB,gCAAmB,CAAA;AACvB,CAAC,EAPW,SAAS,KAAT,SAAS,QAOpB;AAED,MAAM,CAAN,IAAY,UAaX;AAbD,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;I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O,EAAE,oBAAoB;QAC7B,IAAI,EAAE,oBAAoB;KAC7B;IACD,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE;QAC9B,OAAO,EAAE,+CAA+C;QACxD,IAAI,EAAE,qBAAqB;KAC9B;CACJ,CAAC;AAMF,MAAM,CAAC,MAAM,eAAe,GAA0B;IAClD,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACrB,GAAG,EAAE,IAAI;KACZ;CACJ,CAAC"}
@@ -0,0 +1,62 @@
1
+ import { ENGINES, AST_TYPES } from '.';
2
+ interface FunctionElementDefinition {
3
+ identifier: string;
4
+ name: string;
5
+ }
6
+ export interface FunctionDefinition extends FunctionElementDefinition {
7
+ recursiveStartIn?: number;
8
+ transpiler: TranspilerEnginesFunction;
9
+ parameters?: Array<FunctionParameters>;
10
+ }
11
+ type TranspilerEnginesFunction = {
12
+ [key in ENGINES]: Function;
13
+ };
14
+ interface FunctionParameters extends FunctionElementDefinition {
15
+ type: string;
16
+ optional: boolean;
17
+ validator: Array<ValidatorFunctionParameter>;
18
+ }
19
+ interface ValidatorFunctionParameter {
20
+ (args: any): ValidatorResponse;
21
+ }
22
+ export interface ValidatorResponse {
23
+ valid: boolean;
24
+ code?: string;
25
+ message?: string;
26
+ }
27
+ export interface TranspilationResponse {
28
+ valid: boolean;
29
+ expression?: string;
30
+ error?: any;
31
+ }
32
+ export interface FunctionList {
33
+ [identifier: string]: FunctionDefinition;
34
+ }
35
+ export interface CommonAST {
36
+ type: AST_TYPES;
37
+ }
38
+ export interface ProgramAST extends CommonAST {
39
+ exp: string;
40
+ lang: string;
41
+ version: string;
42
+ body?: CommonAST;
43
+ }
44
+ export interface UnaryExpressionAST extends CommonAST {
45
+ operator: string;
46
+ right: CommonAST;
47
+ }
48
+ export interface BinaryExpressionAST extends UnaryExpressionAST {
49
+ left: CommonAST;
50
+ }
51
+ export interface FunctionCallAST extends CommonAST {
52
+ name: string;
53
+ arguments: Array<CommonAST>;
54
+ }
55
+ export interface VariableAST extends CommonAST {
56
+ value: string | boolean | number | CommonAST[] | null | Date;
57
+ }
58
+ export interface LiteralAST extends VariableAST {
59
+ dataType: string;
60
+ }
61
+ export type DateDifUnitParam = 'Y' | 'M' | 'D';
62
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/constants/interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import { FunctionCallAST, ValidatorResponse } from '../constants/interfaces';
2
+ export declare class BaseError extends Error {
3
+ code: string;
4
+ node: FunctionCallAST | undefined;
5
+ constructor(code: string, message: string, node?: FunctionCallAST);
6
+ toString(): string;
7
+ }
8
+ export declare class GenericError extends BaseError {
9
+ constructor(message?: string);
10
+ }
11
+ export declare class UnknownFunctionError extends BaseError {
12
+ node: FunctionCallAST;
13
+ constructor(node: FunctionCallAST);
14
+ }
15
+ export declare class MissingArgumentError extends BaseError {
16
+ node: FunctionCallAST;
17
+ constructor(node: FunctionCallAST);
18
+ }
19
+ export declare class TooManyArgumentsError extends BaseError {
20
+ node: FunctionCallAST;
21
+ constructor(node: FunctionCallAST);
22
+ }
23
+ export declare class InvalidArgumentError extends BaseError {
24
+ node: FunctionCallAST;
25
+ constructor(node: FunctionCallAST, validatorResponse: ValidatorResponse);
26
+ }
@@ -0,0 +1,42 @@
1
+ import { ERROR_DICTIONARY, ERROR_LIST } from '../constants';
2
+ export class BaseError extends Error {
3
+ constructor(code, message, node) {
4
+ super(message);
5
+ this.code = code;
6
+ this.node = node;
7
+ }
8
+ toString() {
9
+ var _a;
10
+ return `${this.code}: ${this.message} ${(_a = this.node) === null || _a === void 0 ? void 0 : _a.name}`;
11
+ }
12
+ }
13
+ export class GenericError extends BaseError {
14
+ constructor(message = ERROR_DICTIONARY[ERROR_LIST.unknown].message) {
15
+ super(ERROR_DICTIONARY[ERROR_LIST.unknown].code, message);
16
+ }
17
+ }
18
+ export class UnknownFunctionError extends BaseError {
19
+ constructor(node) {
20
+ super(ERROR_DICTIONARY[ERROR_LIST.unknownFunction].code, ERROR_DICTIONARY[ERROR_LIST.unknownFunction].message, node);
21
+ this.node = node;
22
+ }
23
+ }
24
+ export class MissingArgumentError extends BaseError {
25
+ constructor(node) {
26
+ super(ERROR_DICTIONARY[ERROR_LIST.missingArg].code, ERROR_DICTIONARY[ERROR_LIST.missingArg].message, node);
27
+ this.node = node;
28
+ }
29
+ }
30
+ export class TooManyArgumentsError extends BaseError {
31
+ constructor(node) {
32
+ super(ERROR_DICTIONARY[ERROR_LIST.tooManyArguments].code, ERROR_DICTIONARY[ERROR_LIST.tooManyArguments].message, node);
33
+ this.node = node;
34
+ }
35
+ }
36
+ export class InvalidArgumentError extends BaseError {
37
+ constructor(node, validatorResponse) {
38
+ super((validatorResponse === null || validatorResponse === void 0 ? void 0 : validatorResponse.code) || '', (validatorResponse === null || validatorResponse === void 0 ? void 0 : validatorResponse.message) || '', node);
39
+ this.node = node;
40
+ }
41
+ }
42
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../../src/errors/definitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG5D,MAAM,OAAO,SAAU,SAAQ,KAAK;IAIhC,YAAY,IAAY,EAAE,OAAe,EAAE,IAAsB;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,QAAQ;;QACJ,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,IAAI,MAAA,IAAI,CAAC,IAAI,0CAAE,IAAI,EAAE,CAAC;IAC9D,CAAC;CACJ;AAED,MAAM,OAAO,YAAa,SAAQ,SAAS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APK,SAAI,GAAJ,IAAI,CAAiB;IAQhC,CAAC;CACJ"}
@@ -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,27 @@
1
+ import { ERROR_LIST } from '../constants';
2
+ const reasonsRegex = {
3
+ unknownFunction: {
4
+ regex: /Unknown call \[.*\] with/,
5
+ value: ERROR_LIST.unknownFunction,
6
+ },
7
+ missingArguments: {
8
+ regex: /static method \[.*\] not found/,
9
+ value: ERROR_LIST.arguments,
10
+ },
11
+ };
12
+ const typesRegex = {
13
+ arguments: {
14
+ regex: /illegal_argument_exception/,
15
+ value: ERROR_LIST.arguments,
16
+ },
17
+ state: {
18
+ regex: /illegal_state_exception/,
19
+ value: ERROR_LIST.nulls,
20
+ },
21
+ null_pointer: {
22
+ regex: /null_pointer_exception/,
23
+ value: ERROR_LIST.nulls,
24
+ },
25
+ };
26
+ export const errorRegex = [reasonsRegex, typesRegex];
27
+ //# sourceMappingURL=elasticsearch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elasticsearch.js","sourceRoot":"","sources":["../../../src/errors/elasticsearch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,YAAY,GAAG;IACjB,eAAe,EAAE;QACb,KAAK,EAAE,0BAA0B;QACjC,KAAK,EAAE,UAAU,CAAC,eAAe;KACpC;IACD,gBAAgB,EAAE;QACd,KAAK,EAAE,gCAAgC;QACvC,KAAK,EAAE,UAAU,CAAC,SAAS;KAC9B;CACJ,CAAC;AAEF,MAAM,UAAU,GAAG;IACf,SAAS,EAAE;QACP,KAAK,EAAE,4BAA4B;QACnC,KAAK,EAAE,UAAU,CAAC,SAAS;KAC9B;IACD,KAAK,EAAE;QACH,KAAK,EAAE,yBAAyB;QAChC,KAAK,EAAE,UAAU,CAAC,KAAK;KAC1B;IACD,YAAY,EAAE;QACV,KAAK,EAAE,wBAAwB;QAC/B,KAAK,EAAE,UAAU,CAAC,KAAK;KAC1B;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ValidatorResponse } from '../constants/interfaces';
2
+ export declare function engineErrors(messages: Array<string>, regexs: Array<object>): ValidatorResponse;
@@ -0,0 +1,21 @@
1
+ import { ERROR_LIST, ERROR_DICTIONARY } from '../constants';
2
+ export function engineErrors(messages, regexs) {
3
+ const loopParams = (obj, str) => {
4
+ for (const key in obj) {
5
+ const regex = new RegExp(obj[key].regex, 'g');
6
+ if (regex.test(str)) {
7
+ return obj[key].value;
8
+ }
9
+ }
10
+ };
11
+ let value;
12
+ messages.forEach((message) => {
13
+ regexs.forEach((regex) => {
14
+ value = loopParams(regex, message);
15
+ });
16
+ });
17
+ if (!value)
18
+ value = ERROR_LIST.unknown;
19
+ return Object.assign({ valid: false }, ERROR_DICTIONARY[value]);
20
+ }
21
+ //# sourceMappingURL=engineErrors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engineErrors.js","sourceRoot":"","sources":["../../../src/errors/engineErrors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAG5D,MAAM,UAAU,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,UAAU,CAAC,OAAO,CAAC;IACvC,uBAAS,KAAK,EAAE,KAAK,IAAK,gBAAgB,CAAC,KAAK,CAAC,EAAG;AACxD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './definitions';
2
+ export * from './engineErrors';
@@ -0,0 +1,5 @@
1
+ export * from './definitions';
2
+ //export * from './elasticsearch';
3
+ export * from './engineErrors';
4
+ //export * from './snowflake';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,kCAAkC;AAClC,cAAc,gBAAgB,CAAC;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,17 @@
1
+ import { ERROR_LIST } from '../constants';
2
+ const reasonsRegex = {
3
+ missingArguments: {
4
+ regex: /not enough arguments for function/,
5
+ value: ERROR_LIST.arguments,
6
+ },
7
+ floatingPoint: {
8
+ regex: /Invalid floating point operation/,
9
+ value: ERROR_LIST.floatingPoint,
10
+ },
11
+ unknownFunction: {
12
+ regex: /Unknown function/,
13
+ value: ERROR_LIST.unknownFunction,
14
+ },
15
+ };
16
+ export const errorRegex = [reasonsRegex];
17
+ //# sourceMappingURL=snowflake.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snowflake.js","sourceRoot":"","sources":["../../../src/errors/snowflake.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,YAAY,GAAG;IACjB,gBAAgB,EAAE;QACd,KAAK,EAAE,mCAAmC;QAC1C,KAAK,EAAE,UAAU,CAAC,SAAS;KAC9B;IACD,aAAa,EAAE;QACX,KAAK,EAAE,kCAAkC;QACzC,KAAK,EAAE,UAAU,CAAC,aAAa;KAClC;IACD,eAAe,EAAE;QACb,KAAK,EAAE,kBAAkB;QACzB,KAAK,EAAE,UAAU,CAAC,eAAe;KACpC;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,YAAY,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { FunctionDefinition } from '../constants/interfaces';
2
+ /**
3
+ * `ABS` Returns the absolute value of a number.
4
+ */
5
+ export declare const ABS: FunctionDefinition;
@@ -0,0 +1,35 @@
1
+ import { isNumberParam } from '../utils';
2
+ /**
3
+ * `ABS` Returns the absolute value of a number.
4
+ */
5
+ export const ABS = {
6
+ identifier: 'ABS',
7
+ name: 'ABS',
8
+ parameters: [
9
+ {
10
+ identifier: 'VALUE',
11
+ name: 'value',
12
+ type: 'Number',
13
+ optional: false,
14
+ validator: [isNumberParam],
15
+ },
16
+ ],
17
+ transpiler: {
18
+ elasticsearch,
19
+ snowflake,
20
+ redshift,
21
+ },
22
+ };
23
+ function elasticsearch(value) {
24
+ return `Math.abs(${value})`;
25
+ }
26
+ function SQL(value) {
27
+ return `ABS(${value})`;
28
+ }
29
+ function snowflake(value) {
30
+ return SQL(value);
31
+ }
32
+ function redshift(value) {
33
+ return SQL(value);
34
+ }
35
+ //# sourceMappingURL=abs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abs.js","sourceRoot":"","sources":["../../../src/functions/abs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,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,aAAa,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"}
@@ -0,0 +1,5 @@
1
+ import { FunctionDefinition } from '../constants/interfaces';
2
+ /**
3
+ * Returns the number of the DATEDIF in a Date.
4
+ */
5
+ export declare const DATEDIF: FunctionDefinition;
@@ -0,0 +1,58 @@
1
+ import { ERROR_LIST, ERROR_DICTIONARY } from '../constants';
2
+ import { dateDif as ESdateDif } from '../utils/elasticsearch/scripts';
3
+ import { dateDif as SQLdateDif } from '../utils/sql/scripts';
4
+ import { isDateParam, isStringParam } from '../utils';
5
+ /**
6
+ * Returns the number of the DATEDIF in a Date.
7
+ */
8
+ export const DATEDIF = {
9
+ identifier: 'DATEDIF',
10
+ name: 'DATEDIF',
11
+ parameters: [
12
+ {
13
+ identifier: 'START_DATE',
14
+ name: 'start_date',
15
+ type: 'Date',
16
+ optional: false,
17
+ validator: [isDateParam],
18
+ },
19
+ {
20
+ identifier: 'END_DATE',
21
+ name: 'end_date',
22
+ type: 'Date',
23
+ optional: false,
24
+ validator: [isDateParam],
25
+ },
26
+ {
27
+ identifier: 'UNIT',
28
+ name: 'unit',
29
+ type: 'String',
30
+ optional: false,
31
+ validator: [isStringParam, customValidatorYMD],
32
+ },
33
+ ],
34
+ transpiler: {
35
+ elasticsearch,
36
+ snowflake,
37
+ redshift,
38
+ },
39
+ };
40
+ function customValidatorYMD(param) {
41
+ const valid = ['Y', 'M', 'D'].includes(param);
42
+ if (!valid)
43
+ return Object.assign({ valid }, ERROR_DICTIONARY[ERROR_LIST.customDateDifParams]);
44
+ return { valid };
45
+ }
46
+ function elasticsearch(start, end, unit) {
47
+ return ESdateDif(start, end, unit);
48
+ }
49
+ function SQL(start, end, unit) {
50
+ return SQLdateDif(start, end, unit);
51
+ }
52
+ function snowflake(start, end, unit) {
53
+ return SQL(start, end, unit);
54
+ }
55
+ function redshift(start, end, unit) {
56
+ return SQL(start, end, unit);
57
+ }
58
+ //# sourceMappingURL=datedif.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datedif.js","sourceRoot":"","sources":["../../../src/functions/datedif.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAC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C,CAAC;AAED,SAAS,SAAS,CAAC,KAAa,EAAE,GAAW,EAAE,IAAsB;IACjE,OAAO,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,GAAW,EAAE,IAAsB;IAChE,OAAO,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { FunctionDefinition } from '../constants/interfaces';
2
+ /**
3
+ * Returns the number of the DAY in a Date.
4
+ */
5
+ export declare const DAY: FunctionDefinition;
@@ -0,0 +1,36 @@
1
+ import { dayScript } from '../utils/elasticsearch/scripts';
2
+ import { isDateParam } from '../utils';
3
+ /**
4
+ * Returns the number of the DAY in a Date.
5
+ */
6
+ export const DAY = {
7
+ identifier: 'DAY',
8
+ name: 'DAY',
9
+ parameters: [
10
+ {
11
+ identifier: 'DATE',
12
+ name: 'date',
13
+ type: 'Date',
14
+ optional: false,
15
+ validator: [isDateParam],
16
+ },
17
+ ],
18
+ transpiler: {
19
+ elasticsearch,
20
+ snowflake,
21
+ redshift,
22
+ },
23
+ };
24
+ function elasticsearch(value) {
25
+ return dayScript(value);
26
+ }
27
+ function SQL(value) {
28
+ return `DATE_PART('day', ${value})`;
29
+ }
30
+ function snowflake(value) {
31
+ return SQL(value);
32
+ }
33
+ function redshift(value) {
34
+ return SQL(value);
35
+ }
36
+ //# sourceMappingURL=day.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"day.js","sourceRoot":"","sources":["../../../src/functions/day.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAuB;IACnC,UAAU,EAAE,KAAK;IACjB,IAAI,EAAE,KAAK;IACX,UAAU,EAAE;QACR;YACI,UAAU,EAAE,MAAM;YAClB,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,WAAW,CAAC;SAC3B;KACJ;IACD,UAAU,EAAE;QACR,aAAa;QACb,SAAS;QACT,QAAQ;KACX;CACJ,CAAC;AAEF,SAAS,aAAa,CAAC,KAAa;IAChC,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED,SAAS,GAAG,CAAC,KAAa;IACtB,OAAO,oBAAoB,KAAK,GAAG,CAAC;AACxC,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"}
@@ -0,0 +1,5 @@
1
+ import { FunctionDefinition } from '../constants/interfaces';
2
+ /**
3
+ * Returns the number of the HOUR in a Date.
4
+ */
5
+ export declare const HOUR: FunctionDefinition;
@@ -0,0 +1,36 @@
1
+ import { hourScript } from '../utils/elasticsearch/scripts';
2
+ import { isDateParam } from '../utils';
3
+ /**
4
+ * Returns the number of the HOUR in a Date.
5
+ */
6
+ export const HOUR = {
7
+ identifier: 'HOUR',
8
+ name: 'HOUR',
9
+ parameters: [
10
+ {
11
+ identifier: 'DATE',
12
+ name: 'date',
13
+ type: 'Date',
14
+ optional: false,
15
+ validator: [isDateParam],
16
+ },
17
+ ],
18
+ transpiler: {
19
+ elasticsearch,
20
+ snowflake,
21
+ redshift,
22
+ },
23
+ };
24
+ function elasticsearch(value) {
25
+ return hourScript(value);
26
+ }
27
+ function SQL(value) {
28
+ return `DATE_PART('hour', ${value})`;
29
+ }
30
+ function snowflake(value) {
31
+ return SQL(value);
32
+ }
33
+ function redshift(value) {
34
+ return SQL(value);
35
+ }
36
+ //# sourceMappingURL=hour.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hour.js","sourceRoot":"","sources":["../../../src/functions/hour.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAuB;IACpC,UAAU,EAAE,MAAM;IAClB,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE;QACR;YACI,UAAU,EAAE,MAAM;YAClB,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,WAAW,CAAC;SAC3B;KACJ;IACD,UAAU,EAAE;QACR,aAAa;QACb,SAAS;QACT,QAAQ;KACX;CACJ,CAAC;AAEF,SAAS,aAAa,CAAC,KAAa;IAChC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,GAAG,CAAC,KAAa;IACtB,OAAO,qBAAqB,KAAK,GAAG,CAAC;AACzC,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"}
@@ -0,0 +1,5 @@
1
+ import { FunctionDefinition } from '../constants/interfaces';
2
+ /**
3
+ * `IF` Returns one value if a logical expression is TRUE and another if it is FALSE.
4
+ */
5
+ export declare const IF: FunctionDefinition;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * `IF` Returns one value if a logical expression is TRUE and another if it is FALSE.
3
+ */
4
+ export const IF = {
5
+ identifier: 'IF',
6
+ name: 'IF',
7
+ parameters: [
8
+ {
9
+ identifier: 'LOGICAL_EXPRESSION',
10
+ name: 'logical_expression',
11
+ type: 'BinaryExpression',
12
+ optional: false,
13
+ validator: [],
14
+ },
15
+ {
16
+ identifier: 'VALUE_IF_TRUE',
17
+ name: 'VALUE_IF_TRUE',
18
+ type: 'Literal',
19
+ optional: false,
20
+ validator: [],
21
+ },
22
+ {
23
+ identifier: 'VALUE_IF_FALSE',
24
+ name: 'VALUE_IF_FALSE',
25
+ type: 'Literal',
26
+ optional: true,
27
+ validator: [],
28
+ },
29
+ ],
30
+ transpiler: {
31
+ elasticsearch,
32
+ snowflake,
33
+ redshift,
34
+ },
35
+ };
36
+ function elasticsearch(logicalExpression, valueIfTrue, valueIfFalse) {
37
+ return `(${logicalExpression} ? ${valueIfTrue} : ${valueIfFalse !== null && valueIfFalse !== void 0 ? valueIfFalse : 'false'})`;
38
+ }
39
+ function snowflake(logicalExpression, valueIfTrue, valueIfFalse) {
40
+ return `IFF(${logicalExpression}, ${valueIfTrue}, ${valueIfFalse !== null && valueIfFalse !== void 0 ? valueIfFalse : 'FALSE'})`;
41
+ }
42
+ function redshift(logicalExpression, valueIfTrue, valueIfFalse) {
43
+ return `
44
+ (CASE
45
+ WHEN ${logicalExpression} THEN ${valueIfTrue}
46
+ ELSE ${valueIfFalse !== null && valueIfFalse !== void 0 ? valueIfFalse : 'FALSE'}
47
+ END)`.trim();
48
+ }
49
+ //# sourceMappingURL=if.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"if.js","sourceRoot":"","sources":["../../../src/functions/if.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,EAAE,GAAuB;IAClC,UAAU,EAAE,IAAI;IAChB,IAAI,EAAE,IAAI;IACV,UAAU,EAAE;QACR;YACI,UAAU,EAAE,oBAAoB;YAChC,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE,kBAAkB;YACxB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,EAAE;SAChB;QACD;YACI,UAAU,EAAE,eAAe;YAC3B,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,EAAE;SAChB;QACD;YACI,UAAU,EAAE,gBAAgB;YAC5B,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,EAAE;SAChB;KACJ;IACD,UAAU,EAAE;QACR,aAAa;QACb,SAAS;QACT,QAAQ;KACX;CACJ,CAAC;AAEF,SAAS,aAAa,CAClB,iBAAyB,EACzB,WAAmB,EACnB,YAAqB;IAErB,OAAO,IAAI,iBAAiB,MAAM,WAAW,MACzC,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,OACpB,GAAG,CAAC;AACR,CAAC;AAED,SAAS,SAAS,CACd,iBAAyB,EACzB,WAAmB,EACnB,YAAqB;IAErB,OAAO,OAAO,iBAAiB,KAAK,WAAW,KAC3C,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,OACpB,GAAG,CAAC;AACR,CAAC;AAED,SAAS,QAAQ,CACb,iBAAyB,EACzB,WAAmB,EACnB,YAAqB;IAErB,OAAO;;WAEA,iBAAiB,SAAS,WAAW;WACrC,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,OAAO;KAC7B,CAAC,IAAI,EAAE,CAAC;AACb,CAAC"}