@cubejs-client/ngx 0.28.51 → 0.29.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/CHANGELOG.md +16 -0
- package/dist/bundles/cubejs-client-ngx.umd.js +106 -639
- package/dist/bundles/cubejs-client-ngx.umd.js.map +1 -1
- package/dist/esm2015/cubejs-client-ngx.js +2 -7
- package/dist/esm2015/index.js +2 -7
- package/dist/esm2015/src/client.js +18 -77
- package/dist/esm2015/src/module.js +2 -10
- package/dist/esm2015/src/public_api.js +8 -13
- package/dist/esm2015/src/query-builder/builder-meta.js +7 -46
- package/dist/esm2015/src/query-builder/chart-type.js +1 -9
- package/dist/esm2015/src/query-builder/common.js +1 -23
- package/dist/esm2015/src/query-builder/pivot-config.js +1 -20
- package/dist/esm2015/src/query-builder/query-builder.service.js +23 -156
- package/dist/esm2015/src/query-builder/query-members.js +29 -275
- package/dist/esm2015/src/query-builder/query.js +11 -68
- package/dist/fesm2015/cubejs-client-ngx.js +88 -686
- package/dist/fesm2015/cubejs-client-ngx.js.map +1 -1
- package/dist/src/query-builder/query-members.d.ts +1 -1
- package/package.json +17 -19
- package/dist/CHANGELOG.md +0 -914
- package/dist/bundles/cubejs-client-ngx.umd.min.js +0 -2
- package/dist/bundles/cubejs-client-ngx.umd.min.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('@cubejs-client/core'), require('rxjs/operators'), require('fast-deep-equal')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define('@cubejs-client/ngx', ['exports', '@angular/core', 'rxjs', '@cubejs-client/core', 'rxjs/operators', 'fast-deep-equal'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global[
|
|
5
|
-
}(this, (function (exports, core, rxjs, cubejs, operators, equal) { 'use strict';
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["cubejs-client"] = global["cubejs-client"] || {}, global["cubejs-client"].ngx = {}), global.ng.core, global.rxjs, global.cubejs, global.rxjs.operators, global.equal));
|
|
5
|
+
})(this, (function (exports, core, rxjs, cubejs, operators, equal) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -328,95 +328,53 @@
|
|
|
328
328
|
}
|
|
329
329
|
|
|
330
330
|
var CubejsClient = /** @class */ (function () {
|
|
331
|
-
/**
|
|
332
|
-
* @param {?} config
|
|
333
|
-
*/
|
|
334
331
|
function CubejsClient(config) {
|
|
335
332
|
var _this = this;
|
|
336
333
|
this.config = config;
|
|
337
334
|
this.ready$ = new rxjs.BehaviorSubject(false);
|
|
338
335
|
if (this.config instanceof rxjs.Observable) {
|
|
339
|
-
this.config.subscribe((
|
|
340
|
-
* @return {?}
|
|
341
|
-
*/function () {
|
|
336
|
+
this.config.subscribe(function () {
|
|
342
337
|
_this.ready$.next(true);
|
|
343
|
-
})
|
|
338
|
+
});
|
|
344
339
|
}
|
|
345
340
|
else {
|
|
346
341
|
this.ready$.next(true);
|
|
347
342
|
}
|
|
348
343
|
}
|
|
349
|
-
/**
|
|
350
|
-
* @private
|
|
351
|
-
* @return {?}
|
|
352
|
-
*/
|
|
353
344
|
CubejsClient.prototype.apiInstace = function () {
|
|
354
345
|
var _this = this;
|
|
355
346
|
if (!this.cubeJsApi) {
|
|
356
347
|
if (this.config instanceof rxjs.Observable) {
|
|
357
|
-
this.config.subscribe((
|
|
358
|
-
|
|
359
|
-
* @return {?}
|
|
360
|
-
*/function (config) {
|
|
361
|
-
_this.cubeJsApi = cubejs__default['default'](config.token, config.options);
|
|
348
|
+
this.config.subscribe(function (config) {
|
|
349
|
+
_this.cubeJsApi = cubejs__default["default"](config.token, config.options);
|
|
362
350
|
if (!_this.cubeJsApi) {
|
|
363
351
|
throw new Error('Cannot create CubejsApi instance. Please check that the config is passed correctly and contains all required options.');
|
|
364
352
|
}
|
|
365
|
-
})
|
|
353
|
+
});
|
|
366
354
|
}
|
|
367
355
|
else {
|
|
368
|
-
this.cubeJsApi = cubejs__default[
|
|
356
|
+
this.cubeJsApi = cubejs__default["default"](this.config.token, this.config.options);
|
|
369
357
|
}
|
|
370
358
|
}
|
|
371
359
|
return this.cubeJsApi;
|
|
372
360
|
};
|
|
373
|
-
/**
|
|
374
|
-
* @param {?} query
|
|
375
|
-
* @param {?=} options
|
|
376
|
-
* @return {?}
|
|
377
|
-
*/
|
|
378
361
|
CubejsClient.prototype.load = function (query, options) {
|
|
379
|
-
return rxjs.from(
|
|
362
|
+
return rxjs.from(this.apiInstace().load(query, options));
|
|
380
363
|
};
|
|
381
|
-
/**
|
|
382
|
-
* @param {?} query
|
|
383
|
-
* @param {?=} options
|
|
384
|
-
* @return {?}
|
|
385
|
-
*/
|
|
386
364
|
CubejsClient.prototype.sql = function (query, options) {
|
|
387
365
|
return rxjs.from(this.apiInstace().sql(query, options));
|
|
388
366
|
};
|
|
389
|
-
/**
|
|
390
|
-
* @param {?} query
|
|
391
|
-
* @param {?=} options
|
|
392
|
-
* @return {?}
|
|
393
|
-
*/
|
|
394
367
|
CubejsClient.prototype.dryRun = function (query, options) {
|
|
395
368
|
return rxjs.from(this.apiInstace().dryRun(query, options));
|
|
396
369
|
};
|
|
397
|
-
/**
|
|
398
|
-
* @param {?=} options
|
|
399
|
-
* @return {?}
|
|
400
|
-
*/
|
|
401
370
|
CubejsClient.prototype.meta = function (options) {
|
|
402
371
|
return rxjs.from(this.apiInstace().meta(options));
|
|
403
372
|
};
|
|
404
|
-
/**
|
|
405
|
-
* @param {?} query
|
|
406
|
-
* @param {?=} params
|
|
407
|
-
* @return {?}
|
|
408
|
-
*/
|
|
409
373
|
CubejsClient.prototype.watch = function (query, params) {
|
|
410
374
|
var _this = this;
|
|
411
375
|
if (params === void 0) { params = {}; }
|
|
412
|
-
return new rxjs.Observable((
|
|
413
|
-
|
|
414
|
-
* @return {?}
|
|
415
|
-
*/function (observer) { return query.subscribe({
|
|
416
|
-
next: ( /**
|
|
417
|
-
* @param {?} query
|
|
418
|
-
* @return {?}
|
|
419
|
-
*/function (query) { return __awaiter(_this, void 0, void 0, function () {
|
|
376
|
+
return new rxjs.Observable(function (observer) { return query.subscribe({
|
|
377
|
+
next: function (query) { return __awaiter(_this, void 0, void 0, function () {
|
|
420
378
|
var resultSet;
|
|
421
379
|
return __generator(this, function (_a) {
|
|
422
380
|
switch (_a.label) {
|
|
@@ -427,45 +385,29 @@
|
|
|
427
385
|
return [2 /*return*/];
|
|
428
386
|
}
|
|
429
387
|
});
|
|
430
|
-
}); }
|
|
431
|
-
}); })
|
|
388
|
+
}); },
|
|
389
|
+
}); });
|
|
432
390
|
};
|
|
433
391
|
return CubejsClient;
|
|
434
392
|
}());
|
|
393
|
+
/** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
|
|
435
394
|
CubejsClient.decorators = [
|
|
436
395
|
{ type: core.Injectable }
|
|
437
396
|
];
|
|
438
|
-
/**
|
|
397
|
+
/**
|
|
398
|
+
* @type {function(): !Array<(null|{
|
|
399
|
+
* type: ?,
|
|
400
|
+
* decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
|
|
401
|
+
* })>}
|
|
402
|
+
* @nocollapse
|
|
403
|
+
*/
|
|
439
404
|
CubejsClient.ctorParameters = function () { return [
|
|
440
405
|
{ type: undefined, decorators: [{ type: core.Inject, args: ['config',] }] }
|
|
441
406
|
]; };
|
|
442
|
-
if (false) {
|
|
443
|
-
/** @type {?} */
|
|
444
|
-
CubejsClient.prototype.ready$;
|
|
445
|
-
/**
|
|
446
|
-
* @type {?}
|
|
447
|
-
* @private
|
|
448
|
-
*/
|
|
449
|
-
CubejsClient.prototype.cubeJsApi;
|
|
450
|
-
/**
|
|
451
|
-
* @type {?}
|
|
452
|
-
* @private
|
|
453
|
-
*/
|
|
454
|
-
CubejsClient.prototype.config;
|
|
455
|
-
}
|
|
456
407
|
|
|
457
|
-
/**
|
|
458
|
-
* @fileoverview added by tsickle
|
|
459
|
-
* Generated from: src/module.ts
|
|
460
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
461
|
-
*/
|
|
462
408
|
var CubejsClientModule = /** @class */ (function () {
|
|
463
409
|
function CubejsClientModule() {
|
|
464
410
|
}
|
|
465
|
-
/**
|
|
466
|
-
* @param {?} config
|
|
467
|
-
* @return {?}
|
|
468
|
-
*/
|
|
469
411
|
CubejsClientModule.forRoot = function (config) {
|
|
470
412
|
return {
|
|
471
413
|
ngModule: CubejsClientModule,
|
|
@@ -480,157 +422,79 @@
|
|
|
480
422
|
};
|
|
481
423
|
return CubejsClientModule;
|
|
482
424
|
}());
|
|
425
|
+
/** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
|
|
483
426
|
CubejsClientModule.decorators = [
|
|
484
427
|
{ type: core.NgModule, args: [{
|
|
485
428
|
providers: [CubejsClient],
|
|
486
429
|
},] }
|
|
487
430
|
];
|
|
488
431
|
|
|
489
|
-
/**
|
|
490
|
-
* @fileoverview added by tsickle
|
|
491
|
-
* Generated from: src/query-builder/common.ts
|
|
492
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
493
|
-
*/
|
|
494
|
-
/**
|
|
495
|
-
* @template T
|
|
496
|
-
*/
|
|
497
432
|
var StateSubject = /** @class */ (function () {
|
|
498
|
-
/**
|
|
499
|
-
* @param {?} value
|
|
500
|
-
*/
|
|
501
433
|
function StateSubject(value) {
|
|
502
434
|
this.subject = new rxjs.BehaviorSubject(value);
|
|
503
435
|
}
|
|
504
|
-
/**
|
|
505
|
-
* @return {?}
|
|
506
|
-
*/
|
|
507
436
|
StateSubject.prototype.get = function () {
|
|
508
437
|
return this.subject.getValue();
|
|
509
438
|
};
|
|
510
|
-
/**
|
|
511
|
-
* @param {?} value
|
|
512
|
-
* @return {?}
|
|
513
|
-
*/
|
|
514
439
|
StateSubject.prototype.set = function (value) {
|
|
515
440
|
this.subject.next(value);
|
|
516
441
|
};
|
|
517
442
|
return StateSubject;
|
|
518
443
|
}());
|
|
519
|
-
if (false) {
|
|
520
|
-
/** @type {?} */
|
|
521
|
-
StateSubject.prototype.subject;
|
|
522
|
-
}
|
|
523
444
|
|
|
524
445
|
var BaseMember = /** @class */ (function () {
|
|
525
|
-
/**
|
|
526
|
-
* @param {?} query
|
|
527
|
-
* @param {?} field
|
|
528
|
-
*/
|
|
529
446
|
function BaseMember(query, field) {
|
|
530
447
|
this.query = query;
|
|
531
448
|
this.field = field;
|
|
532
449
|
}
|
|
533
450
|
Object.defineProperty(BaseMember.prototype, "members", {
|
|
534
|
-
/**
|
|
535
|
-
* @private
|
|
536
|
-
* @return {?}
|
|
537
|
-
*/
|
|
538
451
|
get: function () {
|
|
539
452
|
return this.query.asCubeQuery()[this.field] || [];
|
|
540
453
|
},
|
|
541
454
|
enumerable: false,
|
|
542
455
|
configurable: true
|
|
543
456
|
});
|
|
544
|
-
/**
|
|
545
|
-
* @param {?} name
|
|
546
|
-
* @return {?}
|
|
547
|
-
*/
|
|
548
457
|
BaseMember.prototype.add = function (name) {
|
|
549
458
|
var _b;
|
|
550
459
|
this.query.setPartialQuery((_b = {},
|
|
551
|
-
_b[this.field] =
|
|
460
|
+
_b[this.field] = __spreadArray(__spreadArray([], __read(this.members)), [name]),
|
|
552
461
|
_b));
|
|
553
462
|
};
|
|
554
|
-
/**
|
|
555
|
-
* @param {?} name
|
|
556
|
-
* @param {?} replaceWithName
|
|
557
|
-
* @return {?}
|
|
558
|
-
*/
|
|
559
463
|
BaseMember.prototype.replace = function (name, replaceWithName) {
|
|
560
464
|
var _b;
|
|
561
465
|
this.query.setPartialQuery((_b = {},
|
|
562
|
-
_b[this.field] = this.members.map((
|
|
563
|
-
* @param {?} currentName
|
|
564
|
-
* @return {?}
|
|
565
|
-
*/function (currentName) { return currentName === name ? replaceWithName : currentName; })),
|
|
466
|
+
_b[this.field] = this.members.map(function (currentName) { return currentName === name ? replaceWithName : currentName; }),
|
|
566
467
|
_b));
|
|
567
468
|
};
|
|
568
|
-
/**
|
|
569
|
-
* @param {?} by
|
|
570
|
-
* @return {?}
|
|
571
|
-
*/
|
|
572
469
|
BaseMember.prototype.remove = function (by) {
|
|
573
470
|
var _b;
|
|
574
471
|
this.query.setPartialQuery((_b = {},
|
|
575
472
|
_b[this.field] = this.query
|
|
576
|
-
.asCubeQuery()[this.field].filter((
|
|
577
|
-
* @param {?} currentName
|
|
578
|
-
* @param {?} index
|
|
579
|
-
* @return {?}
|
|
580
|
-
*/function (currentName, index) {
|
|
473
|
+
.asCubeQuery()[this.field].filter(function (currentName, index) {
|
|
581
474
|
if (typeof by === 'string') {
|
|
582
475
|
return currentName !== by;
|
|
583
476
|
}
|
|
584
477
|
return index !== by;
|
|
585
|
-
})
|
|
478
|
+
}),
|
|
586
479
|
_b));
|
|
587
480
|
};
|
|
588
|
-
/**
|
|
589
|
-
* @param {?} members
|
|
590
|
-
* @return {?}
|
|
591
|
-
*/
|
|
592
481
|
BaseMember.prototype.set = function (members) {
|
|
593
482
|
var _b;
|
|
594
483
|
this.query.setPartialQuery((_b = {},
|
|
595
484
|
_b[this.field] = members,
|
|
596
485
|
_b));
|
|
597
486
|
};
|
|
598
|
-
/**
|
|
599
|
-
* @return {?}
|
|
600
|
-
*/
|
|
601
487
|
BaseMember.prototype.asArray = function () {
|
|
602
488
|
var _this = this;
|
|
603
|
-
return (this.query.asCubeQuery()[this.field] || []).map((
|
|
604
|
-
* @param {?} name
|
|
605
|
-
* @return {?}
|
|
606
|
-
*/function (name) { return _this.query.meta.resolveMember(name, _this.field); }));
|
|
489
|
+
return (this.query.asCubeQuery()[this.field] || []).map(function (name) { return _this.query.meta.resolveMember(name, _this.field); });
|
|
607
490
|
};
|
|
608
491
|
return BaseMember;
|
|
609
492
|
}());
|
|
610
|
-
if (false) {
|
|
611
|
-
/**
|
|
612
|
-
* @type {?}
|
|
613
|
-
* @private
|
|
614
|
-
*/
|
|
615
|
-
BaseMember.prototype.query;
|
|
616
|
-
/**
|
|
617
|
-
* @type {?}
|
|
618
|
-
* @private
|
|
619
|
-
*/
|
|
620
|
-
BaseMember.prototype.field;
|
|
621
|
-
}
|
|
622
493
|
var TimeDimensionMember = /** @class */ (function () {
|
|
623
|
-
/**
|
|
624
|
-
* @param {?} query
|
|
625
|
-
*/
|
|
626
494
|
function TimeDimensionMember(query) {
|
|
627
495
|
this.query = query;
|
|
628
496
|
}
|
|
629
497
|
Object.defineProperty(TimeDimensionMember.prototype, "members", {
|
|
630
|
-
/**
|
|
631
|
-
* @private
|
|
632
|
-
* @return {?}
|
|
633
|
-
*/
|
|
634
498
|
get: function () {
|
|
635
499
|
return this.query.asCubeQuery().timeDimensions || [];
|
|
636
500
|
},
|
|
@@ -638,9 +502,6 @@
|
|
|
638
502
|
configurable: true
|
|
639
503
|
});
|
|
640
504
|
Object.defineProperty(TimeDimensionMember.prototype, "granularity", {
|
|
641
|
-
/**
|
|
642
|
-
* @return {?}
|
|
643
|
-
*/
|
|
644
505
|
get: function () {
|
|
645
506
|
var _a;
|
|
646
507
|
return (_a = this.members[0]) === null || _a === void 0 ? void 0 : _a.granularity;
|
|
@@ -648,31 +509,17 @@
|
|
|
648
509
|
enumerable: false,
|
|
649
510
|
configurable: true
|
|
650
511
|
});
|
|
651
|
-
/**
|
|
652
|
-
* @param {?} by
|
|
653
|
-
* @param {?} updateWith
|
|
654
|
-
* @return {?}
|
|
655
|
-
*/
|
|
656
512
|
TimeDimensionMember.prototype.updateTimeDimension = function (by, updateWith) {
|
|
657
|
-
|
|
658
|
-
var timeDimensions = this.members.map(( /**
|
|
659
|
-
* @param {?} td
|
|
660
|
-
* @param {?} index
|
|
661
|
-
* @return {?}
|
|
662
|
-
*/function (td, index) {
|
|
513
|
+
var timeDimensions = this.members.map(function (td, index) {
|
|
663
514
|
if (td.dimension === by || index === by) {
|
|
664
515
|
return Object.assign(Object.assign({}, td), updateWith);
|
|
665
516
|
}
|
|
666
517
|
return td;
|
|
667
|
-
})
|
|
518
|
+
});
|
|
668
519
|
this.query.setPartialQuery({
|
|
669
520
|
timeDimensions: timeDimensions,
|
|
670
521
|
});
|
|
671
522
|
};
|
|
672
|
-
/**
|
|
673
|
-
* @param {?} name
|
|
674
|
-
* @return {?}
|
|
675
|
-
*/
|
|
676
523
|
TimeDimensionMember.prototype.add = function (name) {
|
|
677
524
|
this.query.setPartialQuery({
|
|
678
525
|
timeDimensions: [
|
|
@@ -682,496 +529,244 @@
|
|
|
682
529
|
],
|
|
683
530
|
});
|
|
684
531
|
};
|
|
685
|
-
/**
|
|
686
|
-
* @param {?} name
|
|
687
|
-
* @return {?}
|
|
688
|
-
*/
|
|
689
532
|
TimeDimensionMember.prototype.remove = function (name) {
|
|
690
533
|
this.query.setPartialQuery({
|
|
691
|
-
timeDimensions: this.members.filter((
|
|
692
|
-
* @param {?} __0
|
|
693
|
-
* @return {?}
|
|
694
|
-
*/function (_b) {
|
|
534
|
+
timeDimensions: this.members.filter(function (_b) {
|
|
695
535
|
var dimension = _b.dimension;
|
|
696
536
|
return dimension !== name;
|
|
697
|
-
})
|
|
537
|
+
}),
|
|
698
538
|
});
|
|
699
539
|
};
|
|
700
|
-
/**
|
|
701
|
-
* @param {?} timeDimensions
|
|
702
|
-
* @return {?}
|
|
703
|
-
*/
|
|
704
540
|
TimeDimensionMember.prototype.set = function (timeDimensions) {
|
|
705
541
|
this.query.setPartialQuery({
|
|
706
542
|
timeDimensions: timeDimensions,
|
|
707
543
|
});
|
|
708
544
|
};
|
|
709
|
-
/**
|
|
710
|
-
* @param {?} by
|
|
711
|
-
* @param {?} dateRange
|
|
712
|
-
* @return {?}
|
|
713
|
-
*/
|
|
714
545
|
TimeDimensionMember.prototype.setDateRange = function (by, dateRange) {
|
|
715
546
|
this.updateTimeDimension(by, { dateRange: dateRange });
|
|
716
547
|
};
|
|
717
|
-
/**
|
|
718
|
-
* @param {?} by
|
|
719
|
-
* @param {?} granularity
|
|
720
|
-
* @return {?}
|
|
721
|
-
*/
|
|
722
548
|
TimeDimensionMember.prototype.setGranularity = function (by, granularity) {
|
|
723
549
|
this.updateTimeDimension(by, { granularity: granularity });
|
|
724
550
|
};
|
|
725
|
-
/**
|
|
726
|
-
* @return {?}
|
|
727
|
-
*/
|
|
728
551
|
TimeDimensionMember.prototype.asArray = function () {
|
|
729
552
|
var _this = this;
|
|
730
|
-
return (this.query.asCubeQuery().timeDimensions || []).map((
|
|
731
|
-
* @param {?} td
|
|
732
|
-
* @return {?}
|
|
733
|
-
*/function (td) {
|
|
553
|
+
return (this.query.asCubeQuery().timeDimensions || []).map(function (td) {
|
|
734
554
|
return Object.assign(Object.assign({}, _this.query.meta.resolveMember(td.dimension, 'dimensions')), td);
|
|
735
|
-
})
|
|
555
|
+
});
|
|
736
556
|
};
|
|
737
557
|
return TimeDimensionMember;
|
|
738
558
|
}());
|
|
739
|
-
if (false) {
|
|
740
|
-
/**
|
|
741
|
-
* @type {?}
|
|
742
|
-
* @private
|
|
743
|
-
*/
|
|
744
|
-
TimeDimensionMember.prototype.query;
|
|
745
|
-
}
|
|
746
559
|
var Order = /** @class */ (function () {
|
|
747
|
-
/**
|
|
748
|
-
* @param {?} query
|
|
749
|
-
*/
|
|
750
560
|
function Order(query) {
|
|
751
561
|
this.query = query;
|
|
752
562
|
this.orderMembers = new rxjs.BehaviorSubject([]);
|
|
753
563
|
this.query.subject.subscribe(this.handleQueryChange.bind(this));
|
|
754
564
|
this.orderMembers.subscribe(this.handleOrderMembersChange.bind(this));
|
|
755
565
|
}
|
|
756
|
-
/**
|
|
757
|
-
* @private
|
|
758
|
-
* @param {?} orderMembers
|
|
759
|
-
* @return {?}
|
|
760
|
-
*/
|
|
761
566
|
Order.prototype.handleOrderMembersChange = function (orderMembers) {
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
.filter(( /**
|
|
765
|
-
* @param {?} __0
|
|
766
|
-
* @return {?}
|
|
767
|
-
*/function (_b) {
|
|
567
|
+
var order = orderMembers
|
|
568
|
+
.filter(function (_b) {
|
|
768
569
|
var order = _b.order;
|
|
769
570
|
return order !== 'none';
|
|
770
|
-
})
|
|
771
|
-
.reduce((
|
|
772
|
-
* @param {?} memo
|
|
773
|
-
* @param {?} __1
|
|
774
|
-
* @return {?}
|
|
775
|
-
*/function (memo, _b) {
|
|
571
|
+
})
|
|
572
|
+
.reduce(function (memo, _b) {
|
|
776
573
|
var _c;
|
|
777
574
|
var id = _b.id, order = _b.order;
|
|
778
575
|
return (Object.assign(Object.assign({}, memo), (_c = {}, _c[id] = order, _c)));
|
|
779
|
-
}
|
|
780
|
-
if (!equal__default[
|
|
576
|
+
}, {});
|
|
577
|
+
if (!equal__default["default"](order, this.asObject())) {
|
|
781
578
|
this.query.setPartialQuery({ order: order });
|
|
782
579
|
}
|
|
783
580
|
};
|
|
784
|
-
/**
|
|
785
|
-
* @private
|
|
786
|
-
* @return {?}
|
|
787
|
-
*/
|
|
788
581
|
Order.prototype.handleQueryChange = function () {
|
|
789
582
|
var _this = this;
|
|
790
|
-
this.orderMembers.next(
|
|
791
|
-
* @param {?} __0
|
|
792
|
-
* @return {?}
|
|
793
|
-
*/function (_b) {
|
|
583
|
+
this.orderMembers.next(__spreadArray(__spreadArray(__spreadArray([], __read(this.query.measures.asArray())), __read(this.query.dimensions.asArray())), __read(this.query.timeDimensions.asArray())).map(function (_b) {
|
|
794
584
|
var name = _b.name, title = _b.title;
|
|
795
585
|
return {
|
|
796
586
|
id: name,
|
|
797
587
|
order: _this.of(name),
|
|
798
588
|
title: title,
|
|
799
589
|
};
|
|
800
|
-
}))
|
|
590
|
+
}));
|
|
801
591
|
};
|
|
802
|
-
/**
|
|
803
|
-
* @param {?} id
|
|
804
|
-
* @param {?} order
|
|
805
|
-
* @return {?}
|
|
806
|
-
*/
|
|
807
592
|
Order.prototype.setMemberOrder = function (id, order) {
|
|
808
|
-
this.orderMembers.next(this.orderMembers.getValue().map((
|
|
809
|
-
* @param {?} orderMember
|
|
810
|
-
* @return {?}
|
|
811
|
-
*/function (orderMember) {
|
|
593
|
+
this.orderMembers.next(this.orderMembers.getValue().map(function (orderMember) {
|
|
812
594
|
if (orderMember.id === id) {
|
|
813
595
|
return Object.assign(Object.assign({}, orderMember), { order: order });
|
|
814
596
|
}
|
|
815
597
|
return orderMember;
|
|
816
|
-
}))
|
|
598
|
+
}));
|
|
817
599
|
};
|
|
818
|
-
/**
|
|
819
|
-
* @param {?} sourceIndex
|
|
820
|
-
* @param {?} destinationIndex
|
|
821
|
-
* @return {?}
|
|
822
|
-
*/
|
|
823
600
|
Order.prototype.reorder = function (sourceIndex, destinationIndex) {
|
|
824
601
|
this.orderMembers.next(cubejs.moveItemInArray(this.orderMembers.getValue(), sourceIndex, destinationIndex));
|
|
825
602
|
};
|
|
826
|
-
/**
|
|
827
|
-
* @param {?} member
|
|
828
|
-
* @return {?}
|
|
829
|
-
*/
|
|
830
603
|
Order.prototype.of = function (member) {
|
|
831
604
|
return (this.query.asCubeQuery().order || {})[member] || 'none';
|
|
832
605
|
};
|
|
833
|
-
/**
|
|
834
|
-
* @param {?} order
|
|
835
|
-
* @return {?}
|
|
836
|
-
*/
|
|
837
606
|
Order.prototype.set = function (order) {
|
|
838
607
|
this.query.setPartialQuery({ order: order });
|
|
839
608
|
};
|
|
840
|
-
/**
|
|
841
|
-
* @return {?}
|
|
842
|
-
*/
|
|
843
609
|
Order.prototype.asArray = function () {
|
|
844
610
|
if (Array.isArray(this.query.asCubeQuery().order)) {
|
|
845
|
-
return
|
|
611
|
+
return this.query.asCubeQuery().order;
|
|
846
612
|
}
|
|
847
613
|
return Object.entries(this.query.asCubeQuery().order || {});
|
|
848
614
|
};
|
|
849
|
-
/**
|
|
850
|
-
* @return {?}
|
|
851
|
-
*/
|
|
852
615
|
Order.prototype.asObject = function () {
|
|
853
|
-
return this.asArray().reduce((
|
|
854
|
-
* @param {?} memo
|
|
855
|
-
* @param {?} __1
|
|
856
|
-
* @return {?}
|
|
857
|
-
*/function (memo, _b) {
|
|
616
|
+
return this.asArray().reduce(function (memo, _b) {
|
|
858
617
|
var _c;
|
|
859
618
|
var _d = __read(_b, 2), key = _d[0], value = _d[1];
|
|
860
619
|
return (Object.assign(Object.assign({}, memo), (_c = {}, _c[key] = value, _c)));
|
|
861
|
-
}
|
|
620
|
+
}, {});
|
|
862
621
|
};
|
|
863
622
|
return Order;
|
|
864
623
|
}());
|
|
865
|
-
if (false) {
|
|
866
|
-
/** @type {?} */
|
|
867
|
-
Order.prototype.orderMembers;
|
|
868
|
-
/**
|
|
869
|
-
* @type {?}
|
|
870
|
-
* @private
|
|
871
|
-
*/
|
|
872
|
-
Order.prototype.query;
|
|
873
|
-
}
|
|
874
624
|
var FilterMember = /** @class */ (function () {
|
|
875
|
-
/**
|
|
876
|
-
* @param {?} query
|
|
877
|
-
*/
|
|
878
625
|
function FilterMember(query) {
|
|
879
626
|
this.query = query;
|
|
880
627
|
}
|
|
881
628
|
Object.defineProperty(FilterMember.prototype, "filters", {
|
|
882
|
-
/**
|
|
883
|
-
* @private
|
|
884
|
-
* @return {?}
|
|
885
|
-
*/
|
|
886
629
|
get: function () {
|
|
887
630
|
// TODO: update this type assertion once the QueryBuilder supports logical and/or
|
|
888
|
-
return (
|
|
631
|
+
return (this.query.asCubeQuery().filters || []);
|
|
889
632
|
},
|
|
890
633
|
enumerable: false,
|
|
891
634
|
configurable: true
|
|
892
635
|
});
|
|
893
|
-
/**
|
|
894
|
-
* @param {?} by
|
|
895
|
-
* @param {?} updateWith
|
|
896
|
-
* @return {?}
|
|
897
|
-
*/
|
|
898
636
|
FilterMember.prototype.update = function (by, updateWith) {
|
|
899
|
-
|
|
900
|
-
var filters = this.filters.map(( /**
|
|
901
|
-
* @param {?} filter
|
|
902
|
-
* @param {?} index
|
|
903
|
-
* @return {?}
|
|
904
|
-
*/function (filter, index) {
|
|
637
|
+
var filters = this.filters.map(function (filter, index) {
|
|
905
638
|
if (index === by || filter.member === by || filter.dimension === by) {
|
|
906
639
|
return Object.assign(Object.assign({}, filter), updateWith);
|
|
907
640
|
}
|
|
908
641
|
return filter;
|
|
909
|
-
})
|
|
642
|
+
});
|
|
910
643
|
this.query.setPartialQuery({
|
|
911
|
-
filters:
|
|
644
|
+
filters: filters,
|
|
912
645
|
});
|
|
913
646
|
};
|
|
914
|
-
/**
|
|
915
|
-
* @param {?} filter
|
|
916
|
-
* @return {?}
|
|
917
|
-
*/
|
|
918
647
|
FilterMember.prototype.add = function (filter) {
|
|
919
648
|
this.query.setPartialQuery({
|
|
920
|
-
filters:
|
|
649
|
+
filters: __spreadArray(__spreadArray([], __read(this.filters)), [filter]),
|
|
921
650
|
});
|
|
922
651
|
};
|
|
923
|
-
/**
|
|
924
|
-
* @param {?} by
|
|
925
|
-
* @return {?}
|
|
926
|
-
*/
|
|
927
652
|
FilterMember.prototype.remove = function (by) {
|
|
928
653
|
this.query.setPartialQuery({
|
|
929
|
-
filters: this.filters.filter((
|
|
930
|
-
* @param {?} filter
|
|
931
|
-
* @param {?} index
|
|
932
|
-
* @return {?}
|
|
933
|
-
*/function (filter, index) {
|
|
654
|
+
filters: this.filters.filter(function (filter, index) {
|
|
934
655
|
if (filter.member === by || filter.dimension === by || index === by) {
|
|
935
656
|
return false;
|
|
936
657
|
}
|
|
937
658
|
return true;
|
|
938
|
-
})
|
|
659
|
+
}),
|
|
939
660
|
});
|
|
940
661
|
};
|
|
941
|
-
/**
|
|
942
|
-
* @param {?} filters
|
|
943
|
-
* @return {?}
|
|
944
|
-
*/
|
|
945
662
|
FilterMember.prototype.set = function (filters) {
|
|
946
663
|
this.query.setPartialQuery({
|
|
947
664
|
filters: filters,
|
|
948
665
|
});
|
|
949
666
|
};
|
|
950
|
-
/**
|
|
951
|
-
* @param {?} name
|
|
952
|
-
* @param {?} replaceWithName
|
|
953
|
-
* @return {?}
|
|
954
|
-
*/
|
|
955
667
|
FilterMember.prototype.replace = function (name, replaceWithName) {
|
|
956
668
|
this.query.setPartialQuery({
|
|
957
|
-
filters: this.filters.map((
|
|
958
|
-
* @param {?} filter
|
|
959
|
-
* @return {?}
|
|
960
|
-
*/function (filter) {
|
|
669
|
+
filters: this.filters.map(function (filter) {
|
|
961
670
|
var _b;
|
|
962
|
-
/** @type {?} */
|
|
963
671
|
var field = filter.member ? 'member' : 'dimension';
|
|
964
672
|
return filter.member === name || filter.dimension === name
|
|
965
673
|
? Object.assign(Object.assign({}, filter), (_b = {}, _b[field] = replaceWithName, _b)) : filter;
|
|
966
|
-
})
|
|
674
|
+
}),
|
|
967
675
|
});
|
|
968
676
|
};
|
|
969
|
-
/**
|
|
970
|
-
* @return {?}
|
|
971
|
-
*/
|
|
972
677
|
FilterMember.prototype.asArray = function () {
|
|
973
678
|
var _this = this;
|
|
974
|
-
return this.filters.map((
|
|
975
|
-
* @param {?} filter
|
|
976
|
-
* @return {?}
|
|
977
|
-
*/function (filter) {
|
|
679
|
+
return this.filters.map(function (filter) {
|
|
978
680
|
return Object.assign(Object.assign(Object.assign({}, _this.query.meta.resolveMember(filter.member || filter.dimension, [
|
|
979
681
|
'dimensions',
|
|
980
682
|
'measures',
|
|
981
683
|
])), { operators: _this.query.meta.filterOperatorsForMember(filter.member || filter.dimension, ['dimensions', 'measures']) }), filter);
|
|
982
|
-
})
|
|
684
|
+
});
|
|
983
685
|
};
|
|
984
686
|
return FilterMember;
|
|
985
687
|
}());
|
|
986
|
-
if (false) {
|
|
987
|
-
/**
|
|
988
|
-
* @type {?}
|
|
989
|
-
* @private
|
|
990
|
-
*/
|
|
991
|
-
FilterMember.prototype.query;
|
|
992
|
-
}
|
|
993
688
|
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
Measures
|
|
997
|
-
Dimensions
|
|
998
|
-
Segments
|
|
999
|
-
TimeDimensions
|
|
1000
|
-
Filters
|
|
1001
|
-
Order
|
|
1002
|
-
};
|
|
689
|
+
exports.MemberType = void 0;
|
|
690
|
+
(function (MemberType) {
|
|
691
|
+
MemberType["Measures"] = "measures";
|
|
692
|
+
MemberType["Dimensions"] = "dimensions";
|
|
693
|
+
MemberType["Segments"] = "segments";
|
|
694
|
+
MemberType["TimeDimensions"] = "timeDimensions";
|
|
695
|
+
MemberType["Filters"] = "filters";
|
|
696
|
+
MemberType["Order"] = "order";
|
|
697
|
+
})(exports.MemberType || (exports.MemberType = {}));
|
|
1003
698
|
var Query = /** @class */ (function (_super) {
|
|
1004
699
|
__extends(Query, _super);
|
|
1005
|
-
/**
|
|
1006
|
-
* @param {?} meta
|
|
1007
|
-
* @param {?=} _onBeforeChange
|
|
1008
|
-
*/
|
|
1009
700
|
function Query(meta, _onBeforeChange) {
|
|
1010
|
-
if (_onBeforeChange === void 0) { _onBeforeChange = (
|
|
1011
|
-
* @param {?} newQuery
|
|
1012
|
-
* @return {?}
|
|
1013
|
-
*/function (newQuery) { return newQuery; }); }
|
|
701
|
+
if (_onBeforeChange === void 0) { _onBeforeChange = function (newQuery) { return newQuery; }; }
|
|
1014
702
|
var _this = _super.call(this, {}) || this;
|
|
1015
703
|
_this.meta = meta;
|
|
1016
704
|
_this._onBeforeChange = _onBeforeChange;
|
|
1017
705
|
_this.init();
|
|
1018
706
|
return _this;
|
|
1019
707
|
}
|
|
1020
|
-
/**
|
|
1021
|
-
* @private
|
|
1022
|
-
* @return {?}
|
|
1023
|
-
*/
|
|
1024
708
|
Query.prototype.init = function () {
|
|
1025
|
-
this.measures = new BaseMember(this, MemberType.Measures);
|
|
1026
|
-
this.dimensions = new BaseMember(this, MemberType.Dimensions);
|
|
1027
|
-
this.segments = new BaseMember(this, MemberType.Segments);
|
|
709
|
+
this.measures = new BaseMember(this, exports.MemberType.Measures);
|
|
710
|
+
this.dimensions = new BaseMember(this, exports.MemberType.Dimensions);
|
|
711
|
+
this.segments = new BaseMember(this, exports.MemberType.Segments);
|
|
1028
712
|
this.timeDimensions = new TimeDimensionMember(this);
|
|
1029
713
|
this.filters = new FilterMember(this);
|
|
1030
714
|
this.order = new Order(this);
|
|
1031
715
|
};
|
|
1032
|
-
/**
|
|
1033
|
-
* @return {?}
|
|
1034
|
-
*/
|
|
1035
716
|
Query.prototype.asCubeQuery = function () {
|
|
1036
717
|
return this.subject.getValue() || {};
|
|
1037
718
|
};
|
|
1038
|
-
/**
|
|
1039
|
-
* @param {?} query
|
|
1040
|
-
* @return {?}
|
|
1041
|
-
*/
|
|
1042
719
|
Query.prototype.setQuery = function (query) {
|
|
1043
720
|
this.subject.next(this._onBeforeChange(query, this.subject.getValue(), this));
|
|
1044
721
|
};
|
|
1045
|
-
/**
|
|
1046
|
-
* @param {?} partialQuery
|
|
1047
|
-
* @return {?}
|
|
1048
|
-
*/
|
|
1049
722
|
Query.prototype.setPartialQuery = function (partialQuery) {
|
|
1050
723
|
this.subject.next(this._onBeforeChange(Object.assign(Object.assign({}, this.subject.getValue()), partialQuery), this.subject.getValue(), this));
|
|
1051
724
|
};
|
|
1052
|
-
/**
|
|
1053
|
-
* @param {?} limit
|
|
1054
|
-
* @return {?}
|
|
1055
|
-
*/
|
|
1056
725
|
Query.prototype.setLimit = function (limit) {
|
|
1057
726
|
this.setPartialQuery({ limit: limit });
|
|
1058
727
|
};
|
|
1059
|
-
/**
|
|
1060
|
-
* @return {?}
|
|
1061
|
-
*/
|
|
1062
728
|
Query.prototype.isPresent = function () {
|
|
1063
729
|
return cubejs.isQueryPresent(this.asCubeQuery());
|
|
1064
730
|
};
|
|
1065
731
|
return Query;
|
|
1066
732
|
}(StateSubject));
|
|
1067
|
-
if (false) {
|
|
1068
|
-
/** @type {?} */
|
|
1069
|
-
Query.prototype.measures;
|
|
1070
|
-
/** @type {?} */
|
|
1071
|
-
Query.prototype.dimensions;
|
|
1072
|
-
/** @type {?} */
|
|
1073
|
-
Query.prototype.segments;
|
|
1074
|
-
/** @type {?} */
|
|
1075
|
-
Query.prototype.timeDimensions;
|
|
1076
|
-
/** @type {?} */
|
|
1077
|
-
Query.prototype.filters;
|
|
1078
|
-
/** @type {?} */
|
|
1079
|
-
Query.prototype.order;
|
|
1080
|
-
/** @type {?} */
|
|
1081
|
-
Query.prototype.meta;
|
|
1082
|
-
/**
|
|
1083
|
-
* @type {?}
|
|
1084
|
-
* @private
|
|
1085
|
-
*/
|
|
1086
|
-
Query.prototype._onBeforeChange;
|
|
1087
|
-
}
|
|
1088
733
|
|
|
1089
|
-
/**
|
|
1090
|
-
* @fileoverview added by tsickle
|
|
1091
|
-
* Generated from: src/query-builder/builder-meta.ts
|
|
1092
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1093
|
-
*/
|
|
1094
734
|
var BuilderMeta = /** @class */ (function () {
|
|
1095
|
-
/**
|
|
1096
|
-
* @param {?} meta
|
|
1097
|
-
*/
|
|
1098
735
|
function BuilderMeta(meta) {
|
|
1099
736
|
this.meta = meta;
|
|
1100
737
|
this.mapMeta();
|
|
1101
738
|
}
|
|
1102
|
-
/**
|
|
1103
|
-
* @private
|
|
1104
|
-
* @return {?}
|
|
1105
|
-
*/
|
|
1106
739
|
BuilderMeta.prototype.mapMeta = function () {
|
|
1107
740
|
var _this = this;
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
this.measures = ( /** @type {?} */(this.meta.membersForQuery(null, 'measures')));
|
|
741
|
+
var allDimensions = (this.meta.membersForQuery(null, 'dimensions'));
|
|
742
|
+
this.measures = this.meta.membersForQuery(null, 'measures');
|
|
1111
743
|
this.segments = this.meta.membersForQuery(null, 'segments');
|
|
1112
|
-
this.dimensions = allDimensions.filter((
|
|
1113
|
-
* @param {?} __0
|
|
1114
|
-
* @return {?}
|
|
1115
|
-
*/function (_a) {
|
|
744
|
+
this.dimensions = allDimensions.filter(function (_a) {
|
|
1116
745
|
var type = _a.type;
|
|
1117
746
|
return type !== 'time';
|
|
1118
|
-
})
|
|
1119
|
-
this.timeDimensions = allDimensions.filter((
|
|
1120
|
-
* @param {?} __0
|
|
1121
|
-
* @return {?}
|
|
1122
|
-
*/function (_a) {
|
|
747
|
+
});
|
|
748
|
+
this.timeDimensions = allDimensions.filter(function (_a) {
|
|
1123
749
|
var type = _a.type;
|
|
1124
750
|
return type === 'time';
|
|
1125
|
-
})
|
|
1126
|
-
this.filters =
|
|
1127
|
-
* @param {?} member
|
|
1128
|
-
* @return {?}
|
|
1129
|
-
*/function (member) {
|
|
751
|
+
});
|
|
752
|
+
this.filters = __spreadArray(__spreadArray([], __read(allDimensions)), __read(this.measures)).map(function (member) {
|
|
1130
753
|
return Object.assign(Object.assign({}, member), { operators: _this.meta.filterOperatorsForMember(member.name, [
|
|
1131
754
|
'dimensions',
|
|
1132
755
|
'measures',
|
|
1133
756
|
]) });
|
|
1134
|
-
})
|
|
757
|
+
});
|
|
1135
758
|
};
|
|
1136
759
|
return BuilderMeta;
|
|
1137
760
|
}());
|
|
1138
|
-
if (false) {
|
|
1139
|
-
/** @type {?} */
|
|
1140
|
-
BuilderMeta.prototype.measures;
|
|
1141
|
-
/** @type {?} */
|
|
1142
|
-
BuilderMeta.prototype.dimensions;
|
|
1143
|
-
/** @type {?} */
|
|
1144
|
-
BuilderMeta.prototype.segments;
|
|
1145
|
-
/** @type {?} */
|
|
1146
|
-
BuilderMeta.prototype.timeDimensions;
|
|
1147
|
-
/** @type {?} */
|
|
1148
|
-
BuilderMeta.prototype.filters;
|
|
1149
|
-
/** @type {?} */
|
|
1150
|
-
BuilderMeta.prototype.meta;
|
|
1151
|
-
}
|
|
1152
761
|
|
|
1153
762
|
var PivotConfig = /** @class */ (function (_super) {
|
|
1154
763
|
__extends(PivotConfig, _super);
|
|
1155
|
-
/**
|
|
1156
|
-
* @param {?} pivotConfig
|
|
1157
|
-
*/
|
|
1158
764
|
function PivotConfig(pivotConfig) {
|
|
1159
765
|
return _super.call(this, pivotConfig) || this;
|
|
1160
766
|
}
|
|
1161
|
-
/**
|
|
1162
|
-
* @param {?} sourceIndex
|
|
1163
|
-
* @param {?} destinationIndex
|
|
1164
|
-
* @param {?} sourceAxis
|
|
1165
|
-
* @param {?} destinationAxis
|
|
1166
|
-
* @return {?}
|
|
1167
|
-
*/
|
|
1168
767
|
PivotConfig.prototype.moveItem = function (sourceIndex, destinationIndex, sourceAxis, destinationAxis) {
|
|
1169
768
|
this.subject.next(cubejs.movePivotItem(this.get(), sourceIndex, destinationIndex, sourceAxis, destinationAxis));
|
|
1170
769
|
};
|
|
1171
|
-
/**
|
|
1172
|
-
* @param {?} fillMissingDates
|
|
1173
|
-
* @return {?}
|
|
1174
|
-
*/
|
|
1175
770
|
PivotConfig.prototype.setFillMissingDates = function (fillMissingDates) {
|
|
1176
771
|
this.subject.next(Object.assign(Object.assign({}, this.get()), { fillMissingDates: fillMissingDates }));
|
|
1177
772
|
};
|
|
@@ -1180,9 +775,6 @@
|
|
|
1180
775
|
|
|
1181
776
|
var ChartType = /** @class */ (function (_super) {
|
|
1182
777
|
__extends(ChartType, _super);
|
|
1183
|
-
/**
|
|
1184
|
-
* @param {?} value
|
|
1185
|
-
*/
|
|
1186
778
|
function ChartType(value) {
|
|
1187
779
|
return _super.call(this, value) || this;
|
|
1188
780
|
}
|
|
@@ -1194,57 +786,35 @@
|
|
|
1194
786
|
var _this = this;
|
|
1195
787
|
this._disableHeuristics = false;
|
|
1196
788
|
this._heuristicChange$ = new rxjs.Subject();
|
|
1197
|
-
this.builderMeta = new Promise((
|
|
1198
|
-
|
|
1199
|
-
* @return {?}
|
|
1200
|
-
*/function (resolve) { return (_this._resolveBuilderMeta = resolve); }));
|
|
1201
|
-
this.query = new Promise(( /**
|
|
1202
|
-
* @param {?} resolve
|
|
1203
|
-
* @return {?}
|
|
1204
|
-
*/function (resolve) { return (_this._resolveQuery = resolve); }));
|
|
789
|
+
this.builderMeta = new Promise(function (resolve) { return (_this._resolveBuilderMeta = resolve); });
|
|
790
|
+
this.query = new Promise(function (resolve) { return (_this._resolveQuery = resolve); });
|
|
1205
791
|
this.state = new rxjs.BehaviorSubject({});
|
|
1206
792
|
}
|
|
1207
|
-
/**
|
|
1208
|
-
* @private
|
|
1209
|
-
* @return {?}
|
|
1210
|
-
*/
|
|
1211
793
|
QueryBuilderService.prototype.init = function () {
|
|
1212
794
|
return __awaiter(this, void 0, void 0, function () {
|
|
1213
795
|
var _this = this;
|
|
1214
796
|
return __generator(this, function (_c) {
|
|
1215
797
|
this.pivotConfig = new PivotConfig(null);
|
|
1216
798
|
this.chartType = new ChartType('line');
|
|
1217
|
-
this._cubejs.meta().subscribe((
|
|
1218
|
-
* @param {?} meta
|
|
1219
|
-
* @return {?}
|
|
1220
|
-
*/function (meta) {
|
|
799
|
+
this._cubejs.meta().subscribe(function (meta) {
|
|
1221
800
|
_this._meta = meta;
|
|
1222
801
|
_this._query = new Query(_this._meta, _this._handleQueryChange.bind(_this));
|
|
1223
802
|
_this._resolveQuery(_this._query);
|
|
1224
803
|
_this._resolveBuilderMeta(new BuilderMeta(_this._meta));
|
|
1225
|
-
})
|
|
804
|
+
});
|
|
1226
805
|
this.subscribe();
|
|
1227
806
|
if (!this._disableHeuristics) {
|
|
1228
807
|
this._heuristicChange$
|
|
1229
|
-
.pipe(operators.switchMap((
|
|
1230
|
-
* @param {?} data
|
|
1231
|
-
* @return {?}
|
|
1232
|
-
*/function (data) {
|
|
808
|
+
.pipe(operators.switchMap(function (data) {
|
|
1233
809
|
return rxjs.combineLatest([
|
|
1234
|
-
_this._cubejs.dryRun(data.query).pipe(operators.catchError((
|
|
1235
|
-
* @param {?} error
|
|
1236
|
-
* @return {?}
|
|
1237
|
-
*/function (error) {
|
|
810
|
+
_this._cubejs.dryRun(data.query).pipe(operators.catchError(function (error) {
|
|
1238
811
|
console.error(error);
|
|
1239
812
|
return rxjs.of(null);
|
|
1240
|
-
}))
|
|
813
|
+
})),
|
|
1241
814
|
rxjs.of(data.shouldApplyHeuristicOrder),
|
|
1242
815
|
]);
|
|
1243
|
-
}))
|
|
1244
|
-
.subscribe((
|
|
1245
|
-
* @param {?} __0
|
|
1246
|
-
* @return {?}
|
|
1247
|
-
*/function (_c) {
|
|
816
|
+
}))
|
|
817
|
+
.subscribe(function (_c) {
|
|
1248
818
|
var _d = __read(_c, 2), dryRunResponse = _d[0], shouldApplyHeuristicOrder = _d[1];
|
|
1249
819
|
if (!dryRunResponse) {
|
|
1250
820
|
return;
|
|
@@ -1252,31 +822,20 @@
|
|
|
1252
822
|
var pivotQuery = dryRunResponse.pivotQuery, queryOrder = dryRunResponse.queryOrder;
|
|
1253
823
|
_this.pivotConfig.set(cubejs.ResultSet.getNormalizedPivotConfig(pivotQuery, _this.pivotConfig.get()));
|
|
1254
824
|
if (shouldApplyHeuristicOrder) {
|
|
1255
|
-
_this._query.order.set(queryOrder.reduce((
|
|
1256
|
-
* @param {?} a
|
|
1257
|
-
* @param {?} b
|
|
1258
|
-
* @return {?}
|
|
1259
|
-
*/function (a, b) { return (Object.assign(Object.assign({}, a), b)); }), {}));
|
|
825
|
+
_this._query.order.set(queryOrder.reduce(function (a, b) { return (Object.assign(Object.assign({}, a), b)); }, {}));
|
|
1260
826
|
}
|
|
1261
|
-
})
|
|
827
|
+
});
|
|
1262
828
|
}
|
|
1263
829
|
return [2 /*return*/];
|
|
1264
830
|
});
|
|
1265
831
|
});
|
|
1266
832
|
};
|
|
1267
|
-
/**
|
|
1268
|
-
* @private
|
|
1269
|
-
* @param {?} newQuery
|
|
1270
|
-
* @param {?} oldQuery
|
|
1271
|
-
* @return {?}
|
|
1272
|
-
*/
|
|
1273
833
|
QueryBuilderService.prototype._handleQueryChange = function (newQuery, oldQuery) {
|
|
1274
834
|
var _a, _b;
|
|
1275
835
|
var _c = cubejs.defaultHeuristics(newQuery, oldQuery, {
|
|
1276
836
|
meta: this._meta,
|
|
1277
837
|
sessionGranularity: (_b = (_a = newQuery === null || newQuery === void 0 ? void 0 : newQuery.timeDimensions) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.granularity,
|
|
1278
838
|
}), chartType = _c.chartType, shouldApplyHeuristicOrder = _c.shouldApplyHeuristicOrder, heuristicQuery = _c.query;
|
|
1279
|
-
/** @type {?} */
|
|
1280
839
|
var query = this._disableHeuristics
|
|
1281
840
|
? newQuery
|
|
1282
841
|
: heuristicQuery || newQuery;
|
|
@@ -1291,54 +850,30 @@
|
|
|
1291
850
|
}
|
|
1292
851
|
return query;
|
|
1293
852
|
};
|
|
1294
|
-
/**
|
|
1295
|
-
* @param {?} cubejsClient
|
|
1296
|
-
* @return {?}
|
|
1297
|
-
*/
|
|
1298
853
|
QueryBuilderService.prototype.setCubejsClient = function (cubejsClient) {
|
|
1299
854
|
this._cubejs = cubejsClient;
|
|
1300
855
|
this.init();
|
|
1301
856
|
};
|
|
1302
|
-
/**
|
|
1303
|
-
* @private
|
|
1304
|
-
* @return {?}
|
|
1305
|
-
*/
|
|
1306
857
|
QueryBuilderService.prototype.subscribe = function () {
|
|
1307
858
|
var _this = this;
|
|
1308
|
-
Object.getOwnPropertyNames(this).forEach((
|
|
1309
|
-
* @param {?} key
|
|
1310
|
-
* @return {?}
|
|
1311
|
-
*/function (key) {
|
|
859
|
+
Object.getOwnPropertyNames(this).forEach(function (key) {
|
|
1312
860
|
if (_this[key] instanceof StateSubject) {
|
|
1313
|
-
_this[key].subject.subscribe((
|
|
1314
|
-
* @param {?} value
|
|
1315
|
-
* @return {?}
|
|
1316
|
-
*/function (value) {
|
|
861
|
+
_this[key].subject.subscribe(function (value) {
|
|
1317
862
|
var _c;
|
|
1318
863
|
return _this.setPartialState((_c = {},
|
|
1319
864
|
_c[key] = value,
|
|
1320
865
|
_c));
|
|
1321
|
-
})
|
|
866
|
+
});
|
|
1322
867
|
}
|
|
1323
|
-
})
|
|
1324
|
-
this.query.then((
|
|
1325
|
-
|
|
1326
|
-
* @return {?}
|
|
1327
|
-
*/function (query) {
|
|
1328
|
-
query.subject.subscribe(( /**
|
|
1329
|
-
* @param {?} cubeQuery
|
|
1330
|
-
* @return {?}
|
|
1331
|
-
*/function (cubeQuery) {
|
|
868
|
+
});
|
|
869
|
+
this.query.then(function (query) {
|
|
870
|
+
query.subject.subscribe(function (cubeQuery) {
|
|
1332
871
|
_this.setPartialState({
|
|
1333
872
|
query: cubeQuery,
|
|
1334
873
|
});
|
|
1335
|
-
})
|
|
1336
|
-
})
|
|
874
|
+
});
|
|
875
|
+
});
|
|
1337
876
|
};
|
|
1338
|
-
/**
|
|
1339
|
-
* @param {?} state
|
|
1340
|
-
* @return {?}
|
|
1341
|
-
*/
|
|
1342
877
|
QueryBuilderService.prototype.deserialize = function (state) {
|
|
1343
878
|
return __awaiter(this, void 0, void 0, function () {
|
|
1344
879
|
var _this = this;
|
|
@@ -1351,109 +886,42 @@
|
|
|
1351
886
|
(_c.sent()).setQuery(state.query);
|
|
1352
887
|
_c.label = 2;
|
|
1353
888
|
case 2:
|
|
1354
|
-
Object.entries(state).forEach((
|
|
1355
|
-
* @param {?} __0
|
|
1356
|
-
* @return {?}
|
|
1357
|
-
*/function (_c) {
|
|
889
|
+
Object.entries(state).forEach(function (_c) {
|
|
1358
890
|
var _d = __read(_c, 2), key = _d[0], value = _d[1];
|
|
1359
891
|
if (_this[key] instanceof StateSubject) {
|
|
1360
892
|
_this[key].set(value);
|
|
1361
893
|
}
|
|
1362
|
-
})
|
|
894
|
+
});
|
|
1363
895
|
this.subscribe();
|
|
1364
896
|
return [2 /*return*/];
|
|
1365
897
|
}
|
|
1366
898
|
});
|
|
1367
899
|
});
|
|
1368
900
|
};
|
|
1369
|
-
/**
|
|
1370
|
-
* @param {?} partialState
|
|
1371
|
-
* @return {?}
|
|
1372
|
-
*/
|
|
1373
901
|
QueryBuilderService.prototype.setPartialState = function (partialState) {
|
|
1374
902
|
this.state.next(Object.assign(Object.assign({}, this.state.getValue()), partialState));
|
|
1375
903
|
};
|
|
1376
|
-
/**
|
|
1377
|
-
* @return {?}
|
|
1378
|
-
*/
|
|
1379
904
|
QueryBuilderService.prototype.disableHeuristics = function () {
|
|
1380
905
|
this._disableHeuristics = false;
|
|
1381
906
|
};
|
|
1382
|
-
/**
|
|
1383
|
-
* @return {?}
|
|
1384
|
-
*/
|
|
1385
907
|
QueryBuilderService.prototype.enableHeuristics = function () {
|
|
1386
908
|
this._disableHeuristics = true;
|
|
1387
909
|
};
|
|
1388
910
|
return QueryBuilderService;
|
|
1389
911
|
}());
|
|
912
|
+
/** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
|
|
1390
913
|
QueryBuilderService.decorators = [
|
|
1391
914
|
{ type: core.Injectable }
|
|
1392
915
|
];
|
|
1393
|
-
if (false) {
|
|
1394
|
-
/**
|
|
1395
|
-
* @type {?}
|
|
1396
|
-
* @private
|
|
1397
|
-
*/
|
|
1398
|
-
QueryBuilderService.prototype._cubejs;
|
|
1399
|
-
/**
|
|
1400
|
-
* @type {?}
|
|
1401
|
-
* @private
|
|
1402
|
-
*/
|
|
1403
|
-
QueryBuilderService.prototype._meta;
|
|
1404
|
-
/**
|
|
1405
|
-
* @type {?}
|
|
1406
|
-
* @private
|
|
1407
|
-
*/
|
|
1408
|
-
QueryBuilderService.prototype._query;
|
|
1409
|
-
/**
|
|
1410
|
-
* @type {?}
|
|
1411
|
-
* @private
|
|
1412
|
-
*/
|
|
1413
|
-
QueryBuilderService.prototype._disableHeuristics;
|
|
1414
|
-
/**
|
|
1415
|
-
* @type {?}
|
|
1416
|
-
* @private
|
|
1417
|
-
*/
|
|
1418
|
-
QueryBuilderService.prototype._resolveQuery;
|
|
1419
|
-
/**
|
|
1420
|
-
* @type {?}
|
|
1421
|
-
* @private
|
|
1422
|
-
*/
|
|
1423
|
-
QueryBuilderService.prototype._resolveBuilderMeta;
|
|
1424
|
-
/**
|
|
1425
|
-
* @type {?}
|
|
1426
|
-
* @private
|
|
1427
|
-
*/
|
|
1428
|
-
QueryBuilderService.prototype._heuristicChange$;
|
|
1429
|
-
/** @type {?} */
|
|
1430
|
-
QueryBuilderService.prototype.builderMeta;
|
|
1431
|
-
/** @type {?} */
|
|
1432
|
-
QueryBuilderService.prototype.query;
|
|
1433
|
-
/** @type {?} */
|
|
1434
|
-
QueryBuilderService.prototype.state;
|
|
1435
|
-
/** @type {?} */
|
|
1436
|
-
QueryBuilderService.prototype.pivotConfig;
|
|
1437
|
-
/** @type {?} */
|
|
1438
|
-
QueryBuilderService.prototype.chartType;
|
|
1439
|
-
}
|
|
1440
916
|
|
|
1441
|
-
|
|
1442
|
-
*
|
|
1443
|
-
* Generated from: src/public_api.ts
|
|
1444
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
917
|
+
/*
|
|
918
|
+
* Public API Surface of cubejs-client-ngx
|
|
1445
919
|
*/
|
|
1446
920
|
|
|
1447
|
-
|
|
1448
|
-
* @fileoverview added by tsickle
|
|
1449
|
-
* Generated from: index.ts
|
|
1450
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1451
|
-
*/
|
|
921
|
+
// This file is not used to build this module. It is only used during editing
|
|
1452
922
|
|
|
1453
923
|
/**
|
|
1454
|
-
*
|
|
1455
|
-
* Generated from: cubejs-client-ngx.ts
|
|
1456
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
924
|
+
* Generated bundle index. Do not edit.
|
|
1457
925
|
*/
|
|
1458
926
|
|
|
1459
927
|
exports.BaseMember = BaseMember;
|
|
@@ -1462,15 +930,14 @@
|
|
|
1462
930
|
exports.CubejsClient = CubejsClient;
|
|
1463
931
|
exports.CubejsClientModule = CubejsClientModule;
|
|
1464
932
|
exports.FilterMember = FilterMember;
|
|
1465
|
-
exports.MemberType = MemberType;
|
|
1466
933
|
exports.Order = Order;
|
|
1467
934
|
exports.PivotConfig = PivotConfig;
|
|
1468
935
|
exports.Query = Query;
|
|
1469
936
|
exports.QueryBuilderService = QueryBuilderService;
|
|
1470
937
|
exports.TimeDimensionMember = TimeDimensionMember;
|
|
1471
|
-
exports
|
|
938
|
+
exports["ɵa"] = StateSubject;
|
|
1472
939
|
|
|
1473
940
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1474
941
|
|
|
1475
|
-
}))
|
|
942
|
+
}));
|
|
1476
943
|
//# sourceMappingURL=cubejs-client-ngx.umd.js.map
|