UNPKG

@gooddata/gooddata-js

Version:
81 lines (80 loc) 3.87 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); // (C) 2007-2020 GoodData Corporation var cloneDeep_1 = __importDefault(require("lodash/cloneDeep")); var xhr_1 = require("./xhr"); var user_1 = require("./user"); var metadata_1 = require("./metadata"); var execution_1 = require("./execution"); var project_1 = require("./project"); var report_1 = require("./report/report"); var dashboard_1 = require("./dashboard/dashboard"); var config_1 = require("./config"); var catalogue_1 = require("./catalogue"); var ldm_1 = require("./ldm"); var attributesMapLoader_1 = require("./utils/attributesMapLoader"); var visualizationObjectHelper_1 = require("./utils/visualizationObjectHelper"); var referenceHandling_1 = require("./referenceHandling"); var metadataExt_1 = require("./metadataExt"); var bootstrap_1 = require("./bootstrap"); /** * # JS SDK * Here is a set of functions that mostly are a thin wraper over the [GoodData API](https://developer.gooddata.com/api). * Before calling any of those functions, you need to authenticate with a valid GoodData * user credentials. After that, every subsequent call in the current session is authenticated. * You can find more about the GD authentication mechanism here. * * ## GD Authentication Mechansim * In this JS SDK library we provide you with a simple `login(username, passwd)` function * that does the magic for you. * To fully understand the authentication mechansim, please read * [Authentication via API article](http://developer.gooddata.com/article/authentication-via-api) * on [GoodData Developer Portal](http://developer.gooddata.com/) * * @module sdk * @class sdk */ var SDK = /** @class */ (function () { function SDK(fetchMethod, config) { if (config === void 0) { config = {}; } this.fetchMethod = fetchMethod; this.configStorage = config_1.sanitizeConfig(config); // must be plain object, SDK modules MUST use this storage this.config = new config_1.ConfigModule(this.configStorage); this.xhr = new xhr_1.XhrModule(fetchMethod, this.configStorage); this.user = new user_1.UserModule(this.xhr); this.md = new metadata_1.MetadataModule(this.xhr); this.mdExt = new metadataExt_1.MetadataModuleExt(this.xhr); this.execution = new execution_1.ExecutionModule(this.xhr, this.md); this.project = new project_1.ProjectModule(this.xhr); this.report = new report_1.ReportModule(this.xhr); this.dashboard = new dashboard_1.DashboardModule(this.xhr); this.catalogue = new catalogue_1.CatalogueModule(this.xhr, this.execution); this.bootstrap = new bootstrap_1.BootstrapModule(this.xhr); this.ldm = new ldm_1.LdmModule(this.xhr); var attributesMapLoaderModule = new attributesMapLoader_1.AttributesMapLoaderModule(this.md); this.utils = { loadAttributesMap: attributesMapLoaderModule.loadAttributesMap.bind(attributesMapLoaderModule), getAttributesDisplayForms: visualizationObjectHelper_1.getAttributesDisplayForms, convertReferencesToUris: referenceHandling_1.convertReferencesToUris, convertUrisToReferences: referenceHandling_1.convertUrisToReferences, }; } SDK.prototype.clone = function () { return new SDK(this.fetchMethod, cloneDeep_1.default(this.configStorage)); }; return SDK; }()); exports.SDK = SDK; /** * # Factory for creating SDK instances * * @param {object|null} config object to be passed to SDK constructor * @method setCustomDomain */ exports.factory = function (fetchMethod) { return function (config) { if (config === void 0) { config = {}; } return new SDK(fetchMethod, config); }; };