@sisense/sdk-data 1.2.0 → 1.3.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,4 +1,4 @@
1
- import { DateDimension, LevelAttribute, Attribute, Measure, Filter, BaseMeasure, FilterRelationNode, FilterRelation } from '../interfaces.js';
1
+ import { DateDimension, LevelAttribute, Attribute, Measure, Filter, BaseMeasure, FilterRelationsNode, FilterRelations } from '../interfaces.js';
2
2
  /**
3
3
  * Creates a filter representing the union of multiple filters on the same attribute. The resulting
4
4
  * union filter filters on items that match any of the given filters.
@@ -632,7 +632,7 @@ export declare function topRanking(attribute: Attribute, measure: Measure, count
632
632
  */
633
633
  export declare function bottomRanking(attribute: Attribute, measure: Measure, count: number): Filter;
634
634
  /**
635
- * Set of logic operators for filter relation construction
635
+ * Set of logic operators for filter relations construction
636
636
  *
637
637
  * These operators are still in beta.
638
638
  *
@@ -646,7 +646,7 @@ export declare function bottomRanking(attribute: Attribute, measure: Measure, co
646
646
  * const genderFilter = filterFactory.doesntContain(DM.Commerce.Gender, 'Unspecified');
647
647
  * const costFilter = filterFactory.between(DM.Commerce.Cost, 1000, 2000);
648
648
  *
649
- * // create filter relation of two filters
649
+ * // create filter relations of two filters
650
650
  * const orFilerRelations = filterFactory.logic.or(revenueFilter, countryFilter);
651
651
  * // revenueFilter OR countryFilter
652
652
  *
@@ -662,10 +662,10 @@ export declare function bottomRanking(attribute: Attribute, measure: Measure, co
662
662
  */
663
663
  export declare namespace logic {
664
664
  /**
665
- * Creates an 'AND' filter relation
665
+ * Creates an 'AND' filter relations
666
666
  *
667
667
  * @example
668
- * Create a filter relation for items that have a revenue greater than 100 and are in new condition
668
+ * Create filter relations for items that have a revenue greater than 100 and are in new condition
669
669
  * in the Sample ECommerce data model.
670
670
  * ```ts
671
671
  * const revenueFilter = filterFactory.greaterThan(DM.Commerce.Revenue, 100);
@@ -673,17 +673,17 @@ export declare namespace logic {
673
673
  *
674
674
  * const andFilerRelation = filterFactory.logic.and(revenueFilter, conditionFilter);
675
675
  * ```
676
- * @param left First filter or filter relation
677
- * @param right Second filter or filter relation
678
- * @returns A filter relation
676
+ * @param left First filter or filter relations
677
+ * @param right Second filter or filter relations
678
+ * @returns Filter relations
679
679
  * @beta
680
680
  */
681
- const and: (left: FilterRelationNode, right: FilterRelationNode) => FilterRelation;
681
+ const and: (left: FilterRelationsNode, right: FilterRelationsNode) => FilterRelations;
682
682
  /**
683
- * Creates an 'OR' filter relation
683
+ * Creates an 'OR' filter relations
684
684
  *
685
685
  * @example
686
- * Create a filter relation for items that have a revenue greater than 100 or are in new condition
686
+ * Create filter relations for items that have a revenue greater than 100 or are in new condition
687
687
  * in the Sample ECommerce data model.
688
688
  * ```ts
689
689
  * const revenueFilter = filterFactory.greaterThan(DM.Commerce.Revenue, 100);
@@ -691,10 +691,10 @@ export declare namespace logic {
691
691
  *
692
692
  * const orFilerRelation = filterFactory.logic.or(revenueFilter, conditionFilter);
693
693
  * ```
694
- * @param left First filter or filter relation
695
- * @param right Second filter or filter relation
696
- * @returns A filter relation
694
+ * @param left First filter or filter relations
695
+ * @param right Second filter or filter relations
696
+ * @returns Filter relations
697
697
  * @beta
698
698
  */
699
- const or: (left: FilterRelationNode, right: FilterRelationNode) => FilterRelation;
699
+ const or: (left: FilterRelationsNode, right: FilterRelationsNode) => FilterRelations;
700
700
  }
