@@ -4,7 +4,7 @@ import qs from 'qs';
4
4
import { authOpts } from 'src/auth/auth-session' ;
5
5
import { fetchFromProxy } from 'src/libs/ajax/ajax-common' ;
6
6
7
- export const Cbas = ( signal ) => ( {
7
+ export const Cbas = ( signal ?: AbortSignal ) => ( {
8
8
status : async ( cbasUrlRoot ) => {
9
9
const res = await fetchFromProxy ( cbasUrlRoot ) ( 'status' , _ . mergeAll ( [ authOpts ( ) , { signal, method : 'GET' } ] ) ) ;
10
10
return res . json ( ) ;
@@ -14,19 +14,28 @@ export const Cbas = (signal) => ({
14
14
return res . json ( ) ;
15
15
} ,
16
16
capabilities : async ( cbasUrlRoot ) => {
17
- const res = await fetchFromProxy ( cbasUrlRoot ) ( 'capabilities/v1' , _ . mergeAll ( [ authOpts ( ) , { signal, method : 'GET' } ] ) ) ;
17
+ const res = await fetchFromProxy ( cbasUrlRoot ) (
18
+ 'capabilities/v1' ,
19
+ _ . mergeAll ( [ authOpts ( ) , { signal, method : 'GET' } ] )
20
+ ) ;
18
21
return res . json ( ) ;
19
22
} ,
20
23
runs : {
21
24
get : async ( cbasUrlRoot , submissionId ) => {
22
25
const keyParams = qs . stringify ( { run_set_id : submissionId } ) ;
23
- const res = await fetchFromProxy ( cbasUrlRoot ) ( `api/batch/v1/runs?${ keyParams } ` , _ . mergeAll ( [ authOpts ( ) , { signal, method : 'GET' } ] ) ) ;
26
+ const res = await fetchFromProxy ( cbasUrlRoot ) (
27
+ `api/batch/v1/runs?${ keyParams } ` ,
28
+ _ . mergeAll ( [ authOpts ( ) , { signal, method : 'GET' } ] )
29
+ ) ;
24
30
return res . json ( ) ;
25
31
} ,
26
32
} ,
27
33
methods : {
28
34
post : async ( cbasUrlRoot , payload ) => {
29
- const res = await fetchFromProxy ( cbasUrlRoot ) ( 'api/batch/v1/methods' , _ . mergeAll ( [ authOpts ( ) , jsonBody ( payload ) , { signal, method : 'POST' } ] ) ) ;
35
+ const res = await fetchFromProxy ( cbasUrlRoot ) (
36
+ 'api/batch/v1/methods' ,
37
+ _ . mergeAll ( [ authOpts ( ) , jsonBody ( payload ) , { signal, method : 'POST' } ] )
38
+ ) ;
30
39
return res . json ( ) ;
31
40
} ,
32
41
archive : async ( cbasUrlRoot , methodId ) => {
@@ -39,38 +48,62 @@ export const Cbas = (signal) => ({
39
48
} ,
40
49
getWithVersions : async ( cbasUrlRoot ) => {
41
50
const keyParams = qs . stringify ( { show_versions : true } ) ;
42
- const res = await fetchFromProxy ( cbasUrlRoot ) ( `api/batch/v1/methods?${ keyParams } ` , _ . mergeAll ( [ authOpts ( ) , { signal, method : 'GET' } ] ) ) ;
51
+ const res = await fetchFromProxy ( cbasUrlRoot ) (
52
+ `api/batch/v1/methods?${ keyParams } ` ,
53
+ _ . mergeAll ( [ authOpts ( ) , { signal, method : 'GET' } ] )
54
+ ) ;
43
55
return res . json ( ) ;
44
56
} ,
45
57
getWithoutVersions : async ( cbasUrlRoot ) => {
46
58
const keyParams = qs . stringify ( { show_versions : false } ) ;
47
- const res = await fetchFromProxy ( cbasUrlRoot ) ( `api/batch/v1/methods?${ keyParams } ` , _ . mergeAll ( [ authOpts ( ) , { signal, method : 'GET' } ] ) ) ;
59
+ const res = await fetchFromProxy ( cbasUrlRoot ) (
60
+ `api/batch/v1/methods?${ keyParams } ` ,
61
+ _ . mergeAll ( [ authOpts ( ) , { signal, method : 'GET' } ] )
62
+ ) ;
48
63
return res . json ( ) ;
49
64
} ,
50
65
getById : async ( cbasUrlRoot , methodId ) => {
51
66
const keyParams = qs . stringify ( { method_id : methodId } ) ;
52
- const res = await fetchFromProxy ( cbasUrlRoot ) ( `api/batch/v1/methods?${ keyParams } ` , _ . mergeAll ( [ authOpts ( ) , { signal, method : 'GET' } ] ) ) ;
67
+ const res = await fetchFromProxy ( cbasUrlRoot ) (
68
+ `api/batch/v1/methods?${ keyParams } ` ,
69
+ _ . mergeAll ( [ authOpts ( ) , { signal, method : 'GET' } ] )
70
+ ) ;
53
71
return res . json ( ) ;
54
72
} ,
55
73
} ,
56
74
runSets : {
57
75
get : async ( cbasUrlRoot ) => {
58
- const res = await fetchFromProxy ( cbasUrlRoot ) ( 'api/batch/v1/run_sets' , _ . mergeAll ( [ authOpts ( ) , { signal, method : 'GET' } ] ) ) ;
76
+ const res = await fetchFromProxy ( cbasUrlRoot ) (
77
+ 'api/batch/v1/run_sets' ,
78
+ _ . mergeAll ( [ authOpts ( ) , { signal, method : 'GET' } ] )
79
+ ) ;
59
80
return res . json ( ) ;
60
81
} ,
61
82
post : async ( cbasUrlRoot , payload ) => {
62
- const res = await fetchFromProxy ( cbasUrlRoot ) ( 'api/batch/v1/run_sets' , _ . mergeAll ( [ authOpts ( ) , { signal, method : 'POST' } , jsonBody ( payload ) ] ) ) ;
83
+ const res = await fetchFromProxy ( cbasUrlRoot ) (
84
+ 'api/batch/v1/run_sets' ,
85
+ _ . mergeAll ( [ authOpts ( ) , { signal, method : 'POST' } , jsonBody ( payload ) ] )
86
+ ) ;
63
87
return res . json ( ) ;
64
88
} ,
65
89
getForMethod : async ( cbasUrlRoot , methodId , pageSize ) => {
66
90
const keyParams = qs . stringify ( { method_id : methodId , page_size : pageSize } , { arrayFormat : 'repeat' } ) ;
67
- const res = await fetchFromProxy ( cbasUrlRoot ) ( `api/batch/v1/run_sets?${ keyParams } ` , _ . mergeAll ( [ authOpts ( ) , { signal, method : 'GET' } ] ) ) ;
91
+ const res = await fetchFromProxy ( cbasUrlRoot ) (
92
+ `api/batch/v1/run_sets?${ keyParams } ` ,
93
+ _ . mergeAll ( [ authOpts ( ) , { signal, method : 'GET' } ] )
94
+ ) ;
68
95
return res . json ( ) ;
69
96
} ,
70
97
cancel : async ( cbasUrlRoot , runSetId ) => {
71
98
const keyParams = qs . stringify ( { run_set_id : runSetId } ) ;
72
- const res = await fetchFromProxy ( cbasUrlRoot ) ( `api/batch/v1/run_sets/abort?${ keyParams } ` , _ . mergeAll ( [ authOpts ( ) , { signal, method : 'POST' } ] ) ) ;
99
+ const res = await fetchFromProxy ( cbasUrlRoot ) (
100
+ `api/batch/v1/run_sets/abort?${ keyParams } ` ,
101
+ _ . mergeAll ( [ authOpts ( ) , { signal, method : 'POST' } ] )
102
+ ) ;
73
103
return res . json ( ) ;
74
104
} ,
75
105
} ,
76
106
} ) ;
107
+
108
+ export type CbasAjaxContract = ReturnType < typeof Cbas > ;
109
+ export type CbasMethodsContract = CbasAjaxContract [ 'methods' ] ;
0 commit comments