@io-orkes/conductor-javascript 2.1.4 → 2.1.5

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
@@ -52,6 +52,19 @@ var noopLogger = {
52
52
  };
53
53
 
54
54
  // src/common/types.ts
55
+ var Consistency = /* @__PURE__ */ ((Consistency3) => {
56
+ Consistency3["SYNCHRONOUS"] = "SYNCHRONOUS";
57
+ Consistency3["DURABLE"] = "DURABLE";
58
+ Consistency3["REGION_DURABLE"] = "REGION_DURABLE";
59
+ return Consistency3;
60
+ })(Consistency || {});
61
+ var ReturnStrategy = /* @__PURE__ */ ((ReturnStrategy2) => {
62
+ ReturnStrategy2["TARGET_WORKFLOW"] = "TARGET_WORKFLOW";
63
+ ReturnStrategy2["BLOCKING_WORKFLOW"] = "BLOCKING_WORKFLOW";
64
+ ReturnStrategy2["BLOCKING_TASK"] = "BLOCKING_TASK";
65
+ ReturnStrategy2["BLOCKING_TASK_INPUT"] = "BLOCKING_TASK_INPUT";
66
+ return ReturnStrategy2;
67
+ })(ReturnStrategy || {});
55
68
  var TaskType = /* @__PURE__ */ ((TaskType2) => {
56
69
  TaskType2["START"] = "START";
57
70
  TaskType2["SIMPLE"] = "SIMPLE";
@@ -890,6 +903,76 @@ var TaskResourceService = class {
890
903
  }
891
904
  });
892
905
  }
906
+ /**
907
+ * Update a task By Ref Name synchronously. The output data is merged if data from a previous API call already exists.
908
+ * @param workflowId
909
+ * @param taskRefName
910
+ * @param status
911
+ * @param output
912
+ * @param workerId - Optional
913
+ * @returns Workflow
914
+ * @throws ApiError
915
+ */
916
+ updateTaskSync(workflowId, taskRefName, status, output, workerId2) {
917
+ return this.httpRequest.request({
918
+ method: "POST",
919
+ url: "/tasks/{workflowId}/{taskRefName}/{status}/sync",
920
+ path: {
921
+ "workflowId": workflowId,
922
+ "taskRefName": taskRefName,
923
+ "status": status
924
+ },
925
+ query: {
926
+ "workerid": workerId2
927
+ },
928
+ body: output,
929
+ mediaType: "application/json"
930
+ });
931
+ }
932
+ /**
933
+ * Signals a task in a workflow synchronously and returns data based on the specified return strategy
934
+ * @param workflowId - Workflow ID of the workflow to be signaled
935
+ * @param status - Signal status to be set for the workflow
936
+ * @param output - Output for the task
937
+ * @param returnStrategy - Optional strategy for what data to return (defaults to TARGET_WORKFLOW)
938
+ * @returns SignalResponse with data based on the return strategy
939
+ * @throws ApiError
940
+ */
941
+ signal(workflowId, status, output, returnStrategy = "TARGET_WORKFLOW" /* TARGET_WORKFLOW */) {
942
+ return this.httpRequest.request({
943
+ method: "POST",
944
+ url: "/tasks/{workflowId}/{status}/signal/sync",
945
+ path: {
946
+ "workflowId": workflowId,
947
+ "status": status
948
+ },
949
+ query: {
950
+ "returnStrategy": returnStrategy
951
+ },
952
+ body: output,
953
+ mediaType: "application/json"
954
+ });
955
+ }
956
+ /**
957
+ * Signals a task in a workflow asynchronously (fire-and-forget)
958
+ * @param workflowId - Workflow ID of the workflow to be signaled
959
+ * @param status - Signal status to be set for the workflow
960
+ * @param output - Output for the task
961
+ * @returns Promise<void>
962
+ * @throws ApiError
963
+ */
964
+ signalAsync(workflowId, status, output) {
965
+ return this.httpRequest.request({
966
+ method: "POST",
967
+ url: "/tasks/{workflowId}/{status}/signal",
968
+ path: {
969
+ "workflowId": workflowId,
970
+ "status": status
971
+ },
972
+ body: output,
973
+ mediaType: "application/json"
974
+ });
975
+ }
893
976
  };
894
977
 
895
978
  // src/common/open-api/services/TokenResourceService.ts
