|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +Object.defineProperty(exports, '__esModule', { value: true }); |
| 4 | + |
| 5 | +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } |
| 6 | + |
| 7 | +var core = require('@angular/core'); |
| 8 | +var rxjs = require('rxjs'); |
| 9 | +var cubejs = _interopDefault(require('@cubejs-client/core')); |
| 10 | + |
| 11 | +/*! ***************************************************************************** |
| 12 | +Copyright (c) Microsoft Corporation. All rights reserved. |
| 13 | +Licensed under the Apache License, Version 2.0 (the "License"); you may not use |
| 14 | +this file except in compliance with the License. You may obtain a copy of the |
| 15 | +License at http://www.apache.org/licenses/LICENSE-2.0 |
| 16 | +
|
| 17 | +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 18 | +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED |
| 19 | +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, |
| 20 | +MERCHANTABLITY OR NON-INFRINGEMENT. |
| 21 | +
|
| 22 | +See the Apache Version 2.0 License for specific language governing permissions |
| 23 | +and limitations under the License. |
| 24 | +***************************************************************************** */ |
| 25 | + |
| 26 | +function __decorate(decorators, target, key, desc) { |
| 27 | + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; |
| 28 | + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); |
| 29 | + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; |
| 30 | + return c > 3 && r && Object.defineProperty(target, key, r), r; |
| 31 | +} |
| 32 | + |
| 33 | +function __param(paramIndex, decorator) { |
| 34 | + return function (target, key) { decorator(target, key, paramIndex); } |
| 35 | +} |
| 36 | + |
| 37 | +function __metadata(metadataKey, metadataValue) { |
| 38 | + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); |
| 39 | +} |
| 40 | + |
| 41 | +function __awaiter(thisArg, _arguments, P, generator) { |
| 42 | + return new (P || (P = Promise))(function (resolve, reject) { |
| 43 | + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |
| 44 | + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |
| 45 | + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } |
| 46 | + step((generator = generator.apply(thisArg, _arguments || [])).next()); |
| 47 | + }); |
| 48 | +} |
| 49 | + |
| 50 | +exports.CubejsClient = class CubejsClient { |
| 51 | + constructor(config) { |
| 52 | + this.config = config; |
| 53 | + } |
| 54 | + apiInstace() { |
| 55 | + if (!this.cubeJsApi) { |
| 56 | + this.cubeJsApi = cubejs(this.config.token, this.config.options); |
| 57 | + } |
| 58 | + return this.cubeJsApi; |
| 59 | + } |
| 60 | + load(...params) { |
| 61 | + return rxjs.from(this.apiInstace().load(...params)); |
| 62 | + } |
| 63 | + sql(...params) { |
| 64 | + return rxjs.from(this.apiInstace().sql(...params)); |
| 65 | + } |
| 66 | + meta(...params) { |
| 67 | + return rxjs.from(this.apiInstace().meta(...params)); |
| 68 | + } |
| 69 | + watch(query, params = {}) { |
| 70 | + return rxjs.Observable.create(observer => query.subscribe({ |
| 71 | + next: (query) => __awaiter(this, void 0, void 0, function* () { |
| 72 | + const resultSet = yield this.apiInstace().load(query, params); |
| 73 | + observer.next(resultSet); |
| 74 | + }) |
| 75 | + })); |
| 76 | + } |
| 77 | +}; |
| 78 | +exports.CubejsClient = __decorate([ |
| 79 | + core.Injectable(), |
| 80 | + __param(0, core.Inject('config')), |
| 81 | + __metadata("design:paramtypes", [Object]) |
| 82 | +], exports.CubejsClient); |
| 83 | + |
| 84 | +var CubejsClientModule_1; |
| 85 | +exports.CubejsClientModule = CubejsClientModule_1 = class CubejsClientModule { |
| 86 | + static forRoot(config) { |
| 87 | + return { |
| 88 | + ngModule: CubejsClientModule_1, |
| 89 | + providers: [ |
| 90 | + exports.CubejsClient, |
| 91 | + { |
| 92 | + provide: 'config', |
| 93 | + useValue: config |
| 94 | + } |
| 95 | + ] |
| 96 | + }; |
| 97 | + } |
| 98 | +}; |
| 99 | +exports.CubejsClientModule = CubejsClientModule_1 = __decorate([ |
| 100 | + core.NgModule({ |
| 101 | + providers: [exports.CubejsClient] |
| 102 | + }) |
| 103 | +], exports.CubejsClientModule); |
| 104 | + |
| 105 | +/* |
| 106 | + * Public API Surface of cubejs-client-ngx |
| 107 | + */ |
| 108 | + |
| 109 | +// This file is not used to build this module. It is only used during editing |
0 commit comments