UNPKG

@camunda8/sdk

Version:

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

113 lines (112 loc) 5.42 kB
import { CamundaPlatform8Configuration, DeepPartial } from '../../lib'; import { IHeadersProvider } from '../../oauth'; import { Form, TaskResponse, TaskSearchAfterOrEqualRequest, TaskSearchAfterRequest, TaskSearchBeforeOrEqualRequest, TaskSearchBeforeRequest, TaskSearchRequestBase, TaskSearchResponse, Variable, VariableSearchResponse } from './TasklistDto'; import { JSONDoc } from './utils'; /** * The high-level client for the Tasklist REST API * @example * ``` * * ``` */ export declare class TasklistApiClient { private userAgentString; private oAuthProvider; private rest; /** * Tasklist API Client. * 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. * @example * ``` * const tasklist = new TasklistApiClient() * const tasks = await tasklist.getTasks({ state: TaskState.CREATED }) * ``` * */ constructor(options?: { config?: DeepPartial<CamundaPlatform8Configuration>; oAuthProvider?: IHeadersProvider; }); private getHeaders; private replaceDatesWithString; /** * Query Tasklist for a list of tasks. See the [API documentation](https://docs.camunda.io/docs/apis-clients/tasklist-api/queries/tasks/). * @throws Status 400 - An error is returned when more than one search parameters among [`searchAfter`, `searchAfterOrEqual`, `searchBefore`, `searchBeforeOrEqual`] are present in request * @throws {RESTError} * @example * ``` * const tasklist = new TasklistApiClient() * * async function getTasks() { * const res = await tasklist.searchTasks({ * state: TaskState.CREATED * }) * console.log(res ? 'Nothing' : JSON.stringify(res, null, 2)) * return res * } * ``` * @param query */ searchTasks(query: TaskSearchAfterRequest | TaskSearchAfterOrEqualRequest | TaskSearchBeforeRequest | TaskSearchBeforeOrEqualRequest | Partial<TaskSearchRequestBase>): Promise<TaskSearchResponse[]>; /** * Return a task by id, or throw if not found. * @throws {RESTError} Will throw if no task of the given taskId exists * @returns */ getTask(taskId: string): Promise<TaskResponse>; /** * Get the form details by form id and processDefinitionKey. * @throws {RESTError} */ getForm(formId: string, processDefinitionKey: string, version?: string | number): Promise<Form>; /** * This method returns a list of task variables for the specified taskId and variableNames. If the variableNames parameter is empty, all variables associated with the task will be returned. * @throws {RESTError} */ getVariables({ taskId, variableNames, includeVariables, }: { taskId: string; variableNames?: string[]; includeVariables?: { name: string; alwaysReturnFullValue: boolean; }[]; }): Promise<VariableSearchResponse[]>; /** * https://docs.camunda.io/docs/apis-clients/tasklist-api/queries/variable/ * @throws Throws 404 if no variable of the id is found */ getVariable(variableId: string): Promise<Variable>; /** * Assign a task with taskId to assignee or the active user. * @throws {RESTError} * @throws Status 400 - An error is returned when the task is not active (not in the CREATED state). * Status 400 - An error is returned when task was already assigned, except the case when JWT authentication token used and allowOverrideAssignment = true. * Status 403 - An error is returned when user doesn't have the permission to assign another user to this task. * Status 404 - An error is returned when the task with the taskId is not found. */ assignTask({ taskId, allowOverrideAssignment, assignee, }: { taskId: string; assignee?: string; allowOverrideAssignment?: boolean; }): Promise<TaskResponse>; /** * Complete a task with taskId and optional variables * @throws {RESTError} * @throws Status 400 An error is returned when the task is not active (not in the CREATED state). * @throws Status 400 An error is returned if the task was not claimed (assigned) before. * @throws Status 400 An error is returned if the task is not assigned to the current user. * @throws Status 403 User has no permission to access the task (Self-managed only). * @throws Status 404 An error is returned when the task with the taskId is not found. */ completeTask(taskId: string, variables?: JSONDoc): Promise<TaskResponse>; /** * Unassign a task with taskId * @throws Status 400 An error is returned when the task is not active (not in the CREATED state). * @throws Status 400 An error is returned if the task was not claimed (assigned) before. * @throws Status 404 An error is returned when the task with the taskId is not found. * @throws {RESTError} */ unassignTask(taskId: string): Promise<TaskResponse>; }