Skip to content

Commit

Permalink
Add test workflow feature to JS SDK - https://orkes.io/content/develo…
Browse files Browse the repository at this point in the history
  • Loading branch information
jmigueprieto committed Nov 12, 2024
1 parent 0c07a54 commit b8307a3
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/common/open-api/models/TaskMock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type TaskMock = {
executionTime?: number;
output?: Record<string, Record<string, any>>;
queueWaitTime?: number;
status?:
| "IN_PROGRESS"
| "FAILED"
| "FAILED_WITH_TERMINAL_ERROR"
| "COMPLETED";
};
20 changes: 20 additions & 0 deletions src/common/open-api/models/WorkflowTestRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { TaskMock } from "./TaskMock";
import type { WorkflowDef } from "./WorkflowDef";
export type WorkflowTestRequest = {
correlationId?: string;
createdBy?: string;
externalInputPayloadStoragePath?: string;
idempotencyKey?: string;
idempotencyStrategy?: "FAIL" | "RETURN_EXISTING";
input?: Record<string, Record<string, any>>;
name: string;
priority?: number;
subWorkflowTestRequest?: Record<string, WorkflowTestRequest>;
taskRefToMockOutput?: Record<string, Array<TaskMock>>;
taskToDomain?: Record<string, string>;
version?: number;
workflowDef?: WorkflowDef;
};
18 changes: 18 additions & 0 deletions src/common/open-api/services/WorkflowResourceService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import type { StartWorkflowRequest } from '../models/StartWorkflowRequest';
import type { Workflow } from '../models/Workflow';
import type { WorkflowRun } from '../models/WorkflowRun';
import type { WorkflowStatus } from '../models/WorkflowStatus';
import type { WorkflowTestRequest } from '../models/WorkflowTestRequest';


import type { CancelablePromise } from '../core/CancelablePromise';
import type { BaseHttpRequest } from '../core/BaseHttpRequest';
Expand Down Expand Up @@ -605,4 +607,20 @@ export class WorkflowResourceService {
});
}

/**
* Test workflow execution using mock data
* @param requestBody
* @returns Workflow OK
* @throws ApiError
*/
public testWorkflow(
requestBody: WorkflowTestRequest
): CancelablePromise<Workflow> {
return this.httpRequest.request({
method: 'POST',
url: '/api/workflow/test',
body: requestBody,
mediaType: 'application/json',
});
}
}

0 comments on commit b8307a3

Please sign in to comment.