fets 0.4.14 → 0.4.15

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.
Files changed (69) hide show
  1. package/cjs/Response.js +80 -0
  2. package/cjs/client/auth/oauth.js +34 -0
  3. package/cjs/client/createClient.js +133 -0
  4. package/cjs/client/index.js +6 -0
  5. package/cjs/client/plugins/useClientCookieStore.js +31 -0
  6. package/cjs/client/types.js +0 -0
  7. package/cjs/createRouter.js +299 -0
  8. package/cjs/index.js +16 -0
  9. package/cjs/plugins/ajv.js +213 -0
  10. package/cjs/plugins/openapi.js +171 -0
  11. package/cjs/plugins/utils.js +31 -0
  12. package/cjs/swagger-ui-html.js +3 -0
  13. package/cjs/typed-fetch.js +0 -0
  14. package/cjs/types.js +0 -0
  15. package/cjs/utils.js +73 -0
  16. package/cjs/zod/types.js +7 -0
  17. package/cjs/zod/zod.js +92 -0
  18. package/esm/Response.js +74 -0
  19. package/esm/client/auth/oauth.js +31 -0
  20. package/esm/client/createClient.js +128 -0
  21. package/esm/client/index.js +3 -0
  22. package/esm/client/plugins/useClientCookieStore.js +27 -0
  23. package/esm/client/types.js +0 -0
  24. package/esm/createRouter.js +293 -0
  25. package/esm/index.js +7 -0
  26. package/esm/plugins/ajv.js +208 -0
  27. package/esm/plugins/openapi.js +166 -0
  28. package/esm/plugins/utils.js +27 -0
  29. package/esm/swagger-ui-html.js +1 -0
  30. package/esm/typed-fetch.js +0 -0
  31. package/esm/types.js +0 -0
  32. package/esm/utils.js +69 -0
  33. package/esm/zod/types.js +3 -0
  34. package/esm/zod/zod.js +88 -0
  35. package/package.json +1 -1
  36. package/typings/Response.d.cts +28 -0
  37. package/typings/Response.d.ts +28 -0
  38. package/typings/client/auth/oauth.d.cts +150 -0
  39. package/typings/client/auth/oauth.d.ts +150 -0
  40. package/typings/client/createClient.d.cts +34 -0
  41. package/typings/client/createClient.d.ts +34 -0
  42. package/typings/client/index.d.cts +3 -0
  43. package/typings/client/index.d.ts +3 -0
  44. package/typings/client/plugins/useClientCookieStore.d.cts +3 -0
  45. package/typings/client/plugins/useClientCookieStore.d.ts +3 -0
  46. package/typings/client/types.d.cts +426 -0
  47. package/typings/client/types.d.ts +426 -0
  48. package/typings/createRouter.d.cts +6 -0
  49. package/typings/createRouter.d.ts +6 -0
  50. package/typings/index.d.cts +7 -0
  51. package/typings/index.d.ts +7 -0
  52. package/typings/plugins/ajv.d.cts +4 -0
  53. package/typings/plugins/ajv.d.ts +4 -0
  54. package/typings/plugins/openapi.d.cts +33 -0
  55. package/typings/plugins/openapi.d.ts +33 -0
  56. package/typings/plugins/utils.d.cts +1 -0
  57. package/typings/plugins/utils.d.ts +1 -0
  58. package/typings/swagger-ui-html.d.cts +2 -0
  59. package/typings/swagger-ui-html.d.ts +2 -0
  60. package/typings/typed-fetch.d.cts +232 -0
  61. package/typings/typed-fetch.d.ts +232 -0
  62. package/typings/types.d.cts +261 -0
  63. package/typings/types.d.ts +261 -0
  64. package/typings/utils.d.cts +31 -0
  65. package/typings/utils.d.ts +31 -0
  66. package/typings/zod/types.d.cts +39 -0
  67. package/typings/zod/types.d.ts +39 -0
  68. package/typings/zod/zod.d.cts +2 -0
  69. package/typings/zod/zod.d.ts +2 -0
