@wazootech/worlds-client 0.0.0-stage → 0.8.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/LICENSE +21 -0
- package/README.md +143 -2
- package/THIRD_PARTY_NOTICES.md +33 -0
- package/dist/index.d.ts +2045 -0
- package/dist/index.js +1016 -0
- package/openapi/openapi.json +3658 -0
- package/package.json +60 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,1016 @@
|
|
|
1
|
+
// src/generated/core/bodySerializer.gen.ts
|
|
2
|
+
const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
|
|
3
|
+
Object.entries({
|
|
4
|
+
$body_: "body",
|
|
5
|
+
$headers_: "headers",
|
|
6
|
+
$path_: "path",
|
|
7
|
+
$query_: "query"
|
|
8
|
+
});
|
|
9
|
+
// src/generated/core/serverSentEvents.gen.ts
|
|
10
|
+
function createSseClient({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) {
|
|
11
|
+
let lastEventId;
|
|
12
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
13
|
+
const createStream = async function* () {
|
|
14
|
+
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
15
|
+
let attempt = 0;
|
|
16
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
17
|
+
while (true) {
|
|
18
|
+
if (signal.aborted) break;
|
|
19
|
+
attempt++;
|
|
20
|
+
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
21
|
+
if (lastEventId !== void 0) headers.set("Last-Event-ID", lastEventId);
|
|
22
|
+
try {
|
|
23
|
+
const requestInit = {
|
|
24
|
+
redirect: "follow",
|
|
25
|
+
...options,
|
|
26
|
+
body: options.serializedBody,
|
|
27
|
+
headers,
|
|
28
|
+
signal
|
|
29
|
+
};
|
|
30
|
+
let request = new Request(url, requestInit);
|
|
31
|
+
if (onRequest) request = await onRequest(url, requestInit);
|
|
32
|
+
const response = await (options.fetch ?? globalThis.fetch)(request);
|
|
33
|
+
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
34
|
+
if (!response.body) throw new Error("No body in SSE response");
|
|
35
|
+
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
36
|
+
let buffer = "";
|
|
37
|
+
const abortHandler = () => {
|
|
38
|
+
try {
|
|
39
|
+
reader.cancel();
|
|
40
|
+
} catch {}
|
|
41
|
+
};
|
|
42
|
+
signal.addEventListener("abort", abortHandler);
|
|
43
|
+
try {
|
|
44
|
+
while (true) {
|
|
45
|
+
const { done, value } = await reader.read();
|
|
46
|
+
if (done) break;
|
|
47
|
+
buffer += value;
|
|
48
|
+
buffer = buffer.replace(/\r\n?/g, "\n");
|
|
49
|
+
const chunks = buffer.split("\n\n");
|
|
50
|
+
buffer = chunks.pop() ?? "";
|
|
51
|
+
for (const chunk of chunks) {
|
|
52
|
+
const lines = chunk.split("\n");
|
|
53
|
+
const dataLines = [];
|
|
54
|
+
let eventName;
|
|
55
|
+
for (const line of lines) if (line.startsWith("data:")) dataLines.push(line.replace(/^data:\s*/, ""));
|
|
56
|
+
else if (line.startsWith("event:")) eventName = line.replace(/^event:\s*/, "");
|
|
57
|
+
else if (line.startsWith("id:")) lastEventId = line.replace(/^id:\s*/, "");
|
|
58
|
+
else if (line.startsWith("retry:")) {
|
|
59
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
60
|
+
if (!Number.isNaN(parsed)) retryDelay = parsed;
|
|
61
|
+
}
|
|
62
|
+
let data;
|
|
63
|
+
let parsedJson = false;
|
|
64
|
+
if (dataLines.length) {
|
|
65
|
+
const rawData = dataLines.join("\n");
|
|
66
|
+
try {
|
|
67
|
+
data = JSON.parse(rawData);
|
|
68
|
+
parsedJson = true;
|
|
69
|
+
} catch {
|
|
70
|
+
data = rawData;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (parsedJson) {
|
|
74
|
+
if (responseValidator) await responseValidator(data);
|
|
75
|
+
if (responseTransformer) data = await responseTransformer(data);
|
|
76
|
+
}
|
|
77
|
+
onSseEvent?.({
|
|
78
|
+
data,
|
|
79
|
+
event: eventName,
|
|
80
|
+
id: lastEventId,
|
|
81
|
+
retry: retryDelay
|
|
82
|
+
});
|
|
83
|
+
if (dataLines.length) yield data;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
} finally {
|
|
87
|
+
signal.removeEventListener("abort", abortHandler);
|
|
88
|
+
reader.releaseLock();
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
} catch (error) {
|
|
92
|
+
onSseError?.(error);
|
|
93
|
+
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) break;
|
|
94
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
95
|
+
await sleep(backoff);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
return { stream: createStream() };
|
|
100
|
+
}
|
|
101
|
+
// src/generated/core/pathSerializer.gen.ts
|
|
102
|
+
const separatorArrayExplode = (style) => {
|
|
103
|
+
switch (style) {
|
|
104
|
+
case "label": return ".";
|
|
105
|
+
case "matrix": return ";";
|
|
106
|
+
case "simple": return ",";
|
|
107
|
+
default: return "&";
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const separatorArrayNoExplode = (style) => {
|
|
111
|
+
switch (style) {
|
|
112
|
+
case "form": return ",";
|
|
113
|
+
case "pipeDelimited": return "|";
|
|
114
|
+
case "spaceDelimited": return "%20";
|
|
115
|
+
default: return ",";
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const separatorObjectExplode = (style) => {
|
|
119
|
+
switch (style) {
|
|
120
|
+
case "label": return ".";
|
|
121
|
+
case "matrix": return ";";
|
|
122
|
+
case "simple": return ",";
|
|
123
|
+
default: return "&";
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
|
|
127
|
+
if (!explode) {
|
|
128
|
+
const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
129
|
+
switch (style) {
|
|
130
|
+
case "label": return `.${joinedValues}`;
|
|
131
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
132
|
+
case "simple": return joinedValues;
|
|
133
|
+
default: return `${name}=${joinedValues}`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const separator = separatorArrayExplode(style);
|
|
137
|
+
const joinedValues = value.map((v) => {
|
|
138
|
+
if (style === "label" || style === "simple") return allowReserved ? v : encodeURIComponent(v);
|
|
139
|
+
return serializePrimitiveParam({
|
|
140
|
+
allowReserved,
|
|
141
|
+
name,
|
|
142
|
+
value: v
|
|
143
|
+
});
|
|
144
|
+
}).join(separator);
|
|
145
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
146
|
+
};
|
|
147
|
+
const serializePrimitiveParam = ({ allowReserved, name, value }) => {
|
|
148
|
+
if (value === void 0 || value === null) return "";
|
|
149
|
+
if (typeof value === "object") throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
|
|
150
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
151
|
+
};
|
|
152
|
+
const serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly }) => {
|
|
153
|
+
if (value instanceof Date) return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
154
|
+
if (style !== "deepObject" && !explode) {
|
|
155
|
+
let values = [];
|
|
156
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
157
|
+
values = [
|
|
158
|
+
...values,
|
|
159
|
+
key,
|
|
160
|
+
allowReserved ? v : encodeURIComponent(v)
|
|
161
|
+
];
|
|
162
|
+
});
|
|
163
|
+
const joinedValues = values.join(",");
|
|
164
|
+
switch (style) {
|
|
165
|
+
case "form": return `${name}=${joinedValues}`;
|
|
166
|
+
case "label": return `.${joinedValues}`;
|
|
167
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
168
|
+
default: return joinedValues;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const separator = separatorObjectExplode(style);
|
|
172
|
+
const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
|
|
173
|
+
allowReserved,
|
|
174
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
175
|
+
value: v
|
|
176
|
+
})).join(separator);
|
|
177
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
178
|
+
};
|
|
179
|
+
// src/generated/core/utils.gen.ts
|
|
180
|
+
const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
181
|
+
const defaultPathSerializer = ({ path, url: _url }) => {
|
|
182
|
+
let url = _url;
|
|
183
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
184
|
+
if (matches) for (const match of matches) {
|
|
185
|
+
let explode = false;
|
|
186
|
+
let name = match.substring(1, match.length - 1);
|
|
187
|
+
let style = "simple";
|
|
188
|
+
if (name.endsWith("*")) {
|
|
189
|
+
explode = true;
|
|
190
|
+
name = name.substring(0, name.length - 1);
|
|
191
|
+
}
|
|
192
|
+
if (name.startsWith(".")) {
|
|
193
|
+
name = name.substring(1);
|
|
194
|
+
style = "label";
|
|
195
|
+
} else if (name.startsWith(";")) {
|
|
196
|
+
name = name.substring(1);
|
|
197
|
+
style = "matrix";
|
|
198
|
+
}
|
|
199
|
+
const value = path[name];
|
|
200
|
+
if (value === void 0 || value === null) continue;
|
|
201
|
+
if (Array.isArray(value)) {
|
|
202
|
+
url = url.replace(match, serializeArrayParam({
|
|
203
|
+
explode,
|
|
204
|
+
name,
|
|
205
|
+
style,
|
|
206
|
+
value
|
|
207
|
+
}));
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (typeof value === "object") {
|
|
211
|
+
url = url.replace(match, serializeObjectParam({
|
|
212
|
+
explode,
|
|
213
|
+
name,
|
|
214
|
+
style,
|
|
215
|
+
value,
|
|
216
|
+
valueOnly: true
|
|
217
|
+
}));
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
if (style === "matrix") {
|
|
221
|
+
url = url.replace(match, `;${serializePrimitiveParam({
|
|
222
|
+
name,
|
|
223
|
+
value
|
|
224
|
+
})}`);
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
|
|
228
|
+
url = url.replace(match, replaceValue);
|
|
229
|
+
}
|
|
230
|
+
return url;
|
|
231
|
+
};
|
|
232
|
+
const getUrl = ({ baseUrl, path, query, querySerializer, url: _url }) => {
|
|
233
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
234
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
235
|
+
if (path) url = defaultPathSerializer({
|
|
236
|
+
path,
|
|
237
|
+
url
|
|
238
|
+
});
|
|
239
|
+
let search = query ? querySerializer(query) : "";
|
|
240
|
+
if (search.startsWith("?")) search = search.substring(1);
|
|
241
|
+
if (search) url += `?${search}`;
|
|
242
|
+
return url;
|
|
243
|
+
};
|
|
244
|
+
function getValidRequestBody(options) {
|
|
245
|
+
const hasBody = options.body !== void 0;
|
|
246
|
+
if (hasBody && options.bodySerializer) {
|
|
247
|
+
if ("serializedBody" in options) return options.serializedBody !== void 0 && options.serializedBody !== "" ? options.serializedBody : null;
|
|
248
|
+
return options.body !== "" ? options.body : null;
|
|
249
|
+
}
|
|
250
|
+
if (hasBody) return options.body;
|
|
251
|
+
}
|
|
252
|
+
// src/generated/core/auth.gen.ts
|
|
253
|
+
const getAuthToken = async (auth, callback) => {
|
|
254
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
255
|
+
if (!token) return;
|
|
256
|
+
if (auth.scheme === "bearer") return `Bearer ${token}`;
|
|
257
|
+
if (auth.scheme === "basic") return `Basic ${btoa(token)}`;
|
|
258
|
+
return token;
|
|
259
|
+
};
|
|
260
|
+
// src/generated/client/utils.gen.ts
|
|
261
|
+
const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
262
|
+
const querySerializer = (queryParams) => {
|
|
263
|
+
const search = [];
|
|
264
|
+
if (queryParams && typeof queryParams === "object") for (const name in queryParams) {
|
|
265
|
+
const value = queryParams[name];
|
|
266
|
+
if (value === void 0 || value === null) continue;
|
|
267
|
+
const options = parameters[name] || args;
|
|
268
|
+
if (Array.isArray(value)) {
|
|
269
|
+
const serializedArray = serializeArrayParam({
|
|
270
|
+
allowReserved: options.allowReserved,
|
|
271
|
+
explode: true,
|
|
272
|
+
name,
|
|
273
|
+
style: "form",
|
|
274
|
+
value,
|
|
275
|
+
...options.array
|
|
276
|
+
});
|
|
277
|
+
if (serializedArray) search.push(serializedArray);
|
|
278
|
+
} else if (typeof value === "object") {
|
|
279
|
+
const serializedObject = serializeObjectParam({
|
|
280
|
+
allowReserved: options.allowReserved,
|
|
281
|
+
explode: true,
|
|
282
|
+
name,
|
|
283
|
+
style: "deepObject",
|
|
284
|
+
value,
|
|
285
|
+
...options.object
|
|
286
|
+
});
|
|
287
|
+
if (serializedObject) search.push(serializedObject);
|
|
288
|
+
} else {
|
|
289
|
+
const serializedPrimitive = serializePrimitiveParam({
|
|
290
|
+
allowReserved: options.allowReserved,
|
|
291
|
+
name,
|
|
292
|
+
value
|
|
293
|
+
});
|
|
294
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return search.join("&");
|
|
298
|
+
};
|
|
299
|
+
return querySerializer;
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* Infers parseAs value from provided Content-Type header.
|
|
303
|
+
*/
|
|
304
|
+
const getParseAs = (contentType) => {
|
|
305
|
+
if (!contentType) return "stream";
|
|
306
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
307
|
+
if (!cleanContent) return;
|
|
308
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) return "json";
|
|
309
|
+
if (cleanContent === "multipart/form-data") return "formData";
|
|
310
|
+
if ([
|
|
311
|
+
"application/",
|
|
312
|
+
"audio/",
|
|
313
|
+
"image/",
|
|
314
|
+
"video/"
|
|
315
|
+
].some((type) => cleanContent.startsWith(type))) return "blob";
|
|
316
|
+
if (cleanContent.startsWith("text/")) return "text";
|
|
317
|
+
};
|
|
318
|
+
const checkForExistence = (options, name) => {
|
|
319
|
+
if (!name) return false;
|
|
320
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) return true;
|
|
321
|
+
return false;
|
|
322
|
+
};
|
|
323
|
+
async function setAuthParams(options) {
|
|
324
|
+
for (const auth of options.security ?? []) {
|
|
325
|
+
if (checkForExistence(options, auth.name)) continue;
|
|
326
|
+
const token = await getAuthToken(auth, options.auth);
|
|
327
|
+
if (!token) continue;
|
|
328
|
+
const name = auth.name ?? "Authorization";
|
|
329
|
+
switch (auth.in) {
|
|
330
|
+
case "query":
|
|
331
|
+
if (!options.query) options.query = {};
|
|
332
|
+
options.query[name] = token;
|
|
333
|
+
break;
|
|
334
|
+
case "cookie":
|
|
335
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
336
|
+
break;
|
|
337
|
+
default: options.headers.set(name, token);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
const buildUrl = (options) => getUrl({
|
|
342
|
+
baseUrl: options.baseUrl,
|
|
343
|
+
path: options.path,
|
|
344
|
+
query: options.query,
|
|
345
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
346
|
+
url: options.url
|
|
347
|
+
});
|
|
348
|
+
const mergeConfigs = (a, b) => {
|
|
349
|
+
const config = {
|
|
350
|
+
...a,
|
|
351
|
+
...b
|
|
352
|
+
};
|
|
353
|
+
if (config.baseUrl?.endsWith("/")) config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
354
|
+
config.headers = mergeHeaders(a.headers, b.headers);
|
|
355
|
+
return config;
|
|
356
|
+
};
|
|
357
|
+
const headersEntries = (headers) => {
|
|
358
|
+
const entries = [];
|
|
359
|
+
headers.forEach((value, key) => {
|
|
360
|
+
entries.push([key, value]);
|
|
361
|
+
});
|
|
362
|
+
return entries;
|
|
363
|
+
};
|
|
364
|
+
const mergeHeaders = (...headers) => {
|
|
365
|
+
const mergedHeaders = new Headers();
|
|
366
|
+
for (const header of headers) {
|
|
367
|
+
if (!header) continue;
|
|
368
|
+
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
369
|
+
for (const [key, value] of iterator) if (value === null) mergedHeaders.delete(key);
|
|
370
|
+
else if (Array.isArray(value)) for (const v of value) mergedHeaders.append(key, v);
|
|
371
|
+
else if (value !== void 0) mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
372
|
+
}
|
|
373
|
+
return mergedHeaders;
|
|
374
|
+
};
|
|
375
|
+
var Interceptors = class {
|
|
376
|
+
fns = [];
|
|
377
|
+
clear() {
|
|
378
|
+
this.fns = [];
|
|
379
|
+
}
|
|
380
|
+
eject(id) {
|
|
381
|
+
const index = this.getInterceptorIndex(id);
|
|
382
|
+
if (this.fns[index]) this.fns[index] = null;
|
|
383
|
+
}
|
|
384
|
+
exists(id) {
|
|
385
|
+
const index = this.getInterceptorIndex(id);
|
|
386
|
+
return Boolean(this.fns[index]);
|
|
387
|
+
}
|
|
388
|
+
getInterceptorIndex(id) {
|
|
389
|
+
if (typeof id === "number") return this.fns[id] ? id : -1;
|
|
390
|
+
return this.fns.indexOf(id);
|
|
391
|
+
}
|
|
392
|
+
update(id, fn) {
|
|
393
|
+
const index = this.getInterceptorIndex(id);
|
|
394
|
+
if (this.fns[index]) {
|
|
395
|
+
this.fns[index] = fn;
|
|
396
|
+
return id;
|
|
397
|
+
}
|
|
398
|
+
return false;
|
|
399
|
+
}
|
|
400
|
+
use(fn) {
|
|
401
|
+
this.fns.push(fn);
|
|
402
|
+
return this.fns.length - 1;
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
const createInterceptors = () => ({
|
|
406
|
+
error: new Interceptors(),
|
|
407
|
+
request: new Interceptors(),
|
|
408
|
+
response: new Interceptors()
|
|
409
|
+
});
|
|
410
|
+
const defaultQuerySerializer = createQuerySerializer({
|
|
411
|
+
allowReserved: false,
|
|
412
|
+
array: {
|
|
413
|
+
explode: true,
|
|
414
|
+
style: "form"
|
|
415
|
+
},
|
|
416
|
+
object: {
|
|
417
|
+
explode: true,
|
|
418
|
+
style: "deepObject"
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
const defaultHeaders = { "Content-Type": "application/json" };
|
|
422
|
+
const createConfig = (override = {}) => ({
|
|
423
|
+
...jsonBodySerializer,
|
|
424
|
+
headers: defaultHeaders,
|
|
425
|
+
parseAs: "auto",
|
|
426
|
+
querySerializer: defaultQuerySerializer,
|
|
427
|
+
...override
|
|
428
|
+
});
|
|
429
|
+
// src/generated/client/client.gen.ts
|
|
430
|
+
const createClient = (config = {}) => {
|
|
431
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
432
|
+
const getConfig = () => ({ ..._config });
|
|
433
|
+
const setConfig = (config) => {
|
|
434
|
+
_config = mergeConfigs(_config, config);
|
|
435
|
+
return getConfig();
|
|
436
|
+
};
|
|
437
|
+
const interceptors = createInterceptors();
|
|
438
|
+
const beforeRequest = async (options) => {
|
|
439
|
+
const opts = {
|
|
440
|
+
..._config,
|
|
441
|
+
...options,
|
|
442
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
443
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
444
|
+
serializedBody: void 0
|
|
445
|
+
};
|
|
446
|
+
if (opts.security) await setAuthParams(opts);
|
|
447
|
+
if (opts.requestValidator) await opts.requestValidator(opts);
|
|
448
|
+
if (opts.body !== void 0 && opts.bodySerializer) opts.serializedBody = opts.bodySerializer(opts.body);
|
|
449
|
+
if (opts.body === void 0 || opts.serializedBody === "") opts.headers.delete("Content-Type");
|
|
450
|
+
const resolvedOpts = opts;
|
|
451
|
+
return {
|
|
452
|
+
opts: resolvedOpts,
|
|
453
|
+
url: buildUrl(resolvedOpts)
|
|
454
|
+
};
|
|
455
|
+
};
|
|
456
|
+
const request = async (options) => {
|
|
457
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
458
|
+
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
459
|
+
let request;
|
|
460
|
+
let response;
|
|
461
|
+
try {
|
|
462
|
+
const { opts, url } = await beforeRequest(options);
|
|
463
|
+
const requestInit = {
|
|
464
|
+
redirect: "follow",
|
|
465
|
+
...opts,
|
|
466
|
+
body: getValidRequestBody(opts)
|
|
467
|
+
};
|
|
468
|
+
request = new Request(url, requestInit);
|
|
469
|
+
for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
|
|
470
|
+
response = await (0, opts.fetch)(request);
|
|
471
|
+
for (const fn of interceptors.response.fns) if (fn) response = await fn(response, request, opts);
|
|
472
|
+
const result = {
|
|
473
|
+
request,
|
|
474
|
+
response
|
|
475
|
+
};
|
|
476
|
+
if (response.ok) {
|
|
477
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
478
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
479
|
+
let emptyData;
|
|
480
|
+
switch (parseAs) {
|
|
481
|
+
case "arrayBuffer":
|
|
482
|
+
case "blob":
|
|
483
|
+
case "text":
|
|
484
|
+
emptyData = await response[parseAs]();
|
|
485
|
+
break;
|
|
486
|
+
case "formData":
|
|
487
|
+
emptyData = new FormData();
|
|
488
|
+
break;
|
|
489
|
+
case "stream":
|
|
490
|
+
emptyData = response.body;
|
|
491
|
+
break;
|
|
492
|
+
default: emptyData = {};
|
|
493
|
+
}
|
|
494
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
495
|
+
data: emptyData,
|
|
496
|
+
...result
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
let data;
|
|
500
|
+
switch (parseAs) {
|
|
501
|
+
case "arrayBuffer":
|
|
502
|
+
case "blob":
|
|
503
|
+
case "formData":
|
|
504
|
+
case "text":
|
|
505
|
+
data = await response[parseAs]();
|
|
506
|
+
break;
|
|
507
|
+
case "json": {
|
|
508
|
+
const text = await response.text();
|
|
509
|
+
data = text ? JSON.parse(text) : {};
|
|
510
|
+
break;
|
|
511
|
+
}
|
|
512
|
+
case "stream": return opts.responseStyle === "data" ? response.body : {
|
|
513
|
+
data: response.body,
|
|
514
|
+
...result
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
if (parseAs === "json") {
|
|
518
|
+
if (opts.responseValidator) await opts.responseValidator(data);
|
|
519
|
+
if (opts.responseTransformer) data = await opts.responseTransformer(data);
|
|
520
|
+
}
|
|
521
|
+
return opts.responseStyle === "data" ? data : {
|
|
522
|
+
data,
|
|
523
|
+
...result
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
const textError = await response.text();
|
|
527
|
+
let jsonError;
|
|
528
|
+
try {
|
|
529
|
+
jsonError = JSON.parse(textError);
|
|
530
|
+
} catch {}
|
|
531
|
+
throw jsonError ?? textError;
|
|
532
|
+
} catch (error) {
|
|
533
|
+
let finalError = error;
|
|
534
|
+
for (const fn of interceptors.error.fns) if (fn) finalError = await fn(finalError, response, request, options);
|
|
535
|
+
finalError = finalError || {};
|
|
536
|
+
if (throwOnError) throw finalError;
|
|
537
|
+
return responseStyle === "data" ? void 0 : {
|
|
538
|
+
error: finalError,
|
|
539
|
+
request,
|
|
540
|
+
response
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
const makeMethodFn = (method) => (options) => request({
|
|
545
|
+
...options,
|
|
546
|
+
method
|
|
547
|
+
});
|
|
548
|
+
const makeSseFn = (method) => async (options) => {
|
|
549
|
+
const { opts, url } = await beforeRequest(options);
|
|
550
|
+
return createSseClient({
|
|
551
|
+
...opts,
|
|
552
|
+
body: opts.body,
|
|
553
|
+
method,
|
|
554
|
+
onRequest: async (url, init) => {
|
|
555
|
+
let request = new Request(url, init);
|
|
556
|
+
for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
|
|
557
|
+
return request;
|
|
558
|
+
},
|
|
559
|
+
serializedBody: getValidRequestBody(opts),
|
|
560
|
+
url
|
|
561
|
+
});
|
|
562
|
+
};
|
|
563
|
+
const _buildUrl = (options) => buildUrl({
|
|
564
|
+
..._config,
|
|
565
|
+
...options
|
|
566
|
+
});
|
|
567
|
+
return {
|
|
568
|
+
buildUrl: _buildUrl,
|
|
569
|
+
connect: makeMethodFn("CONNECT"),
|
|
570
|
+
delete: makeMethodFn("DELETE"),
|
|
571
|
+
get: makeMethodFn("GET"),
|
|
572
|
+
getConfig,
|
|
573
|
+
head: makeMethodFn("HEAD"),
|
|
574
|
+
interceptors,
|
|
575
|
+
options: makeMethodFn("OPTIONS"),
|
|
576
|
+
patch: makeMethodFn("PATCH"),
|
|
577
|
+
post: makeMethodFn("POST"),
|
|
578
|
+
put: makeMethodFn("PUT"),
|
|
579
|
+
request,
|
|
580
|
+
setConfig,
|
|
581
|
+
sse: {
|
|
582
|
+
connect: makeSseFn("CONNECT"),
|
|
583
|
+
delete: makeSseFn("DELETE"),
|
|
584
|
+
get: makeSseFn("GET"),
|
|
585
|
+
head: makeSseFn("HEAD"),
|
|
586
|
+
options: makeSseFn("OPTIONS"),
|
|
587
|
+
patch: makeSseFn("PATCH"),
|
|
588
|
+
post: makeSseFn("POST"),
|
|
589
|
+
put: makeSseFn("PUT"),
|
|
590
|
+
trace: makeSseFn("TRACE")
|
|
591
|
+
},
|
|
592
|
+
trace: makeMethodFn("TRACE")
|
|
593
|
+
};
|
|
594
|
+
};
|
|
595
|
+
// src/generated/client.gen.ts
|
|
596
|
+
const client = createClient(createConfig({ baseUrl: "https://data.wazoo.dev" }));
|
|
597
|
+
// src/generated/sdk.gen.ts
|
|
598
|
+
/**
|
|
599
|
+
* Get health
|
|
600
|
+
*
|
|
601
|
+
* Liveness probe. Returns 200 when the service can reach its database; 503 when the database is unreachable.
|
|
602
|
+
*/
|
|
603
|
+
const getHealth = (options) => (options?.client ?? client).get({
|
|
604
|
+
url: "/health",
|
|
605
|
+
...options
|
|
606
|
+
});
|
|
607
|
+
/**
|
|
608
|
+
* Get readiness
|
|
609
|
+
*
|
|
610
|
+
* Readiness probe. Returns 200 only when D1 is reachable and its control-plane schema matches this service.
|
|
611
|
+
*/
|
|
612
|
+
const getReadiness = (options) => (options?.client ?? client).get({
|
|
613
|
+
url: "/ready",
|
|
614
|
+
...options
|
|
615
|
+
});
|
|
616
|
+
/**
|
|
617
|
+
* List worlds
|
|
618
|
+
*
|
|
619
|
+
* List all worlds accessible to the authenticated token. Admin tokens see all worlds; namespace-scoped tokens see only their namespace's worlds.
|
|
620
|
+
*/
|
|
621
|
+
const listWorlds = (options) => (options?.client ?? client).get({
|
|
622
|
+
security: [{
|
|
623
|
+
scheme: "bearer",
|
|
624
|
+
type: "http"
|
|
625
|
+
}],
|
|
626
|
+
url: "/worlds",
|
|
627
|
+
...options
|
|
628
|
+
});
|
|
629
|
+
/**
|
|
630
|
+
* Create world
|
|
631
|
+
*
|
|
632
|
+
* Create a new World metadata record in the shared D1 database. Worlds API mints its ID as w_<ULID>; callers cannot choose the ID or a slug.
|
|
633
|
+
*/
|
|
634
|
+
const createWorld = (options) => (options.client ?? client).post({
|
|
635
|
+
security: [{
|
|
636
|
+
scheme: "bearer",
|
|
637
|
+
type: "http"
|
|
638
|
+
}],
|
|
639
|
+
url: "/worlds",
|
|
640
|
+
...options,
|
|
641
|
+
headers: {
|
|
642
|
+
"Content-Type": "application/json",
|
|
643
|
+
...options.headers
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
/**
|
|
647
|
+
* Delete world
|
|
648
|
+
*
|
|
649
|
+
* Soft-delete a world. The world enters a 30-day grace period during which it can be restored via undelete. After the grace period, the world is permanently purged.
|
|
650
|
+
*/
|
|
651
|
+
const deleteWorld = (options) => (options.client ?? client).delete({
|
|
652
|
+
security: [{
|
|
653
|
+
scheme: "bearer",
|
|
654
|
+
type: "http"
|
|
655
|
+
}],
|
|
656
|
+
url: "/worlds/{worldId}",
|
|
657
|
+
...options
|
|
658
|
+
});
|
|
659
|
+
/**
|
|
660
|
+
* Get world
|
|
661
|
+
*
|
|
662
|
+
* Retrieve a single world by its unique identifier. Returns the full WorldResource including state, storage backend (deprecated), and search configuration.
|
|
663
|
+
*/
|
|
664
|
+
const getWorld = (options) => (options.client ?? client).get({
|
|
665
|
+
security: [{
|
|
666
|
+
scheme: "bearer",
|
|
667
|
+
type: "http"
|
|
668
|
+
}],
|
|
669
|
+
url: "/worlds/{worldId}",
|
|
670
|
+
...options
|
|
671
|
+
});
|
|
672
|
+
/**
|
|
673
|
+
* Update world
|
|
674
|
+
*
|
|
675
|
+
* Update a world's display name, embedding model, or search configuration. Changing the embedding model marks the world stale (embeddingStatus stale): search runs keyword-only until POST /worlds/{worldId}/reindex is called. It does not reindex automatically, because reindexing spends the namespace's embedding budget. Setting a model requires an active embedding credential for the namespace.
|
|
676
|
+
*/
|
|
677
|
+
const updateWorld = (options) => (options.client ?? client).patch({
|
|
678
|
+
security: [{
|
|
679
|
+
scheme: "bearer",
|
|
680
|
+
type: "http"
|
|
681
|
+
}],
|
|
682
|
+
url: "/worlds/{worldId}",
|
|
683
|
+
...options,
|
|
684
|
+
headers: {
|
|
685
|
+
"Content-Type": "application/json",
|
|
686
|
+
...options.headers
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
/**
|
|
690
|
+
* Undelete world
|
|
691
|
+
*
|
|
692
|
+
* Restore a soft-deleted world within its 30-day grace period. Returns the restored WorldResource. Fails if the grace period has expired.
|
|
693
|
+
*/
|
|
694
|
+
const undeleteWorld = (options) => (options.client ?? client).post({
|
|
695
|
+
security: [{
|
|
696
|
+
scheme: "bearer",
|
|
697
|
+
type: "http"
|
|
698
|
+
}],
|
|
699
|
+
url: "/worlds/{worldId}/undelete",
|
|
700
|
+
...options
|
|
701
|
+
});
|
|
702
|
+
/**
|
|
703
|
+
* Suspend world
|
|
704
|
+
*
|
|
705
|
+
* Suspend a world, temporarily blocking all read and write operations. The world can be resumed later without data loss.
|
|
706
|
+
*/
|
|
707
|
+
const suspendWorld = (options) => (options.client ?? client).post({
|
|
708
|
+
security: [{
|
|
709
|
+
scheme: "bearer",
|
|
710
|
+
type: "http"
|
|
711
|
+
}],
|
|
712
|
+
url: "/worlds/{worldId}/suspend",
|
|
713
|
+
...options
|
|
714
|
+
});
|
|
715
|
+
/**
|
|
716
|
+
* Resume world
|
|
717
|
+
*
|
|
718
|
+
* Resume a suspended world, restoring full read and write access.
|
|
719
|
+
*/
|
|
720
|
+
const resumeWorld = (options) => (options.client ?? client).post({
|
|
721
|
+
security: [{
|
|
722
|
+
scheme: "bearer",
|
|
723
|
+
type: "http"
|
|
724
|
+
}],
|
|
725
|
+
url: "/worlds/{worldId}/resume",
|
|
726
|
+
...options
|
|
727
|
+
});
|
|
728
|
+
/**
|
|
729
|
+
* Mark all worlds for a namespace deleted (account deletion)
|
|
730
|
+
*
|
|
731
|
+
* Admin-only. Soft-deletes all worlds in a namespace and revokes all API keys for that namespace. Used for account deletion workflows.
|
|
732
|
+
*/
|
|
733
|
+
const deleteNamespaceWorlds = (options) => (options.client ?? client).post({
|
|
734
|
+
security: [{
|
|
735
|
+
scheme: "bearer",
|
|
736
|
+
type: "http"
|
|
737
|
+
}],
|
|
738
|
+
url: "/admin/namespaces/{namespace}/delete",
|
|
739
|
+
...options
|
|
740
|
+
});
|
|
741
|
+
/**
|
|
742
|
+
* Run purge sweep on demand
|
|
743
|
+
*
|
|
744
|
+
* Admin-only. Triggers the purge sweep to permanently delete all worlds whose 30-day grace period has expired. Normally runs on a schedule; this endpoint forces an immediate sweep.
|
|
745
|
+
*/
|
|
746
|
+
const purgeWorlds = (options) => (options?.client ?? client).post({
|
|
747
|
+
security: [{
|
|
748
|
+
scheme: "bearer",
|
|
749
|
+
type: "http"
|
|
750
|
+
}],
|
|
751
|
+
url: "/admin/purge",
|
|
752
|
+
...options
|
|
753
|
+
});
|
|
754
|
+
/**
|
|
755
|
+
* Import graph data
|
|
756
|
+
*
|
|
757
|
+
* Import RDF data into a world. Accepts Turtle (the default), TriG, N-Triples, N-Quads, or N3 payloads; application/json quad rows; or text/plain chunks. Quads are stored in the world's Cloudflare D1 database and indexed for vector search.
|
|
758
|
+
*/
|
|
759
|
+
const importWorld = (options) => (options.client ?? client).post({
|
|
760
|
+
security: [{
|
|
761
|
+
scheme: "bearer",
|
|
762
|
+
type: "http"
|
|
763
|
+
}],
|
|
764
|
+
url: "/worlds/{worldId}/import",
|
|
765
|
+
...options,
|
|
766
|
+
headers: {
|
|
767
|
+
"Content-Type": "application/json",
|
|
768
|
+
...options.headers
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
/**
|
|
772
|
+
* Export graph data
|
|
773
|
+
*
|
|
774
|
+
* Export RDF quads from a world. Supports JSON (RDF/JSON array), Turtle, TriG, and JSON-LD output formats. Use the limit and offset query parameters for pagination.
|
|
775
|
+
*/
|
|
776
|
+
const exportWorld = (options) => (options.client ?? client).get({
|
|
777
|
+
security: [{
|
|
778
|
+
scheme: "bearer",
|
|
779
|
+
type: "http"
|
|
780
|
+
}],
|
|
781
|
+
url: "/worlds/{worldId}/export",
|
|
782
|
+
...options
|
|
783
|
+
});
|
|
784
|
+
/**
|
|
785
|
+
* Search world
|
|
786
|
+
*
|
|
787
|
+
* Full-text and vector similarity search across a world's graph data. Returns ranked results with id, subject, predicate, content, score, and scoreType on the normalized 0–1 scale, plus the mode that actually ran. Falls back to LIKE-based search if the primary engine is unavailable.
|
|
788
|
+
*/
|
|
789
|
+
const searchWorld = (options) => (options.client ?? client).post({
|
|
790
|
+
security: [{
|
|
791
|
+
scheme: "bearer",
|
|
792
|
+
type: "http"
|
|
793
|
+
}],
|
|
794
|
+
url: "/worlds/{worldId}/search",
|
|
795
|
+
...options,
|
|
796
|
+
headers: {
|
|
797
|
+
"Content-Type": "application/json",
|
|
798
|
+
...options.headers
|
|
799
|
+
}
|
|
800
|
+
});
|
|
801
|
+
/**
|
|
802
|
+
* SPARQL without world
|
|
803
|
+
*
|
|
804
|
+
* Always returns 400. Use POST /worlds/{worldId}/sparql to execute a SPARQL query against a specific world.
|
|
805
|
+
*/
|
|
806
|
+
const sparqlNoWorld = (options) => (options?.client ?? client).post({
|
|
807
|
+
security: [{
|
|
808
|
+
scheme: "bearer",
|
|
809
|
+
type: "http"
|
|
810
|
+
}],
|
|
811
|
+
url: "/worlds/sparql",
|
|
812
|
+
...options
|
|
813
|
+
});
|
|
814
|
+
/**
|
|
815
|
+
* Execute SPARQL query
|
|
816
|
+
*
|
|
817
|
+
* Execute a SPARQL 1.1 query (SELECT, ASK, or UPDATE) against a world's RDF graph. SELECT and ASK require the data:read scope; SPARQL UPDATE (INSERT, DELETE, CLEAR, DROP, and the other update forms) requires data:write, and a key without it receives 403 before the update runs. An unparseable query returns 400 INVALID_ARGUMENT. SELECT results are limited by the server-configured maximum. Queries time out after the configured limit.
|
|
818
|
+
*/
|
|
819
|
+
const sparqlWorld = (options) => (options.client ?? client).post({
|
|
820
|
+
security: [{
|
|
821
|
+
scheme: "bearer",
|
|
822
|
+
type: "http"
|
|
823
|
+
}],
|
|
824
|
+
url: "/worlds/{worldId}/sparql",
|
|
825
|
+
...options,
|
|
826
|
+
headers: {
|
|
827
|
+
"Content-Type": "application/json",
|
|
828
|
+
...options.headers
|
|
829
|
+
}
|
|
830
|
+
});
|
|
831
|
+
/**
|
|
832
|
+
* List API keys
|
|
833
|
+
*
|
|
834
|
+
* List all active (non-revoked) API keys. Optionally filter by namespace. Admin-only.
|
|
835
|
+
*/
|
|
836
|
+
const listApiKeys = (options) => (options?.client ?? client).get({
|
|
837
|
+
security: [{
|
|
838
|
+
scheme: "bearer",
|
|
839
|
+
type: "http"
|
|
840
|
+
}],
|
|
841
|
+
url: "/api-keys",
|
|
842
|
+
...options
|
|
843
|
+
});
|
|
844
|
+
/**
|
|
845
|
+
* Create API key
|
|
846
|
+
*
|
|
847
|
+
* Create a new API key scoped to a namespace and optionally a single world. The token is returned once on creation and cannot be retrieved again.
|
|
848
|
+
*/
|
|
849
|
+
const createApiKey = (options) => (options.client ?? client).post({
|
|
850
|
+
security: [{
|
|
851
|
+
scheme: "bearer",
|
|
852
|
+
type: "http"
|
|
853
|
+
}],
|
|
854
|
+
url: "/api-keys",
|
|
855
|
+
...options,
|
|
856
|
+
headers: {
|
|
857
|
+
"Content-Type": "application/json",
|
|
858
|
+
...options.headers
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
/**
|
|
862
|
+
* Revoke API key
|
|
863
|
+
*
|
|
864
|
+
* Permanently revoke an API key. The key immediately loses all access. This action cannot be undone.
|
|
865
|
+
*/
|
|
866
|
+
const deleteApiKey = (options) => (options.client ?? client).delete({
|
|
867
|
+
security: [{
|
|
868
|
+
scheme: "bearer",
|
|
869
|
+
type: "http"
|
|
870
|
+
}],
|
|
871
|
+
url: "/api-keys/{keyId}",
|
|
872
|
+
...options
|
|
873
|
+
});
|
|
874
|
+
/**
|
|
875
|
+
* Reindex world vector & FTS indexes
|
|
876
|
+
*
|
|
877
|
+
* Rebuild the vector and full-text search indexes for a world from its stored RDF quads. Required after changing the embedding model (the world is stale and search is keyword-only until it completes) and useful to repair search quality. The full-text index is always rebuilt from D1; if any vector could not be embedded, written or cleaned up, status is completed_with_vector_errors and vectorSync says what failed. Rerunning reindex repairs it. If the embedding service fails outright (an outage, or vectors of the wrong length) the request fails with 502 EMBEDDING_FAILED instead: nothing is recorded as ready, a windowed pass keeps its cursor so calling again retries the same window, and the keyword index is unaffected. Embedding spend is checked against the namespace's daily write budget first; an exhausted budget returns 429 EMBEDDING_BUDGET_EXCEEDED. Worlds with more text than EMBEDDING_REINDEX_MAX_CHUNKS are reindexed in windows across several calls: each call embeds only the next window, so no chunk is embedded twice and the world becomes ready when the last window completes.
|
|
878
|
+
*/
|
|
879
|
+
const reindexWorld = (options) => (options.client ?? client).post({
|
|
880
|
+
security: [{
|
|
881
|
+
scheme: "bearer",
|
|
882
|
+
type: "http"
|
|
883
|
+
}],
|
|
884
|
+
url: "/worlds/{worldId}/reindex",
|
|
885
|
+
...options
|
|
886
|
+
});
|
|
887
|
+
/**
|
|
888
|
+
* Back-fill inference for a world's existing data
|
|
889
|
+
*
|
|
890
|
+
* Materializes OWL 2 RL inference for data a world already holds. Enabling inference on a world only reacts to later writes; call this once afterwards to cover what is stored. It reads the world's asserted quads, runs the reasoner once, clears the world's inferred quads and writes the closure. Asserted quads are never changed. It is idempotent and safe to repeat; a failure part way leaves some inferred quads, so call it again. The world must have inference enabled. A world larger than its maxAssertedQuads limit is refused before any write (422 INFERENCE_SIZE_GUARD).
|
|
891
|
+
*/
|
|
892
|
+
const backfillWorldInference = (options) => (options.client ?? client).post({
|
|
893
|
+
security: [{
|
|
894
|
+
scheme: "bearer",
|
|
895
|
+
type: "http"
|
|
896
|
+
}],
|
|
897
|
+
url: "/worlds/{worldId}/infer",
|
|
898
|
+
...options
|
|
899
|
+
});
|
|
900
|
+
/**
|
|
901
|
+
* Read provenance
|
|
902
|
+
*
|
|
903
|
+
* Returns when a subject's facts were written, by which API key, from what source, and which fact each one replaced. One row per event, newest first within a fact, so the first row of a fact is normally the write that made it current. If it is a remove, the fact was written again while provenance was off, or is now inferred. A fact with many events can fill the limit by itself; narrow by predicate to reach the others. Only facts the world holds now are returned, and earlier values are not kept: replacesFactId identifies the replaced fact but not what it said. Facts written before provenance was turned on, and inferred facts, come back without type, time or writer.
|
|
904
|
+
*/
|
|
905
|
+
const queryWorldProvenance = (options) => (options.client ?? client).post({
|
|
906
|
+
security: [{
|
|
907
|
+
scheme: "bearer",
|
|
908
|
+
type: "http"
|
|
909
|
+
}],
|
|
910
|
+
url: "/worlds/{worldId}/provenance",
|
|
911
|
+
...options,
|
|
912
|
+
headers: {
|
|
913
|
+
"Content-Type": "application/json",
|
|
914
|
+
...options.headers
|
|
915
|
+
}
|
|
916
|
+
});
|
|
917
|
+
/**
|
|
918
|
+
* Clear a namespace's daily write budget override
|
|
919
|
+
*
|
|
920
|
+
* Admin-only. Removes the namespace's override so it uses the deployment default again. Idempotent.
|
|
921
|
+
*/
|
|
922
|
+
const clearNamespaceWriteBudget = (options) => (options.client ?? client).delete({
|
|
923
|
+
security: [{
|
|
924
|
+
scheme: "bearer",
|
|
925
|
+
type: "http"
|
|
926
|
+
}],
|
|
927
|
+
url: "/admin/namespaces/{namespace}/write-budget",
|
|
928
|
+
...options
|
|
929
|
+
});
|
|
930
|
+
/**
|
|
931
|
+
* Get a namespace's daily write budget and today's usage
|
|
932
|
+
*
|
|
933
|
+
* Admin-only. Returns the budget that applies to the namespace (its override, else the deployment default) and the D1 rows it has written today. The platform reads this to show usage against a plan.
|
|
934
|
+
*/
|
|
935
|
+
const getNamespaceWriteBudget = (options) => (options.client ?? client).get({
|
|
936
|
+
security: [{
|
|
937
|
+
scheme: "bearer",
|
|
938
|
+
type: "http"
|
|
939
|
+
}],
|
|
940
|
+
url: "/admin/namespaces/{namespace}/write-budget",
|
|
941
|
+
...options
|
|
942
|
+
});
|
|
943
|
+
/**
|
|
944
|
+
* Set a namespace's daily write budget
|
|
945
|
+
*
|
|
946
|
+
* Admin-only. Sets how many D1 rows the namespace may write per UTC day, overriding the deployment default. Writes (SPARQL updates, import, inference back-fill) are refused with 429 WRITE_BUDGET_EXCEEDED once the namespace has used it; reads are never refused. Used by the platform to apply a customer's plan. Takes effect within about 30 seconds across the fleet.
|
|
947
|
+
*/
|
|
948
|
+
const setNamespaceWriteBudget = (options) => (options.client ?? client).put({
|
|
949
|
+
security: [{
|
|
950
|
+
scheme: "bearer",
|
|
951
|
+
type: "http"
|
|
952
|
+
}],
|
|
953
|
+
url: "/admin/namespaces/{namespace}/write-budget",
|
|
954
|
+
...options,
|
|
955
|
+
headers: {
|
|
956
|
+
"Content-Type": "application/json",
|
|
957
|
+
...options.headers
|
|
958
|
+
}
|
|
959
|
+
});
|
|
960
|
+
/**
|
|
961
|
+
* List embedding providers
|
|
962
|
+
*
|
|
963
|
+
* Lists the namespace's embedding provider credentials, newest first, revoked ones included so their status stays readable. Metadata only: no key is ever returned. Requires the embeddings:admin scope.
|
|
964
|
+
*/
|
|
965
|
+
const listEmbeddingProviders = (options) => (options.client ?? client).get({
|
|
966
|
+
security: [{
|
|
967
|
+
scheme: "bearer",
|
|
968
|
+
type: "http"
|
|
969
|
+
}],
|
|
970
|
+
url: "/namespaces/{namespace}/embedding-providers",
|
|
971
|
+
...options
|
|
972
|
+
});
|
|
973
|
+
/**
|
|
974
|
+
* Revoke embedding provider credential
|
|
975
|
+
*
|
|
976
|
+
* Revokes the namespace's credential for one provider: the ciphertext is erased and worlds on that provider's models fall back to keyword-only search (embeddingStatus no_credential). Every world on that provider's models is marked stale (worlds on another provider's models are untouched), so after a new key is set search stays keyword-only until each world is reindexed (vectors built before the revoke are never trusted again). Requires the embeddings:admin scope.
|
|
977
|
+
*/
|
|
978
|
+
const deleteEmbeddingProviderCredential = (options) => (options.client ?? client).delete({
|
|
979
|
+
security: [{
|
|
980
|
+
scheme: "bearer",
|
|
981
|
+
type: "http"
|
|
982
|
+
}],
|
|
983
|
+
url: "/namespaces/{namespace}/embedding-providers/{provider}",
|
|
984
|
+
...options
|
|
985
|
+
});
|
|
986
|
+
/**
|
|
987
|
+
* Get embedding provider credential status
|
|
988
|
+
*
|
|
989
|
+
* Returns the metadata of the namespace's credential for one provider (status, fingerprint, last four characters, timestamps). The key itself is never returned. Requires the embeddings:admin scope.
|
|
990
|
+
*/
|
|
991
|
+
const getEmbeddingProviderCredential = (options) => (options.client ?? client).get({
|
|
992
|
+
security: [{
|
|
993
|
+
scheme: "bearer",
|
|
994
|
+
type: "http"
|
|
995
|
+
}],
|
|
996
|
+
url: "/namespaces/{namespace}/embedding-providers/{provider}",
|
|
997
|
+
...options
|
|
998
|
+
});
|
|
999
|
+
/**
|
|
1000
|
+
* Set embedding provider credential
|
|
1001
|
+
*
|
|
1002
|
+
* Store or rotate the namespace's API key for one embedding provider (bring your own key). The key is encrypted at rest with a key held only as a Worker secret and is write-only: it is never returned or logged. Requires the embeddings:admin scope (or an admin key); world-scoped tokens are refused. Returns 503 EMBEDDINGS_NOT_CONFIGURED when the deployment has no key-encryption key.
|
|
1003
|
+
*/
|
|
1004
|
+
const setEmbeddingProviderCredential = (options) => (options.client ?? client).put({
|
|
1005
|
+
security: [{
|
|
1006
|
+
scheme: "bearer",
|
|
1007
|
+
type: "http"
|
|
1008
|
+
}],
|
|
1009
|
+
url: "/namespaces/{namespace}/embedding-providers/{provider}",
|
|
1010
|
+
...options,
|
|
1011
|
+
headers: {
|
|
1012
|
+
"Content-Type": "application/json",
|
|
1013
|
+
...options.headers
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
1016
|
+
export { backfillWorldInference, clearNamespaceWriteBudget, client, createApiKey, createClient, createWorld, deleteApiKey, deleteEmbeddingProviderCredential, deleteNamespaceWorlds, deleteWorld, exportWorld, getEmbeddingProviderCredential, getHealth, getNamespaceWriteBudget, getReadiness, getWorld, importWorld, listApiKeys, listEmbeddingProviders, listWorlds, purgeWorlds, queryWorldProvenance, reindexWorld, resumeWorld, searchWorld, setEmbeddingProviderCredential, setNamespaceWriteBudget, sparqlNoWorld, sparqlWorld, suspendWorld, undeleteWorld, updateWorld };
|