@cstar.help/js 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +217 -27
- package/dist/index.d.cts +360 -72
- package/dist/index.d.ts +360 -72
- package/dist/index.js +217 -27
- package/package.json +1 -1
- package/dist/community/index.d.cts +0 -115
- package/dist/community/index.d.ts +0 -115
package/dist/index.js
CHANGED
|
@@ -65,7 +65,7 @@ function parseError(statusCode, body, retryAfter) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
// src/client.ts
|
|
68
|
-
var SDK_VERSION = "0.
|
|
68
|
+
var SDK_VERSION = "0.5.0";
|
|
69
69
|
var DEFAULT_BASE_URL = "https://www.cstar.help";
|
|
70
70
|
var DEFAULT_API_VERSION = "2026-03-01";
|
|
71
71
|
var DEFAULT_MAX_RETRIES = 3;
|
|
@@ -81,6 +81,11 @@ var HttpClient = class {
|
|
|
81
81
|
timeout: config.timeout ?? DEFAULT_TIMEOUT
|
|
82
82
|
};
|
|
83
83
|
this.environment = config.apiKey.startsWith("sk_test_") || config.apiKey.startsWith("pk_test_") ? "test" : "live";
|
|
84
|
+
if (config.apiKey.startsWith("sk_") && typeof globalThis !== "undefined" && typeof globalThis.window !== "undefined") {
|
|
85
|
+
console.warn(
|
|
86
|
+
"[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."
|
|
87
|
+
);
|
|
88
|
+
}
|
|
84
89
|
}
|
|
85
90
|
/**
|
|
86
91
|
* Make an authenticated request to the cStar API.
|
|
@@ -116,6 +121,7 @@ var HttpClient = class {
|
|
|
116
121
|
throw lastError;
|
|
117
122
|
}
|
|
118
123
|
if (response.ok) {
|
|
124
|
+
if (response.status === 204) return void 0;
|
|
119
125
|
return await response.json();
|
|
120
126
|
}
|
|
121
127
|
const errorBody = await response.json().catch(() => null);
|
|
@@ -300,6 +306,46 @@ var WebhooksResource = class extends BaseResource {
|
|
|
300
306
|
{ body: params ?? {} }
|
|
301
307
|
);
|
|
302
308
|
}
|
|
309
|
+
/** Fire a test webhook event to all active webhooks and CLI listeners. */
|
|
310
|
+
async triggerTest(params, options) {
|
|
311
|
+
return this.client.request(
|
|
312
|
+
"POST",
|
|
313
|
+
"/webhooks/trigger-test",
|
|
314
|
+
{ body: params, idempotencyKey: options?.idempotencyKey }
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
/** Get a sample webhook payload for an event type (used by Zapier). */
|
|
318
|
+
async sample(event) {
|
|
319
|
+
return this.client.request(
|
|
320
|
+
"GET",
|
|
321
|
+
`/webhooks/sample/${encodeURIComponent(event)}`
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
/** Subscribe to an event (REST Hooks / Zapier protocol). */
|
|
325
|
+
async subscribe(params, options) {
|
|
326
|
+
return this.client.request("POST", "/webhooks/subscribe", {
|
|
327
|
+
body: params,
|
|
328
|
+
idempotencyKey: options?.idempotencyKey
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
/** Unsubscribe from an event (REST Hooks / Zapier protocol). Returns void (204 No Content). */
|
|
332
|
+
async unsubscribe(subscriptionId) {
|
|
333
|
+
await this.client.request("DELETE", `/webhooks/subscribe/${subscriptionId}`);
|
|
334
|
+
}
|
|
335
|
+
/** Register a CLI listener (returns listenerId and signing secret). */
|
|
336
|
+
async listen(params, options) {
|
|
337
|
+
return this.client.request("POST", "/webhooks/listen", {
|
|
338
|
+
body: params,
|
|
339
|
+
idempotencyKey: options?.idempotencyKey
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
/** Deregister a CLI listener. */
|
|
343
|
+
async unlisten(listenerId) {
|
|
344
|
+
return this.client.request(
|
|
345
|
+
"DELETE",
|
|
346
|
+
`/webhooks/listen/${listenerId}`
|
|
347
|
+
);
|
|
348
|
+
}
|
|
303
349
|
};
|
|
304
350
|
|
|
305
351
|
// src/resources/automations.ts
|
|
@@ -579,29 +625,74 @@ var NotificationsResource = class {
|
|
|
579
625
|
constructor(client) {
|
|
580
626
|
this.client = client;
|
|
581
627
|
}
|
|
582
|
-
/** List notifications. */
|
|
628
|
+
/** List notifications for a user. */
|
|
583
629
|
async list(params) {
|
|
584
630
|
return this.client.request("GET", "/notifications", {
|
|
585
631
|
query: params
|
|
586
632
|
});
|
|
587
633
|
}
|
|
588
|
-
/** Get unread notification count. */
|
|
589
|
-
async unreadCount() {
|
|
590
|
-
return this.client.request("GET", "/notifications/unread-count"
|
|
634
|
+
/** Get unread notification count for a user. */
|
|
635
|
+
async unreadCount(userId) {
|
|
636
|
+
return this.client.request("GET", "/notifications/unread-count", {
|
|
637
|
+
query: { userId }
|
|
638
|
+
});
|
|
591
639
|
}
|
|
592
640
|
/** Mark a single notification as read. */
|
|
593
|
-
async markRead(notificationId) {
|
|
641
|
+
async markRead(notificationId, userId) {
|
|
594
642
|
return this.client.request(
|
|
595
643
|
"PATCH",
|
|
596
|
-
`/notifications/${notificationId}`,
|
|
597
|
-
{ body: {
|
|
644
|
+
`/notifications/${notificationId}/read`,
|
|
645
|
+
{ body: { userId } }
|
|
598
646
|
);
|
|
599
647
|
}
|
|
600
648
|
/** Mark all notifications as read. */
|
|
601
|
-
async markAllRead() {
|
|
649
|
+
async markAllRead(userId) {
|
|
650
|
+
return this.client.request(
|
|
651
|
+
"POST",
|
|
652
|
+
"/notifications/mark-all-read",
|
|
653
|
+
{ body: { userId } }
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
/** Delete (dismiss) a notification. For broadcast notifications, pass userId as a query param. */
|
|
657
|
+
async del(notificationId, params) {
|
|
658
|
+
return this.client.request(
|
|
659
|
+
"DELETE",
|
|
660
|
+
`/notifications/${notificationId}`,
|
|
661
|
+
{ query: params }
|
|
662
|
+
);
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
// src/resources/mentions.ts
|
|
667
|
+
var MentionsResource = class {
|
|
668
|
+
constructor(client) {
|
|
669
|
+
this.client = client;
|
|
670
|
+
}
|
|
671
|
+
/** List mentions for a user. */
|
|
672
|
+
async list(params) {
|
|
673
|
+
return this.client.request("GET", "/mentions", {
|
|
674
|
+
query: params
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
/** Get unread mention count for a user. */
|
|
678
|
+
async unreadCount(userId) {
|
|
679
|
+
return this.client.request("GET", "/mentions/unread-count", {
|
|
680
|
+
query: { userId }
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
/** Mark a single mention as read. */
|
|
684
|
+
async markRead(mentionId) {
|
|
685
|
+
return this.client.request(
|
|
686
|
+
"PATCH",
|
|
687
|
+
`/mentions/${mentionId}/read`
|
|
688
|
+
);
|
|
689
|
+
}
|
|
690
|
+
/** Mark all mentions as read for a user. */
|
|
691
|
+
async markAllRead(userId) {
|
|
602
692
|
return this.client.request(
|
|
603
693
|
"POST",
|
|
604
|
-
"/
|
|
694
|
+
"/mentions/mark-all-read",
|
|
695
|
+
{ body: { userId } }
|
|
605
696
|
);
|
|
606
697
|
}
|
|
607
698
|
};
|
|
@@ -681,10 +772,6 @@ var SlaResource = class {
|
|
|
681
772
|
query: params
|
|
682
773
|
});
|
|
683
774
|
}
|
|
684
|
-
/** Get a single SLA rule. */
|
|
685
|
-
async get(ruleId) {
|
|
686
|
-
return this.client.request("GET", `/sla/rules/${ruleId}`);
|
|
687
|
-
}
|
|
688
775
|
/** Create an SLA rule. */
|
|
689
776
|
async create(params, options) {
|
|
690
777
|
return this.client.request("POST", "/sla/rules", {
|
|
@@ -702,35 +789,79 @@ var SlaResource = class {
|
|
|
702
789
|
async del(ruleId) {
|
|
703
790
|
return this.client.request("DELETE", `/sla/rules/${ruleId}`);
|
|
704
791
|
}
|
|
792
|
+
/** Reorder SLA rules by providing an ordered array of IDs. */
|
|
793
|
+
async reorder(orderedIds) {
|
|
794
|
+
return this.client.request("PUT", "/sla/rules/reorder", {
|
|
795
|
+
body: { orderedIds }
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
/** Get SLA compliance metrics. */
|
|
799
|
+
async metrics(params) {
|
|
800
|
+
return this.client.request("GET", "/sla/metrics", {
|
|
801
|
+
query: params
|
|
802
|
+
});
|
|
803
|
+
}
|
|
705
804
|
};
|
|
706
805
|
|
|
707
806
|
// src/resources/analytics.ts
|
|
708
|
-
var
|
|
807
|
+
var CsatSurveysResource = class {
|
|
709
808
|
constructor(client) {
|
|
710
809
|
this.client = client;
|
|
711
810
|
}
|
|
712
|
-
/**
|
|
713
|
-
async
|
|
714
|
-
return this.client.request("GET", "/
|
|
811
|
+
/** List CSAT surveys. */
|
|
812
|
+
async list(params) {
|
|
813
|
+
return this.client.request("GET", "/csat/surveys", {
|
|
715
814
|
query: params
|
|
716
815
|
});
|
|
717
816
|
}
|
|
718
|
-
/** Get
|
|
719
|
-
async
|
|
720
|
-
return this.client.request("GET",
|
|
817
|
+
/** Get a single CSAT survey. */
|
|
818
|
+
async get(surveyId) {
|
|
819
|
+
return this.client.request("GET", `/csat/surveys/${surveyId}`);
|
|
820
|
+
}
|
|
821
|
+
/** Create and send a CSAT survey. */
|
|
822
|
+
async create(params) {
|
|
823
|
+
return this.client.request("POST", "/csat/surveys", {
|
|
824
|
+
body: params
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
var AnalyticsResource = class {
|
|
829
|
+
constructor(client) {
|
|
830
|
+
this.client = client;
|
|
831
|
+
this.csatSurveys = new CsatSurveysResource(client);
|
|
832
|
+
}
|
|
833
|
+
/** Get analytics data. Specify type to control the response shape. */
|
|
834
|
+
async get(params) {
|
|
835
|
+
return this.client.request("GET", "/analytics", {
|
|
721
836
|
query: params
|
|
722
837
|
});
|
|
723
838
|
}
|
|
839
|
+
/** Get analytics overview (shortcut for type=overview). */
|
|
840
|
+
async overview(params) {
|
|
841
|
+
return this.get({ ...params, type: "overview" });
|
|
842
|
+
}
|
|
843
|
+
/** Get agent performance stats (shortcut for type=performance). */
|
|
844
|
+
async performance(params) {
|
|
845
|
+
return this.get({ ...params, type: "performance" });
|
|
846
|
+
}
|
|
847
|
+
/** Get library analytics (shortcut for type=library). */
|
|
848
|
+
async library(params) {
|
|
849
|
+
return this.get({ ...params, type: "library" });
|
|
850
|
+
}
|
|
724
851
|
/** Get CSAT statistics. */
|
|
725
852
|
async csatStats(params) {
|
|
726
853
|
return this.client.request("GET", "/csat/stats", {
|
|
727
854
|
query: params
|
|
728
855
|
});
|
|
729
856
|
}
|
|
730
|
-
/**
|
|
731
|
-
async
|
|
732
|
-
return this.client.request("GET", "/csat/
|
|
733
|
-
|
|
857
|
+
/** Get CSAT settings. */
|
|
858
|
+
async csatSettings() {
|
|
859
|
+
return this.client.request("GET", "/csat/settings");
|
|
860
|
+
}
|
|
861
|
+
/** Update CSAT settings. */
|
|
862
|
+
async updateCsatSettings(params) {
|
|
863
|
+
return this.client.request("PATCH", "/csat/settings", {
|
|
864
|
+
body: params
|
|
734
865
|
});
|
|
735
866
|
}
|
|
736
867
|
};
|
|
@@ -864,9 +995,39 @@ var ActivityResource = class {
|
|
|
864
995
|
};
|
|
865
996
|
|
|
866
997
|
// src/resources/customerGroups.ts
|
|
998
|
+
var CustomerGroupMembersResource = class {
|
|
999
|
+
constructor(client) {
|
|
1000
|
+
this.client = client;
|
|
1001
|
+
}
|
|
1002
|
+
/** List members in a group. */
|
|
1003
|
+
async list(groupId, params) {
|
|
1004
|
+
return this.client.request(
|
|
1005
|
+
"GET",
|
|
1006
|
+
`/customer-groups/${groupId}/members`,
|
|
1007
|
+
{ query: params }
|
|
1008
|
+
);
|
|
1009
|
+
}
|
|
1010
|
+
/** Add member(s) to a group. */
|
|
1011
|
+
async add(groupId, params, options) {
|
|
1012
|
+
return this.client.request(
|
|
1013
|
+
"POST",
|
|
1014
|
+
`/customer-groups/${groupId}/members`,
|
|
1015
|
+
{ body: params, idempotencyKey: options?.idempotencyKey }
|
|
1016
|
+
);
|
|
1017
|
+
}
|
|
1018
|
+
/** Remove a member from a group. */
|
|
1019
|
+
async remove(groupId, customerId) {
|
|
1020
|
+
return this.client.request(
|
|
1021
|
+
"DELETE",
|
|
1022
|
+
`/customer-groups/${groupId}/members`,
|
|
1023
|
+
{ query: { customerId } }
|
|
1024
|
+
);
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
867
1027
|
var CustomerGroupsResource = class extends BaseResource {
|
|
868
1028
|
constructor(client) {
|
|
869
1029
|
super(client, "/customer-groups");
|
|
1030
|
+
this.members = new CustomerGroupMembersResource(client);
|
|
870
1031
|
}
|
|
871
1032
|
};
|
|
872
1033
|
|
|
@@ -930,6 +1091,29 @@ var AchievementsResource = class {
|
|
|
930
1091
|
query: params
|
|
931
1092
|
});
|
|
932
1093
|
}
|
|
1094
|
+
/** Get recently unlocked achievements across the team. */
|
|
1095
|
+
async recent(params) {
|
|
1096
|
+
return this.client.request("GET", "/game/achievements/recent", {
|
|
1097
|
+
query: params
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
};
|
|
1101
|
+
var GameActivityResource = class {
|
|
1102
|
+
constructor(client) {
|
|
1103
|
+
this.client = client;
|
|
1104
|
+
}
|
|
1105
|
+
/** Get the team activity feed. */
|
|
1106
|
+
async list(params) {
|
|
1107
|
+
return this.client.request("GET", "/game/activity", {
|
|
1108
|
+
query: params
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
/** Get activity for a specific member. */
|
|
1112
|
+
async forMember(memberId, params) {
|
|
1113
|
+
return this.client.request("GET", `/game/activity/member/${memberId}`, {
|
|
1114
|
+
query: params
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
933
1117
|
};
|
|
934
1118
|
var QuestsResource = class {
|
|
935
1119
|
constructor(client) {
|
|
@@ -1103,6 +1287,7 @@ var GameResource = class {
|
|
|
1103
1287
|
this.cosmetics = new CosmeticsResource(client);
|
|
1104
1288
|
this.seasons = new SeasonsResource(client);
|
|
1105
1289
|
this.skills = new SkillsResource(client);
|
|
1290
|
+
this.activity = new GameActivityResource(client);
|
|
1106
1291
|
}
|
|
1107
1292
|
/** Get current player stats. */
|
|
1108
1293
|
async player(params) {
|
|
@@ -1126,6 +1311,10 @@ var GameResource = class {
|
|
|
1126
1311
|
query: params
|
|
1127
1312
|
});
|
|
1128
1313
|
}
|
|
1314
|
+
/** Get game balance configuration (read-only constants). */
|
|
1315
|
+
async config() {
|
|
1316
|
+
return this.client.request("GET", "/game/config");
|
|
1317
|
+
}
|
|
1129
1318
|
};
|
|
1130
1319
|
|
|
1131
1320
|
// src/resources/ai.ts
|
|
@@ -1163,9 +1352,9 @@ var ViewsResource = class extends BaseResource {
|
|
|
1163
1352
|
constructor(client) {
|
|
1164
1353
|
super(client, "/views");
|
|
1165
1354
|
}
|
|
1166
|
-
/** Execute a view — returns the filtered results. */
|
|
1355
|
+
/** Execute a view — returns the filtered results. The server uses the view's entity_type to determine which table to query. */
|
|
1167
1356
|
async execute(viewId, params) {
|
|
1168
|
-
return this.client.request("GET", `/views/${viewId}/
|
|
1357
|
+
return this.client.request("GET", `/views/${viewId}/execute`, {
|
|
1169
1358
|
query: params
|
|
1170
1359
|
});
|
|
1171
1360
|
}
|
|
@@ -1205,6 +1394,7 @@ var CStarClient = class {
|
|
|
1205
1394
|
this.members = new MembersResource(this.client);
|
|
1206
1395
|
this.settings = new SettingsResource(this.client);
|
|
1207
1396
|
this.notifications = new NotificationsResource(this.client);
|
|
1397
|
+
this.mentions = new MentionsResource(this.client);
|
|
1208
1398
|
this.attachments = new AttachmentsResource(this.client);
|
|
1209
1399
|
this.customFields = new CustomFieldsResource(this.client);
|
|
1210
1400
|
this.sla = new SlaResource(this.client);
|
package/package.json
CHANGED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/** Configuration for the CommunityClient. */
|
|
2
|
-
interface CommunityConfig {
|
|
3
|
-
/** Team slug (e.g., 'acme'). Identifies the community to query. */
|
|
4
|
-
teamSlug: string;
|
|
5
|
-
/** Override the base URL (defaults to https://www.cstar.help). */
|
|
6
|
-
baseUrl?: string;
|
|
7
|
-
}
|
|
8
|
-
/** A discussion topic/category in the community. */
|
|
9
|
-
interface CommunityTopic {
|
|
10
|
-
id: string;
|
|
11
|
-
name: string;
|
|
12
|
-
slug: string;
|
|
13
|
-
description: string | null;
|
|
14
|
-
icon: string;
|
|
15
|
-
visibility: 'public' | 'members_only';
|
|
16
|
-
sort_order: number;
|
|
17
|
-
}
|
|
18
|
-
/** A public community post. */
|
|
19
|
-
interface CommunityPost {
|
|
20
|
-
id: string;
|
|
21
|
-
title: string;
|
|
22
|
-
slug: string;
|
|
23
|
-
body: string;
|
|
24
|
-
status: 'open' | 'answered' | 'officially_answered' | 'planned' | 'not_planned' | 'completed' | 'under_review';
|
|
25
|
-
visibility: 'public' | 'members_only';
|
|
26
|
-
voteCount: number;
|
|
27
|
-
commentCount: number;
|
|
28
|
-
isPinned: boolean;
|
|
29
|
-
isFeatured: boolean;
|
|
30
|
-
isLocked: boolean;
|
|
31
|
-
commentsEnabled: boolean;
|
|
32
|
-
topicName: string;
|
|
33
|
-
topicSlug: string;
|
|
34
|
-
authorName: string;
|
|
35
|
-
authorAvatar: string;
|
|
36
|
-
authorBio: string;
|
|
37
|
-
authorPostCount: number;
|
|
38
|
-
authorCommentCount: number;
|
|
39
|
-
isTeamMember: boolean;
|
|
40
|
-
lastActivityAt: string;
|
|
41
|
-
createdAt: string;
|
|
42
|
-
}
|
|
43
|
-
/** A comment on a community post. */
|
|
44
|
-
interface CommunityComment {
|
|
45
|
-
id: string;
|
|
46
|
-
body: string;
|
|
47
|
-
isOfficial: boolean;
|
|
48
|
-
voteScore: number;
|
|
49
|
-
parentCommentId: string | null;
|
|
50
|
-
authorName: string;
|
|
51
|
-
authorAvatar: string;
|
|
52
|
-
authorBio: string;
|
|
53
|
-
authorPostCount: number;
|
|
54
|
-
authorCommentCount: number;
|
|
55
|
-
isTeamMember: boolean;
|
|
56
|
-
createdAt: string;
|
|
57
|
-
}
|
|
58
|
-
/** Parameters for listing posts. */
|
|
59
|
-
interface CommunityPostListParams {
|
|
60
|
-
/** Filter by topic slug. */
|
|
61
|
-
topicSlug?: string;
|
|
62
|
-
/** Filter by status. */
|
|
63
|
-
status?: string;
|
|
64
|
-
/** Sort order (default: 'recent'). */
|
|
65
|
-
sort?: 'recent' | 'votes' | 'comments';
|
|
66
|
-
/** Max results per page. */
|
|
67
|
-
limit?: number;
|
|
68
|
-
/** Pagination offset. */
|
|
69
|
-
offset?: number;
|
|
70
|
-
}
|
|
71
|
-
/** Search results. */
|
|
72
|
-
interface CommunitySearchResult {
|
|
73
|
-
data: CommunityPost[];
|
|
74
|
-
count: number;
|
|
75
|
-
query: string;
|
|
76
|
-
}
|
|
77
|
-
/** A single post with its comments. */
|
|
78
|
-
interface CommunityPostDetail {
|
|
79
|
-
post: CommunityPost;
|
|
80
|
-
comments: CommunityComment[];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Public community client. No authentication required.
|
|
85
|
-
*
|
|
86
|
-
* ```typescript
|
|
87
|
-
* const community = new CommunityClient({ teamSlug: 'acme' });
|
|
88
|
-
* const topics = await community.topics();
|
|
89
|
-
* const posts = await community.posts({ topicSlug: 'feedback', sort: 'votes' });
|
|
90
|
-
* const post = await community.post('my-feature-request');
|
|
91
|
-
* const results = await community.search('dark mode');
|
|
92
|
-
* ```
|
|
93
|
-
*/
|
|
94
|
-
declare class CommunityClient {
|
|
95
|
-
private readonly baseUrl;
|
|
96
|
-
private readonly teamSlug;
|
|
97
|
-
constructor(config: CommunityConfig);
|
|
98
|
-
/** List all public community topics. */
|
|
99
|
-
topics(): Promise<CommunityTopic[]>;
|
|
100
|
-
/** List public posts, optionally filtered by topic, status, or sort order. */
|
|
101
|
-
posts(params?: CommunityPostListParams): Promise<{
|
|
102
|
-
posts: CommunityPost[];
|
|
103
|
-
count: number;
|
|
104
|
-
}>;
|
|
105
|
-
/** Get a single post by slug, including all comments. */
|
|
106
|
-
post(slug: string): Promise<CommunityPostDetail>;
|
|
107
|
-
/**
|
|
108
|
-
* Full-text search across post titles and bodies.
|
|
109
|
-
* Returns matching posts with relevance ranking.
|
|
110
|
-
*/
|
|
111
|
-
search(query: string): Promise<CommunitySearchResult>;
|
|
112
|
-
private fetch;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export { CommunityClient, type CommunityComment, type CommunityConfig, type CommunityPost, type CommunityPostDetail, type CommunityPostListParams, type CommunitySearchResult, type CommunityTopic };
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/** Configuration for the CommunityClient. */
|
|
2
|
-
interface CommunityConfig {
|
|
3
|
-
/** Team slug (e.g., 'acme'). Identifies the community to query. */
|
|
4
|
-
teamSlug: string;
|
|
5
|
-
/** Override the base URL (defaults to https://www.cstar.help). */
|
|
6
|
-
baseUrl?: string;
|
|
7
|
-
}
|
|
8
|
-
/** A discussion topic/category in the community. */
|
|
9
|
-
interface CommunityTopic {
|
|
10
|
-
id: string;
|
|
11
|
-
name: string;
|
|
12
|
-
slug: string;
|
|
13
|
-
description: string | null;
|
|
14
|
-
icon: string;
|
|
15
|
-
visibility: 'public' | 'members_only';
|
|
16
|
-
sort_order: number;
|
|
17
|
-
}
|
|
18
|
-
/** A public community post. */
|
|
19
|
-
interface CommunityPost {
|
|
20
|
-
id: string;
|
|
21
|
-
title: string;
|
|
22
|
-
slug: string;
|
|
23
|
-
body: string;
|
|
24
|
-
status: 'open' | 'answered' | 'officially_answered' | 'planned' | 'not_planned' | 'completed' | 'under_review';
|
|
25
|
-
visibility: 'public' | 'members_only';
|
|
26
|
-
voteCount: number;
|
|
27
|
-
commentCount: number;
|
|
28
|
-
isPinned: boolean;
|
|
29
|
-
isFeatured: boolean;
|
|
30
|
-
isLocked: boolean;
|
|
31
|
-
commentsEnabled: boolean;
|
|
32
|
-
topicName: string;
|
|
33
|
-
topicSlug: string;
|
|
34
|
-
authorName: string;
|
|
35
|
-
authorAvatar: string;
|
|
36
|
-
authorBio: string;
|
|
37
|
-
authorPostCount: number;
|
|
38
|
-
authorCommentCount: number;
|
|
39
|
-
isTeamMember: boolean;
|
|
40
|
-
lastActivityAt: string;
|
|
41
|
-
createdAt: string;
|
|
42
|
-
}
|
|
43
|
-
/** A comment on a community post. */
|
|
44
|
-
interface CommunityComment {
|
|
45
|
-
id: string;
|
|
46
|
-
body: string;
|
|
47
|
-
isOfficial: boolean;
|
|
48
|
-
voteScore: number;
|
|
49
|
-
parentCommentId: string | null;
|
|
50
|
-
authorName: string;
|
|
51
|
-
authorAvatar: string;
|
|
52
|
-
authorBio: string;
|
|
53
|
-
authorPostCount: number;
|
|
54
|
-
authorCommentCount: number;
|
|
55
|
-
isTeamMember: boolean;
|
|
56
|
-
createdAt: string;
|
|
57
|
-
}
|
|
58
|
-
/** Parameters for listing posts. */
|
|
59
|
-
interface CommunityPostListParams {
|
|
60
|
-
/** Filter by topic slug. */
|
|
61
|
-
topicSlug?: string;
|
|
62
|
-
/** Filter by status. */
|
|
63
|
-
status?: string;
|
|
64
|
-
/** Sort order (default: 'recent'). */
|
|
65
|
-
sort?: 'recent' | 'votes' | 'comments';
|
|
66
|
-
/** Max results per page. */
|
|
67
|
-
limit?: number;
|
|
68
|
-
/** Pagination offset. */
|
|
69
|
-
offset?: number;
|
|
70
|
-
}
|
|
71
|
-
/** Search results. */
|
|
72
|
-
interface CommunitySearchResult {
|
|
73
|
-
data: CommunityPost[];
|
|
74
|
-
count: number;
|
|
75
|
-
query: string;
|
|
76
|
-
}
|
|
77
|
-
/** A single post with its comments. */
|
|
78
|
-
interface CommunityPostDetail {
|
|
79
|
-
post: CommunityPost;
|
|
80
|
-
comments: CommunityComment[];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Public community client. No authentication required.
|
|
85
|
-
*
|
|
86
|
-
* ```typescript
|
|
87
|
-
* const community = new CommunityClient({ teamSlug: 'acme' });
|
|
88
|
-
* const topics = await community.topics();
|
|
89
|
-
* const posts = await community.posts({ topicSlug: 'feedback', sort: 'votes' });
|
|
90
|
-
* const post = await community.post('my-feature-request');
|
|
91
|
-
* const results = await community.search('dark mode');
|
|
92
|
-
* ```
|
|
93
|
-
*/
|
|
94
|
-
declare class CommunityClient {
|
|
95
|
-
private readonly baseUrl;
|
|
96
|
-
private readonly teamSlug;
|
|
97
|
-
constructor(config: CommunityConfig);
|
|
98
|
-
/** List all public community topics. */
|
|
99
|
-
topics(): Promise<CommunityTopic[]>;
|
|
100
|
-
/** List public posts, optionally filtered by topic, status, or sort order. */
|
|
101
|
-
posts(params?: CommunityPostListParams): Promise<{
|
|
102
|
-
posts: CommunityPost[];
|
|
103
|
-
count: number;
|
|
104
|
-
}>;
|
|
105
|
-
/** Get a single post by slug, including all comments. */
|
|
106
|
-
post(slug: string): Promise<CommunityPostDetail>;
|
|
107
|
-
/**
|
|
108
|
-
* Full-text search across post titles and bodies.
|
|
109
|
-
* Returns matching posts with relevance ranking.
|
|
110
|
-
*/
|
|
111
|
-
search(query: string): Promise<CommunitySearchResult>;
|
|
112
|
-
private fetch;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export { CommunityClient, type CommunityComment, type CommunityConfig, type CommunityPost, type CommunityPostDetail, type CommunityPostListParams, type CommunitySearchResult, type CommunityTopic };
|