@tailorkit/client-platform 0.1.0-beta.0
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 +674 -0
- package/dist/chunk-4K3CQFYO.js +214 -0
- package/dist/chunk-5IRC5P4W.js +9 -0
- package/dist/chunk-5X7JZMEF.js +0 -0
- package/dist/chunk-BV7KDGT6.js +15 -0
- package/dist/chunk-GBVROCWH.js +123 -0
- package/dist/chunk-JETBOCXO.js +132 -0
- package/dist/chunk-KP5YYTW6.js +109 -0
- package/dist/chunk-MG3GT4SQ.js +238 -0
- package/dist/chunk-RRYF7FTJ.js +81 -0
- package/dist/chunk-TWOK2M2L.js +130 -0
- package/dist/chunk-TZPDFAYB.js +18 -0
- package/dist/chunk-VS3R5QGP.js +97 -0
- package/dist/chunk-X5TBL4RL.js +0 -0
- package/dist/chunk-ZLGFMDTV.js +58 -0
- package/dist/client/client/client.gen.d.ts +3 -0
- package/dist/client/client/client.gen.d.ts.map +1 -0
- package/dist/client/client/client.gen.js +12 -0
- package/dist/client/client/index.d.ts +9 -0
- package/dist/client/client/index.d.ts.map +1 -0
- package/dist/client/client/index.js +33 -0
- package/dist/client/client/types.gen.d.ts +121 -0
- package/dist/client/client/types.gen.d.ts.map +1 -0
- package/dist/client/client/types.gen.js +0 -0
- package/dist/client/client/utils.gen.d.ts +38 -0
- package/dist/client/client/utils.gen.d.ts.map +1 -0
- package/dist/client/client/utils.gen.js +24 -0
- package/dist/client/client.gen.d.ts +13 -0
- package/dist/client/client.gen.d.ts.map +1 -0
- package/dist/client/client.gen.js +16 -0
- package/dist/client/core/auth.gen.d.ts +19 -0
- package/dist/client/core/auth.gen.d.ts.map +1 -0
- package/dist/client/core/auth.gen.js +6 -0
- package/dist/client/core/bodySerializer.gen.d.ts +26 -0
- package/dist/client/core/bodySerializer.gen.d.ts.map +1 -0
- package/dist/client/core/bodySerializer.gen.js +10 -0
- package/dist/client/core/params.gen.d.ts +44 -0
- package/dist/client/core/params.gen.d.ts.map +1 -0
- package/dist/client/core/params.gen.js +6 -0
- package/dist/client/core/pathSerializer.gen.d.ts +34 -0
- package/dist/client/core/pathSerializer.gen.d.ts.map +1 -0
- package/dist/client/core/pathSerializer.gen.js +16 -0
- package/dist/client/core/queryKeySerializer.gen.d.ts +19 -0
- package/dist/client/core/queryKeySerializer.gen.d.ts.map +1 -0
- package/dist/client/core/queryKeySerializer.gen.js +10 -0
- package/dist/client/core/serverSentEvents.gen.d.ts +72 -0
- package/dist/client/core/serverSentEvents.gen.d.ts.map +1 -0
- package/dist/client/core/serverSentEvents.gen.js +6 -0
- package/dist/client/core/types.gen.d.ts +79 -0
- package/dist/client/core/types.gen.d.ts.map +1 -0
- package/dist/client/core/types.gen.js +0 -0
- package/dist/client/core/utils.gen.d.ts +20 -0
- package/dist/client/core/utils.gen.d.ts.map +1 -0
- package/dist/client/core/utils.gen.js +13 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +46 -0
- package/dist/client/sdk.gen.d.ts +31 -0
- package/dist/client/sdk.gen.d.ts.map +1 -0
- package/dist/client/sdk.gen.js +45 -0
- package/dist/client/types.gen.d.ts +436 -0
- package/dist/client/types.gen.d.ts.map +1 -0
- package/dist/client/types.gen.js +0 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +6 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +50 -0
- package/package.json +56 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildUrl,
|
|
3
|
+
createConfig,
|
|
4
|
+
createInterceptors,
|
|
5
|
+
getParseAs,
|
|
6
|
+
mergeConfigs,
|
|
7
|
+
mergeHeaders,
|
|
8
|
+
setAuthParams
|
|
9
|
+
} from "./chunk-MG3GT4SQ.js";
|
|
10
|
+
import {
|
|
11
|
+
getValidRequestBody
|
|
12
|
+
} from "./chunk-KP5YYTW6.js";
|
|
13
|
+
import {
|
|
14
|
+
createSseClient
|
|
15
|
+
} from "./chunk-TWOK2M2L.js";
|
|
16
|
+
|
|
17
|
+
// src/client/client/client.gen.ts
|
|
18
|
+
var createClient = (config = {}) => {
|
|
19
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
20
|
+
const getConfig = () => ({ ..._config });
|
|
21
|
+
const setConfig = (config2) => {
|
|
22
|
+
_config = mergeConfigs(_config, config2);
|
|
23
|
+
return getConfig();
|
|
24
|
+
};
|
|
25
|
+
const interceptors = createInterceptors();
|
|
26
|
+
const beforeRequest = async (options) => {
|
|
27
|
+
const opts = {
|
|
28
|
+
..._config,
|
|
29
|
+
...options,
|
|
30
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
31
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
32
|
+
serializedBody: void 0
|
|
33
|
+
};
|
|
34
|
+
if (opts.security) {
|
|
35
|
+
await setAuthParams(opts);
|
|
36
|
+
}
|
|
37
|
+
if (opts.requestValidator) {
|
|
38
|
+
await opts.requestValidator(opts);
|
|
39
|
+
}
|
|
40
|
+
if (opts.body !== void 0 && opts.bodySerializer) {
|
|
41
|
+
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
42
|
+
}
|
|
43
|
+
if (opts.body === void 0 || opts.serializedBody === "") {
|
|
44
|
+
opts.headers.delete("Content-Type");
|
|
45
|
+
}
|
|
46
|
+
const resolvedOpts = opts;
|
|
47
|
+
const url = buildUrl(resolvedOpts);
|
|
48
|
+
return { opts: resolvedOpts, url };
|
|
49
|
+
};
|
|
50
|
+
const request = async (options) => {
|
|
51
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
52
|
+
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
53
|
+
let request2;
|
|
54
|
+
let response;
|
|
55
|
+
try {
|
|
56
|
+
const { opts, url } = await beforeRequest(options);
|
|
57
|
+
const requestInit = {
|
|
58
|
+
redirect: "follow",
|
|
59
|
+
...opts,
|
|
60
|
+
body: getValidRequestBody(opts)
|
|
61
|
+
};
|
|
62
|
+
request2 = new Request(url, requestInit);
|
|
63
|
+
for (const fn of interceptors.request.fns) {
|
|
64
|
+
if (fn) {
|
|
65
|
+
request2 = await fn(request2, opts);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const _fetch = opts.fetch;
|
|
69
|
+
response = await _fetch(request2);
|
|
70
|
+
for (const fn of interceptors.response.fns) {
|
|
71
|
+
if (fn) {
|
|
72
|
+
response = await fn(response, request2, opts);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const result = {
|
|
76
|
+
request: request2,
|
|
77
|
+
response
|
|
78
|
+
};
|
|
79
|
+
if (response.ok) {
|
|
80
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
81
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
82
|
+
let emptyData;
|
|
83
|
+
switch (parseAs) {
|
|
84
|
+
case "arrayBuffer":
|
|
85
|
+
case "blob":
|
|
86
|
+
case "text":
|
|
87
|
+
emptyData = await response[parseAs]();
|
|
88
|
+
break;
|
|
89
|
+
case "formData":
|
|
90
|
+
emptyData = new FormData();
|
|
91
|
+
break;
|
|
92
|
+
case "stream":
|
|
93
|
+
emptyData = response.body;
|
|
94
|
+
break;
|
|
95
|
+
case "json":
|
|
96
|
+
default:
|
|
97
|
+
emptyData = {};
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
101
|
+
data: emptyData,
|
|
102
|
+
...result
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
let data;
|
|
106
|
+
switch (parseAs) {
|
|
107
|
+
case "arrayBuffer":
|
|
108
|
+
case "blob":
|
|
109
|
+
case "formData":
|
|
110
|
+
case "text":
|
|
111
|
+
data = await response[parseAs]();
|
|
112
|
+
break;
|
|
113
|
+
case "json": {
|
|
114
|
+
const text = await response.text();
|
|
115
|
+
data = text ? JSON.parse(text) : {};
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
case "stream":
|
|
119
|
+
return opts.responseStyle === "data" ? response.body : {
|
|
120
|
+
data: response.body,
|
|
121
|
+
...result
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (parseAs === "json") {
|
|
125
|
+
if (opts.responseValidator) {
|
|
126
|
+
await opts.responseValidator(data);
|
|
127
|
+
}
|
|
128
|
+
if (opts.responseTransformer) {
|
|
129
|
+
data = await opts.responseTransformer(data);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return opts.responseStyle === "data" ? data : {
|
|
133
|
+
data,
|
|
134
|
+
...result
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
const textError = await response.text();
|
|
138
|
+
let jsonError;
|
|
139
|
+
try {
|
|
140
|
+
jsonError = JSON.parse(textError);
|
|
141
|
+
} catch {
|
|
142
|
+
}
|
|
143
|
+
throw jsonError ?? textError;
|
|
144
|
+
} catch (error) {
|
|
145
|
+
let finalError = error;
|
|
146
|
+
for (const fn of interceptors.error.fns) {
|
|
147
|
+
if (fn) {
|
|
148
|
+
finalError = await fn(finalError, response, request2, options);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
finalError = finalError || {};
|
|
152
|
+
if (throwOnError) {
|
|
153
|
+
throw finalError;
|
|
154
|
+
}
|
|
155
|
+
return responseStyle === "data" ? void 0 : {
|
|
156
|
+
error: finalError,
|
|
157
|
+
request: request2,
|
|
158
|
+
response
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
163
|
+
const makeSseFn = (method) => async (options) => {
|
|
164
|
+
const { opts, url } = await beforeRequest(options);
|
|
165
|
+
return createSseClient({
|
|
166
|
+
...opts,
|
|
167
|
+
body: opts.body,
|
|
168
|
+
method,
|
|
169
|
+
onRequest: async (url2, init) => {
|
|
170
|
+
let request2 = new Request(url2, init);
|
|
171
|
+
for (const fn of interceptors.request.fns) {
|
|
172
|
+
if (fn) {
|
|
173
|
+
request2 = await fn(request2, opts);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return request2;
|
|
177
|
+
},
|
|
178
|
+
serializedBody: getValidRequestBody(opts),
|
|
179
|
+
url
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
const _buildUrl = (options) => buildUrl({ ..._config, ...options });
|
|
183
|
+
return {
|
|
184
|
+
buildUrl: _buildUrl,
|
|
185
|
+
connect: makeMethodFn("CONNECT"),
|
|
186
|
+
delete: makeMethodFn("DELETE"),
|
|
187
|
+
get: makeMethodFn("GET"),
|
|
188
|
+
getConfig,
|
|
189
|
+
head: makeMethodFn("HEAD"),
|
|
190
|
+
interceptors,
|
|
191
|
+
options: makeMethodFn("OPTIONS"),
|
|
192
|
+
patch: makeMethodFn("PATCH"),
|
|
193
|
+
post: makeMethodFn("POST"),
|
|
194
|
+
put: makeMethodFn("PUT"),
|
|
195
|
+
request,
|
|
196
|
+
setConfig,
|
|
197
|
+
sse: {
|
|
198
|
+
connect: makeSseFn("CONNECT"),
|
|
199
|
+
delete: makeSseFn("DELETE"),
|
|
200
|
+
get: makeSseFn("GET"),
|
|
201
|
+
head: makeSseFn("HEAD"),
|
|
202
|
+
options: makeSseFn("OPTIONS"),
|
|
203
|
+
patch: makeSseFn("PATCH"),
|
|
204
|
+
post: makeSseFn("POST"),
|
|
205
|
+
put: makeSseFn("PUT"),
|
|
206
|
+
trace: makeSseFn("TRACE")
|
|
207
|
+
},
|
|
208
|
+
trace: makeMethodFn("TRACE")
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
export {
|
|
213
|
+
createClient
|
|
214
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createClient
|
|
3
|
+
} from "./chunk-4K3CQFYO.js";
|
|
4
|
+
import {
|
|
5
|
+
createConfig
|
|
6
|
+
} from "./chunk-MG3GT4SQ.js";
|
|
7
|
+
|
|
8
|
+
// src/client/client.gen.ts
|
|
9
|
+
var client = createClient(
|
|
10
|
+
createConfig({ baseUrl: "https://tailorkit.dev/api/platform" })
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
client
|
|
15
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {
|
|
2
|
+
client
|
|
3
|
+
} from "./chunk-BV7KDGT6.js";
|
|
4
|
+
|
|
5
|
+
// src/client/sdk.gen.ts
|
|
6
|
+
var appsList = (options) => (options.client ?? client).get({
|
|
7
|
+
url: "/apps",
|
|
8
|
+
...options
|
|
9
|
+
});
|
|
10
|
+
var appsCreate = (options) => (options.client ?? client).post({
|
|
11
|
+
url: "/apps",
|
|
12
|
+
...options,
|
|
13
|
+
headers: {
|
|
14
|
+
"Content-Type": "application/json",
|
|
15
|
+
...options.headers
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var appsDelete = (options) => (options.client ?? client).delete({
|
|
19
|
+
url: "/apps/{appId}",
|
|
20
|
+
...options
|
|
21
|
+
});
|
|
22
|
+
var appsGet = (options) => (options.client ?? client).get({
|
|
23
|
+
url: "/apps/{appId}",
|
|
24
|
+
...options
|
|
25
|
+
});
|
|
26
|
+
var appsUpdate = (options) => (options.client ?? client).put({
|
|
27
|
+
url: "/apps/{appId}",
|
|
28
|
+
...options,
|
|
29
|
+
headers: {
|
|
30
|
+
"Content-Type": "application/json",
|
|
31
|
+
...options.headers
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
var appsDeploy = (options) => (options.client ?? client).post({
|
|
35
|
+
url: "/apps/{appId}/deploy",
|
|
36
|
+
...options,
|
|
37
|
+
headers: {
|
|
38
|
+
"Content-Type": "application/json",
|
|
39
|
+
...options.headers
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var cliAuthApprove = (options) => (options.client ?? client).post({
|
|
43
|
+
url: "/cli-auth/approve",
|
|
44
|
+
...options,
|
|
45
|
+
headers: {
|
|
46
|
+
"Content-Type": "application/json",
|
|
47
|
+
...options.headers
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
var cliAuthDeny = (options) => (options.client ?? client).post({
|
|
51
|
+
url: "/cli-auth/deny",
|
|
52
|
+
...options,
|
|
53
|
+
headers: {
|
|
54
|
+
"Content-Type": "application/json",
|
|
55
|
+
...options.headers
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
var cliAuthPoll = (options) => (options.client ?? client).post({
|
|
59
|
+
url: "/cli-auth/poll",
|
|
60
|
+
...options,
|
|
61
|
+
headers: {
|
|
62
|
+
"Content-Type": "application/json",
|
|
63
|
+
...options.headers
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
var cliAuthStart = (options) => (options.client ?? client).post({
|
|
67
|
+
url: "/cli-auth/start",
|
|
68
|
+
...options,
|
|
69
|
+
headers: {
|
|
70
|
+
"Content-Type": "application/json",
|
|
71
|
+
...options.headers
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
var cliAuthVerifyToken = (options) => (options.client ?? client).post({
|
|
75
|
+
url: "/cli-auth/verify-token",
|
|
76
|
+
...options,
|
|
77
|
+
headers: {
|
|
78
|
+
"Content-Type": "application/json",
|
|
79
|
+
...options.headers
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
var deploymentsList = (options) => (options.client ?? client).get({
|
|
83
|
+
url: "/deployments",
|
|
84
|
+
...options
|
|
85
|
+
});
|
|
86
|
+
var deploymentsCreate = (options) => (options.client ?? client).post({
|
|
87
|
+
url: "/deployments",
|
|
88
|
+
...options,
|
|
89
|
+
headers: {
|
|
90
|
+
"Content-Type": "application/json",
|
|
91
|
+
...options.headers
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
var deploymentsGet = (options) => (options.client ?? client).get({
|
|
95
|
+
url: "/deployments/{deploymentId}",
|
|
96
|
+
...options
|
|
97
|
+
});
|
|
98
|
+
var deploymentsPublish = (options) => (options.client ?? client).post({
|
|
99
|
+
url: "/deployments/{deploymentId}",
|
|
100
|
+
...options,
|
|
101
|
+
headers: {
|
|
102
|
+
"Content-Type": "application/json",
|
|
103
|
+
...options.headers
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
appsList,
|
|
109
|
+
appsCreate,
|
|
110
|
+
appsDelete,
|
|
111
|
+
appsGet,
|
|
112
|
+
appsUpdate,
|
|
113
|
+
appsDeploy,
|
|
114
|
+
cliAuthApprove,
|
|
115
|
+
cliAuthDeny,
|
|
116
|
+
cliAuthPoll,
|
|
117
|
+
cliAuthStart,
|
|
118
|
+
cliAuthVerifyToken,
|
|
119
|
+
deploymentsList,
|
|
120
|
+
deploymentsCreate,
|
|
121
|
+
deploymentsGet,
|
|
122
|
+
deploymentsPublish
|
|
123
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// src/client/core/pathSerializer.gen.ts
|
|
2
|
+
var separatorArrayExplode = (style) => {
|
|
3
|
+
switch (style) {
|
|
4
|
+
case "label":
|
|
5
|
+
return ".";
|
|
6
|
+
case "matrix":
|
|
7
|
+
return ";";
|
|
8
|
+
case "simple":
|
|
9
|
+
return ",";
|
|
10
|
+
default:
|
|
11
|
+
return "&";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var separatorArrayNoExplode = (style) => {
|
|
15
|
+
switch (style) {
|
|
16
|
+
case "form":
|
|
17
|
+
return ",";
|
|
18
|
+
case "pipeDelimited":
|
|
19
|
+
return "|";
|
|
20
|
+
case "spaceDelimited":
|
|
21
|
+
return "%20";
|
|
22
|
+
default:
|
|
23
|
+
return ",";
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var separatorObjectExplode = (style) => {
|
|
27
|
+
switch (style) {
|
|
28
|
+
case "label":
|
|
29
|
+
return ".";
|
|
30
|
+
case "matrix":
|
|
31
|
+
return ";";
|
|
32
|
+
case "simple":
|
|
33
|
+
return ",";
|
|
34
|
+
default:
|
|
35
|
+
return "&";
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var serializeArrayParam = ({
|
|
39
|
+
allowReserved,
|
|
40
|
+
explode,
|
|
41
|
+
name,
|
|
42
|
+
style,
|
|
43
|
+
value
|
|
44
|
+
}) => {
|
|
45
|
+
if (!explode) {
|
|
46
|
+
const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
47
|
+
switch (style) {
|
|
48
|
+
case "label":
|
|
49
|
+
return `.${joinedValues2}`;
|
|
50
|
+
case "matrix":
|
|
51
|
+
return `;${name}=${joinedValues2}`;
|
|
52
|
+
case "simple":
|
|
53
|
+
return joinedValues2;
|
|
54
|
+
default:
|
|
55
|
+
return `${name}=${joinedValues2}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const separator = separatorArrayExplode(style);
|
|
59
|
+
const joinedValues = value.map((v) => {
|
|
60
|
+
if (style === "label" || style === "simple") {
|
|
61
|
+
return allowReserved ? v : encodeURIComponent(v);
|
|
62
|
+
}
|
|
63
|
+
return serializePrimitiveParam({
|
|
64
|
+
allowReserved,
|
|
65
|
+
name,
|
|
66
|
+
value: v
|
|
67
|
+
});
|
|
68
|
+
}).join(separator);
|
|
69
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
70
|
+
};
|
|
71
|
+
var serializePrimitiveParam = ({
|
|
72
|
+
allowReserved,
|
|
73
|
+
name,
|
|
74
|
+
value
|
|
75
|
+
}) => {
|
|
76
|
+
if (value === void 0 || value === null) {
|
|
77
|
+
return "";
|
|
78
|
+
}
|
|
79
|
+
if (typeof value === "object") {
|
|
80
|
+
throw new Error(
|
|
81
|
+
"Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
85
|
+
};
|
|
86
|
+
var serializeObjectParam = ({
|
|
87
|
+
allowReserved,
|
|
88
|
+
explode,
|
|
89
|
+
name,
|
|
90
|
+
style,
|
|
91
|
+
value,
|
|
92
|
+
valueOnly
|
|
93
|
+
}) => {
|
|
94
|
+
if (value instanceof Date) {
|
|
95
|
+
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
96
|
+
}
|
|
97
|
+
if (style !== "deepObject" && !explode) {
|
|
98
|
+
let values = [];
|
|
99
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
100
|
+
values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
|
|
101
|
+
});
|
|
102
|
+
const joinedValues2 = values.join(",");
|
|
103
|
+
switch (style) {
|
|
104
|
+
case "form":
|
|
105
|
+
return `${name}=${joinedValues2}`;
|
|
106
|
+
case "label":
|
|
107
|
+
return `.${joinedValues2}`;
|
|
108
|
+
case "matrix":
|
|
109
|
+
return `;${name}=${joinedValues2}`;
|
|
110
|
+
default:
|
|
111
|
+
return joinedValues2;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const separator = separatorObjectExplode(style);
|
|
115
|
+
const joinedValues = Object.entries(value).map(
|
|
116
|
+
([key, v]) => serializePrimitiveParam({
|
|
117
|
+
allowReserved,
|
|
118
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
119
|
+
value: v
|
|
120
|
+
})
|
|
121
|
+
).join(separator);
|
|
122
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export {
|
|
126
|
+
separatorArrayExplode,
|
|
127
|
+
separatorArrayNoExplode,
|
|
128
|
+
separatorObjectExplode,
|
|
129
|
+
serializeArrayParam,
|
|
130
|
+
serializePrimitiveParam,
|
|
131
|
+
serializeObjectParam
|
|
132
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
serializeArrayParam,
|
|
3
|
+
serializeObjectParam,
|
|
4
|
+
serializePrimitiveParam
|
|
5
|
+
} from "./chunk-JETBOCXO.js";
|
|
6
|
+
|
|
7
|
+
// src/client/core/utils.gen.ts
|
|
8
|
+
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
9
|
+
var defaultPathSerializer = ({ path, url: _url }) => {
|
|
10
|
+
let url = _url;
|
|
11
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
12
|
+
if (matches) {
|
|
13
|
+
for (const match of matches) {
|
|
14
|
+
let explode = false;
|
|
15
|
+
let name = match.substring(1, match.length - 1);
|
|
16
|
+
let style = "simple";
|
|
17
|
+
if (name.endsWith("*")) {
|
|
18
|
+
explode = true;
|
|
19
|
+
name = name.substring(0, name.length - 1);
|
|
20
|
+
}
|
|
21
|
+
if (name.startsWith(".")) {
|
|
22
|
+
name = name.substring(1);
|
|
23
|
+
style = "label";
|
|
24
|
+
} else if (name.startsWith(";")) {
|
|
25
|
+
name = name.substring(1);
|
|
26
|
+
style = "matrix";
|
|
27
|
+
}
|
|
28
|
+
const value = path[name];
|
|
29
|
+
if (value === void 0 || value === null) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (Array.isArray(value)) {
|
|
33
|
+
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (typeof value === "object") {
|
|
37
|
+
url = url.replace(
|
|
38
|
+
match,
|
|
39
|
+
serializeObjectParam({
|
|
40
|
+
explode,
|
|
41
|
+
name,
|
|
42
|
+
style,
|
|
43
|
+
value,
|
|
44
|
+
valueOnly: true
|
|
45
|
+
})
|
|
46
|
+
);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (style === "matrix") {
|
|
50
|
+
url = url.replace(
|
|
51
|
+
match,
|
|
52
|
+
`;${serializePrimitiveParam({
|
|
53
|
+
name,
|
|
54
|
+
value
|
|
55
|
+
})}`
|
|
56
|
+
);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const replaceValue = encodeURIComponent(
|
|
60
|
+
style === "label" ? `.${value}` : value
|
|
61
|
+
);
|
|
62
|
+
url = url.replace(match, replaceValue);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return url;
|
|
66
|
+
};
|
|
67
|
+
var getUrl = ({
|
|
68
|
+
baseUrl,
|
|
69
|
+
path,
|
|
70
|
+
query,
|
|
71
|
+
querySerializer,
|
|
72
|
+
url: _url
|
|
73
|
+
}) => {
|
|
74
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
75
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
76
|
+
if (path) {
|
|
77
|
+
url = defaultPathSerializer({ path, url });
|
|
78
|
+
}
|
|
79
|
+
let search = query ? querySerializer(query) : "";
|
|
80
|
+
if (search.startsWith("?")) {
|
|
81
|
+
search = search.substring(1);
|
|
82
|
+
}
|
|
83
|
+
if (search) {
|
|
84
|
+
url += `?${search}`;
|
|
85
|
+
}
|
|
86
|
+
return url;
|
|
87
|
+
};
|
|
88
|
+
function getValidRequestBody(options) {
|
|
89
|
+
const hasBody = options.body !== void 0;
|
|
90
|
+
const isSerializedBody = hasBody && options.bodySerializer;
|
|
91
|
+
if (isSerializedBody) {
|
|
92
|
+
if ("serializedBody" in options) {
|
|
93
|
+
const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
|
|
94
|
+
return hasSerializedBody ? options.serializedBody : null;
|
|
95
|
+
}
|
|
96
|
+
return options.body !== "" ? options.body : null;
|
|
97
|
+
}
|
|
98
|
+
if (hasBody) {
|
|
99
|
+
return options.body;
|
|
100
|
+
}
|
|
101
|
+
return void 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
PATH_PARAM_RE,
|
|
106
|
+
defaultPathSerializer,
|
|
107
|
+
getUrl,
|
|
108
|
+
getValidRequestBody
|
|
109
|
+
};
|