benji-sdk 0.1.0 → 0.1.2
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 +41 -141
- package/dist/client/client/client.gen.d.ts +1 -1
- package/dist/client/client/client.gen.d.ts.map +1 -1
- package/dist/client/client/client.gen.js +46 -46
- package/dist/client/client/index.d.ts +8 -8
- package/dist/client/client/index.d.ts.map +1 -1
- package/dist/client/client/index.js +5 -5
- package/dist/client/client/types.gen.d.ts +18 -18
- package/dist/client/client/types.gen.d.ts.map +1 -1
- package/dist/client/client/utils.gen.d.ts +3 -3
- package/dist/client/client/utils.gen.d.ts.map +1 -1
- package/dist/client/client/utils.gen.js +34 -34
- package/dist/client/client.gen.d.ts +3 -3
- package/dist/client/client.gen.d.ts.map +1 -1
- package/dist/client/client.gen.js +2 -2
- package/dist/client/core/auth.gen.d.ts +3 -3
- package/dist/client/core/auth.gen.js +3 -3
- package/dist/client/core/bodySerializer.gen.d.ts +1 -1
- package/dist/client/core/bodySerializer.gen.d.ts.map +1 -1
- package/dist/client/core/bodySerializer.gen.js +3 -3
- package/dist/client/core/params.gen.d.ts +3 -3
- package/dist/client/core/params.gen.js +9 -9
- package/dist/client/core/pathSerializer.gen.d.ts +3 -3
- package/dist/client/core/pathSerializer.gen.d.ts.map +1 -1
- package/dist/client/core/pathSerializer.gen.js +36 -36
- package/dist/client/core/queryKeySerializer.gen.js +11 -11
- package/dist/client/core/serverSentEvents.gen.d.ts +3 -3
- package/dist/client/core/serverSentEvents.gen.d.ts.map +1 -1
- package/dist/client/core/serverSentEvents.gen.js +19 -19
- package/dist/client/core/types.gen.d.ts +4 -4
- package/dist/client/core/types.gen.d.ts.map +1 -1
- package/dist/client/core/utils.gen.d.ts +1 -1
- package/dist/client/core/utils.gen.d.ts.map +1 -1
- package/dist/client/core/utils.gen.js +17 -17
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/sdk.gen.d.ts +1067 -157
- package/dist/client/sdk.gen.d.ts.map +1 -1
- package/dist/client/sdk.gen.js +2907 -769
- package/dist/client/types.gen.d.ts +10703 -4298
- package/dist/client/types.gen.d.ts.map +1 -1
- package/dist/env.d.ts +10 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +18 -0
- package/dist/errors.d.ts +22 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +21 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -3
- package/dist/method-metadata.gen.d.ts +2 -0
- package/dist/method-metadata.gen.d.ts.map +1 -0
- package/dist/method-metadata.gen.js +2 -0
- package/dist/methods.d.ts +27 -0
- package/dist/methods.d.ts.map +1 -0
- package/dist/methods.js +147 -0
- package/dist/wrapper.d.ts +20 -0
- package/dist/wrapper.d.ts.map +1 -0
- package/dist/wrapper.js +49 -0
- package/package.json +10 -6
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
import { getAuthToken } from
|
|
3
|
-
import { jsonBodySerializer } from
|
|
4
|
-
import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam, } from
|
|
5
|
-
import { getUrl } from
|
|
2
|
+
import { getAuthToken } from "../core/auth.gen.js";
|
|
3
|
+
import { jsonBodySerializer } from "../core/bodySerializer.gen.js";
|
|
4
|
+
import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam, } from "../core/pathSerializer.gen.js";
|
|
5
|
+
import { getUrl } from "../core/utils.gen.js";
|
|
6
6
|
export const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
7
7
|
const querySerializer = (queryParams) => {
|
|
8
8
|
const search = [];
|
|
9
|
-
if (queryParams && typeof queryParams ===
|
|
9
|
+
if (queryParams && typeof queryParams === "object") {
|
|
10
10
|
for (const name in queryParams) {
|
|
11
11
|
const value = queryParams[name];
|
|
12
12
|
if (value === undefined || value === null) {
|
|
@@ -18,19 +18,19 @@ export const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
|
18
18
|
allowReserved: options.allowReserved,
|
|
19
19
|
explode: true,
|
|
20
20
|
name,
|
|
21
|
-
style:
|
|
21
|
+
style: "form",
|
|
22
22
|
value,
|
|
23
23
|
...options.array,
|
|
24
24
|
});
|
|
25
25
|
if (serializedArray)
|
|
26
26
|
search.push(serializedArray);
|
|
27
27
|
}
|
|
28
|
-
else if (typeof value ===
|
|
28
|
+
else if (typeof value === "object") {
|
|
29
29
|
const serializedObject = serializeObjectParam({
|
|
30
30
|
allowReserved: options.allowReserved,
|
|
31
31
|
explode: true,
|
|
32
32
|
name,
|
|
33
|
-
style:
|
|
33
|
+
style: "deepObject",
|
|
34
34
|
value: value,
|
|
35
35
|
...options.object,
|
|
36
36
|
});
|
|
@@ -48,7 +48,7 @@ export const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
return search.join(
|
|
51
|
+
return search.join("&");
|
|
52
52
|
};
|
|
53
53
|
return querySerializer;
|
|
54
54
|
};
|
|
@@ -59,24 +59,24 @@ export const getParseAs = (contentType) => {
|
|
|
59
59
|
if (!contentType) {
|
|
60
60
|
// If no Content-Type header is provided, the best we can do is return the raw response body,
|
|
61
61
|
// which is effectively the same as the 'stream' option.
|
|
62
|
-
return
|
|
62
|
+
return "stream";
|
|
63
63
|
}
|
|
64
|
-
const cleanContent = contentType.split(
|
|
64
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
65
65
|
if (!cleanContent) {
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
-
if (cleanContent.startsWith(
|
|
69
|
-
cleanContent.endsWith(
|
|
70
|
-
return
|
|
68
|
+
if (cleanContent.startsWith("application/json") ||
|
|
69
|
+
cleanContent.endsWith("+json")) {
|
|
70
|
+
return "json";
|
|
71
71
|
}
|
|
72
|
-
if (cleanContent ===
|
|
73
|
-
return
|
|
72
|
+
if (cleanContent === "multipart/form-data") {
|
|
73
|
+
return "formData";
|
|
74
74
|
}
|
|
75
|
-
if ([
|
|
76
|
-
return
|
|
75
|
+
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
76
|
+
return "blob";
|
|
77
77
|
}
|
|
78
|
-
if (cleanContent.startsWith(
|
|
79
|
-
return
|
|
78
|
+
if (cleanContent.startsWith("text/")) {
|
|
79
|
+
return "text";
|
|
80
80
|
}
|
|
81
81
|
return;
|
|
82
82
|
};
|
|
@@ -86,7 +86,7 @@ const checkForExistence = (options, name) => {
|
|
|
86
86
|
}
|
|
87
87
|
if (options.headers.has(name) ||
|
|
88
88
|
options.query?.[name] ||
|
|
89
|
-
options.headers.get(
|
|
89
|
+
options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
90
90
|
return true;
|
|
91
91
|
}
|
|
92
92
|
return false;
|
|
@@ -100,18 +100,18 @@ export const setAuthParams = async ({ security, ...options }) => {
|
|
|
100
100
|
if (!token) {
|
|
101
101
|
continue;
|
|
102
102
|
}
|
|
103
|
-
const name = auth.name ??
|
|
103
|
+
const name = auth.name ?? "Authorization";
|
|
104
104
|
switch (auth.in) {
|
|
105
|
-
case
|
|
105
|
+
case "query":
|
|
106
106
|
if (!options.query) {
|
|
107
107
|
options.query = {};
|
|
108
108
|
}
|
|
109
109
|
options.query[name] = token;
|
|
110
110
|
break;
|
|
111
|
-
case
|
|
112
|
-
options.headers.append(
|
|
111
|
+
case "cookie":
|
|
112
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
113
113
|
break;
|
|
114
|
-
case
|
|
114
|
+
case "header":
|
|
115
115
|
default:
|
|
116
116
|
options.headers.set(name, token);
|
|
117
117
|
break;
|
|
@@ -122,14 +122,14 @@ export const buildUrl = (options) => getUrl({
|
|
|
122
122
|
baseUrl: options.baseUrl,
|
|
123
123
|
path: options.path,
|
|
124
124
|
query: options.query,
|
|
125
|
-
querySerializer: typeof options.querySerializer ===
|
|
125
|
+
querySerializer: typeof options.querySerializer === "function"
|
|
126
126
|
? options.querySerializer
|
|
127
127
|
: createQuerySerializer(options.querySerializer),
|
|
128
128
|
url: options.url,
|
|
129
129
|
});
|
|
130
130
|
export const mergeConfigs = (a, b) => {
|
|
131
131
|
const config = { ...a, ...b };
|
|
132
|
-
if (config.baseUrl?.endsWith(
|
|
132
|
+
if (config.baseUrl?.endsWith("/")) {
|
|
133
133
|
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
134
134
|
}
|
|
135
135
|
config.headers = mergeHeaders(a.headers, b.headers);
|
|
@@ -163,7 +163,7 @@ export const mergeHeaders = (...headers) => {
|
|
|
163
163
|
else if (value !== undefined) {
|
|
164
164
|
// assume object headers are meant to be JSON stringified, i.e. their
|
|
165
165
|
// content value in OpenAPI specification is 'application/json'
|
|
166
|
-
mergedHeaders.set(key, typeof value ===
|
|
166
|
+
mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
}
|
|
@@ -187,7 +187,7 @@ class Interceptors {
|
|
|
187
187
|
return Boolean(this.fns[index]);
|
|
188
188
|
}
|
|
189
189
|
getInterceptorIndex(id) {
|
|
190
|
-
if (typeof id ===
|
|
190
|
+
if (typeof id === "number") {
|
|
191
191
|
return this.fns[id] ? id : -1;
|
|
192
192
|
}
|
|
193
193
|
return this.fns.indexOf(id);
|
|
@@ -214,20 +214,20 @@ const defaultQuerySerializer = createQuerySerializer({
|
|
|
214
214
|
allowReserved: false,
|
|
215
215
|
array: {
|
|
216
216
|
explode: true,
|
|
217
|
-
style:
|
|
217
|
+
style: "form",
|
|
218
218
|
},
|
|
219
219
|
object: {
|
|
220
220
|
explode: true,
|
|
221
|
-
style:
|
|
221
|
+
style: "deepObject",
|
|
222
222
|
},
|
|
223
223
|
});
|
|
224
224
|
const defaultHeaders = {
|
|
225
|
-
|
|
225
|
+
"Content-Type": "application/json",
|
|
226
226
|
};
|
|
227
227
|
export const createConfig = (override = {}) => ({
|
|
228
228
|
...jsonBodySerializer,
|
|
229
229
|
headers: defaultHeaders,
|
|
230
|
-
parseAs:
|
|
230
|
+
parseAs: "auto",
|
|
231
231
|
querySerializer: defaultQuerySerializer,
|
|
232
232
|
...override,
|
|
233
233
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ClientOptions, type Config } from
|
|
2
|
-
import type { ClientOptions as ClientOptions2 } from
|
|
1
|
+
import { type ClientOptions, type Config } from "./client/index.js";
|
|
2
|
+
import type { ClientOptions as ClientOptions2 } from "./types.gen.js";
|
|
3
3
|
/**
|
|
4
4
|
* The `createClientConfig()` function will be called on client initialization
|
|
5
5
|
* and the returned object will become the client's initial configuration.
|
|
@@ -9,5 +9,5 @@ import type { ClientOptions as ClientOptions2 } from './types.gen';
|
|
|
9
9
|
* to ensure your client always has the correct values.
|
|
10
10
|
*/
|
|
11
11
|
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
|
12
|
-
export declare const client: import("./client").Client;
|
|
12
|
+
export declare const client: import("./client/types.gen.js").Client;
|
|
13
13
|
//# sourceMappingURL=client.gen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.gen.d.ts","sourceRoot":"","sources":["../../src/client/client.gen.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.gen.d.ts","sourceRoot":"","sources":["../../src/client/client.gen.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,MAAM,EAGZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,aAAa,IAAI,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEtE;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,aAAa,GAAG,cAAc,IAAI,CACzE,QAAQ,CAAC,EAAE,MAAM,CAAC,aAAa,GAAG,CAAC,CAAC,KACjC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;AAEzC,eAAO,MAAM,MAAM,wCAElB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
import { createClient, createConfig } from
|
|
3
|
-
export const client = createClient(createConfig({ baseUrl:
|
|
2
|
+
import { createClient, createConfig, } from "./client/index.js";
|
|
3
|
+
export const client = createClient(createConfig({ baseUrl: "https://alpha.benji.so/api/rest" }));
|
|
@@ -5,15 +5,15 @@ export interface Auth {
|
|
|
5
5
|
*
|
|
6
6
|
* @default 'header'
|
|
7
7
|
*/
|
|
8
|
-
in?:
|
|
8
|
+
in?: "header" | "query" | "cookie";
|
|
9
9
|
/**
|
|
10
10
|
* Header or query parameter name.
|
|
11
11
|
*
|
|
12
12
|
* @default 'Authorization'
|
|
13
13
|
*/
|
|
14
14
|
name?: string;
|
|
15
|
-
scheme?:
|
|
16
|
-
type:
|
|
15
|
+
scheme?: "basic" | "bearer";
|
|
16
|
+
type: "apiKey" | "http";
|
|
17
17
|
}
|
|
18
18
|
export declare const getAuthToken: (auth: Auth, callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken) => Promise<string | undefined>;
|
|
19
19
|
//# sourceMappingURL=auth.gen.d.ts.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
export const getAuthToken = async (auth, callback) => {
|
|
3
|
-
const token = typeof callback ===
|
|
3
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
4
4
|
if (!token) {
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
7
|
-
if (auth.scheme ===
|
|
7
|
+
if (auth.scheme === "bearer") {
|
|
8
8
|
return `Bearer ${token}`;
|
|
9
9
|
}
|
|
10
|
-
if (auth.scheme ===
|
|
10
|
+
if (auth.scheme === "basic") {
|
|
11
11
|
return `Basic ${btoa(token)}`;
|
|
12
12
|
}
|
|
13
13
|
return token;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ArrayStyle, ObjectStyle, SerializerOptions } from
|
|
1
|
+
import type { ArrayStyle, ObjectStyle, SerializerOptions } from "./pathSerializer.gen.js";
|
|
2
2
|
export type QuerySerializer = (query: Record<string, unknown>) => string;
|
|
3
3
|
export type BodySerializer = (body: any) => any;
|
|
4
4
|
type QuerySerializerOptionsObject = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bodySerializer.gen.d.ts","sourceRoot":"","sources":["../../../src/client/core/bodySerializer.gen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,iBAAiB,EAClB,MAAM,
|
|
1
|
+
{"version":3,"file":"bodySerializer.gen.d.ts","sourceRoot":"","sources":["../../../src/client/core/bodySerializer.gen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,iBAAiB,EAClB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC;AAEzE,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,CAAC;AAEhD,KAAK,4BAA4B,GAAG;IAClC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC;IAC/C,MAAM,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,4BAA4B,GAAG;IAClE;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,4BAA4B,CAAC,CAAC;CAC3D,CAAC;AA4BF,eAAO,MAAM,sBAAsB;qBAChB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,QACnE,CAAC,KACN,QAAQ;CAgBZ,CAAC;AAEF,eAAO,MAAM,kBAAkB;qBACZ,CAAC,QAAQ,CAAC,KAAG,MAAM;CAIrC,CAAC;AAEF,eAAO,MAAM,6BAA6B;qBACvB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,QACnE,CAAC,KACN,MAAM;CAgBV,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
const serializeFormDataPair = (data, key, value) => {
|
|
3
|
-
if (typeof value ===
|
|
3
|
+
if (typeof value === "string" || value instanceof Blob) {
|
|
4
4
|
data.append(key, value);
|
|
5
5
|
}
|
|
6
6
|
else if (value instanceof Date) {
|
|
@@ -11,7 +11,7 @@ const serializeFormDataPair = (data, key, value) => {
|
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
const serializeUrlSearchParamsPair = (data, key, value) => {
|
|
14
|
-
if (typeof value ===
|
|
14
|
+
if (typeof value === "string") {
|
|
15
15
|
data.append(key, value);
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
@@ -36,7 +36,7 @@ export const formDataBodySerializer = {
|
|
|
36
36
|
},
|
|
37
37
|
};
|
|
38
38
|
export const jsonBodySerializer = {
|
|
39
|
-
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value ===
|
|
39
|
+
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value),
|
|
40
40
|
};
|
|
41
41
|
export const urlSearchParamsBodySerializer = {
|
|
42
42
|
bodySerializer: (body) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
type Slot =
|
|
1
|
+
type Slot = "body" | "headers" | "path" | "query";
|
|
2
2
|
export type Field = {
|
|
3
|
-
in: Exclude<Slot,
|
|
3
|
+
in: Exclude<Slot, "body">;
|
|
4
4
|
/**
|
|
5
5
|
* Field name. This is the name we want the user to see and use.
|
|
6
6
|
*/
|
|
@@ -11,7 +11,7 @@ export type Field = {
|
|
|
11
11
|
*/
|
|
12
12
|
map?: string;
|
|
13
13
|
} | {
|
|
14
|
-
in: Extract<Slot,
|
|
14
|
+
in: Extract<Slot, "body">;
|
|
15
15
|
/**
|
|
16
16
|
* Key isn't required for bodies.
|
|
17
17
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
const extraPrefixesMap = {
|
|
3
|
-
$body_:
|
|
4
|
-
$headers_:
|
|
5
|
-
$path_:
|
|
6
|
-
$query_:
|
|
3
|
+
$body_: "body",
|
|
4
|
+
$headers_: "headers",
|
|
5
|
+
$path_: "path",
|
|
6
|
+
$query_: "query",
|
|
7
7
|
};
|
|
8
8
|
const extraPrefixes = Object.entries(extraPrefixesMap);
|
|
9
9
|
const buildKeyMap = (fields, map) => {
|
|
@@ -11,7 +11,7 @@ const buildKeyMap = (fields, map) => {
|
|
|
11
11
|
map = new Map();
|
|
12
12
|
}
|
|
13
13
|
for (const config of fields) {
|
|
14
|
-
if (
|
|
14
|
+
if ("in" in config) {
|
|
15
15
|
if (config.key) {
|
|
16
16
|
map.set(config.key, {
|
|
17
17
|
in: config.in,
|
|
@@ -19,7 +19,7 @@ const buildKeyMap = (fields, map) => {
|
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
else if (
|
|
22
|
+
else if ("key" in config) {
|
|
23
23
|
map.set(config.key, {
|
|
24
24
|
map: config.map,
|
|
25
25
|
});
|
|
@@ -32,7 +32,7 @@ const buildKeyMap = (fields, map) => {
|
|
|
32
32
|
};
|
|
33
33
|
const stripEmptySlots = (params) => {
|
|
34
34
|
for (const [slot, value] of Object.entries(params)) {
|
|
35
|
-
if (value && typeof value ===
|
|
35
|
+
if (value && typeof value === "object" && !Object.keys(value).length) {
|
|
36
36
|
delete params[slot];
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -53,7 +53,7 @@ export const buildClientParams = (args, fields) => {
|
|
|
53
53
|
if (!config) {
|
|
54
54
|
continue;
|
|
55
55
|
}
|
|
56
|
-
if (
|
|
56
|
+
if ("in" in config) {
|
|
57
57
|
if (config.key) {
|
|
58
58
|
const field = map.get(config.key);
|
|
59
59
|
const name = field.map || config.key;
|
|
@@ -83,7 +83,7 @@ export const buildClientParams = (args, fields) => {
|
|
|
83
83
|
const [prefix, slot] = extra;
|
|
84
84
|
params[slot][key.slice(prefix.length)] = value;
|
|
85
85
|
}
|
|
86
|
-
else if (
|
|
86
|
+
else if ("allowExtra" in config && config.allowExtra) {
|
|
87
87
|
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
|
|
88
88
|
if (allowed) {
|
|
89
89
|
params[slot][key] = value;
|
|
@@ -11,10 +11,10 @@ export interface SerializerOptions<T> {
|
|
|
11
11
|
explode: boolean;
|
|
12
12
|
style: T;
|
|
13
13
|
}
|
|
14
|
-
export type ArrayStyle =
|
|
14
|
+
export type ArrayStyle = "form" | "spaceDelimited" | "pipeDelimited";
|
|
15
15
|
export type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
|
|
16
|
-
type MatrixStyle =
|
|
17
|
-
export type ObjectStyle =
|
|
16
|
+
type MatrixStyle = "label" | "matrix" | "simple";
|
|
17
|
+
export type ObjectStyle = "form" | "deepObject";
|
|
18
18
|
type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
|
|
19
19
|
interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
|
20
20
|
value: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathSerializer.gen.d.ts","sourceRoot":"","sources":["../../../src/client/core/pathSerializer.gen.ts"],"names":[],"mappings":"AAEA,UAAU,gBAAgB,CAAC,CAAC,CAC1B,SAAQ,yBAAyB,
|
|
1
|
+
{"version":3,"file":"pathSerializer.gen.d.ts","sourceRoot":"","sources":["../../../src/client/core/pathSerializer.gen.ts"],"names":[],"mappings":"AAEA,UAAU,gBAAgB,CAAC,CAAC,CAC1B,SAAQ,yBAAyB,EAAE,iBAAiB,CAAC,CAAC,CAAC;CAAG;AAE5D,UAAU,yBAAyB;IACjC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,CAAC,CAAC;CACV;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,gBAAgB,GAAG,eAAe,CAAC;AACrE,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,WAAW,CAAC;AAC3D,KAAK,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACjD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,YAAY,CAAC;AAChD,KAAK,oBAAoB,GAAG,WAAW,GAAG,WAAW,CAAC;AAEtD,UAAU,uBAAwB,SAAQ,yBAAyB;IACjE,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,qBAAqB,GAAI,OAAO,mBAAmB,0BAW/D,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,OAAO,mBAAmB,sBAWjE,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,OAAO,oBAAoB,0BAWjE,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,iDAMjC,gBAAgB,CAAC,mBAAmB,CAAC,GAAG;IACzC,KAAK,EAAE,OAAO,EAAE,CAAC;CAClB,WAkCA,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,iCAIrC,uBAAuB,WAYzB,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,4DAOlC,gBAAgB,CAAC,oBAAoB,CAAC,GAAG;IAC1C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,WAwCA,CAAC"}
|
|
@@ -1,49 +1,49 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
export const separatorArrayExplode = (style) => {
|
|
3
3
|
switch (style) {
|
|
4
|
-
case
|
|
5
|
-
return
|
|
6
|
-
case
|
|
7
|
-
return
|
|
8
|
-
case
|
|
9
|
-
return
|
|
4
|
+
case "label":
|
|
5
|
+
return ".";
|
|
6
|
+
case "matrix":
|
|
7
|
+
return ";";
|
|
8
|
+
case "simple":
|
|
9
|
+
return ",";
|
|
10
10
|
default:
|
|
11
|
-
return
|
|
11
|
+
return "&";
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
export const separatorArrayNoExplode = (style) => {
|
|
15
15
|
switch (style) {
|
|
16
|
-
case
|
|
17
|
-
return
|
|
18
|
-
case
|
|
19
|
-
return
|
|
20
|
-
case
|
|
21
|
-
return
|
|
16
|
+
case "form":
|
|
17
|
+
return ",";
|
|
18
|
+
case "pipeDelimited":
|
|
19
|
+
return "|";
|
|
20
|
+
case "spaceDelimited":
|
|
21
|
+
return "%20";
|
|
22
22
|
default:
|
|
23
|
-
return
|
|
23
|
+
return ",";
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
export const separatorObjectExplode = (style) => {
|
|
27
27
|
switch (style) {
|
|
28
|
-
case
|
|
29
|
-
return
|
|
30
|
-
case
|
|
31
|
-
return
|
|
32
|
-
case
|
|
33
|
-
return
|
|
28
|
+
case "label":
|
|
29
|
+
return ".";
|
|
30
|
+
case "matrix":
|
|
31
|
+
return ";";
|
|
32
|
+
case "simple":
|
|
33
|
+
return ",";
|
|
34
34
|
default:
|
|
35
|
-
return
|
|
35
|
+
return "&";
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
export const serializeArrayParam = ({ allowReserved, explode, name, style, value, }) => {
|
|
39
39
|
if (!explode) {
|
|
40
40
|
const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
41
41
|
switch (style) {
|
|
42
|
-
case
|
|
42
|
+
case "label":
|
|
43
43
|
return `.${joinedValues}`;
|
|
44
|
-
case
|
|
44
|
+
case "matrix":
|
|
45
45
|
return `;${name}=${joinedValues}`;
|
|
46
|
-
case
|
|
46
|
+
case "simple":
|
|
47
47
|
return joinedValues;
|
|
48
48
|
default:
|
|
49
49
|
return `${name}=${joinedValues}`;
|
|
@@ -52,7 +52,7 @@ export const serializeArrayParam = ({ allowReserved, explode, name, style, value
|
|
|
52
52
|
const separator = separatorArrayExplode(style);
|
|
53
53
|
const joinedValues = value
|
|
54
54
|
.map((v) => {
|
|
55
|
-
if (style ===
|
|
55
|
+
if (style === "label" || style === "simple") {
|
|
56
56
|
return allowReserved ? v : encodeURIComponent(v);
|
|
57
57
|
}
|
|
58
58
|
return serializePrimitiveParam({
|
|
@@ -62,16 +62,16 @@ export const serializeArrayParam = ({ allowReserved, explode, name, style, value
|
|
|
62
62
|
});
|
|
63
63
|
})
|
|
64
64
|
.join(separator);
|
|
65
|
-
return style ===
|
|
65
|
+
return style === "label" || style === "matrix"
|
|
66
66
|
? separator + joinedValues
|
|
67
67
|
: joinedValues;
|
|
68
68
|
};
|
|
69
69
|
export const serializePrimitiveParam = ({ allowReserved, name, value, }) => {
|
|
70
70
|
if (value === undefined || value === null) {
|
|
71
|
-
return
|
|
71
|
+
return "";
|
|
72
72
|
}
|
|
73
|
-
if (typeof value ===
|
|
74
|
-
throw new Error(
|
|
73
|
+
if (typeof value === "object") {
|
|
74
|
+
throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
|
|
75
75
|
}
|
|
76
76
|
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
77
77
|
};
|
|
@@ -79,7 +79,7 @@ export const serializeObjectParam = ({ allowReserved, explode, name, style, valu
|
|
|
79
79
|
if (value instanceof Date) {
|
|
80
80
|
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
81
81
|
}
|
|
82
|
-
if (style !==
|
|
82
|
+
if (style !== "deepObject" && !explode) {
|
|
83
83
|
let values = [];
|
|
84
84
|
Object.entries(value).forEach(([key, v]) => {
|
|
85
85
|
values = [
|
|
@@ -88,13 +88,13 @@ export const serializeObjectParam = ({ allowReserved, explode, name, style, valu
|
|
|
88
88
|
allowReserved ? v : encodeURIComponent(v),
|
|
89
89
|
];
|
|
90
90
|
});
|
|
91
|
-
const joinedValues = values.join(
|
|
91
|
+
const joinedValues = values.join(",");
|
|
92
92
|
switch (style) {
|
|
93
|
-
case
|
|
93
|
+
case "form":
|
|
94
94
|
return `${name}=${joinedValues}`;
|
|
95
|
-
case
|
|
95
|
+
case "label":
|
|
96
96
|
return `.${joinedValues}`;
|
|
97
|
-
case
|
|
97
|
+
case "matrix":
|
|
98
98
|
return `;${name}=${joinedValues}`;
|
|
99
99
|
default:
|
|
100
100
|
return joinedValues;
|
|
@@ -104,11 +104,11 @@ export const serializeObjectParam = ({ allowReserved, explode, name, style, valu
|
|
|
104
104
|
const joinedValues = Object.entries(value)
|
|
105
105
|
.map(([key, v]) => serializePrimitiveParam({
|
|
106
106
|
allowReserved,
|
|
107
|
-
name: style ===
|
|
107
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
108
108
|
value: v,
|
|
109
109
|
}))
|
|
110
110
|
.join(separator);
|
|
111
|
-
return style ===
|
|
111
|
+
return style === "label" || style === "matrix"
|
|
112
112
|
? separator + joinedValues
|
|
113
113
|
: joinedValues;
|
|
114
114
|
};
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export const queryKeyJsonReplacer = (_key, value) => {
|
|
6
6
|
if (value === undefined ||
|
|
7
|
-
typeof value ===
|
|
8
|
-
typeof value ===
|
|
7
|
+
typeof value === "function" ||
|
|
8
|
+
typeof value === "symbol") {
|
|
9
9
|
return undefined;
|
|
10
10
|
}
|
|
11
|
-
if (typeof value ===
|
|
11
|
+
if (typeof value === "bigint") {
|
|
12
12
|
return value.toString();
|
|
13
13
|
}
|
|
14
14
|
if (value instanceof Date) {
|
|
@@ -35,7 +35,7 @@ export const stringifyToJsonValue = (input) => {
|
|
|
35
35
|
* Detects plain objects (including objects with a null prototype).
|
|
36
36
|
*/
|
|
37
37
|
const isPlainObject = (value) => {
|
|
38
|
-
if (value === null || typeof value !==
|
|
38
|
+
if (value === null || typeof value !== "object") {
|
|
39
39
|
return false;
|
|
40
40
|
}
|
|
41
41
|
const prototype = Object.getPrototypeOf(value);
|
|
@@ -69,17 +69,17 @@ export const serializeQueryKeyValue = (value) => {
|
|
|
69
69
|
if (value === null) {
|
|
70
70
|
return null;
|
|
71
71
|
}
|
|
72
|
-
if (typeof value ===
|
|
73
|
-
typeof value ===
|
|
74
|
-
typeof value ===
|
|
72
|
+
if (typeof value === "string" ||
|
|
73
|
+
typeof value === "number" ||
|
|
74
|
+
typeof value === "boolean") {
|
|
75
75
|
return value;
|
|
76
76
|
}
|
|
77
77
|
if (value === undefined ||
|
|
78
|
-
typeof value ===
|
|
79
|
-
typeof value ===
|
|
78
|
+
typeof value === "function" ||
|
|
79
|
+
typeof value === "symbol") {
|
|
80
80
|
return undefined;
|
|
81
81
|
}
|
|
82
|
-
if (typeof value ===
|
|
82
|
+
if (typeof value === "bigint") {
|
|
83
83
|
return value.toString();
|
|
84
84
|
}
|
|
85
85
|
if (value instanceof Date) {
|
|
@@ -88,7 +88,7 @@ export const serializeQueryKeyValue = (value) => {
|
|
|
88
88
|
if (Array.isArray(value)) {
|
|
89
89
|
return stringifyToJsonValue(value);
|
|
90
90
|
}
|
|
91
|
-
if (typeof URLSearchParams !==
|
|
91
|
+
if (typeof URLSearchParams !== "undefined" &&
|
|
92
92
|
value instanceof URLSearchParams) {
|
|
93
93
|
return serializeSearchParams(value);
|
|
94
94
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Config } from
|
|
2
|
-
export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit,
|
|
1
|
+
import type { Config } from "./types.gen.js";
|
|
2
|
+
export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, "method"> & Pick<Config, "method" | "responseTransformer" | "responseValidator"> & {
|
|
3
3
|
/**
|
|
4
4
|
* Fetch API implementation. You can use this option to provide a custom
|
|
5
5
|
* fetch instance.
|
|
@@ -28,7 +28,7 @@ export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method
|
|
|
28
28
|
* @returns Nothing (void).
|
|
29
29
|
*/
|
|
30
30
|
onSseEvent?: (event: StreamEvent<TData>) => void;
|
|
31
|
-
serializedBody?: RequestInit[
|
|
31
|
+
serializedBody?: RequestInit["body"];
|
|
32
32
|
/**
|
|
33
33
|
* Default retry delay in milliseconds.
|
|
34
34
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverSentEvents.gen.d.ts","sourceRoot":"","sources":["../../../src/client/core/serverSentEvents.gen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"serverSentEvents.gen.d.ts","sourceRoot":"","sources":["../../../src/client/core/serverSentEvents.gen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,MAAM,uBAAuB,CAAC,KAAK,GAAG,OAAO,IAAI,IAAI,CACzD,WAAW,EACX,QAAQ,CACT,GACC,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,qBAAqB,GAAG,mBAAmB,CAAC,GAAG;IACrE;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjE;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IACjD,cAAc,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC;;;;;;OAMG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEJ,MAAM,WAAW,WAAW,CAAC,KAAK,GAAG,OAAO;IAC1C,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,sBAAsB,CAChC,KAAK,GAAG,OAAO,EACf,OAAO,GAAG,IAAI,EACd,KAAK,GAAG,OAAO,IACb;IACF,MAAM,EAAE,cAAc,CACpB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,KAAK,CAAC,GAAG,KAAK,EAClE,OAAO,EACP,KAAK,CACN,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,KAAK,GAAG,OAAO,EAAE,yKAY9C,uBAAuB,KAAG,sBAAsB,CAAC,KAAK,CAqKxD,CAAC"}
|