@io-orkes/conductor-javascript 2.1.3-alpha2 → 2.1.4

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
@@ -1484,6 +1484,20 @@ var WorkflowResourceService = class {
1484
1484
  }
1485
1485
  });
1486
1486
  }
1487
+ /**
1488
+ * Test workflow execution using mock data
1489
+ * @param requestBody
1490
+ * @returns Workflow OK
1491
+ * @throws ApiError
1492
+ */
1493
+ testWorkflow(requestBody) {
1494
+ return this.httpRequest.request({
1495
+ method: "POST",
1496
+ url: "/workflow/test",
1497
+ body: requestBody,
1498
+ mediaType: "application/json"
1499
+ });
1500
+ }
1487
1501
  };
1488
1502
 
1489
1503
  // src/common/open-api/core/ApiError.ts
@@ -1623,15 +1637,15 @@ var getQueryString = (params) => {
1623
1637
  const append = (key, value) => {
1624
1638
  qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
1625
1639
  };
1626
- const process = (key, value) => {
1640
+ const process2 = (key, value) => {
1627
1641
  if (isDefined(value)) {
1628
1642
  if (Array.isArray(value)) {
1629
1643
  value.forEach((v) => {
1630
- process(key, v);
1644
+ process2(key, v);
1631
1645
  });
1632
1646
  } else if (typeof value === "object") {
1633
1647
  Object.entries(value).forEach(([k, v]) => {
1634
- process(`${key}[${k}]`, v);
1648
+ process2(`${key}[${k}]`, v);
1635
1649
  });
1636
1650
  } else {
1637
1651
  append(key, value);
@@ -1639,7 +1653,7 @@ var getQueryString = (params) => {
1639
1653
  }
1640
1654
  };
1641
1655
  Object.entries(params).forEach(([key, value]) => {
1642
- process(key, value);
1656
+ process2(key, value);
1643
1657
  });
1644
1658
  if (qs.length > 0) {
1645
1659
  return `?${qs.join("&")}`;
@@ -1663,7 +1677,7 @@ var getUrl = (config, options) => {
1663
1677
  var getFormData = (options) => {
1664
1678
  if (options.formData) {
1665
1679
  const formData = new FormData();
1666
- const process = (key, value) => {
1680
+ const process2 = (key, value) => {
1667
1681
  if (isString(value) || isBlob(value)) {
1668
1682
  formData.append(key, value);
1669
1683
  } else {
@@ -1672,9 +1686,9 @@ var getFormData = (options) => {
1672
1686
  };
1673
1687
  Object.entries(options.formData).filter(([_, value]) => isDefined(value)).forEach(([key, value]) => {
1674
1688
  if (Array.isArray(value)) {
1675
- value.forEach((v) => process(key, v));
1689
+ value.forEach((v) => process2(key, v));
1676
1690
  } else {
1677
- process(key, value);
1691
+ process2(key, value);
1678
1692
  }
1679
1693
  });
1680
1694
  return formData;
@@ -1859,7 +1873,7 @@ var HumanTaskService = class {
1859
1873
  method: "DELETE",
1860
1874
  url: "/human/tasks/delete/{taskId}",
1861
1875
  path: {
1862
- taskId
1876
+ "taskId": taskId
1863
1877
  }
1864
1878
  });
1865
1879
  }
@@ -1892,10 +1906,10 @@ var HumanTaskService = class {
1892
1906
  method: "POST",
1893
1907
  url: "/human/tasks/update/taskRef",
1894
1908
  query: {
1895
- workflowId,
1896
- taskRefName,
1897
- complete,
1898
- iteration
1909
+ "workflowId": workflowId,
1910
+ "taskRefName": taskRefName,
1911
+ "complete": complete,
1912
+ "iteration": iteration
1899
1913
  },
1900
1914
  body: requestBody,
1901
1915
  mediaType: "application/json"
@@ -1907,15 +1921,12 @@ var HumanTaskService = class {
1907
1921
  * @returns HumanTaskEntry OK
1908
1922
  * @throws ApiError
1909
1923
  */
1910
- getTask1(taskId, withTemplate = false) {
1924
+ getTask1(taskId) {
1911
1925
  return this.httpRequest.request({
1912
1926
  method: "GET",
1913
1927
  url: "/human/tasks/{taskId}",
1914
1928
  path: {
1915
- taskId
1916
- },
1917
- query: {
1918
- withTemplate
1929
+ "taskId": taskId
1919
1930
  }
1920
1931
  });
1921
1932
  }
@@ -1931,11 +1942,11 @@ var HumanTaskService = class {
1931
1942
  method: "POST",
1932
1943
  url: "/human/tasks/{taskId}/claim",
1933
1944
  path: {
1934
- taskId
1945
+ "taskId": taskId
1935
1946
  },
1936
1947
  query: {
1937
- overrideAssignment,
1938
- withTemplate
1948
+ "overrideAssignment": overrideAssignment,
1949
+ "withTemplate": withTemplate
1939
1950
  }
1940
1951
  });
1941
1952
  }
@@ -1952,12 +1963,12 @@ var HumanTaskService = class {
1952
1963
  method: "POST",
1953
1964
  url: "/human/tasks/{taskId}/externalUser/{userId}",
1954
1965
  path: {
1955
- taskId,
1956
- userId
1966
+ "taskId": taskId,
1967
+ "userId": userId
1957
1968
  },
1958
1969
  query: {
1959
- overrideAssignment,
1960
- withTemplate
1970
+ "overrideAssignment": overrideAssignment,
1971
+ "withTemplate": withTemplate
1961
1972
  }
1962
1973
  });
1963
1974
  }
@@ -1973,7 +1984,7 @@ var HumanTaskService = class {
1973
1984
  method: "POST",
1974
1985
  url: "/human/tasks/{taskId}/reassign",
1975
1986
  path: {
1976
- taskId
1987
+ "taskId": taskId
1977
1988
  },
1978
1989
  body: requestBody,
1979
1990
  mediaType: "application/json"
@@ -1990,7 +2001,7 @@ var HumanTaskService = class {
1990
2001
  method: "POST",
1991
2002
  url: "/human/tasks/{taskId}/release",
1992
2003
  path: {
1993
- taskId
2004
+ "taskId": taskId
1994
2005
  }
1995
2006
  });
1996
2007
  }
@@ -2006,10 +2017,10 @@ var HumanTaskService = class {
2006
2017
  method: "POST",
2007
2018
  url: "/human/tasks/{taskId}/skip",
2008
2019
  path: {
2009
- taskId
2020
+ "taskId": taskId
2010
2021
  },
2011
2022
  query: {
2012
- reason
2023
+ "reason": reason
2013
2024
  }
2014
2025
  });
2015
2026
  }
@@ -2026,10 +2037,10 @@ var HumanTaskService = class {
2026
2037
  method: "POST",
2027
2038
  url: "/human/tasks/{taskId}/update",
2028
2039
  path: {
2029
- taskId
2040
+ "taskId": taskId
2030
2041
  },
2031
2042
  query: {
2032
- complete
2043
+ "complete": complete
2033
2044
  },
2034
2045
  body: requestBody,
2035
2046
  mediaType: "application/json"
@@ -2047,8 +2058,8 @@ var HumanTaskService = class {
2047
2058
  method: "GET",
2048
2059
  url: "/human/template",
2049
2060
  query: {
2050
- name,
2051
- version
2061
+ "name": name,
2062
+ "version": version
2052
2063
  }
2053
2064
  });
2054
2065
  }
@@ -2064,7 +2075,7 @@ var HumanTaskService = class {
2064
2075
  method: "POST",
2065
2076
  url: "/human/template",
2066
2077
  query: {
2067
- newVersion
2078
+ "newVersion": newVersion
2068
2079
  },
2069
2080
  body: requestBody,
2070
2081
  mediaType: "application/json"
@@ -2082,7 +2093,7 @@ var HumanTaskService = class {
2082
2093
  method: "POST",
2083
2094
  url: "/human/template/bulk",
2084
2095
  query: {
2085
- newVersion
2096
+ "newVersion": newVersion
2086
2097
  },
2087
2098
  body: requestBody,
2088
2099
  mediaType: "application/json"
@@ -2099,7 +2110,7 @@ var HumanTaskService = class {
2099
2110
  method: "DELETE",
2100
2111
  url: "/human/template/{name}",
2101
2112
  path: {
2102
- name
2113
+ "name": name
2103
2114
  }
2104
2115
  });
2105
2116
  }
@@ -2115,8 +2126,8 @@ var HumanTaskService = class {
2115
2126
  method: "DELETE",
2116
2127
  url: "/human/template/{name}/{version}",
2117
2128
  path: {
2118
- name,
2119
- version
2129
+ "name": name,
2130
+ "version": version
2120
2131
  }
2121
2132
  });
2122
2133
  }
@@ -2132,8 +2143,8 @@ var HumanTaskService = class {
2132
2143
  method: "GET",
2133
2144
  url: "/human/template/{name}/{version}",
2134
2145
  path: {
2135
- name,
2136
- version
2146
+ "name": name,
2147
+ "version": version
2137
2148
  }
2138
2149
  });
2139
2150
  }
