@unshared/client 0.2.3 → 0.3.1
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/HttpHeaders.cjs +4 -0
- package/dist/HttpHeaders.cjs.map +1 -0
- package/dist/{chunks/8BFCFxqa.d.ts → HttpHeaders.d.ts} +1 -1
- package/dist/HttpHeaders.js +5 -0
- package/dist/HttpHeaders.js.map +1 -0
- package/dist/HttpMethods.cjs +4 -0
- package/dist/HttpMethods.cjs.map +1 -0
- package/dist/{chunks/DZp6zyqV.d.ts → HttpMethods.d.ts} +1 -98
- package/dist/HttpMethods.js +5 -0
- package/dist/HttpMethods.js.map +1 -0
- package/dist/HttpStatusCodes.cjs +4 -0
- package/dist/HttpStatusCodes.cjs.map +1 -0
- package/dist/HttpStatusCodes.d.ts +615 -0
- package/dist/HttpStatusCodes.js +5 -0
- package/dist/HttpStatusCodes.js.map +1 -0
- package/dist/chunks/0ZzUT3m_.js +46 -0
- package/dist/chunks/0ZzUT3m_.js.map +1 -0
- package/dist/chunks/BUeqbyph.js +114 -0
- package/dist/chunks/BUeqbyph.js.map +1 -0
- package/dist/chunks/{D-WqCFul.js → Biic1J5b.js} +11 -9
- package/dist/chunks/Biic1J5b.js.map +1 -0
- package/dist/chunks/CO11DuYE.d.ts +144 -0
- package/dist/chunks/CYmaYL5B.cjs +45 -0
- package/dist/chunks/CYmaYL5B.cjs.map +1 -0
- package/dist/chunks/Cayg8606.cjs +112 -0
- package/dist/chunks/Cayg8606.cjs.map +1 -0
- package/dist/chunks/{xRZPkxch.cjs → CtW2aMuA.cjs} +11 -9
- package/dist/chunks/CtW2aMuA.cjs.map +1 -0
- package/dist/chunks/DJJsADWD.js +9 -0
- package/dist/chunks/DJJsADWD.js.map +1 -0
- package/dist/chunks/DOZHjge0.d.ts +224 -0
- package/dist/chunks/Du56lBvc.js +75 -0
- package/dist/chunks/Du56lBvc.js.map +1 -0
- package/dist/chunks/Du_W5H6e.cjs +8 -0
- package/dist/chunks/Du_W5H6e.cjs.map +1 -0
- package/dist/chunks/VkINJoq7.cjs +74 -0
- package/dist/chunks/VkINJoq7.cjs.map +1 -0
- package/dist/createClient.cjs +82 -18
- package/dist/createClient.cjs.map +1 -1
- package/dist/createClient.d.ts +109 -29
- package/dist/createClient.js +85 -20
- package/dist/createClient.js.map +1 -1
- package/dist/createService.cjs +18 -0
- package/dist/createService.cjs.map +1 -0
- package/dist/createService.d.ts +38 -0
- package/dist/createService.js +20 -0
- package/dist/createService.js.map +1 -0
- package/dist/index.cjs +12 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +9 -625
- package/dist/index.js +13 -27
- package/dist/index.js.map +1 -1
- package/dist/openapi.cjs +3 -15
- package/dist/openapi.cjs.map +1 -1
- package/dist/openapi.d.ts +7 -35
- package/dist/openapi.js +3 -15
- package/dist/openapi.js.map +1 -1
- package/dist/utils.cjs +13 -11
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +57 -27
- package/dist/utils.js +12 -9
- package/dist/utils.js.map +1 -1
- package/dist/websocket.cjs +7 -0
- package/dist/websocket.cjs.map +1 -0
- package/dist/websocket.d.ts +148 -0
- package/dist/websocket.js +8 -0
- package/dist/websocket.js.map +1 -0
- package/package.json +28 -8
- package/dist/chunks/B2OrSen1.d.ts +0 -185
- package/dist/chunks/B5hc73Po.js +0 -96
- package/dist/chunks/B5hc73Po.js.map +0 -1
- package/dist/chunks/CKfJvIQ8.js +0 -50
- package/dist/chunks/CKfJvIQ8.js.map +0 -1
- package/dist/chunks/Cx8m1YzL.cjs +0 -49
- package/dist/chunks/Cx8m1YzL.cjs.map +0 -1
- package/dist/chunks/D-WqCFul.js.map +0 -1
- package/dist/chunks/D8Tsm7xC.cjs +0 -95
- package/dist/chunks/D8Tsm7xC.cjs.map +0 -1
- package/dist/chunks/r8pYO6Hx.d.ts +0 -38
- package/dist/chunks/xRZPkxch.cjs.map +0 -1
- package/dist/fetch.cjs +0 -8
- package/dist/fetch.cjs.map +0 -1
- package/dist/fetch.d.ts +0 -16
- package/dist/fetch.js +0 -9
- package/dist/fetch.js.map +0 -1
package/dist/createClient.d.ts
CHANGED
@@ -1,38 +1,118 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import { O as
|
4
|
-
import { R as
|
5
|
-
import {
|
6
|
-
import '
|
1
|
+
import { Result } from '@unshared/functions/attempt';
|
2
|
+
import { ServiceOptions } from './createService.js';
|
3
|
+
import { O as OpenAPILike, a as OpenAPIOptionsMap } from './chunks/DOZHjge0.js';
|
4
|
+
import { R as RequestOptions } from './chunks/CO11DuYE.js';
|
5
|
+
import { WebSocketChannel, ConnectOptions } from './websocket.js';
|
6
|
+
import '@unshared/types';
|
7
|
+
import 'openapi-types';
|
8
|
+
import './HttpHeaders.js';
|
9
|
+
import './HttpMethods.js';
|
7
10
|
|
8
|
-
type
|
9
|
-
type
|
10
|
-
type
|
11
|
-
|
12
|
-
|
13
|
-
} & {
|
14
|
-
fetch: ClientFetch<T>;
|
15
|
-
}>;
|
16
|
-
type ClientOptions<T = any> = Override<RequestHooks & RequestOptions, {
|
17
|
-
baseUrl?: ClientBaseUrl<T>;
|
11
|
+
type Data<T extends RequestOptions> = T extends RequestOptions<any, any, any, any, any, any, infer R, any> ? R : unknown;
|
12
|
+
type Routes = Record<string, RequestOptions>;
|
13
|
+
type Channels = Record<string, ConnectOptions>;
|
14
|
+
declare class Client<T extends Routes = Routes, U extends Channels = Channels> {
|
15
|
+
options: RequestOptions;
|
18
16
|
/**
|
19
|
-
*
|
17
|
+
* Create a new client for the application.
|
20
18
|
*
|
21
|
-
* @
|
19
|
+
* @param options The options to pass to the client.
|
20
|
+
* @example new Client({ baseUrl: 'https://api.example.com' })
|
22
21
|
*/
|
23
|
-
|
24
|
-
|
22
|
+
constructor(options?: RequestOptions);
|
23
|
+
/**
|
24
|
+
* Fetch a route from the API and return the `Response` object. If the client was instantiated with an
|
25
|
+
* application, the route name will be inferred from the application routes. Otherwise, you
|
26
|
+
* can pass the route name as a string.
|
27
|
+
*
|
28
|
+
* @param route The name of the route to fetch.
|
29
|
+
* @param options The options to pass to the request.
|
30
|
+
* @returns The response from the server.
|
31
|
+
*/
|
32
|
+
fetch<K extends keyof T & string, V extends T[K]>(route: K, options?: V): Promise<Response>;
|
33
|
+
/**
|
34
|
+
* Fetch a route from the API and return the data. If the client was instantiated with an
|
35
|
+
* application, the route name will be inferred from the application routes. Otherwise, you
|
36
|
+
* can pass the route name as a string.
|
37
|
+
*
|
38
|
+
* @param route The name of the route to fetch.
|
39
|
+
* @param options The options to pass to the request.
|
40
|
+
* @returns The data from the API.
|
41
|
+
* @example
|
42
|
+
* // Declare the application type.
|
43
|
+
* type App = Application<[ModuleProduct]>
|
44
|
+
*
|
45
|
+
* // Create a type-safe client for the application.
|
46
|
+
* const request = createClient<App>()
|
47
|
+
*
|
48
|
+
* // Fetch the data from the API.
|
49
|
+
* const data = request('GET /api/product/:id', { data: { id: '1' } })
|
50
|
+
*/
|
51
|
+
request<K extends keyof T & string, V extends T[K]>(route: K, options?: V): Promise<Data<V>>;
|
52
|
+
/**
|
53
|
+
* Attempt to fetch a route from the API and return the data. If the client was instantiated with an
|
54
|
+
* application, the route name will be inferred from the application routes. Otherwise, you
|
55
|
+
* can pass the route name as a string.
|
56
|
+
*
|
57
|
+
* @param route The name of the route to fetch.
|
58
|
+
* @param options The options to pass to the request.
|
59
|
+
* @returns A result object with either the data or an error.
|
60
|
+
* @example
|
61
|
+
* // Declare the application type.
|
62
|
+
* type App = Application<[ModuleProduct]>
|
63
|
+
*
|
64
|
+
* // Create a type-safe client for the application.
|
65
|
+
* const request = createClient<App>()
|
66
|
+
*
|
67
|
+
* // Fetch the data from the API.
|
68
|
+
* const { data, error } = requestAttempt('GET /api/product/:id', { data: { id: '1' } })
|
69
|
+
* if (error) console.error(error)
|
70
|
+
* else console.log(data)
|
71
|
+
*/
|
72
|
+
requestAttempt<K extends keyof T & string, V extends T[K]>(route: K, options?: V): Promise<Result<Data<V>>>;
|
73
|
+
/**
|
74
|
+
* Create a new WebSocket connection to the server with the given path. The connection will
|
75
|
+
* automatically reconnect if the connection is closed unexpectedly.
|
76
|
+
*
|
77
|
+
* @param channel The path to connect to.
|
78
|
+
* @param options The options to pass to the connection.
|
79
|
+
* @returns The WebSocket connection.
|
80
|
+
*/
|
81
|
+
connect<P extends keyof U & string, V extends U[P]>(channel: P, options?: V): WebSocketChannel<V>;
|
82
|
+
}
|
83
|
+
/**
|
84
|
+
* Create a new type-safe client for the application. The client can be used to fetch data from
|
85
|
+
* the API and connect to the server using WebSockets with the given path.
|
86
|
+
*
|
87
|
+
* @param options The options to pass to the client.
|
88
|
+
* @returns The client object with the request method.
|
89
|
+
* @example
|
90
|
+
* // Create a type-safe client for the application.
|
91
|
+
* const client = createClient<[ModuleUser]>()
|
92
|
+
*
|
93
|
+
* // Fetch the data from the API.
|
94
|
+
* const data = await client.request('GET /api/user/:id', { id: '1' })
|
95
|
+
*
|
96
|
+
* // Use the data from the API.
|
97
|
+
* console.log(data) // { id: '1', name: 'John Doe' }
|
98
|
+
*/
|
99
|
+
declare function createClient<T extends OpenAPILike>(options?: ServiceOptions<T>): Client<OpenAPIOptionsMap<T>>;
|
25
100
|
/**
|
26
|
-
* Create a new client
|
101
|
+
* Create a new type-safe client for the application. The client can be used to fetch data from
|
102
|
+
* the API and connect to the server using WebSockets with the given path.
|
27
103
|
*
|
28
|
-
* @param
|
29
|
-
* @
|
30
|
-
* @returns The client instance.
|
104
|
+
* @param options The options to pass to the client.
|
105
|
+
* @returns The client object with the request method.
|
31
106
|
* @example
|
32
|
-
*
|
33
|
-
*
|
107
|
+
* // Create a type-safe client for the application.
|
108
|
+
* const client = createClient<[ModuleUser]>()
|
109
|
+
*
|
110
|
+
* // Fetch the data from the API.
|
111
|
+
* const data = await client.request('GET /api/user/:id', { id: '1' })
|
112
|
+
*
|
113
|
+
* // Use the data from the API.
|
114
|
+
* console.log(data) // { id: '1', name: 'John Doe' }
|
34
115
|
*/
|
35
|
-
declare function createClient<T extends
|
36
|
-
declare function createClient<T extends OpenAPI.Document>(url: ClientBaseUrl<T>, initialOptions?: ClientOptions<T>): Client<T>;
|
116
|
+
declare function createClient<T extends Routes = Routes, V extends Channels = Channels>(options?: RequestOptions): Client<T, V>;
|
37
117
|
|
38
|
-
export {
|
118
|
+
export { Client, createClient };
|
package/dist/createClient.js
CHANGED
@@ -1,27 +1,92 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import "./chunks/
|
1
|
+
import { attempt } from "@unshared/functions/attempt";
|
2
|
+
import { f as fetch } from "./chunks/BUeqbyph.js";
|
3
|
+
import { r as request } from "./chunks/DJJsADWD.js";
|
4
|
+
import { c as connect } from "./chunks/Du56lBvc.js";
|
5
|
+
import "./chunks/0ZzUT3m_.js";
|
5
6
|
import "@unshared/functions/awaitable";
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
const status = response.status.toString();
|
16
|
-
throw status in responses && typeof responses[status] == "object" && responses[status] !== null && "description" in responses[status] && typeof responses[status].description == "string" ? new Error(responses[status].description) : new Error(response.statusText);
|
7
|
+
class Client {
|
8
|
+
/**
|
9
|
+
* Create a new client for the application.
|
10
|
+
*
|
11
|
+
* @param options The options to pass to the client.
|
12
|
+
* @example new Client({ baseUrl: 'https://api.example.com' })
|
13
|
+
*/
|
14
|
+
constructor(options = {}) {
|
15
|
+
this.options = options;
|
17
16
|
}
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
/**
|
18
|
+
* Fetch a route from the API and return the `Response` object. If the client was instantiated with an
|
19
|
+
* application, the route name will be inferred from the application routes. Otherwise, you
|
20
|
+
* can pass the route name as a string.
|
21
|
+
*
|
22
|
+
* @param route The name of the route to fetch.
|
23
|
+
* @param options The options to pass to the request.
|
24
|
+
* @returns The response from the server.
|
25
|
+
*/
|
26
|
+
fetch(route, options) {
|
27
|
+
return fetch(route, { ...this.options, ...options });
|
28
|
+
}
|
29
|
+
/**
|
30
|
+
* Fetch a route from the API and return the data. If the client was instantiated with an
|
31
|
+
* application, the route name will be inferred from the application routes. Otherwise, you
|
32
|
+
* can pass the route name as a string.
|
33
|
+
*
|
34
|
+
* @param route The name of the route to fetch.
|
35
|
+
* @param options The options to pass to the request.
|
36
|
+
* @returns The data from the API.
|
37
|
+
* @example
|
38
|
+
* // Declare the application type.
|
39
|
+
* type App = Application<[ModuleProduct]>
|
40
|
+
*
|
41
|
+
* // Create a type-safe client for the application.
|
42
|
+
* const request = createClient<App>()
|
43
|
+
*
|
44
|
+
* // Fetch the data from the API.
|
45
|
+
* const data = request('GET /api/product/:id', { data: { id: '1' } })
|
46
|
+
*/
|
47
|
+
request(route, options) {
|
48
|
+
return request(route, { ...this.options, ...options });
|
49
|
+
}
|
50
|
+
/**
|
51
|
+
* Attempt to fetch a route from the API and return the data. If the client was instantiated with an
|
52
|
+
* application, the route name will be inferred from the application routes. Otherwise, you
|
53
|
+
* can pass the route name as a string.
|
54
|
+
*
|
55
|
+
* @param route The name of the route to fetch.
|
56
|
+
* @param options The options to pass to the request.
|
57
|
+
* @returns A result object with either the data or an error.
|
58
|
+
* @example
|
59
|
+
* // Declare the application type.
|
60
|
+
* type App = Application<[ModuleProduct]>
|
61
|
+
*
|
62
|
+
* // Create a type-safe client for the application.
|
63
|
+
* const request = createClient<App>()
|
64
|
+
*
|
65
|
+
* // Fetch the data from the API.
|
66
|
+
* const { data, error } = requestAttempt('GET /api/product/:id', { data: { id: '1' } })
|
67
|
+
* if (error) console.error(error)
|
68
|
+
* else console.log(data)
|
69
|
+
*/
|
70
|
+
requestAttempt(route, options) {
|
71
|
+
return attempt(() => this.request(route, options));
|
72
|
+
}
|
73
|
+
/**
|
74
|
+
* Create a new WebSocket connection to the server with the given path. The connection will
|
75
|
+
* automatically reconnect if the connection is closed unexpectedly.
|
76
|
+
*
|
77
|
+
* @param channel The path to connect to.
|
78
|
+
* @param options The options to pass to the connection.
|
79
|
+
* @returns The WebSocket connection.
|
80
|
+
*/
|
81
|
+
connect(channel, options) {
|
82
|
+
return connect(channel, { baseUrl: this.options.baseUrl, ...options });
|
83
|
+
}
|
84
|
+
}
|
85
|
+
function createClient(options) {
|
86
|
+
return new Client(options);
|
23
87
|
}
|
24
88
|
export {
|
89
|
+
Client,
|
25
90
|
createClient
|
26
91
|
};
|
27
92
|
//# sourceMappingURL=createClient.js.map
|
package/dist/createClient.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createClient.js","sources":["../createClient.ts"],"sourcesContent":["import type {
|
1
|
+
{"version":3,"file":"createClient.js","sources":["../createClient.ts"],"sourcesContent":["import type { Result } from '@unshared/functions/attempt'\nimport type { ServiceOptions } from './createService'\nimport type { OpenAPILike, OpenAPIOptionsMap } from './openapi'\nimport type { RequestOptions } from './utils'\nimport type { ConnectOptions, WebSocketChannel } from './websocket'\nimport { attempt } from '@unshared/functions/attempt'\nimport { fetch } from './utils/fetch'\nimport { request } from './utils/request'\nimport { connect } from './websocket/connect'\n\ntype Data<T extends RequestOptions> = T extends RequestOptions<any, any, any, any, any, any, infer R, any> ? R : unknown\ntype Routes = Record<string, RequestOptions>\ntype Channels = Record<string, ConnectOptions>\n\nexport class Client<T extends Routes = Routes, U extends Channels = Channels> {\n\n /**\n * Create a new client for the application.\n *\n * @param options The options to pass to the client.\n * @example new Client({ baseUrl: 'https://api.example.com' })\n */\n constructor(public options: RequestOptions = {}) {}\n\n /**\n * Fetch a route from the API and return the `Response` object. If the client was instantiated with an\n * application, the route name will be inferred from the application routes. Otherwise, you\n * can pass the route name as a string.\n *\n * @param route The name of the route to fetch.\n * @param options The options to pass to the request.\n * @returns The response from the server.\n */\n public fetch<K extends keyof T & string, V extends T[K]>(route: K, options?: V): Promise<Response> {\n return fetch(route, { ...this.options, ...options })\n }\n\n /**\n * Fetch a route from the API and return the data. If the client was instantiated with an\n * application, the route name will be inferred from the application routes. Otherwise, you\n * can pass the route name as a string.\n *\n * @param route The name of the route to fetch.\n * @param options The options to pass to the request.\n * @returns The data from the API.\n * @example\n * // Declare the application type.\n * type App = Application<[ModuleProduct]>\n *\n * // Create a type-safe client for the application.\n * const request = createClient<App>()\n *\n * // Fetch the data from the API.\n * const data = request('GET /api/product/:id', { data: { id: '1' } })\n */\n public request<K extends keyof T & string, V extends T[K]>(route: K, options?: V): Promise<Data<V>> {\n return request(route, { ...this.options, ...options }) as Promise<Data<V>>\n }\n\n /**\n * Attempt to fetch a route from the API and return the data. If the client was instantiated with an\n * application, the route name will be inferred from the application routes. Otherwise, you\n * can pass the route name as a string.\n *\n * @param route The name of the route to fetch.\n * @param options The options to pass to the request.\n * @returns A result object with either the data or an error.\n * @example\n * // Declare the application type.\n * type App = Application<[ModuleProduct]>\n *\n * // Create a type-safe client for the application.\n * const request = createClient<App>()\n *\n * // Fetch the data from the API.\n * const { data, error } = requestAttempt('GET /api/product/:id', { data: { id: '1' } })\n * if (error) console.error(error)\n * else console.log(data)\n */\n public requestAttempt<K extends keyof T & string, V extends T[K]>(route: K, options?: V): Promise<Result<Data<V>>> {\n return attempt(() => this.request(route, options))\n }\n\n /**\n * Create a new WebSocket connection to the server with the given path. The connection will\n * automatically reconnect if the connection is closed unexpectedly.\n *\n * @param channel The path to connect to.\n * @param options The options to pass to the connection.\n * @returns The WebSocket connection.\n */\n public connect<P extends keyof U & string, V extends U[P]>(channel: P, options?: V): WebSocketChannel<V> {\n return connect(channel, { baseUrl: this.options.baseUrl, ...options }) as WebSocketChannel<V>\n }\n}\n\n/**\n * Create a new type-safe client for the application. The client can be used to fetch data from\n * the API and connect to the server using WebSockets with the given path.\n *\n * @param options The options to pass to the client.\n * @returns The client object with the request method.\n * @example\n * // Create a type-safe client for the application.\n * const client = createClient<[ModuleUser]>()\n *\n * // Fetch the data from the API.\n * const data = await client.request('GET /api/user/:id', { id: '1' })\n *\n * // Use the data from the API.\n * console.log(data) // { id: '1', name: 'John Doe' }\n */\nexport function createClient<T extends OpenAPILike>(options?: ServiceOptions<T>): Client<OpenAPIOptionsMap<T>>\n\n/**\n * Create a new type-safe client for the application. The client can be used to fetch data from\n * the API and connect to the server using WebSockets with the given path.\n *\n * @param options The options to pass to the client.\n * @returns The client object with the request method.\n * @example\n * // Create a type-safe client for the application.\n * const client = createClient<[ModuleUser]>()\n *\n * // Fetch the data from the API.\n * const data = await client.request('GET /api/user/:id', { id: '1' })\n *\n * // Use the data from the API.\n * console.log(data) // { id: '1', name: 'John Doe' }\n */\nexport function createClient<T extends Routes = Routes, V extends Channels = Channels>(options?: RequestOptions): Client<T, V>\nexport function createClient(options?: RequestOptions): Client {\n return new Client(options)\n}\n"],"names":[],"mappings":";;;;;;AAcO,MAAM,OAAiE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5E,YAAmB,UAA0B,IAAI;AAA9B,SAAA,UAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWZ,MAAkD,OAAU,SAAgC;AAC1F,WAAA,MAAM,OAAO,EAAE,GAAG,KAAK,SAAS,GAAG,SAAS;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqB9C,QAAoD,OAAU,SAA+B;AAC3F,WAAA,QAAQ,OAAO,EAAE,GAAG,KAAK,SAAS,GAAG,SAAS;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBhD,eAA2D,OAAU,SAAuC;AACjH,WAAO,QAAQ,MAAM,KAAK,QAAQ,OAAO,OAAO,CAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAW5C,QAAoD,SAAY,SAAkC;AAChG,WAAA,QAAQ,SAAS,EAAE,SAAS,KAAK,QAAQ,SAAS,GAAG,SAAS;AAAA,EAAA;AAEzE;AAqCO,SAAS,aAAa,SAAkC;AACtD,SAAA,IAAI,OAAO,OAAO;AAC3B;"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var resolveOperation = require("./chunks/CtW2aMuA.cjs"), handleResponse = require("./chunks/Cayg8606.cjs");
|
3
|
+
require("./chunks/CYmaYL5B.cjs");
|
4
|
+
require("@unshared/functions/awaitable");
|
5
|
+
function createService(document, initialOptions) {
|
6
|
+
return new Proxy({}, {
|
7
|
+
get(_, id) {
|
8
|
+
return async (data, options) => {
|
9
|
+
const baseUrl = resolveOperation.getServerUrl(document), operation = resolveOperation.resolveOperation(document, id), { method, path, responses = {} } = operation, response = await handleResponse.fetch(path, { method, baseUrl, data, ...initialOptions, ...options });
|
10
|
+
if (response.ok) return handleResponse.handleResponse(response, { ...initialOptions, ...options });
|
11
|
+
const status = response.status.toString();
|
12
|
+
throw status in responses && typeof responses[status] == "object" && responses[status] !== null && "description" in responses[status] && typeof responses[status].description == "string" ? new Error(responses[status].description) : new Error(response.statusText);
|
13
|
+
};
|
14
|
+
}
|
15
|
+
});
|
16
|
+
}
|
17
|
+
exports.createService = createService;
|
18
|
+
//# sourceMappingURL=createService.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"createService.cjs","sources":["../createService.ts"],"sourcesContent":["import type { MaybeLiteral } from '@unshared/types'\nimport type { OpenAPIV3, Operation, OperationById, OperationId, OperationOptions, OperationResult, ServerUrl } from './openapi'\nimport type { RequestOptions } from './utils/request'\nimport { getServerUrl } from './openapi/getServerUrl'\nimport { resolveOperation } from './openapi/resolveOperation'\nimport { fetch } from './utils/fetch'\nimport { handleResponse } from './utils/handleResponse'\n\n/** A service instance for the given OpenAPI specification. */\nexport type Service<T> = {\n [K in OperationId<T>]:\n OperationById<T, K> extends infer U extends OperationById<T, K>\n ? (data: OperationOptions<T, U>['data'], options?: OperationOptions<T, U>) => Promise<OperationResult<T, U>>\n : never\n}\n\n/** The options to pass to the service client. */\nexport interface ServiceOptions<T = any> extends RequestOptions {\n baseUrl?: MaybeLiteral<ServerUrl<T>>\n headers?: T extends { openapi: string } ? OpenAPIV3.ServerHeaders<T> : never\n}\n\n/**\n * Create a new client instance for the given OpenAPI specification.\n *\n * @param document The OpenAPI specification document.\n * @param initialOptions The initial options to use for every request.\n * @returns The client instance.\n * @example\n *\n * // Import the Giphy OpenAPI specification.\n * import Giphy from './giphy.openapi.json'\n *\n * // Create a new service instance for the Giphy API.\n * const service = createService(Giphy, { headers: { 'Bearer' } })\n *\n * // Request the \"searchGifs\" operation from the Giphy API.\n * await service.getGifs({ limit: 10, offset: 0, q: 'cats' }) // => { data: [...] }\n */\nexport function createService<T extends object>(document: Readonly<T>, initialOptions?: ServiceOptions<T>): Service<T> {\n return new Proxy({}, {\n get(_, id: OperationId<T>) {\n return async(data: object, options: RequestOptions) => {\n\n // --- Find the operation in the OpenAPI specification.\n const baseUrl = getServerUrl(document)\n const operation = resolveOperation(document, id) as Operation\n\n // --- Fetch the relevant resource from the server.\n const { method, path, responses = {} } = operation\n const response = await fetch(path, { method, baseUrl, data, ...initialOptions, ...options })\n if (response.ok) return handleResponse(response, { ...initialOptions, ...options })\n\n // --- Throw an error if the response was not successful.\n const status = response.status.toString()\n if (status in responses\n && typeof responses[status] === 'object'\n && responses[status] !== null\n && 'description' in responses[status]\n && typeof responses[status].description === 'string')\n throw new Error(responses[status].description)\n\n // --- Throw a generic error if the response was not successful.\n throw new Error(response.statusText)\n }\n },\n }) as Service<T>\n}\n"],"names":["getServerUrl","resolveOperation","fetch","handleResponse"],"mappings":";;;;AAuCgB,SAAA,cAAgC,UAAuB,gBAAgD;AAC9G,SAAA,IAAI,MAAM,IAAI;AAAA,IACnB,IAAI,GAAG,IAAoB;AAClB,aAAA,OAAM,MAAc,YAA4B;AAGrD,cAAM,UAAUA,iBAAAA,aAAa,QAAQ,GAC/B,YAAYC,iBAAAA,iBAAiB,UAAU,EAAE,GAGzC,EAAE,QAAQ,MAAM,YAAY,GAAG,IAAI,WACnC,WAAW,MAAMC,eAAAA,MAAM,MAAM,EAAE,QAAQ,SAAS,MAAM,GAAG,gBAAgB,GAAG,SAAS;AACvF,YAAA,SAAS,GAAI,QAAOC,eAAe,eAAA,UAAU,EAAE,GAAG,gBAAgB,GAAG,SAAS;AAG5E,cAAA,SAAS,SAAS,OAAO,SAAS;AACxC,cAAI,UAAU,aACT,OAAO,UAAU,MAAM,KAAM,YAC7B,UAAU,MAAM,MAAM,QACtB,iBAAiB,UAAU,MAAM,KACjC,OAAO,UAAU,MAAM,EAAE,eAAgB,WACtC,IAAI,MAAM,UAAU,MAAM,EAAE,WAAW,IAGzC,IAAI,MAAM,SAAS,UAAU;AAAA,MACrC;AAAA,IAAA;AAAA,EACF,CACD;AACH;;"}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { MaybeLiteral } from '@unshared/types';
|
2
|
+
import { b as OperationId, c as OperationById, d as OperationOptions, e as OperationResult, S as ServerUrl, f as OpenAPIV3 } from './chunks/DOZHjge0.js';
|
3
|
+
import { R as RequestOptions } from './chunks/CO11DuYE.js';
|
4
|
+
import 'openapi-types';
|
5
|
+
import './HttpHeaders.js';
|
6
|
+
import './HttpMethods.js';
|
7
|
+
|
8
|
+
/** A service instance for the given OpenAPI specification. */
|
9
|
+
type Service<T> = {
|
10
|
+
[K in OperationId<T>]: OperationById<T, K> extends infer U extends OperationById<T, K> ? (data: OperationOptions<T, U>['data'], options?: OperationOptions<T, U>) => Promise<OperationResult<T, U>> : never;
|
11
|
+
};
|
12
|
+
/** The options to pass to the service client. */
|
13
|
+
interface ServiceOptions<T = any> extends RequestOptions {
|
14
|
+
baseUrl?: MaybeLiteral<ServerUrl<T>>;
|
15
|
+
headers?: T extends {
|
16
|
+
openapi: string;
|
17
|
+
} ? OpenAPIV3.ServerHeaders<T> : never;
|
18
|
+
}
|
19
|
+
/**
|
20
|
+
* Create a new client instance for the given OpenAPI specification.
|
21
|
+
*
|
22
|
+
* @param document The OpenAPI specification document.
|
23
|
+
* @param initialOptions The initial options to use for every request.
|
24
|
+
* @returns The client instance.
|
25
|
+
* @example
|
26
|
+
*
|
27
|
+
* // Import the Giphy OpenAPI specification.
|
28
|
+
* import Giphy from './giphy.openapi.json'
|
29
|
+
*
|
30
|
+
* // Create a new service instance for the Giphy API.
|
31
|
+
* const service = createService(Giphy, { headers: { 'Bearer' } })
|
32
|
+
*
|
33
|
+
* // Request the "searchGifs" operation from the Giphy API.
|
34
|
+
* await service.getGifs({ limit: 10, offset: 0, q: 'cats' }) // => { data: [...] }
|
35
|
+
*/
|
36
|
+
declare function createService<T extends object>(document: Readonly<T>, initialOptions?: ServiceOptions<T>): Service<T>;
|
37
|
+
|
38
|
+
export { type Service, type ServiceOptions, createService };
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { g as getServerUrl, r as resolveOperation } from "./chunks/Biic1J5b.js";
|
2
|
+
import { f as fetch, h as handleResponse } from "./chunks/BUeqbyph.js";
|
3
|
+
import "./chunks/0ZzUT3m_.js";
|
4
|
+
import "@unshared/functions/awaitable";
|
5
|
+
function createService(document, initialOptions) {
|
6
|
+
return new Proxy({}, {
|
7
|
+
get(_, id) {
|
8
|
+
return async (data, options) => {
|
9
|
+
const baseUrl = getServerUrl(document), operation = resolveOperation(document, id), { method, path, responses = {} } = operation, response = await fetch(path, { method, baseUrl, data, ...initialOptions, ...options });
|
10
|
+
if (response.ok) return handleResponse(response, { ...initialOptions, ...options });
|
11
|
+
const status = response.status.toString();
|
12
|
+
throw status in responses && typeof responses[status] == "object" && responses[status] !== null && "description" in responses[status] && typeof responses[status].description == "string" ? new Error(responses[status].description) : new Error(response.statusText);
|
13
|
+
};
|
14
|
+
}
|
15
|
+
});
|
16
|
+
}
|
17
|
+
export {
|
18
|
+
createService
|
19
|
+
};
|
20
|
+
//# sourceMappingURL=createService.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"createService.js","sources":["../createService.ts"],"sourcesContent":["import type { MaybeLiteral } from '@unshared/types'\nimport type { OpenAPIV3, Operation, OperationById, OperationId, OperationOptions, OperationResult, ServerUrl } from './openapi'\nimport type { RequestOptions } from './utils/request'\nimport { getServerUrl } from './openapi/getServerUrl'\nimport { resolveOperation } from './openapi/resolveOperation'\nimport { fetch } from './utils/fetch'\nimport { handleResponse } from './utils/handleResponse'\n\n/** A service instance for the given OpenAPI specification. */\nexport type Service<T> = {\n [K in OperationId<T>]:\n OperationById<T, K> extends infer U extends OperationById<T, K>\n ? (data: OperationOptions<T, U>['data'], options?: OperationOptions<T, U>) => Promise<OperationResult<T, U>>\n : never\n}\n\n/** The options to pass to the service client. */\nexport interface ServiceOptions<T = any> extends RequestOptions {\n baseUrl?: MaybeLiteral<ServerUrl<T>>\n headers?: T extends { openapi: string } ? OpenAPIV3.ServerHeaders<T> : never\n}\n\n/**\n * Create a new client instance for the given OpenAPI specification.\n *\n * @param document The OpenAPI specification document.\n * @param initialOptions The initial options to use for every request.\n * @returns The client instance.\n * @example\n *\n * // Import the Giphy OpenAPI specification.\n * import Giphy from './giphy.openapi.json'\n *\n * // Create a new service instance for the Giphy API.\n * const service = createService(Giphy, { headers: { 'Bearer' } })\n *\n * // Request the \"searchGifs\" operation from the Giphy API.\n * await service.getGifs({ limit: 10, offset: 0, q: 'cats' }) // => { data: [...] }\n */\nexport function createService<T extends object>(document: Readonly<T>, initialOptions?: ServiceOptions<T>): Service<T> {\n return new Proxy({}, {\n get(_, id: OperationId<T>) {\n return async(data: object, options: RequestOptions) => {\n\n // --- Find the operation in the OpenAPI specification.\n const baseUrl = getServerUrl(document)\n const operation = resolveOperation(document, id) as Operation\n\n // --- Fetch the relevant resource from the server.\n const { method, path, responses = {} } = operation\n const response = await fetch(path, { method, baseUrl, data, ...initialOptions, ...options })\n if (response.ok) return handleResponse(response, { ...initialOptions, ...options })\n\n // --- Throw an error if the response was not successful.\n const status = response.status.toString()\n if (status in responses\n && typeof responses[status] === 'object'\n && responses[status] !== null\n && 'description' in responses[status]\n && typeof responses[status].description === 'string')\n throw new Error(responses[status].description)\n\n // --- Throw a generic error if the response was not successful.\n throw new Error(response.statusText)\n }\n },\n }) as Service<T>\n}\n"],"names":[],"mappings":";;;;AAuCgB,SAAA,cAAgC,UAAuB,gBAAgD;AAC9G,SAAA,IAAI,MAAM,IAAI;AAAA,IACnB,IAAI,GAAG,IAAoB;AAClB,aAAA,OAAM,MAAc,YAA4B;AAGrD,cAAM,UAAU,aAAa,QAAQ,GAC/B,YAAY,iBAAiB,UAAU,EAAE,GAGzC,EAAE,QAAQ,MAAM,YAAY,GAAG,IAAI,WACnC,WAAW,MAAM,MAAM,MAAM,EAAE,QAAQ,SAAS,MAAM,GAAG,gBAAgB,GAAG,SAAS;AACvF,YAAA,SAAS,GAAI,QAAO,eAAe,UAAU,EAAE,GAAG,gBAAgB,GAAG,SAAS;AAG5E,cAAA,SAAS,SAAS,OAAO,SAAS;AACxC,cAAI,UAAU,aACT,OAAO,UAAU,MAAM,KAAM,YAC7B,UAAU,MAAM,MAAM,QACtB,iBAAiB,UAAU,MAAM,KACjC,OAAO,UAAU,MAAM,EAAE,eAAgB,WACtC,IAAI,MAAM,UAAU,MAAM,EAAE,WAAW,IAGzC,IAAI,MAAM,SAAS,UAAU;AAAA,MACrC;AAAA,IAAA;AAAA,EACF,CACD;AACH;"}
|
package/dist/index.cjs
CHANGED
@@ -1,30 +1,16 @@
|
|
1
1
|
"use strict";
|
2
|
-
var createClient = require("./createClient.cjs"),
|
3
|
-
require("
|
4
|
-
|
2
|
+
var createClient = require("./createClient.cjs"), createService = require("./createService.cjs"), HttpHeaders = require("./HttpHeaders.cjs"), HttpMethods = require("./HttpMethods.cjs"), HttpStatusCodes = require("./HttpStatusCodes.cjs");
|
3
|
+
require("@unshared/functions/attempt");
|
4
|
+
require("./chunks/Cayg8606.cjs");
|
5
|
+
require("./chunks/CYmaYL5B.cjs");
|
5
6
|
require("@unshared/functions/awaitable");
|
6
|
-
var HttpHeader = /* @__PURE__ */ ((HttpHeader2) => (HttpHeader2["Accept-CH"] = "Accept-CH", HttpHeader2["Accept-Charset"] = "Accept-Charset", HttpHeader2["Accept-Encoding"] = "Accept-Encoding", HttpHeader2["Accept-Language"] = "Accept-Language", HttpHeader2["Accept-Patch"] = "Accept-Patch", HttpHeader2["Accept-Post"] = "Accept-Post", HttpHeader2["Accept-Ranges"] = "Accept-Ranges", HttpHeader2.Accept = "Accept", HttpHeader2["Access-Control-Allow-Credentials"] = "Access-Control-Allow-Credentials", HttpHeader2["Access-Control-Allow-Headers"] = "Access-Control-Allow-Headers", HttpHeader2["Access-Control-Allow-Methods"] = "Access-Control-Allow-Methods", HttpHeader2["Access-Control-Allow-Origin"] = "Access-Control-Allow-Origin", HttpHeader2["Access-Control-Expose-Headers"] = "Access-Control-Expose-Headers", HttpHeader2["Access-Control-Max-Age"] = "Access-Control-Max-Age", HttpHeader2["Access-Control-Request-Headers"] = "Access-Control-Request-Headers", HttpHeader2["Access-Control-Request-Method"] = "Access-Control-Request-Method", HttpHeader2.Age = "Age", HttpHeader2.Allow = "Allow", HttpHeader2["Alt-Svc"] = "Alt-Svc", HttpHeader2["Alt-Used"] = "Alt-Used", HttpHeader2["Attribution-Reporting-Eligible"] = "Attribution-Reporting-Eligible", HttpHeader2["Attribution-Reporting-Register-Source"] = "Attribution-Reporting-Register-Source", HttpHeader2["Attribution-Reporting-Register-Trigger"] = "Attribution-Reporting-Register-Trigger", HttpHeader2.Authorization = "Authorization", HttpHeader2["Cache-Control"] = "Cache-Control", HttpHeader2["Clear-Site-Data"] = "Clear-Site-Data", HttpHeader2.Connection = "Connection", HttpHeader2["Content-Digest"] = "Content-Digest", HttpHeader2["Content-Disposition"] = "Content-Disposition", HttpHeader2["Content-DPR"] = "Content-DPR", HttpHeader2["Content-Encoding"] = "Content-Encoding", HttpHeader2["Content-Language"] = "Content-Language", HttpHeader2["Content-Length"] = "Content-Length", HttpHeader2["Content-Location"] = "Content-Location", HttpHeader2["Content-Range"] = "Content-Range", HttpHeader2["Content-Security-Policy-Report-Only"] = "Content-Security-Policy-Report-Only", HttpHeader2["Content-Security-Policy"] = "Content-Security-Policy", HttpHeader2["Content-Type"] = "Content-Type", HttpHeader2.Cookie = "Cookie", HttpHeader2["Critical-CH"] = "Critical-CH", HttpHeader2["Cross-Origin-Embedder-Policy"] = "Cross-Origin-Embedder-Policy", HttpHeader2["Cross-Origin-Opener-Policy"] = "Cross-Origin-Opener-Policy", HttpHeader2["Cross-Origin-Resource-Policy"] = "Cross-Origin-Resource-Policy", HttpHeader2.Date = "Date", HttpHeader2["Device-Memory"] = "Device-Memory", HttpHeader2.Digest = "Digest", HttpHeader2.DNT = "DNT", HttpHeader2.Downlink = "Downlink", HttpHeader2.DPR = "DPR", HttpHeader2["Early-Data"] = "Early-Data", HttpHeader2.ECT = "ECT", HttpHeader2.ETag = "ETag", HttpHeader2["Expect-CT"] = "Expect-CT", HttpHeader2.Expect = "Expect", HttpHeader2.Expires = "Expires", HttpHeader2.Forwarded = "Forwarded", HttpHeader2.From = "From", HttpHeader2.Host = "Host", HttpHeader2["If-Match"] = "If-Match", HttpHeader2["If-Modified-Since"] = "If-Modified-Since", HttpHeader2["If-None-Match"] = "If-None-Match", HttpHeader2["If-Range"] = "If-Range", HttpHeader2["If-Unmodified-Since"] = "If-Unmodified-Since", HttpHeader2["Keep-Alive"] = "Keep-Alive", HttpHeader2["Last-Modified"] = "Last-Modified", HttpHeader2.Link = "Link", HttpHeader2.Location = "Location", HttpHeader2["Max-Forwards"] = "Max-Forwards", HttpHeader2.NEL = "NEL", HttpHeader2["No-Vary-Search"] = "No-Vary-Search", HttpHeader2["Observe-Browsing-Topics"] = "Observe-Browsing-Topics", HttpHeader2["Origin-Agent-Cluster"] = "Origin-Agent-Cluster", HttpHeader2.Origin = "Origin", HttpHeader2["Permissions-Policy"] = "Permissions-Policy", HttpHeader2.Pragma = "Pragma", HttpHeader2.Priority = "Priority", HttpHeader2["Proxy-Authenticate"] = "Proxy-Authenticate", HttpHeader2["Proxy-Authorization"] = "Proxy-Authorization", HttpHeader2.Range = "Range", HttpHeader2.Referer = "Referer", HttpHeader2["Referrer-Policy"] = "Referrer-Policy", HttpHeader2.Refresh = "Refresh", HttpHeader2["Report-To"] = "Report-To", HttpHeader2["Reporting-Endpoints"] = "Reporting-Endpoints", HttpHeader2["Repr-Digest"] = "Repr-Digest", HttpHeader2["Retry-After"] = "Retry-After", HttpHeader2.RTT = "RTT", HttpHeader2["Save-Data"] = "Save-Data", HttpHeader2["Sec-Browsing-Topics"] = "Sec-Browsing-Topics", HttpHeader2["Sec-CH-Prefers-Color-Scheme"] = "Sec-CH-Prefers-Color-Scheme", HttpHeader2["Sec-CH-Prefers-Reduced-Motion"] = "Sec-CH-Prefers-Reduced-Motion", HttpHeader2["Sec-CH-Prefers-Reduced-Transparency"] = "Sec-CH-Prefers-Reduced-Transparency", HttpHeader2["Sec-CH-UA-Arch"] = "Sec-CH-UA-Arch", HttpHeader2["Sec-CH-UA-Bitness"] = "Sec-CH-UA-Bitness", HttpHeader2["Sec-CH-UA-Full-Version-List"] = "Sec-CH-UA-Full-Version-List", HttpHeader2["Sec-CH-UA-Full-Version"] = "Sec-CH-UA-Full-Version", HttpHeader2["Sec-CH-UA-Mobile"] = "Sec-CH-UA-Mobile", HttpHeader2["Sec-CH-UA-Model"] = "Sec-CH-UA-Model", HttpHeader2["Sec-CH-UA-Platform-Version"] = "Sec-CH-UA-Platform-Version", HttpHeader2["Sec-CH-UA-Platform"] = "Sec-CH-UA-Platform", HttpHeader2["Sec-CH-UA"] = "Sec-CH-UA", HttpHeader2["Sec-Fetch-Dest"] = "Sec-Fetch-Dest", HttpHeader2["Sec-Fetch-Mode"] = "Sec-Fetch-Mode", HttpHeader2["Sec-Fetch-Site"] = "Sec-Fetch-Site", HttpHeader2["Sec-Fetch-User"] = "Sec-Fetch-User", HttpHeader2["Sec-GPC"] = "Sec-GPC", HttpHeader2["Sec-Purpose"] = "Sec-Purpose", HttpHeader2["Sec-WebSocket-Accept"] = "Sec-WebSocket-Accept", HttpHeader2["Sec-WebSocket-Extensions"] = "Sec-WebSocket-Extensions", HttpHeader2["Sec-WebSocket-Key"] = "Sec-WebSocket-Key", HttpHeader2["Sec-WebSocket-Protocol"] = "Sec-WebSocket-Protocol", HttpHeader2["Sec-WebSocket-Version"] = "Sec-WebSocket-Version", HttpHeader2["Server-Timing"] = "Server-Timing", HttpHeader2.Server = "Server", HttpHeader2["Service-Worker-Navigation-Preload"] = "Service-Worker-Navigation-Preload", HttpHeader2["Set-Cookie"] = "Set-Cookie", HttpHeader2["Set-Login"] = "Set-Login", HttpHeader2.SourceMap = "SourceMap", HttpHeader2["Speculation-Rules"] = "Speculation-Rules", HttpHeader2["Strict-Transport-Security"] = "Strict-Transport-Security", HttpHeader2["Supports-Loading-Mode"] = "Supports-Loading-Mode", HttpHeader2.TE = "TE", HttpHeader2["Timing-Allow-Origin"] = "Timing-Allow-Origin", HttpHeader2.Tk = "Tk", HttpHeader2.Trailer = "Trailer", HttpHeader2["Transfer-Encoding"] = "Transfer-Encoding", HttpHeader2["Upgrade-Insecure-Requests"] = "Upgrade-Insecure-Requests", HttpHeader2.Upgrade = "Upgrade", HttpHeader2["User-Agent"] = "User-Agent", HttpHeader2.Vary = "Vary", HttpHeader2.Via = "Via", HttpHeader2["Viewport-Width"] = "Viewport-Width", HttpHeader2["Want-Content-Digest"] = "Want-Content-Digest", HttpHeader2["Want-Digest"] = "Want-Digest", HttpHeader2["Want-Repr-Digest"] = "Want-Repr-Digest", HttpHeader2.Warning = "Warning", HttpHeader2.Width = "Width", HttpHeader2["WWW-Authenticate"] = "WWW-Authenticate", HttpHeader2["X-Content-Type-Options"] = "X-Content-Type-Options", HttpHeader2["X-DNS-Prefetch-Control"] = "X-DNS-Prefetch-Control", HttpHeader2["X-Forwarded-For"] = "X-Forwarded-For", HttpHeader2["X-Forwarded-Host"] = "X-Forwarded-Host", HttpHeader2["X-Forwarded-Proto"] = "X-Forwarded-Proto", HttpHeader2["X-Frame-Options"] = "X-Frame-Options", HttpHeader2["X-XSS-Protection"] = "X-XSS-Protection", HttpHeader2))(HttpHeader || {}), HttpMethod = /* @__PURE__ */ ((HttpMethod2) => (HttpMethod2.CONNECT = "CONNECT", HttpMethod2.DELETE = "DELETE", HttpMethod2.GET = "GET", HttpMethod2.HEAD = "HEAD", HttpMethod2.OPTIONS = "OPTIONS", HttpMethod2.PATCH = "PATCH", HttpMethod2.POST = "POST", HttpMethod2.PUT = "PUT", HttpMethod2.TRACE = "TRACE", HttpMethod2))(HttpMethod || {}), HttpStatusCode = /* @__PURE__ */ ((HttpStatusCode2) => (HttpStatusCode2[HttpStatusCode2.CONTINUE = 100] = "CONTINUE", HttpStatusCode2[HttpStatusCode2.SWITCHING_PROTOCOLS = 101] = "SWITCHING_PROTOCOLS", HttpStatusCode2[HttpStatusCode2.PROCESSING = 102] = "PROCESSING", HttpStatusCode2[HttpStatusCode2.EARLY_HINTS = 103] = "EARLY_HINTS", HttpStatusCode2[HttpStatusCode2.OK = 200] = "OK", HttpStatusCode2[HttpStatusCode2.CREATED = 201] = "CREATED", HttpStatusCode2[HttpStatusCode2.ACCEPTED = 202] = "ACCEPTED", HttpStatusCode2[HttpStatusCode2.NON_AUTHORITATIVE_INFORMATION = 203] = "NON_AUTHORITATIVE_INFORMATION", HttpStatusCode2[HttpStatusCode2.NO_CONTENT = 204] = "NO_CONTENT", HttpStatusCode2[HttpStatusCode2.RESET_CONTENT = 205] = "RESET_CONTENT", HttpStatusCode2[HttpStatusCode2.PARTIAL_CONTENT = 206] = "PARTIAL_CONTENT", HttpStatusCode2[HttpStatusCode2.MULTI_STATUS = 207] = "MULTI_STATUS", HttpStatusCode2[HttpStatusCode2.ALREADY_REPORTED = 208] = "ALREADY_REPORTED", HttpStatusCode2[HttpStatusCode2.IM_USED = 226] = "IM_USED", HttpStatusCode2[HttpStatusCode2.MULTIPLE_CHOICES = 300] = "MULTIPLE_CHOICES", HttpStatusCode2[HttpStatusCode2.MOVED_PERMANENTLY = 301] = "MOVED_PERMANENTLY", HttpStatusCode2[HttpStatusCode2.FOUND = 302] = "FOUND", HttpStatusCode2[HttpStatusCode2.SEE_OTHER = 303] = "SEE_OTHER", HttpStatusCode2[HttpStatusCode2.NOT_MODIFIED = 304] = "NOT_MODIFIED", HttpStatusCode2[HttpStatusCode2.TEMPORARY_REDIRECT = 307] = "TEMPORARY_REDIRECT", HttpStatusCode2[HttpStatusCode2.PERMANENT_REDIRECT = 308] = "PERMANENT_REDIRECT", HttpStatusCode2[HttpStatusCode2.BAD_REQUEST = 400] = "BAD_REQUEST", HttpStatusCode2[HttpStatusCode2.UNAUTHORIZED = 401] = "UNAUTHORIZED", HttpStatusCode2[HttpStatusCode2.PAYMENT_REQUIRED = 402] = "PAYMENT_REQUIRED", HttpStatusCode2[HttpStatusCode2.FORBIDDEN = 403] = "FORBIDDEN", HttpStatusCode2[HttpStatusCode2.NOT_FOUND = 404] = "NOT_FOUND", HttpStatusCode2[HttpStatusCode2.METHOD_NOT_ALLOWED = 405] = "METHOD_NOT_ALLOWED", HttpStatusCode2[HttpStatusCode2.NOT_ACCEPTABLE = 406] = "NOT_ACCEPTABLE", HttpStatusCode2[HttpStatusCode2.PROXY_AUTHENTICATION_REQUIRED = 407] = "PROXY_AUTHENTICATION_REQUIRED", HttpStatusCode2[HttpStatusCode2.REQUEST_TIMEOUT = 408] = "REQUEST_TIMEOUT", HttpStatusCode2[HttpStatusCode2.CONFLICT = 409] = "CONFLICT", HttpStatusCode2[HttpStatusCode2.GONE = 410] = "GONE", HttpStatusCode2[HttpStatusCode2.LENGTH_REQUIRED = 411] = "LENGTH_REQUIRED", HttpStatusCode2[HttpStatusCode2.PRECONDITION_FAILED = 412] = "PRECONDITION_FAILED", HttpStatusCode2[HttpStatusCode2.CONTENT_TOO_LARGE = 413] = "CONTENT_TOO_LARGE", HttpStatusCode2[HttpStatusCode2.URI_TOO_LONG = 414] = "URI_TOO_LONG", HttpStatusCode2[HttpStatusCode2.UNSUPPORTED_MEDIA_TYPE = 415] = "UNSUPPORTED_MEDIA_TYPE", HttpStatusCode2[HttpStatusCode2.RANGE_NOT_SATISFIABLE = 416] = "RANGE_NOT_SATISFIABLE", HttpStatusCode2[HttpStatusCode2.EXPECTATION_FAILED = 417] = "EXPECTATION_FAILED", HttpStatusCode2[HttpStatusCode2.I_M_A_TEAPOT = 418] = "I_M_A_TEAPOT", HttpStatusCode2[HttpStatusCode2.MISDIRECTED_REQUEST = 421] = "MISDIRECTED_REQUEST", HttpStatusCode2[HttpStatusCode2.UNPROCESSABLE_CONTENT = 422] = "UNPROCESSABLE_CONTENT", HttpStatusCode2[HttpStatusCode2.LOCKED = 423] = "LOCKED", HttpStatusCode2[HttpStatusCode2.FAILED_DEPENDENCY = 424] = "FAILED_DEPENDENCY", HttpStatusCode2[HttpStatusCode2.TOO_EARLY = 425] = "TOO_EARLY", HttpStatusCode2[HttpStatusCode2.UPGRADE_REQUIRED = 426] = "UPGRADE_REQUIRED", HttpStatusCode2[HttpStatusCode2.PRECONDITION_REQUIRED = 428] = "PRECONDITION_REQUIRED", HttpStatusCode2[HttpStatusCode2.TOO_MANY_REQUESTS = 429] = "TOO_MANY_REQUESTS", HttpStatusCode2[HttpStatusCode2.REQUEST_HEADER_FIELDS_TOO_LARGE = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE", HttpStatusCode2[HttpStatusCode2.UNAVAILABLE_FOR_LEGAL_REASONS = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS", HttpStatusCode2[HttpStatusCode2.INTERNAL_SERVER_ERROR = 500] = "INTERNAL_SERVER_ERROR", HttpStatusCode2[HttpStatusCode2.NOT_IMPLEMENTED = 501] = "NOT_IMPLEMENTED", HttpStatusCode2[HttpStatusCode2.BAD_GATEWAY = 502] = "BAD_GATEWAY", HttpStatusCode2[HttpStatusCode2.SERVICE_UNAVAILABLE = 503] = "SERVICE_UNAVAILABLE", HttpStatusCode2[HttpStatusCode2.GATEWAY_TIMEOUT = 504] = "GATEWAY_TIMEOUT", HttpStatusCode2[HttpStatusCode2.HTTP_VERSION_NOT_SUPPORTED = 505] = "HTTP_VERSION_NOT_SUPPORTED", HttpStatusCode2[HttpStatusCode2.VARIANT_ALSO_NEGOTIATES = 506] = "VARIANT_ALSO_NEGOTIATES", HttpStatusCode2[HttpStatusCode2.INSUFFICIENT_STORAGE = 507] = "INSUFFICIENT_STORAGE", HttpStatusCode2[HttpStatusCode2.LOOP_DETECTED = 508] = "LOOP_DETECTED", HttpStatusCode2[HttpStatusCode2.NOT_EXTENDED = 510] = "NOT_EXTENDED", HttpStatusCode2[HttpStatusCode2.NETWORK_AUTHENTICATION_REQUIRED = 511] = "NETWORK_AUTHENTICATION_REQUIRED", HttpStatusCode2))(HttpStatusCode || {});
|
7
|
+
require("./chunks/Du_W5H6e.cjs");
|
8
|
+
require("./chunks/VkINJoq7.cjs");
|
9
|
+
require("./chunks/CtW2aMuA.cjs");
|
10
|
+
exports.Client = createClient.Client;
|
7
11
|
exports.createClient = createClient.createClient;
|
8
|
-
exports.
|
9
|
-
exports.
|
10
|
-
exports.
|
11
|
-
exports.
|
12
|
-
exports.resolveReference = openapi.resolveReference;
|
13
|
-
exports.getBaseUrl = getOperationById.getBaseUrl;
|
14
|
-
exports.getOperationById = getOperationById.getOperationById;
|
15
|
-
exports.handleResponse = handleResponse.handleResponse;
|
16
|
-
exports.handleResponseStreamJson = handleResponse.handleResponseStreamJson;
|
17
|
-
exports.isFormDataLike = parseRequest.isFormDataLike;
|
18
|
-
exports.isObjectLike = parseRequest.isObjectLike;
|
19
|
-
exports.parseRequest = parseRequest.parseRequest;
|
20
|
-
exports.parseRequestBody = parseRequest.parseRequestBody;
|
21
|
-
exports.parseRequestHeaders = parseRequest.parseRequestHeaders;
|
22
|
-
exports.parseRequestParameters = parseRequest.parseRequestParameters;
|
23
|
-
exports.parseRequestQuery = parseRequest.parseRequestQuery;
|
24
|
-
exports.parseRequestUrl = parseRequest.parseRequestUrl;
|
25
|
-
exports.toFormData = parseRequest.toFormData;
|
26
|
-
exports.toSearchParams = parseRequest.toSearchParams;
|
27
|
-
exports.HttpHeader = HttpHeader;
|
28
|
-
exports.HttpMethod = HttpMethod;
|
29
|
-
exports.HttpStatusCode = HttpStatusCode;
|
12
|
+
exports.createService = createService.createService;
|
13
|
+
exports.HttpHeader = HttpHeaders.HttpHeader;
|
14
|
+
exports.HttpMethod = HttpMethods.HttpMethod;
|
15
|
+
exports.HttpStatusCode = HttpStatusCodes.HttpStatusCode;
|
30
16
|
//# sourceMappingURL=index.cjs.map
|