@@ -0,0 +1,426 @@
1
+ import type { B, Call, Fn, Objects, Pipe, Strings, Tuples } from 'hotscript';
2
+ import { type O } from 'ts-toolbelt';
3
+ import { HTTPMethod, NotOkStatusCode, OkStatusCode, StatusCode, TypedResponse } from '../typed-fetch.cjs';
4
+ import type { ExtractPathParamsWithBrackets, ExtractPathParamsWithPattern, FromSchema, JSONSchema, OpenAPIDocument, Simplify } from '../types.cjs';
5
+ import type { OASOAuthPath, OAuth2AuthParams } from './auth/oauth.cjs';
6
+ type JSONSchema7TypeName = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
7
+ type Mutable<Type> = FixJSONSchema<{
8
+ -readonly [Key in keyof Type]: Mutable<Type[Key]>;
9
+ }>;
10
+ type RefToPath<T extends string> = T extends `#/${infer Ref}` ? Call<Strings.Split<'/'>, Ref> : never;
11
+ type ResolveRef<TObj, TRef extends string> = {
12
+ $id: TRef;
13
+ } & O.Path<TObj, RefToPath<TRef>>;
14
+ type ResolveRefInObj<T, TBase> = T extends {
15
+ $ref: infer Ref;
16
+ } ? Ref extends string ? ResolveRef<TBase, Ref> : T : T;
17
+ type ResolveRefsInObj<T, TBase = T> = {
18
+ [K in keyof T]: ResolveRefsInObj<ResolveRefInObj<T[K], TBase>, TBase>;
19
+ };
20
+ /**
21
+ * Resolve all $refs in the OpenAPI document and normalizes the types for the client generic
22
+ */
23
+ export type NormalizeOAS<TOAS> = Mutable<ResolveRefsInObj<TOAS>>;
24
+ export type OASPathMap<TOAS extends OpenAPIDocument> = TOAS['paths'];
25
+ export type OASMethodMap<TOAS extends OpenAPIDocument, TPath extends keyof OASPathMap<TOAS>> = OASPathMap<TOAS>[TPath];
26
+ export type OASStatusMap<TOAS extends OpenAPIDocument, TPath extends keyof OASPathMap<TOAS>, TMethod extends keyof OASMethodMap<TOAS, TPath>> = OASMethodMap<TOAS, TPath>[TMethod] extends {
27
+ responses: any;
28
+ } ? OASMethodMap<TOAS, TPath>[TMethod]['responses'] : never;
29
+ export type OASResponseSchemas<TOAS extends OpenAPIDocument, TPath extends keyof OASPathMap<TOAS>, TMethod extends keyof OASMethodMap<TOAS, TPath>, TStatus extends keyof OASStatusMap<TOAS, TPath, TMethod>> = OASStatusMap<TOAS, TPath, TMethod>[TStatus]['content'];
30
+ export type OASJSONResponseSchema<TOAS extends OpenAPIDocument, TPath extends keyof OASPathMap<TOAS>, TMethod extends keyof OASMethodMap<TOAS, TPath>, TStatus extends keyof OASStatusMap<TOAS, TPath, TMethod>> = OASStatusMap<TOAS, TPath, TMethod>[TStatus] extends {
31
+ content: any;
32
+ } ? OASResponseSchemas<TOAS, TPath, TMethod, TStatus>[keyof OASResponseSchemas<TOAS, TPath, TMethod, TStatus>]['schema'] : OASStatusMap<TOAS, TPath, TMethod>[TStatus]['schema'];
33
+ type ToNumber<T extends string | number, R extends any[] = []> = T extends number ? T : T extends `${number}` ? T extends `${R['length']}` ? R['length'] : ToNumber<T, [1, ...R]> : never;
34
+ export type OASResponse<TOAS extends OpenAPIDocument, TPath extends keyof TOAS['paths'], TMethod extends keyof TOAS['paths'][TPath]> = {
35
+ [TStatus in keyof OASStatusMap<TOAS, TPath, TMethod>]: TypedResponse<FromSchema<OASJSONResponseSchema<TOAS, TPath, TMethod, TStatus>>, Record<string, string>, TStatus extends StatusCode ? TStatus : TStatus extends 'default' ? OASStatusMap<TOAS, TPath, TMethod> extends Record<'200' | 200, any> ? Exclude<NotOkStatusCode, ToNumber<Exclude<keyof OASStatusMap<TOAS, TPath, TMethod>, symbol>>> : Exclude<OkStatusCode, ToNumber<Exclude<keyof OASStatusMap<TOAS, TPath, TMethod>, symbol>>> : TStatus extends `${number}${number}${number}` ? ToNumber<TStatus> extends StatusCode ? ToNumber<TStatus> : 200 : 200>;
36
+ }[keyof OASStatusMap<TOAS, TPath, TMethod>];
37
+ interface OASParamPropMap {
38
+ query: 'query';
39
+ path: 'params';
40
+ header: 'headers';
41
+ }
42
+ export type OASParamObj<TParameter extends {
43
+ name: string;
44
+ }> = TParameter extends {
45
+ required: true;
46
+ } ? {
47
+ [TName in TParameter['name']]: TParameter extends {
48
+ schema: JSONSchema;
49
+ } ? FromSchema<TParameter['schema']> : TParameter extends {
50
+ type: JSONSchema7TypeName;
51
+ enum?: any[];
52
+ } ? FromSchema<{
53
+ type: TParameter['type'];
54
+ enum: TParameter['enum'];
55
+ }> : unknown;
56
+ } : {
57
+ [TName in TParameter['name']]?: TParameter extends {
58
+ schema: JSONSchema;
59
+ } ? FromSchema<TParameter['schema']> : TParameter extends {
60
+ type: JSONSchema7TypeName;
61
+ enum?: any[];
62
+ } ? FromSchema<{
63
+ type: TParameter['type'];
64
+ enum: TParameter['enum'];
65
+ }> : unknown;
66
+ };
67
+ interface OASParamToRequestParam<TParameters extends {
68
+ in: string;
69
+ required?: boolean;
70
+ }[]> extends Fn {
71
+ return: this['arg0'] extends {
72
+ name: string;
73
+ in: infer TParamType;
74
+ } ? TParameters extends [{
75
+ in: TParamType;
76
+ required?: true;
77
+ }] ? {
78
+ [TKey in TParamType extends keyof OASParamPropMap ? OASParamPropMap[TParamType] : never]: OASParamObj<this['arg0']>;
79
+ } : {
80
+ [TKey in TParamType extends keyof OASParamPropMap ? OASParamPropMap[TParamType] : never]?: OASParamObj<this['arg0']>;
81
+ } : {};
82
+ }
83
+ export type OASParamMap<TParameters extends {
84
+ name: string;
85
+ in: string;
86
+ }[]> = Pipe<TParameters, [
87
+ Tuples.Map<OASParamToRequestParam<TParameters>>,
88
+ Tuples.ToIntersection
89
+ ]>;
90
+ export type OASClient<TOAS extends OpenAPIDocument> = {
91
+ [TPath in keyof OASPathMap<TOAS>]: {
92
+ [TMethod in keyof OASMethodMap<TOAS, TPath>]: OASRequestParams<TOAS, TPath, TMethod> extends {
93
+ json: {};
94
+ } | {
95
+ params: {};
96
+ } | {
97
+ headers: {};
98
+ } | {
99
+ query: {};
100
+ } ? (requestParams: Simplify<OASRequestParams<TOAS, TPath, TMethod>>, init?: RequestInit) => Promise<OASResponse<TOAS, TPath, TMethod>> : (requestParams?: Simplify<OASRequestParams<TOAS, TPath, TMethod>>, init?: RequestInit) => Promise<OASResponse<TOAS, TPath, TMethod>>;
101
+ };
102
+ } & OASOAuthPath<TOAS>;
103
+ export type OASModel<TOAS extends OpenAPIDocument, TName extends TOAS extends {
104
+ components: {
105
+ schemas: Record<string, JSONSchema>;
106
+ };
107
+ } ? keyof TOAS['components']['schemas'] : TOAS extends {
108
+ definitions: Record<string, JSONSchema>;
109
+ } ? keyof TOAS['definitions'] : never> = TOAS extends {
110
+ components: {
111
+ schemas: {
112
+ [TModelName in TName]: JSONSchema;
113
+ };
114
+ };
115
+ } ? FromSchema<TOAS['components']['schemas'][TName]> : TOAS extends {
116
+ definitions: {
117
+ [TModelName in TName]: JSONSchema;
118
+ };
119
+ } ? FromSchema<TOAS['definitions'][TName]> : never;
120
+ export type FixJSONSchema<T> = FixAdditionalPropertiesForAllOf<FixMissingAdditionalProperties<FixMissingTypeObject<FixExtraRequiredFields<T>>>>;
121
+ type FixAdditionalPropertiesForAllOf<T> = T extends {
122
+ allOf: any[];
123
+ } ? Omit<T, 'allOf'> & {
124
+ allOf: Call<Tuples.Map<Objects.Omit<'additionalProperties'>>, T['allOf']>;
125
+ } : T;
126
+ type FixMissingTypeObject<T> = T extends {
127
+ properties: any;
128
+ } ? T & {
129
+ type: 'object';
130
+ } : T;
131
+ type FixMissingAdditionalProperties<T> = T extends {
132
+ type: 'object';
133
+ properties: any;
134
+ } ? Omit<T, 'additionalProperties'> & {
135
+ additionalProperties: false;
136
+ } : T;
137
+ type FixExtraRequiredFields<T> = T extends {
138
+ properties: Record<string, any>;
139
+ required: string[];
140
+ } ? Omit<T, 'required'> & {
141
+ required: Call<Tuples.Filter<B.Extends<keyof T['properties']>>, T['required']>;
142
+ } : T;
143
+ export type OASRequestParams<TOAS extends OpenAPIDocument, TPath extends keyof OASPathMap<TOAS>, TMethod extends keyof OASMethodMap<TOAS, TPath>> = (OASMethodMap<TOAS, TPath>[TMethod] extends {
144
+ requestBody: {
145
+ content: {
146
+ 'application/json': {
147
+ schema: JSONSchema;
148
+ };
149
+ };
150
+ };
151
+ } ? OASMethodMap<TOAS, TPath>[TMethod]['requestBody'] extends {
152
+ required: true;
153
+ } ? {
154
+ /**
155
+ * The request body in JSON is required for this request.
156
+ *
157
+ * The value of `json` will be stringified and sent as the request body with `Content-Type: application/json`.
158
+ */
159
+ json: FromSchema<OASMethodMap<TOAS, TPath>[TMethod]['requestBody']['content']['application/json']['schema']>;
160
+ } : {
161
+ /**
162
+ * The request body in JSON is optional for this request.
163
+ *
164
+ * The value of `json` will be stringified and sent as the request body with `Content-Type: application/json`.
165
+ */
166
+ json?: FromSchema<OASMethodMap<TOAS, TPath>[TMethod]['requestBody']['content']['application/json']['schema']>;
167
+ } : OASMethodMap<TOAS, TPath>[TMethod] extends {
168
+ requestBody: {
169
+ content: {
170
+ 'multipart/form-data': {
171
+ schema: JSONSchema;
172
+ };
173
+ };
174
+ };
175
+ } ? OASMethodMap<TOAS, TPath>[TMethod]['requestBody'] extends {
176
+ required: true;
177
+ } ? {
178
+ /**
179
+ * The request body in multipart/form-data is required for this request.
180
+ *
181
+ * The value of `formData` will be sent as the request body with `Content-Type: multipart/form-data`.
182
+ */
183
+ formData: FromSchema<OASMethodMap<TOAS, TPath>[TMethod]['requestBody']['content']['multipart/form-data']['schema']>;
184
+ } : {
185
+ /**
186
+ * The request body in multipart/form-data is optional for this request.
187
+ *
188
+ * The value of `formData` will be sent as the request body with `Content-Type: multipart/form-data`.
189
+ */
190
+ formData?: FromSchema<OASMethodMap<TOAS, TPath>[TMethod]['requestBody']['content']['multipart/form-data']['schema']>;
191
+ } : OASMethodMap<TOAS, TPath>[TMethod] extends {
192
+ requestBody: {
193
+ content: {
194
+ 'application/x-www-form-urlencoded': {
195
+ schema: JSONSchema;
196
+ };
197
+ };
198
+ };
199
+ } ? OASMethodMap<TOAS, TPath>[TMethod]['requestBody'] extends {
200
+ required: true;
201
+ } ? {
202
+ /**
203
+ * The request body in application/x-www-form-urlencoded is required for this request.
204
+ *
205
+ * The value of `formUrlEncoded` will be sent as the request body with `Content-Type: application/x-www-form-urlencoded`.
206
+ */
207
+ formUrlEncoded: FromSchema<OASMethodMap<TOAS, TPath>[TMethod]['requestBody']['content']['application/x-www-form-urlencoded']['schema']>;
208
+ } : {
209
+ /**
210
+ * The request body in application/x-www-form-urlencoded is optional for this request.
211
+ *
212
+ * The value of `formUrlEncoded` will be sent as the request body with `Content-Type: application/x-www-form-urlencoded`.
213
+ */
214
+ formUrlEncoded?: FromSchema<OASMethodMap<TOAS, TPath>[TMethod]['requestBody']['content']['application/x-www-form-urlencoded']['schema']>;
215
+ } : {}) & (OASMethodMap<TOAS, TPath>[TMethod] extends {
216
+ parameters: {
217
+ name: string;
218
+ in: string;
219
+ }[];
220
+ } ? OASParamMap<OASMethodMap<TOAS, TPath>[TMethod]['parameters']> : {}) & (TPath extends `${string}{${string}}${string}` ? {
221
+ /**
222
+ * Parameters defined in the path are required for this request.
223
+ *
224
+ * The value of `params` will be used to replace the path parameters.
225
+ *
226
+ * For example if path is `/todos/{id}` and `params` is `{ id: '1' }`, the path will be `/todos/1`
227
+ */
228
+ params: Record<ExtractPathParamsWithBrackets<TPath>, string | number | bigint | boolean>;
229
+ } : {}) & (TPath extends `${string}:${string}${string}` ? {
230
+ /**
231
+ * Parameters defined in the path are required for this request.
232
+ *
233
+ * The value of `params` will be used to replace the path parameters.
234
+ *
235
+ * For example if path is `/todos/:id` and `params` is `{ id: '1' }`, the path will be `/todos/1`.
236
+ */
237
+ params: Record<ExtractPathParamsWithPattern<TPath>, string | number | bigint | boolean>;
238
+ } : {}) & OASSecurityParamsBySecurityRef<TOAS, OASMethodMap<TOAS, TPath>[TMethod]> & OASSecurityParamsBySecurityRef<TOAS, TOAS>;
239
+ export type OASInput<TOAS extends OpenAPIDocument, TPath extends keyof OASPathMap<TOAS>, TMethod extends keyof OASMethodMap<TOAS, TPath>, TRequestType extends keyof OASRequestParams<TOAS, TPath, TMethod>> = OASRequestParams<TOAS, TPath, TMethod>[TRequestType];
240
+ export type OASOutput<TOAS extends OpenAPIDocument, TPath extends keyof OASPathMap<TOAS>, TMethod extends keyof OASMethodMap<TOAS, TPath>, TStatusCode extends keyof OASStatusMap<TOAS, TPath, TMethod> = 200> = FromSchema<OASJSONResponseSchema<TOAS, TPath, TMethod, TStatusCode>>;
241
+ export type OASComponentSchema<TOAS extends OpenAPIDocument, TName extends string> = TOAS extends {
242
+ components: {
243
+ schemas: {
244
+ [TModelName in TName]: JSONSchema;
245
+ };
246
+ };
247
+ } ? FromSchema<TOAS['components']['schemas'][TName]> : never;
248
+ export interface ClientOptions {
249
+ /**
250
+ * The base URL of the API
251
+ */
252
+ endpoint?: string;
253
+ /**
254
+ * WHATWG compatible fetch implementation
255
+ *
256
+ * @see https://the-guild.dev/openapi/fets/client/client-configuration#customizing-the-fetch-function
257
+ */
258
+ fetchFn?: typeof fetch;
259
+ /**
260
+ * Plugins to extend the client functionality
261
+ *
262
+ * @see https://the-guild.dev/openapi/fets/client/plugins
263
+ */
264
+ plugins?: ClientPlugin[];
265
+ }
266
+ export type ClientOptionsWithStrictEndpoint<TOAS extends OpenAPIDocument> = Omit<ClientOptions, 'endpoint'> & (TOAS extends {
267
+ servers: (infer TEndpoint extends string)[];
268
+ } ? {
269
+ /**
270
+ * The base URL of the API defined in the OAS document.
271
+ *
272
+ * @see https://swagger.io/docs/specification/api-host-and-base-path/
273
+ */
274
+ endpoint: TEndpoint;
275
+ } : TOAS extends {
276
+ servers: {
277
+ url: infer TEndpoint extends string;
278
+ }[];
279
+ } ? {
280
+ /**
281
+ * The base URL of the API defined in the OAS document.
282
+ *
283
+ * @see https://swagger.io/docs/specification/api-host-and-base-path/
284
+ */
285
+ endpoint: TEndpoint;
286
+ } : TOAS extends {
287
+ host: infer THost extends string;
288
+ basePath: infer TBasePath extends string;
289
+ schemes: (infer TProtocol extends string)[];
290
+ } ? {
291
+ /**
292
+ * REST APIs have a base URL to which the endpoint paths are appended. The base URL is defined by `schemes`, `host` and `basePath` on the root level of the API specification.
293
+ *
294
+ * @see https://swagger.io/docs/specification/2-0/api-host-and-base-path/
295
+ */
296
+ endpoint: `${TProtocol}://${THost}${TBasePath}`;
297
+ } : {
298
+ endpoint?: string;
299
+ });
300
+ export interface ClientRequestParams {
301
+ json?: any;
302
+ formData?: FormData;
303
+ formUrlEncoded?: Record<string, string | string[]>;
304
+ params?: Record<string, string>;
305
+ query?: Record<string, string | string[]>;
306
+ headers?: Record<string, string>;
307
+ }
308
+ export type ClientMethod = (requestParams?: ClientRequestParams) => Promise<Response>;
309
+ export interface ClientPlugin {
310
+ onRequestInit?: OnRequestInitHook;
311
+ onFetch?: OnFetchHook;
312
+ onResponse?: OnResponseHook;
313
+ }
314
+ export type OnRequestInitHook = (payload: ClientOnRequestInitPayload) => Promise<void> | void;
315
+ export type OnFetchHook = (payload: ClientOnFetchHookPayload) => Promise<void> | void;
316
+ export type OnResponseHook = (payload: ClientOnResponseHookPayload) => Promise<void> | void;
317
+ export interface ClientOnRequestInitPayload {
318
+ path: string;
319
+ method: HTTPMethod;
320
+ requestParams: ClientRequestParams;
321
+ requestInit: RequestInit;
322
+ endResponse(response: Response): void;
323
+ }
324
+ export interface ClientOnFetchHookPayload {
325
+ url: string;
326
+ init: RequestInit;
327
+ fetchFn: typeof fetch;
328
+ setFetchFn(fetchFn: typeof fetch): void;
329
+ }
330
+ export interface ClientOnResponseHookPayload {
331
+ path: string;
332
+ method: HTTPMethod;
333
+ requestParams: ClientRequestParams;
334
+ requestInit: RequestInit;
335
+ response: Response;
336
+ }
337
+ export type BasicAuthParams<TSecurityScheme> = TSecurityScheme extends {
338
+ type: 'http';
339
+ scheme: 'basic';
340
+ } | {
341
+ type: 'basic';
342
+ } ? {
343
+ headers: {
344
+ /**
345
+ * `Authorization` header is required for basic authentication
346
+ * @see https://en.wikipedia.org/wiki/Basic_access_authentication
347
+ *
348
+ * It contains the word `Basic` followed by a space and a base64-encoded string `username:password`
349
+ *
350
+ * @example
351
+ * ```
352
+ * Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
353
+ * ```
354
+ */
355
+ Authorization: `Basic ${string}`;
356
+ };
357
+ } : {};
358
+ export type BearerAuthParams<TSecurityScheme> = TSecurityScheme extends {
359
+ type: 'http';
360
+ scheme: 'bearer';
361
+ } | {
362
+ type: 'bearer';
363
+ } ? {
364
+ /**
365
+ * `Authorization` header is required for bearer authentication
366
+ * @see https://swagger.io/docs/specification/authentication/bearer-authentication/
367
+ */
368
+ headers: {
369
+ /**
370
+ * It contains the word `Bearer` followed by a space and the token
371
+ *
372
+ * @example
373
+ * ```
374
+ * Authorization: Bearer {token}
375
+ * ```
376
+ */
377
+ Authorization: `Bearer ${string}`;
378
+ };
379
+ } : {};
380
+ export type ApiKeyAuthParams<TSecurityScheme> = TSecurityScheme extends {
381
+ type: 'apiKey';
382
+ in: 'header';
383
+ name: infer TApiKeyHeaderName;
384
+ } ? {
385
+ headers: {
386
+ [THeaderName in TApiKeyHeaderName extends string ? TApiKeyHeaderName : never]: string;
387
+ };
388
+ } : TSecurityScheme extends {
389
+ type: 'apiKey';
390
+ in: 'query';
391
+ name: infer TApiKeyQueryName;
392
+ } ? {
393
+ query: {
394
+ [TQueryName in TApiKeyQueryName extends string ? TApiKeyQueryName : never]: string;
395
+ };
396
+ } : {};
397
+ export type SecuritySchemeName<T extends {
398
+ security: {
399
+ [key: string]: any;
400
+ }[];
401
+ }> = Call<Tuples.Map<Objects.Keys>, T['security']>[number];
402
+ export type OASSecurityParams<TSecurityScheme> = BasicAuthParams<TSecurityScheme> & BearerAuthParams<TSecurityScheme> & ApiKeyAuthParams<TSecurityScheme> & OAuth2AuthParams<TSecurityScheme>;
403
+ export type OASSecurityParamsBySecurityRef<TOAS, TSecurityObj> = TSecurityObj extends {
404
+ security: {
405
+ [key: string]: any;
406
+ }[];
407
+ } ? TOAS extends {
408
+ components: {
409
+ securitySchemes: {
410
+ [TSecuritySchemeNameKey in SecuritySchemeName<TSecurityObj> extends string ? SecuritySchemeName<TSecurityObj> : never]: infer TSecurityScheme;
411
+ };
412
+ };
413
+ } | {
414
+ securityDefinitions: {
415
+ [TSecuritySchemeNameKey in SecuritySchemeName<TSecurityObj> extends string ? SecuritySchemeName<TSecurityObj> : never]: infer TSecurityScheme;
416
+ };
417
+ } ? OASSecurityParams<TSecurityScheme> : SecuritySchemeName<TSecurityObj> extends `basic${string}` ? BasicAuthParams<{
418
+ type: 'http';
419
+ scheme: 'basic';
420
+ }> : SecuritySchemeName<TSecurityObj> extends `bearer${string}` ? BearerAuthParams<{
421
+ type: 'http';
422
+ scheme: 'bearer';
423
+ }> : SecuritySchemeName<TSecurityObj> extends `oauth${string}` ? OAuth2AuthParams<{
424
+ type: 'oauth2';
425
+ }> : {} : {};
426
+ export {};