1
1
import ky from "ky" ;
2
+ import { WORKFLOW_ID } from "../apis/catalog/brc-analytics-catalog/common/entities" ;
2
3
3
4
interface WorkflowLandingsBody {
4
- request_state : { reference_genome : string } ;
5
+ request_state : WorkflowLandingsBodyRequestState ;
5
6
workflow_id : string ;
6
7
workflow_target_type : "trs_url" ;
7
8
}
8
9
10
+ type WorkflowLandingsBodyRequestState = { reference_genome : string } ;
11
+
9
12
interface WorkflowLanding {
10
13
uuid : string ;
11
14
}
@@ -23,13 +26,11 @@ const WORKFLOW_LANDING_URL_PREFIX =
23
26
* @returns workflow landing URL.
24
27
*/
25
28
export async function getWorkflowLandingUrl (
26
- workflowId : string ,
29
+ workflowId : WORKFLOW_ID ,
27
30
referenceGenome : string
28
31
) : Promise < string > {
29
32
const body : WorkflowLandingsBody = {
30
- request_state : {
31
- reference_genome : referenceGenome ,
32
- } ,
33
+ request_state : getWorkflowLandingsRequestState ( workflowId , referenceGenome ) ,
33
34
workflow_id : workflowId ,
34
35
workflow_target_type : "trs_url" ,
35
36
} ;
@@ -42,3 +43,16 @@ export async function getWorkflowLandingUrl(
42
43
const id = ( await res . json ( ) ) . uuid ;
43
44
return WORKFLOW_LANDING_URL_PREFIX + encodeURIComponent ( id ) ;
44
45
}
46
+
47
+ /**
48
+ * Get the appropriate `request_state` object for the given workflow ID and reference genome.
49
+ * @param workflowId - Workflow ID.
50
+ * @param referenceGenome - Reference genome.
51
+ * @returns `request_state` value for the workflow landings request body.
52
+ */
53
+ function getWorkflowLandingsRequestState (
54
+ workflowId : WORKFLOW_ID ,
55
+ referenceGenome : string
56
+ ) : WorkflowLandingsBodyRequestState {
57
+ return { reference_genome : referenceGenome } ;
58
+ }
0 commit comments