@qrvey/formula-lang 0.3.0 → 0.4.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 (126) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/__tests__/integration/__mocks__/context.ts +23 -0
  3. package/__tests__/integration/__mocks__/elasticsearchScripts.ts +11 -4
  4. package/__tests__/integration/__mocks__/sqlScripts.ts +3 -2
  5. package/__tests__/integration/elasticsearch.test.ts +17 -3
  6. package/__tests__/integration/expression.test.ts +34 -0
  7. package/__tests__/integration/redshift.test.ts +15 -0
  8. package/__tests__/integration/sonwflake.test.ts +15 -0
  9. package/dist/constants/interfaces.d.ts +8 -8
  10. package/dist/transpiler/columnTranspilation.d.ts +3 -0
  11. package/dist/transpiler/columnTranspilation.js +19 -0
  12. package/dist/transpiler/columnTranspilation.js.map +1 -0
  13. package/dist/transpiler/index.d.ts +3 -2
  14. package/dist/transpiler/index.js +6 -1
  15. package/dist/transpiler/index.js.map +1 -1
  16. package/dist/utils/getVariableType.d.ts +3 -3
  17. package/dist/utils/getVariableType.js.map +1 -1
  18. package/package.json +1 -1
  19. package/pkg/dist/constants/index.d.ts +0 -42
  20. package/pkg/dist/constants/index.js +0 -86
  21. package/pkg/dist/constants/index.js.map +0 -1
  22. package/pkg/dist/constants/interfaces.d.ts +0 -62
  23. package/pkg/dist/constants/interfaces.js +0 -2
  24. package/pkg/dist/constants/interfaces.js.map +0 -1
  25. package/pkg/dist/errors/definitions.d.ts +0 -26
  26. package/pkg/dist/errors/definitions.js +0 -42
  27. package/pkg/dist/errors/definitions.js.map +0 -1
  28. package/pkg/dist/errors/elasticsearch.d.ts +0 -24
  29. package/pkg/dist/errors/elasticsearch.js +0 -27
  30. package/pkg/dist/errors/elasticsearch.js.map +0 -1
  31. package/pkg/dist/errors/engineErrors.d.ts +0 -2
  32. package/pkg/dist/errors/engineErrors.js +0 -21
  33. package/pkg/dist/errors/engineErrors.js.map +0 -1
  34. package/pkg/dist/errors/index.d.ts +0 -2
  35. package/pkg/dist/errors/index.js +0 -5
  36. package/pkg/dist/errors/index.js.map +0 -1
  37. package/pkg/dist/errors/snowflake.d.ts +0 -15
  38. package/pkg/dist/errors/snowflake.js +0 -17
  39. package/pkg/dist/errors/snowflake.js.map +0 -1
  40. package/pkg/dist/functions/abs.d.ts +0 -5
  41. package/pkg/dist/functions/abs.js +0 -35
  42. package/pkg/dist/functions/abs.js.map +0 -1
  43. package/pkg/dist/functions/datedif.d.ts +0 -5
  44. package/pkg/dist/functions/datedif.js +0 -58
  45. package/pkg/dist/functions/datedif.js.map +0 -1
  46. package/pkg/dist/functions/day.d.ts +0 -5
  47. package/pkg/dist/functions/day.js +0 -36
  48. package/pkg/dist/functions/day.js.map +0 -1
  49. package/pkg/dist/functions/hour.d.ts +0 -5
  50. package/pkg/dist/functions/hour.js +0 -36
  51. package/pkg/dist/functions/hour.js.map +0 -1
  52. package/pkg/dist/functions/if.d.ts +0 -5
  53. package/pkg/dist/functions/if.js +0 -49
  54. package/pkg/dist/functions/if.js.map +0 -1
  55. package/pkg/dist/functions/ifs.d.ts +0 -5
  56. package/pkg/dist/functions/ifs.js +0 -71
  57. package/pkg/dist/functions/ifs.js.map +0 -1
  58. package/pkg/dist/functions/index.d.ts +0 -4
  59. package/pkg/dist/functions/index.js +0 -29
  60. package/pkg/dist/functions/index.js.map +0 -1
  61. package/pkg/dist/functions/mid.d.ts +0 -5
  62. package/pkg/dist/functions/mid.js +0 -51
  63. package/pkg/dist/functions/mid.js.map +0 -1
  64. package/pkg/dist/functions/minute.d.ts +0 -5
  65. package/pkg/dist/functions/minute.js +0 -36
  66. package/pkg/dist/functions/minute.js.map +0 -1
  67. package/pkg/dist/functions/month.d.ts +0 -5
  68. package/pkg/dist/functions/month.js +0 -36
  69. package/pkg/dist/functions/month.js.map +0 -1
  70. package/pkg/dist/functions/second.d.ts +0 -5
  71. package/pkg/dist/functions/second.js +0 -36
  72. package/pkg/dist/functions/second.js.map +0 -1
  73. package/pkg/dist/functions/year.d.ts +0 -5
  74. package/pkg/dist/functions/year.js +0 -36
  75. package/pkg/dist/functions/year.js.map +0 -1
  76. package/pkg/dist/grammar/generated/qformula.lang.js +0 -43
  77. package/pkg/dist/grammar/generated/qformula.lang.js.map +0 -1
  78. package/pkg/dist/grammar/qformula.grammar.d.ts +0 -1
  79. package/pkg/dist/grammar/qformula.grammar.js +0 -2
  80. package/pkg/dist/grammar/qformula.grammar.js.map +0 -1
  81. package/pkg/dist/index.js +0 -29
  82. package/pkg/dist/index.js.map +0 -1
  83. package/pkg/dist/parser/json-parser.js +0 -139
  84. package/pkg/dist/parser/json-parser.js.map +0 -1
  85. package/pkg/dist/transpiler/index.d.ts +0 -17
  86. package/pkg/dist/transpiler/index.js +0 -82
  87. package/pkg/dist/transpiler/index.js.map +0 -1
  88. package/pkg/dist/transpiler/validateFuncStructure.d.ts +0 -2
  89. package/pkg/dist/transpiler/validateFuncStructure.js +0 -35
  90. package/pkg/dist/transpiler/validateFuncStructure.js.map +0 -1
  91. package/pkg/dist/utils/customFunctions.d.ts +0 -2
  92. package/pkg/dist/utils/customFunctions.js +0 -11
  93. package/pkg/dist/utils/customFunctions.js.map +0 -1
  94. package/pkg/dist/utils/elasticsearch/index.d.ts +0 -1
  95. package/pkg/dist/utils/elasticsearch/index.js +0 -15
  96. package/pkg/dist/utils/elasticsearch/index.js.map +0 -1
  97. package/pkg/dist/utils/elasticsearch/scripts.d.ts +0 -9
  98. package/pkg/dist/utils/elasticsearch/scripts.js +0 -33
  99. package/pkg/dist/utils/elasticsearch/scripts.js.map +0 -1
  100. package/pkg/dist/utils/getMonthMaxDayAllowed.d.ts +0 -7
  101. package/pkg/dist/utils/getMonthMaxDayAllowed.js +0 -22
  102. package/pkg/dist/utils/getMonthMaxDayAllowed.js.map +0 -1
  103. package/pkg/dist/utils/getNodeValue.d.ts +0 -2
  104. package/pkg/dist/utils/getNodeValue.js +0 -9
  105. package/pkg/dist/utils/getNodeValue.js.map +0 -1
  106. package/pkg/dist/utils/index.d.ts +0 -8
  107. package/pkg/dist/utils/index.js +0 -9
  108. package/pkg/dist/utils/index.js.map +0 -1
  109. package/pkg/dist/utils/isDateParam.d.ts +0 -2
  110. package/pkg/dist/utils/isDateParam.js +0 -10
  111. package/pkg/dist/utils/isDateParam.js.map +0 -1
  112. package/pkg/dist/utils/isNumberParam.d.ts +0 -2
  113. package/pkg/dist/utils/isNumberParam.js +0 -8
  114. package/pkg/dist/utils/isNumberParam.js.map +0 -1
  115. package/pkg/dist/utils/isPositiveNumberParam.d.ts +0 -2
  116. package/pkg/dist/utils/isPositiveNumberParam.js +0 -8
  117. package/pkg/dist/utils/isPositiveNumberParam.js.map +0 -1
  118. package/pkg/dist/utils/isStringParam.d.ts +0 -2
  119. package/pkg/dist/utils/isStringParam.js +0 -8
  120. package/pkg/dist/utils/isStringParam.js.map +0 -1
  121. package/pkg/dist/utils/isValidDate.d.ts +0 -1
  122. package/pkg/dist/utils/isValidDate.js +0 -4
  123. package/pkg/dist/utils/isValidDate.js.map +0 -1
  124. package/pkg/dist/utils/sql/scripts.d.ts +0 -2
  125. package/pkg/dist/utils/sql/scripts.js +0 -39
  126. package/pkg/dist/utils/sql/scripts.js.map +0 -1
