@io-orkes/conductor-javascript 1.2.2 → 2.0.0-rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/browser.d.mts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +268 -134
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +267 -134
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +268 -134
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +267 -134
- package/dist/index.mjs.map +1 -1
- package/dist/{types-1e3272c6.d.ts → types-dbfd77fb.d.ts} +536 -521
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -50,6 +50,7 @@ __export(browser_exports, {
|
|
|
50
50
|
WorkflowBulkResourceService: () => WorkflowBulkResourceService,
|
|
51
51
|
WorkflowExecutor: () => WorkflowExecutor,
|
|
52
52
|
WorkflowResourceService: () => WorkflowResourceService,
|
|
53
|
+
completedTaskMatchingType: () => completedTaskMatchingType,
|
|
53
54
|
conductorEventTask: () => conductorEventTask,
|
|
54
55
|
doWhileTask: () => doWhileTask,
|
|
55
56
|
dynamicForkTask: () => dynamicForkTask,
|
|
@@ -1918,83 +1919,70 @@ var HumanTaskService = class {
|
|
|
1918
1919
|
this.httpRequest = httpRequest;
|
|
1919
1920
|
}
|
|
1920
1921
|
/**
|
|
1921
|
-
*
|
|
1922
|
-
* @param
|
|
1923
|
-
* @
|
|
1924
|
-
* @param assigneeType
|
|
1925
|
-
* @param claimedBy
|
|
1926
|
-
* @param taskName
|
|
1927
|
-
* @param freeText
|
|
1928
|
-
* @param includeInputOutput
|
|
1929
|
-
* @returns SearchResultHumanTaskEntry OK
|
|
1922
|
+
* If the workflow is disconnected from tasks, this API can be used to clean up (in bulk)
|
|
1923
|
+
* @param requestBody
|
|
1924
|
+
* @returns any OK
|
|
1930
1925
|
* @throws ApiError
|
|
1931
1926
|
*/
|
|
1932
|
-
|
|
1927
|
+
deleteTaskFromHumanTaskRecords(requestBody) {
|
|
1933
1928
|
return this.httpRequest.request({
|
|
1934
|
-
method: "
|
|
1935
|
-
url: "/human/tasks",
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
"assignee": assignee,
|
|
1939
|
-
"assigneeType": assigneeType,
|
|
1940
|
-
"claimedBy": claimedBy,
|
|
1941
|
-
"taskName": taskName,
|
|
1942
|
-
"freeText": freeText,
|
|
1943
|
-
"includeInputOutput": includeInputOutput
|
|
1944
|
-
}
|
|
1929
|
+
method: "DELETE",
|
|
1930
|
+
url: "/human/tasks/delete",
|
|
1931
|
+
body: requestBody,
|
|
1932
|
+
mediaType: "application/json"
|
|
1945
1933
|
});
|
|
1946
1934
|
}
|
|
1947
1935
|
/**
|
|
1948
|
-
*
|
|
1949
|
-
* @
|
|
1936
|
+
* If the workflow is disconnected from tasks, this API can be used to clean up
|
|
1937
|
+
* @param taskId
|
|
1938
|
+
* @returns any OK
|
|
1950
1939
|
* @throws ApiError
|
|
1951
1940
|
*/
|
|
1952
|
-
|
|
1941
|
+
deleteTaskFromHumanTaskRecords1(taskId) {
|
|
1953
1942
|
return this.httpRequest.request({
|
|
1954
|
-
method: "
|
|
1955
|
-
url: "/human/tasks/
|
|
1943
|
+
method: "DELETE",
|
|
1944
|
+
url: "/human/tasks/delete/{taskId}",
|
|
1945
|
+
path: {
|
|
1946
|
+
"taskId": taskId
|
|
1947
|
+
}
|
|
1956
1948
|
});
|
|
1957
1949
|
}
|
|
1958
1950
|
/**
|
|
1959
1951
|
* Search human tasks
|
|
1960
|
-
* @param
|
|
1961
|
-
* @
|
|
1962
|
-
* @param size
|
|
1963
|
-
* @param freeText
|
|
1964
|
-
* @param query
|
|
1965
|
-
* @param jsonQuery
|
|
1966
|
-
* @param includeInputOutput
|
|
1967
|
-
* @returns HTScrollableSearchResultHumanTaskEntry OK
|
|
1952
|
+
* @param requestBody
|
|
1953
|
+
* @returns HumanTaskSearchResult OK
|
|
1968
1954
|
* @throws ApiError
|
|
1969
1955
|
*/
|
|
1970
|
-
|
|
1956
|
+
search(requestBody) {
|
|
1971
1957
|
return this.httpRequest.request({
|
|
1972
|
-
method: "
|
|
1958
|
+
method: "POST",
|
|
1973
1959
|
url: "/human/tasks/search",
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
"start": start,
|
|
1977
|
-
"size": size,
|
|
1978
|
-
"freeText": freeText,
|
|
1979
|
-
"query": query,
|
|
1980
|
-
"jsonQuery": jsonQuery,
|
|
1981
|
-
"includeInputOutput": includeInputOutput
|
|
1982
|
-
}
|
|
1960
|
+
body: requestBody,
|
|
1961
|
+
mediaType: "application/json"
|
|
1983
1962
|
});
|
|
1984
1963
|
}
|
|
1985
1964
|
/**
|
|
1986
|
-
*
|
|
1987
|
-
* @param
|
|
1965
|
+
* Update task output, optionally complete
|
|
1966
|
+
* @param workflowId
|
|
1967
|
+
* @param taskRefName
|
|
1968
|
+
* @param requestBody
|
|
1969
|
+
* @param complete
|
|
1970
|
+
* @param iteration Populate this value if your task is in a loop and you want to update a specific iteration. If its not in a loop OR if you want to just update the latest iteration, leave this as empty
|
|
1988
1971
|
* @returns any OK
|
|
1989
1972
|
* @throws ApiError
|
|
1990
1973
|
*/
|
|
1991
|
-
|
|
1974
|
+
updateTaskOutputByRef(workflowId, taskRefName, requestBody, complete = false, iteration) {
|
|
1992
1975
|
return this.httpRequest.request({
|
|
1993
|
-
method: "
|
|
1994
|
-
url: "/human/tasks/
|
|
1995
|
-
|
|
1996
|
-
"
|
|
1997
|
-
|
|
1976
|
+
method: "POST",
|
|
1977
|
+
url: "/human/tasks/update/taskRef",
|
|
1978
|
+
query: {
|
|
1979
|
+
"workflowId": workflowId,
|
|
1980
|
+
"taskRefName": taskRefName,
|
|
1981
|
+
"complete": complete,
|
|
1982
|
+
"iteration": iteration
|
|
1983
|
+
},
|
|
1984
|
+
body: requestBody,
|
|
1985
|
+
mediaType: "application/json"
|
|
1998
1986
|
});
|
|
1999
1987
|
}
|
|
2000
1988
|
/**
|
|
@@ -2012,33 +2000,22 @@ var HumanTaskService = class {
|
|
|
2012
2000
|
}
|
|
2013
2001
|
});
|
|
2014
2002
|
}
|
|
2015
|
-
/**
|
|
2016
|
-
* Get human task action log entries by task id
|
|
2017
|
-
* @param taskId
|
|
2018
|
-
* @returns HumanTaskActionLogEntry OK
|
|
2019
|
-
* @throws ApiError
|
|
2020
|
-
*/
|
|
2021
|
-
getActionLogs(taskId) {
|
|
2022
|
-
return this.httpRequest.request({
|
|
2023
|
-
method: "GET",
|
|
2024
|
-
url: "/human/tasks/{taskId}/actionLogs",
|
|
2025
|
-
path: {
|
|
2026
|
-
"taskId": taskId
|
|
2027
|
-
}
|
|
2028
|
-
});
|
|
2029
|
-
}
|
|
2030
2003
|
/**
|
|
2031
2004
|
* Claim a task by authenticated Conductor user
|
|
2032
2005
|
* @param taskId
|
|
2006
|
+
* @param overrideAssignment
|
|
2033
2007
|
* @returns any OK
|
|
2034
2008
|
* @throws ApiError
|
|
2035
2009
|
*/
|
|
2036
|
-
claimTask(taskId) {
|
|
2010
|
+
claimTask(taskId, overrideAssignment = false) {
|
|
2037
2011
|
return this.httpRequest.request({
|
|
2038
2012
|
method: "POST",
|
|
2039
2013
|
url: "/human/tasks/{taskId}/claim",
|
|
2040
2014
|
path: {
|
|
2041
2015
|
"taskId": taskId
|
|
2016
|
+
},
|
|
2017
|
+
query: {
|
|
2018
|
+
"overrideAssignment": overrideAssignment
|
|
2042
2019
|
}
|
|
2043
2020
|
});
|
|
2044
2021
|
}
|
|
@@ -2046,16 +2023,20 @@ var HumanTaskService = class {
|
|
|
2046
2023
|
* Claim a task to an external user
|
|
2047
2024
|
* @param taskId
|
|
2048
2025
|
* @param userId
|
|
2026
|
+
* @param overrideAssignment
|
|
2049
2027
|
* @returns any OK
|
|
2050
2028
|
* @throws ApiError
|
|
2051
2029
|
*/
|
|
2052
|
-
assignAndClaim(taskId, userId) {
|
|
2030
|
+
assignAndClaim(taskId, userId, overrideAssignment = false) {
|
|
2053
2031
|
return this.httpRequest.request({
|
|
2054
2032
|
method: "POST",
|
|
2055
2033
|
url: "/human/tasks/{taskId}/externalUser/{userId}",
|
|
2056
2034
|
path: {
|
|
2057
2035
|
"taskId": taskId,
|
|
2058
2036
|
"userId": userId
|
|
2037
|
+
},
|
|
2038
|
+
query: {
|
|
2039
|
+
"overrideAssignment": overrideAssignment
|
|
2059
2040
|
}
|
|
2060
2041
|
});
|
|
2061
2042
|
}
|
|
@@ -2093,17 +2074,21 @@ var HumanTaskService = class {
|
|
|
2093
2074
|
});
|
|
2094
2075
|
}
|
|
2095
2076
|
/**
|
|
2096
|
-
*
|
|
2077
|
+
* If a task is assigned to a user, this API can be used to skip that assignment and move to the next assignee
|
|
2097
2078
|
* @param taskId
|
|
2098
|
-
* @
|
|
2079
|
+
* @param reason
|
|
2080
|
+
* @returns any OK
|
|
2099
2081
|
* @throws ApiError
|
|
2100
2082
|
*/
|
|
2101
|
-
|
|
2083
|
+
skipTask(taskId, reason) {
|
|
2102
2084
|
return this.httpRequest.request({
|
|
2103
|
-
method: "
|
|
2104
|
-
url: "/human/tasks/{taskId}/
|
|
2085
|
+
method: "POST",
|
|
2086
|
+
url: "/human/tasks/{taskId}/skip",
|
|
2105
2087
|
path: {
|
|
2106
2088
|
"taskId": taskId
|
|
2089
|
+
},
|
|
2090
|
+
query: {
|
|
2091
|
+
"reason": reason
|
|
2107
2092
|
}
|
|
2108
2093
|
});
|
|
2109
2094
|
}
|
|
@@ -2130,48 +2115,51 @@ var HumanTaskService = class {
|
|
|
2130
2115
|
});
|
|
2131
2116
|
}
|
|
2132
2117
|
/**
|
|
2133
|
-
*
|
|
2118
|
+
* List all user form templates or get templates by name, or a template by name and version
|
|
2134
2119
|
* @param name
|
|
2135
|
-
* @
|
|
2120
|
+
* @param version
|
|
2121
|
+
* @returns HumanTaskTemplate OK
|
|
2136
2122
|
* @throws ApiError
|
|
2137
2123
|
*/
|
|
2138
|
-
|
|
2124
|
+
getAllTemplates(name, version) {
|
|
2139
2125
|
return this.httpRequest.request({
|
|
2140
|
-
method: "
|
|
2126
|
+
method: "GET",
|
|
2141
2127
|
url: "/human/template",
|
|
2142
2128
|
query: {
|
|
2143
|
-
"name": name
|
|
2129
|
+
"name": name,
|
|
2130
|
+
"version": version
|
|
2144
2131
|
}
|
|
2145
2132
|
});
|
|
2146
2133
|
}
|
|
2147
2134
|
/**
|
|
2148
|
-
*
|
|
2149
|
-
* @param
|
|
2150
|
-
* @param
|
|
2151
|
-
* @returns
|
|
2135
|
+
* Save user form template
|
|
2136
|
+
* @param requestBody
|
|
2137
|
+
* @param newVersion
|
|
2138
|
+
* @returns HumanTaskTemplate OK
|
|
2152
2139
|
* @throws ApiError
|
|
2153
2140
|
*/
|
|
2154
|
-
|
|
2141
|
+
saveTemplate(requestBody, newVersion = false) {
|
|
2155
2142
|
return this.httpRequest.request({
|
|
2156
|
-
method: "
|
|
2143
|
+
method: "POST",
|
|
2157
2144
|
url: "/human/template",
|
|
2158
2145
|
query: {
|
|
2159
|
-
"
|
|
2160
|
-
|
|
2161
|
-
|
|
2146
|
+
"newVersion": newVersion
|
|
2147
|
+
},
|
|
2148
|
+
body: requestBody,
|
|
2149
|
+
mediaType: "application/json"
|
|
2162
2150
|
});
|
|
2163
2151
|
}
|
|
2164
2152
|
/**
|
|
2165
|
-
* Save
|
|
2153
|
+
* Save user form template
|
|
2166
2154
|
* @param requestBody
|
|
2167
2155
|
* @param newVersion
|
|
2168
|
-
* @returns
|
|
2156
|
+
* @returns HumanTaskTemplate OK
|
|
2169
2157
|
* @throws ApiError
|
|
2170
2158
|
*/
|
|
2171
|
-
|
|
2159
|
+
saveTemplates(requestBody, newVersion = false) {
|
|
2172
2160
|
return this.httpRequest.request({
|
|
2173
2161
|
method: "POST",
|
|
2174
|
-
url: "/human/template",
|
|
2162
|
+
url: "/human/template/bulk",
|
|
2175
2163
|
query: {
|
|
2176
2164
|
"newVersion": newVersion
|
|
2177
2165
|
},
|
|
@@ -2180,32 +2168,51 @@ var HumanTaskService = class {
|
|
|
2180
2168
|
});
|
|
2181
2169
|
}
|
|
2182
2170
|
/**
|
|
2183
|
-
* Delete
|
|
2184
|
-
* @param
|
|
2171
|
+
* Delete all versions of user form template by name
|
|
2172
|
+
* @param name
|
|
2173
|
+
* @returns any OK
|
|
2174
|
+
* @throws ApiError
|
|
2175
|
+
*/
|
|
2176
|
+
deleteTemplateByName(name) {
|
|
2177
|
+
return this.httpRequest.request({
|
|
2178
|
+
method: "DELETE",
|
|
2179
|
+
url: "/human/template/{name}",
|
|
2180
|
+
path: {
|
|
2181
|
+
"name": name
|
|
2182
|
+
}
|
|
2183
|
+
});
|
|
2184
|
+
}
|
|
2185
|
+
/**
|
|
2186
|
+
* Delete a version of form template by name
|
|
2187
|
+
* @param name
|
|
2188
|
+
* @param version
|
|
2185
2189
|
* @returns any OK
|
|
2186
2190
|
* @throws ApiError
|
|
2187
2191
|
*/
|
|
2188
|
-
|
|
2192
|
+
deleteTemplatesByNameAndVersion(name, version) {
|
|
2189
2193
|
return this.httpRequest.request({
|
|
2190
2194
|
method: "DELETE",
|
|
2191
|
-
url: "/human/template/{
|
|
2195
|
+
url: "/human/template/{name}/{version}",
|
|
2192
2196
|
path: {
|
|
2193
|
-
"
|
|
2197
|
+
"name": name,
|
|
2198
|
+
"version": version
|
|
2194
2199
|
}
|
|
2195
2200
|
});
|
|
2196
2201
|
}
|
|
2197
2202
|
/**
|
|
2198
|
-
* Get
|
|
2199
|
-
* @param
|
|
2200
|
-
* @
|
|
2203
|
+
* Get user form template by name and version
|
|
2204
|
+
* @param name
|
|
2205
|
+
* @param version
|
|
2206
|
+
* @returns HumanTaskTemplate OK
|
|
2201
2207
|
* @throws ApiError
|
|
2202
2208
|
*/
|
|
2203
|
-
|
|
2209
|
+
getTemplateByNameAndVersion(name, version) {
|
|
2204
2210
|
return this.httpRequest.request({
|
|
2205
2211
|
method: "GET",
|
|
2206
|
-
url: "/human/template/{
|
|
2212
|
+
url: "/human/template/{name}/{version}",
|
|
2207
2213
|
path: {
|
|
2208
|
-
"
|
|
2214
|
+
"name": name,
|
|
2215
|
+
"version": version
|
|
2209
2216
|
}
|
|
2210
2217
|
});
|
|
2211
2218
|
}
|
|
@@ -2376,6 +2383,15 @@ var Poller = class {
|
|
|
2376
2383
|
}
|
|
2377
2384
|
};
|
|
2378
2385
|
|
|
2386
|
+
// src/task/helpers.ts
|
|
2387
|
+
var optionEquals = (oldOptions, newOptions) => {
|
|
2388
|
+
const newOptionEntries = Object.entries(newOptions);
|
|
2389
|
+
const oldOptionsEntries = Object.entries(oldOptions);
|
|
2390
|
+
return newOptionEntries.length === oldOptionsEntries.length && newOptionEntries.every(
|
|
2391
|
+
([key, value]) => oldOptions[key] === value
|
|
2392
|
+
);
|
|
2393
|
+
};
|
|
2394
|
+
|
|
2379
2395
|
// src/task/TaskRunner.ts
|
|
2380
2396
|
var DEFAULT_ERROR_MESSAGE = "An unknown error occurred";
|
|
2381
2397
|
var MAX_RETRIES = 3;
|
|
@@ -2502,13 +2518,16 @@ var TaskRunner = class {
|
|
|
2502
2518
|
}
|
|
2503
2519
|
updateOptions(options) {
|
|
2504
2520
|
const newOptions = { ...this.options, ...options };
|
|
2505
|
-
this.
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2521
|
+
const isOptionsUpdated = !optionEquals(this.options, newOptions);
|
|
2522
|
+
if (isOptionsUpdated) {
|
|
2523
|
+
this.poller.updateOptions({
|
|
2524
|
+
concurrency: newOptions.concurrency,
|
|
2525
|
+
pollInterval: newOptions.pollInterval
|
|
2526
|
+
});
|
|
2527
|
+
this.logger.info(
|
|
2528
|
+
`TaskWorker ${this.worker.taskDefName} configuration updated with concurrency of ${this.poller.options.concurrency} and poll interval of ${this.poller.options.pollInterval}`
|
|
2529
|
+
);
|
|
2530
|
+
}
|
|
2512
2531
|
this.options = newOptions;
|
|
2513
2532
|
}
|
|
2514
2533
|
get getOptions() {
|
|
@@ -2651,9 +2670,18 @@ var tryCatchReThrow = (fn) => {
|
|
|
2651
2670
|
throw errorMapper(error);
|
|
2652
2671
|
}
|
|
2653
2672
|
};
|
|
2673
|
+
function reverseFind(array, predicate) {
|
|
2674
|
+
for (let i = array.length - 1; i >= 0; i--) {
|
|
2675
|
+
if (predicate(array[i], i, array)) {
|
|
2676
|
+
return array[i];
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
return void 0;
|
|
2680
|
+
}
|
|
2654
2681
|
|
|
2655
2682
|
// src/core/executor.ts
|
|
2656
2683
|
var RETRY_TIME_IN_MILLISECONDS = 1e4;
|
|
2684
|
+
var completedTaskMatchingType = (taskType) => (task) => task.status === "COMPLETED" && task.taskType === taskType;
|
|
2657
2685
|
var WorkflowExecutor = class {
|
|
2658
2686
|
constructor(client) {
|
|
2659
2687
|
this._client = client;
|
|
@@ -2686,12 +2714,38 @@ var WorkflowExecutor = class {
|
|
|
2686
2714
|
*/
|
|
2687
2715
|
executeWorkflow(workflowRequest, name, version, requestId, waitUntilTaskRef = "") {
|
|
2688
2716
|
return tryCatchReThrow(
|
|
2689
|
-
() => this._client.workflowResource.executeWorkflow(
|
|
2717
|
+
() => this._client.workflowResource.executeWorkflow(
|
|
2718
|
+
workflowRequest,
|
|
2719
|
+
name,
|
|
2720
|
+
version,
|
|
2721
|
+
requestId,
|
|
2722
|
+
waitUntilTaskRef
|
|
2723
|
+
)
|
|
2690
2724
|
);
|
|
2691
2725
|
}
|
|
2692
2726
|
startWorkflows(workflowsRequest) {
|
|
2693
2727
|
return tryCatchReThrow(() => workflowsRequest.map(this.startWorkflow));
|
|
2694
2728
|
}
|
|
2729
|
+
async goBackToTask(workflowInstanceId, taskFinderPredicate, rerunWorkflowRequestOverrides = {}) {
|
|
2730
|
+
const { tasks: executedTasks = [] } = await this.getExecution(
|
|
2731
|
+
workflowInstanceId
|
|
2732
|
+
);
|
|
2733
|
+
const maybePreviousTask = reverseFind(
|
|
2734
|
+
executedTasks,
|
|
2735
|
+
taskFinderPredicate
|
|
2736
|
+
);
|
|
2737
|
+
if (!maybePreviousTask) {
|
|
2738
|
+
throw new Error("Task not found");
|
|
2739
|
+
}
|
|
2740
|
+
await this.reRun(workflowInstanceId, {
|
|
2741
|
+
//taskInput: previousTask.inputData,
|
|
2742
|
+
...rerunWorkflowRequestOverrides,
|
|
2743
|
+
reRunFromTaskId: maybePreviousTask.taskId
|
|
2744
|
+
});
|
|
2745
|
+
}
|
|
2746
|
+
async goBackToFirstTaskMatchingType(workflowInstanceId, taskType) {
|
|
2747
|
+
return this.goBackToTask(workflowInstanceId, completedTaskMatchingType(taskType));
|
|
2748
|
+
}
|
|
2695
2749
|
/**
|
|
2696
2750
|
* Takes an workflowInstanceId and an includeTasks and an optional retry parameter returns the whole execution status.
|
|
2697
2751
|
* If includeTasks flag is provided. Details of tasks execution will be returned as well,
|
|
@@ -2736,6 +2790,22 @@ var WorkflowExecutor = class {
|
|
|
2736
2790
|
)
|
|
2737
2791
|
);
|
|
2738
2792
|
}
|
|
2793
|
+
/**
|
|
2794
|
+
* Returns a summary of the current workflow status.
|
|
2795
|
+
*
|
|
2796
|
+
* @param workflowInstanceId current running workflow
|
|
2797
|
+
* @param includeOutput flag to include output
|
|
2798
|
+
* @param includeVariables flag to include variable
|
|
2799
|
+
* @returns Promise<WorkflowStatus>
|
|
2800
|
+
*/
|
|
2801
|
+
getExecution(workflowInstanceId, includeTasks = true) {
|
|
2802
|
+
return tryCatchReThrow(
|
|
2803
|
+
() => this._client.workflowResource.getExecutionStatus(
|
|
2804
|
+
workflowInstanceId,
|
|
2805
|
+
includeTasks
|
|
2806
|
+
)
|
|
2807
|
+
);
|
|
2808
|
+
}
|
|
2739
2809
|
/**
|
|
2740
2810
|
* Pauses a running workflow
|
|
2741
2811
|
* @param workflowInstanceId current workflow execution
|
|
@@ -2905,11 +2975,24 @@ var WorkflowExecutor = class {
|
|
|
2905
2975
|
};
|
|
2906
2976
|
|
|
2907
2977
|
// src/core/human.ts
|
|
2978
|
+
var EMPTY_SEARCH = {
|
|
2979
|
+
size: 15,
|
|
2980
|
+
states: [],
|
|
2981
|
+
taskInputQuery: "",
|
|
2982
|
+
taskOutputQuery: "",
|
|
2983
|
+
definitionNames: [],
|
|
2984
|
+
taskRefNames: [],
|
|
2985
|
+
claimants: [],
|
|
2986
|
+
assignees: [],
|
|
2987
|
+
start: 0
|
|
2988
|
+
};
|
|
2989
|
+
var DEFAULT_POLL_INTERVAL2 = { pollInterval: 100, maxPollTimes: 20 };
|
|
2908
2990
|
var HumanExecutor = class {
|
|
2909
2991
|
constructor(client) {
|
|
2910
2992
|
this._client = client;
|
|
2911
2993
|
}
|
|
2912
2994
|
/**
|
|
2995
|
+
* @deprecated use search instead
|
|
2913
2996
|
* Takes a set of filter parameters. return matches of human tasks for that set of parameters
|
|
2914
2997
|
* @param state
|
|
2915
2998
|
* @param assignee
|
|
@@ -2920,21 +3003,68 @@ var HumanExecutor = class {
|
|
|
2920
3003
|
* @param includeInputOutput
|
|
2921
3004
|
* @returns
|
|
2922
3005
|
*/
|
|
2923
|
-
async getTasksByFilter(state, assignee, assigneeType, claimedBy, taskName,
|
|
2924
|
-
const
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
3006
|
+
async getTasksByFilter(state, assignee, assigneeType, claimedBy, taskName, taskInputQuery, taskOutputQuery) {
|
|
3007
|
+
const [claimedUserType, claimedUser] = claimedBy?.split(":") ?? [];
|
|
3008
|
+
if (claimedUserType && !claimedUser) {
|
|
3009
|
+
throw new Error("claimedBy should be in the format of <userType>:<user>");
|
|
3010
|
+
}
|
|
3011
|
+
const response = await this.search({
|
|
3012
|
+
states: [state],
|
|
3013
|
+
assignees: assignee ? [{ userType: assigneeType, user: assignee }] : [],
|
|
3014
|
+
claimants: claimedBy ? [{ userType: claimedUserType, user: claimedUser }] : [],
|
|
3015
|
+
taskRefNames: taskName ? [taskName] : [],
|
|
3016
|
+
taskInputQuery,
|
|
3017
|
+
taskOutputQuery
|
|
3018
|
+
});
|
|
3019
|
+
return response;
|
|
3020
|
+
}
|
|
3021
|
+
/**
|
|
3022
|
+
* Takes a set of filter parameters. return matches of human tasks for that set of parameters
|
|
3023
|
+
* @param state
|
|
3024
|
+
* @param assignee
|
|
3025
|
+
* @param assigneeType
|
|
3026
|
+
* @param claimedBy
|
|
3027
|
+
* @param taskName
|
|
3028
|
+
* @param freeText
|
|
3029
|
+
* @param includeInputOutput
|
|
3030
|
+
* @returns Promise<HumanTaskEntry[]>
|
|
3031
|
+
*/
|
|
3032
|
+
async search(searchParams) {
|
|
3033
|
+
const search = { ...EMPTY_SEARCH, ...searchParams };
|
|
3034
|
+
const response = await tryCatchReThrow(
|
|
3035
|
+
() => this._client.humanTask.search(search)
|
|
2932
3036
|
);
|
|
2933
3037
|
if (response.results != void 0) {
|
|
2934
3038
|
return response.results;
|
|
2935
3039
|
}
|
|
2936
3040
|
return [];
|
|
2937
3041
|
}
|
|
3042
|
+
/**
|
|
3043
|
+
* Takes a set of filter parameters. An polling interval options. will poll until the task returns a result
|
|
3044
|
+
* @param state
|
|
3045
|
+
* @param assignee
|
|
3046
|
+
* @param assigneeType
|
|
3047
|
+
* @param claimedBy
|
|
3048
|
+
* @param taskName
|
|
3049
|
+
* @param freeText
|
|
3050
|
+
* @param includeInputOutput
|
|
3051
|
+
* @returns Promise<HumanTaskEntry[]>
|
|
3052
|
+
*/
|
|
3053
|
+
async pollSearch(searchParams, {
|
|
3054
|
+
pollInterval = 100,
|
|
3055
|
+
maxPollTimes = 20
|
|
3056
|
+
} = DEFAULT_POLL_INTERVAL2) {
|
|
3057
|
+
let pollCount = 0;
|
|
3058
|
+
while (pollCount < maxPollTimes) {
|
|
3059
|
+
const response = await this.search(searchParams);
|
|
3060
|
+
if (response.length > 0) {
|
|
3061
|
+
return response;
|
|
3062
|
+
}
|
|
3063
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
3064
|
+
pollCount++;
|
|
3065
|
+
}
|
|
3066
|
+
return [];
|
|
3067
|
+
}
|
|
2938
3068
|
/**
|
|
2939
3069
|
* Returns task for a given task id
|
|
2940
3070
|
* @param taskId
|
|
@@ -2950,11 +3080,9 @@ var HumanExecutor = class {
|
|
|
2950
3080
|
* @returns
|
|
2951
3081
|
*/
|
|
2952
3082
|
async claimTaskAsExternalUser(taskId, assignee) {
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
throw errorMapper(error);
|
|
2957
|
-
}
|
|
3083
|
+
return tryCatchReThrow(
|
|
3084
|
+
() => this._client.humanTask.assignAndClaim(taskId, assignee)
|
|
3085
|
+
);
|
|
2958
3086
|
}
|
|
2959
3087
|
/**
|
|
2960
3088
|
* Claim task as conductor user
|
|
@@ -2962,11 +3090,7 @@ var HumanExecutor = class {
|
|
|
2962
3090
|
* @returns
|
|
2963
3091
|
*/
|
|
2964
3092
|
async claimTaskAsConductorUser(taskId) {
|
|
2965
|
-
|
|
2966
|
-
await this._client.humanTask.claimTask(taskId);
|
|
2967
|
-
} catch (error) {
|
|
2968
|
-
throw errorMapper(error);
|
|
2969
|
-
}
|
|
3093
|
+
return tryCatchReThrow(() => this._client.humanTask.claimTask(taskId));
|
|
2970
3094
|
}
|
|
2971
3095
|
/**
|
|
2972
3096
|
* Claim task as conductor user
|
|
@@ -2982,15 +3106,24 @@ var HumanExecutor = class {
|
|
|
2982
3106
|
}
|
|
2983
3107
|
}
|
|
2984
3108
|
/**
|
|
2985
|
-
* Returns a HumanTaskTemplateEntry for a given
|
|
3109
|
+
* Returns a HumanTaskTemplateEntry for a given name and version
|
|
2986
3110
|
* @param templateId
|
|
2987
3111
|
* @returns
|
|
2988
3112
|
*/
|
|
2989
|
-
async
|
|
3113
|
+
async getTemplateByNameVersion(name, version) {
|
|
2990
3114
|
return tryCatchReThrow(
|
|
2991
|
-
() => this._client.humanTask.
|
|
3115
|
+
() => this._client.humanTask.getTemplateByNameAndVersion(name, version)
|
|
2992
3116
|
);
|
|
2993
3117
|
}
|
|
3118
|
+
/**
|
|
3119
|
+
* @deprecated use getTemplate instead. name will be used as id here with version 1
|
|
3120
|
+
* Returns a HumanTaskTemplateEntry for a given templateId
|
|
3121
|
+
* @param templateId
|
|
3122
|
+
* @returns
|
|
3123
|
+
*/
|
|
3124
|
+
async getTemplateById(templateNameVersionOne) {
|
|
3125
|
+
return this.getTemplateByNameVersion(templateNameVersionOne, 1);
|
|
3126
|
+
}
|
|
2994
3127
|
/**
|
|
2995
3128
|
* Takes a taskId and a partial body. will update with given body
|
|
2996
3129
|
* @param taskId
|
|
@@ -3586,6 +3719,7 @@ var orkesConductorClient = baseOrkesConductorClient(
|
|
|
3586
3719
|
WorkflowBulkResourceService,
|
|
3587
3720
|
WorkflowExecutor,
|
|
3588
3721
|
WorkflowResourceService,
|
|
3722
|
+
completedTaskMatchingType,
|
|
3589
3723
|
conductorEventTask,
|
|
3590
3724
|
doWhileTask,
|
|
3591
3725
|
dynamicForkTask,
|