UNPKG

@camunda8/sdk

Version:

[![NPM](https://nodei.co/npm/@camunda8/sdk.png)](https://www.npmjs.com/package/@camunda8/sdk)

120 lines 4.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Camunda8 = void 0; const admin_1 = require("../admin"); const lib_1 = require("../lib"); const modeler_1 = require("../modeler"); const operate_1 = require("../operate"); const optimize_1 = require("../optimize"); const tasklist_1 = require("../tasklist"); const zeebe_1 = require("../zeebe"); const C8Logger_1 = require("./lib/C8Logger"); const CamundaRestClient_1 = require("./lib/CamundaRestClient"); /** * A single point of configuration for all Camunda Platform 8 clients. * * This class is a facade for all the clients in the Camunda Platform 8 SDK. * * @example * ```typescript * import { Camunda8 } from '@camunda8/sdk' * * const c8 = new Camunda8() * const zeebe = c8.getZeebeGrpcApiClient() * const operate = c8.getOperateApiClient() * const optimize = c8.getOptimizeApiClient() * const tasklist = c8.getTasklistApiClient() * const modeler = c8.getModelerApiClient() * const admin = c8.getAdminApiClient() * const c8Rest = c8.getCamundaRestClient() * ``` */ class Camunda8 { /** * All constructor parameters for configuration are optional. If no configuration is provided, the SDK will use environment variables to configure itself. */ constructor(config = {}) { this.configuration = lib_1.CamundaEnvironmentConfigurator.mergeConfigWithEnvironment(config); this.oAuthProvider = (0, lib_1.constructOAuthProvider)(this.configuration); this.log = (0, C8Logger_1.getLogger)(config); this.log.debug('Camunda8 SDK initialized'); } getOperateApiClient(config = {}) { if (!this.operateApiClient) { this.operateApiClient = new operate_1.OperateApiClient({ config: { ...this.configuration, ...config }, oAuthProvider: this.oAuthProvider, }); } return this.operateApiClient; } getAdminApiClient(config = {}) { if (!this.adminApiClient) { this.adminApiClient = new admin_1.AdminApiClient({ config: { ...this.configuration, ...config }, oAuthProvider: this.oAuthProvider, }); } return this.adminApiClient; } getModelerApiClient(config = {}) { if (!this.modelerApiClient) { this.modelerApiClient = new modeler_1.ModelerApiClient({ config: { ...this.configuration, ...config }, oAuthProvider: this.oAuthProvider, }); } return this.modelerApiClient; } getOptimizeApiClient(config = {}) { if (!this.optimizeApiClient) { this.optimizeApiClient = new optimize_1.OptimizeApiClient({ config: { ...this.configuration, ...config }, oAuthProvider: this.oAuthProvider, }); } return this.optimizeApiClient; } getTasklistApiClient(config = {}) { if (!this.tasklistApiClient) { this.tasklistApiClient = new tasklist_1.TasklistApiClient({ config: { ...this.configuration, ...config }, oAuthProvider: this.oAuthProvider, }); } return this.tasklistApiClient; } getZeebeGrpcApiClient(config = {}) { if (!this.zeebeGrpcApiClient) { this.zeebeGrpcApiClient = new zeebe_1.ZeebeGrpcClient({ config: { ...this.configuration, ...config }, oAuthProvider: this.oAuthProvider, }); } return this.zeebeGrpcApiClient; } /** * @deprecated from 8.6.0. Please use getCamundaRestClient() instead. */ getZeebeRestClient(config = {}) { if (!this.zeebeRestClient) { this.zeebeRestClient = new zeebe_1.ZeebeRestClient({ config: { ...this.configuration, ...config }, oAuthProvider: this.oAuthProvider, }); } return this.zeebeRestClient; } getCamundaRestClient(config = {}) { if (!this.camundaRestClient) { this.camundaRestClient = new CamundaRestClient_1.CamundaRestClient({ config: { ...this.configuration, ...config }, oAuthProvider: this.oAuthProvider, }); } return this.camundaRestClient; } } exports.Camunda8 = Camunda8; //# sourceMappingURL=index.js.map