@cstar.help/js 0.4.0 → 0.5.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/README.md +195 -87
- package/dist/chat/index.cjs +79 -0
- package/dist/chat/index.d.cts +77 -0
- package/dist/chat/index.d.ts +77 -0
- package/dist/chat/index.js +79 -0
- package/dist/community/index.cjs +149 -0
- package/dist/community/index.js +149 -0
- package/dist/index.cjs +1047 -1
- package/dist/index.d.cts +1757 -4
- package/dist/index.d.ts +1757 -4
- package/dist/index.js +1047 -1
- package/package.json +1 -1
- package/dist/community/index.d.cts +0 -115
- package/dist/community/index.d.ts +0 -115
package/dist/index.cjs
CHANGED
|
@@ -97,7 +97,7 @@ function parseError(statusCode, body, retryAfter) {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
// src/client.ts
|
|
100
|
-
var SDK_VERSION = "0.
|
|
100
|
+
var SDK_VERSION = "0.5.0";
|
|
101
101
|
var DEFAULT_BASE_URL = "https://www.cstar.help";
|
|
102
102
|
var DEFAULT_API_VERSION = "2026-03-01";
|
|
103
103
|
var DEFAULT_MAX_RETRIES = 3;
|
|
@@ -113,6 +113,11 @@ var HttpClient = class {
|
|
|
113
113
|
timeout: config.timeout ?? DEFAULT_TIMEOUT
|
|
114
114
|
};
|
|
115
115
|
this.environment = config.apiKey.startsWith("sk_test_") || config.apiKey.startsWith("pk_test_") ? "test" : "live";
|
|
116
|
+
if (config.apiKey.startsWith("sk_") && typeof globalThis !== "undefined" && typeof globalThis.window !== "undefined") {
|
|
117
|
+
console.warn(
|
|
118
|
+
"[cStar] WARNING: Secret API key detected in a browser environment. This exposes your key to anyone viewing your site. Use CStarClient with secret keys on the server only. For client-side use, import from @cstar.help/js/chat, /library, or /community instead."
|
|
119
|
+
);
|
|
120
|
+
}
|
|
116
121
|
}
|
|
117
122
|
/**
|
|
118
123
|
* Make an authenticated request to the cStar API.
|
|
@@ -148,6 +153,7 @@ var HttpClient = class {
|
|
|
148
153
|
throw lastError;
|
|
149
154
|
}
|
|
150
155
|
if (response.ok) {
|
|
156
|
+
if (response.status === 204) return void 0;
|
|
151
157
|
return await response.json();
|
|
152
158
|
}
|
|
153
159
|
const errorBody = await response.json().catch(() => null);
|
|
@@ -332,6 +338,105 @@ var WebhooksResource = class extends BaseResource {
|
|
|
332
338
|
{ body: params ?? {} }
|
|
333
339
|
);
|
|
334
340
|
}
|
|
341
|
+
/** Fire a test webhook event to all active webhooks and CLI listeners. */
|
|
342
|
+
async triggerTest(params, options) {
|
|
343
|
+
return this.client.request(
|
|
344
|
+
"POST",
|
|
345
|
+
"/webhooks/trigger-test",
|
|
346
|
+
{ body: params, idempotencyKey: options?.idempotencyKey }
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
/** Get a sample webhook payload for an event type (used by Zapier). */
|
|
350
|
+
async sample(event) {
|
|
351
|
+
return this.client.request(
|
|
352
|
+
"GET",
|
|
353
|
+
`/webhooks/sample/${encodeURIComponent(event)}`
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
/** Subscribe to an event (REST Hooks / Zapier protocol). */
|
|
357
|
+
async subscribe(params, options) {
|
|
358
|
+
return this.client.request("POST", "/webhooks/subscribe", {
|
|
359
|
+
body: params,
|
|
360
|
+
idempotencyKey: options?.idempotencyKey
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
/** Unsubscribe from an event (REST Hooks / Zapier protocol). Returns void (204 No Content). */
|
|
364
|
+
async unsubscribe(subscriptionId) {
|
|
365
|
+
await this.client.request("DELETE", `/webhooks/subscribe/${subscriptionId}`);
|
|
366
|
+
}
|
|
367
|
+
/** Register a CLI listener (returns listenerId and signing secret). */
|
|
368
|
+
async listen(params, options) {
|
|
369
|
+
return this.client.request("POST", "/webhooks/listen", {
|
|
370
|
+
body: params,
|
|
371
|
+
idempotencyKey: options?.idempotencyKey
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
/** Deregister a CLI listener. */
|
|
375
|
+
async unlisten(listenerId) {
|
|
376
|
+
return this.client.request(
|
|
377
|
+
"DELETE",
|
|
378
|
+
`/webhooks/listen/${listenerId}`
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
// src/resources/automations.ts
|
|
384
|
+
var AutomationsResource = class extends BaseResource {
|
|
385
|
+
constructor(client) {
|
|
386
|
+
super(client, "/automations");
|
|
387
|
+
}
|
|
388
|
+
/** Toggle a rule's enabled state. */
|
|
389
|
+
async toggle(ruleId, enabled) {
|
|
390
|
+
return this.client.request(
|
|
391
|
+
"PATCH",
|
|
392
|
+
`/automations/${ruleId}/toggle`,
|
|
393
|
+
{ body: enabled !== void 0 ? { enabled } : {} }
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
/** Reorder rules by providing an ordered array of IDs. */
|
|
397
|
+
async reorder(orderedIds) {
|
|
398
|
+
return this.client.request("PUT", "/automations/reorder", {
|
|
399
|
+
body: { orderedIds }
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
/** Dry-run a rule against a specific resource (no actions executed). */
|
|
403
|
+
async test(ruleId, params) {
|
|
404
|
+
return this.client.request(
|
|
405
|
+
"POST",
|
|
406
|
+
`/automations/${ruleId}/test`,
|
|
407
|
+
{ body: params }
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
/** Get execution history for a specific rule. */
|
|
411
|
+
async executions(ruleId, params) {
|
|
412
|
+
const searchParams = new URLSearchParams();
|
|
413
|
+
if (params?.page) searchParams.set("page", String(params.page));
|
|
414
|
+
if (params?.pageSize) searchParams.set("pageSize", String(params.pageSize));
|
|
415
|
+
if (params?.triggerEvent) searchParams.set("triggerEvent", params.triggerEvent);
|
|
416
|
+
if (params?.resourceId) searchParams.set("resourceId", params.resourceId);
|
|
417
|
+
const qs = searchParams.toString();
|
|
418
|
+
return this.client.request(
|
|
419
|
+
"GET",
|
|
420
|
+
`/automations/${ruleId}/executions${qs ? `?${qs}` : ""}`
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
/** Get all execution history for the team. */
|
|
424
|
+
async allExecutions(params) {
|
|
425
|
+
const searchParams = new URLSearchParams();
|
|
426
|
+
if (params?.page) searchParams.set("page", String(params.page));
|
|
427
|
+
if (params?.pageSize) searchParams.set("pageSize", String(params.pageSize));
|
|
428
|
+
if (params?.triggerEvent) searchParams.set("triggerEvent", params.triggerEvent);
|
|
429
|
+
if (params?.resourceId) searchParams.set("resourceId", params.resourceId);
|
|
430
|
+
const qs = searchParams.toString();
|
|
431
|
+
return this.client.request(
|
|
432
|
+
"GET",
|
|
433
|
+
`/automations/executions${qs ? `?${qs}` : ""}`
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
/** Test conditions against sample data (without a rule). */
|
|
437
|
+
async evaluate(params) {
|
|
438
|
+
return this.client.request("POST", "/automations/evaluate", { body: params });
|
|
439
|
+
}
|
|
335
440
|
};
|
|
336
441
|
|
|
337
442
|
// src/resources/categories.ts
|
|
@@ -384,6 +489,926 @@ var CommunityTopicsResource = class extends BaseResource {
|
|
|
384
489
|
}
|
|
385
490
|
};
|
|
386
491
|
|
|
492
|
+
// src/resources/members.ts
|
|
493
|
+
var InvitesResource = class {
|
|
494
|
+
constructor(client) {
|
|
495
|
+
this.client = client;
|
|
496
|
+
}
|
|
497
|
+
/** List pending invites. */
|
|
498
|
+
async list(params) {
|
|
499
|
+
return this.client.request("GET", "/invites", {
|
|
500
|
+
query: params
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
/** Create and send a new invite. */
|
|
504
|
+
async create(params, options) {
|
|
505
|
+
return this.client.request("POST", "/invites", {
|
|
506
|
+
body: params,
|
|
507
|
+
idempotencyKey: options?.idempotencyKey
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
/** Revoke a pending invite. */
|
|
511
|
+
async del(inviteId) {
|
|
512
|
+
return this.client.request("DELETE", `/invites/${inviteId}`);
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
var MembersResource = class {
|
|
516
|
+
constructor(client) {
|
|
517
|
+
this.client = client;
|
|
518
|
+
this.invites = new InvitesResource(client);
|
|
519
|
+
}
|
|
520
|
+
/** List all team members. */
|
|
521
|
+
async list(params) {
|
|
522
|
+
return this.client.request("GET", "/members", {
|
|
523
|
+
query: params
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
/** Get a single member by membership ID. */
|
|
527
|
+
async get(memberId) {
|
|
528
|
+
return this.client.request("GET", `/members/${memberId}`);
|
|
529
|
+
}
|
|
530
|
+
/** Update a member's role. */
|
|
531
|
+
async update(memberId, params) {
|
|
532
|
+
return this.client.request("PATCH", `/members/${memberId}`, {
|
|
533
|
+
body: params
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
/** Remove a member from the team. */
|
|
537
|
+
async del(memberId) {
|
|
538
|
+
return this.client.request("DELETE", `/members/${memberId}`);
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
// src/resources/settings.ts
|
|
543
|
+
var StatusesResource = class {
|
|
544
|
+
constructor(client) {
|
|
545
|
+
this.client = client;
|
|
546
|
+
}
|
|
547
|
+
/** List all statuses. */
|
|
548
|
+
async list() {
|
|
549
|
+
return this.client.request("GET", "/settings/statuses");
|
|
550
|
+
}
|
|
551
|
+
/** Create a new status. */
|
|
552
|
+
async create(params, options) {
|
|
553
|
+
return this.client.request("POST", "/settings/statuses", {
|
|
554
|
+
body: params,
|
|
555
|
+
idempotencyKey: options?.idempotencyKey
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
/** Update a status. */
|
|
559
|
+
async update(statusKey, params) {
|
|
560
|
+
return this.client.request(
|
|
561
|
+
"PATCH",
|
|
562
|
+
`/settings/statuses/${statusKey}`,
|
|
563
|
+
{ body: params }
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
/** Delete a status. */
|
|
567
|
+
async del(statusKey) {
|
|
568
|
+
return this.client.request(
|
|
569
|
+
"DELETE",
|
|
570
|
+
`/settings/statuses/${statusKey}`
|
|
571
|
+
);
|
|
572
|
+
}
|
|
573
|
+
/** Reorder statuses. */
|
|
574
|
+
async reorder(orderedKeys) {
|
|
575
|
+
return this.client.request("PUT", "/settings/statuses/reorder", {
|
|
576
|
+
body: { orderedKeys }
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
var QuickRepliesResource = class {
|
|
581
|
+
constructor(client) {
|
|
582
|
+
this.client = client;
|
|
583
|
+
}
|
|
584
|
+
/** List all quick replies. */
|
|
585
|
+
async list() {
|
|
586
|
+
return this.client.request("GET", "/settings/quick-replies");
|
|
587
|
+
}
|
|
588
|
+
/** Create a new quick reply. */
|
|
589
|
+
async create(params, options) {
|
|
590
|
+
return this.client.request("POST", "/settings/quick-replies", {
|
|
591
|
+
body: params,
|
|
592
|
+
idempotencyKey: options?.idempotencyKey
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
/** Update a quick reply. */
|
|
596
|
+
async update(replyId, params) {
|
|
597
|
+
return this.client.request(
|
|
598
|
+
"PATCH",
|
|
599
|
+
`/settings/quick-replies/${replyId}`,
|
|
600
|
+
{ body: params }
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
/** Delete a quick reply. */
|
|
604
|
+
async del(replyId) {
|
|
605
|
+
return this.client.request(
|
|
606
|
+
"DELETE",
|
|
607
|
+
`/settings/quick-replies/${replyId}`
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
/** Reorder quick replies. */
|
|
611
|
+
async reorder(orderedIds) {
|
|
612
|
+
return this.client.request(
|
|
613
|
+
"PUT",
|
|
614
|
+
"/settings/quick-replies/reorder",
|
|
615
|
+
{ body: { orderedIds } }
|
|
616
|
+
);
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
var SettingsResource = class {
|
|
620
|
+
constructor(client) {
|
|
621
|
+
this.client = client;
|
|
622
|
+
this.statuses = new StatusesResource(client);
|
|
623
|
+
this.quickReplies = new QuickRepliesResource(client);
|
|
624
|
+
}
|
|
625
|
+
/** Get all team settings. */
|
|
626
|
+
async get() {
|
|
627
|
+
return this.client.request("GET", "/settings");
|
|
628
|
+
}
|
|
629
|
+
/** Update team settings (bulk). */
|
|
630
|
+
async update(params) {
|
|
631
|
+
return this.client.request("PATCH", "/settings", { body: params });
|
|
632
|
+
}
|
|
633
|
+
/** Get business hours configuration. */
|
|
634
|
+
async getBusinessHours() {
|
|
635
|
+
return this.client.request("GET", "/settings/business-hours");
|
|
636
|
+
}
|
|
637
|
+
/** Update business hours configuration. */
|
|
638
|
+
async updateBusinessHours(params) {
|
|
639
|
+
return this.client.request("PATCH", "/settings/business-hours", {
|
|
640
|
+
body: params
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
/** Get widget settings. */
|
|
644
|
+
async getWidget() {
|
|
645
|
+
return this.client.request("GET", "/settings/widget");
|
|
646
|
+
}
|
|
647
|
+
/** Update widget settings. */
|
|
648
|
+
async updateWidget(params) {
|
|
649
|
+
return this.client.request("PATCH", "/settings/widget", {
|
|
650
|
+
body: params
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
// src/resources/notifications.ts
|
|
656
|
+
var NotificationsResource = class {
|
|
657
|
+
constructor(client) {
|
|
658
|
+
this.client = client;
|
|
659
|
+
}
|
|
660
|
+
/** List notifications for a user. */
|
|
661
|
+
async list(params) {
|
|
662
|
+
return this.client.request("GET", "/notifications", {
|
|
663
|
+
query: params
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
/** Get unread notification count for a user. */
|
|
667
|
+
async unreadCount(userId) {
|
|
668
|
+
return this.client.request("GET", "/notifications/unread-count", {
|
|
669
|
+
query: { userId }
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
/** Mark a single notification as read. */
|
|
673
|
+
async markRead(notificationId, userId) {
|
|
674
|
+
return this.client.request(
|
|
675
|
+
"PATCH",
|
|
676
|
+
`/notifications/${notificationId}/read`,
|
|
677
|
+
{ body: { userId } }
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
/** Mark all notifications as read. */
|
|
681
|
+
async markAllRead(userId) {
|
|
682
|
+
return this.client.request(
|
|
683
|
+
"POST",
|
|
684
|
+
"/notifications/mark-all-read",
|
|
685
|
+
{ body: { userId } }
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
/** Delete (dismiss) a notification. For broadcast notifications, pass userId as a query param. */
|
|
689
|
+
async del(notificationId, params) {
|
|
690
|
+
return this.client.request(
|
|
691
|
+
"DELETE",
|
|
692
|
+
`/notifications/${notificationId}`,
|
|
693
|
+
{ query: params }
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
// src/resources/mentions.ts
|
|
699
|
+
var MentionsResource = class {
|
|
700
|
+
constructor(client) {
|
|
701
|
+
this.client = client;
|
|
702
|
+
}
|
|
703
|
+
/** List mentions for a user. */
|
|
704
|
+
async list(params) {
|
|
705
|
+
return this.client.request("GET", "/mentions", {
|
|
706
|
+
query: params
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
/** Get unread mention count for a user. */
|
|
710
|
+
async unreadCount(userId) {
|
|
711
|
+
return this.client.request("GET", "/mentions/unread-count", {
|
|
712
|
+
query: { userId }
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
/** Mark a single mention as read. */
|
|
716
|
+
async markRead(mentionId) {
|
|
717
|
+
return this.client.request(
|
|
718
|
+
"PATCH",
|
|
719
|
+
`/mentions/${mentionId}/read`
|
|
720
|
+
);
|
|
721
|
+
}
|
|
722
|
+
/** Mark all mentions as read for a user. */
|
|
723
|
+
async markAllRead(userId) {
|
|
724
|
+
return this.client.request(
|
|
725
|
+
"POST",
|
|
726
|
+
"/mentions/mark-all-read",
|
|
727
|
+
{ body: { userId } }
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
// src/resources/attachments.ts
|
|
733
|
+
var AttachmentsResource = class {
|
|
734
|
+
constructor(client) {
|
|
735
|
+
this.client = client;
|
|
736
|
+
}
|
|
737
|
+
/** List attachments. */
|
|
738
|
+
async list(params) {
|
|
739
|
+
return this.client.request("GET", "/attachments", {
|
|
740
|
+
query: params
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
/** Get a single attachment. */
|
|
744
|
+
async get(attachmentId) {
|
|
745
|
+
return this.client.request("GET", `/attachments/${attachmentId}`);
|
|
746
|
+
}
|
|
747
|
+
/** Delete an attachment. */
|
|
748
|
+
async del(attachmentId) {
|
|
749
|
+
return this.client.request(
|
|
750
|
+
"DELETE",
|
|
751
|
+
`/attachments/${attachmentId}`
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
// src/resources/customFields.ts
|
|
757
|
+
var CustomFieldsResource = class {
|
|
758
|
+
constructor(client) {
|
|
759
|
+
this.client = client;
|
|
760
|
+
}
|
|
761
|
+
/** List custom fields. */
|
|
762
|
+
async list(params) {
|
|
763
|
+
return this.client.request("GET", "/custom-fields", {
|
|
764
|
+
query: params
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
/** Get a single custom field. */
|
|
768
|
+
async get(fieldId) {
|
|
769
|
+
return this.client.request("GET", `/custom-fields/${fieldId}`);
|
|
770
|
+
}
|
|
771
|
+
/** Create a custom field. */
|
|
772
|
+
async create(params, options) {
|
|
773
|
+
return this.client.request("POST", "/custom-fields", {
|
|
774
|
+
body: params,
|
|
775
|
+
idempotencyKey: options?.idempotencyKey
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
/** Update a custom field. */
|
|
779
|
+
async update(fieldId, params) {
|
|
780
|
+
return this.client.request("PATCH", `/custom-fields/${fieldId}`, {
|
|
781
|
+
body: params
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
/** Delete a custom field. */
|
|
785
|
+
async del(fieldId) {
|
|
786
|
+
return this.client.request("DELETE", `/custom-fields/${fieldId}`);
|
|
787
|
+
}
|
|
788
|
+
/** Reorder custom fields. */
|
|
789
|
+
async reorder(orderedIds) {
|
|
790
|
+
return this.client.request("PUT", "/custom-fields/reorder", {
|
|
791
|
+
body: { orderedIds }
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
|
|
796
|
+
// src/resources/sla.ts
|
|
797
|
+
var SlaResource = class {
|
|
798
|
+
constructor(client) {
|
|
799
|
+
this.client = client;
|
|
800
|
+
}
|
|
801
|
+
/** List SLA rules. */
|
|
802
|
+
async list(params) {
|
|
803
|
+
return this.client.request("GET", "/sla/rules", {
|
|
804
|
+
query: params
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
/** Create an SLA rule. */
|
|
808
|
+
async create(params, options) {
|
|
809
|
+
return this.client.request("POST", "/sla/rules", {
|
|
810
|
+
body: params,
|
|
811
|
+
idempotencyKey: options?.idempotencyKey
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
/** Update an SLA rule. */
|
|
815
|
+
async update(ruleId, params) {
|
|
816
|
+
return this.client.request("PATCH", `/sla/rules/${ruleId}`, {
|
|
817
|
+
body: params
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
/** Delete an SLA rule. */
|
|
821
|
+
async del(ruleId) {
|
|
822
|
+
return this.client.request("DELETE", `/sla/rules/${ruleId}`);
|
|
823
|
+
}
|
|
824
|
+
/** Reorder SLA rules by providing an ordered array of IDs. */
|
|
825
|
+
async reorder(orderedIds) {
|
|
826
|
+
return this.client.request("PUT", "/sla/rules/reorder", {
|
|
827
|
+
body: { orderedIds }
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
/** Get SLA compliance metrics. */
|
|
831
|
+
async metrics(params) {
|
|
832
|
+
return this.client.request("GET", "/sla/metrics", {
|
|
833
|
+
query: params
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
// src/resources/analytics.ts
|
|
839
|
+
var CsatSurveysResource = class {
|
|
840
|
+
constructor(client) {
|
|
841
|
+
this.client = client;
|
|
842
|
+
}
|
|
843
|
+
/** List CSAT surveys. */
|
|
844
|
+
async list(params) {
|
|
845
|
+
return this.client.request("GET", "/csat/surveys", {
|
|
846
|
+
query: params
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
/** Get a single CSAT survey. */
|
|
850
|
+
async get(surveyId) {
|
|
851
|
+
return this.client.request("GET", `/csat/surveys/${surveyId}`);
|
|
852
|
+
}
|
|
853
|
+
/** Create and send a CSAT survey. */
|
|
854
|
+
async create(params) {
|
|
855
|
+
return this.client.request("POST", "/csat/surveys", {
|
|
856
|
+
body: params
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
var AnalyticsResource = class {
|
|
861
|
+
constructor(client) {
|
|
862
|
+
this.client = client;
|
|
863
|
+
this.csatSurveys = new CsatSurveysResource(client);
|
|
864
|
+
}
|
|
865
|
+
/** Get analytics data. Specify type to control the response shape. */
|
|
866
|
+
async get(params) {
|
|
867
|
+
return this.client.request("GET", "/analytics", {
|
|
868
|
+
query: params
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
/** Get analytics overview (shortcut for type=overview). */
|
|
872
|
+
async overview(params) {
|
|
873
|
+
return this.get({ ...params, type: "overview" });
|
|
874
|
+
}
|
|
875
|
+
/** Get agent performance stats (shortcut for type=performance). */
|
|
876
|
+
async performance(params) {
|
|
877
|
+
return this.get({ ...params, type: "performance" });
|
|
878
|
+
}
|
|
879
|
+
/** Get library analytics (shortcut for type=library). */
|
|
880
|
+
async library(params) {
|
|
881
|
+
return this.get({ ...params, type: "library" });
|
|
882
|
+
}
|
|
883
|
+
/** Get CSAT statistics. */
|
|
884
|
+
async csatStats(params) {
|
|
885
|
+
return this.client.request("GET", "/csat/stats", {
|
|
886
|
+
query: params
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
/** Get CSAT settings. */
|
|
890
|
+
async csatSettings() {
|
|
891
|
+
return this.client.request("GET", "/csat/settings");
|
|
892
|
+
}
|
|
893
|
+
/** Update CSAT settings. */
|
|
894
|
+
async updateCsatSettings(params) {
|
|
895
|
+
return this.client.request("PATCH", "/csat/settings", {
|
|
896
|
+
body: params
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
|
|
901
|
+
// src/resources/bulk.ts
|
|
902
|
+
var BulkResource = class {
|
|
903
|
+
constructor(client) {
|
|
904
|
+
this.client = client;
|
|
905
|
+
}
|
|
906
|
+
/** Bulk update resources. */
|
|
907
|
+
async update(params, options) {
|
|
908
|
+
return this.client.request("POST", "/bulk", {
|
|
909
|
+
body: { action: "update", ...params },
|
|
910
|
+
idempotencyKey: options?.idempotencyKey
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
/** Bulk delete resources. */
|
|
914
|
+
async del(params, options) {
|
|
915
|
+
return this.client.request("POST", "/bulk", {
|
|
916
|
+
body: { action: "delete", ...params },
|
|
917
|
+
idempotencyKey: options?.idempotencyKey
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
};
|
|
921
|
+
|
|
922
|
+
// src/resources/exportImport.ts
|
|
923
|
+
var ExportResource = class {
|
|
924
|
+
constructor(client) {
|
|
925
|
+
this.client = client;
|
|
926
|
+
}
|
|
927
|
+
/** Create an export. Returns exported data synchronously. */
|
|
928
|
+
async create(params, options) {
|
|
929
|
+
return this.client.request("POST", "/export", {
|
|
930
|
+
body: params,
|
|
931
|
+
idempotencyKey: options?.idempotencyKey
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
var ImportResource = class {
|
|
936
|
+
constructor(client) {
|
|
937
|
+
this.client = client;
|
|
938
|
+
}
|
|
939
|
+
/** Run an import. Processes records synchronously (max 500). */
|
|
940
|
+
async create(params, options) {
|
|
941
|
+
return this.client.request("POST", "/import", {
|
|
942
|
+
body: params,
|
|
943
|
+
idempotencyKey: options?.idempotencyKey
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
/** List import history logs. */
|
|
947
|
+
async logs(params) {
|
|
948
|
+
return this.client.request("GET", "/import", {
|
|
949
|
+
query: params
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
/** Get a single import log. */
|
|
953
|
+
async getLog(logId) {
|
|
954
|
+
return this.client.request("GET", `/import/logs/${logId}`);
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
// src/resources/auditLog.ts
|
|
959
|
+
var AuditLogResource = class {
|
|
960
|
+
constructor(client) {
|
|
961
|
+
this.client = client;
|
|
962
|
+
}
|
|
963
|
+
/** List audit log entries. */
|
|
964
|
+
async list(params) {
|
|
965
|
+
return this.client.request("GET", "/audit-log", {
|
|
966
|
+
query: params
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
|
|
971
|
+
// src/resources/search.ts
|
|
972
|
+
var SearchResource = class {
|
|
973
|
+
constructor(client) {
|
|
974
|
+
this.client = client;
|
|
975
|
+
}
|
|
976
|
+
/** Perform a cross-resource search. */
|
|
977
|
+
async query(params) {
|
|
978
|
+
const query = {
|
|
979
|
+
q: params.query,
|
|
980
|
+
limit: params.limit?.toString()
|
|
981
|
+
};
|
|
982
|
+
if (params.types?.length) {
|
|
983
|
+
query.types = params.types.join(",");
|
|
984
|
+
}
|
|
985
|
+
return this.client.request("GET", "/search", { query });
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
|
|
989
|
+
// src/resources/tags.ts
|
|
990
|
+
var TagsResource = class {
|
|
991
|
+
constructor(client) {
|
|
992
|
+
this.client = client;
|
|
993
|
+
}
|
|
994
|
+
/** List all tags with usage counts. */
|
|
995
|
+
async list(params) {
|
|
996
|
+
return this.client.request("GET", "/tags", {
|
|
997
|
+
query: params
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
/** Create a tag. */
|
|
1001
|
+
async create(name, options) {
|
|
1002
|
+
return this.client.request("POST", "/tags", {
|
|
1003
|
+
body: { name },
|
|
1004
|
+
idempotencyKey: options?.idempotencyKey
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
/** Delete a tag. */
|
|
1008
|
+
async del(name) {
|
|
1009
|
+
return this.client.request(
|
|
1010
|
+
"DELETE",
|
|
1011
|
+
`/tags/${encodeURIComponent(name)}`
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1014
|
+
};
|
|
1015
|
+
|
|
1016
|
+
// src/resources/activity.ts
|
|
1017
|
+
var ActivityResource = class {
|
|
1018
|
+
constructor(client) {
|
|
1019
|
+
this.client = client;
|
|
1020
|
+
}
|
|
1021
|
+
/** List recent activity events. */
|
|
1022
|
+
async list(params) {
|
|
1023
|
+
return this.client.request("GET", "/activity", {
|
|
1024
|
+
query: params
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
|
|
1029
|
+
// src/resources/customerGroups.ts
|
|
1030
|
+
var CustomerGroupMembersResource = class {
|
|
1031
|
+
constructor(client) {
|
|
1032
|
+
this.client = client;
|
|
1033
|
+
}
|
|
1034
|
+
/** List members in a group. */
|
|
1035
|
+
async list(groupId, params) {
|
|
1036
|
+
return this.client.request(
|
|
1037
|
+
"GET",
|
|
1038
|
+
`/customer-groups/${groupId}/members`,
|
|
1039
|
+
{ query: params }
|
|
1040
|
+
);
|
|
1041
|
+
}
|
|
1042
|
+
/** Add member(s) to a group. */
|
|
1043
|
+
async add(groupId, params, options) {
|
|
1044
|
+
return this.client.request(
|
|
1045
|
+
"POST",
|
|
1046
|
+
`/customer-groups/${groupId}/members`,
|
|
1047
|
+
{ body: params, idempotencyKey: options?.idempotencyKey }
|
|
1048
|
+
);
|
|
1049
|
+
}
|
|
1050
|
+
/** Remove a member from a group. */
|
|
1051
|
+
async remove(groupId, customerId) {
|
|
1052
|
+
return this.client.request(
|
|
1053
|
+
"DELETE",
|
|
1054
|
+
`/customer-groups/${groupId}/members`,
|
|
1055
|
+
{ query: { customerId } }
|
|
1056
|
+
);
|
|
1057
|
+
}
|
|
1058
|
+
};
|
|
1059
|
+
var CustomerGroupsResource = class extends BaseResource {
|
|
1060
|
+
constructor(client) {
|
|
1061
|
+
super(client, "/customer-groups");
|
|
1062
|
+
this.members = new CustomerGroupMembersResource(client);
|
|
1063
|
+
}
|
|
1064
|
+
};
|
|
1065
|
+
|
|
1066
|
+
// src/resources/game.ts
|
|
1067
|
+
var BossResource = class {
|
|
1068
|
+
constructor(client) {
|
|
1069
|
+
this.client = client;
|
|
1070
|
+
}
|
|
1071
|
+
/** Get current boss state. */
|
|
1072
|
+
async current() {
|
|
1073
|
+
return this.client.request("GET", "/game/boss");
|
|
1074
|
+
}
|
|
1075
|
+
/** Check if a boss is active (lightweight). */
|
|
1076
|
+
async isActive() {
|
|
1077
|
+
return this.client.request("GET", "/game/boss/active");
|
|
1078
|
+
}
|
|
1079
|
+
/** Spawn a new boss. */
|
|
1080
|
+
async spawn(params, options) {
|
|
1081
|
+
return this.client.request("POST", "/game/boss/spawn", {
|
|
1082
|
+
body: params ?? {},
|
|
1083
|
+
idempotencyKey: options?.idempotencyKey
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
/** Deal damage to the current boss. */
|
|
1087
|
+
async damage(params, options) {
|
|
1088
|
+
return this.client.request("POST", "/game/boss/damage", {
|
|
1089
|
+
body: params,
|
|
1090
|
+
idempotencyKey: options?.idempotencyKey
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
/** List boss defeat history. */
|
|
1094
|
+
async defeats(params) {
|
|
1095
|
+
return this.client.request("GET", "/game/boss/defeats", {
|
|
1096
|
+
query: params
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
/** Get a single defeat record. */
|
|
1100
|
+
async getDefeat(defeatId) {
|
|
1101
|
+
return this.client.request("GET", `/game/boss/defeats/${defeatId}`);
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
var AchievementsResource = class {
|
|
1105
|
+
constructor(client) {
|
|
1106
|
+
this.client = client;
|
|
1107
|
+
}
|
|
1108
|
+
/** List all achievements with progress. */
|
|
1109
|
+
async list(params) {
|
|
1110
|
+
return this.client.request("GET", "/game/achievements", {
|
|
1111
|
+
query: params
|
|
1112
|
+
});
|
|
1113
|
+
}
|
|
1114
|
+
/** List unlocked achievements only. */
|
|
1115
|
+
async unlocked(params) {
|
|
1116
|
+
return this.client.request("GET", "/game/achievements/unlocked", {
|
|
1117
|
+
query: params
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
/** Get a single achievement. */
|
|
1121
|
+
async get(achievementId, params) {
|
|
1122
|
+
return this.client.request("GET", `/game/achievements/${achievementId}`, {
|
|
1123
|
+
query: params
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
/** Get recently unlocked achievements across the team. */
|
|
1127
|
+
async recent(params) {
|
|
1128
|
+
return this.client.request("GET", "/game/achievements/recent", {
|
|
1129
|
+
query: params
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
var GameActivityResource = class {
|
|
1134
|
+
constructor(client) {
|
|
1135
|
+
this.client = client;
|
|
1136
|
+
}
|
|
1137
|
+
/** Get the team activity feed. */
|
|
1138
|
+
async list(params) {
|
|
1139
|
+
return this.client.request("GET", "/game/activity", {
|
|
1140
|
+
query: params
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
/** Get activity for a specific member. */
|
|
1144
|
+
async forMember(memberId, params) {
|
|
1145
|
+
return this.client.request("GET", `/game/activity/member/${memberId}`, {
|
|
1146
|
+
query: params
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
};
|
|
1150
|
+
var QuestsResource = class {
|
|
1151
|
+
constructor(client) {
|
|
1152
|
+
this.client = client;
|
|
1153
|
+
}
|
|
1154
|
+
/** Get today's quests. */
|
|
1155
|
+
async today(params) {
|
|
1156
|
+
return this.client.request("GET", "/game/quests/today", {
|
|
1157
|
+
query: params
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
/** Get quest history. */
|
|
1161
|
+
async history(params) {
|
|
1162
|
+
return this.client.request("GET", "/game/quests/history", {
|
|
1163
|
+
query: params
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
};
|
|
1167
|
+
var PuzzlesResource = class {
|
|
1168
|
+
constructor(client) {
|
|
1169
|
+
this.client = client;
|
|
1170
|
+
}
|
|
1171
|
+
/** Get today's puzzle. */
|
|
1172
|
+
async today(params) {
|
|
1173
|
+
return this.client.request("GET", "/game/puzzles/today", {
|
|
1174
|
+
query: params
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
/** Submit a puzzle answer. */
|
|
1178
|
+
async complete(params, options) {
|
|
1179
|
+
return this.client.request("POST", "/game/puzzles/complete", {
|
|
1180
|
+
body: params,
|
|
1181
|
+
idempotencyKey: options?.idempotencyKey
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
/** Get puzzle streak for a user. */
|
|
1185
|
+
async streak(params) {
|
|
1186
|
+
return this.client.request("GET", "/game/puzzles/streak", {
|
|
1187
|
+
query: params
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
/** Get puzzle leaderboard. */
|
|
1191
|
+
async leaderboard(params) {
|
|
1192
|
+
return this.client.request("GET", "/game/puzzles/leaderboard", {
|
|
1193
|
+
query: params
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
};
|
|
1197
|
+
var OneUpsResource = class {
|
|
1198
|
+
constructor(client) {
|
|
1199
|
+
this.client = client;
|
|
1200
|
+
}
|
|
1201
|
+
/** List one-ups. */
|
|
1202
|
+
async list(params) {
|
|
1203
|
+
return this.client.request("GET", "/game/one-ups", {
|
|
1204
|
+
query: params
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
/** Send a one-up. */
|
|
1208
|
+
async send(params, options) {
|
|
1209
|
+
return this.client.request("POST", "/game/one-ups", {
|
|
1210
|
+
body: params,
|
|
1211
|
+
idempotencyKey: options?.idempotencyKey
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
/** Check remaining free one-ups today. */
|
|
1215
|
+
async remaining(params) {
|
|
1216
|
+
return this.client.request("GET", "/game/one-ups/remaining", {
|
|
1217
|
+
query: params
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
var HighFivesResource = class {
|
|
1222
|
+
constructor(client) {
|
|
1223
|
+
this.client = client;
|
|
1224
|
+
}
|
|
1225
|
+
/** List high fives. */
|
|
1226
|
+
async list(params) {
|
|
1227
|
+
return this.client.request("GET", "/game/high-fives", {
|
|
1228
|
+
query: params
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
/** Send a high five. */
|
|
1232
|
+
async send(params, options) {
|
|
1233
|
+
return this.client.request("POST", "/game/high-fives", {
|
|
1234
|
+
body: params,
|
|
1235
|
+
idempotencyKey: options?.idempotencyKey
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
/** Check if you can send a high five to a team. */
|
|
1239
|
+
async canSend(recipientTeamId, params) {
|
|
1240
|
+
return this.client.request("GET", `/game/high-fives/can-send/${recipientTeamId}`, {
|
|
1241
|
+
query: params
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
};
|
|
1245
|
+
var CosmeticsResource = class {
|
|
1246
|
+
constructor(client) {
|
|
1247
|
+
this.client = client;
|
|
1248
|
+
}
|
|
1249
|
+
/** List unlocked cosmetics. */
|
|
1250
|
+
async list(params) {
|
|
1251
|
+
return this.client.request("GET", "/game/cosmetics", {
|
|
1252
|
+
query: params
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
/** Get cosmetic preferences. */
|
|
1256
|
+
async getPreferences(params) {
|
|
1257
|
+
return this.client.request("GET", "/game/cosmetics/preferences", {
|
|
1258
|
+
query: params
|
|
1259
|
+
});
|
|
1260
|
+
}
|
|
1261
|
+
/** Update cosmetic preferences. */
|
|
1262
|
+
async updatePreferences(params) {
|
|
1263
|
+
return this.client.request("PATCH", "/game/cosmetics/preferences", { body: params });
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
var SeasonsResource = class {
|
|
1267
|
+
constructor(client) {
|
|
1268
|
+
this.client = client;
|
|
1269
|
+
}
|
|
1270
|
+
/** List all seasons. */
|
|
1271
|
+
async list() {
|
|
1272
|
+
return this.client.request("GET", "/game/seasons");
|
|
1273
|
+
}
|
|
1274
|
+
/** Get the current active season. */
|
|
1275
|
+
async current() {
|
|
1276
|
+
return this.client.request("GET", "/game/seasons/current");
|
|
1277
|
+
}
|
|
1278
|
+
/** Get user stats for a season. */
|
|
1279
|
+
async stats(seasonId, params) {
|
|
1280
|
+
return this.client.request("GET", `/game/seasons/${seasonId}/stats`, {
|
|
1281
|
+
query: params
|
|
1282
|
+
});
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
var SkillsResource = class {
|
|
1286
|
+
constructor(client) {
|
|
1287
|
+
this.client = client;
|
|
1288
|
+
}
|
|
1289
|
+
/** Get the skill tree with current allocations. */
|
|
1290
|
+
async get(params) {
|
|
1291
|
+
return this.client.request("GET", "/game/skills", {
|
|
1292
|
+
query: params
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
/** Allocate a skill point. */
|
|
1296
|
+
async allocate(params, options) {
|
|
1297
|
+
return this.client.request("POST", "/game/skills/allocate", {
|
|
1298
|
+
body: params,
|
|
1299
|
+
idempotencyKey: options?.idempotencyKey
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
/** Reset all skill allocations. */
|
|
1303
|
+
async reset(params, options) {
|
|
1304
|
+
return this.client.request("POST", "/game/skills/reset", {
|
|
1305
|
+
body: params,
|
|
1306
|
+
idempotencyKey: options?.idempotencyKey
|
|
1307
|
+
});
|
|
1308
|
+
}
|
|
1309
|
+
};
|
|
1310
|
+
var GameResource = class {
|
|
1311
|
+
constructor(client) {
|
|
1312
|
+
this.client = client;
|
|
1313
|
+
this.boss = new BossResource(client);
|
|
1314
|
+
this.achievements = new AchievementsResource(client);
|
|
1315
|
+
this.quests = new QuestsResource(client);
|
|
1316
|
+
this.puzzles = new PuzzlesResource(client);
|
|
1317
|
+
this.oneUps = new OneUpsResource(client);
|
|
1318
|
+
this.highFives = new HighFivesResource(client);
|
|
1319
|
+
this.cosmetics = new CosmeticsResource(client);
|
|
1320
|
+
this.seasons = new SeasonsResource(client);
|
|
1321
|
+
this.skills = new SkillsResource(client);
|
|
1322
|
+
this.activity = new GameActivityResource(client);
|
|
1323
|
+
}
|
|
1324
|
+
/** Get current player stats. */
|
|
1325
|
+
async player(params) {
|
|
1326
|
+
return this.client.request("GET", "/game/player", {
|
|
1327
|
+
query: params
|
|
1328
|
+
});
|
|
1329
|
+
}
|
|
1330
|
+
/** Get a specific player's stats by membership ID. */
|
|
1331
|
+
async getPlayer(memberId) {
|
|
1332
|
+
return this.client.request("GET", `/game/player/${memberId}`);
|
|
1333
|
+
}
|
|
1334
|
+
/** Get the team leaderboard. */
|
|
1335
|
+
async leaderboard(params) {
|
|
1336
|
+
return this.client.request("GET", "/game/leaderboard", {
|
|
1337
|
+
query: params
|
|
1338
|
+
});
|
|
1339
|
+
}
|
|
1340
|
+
/** Get the current user's leaderboard position. */
|
|
1341
|
+
async myRank(params) {
|
|
1342
|
+
return this.client.request("GET", "/game/leaderboard/me", {
|
|
1343
|
+
query: params
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1346
|
+
/** Get game balance configuration (read-only constants). */
|
|
1347
|
+
async config() {
|
|
1348
|
+
return this.client.request("GET", "/game/config");
|
|
1349
|
+
}
|
|
1350
|
+
};
|
|
1351
|
+
|
|
1352
|
+
// src/resources/ai.ts
|
|
1353
|
+
var AiResource = class {
|
|
1354
|
+
constructor(client) {
|
|
1355
|
+
this.client = client;
|
|
1356
|
+
}
|
|
1357
|
+
/** Run an AI action. */
|
|
1358
|
+
async run(params, options) {
|
|
1359
|
+
return this.client.request("POST", "/ai", {
|
|
1360
|
+
body: params,
|
|
1361
|
+
idempotencyKey: options?.idempotencyKey
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
/** Auto-tag a ticket. */
|
|
1365
|
+
async autoTag(ticketId) {
|
|
1366
|
+
return this.run({ action: "auto-tag", ticketId });
|
|
1367
|
+
}
|
|
1368
|
+
/** Suggest a reply for a ticket. */
|
|
1369
|
+
async suggestReply(ticketId) {
|
|
1370
|
+
return this.run({ action: "suggest-reply", ticketId });
|
|
1371
|
+
}
|
|
1372
|
+
/** Summarize a ticket. */
|
|
1373
|
+
async summarize(ticketId) {
|
|
1374
|
+
return this.run({ action: "summarize", ticketId });
|
|
1375
|
+
}
|
|
1376
|
+
/** Improve text. */
|
|
1377
|
+
async improve(text) {
|
|
1378
|
+
return this.run({ action: "improve", text });
|
|
1379
|
+
}
|
|
1380
|
+
};
|
|
1381
|
+
|
|
1382
|
+
// src/resources/views.ts
|
|
1383
|
+
var ViewsResource = class extends BaseResource {
|
|
1384
|
+
constructor(client) {
|
|
1385
|
+
super(client, "/views");
|
|
1386
|
+
}
|
|
1387
|
+
/** Execute a view — returns the filtered results. The server uses the view's entity_type to determine which table to query. */
|
|
1388
|
+
async execute(viewId, params) {
|
|
1389
|
+
return this.client.request("GET", `/views/${viewId}/execute`, {
|
|
1390
|
+
query: params
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1393
|
+
};
|
|
1394
|
+
|
|
1395
|
+
// src/resources/billing.ts
|
|
1396
|
+
var BillingResource = class {
|
|
1397
|
+
constructor(client) {
|
|
1398
|
+
this.client = client;
|
|
1399
|
+
}
|
|
1400
|
+
/** Get current subscription status. */
|
|
1401
|
+
async subscription() {
|
|
1402
|
+
return this.client.request("GET", "/billing/subscription");
|
|
1403
|
+
}
|
|
1404
|
+
/** Create a Stripe billing portal session. */
|
|
1405
|
+
async portal(params) {
|
|
1406
|
+
return this.client.request("POST", "/billing/portal", {
|
|
1407
|
+
body: params ?? {}
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
};
|
|
1411
|
+
|
|
387
1412
|
// src/index.ts
|
|
388
1413
|
var CStarClient = class {
|
|
389
1414
|
constructor(config) {
|
|
@@ -392,11 +1417,32 @@ var CStarClient = class {
|
|
|
392
1417
|
this.customers = new CustomersResource(this.client);
|
|
393
1418
|
this.articles = new ArticlesResource(this.client);
|
|
394
1419
|
this.webhooks = new WebhooksResource(this.client);
|
|
1420
|
+
this.automations = new AutomationsResource(this.client);
|
|
395
1421
|
this.categories = new CategoriesResource(this.client);
|
|
396
1422
|
this.community = {
|
|
397
1423
|
posts: new CommunityPostsResource(this.client),
|
|
398
1424
|
topics: new CommunityTopicsResource(this.client)
|
|
399
1425
|
};
|
|
1426
|
+
this.members = new MembersResource(this.client);
|
|
1427
|
+
this.settings = new SettingsResource(this.client);
|
|
1428
|
+
this.notifications = new NotificationsResource(this.client);
|
|
1429
|
+
this.mentions = new MentionsResource(this.client);
|
|
1430
|
+
this.attachments = new AttachmentsResource(this.client);
|
|
1431
|
+
this.customFields = new CustomFieldsResource(this.client);
|
|
1432
|
+
this.sla = new SlaResource(this.client);
|
|
1433
|
+
this.analytics = new AnalyticsResource(this.client);
|
|
1434
|
+
this.bulk = new BulkResource(this.client);
|
|
1435
|
+
this.export = new ExportResource(this.client);
|
|
1436
|
+
this.import = new ImportResource(this.client);
|
|
1437
|
+
this.auditLog = new AuditLogResource(this.client);
|
|
1438
|
+
this.search = new SearchResource(this.client);
|
|
1439
|
+
this.tags = new TagsResource(this.client);
|
|
1440
|
+
this.activity = new ActivityResource(this.client);
|
|
1441
|
+
this.customerGroups = new CustomerGroupsResource(this.client);
|
|
1442
|
+
this.game = new GameResource(this.client);
|
|
1443
|
+
this.ai = new AiResource(this.client);
|
|
1444
|
+
this.views = new ViewsResource(this.client);
|
|
1445
|
+
this.billing = new BillingResource(this.client);
|
|
400
1446
|
}
|
|
401
1447
|
/** Whether this client is using test mode keys (sk_test_* or pk_test_*). */
|
|
402
1448
|
get isTestMode() {
|