@usenadia/node 0.0.0-stage → 0.1.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,1729 @@
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
+ DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
24
+ Nadia: () => Nadia,
25
+ NadiaError: () => NadiaError,
26
+ callVideoFunction: () => callVideoFunction,
27
+ changePostStatus: () => changePostStatus,
28
+ checkConnection: () => checkConnection,
29
+ createAutomationFlow: () => createAutomationFlow,
30
+ createContent: () => createContent,
31
+ createPost: () => createPost,
32
+ createWebhook: () => createWebhook,
33
+ default: () => index_default,
34
+ deleteAutomationFlow: () => deleteAutomationFlow,
35
+ deleteAutomationPose: () => deleteAutomationPose,
36
+ deleteChannel: () => deleteChannel,
37
+ deleteComment: () => deleteComment,
38
+ deleteContent: () => deleteContent,
39
+ deletePost: () => deletePost,
40
+ deletePostGroup: () => deletePostGroup,
41
+ deleteWebhook: () => deleteWebhook,
42
+ findSlot: () => findSlot,
43
+ generateVideo: () => generateVideo,
44
+ getAccountHistory: () => getAccountHistory,
45
+ getAutomationFlow: () => getAutomationFlow,
46
+ getAutomationPose: () => getAutomationPose,
47
+ getChannelAnalytics: () => getChannelAnalytics,
48
+ getChannelSettings: () => getChannelSettings,
49
+ getContent: () => getContent,
50
+ getContentsPerformance: () => getContentsPerformance,
51
+ getConversation: () => getConversation,
52
+ getHookForms: () => getHookForms,
53
+ getMusicTrack: () => getMusicTrack,
54
+ getPostAnalytics: () => getPostAnalytics,
55
+ getVideoHistory: () => getVideoHistory,
56
+ getWebhook: () => getWebhook,
57
+ hideComment: () => hideComment,
58
+ importHooks: () => importHooks,
59
+ importMusic: () => importMusic,
60
+ linkContentPost: () => linkContentPost,
61
+ listAutomationFlowPoses: () => listAutomationFlowPoses,
62
+ listAutomationFlows: () => listAutomationFlows,
63
+ listAutomationPoseRuns: () => listAutomationPoseRuns,
64
+ listChannelAutomationPoses: () => listChannelAutomationPoses,
65
+ listChannelMedia: () => listChannelMedia,
66
+ listChannelStories: () => listChannelStories,
67
+ listChannels: () => listChannels,
68
+ listContents: () => listContents,
69
+ listConversations: () => listConversations,
70
+ listGroups: () => listGroups,
71
+ listHookFamilies: () => listHookFamilies,
72
+ listMediaComments: () => listMediaComments,
73
+ listMissingMedia: () => listMissingMedia,
74
+ listMusic: () => listMusic,
75
+ listMusicPillars: () => listMusicPillars,
76
+ listNotifications: () => listNotifications,
77
+ listPosts: () => listPosts,
78
+ listVideoPerformance: () => listVideoPerformance,
79
+ listWebhookEvents: () => listWebhookEvents,
80
+ listWebhooks: () => listWebhooks,
81
+ moveContent: () => moveContent,
82
+ pollAutomationPose: () => pollAutomationPose,
83
+ pollInbox: () => pollInbox,
84
+ poseAutomationFlow: () => poseAutomationFlow,
85
+ previewAutomationEmail: () => previewAutomationEmail,
86
+ replaceHookFamilies: () => replaceHookFamilies,
87
+ replayAutomationPose: () => replayAutomationPose,
88
+ replyToComment: () => replyToComment,
89
+ runChannelTool: () => runChannelTool,
90
+ searchHooks: () => searchHooks,
91
+ sendAutomationTestEmail: () => sendAutomationTestEmail,
92
+ sendDirectMessage: () => sendDirectMessage,
93
+ setAutomationFlowStatus: () => setAutomationFlowStatus,
94
+ setPostReleaseId: () => setPostReleaseId,
95
+ startChannelConnection: () => startChannelConnection,
96
+ subscribeInboxWebhook: () => subscribeInboxWebhook,
97
+ updateAutomationFlow: () => updateAutomationFlow,
98
+ updateAutomationPose: () => updateAutomationPose,
99
+ updateContent: () => updateContent,
100
+ uploadFile: () => uploadFile,
101
+ uploadFromUrl: () => uploadFromUrl,
102
+ uploadMusicFile: () => uploadMusicFile,
103
+ upsertContent: () => upsertContent
104
+ });
105
+ module.exports = __toCommonJS(index_exports);
106
+
107
+ // src/generated/core/bodySerializer.gen.ts
108
+ var serializeFormDataPair = (data, key, value) => {
109
+ if (typeof value === "string" || value instanceof Blob) {
110
+ data.append(key, value);
111
+ } else if (value instanceof Date) {
112
+ data.append(key, value.toISOString());
113
+ } else {
114
+ data.append(key, JSON.stringify(value));
115
+ }
116
+ };
117
+ var formDataBodySerializer = {
118
+ bodySerializer: (body) => {
119
+ const data = new FormData();
120
+ Object.entries(body).forEach(([key, value]) => {
121
+ if (value === void 0 || value === null) {
122
+ return;
123
+ }
124
+ if (Array.isArray(value)) {
125
+ value.forEach((v) => serializeFormDataPair(data, key, v));
126
+ } else {
127
+ serializeFormDataPair(data, key, value);
128
+ }
129
+ });
130
+ return data;
131
+ }
132
+ };
133
+ var jsonBodySerializer = {
134
+ bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
135
+ };
136
+
137
+ // src/generated/core/params.gen.ts
138
+ var extraPrefixesMap = {
139
+ $body_: "body",
140
+ $headers_: "headers",
141
+ $path_: "path",
142
+ $query_: "query"
143
+ };
144
+ var extraPrefixes = Object.entries(extraPrefixesMap);
145
+
146
+ // src/generated/core/serverSentEvents.gen.ts
147
+ function createSseClient({
148
+ onRequest,
149
+ onSseError,
150
+ onSseEvent,
151
+ responseTransformer,
152
+ responseValidator,
153
+ sseDefaultRetryDelay,
154
+ sseMaxRetryAttempts,
155
+ sseMaxRetryDelay,
156
+ sseSleepFn,
157
+ url,
158
+ ...options
159
+ }) {
160
+ let lastEventId;
161
+ const sleep2 = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
162
+ const createStream = async function* () {
163
+ let retryDelay = sseDefaultRetryDelay ?? 3e3;
164
+ let attempt = 0;
165
+ const signal = options.signal ?? new AbortController().signal;
166
+ while (true) {
167
+ if (signal.aborted) break;
168
+ attempt++;
169
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
170
+ if (lastEventId !== void 0) {
171
+ headers.set("Last-Event-ID", lastEventId);
172
+ }
173
+ try {
174
+ const requestInit = {
175
+ redirect: "follow",
176
+ ...options,
177
+ body: options.serializedBody,
178
+ headers,
179
+ signal
180
+ };
181
+ let request = new Request(url, requestInit);
182
+ if (onRequest) {
183
+ request = await onRequest(url, requestInit);
184
+ }
185
+ const _fetch = options.fetch ?? globalThis.fetch;
186
+ const response = await _fetch(request);
187
+ if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
188
+ if (!response.body) throw new Error("No body in SSE response");
189
+ const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
190
+ let buffer = "";
191
+ const abortHandler = () => {
192
+ try {
193
+ reader.cancel();
194
+ } catch {
195
+ }
196
+ };
197
+ signal.addEventListener("abort", abortHandler);
198
+ try {
199
+ while (true) {
200
+ const { done, value } = await reader.read();
201
+ if (done) break;
202
+ buffer += value;
203
+ buffer = buffer.replace(/\r\n?/g, "\n");
204
+ const chunks = buffer.split("\n\n");
205
+ buffer = chunks.pop() ?? "";
206
+ for (const chunk of chunks) {
207
+ const lines = chunk.split("\n");
208
+ const dataLines = [];
209
+ let eventName;
210
+ for (const line of lines) {
211
+ if (line.startsWith("data:")) {
212
+ dataLines.push(line.replace(/^data:\s*/, ""));
213
+ } else if (line.startsWith("event:")) {
214
+ eventName = line.replace(/^event:\s*/, "");
215
+ } else if (line.startsWith("id:")) {
216
+ lastEventId = line.replace(/^id:\s*/, "");
217
+ } else if (line.startsWith("retry:")) {
218
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
219
+ if (!Number.isNaN(parsed)) {
220
+ retryDelay = parsed;
221
+ }
222
+ }
223
+ }
224
+ let data;
225
+ let parsedJson = false;
226
+ if (dataLines.length) {
227
+ const rawData = dataLines.join("\n");
228
+ try {
229
+ data = JSON.parse(rawData);
230
+ parsedJson = true;
231
+ } catch {
232
+ data = rawData;
233
+ }
234
+ }
235
+ if (parsedJson) {
236
+ if (responseValidator) {
237
+ await responseValidator(data);
238
+ }
239
+ if (responseTransformer) {
240
+ data = await responseTransformer(data);
241
+ }
242
+ }
243
+ onSseEvent?.({
244
+ data,
245
+ event: eventName,
246
+ id: lastEventId,
247
+ retry: retryDelay
248
+ });
249
+ if (dataLines.length) {
250
+ yield data;
251
+ }
252
+ }
253
+ }
254
+ } finally {
255
+ signal.removeEventListener("abort", abortHandler);
256
+ reader.releaseLock();
257
+ }
258
+ break;
259
+ } catch (error) {
260
+ onSseError?.(error);
261
+ if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
262
+ break;
263
+ }
264
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
265
+ await sleep2(backoff);
266
+ }
267
+ }
268
+ };
269
+ const stream = createStream();
270
+ return { stream };
271
+ }
272
+
273
+ // src/generated/core/pathSerializer.gen.ts
274
+ var separatorArrayExplode = (style) => {
275
+ switch (style) {
276
+ case "label":
277
+ return ".";
278
+ case "matrix":
279
+ return ";";
280
+ case "simple":
281
+ return ",";
282
+ default:
283
+ return "&";
284
+ }
285
+ };
286
+ var separatorArrayNoExplode = (style) => {
287
+ switch (style) {
288
+ case "form":
289
+ return ",";
290
+ case "pipeDelimited":
291
+ return "|";
292
+ case "spaceDelimited":
293
+ return "%20";
294
+ default:
295
+ return ",";
296
+ }
297
+ };
298
+ var separatorObjectExplode = (style) => {
299
+ switch (style) {
300
+ case "label":
301
+ return ".";
302
+ case "matrix":
303
+ return ";";
304
+ case "simple":
305
+ return ",";
306
+ default:
307
+ return "&";
308
+ }
309
+ };
310
+ var serializeArrayParam = ({
311
+ allowReserved,
312
+ explode,
313
+ name,
314
+ style,
315
+ value
316
+ }) => {
317
+ if (!explode) {
318
+ const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
319
+ switch (style) {
320
+ case "label":
321
+ return `.${joinedValues2}`;
322
+ case "matrix":
323
+ return `;${name}=${joinedValues2}`;
324
+ case "simple":
325
+ return joinedValues2;
326
+ default:
327
+ return `${name}=${joinedValues2}`;
328
+ }
329
+ }
330
+ const separator = separatorArrayExplode(style);
331
+ const joinedValues = value.map((v) => {
332
+ if (style === "label" || style === "simple") {
333
+ return allowReserved ? v : encodeURIComponent(v);
334
+ }
335
+ return serializePrimitiveParam({
336
+ allowReserved,
337
+ name,
338
+ value: v
339
+ });
340
+ }).join(separator);
341
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
342
+ };
343
+ var serializePrimitiveParam = ({
344
+ allowReserved,
345
+ name,
346
+ value
347
+ }) => {
348
+ if (value === void 0 || value === null) {
349
+ return "";
350
+ }
351
+ if (typeof value === "object") {
352
+ throw new Error(
353
+ "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
354
+ );
355
+ }
356
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
357
+ };
358
+ var serializeObjectParam = ({
359
+ allowReserved,
360
+ explode,
361
+ name,
362
+ style,
363
+ value,
364
+ valueOnly
365
+ }) => {
366
+ if (value instanceof Date) {
367
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
368
+ }
369
+ if (style !== "deepObject" && !explode) {
370
+ let values = [];
371
+ Object.entries(value).forEach(([key, v]) => {
372
+ values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
373
+ });
374
+ const joinedValues2 = values.join(",");
375
+ switch (style) {
376
+ case "form":
377
+ return `${name}=${joinedValues2}`;
378
+ case "label":
379
+ return `.${joinedValues2}`;
380
+ case "matrix":
381
+ return `;${name}=${joinedValues2}`;
382
+ default:
383
+ return joinedValues2;
384
+ }
385
+ }
386
+ const separator = separatorObjectExplode(style);
387
+ const joinedValues = Object.entries(value).map(
388
+ ([key, v]) => serializePrimitiveParam({
389
+ allowReserved,
390
+ name: style === "deepObject" ? `${name}[${key}]` : key,
391
+ value: v
392
+ })
393
+ ).join(separator);
394
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
395
+ };
396
+
397
+ // src/generated/core/utils.gen.ts
398
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
399
+ var defaultPathSerializer = ({ path, url: _url }) => {
400
+ let url = _url;
401
+ const matches = _url.match(PATH_PARAM_RE);
402
+ if (matches) {
403
+ for (const match of matches) {
404
+ let explode = false;
405
+ let name = match.substring(1, match.length - 1);
406
+ let style = "simple";
407
+ if (name.endsWith("*")) {
408
+ explode = true;
409
+ name = name.substring(0, name.length - 1);
410
+ }
411
+ if (name.startsWith(".")) {
412
+ name = name.substring(1);
413
+ style = "label";
414
+ } else if (name.startsWith(";")) {
415
+ name = name.substring(1);
416
+ style = "matrix";
417
+ }
418
+ const value = path[name];
419
+ if (value === void 0 || value === null) {
420
+ continue;
421
+ }
422
+ if (Array.isArray(value)) {
423
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
424
+ continue;
425
+ }
426
+ if (typeof value === "object") {
427
+ url = url.replace(
428
+ match,
429
+ serializeObjectParam({
430
+ explode,
431
+ name,
432
+ style,
433
+ value,
434
+ valueOnly: true
435
+ })
436
+ );
437
+ continue;
438
+ }
439
+ if (style === "matrix") {
440
+ url = url.replace(
441
+ match,
442
+ `;${serializePrimitiveParam({
443
+ name,
444
+ value
445
+ })}`
446
+ );
447
+ continue;
448
+ }
449
+ const replaceValue = encodeURIComponent(
450
+ style === "label" ? `.${value}` : value
451
+ );
452
+ url = url.replace(match, replaceValue);
453
+ }
454
+ }
455
+ return url;
456
+ };
457
+ var getUrl = ({
458
+ baseUrl,
459
+ path,
460
+ query,
461
+ querySerializer,
462
+ url: _url
463
+ }) => {
464
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
465
+ let url = (baseUrl ?? "") + pathUrl;
466
+ if (path) {
467
+ url = defaultPathSerializer({ path, url });
468
+ }
469
+ let search = query ? querySerializer(query) : "";
470
+ if (search.startsWith("?")) {
471
+ search = search.substring(1);
472
+ }
473
+ if (search) {
474
+ url += `?${search}`;
475
+ }
476
+ return url;
477
+ };
478
+ function getValidRequestBody(options) {
479
+ const hasBody = options.body !== void 0;
480
+ const isSerializedBody = hasBody && options.bodySerializer;
481
+ if (isSerializedBody) {
482
+ if ("serializedBody" in options) {
483
+ const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
484
+ return hasSerializedBody ? options.serializedBody : null;
485
+ }
486
+ return options.body !== "" ? options.body : null;
487
+ }
488
+ if (hasBody) {
489
+ return options.body;
490
+ }
491
+ return void 0;
492
+ }
493
+
494
+ // src/generated/core/auth.gen.ts
495
+ var getAuthToken = async (auth, callback) => {
496
+ const token = typeof callback === "function" ? await callback(auth) : callback;
497
+ if (!token) {
498
+ return;
499
+ }
500
+ if (auth.scheme === "bearer") {
501
+ return `Bearer ${token}`;
502
+ }
503
+ if (auth.scheme === "basic") {
504
+ return `Basic ${btoa(token)}`;
505
+ }
506
+ return token;
507
+ };
508
+
509
+ // src/generated/client/utils.gen.ts
510
+ var createQuerySerializer = ({
511
+ parameters = {},
512
+ ...args
513
+ } = {}) => {
514
+ const querySerializer = (queryParams) => {
515
+ const search = [];
516
+ if (queryParams && typeof queryParams === "object") {
517
+ for (const name in queryParams) {
518
+ const value = queryParams[name];
519
+ if (value === void 0 || value === null) {
520
+ continue;
521
+ }
522
+ const options = parameters[name] || args;
523
+ if (Array.isArray(value)) {
524
+ const serializedArray = serializeArrayParam({
525
+ allowReserved: options.allowReserved,
526
+ explode: true,
527
+ name,
528
+ style: "form",
529
+ value,
530
+ ...options.array
531
+ });
532
+ if (serializedArray) search.push(serializedArray);
533
+ } else if (typeof value === "object") {
534
+ const serializedObject = serializeObjectParam({
535
+ allowReserved: options.allowReserved,
536
+ explode: true,
537
+ name,
538
+ style: "deepObject",
539
+ value,
540
+ ...options.object
541
+ });
542
+ if (serializedObject) search.push(serializedObject);
543
+ } else {
544
+ const serializedPrimitive = serializePrimitiveParam({
545
+ allowReserved: options.allowReserved,
546
+ name,
547
+ value
548
+ });
549
+ if (serializedPrimitive) search.push(serializedPrimitive);
550
+ }
551
+ }
552
+ }
553
+ return search.join("&");
554
+ };
555
+ return querySerializer;
556
+ };
557
+ var getParseAs = (contentType) => {
558
+ if (!contentType) {
559
+ return "stream";
560
+ }
561
+ const cleanContent = contentType.split(";")[0]?.trim();
562
+ if (!cleanContent) {
563
+ return;
564
+ }
565
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
566
+ return "json";
567
+ }
568
+ if (cleanContent === "multipart/form-data") {
569
+ return "formData";
570
+ }
571
+ if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
572
+ return "blob";
573
+ }
574
+ if (cleanContent.startsWith("text/")) {
575
+ return "text";
576
+ }
577
+ return;
578
+ };
579
+ var checkForExistence = (options, name) => {
580
+ if (!name) {
581
+ return false;
582
+ }
583
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
584
+ return true;
585
+ }
586
+ return false;
587
+ };
588
+ async function setAuthParams(options) {
589
+ for (const auth of options.security ?? []) {
590
+ if (checkForExistence(options, auth.name)) {
591
+ continue;
592
+ }
593
+ const token = await getAuthToken(auth, options.auth);
594
+ if (!token) {
595
+ continue;
596
+ }
597
+ const name = auth.name ?? "Authorization";
598
+ switch (auth.in) {
599
+ case "query":
600
+ if (!options.query) {
601
+ options.query = {};
602
+ }
603
+ options.query[name] = token;
604
+ break;
605
+ case "cookie":
606
+ options.headers.append("Cookie", `${name}=${token}`);
607
+ break;
608
+ case "header":
609
+ default:
610
+ options.headers.set(name, token);
611
+ break;
612
+ }
613
+ }
614
+ }
615
+ var buildUrl = (options) => getUrl({
616
+ baseUrl: options.baseUrl,
617
+ path: options.path,
618
+ query: options.query,
619
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
620
+ url: options.url
621
+ });
622
+ var mergeConfigs = (a, b) => {
623
+ const config = { ...a, ...b };
624
+ if (config.baseUrl?.endsWith("/")) {
625
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
626
+ }
627
+ config.headers = mergeHeaders(a.headers, b.headers);
628
+ return config;
629
+ };
630
+ var headersEntries = (headers) => {
631
+ const entries = [];
632
+ headers.forEach((value, key) => {
633
+ entries.push([key, value]);
634
+ });
635
+ return entries;
636
+ };
637
+ var mergeHeaders = (...headers) => {
638
+ const mergedHeaders = new Headers();
639
+ for (const header of headers) {
640
+ if (!header) {
641
+ continue;
642
+ }
643
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
644
+ for (const [key, value] of iterator) {
645
+ if (value === null) {
646
+ mergedHeaders.delete(key);
647
+ } else if (Array.isArray(value)) {
648
+ for (const v of value) {
649
+ mergedHeaders.append(key, v);
650
+ }
651
+ } else if (value !== void 0) {
652
+ mergedHeaders.set(
653
+ key,
654
+ typeof value === "object" ? JSON.stringify(value) : value
655
+ );
656
+ }
657
+ }
658
+ }
659
+ return mergedHeaders;
660
+ };
661
+ var Interceptors = class {
662
+ fns = [];
663
+ clear() {
664
+ this.fns = [];
665
+ }
666
+ eject(id) {
667
+ const index = this.getInterceptorIndex(id);
668
+ if (this.fns[index]) {
669
+ this.fns[index] = null;
670
+ }
671
+ }
672
+ exists(id) {
673
+ const index = this.getInterceptorIndex(id);
674
+ return Boolean(this.fns[index]);
675
+ }
676
+ getInterceptorIndex(id) {
677
+ if (typeof id === "number") {
678
+ return this.fns[id] ? id : -1;
679
+ }
680
+ return this.fns.indexOf(id);
681
+ }
682
+ update(id, fn) {
683
+ const index = this.getInterceptorIndex(id);
684
+ if (this.fns[index]) {
685
+ this.fns[index] = fn;
686
+ return id;
687
+ }
688
+ return false;
689
+ }
690
+ use(fn) {
691
+ this.fns.push(fn);
692
+ return this.fns.length - 1;
693
+ }
694
+ };
695
+ var createInterceptors = () => ({
696
+ error: new Interceptors(),
697
+ request: new Interceptors(),
698
+ response: new Interceptors()
699
+ });
700
+ var defaultQuerySerializer = createQuerySerializer({
701
+ allowReserved: false,
702
+ array: {
703
+ explode: true,
704
+ style: "form"
705
+ },
706
+ object: {
707
+ explode: true,
708
+ style: "deepObject"
709
+ }
710
+ });
711
+ var defaultHeaders = {
712
+ "Content-Type": "application/json"
713
+ };
714
+ var createConfig = (override = {}) => ({
715
+ ...jsonBodySerializer,
716
+ headers: defaultHeaders,
717
+ parseAs: "auto",
718
+ querySerializer: defaultQuerySerializer,
719
+ ...override
720
+ });
721
+
722
+ // src/generated/client/client.gen.ts
723
+ var createClient = (config = {}) => {
724
+ let _config = mergeConfigs(createConfig(), config);
725
+ const getConfig = () => ({ ..._config });
726
+ const setConfig = (config2) => {
727
+ _config = mergeConfigs(_config, config2);
728
+ return getConfig();
729
+ };
730
+ const interceptors = createInterceptors();
731
+ const beforeRequest = async (options) => {
732
+ const opts = {
733
+ ..._config,
734
+ ...options,
735
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
736
+ headers: mergeHeaders(_config.headers, options.headers),
737
+ serializedBody: void 0
738
+ };
739
+ if (opts.security) {
740
+ await setAuthParams(opts);
741
+ }
742
+ if (opts.requestValidator) {
743
+ await opts.requestValidator(opts);
744
+ }
745
+ if (opts.body !== void 0 && opts.bodySerializer) {
746
+ opts.serializedBody = opts.bodySerializer(opts.body);
747
+ }
748
+ if (opts.body === void 0 || opts.serializedBody === "") {
749
+ opts.headers.delete("Content-Type");
750
+ }
751
+ const resolvedOpts = opts;
752
+ const url = buildUrl(resolvedOpts);
753
+ return { opts: resolvedOpts, url };
754
+ };
755
+ const request = async (options) => {
756
+ const throwOnError = options.throwOnError ?? _config.throwOnError;
757
+ const responseStyle = options.responseStyle ?? _config.responseStyle;
758
+ let request2;
759
+ let response;
760
+ try {
761
+ const { opts, url } = await beforeRequest(options);
762
+ const requestInit = {
763
+ redirect: "follow",
764
+ ...opts,
765
+ body: getValidRequestBody(opts)
766
+ };
767
+ request2 = new Request(url, requestInit);
768
+ for (const fn of interceptors.request.fns) {
769
+ if (fn) {
770
+ request2 = await fn(request2, opts);
771
+ }
772
+ }
773
+ const _fetch = opts.fetch;
774
+ response = await _fetch(request2);
775
+ for (const fn of interceptors.response.fns) {
776
+ if (fn) {
777
+ response = await fn(response, request2, opts);
778
+ }
779
+ }
780
+ const result = {
781
+ request: request2,
782
+ response
783
+ };
784
+ if (response.ok) {
785
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
786
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
787
+ let emptyData;
788
+ switch (parseAs) {
789
+ case "arrayBuffer":
790
+ case "blob":
791
+ case "text":
792
+ emptyData = await response[parseAs]();
793
+ break;
794
+ case "formData":
795
+ emptyData = new FormData();
796
+ break;
797
+ case "stream":
798
+ emptyData = response.body;
799
+ break;
800
+ case "json":
801
+ default:
802
+ emptyData = {};
803
+ break;
804
+ }
805
+ return opts.responseStyle === "data" ? emptyData : {
806
+ data: emptyData,
807
+ ...result
808
+ };
809
+ }
810
+ let data;
811
+ switch (parseAs) {
812
+ case "arrayBuffer":
813
+ case "blob":
814
+ case "formData":
815
+ case "text":
816
+ data = await response[parseAs]();
817
+ break;
818
+ case "json": {
819
+ const text = await response.text();
820
+ data = text ? JSON.parse(text) : {};
821
+ break;
822
+ }
823
+ case "stream":
824
+ return opts.responseStyle === "data" ? response.body : {
825
+ data: response.body,
826
+ ...result
827
+ };
828
+ }
829
+ if (parseAs === "json") {
830
+ if (opts.responseValidator) {
831
+ await opts.responseValidator(data);
832
+ }
833
+ if (opts.responseTransformer) {
834
+ data = await opts.responseTransformer(data);
835
+ }
836
+ }
837
+ return opts.responseStyle === "data" ? data : {
838
+ data,
839
+ ...result
840
+ };
841
+ }
842
+ const textError = await response.text();
843
+ let jsonError;
844
+ try {
845
+ jsonError = JSON.parse(textError);
846
+ } catch {
847
+ }
848
+ throw jsonError ?? textError;
849
+ } catch (error) {
850
+ let finalError = error;
851
+ for (const fn of interceptors.error.fns) {
852
+ if (fn) {
853
+ finalError = await fn(finalError, response, request2, options);
854
+ }
855
+ }
856
+ finalError = finalError || {};
857
+ if (throwOnError) {
858
+ throw finalError;
859
+ }
860
+ return responseStyle === "data" ? void 0 : {
861
+ error: finalError,
862
+ request: request2,
863
+ response
864
+ };
865
+ }
866
+ };
867
+ const makeMethodFn = (method) => (options) => request({ ...options, method });
868
+ const makeSseFn = (method) => async (options) => {
869
+ const { opts, url } = await beforeRequest(options);
870
+ return createSseClient({
871
+ ...opts,
872
+ body: opts.body,
873
+ method,
874
+ onRequest: async (url2, init) => {
875
+ let request2 = new Request(url2, init);
876
+ for (const fn of interceptors.request.fns) {
877
+ if (fn) {
878
+ request2 = await fn(request2, opts);
879
+ }
880
+ }
881
+ return request2;
882
+ },
883
+ serializedBody: getValidRequestBody(opts),
884
+ url
885
+ });
886
+ };
887
+ const _buildUrl = (options) => buildUrl({ ..._config, ...options });
888
+ return {
889
+ buildUrl: _buildUrl,
890
+ connect: makeMethodFn("CONNECT"),
891
+ delete: makeMethodFn("DELETE"),
892
+ get: makeMethodFn("GET"),
893
+ getConfig,
894
+ head: makeMethodFn("HEAD"),
895
+ interceptors,
896
+ options: makeMethodFn("OPTIONS"),
897
+ patch: makeMethodFn("PATCH"),
898
+ post: makeMethodFn("POST"),
899
+ put: makeMethodFn("PUT"),
900
+ request,
901
+ setConfig,
902
+ sse: {
903
+ connect: makeSseFn("CONNECT"),
904
+ delete: makeSseFn("DELETE"),
905
+ get: makeSseFn("GET"),
906
+ head: makeSseFn("HEAD"),
907
+ options: makeSseFn("OPTIONS"),
908
+ patch: makeSseFn("PATCH"),
909
+ post: makeSseFn("POST"),
910
+ put: makeSseFn("PUT"),
911
+ trace: makeSseFn("TRACE")
912
+ },
913
+ trace: makeMethodFn("TRACE")
914
+ };
915
+ };
916
+
917
+ // src/generated/client.gen.ts
918
+ var client = createClient(createConfig({ baseUrl: "https://app.usenadia.com/api" }));
919
+
920
+ // src/generated/sdk.gen.ts
921
+ var uploadFile = (options) => (options.client ?? client).post({
922
+ ...formDataBodySerializer,
923
+ security: [{ name: "Authorization", type: "apiKey" }],
924
+ url: "/public/v1/upload",
925
+ ...options,
926
+ headers: {
927
+ "Content-Type": null,
928
+ ...options.headers
929
+ }
930
+ });
931
+ var uploadFromUrl = (options) => (options.client ?? client).post({
932
+ security: [{ name: "Authorization", type: "apiKey" }],
933
+ url: "/public/v1/upload-from-url",
934
+ ...options,
935
+ headers: {
936
+ "Content-Type": "application/json",
937
+ ...options.headers
938
+ }
939
+ });
940
+ var findSlot = (options) => (options.client ?? client).get({
941
+ security: [{ name: "Authorization", type: "apiKey" }],
942
+ url: "/public/v1/find-slot/{id}",
943
+ ...options
944
+ });
945
+ var listPosts = (options) => (options.client ?? client).get({
946
+ security: [{ name: "Authorization", type: "apiKey" }],
947
+ url: "/public/v1/posts",
948
+ ...options
949
+ });
950
+ var createPost = (options) => (options.client ?? client).post({
951
+ security: [{ name: "Authorization", type: "apiKey" }],
952
+ url: "/public/v1/posts",
953
+ ...options,
954
+ headers: {
955
+ "Content-Type": "application/json",
956
+ ...options.headers
957
+ }
958
+ });
959
+ var deletePost = (options) => (options.client ?? client).delete({
960
+ security: [{ name: "Authorization", type: "apiKey" }],
961
+ url: "/public/v1/posts/{id}",
962
+ ...options
963
+ });
964
+ var deletePostGroup = (options) => (options.client ?? client).delete({
965
+ security: [{ name: "Authorization", type: "apiKey" }],
966
+ url: "/public/v1/posts/group/{group}",
967
+ ...options
968
+ });
969
+ var checkConnection = (options) => (options?.client ?? client).get({
970
+ security: [{ name: "Authorization", type: "apiKey" }],
971
+ url: "/public/v1/is-connected",
972
+ ...options
973
+ });
974
+ var listGroups = (options) => (options?.client ?? client).get({
975
+ security: [{ name: "Authorization", type: "apiKey" }],
976
+ url: "/public/v1/groups",
977
+ ...options
978
+ });
979
+ var listChannels = (options) => (options?.client ?? client).get({
980
+ security: [{ name: "Authorization", type: "apiKey" }],
981
+ url: "/public/v1/integrations",
982
+ ...options
983
+ });
984
+ var startChannelConnection = (options) => (options.client ?? client).get({
985
+ security: [{ name: "Authorization", type: "apiKey" }],
986
+ url: "/public/v1/social/{integration}",
987
+ ...options
988
+ });
989
+ var listNotifications = (options) => (options?.client ?? client).get({
990
+ security: [{ name: "Authorization", type: "apiKey" }],
991
+ url: "/public/v1/notifications",
992
+ ...options
993
+ });
994
+ var generateVideo = (options) => (options.client ?? client).post({
995
+ security: [{ name: "Authorization", type: "apiKey" }],
996
+ url: "/public/v1/generate-video",
997
+ ...options,
998
+ headers: {
999
+ "Content-Type": "application/json",
1000
+ ...options.headers
1001
+ }
1002
+ });
1003
+ var callVideoFunction = (options) => (options.client ?? client).post({
1004
+ security: [{ name: "Authorization", type: "apiKey" }],
1005
+ url: "/public/v1/video/function",
1006
+ ...options,
1007
+ headers: {
1008
+ "Content-Type": "application/json",
1009
+ ...options.headers
1010
+ }
1011
+ });
1012
+ var deleteChannel = (options) => (options.client ?? client).delete({
1013
+ security: [{ name: "Authorization", type: "apiKey" }],
1014
+ url: "/public/v1/integrations/{id}",
1015
+ ...options
1016
+ });
1017
+ var getChannelSettings = (options) => (options.client ?? client).get({
1018
+ security: [{ name: "Authorization", type: "apiKey" }],
1019
+ url: "/public/v1/integration-settings/{id}",
1020
+ ...options
1021
+ });
1022
+ var listMissingMedia = (options) => (options.client ?? client).get({
1023
+ security: [{ name: "Authorization", type: "apiKey" }],
1024
+ url: "/public/v1/posts/{id}/missing",
1025
+ ...options
1026
+ });
1027
+ var changePostStatus = (options) => (options.client ?? client).put({
1028
+ security: [{ name: "Authorization", type: "apiKey" }],
1029
+ url: "/public/v1/posts/{id}/status",
1030
+ ...options,
1031
+ headers: {
1032
+ "Content-Type": "application/json",
1033
+ ...options.headers
1034
+ }
1035
+ });
1036
+ var setPostReleaseId = (options) => (options.client ?? client).put({
1037
+ security: [{ name: "Authorization", type: "apiKey" }],
1038
+ url: "/public/v1/posts/{id}/release-id",
1039
+ ...options,
1040
+ headers: {
1041
+ "Content-Type": "application/json",
1042
+ ...options.headers
1043
+ }
1044
+ });
1045
+ var getChannelAnalytics = (options) => (options.client ?? client).get({
1046
+ security: [{ name: "Authorization", type: "apiKey" }],
1047
+ url: "/public/v1/analytics/{integration}",
1048
+ ...options
1049
+ });
1050
+ var listVideoPerformance = (options) => (options.client ?? client).get({
1051
+ security: [{ name: "Authorization", type: "apiKey" }],
1052
+ url: "/public/v1/video-list/{integrationId}",
1053
+ ...options
1054
+ });
1055
+ var getAccountHistory = (options) => (options.client ?? client).get({
1056
+ security: [{ name: "Authorization", type: "apiKey" }],
1057
+ url: "/public/v1/analytics-history/{integrationId}",
1058
+ ...options
1059
+ });
1060
+ var getVideoHistory = (options) => (options.client ?? client).get({
1061
+ security: [{ name: "Authorization", type: "apiKey" }],
1062
+ url: "/public/v1/video-history/{integrationId}",
1063
+ ...options
1064
+ });
1065
+ var getPostAnalytics = (options) => (options.client ?? client).get({
1066
+ security: [{ name: "Authorization", type: "apiKey" }],
1067
+ url: "/public/v1/analytics/post/{postId}",
1068
+ ...options
1069
+ });
1070
+ var runChannelTool = (options) => (options.client ?? client).post({
1071
+ security: [{ name: "Authorization", type: "apiKey" }],
1072
+ url: "/public/v1/integration-trigger/{id}",
1073
+ ...options,
1074
+ headers: {
1075
+ "Content-Type": "application/json",
1076
+ ...options.headers
1077
+ }
1078
+ });
1079
+ var listChannelMedia = (options) => (options.client ?? client).get({
1080
+ security: [{ name: "Authorization", type: "apiKey" }],
1081
+ url: "/public/v1/inbox/media/{integrationId}",
1082
+ ...options
1083
+ });
1084
+ var listChannelStories = (options) => (options.client ?? client).get({
1085
+ security: [{ name: "Authorization", type: "apiKey" }],
1086
+ url: "/public/v1/inbox/stories/{integrationId}",
1087
+ ...options
1088
+ });
1089
+ var listMediaComments = (options) => (options.client ?? client).get({
1090
+ security: [{ name: "Authorization", type: "apiKey" }],
1091
+ url: "/public/v1/inbox/comments/{integrationId}/{mediaId}",
1092
+ ...options
1093
+ });
1094
+ var replyToComment = (options) => (options.client ?? client).post({
1095
+ security: [{ name: "Authorization", type: "apiKey" }],
1096
+ url: "/public/v1/inbox/comments/{commentId}/reply",
1097
+ ...options,
1098
+ headers: {
1099
+ "Content-Type": "application/json",
1100
+ ...options.headers
1101
+ }
1102
+ });
1103
+ var hideComment = (options) => (options.client ?? client).post({
1104
+ security: [{ name: "Authorization", type: "apiKey" }],
1105
+ url: "/public/v1/inbox/comments/{integrationId}/{commentId}/hide",
1106
+ ...options,
1107
+ headers: {
1108
+ "Content-Type": "application/json",
1109
+ ...options.headers
1110
+ }
1111
+ });
1112
+ var deleteComment = (options) => (options.client ?? client).delete({
1113
+ security: [{ name: "Authorization", type: "apiKey" }],
1114
+ url: "/public/v1/inbox/comments/{integrationId}/{commentId}",
1115
+ ...options
1116
+ });
1117
+ var listConversations = (options) => (options.client ?? client).get({
1118
+ security: [{ name: "Authorization", type: "apiKey" }],
1119
+ url: "/public/v1/inbox/{integrationId}",
1120
+ ...options
1121
+ });
1122
+ var sendDirectMessage = (options) => (options.client ?? client).post({
1123
+ security: [{ name: "Authorization", type: "apiKey" }],
1124
+ url: "/public/v1/inbox/{integrationId}/send",
1125
+ ...options,
1126
+ headers: {
1127
+ "Content-Type": "application/json",
1128
+ ...options.headers
1129
+ }
1130
+ });
1131
+ var pollInbox = (options) => (options.client ?? client).post({
1132
+ security: [{ name: "Authorization", type: "apiKey" }],
1133
+ url: "/public/v1/inbox/{integrationId}/poll",
1134
+ ...options
1135
+ });
1136
+ var subscribeInboxWebhook = (options) => (options.client ?? client).post({
1137
+ security: [{ name: "Authorization", type: "apiKey" }],
1138
+ url: "/public/v1/inbox/{integrationId}/subscribe-webhook",
1139
+ ...options
1140
+ });
1141
+ var getConversation = (options) => (options.client ?? client).get({
1142
+ security: [{ name: "Authorization", type: "apiKey" }],
1143
+ url: "/public/v1/inbox/{integrationId}/{conversationId}",
1144
+ ...options
1145
+ });
1146
+ var listAutomationFlows = (options) => (options?.client ?? client).get({
1147
+ security: [{ name: "Authorization", type: "apiKey" }],
1148
+ url: "/public/v1/automation-flows",
1149
+ ...options
1150
+ });
1151
+ var createAutomationFlow = (options) => (options.client ?? client).post({
1152
+ security: [{ name: "Authorization", type: "apiKey" }],
1153
+ url: "/public/v1/automation-flows",
1154
+ ...options,
1155
+ headers: {
1156
+ "Content-Type": "application/json",
1157
+ ...options.headers
1158
+ }
1159
+ });
1160
+ var previewAutomationEmail = (options) => (options.client ?? client).post({
1161
+ security: [{ name: "Authorization", type: "apiKey" }],
1162
+ url: "/public/v1/automation-flows/email-preview",
1163
+ ...options,
1164
+ headers: {
1165
+ "Content-Type": "application/json",
1166
+ ...options.headers
1167
+ }
1168
+ });
1169
+ var sendAutomationTestEmail = (options) => (options.client ?? client).post({
1170
+ security: [{ name: "Authorization", type: "apiKey" }],
1171
+ url: "/public/v1/automation-flows/email-test",
1172
+ ...options,
1173
+ headers: {
1174
+ "Content-Type": "application/json",
1175
+ ...options.headers
1176
+ }
1177
+ });
1178
+ var deleteAutomationFlow = (options) => (options.client ?? client).delete({
1179
+ security: [{ name: "Authorization", type: "apiKey" }],
1180
+ url: "/public/v1/automation-flows/{id}",
1181
+ ...options
1182
+ });
1183
+ var getAutomationFlow = (options) => (options.client ?? client).get({
1184
+ security: [{ name: "Authorization", type: "apiKey" }],
1185
+ url: "/public/v1/automation-flows/{id}",
1186
+ ...options
1187
+ });
1188
+ var updateAutomationFlow = (options) => (options.client ?? client).put({
1189
+ security: [{ name: "Authorization", type: "apiKey" }],
1190
+ url: "/public/v1/automation-flows/{id}",
1191
+ ...options,
1192
+ headers: {
1193
+ "Content-Type": "application/json",
1194
+ ...options.headers
1195
+ }
1196
+ });
1197
+ var setAutomationFlowStatus = (options) => (options.client ?? client).put({
1198
+ security: [{ name: "Authorization", type: "apiKey" }],
1199
+ url: "/public/v1/automation-flows/{id}/status",
1200
+ ...options,
1201
+ headers: {
1202
+ "Content-Type": "application/json",
1203
+ ...options.headers
1204
+ }
1205
+ });
1206
+ var listAutomationFlowPoses = (options) => (options.client ?? client).get({
1207
+ security: [{ name: "Authorization", type: "apiKey" }],
1208
+ url: "/public/v1/automation-flows/{id}/poses",
1209
+ ...options
1210
+ });
1211
+ var poseAutomationFlow = (options) => (options.client ?? client).post({
1212
+ security: [{ name: "Authorization", type: "apiKey" }],
1213
+ url: "/public/v1/automation-flows/{id}/poses",
1214
+ ...options,
1215
+ headers: {
1216
+ "Content-Type": "application/json",
1217
+ ...options.headers
1218
+ }
1219
+ });
1220
+ var listChannelAutomationPoses = (options) => (options.client ?? client).get({
1221
+ security: [{ name: "Authorization", type: "apiKey" }],
1222
+ url: "/public/v1/automation-flow-poses",
1223
+ ...options
1224
+ });
1225
+ var deleteAutomationPose = (options) => (options.client ?? client).delete({
1226
+ security: [{ name: "Authorization", type: "apiKey" }],
1227
+ url: "/public/v1/automation-flow-poses/{id}",
1228
+ ...options
1229
+ });
1230
+ var getAutomationPose = (options) => (options.client ?? client).get({
1231
+ security: [{ name: "Authorization", type: "apiKey" }],
1232
+ url: "/public/v1/automation-flow-poses/{id}",
1233
+ ...options
1234
+ });
1235
+ var updateAutomationPose = (options) => (options.client ?? client).put({
1236
+ security: [{ name: "Authorization", type: "apiKey" }],
1237
+ url: "/public/v1/automation-flow-poses/{id}",
1238
+ ...options,
1239
+ headers: {
1240
+ "Content-Type": "application/json",
1241
+ ...options.headers
1242
+ }
1243
+ });
1244
+ var listAutomationPoseRuns = (options) => (options.client ?? client).get({
1245
+ security: [{ name: "Authorization", type: "apiKey" }],
1246
+ url: "/public/v1/automation-flow-poses/{id}/runs",
1247
+ ...options
1248
+ });
1249
+ var pollAutomationPose = (options) => (options.client ?? client).post({
1250
+ security: [{ name: "Authorization", type: "apiKey" }],
1251
+ url: "/public/v1/automation-flow-poses/{id}/poll",
1252
+ ...options
1253
+ });
1254
+ var replayAutomationPose = (options) => (options.client ?? client).post({
1255
+ security: [{ name: "Authorization", type: "apiKey" }],
1256
+ url: "/public/v1/automation-flow-poses/{id}/replay",
1257
+ ...options,
1258
+ headers: {
1259
+ "Content-Type": "application/json",
1260
+ ...options.headers
1261
+ }
1262
+ });
1263
+ var listWebhookEvents = (options) => (options?.client ?? client).get({
1264
+ security: [{ name: "Authorization", type: "apiKey" }],
1265
+ url: "/public/v1/webhooks/events",
1266
+ ...options
1267
+ });
1268
+ var listWebhooks = (options) => (options?.client ?? client).get({
1269
+ security: [{ name: "Authorization", type: "apiKey" }],
1270
+ url: "/public/v1/webhooks",
1271
+ ...options
1272
+ });
1273
+ var createWebhook = (options) => (options.client ?? client).post({
1274
+ security: [{ name: "Authorization", type: "apiKey" }],
1275
+ url: "/public/v1/webhooks",
1276
+ ...options,
1277
+ headers: {
1278
+ "Content-Type": "application/json",
1279
+ ...options.headers
1280
+ }
1281
+ });
1282
+ var deleteWebhook = (options) => (options.client ?? client).delete({
1283
+ security: [{ name: "Authorization", type: "apiKey" }],
1284
+ url: "/public/v1/webhooks/{id}",
1285
+ ...options
1286
+ });
1287
+ var getWebhook = (options) => (options.client ?? client).get({
1288
+ security: [{ name: "Authorization", type: "apiKey" }],
1289
+ url: "/public/v1/webhooks/{id}",
1290
+ ...options
1291
+ });
1292
+ var listContents = (options) => (options?.client ?? client).get({
1293
+ security: [{ name: "Authorization", type: "apiKey" }],
1294
+ url: "/public/v1/contents",
1295
+ ...options
1296
+ });
1297
+ var createContent = (options) => (options.client ?? client).post({
1298
+ security: [{ name: "Authorization", type: "apiKey" }],
1299
+ url: "/public/v1/contents",
1300
+ ...options,
1301
+ headers: {
1302
+ "Content-Type": "application/json",
1303
+ ...options.headers
1304
+ }
1305
+ });
1306
+ var getContentsPerformance = (options) => (options?.client ?? client).get({
1307
+ security: [{ name: "Authorization", type: "apiKey" }],
1308
+ url: "/public/v1/contents/performance",
1309
+ ...options
1310
+ });
1311
+ var deleteContent = (options) => (options.client ?? client).delete({
1312
+ security: [{ name: "Authorization", type: "apiKey" }],
1313
+ url: "/public/v1/contents/{id}",
1314
+ ...options
1315
+ });
1316
+ var getContent = (options) => (options.client ?? client).get({
1317
+ security: [{ name: "Authorization", type: "apiKey" }],
1318
+ url: "/public/v1/contents/{id}",
1319
+ ...options
1320
+ });
1321
+ var updateContent = (options) => (options.client ?? client).put({
1322
+ security: [{ name: "Authorization", type: "apiKey" }],
1323
+ url: "/public/v1/contents/{id}",
1324
+ ...options,
1325
+ headers: {
1326
+ "Content-Type": "application/json",
1327
+ ...options.headers
1328
+ }
1329
+ });
1330
+ var upsertContent = (options) => (options.client ?? client).post({
1331
+ security: [{ name: "Authorization", type: "apiKey" }],
1332
+ url: "/public/v1/contents/upsert",
1333
+ ...options,
1334
+ headers: {
1335
+ "Content-Type": "application/json",
1336
+ ...options.headers
1337
+ }
1338
+ });
1339
+ var moveContent = (options) => (options.client ?? client).put({
1340
+ security: [{ name: "Authorization", type: "apiKey" }],
1341
+ url: "/public/v1/contents/{id}/move",
1342
+ ...options,
1343
+ headers: {
1344
+ "Content-Type": "application/json",
1345
+ ...options.headers
1346
+ }
1347
+ });
1348
+ var linkContentPost = (options) => (options.client ?? client).put({
1349
+ security: [{ name: "Authorization", type: "apiKey" }],
1350
+ url: "/public/v1/contents/{id}/post",
1351
+ ...options,
1352
+ headers: {
1353
+ "Content-Type": "application/json",
1354
+ ...options.headers
1355
+ }
1356
+ });
1357
+ var searchHooks = (options) => (options?.client ?? client).get({
1358
+ security: [{ name: "Authorization", type: "apiKey" }],
1359
+ url: "/public/v1/hooks",
1360
+ ...options
1361
+ });
1362
+ var getHookForms = (options) => (options?.client ?? client).get({
1363
+ security: [{ name: "Authorization", type: "apiKey" }],
1364
+ url: "/public/v1/hooks/forms",
1365
+ ...options
1366
+ });
1367
+ var listHookFamilies = (options) => (options?.client ?? client).get({
1368
+ security: [{ name: "Authorization", type: "apiKey" }],
1369
+ url: "/public/v1/hooks/families",
1370
+ ...options
1371
+ });
1372
+ var replaceHookFamilies = (options) => (options.client ?? client).put({
1373
+ security: [{ name: "Authorization", type: "apiKey" }],
1374
+ url: "/public/v1/hooks/families",
1375
+ ...options,
1376
+ headers: {
1377
+ "Content-Type": "application/json",
1378
+ ...options.headers
1379
+ }
1380
+ });
1381
+ var importHooks = (options) => (options.client ?? client).post({
1382
+ security: [{ name: "Authorization", type: "apiKey" }],
1383
+ url: "/public/v1/hooks/import",
1384
+ ...options,
1385
+ headers: {
1386
+ "Content-Type": "application/json",
1387
+ ...options.headers
1388
+ }
1389
+ });
1390
+ var listMusic = (options) => (options?.client ?? client).get({
1391
+ security: [{ name: "Authorization", type: "apiKey" }],
1392
+ url: "/public/v1/music",
1393
+ ...options
1394
+ });
1395
+ var listMusicPillars = (options) => (options?.client ?? client).get({
1396
+ security: [{ name: "Authorization", type: "apiKey" }],
1397
+ url: "/public/v1/music/pillars",
1398
+ ...options
1399
+ });
1400
+ var getMusicTrack = (options) => (options.client ?? client).get({
1401
+ security: [{ name: "Authorization", type: "apiKey" }],
1402
+ url: "/public/v1/music/{slug}",
1403
+ ...options
1404
+ });
1405
+ var importMusic = (options) => (options.client ?? client).post({
1406
+ security: [{ name: "Authorization", type: "apiKey" }],
1407
+ url: "/public/v1/music/import",
1408
+ ...options,
1409
+ headers: {
1410
+ "Content-Type": "application/json",
1411
+ ...options.headers
1412
+ }
1413
+ });
1414
+ var uploadMusicFile = (options) => (options.client ?? client).put({
1415
+ ...formDataBodySerializer,
1416
+ security: [{ name: "Authorization", type: "apiKey" }],
1417
+ url: "/public/v1/music/{slug}/file",
1418
+ ...options,
1419
+ headers: {
1420
+ "Content-Type": null,
1421
+ ...options.headers
1422
+ }
1423
+ });
1424
+
1425
+ // src/index.ts
1426
+ var DEFAULT_BASE_URL = "https://app.usenadia.com/api";
1427
+ var NadiaError = class _NadiaError extends Error {
1428
+ status;
1429
+ body;
1430
+ constructor(status, body, message) {
1431
+ super(message ?? `UseNadia API responded ${status}`);
1432
+ this.name = "NadiaError";
1433
+ this.status = status;
1434
+ this.body = body;
1435
+ Object.setPrototypeOf(this, _NadiaError.prototype);
1436
+ }
1437
+ /**
1438
+ * True when retrying later could plausibly work: a rate limit, a server
1439
+ * hiccup, or a request that never completed at all (status 0).
1440
+ */
1441
+ get isTransient() {
1442
+ return this.status === 0 || this.status === 429 || this.status >= 500;
1443
+ }
1444
+ };
1445
+ var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
1446
+ var messageOf = (body) => {
1447
+ if (body && typeof body === "object" && "msg" in body) {
1448
+ const msg = body.msg;
1449
+ if (typeof msg === "string") return msg;
1450
+ }
1451
+ return void 0;
1452
+ };
1453
+ var Nadia = class {
1454
+ client;
1455
+ retries;
1456
+ constructor(apiKey, options = {}) {
1457
+ if (!apiKey) {
1458
+ throw new Error("An API key is required.");
1459
+ }
1460
+ const opts = typeof options === "string" ? { baseUrl: options } : options;
1461
+ this.retries = opts.retries ?? 2;
1462
+ this.client = client;
1463
+ this.client.setConfig({
1464
+ baseUrl: opts.baseUrl ?? DEFAULT_BASE_URL,
1465
+ headers: { Authorization: apiKey },
1466
+ ...opts.fetch ? { fetch: opts.fetch } : {}
1467
+ });
1468
+ }
1469
+ /**
1470
+ * Runs a generated operation, turns a non-2xx into a `NadiaError`, and
1471
+ * retries the transient ones. Every method below goes through here — that is
1472
+ * the whole point of the facade.
1473
+ */
1474
+ async call(operation) {
1475
+ let lastError;
1476
+ for (let attempt = 0; attempt <= this.retries; attempt++) {
1477
+ const { data, error, response } = await operation({ client: this.client });
1478
+ if (!response) {
1479
+ lastError = new NadiaError(0, error, "The request did not complete.");
1480
+ } else if (response.ok) {
1481
+ return data;
1482
+ } else {
1483
+ lastError = new NadiaError(response.status, error, messageOf(error));
1484
+ }
1485
+ if (!lastError.isTransient || attempt === this.retries) {
1486
+ throw lastError;
1487
+ }
1488
+ await sleep(2 ** attempt * 500);
1489
+ }
1490
+ throw lastError;
1491
+ }
1492
+ /* --------------------------------------------------------------- *
1493
+ * The five calls upstream had, same names, same shape
1494
+ * --------------------------------------------------------------- */
1495
+ /** Schedule, publish or draft a post on one or more channels. */
1496
+ post(body) {
1497
+ return this.call(
1498
+ (o) => createPost({ ...o, body })
1499
+ );
1500
+ }
1501
+ /** List posts in a date range. */
1502
+ postList(query) {
1503
+ return this.call(
1504
+ (o) => listPosts({ ...o, query })
1505
+ );
1506
+ }
1507
+ /** Upload a file and get a URL usable in a post. */
1508
+ upload(file, filename = "upload") {
1509
+ const form = new FormData();
1510
+ form.append("file", file, filename);
1511
+ return this.call(
1512
+ (o) => uploadFile({
1513
+ ...o,
1514
+ body: form,
1515
+ bodySerializer: (body) => body
1516
+ })
1517
+ );
1518
+ }
1519
+ /** List your connected channels. */
1520
+ integrations() {
1521
+ return this.call((o) => listChannels(o));
1522
+ }
1523
+ /** Delete a post and everything published with it. */
1524
+ deletePost(id) {
1525
+ return this.call(
1526
+ (o) => deletePost({ ...o, path: { id } })
1527
+ );
1528
+ }
1529
+ /* --------------------------------------------------------------- *
1530
+ * The rest of our surface, which upstream never had
1531
+ * --------------------------------------------------------------- */
1532
+ /** Check that the API key is valid. Throws `NadiaError` with status 401 if not. */
1533
+ async isConnected() {
1534
+ await this.call((o) => checkConnection(o));
1535
+ return true;
1536
+ }
1537
+ /** Next free slot in a channel's schedule. */
1538
+ findSlot(integrationId) {
1539
+ return this.call(
1540
+ (o) => findSlot({
1541
+ ...o,
1542
+ path: { id: integrationId }
1543
+ })
1544
+ );
1545
+ }
1546
+ /** List your groups (brands). */
1547
+ groups() {
1548
+ return this.call((o) => listGroups(o));
1549
+ }
1550
+ /** Direct message conversations of a channel. */
1551
+ inbox(integrationId, limit) {
1552
+ return this.call(
1553
+ (o) => listConversations({
1554
+ ...o,
1555
+ path: { integrationId },
1556
+ query: limit ? { limit: String(limit) } : void 0
1557
+ })
1558
+ );
1559
+ }
1560
+ /* --------------------------------------------------------------- *
1561
+ * The content board: one card per video, from the idea to the
1562
+ * numbers after publication
1563
+ * --------------------------------------------------------------- */
1564
+ /**
1565
+ * The cards of the board, with the posts scheduled from each. Filters
1566
+ * combine: `stage`, `tag`, `externalId`; `fields` (`'id,title,stage'`)
1567
+ * leaves the scripts out.
1568
+ */
1569
+ contents(query) {
1570
+ return this.call((o) => listContents({ ...o, query }));
1571
+ }
1572
+ /** One card. */
1573
+ content(id) {
1574
+ return this.call((o) => getContent({ ...o, path: { id } }));
1575
+ }
1576
+ /** Create a card — in IDEA unless `stage` says otherwise. */
1577
+ createContent(body) {
1578
+ return this.call((o) => createContent({ ...o, body }));
1579
+ }
1580
+ /**
1581
+ * Create or update the card holding `externalId` (your own id: a script
1582
+ * file path, a build id). Re-running an import never duplicates; an
1583
+ * existing card keeps its column.
1584
+ */
1585
+ upsertContent(body) {
1586
+ return this.call((o) => upsertContent({ ...o, body }));
1587
+ }
1588
+ /** Update a card: only the fields sent change, `null` clears one. */
1589
+ updateContent(id, body) {
1590
+ return this.call((o) => updateContent({ ...o, path: { id }, body }));
1591
+ }
1592
+ /** Move a card to another column (to the bottom unless `position` is given). */
1593
+ moveContent(id, stage, position) {
1594
+ return this.call(
1595
+ (o) => moveContent({
1596
+ ...o,
1597
+ path: { id },
1598
+ body: position === void 0 ? { stage } : { stage, position }
1599
+ })
1600
+ );
1601
+ }
1602
+ /**
1603
+ * Tie a card to a post scheduled from it — the `group` passed on
1604
+ * {@link Nadia.post}. A card holds several posts (a TikTok draft, an
1605
+ * Instagram post): each call adds one. The card moves to PUBLISHED when
1606
+ * the first of them goes live.
1607
+ */
1608
+ linkContentPost(id, postGroup) {
1609
+ return this.call(
1610
+ (o) => linkContentPost({ ...o, path: { id }, body: { postGroup } })
1611
+ );
1612
+ }
1613
+ /** Delete a card. */
1614
+ deleteContent(id) {
1615
+ return this.call((o) => deleteContent({ ...o, path: { id } }));
1616
+ }
1617
+ /** The numbers of the published cards, keyed by card id. */
1618
+ contentsPerformance() {
1619
+ return this.call((o) => getContentsPerformance(o));
1620
+ }
1621
+ /**
1622
+ * Runs any generated operation with the facade's guarantees — a non-2xx
1623
+ * throws a `NadiaError`, the transient ones are retried. The way to reach
1624
+ * what the facade does not sugar without giving those up.
1625
+ *
1626
+ * import { getChannelAnalytics } from '@usenadia/node';
1627
+ * await nadia.request((o) =>
1628
+ * getChannelAnalytics({ ...o, path: { integration: id }, query: { date: '7' } })
1629
+ * );
1630
+ */
1631
+ request(operation) {
1632
+ return this.call(operation);
1633
+ }
1634
+ /**
1635
+ * The generated client, configured with your key. Use it for any of the
1636
+ * operations the facade does not wrap — nothing here is a dead end.
1637
+ *
1638
+ * import { getChannelAnalytics } from '@usenadia/node';
1639
+ * await getChannelAnalytics({ client: nadia.raw, path: {...} });
1640
+ */
1641
+ get raw() {
1642
+ return this.client;
1643
+ }
1644
+ };
1645
+ var index_default = Nadia;
1646
+ // Annotate the CommonJS export names for ESM import in node:
1647
+ 0 && (module.exports = {
1648
+ DEFAULT_BASE_URL,
1649
+ Nadia,
1650
+ NadiaError,
1651
+ callVideoFunction,
1652
+ changePostStatus,
1653
+ checkConnection,
1654
+ createAutomationFlow,
1655
+ createContent,
1656
+ createPost,
1657
+ createWebhook,
1658
+ deleteAutomationFlow,
1659
+ deleteAutomationPose,
1660
+ deleteChannel,
1661
+ deleteComment,
1662
+ deleteContent,
1663
+ deletePost,
1664
+ deletePostGroup,
1665
+ deleteWebhook,
1666
+ findSlot,
1667
+ generateVideo,
1668
+ getAccountHistory,
1669
+ getAutomationFlow,
1670
+ getAutomationPose,
1671
+ getChannelAnalytics,
1672
+ getChannelSettings,
1673
+ getContent,
1674
+ getContentsPerformance,
1675
+ getConversation,
1676
+ getHookForms,
1677
+ getMusicTrack,
1678
+ getPostAnalytics,
1679
+ getVideoHistory,
1680
+ getWebhook,
1681
+ hideComment,
1682
+ importHooks,
1683
+ importMusic,
1684
+ linkContentPost,
1685
+ listAutomationFlowPoses,
1686
+ listAutomationFlows,
1687
+ listAutomationPoseRuns,
1688
+ listChannelAutomationPoses,
1689
+ listChannelMedia,
1690
+ listChannelStories,
1691
+ listChannels,
1692
+ listContents,
1693
+ listConversations,
1694
+ listGroups,
1695
+ listHookFamilies,
1696
+ listMediaComments,
1697
+ listMissingMedia,
1698
+ listMusic,
1699
+ listMusicPillars,
1700
+ listNotifications,
1701
+ listPosts,
1702
+ listVideoPerformance,
1703
+ listWebhookEvents,
1704
+ listWebhooks,
1705
+ moveContent,
1706
+ pollAutomationPose,
1707
+ pollInbox,
1708
+ poseAutomationFlow,
1709
+ previewAutomationEmail,
1710
+ replaceHookFamilies,
1711
+ replayAutomationPose,
1712
+ replyToComment,
1713
+ runChannelTool,
1714
+ searchHooks,
1715
+ sendAutomationTestEmail,
1716
+ sendDirectMessage,
1717
+ setAutomationFlowStatus,
1718
+ setPostReleaseId,
1719
+ startChannelConnection,
1720
+ subscribeInboxWebhook,
1721
+ updateAutomationFlow,
1722
+ updateAutomationPose,
1723
+ updateContent,
1724
+ uploadFile,
1725
+ uploadFromUrl,
1726
+ uploadMusicFile,
1727
+ upsertContent
1728
+ });
1729
+ //# sourceMappingURL=index.js.map