@@ -1,9 +0,0 @@
1
- import { DateDifUnitParam } from '../../constants/interfaces';
2
- export declare const dateFormatScript: string;
3
- export declare const dayScript: (value: any) => string;
4
- export declare const monthScript: (value: any) => string;
5
- export declare const yearScript: (value: any) => string;
6
- export declare const hourScript: (value: any) => string;
7
- export declare const minuteScript: (value: any) => string;
8
- export declare const secondScript: (value: any) => string;
9
- export declare function dateDif(start: any, end: any, unit: DateDifUnitParam): string;
@@ -1,33 +0,0 @@
1
- var SCRIPT_NAMES;
2
- (function (SCRIPT_NAMES) {
3
- SCRIPT_NAMES["dateFormat"] = "DATE_FORMAT_SCRIPT";
4
- })(SCRIPT_NAMES || (SCRIPT_NAMES = {}));
5
- export const dateFormatScript = `
6
- String ${SCRIPT_NAMES.dateFormat}(def date_value, String format) {
7
- def isCustomDate = (date_value instanceof JodaCompatibleZonedDateTime || date_value instanceof ZonedDateTime);
8
- if (date_value instanceof List && !isCustomDate) {
9
- if (date_value.empty) return null;
10
- date_value = date_value.value;
11
- }
12
- return DateTimeFormatter.ofPattern(format).format(date_value)
13
- }
14
- `;
15
- function dateFormatToInt(value, format) {
16
- return `Integer.parseInt(${SCRIPT_NAMES.dateFormat}(${value}, '${format}'))`;
17
- }
18
- export const dayScript = (value) => dateFormatToInt(value, 'dd');
19
- export const monthScript = (value) => dateFormatToInt(value, 'MM');
20
- export const yearScript = (value) => dateFormatToInt(value, 'yyyy');
21
- export const hourScript = (value) => dateFormatToInt(value, 'HH');
22
- export const minuteScript = (value) => dateFormatToInt(value, 'mm');
23
- export const secondScript = (value) => dateFormatToInt(value, 'ss');
24
- export function dateDif(start, end, unit) {
25
- const units = {
26
- Y: 'YEARS',
27
- M: 'MONTHS',
28
- D: 'DAYS',
29
- };
30
- const currentUnit = units[unit];
31
- return `ChronoUnit.${currentUnit}.between(${start}, ${end})`;
32
- }
33
- //# sourceMappingURL=scripts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scripts.js","sourceRoot":"","sources":["../../../../src/utils/elasticsearch/scripts.ts"],"names":[],"mappings":"AAEA,IAAK,YAEJ;AAFD,WAAK,YAAY;IACb,iDAAiC,CAAA;AACrC,CAAC,EAFI,YAAY,KAAZ,YAAY,QAEhB;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;SACvB,YAAY,CAAC,UAAU;;;;;;;;CAQ/B,CAAC;AAEF,SAAS,eAAe,CAAC,KAAU,EAAE,MAAc;IAC/C,OAAO,oBAAoB,YAAY,CAAC,UAAU,IAAI,KAAK,MAAM,MAAM,KAAK,CAAC;AACjF,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAEtE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAExE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAEzE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAEvE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAEzE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAEzE,MAAM,UAAU,OAAO,CAAC,KAAU,EAAE,GAAQ,EAAE,IAAsB;IAChE,MAAM,KAAK,GAAG;QACV,CAAC,EAAE,OAAO;QACV,CAAC,EAAE,QAAQ;QACX,CAAC,EAAE,MAAM;KACZ,CAAC;IACF,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,cAAc,WAAW,YAAY,KAAK,KAAK,GAAG,GAAG,CAAC;AACjE,CAAC"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Gets the max number of days allowed for a date
3
- * @param month 0 index month of the year
4
- * @param year year of a date
5
- * @returns number with the max number allowed. -1 if month does not exist in array list
6
- */
7
- export declare function getMonthMaxDayAllowed(month: number, year: number): number;
@@ -1,22 +0,0 @@
1
- function isLeapYear(year) {
2
- return year % 4 === 0 && year % 100 !== 0;
3
- }
4
- const MONTH_MAX_DAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
5
- /**
6
- * Gets the max number of days allowed for a date
7
- * @param month 0 index month of the year
8
- * @param year year of a date
9
- * @returns number with the max number allowed. -1 if month does not exist in array list
10
- */
11
- export function getMonthMaxDayAllowed(month, year) {
12
- if (month > 11 || month < 0)
13
- return -1;
14
- if (month === 1) {
15
- // case for february
16
- return isLeapYear(year) ? 29 : MONTH_MAX_DAYS[month];
17
- }
18
- else {
19
- return MONTH_MAX_DAYS[month];
20
- }
21
- }
22
- //# sourceMappingURL=getMonthMaxDayAllowed.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getMonthMaxDayAllowed.js","sourceRoot":"","sources":["../../../src/utils/getMonthMaxDayAllowed.ts"],"names":[],"mappings":"AAAA,SAAS,UAAU,CAAC,IAAY;IAC5B,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,GAAG,KAAK,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,cAAc,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAExE;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAa,EAAE,IAAY;IAC7D,IAAI,KAAK,GAAG,EAAE,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC;IACvC,IAAI,KAAK,KAAK,CAAC,EAAE;QACb,oBAAoB;QACpB,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;KACxD;SAAM;QACH,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;KAChC;AACL,CAAC"}
@@ -1,2 +0,0 @@
1
- import { SyntaxNode } from '@lezer/common';
2
- export declare function getNodeValue(str: string, node: SyntaxNode): string;
@@ -1,9 +0,0 @@
1
- export function getNodeValue(str, node) {
2
- if (!str || !node)
3
- return '';
4
- return sliceNodeValue(str, node);
5
- }
6
- function sliceNodeValue(str, { from, to }) {
7
- return str.slice(from, to);
8
- }
9
- //# sourceMappingURL=getNodeValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getNodeValue.js","sourceRoot":"","sources":["../../../src/utils/getNodeValue.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,IAAgB;IACtD,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IAC7B,OAAO,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,cAAc,CACnB,GAAW,EACX,EAAE,IAAI,EAAE,EAAE,EAAgC;IAE1C,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAC/B,CAAC"}
@@ -1,8 +0,0 @@
1
- export * from './getNodeValue';
2
- export * from './customFunctions';
3
- export * from './isNumberParam';
4
- export * from './isPositiveNumberParam';
5
- export * from './isStringParam';
6
- export * from './isDateParam';
7
- export * from './isValidDate';
8
- export * from './getMonthMaxDayAllowed';
@@ -1,9 +0,0 @@
1
- export * from './getNodeValue';
2
- export * from './customFunctions';
3
- export * from './isNumberParam';
4
- export * from './isPositiveNumberParam';
5
- export * from './isStringParam';
6
- export * from './isDateParam';
7
- export * from './isValidDate';
8
- export * from './getMonthMaxDayAllowed';
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC"}
@@ -1,2 +0,0 @@
1
- import { ValidatorResponse } from '../constants/interfaces';
2
- export declare function isDateParam(param: any): ValidatorResponse;
@@ -1,10 +0,0 @@
1
- import { ERROR_LIST, ERROR_DICTIONARY } from '../constants';
2
- import { isValidDate } from '.';
3
- export function isDateParam(param) {
4
- const dateValue = new Date(param);
5
- const valid = isValidDate(dateValue);
6
- if (!valid)
7
- return Object.assign({ valid }, ERROR_DICTIONARY[ERROR_LIST.missingDate]);
8
- return { valid };
9
- }
10
- //# sourceMappingURL=isDateParam.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isDateParam.js","sourceRoot":"","sources":["../../../src/utils/isDateParam.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,CAAC;AAEhC,MAAM,UAAU,WAAW,CAAC,KAAU;IAClC,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,CAAC,KAAK;QAAE,uBAAS,KAAK,IAAK,gBAAgB,CAAC,UAAU,CAAC,WAAW,CAAC,EAAG;IAC1E,OAAO,EAAE,KAAK,EAAE,CAAC;AACrB,CAAC"}
@@ -1,2 +0,0 @@
1
- import { ValidatorResponse } from '../constants/interfaces';
2
- export declare function isNumberParam(param: any): ValidatorResponse;
@@ -1,8 +0,0 @@
1
- import { ERROR_LIST, ERROR_DICTIONARY } from '../constants';
2
- export function isNumberParam(param) {
3
- const valid = typeof param === 'number';
4
- if (!valid)
5
- return Object.assign({ valid }, ERROR_DICTIONARY[ERROR_LIST.missingNumber]);
6
- return { valid };
7
- }
8
- //# sourceMappingURL=isNumberParam.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isNumberParam.js","sourceRoot":"","sources":["../../../src/utils/isNumberParam.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAG5D,MAAM,UAAU,aAAa,CAAC,KAAU;IACpC,MAAM,KAAK,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC;IACxC,IAAI,CAAC,KAAK;QAAE,uBAAS,KAAK,IAAK,gBAAgB,CAAC,UAAU,CAAC,aAAa,CAAC,EAAG;IAC5E,OAAO,EAAE,KAAK,EAAE,CAAC;AACrB,CAAC"}
@@ -1,2 +0,0 @@
1
- import { ValidatorResponse } from '../constants/interfaces';
2
- export declare function isPositiveNumberParam(param: any): ValidatorResponse;
@@ -1,8 +0,0 @@
1
- import { ERROR_LIST, ERROR_DICTIONARY } from '../constants';
2
- export function isPositiveNumberParam(param) {
3
- const valid = param >= 0;
4
- if (!valid)
5
- return Object.assign({ valid }, ERROR_DICTIONARY[ERROR_LIST.greaterThanZero]);
6
- return { valid };
7
- }
8
- //# sourceMappingURL=isPositiveNumberParam.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isPositiveNumberParam.js","sourceRoot":"","sources":["../../../src/utils/isPositiveNumberParam.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAG5D,MAAM,UAAU,qBAAqB,CAAC,KAAU;IAC5C,MAAM,KAAK,GAAG,KAAK,IAAI,CAAC,CAAC;IACzB,IAAI,CAAC,KAAK;QACN,uBAAS,KAAK,IAAK,gBAAgB,CAAC,UAAU,CAAC,eAAe,CAAC,EAAG;IACtE,OAAO,EAAE,KAAK,EAAE,CAAC;AACrB,CAAC"}
@@ -1,2 +0,0 @@
1
- import { ValidatorResponse } from '../constants/interfaces';
2
- export declare function isStringParam(param: any): ValidatorResponse;
@@ -1,8 +0,0 @@
1
- import { ERROR_LIST, ERROR_DICTIONARY } from '../constants';
2
- export function isStringParam(param) {
3
- const valid = typeof param === 'string';
4
- if (!valid)
5
- return Object.assign({ valid }, ERROR_DICTIONARY[ERROR_LIST.missingString]);
6
- return { valid };
7
- }
8
- //# sourceMappingURL=isStringParam.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isStringParam.js","sourceRoot":"","sources":["../../../src/utils/isStringParam.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAG5D,MAAM,UAAU,aAAa,CAAC,KAAU;IACpC,MAAM,KAAK,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC;IACxC,IAAI,CAAC,KAAK;QAAE,uBAAS,KAAK,IAAK,gBAAgB,CAAC,UAAU,CAAC,aAAa,CAAC,EAAG;IAC5E,OAAO,EAAE,KAAK,EAAE,CAAC;AACrB,CAAC"}
@@ -1 +0,0 @@
1
- export declare function isValidDate(d: unknown): boolean;
@@ -1,4 +0,0 @@
1
- export function isValidDate(d) {
2
- return !isNaN(d) && d instanceof Date;
3
- }
4
- //# sourceMappingURL=isValidDate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isValidDate.js","sourceRoot":"","sources":["../../../src/utils/isValidDate.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAC,CAAU;IAClC,OAAO,CAAC,KAAK,CAAC,CAAW,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC;AACpD,CAAC"}
@@ -1,2 +0,0 @@
1
- import { DateDifUnitParam } from '../../constants/interfaces';
2
- export declare function dateDif(start: string, end: string, unit: DateDifUnitParam): string;
@@ -1,39 +0,0 @@
1
- function datePart(value, format) {
2
- return `DATE_PART('${format}', ${value})`;
3
- }
4
- function toDate(value, format = 'MM/DD/YYYY') {
5
- return `TO_DATE(${value}, '${format}')`;
6
- }
7
- function generalDateDif(start, end, unit) {
8
- const units = {
9
- Y: 'year',
10
- M: 'month',
11
- D: 'day',
12
- };
13
- const currentUnit = units[unit];
14
- return `DATEDIFF('${currentUnit}', ${start}, ${end})`;
15
- }
16
- function customDateDifYear(start, end) {
17
- const month = datePart('month', end);
18
- const day = datePart('day', end);
19
- const year = datePart('year', start);
20
- const parts = [month, day, year].join(`|| '/' ||`);
21
- const customDate = toDate(parts);
22
- const dateDifToCompare = generalDateDif(start, customDate, 'D');
23
- const dateDifYear = generalDateDif(start, end, 'Y');
24
- const result = `CASE
25
- WHEN ${dateDifToCompare} >= 0
26
- THEN ${dateDifYear}
27
- ELSE ${dateDifYear} - 1
28
- END`;
29
- return result;
30
- }
31
- export function dateDif(start, end, unit) {
32
- const units = {
33
- Y: customDateDifYear,
34
- M: generalDateDif,
35
- D: generalDateDif,
36
- };
37
- return units[unit](start, end, unit);
38
- }
39
- //# sourceMappingURL=scripts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scripts.js","sourceRoot":"","sources":["../../../../src/utils/sql/scripts.ts"],"names":[],"mappings":"AAEA,SAAS,QAAQ,CAAC,KAAa,EAAE,MAAc;IAC3C,OAAO,cAAc,MAAM,MAAM,KAAK,GAAG,CAAC;AAC9C,CAAC;AAED,SAAS,MAAM,CAAC,KAAa,EAAE,MAAM,GAAG,YAAY;IAChD,OAAO,WAAW,KAAK,MAAM,MAAM,IAAI,CAAC;AAC5C,CAAC;AAED,SAAS,cAAc,CAAC,KAAa,EAAE,GAAW,EAAE,IAAsB;IACtE,MAAM,KAAK,GAAG;QACV,CAAC,EAAE,MAAM;QACT,CAAC,EAAE,OAAO;QACV,CAAC,EAAE,KAAK;KACX,CAAC;IACF,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,aAAa,WAAW,MAAM,KAAK,KAAK,GAAG,GAAG,CAAC;AAC1D,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAa,EAAE,GAAW;IACjD,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACjC,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACnD,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,gBAAgB,GAAG,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;IAChE,MAAM,WAAW,GAAG,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG;eACJ,gBAAgB;mBACZ,WAAW;eACf,WAAW;QAClB,CAAC;IACL,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAa,EAAE,GAAW,EAAE,IAAsB;IACtE,MAAM,KAAK,GAAG;QACV,CAAC,EAAE,iBAAiB;QACpB,CAAC,EAAE,cAAc;QACjB,CAAC,EAAE,cAAc;KACpB,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC"}