dsl-to-sql 1.0.0-fabric-1p-development.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +9 -0
- package/.turbo/turbo-check-types.log +4 -0
- package/.turbo/turbo-lint.log +126 -0
- package/README.md +45 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +236 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/coverage/src/constants.ts.html +826 -0
- package/coverage/src/database_types.ts.html +136 -0
- package/coverage/src/epm-query-builder/EpmQueryBuilder.ts.html +166 -0
- package/coverage/src/epm-query-builder/base/BaseAdvancedAggregations.ts.html +568 -0
- package/coverage/src/epm-query-builder/base/BaseAnalyticalFunctions.ts.html +694 -0
- package/coverage/src/epm-query-builder/base/BaseCTEGenerator.ts.html +1459 -0
- package/coverage/src/epm-query-builder/base/BaseCountQueryBuilder.ts.html +400 -0
- package/coverage/src/epm-query-builder/base/BaseMeasureBuilder.ts.html +295 -0
- package/coverage/src/epm-query-builder/base/BaseOrderBuilder.ts.html +670 -0
- package/coverage/src/epm-query-builder/base/BasePaginationBuilder.ts.html +364 -0
- package/coverage/src/epm-query-builder/base/BaseQueryBuilder.ts.html +238 -0
- package/coverage/src/epm-query-builder/base/BaseRollupBuilder.ts.html +532 -0
- package/coverage/src/epm-query-builder/base/BaseSqlBuilder.ts.html +601 -0
- package/coverage/src/epm-query-builder/base/BaseSuperFilterBuilder.ts.html +1966 -0
- package/coverage/src/epm-query-builder/base/BaseUtilities.ts.html +1798 -0
- package/coverage/src/epm-query-builder/base/ColumnRefUtils.ts.html +211 -0
- package/coverage/src/epm-query-builder/base/RelationshipResolver.ts.html +706 -0
- package/coverage/src/epm-query-builder/base/SharedFilterBuilder.ts.html +1717 -0
- package/coverage/src/epm-query-builder/base/index.html +326 -0
- package/coverage/src/epm-query-builder/constants/Aggregations.ts.html +133 -0
- package/coverage/src/epm-query-builder/constants/Database.ts.html +103 -0
- package/coverage/src/epm-query-builder/constants/Source.ts.html +106 -0
- package/coverage/src/epm-query-builder/constants/index.html +146 -0
- package/coverage/src/epm-query-builder/dialects/duckdb/DuckDbAdvancedAggregations.ts.html +286 -0
- package/coverage/src/epm-query-builder/dialects/duckdb/DuckDbJoinBuilder.ts.html +280 -0
- package/coverage/src/epm-query-builder/dialects/duckdb/DuckDbMeasureBuilder.ts.html +1924 -0
- package/coverage/src/epm-query-builder/dialects/duckdb/DuckDbOrderBuilder.ts.html +769 -0
- package/coverage/src/epm-query-builder/dialects/duckdb/DuckDbPaginationBuilder.ts.html +643 -0
- package/coverage/src/epm-query-builder/dialects/duckdb/DuckDbQueryBuilder.ts.html +2644 -0
- package/coverage/src/epm-query-builder/dialects/duckdb/DuckDbRollupBuilder.ts.html +478 -0
- package/coverage/src/epm-query-builder/dialects/duckdb/DuckDbSuperFilterBuilder.ts.html +1195 -0
- package/coverage/src/epm-query-builder/dialects/duckdb/index.html +221 -0
- package/coverage/src/epm-query-builder/errors/QueryBuilderErrors.ts.html +280 -0
- package/coverage/src/epm-query-builder/errors/index.html +116 -0
- package/coverage/src/epm-query-builder/index.html +116 -0
- package/coverage/src/epm-query-builder/interfaces/IDatabaseQueryBuilder.ts.html +100 -0
- package/coverage/src/epm-query-builder/interfaces/index.html +131 -0
- package/coverage/src/epm-query-builder/interfaces/index.ts.html +88 -0
- package/coverage/src/epm-query-builder/utils/format.ts.html +151 -0
- package/coverage/src/epm-query-builder/utils/index.html +146 -0
- package/coverage/src/epm-query-builder/utils/sql.ts.html +247 -0
- package/coverage/src/epm-query-builder/utils/validation.ts.html +124 -0
- package/coverage/src/epm-query-builder/validation/QueryOptionsValidator.ts.html +631 -0
- package/coverage/src/epm-query-builder/validation/SqlQueryValidator.ts.html +475 -0
- package/coverage/src/epm-query-builder/validation/index.html +131 -0
- package/coverage/src/filters/FilterConditionBuilder.ts.html +427 -0
- package/coverage/src/filters/filter-types.ts.html +484 -0
- package/coverage/src/filters/index.html +131 -0
- package/coverage/src/index.html +176 -0
- package/coverage/src/index.ts.html +103 -0
- package/coverage/src/js-lib/JsToSqlParser.ts.html +736 -0
- package/coverage/src/js-lib/ParseContext.ts.html +532 -0
- package/coverage/src/js-lib/db/azuresql/AzureSqlCallExpressionVisitor.ts.html +196 -0
- package/coverage/src/js-lib/db/azuresql/index.html +116 -0
- package/coverage/src/js-lib/db/base/ArrayExpressionVisitor.ts.html +133 -0
- package/coverage/src/js-lib/db/base/AssignmentExpressionVisitor.ts.html +187 -0
- package/coverage/src/js-lib/db/base/BinaryExpressionVisitor.ts.html +223 -0
- package/coverage/src/js-lib/db/base/CallExpressionVisitor.ts.html +5479 -0
- package/coverage/src/js-lib/db/base/IdentifierVisitor.ts.html +283 -0
- package/coverage/src/js-lib/db/base/LiteralVisitor.ts.html +199 -0
- package/coverage/src/js-lib/db/base/MemberExpressionVisitor.ts.html +193 -0
- package/coverage/src/js-lib/db/base/ProgramVisitor.ts.html +139 -0
- package/coverage/src/js-lib/db/base/UnaryExpressionVisitor.ts.html +181 -0
- package/coverage/src/js-lib/db/base/VisitorInterface.ts.html +103 -0
- package/coverage/src/js-lib/db/base/index.html +251 -0
- package/coverage/src/js-lib/db/bigquery/BigQueryCallExpressionVisitor.ts.html +1747 -0
- package/coverage/src/js-lib/db/bigquery/index.html +116 -0
- package/coverage/src/js-lib/db/commonTransforms.ts.html +2074 -0
- package/coverage/src/js-lib/db/databricks/DatabricksCallExpressionVisitor.ts.html +1303 -0
- package/coverage/src/js-lib/db/databricks/index.html +116 -0
- package/coverage/src/js-lib/db/fabricsql/FabricSqlCallExpressionVisitor.ts.html +196 -0
- package/coverage/src/js-lib/db/fabricsql/index.html +116 -0
- package/coverage/src/js-lib/db/fabricwarehouse/FabricWarehouseCallExpressionVisitor.ts.html +292 -0
- package/coverage/src/js-lib/db/fabricwarehouse/index.html +116 -0
- package/coverage/src/js-lib/db/index.html +116 -0
- package/coverage/src/js-lib/db/postgresql/PostgreSqlCallExpressionVisitor.ts.html +985 -0
- package/coverage/src/js-lib/db/postgresql/index.html +116 -0
- package/coverage/src/js-lib/db/redshift/RedshiftCallExpressionVisitor.ts.html +685 -0
- package/coverage/src/js-lib/db/redshift/index.html +116 -0
- package/coverage/src/js-lib/db/sample/SampleCallExpressionVisitor.ts.html +196 -0
- package/coverage/src/js-lib/db/sample/index.html +116 -0
- package/coverage/src/js-lib/db/snowflake/SnowflakeCallExpressionVisitor.ts.html +1447 -0
- package/coverage/src/js-lib/db/snowflake/index.html +116 -0
- package/coverage/src/js-lib/db/validator/FormulaValidator.ts.html +4162 -0
- package/coverage/src/js-lib/db/validator/index.html +116 -0
- package/coverage/src/js-lib/index.html +131 -0
- package/coverage/src/js-lib/objects/BaseObject.ts.html +169 -0
- package/coverage/src/js-lib/objects/DateObject.ts.html +169 -0
- package/coverage/src/js-lib/objects/PctObject.ts.html +178 -0
- package/coverage/src/js-lib/objects/index.html +146 -0
- package/coverage/src/query-builder/PaginationBuilder.ts.html +142 -0
- package/coverage/src/query-builder/QueryBuilder.ts.html +3118 -0
- package/coverage/src/query-builder/SuperFilterBuilder.ts.html +1969 -0
- package/coverage/src/query-builder/index.html +146 -0
- package/coverage/src/runtime_var.ts.html +109 -0
- package/coverage/src/sql-lib/binary_expr.ts.html +133 -0
- package/coverage/src/sql-lib/case.ts.html +133 -0
- package/coverage/src/sql-lib/column.ts.html +139 -0
- package/coverage/src/sql-lib/else.ts.html +124 -0
- package/coverage/src/sql-lib/function.ts.html +112 -0
- package/coverage/src/sql-lib/index.html +251 -0
- package/coverage/src/sql-lib/join.ts.html +127 -0
- package/coverage/src/sql-lib/literal.ts.html +130 -0
- package/coverage/src/sql-lib/select.ts.html +547 -0
- package/coverage/src/sql-lib/unary_expr.ts.html +112 -0
- package/coverage/src/sql-lib/when.ts.html +130 -0
- package/coverage/src/sql_query_gen.ts.html +535 -0
- package/coverage/src/superFilter/DateFilterFactory.ts.html +625 -0
- package/coverage/src/superFilter/dateFunction.ts.html +193 -0
- package/coverage/src/superFilter/index.html +131 -0
- package/coverage/src/utils.ts.html +571 -0
- package/dist/index.cjs +8440 -0
- package/dist/index.d.cts +927 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +927 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8387 -0
- package/dist/index.js.map +1 -0
- package/eslint.config.js +4 -0
- package/jest.config.ts +44 -0
- package/package.json +45 -0
- package/src/constants.ts +247 -0
- package/src/epm-query-builder/EpmQueryBuilder.ts +27 -0
- package/src/epm-query-builder/base/BaseAdvancedAggregations.ts +161 -0
- package/src/epm-query-builder/base/BaseAnalyticalFunctions.ts +203 -0
- package/src/epm-query-builder/base/BaseCTEGenerator.ts +458 -0
- package/src/epm-query-builder/base/BaseCountQueryBuilder.ts +105 -0
- package/src/epm-query-builder/base/BaseMeasureBuilder.ts +87 -0
- package/src/epm-query-builder/base/BaseOrderBuilder.ts +195 -0
- package/src/epm-query-builder/base/BasePaginationBuilder.ts +93 -0
- package/src/epm-query-builder/base/BaseQueryBuilder.ts +51 -0
- package/src/epm-query-builder/base/BaseRollupBuilder.ts +149 -0
- package/src/epm-query-builder/base/BaseSqlBuilder.ts +172 -0
- package/src/epm-query-builder/base/BaseSuperFilterBuilder.ts +627 -0
- package/src/epm-query-builder/base/BaseUtilities.ts +571 -0
- package/src/epm-query-builder/base/ColumnRefUtils.ts +42 -0
- package/src/epm-query-builder/base/RelationshipResolver.ts +207 -0
- package/src/epm-query-builder/base/SharedFilterBuilder.ts +544 -0
- package/src/epm-query-builder/constants/Aggregations.ts +16 -0
- package/src/epm-query-builder/constants/Database.ts +6 -0
- package/src/epm-query-builder/constants/Source.ts +7 -0
- package/src/epm-query-builder/dialects/duckdb/DuckDbAdvancedAggregations.ts +67 -0
- package/src/epm-query-builder/dialects/duckdb/DuckDbJoinBuilder.ts +65 -0
- package/src/epm-query-builder/dialects/duckdb/DuckDbMeasureBuilder.ts +626 -0
- package/src/epm-query-builder/dialects/duckdb/DuckDbOrderBuilder.ts +228 -0
- package/src/epm-query-builder/dialects/duckdb/DuckDbPaginationBuilder.ts +186 -0
- package/src/epm-query-builder/dialects/duckdb/DuckDbQueryBuilder.ts +853 -0
- package/src/epm-query-builder/dialects/duckdb/DuckDbRollupBuilder.ts +131 -0
- package/src/epm-query-builder/dialects/duckdb/DuckDbSuperFilterBuilder.ts +370 -0
- package/src/epm-query-builder/errors/QueryBuilderErrors.ts +65 -0
- package/src/epm-query-builder/interfaces/IDatabaseQueryBuilder.ts +5 -0
- package/src/epm-query-builder/interfaces/index.ts +1 -0
- package/src/epm-query-builder/types/query-builder-types.d.ts +289 -0
- package/src/epm-query-builder/utils/format.ts +22 -0
- package/src/epm-query-builder/utils/sql.ts +54 -0
- package/src/epm-query-builder/utils/validation.ts +13 -0
- package/src/epm-query-builder/validation/QueryOptionsValidator.ts +182 -0
- package/src/epm-query-builder/validation/SqlQueryValidator.ts +130 -0
- package/src/filters/FilterConditionBuilder.ts +114 -0
- package/src/filters/filter-types.ts +133 -0
- package/src/index.ts +10 -0
- package/src/js-lib/JsToSqlParser.ts +217 -0
- package/src/js-lib/ParseContext.ts +149 -0
- package/src/js-lib/db/base/ArrayExpressionVisitor.ts +16 -0
- package/src/js-lib/db/base/AssignmentExpressionVisitor.ts +34 -0
- package/src/js-lib/db/base/BinaryExpressionVisitor.ts +46 -0
- package/src/js-lib/db/base/CallExpressionVisitor.ts +1798 -0
- package/src/js-lib/db/base/IdentifierVisitor.ts +66 -0
- package/src/js-lib/db/base/LiteralVisitor.ts +38 -0
- package/src/js-lib/db/base/MemberExpressionVisitor.ts +36 -0
- package/src/js-lib/db/base/ProgramVisitor.ts +18 -0
- package/src/js-lib/db/base/UnaryExpressionVisitor.ts +32 -0
- package/src/js-lib/db/base/VisitorInterface.ts +6 -0
- package/src/js-lib/db/validator/FormulaValidator.ts +1235 -0
- package/src/js-lib/objects/BaseObject.ts +28 -0
- package/src/js-lib/objects/DateObject.ts +28 -0
- package/src/js-lib/objects/PctObject.ts +31 -0
- package/src/query-builder/PaginationBuilder.ts +19 -0
- package/src/query-builder/QueryBuilder.ts +1035 -0
- package/src/query-builder/SuperFilterBuilder.ts +628 -0
- package/src/runtime_var.ts +8 -0
- package/src/sql-lib/binary_expr.ts +16 -0
- package/src/sql-lib/case.ts +16 -0
- package/src/sql-lib/column.ts +18 -0
- package/src/sql-lib/else.ts +13 -0
- package/src/sql-lib/function.ts +9 -0
- package/src/sql-lib/join.ts +14 -0
- package/src/sql-lib/literal.ts +15 -0
- package/src/sql-lib/select.ts +154 -0
- package/src/sql-lib/unary_expr.ts +9 -0
- package/src/sql-lib/when.ts +15 -0
- package/src/sql-types.d.ts +565 -0
- package/src/sql_query_gen.ts +150 -0
- package/src/superFilter/DateFilterFactory.ts +180 -0
- package/src/superFilter/dateFunction.ts +36 -0
- package/src/utils.ts +354 -0
- package/test-output/report/junit.xml +329 -0
- package/tests/JsToSqlParser.test.ts +163 -0
- package/tests/QueryBuilder.test.ts +1320 -0
- package/tests/js-lib/CallExpressionVisitor.test.ts +820 -0
- package/tests/mocks/MockQueryResolver.ts +14 -0
- package/tests/sanity.test.ts +146 -0
- package/tests/sql-lib/binary_expr.test.ts +75 -0
- package/tests/sql-lib/case.test.ts +117 -0
- package/tests/sql-lib/column.test.ts +87 -0
- package/tests/sql-lib/else.test.ts +56 -0
- package/tests/sql-lib/function.test.ts +96 -0
- package/tests/sql-lib/literal.test.ts +75 -0
- package/tests/sql-lib/select.test.ts +245 -0
- package/tests/sql-lib/unary_expr.test.ts +32 -0
- package/tests/utils.test.ts +13 -0
- package/tsconfig.json +24 -0
- package/tsdown.config.ts +23 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,927 @@
|
|
|
1
|
+
import * as acorn from "acorn";
|
|
2
|
+
|
|
3
|
+
//#region src/js-lib/ParseContext.d.ts
|
|
4
|
+
declare enum MDM_COLUMN_TYPE {
|
|
5
|
+
TEXT = 1,
|
|
6
|
+
SINGLE_SELECT = 2,
|
|
7
|
+
MULTI_SELECT = 3,
|
|
8
|
+
DATE = 4,
|
|
9
|
+
COMMENTS = 5,
|
|
10
|
+
NUMBER = 6,
|
|
11
|
+
PERSON = 7,
|
|
12
|
+
TIME = 8,
|
|
13
|
+
LAST_UPDATED_BY = 9,
|
|
14
|
+
LAST_UPDATED_AT = 10,
|
|
15
|
+
CHECKBOX = 11,
|
|
16
|
+
DATETIME = 12,
|
|
17
|
+
DECIMAL = 13,
|
|
18
|
+
IMAGE = 14,
|
|
19
|
+
URL = 15,
|
|
20
|
+
EMAIL = 16,
|
|
21
|
+
FORMULA = 17,
|
|
22
|
+
}
|
|
23
|
+
declare enum ResolvedExpressionType {
|
|
24
|
+
COLUMN = "columnExpr",
|
|
25
|
+
CTE = "cteExpr",
|
|
26
|
+
}
|
|
27
|
+
type CteExpression = {
|
|
28
|
+
type: ResolvedExpressionType.CTE;
|
|
29
|
+
cteName: string;
|
|
30
|
+
value: string[];
|
|
31
|
+
};
|
|
32
|
+
type ColumnExpression = {
|
|
33
|
+
type: ResolvedExpressionType.COLUMN;
|
|
34
|
+
value: string[];
|
|
35
|
+
};
|
|
36
|
+
type SqlQueryProps = {
|
|
37
|
+
resolvedExpression: ColumnExpression | CteExpression;
|
|
38
|
+
};
|
|
39
|
+
type ColumnMeta = {
|
|
40
|
+
sqlQueryProps?: SqlQueryProps;
|
|
41
|
+
computationOrder?: number;
|
|
42
|
+
deps?: string[];
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
};
|
|
45
|
+
interface IMDMColumnConfigWithParsedMeta {
|
|
46
|
+
columnName: string;
|
|
47
|
+
columnType: MDM_COLUMN_TYPE;
|
|
48
|
+
columnMeta: ColumnMeta;
|
|
49
|
+
}
|
|
50
|
+
type TColumnConfigMap = Record<string, IMDMColumnConfigWithParsedMeta>;
|
|
51
|
+
type ParseContextProps = {
|
|
52
|
+
columnConfigMap: TColumnConfigMap;
|
|
53
|
+
currentColumnId: string;
|
|
54
|
+
primaryKeyColumns: string[];
|
|
55
|
+
tableName: string;
|
|
56
|
+
};
|
|
57
|
+
declare class ParseContext {
|
|
58
|
+
private lastEvaluatedValue;
|
|
59
|
+
private _cteCount;
|
|
60
|
+
formulaIdColumnMap: Record<string, string>;
|
|
61
|
+
deprecatedFormulaColumnMap: Record<string, string>;
|
|
62
|
+
ifCondition: boolean;
|
|
63
|
+
private readonly columnDeps;
|
|
64
|
+
readonly state: Map<string, any>;
|
|
65
|
+
readonly columnConfigMap: TColumnConfigMap;
|
|
66
|
+
readonly currentColumnId: string;
|
|
67
|
+
readonly primaryKeyColumns: string[];
|
|
68
|
+
readonly tableName: string;
|
|
69
|
+
readonly entityNameFormatter: (name: string) => string;
|
|
70
|
+
returnType: string | undefined;
|
|
71
|
+
isValid: boolean;
|
|
72
|
+
error: string | undefined;
|
|
73
|
+
constructor(props: ParseContextProps);
|
|
74
|
+
/**
|
|
75
|
+
* Reset the parse context
|
|
76
|
+
*/
|
|
77
|
+
reset(): ParseContext;
|
|
78
|
+
get(node: acorn.Node): any;
|
|
79
|
+
set(node: acorn.Node, value: any): void;
|
|
80
|
+
getId(node: acorn.Node): string;
|
|
81
|
+
getLastEvaluatedValue(): any;
|
|
82
|
+
getColumnCount(): number;
|
|
83
|
+
addColumnDep(columnName: string): void;
|
|
84
|
+
getColumnDeps(): Set<string>;
|
|
85
|
+
get cteCount(): number;
|
|
86
|
+
incrementCTECount(): void;
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/query-builder/SuperFilterBuilder.d.ts
|
|
90
|
+
declare enum EDateRangeRelativeFilterCondition {
|
|
91
|
+
IS_IN_THE_LAST = "IS_IN_THE_LAST",
|
|
92
|
+
IS_IN_THIS = "IS_IN_THIS",
|
|
93
|
+
IS_IN_THE_NEXT = "IS_IN_THE_NEXT",
|
|
94
|
+
}
|
|
95
|
+
declare enum EDateRangeRelativePeriodFilterCondition {
|
|
96
|
+
DAYS = "DAYS",
|
|
97
|
+
WEEKS = "WEEKS",
|
|
98
|
+
CALENDER_WEEKS = "CALENDER_WEEKS",
|
|
99
|
+
MONTHS = "MONTHS",
|
|
100
|
+
CALENDER_MONTHS = "CALENDER_MONTHS",
|
|
101
|
+
YEARS = "YEARS",
|
|
102
|
+
CALENDER_YEARS = "CALENDER_YEARS",
|
|
103
|
+
HOURS = "HOURS",
|
|
104
|
+
MINUTES = "MINUTES",
|
|
105
|
+
CALENDER_QUARTERS = "CALENDER_QUARTERS",
|
|
106
|
+
FISCAL_QUARTER = "FISCAL_QUARTER",
|
|
107
|
+
FISCAL_YEAR = "FISCAL_YEAR",
|
|
108
|
+
QUARTERS = "QUARTERS",
|
|
109
|
+
}
|
|
110
|
+
declare const negativeCharacterOperators: RangeOperator[];
|
|
111
|
+
declare const startsWithCharacterOperators: RangeOperator[];
|
|
112
|
+
declare const containsCharacterOperators: RangeOperator[];
|
|
113
|
+
declare enum EFilterDataType {
|
|
114
|
+
BOOLEAN = "boolean",
|
|
115
|
+
DATE = "date",
|
|
116
|
+
NUMBER = "number",
|
|
117
|
+
STRING = "string",
|
|
118
|
+
}
|
|
119
|
+
declare class SuperFilterBuilder {
|
|
120
|
+
private superFilter;
|
|
121
|
+
private databaseDetails;
|
|
122
|
+
private skipCountForRankingFilter;
|
|
123
|
+
private joinClauses;
|
|
124
|
+
private manualFilterOptions;
|
|
125
|
+
private lastRankingFilter;
|
|
126
|
+
constructor(superFilter: ISuperFilterConfig, databaseDetails: any, skipCountForRankingFilter?: boolean, joinClauses?: JoinExpressions, manualFilterOptions?: IManualFilterConfig[]);
|
|
127
|
+
/**
|
|
128
|
+
* Entry point: build SQL condition string
|
|
129
|
+
*/
|
|
130
|
+
build(): string;
|
|
131
|
+
/**
|
|
132
|
+
* Recursively process group and children
|
|
133
|
+
* - skips all ranking filters during this pass
|
|
134
|
+
* - preserves order of all other filters
|
|
135
|
+
*/
|
|
136
|
+
private processGroup;
|
|
137
|
+
/**
|
|
138
|
+
* Find the last ranking filter in the whole superFilter (depth-first, left-to-right traversal)
|
|
139
|
+
*/
|
|
140
|
+
private findLastRankingFilter;
|
|
141
|
+
/**
|
|
142
|
+
* Decide which filter type to handle
|
|
143
|
+
*/
|
|
144
|
+
private processFilter;
|
|
145
|
+
/**
|
|
146
|
+
* Handle VALUES filter => column IN/NOT IN (...)
|
|
147
|
+
*/
|
|
148
|
+
private processValuesFilter;
|
|
149
|
+
/**
|
|
150
|
+
* Handle RANGE filter => column op value AND/OR column op value
|
|
151
|
+
*/
|
|
152
|
+
private processRangeFilter;
|
|
153
|
+
/**
|
|
154
|
+
* Handle RANKING filter (top/bottom/both)
|
|
155
|
+
*/
|
|
156
|
+
private processRankingFilter;
|
|
157
|
+
/**
|
|
158
|
+
* Resolve column name (table.column or column only)
|
|
159
|
+
*/
|
|
160
|
+
private getColumnName;
|
|
161
|
+
/**
|
|
162
|
+
* Get filter data type
|
|
163
|
+
*/
|
|
164
|
+
private getFilterDataType;
|
|
165
|
+
/**
|
|
166
|
+
* Format value depending on datatype/db
|
|
167
|
+
*/
|
|
168
|
+
private formatValue;
|
|
169
|
+
/**
|
|
170
|
+
* Format relative character filter
|
|
171
|
+
*/
|
|
172
|
+
private formatRelativeCharacterFilter;
|
|
173
|
+
/**
|
|
174
|
+
* Process search filter
|
|
175
|
+
*/
|
|
176
|
+
processSearchFilter(filter: IGroupFilter, isSearch?: boolean): string;
|
|
177
|
+
private getManualFilterMatch;
|
|
178
|
+
private getOperatorFlags;
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/filters/filter-types.d.ts
|
|
182
|
+
type LogicalCombinator = 'and' | 'or';
|
|
183
|
+
type Rule = {
|
|
184
|
+
operator: string;
|
|
185
|
+
value: string | number | boolean | (string | number)[];
|
|
186
|
+
column: string;
|
|
187
|
+
isCategoryFilter?: boolean;
|
|
188
|
+
topNDataTarget?: string;
|
|
189
|
+
};
|
|
190
|
+
type RuleGroup = {
|
|
191
|
+
rules: Array<Rule>;
|
|
192
|
+
combinator: LogicalCombinator;
|
|
193
|
+
};
|
|
194
|
+
type FilterConfig = {
|
|
195
|
+
rules: Array<Rule | RuleGroup>;
|
|
196
|
+
combinator: LogicalCombinator;
|
|
197
|
+
not: boolean;
|
|
198
|
+
};
|
|
199
|
+
type FilterType = 'VALUES' | 'RANGE' | 'DATE' | 'RANKING';
|
|
200
|
+
interface IValueFilter {
|
|
201
|
+
id: string[];
|
|
202
|
+
label: string[];
|
|
203
|
+
}
|
|
204
|
+
interface IRangeFilter {
|
|
205
|
+
from?: string;
|
|
206
|
+
to?: string;
|
|
207
|
+
logicalOperator?: 'AND' | 'OR';
|
|
208
|
+
fromCondition?: string;
|
|
209
|
+
toCondition?: string;
|
|
210
|
+
}
|
|
211
|
+
interface IRankingFilter {
|
|
212
|
+
type: 'TOP' | 'BOTTOM' | 'BOTH';
|
|
213
|
+
rankByColumnId: string;
|
|
214
|
+
rankByColumnName: string;
|
|
215
|
+
rankByColumnType: string;
|
|
216
|
+
rankByTableName: string;
|
|
217
|
+
rankByAggregationType: string;
|
|
218
|
+
value: number;
|
|
219
|
+
isPercentage: boolean;
|
|
220
|
+
}
|
|
221
|
+
type IDateTimeFilter = {
|
|
222
|
+
relativeDateFilter?: EDateRangeRelativeFilterCondition;
|
|
223
|
+
period?: EDateRangeRelativePeriodFilterCondition;
|
|
224
|
+
duration?: number;
|
|
225
|
+
includeToday?: boolean;
|
|
226
|
+
fiscalYearStartMonth?: number;
|
|
227
|
+
};
|
|
228
|
+
interface IGroupFilter {
|
|
229
|
+
columnIds: string[];
|
|
230
|
+
tableNames: string[];
|
|
231
|
+
columnNames: string[];
|
|
232
|
+
dataType: string[];
|
|
233
|
+
filterType: FilterType;
|
|
234
|
+
sourceType?: string[];
|
|
235
|
+
columnType?: string[];
|
|
236
|
+
columnDataType?: string[];
|
|
237
|
+
valuesFilterApplicationType?: 'exclude' | 'include';
|
|
238
|
+
valuesFilter?: IValueFilter[];
|
|
239
|
+
logicalOperator?: 'AND' | 'OR';
|
|
240
|
+
aggregationType?: string[];
|
|
241
|
+
rangeFilter?: IRangeFilter[];
|
|
242
|
+
dateTimeFilter?: IDateTimeFilter;
|
|
243
|
+
rankingFilter?: IRankingFilter[];
|
|
244
|
+
searchConfig?: {
|
|
245
|
+
matchCase: boolean;
|
|
246
|
+
searchString: string;
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
interface ISuperFilterConfig {
|
|
250
|
+
groupId: string;
|
|
251
|
+
groupLabel: string;
|
|
252
|
+
condition: 'AND' | 'OR';
|
|
253
|
+
children: ({
|
|
254
|
+
filters: IGroupFilter;
|
|
255
|
+
} | ISuperFilterConfig)[];
|
|
256
|
+
}
|
|
257
|
+
type RelationshipMapping = {
|
|
258
|
+
joinType: string;
|
|
259
|
+
id: string;
|
|
260
|
+
schema: string;
|
|
261
|
+
table: string;
|
|
262
|
+
joinId: string;
|
|
263
|
+
label: string;
|
|
264
|
+
alias: string;
|
|
265
|
+
};
|
|
266
|
+
type JoinExpressions = {
|
|
267
|
+
alias: string;
|
|
268
|
+
joinRelation: RelationshipMapping[];
|
|
269
|
+
};
|
|
270
|
+
type RangeOperator = 'IS' | 'IS_NOT' | 'IS_BLANK' | 'IS_NOT_BLANK' | 'IS_AFTER' | 'IS_BEFORE' | 'IS_ON_OR_AFTER' | 'IS_ON_OR_BEFORE' | 'IS_LESS_THAN' | 'IS_LESS_THAN_OR_EQUAL_TO' | 'IS_GREATER_THAN' | 'IS_GREATER_THAN_OR_EQUAL_TO' | 'CONTAINS' | 'DOES_NOT_CONTAIN' | 'STARTS_WITH' | 'DOES_NOT_START_WITH';
|
|
271
|
+
interface IManualFilterOption {
|
|
272
|
+
displayName?: string;
|
|
273
|
+
value: string | number | boolean;
|
|
274
|
+
id: string;
|
|
275
|
+
}
|
|
276
|
+
interface IManualFilterConfig {
|
|
277
|
+
column: string;
|
|
278
|
+
options: IManualFilterOption[];
|
|
279
|
+
}
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/query-builder/PaginationBuilder.d.ts
|
|
282
|
+
interface PaginationBuilder {
|
|
283
|
+
generateQuery(offset: number, limit: number): string;
|
|
284
|
+
}
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region src/query-builder/QueryBuilder.d.ts
|
|
287
|
+
type SortConfig = {
|
|
288
|
+
column: string;
|
|
289
|
+
order: 'ASC' | 'DESC';
|
|
290
|
+
}[];
|
|
291
|
+
type PaginationConfig = {
|
|
292
|
+
skip: number;
|
|
293
|
+
take: number;
|
|
294
|
+
};
|
|
295
|
+
type FilterResolverParams = {
|
|
296
|
+
filterConfig: FilterConfig;
|
|
297
|
+
schema?: IColumnSchemaItem[];
|
|
298
|
+
};
|
|
299
|
+
interface QueryResolver {
|
|
300
|
+
filterResolver(params: FilterResolverParams): string;
|
|
301
|
+
}
|
|
302
|
+
type RuntimeVariables = {
|
|
303
|
+
$RUNTIME_LOGGEDIN_NAME: string;
|
|
304
|
+
$RUNTIME_LOGGEDIN_EMAIL: string;
|
|
305
|
+
$RUNTIME_CURRENT_DATE?: string;
|
|
306
|
+
$RUNTIME_CURRENT_DATETIME?: string;
|
|
307
|
+
};
|
|
308
|
+
type QueryBuilderOptions = {
|
|
309
|
+
selectedColumns: string[];
|
|
310
|
+
databaseDetails: Record<string, any>;
|
|
311
|
+
primaryKeyColumns: string[];
|
|
312
|
+
filterConfig?: FilterConfig;
|
|
313
|
+
pagination?: PaginationConfig;
|
|
314
|
+
sortConfig?: SortConfig;
|
|
315
|
+
searchExpression?: string;
|
|
316
|
+
distinct?: boolean;
|
|
317
|
+
columnConfigMap: Record<string, IMDMColumnConfigWithParsedMeta>;
|
|
318
|
+
queryResolver: QueryResolver;
|
|
319
|
+
runtimeVariables: RuntimeVariables;
|
|
320
|
+
schema?: IColumnSchemaItem[];
|
|
321
|
+
includeFinalCTESelectQuery?: boolean;
|
|
322
|
+
finalResponseAsObject?: boolean;
|
|
323
|
+
superFilters?: ISuperFilterConfig;
|
|
324
|
+
skipCountForRankingFilter?: boolean;
|
|
325
|
+
joinClauses?: JoinExpressions;
|
|
326
|
+
manualFilterOptions?: IManualFilterConfig[];
|
|
327
|
+
enableLastSelectCTEWrap?: boolean;
|
|
328
|
+
};
|
|
329
|
+
type BuildOptions = Partial<Omit<QueryBuilderOptions, 'tableName' | 'queryResolver' | 'schema'>>;
|
|
330
|
+
type FinalQueryResult = {
|
|
331
|
+
finalQuery: string;
|
|
332
|
+
finalCteName?: string;
|
|
333
|
+
};
|
|
334
|
+
type CalculationOrderResult = {
|
|
335
|
+
nativeColumns: Set<string>;
|
|
336
|
+
formulaColumnsByDependencyLevel: IMDMColumnConfigWithParsedMeta[][];
|
|
337
|
+
};
|
|
338
|
+
declare enum DEFAULT_VALUE_TYPE {
|
|
339
|
+
MANUAL = "MANUAL",
|
|
340
|
+
DERIVED = "DERIVED",
|
|
341
|
+
NONE = "NONE",
|
|
342
|
+
}
|
|
343
|
+
type IColumnSchemaItem = {
|
|
344
|
+
name: string;
|
|
345
|
+
type: string;
|
|
346
|
+
defaultValue?: string | number;
|
|
347
|
+
isNullable?: boolean;
|
|
348
|
+
isIdentity?: boolean;
|
|
349
|
+
};
|
|
350
|
+
declare const MAX_STRING_TYPE = "nvarchar(max)";
|
|
351
|
+
/**
|
|
352
|
+
* Steps:
|
|
353
|
+
* 1. Separate out filters for native columns and formula columns
|
|
354
|
+
* 2. Apply filters for native columns in the main CTE. If Native columns have sorting config then -
|
|
355
|
+
* - If SortConfig exists for Formula columns with cte, do not apply sorting
|
|
356
|
+
* - If SortConfig exists for Formula columns without cte, apply sorting
|
|
357
|
+
* - If SortConfig does not exist for Formula columns, apply sorting
|
|
358
|
+
* 3. Apply filters for formula columns in the CTE followed by the column specific CTEs due to alias not supported in where clause
|
|
359
|
+
* 4. Apply SortConfig and pagination in the CTE with last filter
|
|
360
|
+
* 5. Perform final projection and apply SortConfig and Pagination, if still exists
|
|
361
|
+
*/
|
|
362
|
+
declare class QueryBuilder {
|
|
363
|
+
private readonly paginationBuilder;
|
|
364
|
+
private readonly options;
|
|
365
|
+
constructor(options: QueryBuilderOptions);
|
|
366
|
+
build(options?: BuildOptions): FinalQueryResult;
|
|
367
|
+
buildCountQuery(options?: BuildOptions): FinalQueryResult;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Implementation class for QueryBuilder
|
|
371
|
+
*
|
|
372
|
+
* @private exposed for testing
|
|
373
|
+
*/
|
|
374
|
+
declare class QueryBuilderImpl {
|
|
375
|
+
private readonly paginationBuilder;
|
|
376
|
+
private readonly options;
|
|
377
|
+
private buildState;
|
|
378
|
+
private readonly entityNameFormatter;
|
|
379
|
+
constructor(options: QueryBuilderOptions, paginationBuilder: PaginationBuilder);
|
|
380
|
+
build(isCountQuery?: boolean): FinalQueryResult;
|
|
381
|
+
/**
|
|
382
|
+
* Returns the sort config with only the columns that are part of the requested columns
|
|
383
|
+
*/
|
|
384
|
+
private getRelevantSortConfig;
|
|
385
|
+
/**
|
|
386
|
+
* Adds columns used in the filter config to the set of all columns
|
|
387
|
+
*/
|
|
388
|
+
private addColumnsFromFilterConfig;
|
|
389
|
+
private retrieveColumnExprsInFront;
|
|
390
|
+
private buildMainCTE;
|
|
391
|
+
/**
|
|
392
|
+
* Returns the filter expression for the selected columns. If column type is formula,
|
|
393
|
+
* stores the rules in pending filter config and process it in the next call to getFilterExpression
|
|
394
|
+
* else processes immediately.
|
|
395
|
+
*
|
|
396
|
+
* Note - Pass empty set to process any pending filter config
|
|
397
|
+
*/
|
|
398
|
+
private getFilterExpression;
|
|
399
|
+
/**
|
|
400
|
+
* Returns the sort expression if each column in the sort config is part of selected columns
|
|
401
|
+
*/
|
|
402
|
+
private getSortExpression;
|
|
403
|
+
/**
|
|
404
|
+
* Returns the pagination expression if the pagination config is set and sort is not pending.
|
|
405
|
+
* It must be called after getSortExpression.
|
|
406
|
+
*/
|
|
407
|
+
private getPaginationExpression;
|
|
408
|
+
/**
|
|
409
|
+
* Builds the intermediate CTEs for the formula columns
|
|
410
|
+
* 1. Replace table name with previous cte name
|
|
411
|
+
* 2. Apply filter condition
|
|
412
|
+
* 3. Apply sort expression, if applicable
|
|
413
|
+
* 4. Apply pagination, if applicable
|
|
414
|
+
* 5. Return CTEs/Column expressions
|
|
415
|
+
*/
|
|
416
|
+
private buildIntermediateCTE;
|
|
417
|
+
private addStagingCTE;
|
|
418
|
+
private buildFinalProjection;
|
|
419
|
+
private applyDistinctExpressionToMainCTE;
|
|
420
|
+
private applyCountExpressionToMainCTE;
|
|
421
|
+
private getDistinctCountCte;
|
|
422
|
+
private buildSqlQueryParts;
|
|
423
|
+
/**
|
|
424
|
+
* Returns the calculation order for the given columns
|
|
425
|
+
* @private exposed for testing
|
|
426
|
+
*/
|
|
427
|
+
getCalculationOrder(columns: Set<string>): CalculationOrderResult;
|
|
428
|
+
private dfs;
|
|
429
|
+
/**
|
|
430
|
+
* Applies the join positions from the query builder to the given Select AST.
|
|
431
|
+
* The join positions are added to the FROM list of the AST.
|
|
432
|
+
*
|
|
433
|
+
* @param {Select} ast - The Select AST to apply the join positions to.
|
|
434
|
+
* @returns {string[]} - An empty array, for consistency with other methods.
|
|
435
|
+
*/
|
|
436
|
+
private applyJoinExpressionToMainCTE;
|
|
437
|
+
/**
|
|
438
|
+
* Gets the super filter expression.
|
|
439
|
+
* If super filters are present and the pending filter config is not empty,
|
|
440
|
+
* it will process the super filter condition and return the result.
|
|
441
|
+
* If the super filter expression is empty, it will return an empty string.
|
|
442
|
+
* @returns {string} - The super filter expression.
|
|
443
|
+
*/
|
|
444
|
+
private getSuperFilterExpression;
|
|
445
|
+
private buildFinalQueryComponents;
|
|
446
|
+
private filterRequiredColumns;
|
|
447
|
+
}
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region src/js-lib/db/base/VisitorInterface.d.ts
|
|
450
|
+
type Node = acorn.Node;
|
|
451
|
+
interface VisitorInterface<T extends Node> {
|
|
452
|
+
visitor: (node: T, context: ParseContext) => void;
|
|
453
|
+
}
|
|
454
|
+
//#endregion
|
|
455
|
+
//#region src/js-lib/JsToSqlParser.d.ts
|
|
456
|
+
type ResolvedFormulaProps = {
|
|
457
|
+
returnType: string | undefined;
|
|
458
|
+
isValid: boolean;
|
|
459
|
+
error: string | undefined;
|
|
460
|
+
sqlQueryProps: SqlQueryProps;
|
|
461
|
+
deps: string[];
|
|
462
|
+
};
|
|
463
|
+
/**
|
|
464
|
+
* Factory function to create database specific parser
|
|
465
|
+
*/
|
|
466
|
+
declare function createJsToSqlParser(context: ParseContext): JsToSqlParser;
|
|
467
|
+
type VisitorConfig = {
|
|
468
|
+
callExpression?: VisitorInterface<acorn.CallExpression>;
|
|
469
|
+
identifier?: VisitorInterface<acorn.Identifier>;
|
|
470
|
+
literal?: VisitorInterface<acorn.Literal>;
|
|
471
|
+
binaryExpression?: VisitorInterface<acorn.BinaryExpression>;
|
|
472
|
+
arrayExpression?: VisitorInterface<acorn.ArrayExpression>;
|
|
473
|
+
unaryExpression?: VisitorInterface<acorn.UnaryExpression>;
|
|
474
|
+
program?: VisitorInterface<acorn.Program>;
|
|
475
|
+
memberExpression?: VisitorInterface<acorn.MemberExpression>;
|
|
476
|
+
assignmentExpression?: VisitorInterface<acorn.AssignmentExpression>;
|
|
477
|
+
};
|
|
478
|
+
/**
|
|
479
|
+
* Parses a JavaScript formula and returns the corresponding SQL AST.
|
|
480
|
+
* - For Database specific overrides, implement the corresponding visitor in `db` directory and
|
|
481
|
+
* pass it to the constructor as part of the `config` parameter.
|
|
482
|
+
* - Use Factory function to compose parser for specific database
|
|
483
|
+
*/
|
|
484
|
+
declare class JsToSqlParser {
|
|
485
|
+
private context;
|
|
486
|
+
private callExpression;
|
|
487
|
+
private identifier;
|
|
488
|
+
private literal;
|
|
489
|
+
private binaryExpression;
|
|
490
|
+
private arrayExpression;
|
|
491
|
+
private unaryExpression;
|
|
492
|
+
private program;
|
|
493
|
+
private memberExpression;
|
|
494
|
+
private assignmentExpression;
|
|
495
|
+
constructor(context: ParseContext, config?: VisitorConfig);
|
|
496
|
+
parse(formula: string): any;
|
|
497
|
+
/**
|
|
498
|
+
* Converts the SQL AST to a SQL query string
|
|
499
|
+
*/
|
|
500
|
+
toSql(sqlAst: any): string;
|
|
501
|
+
/**
|
|
502
|
+
* Creates appropriate SQL query props based on the SQL AST
|
|
503
|
+
*/
|
|
504
|
+
toSqlProps(sqlAst: any): SqlQueryProps;
|
|
505
|
+
/**
|
|
506
|
+
* Returns the resolved formula props for current column along with the dependencies
|
|
507
|
+
*/
|
|
508
|
+
getResolvedFormulaProps(sqlAst: any): ResolvedFormulaProps;
|
|
509
|
+
/**
|
|
510
|
+
* Pre walk and detect if the jsAst has 'if'
|
|
511
|
+
*/
|
|
512
|
+
private detectIfCondition;
|
|
513
|
+
/**
|
|
514
|
+
* Extracts and normalizes formula by adding parentheses to reserved function names
|
|
515
|
+
*/
|
|
516
|
+
private processFormulaText;
|
|
517
|
+
private removeForeach;
|
|
518
|
+
}
|
|
519
|
+
//#endregion
|
|
520
|
+
//#region src/sql-types.d.ts
|
|
521
|
+
interface OrderBy {
|
|
522
|
+
type: 'ASC' | 'DESC';
|
|
523
|
+
expr: any;
|
|
524
|
+
loc?: LocationRange;
|
|
525
|
+
}
|
|
526
|
+
type RawSqlExpression = {
|
|
527
|
+
type: 'sql_expr';
|
|
528
|
+
value: string;
|
|
529
|
+
meta?: Record<string, any>;
|
|
530
|
+
};
|
|
531
|
+
interface ValueExpr<T = string | number | boolean> {
|
|
532
|
+
type: 'backticks_quote_string' | 'string' | 'regex_string' | 'hex_string' | 'full_hex_string' | 'natural_string' | 'bit_string' | 'double_quote_string' | 'single_quote_string' | 'boolean' | 'bool' | 'null' | 'star' | 'param' | 'origin' | 'date' | 'datetime' | 'default' | 'time' | 'timestamp' | 'var_string';
|
|
533
|
+
value: T;
|
|
534
|
+
}
|
|
535
|
+
interface ColumnRefItem {
|
|
536
|
+
type: 'column_ref';
|
|
537
|
+
table: string | null;
|
|
538
|
+
column: string | {
|
|
539
|
+
expr: ValueExpr;
|
|
540
|
+
};
|
|
541
|
+
options?: ExprList;
|
|
542
|
+
loc?: LocationRange;
|
|
543
|
+
collate?: {
|
|
544
|
+
collate: CollateExpr;
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
interface ColumnRefExpr {
|
|
548
|
+
type: 'expr';
|
|
549
|
+
expr: ColumnRefItem;
|
|
550
|
+
as: string | null;
|
|
551
|
+
}
|
|
552
|
+
type ColumnRef = ColumnRefItem | ColumnRefExpr;
|
|
553
|
+
interface Case {
|
|
554
|
+
type: 'case';
|
|
555
|
+
expr: null;
|
|
556
|
+
args: Array<{
|
|
557
|
+
cond: Binary;
|
|
558
|
+
result: ExpressionValue;
|
|
559
|
+
type: 'when';
|
|
560
|
+
} | {
|
|
561
|
+
result: ExpressionValue;
|
|
562
|
+
type: 'else';
|
|
563
|
+
}>;
|
|
564
|
+
}
|
|
565
|
+
interface Cast {
|
|
566
|
+
type: 'cast';
|
|
567
|
+
keyword: 'cast';
|
|
568
|
+
expr: ExpressionValue;
|
|
569
|
+
symbol: 'as';
|
|
570
|
+
target: {
|
|
571
|
+
dataType: string;
|
|
572
|
+
suffix: unknown[];
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
interface AggrFunc {
|
|
576
|
+
type: 'aggr_func';
|
|
577
|
+
name: string;
|
|
578
|
+
args: {
|
|
579
|
+
expr: ExpressionValue;
|
|
580
|
+
distinct: 'DISTINCT' | null;
|
|
581
|
+
orderby: OrderBy[] | null;
|
|
582
|
+
parentheses?: boolean;
|
|
583
|
+
};
|
|
584
|
+
loc?: LocationRange;
|
|
585
|
+
}
|
|
586
|
+
type FunctionName = {
|
|
587
|
+
schema?: {
|
|
588
|
+
value: string;
|
|
589
|
+
type: string;
|
|
590
|
+
};
|
|
591
|
+
name: ValueExpr<string>[];
|
|
592
|
+
};
|
|
593
|
+
interface SqlFunction {
|
|
594
|
+
type: 'function';
|
|
595
|
+
name: FunctionName;
|
|
596
|
+
args?: ExprList;
|
|
597
|
+
suffix?: any;
|
|
598
|
+
loc?: LocationRange;
|
|
599
|
+
}
|
|
600
|
+
interface Column {
|
|
601
|
+
type: 'column';
|
|
602
|
+
expr: ExpressionValue;
|
|
603
|
+
as: ValueExpr<string> | string | null;
|
|
604
|
+
type?: string;
|
|
605
|
+
loc?: LocationRange;
|
|
606
|
+
}
|
|
607
|
+
interface Interval {
|
|
608
|
+
type: 'interval';
|
|
609
|
+
unit: string;
|
|
610
|
+
expr: ValueExpr & {
|
|
611
|
+
loc?: LocationRange;
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
type Param = {
|
|
615
|
+
type: 'param';
|
|
616
|
+
value: string;
|
|
617
|
+
loc?: LocationRange;
|
|
618
|
+
};
|
|
619
|
+
type Value = {
|
|
620
|
+
type: string;
|
|
621
|
+
value: any;
|
|
622
|
+
loc?: LocationRange;
|
|
623
|
+
};
|
|
624
|
+
type Binary = {
|
|
625
|
+
type: 'binary_expr';
|
|
626
|
+
operator: string;
|
|
627
|
+
left: ExpressionValue | ExprList;
|
|
628
|
+
right: ExpressionValue | ExprList;
|
|
629
|
+
loc?: LocationRange;
|
|
630
|
+
parentheses?: boolean;
|
|
631
|
+
};
|
|
632
|
+
type UnaryExpression = {
|
|
633
|
+
type: 'unary_expr';
|
|
634
|
+
operator: string;
|
|
635
|
+
expr: ExpressionValue;
|
|
636
|
+
};
|
|
637
|
+
type ExpressionValue = ColumnRef | Column | Param | SqlFunction | Case | AggrFunc | Value | UnaryExpression | Binary | Cast | Interval | RawSqlExpression;
|
|
638
|
+
type ExprList = {
|
|
639
|
+
type: 'expr_list';
|
|
640
|
+
value: ExpressionValue[];
|
|
641
|
+
loc?: LocationRange;
|
|
642
|
+
parentheses?: boolean;
|
|
643
|
+
separator?: string;
|
|
644
|
+
};
|
|
645
|
+
type CollateExpr = {
|
|
646
|
+
type: 'collate';
|
|
647
|
+
symbol?: '=';
|
|
648
|
+
value: string;
|
|
649
|
+
};
|
|
650
|
+
//#endregion
|
|
651
|
+
//#region src/constants.d.ts
|
|
652
|
+
declare enum EDataType {
|
|
653
|
+
STRING = "string",
|
|
654
|
+
NUMBER = "number",
|
|
655
|
+
DATE = "date",
|
|
656
|
+
BOOLEAN = "boolean",
|
|
657
|
+
NULL = "null",
|
|
658
|
+
}
|
|
659
|
+
type NullableValueType = EDataType | null;
|
|
660
|
+
//#endregion
|
|
661
|
+
//#region src/utils.d.ts
|
|
662
|
+
declare function formatDBEntityName(name: string): string;
|
|
663
|
+
declare function getEntityNameFormatter(): (name: string, type?: string) => string;
|
|
664
|
+
declare function resolveRuntimeVariables(expr: string, runtimeVariables: RuntimeVariables): string;
|
|
665
|
+
declare function getDeprecatedFormulaId(columnName: string): string;
|
|
666
|
+
declare function getFormulaId(columnName: string): string;
|
|
667
|
+
declare function getDeprecatedFormulaIdColumnMap(columnConfigMap: Record<string, IMDMColumnConfigWithParsedMeta>): Record<string, string>;
|
|
668
|
+
declare function getFormulaIdColumnMap(columnConfigMap: Record<string, IMDMColumnConfigWithParsedMeta>): Record<string, string>;
|
|
669
|
+
declare function getFormattedTableName(databaseDetails: Record<string, any>): string;
|
|
670
|
+
declare function getCurrentDate(): string;
|
|
671
|
+
declare function getCurrentDateTime(): string;
|
|
672
|
+
/**
|
|
673
|
+
* Gets the join expressions from the join config
|
|
674
|
+
* @returns An array of join expressions in SQL format
|
|
675
|
+
*/
|
|
676
|
+
declare function getJoinExpressions(joinClauses: JoinExpressions, databaseDetails: Record<string, string>): string[];
|
|
677
|
+
/**
|
|
678
|
+
* Strips the 'WHERE' clause from the SQL query.
|
|
679
|
+
* - If where clause is not present, returns the original query.
|
|
680
|
+
* - If where clause is present, returns the part of the query after the 'WHERE' clause.
|
|
681
|
+
*/
|
|
682
|
+
declare function stripWhereClause(sqlQuery: string): string;
|
|
683
|
+
/**
|
|
684
|
+
* Extracts the target type of a CAST expression from a given Binary expression.
|
|
685
|
+
* The target type is the right-hand side of the AS operator, e.g. 'INT' in 'CAST(x AS INT)'.
|
|
686
|
+
* If the given expression does not represent a CAST expression, returns null.
|
|
687
|
+
* @param {Binary} arg - The Binary expression to extract the target type from.
|
|
688
|
+
* @returns {string | null} - The target type of the CAST expression, or null if it is not a CAST expression.
|
|
689
|
+
*/
|
|
690
|
+
declare function extractCastTargetType(arg: Binary): string | null;
|
|
691
|
+
/**
|
|
692
|
+
* Maps a SQL cast type to a Fabric data type
|
|
693
|
+
* @param {string} type - The SQL cast type to map.
|
|
694
|
+
* @returns {NullableValueType} - The corresponding Fabric data type.
|
|
695
|
+
*/
|
|
696
|
+
declare function mapSqlTypeToDataType(type: string): NullableValueType;
|
|
697
|
+
declare function isValidDate(value: string): boolean;
|
|
698
|
+
declare function getArgType(arg: ExpressionValue, context: ParseContext): NullableValueType;
|
|
699
|
+
//#endregion
|
|
700
|
+
//#region src/epm-query-builder/types/query-builder-types.d.ts
|
|
701
|
+
interface Relationship {
|
|
702
|
+
fromTable: string;
|
|
703
|
+
fromColumn: string;
|
|
704
|
+
toTable: string;
|
|
705
|
+
toColumn: string;
|
|
706
|
+
isActive?: boolean;
|
|
707
|
+
crossFilterDirection?: 'SINGLE' | 'BOTH' | null;
|
|
708
|
+
fromColumnMultiplicity: '*' | '0..1';
|
|
709
|
+
toColumnMultiplicity: '*' | '0..1';
|
|
710
|
+
}
|
|
711
|
+
interface EpmQueryBuilderOptions {
|
|
712
|
+
config: {
|
|
713
|
+
source: string;
|
|
714
|
+
};
|
|
715
|
+
selectedColumns?: string[];
|
|
716
|
+
databaseDetails: Record<string, unknown>;
|
|
717
|
+
primaryKeyColumns?: string[];
|
|
718
|
+
pagination?: PaginationConfig$1;
|
|
719
|
+
searchExpression?: string;
|
|
720
|
+
distinct?: boolean;
|
|
721
|
+
superFilters?: SuperFilterConfig;
|
|
722
|
+
rows: RowColumnConfig[];
|
|
723
|
+
columns: RowColumnConfig[];
|
|
724
|
+
values: MeasureConfig[];
|
|
725
|
+
orderBy: OrderByConfig[];
|
|
726
|
+
skipRollup?: boolean;
|
|
727
|
+
isCrossHighlightEnabled?: boolean;
|
|
728
|
+
measureFilters?: MeasureFilterConfig[];
|
|
729
|
+
dimensionIdMappings?: Record<string, DimensionIdMapping[]>;
|
|
730
|
+
customMeasures?: string[];
|
|
731
|
+
staticFormatStrings?: Record<string, string>;
|
|
732
|
+
isRankingFilterIncluded?: boolean;
|
|
733
|
+
relationships?: Relationship[];
|
|
734
|
+
}
|
|
735
|
+
interface RowColumnConfig {
|
|
736
|
+
id: string;
|
|
737
|
+
label: string;
|
|
738
|
+
type: string;
|
|
739
|
+
columnName: string;
|
|
740
|
+
tableName?: string;
|
|
741
|
+
aggregationType?: string;
|
|
742
|
+
dataType?: string;
|
|
743
|
+
orderByRef?: string;
|
|
744
|
+
formatString?: string;
|
|
745
|
+
expansionConfig?: ExpansionConfig;
|
|
746
|
+
}
|
|
747
|
+
interface MeasureConfig {
|
|
748
|
+
id: string;
|
|
749
|
+
label: string;
|
|
750
|
+
columnName: string;
|
|
751
|
+
tableName: string;
|
|
752
|
+
type: string;
|
|
753
|
+
aggregationType?: string;
|
|
754
|
+
dataType?: string;
|
|
755
|
+
formatString?: string;
|
|
756
|
+
isGetRangeEnabled?: boolean;
|
|
757
|
+
}
|
|
758
|
+
interface OrderByConfig {
|
|
759
|
+
id: string;
|
|
760
|
+
columnName: string;
|
|
761
|
+
tableName?: string;
|
|
762
|
+
type: 'ASC' | 'DESC';
|
|
763
|
+
aggregationType?: string;
|
|
764
|
+
isColumnPresentInOutput?: boolean;
|
|
765
|
+
}
|
|
766
|
+
interface RangeFilter {
|
|
767
|
+
operator?: string;
|
|
768
|
+
value?: string | number;
|
|
769
|
+
from?: string | number;
|
|
770
|
+
fromCondition?: string;
|
|
771
|
+
to?: string | number;
|
|
772
|
+
toCondition?: string;
|
|
773
|
+
logicalOperator?: string;
|
|
774
|
+
}
|
|
775
|
+
interface DateRangeFilter {
|
|
776
|
+
startDate: string;
|
|
777
|
+
endDate: string;
|
|
778
|
+
operator?: string;
|
|
779
|
+
}
|
|
780
|
+
interface SearchCondition {
|
|
781
|
+
operator: string;
|
|
782
|
+
value: string;
|
|
783
|
+
logicalOperator?: string;
|
|
784
|
+
}
|
|
785
|
+
interface RankingConfig {
|
|
786
|
+
type: RankingFilterType;
|
|
787
|
+
rankByColumnId: string;
|
|
788
|
+
rankByAggregationType: AggregationType;
|
|
789
|
+
rankByColumnName?: string;
|
|
790
|
+
rankByTableName?: string;
|
|
791
|
+
rankByColumnType?: string;
|
|
792
|
+
value: number;
|
|
793
|
+
isPercentage?: boolean;
|
|
794
|
+
operator?: string;
|
|
795
|
+
measureId?: string;
|
|
796
|
+
}
|
|
797
|
+
interface FilterConfig$1 {
|
|
798
|
+
filterType: string;
|
|
799
|
+
columnIds: string[];
|
|
800
|
+
columnNames: string[];
|
|
801
|
+
tableNames: string[];
|
|
802
|
+
columnDataType?: string[];
|
|
803
|
+
sourceType?: string[];
|
|
804
|
+
dataType?: string[];
|
|
805
|
+
valuesFilterApplicationType?: ValuesFilterApplicationType;
|
|
806
|
+
valuesFilter?: {
|
|
807
|
+
id: string | string[];
|
|
808
|
+
label: string | string[];
|
|
809
|
+
}[];
|
|
810
|
+
isCrossHighlight?: boolean;
|
|
811
|
+
rangeFilter?: RangeFilter[];
|
|
812
|
+
dateRangeFilter?: DateRangeFilter[];
|
|
813
|
+
relativePeriodFilter?: RelativePeriodFilterConfig;
|
|
814
|
+
aggregationType?: string[];
|
|
815
|
+
columnType?: string[];
|
|
816
|
+
logicalOperator?: string;
|
|
817
|
+
isTupleFilter?: boolean;
|
|
818
|
+
searchConditions?: SearchCondition[];
|
|
819
|
+
isRankingFilter?: boolean;
|
|
820
|
+
rankingConfig?: RankingConfig;
|
|
821
|
+
rankingFilter?: RankingConfig[];
|
|
822
|
+
blankFilterConfig?: BlankFilterConfig;
|
|
823
|
+
dateHierarchyConfig?: DateHierarchyConfig;
|
|
824
|
+
compositeColumnConfig?: CompositeColumnConfig;
|
|
825
|
+
fieldParameterMapping?: FieldParameterMapping;
|
|
826
|
+
distinctRowsCount?: number;
|
|
827
|
+
isRelativePeriodFilter?: boolean;
|
|
828
|
+
isDateHierarchyFilter?: boolean;
|
|
829
|
+
isFieldParameterFilter?: boolean;
|
|
830
|
+
isCompositeFilter?: boolean;
|
|
831
|
+
}
|
|
832
|
+
interface SuperFilterChild {
|
|
833
|
+
filters?: FilterConfig$1;
|
|
834
|
+
isGroup?: boolean;
|
|
835
|
+
isFilter?: boolean;
|
|
836
|
+
groupId?: string;
|
|
837
|
+
groupLabel?: string;
|
|
838
|
+
condition?: string;
|
|
839
|
+
children?: SuperFilterChild[];
|
|
840
|
+
}
|
|
841
|
+
interface SuperFilterConfig {
|
|
842
|
+
groupId: string;
|
|
843
|
+
groupLabel: string;
|
|
844
|
+
condition: string;
|
|
845
|
+
children: SuperFilterChild[];
|
|
846
|
+
}
|
|
847
|
+
interface MeasureFilterConfig {
|
|
848
|
+
id: string;
|
|
849
|
+
tableName: string;
|
|
850
|
+
columnName: string;
|
|
851
|
+
aggregationType?: string;
|
|
852
|
+
dataType: string;
|
|
853
|
+
operator: string;
|
|
854
|
+
value: string | number;
|
|
855
|
+
logicalOperator?: string;
|
|
856
|
+
}
|
|
857
|
+
interface PaginationConfig$1 {
|
|
858
|
+
limit?: number;
|
|
859
|
+
skip?: number;
|
|
860
|
+
take?: number;
|
|
861
|
+
reference?: PaginationReference;
|
|
862
|
+
}
|
|
863
|
+
interface PaginationReference {
|
|
864
|
+
dimensions?: string[];
|
|
865
|
+
instances?: string[];
|
|
866
|
+
command?: PaginationCommand;
|
|
867
|
+
nextToken?: string[];
|
|
868
|
+
}
|
|
869
|
+
interface ExpansionConfig {
|
|
870
|
+
expansionType: string;
|
|
871
|
+
items?: string[];
|
|
872
|
+
start?: string;
|
|
873
|
+
end?: string;
|
|
874
|
+
step?: number;
|
|
875
|
+
interval?: string;
|
|
876
|
+
hierarchies?: string[];
|
|
877
|
+
hierarchyTable?: string[][];
|
|
878
|
+
}
|
|
879
|
+
type AggregationType = 'SUM' | 'COUNT' | 'COUNT_DISTINCT' | 'DISTINCT_COUNT' | 'AVG' | 'MIN' | 'MAX' | 'FIRST' | 'LAST' | 'STANDARD_DEVIATION' | 'VARIANCE' | 'MEDIAN' | 'MODE' | 'CONCATENATED' | 'CONCATENATED_IDS';
|
|
880
|
+
type RankingFilterType = 'TOP' | 'BOTTOM' | 'BOTH';
|
|
881
|
+
type ValuesFilterApplicationType = 'INCLUDE' | 'EXCLUDE';
|
|
882
|
+
type PaginationCommand = 'NEXT_HEIR' | 'SIBLING' | 'CHILDREN';
|
|
883
|
+
type RelativePeriodFilter = 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS' | 'CALENDER_WEEKS' | 'CALENDER_MONTHS' | 'CALENDER_YEARS' | 'CALENDER_QUARTERS' | 'FISCAL_YEAR' | 'FISCAL_QUARTER' | 'HOURS' | 'MINUTES';
|
|
884
|
+
type DateRelativeFilter = 'IS_IN_THE_LAST' | 'IS_IN_THE_NEXT' | 'IS_IN_THIS' | 'IS_BEFORE' | 'IS_AFTER';
|
|
885
|
+
interface DimensionIdMapping {
|
|
886
|
+
sourceField: string;
|
|
887
|
+
targetTable: string;
|
|
888
|
+
targetField: string;
|
|
889
|
+
}
|
|
890
|
+
interface FieldParameterMapping {
|
|
891
|
+
sourceField: string;
|
|
892
|
+
targetTable: string;
|
|
893
|
+
targetField: string;
|
|
894
|
+
filterValues?: string[];
|
|
895
|
+
}
|
|
896
|
+
interface RelativePeriodFilterConfig {
|
|
897
|
+
duration: number;
|
|
898
|
+
period: RelativePeriodFilter;
|
|
899
|
+
relativeDateFilter: DateRelativeFilter;
|
|
900
|
+
includeToday?: boolean;
|
|
901
|
+
fiscalYearStartMonth?: number;
|
|
902
|
+
}
|
|
903
|
+
interface DateHierarchyConfig {
|
|
904
|
+
level: 'YEAR' | 'QUARTER' | 'MONTH' | 'DAY' | 'WEEK' | 'DAYOFWEEK';
|
|
905
|
+
values: number[];
|
|
906
|
+
format?: string;
|
|
907
|
+
fiscalYearStartMonth?: number;
|
|
908
|
+
}
|
|
909
|
+
interface BlankFilterConfig {
|
|
910
|
+
operator: 'IS_BLANK' | 'IS_NOT_BLANK';
|
|
911
|
+
treatEmptyStringAsBlank?: boolean;
|
|
912
|
+
}
|
|
913
|
+
interface CompositeColumnConfig {
|
|
914
|
+
columnIds: string[];
|
|
915
|
+
operator: 'CONCATENATE' | 'COMBINE';
|
|
916
|
+
separator?: string;
|
|
917
|
+
}
|
|
918
|
+
//#endregion
|
|
919
|
+
//#region src/epm-query-builder/EpmQueryBuilder.d.ts
|
|
920
|
+
declare class EpmQueryBuilder {
|
|
921
|
+
private readonly impl;
|
|
922
|
+
constructor(options: EpmQueryBuilderOptions);
|
|
923
|
+
build(): string;
|
|
924
|
+
}
|
|
925
|
+
//#endregion
|
|
926
|
+
export { ColumnExpression, ColumnMeta, CteExpression, DEFAULT_VALUE_TYPE, EDateRangeRelativeFilterCondition, EDateRangeRelativePeriodFilterCondition, EFilterDataType, EpmQueryBuilder, type EpmQueryBuilderOptions, FilterConfig, FilterResolverParams, FilterType, FinalQueryResult, IDateTimeFilter, IGroupFilter, IMDMColumnConfigWithParsedMeta, IManualFilterConfig, IManualFilterOption, IRangeFilter, IRankingFilter, ISuperFilterConfig, IValueFilter, JoinExpressions, JsToSqlParser, LogicalCombinator, MAX_STRING_TYPE, MDM_COLUMN_TYPE, PaginationConfig, ParseContext, ParseContextProps, QueryBuilder, QueryBuilderImpl, QueryBuilderOptions, QueryResolver, RangeOperator, RelationshipMapping, ResolvedExpressionType, ResolvedFormulaProps, Rule, RuleGroup, RuntimeVariables, SortConfig, SqlQueryProps, SuperFilterBuilder, TColumnConfigMap, VisitorConfig, containsCharacterOperators, createJsToSqlParser, extractCastTargetType, formatDBEntityName, getArgType, getCurrentDate, getCurrentDateTime, getDeprecatedFormulaId, getDeprecatedFormulaIdColumnMap, getEntityNameFormatter, getFormattedTableName, getFormulaId, getFormulaIdColumnMap, getJoinExpressions, isValidDate, mapSqlTypeToDataType, negativeCharacterOperators, resolveRuntimeVariables, startsWithCharacterOperators, stripWhereClause };
|
|
927
|
+
//# sourceMappingURL=index.d.ts.map
|