UNPKG

browser-sdk

Version:

javascript SDK for the lightelligence-platform

157 lines (140 loc) 6.79 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _apiService = _interopRequireDefault(require("../tools/apiService")); /** * Methods for application operations for the owner (developer) */ var ApplicationDeveloper = /*#__PURE__*/ function () { function ApplicationDeveloper() { (0, _classCallCheck2["default"])(this, ApplicationDeveloper); } (0, _createClass2["default"])(ApplicationDeveloper, null, [{ key: "createApplication", /** * Creates an application. * Include the tenant to the allowedTenants to enable the access for the usage. Ownership of the application does not imply ability to use the application. * @param {object} application The application data * @param {string} application.name The name of the application * @param {string} [application.teaserDescription] A short description for the application * @param {string} [application.url] A URL with more information on the app. E.g. the app homepage. Protocol is required * @param {boolean} [application.withPublicOauth2Client] Indicator of whether the application should also be accessible as a public OAuth2 client * @param {Array<string>} [application.redirectUris] List of redirect URIs * @param {Array<{tenantId:string, comment?:string}>} [application.allowedTenants] List of allowed tenants * @returns {Promise} */ value: function createApplication(application) { return _apiService["default"].call('/application-developer/applications', 'POST', application); } /** * Get all applications, which are owned (developed) by the tenant. * Tenant is implied by the session * @param {object} params Search parameters * @param {number} [params.page=0] The number of the result page starting with 0 * @param {number} [params.pageSize=10] The number of result per page. Default is 10 * @returns {Promise} */ }, { key: "getApplications", value: function getApplications(params) { var urlParams = new URLSearchParams(params); return _apiService["default"].call("/application-developer/applications?".concat(urlParams.toString())); } /** * Get details of a specific owned (developed) application * @param {string} applicationId The application ID * @returns {Promise} */ }, { key: "getApplicationDetails", value: function getApplicationDetails(applicationId) { return _apiService["default"].call("/application-developer/applications/".concat(applicationId)); } /** * Delete an owned (developed) application * @param {string} applicationId The application ID * @returns {Promise} */ }, { key: "deleteApplication", value: function deleteApplication(applicationId) { return _apiService["default"].call("/application-developer/applications/".concat(applicationId), 'DELETE'); } /** * Update an owned (developed) application * @param {string} applicationId The application ID * @param {object} application The applications data * @param {string} [application.name] The name of the application * @param {string} [application.teaserDescription] A short description for the application * @param {string} [application.url] A URL with more information on the app. E.g. the app homepage. Protocol is required * @param {boolean} [application.withPublicOauth2Client] Indicator of whether the application should also be accessible as a public OAuth2 client * @param {string} [application.status] Enum: 'active'. 'inactive'. Status of the application. An inactive application cannot be installed, nor can the tenant data be accessed * @param {Array<string>} [application.redirectUris] List of redirect URIs * @returns {Promise} */ }, { key: "patchApplication", value: function patchApplication(applicationId, application) { return _apiService["default"].call("/application-developer/applications/".concat(applicationId), 'PATCH', application); } /** * Get the list of the tenants who can install the application * @param {string} applicationId The application ID * @param {object} params Search parameters * @param {number} [params.page=0] The number of the result page starting with 0 * @param {number} [params.pageSize=10] The number of result per page. Default is 10 * @returns {Promise} */ }, { key: "getAllowedTenants", value: function getAllowedTenants(applicationId) { var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var urlParams = new URLSearchParams(params); return _apiService["default"].call("/application-developer/applications/".concat(applicationId, "/allowed-tenants?").concat(urlParams.toString())); } /** * Add a tenant to the list of those who can install the application * @param {string} applicationId The application ID * @param {string} tenantId The tenant ID * @param {object} [data] * @param {string} [data.comment] A comment about the allowed tenant * @returns {Promise} */ }, { key: "addAllowedTenant", value: function addAllowedTenant(applicationId, tenantId) { var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; return _apiService["default"].call("/application-developer/applications/".concat(applicationId, "/allowed-tenants/").concat(tenantId), 'PUT', data); } /** * Deletes the tenant from the list of the allowed tenants * @param {string} applicationId The application ID * @param {string} tenantId The tenant ID * @returns {Promise} */ }, { key: "removeAllowedTenant", value: function removeAllowedTenant(applicationId, tenantId) { return _apiService["default"].call("/application-developer/applications/".concat(applicationId, "/allowed-tenants/").concat(tenantId), 'DELETE'); } /** * Regenerates an application secret for an owned (developed) application * @param {string} applicationId The application ID * @returns {Promise} */ }, { key: "regenerateApplicationSecret", value: function regenerateApplicationSecret(applicationId) { return _apiService["default"].call("/application-developer/applications/".concat(applicationId, "/secret"), 'POST'); } }]); return ApplicationDeveloper; }(); exports["default"] = ApplicationDeveloper;