@remkoj/optimizely-cms-api 6.0.0-pre8 → 6.0.0-rc.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/LICENSE +12 -12
- package/README.md +7 -5
- package/dist/api-client.d.ts +9 -6
- package/dist/api-client.js +45 -40
- package/dist/client/client/{client.d.ts → client.gen.d.ts} +1 -1
- package/dist/client/client/client.gen.js +239 -0
- package/dist/client/client/index.d.ts +8 -7
- package/dist/client/client/index.js +15 -12
- package/dist/client/client/{types.d.ts → types.gen.d.ts} +17 -19
- package/dist/client/{core/types.js → client/types.gen.js} +1 -0
- package/dist/client/client/{utils.d.ts → utils.gen.d.ts} +9 -21
- package/dist/client/client/{utils.js → utils.gen.js} +67 -124
- package/dist/client/client.gen.d.ts +3 -3
- package/dist/client/client.gen.js +2 -4
- package/dist/client/core/{auth.js → auth.gen.js} +1 -0
- package/dist/client/core/bodySerializer.gen.d.ts +25 -0
- package/dist/client/core/{bodySerializer.js → bodySerializer.gen.js} +5 -1
- package/dist/client/core/{params.d.ts → params.gen.d.ts} +20 -0
- package/dist/client/core/{params.js → params.gen.js} +19 -6
- package/dist/client/core/{pathSerializer.js → pathSerializer.gen.js} +4 -11
- package/dist/client/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/client/core/queryKeySerializer.gen.js +98 -0
- package/dist/client/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/client/core/serverSentEvents.gen.js +137 -0
- package/dist/client/core/{types.d.ts → types.gen.d.ts} +19 -14
- package/dist/client/{client/types.js → core/types.gen.js} +1 -0
- package/dist/client/core/utils.gen.d.ts +19 -0
- package/dist/client/core/utils.gen.js +93 -0
- package/dist/client/index.d.ts +4 -4
- package/dist/client/index.js +99 -19
- package/dist/client/sdk.gen.d.ts +124 -70
- package/dist/client/sdk.gen.js +448 -490
- package/dist/client/transformers.gen.d.ts +14 -4
- package/dist/client/transformers.gen.js +143 -59
- package/dist/client/types.gen.d.ts +1231 -856
- package/dist/client/types.gen.js +0 -84
- package/dist/client-config.d.ts +5 -2
- package/dist/client-config.js +42 -14
- package/dist/config.d.ts +2 -3
- package/dist/config.js +13 -42
- package/dist/getaccesstoken.d.ts +1 -1
- package/dist/getaccesstoken.js +9 -7
- package/dist/index.d.ts +3 -1
- package/dist/index.js +7 -1
- package/dist/types.d.ts +3 -1
- package/dist/types.js +1 -0
- package/dist/version.json +3 -3
- package/package.json +11 -15
- package/dist/client/client/client.js +0 -149
- package/dist/client/core/bodySerializer.d.ts +0 -17
- /package/dist/client/core/{auth.d.ts → auth.gen.d.ts} +0 -0
- /package/dist/client/core/{pathSerializer.d.ts → pathSerializer.gen.d.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Client, ClientOptions, Config, RequestOptions } from './types';
|
|
3
|
-
export declare const createQuerySerializer: <T = unknown>({
|
|
1
|
+
import type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
|
2
|
+
import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';
|
|
3
|
+
export declare const createQuerySerializer: <T = unknown>({ parameters, ...args }?: QuerySerializerOptions) => (queryParams: T) => string;
|
|
4
4
|
/**
|
|
5
5
|
* Infers parseAs value from provided Content-Type header.
|
|
6
6
|
*/
|
|
@@ -9,37 +9,25 @@ export declare const setAuthParams: ({ security, ...options }: Pick<Required<Req
|
|
|
9
9
|
headers: Headers;
|
|
10
10
|
}) => Promise<void>;
|
|
11
11
|
export declare const buildUrl: Client['buildUrl'];
|
|
12
|
-
export declare const getUrl: ({ baseUrl, path, query, querySerializer, url: _url, }: {
|
|
13
|
-
baseUrl?: string;
|
|
14
|
-
path?: Record<string, unknown>;
|
|
15
|
-
query?: Record<string, unknown>;
|
|
16
|
-
querySerializer: QuerySerializer;
|
|
17
|
-
url: string;
|
|
18
|
-
}) => string;
|
|
19
12
|
export declare const mergeConfigs: (a: Config, b: Config) => Config;
|
|
20
13
|
export declare const mergeHeaders: (...headers: Array<Required<Config>["headers"] | undefined>) => Headers;
|
|
21
14
|
type ErrInterceptor<Err, Res, Req, Options> = (error: Err, response: Res, request: Req, options: Options) => Err | Promise<Err>;
|
|
22
15
|
type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
|
|
23
16
|
type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
|
|
24
17
|
declare class Interceptors<Interceptor> {
|
|
25
|
-
|
|
26
|
-
constructor();
|
|
18
|
+
fns: Array<Interceptor | null>;
|
|
27
19
|
clear(): void;
|
|
28
|
-
getInterceptorIndex(id: number | Interceptor): number;
|
|
29
|
-
exists(id: number | Interceptor): boolean;
|
|
30
20
|
eject(id: number | Interceptor): void;
|
|
31
|
-
|
|
21
|
+
exists(id: number | Interceptor): boolean;
|
|
22
|
+
getInterceptorIndex(id: number | Interceptor): number;
|
|
23
|
+
update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
|
|
32
24
|
use(fn: Interceptor): number;
|
|
33
25
|
}
|
|
34
26
|
export interface Middleware<Req, Res, Err, Options> {
|
|
35
|
-
error: Pick<Interceptors<ErrInterceptor<Err, Res, Req, Options>>, 'eject' | 'use'>;
|
|
36
|
-
request: Pick<Interceptors<ReqInterceptor<Req, Options>>, 'eject' | 'use'>;
|
|
37
|
-
response: Pick<Interceptors<ResInterceptor<Res, Req, Options>>, 'eject' | 'use'>;
|
|
38
|
-
}
|
|
39
|
-
export declare const createInterceptors: <Req, Res, Err, Options>() => {
|
|
40
27
|
error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
|
|
41
28
|
request: Interceptors<ReqInterceptor<Req, Options>>;
|
|
42
29
|
response: Interceptors<ResInterceptor<Res, Req, Options>>;
|
|
43
|
-
}
|
|
30
|
+
}
|
|
31
|
+
export declare const createInterceptors: <Req, Res, Err, Options>() => Middleware<Req, Res, Err, Options>;
|
|
44
32
|
export declare const createConfig: <T extends ClientOptions = ClientOptions>(override?: Config<Omit<ClientOptions, keyof T> & T>) => Config<Omit<ClientOptions, keyof T> & T>;
|
|
45
33
|
export {};
|
|
@@ -1,62 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createConfig = exports.createInterceptors = exports.mergeHeaders = exports.mergeConfigs = exports.
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
let url = _url;
|
|
10
|
-
const matches = _url.match(PATH_PARAM_RE);
|
|
11
|
-
if (matches) {
|
|
12
|
-
for (const match of matches) {
|
|
13
|
-
let explode = false;
|
|
14
|
-
let name = match.substring(1, match.length - 1);
|
|
15
|
-
let style = 'simple';
|
|
16
|
-
if (name.endsWith('*')) {
|
|
17
|
-
explode = true;
|
|
18
|
-
name = name.substring(0, name.length - 1);
|
|
19
|
-
}
|
|
20
|
-
if (name.startsWith('.')) {
|
|
21
|
-
name = name.substring(1);
|
|
22
|
-
style = 'label';
|
|
23
|
-
}
|
|
24
|
-
else if (name.startsWith(';')) {
|
|
25
|
-
name = name.substring(1);
|
|
26
|
-
style = 'matrix';
|
|
27
|
-
}
|
|
28
|
-
const value = path[name];
|
|
29
|
-
if (value === undefined || value === null) {
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (Array.isArray(value)) {
|
|
33
|
-
url = url.replace(match, (0, pathSerializer_1.serializeArrayParam)({ explode, name, style, value }));
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
if (typeof value === 'object') {
|
|
37
|
-
url = url.replace(match, (0, pathSerializer_1.serializeObjectParam)({
|
|
38
|
-
explode,
|
|
39
|
-
name,
|
|
40
|
-
style,
|
|
41
|
-
value: value,
|
|
42
|
-
valueOnly: true,
|
|
43
|
-
}));
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
if (style === 'matrix') {
|
|
47
|
-
url = url.replace(match, `;${(0, pathSerializer_1.serializePrimitiveParam)({
|
|
48
|
-
name,
|
|
49
|
-
value: value,
|
|
50
|
-
})}`);
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
const replaceValue = encodeURIComponent(style === 'label' ? `.${value}` : value);
|
|
54
|
-
url = url.replace(match, replaceValue);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return url;
|
|
58
|
-
};
|
|
59
|
-
const createQuerySerializer = ({ allowReserved, array, object, } = {}) => {
|
|
4
|
+
exports.createConfig = exports.createInterceptors = exports.mergeHeaders = exports.mergeConfigs = exports.buildUrl = exports.setAuthParams = exports.getParseAs = exports.createQuerySerializer = void 0;
|
|
5
|
+
const auth_gen_1 = require("../core/auth.gen");
|
|
6
|
+
const bodySerializer_gen_1 = require("../core/bodySerializer.gen");
|
|
7
|
+
const pathSerializer_gen_1 = require("../core/pathSerializer.gen");
|
|
8
|
+
const utils_gen_1 = require("../core/utils.gen");
|
|
9
|
+
const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
60
10
|
const querySerializer = (queryParams) => {
|
|
61
11
|
const search = [];
|
|
62
12
|
if (queryParams && typeof queryParams === 'object') {
|
|
@@ -65,33 +15,34 @@ const createQuerySerializer = ({ allowReserved, array, object, } = {}) => {
|
|
|
65
15
|
if (value === undefined || value === null) {
|
|
66
16
|
continue;
|
|
67
17
|
}
|
|
18
|
+
const options = parameters[name] || args;
|
|
68
19
|
if (Array.isArray(value)) {
|
|
69
|
-
const serializedArray = (0,
|
|
70
|
-
allowReserved,
|
|
20
|
+
const serializedArray = (0, pathSerializer_gen_1.serializeArrayParam)({
|
|
21
|
+
allowReserved: options.allowReserved,
|
|
71
22
|
explode: true,
|
|
72
23
|
name,
|
|
73
24
|
style: 'form',
|
|
74
25
|
value,
|
|
75
|
-
...array,
|
|
26
|
+
...options.array,
|
|
76
27
|
});
|
|
77
28
|
if (serializedArray)
|
|
78
29
|
search.push(serializedArray);
|
|
79
30
|
}
|
|
80
31
|
else if (typeof value === 'object') {
|
|
81
|
-
const serializedObject = (0,
|
|
82
|
-
allowReserved,
|
|
32
|
+
const serializedObject = (0, pathSerializer_gen_1.serializeObjectParam)({
|
|
33
|
+
allowReserved: options.allowReserved,
|
|
83
34
|
explode: true,
|
|
84
35
|
name,
|
|
85
36
|
style: 'deepObject',
|
|
86
37
|
value: value,
|
|
87
|
-
...object,
|
|
38
|
+
...options.object,
|
|
88
39
|
});
|
|
89
40
|
if (serializedObject)
|
|
90
41
|
search.push(serializedObject);
|
|
91
42
|
}
|
|
92
43
|
else {
|
|
93
|
-
const serializedPrimitive = (0,
|
|
94
|
-
allowReserved,
|
|
44
|
+
const serializedPrimitive = (0, pathSerializer_gen_1.serializePrimitiveParam)({
|
|
45
|
+
allowReserved: options.allowReserved,
|
|
95
46
|
name,
|
|
96
47
|
value: value,
|
|
97
48
|
});
|
|
@@ -118,8 +69,7 @@ const getParseAs = (contentType) => {
|
|
|
118
69
|
if (!cleanContent) {
|
|
119
70
|
return;
|
|
120
71
|
}
|
|
121
|
-
if (cleanContent.startsWith('application/json') ||
|
|
122
|
-
cleanContent.endsWith('+json')) {
|
|
72
|
+
if (cleanContent.startsWith('application/json') || cleanContent.endsWith('+json')) {
|
|
123
73
|
return 'json';
|
|
124
74
|
}
|
|
125
75
|
if (cleanContent === 'multipart/form-data') {
|
|
@@ -134,9 +84,23 @@ const getParseAs = (contentType) => {
|
|
|
134
84
|
return;
|
|
135
85
|
};
|
|
136
86
|
exports.getParseAs = getParseAs;
|
|
87
|
+
const checkForExistence = (options, name) => {
|
|
88
|
+
if (!name) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
if (options.headers.has(name) ||
|
|
92
|
+
options.query?.[name] ||
|
|
93
|
+
options.headers.get('Cookie')?.includes(`${name}=`)) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
};
|
|
137
98
|
const setAuthParams = async ({ security, ...options }) => {
|
|
138
99
|
for (const auth of security) {
|
|
139
|
-
|
|
100
|
+
if (checkForExistence(options, auth.name)) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const token = await (0, auth_gen_1.getAuthToken)(auth, options.auth);
|
|
140
104
|
if (!token) {
|
|
141
105
|
continue;
|
|
142
106
|
}
|
|
@@ -156,39 +120,19 @@ const setAuthParams = async ({ security, ...options }) => {
|
|
|
156
120
|
options.headers.set(name, token);
|
|
157
121
|
break;
|
|
158
122
|
}
|
|
159
|
-
return;
|
|
160
123
|
}
|
|
161
124
|
};
|
|
162
125
|
exports.setAuthParams = setAuthParams;
|
|
163
|
-
const buildUrl = (options) => {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
});
|
|
173
|
-
return url;
|
|
174
|
-
};
|
|
126
|
+
const buildUrl = (options) => (0, utils_gen_1.getUrl)({
|
|
127
|
+
baseUrl: options.baseUrl,
|
|
128
|
+
path: options.path,
|
|
129
|
+
query: options.query,
|
|
130
|
+
querySerializer: typeof options.querySerializer === 'function'
|
|
131
|
+
? options.querySerializer
|
|
132
|
+
: (0, exports.createQuerySerializer)(options.querySerializer),
|
|
133
|
+
url: options.url,
|
|
134
|
+
});
|
|
175
135
|
exports.buildUrl = buildUrl;
|
|
176
|
-
const getUrl = ({ baseUrl, path, query, querySerializer, url: _url, }) => {
|
|
177
|
-
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
|
|
178
|
-
let url = (baseUrl ?? '') + pathUrl;
|
|
179
|
-
if (path) {
|
|
180
|
-
url = defaultPathSerializer({ path, url });
|
|
181
|
-
}
|
|
182
|
-
let search = query ? querySerializer(query) : '';
|
|
183
|
-
if (search.startsWith('?')) {
|
|
184
|
-
search = search.substring(1);
|
|
185
|
-
}
|
|
186
|
-
if (search) {
|
|
187
|
-
url += `?${search}`;
|
|
188
|
-
}
|
|
189
|
-
return url;
|
|
190
|
-
};
|
|
191
|
-
exports.getUrl = getUrl;
|
|
192
136
|
const mergeConfigs = (a, b) => {
|
|
193
137
|
const config = { ...a, ...b };
|
|
194
138
|
if (config.baseUrl?.endsWith('/')) {
|
|
@@ -198,13 +142,20 @@ const mergeConfigs = (a, b) => {
|
|
|
198
142
|
return config;
|
|
199
143
|
};
|
|
200
144
|
exports.mergeConfigs = mergeConfigs;
|
|
145
|
+
const headersEntries = (headers) => {
|
|
146
|
+
const entries = [];
|
|
147
|
+
headers.forEach((value, key) => {
|
|
148
|
+
entries.push([key, value]);
|
|
149
|
+
});
|
|
150
|
+
return entries;
|
|
151
|
+
};
|
|
201
152
|
const mergeHeaders = (...headers) => {
|
|
202
153
|
const mergedHeaders = new Headers();
|
|
203
154
|
for (const header of headers) {
|
|
204
|
-
if (!header
|
|
155
|
+
if (!header) {
|
|
205
156
|
continue;
|
|
206
157
|
}
|
|
207
|
-
const iterator = header instanceof Headers ? header
|
|
158
|
+
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
208
159
|
for (const [key, value] of iterator) {
|
|
209
160
|
if (value === null) {
|
|
210
161
|
mergedHeaders.delete(key);
|
|
@@ -225,47 +176,39 @@ const mergeHeaders = (...headers) => {
|
|
|
225
176
|
};
|
|
226
177
|
exports.mergeHeaders = mergeHeaders;
|
|
227
178
|
class Interceptors {
|
|
228
|
-
|
|
229
|
-
constructor() {
|
|
230
|
-
this._fns = [];
|
|
231
|
-
}
|
|
179
|
+
fns = [];
|
|
232
180
|
clear() {
|
|
233
|
-
this.
|
|
181
|
+
this.fns = [];
|
|
234
182
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
else {
|
|
240
|
-
return this._fns.indexOf(id);
|
|
183
|
+
eject(id) {
|
|
184
|
+
const index = this.getInterceptorIndex(id);
|
|
185
|
+
if (this.fns[index]) {
|
|
186
|
+
this.fns[index] = null;
|
|
241
187
|
}
|
|
242
188
|
}
|
|
243
189
|
exists(id) {
|
|
244
190
|
const index = this.getInterceptorIndex(id);
|
|
245
|
-
return
|
|
191
|
+
return Boolean(this.fns[index]);
|
|
246
192
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
this._fns[index] = null;
|
|
193
|
+
getInterceptorIndex(id) {
|
|
194
|
+
if (typeof id === 'number') {
|
|
195
|
+
return this.fns[id] ? id : -1;
|
|
251
196
|
}
|
|
197
|
+
return this.fns.indexOf(id);
|
|
252
198
|
}
|
|
253
199
|
update(id, fn) {
|
|
254
200
|
const index = this.getInterceptorIndex(id);
|
|
255
|
-
if (this.
|
|
256
|
-
this.
|
|
201
|
+
if (this.fns[index]) {
|
|
202
|
+
this.fns[index] = fn;
|
|
257
203
|
return id;
|
|
258
204
|
}
|
|
259
|
-
|
|
260
|
-
return false;
|
|
261
|
-
}
|
|
205
|
+
return false;
|
|
262
206
|
}
|
|
263
207
|
use(fn) {
|
|
264
|
-
this.
|
|
265
|
-
return this.
|
|
208
|
+
this.fns.push(fn);
|
|
209
|
+
return this.fns.length - 1;
|
|
266
210
|
}
|
|
267
211
|
}
|
|
268
|
-
// do not add `Middleware` as return type so we can use _fns internally
|
|
269
212
|
const createInterceptors = () => ({
|
|
270
213
|
error: new Interceptors(),
|
|
271
214
|
request: new Interceptors(),
|
|
@@ -287,7 +230,7 @@ const defaultHeaders = {
|
|
|
287
230
|
'Content-Type': 'application/json',
|
|
288
231
|
};
|
|
289
232
|
const createConfig = (override = {}) => ({
|
|
290
|
-
...
|
|
233
|
+
...bodySerializer_gen_1.jsonBodySerializer,
|
|
291
234
|
headers: defaultHeaders,
|
|
292
235
|
parseAs: 'auto',
|
|
293
236
|
querySerializer: defaultQuerySerializer,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import
|
|
1
|
+
import { type ClientOptions, type Config } from './client';
|
|
2
|
+
import type { ClientOptions as ClientOptions2 } from './types.gen';
|
|
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.
|
|
@@ -8,5 +8,5 @@ import { type Config, type ClientOptions as DefaultClientOptions } from './clien
|
|
|
8
8
|
* `setConfig()`. This is useful for example if you're using Next.js
|
|
9
9
|
* to ensure your client always has the correct values.
|
|
10
10
|
*/
|
|
11
|
-
export type CreateClientConfig<T extends
|
|
11
|
+
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
|
12
12
|
export declare const client: import("./client").Client;
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.client = void 0;
|
|
5
|
-
const client_1 = require("./client");
|
|
6
5
|
const client_config_1 = require("../client-config");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
})));
|
|
6
|
+
const client_1 = require("./client");
|
|
7
|
+
exports.client = (0, client_1.createClient)((0, client_config_1.createClientConfig)((0, client_1.createConfig)({ baseUrl: 'https://api.cms.optimizely.com/preview3' })));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ArrayStyle, ObjectStyle, SerializerOptions } from './pathSerializer.gen';
|
|
2
|
+
export type QuerySerializer = (query: Record<string, unknown>) => string;
|
|
3
|
+
export type BodySerializer = (body: unknown) => unknown;
|
|
4
|
+
type QuerySerializerOptionsObject = {
|
|
5
|
+
allowReserved?: boolean;
|
|
6
|
+
array?: Partial<SerializerOptions<ArrayStyle>>;
|
|
7
|
+
object?: Partial<SerializerOptions<ObjectStyle>>;
|
|
8
|
+
};
|
|
9
|
+
export type QuerySerializerOptions = QuerySerializerOptionsObject & {
|
|
10
|
+
/**
|
|
11
|
+
* Per-parameter serialization overrides. When provided, these settings
|
|
12
|
+
* override the global array/object settings for specific parameter names.
|
|
13
|
+
*/
|
|
14
|
+
parameters?: Record<string, QuerySerializerOptionsObject>;
|
|
15
|
+
};
|
|
16
|
+
export declare const formDataBodySerializer: {
|
|
17
|
+
bodySerializer: (body: unknown) => FormData;
|
|
18
|
+
};
|
|
19
|
+
export declare const jsonBodySerializer: {
|
|
20
|
+
bodySerializer: (body: unknown) => string;
|
|
21
|
+
};
|
|
22
|
+
export declare const urlSearchParamsBodySerializer: {
|
|
23
|
+
bodySerializer: (body: unknown) => string;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.urlSearchParamsBodySerializer = exports.jsonBodySerializer = exports.formDataBodySerializer = void 0;
|
|
4
5
|
const serializeFormDataPair = (data, key, value) => {
|
|
5
6
|
if (typeof value === 'string' || value instanceof Blob) {
|
|
6
7
|
data.append(key, value);
|
|
7
8
|
}
|
|
9
|
+
else if (value instanceof Date) {
|
|
10
|
+
data.append(key, value.toISOString());
|
|
11
|
+
}
|
|
8
12
|
else {
|
|
9
13
|
data.append(key, JSON.stringify(value));
|
|
10
14
|
}
|
|
@@ -35,7 +39,7 @@ exports.formDataBodySerializer = {
|
|
|
35
39
|
},
|
|
36
40
|
};
|
|
37
41
|
exports.jsonBodySerializer = {
|
|
38
|
-
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === 'bigint' ? value.toString() : value),
|
|
42
|
+
bodySerializer: (body) => JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value)),
|
|
39
43
|
};
|
|
40
44
|
exports.urlSearchParamsBodySerializer = {
|
|
41
45
|
bodySerializer: (body) => {
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
type Slot = 'body' | 'headers' | 'path' | 'query';
|
|
2
2
|
export type Field = {
|
|
3
3
|
in: Exclude<Slot, 'body'>;
|
|
4
|
+
/**
|
|
5
|
+
* Field name. This is the name we want the user to see and use.
|
|
6
|
+
*/
|
|
4
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
|
+
*/
|
|
5
12
|
map?: string;
|
|
6
13
|
} | {
|
|
7
14
|
in: Extract<Slot, 'body'>;
|
|
15
|
+
/**
|
|
16
|
+
* Key isn't required for bodies.
|
|
17
|
+
*/
|
|
8
18
|
key?: string;
|
|
9
19
|
map?: string;
|
|
20
|
+
} | {
|
|
21
|
+
/**
|
|
22
|
+
* Field name. This is the name we want the user to see and use.
|
|
23
|
+
*/
|
|
24
|
+
key: string;
|
|
25
|
+
/**
|
|
26
|
+
* Field mapped name. This is the name we want to use in the request.
|
|
27
|
+
* If `in` is omitted, `map` aliases `key` to the transport layer.
|
|
28
|
+
*/
|
|
29
|
+
map: Slot;
|
|
10
30
|
};
|
|
11
31
|
export interface Fields {
|
|
12
32
|
allowExtra?: Partial<Record<Slot, boolean>>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.buildClientParams = void 0;
|
|
4
5
|
const extraPrefixesMap = {
|
|
@@ -21,6 +22,11 @@ const buildKeyMap = (fields, map) => {
|
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
}
|
|
25
|
+
else if ('key' in config) {
|
|
26
|
+
map.set(config.key, {
|
|
27
|
+
map: config.map,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
24
30
|
else if (config.args) {
|
|
25
31
|
buildKeyMap(config.args, map);
|
|
26
32
|
}
|
|
@@ -29,7 +35,7 @@ const buildKeyMap = (fields, map) => {
|
|
|
29
35
|
};
|
|
30
36
|
const stripEmptySlots = (params) => {
|
|
31
37
|
for (const [slot, value] of Object.entries(params)) {
|
|
32
|
-
if (value && typeof value === 'object' && !Object.keys(value).length) {
|
|
38
|
+
if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {
|
|
33
39
|
delete params[slot];
|
|
34
40
|
}
|
|
35
41
|
}
|
|
@@ -54,7 +60,9 @@ const buildClientParams = (args, fields) => {
|
|
|
54
60
|
if (config.key) {
|
|
55
61
|
const field = map.get(config.key);
|
|
56
62
|
const name = field.map || config.key;
|
|
57
|
-
|
|
63
|
+
if (field.in) {
|
|
64
|
+
params[field.in][name] = arg;
|
|
65
|
+
}
|
|
58
66
|
}
|
|
59
67
|
else {
|
|
60
68
|
params.body = arg;
|
|
@@ -64,8 +72,13 @@ const buildClientParams = (args, fields) => {
|
|
|
64
72
|
for (const [key, value] of Object.entries(arg ?? {})) {
|
|
65
73
|
const field = map.get(key);
|
|
66
74
|
if (field) {
|
|
67
|
-
|
|
68
|
-
|
|
75
|
+
if (field.in) {
|
|
76
|
+
const name = field.map || key;
|
|
77
|
+
params[field.in][name] = value;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
params[field.map] = value;
|
|
81
|
+
}
|
|
69
82
|
}
|
|
70
83
|
else {
|
|
71
84
|
const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
|
|
@@ -73,8 +86,8 @@ const buildClientParams = (args, fields) => {
|
|
|
73
86
|
const [prefix, slot] = extra;
|
|
74
87
|
params[slot][key.slice(prefix.length)] = value;
|
|
75
88
|
}
|
|
76
|
-
else {
|
|
77
|
-
for (const [slot, allowed] of Object.entries(config.allowExtra
|
|
89
|
+
else if ('allowExtra' in config && config.allowExtra) {
|
|
90
|
+
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
|
|
78
91
|
if (allowed) {
|
|
79
92
|
params[slot][key] = value;
|
|
80
93
|
break;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.serializeObjectParam = exports.serializePrimitiveParam = exports.serializeArrayParam = exports.separatorObjectExplode = exports.separatorArrayNoExplode = exports.separatorArrayExplode = void 0;
|
|
4
5
|
const separatorArrayExplode = (style) => {
|
|
@@ -67,9 +68,7 @@ const serializeArrayParam = ({ allowReserved, explode, name, style, value, }) =>
|
|
|
67
68
|
});
|
|
68
69
|
})
|
|
69
70
|
.join(separator);
|
|
70
|
-
return style === 'label' || style === 'matrix'
|
|
71
|
-
? separator + joinedValues
|
|
72
|
-
: joinedValues;
|
|
71
|
+
return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues;
|
|
73
72
|
};
|
|
74
73
|
exports.serializeArrayParam = serializeArrayParam;
|
|
75
74
|
const serializePrimitiveParam = ({ allowReserved, name, value, }) => {
|
|
@@ -89,11 +88,7 @@ const serializeObjectParam = ({ allowReserved, explode, name, style, value, valu
|
|
|
89
88
|
if (style !== 'deepObject' && !explode) {
|
|
90
89
|
let values = [];
|
|
91
90
|
Object.entries(value).forEach(([key, v]) => {
|
|
92
|
-
values = [
|
|
93
|
-
...values,
|
|
94
|
-
key,
|
|
95
|
-
allowReserved ? v : encodeURIComponent(v),
|
|
96
|
-
];
|
|
91
|
+
values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
|
|
97
92
|
});
|
|
98
93
|
const joinedValues = values.join(',');
|
|
99
94
|
switch (style) {
|
|
@@ -115,8 +110,6 @@ const serializeObjectParam = ({ allowReserved, explode, name, style, value, valu
|
|
|
115
110
|
value: v,
|
|
116
111
|
}))
|
|
117
112
|
.join(separator);
|
|
118
|
-
return style === 'label' || style === 'matrix'
|
|
119
|
-
? separator + joinedValues
|
|
120
|
-
: joinedValues;
|
|
113
|
+
return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues;
|
|
121
114
|
};
|
|
122
115
|
exports.serializeObjectParam = serializeObjectParam;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-friendly union that mirrors what Pinia Colada can hash.
|
|
3
|
+
*/
|
|
4
|
+
export type JsonValue = null | string | number | boolean | JsonValue[] | {
|
|
5
|
+
[key: string]: JsonValue;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
|
|
9
|
+
*/
|
|
10
|
+
export declare const queryKeyJsonReplacer: (_key: string, value: unknown) => {} | null | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Safely stringifies a value and parses it back into a JsonValue.
|
|
13
|
+
*/
|
|
14
|
+
export declare const stringifyToJsonValue: (input: unknown) => JsonValue | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Normalizes any accepted value into a JSON-friendly shape for query keys.
|
|
17
|
+
*/
|
|
18
|
+
export declare const serializeQueryKeyValue: (value: unknown) => JsonValue | undefined;
|