@touhidrahman/auditlog-sdk 1.0.0 → 1.0.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 +9 -0
- package/index.cjs.default.js +1 -0
- package/index.cjs.js +1098 -0
- package/index.cjs.mjs +2 -0
- package/index.d.ts +1 -0
- package/index.esm.js +1077 -0
- package/package.json +14 -15
- package/src/hey-api/types.gen.d.ts +12 -0
- package/src/hey-api/client/client.gen.js +0 -217
- package/src/hey-api/client/index.js +0 -6
- package/src/hey-api/client/types.gen.js +0 -2
- package/src/hey-api/client/utils.gen.js +0 -233
- package/src/hey-api/client.gen.js +0 -5
- package/src/hey-api/core/auth.gen.js +0 -14
- package/src/hey-api/core/bodySerializer.gen.js +0 -57
- package/src/hey-api/core/params.gen.js +0 -106
- package/src/hey-api/core/pathSerializer.gen.js +0 -118
- package/src/hey-api/core/queryKeySerializer.gen.js +0 -100
- package/src/hey-api/core/serverSentEvents.gen.js +0 -136
- package/src/hey-api/core/types.gen.js +0 -2
- package/src/hey-api/core/utils.gen.js +0 -88
- package/src/hey-api/index.js +0 -2
- package/src/hey-api/sdk.gen.js +0 -112
- package/src/hey-api/transformers.gen.js +0 -130
- package/src/hey-api/types.gen.js +0 -2
- package/src/index.js +0 -3
package/package.json
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@touhidrahman/auditlog-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/touhidrahman/my-angular-libs"
|
|
8
8
|
},
|
|
9
|
-
"files": [
|
|
10
|
-
"src"
|
|
11
|
-
],
|
|
12
|
-
"type": "module",
|
|
13
|
-
"main": "./src/index.js",
|
|
14
|
-
"module": "./src/index.js",
|
|
15
|
-
"types": "./src/index.d.ts",
|
|
16
|
-
"exports": {
|
|
17
|
-
".": {
|
|
18
|
-
"types": "./src/index.d.ts",
|
|
19
|
-
"import": "./src/index.js"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
9
|
"publishConfig": {
|
|
23
10
|
"access": "public"
|
|
24
11
|
},
|
|
25
12
|
"dependencies": {
|
|
26
13
|
"@hey-api/client-fetch": "0.13.1",
|
|
27
14
|
"tslib": "^2.3.0"
|
|
28
|
-
}
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
"./package.json": "./package.json",
|
|
18
|
+
".": {
|
|
19
|
+
"module": "./index.esm.js",
|
|
20
|
+
"types": "./index.d.ts",
|
|
21
|
+
"import": "./index.cjs.mjs",
|
|
22
|
+
"default": "./index.cjs.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"module": "./index.esm.js",
|
|
26
|
+
"main": "./index.cjs.js",
|
|
27
|
+
"types": "./index.d.ts"
|
|
29
28
|
}
|
|
@@ -416,6 +416,8 @@ export type GetLogsData = {
|
|
|
416
416
|
creatorId?: string | null;
|
|
417
417
|
creatorName?: string | null;
|
|
418
418
|
projectId?: string;
|
|
419
|
+
referenceName?: string | null;
|
|
420
|
+
referenceId?: string | null;
|
|
419
421
|
action?: 'create' | 'update' | 'delete';
|
|
420
422
|
previousData?: string | number | boolean | unknown | {
|
|
421
423
|
[key: string]: unknown;
|
|
@@ -448,6 +450,8 @@ export type GetLogsResponses = {
|
|
|
448
450
|
creatorId?: string | null;
|
|
449
451
|
creatorName?: string | null;
|
|
450
452
|
projectId?: string;
|
|
453
|
+
referenceName?: string | null;
|
|
454
|
+
referenceId?: string | null;
|
|
451
455
|
action?: 'create' | 'update' | 'delete';
|
|
452
456
|
previousData?: string | number | boolean | unknown | {
|
|
453
457
|
[key: string]: unknown;
|
|
@@ -482,6 +486,8 @@ export type PostLogsData = {
|
|
|
482
486
|
creatorId?: string | null;
|
|
483
487
|
creatorName?: string | null;
|
|
484
488
|
projectId: string;
|
|
489
|
+
referenceName?: string | null;
|
|
490
|
+
referenceId?: string | null;
|
|
485
491
|
action: 'create' | 'update' | 'delete';
|
|
486
492
|
previousData?: string | number | boolean | unknown | {
|
|
487
493
|
[key: string]: unknown;
|
|
@@ -535,6 +541,8 @@ export type PostLogsResponses = {
|
|
|
535
541
|
creatorId?: string | null;
|
|
536
542
|
creatorName?: string | null;
|
|
537
543
|
projectId?: string;
|
|
544
|
+
referenceName?: string | null;
|
|
545
|
+
referenceId?: string | null;
|
|
538
546
|
action?: 'create' | 'update' | 'delete';
|
|
539
547
|
previousData?: string | number | boolean | unknown | {
|
|
540
548
|
[key: string]: unknown;
|
|
@@ -562,6 +570,8 @@ export type GetLogsExportCsvData = {
|
|
|
562
570
|
creatorId?: string | null;
|
|
563
571
|
creatorName?: string | null;
|
|
564
572
|
projectId?: string;
|
|
573
|
+
referenceName?: string | null;
|
|
574
|
+
referenceId?: string | null;
|
|
565
575
|
action?: 'create' | 'update' | 'delete';
|
|
566
576
|
previousData?: string | number | boolean | unknown | {
|
|
567
577
|
[key: string]: unknown;
|
|
@@ -674,6 +684,8 @@ export type GetLogsIdResponses = {
|
|
|
674
684
|
creatorId?: string | null;
|
|
675
685
|
creatorName?: string | null;
|
|
676
686
|
projectId?: string;
|
|
687
|
+
referenceName?: string | null;
|
|
688
|
+
referenceId?: string | null;
|
|
677
689
|
action?: 'create' | 'update' | 'delete';
|
|
678
690
|
previousData?: string | number | boolean | unknown | {
|
|
679
691
|
[key: string]: unknown;
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
import { createSseClient } from '../core/serverSentEvents.gen';
|
|
3
|
-
import { getValidRequestBody } from '../core/utils.gen';
|
|
4
|
-
import { buildUrl, createConfig, createInterceptors, getParseAs, mergeConfigs, mergeHeaders, setAuthParams, } from './utils.gen';
|
|
5
|
-
export const createClient = (config = {}) => {
|
|
6
|
-
let _config = mergeConfigs(createConfig(), config);
|
|
7
|
-
const getConfig = () => ({ ..._config });
|
|
8
|
-
const setConfig = (config) => {
|
|
9
|
-
_config = mergeConfigs(_config, config);
|
|
10
|
-
return getConfig();
|
|
11
|
-
};
|
|
12
|
-
const interceptors = createInterceptors();
|
|
13
|
-
const beforeRequest = async (options) => {
|
|
14
|
-
const opts = {
|
|
15
|
-
..._config,
|
|
16
|
-
...options,
|
|
17
|
-
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
18
|
-
headers: mergeHeaders(_config.headers, options.headers),
|
|
19
|
-
serializedBody: undefined,
|
|
20
|
-
};
|
|
21
|
-
if (opts.security) {
|
|
22
|
-
await setAuthParams(opts);
|
|
23
|
-
}
|
|
24
|
-
if (opts.requestValidator) {
|
|
25
|
-
await opts.requestValidator(opts);
|
|
26
|
-
}
|
|
27
|
-
if (opts.body !== undefined && opts.bodySerializer) {
|
|
28
|
-
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
29
|
-
}
|
|
30
|
-
// remove Content-Type header if body is empty to avoid sending invalid requests
|
|
31
|
-
if (opts.body === undefined || opts.serializedBody === '') {
|
|
32
|
-
opts.headers.delete('Content-Type');
|
|
33
|
-
}
|
|
34
|
-
const resolvedOpts = opts;
|
|
35
|
-
const url = buildUrl(resolvedOpts);
|
|
36
|
-
return { opts: resolvedOpts, url };
|
|
37
|
-
};
|
|
38
|
-
const request = async (options) => {
|
|
39
|
-
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
40
|
-
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
41
|
-
let request;
|
|
42
|
-
let response;
|
|
43
|
-
try {
|
|
44
|
-
const { opts, url } = await beforeRequest(options);
|
|
45
|
-
const requestInit = {
|
|
46
|
-
redirect: 'follow',
|
|
47
|
-
...opts,
|
|
48
|
-
body: getValidRequestBody(opts),
|
|
49
|
-
};
|
|
50
|
-
request = new Request(url, requestInit);
|
|
51
|
-
for (const fn of interceptors.request.fns) {
|
|
52
|
-
if (fn) {
|
|
53
|
-
request = await fn(request, opts);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// fetch must be assigned here, otherwise it would throw the error:
|
|
57
|
-
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
58
|
-
const _fetch = opts.fetch;
|
|
59
|
-
response = await _fetch(request);
|
|
60
|
-
for (const fn of interceptors.response.fns) {
|
|
61
|
-
if (fn) {
|
|
62
|
-
response = await fn(response, request, opts);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
const result = {
|
|
66
|
-
request,
|
|
67
|
-
response,
|
|
68
|
-
};
|
|
69
|
-
if (response.ok) {
|
|
70
|
-
const parseAs = (opts.parseAs === 'auto'
|
|
71
|
-
? getParseAs(response.headers.get('Content-Type'))
|
|
72
|
-
: opts.parseAs) ?? 'json';
|
|
73
|
-
if (response.status === 204 ||
|
|
74
|
-
response.headers.get('Content-Length') === '0') {
|
|
75
|
-
let emptyData;
|
|
76
|
-
switch (parseAs) {
|
|
77
|
-
case 'arrayBuffer':
|
|
78
|
-
case 'blob':
|
|
79
|
-
case 'text':
|
|
80
|
-
emptyData = await response[parseAs]();
|
|
81
|
-
break;
|
|
82
|
-
case 'formData':
|
|
83
|
-
emptyData = new FormData();
|
|
84
|
-
break;
|
|
85
|
-
case 'stream':
|
|
86
|
-
emptyData = response.body;
|
|
87
|
-
break;
|
|
88
|
-
case 'json':
|
|
89
|
-
default:
|
|
90
|
-
emptyData = {};
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
return opts.responseStyle === 'data'
|
|
94
|
-
? emptyData
|
|
95
|
-
: {
|
|
96
|
-
data: emptyData,
|
|
97
|
-
...result,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
let data;
|
|
101
|
-
switch (parseAs) {
|
|
102
|
-
case 'arrayBuffer':
|
|
103
|
-
case 'blob':
|
|
104
|
-
case 'formData':
|
|
105
|
-
case 'text':
|
|
106
|
-
data = await response[parseAs]();
|
|
107
|
-
break;
|
|
108
|
-
case 'json': {
|
|
109
|
-
// Some servers return 200 with no Content-Length and empty body.
|
|
110
|
-
// response.json() would throw; read as text and parse if non-empty.
|
|
111
|
-
const text = await response.text();
|
|
112
|
-
data = text ? JSON.parse(text) : {};
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
case 'stream':
|
|
116
|
-
return opts.responseStyle === 'data'
|
|
117
|
-
? response.body
|
|
118
|
-
: {
|
|
119
|
-
data: response.body,
|
|
120
|
-
...result,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
if (parseAs === 'json') {
|
|
124
|
-
if (opts.responseValidator) {
|
|
125
|
-
await opts.responseValidator(data);
|
|
126
|
-
}
|
|
127
|
-
if (opts.responseTransformer) {
|
|
128
|
-
data = await opts.responseTransformer(data);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return opts.responseStyle === 'data'
|
|
132
|
-
? data
|
|
133
|
-
: {
|
|
134
|
-
data,
|
|
135
|
-
...result,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
const textError = await response.text();
|
|
139
|
-
let jsonError;
|
|
140
|
-
try {
|
|
141
|
-
jsonError = JSON.parse(textError);
|
|
142
|
-
}
|
|
143
|
-
catch {
|
|
144
|
-
// noop
|
|
145
|
-
}
|
|
146
|
-
throw jsonError ?? textError;
|
|
147
|
-
}
|
|
148
|
-
catch (error) {
|
|
149
|
-
let finalError = error;
|
|
150
|
-
for (const fn of interceptors.error.fns) {
|
|
151
|
-
if (fn) {
|
|
152
|
-
finalError = await fn(finalError, response, request, options);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
finalError = finalError || {};
|
|
156
|
-
if (throwOnError) {
|
|
157
|
-
throw finalError;
|
|
158
|
-
}
|
|
159
|
-
// TODO: we probably want to return error and improve types
|
|
160
|
-
return responseStyle === 'data'
|
|
161
|
-
? undefined
|
|
162
|
-
: {
|
|
163
|
-
error: finalError,
|
|
164
|
-
request,
|
|
165
|
-
response,
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
170
|
-
const makeSseFn = (method) => async (options) => {
|
|
171
|
-
const { opts, url } = await beforeRequest(options);
|
|
172
|
-
return createSseClient({
|
|
173
|
-
...opts,
|
|
174
|
-
body: opts.body,
|
|
175
|
-
method,
|
|
176
|
-
onRequest: async (url, init) => {
|
|
177
|
-
let request = new Request(url, init);
|
|
178
|
-
for (const fn of interceptors.request.fns) {
|
|
179
|
-
if (fn) {
|
|
180
|
-
request = await fn(request, opts);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return request;
|
|
184
|
-
},
|
|
185
|
-
serializedBody: getValidRequestBody(opts),
|
|
186
|
-
url,
|
|
187
|
-
});
|
|
188
|
-
};
|
|
189
|
-
const _buildUrl = (options) => buildUrl({ ..._config, ...options });
|
|
190
|
-
return {
|
|
191
|
-
buildUrl: _buildUrl,
|
|
192
|
-
connect: makeMethodFn('CONNECT'),
|
|
193
|
-
delete: makeMethodFn('DELETE'),
|
|
194
|
-
get: makeMethodFn('GET'),
|
|
195
|
-
getConfig,
|
|
196
|
-
head: makeMethodFn('HEAD'),
|
|
197
|
-
interceptors,
|
|
198
|
-
options: makeMethodFn('OPTIONS'),
|
|
199
|
-
patch: makeMethodFn('PATCH'),
|
|
200
|
-
post: makeMethodFn('POST'),
|
|
201
|
-
put: makeMethodFn('PUT'),
|
|
202
|
-
request,
|
|
203
|
-
setConfig,
|
|
204
|
-
sse: {
|
|
205
|
-
connect: makeSseFn('CONNECT'),
|
|
206
|
-
delete: makeSseFn('DELETE'),
|
|
207
|
-
get: makeSseFn('GET'),
|
|
208
|
-
head: makeSseFn('HEAD'),
|
|
209
|
-
options: makeSseFn('OPTIONS'),
|
|
210
|
-
patch: makeSseFn('PATCH'),
|
|
211
|
-
post: makeSseFn('POST'),
|
|
212
|
-
put: makeSseFn('PUT'),
|
|
213
|
-
trace: makeSseFn('TRACE'),
|
|
214
|
-
},
|
|
215
|
-
trace: makeMethodFn('TRACE'),
|
|
216
|
-
};
|
|
217
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from '../core/bodySerializer.gen';
|
|
3
|
-
export { buildClientParams } from '../core/params.gen';
|
|
4
|
-
export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen';
|
|
5
|
-
export { createClient } from './client.gen';
|
|
6
|
-
export { createConfig, mergeHeaders } from './utils.gen';
|
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
import { getAuthToken } from '../core/auth.gen';
|
|
3
|
-
import { jsonBodySerializer } from '../core/bodySerializer.gen';
|
|
4
|
-
import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam, } from '../core/pathSerializer.gen';
|
|
5
|
-
import { getUrl } from '../core/utils.gen';
|
|
6
|
-
export const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
7
|
-
const querySerializer = (queryParams) => {
|
|
8
|
-
const search = [];
|
|
9
|
-
if (queryParams && typeof queryParams === 'object') {
|
|
10
|
-
for (const name in queryParams) {
|
|
11
|
-
const value = queryParams[name];
|
|
12
|
-
if (value === undefined || value === null) {
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
const options = parameters[name] || args;
|
|
16
|
-
if (Array.isArray(value)) {
|
|
17
|
-
const serializedArray = serializeArrayParam({
|
|
18
|
-
allowReserved: options.allowReserved,
|
|
19
|
-
explode: true,
|
|
20
|
-
name,
|
|
21
|
-
style: 'form',
|
|
22
|
-
value,
|
|
23
|
-
...options.array,
|
|
24
|
-
});
|
|
25
|
-
if (serializedArray)
|
|
26
|
-
search.push(serializedArray);
|
|
27
|
-
}
|
|
28
|
-
else if (typeof value === 'object') {
|
|
29
|
-
const serializedObject = serializeObjectParam({
|
|
30
|
-
allowReserved: options.allowReserved,
|
|
31
|
-
explode: true,
|
|
32
|
-
name,
|
|
33
|
-
style: 'deepObject',
|
|
34
|
-
value: value,
|
|
35
|
-
...options.object,
|
|
36
|
-
});
|
|
37
|
-
if (serializedObject)
|
|
38
|
-
search.push(serializedObject);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
const serializedPrimitive = serializePrimitiveParam({
|
|
42
|
-
allowReserved: options.allowReserved,
|
|
43
|
-
name,
|
|
44
|
-
value: value,
|
|
45
|
-
});
|
|
46
|
-
if (serializedPrimitive)
|
|
47
|
-
search.push(serializedPrimitive);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return search.join('&');
|
|
52
|
-
};
|
|
53
|
-
return querySerializer;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Infers parseAs value from provided Content-Type header.
|
|
57
|
-
*/
|
|
58
|
-
export const getParseAs = (contentType) => {
|
|
59
|
-
if (!contentType) {
|
|
60
|
-
// If no Content-Type header is provided, the best we can do is return the raw response body,
|
|
61
|
-
// which is effectively the same as the 'stream' option.
|
|
62
|
-
return 'stream';
|
|
63
|
-
}
|
|
64
|
-
const cleanContent = contentType.split(';')[0]?.trim();
|
|
65
|
-
if (!cleanContent) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (cleanContent.startsWith('application/json') ||
|
|
69
|
-
cleanContent.endsWith('+json')) {
|
|
70
|
-
return 'json';
|
|
71
|
-
}
|
|
72
|
-
if (cleanContent === 'multipart/form-data') {
|
|
73
|
-
return 'formData';
|
|
74
|
-
}
|
|
75
|
-
if (['application/', 'audio/', 'image/', 'video/'].some((type) => cleanContent.startsWith(type))) {
|
|
76
|
-
return 'blob';
|
|
77
|
-
}
|
|
78
|
-
if (cleanContent.startsWith('text/')) {
|
|
79
|
-
return 'text';
|
|
80
|
-
}
|
|
81
|
-
return;
|
|
82
|
-
};
|
|
83
|
-
const checkForExistence = (options, name) => {
|
|
84
|
-
if (!name) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
if (options.headers.has(name) ||
|
|
88
|
-
options.query?.[name] ||
|
|
89
|
-
options.headers.get('Cookie')?.includes(`${name}=`)) {
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
return false;
|
|
93
|
-
};
|
|
94
|
-
export async function setAuthParams(options) {
|
|
95
|
-
for (const auth of options.security ?? []) {
|
|
96
|
-
if (checkForExistence(options, auth.name)) {
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
const token = await getAuthToken(auth, options.auth);
|
|
100
|
-
if (!token) {
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
const name = auth.name ?? 'Authorization';
|
|
104
|
-
switch (auth.in) {
|
|
105
|
-
case 'query':
|
|
106
|
-
if (!options.query) {
|
|
107
|
-
options.query = {};
|
|
108
|
-
}
|
|
109
|
-
options.query[name] = token;
|
|
110
|
-
break;
|
|
111
|
-
case 'cookie':
|
|
112
|
-
options.headers.append('Cookie', `${name}=${token}`);
|
|
113
|
-
break;
|
|
114
|
-
case 'header':
|
|
115
|
-
default:
|
|
116
|
-
options.headers.set(name, token);
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
export const buildUrl = (options) => getUrl({
|
|
122
|
-
baseUrl: options.baseUrl,
|
|
123
|
-
path: options.path,
|
|
124
|
-
query: options.query,
|
|
125
|
-
querySerializer: typeof options.querySerializer === 'function'
|
|
126
|
-
? options.querySerializer
|
|
127
|
-
: createQuerySerializer(options.querySerializer),
|
|
128
|
-
url: options.url,
|
|
129
|
-
});
|
|
130
|
-
export const mergeConfigs = (a, b) => {
|
|
131
|
-
const config = { ...a, ...b };
|
|
132
|
-
if (config.baseUrl?.endsWith('/')) {
|
|
133
|
-
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
134
|
-
}
|
|
135
|
-
config.headers = mergeHeaders(a.headers, b.headers);
|
|
136
|
-
return config;
|
|
137
|
-
};
|
|
138
|
-
const headersEntries = (headers) => {
|
|
139
|
-
const entries = [];
|
|
140
|
-
headers.forEach((value, key) => {
|
|
141
|
-
entries.push([key, value]);
|
|
142
|
-
});
|
|
143
|
-
return entries;
|
|
144
|
-
};
|
|
145
|
-
export const mergeHeaders = (...headers) => {
|
|
146
|
-
const mergedHeaders = new Headers();
|
|
147
|
-
for (const header of headers) {
|
|
148
|
-
if (!header) {
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
const iterator = header instanceof Headers
|
|
152
|
-
? headersEntries(header)
|
|
153
|
-
: Object.entries(header);
|
|
154
|
-
for (const [key, value] of iterator) {
|
|
155
|
-
if (value === null) {
|
|
156
|
-
mergedHeaders.delete(key);
|
|
157
|
-
}
|
|
158
|
-
else if (Array.isArray(value)) {
|
|
159
|
-
for (const v of value) {
|
|
160
|
-
mergedHeaders.append(key, v);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
else if (value !== undefined) {
|
|
164
|
-
// assume object headers are meant to be JSON stringified, i.e., their
|
|
165
|
-
// content value in OpenAPI specification is 'application/json'
|
|
166
|
-
mergedHeaders.set(key, typeof value === 'object'
|
|
167
|
-
? JSON.stringify(value)
|
|
168
|
-
: value);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
return mergedHeaders;
|
|
173
|
-
};
|
|
174
|
-
class Interceptors {
|
|
175
|
-
fns = [];
|
|
176
|
-
clear() {
|
|
177
|
-
this.fns = [];
|
|
178
|
-
}
|
|
179
|
-
eject(id) {
|
|
180
|
-
const index = this.getInterceptorIndex(id);
|
|
181
|
-
if (this.fns[index]) {
|
|
182
|
-
this.fns[index] = null;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
exists(id) {
|
|
186
|
-
const index = this.getInterceptorIndex(id);
|
|
187
|
-
return Boolean(this.fns[index]);
|
|
188
|
-
}
|
|
189
|
-
getInterceptorIndex(id) {
|
|
190
|
-
if (typeof id === 'number') {
|
|
191
|
-
return this.fns[id] ? id : -1;
|
|
192
|
-
}
|
|
193
|
-
return this.fns.indexOf(id);
|
|
194
|
-
}
|
|
195
|
-
update(id, fn) {
|
|
196
|
-
const index = this.getInterceptorIndex(id);
|
|
197
|
-
if (this.fns[index]) {
|
|
198
|
-
this.fns[index] = fn;
|
|
199
|
-
return id;
|
|
200
|
-
}
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
use(fn) {
|
|
204
|
-
this.fns.push(fn);
|
|
205
|
-
return this.fns.length - 1;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
export const createInterceptors = () => ({
|
|
209
|
-
error: new Interceptors(),
|
|
210
|
-
request: new Interceptors(),
|
|
211
|
-
response: new Interceptors(),
|
|
212
|
-
});
|
|
213
|
-
const defaultQuerySerializer = createQuerySerializer({
|
|
214
|
-
allowReserved: false,
|
|
215
|
-
array: {
|
|
216
|
-
explode: true,
|
|
217
|
-
style: 'form',
|
|
218
|
-
},
|
|
219
|
-
object: {
|
|
220
|
-
explode: true,
|
|
221
|
-
style: 'deepObject',
|
|
222
|
-
},
|
|
223
|
-
});
|
|
224
|
-
const defaultHeaders = {
|
|
225
|
-
'Content-Type': 'application/json',
|
|
226
|
-
};
|
|
227
|
-
export const createConfig = (override = {}) => ({
|
|
228
|
-
...jsonBodySerializer,
|
|
229
|
-
headers: defaultHeaders,
|
|
230
|
-
parseAs: 'auto',
|
|
231
|
-
querySerializer: defaultQuerySerializer,
|
|
232
|
-
...override,
|
|
233
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
export const getAuthToken = async (auth, callback) => {
|
|
3
|
-
const token = typeof callback === 'function' ? await callback(auth) : callback;
|
|
4
|
-
if (!token) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
if (auth.scheme === 'bearer') {
|
|
8
|
-
return `Bearer ${token}`;
|
|
9
|
-
}
|
|
10
|
-
if (auth.scheme === 'basic') {
|
|
11
|
-
return `Basic ${btoa(token)}`;
|
|
12
|
-
}
|
|
13
|
-
return token;
|
|
14
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
const serializeFormDataPair = (data, key, value) => {
|
|
3
|
-
if (typeof value === 'string' || value instanceof Blob) {
|
|
4
|
-
data.append(key, value);
|
|
5
|
-
}
|
|
6
|
-
else if (value instanceof Date) {
|
|
7
|
-
data.append(key, value.toISOString());
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
data.append(key, JSON.stringify(value));
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
const serializeUrlSearchParamsPair = (data, key, value) => {
|
|
14
|
-
if (typeof value === 'string') {
|
|
15
|
-
data.append(key, value);
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
data.append(key, JSON.stringify(value));
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
export const formDataBodySerializer = {
|
|
22
|
-
bodySerializer: (body) => {
|
|
23
|
-
const data = new FormData();
|
|
24
|
-
Object.entries(body).forEach(([key, value]) => {
|
|
25
|
-
if (value === undefined || value === null) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (Array.isArray(value)) {
|
|
29
|
-
value.forEach((v) => serializeFormDataPair(data, key, v));
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
serializeFormDataPair(data, key, value);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
return data;
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
export const jsonBodySerializer = {
|
|
39
|
-
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === 'bigint' ? value.toString() : value),
|
|
40
|
-
};
|
|
41
|
-
export const urlSearchParamsBodySerializer = {
|
|
42
|
-
bodySerializer: (body) => {
|
|
43
|
-
const data = new URLSearchParams();
|
|
44
|
-
Object.entries(body).forEach(([key, value]) => {
|
|
45
|
-
if (value === undefined || value === null) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (Array.isArray(value)) {
|
|
49
|
-
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
serializeUrlSearchParamsPair(data, key, value);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return data.toString();
|
|
56
|
-
},
|
|
57
|
-
};
|