File tree Expand file tree Collapse file tree 2 files changed +4
-31
lines changed Expand file tree Collapse file tree 2 files changed +4
-31
lines changed Original file line number Diff line number Diff line change 1
1
import { createApiRef } from '@backstage/core-plugin-api' ;
2
2
3
- export type ToolRequest = {
4
- method ?: string ;
5
- headers ?: Record < string , string > ;
6
- body ?:
7
- | string
8
- | ArrayBuffer
9
- | SharedArrayBuffer
10
- | ArrayBufferView
11
- | Blob
12
- | FormData
13
- | URLSearchParams
14
- | ReadableStream < Uint8Array >
15
- | null ;
16
- } ;
17
-
18
- export type ToolResponse = {
19
- readonly status : number ;
20
- readonly statusText : string ;
21
- readonly ok : boolean ;
22
- readonly json : ( ) => Promise < unknown > ;
23
- readonly text : ( ) => Promise < string > ;
24
- readonly arrayBuffer : ( ) => Promise < ArrayBuffer > ;
25
- } ;
26
-
27
3
export interface ToolboxApi {
28
4
getBackendTools ( ) : Promise < string [ ] > ;
29
5
30
- toolRequest ( toolName : string , request : ToolRequest ) : Promise < ToolResponse > ;
6
+ toolRequest ( toolName : string , request : any ) : Promise < any > ;
31
7
32
8
toolJsonRequest ( toolName : string , data : any ) : Promise < unknown > ;
33
9
}
Original file line number Diff line number Diff line change 1
- import { ToolboxApi , ToolRequest , ToolResponse } from './ToolboxApi' ;
1
+ import { ToolboxApi } from './ToolboxApi' ;
2
2
import { DiscoveryApi , FetchApi } from '@backstage/core-plugin-api' ;
3
3
4
4
export class ToolboxClient implements ToolboxApi {
@@ -25,10 +25,7 @@ export class ToolboxClient implements ToolboxApi {
25
25
}
26
26
}
27
27
28
- async toolRequest (
29
- toolName : string ,
30
- request : ToolRequest ,
31
- ) : Promise < ToolResponse > {
28
+ async toolRequest ( toolName : string , request : any ) : Promise < any > {
32
29
const url = `${ await this . getBaseUrl ( ) } /${ toolName } ` ;
33
30
const response = await this . fetchApi . fetch ( url , request ) ;
34
31
if ( response . ok ) {
@@ -38,7 +35,7 @@ export class ToolboxClient implements ToolboxApi {
38
35
}
39
36
40
37
async toolJsonRequest ( toolName : string , data : any ) : Promise < unknown > {
41
- const request : ToolRequest = {
38
+ const request = {
42
39
method : 'POST' ,
43
40
headers : {
44
41
'Content-Type' : 'application/json' ,
You can’t perform that action at this time.
0 commit comments