@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/index.js
CHANGED
|
@@ -53,6 +53,7 @@ __export(conductor_javascript_exports, {
|
|
|
53
53
|
WorkflowExecutor: () => WorkflowExecutor,
|
|
54
54
|
WorkflowResourceService: () => WorkflowResourceService,
|
|
55
55
|
baseOrkesConductorClient: () => baseOrkesConductorClient,
|
|
56
|
+
completedTaskMatchingType: () => completedTaskMatchingType,
|
|
56
57
|
conductorEventTask: () => conductorEventTask,
|
|
57
58
|
doWhileTask: () => doWhileTask,
|
|
58
59
|
dynamicForkTask: () => dynamicForkTask,
|
|
@@ -1924,83 +1925,70 @@ var HumanTaskService = class {
|
|
|
1924
1925
|
this.httpRequest = httpRequest;
|
|
1925
1926
|
}
|
|
1926
1927
|
/**
|
|
1927
|
-
*
|
|
1928
|
-
* @param
|
|
1929
|
-
* @
|
|
1930
|
-
* @param assigneeType
|
|
1931
|
-
* @param claimedBy
|
|
1932
|
-
* @param taskName
|
|
1933
|
-
* @param freeText
|
|
1934
|
-
* @param includeInputOutput
|
|
1935
|
-
* @returns SearchResultHumanTaskEntry OK
|
|
1928
|
+
* If the workflow is disconnected from tasks, this API can be used to clean up (in bulk)
|
|
1929
|
+
* @param requestBody
|
|
1930
|
+
* @returns any OK
|
|
1936
1931
|
* @throws ApiError
|
|
1937
1932
|
*/
|
|
1938
|
-
|
|
1933
|
+
deleteTaskFromHumanTaskRecords(requestBody) {
|
|
1939
1934
|
return this.httpRequest.request({
|
|
1940
|
-
method: "
|
|
1941
|
-
url: "/human/tasks",
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
"assignee": assignee,
|
|
1945
|
-
"assigneeType": assigneeType,
|
|
1946
|
-
"claimedBy": claimedBy,
|
|
1947
|
-
"taskName": taskName,
|
|
1948
|
-
"freeText": freeText,
|
|
1949
|
-
"includeInputOutput": includeInputOutput
|
|
1950
|
-
}
|
|
1935
|
+
method: "DELETE",
|
|
1936
|
+
url: "/human/tasks/delete",
|
|
1937
|
+
body: requestBody,
|
|
1938
|
+
mediaType: "application/json"
|
|
1951
1939
|
});
|
|
1952
1940
|
}
|
|
1953
1941
|
/**
|
|
1954
|
-
*
|
|
1955
|
-
* @
|
|
1942
|
+
* If the workflow is disconnected from tasks, this API can be used to clean up
|
|
1943
|
+
* @param taskId
|
|
1944
|
+
* @returns any OK
|
|
1956
1945
|
* @throws ApiError
|
|
1957
1946
|
*/
|
|
1958
|
-
|
|
1947
|
+
deleteTaskFromHumanTaskRecords1(taskId) {
|
|
1959
1948
|
return this.httpRequest.request({
|
|
1960
|
-
method: "
|
|
1961
|
-
url: "/human/tasks/
|
|
1949
|
+
method: "DELETE",
|
|
1950
|
+
url: "/human/tasks/delete/{taskId}",
|
|
1951
|
+
path: {
|
|
1952
|
+
"taskId": taskId
|
|
1953
|
+
}
|
|
1962
1954
|
});
|
|
1963
1955
|
}
|
|
1964
1956
|
/**
|
|
1965
1957
|
* Search human tasks
|
|
1966
|
-
* @param
|
|
1967
|
-
* @
|
|
1968
|
-
* @param size
|
|
1969
|
-
* @param freeText
|
|
1970
|
-
* @param query
|
|
1971
|
-
* @param jsonQuery
|
|
1972
|
-
* @param includeInputOutput
|
|
1973
|
-
* @returns HTScrollableSearchResultHumanTaskEntry OK
|
|
1958
|
+
* @param requestBody
|
|
1959
|
+
* @returns HumanTaskSearchResult OK
|
|
1974
1960
|
* @throws ApiError
|
|
1975
1961
|
*/
|
|
1976
|
-
|
|
1962
|
+
search(requestBody) {
|
|
1977
1963
|
return this.httpRequest.request({
|
|
1978
|
-
method: "
|
|
1964
|
+
method: "POST",
|
|
1979
1965
|
url: "/human/tasks/search",
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
"start": start,
|
|
1983
|
-
"size": size,
|
|
1984
|
-
"freeText": freeText,
|
|
1985
|
-
"query": query,
|
|
1986
|
-
"jsonQuery": jsonQuery,
|
|
1987
|
-
"includeInputOutput": includeInputOutput
|
|
1988
|
-
}
|
|
1966
|
+
body: requestBody,
|
|
1967
|
+
mediaType: "application/json"
|
|
1989
1968
|
});
|
|
1990
1969
|
}
|
|
1991
1970
|
/**
|
|
1992
|
-
*
|
|
1993
|
-
* @param
|
|
1971
|
+
* Update task output, optionally complete
|
|
1972
|
+
* @param workflowId
|
|
1973
|
+
* @param taskRefName
|
|
1974
|
+
* @param requestBody
|
|
1975
|
+
* @param complete
|
|
1976
|
+
* @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
|
|
1994
1977
|
* @returns any OK
|
|
1995
1978
|
* @throws ApiError
|
|
1996
1979
|
*/
|
|
1997
|
-
|
|
1980
|
+
updateTaskOutputByRef(workflowId, taskRefName, requestBody, complete = false, iteration) {
|
|
1998
1981
|
return this.httpRequest.request({
|
|
1999
|
-
method: "
|
|
2000
|
-
url: "/human/tasks/
|
|
2001
|
-
|
|
2002
|
-
"
|
|
2003
|
-
|
|
1982
|
+
method: "POST",
|
|
1983
|
+
url: "/human/tasks/update/taskRef",
|
|
1984
|
+
query: {
|
|
1985
|
+
"workflowId": workflowId,
|
|
1986
|
+
"taskRefName": taskRefName,
|
|
1987
|
+
"complete": complete,
|
|
1988
|
+
"iteration": iteration
|
|
1989
|
+
},
|
|
1990
|
+
body: requestBody,
|
|
1991
|
+
mediaType: "application/json"
|
|
2004
1992
|
});
|
|
2005
1993
|
}
|
|
2006
1994
|
/**
|
|
@@ -2018,33 +2006,22 @@ var HumanTaskService = class {
|
|
|
2018
2006
|
}
|
|
2019
2007
|
});
|
|
2020
2008
|
}
|
|
2021
|
-
/**
|
|
2022
|
-
* Get human task action log entries by task id
|
|
2023
|
-
* @param taskId
|
|
2024
|
-
* @returns HumanTaskActionLogEntry OK
|
|
2025
|
-
* @throws ApiError
|
|
2026
|
-
*/
|
|
2027
|
-
getActionLogs(taskId) {
|
|
2028
|
-
return this.httpRequest.request({
|
|
2029
|
-
method: "GET",
|
|
2030
|
-
url: "/human/tasks/{taskId}/actionLogs",
|
|
2031
|
-
path: {
|
|
2032
|
-
"taskId": taskId
|
|
2033
|
-
}
|
|
2034
|
-
});
|
|
2035
|
-
}
|
|
2036
2009
|
/**
|
|
2037
2010
|
* Claim a task by authenticated Conductor user
|
|
2038
2011
|
* @param taskId
|
|
2012
|
+
* @param overrideAssignment
|
|
2039
2013
|
* @returns any OK
|
|
2040
2014
|
* @throws ApiError
|
|
2041
2015
|
*/
|
|
2042
|
-
claimTask(taskId) {
|
|
2016
|
+
claimTask(taskId, overrideAssignment = false) {
|
|
2043
2017
|
return this.httpRequest.request({
|
|
2044
2018
|
method: "POST",
|
|
2045
2019
|
url: "/human/tasks/{taskId}/claim",
|
|
2046
2020
|
path: {
|
|
2047
2021
|
"taskId": taskId
|
|
2022
|
+
},
|
|
2023
|
+
query: {
|
|
2024
|
+
"overrideAssignment": overrideAssignment
|
|
2048
2025
|
}
|
|
2049
2026
|
});
|
|
2050
2027
|
}
|
|
@@ -2052,16 +2029,20 @@ var HumanTaskService = class {
|
|
|
2052
2029
|
* Claim a task to an external user
|
|
2053
2030
|
* @param taskId
|
|
2054
2031
|
* @param userId
|
|
2032
|
+
* @param overrideAssignment
|
|
2055
2033
|
* @returns any OK
|
|
2056
2034
|
* @throws ApiError
|
|
2057
2035
|
*/
|
|
2058
|
-
assignAndClaim(taskId, userId) {
|
|
2036
|
+
assignAndClaim(taskId, userId, overrideAssignment = false) {
|
|
2059
2037
|
return this.httpRequest.request({
|
|
2060
2038
|
method: "POST",
|
|
2061
2039
|
url: "/human/tasks/{taskId}/externalUser/{userId}",
|
|
2062
2040
|
path: {
|
|
2063
2041
|
"taskId": taskId,
|
|
2064
2042
|
"userId": userId
|
|
2043
|
+
},
|
|
2044
|
+
query: {
|
|
2045
|
+
"overrideAssignment": overrideAssignment
|
|
2065
2046
|
}
|
|
2066
2047
|
});
|
|
2067
2048
|
}
|
|
@@ -2099,17 +2080,21 @@ var HumanTaskService = class {
|
|
|
2099
2080
|
});
|
|
2100
2081
|
}
|
|
2101
2082
|
/**
|
|
2102
|
-
*
|
|
2083
|
+
* If a task is assigned to a user, this API can be used to skip that assignment and move to the next assignee
|
|
2103
2084
|
* @param taskId
|
|
2104
|
-
* @
|
|
2085
|
+
* @param reason
|
|
2086
|
+
* @returns any OK
|
|
2105
2087
|
* @throws ApiError
|
|
2106
2088
|
*/
|
|
2107
|
-
|
|
2089
|
+
skipTask(taskId, reason) {
|
|
2108
2090
|
return this.httpRequest.request({
|
|
2109
|
-
method: "
|
|
2110
|
-
url: "/human/tasks/{taskId}/
|
|
2091
|
+
method: "POST",
|
|
2092
|
+
url: "/human/tasks/{taskId}/skip",
|
|
2111
2093
|
path: {
|
|
2112
2094
|
"taskId": taskId
|
|
2095
|
+
},
|
|
2096
|
+
query: {
|
|
2097
|
+
"reason": reason
|
|
2113
2098
|
}
|
|
2114
2099
|
});
|
|
2115
2100
|
}
|
|
@@ -2136,48 +2121,51 @@ var HumanTaskService = class {
|
|
|
2136
2121
|
});
|
|
2137
2122
|
}
|
|
2138
2123
|
/**
|
|
2139
|
-
*
|
|
2124
|
+
* List all user form templates or get templates by name, or a template by name and version
|
|
2140
2125
|
* @param name
|
|
2141
|
-
* @
|
|
2126
|
+
* @param version
|
|
2127
|
+
* @returns HumanTaskTemplate OK
|
|
2142
2128
|
* @throws ApiError
|
|
2143
2129
|
*/
|
|
2144
|
-
|
|
2130
|
+
getAllTemplates(name, version) {
|
|
2145
2131
|
return this.httpRequest.request({
|
|
2146
|
-
method: "
|
|
2132
|
+
method: "GET",
|
|
2147
2133
|
url: "/human/template",
|
|
2148
2134
|
query: {
|
|
2149
|
-
"name": name
|
|
2135
|
+
"name": name,
|
|
2136
|
+
"version": version
|
|
2150
2137
|
}
|
|
2151
2138
|
});
|
|
2152
2139
|
}
|
|
2153
2140
|
/**
|
|
2154
|
-
*
|
|
2155
|
-
* @param
|
|
2156
|
-
* @param
|
|
2157
|
-
* @returns
|
|
2141
|
+
* Save user form template
|
|
2142
|
+
* @param requestBody
|
|
2143
|
+
* @param newVersion
|
|
2144
|
+
* @returns HumanTaskTemplate OK
|
|
2158
2145
|
* @throws ApiError
|
|
2159
2146
|
*/
|
|
2160
|
-
|
|
2147
|
+
saveTemplate(requestBody, newVersion = false) {
|
|
2161
2148
|
return this.httpRequest.request({
|
|
2162
|
-
method: "
|
|
2149
|
+
method: "POST",
|
|
2163
2150
|
url: "/human/template",
|
|
2164
2151
|
query: {
|
|
2165
|
-
"
|
|
2166
|
-
|
|
2167
|
-
|
|
2152
|
+
"newVersion": newVersion
|
|
2153
|
+
},
|
|
2154
|
+
body: requestBody,
|
|
2155
|
+
mediaType: "application/json"
|
|
2168
2156
|
});
|
|
2169
2157
|
}
|
|
2170
2158
|
/**
|
|
2171
|
-
* Save
|
|
2159
|
+
* Save user form template
|
|
2172
2160
|
* @param requestBody
|
|
2173
2161
|
* @param newVersion
|
|
2174
|
-
* @returns
|
|
2162
|
+
* @returns HumanTaskTemplate OK
|
|
2175
2163
|
* @throws ApiError
|
|
2176
2164
|
*/
|
|
2177
|
-
|
|
2165
|
+
saveTemplates(requestBody, newVersion = false) {
|
|
2178
2166
|
return this.httpRequest.request({
|
|
2179
2167
|
method: "POST",
|
|
2180
|
-
url: "/human/template",
|
|
2168
|
+
url: "/human/template/bulk",
|
|
2181
2169
|
query: {
|
|
2182
2170
|
"newVersion": newVersion
|
|
2183
2171
|
},
|
|
@@ -2186,32 +2174,51 @@ var HumanTaskService = class {
|
|
|
2186
2174
|
});
|
|
2187
2175
|
}
|
|
2188
2176
|
/**
|
|
2189
|
-
* Delete
|
|
2190
|
-
* @param
|
|
2177
|
+
* Delete all versions of user form template by name
|
|
2178
|
+
* @param name
|
|
2179
|
+
* @returns any OK
|
|
2180
|
+
* @throws ApiError
|
|
2181
|
+
*/
|
|
2182
|
+
deleteTemplateByName(name) {
|
|
2183
|
+
return this.httpRequest.request({
|
|
2184
|
+
method: "DELETE",
|
|
2185
|
+
url: "/human/template/{name}",
|
|
2186
|
+
path: {
|
|
2187
|
+
"name": name
|
|
2188
|
+
}
|
|
2189
|
+
});
|
|
2190
|
+
}
|
|
2191
|
+
/**
|
|
2192
|
+
* Delete a version of form template by name
|
|
2193
|
+
* @param name
|
|
2194
|
+
* @param version
|
|
2191
2195
|
* @returns any OK
|
|
2192
2196
|
* @throws ApiError
|
|
2193
2197
|
*/
|
|
2194
|
-
|
|
2198
|
+
deleteTemplatesByNameAndVersion(name, version) {
|
|
2195
2199
|
return this.httpRequest.request({
|
|
2196
2200
|
method: "DELETE",
|
|
2197
|
-
url: "/human/template/{
|
|
2201
|
+
url: "/human/template/{name}/{version}",
|
|
2198
2202
|
path: {
|
|
2199
|
-
"
|
|
2203
|
+
"name": name,
|
|
2204
|
+
"version": version
|
|
2200
2205
|
}
|
|
2201
2206
|
});
|
|
2202
2207
|
}
|
|
2203
2208
|
/**
|
|
2204
|
-
* Get
|
|
2205
|
-
* @param
|
|
2206
|
-
* @
|
|
2209
|
+
* Get user form template by name and version
|
|
2210
|
+
* @param name
|
|
2211
|
+
* @param version
|
|
2212
|
+
* @returns HumanTaskTemplate OK
|
|
2207
2213
|
* @throws ApiError
|
|
2208
2214
|
*/
|
|
2209
|
-
|
|
2215
|
+
getTemplateByNameAndVersion(name, version) {
|
|
2210
2216
|
return this.httpRequest.request({
|
|
2211
2217
|
method: "GET",
|
|
2212
|
-
url: "/human/template/{
|
|
2218
|
+
url: "/human/template/{name}/{version}",
|
|
2213
2219
|
path: {
|
|
2214
|
-
"
|
|
2220
|
+
"name": name,
|
|
2221
|
+
"version": version
|
|
2215
2222
|
}
|
|
2216
2223
|
});
|
|
2217
2224
|
}
|
|
@@ -2382,6 +2389,15 @@ var Poller = class {
|
|
|
2382
2389
|
}
|
|
2383
2390
|
};
|
|
2384
2391
|
|
|
2392
|
+
// src/task/helpers.ts
|
|
2393
|
+
var optionEquals = (oldOptions, newOptions) => {
|
|
2394
|
+
const newOptionEntries = Object.entries(newOptions);
|
|
2395
|
+
const oldOptionsEntries = Object.entries(oldOptions);
|
|
2396
|
+
return newOptionEntries.length === oldOptionsEntries.length && newOptionEntries.every(
|
|
2397
|
+
([key, value]) => oldOptions[key] === value
|
|
2398
|
+
);
|
|
2399
|
+
};
|
|
2400
|
+
|
|
2385
2401
|
// src/task/TaskRunner.ts
|
|
2386
2402
|
var DEFAULT_ERROR_MESSAGE = "An unknown error occurred";
|
|
2387
2403
|
var MAX_RETRIES = 3;
|
|
@@ -2508,13 +2524,16 @@ var TaskRunner = class {
|
|
|
2508
2524
|
}
|
|
2509
2525
|
updateOptions(options) {
|
|
2510
2526
|
const newOptions = { ...this.options, ...options };
|
|
2511
|
-
this.
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2527
|
+
const isOptionsUpdated = !optionEquals(this.options, newOptions);
|
|
2528
|
+
if (isOptionsUpdated) {
|
|
2529
|
+
this.poller.updateOptions({
|
|
2530
|
+
concurrency: newOptions.concurrency,
|
|
2531
|
+
pollInterval: newOptions.pollInterval
|
|
2532
|
+
});
|
|
2533
|
+
this.logger.info(
|
|
2534
|
+
`TaskWorker ${this.worker.taskDefName} configuration updated with concurrency of ${this.poller.options.concurrency} and poll interval of ${this.poller.options.pollInterval}`
|
|
2535
|
+
);
|
|
2536
|
+
}
|
|
2518
2537
|
this.options = newOptions;
|
|
2519
2538
|
}
|
|
2520
2539
|
get getOptions() {
|
|
@@ -2657,9 +2676,18 @@ var tryCatchReThrow = (fn) => {
|
|
|
2657
2676
|
throw errorMapper(error);
|
|
2658
2677
|
}
|
|
2659
2678
|
};
|
|
2679
|
+
function reverseFind(array, predicate) {
|
|
2680
|
+
for (let i = array.length - 1; i >= 0; i--) {
|
|
2681
|
+
if (predicate(array[i], i, array)) {
|
|
2682
|
+
return array[i];
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
return void 0;
|
|
2686
|
+
}
|
|
2660
2687
|
|
|
2661
2688
|
// src/core/executor.ts
|
|
2662
2689
|
var RETRY_TIME_IN_MILLISECONDS = 1e4;
|
|
2690
|
+
var completedTaskMatchingType = (taskType) => (task) => task.status === "COMPLETED" && task.taskType === taskType;
|
|
2663
2691
|
var WorkflowExecutor = class {
|
|
2664
2692
|
constructor(client) {
|
|
2665
2693
|
this._client = client;
|
|
@@ -2692,12 +2720,38 @@ var WorkflowExecutor = class {
|
|
|
2692
2720
|
*/
|
|
2693
2721
|
executeWorkflow(workflowRequest, name, version, requestId, waitUntilTaskRef = "") {
|
|
2694
2722
|
return tryCatchReThrow(
|
|
2695
|
-
() => this._client.workflowResource.executeWorkflow(
|
|
2723
|
+
() => this._client.workflowResource.executeWorkflow(
|
|
2724
|
+
workflowRequest,
|
|
2725
|
+
name,
|
|
2726
|
+
version,
|
|
2727
|
+
requestId,
|
|
2728
|
+
waitUntilTaskRef
|
|
2729
|
+
)
|
|
2696
2730
|
);
|
|
2697
2731
|
}
|
|
2698
2732
|
startWorkflows(workflowsRequest) {
|
|
2699
2733
|
return tryCatchReThrow(() => workflowsRequest.map(this.startWorkflow));
|
|
2700
2734
|
}
|
|
2735
|
+
async goBackToTask(workflowInstanceId, taskFinderPredicate, rerunWorkflowRequestOverrides = {}) {
|
|
2736
|
+
const { tasks: executedTasks = [] } = await this.getExecution(
|
|
2737
|
+
workflowInstanceId
|
|
2738
|
+
);
|
|
2739
|
+
const maybePreviousTask = reverseFind(
|
|
2740
|
+
executedTasks,
|
|
2741
|
+
taskFinderPredicate
|
|
2742
|
+
);
|
|
2743
|
+
if (!maybePreviousTask) {
|
|
2744
|
+
throw new Error("Task not found");
|
|
2745
|
+
}
|
|
2746
|
+
await this.reRun(workflowInstanceId, {
|
|
2747
|
+
//taskInput: previousTask.inputData,
|
|
2748
|
+
...rerunWorkflowRequestOverrides,
|
|
2749
|
+
reRunFromTaskId: maybePreviousTask.taskId
|
|
2750
|
+
});
|
|
2751
|
+
}
|
|
2752
|
+
async goBackToFirstTaskMatchingType(workflowInstanceId, taskType) {
|
|
2753
|
+
return this.goBackToTask(workflowInstanceId, completedTaskMatchingType(taskType));
|
|
2754
|
+
}
|
|
2701
2755
|
/**
|
|
2702
2756
|
* Takes an workflowInstanceId and an includeTasks and an optional retry parameter returns the whole execution status.
|
|
2703
2757
|
* If includeTasks flag is provided. Details of tasks execution will be returned as well,
|
|
@@ -2742,6 +2796,22 @@ var WorkflowExecutor = class {
|
|
|
2742
2796
|
)
|
|
2743
2797
|
);
|
|
2744
2798
|
}
|
|
2799
|
+
/**
|
|
2800
|
+
* Returns a summary of the current workflow status.
|
|
2801
|
+
*
|
|
2802
|
+
* @param workflowInstanceId current running workflow
|
|
2803
|
+
* @param includeOutput flag to include output
|
|
2804
|
+
* @param includeVariables flag to include variable
|
|
2805
|
+
* @returns Promise<WorkflowStatus>
|
|
2806
|
+
*/
|
|
2807
|
+
getExecution(workflowInstanceId, includeTasks = true) {
|
|
2808
|
+
return tryCatchReThrow(
|
|
2809
|
+
() => this._client.workflowResource.getExecutionStatus(
|
|
2810
|
+
workflowInstanceId,
|
|
2811
|
+
includeTasks
|
|
2812
|
+
)
|
|
2813
|
+
);
|
|
2814
|
+
}
|
|
2745
2815
|
/**
|
|
2746
2816
|
* Pauses a running workflow
|
|
2747
2817
|
* @param workflowInstanceId current workflow execution
|
|
@@ -2911,11 +2981,24 @@ var WorkflowExecutor = class {
|
|
|
2911
2981
|
};
|
|
2912
2982
|
|
|
2913
2983
|
// src/core/human.ts
|
|
2984
|
+
var EMPTY_SEARCH = {
|
|
2985
|
+
size: 15,
|
|
2986
|
+
states: [],
|
|
2987
|
+
taskInputQuery: "",
|
|
2988
|
+
taskOutputQuery: "",
|
|
2989
|
+
definitionNames: [],
|
|
2990
|
+
taskRefNames: [],
|
|
2991
|
+
claimants: [],
|
|
2992
|
+
assignees: [],
|
|
2993
|
+
start: 0
|
|
2994
|
+
};
|
|
2995
|
+
var DEFAULT_POLL_INTERVAL2 = { pollInterval: 100, maxPollTimes: 20 };
|
|
2914
2996
|
var HumanExecutor = class {
|
|
2915
2997
|
constructor(client) {
|
|
2916
2998
|
this._client = client;
|
|
2917
2999
|
}
|
|
2918
3000
|
/**
|
|
3001
|
+
* @deprecated use search instead
|
|
2919
3002
|
* Takes a set of filter parameters. return matches of human tasks for that set of parameters
|
|
2920
3003
|
* @param state
|
|
2921
3004
|
* @param assignee
|
|
@@ -2926,21 +3009,68 @@ var HumanExecutor = class {
|
|
|
2926
3009
|
* @param includeInputOutput
|
|
2927
3010
|
* @returns
|
|
2928
3011
|
*/
|
|
2929
|
-
async getTasksByFilter(state, assignee, assigneeType, claimedBy, taskName,
|
|
2930
|
-
const
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
3012
|
+
async getTasksByFilter(state, assignee, assigneeType, claimedBy, taskName, taskInputQuery, taskOutputQuery) {
|
|
3013
|
+
const [claimedUserType, claimedUser] = claimedBy?.split(":") ?? [];
|
|
3014
|
+
if (claimedUserType && !claimedUser) {
|
|
3015
|
+
throw new Error("claimedBy should be in the format of <userType>:<user>");
|
|
3016
|
+
}
|
|
3017
|
+
const response = await this.search({
|
|
3018
|
+
states: [state],
|
|
3019
|
+
assignees: assignee ? [{ userType: assigneeType, user: assignee }] : [],
|
|
3020
|
+
claimants: claimedBy ? [{ userType: claimedUserType, user: claimedUser }] : [],
|
|
3021
|
+
taskRefNames: taskName ? [taskName] : [],
|
|
3022
|
+
taskInputQuery,
|
|
3023
|
+
taskOutputQuery
|
|
3024
|
+
});
|
|
3025
|
+
return response;
|
|
3026
|
+
}
|
|
3027
|
+
/**
|
|
3028
|
+
* Takes a set of filter parameters. return matches of human tasks for that set of parameters
|
|
3029
|
+
* @param state
|
|
3030
|
+
* @param assignee
|
|
3031
|
+
* @param assigneeType
|
|
3032
|
+
* @param claimedBy
|
|
3033
|
+
* @param taskName
|
|
3034
|
+
* @param freeText
|
|
3035
|
+
* @param includeInputOutput
|
|
3036
|
+
* @returns Promise<HumanTaskEntry[]>
|
|
3037
|
+
*/
|
|
3038
|
+
async search(searchParams) {
|
|
3039
|
+
const search = { ...EMPTY_SEARCH, ...searchParams };
|
|
3040
|
+
const response = await tryCatchReThrow(
|
|
3041
|
+
() => this._client.humanTask.search(search)
|
|
2938
3042
|
);
|
|
2939
3043
|
if (response.results != void 0) {
|
|
2940
3044
|
return response.results;
|
|
2941
3045
|
}
|
|
2942
3046
|
return [];
|
|
2943
3047
|
}
|
|
3048
|
+
/**
|
|
3049
|
+
* Takes a set of filter parameters. An polling interval options. will poll until the task returns a result
|
|
3050
|
+
* @param state
|
|
3051
|
+
* @param assignee
|
|
3052
|
+
* @param assigneeType
|
|
3053
|
+
* @param claimedBy
|
|
3054
|
+
* @param taskName
|
|
3055
|
+
* @param freeText
|
|
3056
|
+
* @param includeInputOutput
|
|
3057
|
+
* @returns Promise<HumanTaskEntry[]>
|
|
3058
|
+
*/
|
|
3059
|
+
async pollSearch(searchParams, {
|
|
3060
|
+
pollInterval = 100,
|
|
3061
|
+
maxPollTimes = 20
|
|
3062
|
+
} = DEFAULT_POLL_INTERVAL2) {
|
|
3063
|
+
let pollCount = 0;
|
|
3064
|
+
while (pollCount < maxPollTimes) {
|
|
3065
|
+
const response = await this.search(searchParams);
|
|
3066
|
+
if (response.length > 0) {
|
|
3067
|
+
return response;
|
|
3068
|
+
}
|
|
3069
|
+
await new Promise((resolve3) => setTimeout(resolve3, pollInterval));
|
|
3070
|
+
pollCount++;
|
|
3071
|
+
}
|
|
3072
|
+
return [];
|
|
3073
|
+
}
|
|
2944
3074
|
/**
|
|
2945
3075
|
* Returns task for a given task id
|
|
2946
3076
|
* @param taskId
|
|
@@ -2956,11 +3086,9 @@ var HumanExecutor = class {
|
|
|
2956
3086
|
* @returns
|
|
2957
3087
|
*/
|
|
2958
3088
|
async claimTaskAsExternalUser(taskId, assignee) {
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
throw errorMapper(error);
|
|
2963
|
-
}
|
|
3089
|
+
return tryCatchReThrow(
|
|
3090
|
+
() => this._client.humanTask.assignAndClaim(taskId, assignee)
|
|
3091
|
+
);
|
|
2964
3092
|
}
|
|
2965
3093
|
/**
|
|
2966
3094
|
* Claim task as conductor user
|
|
@@ -2968,11 +3096,7 @@ var HumanExecutor = class {
|
|
|
2968
3096
|
* @returns
|
|
2969
3097
|
*/
|
|
2970
3098
|
async claimTaskAsConductorUser(taskId) {
|
|
2971
|
-
|
|
2972
|
-
await this._client.humanTask.claimTask(taskId);
|
|
2973
|
-
} catch (error) {
|
|
2974
|
-
throw errorMapper(error);
|
|
2975
|
-
}
|
|
3099
|
+
return tryCatchReThrow(() => this._client.humanTask.claimTask(taskId));
|
|
2976
3100
|
}
|
|
2977
3101
|
/**
|
|
2978
3102
|
* Claim task as conductor user
|
|
@@ -2988,15 +3112,24 @@ var HumanExecutor = class {
|
|
|
2988
3112
|
}
|
|
2989
3113
|
}
|
|
2990
3114
|
/**
|
|
2991
|
-
* Returns a HumanTaskTemplateEntry for a given
|
|
3115
|
+
* Returns a HumanTaskTemplateEntry for a given name and version
|
|
2992
3116
|
* @param templateId
|
|
2993
3117
|
* @returns
|
|
2994
3118
|
*/
|
|
2995
|
-
async
|
|
3119
|
+
async getTemplateByNameVersion(name, version) {
|
|
2996
3120
|
return tryCatchReThrow(
|
|
2997
|
-
() => this._client.humanTask.
|
|
3121
|
+
() => this._client.humanTask.getTemplateByNameAndVersion(name, version)
|
|
2998
3122
|
);
|
|
2999
3123
|
}
|
|
3124
|
+
/**
|
|
3125
|
+
* @deprecated use getTemplate instead. name will be used as id here with version 1
|
|
3126
|
+
* Returns a HumanTaskTemplateEntry for a given templateId
|
|
3127
|
+
* @param templateId
|
|
3128
|
+
* @returns
|
|
3129
|
+
*/
|
|
3130
|
+
async getTemplateById(templateNameVersionOne) {
|
|
3131
|
+
return this.getTemplateByNameVersion(templateNameVersionOne, 1);
|
|
3132
|
+
}
|
|
3000
3133
|
/**
|
|
3001
3134
|
* Takes a taskId and a partial body. will update with given body
|
|
3002
3135
|
* @param taskId
|
|
@@ -3949,6 +4082,7 @@ var orkesConductorClient = baseOrkesConductorClient(
|
|
|
3949
4082
|
WorkflowExecutor,
|
|
3950
4083
|
WorkflowResourceService,
|
|
3951
4084
|
baseOrkesConductorClient,
|
|
4085
|
+
completedTaskMatchingType,
|
|
3952
4086
|
conductorEventTask,
|
|
3953
4087
|
doWhileTask,
|
|
3954
4088
|
dynamicForkTask,
|