@robosystems/client 0.1.15 → 0.1.17
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/extensions/hooks.d.ts +1 -1
- package/package.json +48 -6
- package/sdk/client/client.gen.d.ts +2 -0
- package/sdk/client/client.gen.js +153 -0
- package/sdk/client/client.gen.ts +200 -0
- package/sdk/client/index.d.ts +7 -0
- package/sdk/client/index.js +15 -0
- package/sdk/client/index.ts +25 -0
- package/sdk/client/types.gen.d.ts +122 -0
- package/sdk/client/types.gen.js +4 -0
- package/sdk/client/types.gen.ts +233 -0
- package/sdk/client/utils.gen.d.ts +45 -0
- package/sdk/client/utils.gen.js +296 -0
- package/sdk/client/utils.gen.ts +419 -0
- package/sdk/client.gen.d.ts +12 -0
- package/sdk/client.gen.js +8 -0
- package/sdk/client.gen.ts +18 -0
- package/sdk/core/auth.gen.d.ts +18 -0
- package/sdk/core/auth.gen.js +18 -0
- package/sdk/core/auth.gen.ts +42 -0
- package/sdk/core/bodySerializer.gen.d.ts +17 -0
- package/sdk/core/bodySerializer.gen.js +57 -0
- package/sdk/core/bodySerializer.gen.ts +90 -0
- package/sdk/core/params.gen.d.ts +33 -0
- package/sdk/core/params.gen.js +92 -0
- package/sdk/core/params.gen.ts +153 -0
- package/sdk/core/pathSerializer.gen.d.ts +33 -0
- package/sdk/core/pathSerializer.gen.js +123 -0
- package/sdk/core/pathSerializer.gen.ts +181 -0
- package/sdk/core/types.gen.d.ts +78 -0
- package/sdk/core/types.gen.js +4 -0
- package/sdk/core/types.gen.ts +121 -0
- package/sdk/index.d.ts +2 -0
- package/sdk/index.js +19 -0
- package/sdk/index.ts +3 -0
- package/sdk/sdk.gen.d.ts +1249 -0
- package/sdk/sdk.gen.js +2572 -0
- package/sdk/sdk.gen.ts +2585 -0
- package/sdk/types.gen.d.ts +6347 -0
- package/sdk/types.gen.js +3 -0
- package/sdk/types.gen.ts +6852 -0
- package/sdk-extensions/OperationClient.d.ts +64 -0
- package/sdk-extensions/OperationClient.js +251 -0
- package/sdk-extensions/OperationClient.ts +322 -0
- package/sdk-extensions/QueryClient.d.ts +50 -0
- package/sdk-extensions/QueryClient.js +190 -0
- package/sdk-extensions/QueryClient.ts +283 -0
- package/sdk-extensions/README.md +672 -0
- package/sdk-extensions/SSEClient.d.ts +48 -0
- package/sdk-extensions/SSEClient.js +148 -0
- package/sdk-extensions/SSEClient.ts +189 -0
- package/sdk-extensions/config.d.ts +32 -0
- package/sdk-extensions/config.js +74 -0
- package/sdk-extensions/config.ts +91 -0
- package/sdk-extensions/hooks.d.ts +110 -0
- package/sdk-extensions/hooks.js +371 -0
- package/sdk-extensions/hooks.ts +438 -0
- package/sdk-extensions/index.d.ts +46 -0
- package/sdk-extensions/index.js +110 -0
- package/sdk-extensions/index.ts +123 -0
- package/sdk.gen.d.ts +210 -104
- package/sdk.gen.js +409 -287
- package/sdk.gen.ts +404 -282
- package/types.gen.d.ts +1218 -567
- package/types.gen.ts +1236 -566
- package/openapi-ts.config.js +0 -9
- package/prepare.js +0 -220
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
type Slot = 'body' | 'headers' | 'path' | 'query';
|
|
2
|
+
export type Field = {
|
|
3
|
+
in: Exclude<Slot, 'body'>;
|
|
4
|
+
/**
|
|
5
|
+
* Field name. This is the name we want the user to see and use.
|
|
6
|
+
*/
|
|
7
|
+
key: string;
|
|
8
|
+
/**
|
|
9
|
+
* Field mapped name. This is the name we want to use in the request.
|
|
10
|
+
* If omitted, we use the same value as `key`.
|
|
11
|
+
*/
|
|
12
|
+
map?: string;
|
|
13
|
+
} | {
|
|
14
|
+
in: Extract<Slot, 'body'>;
|
|
15
|
+
/**
|
|
16
|
+
* Key isn't required for bodies.
|
|
17
|
+
*/
|
|
18
|
+
key?: string;
|
|
19
|
+
map?: string;
|
|
20
|
+
};
|
|
21
|
+
export interface Fields {
|
|
22
|
+
allowExtra?: Partial<Record<Slot, boolean>>;
|
|
23
|
+
args?: ReadonlyArray<Field>;
|
|
24
|
+
}
|
|
25
|
+
export type FieldsConfig = ReadonlyArray<Field | Fields>;
|
|
26
|
+
interface Params {
|
|
27
|
+
body: unknown;
|
|
28
|
+
headers: Record<string, unknown>;
|
|
29
|
+
path: Record<string, unknown>;
|
|
30
|
+
query: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
export declare const buildClientParams: (args: ReadonlyArray<unknown>, fields: FieldsConfig) => Params;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.buildClientParams = void 0;
|
|
5
|
+
const extraPrefixesMap = {
|
|
6
|
+
$body_: 'body',
|
|
7
|
+
$headers_: 'headers',
|
|
8
|
+
$path_: 'path',
|
|
9
|
+
$query_: 'query',
|
|
10
|
+
};
|
|
11
|
+
const extraPrefixes = Object.entries(extraPrefixesMap);
|
|
12
|
+
const buildKeyMap = (fields, map) => {
|
|
13
|
+
if (!map) {
|
|
14
|
+
map = new Map();
|
|
15
|
+
}
|
|
16
|
+
for (const config of fields) {
|
|
17
|
+
if ('in' in config) {
|
|
18
|
+
if (config.key) {
|
|
19
|
+
map.set(config.key, {
|
|
20
|
+
in: config.in,
|
|
21
|
+
map: config.map,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else if (config.args) {
|
|
26
|
+
buildKeyMap(config.args, map);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return map;
|
|
30
|
+
};
|
|
31
|
+
const stripEmptySlots = (params) => {
|
|
32
|
+
for (const [slot, value] of Object.entries(params)) {
|
|
33
|
+
if (value && typeof value === 'object' && !Object.keys(value).length) {
|
|
34
|
+
delete params[slot];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const buildClientParams = (args, fields) => {
|
|
39
|
+
const params = {
|
|
40
|
+
body: {},
|
|
41
|
+
headers: {},
|
|
42
|
+
path: {},
|
|
43
|
+
query: {},
|
|
44
|
+
};
|
|
45
|
+
const map = buildKeyMap(fields);
|
|
46
|
+
let config;
|
|
47
|
+
for (const [index, arg] of args.entries()) {
|
|
48
|
+
if (fields[index]) {
|
|
49
|
+
config = fields[index];
|
|
50
|
+
}
|
|
51
|
+
if (!config) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if ('in' in config) {
|
|
55
|
+
if (config.key) {
|
|
56
|
+
const field = map.get(config.key);
|
|
57
|
+
const name = field.map || config.key;
|
|
58
|
+
params[field.in][name] = arg;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
params.body = arg;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
for (const [key, value] of Object.entries(arg ?? {})) {
|
|
66
|
+
const field = map.get(key);
|
|
67
|
+
if (field) {
|
|
68
|
+
const name = field.map || key;
|
|
69
|
+
params[field.in][name] = value;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
|
|
73
|
+
if (extra) {
|
|
74
|
+
const [prefix, slot] = extra;
|
|
75
|
+
params[slot][key.slice(prefix.length)] = value;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
for (const [slot, allowed] of Object.entries(config.allowExtra ?? {})) {
|
|
79
|
+
if (allowed) {
|
|
80
|
+
params[slot][key] = value;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
stripEmptySlots(params);
|
|
90
|
+
return params;
|
|
91
|
+
};
|
|
92
|
+
exports.buildClientParams = buildClientParams;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
type Slot = 'body' | 'headers' | 'path' | 'query';
|
|
4
|
+
|
|
5
|
+
export type Field =
|
|
6
|
+
| {
|
|
7
|
+
in: Exclude<Slot, 'body'>;
|
|
8
|
+
/**
|
|
9
|
+
* Field name. This is the name we want the user to see and use.
|
|
10
|
+
*/
|
|
11
|
+
key: string;
|
|
12
|
+
/**
|
|
13
|
+
* Field mapped name. This is the name we want to use in the request.
|
|
14
|
+
* If omitted, we use the same value as `key`.
|
|
15
|
+
*/
|
|
16
|
+
map?: string;
|
|
17
|
+
}
|
|
18
|
+
| {
|
|
19
|
+
in: Extract<Slot, 'body'>;
|
|
20
|
+
/**
|
|
21
|
+
* Key isn't required for bodies.
|
|
22
|
+
*/
|
|
23
|
+
key?: string;
|
|
24
|
+
map?: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export interface Fields {
|
|
28
|
+
allowExtra?: Partial<Record<Slot, boolean>>;
|
|
29
|
+
args?: ReadonlyArray<Field>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type FieldsConfig = ReadonlyArray<Field | Fields>;
|
|
33
|
+
|
|
34
|
+
const extraPrefixesMap: Record<string, Slot> = {
|
|
35
|
+
$body_: 'body',
|
|
36
|
+
$headers_: 'headers',
|
|
37
|
+
$path_: 'path',
|
|
38
|
+
$query_: 'query',
|
|
39
|
+
};
|
|
40
|
+
const extraPrefixes = Object.entries(extraPrefixesMap);
|
|
41
|
+
|
|
42
|
+
type KeyMap = Map<
|
|
43
|
+
string,
|
|
44
|
+
{
|
|
45
|
+
in: Slot;
|
|
46
|
+
map?: string;
|
|
47
|
+
}
|
|
48
|
+
>;
|
|
49
|
+
|
|
50
|
+
const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
|
|
51
|
+
if (!map) {
|
|
52
|
+
map = new Map();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
for (const config of fields) {
|
|
56
|
+
if ('in' in config) {
|
|
57
|
+
if (config.key) {
|
|
58
|
+
map.set(config.key, {
|
|
59
|
+
in: config.in,
|
|
60
|
+
map: config.map,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
} else if (config.args) {
|
|
64
|
+
buildKeyMap(config.args, map);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return map;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
interface Params {
|
|
72
|
+
body: unknown;
|
|
73
|
+
headers: Record<string, unknown>;
|
|
74
|
+
path: Record<string, unknown>;
|
|
75
|
+
query: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const stripEmptySlots = (params: Params) => {
|
|
79
|
+
for (const [slot, value] of Object.entries(params)) {
|
|
80
|
+
if (value && typeof value === 'object' && !Object.keys(value).length) {
|
|
81
|
+
delete params[slot as Slot];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const buildClientParams = (
|
|
87
|
+
args: ReadonlyArray<unknown>,
|
|
88
|
+
fields: FieldsConfig,
|
|
89
|
+
) => {
|
|
90
|
+
const params: Params = {
|
|
91
|
+
body: {},
|
|
92
|
+
headers: {},
|
|
93
|
+
path: {},
|
|
94
|
+
query: {},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const map = buildKeyMap(fields);
|
|
98
|
+
|
|
99
|
+
let config: FieldsConfig[number] | undefined;
|
|
100
|
+
|
|
101
|
+
for (const [index, arg] of args.entries()) {
|
|
102
|
+
if (fields[index]) {
|
|
103
|
+
config = fields[index];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!config) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if ('in' in config) {
|
|
111
|
+
if (config.key) {
|
|
112
|
+
const field = map.get(config.key)!;
|
|
113
|
+
const name = field.map || config.key;
|
|
114
|
+
(params[field.in] as Record<string, unknown>)[name] = arg;
|
|
115
|
+
} else {
|
|
116
|
+
params.body = arg;
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
for (const [key, value] of Object.entries(arg ?? {})) {
|
|
120
|
+
const field = map.get(key);
|
|
121
|
+
|
|
122
|
+
if (field) {
|
|
123
|
+
const name = field.map || key;
|
|
124
|
+
(params[field.in] as Record<string, unknown>)[name] = value;
|
|
125
|
+
} else {
|
|
126
|
+
const extra = extraPrefixes.find(([prefix]) =>
|
|
127
|
+
key.startsWith(prefix),
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
if (extra) {
|
|
131
|
+
const [prefix, slot] = extra;
|
|
132
|
+
(params[slot] as Record<string, unknown>)[
|
|
133
|
+
key.slice(prefix.length)
|
|
134
|
+
] = value;
|
|
135
|
+
} else {
|
|
136
|
+
for (const [slot, allowed] of Object.entries(
|
|
137
|
+
config.allowExtra ?? {},
|
|
138
|
+
)) {
|
|
139
|
+
if (allowed) {
|
|
140
|
+
(params[slot as Slot] as Record<string, unknown>)[key] = value;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
stripEmptySlots(params);
|
|
151
|
+
|
|
152
|
+
return params;
|
|
153
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
interface SerializeOptions<T> extends SerializePrimitiveOptions, SerializerOptions<T> {
|
|
2
|
+
}
|
|
3
|
+
interface SerializePrimitiveOptions {
|
|
4
|
+
allowReserved?: boolean;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SerializerOptions<T> {
|
|
8
|
+
/**
|
|
9
|
+
* @default true
|
|
10
|
+
*/
|
|
11
|
+
explode: boolean;
|
|
12
|
+
style: T;
|
|
13
|
+
}
|
|
14
|
+
export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
|
|
15
|
+
export type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
|
|
16
|
+
type MatrixStyle = 'label' | 'matrix' | 'simple';
|
|
17
|
+
export type ObjectStyle = 'form' | 'deepObject';
|
|
18
|
+
type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
|
|
19
|
+
interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
|
20
|
+
value: string;
|
|
21
|
+
}
|
|
22
|
+
export declare const separatorArrayExplode: (style: ArraySeparatorStyle) => "." | ";" | "," | "&";
|
|
23
|
+
export declare const separatorArrayNoExplode: (style: ArraySeparatorStyle) => "," | "|" | "%20";
|
|
24
|
+
export declare const separatorObjectExplode: (style: ObjectSeparatorStyle) => "." | ";" | "," | "&";
|
|
25
|
+
export declare const serializeArrayParam: ({ allowReserved, explode, name, style, value, }: SerializeOptions<ArraySeparatorStyle> & {
|
|
26
|
+
value: unknown[];
|
|
27
|
+
}) => string;
|
|
28
|
+
export declare const serializePrimitiveParam: ({ allowReserved, name, value, }: SerializePrimitiveParam) => string;
|
|
29
|
+
export declare const serializeObjectParam: ({ allowReserved, explode, name, style, value, valueOnly, }: SerializeOptions<ObjectSeparatorStyle> & {
|
|
30
|
+
value: Record<string, unknown> | Date;
|
|
31
|
+
valueOnly?: boolean;
|
|
32
|
+
}) => string;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.serializeObjectParam = exports.serializePrimitiveParam = exports.serializeArrayParam = exports.separatorObjectExplode = exports.separatorArrayNoExplode = exports.separatorArrayExplode = void 0;
|
|
5
|
+
const separatorArrayExplode = (style) => {
|
|
6
|
+
switch (style) {
|
|
7
|
+
case 'label':
|
|
8
|
+
return '.';
|
|
9
|
+
case 'matrix':
|
|
10
|
+
return ';';
|
|
11
|
+
case 'simple':
|
|
12
|
+
return ',';
|
|
13
|
+
default:
|
|
14
|
+
return '&';
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
exports.separatorArrayExplode = separatorArrayExplode;
|
|
18
|
+
const separatorArrayNoExplode = (style) => {
|
|
19
|
+
switch (style) {
|
|
20
|
+
case 'form':
|
|
21
|
+
return ',';
|
|
22
|
+
case 'pipeDelimited':
|
|
23
|
+
return '|';
|
|
24
|
+
case 'spaceDelimited':
|
|
25
|
+
return '%20';
|
|
26
|
+
default:
|
|
27
|
+
return ',';
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.separatorArrayNoExplode = separatorArrayNoExplode;
|
|
31
|
+
const separatorObjectExplode = (style) => {
|
|
32
|
+
switch (style) {
|
|
33
|
+
case 'label':
|
|
34
|
+
return '.';
|
|
35
|
+
case 'matrix':
|
|
36
|
+
return ';';
|
|
37
|
+
case 'simple':
|
|
38
|
+
return ',';
|
|
39
|
+
default:
|
|
40
|
+
return '&';
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.separatorObjectExplode = separatorObjectExplode;
|
|
44
|
+
const serializeArrayParam = ({ allowReserved, explode, name, style, value, }) => {
|
|
45
|
+
if (!explode) {
|
|
46
|
+
const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join((0, exports.separatorArrayNoExplode)(style));
|
|
47
|
+
switch (style) {
|
|
48
|
+
case 'label':
|
|
49
|
+
return `.${joinedValues}`;
|
|
50
|
+
case 'matrix':
|
|
51
|
+
return `;${name}=${joinedValues}`;
|
|
52
|
+
case 'simple':
|
|
53
|
+
return joinedValues;
|
|
54
|
+
default:
|
|
55
|
+
return `${name}=${joinedValues}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const separator = (0, exports.separatorArrayExplode)(style);
|
|
59
|
+
const joinedValues = value
|
|
60
|
+
.map((v) => {
|
|
61
|
+
if (style === 'label' || style === 'simple') {
|
|
62
|
+
return allowReserved ? v : encodeURIComponent(v);
|
|
63
|
+
}
|
|
64
|
+
return (0, exports.serializePrimitiveParam)({
|
|
65
|
+
allowReserved,
|
|
66
|
+
name,
|
|
67
|
+
value: v,
|
|
68
|
+
});
|
|
69
|
+
})
|
|
70
|
+
.join(separator);
|
|
71
|
+
return style === 'label' || style === 'matrix'
|
|
72
|
+
? separator + joinedValues
|
|
73
|
+
: joinedValues;
|
|
74
|
+
};
|
|
75
|
+
exports.serializeArrayParam = serializeArrayParam;
|
|
76
|
+
const serializePrimitiveParam = ({ allowReserved, name, value, }) => {
|
|
77
|
+
if (value === undefined || value === null) {
|
|
78
|
+
return '';
|
|
79
|
+
}
|
|
80
|
+
if (typeof value === 'object') {
|
|
81
|
+
throw new Error('Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.');
|
|
82
|
+
}
|
|
83
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
84
|
+
};
|
|
85
|
+
exports.serializePrimitiveParam = serializePrimitiveParam;
|
|
86
|
+
const serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly, }) => {
|
|
87
|
+
if (value instanceof Date) {
|
|
88
|
+
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
89
|
+
}
|
|
90
|
+
if (style !== 'deepObject' && !explode) {
|
|
91
|
+
let values = [];
|
|
92
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
93
|
+
values = [
|
|
94
|
+
...values,
|
|
95
|
+
key,
|
|
96
|
+
allowReserved ? v : encodeURIComponent(v),
|
|
97
|
+
];
|
|
98
|
+
});
|
|
99
|
+
const joinedValues = values.join(',');
|
|
100
|
+
switch (style) {
|
|
101
|
+
case 'form':
|
|
102
|
+
return `${name}=${joinedValues}`;
|
|
103
|
+
case 'label':
|
|
104
|
+
return `.${joinedValues}`;
|
|
105
|
+
case 'matrix':
|
|
106
|
+
return `;${name}=${joinedValues}`;
|
|
107
|
+
default:
|
|
108
|
+
return joinedValues;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const separator = (0, exports.separatorObjectExplode)(style);
|
|
112
|
+
const joinedValues = Object.entries(value)
|
|
113
|
+
.map(([key, v]) => (0, exports.serializePrimitiveParam)({
|
|
114
|
+
allowReserved,
|
|
115
|
+
name: style === 'deepObject' ? `${name}[${key}]` : key,
|
|
116
|
+
value: v,
|
|
117
|
+
}))
|
|
118
|
+
.join(separator);
|
|
119
|
+
return style === 'label' || style === 'matrix'
|
|
120
|
+
? separator + joinedValues
|
|
121
|
+
: joinedValues;
|
|
122
|
+
};
|
|
123
|
+
exports.serializeObjectParam = serializeObjectParam;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
interface SerializeOptions<T>
|
|
4
|
+
extends SerializePrimitiveOptions,
|
|
5
|
+
SerializerOptions<T> {}
|
|
6
|
+
|
|
7
|
+
interface SerializePrimitiveOptions {
|
|
8
|
+
allowReserved?: boolean;
|
|
9
|
+
name: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface SerializerOptions<T> {
|
|
13
|
+
/**
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
explode: boolean;
|
|
17
|
+
style: T;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
|
|
21
|
+
export type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
|
|
22
|
+
type MatrixStyle = 'label' | 'matrix' | 'simple';
|
|
23
|
+
export type ObjectStyle = 'form' | 'deepObject';
|
|
24
|
+
type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
|
|
25
|
+
|
|
26
|
+
interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
|
27
|
+
value: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
|
|
31
|
+
switch (style) {
|
|
32
|
+
case 'label':
|
|
33
|
+
return '.';
|
|
34
|
+
case 'matrix':
|
|
35
|
+
return ';';
|
|
36
|
+
case 'simple':
|
|
37
|
+
return ',';
|
|
38
|
+
default:
|
|
39
|
+
return '&';
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
|
|
44
|
+
switch (style) {
|
|
45
|
+
case 'form':
|
|
46
|
+
return ',';
|
|
47
|
+
case 'pipeDelimited':
|
|
48
|
+
return '|';
|
|
49
|
+
case 'spaceDelimited':
|
|
50
|
+
return '%20';
|
|
51
|
+
default:
|
|
52
|
+
return ',';
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const separatorObjectExplode = (style: ObjectSeparatorStyle) => {
|
|
57
|
+
switch (style) {
|
|
58
|
+
case 'label':
|
|
59
|
+
return '.';
|
|
60
|
+
case 'matrix':
|
|
61
|
+
return ';';
|
|
62
|
+
case 'simple':
|
|
63
|
+
return ',';
|
|
64
|
+
default:
|
|
65
|
+
return '&';
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const serializeArrayParam = ({
|
|
70
|
+
allowReserved,
|
|
71
|
+
explode,
|
|
72
|
+
name,
|
|
73
|
+
style,
|
|
74
|
+
value,
|
|
75
|
+
}: SerializeOptions<ArraySeparatorStyle> & {
|
|
76
|
+
value: unknown[];
|
|
77
|
+
}) => {
|
|
78
|
+
if (!explode) {
|
|
79
|
+
const joinedValues = (
|
|
80
|
+
allowReserved ? value : value.map((v) => encodeURIComponent(v as string))
|
|
81
|
+
).join(separatorArrayNoExplode(style));
|
|
82
|
+
switch (style) {
|
|
83
|
+
case 'label':
|
|
84
|
+
return `.${joinedValues}`;
|
|
85
|
+
case 'matrix':
|
|
86
|
+
return `;${name}=${joinedValues}`;
|
|
87
|
+
case 'simple':
|
|
88
|
+
return joinedValues;
|
|
89
|
+
default:
|
|
90
|
+
return `${name}=${joinedValues}`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const separator = separatorArrayExplode(style);
|
|
95
|
+
const joinedValues = value
|
|
96
|
+
.map((v) => {
|
|
97
|
+
if (style === 'label' || style === 'simple') {
|
|
98
|
+
return allowReserved ? v : encodeURIComponent(v as string);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return serializePrimitiveParam({
|
|
102
|
+
allowReserved,
|
|
103
|
+
name,
|
|
104
|
+
value: v as string,
|
|
105
|
+
});
|
|
106
|
+
})
|
|
107
|
+
.join(separator);
|
|
108
|
+
return style === 'label' || style === 'matrix'
|
|
109
|
+
? separator + joinedValues
|
|
110
|
+
: joinedValues;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const serializePrimitiveParam = ({
|
|
114
|
+
allowReserved,
|
|
115
|
+
name,
|
|
116
|
+
value,
|
|
117
|
+
}: SerializePrimitiveParam) => {
|
|
118
|
+
if (value === undefined || value === null) {
|
|
119
|
+
return '';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (typeof value === 'object') {
|
|
123
|
+
throw new Error(
|
|
124
|
+
'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.',
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export const serializeObjectParam = ({
|
|
132
|
+
allowReserved,
|
|
133
|
+
explode,
|
|
134
|
+
name,
|
|
135
|
+
style,
|
|
136
|
+
value,
|
|
137
|
+
valueOnly,
|
|
138
|
+
}: SerializeOptions<ObjectSeparatorStyle> & {
|
|
139
|
+
value: Record<string, unknown> | Date;
|
|
140
|
+
valueOnly?: boolean;
|
|
141
|
+
}) => {
|
|
142
|
+
if (value instanceof Date) {
|
|
143
|
+
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (style !== 'deepObject' && !explode) {
|
|
147
|
+
let values: string[] = [];
|
|
148
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
149
|
+
values = [
|
|
150
|
+
...values,
|
|
151
|
+
key,
|
|
152
|
+
allowReserved ? (v as string) : encodeURIComponent(v as string),
|
|
153
|
+
];
|
|
154
|
+
});
|
|
155
|
+
const joinedValues = values.join(',');
|
|
156
|
+
switch (style) {
|
|
157
|
+
case 'form':
|
|
158
|
+
return `${name}=${joinedValues}`;
|
|
159
|
+
case 'label':
|
|
160
|
+
return `.${joinedValues}`;
|
|
161
|
+
case 'matrix':
|
|
162
|
+
return `;${name}=${joinedValues}`;
|
|
163
|
+
default:
|
|
164
|
+
return joinedValues;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const separator = separatorObjectExplode(style);
|
|
169
|
+
const joinedValues = Object.entries(value)
|
|
170
|
+
.map(([key, v]) =>
|
|
171
|
+
serializePrimitiveParam({
|
|
172
|
+
allowReserved,
|
|
173
|
+
name: style === 'deepObject' ? `${name}[${key}]` : key,
|
|
174
|
+
value: v as string,
|
|
175
|
+
}),
|
|
176
|
+
)
|
|
177
|
+
.join(separator);
|
|
178
|
+
return style === 'label' || style === 'matrix'
|
|
179
|
+
? separator + joinedValues
|
|
180
|
+
: joinedValues;
|
|
181
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Auth, AuthToken } from './auth.gen';
|
|
2
|
+
import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from './bodySerializer.gen';
|
|
3
|
+
export interface Client<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never> {
|
|
4
|
+
/**
|
|
5
|
+
* Returns the final request URL.
|
|
6
|
+
*/
|
|
7
|
+
buildUrl: BuildUrlFn;
|
|
8
|
+
connect: MethodFn;
|
|
9
|
+
delete: MethodFn;
|
|
10
|
+
get: MethodFn;
|
|
11
|
+
getConfig: () => Config;
|
|
12
|
+
head: MethodFn;
|
|
13
|
+
options: MethodFn;
|
|
14
|
+
patch: MethodFn;
|
|
15
|
+
post: MethodFn;
|
|
16
|
+
put: MethodFn;
|
|
17
|
+
request: RequestFn;
|
|
18
|
+
setConfig: (config: Config) => Config;
|
|
19
|
+
trace: MethodFn;
|
|
20
|
+
}
|
|
21
|
+
export interface Config {
|
|
22
|
+
/**
|
|
23
|
+
* Auth token or a function returning auth token. The resolved value will be
|
|
24
|
+
* added to the request payload as defined by its `security` array.
|
|
25
|
+
*/
|
|
26
|
+
auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
|
|
27
|
+
/**
|
|
28
|
+
* A function for serializing request body parameter. By default,
|
|
29
|
+
* {@link JSON.stringify()} will be used.
|
|
30
|
+
*/
|
|
31
|
+
bodySerializer?: BodySerializer | null;
|
|
32
|
+
/**
|
|
33
|
+
* An object containing any HTTP headers that you want to pre-populate your
|
|
34
|
+
* `Headers` object with.
|
|
35
|
+
*
|
|
36
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
|
37
|
+
*/
|
|
38
|
+
headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* The request method.
|
|
41
|
+
*
|
|
42
|
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
|
|
43
|
+
*/
|
|
44
|
+
method?: 'CONNECT' | 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT' | 'TRACE';
|
|
45
|
+
/**
|
|
46
|
+
* A function for serializing request query parameters. By default, arrays
|
|
47
|
+
* will be exploded in form style, objects will be exploded in deepObject
|
|
48
|
+
* style, and reserved characters are percent-encoded.
|
|
49
|
+
*
|
|
50
|
+
* This method will have no effect if the native `paramsSerializer()` Axios
|
|
51
|
+
* API function is used.
|
|
52
|
+
*
|
|
53
|
+
* {@link https://swagger.io/docs/specification/serialization/#query View examples}
|
|
54
|
+
*/
|
|
55
|
+
querySerializer?: QuerySerializer | QuerySerializerOptions;
|
|
56
|
+
/**
|
|
57
|
+
* A function validating request data. This is useful if you want to ensure
|
|
58
|
+
* the request conforms to the desired shape, so it can be safely sent to
|
|
59
|
+
* the server.
|
|
60
|
+
*/
|
|
61
|
+
requestValidator?: (data: unknown) => Promise<unknown>;
|
|
62
|
+
/**
|
|
63
|
+
* A function transforming response data before it's returned. This is useful
|
|
64
|
+
* for post-processing data, e.g. converting ISO strings into Date objects.
|
|
65
|
+
*/
|
|
66
|
+
responseTransformer?: (data: unknown) => Promise<unknown>;
|
|
67
|
+
/**
|
|
68
|
+
* A function validating response data. This is useful if you want to ensure
|
|
69
|
+
* the response conforms to the desired shape, so it can be safely passed to
|
|
70
|
+
* the transformers and returned to the user.
|
|
71
|
+
*/
|
|
72
|
+
responseValidator?: (data: unknown) => Promise<unknown>;
|
|
73
|
+
}
|
|
74
|
+
type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never] ? true : [T] extends [never | undefined] ? [undefined] extends [T] ? false : true : false;
|
|
75
|
+
export type OmitNever<T extends Record<string, unknown>> = {
|
|
76
|
+
[K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K];
|
|
77
|
+
};
|
|
78
|
+
export {};
|