Skip to content

Commit

Permalink
Mainly Idempotency Key support (#66)
Browse files Browse the repository at this point in the history
* fix: imports

* feat: added idempotencyKey support

* feat: added displayName to HumanTaskEntry
  • Loading branch information
Sudakatux authored Jun 26, 2024
1 parent c05674e commit e9175d8
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/common/open-api/models/HumanTaskEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type HumanTaskEntry = {
createdBy?: string;
createdOn?: number;
definitionName?: string;
displayName?: string;
humanTaskDef?: HumanTaskDefinition;
input?: Record<string, any>;
output?: Record<string, any>;
Expand Down
2 changes: 2 additions & 0 deletions src/common/open-api/models/StartWorkflowRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export type StartWorkflowRequest = {
taskToDomain?: Record<string, string>;
workflowDef?: WorkflowDef;
externalInputPayloadStoragePath?: string;
idempotencyKey?: string;
idempotencyStrategy?: 'FAIL' | 'RETURN_EXISTING';
priority?: number;
createdBy?: string;
};
Expand Down
2 changes: 2 additions & 0 deletions src/common/open-api/models/SubWorkflowParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ export type SubWorkflowParams = {
version?: number;
taskToDomain?: Record<string, string>;
workflowDefinition?: WorkflowDef;
idempotencyKey?: string;
idempotencyStrategy?: 'FAIL' | 'RETURN_EXISTING';
};

1 change: 1 addition & 0 deletions src/common/open-api/models/Workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type Workflow = {
createdBy?: string;
updatedBy?: string;
status?: 'RUNNING' | 'COMPLETED' | 'FAILED' | 'TIMED_OUT' | 'TERMINATED' | 'PAUSED';
idempotencyKey?: string;
endTime?: number;
workflowId?: string;
parentWorkflowId?: string;
Expand Down
3 changes: 2 additions & 1 deletion src/core/__test__/MetadataClient.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect, describe, test, jest } from "@jest/globals";
import { MetadataClient, taskDefinition } from "..";
import { MetadataClient } from "../metadataClient";
import { taskDefinition } from "../sdk";
import { orkesConductorClient, OrkesApiConfig } from "../../orkes";

const playConfig: Partial<OrkesApiConfig> = {
Expand Down
14 changes: 14 additions & 0 deletions src/core/__test__/executor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,18 @@ describe("Executor", () => {
expect(workflowStatus.status).toBeTruthy();
expect(workflowStatus.tasks?.length).toBe(1);
});
test("Should execute a workflow with indempotency key", async () => {
const client = await clientPromise;
const executor = new WorkflowExecutor(client);
const idempotencyKey = uuidv4();
const executionId = await executor.startWorkflow({
name: name,
version: version,
idempotencyKey,
idempotencyStrategy: "RETURN_EXISTING",
});

const executionDetails = await executor.getWorkflow(executionId!, true);
expect(executionDetails.idempotencyKey).toEqual(idempotencyKey);
});
});
2 changes: 1 addition & 1 deletion src/core/taskClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TaskResultStatus } from "../../dist";
import { TaskResultStatus } from "../core/types";
import {
ConductorClient,
SearchResultTask,
Expand Down

0 comments on commit e9175d8

Please sign in to comment.