gatana-sdk 2.2.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 +21 -0
- package/dist/api/index.cjs +155 -0
- package/dist/api/index.d.cts +2 -0
- package/dist/api/index.d.mts +2 -0
- package/dist/api/index.mjs +3 -0
- package/dist/apiv2/index.cjs +9 -0
- package/dist/apiv2/index.d.cts +2 -0
- package/dist/apiv2/index.d.mts +2 -0
- package/dist/apiv2/index.mjs +3 -0
- package/dist/chunk-DQk6qfdC.mjs +18 -0
- package/dist/chunk-uaV2rQ02.cjs +53 -0
- package/dist/config.cjs +92 -0
- package/dist/config.d.cts +28 -0
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.mts +28 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +80 -0
- package/dist/config.mjs.map +1 -0
- package/dist/index.cjs +198 -0
- package/dist/index.d.cts +73 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +73 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +189 -0
- package/dist/index.mjs.map +1 -0
- package/dist/sdk.gen-8pk6phy9.d.mts +4461 -0
- package/dist/sdk.gen-8pk6phy9.d.mts.map +1 -0
- package/dist/sdk.gen-C3exKd-p.d.mts +623 -0
- package/dist/sdk.gen-C3exKd-p.d.mts.map +1 -0
- package/dist/sdk.gen-CKko8Vw_.cjs +3977 -0
- package/dist/sdk.gen-CjrIKr7c.cjs +774 -0
- package/dist/sdk.gen-CsXf3DVg.d.cts +623 -0
- package/dist/sdk.gen-CsXf3DVg.d.cts.map +1 -0
- package/dist/sdk.gen-DH-7_dug.mjs +728 -0
- package/dist/sdk.gen-DH-7_dug.mjs.map +1 -0
- package/dist/sdk.gen-DjFKgYPq.mjs +3055 -0
- package/dist/sdk.gen-DjFKgYPq.mjs.map +1 -0
- package/dist/sdk.gen-vjzsjj67.d.cts +4461 -0
- package/dist/sdk.gen-vjzsjj67.d.cts.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,728 @@
|
|
|
1
|
+
import { t as __exportAll } from "./chunk-DQk6qfdC.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/apiv2/core/bodySerializer.gen.ts
|
|
4
|
+
const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/apiv2/core/params.gen.ts
|
|
8
|
+
const extraPrefixes = Object.entries({
|
|
9
|
+
$body_: "body",
|
|
10
|
+
$headers_: "headers",
|
|
11
|
+
$path_: "path",
|
|
12
|
+
$query_: "query"
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/apiv2/core/serverSentEvents.gen.ts
|
|
17
|
+
const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) => {
|
|
18
|
+
let lastEventId;
|
|
19
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
20
|
+
const createStream = async function* () {
|
|
21
|
+
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
22
|
+
let attempt = 0;
|
|
23
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
24
|
+
while (true) {
|
|
25
|
+
if (signal.aborted) break;
|
|
26
|
+
attempt++;
|
|
27
|
+
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
28
|
+
if (lastEventId !== void 0) headers.set("Last-Event-ID", lastEventId);
|
|
29
|
+
try {
|
|
30
|
+
const requestInit = {
|
|
31
|
+
redirect: "follow",
|
|
32
|
+
...options,
|
|
33
|
+
body: options.serializedBody,
|
|
34
|
+
headers,
|
|
35
|
+
signal
|
|
36
|
+
};
|
|
37
|
+
let request = new Request(url, requestInit);
|
|
38
|
+
if (onRequest) request = await onRequest(url, requestInit);
|
|
39
|
+
const response = await (options.fetch ?? globalThis.fetch)(request);
|
|
40
|
+
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
41
|
+
if (!response.body) throw new Error("No body in SSE response");
|
|
42
|
+
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
43
|
+
let buffer = "";
|
|
44
|
+
const abortHandler = () => {
|
|
45
|
+
try {
|
|
46
|
+
reader.cancel();
|
|
47
|
+
} catch {}
|
|
48
|
+
};
|
|
49
|
+
signal.addEventListener("abort", abortHandler);
|
|
50
|
+
try {
|
|
51
|
+
while (true) {
|
|
52
|
+
const { done, value } = await reader.read();
|
|
53
|
+
if (done) break;
|
|
54
|
+
buffer += value;
|
|
55
|
+
const chunks = buffer.split("\n\n");
|
|
56
|
+
buffer = chunks.pop() ?? "";
|
|
57
|
+
for (const chunk of chunks) {
|
|
58
|
+
const lines = chunk.split("\n");
|
|
59
|
+
const dataLines = [];
|
|
60
|
+
let eventName;
|
|
61
|
+
for (const line of lines) if (line.startsWith("data:")) dataLines.push(line.replace(/^data:\s*/, ""));
|
|
62
|
+
else if (line.startsWith("event:")) eventName = line.replace(/^event:\s*/, "");
|
|
63
|
+
else if (line.startsWith("id:")) lastEventId = line.replace(/^id:\s*/, "");
|
|
64
|
+
else if (line.startsWith("retry:")) {
|
|
65
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
66
|
+
if (!Number.isNaN(parsed)) retryDelay = parsed;
|
|
67
|
+
}
|
|
68
|
+
let data;
|
|
69
|
+
let parsedJson = false;
|
|
70
|
+
if (dataLines.length) {
|
|
71
|
+
const rawData = dataLines.join("\n");
|
|
72
|
+
try {
|
|
73
|
+
data = JSON.parse(rawData);
|
|
74
|
+
parsedJson = true;
|
|
75
|
+
} catch {
|
|
76
|
+
data = rawData;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (parsedJson) {
|
|
80
|
+
if (responseValidator) await responseValidator(data);
|
|
81
|
+
if (responseTransformer) data = await responseTransformer(data);
|
|
82
|
+
}
|
|
83
|
+
onSseEvent?.({
|
|
84
|
+
data,
|
|
85
|
+
event: eventName,
|
|
86
|
+
id: lastEventId,
|
|
87
|
+
retry: retryDelay
|
|
88
|
+
});
|
|
89
|
+
if (dataLines.length) yield data;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
} finally {
|
|
93
|
+
signal.removeEventListener("abort", abortHandler);
|
|
94
|
+
reader.releaseLock();
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
} catch (error) {
|
|
98
|
+
onSseError?.(error);
|
|
99
|
+
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) break;
|
|
100
|
+
await sleep(Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
return { stream: createStream() };
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/apiv2/core/pathSerializer.gen.ts
|
|
109
|
+
const separatorArrayExplode = (style) => {
|
|
110
|
+
switch (style) {
|
|
111
|
+
case "label": return ".";
|
|
112
|
+
case "matrix": return ";";
|
|
113
|
+
case "simple": return ",";
|
|
114
|
+
default: return "&";
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const separatorArrayNoExplode = (style) => {
|
|
118
|
+
switch (style) {
|
|
119
|
+
case "form": return ",";
|
|
120
|
+
case "pipeDelimited": return "|";
|
|
121
|
+
case "spaceDelimited": return "%20";
|
|
122
|
+
default: return ",";
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const separatorObjectExplode = (style) => {
|
|
126
|
+
switch (style) {
|
|
127
|
+
case "label": return ".";
|
|
128
|
+
case "matrix": return ";";
|
|
129
|
+
case "simple": return ",";
|
|
130
|
+
default: return "&";
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
|
|
134
|
+
if (!explode) {
|
|
135
|
+
const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
136
|
+
switch (style) {
|
|
137
|
+
case "label": return `.${joinedValues}`;
|
|
138
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
139
|
+
case "simple": return joinedValues;
|
|
140
|
+
default: return `${name}=${joinedValues}`;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const separator = separatorArrayExplode(style);
|
|
144
|
+
const joinedValues = value.map((v) => {
|
|
145
|
+
if (style === "label" || style === "simple") return allowReserved ? v : encodeURIComponent(v);
|
|
146
|
+
return serializePrimitiveParam({
|
|
147
|
+
allowReserved,
|
|
148
|
+
name,
|
|
149
|
+
value: v
|
|
150
|
+
});
|
|
151
|
+
}).join(separator);
|
|
152
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
153
|
+
};
|
|
154
|
+
const serializePrimitiveParam = ({ allowReserved, name, value }) => {
|
|
155
|
+
if (value === void 0 || value === null) return "";
|
|
156
|
+
if (typeof value === "object") throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
|
|
157
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
158
|
+
};
|
|
159
|
+
const serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly }) => {
|
|
160
|
+
if (value instanceof Date) return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
161
|
+
if (style !== "deepObject" && !explode) {
|
|
162
|
+
let values = [];
|
|
163
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
164
|
+
values = [
|
|
165
|
+
...values,
|
|
166
|
+
key,
|
|
167
|
+
allowReserved ? v : encodeURIComponent(v)
|
|
168
|
+
];
|
|
169
|
+
});
|
|
170
|
+
const joinedValues = values.join(",");
|
|
171
|
+
switch (style) {
|
|
172
|
+
case "form": return `${name}=${joinedValues}`;
|
|
173
|
+
case "label": return `.${joinedValues}`;
|
|
174
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
175
|
+
default: return joinedValues;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const separator = separatorObjectExplode(style);
|
|
179
|
+
const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
|
|
180
|
+
allowReserved,
|
|
181
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
182
|
+
value: v
|
|
183
|
+
})).join(separator);
|
|
184
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/apiv2/core/utils.gen.ts
|
|
189
|
+
const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
190
|
+
const defaultPathSerializer = ({ path, url: _url }) => {
|
|
191
|
+
let url = _url;
|
|
192
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
193
|
+
if (matches) for (const match of matches) {
|
|
194
|
+
let explode = false;
|
|
195
|
+
let name = match.substring(1, match.length - 1);
|
|
196
|
+
let style = "simple";
|
|
197
|
+
if (name.endsWith("*")) {
|
|
198
|
+
explode = true;
|
|
199
|
+
name = name.substring(0, name.length - 1);
|
|
200
|
+
}
|
|
201
|
+
if (name.startsWith(".")) {
|
|
202
|
+
name = name.substring(1);
|
|
203
|
+
style = "label";
|
|
204
|
+
} else if (name.startsWith(";")) {
|
|
205
|
+
name = name.substring(1);
|
|
206
|
+
style = "matrix";
|
|
207
|
+
}
|
|
208
|
+
const value = path[name];
|
|
209
|
+
if (value === void 0 || value === null) continue;
|
|
210
|
+
if (Array.isArray(value)) {
|
|
211
|
+
url = url.replace(match, serializeArrayParam({
|
|
212
|
+
explode,
|
|
213
|
+
name,
|
|
214
|
+
style,
|
|
215
|
+
value
|
|
216
|
+
}));
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
if (typeof value === "object") {
|
|
220
|
+
url = url.replace(match, serializeObjectParam({
|
|
221
|
+
explode,
|
|
222
|
+
name,
|
|
223
|
+
style,
|
|
224
|
+
value,
|
|
225
|
+
valueOnly: true
|
|
226
|
+
}));
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
if (style === "matrix") {
|
|
230
|
+
url = url.replace(match, `;${serializePrimitiveParam({
|
|
231
|
+
name,
|
|
232
|
+
value
|
|
233
|
+
})}`);
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
|
|
237
|
+
url = url.replace(match, replaceValue);
|
|
238
|
+
}
|
|
239
|
+
return url;
|
|
240
|
+
};
|
|
241
|
+
const getUrl = ({ baseUrl, path, query, querySerializer, url: _url }) => {
|
|
242
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
243
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
244
|
+
if (path) url = defaultPathSerializer({
|
|
245
|
+
path,
|
|
246
|
+
url
|
|
247
|
+
});
|
|
248
|
+
let search = query ? querySerializer(query) : "";
|
|
249
|
+
if (search.startsWith("?")) search = search.substring(1);
|
|
250
|
+
if (search) url += `?${search}`;
|
|
251
|
+
return url;
|
|
252
|
+
};
|
|
253
|
+
function getValidRequestBody(options) {
|
|
254
|
+
const hasBody = options.body !== void 0;
|
|
255
|
+
if (hasBody && options.bodySerializer) {
|
|
256
|
+
if ("serializedBody" in options) return options.serializedBody !== void 0 && options.serializedBody !== "" ? options.serializedBody : null;
|
|
257
|
+
return options.body !== "" ? options.body : null;
|
|
258
|
+
}
|
|
259
|
+
if (hasBody) return options.body;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/apiv2/core/auth.gen.ts
|
|
264
|
+
const getAuthToken = async (auth, callback) => {
|
|
265
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
266
|
+
if (!token) return;
|
|
267
|
+
if (auth.scheme === "bearer") return `Bearer ${token}`;
|
|
268
|
+
if (auth.scheme === "basic") return `Basic ${btoa(token)}`;
|
|
269
|
+
return token;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region src/apiv2/client/utils.gen.ts
|
|
274
|
+
const createQuerySerializer = ({ allowReserved, array, object } = {}) => {
|
|
275
|
+
const querySerializer = (queryParams) => {
|
|
276
|
+
const search = [];
|
|
277
|
+
if (queryParams && typeof queryParams === "object") for (const name in queryParams) {
|
|
278
|
+
const value = queryParams[name];
|
|
279
|
+
if (value === void 0 || value === null) continue;
|
|
280
|
+
if (Array.isArray(value)) {
|
|
281
|
+
const serializedArray = serializeArrayParam({
|
|
282
|
+
allowReserved,
|
|
283
|
+
explode: true,
|
|
284
|
+
name,
|
|
285
|
+
style: "form",
|
|
286
|
+
value,
|
|
287
|
+
...array
|
|
288
|
+
});
|
|
289
|
+
if (serializedArray) search.push(serializedArray);
|
|
290
|
+
} else if (typeof value === "object") {
|
|
291
|
+
const serializedObject = serializeObjectParam({
|
|
292
|
+
allowReserved,
|
|
293
|
+
explode: true,
|
|
294
|
+
name,
|
|
295
|
+
style: "deepObject",
|
|
296
|
+
value,
|
|
297
|
+
...object
|
|
298
|
+
});
|
|
299
|
+
if (serializedObject) search.push(serializedObject);
|
|
300
|
+
} else {
|
|
301
|
+
const serializedPrimitive = serializePrimitiveParam({
|
|
302
|
+
allowReserved,
|
|
303
|
+
name,
|
|
304
|
+
value
|
|
305
|
+
});
|
|
306
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return search.join("&");
|
|
310
|
+
};
|
|
311
|
+
return querySerializer;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Infers parseAs value from provided Content-Type header.
|
|
315
|
+
*/
|
|
316
|
+
const getParseAs = (contentType) => {
|
|
317
|
+
if (!contentType) return "stream";
|
|
318
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
319
|
+
if (!cleanContent) return;
|
|
320
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) return "json";
|
|
321
|
+
if (cleanContent === "multipart/form-data") return "formData";
|
|
322
|
+
if ([
|
|
323
|
+
"application/",
|
|
324
|
+
"audio/",
|
|
325
|
+
"image/",
|
|
326
|
+
"video/"
|
|
327
|
+
].some((type) => cleanContent.startsWith(type))) return "blob";
|
|
328
|
+
if (cleanContent.startsWith("text/")) return "text";
|
|
329
|
+
};
|
|
330
|
+
const checkForExistence = (options, name) => {
|
|
331
|
+
if (!name) return false;
|
|
332
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) return true;
|
|
333
|
+
return false;
|
|
334
|
+
};
|
|
335
|
+
const setAuthParams = async ({ security, ...options }) => {
|
|
336
|
+
for (const auth of security) {
|
|
337
|
+
if (checkForExistence(options, auth.name)) continue;
|
|
338
|
+
const token = await getAuthToken(auth, options.auth);
|
|
339
|
+
if (!token) continue;
|
|
340
|
+
const name = auth.name ?? "Authorization";
|
|
341
|
+
switch (auth.in) {
|
|
342
|
+
case "query":
|
|
343
|
+
if (!options.query) options.query = {};
|
|
344
|
+
options.query[name] = token;
|
|
345
|
+
break;
|
|
346
|
+
case "cookie":
|
|
347
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
348
|
+
break;
|
|
349
|
+
default:
|
|
350
|
+
options.headers.set(name, token);
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
const buildUrl = (options) => getUrl({
|
|
356
|
+
baseUrl: options.baseUrl,
|
|
357
|
+
path: options.path,
|
|
358
|
+
query: options.query,
|
|
359
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
360
|
+
url: options.url
|
|
361
|
+
});
|
|
362
|
+
const mergeConfigs = (a, b) => {
|
|
363
|
+
const config = {
|
|
364
|
+
...a,
|
|
365
|
+
...b
|
|
366
|
+
};
|
|
367
|
+
if (config.baseUrl?.endsWith("/")) config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
368
|
+
config.headers = mergeHeaders(a.headers, b.headers);
|
|
369
|
+
return config;
|
|
370
|
+
};
|
|
371
|
+
const headersEntries = (headers) => {
|
|
372
|
+
const entries = [];
|
|
373
|
+
headers.forEach((value, key) => {
|
|
374
|
+
entries.push([key, value]);
|
|
375
|
+
});
|
|
376
|
+
return entries;
|
|
377
|
+
};
|
|
378
|
+
const mergeHeaders = (...headers) => {
|
|
379
|
+
const mergedHeaders = new Headers();
|
|
380
|
+
for (const header of headers) {
|
|
381
|
+
if (!header) continue;
|
|
382
|
+
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
383
|
+
for (const [key, value] of iterator) if (value === null) mergedHeaders.delete(key);
|
|
384
|
+
else if (Array.isArray(value)) for (const v of value) mergedHeaders.append(key, v);
|
|
385
|
+
else if (value !== void 0) mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
386
|
+
}
|
|
387
|
+
return mergedHeaders;
|
|
388
|
+
};
|
|
389
|
+
var Interceptors = class {
|
|
390
|
+
_fns;
|
|
391
|
+
constructor() {
|
|
392
|
+
this._fns = [];
|
|
393
|
+
}
|
|
394
|
+
clear() {
|
|
395
|
+
this._fns = [];
|
|
396
|
+
}
|
|
397
|
+
getInterceptorIndex(id) {
|
|
398
|
+
if (typeof id === "number") return this._fns[id] ? id : -1;
|
|
399
|
+
else return this._fns.indexOf(id);
|
|
400
|
+
}
|
|
401
|
+
exists(id) {
|
|
402
|
+
const index = this.getInterceptorIndex(id);
|
|
403
|
+
return !!this._fns[index];
|
|
404
|
+
}
|
|
405
|
+
eject(id) {
|
|
406
|
+
const index = this.getInterceptorIndex(id);
|
|
407
|
+
if (this._fns[index]) this._fns[index] = null;
|
|
408
|
+
}
|
|
409
|
+
update(id, fn) {
|
|
410
|
+
const index = this.getInterceptorIndex(id);
|
|
411
|
+
if (this._fns[index]) {
|
|
412
|
+
this._fns[index] = fn;
|
|
413
|
+
return id;
|
|
414
|
+
} else return false;
|
|
415
|
+
}
|
|
416
|
+
use(fn) {
|
|
417
|
+
this._fns = [...this._fns, fn];
|
|
418
|
+
return this._fns.length - 1;
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
const createInterceptors = () => ({
|
|
422
|
+
error: new Interceptors(),
|
|
423
|
+
request: new Interceptors(),
|
|
424
|
+
response: new Interceptors()
|
|
425
|
+
});
|
|
426
|
+
const defaultQuerySerializer = createQuerySerializer({
|
|
427
|
+
allowReserved: false,
|
|
428
|
+
array: {
|
|
429
|
+
explode: true,
|
|
430
|
+
style: "form"
|
|
431
|
+
},
|
|
432
|
+
object: {
|
|
433
|
+
explode: true,
|
|
434
|
+
style: "deepObject"
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
const defaultHeaders = { "Content-Type": "application/json" };
|
|
438
|
+
const createConfig = (override = {}) => ({
|
|
439
|
+
...jsonBodySerializer,
|
|
440
|
+
headers: defaultHeaders,
|
|
441
|
+
parseAs: "auto",
|
|
442
|
+
querySerializer: defaultQuerySerializer,
|
|
443
|
+
...override
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
//#endregion
|
|
447
|
+
//#region src/apiv2/client/client.gen.ts
|
|
448
|
+
const createClient = (config = {}) => {
|
|
449
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
450
|
+
const getConfig = () => ({ ..._config });
|
|
451
|
+
const setConfig = (config) => {
|
|
452
|
+
_config = mergeConfigs(_config, config);
|
|
453
|
+
return getConfig();
|
|
454
|
+
};
|
|
455
|
+
const interceptors = createInterceptors();
|
|
456
|
+
const beforeRequest = async (options) => {
|
|
457
|
+
const opts = {
|
|
458
|
+
..._config,
|
|
459
|
+
...options,
|
|
460
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
461
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
462
|
+
serializedBody: void 0
|
|
463
|
+
};
|
|
464
|
+
if (opts.security) await setAuthParams({
|
|
465
|
+
...opts,
|
|
466
|
+
security: opts.security
|
|
467
|
+
});
|
|
468
|
+
if (opts.requestValidator) await opts.requestValidator(opts);
|
|
469
|
+
if (opts.body !== void 0 && opts.bodySerializer) opts.serializedBody = opts.bodySerializer(opts.body);
|
|
470
|
+
if (opts.body === void 0 || opts.serializedBody === "") opts.headers.delete("Content-Type");
|
|
471
|
+
return {
|
|
472
|
+
opts,
|
|
473
|
+
url: buildUrl(opts)
|
|
474
|
+
};
|
|
475
|
+
};
|
|
476
|
+
const request = async (options) => {
|
|
477
|
+
const { opts, url } = await beforeRequest(options);
|
|
478
|
+
const requestInit = {
|
|
479
|
+
redirect: "follow",
|
|
480
|
+
...opts,
|
|
481
|
+
body: getValidRequestBody(opts)
|
|
482
|
+
};
|
|
483
|
+
let request = new Request(url, requestInit);
|
|
484
|
+
for (const fn of interceptors.request._fns) if (fn) request = await fn(request, opts);
|
|
485
|
+
const _fetch = opts.fetch;
|
|
486
|
+
let response = await _fetch(request);
|
|
487
|
+
for (const fn of interceptors.response._fns) if (fn) response = await fn(response, request, opts);
|
|
488
|
+
const result = {
|
|
489
|
+
request,
|
|
490
|
+
response
|
|
491
|
+
};
|
|
492
|
+
if (response.ok) {
|
|
493
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
494
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
495
|
+
let emptyData;
|
|
496
|
+
switch (parseAs) {
|
|
497
|
+
case "arrayBuffer":
|
|
498
|
+
case "blob":
|
|
499
|
+
case "text":
|
|
500
|
+
emptyData = await response[parseAs]();
|
|
501
|
+
break;
|
|
502
|
+
case "formData":
|
|
503
|
+
emptyData = new FormData();
|
|
504
|
+
break;
|
|
505
|
+
case "stream":
|
|
506
|
+
emptyData = response.body;
|
|
507
|
+
break;
|
|
508
|
+
default:
|
|
509
|
+
emptyData = {};
|
|
510
|
+
break;
|
|
511
|
+
}
|
|
512
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
513
|
+
data: emptyData,
|
|
514
|
+
...result
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
let data;
|
|
518
|
+
switch (parseAs) {
|
|
519
|
+
case "arrayBuffer":
|
|
520
|
+
case "blob":
|
|
521
|
+
case "formData":
|
|
522
|
+
case "json":
|
|
523
|
+
case "text":
|
|
524
|
+
data = await response[parseAs]();
|
|
525
|
+
break;
|
|
526
|
+
case "stream": return opts.responseStyle === "data" ? response.body : {
|
|
527
|
+
data: response.body,
|
|
528
|
+
...result
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
if (parseAs === "json") {
|
|
532
|
+
if (opts.responseValidator) await opts.responseValidator(data);
|
|
533
|
+
if (opts.responseTransformer) data = await opts.responseTransformer(data);
|
|
534
|
+
}
|
|
535
|
+
return opts.responseStyle === "data" ? data : {
|
|
536
|
+
data,
|
|
537
|
+
...result
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
const textError = await response.text();
|
|
541
|
+
let jsonError;
|
|
542
|
+
try {
|
|
543
|
+
jsonError = JSON.parse(textError);
|
|
544
|
+
} catch {}
|
|
545
|
+
const error = jsonError ?? textError;
|
|
546
|
+
let finalError = error;
|
|
547
|
+
for (const fn of interceptors.error._fns) if (fn) finalError = await fn(error, response, request, opts);
|
|
548
|
+
finalError = finalError || {};
|
|
549
|
+
if (opts.throwOnError) throw finalError;
|
|
550
|
+
return opts.responseStyle === "data" ? void 0 : {
|
|
551
|
+
error: finalError,
|
|
552
|
+
...result
|
|
553
|
+
};
|
|
554
|
+
};
|
|
555
|
+
const makeMethodFn = (method) => (options) => request({
|
|
556
|
+
...options,
|
|
557
|
+
method
|
|
558
|
+
});
|
|
559
|
+
const makeSseFn = (method) => async (options) => {
|
|
560
|
+
const { opts, url } = await beforeRequest(options);
|
|
561
|
+
return createSseClient({
|
|
562
|
+
...opts,
|
|
563
|
+
body: opts.body,
|
|
564
|
+
headers: opts.headers,
|
|
565
|
+
method,
|
|
566
|
+
onRequest: async (url, init) => {
|
|
567
|
+
let request = new Request(url, init);
|
|
568
|
+
for (const fn of interceptors.request._fns) if (fn) request = await fn(request, opts);
|
|
569
|
+
return request;
|
|
570
|
+
},
|
|
571
|
+
url
|
|
572
|
+
});
|
|
573
|
+
};
|
|
574
|
+
return {
|
|
575
|
+
buildUrl,
|
|
576
|
+
connect: makeMethodFn("CONNECT"),
|
|
577
|
+
delete: makeMethodFn("DELETE"),
|
|
578
|
+
get: makeMethodFn("GET"),
|
|
579
|
+
getConfig,
|
|
580
|
+
head: makeMethodFn("HEAD"),
|
|
581
|
+
interceptors,
|
|
582
|
+
options: makeMethodFn("OPTIONS"),
|
|
583
|
+
patch: makeMethodFn("PATCH"),
|
|
584
|
+
post: makeMethodFn("POST"),
|
|
585
|
+
put: makeMethodFn("PUT"),
|
|
586
|
+
request,
|
|
587
|
+
setConfig,
|
|
588
|
+
sse: {
|
|
589
|
+
connect: makeSseFn("CONNECT"),
|
|
590
|
+
delete: makeSseFn("DELETE"),
|
|
591
|
+
get: makeSseFn("GET"),
|
|
592
|
+
head: makeSseFn("HEAD"),
|
|
593
|
+
options: makeSseFn("OPTIONS"),
|
|
594
|
+
patch: makeSseFn("PATCH"),
|
|
595
|
+
post: makeSseFn("POST"),
|
|
596
|
+
put: makeSseFn("PUT"),
|
|
597
|
+
trace: makeSseFn("TRACE")
|
|
598
|
+
},
|
|
599
|
+
trace: makeMethodFn("TRACE")
|
|
600
|
+
};
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
//#endregion
|
|
604
|
+
//#region src/apiv2/client.gen.ts
|
|
605
|
+
const client = createClient(createConfig());
|
|
606
|
+
|
|
607
|
+
//#endregion
|
|
608
|
+
//#region src/apiv2/sdk.gen.ts
|
|
609
|
+
var sdk_gen_exports = /* @__PURE__ */ __exportAll({
|
|
610
|
+
deleteServersBySlug: () => deleteServersBySlug,
|
|
611
|
+
getServers: () => getServers,
|
|
612
|
+
getServersBySlug: () => getServersBySlug,
|
|
613
|
+
patchServersBySlug: () => patchServersBySlug,
|
|
614
|
+
postServers: () => postServers,
|
|
615
|
+
putServersBySlug: () => putServersBySlug
|
|
616
|
+
});
|
|
617
|
+
/**
|
|
618
|
+
* List all MCP servers the caller has access to.
|
|
619
|
+
*/
|
|
620
|
+
const getServers = (options) => {
|
|
621
|
+
return (options?.client ?? client).get({
|
|
622
|
+
security: [{
|
|
623
|
+
scheme: "bearer",
|
|
624
|
+
type: "http"
|
|
625
|
+
}, {
|
|
626
|
+
scheme: "bearer",
|
|
627
|
+
type: "http"
|
|
628
|
+
}],
|
|
629
|
+
url: "/servers",
|
|
630
|
+
...options
|
|
631
|
+
});
|
|
632
|
+
};
|
|
633
|
+
/**
|
|
634
|
+
* Create a new MCP server. Requires `slug` and `transportConfig`. All other fields are optional with sensible defaults. Read-only fields are silently ignored.
|
|
635
|
+
*/
|
|
636
|
+
const postServers = (options) => {
|
|
637
|
+
return (options?.client ?? client).post({
|
|
638
|
+
security: [{
|
|
639
|
+
scheme: "bearer",
|
|
640
|
+
type: "http"
|
|
641
|
+
}, {
|
|
642
|
+
scheme: "bearer",
|
|
643
|
+
type: "http"
|
|
644
|
+
}],
|
|
645
|
+
url: "/servers",
|
|
646
|
+
...options,
|
|
647
|
+
headers: {
|
|
648
|
+
"Content-Type": "application/json",
|
|
649
|
+
...options?.headers
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
};
|
|
653
|
+
/**
|
|
654
|
+
* Delete an MCP server.
|
|
655
|
+
*/
|
|
656
|
+
const deleteServersBySlug = (options) => {
|
|
657
|
+
return (options.client ?? client).delete({
|
|
658
|
+
security: [{
|
|
659
|
+
scheme: "bearer",
|
|
660
|
+
type: "http"
|
|
661
|
+
}, {
|
|
662
|
+
scheme: "bearer",
|
|
663
|
+
type: "http"
|
|
664
|
+
}],
|
|
665
|
+
url: "/servers/{slug}",
|
|
666
|
+
...options
|
|
667
|
+
});
|
|
668
|
+
};
|
|
669
|
+
/**
|
|
670
|
+
* Get a single MCP server. The response body can be PUT back to update the server.
|
|
671
|
+
*/
|
|
672
|
+
const getServersBySlug = (options) => {
|
|
673
|
+
return (options.client ?? client).get({
|
|
674
|
+
security: [{
|
|
675
|
+
scheme: "bearer",
|
|
676
|
+
type: "http"
|
|
677
|
+
}, {
|
|
678
|
+
scheme: "bearer",
|
|
679
|
+
type: "http"
|
|
680
|
+
}],
|
|
681
|
+
url: "/servers/{slug}",
|
|
682
|
+
...options
|
|
683
|
+
});
|
|
684
|
+
};
|
|
685
|
+
/**
|
|
686
|
+
* Partially update an MCP server using JSON Merge Patch (RFC 7396). Send only the fields to change. Explicit `null` clears nullable fields (logoUrl, oauthMetadata, oauthClientConfiguration). Absent fields are untouched. Read-only fields are silently ignored.
|
|
687
|
+
*/
|
|
688
|
+
const patchServersBySlug = (options) => {
|
|
689
|
+
return (options.client ?? client).patch({
|
|
690
|
+
security: [{
|
|
691
|
+
scheme: "bearer",
|
|
692
|
+
type: "http"
|
|
693
|
+
}, {
|
|
694
|
+
scheme: "bearer",
|
|
695
|
+
type: "http"
|
|
696
|
+
}],
|
|
697
|
+
url: "/servers/{slug}",
|
|
698
|
+
...options,
|
|
699
|
+
headers: {
|
|
700
|
+
"Content-Type": "application/json",
|
|
701
|
+
...options.headers
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
};
|
|
705
|
+
/**
|
|
706
|
+
* Update an MCP server. Accepts the full server object from GET; read-only fields (id, tenantId, createdAt, updatedAt, lastToolRefreshAt) are silently ignored. Supports updating isEnabled, authorization, and config in a single call.
|
|
707
|
+
*/
|
|
708
|
+
const putServersBySlug = (options) => {
|
|
709
|
+
return (options.client ?? client).put({
|
|
710
|
+
security: [{
|
|
711
|
+
scheme: "bearer",
|
|
712
|
+
type: "http"
|
|
713
|
+
}, {
|
|
714
|
+
scheme: "bearer",
|
|
715
|
+
type: "http"
|
|
716
|
+
}],
|
|
717
|
+
url: "/servers/{slug}",
|
|
718
|
+
...options,
|
|
719
|
+
headers: {
|
|
720
|
+
"Content-Type": "application/json",
|
|
721
|
+
...options.headers
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
//#endregion
|
|
727
|
+
export { postServers as a, client as c, patchServersBySlug as i, getServers as n, putServersBySlug as o, getServersBySlug as r, sdk_gen_exports as s, deleteServersBySlug as t };
|
|
728
|
+
//# sourceMappingURL=sdk.gen-DH-7_dug.mjs.map
|