@reverbia/sdk 1.0.0 → 1.1.0-next.20251230221037
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/README.md +290 -45
- package/dist/expo/index.cjs +3428 -0
- package/dist/expo/index.d.mts +1217 -0
- package/dist/expo/index.d.ts +1217 -0
- package/dist/expo/index.mjs +3395 -0
- package/dist/index.cjs +972 -0
- package/dist/index.d.mts +1514 -0
- package/dist/index.d.ts +1514 -0
- package/dist/index.mjs +934 -0
- package/dist/next/index.cjs +64 -0
- package/dist/next/index.d.mts +23 -0
- package/dist/next/index.d.ts +23 -0
- package/dist/next/index.mjs +39 -0
- package/dist/polyfills/index.cjs +61 -0
- package/dist/polyfills/index.d.mts +9 -0
- package/dist/polyfills/index.d.ts +9 -0
- package/dist/polyfills/index.mjs +34 -0
- package/dist/react/chunk-KUFGQF6E.mjs +290 -0
- package/dist/react/chunk-T56Y62G7.mjs +410 -0
- package/dist/react/index.cjs +7982 -0
- package/dist/react/index.d.mts +3139 -0
- package/dist/react/index.d.ts +3139 -0
- package/dist/react/index.mjs +7209 -0
- package/dist/react/storage-Z2NBANCK.mjs +29 -0
- package/dist/react/useEncryption-5RTXKDNZ.mjs +31 -0
- package/dist/vercel/index.cjs +86 -0
- package/dist/vercel/index.d.mts +119 -0
- package/dist/vercel/index.d.ts +119 -0
- package/dist/vercel/index.mjs +57 -0
- package/package.json +91 -16
- package/dist/cjs/client/client/client.gen.d.ts +0 -2
- package/dist/cjs/client/client/client.gen.js +0 -203
- package/dist/cjs/client/client/index.d.ts +0 -8
- package/dist/cjs/client/client/index.js +0 -16
- package/dist/cjs/client/client/types.gen.d.ts +0 -99
- package/dist/cjs/client/client/types.gen.js +0 -3
- package/dist/cjs/client/client/utils.gen.d.ts +0 -40
- package/dist/cjs/client/client/utils.gen.js +0 -314
- package/dist/cjs/client/client.gen.d.ts +0 -12
- package/dist/cjs/client/client.gen.js +0 -6
- package/dist/cjs/client/core/auth.gen.d.ts +0 -18
- package/dist/cjs/client/core/auth.gen.js +0 -18
- package/dist/cjs/client/core/bodySerializer.gen.d.ts +0 -25
- package/dist/cjs/client/core/bodySerializer.gen.js +0 -60
- package/dist/cjs/client/core/params.gen.d.ts +0 -43
- package/dist/cjs/client/core/params.gen.js +0 -104
- package/dist/cjs/client/core/pathSerializer.gen.d.ts +0 -33
- package/dist/cjs/client/core/pathSerializer.gen.js +0 -123
- package/dist/cjs/client/core/queryKeySerializer.gen.d.ts +0 -18
- package/dist/cjs/client/core/queryKeySerializer.gen.js +0 -105
- package/dist/cjs/client/core/serverSentEvents.gen.d.ts +0 -71
- package/dist/cjs/client/core/serverSentEvents.gen.js +0 -139
- package/dist/cjs/client/core/types.gen.d.ts +0 -78
- package/dist/cjs/client/core/types.gen.js +0 -3
- package/dist/cjs/client/core/utils.gen.d.ts +0 -19
- package/dist/cjs/client/core/utils.gen.js +0 -93
- package/dist/cjs/client/index.d.ts +0 -2
- package/dist/cjs/client/index.js +0 -18
- package/dist/cjs/client/sdk.gen.d.ts +0 -27
- package/dist/cjs/client/sdk.gen.js +0 -33
- package/dist/cjs/client/types.gen.d.ts +0 -120
- package/dist/cjs/client/types.gen.js +0 -3
- package/dist/esm/client/client/client.gen.d.ts +0 -2
- package/dist/esm/client/client/client.gen.js +0 -199
- package/dist/esm/client/client/index.d.ts +0 -8
- package/dist/esm/client/client/index.js +0 -6
- package/dist/esm/client/client/types.gen.d.ts +0 -99
- package/dist/esm/client/client/types.gen.js +0 -2
- package/dist/esm/client/client/utils.gen.d.ts +0 -40
- package/dist/esm/client/client/utils.gen.js +0 -302
- package/dist/esm/client/client.gen.d.ts +0 -12
- package/dist/esm/client/client.gen.js +0 -3
- package/dist/esm/client/core/auth.gen.d.ts +0 -18
- package/dist/esm/client/core/auth.gen.js +0 -14
- package/dist/esm/client/core/bodySerializer.gen.d.ts +0 -25
- package/dist/esm/client/core/bodySerializer.gen.js +0 -57
- package/dist/esm/client/core/params.gen.d.ts +0 -43
- package/dist/esm/client/core/params.gen.js +0 -100
- package/dist/esm/client/core/pathSerializer.gen.d.ts +0 -33
- package/dist/esm/client/core/pathSerializer.gen.js +0 -114
- package/dist/esm/client/core/queryKeySerializer.gen.d.ts +0 -18
- package/dist/esm/client/core/queryKeySerializer.gen.js +0 -99
- package/dist/esm/client/core/serverSentEvents.gen.d.ts +0 -71
- package/dist/esm/client/core/serverSentEvents.gen.js +0 -135
- package/dist/esm/client/core/types.gen.d.ts +0 -78
- package/dist/esm/client/core/types.gen.js +0 -2
- package/dist/esm/client/core/utils.gen.d.ts +0 -19
- package/dist/esm/client/core/utils.gen.js +0 -87
- package/dist/esm/client/index.d.ts +0 -2
- package/dist/esm/client/index.js +0 -2
- package/dist/esm/client/sdk.gen.d.ts +0 -27
- package/dist/esm/client/sdk.gen.js +0 -28
- package/dist/esm/client/types.gen.d.ts +0 -120
- package/dist/esm/client/types.gen.js +0 -2
- package/dist/types/client/client/client.gen.d.ts +0 -2
- package/dist/types/client/client/index.d.ts +0 -8
- package/dist/types/client/client/types.gen.d.ts +0 -99
- package/dist/types/client/client/utils.gen.d.ts +0 -40
- package/dist/types/client/client.gen.d.ts +0 -12
- package/dist/types/client/core/auth.gen.d.ts +0 -18
- package/dist/types/client/core/bodySerializer.gen.d.ts +0 -25
- package/dist/types/client/core/params.gen.d.ts +0 -43
- package/dist/types/client/core/pathSerializer.gen.d.ts +0 -33
- package/dist/types/client/core/queryKeySerializer.gen.d.ts +0 -18
- package/dist/types/client/core/serverSentEvents.gen.d.ts +0 -71
- package/dist/types/client/core/types.gen.d.ts +0 -78
- package/dist/types/client/core/utils.gen.d.ts +0 -19
- package/dist/types/client/index.d.ts +0 -2
- package/dist/types/client/sdk.gen.d.ts +0 -27
- package/dist/types/client/types.gen.d.ts +0 -120
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.createClient = void 0;
|
|
5
|
-
const serverSentEvents_gen_1 = require("../core/serverSentEvents.gen");
|
|
6
|
-
const utils_gen_1 = require("../core/utils.gen");
|
|
7
|
-
const utils_gen_2 = require("./utils.gen");
|
|
8
|
-
const createClient = (config = {}) => {
|
|
9
|
-
let _config = (0, utils_gen_2.mergeConfigs)((0, utils_gen_2.createConfig)(), config);
|
|
10
|
-
const getConfig = () => ({ ..._config });
|
|
11
|
-
const setConfig = (config) => {
|
|
12
|
-
_config = (0, utils_gen_2.mergeConfigs)(_config, config);
|
|
13
|
-
return getConfig();
|
|
14
|
-
};
|
|
15
|
-
const interceptors = (0, utils_gen_2.createInterceptors)();
|
|
16
|
-
const beforeRequest = async (options) => {
|
|
17
|
-
const opts = {
|
|
18
|
-
..._config,
|
|
19
|
-
...options,
|
|
20
|
-
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
21
|
-
headers: (0, utils_gen_2.mergeHeaders)(_config.headers, options.headers),
|
|
22
|
-
serializedBody: undefined,
|
|
23
|
-
};
|
|
24
|
-
if (opts.security) {
|
|
25
|
-
await (0, utils_gen_2.setAuthParams)({
|
|
26
|
-
...opts,
|
|
27
|
-
security: opts.security,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
if (opts.requestValidator) {
|
|
31
|
-
await opts.requestValidator(opts);
|
|
32
|
-
}
|
|
33
|
-
if (opts.body !== undefined && opts.bodySerializer) {
|
|
34
|
-
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
35
|
-
}
|
|
36
|
-
// remove Content-Type header if body is empty to avoid sending invalid requests
|
|
37
|
-
if (opts.body === undefined || opts.serializedBody === '') {
|
|
38
|
-
opts.headers.delete('Content-Type');
|
|
39
|
-
}
|
|
40
|
-
const url = (0, utils_gen_2.buildUrl)(opts);
|
|
41
|
-
return { opts, url };
|
|
42
|
-
};
|
|
43
|
-
// @ts-expect-error
|
|
44
|
-
const request = async (options) => {
|
|
45
|
-
// @ts-expect-error
|
|
46
|
-
const { opts, url } = await beforeRequest(options);
|
|
47
|
-
for (const fn of interceptors.request.fns) {
|
|
48
|
-
if (fn) {
|
|
49
|
-
await fn(opts);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
// fetch must be assigned here, otherwise it would throw the error:
|
|
53
|
-
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
54
|
-
const _fetch = opts.fetch;
|
|
55
|
-
const requestInit = {
|
|
56
|
-
...opts,
|
|
57
|
-
body: (0, utils_gen_1.getValidRequestBody)(opts),
|
|
58
|
-
};
|
|
59
|
-
let response = await _fetch(url, requestInit);
|
|
60
|
-
for (const fn of interceptors.response.fns) {
|
|
61
|
-
if (fn) {
|
|
62
|
-
response = await fn(response, opts);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
const result = {
|
|
66
|
-
response,
|
|
67
|
-
};
|
|
68
|
-
if (response.ok) {
|
|
69
|
-
const parseAs = (opts.parseAs === 'auto'
|
|
70
|
-
? (0, utils_gen_2.getParseAs)(response.headers.get('Content-Type'))
|
|
71
|
-
: opts.parseAs) ?? 'json';
|
|
72
|
-
if (response.status === 204 ||
|
|
73
|
-
response.headers.get('Content-Length') === '0') {
|
|
74
|
-
let emptyData;
|
|
75
|
-
switch (parseAs) {
|
|
76
|
-
case 'arrayBuffer':
|
|
77
|
-
case 'blob':
|
|
78
|
-
case 'text':
|
|
79
|
-
emptyData = await response[parseAs]();
|
|
80
|
-
break;
|
|
81
|
-
case 'formData':
|
|
82
|
-
emptyData = new FormData();
|
|
83
|
-
break;
|
|
84
|
-
case 'stream':
|
|
85
|
-
emptyData = response.body;
|
|
86
|
-
break;
|
|
87
|
-
case 'json':
|
|
88
|
-
default:
|
|
89
|
-
emptyData = {};
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
data: emptyData,
|
|
94
|
-
...result,
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
let data;
|
|
98
|
-
switch (parseAs) {
|
|
99
|
-
case 'arrayBuffer':
|
|
100
|
-
case 'blob':
|
|
101
|
-
case 'formData':
|
|
102
|
-
case 'json':
|
|
103
|
-
case 'text':
|
|
104
|
-
data = await response[parseAs]();
|
|
105
|
-
break;
|
|
106
|
-
case 'stream':
|
|
107
|
-
return {
|
|
108
|
-
data: response.body,
|
|
109
|
-
...result,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
if (parseAs === 'json') {
|
|
113
|
-
if (opts.responseValidator) {
|
|
114
|
-
await opts.responseValidator(data);
|
|
115
|
-
}
|
|
116
|
-
if (opts.responseTransformer) {
|
|
117
|
-
data = await opts.responseTransformer(data);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return {
|
|
121
|
-
data,
|
|
122
|
-
...result,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
const textError = await response.text();
|
|
126
|
-
let jsonError;
|
|
127
|
-
try {
|
|
128
|
-
jsonError = JSON.parse(textError);
|
|
129
|
-
}
|
|
130
|
-
catch {
|
|
131
|
-
// noop
|
|
132
|
-
}
|
|
133
|
-
const error = jsonError ?? textError;
|
|
134
|
-
let finalError = error;
|
|
135
|
-
for (const fn of interceptors.error.fns) {
|
|
136
|
-
if (fn) {
|
|
137
|
-
finalError = (await fn(error, response, opts));
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
finalError = finalError || {};
|
|
141
|
-
if (opts.throwOnError) {
|
|
142
|
-
throw finalError;
|
|
143
|
-
}
|
|
144
|
-
return {
|
|
145
|
-
error: finalError,
|
|
146
|
-
...result,
|
|
147
|
-
};
|
|
148
|
-
};
|
|
149
|
-
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
150
|
-
const makeSseFn = (method) => async (options) => {
|
|
151
|
-
const { opts, url } = await beforeRequest(options);
|
|
152
|
-
return (0, serverSentEvents_gen_1.createSseClient)({
|
|
153
|
-
...opts,
|
|
154
|
-
body: opts.body,
|
|
155
|
-
headers: opts.headers,
|
|
156
|
-
method,
|
|
157
|
-
onRequest: async (url, init) => {
|
|
158
|
-
let request = new Request(url, init);
|
|
159
|
-
const requestInit = {
|
|
160
|
-
...init,
|
|
161
|
-
method: init.method,
|
|
162
|
-
url,
|
|
163
|
-
};
|
|
164
|
-
for (const fn of interceptors.request.fns) {
|
|
165
|
-
if (fn) {
|
|
166
|
-
await fn(requestInit);
|
|
167
|
-
request = new Request(requestInit.url, requestInit);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return request;
|
|
171
|
-
},
|
|
172
|
-
url,
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
return {
|
|
176
|
-
buildUrl: utils_gen_2.buildUrl,
|
|
177
|
-
connect: makeMethodFn('CONNECT'),
|
|
178
|
-
delete: makeMethodFn('DELETE'),
|
|
179
|
-
get: makeMethodFn('GET'),
|
|
180
|
-
getConfig,
|
|
181
|
-
head: makeMethodFn('HEAD'),
|
|
182
|
-
interceptors,
|
|
183
|
-
options: makeMethodFn('OPTIONS'),
|
|
184
|
-
patch: makeMethodFn('PATCH'),
|
|
185
|
-
post: makeMethodFn('POST'),
|
|
186
|
-
put: makeMethodFn('PUT'),
|
|
187
|
-
request,
|
|
188
|
-
setConfig,
|
|
189
|
-
sse: {
|
|
190
|
-
connect: makeSseFn('CONNECT'),
|
|
191
|
-
delete: makeSseFn('DELETE'),
|
|
192
|
-
get: makeSseFn('GET'),
|
|
193
|
-
head: makeSseFn('HEAD'),
|
|
194
|
-
options: makeSseFn('OPTIONS'),
|
|
195
|
-
patch: makeSseFn('PATCH'),
|
|
196
|
-
post: makeSseFn('POST'),
|
|
197
|
-
put: makeSseFn('PUT'),
|
|
198
|
-
trace: makeSseFn('TRACE'),
|
|
199
|
-
},
|
|
200
|
-
trace: makeMethodFn('TRACE'),
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
|
-
exports.createClient = createClient;
|
|
@@ -1,8 +0,0 @@
|
|
|
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';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.createConfig = exports.createClient = exports.serializeQueryKeyValue = exports.buildClientParams = exports.urlSearchParamsBodySerializer = exports.jsonBodySerializer = exports.formDataBodySerializer = void 0;
|
|
5
|
-
var bodySerializer_gen_1 = require("../core/bodySerializer.gen");
|
|
6
|
-
Object.defineProperty(exports, "formDataBodySerializer", { enumerable: true, get: function () { return bodySerializer_gen_1.formDataBodySerializer; } });
|
|
7
|
-
Object.defineProperty(exports, "jsonBodySerializer", { enumerable: true, get: function () { return bodySerializer_gen_1.jsonBodySerializer; } });
|
|
8
|
-
Object.defineProperty(exports, "urlSearchParamsBodySerializer", { enumerable: true, get: function () { return bodySerializer_gen_1.urlSearchParamsBodySerializer; } });
|
|
9
|
-
var params_gen_1 = require("../core/params.gen");
|
|
10
|
-
Object.defineProperty(exports, "buildClientParams", { enumerable: true, get: function () { return params_gen_1.buildClientParams; } });
|
|
11
|
-
var queryKeySerializer_gen_1 = require("../core/queryKeySerializer.gen");
|
|
12
|
-
Object.defineProperty(exports, "serializeQueryKeyValue", { enumerable: true, get: function () { return queryKeySerializer_gen_1.serializeQueryKeyValue; } });
|
|
13
|
-
var client_gen_1 = require("./client.gen");
|
|
14
|
-
Object.defineProperty(exports, "createClient", { enumerable: true, get: function () { return client_gen_1.createClient; } });
|
|
15
|
-
var utils_gen_1 = require("./utils.gen");
|
|
16
|
-
Object.defineProperty(exports, "createConfig", { enumerable: true, get: function () { return utils_gen_1.createConfig; } });
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import type { Auth } from '../core/auth.gen';
|
|
2
|
-
import type { ServerSentEventsOptions, ServerSentEventsResult } from '../core/serverSentEvents.gen';
|
|
3
|
-
import type { Client as CoreClient, Config as CoreConfig } from '../core/types.gen';
|
|
4
|
-
import type { Middleware } from './utils.gen';
|
|
5
|
-
export interface Config<T extends ClientOptions = ClientOptions> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, CoreConfig {
|
|
6
|
-
/**
|
|
7
|
-
* Base URL for all requests made by this client.
|
|
8
|
-
*/
|
|
9
|
-
baseUrl?: T['baseUrl'];
|
|
10
|
-
/**
|
|
11
|
-
* Fetch API implementation. You can use this option to provide a custom
|
|
12
|
-
* fetch instance.
|
|
13
|
-
*
|
|
14
|
-
* @default globalThis.fetch
|
|
15
|
-
*/
|
|
16
|
-
fetch?: typeof fetch;
|
|
17
|
-
/**
|
|
18
|
-
* Return the response data parsed in a specified format. By default, `auto`
|
|
19
|
-
* will infer the appropriate method from the `Content-Type` response header.
|
|
20
|
-
* You can override this behavior with any of the {@link Body} methods.
|
|
21
|
-
* Select `stream` if you don't want to parse response data at all.
|
|
22
|
-
*
|
|
23
|
-
* @default 'auto'
|
|
24
|
-
*/
|
|
25
|
-
parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
|
|
26
|
-
/**
|
|
27
|
-
* Throw an error instead of returning it in the response?
|
|
28
|
-
*
|
|
29
|
-
* @default false
|
|
30
|
-
*/
|
|
31
|
-
throwOnError?: T['throwOnError'];
|
|
32
|
-
}
|
|
33
|
-
export interface RequestOptions<TData = unknown, ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
|
|
34
|
-
throwOnError: ThrowOnError;
|
|
35
|
-
}>, Pick<ServerSentEventsOptions<TData>, 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
|
|
36
|
-
/**
|
|
37
|
-
* Any body that you want to add to your request.
|
|
38
|
-
*
|
|
39
|
-
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
|
|
40
|
-
*/
|
|
41
|
-
body?: unknown;
|
|
42
|
-
path?: Record<string, unknown>;
|
|
43
|
-
query?: Record<string, unknown>;
|
|
44
|
-
/**
|
|
45
|
-
* Security mechanism(s) to use for the request.
|
|
46
|
-
*/
|
|
47
|
-
security?: ReadonlyArray<Auth>;
|
|
48
|
-
url: Url;
|
|
49
|
-
}
|
|
50
|
-
export interface ResolvedRequestOptions<ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, ThrowOnError, Url> {
|
|
51
|
-
serializedBody?: string;
|
|
52
|
-
}
|
|
53
|
-
export type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean> = ThrowOnError extends true ? Promise<{
|
|
54
|
-
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
55
|
-
response: Response;
|
|
56
|
-
}> : Promise<({
|
|
57
|
-
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
58
|
-
error: undefined;
|
|
59
|
-
} | {
|
|
60
|
-
data: undefined;
|
|
61
|
-
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
|
|
62
|
-
}) & {
|
|
63
|
-
response: Response;
|
|
64
|
-
}>;
|
|
65
|
-
export interface ClientOptions {
|
|
66
|
-
baseUrl?: string;
|
|
67
|
-
throwOnError?: boolean;
|
|
68
|
-
}
|
|
69
|
-
type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions<TData, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError>;
|
|
70
|
-
type SseFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false>(options: Omit<RequestOptions<TData, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData, TError>>;
|
|
71
|
-
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>;
|
|
72
|
-
type BuildUrlFn = <TData extends {
|
|
73
|
-
body?: unknown;
|
|
74
|
-
path?: Record<string, unknown>;
|
|
75
|
-
query?: Record<string, unknown>;
|
|
76
|
-
url: string;
|
|
77
|
-
}>(options: TData & Options<TData>) => string;
|
|
78
|
-
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
|
|
79
|
-
interceptors: Middleware<Response, unknown, ResolvedRequestOptions>;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* The `createClientConfig()` function will be called on client initialization
|
|
83
|
-
* and the returned object will become the client's initial configuration.
|
|
84
|
-
*
|
|
85
|
-
* You may want to initialize your client this way instead of calling
|
|
86
|
-
* `setConfig()`. This is useful for example if you're using Next.js
|
|
87
|
-
* to ensure your client always has the correct values.
|
|
88
|
-
*/
|
|
89
|
-
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
|
90
|
-
export interface TDataShape {
|
|
91
|
-
body?: unknown;
|
|
92
|
-
headers?: unknown;
|
|
93
|
-
path?: unknown;
|
|
94
|
-
query?: unknown;
|
|
95
|
-
url: string;
|
|
96
|
-
}
|
|
97
|
-
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
98
|
-
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'>);
|
|
99
|
-
export {};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { QuerySerializer, 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
|
-
/**
|
|
5
|
-
* Infers parseAs value from provided Content-Type header.
|
|
6
|
-
*/
|
|
7
|
-
export declare const getParseAs: (contentType: string | null) => Exclude<Config["parseAs"], "auto">;
|
|
8
|
-
export declare const setAuthParams: ({ security, ...options }: Pick<Required<RequestOptions>, "security"> & Pick<RequestOptions, "auth" | "query"> & {
|
|
9
|
-
headers: Headers;
|
|
10
|
-
}) => Promise<void>;
|
|
11
|
-
export declare const buildUrl: Client['buildUrl'];
|
|
12
|
-
export declare const getUrl: ({ baseUrl, path, query, querySerializer, url: _url, }: {
|
|
13
|
-
baseUrl?: string;
|
|
14
|
-
path?: Record<string, unknown>;
|
|
15
|
-
query?: Record<string, unknown>;
|
|
16
|
-
querySerializer: QuerySerializer;
|
|
17
|
-
url: string;
|
|
18
|
-
}) => string;
|
|
19
|
-
export declare const mergeConfigs: (a: Config, b: Config) => Config;
|
|
20
|
-
export declare const mergeHeaders: (...headers: Array<Required<Config>["headers"] | undefined>) => Headers;
|
|
21
|
-
type ErrInterceptor<Err, Res, Options> = (error: Err, response: Res, options: Options) => Err | Promise<Err>;
|
|
22
|
-
type ReqInterceptor<Options> = (options: Options) => void | Promise<void>;
|
|
23
|
-
type ResInterceptor<Res, Options> = (response: Res, options: Options) => Res | Promise<Res>;
|
|
24
|
-
declare class Interceptors<Interceptor> {
|
|
25
|
-
fns: Array<Interceptor | null>;
|
|
26
|
-
clear(): void;
|
|
27
|
-
eject(id: number | Interceptor): void;
|
|
28
|
-
exists(id: number | Interceptor): boolean;
|
|
29
|
-
getInterceptorIndex(id: number | Interceptor): number;
|
|
30
|
-
update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
|
|
31
|
-
use(fn: Interceptor): number;
|
|
32
|
-
}
|
|
33
|
-
export interface Middleware<Res, Err, Options> {
|
|
34
|
-
error: Interceptors<ErrInterceptor<Err, Res, Options>>;
|
|
35
|
-
request: Interceptors<ReqInterceptor<Options>>;
|
|
36
|
-
response: Interceptors<ResInterceptor<Res, Options>>;
|
|
37
|
-
}
|
|
38
|
-
export declare const createInterceptors: <Res, Err, Options>() => Middleware<Res, Err, Options>;
|
|
39
|
-
export declare const createConfig: <T extends ClientOptions = ClientOptions>(override?: Config<Omit<ClientOptions, keyof T> & T>) => Config<Omit<ClientOptions, keyof T> & T>;
|
|
40
|
-
export {};
|
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.createConfig = exports.createInterceptors = exports.mergeHeaders = exports.mergeConfigs = exports.getUrl = exports.buildUrl = exports.setAuthParams = exports.getParseAs = exports.createQuerySerializer = void 0;
|
|
5
|
-
const auth_gen_1 = require("../core/auth.gen");
|
|
6
|
-
const bodySerializer_gen_1 = require("../core/bodySerializer.gen");
|
|
7
|
-
const pathSerializer_gen_1 = require("../core/pathSerializer.gen");
|
|
8
|
-
const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
9
|
-
const defaultPathSerializer = ({ path, url: _url }) => {
|
|
10
|
-
let url = _url;
|
|
11
|
-
const matches = _url.match(PATH_PARAM_RE);
|
|
12
|
-
if (matches) {
|
|
13
|
-
for (const match of matches) {
|
|
14
|
-
let explode = false;
|
|
15
|
-
let name = match.substring(1, match.length - 1);
|
|
16
|
-
let style = 'simple';
|
|
17
|
-
if (name.endsWith('*')) {
|
|
18
|
-
explode = true;
|
|
19
|
-
name = name.substring(0, name.length - 1);
|
|
20
|
-
}
|
|
21
|
-
if (name.startsWith('.')) {
|
|
22
|
-
name = name.substring(1);
|
|
23
|
-
style = 'label';
|
|
24
|
-
}
|
|
25
|
-
else if (name.startsWith(';')) {
|
|
26
|
-
name = name.substring(1);
|
|
27
|
-
style = 'matrix';
|
|
28
|
-
}
|
|
29
|
-
const value = path[name];
|
|
30
|
-
if (value === undefined || value === null) {
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
if (Array.isArray(value)) {
|
|
34
|
-
url = url.replace(match, (0, pathSerializer_gen_1.serializeArrayParam)({ explode, name, style, value }));
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
if (typeof value === 'object') {
|
|
38
|
-
url = url.replace(match, (0, pathSerializer_gen_1.serializeObjectParam)({
|
|
39
|
-
explode,
|
|
40
|
-
name,
|
|
41
|
-
style,
|
|
42
|
-
value: value,
|
|
43
|
-
valueOnly: true,
|
|
44
|
-
}));
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
if (style === 'matrix') {
|
|
48
|
-
url = url.replace(match, `;${(0, pathSerializer_gen_1.serializePrimitiveParam)({
|
|
49
|
-
name,
|
|
50
|
-
value: value,
|
|
51
|
-
})}`);
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
const replaceValue = encodeURIComponent(style === 'label' ? `.${value}` : value);
|
|
55
|
-
url = url.replace(match, replaceValue);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return url;
|
|
59
|
-
};
|
|
60
|
-
const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
61
|
-
const querySerializer = (queryParams) => {
|
|
62
|
-
const search = [];
|
|
63
|
-
if (queryParams && typeof queryParams === 'object') {
|
|
64
|
-
for (const name in queryParams) {
|
|
65
|
-
const value = queryParams[name];
|
|
66
|
-
if (value === undefined || value === null) {
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
const options = parameters[name] || args;
|
|
70
|
-
if (Array.isArray(value)) {
|
|
71
|
-
const serializedArray = (0, pathSerializer_gen_1.serializeArrayParam)({
|
|
72
|
-
allowReserved: options.allowReserved,
|
|
73
|
-
explode: true,
|
|
74
|
-
name,
|
|
75
|
-
style: 'form',
|
|
76
|
-
value,
|
|
77
|
-
...options.array,
|
|
78
|
-
});
|
|
79
|
-
if (serializedArray)
|
|
80
|
-
search.push(serializedArray);
|
|
81
|
-
}
|
|
82
|
-
else if (typeof value === 'object') {
|
|
83
|
-
const serializedObject = (0, pathSerializer_gen_1.serializeObjectParam)({
|
|
84
|
-
allowReserved: options.allowReserved,
|
|
85
|
-
explode: true,
|
|
86
|
-
name,
|
|
87
|
-
style: 'deepObject',
|
|
88
|
-
value: value,
|
|
89
|
-
...options.object,
|
|
90
|
-
});
|
|
91
|
-
if (serializedObject)
|
|
92
|
-
search.push(serializedObject);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
const serializedPrimitive = (0, pathSerializer_gen_1.serializePrimitiveParam)({
|
|
96
|
-
allowReserved: options.allowReserved,
|
|
97
|
-
name,
|
|
98
|
-
value: value,
|
|
99
|
-
});
|
|
100
|
-
if (serializedPrimitive)
|
|
101
|
-
search.push(serializedPrimitive);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return search.join('&');
|
|
106
|
-
};
|
|
107
|
-
return querySerializer;
|
|
108
|
-
};
|
|
109
|
-
exports.createQuerySerializer = createQuerySerializer;
|
|
110
|
-
/**
|
|
111
|
-
* Infers parseAs value from provided Content-Type header.
|
|
112
|
-
*/
|
|
113
|
-
const getParseAs = (contentType) => {
|
|
114
|
-
if (!contentType) {
|
|
115
|
-
// If no Content-Type header is provided, the best we can do is return the raw response body,
|
|
116
|
-
// which is effectively the same as the 'stream' option.
|
|
117
|
-
return 'stream';
|
|
118
|
-
}
|
|
119
|
-
const cleanContent = contentType.split(';')[0]?.trim();
|
|
120
|
-
if (!cleanContent) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
if (cleanContent.startsWith('application/json') ||
|
|
124
|
-
cleanContent.endsWith('+json')) {
|
|
125
|
-
return 'json';
|
|
126
|
-
}
|
|
127
|
-
if (cleanContent === 'multipart/form-data') {
|
|
128
|
-
return 'formData';
|
|
129
|
-
}
|
|
130
|
-
if (['application/', 'audio/', 'image/', 'video/'].some((type) => cleanContent.startsWith(type))) {
|
|
131
|
-
return 'blob';
|
|
132
|
-
}
|
|
133
|
-
if (cleanContent.startsWith('text/')) {
|
|
134
|
-
return 'text';
|
|
135
|
-
}
|
|
136
|
-
return;
|
|
137
|
-
};
|
|
138
|
-
exports.getParseAs = getParseAs;
|
|
139
|
-
const checkForExistence = (options, name) => {
|
|
140
|
-
if (!name) {
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
if (options.headers.has(name) ||
|
|
144
|
-
options.query?.[name] ||
|
|
145
|
-
options.headers.get('Cookie')?.includes(`${name}=`)) {
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
return false;
|
|
149
|
-
};
|
|
150
|
-
const setAuthParams = async ({ security, ...options }) => {
|
|
151
|
-
for (const auth of security) {
|
|
152
|
-
if (checkForExistence(options, auth.name)) {
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
const token = await (0, auth_gen_1.getAuthToken)(auth, options.auth);
|
|
156
|
-
if (!token) {
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
|
-
const name = auth.name ?? 'Authorization';
|
|
160
|
-
switch (auth.in) {
|
|
161
|
-
case 'query':
|
|
162
|
-
if (!options.query) {
|
|
163
|
-
options.query = {};
|
|
164
|
-
}
|
|
165
|
-
options.query[name] = token;
|
|
166
|
-
break;
|
|
167
|
-
case 'cookie':
|
|
168
|
-
options.headers.append('Cookie', `${name}=${token}`);
|
|
169
|
-
break;
|
|
170
|
-
case 'header':
|
|
171
|
-
default:
|
|
172
|
-
options.headers.set(name, token);
|
|
173
|
-
break;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
exports.setAuthParams = setAuthParams;
|
|
178
|
-
const buildUrl = (options) => {
|
|
179
|
-
const url = (0, exports.getUrl)({
|
|
180
|
-
baseUrl: options.baseUrl,
|
|
181
|
-
path: options.path,
|
|
182
|
-
query: options.query,
|
|
183
|
-
querySerializer: typeof options.querySerializer === 'function'
|
|
184
|
-
? options.querySerializer
|
|
185
|
-
: (0, exports.createQuerySerializer)(options.querySerializer),
|
|
186
|
-
url: options.url,
|
|
187
|
-
});
|
|
188
|
-
return url;
|
|
189
|
-
};
|
|
190
|
-
exports.buildUrl = buildUrl;
|
|
191
|
-
const getUrl = ({ baseUrl, path, query, querySerializer, url: _url, }) => {
|
|
192
|
-
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
|
|
193
|
-
let url = (baseUrl ?? '') + pathUrl;
|
|
194
|
-
if (path) {
|
|
195
|
-
url = defaultPathSerializer({ path, url });
|
|
196
|
-
}
|
|
197
|
-
let search = query ? querySerializer(query) : '';
|
|
198
|
-
if (search.startsWith('?')) {
|
|
199
|
-
search = search.substring(1);
|
|
200
|
-
}
|
|
201
|
-
if (search) {
|
|
202
|
-
url += `?${search}`;
|
|
203
|
-
}
|
|
204
|
-
return url;
|
|
205
|
-
};
|
|
206
|
-
exports.getUrl = getUrl;
|
|
207
|
-
const mergeConfigs = (a, b) => {
|
|
208
|
-
const config = { ...a, ...b };
|
|
209
|
-
if (config.baseUrl?.endsWith('/')) {
|
|
210
|
-
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
211
|
-
}
|
|
212
|
-
config.headers = (0, exports.mergeHeaders)(a.headers, b.headers);
|
|
213
|
-
return config;
|
|
214
|
-
};
|
|
215
|
-
exports.mergeConfigs = mergeConfigs;
|
|
216
|
-
const headersEntries = (headers) => {
|
|
217
|
-
const entries = [];
|
|
218
|
-
headers.forEach((value, key) => {
|
|
219
|
-
entries.push([key, value]);
|
|
220
|
-
});
|
|
221
|
-
return entries;
|
|
222
|
-
};
|
|
223
|
-
const mergeHeaders = (...headers) => {
|
|
224
|
-
const mergedHeaders = new Headers();
|
|
225
|
-
for (const header of headers) {
|
|
226
|
-
if (!header || typeof header !== 'object') {
|
|
227
|
-
continue;
|
|
228
|
-
}
|
|
229
|
-
const iterator = header instanceof Headers
|
|
230
|
-
? headersEntries(header)
|
|
231
|
-
: Object.entries(header);
|
|
232
|
-
for (const [key, value] of iterator) {
|
|
233
|
-
if (value === null) {
|
|
234
|
-
mergedHeaders.delete(key);
|
|
235
|
-
}
|
|
236
|
-
else if (Array.isArray(value)) {
|
|
237
|
-
for (const v of value) {
|
|
238
|
-
mergedHeaders.append(key, v);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
else if (value !== undefined) {
|
|
242
|
-
// assume object headers are meant to be JSON stringified, i.e. their
|
|
243
|
-
// content value in OpenAPI specification is 'application/json'
|
|
244
|
-
mergedHeaders.set(key, typeof value === 'object' ? JSON.stringify(value) : value);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
return mergedHeaders;
|
|
249
|
-
};
|
|
250
|
-
exports.mergeHeaders = mergeHeaders;
|
|
251
|
-
class Interceptors {
|
|
252
|
-
constructor() {
|
|
253
|
-
this.fns = [];
|
|
254
|
-
}
|
|
255
|
-
clear() {
|
|
256
|
-
this.fns = [];
|
|
257
|
-
}
|
|
258
|
-
eject(id) {
|
|
259
|
-
const index = this.getInterceptorIndex(id);
|
|
260
|
-
if (this.fns[index]) {
|
|
261
|
-
this.fns[index] = null;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
exists(id) {
|
|
265
|
-
const index = this.getInterceptorIndex(id);
|
|
266
|
-
return Boolean(this.fns[index]);
|
|
267
|
-
}
|
|
268
|
-
getInterceptorIndex(id) {
|
|
269
|
-
if (typeof id === 'number') {
|
|
270
|
-
return this.fns[id] ? id : -1;
|
|
271
|
-
}
|
|
272
|
-
return this.fns.indexOf(id);
|
|
273
|
-
}
|
|
274
|
-
update(id, fn) {
|
|
275
|
-
const index = this.getInterceptorIndex(id);
|
|
276
|
-
if (this.fns[index]) {
|
|
277
|
-
this.fns[index] = fn;
|
|
278
|
-
return id;
|
|
279
|
-
}
|
|
280
|
-
return false;
|
|
281
|
-
}
|
|
282
|
-
use(fn) {
|
|
283
|
-
this.fns.push(fn);
|
|
284
|
-
return this.fns.length - 1;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
const createInterceptors = () => ({
|
|
288
|
-
error: new Interceptors(),
|
|
289
|
-
request: new Interceptors(),
|
|
290
|
-
response: new Interceptors(),
|
|
291
|
-
});
|
|
292
|
-
exports.createInterceptors = createInterceptors;
|
|
293
|
-
const defaultQuerySerializer = (0, exports.createQuerySerializer)({
|
|
294
|
-
allowReserved: false,
|
|
295
|
-
array: {
|
|
296
|
-
explode: true,
|
|
297
|
-
style: 'form',
|
|
298
|
-
},
|
|
299
|
-
object: {
|
|
300
|
-
explode: true,
|
|
301
|
-
style: 'deepObject',
|
|
302
|
-
},
|
|
303
|
-
});
|
|
304
|
-
const defaultHeaders = {
|
|
305
|
-
'Content-Type': 'application/json',
|
|
306
|
-
};
|
|
307
|
-
const createConfig = (override = {}) => ({
|
|
308
|
-
...bodySerializer_gen_1.jsonBodySerializer,
|
|
309
|
-
headers: defaultHeaders,
|
|
310
|
-
parseAs: 'auto',
|
|
311
|
-
querySerializer: defaultQuerySerializer,
|
|
312
|
-
...override,
|
|
313
|
-
});
|
|
314
|
-
exports.createConfig = createConfig;
|