@getlatedev/node 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.mjs ADDED
@@ -0,0 +1,1106 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+
5
+ // node_modules/@hey-api/client-fetch/dist/index.js
6
+ var U = /\{[^{}]+\}/g;
7
+ var S = ({ allowReserved: t, name: r, value: e }) => {
8
+ if (e == null) return "";
9
+ if (typeof e == "object") throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");
10
+ return `${r}=${t ? e : encodeURIComponent(e)}`;
11
+ };
12
+ var $ = (t) => {
13
+ switch (t) {
14
+ case "label":
15
+ return ".";
16
+ case "matrix":
17
+ return ";";
18
+ case "simple":
19
+ return ",";
20
+ default:
21
+ return "&";
22
+ }
23
+ };
24
+ var k = (t) => {
25
+ switch (t) {
26
+ case "form":
27
+ return ",";
28
+ case "pipeDelimited":
29
+ return "|";
30
+ case "spaceDelimited":
31
+ return "%20";
32
+ default:
33
+ return ",";
34
+ }
35
+ };
36
+ var D = (t) => {
37
+ switch (t) {
38
+ case "label":
39
+ return ".";
40
+ case "matrix":
41
+ return ";";
42
+ case "simple":
43
+ return ",";
44
+ default:
45
+ return "&";
46
+ }
47
+ };
48
+ var j = ({ allowReserved: t, explode: r, name: e, style: s, value: o }) => {
49
+ if (!r) {
50
+ let n = (t ? o : o.map((c) => encodeURIComponent(c))).join(k(s));
51
+ switch (s) {
52
+ case "label":
53
+ return `.${n}`;
54
+ case "matrix":
55
+ return `;${e}=${n}`;
56
+ case "simple":
57
+ return n;
58
+ default:
59
+ return `${e}=${n}`;
60
+ }
61
+ }
62
+ let a = $(s), i = o.map((n) => s === "label" || s === "simple" ? t ? n : encodeURIComponent(n) : S({ allowReserved: t, name: e, value: n })).join(a);
63
+ return s === "label" || s === "matrix" ? a + i : i;
64
+ };
65
+ var A = ({ allowReserved: t, explode: r, name: e, style: s, value: o }) => {
66
+ if (o instanceof Date) return `${e}=${o.toISOString()}`;
67
+ if (s !== "deepObject" && !r) {
68
+ let n = [];
69
+ Object.entries(o).forEach(([f, p]) => {
70
+ n = [...n, f, t ? p : encodeURIComponent(p)];
71
+ });
72
+ let c = n.join(",");
73
+ switch (s) {
74
+ case "form":
75
+ return `${e}=${c}`;
76
+ case "label":
77
+ return `.${c}`;
78
+ case "matrix":
79
+ return `;${e}=${c}`;
80
+ default:
81
+ return c;
82
+ }
83
+ }
84
+ let a = D(s), i = Object.entries(o).map(([n, c]) => S({ allowReserved: t, name: s === "deepObject" ? `${e}[${n}]` : n, value: c })).join(a);
85
+ return s === "label" || s === "matrix" ? a + i : i;
86
+ };
87
+ var _ = ({ path: t, url: r }) => {
88
+ let e = r, s = r.match(U);
89
+ if (s) for (let o of s) {
90
+ let a = false, i = o.substring(1, o.length - 1), n = "simple";
91
+ i.endsWith("*") && (a = true, i = i.substring(0, i.length - 1)), i.startsWith(".") ? (i = i.substring(1), n = "label") : i.startsWith(";") && (i = i.substring(1), n = "matrix");
92
+ let c = t[i];
93
+ if (c == null) continue;
94
+ if (Array.isArray(c)) {
95
+ e = e.replace(o, j({ explode: a, name: i, style: n, value: c }));
96
+ continue;
97
+ }
98
+ if (typeof c == "object") {
99
+ e = e.replace(o, A({ explode: a, name: i, style: n, value: c }));
100
+ continue;
101
+ }
102
+ if (n === "matrix") {
103
+ e = e.replace(o, `;${S({ name: i, value: c })}`);
104
+ continue;
105
+ }
106
+ let f = encodeURIComponent(n === "label" ? `.${c}` : c);
107
+ e = e.replace(o, f);
108
+ }
109
+ return e;
110
+ };
111
+ var C = ({ allowReserved: t, array: r, object: e } = {}) => (o) => {
112
+ let a = [];
113
+ if (o && typeof o == "object") for (let i in o) {
114
+ let n = o[i];
115
+ if (n != null) {
116
+ if (Array.isArray(n)) {
117
+ a = [...a, j({ allowReserved: t, explode: true, name: i, style: "form", value: n, ...r })];
118
+ continue;
119
+ }
120
+ if (typeof n == "object") {
121
+ a = [...a, A({ allowReserved: t, explode: true, name: i, style: "deepObject", value: n, ...e })];
122
+ continue;
123
+ }
124
+ a = [...a, S({ allowReserved: t, name: i, value: n })];
125
+ }
126
+ }
127
+ return a.join("&");
128
+ };
129
+ var w = (t) => {
130
+ if (!t) return "stream";
131
+ let r = t.split(";")[0]?.trim();
132
+ if (r) {
133
+ if (r.startsWith("application/json") || r.endsWith("+json")) return "json";
134
+ if (r === "multipart/form-data") return "formData";
135
+ if (["application/", "audio/", "image/", "video/"].some((e) => r.startsWith(e))) return "blob";
136
+ if (r.startsWith("text/")) return "text";
137
+ }
138
+ };
139
+ var H = async (t, r) => {
140
+ let e = typeof r == "function" ? await r(t) : r;
141
+ if (e) return t.scheme === "bearer" ? `Bearer ${e}` : t.scheme === "basic" ? `Basic ${btoa(e)}` : e;
142
+ };
143
+ var P = async ({ security: t, ...r }) => {
144
+ for (let e of t) {
145
+ let s = await H(e, r.auth);
146
+ if (!s) continue;
147
+ let o = e.name ?? "Authorization";
148
+ switch (e.in) {
149
+ case "query":
150
+ r.query || (r.query = {}), r.query[o] = s;
151
+ break;
152
+ case "header":
153
+ default:
154
+ r.headers.set(o, s);
155
+ break;
156
+ }
157
+ return;
158
+ }
159
+ };
160
+ var b = (t) => B({ baseUrl: t.baseUrl ?? "", path: t.path, query: t.query, querySerializer: typeof t.querySerializer == "function" ? t.querySerializer : C(t.querySerializer), url: t.url });
161
+ var B = ({ baseUrl: t, path: r, query: e, querySerializer: s, url: o }) => {
162
+ let a = o.startsWith("/") ? o : `/${o}`, i = t + a;
163
+ r && (i = _({ path: r, url: i }));
164
+ let n = e ? s(e) : "";
165
+ return n.startsWith("?") && (n = n.substring(1)), n && (i += `?${n}`), i;
166
+ };
167
+ var R = (t, r) => {
168
+ let e = { ...t, ...r };
169
+ return e.baseUrl?.endsWith("/") && (e.baseUrl = e.baseUrl.substring(0, e.baseUrl.length - 1)), e.headers = O(t.headers, r.headers), e;
170
+ };
171
+ var O = (...t) => {
172
+ let r = new Headers();
173
+ for (let e of t) {
174
+ if (!e || typeof e != "object") continue;
175
+ let s = e instanceof Headers ? e.entries() : Object.entries(e);
176
+ for (let [o, a] of s) if (a === null) r.delete(o);
177
+ else if (Array.isArray(a)) for (let i of a) r.append(o, i);
178
+ else a !== void 0 && r.set(o, typeof a == "object" ? JSON.stringify(a) : a);
179
+ }
180
+ return r;
181
+ };
182
+ var y = class {
183
+ constructor() {
184
+ __publicField(this, "_fns");
185
+ this._fns = [];
186
+ }
187
+ clear() {
188
+ this._fns = [];
189
+ }
190
+ exists(r) {
191
+ return this._fns.indexOf(r) !== -1;
192
+ }
193
+ eject(r) {
194
+ let e = this._fns.indexOf(r);
195
+ e !== -1 && (this._fns = [...this._fns.slice(0, e), ...this._fns.slice(e + 1)]);
196
+ }
197
+ use(r) {
198
+ this._fns = [...this._fns, r];
199
+ }
200
+ };
201
+ var E = () => ({ error: new y(), request: new y(), response: new y() });
202
+ var x = (t, r, e) => {
203
+ typeof e == "string" || e instanceof Blob ? t.append(r, e) : t.append(r, JSON.stringify(e));
204
+ };
205
+ var W = { bodySerializer: (t) => {
206
+ let r = new FormData();
207
+ return Object.entries(t).forEach(([e, s]) => {
208
+ s != null && (Array.isArray(s) ? s.forEach((o) => x(r, e, o)) : x(r, e, s));
209
+ }), r;
210
+ } };
211
+ var I = { bodySerializer: (t) => JSON.stringify(t) };
212
+ var Q = C({ allowReserved: false, array: { explode: true, style: "form" }, object: { explode: true, style: "deepObject" } });
213
+ var V = { "Content-Type": "application/json" };
214
+ var q = (t = {}) => ({ ...I, baseUrl: "", headers: V, parseAs: "auto", querySerializer: Q, ...t });
215
+ var M = (t = {}) => {
216
+ let r = R(q(), t), e = () => ({ ...r }), s = (i) => (r = R(r, i), e()), o = E(), a = async (i) => {
217
+ let n = { ...r, ...i, fetch: i.fetch ?? r.fetch ?? globalThis.fetch, headers: O(r.headers, i.headers) };
218
+ n.security && await P({ ...n, security: n.security }), n.body && n.bodySerializer && (n.body = n.bodySerializer(n.body)), n.body || n.headers.delete("Content-Type");
219
+ let c = b(n), f = { redirect: "follow", ...n }, p = new Request(c, f);
220
+ for (let u of o.request._fns) p = await u(p, n);
221
+ let T = n.fetch, l = await T(p);
222
+ for (let u of o.response._fns) l = await u(l, p, n);
223
+ let h = { request: p, response: l };
224
+ if (l.ok) {
225
+ if (l.status === 204 || l.headers.get("Content-Length") === "0") return { data: {}, ...h };
226
+ let u = (n.parseAs === "auto" ? w(l.headers.get("Content-Type")) : n.parseAs) ?? "json";
227
+ if (u === "stream") return { data: l.body, ...h };
228
+ let g = await l[u]();
229
+ return u === "json" && (n.responseValidator && await n.responseValidator(g), n.responseTransformer && (g = await n.responseTransformer(g))), { data: g, ...h };
230
+ }
231
+ let m = await l.text();
232
+ try {
233
+ m = JSON.parse(m);
234
+ } catch {
235
+ }
236
+ let d = m;
237
+ for (let u of o.error._fns) d = await u(m, l, p, n);
238
+ if (d = d || {}, n.throwOnError) throw d;
239
+ return { error: d, ...h };
240
+ };
241
+ return { buildUrl: b, connect: (i) => a({ ...i, method: "CONNECT" }), delete: (i) => a({ ...i, method: "DELETE" }), get: (i) => a({ ...i, method: "GET" }), getConfig: e, head: (i) => a({ ...i, method: "HEAD" }), interceptors: o, options: (i) => a({ ...i, method: "OPTIONS" }), patch: (i) => a({ ...i, method: "PATCH" }), post: (i) => a({ ...i, method: "POST" }), put: (i) => a({ ...i, method: "PUT" }), request: a, setConfig: s, trace: (i) => a({ ...i, method: "TRACE" }) };
242
+ };
243
+
244
+ // src/generated/sdk.gen.ts
245
+ var client = M(q());
246
+ var getV1ToolsYoutubeDownload = (options) => {
247
+ return (options?.client ?? client).get({
248
+ ...options,
249
+ url: "/v1/tools/youtube/download"
250
+ });
251
+ };
252
+ var getV1ToolsYoutubeTranscript = (options) => {
253
+ return (options?.client ?? client).get({
254
+ ...options,
255
+ url: "/v1/tools/youtube/transcript"
256
+ });
257
+ };
258
+ var getV1ToolsInstagramDownload = (options) => {
259
+ return (options?.client ?? client).get({
260
+ ...options,
261
+ url: "/v1/tools/instagram/download"
262
+ });
263
+ };
264
+ var postV1ToolsInstagramHashtagChecker = (options) => {
265
+ return (options?.client ?? client).post({
266
+ ...options,
267
+ url: "/v1/tools/instagram/hashtag-checker"
268
+ });
269
+ };
270
+ var getV1ToolsTiktokDownload = (options) => {
271
+ return (options?.client ?? client).get({
272
+ ...options,
273
+ url: "/v1/tools/tiktok/download"
274
+ });
275
+ };
276
+ var getV1ToolsTwitterDownload = (options) => {
277
+ return (options?.client ?? client).get({
278
+ ...options,
279
+ url: "/v1/tools/twitter/download"
280
+ });
281
+ };
282
+ var getV1ToolsFacebookDownload = (options) => {
283
+ return (options?.client ?? client).get({
284
+ ...options,
285
+ url: "/v1/tools/facebook/download"
286
+ });
287
+ };
288
+ var getV1ToolsLinkedinDownload = (options) => {
289
+ return (options?.client ?? client).get({
290
+ ...options,
291
+ url: "/v1/tools/linkedin/download"
292
+ });
293
+ };
294
+ var getV1ToolsBlueskyDownload = (options) => {
295
+ return (options?.client ?? client).get({
296
+ ...options,
297
+ url: "/v1/tools/bluesky/download"
298
+ });
299
+ };
300
+ var getV1Analytics = (options) => {
301
+ return (options?.client ?? client).get({
302
+ ...options,
303
+ url: "/v1/analytics"
304
+ });
305
+ };
306
+ var getV1AnalyticsYoutubeDailyViews = (options) => {
307
+ return (options?.client ?? client).get({
308
+ ...options,
309
+ url: "/v1/analytics/youtube/daily-views"
310
+ });
311
+ };
312
+ var getV1AccountGroups = (options) => {
313
+ return (options?.client ?? client).get({
314
+ ...options,
315
+ url: "/v1/account-groups"
316
+ });
317
+ };
318
+ var postV1AccountGroups = (options) => {
319
+ return (options?.client ?? client).post({
320
+ ...options,
321
+ url: "/v1/account-groups"
322
+ });
323
+ };
324
+ var putV1AccountGroupsByGroupId = (options) => {
325
+ return (options?.client ?? client).put({
326
+ ...options,
327
+ url: "/v1/account-groups/{groupId}"
328
+ });
329
+ };
330
+ var deleteV1AccountGroupsByGroupId = (options) => {
331
+ return (options?.client ?? client).delete({
332
+ ...options,
333
+ url: "/v1/account-groups/{groupId}"
334
+ });
335
+ };
336
+ var postV1MediaPresign = (options) => {
337
+ return (options?.client ?? client).post({
338
+ ...options,
339
+ url: "/v1/media/presign"
340
+ });
341
+ };
342
+ var getV1RedditSearch = (options) => {
343
+ return (options?.client ?? client).get({
344
+ ...options,
345
+ url: "/v1/reddit/search"
346
+ });
347
+ };
348
+ var getV1RedditFeed = (options) => {
349
+ return (options?.client ?? client).get({
350
+ ...options,
351
+ url: "/v1/reddit/feed"
352
+ });
353
+ };
354
+ var getV1UsageStats = (options) => {
355
+ return (options?.client ?? client).get({
356
+ ...options,
357
+ url: "/v1/usage-stats"
358
+ });
359
+ };
360
+ var getV1Posts = (options) => {
361
+ return (options?.client ?? client).get({
362
+ ...options,
363
+ url: "/v1/posts"
364
+ });
365
+ };
366
+ var postV1Posts = (options) => {
367
+ return (options?.client ?? client).post({
368
+ ...options,
369
+ url: "/v1/posts"
370
+ });
371
+ };
372
+ var getV1PostsByPostId = (options) => {
373
+ return (options?.client ?? client).get({
374
+ ...options,
375
+ url: "/v1/posts/{postId}"
376
+ });
377
+ };
378
+ var putV1PostsByPostId = (options) => {
379
+ return (options?.client ?? client).put({
380
+ ...options,
381
+ url: "/v1/posts/{postId}"
382
+ });
383
+ };
384
+ var deleteV1PostsByPostId = (options) => {
385
+ return (options?.client ?? client).delete({
386
+ ...options,
387
+ url: "/v1/posts/{postId}"
388
+ });
389
+ };
390
+ var postV1PostsBulkUpload = (options) => {
391
+ return (options?.client ?? client).post({
392
+ ...options,
393
+ ...W,
394
+ headers: {
395
+ "Content-Type": null,
396
+ ...options?.headers
397
+ },
398
+ url: "/v1/posts/bulk-upload"
399
+ });
400
+ };
401
+ var postV1PostsByPostIdRetry = (options) => {
402
+ return (options?.client ?? client).post({
403
+ ...options,
404
+ url: "/v1/posts/{postId}/retry"
405
+ });
406
+ };
407
+ var getV1Users = (options) => {
408
+ return (options?.client ?? client).get({
409
+ ...options,
410
+ url: "/v1/users"
411
+ });
412
+ };
413
+ var getV1UsersByUserId = (options) => {
414
+ return (options?.client ?? client).get({
415
+ ...options,
416
+ url: "/v1/users/{userId}"
417
+ });
418
+ };
419
+ var getV1Profiles = (options) => {
420
+ return (options?.client ?? client).get({
421
+ ...options,
422
+ url: "/v1/profiles"
423
+ });
424
+ };
425
+ var postV1Profiles = (options) => {
426
+ return (options?.client ?? client).post({
427
+ ...options,
428
+ url: "/v1/profiles"
429
+ });
430
+ };
431
+ var getV1ProfilesByProfileId = (options) => {
432
+ return (options?.client ?? client).get({
433
+ ...options,
434
+ url: "/v1/profiles/{profileId}"
435
+ });
436
+ };
437
+ var putV1ProfilesByProfileId = (options) => {
438
+ return (options?.client ?? client).put({
439
+ ...options,
440
+ url: "/v1/profiles/{profileId}"
441
+ });
442
+ };
443
+ var deleteV1ProfilesByProfileId = (options) => {
444
+ return (options?.client ?? client).delete({
445
+ ...options,
446
+ url: "/v1/profiles/{profileId}"
447
+ });
448
+ };
449
+ var getV1Accounts = (options) => {
450
+ return (options?.client ?? client).get({
451
+ ...options,
452
+ url: "/v1/accounts"
453
+ });
454
+ };
455
+ var getV1AccountsFollowerStats = (options) => {
456
+ return (options?.client ?? client).get({
457
+ ...options,
458
+ url: "/v1/accounts/follower-stats"
459
+ });
460
+ };
461
+ var putV1AccountsByAccountId = (options) => {
462
+ return (options?.client ?? client).put({
463
+ ...options,
464
+ url: "/v1/accounts/{accountId}"
465
+ });
466
+ };
467
+ var deleteV1AccountsByAccountId = (options) => {
468
+ return (options?.client ?? client).delete({
469
+ ...options,
470
+ url: "/v1/accounts/{accountId}"
471
+ });
472
+ };
473
+ var getV1AccountsHealth = (options) => {
474
+ return (options?.client ?? client).get({
475
+ ...options,
476
+ url: "/v1/accounts/health"
477
+ });
478
+ };
479
+ var getV1AccountsByAccountIdHealth = (options) => {
480
+ return (options?.client ?? client).get({
481
+ ...options,
482
+ url: "/v1/accounts/{accountId}/health"
483
+ });
484
+ };
485
+ var getV1ApiKeys = (options) => {
486
+ return (options?.client ?? client).get({
487
+ ...options,
488
+ url: "/v1/api-keys"
489
+ });
490
+ };
491
+ var postV1ApiKeys = (options) => {
492
+ return (options?.client ?? client).post({
493
+ ...options,
494
+ url: "/v1/api-keys"
495
+ });
496
+ };
497
+ var deleteV1ApiKeysByKeyId = (options) => {
498
+ return (options?.client ?? client).delete({
499
+ ...options,
500
+ url: "/v1/api-keys/{keyId}"
501
+ });
502
+ };
503
+ var postV1InviteTokens = (options) => {
504
+ return (options?.client ?? client).post({
505
+ ...options,
506
+ url: "/v1/invite/tokens"
507
+ });
508
+ };
509
+ var getV1PlatformInvites = (options) => {
510
+ return (options?.client ?? client).get({
511
+ ...options,
512
+ url: "/v1/platform-invites"
513
+ });
514
+ };
515
+ var postV1PlatformInvites = (options) => {
516
+ return (options?.client ?? client).post({
517
+ ...options,
518
+ url: "/v1/platform-invites"
519
+ });
520
+ };
521
+ var deleteV1PlatformInvites = (options) => {
522
+ return (options?.client ?? client).delete({
523
+ ...options,
524
+ url: "/v1/platform-invites"
525
+ });
526
+ };
527
+ var getV1ConnectByPlatform = (options) => {
528
+ return (options?.client ?? client).get({
529
+ ...options,
530
+ url: "/v1/connect/{platform}"
531
+ });
532
+ };
533
+ var postV1ConnectByPlatform = (options) => {
534
+ return (options?.client ?? client).post({
535
+ ...options,
536
+ url: "/v1/connect/{platform}"
537
+ });
538
+ };
539
+ var getV1ConnectFacebookSelectPage = (options) => {
540
+ return (options?.client ?? client).get({
541
+ ...options,
542
+ url: "/v1/connect/facebook/select-page"
543
+ });
544
+ };
545
+ var postV1ConnectFacebookSelectPage = (options) => {
546
+ return (options?.client ?? client).post({
547
+ ...options,
548
+ url: "/v1/connect/facebook/select-page"
549
+ });
550
+ };
551
+ var getV1ConnectGooglebusinessLocations = (options) => {
552
+ return (options?.client ?? client).get({
553
+ ...options,
554
+ url: "/v1/connect/googlebusiness/locations"
555
+ });
556
+ };
557
+ var postV1ConnectGooglebusinessSelectLocation = (options) => {
558
+ return (options?.client ?? client).post({
559
+ ...options,
560
+ url: "/v1/connect/googlebusiness/select-location"
561
+ });
562
+ };
563
+ var getV1AccountsByAccountIdGmbReviews = (options) => {
564
+ return (options?.client ?? client).get({
565
+ ...options,
566
+ url: "/v1/accounts/{accountId}/gmb-reviews"
567
+ });
568
+ };
569
+ var getV1ConnectLinkedinOrganizations = (options) => {
570
+ return (options?.client ?? client).get({
571
+ ...options,
572
+ url: "/v1/connect/linkedin/organizations"
573
+ });
574
+ };
575
+ var postV1ConnectLinkedinSelectOrganization = (options) => {
576
+ return (options?.client ?? client).post({
577
+ ...options,
578
+ url: "/v1/connect/linkedin/select-organization"
579
+ });
580
+ };
581
+ var getV1ConnectPinterestSelectBoard = (options) => {
582
+ return (options?.client ?? client).get({
583
+ ...options,
584
+ url: "/v1/connect/pinterest/select-board"
585
+ });
586
+ };
587
+ var postV1ConnectPinterestSelectBoard = (options) => {
588
+ return (options?.client ?? client).post({
589
+ ...options,
590
+ url: "/v1/connect/pinterest/select-board"
591
+ });
592
+ };
593
+ var getV1ConnectSnapchatSelectProfile = (options) => {
594
+ return (options?.client ?? client).get({
595
+ ...options,
596
+ url: "/v1/connect/snapchat/select-profile"
597
+ });
598
+ };
599
+ var postV1ConnectSnapchatSelectProfile = (options) => {
600
+ return (options?.client ?? client).post({
601
+ ...options,
602
+ url: "/v1/connect/snapchat/select-profile"
603
+ });
604
+ };
605
+ var postV1ConnectBlueskyCredentials = (options) => {
606
+ return (options?.client ?? client).post({
607
+ ...options,
608
+ url: "/v1/connect/bluesky/credentials"
609
+ });
610
+ };
611
+ var getV1ConnectTelegram = (options) => {
612
+ return (options?.client ?? client).get({
613
+ ...options,
614
+ url: "/v1/connect/telegram"
615
+ });
616
+ };
617
+ var postV1ConnectTelegram = (options) => {
618
+ return (options?.client ?? client).post({
619
+ ...options,
620
+ url: "/v1/connect/telegram"
621
+ });
622
+ };
623
+ var patchV1ConnectTelegram = (options) => {
624
+ return (options?.client ?? client).patch({
625
+ ...options,
626
+ url: "/v1/connect/telegram"
627
+ });
628
+ };
629
+ var putV1AccountsByAccountIdFacebookPage = (options) => {
630
+ return (options?.client ?? client).put({
631
+ ...options,
632
+ url: "/v1/accounts/{accountId}/facebook-page"
633
+ });
634
+ };
635
+ var getV1AccountsByAccountIdLinkedinOrganizations = (options) => {
636
+ return (options?.client ?? client).get({
637
+ ...options,
638
+ url: "/v1/accounts/{accountId}/linkedin-organizations"
639
+ });
640
+ };
641
+ var getV1AccountsByAccountIdLinkedinAggregateAnalytics = (options) => {
642
+ return (options?.client ?? client).get({
643
+ ...options,
644
+ url: "/v1/accounts/{accountId}/linkedin-aggregate-analytics"
645
+ });
646
+ };
647
+ var getV1AccountsByAccountIdLinkedinPostAnalytics = (options) => {
648
+ return (options?.client ?? client).get({
649
+ ...options,
650
+ url: "/v1/accounts/{accountId}/linkedin-post-analytics"
651
+ });
652
+ };
653
+ var putV1AccountsByAccountIdLinkedinOrganization = (options) => {
654
+ return (options?.client ?? client).put({
655
+ ...options,
656
+ url: "/v1/accounts/{accountId}/linkedin-organization"
657
+ });
658
+ };
659
+ var getV1AccountsByAccountIdLinkedinMentions = (options) => {
660
+ return (options?.client ?? client).get({
661
+ ...options,
662
+ url: "/v1/accounts/{accountId}/linkedin-mentions"
663
+ });
664
+ };
665
+ var getV1AccountsByAccountIdPinterestBoards = (options) => {
666
+ return (options?.client ?? client).get({
667
+ ...options,
668
+ url: "/v1/accounts/{accountId}/pinterest-boards"
669
+ });
670
+ };
671
+ var putV1AccountsByAccountIdPinterestBoards = (options) => {
672
+ return (options?.client ?? client).put({
673
+ ...options,
674
+ url: "/v1/accounts/{accountId}/pinterest-boards"
675
+ });
676
+ };
677
+ var getV1AccountsByAccountIdRedditSubreddits = (options) => {
678
+ return (options?.client ?? client).get({
679
+ ...options,
680
+ url: "/v1/accounts/{accountId}/reddit-subreddits"
681
+ });
682
+ };
683
+ var putV1AccountsByAccountIdRedditSubreddits = (options) => {
684
+ return (options?.client ?? client).put({
685
+ ...options,
686
+ url: "/v1/accounts/{accountId}/reddit-subreddits"
687
+ });
688
+ };
689
+ var getV1QueueSlots = (options) => {
690
+ return (options?.client ?? client).get({
691
+ ...options,
692
+ url: "/v1/queue/slots"
693
+ });
694
+ };
695
+ var postV1QueueSlots = (options) => {
696
+ return (options?.client ?? client).post({
697
+ ...options,
698
+ url: "/v1/queue/slots"
699
+ });
700
+ };
701
+ var putV1QueueSlots = (options) => {
702
+ return (options?.client ?? client).put({
703
+ ...options,
704
+ url: "/v1/queue/slots"
705
+ });
706
+ };
707
+ var deleteV1QueueSlots = (options) => {
708
+ return (options?.client ?? client).delete({
709
+ ...options,
710
+ url: "/v1/queue/slots"
711
+ });
712
+ };
713
+ var getV1QueuePreview = (options) => {
714
+ return (options?.client ?? client).get({
715
+ ...options,
716
+ url: "/v1/queue/preview"
717
+ });
718
+ };
719
+ var getV1QueueNextSlot = (options) => {
720
+ return (options?.client ?? client).get({
721
+ ...options,
722
+ url: "/v1/queue/next-slot"
723
+ });
724
+ };
725
+ var getV1WebhooksSettings = (options) => {
726
+ return (options?.client ?? client).get({
727
+ ...options,
728
+ url: "/v1/webhooks/settings"
729
+ });
730
+ };
731
+ var postV1WebhooksSettings = (options) => {
732
+ return (options?.client ?? client).post({
733
+ ...options,
734
+ url: "/v1/webhooks/settings"
735
+ });
736
+ };
737
+ var putV1WebhooksSettings = (options) => {
738
+ return (options?.client ?? client).put({
739
+ ...options,
740
+ url: "/v1/webhooks/settings"
741
+ });
742
+ };
743
+ var deleteV1WebhooksSettings = (options) => {
744
+ return (options?.client ?? client).delete({
745
+ ...options,
746
+ url: "/v1/webhooks/settings"
747
+ });
748
+ };
749
+ var postV1WebhooksTest = (options) => {
750
+ return (options?.client ?? client).post({
751
+ ...options,
752
+ url: "/v1/webhooks/test"
753
+ });
754
+ };
755
+ var getV1WebhooksLogs = (options) => {
756
+ return (options?.client ?? client).get({
757
+ ...options,
758
+ url: "/v1/webhooks/logs"
759
+ });
760
+ };
761
+ var getV1Logs = (options) => {
762
+ return (options?.client ?? client).get({
763
+ ...options,
764
+ url: "/v1/logs"
765
+ });
766
+ };
767
+ var getV1LogsByLogId = (options) => {
768
+ return (options?.client ?? client).get({
769
+ ...options,
770
+ url: "/v1/logs/{logId}"
771
+ });
772
+ };
773
+ var getV1PostsByPostIdLogs = (options) => {
774
+ return (options?.client ?? client).get({
775
+ ...options,
776
+ url: "/v1/posts/{postId}/logs"
777
+ });
778
+ };
779
+
780
+ // src/errors.ts
781
+ var LateApiError = class _LateApiError extends Error {
782
+ constructor(message, statusCode, code, details) {
783
+ super(message);
784
+ this.name = "LateApiError";
785
+ this.statusCode = statusCode;
786
+ this.code = code;
787
+ this.details = details;
788
+ if (Error.captureStackTrace) {
789
+ Error.captureStackTrace(this, _LateApiError);
790
+ }
791
+ }
792
+ /**
793
+ * Check if this is a rate limit error
794
+ */
795
+ isRateLimited() {
796
+ return this.statusCode === 429;
797
+ }
798
+ /**
799
+ * Check if this is an authentication error
800
+ */
801
+ isAuthError() {
802
+ return this.statusCode === 401;
803
+ }
804
+ /**
805
+ * Check if this is a permission/access error
806
+ */
807
+ isForbidden() {
808
+ return this.statusCode === 403;
809
+ }
810
+ /**
811
+ * Check if this is a not found error
812
+ */
813
+ isNotFound() {
814
+ return this.statusCode === 404;
815
+ }
816
+ /**
817
+ * Check if this is a validation error
818
+ */
819
+ isValidationError() {
820
+ return this.statusCode === 400;
821
+ }
822
+ /**
823
+ * Check if this is a payment required error
824
+ */
825
+ isPaymentRequired() {
826
+ return this.statusCode === 402;
827
+ }
828
+ };
829
+ var RateLimitError = class extends LateApiError {
830
+ constructor(message, limit, remaining, resetAt) {
831
+ super(message, 429, "rate_limit_exceeded");
832
+ this.name = "RateLimitError";
833
+ this.limit = limit;
834
+ this.remaining = remaining;
835
+ this.resetAt = resetAt;
836
+ }
837
+ /**
838
+ * Get seconds until rate limit resets
839
+ */
840
+ getSecondsUntilReset() {
841
+ if (!this.resetAt) return void 0;
842
+ return Math.max(0, Math.ceil((this.resetAt.getTime() - Date.now()) / 1e3));
843
+ }
844
+ };
845
+ var ValidationError = class extends LateApiError {
846
+ constructor(message, fields) {
847
+ super(message, 400, "validation_error", { fields });
848
+ this.name = "ValidationError";
849
+ this.fields = fields;
850
+ }
851
+ };
852
+ function parseApiError(response, body) {
853
+ const message = body?.error || body?.message || response.statusText || "Unknown error";
854
+ const code = body?.code;
855
+ const details = body?.details;
856
+ if (response.status === 429) {
857
+ const limit = response.headers.get("X-RateLimit-Limit");
858
+ const remaining = response.headers.get("X-RateLimit-Remaining");
859
+ const reset = response.headers.get("X-RateLimit-Reset");
860
+ return new RateLimitError(
861
+ message,
862
+ limit ? parseInt(limit, 10) : void 0,
863
+ remaining ? parseInt(remaining, 10) : void 0,
864
+ reset ? new Date(parseInt(reset, 10) * 1e3) : void 0
865
+ );
866
+ }
867
+ if (response.status === 400 && details?.fields) {
868
+ return new ValidationError(message, details.fields);
869
+ }
870
+ return new LateApiError(message, response.status, code, details);
871
+ }
872
+
873
+ // src/client.ts
874
+ var Late = class {
875
+ /**
876
+ * Create a new Late API client.
877
+ *
878
+ * @param options - Configuration options for the client
879
+ */
880
+ constructor(options = {}) {
881
+ /**
882
+ * Posts API - Create, schedule, and manage social media posts
883
+ */
884
+ this.posts = {
885
+ list: getV1Posts,
886
+ create: postV1Posts,
887
+ get: getV1PostsByPostId,
888
+ update: putV1PostsByPostId,
889
+ delete: deleteV1PostsByPostId,
890
+ retry: postV1PostsByPostIdRetry,
891
+ bulkUpload: postV1PostsBulkUpload,
892
+ getLogs: getV1PostsByPostIdLogs
893
+ };
894
+ /**
895
+ * Accounts API - Manage connected social media accounts
896
+ */
897
+ this.accounts = {
898
+ list: getV1Accounts,
899
+ update: putV1AccountsByAccountId,
900
+ delete: deleteV1AccountsByAccountId,
901
+ getFollowerStats: getV1AccountsFollowerStats,
902
+ getAllHealth: getV1AccountsHealth,
903
+ getHealth: getV1AccountsByAccountIdHealth,
904
+ updateFacebookPage: putV1AccountsByAccountIdFacebookPage,
905
+ getLinkedInOrganizations: getV1AccountsByAccountIdLinkedinOrganizations,
906
+ updateLinkedInOrganization: putV1AccountsByAccountIdLinkedinOrganization,
907
+ getLinkedInMentions: getV1AccountsByAccountIdLinkedinMentions,
908
+ getPinterestBoards: getV1AccountsByAccountIdPinterestBoards,
909
+ updatePinterestBoards: putV1AccountsByAccountIdPinterestBoards,
910
+ getRedditSubreddits: getV1AccountsByAccountIdRedditSubreddits,
911
+ updateRedditSubreddits: putV1AccountsByAccountIdRedditSubreddits,
912
+ getGoogleBusinessReviews: getV1AccountsByAccountIdGmbReviews
913
+ };
914
+ /**
915
+ * Profiles API - Manage workspace profiles
916
+ */
917
+ this.profiles = {
918
+ list: getV1Profiles,
919
+ create: postV1Profiles,
920
+ get: getV1ProfilesByProfileId,
921
+ update: putV1ProfilesByProfileId,
922
+ delete: deleteV1ProfilesByProfileId
923
+ };
924
+ /**
925
+ * Analytics API - Get performance metrics
926
+ */
927
+ this.analytics = {
928
+ get: getV1Analytics,
929
+ getYouTubeDailyViews: getV1AnalyticsYoutubeDailyViews,
930
+ getLinkedInAggregate: getV1AccountsByAccountIdLinkedinAggregateAnalytics,
931
+ getLinkedInPostAnalytics: getV1AccountsByAccountIdLinkedinPostAnalytics
932
+ };
933
+ /**
934
+ * Account Groups API - Organize accounts into groups
935
+ */
936
+ this.accountGroups = {
937
+ list: getV1AccountGroups,
938
+ create: postV1AccountGroups,
939
+ update: putV1AccountGroupsByGroupId,
940
+ delete: deleteV1AccountGroupsByGroupId
941
+ };
942
+ /**
943
+ * Queue API - Manage posting queue
944
+ */
945
+ this.queue = {
946
+ listSlots: getV1QueueSlots,
947
+ createSlot: postV1QueueSlots,
948
+ updateSlot: putV1QueueSlots,
949
+ deleteSlot: deleteV1QueueSlots,
950
+ preview: getV1QueuePreview,
951
+ getNextSlot: getV1QueueNextSlot
952
+ };
953
+ /**
954
+ * Webhooks API - Configure event webhooks
955
+ */
956
+ this.webhooks = {
957
+ getSettings: getV1WebhooksSettings,
958
+ createSettings: postV1WebhooksSettings,
959
+ updateSettings: putV1WebhooksSettings,
960
+ deleteSettings: deleteV1WebhooksSettings,
961
+ test: postV1WebhooksTest,
962
+ getLogs: getV1WebhooksLogs
963
+ };
964
+ /**
965
+ * API Keys API - Manage API keys
966
+ */
967
+ this.apiKeys = {
968
+ list: getV1ApiKeys,
969
+ create: postV1ApiKeys,
970
+ delete: deleteV1ApiKeysByKeyId
971
+ };
972
+ /**
973
+ * Media API - Upload and manage media files
974
+ */
975
+ this.media = {
976
+ getPresignedUrl: postV1MediaPresign
977
+ };
978
+ /**
979
+ * Tools API - Media download and utilities
980
+ */
981
+ this.tools = {
982
+ downloadYouTube: getV1ToolsYoutubeDownload,
983
+ getYouTubeTranscript: getV1ToolsYoutubeTranscript,
984
+ downloadInstagram: getV1ToolsInstagramDownload,
985
+ checkInstagramHashtags: postV1ToolsInstagramHashtagChecker,
986
+ downloadTikTok: getV1ToolsTiktokDownload,
987
+ downloadTwitter: getV1ToolsTwitterDownload,
988
+ downloadFacebook: getV1ToolsFacebookDownload,
989
+ downloadLinkedIn: getV1ToolsLinkedinDownload,
990
+ downloadBluesky: getV1ToolsBlueskyDownload
991
+ };
992
+ /**
993
+ * Users API - User management
994
+ */
995
+ this.users = {
996
+ list: getV1Users,
997
+ get: getV1UsersByUserId
998
+ };
999
+ /**
1000
+ * Usage API - Get usage statistics
1001
+ */
1002
+ this.usage = {
1003
+ getStats: getV1UsageStats
1004
+ };
1005
+ /**
1006
+ * Logs API - Publishing logs
1007
+ */
1008
+ this.logs = {
1009
+ list: getV1Logs,
1010
+ get: getV1LogsByLogId
1011
+ };
1012
+ /**
1013
+ * Connect API - OAuth connection flows
1014
+ */
1015
+ this.connect = {
1016
+ getUrl: getV1ConnectByPlatform,
1017
+ handleCallback: postV1ConnectByPlatform,
1018
+ facebook: {
1019
+ listPages: getV1ConnectFacebookSelectPage,
1020
+ selectPage: postV1ConnectFacebookSelectPage
1021
+ },
1022
+ googleBusiness: {
1023
+ listLocations: getV1ConnectGooglebusinessLocations,
1024
+ selectLocation: postV1ConnectGooglebusinessSelectLocation
1025
+ },
1026
+ linkedIn: {
1027
+ listOrganizations: getV1ConnectLinkedinOrganizations,
1028
+ selectOrganization: postV1ConnectLinkedinSelectOrganization
1029
+ },
1030
+ pinterest: {
1031
+ listBoards: getV1ConnectPinterestSelectBoard,
1032
+ selectBoard: postV1ConnectPinterestSelectBoard
1033
+ },
1034
+ snapchat: {
1035
+ listProfiles: getV1ConnectSnapchatSelectProfile,
1036
+ selectProfile: postV1ConnectSnapchatSelectProfile
1037
+ },
1038
+ bluesky: {
1039
+ connectCredentials: postV1ConnectBlueskyCredentials
1040
+ },
1041
+ telegram: {
1042
+ getStatus: getV1ConnectTelegram,
1043
+ initiate: postV1ConnectTelegram,
1044
+ complete: patchV1ConnectTelegram
1045
+ }
1046
+ };
1047
+ /**
1048
+ * Reddit API - Search and feed
1049
+ */
1050
+ this.reddit = {
1051
+ search: getV1RedditSearch,
1052
+ getFeed: getV1RedditFeed
1053
+ };
1054
+ /**
1055
+ * Invites API - Team invitations
1056
+ */
1057
+ this.invites = {
1058
+ createToken: postV1InviteTokens,
1059
+ list: getV1PlatformInvites,
1060
+ create: postV1PlatformInvites,
1061
+ delete: deleteV1PlatformInvites
1062
+ };
1063
+ const apiKey = options.apiKey ?? process.env["LATE_API_KEY"];
1064
+ if (!apiKey) {
1065
+ throw new LateApiError(
1066
+ "The LATE_API_KEY environment variable is missing or empty; either provide it, or instantiate the Late client with an apiKey option, like new Late({ apiKey: 'sk_...' }).",
1067
+ 401,
1068
+ "missing_api_key"
1069
+ );
1070
+ }
1071
+ this.apiKey = apiKey;
1072
+ this.baseURL = options.baseURL ?? "https://getlate.dev/api";
1073
+ this._options = options;
1074
+ client.setConfig({
1075
+ baseUrl: this.baseURL
1076
+ });
1077
+ client.interceptors.request.use((request) => {
1078
+ request.headers.set("Authorization", `Bearer ${this.apiKey}`);
1079
+ if (options.defaultHeaders) {
1080
+ for (const [key, value] of Object.entries(options.defaultHeaders)) {
1081
+ request.headers.set(key, value);
1082
+ }
1083
+ }
1084
+ return request;
1085
+ });
1086
+ client.interceptors.response.use(async (response) => {
1087
+ if (!response.ok) {
1088
+ let body;
1089
+ try {
1090
+ body = await response.clone().json();
1091
+ } catch {
1092
+ }
1093
+ throw parseApiError(response, body);
1094
+ }
1095
+ return response;
1096
+ });
1097
+ }
1098
+ };
1099
+ export {
1100
+ Late,
1101
+ LateApiError,
1102
+ RateLimitError,
1103
+ ValidationError,
1104
+ Late as default,
1105
+ parseApiError
1106
+ };