UNPKG

baasic-sdk-javascript

Version:

JavaScript SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).

74 lines (73 loc) 3.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var common_1 = require("./common"); var contracts_1 = require("./core/contracts"); var core_1 = require("./core"); var _1 = require("./"); var httpApi_1 = require("./httpApi"); var modules = require("./modules"); var BaasicApp = /** @class */ (function () { function BaasicApp(apiKey, options) { this.apiKey = apiKey; this.options = options; this.utility = new common_1.Utility(); if (!this.apiKey) { throw new Error("API Key is required."); } var opt = {}; if (options) { opt = options; } this.settings = this.utility.extendAs({}, BaasicApp.defaultSettings, opt); this.diModule = new _1.DIModule(); this.diModule.init(this, [common_1.commonDIModule, core_1.coreDIModule, httpApi_1.httpDIModule, modules]); this.tokenHandler = this.diModule.kernel.get(contracts_1.TYPES.ITokenHandler); this.userHandler = this.diModule.kernel.get(contracts_1.TYPES.IUserHandler); this.eventHandler = this.diModule.kernel.get(contracts_1.TYPES.IEventHandler); this.apiClient = this.diModule.kernel.get(httpApi_1.httpTYPES.ApiClient); this.membershipModule = this.diModule.kernel.get(modules.Membership.TYPES.Root); //Modules this.applicationSettingModule = this.diModule.kernel.get(modules.ApplicationSettings.TYPES.ApplicationSettingsClient); this.keyValueModule = this.diModule.kernel.get(modules.KeyValue.TYPES.KeyValueClient); this.valueSetModule = this.diModule.kernel.get(modules.ValueSet.TYPES.ValueSetClient); this.userProfileModule = this.diModule.kernel.get(modules.UserProfile.TYPES.Root); this.templatingModule = this.diModule.kernel.get(modules.Templating.TYPES.TemplatingClient); this.meteringModule = this.diModule.kernel.get(modules.Metering.TYPES.MeteringClient); this.mediaVaultModule = this.diModule.kernel.get(modules.MediaVault.TYPES.MediaVaultClient); this.mediaGalleryModule = this.diModule.kernel.get(modules.MediaGallery.TYPES.Root); this.fileModule = this.diModule.kernel.get(modules.Files.TYPES.FilesClient); this.dynamicResourceModule = this.diModule.kernel.get(modules.DynamicResource.TYPES.DynamicResourceClient); this.notificationModule = this.diModule.kernel.get(modules.Notifications.TYPES.NotificationsClient); this.articleModule = this.diModule.kernel.get(modules.Article.TYPES.Root); this.commerceModule = this.diModule.kernel.get(modules.Commerce.TYPES.CommerceClient); this.calendarModule = this.diModule.kernel.get(modules.Calendar.TYPES.Root); this.shoppingCartModule = this.diModule.kernel.get(modules.ShoppingCart.TYPES.Root); this.blogModule = this.diModule.kernel.get(modules.Blog.TYPES.Root); } BaasicApp.prototype.getAccessToken = function () { return this.tokenHandler.get(contracts_1.TokenTypes.Access); }; BaasicApp.prototype.updateAccessToken = function (value) { this.tokenHandler.store(value); }; BaasicApp.prototype.getApiKey = function () { return this.apiKey; }; BaasicApp.prototype.getApiUrl = function () { return this.settings.apiUrl; }; BaasicApp.prototype.getUser = function () { return this.userHandler.getUser(); }; BaasicApp.prototype.setUser = function (userInfo) { this.userHandler.setUser(userInfo); }; BaasicApp.defaultSettings = { useSSL: true, apiRootUrl: 'api.baasic.com', apiVersion: 'v1', enableHALJSON: false }; return BaasicApp; }()); exports.BaasicApp = BaasicApp;