@sisense/sdk-query-client 0.16.0 → 1.0.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/jaql/get-jaql-query-payload.js +15 -5
- package/dist/types.d.ts +4 -1
- package/package.json +15 -4
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import { v4 as uuid } from 'uuid';
|
|
2
2
|
import { applyHighlightFilters, matchHighlightsWithAttributes } from './metadata/highlights.js';
|
|
3
3
|
export function getJaqlQueryPayload(queryDescription, shouldSkipHighlightsWithoutAttributes) {
|
|
4
|
-
const { attributes, measures, filters, highlights, dataSource, count, offset } = queryDescription;
|
|
5
|
-
|
|
4
|
+
const { attributes, measures, filters, filterRelations, highlights, dataSource, count, offset } = queryDescription;
|
|
5
|
+
const queryPayload = Object.assign({ metadata: prepareQueryMetadata({ attributes, measures, filters, filterRelations, highlights }, shouldSkipHighlightsWithoutAttributes) }, prepareQueryOptions(dataSource, count, offset));
|
|
6
|
+
if (filterRelations) {
|
|
7
|
+
return Object.assign(Object.assign({}, queryPayload), { filterRelations });
|
|
8
|
+
}
|
|
9
|
+
return queryPayload;
|
|
6
10
|
}
|
|
7
11
|
function prepareQueryMetadata(metadataDescription, shouldSkipHighlightsWithoutAttributes) {
|
|
8
|
-
const { attributes, measures, filters, highlights } = metadataDescription;
|
|
12
|
+
const { attributes, measures, filters, filterRelations, highlights } = metadataDescription;
|
|
9
13
|
const attributesMetadata = attributes.map((d) => d.jaql());
|
|
10
14
|
const measuresMetadata = measures.map((d) => d.jaql());
|
|
11
15
|
const [highlightsWithAttributes, highlightsWithoutAttributes] = matchHighlightsWithAttributes(attributesMetadata, highlights);
|
|
12
16
|
attributesMetadata.forEach((d) => applyHighlightFilters(d, highlightsWithAttributes));
|
|
17
|
+
const getFilterJaql = (f) => {
|
|
18
|
+
if (filterRelations) {
|
|
19
|
+
return Object.assign(Object.assign({}, f.jaql()), { instanceid: f.guid });
|
|
20
|
+
}
|
|
21
|
+
return f.jaql();
|
|
22
|
+
};
|
|
13
23
|
const filtersMetadata = (shouldSkipHighlightsWithoutAttributes
|
|
14
|
-
? filters.map((d) => d
|
|
15
|
-
: [...filters, ...highlightsWithoutAttributes].map((d) => d
|
|
24
|
+
? filters.map((d) => getFilterJaql(d))
|
|
25
|
+
: [...filters, ...highlightsWithoutAttributes].map((d) => getFilterJaql(d))).filter((f) => {
|
|
16
26
|
return Object.keys(f.jaql.filter || {}).length !== 0;
|
|
17
27
|
});
|
|
18
28
|
if (shouldSkipHighlightsWithoutAttributes && highlightsWithoutAttributes.length > 0) {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Filter, Measure, Attribute, Cell, QueryResultData, DataSource } from '@sisense/sdk-data';
|
|
1
|
+
import { Filter, Measure, Attribute, Cell, QueryResultData, DataSource, FilterRelation } from '@sisense/sdk-data';
|
|
2
2
|
/**
|
|
3
3
|
* All the properties that fully describe a query you want to send.
|
|
4
4
|
*/
|
|
@@ -8,6 +8,7 @@ export type QueryDescription = {
|
|
|
8
8
|
measures: Measure[];
|
|
9
9
|
filters: Filter[];
|
|
10
10
|
highlights: Filter[];
|
|
11
|
+
filterRelations?: FilterRelation;
|
|
11
12
|
count?: number;
|
|
12
13
|
offset?: number;
|
|
13
14
|
};
|
|
@@ -37,6 +38,7 @@ export type ExecutingCsvQueryResult = {
|
|
|
37
38
|
cancel: (reason?: string) => Promise<void>;
|
|
38
39
|
};
|
|
39
40
|
export type MetadataItem = {
|
|
41
|
+
instanceid?: string;
|
|
40
42
|
measure?: MetadataItemJaql;
|
|
41
43
|
jaql: MetadataItemJaql;
|
|
42
44
|
panel?: string;
|
|
@@ -74,6 +76,7 @@ export type MetadataItemJaql = {
|
|
|
74
76
|
filter?: MetadataItem;
|
|
75
77
|
};
|
|
76
78
|
export type JaqlQueryPayload = QueryOptions & {
|
|
79
|
+
filterRelations?: FilterRelation;
|
|
77
80
|
metadata: MetadataItem[];
|
|
78
81
|
};
|
|
79
82
|
export type DataSourceField = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sisense/sdk-query-client",
|
|
3
|
-
"
|
|
3
|
+
"homepage": "https://sisense.dev/guides/sdk/",
|
|
4
|
+
"description": "Compose SDK package for handling data queries against Sisense data sources",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/sisense/compose-sdk-monorepo",
|
|
8
|
+
"directory": "packages/sdk-query-client"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"Sisense",
|
|
12
|
+
"Compose SDK"
|
|
13
|
+
],
|
|
14
|
+
"version": "1.0.0",
|
|
4
15
|
"type": "module",
|
|
5
16
|
"exports": "./dist/index.js",
|
|
6
17
|
"main": "./dist/index.js",
|
|
@@ -9,9 +20,9 @@
|
|
|
9
20
|
"author": "Sisense",
|
|
10
21
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
11
22
|
"dependencies": {
|
|
12
|
-
"@sisense/sdk-common": "^0.
|
|
13
|
-
"@sisense/sdk-data": "^0.
|
|
14
|
-
"@sisense/sdk-rest-client": "^0.
|
|
23
|
+
"@sisense/sdk-common": "^1.0.0",
|
|
24
|
+
"@sisense/sdk-data": "^1.0.0",
|
|
25
|
+
"@sisense/sdk-rest-client": "^1.0.0",
|
|
15
26
|
"@sisense/task-manager": "^0.1.0",
|
|
16
27
|
"numeral": "^2.0.6",
|
|
17
28
|
"uuid": "^9.0.0"
|