@wazootech/client 0.0.0-stage → 0.7.2-rc.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/dist/index.js ADDED
@@ -0,0 +1,1100 @@
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://api.wazoo.dev" }));
597
+ // src/generated/sdk.gen.ts
598
+ /**
599
+ * Get health
600
+ */
601
+ const getHealth = (options) => (options?.client ?? client).get({
602
+ url: "/health",
603
+ ...options
604
+ });
605
+ /**
606
+ * Get readiness
607
+ *
608
+ * Returns ready only when the management database uses the canonical world-identity schema.
609
+ */
610
+ const getReadiness = (options) => (options?.client ?? client).get({
611
+ url: "/ready",
612
+ ...options
613
+ });
614
+ /**
615
+ * Start magic-link login
616
+ *
617
+ * Sends a one-time code to an allowlisted email. Unauthenticated; limited to 5 requests per minute per IP. Every outcome (missing email, rate-limited, not allowlisted, unconfigured) returns 200 `{ ok: true }` so the endpoint does not reveal which emails are on the beta list; no code is sent to an email that is not allowlisted.
618
+ */
619
+ const login = (options) => (options?.client ?? client).post({
620
+ url: "/v1/auth/login",
621
+ ...options,
622
+ headers: {
623
+ "Content-Type": "application/json",
624
+ ...options?.headers
625
+ }
626
+ });
627
+ /**
628
+ * Redeem login code for a session token
629
+ *
630
+ * Redeems the WorkOS magic-auth code and mints a `wzp_` session token. Unauthenticated; limited to 10 requests per minute per IP.
631
+ */
632
+ const verifyLogin = (options) => (options?.client ?? client).post({
633
+ url: "/v1/auth/verify",
634
+ ...options,
635
+ headers: {
636
+ "Content-Type": "application/json",
637
+ ...options?.headers
638
+ }
639
+ });
640
+ /**
641
+ * Mint a console session token (admin)
642
+ *
643
+ * Admin-only. Mints a 30-day console session token for an arbitrary email, creating the user when needed. Requires the `admin` scope.
644
+ */
645
+ const mintWorkosSession = (options) => (options?.client ?? client).post({
646
+ security: [{
647
+ scheme: "bearer",
648
+ type: "http"
649
+ }],
650
+ url: "/v1/auth/workos",
651
+ ...options,
652
+ headers: {
653
+ "Content-Type": "application/json",
654
+ ...options?.headers
655
+ }
656
+ });
657
+ /**
658
+ * Mint a console session token (deprecated path)
659
+ *
660
+ * Deprecated: use `POST /v1/auth/workos`. This path replies with a 308 redirect to it, which keeps the method and body. Admin-only; requires the `admin` scope.
661
+ *
662
+ * @deprecated
663
+ */
664
+ const createWorkosSession = (options) => (options?.client ?? client).post({
665
+ security: [{
666
+ scheme: "bearer",
667
+ type: "http"
668
+ }],
669
+ url: "/v1/auth/workos-session",
670
+ ...options,
671
+ headers: {
672
+ "Content-Type": "application/json",
673
+ ...options?.headers
674
+ }
675
+ });
676
+ /**
677
+ * Delete the authenticated user's account (two-step confirmation)
678
+ */
679
+ const deleteUserMe = (options) => (options.client ?? client).delete({
680
+ security: [{
681
+ scheme: "bearer",
682
+ type: "http"
683
+ }],
684
+ url: "/v1/users/me",
685
+ ...options,
686
+ headers: {
687
+ "Content-Type": "application/json",
688
+ ...options.headers
689
+ }
690
+ });
691
+ /**
692
+ * Get authenticated user
693
+ */
694
+ const getUserMe = (options) => (options?.client ?? client).get({
695
+ security: [{
696
+ scheme: "bearer",
697
+ type: "http"
698
+ }],
699
+ url: "/v1/users/me",
700
+ ...options
701
+ });
702
+ /**
703
+ * Initiate account deletion (returns a short-lived confirmation token)
704
+ */
705
+ const initiateAccountDeletion = (options) => (options?.client ?? client).post({
706
+ security: [{
707
+ scheme: "bearer",
708
+ type: "http"
709
+ }],
710
+ url: "/v1/users/me/deletion",
711
+ ...options
712
+ });
713
+ /**
714
+ * Export the data Wazoo holds on the authenticated user
715
+ */
716
+ const exportUserMe = (options) => (options?.client ?? client).get({
717
+ security: [{
718
+ scheme: "bearer",
719
+ type: "http"
720
+ }],
721
+ url: "/v1/users/me/export",
722
+ ...options
723
+ });
724
+ /**
725
+ * List embedding provider credentials
726
+ *
727
+ * Lists the caller's bring-your-own-key embedding credentials, revoked ones included so their status stays readable. Metadata only: a key is never returned.
728
+ */
729
+ const listEmbeddingProviders = (options) => (options?.client ?? client).get({
730
+ security: [{
731
+ scheme: "bearer",
732
+ type: "http"
733
+ }],
734
+ url: "/v1/users/me/embedding-providers",
735
+ ...options
736
+ });
737
+ /**
738
+ * Revoke an embedding provider credential
739
+ *
740
+ * Revokes the caller's credential for one provider. The stored key is erased and every world on that provider's models falls back to keyword search until a new key is stored and the world is reindexed. Worlds on another provider's models are not affected.
741
+ */
742
+ const deleteEmbeddingProviderCredential = (options) => (options.client ?? client).delete({
743
+ security: [{
744
+ scheme: "bearer",
745
+ type: "http"
746
+ }],
747
+ url: "/v1/users/me/embedding-providers/{provider}",
748
+ ...options
749
+ });
750
+ /**
751
+ * Get an embedding provider credential's status
752
+ *
753
+ * Returns the metadata of the caller's credential for one provider. The key itself is never returned.
754
+ */
755
+ const getEmbeddingProviderCredential = (options) => (options.client ?? client).get({
756
+ security: [{
757
+ scheme: "bearer",
758
+ type: "http"
759
+ }],
760
+ url: "/v1/users/me/embedding-providers/{provider}",
761
+ ...options
762
+ });
763
+ /**
764
+ * Set an embedding provider credential
765
+ *
766
+ * Stores or rotates the caller's API key for one embedding provider. The key is encrypted at rest, write-only, and never returned or logged. Choose a model, reindex, and search with a world token on the data plane afterwards. Returns 503 EMBEDDINGS_NOT_CONFIGURED when the deployment has embeddings disabled.
767
+ */
768
+ const setEmbeddingProviderCredential = (options) => (options.client ?? client).put({
769
+ security: [{
770
+ scheme: "bearer",
771
+ type: "http"
772
+ }],
773
+ url: "/v1/users/me/embedding-providers/{provider}",
774
+ ...options,
775
+ headers: {
776
+ "Content-Type": "application/json",
777
+ ...options.headers
778
+ }
779
+ });
780
+ /**
781
+ * List worlds
782
+ */
783
+ const listWorlds = (options) => (options?.client ?? client).get({
784
+ security: [{
785
+ scheme: "bearer",
786
+ type: "http"
787
+ }],
788
+ url: "/v1/worlds",
789
+ ...options
790
+ });
791
+ /**
792
+ * Create world
793
+ */
794
+ const createWorld = (options) => (options.client ?? client).post({
795
+ security: [{
796
+ scheme: "bearer",
797
+ type: "http"
798
+ }],
799
+ url: "/v1/worlds",
800
+ ...options,
801
+ headers: {
802
+ "Content-Type": "application/json",
803
+ ...options.headers
804
+ }
805
+ });
806
+ /**
807
+ * Delete world
808
+ */
809
+ const deleteWorld = (options) => (options.client ?? client).delete({
810
+ security: [{
811
+ scheme: "bearer",
812
+ type: "http"
813
+ }],
814
+ url: "/v1/worlds/{worldId}",
815
+ ...options
816
+ });
817
+ /**
818
+ * Get world
819
+ */
820
+ const getWorld = (options) => (options.client ?? client).get({
821
+ security: [{
822
+ scheme: "bearer",
823
+ type: "http"
824
+ }],
825
+ url: "/v1/worlds/{worldId}",
826
+ ...options
827
+ });
828
+ /**
829
+ * Update world
830
+ */
831
+ const updateWorld = (options) => (options.client ?? client).patch({
832
+ security: [{
833
+ scheme: "bearer",
834
+ type: "http"
835
+ }],
836
+ url: "/v1/worlds/{worldId}",
837
+ ...options,
838
+ headers: {
839
+ "Content-Type": "application/json",
840
+ ...options.headers
841
+ }
842
+ });
843
+ /**
844
+ * Undelete world
845
+ */
846
+ const undeleteWorld = (options) => (options.client ?? client).post({
847
+ security: [{
848
+ scheme: "bearer",
849
+ type: "http"
850
+ }],
851
+ url: "/v1/worlds/{worldId}/undelete",
852
+ ...options
853
+ });
854
+ /**
855
+ * List world tokens
856
+ */
857
+ const listWorldTokens = (options) => (options.client ?? client).get({
858
+ security: [{
859
+ scheme: "bearer",
860
+ type: "http"
861
+ }],
862
+ url: "/v1/worlds/{worldId}/auth/tokens",
863
+ ...options
864
+ });
865
+ /**
866
+ * Create world token
867
+ */
868
+ const createWorldToken = (options) => (options.client ?? client).post({
869
+ security: [{
870
+ scheme: "bearer",
871
+ type: "http"
872
+ }],
873
+ url: "/v1/worlds/{worldId}/auth/tokens",
874
+ ...options,
875
+ headers: {
876
+ "Content-Type": "application/json",
877
+ ...options.headers
878
+ }
879
+ });
880
+ /**
881
+ * Revoke world token
882
+ */
883
+ const deleteWorldToken = (options) => (options.client ?? client).delete({
884
+ security: [{
885
+ scheme: "bearer",
886
+ type: "http"
887
+ }],
888
+ url: "/v1/worlds/{worldId}/auth/tokens/{tokenUid}",
889
+ ...options
890
+ });
891
+ /**
892
+ * List platform tokens
893
+ */
894
+ const listPlatformTokens = (options) => (options?.client ?? client).get({
895
+ security: [{
896
+ scheme: "bearer",
897
+ type: "http"
898
+ }],
899
+ url: "/v1/auth/api-tokens",
900
+ ...options
901
+ });
902
+ /**
903
+ * Create platform token
904
+ */
905
+ const createPlatformToken = (options) => (options.client ?? client).post({
906
+ security: [{
907
+ scheme: "bearer",
908
+ type: "http"
909
+ }],
910
+ url: "/v1/auth/api-tokens",
911
+ ...options,
912
+ headers: {
913
+ "Content-Type": "application/json",
914
+ ...options.headers
915
+ }
916
+ });
917
+ /**
918
+ * Revoke platform token
919
+ */
920
+ const deletePlatformToken = (options) => (options.client ?? client).delete({
921
+ security: [{
922
+ scheme: "bearer",
923
+ type: "http"
924
+ }],
925
+ url: "/v1/auth/api-tokens/{tokenName}",
926
+ ...options
927
+ });
928
+ /**
929
+ * Create named platform token
930
+ */
931
+ const createNamedPlatformToken = (options) => (options.client ?? client).post({
932
+ security: [{
933
+ scheme: "bearer",
934
+ type: "http"
935
+ }],
936
+ url: "/v1/auth/api-tokens/{tokenName}",
937
+ ...options,
938
+ headers: {
939
+ "Content-Type": "application/json",
940
+ ...options.headers
941
+ }
942
+ });
943
+ /**
944
+ * Validate platform token
945
+ */
946
+ const validatePlatformToken = (options) => (options?.client ?? client).get({
947
+ security: [{
948
+ scheme: "bearer",
949
+ type: "http"
950
+ }],
951
+ url: "/v1/auth/api-tokens/validate",
952
+ ...options
953
+ });
954
+ /**
955
+ * Get world usage
956
+ */
957
+ const getWorldUsage = (options) => (options.client ?? client).get({
958
+ security: [{
959
+ scheme: "bearer",
960
+ type: "http"
961
+ }],
962
+ url: "/v1/worlds/{worldId}/usage",
963
+ ...options
964
+ });
965
+ /**
966
+ * Record world usage
967
+ */
968
+ const recordWorldUsage = (options) => (options.client ?? client).post({
969
+ security: [{
970
+ scheme: "bearer",
971
+ type: "http"
972
+ }],
973
+ url: "/v1/worlds/{worldId}/usage",
974
+ ...options,
975
+ headers: {
976
+ "Content-Type": "application/json",
977
+ ...options.headers
978
+ }
979
+ });
980
+ /**
981
+ * Get world limits
982
+ */
983
+ const getWorldLimits = (options) => (options.client ?? client).get({
984
+ security: [{
985
+ scheme: "bearer",
986
+ type: "http"
987
+ }],
988
+ url: "/v1/worlds/{worldId}/limits",
989
+ ...options
990
+ });
991
+ /**
992
+ * Get world billing
993
+ */
994
+ const getWorldBilling = (options) => (options.client ?? client).get({
995
+ security: [{
996
+ scheme: "bearer",
997
+ type: "http"
998
+ }],
999
+ url: "/v1/worlds/{worldId}/billing",
1000
+ ...options
1001
+ });
1002
+ /**
1003
+ * List world invoices
1004
+ */
1005
+ const listWorldInvoices = (options) => (options.client ?? client).get({
1006
+ security: [{
1007
+ scheme: "bearer",
1008
+ type: "http"
1009
+ }],
1010
+ url: "/v1/worlds/{worldId}/billing/invoices",
1011
+ ...options
1012
+ });
1013
+ /**
1014
+ * Cancel world subscription
1015
+ */
1016
+ const cancelWorldSubscription = (options) => (options.client ?? client).post({
1017
+ security: [{
1018
+ scheme: "bearer",
1019
+ type: "http"
1020
+ }],
1021
+ url: "/v1/worlds/{worldId}/billing/cancel",
1022
+ ...options
1023
+ });
1024
+ /**
1025
+ * Open billing portal
1026
+ */
1027
+ const openWorldBillingPortal = (options) => (options.client ?? client).post({
1028
+ security: [{
1029
+ scheme: "bearer",
1030
+ type: "http"
1031
+ }],
1032
+ url: "/v1/worlds/{worldId}/billing/openPortal",
1033
+ ...options
1034
+ });
1035
+ /**
1036
+ * List admin audit events
1037
+ */
1038
+ const listAdminAuditEvents = (options) => (options?.client ?? client).get({
1039
+ security: [{
1040
+ scheme: "bearer",
1041
+ type: "http"
1042
+ }],
1043
+ url: "/v1/admin/audit-events",
1044
+ ...options
1045
+ });
1046
+ /**
1047
+ * Get the authenticated user's plan and today's write usage
1048
+ */
1049
+ const getUserPlan = (options) => (options?.client ?? client).get({
1050
+ security: [{
1051
+ scheme: "bearer",
1052
+ type: "http"
1053
+ }],
1054
+ url: "/v1/users/me/plan",
1055
+ ...options
1056
+ });
1057
+ /**
1058
+ * Set a user's plan
1059
+ *
1060
+ * Admin-only. Stores the plan and applies its daily write budget in the data plane. Idempotent: if the data plane cannot be reached the plan is still saved, the call returns 502 BUDGET_SYNC_FAILED, and repeating it retries the sync.
1061
+ */
1062
+ const setUserPlan = (options) => (options.client ?? client).put({
1063
+ security: [{
1064
+ scheme: "bearer",
1065
+ type: "http"
1066
+ }],
1067
+ url: "/v1/admin/users/{userUid}/plan",
1068
+ ...options,
1069
+ headers: {
1070
+ "Content-Type": "application/json",
1071
+ ...options.headers
1072
+ }
1073
+ });
1074
+ /**
1075
+ * Start a Pro subscription checkout
1076
+ *
1077
+ * Creates a Stripe Checkout session for the Pro plan and returns the hosted page's URL. The plan changes when Stripe confirms the payment (a webhook), not when this call returns, so the console shows the new plan shortly after the user comes back.
1078
+ */
1079
+ const createCheckoutSession = (options) => (options?.client ?? client).post({
1080
+ security: [{
1081
+ scheme: "bearer",
1082
+ type: "http"
1083
+ }],
1084
+ url: "/v1/users/me/billing/checkout",
1085
+ ...options
1086
+ });
1087
+ /**
1088
+ * Open the Stripe billing portal
1089
+ *
1090
+ * Creates a Stripe billing portal session where the user can update their card, see invoices or cancel, and returns its URL.
1091
+ */
1092
+ const createBillingPortalSession = (options) => (options?.client ?? client).post({
1093
+ security: [{
1094
+ scheme: "bearer",
1095
+ type: "http"
1096
+ }],
1097
+ url: "/v1/users/me/billing/portal",
1098
+ ...options
1099
+ });
1100
+ export { cancelWorldSubscription, client, createBillingPortalSession, createCheckoutSession, createClient, createNamedPlatformToken, createPlatformToken, createWorkosSession, createWorld, createWorldToken, deleteEmbeddingProviderCredential, deletePlatformToken, deleteUserMe, deleteWorld, deleteWorldToken, exportUserMe, getEmbeddingProviderCredential, getHealth, getReadiness, getUserMe, getUserPlan, getWorld, getWorldBilling, getWorldLimits, getWorldUsage, initiateAccountDeletion, listAdminAuditEvents, listEmbeddingProviders, listPlatformTokens, listWorldInvoices, listWorldTokens, listWorlds, login, mintWorkosSession, openWorldBillingPortal, recordWorldUsage, setEmbeddingProviderCredential, setUserPlan, undeleteWorld, updateWorld, validatePlatformToken, verifyLogin };