@renai-labs/sdk 0.1.0 → 0.1.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/auth.d.ts +1 -0
- package/dist/auth.js +2 -1
- package/dist/client.js +12 -1
- package/dist/generated/@tanstack/react-query.gen.d.ts +915 -1201
- package/dist/generated/@tanstack/react-query.gen.js +1063 -1473
- package/dist/generated/client/client.gen.d.ts +1 -1
- package/dist/generated/client/client.gen.js +44 -46
- package/dist/generated/client/index.d.ts +8 -8
- package/dist/generated/client/index.js +5 -5
- package/dist/generated/client/types.gen.d.ts +18 -18
- package/dist/generated/client/utils.gen.d.ts +3 -3
- package/dist/generated/client/utils.gen.js +33 -35
- package/dist/generated/client.gen.d.ts +2 -2
- package/dist/generated/client.gen.js +1 -1
- package/dist/generated/core/auth.gen.d.ts +3 -3
- package/dist/generated/core/auth.gen.js +3 -3
- package/dist/generated/core/bodySerializer.gen.d.ts +1 -1
- package/dist/generated/core/bodySerializer.gen.js +3 -3
- package/dist/generated/core/params.gen.d.ts +3 -3
- package/dist/generated/core/params.gen.js +11 -9
- package/dist/generated/core/pathSerializer.gen.d.ts +4 -4
- package/dist/generated/core/pathSerializer.gen.js +37 -37
- package/dist/generated/core/queryKeySerializer.gen.js +8 -7
- package/dist/generated/core/serverSentEvents.gen.d.ts +3 -3
- package/dist/generated/core/serverSentEvents.gen.js +19 -19
- package/dist/generated/core/types.gen.d.ts +4 -4
- package/dist/generated/core/utils.gen.d.ts +1 -1
- package/dist/generated/core/utils.gen.js +17 -17
- package/dist/generated/internal/types.gen.d.ts +664 -0
- package/dist/generated/internal/types.gen.js +2 -0
- package/dist/generated/sdk.gen.d.ts +281 -343
- package/dist/generated/sdk.gen.js +930 -723
- package/dist/generated/types.gen.d.ts +2626 -2238
- package/dist/generated/zod.gen.d.ts +5569 -2277
- package/dist/generated/zod.gen.js +1757 -1118
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +11 -3
|
@@ -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" && !Array.isArray(value) && !Object.keys(value).length) {
|
|
36
36
|
delete params[slot];
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -53,11 +53,12 @@ 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;
|
|
60
60
|
if (field.in) {
|
|
61
|
+
;
|
|
61
62
|
params[field.in][name] = arg;
|
|
62
63
|
}
|
|
63
64
|
}
|
|
@@ -83,9 +84,10 @@ export const buildClientParams = (args, fields) => {
|
|
|
83
84
|
const [prefix, slot] = extra;
|
|
84
85
|
params[slot][key.slice(prefix.length)] = value;
|
|
85
86
|
}
|
|
86
|
-
else if (
|
|
87
|
+
else if ("allowExtra" in config && config.allowExtra) {
|
|
87
88
|
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
|
|
88
89
|
if (allowed) {
|
|
90
|
+
;
|
|
89
91
|
params[slot][key] = value;
|
|
90
92
|
break;
|
|
91
93
|
}
|
|
@@ -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;
|
|
@@ -25,7 +25,7 @@ export declare const separatorObjectExplode: (style: ObjectSeparatorStyle) => ".
|
|
|
25
25
|
export declare const serializeArrayParam: ({ allowReserved, explode, name, style, value, }: SerializeOptions<ArraySeparatorStyle> & {
|
|
26
26
|
value: unknown[];
|
|
27
27
|
}) => string;
|
|
28
|
-
export declare const serializePrimitiveParam: ({ allowReserved, name, value
|
|
28
|
+
export declare const serializePrimitiveParam: ({ allowReserved, name, value }: SerializePrimitiveParam) => string;
|
|
29
29
|
export declare const serializeObjectParam: ({ allowReserved, explode, name, style, value, valueOnly, }: SerializeOptions<ObjectSeparatorStyle> & {
|
|
30
30
|
value: Record<string, unknown> | Date;
|
|
31
31
|
valueOnly?: boolean;
|
|
@@ -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,14 +62,14 @@ 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" ? separator + joinedValues : joinedValues;
|
|
66
66
|
};
|
|
67
|
-
export const serializePrimitiveParam = ({ allowReserved, name, value
|
|
67
|
+
export const serializePrimitiveParam = ({ allowReserved, name, value }) => {
|
|
68
68
|
if (value === undefined || value === null) {
|
|
69
|
-
return
|
|
69
|
+
return "";
|
|
70
70
|
}
|
|
71
|
-
if (typeof value ===
|
|
72
|
-
throw new Error(
|
|
71
|
+
if (typeof value === "object") {
|
|
72
|
+
throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
|
|
73
73
|
}
|
|
74
74
|
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
75
75
|
};
|
|
@@ -77,18 +77,18 @@ export const serializeObjectParam = ({ allowReserved, explode, name, style, valu
|
|
|
77
77
|
if (value instanceof Date) {
|
|
78
78
|
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
79
79
|
}
|
|
80
|
-
if (style !==
|
|
80
|
+
if (style !== "deepObject" && !explode) {
|
|
81
81
|
let values = [];
|
|
82
82
|
Object.entries(value).forEach(([key, v]) => {
|
|
83
83
|
values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
|
|
84
84
|
});
|
|
85
|
-
const joinedValues = values.join(
|
|
85
|
+
const joinedValues = values.join(",");
|
|
86
86
|
switch (style) {
|
|
87
|
-
case
|
|
87
|
+
case "form":
|
|
88
88
|
return `${name}=${joinedValues}`;
|
|
89
|
-
case
|
|
89
|
+
case "label":
|
|
90
90
|
return `.${joinedValues}`;
|
|
91
|
-
case
|
|
91
|
+
case "matrix":
|
|
92
92
|
return `;${name}=${joinedValues}`;
|
|
93
93
|
default:
|
|
94
94
|
return joinedValues;
|
|
@@ -98,9 +98,9 @@ export const serializeObjectParam = ({ allowReserved, explode, name, style, valu
|
|
|
98
98
|
const joinedValues = Object.entries(value)
|
|
99
99
|
.map(([key, v]) => serializePrimitiveParam({
|
|
100
100
|
allowReserved,
|
|
101
|
-
name: style ===
|
|
101
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
102
102
|
value: v,
|
|
103
103
|
}))
|
|
104
104
|
.join(separator);
|
|
105
|
-
return style ===
|
|
105
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
106
106
|
};
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
|
|
4
4
|
*/
|
|
5
5
|
export const queryKeyJsonReplacer = (_key, value) => {
|
|
6
|
-
if (value === undefined || typeof value ===
|
|
6
|
+
if (value === undefined || typeof value === "function" || typeof value === "symbol") {
|
|
7
7
|
return undefined;
|
|
8
8
|
}
|
|
9
|
-
if (typeof value ===
|
|
9
|
+
if (typeof value === "bigint") {
|
|
10
10
|
return value.toString();
|
|
11
11
|
}
|
|
12
12
|
if (value instanceof Date) {
|
|
@@ -33,7 +33,7 @@ export const stringifyToJsonValue = (input) => {
|
|
|
33
33
|
* Detects plain objects (including objects with a null prototype).
|
|
34
34
|
*/
|
|
35
35
|
const isPlainObject = (value) => {
|
|
36
|
-
if (value === null || typeof value !==
|
|
36
|
+
if (value === null || typeof value !== "object") {
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
39
39
|
const prototype = Object.getPrototypeOf(value);
|
|
@@ -52,6 +52,7 @@ const serializeSearchParams = (params) => {
|
|
|
52
52
|
continue;
|
|
53
53
|
}
|
|
54
54
|
if (Array.isArray(existing)) {
|
|
55
|
+
;
|
|
55
56
|
existing.push(value);
|
|
56
57
|
}
|
|
57
58
|
else {
|
|
@@ -67,13 +68,13 @@ export const serializeQueryKeyValue = (value) => {
|
|
|
67
68
|
if (value === null) {
|
|
68
69
|
return null;
|
|
69
70
|
}
|
|
70
|
-
if (typeof value ===
|
|
71
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
71
72
|
return value;
|
|
72
73
|
}
|
|
73
|
-
if (value === undefined || typeof value ===
|
|
74
|
+
if (value === undefined || typeof value === "function" || typeof value === "symbol") {
|
|
74
75
|
return undefined;
|
|
75
76
|
}
|
|
76
|
-
if (typeof value ===
|
|
77
|
+
if (typeof value === "bigint") {
|
|
77
78
|
return value.toString();
|
|
78
79
|
}
|
|
79
80
|
if (value instanceof Date) {
|
|
@@ -82,7 +83,7 @@ export const serializeQueryKeyValue = (value) => {
|
|
|
82
83
|
if (Array.isArray(value)) {
|
|
83
84
|
return stringifyToJsonValue(value);
|
|
84
85
|
}
|
|
85
|
-
if (typeof URLSearchParams !==
|
|
86
|
+
if (typeof URLSearchParams !== "undefined" && value instanceof URLSearchParams) {
|
|
86
87
|
return serializeSearchParams(value);
|
|
87
88
|
}
|
|
88
89
|
if (isPlainObject(value)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Config } from
|
|
2
|
-
export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit,
|
|
1
|
+
import type { Config } from "./types.gen";
|
|
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
|
*
|
|
@@ -14,11 +14,11 @@ export function createSseClient({ onRequest, onSseError, onSseEvent, responseTra
|
|
|
14
14
|
? options.headers
|
|
15
15
|
: new Headers(options.headers);
|
|
16
16
|
if (lastEventId !== undefined) {
|
|
17
|
-
headers.set(
|
|
17
|
+
headers.set("Last-Event-ID", lastEventId);
|
|
18
18
|
}
|
|
19
19
|
try {
|
|
20
20
|
const requestInit = {
|
|
21
|
-
redirect:
|
|
21
|
+
redirect: "follow",
|
|
22
22
|
...options,
|
|
23
23
|
body: options.serializedBody,
|
|
24
24
|
headers,
|
|
@@ -35,9 +35,9 @@ export function createSseClient({ onRequest, onSseError, onSseEvent, responseTra
|
|
|
35
35
|
if (!response.ok)
|
|
36
36
|
throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
37
37
|
if (!response.body)
|
|
38
|
-
throw new Error(
|
|
38
|
+
throw new Error("No body in SSE response");
|
|
39
39
|
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
40
|
-
let buffer =
|
|
40
|
+
let buffer = "";
|
|
41
41
|
const abortHandler = () => {
|
|
42
42
|
try {
|
|
43
43
|
reader.cancel();
|
|
@@ -46,32 +46,32 @@ export function createSseClient({ onRequest, onSseError, onSseEvent, responseTra
|
|
|
46
46
|
// noop
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
signal.addEventListener(
|
|
49
|
+
signal.addEventListener("abort", abortHandler);
|
|
50
50
|
try {
|
|
51
51
|
while (true) {
|
|
52
52
|
const { done, value } = await reader.read();
|
|
53
53
|
if (done)
|
|
54
54
|
break;
|
|
55
55
|
buffer += value;
|
|
56
|
-
buffer = buffer.replace(/\r\n?/g,
|
|
57
|
-
const chunks = buffer.split(
|
|
58
|
-
buffer = chunks.pop() ??
|
|
56
|
+
buffer = buffer.replace(/\r\n?/g, "\n"); // normalize line endings
|
|
57
|
+
const chunks = buffer.split("\n\n");
|
|
58
|
+
buffer = chunks.pop() ?? "";
|
|
59
59
|
for (const chunk of chunks) {
|
|
60
|
-
const lines = chunk.split(
|
|
60
|
+
const lines = chunk.split("\n");
|
|
61
61
|
const dataLines = [];
|
|
62
62
|
let eventName;
|
|
63
63
|
for (const line of lines) {
|
|
64
|
-
if (line.startsWith(
|
|
65
|
-
dataLines.push(line.replace(/^data:\s*/,
|
|
64
|
+
if (line.startsWith("data:")) {
|
|
65
|
+
dataLines.push(line.replace(/^data:\s*/, ""));
|
|
66
66
|
}
|
|
67
|
-
else if (line.startsWith(
|
|
68
|
-
eventName = line.replace(/^event:\s*/,
|
|
67
|
+
else if (line.startsWith("event:")) {
|
|
68
|
+
eventName = line.replace(/^event:\s*/, "");
|
|
69
69
|
}
|
|
70
|
-
else if (line.startsWith(
|
|
71
|
-
lastEventId = line.replace(/^id:\s*/,
|
|
70
|
+
else if (line.startsWith("id:")) {
|
|
71
|
+
lastEventId = line.replace(/^id:\s*/, "");
|
|
72
72
|
}
|
|
73
|
-
else if (line.startsWith(
|
|
74
|
-
const parsed = Number.parseInt(line.replace(/^retry:\s*/,
|
|
73
|
+
else if (line.startsWith("retry:")) {
|
|
74
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
75
75
|
if (!Number.isNaN(parsed)) {
|
|
76
76
|
retryDelay = parsed;
|
|
77
77
|
}
|
|
@@ -80,7 +80,7 @@ export function createSseClient({ onRequest, onSseError, onSseEvent, responseTra
|
|
|
80
80
|
let data;
|
|
81
81
|
let parsedJson = false;
|
|
82
82
|
if (dataLines.length) {
|
|
83
|
-
const rawData = dataLines.join(
|
|
83
|
+
const rawData = dataLines.join("\n");
|
|
84
84
|
try {
|
|
85
85
|
data = JSON.parse(rawData);
|
|
86
86
|
parsedJson = true;
|
|
@@ -110,7 +110,7 @@ export function createSseClient({ onRequest, onSseError, onSseEvent, responseTra
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
finally {
|
|
113
|
-
signal.removeEventListener(
|
|
113
|
+
signal.removeEventListener("abort", abortHandler);
|
|
114
114
|
reader.releaseLock();
|
|
115
115
|
}
|
|
116
116
|
break; // exit loop on normal completion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Auth, AuthToken } from
|
|
2
|
-
import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from
|
|
3
|
-
export type HttpMethod =
|
|
1
|
+
import type { Auth, AuthToken } from "./auth.gen";
|
|
2
|
+
import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from "./bodySerializer.gen";
|
|
3
|
+
export type HttpMethod = "connect" | "delete" | "get" | "head" | "options" | "patch" | "post" | "put" | "trace";
|
|
4
4
|
export type Client<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
|
|
5
5
|
/**
|
|
6
6
|
* Returns the final request URL.
|
|
@@ -35,7 +35,7 @@ export interface Config {
|
|
|
35
35
|
*
|
|
36
36
|
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
|
37
37
|
*/
|
|
38
|
-
headers?: RequestInit[
|
|
38
|
+
headers?: RequestInit["headers"] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
|
|
39
39
|
/**
|
|
40
40
|
* The request method.
|
|
41
41
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam, } from
|
|
2
|
+
import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam, } from "./pathSerializer.gen";
|
|
3
3
|
export const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
4
4
|
export const defaultPathSerializer = ({ path, url: _url }) => {
|
|
5
5
|
let url = _url;
|
|
@@ -8,18 +8,18 @@ export const defaultPathSerializer = ({ path, url: _url }) => {
|
|
|
8
8
|
for (const match of matches) {
|
|
9
9
|
let explode = false;
|
|
10
10
|
let name = match.substring(1, match.length - 1);
|
|
11
|
-
let style =
|
|
12
|
-
if (name.endsWith(
|
|
11
|
+
let style = "simple";
|
|
12
|
+
if (name.endsWith("*")) {
|
|
13
13
|
explode = true;
|
|
14
14
|
name = name.substring(0, name.length - 1);
|
|
15
15
|
}
|
|
16
|
-
if (name.startsWith(
|
|
16
|
+
if (name.startsWith(".")) {
|
|
17
17
|
name = name.substring(1);
|
|
18
|
-
style =
|
|
18
|
+
style = "label";
|
|
19
19
|
}
|
|
20
|
-
else if (name.startsWith(
|
|
20
|
+
else if (name.startsWith(";")) {
|
|
21
21
|
name = name.substring(1);
|
|
22
|
-
style =
|
|
22
|
+
style = "matrix";
|
|
23
23
|
}
|
|
24
24
|
const value = path[name];
|
|
25
25
|
if (value === undefined || value === null) {
|
|
@@ -29,7 +29,7 @@ export const defaultPathSerializer = ({ path, url: _url }) => {
|
|
|
29
29
|
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
30
30
|
continue;
|
|
31
31
|
}
|
|
32
|
-
if (typeof value ===
|
|
32
|
+
if (typeof value === "object") {
|
|
33
33
|
url = url.replace(match, serializeObjectParam({
|
|
34
34
|
explode,
|
|
35
35
|
name,
|
|
@@ -39,27 +39,27 @@ export const defaultPathSerializer = ({ path, url: _url }) => {
|
|
|
39
39
|
}));
|
|
40
40
|
continue;
|
|
41
41
|
}
|
|
42
|
-
if (style ===
|
|
42
|
+
if (style === "matrix") {
|
|
43
43
|
url = url.replace(match, `;${serializePrimitiveParam({
|
|
44
44
|
name,
|
|
45
45
|
value: value,
|
|
46
46
|
})}`);
|
|
47
47
|
continue;
|
|
48
48
|
}
|
|
49
|
-
const replaceValue = encodeURIComponent(style ===
|
|
49
|
+
const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
|
|
50
50
|
url = url.replace(match, replaceValue);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
return url;
|
|
54
54
|
};
|
|
55
55
|
export const getUrl = ({ baseUrl, path, query, querySerializer, url: _url, }) => {
|
|
56
|
-
const pathUrl = _url.startsWith(
|
|
57
|
-
let url = (baseUrl ??
|
|
56
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
57
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
58
58
|
if (path) {
|
|
59
59
|
url = defaultPathSerializer({ path, url });
|
|
60
60
|
}
|
|
61
|
-
let search = query ? querySerializer(query) :
|
|
62
|
-
if (search.startsWith(
|
|
61
|
+
let search = query ? querySerializer(query) : "";
|
|
62
|
+
if (search.startsWith("?")) {
|
|
63
63
|
search = search.substring(1);
|
|
64
64
|
}
|
|
65
65
|
if (search) {
|
|
@@ -71,12 +71,12 @@ export function getValidRequestBody(options) {
|
|
|
71
71
|
const hasBody = options.body !== undefined;
|
|
72
72
|
const isSerializedBody = hasBody && options.bodySerializer;
|
|
73
73
|
if (isSerializedBody) {
|
|
74
|
-
if (
|
|
75
|
-
const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !==
|
|
74
|
+
if ("serializedBody" in options) {
|
|
75
|
+
const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== "";
|
|
76
76
|
return hasSerializedBody ? options.serializedBody : null;
|
|
77
77
|
}
|
|
78
78
|
// not all clients implement a serializedBody property (i.e., client-axios)
|
|
79
|
-
return options.body !==
|
|
79
|
+
return options.body !== "" ? options.body : null;
|
|
80
80
|
}
|
|
81
81
|
// plain/text body
|
|
82
82
|
if (hasBody) {
|