@@ -2163,6 +2174,17 @@ var HumanTaskResourceService = class {
2163
2174
 
2164
2175
  // src/common/open-api/ConductorClient.ts
2165
2176
  var defaultRequestHandler = (request3, config, options) => request3(config, options);
2177
+ var getServerBaseURL = (config) => {
2178
+ if (config?.useEnvVars) {
2179
+ if (!process.env.CONDUCTOR_SERVER_URL) {
2180
+ throw new Error(
2181
+ "Environment variable CONDUCTOR_SERVER_URL is not defined."
2182
+ );
2183
+ }
2184
+ return process.env.CONDUCTOR_SERVER_URL;
2185
+ }
2186
+ return config?.serverUrl ?? "http://localhost:8080";
2187
+ };
2166
2188
  var ConductorClient = class {
2167
2189
  eventResource;
2168
2190
  healthCheckResource;
@@ -2178,7 +2200,7 @@ var ConductorClient = class {
2178
2200
  token;
2179
2201
  constructor(config, requestHandler = defaultRequestHandler) {
2180
2202
  const resolvedConfig = {
2181
- BASE: config?.serverUrl ?? "http://localhost:8080",
2203
+ BASE: getServerBaseURL(config),
2182
2204
  VERSION: config?.VERSION ?? "0",
2183
2205
  WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
2184
2206
  CREDENTIALS: config?.CREDENTIALS ?? "include",
@@ -3026,10 +3048,8 @@ var HumanExecutor = class {
3026
3048
  * @param taskId
3027
3049
  * @returns
3028
3050
  */
3029
- getTaskById(taskId, withTemplate = false) {
3030
- return tryCatchReThrow(
3031
- () => this._client.humanTask.getTask1(taskId, withTemplate)
3032
- );
3051
+ getTaskById(taskId) {
3052
+ return tryCatchReThrow(() => this._client.humanTask.getTask1(taskId));
3033
3053
  }
3034
3054
  /**
3035
3055
  * Assigns taskId to assignee. If the task is already assigned to another user, this will fail.
@@ -3039,12 +3059,7 @@ var HumanExecutor = class {
3039
3059
  */
3040
3060
  async claimTaskAsExternalUser(taskId, assignee, options) {
3041
3061
  return tryCatchReThrow(
3042
- () => this._client.humanTask.assignAndClaim(
3043
- taskId,
3044
- assignee,
3045
- options?.overrideAssignment,
3046
- options?.withTemplate
3047
- )
3062
+ () => this._client.humanTask.assignAndClaim(taskId, assignee, options?.overrideAssignment, options?.withTemplate)
3048
3063
  );
3049
3064
  }
3050
3065
  /**
@@ -3053,13 +3068,7 @@ var HumanExecutor = class {
3053
3068
  * @returns
3054
3069
  */
3055
3070
  async claimTaskAsConductorUser(taskId, options) {
3056
- return tryCatchReThrow(
3057
- () => this._client.humanTask.claimTask(
3058
- taskId,
3059
- options?.overrideAssignment,
3060
- options?.withTemplate
3061
- )
3062
- );
3071
+ return tryCatchReThrow(() => this._client.humanTask.claimTask(taskId, options?.overrideAssignment, options?.withTemplate));
3063
3072
  }
3064
3073
  /**
3065
3074
  * Claim task as conductor user
@@ -3899,6 +3908,18 @@ var MetadataClient = class {
3899
3908
  () => this._client.metadataResource.updateTaskDef(taskDef)
3900
3909
  );
3901
3910
  }
3911
+ /**
3912
+ * Creates or updates (overwrite: true) a workflow definition
3913
+ *
3914
+ * @param workflowDef
3915
+ * @param overwrite
3916
+ * @returns
3917
+ */
3918
+ registerWorkflowDef(workflowDef, overwrite = false) {
3919
+ return tryCatchReThrow(
3920
+ () => this._client.metadataResource.create(workflowDef, overwrite)
3921
+ );
3922
+ }
3902
3923
  };
3903
3924
 
3904
3925
  // src/orkes/BaseOrkesConductorClient.ts
@@ -3928,6 +3949,16 @@ var baseOrkesConductorClient = (fetchFn, baseRequestHandler = defaultRequestHand
3928
3949
  method: "POST"
3929
3950
  });
3930
3951
  return async (config, requestHandler = baseRequestHandler) => {
3952
+ if (config?.useEnvVars) {
3953
+ if (!process.env.CONDUCTOR_SERVER_URL) {
3954
+ throw new Error(
3955
+ "Environment variable CONDUCTOR_SERVER_URL is not defined."
3956
+ );
3957
+ }
3958
+ config.serverUrl = process.env.CONDUCTOR_SERVER_URL;
3959
+ config.keyId = process.env.CONDUCTOR_AUTH_KEY;
3960
+ config.keySecret = process.env.CONDUCTOR_AUTH_SECRET;
3961
+ }
3931
3962
  if (config?.keySecret != null && config?.keyId != null) {
3932
3963
  const {
3933
3964
  serverUrl,
@@ -3996,15 +4027,15 @@ var getQueryString2 = (params) => {
3996
4027
  const append = (key, value) => {
3997
4028
  qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
3998
4029
  };
3999
- const process = (key, value) => {
4030
+ const process2 = (key, value) => {
4000
4031
  if (isDefined2(value)) {
4001
4032
  if (Array.isArray(value)) {
4002
4033
  value.forEach((v) => {
4003
- process(key, v);
4034
+ process2(key, v);
4004
4035
  });
4005
4036
  } else if (typeof value === "object") {
4006
4037
  Object.entries(value).forEach(([k, v]) => {
4007
- process(`${key}[${k}]`, v);
4038
+ process2(`${key}[${k}]`, v);
4008
4039
  });
4009
4040
  } else {
4010
4041
  append(key, value);
@@ -4012,7 +4043,7 @@ var getQueryString2 = (params) => {
4012
4043
  }
4013
4044
  };
4014
4045
  Object.entries(params).forEach(([key, value]) => {
4015
- process(key, value);
4046
+ process2(key, value);
4016
4047
  });
4017
4048
  if (qs.length > 0) {
4018
4049
  return `?${qs.join("&")}`;
@@ -4036,7 +4067,7 @@ var getUrl2 = (config, options) => {
4036
4067
  var getFormData2 = (options) => {
4037
4068
  if (options.formData) {
4038
4069
  const formData = new FormData();
4039
- const process = (key, value) => {
4070
+ const process2 = (key, value) => {
4040
4071
  if (isString2(value) || isBlob2(value)) {
4041
4072
  formData.append(key, value);
4042
4073
  } else {
@@ -4045,9 +4076,9 @@ var getFormData2 = (options) => {
4045
4076
  };
4046
4077
  Object.entries(options.formData).filter(([_, value]) => isDefined2(value)).forEach(([key, value]) => {
4047
4078
  if (Array.isArray(value)) {
4048
- value.forEach((v) => process(key, v));
4079
+ value.forEach((v) => process2(key, v));
4049
4080
  } else {
4050
- process(key, value);
4081
+ process2(key, value);
4051
4082
  }
4052
4083
  });
4053
4084
  return formData;