@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.js CHANGED
@@ -28,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // index.ts
31
- var conductor_javascript_exports = {};
32
- __export(conductor_javascript_exports, {
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
33
  ApiError: () => ApiError,
34
34
  AuthConductorClient: () => AuthConductorClient,
35
35
  BaseHttpRequest: () => BaseHttpRequest,
@@ -37,6 +37,7 @@ __export(conductor_javascript_exports, {
37
37
  CancelablePromise: () => CancelablePromise,
38
38
  ConductorClient: () => ConductorClient,
39
39
  ConductorError: () => ConductorError,
40
+ Consistency: () => Consistency,
40
41
  DefaultLogger: () => DefaultLogger,
41
42
  EventResourceService: () => EventResourceService,
42
43
  HealthCheckResourceService: () => HealthCheckResourceService,
@@ -44,6 +45,7 @@ __export(conductor_javascript_exports, {
44
45
  MAX_RETRIES: () => MAX_RETRIES,
45
46
  MetadataClient: () => MetadataClient,
46
47
  MetadataResourceService: () => MetadataResourceService,
48
+ ReturnStrategy: () => ReturnStrategy,
47
49
  SchedulerClient: () => SchedulerClient,
48
50
  SchedulerResourceService: () => SchedulerResourceService,
49
51
  TaskClient: () => TaskClient,
@@ -101,7 +103,7 @@ __export(conductor_javascript_exports, {
101
103
  waitTaskUntil: () => waitTaskUntil,
102
104
  workflow: () => workflow
103
105
  });
104
- module.exports = __toCommonJS(conductor_javascript_exports);
106
+ module.exports = __toCommonJS(index_exports);
105
107
 
106
108
  // src/common/ConductorLogger.ts
107
109
  var LOG_LEVELS = {
@@ -157,6 +159,19 @@ var noopLogger = {
157
159
  };
158
160
 
159
161
  // src/common/types.ts
162
+ var Consistency = /* @__PURE__ */ ((Consistency3) => {
163
+ Consistency3["SYNCHRONOUS"] = "SYNCHRONOUS";
164
+ Consistency3["DURABLE"] = "DURABLE";
165
+ Consistency3["REGION_DURABLE"] = "REGION_DURABLE";
166
+ return Consistency3;
167
+ })(Consistency || {});
168
+ var ReturnStrategy = /* @__PURE__ */ ((ReturnStrategy2) => {
169
+ ReturnStrategy2["TARGET_WORKFLOW"] = "TARGET_WORKFLOW";
170
+ ReturnStrategy2["BLOCKING_WORKFLOW"] = "BLOCKING_WORKFLOW";
171
+ ReturnStrategy2["BLOCKING_TASK"] = "BLOCKING_TASK";
172
+ ReturnStrategy2["BLOCKING_TASK_INPUT"] = "BLOCKING_TASK_INPUT";
173
+ return ReturnStrategy2;
174
+ })(ReturnStrategy || {});
160
175
  var TaskType = /* @__PURE__ */ ((TaskType2) => {
161
176
  TaskType2["START"] = "START";
162
177
  TaskType2["SIMPLE"] = "SIMPLE";
@@ -995,6 +1010,76 @@ var TaskResourceService = class {
995
1010
  }
996
1011
  });
997
1012
  }
1013
+ /**
1014
+ * Update a task By Ref Name synchronously. The output data is merged if data from a previous API call already exists.
1015
+ * @param workflowId
1016
+ * @param taskRefName
1017
+ * @param status
1018
+ * @param output
1019
+ * @param workerId - Optional
1020
+ * @returns Workflow
1021
+ * @throws ApiError
1022
+ */
1023
+ updateTaskSync(workflowId, taskRefName, status, output, workerId2) {
1024
+ return this.httpRequest.request({
1025
+ method: "POST",
1026
+ url: "/tasks/{workflowId}/{taskRefName}/{status}/sync",
1027
+ path: {
1028
+ "workflowId": workflowId,
1029
+ "taskRefName": taskRefName,
1030
+ "status": status
1031
+ },
1032
+ query: {
1033
+ "workerid": workerId2
1034
+ },
1035
+ body: output,
1036
+ mediaType: "application/json"
1037
+ });
1038
+ }
1039
+ /**
1040
+ * Signals a task in a workflow synchronously and returns data based on the specified return strategy
1041
+ * @param workflowId - Workflow ID of the workflow to be signaled
1042
+ * @param status - Signal status to be set for the workflow
1043
+ * @param output - Output for the task
1044
+ * @param returnStrategy - Optional strategy for what data to return (defaults to TARGET_WORKFLOW)
1045
+ * @returns SignalResponse with data based on the return strategy
1046
+ * @throws ApiError
1047
+ */
1048
+ signal(workflowId, status, output, returnStrategy = "TARGET_WORKFLOW" /* TARGET_WORKFLOW */) {
1049
+ return this.httpRequest.request({
1050
+ method: "POST",
1051
+ url: "/tasks/{workflowId}/{status}/signal/sync",
1052
+ path: {
1053
+ "workflowId": workflowId,
1054
+ "status": status
1055
+ },
1056
+ query: {
1057
+ "returnStrategy": returnStrategy
1058
+ },
1059
+ body: output,
1060
+ mediaType: "application/json"
1061
+ });
1062
+ }
1063
+ /**
1064
+ * Signals a task in a workflow asynchronously (fire-and-forget)
1065
+ * @param workflowId - Workflow ID of the workflow to be signaled
1066
+ * @param status - Signal status to be set for the workflow
1067
+ * @param output - Output for the task
1068
+ * @returns Promise<void>
1069
+ * @throws ApiError
1070
+ */
1071
+ signalAsync(workflowId, status, output) {
1072
+ return this.httpRequest.request({
1073
+ method: "POST",
1074
+ url: "/tasks/{workflowId}/{status}/signal",
1075
+ path: {
1076
+ "workflowId": workflowId,
1077
+ "status": status
1078
+ },
1079
+ body: output,
1080
+ mediaType: "application/json"
1081
+ });
1082
+ }
998
1083
  };
999
1084
 
1000
1085
  // src/common/open-api/services/TokenResourceService.ts
@@ -1144,16 +1229,18 @@ var WorkflowResourceService = class {
1144
1229
  }
1145
1230
  /**
1146
1231
  * Execute a workflow synchronously
1147
- * @param body
1148
- * @param name
1149
- * @param version
1150
- * @param requestId
1151
- * @param waitUntilTaskRef
1152
- * @param callback
1153
- * @returns workflowRun
1232
+ * @param body
1233
+ * @param name
1234
+ * @param version
1235
+ * @param requestId
1236
+ * @param waitUntilTaskRef
1237
+ * @param waitForSeconds - Optional, defaults to 10
1238
+ * @param consistency - Optional, defaults to "DURABLE"
1239
+ * @param returnStrategy - Optional, defaults to "TARGET_WORKFLOW"
1240
+ * @returns SignalResponse
1154
1241
  * @throws ApiError
1155
1242
  */
1156
- executeWorkflow(body, name, version, requestId, waitUntilTaskRef) {
1243
+ executeWorkflow(body, name, version, requestId, waitUntilTaskRef, waitForSeconds, consistency, returnStrategy) {
1157
1244
  return this.httpRequest.request({
1158
1245
  method: "POST",
1159
1246
  url: "/workflow/execute/{name}/{version}",
@@ -1163,7 +1250,10 @@ var WorkflowResourceService = class {
1163
1250
  },
1164
1251
  query: {
1165
1252
  "requestId": requestId,
1166
- "waitUntilTaskRef": waitUntilTaskRef
1253
+ "waitUntilTaskRef": waitUntilTaskRef,
1254
+ "waitForSeconds": waitForSeconds,
1255
+ "consistency": consistency,
1256
+ "returnStrategy": returnStrategy
1167
1257
  },
1168
1258
  body,
1169
1259
  mediaType: "application/json"
@@ -2277,6 +2367,245 @@ var HumanTaskResourceService = class {
2277
2367
  }
2278
2368
  };
2279
2369
 
2370
+ // src/common/open-api/services/ServiceRegistryResourceService.ts
2371
+ var ServiceRegistryResourceService = class {
2372
+ constructor(httpRequest) {
2373
+ this.httpRequest = httpRequest;
2374
+ }
2375
+ /**
2376
+ * Retrieve all registered services
2377
+ * @returns Array<ServiceRegistryModels> List of all registered services
2378
+ * @throws ApiError
2379
+ */
2380
+ getRegisteredServices() {
2381
+ return this.httpRequest.request({
2382
+ method: "GET",
2383
+ url: "/registry/service"
2384
+ });
2385
+ }
2386
+ /**
2387
+ * Remove a service by name
2388
+ * @param name The name of the service to remove
2389
+ * @returns void
2390
+ * @throws ApiError
2391
+ */
2392
+ removeService(name) {
2393
+ return this.httpRequest.request({
2394
+ method: "DELETE",
2395
+ url: "/registry/service/{name}",
2396
+ path: {
2397
+ "name": name
2398
+ }
2399
+ });
2400
+ }
2401
+ /**
2402
+ * Get a service by name
2403
+ * @param name The name of the service to retrieve
2404
+ * @returns ServiceRegistryModels The requested service registry
2405
+ * @throws ApiError
2406
+ */
2407
+ getService(name) {
2408
+ return this.httpRequest.request({
2409
+ method: "GET",
2410
+ url: "/registry/service/{name}",
2411
+ path: {
2412
+ "name": name
2413
+ }
2414
+ });
2415
+ }
2416
+ /**
2417
+ * Open the circuit breaker for a service
2418
+ * @param name The name of the service
2419
+ * @returns CircuitBreakerTransitionResponse Response with circuit breaker status
2420
+ * @throws ApiError
2421
+ */
2422
+ openCircuitBreaker(name) {
2423
+ return this.httpRequest.request({
2424
+ method: "POST",
2425
+ url: "/registry/service/{name}/circuit-breaker/open",
2426
+ path: {
2427
+ "name": name
2428
+ }
2429
+ });
2430
+ }
2431
+ /**
2432
+ * Close the circuit breaker for a service
2433
+ * @param name The name of the service
2434
+ * @returns CircuitBreakerTransitionResponse Response with circuit breaker status
2435
+ * @throws ApiError
2436
+ */
2437
+ closeCircuitBreaker(name) {
2438
+ return this.httpRequest.request({
2439
+ method: "POST",
2440
+ url: "/registry/service/{name}/circuit-breaker/close",
2441
+ path: {
2442
+ "name": name
2443
+ }
2444
+ });
2445
+ }
2446
+ /**
2447
+ * Get circuit breaker status for a service
2448
+ * @param name The name of the service
2449
+ * @returns CircuitBreakerTransitionResponse Response with circuit breaker status
2450
+ * @throws ApiError
2451
+ */
2452
+ getCircuitBreakerStatus(name) {
2453
+ return this.httpRequest.request({
2454
+ method: "GET",
2455
+ url: "/registry/service/{name}/circuit-breaker/status",
2456
+ path: {
2457
+ "name": name
2458
+ }
2459
+ });
2460
+ }
2461
+ /**
2462
+ * Add or update a service registry
2463
+ * @param serviceRegistry The service registry to add or update
2464
+ * @returns void
2465
+ * @throws ApiError
2466
+ */
2467
+ addOrUpdateService(serviceRegistry) {
2468
+ return this.httpRequest.request({
2469
+ method: "POST",
2470
+ url: "/registry/service",
2471
+ body: serviceRegistry,
2472
+ mediaType: "application/json"
2473
+ });
2474
+ }
2475
+ /**
2476
+ * Add or update a service method
2477
+ * @param registryName The name of the registry
2478
+ * @param method The service method to add or update
2479
+ * @returns void
2480
+ * @throws ApiError
2481
+ */
2482
+ addOrUpdateServiceMethod(registryName, method) {
2483
+ return this.httpRequest.request({
2484
+ method: "POST",
2485
+ url: "/registry/service/{registryName}/methods",
2486
+ path: {
2487
+ "registryName": registryName
2488
+ },
2489
+ body: method,
2490
+ mediaType: "application/json"
2491
+ });
2492
+ }
2493
+ /**
2494
+ * Remove a service method
2495
+ * @param registryName The name of the registry
2496
+ * @param serviceName The name of the service
2497
+ * @param method The name of the method
2498
+ * @param methodType The type of the method
2499
+ * @returns void
2500
+ * @throws ApiError
2501
+ */
2502
+ removeMethod(registryName, serviceName, method, methodType) {
2503
+ return this.httpRequest.request({
2504
+ method: "DELETE",
2505
+ url: "/registry/service/{registryName}/methods",
2506
+ path: {
2507
+ "registryName": registryName
2508
+ },
2509
+ query: {
2510
+ "serviceName": serviceName,
2511
+ "method": method,
2512
+ "methodType": methodType
2513
+ }
2514
+ });
2515
+ }
2516
+ /**
2517
+ * Get proto data
2518
+ * @param registryName The name of the registry
2519
+ * @param filename The name of the proto file
2520
+ * @returns binary The proto file data
2521
+ * @throws ApiError
2522
+ */
2523
+ getProtoData(registryName, filename) {
2524
+ return this.httpRequest.request({
2525
+ method: "GET",
2526
+ url: "/registry/service/protos/{registryName}/{filename}",
2527
+ path: {
2528
+ "registryName": registryName,
2529
+ "filename": filename
2530
+ },
2531
+ headers: {
2532
+ "Accept": "application/octet-stream"
2533
+ }
2534
+ });
2535
+ }
2536
+ /**
2537
+ * Set proto data
2538
+ * @param registryName The name of the registry
2539
+ * @param filename The name of the proto file
2540
+ * @param data The proto file data
2541
+ * @returns void
2542
+ * @throws ApiError
2543
+ */
2544
+ setProtoData(registryName, filename, data) {
2545
+ return this.httpRequest.request({
2546
+ method: "POST",
2547
+ url: "/registry/service/protos/{registryName}/{filename}",
2548
+ path: {
2549
+ "registryName": registryName,
2550
+ "filename": filename
2551
+ },
2552
+ body: data,
2553
+ mediaType: "application/octet-stream"
2554
+ });
2555
+ }
2556
+ /**
2557
+ * Delete a proto file
2558
+ * @param registryName The name of the registry
2559
+ * @param filename The name of the proto file
2560
+ * @returns void
2561
+ * @throws ApiError
2562
+ */
2563
+ deleteProto(registryName, filename) {
2564
+ return this.httpRequest.request({
2565
+ method: "DELETE",
2566
+ url: "/registry/service/protos/{registryName}/{filename}",
2567
+ path: {
2568
+ "registryName": registryName,
2569
+ "filename": filename
2570
+ }
2571
+ });
2572
+ }
2573
+ /**
2574
+ * Get all proto files for a registry
2575
+ * @param registryName The name of the registry
2576
+ * @returns Array<ProtoRegistryEntry> List of proto registry entries
2577
+ * @throws ApiError
2578
+ */
2579
+ getAllProtos(registryName) {
2580
+ return this.httpRequest.request({
2581
+ method: "GET",
2582
+ url: "/registry/service/protos/{registryName}",
2583
+ path: {
2584
+ "registryName": registryName
2585
+ }
2586
+ });
2587
+ }
2588
+ /**
2589
+ * Discover service methods
2590
+ * @param name The name of the service
2591
+ * @param create Whether to create the discovered methods (defaults to false)
2592
+ * @returns Array<ServiceMethod> The discovered service methods
2593
+ * @throws ApiError
2594
+ */
2595
+ discover(name, create = false) {
2596
+ return this.httpRequest.request({
2597
+ method: "GET",
2598
+ url: "/registry/service/{name}/discover",
2599
+ path: {
2600
+ "name": name
2601
+ },
2602
+ query: {
2603
+ "create": create
2604
+ }
2605
+ });
2606
+ }
2607
+ };
2608
+
2280
2609
  // src/common/open-api/ConductorClient.ts
2281
2610
  var defaultRequestHandler = (request3, config, options) => request3(config, options);
2282
2611
  var getServerBaseURL = (config) => {
@@ -2299,6 +2628,7 @@ var ConductorClient = class {
2299
2628
  tokenResource;
2300
2629
  workflowBulkResource;
2301
2630
  workflowResource;
2631
+ serviceRegistryResource;
2302
2632
  humanTask;
2303
2633
  humanTaskResource;
2304
2634
  request;
@@ -2334,6 +2664,7 @@ var ConductorClient = class {
2334
2664
  this.tokenResource = new TokenResourceService(this.request);
2335
2665
  this.workflowBulkResource = new WorkflowBulkResourceService(this.request);
2336
2666
  this.workflowResource = new WorkflowResourceService(this.request);
2667
+ this.serviceRegistryResource = new ServiceRegistryResourceService(this.request);
2337
2668
  this.humanTask = new HumanTaskService(this.request);
2338
2669
  this.humanTaskResource = new HumanTaskResourceService(this.request);
2339
2670
  }
@@ -2789,19 +3120,18 @@ var WorkflowExecutor = class {
2789
3120
  () => this._client.workflowResource.startWorkflow(workflowRequest)
2790
3121
  );
2791
3122
  }
2792
- /**
2793
- * Execute a workflow synchronously. returns a Promise<WorkflowRun> with details of the running workflow
2794
- * @param workflowRequest
2795
- * @returns
2796
- */
2797
- executeWorkflow(workflowRequest, name, version, requestId, waitUntilTaskRef = "") {
3123
+ // Implementation
3124
+ executeWorkflow(workflowRequest, name, version, requestId, waitUntilTaskRef = "", waitForSeconds, consistency, returnStrategy) {
2798
3125
  return tryCatchReThrow(
2799
3126
  () => this._client.workflowResource.executeWorkflow(
2800
3127
  workflowRequest,
2801
3128
  name,
2802
3129
  version,
2803
3130
  requestId,
2804
- waitUntilTaskRef
3131
+ waitUntilTaskRef,
3132
+ waitForSeconds,
3133
+ consistency,
3134
+ returnStrategy
2805
3135
  )
2806
3136
  );
2807
3137
  }
@@ -3054,6 +3384,60 @@ var WorkflowExecutor = class {
3054
3384
  getTask(taskId) {
3055
3385
  return tryCatchReThrow(() => this._client.taskResource.getTask(taskId));
3056
3386
  }
3387
+ /**
3388
+ * Updates a task by reference name synchronously and returns the complete workflow
3389
+ * @param taskReferenceName
3390
+ * @param workflowInstanceId
3391
+ * @param status
3392
+ * @param taskOutput
3393
+ * @param workerId - Optional
3394
+ * @returns Promise<Workflow>
3395
+ */
3396
+ updateTaskSync(taskReferenceName, workflowInstanceId, status, taskOutput, workerId2) {
3397
+ return tryCatchReThrow(
3398
+ () => this._client.taskResource.updateTaskSync(
3399
+ workflowInstanceId,
3400
+ taskReferenceName,
3401
+ status,
3402
+ taskOutput,
3403
+ workerId2
3404
+ )
3405
+ );
3406
+ }
3407
+ /**
3408
+ * Signals a workflow task and returns data based on the specified return strategy
3409
+ * @param workflowInstanceId - Workflow instance ID to signal
3410
+ * @param status - Task status to set
3411
+ * @param taskOutput - Output data for the task
3412
+ * @param returnStrategy - Optional strategy for what data to return (defaults to TARGET_WORKFLOW)
3413
+ * @returns Promise<SignalResponse> with data based on the return strategy
3414
+ */
3415
+ signal(workflowInstanceId, status, taskOutput, returnStrategy = "TARGET_WORKFLOW" /* TARGET_WORKFLOW */) {
3416
+ return tryCatchReThrow(
3417
+ () => this._client.taskResource.signal(
3418
+ workflowInstanceId,
3419
+ status,
3420
+ taskOutput,
3421
+ returnStrategy
3422
+ )
3423
+ );
3424
+ }
3425
+ /**
3426
+ * Signals a workflow task asynchronously (fire-and-forget)
3427
+ * @param workflowInstanceId - Workflow instance ID to signal
3428
+ * @param status - Task status to set
3429
+ * @param taskOutput - Output data for the task
3430
+ * @returns Promise<void>
3431
+ */
3432
+ signalAsync(workflowInstanceId, status, taskOutput) {
3433
+ return tryCatchReThrow(
3434
+ () => this._client.taskResource.signalAsync(
3435
+ workflowInstanceId,
3436
+ status,
3437
+ taskOutput
3438
+ )
3439
+ );
3440
+ }
3057
3441
  };
3058
3442
 
3059
3443
  // src/core/human.ts
@@ -3354,6 +3738,7 @@ var generateHTTPTask = (overrides = {}) => ({
3354
3738
  method: "GET"
3355
3739
  }
3356
3740
  },
3741
+ asyncComplete: false,
3357
3742
  ...overrides,
3358
3743
  type: "HTTP" /* HTTP */
3359
3744
  });
@@ -3588,12 +3973,13 @@ var forkTaskJoin = (taskReferenceName, forkTasks) => [
3588
3973
  ];
3589
3974
 
3590
3975
  // src/core/sdk/http.ts
3591
- var httpTask = (taskReferenceName, inputParameters) => ({
3976
+ var httpTask = (taskReferenceName, inputParameters, asyncComplete = false) => ({
3592
3977
  name: taskReferenceName,
3593
3978
  taskReferenceName,
3594
3979
  inputParameters: {
3595
3980
  http_request: inputParameters
3596
3981
  },
3982
+ asyncComplete,
3597
3983
  type: "HTTP" /* HTTP */
3598
3984
  });
3599
3985
 
@@ -4025,6 +4411,18 @@ var MetadataClient = class {
4025
4411
  () => this._client.metadataResource.create(workflowDef, overwrite)
4026
4412
  );
4027
4413
  }
4414
+ /**
4415
+ * Unregister (overwrite: true) a workflow definition
4416
+ *
4417
+ * @param workflowDef
4418
+ * @param overwrite
4419
+ * @returns
4420
+ */
4421
+ unregisterWorkflow(workflowName, version = 1) {
4422
+ return tryCatchReThrow(
4423
+ () => this._client.metadataResource.unregisterWorkflowDef(workflowName, version)
4424
+ );
4425
+ }
4028
4426
  };
4029
4427
 
4030
4428
  // src/orkes/BaseOrkesConductorClient.ts
@@ -4347,6 +4745,7 @@ var request2 = (config, options, fetchFn = fetch) => {
4347
4745
  CancelablePromise,
4348
4746
  ConductorClient,
4349
4747
  ConductorError,
4748
+ Consistency,
4350
4749
  DefaultLogger,
4351
4750
  EventResourceService,
4352
4751
  HealthCheckResourceService,
@@ -4354,6 +4753,7 @@ var request2 = (config, options, fetchFn = fetch) => {
4354
4753
  MAX_RETRIES,
4355
4754
  MetadataClient,
4356
4755
  MetadataResourceService,
4756
+ ReturnStrategy,
4357
4757
  SchedulerClient,
4358
4758
  SchedulerResourceService,
4359
4759
  TaskClient,