Skip to content

Commit e9175d8

Browse files
authored
Mainly Idempotency Key support (#66)
* fix: imports * feat: added idempotencyKey support * feat: added displayName to HumanTaskEntry
1 parent c05674e commit e9175d8

File tree

7 files changed

+23
-2
lines changed

7 files changed

+23
-2
lines changed

src/common/open-api/models/HumanTaskEntry.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type HumanTaskEntry = {
1111
createdBy?: string;
1212
createdOn?: number;
1313
definitionName?: string;
14+
displayName?: string;
1415
humanTaskDef?: HumanTaskDefinition;
1516
input?: Record<string, any>;
1617
output?: Record<string, any>;

src/common/open-api/models/StartWorkflowRequest.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export type StartWorkflowRequest = {
1212
taskToDomain?: Record<string, string>;
1313
workflowDef?: WorkflowDef;
1414
externalInputPayloadStoragePath?: string;
15+
idempotencyKey?: string;
16+
idempotencyStrategy?: 'FAIL' | 'RETURN_EXISTING';
1517
priority?: number;
1618
createdBy?: string;
1719
};

src/common/open-api/models/SubWorkflowParams.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ export type SubWorkflowParams = {
99
version?: number;
1010
taskToDomain?: Record<string, string>;
1111
workflowDefinition?: WorkflowDef;
12+
idempotencyKey?: string;
13+
idempotencyStrategy?: 'FAIL' | 'RETURN_EXISTING';
1214
};
1315

src/common/open-api/models/Workflow.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export type Workflow = {
1212
createdBy?: string;
1313
updatedBy?: string;
1414
status?: 'RUNNING' | 'COMPLETED' | 'FAILED' | 'TIMED_OUT' | 'TERMINATED' | 'PAUSED';
15+
idempotencyKey?: string;
1516
endTime?: number;
1617
workflowId?: string;
1718
parentWorkflowId?: string;

src/core/__test__/MetadataClient.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect, describe, test, jest } from "@jest/globals";
2-
import { MetadataClient, taskDefinition } from "..";
2+
import { MetadataClient } from "../metadataClient";
3+
import { taskDefinition } from "../sdk";
34
import { orkesConductorClient, OrkesApiConfig } from "../../orkes";
45

56
const playConfig: Partial<OrkesApiConfig> = {

src/core/__test__/executor.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,18 @@ describe("Executor", () => {
9999
expect(workflowStatus.status).toBeTruthy();
100100
expect(workflowStatus.tasks?.length).toBe(1);
101101
});
102+
test("Should execute a workflow with indempotency key", async () => {
103+
const client = await clientPromise;
104+
const executor = new WorkflowExecutor(client);
105+
const idempotencyKey = uuidv4();
106+
const executionId = await executor.startWorkflow({
107+
name: name,
108+
version: version,
109+
idempotencyKey,
110+
idempotencyStrategy: "RETURN_EXISTING",
111+
});
112+
113+
const executionDetails = await executor.getWorkflow(executionId!, true);
114+
expect(executionDetails.idempotencyKey).toEqual(idempotencyKey);
115+
});
102116
});

src/core/taskClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TaskResultStatus } from "../../dist";
1+
import { TaskResultStatus } from "../core/types";
22
import {
33
ConductorClient,
44
SearchResultTask,

0 commit comments

Comments
 (0)