@sisense/sdk-query-client 1.10.0 → 1.11.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.
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { JaqlQueryPayload, QueryDescription, PivotQueryDescription } from '../types.js';
|
|
1
|
+
import { JaqlQueryPayload, QueryDescription, PivotQueryDescription, QueryOptions } from '../types.js';
|
|
2
|
+
import { DataSource } from '@sisense/sdk-data';
|
|
2
3
|
/**
|
|
3
4
|
* @internal
|
|
4
5
|
*/
|
|
5
6
|
export declare function getJaqlQueryPayload(queryDescription: QueryDescription, shouldSkipHighlightsWithoutAttributes: boolean): JaqlQueryPayload;
|
|
7
|
+
export declare function prepareQueryOptions(dataSource: DataSource, count?: number, offset?: number, includeUngroup?: boolean): QueryOptions;
|
|
6
8
|
/**
|
|
7
9
|
* Converts a pivot query description to a JAQL query payload.
|
|
8
10
|
*
|
|
@@ -8,8 +8,13 @@ const JAQL_BY_CSDK = 'ComposeSDK';
|
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
10
|
export function getJaqlQueryPayload(queryDescription, shouldSkipHighlightsWithoutAttributes) {
|
|
11
|
-
const { attributes, measures, filters, filterRelations, highlights, dataSource, count, offset } = queryDescription;
|
|
12
|
-
|
|
11
|
+
const { attributes, measures, filters, filterRelations, highlights, dataSource, count, offset, ungroup, } = queryDescription;
|
|
12
|
+
// "ungroup: true" will be set in JAQL when two conditions are met:
|
|
13
|
+
// (1) ungroup is set to true
|
|
14
|
+
// AND
|
|
15
|
+
// (2) the query has no measures (unaggregated query)
|
|
16
|
+
const includeUngroup = ungroup && measures.length === 0;
|
|
17
|
+
const queryPayload = Object.assign({ metadata: prepareQueryMetadata({ attributes, measures, filters, filterRelations, highlights }, shouldSkipHighlightsWithoutAttributes) }, prepareQueryOptions(dataSource, count, offset, includeUngroup));
|
|
13
18
|
if (filterRelations) {
|
|
14
19
|
return Object.assign(Object.assign({}, queryPayload), { filterRelations });
|
|
15
20
|
}
|
|
@@ -43,8 +48,8 @@ function prepareQueryMetadata(metadataDescription, shouldSkipHighlightsWithoutAt
|
|
|
43
48
|
const filtersMetadata = prepareFilterMetadata(attributesMetadata, filters, filterRelations, highlights, shouldSkipHighlightsWithoutAttributes);
|
|
44
49
|
return [...attributesMetadata, ...measuresMetadata, ...filtersMetadata];
|
|
45
50
|
}
|
|
46
|
-
function prepareQueryOptions(dataSource, count, offset) {
|
|
47
|
-
return Object.assign(Object.assign({ datasource: getJaqlDataSource(dataSource), by: JAQL_BY_CSDK, queryGuid: uuid() }, (count ? { count } : {})), (offset ? { offset } : {}));
|
|
51
|
+
export function prepareQueryOptions(dataSource, count, offset, includeUngroup) {
|
|
52
|
+
return Object.assign(Object.assign(Object.assign({ datasource: getJaqlDataSource(dataSource), by: JAQL_BY_CSDK, queryGuid: uuid() }, (includeUngroup ? { ungroup: true } : {})), (count ? { count } : {})), (offset ? { offset } : {}));
|
|
48
53
|
}
|
|
49
54
|
/**
|
|
50
55
|
* Converts a pivot query description to a JAQL query payload.
|
|
@@ -119,7 +119,7 @@ export class QueryTaskManager extends AbstractTaskManager {
|
|
|
119
119
|
export function validateJaqlResponse(jaqlResponse) {
|
|
120
120
|
var _a;
|
|
121
121
|
if (jaqlResponse.error) {
|
|
122
|
-
throw new Error(`${jaqlResponse.details} ${(_a = jaqlResponse.database) !== null && _a !== void 0 ? _a : ''}`);
|
|
122
|
+
throw new Error(`${jaqlResponse.details} ${(_a = jaqlResponse.database) !== null && _a !== void 0 ? _a : ''} ${jaqlResponse.extraDetails ? JSON.stringify(jaqlResponse.extraDetails) : ''}`);
|
|
123
123
|
}
|
|
124
124
|
return true;
|
|
125
125
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type QueryDescription = {
|
|
|
12
12
|
filterRelations?: FilterRelationsJaql;
|
|
13
13
|
count?: number;
|
|
14
14
|
offset?: number;
|
|
15
|
+
ungroup?: boolean;
|
|
15
16
|
};
|
|
16
17
|
/**
|
|
17
18
|
* All the properties that fully describe a pivot query you want to send.
|
|
@@ -51,6 +52,9 @@ export type QueryOptions = {
|
|
|
51
52
|
datasource: JaqlDataSource;
|
|
52
53
|
by: string;
|
|
53
54
|
queryGuid: string;
|
|
55
|
+
count?: number;
|
|
56
|
+
offset?: number;
|
|
57
|
+
ungroup?: boolean;
|
|
54
58
|
dashboard?: string;
|
|
55
59
|
widget?: string;
|
|
56
60
|
format?: string;
|
|
@@ -192,6 +196,7 @@ export type JaqlResponse = {
|
|
|
192
196
|
values?: Cell[][] | Cell[];
|
|
193
197
|
error?: boolean;
|
|
194
198
|
details?: string;
|
|
199
|
+
extraDetails?: string;
|
|
195
200
|
type?: string;
|
|
196
201
|
errorSource?: string;
|
|
197
202
|
httpStatusCode?: number;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"Sisense",
|
|
12
12
|
"Compose SDK"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.11.0",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": "./dist/index.js",
|
|
17
17
|
"main": "./dist/index.js",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"author": "Sisense",
|
|
21
21
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@sisense/sdk-common": "^1.
|
|
24
|
-
"@sisense/sdk-data": "^1.
|
|
25
|
-
"@sisense/sdk-pivot-client": "^1.
|
|
26
|
-
"@sisense/sdk-rest-client": "^1.
|
|
23
|
+
"@sisense/sdk-common": "^1.11.0",
|
|
24
|
+
"@sisense/sdk-data": "^1.11.0",
|
|
25
|
+
"@sisense/sdk-pivot-client": "^1.11.0",
|
|
26
|
+
"@sisense/sdk-rest-client": "^1.11.0",
|
|
27
27
|
"@sisense/task-manager": "^0.1.0",
|
|
28
28
|
"numeral": "^2.0.6",
|
|
29
29
|
"ts-deepmerge": "6.0.2",
|