UNPKG

3.87 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6// (C) 2007-2020 GoodData Corporation
7var cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
8var xhr_1 = require("./xhr");
9var user_1 = require("./user");
10var metadata_1 = require("./metadata");
11var execution_1 = require("./execution");
12var project_1 = require("./project");
13var report_1 = require("./report/report");
14var dashboard_1 = require("./dashboard/dashboard");
15var config_1 = require("./config");
16var catalogue_1 = require("./catalogue");
17var ldm_1 = require("./ldm");
18var attributesMapLoader_1 = require("./utils/attributesMapLoader");
19var visualizationObjectHelper_1 = require("./utils/visualizationObjectHelper");
20var referenceHandling_1 = require("./referenceHandling");
21var metadataExt_1 = require("./metadataExt");
22var bootstrap_1 = require("./bootstrap");
23/**
24 * # JS SDK
25 * Here is a set of functions that mostly are a thin wraper over the [GoodData API](https://developer.gooddata.com/api).
26 * Before calling any of those functions, you need to authenticate with a valid GoodData
27 * user credentials. After that, every subsequent call in the current session is authenticated.
28 * You can find more about the GD authentication mechanism here.
29 *
30 * ## GD Authentication Mechansim
31 * In this JS SDK library we provide you with a simple `login(username, passwd)` function
32 * that does the magic for you.
33 * To fully understand the authentication mechansim, please read
34 * [Authentication via API article](http://developer.gooddata.com/article/authentication-via-api)
35 * on [GoodData Developer Portal](http://developer.gooddata.com/)
36 *
37 * @module sdk
38 * @class sdk
39 */
40var SDK = /** @class */ (function () {
41 function SDK(fetchMethod, config) {
42 if (config === void 0) { config = {}; }
43 this.fetchMethod = fetchMethod;
44 this.configStorage = config_1.sanitizeConfig(config); // must be plain object, SDK modules MUST use this storage
45 this.config = new config_1.ConfigModule(this.configStorage);
46 this.xhr = new xhr_1.XhrModule(fetchMethod, this.configStorage);
47 this.user = new user_1.UserModule(this.xhr);
48 this.md = new metadata_1.MetadataModule(this.xhr);
49 this.mdExt = new metadataExt_1.MetadataModuleExt(this.xhr);
50 this.execution = new execution_1.ExecutionModule(this.xhr, this.md);
51 this.project = new project_1.ProjectModule(this.xhr);
52 this.report = new report_1.ReportModule(this.xhr);
53 this.dashboard = new dashboard_1.DashboardModule(this.xhr);
54 this.catalogue = new catalogue_1.CatalogueModule(this.xhr, this.execution);
55 this.bootstrap = new bootstrap_1.BootstrapModule(this.xhr);
56 this.ldm = new ldm_1.LdmModule(this.xhr);
57 var attributesMapLoaderModule = new attributesMapLoader_1.AttributesMapLoaderModule(this.md);
58 this.utils = {
59 loadAttributesMap: attributesMapLoaderModule.loadAttributesMap.bind(attributesMapLoaderModule),
60 getAttributesDisplayForms: visualizationObjectHelper_1.getAttributesDisplayForms,
61 convertReferencesToUris: referenceHandling_1.convertReferencesToUris,
62 convertUrisToReferences: referenceHandling_1.convertUrisToReferences,
63 };
64 }
65 SDK.prototype.clone = function () {
66 return new SDK(this.fetchMethod, cloneDeep_1.default(this.configStorage));
67 };
68 return SDK;
69}());
70exports.SDK = SDK;
71/**
72 * # Factory for creating SDK instances
73 *
74 * @param {object|null} config object to be passed to SDK constructor
75 * @method setCustomDomain
76 */
77exports.factory = function (fetchMethod) { return function (config) {
78 if (config === void 0) { config = {}; }
79 return new SDK(fetchMethod, config);
80}; };