@aifeatures/backend 0.1.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/dist/index.cjs ADDED
@@ -0,0 +1,1002 @@
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
+ deleteApiV1FormsByFormId: () => deleteApiV1FormsByFormId,
24
+ deleteApiV1SitesBySiteId: () => deleteApiV1SitesBySiteId,
25
+ deleteApiV1SubmissionsBySubmissionId: () => deleteApiV1SubmissionsBySubmissionId,
26
+ getApiV1Forms: () => getApiV1Forms,
27
+ getApiV1FormsByFormId: () => getApiV1FormsByFormId,
28
+ getApiV1FormsByFormIdSubmissions: () => getApiV1FormsByFormIdSubmissions,
29
+ getApiV1Sites: () => getApiV1Sites,
30
+ getApiV1SitesBySiteId: () => getApiV1SitesBySiteId,
31
+ getApiV1SitesBySiteIdForms: () => getApiV1SitesBySiteIdForms,
32
+ getApiV1SubmissionsBySubmissionId: () => getApiV1SubmissionsBySubmissionId,
33
+ getApiV1SubmissionsBySubmissionIdAttachmentsByFilename: () => getApiV1SubmissionsBySubmissionIdAttachmentsByFilename,
34
+ patchApiV1FormsByFormId: () => patchApiV1FormsByFormId,
35
+ patchApiV1SitesBySiteId: () => patchApiV1SitesBySiteId,
36
+ patchApiV1SitesBySiteIdDomains: () => patchApiV1SitesBySiteIdDomains,
37
+ postApiV1Forms: () => postApiV1Forms,
38
+ postApiV1Sites: () => postApiV1Sites,
39
+ postApiV1SitesBySiteIdForms: () => postApiV1SitesBySiteIdForms
40
+ });
41
+ module.exports = __toCommonJS(index_exports);
42
+
43
+ // src/client/core/bodySerializer.gen.ts
44
+ var jsonBodySerializer = {
45
+ bodySerializer: (body) => JSON.stringify(
46
+ body,
47
+ (_key, value) => typeof value === "bigint" ? value.toString() : value
48
+ )
49
+ };
50
+
51
+ // src/client/core/params.gen.ts
52
+ var extraPrefixesMap = {
53
+ $body_: "body",
54
+ $headers_: "headers",
55
+ $path_: "path",
56
+ $query_: "query"
57
+ };
58
+ var extraPrefixes = Object.entries(extraPrefixesMap);
59
+
60
+ // src/client/core/serverSentEvents.gen.ts
61
+ var createSseClient = ({
62
+ onRequest,
63
+ onSseError,
64
+ onSseEvent,
65
+ responseTransformer,
66
+ responseValidator,
67
+ sseDefaultRetryDelay,
68
+ sseMaxRetryAttempts,
69
+ sseMaxRetryDelay,
70
+ sseSleepFn,
71
+ url,
72
+ ...options
73
+ }) => {
74
+ let lastEventId;
75
+ const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
76
+ const createStream = async function* () {
77
+ let retryDelay = sseDefaultRetryDelay ?? 3e3;
78
+ let attempt = 0;
79
+ const signal = options.signal ?? new AbortController().signal;
80
+ while (true) {
81
+ if (signal.aborted) break;
82
+ attempt++;
83
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
84
+ if (lastEventId !== void 0) {
85
+ headers.set("Last-Event-ID", lastEventId);
86
+ }
87
+ try {
88
+ const requestInit = {
89
+ redirect: "follow",
90
+ ...options,
91
+ body: options.serializedBody,
92
+ headers,
93
+ signal
94
+ };
95
+ let request = new Request(url, requestInit);
96
+ if (onRequest) {
97
+ request = await onRequest(url, requestInit);
98
+ }
99
+ const _fetch = options.fetch ?? globalThis.fetch;
100
+ const response = await _fetch(request);
101
+ if (!response.ok)
102
+ throw new Error(
103
+ `SSE failed: ${response.status} ${response.statusText}`
104
+ );
105
+ if (!response.body) throw new Error("No body in SSE response");
106
+ const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
107
+ let buffer = "";
108
+ const abortHandler = () => {
109
+ try {
110
+ reader.cancel();
111
+ } catch {
112
+ }
113
+ };
114
+ signal.addEventListener("abort", abortHandler);
115
+ try {
116
+ while (true) {
117
+ const { done, value } = await reader.read();
118
+ if (done) break;
119
+ buffer += value;
120
+ buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
121
+ const chunks = buffer.split("\n\n");
122
+ buffer = chunks.pop() ?? "";
123
+ for (const chunk of chunks) {
124
+ const lines = chunk.split("\n");
125
+ const dataLines = [];
126
+ let eventName;
127
+ for (const line of lines) {
128
+ if (line.startsWith("data:")) {
129
+ dataLines.push(line.replace(/^data:\s*/, ""));
130
+ } else if (line.startsWith("event:")) {
131
+ eventName = line.replace(/^event:\s*/, "");
132
+ } else if (line.startsWith("id:")) {
133
+ lastEventId = line.replace(/^id:\s*/, "");
134
+ } else if (line.startsWith("retry:")) {
135
+ const parsed = Number.parseInt(
136
+ line.replace(/^retry:\s*/, ""),
137
+ 10
138
+ );
139
+ if (!Number.isNaN(parsed)) {
140
+ retryDelay = parsed;
141
+ }
142
+ }
143
+ }
144
+ let data;
145
+ let parsedJson = false;
146
+ if (dataLines.length) {
147
+ const rawData = dataLines.join("\n");
148
+ try {
149
+ data = JSON.parse(rawData);
150
+ parsedJson = true;
151
+ } catch {
152
+ data = rawData;
153
+ }
154
+ }
155
+ if (parsedJson) {
156
+ if (responseValidator) {
157
+ await responseValidator(data);
158
+ }
159
+ if (responseTransformer) {
160
+ data = await responseTransformer(data);
161
+ }
162
+ }
163
+ onSseEvent?.({
164
+ data,
165
+ event: eventName,
166
+ id: lastEventId,
167
+ retry: retryDelay
168
+ });
169
+ if (dataLines.length) {
170
+ yield data;
171
+ }
172
+ }
173
+ }
174
+ } finally {
175
+ signal.removeEventListener("abort", abortHandler);
176
+ reader.releaseLock();
177
+ }
178
+ break;
179
+ } catch (error) {
180
+ onSseError?.(error);
181
+ if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
182
+ break;
183
+ }
184
+ const backoff = Math.min(
185
+ retryDelay * 2 ** (attempt - 1),
186
+ sseMaxRetryDelay ?? 3e4
187
+ );
188
+ await sleep(backoff);
189
+ }
190
+ }
191
+ };
192
+ const stream = createStream();
193
+ return { stream };
194
+ };
195
+
196
+ // src/client/core/pathSerializer.gen.ts
197
+ var separatorArrayExplode = (style) => {
198
+ switch (style) {
199
+ case "label":
200
+ return ".";
201
+ case "matrix":
202
+ return ";";
203
+ case "simple":
204
+ return ",";
205
+ default:
206
+ return "&";
207
+ }
208
+ };
209
+ var separatorArrayNoExplode = (style) => {
210
+ switch (style) {
211
+ case "form":
212
+ return ",";
213
+ case "pipeDelimited":
214
+ return "|";
215
+ case "spaceDelimited":
216
+ return "%20";
217
+ default:
218
+ return ",";
219
+ }
220
+ };
221
+ var separatorObjectExplode = (style) => {
222
+ switch (style) {
223
+ case "label":
224
+ return ".";
225
+ case "matrix":
226
+ return ";";
227
+ case "simple":
228
+ return ",";
229
+ default:
230
+ return "&";
231
+ }
232
+ };
233
+ var serializeArrayParam = ({
234
+ allowReserved,
235
+ explode,
236
+ name,
237
+ style,
238
+ value
239
+ }) => {
240
+ if (!explode) {
241
+ const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
242
+ switch (style) {
243
+ case "label":
244
+ return `.${joinedValues2}`;
245
+ case "matrix":
246
+ return `;${name}=${joinedValues2}`;
247
+ case "simple":
248
+ return joinedValues2;
249
+ default:
250
+ return `${name}=${joinedValues2}`;
251
+ }
252
+ }
253
+ const separator = separatorArrayExplode(style);
254
+ const joinedValues = value.map((v) => {
255
+ if (style === "label" || style === "simple") {
256
+ return allowReserved ? v : encodeURIComponent(v);
257
+ }
258
+ return serializePrimitiveParam({
259
+ allowReserved,
260
+ name,
261
+ value: v
262
+ });
263
+ }).join(separator);
264
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
265
+ };
266
+ var serializePrimitiveParam = ({
267
+ allowReserved,
268
+ name,
269
+ value
270
+ }) => {
271
+ if (value === void 0 || value === null) {
272
+ return "";
273
+ }
274
+ if (typeof value === "object") {
275
+ throw new Error(
276
+ "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
277
+ );
278
+ }
279
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
280
+ };
281
+ var serializeObjectParam = ({
282
+ allowReserved,
283
+ explode,
284
+ name,
285
+ style,
286
+ value,
287
+ valueOnly
288
+ }) => {
289
+ if (value instanceof Date) {
290
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
291
+ }
292
+ if (style !== "deepObject" && !explode) {
293
+ let values = [];
294
+ Object.entries(value).forEach(([key, v]) => {
295
+ values = [
296
+ ...values,
297
+ key,
298
+ allowReserved ? v : encodeURIComponent(v)
299
+ ];
300
+ });
301
+ const joinedValues2 = values.join(",");
302
+ switch (style) {
303
+ case "form":
304
+ return `${name}=${joinedValues2}`;
305
+ case "label":
306
+ return `.${joinedValues2}`;
307
+ case "matrix":
308
+ return `;${name}=${joinedValues2}`;
309
+ default:
310
+ return joinedValues2;
311
+ }
312
+ }
313
+ const separator = separatorObjectExplode(style);
314
+ const joinedValues = Object.entries(value).map(
315
+ ([key, v]) => serializePrimitiveParam({
316
+ allowReserved,
317
+ name: style === "deepObject" ? `${name}[${key}]` : key,
318
+ value: v
319
+ })
320
+ ).join(separator);
321
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
322
+ };
323
+
324
+ // src/client/core/utils.gen.ts
325
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
326
+ var defaultPathSerializer = ({ path, url: _url }) => {
327
+ let url = _url;
328
+ const matches = _url.match(PATH_PARAM_RE);
329
+ if (matches) {
330
+ for (const match of matches) {
331
+ let explode = false;
332
+ let name = match.substring(1, match.length - 1);
333
+ let style = "simple";
334
+ if (name.endsWith("*")) {
335
+ explode = true;
336
+ name = name.substring(0, name.length - 1);
337
+ }
338
+ if (name.startsWith(".")) {
339
+ name = name.substring(1);
340
+ style = "label";
341
+ } else if (name.startsWith(";")) {
342
+ name = name.substring(1);
343
+ style = "matrix";
344
+ }
345
+ const value = path[name];
346
+ if (value === void 0 || value === null) {
347
+ continue;
348
+ }
349
+ if (Array.isArray(value)) {
350
+ url = url.replace(
351
+ match,
352
+ serializeArrayParam({ explode, name, style, value })
353
+ );
354
+ continue;
355
+ }
356
+ if (typeof value === "object") {
357
+ url = url.replace(
358
+ match,
359
+ serializeObjectParam({
360
+ explode,
361
+ name,
362
+ style,
363
+ value,
364
+ valueOnly: true
365
+ })
366
+ );
367
+ continue;
368
+ }
369
+ if (style === "matrix") {
370
+ url = url.replace(
371
+ match,
372
+ `;${serializePrimitiveParam({
373
+ name,
374
+ value
375
+ })}`
376
+ );
377
+ continue;
378
+ }
379
+ const replaceValue = encodeURIComponent(
380
+ style === "label" ? `.${value}` : value
381
+ );
382
+ url = url.replace(match, replaceValue);
383
+ }
384
+ }
385
+ return url;
386
+ };
387
+ var getUrl = ({
388
+ baseUrl,
389
+ path,
390
+ query,
391
+ querySerializer,
392
+ url: _url
393
+ }) => {
394
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
395
+ let url = (baseUrl ?? "") + pathUrl;
396
+ if (path) {
397
+ url = defaultPathSerializer({ path, url });
398
+ }
399
+ let search = query ? querySerializer(query) : "";
400
+ if (search.startsWith("?")) {
401
+ search = search.substring(1);
402
+ }
403
+ if (search) {
404
+ url += `?${search}`;
405
+ }
406
+ return url;
407
+ };
408
+ function getValidRequestBody(options) {
409
+ const hasBody = options.body !== void 0;
410
+ const isSerializedBody = hasBody && options.bodySerializer;
411
+ if (isSerializedBody) {
412
+ if ("serializedBody" in options) {
413
+ const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
414
+ return hasSerializedBody ? options.serializedBody : null;
415
+ }
416
+ return options.body !== "" ? options.body : null;
417
+ }
418
+ if (hasBody) {
419
+ return options.body;
420
+ }
421
+ return void 0;
422
+ }
423
+
424
+ // src/client/core/auth.gen.ts
425
+ var getAuthToken = async (auth, callback) => {
426
+ const token = typeof callback === "function" ? await callback(auth) : callback;
427
+ if (!token) {
428
+ return;
429
+ }
430
+ if (auth.scheme === "bearer") {
431
+ return `Bearer ${token}`;
432
+ }
433
+ if (auth.scheme === "basic") {
434
+ return `Basic ${btoa(token)}`;
435
+ }
436
+ return token;
437
+ };
438
+
439
+ // src/client/client/utils.gen.ts
440
+ var createQuerySerializer = ({
441
+ parameters = {},
442
+ ...args
443
+ } = {}) => {
444
+ const querySerializer = (queryParams) => {
445
+ const search = [];
446
+ if (queryParams && typeof queryParams === "object") {
447
+ for (const name in queryParams) {
448
+ const value = queryParams[name];
449
+ if (value === void 0 || value === null) {
450
+ continue;
451
+ }
452
+ const options = parameters[name] || args;
453
+ if (Array.isArray(value)) {
454
+ const serializedArray = serializeArrayParam({
455
+ allowReserved: options.allowReserved,
456
+ explode: true,
457
+ name,
458
+ style: "form",
459
+ value,
460
+ ...options.array
461
+ });
462
+ if (serializedArray) search.push(serializedArray);
463
+ } else if (typeof value === "object") {
464
+ const serializedObject = serializeObjectParam({
465
+ allowReserved: options.allowReserved,
466
+ explode: true,
467
+ name,
468
+ style: "deepObject",
469
+ value,
470
+ ...options.object
471
+ });
472
+ if (serializedObject) search.push(serializedObject);
473
+ } else {
474
+ const serializedPrimitive = serializePrimitiveParam({
475
+ allowReserved: options.allowReserved,
476
+ name,
477
+ value
478
+ });
479
+ if (serializedPrimitive) search.push(serializedPrimitive);
480
+ }
481
+ }
482
+ }
483
+ return search.join("&");
484
+ };
485
+ return querySerializer;
486
+ };
487
+ var getParseAs = (contentType) => {
488
+ if (!contentType) {
489
+ return "stream";
490
+ }
491
+ const cleanContent = contentType.split(";")[0]?.trim();
492
+ if (!cleanContent) {
493
+ return;
494
+ }
495
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
496
+ return "json";
497
+ }
498
+ if (cleanContent === "multipart/form-data") {
499
+ return "formData";
500
+ }
501
+ if (["application/", "audio/", "image/", "video/"].some(
502
+ (type) => cleanContent.startsWith(type)
503
+ )) {
504
+ return "blob";
505
+ }
506
+ if (cleanContent.startsWith("text/")) {
507
+ return "text";
508
+ }
509
+ return;
510
+ };
511
+ var checkForExistence = (options, name) => {
512
+ if (!name) {
513
+ return false;
514
+ }
515
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
516
+ return true;
517
+ }
518
+ return false;
519
+ };
520
+ var setAuthParams = async ({
521
+ security,
522
+ ...options
523
+ }) => {
524
+ for (const auth of security) {
525
+ if (checkForExistence(options, auth.name)) {
526
+ continue;
527
+ }
528
+ const token = await getAuthToken(auth, options.auth);
529
+ if (!token) {
530
+ continue;
531
+ }
532
+ const name = auth.name ?? "Authorization";
533
+ switch (auth.in) {
534
+ case "query":
535
+ if (!options.query) {
536
+ options.query = {};
537
+ }
538
+ options.query[name] = token;
539
+ break;
540
+ case "cookie":
541
+ options.headers.append("Cookie", `${name}=${token}`);
542
+ break;
543
+ case "header":
544
+ default:
545
+ options.headers.set(name, token);
546
+ break;
547
+ }
548
+ }
549
+ };
550
+ var buildUrl = (options) => getUrl({
551
+ baseUrl: options.baseUrl,
552
+ path: options.path,
553
+ query: options.query,
554
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
555
+ url: options.url
556
+ });
557
+ var mergeConfigs = (a, b) => {
558
+ const config = { ...a, ...b };
559
+ if (config.baseUrl?.endsWith("/")) {
560
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
561
+ }
562
+ config.headers = mergeHeaders(a.headers, b.headers);
563
+ return config;
564
+ };
565
+ var headersEntries = (headers) => {
566
+ const entries = [];
567
+ headers.forEach((value, key) => {
568
+ entries.push([key, value]);
569
+ });
570
+ return entries;
571
+ };
572
+ var mergeHeaders = (...headers) => {
573
+ const mergedHeaders = new Headers();
574
+ for (const header of headers) {
575
+ if (!header) {
576
+ continue;
577
+ }
578
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
579
+ for (const [key, value] of iterator) {
580
+ if (value === null) {
581
+ mergedHeaders.delete(key);
582
+ } else if (Array.isArray(value)) {
583
+ for (const v of value) {
584
+ mergedHeaders.append(key, v);
585
+ }
586
+ } else if (value !== void 0) {
587
+ mergedHeaders.set(
588
+ key,
589
+ typeof value === "object" ? JSON.stringify(value) : value
590
+ );
591
+ }
592
+ }
593
+ }
594
+ return mergedHeaders;
595
+ };
596
+ var Interceptors = class {
597
+ constructor() {
598
+ this.fns = [];
599
+ }
600
+ clear() {
601
+ this.fns = [];
602
+ }
603
+ eject(id) {
604
+ const index = this.getInterceptorIndex(id);
605
+ if (this.fns[index]) {
606
+ this.fns[index] = null;
607
+ }
608
+ }
609
+ exists(id) {
610
+ const index = this.getInterceptorIndex(id);
611
+ return Boolean(this.fns[index]);
612
+ }
613
+ getInterceptorIndex(id) {
614
+ if (typeof id === "number") {
615
+ return this.fns[id] ? id : -1;
616
+ }
617
+ return this.fns.indexOf(id);
618
+ }
619
+ update(id, fn) {
620
+ const index = this.getInterceptorIndex(id);
621
+ if (this.fns[index]) {
622
+ this.fns[index] = fn;
623
+ return id;
624
+ }
625
+ return false;
626
+ }
627
+ use(fn) {
628
+ this.fns.push(fn);
629
+ return this.fns.length - 1;
630
+ }
631
+ };
632
+ var createInterceptors = () => ({
633
+ error: new Interceptors(),
634
+ request: new Interceptors(),
635
+ response: new Interceptors()
636
+ });
637
+ var defaultQuerySerializer = createQuerySerializer({
638
+ allowReserved: false,
639
+ array: {
640
+ explode: true,
641
+ style: "form"
642
+ },
643
+ object: {
644
+ explode: true,
645
+ style: "deepObject"
646
+ }
647
+ });
648
+ var defaultHeaders = {
649
+ "Content-Type": "application/json"
650
+ };
651
+ var createConfig = (override = {}) => ({
652
+ ...jsonBodySerializer,
653
+ headers: defaultHeaders,
654
+ parseAs: "auto",
655
+ querySerializer: defaultQuerySerializer,
656
+ ...override
657
+ });
658
+
659
+ // src/client/client/client.gen.ts
660
+ var createClient = (config = {}) => {
661
+ let _config = mergeConfigs(createConfig(), config);
662
+ const getConfig = () => ({ ..._config });
663
+ const setConfig = (config2) => {
664
+ _config = mergeConfigs(_config, config2);
665
+ return getConfig();
666
+ };
667
+ const interceptors = createInterceptors();
668
+ const beforeRequest = async (options) => {
669
+ const opts = {
670
+ ..._config,
671
+ ...options,
672
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
673
+ headers: mergeHeaders(_config.headers, options.headers),
674
+ serializedBody: void 0
675
+ };
676
+ if (opts.security) {
677
+ await setAuthParams({
678
+ ...opts,
679
+ security: opts.security
680
+ });
681
+ }
682
+ if (opts.requestValidator) {
683
+ await opts.requestValidator(opts);
684
+ }
685
+ if (opts.body !== void 0 && opts.bodySerializer) {
686
+ opts.serializedBody = opts.bodySerializer(opts.body);
687
+ }
688
+ if (opts.body === void 0 || opts.serializedBody === "") {
689
+ opts.headers.delete("Content-Type");
690
+ }
691
+ const url = buildUrl(opts);
692
+ return { opts, url };
693
+ };
694
+ const request = async (options) => {
695
+ const { opts, url } = await beforeRequest(options);
696
+ const requestInit = {
697
+ redirect: "follow",
698
+ ...opts,
699
+ body: getValidRequestBody(opts)
700
+ };
701
+ let request2 = new Request(url, requestInit);
702
+ for (const fn of interceptors.request.fns) {
703
+ if (fn) {
704
+ request2 = await fn(request2, opts);
705
+ }
706
+ }
707
+ const _fetch = opts.fetch;
708
+ let response;
709
+ try {
710
+ response = await _fetch(request2);
711
+ } catch (error2) {
712
+ let finalError2 = error2;
713
+ for (const fn of interceptors.error.fns) {
714
+ if (fn) {
715
+ finalError2 = await fn(
716
+ error2,
717
+ void 0,
718
+ request2,
719
+ opts
720
+ );
721
+ }
722
+ }
723
+ finalError2 = finalError2 || {};
724
+ if (opts.throwOnError) {
725
+ throw finalError2;
726
+ }
727
+ return opts.responseStyle === "data" ? void 0 : {
728
+ error: finalError2,
729
+ request: request2,
730
+ response: void 0
731
+ };
732
+ }
733
+ for (const fn of interceptors.response.fns) {
734
+ if (fn) {
735
+ response = await fn(response, request2, opts);
736
+ }
737
+ }
738
+ const result = {
739
+ request: request2,
740
+ response
741
+ };
742
+ if (response.ok) {
743
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
744
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
745
+ let emptyData;
746
+ switch (parseAs) {
747
+ case "arrayBuffer":
748
+ case "blob":
749
+ case "text":
750
+ emptyData = await response[parseAs]();
751
+ break;
752
+ case "formData":
753
+ emptyData = new FormData();
754
+ break;
755
+ case "stream":
756
+ emptyData = response.body;
757
+ break;
758
+ case "json":
759
+ default:
760
+ emptyData = {};
761
+ break;
762
+ }
763
+ return opts.responseStyle === "data" ? emptyData : {
764
+ data: emptyData,
765
+ ...result
766
+ };
767
+ }
768
+ let data;
769
+ switch (parseAs) {
770
+ case "arrayBuffer":
771
+ case "blob":
772
+ case "formData":
773
+ case "json":
774
+ case "text":
775
+ data = await response[parseAs]();
776
+ break;
777
+ case "stream":
778
+ return opts.responseStyle === "data" ? response.body : {
779
+ data: response.body,
780
+ ...result
781
+ };
782
+ }
783
+ if (parseAs === "json") {
784
+ if (opts.responseValidator) {
785
+ await opts.responseValidator(data);
786
+ }
787
+ if (opts.responseTransformer) {
788
+ data = await opts.responseTransformer(data);
789
+ }
790
+ }
791
+ return opts.responseStyle === "data" ? data : {
792
+ data,
793
+ ...result
794
+ };
795
+ }
796
+ const textError = await response.text();
797
+ let jsonError;
798
+ try {
799
+ jsonError = JSON.parse(textError);
800
+ } catch {
801
+ }
802
+ const error = jsonError ?? textError;
803
+ let finalError = error;
804
+ for (const fn of interceptors.error.fns) {
805
+ if (fn) {
806
+ finalError = await fn(error, response, request2, opts);
807
+ }
808
+ }
809
+ finalError = finalError || {};
810
+ if (opts.throwOnError) {
811
+ throw finalError;
812
+ }
813
+ return opts.responseStyle === "data" ? void 0 : {
814
+ error: finalError,
815
+ ...result
816
+ };
817
+ };
818
+ const makeMethodFn = (method) => (options) => request({ ...options, method });
819
+ const makeSseFn = (method) => async (options) => {
820
+ const { opts, url } = await beforeRequest(options);
821
+ return createSseClient({
822
+ ...opts,
823
+ body: opts.body,
824
+ headers: opts.headers,
825
+ method,
826
+ onRequest: async (url2, init) => {
827
+ let request2 = new Request(url2, init);
828
+ for (const fn of interceptors.request.fns) {
829
+ if (fn) {
830
+ request2 = await fn(request2, opts);
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/client/client.gen.ts
868
+ var client = createClient(
869
+ createConfig({ baseUrl: "https://aifeatures.dev/api/v1" })
870
+ );
871
+
872
+ // src/client/sdk.gen.ts
873
+ var getApiV1Forms = (options) => (options?.client ?? client).get({
874
+ security: [{ scheme: "bearer", type: "http" }],
875
+ url: "/api/v1/forms",
876
+ ...options
877
+ });
878
+ var postApiV1Forms = (options) => (options.client ?? client).post({
879
+ security: [{ scheme: "bearer", type: "http" }],
880
+ url: "/api/v1/forms",
881
+ ...options,
882
+ headers: {
883
+ "Content-Type": "application/json",
884
+ ...options.headers
885
+ }
886
+ });
887
+ var getApiV1Sites = (options) => (options?.client ?? client).get({
888
+ security: [{ scheme: "bearer", type: "http" }],
889
+ url: "/api/v1/sites",
890
+ ...options
891
+ });
892
+ var postApiV1Sites = (options) => (options.client ?? client).post({
893
+ security: [{ scheme: "bearer", type: "http" }],
894
+ url: "/api/v1/sites",
895
+ ...options,
896
+ headers: {
897
+ "Content-Type": "application/json",
898
+ ...options.headers
899
+ }
900
+ });
901
+ var deleteApiV1SitesBySiteId = (options) => (options.client ?? client).delete({
902
+ security: [{ scheme: "bearer", type: "http" }],
903
+ url: "/api/v1/sites/{siteId}",
904
+ ...options
905
+ });
906
+ var getApiV1SitesBySiteId = (options) => (options.client ?? client).get({
907
+ security: [{ scheme: "bearer", type: "http" }],
908
+ url: "/api/v1/sites/{siteId}",
909
+ ...options
910
+ });
911
+ var patchApiV1SitesBySiteId = (options) => (options.client ?? client).patch({
912
+ security: [{ scheme: "bearer", type: "http" }],
913
+ url: "/api/v1/sites/{siteId}",
914
+ ...options,
915
+ headers: {
916
+ "Content-Type": "application/json",
917
+ ...options.headers
918
+ }
919
+ });
920
+ var patchApiV1SitesBySiteIdDomains = (options) => (options.client ?? client).patch({
921
+ security: [{ scheme: "bearer", type: "http" }],
922
+ url: "/api/v1/sites/{siteId}/domains",
923
+ ...options,
924
+ headers: {
925
+ "Content-Type": "application/json",
926
+ ...options.headers
927
+ }
928
+ });
929
+ var getApiV1SitesBySiteIdForms = (options) => (options.client ?? client).get({
930
+ security: [{ scheme: "bearer", type: "http" }],
931
+ url: "/api/v1/sites/{siteId}/forms",
932
+ ...options
933
+ });
934
+ var postApiV1SitesBySiteIdForms = (options) => (options.client ?? client).post({
935
+ security: [{ scheme: "bearer", type: "http" }],
936
+ url: "/api/v1/sites/{siteId}/forms",
937
+ ...options,
938
+ headers: {
939
+ "Content-Type": "application/json",
940
+ ...options.headers
941
+ }
942
+ });
943
+ var deleteApiV1FormsByFormId = (options) => (options.client ?? client).delete({
944
+ security: [{ scheme: "bearer", type: "http" }],
945
+ url: "/api/v1/forms/{formId}",
946
+ ...options
947
+ });
948
+ var getApiV1FormsByFormId = (options) => (options.client ?? client).get({
949
+ security: [{ scheme: "bearer", type: "http" }],
950
+ url: "/api/v1/forms/{formId}",
951
+ ...options
952
+ });
953
+ var patchApiV1FormsByFormId = (options) => (options.client ?? client).patch({
954
+ security: [{ scheme: "bearer", type: "http" }],
955
+ url: "/api/v1/forms/{formId}",
956
+ ...options,
957
+ headers: {
958
+ "Content-Type": "application/json",
959
+ ...options.headers
960
+ }
961
+ });
962
+ var getApiV1FormsByFormIdSubmissions = (options) => (options.client ?? client).get({
963
+ security: [{ scheme: "bearer", type: "http" }],
964
+ url: "/api/v1/forms/{formId}/submissions",
965
+ ...options
966
+ });
967
+ var deleteApiV1SubmissionsBySubmissionId = (options) => (options.client ?? client).delete({
968
+ security: [{ scheme: "bearer", type: "http" }],
969
+ url: "/api/v1/submissions/{submissionId}",
970
+ ...options
971
+ });
972
+ var getApiV1SubmissionsBySubmissionId = (options) => (options.client ?? client).get({
973
+ security: [{ scheme: "bearer", type: "http" }],
974
+ url: "/api/v1/submissions/{submissionId}",
975
+ ...options
976
+ });
977
+ var getApiV1SubmissionsBySubmissionIdAttachmentsByFilename = (options) => (options.client ?? client).get({
978
+ security: [{ scheme: "bearer", type: "http" }],
979
+ url: "/api/v1/submissions/{submissionId}/attachments/{filename}",
980
+ ...options
981
+ });
982
+ // Annotate the CommonJS export names for ESM import in node:
983
+ 0 && (module.exports = {
984
+ deleteApiV1FormsByFormId,
985
+ deleteApiV1SitesBySiteId,
986
+ deleteApiV1SubmissionsBySubmissionId,
987
+ getApiV1Forms,
988
+ getApiV1FormsByFormId,
989
+ getApiV1FormsByFormIdSubmissions,
990
+ getApiV1Sites,
991
+ getApiV1SitesBySiteId,
992
+ getApiV1SitesBySiteIdForms,
993
+ getApiV1SubmissionsBySubmissionId,
994
+ getApiV1SubmissionsBySubmissionIdAttachmentsByFilename,
995
+ patchApiV1FormsByFormId,
996
+ patchApiV1SitesBySiteId,
997
+ patchApiV1SitesBySiteIdDomains,
998
+ postApiV1Forms,
999
+ postApiV1Sites,
1000
+ postApiV1SitesBySiteIdForms
1001
+ });
1002
+ //# sourceMappingURL=index.cjs.map