From 315c2c1cb30035d0dfedddd7c6effd0d55dc6014 Mon Sep 17 00:00:00 2001 From: James Stuart Milne Date: Fri, 9 Aug 2024 12:16:01 -0300 Subject: [PATCH 1/2] feat: add withTemplate flag in task. feat: add ability to search by workflowId --- src/common/open-api/models/HumanTaskSearch.ts | 1 + .../open-api/services/HumanTaskService.ts | 2 ++ src/core/human.ts | 28 +++++++++++++++---- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/common/open-api/models/HumanTaskSearch.ts b/src/common/open-api/models/HumanTaskSearch.ts index 80405a09..acd21dd2 100644 --- a/src/common/open-api/models/HumanTaskSearch.ts +++ b/src/common/open-api/models/HumanTaskSearch.ts @@ -15,6 +15,7 @@ export type HumanTaskSearch = { start?: number; states?: Array<'PENDING' | 'ASSIGNED' | 'IN_PROGRESS' | 'COMPLETED' | 'TIMED_OUT' | 'DELETED'>; taskRefNames?: Array; + workflowIds?: Array; workflowNames?: Array; }; diff --git a/src/common/open-api/services/HumanTaskService.ts b/src/common/open-api/services/HumanTaskService.ts index fc53f67f..b36158b2 100644 --- a/src/common/open-api/services/HumanTaskService.ts +++ b/src/common/open-api/services/HumanTaskService.ts @@ -105,12 +105,14 @@ export class HumanTaskService { */ public getTask1( taskId: string, + withTemplate: boolean = false, ): CancelablePromise { return this.httpRequest.request({ method: 'GET', url: '/human/tasks/{taskId}', path: { 'taskId': taskId, + withTemplate }, }); } diff --git a/src/core/human.ts b/src/core/human.ts index e89fd4a4..3766690e 100644 --- a/src/core/human.ts +++ b/src/core/human.ts @@ -141,8 +141,13 @@ export class HumanExecutor { * @param taskId * @returns */ - public getTaskById(taskId: string): Promise { - return tryCatchReThrow(() => this._client.humanTask.getTask1(taskId!)); + public getTaskById( + taskId: string, + withTemplate: boolean = false + ): Promise { + return tryCatchReThrow(() => + this._client.humanTask.getTask1(taskId!, withTemplate) + ); } /** @@ -154,10 +159,15 @@ export class HumanExecutor { public async claimTaskAsExternalUser( taskId: string, assignee: string, - options?:Record + options?: Record ): Promise { return tryCatchReThrow(() => - this._client.humanTask.assignAndClaim(taskId, assignee,options?.overrideAssignment,options?.withTemplate) + this._client.humanTask.assignAndClaim( + taskId, + assignee, + options?.overrideAssignment, + options?.withTemplate + ) ); } @@ -168,9 +178,15 @@ export class HumanExecutor { */ public async claimTaskAsConductorUser( taskId: string, - options?:Record + options?: Record ): Promise { - return tryCatchReThrow(() => this._client.humanTask.claimTask(taskId,options?.overrideAssignment,options?.withTemplate)); + return tryCatchReThrow(() => + this._client.humanTask.claimTask( + taskId, + options?.overrideAssignment, + options?.withTemplate + ) + ); } /** From 542ff77c932e96931e47854683b46780f773bc7d Mon Sep 17 00:00:00 2001 From: James Stuart Milne Date: Mon, 12 Aug 2024 10:24:54 -0300 Subject: [PATCH 2/2] fix: types to allow fetchingTemplate feat: add ability to search by workflowId --- .../open-api/models/HumanTaskDefinition.ts | 11 ++++---- .../open-api/services/HumanTaskService.ts | 27 ++++++++++--------- src/core/human.ts | 13 ++++++--- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/common/open-api/models/HumanTaskDefinition.ts b/src/common/open-api/models/HumanTaskDefinition.ts index 3a3316e8..f36c16e4 100644 --- a/src/common/open-api/models/HumanTaskDefinition.ts +++ b/src/common/open-api/models/HumanTaskDefinition.ts @@ -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; taskTriggers?: Array; userFormTemplate?: UserFormTemplate; + fullTemplate?: HumanTaskTemplate; }; - diff --git a/src/common/open-api/services/HumanTaskService.ts b/src/common/open-api/services/HumanTaskService.ts index b36158b2..1df7e133 100644 --- a/src/common/open-api/services/HumanTaskService.ts +++ b/src/common/open-api/services/HumanTaskService.ts @@ -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) {} /** @@ -105,14 +104,16 @@ export class HumanTaskService { */ public getTask1( taskId: string, - withTemplate: boolean = false, + withTemplate: boolean = false ): CancelablePromise { return this.httpRequest.request({ method: 'GET', url: '/human/tasks/{taskId}', path: { - 'taskId': taskId, - withTemplate + taskId: taskId, + }, + query: { + withTemplate, }, }); } @@ -247,8 +248,8 @@ export class HumanTaskService { complete: boolean = false, ): CancelablePromise { return this.httpRequest.request({ - method: 'POST', - url: '/human/tasks/{taskId}/update', + method: "POST", + url: "/human/tasks/{taskId}/update", path: { 'taskId': taskId, }, diff --git a/src/core/human.ts b/src/core/human.ts index 3766690e..eb6fbb7b 100644 --- a/src/core/human.ts +++ b/src/core/human.ts @@ -30,6 +30,11 @@ type PollIntervalOptions = { pollInterval: number; maxPollTimes: number; }; + +type ClaimOptions = { + overrideAssignment: boolean; + withTemplate: boolean; +}; export class HumanExecutor { public readonly _client: ConductorClient; @@ -60,7 +65,7 @@ export class HumanExecutor { claimedBy?: string, taskName?: string, taskInputQuery?: string, - taskOutputQuery?: string, + taskOutputQuery?: string ): Promise { const [claimedUserType, claimedUser] = claimedBy?.split(":") ?? []; @@ -76,7 +81,7 @@ export class HumanExecutor { : [], taskRefNames: taskName ? [taskName] : [], taskInputQuery, - taskOutputQuery + taskOutputQuery, }); return response; @@ -159,7 +164,7 @@ export class HumanExecutor { public async claimTaskAsExternalUser( taskId: string, assignee: string, - options?: Record + options?: ClaimOptions ): Promise { return tryCatchReThrow(() => this._client.humanTask.assignAndClaim( @@ -178,7 +183,7 @@ export class HumanExecutor { */ public async claimTaskAsConductorUser( taskId: string, - options?: Record + options?: ClaimOptions ): Promise { return tryCatchReThrow(() => this._client.humanTask.claimTask(