@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.
Files changed (313) hide show
  1. package/.vscode/launch.json +15 -0
  2. package/CHANGELOG.md +12 -0
  3. package/dist/bundle.js +23152 -0
  4. package/dist/cjs/constants/index.d.ts +53 -0
  5. package/dist/cjs/constants/index.js +117 -0
  6. package/dist/cjs/constants/index.js.map +1 -0
  7. package/dist/cjs/constants/interfaces.d.ts +91 -0
  8. package/dist/cjs/constants/interfaces.js +3 -0
  9. package/dist/cjs/constants/interfaces.js.map +1 -0
  10. package/dist/cjs/errors/definitions.d.ts +43 -0
  11. package/dist/cjs/errors/definitions.js +91 -0
  12. package/dist/cjs/errors/definitions.js.map +1 -0
  13. package/dist/cjs/errors/elasticsearch.d.ts +24 -0
  14. package/dist/cjs/errors/elasticsearch.js +30 -0
  15. package/dist/cjs/errors/elasticsearch.js.map +1 -0
  16. package/dist/cjs/errors/engineErrors.d.ts +2 -0
  17. package/dist/cjs/errors/engineErrors.js +25 -0
  18. package/dist/cjs/errors/engineErrors.js.map +1 -0
  19. package/dist/cjs/errors/index.d.ts +2 -0
  20. package/dist/cjs/errors/index.js +21 -0
  21. package/dist/cjs/errors/index.js.map +1 -0
  22. package/dist/cjs/errors/snowflake.d.ts +15 -0
  23. package/dist/cjs/errors/snowflake.js +20 -0
  24. package/dist/cjs/errors/snowflake.js.map +1 -0
  25. package/dist/cjs/functions/abs.d.ts +5 -0
  26. package/dist/cjs/functions/abs.js +38 -0
  27. package/dist/cjs/functions/abs.js.map +1 -0
  28. package/dist/cjs/functions/datedif.d.ts +5 -0
  29. package/dist/cjs/functions/datedif.js +64 -0
  30. package/dist/cjs/functions/datedif.js.map +1 -0
  31. package/dist/cjs/functions/day.d.ts +5 -0
  32. package/dist/cjs/functions/day.js +39 -0
  33. package/dist/cjs/functions/day.js.map +1 -0
  34. package/dist/cjs/functions/hour.d.ts +5 -0
  35. package/dist/cjs/functions/hour.js +39 -0
  36. package/dist/cjs/functions/hour.js.map +1 -0
  37. package/dist/cjs/functions/if.d.ts +5 -0
  38. package/dist/cjs/functions/if.js +52 -0
  39. package/dist/cjs/functions/if.js.map +1 -0
  40. package/dist/cjs/functions/ifs.d.ts +5 -0
  41. package/dist/cjs/functions/ifs.js +74 -0
  42. package/dist/cjs/functions/ifs.js.map +1 -0
  43. package/dist/cjs/functions/index.d.ts +4 -0
  44. package/dist/cjs/functions/index.js +33 -0
  45. package/dist/cjs/functions/index.js.map +1 -0
  46. package/dist/cjs/functions/mid.d.ts +5 -0
  47. package/dist/cjs/functions/mid.js +54 -0
  48. package/dist/cjs/functions/mid.js.map +1 -0
  49. package/dist/cjs/functions/minute.d.ts +5 -0
  50. package/dist/cjs/functions/minute.js +39 -0
  51. package/dist/cjs/functions/minute.js.map +1 -0
  52. package/dist/cjs/functions/month.d.ts +5 -0
  53. package/dist/cjs/functions/month.js +39 -0
  54. package/dist/cjs/functions/month.js.map +1 -0
  55. package/dist/cjs/functions/second.d.ts +5 -0
  56. package/dist/cjs/functions/second.js +39 -0
  57. package/dist/cjs/functions/second.js.map +1 -0
  58. package/dist/cjs/functions/year.d.ts +5 -0
  59. package/dist/cjs/functions/year.js +39 -0
  60. package/dist/cjs/functions/year.js.map +1 -0
  61. package/dist/cjs/grammar/generated/qformula.lang.d.ts +13 -0
  62. package/dist/cjs/grammar/generated/qformula.lang.js +50 -0
  63. package/dist/cjs/grammar/generated/qformula.lang.js.map +1 -0
  64. package/dist/cjs/grammar/qformula.grammar.d.ts +1 -0
  65. package/dist/cjs/grammar/qformula.grammar.js +18 -0
  66. package/dist/cjs/grammar/qformula.grammar.js.map +1 -0
  67. package/dist/cjs/index.d.ts +10 -0
  68. package/dist/cjs/index.js +33 -0
  69. package/dist/cjs/index.js.map +1 -0
  70. package/dist/cjs/main.d.ts +1 -0
  71. package/dist/cjs/main.js +69 -0
  72. package/dist/cjs/main.js.map +1 -0
  73. package/dist/cjs/parser/json-parser.d.ts +3 -0
  74. package/dist/cjs/parser/json-parser.js +201 -0
  75. package/dist/cjs/parser/json-parser.js.map +1 -0
  76. package/dist/cjs/parser/syntax-errors.d.ts +3 -0
  77. package/dist/cjs/parser/syntax-errors.js +28 -0
  78. package/dist/cjs/parser/syntax-errors.js.map +1 -0
  79. package/dist/cjs/transpiler/columnTranspilation.d.ts +3 -0
  80. package/dist/cjs/transpiler/columnTranspilation.js +29 -0
  81. package/dist/cjs/transpiler/columnTranspilation.js.map +1 -0
  82. package/dist/cjs/transpiler/index.d.ts +18 -0
  83. package/dist/cjs/transpiler/index.js +107 -0
  84. package/dist/cjs/transpiler/index.js.map +1 -0
  85. package/dist/cjs/transpiler/unshiftCustomFunctions.d.ts +2 -0
  86. package/dist/cjs/transpiler/unshiftCustomFunctions.js +14 -0
  87. package/dist/cjs/transpiler/unshiftCustomFunctions.js.map +1 -0
  88. package/dist/cjs/transpiler/validateFuncStructure.d.ts +2 -0
  89. package/dist/cjs/transpiler/validateFuncStructure.js +41 -0
  90. package/dist/cjs/transpiler/validateFuncStructure.js.map +1 -0
  91. package/dist/cjs/utils/customFunctions.d.ts +4 -0
  92. package/dist/cjs/utils/customFunctions.js +35 -0
  93. package/dist/cjs/utils/customFunctions.js.map +1 -0
  94. package/dist/cjs/utils/elasticsearch/index.d.ts +2 -0
  95. package/dist/cjs/utils/elasticsearch/index.js +22 -0
  96. package/dist/cjs/utils/elasticsearch/index.js.map +1 -0
  97. package/dist/cjs/utils/elasticsearch/scripts.d.ts +11 -0
  98. package/dist/cjs/utils/elasticsearch/scripts.js +57 -0
  99. package/dist/cjs/utils/elasticsearch/scripts.js.map +1 -0
  100. package/dist/cjs/utils/getMonthMaxDayAllowed.d.ts +7 -0
  101. package/dist/cjs/utils/getMonthMaxDayAllowed.js +26 -0
  102. package/dist/cjs/utils/getMonthMaxDayAllowed.js.map +1 -0
  103. package/dist/cjs/utils/getNodeValue.d.ts +2 -0
  104. package/dist/cjs/utils/getNodeValue.js +13 -0
  105. package/dist/cjs/utils/getNodeValue.js.map +1 -0
  106. package/dist/cjs/utils/getVariableType.d.ts +3 -0
  107. package/dist/cjs/utils/getVariableType.js +19 -0
  108. package/dist/cjs/utils/getVariableType.js.map +1 -0
  109. package/dist/cjs/utils/index.d.ts +10 -0
  110. package/dist/cjs/utils/index.js +29 -0
  111. package/dist/cjs/utils/index.js.map +1 -0
  112. package/dist/cjs/utils/isDateParam.d.ts +2 -0
  113. package/dist/cjs/utils/isDateParam.js +12 -0
  114. package/dist/cjs/utils/isDateParam.js.map +1 -0
  115. package/dist/cjs/utils/isNumberParam.d.ts +2 -0
  116. package/dist/cjs/utils/isNumberParam.js +12 -0
  117. package/dist/cjs/utils/isNumberParam.js.map +1 -0
  118. package/dist/cjs/utils/isPositiveNumberParam.d.ts +2 -0
  119. package/dist/cjs/utils/isPositiveNumberParam.js +12 -0
  120. package/dist/cjs/utils/isPositiveNumberParam.js.map +1 -0
  121. package/dist/cjs/utils/isStringParam.d.ts +2 -0
  122. package/dist/cjs/utils/isStringParam.js +12 -0
  123. package/dist/cjs/utils/isStringParam.js.map +1 -0
  124. package/dist/cjs/utils/isValidDate.d.ts +1 -0
  125. package/dist/cjs/utils/isValidDate.js +8 -0
  126. package/dist/cjs/utils/isValidDate.js.map +1 -0
  127. package/dist/cjs/utils/sql/index.d.ts +1 -0
  128. package/dist/cjs/utils/sql/index.js +6 -0
  129. package/dist/cjs/utils/sql/index.js.map +1 -0
  130. package/dist/cjs/utils/sql/scripts.d.ts +3 -0
  131. package/dist/cjs/utils/sql/scripts.js +44 -0
  132. package/dist/cjs/utils/sql/scripts.js.map +1 -0
  133. package/dist/constants/index.d.ts +11 -2
  134. package/dist/constants/index.js +11 -0
  135. package/dist/constants/index.js.map +1 -1
  136. package/dist/constants/interfaces.d.ts +13 -3
  137. package/dist/errors/definitions.d.ts +20 -3
  138. package/dist/errors/definitions.js +20 -2
  139. package/dist/errors/definitions.js.map +1 -1
  140. package/dist/grammar/generated/qformula.lang.d.ts +9 -0
  141. package/dist/grammar/generated/qformula.lang.js +5 -4
  142. package/dist/grammar/generated/qformula.lang.js.map +1 -1
  143. package/dist/index.d.ts +3 -2
  144. package/dist/index.html +21 -0
  145. package/dist/index.js +2 -2
  146. package/dist/index.js.map +1 -1
  147. package/dist/main.d.ts +1 -0
  148. package/dist/main.js +65 -0
  149. package/dist/main.js.map +1 -0
  150. package/dist/module/constants/index.d.ts +53 -0
  151. package/dist/module/constants/index.js +114 -0
  152. package/dist/module/constants/index.js.map +1 -0
  153. package/dist/module/constants/interfaces.d.ts +91 -0
  154. package/dist/module/constants/interfaces.js +2 -0
  155. package/dist/module/constants/interfaces.js.map +1 -0
  156. package/dist/module/errors/definitions.d.ts +43 -0
  157. package/dist/module/errors/definitions.js +78 -0
  158. package/dist/module/errors/definitions.js.map +1 -0
  159. package/dist/module/errors/elasticsearch.d.ts +24 -0
  160. package/dist/module/errors/elasticsearch.js +27 -0
  161. package/dist/module/errors/elasticsearch.js.map +1 -0
  162. package/dist/module/errors/engineErrors.d.ts +2 -0
  163. package/dist/module/errors/engineErrors.js +21 -0
  164. package/dist/module/errors/engineErrors.js.map +1 -0
  165. package/dist/module/errors/index.d.ts +2 -0
  166. package/dist/module/errors/index.js +5 -0
  167. package/dist/module/errors/index.js.map +1 -0
  168. package/dist/module/errors/snowflake.d.ts +15 -0
  169. package/dist/module/errors/snowflake.js +17 -0
  170. package/dist/module/errors/snowflake.js.map +1 -0
  171. package/dist/module/functions/abs.d.ts +5 -0
  172. package/dist/module/functions/abs.js +35 -0
  173. package/dist/module/functions/abs.js.map +1 -0
  174. package/dist/module/functions/datedif.d.ts +5 -0
  175. package/dist/module/functions/datedif.js +61 -0
  176. package/dist/module/functions/datedif.js.map +1 -0
  177. package/dist/module/functions/day.d.ts +5 -0
  178. package/dist/module/functions/day.js +36 -0
  179. package/dist/module/functions/day.js.map +1 -0
  180. package/dist/module/functions/hour.d.ts +5 -0
  181. package/dist/module/functions/hour.js +36 -0
  182. package/dist/module/functions/hour.js.map +1 -0
  183. package/dist/module/functions/if.d.ts +5 -0
  184. package/dist/module/functions/if.js +49 -0
  185. package/dist/module/functions/if.js.map +1 -0
  186. package/dist/module/functions/ifs.d.ts +5 -0
  187. package/dist/module/functions/ifs.js +71 -0
  188. package/dist/module/functions/ifs.js.map +1 -0
  189. package/dist/module/functions/index.d.ts +4 -0
  190. package/dist/module/functions/index.js +29 -0
  191. package/dist/module/functions/index.js.map +1 -0
  192. package/dist/module/functions/mid.d.ts +5 -0
  193. package/dist/module/functions/mid.js +51 -0
  194. package/dist/module/functions/mid.js.map +1 -0
  195. package/dist/module/functions/minute.d.ts +5 -0
  196. package/dist/module/functions/minute.js +36 -0
  197. package/dist/module/functions/minute.js.map +1 -0
  198. package/dist/module/functions/month.d.ts +5 -0
  199. package/dist/module/functions/month.js +36 -0
  200. package/dist/module/functions/month.js.map +1 -0
  201. package/dist/module/functions/second.d.ts +5 -0
  202. package/dist/module/functions/second.js +36 -0
  203. package/dist/module/functions/second.js.map +1 -0
  204. package/dist/module/functions/year.d.ts +5 -0
  205. package/dist/module/functions/year.js +36 -0
  206. package/dist/module/functions/year.js.map +1 -0
  207. package/dist/module/grammar/generated/qformula.lang.d.ts +13 -0
  208. package/dist/module/grammar/generated/qformula.lang.js +45 -0
  209. package/dist/module/grammar/generated/qformula.lang.js.map +1 -0
  210. package/dist/module/grammar/qformula.grammar.d.ts +1 -0
  211. package/dist/module/grammar/qformula.grammar.js +2 -0
  212. package/dist/module/grammar/qformula.grammar.js.map +1 -0
  213. package/dist/module/index.d.ts +10 -0
  214. package/dist/module/index.js +20 -0
  215. package/dist/module/index.js.map +1 -0
  216. package/dist/module/main.d.ts +1 -0
  217. package/dist/module/main.js +67 -0
  218. package/dist/module/main.js.map +1 -0
  219. package/dist/module/parser/json-parser.d.ts +3 -0
  220. package/dist/module/parser/json-parser.js +197 -0
  221. package/dist/module/parser/json-parser.js.map +1 -0
  222. package/dist/module/parser/syntax-errors.d.ts +3 -0
  223. package/dist/module/parser/syntax-errors.js +24 -0
  224. package/dist/module/parser/syntax-errors.js.map +1 -0
  225. package/dist/module/transpiler/columnTranspilation.d.ts +3 -0
  226. package/dist/module/transpiler/columnTranspilation.js +25 -0
  227. package/dist/module/transpiler/columnTranspilation.js.map +1 -0
  228. package/dist/module/transpiler/index.d.ts +18 -0
  229. package/dist/module/transpiler/index.js +102 -0
  230. package/dist/module/transpiler/index.js.map +1 -0
  231. package/dist/module/transpiler/unshiftCustomFunctions.d.ts +2 -0
  232. package/dist/module/transpiler/unshiftCustomFunctions.js +10 -0
  233. package/dist/module/transpiler/unshiftCustomFunctions.js.map +1 -0
  234. package/dist/module/transpiler/validateFuncStructure.d.ts +2 -0
  235. package/dist/module/transpiler/validateFuncStructure.js +37 -0
  236. package/dist/module/transpiler/validateFuncStructure.js.map +1 -0
  237. package/dist/module/utils/customFunctions.d.ts +4 -0
  238. package/dist/module/utils/customFunctions.js +29 -0
  239. package/dist/module/utils/customFunctions.js.map +1 -0
  240. package/dist/module/utils/elasticsearch/index.d.ts +2 -0
  241. package/dist/module/utils/elasticsearch/index.js +16 -0
  242. package/dist/module/utils/elasticsearch/index.js.map +1 -0
  243. package/dist/module/utils/elasticsearch/scripts.d.ts +11 -0
  244. package/dist/module/utils/elasticsearch/scripts.js +46 -0
  245. package/dist/module/utils/elasticsearch/scripts.js.map +1 -0
  246. package/dist/module/utils/getMonthMaxDayAllowed.d.ts +7 -0
  247. package/dist/module/utils/getMonthMaxDayAllowed.js +22 -0
  248. package/dist/module/utils/getMonthMaxDayAllowed.js.map +1 -0
  249. package/dist/module/utils/getNodeValue.d.ts +2 -0
  250. package/dist/module/utils/getNodeValue.js +9 -0
  251. package/dist/module/utils/getNodeValue.js.map +1 -0
  252. package/dist/module/utils/getVariableType.d.ts +3 -0
  253. package/dist/module/utils/getVariableType.js +14 -0
  254. package/dist/module/utils/getVariableType.js.map +1 -0
  255. package/dist/module/utils/index.d.ts +10 -0
  256. package/dist/module/utils/index.js +11 -0
  257. package/dist/module/utils/index.js.map +1 -0
  258. package/dist/module/utils/isDateParam.d.ts +2 -0
  259. package/dist/module/utils/isDateParam.js +8 -0
  260. package/dist/module/utils/isDateParam.js.map +1 -0
  261. package/dist/module/utils/isNumberParam.d.ts +2 -0
  262. package/dist/module/utils/isNumberParam.js +8 -0
  263. package/dist/module/utils/isNumberParam.js.map +1 -0
  264. package/dist/module/utils/isPositiveNumberParam.d.ts +2 -0
  265. package/dist/module/utils/isPositiveNumberParam.js +8 -0
  266. package/dist/module/utils/isPositiveNumberParam.js.map +1 -0
  267. package/dist/module/utils/isStringParam.d.ts +2 -0
  268. package/dist/module/utils/isStringParam.js +8 -0
  269. package/dist/module/utils/isStringParam.js.map +1 -0
  270. package/dist/module/utils/isValidDate.d.ts +1 -0
  271. package/dist/module/utils/isValidDate.js +4 -0
  272. package/dist/module/utils/isValidDate.js.map +1 -0
  273. package/dist/module/utils/sql/index.d.ts +1 -0
  274. package/dist/module/utils/sql/index.js +2 -0
  275. package/dist/module/utils/sql/index.js.map +1 -0
  276. package/dist/module/utils/sql/scripts.d.ts +3 -0
  277. package/dist/module/utils/sql/scripts.js +39 -0
  278. package/dist/module/utils/sql/scripts.js.map +1 -0
  279. package/dist/parser/json-parser.js +26 -15
  280. package/dist/parser/json-parser.js.map +1 -1
  281. package/dist/parser/syntax-errors.d.ts +3 -0
  282. package/dist/parser/syntax-errors.js +20 -0
  283. package/dist/parser/syntax-errors.js.map +1 -0
  284. package/dist/transpiler/columnTranspilation.d.ts +2 -2
  285. package/dist/transpiler/columnTranspilation.js +10 -4
  286. package/dist/transpiler/columnTranspilation.js.map +1 -1
  287. package/dist/transpiler/index.d.ts +4 -4
  288. package/dist/transpiler/index.js +28 -20
  289. package/dist/transpiler/index.js.map +1 -1
  290. package/dist/transpiler/unshiftCustomFunctions.d.ts +2 -0
  291. package/dist/transpiler/unshiftCustomFunctions.js +10 -0
  292. package/dist/transpiler/unshiftCustomFunctions.js.map +1 -0
  293. package/dist/utils/customFunctions.d.ts +1 -0
  294. package/dist/utils/customFunctions.js +10 -2
  295. package/dist/utils/customFunctions.js.map +1 -1
  296. package/dist/utils/elasticsearch/index.d.ts +1 -1
  297. package/dist/utils/elasticsearch/index.js +1 -1
  298. package/dist/utils/elasticsearch/index.js.map +1 -1
  299. package/dist/utils/elasticsearch/scripts.d.ts +1 -0
  300. package/dist/utils/elasticsearch/scripts.js +14 -4
  301. package/dist/utils/elasticsearch/scripts.js.map +1 -1
  302. package/jest.config.ts +6 -0
  303. package/package.json +21 -6
  304. package/__tests__/integration/__mocks__/context.ts +0 -23
  305. package/__tests__/integration/__mocks__/elasticsearchScripts.ts +0 -28
  306. package/__tests__/integration/__mocks__/sqlScripts.ts +0 -21
  307. package/__tests__/integration/elasticsearch.test.ts +0 -172
  308. package/__tests__/integration/expression.test.ts +0 -56
  309. package/__tests__/integration/redshift.test.ts +0 -142
  310. package/__tests__/integration/sonwflake.test.ts +0 -138
  311. package/__tests__/unit/parser.test.ts +0 -236
  312. package/__tests__/unit/transpiler.test.ts +0 -128
  313. package/bitbucket-pipelines.yml +0 -63
