diff --git a/examples/workflow/authoring/package-lock.json b/examples/workflow/authoring/package-lock.json index ced6d63c..8697ab52 100644 --- a/examples/workflow/authoring/package-lock.json +++ b/examples/workflow/authoring/package-lock.json @@ -25,7 +25,7 @@ "dependencies": { "@grpc/grpc-js": "^1.9.3", "@js-temporal/polyfill": "^0.3.0", - "@microsoft/durabletask-js": "^0.1.0-alpha.2", + "@dapr/durabletask-js": "^0.1.0-alpha.2", "@types/google-protobuf": "^3.15.5", "@types/node-fetch": "^2.6.2", "body-parser": "^1.19.0", @@ -310,7 +310,7 @@ "requires": { "@grpc/grpc-js": "^1.9.3", "@js-temporal/polyfill": "^0.3.0", - "@microsoft/durabletask-js": "^0.1.0-alpha.2", + "@dapr/durabletask-js": "^0.1.0-alpha.2", "@types/body-parser": "^1.19.1", "@types/express": "^4.17.15", "@types/google-protobuf": "^3.15.5", diff --git a/examples/workflow/management/package-lock.json b/examples/workflow/management/package-lock.json index 1c981ceb..df991edf 100644 --- a/examples/workflow/management/package-lock.json +++ b/examples/workflow/management/package-lock.json @@ -24,7 +24,7 @@ "dependencies": { "@grpc/grpc-js": "^1.9.3", "@js-temporal/polyfill": "^0.3.0", - "@microsoft/durabletask-js": "^0.1.0-alpha.2", + "@dapr/durabletask-js": "^0.1.0-alpha.2", "@types/google-protobuf": "^3.15.5", "@types/node-fetch": "^2.6.2", "body-parser": "^1.19.0", @@ -302,7 +302,7 @@ "requires": { "@grpc/grpc-js": "^1.9.3", "@js-temporal/polyfill": "^0.3.0", - "@microsoft/durabletask-js": "^0.1.0-alpha.2", + "@dapr/durabletask-js": "^0.1.0-alpha.2", "@swc/core": "^1.3.55", "@types/body-parser": "^1.19.1", "@types/express": "^4.17.15", diff --git a/package-lock.json b/package-lock.json index 03732590..9cb47fc9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,9 +9,9 @@ "version": "3.4.0", "license": "ISC", "dependencies": { + "@dapr/durabletask-js": "0.1.0-alpha.2", "@grpc/grpc-js": "^1.9.3", "@js-temporal/polyfill": "^0.3.0", - "@microsoft/durabletask-js": "^0.1.0-alpha.2", "@types/google-protobuf": "^3.15.5", "@types/node-fetch": "^2.6.2", "body-parser": "^1.19.0", @@ -730,6 +730,15 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "node_modules/@dapr/durabletask-js": { + "version": "0.1.0-alpha.2", + "resolved": "https://registry.npmjs.org/@dapr/durabletask-js/-/durabletask-js-0.1.0-alpha.2.tgz", + "integrity": "sha512-ZPtRf9S5SVf3fRKMGNSwPwVT8s5JjEPrxaGkw0i0JPWKN9JXFHvAX/M9kWULhSGZCSPhvAgusMT0lAKUgRlpkg==", + "dependencies": { + "@grpc/grpc-js": "^1.8.14", + "google-protobuf": "^3.21.2" + } + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -1261,15 +1270,6 @@ "node": ">=12" } }, - "node_modules/@microsoft/durabletask-js": { - "version": "0.1.0-alpha.2", - "resolved": "https://registry.npmjs.org/@microsoft/durabletask-js/-/durabletask-js-0.1.0-alpha.2.tgz", - "integrity": "sha512-EiUgOyT05JQ9/M/InjTKdXs5Y1XxdXRczb6nizceJglXr8S/myxMnQHDV1QRASxroFCoTyKiDHU6uAq4Cpe/LQ==", - "dependencies": { - "@grpc/grpc-js": "^1.8.14", - "google-protobuf": "^3.21.2" - } - }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -8046,6 +8046,15 @@ } } }, + "@dapr/durabletask-js": { + "version": "0.1.0-alpha.2", + "resolved": "https://registry.npmjs.org/@dapr/durabletask-js/-/durabletask-js-0.1.0-alpha.2.tgz", + "integrity": "sha512-ZPtRf9S5SVf3fRKMGNSwPwVT8s5JjEPrxaGkw0i0JPWKN9JXFHvAX/M9kWULhSGZCSPhvAgusMT0lAKUgRlpkg==", + "requires": { + "@grpc/grpc-js": "^1.8.14", + "google-protobuf": "^3.21.2" + } + }, "@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -8454,15 +8463,6 @@ "tslib": "^2.3.1" } }, - "@microsoft/durabletask-js": { - "version": "0.1.0-alpha.2", - "resolved": "https://registry.npmjs.org/@microsoft/durabletask-js/-/durabletask-js-0.1.0-alpha.2.tgz", - "integrity": "sha512-EiUgOyT05JQ9/M/InjTKdXs5Y1XxdXRczb6nizceJglXr8S/myxMnQHDV1QRASxroFCoTyKiDHU6uAq4Cpe/LQ==", - "requires": { - "@grpc/grpc-js": "^1.8.14", - "google-protobuf": "^3.21.2" - } - }, "@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", diff --git a/package.json b/package.json index d5d5f8f1..a91e972e 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "dependencies": { "@grpc/grpc-js": "^1.9.3", "@js-temporal/polyfill": "^0.3.0", - "@microsoft/durabletask-js": "^0.1.0-alpha.2", + "@dapr/durabletask-js": "0.1.0-alpha.2", "@types/google-protobuf": "^3.15.5", "@types/node-fetch": "^2.6.2", "body-parser": "^1.19.0", diff --git a/src/index.ts b/src/index.ts index 8a0a929d..2fc96d85 100644 --- a/src/index.ts +++ b/src/index.ts @@ -45,7 +45,7 @@ import WorkflowActivityContext from "./workflow/runtime/WorkflowActivityContext" import WorkflowContext from "./workflow/runtime/WorkflowContext"; import WorkflowRuntime from "./workflow/runtime/WorkflowRuntime"; import { TWorkflow } from "./types/workflow/Workflow.type"; -import { Task } from "@microsoft/durabletask-js/task/task"; +import { Task } from "@dapr/durabletask-js/task/task"; import { WorkflowFailureDetails } from "./workflow/client/WorkflowFailureDetails"; import { WorkflowState } from "./workflow/client/WorkflowState"; import { diff --git a/src/types/workflow/Workflow.type.ts b/src/types/workflow/Workflow.type.ts index 36d2bbc2..650389aa 100644 --- a/src/types/workflow/Workflow.type.ts +++ b/src/types/workflow/Workflow.type.ts @@ -12,7 +12,7 @@ limitations under the License. */ import WorkflowContext from "../../workflow/runtime/WorkflowContext"; -import { Task } from "@microsoft/durabletask-js/task/task"; +import { Task } from "@dapr/durabletask-js/task/task"; import { TOutput } from "./InputOutput.type"; /** diff --git a/src/workflow/client/DaprWorkflowClient.ts b/src/workflow/client/DaprWorkflowClient.ts index 7bf880e8..65196701 100644 --- a/src/workflow/client/DaprWorkflowClient.ts +++ b/src/workflow/client/DaprWorkflowClient.ts @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { TaskHubGrpcClient } from "@microsoft/durabletask-js"; +import { TaskHubGrpcClient } from "@dapr/durabletask-js"; import { WorkflowState } from "./WorkflowState"; import { generateApiTokenClientInterceptors, generateEndpoint, getDaprApiToken } from "../internal/index"; import { TWorkflow } from "../../types/workflow/Workflow.type"; diff --git a/src/workflow/client/WorkflowFailureDetails.ts b/src/workflow/client/WorkflowFailureDetails.ts index 240fbc2a..d68d732c 100644 --- a/src/workflow/client/WorkflowFailureDetails.ts +++ b/src/workflow/client/WorkflowFailureDetails.ts @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { FailureDetails } from "@microsoft/durabletask-js/task/failure-details"; +import { FailureDetails } from "@dapr/durabletask-js/task/failure-details"; /** * Class that represents the details of a task failure. diff --git a/src/workflow/client/WorkflowState.ts b/src/workflow/client/WorkflowState.ts index a5cbfd03..7f737d2c 100644 --- a/src/workflow/client/WorkflowState.ts +++ b/src/workflow/client/WorkflowState.ts @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { OrchestrationState } from "@microsoft/durabletask-js/orchestration/orchestration-state"; +import { OrchestrationState } from "@dapr/durabletask-js/orchestration/orchestration-state"; import { WorkflowFailureDetails } from "./WorkflowFailureDetails"; import { WorkflowRuntimeStatus, fromOrchestrationStatus } from "../runtime/WorkflowRuntimeStatus"; @@ -105,4 +105,12 @@ export class WorkflowState { public get workflowFailureDetails(): WorkflowFailureDetails | undefined { return this._workflowFailureDetails; } + + /** + * Gets the workflow instance's custom status, if any, as a string value. + * @returns {string | undefined} The workflow instance's custom status or undefined. + */ + public get customStatus(): string | undefined { + return this._orchestrationState.serializedCustomStatus; + } } diff --git a/src/workflow/runtime/WorkflowActivityContext.ts b/src/workflow/runtime/WorkflowActivityContext.ts index cf29962d..f6749bd6 100644 --- a/src/workflow/runtime/WorkflowActivityContext.ts +++ b/src/workflow/runtime/WorkflowActivityContext.ts @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { ActivityContext } from "@microsoft/durabletask-js"; +import { ActivityContext } from "@dapr/durabletask-js"; /** * Used by activity to perform actions such as getting activity's name and diff --git a/src/workflow/runtime/WorkflowContext.ts b/src/workflow/runtime/WorkflowContext.ts index 908f8ef9..90e848f8 100644 --- a/src/workflow/runtime/WorkflowContext.ts +++ b/src/workflow/runtime/WorkflowContext.ts @@ -11,14 +11,14 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { OrchestrationContext } from "@microsoft/durabletask-js"; -import { Task } from "@microsoft/durabletask-js/task/task"; +import { OrchestrationContext } from "@dapr/durabletask-js"; +import { Task } from "@dapr/durabletask-js/task/task"; import { TWorkflowActivity } from "../../types/workflow/Activity.type"; import { TWorkflow } from "../../types/workflow/Workflow.type"; import { getFunctionName } from "../internal"; -import { WhenAllTask } from "@microsoft/durabletask-js/task/when-all-task"; -import { whenAll, whenAny } from "@microsoft/durabletask-js/task"; -import { WhenAnyTask } from "@microsoft/durabletask-js/task/when-any-task"; +import { WhenAllTask } from "@dapr/durabletask-js/task/when-all-task"; +import { whenAll, whenAny } from "@dapr/durabletask-js/task"; +import { WhenAnyTask } from "@dapr/durabletask-js/task/when-any-task"; import { TInput, TOutput } from "../../types/workflow/InputOutput.type"; /** @@ -156,6 +156,15 @@ export default class WorkflowContext { this._innerContext.continueAsNew(newInput, saveEvents); } + /** + * Sets the custom status + * + * @param status {string} The new custom status + */ + public setCustomStatus(status: string): void { + this._innerContext.setCustomStatus(status); + } + /** * Returns a task that completes when all of the provided tasks complete or when one of the tasks fail * diff --git a/src/workflow/runtime/WorkflowRuntime.ts b/src/workflow/runtime/WorkflowRuntime.ts index 83c6aa9a..2675f0a2 100644 --- a/src/workflow/runtime/WorkflowRuntime.ts +++ b/src/workflow/runtime/WorkflowRuntime.ts @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { ActivityContext, OrchestrationContext, TaskHubGrpcWorker } from "@microsoft/durabletask-js"; +import { ActivityContext, OrchestrationContext, TaskHubGrpcWorker } from "@dapr/durabletask-js"; import { TWorkflow } from "../../types/workflow/Workflow.type"; import { TWorkflowActivity } from "../../types/workflow/Activity.type"; import { TInput, TOutput } from "../../types/workflow/InputOutput.type"; diff --git a/src/workflow/runtime/WorkflowRuntimeStatus.ts b/src/workflow/runtime/WorkflowRuntimeStatus.ts index df355f9c..ad7da6ad 100644 --- a/src/workflow/runtime/WorkflowRuntimeStatus.ts +++ b/src/workflow/runtime/WorkflowRuntimeStatus.ts @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { OrchestrationStatus } from "@microsoft/durabletask-js/orchestration/enum/orchestration-status.enum"; +import { OrchestrationStatus } from "@dapr/durabletask-js/orchestration/enum/orchestration-status.enum"; /** * Enum describing the runtime status of a workflow. diff --git a/test/e2e/workflow/workflow.test.ts b/test/e2e/workflow/workflow.test.ts index 5657c3a4..d8c95f4c 100644 --- a/test/e2e/workflow/workflow.test.ts +++ b/test/e2e/workflow/workflow.test.ts @@ -18,7 +18,7 @@ import { TWorkflow } from "../../../src/types/workflow/Workflow.type"; import { getFunctionName } from "../../../src/workflow/internal"; import { WorkflowRuntimeStatus } from "../../../src/workflow/runtime/WorkflowRuntimeStatus"; import WorkflowActivityContext from "../../../src/workflow/runtime/WorkflowActivityContext"; -import { Task } from "@microsoft/durabletask-js/task/task"; +import { Task } from "@dapr/durabletask-js/task/task"; const clientHost = "localhost"; const clientPort = "4001"; @@ -76,7 +76,7 @@ describe("Workflow", () => { current = yield ctx.callActivity(plusOne, current); numbers.push(current); } - + ctx.setCustomStatus("foo"); return numbers; }; @@ -93,6 +93,7 @@ describe("Workflow", () => { expect(state?.runtimeStatus).toEqual(WorkflowRuntimeStatus.COMPLETED); expect(state?.serializedInput).toEqual(JSON.stringify(1)); expect(state?.serializedOutput).toEqual(JSON.stringify([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])); + expect(state?.customStatus).toEqual("foo"); }, 31000); it("should be able to run fan-out/fan-in", async () => { diff --git a/test/unit/workflow/workflowRuntimeStatus.test.ts b/test/unit/workflow/workflowRuntimeStatus.test.ts index c813852b..08e34a9c 100644 --- a/test/unit/workflow/workflowRuntimeStatus.test.ts +++ b/test/unit/workflow/workflowRuntimeStatus.test.ts @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { OrchestrationStatus } from "@microsoft/durabletask-js/orchestration/enum/orchestration-status.enum"; +import { OrchestrationStatus } from "@dapr/durabletask-js/orchestration/enum/orchestration-status.enum"; import { WorkflowRuntimeStatus, fromOrchestrationStatus,