UNPKG

@camunda8/sdk

Version:

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

253 lines (252 loc) 8.06 kB
import { CamundaPlatform8Configuration, DeepPartial } from '../../lib'; import { IOAuthProvider } from '../../oauth'; import { ChangeStatus, DecisionDefinition, DecisionInstance, DecisionRequirements, FlownodeInstance, Incident, ProcessDefinition, ProcessInstance, ProcessInstanceStatistics, Query, SearchResults, Variable } from './OperateDto'; type JSONDoc = { [key: string]: string | boolean | number | JSONDoc; }; type EnhanceWithTenantIdIfMissing<T> = T extends { filter: { tenantId: string | undefined; }; } ? T : T extends { filter: infer F; } ? { filter: F & { tenantId: string | undefined; }; } & Omit<T, 'filter'> : { filter: { tenantId: string | undefined; }; } & T; /** * @description The high-level client for Operate. * @example * ``` * const operate = new OperateApiClient() * * operate.searchProcessInstances({ * filter: { * state: "ACTIVE" * }, * size: 50 * }).then(instances => { * console.log(instances) * }) * ``` */ export declare class OperateApiClient { private userAgentString; private oAuthProvider; private rest; private tenantId; /** * @example * ``` * const operate = new OperateApiClient() * ``` * @throws {RESTError} An error that may occur during API operations. */ constructor(options?: { config?: DeepPartial<CamundaPlatform8Configuration>; oAuthProvider?: IOAuthProvider; }); private getHeaders; protected addTenantIdToFilter<T>(query: Query<T>, tenantId?: string | undefined): Query<EnhanceWithTenantIdIfMissing<T>>; /** * @description Search and retrieve process definitions. * * [Camunda 8 Documentation](https://docs.camunda.io/docs/apis-clients/operate-api/#process-definition) * @throws {RESTError} * @example * ``` * const query: Query<ProcessDefinition> = { * filter: {}, * size: 50, * sort: [ * { * field: "bpmnProcessId", * order: "ASC", * }, * ], * }; * const operate = newOperateClient() * const defs = await operate.searchProcessDefinitions(query); * ``` */ searchProcessDefinitions(query?: Query<ProcessDefinition>): Promise<SearchResults<ProcessDefinition>>; /** * * @description Retrieve the metadata for a specific process definition, by key. * @throws {RESTError} * [Camunda 8 Documentation](https://docs.camunda.io/docs/apis-clients/operate-api/#process-definition) * @example * ``` * const operate = new OperateApiClient() * const definition = await operate.getProcessDefinition(2251799817140074); * ``` */ getProcessDefinition(processDefinitionKey: number | string): Promise<ProcessDefinition>; getProcessDefinitionXML(processDefinitionKey: number | string): Promise<string>; /** * * @throws {RESTError} */ searchDecisionDefinitions(query: Query<DecisionDefinition>): Promise<SearchResults<DecisionDefinition>>; /** * @throws {RESTError} */ getDecisionDefinition(decisionDefinitionKey: number | string): Promise<DecisionDefinition>; /** * @throws {RESTError} */ searchDecisionInstances(query: Query<DecisionInstance>): Promise<SearchResults<DecisionInstance>>; /** * @throws {RESTError} */ getDecisionInstance(decisionInstanceKey: number | string): Promise<DecisionInstance>; /** * @description Search and retrieve process instances. * @throws {RESTError} * @example * ``` * const operate = new OperateApiClient() * const query: Query<ProcessInstance> = { * filter: { * processVersion: 1 * }, * size: 50, * sort: [ * { * field: "bpmProcessId", * order: "ASC" * } * ] * } * const instances = await operate.searchProcessInstances(query) * console.log(`Found ${instances.total} instances`) */ searchProcessInstances(query?: Query<ProcessInstance>): Promise<SearchResults<ProcessInstance>>; /** * * @description Retrieve a specific process instance by id. * @throws {RESTError} * @example * ``` * const operate = new OperateApiClient() * const instance = await operate.getProcessInstance(2251799819847322) * ``` */ getProcessInstance(processInstanceKey: number | string): Promise<ProcessInstance>; /** * @description Delete a specific process instance by key. * @throws {RESTError} * @example * ``` * const operate = new OperateApiClient() * await operate.deleteProcessInstance(2251799819847322) * ``` */ deleteProcessInstance(processInstanceKey: number | string): Promise<ChangeStatus>; /** * @description Get the statistics for a process instance, grouped by flow nodes * @throws {RESTError} */ getProcessInstanceStatistics(processInstanceKey: number | string): Promise<ProcessInstanceStatistics[]>; /** * @description Get sequence flows of process instance by key * @throws {RESTError} */ getProcessInstanceSequenceFlows(processInstanceKey: number | string): Promise<string[]>; /** * * @description Search and retrieve incidents. * @throws {RESTError} * @example * ``` * const operate = new OperateApiClient() * const query: Query<Incident> = { * filter: { * state: "ACTIVE" * }, * size: 50, * sort: [ * { * field: "creationTime", * order: "ASC" * } * ] * } * const incidents = operate.searchIncidents(query) * ``` */ searchIncidents(query?: Query<Incident>): Promise<SearchResults<Incident>>; /** * * @description Retrieve an incident by incident key. * @throws {RESTError} * @example * ``` * const operate = new OperateApiClient() * const incident = await operate.getIncident(2251799818436725) * console.log(incident.message) * ``` */ getIncident(key: number | string): Promise<Incident>; /** * @throws {RESTError} */ searchFlownodeInstances(query: Query<FlownodeInstance>): Promise<SearchResults<FlownodeInstance>>; /** * @throws {RESTError} */ getFlownodeInstance(key: number | string): Promise<FlownodeInstance>; /** * @throws {RESTError} */ searchVariables(query: Query<Variable>): Promise<SearchResults<Variable>>; /** * @description Retrieve the variables for a Process Instance, given its key. Documentation: https://docs.camunda.io/docs/apis-tools/operate-api/specifications/search/ * @throws {RESTError} * @param processInstanceKey * @returns */ getVariablesforProcess(processInstanceKey: number | string, options?: { size?: number; searchAfter?: unknown[]; sort?: { field: string; order?: 'ASC' | 'DESC'; }[]; }): Promise<{ items: Variable[]; sortValues: unknown[]; total: number; }>; /** * @description Retrieve the variables for a Process Instance as an object, given its key * @param processInstanceKey * @throws {RESTError} */ getJSONVariablesforProcess<T extends { [key: string]: JSONDoc; }>(processInstanceKey: number | string, size?: number): Promise<T>; private safeJSONparse; /** * * @description Return a variable identified by its variable key * @throws {RESTError} * @returns */ getVariables(variableKey: number | string): Promise<Variable>; /** * @throws {RESTError} */ searchDecisionRequirements(query: Query<DecisionRequirements>): Promise<unknown>; getDecisionRequirements(key: string | number): Promise<DecisionRequirements>; /** * @throws {RESTError} */ getDecisionRequirementsXML(key: string | number): Promise<string>; } export {};