Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/common/open-api/models/HumanTaskDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
/* tslint:disable */
/* eslint-disable */

import type { HumanTaskAssignment } from './HumanTaskAssignment';
import type { HumanTaskTrigger } from './HumanTaskTrigger';
import type { UserFormTemplate } from './UserFormTemplate';
import type { HumanTaskAssignment } from "./HumanTaskAssignment";
import type { HumanTaskTemplate } from "./HumanTaskTemplate";
import type { HumanTaskTrigger } from "./HumanTaskTrigger";
import type { UserFormTemplate } from "./UserFormTemplate";

export type HumanTaskDefinition = {
assignmentCompletionStrategy?: 'LEAVE_OPEN' | 'TERMINATE';
assignmentCompletionStrategy?: "LEAVE_OPEN" | "TERMINATE";
assignments?: Array<HumanTaskAssignment>;
taskTriggers?: Array<HumanTaskTrigger>;
userFormTemplate?: UserFormTemplate;
fullTemplate?: HumanTaskTemplate;
};

1 change: 1 addition & 0 deletions src/common/open-api/models/HumanTaskSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type HumanTaskSearch = {
start?: number;
states?: Array<'PENDING' | 'ASSIGNED' | 'IN_PROGRESS' | 'COMPLETED' | 'TIMED_OUT' | 'DELETED'>;
taskRefNames?: Array<string>;
workflowIds?: Array<string>;
workflowNames?: Array<string>;
};

25 changes: 14 additions & 11 deletions src/common/open-api/services/HumanTaskService.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { HumanTaskAssignment } from '../models/HumanTaskAssignment';
import type { HumanTaskEntry } from '../models/HumanTaskEntry';
import type { HumanTaskSearch } from '../models/HumanTaskSearch';
import type { HumanTaskSearchResult } from '../models/HumanTaskSearchResult';
import type { HumanTaskTemplate } from '../models/HumanTaskTemplate';
import type { HumanTaskAssignment } from "../models/HumanTaskAssignment";
import type { HumanTaskEntry } from "../models/HumanTaskEntry";
import type { HumanTaskSearch } from "../models/HumanTaskSearch";
import type { HumanTaskSearchResult } from "../models/HumanTaskSearchResult";
import type { HumanTaskTemplate } from "../models/HumanTaskTemplate";

import type { CancelablePromise } from '../core/CancelablePromise';
import type { BaseHttpRequest } from '../core/BaseHttpRequest';
import type { CancelablePromise } from "../core/CancelablePromise";
import type { BaseHttpRequest } from "../core/BaseHttpRequest";

export class HumanTaskService {

constructor(public readonly httpRequest: BaseHttpRequest) {}

/**
Expand Down Expand Up @@ -105,12 +104,16 @@ export class HumanTaskService {
*/
public getTask1(
taskId: string,
withTemplate: boolean = false
): CancelablePromise<HumanTaskEntry> {
return this.httpRequest.request({
method: 'GET',
url: '/human/tasks/{taskId}',
path: {
'taskId': taskId,
taskId: taskId,
},
query: {
withTemplate,
},
});
}
Expand Down Expand Up @@ -245,8 +248,8 @@ export class HumanTaskService {
complete: boolean = false,
): CancelablePromise<any> {
return this.httpRequest.request({
method: 'POST',
url: '/human/tasks/{taskId}/update',
method: "POST",
url: "/human/tasks/{taskId}/update",
path: {
'taskId': taskId,
},
Expand Down
37 changes: 29 additions & 8 deletions src/core/human.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ type PollIntervalOptions = {
pollInterval: number;
maxPollTimes: number;
};

type ClaimOptions = {
overrideAssignment: boolean;
withTemplate: boolean;
};
export class HumanExecutor {
public readonly _client: ConductorClient;

Expand Down Expand Up @@ -60,7 +65,7 @@ export class HumanExecutor {
claimedBy?: string,
taskName?: string,
taskInputQuery?: string,
taskOutputQuery?: string,
taskOutputQuery?: string
): Promise<HumanTaskEntry[]> {
const [claimedUserType, claimedUser] = claimedBy?.split(":") ?? [];

Expand All @@ -76,7 +81,7 @@ export class HumanExecutor {
: [],
taskRefNames: taskName ? [taskName] : [],
taskInputQuery,
taskOutputQuery
taskOutputQuery,
});

return response;
Expand Down Expand Up @@ -141,8 +146,13 @@ export class HumanExecutor {
* @param taskId
* @returns
*/
public getTaskById(taskId: string): Promise<HumanTaskEntry> {
return tryCatchReThrow(() => this._client.humanTask.getTask1(taskId!));
public getTaskById(
taskId: string,
withTemplate: boolean = false
): Promise<HumanTaskEntry> {
return tryCatchReThrow(() =>
this._client.humanTask.getTask1(taskId!, withTemplate)
);
}

/**
Expand All @@ -154,10 +164,15 @@ export class HumanExecutor {
public async claimTaskAsExternalUser(
taskId: string,
assignee: string,
options?:Record<string,boolean>
options?: ClaimOptions
): Promise<HumanTaskEntry> {
return tryCatchReThrow(() =>
this._client.humanTask.assignAndClaim(taskId, assignee,options?.overrideAssignment,options?.withTemplate)
this._client.humanTask.assignAndClaim(
taskId,
assignee,
options?.overrideAssignment,
options?.withTemplate
)
);
}

Expand All @@ -168,9 +183,15 @@ export class HumanExecutor {
*/
public async claimTaskAsConductorUser(
taskId: string,
options?:Record<string,boolean>
options?: ClaimOptions
): Promise<HumanTaskEntry> {
return tryCatchReThrow(() => this._client.humanTask.claimTask(taskId,options?.overrideAssignment,options?.withTemplate));
return tryCatchReThrow(() =>
this._client.humanTask.claimTask(
taskId,
options?.overrideAssignment,
options?.withTemplate
)
);
}

/**
Expand Down
Loading