UNPKG

@kuflow/kuflow-rest

Version:
119 lines 4.55 kB
"use strict"; /** * The MIT License * Copyright © 2021-present KuFlow S.L. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.KuFlowRestClient = void 0; const generated_1 = require("./generated"); const operations_1 = require("./operations"); class KuFlowRestClient { static API_VERSION = 'v2024-06-14'; /** * Authentication API operations. */ authenticationOperations; /** * KMS API operations. */ kmsOperations; /** * Principal API operations. */ principalOperations; /** * Tenant API operations. */ tenantOperations; /** * Tenant User API operations. */ tenantUserOperations; /** * Process API operations. */ processOperations; /** * Process Item API operations. */ processItemOperations; /** * Worker API operations. */ workerOperations; /** * Robot API operations. */ robotOperations; /** * Initializes a new instance of the KuFlowClient class. * @param authentication Credentials which uniquely identify the client. * @param options The parameter options */ constructor(authentication, options) { options = this.normalizeOptions(options); const tokenCredential = kuflowTokenCredential(authentication); const clientGenerated = new generated_1.KuFlowRestClientGenerated(tokenCredential, { ...options, credentialScopes: 'https://api.kuflow.com/v2024-06-14/.default', }); this.authenticationOperations = new operations_1.AuthenticationOperations(clientGenerated); this.kmsOperations = new operations_1.KmsOperations(clientGenerated); this.principalOperations = new operations_1.PrincipalOperations(clientGenerated); this.tenantOperations = new operations_1.TenantOperations(clientGenerated); this.tenantUserOperations = new operations_1.TenantUserOperations(clientGenerated); this.processOperations = new operations_1.ProcessOperations(clientGenerated); this.processItemOperations = new operations_1.ProcessItemOperations(clientGenerated); this.workerOperations = new operations_1.WorkerOperations(clientGenerated); this.robotOperations = new operations_1.RobotOperations(clientGenerated); } normalizeOptions(options) { if (options == null) { return undefined; } if (options.endpoint != null) { options.endpoint = options.endpoint.trim(); if (!options.endpoint.endsWith(`/${KuFlowRestClient.API_VERSION}`)) { options.endpoint = `${options.endpoint}/${KuFlowRestClient.API_VERSION}`; } } return options; } } exports.KuFlowRestClient = KuFlowRestClient; function kuflowTokenCredential(authentication) { if (authentication.credential != null) { return authentication.credential; } if (authentication.clientId != null && authentication.clientSecret != null) { const accessToken = { token: Buffer.from(`${authentication.clientId}:${authentication.clientSecret}`).toString('base64'), expiresOnTimestamp: Number.MAX_VALUE, }; return { async getToken() { return accessToken; }, }; } throw new Error('credential or clientId/clientSecret is required'); } //# sourceMappingURL=kuFlowRestClient.js.map