@seatmap-fyi/api-client 0.1.0-alpha.1 → 0.1.0-alpha.11
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/configuration.d.ts +8 -5
- package/dist/configuration.js +5 -3
- package/dist/generated.d.ts +1168 -252
- package/dist/generated.js +658 -311
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/transport.d.ts +13 -1
- package/dist/transport.js +47 -23
- package/package.json +4 -1
- package/dist/errors/api-error.d.ts +0 -5
- package/dist/errors/api-error.js +0 -10
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/transport.d.ts
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
|
+
import type { AxiosRequestConfig } from "axios";
|
|
1
2
|
import type { Configuration } from "./configuration.js";
|
|
2
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @method prepareRequestOptions
|
|
5
|
+
* @description Applies instance-scoped transport settings, the SDK write contract and optional body compression.
|
|
6
|
+
* @async
|
|
7
|
+
* @param {Configuration} configuration
|
|
8
|
+
* @param {string | undefined} basePath
|
|
9
|
+
* @param {AxiosRequestConfig | undefined} options
|
|
10
|
+
* @param {string} method
|
|
11
|
+
* @param {unknown} [body]
|
|
12
|
+
* @returns {Promise<AxiosRequestConfig<unknown>>}
|
|
13
|
+
*/
|
|
14
|
+
export declare function prepareRequestOptions(configuration: Configuration, basePath: string | undefined, options: AxiosRequestConfig | undefined, method: string, body?: unknown): Promise<AxiosRequestConfig<unknown>>;
|
package/dist/transport.js
CHANGED
|
@@ -1,26 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { mergeConfig } from "axios";
|
|
2
|
+
const clientContract = "3";
|
|
3
|
+
const requestCompressionThreshold = 64 * 1024;
|
|
4
|
+
/**
|
|
5
|
+
* @method prepareRequestOptions
|
|
6
|
+
* @description Applies instance-scoped transport settings, the SDK write contract and optional body compression.
|
|
7
|
+
* @async
|
|
8
|
+
* @param {Configuration} configuration
|
|
9
|
+
* @param {string | undefined} basePath
|
|
10
|
+
* @param {AxiosRequestConfig | undefined} options
|
|
11
|
+
* @param {string} method
|
|
12
|
+
* @param {unknown} [body]
|
|
13
|
+
* @returns {Promise<AxiosRequestConfig<unknown>>}
|
|
14
|
+
*/
|
|
15
|
+
export async function prepareRequestOptions(configuration, basePath, options, method, body) {
|
|
16
|
+
const prepared = mergeConfig(configuration.baseOptions ?? {}, options ?? {});
|
|
17
|
+
const headers = { ...prepared.headers };
|
|
18
|
+
if (!["GET", "HEAD", "OPTIONS"].includes(method)) {
|
|
19
|
+
headers["X-Seatmap-Contract"] = clientContract;
|
|
20
|
+
}
|
|
21
|
+
const configuredBasePath = basePath ?? configuration.basePath;
|
|
22
|
+
if (configuredBasePath !== undefined) {
|
|
23
|
+
prepared.baseURL = configuredBasePath;
|
|
24
|
+
}
|
|
25
|
+
if (body === undefined &&
|
|
26
|
+
!["GET", "HEAD", "OPTIONS"].includes(method) &&
|
|
27
|
+
!Object.keys(headers).some((name) => name.toLowerCase() === "content-type")) {
|
|
28
|
+
headers["Content-Type"] = "application/json";
|
|
29
|
+
}
|
|
30
|
+
prepared.headers = headers;
|
|
31
|
+
if (prepared.validateStatus === undefined) {
|
|
32
|
+
prepared.validateStatus = (status) => (status >= 200 && status < 300) || status === 304;
|
|
33
|
+
}
|
|
34
|
+
if (!configuration.compressRequests ||
|
|
35
|
+
body === undefined ||
|
|
36
|
+
(typeof Blob !== "undefined" && body instanceof Blob) ||
|
|
37
|
+
body instanceof ArrayBuffer ||
|
|
38
|
+
ArrayBuffer.isView(body) ||
|
|
39
|
+
Object.keys(headers).some((name) => name.toLowerCase() === "content-encoding")) {
|
|
40
|
+
return prepared;
|
|
18
41
|
}
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
headers.set(name, value);
|
|
42
|
+
const serialized = JSON.stringify(options?.data ?? body);
|
|
43
|
+
if (serialized.length < requestCompressionThreshold ||
|
|
44
|
+
typeof CompressionStream === "undefined") {
|
|
45
|
+
return prepared;
|
|
24
46
|
}
|
|
25
|
-
|
|
47
|
+
prepared.data = await new Response(new Blob([serialized]).stream().pipeThrough(new CompressionStream("gzip"))).arrayBuffer();
|
|
48
|
+
headers["Content-Encoding"] = "gzip";
|
|
49
|
+
return prepared;
|
|
26
50
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seatmap-fyi/api-client",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.11",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -18,5 +18,8 @@
|
|
|
18
18
|
},
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"axios": "1.20.0"
|
|
21
24
|
}
|
|
22
25
|
}
|
package/dist/errors/api-error.js
DELETED