@robosystems/client 0.2.24 → 0.2.26
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 +7 -6
- package/bin/{create-feature → create-feature.sh} +11 -1
- package/client/client.gen.js +118 -34
- package/client/client.gen.ts +125 -38
- package/client/index.d.ts +2 -1
- package/client/index.js +3 -1
- package/client/index.ts +1 -1
- package/client/types.gen.d.ts +11 -16
- package/client/types.gen.js +0 -1
- package/client/types.gen.ts +44 -64
- package/client/utils.gen.d.ts +8 -20
- package/client/utils.gen.js +44 -112
- package/client/utils.gen.ts +57 -181
- package/client.gen.d.ts +3 -3
- package/client.gen.js +1 -3
- package/client.gen.ts +4 -6
- package/core/auth.gen.ts +1 -2
- package/core/bodySerializer.gen.d.ts +12 -4
- package/core/bodySerializer.gen.js +1 -1
- package/core/bodySerializer.gen.ts +17 -25
- package/core/params.gen.d.ts +10 -0
- package/core/params.gen.js +17 -5
- package/core/params.gen.ts +37 -21
- package/core/pathSerializer.gen.js +3 -11
- package/core/pathSerializer.gen.ts +4 -14
- package/core/queryKeySerializer.gen.d.ts +18 -0
- package/core/queryKeySerializer.gen.js +98 -0
- package/core/queryKeySerializer.gen.ts +117 -0
- package/core/serverSentEvents.gen.d.ts +71 -0
- package/core/serverSentEvents.gen.js +137 -0
- package/core/serverSentEvents.gen.ts +243 -0
- package/core/types.gen.d.ts +12 -12
- package/core/types.gen.js +0 -1
- package/core/types.gen.ts +21 -38
- package/core/utils.gen.d.ts +19 -0
- package/core/utils.gen.js +93 -0
- package/core/utils.gen.ts +140 -0
- package/extensions/GraphClient.d.ts +21 -1
- package/extensions/GraphClient.js +100 -32
- package/extensions/GraphClient.test.ts +176 -6
- package/extensions/GraphClient.ts +124 -34
- package/extensions/QueryClient.js +23 -2
- package/extensions/QueryClient.test.ts +2 -1
- package/extensions/QueryClient.ts +27 -2
- package/index.ts +3 -2
- package/package.json +11 -9
- package/sdk/client/client.gen.js +118 -34
- package/sdk/client/client.gen.ts +125 -38
- package/sdk/client/index.d.ts +2 -1
- package/sdk/client/index.js +3 -1
- package/sdk/client/index.ts +1 -1
- package/sdk/client/types.gen.d.ts +11 -16
- package/sdk/client/types.gen.js +0 -1
- package/sdk/client/types.gen.ts +44 -64
- package/sdk/client/utils.gen.d.ts +8 -20
- package/sdk/client/utils.gen.js +44 -112
- package/sdk/client/utils.gen.ts +57 -181
- package/sdk/client.gen.d.ts +3 -3
- package/sdk/client.gen.js +1 -3
- package/sdk/client.gen.ts +4 -6
- package/sdk/core/auth.gen.ts +1 -2
- package/sdk/core/bodySerializer.gen.d.ts +12 -4
- package/sdk/core/bodySerializer.gen.js +1 -1
- package/sdk/core/bodySerializer.gen.ts +17 -25
- package/sdk/core/params.gen.d.ts +10 -0
- package/sdk/core/params.gen.js +17 -5
- package/sdk/core/params.gen.ts +37 -21
- package/sdk/core/pathSerializer.gen.js +3 -11
- package/sdk/core/pathSerializer.gen.ts +4 -14
- package/sdk/core/queryKeySerializer.gen.d.ts +18 -0
- package/sdk/core/queryKeySerializer.gen.js +98 -0
- package/sdk/core/queryKeySerializer.gen.ts +117 -0
- package/sdk/core/serverSentEvents.gen.d.ts +71 -0
- package/sdk/core/serverSentEvents.gen.js +137 -0
- package/sdk/core/serverSentEvents.gen.ts +243 -0
- package/sdk/core/types.gen.d.ts +12 -12
- package/sdk/core/types.gen.js +0 -1
- package/sdk/core/types.gen.ts +21 -38
- package/sdk/core/utils.gen.d.ts +19 -0
- package/sdk/core/utils.gen.js +93 -0
- package/sdk/core/utils.gen.ts +140 -0
- package/sdk/index.d.ts +2 -2
- package/sdk/index.js +114 -17
- package/sdk/index.ts +3 -2
- package/sdk/sdk.gen.d.ts +112 -3
- package/sdk/sdk.gen.js +778 -1736
- package/sdk/sdk.gen.ts +782 -1740
- package/sdk/types.gen.d.ts +851 -5
- package/sdk/types.gen.ts +852 -6
- package/sdk-extensions/GraphClient.d.ts +21 -1
- package/sdk-extensions/GraphClient.js +100 -32
- package/sdk-extensions/GraphClient.test.ts +176 -6
- package/sdk-extensions/GraphClient.ts +124 -34
- package/sdk-extensions/QueryClient.js +23 -2
- package/sdk-extensions/QueryClient.test.ts +2 -1
- package/sdk-extensions/QueryClient.ts +27 -2
- package/sdk.gen.d.ts +112 -3
- package/sdk.gen.js +778 -1736
- package/sdk.gen.ts +782 -1740
- package/types.gen.d.ts +851 -5
- package/types.gen.ts +852 -6
package/client/types.gen.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
/* eslint-disable no-undef */
|
|
3
2
|
|
|
4
3
|
import type { Auth } from '../core/auth.gen';
|
|
5
4
|
import type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from '../core/
|
|
5
|
+
ServerSentEventsOptions,
|
|
6
|
+
ServerSentEventsResult,
|
|
7
|
+
} from '../core/serverSentEvents.gen';
|
|
8
|
+
import type { Client as CoreClient, Config as CoreConfig } from '../core/types.gen';
|
|
9
9
|
import type { Middleware } from './utils.gen';
|
|
10
10
|
|
|
11
11
|
export type ResponseStyle = 'data' | 'fields';
|
|
12
12
|
|
|
13
13
|
export interface Config<T extends ClientOptions = ClientOptions>
|
|
14
|
-
extends Omit<RequestInit, 'body' | 'headers' | 'method'>,
|
|
15
|
-
CoreConfig {
|
|
14
|
+
extends Omit<RequestInit, 'body' | 'headers' | 'method'>, CoreConfig {
|
|
16
15
|
/**
|
|
17
16
|
* Base URL for all requests made by this client.
|
|
18
17
|
*/
|
|
@@ -23,7 +22,7 @@ export interface Config<T extends ClientOptions = ClientOptions>
|
|
|
23
22
|
*
|
|
24
23
|
* @default globalThis.fetch
|
|
25
24
|
*/
|
|
26
|
-
fetch?:
|
|
25
|
+
fetch?: typeof fetch;
|
|
27
26
|
/**
|
|
28
27
|
* Please don't use the Fetch client for Next.js applications. The `next`
|
|
29
28
|
* options won't have any effect.
|
|
@@ -39,14 +38,7 @@ export interface Config<T extends ClientOptions = ClientOptions>
|
|
|
39
38
|
*
|
|
40
39
|
* @default 'auto'
|
|
41
40
|
*/
|
|
42
|
-
parseAs?:
|
|
43
|
-
| 'arrayBuffer'
|
|
44
|
-
| 'auto'
|
|
45
|
-
| 'blob'
|
|
46
|
-
| 'formData'
|
|
47
|
-
| 'json'
|
|
48
|
-
| 'stream'
|
|
49
|
-
| 'text';
|
|
41
|
+
parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
|
|
50
42
|
/**
|
|
51
43
|
* Should we return only data or multiple fields (data, error, response, etc.)?
|
|
52
44
|
*
|
|
@@ -62,13 +54,24 @@ export interface Config<T extends ClientOptions = ClientOptions>
|
|
|
62
54
|
}
|
|
63
55
|
|
|
64
56
|
export interface RequestOptions<
|
|
57
|
+
TData = unknown,
|
|
65
58
|
TResponseStyle extends ResponseStyle = 'fields',
|
|
66
59
|
ThrowOnError extends boolean = boolean,
|
|
67
60
|
Url extends string = string,
|
|
68
|
-
>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
61
|
+
>
|
|
62
|
+
extends
|
|
63
|
+
Config<{
|
|
64
|
+
responseStyle: TResponseStyle;
|
|
65
|
+
throwOnError: ThrowOnError;
|
|
66
|
+
}>,
|
|
67
|
+
Pick<
|
|
68
|
+
ServerSentEventsOptions<TData>,
|
|
69
|
+
| 'onSseError'
|
|
70
|
+
| 'onSseEvent'
|
|
71
|
+
| 'sseDefaultRetryDelay'
|
|
72
|
+
| 'sseMaxRetryAttempts'
|
|
73
|
+
| 'sseMaxRetryDelay'
|
|
74
|
+
> {
|
|
72
75
|
/**
|
|
73
76
|
* Any body that you want to add to your request.
|
|
74
77
|
*
|
|
@@ -88,7 +91,7 @@ export interface ResolvedRequestOptions<
|
|
|
88
91
|
TResponseStyle extends ResponseStyle = 'fields',
|
|
89
92
|
ThrowOnError extends boolean = boolean,
|
|
90
93
|
Url extends string = string,
|
|
91
|
-
> extends RequestOptions<TResponseStyle, ThrowOnError, Url> {
|
|
94
|
+
> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
|
|
92
95
|
serializedBody?: string;
|
|
93
96
|
}
|
|
94
97
|
|
|
@@ -104,32 +107,22 @@ export type RequestResult<
|
|
|
104
107
|
? TData[keyof TData]
|
|
105
108
|
: TData
|
|
106
109
|
: {
|
|
107
|
-
data: TData extends Record<string, unknown>
|
|
108
|
-
? TData[keyof TData]
|
|
109
|
-
: TData;
|
|
110
|
+
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
110
111
|
request: Request;
|
|
111
112
|
response: Response;
|
|
112
113
|
}
|
|
113
114
|
>
|
|
114
115
|
: Promise<
|
|
115
116
|
TResponseStyle extends 'data'
|
|
116
|
-
?
|
|
117
|
-
| (TData extends Record<string, unknown>
|
|
118
|
-
? TData[keyof TData]
|
|
119
|
-
: TData)
|
|
120
|
-
| undefined
|
|
117
|
+
? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined
|
|
121
118
|
: (
|
|
122
119
|
| {
|
|
123
|
-
data: TData extends Record<string, unknown>
|
|
124
|
-
? TData[keyof TData]
|
|
125
|
-
: TData;
|
|
120
|
+
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
126
121
|
error: undefined;
|
|
127
122
|
}
|
|
128
123
|
| {
|
|
129
124
|
data: undefined;
|
|
130
|
-
error: TError extends Record<string, unknown>
|
|
131
|
-
? TError[keyof TError]
|
|
132
|
-
: TError;
|
|
125
|
+
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
|
|
133
126
|
}
|
|
134
127
|
) & {
|
|
135
128
|
request: Request;
|
|
@@ -149,17 +142,26 @@ type MethodFn = <
|
|
|
149
142
|
ThrowOnError extends boolean = false,
|
|
150
143
|
TResponseStyle extends ResponseStyle = 'fields',
|
|
151
144
|
>(
|
|
152
|
-
options: Omit<RequestOptions<TResponseStyle, ThrowOnError>, 'method'>,
|
|
145
|
+
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>,
|
|
153
146
|
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
154
147
|
|
|
148
|
+
type SseFn = <
|
|
149
|
+
TData = unknown,
|
|
150
|
+
TError = unknown,
|
|
151
|
+
ThrowOnError extends boolean = false,
|
|
152
|
+
TResponseStyle extends ResponseStyle = 'fields',
|
|
153
|
+
>(
|
|
154
|
+
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>,
|
|
155
|
+
) => Promise<ServerSentEventsResult<TData, TError>>;
|
|
156
|
+
|
|
155
157
|
type RequestFn = <
|
|
156
158
|
TData = unknown,
|
|
157
159
|
TError = unknown,
|
|
158
160
|
ThrowOnError extends boolean = false,
|
|
159
161
|
TResponseStyle extends ResponseStyle = 'fields',
|
|
160
162
|
>(
|
|
161
|
-
options: Omit<RequestOptions<TResponseStyle, ThrowOnError>, 'method'> &
|
|
162
|
-
Pick<Required<RequestOptions<TResponseStyle, ThrowOnError>>, 'method'>,
|
|
163
|
+
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> &
|
|
164
|
+
Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>,
|
|
163
165
|
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
164
166
|
|
|
165
167
|
type BuildUrlFn = <
|
|
@@ -170,10 +172,10 @@ type BuildUrlFn = <
|
|
|
170
172
|
url: string;
|
|
171
173
|
},
|
|
172
174
|
>(
|
|
173
|
-
options:
|
|
175
|
+
options: TData & Options<TData>,
|
|
174
176
|
) => string;
|
|
175
177
|
|
|
176
|
-
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn> & {
|
|
178
|
+
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
|
|
177
179
|
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
|
|
178
180
|
};
|
|
179
181
|
|
|
@@ -202,32 +204,10 @@ type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
|
202
204
|
export type Options<
|
|
203
205
|
TData extends TDataShape = TDataShape,
|
|
204
206
|
ThrowOnError extends boolean = boolean,
|
|
207
|
+
TResponse = unknown,
|
|
205
208
|
TResponseStyle extends ResponseStyle = 'fields',
|
|
206
209
|
> = OmitKeys<
|
|
207
|
-
RequestOptions<TResponseStyle, ThrowOnError>,
|
|
210
|
+
RequestOptions<TResponse, TResponseStyle, ThrowOnError>,
|
|
208
211
|
'body' | 'path' | 'query' | 'url'
|
|
209
212
|
> &
|
|
210
|
-
Omit<TData, 'url'
|
|
211
|
-
|
|
212
|
-
export type OptionsLegacyParser<
|
|
213
|
-
TData = unknown,
|
|
214
|
-
ThrowOnError extends boolean = boolean,
|
|
215
|
-
TResponseStyle extends ResponseStyle = 'fields',
|
|
216
|
-
> = TData extends { body?: any }
|
|
217
|
-
? TData extends { headers?: any }
|
|
218
|
-
? OmitKeys<
|
|
219
|
-
RequestOptions<TResponseStyle, ThrowOnError>,
|
|
220
|
-
'body' | 'headers' | 'url'
|
|
221
|
-
> &
|
|
222
|
-
TData
|
|
223
|
-
: OmitKeys<RequestOptions<TResponseStyle, ThrowOnError>, 'body' | 'url'> &
|
|
224
|
-
TData &
|
|
225
|
-
Pick<RequestOptions<TResponseStyle, ThrowOnError>, 'headers'>
|
|
226
|
-
: TData extends { headers?: any }
|
|
227
|
-
? OmitKeys<
|
|
228
|
-
RequestOptions<TResponseStyle, ThrowOnError>,
|
|
229
|
-
'headers' | 'url'
|
|
230
|
-
> &
|
|
231
|
-
TData &
|
|
232
|
-
Pick<RequestOptions<TResponseStyle, ThrowOnError>, 'body'>
|
|
233
|
-
: OmitKeys<RequestOptions<TResponseStyle, ThrowOnError>, 'url'> & TData;
|
|
213
|
+
([TData] extends [never] ? unknown : Omit<TData, 'url'>);
|
package/client/utils.gen.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
|
2
2
|
import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';
|
|
3
|
-
export declare const createQuerySerializer: <T = unknown>({
|
|
3
|
+
export declare const createQuerySerializer: <T = unknown>({ parameters, ...args }?: QuerySerializerOptions) => (queryParams: T) => string;
|
|
4
4
|
/**
|
|
5
5
|
* Infers parseAs value from provided Content-Type header.
|
|
6
6
|
*/
|
|
@@ -9,37 +9,25 @@ export declare const setAuthParams: ({ security, ...options }: Pick<Required<Req
|
|
|
9
9
|
headers: Headers;
|
|
10
10
|
}) => Promise<void>;
|
|
11
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
12
|
export declare const mergeConfigs: (a: Config, b: Config) => Config;
|
|
20
13
|
export declare const mergeHeaders: (...headers: Array<Required<Config>["headers"] | undefined>) => Headers;
|
|
21
14
|
type ErrInterceptor<Err, Res, Req, Options> = (error: Err, response: Res, request: Req, options: Options) => Err | Promise<Err>;
|
|
22
15
|
type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
|
|
23
16
|
type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
|
|
24
17
|
declare class Interceptors<Interceptor> {
|
|
25
|
-
|
|
26
|
-
constructor();
|
|
18
|
+
fns: Array<Interceptor | null>;
|
|
27
19
|
clear(): void;
|
|
28
|
-
getInterceptorIndex(id: number | Interceptor): number;
|
|
29
|
-
exists(id: number | Interceptor): boolean;
|
|
30
20
|
eject(id: number | Interceptor): void;
|
|
31
|
-
|
|
21
|
+
exists(id: number | Interceptor): boolean;
|
|
22
|
+
getInterceptorIndex(id: number | Interceptor): number;
|
|
23
|
+
update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
|
|
32
24
|
use(fn: Interceptor): number;
|
|
33
25
|
}
|
|
34
26
|
export interface Middleware<Req, Res, Err, Options> {
|
|
35
|
-
error: Pick<Interceptors<ErrInterceptor<Err, Res, Req, Options>>, 'eject' | 'use'>;
|
|
36
|
-
request: Pick<Interceptors<ReqInterceptor<Req, Options>>, 'eject' | 'use'>;
|
|
37
|
-
response: Pick<Interceptors<ResInterceptor<Res, Req, Options>>, 'eject' | 'use'>;
|
|
38
|
-
}
|
|
39
|
-
export declare const createInterceptors: <Req, Res, Err, Options>() => {
|
|
40
27
|
error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
|
|
41
28
|
request: Interceptors<ReqInterceptor<Req, Options>>;
|
|
42
29
|
response: Interceptors<ResInterceptor<Res, Req, Options>>;
|
|
43
|
-
}
|
|
30
|
+
}
|
|
31
|
+
export declare const createInterceptors: <Req, Res, Err, Options>() => Middleware<Req, Res, Err, Options>;
|
|
44
32
|
export declare const createConfig: <T extends ClientOptions = ClientOptions>(override?: Config<Omit<ClientOptions, keyof T> & T>) => Config<Omit<ClientOptions, keyof T> & T>;
|
|
45
33
|
export {};
|
package/client/utils.gen.js
CHANGED
|
@@ -1,63 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.createConfig = exports.createInterceptors = exports.mergeHeaders = exports.mergeConfigs = exports.
|
|
4
|
+
exports.createConfig = exports.createInterceptors = exports.mergeHeaders = exports.mergeConfigs = exports.buildUrl = exports.setAuthParams = exports.getParseAs = exports.createQuerySerializer = void 0;
|
|
5
5
|
const auth_gen_1 = require("../core/auth.gen");
|
|
6
6
|
const bodySerializer_gen_1 = require("../core/bodySerializer.gen");
|
|
7
7
|
const pathSerializer_gen_1 = require("../core/pathSerializer.gen");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
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 = ({ allowReserved, array, object, } = {}) => {
|
|
8
|
+
const utils_gen_1 = require("../core/utils.gen");
|
|
9
|
+
const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
61
10
|
const querySerializer = (queryParams) => {
|
|
62
11
|
const search = [];
|
|
63
12
|
if (queryParams && typeof queryParams === 'object') {
|
|
@@ -66,33 +15,34 @@ const createQuerySerializer = ({ allowReserved, array, object, } = {}) => {
|
|
|
66
15
|
if (value === undefined || value === null) {
|
|
67
16
|
continue;
|
|
68
17
|
}
|
|
18
|
+
const options = parameters[name] || args;
|
|
69
19
|
if (Array.isArray(value)) {
|
|
70
20
|
const serializedArray = (0, pathSerializer_gen_1.serializeArrayParam)({
|
|
71
|
-
allowReserved,
|
|
21
|
+
allowReserved: options.allowReserved,
|
|
72
22
|
explode: true,
|
|
73
23
|
name,
|
|
74
24
|
style: 'form',
|
|
75
25
|
value,
|
|
76
|
-
...array,
|
|
26
|
+
...options.array,
|
|
77
27
|
});
|
|
78
28
|
if (serializedArray)
|
|
79
29
|
search.push(serializedArray);
|
|
80
30
|
}
|
|
81
31
|
else if (typeof value === 'object') {
|
|
82
32
|
const serializedObject = (0, pathSerializer_gen_1.serializeObjectParam)({
|
|
83
|
-
allowReserved,
|
|
33
|
+
allowReserved: options.allowReserved,
|
|
84
34
|
explode: true,
|
|
85
35
|
name,
|
|
86
36
|
style: 'deepObject',
|
|
87
37
|
value: value,
|
|
88
|
-
...object,
|
|
38
|
+
...options.object,
|
|
89
39
|
});
|
|
90
40
|
if (serializedObject)
|
|
91
41
|
search.push(serializedObject);
|
|
92
42
|
}
|
|
93
43
|
else {
|
|
94
44
|
const serializedPrimitive = (0, pathSerializer_gen_1.serializePrimitiveParam)({
|
|
95
|
-
allowReserved,
|
|
45
|
+
allowReserved: options.allowReserved,
|
|
96
46
|
name,
|
|
97
47
|
value: value,
|
|
98
48
|
});
|
|
@@ -119,8 +69,7 @@ const getParseAs = (contentType) => {
|
|
|
119
69
|
if (!cleanContent) {
|
|
120
70
|
return;
|
|
121
71
|
}
|
|
122
|
-
if (cleanContent.startsWith('application/json') ||
|
|
123
|
-
cleanContent.endsWith('+json')) {
|
|
72
|
+
if (cleanContent.startsWith('application/json') || cleanContent.endsWith('+json')) {
|
|
124
73
|
return 'json';
|
|
125
74
|
}
|
|
126
75
|
if (cleanContent === 'multipart/form-data') {
|
|
@@ -174,35 +123,16 @@ const setAuthParams = async ({ security, ...options }) => {
|
|
|
174
123
|
}
|
|
175
124
|
};
|
|
176
125
|
exports.setAuthParams = setAuthParams;
|
|
177
|
-
const buildUrl = (options) => {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
});
|
|
187
|
-
return url;
|
|
188
|
-
};
|
|
126
|
+
const buildUrl = (options) => (0, utils_gen_1.getUrl)({
|
|
127
|
+
baseUrl: options.baseUrl,
|
|
128
|
+
path: options.path,
|
|
129
|
+
query: options.query,
|
|
130
|
+
querySerializer: typeof options.querySerializer === 'function'
|
|
131
|
+
? options.querySerializer
|
|
132
|
+
: (0, exports.createQuerySerializer)(options.querySerializer),
|
|
133
|
+
url: options.url,
|
|
134
|
+
});
|
|
189
135
|
exports.buildUrl = buildUrl;
|
|
190
|
-
const getUrl = ({ baseUrl, path, query, querySerializer, url: _url, }) => {
|
|
191
|
-
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
|
|
192
|
-
let url = (baseUrl ?? '') + pathUrl;
|
|
193
|
-
if (path) {
|
|
194
|
-
url = defaultPathSerializer({ path, url });
|
|
195
|
-
}
|
|
196
|
-
let search = query ? querySerializer(query) : '';
|
|
197
|
-
if (search.startsWith('?')) {
|
|
198
|
-
search = search.substring(1);
|
|
199
|
-
}
|
|
200
|
-
if (search) {
|
|
201
|
-
url += `?${search}`;
|
|
202
|
-
}
|
|
203
|
-
return url;
|
|
204
|
-
};
|
|
205
|
-
exports.getUrl = getUrl;
|
|
206
136
|
const mergeConfigs = (a, b) => {
|
|
207
137
|
const config = { ...a, ...b };
|
|
208
138
|
if (config.baseUrl?.endsWith('/')) {
|
|
@@ -212,13 +142,20 @@ const mergeConfigs = (a, b) => {
|
|
|
212
142
|
return config;
|
|
213
143
|
};
|
|
214
144
|
exports.mergeConfigs = mergeConfigs;
|
|
145
|
+
const headersEntries = (headers) => {
|
|
146
|
+
const entries = [];
|
|
147
|
+
headers.forEach((value, key) => {
|
|
148
|
+
entries.push([key, value]);
|
|
149
|
+
});
|
|
150
|
+
return entries;
|
|
151
|
+
};
|
|
215
152
|
const mergeHeaders = (...headers) => {
|
|
216
153
|
const mergedHeaders = new Headers();
|
|
217
154
|
for (const header of headers) {
|
|
218
|
-
if (!header
|
|
155
|
+
if (!header) {
|
|
219
156
|
continue;
|
|
220
157
|
}
|
|
221
|
-
const iterator = header instanceof Headers ? header
|
|
158
|
+
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
222
159
|
for (const [key, value] of iterator) {
|
|
223
160
|
if (value === null) {
|
|
224
161
|
mergedHeaders.delete(key);
|
|
@@ -240,45 +177,40 @@ const mergeHeaders = (...headers) => {
|
|
|
240
177
|
exports.mergeHeaders = mergeHeaders;
|
|
241
178
|
class Interceptors {
|
|
242
179
|
constructor() {
|
|
243
|
-
this.
|
|
180
|
+
this.fns = [];
|
|
244
181
|
}
|
|
245
182
|
clear() {
|
|
246
|
-
this.
|
|
183
|
+
this.fns = [];
|
|
247
184
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
else {
|
|
253
|
-
return this._fns.indexOf(id);
|
|
185
|
+
eject(id) {
|
|
186
|
+
const index = this.getInterceptorIndex(id);
|
|
187
|
+
if (this.fns[index]) {
|
|
188
|
+
this.fns[index] = null;
|
|
254
189
|
}
|
|
255
190
|
}
|
|
256
191
|
exists(id) {
|
|
257
192
|
const index = this.getInterceptorIndex(id);
|
|
258
|
-
return
|
|
193
|
+
return Boolean(this.fns[index]);
|
|
259
194
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
this._fns[index] = null;
|
|
195
|
+
getInterceptorIndex(id) {
|
|
196
|
+
if (typeof id === 'number') {
|
|
197
|
+
return this.fns[id] ? id : -1;
|
|
264
198
|
}
|
|
199
|
+
return this.fns.indexOf(id);
|
|
265
200
|
}
|
|
266
201
|
update(id, fn) {
|
|
267
202
|
const index = this.getInterceptorIndex(id);
|
|
268
|
-
if (this.
|
|
269
|
-
this.
|
|
203
|
+
if (this.fns[index]) {
|
|
204
|
+
this.fns[index] = fn;
|
|
270
205
|
return id;
|
|
271
206
|
}
|
|
272
|
-
|
|
273
|
-
return false;
|
|
274
|
-
}
|
|
207
|
+
return false;
|
|
275
208
|
}
|
|
276
209
|
use(fn) {
|
|
277
|
-
this.
|
|
278
|
-
return this.
|
|
210
|
+
this.fns.push(fn);
|
|
211
|
+
return this.fns.length - 1;
|
|
279
212
|
}
|
|
280
213
|
}
|
|
281
|
-
// do not add `Middleware` as return type so we can use _fns internally
|
|
282
214
|
const createInterceptors = () => ({
|
|
283
215
|
error: new Interceptors(),
|
|
284
216
|
request: new Interceptors(),
|