@sisense/sdk-data 1.4.1 → 1.6.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.
@@ -115,10 +115,13 @@ export declare class DimensionalLevelAttribute extends DimensionalAttribute impl
115
115
  *
116
116
  * @param json - JSON object representing the attribute
117
117
  * @returns An Attribute instance
118
+ * @group Data Model Utilities
118
119
  */
119
120
  export declare function createAttribute(json: any): Attribute;
120
121
  /**
121
- * @param json
122
+ * Creates a LevelAttribute instance from the given JSON object.
123
+ *
124
+ * @param json - JSON object representing the level attribute
122
125
  * @internal
123
126
  */
124
127
  export declare function createLevel(json: any): LevelAttribute;
@@ -264,15 +264,18 @@ export class DimensionalLevelAttribute extends DimensionalAttribute {
264
264
  *
265
265
  * @param json - JSON object representing the attribute
266
266
  * @returns An Attribute instance
267
+ * @group Data Model Utilities
267
268
  */
268
269
  export function createAttribute(json) {
269
270
  if (json.granularity) {
270
271
  return createLevel(json);
271
272
  }
272
- return new DimensionalAttribute(json.name || json.title, json.attribute || json.expression || json.dim, json.type || json.desc || json.description);
273
+ return new DimensionalAttribute(json.name || json.title, json.attribute || json.expression || json.dim, json.type, json.desc || json.description);
273
274
  }
274
275
  /**
275
- * @param json
276
+ * Creates a LevelAttribute instance from the given JSON object.
277
+ *
278
+ * @param json - JSON object representing the level attribute
276
279
  * @internal
277
280
  */
278
281
  export function createLevel(json) {
@@ -42,5 +42,12 @@ export class DimensionalElement {
42
42
  * @internal
43
43
  */
44
44
  export function normalizeName(name) {
45
- return name.replace(/[\/\\!#,+()$~%.'":*?<>{}\-` \[\]]/g, '');
45
+ // Remove all invalid characters
46
+ let normalizedName = name.replace(/[^a-zA-Z0-9_]/g, '');
47
+ // Prefix with '_' if it starts with a number
48
+ const firstChar = normalizedName.charAt(0);
49
+ if (firstChar.match(/[0-9]/)) {
50
+ normalizedName = '_' + normalizedName;
51
+ }
52
+ return normalizedName;
46
53
  }
@@ -1,11 +1,11 @@
1
1
  import { DataModel, Element } from './interfaces.js';
2
- import { DataSource } from '../interfaces.js';
2
+ import { DataSource, DataSourceInfo } from '../interfaces.js';
3
3
  /**
4
4
  * @internal
5
5
  */
6
6
  export declare class DimensionalDataModel implements DataModel {
7
7
  static fromConfig(config: any): DimensionalDataModel;
8
- constructor(name: string, dataSource: DataSource, metadata: Element[]);
8
+ constructor(name: string, dataSource: DataSourceInfo, metadata: Element[]);
9
9
  readonly name: string;
10
10
  readonly dataSource: DataSource;
11
11
  readonly metadata: Element[];
@@ -150,6 +150,7 @@ export declare class DimensionalDateDimension extends DimensionalDimension imple
150
150
  *
151
151
  * @param json - JSON object representing the Dimension
152
152
  * @returns A new Dimension instance
153
+ * @group Data Model Utilities
153
154
  */
154
155
  export declare function createDimension(json: any): Dimension;
155
156
  /**
@@ -161,5 +162,6 @@ export declare function createDimension(json: any): Dimension;
161
162
  *
162
163
  * @param json - JSON object representing the Date Dimension
163
164
  * @returns A new Date Dimension instance
165
+ * @group Data Model Utilities
164
166
  */
165
167
  export declare function createDateDimension(json: any): DateDimension;
@@ -238,6 +238,7 @@ export class DimensionalDateDimension extends DimensionalDimension {
238
238
  *
239
239
  * @param json - JSON object representing the Dimension
240
240
  * @returns A new Dimension instance
241
+ * @group Data Model Utilities
241
242
  */
242
243
  export function createDimension(json) {
243
244
  const name = json.name || json.title;
@@ -289,6 +290,7 @@ export function createDimension(json) {
289
290
  *
290
291
  * @param json - JSON object representing the Date Dimension
291
292
  * @returns A new Date Dimension instance
293
+ * @group Data Model Utilities
292
294
  */
293
295
  export function createDateDimension(json) {
294
296
  const name = json.name || json.title;
@@ -1,9 +1,11 @@
1
+ import { DataSource } from '../interfaces.js';
1
2
  import { Sort } from './types.js';
2
3
  /**
3
4
  * @internal
4
5
  */
5
6
  export interface DataModel {
6
7
  readonly name: string;
8
+ readonly dataSource: DataSource;
7
9
  readonly metadata: Element[];
8
10
  [propName: string]: any;
9
11
  }
@@ -70,6 +70,7 @@ export declare const RankingSortTypes: {
70
70
  * @param formula - Formula to be used for the measure
71
71
  * @param context - Formula context as a map of strings to measures or attributes
72
72
  * @returns A calculated measure instance
73
+ * @group Advanced Analytics
73
74
  */
74
75
  export declare function customFormula(title: string, formula: string, context: CustomFormulaContext): Attribute | Measure;
75
76
  /**
@@ -88,6 +89,7 @@ export declare function customFormula(title: string, formula: string, context: C
88
89
  * @param name - Optional name for the new measure
89
90
  * @param format - Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc.
90
91
  * @returns A measure instance
92
+ * @group Aggregation
91
93
  */
92
94
  export declare function aggregate(attribute: Attribute, aggregationType: string, name?: string, format?: string): BaseMeasure;
93
95
  /**
@@ -100,6 +102,7 @@ export declare function aggregate(attribute: Attribute, aggregationType: string,
100
102
  * ```
101
103
  * @param value - Value to be returned as a measure
102
104
  * @returns A calculated measure instance
105
+ * @group Arithmetic
103
106
  */
104
107
  export declare function constant(value: number): CalculatedMeasure;
105
108
  /**
@@ -116,6 +119,7 @@ export declare function constant(value: number): CalculatedMeasure;
116
119
  * @param name - Optional name for the new measure
117
120
  * @param format - Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc.
118
121
  * @returns A measure instance
122
+ * @group Aggregation
119
123
  */
120
124
  export declare function sum(attribute: Attribute, name?: string, format?: string): BaseMeasure;
121
125
  /**
@@ -130,6 +134,7 @@ export declare function sum(attribute: Attribute, name?: string, format?: string
130
134
  * @param name - Optional name for the new measure
131
135
  * @param format - Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc.
132
136
  * @returns A measure instance
137
+ * @group Aggregation
133
138
  */
134
139
  export declare function average(attribute: Attribute, name?: string, format?: string): BaseMeasure;
135
140
  /**
@@ -144,6 +149,7 @@ export declare function average(attribute: Attribute, name?: string, format?: st
144
149
  * @param name - Optional name for the new measure
145
150
  * @param format - Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc.
146
151
  * @returns A measure instance
152
+ * @group Aggregation
147
153
  */
148
154
  export declare function min(attribute: Attribute, name?: string, format?: string): BaseMeasure;
149
155
  /**
@@ -158,6 +164,7 @@ export declare function min(attribute: Attribute, name?: string, format?: string
158
164
  * @param name - Optional name for the new measure
159
165
  * @param format - Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc.
160
166
  * @returns A measure instance
167
+ * @group Aggregation
161
168
  */
162
169
  export declare function max(attribute: Attribute, name?: string, format?: string): BaseMeasure;
163
170
  /**
@@ -172,6 +179,7 @@ export declare function max(attribute: Attribute, name?: string, format?: string
172
179
  * @param name - Optional name for the new measure
173
180
  * @param format - Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc.
174
181
  * @returns A measure instance
182
+ * @group Aggregation
175
183
  */
176
184
  export declare function median(attribute: Attribute, name?: string, format?: string): BaseMeasure;
177
185
  /**
@@ -188,6 +196,7 @@ export declare function median(attribute: Attribute, name?: string, format?: str
188
196
  * @param name - Optional name for the new measure
189
197
  * @param format - Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc.
190
198
  * @returns A measure instance
199
+ * @group Aggregation
191
200
  */
192
201
  export declare function count(attribute: Attribute, name?: string, format?: string): BaseMeasure;
193
202
  /**
@@ -204,6 +213,7 @@ export declare function count(attribute: Attribute, name?: string, format?: stri
204
213
  * @param name - Optional name for the new measure
205
214
  * @param format - Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc.
206
215
  * @returns A measure instance
216
+ * @group Aggregation
207
217
  */
208
218
  export declare function countDistinct(attribute: Attribute, name?: string, format?: string): BaseMeasure;
209
219
  /**
@@ -231,6 +241,7 @@ export declare function countDistinct(attribute: Attribute, name?: string, forma
231
241
  * @param name - Optional name for the new measure
232
242
  * @param format - Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc.
233
243
  * @returns A calculated measure instance
244
+ * @group Advanced Analytics
234
245
  */
235
246
  export declare function measuredValue(measure: Measure, filters: Filter[], name?: string, format?: string): CalculatedMeasure;
236
247
  /**
@@ -247,6 +258,7 @@ export declare function measuredValue(measure: Measure, filters: Filter[], name?
247
258
  * @param name - Optional name for the new measure
248
259
  * @param withParentheses - Optional boolean flag whether to wrap the arithmetic operation with parentheses
249
260
  * @returns A calculated measure instance
261
+ * @group Arithmetic
250
262
  */
251
263
  export declare function add(value1: Measure | number, value2: Measure | number, name?: string, withParentheses?: boolean): CalculatedMeasure;
252
264
  /**
@@ -263,6 +275,7 @@ export declare function add(value1: Measure | number, value2: Measure | number,
263
275
  * @param name - Optional name for the new measure
264
276
  * @param withParentheses - Optional boolean flag whether to wrap the arithmetic operation with parentheses
265
277
  * @returns A calculated measure instance
278
+ * @group Arithmetic
266
279
  */
267
280
  export declare function subtract(value1: Measure | number, value2: Measure | number, name?: string, withParentheses?: boolean): CalculatedMeasure;
268
281
  /**
@@ -279,6 +292,7 @@ export declare function subtract(value1: Measure | number, value2: Measure | num
279
292
  * @param name - Optional name for the new measure
280
293
  * @param withParentheses - Optional boolean flag whether to wrap the arithmetic operation with parentheses
281
294
  * @returns A calculated measure instance
295
+ * @group Arithmetic
282
296
  */
283
297
  export declare function multiply(value1: Measure | number, value2: Measure | number, name?: string, withParentheses?: boolean): CalculatedMeasure;
284
298
  /**
@@ -295,6 +309,7 @@ export declare function multiply(value1: Measure | number, value2: Measure | num
295
309
  * @param name - Optional name for the new measure
296
310
  * @param withParentheses - Optional boolean flag whether to wrap the arithmetic operation with parentheses
297
311
  * @returns A calculated measure instance
312
+ * @group Arithmetic
298
313
  */
299
314
  export declare function divide(value1: Measure | number, value2: Measure | number, name?: string, withParentheses?: boolean): CalculatedMeasure;
300
315
  /**
@@ -313,6 +328,7 @@ export declare function divide(value1: Measure | number, value2: Measure | numbe
313
328
  * @param measure - Measure to apply the YTD Sum to
314
329
  * @param name - Name for the new measure
315
330
  * @returns A calculated measure instance
331
+ * @group Time-based
316
332
  */
317
333
  export declare function yearToDateSum(measure: Measure, name?: string): CalculatedMeasure;
318
334
  /**
@@ -331,6 +347,7 @@ export declare function yearToDateSum(measure: Measure, name?: string): Calculat
331
347
  * @param measure - Measure to apply the QTD Sum to
332
348
  * @param name - Name for the new measure
333
349
  * @returns A calculated measure instance
350
+ * @group Time-based
334
351
  */
335
352
  export declare function quarterToDateSum(measure: Measure, name?: string): CalculatedMeasure;
336
353
  /**
@@ -349,6 +366,7 @@ export declare function quarterToDateSum(measure: Measure, name?: string): Calcu
349
366
  * @param measure - Measure to apply the MTD Sum to
350
367
  * @param name - Name for the new measure
351
368
  * @returns A calculated measure instance
369
+ * @group Time-based
352
370
  */
353
371
  export declare function monthToDateSum(measure: Measure, name?: string): CalculatedMeasure;
354
372
  /**
@@ -367,6 +385,7 @@ export declare function monthToDateSum(measure: Measure, name?: string): Calcula
367
385
  * @param measure - Measure to apply the WTD Sum to
368
386
  * @param name - Name for the new measure
369
387
  * @returns A calculated measure instance
388
+ * @group Time-based
370
389
  */
371
390
  export declare function weekToDateSum(measure: Measure, name?: string): CalculatedMeasure;
372
391
  /**
@@ -395,6 +414,7 @@ export declare function weekToDateSum(measure: Measure, name?: string): Calculat
395
414
  * when there are two or more dimensions. The default value is false.
396
415
  * @param name - Name for the new measure
397
416
  * @returns A calculated measure instance
417
+ * @group Statistics
398
418
  */
399
419
  export declare function runningSum(measure: Measure, _continuous?: boolean, name?: string): CalculatedMeasure;
400
420
  /**
@@ -422,6 +442,7 @@ export declare function runningSum(measure: Measure, _continuous?: boolean, name
422
442
  * @param measure - Measure to apply growth to
423
443
  * @param name - Name for the new measure
424
444
  * @returns A calculated measure instance
445
+ * @group Statistics
425
446
  */
426
447
  export declare function growth(measure: Measure, name?: string): CalculatedMeasure;
427
448
  /**
@@ -449,6 +470,7 @@ export declare function growth(measure: Measure, name?: string): CalculatedMeasu
449
470
  * @param measure - Measure to apply the Growth rate
450
471
  * @param name - Name for the new measure
451
472
  * @returns A calculated measure instance
473
+ * @group Statistics
452
474
  */
453
475
  export declare function growthRate(measure: Measure, name?: string): CalculatedMeasure;
454
476
  /**
@@ -475,6 +497,7 @@ export declare function growthRate(measure: Measure, name?: string): CalculatedM
475
497
  * @param measure - Measure to apply growth to
476
498
  * @param name - Name for the new measure
477
499
  * @returns A calculated measure instance
500
+ * @group Statistics
478
501
  */
479
502
  export declare function growthPastWeek(measure: Measure, name?: string): CalculatedMeasure;
480
503
  /**
@@ -501,6 +524,7 @@ export declare function growthPastWeek(measure: Measure, name?: string): Calcula
501
524
  * @param measure - Measure to apply growth to
502
525
  * @param name - Name for the new measure
503
526
  * @returns A calculated measure instance
527
+ * @group Statistics
504
528
  */
505
529
  export declare function growthPastMonth(measure: Measure, name?: string): CalculatedMeasure;
506
530
  /**
@@ -527,6 +551,7 @@ export declare function growthPastMonth(measure: Measure, name?: string): Calcul
527
551
  * @param measure - Measure to apply growth to
528
552
  * @param name - Name for the new measure
529
553
  * @returns A calculated measure instance
554
+ * @group Statistics
530
555
  */
531
556
  export declare function growthPastQuarter(measure: Measure, name?: string): CalculatedMeasure;
532
557
  /**
@@ -553,6 +578,7 @@ export declare function growthPastQuarter(measure: Measure, name?: string): Calc
553
578
  * @param measure - Measure to apply growth to
554
579
  * @param name - Name for the new measure
555
580
  * @returns A calculated measure instance
581
+ * @group Statistics
556
582
  */
557
583
  export declare function growthPastYear(measure: Measure, name?: string): CalculatedMeasure;
558
584
  /**
@@ -571,6 +597,7 @@ export declare function growthPastYear(measure: Measure, name?: string): Calcula
571
597
  * @param measure - Measure to apply difference to
572
598
  * @param name - Name for the new measure
573
599
  * @returns A calculated measure instance
600
+ * @group Time-based
574
601
  */
575
602
  export declare function difference(measure: Measure, name?: string): CalculatedMeasure;
576
603
  /**
@@ -588,6 +615,7 @@ export declare function difference(measure: Measure, name?: string): CalculatedM
588
615
  * @param measure - Measure to apply difference to
589
616
  * @param name - Name for the new measure
590
617
  * @returns A calculated measure instance
618
+ * @group Time-based
591
619
  */
592
620
  export declare function diffPastWeek(measure: Measure, name?: string): CalculatedMeasure;
593
621
  /**
@@ -605,6 +633,7 @@ export declare function diffPastWeek(measure: Measure, name?: string): Calculate
605
633
  * @param measure - Measure to apply difference to
606
634
  * @param name - Name for the new measure
607
635
  * @returns A calculated measure instance
636
+ * @group Time-based
608
637
  */
609
638
  export declare function diffPastMonth(measure: Measure, name?: string): CalculatedMeasure;
610
639
  /**
@@ -622,6 +651,7 @@ export declare function diffPastMonth(measure: Measure, name?: string): Calculat
622
651
  * @param measure - Measure to apply difference to
623
652
  * @param name - Name for the new measure
624
653
  * @returns A calculated measure instance
654
+ * @group Time-based
625
655
  */
626
656
  export declare function diffPastQuarter(measure: Measure, name?: string): CalculatedMeasure;
627
657
  /**
@@ -639,6 +669,7 @@ export declare function diffPastQuarter(measure: Measure, name?: string): Calcul
639
669
  * @param measure - Measure to apply difference to
640
670
  * @param name - Name for the new measure
641
671
  * @returns A calculated measure instance
672
+ * @group Time-based
642
673
  */
643
674
  export declare function diffPastYear(measure: Measure, name?: string): CalculatedMeasure;
644
675
  /**
@@ -652,6 +683,7 @@ export declare function diffPastYear(measure: Measure, name?: string): Calculate
652
683
  * @param measure - Measure to apply past value to
653
684
  * @param name - Name for the new measure
654
685
  * @returns A calculated measure instance
686
+ * @group Time-based
655
687
  */
656
688
  export declare function pastDay(measure: Measure, name?: string): CalculatedMeasure;
657
689
  /**
@@ -668,6 +700,7 @@ export declare function pastDay(measure: Measure, name?: string): CalculatedMeas
668
700
  * @param measure - Measure to apply past value to
669
701
  * @param name - Name for the new measure
670
702
  * @returns A calculated measure instance
703
+ * @group Time-based
671
704
  */
672
705
  export declare function pastWeek(measure: Measure, name?: string): CalculatedMeasure;
673
706
  /**
@@ -685,6 +718,7 @@ export declare function pastWeek(measure: Measure, name?: string): CalculatedMea
685
718
  * @param measure - Measure to apply past value to
686
719
  * @param name - Name for the new measure
687
720
  * @returns A calculated measure instance
721
+ * @group Time-based
688
722
  */
689
723
  export declare function pastMonth(measure: Measure, name?: string): CalculatedMeasure;
690
724
  /**
@@ -702,6 +736,7 @@ export declare function pastMonth(measure: Measure, name?: string): CalculatedMe
702
736
  * @param measure - Measure to apply past value to
703
737
  * @param name - Name for the new measure
704
738
  * @returns A calculated measure instance
739
+ * @group Time-based
705
740
  */
706
741
  export declare function pastQuarter(measure: Measure, name?: string): CalculatedMeasure;
707
742
  /**
@@ -719,6 +754,7 @@ export declare function pastQuarter(measure: Measure, name?: string): Calculated
719
754
  * @param measure - Measure to apply past value to
720
755
  * @param name - Name for the new measure
721
756
  * @returns A calculated measure instance
757
+ * @group Time-based
722
758
  */
723
759
  export declare function pastYear(measure: Measure, name?: string): CalculatedMeasure;
724
760
  /**
@@ -753,6 +789,7 @@ export declare function pastYear(measure: Measure, name?: string): CalculatedMea
753
789
  * @param measure - Measure to apply the Contribution logic to
754
790
  * @param name - Name for the new measure
755
791
  * @returns A calculated measure instance
792
+ * @group Statistics
756
793
  */
757
794
  export declare function contribution(measure: Measure, name?: string): CalculatedMeasure;
758
795
  /**
@@ -779,6 +816,7 @@ export declare function contribution(measure: Measure, name?: string): Calculate
779
816
  * @param name - Name for the new measure
780
817
  * @param options - Trend options
781
818
  * @returns A calculated measure instance
819
+ * @group Advanced Analytics
782
820
  */
783
821
  export declare function trend(measure: Measure, name?: string, options?: TrendFormulaOptions): CalculatedMeasure;
784
822
  /**
@@ -813,6 +851,7 @@ export declare function trend(measure: Measure, name?: string, options?: TrendFo
813
851
  * @param name - Name for the new measure
814
852
  * @param options - Forecast options
815
853
  * @returns A calculated measure instance
854
+ * @group Advanced Analytics
816
855
  */
817
856
  export declare function forecast(measure: Measure, name?: string, options?: ForecastFormulaOptions): CalculatedMeasure;
818
857
  /**
@@ -863,5 +902,6 @@ export declare function forecast(measure: Measure, name?: string, options?: Fore
863
902
  * @param rankType - How to handle equally ranked items. By default the type is standard competition ranking.
864
903
  * @param groupBy - Rank partition attributes
865
904
  * @returns A calculated measure instance
905
+ * @group Statistics
866
906
  */
867
907
  export declare function rank(measure: Measure, name?: string, sort?: string, rankType?: string, groupBy?: Attribute[]): CalculatedMeasure;
@@ -135,6 +135,7 @@ function transformCustomFormulaJaql(jaql) {
135
135
  * @param formula - Formula to be used for the measure
136
136
  * @param context - Formula context as a map of strings to measures or attributes
137
137
  * @returns A calculated measure instance
138
+ * @group Advanced Analytics
138
139
  */
139
140
  export function customFormula(title, formula, context) {
140
141
  const newContext = Object.entries(context).reduce((acc, [key, val]) => {
@@ -174,6 +175,7 @@ function arithmetic(operand1, operator, operand2, name, withParentheses) {
174
175
  * @param name - Optional name for the new measure
175
176
  * @param format - Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc.
176
177
  * @returns A measure instance
178
+ * @group Aggregation
177
179
  */
178
180
  export function aggregate(attribute, aggregationType, name, format) {
179
181
  return new DimensionalBaseMeasure(name !== null && name !== void 0 ? name : `${aggregationType.toString()} ${attribute.name}`, attribute, aggregationType, format);
@@ -188,6 +190,7 @@ export function aggregate(attribute, aggregationType, name, format) {
188
190
  * ```
189
191
  * @param value - Value to be returned as a measure
190
192
  * @returns A calculated measure instance
193
+ * @group Arithmetic
191
194
  */
192
195
  export function constant(value) {
193
196
  return new DimensionalCalculatedMeasure(`${value}`, `${value}`, {});
@@ -206,6 +209,7 @@ export function constant(value) {
206
209
  * @param name - Optional name for the new measure
207
210
  * @param format - Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc.
208
211
  * @returns A measure instance
212
+ * @group Aggregation
209
213
  */
210
214
  export function sum(attribute, name, format) {
211
215
  return aggregate(attribute, AggregationTypes.Sum, name, format);
@@ -222,6 +226,7 @@ export function sum(attribute, name, format) {
222
226
  * @param name - Optional name for the new measure
223
227
  * @param format - Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc.
224
228
  * @returns A measure instance
229
+ * @group Aggregation
225
230
  */
226
231
  export function average(attribute, name, format) {
227
232
  return aggregate(attribute, AggregationTypes.Average, name, format);
@@ -238,6 +243,7 @@ export function average(attribute, name, format) {
238
243
  * @param name - Optional name for the new measure
239
244
  * @param format - Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc.
240
245
  * @returns A measure instance
246
+ * @group Aggregation
241
247
  */
242
248
  export function min(attribute, name, format) {
243
249
  return aggregate(attribute, AggregationTypes.Min, name, format);
@@ -254,6 +260,7 @@ export function min(attribute, name, format) {
254
260
  * @param name - Optional name for the new measure
255
261
  * @param format - Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc.
256
262
  * @returns A measure instance
263
+ * @group Aggregation
257
264
  */
258
265
  export function max(attribute, name, format) {
259
266
  return aggregate(attribute, AggregationTypes.Max, name, format);
@@ -270,6 +277,7 @@ export function max(attribute, name, format) {
270
277
  * @param name - Optional name for the new measure
271
278
  * @param format - Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc.
272
279
  * @returns A measure instance
280
+ * @group Aggregation
273
281
  */
274
282
  export function median(attribute, name, format) {
275
283
  return aggregate(attribute, AggregationTypes.Median, name, format);
@@ -288,6 +296,7 @@ export function median(attribute, name, format) {
288
296
  * @param name - Optional name for the new measure
289
297
  * @param format - Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc.
290
298
  * @returns A measure instance
299
+ * @group Aggregation
291
300
  */
292
301
  export function count(attribute, name, format) {
293
302
  return aggregate(attribute, AggregationTypes.Count, name, format);
@@ -306,6 +315,7 @@ export function count(attribute, name, format) {
306
315
  * @param name - Optional name for the new measure
307
316
  * @param format - Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc.
308
317
  * @returns A measure instance
318
+ * @group Aggregation
309
319
  */
310
320
  export function countDistinct(attribute, name, format) {
311
321
  return aggregate(attribute, AggregationTypes.CountDistinct, name, format);
@@ -335,6 +345,7 @@ export function countDistinct(attribute, name, format) {
335
345
  * @param name - Optional name for the new measure
336
346
  * @param format - Optional numeric formatting to apply using a Numeral.js format string. Can only be used for explicit queries. Cannot be used in charts, tables, etc.
337
347
  * @returns A calculated measure instance
348
+ * @group Advanced Analytics
338
349
  */
339
350
  export function measuredValue(measure, filters, name, format) {
340
351
  const builder = [];
@@ -363,6 +374,7 @@ export function measuredValue(measure, filters, name, format) {
363
374
  * @param name - Optional name for the new measure
364
375
  * @param withParentheses - Optional boolean flag whether to wrap the arithmetic operation with parentheses
365
376
  * @returns A calculated measure instance
377
+ * @group Arithmetic
366
378
  */
367
379
  export function add(value1, value2, name, withParentheses) {
368
380
  return arithmetic(value1, '+', value2, name, withParentheses);
@@ -381,6 +393,7 @@ export function add(value1, value2, name, withParentheses) {
381
393
  * @param name - Optional name for the new measure
382
394
  * @param withParentheses - Optional boolean flag whether to wrap the arithmetic operation with parentheses
383
395
  * @returns A calculated measure instance
396
+ * @group Arithmetic
384
397
  */
385
398
  export function subtract(value1, value2, name, withParentheses) {
386
399
  return arithmetic(value1, '-', value2, name, withParentheses);
@@ -399,6 +412,7 @@ export function subtract(value1, value2, name, withParentheses) {
399
412
  * @param name - Optional name for the new measure
400
413
  * @param withParentheses - Optional boolean flag whether to wrap the arithmetic operation with parentheses
401
414
  * @returns A calculated measure instance
415
+ * @group Arithmetic
402
416
  */
403
417
  export function multiply(value1, value2, name, withParentheses) {
404
418
  return arithmetic(value1, '*', value2, name, withParentheses);
@@ -417,6 +431,7 @@ export function multiply(value1, value2, name, withParentheses) {
417
431
  * @param name - Optional name for the new measure
418
432
  * @param withParentheses - Optional boolean flag whether to wrap the arithmetic operation with parentheses
419
433
  * @returns A calculated measure instance
434
+ * @group Arithmetic
420
435
  */
421
436
  export function divide(value1, value2, name, withParentheses) {
422
437
  return arithmetic(value1, '/', value2, name, withParentheses);
@@ -437,6 +452,7 @@ export function divide(value1, value2, name, withParentheses) {
437
452
  * @param measure - Measure to apply the YTD Sum to
438
453
  * @param name - Name for the new measure
439
454
  * @returns A calculated measure instance
455
+ * @group Time-based
440
456
  */
441
457
  export function yearToDateSum(measure, name) {
442
458
  return measureFunction(measure, name !== null && name !== void 0 ? name : 'YTD ' + measure.name, 'YTDSum');
@@ -457,6 +473,7 @@ export function yearToDateSum(measure, name) {
457
473
  * @param measure - Measure to apply the QTD Sum to
458
474
  * @param name - Name for the new measure
459
475
  * @returns A calculated measure instance
476
+ * @group Time-based
460
477
  */
461
478
  export function quarterToDateSum(measure, name) {
462
479
  return measureFunction(measure, name !== null && name !== void 0 ? name : 'QTD ' + name, 'QTDSum');
@@ -477,6 +494,7 @@ export function quarterToDateSum(measure, name) {
477
494
  * @param measure - Measure to apply the MTD Sum to
478
495
  * @param name - Name for the new measure
479
496
  * @returns A calculated measure instance
497
+ * @group Time-based
480
498
  */
481
499
  export function monthToDateSum(measure, name) {
482
500
  return measureFunction(measure, name !== null && name !== void 0 ? name : 'MTD ' + measure.name, 'MTDSum');
@@ -497,6 +515,7 @@ export function monthToDateSum(measure, name) {
497
515
  * @param measure - Measure to apply the WTD Sum to
498
516
  * @param name - Name for the new measure
499
517
  * @returns A calculated measure instance
518
+ * @group Time-based
500
519
  */
501
520
  export function weekToDateSum(measure, name) {
502
521
  return measureFunction(measure, name !== null && name !== void 0 ? name : 'MTD ' + measure.name, 'WTDSum');
@@ -527,6 +546,7 @@ export function weekToDateSum(measure, name) {
527
546
  * when there are two or more dimensions. The default value is false.
528
547
  * @param name - Name for the new measure
529
548
  * @returns A calculated measure instance
549
+ * @group Statistics
530
550
  */
531
551
  export function runningSum(measure, _continuous, name) {
532
552
  return measureFunction(measure, name !== null && name !== void 0 ? name : 'Running Sum ' + measure.name, 'RSum');
@@ -556,6 +576,7 @@ export function runningSum(measure, _continuous, name) {
556
576
  * @param measure - Measure to apply growth to
557
577
  * @param name - Name for the new measure
558
578
  * @returns A calculated measure instance
579
+ * @group Statistics
559
580
  */
560
581
  export function growth(measure, name) {
561
582
  return measureFunction(measure, name !== null && name !== void 0 ? name : measure.name + ' Growth', 'growth');
@@ -585,6 +606,7 @@ export function growth(measure, name) {
585
606
  * @param measure - Measure to apply the Growth rate
586
607
  * @param name - Name for the new measure
587
608
  * @returns A calculated measure instance
609
+ * @group Statistics
588
610
  */
589
611
  export function growthRate(measure, name) {
590
612
  return measureFunction(measure, name !== null && name !== void 0 ? name : measure.name + ' Growth', 'growthrate');
@@ -613,6 +635,7 @@ export function growthRate(measure, name) {
613
635
  * @param measure - Measure to apply growth to
614
636
  * @param name - Name for the new measure
615
637
  * @returns A calculated measure instance
638
+ * @group Statistics
616
639
  */
617
640
  export function growthPastWeek(measure, name) {
618
641
  return measureFunction(measure, name !== null && name !== void 0 ? name : measure.name + ' Growth', 'growthpastweek');
@@ -641,6 +664,7 @@ export function growthPastWeek(measure, name) {
641
664
  * @param measure - Measure to apply growth to
642
665
  * @param name - Name for the new measure
643
666
  * @returns A calculated measure instance
667
+ * @group Statistics
644
668
  */
645
669
  export function growthPastMonth(measure, name) {
646
670
  return measureFunction(measure, name !== null && name !== void 0 ? name : measure.name + ' Growth', 'growthpastmonth');
@@ -669,6 +693,7 @@ export function growthPastMonth(measure, name) {
669
693
  * @param measure - Measure to apply growth to
670
694
  * @param name - Name for the new measure
671
695
  * @returns A calculated measure instance
696
+ * @group Statistics
672
697
  */
673
698
  export function growthPastQuarter(measure, name) {
674
699
  return measureFunction(measure, name !== null && name !== void 0 ? name : measure.name + ' Growth', 'growthpastquarter');
@@ -697,6 +722,7 @@ export function growthPastQuarter(measure, name) {
697
722
  * @param measure - Measure to apply growth to
698
723
  * @param name - Name for the new measure
699
724
  * @returns A calculated measure instance
725
+ * @group Statistics
700
726
  */
701
727
  export function growthPastYear(measure, name) {
702
728
  return measureFunction(measure, name !== null && name !== void 0 ? name : measure.name + ' Growth', 'growthpastyear');
@@ -717,6 +743,7 @@ export function growthPastYear(measure, name) {
717
743
  * @param measure - Measure to apply difference to
718
744
  * @param name - Name for the new measure
719
745
  * @returns A calculated measure instance
746
+ * @group Time-based
720
747
  */
721
748
  export function difference(measure, name) {
722
749
  return measureFunction(measure, name !== null && name !== void 0 ? name : measure.name + ' Difference', 'diffpastperiod');
@@ -736,6 +763,7 @@ export function difference(measure, name) {
736
763
  * @param measure - Measure to apply difference to
737
764
  * @param name - Name for the new measure
738
765
  * @returns A calculated measure instance
766
+ * @group Time-based
739
767
  */
740
768
  export function diffPastWeek(measure, name) {
741
769
  return measureFunction(measure, name !== null && name !== void 0 ? name : measure.name + ' Difference', 'diffpastweek');
@@ -755,6 +783,7 @@ export function diffPastWeek(measure, name) {
755
783
  * @param measure - Measure to apply difference to
756
784
  * @param name - Name for the new measure
757
785
  * @returns A calculated measure instance
786
+ * @group Time-based
758
787
  */
759
788
  export function diffPastMonth(measure, name) {
760
789
  return measureFunction(measure, name !== null && name !== void 0 ? name : measure.name + ' Difference', 'diffpastmonth');
@@ -774,6 +803,7 @@ export function diffPastMonth(measure, name) {
774
803
  * @param measure - Measure to apply difference to
775
804
  * @param name - Name for the new measure
776
805
  * @returns A calculated measure instance
806
+ * @group Time-based
777
807
  */
778
808
  export function diffPastQuarter(measure, name) {
779
809
  return measureFunction(measure, name !== null && name !== void 0 ? name : measure.name + ' Difference', 'diffpastquarter');
@@ -793,6 +823,7 @@ export function diffPastQuarter(measure, name) {
793
823
  * @param measure - Measure to apply difference to
794
824
  * @param name - Name for the new measure
795
825
  * @returns A calculated measure instance
826
+ * @group Time-based
796
827
  */
797
828
  export function diffPastYear(measure, name) {
798
829
  return measureFunction(measure, name !== null && name !== void 0 ? name : measure.name + ' Difference', 'diffpastyear');
@@ -808,6 +839,7 @@ export function diffPastYear(measure, name) {
808
839
  * @param measure - Measure to apply past value to
809
840
  * @param name - Name for the new measure
810
841
  * @returns A calculated measure instance
842
+ * @group Time-based
811
843
  */
812
844
  export function pastDay(measure, name) {
813
845
  return measureFunction(measure, name !== null && name !== void 0 ? name : measure.name + ' Past Day', 'pastday');
@@ -826,6 +858,7 @@ export function pastDay(measure, name) {
826
858
  * @param measure - Measure to apply past value to
827
859
  * @param name - Name for the new measure
828
860
  * @returns A calculated measure instance
861
+ * @group Time-based
829
862
  */
830
863
  export function pastWeek(measure, name) {
831
864
  return measureFunction(measure, name !== null && name !== void 0 ? name : measure.name + ' Past Week', 'pastweek');
@@ -845,6 +878,7 @@ export function pastWeek(measure, name) {
845
878
  * @param measure - Measure to apply past value to
846
879
  * @param name - Name for the new measure
847
880
  * @returns A calculated measure instance
881
+ * @group Time-based
848
882
  */
849
883
  export function pastMonth(measure, name) {
850
884
  return measureFunction(measure, name !== null && name !== void 0 ? name : measure.name + ' Past Month', 'pastmonth');
@@ -864,6 +898,7 @@ export function pastMonth(measure, name) {
864
898
  * @param measure - Measure to apply past value to
865
899
  * @param name - Name for the new measure
866
900
  * @returns A calculated measure instance
901
+ * @group Time-based
867
902
  */
868
903
  export function pastQuarter(measure, name) {
869
904
  return measureFunction(measure, name !== null && name !== void 0 ? name : measure.name + ' Past Quarter', 'pastquarter');
@@ -883,6 +918,7 @@ export function pastQuarter(measure, name) {
883
918
  * @param measure - Measure to apply past value to
884
919
  * @param name - Name for the new measure
885
920
  * @returns A calculated measure instance
921
+ * @group Time-based
886
922
  */
887
923
  export function pastYear(measure, name) {
888
924
  return measureFunction(measure, name !== null && name !== void 0 ? name : measure.name + ' Past Year', 'pastyear');
@@ -919,6 +955,7 @@ export function pastYear(measure, name) {
919
955
  * @param measure - Measure to apply the Contribution logic to
920
956
  * @param name - Name for the new measure
921
957
  * @returns A calculated measure instance
958
+ * @group Statistics
922
959
  */
923
960
  export function contribution(measure, name) {
924
961
  return measureFunction(measure, name !== null && name !== void 0 ? name : measure.name + ' Contribution', 'contribution');
@@ -947,6 +984,7 @@ export function contribution(measure, name) {
947
984
  * @param name - Name for the new measure
948
985
  * @param options - Trend options
949
986
  * @returns A calculated measure instance
987
+ * @group Advanced Analytics
950
988
  */
951
989
  export function trend(measure, name, options) {
952
990
  let params;
@@ -992,6 +1030,7 @@ export function trend(measure, name, options) {
992
1030
  * @param name - Name for the new measure
993
1031
  * @param options - Forecast options
994
1032
  * @returns A calculated measure instance
1033
+ * @group Advanced Analytics
995
1034
  */
996
1035
  export function forecast(measure, name, options) {
997
1036
  let params;
@@ -1065,6 +1104,7 @@ export function forecast(measure, name, options) {
1065
1104
  * @param rankType - How to handle equally ranked items. By default the type is standard competition ranking.
1066
1105
  * @param groupBy - Rank partition attributes
1067
1106
  * @returns A calculated measure instance
1107
+ * @group Statistics
1068
1108
  */
1069
1109
  export function rank(measure, name, sort = RankingSortTypes.Descending, rankType = RankingTypes.StandardCompetition, groupBy = []) {
1070
1110
  const builder = [];
package/dist/index.d.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import './translation/initialize-i18n.js';
2
2
  /**
3
3
  * @packageDocumentation
4
+ * @group Factories
5
+ * Functions for creating measures, filters, and advanced analytics elements.
6
+ * @group Data Model Utilities
7
+ * Utility functions for creating attributes and dimensions in code.
4
8
  */
5
9
  export * from './interfaces.js';
6
10
  export * from './dimensional-model/types.js';
@@ -42,6 +46,7 @@ export * from './dimensional-model/filters/filters.js';
42
46
  * }
43
47
  * return null;
44
48
  * ```
49
+ * @group Factories
45
50
  */
46
51
  export * as filterFactory from './dimensional-model/filters/factory.js';
47
52
  export * from './dimensional-model/measures/measures.js';
@@ -76,11 +81,14 @@ export * from './dimensional-model/measures/measures.js';
76
81
  * }
77
82
  * return null;
78
83
  * ```
84
+ * @group Factories
79
85
  */
80
86
  export * as measureFactory from './dimensional-model/measures/factory.js';
81
87
  export * from './dimensional-model/simple-column-types.js';
82
88
  /**
83
89
  * Functions to create elements for advanced analytics – for example, attributes and measures for constructing a custom Boxplot chart
90
+ *
91
+ * @group Factories
84
92
  */
85
93
  export * as analyticsFactory from './dimensional-model/analytics/factory.js';
86
94
  export * from './utils.js';
package/dist/index.js CHANGED
@@ -1,6 +1,10 @@
1
1
  import './translation/initialize-i18n.js';
2
2
  /**
3
3
  * @packageDocumentation
4
+ * @group Factories
5
+ * Functions for creating measures, filters, and advanced analytics elements.
6
+ * @group Data Model Utilities
7
+ * Utility functions for creating attributes and dimensions in code.
4
8
  */
5
9
  export * from './interfaces.js';
6
10
  export * from './dimensional-model/types.js';
@@ -42,6 +46,7 @@ export * from './dimensional-model/filters/filters.js';
42
46
  * }
43
47
  * return null;
44
48
  * ```
49
+ * @group Factories
45
50
  */
46
51
  export * as filterFactory from './dimensional-model/filters/factory.js';
47
52
  export * from './dimensional-model/measures/measures.js';
@@ -76,11 +81,14 @@ export * from './dimensional-model/measures/measures.js';
76
81
  * }
77
82
  * return null;
78
83
  * ```
84
+ * @group Factories
79
85
  */
80
86
  export * as measureFactory from './dimensional-model/measures/factory.js';
81
87
  export * from './dimensional-model/simple-column-types.js';
82
88
  /**
83
89
  * Functions to create elements for advanced analytics – for example, attributes and measures for constructing a custom Boxplot chart
90
+ *
91
+ * @group Factories
84
92
  */
85
93
  export * as analyticsFactory from './dimensional-model/analytics/factory.js';
86
94
  export * from './utils.js';
@@ -122,10 +122,17 @@ export interface CalculatedMeasureColumn {
122
122
  */
123
123
  title?: string;
124
124
  }
125
+ /**
126
+ * Info of data source
127
+ */
128
+ export declare type DataSourceInfo = {
129
+ title: string;
130
+ type: 'live' | 'elasticube';
131
+ };
125
132
  /**
126
133
  * Data source for queries to run against
127
134
  */
128
- export declare type DataSource = string;
135
+ export declare type DataSource = string | DataSourceInfo;
129
136
  /**
130
137
  * Data set, which is made up of an array of {@link Column | columns}
131
138
  * and a two-dimensional array of data {@link Cell | cells}.
@@ -13,5 +13,5 @@ export const EMPTY_PIVOT_QUERY_RESULT_DATA = {
13
13
  * @internal
14
14
  */
15
15
  export function isDataSource(arg) {
16
- return arg === undefined || typeof arg === 'string';
16
+ return arg === undefined || typeof arg === 'string' || ('title' in arg && 'type' in arg);
17
17
  }
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Filter, FilterRelations, FilterRelationsJaql } from './index.js';
1
+ import { Filter, FilterRelations, FilterRelationsJaql, DataSource, DataSourceInfo } 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
  *
@@ -14,3 +14,13 @@ export declare const getFilterListAndRelations: (filterRelations: FilterRelation
14
14
  filters: Filter[] | undefined;
15
15
  relations: FilterRelationsJaql | undefined;
16
16
  };
17
+ /**
18
+ * Gets the name of the data source
19
+ * @internal
20
+ */
21
+ export declare function getDataSourceName(dataSource: DataSource): string;
22
+ /**
23
+ * Checks if the provided 'dataSource' is a data source info structure that contains more than just the data source name.
24
+ * @internal
25
+ */
26
+ export declare function isDataSourceInfo(dataSource: DataSource): dataSource is DataSourceInfo;
package/dist/utils.js CHANGED
@@ -61,3 +61,17 @@ export const getFilterListAndRelations = (filterRelations) => {
61
61
  const relations = traverse(copiedFilterRelations);
62
62
  return { filters: Array.from(filters), relations };
63
63
  };
64
+ /**
65
+ * Gets the name of the data source
66
+ * @internal
67
+ */
68
+ export function getDataSourceName(dataSource) {
69
+ return typeof dataSource === 'string' ? dataSource : dataSource.title;
70
+ }
71
+ /**
72
+ * Checks if the provided 'dataSource' is a data source info structure that contains more than just the data source name.
73
+ * @internal
74
+ */
75
+ export function isDataSourceInfo(dataSource) {
76
+ return typeof dataSource === 'object' && 'type' in dataSource && 'title' in dataSource;
77
+ }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "Sisense",
12
12
  "Compose SDK"
13
13
  ],
14
- "version": "1.4.1",
14
+ "version": "1.6.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.4.1",
27
- "@sisense/sdk-rest-client": "^1.4.1",
26
+ "@sisense/sdk-common": "^1.6.0",
27
+ "@sisense/sdk-rest-client": "^1.6.0",
28
28
  "guid-typescript": "^1.0.9",
29
29
  "lodash": "^4.17.21",
30
30
  "numeral": "^2.0.6",