@anuma/sdk 1.0.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.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +98 -0
  3. package/dist/expo/chunk-LJYAMK62.mjs +25 -0
  4. package/dist/expo/chunk-MJJIYFAX.mjs +25 -0
  5. package/dist/expo/chunk-PJCZO4BQ.mjs +25 -0
  6. package/dist/expo/clientConfig-2MI4KULF.mjs +10 -0
  7. package/dist/expo/clientConfig-QDAXFL3W.mjs +10 -0
  8. package/dist/expo/clientConfig-R4IOW7I2.mjs +10 -0
  9. package/dist/expo/index.cjs +7858 -0
  10. package/dist/expo/index.d.mts +2590 -0
  11. package/dist/expo/index.d.ts +2590 -0
  12. package/dist/expo/index.mjs +7770 -0
  13. package/dist/index.cjs +1200 -0
  14. package/dist/index.d.mts +2796 -0
  15. package/dist/index.d.ts +2796 -0
  16. package/dist/index.mjs +1138 -0
  17. package/dist/next/index.cjs +64 -0
  18. package/dist/next/index.d.mts +23 -0
  19. package/dist/next/index.d.ts +23 -0
  20. package/dist/next/index.mjs +39 -0
  21. package/dist/polyfills/index.cjs +61 -0
  22. package/dist/polyfills/index.d.mts +9 -0
  23. package/dist/polyfills/index.d.ts +9 -0
  24. package/dist/polyfills/index.mjs +34 -0
  25. package/dist/react/chunk-LJYAMK62.mjs +25 -0
  26. package/dist/react/chunk-MJJIYFAX.mjs +25 -0
  27. package/dist/react/chunk-PJCZO4BQ.mjs +25 -0
  28. package/dist/react/clientConfig-2MI4KULF.mjs +10 -0
  29. package/dist/react/clientConfig-QDAXFL3W.mjs +10 -0
  30. package/dist/react/clientConfig-R4IOW7I2.mjs +10 -0
  31. package/dist/react/index.cjs +15178 -0
  32. package/dist/react/index.d.mts +6014 -0
  33. package/dist/react/index.d.ts +6014 -0
  34. package/dist/react/index.mjs +14945 -0
  35. package/dist/tools/chunk-KDFGY4SK.mjs +13 -0
  36. package/dist/tools/clientConfig-RMDOT5YM.mjs +10 -0
  37. package/dist/tools/index.cjs +775 -0
  38. package/dist/tools/index.d.mts +121 -0
  39. package/dist/tools/index.d.ts +121 -0
  40. package/dist/tools/index.mjs +741 -0
  41. package/dist/vercel/index.cjs +86 -0
  42. package/dist/vercel/index.d.mts +149 -0
  43. package/dist/vercel/index.d.ts +149 -0
  44. package/dist/vercel/index.mjs +57 -0
  45. package/package.json +149 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,1200 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ deleteApiV1AdminAppsByAppIdApiKeysById: () => deleteApiV1AdminAppsByAppIdApiKeysById,
