@smartlyqofficial/node 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,969 @@
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
+ AccountResource: () => AccountResource,
24
+ AnalyticsResource: () => AnalyticsResource,
25
+ ArticlesResource: () => ArticlesResource,
26
+ AudioResource: () => AudioResource,
27
+ CaptainResource: () => CaptainResource,
28
+ ChatbotsResource: () => ChatbotsResource,
29
+ CommentsResource: () => CommentsResource,
30
+ ContactsResource: () => ContactsResource,
31
+ ContentResource: () => ContentResource,
32
+ CoreClient: () => CoreClient,
33
+ CustomFieldsResource: () => CustomFieldsResource,
34
+ ImagesResource: () => ImagesResource,
35
+ JobsResource: () => JobsResource,
36
+ MediaResource: () => MediaResource,
37
+ MessagesResource: () => MessagesResource,
38
+ OpportunitiesResource: () => OpportunitiesResource,
39
+ PresentationsResource: () => PresentationsResource,
40
+ ProfilesResource: () => ProfilesResource,
41
+ SeoResource: () => SeoResource,
42
+ ShortsResource: () => ShortsResource,
43
+ SmartlyQ: () => SmartlyQ,
44
+ SmartlyQConnectionError: () => SmartlyQConnectionError,
45
+ SmartlyQError: () => SmartlyQError,
46
+ SocialResource: () => SocialResource,
47
+ UrlsResource: () => UrlsResource,
48
+ VideosResource: () => VideosResource,
49
+ WebhooksResource: () => WebhooksResource,
50
+ WorkspacesResource: () => WorkspacesResource,
51
+ createResources: () => createResources,
52
+ default: () => index_default
53
+ });
54
+ module.exports = __toCommonJS(index_exports);
55
+
56
+ // src/core.ts
57
+ var SmartlyQError = class extends Error {
58
+ constructor(status, envelope, fallback) {
59
+ super(envelope?.error?.message ?? fallback);
60
+ this.name = "SmartlyQError";
61
+ this.status = status;
62
+ this.code = envelope?.error?.code;
63
+ this.details = envelope?.error?.details;
64
+ this.requestId = envelope?.meta?.request_id;
65
+ }
66
+ };
67
+ var SmartlyQConnectionError = class extends Error {
68
+ constructor(message, cause) {
69
+ super(message);
70
+ this.cause = cause;
71
+ this.name = "SmartlyQConnectionError";
72
+ }
73
+ };
74
+ var RETRYABLE_STATUSES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
75
+ var CoreClient = class {
76
+ constructor(options = {}) {
77
+ const apiKey = options.apiKey ?? (typeof process !== "undefined" ? process.env?.SMARTLYQ_API_KEY : void 0);
78
+ if (!apiKey) {
79
+ throw new Error(
80
+ "Missing API key. Pass `apiKey` to the client or set the SMARTLYQ_API_KEY environment variable."
81
+ );
82
+ }
83
+ this.apiKey = apiKey;
84
+ this.baseUrl = (options.baseUrl ?? "https://api.smartlyq.com/v1").replace(/\/+$/, "");
85
+ this.timeout = options.timeout ?? 6e4;
86
+ this.maxRetries = options.maxRetries ?? 2;
87
+ this.defaultHeaders = options.defaultHeaders ?? {};
88
+ this.fetchImpl = options.fetch ?? globalThis.fetch;
89
+ if (!this.fetchImpl) {
90
+ throw new Error("No fetch implementation available. Use Node 18+ or pass `fetch`.");
91
+ }
92
+ }
93
+ async request(method, path, req = {}) {
94
+ const url = this.buildUrl(path, req.query);
95
+ const headers = {
96
+ Authorization: `Bearer ${this.apiKey}`,
97
+ Accept: "application/json",
98
+ "User-Agent": "@smartlyqofficial/node",
99
+ ...this.defaultHeaders,
100
+ ...req.options?.headers
101
+ };
102
+ if (req.body !== void 0) headers["Content-Type"] = "application/json";
103
+ if (req.options?.profileId) headers["X-Profile-Id"] = req.options.profileId;
104
+ if (req.options?.idempotencyKey) headers["Idempotency-Key"] = req.options.idempotencyKey;
105
+ const timeout = req.options?.timeout ?? this.timeout;
106
+ let lastError;
107
+ for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
108
+ const controller = new AbortController();
109
+ const timer = setTimeout(() => controller.abort(), timeout);
110
+ const onOuterAbort = () => controller.abort();
111
+ req.options?.signal?.addEventListener("abort", onOuterAbort);
112
+ let response;
113
+ try {
114
+ response = await this.fetchImpl(url, {
115
+ method,
116
+ headers,
117
+ body: req.body !== void 0 ? JSON.stringify(req.body) : void 0,
118
+ signal: controller.signal
119
+ });
120
+ } catch (err) {
121
+ lastError = err;
122
+ if (req.options?.signal?.aborted) {
123
+ throw new SmartlyQConnectionError("Request aborted", err);
124
+ }
125
+ if (attempt < this.maxRetries) {
126
+ await sleep(backoffMs(attempt));
127
+ continue;
128
+ }
129
+ throw new SmartlyQConnectionError(`Request failed: ${String(err)}`, err);
130
+ } finally {
131
+ clearTimeout(timer);
132
+ req.options?.signal?.removeEventListener("abort", onOuterAbort);
133
+ }
134
+ if (response.ok) {
135
+ if (response.status === 204) return void 0;
136
+ return await response.json();
137
+ }
138
+ const envelope = await response.json().catch(() => void 0);
139
+ if (RETRYABLE_STATUSES.has(response.status) && attempt < this.maxRetries) {
140
+ const retryAfter = Number(response.headers.get("Retry-After"));
141
+ await sleep(retryAfter > 0 ? retryAfter * 1e3 : backoffMs(attempt));
142
+ continue;
143
+ }
144
+ throw new SmartlyQError(response.status, envelope, `HTTP ${response.status}`);
145
+ }
146
+ throw new SmartlyQConnectionError(`Request failed: ${String(lastError)}`, lastError);
147
+ }
148
+ buildUrl(path, query) {
149
+ const url = new URL(this.baseUrl + path);
150
+ if (query) {
151
+ for (const [key, value] of Object.entries(query)) {
152
+ if (value === void 0 || value === null) continue;
153
+ if (Array.isArray(value)) {
154
+ for (const item of value) url.searchParams.append(key, String(item));
155
+ } else {
156
+ url.searchParams.set(key, String(value));
157
+ }
158
+ }
159
+ }
160
+ return url.toString();
161
+ }
162
+ };
163
+ function backoffMs(attempt) {
164
+ const base = 500 * 2 ** attempt;
165
+ return base + Math.random() * base * 0.25;
166
+ }
167
+ function sleep(ms) {
168
+ return new Promise((resolve) => setTimeout(resolve, ms));
169
+ }
170
+
171
+ // src/resources.gen.ts
172
+ var AccountResource = class {
173
+ constructor(_client) {
174
+ this._client = _client;
175
+ }
176
+ /** Get current user profile `GET /me` */
177
+ getMe(options) {
178
+ return this._client.request("GET", "/me", { options });
179
+ }
180
+ /** Get usage summary `GET /me/usage` */
181
+ getMeUsage(query, options) {
182
+ return this._client.request("GET", "/me/usage", { query, options });
183
+ }
184
+ /** Get wallet balance `GET /me/balance` */
185
+ getMeBalance(options) {
186
+ return this._client.request("GET", "/me/balance", { options });
187
+ }
188
+ };
189
+ var CaptainResource = class {
190
+ constructor(_client) {
191
+ this._client = _client;
192
+ }
193
+ /** Send AI Captain message `POST /captain/messages` */
194
+ sendMessage(body, options) {
195
+ return this._client.request("POST", "/captain/messages", { body, options });
196
+ }
197
+ /** List AI Captain conversations `GET /captain/conversations` */
198
+ listConversations(query, options) {
199
+ return this._client.request("GET", "/captain/conversations", { query, options });
200
+ }
201
+ /** Get AI Captain conversation `GET /captain/conversations/{conversation_id}` */
202
+ getConversation(conversationId, options) {
203
+ return this._client.request("GET", `/captain/conversations/${encodeURIComponent(conversationId)}`, { options });
204
+ }
205
+ };
206
+ var AnalyticsResource = class {
207
+ constructor(_client) {
208
+ this._client = _client;
209
+ }
210
+ /** Get analytics overview `GET /analytics/overview` */
211
+ getOverview(query, options) {
212
+ return this._client.request("GET", "/analytics/overview", { query, options });
213
+ }
214
+ /** Get post analytics `GET /analytics/posts` */
215
+ getPosts(query, options) {
216
+ return this._client.request("GET", "/analytics/posts", { query, options });
217
+ }
218
+ /** Get account analytics `GET /analytics/accounts/{account_id}` */
219
+ getAccount(accountId, query, options) {
220
+ return this._client.request("GET", `/analytics/accounts/${encodeURIComponent(accountId)}`, { query, options });
221
+ }
222
+ };
223
+ var ArticlesResource = class {
224
+ constructor(_client) {
225
+ this._client = _client;
226
+ }
227
+ /** Generate article `POST /articles/generate` */
228
+ generate(body, options) {
229
+ return this._client.request("POST", "/articles/generate", { body, options });
230
+ }
231
+ /** List articles `GET /articles` */
232
+ list(query, options) {
233
+ return this._client.request("GET", "/articles", { query, options });
234
+ }
235
+ /** Get article `GET /articles/{article_id}` */
236
+ get(articleId, options) {
237
+ return this._client.request("GET", `/articles/${encodeURIComponent(articleId)}`, { options });
238
+ }
239
+ /** Delete article `DELETE /articles/{article_id}` */
240
+ delete(articleId, options) {
241
+ return this._client.request("DELETE", `/articles/${encodeURIComponent(articleId)}`, { options });
242
+ }
243
+ };
244
+ var AudioResource = class {
245
+ constructor(_client) {
246
+ this._client = _client;
247
+ }
248
+ /** Text to speech `POST /audio/text-to-speech` */
249
+ textToSpeech(body, options) {
250
+ return this._client.request("POST", "/audio/text-to-speech", { body, options });
251
+ }
252
+ /** Speech to text `POST /audio/speech-to-text` */
253
+ speechToText(body, options) {
254
+ return this._client.request("POST", "/audio/speech-to-text", { body, options });
255
+ }
256
+ /** Get audio `GET /audio/{audio_id}` */
257
+ get(audioId, options) {
258
+ return this._client.request("GET", `/audio/${encodeURIComponent(audioId)}`, { options });
259
+ }
260
+ };
261
+ var ChatbotsResource = class {
262
+ constructor(_client) {
263
+ this._client = _client;
264
+ }
265
+ /** List chatbots `GET /chatbots` */
266
+ list(query, options) {
267
+ return this._client.request("GET", "/chatbots", { query, options });
268
+ }
269
+ /** Create chatbot `POST /chatbots` */
270
+ create(body, options) {
271
+ return this._client.request("POST", "/chatbots", { body, options });
272
+ }
273
+ /** Get chatbot `GET /chatbots/{id}` */
274
+ get(id, options) {
275
+ return this._client.request("GET", `/chatbots/${encodeURIComponent(id)}`, { options });
276
+ }
277
+ /** Update chatbot `PATCH /chatbots/{id}` */
278
+ update(id, body, options) {
279
+ return this._client.request("PATCH", `/chatbots/${encodeURIComponent(id)}`, { body, options });
280
+ }
281
+ /** Delete chatbot `DELETE /chatbots/{id}` */
282
+ delete(id, options) {
283
+ return this._client.request("DELETE", `/chatbots/${encodeURIComponent(id)}`, { options });
284
+ }
285
+ /** Start chatbot training `POST /chatbots/{id}/train` */
286
+ train(id, options) {
287
+ return this._client.request("POST", `/chatbots/${encodeURIComponent(id)}/train`, { options });
288
+ }
289
+ /** Get chatbot training status `GET /chatbots/{id}/train-status` */
290
+ getTrainStatus(id, options) {
291
+ return this._client.request("GET", `/chatbots/${encodeURIComponent(id)}/train-status`, { options });
292
+ }
293
+ /** Send chatbot message `POST /chatbots/{id}/messages` */
294
+ sendMessage(id, body, options) {
295
+ return this._client.request("POST", `/chatbots/${encodeURIComponent(id)}/messages`, { body, options });
296
+ }
297
+ /** List chatbot conversations `GET /chatbots/{id}/conversations` */
298
+ listConversations(id, query, options) {
299
+ return this._client.request("GET", `/chatbots/${encodeURIComponent(id)}/conversations`, { query, options });
300
+ }
301
+ /** Get conversation messages `GET /chatbots/{id}/conversations/{conv_id}/messages` */
302
+ getConversationMessages(id, convId, options) {
303
+ return this._client.request("GET", `/chatbots/${encodeURIComponent(id)}/conversations/${encodeURIComponent(convId)}/messages`, { options });
304
+ }
305
+ };
306
+ var CommentsResource = class {
307
+ constructor(_client) {
308
+ this._client = _client;
309
+ }
310
+ /** List comments `GET /social/comments` */
311
+ list(query, options) {
312
+ return this._client.request("GET", "/social/comments", { query, options });
313
+ }
314
+ /** Reply to a comment `POST /social/comments/{comment_id}/reply` */
315
+ replyTo(commentId, body, options) {
316
+ return this._client.request("POST", `/social/comments/${encodeURIComponent(commentId)}/reply`, { body, options });
317
+ }
318
+ /** Hide or unhide a comment `POST /social/comments/{comment_id}/hide` */
319
+ hide(commentId, options) {
320
+ return this._client.request("POST", `/social/comments/${encodeURIComponent(commentId)}/hide`, { options });
321
+ }
322
+ /** Delete a comment `DELETE /social/comments/{comment_id}` */
323
+ delete(commentId, options) {
324
+ return this._client.request("DELETE", `/social/comments/${encodeURIComponent(commentId)}`, { options });
325
+ }
326
+ };
327
+ var ContentResource = class {
328
+ constructor(_client) {
329
+ this._client = _client;
330
+ }
331
+ /** Rewrite content `POST /content/rewrite` */
332
+ rewrite(body, options) {
333
+ return this._client.request("POST", "/content/rewrite", { body, options });
334
+ }
335
+ /** Generate a social caption `POST /content/caption` */
336
+ generateCaption(body, options) {
337
+ return this._client.request("POST", "/content/caption", { body, options });
338
+ }
339
+ };
340
+ var ContactsResource = class {
341
+ constructor(_client) {
342
+ this._client = _client;
343
+ }
344
+ /** List contacts `GET /contacts` */
345
+ list(query, options) {
346
+ return this._client.request("GET", "/contacts", { query, options });
347
+ }
348
+ /** Create or upsert a contact `POST /contacts` */
349
+ create(body, options) {
350
+ return this._client.request("POST", "/contacts", { body, options });
351
+ }
352
+ /** Get a contact `GET /contacts/{id}` */
353
+ get(id, options) {
354
+ return this._client.request("GET", `/contacts/${encodeURIComponent(id)}`, { options });
355
+ }
356
+ /** Update a contact `PATCH /contacts/{id}` */
357
+ update(id, body, options) {
358
+ return this._client.request("PATCH", `/contacts/${encodeURIComponent(id)}`, { body, options });
359
+ }
360
+ /** Add tags to a contact `POST /contacts/{id}/tags` */
361
+ addTags(id, body, options) {
362
+ return this._client.request("POST", `/contacts/${encodeURIComponent(id)}/tags`, { body, options });
363
+ }
364
+ /** Remove tags from a contact `DELETE /contacts/{id}/tags` */
365
+ removeTags(id, body, options) {
366
+ return this._client.request("DELETE", `/contacts/${encodeURIComponent(id)}/tags`, { body, options });
367
+ }
368
+ /** List contact notes `GET /contacts/{id}/notes` */
369
+ listNotes(id, options) {
370
+ return this._client.request("GET", `/contacts/${encodeURIComponent(id)}/notes`, { options });
371
+ }
372
+ /** Add a note to a contact `POST /contacts/{id}/notes` */
373
+ addNote(id, body, options) {
374
+ return this._client.request("POST", `/contacts/${encodeURIComponent(id)}/notes`, { body, options });
375
+ }
376
+ /** Enroll a contact in an automation `POST /contacts/{id}/enroll` */
377
+ enroll(id, body, options) {
378
+ return this._client.request("POST", `/contacts/${encodeURIComponent(id)}/enroll`, { body, options });
379
+ }
380
+ /** Log a message on a contact's timeline `POST /contacts/{id}/messages` */
381
+ addMessage(id, body, options) {
382
+ return this._client.request("POST", `/contacts/${encodeURIComponent(id)}/messages`, { body, options });
383
+ }
384
+ };
385
+ var CustomFieldsResource = class {
386
+ constructor(_client) {
387
+ this._client = _client;
388
+ }
389
+ /** List custom fields `GET /custom-fields` */
390
+ list(options) {
391
+ return this._client.request("GET", "/custom-fields", { options });
392
+ }
393
+ /** Create a custom field `POST /custom-fields` */
394
+ create(body, options) {
395
+ return this._client.request("POST", "/custom-fields", { body, options });
396
+ }
397
+ /** Delete a custom field `DELETE /custom-fields/{id}` */
398
+ delete(id, options) {
399
+ return this._client.request("DELETE", `/custom-fields/${encodeURIComponent(id)}`, { options });
400
+ }
401
+ };
402
+ var OpportunitiesResource = class {
403
+ constructor(_client) {
404
+ this._client = _client;
405
+ }
406
+ /** List pipelines `GET /pipelines` */
407
+ listPipelines(options) {
408
+ return this._client.request("GET", "/pipelines", { options });
409
+ }
410
+ /** Create a pipeline `POST /pipelines` */
411
+ createPipeline(body, options) {
412
+ return this._client.request("POST", "/pipelines", { body, options });
413
+ }
414
+ /** List opportunities `GET /opportunities` */
415
+ list(query, options) {
416
+ return this._client.request("GET", "/opportunities", { query, options });
417
+ }
418
+ /** Create an opportunity `POST /opportunities` */
419
+ create(body, options) {
420
+ return this._client.request("POST", "/opportunities", { body, options });
421
+ }
422
+ /** Get an opportunity `GET /opportunities/{id}` */
423
+ get(id, options) {
424
+ return this._client.request("GET", `/opportunities/${encodeURIComponent(id)}`, { options });
425
+ }
426
+ /** Update an opportunity `PATCH /opportunities/{id}` */
427
+ update(id, body, options) {
428
+ return this._client.request("PATCH", `/opportunities/${encodeURIComponent(id)}`, { body, options });
429
+ }
430
+ /** Delete an opportunity `DELETE /opportunities/{id}` */
431
+ delete(id, options) {
432
+ return this._client.request("DELETE", `/opportunities/${encodeURIComponent(id)}`, { options });
433
+ }
434
+ /** Update opportunity status `POST /opportunities/{id}/status` */
435
+ updateStatus(id, body, options) {
436
+ return this._client.request("POST", `/opportunities/${encodeURIComponent(id)}/status`, { body, options });
437
+ }
438
+ };
439
+ var MessagesResource = class {
440
+ constructor(_client) {
441
+ this._client = _client;
442
+ }
443
+ /** List DM conversations `GET /social/conversations` */
444
+ listConversations(query, options) {
445
+ return this._client.request("GET", "/social/conversations", { query, options });
446
+ }
447
+ /** List messages in a conversation `GET /social/conversations/{conversation_id}/messages` */
448
+ list(conversationId, query, options) {
449
+ return this._client.request("GET", `/social/conversations/${encodeURIComponent(conversationId)}/messages`, { query, options });
450
+ }
451
+ /** Send a direct message `POST /social/conversations/{conversation_id}/messages` */
452
+ send(conversationId, body, options) {
453
+ return this._client.request("POST", `/social/conversations/${encodeURIComponent(conversationId)}/messages`, { body, options });
454
+ }
455
+ /** Mark a conversation read `POST /social/conversations/{conversation_id}/read` */
456
+ markConversationRead(conversationId, options) {
457
+ return this._client.request("POST", `/social/conversations/${encodeURIComponent(conversationId)}/read`, { options });
458
+ }
459
+ };
460
+ var ImagesResource = class {
461
+ constructor(_client) {
462
+ this._client = _client;
463
+ }
464
+ /** Generate image `POST /images/generate` */
465
+ generate(body, options) {
466
+ return this._client.request("POST", "/images/generate", { body, options });
467
+ }
468
+ /** List images `GET /images` */
469
+ list(query, options) {
470
+ return this._client.request("GET", "/images", { query, options });
471
+ }
472
+ /** Get image `GET /images/{image_id}` */
473
+ get(imageId, options) {
474
+ return this._client.request("GET", `/images/${encodeURIComponent(imageId)}`, { options });
475
+ }
476
+ /** Delete image `DELETE /images/{image_id}` */
477
+ delete(imageId, options) {
478
+ return this._client.request("DELETE", `/images/${encodeURIComponent(imageId)}`, { options });
479
+ }
480
+ };
481
+ var JobsResource = class {
482
+ constructor(_client) {
483
+ this._client = _client;
484
+ }
485
+ /** List jobs `GET /jobs` */
486
+ list(query, options) {
487
+ return this._client.request("GET", "/jobs", { query, options });
488
+ }
489
+ /** Get job `GET /jobs/{job_id}` */
490
+ get(jobId, options) {
491
+ return this._client.request("GET", `/jobs/${encodeURIComponent(jobId)}`, { options });
492
+ }
493
+ /** Cancel job `POST /jobs/{job_id}/cancel` */
494
+ cancel(jobId, body, options) {
495
+ return this._client.request("POST", `/jobs/${encodeURIComponent(jobId)}/cancel`, { body, options });
496
+ }
497
+ };
498
+ var MediaResource = class {
499
+ constructor(_client) {
500
+ this._client = _client;
501
+ }
502
+ /** List media `GET /media` */
503
+ list(query, options) {
504
+ return this._client.request("GET", "/media", { query, options });
505
+ }
506
+ /** Get media `GET /media/{media_id}` */
507
+ get(mediaId, options) {
508
+ return this._client.request("GET", `/media/${encodeURIComponent(mediaId)}`, { options });
509
+ }
510
+ /** Delete media `DELETE /media/{media_id}` */
511
+ delete(mediaId, options) {
512
+ return this._client.request("DELETE", `/media/${encodeURIComponent(mediaId)}`, { options });
513
+ }
514
+ /** Get presigned upload URL `POST /media/upload-url` */
515
+ getUploadUrl(body, options) {
516
+ return this._client.request("POST", "/media/upload-url", { body, options });
517
+ }
518
+ };
519
+ var PresentationsResource = class {
520
+ constructor(_client) {
521
+ this._client = _client;
522
+ }
523
+ /** Generate presentation `POST /presentations/generate` */
524
+ generate(body, options) {
525
+ return this._client.request("POST", "/presentations/generate", { body, options });
526
+ }
527
+ /** List presentations `GET /presentations` */
528
+ list(query, options) {
529
+ return this._client.request("GET", "/presentations", { query, options });
530
+ }
531
+ /** Get presentation `GET /presentations/{presentation_id}` */
532
+ get(presentationId, options) {
533
+ return this._client.request("GET", `/presentations/${encodeURIComponent(presentationId)}`, { options });
534
+ }
535
+ /** Delete presentation `DELETE /presentations/{presentation_id}` */
536
+ delete(presentationId, options) {
537
+ return this._client.request("DELETE", `/presentations/${encodeURIComponent(presentationId)}`, { options });
538
+ }
539
+ };
540
+ var ProfilesResource = class {
541
+ constructor(_client) {
542
+ this._client = _client;
543
+ }
544
+ /** List profiles `GET /profiles` */
545
+ list(query, options) {
546
+ return this._client.request("GET", "/profiles", { query, options });
547
+ }
548
+ /** Create a profile `POST /profiles` */
549
+ create(body, options) {
550
+ return this._client.request("POST", "/profiles", { body, options });
551
+ }
552
+ /** Get a profile `GET /profiles/{id}` */
553
+ get(id, options) {
554
+ return this._client.request("GET", `/profiles/${encodeURIComponent(id)}`, { options });
555
+ }
556
+ /** Delete a profile `DELETE /profiles/{id}` */
557
+ delete(id, body, options) {
558
+ return this._client.request("DELETE", `/profiles/${encodeURIComponent(id)}`, { body, options });
559
+ }
560
+ /** List a profile's connected accounts `GET /profiles/{id}/accounts` */
561
+ listAccounts(id, options) {
562
+ return this._client.request("GET", `/profiles/${encodeURIComponent(id)}/accounts`, { options });
563
+ }
564
+ /** Pause a profile `POST /profiles/{id}/pause` */
565
+ pause(id, options) {
566
+ return this._client.request("POST", `/profiles/${encodeURIComponent(id)}/pause`, { options });
567
+ }
568
+ /** Resume a profile `POST /profiles/{id}/resume` */
569
+ resume(id, options) {
570
+ return this._client.request("POST", `/profiles/${encodeURIComponent(id)}/resume`, { options });
571
+ }
572
+ /** Create a hosted connect link `POST /profiles/{id}/connect-link` */
573
+ createConnectLink(id, body, options) {
574
+ return this._client.request("POST", `/profiles/${encodeURIComponent(id)}/connect-link`, { body, options });
575
+ }
576
+ /** Get a raw connect URL for one platform `POST /profiles/{id}/connect/{platform}` */
577
+ createConnectUrl(id, platform, body, options) {
578
+ return this._client.request("POST", `/profiles/${encodeURIComponent(id)}/connect/${encodeURIComponent(platform)}`, { body, options });
579
+ }
580
+ /** Account billing summary `GET /me/account-billing` */
581
+ getAccountBilling(options) {
582
+ return this._client.request("GET", "/me/account-billing", { options });
583
+ }
584
+ };
585
+ var SeoResource = class {
586
+ constructor(_client) {
587
+ this._client = _client;
588
+ }
589
+ /** Keyword research `POST /seo/keyword-research` */
590
+ keywordResearch(body, options) {
591
+ return this._client.request("POST", "/seo/keyword-research", { body, options });
592
+ }
593
+ /** Live SERP lookup `POST /seo/serp` */
594
+ serp(body, options) {
595
+ return this._client.request("POST", "/seo/serp", { body, options });
596
+ }
597
+ /** Keyword difficulty `POST /seo/keyword-difficulty` */
598
+ keywordDifficulty(body, options) {
599
+ return this._client.request("POST", "/seo/keyword-difficulty", { body, options });
600
+ }
601
+ /** Ranked keywords (rank tracking) `POST /seo/ranked-keywords` */
602
+ rankedKeywords(body, options) {
603
+ return this._client.request("POST", "/seo/ranked-keywords", { body, options });
604
+ }
605
+ /** Domain rank overview `POST /seo/domain-overview` */
606
+ domainOverview(body, options) {
607
+ return this._client.request("POST", "/seo/domain-overview", { body, options });
608
+ }
609
+ /** Organic competitors `POST /seo/competitors` */
610
+ competitors(body, options) {
611
+ return this._client.request("POST", "/seo/competitors", { body, options });
612
+ }
613
+ /** Backlink profile summary `POST /seo/backlinks-summary` */
614
+ backlinksSummary(body, options) {
615
+ return this._client.request("POST", "/seo/backlinks-summary", { body, options });
616
+ }
617
+ /** On-page SEO audit `POST /seo/audit` */
618
+ audit(body, options) {
619
+ return this._client.request("POST", "/seo/audit", { body, options });
620
+ }
621
+ /** Backlink prospects (link gap) `POST /seo/backlink-prospects` */
622
+ backlinkProspects(body, options) {
623
+ return this._client.request("POST", "/seo/backlink-prospects", { body, options });
624
+ }
625
+ /** Referring domains `POST /seo/referring-domains` */
626
+ referringDomains(body, options) {
627
+ return this._client.request("POST", "/seo/referring-domains", { body, options });
628
+ }
629
+ /** Backlink anchors `POST /seo/backlink-anchors` */
630
+ backlinkAnchors(body, options) {
631
+ return this._client.request("POST", "/seo/backlink-anchors", { body, options });
632
+ }
633
+ /** Backlink spam score `POST /seo/spam-score` */
634
+ spamScore(body, options) {
635
+ return this._client.request("POST", "/seo/spam-score", { body, options });
636
+ }
637
+ /** Historical rank overview `POST /seo/rank-history` */
638
+ rankHistory(body, options) {
639
+ return this._client.request("POST", "/seo/rank-history", { body, options });
640
+ }
641
+ /** Deep site audit `POST /seo/site-audit` */
642
+ siteAudit(body, options) {
643
+ return this._client.request("POST", "/seo/site-audit", { body, options });
644
+ }
645
+ /** AI Visibility: brand lookup `POST /seo/brand-lookup` */
646
+ brandLookup(body, options) {
647
+ return this._client.request("POST", "/seo/brand-lookup", { body, options });
648
+ }
649
+ /** AI Visibility: prompt explorer `POST /seo/prompt-explorer` */
650
+ promptExplorer(body, options) {
651
+ return this._client.request("POST", "/seo/prompt-explorer", { body, options });
652
+ }
653
+ /** AI Visibility Audit (async) `POST /seo/ai-audit` */
654
+ aiAudit(body, options) {
655
+ return this._client.request("POST", "/seo/ai-audit", { body, options });
656
+ }
657
+ };
658
+ var ShortsResource = class {
659
+ constructor(_client) {
660
+ this._client = _client;
661
+ }
662
+ /** Generate viral shorts from a long video `POST /shorts/generate` */
663
+ generate(body, options) {
664
+ return this._client.request("POST", "/shorts/generate", { body, options });
665
+ }
666
+ /** List shorts jobs `GET /shorts` */
667
+ list(query, options) {
668
+ return this._client.request("GET", "/shorts", { query, options });
669
+ }
670
+ /** Get shorts job + clips `GET /shorts/{uid}` */
671
+ get(uid, options) {
672
+ return this._client.request("GET", `/shorts/${encodeURIComponent(uid)}`, { options });
673
+ }
674
+ };
675
+ var SocialResource = class {
676
+ constructor(_client) {
677
+ this._client = _client;
678
+ }
679
+ /** List social accounts `GET /social/accounts` */
680
+ listAccounts(options) {
681
+ return this._client.request("GET", "/social/accounts", { options });
682
+ }
683
+ /** List social posts `GET /social/posts` */
684
+ listPosts(query, options) {
685
+ return this._client.request("GET", "/social/posts", { query, options });
686
+ }
687
+ /** Create post (publish immediately) `POST /social/posts` */
688
+ createPost(body, options) {
689
+ return this._client.request("POST", "/social/posts", { body, options });
690
+ }
691
+ /** Schedule post `POST /social/posts/schedule` */
692
+ schedulePost(body, options) {
693
+ return this._client.request("POST", "/social/posts/schedule", { body, options });
694
+ }
695
+ /** Get social post `GET /social/posts/{post_id}` */
696
+ getPost(postId, options) {
697
+ return this._client.request("GET", `/social/posts/${encodeURIComponent(postId)}`, { options });
698
+ }
699
+ /** Update social post `PATCH /social/posts/{post_id}` */
700
+ updatePost(postId, body, options) {
701
+ return this._client.request("PATCH", `/social/posts/${encodeURIComponent(postId)}`, { body, options });
702
+ }
703
+ /** Delete social post `DELETE /social/posts/{post_id}` */
704
+ deletePost(postId, options) {
705
+ return this._client.request("DELETE", `/social/posts/${encodeURIComponent(postId)}`, { options });
706
+ }
707
+ /** Disconnect a social account `DELETE /social/accounts/{account_id}` */
708
+ disconnectAccount(accountId, options) {
709
+ return this._client.request("DELETE", `/social/accounts/${encodeURIComponent(accountId)}`, { options });
710
+ }
711
+ /** Account health `GET /social/accounts/{account_id}/health` */
712
+ getAccountHealth(accountId, options) {
713
+ return this._client.request("GET", `/social/accounts/${encodeURIComponent(accountId)}/health`, { options });
714
+ }
715
+ /** Account reconnect URL `GET /social/accounts/{account_id}/reconnect-url` */
716
+ getAccountReconnectUrl(accountId, options) {
717
+ return this._client.request("GET", `/social/accounts/${encodeURIComponent(accountId)}/reconnect-url`, { options });
718
+ }
719
+ /** Pause posting to an account `POST /social/accounts/{account_id}/pause` */
720
+ pauseAccount(accountId, options) {
721
+ return this._client.request("POST", `/social/accounts/${encodeURIComponent(accountId)}/pause`, { options });
722
+ }
723
+ /** Resume posting to an account `POST /social/accounts/{account_id}/resume` */
724
+ resumeAccount(accountId, options) {
725
+ return this._client.request("POST", `/social/accounts/${encodeURIComponent(accountId)}/resume`, { options });
726
+ }
727
+ /** Retry publishing a post `POST /social/posts/{post_id}/retry` */
728
+ retryPost(postId, body, options) {
729
+ return this._client.request("POST", `/social/posts/${encodeURIComponent(postId)}/retry`, { body, options });
730
+ }
731
+ /** Poll headless connection status `GET /social/connect/{platform}` */
732
+ connectAccountStatus(platform, options) {
733
+ return this._client.request("GET", `/social/connect/${encodeURIComponent(platform)}`, { options });
734
+ }
735
+ /** Start headless account connection `POST /social/connect/{platform}` */
736
+ connectAccount(platform, body, options) {
737
+ return this._client.request("POST", `/social/connect/${encodeURIComponent(platform)}`, { body, options });
738
+ }
739
+ };
740
+ var UrlsResource = class {
741
+ constructor(_client) {
742
+ this._client = _client;
743
+ }
744
+ /** Shorten URL `POST /urls/shorten` */
745
+ shorten(body, options) {
746
+ return this._client.request("POST", "/urls/shorten", { body, options });
747
+ }
748
+ /** List short URLs `GET /urls` */
749
+ list(query, options) {
750
+ return this._client.request("GET", "/urls", { query, options });
751
+ }
752
+ /** Get short URL `GET /urls/{url_id}` */
753
+ get(urlId, options) {
754
+ return this._client.request("GET", `/urls/${encodeURIComponent(urlId)}`, { options });
755
+ }
756
+ /** Delete short URL `DELETE /urls/{url_id}` */
757
+ delete(urlId, options) {
758
+ return this._client.request("DELETE", `/urls/${encodeURIComponent(urlId)}`, { options });
759
+ }
760
+ /** Get short URL stats `GET /urls/{url_id}/stats` */
761
+ getStats(urlId, options) {
762
+ return this._client.request("GET", `/urls/${encodeURIComponent(urlId)}/stats`, { options });
763
+ }
764
+ };
765
+ var VideosResource = class {
766
+ constructor(_client) {
767
+ this._client = _client;
768
+ }
769
+ /** List available video models `GET /videos/models` */
770
+ listModels(options) {
771
+ return this._client.request("GET", "/videos/models", { options });
772
+ }
773
+ /** Generate video `POST /videos/generate` */
774
+ generate(body, options) {
775
+ return this._client.request("POST", "/videos/generate", { body, options });
776
+ }
777
+ /** List videos `GET /videos` */
778
+ list(query, options) {
779
+ return this._client.request("GET", "/videos", { query, options });
780
+ }
781
+ /** Get video `GET /videos/{video_id}` */
782
+ get(videoId, options) {
783
+ return this._client.request("GET", `/videos/${encodeURIComponent(videoId)}`, { options });
784
+ }
785
+ /** Delete video `DELETE /videos/{video_id}` */
786
+ delete(videoId, options) {
787
+ return this._client.request("DELETE", `/videos/${encodeURIComponent(videoId)}`, { options });
788
+ }
789
+ /** Generate a viral hook line `POST /videos/hook` */
790
+ generateHook(body, options) {
791
+ return this._client.request("POST", "/videos/hook", { body, options });
792
+ }
793
+ /** Suggest B-roll moments `POST /videos/broll-suggest` */
794
+ suggestBroll(body, options) {
795
+ return this._client.request("POST", "/videos/broll-suggest", { body, options });
796
+ }
797
+ /** Suggest on-screen emphasis `POST /videos/emphasis` */
798
+ suggestEmphasis(body, options) {
799
+ return this._client.request("POST", "/videos/emphasis", { body, options });
800
+ }
801
+ /** Generate a viral thumbnail `POST /videos/viral-thumbnail` */
802
+ generateViralThumbnail(body, options) {
803
+ return this._client.request("POST", "/videos/viral-thumbnail", { body, options });
804
+ }
805
+ };
806
+ var WebhooksResource = class {
807
+ constructor(_client) {
808
+ this._client = _client;
809
+ }
810
+ /** List webhooks `GET /webhooks` */
811
+ list(options) {
812
+ return this._client.request("GET", "/webhooks", { options });
813
+ }
814
+ /** Create webhook `POST /webhooks` */
815
+ create(body, options) {
816
+ return this._client.request("POST", "/webhooks", { body, options });
817
+ }
818
+ /** Delete webhook `DELETE /webhooks/{id}` */
819
+ delete(id, options) {
820
+ return this._client.request("DELETE", `/webhooks/${encodeURIComponent(id)}`, { options });
821
+ }
822
+ };
823
+ var WorkspacesResource = class {
824
+ constructor(_client) {
825
+ this._client = _client;
826
+ }
827
+ /** List workspaces (sub-accounts) `GET /workspaces` */
828
+ list(options) {
829
+ return this._client.request("GET", "/workspaces", { options });
830
+ }
831
+ /** Create a workspace (sub-account) `POST /workspaces` */
832
+ create(body, options) {
833
+ return this._client.request("POST", "/workspaces", { body, options });
834
+ }
835
+ /** Bulk sub-account action `POST /workspaces/bulk` */
836
+ bulkAction(body, options) {
837
+ return this._client.request("POST", "/workspaces/bulk", { body, options });
838
+ }
839
+ /** Get a workspace (sub-account) `GET /workspaces/{id}` */
840
+ get(id, options) {
841
+ return this._client.request("GET", `/workspaces/${encodeURIComponent(id)}`, { options });
842
+ }
843
+ /** Delete a workspace (sub-account) `DELETE /workspaces/{id}` */
844
+ delete(id, body, options) {
845
+ return this._client.request("DELETE", `/workspaces/${encodeURIComponent(id)}`, { body, options });
846
+ }
847
+ /** Disable SaaS mode for a workspace `POST /workspaces/{id}/disable-saas` */
848
+ disableSaas(id, body, options) {
849
+ return this._client.request("POST", `/workspaces/${encodeURIComponent(id)}/disable-saas`, { body, options });
850
+ }
851
+ /** Pause (suspend) a workspace `POST /workspaces/{id}/pause` */
852
+ pause(id, options) {
853
+ return this._client.request("POST", `/workspaces/${encodeURIComponent(id)}/pause`, { options });
854
+ }
855
+ /** Resume a paused workspace `POST /workspaces/{id}/resume` */
856
+ resume(id, options) {
857
+ return this._client.request("POST", `/workspaces/${encodeURIComponent(id)}/resume`, { options });
858
+ }
859
+ /** Get a sub-account's subscription `GET /workspaces/{id}/subscription` */
860
+ getSubscription(id, options) {
861
+ return this._client.request("GET", `/workspaces/${encodeURIComponent(id)}/subscription`, { options });
862
+ }
863
+ /** Get a sub-account's wallet balance `GET /workspaces/{id}/wallet` */
864
+ getWallet(id, options) {
865
+ return this._client.request("GET", `/workspaces/${encodeURIComponent(id)}/wallet`, { options });
866
+ }
867
+ /** List SaaS plans `GET /saas/plans` */
868
+ listSaasPlans(options) {
869
+ return this._client.request("GET", "/saas/plans", { options });
870
+ }
871
+ /** Get a SaaS plan `GET /saas/plans/{id}` */
872
+ getSaasPlan(id, options) {
873
+ return this._client.request("GET", `/saas/plans/${encodeURIComponent(id)}`, { options });
874
+ }
875
+ };
876
+ function createResources(client) {
877
+ return {
878
+ account: new AccountResource(client),
879
+ captain: new CaptainResource(client),
880
+ analytics: new AnalyticsResource(client),
881
+ articles: new ArticlesResource(client),
882
+ audio: new AudioResource(client),
883
+ chatbots: new ChatbotsResource(client),
884
+ comments: new CommentsResource(client),
885
+ content: new ContentResource(client),
886
+ contacts: new ContactsResource(client),
887
+ customFields: new CustomFieldsResource(client),
888
+ opportunities: new OpportunitiesResource(client),
889
+ messages: new MessagesResource(client),
890
+ images: new ImagesResource(client),
891
+ jobs: new JobsResource(client),
892
+ media: new MediaResource(client),
893
+ presentations: new PresentationsResource(client),
894
+ profiles: new ProfilesResource(client),
895
+ seo: new SeoResource(client),
896
+ shorts: new ShortsResource(client),
897
+ social: new SocialResource(client),
898
+ urls: new UrlsResource(client),
899
+ videos: new VideosResource(client),
900
+ webhooks: new WebhooksResource(client),
901
+ workspaces: new WorkspacesResource(client)
902
+ };
903
+ }
904
+
905
+ // src/index.ts
906
+ var SmartlyQ = class {
907
+ constructor(options = {}) {
908
+ const resolved = typeof options === "string" ? { apiKey: options } : options;
909
+ this.core = new CoreClient(resolved);
910
+ const resources = createResources(this.core);
911
+ this.account = resources.account;
912
+ this.analytics = resources.analytics;
913
+ this.articles = resources.articles;
914
+ this.audio = resources.audio;
915
+ this.captain = resources.captain;
916
+ this.chatbots = resources.chatbots;
917
+ this.comments = resources.comments;
918
+ this.contacts = resources.contacts;
919
+ this.content = resources.content;
920
+ this.customFields = resources.customFields;
921
+ this.images = resources.images;
922
+ this.jobs = resources.jobs;
923
+ this.media = resources.media;
924
+ this.messages = resources.messages;
925
+ this.opportunities = resources.opportunities;
926
+ this.presentations = resources.presentations;
927
+ this.profiles = resources.profiles;
928
+ this.seo = resources.seo;
929
+ this.shorts = resources.shorts;
930
+ this.social = resources.social;
931
+ this.urls = resources.urls;
932
+ this.videos = resources.videos;
933
+ this.webhooks = resources.webhooks;
934
+ this.workspaces = resources.workspaces;
935
+ }
936
+ };
937
+ var index_default = SmartlyQ;
938
+ // Annotate the CommonJS export names for ESM import in node:
939
+ 0 && (module.exports = {
940
+ AccountResource,
941
+ AnalyticsResource,
942
+ ArticlesResource,
943
+ AudioResource,
944
+ CaptainResource,
945
+ ChatbotsResource,
946
+ CommentsResource,
947
+ ContactsResource,
948
+ ContentResource,
949
+ CoreClient,
950
+ CustomFieldsResource,
951
+ ImagesResource,
952
+ JobsResource,
953
+ MediaResource,
954
+ MessagesResource,
955
+ OpportunitiesResource,
956
+ PresentationsResource,
957
+ ProfilesResource,
958
+ SeoResource,
959
+ ShortsResource,
960
+ SmartlyQ,
961
+ SmartlyQConnectionError,
962
+ SmartlyQError,
963
+ SocialResource,
964
+ UrlsResource,
965
+ VideosResource,
966
+ WebhooksResource,
967
+ WorkspacesResource,
968
+ createResources
969
+ });