@io-orkes/conductor-javascript 0.9.1 → 1.0.1

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/dist/index.mjs CHANGED
@@ -831,6 +831,22 @@ var WorkflowResourceService = class {
831
831
  }
832
832
  });
833
833
  }
834
+ executeWorkflow(body, name, version, requestId, waitUntilTaskRef) {
835
+ return this.httpRequest.request({
836
+ method: "POST",
837
+ url: "/workflow/execute/{name}/{version}",
838
+ path: {
839
+ "name": name,
840
+ "version": version
841
+ },
842
+ query: {
843
+ "requestId": requestId,
844
+ "waitUntilTaskRef": waitUntilTaskRef
845
+ },
846
+ body,
847
+ mediaType: "application/json"
848
+ });
849
+ }
834
850
  startWorkflow(requestBody) {
835
851
  return this.httpRequest.request({
836
852
  method: "POST",
@@ -1313,6 +1329,202 @@ var request = (config, options) => {
1313
1329
  });
1314
1330
  };
1315
1331
 
1332
+ // src/common/open-api/services/HumanTaskService.ts
1333
+ var HumanTaskService = class {
1334
+ constructor(httpRequest) {
1335
+ this.httpRequest = httpRequest;
1336
+ }
1337
+ getTasksByFilter(state, assignee, assigneeType, claimedBy, taskName, freeText, includeInputOutput = false) {
1338
+ return this.httpRequest.request({
1339
+ method: "GET",
1340
+ url: "/human/tasks",
1341
+ query: {
1342
+ "state": state,
1343
+ "assignee": assignee,
1344
+ "assigneeType": assigneeType,
1345
+ "claimedBy": claimedBy,
1346
+ "taskName": taskName,
1347
+ "freeText": freeText,
1348
+ "includeInputOutput": includeInputOutput
1349
+ }
1350
+ });
1351
+ }
1352
+ getTaskLoad() {
1353
+ return this.httpRequest.request({
1354
+ method: "GET",
1355
+ url: "/human/tasks/load"
1356
+ });
1357
+ }
1358
+ search1(queryId, start, size = 100, freeText = "*", query, jsonQuery, includeInputOutput = false) {
1359
+ return this.httpRequest.request({
1360
+ method: "GET",
1361
+ url: "/human/tasks/search",
1362
+ query: {
1363
+ "queryId": queryId,
1364
+ "start": start,
1365
+ "size": size,
1366
+ "freeText": freeText,
1367
+ "query": query,
1368
+ "jsonQuery": jsonQuery,
1369
+ "includeInputOutput": includeInputOutput
1370
+ }
1371
+ });
1372
+ }
1373
+ updateTaskOutput1(taskId) {
1374
+ return this.httpRequest.request({
1375
+ method: "DELETE",
1376
+ url: "/human/tasks/{taskId}",
1377
+ path: {
1378
+ "taskId": taskId
1379
+ }
1380
+ });
1381
+ }
1382
+ getTask1(taskId) {
1383
+ return this.httpRequest.request({
1384
+ method: "GET",
1385
+ url: "/human/tasks/{taskId}",
1386
+ path: {
1387
+ "taskId": taskId
1388
+ }
1389
+ });
1390
+ }
1391
+ getActionLogs(taskId) {
1392
+ return this.httpRequest.request({
1393
+ method: "GET",
1394
+ url: "/human/tasks/{taskId}/actionLogs",
1395
+ path: {
1396
+ "taskId": taskId
1397
+ }
1398
+ });
1399
+ }
1400
+ claimTask(taskId) {
1401
+ return this.httpRequest.request({
1402
+ method: "POST",
1403
+ url: "/human/tasks/{taskId}/claim",
1404
+ path: {
1405
+ "taskId": taskId
1406
+ }
1407
+ });
1408
+ }
1409
+ assignAndClaim(taskId, userId) {
1410
+ return this.httpRequest.request({
1411
+ method: "POST",
1412
+ url: "/human/tasks/{taskId}/externalUser/{userId}",
1413
+ path: {
1414
+ "taskId": taskId,
1415
+ "userId": userId
1416
+ }
1417
+ });
1418
+ }
1419
+ reassignTask(taskId, requestBody) {
1420
+ return this.httpRequest.request({
1421
+ method: "POST",
1422
+ url: "/human/tasks/{taskId}/reassign",
1423
+ path: {
1424
+ "taskId": taskId
1425
+ },
1426
+ body: requestBody,
1427
+ mediaType: "application/json"
1428
+ });
1429
+ }
1430
+ releaseTask(taskId) {
1431
+ return this.httpRequest.request({
1432
+ method: "POST",
1433
+ url: "/human/tasks/{taskId}/release",
1434
+ path: {
1435
+ "taskId": taskId
1436
+ }
1437
+ });
1438
+ }
1439
+ getStateLogs(taskId) {
1440
+ return this.httpRequest.request({
1441
+ method: "GET",
1442
+ url: "/human/tasks/{taskId}/stateLogs",
1443
+ path: {
1444
+ "taskId": taskId
1445
+ }
1446
+ });
1447
+ }
1448
+ updateTaskOutput(taskId, requestBody, complete = false) {
1449
+ return this.httpRequest.request({
1450
+ method: "POST",
1451
+ url: "/human/tasks/{taskId}/update",
1452
+ path: {
1453
+ "taskId": taskId
1454
+ },
1455
+ query: {
1456
+ "complete": complete
1457
+ },
1458
+ body: requestBody,
1459
+ mediaType: "application/json"
1460
+ });
1461
+ }
1462
+ deleteTemplatesByName(name) {
1463
+ return this.httpRequest.request({
1464
+ method: "DELETE",
1465
+ url: "/human/template",
1466
+ query: {
1467
+ "name": name
1468
+ }
1469
+ });
1470
+ }
1471
+ getAllTemplates(name, version) {
1472
+ return this.httpRequest.request({
1473
+ method: "GET",
1474
+ url: "/human/template",
1475
+ query: {
1476
+ "name": name,
1477
+ "version": version
1478
+ }
1479
+ });
1480
+ }
1481
+ saveTemplate(requestBody, newVersion = false) {
1482
+ return this.httpRequest.request({
1483
+ method: "POST",
1484
+ url: "/human/template",
1485
+ query: {
1486
+ "newVersion": newVersion
1487
+ },
1488
+ body: requestBody,
1489
+ mediaType: "application/json"
1490
+ });
1491
+ }
1492
+ deleteTemplateById(id) {
1493
+ return this.httpRequest.request({
1494
+ method: "DELETE",
1495
+ url: "/human/template/{id}",
1496
+ path: {
1497
+ "id": id
1498
+ }
1499
+ });
1500
+ }
1501
+ getTemplateById(id) {
1502
+ return this.httpRequest.request({
1503
+ method: "GET",
1504
+ url: "/human/template/{id}",
1505
+ path: {
1506
+ "id": id
1507
+ }
1508
+ });
1509
+ }
1510
+ };
1511
+
1512
+ // src/common/open-api/services/HumanTaskResourceService.ts
1513
+ var HumanTaskResourceService = class {
1514
+ constructor(httpRequest) {
1515
+ this.httpRequest = httpRequest;
1516
+ }
1517
+ getConductorTaskById(taskId) {
1518
+ return this.httpRequest.request({
1519
+ method: "GET",
1520
+ url: "/human/tasks/{taskId}/conductorTask",
1521
+ path: {
1522
+ "taskId": taskId
1523
+ }
1524
+ });
1525
+ }
1526
+ };
1527
+
1316
1528
  // src/common/open-api/ConductorClient.ts
1317
1529
  var defaultRequestHandler = (request2, config, options) => request2(config, options);
1318
1530
  var ConductorClient = class {
@@ -1343,6 +1555,8 @@ var ConductorClient = class {
1343
1555
  this.tokenResource = new TokenResourceService(this.request);
1344
1556
  this.workflowBulkResource = new WorkflowBulkResourceService(this.request);
1345
1557
  this.workflowResource = new WorkflowResourceService(this.request);
1558
+ this.humanTask = new HumanTaskService(this.request);
1559
+ this.humanTaskResource = new HumanTaskResourceService(this.request);
1346
1560
  }
1347
1561
  };
1348
1562
 
@@ -1470,7 +1684,7 @@ var generateHTTPTask = (overrides = {}) => __spreadProps(__spreadValues(__spread
1470
1684
  // src/common/generators/InlineTask.ts
1471
1685
  var defaultInputParams = {
1472
1686
  value: "${workflow.input.value}",
1473
- evaluatorType: "javascript",
1687
+ evaluatorType: "graaljs",
1474
1688
  expression: "true"
1475
1689
  };
1476
1690
  var generateEvaluationCode = (inputParametersPartial = {}) => {
@@ -1480,15 +1694,15 @@ var generateEvaluationCode = (inputParametersPartial = {}) => {
1480
1694
  const resultingFunction = inlineExpression();
1481
1695
  const resultingFunctionAsString = resultingFunction.toString();
1482
1696
  const toReturn = __spreadProps(__spreadValues({
1483
- evaluatorType: "javascript"
1697
+ evaluatorType: "graaljs"
1484
1698
  }, inputParametersPartial || { value: "true" }), {
1485
1699
  expression: `(${resultingFunctionAsString})();`
1486
1700
  });
1487
1701
  return toReturn;
1488
1702
  }
1489
- return __spreadProps(__spreadValues(__spreadValues({}, defaultInputParams), inputParametersPartial), {
1490
- evaluatorType: "javascript"
1491
- });
1703
+ return __spreadValues(__spreadProps(__spreadValues({}, defaultInputParams), {
1704
+ evaluatorType: "graaljs"
1705
+ }), inputParametersPartial);
1492
1706
  };
1493
1707
  var generateInlineTask = (override = {}) => __spreadProps(__spreadValues(__spreadValues({}, nameTaskNameGenerator("inline", override)), override), {
1494
1708
  inputParameters: generateEvaluationCode(override?.inputParameters || {}),
@@ -1853,6 +2067,13 @@ var workflow = (name, tasks) => ({
1853
2067
  timeoutSeconds: 0
1854
2068
  });
1855
2069
 
2070
+ // src/common/open-api/core/BaseHttpRequest.ts
2071
+ var BaseHttpRequest = class {
2072
+ constructor(config) {
2073
+ this.config = config;
2074
+ }
2075
+ };
2076
+
1856
2077
  // src/task/TaskManager.ts
1857
2078
  var defaultManagerOptions = {
1858
2079
  workerID: "",
@@ -1920,16 +2141,8 @@ var ConductorError = class extends Error {
1920
2141
  }
1921
2142
  }
1922
2143
  };
1923
- var TaskResult = /* @__PURE__ */ ((TaskResult3) => {
1924
- TaskResult3["IN_PROGRESS"] = "IN_PROGRESS";
1925
- TaskResult3["FAILED"] = "FAILED";
1926
- TaskResult3["FAILED_WITH_TERMINAL_ERROR"] = "FAILED_WITH_TERMINAL_ERROR";
1927
- TaskResult3["COMPLETED"] = "COMPLETED";
1928
- return TaskResult3;
1929
- })(TaskResult || {});
1930
2144
 
1931
- // src/core/executor.ts
1932
- var RETRY_TIME_IN_MILLISECONDS = 1e4;
2145
+ // src/core/helpers.ts
1933
2146
  var errorMapper = (error) => new ConductorError(error?.body?.message, error);
1934
2147
  var tryCatchReThrow = (fn) => {
1935
2148
  try {
@@ -1938,6 +2151,9 @@ var tryCatchReThrow = (fn) => {
1938
2151
  throw errorMapper(error);
1939
2152
  }
1940
2153
  };
2154
+
2155
+ // src/core/executor.ts
2156
+ var RETRY_TIME_IN_MILLISECONDS = 1e4;
1941
2157
  var WorkflowExecutor = class {
1942
2158
  constructor(client) {
1943
2159
  this._client = client;
@@ -1948,6 +2164,9 @@ var WorkflowExecutor = class {
1948
2164
  startWorkflow(workflowRequest) {
1949
2165
  return tryCatchReThrow(() => this._client.workflowResource.startWorkflow(workflowRequest));
1950
2166
  }
2167
+ executeWorkflow(workflowRequest, name, version, requestId, waitUntilTaskRef = "") {
2168
+ return tryCatchReThrow(() => this._client.workflowResource.executeWorkflow(workflowRequest, name, version, requestId, waitUntilTaskRef));
2169
+ }
1951
2170
  startWorkflows(workflowsRequest) {
1952
2171
  return tryCatchReThrow(() => workflowsRequest.map(this.startWorkflow));
1953
2172
  }
@@ -1991,29 +2210,99 @@ var WorkflowExecutor = class {
1991
2210
  terminate(workflowInstanceId, reason) {
1992
2211
  return tryCatchReThrow(() => this._client.workflowResource.terminate1(workflowInstanceId, reason));
1993
2212
  }
1994
- updateTask(taskId, workflowInstanceId, taskStatus, taskOutput) {
2213
+ updateTask(taskId, workflowInstanceId, taskStatus, outputData) {
1995
2214
  const taskUpdates = {
1996
2215
  status: taskStatus,
1997
2216
  taskId,
1998
2217
  workflowInstanceId
1999
2218
  };
2000
- return tryCatchReThrow(() => this._client.taskResource.updateTask1(__spreadValues(__spreadValues({}, taskOutput), taskUpdates)));
2219
+ return tryCatchReThrow(() => this._client.taskResource.updateTask1(__spreadValues({
2220
+ outputData
2221
+ }, taskUpdates)));
2001
2222
  }
2002
2223
  updateTaskByRefName(taskReferenceName, workflowInstanceId, status, taskOutput) {
2003
2224
  return tryCatchReThrow(() => this._client.taskResource.updateTask(workflowInstanceId, taskReferenceName, status, taskOutput));
2004
2225
  }
2226
+ getTask(taskId) {
2227
+ return tryCatchReThrow(() => this._client.taskResource.getTask(taskId));
2228
+ }
2229
+ };
2230
+
2231
+ // src/core/human.ts
2232
+ var HumanExecutor = class {
2233
+ constructor(client) {
2234
+ this._client = client;
2235
+ }
2236
+ async getTasksByFilter(state, assignee, assigneeType, claimedBy, taskName, freeText, includeInputOutput = false) {
2237
+ const response = await this._client.humanTask.getTasksByFilter(state, assignee, assigneeType, claimedBy, taskName, freeText, includeInputOutput);
2238
+ if (response.results != void 0) {
2239
+ return response.results;
2240
+ }
2241
+ return [];
2242
+ }
2243
+ getTaskById(taskId) {
2244
+ return tryCatchReThrow(() => this._client.humanTask.getTask1(taskId));
2245
+ }
2246
+ async claimTaskAsExternalUser(taskId, assignee) {
2247
+ try {
2248
+ await this._client.humanTask.assignAndClaim(taskId, assignee);
2249
+ } catch (error) {
2250
+ throw errorMapper(error);
2251
+ }
2252
+ }
2253
+ async claimTaskAsConductorUser(taskId) {
2254
+ try {
2255
+ await this._client.humanTask.claimTask(taskId);
2256
+ } catch (error) {
2257
+ throw errorMapper(error);
2258
+ }
2259
+ }
2260
+ async releaseTask(taskId) {
2261
+ try {
2262
+ await this._client.humanTask.releaseTask(taskId);
2263
+ } catch (error) {
2264
+ throw errorMapper(error);
2265
+ }
2266
+ }
2267
+ async getTemplateById(templateId) {
2268
+ return tryCatchReThrow(() => this._client.humanTask.getTemplateById(templateId));
2269
+ }
2270
+ async updateTaskOutput(taskId, requestBody) {
2271
+ try {
2272
+ await this._client.humanTask.updateTaskOutput(taskId, requestBody, false);
2273
+ } catch (error) {
2274
+ throw errorMapper(error);
2275
+ }
2276
+ }
2277
+ async completeTask(taskId, requestBody = {}) {
2278
+ try {
2279
+ await this._client.humanTask.updateTaskOutput(taskId, requestBody, true);
2280
+ } catch (error) {
2281
+ throw errorMapper(error);
2282
+ }
2283
+ }
2005
2284
  };
2006
2285
  export {
2286
+ ApiError,
2287
+ BaseHttpRequest,
2007
2288
  CancelError,
2008
2289
  CancelablePromise,
2009
2290
  ConductorClient,
2010
2291
  ConductorError,
2011
2292
  DefaultLogger,
2293
+ EventResourceService,
2294
+ HealthCheckResourceService,
2295
+ HumanExecutor,
2296
+ MetadataResourceService,
2297
+ SchedulerResourceService,
2012
2298
  TaskManager,
2013
- TaskResult,
2299
+ TaskResourceService,
2014
2300
  TaskRunner,
2015
2301
  TaskType,
2302
+ TokenResourceService,
2303
+ WorkflowBulkResourceService,
2016
2304
  WorkflowExecutor,
2305
+ WorkflowResourceService,
2017
2306
  conductorEventTask,
2018
2307
  doWhileTask,
2019
2308
  dynamicForkTask,