24
+ deleteApiV1AdminAppsById: () => deleteApiV1AdminAppsById,
25
+ getApiV1AdminApps: () => getApiV1AdminApps,
26
+ getApiV1AdminAppsByAppIdApiKeys: () => getApiV1AdminAppsByAppIdApiKeys,
27
+ getApiV1AdminAppsByAppIdApiKeysById: () => getApiV1AdminAppsByAppIdApiKeysById,
28
+ getApiV1AdminAppsById: () => getApiV1AdminAppsById,
29
+ getApiV1Config: () => getApiV1Config,
30
+ getApiV1CreditsBalance: () => getApiV1CreditsBalance,
31
+ getApiV1CreditsPacks: () => getApiV1CreditsPacks,
32
+ getApiV1DocsSwaggerJson: () => getApiV1DocsSwaggerJson,
33
+ getApiV1Models: () => getApiV1Models,
34
+ getApiV1SubscriptionsStatus: () => getApiV1SubscriptionsStatus,
35
+ getApiV1Tasks: () => getApiV1Tasks,
36
+ getApiV1Tools: () => getApiV1Tools,
37
+ getHealth: () => getHealth,
38
+ postApiV1AdminAddCredits: () => postApiV1AdminAddCredits,
39
+ postApiV1AdminApps: () => postApiV1AdminApps,
40
+ postApiV1AdminAppsByAppIdApiKeys: () => postApiV1AdminAppsByAppIdApiKeys,
41
+ postApiV1AdminSeedApps: () => postApiV1AdminSeedApps,
42
+ postApiV1AdminSubscriptionTier: () => postApiV1AdminSubscriptionTier,
43
+ postApiV1ChatCompletions: () => postApiV1ChatCompletions,
44
+ postApiV1CreditsClaimDaily: () => postApiV1CreditsClaimDaily,
45
+ postApiV1CreditsPurchase: () => postApiV1CreditsPurchase,
46
+ postApiV1CreditsSyncSnag: () => postApiV1CreditsSyncSnag,
47
+ postApiV1Embeddings: () => postApiV1Embeddings,
48
+ postApiV1Responses: () => postApiV1Responses,
49
+ postApiV1SubscriptionsCancel: () => postApiV1SubscriptionsCancel,
50
+ postApiV1SubscriptionsCreateCheckoutSession: () => postApiV1SubscriptionsCreateCheckoutSession,
51
+ postApiV1SubscriptionsCustomerPortal: () => postApiV1SubscriptionsCustomerPortal,
52
+ postApiV1SubscriptionsRenew: () => postApiV1SubscriptionsRenew,
53
+ postApiV1SubscriptionsWebhook: () => postApiV1SubscriptionsWebhook,
54
+ postAuthOauthByProviderExchange: () => postAuthOauthByProviderExchange,
55
+ postAuthOauthByProviderRefresh: () => postAuthOauthByProviderRefresh,
56
+ postAuthOauthByProviderRevoke: () => postAuthOauthByProviderRevoke,
57
+ putApiV1AdminAppsByAppIdApiKeysById: () => putApiV1AdminAppsByAppIdApiKeysById,
58
+ putApiV1AdminAppsById: () => putApiV1AdminAppsById
59
+ });
60
+ module.exports = __toCommonJS(index_exports);
61
+
62
+ // src/client/core/bodySerializer.gen.ts
63
+ var jsonBodySerializer = {
64
+ bodySerializer: (body) => JSON.stringify(
65
+ body,
66
+ (_key, value) => typeof value === "bigint" ? value.toString() : value
67
+ )
68
+ };
69
+
70
+ // src/client/core/params.gen.ts
71
+ var extraPrefixesMap = {
72
+ $body_: "body",
73
+ $headers_: "headers",
74
+ $path_: "path",
75
+ $query_: "query"
76
+ };
77
+ var extraPrefixes = Object.entries(extraPrefixesMap);
78
+
79
+ // src/client/core/serverSentEvents.gen.ts
80
+ var createSseClient = ({
81
+ onRequest,
82
+ onSseError,
83
+ onSseEvent,
84
+ responseTransformer,
85
+ responseValidator,
86
+ sseDefaultRetryDelay,
87
+ sseMaxRetryAttempts,
88
+ sseMaxRetryDelay,
89
+ sseSleepFn,
90
+ url,
91
+ ...options
92
+ }) => {
93
+ let lastEventId;
94
+ const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
95
+ const createStream = async function* () {
96
+ let retryDelay = sseDefaultRetryDelay ?? 3e3;
97
+ let attempt = 0;
98
+ const signal = options.signal ?? new AbortController().signal;
99
+ while (true) {
100
+ if (signal.aborted) break;
101
+ attempt++;
102
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
103
+ if (lastEventId !== void 0) {
104
+ headers.set("Last-Event-ID", lastEventId);
105
+ }
106
+ try {
107
+ const requestInit = {
108
+ redirect: "follow",
109
+ ...options,
110
+ body: options.serializedBody,
111
+ headers,
112
+ signal
113
+ };
114
+ let request = new Request(url, requestInit);
115
+ if (onRequest) {
116
+ request = await onRequest(url, requestInit);
117
+ }
118
+ const _fetch = options.fetch ?? globalThis.fetch;
119
+ const response = await _fetch(request);
120
+ if (!response.ok)
121
+ throw new Error(
122
+ `SSE failed: ${response.status} ${response.statusText}`
123
+ );
124
+ if (!response.body) throw new Error("No body in SSE response");
125
+ const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
126
+ let buffer = "";
127
+ const abortHandler = () => {
128
+ try {
129
+ reader.cancel();
130
+ } catch {
131
+ }
132
+ };
133
+ signal.addEventListener("abort", abortHandler);
134
+ try {
135
+ while (true) {
136
+ const { done, value } = await reader.read();
137
+ if (done) break;
138
+ buffer += value;
139
+ const chunks = buffer.split("\n\n");
140
+ buffer = chunks.pop() ?? "";
141
+ for (const chunk of chunks) {
142
+ const lines = chunk.split("\n");
143
+ const dataLines = [];
144
+ let eventName;
145
+ for (const line of lines) {
146
+ if (line.startsWith("data:")) {
147
+ dataLines.push(line.replace(/^data:\s*/, ""));
148
+ } else if (line.startsWith("event:")) {
149
+ eventName = line.replace(/^event:\s*/, "");
150
+ } else if (line.startsWith("id:")) {
151
+ lastEventId = line.replace(/^id:\s*/, "");
152
+ } else if (line.startsWith("retry:")) {
153
+ const parsed = Number.parseInt(
154
+ line.replace(/^retry:\s*/, ""),
155
+ 10
156
+ );
157
+ if (!Number.isNaN(parsed)) {
158
+ retryDelay = parsed;
159
+ }
160
+ }
161
+ }
162
+ let data;
163
+ let parsedJson = false;
164
+ if (dataLines.length) {
165
+ const rawData = dataLines.join("\n");
166
+ try {
167
+ data = JSON.parse(rawData);
168
+ parsedJson = true;
169
+ } catch {
170
+ data = rawData;
171
+ }
172
+ }
173
+ if (parsedJson) {
174
+ if (responseValidator) {
175
+ await responseValidator(data);
176
+ }
177
+ if (responseTransformer) {
178
+ data = await responseTransformer(data);
179
+ }
180
+ }
181
+ onSseEvent?.({
182
+ data,
183
+ event: eventName,
184
+ id: lastEventId,
185
+ retry: retryDelay
186
+ });
187
+ if (dataLines.length) {
188
+ yield data;
189
+ }
190
+ }
191
+ }
192
+ } finally {
193
+ signal.removeEventListener("abort", abortHandler);
194
+ reader.releaseLock();
195
+ }
196
+ break;
197
+ } catch (error) {
198
+ onSseError?.(error);
199
+ if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
200
+ break;
201
+ }
202
+ const backoff = Math.min(
203
+ retryDelay * 2 ** (attempt - 1),
204
+ sseMaxRetryDelay ?? 3e4
205
+ );
206
+ await sleep(backoff);
207
+ }
208
+ }
209
+ };
210
+ const stream = createStream();
211
+ return { stream };
212
+ };
213
+
214
+ // src/client/core/pathSerializer.gen.ts
215
+ var separatorArrayExplode = (style) => {
216
+ switch (style) {
217
+ case "label":
218
+ return ".";
219
+ case "matrix":
220
+ return ";";
221
+ case "simple":
222
+ return ",";
223
+ default:
224
+ return "&";
225
+ }
226
+ };
227
+ var separatorArrayNoExplode = (style) => {
228
+ switch (style) {
229
+ case "form":
230
+ return ",";
231
+ case "pipeDelimited":
232
+ return "|";
233
+ case "spaceDelimited":
234
+ return "%20";
235
+ default:
236
+ return ",";
237
+ }
238
+ };
239
+ var separatorObjectExplode = (style) => {
240
+ switch (style) {
241
+ case "label":
242
+ return ".";
243
+ case "matrix":
244
+ return ";";
245
+ case "simple":
246
+ return ",";
247
+ default:
248
+ return "&";
249
+ }
250
+ };
251
+ var serializeArrayParam = ({
252
+ allowReserved,
253
+ explode,
254
+ name,
255
+ style,
256
+ value
257
+ }) => {
258
+ if (!explode) {
259
+ const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
260
+ switch (style) {
261
+ case "label":
262
+ return `.${joinedValues2}`;
263
+ case "matrix":
264
+ return `;${name}=${joinedValues2}`;
265
+ case "simple":
266
+ return joinedValues2;
267
+ default:
268
+ return `${name}=${joinedValues2}`;
269
+ }
270
+ }
271
+ const separator = separatorArrayExplode(style);
272
+ const joinedValues = value.map((v) => {
273
+ if (style === "label" || style === "simple") {
274
+ return allowReserved ? v : encodeURIComponent(v);
275
+ }
276
+ return serializePrimitiveParam({
277
+ allowReserved,
278
+ name,
279
+ value: v
280
+ });
281
+ }).join(separator);
282
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
283
+ };
284
+ var serializePrimitiveParam = ({
285
+ allowReserved,
286
+ name,
287
+ value
288
+ }) => {
289
+ if (value === void 0 || value === null) {
290
+ return "";
291
+ }
292
+ if (typeof value === "object") {
293
+ throw new Error(
294
+ "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
295
+ );
296
+ }
297
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
298
+ };
299
+ var serializeObjectParam = ({
300
+ allowReserved,
301
+ explode,
302
+ name,
303
+ style,
304
+ value,
305
+ valueOnly
306
+ }) => {
307
+ if (value instanceof Date) {
308
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
309
+ }
310
+ if (style !== "deepObject" && !explode) {
311
+ let values = [];
312
+ Object.entries(value).forEach(([key, v]) => {
313
+ values = [
314
+ ...values,
315
+ key,
316
+ allowReserved ? v : encodeURIComponent(v)
317
+ ];
318
+ });
319
+ const joinedValues2 = values.join(",");
320
+ switch (style) {
321
+ case "form":
322
+ return `${name}=${joinedValues2}`;
323
+ case "label":
324
+ return `.${joinedValues2}`;
325
+ case "matrix":
326
+ return `;${name}=${joinedValues2}`;
327
+ default:
328
+ return joinedValues2;
329
+ }
330
+ }
331
+ const separator = separatorObjectExplode(style);
332
+ const joinedValues = Object.entries(value).map(
333
+ ([key, v]) => serializePrimitiveParam({
334
+ allowReserved,
335
+ name: style === "deepObject" ? `${name}[${key}]` : key,
336
+ value: v
337
+ })
338
+ ).join(separator);
339
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
340
+ };
341
+
342
+ // src/client/core/utils.gen.ts
343
+ function getValidRequestBody(options) {
344
+ const hasBody = options.body !== void 0;
345
+ const isSerializedBody = hasBody && options.bodySerializer;
346
+ if (isSerializedBody) {
347
+ if ("serializedBody" in options) {
348
+ const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
349
+ return hasSerializedBody ? options.serializedBody : null;
350
+ }
351
+ return options.body !== "" ? options.body : null;
352
+ }
353
+ if (hasBody) {
354
+ return options.body;
355
+ }
356
+ return void 0;
357
+ }
358
+
359
+ // src/client/core/auth.gen.ts
360
+ var getAuthToken = async (auth, callback) => {
361
+ const token = typeof callback === "function" ? await callback(auth) : callback;
362
+ if (!token) {
363
+ return;
364
+ }
365
+ if (auth.scheme === "bearer") {
366
+ return `Bearer ${token}`;
367
+ }
368
+ if (auth.scheme === "basic") {
369
+ return `Basic ${btoa(token)}`;
370
+ }
371
+ return token;
372
+ };
373
+
374
+ // src/client/client/utils.gen.ts
375
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
376
+ var defaultPathSerializer = ({ path, url: _url }) => {
377
+ let url = _url;
378
+ const matches = _url.match(PATH_PARAM_RE);
379
+ if (matches) {
380
+ for (const match of matches) {
381
+ let explode = false;
382
+ let name = match.substring(1, match.length - 1);
383
+ let style = "simple";
384
+ if (name.endsWith("*")) {
385
+ explode = true;
386
+ name = name.substring(0, name.length - 1);
387
+ }
388
+ if (name.startsWith(".")) {
389
+ name = name.substring(1);
390
+ style = "label";
391
+ } else if (name.startsWith(";")) {
392
+ name = name.substring(1);
393
+ style = "matrix";
394
+ }
395
+ const value = path[name];
396
+ if (value === void 0 || value === null) {
397
+ continue;
398
+ }
399
+ if (Array.isArray(value)) {
400
+ url = url.replace(
401
+ match,
402
+ serializeArrayParam({ explode, name, style, value })
403
+ );
404
+ continue;
405
+ }
406
+ if (typeof value === "object") {
407
+ url = url.replace(
408
+ match,
409
+ serializeObjectParam({
410
+ explode,
411
+ name,
412
+ style,
413
+ value,
414
+ valueOnly: true
415
+ })
416
+ );
417
+ continue;
418
+ }
419
+ if (style === "matrix") {
420
+ url = url.replace(
421
+ match,
422
+ `;${serializePrimitiveParam({
423
+ name,
424
+ value
425
+ })}`
426
+ );
427
+ continue;
428
+ }
429
+ const replaceValue = encodeURIComponent(
430
+ style === "label" ? `.${value}` : value
431
+ );
432
+ url = url.replace(match, replaceValue);
433
+ }
434
+ }
435
+ return url;
436
+ };
437
+ var createQuerySerializer = ({
438
+ parameters = {},
439
+ ...args
440
+ } = {}) => {
441
+ const querySerializer = (queryParams) => {
442
+ const search = [];
443
+ if (queryParams && typeof queryParams === "object") {
444
+ for (const name in queryParams) {
445
+ const value = queryParams[name];
446
+ if (value === void 0 || value === null) {
447
+ continue;
448
+ }
449
+ const options = parameters[name] || args;
450
+ if (Array.isArray(value)) {
451
+ const serializedArray = serializeArrayParam({
452
+ allowReserved: options.allowReserved,
453
+ explode: true,
454
+ name,
455
+ style: "form",
456
+ value,
457
+ ...options.array
458
+ });
459
+ if (serializedArray) search.push(serializedArray);
460
+ } else if (typeof value === "object") {
461
+ const serializedObject = serializeObjectParam({
462
+ allowReserved: options.allowReserved,
463
+ explode: true,
464
+ name,
465
+ style: "deepObject",
466
+ value,
467
+ ...options.object
468
+ });
469
+ if (serializedObject) search.push(serializedObject);
470
+ } else {
471
+ const serializedPrimitive = serializePrimitiveParam({
472
+ allowReserved: options.allowReserved,
473
+ name,
474
+ value
475
+ });
476
+ if (serializedPrimitive) search.push(serializedPrimitive);
477
+ }
478
+ }
479
+ }
480
+ return search.join("&");
481
+ };
482
+ return querySerializer;
483
+ };
484
+ var getParseAs = (contentType) => {
485
+ if (!contentType) {
486
+ return "stream";
487
+ }
488
+ const cleanContent = contentType.split(";")[0]?.trim();
489
+ if (!cleanContent) {
490
+ return;
491
+ }
492
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
493
+ return "json";
494
+ }
495
+ if (cleanContent === "multipart/form-data") {
496
+ return "formData";
497
+ }
498
+ if (["application/", "audio/", "image/", "video/"].some(
499
+ (type) => cleanContent.startsWith(type)
500
+ )) {
501
+ return "blob";
502
+ }
503
+ if (cleanContent.startsWith("text/")) {
504
+ return "text";
505
+ }
506
+ return;
507
+ };
508
+ var checkForExistence = (options, name) => {
509
+ if (!name) {
510
+ return false;
511
+ }
512
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
513
+ return true;
514
+ }
515
+ return false;
516
+ };
517
+ var setAuthParams = async ({
518
+ security,
519
+ ...options
520
+ }) => {
521
+ for (const auth of security) {
522
+ if (checkForExistence(options, auth.name)) {
523
+ continue;
524
+ }
525
+ const token = await getAuthToken(auth, options.auth);
526
+ if (!token) {
527
+ continue;
528
+ }
529
+ const name = auth.name ?? "Authorization";
530
+ switch (auth.in) {
531
+ case "query":
532
+ if (!options.query) {
533
+ options.query = {};
534
+ }
535
+ options.query[name] = token;
536
+ break;
537
+ case "cookie":
538
+ options.headers.append("Cookie", `${name}=${token}`);
539
+ break;
540
+ case "header":
541
+ default:
542
+ options.headers.set(name, token);
543
+ break;
544
+ }
545
+ }
546
+ };
547
+ var buildUrl = (options) => {
548
+ const url = getUrl({
549
+ baseUrl: options.baseUrl,
550
+ path: options.path,
551
+ query: options.query,
552
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
553
+ url: options.url
554
+ });
555
+ return url;
556
+ };
557
+ var getUrl = ({
558
+ baseUrl,
559
+ path,
560
+ query,
561
+ querySerializer,
562
+ url: _url
563
+ }) => {
564
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
565
+ let url = (baseUrl ?? "") + pathUrl;
566
+ if (path) {
567
+ url = defaultPathSerializer({ path, url });
568
+ }
569
+ let search = query ? querySerializer(query) : "";
570
+ if (search.startsWith("?")) {
571
+ search = search.substring(1);
572
+ }
573
+ if (search) {
574
+ url += `?${search}`;
575
+ }
576
+ return url;
577
+ };
578
+ var mergeConfigs = (a, b) => {
579
+ const config = { ...a, ...b };
580
+ if (config.baseUrl?.endsWith("/")) {
581
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
582
+ }
583
+ config.headers = mergeHeaders(a.headers, b.headers);
584
+ return config;
585
+ };
586
+ var headersEntries = (headers) => {
587
+ const entries = [];
588
+ headers.forEach((value, key) => {
589
+ entries.push([key, value]);
590
+ });
591
+ return entries;
592
+ };
593
+ var mergeHeaders = (...headers) => {
594
+ const mergedHeaders = new Headers();
595
+ for (const header of headers) {
596
+ if (!header || typeof header !== "object") {
597
+ continue;
598
+ }
599
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
600
+ for (const [key, value] of iterator) {
601
+ if (value === null) {
602
+ mergedHeaders.delete(key);
603
+ } else if (Array.isArray(value)) {
604
+ for (const v of value) {
605
+ mergedHeaders.append(key, v);
606
+ }
607
+ } else if (value !== void 0) {
608
+ mergedHeaders.set(
609
+ key,
610
+ typeof value === "object" ? JSON.stringify(value) : value
611
+ );
612
+ }
613
+ }
614
+ }
615
+ return mergedHeaders;
616
+ };
617
+ var Interceptors = class {
618
+ constructor() {
619
+ this.fns = [];
620
+ }
621
+ clear() {
622
+ this.fns = [];
623
+ }
624
+ eject(id) {
625
+ const index = this.getInterceptorIndex(id);
626
+ if (this.fns[index]) {
627
+ this.fns[index] = null;
628
+ }
629
+ }
630
+ exists(id) {
631
+ const index = this.getInterceptorIndex(id);
632
+ return Boolean(this.fns[index]);
633
+ }
634
+ getInterceptorIndex(id) {
635
+ if (typeof id === "number") {
636
+ return this.fns[id] ? id : -1;
637
+ }
638
+ return this.fns.indexOf(id);
639
+ }
640
+ update(id, fn) {
641
+ const index = this.getInterceptorIndex(id);
642
+ if (this.fns[index]) {
643
+ this.fns[index] = fn;
644
+ return id;
645
+ }
646
+ return false;
647
+ }
648
+ use(fn) {
649
+ this.fns.push(fn);
650
+ return this.fns.length - 1;
651
+ }
652
+ };
653
+ var createInterceptors = () => ({
654
+ error: new Interceptors(),
655
+ request: new Interceptors(),
656
+ response: new Interceptors()
657
+ });
658
+ var defaultQuerySerializer = createQuerySerializer({
659
+ allowReserved: false,
660
+ array: {
661
+ explode: true,
662
+ style: "form"
663
+ },
664
+ object: {
665
+ explode: true,
666
+ style: "deepObject"
667
+ }
668
+ });
669
+ var defaultHeaders = {
670
+ "Content-Type": "application/json"
671
+ };
672
+ var createConfig = (override = {}) => ({
673
+ ...jsonBodySerializer,
674
+ headers: defaultHeaders,
675
+ parseAs: "auto",
676
+ querySerializer: defaultQuerySerializer,
677
+ ...override
678
+ });
679
+
680
+ // src/client/client/client.gen.ts
681
+ var createClient = (config = {}) => {
682
+ let _config = mergeConfigs(createConfig(), config);
683
+ const getConfig = () => ({ ..._config });
684
+ const setConfig = (config2) => {
685
+ _config = mergeConfigs(_config, config2);
686
+ return getConfig();
687
+ };
688
+ const interceptors = createInterceptors();
689
+ const beforeRequest = async (options) => {
690
+ const opts = {
691
+ ..._config,
692
+ ...options,
693
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
694
+ headers: mergeHeaders(_config.headers, options.headers),
695
+ serializedBody: void 0
696
+ };
697
+ if (opts.security) {
698
+ await setAuthParams({
699
+ ...opts,
700
+ security: opts.security
701
+ });
702
+ }
703
+ if (opts.requestValidator) {
704
+ await opts.requestValidator(opts);
705
+ }
706
+ if (opts.body !== void 0 && opts.bodySerializer) {
707
+ opts.serializedBody = opts.bodySerializer(opts.body);
708
+ }
709
+ if (opts.body === void 0 || opts.serializedBody === "") {
710
+ opts.headers.delete("Content-Type");
711
+ }
712
+ const url = buildUrl(opts);
713
+ return { opts, url };
714
+ };
715
+ const request = async (options) => {
716
+ const { opts, url } = await beforeRequest(options);
717
+ for (const fn of interceptors.request.fns) {
718
+ if (fn) {
719
+ await fn(opts);
720
+ }
721
+ }
722
+ const _fetch = opts.fetch;
723
+ const requestInit = {
724
+ ...opts,
725
+ body: getValidRequestBody(opts)
726
+ };
727
+ let response = await _fetch(url, requestInit);
728
+ for (const fn of interceptors.response.fns) {
729
+ if (fn) {
730
+ response = await fn(response, opts);
731
+ }
732
+ }
733
+ const result = {
734
+ response
735
+ };
736
+ if (response.ok) {
737
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
738
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
739
+ let emptyData;
740
+ switch (parseAs) {
741
+ case "arrayBuffer":
742
+ case "blob":
743
+ case "text":
744
+ emptyData = await response[parseAs]();
745
+ break;
746
+ case "formData":
747
+ emptyData = new FormData();
748
+ break;
749
+ case "stream":
750
+ emptyData = response.body;
751
+ break;
752
+ case "json":
753
+ default:
754
+ emptyData = {};
755
+ break;
756
+ }
757
+ return {
758
+ data: emptyData,
759
+ ...result
760
+ };
761
+ }
762
+ let data;
763
+ switch (parseAs) {
764
+ case "arrayBuffer":
765
+ case "blob":
766
+ case "formData":
767
+ case "json":
768
+ case "text":
769
+ data = await response[parseAs]();
770
+ break;
771
+ case "stream":
772
+ return {
773
+ data: response.body,
774
+ ...result
775
+ };
776
+ }
777
+ if (parseAs === "json") {
778
+ if (opts.responseValidator) {
779
+ await opts.responseValidator(data);
780
+ }
781
+ if (opts.responseTransformer) {
782
+ data = await opts.responseTransformer(data);
783
+ }
784
+ }
785
+ return {
786
+ data,
787
+ ...result
788
+ };
789
+ }
790
+ const textError = await response.text();
791
+ let jsonError;
792
+ try {
793
+ jsonError = JSON.parse(textError);
794
+ } catch {
795
+ }
796
+ const error = jsonError ?? textError;
797
+ let finalError = error;
798
+ for (const fn of interceptors.error.fns) {
799
+ if (fn) {
800
+ finalError = await fn(error, response, opts);
801
+ }
802
+ }
803
+ finalError = finalError || {};
804
+ if (opts.throwOnError) {
805
+ throw finalError;
806
+ }
807
+ return {
808
+ error: finalError,
809
+ ...result
810
+ };
811
+ };
812
+ const makeMethodFn = (method) => (options) => request({ ...options, method });
813
+ const makeSseFn = (method) => async (options) => {
814
+ const { opts, url } = await beforeRequest(options);
815
+ return createSseClient({
816
+ ...opts,
817
+ body: opts.body,
818
+ headers: opts.headers,
819
+ method,
820
+ onRequest: async (url2, init) => {
821
+ let request2 = new Request(url2, init);
822
+ const requestInit = {
823
+ ...init,
824
+ method: init.method,
825
+ url: url2
826
+ };
827
+ for (const fn of interceptors.request.fns) {
828
+ if (fn) {
829
+ await fn(requestInit);
830
+ request2 = new Request(requestInit.url, requestInit);
831
+ }
832
+ }
833
+ return request2;
834
+ },
835
+ url
836
+ });
837
+ };
838
+ return {
839
+ buildUrl,
840
+ connect: makeMethodFn("CONNECT"),
841
+ delete: makeMethodFn("DELETE"),
842
+ get: makeMethodFn("GET"),
843
+ getConfig,
844
+ head: makeMethodFn("HEAD"),
845
+ interceptors,
846
+ options: makeMethodFn("OPTIONS"),
847
+ patch: makeMethodFn("PATCH"),
848
+ post: makeMethodFn("POST"),
849
+ put: makeMethodFn("PUT"),
850
+ request,
851
+ setConfig,
852
+ sse: {
853
+ connect: makeSseFn("CONNECT"),
854
+ delete: makeSseFn("DELETE"),
855
+ get: makeSseFn("GET"),
856
+ head: makeSseFn("HEAD"),
857
+ options: makeSseFn("OPTIONS"),
858
+ patch: makeSseFn("PATCH"),
859
+ post: makeSseFn("POST"),
860
+ put: makeSseFn("PUT"),
861
+ trace: makeSseFn("TRACE")
862
+ },
863
+ trace: makeMethodFn("TRACE")
864
+ };
865
+ };
866
+
867
+ // src/clientConfig.ts
868
+ var BASE_URL = "https://portal.anuma-dev.ai";
869
+ var createClientConfig = (config) => ({
870
+ ...config,
871
+ baseUrl: BASE_URL
872
+ });
873
+
874
+ // src/client/client.gen.ts
875
+ var client = createClient(createClientConfig(createConfig()));
876
+
877
+ // src/client/sdk.gen.ts
878
+ var postApiV1AdminAddCredits = (options) => {
879
+ return (options.client ?? client).post({
880
+ url: "/api/v1/admin/add-credits",
881
+ ...options,
882
+ headers: {
883
+ "Content-Type": "application/json",
884
+ ...options.headers
885
+ }
886
+ });
887
+ };
888
+ var getApiV1AdminApps = (options) => {
889
+ return (options.client ?? client).get({
890
+ url: "/api/v1/admin/apps",
891
+ ...options
892
+ });
893
+ };
894
+ var postApiV1AdminApps = (options) => {
895
+ return (options.client ?? client).post({
896
+ url: "/api/v1/admin/apps",
897
+ ...options,
898
+ headers: {
899
+ "Content-Type": "application/json",
900
+ ...options.headers
901
+ }
902
+ });
903
+ };
904
+ var getApiV1AdminAppsByAppIdApiKeys = (options) => {
905
+ return (options.client ?? client).get({
906
+ url: "/api/v1/admin/apps/{app_id}/api-keys",
907
+ ...options
908
+ });
909
+ };
910
+ var postApiV1AdminAppsByAppIdApiKeys = (options) => {
911
+ return (options.client ?? client).post({
912
+ url: "/api/v1/admin/apps/{app_id}/api-keys",
913
+ ...options,
914
+ headers: {
915
+ "Content-Type": "application/json",
916
+ ...options.headers
917
+ }
918
+ });
919
+ };
920
+ var deleteApiV1AdminAppsByAppIdApiKeysById = (options) => {
921
+ return (options.client ?? client).delete({
922
+ url: "/api/v1/admin/apps/{app_id}/api-keys/{id}",
923
+ ...options
924
+ });
925
+ };
926
+ var getApiV1AdminAppsByAppIdApiKeysById = (options) => {
927
+ return (options.client ?? client).get({
928
+ url: "/api/v1/admin/apps/{app_id}/api-keys/{id}",
929
+ ...options
930
+ });
931
+ };
932
+ var putApiV1AdminAppsByAppIdApiKeysById = (options) => {
933
+ return (options.client ?? client).put({
934
+ url: "/api/v1/admin/apps/{app_id}/api-keys/{id}",
935
+ ...options,
936
+ headers: {
937
+ "Content-Type": "application/json",
938
+ ...options.headers
939
+ }
940
+ });
941
+ };
942
+ var deleteApiV1AdminAppsById = (options) => {
943
+ return (options.client ?? client).delete({
944
+ url: "/api/v1/admin/apps/{id}",
945
+ ...options
946
+ });
947
+ };
948
+ var getApiV1AdminAppsById = (options) => {
949
+ return (options.client ?? client).get({
950
+ url: "/api/v1/admin/apps/{id}",
951
+ ...options
952
+ });
953
+ };
954
+ var putApiV1AdminAppsById = (options) => {
955
+ return (options.client ?? client).put({
956
+ url: "/api/v1/admin/apps/{id}",
957
+ ...options,
958
+ headers: {
959
+ "Content-Type": "application/json",
960
+ ...options.headers
961
+ }
962
+ });
963
+ };
964
+ var postApiV1AdminSeedApps = (options) => {
965
+ return (options.client ?? client).post({
966
+ url: "/api/v1/admin/seed-apps",
967
+ ...options,
968
+ headers: {
969
+ "Content-Type": "application/json",
970
+ ...options.headers
971
+ }
972
+ });
973
+ };
974
+ var postApiV1AdminSubscriptionTier = (options) => {
975
+ return (options.client ?? client).post({
976
+ url: "/api/v1/admin/subscription-tier",
977
+ ...options,
978
+ headers: {
979
+ "Content-Type": "application/json",
980
+ ...options.headers
981
+ }
982
+ });
983
+ };
984
+ var postApiV1ChatCompletions = (options) => {
985
+ return (options.client ?? client).post({
986
+ url: "/api/v1/chat/completions",
987
+ ...options,
988
+ headers: {
989
+ "Content-Type": "application/json",
990
+ ...options.headers
991
+ }
992
+ });
993
+ };
994
+ var getApiV1Config = (options) => {
995
+ return (options?.client ?? client).get({
996
+ url: "/api/v1/config",
997
+ ...options
998
+ });
999
+ };
1000
+ var getApiV1CreditsBalance = (options) => {
1001
+ return (options?.client ?? client).get({
1002
+ url: "/api/v1/credits/balance",
1003
+ ...options
1004
+ });
1005
+ };
1006
+ var postApiV1CreditsClaimDaily = (options) => {
1007
+ return (options?.client ?? client).post({
1008
+ url: "/api/v1/credits/claim-daily",
1009
+ ...options
1010
+ });
1011
+ };
1012
+ var getApiV1CreditsPacks = (options) => {
1013
+ return (options?.client ?? client).get({
1014
+ url: "/api/v1/credits/packs",
1015
+ ...options
1016
+ });
1017
+ };
1018
+ var postApiV1CreditsPurchase = (options) => {
1019
+ return (options.client ?? client).post({
1020
+ url: "/api/v1/credits/purchase",
1021
+ ...options,
1022
+ headers: {
1023
+ "Content-Type": "application/json",
1024
+ ...options.headers
1025
+ }
1026
+ });
1027
+ };
1028
+ var postApiV1CreditsSyncSnag = (options) => {
1029
+ return (options?.client ?? client).post({
1030
+ url: "/api/v1/credits/sync-snag",
1031
+ ...options
1032
+ });
1033
+ };
1034
+ var getApiV1DocsSwaggerJson = (options) => {
1035
+ return (options?.client ?? client).get({
1036
+ url: "/api/v1/docs/swagger.json",
1037
+ ...options
1038
+ });
1039
+ };
1040
+ var postApiV1Embeddings = (options) => {
1041
+ return (options.client ?? client).post({
1042
+ url: "/api/v1/embeddings",
1043
+ ...options,
1044
+ headers: {
1045
+ "Content-Type": "application/json",
1046
+ ...options.headers
1047
+ }
1048
+ });
1049
+ };
1050
+ var getApiV1Models = (options) => {
1051
+ return (options?.client ?? client).get({
1052
+ url: "/api/v1/models",
1053
+ ...options
1054
+ });
1055
+ };
1056
+ var postApiV1Responses = (options) => {
1057
+ return (options.client ?? client).post({
1058
+ url: "/api/v1/responses",
1059
+ ...options,
1060
+ headers: {
1061
+ "Content-Type": "application/json",
1062
+ ...options.headers
1063
+ }
1064
+ });
1065
+ };
1066
+ var postApiV1SubscriptionsCancel = (options) => {
1067
+ return (options?.client ?? client).post({
1068
+ url: "/api/v1/subscriptions/cancel",
1069
+ ...options
1070
+ });
1071
+ };
1072
+ var postApiV1SubscriptionsCreateCheckoutSession = (options) => {
1073
+ return (options.client ?? client).post({
1074
+ url: "/api/v1/subscriptions/create-checkout-session",
1075
+ ...options,
1076
+ headers: {
1077
+ "Content-Type": "application/json",
1078
+ ...options.headers
1079
+ }
1080
+ });
1081
+ };
1082
+ var postApiV1SubscriptionsCustomerPortal = (options) => {
1083
+ return (options.client ?? client).post({
1084
+ url: "/api/v1/subscriptions/customer-portal",
1085
+ ...options,
1086
+ headers: {
1087
+ "Content-Type": "application/json",
1088
+ ...options.headers
1089
+ }
1090
+ });
1091
+ };
1092
+ var postApiV1SubscriptionsRenew = (options) => {
1093
+ return (options?.client ?? client).post({
1094
+ url: "/api/v1/subscriptions/renew",
1095
+ ...options
1096
+ });
1097
+ };
1098
+ var getApiV1SubscriptionsStatus = (options) => {
1099
+ return (options?.client ?? client).get({
1100
+ url: "/api/v1/subscriptions/status",
1101
+ ...options
1102
+ });
1103
+ };
1104
+ var postApiV1SubscriptionsWebhook = (options) => {
1105
+ return (options.client ?? client).post({
1106
+ url: "/api/v1/subscriptions/webhook",
1107
+ ...options,
1108
+ headers: {
1109
+ "Content-Type": "application/json",
1110
+ ...options.headers
1111
+ }
1112
+ });
1113
+ };
1114
+ var getApiV1Tasks = (options) => {
1115
+ return (options?.client ?? client).get({
1116
+ url: "/api/v1/tasks",
1117
+ ...options
1118
+ });
1119
+ };
1120
+ var getApiV1Tools = (options) => {
1121
+ return (options?.client ?? client).get({
1122
+ url: "/api/v1/tools",
1123
+ ...options
1124
+ });
1125
+ };
1126
+ var postAuthOauthByProviderExchange = (options) => {
1127
+ return (options.client ?? client).post({
1128
+ url: "/auth/oauth/{provider}/exchange",
1129
+ ...options,
1130
+ headers: {
1131
+ "Content-Type": "application/json",
1132
+ ...options.headers
1133
+ }
1134
+ });
1135
+ };
1136
+ var postAuthOauthByProviderRefresh = (options) => {
1137
+ return (options.client ?? client).post({
1138
+ url: "/auth/oauth/{provider}/refresh",
1139
+ ...options,
1140
+ headers: {
1141
+ "Content-Type": "application/json",
1142
+ ...options.headers
1143
+ }
1144
+ });
1145
+ };
1146
+ var postAuthOauthByProviderRevoke = (options) => {
1147
+ return (options.client ?? client).post({
1148
+ url: "/auth/oauth/{provider}/revoke",
1149
+ ...options,
1150
+ headers: {
1151
+ "Content-Type": "application/json",
1152
+ ...options.headers
1153
+ }
1154
+ });
1155
+ };
1156
+ var getHealth = (options) => {
1157
+ return (options?.client ?? client).get({
1158
+ url: "/health",
1159
+ ...options
1160
+ });
1161
+ };
1162
+ // Annotate the CommonJS export names for ESM import in node:
1163
+ 0 && (module.exports = {
1164
+ deleteApiV1AdminAppsByAppIdApiKeysById,
1165
+ deleteApiV1AdminAppsById,
1166
+ getApiV1AdminApps,
1167
+ getApiV1AdminAppsByAppIdApiKeys,
1168
+ getApiV1AdminAppsByAppIdApiKeysById,
1169
+ getApiV1AdminAppsById,
1170
+ getApiV1Config,
1171
+ getApiV1CreditsBalance,
1172
+ getApiV1CreditsPacks,
1173
+ getApiV1DocsSwaggerJson,
1174
+ getApiV1Models,
1175
+ getApiV1SubscriptionsStatus,
1176
+ getApiV1Tasks,
1177
+ getApiV1Tools,
1178
+ getHealth,
1179
+ postApiV1AdminAddCredits,
1180
+ postApiV1AdminApps,
1181
+ postApiV1AdminAppsByAppIdApiKeys,
1182
+ postApiV1AdminSeedApps,
1183
+ postApiV1AdminSubscriptionTier,
1184
+ postApiV1ChatCompletions,
1185
+ postApiV1CreditsClaimDaily,
1186
+ postApiV1CreditsPurchase,
1187
+ postApiV1CreditsSyncSnag,
1188
+ postApiV1Embeddings,
1189
+ postApiV1Responses,
1190
+ postApiV1SubscriptionsCancel,
1191
+ postApiV1SubscriptionsCreateCheckoutSession,
1192
+ postApiV1SubscriptionsCustomerPortal,
1193
+ postApiV1SubscriptionsRenew,
1194
+ postApiV1SubscriptionsWebhook,
1195
+ postAuthOauthByProviderExchange,
1196
+ postAuthOauthByProviderRefresh,
1197
+ postAuthOauthByProviderRevoke,
1198
+ putApiV1AdminAppsByAppIdApiKeysById,
1199
+ putApiV1AdminAppsById
1200
+ });