-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from Deltares/173-add-workflows
Add workflows and moduleruntimes endpoint
- Loading branch information
Showing
12 changed files
with
221 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import type { BaseFilter } from "./baseFilter"; | ||
|
||
export interface ModuleRuntimesFilter extends BaseFilter { | ||
workflowId?: string; | ||
|
||
// TODO: Is this being used? Seems to be an invalid parameter. | ||
// Unique sequence number that can be used to order asynchronous api requests. | ||
draw?: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import type { BaseFilter } from "./baseFilter"; | ||
|
||
export interface WorkflowsFilter extends BaseFilter {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './workflowsResponse.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* tslint:disable */ | ||
|
||
/** | ||
* WorkflowResponse PI_JSON | ||
*/ | ||
export interface WorkflowResponse { | ||
/** | ||
* Workflows | ||
*/ | ||
workflows: Workflow[]; | ||
} | ||
export interface Workflow { | ||
/** | ||
* the id of the workflow | ||
*/ | ||
id: string; | ||
/** | ||
* The name of the workflow | ||
*/ | ||
name: string; | ||
/** | ||
* The description of the workflow | ||
*/ | ||
description: string; | ||
/** | ||
* The whatif template id | ||
*/ | ||
whatIfTemplateId?: string; | ||
/** | ||
* the minimum forecast length of the workflow | ||
*/ | ||
minimumForecastLength?: string; | ||
/** | ||
* the maximum forecast length of the workflow | ||
*/ | ||
maximumForecastLength?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { DocumentFormat, PiWebserviceProvider, ModuleRuntimesFilter } from "../../../src"; | ||
|
||
import expectedResponse from "../mock/moduleRunTimes.json"; | ||
import "cross-fetch/polyfill"; | ||
import fetchMock from "fetch-mock"; | ||
|
||
describe("moduleRunTimes", function () { | ||
afterAll(() => { | ||
fetchMock.restore(); | ||
}); | ||
|
||
it("gets called when done", async () => { | ||
fetchMock.get( | ||
"https://mock.dev/fewswebservices/rest/fewspiservice/v1/moduleruntimes?documentFormat=PI_JSON", | ||
{ | ||
status: 200, | ||
body: JSON.stringify(expectedResponse), | ||
} | ||
); | ||
|
||
const provider = new PiWebserviceProvider( | ||
"https://mock.dev/fewswebservices" | ||
); | ||
|
||
const filter: ModuleRuntimesFilter = { | ||
documentFormat: DocumentFormat.PI_JSON, | ||
} | ||
|
||
const results = await provider.getModuleRunTimes(filter); | ||
expect(results).toStrictEqual(expectedResponse); | ||
expect(results.moduleRunTimes.length).toBe(2); | ||
expect(results.moduleRunTimes[0].workflowId).toBe("testWorkflowId1"); | ||
expect(results.moduleRunTimes[0].moduleInstanceId).toBe("testModuleInstanceId1"); | ||
expect(results.moduleRunTimes[0].mcId).toBe("testId1"); | ||
expect(results.moduleRunTimes[0].expectedStartTime).toBe(1737640822000); | ||
expect(results.moduleRunTimes[0].expectedCompletionTime).toBe(1737640822000); | ||
expect(results.moduleRunTimes[0].expectedPendingDuration).toBe(21568); | ||
expect(results.moduleRunTimes[0].expectedRunningDuration).toBe(41); | ||
expect(results.moduleRunTimes[1].workflowId).toBe("testWorkflowId2"); | ||
expect(results.moduleRunTimes[1].moduleInstanceId).toBe("testModuleInstanceId2"); | ||
expect(results.moduleRunTimes[1].mcId).toBe("testId2"); | ||
expect(results.moduleRunTimes[1].expectedStartTime).toBe(1737640822000); | ||
expect(results.moduleRunTimes[1].expectedCompletionTime).toBe(1737641175000); | ||
expect(results.moduleRunTimes[1].expectedPendingDuration).toBe(21610); | ||
expect(results.moduleRunTimes[1].expectedRunningDuration).toBe(353755); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { DocumentFormat, PiWebserviceProvider, WorkflowsFilter } from "../../../src"; | ||
|
||
import expectedResponse from "../mock/workflows.json"; | ||
import "cross-fetch/polyfill"; | ||
import fetchMock from "fetch-mock"; | ||
|
||
describe("workflows", function () { | ||
afterAll(() => { | ||
fetchMock.restore(); | ||
}); | ||
|
||
it("gets called when done", async () => { | ||
fetchMock.get( | ||
"https://mock.dev/fewswebservices/rest/fewspiservice/v1/workflows?documentFormat=PI_JSON", | ||
{ | ||
status: 200, | ||
body: JSON.stringify(expectedResponse), | ||
} | ||
); | ||
|
||
const provider = new PiWebserviceProvider( | ||
"https://mock.dev/fewswebservices" | ||
); | ||
|
||
const workflowsFilter: WorkflowsFilter = { | ||
documentFormat: DocumentFormat.PI_JSON, | ||
} | ||
|
||
const results = await provider.getWorkflows(workflowsFilter); | ||
expect(results).toStrictEqual(expectedResponse); | ||
expect(results.workflows.length).toBe(2); | ||
expect(results.workflows[0].id).toBe("ImportHistorical"); | ||
expect(results.workflows[0].name).toBe("Import Historical Data"); | ||
expect(results.workflows[0].description).toBe(""); | ||
expect(results.workflows[1].id).toBe("ImportTEST"); | ||
expect(results.workflows[1].name).toBe("Import TEST"); | ||
expect(results.workflows[1].description).toBe("Import TEST"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"moduleRunTimes": [ | ||
{ | ||
"workflowId": "testWorkflowId1", | ||
"moduleInstanceId": "testModuleInstanceId1", | ||
"mcId": "testId1", | ||
"expectedStartTime": 1737640822000, | ||
"expectedCompletionTime": 1737640822000, | ||
"expectedPendingDuration": 21568, | ||
"expectedRunningDuration": 41 | ||
}, | ||
{ | ||
"workflowId": "testWorkflowId2", | ||
"moduleInstanceId": "testModuleInstanceId2", | ||
"mcId": "testId2", | ||
"expectedStartTime": 1737640822000, | ||
"expectedCompletionTime": 1737641175000, | ||
"expectedPendingDuration": 21610, | ||
"expectedRunningDuration": 353755 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"workflows": [ | ||
{ | ||
"id": "ImportHistorical", | ||
"name": "Import Historical Data", | ||
"description": "" | ||
}, | ||
{ | ||
"id": "ImportTEST", | ||
"name": "Import TEST", | ||
"description": "Import TEST" | ||
} | ||
] | ||
} |