@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.mjs
CHANGED
|
@@ -1823,83 +1823,70 @@ var HumanTaskService = class {
|
|
|
1823
1823
|
this.httpRequest = httpRequest;
|
|
1824
1824
|
}
|
|
1825
1825
|
/**
|
|
1826
|
-
*
|
|
1827
|
-
* @param
|
|
1828
|
-
* @
|
|
1829
|
-
* @param assigneeType
|
|
1830
|
-
* @param claimedBy
|
|
1831
|
-
* @param taskName
|
|
1832
|
-
* @param freeText
|
|
1833
|
-
* @param includeInputOutput
|
|
1834
|
-
* @returns SearchResultHumanTaskEntry OK
|
|
1826
|
+
* If the workflow is disconnected from tasks, this API can be used to clean up (in bulk)
|
|
1827
|
+
* @param requestBody
|
|
1828
|
+
* @returns any OK
|
|
1835
1829
|
* @throws ApiError
|
|
1836
1830
|
*/
|
|
1837
|
-
|
|
1831
|
+
deleteTaskFromHumanTaskRecords(requestBody) {
|
|
1838
1832
|
return this.httpRequest.request({
|
|
1839
|
-
method: "
|
|
1840
|
-
url: "/human/tasks",
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
"assignee": assignee,
|
|
1844
|
-
"assigneeType": assigneeType,
|
|
1845
|
-
"claimedBy": claimedBy,
|
|
1846
|
-
"taskName": taskName,
|
|
1847
|
-
"freeText": freeText,
|
|
1848
|
-
"includeInputOutput": includeInputOutput
|
|
1849
|
-
}
|
|
1833
|
+
method: "DELETE",
|
|
1834
|
+
url: "/human/tasks/delete",
|
|
1835
|
+
body: requestBody,
|
|
1836
|
+
mediaType: "application/json"
|
|
1850
1837
|
});
|
|
1851
1838
|
}
|
|
1852
1839
|
/**
|
|
1853
|
-
*
|
|
1854
|
-
* @
|
|
1840
|
+
* If the workflow is disconnected from tasks, this API can be used to clean up
|
|
1841
|
+
* @param taskId
|
|
1842
|
+
* @returns any OK
|
|
1855
1843
|
* @throws ApiError
|
|
1856
1844
|
*/
|
|
1857
|
-
|
|
1845
|
+
deleteTaskFromHumanTaskRecords1(taskId) {
|
|
1858
1846
|
return this.httpRequest.request({
|
|
1859
|
-
method: "
|
|
1860
|
-
url: "/human/tasks/
|
|
1847
|
+
method: "DELETE",
|
|
1848
|
+
url: "/human/tasks/delete/{taskId}",
|
|
1849
|
+
path: {
|
|
1850
|
+
"taskId": taskId
|
|
1851
|
+
}
|
|
1861
1852
|
});
|
|
1862
1853
|
}
|
|
1863
1854
|
/**
|
|
1864
1855
|
* Search human tasks
|
|
1865
|
-
* @param
|
|
1866
|
-
* @
|
|
1867
|
-
* @param size
|
|
1868
|
-
* @param freeText
|
|
1869
|
-
* @param query
|
|
1870
|
-
* @param jsonQuery
|
|
1871
|
-
* @param includeInputOutput
|
|
1872
|
-
* @returns HTScrollableSearchResultHumanTaskEntry OK
|
|
1856
|
+
* @param requestBody
|
|
1857
|
+
* @returns HumanTaskSearchResult OK
|
|
1873
1858
|
* @throws ApiError
|
|
1874
1859
|
*/
|
|
1875
|
-
|
|
1860
|
+
search(requestBody) {
|
|
1876
1861
|
return this.httpRequest.request({
|
|
1877
|
-
method: "
|
|
1862
|
+
method: "POST",
|
|
1878
1863
|
url: "/human/tasks/search",
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
"start": start,
|
|
1882
|
-
"size": size,
|
|
1883
|
-
"freeText": freeText,
|
|
1884
|
-
"query": query,
|
|
1885
|
-
"jsonQuery": jsonQuery,
|
|
1886
|
-
"includeInputOutput": includeInputOutput
|
|
1887
|
-
}
|
|
1864
|
+
body: requestBody,
|
|
1865
|
+
mediaType: "application/json"
|
|
1888
1866
|
});
|
|
1889
1867
|
}
|
|
1890
1868
|
/**
|
|
1891
|
-
*
|
|
1892
|
-
* @param
|
|
1869
|
+
* Update task output, optionally complete
|
|
1870
|
+
* @param workflowId
|
|
1871
|
+
* @param taskRefName
|
|
1872
|
+
* @param requestBody
|
|
1873
|
+
* @param complete
|
|
1874
|
+
* @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
|
|
1893
1875
|
* @returns any OK
|
|
1894
1876
|
* @throws ApiError
|
|
1895
1877
|
*/
|
|
1896
|
-
|
|
1878
|
+
updateTaskOutputByRef(workflowId, taskRefName, requestBody, complete = false, iteration) {
|
|
1897
1879
|
return this.httpRequest.request({
|
|
1898
|
-
method: "
|
|
1899
|
-
url: "/human/tasks/
|
|
1900
|
-
|
|
1901
|
-
"
|
|
1902
|
-
|
|
1880
|
+
method: "POST",
|
|
1881
|
+
url: "/human/tasks/update/taskRef",
|
|
1882
|
+
query: {
|
|
1883
|
+
"workflowId": workflowId,
|
|
1884
|
+
"taskRefName": taskRefName,
|
|
1885
|
+
"complete": complete,
|
|
1886
|
+
"iteration": iteration
|
|
1887
|
+
},
|
|
1888
|
+
body: requestBody,
|
|
1889
|
+
mediaType: "application/json"
|
|
1903
1890
|
});
|
|
1904
1891
|
}
|
|
1905
1892
|
/**
|
|
@@ -1917,33 +1904,22 @@ var HumanTaskService = class {
|
|
|
1917
1904
|
}
|
|
1918
1905
|
});
|
|
1919
1906
|
}
|
|
1920
|
-
/**
|
|
1921
|
-
* Get human task action log entries by task id
|
|
1922
|
-
* @param taskId
|
|
1923
|
-
* @returns HumanTaskActionLogEntry OK
|
|
1924
|
-
* @throws ApiError
|
|
1925
|
-
*/
|
|
1926
|
-
getActionLogs(taskId) {
|
|
1927
|
-
return this.httpRequest.request({
|
|
1928
|
-
method: "GET",
|
|
1929
|
-
url: "/human/tasks/{taskId}/actionLogs",
|
|
1930
|
-
path: {
|
|
1931
|
-
"taskId": taskId
|
|
1932
|
-
}
|
|
1933
|
-
});
|
|
1934
|
-
}
|
|
1935
1907
|
/**
|
|
1936
1908
|
* Claim a task by authenticated Conductor user
|
|
1937
1909
|
* @param taskId
|
|
1910
|
+
* @param overrideAssignment
|
|
1938
1911
|
* @returns any OK
|
|
1939
1912
|
* @throws ApiError
|
|
1940
1913
|
*/
|
|
1941
|
-
claimTask(taskId) {
|
|
1914
|
+
claimTask(taskId, overrideAssignment = false) {
|
|
1942
1915
|
return this.httpRequest.request({
|
|
1943
1916
|
method: "POST",
|
|
1944
1917
|
url: "/human/tasks/{taskId}/claim",
|
|
1945
1918
|
path: {
|
|
1946
1919
|
"taskId": taskId
|
|
1920
|
+
},
|
|
1921
|
+
query: {
|
|
1922
|
+
"overrideAssignment": overrideAssignment
|
|
1947
1923
|
}
|
|
1948
1924
|
});
|
|
1949
1925
|
}
|
|
@@ -1951,16 +1927,20 @@ var HumanTaskService = class {
|
|
|
1951
1927
|
* Claim a task to an external user
|
|
1952
1928
|
* @param taskId
|
|
1953
1929
|
* @param userId
|
|
1930
|
+
* @param overrideAssignment
|
|
1954
1931
|
* @returns any OK
|
|
1955
1932
|
* @throws ApiError
|
|
1956
1933
|
*/
|
|
1957
|
-
assignAndClaim(taskId, userId) {
|
|
1934
|
+
assignAndClaim(taskId, userId, overrideAssignment = false) {
|
|
1958
1935
|
return this.httpRequest.request({
|
|
1959
1936
|
method: "POST",
|
|
1960
1937
|
url: "/human/tasks/{taskId}/externalUser/{userId}",
|
|
1961
1938
|
path: {
|
|
1962
1939
|
"taskId": taskId,
|
|
1963
1940
|
"userId": userId
|
|
1941
|
+
},
|
|
1942
|
+
query: {
|
|
1943
|
+
"overrideAssignment": overrideAssignment
|
|
1964
1944
|
}
|
|
1965
1945
|
});
|
|
1966
1946
|
}
|
|
@@ -1998,17 +1978,21 @@ var HumanTaskService = class {
|
|
|
1998
1978
|
});
|
|
1999
1979
|
}
|
|
2000
1980
|
/**
|
|
2001
|
-
*
|
|
1981
|
+
* If a task is assigned to a user, this API can be used to skip that assignment and move to the next assignee
|
|
2002
1982
|
* @param taskId
|
|
2003
|
-
* @
|
|
1983
|
+
* @param reason
|
|
1984
|
+
* @returns any OK
|
|
2004
1985
|
* @throws ApiError
|
|
2005
1986
|
*/
|
|
2006
|
-
|
|
1987
|
+
skipTask(taskId, reason) {
|
|
2007
1988
|
return this.httpRequest.request({
|
|
2008
|
-
method: "
|
|
2009
|
-
url: "/human/tasks/{taskId}/
|
|
1989
|
+
method: "POST",
|
|
1990
|
+
url: "/human/tasks/{taskId}/skip",
|
|
2010
1991
|
path: {
|
|
2011
1992
|
"taskId": taskId
|
|
1993
|
+
},
|
|
1994
|
+
query: {
|
|
1995
|
+
"reason": reason
|
|
2012
1996
|
}
|
|
2013
1997
|
});
|
|
2014
1998
|
}
|
|
@@ -2035,48 +2019,51 @@ var HumanTaskService = class {
|
|
|
2035
2019
|
});
|
|
2036
2020
|
}
|
|
2037
2021
|
/**
|
|
2038
|
-
*
|
|
2022
|
+
* List all user form templates or get templates by name, or a template by name and version
|
|
2039
2023
|
* @param name
|
|
2040
|
-
* @
|
|
2024
|
+
* @param version
|
|
2025
|
+
* @returns HumanTaskTemplate OK
|
|
2041
2026
|
* @throws ApiError
|
|
2042
2027
|
*/
|
|
2043
|
-
|
|
2028
|
+
getAllTemplates(name, version) {
|
|
2044
2029
|
return this.httpRequest.request({
|
|
2045
|
-
method: "
|
|
2030
|
+
method: "GET",
|
|
2046
2031
|
url: "/human/template",
|
|
2047
2032
|
query: {
|
|
2048
|
-
"name": name
|
|
2033
|
+
"name": name,
|
|
2034
|
+
"version": version
|
|
2049
2035
|
}
|
|
2050
2036
|
});
|
|
2051
2037
|
}
|
|
2052
2038
|
/**
|
|
2053
|
-
*
|
|
2054
|
-
* @param
|
|
2055
|
-
* @param
|
|
2056
|
-
* @returns
|
|
2039
|
+
* Save user form template
|
|
2040
|
+
* @param requestBody
|
|
2041
|
+
* @param newVersion
|
|
2042
|
+
* @returns HumanTaskTemplate OK
|
|
2057
2043
|
* @throws ApiError
|
|
2058
2044
|
*/
|
|
2059
|
-
|
|
2045
|
+
saveTemplate(requestBody, newVersion = false) {
|
|
2060
2046
|
return this.httpRequest.request({
|
|
2061
|
-
method: "
|
|
2047
|
+
method: "POST",
|
|
2062
2048
|
url: "/human/template",
|
|
2063
2049
|
query: {
|
|
2064
|
-
"
|
|
2065
|
-
|
|
2066
|
-
|
|
2050
|
+
"newVersion": newVersion
|
|
2051
|
+
},
|
|
2052
|
+
body: requestBody,
|
|
2053
|
+
mediaType: "application/json"
|
|
2067
2054
|
});
|
|
2068
2055
|
}
|
|
2069
2056
|
/**
|
|
2070
|
-
* Save
|
|
2057
|
+
* Save user form template
|
|
2071
2058
|
* @param requestBody
|
|
2072
2059
|
* @param newVersion
|
|
2073
|
-
* @returns
|
|
2060
|
+
* @returns HumanTaskTemplate OK
|
|
2074
2061
|
* @throws ApiError
|
|
2075
2062
|
*/
|
|
2076
|
-
|
|
2063
|
+
saveTemplates(requestBody, newVersion = false) {
|
|
2077
2064
|
return this.httpRequest.request({
|
|
2078
2065
|
method: "POST",
|
|
2079
|
-
url: "/human/template",
|
|
2066
|
+
url: "/human/template/bulk",
|
|
2080
2067
|
query: {
|
|
2081
2068
|
"newVersion": newVersion
|
|
2082
2069
|
},
|
|
@@ -2085,32 +2072,51 @@ var HumanTaskService = class {
|
|
|
2085
2072
|
});
|
|
2086
2073
|
}
|
|
2087
2074
|
/**
|
|
2088
|
-
* Delete
|
|
2089
|
-
* @param
|
|
2075
|
+
* Delete all versions of user form template by name
|
|
2076
|
+
* @param name
|
|
2077
|
+
* @returns any OK
|
|
2078
|
+
* @throws ApiError
|
|
2079
|
+
*/
|
|
2080
|
+
deleteTemplateByName(name) {
|
|
2081
|
+
return this.httpRequest.request({
|
|
2082
|
+
method: "DELETE",
|
|
2083
|
+
url: "/human/template/{name}",
|
|
2084
|
+
path: {
|
|
2085
|
+
"name": name
|
|
2086
|
+
}
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
/**
|
|
2090
|
+
* Delete a version of form template by name
|
|
2091
|
+
* @param name
|
|
2092
|
+
* @param version
|
|
2090
2093
|
* @returns any OK
|
|
2091
2094
|
* @throws ApiError
|
|
2092
2095
|
*/
|
|
2093
|
-
|
|
2096
|
+
deleteTemplatesByNameAndVersion(name, version) {
|
|
2094
2097
|
return this.httpRequest.request({
|
|
2095
2098
|
method: "DELETE",
|
|
2096
|
-
url: "/human/template/{
|
|
2099
|
+
url: "/human/template/{name}/{version}",
|
|
2097
2100
|
path: {
|
|
2098
|
-
"
|
|
2101
|
+
"name": name,
|
|
2102
|
+
"version": version
|
|
2099
2103
|
}
|
|
2100
2104
|
});
|
|
2101
2105
|
}
|
|
2102
2106
|
/**
|
|
2103
|
-
* Get
|
|
2104
|
-
* @param
|
|
2105
|
-
* @
|
|
2107
|
+
* Get user form template by name and version
|
|
2108
|
+
* @param name
|
|
2109
|
+
* @param version
|
|
2110
|
+
* @returns HumanTaskTemplate OK
|
|
2106
2111
|
* @throws ApiError
|
|
2107
2112
|
*/
|
|
2108
|
-
|
|
2113
|
+
getTemplateByNameAndVersion(name, version) {
|
|
2109
2114
|
return this.httpRequest.request({
|
|
2110
2115
|
method: "GET",
|
|
2111
|
-
url: "/human/template/{
|
|
2116
|
+
url: "/human/template/{name}/{version}",
|
|
2112
2117
|
path: {
|
|
2113
|
-
"
|
|
2118
|
+
"name": name,
|
|
2119
|
+
"version": version
|
|
2114
2120
|
}
|
|
2115
2121
|
});
|
|
2116
2122
|
}
|
|
@@ -2281,6 +2287,15 @@ var Poller = class {
|
|
|
2281
2287
|
}
|
|
2282
2288
|
};
|
|
2283
2289
|
|
|
2290
|
+
// src/task/helpers.ts
|
|
2291
|
+
var optionEquals = (oldOptions, newOptions) => {
|
|
2292
|
+
const newOptionEntries = Object.entries(newOptions);
|
|
2293
|
+
const oldOptionsEntries = Object.entries(oldOptions);
|
|
2294
|
+
return newOptionEntries.length === oldOptionsEntries.length && newOptionEntries.every(
|
|
2295
|
+
([key, value]) => oldOptions[key] === value
|
|
2296
|
+
);
|
|
2297
|
+
};
|
|
2298
|
+
|
|
2284
2299
|
// src/task/TaskRunner.ts
|
|
2285
2300
|
var DEFAULT_ERROR_MESSAGE = "An unknown error occurred";
|
|
2286
2301
|
var MAX_RETRIES = 3;
|
|
@@ -2407,13 +2422,16 @@ var TaskRunner = class {
|
|
|
2407
2422
|
}
|
|
2408
2423
|
updateOptions(options) {
|
|
2409
2424
|
const newOptions = { ...this.options, ...options };
|
|
2410
|
-
this.
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2425
|
+
const isOptionsUpdated = !optionEquals(this.options, newOptions);
|
|
2426
|
+
if (isOptionsUpdated) {
|
|
2427
|
+
this.poller.updateOptions({
|
|
2428
|
+
concurrency: newOptions.concurrency,
|
|
2429
|
+
pollInterval: newOptions.pollInterval
|
|
2430
|
+
});
|
|
2431
|
+
this.logger.info(
|
|
2432
|
+
`TaskWorker ${this.worker.taskDefName} configuration updated with concurrency of ${this.poller.options.concurrency} and poll interval of ${this.poller.options.pollInterval}`
|
|
2433
|
+
);
|
|
2434
|
+
}
|
|
2417
2435
|
this.options = newOptions;
|
|
2418
2436
|
}
|
|
2419
2437
|
get getOptions() {
|
|
@@ -2556,9 +2574,18 @@ var tryCatchReThrow = (fn) => {
|
|
|
2556
2574
|
throw errorMapper(error);
|
|
2557
2575
|
}
|
|
2558
2576
|
};
|
|
2577
|
+
function reverseFind(array, predicate) {
|
|
2578
|
+
for (let i = array.length - 1; i >= 0; i--) {
|
|
2579
|
+
if (predicate(array[i], i, array)) {
|
|
2580
|
+
return array[i];
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
return void 0;
|
|
2584
|
+
}
|
|
2559
2585
|
|
|
2560
2586
|
// src/core/executor.ts
|
|
2561
2587
|
var RETRY_TIME_IN_MILLISECONDS = 1e4;
|
|
2588
|
+
var completedTaskMatchingType = (taskType) => (task) => task.status === "COMPLETED" && task.taskType === taskType;
|
|
2562
2589
|
var WorkflowExecutor = class {
|
|
2563
2590
|
constructor(client) {
|
|
2564
2591
|
this._client = client;
|
|
@@ -2591,12 +2618,38 @@ var WorkflowExecutor = class {
|
|
|
2591
2618
|
*/
|
|
2592
2619
|
executeWorkflow(workflowRequest, name, version, requestId, waitUntilTaskRef = "") {
|
|
2593
2620
|
return tryCatchReThrow(
|
|
2594
|
-
() => this._client.workflowResource.executeWorkflow(
|
|
2621
|
+
() => this._client.workflowResource.executeWorkflow(
|
|
2622
|
+
workflowRequest,
|
|
2623
|
+
name,
|
|
2624
|
+
version,
|
|
2625
|
+
requestId,
|
|
2626
|
+
waitUntilTaskRef
|
|
2627
|
+
)
|
|
2595
2628
|
);
|
|
2596
2629
|
}
|
|
2597
2630
|
startWorkflows(workflowsRequest) {
|
|
2598
2631
|
return tryCatchReThrow(() => workflowsRequest.map(this.startWorkflow));
|
|
2599
2632
|
}
|
|
2633
|
+
async goBackToTask(workflowInstanceId, taskFinderPredicate, rerunWorkflowRequestOverrides = {}) {
|
|
2634
|
+
const { tasks: executedTasks = [] } = await this.getExecution(
|
|
2635
|
+
workflowInstanceId
|
|
2636
|
+
);
|
|
2637
|
+
const maybePreviousTask = reverseFind(
|
|
2638
|
+
executedTasks,
|
|
2639
|
+
taskFinderPredicate
|
|
2640
|
+
);
|
|
2641
|
+
if (!maybePreviousTask) {
|
|
2642
|
+
throw new Error("Task not found");
|
|
2643
|
+
}
|
|
2644
|
+
await this.reRun(workflowInstanceId, {
|
|
2645
|
+
//taskInput: previousTask.inputData,
|
|
2646
|
+
...rerunWorkflowRequestOverrides,
|
|
2647
|
+
reRunFromTaskId: maybePreviousTask.taskId
|
|
2648
|
+
});
|
|
2649
|
+
}
|
|
2650
|
+
async goBackToFirstTaskMatchingType(workflowInstanceId, taskType) {
|
|
2651
|
+
return this.goBackToTask(workflowInstanceId, completedTaskMatchingType(taskType));
|
|
2652
|
+
}
|
|
2600
2653
|
/**
|
|
2601
2654
|
* Takes an workflowInstanceId and an includeTasks and an optional retry parameter returns the whole execution status.
|
|
2602
2655
|
* If includeTasks flag is provided. Details of tasks execution will be returned as well,
|
|
@@ -2641,6 +2694,22 @@ var WorkflowExecutor = class {
|
|
|
2641
2694
|
)
|
|
2642
2695
|
);
|
|
2643
2696
|
}
|
|
2697
|
+
/**
|
|
2698
|
+
* Returns a summary of the current workflow status.
|
|
2699
|
+
*
|
|
2700
|
+
* @param workflowInstanceId current running workflow
|
|
2701
|
+
* @param includeOutput flag to include output
|
|
2702
|
+
* @param includeVariables flag to include variable
|
|
2703
|
+
* @returns Promise<WorkflowStatus>
|
|
2704
|
+
*/
|
|
2705
|
+
getExecution(workflowInstanceId, includeTasks = true) {
|
|
2706
|
+
return tryCatchReThrow(
|
|
2707
|
+
() => this._client.workflowResource.getExecutionStatus(
|
|
2708
|
+
workflowInstanceId,
|
|
2709
|
+
includeTasks
|
|
2710
|
+
)
|
|
2711
|
+
);
|
|
2712
|
+
}
|
|
2644
2713
|
/**
|
|
2645
2714
|
* Pauses a running workflow
|
|
2646
2715
|
* @param workflowInstanceId current workflow execution
|
|
@@ -2810,11 +2879,24 @@ var WorkflowExecutor = class {
|
|
|
2810
2879
|
};
|
|
2811
2880
|
|
|
2812
2881
|
// src/core/human.ts
|
|
2882
|
+
var EMPTY_SEARCH = {
|
|
2883
|
+
size: 15,
|
|
2884
|
+
states: [],
|
|
2885
|
+
taskInputQuery: "",
|
|
2886
|
+
taskOutputQuery: "",
|
|
2887
|
+
definitionNames: [],
|
|
2888
|
+
taskRefNames: [],
|
|
2889
|
+
claimants: [],
|
|
2890
|
+
assignees: [],
|
|
2891
|
+
start: 0
|
|
2892
|
+
};
|
|
2893
|
+
var DEFAULT_POLL_INTERVAL2 = { pollInterval: 100, maxPollTimes: 20 };
|
|
2813
2894
|
var HumanExecutor = class {
|
|
2814
2895
|
constructor(client) {
|
|
2815
2896
|
this._client = client;
|
|
2816
2897
|
}
|
|
2817
2898
|
/**
|
|
2899
|
+
* @deprecated use search instead
|
|
2818
2900
|
* Takes a set of filter parameters. return matches of human tasks for that set of parameters
|
|
2819
2901
|
* @param state
|
|
2820
2902
|
* @param assignee
|
|
@@ -2825,21 +2907,68 @@ var HumanExecutor = class {
|
|
|
2825
2907
|
* @param includeInputOutput
|
|
2826
2908
|
* @returns
|
|
2827
2909
|
*/
|
|
2828
|
-
async getTasksByFilter(state, assignee, assigneeType, claimedBy, taskName,
|
|
2829
|
-
const
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2910
|
+
async getTasksByFilter(state, assignee, assigneeType, claimedBy, taskName, taskInputQuery, taskOutputQuery) {
|
|
2911
|
+
const [claimedUserType, claimedUser] = claimedBy?.split(":") ?? [];
|
|
2912
|
+
if (claimedUserType && !claimedUser) {
|
|
2913
|
+
throw new Error("claimedBy should be in the format of <userType>:<user>");
|
|
2914
|
+
}
|
|
2915
|
+
const response = await this.search({
|
|
2916
|
+
states: [state],
|
|
2917
|
+
assignees: assignee ? [{ userType: assigneeType, user: assignee }] : [],
|
|
2918
|
+
claimants: claimedBy ? [{ userType: claimedUserType, user: claimedUser }] : [],
|
|
2919
|
+
taskRefNames: taskName ? [taskName] : [],
|
|
2920
|
+
taskInputQuery,
|
|
2921
|
+
taskOutputQuery
|
|
2922
|
+
});
|
|
2923
|
+
return response;
|
|
2924
|
+
}
|
|
2925
|
+
/**
|
|
2926
|
+
* Takes a set of filter parameters. return matches of human tasks for that set of parameters
|
|
2927
|
+
* @param state
|
|
2928
|
+
* @param assignee
|
|
2929
|
+
* @param assigneeType
|
|
2930
|
+
* @param claimedBy
|
|
2931
|
+
* @param taskName
|
|
2932
|
+
* @param freeText
|
|
2933
|
+
* @param includeInputOutput
|
|
2934
|
+
* @returns Promise<HumanTaskEntry[]>
|
|
2935
|
+
*/
|
|
2936
|
+
async search(searchParams) {
|
|
2937
|
+
const search = { ...EMPTY_SEARCH, ...searchParams };
|
|
2938
|
+
const response = await tryCatchReThrow(
|
|
2939
|
+
() => this._client.humanTask.search(search)
|
|
2837
2940
|
);
|
|
2838
2941
|
if (response.results != void 0) {
|
|
2839
2942
|
return response.results;
|
|
2840
2943
|
}
|
|
2841
2944
|
return [];
|
|
2842
2945
|
}
|
|
2946
|
+
/**
|
|
2947
|
+
* Takes a set of filter parameters. An polling interval options. will poll until the task returns a result
|
|
2948
|
+
* @param state
|
|
2949
|
+
* @param assignee
|
|
2950
|
+
* @param assigneeType
|
|
2951
|
+
* @param claimedBy
|
|
2952
|
+
* @param taskName
|
|
2953
|
+
* @param freeText
|
|
2954
|
+
* @param includeInputOutput
|
|
2955
|
+
* @returns Promise<HumanTaskEntry[]>
|
|
2956
|
+
*/
|
|
2957
|
+
async pollSearch(searchParams, {
|
|
2958
|
+
pollInterval = 100,
|
|
2959
|
+
maxPollTimes = 20
|
|
2960
|
+
} = DEFAULT_POLL_INTERVAL2) {
|
|
2961
|
+
let pollCount = 0;
|
|
2962
|
+
while (pollCount < maxPollTimes) {
|
|
2963
|
+
const response = await this.search(searchParams);
|
|
2964
|
+
if (response.length > 0) {
|
|
2965
|
+
return response;
|
|
2966
|
+
}
|
|
2967
|
+
await new Promise((resolve3) => setTimeout(resolve3, pollInterval));
|
|
2968
|
+
pollCount++;
|
|
2969
|
+
}
|
|
2970
|
+
return [];
|
|
2971
|
+
}
|
|
2843
2972
|
/**
|
|
2844
2973
|
* Returns task for a given task id
|
|
2845
2974
|
* @param taskId
|
|
@@ -2855,11 +2984,9 @@ var HumanExecutor = class {
|
|
|
2855
2984
|
* @returns
|
|
2856
2985
|
*/
|
|
2857
2986
|
async claimTaskAsExternalUser(taskId, assignee) {
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
throw errorMapper(error);
|
|
2862
|
-
}
|
|
2987
|
+
return tryCatchReThrow(
|
|
2988
|
+
() => this._client.humanTask.assignAndClaim(taskId, assignee)
|
|
2989
|
+
);
|
|
2863
2990
|
}
|
|
2864
2991
|
/**
|
|
2865
2992
|
* Claim task as conductor user
|
|
@@ -2867,11 +2994,7 @@ var HumanExecutor = class {
|
|
|
2867
2994
|
* @returns
|
|
2868
2995
|
*/
|
|
2869
2996
|
async claimTaskAsConductorUser(taskId) {
|
|
2870
|
-
|
|
2871
|
-
await this._client.humanTask.claimTask(taskId);
|
|
2872
|
-
} catch (error) {
|
|
2873
|
-
throw errorMapper(error);
|
|
2874
|
-
}
|
|
2997
|
+
return tryCatchReThrow(() => this._client.humanTask.claimTask(taskId));
|
|
2875
2998
|
}
|
|
2876
2999
|
/**
|
|
2877
3000
|
* Claim task as conductor user
|
|
@@ -2887,15 +3010,24 @@ var HumanExecutor = class {
|
|
|
2887
3010
|
}
|
|
2888
3011
|
}
|
|
2889
3012
|
/**
|
|
2890
|
-
* Returns a HumanTaskTemplateEntry for a given
|
|
3013
|
+
* Returns a HumanTaskTemplateEntry for a given name and version
|
|
2891
3014
|
* @param templateId
|
|
2892
3015
|
* @returns
|
|
2893
3016
|
*/
|
|
2894
|
-
async
|
|
3017
|
+
async getTemplateByNameVersion(name, version) {
|
|
2895
3018
|
return tryCatchReThrow(
|
|
2896
|
-
() => this._client.humanTask.
|
|
3019
|
+
() => this._client.humanTask.getTemplateByNameAndVersion(name, version)
|
|
2897
3020
|
);
|
|
2898
3021
|
}
|
|
3022
|
+
/**
|
|
3023
|
+
* @deprecated use getTemplate instead. name will be used as id here with version 1
|
|
3024
|
+
* Returns a HumanTaskTemplateEntry for a given templateId
|
|
3025
|
+
* @param templateId
|
|
3026
|
+
* @returns
|
|
3027
|
+
*/
|
|
3028
|
+
async getTemplateById(templateNameVersionOne) {
|
|
3029
|
+
return this.getTemplateByNameVersion(templateNameVersionOne, 1);
|
|
3030
|
+
}
|
|
2899
3031
|
/**
|
|
2900
3032
|
* Takes a taskId and a partial body. will update with given body
|
|
2901
3033
|
* @param taskId
|
|
@@ -3847,6 +3979,7 @@ export {
|
|
|
3847
3979
|
WorkflowExecutor,
|
|
3848
3980
|
WorkflowResourceService,
|
|
3849
3981
|
baseOrkesConductorClient,
|
|
3982
|
+
completedTaskMatchingType,
|
|
3850
3983
|
conductorEventTask,
|
|
3851
3984
|
doWhileTask,
|
|
3852
3985
|
dynamicForkTask,
|