From f15a2470609a607a736c71cae73e7354945e15e1 Mon Sep 17 00:00:00 2001 From: Whit Waldo Date: Thu, 13 Mar 2025 11:23:40 -0500 Subject: [PATCH 1/2] Renamed the workflow methods so they're equivalent to the method names used in the .NET SDK (absent the `Async` verbiage as that's not typical of JavaScript convention. Signed-off-by: Whit Waldo --- src/implementation/Client/GRPCClient/workflow.ts | 14 +++++++------- src/implementation/Client/HTTPClient/workflow.ts | 14 +++++++------- src/interfaces/Client/IClientWorkflow.ts | 14 +++++++------- test/unit/protocols/http/workflow.test.ts | 8 ++++---- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/implementation/Client/GRPCClient/workflow.ts b/src/implementation/Client/GRPCClient/workflow.ts index ba7b6b21..e9009bd1 100644 --- a/src/implementation/Client/GRPCClient/workflow.ts +++ b/src/implementation/Client/GRPCClient/workflow.ts @@ -23,11 +23,11 @@ export default class GRPCClientWorkflow implements IClientWorkflow { this.client = client; } - get(_instanceId: string, _workflowComponent?: string | undefined): Promise { + getWorkflowState(_instanceId: string, _workflowComponent?: string | undefined): Promise { throw new GRPCNotSupportedError(); } - start( + scheduleNewWorkflow( _workflowName: string, _input?: any, _instanceId?: string | undefined, @@ -36,23 +36,23 @@ export default class GRPCClientWorkflow implements IClientWorkflow { throw new GRPCNotSupportedError(); } - terminate(_instanceId: string, _workflowComponent?: string | undefined): Promise { + terminateWorkflow(_instanceId: string, _workflowComponent?: string | undefined): Promise { throw new GRPCNotSupportedError(); } - pause(_instanceId: string, _workflowComponent?: string | undefined): Promise { + suspendWorkflow(_instanceId: string, _workflowComponent?: string | undefined): Promise { throw new GRPCNotSupportedError(); } - resume(_instanceId: string, _workflowComponent?: string | undefined): Promise { + resumeWorkflow(_instanceId: string, _workflowComponent?: string | undefined): Promise { throw new GRPCNotSupportedError(); } - purge(_instanceId: string, _workflowComponent?: string | undefined): Promise { + purgeInstance(_instanceId: string, _workflowComponent?: string | undefined): Promise { throw new GRPCNotSupportedError(); } - raise(_instanceId: string, _eventName: string, _input?: any, _workflowComponent?: string | undefined): Promise { + raiseEvent(_instanceId: string, _eventName: string, _input?: any, _workflowComponent?: string | undefined): Promise { throw new GRPCNotSupportedError(); } } diff --git a/src/implementation/Client/HTTPClient/workflow.ts b/src/implementation/Client/HTTPClient/workflow.ts index eb6dc906..905bcbdb 100644 --- a/src/implementation/Client/HTTPClient/workflow.ts +++ b/src/implementation/Client/HTTPClient/workflow.ts @@ -33,7 +33,7 @@ export default class HTTPClientWorkflow implements IClientWorkflow { this.logger = new Logger("HTTPClient", "Workflow", client.options.logger); } - async get(instanceID: string, workflowComponent?: string): Promise { + async getWorkflowState(instanceID: string, workflowComponent?: string): Promise { if (!instanceID) { throw new PropertyRequiredError("instanceID"); } @@ -69,7 +69,7 @@ export default class HTTPClientWorkflow implements IClientWorkflow { } } - async start( + async scheduleNewWorkflow( workflowName: string, input?: any, instanceId?: string | undefined, @@ -113,7 +113,7 @@ export default class HTTPClientWorkflow implements IClientWorkflow { } } - async raise( + async raiseEvent( instanceId: string, eventName: string, eventData?: any, @@ -153,19 +153,19 @@ export default class HTTPClientWorkflow implements IClientWorkflow { } } - async terminate(instanceId: string, workflowComponent?: string | undefined): Promise { + async terminateWorkflow(instanceId: string, workflowComponent?: string | undefined): Promise { await this._invokeMethod(instanceId, "terminate", workflowComponent); } - async pause(instanceId: string, workflowComponent?: string | undefined): Promise { + async suspendWorkflow(instanceId: string, workflowComponent?: string | undefined): Promise { await this._invokeMethod(instanceId, "pause", workflowComponent); } - async resume(instanceId: string, workflowComponent?: string | undefined): Promise { + async resumeWorkflow(instanceId: string, workflowComponent?: string | undefined): Promise { await this._invokeMethod(instanceId, "resume", workflowComponent); } - async purge(instanceId: string, workflowComponent?: string | undefined): Promise { + async purgeInstance(instanceId: string, workflowComponent?: string | undefined): Promise { await this._invokeMethod(instanceId, "purge", workflowComponent); } diff --git a/src/interfaces/Client/IClientWorkflow.ts b/src/interfaces/Client/IClientWorkflow.ts index 9378c3a7..62149e2b 100644 --- a/src/interfaces/Client/IClientWorkflow.ts +++ b/src/interfaces/Client/IClientWorkflow.ts @@ -19,7 +19,7 @@ export default interface IClientWorkflow { * @param instanceId The unique identifier for the workflow instance. * @param workflowComponent The name of the workflow component to interface with, if not provided the default "dapr" will be used. */ - get(instanceId: string, workflowComponent?: string): Promise; + getWorkflowState(instanceId: string, workflowComponent?: string): Promise; /** * Starts a new workflow instance. @@ -28,35 +28,35 @@ export default interface IClientWorkflow { * @param instanceId The unique identifier for the workflow instance, if not provided one will be generated. * @param workflowComponent The name of the workflow component to interface with, if not provided the default "dapr" will be used. */ - start(workflowName: string, input?: any, instanceId?: string, workflowComponent?: string): Promise; + scheduleNewWorkflow(workflowName: string, input?: any, instanceId?: string, workflowComponent?: string): Promise; /** * Terminates a workflow instance. * @param instanceId The unique identifier for the workflow instance. * @param workflowComponent The name of the workflow component to interface with, if not provided the default "dapr" will be used. */ - terminate(instanceId: string, workflowComponent?: string): Promise; + terminateWorkflow(instanceId: string, workflowComponent?: string): Promise; /** * Pauses a workflow instance. * @param instanceId The unique identifier for the workflow instance. * @param workflowComponent The name of the workflow component to interface with, if not provided the default "dapr" will be used. */ - pause(instanceId: string, workflowComponent?: string): Promise; + suspendWorkflow(instanceId: string, workflowComponent?: string): Promise; /** * Resumes a workflow instance. * @param instanceId The unique identifier for the workflow instance. * @param workflowComponent The name of the workflow component to interface with, if not provided the default "dapr" will be used. */ - resume(instanceId: string, workflowComponent?: string): Promise; + resumeWorkflow(instanceId: string, workflowComponent?: string): Promise; /** * Purge a workflow instance. * @param instanceId The unique identifier for the workflow instance. * @param workflowComponent The name of the workflow component to interface with, if not provided the default "dapr" will be used. */ - purge(instanceId: string, workflowComponent?: string): Promise; + purgeInstance(instanceId: string, workflowComponent?: string): Promise; /** * Raise an event to a workflow instance. @@ -65,5 +65,5 @@ export default interface IClientWorkflow { * @param eventData The data associated with the event, should be JSON serializable. * @param workflowComponent The name of the workflow component to interface with, if not provided the default "dapr" will be used. */ - raise(instanceId: string, eventName: string, eventData?: any, workflowComponent?: string): Promise; + raiseEvent(instanceId: string, eventName: string, eventData?: any, workflowComponent?: string): Promise; } diff --git a/test/unit/protocols/http/workflow.test.ts b/test/unit/protocols/http/workflow.test.ts index 8d26c6d7..c9dd573b 100644 --- a/test/unit/protocols/http/workflow.test.ts +++ b/test/unit/protocols/http/workflow.test.ts @@ -25,10 +25,10 @@ describe("workflow", () => { const workflow = new HTTPClientWorkflow(client); it("should throw PropertyRequiredError when instanceID variable is not provided in get method", async () => { - await expect(workflow.get("")).rejects.toThrow(PropertyRequiredError); + await expect(workflow.getWorkflowState("")).rejects.toThrow(PropertyRequiredError); }); it("should throw PropertyRequiredError when workflowName variable is not provided in start method", async () => { - await expect(workflow.start("")).rejects.toThrow(PropertyRequiredError); + await expect(workflow.scheduleNewWorkflow("")).rejects.toThrow(PropertyRequiredError); }); it("should throw PropertyRequiredError when instanceID variable is not provided in _invokeMethod method", async () => { await expect(workflow._invokeMethod("", "raise")).rejects.toThrow(PropertyRequiredError); @@ -37,9 +37,9 @@ describe("workflow", () => { await expect(workflow._invokeMethod(randomUUID(), "")).rejects.toThrow(PropertyRequiredError); }); it("should throw PropertyRequiredError when instanceID variable is not provided in raise method", async () => { - await expect(workflow.raise("", "Event")).rejects.toThrow(PropertyRequiredError); + await expect(workflow.raiseEvent("", "Event")).rejects.toThrow(PropertyRequiredError); }); it("should throw PropertyRequiredError when eventName variable is not provided in raise method", async () => { - await expect(workflow.raise(randomUUID(), "")).rejects.toThrow(PropertyRequiredError); + await expect(workflow.raiseEvent(randomUUID(), "")).rejects.toThrow(PropertyRequiredError); }); }); From f33358a62839b8b8962af01db48a0a8eb89debd8 Mon Sep 17 00:00:00 2001 From: Whit Waldo Date: Thu, 18 Sep 2025 11:53:10 -0500 Subject: [PATCH 2/2] Standardized naming convention to other SDKs Signed-off-by: Whit Waldo --- src/implementation/Client/GRPCClient/workflow.ts | 2 +- src/implementation/Client/HTTPClient/workflow.ts | 6 +++--- src/interfaces/Client/IClientWorkflow.ts | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/implementation/Client/GRPCClient/workflow.ts b/src/implementation/Client/GRPCClient/workflow.ts index d6f291d9..43d24324 100644 --- a/src/implementation/Client/GRPCClient/workflow.ts +++ b/src/implementation/Client/GRPCClient/workflow.ts @@ -51,7 +51,7 @@ export default class GRPCClientWorkflow implements IClientWorkflow { throw new GRPCNotSupportedError(); } - raise(_instanceId: string, _eventName: string, _input?: any): Promise { + raiseEvent(_instanceId: string, _eventName: string, _input?: any): Promise { throw new GRPCNotSupportedError(); } } diff --git a/src/implementation/Client/HTTPClient/workflow.ts b/src/implementation/Client/HTTPClient/workflow.ts index c2d9b9ba..428f976e 100644 --- a/src/implementation/Client/HTTPClient/workflow.ts +++ b/src/implementation/Client/HTTPClient/workflow.ts @@ -31,7 +31,7 @@ export default class HTTPClientWorkflow implements IClientWorkflow { this.logger = new Logger("HTTPClient", "Workflow", client.options.logger); } - async get(instanceID: string): Promise { + async getWorkflowState(instanceID: string): Promise { if (!instanceID) { throw new PropertyRequiredError("instanceID"); } @@ -81,7 +81,7 @@ export default class HTTPClientWorkflow implements IClientWorkflow { const queryParams = createHTTPQueryParam({ data: { instanceID: instanceId } }); - // Set content type if provided. + // Set content-type if provided. // If not, HTTPClient will infer it from the data. const headers: KeyValueType = {}; if (options.contentType) { @@ -120,7 +120,7 @@ export default class HTTPClientWorkflow implements IClientWorkflow { throw new PropertyRequiredError("eventName"); } - // Set content type if provided. + // Set content-type if provided. // If not, HTTPClient will infer it from the data. const headers: KeyValueType = {}; if (options.eventContentType) { diff --git a/src/interfaces/Client/IClientWorkflow.ts b/src/interfaces/Client/IClientWorkflow.ts index 3b33b907..5027e7cb 100644 --- a/src/interfaces/Client/IClientWorkflow.ts +++ b/src/interfaces/Client/IClientWorkflow.ts @@ -19,7 +19,7 @@ export default interface IClientWorkflow { * @param instanceId The unique identifier for the workflow instance. */ - get(instanceId: string): Promise; + getWorkflowState(instanceId: string): Promise; /** * Starts a new workflow instance. @@ -27,7 +27,7 @@ export default interface IClientWorkflow { * @param input The input to pass to the workflow, should be JSON serializable. * @param instanceId The unique identifier for the workflow instance, if not provided one will be generated. */ - start(workflowName: string, input?: any, instanceId?: string): Promise; + scheduleNewWorkflow(workflowName: string, input?: any, instanceId?: string): Promise; /** * Terminates a workflow instance. @@ -59,5 +59,5 @@ export default interface IClientWorkflow { * @param eventName The name of the event to raise. * @param eventData The data associated with the event, should be JSON serializable. */ - raise(instanceId: string, eventName: string, eventData?: any): Promise; + raiseEvent(instanceId: string, eventName: string, eventData?: any): Promise; }