1
- import axios , { AxiosError , AxiosInstance } from 'axios'
1
+ import axios , { AxiosError } from 'axios'
2
2
import { isNode } from 'browser-or-node'
3
3
import http from 'http'
4
4
import https from 'https'
5
5
import { getClientConfig , ClientProps , ClientConfig } from './config'
6
- import { CreateFileResponse , GetFileResponse } from './gen'
7
- import { ApiClient as AutoGeneratedClient , CreateFileProps } from './gen/client'
6
+ import { Client as AutoGeneratedClient } from './gen'
7
+
8
+ import { CreateFileInput , CreateFileResponse } from './gen/operations/createFile'
9
+ import { GetFileResponse } from './gen/operations/getFile'
8
10
9
11
export { isApiError } from './gen/errors'
10
12
@@ -15,15 +17,15 @@ export type {
15
17
User ,
16
18
State ,
17
19
Event ,
18
- ModelFile as File ,
20
+ File ,
19
21
Bot ,
20
22
Integration ,
21
23
Issue ,
22
24
IssueEvent ,
23
25
Account ,
24
26
Workspace ,
25
27
Usage ,
26
- } from './gen'
28
+ } from './gen/models '
27
29
export * from './gen/errors'
28
30
29
31
const _100mb = 100 * 1024 * 1024
@@ -32,16 +34,13 @@ const maxContentLength = _100mb
32
34
33
35
export class Client extends AutoGeneratedClient {
34
36
public readonly config : Readonly < ClientConfig >
35
- private readonly axiosClient : AxiosInstance
36
37
37
38
public constructor ( clientProps : ClientProps = { } ) {
38
39
const clientConfig = getClientConfig ( clientProps )
39
40
const axiosClient = createAxiosClient ( clientConfig )
40
-
41
- super ( undefined , clientConfig . apiUrl , axiosClient )
41
+ super ( axiosClient )
42
42
43
43
this . config = clientConfig
44
- this . axiosClient = axiosClient
45
44
}
46
45
47
46
/**
@@ -54,7 +53,7 @@ export class Client extends AutoGeneratedClient {
54
53
tags,
55
54
contentType,
56
55
accessPolicies,
57
- } : Omit < CreateFileProps , 'size' > & { data : Buffer } ) : Promise < GetFileResponse > => {
56
+ } : Omit < CreateFileInput , 'size' > & { data : Buffer } ) : Promise < GetFileResponse > => {
58
57
const { file } = await this . createFile ( {
59
58
name,
60
59
tags,
@@ -88,8 +87,9 @@ export class FileUploadError extends Error {
88
87
}
89
88
90
89
function createAxiosClient ( config : ClientConfig ) {
91
- const { headers, withCredentials, timeout } = config
90
+ const { apiUrl , headers, withCredentials, timeout } = config
92
91
return axios . create ( {
92
+ baseURL : apiUrl ,
93
93
headers,
94
94
withCredentials,
95
95
timeout,
0 commit comments