waldur-js-client 8.0.9-dev.30 → 8.0.9-dev.32
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/client/{client.d.ts → client.gen.d.ts} +1 -1
- package/dist/client/client.gen.js +216 -0
- package/dist/client/index.d.ts +8 -7
- package/dist/client/index.js +6 -4
- package/dist/client/{types.d.ts → types.gen.d.ts} +22 -21
- package/dist/client/types.gen.js +2 -0
- package/dist/client/{utils.d.ts → utils.gen.d.ts} +16 -24
- package/dist/client/{utils.js → utils.gen.js} +65 -121
- package/dist/client.gen.d.ts +3 -3
- package/dist/core/{auth.js → auth.gen.js} +1 -0
- package/dist/core/bodySerializer.gen.d.ts +25 -0
- package/dist/core/{bodySerializer.js → bodySerializer.gen.js} +5 -1
- package/dist/core/{params.d.ts → params.gen.d.ts} +20 -0
- package/dist/core/{params.js → params.gen.js} +23 -10
- package/dist/core/{pathSerializer.js → pathSerializer.gen.js} +4 -11
- package/dist/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/core/queryKeySerializer.gen.js +92 -0
- package/dist/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/core/serverSentEvents.gen.js +132 -0
- package/dist/core/{types.d.ts → types.gen.d.ts} +20 -15
- package/dist/core/types.gen.js +2 -0
- package/dist/core/utils.gen.d.ts +19 -0
- package/dist/core/utils.gen.js +87 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -2
- package/dist/sdk.gen.d.ts +1061 -4
- package/dist/sdk.gen.js +28375 -55513
- package/dist/types.gen.d.ts +604 -422
- package/package.json +1 -1
- package/dist/client/client.js +0 -143
- package/dist/client/types.js +0 -1
- package/dist/core/bodySerializer.d.ts +0 -17
- package/dist/core/types.js +0 -1
- /package/dist/core/{auth.d.ts → auth.gen.d.ts} +0 -0
- /package/dist/core/{pathSerializer.d.ts → pathSerializer.gen.d.ts} +0 -0
package/package.json
CHANGED
package/dist/client/client.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { buildUrl, createConfig, createInterceptors, getParseAs, mergeConfigs, mergeHeaders, setAuthParams, } from './utils';
|
|
2
|
-
export const createClient = (config = {}) => {
|
|
3
|
-
let _config = mergeConfigs(createConfig(), config);
|
|
4
|
-
const getConfig = () => ({ ..._config });
|
|
5
|
-
const setConfig = (config) => {
|
|
6
|
-
_config = mergeConfigs(_config, config);
|
|
7
|
-
return getConfig();
|
|
8
|
-
};
|
|
9
|
-
const interceptors = createInterceptors();
|
|
10
|
-
const request = async (options) => {
|
|
11
|
-
const opts = {
|
|
12
|
-
..._config,
|
|
13
|
-
...options,
|
|
14
|
-
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
15
|
-
headers: mergeHeaders(_config.headers, options.headers),
|
|
16
|
-
};
|
|
17
|
-
if (opts.security) {
|
|
18
|
-
await setAuthParams({
|
|
19
|
-
...opts,
|
|
20
|
-
security: opts.security,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
if (opts.requestValidator) {
|
|
24
|
-
await opts.requestValidator(opts);
|
|
25
|
-
}
|
|
26
|
-
if (opts.body && opts.bodySerializer) {
|
|
27
|
-
opts.body = opts.bodySerializer(opts.body);
|
|
28
|
-
}
|
|
29
|
-
// remove Content-Type header if body is empty to avoid sending invalid requests
|
|
30
|
-
if (opts.body === undefined || opts.body === '') {
|
|
31
|
-
opts.headers.delete('Content-Type');
|
|
32
|
-
}
|
|
33
|
-
const url = buildUrl(opts);
|
|
34
|
-
const requestInit = {
|
|
35
|
-
redirect: 'follow',
|
|
36
|
-
...opts,
|
|
37
|
-
};
|
|
38
|
-
let request = new Request(url, requestInit);
|
|
39
|
-
for (const fn of interceptors.request._fns) {
|
|
40
|
-
if (fn) {
|
|
41
|
-
request = await fn(request, opts);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// fetch must be assigned here, otherwise it would throw the error:
|
|
45
|
-
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
46
|
-
const _fetch = opts.fetch;
|
|
47
|
-
let response = await _fetch(request);
|
|
48
|
-
for (const fn of interceptors.response._fns) {
|
|
49
|
-
if (fn) {
|
|
50
|
-
response = await fn(response, request, opts);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const result = {
|
|
54
|
-
request,
|
|
55
|
-
response,
|
|
56
|
-
};
|
|
57
|
-
if (response.ok) {
|
|
58
|
-
if (response.status === 204 ||
|
|
59
|
-
response.headers.get('Content-Length') === '0') {
|
|
60
|
-
return opts.responseStyle === 'data'
|
|
61
|
-
? {}
|
|
62
|
-
: {
|
|
63
|
-
data: {},
|
|
64
|
-
...result,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
const parseAs = (opts.parseAs === 'auto'
|
|
68
|
-
? getParseAs(response.headers.get('Content-Type'))
|
|
69
|
-
: opts.parseAs) ?? 'json';
|
|
70
|
-
let data;
|
|
71
|
-
switch (parseAs) {
|
|
72
|
-
case 'arrayBuffer':
|
|
73
|
-
case 'blob':
|
|
74
|
-
case 'formData':
|
|
75
|
-
case 'json':
|
|
76
|
-
case 'text':
|
|
77
|
-
data = await response[parseAs]();
|
|
78
|
-
break;
|
|
79
|
-
case 'stream':
|
|
80
|
-
return opts.responseStyle === 'data'
|
|
81
|
-
? response.body
|
|
82
|
-
: {
|
|
83
|
-
data: response.body,
|
|
84
|
-
...result,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
if (parseAs === 'json') {
|
|
88
|
-
if (opts.responseValidator) {
|
|
89
|
-
await opts.responseValidator(data);
|
|
90
|
-
}
|
|
91
|
-
if (opts.responseTransformer) {
|
|
92
|
-
data = await opts.responseTransformer(data);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return opts.responseStyle === 'data'
|
|
96
|
-
? data
|
|
97
|
-
: {
|
|
98
|
-
data,
|
|
99
|
-
...result,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
let error = await response.text();
|
|
103
|
-
try {
|
|
104
|
-
error = JSON.parse(error);
|
|
105
|
-
}
|
|
106
|
-
catch {
|
|
107
|
-
// noop
|
|
108
|
-
}
|
|
109
|
-
let finalError = error;
|
|
110
|
-
for (const fn of interceptors.error._fns) {
|
|
111
|
-
if (fn) {
|
|
112
|
-
finalError = (await fn(error, response, request, opts));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
finalError = finalError || {};
|
|
116
|
-
if (opts.throwOnError) {
|
|
117
|
-
throw finalError;
|
|
118
|
-
}
|
|
119
|
-
// TODO: we probably want to return error and improve types
|
|
120
|
-
return opts.responseStyle === 'data'
|
|
121
|
-
? undefined
|
|
122
|
-
: {
|
|
123
|
-
error: finalError,
|
|
124
|
-
...result,
|
|
125
|
-
};
|
|
126
|
-
};
|
|
127
|
-
return {
|
|
128
|
-
buildUrl,
|
|
129
|
-
connect: (options) => request({ ...options, method: 'CONNECT' }),
|
|
130
|
-
delete: (options) => request({ ...options, method: 'DELETE' }),
|
|
131
|
-
get: (options) => request({ ...options, method: 'GET' }),
|
|
132
|
-
getConfig,
|
|
133
|
-
head: (options) => request({ ...options, method: 'HEAD' }),
|
|
134
|
-
interceptors,
|
|
135
|
-
options: (options) => request({ ...options, method: 'OPTIONS' }),
|
|
136
|
-
patch: (options) => request({ ...options, method: 'PATCH' }),
|
|
137
|
-
post: (options) => request({ ...options, method: 'POST' }),
|
|
138
|
-
put: (options) => request({ ...options, method: 'PUT' }),
|
|
139
|
-
request,
|
|
140
|
-
setConfig,
|
|
141
|
-
trace: (options) => request({ ...options, method: 'TRACE' }),
|
|
142
|
-
};
|
|
143
|
-
};
|
package/dist/client/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ArrayStyle, ObjectStyle, SerializerOptions } from './pathSerializer';
|
|
2
|
-
export type QuerySerializer = (query: Record<string, unknown>) => string;
|
|
3
|
-
export type BodySerializer = (body: any) => any;
|
|
4
|
-
export interface QuerySerializerOptions {
|
|
5
|
-
allowReserved?: boolean;
|
|
6
|
-
array?: SerializerOptions<ArrayStyle>;
|
|
7
|
-
object?: SerializerOptions<ObjectStyle>;
|
|
8
|
-
}
|
|
9
|
-
export declare const formDataBodySerializer: {
|
|
10
|
-
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => FormData;
|
|
11
|
-
};
|
|
12
|
-
export declare const jsonBodySerializer: {
|
|
13
|
-
bodySerializer: <T>(body: T) => string;
|
|
14
|
-
};
|
|
15
|
-
export declare const urlSearchParamsBodySerializer: {
|
|
16
|
-
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => string;
|
|
17
|
-
};
|
package/dist/core/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
File without changes
|