@@ -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,78 @@
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.message = message;
7
+ this.node = node;
8
+ this.code = code;
9
+ this.node = node;
10
+ }
11
+ toString() {
12
+ var _a, _b;
13
+ if (this.node === undefined) {
14
+ return `${this.code}: ${this.message}`;
15
+ }
16
+ else if ('name' in this.node) {
17
+ return `${this.code}: ${this.message} ${(_a = this.node) === null || _a === void 0 ? void 0 : _a.name}`;
18
+ }
19
+ else if ('type' in this.node) {
20
+ return `${this.code}: ${this.message} ${(_b = this.node) === null || _b === void 0 ? void 0 : _b.type}`;
21
+ }
22
+ return '';
23
+ }
24
+ }
25
+ export class GenericError extends BaseError {
26
+ constructor(message = ERROR_DICTIONARY[ERROR_LIST.unknown].message) {
27
+ super(ERROR_DICTIONARY[ERROR_LIST.unknown].code, message);
28
+ }
29
+ }
30
+ export class UnknownFunctionError extends BaseError {
31
+ constructor(node) {
32
+ super(ERROR_DICTIONARY[ERROR_LIST.unknownFunction].code, ERROR_DICTIONARY[ERROR_LIST.unknownFunction].message, node);
33
+ this.node = node;
34
+ }
35
+ }
36
+ export class MissingArgumentError extends BaseError {
37
+ constructor(node) {
38
+ super(ERROR_DICTIONARY[ERROR_LIST.missingArg].code, ERROR_DICTIONARY[ERROR_LIST.missingArg].message, node);
39
+ this.node = node;
40
+ }
41
+ }
42
+ export class MissingParenthesisError extends BaseError {
43
+ constructor(node) {
44
+ super(ERROR_DICTIONARY[ERROR_LIST.missingParenthesis].code, ERROR_DICTIONARY[ERROR_LIST.missingParenthesis].message, node);
45
+ this.node = node;
46
+ }
47
+ }
48
+ export class UnknownTokenError extends BaseError {
49
+ constructor(node) {
50
+ super(ERROR_DICTIONARY[ERROR_LIST.unknownToken].code, ERROR_DICTIONARY[ERROR_LIST.unknownToken].message, node);
51
+ this.node = node;
52
+ }
53
+ }
54
+ export class NotAllowedExpressionError extends BaseError {
55
+ constructor(node) {
56
+ super(ERROR_DICTIONARY[ERROR_LIST.notAllowedExpression].code, ERROR_DICTIONARY[ERROR_LIST.notAllowedExpression].message, node);
57
+ this.node = node;
58
+ }
59
+ }
60
+ export class TooManyArgumentsError extends BaseError {
61
+ constructor(node) {
62
+ super(ERROR_DICTIONARY[ERROR_LIST.tooManyArguments].code, ERROR_DICTIONARY[ERROR_LIST.tooManyArguments].message, node);
63
+ this.node = node;
64
+ }
65
+ }
66
+ export class InvalidArgumentError extends BaseError {
67
+ constructor(node, validatorResponse) {
68
+ super((validatorResponse === null || validatorResponse === void 0 ? void 0 : validatorResponse.code) || '', (validatorResponse === null || validatorResponse === void 0 ? void 0 : validatorResponse.message) || '', node);
69
+ this.node = node;
70
+ }
71
+ }
72
+ export class UnknownExpressionError extends BaseError {
73
+ constructor(expression) {
74
+ super(ERROR_DICTIONARY[ERROR_LIST.unknownExpression].code, ERROR_DICTIONARY[ERROR_LIST.unknownExpression].message, expression);
75
+ this.expression = expression;
76
+ }
77
+ }
78
+ //# 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;AAQ5D,MAAM,OAAO,SAA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,gBAAgB,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,OAAO,EACrD,IAAI,CACP,CAAC;QALa,SAAI,GAAJ,IAAI,CAAiB;IAMxC,CAAC;CACJ;AAED,MAAM,OAAO,oBAAqB,SAAQ,SAAS;IAC/C,YACW,IAAqB,EAC5B,iBAAoC;QAEpC,KAAK,CACD,CAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,IAAI,KAAI,EAAE,EAC7B,CAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,OAAO,KAAI,EAAE,EAChC,IAAI,CACP,CAAC;QAPK,SAAI,GAAJ,IAAI,CAAiB;IAQhC,CAAC;CACJ;AAED,MAAM,OAAO,sBAAuB,SAAQ,SAAS;IACjD,YAAmB,UAAqB;QACpC,KAAK,CACD,gBAAgB,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,IAAI,EACnD,gBAAgB,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,OAAO,EACtD,UAAU,CACb,CAAC;QALa,eAAU,GAAV,UAAU,CAAW;IAMxC,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,61 @@
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, removeQuotes } 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
+ param = removeQuotes(param);
42
+ const valid = ['Y', 'M', 'D'].includes(param);
43
+ if (!valid)
44
+ return Object.assign({ valid }, ERROR_DICTIONARY[ERROR_LIST.customDateDifParams]);
45
+ return { valid };
46
+ }
47
+ function elasticsearch(start, end, unit) {
48
+ unit = removeQuotes(unit);
49
+ return ESdateDif(start, end, unit);
50
+ }
51
+ function SQL(start, end, unit) {
52
+ unit = removeQuotes(unit);
53
+ return SQLdateDif(start, end, unit);
54
+ }
55
+ function snowflake(start, end, unit) {
56
+ return SQL(start, end, unit);
57
+ }
58
+ function redshift(start, end, unit) {
59
+ return SQL(start, end, unit);
60
+ }
61
+ //# 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;AAC7D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEpE;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAuB;IACvC,UAAU,EAAE,SAAS;IACrB,IAAI,EAAE,SAAS;IACf,UAAU,EAAE;QACR;YACI,UAAU,EAAE,YAAY;YACxB,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,WAAW,CAAC;SAC3B;QACD;YACI,UAAU,EAAE,UAAU;YACtB,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,CAAC,WAAW,CAAC;SAC3B;QACD;YACI,UAAU,EAAE,MAAM;YAClB,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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"}
@@ -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 IFS: FunctionDefinition;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * `IF` Returns one value if a logical expression is TRUE and another if it is FALSE.
3
+ */
4
+ export const IFS = {
5
+ identifier: 'IFS',
6
+ name: 'IFS',
7
+ recursiveStartIn: 0,
8
+ parameters: [
9
+ {
10
+ identifier: 'LOGICAL_EXPRESSION',
11
+ name: 'logical_expression',
12
+ type: 'BinaryExpression',
13
+ optional: false,
14
+ validator: [],
15
+ },
16
+ {
17
+ identifier: 'VALUE_IF_TRUE',
18
+ name: 'VALUE_IF_TRUE',
19
+ type: 'Literal',
20
+ optional: false,
21
+ validator: [],
22
+ },
23
+ ],
24
+ transpiler: {
25
+ elasticsearch,
26
+ snowflake,
27
+ redshift,
28
+ },
29
+ };
30
+ function elasticsearch(...args) {
31
+ const _args = [...args];
32
+ const logicalExpression = _args.shift();
33
+ const valueIfTrue = _args.shift();
34
+ if (_args.length === 0) {
35
+ return `(${logicalExpression} ? ${valueIfTrue} : null)`;
36
+ }
37
+ else {
38
+ return `(${logicalExpression} ? ${valueIfTrue} : ${elasticsearch(..._args)})`;
39
+ }
40
+ }
41
+ function snowflake(...args) {
42
+ const _args = [...args];
43
+ const logicalExpression = _args.shift();
44
+ const valueIfTrue = _args.shift();
45
+ if (_args.length === 0) {
46
+ return `IFF(${logicalExpression}, ${valueIfTrue}, NULL)`;
47
+ }
48
+ else {
49
+ return `IFF(${logicalExpression}, ${valueIfTrue}, ${snowflake(..._args)})`;
50
+ }
51
+ }
52
+ function redshift(...args) {
53
+ const _args = [...args];
54
+ const logicalExpression = _args.shift();
55
+ const valueIfTrue = _args.shift();
56
+ if (_args.length === 0) {
57
+ return `
58
+ (CASE
59
+ WHEN ${logicalExpression} THEN ${valueIfTrue}
60
+ ELSE NULL
61
+ END)`.trim();
62
+ }
63
+ else {
64
+ return `
65
+ (CASE
66
+ WHEN ${logicalExpression} THEN ${valueIfTrue}
67
+ ELSE ${redshift(..._args)}
68
+ END)`.trim();
69
+ }
70
+ }
71
+ //# sourceMappingURL=ifs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ifs.js","sourceRoot":"","sources":["../../../src/functions/ifs.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAuB;IACnC,UAAU,EAAE,KAAK;IACjB,IAAI,EAAE,KAAK;IACX,gBAAgB,EAAE,CAAC;IACnB,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;KACJ;IACD,UAAU,EAAE;QACR,aAAa;QACb,SAAS;QACT,QAAQ;KACX;CACJ,CAAC;AAEF,SAAS,aAAa,CAAC,GAAG,IAAW;IACjC,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IACxB,MAAM,iBAAiB,GAAG,KAAK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export declare const functionList: FunctionList;
3
+ export declare const FUNCTION_LIST: string[];
4
+ export declare function getFunctionDetail(functionName: string): FunctionDefinition | undefined;