UNPKG

@camunda8/sdk

Version:

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

177 lines (176 loc) 8.48 kB
import { CamundaClient, CamundaClientLoose } from '@camunda8/orchestration-cluster-api'; import { AdminApiClient } from '../admin'; import { Camunda8ClientConfiguration } from '../lib'; import { ModelerApiClient } from '../modeler'; import { IHeadersProvider } from '../oauth'; import { OperateApiClient } from '../operate'; import { OptimizeApiClient } from '../optimize'; import { TasklistApiClient } from '../tasklist'; import { ZeebeGrpcClient } from '../zeebe'; import { Logger } from './lib/C8Logger'; import { CamundaRestClient } from './lib/CamundaRestClient'; /** Options interface for client creation */ interface ClientOptions { /** Whether to cache the client instance. Overrides global default if specified. */ cached?: boolean; } /** Options interface for Camunda8 constructor */ interface Camunda8Options { /** Default caching behavior for all client methods. Default: true */ defaultCached?: boolean; } /** * A single point of configuration for all Camunda Platform 8 clients. * * This class is a factory for all the clients in the Camunda Platform 8 SDK. It allows a single point of configuration for all clients. * * @example * ```typescript * import { Camunda8 } from '@camunda8/sdk' * * const c8 = new Camunda8() * // 8.8 REST API client - recommended * const camunda = c8.getOrchestrationClusterApiClient() // returns `CamundaClient` * // Loosely-typed 8.8 REST API client, for migration * const camundaLoose = c8.getOrchestrationClusterApiClientLoose() // returns `CamundaClientLoose` * // 8.7 REST API client * const c8Rest = c8.getCamundaRestClient() * // gRPC API client * const zeebe = c8.getZeebeGrpcApiClient() * // Infrastructure APIs * const modeler = c8.getModelerApiClient() * const admin = c8.getAdminApiClient() * // Legacy v1 API clients * const operate = c8.getOperateApiClient() * const optimize = c8.getOptimizeApiClient() * const tasklist = c8.getTasklistApiClient() * ``` */ export declare class Camunda8 { private readonly zeebeGrpcApiClients; private readonly camundaRestClients; private readonly operateApiClients; private readonly tasklistApiClients; private readonly optimizeApiClients; private readonly adminApiClients; private readonly modelerApiClients; private readonly orchestrationRestClients; private readonly orchestrationLooseClients; private readonly createdClients; private __apiClientCreationListener?; private readonly defaultCached; private readonly configuration; private readonly oAuthProvider; log: Logger; /** * All constructor parameters for configuration are optional. If no configuration is provided, the SDK will use environment variables to configure itself. * See {@link CamundaSDKConfiguration} for the complete list of configuration parameters. Values can be passed in explicitly in code, or set via environment variables (recommended: separate configuration and application logic). * Explicitly set values will override environment variables, which are merged into the configuration. */ constructor( /** * Optional explicit overrides. With no configuration, the SDK will use environment variables to configure itself. */ config?: Camunda8ClientConfiguration & { /** * An optional {@link IHeadersProvider} implementation. This can be used to add headers to REST requests made by the SDK. * In most cases, you will not need to supply this. You can use `CAMUNDA_AUTH_STRATEGY` and appropriate config values to configure * a preconfigured auth strategy. This configuration parameter is provided for advanced use-cases. **/ oAuthProvider?: IHeadersProvider; }, /** * Optional global configuration for the Camunda8 instance. */ options?: Camunda8Options); /** * @internal * Private hook for framework integration. Not part of public API. * Subject to change without notice. Use at your own risk. */ private __registerApiClientCreationListener; /** * Creates a deterministic cache key from configuration object */ private createConfigKey; /** * Closes all created API clients and clears all caches */ closeAllClients(): Promise<void>; /** * Returns a client for the "Operate REST API" * See: https://docs.camunda.io/docs/apis-tools/operate-api/overview/ */ getOperateApiClient(config?: Camunda8ClientConfiguration, options?: ClientOptions): OperateApiClient; private createNewOperateApiClient; /** * Returns a client for the Administration REST API * See: https://docs.camunda.io/docs/apis-tools/administration-api/administration-api-reference/ */ getAdminApiClient(config?: Camunda8ClientConfiguration, options?: ClientOptions): AdminApiClient; private createNewAdminApiClient; /** * Returns a client for the Web Modeler REST API * See: https://docs.camunda.io/docs/apis-tools/web-modeler-api/overview/ */ getModelerApiClient(config?: Camunda8ClientConfiguration, options?: ClientOptions): ModelerApiClient; private createNewModelerApiClient; /** * Returns a client for the Optimize REST API * See: https://docs.camunda.io/docs/apis-tools/optimize-api/overview/ */ getOptimizeApiClient(config?: Camunda8ClientConfiguration, options?: ClientOptions): OptimizeApiClient; private createNewOptimizeApiClient; /** * Returns a client for the Tasklist REST API * See: https://docs.camunda.io/docs/apis-tools/tasklist-api-rest/tasklist-api-rest-overview/ */ getTasklistApiClient(config?: Camunda8ClientConfiguration, options?: ClientOptions): TasklistApiClient; private createNewTasklistApiClient; /** * Returns a client for the Zeebe gRPC API * See: https://docs.camunda.io/docs/apis-tools/zeebe-api/overview/ */ getZeebeGrpcApiClient(config?: Camunda8ClientConfiguration, options?: ClientOptions): ZeebeGrpcClient; private createNewZeebeGrpcClient; /** * Returns a client for the Camunda 8 REST API * See: https://docs.camunda.io/docs/apis-tools/camunda-api-rest/camunda-api-rest-overview/ */ getCamundaRestClient(config?: Camunda8ClientConfiguration, options?: ClientOptions): CamundaRestClient; /** * Returns a strongly-typed Orchestration Cluster API client, of type `CamundaClient`. * See [here](https://camunda.github.io/orchestration-cluster-api-js/classes/index.CamundaClient.html) for full API documentation of the `CamundaClient`. * * This client exposes branded identifier types (e.g. {@link OrchestrationLifters.ProcessInstanceKey}) * to provide additional compile-time safety when interacting with the Orchestration Cluster API. * * The configuration passed here is merged with environment variables (see {@link CamundaSDKConfiguration}). * When `options.cached` (default) is true, a client instance keyed by its effective configuration is reused. * * @param config Optional explicit SDK configuration overrides. * @param options Client creation options (e.g. caching control). * @returns {@link CamundaClient} A branded Orchestration Cluster API client instance. */ getOrchestrationClusterApiClient(config?: Camunda8ClientConfiguration, options?: ClientOptions): CamundaClient; /** * Returns a loosely-typed Orchestration Cluster API client. * This variant widens branded key types to primitive strings for progressive adoption. */ /** * Returns a loosely-typed Orchestration Cluster API client. * * This variant widens branded identifier types to plain strings to make incremental adoption easier * in existing codebases that already use raw string IDs. Use this when you prefer flexibility over * the additional type safety provided by {@link getOrchestrationClusterApiClient}. * * @param config Optional explicit SDK configuration overrides. * @param options Client creation options (e.g. caching control). * @returns {@link CamundaClientLoose} A loose Orchestration Cluster API client instance. */ getOrchestrationClusterApiClientLoose(config?: Camunda8ClientConfiguration, options?: ClientOptions): CamundaClientLoose; private createNewOrchestrationClusterApiClientLoose; private createNewOrchestrationClusterApiClient; private createNewCamundaRestClient; } export {};