@codeforamerica/safety-net-openapi-california 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/applications/client/client.gen.d.ts +2 -0
- package/dist/applications/client/client.gen.js +128 -0
- package/dist/applications/client/index.d.ts +8 -0
- package/dist/applications/client/index.js +6 -0
- package/dist/applications/client/types.gen.d.ts +88 -0
- package/dist/applications/client/types.gen.js +2 -0
- package/dist/applications/client/utils.gen.d.ts +14 -0
- package/dist/applications/client/utils.gen.js +171 -0
- package/dist/applications/client.gen.d.ts +12 -0
- package/dist/applications/client.gen.js +3 -0
- package/dist/applications/core/auth.gen.d.ts +18 -0
- package/dist/applications/core/auth.gen.js +14 -0
- package/dist/applications/core/bodySerializer.gen.d.ts +25 -0
- package/dist/applications/core/bodySerializer.gen.js +57 -0
- package/dist/applications/core/params.gen.d.ts +43 -0
- package/dist/applications/core/params.gen.js +100 -0
- package/dist/applications/core/pathSerializer.gen.d.ts +33 -0
- package/dist/applications/core/pathSerializer.gen.js +114 -0
- package/dist/applications/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/applications/core/queryKeySerializer.gen.js +99 -0
- package/dist/applications/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/applications/core/serverSentEvents.gen.js +137 -0
- package/dist/applications/core/types.gen.d.ts +78 -0
- package/dist/applications/core/types.gen.js +2 -0
- package/dist/applications/core/utils.gen.d.ts +19 -0
- package/dist/applications/core/utils.gen.js +87 -0
- package/dist/applications/index.d.ts +2 -0
- package/dist/applications/index.js +2 -0
- package/dist/applications/sdk.gen.d.ts +45 -0
- package/dist/applications/sdk.gen.js +70 -0
- package/dist/applications/types.gen.d.ts +34007 -0
- package/dist/applications/types.gen.js +2 -0
- package/dist/applications/zod.gen.d.ts +17374 -0
- package/dist/applications/zod.gen.js +16857 -0
- package/dist/households/client/client.gen.d.ts +2 -0
- package/dist/households/client/client.gen.js +128 -0
- package/dist/households/client/index.d.ts +8 -0
- package/dist/households/client/index.js +6 -0
- package/dist/households/client/types.gen.d.ts +88 -0
- package/dist/households/client/types.gen.js +2 -0
- package/dist/households/client/utils.gen.d.ts +14 -0
- package/dist/households/client/utils.gen.js +171 -0
- package/dist/households/client.gen.d.ts +12 -0
- package/dist/households/client.gen.js +3 -0
- package/dist/households/core/auth.gen.d.ts +18 -0
- package/dist/households/core/auth.gen.js +14 -0
- package/dist/households/core/bodySerializer.gen.d.ts +25 -0
- package/dist/households/core/bodySerializer.gen.js +57 -0
- package/dist/households/core/params.gen.d.ts +43 -0
- package/dist/households/core/params.gen.js +100 -0
- package/dist/households/core/pathSerializer.gen.d.ts +33 -0
- package/dist/households/core/pathSerializer.gen.js +114 -0
- package/dist/households/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/households/core/queryKeySerializer.gen.js +99 -0
- package/dist/households/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/households/core/serverSentEvents.gen.js +137 -0
- package/dist/households/core/types.gen.d.ts +78 -0
- package/dist/households/core/types.gen.js +2 -0
- package/dist/households/core/utils.gen.d.ts +19 -0
- package/dist/households/core/utils.gen.js +87 -0
- package/dist/households/index.d.ts +2 -0
- package/dist/households/index.js +2 -0
- package/dist/households/sdk.gen.d.ts +45 -0
- package/dist/households/sdk.gen.js +70 -0
- package/dist/households/types.gen.d.ts +1693 -0
- package/dist/households/types.gen.js +2 -0
- package/dist/households/zod.gen.d.ts +624 -0
- package/dist/households/zod.gen.js +625 -0
- package/dist/incomes/client/client.gen.d.ts +2 -0
- package/dist/incomes/client/client.gen.js +128 -0
- package/dist/incomes/client/index.d.ts +8 -0
- package/dist/incomes/client/index.js +6 -0
- package/dist/incomes/client/types.gen.d.ts +88 -0
- package/dist/incomes/client/types.gen.js +2 -0
- package/dist/incomes/client/utils.gen.d.ts +14 -0
- package/dist/incomes/client/utils.gen.js +171 -0
- package/dist/incomes/client.gen.d.ts +12 -0
- package/dist/incomes/client.gen.js +3 -0
- package/dist/incomes/core/auth.gen.d.ts +18 -0
- package/dist/incomes/core/auth.gen.js +14 -0
- package/dist/incomes/core/bodySerializer.gen.d.ts +25 -0
- package/dist/incomes/core/bodySerializer.gen.js +57 -0
- package/dist/incomes/core/params.gen.d.ts +43 -0
- package/dist/incomes/core/params.gen.js +100 -0
- package/dist/incomes/core/pathSerializer.gen.d.ts +33 -0
- package/dist/incomes/core/pathSerializer.gen.js +114 -0
- package/dist/incomes/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/incomes/core/queryKeySerializer.gen.js +99 -0
- package/dist/incomes/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/incomes/core/serverSentEvents.gen.js +137 -0
- package/dist/incomes/core/types.gen.d.ts +78 -0
- package/dist/incomes/core/types.gen.js +2 -0
- package/dist/incomes/core/utils.gen.d.ts +19 -0
- package/dist/incomes/core/utils.gen.js +87 -0
- package/dist/incomes/index.d.ts +2 -0
- package/dist/incomes/index.js +2 -0
- package/dist/incomes/sdk.gen.d.ts +47 -0
- package/dist/incomes/sdk.gen.js +72 -0
- package/dist/incomes/types.gen.d.ts +1425 -0
- package/dist/incomes/types.gen.js +2 -0
- package/dist/incomes/zod.gen.d.ts +961 -0
- package/dist/incomes/zod.gen.js +920 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/persons/client/client.gen.d.ts +2 -0
- package/dist/persons/client/client.gen.js +128 -0
- package/dist/persons/client/index.d.ts +8 -0
- package/dist/persons/client/index.js +6 -0
- package/dist/persons/client/types.gen.d.ts +88 -0
- package/dist/persons/client/types.gen.js +2 -0
- package/dist/persons/client/utils.gen.d.ts +14 -0
- package/dist/persons/client/utils.gen.js +171 -0
- package/dist/persons/client.gen.d.ts +12 -0
- package/dist/persons/client.gen.js +3 -0
- package/dist/persons/core/auth.gen.d.ts +18 -0
- package/dist/persons/core/auth.gen.js +14 -0
- package/dist/persons/core/bodySerializer.gen.d.ts +25 -0
- package/dist/persons/core/bodySerializer.gen.js +57 -0
- package/dist/persons/core/params.gen.d.ts +43 -0
- package/dist/persons/core/params.gen.js +100 -0
- package/dist/persons/core/pathSerializer.gen.d.ts +33 -0
- package/dist/persons/core/pathSerializer.gen.js +114 -0
- package/dist/persons/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/persons/core/queryKeySerializer.gen.js +99 -0
- package/dist/persons/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/persons/core/serverSentEvents.gen.js +137 -0
- package/dist/persons/core/types.gen.d.ts +78 -0
- package/dist/persons/core/types.gen.js +2 -0
- package/dist/persons/core/utils.gen.d.ts +19 -0
- package/dist/persons/core/utils.gen.js +87 -0
- package/dist/persons/index.d.ts +2 -0
- package/dist/persons/index.js +2 -0
- package/dist/persons/sdk.gen.d.ts +45 -0
- package/dist/persons/sdk.gen.js +70 -0
- package/dist/persons/types.gen.d.ts +7595 -0
- package/dist/persons/types.gen.js +2 -0
- package/dist/persons/zod.gen.d.ts +3578 -0
- package/dist/persons/zod.gen.js +3579 -0
- package/dist/search-helpers.d.ts +242 -0
- package/dist/search-helpers.js +244 -0
- package/package.json +95 -0
- package/src/applications/client/client.gen.ts +166 -0
- package/src/applications/client/index.ts +23 -0
- package/src/applications/client/types.gen.ts +197 -0
- package/src/applications/client/utils.gen.ts +213 -0
- package/src/applications/client.gen.ts +16 -0
- package/src/applications/core/auth.gen.ts +42 -0
- package/src/applications/core/bodySerializer.gen.ts +100 -0
- package/src/applications/core/params.gen.ts +176 -0
- package/src/applications/core/pathSerializer.gen.ts +181 -0
- package/src/applications/core/queryKeySerializer.gen.ts +136 -0
- package/src/applications/core/serverSentEvents.gen.ts +266 -0
- package/src/applications/core/types.gen.ts +118 -0
- package/src/applications/core/utils.gen.ts +143 -0
- package/src/applications/index.ts +4 -0
- package/src/applications/sdk.gen.ts +92 -0
- package/src/applications/types.gen.ts +34043 -0
- package/src/applications/zod.gen.ts +16877 -0
- package/src/households/client/client.gen.ts +166 -0
- package/src/households/client/index.ts +23 -0
- package/src/households/client/types.gen.ts +197 -0
- package/src/households/client/utils.gen.ts +213 -0
- package/src/households/client.gen.ts +16 -0
- package/src/households/core/auth.gen.ts +42 -0
- package/src/households/core/bodySerializer.gen.ts +100 -0
- package/src/households/core/params.gen.ts +176 -0
- package/src/households/core/pathSerializer.gen.ts +181 -0
- package/src/households/core/queryKeySerializer.gen.ts +136 -0
- package/src/households/core/serverSentEvents.gen.ts +266 -0
- package/src/households/core/types.gen.ts +118 -0
- package/src/households/core/utils.gen.ts +143 -0
- package/src/households/index.ts +4 -0
- package/src/households/sdk.gen.ts +92 -0
- package/src/households/types.gen.ts +1729 -0
- package/src/households/zod.gen.ts +645 -0
- package/src/incomes/client/client.gen.ts +166 -0
- package/src/incomes/client/index.ts +23 -0
- package/src/incomes/client/types.gen.ts +197 -0
- package/src/incomes/client/utils.gen.ts +213 -0
- package/src/incomes/client.gen.ts +16 -0
- package/src/incomes/core/auth.gen.ts +42 -0
- package/src/incomes/core/bodySerializer.gen.ts +100 -0
- package/src/incomes/core/params.gen.ts +176 -0
- package/src/incomes/core/pathSerializer.gen.ts +181 -0
- package/src/incomes/core/queryKeySerializer.gen.ts +136 -0
- package/src/incomes/core/serverSentEvents.gen.ts +266 -0
- package/src/incomes/core/types.gen.ts +118 -0
- package/src/incomes/core/utils.gen.ts +143 -0
- package/src/incomes/index.ts +4 -0
- package/src/incomes/sdk.gen.ts +94 -0
- package/src/incomes/types.gen.ts +1460 -0
- package/src/incomes/zod.gen.ts +939 -0
- package/src/index.ts +5 -0
- package/src/persons/client/client.gen.ts +166 -0
- package/src/persons/client/index.ts +23 -0
- package/src/persons/client/types.gen.ts +197 -0
- package/src/persons/client/utils.gen.ts +213 -0
- package/src/persons/client.gen.ts +16 -0
- package/src/persons/core/auth.gen.ts +42 -0
- package/src/persons/core/bodySerializer.gen.ts +100 -0
- package/src/persons/core/params.gen.ts +176 -0
- package/src/persons/core/pathSerializer.gen.ts +181 -0
- package/src/persons/core/queryKeySerializer.gen.ts +136 -0
- package/src/persons/core/serverSentEvents.gen.ts +266 -0
- package/src/persons/core/types.gen.ts +118 -0
- package/src/persons/core/utils.gen.ts +143 -0
- package/src/persons/index.ts +4 -0
- package/src/persons/sdk.gen.ts +92 -0
- package/src/persons/types.gen.ts +7631 -0
- package/src/persons/zod.gen.ts +3599 -0
- package/src/search-helpers.ts +264 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import type { AxiosError, AxiosInstance, RawAxiosRequestHeaders } from 'axios';
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
|
|
6
|
+
import { createSseClient } from '../core/serverSentEvents.gen';
|
|
7
|
+
import type { HttpMethod } from '../core/types.gen';
|
|
8
|
+
import { getValidRequestBody } from '../core/utils.gen';
|
|
9
|
+
import type { Client, Config, RequestOptions } from './types.gen';
|
|
10
|
+
import {
|
|
11
|
+
buildUrl,
|
|
12
|
+
createConfig,
|
|
13
|
+
mergeConfigs,
|
|
14
|
+
mergeHeaders,
|
|
15
|
+
setAuthParams,
|
|
16
|
+
} from './utils.gen';
|
|
17
|
+
|
|
18
|
+
export const createClient = (config: Config = {}): Client => {
|
|
19
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
20
|
+
|
|
21
|
+
let instance: AxiosInstance;
|
|
22
|
+
|
|
23
|
+
if (_config.axios && !('Axios' in _config.axios)) {
|
|
24
|
+
instance = _config.axios;
|
|
25
|
+
} else {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
27
|
+
const { auth, ...configWithoutAuth } = _config;
|
|
28
|
+
instance = axios.create(configWithoutAuth);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const getConfig = (): Config => ({ ..._config });
|
|
32
|
+
|
|
33
|
+
const setConfig = (config: Config): Config => {
|
|
34
|
+
_config = mergeConfigs(_config, config);
|
|
35
|
+
instance.defaults = {
|
|
36
|
+
...instance.defaults,
|
|
37
|
+
..._config,
|
|
38
|
+
|
|
39
|
+
headers: mergeHeaders(instance.defaults.headers, _config.headers),
|
|
40
|
+
};
|
|
41
|
+
return getConfig();
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const beforeRequest = async (options: RequestOptions) => {
|
|
45
|
+
const opts = {
|
|
46
|
+
..._config,
|
|
47
|
+
...options,
|
|
48
|
+
axios: options.axios ?? _config.axios ?? instance,
|
|
49
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
if (opts.security) {
|
|
53
|
+
await setAuthParams({
|
|
54
|
+
...opts,
|
|
55
|
+
security: opts.security,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (opts.requestValidator) {
|
|
60
|
+
await opts.requestValidator(opts);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (opts.body !== undefined && opts.bodySerializer) {
|
|
64
|
+
opts.body = opts.bodySerializer(opts.body);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const url = buildUrl(opts);
|
|
68
|
+
|
|
69
|
+
return { opts, url };
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const request: Client['request'] = async (options) => {
|
|
73
|
+
|
|
74
|
+
const { opts, url } = await beforeRequest(options);
|
|
75
|
+
try {
|
|
76
|
+
// assign Axios here for consistency with fetch
|
|
77
|
+
const _axios = opts.axios!;
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
79
|
+
const { auth, ...optsWithoutAuth } = opts;
|
|
80
|
+
const response = await _axios({
|
|
81
|
+
...optsWithoutAuth,
|
|
82
|
+
baseURL: '', // the baseURL is already included in `url`
|
|
83
|
+
data: getValidRequestBody(opts),
|
|
84
|
+
headers: opts.headers as RawAxiosRequestHeaders,
|
|
85
|
+
// let `paramsSerializer()` handle query params if it exists
|
|
86
|
+
params: opts.paramsSerializer ? opts.query : undefined,
|
|
87
|
+
url,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
let { data } = response;
|
|
91
|
+
|
|
92
|
+
if (opts.responseType === 'json') {
|
|
93
|
+
if (opts.responseValidator) {
|
|
94
|
+
await opts.responseValidator(data);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (opts.responseTransformer) {
|
|
98
|
+
data = await opts.responseTransformer(data);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
...response,
|
|
104
|
+
data: data ?? {},
|
|
105
|
+
};
|
|
106
|
+
} catch (error) {
|
|
107
|
+
const e = error as AxiosError;
|
|
108
|
+
if (opts.throwOnError) {
|
|
109
|
+
throw e;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
e.error = e.response?.data ?? {};
|
|
113
|
+
return e;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const makeMethodFn =
|
|
118
|
+
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
|
|
119
|
+
request({ ...options, method });
|
|
120
|
+
|
|
121
|
+
const makeSseFn =
|
|
122
|
+
(method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
|
|
123
|
+
const { opts, url } = await beforeRequest(options);
|
|
124
|
+
return createSseClient({
|
|
125
|
+
...opts,
|
|
126
|
+
body: opts.body as BodyInit | null | undefined,
|
|
127
|
+
headers: opts.headers as Record<string, string>,
|
|
128
|
+
method,
|
|
129
|
+
serializedBody: getValidRequestBody(opts) as
|
|
130
|
+
| BodyInit
|
|
131
|
+
| null
|
|
132
|
+
| undefined,
|
|
133
|
+
|
|
134
|
+
signal: opts.signal,
|
|
135
|
+
url,
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
buildUrl,
|
|
141
|
+
connect: makeMethodFn('CONNECT'),
|
|
142
|
+
delete: makeMethodFn('DELETE'),
|
|
143
|
+
get: makeMethodFn('GET'),
|
|
144
|
+
getConfig,
|
|
145
|
+
head: makeMethodFn('HEAD'),
|
|
146
|
+
instance,
|
|
147
|
+
options: makeMethodFn('OPTIONS'),
|
|
148
|
+
patch: makeMethodFn('PATCH'),
|
|
149
|
+
post: makeMethodFn('POST'),
|
|
150
|
+
put: makeMethodFn('PUT'),
|
|
151
|
+
request,
|
|
152
|
+
setConfig,
|
|
153
|
+
sse: {
|
|
154
|
+
connect: makeSseFn('CONNECT'),
|
|
155
|
+
delete: makeSseFn('DELETE'),
|
|
156
|
+
get: makeSseFn('GET'),
|
|
157
|
+
head: makeSseFn('HEAD'),
|
|
158
|
+
options: makeSseFn('OPTIONS'),
|
|
159
|
+
patch: makeSseFn('PATCH'),
|
|
160
|
+
post: makeSseFn('POST'),
|
|
161
|
+
put: makeSseFn('PUT'),
|
|
162
|
+
trace: makeSseFn('TRACE'),
|
|
163
|
+
},
|
|
164
|
+
trace: makeMethodFn('TRACE'),
|
|
165
|
+
} as Client;
|
|
166
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
export type { Auth } from '../core/auth.gen';
|
|
4
|
+
export type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
|
5
|
+
export {
|
|
6
|
+
formDataBodySerializer,
|
|
7
|
+
jsonBodySerializer,
|
|
8
|
+
urlSearchParamsBodySerializer,
|
|
9
|
+
} from '../core/bodySerializer.gen';
|
|
10
|
+
export { buildClientParams } from '../core/params.gen';
|
|
11
|
+
export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen';
|
|
12
|
+
export { createClient } from './client.gen';
|
|
13
|
+
export type {
|
|
14
|
+
Client,
|
|
15
|
+
ClientOptions,
|
|
16
|
+
Config,
|
|
17
|
+
CreateClientConfig,
|
|
18
|
+
Options,
|
|
19
|
+
RequestOptions,
|
|
20
|
+
RequestResult,
|
|
21
|
+
TDataShape,
|
|
22
|
+
} from './types.gen';
|
|
23
|
+
export { createConfig } from './utils.gen';
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
AxiosError,
|
|
5
|
+
AxiosInstance,
|
|
6
|
+
AxiosRequestHeaders,
|
|
7
|
+
AxiosResponse,
|
|
8
|
+
AxiosStatic,
|
|
9
|
+
CreateAxiosDefaults,
|
|
10
|
+
} from 'axios';
|
|
11
|
+
|
|
12
|
+
import type { Auth } from '../core/auth.gen';
|
|
13
|
+
import type {
|
|
14
|
+
ServerSentEventsOptions,
|
|
15
|
+
ServerSentEventsResult,
|
|
16
|
+
} from '../core/serverSentEvents.gen';
|
|
17
|
+
import type {
|
|
18
|
+
Client as CoreClient,
|
|
19
|
+
Config as CoreConfig,
|
|
20
|
+
} from '../core/types.gen';
|
|
21
|
+
|
|
22
|
+
export interface Config<T extends ClientOptions = ClientOptions>
|
|
23
|
+
extends Omit<CreateAxiosDefaults, 'auth' | 'baseURL' | 'headers' | 'method'>,
|
|
24
|
+
CoreConfig {
|
|
25
|
+
/**
|
|
26
|
+
* Axios implementation. You can use this option to provide either an
|
|
27
|
+
* `AxiosStatic` or an `AxiosInstance`.
|
|
28
|
+
*
|
|
29
|
+
* @default axios
|
|
30
|
+
*/
|
|
31
|
+
axios?: AxiosStatic | AxiosInstance;
|
|
32
|
+
/**
|
|
33
|
+
* Base URL for all requests made by this client.
|
|
34
|
+
*/
|
|
35
|
+
baseURL?: T['baseURL'];
|
|
36
|
+
/**
|
|
37
|
+
* An object containing any HTTP headers that you want to pre-populate your
|
|
38
|
+
* `Headers` object with.
|
|
39
|
+
*
|
|
40
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
|
41
|
+
*/
|
|
42
|
+
headers?:
|
|
43
|
+
| AxiosRequestHeaders
|
|
44
|
+
| Record<
|
|
45
|
+
string,
|
|
46
|
+
| string
|
|
47
|
+
| number
|
|
48
|
+
| boolean
|
|
49
|
+
| (string | number | boolean)[]
|
|
50
|
+
| null
|
|
51
|
+
| undefined
|
|
52
|
+
| unknown
|
|
53
|
+
>;
|
|
54
|
+
/**
|
|
55
|
+
* Throw an error instead of returning it in the response?
|
|
56
|
+
*
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
throwOnError?: T['throwOnError'];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface RequestOptions<
|
|
63
|
+
TData = unknown,
|
|
64
|
+
ThrowOnError extends boolean = boolean,
|
|
65
|
+
Url extends string = string,
|
|
66
|
+
> extends Config<{
|
|
67
|
+
throwOnError: ThrowOnError;
|
|
68
|
+
}>,
|
|
69
|
+
Pick<
|
|
70
|
+
ServerSentEventsOptions<TData>,
|
|
71
|
+
| 'onSseError'
|
|
72
|
+
| 'onSseEvent'
|
|
73
|
+
| 'sseDefaultRetryDelay'
|
|
74
|
+
| 'sseMaxRetryAttempts'
|
|
75
|
+
| 'sseMaxRetryDelay'
|
|
76
|
+
> {
|
|
77
|
+
/**
|
|
78
|
+
* Any body that you want to add to your request.
|
|
79
|
+
*
|
|
80
|
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
|
|
81
|
+
*/
|
|
82
|
+
body?: unknown;
|
|
83
|
+
path?: Record<string, unknown>;
|
|
84
|
+
query?: Record<string, unknown>;
|
|
85
|
+
/**
|
|
86
|
+
* Security mechanism(s) to use for the request.
|
|
87
|
+
*/
|
|
88
|
+
security?: ReadonlyArray<Auth>;
|
|
89
|
+
url: Url;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface ClientOptions {
|
|
93
|
+
baseURL?: string;
|
|
94
|
+
throwOnError?: boolean;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type RequestResult<
|
|
98
|
+
TData = unknown,
|
|
99
|
+
TError = unknown,
|
|
100
|
+
ThrowOnError extends boolean = boolean,
|
|
101
|
+
> = ThrowOnError extends true
|
|
102
|
+
? Promise<
|
|
103
|
+
AxiosResponse<
|
|
104
|
+
TData extends Record<string, unknown> ? TData[keyof TData] : TData
|
|
105
|
+
>
|
|
106
|
+
>
|
|
107
|
+
: Promise<
|
|
108
|
+
| (AxiosResponse<
|
|
109
|
+
TData extends Record<string, unknown> ? TData[keyof TData] : TData
|
|
110
|
+
> & { error: undefined })
|
|
111
|
+
| (AxiosError<
|
|
112
|
+
TError extends Record<string, unknown> ? TError[keyof TError] : TError
|
|
113
|
+
> & {
|
|
114
|
+
data: undefined;
|
|
115
|
+
error: TError extends Record<string, unknown>
|
|
116
|
+
? TError[keyof TError]
|
|
117
|
+
: TError;
|
|
118
|
+
})
|
|
119
|
+
>;
|
|
120
|
+
|
|
121
|
+
type MethodFn = <
|
|
122
|
+
TData = unknown,
|
|
123
|
+
TError = unknown,
|
|
124
|
+
ThrowOnError extends boolean = false,
|
|
125
|
+
>(
|
|
126
|
+
options: Omit<RequestOptions<TData, ThrowOnError>, 'method'>,
|
|
127
|
+
) => RequestResult<TData, TError, ThrowOnError>;
|
|
128
|
+
|
|
129
|
+
type SseFn = <
|
|
130
|
+
TData = unknown,
|
|
131
|
+
TError = unknown,
|
|
132
|
+
ThrowOnError extends boolean = false,
|
|
133
|
+
>(
|
|
134
|
+
options: Omit<RequestOptions<TData, ThrowOnError>, 'method'>,
|
|
135
|
+
) => Promise<ServerSentEventsResult<TData, TError>>;
|
|
136
|
+
|
|
137
|
+
type RequestFn = <
|
|
138
|
+
TData = unknown,
|
|
139
|
+
TError = unknown,
|
|
140
|
+
ThrowOnError extends boolean = false,
|
|
141
|
+
>(
|
|
142
|
+
options: Omit<RequestOptions<TData, ThrowOnError>, 'method'> &
|
|
143
|
+
Pick<Required<RequestOptions<TData, ThrowOnError>>, 'method'>,
|
|
144
|
+
) => RequestResult<TData, TError, ThrowOnError>;
|
|
145
|
+
|
|
146
|
+
type BuildUrlFn = <
|
|
147
|
+
TData extends {
|
|
148
|
+
body?: unknown;
|
|
149
|
+
path?: Record<string, unknown>;
|
|
150
|
+
query?: Record<string, unknown>;
|
|
151
|
+
url: string;
|
|
152
|
+
},
|
|
153
|
+
>(
|
|
154
|
+
options: TData & Options<TData>,
|
|
155
|
+
) => string;
|
|
156
|
+
|
|
157
|
+
export type Client = CoreClient<
|
|
158
|
+
RequestFn,
|
|
159
|
+
Config,
|
|
160
|
+
MethodFn,
|
|
161
|
+
BuildUrlFn,
|
|
162
|
+
SseFn
|
|
163
|
+
> & {
|
|
164
|
+
instance: AxiosInstance;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The `createClientConfig()` function will be called on client initialization
|
|
169
|
+
* and the returned object will become the client's initial configuration.
|
|
170
|
+
*
|
|
171
|
+
* You may want to initialize your client this way instead of calling
|
|
172
|
+
* `setConfig()`. This is useful for example if you're using Next.js
|
|
173
|
+
* to ensure your client always has the correct values.
|
|
174
|
+
*/
|
|
175
|
+
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (
|
|
176
|
+
override?: Config<ClientOptions & T>,
|
|
177
|
+
) => Config<Required<ClientOptions> & T>;
|
|
178
|
+
|
|
179
|
+
export interface TDataShape {
|
|
180
|
+
body?: unknown;
|
|
181
|
+
headers?: unknown;
|
|
182
|
+
path?: unknown;
|
|
183
|
+
query?: unknown;
|
|
184
|
+
url: string;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
188
|
+
|
|
189
|
+
export type Options<
|
|
190
|
+
TData extends TDataShape = TDataShape,
|
|
191
|
+
ThrowOnError extends boolean = boolean,
|
|
192
|
+
TResponse = unknown,
|
|
193
|
+
> = OmitKeys<
|
|
194
|
+
RequestOptions<TResponse, ThrowOnError>,
|
|
195
|
+
'body' | 'path' | 'query' | 'url'
|
|
196
|
+
> &
|
|
197
|
+
([TData] extends [never] ? unknown : Omit<TData, 'url'>);
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import { getAuthToken } from '../core/auth.gen';
|
|
4
|
+
import type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
|
5
|
+
import {
|
|
6
|
+
serializeArrayParam,
|
|
7
|
+
serializeObjectParam,
|
|
8
|
+
serializePrimitiveParam,
|
|
9
|
+
} from '../core/pathSerializer.gen';
|
|
10
|
+
import { getUrl } from '../core/utils.gen';
|
|
11
|
+
import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';
|
|
12
|
+
|
|
13
|
+
export const createQuerySerializer = <T = unknown>({
|
|
14
|
+
parameters = {},
|
|
15
|
+
...args
|
|
16
|
+
}: QuerySerializerOptions = {}) => {
|
|
17
|
+
const querySerializer = (queryParams: T) => {
|
|
18
|
+
const search: string[] = [];
|
|
19
|
+
if (queryParams && typeof queryParams === 'object') {
|
|
20
|
+
for (const name in queryParams) {
|
|
21
|
+
const value = queryParams[name];
|
|
22
|
+
|
|
23
|
+
if (value === undefined || value === null) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const options = parameters[name] || args;
|
|
28
|
+
|
|
29
|
+
if (Array.isArray(value)) {
|
|
30
|
+
const serializedArray = serializeArrayParam({
|
|
31
|
+
allowReserved: options.allowReserved,
|
|
32
|
+
explode: true,
|
|
33
|
+
name,
|
|
34
|
+
style: 'form',
|
|
35
|
+
value,
|
|
36
|
+
...options.array,
|
|
37
|
+
});
|
|
38
|
+
if (serializedArray) search.push(serializedArray);
|
|
39
|
+
} else if (typeof value === 'object') {
|
|
40
|
+
const serializedObject = serializeObjectParam({
|
|
41
|
+
allowReserved: options.allowReserved,
|
|
42
|
+
explode: true,
|
|
43
|
+
name,
|
|
44
|
+
style: 'deepObject',
|
|
45
|
+
value: value as Record<string, unknown>,
|
|
46
|
+
...options.object,
|
|
47
|
+
});
|
|
48
|
+
if (serializedObject) search.push(serializedObject);
|
|
49
|
+
} else {
|
|
50
|
+
const serializedPrimitive = serializePrimitiveParam({
|
|
51
|
+
allowReserved: options.allowReserved,
|
|
52
|
+
name,
|
|
53
|
+
value: value as string,
|
|
54
|
+
});
|
|
55
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return search.join('&');
|
|
60
|
+
};
|
|
61
|
+
return querySerializer;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const checkForExistence = (
|
|
65
|
+
options: Pick<RequestOptions, 'auth' | 'query'> & {
|
|
66
|
+
headers: Record<any, unknown>;
|
|
67
|
+
},
|
|
68
|
+
name?: string,
|
|
69
|
+
): boolean => {
|
|
70
|
+
if (!name) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (name in options.headers || options.query?.[name]) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
if (
|
|
77
|
+
'Cookie' in options.headers &&
|
|
78
|
+
options.headers['Cookie'] &&
|
|
79
|
+
typeof options.headers['Cookie'] === 'string'
|
|
80
|
+
) {
|
|
81
|
+
return options.headers['Cookie'].includes(`${name}=`);
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const setAuthParams = async ({
|
|
87
|
+
security,
|
|
88
|
+
...options
|
|
89
|
+
}: Pick<Required<RequestOptions>, 'security'> &
|
|
90
|
+
Pick<RequestOptions, 'auth' | 'query'> & {
|
|
91
|
+
headers: Record<any, unknown>;
|
|
92
|
+
}) => {
|
|
93
|
+
for (const auth of security) {
|
|
94
|
+
if (checkForExistence(options, auth.name)) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const token = await getAuthToken(auth, options.auth);
|
|
98
|
+
|
|
99
|
+
if (!token) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const name = auth.name ?? 'Authorization';
|
|
104
|
+
|
|
105
|
+
switch (auth.in) {
|
|
106
|
+
case 'query':
|
|
107
|
+
if (!options.query) {
|
|
108
|
+
options.query = {};
|
|
109
|
+
}
|
|
110
|
+
options.query[name] = token;
|
|
111
|
+
break;
|
|
112
|
+
case 'cookie': {
|
|
113
|
+
const value = `${name}=${token}`;
|
|
114
|
+
if ('Cookie' in options.headers && options.headers['Cookie']) {
|
|
115
|
+
options.headers['Cookie'] = `${options.headers['Cookie']}; ${value}`;
|
|
116
|
+
} else {
|
|
117
|
+
options.headers['Cookie'] = value;
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case 'header':
|
|
122
|
+
default:
|
|
123
|
+
options.headers[name] = token;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export const buildUrl: Client['buildUrl'] = (options) => {
|
|
130
|
+
const instanceBaseUrl = options.axios?.defaults?.baseURL;
|
|
131
|
+
|
|
132
|
+
const baseUrl =
|
|
133
|
+
!!options.baseURL && typeof options.baseURL === 'string'
|
|
134
|
+
? options.baseURL
|
|
135
|
+
: instanceBaseUrl;
|
|
136
|
+
|
|
137
|
+
return getUrl({
|
|
138
|
+
baseUrl: baseUrl as string,
|
|
139
|
+
path: options.path,
|
|
140
|
+
// let `paramsSerializer()` handle query params if it exists
|
|
141
|
+
query: !options.paramsSerializer ? options.query : undefined,
|
|
142
|
+
querySerializer:
|
|
143
|
+
typeof options.querySerializer === 'function'
|
|
144
|
+
? options.querySerializer
|
|
145
|
+
: createQuerySerializer(options.querySerializer),
|
|
146
|
+
url: options.url,
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export const mergeConfigs = (a: Config, b: Config): Config => {
|
|
151
|
+
const config = { ...a, ...b };
|
|
152
|
+
config.headers = mergeHeaders(a.headers, b.headers);
|
|
153
|
+
return config;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Special Axios headers keywords allowing to set headers by request method.
|
|
158
|
+
*/
|
|
159
|
+
export const axiosHeadersKeywords = [
|
|
160
|
+
'common',
|
|
161
|
+
'delete',
|
|
162
|
+
'get',
|
|
163
|
+
'head',
|
|
164
|
+
'patch',
|
|
165
|
+
'post',
|
|
166
|
+
'put',
|
|
167
|
+
] as const;
|
|
168
|
+
|
|
169
|
+
export const mergeHeaders = (
|
|
170
|
+
...headers: Array<Required<Config>['headers'] | undefined>
|
|
171
|
+
): Record<any, unknown> => {
|
|
172
|
+
const mergedHeaders: Record<any, unknown> = {};
|
|
173
|
+
for (const header of headers) {
|
|
174
|
+
if (!header || typeof header !== 'object') {
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const iterator = Object.entries(header);
|
|
179
|
+
|
|
180
|
+
for (const [key, value] of iterator) {
|
|
181
|
+
if (
|
|
182
|
+
axiosHeadersKeywords.includes(
|
|
183
|
+
key as (typeof axiosHeadersKeywords)[number],
|
|
184
|
+
) &&
|
|
185
|
+
typeof value === 'object'
|
|
186
|
+
) {
|
|
187
|
+
mergedHeaders[key] = {
|
|
188
|
+
...(mergedHeaders[key] as Record<any, unknown>),
|
|
189
|
+
...value,
|
|
190
|
+
};
|
|
191
|
+
} else if (value === null) {
|
|
192
|
+
delete mergedHeaders[key];
|
|
193
|
+
} else if (Array.isArray(value)) {
|
|
194
|
+
for (const v of value) {
|
|
195
|
+
// @ts-expect-error
|
|
196
|
+
mergedHeaders[key] = [...(mergedHeaders[key] ?? []), v as string];
|
|
197
|
+
}
|
|
198
|
+
} else if (value !== undefined) {
|
|
199
|
+
// assume object headers are meant to be JSON stringified, i.e. their
|
|
200
|
+
// content value in OpenAPI specification is 'application/json'
|
|
201
|
+
mergedHeaders[key] =
|
|
202
|
+
typeof value === 'object' ? JSON.stringify(value) : (value as string);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return mergedHeaders;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export const createConfig = <T extends ClientOptions = ClientOptions>(
|
|
210
|
+
override: Config<Omit<ClientOptions, keyof T> & T> = {},
|
|
211
|
+
): Config<Omit<ClientOptions, keyof T> & T> => ({
|
|
212
|
+
...override,
|
|
213
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import { type ClientOptions, type Config, createClient, createConfig } from './client';
|
|
4
|
+
import type { ClientOptions as ClientOptions2 } from './types.gen';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `createClientConfig()` function will be called on client initialization
|
|
8
|
+
* and the returned object will become the client's initial configuration.
|
|
9
|
+
*
|
|
10
|
+
* You may want to initialize your client this way instead of calling
|
|
11
|
+
* `setConfig()`. This is useful for example if you're using Next.js
|
|
12
|
+
* to ensure your client always has the correct values.
|
|
13
|
+
*/
|
|
14
|
+
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
|
15
|
+
|
|
16
|
+
export const client = createClient(createConfig<ClientOptions2>({ baseURL: 'https://api.example.com' }));
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
export type AuthToken = string | undefined;
|
|
4
|
+
|
|
5
|
+
export interface Auth {
|
|
6
|
+
/**
|
|
7
|
+
* Which part of the request do we use to send the auth?
|
|
8
|
+
*
|
|
9
|
+
* @default 'header'
|
|
10
|
+
*/
|
|
11
|
+
in?: 'header' | 'query' | 'cookie';
|
|
12
|
+
/**
|
|
13
|
+
* Header or query parameter name.
|
|
14
|
+
*
|
|
15
|
+
* @default 'Authorization'
|
|
16
|
+
*/
|
|
17
|
+
name?: string;
|
|
18
|
+
scheme?: 'basic' | 'bearer';
|
|
19
|
+
type: 'apiKey' | 'http';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const getAuthToken = async (
|
|
23
|
+
auth: Auth,
|
|
24
|
+
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,
|
|
25
|
+
): Promise<string | undefined> => {
|
|
26
|
+
const token =
|
|
27
|
+
typeof callback === 'function' ? await callback(auth) : callback;
|
|
28
|
+
|
|
29
|
+
if (!token) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (auth.scheme === 'bearer') {
|
|
34
|
+
return `Bearer ${token}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (auth.scheme === 'basic') {
|
|
38
|
+
return `Basic ${btoa(token)}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return token;
|
|
42
|
+
};
|