@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.js CHANGED
@@ -1589,6 +1589,20 @@ var WorkflowResourceService = class {
1589
1589
  }
1590
1590
  });
1591
1591
  }
1592
+ /**
1593
+ * Test workflow execution using mock data
1594
+ * @param requestBody
1595
+ * @returns Workflow OK
1596
+ * @throws ApiError
1597
+ */
1598
+ testWorkflow(requestBody) {
1599
+ return this.httpRequest.request({
1600
+ method: "POST",
1601
+ url: "/workflow/test",
1602
+ body: requestBody,
1603
+ mediaType: "application/json"
1604
+ });
1605
+ }
1592
1606
  };
1593
1607
 
1594
1608
  // src/common/open-api/core/ApiError.ts
@@ -1728,15 +1742,15 @@ var getQueryString = (params) => {
1728
1742
  const append = (key, value) => {
1729
1743
  qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
1730
1744
  };
1731
- const process = (key, value) => {
1745
+ const process2 = (key, value) => {
1732
1746
  if (isDefined(value)) {
1733
1747
  if (Array.isArray(value)) {
1734
1748
  value.forEach((v) => {
1735
- process(key, v);
1749
+ process2(key, v);
1736
1750
  });
1737
1751
  } else if (typeof value === "object") {
1738
1752
  Object.entries(value).forEach(([k, v]) => {
1739
- process(`${key}[${k}]`, v);
1753
+ process2(`${key}[${k}]`, v);
1740
1754
  });
1741
1755
  } else {
1742
1756
  append(key, value);
@@ -1744,7 +1758,7 @@ var getQueryString = (params) => {
1744
1758
  }
1745
1759
  };
1746
1760
  Object.entries(params).forEach(([key, value]) => {
1747
- process(key, value);
1761
+ process2(key, value);
1748
1762
  });
1749
1763
  if (qs.length > 0) {
1750
1764
  return `?${qs.join("&")}`;
@@ -1768,7 +1782,7 @@ var getUrl = (config, options) => {
1768
1782
  var getFormData = (options) => {
1769
1783
  if (options.formData) {
1770
1784
  const formData = new FormData();
1771
- const process = (key, value) => {
1785
+ const process2 = (key, value) => {
1772
1786
  if (isString(value) || isBlob(value)) {
1773
1787
  formData.append(key, value);
1774
1788
  } else {
@@ -1777,9 +1791,9 @@ var getFormData = (options) => {
1777
1791
  };
1778
1792
  Object.entries(options.formData).filter(([_, value]) => isDefined(value)).forEach(([key, value]) => {
1779
1793
  if (Array.isArray(value)) {
1780
- value.forEach((v) => process(key, v));
1794
+ value.forEach((v) => process2(key, v));
1781
1795
  } else {
1782
- process(key, value);
1796
+ process2(key, value);
1783
1797
  }
1784
1798
  });
1785
1799
  return formData;
@@ -1964,7 +1978,7 @@ var HumanTaskService = class {
1964
1978
  method: "DELETE",
1965
1979
  url: "/human/tasks/delete/{taskId}",
1966
1980
  path: {
1967
- taskId
1981
+ "taskId": taskId
1968
1982
  }
1969
1983
  });
1970
1984
  }
@@ -1997,10 +2011,10 @@ var HumanTaskService = class {
1997
2011
  method: "POST",
1998
2012
  url: "/human/tasks/update/taskRef",
1999
2013
  query: {
2000
- workflowId,
2001
- taskRefName,
2002
- complete,
2003
- iteration
2014
+ "workflowId": workflowId,
2015
+ "taskRefName": taskRefName,
2016
+ "complete": complete,
2017
+ "iteration": iteration
2004
2018
  },
2005
2019
  body: requestBody,
2006
2020
  mediaType: "application/json"
@@ -2012,15 +2026,12 @@ var HumanTaskService = class {
2012
2026
  * @returns HumanTaskEntry OK
2013
2027
  * @throws ApiError
2014
2028
  */
2015
- getTask1(taskId, withTemplate = false) {
2029
+ getTask1(taskId) {
2016
2030
  return this.httpRequest.request({
2017
2031
  method: "GET",
2018
2032
  url: "/human/tasks/{taskId}",
2019
2033
  path: {
2020
- taskId
2021
- },
2022
- query: {
2023
- withTemplate
2034
+ "taskId": taskId
2024
2035
  }
2025
2036
  });
2026
2037
  }
@@ -2036,11 +2047,11 @@ var HumanTaskService = class {
2036
2047
  method: "POST",
2037
2048
  url: "/human/tasks/{taskId}/claim",
2038
2049
  path: {
2039
- taskId
2050
+ "taskId": taskId
2040
2051
  },
2041
2052
  query: {
2042
- overrideAssignment,
2043
- withTemplate
2053
+ "overrideAssignment": overrideAssignment,
2054
+ "withTemplate": withTemplate
2044
2055
  }
2045
2056
  });
2046
2057
  }
@@ -2057,12 +2068,12 @@ var HumanTaskService = class {
2057
2068
  method: "POST",
2058
2069
  url: "/human/tasks/{taskId}/externalUser/{userId}",
2059
2070
  path: {
2060
- taskId,
2061
- userId
2071
+ "taskId": taskId,
2072
+ "userId": userId
2062
2073
  },
2063
2074
  query: {
2064
- overrideAssignment,
2065
- withTemplate
2075
+ "overrideAssignment": overrideAssignment,
2076
+ "withTemplate": withTemplate
2066
2077
  }
2067
2078
  });
2068
2079
  }
@@ -2078,7 +2089,7 @@ var HumanTaskService = class {
2078
2089
  method: "POST",
2079
2090
  url: "/human/tasks/{taskId}/reassign",
2080
2091
  path: {
2081
- taskId
2092
+ "taskId": taskId
2082
2093
  },
2083
2094
  body: requestBody,
2084
2095
  mediaType: "application/json"
@@ -2095,7 +2106,7 @@ var HumanTaskService = class {
2095
2106
  method: "POST",
2096
2107
  url: "/human/tasks/{taskId}/release",
2097
2108
  path: {
2098
- taskId
2109
+ "taskId": taskId
2099
2110
  }
2100
2111
  });
2101
2112
  }
@@ -2111,10 +2122,10 @@ var HumanTaskService = class {
2111
2122
  method: "POST",
2112
2123
  url: "/human/tasks/{taskId}/skip",
2113
2124
  path: {
2114
- taskId
2125
+ "taskId": taskId
2115
2126
  },
2116
2127
  query: {
2117
- reason
2128
+ "reason": reason
2118
2129
  }
2119
2130
  });
2120
2131
  }
@@ -2131,10 +2142,10 @@ var HumanTaskService = class {
2131
2142
  method: "POST",
2132
2143
  url: "/human/tasks/{taskId}/update",
2133
2144
  path: {
2134
- taskId
2145
+ "taskId": taskId
2135
2146
  },
2136
2147
  query: {
2137
- complete
2148
+ "complete": complete
2138
2149
  },
2139
2150
  body: requestBody,
2140
2151
  mediaType: "application/json"
@@ -2152,8 +2163,8 @@ var HumanTaskService = class {
2152
2163
  method: "GET",
2153
2164
  url: "/human/template",
2154
2165
  query: {
2155
- name,
2156
- version
2166
+ "name": name,
2167
+ "version": version
2157
2168
  }
2158
2169
  });
2159
2170
  }
@@ -2169,7 +2180,7 @@ var HumanTaskService = class {
2169
2180
  method: "POST",
2170
2181
  url: "/human/template",
2171
2182
  query: {
2172
- newVersion
2183
+ "newVersion": newVersion
2173
2184
  },
2174
2185
  body: requestBody,
2175
2186
  mediaType: "application/json"
@@ -2187,7 +2198,7 @@ var HumanTaskService = class {
2187
2198
  method: "POST",
2188
2199
  url: "/human/template/bulk",
2189
2200
  query: {
2190
- newVersion
2201
+ "newVersion": newVersion
2191
2202
  },
2192
2203
  body: requestBody,
2193
2204
  mediaType: "application/json"
@@ -2204,7 +2215,7 @@ var HumanTaskService = class {
2204
2215
  method: "DELETE",
2205
2216
  url: "/human/template/{name}",
2206
2217
  path: {
2207
- name
2218
+ "name": name
2208
2219
  }
2209
2220
  });
2210
2221
  }
@@ -2220,8 +2231,8 @@ var HumanTaskService = class {
2220
2231
  method: "DELETE",
2221
2232
  url: "/human/template/{name}/{version}",
2222
2233
  path: {
2223
- name,
2224
- version
2234
+ "name": name,
2235
+ "version": version
2225
2236
  }
2226
2237
  });
2227
2238
  }
@@ -2237,8 +2248,8 @@ var HumanTaskService = class {
2237
2248
  method: "GET",
2238
2249
  url: "/human/template/{name}/{version}",
2239
2250
  path: {
2240
- name,
2241
- version
2251
+ "name": name,
2252
+ "version": version
2242
2253
  }
2243
2254
  });
2244
2255
  }
