@sisense/sdk-query-client 0.12.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/interfaces.d.ts +2 -2
- package/dist/query-client.d.ts +2 -2
- package/dist/query-client.js +2 -2
- package/dist/query-result/get-data-from-query-result.d.ts +6 -0
- package/dist/query-result/get-data-from-query-result.js +22 -6
- package/dist/query-task-manager/query-task-manager.d.ts +1 -0
- package/dist/query-task-manager/query-task-manager.js +14 -4
- package/dist/query-task-manager/query-task-passport.d.ts +3 -3
- package/dist/query-task-manager/query-task-passport.js +2 -2
- package/dist/types.d.ts +12 -0
- package/package.json +4 -4
package/dist/interfaces.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DataSourceField, ExecutingQueryResult, QueryDescription } from './types.js';
|
|
1
|
+
import { DataSourceField, ExecutingQueryResult, QueryDescription, QueryExecutionConfig } from './types.js';
|
|
2
2
|
import { DataSource } from '@sisense/sdk-data';
|
|
3
3
|
export interface QueryClient {
|
|
4
|
-
executeQuery(params: QueryDescription): ExecutingQueryResult;
|
|
4
|
+
executeQuery(params: QueryDescription, config?: QueryExecutionConfig): ExecutingQueryResult;
|
|
5
5
|
getDataSourceFields(dataSource: DataSource): Promise<DataSourceField[]>;
|
|
6
6
|
}
|
package/dist/query-client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataSourceField, ExecutingQueryResult, QueryDescription } from './types.js';
|
|
1
|
+
import { DataSourceField, ExecutingQueryResult, QueryDescription, QueryExecutionConfig } from './types.js';
|
|
2
2
|
import { QueryClient } from './interfaces.js';
|
|
3
3
|
import { DataSource } from '@sisense/sdk-data';
|
|
4
4
|
import { HttpClient } from '@sisense/sdk-rest-client';
|
|
@@ -16,7 +16,7 @@ export declare class DimensionalQueryClient implements QueryClient {
|
|
|
16
16
|
* @returns promise that resolves to query result data and cancel function that can be used to cancel sent query
|
|
17
17
|
* @throws Error if query description is invalid
|
|
18
18
|
*/
|
|
19
|
-
executeQuery(queryDescription: QueryDescription): ExecutingQueryResult;
|
|
19
|
+
executeQuery(queryDescription: QueryDescription, config?: QueryExecutionConfig): ExecutingQueryResult;
|
|
20
20
|
getDataSourceFields(dataSource: DataSource, count?: number, offset?: number): Promise<DataSourceField[]>;
|
|
21
21
|
}
|
|
22
22
|
/**
|
package/dist/query-client.js
CHANGED
|
@@ -29,9 +29,9 @@ export class DimensionalQueryClient {
|
|
|
29
29
|
* @returns promise that resolves to query result data and cancel function that can be used to cancel sent query
|
|
30
30
|
* @throws Error if query description is invalid
|
|
31
31
|
*/
|
|
32
|
-
executeQuery(queryDescription) {
|
|
32
|
+
executeQuery(queryDescription, config) {
|
|
33
33
|
validateQueryDescription(queryDescription);
|
|
34
|
-
const taskPassport = new QueryTaskPassport('SEND_JAQL_QUERY', queryDescription, this.shouldSkipHighlightsWithoutAttributes);
|
|
34
|
+
const taskPassport = new QueryTaskPassport('SEND_JAQL_QUERY', queryDescription, Object.assign(Object.assign({}, (config ? config : {})), { shouldSkipHighlightsWithoutAttributes: this.shouldSkipHighlightsWithoutAttributes || false }));
|
|
35
35
|
return {
|
|
36
36
|
resultPromise: new Promise((resolve, reject) => {
|
|
37
37
|
void this.taskManager.executeQuerySending(taskPassport).then((executionResult) => {
|
|
@@ -2,5 +2,11 @@ import { Cell, DataCell, Element, QueryResultData } from '@sisense/sdk-data';
|
|
|
2
2
|
import { JaqlResponse } from '../types.js';
|
|
3
3
|
export declare const getDataFromQueryResult: (result: JaqlResponse, metadata: Element[]) => QueryResultData;
|
|
4
4
|
export declare function prepareResultAsColsAndRows(data: DataCell[][], metadata: Element[]): QueryResultData;
|
|
5
|
+
/**
|
|
6
|
+
* Sets the `blur` property for each cell in a 2D array of data cells based on the `selected` property.
|
|
7
|
+
*
|
|
8
|
+
* @param rows - The 2D array of data cells representing rows and columns.
|
|
9
|
+
* @returns A new 2D array of cells with the `blur` property set.
|
|
10
|
+
*/
|
|
5
11
|
export declare function setCellsBlur(rows: DataCell[][]): Cell[][];
|
|
6
12
|
export declare function getQueryResultValues({ values, metadata }: JaqlResponse): DataCell[][];
|
|
@@ -14,13 +14,29 @@ export function prepareResultAsColsAndRows(data, metadata) {
|
|
|
14
14
|
rows: setCellsBlur(data),
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Sets the `blur` property for each cell in a 2D array of data cells based on the `selected` property.
|
|
19
|
+
*
|
|
20
|
+
* @param rows - The 2D array of data cells representing rows and columns.
|
|
21
|
+
* @returns A new 2D array of cells with the `blur` property set.
|
|
22
|
+
*/
|
|
17
23
|
export function setCellsBlur(rows) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
var _a;
|
|
25
|
+
// An array indicating whether `blur` is enabled per each column.
|
|
26
|
+
const blurEnabledPerColumn = (_a = rows[0]) === null || _a === void 0 ? void 0 : _a.map((_value, index) => {
|
|
27
|
+
return rows.some((r) => 'selected' in r[index]);
|
|
28
|
+
});
|
|
29
|
+
return rows.map((r) => {
|
|
30
|
+
// calculates a single `blur` value for a whole row based on each column (cell) configuration.
|
|
31
|
+
const blur = blurEnabledPerColumn.some((isBlurEnabled, columnIndex) => {
|
|
32
|
+
return isBlurEnabled && !r[columnIndex].selected;
|
|
33
|
+
});
|
|
34
|
+
return r.map((d) => ({
|
|
35
|
+
data: d.data,
|
|
36
|
+
text: d.text,
|
|
37
|
+
blur,
|
|
38
|
+
}));
|
|
39
|
+
});
|
|
24
40
|
}
|
|
25
41
|
export function getQueryResultValues({ values = [], metadata = [] }) {
|
|
26
42
|
var _a, _b, _c, _d;
|
|
@@ -8,6 +8,7 @@ export declare class QueryTaskManager extends AbstractTaskManager {
|
|
|
8
8
|
private sentRequestsAbortersMap;
|
|
9
9
|
private queryApi;
|
|
10
10
|
constructor(queryApi: QueryApiDispatcher);
|
|
11
|
+
private prepareJaqlPayload;
|
|
11
12
|
private sendJaqlQuery;
|
|
12
13
|
private cancelJaqlQuery;
|
|
13
14
|
executeQuerySending: (passport: QueryTaskPassport) => Promise<import("@sisense/task-manager").TaskExecutionResult<QueryResultData, EmptyObject>>;
|
|
@@ -16,16 +16,26 @@ export class QueryTaskManager extends AbstractTaskManager {
|
|
|
16
16
|
/** Map of aborters by task id to be able to cancel sent requests */
|
|
17
17
|
this.sentRequestsAbortersMap = new Map();
|
|
18
18
|
this.executeQuerySending = super.createFlow([
|
|
19
|
+
new Step('PREPARE_JAQL_PAYLOAD', this.prepareJaqlPayload.bind(this), () => __awaiter(this, void 0, void 0, function* () { })),
|
|
19
20
|
new Step('SEND_JAQL_QUERY', this.sendJaqlQuery.bind(this), this.cancelJaqlQuery.bind(this)),
|
|
20
21
|
]);
|
|
21
22
|
this.queryApi = queryApi;
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
+
prepareJaqlPayload(task) {
|
|
24
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
const { queryDescription,
|
|
26
|
-
const jaqlPayload = getJaqlQueryPayload(queryDescription, shouldSkipHighlightsWithoutAttributes);
|
|
26
|
+
const { queryDescription, executionConfig } = task.passport;
|
|
27
|
+
const jaqlPayload = getJaqlQueryPayload(queryDescription, executionConfig.shouldSkipHighlightsWithoutAttributes);
|
|
28
|
+
const onBeforeQuery = task.passport.executionConfig.onBeforeQuery;
|
|
29
|
+
if (onBeforeQuery) {
|
|
30
|
+
return onBeforeQuery(jaqlPayload);
|
|
31
|
+
}
|
|
32
|
+
return jaqlPayload;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
sendJaqlQuery(task, jaqlPayload) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const { queryDescription, taskId } = task.passport;
|
|
27
38
|
const { responsePromise, abortHttpRequest } = this.queryApi.sendJaqlRequest(task.passport.queryDescription.dataSource, jaqlPayload);
|
|
28
|
-
const taskId = task.passport.taskId;
|
|
29
39
|
this.sentRequestsAbortersMap.set(taskId, abortHttpRequest);
|
|
30
40
|
const jaqlResponse = yield responsePromise.finally(() => {
|
|
31
41
|
this.sentRequestsAbortersMap.delete(taskId);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TaskPassport } from '@sisense/task-manager';
|
|
2
|
-
import { QueryDescription } from '../types.js';
|
|
2
|
+
import { QueryDescription, QueryExecutionConfigInternal } from '../types.js';
|
|
3
3
|
type TaskType = 'SEND_JAQL_QUERY';
|
|
4
4
|
export declare class QueryTaskPassport extends TaskPassport {
|
|
5
5
|
queryDescription: QueryDescription;
|
|
6
|
-
|
|
6
|
+
executionConfig: QueryExecutionConfigInternal;
|
|
7
7
|
type: TaskType;
|
|
8
|
-
constructor(type: TaskType, queryDescription: QueryDescription,
|
|
8
|
+
constructor(type: TaskType, queryDescription: QueryDescription, executionConfig: QueryExecutionConfigInternal);
|
|
9
9
|
}
|
|
10
10
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { TaskPassport } from '@sisense/task-manager';
|
|
2
2
|
export class QueryTaskPassport extends TaskPassport {
|
|
3
|
-
constructor(type, queryDescription,
|
|
3
|
+
constructor(type, queryDescription, executionConfig) {
|
|
4
4
|
super();
|
|
5
5
|
this.queryDescription = queryDescription;
|
|
6
6
|
this.type = type;
|
|
7
|
-
this.
|
|
7
|
+
this.executionConfig = executionConfig;
|
|
8
8
|
}
|
|
9
9
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -11,6 +11,18 @@ export type QueryDescription = {
|
|
|
11
11
|
count?: number;
|
|
12
12
|
offset?: number;
|
|
13
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Additional configuration for query execution.
|
|
16
|
+
*/
|
|
17
|
+
export type QueryExecutionConfig = {
|
|
18
|
+
/**
|
|
19
|
+
* Sync or async callback that allows to modify the JAQL payload before it is sent to the server.
|
|
20
|
+
*/
|
|
21
|
+
onBeforeQuery?: (jaql: JaqlQueryPayload) => JaqlQueryPayload | Promise<JaqlQueryPayload>;
|
|
22
|
+
};
|
|
23
|
+
export type QueryExecutionConfigInternal = QueryExecutionConfig & {
|
|
24
|
+
shouldSkipHighlightsWithoutAttributes: boolean;
|
|
25
|
+
};
|
|
14
26
|
export type QueryOptions = {
|
|
15
27
|
datasource: string;
|
|
16
28
|
by: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sisense/sdk-query-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dist/index.js",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"author": "Sisense",
|
|
10
10
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@sisense/sdk-common": "^0.
|
|
13
|
-
"@sisense/sdk-data": "^0.
|
|
14
|
-
"@sisense/sdk-rest-client": "^0.
|
|
12
|
+
"@sisense/sdk-common": "^0.14.0",
|
|
13
|
+
"@sisense/sdk-data": "^0.14.0",
|
|
14
|
+
"@sisense/sdk-rest-client": "^0.14.0",
|
|
15
15
|
"@sisense/task-manager": "^0.1.0",
|
|
16
16
|
"numeral": "^2.0.6",
|
|
17
17
|
"uuid": "^9.0.0"
|