@@ -1039,16 +1122,18 @@ var WorkflowResourceService = class {
1039
1122
  }
1040
1123
  /**
1041
1124
  * Execute a workflow synchronously
1042
- * @param body
1043
- * @param name
1044
- * @param version
1045
- * @param requestId
1046
- * @param waitUntilTaskRef
1047
- * @param callback
1048
- * @returns workflowRun
1125
+ * @param body
1126
+ * @param name
1127
+ * @param version
1128
+ * @param requestId
1129
+ * @param waitUntilTaskRef
1130
+ * @param waitForSeconds - Optional, defaults to 10
1131
+ * @param consistency - Optional, defaults to "DURABLE"
1132
+ * @param returnStrategy - Optional, defaults to "TARGET_WORKFLOW"
1133
+ * @returns SignalResponse
1049
1134
  * @throws ApiError
1050
1135
  */
1051
- executeWorkflow(body, name, version, requestId, waitUntilTaskRef) {
1136
+ executeWorkflow(body, name, version, requestId, waitUntilTaskRef, waitForSeconds, consistency, returnStrategy) {
1052
1137
  return this.httpRequest.request({
1053
1138
  method: "POST",
1054
1139
  url: "/workflow/execute/{name}/{version}",
@@ -1058,7 +1143,10 @@ var WorkflowResourceService = class {
1058
1143
  },
1059
1144
  query: {
1060
1145
  "requestId": requestId,
1061
- "waitUntilTaskRef": waitUntilTaskRef
1146
+ "waitUntilTaskRef": waitUntilTaskRef,
1147
+ "waitForSeconds": waitForSeconds,
1148
+ "consistency": consistency,
1149
+ "returnStrategy": returnStrategy
1062
1150
  },
1063
1151
  body,
1064
1152
  mediaType: "application/json"
@@ -2172,6 +2260,245 @@ var HumanTaskResourceService = class {
2172
2260
  }
2173
2261
  };
2174
2262
 
2263
+ // src/common/open-api/services/ServiceRegistryResourceService.ts
2264
+ var ServiceRegistryResourceService = class {
2265
+ constructor(httpRequest) {
2266
+ this.httpRequest = httpRequest;
2267
+ }
2268
+ /**
2269
+ * Retrieve all registered services
2270
+ * @returns Array<ServiceRegistryModels> List of all registered services
2271
+ * @throws ApiError
2272
+ */
2273
+ getRegisteredServices() {
2274
+ return this.httpRequest.request({
2275
+ method: "GET",
2276
+ url: "/registry/service"
2277
+ });
2278
+ }
2279
+ /**
2280
+ * Remove a service by name
2281
+ * @param name The name of the service to remove
2282
+ * @returns void
2283
+ * @throws ApiError
2284
+ */
2285
+ removeService(name) {
2286
+ return this.httpRequest.request({
2287
+ method: "DELETE",
2288
+ url: "/registry/service/{name}",
2289
+ path: {
2290
+ "name": name
2291
+ }
2292
+ });
2293
+ }
2294
+ /**
2295
+ * Get a service by name
2296
+ * @param name The name of the service to retrieve
2297
+ * @returns ServiceRegistryModels The requested service registry
2298
+ * @throws ApiError
2299
+ */
2300
+ getService(name) {
2301
+ return this.httpRequest.request({
2302
+ method: "GET",
2303
+ url: "/registry/service/{name}",
2304
+ path: {
2305
+ "name": name
2306
+ }
2307
+ });
2308
+ }
2309
+ /**
2310
+ * Open the circuit breaker for a service
2311
+ * @param name The name of the service
2312
+ * @returns CircuitBreakerTransitionResponse Response with circuit breaker status
2313
+ * @throws ApiError
2314
+ */
2315
+ openCircuitBreaker(name) {
2316
+ return this.httpRequest.request({
2317
+ method: "POST",
2318
+ url: "/registry/service/{name}/circuit-breaker/open",
2319
+ path: {
2320
+ "name": name
2321
+ }
2322
+ });
2323
+ }
2324
+ /**
2325
+ * Close the circuit breaker for a service
2326
+ * @param name The name of the service
2327
+ * @returns CircuitBreakerTransitionResponse Response with circuit breaker status
2328
+ * @throws ApiError
2329
+ */
2330
+ closeCircuitBreaker(name) {
2331
+ return this.httpRequest.request({
2332
+ method: "POST",
2333
+ url: "/registry/service/{name}/circuit-breaker/close",
2334
+ path: {
2335
+ "name": name
2336
+ }
2337
+ });
2338
+ }
2339
+ /**
2340
+ * Get circuit breaker status for a service
2341
+ * @param name The name of the service
2342
+ * @returns CircuitBreakerTransitionResponse Response with circuit breaker status
2343
+ * @throws ApiError
2344
+ */
2345
+ getCircuitBreakerStatus(name) {
2346
+ return this.httpRequest.request({
2347
+ method: "GET",
2348
+ url: "/registry/service/{name}/circuit-breaker/status",
2349
+ path: {
2350
+ "name": name
2351
+ }
2352
+ });
2353
+ }
2354
+ /**
2355
+ * Add or update a service registry
2356
+ * @param serviceRegistry The service registry to add or update
2357
+ * @returns void
2358
+ * @throws ApiError
2359
+ */
2360
+ addOrUpdateService(serviceRegistry) {
2361
+ return this.httpRequest.request({
2362
+ method: "POST",
2363
+ url: "/registry/service",
2364
+ body: serviceRegistry,
2365
+ mediaType: "application/json"
2366
+ });
2367
+ }
2368
+ /**
2369
+ * Add or update a service method
2370
+ * @param registryName The name of the registry
2371
+ * @param method The service method to add or update
2372
+ * @returns void
2373
+ * @throws ApiError
2374
+ */
2375
+ addOrUpdateServiceMethod(registryName, method) {
2376
+ return this.httpRequest.request({
2377
+ method: "POST",
2378
+ url: "/registry/service/{registryName}/methods",
2379
+ path: {
2380
+ "registryName": registryName
2381
+ },
2382
+ body: method,
2383
+ mediaType: "application/json"
2384
+ });
2385
+ }
2386
+ /**
2387
+ * Remove a service method
2388
+ * @param registryName The name of the registry
2389
+ * @param serviceName The name of the service
2390
+ * @param method The name of the method
2391
+ * @param methodType The type of the method
2392
+ * @returns void
2393
+ * @throws ApiError
2394
+ */
2395
+ removeMethod(registryName, serviceName, method, methodType) {
2396
+ return this.httpRequest.request({
2397
+ method: "DELETE",
2398
+ url: "/registry/service/{registryName}/methods",
2399
+ path: {
2400
+ "registryName": registryName
2401
+ },
2402
+ query: {
2403
+ "serviceName": serviceName,
2404
+ "method": method,
2405
+ "methodType": methodType
2406
+ }
2407
+ });
2408
+ }
2409
+ /**
2410
+ * Get proto data
2411
+ * @param registryName The name of the registry
2412
+ * @param filename The name of the proto file
2413
+ * @returns binary The proto file data
2414
+ * @throws ApiError
2415
+ */
2416
+ getProtoData(registryName, filename) {
2417
+ return this.httpRequest.request({
2418
+ method: "GET",
2419
+ url: "/registry/service/protos/{registryName}/{filename}",
2420
+ path: {
2421
+ "registryName": registryName,
2422
+ "filename": filename
2423
+ },
2424
+ headers: {
2425
+ "Accept": "application/octet-stream"
2426
+ }
2427
+ });
2428
+ }
2429
+ /**
2430
+ * Set proto data
2431
+ * @param registryName The name of the registry
2432
+ * @param filename The name of the proto file
2433
+ * @param data The proto file data
2434
+ * @returns void
2435
+ * @throws ApiError
2436
+ */
2437
+ setProtoData(registryName, filename, data) {
2438
+ return this.httpRequest.request({
2439
+ method: "POST",
2440
+ url: "/registry/service/protos/{registryName}/{filename}",
2441
+ path: {
2442
+ "registryName": registryName,
2443
+ "filename": filename
2444
+ },
2445
+ body: data,
2446
+ mediaType: "application/octet-stream"
2447
+ });
2448
+ }
2449
+ /**
2450
+ * Delete a proto file
2451
+ * @param registryName The name of the registry
2452
+ * @param filename The name of the proto file
2453
+ * @returns void
2454
+ * @throws ApiError
2455
+ */
2456
+ deleteProto(registryName, filename) {
2457
+ return this.httpRequest.request({
2458
+ method: "DELETE",
2459
+ url: "/registry/service/protos/{registryName}/{filename}",
2460
+ path: {
2461
+ "registryName": registryName,
2462
+ "filename": filename
2463
+ }
2464
+ });
2465
+ }
2466
+ /**
2467
+ * Get all proto files for a registry
2468
+ * @param registryName The name of the registry
2469
+ * @returns Array<ProtoRegistryEntry> List of proto registry entries
2470
+ * @throws ApiError
2471
+ */
2472
+ getAllProtos(registryName) {
2473
+ return this.httpRequest.request({
2474
+ method: "GET",
2475
+ url: "/registry/service/protos/{registryName}",
2476
+ path: {
2477
+ "registryName": registryName
2478
+ }
2479
+ });
2480
+ }
2481
+ /**
2482
+ * Discover service methods
2483
+ * @param name The name of the service
2484
+ * @param create Whether to create the discovered methods (defaults to false)
2485
+ * @returns Array<ServiceMethod> The discovered service methods
2486
+ * @throws ApiError
2487
+ */
2488
+ discover(name, create = false) {
2489
+ return this.httpRequest.request({
2490
+ method: "GET",
2491
+ url: "/registry/service/{name}/discover",
2492
+ path: {
2493
+ "name": name
2494
+ },
2495
+ query: {
2496
+ "create": create
2497
+ }
2498
+ });
2499
+ }
2500
+ };
2501
+
2175
2502
  // src/common/open-api/ConductorClient.ts
2176
2503
  var defaultRequestHandler = (request3, config, options) => request3(config, options);
2177
2504
  var getServerBaseURL = (config) => {
@@ -2194,6 +2521,7 @@ var ConductorClient = class {
2194
2521
  tokenResource;
2195
2522
  workflowBulkResource;
2196
2523
  workflowResource;
2524
+ serviceRegistryResource;
2197
2525
  humanTask;
2198
2526
  humanTaskResource;
2199
2527
  request;
@@ -2229,6 +2557,7 @@ var ConductorClient = class {
2229
2557
  this.tokenResource = new TokenResourceService(this.request);
2230
2558
  this.workflowBulkResource = new WorkflowBulkResourceService(this.request);
2231
2559
  this.workflowResource = new WorkflowResourceService(this.request);
2560
+ this.serviceRegistryResource = new ServiceRegistryResourceService(this.request);
2232
2561
  this.humanTask = new HumanTaskService(this.request);
2233
2562
  this.humanTaskResource = new HumanTaskResourceService(this.request);
2234
2563
  }
@@ -2684,19 +3013,18 @@ var WorkflowExecutor = class {
2684
3013
  () => this._client.workflowResource.startWorkflow(workflowRequest)
2685
3014
  );
2686
3015
  }
2687
- /**
2688
- * Execute a workflow synchronously. returns a Promise<WorkflowRun> with details of the running workflow
2689
- * @param workflowRequest
2690
- * @returns
2691
- */
2692
- executeWorkflow(workflowRequest, name, version, requestId, waitUntilTaskRef = "") {
3016
+ // Implementation
3017
+ executeWorkflow(workflowRequest, name, version, requestId, waitUntilTaskRef = "", waitForSeconds, consistency, returnStrategy) {
2693
3018
  return tryCatchReThrow(
2694
3019
  () => this._client.workflowResource.executeWorkflow(
2695
3020
  workflowRequest,
2696
3021
  name,
2697
3022
  version,
2698
3023
  requestId,
2699
- waitUntilTaskRef
3024
+ waitUntilTaskRef,
3025
+ waitForSeconds,
3026
+ consistency,
3027
+ returnStrategy
2700
3028
  )
2701
3029
  );
2702
3030
  }
@@ -2949,6 +3277,60 @@ var WorkflowExecutor = class {
2949
3277
  getTask(taskId) {
2950
3278
  return tryCatchReThrow(() => this._client.taskResource.getTask(taskId));
2951
3279
  }
3280
+ /**
3281
+ * Updates a task by reference name synchronously and returns the complete workflow
3282
+ * @param taskReferenceName
3283
+ * @param workflowInstanceId
3284
+ * @param status
3285
+ * @param taskOutput
3286
+ * @param workerId - Optional
3287
+ * @returns Promise<Workflow>
3288
+ */
3289
+ updateTaskSync(taskReferenceName, workflowInstanceId, status, taskOutput, workerId2) {
3290
+ return tryCatchReThrow(
3291
+ () => this._client.taskResource.updateTaskSync(
3292
+ workflowInstanceId,
3293
+ taskReferenceName,
3294
+ status,
3295
+ taskOutput,
3296
+ workerId2
3297
+ )
3298
+ );
3299
+ }
3300
+ /**
3301
+ * Signals a workflow task and returns data based on the specified return strategy
3302
+ * @param workflowInstanceId - Workflow instance ID to signal
3303
+ * @param status - Task status to set
3304
+ * @param taskOutput - Output data for the task
3305
+ * @param returnStrategy - Optional strategy for what data to return (defaults to TARGET_WORKFLOW)
3306
+ * @returns Promise<SignalResponse> with data based on the return strategy
3307
+ */
3308
+ signal(workflowInstanceId, status, taskOutput, returnStrategy = "TARGET_WORKFLOW" /* TARGET_WORKFLOW */) {
3309
+ return tryCatchReThrow(
3310
+ () => this._client.taskResource.signal(
3311
+ workflowInstanceId,
3312
+ status,
3313
+ taskOutput,
3314
+ returnStrategy
3315
+ )
3316
+ );
3317
+ }
3318
+ /**
3319
+ * Signals a workflow task asynchronously (fire-and-forget)
3320
+ * @param workflowInstanceId - Workflow instance ID to signal
3321
+ * @param status - Task status to set
3322
+ * @param taskOutput - Output data for the task
3323
+ * @returns Promise<void>
3324
+ */
3325
+ signalAsync(workflowInstanceId, status, taskOutput) {
3326
+ return tryCatchReThrow(
3327
+ () => this._client.taskResource.signalAsync(
3328
+ workflowInstanceId,
3329
+ status,
3330
+ taskOutput
3331
+ )
3332
+ );
3333
+ }
2952
3334
  };
2953
3335
 
2954
3336
  // src/core/human.ts
@@ -3249,6 +3631,7 @@ var generateHTTPTask = (overrides = {}) => ({
3249
3631
  method: "GET"
3250
3632
  }
3251
3633
  },
3634
+ asyncComplete: false,
3252
3635
  ...overrides,
3253
3636
  type: "HTTP" /* HTTP */
3254
3637
  });
@@ -3483,12 +3866,13 @@ var forkTaskJoin = (taskReferenceName, forkTasks) => [
3483
3866
  ];
3484
3867
 
3485
3868
  // src/core/sdk/http.ts
3486
- var httpTask = (taskReferenceName, inputParameters) => ({
3869
+ var httpTask = (taskReferenceName, inputParameters, asyncComplete = false) => ({
3487
3870
  name: taskReferenceName,
3488
3871
  taskReferenceName,
3489
3872
  inputParameters: {
3490
3873
  http_request: inputParameters
3491
3874
  },
3875
+ asyncComplete,
3492
3876
  type: "HTTP" /* HTTP */
3493
3877
  });
3494
3878
 
@@ -3920,6 +4304,18 @@ var MetadataClient = class {
3920
4304
  () => this._client.metadataResource.create(workflowDef, overwrite)
3921
4305
  );
3922
4306
  }
4307
+ /**
4308
+ * Unregister (overwrite: true) a workflow definition
4309
+ *
4310
+ * @param workflowDef
4311
+ * @param overwrite
4312
+ * @returns
4313
+ */
4314
+ unregisterWorkflow(workflowName, version = 1) {
4315
+ return tryCatchReThrow(
4316
+ () => this._client.metadataResource.unregisterWorkflowDef(workflowName, version)
4317
+ );
4318
+ }
3923
4319
  };
3924
4320
 
3925
4321
  // src/orkes/BaseOrkesConductorClient.ts
@@ -4241,6 +4637,7 @@ export {
4241
4637
  CancelablePromise,
4242
4638
  ConductorClient,
4243
4639
  ConductorError,
4640
+ Consistency,
4244
4641
  DefaultLogger,
4245
4642
  EventResourceService,
4246
4643
  HealthCheckResourceService,
@@ -4248,6 +4645,7 @@ export {
4248
4645
  MAX_RETRIES,
4249
4646
  MetadataClient,
4250
4647
  MetadataResourceService,
4648
+ ReturnStrategy,
4251
4649
  SchedulerClient,
4252
4650
  SchedulerResourceService,
4253
4651
  TaskClient,