@@ -734,7 +734,7 @@ const relate = (node) => {
734
734
  return node;
735
735
  };
736
736
  /**
737
- * Set of logic operators for filter relation construction
737
+ * Set of logic operators for filter relations construction
738
738
  *
739
739
  * These operators are still in beta.
740
740
  *
@@ -748,7 +748,7 @@ const relate = (node) => {
748
748
  * const genderFilter = filterFactory.doesntContain(DM.Commerce.Gender, 'Unspecified');
749
749
  * const costFilter = filterFactory.between(DM.Commerce.Cost, 1000, 2000);
750
750
  *
751
- * // create filter relation of two filters
751
+ * // create filter relations of two filters
752
752
  * const orFilerRelations = filterFactory.logic.or(revenueFilter, countryFilter);
753
753
  * // revenueFilter OR countryFilter
754
754
  *
@@ -766,10 +766,10 @@ const relate = (node) => {
766
766
  export var logic;
767
767
  (function (logic) {
768
768
  /**
769
- * Creates an 'AND' filter relation
769
+ * Creates an 'AND' filter relations
770
770
  *
771
771
  * @example
772
- * Create a filter relation for items that have a revenue greater than 100 and are in new condition
772
+ * Create filter relations for items that have a revenue greater than 100 and are in new condition
773
773
  * in the Sample ECommerce data model.
774
774
  * ```ts
775
775
  * const revenueFilter = filterFactory.greaterThan(DM.Commerce.Revenue, 100);
@@ -777,9 +777,9 @@ export var logic;
777
777
  *
778
778
  * const andFilerRelation = filterFactory.logic.and(revenueFilter, conditionFilter);
779
779
  * ```
780
- * @param left First filter or filter relation
781
- * @param right Second filter or filter relation
782
- * @returns A filter relation
780
+ * @param left First filter or filter relations
781
+ * @param right Second filter or filter relations
782
+ * @returns Filter relations
783
783
  * @beta
784
784
  */
785
785
  logic.and = (left, right) => ({
@@ -788,10 +788,10 @@ export var logic;
788
788
  right: relate(right),
789
789
  });
790
790
  /**
791
- * Creates an 'OR' filter relation
791
+ * Creates an 'OR' filter relations
792
792
  *
793
793
  * @example
794
- * Create a filter relation for items that have a revenue greater than 100 or are in new condition
794
+ * Create filter relations for items that have a revenue greater than 100 or are in new condition
795
795
  * in the Sample ECommerce data model.
796
796
  * ```ts
797
797
  * const revenueFilter = filterFactory.greaterThan(DM.Commerce.Revenue, 100);
@@ -799,9 +799,9 @@ export var logic;
799
799
  *
800
800
  * const orFilerRelation = filterFactory.logic.or(revenueFilter, conditionFilter);
801
801
  * ```
802
- * @param left First filter or filter relation
803
- * @param right Second filter or filter relation
804
- * @returns A filter relation
802
+ * @param left First filter or filter relations
803
+ * @param right Second filter or filter relations
804
+ * @returns Filter relations
805
805
  * @beta
806
806
  */
