@sisense/sdk-query-client 1.19.0 → 1.21.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,6 +1,6 @@
1
1
  import { v4 as uuid } from 'uuid';
2
2
  import merge from 'ts-deepmerge';
3
- import { isPivotAttribute, isPivotMeasure, DEFAULT_PIVOT_GRAND_TOTALS, isDataSourceInfo, } from '@sisense/sdk-data';
3
+ import { isPivotAttribute, isPivotMeasure, DEFAULT_PIVOT_GRAND_TOTALS, convertJaqlDataSource, } from '@sisense/sdk-data';
4
4
  import { applyHighlightFilters, matchHighlightsWithAttributes } from './metadata/highlights.js';
5
5
  import { getPivotMetadataStats, normalizeLastRowSorting, preparePivotRowJaqlSortOptions, } from './pivot/pivot-query-utils.js';
6
6
  const JAQL_BY_CSDK = 'ComposeSDK';
@@ -56,7 +56,7 @@ function prepareQueryMetadata(metadataDescription, shouldSkipHighlightsWithoutAt
56
56
  return [...attributesMetadata, ...measuresMetadata, ...filtersMetadata];
57
57
  }
58
58
  export function prepareQueryOptions(dataSource, count, offset, includeUngroup) {
59
- return Object.assign(Object.assign(Object.assign({ datasource: getJaqlDataSource(dataSource), by: JAQL_BY_CSDK, queryGuid: uuid() }, (includeUngroup ? { ungroup: true } : {})), (count ? { count } : {})), (offset ? { offset } : {}));
59
+ return Object.assign(Object.assign(Object.assign({ datasource: convertJaqlDataSource(dataSource), by: JAQL_BY_CSDK, queryGuid: uuid() }, (includeUngroup ? { ungroup: true } : {})), (count ? { count } : {})), (offset ? { offset } : {}));
60
60
  }
61
61
  /**
62
62
  * Converts a pivot query description to a JAQL query payload.
@@ -120,16 +120,5 @@ function preparePivotQueryMetadata(pivotMetadataDescription, shouldSkipHighlight
120
120
  * @param offset
121
121
  */
122
122
  function preparePivotQueryOptions(dataSource, grandTotals, count, offset) {
123
- return Object.assign(Object.assign(Object.assign({ datasource: getJaqlDataSource(dataSource), by: JAQL_BY_CSDK, queryGuid: uuid(), dashboard: JAQL_BY_CSDK, widget: JAQL_BY_CSDK, format: 'pivot' }, (count ? { count } : {})), (offset ? { offset } : {})), { grandTotals: Object.assign(Object.assign({}, DEFAULT_PIVOT_GRAND_TOTALS), grandTotals) });
124
- }
125
- /**
126
- * Converts a DataSource to a description of data source used in JAQL.
127
- */
128
- function getJaqlDataSource(dataSource) {
129
- return isDataSourceInfo(dataSource)
130
- ? {
131
- title: dataSource.title,
132
- live: dataSource.type === 'live',
133
- }
134
- : dataSource;
123
+ return Object.assign(Object.assign(Object.assign({ datasource: convertJaqlDataSource(dataSource), by: JAQL_BY_CSDK, queryGuid: uuid(), dashboard: JAQL_BY_CSDK, widget: JAQL_BY_CSDK, format: 'pivot' }, (count ? { count } : {})), (offset ? { offset } : {})), { grandTotals: Object.assign(Object.assign({}, DEFAULT_PIVOT_GRAND_TOTALS), grandTotals) });
135
124
  }
@@ -16,7 +16,7 @@ export class QueryApiDispatcher {
16
16
  }
17
17
  getDataSourceFields(dataSource, count = 9999, offset = 0) {
18
18
  const dataSourceName = getDataSourceName(dataSource);
19
- const url = `${API_DATASOURCES_BASE_PATH}/${encodeURIComponent(dataSourceName)}/fields/search`;
19
+ const url = `${API_DATASOURCES_BASE_PATH}/${encodeURI(dataSourceName)}/fields/search`;
20
20
  // when error is encountered, API returns only status code 400 without informative error message
21
21
  // to remedy, catch error and throw a more informative error message
22
22
  return this.httpClient.post(url, { offset, count }).catch(() => {
@@ -133,7 +133,8 @@ export function validateQueryDescription(queryDescription) {
133
133
  }
134
134
  attributes.forEach((attribute) => {
135
135
  if (!attribute.skipValidation && !MetadataTypes.isAttribute(attribute)) {
136
- throw new TranslatableError('errors.invalidAttribute', { attributeName: attribute.name });
136
+ const { name: attributeName } = attribute;
137
+ throw new TranslatableError('errors.invalidAttribute', { attributeName });
137
138
  }
138
139
  });
139
140
  measures.forEach((measure) => {
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Filter, Measure, Attribute, Cell, QueryResultData, DataSource, PivotAttribute, PivotMeasure, PivotQueryResultData, PivotGrandTotals, FilterRelationsJaql } from '@sisense/sdk-data';
1
+ import { Filter, Measure, Attribute, Cell, QueryResultData, DataSource, PivotAttribute, PivotMeasure, PivotQueryResultData, PivotGrandTotals, FilterRelationsJaql, JaqlDataSource } from '@sisense/sdk-data';
2
2
  import { AnyObject } from './helpers/utility-types.js';
3
3
  /**
4
4
  * All the properties that fully describe a query you want to send.
@@ -41,13 +41,6 @@ export type QueryExecutionConfig = {
41
41
  export type QueryExecutionConfigInternal = QueryExecutionConfig & {
42
42
  shouldSkipHighlightsWithoutAttributes: boolean;
43
43
  };
44
- /**
45
- * Data source description used in JAQL.
46
- */
47
- export type JaqlDataSource = string | {
48
- title: string;
49
- live: boolean;
50
- };
51
44
  export type QueryOptions = {
52
45
  datasource: JaqlDataSource;
53
46
  by: string;
@@ -208,6 +201,7 @@ export type DataSourceSchema = {
208
201
  } & AnyObject;
209
202
  export type DataSourceMetadata = {
210
203
  title: string;
204
+ fullname: string;
211
205
  live: boolean;
212
206
  };
213
207
  export type AbortRequestFunction = (reason?: string) => void;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "Sisense",
12
12
  "Compose SDK"
13
13
  ],
14
- "version": "1.19.0",
14
+ "version": "1.21.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.19.0",
24
- "@sisense/sdk-data": "^1.19.0",
25
- "@sisense/sdk-pivot-client": "^1.19.0",
26
- "@sisense/sdk-rest-client": "^1.19.0",
23
+ "@sisense/sdk-common": "^1.21.0",
24
+ "@sisense/sdk-data": "^1.21.0",
25
+ "@sisense/sdk-pivot-client": "^1.21.0",
26
+ "@sisense/sdk-rest-client": "^1.21.0",
27
27
  "@sisense/task-manager": "^0.1.0",
28
28
  "numeral": "^2.0.6",
29
29
  "ts-deepmerge": "6.0.2",