@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,128 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import { createSseClient } from '../core/serverSentEvents.gen';
|
|
4
|
+
import { getValidRequestBody } from '../core/utils.gen';
|
|
5
|
+
import { buildUrl, createConfig, mergeConfigs, mergeHeaders, setAuthParams, } from './utils.gen';
|
|
6
|
+
export const createClient = (config = {}) => {
|
|
7
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
8
|
+
let instance;
|
|
9
|
+
if (_config.axios && !('Axios' in _config.axios)) {
|
|
10
|
+
instance = _config.axios;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
|
+
const { auth, ...configWithoutAuth } = _config;
|
|
15
|
+
instance = axios.create(configWithoutAuth);
|
|
16
|
+
}
|
|
17
|
+
const getConfig = () => ({ ..._config });
|
|
18
|
+
const setConfig = (config) => {
|
|
19
|
+
_config = mergeConfigs(_config, config);
|
|
20
|
+
instance.defaults = {
|
|
21
|
+
...instance.defaults,
|
|
22
|
+
..._config,
|
|
23
|
+
headers: mergeHeaders(instance.defaults.headers, _config.headers),
|
|
24
|
+
};
|
|
25
|
+
return getConfig();
|
|
26
|
+
};
|
|
27
|
+
const beforeRequest = async (options) => {
|
|
28
|
+
const opts = {
|
|
29
|
+
..._config,
|
|
30
|
+
...options,
|
|
31
|
+
axios: options.axios ?? _config.axios ?? instance,
|
|
32
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
33
|
+
};
|
|
34
|
+
if (opts.security) {
|
|
35
|
+
await setAuthParams({
|
|
36
|
+
...opts,
|
|
37
|
+
security: opts.security,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (opts.requestValidator) {
|
|
41
|
+
await opts.requestValidator(opts);
|
|
42
|
+
}
|
|
43
|
+
if (opts.body !== undefined && opts.bodySerializer) {
|
|
44
|
+
opts.body = opts.bodySerializer(opts.body);
|
|
45
|
+
}
|
|
46
|
+
const url = buildUrl(opts);
|
|
47
|
+
return { opts, url };
|
|
48
|
+
};
|
|
49
|
+
const request = async (options) => {
|
|
50
|
+
const { opts, url } = await beforeRequest(options);
|
|
51
|
+
try {
|
|
52
|
+
// assign Axios here for consistency with fetch
|
|
53
|
+
const _axios = opts.axios;
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
55
|
+
const { auth, ...optsWithoutAuth } = opts;
|
|
56
|
+
const response = await _axios({
|
|
57
|
+
...optsWithoutAuth,
|
|
58
|
+
baseURL: '', // the baseURL is already included in `url`
|
|
59
|
+
data: getValidRequestBody(opts),
|
|
60
|
+
headers: opts.headers,
|
|
61
|
+
// let `paramsSerializer()` handle query params if it exists
|
|
62
|
+
params: opts.paramsSerializer ? opts.query : undefined,
|
|
63
|
+
url,
|
|
64
|
+
});
|
|
65
|
+
let { data } = response;
|
|
66
|
+
if (opts.responseType === 'json') {
|
|
67
|
+
if (opts.responseValidator) {
|
|
68
|
+
await opts.responseValidator(data);
|
|
69
|
+
}
|
|
70
|
+
if (opts.responseTransformer) {
|
|
71
|
+
data = await opts.responseTransformer(data);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
...response,
|
|
76
|
+
data: data ?? {},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
const e = error;
|
|
81
|
+
if (opts.throwOnError) {
|
|
82
|
+
throw e;
|
|
83
|
+
}
|
|
84
|
+
e.error = e.response?.data ?? {};
|
|
85
|
+
return e;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
89
|
+
const makeSseFn = (method) => async (options) => {
|
|
90
|
+
const { opts, url } = await beforeRequest(options);
|
|
91
|
+
return createSseClient({
|
|
92
|
+
...opts,
|
|
93
|
+
body: opts.body,
|
|
94
|
+
headers: opts.headers,
|
|
95
|
+
method,
|
|
96
|
+
serializedBody: getValidRequestBody(opts),
|
|
97
|
+
signal: opts.signal,
|
|
98
|
+
url,
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
return {
|
|
102
|
+
buildUrl,
|
|
103
|
+
connect: makeMethodFn('CONNECT'),
|
|
104
|
+
delete: makeMethodFn('DELETE'),
|
|
105
|
+
get: makeMethodFn('GET'),
|
|
106
|
+
getConfig,
|
|
107
|
+
head: makeMethodFn('HEAD'),
|
|
108
|
+
instance,
|
|
109
|
+
options: makeMethodFn('OPTIONS'),
|
|
110
|
+
patch: makeMethodFn('PATCH'),
|
|
111
|
+
post: makeMethodFn('POST'),
|
|
112
|
+
put: makeMethodFn('PUT'),
|
|
113
|
+
request,
|
|
114
|
+
setConfig,
|
|
115
|
+
sse: {
|
|
116
|
+
connect: makeSseFn('CONNECT'),
|
|
117
|
+
delete: makeSseFn('DELETE'),
|
|
118
|
+
get: makeSseFn('GET'),
|
|
119
|
+
head: makeSseFn('HEAD'),
|
|
120
|
+
options: makeSseFn('OPTIONS'),
|
|
121
|
+
patch: makeSseFn('PATCH'),
|
|
122
|
+
post: makeSseFn('POST'),
|
|
123
|
+
put: makeSseFn('PUT'),
|
|
124
|
+
trace: makeSseFn('TRACE'),
|
|
125
|
+
},
|
|
126
|
+
trace: makeMethodFn('TRACE'),
|
|
127
|
+
};
|
|
128
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { Auth } from '../core/auth.gen';
|
|
2
|
+
export type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
|
3
|
+
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from '../core/bodySerializer.gen';
|
|
4
|
+
export { buildClientParams } from '../core/params.gen';
|
|
5
|
+
export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen';
|
|
6
|
+
export { createClient } from './client.gen';
|
|
7
|
+
export type { Client, ClientOptions, Config, CreateClientConfig, Options, RequestOptions, RequestResult, TDataShape, } from './types.gen';
|
|
8
|
+
export { createConfig } from './utils.gen';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from '../core/bodySerializer.gen';
|
|
3
|
+
export { buildClientParams } from '../core/params.gen';
|
|
4
|
+
export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen';
|
|
5
|
+
export { createClient } from './client.gen';
|
|
6
|
+
export { createConfig } from './utils.gen';
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { AxiosError, AxiosInstance, AxiosRequestHeaders, AxiosResponse, AxiosStatic, CreateAxiosDefaults } from 'axios';
|
|
2
|
+
import type { Auth } from '../core/auth.gen';
|
|
3
|
+
import type { ServerSentEventsOptions, ServerSentEventsResult } from '../core/serverSentEvents.gen';
|
|
4
|
+
import type { Client as CoreClient, Config as CoreConfig } from '../core/types.gen';
|
|
5
|
+
export interface Config<T extends ClientOptions = ClientOptions> extends Omit<CreateAxiosDefaults, 'auth' | 'baseURL' | 'headers' | 'method'>, CoreConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Axios implementation. You can use this option to provide either an
|
|
8
|
+
* `AxiosStatic` or an `AxiosInstance`.
|
|
9
|
+
*
|
|
10
|
+
* @default axios
|
|
11
|
+
*/
|
|
12
|
+
axios?: AxiosStatic | AxiosInstance;
|
|
13
|
+
/**
|
|
14
|
+
* Base URL for all requests made by this client.
|
|
15
|
+
*/
|
|
16
|
+
baseURL?: T['baseURL'];
|
|
17
|
+
/**
|
|
18
|
+
* An object containing any HTTP headers that you want to pre-populate your
|
|
19
|
+
* `Headers` object with.
|
|
20
|
+
*
|
|
21
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
|
22
|
+
*/
|
|
23
|
+
headers?: AxiosRequestHeaders | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
|
|
24
|
+
/**
|
|
25
|
+
* Throw an error instead of returning it in the response?
|
|
26
|
+
*
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
throwOnError?: T['throwOnError'];
|
|
30
|
+
}
|
|
31
|
+
export interface RequestOptions<TData = unknown, ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
|
|
32
|
+
throwOnError: ThrowOnError;
|
|
33
|
+
}>, Pick<ServerSentEventsOptions<TData>, 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
|
|
34
|
+
/**
|
|
35
|
+
* Any body that you want to add to your request.
|
|
36
|
+
*
|
|
37
|
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
|
|
38
|
+
*/
|
|
39
|
+
body?: unknown;
|
|
40
|
+
path?: Record<string, unknown>;
|
|
41
|
+
query?: Record<string, unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* Security mechanism(s) to use for the request.
|
|
44
|
+
*/
|
|
45
|
+
security?: ReadonlyArray<Auth>;
|
|
46
|
+
url: Url;
|
|
47
|
+
}
|
|
48
|
+
export interface ClientOptions {
|
|
49
|
+
baseURL?: string;
|
|
50
|
+
throwOnError?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean> = ThrowOnError extends true ? Promise<AxiosResponse<TData extends Record<string, unknown> ? TData[keyof TData] : TData>> : Promise<(AxiosResponse<TData extends Record<string, unknown> ? TData[keyof TData] : TData> & {
|
|
53
|
+
error: undefined;
|
|
54
|
+
}) | (AxiosError<TError extends Record<string, unknown> ? TError[keyof TError] : TError> & {
|
|
55
|
+
data: undefined;
|
|
56
|
+
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
|
|
57
|
+
})>;
|
|
58
|
+
type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions<TData, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError>;
|
|
59
|
+
type SseFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions<TData, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData, TError>>;
|
|
60
|
+
type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions<TData, ThrowOnError>, 'method'> & Pick<Required<RequestOptions<TData, ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError>;
|
|
61
|
+
type BuildUrlFn = <TData extends {
|
|
62
|
+
body?: unknown;
|
|
63
|
+
path?: Record<string, unknown>;
|
|
64
|
+
query?: Record<string, unknown>;
|
|
65
|
+
url: string;
|
|
66
|
+
}>(options: TData & Options<TData>) => string;
|
|
67
|
+
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
|
|
68
|
+
instance: AxiosInstance;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* The `createClientConfig()` function will be called on client initialization
|
|
72
|
+
* and the returned object will become the client's initial configuration.
|
|
73
|
+
*
|
|
74
|
+
* You may want to initialize your client this way instead of calling
|
|
75
|
+
* `setConfig()`. This is useful for example if you're using Next.js
|
|
76
|
+
* to ensure your client always has the correct values.
|
|
77
|
+
*/
|
|
78
|
+
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
|
79
|
+
export interface TDataShape {
|
|
80
|
+
body?: unknown;
|
|
81
|
+
headers?: unknown;
|
|
82
|
+
path?: unknown;
|
|
83
|
+
query?: unknown;
|
|
84
|
+
url: string;
|
|
85
|
+
}
|
|
86
|
+
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
87
|
+
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = OmitKeys<RequestOptions<TResponse, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
|
|
88
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
|
2
|
+
import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';
|
|
3
|
+
export declare const createQuerySerializer: <T = unknown>({ parameters, ...args }?: QuerySerializerOptions) => (queryParams: T) => string;
|
|
4
|
+
export declare const setAuthParams: ({ security, ...options }: Pick<Required<RequestOptions>, "security"> & Pick<RequestOptions, "auth" | "query"> & {
|
|
5
|
+
headers: Record<any, unknown>;
|
|
6
|
+
}) => Promise<void>;
|
|
7
|
+
export declare const buildUrl: Client['buildUrl'];
|
|
8
|
+
export declare const mergeConfigs: (a: Config, b: Config) => Config;
|
|
9
|
+
/**
|
|
10
|
+
* Special Axios headers keywords allowing to set headers by request method.
|
|
11
|
+
*/
|
|
12
|
+
export declare const axiosHeadersKeywords: readonly ["common", "delete", "get", "head", "patch", "post", "put"];
|
|
13
|
+
export declare const mergeHeaders: (...headers: Array<Required<Config>["headers"] | undefined>) => Record<any, unknown>;
|
|
14
|
+
export declare const createConfig: <T extends ClientOptions = ClientOptions>(override?: Config<Omit<ClientOptions, keyof T> & T>) => Config<Omit<ClientOptions, keyof T> & T>;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
import { getAuthToken } from '../core/auth.gen';
|
|
3
|
+
import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam, } from '../core/pathSerializer.gen';
|
|
4
|
+
import { getUrl } from '../core/utils.gen';
|
|
5
|
+
export const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
6
|
+
const querySerializer = (queryParams) => {
|
|
7
|
+
const search = [];
|
|
8
|
+
if (queryParams && typeof queryParams === 'object') {
|
|
9
|
+
for (const name in queryParams) {
|
|
10
|
+
const value = queryParams[name];
|
|
11
|
+
if (value === undefined || value === null) {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
const options = parameters[name] || args;
|
|
15
|
+
if (Array.isArray(value)) {
|
|
16
|
+
const serializedArray = serializeArrayParam({
|
|
17
|
+
allowReserved: options.allowReserved,
|
|
18
|
+
explode: true,
|
|
19
|
+
name,
|
|
20
|
+
style: 'form',
|
|
21
|
+
value,
|
|
22
|
+
...options.array,
|
|
23
|
+
});
|
|
24
|
+
if (serializedArray)
|
|
25
|
+
search.push(serializedArray);
|
|
26
|
+
}
|
|
27
|
+
else if (typeof value === 'object') {
|
|
28
|
+
const serializedObject = serializeObjectParam({
|
|
29
|
+
allowReserved: options.allowReserved,
|
|
30
|
+
explode: true,
|
|
31
|
+
name,
|
|
32
|
+
style: 'deepObject',
|
|
33
|
+
value: value,
|
|
34
|
+
...options.object,
|
|
35
|
+
});
|
|
36
|
+
if (serializedObject)
|
|
37
|
+
search.push(serializedObject);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const serializedPrimitive = serializePrimitiveParam({
|
|
41
|
+
allowReserved: options.allowReserved,
|
|
42
|
+
name,
|
|
43
|
+
value: value,
|
|
44
|
+
});
|
|
45
|
+
if (serializedPrimitive)
|
|
46
|
+
search.push(serializedPrimitive);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return search.join('&');
|
|
51
|
+
};
|
|
52
|
+
return querySerializer;
|
|
53
|
+
};
|
|
54
|
+
const checkForExistence = (options, name) => {
|
|
55
|
+
if (!name) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
if (name in options.headers || options.query?.[name]) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
if ('Cookie' in options.headers &&
|
|
62
|
+
options.headers['Cookie'] &&
|
|
63
|
+
typeof options.headers['Cookie'] === 'string') {
|
|
64
|
+
return options.headers['Cookie'].includes(`${name}=`);
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
};
|
|
68
|
+
export const setAuthParams = async ({ security, ...options }) => {
|
|
69
|
+
for (const auth of security) {
|
|
70
|
+
if (checkForExistence(options, auth.name)) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const token = await getAuthToken(auth, options.auth);
|
|
74
|
+
if (!token) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const name = auth.name ?? 'Authorization';
|
|
78
|
+
switch (auth.in) {
|
|
79
|
+
case 'query':
|
|
80
|
+
if (!options.query) {
|
|
81
|
+
options.query = {};
|
|
82
|
+
}
|
|
83
|
+
options.query[name] = token;
|
|
84
|
+
break;
|
|
85
|
+
case 'cookie': {
|
|
86
|
+
const value = `${name}=${token}`;
|
|
87
|
+
if ('Cookie' in options.headers && options.headers['Cookie']) {
|
|
88
|
+
options.headers['Cookie'] = `${options.headers['Cookie']}; ${value}`;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
options.headers['Cookie'] = value;
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
case 'header':
|
|
96
|
+
default:
|
|
97
|
+
options.headers[name] = token;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
export const buildUrl = (options) => {
|
|
103
|
+
const instanceBaseUrl = options.axios?.defaults?.baseURL;
|
|
104
|
+
const baseUrl = !!options.baseURL && typeof options.baseURL === 'string'
|
|
105
|
+
? options.baseURL
|
|
106
|
+
: instanceBaseUrl;
|
|
107
|
+
return getUrl({
|
|
108
|
+
baseUrl: baseUrl,
|
|
109
|
+
path: options.path,
|
|
110
|
+
// let `paramsSerializer()` handle query params if it exists
|
|
111
|
+
query: !options.paramsSerializer ? options.query : undefined,
|
|
112
|
+
querySerializer: typeof options.querySerializer === 'function'
|
|
113
|
+
? options.querySerializer
|
|
114
|
+
: createQuerySerializer(options.querySerializer),
|
|
115
|
+
url: options.url,
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
export const mergeConfigs = (a, b) => {
|
|
119
|
+
const config = { ...a, ...b };
|
|
120
|
+
config.headers = mergeHeaders(a.headers, b.headers);
|
|
121
|
+
return config;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Special Axios headers keywords allowing to set headers by request method.
|
|
125
|
+
*/
|
|
126
|
+
export const axiosHeadersKeywords = [
|
|
127
|
+
'common',
|
|
128
|
+
'delete',
|
|
129
|
+
'get',
|
|
130
|
+
'head',
|
|
131
|
+
'patch',
|
|
132
|
+
'post',
|
|
133
|
+
'put',
|
|
134
|
+
];
|
|
135
|
+
export const mergeHeaders = (...headers) => {
|
|
136
|
+
const mergedHeaders = {};
|
|
137
|
+
for (const header of headers) {
|
|
138
|
+
if (!header || typeof header !== 'object') {
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
const iterator = Object.entries(header);
|
|
142
|
+
for (const [key, value] of iterator) {
|
|
143
|
+
if (axiosHeadersKeywords.includes(key) &&
|
|
144
|
+
typeof value === 'object') {
|
|
145
|
+
mergedHeaders[key] = {
|
|
146
|
+
...mergedHeaders[key],
|
|
147
|
+
...value,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
else if (value === null) {
|
|
151
|
+
delete mergedHeaders[key];
|
|
152
|
+
}
|
|
153
|
+
else if (Array.isArray(value)) {
|
|
154
|
+
for (const v of value) {
|
|
155
|
+
// @ts-expect-error
|
|
156
|
+
mergedHeaders[key] = [...(mergedHeaders[key] ?? []), v];
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
else if (value !== undefined) {
|
|
160
|
+
// assume object headers are meant to be JSON stringified, i.e. their
|
|
161
|
+
// content value in OpenAPI specification is 'application/json'
|
|
162
|
+
mergedHeaders[key] =
|
|
163
|
+
typeof value === 'object' ? JSON.stringify(value) : value;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return mergedHeaders;
|
|
168
|
+
};
|
|
169
|
+
export const createConfig = (override = {}) => ({
|
|
170
|
+
...override,
|
|
171
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ClientOptions, type Config } from './client';
|
|
2
|
+
import type { ClientOptions as ClientOptions2 } from './types.gen';
|
|
3
|
+
/**
|
|
4
|
+
* The `createClientConfig()` function will be called on client initialization
|
|
5
|
+
* and the returned object will become the client's initial configuration.
|
|
6
|
+
*
|
|
7
|
+
* You may want to initialize your client this way instead of calling
|
|
8
|
+
* `setConfig()`. This is useful for example if you're using Next.js
|
|
9
|
+
* to ensure your client always has the correct values.
|
|
10
|
+
*/
|
|
11
|
+
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
|
12
|
+
export declare const client: import("./client").Client;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type AuthToken = string | undefined;
|
|
2
|
+
export interface Auth {
|
|
3
|
+
/**
|
|
4
|
+
* Which part of the request do we use to send the auth?
|
|
5
|
+
*
|
|
6
|
+
* @default 'header'
|
|
7
|
+
*/
|
|
8
|
+
in?: 'header' | 'query' | 'cookie';
|
|
9
|
+
/**
|
|
10
|
+
* Header or query parameter name.
|
|
11
|
+
*
|
|
12
|
+
* @default 'Authorization'
|
|
13
|
+
*/
|
|
14
|
+
name?: string;
|
|
15
|
+
scheme?: 'basic' | 'bearer';
|
|
16
|
+
type: 'apiKey' | 'http';
|
|
17
|
+
}
|
|
18
|
+
export declare const getAuthToken: (auth: Auth, callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken) => Promise<string | undefined>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
export const getAuthToken = async (auth, callback) => {
|
|
3
|
+
const token = typeof callback === 'function' ? await callback(auth) : callback;
|
|
4
|
+
if (!token) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
if (auth.scheme === 'bearer') {
|
|
8
|
+
return `Bearer ${token}`;
|
|
9
|
+
}
|
|
10
|
+
if (auth.scheme === 'basic') {
|
|
11
|
+
return `Basic ${btoa(token)}`;
|
|
12
|
+
}
|
|
13
|
+
return token;
|
|
14
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ArrayStyle, ObjectStyle, SerializerOptions } from './pathSerializer.gen';
|
|
2
|
+
export type QuerySerializer = (query: Record<string, unknown>) => string;
|
|
3
|
+
export type BodySerializer = (body: any) => any;
|
|
4
|
+
type QuerySerializerOptionsObject = {
|
|
5
|
+
allowReserved?: boolean;
|
|
6
|
+
array?: Partial<SerializerOptions<ArrayStyle>>;
|
|
7
|
+
object?: Partial<SerializerOptions<ObjectStyle>>;
|
|
8
|
+
};
|
|
9
|
+
export type QuerySerializerOptions = QuerySerializerOptionsObject & {
|
|
10
|
+
/**
|
|
11
|
+
* Per-parameter serialization overrides. When provided, these settings
|
|
12
|
+
* override the global array/object settings for specific parameter names.
|
|
13
|
+
*/
|
|
14
|
+
parameters?: Record<string, QuerySerializerOptionsObject>;
|
|
15
|
+
};
|
|
16
|
+
export declare const formDataBodySerializer: {
|
|
17
|
+
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => FormData;
|
|
18
|
+
};
|
|
19
|
+
export declare const jsonBodySerializer: {
|
|
20
|
+
bodySerializer: <T>(body: T) => string;
|
|
21
|
+
};
|
|
22
|
+
export declare const urlSearchParamsBodySerializer: {
|
|
23
|
+
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => string;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
const serializeFormDataPair = (data, key, value) => {
|
|
3
|
+
if (typeof value === 'string' || value instanceof Blob) {
|
|
4
|
+
data.append(key, value);
|
|
5
|
+
}
|
|
6
|
+
else if (value instanceof Date) {
|
|
7
|
+
data.append(key, value.toISOString());
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
data.append(key, JSON.stringify(value));
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const serializeUrlSearchParamsPair = (data, key, value) => {
|
|
14
|
+
if (typeof value === 'string') {
|
|
15
|
+
data.append(key, value);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
data.append(key, JSON.stringify(value));
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export const formDataBodySerializer = {
|
|
22
|
+
bodySerializer: (body) => {
|
|
23
|
+
const data = new FormData();
|
|
24
|
+
Object.entries(body).forEach(([key, value]) => {
|
|
25
|
+
if (value === undefined || value === null) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (Array.isArray(value)) {
|
|
29
|
+
value.forEach((v) => serializeFormDataPair(data, key, v));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
serializeFormDataPair(data, key, value);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return data;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
export const jsonBodySerializer = {
|
|
39
|
+
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === 'bigint' ? value.toString() : value),
|
|
40
|
+
};
|
|
41
|
+
export const urlSearchParamsBodySerializer = {
|
|
42
|
+
bodySerializer: (body) => {
|
|
43
|
+
const data = new URLSearchParams();
|
|
44
|
+
Object.entries(body).forEach(([key, value]) => {
|
|
45
|
+
if (value === undefined || value === null) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (Array.isArray(value)) {
|
|
49
|
+
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
serializeUrlSearchParamsPair(data, key, value);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return data.toString();
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
type Slot = 'body' | 'headers' | 'path' | 'query';
|
|
2
|
+
export type Field = {
|
|
3
|
+
in: Exclude<Slot, 'body'>;
|
|
4
|
+
/**
|
|
5
|
+
* Field name. This is the name we want the user to see and use.
|
|
6
|
+
*/
|
|
7
|
+
key: string;
|
|
8
|
+
/**
|
|
9
|
+
* Field mapped name. This is the name we want to use in the request.
|
|
10
|
+
* If omitted, we use the same value as `key`.
|
|
11
|
+
*/
|
|
12
|
+
map?: string;
|
|
13
|
+
} | {
|
|
14
|
+
in: Extract<Slot, 'body'>;
|
|
15
|
+
/**
|
|
16
|
+
* Key isn't required for bodies.
|
|
17
|
+
*/
|
|
18
|
+
key?: string;
|
|
19
|
+
map?: string;
|
|
20
|
+
} | {
|
|
21
|
+
/**
|
|
22
|
+
* Field name. This is the name we want the user to see and use.
|
|
23
|
+
*/
|
|
24
|
+
key: string;
|
|
25
|
+
/**
|
|
26
|
+
* Field mapped name. This is the name we want to use in the request.
|
|
27
|
+
* If `in` is omitted, `map` aliases `key` to the transport layer.
|
|
28
|
+
*/
|
|
29
|
+
map: Slot;
|
|
30
|
+
};
|
|
31
|
+
export interface Fields {
|
|
32
|
+
allowExtra?: Partial<Record<Slot, boolean>>;
|
|
33
|
+
args?: ReadonlyArray<Field>;
|
|
34
|
+
}
|
|
35
|
+
export type FieldsConfig = ReadonlyArray<Field | Fields>;
|
|
36
|
+
interface Params {
|
|
37
|
+
body: unknown;
|
|
38
|
+
headers: Record<string, unknown>;
|
|
39
|
+
path: Record<string, unknown>;
|
|
40
|
+
query: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
export declare const buildClientParams: (args: ReadonlyArray<unknown>, fields: FieldsConfig) => Params;
|
|
43
|
+
export {};
|