807
807
  logic.or = (left, right) => ({
@@ -346,15 +346,6 @@ export interface Filter extends Element {
346
346
  export interface CustomFormulaContext {
347
347
  [key: string]: Attribute | Measure;
348
348
  }
349
- export declare type FilterRelationNode = Filter | Filter[] | FilterRelation | FilterRelationJaqlNode;
350
- export interface FilterRelation {
351
- left: FilterRelationNode;
352
- right: FilterRelationNode;
353
- operator: 'AND' | 'OR';
354
- }
355
- export declare type FilterRelationJaqlNode = {
356
- instanceid: string;
357
- };
358
349
  /**
359
350
  * Wrapped attribute with additional options for pivot table
360
351
  */
@@ -396,3 +387,64 @@ export declare type PivotGrandTotals = {
396
387
  * @internal
397
388
  */
398
389
  export declare const DEFAULT_PIVOT_GRAND_TOTALS: PivotGrandTotals;
390
+ /** A node or a subtree of a {@link FilterRelations} tree */
391
+ export declare type FilterRelationsNode = Filter | Filter[] | FilterRelations;
392
+ /**
393
+ * A node or a subtree of a {@link FilterRelationsModel} tree
394
+ *
395
+ * @internal
396
+ */
397
+ export declare type FilterRelationsModelNode = FilterRelationsModelIdNode | FilterRelationsModelBracketNode | FilterRelationsModel;
398
+ /**
399
+ * A node or a subtree of a {@link FilterRelationsJaql} tree
400
+ *
401
+ * @internal
402
+ */
403
+ export declare type FilterRelationsJaqlNode = FilterRelationsJaqlIdNode | FilterRelationsJaql;
404
+ /**
405
+ * Representation of filter logical relations (AND/OR)
406
+ *
407
+ * Unlike {@link FilterRelationsModel} or {@link FilterRelationsJaql},
408
+ * this interface contains filter objects, not just id nodes
409
+ */
410
+ export interface FilterRelations {
411
+ left: FilterRelationsNode;
412
+ right: FilterRelationsNode;
413
+ operator: 'AND' | 'OR';
414
+ }
415
+ /**
416
+ * Incoming filter logical relations (AND/OR) when fetched from the instance
417
+ *
418
+ * @internal
419
+ */
420
+ export interface FilterRelationsModel {
421
+ left: FilterRelationsModelNode;
422
+ right: FilterRelationsModelNode;
423
+ operator: 'AND' | 'OR';
424
+ }
425
+ /**
426
+ * Outgoing filter logical relations (AND/OR) when added to a query
427
+ *
428
+ * @internal
429
+ */
430
+ export interface FilterRelationsJaql {
431
+ left: FilterRelationsJaqlNode;
432
+ right: FilterRelationsJaqlNode;
433
+ operator: 'AND' | 'OR';
434
+ }
435
+ /** A node of a {@link FilterRelationsJaql} tree that represents a filter */
436
+ export declare type FilterRelationsJaqlIdNode = {
437
+ instanceid: string;
438
+ };
439
+ /** A node of a {@link FilterRelationsModel} tree that represents a filter */
440
+ export declare type FilterRelationsModelIdNode = {
441
+ instanceId: string;
442
+ };
443
+ /**
444
+ * A node of a {@link FilterRelationsModel} tree that represents a bracket expression
445
+ *
446
+ * @internal
447
+ */
448
+ export declare type FilterRelationsModelBracketNode = {
449
+ value: FilterRelationsModelNode;
450
+ };
@@ -150,16 +150,20 @@ export declare const DateLevels: {
150
150
  /** @internal */
151
151
  readonly all: string[];
152
152
  };
153
+ /** @internal */
153
154
  export declare enum DataType {
154
155
  TEXT = "text",
155
156
  NUMERIC = "numeric",
156
157
  DATETIME = "datetime"
157
158
  }
159
+ /** @internal */
158
160
  export declare enum SortDirection {
159
161
  ASC = "asc",
160
162
  DESC = "desc"
161
163
  }
164
+ /** @internal */
162
165
  export declare type Jaql = BaseJaql | FormulaJaql | FilterJaql;
166
+ /** @internal */
163
167
  export declare type BaseJaql = {
164
168
  agg?: string;
165
169
  datatype: DataType;
@@ -170,8 +174,11 @@ export declare type BaseJaql = {
170
174
  level?: 'years' | 'quarters' | 'months' | 'weeks' | 'minutes' | 'days';
171
175
  sort?: SortDirection;
172
176
  };
177
+ /** @internal */
173
178
  export declare type FormulaID = string;
179
+ /** @internal */
174
180
  export declare type FormulaContext = BaseJaql | FormulaJaql | FilterJaql;
181
+ /** @internal */
175
182
  export declare type FormulaJaql = {
176
183
  type?: 'measure';
177
184
  sort?: SortDirection;
@@ -179,24 +186,31 @@ export declare type FormulaJaql = {
179
186
  formula: string;
180
187
  context?: Record<FormulaID, FormulaContext>;
181
188
  };
189
+ /** @internal */
182
190
  export declare type BaseFilter = IncludeAllFilter | IncludeMembersFilter | ExcludeMembersFilter;
191
+ /** @internal */
183
192
  export declare type BackgroundFilter = BaseFilter & {
184
193
  level?: 'string';
185
194
  };
195
+ /** @internal */
186
196
  export declare type IncludeAllFilter = {
187
197
  all: true;
188
198
  };
199
+ /** @internal */
189
200
  export declare type IncludeMembersFilter = {
190
201
  members: string[];
191
202
  };
203
+ /** @internal */
192
204
  export declare type ExcludeMembersFilter = {
193
205
  exclude: {
194
206
  members: string[];
195
207
  };
196
208
  };
209
+ /** @internal */
197
210
  export declare type TurnOffMembersFilter = ExcludeMembersFilter & {
198
211
  turnedOff: boolean;
199
212
  };
213
+ /** @internal */
200
214
  export declare type FilterJaql = BaseJaql & {
201
215
  filter: BaseFilter & {
202
216
  filter?: BackgroundFilter | TurnOffMembersFilter;
@@ -282,12 +282,14 @@ export const DateLevels = {
282
282
  ];
283
283
  },
284
284
  };
285
+ /** @internal */
285
286
  export var DataType;
286
287
  (function (DataType) {
287
288
  DataType["TEXT"] = "text";
288
289
  DataType["NUMERIC"] = "numeric";
289
290
  DataType["DATETIME"] = "datetime";
290
291
  })(DataType = DataType || (DataType = {}));
292
+ /** @internal */
291
293
  export var SortDirection;
292
294
  (function (SortDirection) {
293
295
  SortDirection["ASC"] = "asc";
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Filter, FilterRelation } from './index.js';
1
+ import { Filter, FilterRelations, FilterRelationsJaql } from './index.js';
2
2
  /**
3
3
  * A more performant, but slightly bulkier, RFC4122v4 implementation. Performance is improved by minimizing calls to random()
4
4
  *
@@ -10,7 +10,7 @@ export declare const guidFast: (len?: number) => string;
10
10
  *
11
11
  * @internal
12
12
  */
13
- export declare const getFilterListAndRelations: (filterRelations: FilterRelation | Filter[] | undefined) => {
13
+ export declare const getFilterListAndRelations: (filterRelations: FilterRelations | Filter[] | undefined) => {
14
14
  filters: Filter[] | undefined;
15
- relations: FilterRelation | undefined;
15
+ relations: FilterRelationsJaql | undefined;
16
16
  };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "Sisense",
12
12
  "Compose SDK"
13
13
  ],
14
- "version": "1.2.0",
14
+ "version": "1.3.0",
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": "./dist/index.js",
@@ -23,8 +23,8 @@
23
23
  "author": "Sisense ",
24
24
  "license": "SEE LICENSE IN LICENSE.md",
25
25
  "dependencies": {
26
- "@sisense/sdk-common": "^1.2.0",
27
- "@sisense/sdk-rest-client": "^1.2.0",
26
+ "@sisense/sdk-common": "^1.3.0",
27
+ "@sisense/sdk-rest-client": "^1.3.0",
28
28
  "guid-typescript": "^1.0.9",
29
29
  "lodash": "^4.17.21",
30
30
  "numeral": "^2.0.6",