@@ -2268,6 +2279,17 @@ var HumanTaskResourceService = class {
2268
2279
 
2269
2280
  // src/common/open-api/ConductorClient.ts
2270
2281
  var defaultRequestHandler = (request3, config, options) => request3(config, options);
2282
+ var getServerBaseURL = (config) => {
2283
+ if (config?.useEnvVars) {
2284
+ if (!process.env.CONDUCTOR_SERVER_URL) {
2285
+ throw new Error(
2286
+ "Environment variable CONDUCTOR_SERVER_URL is not defined."
2287
+ );
2288
+ }
2289
+ return process.env.CONDUCTOR_SERVER_URL;
2290
+ }
2291
+ return config?.serverUrl ?? "http://localhost:8080";
2292
+ };
2271
2293
  var ConductorClient = class {
2272
2294
  eventResource;
2273
2295
  healthCheckResource;
@@ -2283,7 +2305,7 @@ var ConductorClient = class {
2283
2305
  token;
2284
2306
  constructor(config, requestHandler = defaultRequestHandler) {
2285
2307
  const resolvedConfig = {
2286
- BASE: config?.serverUrl ?? "http://localhost:8080",
2308
+ BASE: getServerBaseURL(config),
2287
2309
  VERSION: config?.VERSION ?? "0",
2288
2310
  WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
2289
2311
  CREDENTIALS: config?.CREDENTIALS ?? "include",
@@ -3131,10 +3153,8 @@ var HumanExecutor = class {
3131
3153
  * @param taskId
3132
3154
  * @returns
3133
3155
  */
3134
- getTaskById(taskId, withTemplate = false) {
3135
- return tryCatchReThrow(
3136
- () => this._client.humanTask.getTask1(taskId, withTemplate)
3137
- );
3156
+ getTaskById(taskId) {
3157
+ return tryCatchReThrow(() => this._client.humanTask.getTask1(taskId));
3138
3158
  }
3139
3159
  /**
3140
3160
  * Assigns taskId to assignee. If the task is already assigned to another user, this will fail.
@@ -3144,12 +3164,7 @@ var HumanExecutor = class {
3144
3164
  */
3145
3165
  async claimTaskAsExternalUser(taskId, assignee, options) {
3146
3166
  return tryCatchReThrow(
3147
- () => this._client.humanTask.assignAndClaim(
3148
- taskId,
3149
- assignee,
3150
- options?.overrideAssignment,
3151
- options?.withTemplate
3152
- )
3167
+ () => this._client.humanTask.assignAndClaim(taskId, assignee, options?.overrideAssignment, options?.withTemplate)
3153
3168
  );
3154
3169
  }
3155
3170
  /**
@@ -3158,13 +3173,7 @@ var HumanExecutor = class {
3158
3173
  * @returns
3159
3174
  */
3160
3175
  async claimTaskAsConductorUser(taskId, options) {
3161
- return tryCatchReThrow(
3162
- () => this._client.humanTask.claimTask(
3163
- taskId,
3164
- options?.overrideAssignment,
3165
- options?.withTemplate
3166
- )
3167
- );
3176
+ return tryCatchReThrow(() => this._client.humanTask.claimTask(taskId, options?.overrideAssignment, options?.withTemplate));
3168
3177
  }
3169
3178
  /**
3170
3179
  * Claim task as conductor user
@@ -4004,6 +4013,18 @@ var MetadataClient = class {
4004
4013
  () => this._client.metadataResource.updateTaskDef(taskDef)
4005
4014
  );
4006
4015
  }
4016
+ /**
4017
+ * Creates or updates (overwrite: true) a workflow definition
4018
+ *
4019
+ * @param workflowDef
4020
+ * @param overwrite
4021
+ * @returns
4022
+ */
4023
+ registerWorkflowDef(workflowDef, overwrite = false) {
4024
+ return tryCatchReThrow(
4025
+ () => this._client.metadataResource.create(workflowDef, overwrite)
4026
+ );
4027
+ }
4007
4028
  };
4008
4029
 
4009
4030
  // src/orkes/BaseOrkesConductorClient.ts
@@ -4033,6 +4054,16 @@ var baseOrkesConductorClient = (fetchFn, baseRequestHandler = defaultRequestHand
4033
4054
  method: "POST"
4034
4055
  });
4035
4056
  return async (config, requestHandler = baseRequestHandler) => {
4057
+ if (config?.useEnvVars) {
4058
+ if (!process.env.CONDUCTOR_SERVER_URL) {
4059
+ throw new Error(
4060
+ "Environment variable CONDUCTOR_SERVER_URL is not defined."
4061
+ );
4062
+ }
4063
+ config.serverUrl = process.env.CONDUCTOR_SERVER_URL;
4064
+ config.keyId = process.env.CONDUCTOR_AUTH_KEY;
4065
+ config.keySecret = process.env.CONDUCTOR_AUTH_SECRET;
4066
+ }
4036
4067
  if (config?.keySecret != null && config?.keyId != null) {
4037
4068
  const {
4038
4069
  serverUrl,
@@ -4101,15 +4132,15 @@ var getQueryString2 = (params) => {
4101
4132
  const append = (key, value) => {
4102
4133
  qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
4103
4134
  };
4104
- const process = (key, value) => {
4135
+ const process2 = (key, value) => {
4105
4136
  if (isDefined2(value)) {
4106
4137
  if (Array.isArray(value)) {
4107
4138
  value.forEach((v) => {
4108
- process(key, v);
4139
+ process2(key, v);
4109
4140
  });
4110
4141
  } else if (typeof value === "object") {
4111
4142
  Object.entries(value).forEach(([k, v]) => {
4112
- process(`${key}[${k}]`, v);
4143
+ process2(`${key}[${k}]`, v);
4113
4144
  });
4114
4145
  } else {
4115
4146
  append(key, value);
@@ -4117,7 +4148,7 @@ var getQueryString2 = (params) => {
4117
4148
  }
4118
4149
  };
4119
4150
  Object.entries(params).forEach(([key, value]) => {
4120
- process(key, value);
4151
+ process2(key, value);
4121
4152
  });
4122
4153
  if (qs.length > 0) {
4123
4154
  return `?${qs.join("&")}`;
@@ -4141,7 +4172,7 @@ var getUrl2 = (config, options) => {
4141
4172
  var getFormData2 = (options) => {
4142
4173
  if (options.formData) {
4143
4174
  const formData = new FormData();
4144
- const process = (key, value) => {
4175
+ const process2 = (key, value) => {
4145
4176
  if (isString2(value) || isBlob2(value)) {
4146
4177
  formData.append(key, value);
4147
4178
  } else {
@@ -4150,9 +4181,9 @@ var getFormData2 = (options) => {
4150
4181
  };
4151
4182
  Object.entries(options.formData).filter(([_, value]) => isDefined2(value)).forEach(([key, value]) => {
4152
4183
  if (Array.isArray(value)) {
4153
- value.forEach((v) => process(key, v));
4184
+ value.forEach((v) => process2(key, v));
4154
4185
  } else {
4155
- process(key, value);
4186
+ process2(key, value);
4156
4187
  }
4157
4188
  });
4158
4189
  return formData;