@geoly-ai/social-hub-sdk 0.0.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.d.ts +681 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +815 -0
- package/dist/index.js.map +1 -0
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.d.ts.map +1 -0
- package/dist/index.test.js +34 -0
- package/dist/index.test.js.map +1 -0
- package/package.json +34 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,815 @@
|
|
|
1
|
+
/** GET /health without API key. */
|
|
2
|
+
export async function getSocialHubHealth(baseUrl) {
|
|
3
|
+
const url = `${baseUrl.replace(/\/$/, "")}/health`;
|
|
4
|
+
const res = await fetch(url);
|
|
5
|
+
const text = await res.text();
|
|
6
|
+
if (!res.ok) {
|
|
7
|
+
throw new Error(`HTTP ${res.status}: ${text}`);
|
|
8
|
+
}
|
|
9
|
+
return (text ? JSON.parse(text) : {});
|
|
10
|
+
}
|
|
11
|
+
/** GET /health/live without API key. */
|
|
12
|
+
export async function getSocialHubHealthLive(baseUrl) {
|
|
13
|
+
const url = `${baseUrl.replace(/\/$/, "")}/health/live`;
|
|
14
|
+
const res = await fetch(url);
|
|
15
|
+
const text = await res.text();
|
|
16
|
+
if (!res.ok) {
|
|
17
|
+
throw new Error(`HTTP ${res.status}: ${text}`);
|
|
18
|
+
}
|
|
19
|
+
return (text ? JSON.parse(text) : { ok: true });
|
|
20
|
+
}
|
|
21
|
+
/** POST /v1/auth/device/code — no API key required. */
|
|
22
|
+
export async function createDeviceCode(baseUrl, body) {
|
|
23
|
+
const url = `${baseUrl.replace(/\/$/, "")}/v1/auth/device/code`;
|
|
24
|
+
const res = await fetch(url, {
|
|
25
|
+
method: "POST",
|
|
26
|
+
headers: { "Content-Type": "application/json" },
|
|
27
|
+
body: JSON.stringify(body),
|
|
28
|
+
});
|
|
29
|
+
const text = await res.text();
|
|
30
|
+
if (!res.ok) {
|
|
31
|
+
throw new Error(`HTTP ${res.status}: ${text}`);
|
|
32
|
+
}
|
|
33
|
+
return JSON.parse(text);
|
|
34
|
+
}
|
|
35
|
+
/** POST /v1/auth/device/token — poll for CLI access token. */
|
|
36
|
+
export async function pollDeviceToken(baseUrl, deviceCode) {
|
|
37
|
+
const url = `${baseUrl.replace(/\/$/, "")}/v1/auth/device/token`;
|
|
38
|
+
const res = await fetch(url, {
|
|
39
|
+
method: "POST",
|
|
40
|
+
headers: { "Content-Type": "application/json" },
|
|
41
|
+
body: JSON.stringify({ deviceCode }),
|
|
42
|
+
});
|
|
43
|
+
const text = await res.text();
|
|
44
|
+
const parsed = (text ? JSON.parse(text) : {});
|
|
45
|
+
if (!res.ok) {
|
|
46
|
+
if (parsed.error === "authorization_pending" ||
|
|
47
|
+
parsed.error === "slow_down" ||
|
|
48
|
+
parsed.error === "expired_token" ||
|
|
49
|
+
parsed.error === "access_denied") {
|
|
50
|
+
return { error: parsed.error };
|
|
51
|
+
}
|
|
52
|
+
throw new Error(`HTTP ${res.status}: ${text}`);
|
|
53
|
+
}
|
|
54
|
+
return parsed;
|
|
55
|
+
}
|
|
56
|
+
function buildQuery(params) {
|
|
57
|
+
const sp = new URLSearchParams();
|
|
58
|
+
for (const [k, v] of Object.entries(params)) {
|
|
59
|
+
if (v === undefined || v === "")
|
|
60
|
+
continue;
|
|
61
|
+
sp.set(k, String(v));
|
|
62
|
+
}
|
|
63
|
+
const s = sp.toString();
|
|
64
|
+
return s ? `?${s}` : "";
|
|
65
|
+
}
|
|
66
|
+
function parseErrorMessage(text) {
|
|
67
|
+
try {
|
|
68
|
+
const j = JSON.parse(text);
|
|
69
|
+
return j.error?.message ?? j.message ?? text;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return text;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export class SocialHubClient {
|
|
76
|
+
opts;
|
|
77
|
+
constructor(opts) {
|
|
78
|
+
this.opts = opts;
|
|
79
|
+
}
|
|
80
|
+
teamBase(teamId) {
|
|
81
|
+
return `/v1/teams/${teamId}`;
|
|
82
|
+
}
|
|
83
|
+
/** GET /health — no API key required. */
|
|
84
|
+
async getHealth() {
|
|
85
|
+
return getSocialHubHealth(this.opts.baseUrl);
|
|
86
|
+
}
|
|
87
|
+
async fetchJson(path, init) {
|
|
88
|
+
const url = `${this.opts.baseUrl.replace(/\/$/, "")}${path}`;
|
|
89
|
+
const res = await fetch(url, {
|
|
90
|
+
...init,
|
|
91
|
+
headers: {
|
|
92
|
+
Authorization: `Bearer ${this.opts.apiKey}`,
|
|
93
|
+
"Content-Type": "application/json",
|
|
94
|
+
...init?.headers,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
const text = await res.text();
|
|
98
|
+
if (!res.ok) {
|
|
99
|
+
throw new Error(`HTTP ${res.status}: ${parseErrorMessage(text)}`);
|
|
100
|
+
}
|
|
101
|
+
if (init?.parseJson === false)
|
|
102
|
+
return undefined;
|
|
103
|
+
return (text ? JSON.parse(text) : {});
|
|
104
|
+
}
|
|
105
|
+
// --- events (existing) ---
|
|
106
|
+
async appendEvent(teamId, body) {
|
|
107
|
+
return this.fetchJson(`/v1/teams/${teamId}/events`, {
|
|
108
|
+
method: "POST",
|
|
109
|
+
body: JSON.stringify(body),
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
async listEvents(teamId, limit = 50) {
|
|
113
|
+
return this.fetchJson(`/v1/teams/${teamId}/events?limit=${limit}`);
|
|
114
|
+
}
|
|
115
|
+
// --- dashboard ---
|
|
116
|
+
async getDashboardSummary(teamId, params = {}) {
|
|
117
|
+
const q = buildQuery({
|
|
118
|
+
interactionTrendDays: params.interactionTrendDays,
|
|
119
|
+
campaignId: params.campaignId,
|
|
120
|
+
brandId: params.brandId,
|
|
121
|
+
from: params.from,
|
|
122
|
+
to: params.to,
|
|
123
|
+
});
|
|
124
|
+
return this.fetchJson(`${this.teamBase(teamId)}/dashboard/summary${q}`);
|
|
125
|
+
}
|
|
126
|
+
// --- calendar entries ---
|
|
127
|
+
async listCalendarEntries(teamId, params = {}) {
|
|
128
|
+
const q = buildQuery({
|
|
129
|
+
limit: params.limit,
|
|
130
|
+
campaignId: params.campaignId,
|
|
131
|
+
publishingPlanId: params.publishingPlanId,
|
|
132
|
+
socialAccountId: params.socialAccountId,
|
|
133
|
+
status: params.status,
|
|
134
|
+
from: params.from,
|
|
135
|
+
to: params.to,
|
|
136
|
+
});
|
|
137
|
+
return this.fetchJson(`${this.teamBase(teamId)}/calendar-entries${q}`);
|
|
138
|
+
}
|
|
139
|
+
async updateCalendarEntry(teamId, entryId, body) {
|
|
140
|
+
return this.fetchJson(`${this.teamBase(teamId)}/calendar-entries/${entryId}`, {
|
|
141
|
+
method: "PATCH",
|
|
142
|
+
body: JSON.stringify(body),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
// --- reddit post snapshots ---
|
|
146
|
+
async listRedditPostSnapshots(teamId, params = {}) {
|
|
147
|
+
const q = buildQuery({
|
|
148
|
+
limit: params.limit ?? 100,
|
|
149
|
+
campaignId: params.campaignId,
|
|
150
|
+
calendarEntryId: params.calendarEntryId,
|
|
151
|
+
socialAccountId: params.socialAccountId,
|
|
152
|
+
});
|
|
153
|
+
return this.fetchJson(`${this.teamBase(teamId)}/reddit-post-snapshots${q}`);
|
|
154
|
+
}
|
|
155
|
+
async getRedditPostSnapshotStats(teamId, params = {}) {
|
|
156
|
+
const q = buildQuery({
|
|
157
|
+
campaignId: params.campaignId,
|
|
158
|
+
calendarEntryId: params.calendarEntryId,
|
|
159
|
+
opsStatus: params.opsStatus,
|
|
160
|
+
postType: params.postType,
|
|
161
|
+
range: params.range,
|
|
162
|
+
compare: params.compare,
|
|
163
|
+
});
|
|
164
|
+
return this.fetchJson(`${this.teamBase(teamId)}/reddit-post-snapshots/stats${q}`);
|
|
165
|
+
}
|
|
166
|
+
async getRedditPostRefreshStatus(teamId) {
|
|
167
|
+
return this.fetchJson(`${this.teamBase(teamId)}/reddit-post-snapshots/refresh-status`);
|
|
168
|
+
}
|
|
169
|
+
async refreshAllRedditPostSnapshots(teamId) {
|
|
170
|
+
return this.fetchJson(`${this.teamBase(teamId)}/reddit-post-snapshots/refresh-all`, { method: "POST", body: JSON.stringify({}) });
|
|
171
|
+
}
|
|
172
|
+
async getRedditRefreshAllProgress(teamId, batchId) {
|
|
173
|
+
return this.fetchJson(`${this.teamBase(teamId)}/reddit-post-snapshots/refresh-all/${batchId}/progress`);
|
|
174
|
+
}
|
|
175
|
+
async refreshRedditPostSnapshot(teamId, snapshotId) {
|
|
176
|
+
return this.fetchJson(`${this.teamBase(teamId)}/reddit-post-snapshots/${snapshotId}/refresh`, { method: "POST", body: JSON.stringify({}) });
|
|
177
|
+
}
|
|
178
|
+
async updateRedditPostSnapshot(teamId, snapshotId, body) {
|
|
179
|
+
return this.fetchJson(`${this.teamBase(teamId)}/reddit-post-snapshots/${snapshotId}`, { method: "PUT", body: JSON.stringify(body) });
|
|
180
|
+
}
|
|
181
|
+
async deleteRedditPostSnapshot(teamId, snapshotId) {
|
|
182
|
+
return this.fetchJson(`${this.teamBase(teamId)}/reddit-post-snapshots/${snapshotId}`, { method: "DELETE" });
|
|
183
|
+
}
|
|
184
|
+
async importRedditPostSnapshotsFromFeishu(teamId, body = {}) {
|
|
185
|
+
return this.fetchJson(`${this.teamBase(teamId)}/reddit-post-snapshots/import-feishu`, { method: "POST", body: JSON.stringify(body) });
|
|
186
|
+
}
|
|
187
|
+
// --- scheduled jobs ---
|
|
188
|
+
async listScheduledJobs(teamId, params = {}) {
|
|
189
|
+
const q = buildQuery({
|
|
190
|
+
limit: params.limit,
|
|
191
|
+
status: params.status,
|
|
192
|
+
socialAccountId: params.socialAccountId,
|
|
193
|
+
from: params.from,
|
|
194
|
+
to: params.to,
|
|
195
|
+
});
|
|
196
|
+
return this.fetchJson(`${this.teamBase(teamId)}/scheduled-jobs${q}`);
|
|
197
|
+
}
|
|
198
|
+
async getScheduledJobsAutomationSummary(teamId, hours = 24) {
|
|
199
|
+
return this.fetchJson(`${this.teamBase(teamId)}/scheduled-jobs/automation-summary?hours=${hours}`);
|
|
200
|
+
}
|
|
201
|
+
async createScheduledJob(teamId, body) {
|
|
202
|
+
return this.fetchJson(`${this.teamBase(teamId)}/scheduled-jobs`, {
|
|
203
|
+
method: "POST",
|
|
204
|
+
body: JSON.stringify(body),
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
async createScheduledJobsBatch(teamId, body) {
|
|
208
|
+
return this.fetchJson(`${this.teamBase(teamId)}/scheduled-jobs/batch`, {
|
|
209
|
+
method: "POST",
|
|
210
|
+
body: JSON.stringify(body),
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
async retryScheduledJob(teamId, jobId) {
|
|
214
|
+
return this.fetchJson(`${this.teamBase(teamId)}/scheduled-jobs/${jobId}/retry`, {
|
|
215
|
+
method: "POST",
|
|
216
|
+
body: JSON.stringify({}),
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
async cancelScheduledJob(teamId, jobId) {
|
|
220
|
+
return this.fetchJson(`${this.teamBase(teamId)}/scheduled-jobs/${jobId}/cancel`, {
|
|
221
|
+
method: "POST",
|
|
222
|
+
body: JSON.stringify({}),
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
// --- content drafts ---
|
|
226
|
+
async listContentDrafts(teamId, limit = 50) {
|
|
227
|
+
return this.fetchJson(`${this.teamBase(teamId)}/content-drafts?limit=${limit}`);
|
|
228
|
+
}
|
|
229
|
+
async createContentDraft(teamId, body) {
|
|
230
|
+
return this.fetchJson(`${this.teamBase(teamId)}/content-drafts`, {
|
|
231
|
+
method: "POST",
|
|
232
|
+
body: JSON.stringify(body),
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
// --- reports ---
|
|
236
|
+
async listReports(teamId, options = 50) {
|
|
237
|
+
const opts = typeof options === "number" ? { limit: options } : (options ?? {});
|
|
238
|
+
const q = buildQuery({
|
|
239
|
+
limit: opts.limit ?? 50,
|
|
240
|
+
reportType: opts.reportType,
|
|
241
|
+
});
|
|
242
|
+
return this.fetchJson(`${this.teamBase(teamId)}/reports${q}`);
|
|
243
|
+
}
|
|
244
|
+
async ingestReport(teamId, body) {
|
|
245
|
+
return this.fetchJson(`${this.teamBase(teamId)}/reports/ingest`, {
|
|
246
|
+
method: "POST",
|
|
247
|
+
body: JSON.stringify(body),
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
// --- accounts ---
|
|
251
|
+
async listAccounts(teamId, params = {}) {
|
|
252
|
+
const q = buildQuery({
|
|
253
|
+
limit: params.limit,
|
|
254
|
+
status: params.status,
|
|
255
|
+
platform: params.platform,
|
|
256
|
+
campaignId: params.campaignId,
|
|
257
|
+
});
|
|
258
|
+
return this.fetchJson(`${this.teamBase(teamId)}/accounts${q}`);
|
|
259
|
+
}
|
|
260
|
+
async createAccount(teamId, body) {
|
|
261
|
+
return this.fetchJson(`${this.teamBase(teamId)}/accounts`, {
|
|
262
|
+
method: "POST",
|
|
263
|
+
body: JSON.stringify(body),
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
// --- brands ---
|
|
267
|
+
async listBrands(teamId) {
|
|
268
|
+
return this.fetchJson(`${this.teamBase(teamId)}/brands`);
|
|
269
|
+
}
|
|
270
|
+
async createBrand(teamId, body) {
|
|
271
|
+
return this.fetchJson(`${this.teamBase(teamId)}/brands`, {
|
|
272
|
+
method: "POST",
|
|
273
|
+
body: JSON.stringify(body),
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
async updateBrand(teamId, brandId, body) {
|
|
277
|
+
return this.fetchJson(`${this.teamBase(teamId)}/brands/${brandId}`, {
|
|
278
|
+
method: "PATCH",
|
|
279
|
+
body: JSON.stringify(body),
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
// --- campaigns ---
|
|
283
|
+
async listCampaigns(teamId, params = {}) {
|
|
284
|
+
const q = buildQuery({ brandId: params.brandId });
|
|
285
|
+
return this.fetchJson(`${this.teamBase(teamId)}/campaigns${q}`);
|
|
286
|
+
}
|
|
287
|
+
async createCampaign(teamId, body) {
|
|
288
|
+
return this.fetchJson(`${this.teamBase(teamId)}/campaigns`, {
|
|
289
|
+
method: "POST",
|
|
290
|
+
body: JSON.stringify(body),
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
// --- publishing plans ---
|
|
294
|
+
async listPublishingPlans(teamId, params = {}) {
|
|
295
|
+
const q = buildQuery({ campaignId: params.campaignId });
|
|
296
|
+
return this.fetchJson(`${this.teamBase(teamId)}/publishing-plans${q}`);
|
|
297
|
+
}
|
|
298
|
+
async createPublishingPlan(teamId, body) {
|
|
299
|
+
return this.fetchJson(`${this.teamBase(teamId)}/publishing-plans`, {
|
|
300
|
+
method: "POST",
|
|
301
|
+
body: JSON.stringify(body),
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
// --- audit & permissions ---
|
|
305
|
+
async listAuditLogs(teamId, params = {}) {
|
|
306
|
+
const q = buildQuery({
|
|
307
|
+
limit: params.limit,
|
|
308
|
+
type: params.type,
|
|
309
|
+
actor: params.actor,
|
|
310
|
+
result: params.result,
|
|
311
|
+
socialAccountId: params.socialAccountId,
|
|
312
|
+
createdFrom: params.createdFrom,
|
|
313
|
+
createdTo: params.createdTo,
|
|
314
|
+
});
|
|
315
|
+
return this.fetchJson(`${this.teamBase(teamId)}/audit-logs${q}`);
|
|
316
|
+
}
|
|
317
|
+
async getPermissionsMatrix(teamId) {
|
|
318
|
+
return this.fetchJson(`${this.teamBase(teamId)}/permissions-matrix`);
|
|
319
|
+
}
|
|
320
|
+
// --- account graph ---
|
|
321
|
+
async listAccountGraphEdges(teamId, params = {}) {
|
|
322
|
+
const q = buildQuery({
|
|
323
|
+
limit: params.limit,
|
|
324
|
+
cursor: params.cursor,
|
|
325
|
+
socialAccountId: params.socialAccountId,
|
|
326
|
+
edgeType: params.edgeType,
|
|
327
|
+
minRisk: params.minRisk,
|
|
328
|
+
});
|
|
329
|
+
return this.fetchJson(`${this.teamBase(teamId)}/account-graph${q}`);
|
|
330
|
+
}
|
|
331
|
+
// --- reddit snapshots (manual create) ---
|
|
332
|
+
async createRedditPostSnapshot(teamId, body) {
|
|
333
|
+
return this.fetchJson(`${this.teamBase(teamId)}/reddit-post-snapshots`, {
|
|
334
|
+
method: "POST",
|
|
335
|
+
body: JSON.stringify(body),
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
// --- events batch ---
|
|
339
|
+
async appendEventsBatch(teamId, body) {
|
|
340
|
+
return this.fetchJson(`${this.teamBase(teamId)}/events/batch`, {
|
|
341
|
+
method: "POST",
|
|
342
|
+
body: JSON.stringify(body),
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
// --- openclaw ingest ---
|
|
346
|
+
async triggerOpenClawIngest(teamId, body) {
|
|
347
|
+
return this.fetchJson(`${this.teamBase(teamId)}/openclaw-ingest`, {
|
|
348
|
+
method: "POST",
|
|
349
|
+
body: JSON.stringify(body),
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
// --- compliance ---
|
|
353
|
+
async listSubredditSanctions(teamId, params = {}) {
|
|
354
|
+
const q = buildQuery({
|
|
355
|
+
limit: params.limit,
|
|
356
|
+
socialAccountId: params.socialAccountId,
|
|
357
|
+
subreddit: params.subreddit,
|
|
358
|
+
});
|
|
359
|
+
return this.fetchJson(`${this.teamBase(teamId)}/subreddit-sanctions${q}`);
|
|
360
|
+
}
|
|
361
|
+
async createSubredditSanction(teamId, body) {
|
|
362
|
+
return this.fetchJson(`${this.teamBase(teamId)}/subreddit-sanctions`, {
|
|
363
|
+
method: "POST",
|
|
364
|
+
body: JSON.stringify(body),
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
async listAccountRiskProfiles(teamId, limit = 100) {
|
|
368
|
+
return this.fetchJson(`${this.teamBase(teamId)}/account-risk-profiles?limit=${limit}`);
|
|
369
|
+
}
|
|
370
|
+
async getAccountRiskProfile(teamId, socialAccountId) {
|
|
371
|
+
return this.fetchJson(`${this.teamBase(teamId)}/social-accounts/${socialAccountId}/risk-profile`);
|
|
372
|
+
}
|
|
373
|
+
async upsertAccountRiskProfile(teamId, socialAccountId, body) {
|
|
374
|
+
return this.fetchJson(`${this.teamBase(teamId)}/social-accounts/${socialAccountId}/risk-profile`, {
|
|
375
|
+
method: "PUT",
|
|
376
|
+
body: JSON.stringify(body),
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
// ── Group A: single-resource CRUD ────────────────────────────────────────
|
|
380
|
+
async getAccount(teamId, accountId) {
|
|
381
|
+
return this.fetchJson(`${this.teamBase(teamId)}/accounts/${accountId}`);
|
|
382
|
+
}
|
|
383
|
+
async updateAccount(teamId, accountId, body) {
|
|
384
|
+
return this.fetchJson(`${this.teamBase(teamId)}/accounts/${accountId}`, { method: "PATCH", body: JSON.stringify(body) });
|
|
385
|
+
}
|
|
386
|
+
async getCampaign(teamId, campaignId) {
|
|
387
|
+
return this.fetchJson(`${this.teamBase(teamId)}/campaigns/${campaignId}`);
|
|
388
|
+
}
|
|
389
|
+
async updateCampaign(teamId, campaignId, body) {
|
|
390
|
+
return this.fetchJson(`${this.teamBase(teamId)}/campaigns/${campaignId}`, { method: "PATCH", body: JSON.stringify(body) });
|
|
391
|
+
}
|
|
392
|
+
async getContentDraft(teamId, draftId) {
|
|
393
|
+
return this.fetchJson(`${this.teamBase(teamId)}/content-drafts/${draftId}`);
|
|
394
|
+
}
|
|
395
|
+
async updateContentDraft(teamId, draftId, body) {
|
|
396
|
+
return this.fetchJson(`${this.teamBase(teamId)}/content-drafts/${draftId}`, { method: "PATCH", body: JSON.stringify(body) });
|
|
397
|
+
}
|
|
398
|
+
async deleteContentDraft(teamId, draftId) {
|
|
399
|
+
await this.fetchJson(`${this.teamBase(teamId)}/content-drafts/${draftId}`, { method: "DELETE", parseJson: false });
|
|
400
|
+
}
|
|
401
|
+
async cancelPublishingPlan(teamId, planId) {
|
|
402
|
+
await this.fetchJson(`${this.teamBase(teamId)}/publishing-plans/${planId}`, { method: "DELETE", parseJson: false });
|
|
403
|
+
}
|
|
404
|
+
// ── Group B: agent-teams management ──────────────────────────────────────
|
|
405
|
+
async listAgentTeams() {
|
|
406
|
+
return this.fetchJson(`/v1/agent-teams`);
|
|
407
|
+
}
|
|
408
|
+
async listWorkspaceDocuments(teamId, params = {}) {
|
|
409
|
+
const q = buildQuery({ kind: params.kind, limit: params.limit });
|
|
410
|
+
return this.fetchJson(`/v1/agent-teams/${teamId}/workspace-documents${q}`);
|
|
411
|
+
}
|
|
412
|
+
async createTeam(body) {
|
|
413
|
+
return this.fetchJson(`/v1/agent-teams`, {
|
|
414
|
+
method: "POST",
|
|
415
|
+
body: JSON.stringify(body),
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
async updateTeam(teamId, body) {
|
|
419
|
+
return this.fetchJson(`/v1/agent-teams/${teamId}`, {
|
|
420
|
+
method: "PATCH",
|
|
421
|
+
body: JSON.stringify(body),
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
async addTeamMember(teamId, body) {
|
|
425
|
+
return this.fetchJson(`/v1/agent-teams/${teamId}/members`, {
|
|
426
|
+
method: "POST",
|
|
427
|
+
body: JSON.stringify(body),
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
// ── Group B: subreddit intelligence ──────────────────────────────────────
|
|
431
|
+
async listSubredditWatchlists(teamId, params = {}) {
|
|
432
|
+
const q = buildQuery({
|
|
433
|
+
limit: params.limit,
|
|
434
|
+
offset: params.offset,
|
|
435
|
+
campaignId: params.campaignId,
|
|
436
|
+
});
|
|
437
|
+
return this.fetchJson(`${this.teamBase(teamId)}/subreddit-intelligence/watchlists${q}`);
|
|
438
|
+
}
|
|
439
|
+
async createSubredditWatchlist(teamId, body) {
|
|
440
|
+
return this.fetchJson(`${this.teamBase(teamId)}/subreddit-intelligence/watchlists`, { method: "POST", body: JSON.stringify(body) });
|
|
441
|
+
}
|
|
442
|
+
async updateSubredditWatchlist(teamId, watchlistId, body) {
|
|
443
|
+
return this.fetchJson(`${this.teamBase(teamId)}/subreddit-intelligence/watchlists/${watchlistId}`, { method: "PATCH", body: JSON.stringify(body) });
|
|
444
|
+
}
|
|
445
|
+
async deleteSubredditWatchlist(teamId, watchlistId) {
|
|
446
|
+
await this.fetchJson(`${this.teamBase(teamId)}/subreddit-intelligence/watchlists/${watchlistId}`, { method: "DELETE", parseJson: false });
|
|
447
|
+
}
|
|
448
|
+
async listHotPosts(teamId, params = {}) {
|
|
449
|
+
const q = buildQuery({
|
|
450
|
+
limit: params.limit,
|
|
451
|
+
offset: params.offset,
|
|
452
|
+
subreddit: params.subreddit,
|
|
453
|
+
sortBy: params.sortBy,
|
|
454
|
+
});
|
|
455
|
+
return this.fetchJson(`${this.teamBase(teamId)}/subreddit-intelligence/hot-posts${q}`);
|
|
456
|
+
}
|
|
457
|
+
async createHotPost(teamId, body) {
|
|
458
|
+
return this.fetchJson(`${this.teamBase(teamId)}/subreddit-intelligence/hot-posts`, { method: "POST", body: JSON.stringify(body) });
|
|
459
|
+
}
|
|
460
|
+
async exportHotPostsCsv(teamId, params = {}) {
|
|
461
|
+
const q = buildQuery({
|
|
462
|
+
limit: params.limit ?? 500,
|
|
463
|
+
subreddit: params.subreddit,
|
|
464
|
+
sortBy: params.sortBy,
|
|
465
|
+
});
|
|
466
|
+
const url = `${this.teamBase(teamId)}/subreddit-intelligence/hot-posts/export.csv${q}`;
|
|
467
|
+
const res = await fetch(url, {
|
|
468
|
+
headers: { Authorization: `Bearer ${this.opts.apiKey}` },
|
|
469
|
+
});
|
|
470
|
+
if (!res.ok)
|
|
471
|
+
throw new Error(`HTTP ${res.status}`);
|
|
472
|
+
return res.text();
|
|
473
|
+
}
|
|
474
|
+
async listKolIntents(teamId, params = {}) {
|
|
475
|
+
const q = buildQuery({
|
|
476
|
+
limit: params.limit,
|
|
477
|
+
offset: params.offset,
|
|
478
|
+
campaignId: params.campaignId,
|
|
479
|
+
status: params.status,
|
|
480
|
+
sortBy: params.sortBy,
|
|
481
|
+
sortOrder: params.sortOrder,
|
|
482
|
+
});
|
|
483
|
+
return this.fetchJson(`${this.teamBase(teamId)}/subreddit-intelligence/kol-intents${q}`);
|
|
484
|
+
}
|
|
485
|
+
async createKolIntent(teamId, body) {
|
|
486
|
+
return this.fetchJson(`${this.teamBase(teamId)}/subreddit-intelligence/kol-intents`, { method: "POST", body: JSON.stringify(body) });
|
|
487
|
+
}
|
|
488
|
+
async dispatchTaskFromHotPost(teamId, body) {
|
|
489
|
+
return this.fetchJson(`${this.teamBase(teamId)}/subreddit-intelligence/hot-posts/dispatch-task`, { method: "POST", body: JSON.stringify(body) });
|
|
490
|
+
}
|
|
491
|
+
// ── Group B: users & brand members ───────────────────────────────────────
|
|
492
|
+
async listUsers(teamId) {
|
|
493
|
+
return this.fetchJson(`${this.teamBase(teamId)}/users`);
|
|
494
|
+
}
|
|
495
|
+
async createUser(teamId, body) {
|
|
496
|
+
return this.fetchJson(`${this.teamBase(teamId)}/users`, {
|
|
497
|
+
method: "POST",
|
|
498
|
+
body: JSON.stringify(body),
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
async listBrandMembers(teamId, params = {}) {
|
|
502
|
+
const q = buildQuery({ userId: params.userId });
|
|
503
|
+
return this.fetchJson(`${this.teamBase(teamId)}/brand-members${q}`);
|
|
504
|
+
}
|
|
505
|
+
async createBrandMember(teamId, body) {
|
|
506
|
+
return this.fetchJson(`${this.teamBase(teamId)}/brand-members`, {
|
|
507
|
+
method: "POST",
|
|
508
|
+
body: JSON.stringify(body),
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
// ── Group B: notification channels ───────────────────────────────────────
|
|
512
|
+
async listNotificationChannels(teamId, params = {}) {
|
|
513
|
+
const q = buildQuery({ campaignId: params.campaignId });
|
|
514
|
+
return this.fetchJson(`${this.teamBase(teamId)}/notification-channels${q}`);
|
|
515
|
+
}
|
|
516
|
+
async createNotificationChannel(teamId, body) {
|
|
517
|
+
return this.fetchJson(`${this.teamBase(teamId)}/notification-channels`, { method: "POST", body: JSON.stringify(body) });
|
|
518
|
+
}
|
|
519
|
+
async updateNotificationChannel(teamId, channelId, body) {
|
|
520
|
+
return this.fetchJson(`${this.teamBase(teamId)}/notification-channels/${channelId}`, { method: "PATCH", body: JSON.stringify(body) });
|
|
521
|
+
}
|
|
522
|
+
async deleteNotificationChannel(teamId, channelId) {
|
|
523
|
+
await this.fetchJson(`${this.teamBase(teamId)}/notification-channels/${channelId}`, { method: "DELETE", parseJson: false });
|
|
524
|
+
}
|
|
525
|
+
async testNotificationChannel(teamId, channelId) {
|
|
526
|
+
return this.fetchJson(`${this.teamBase(teamId)}/notification-channels/${channelId}/test`, { method: "POST", body: JSON.stringify({}) });
|
|
527
|
+
}
|
|
528
|
+
// ── Group B: API keys ─────────────────────────────────────────────────────
|
|
529
|
+
async listApiKeys(teamId, params = {}) {
|
|
530
|
+
const q = buildQuery({ limit: params.limit });
|
|
531
|
+
return this.fetchJson(`${this.teamBase(teamId)}/api-keys${q}`);
|
|
532
|
+
}
|
|
533
|
+
async createApiKey(teamId, body) {
|
|
534
|
+
return this.fetchJson(`${this.teamBase(teamId)}/api-keys`, {
|
|
535
|
+
method: "POST",
|
|
536
|
+
body: JSON.stringify(body),
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
async deleteApiKey(teamId, apiKeyId) {
|
|
540
|
+
await this.fetchJson(`${this.teamBase(teamId)}/api-keys/${apiKeyId}`, { method: "DELETE", parseJson: false });
|
|
541
|
+
}
|
|
542
|
+
async rotateApiKey(teamId, apiKeyId) {
|
|
543
|
+
return this.fetchJson(`${this.teamBase(teamId)}/api-keys/${apiKeyId}/rotate`, { method: "POST", body: JSON.stringify({}) });
|
|
544
|
+
}
|
|
545
|
+
async batchRevokeApiKeys(teamId, ids) {
|
|
546
|
+
return this.fetchJson(`${this.teamBase(teamId)}/api-keys/batch/revoke`, { method: "POST", body: JSON.stringify({ ids }) });
|
|
547
|
+
}
|
|
548
|
+
async batchRotateApiKeys(teamId, ids) {
|
|
549
|
+
return this.fetchJson(`${this.teamBase(teamId)}/api-keys/batch/rotate`, { method: "POST", body: JSON.stringify({ ids }) });
|
|
550
|
+
}
|
|
551
|
+
// ── Group C: scattered gaps ───────────────────────────────────────────────
|
|
552
|
+
async listEventsFiltered(teamId, params = {}) {
|
|
553
|
+
const q = buildQuery({
|
|
554
|
+
limit: params.limit,
|
|
555
|
+
type: params.type,
|
|
556
|
+
actor: params.actor,
|
|
557
|
+
result: params.result,
|
|
558
|
+
socialAccountId: params.socialAccountId,
|
|
559
|
+
createdFrom: params.createdFrom,
|
|
560
|
+
createdTo: params.createdTo,
|
|
561
|
+
});
|
|
562
|
+
return this.fetchJson(`${this.teamBase(teamId)}/events${q}`);
|
|
563
|
+
}
|
|
564
|
+
async exportEventsCsv(teamId, params = {}) {
|
|
565
|
+
const q = buildQuery({
|
|
566
|
+
limit: params.limit ?? 1000,
|
|
567
|
+
type: params.type,
|
|
568
|
+
actor: params.actor,
|
|
569
|
+
result: params.result,
|
|
570
|
+
socialAccountId: params.socialAccountId,
|
|
571
|
+
createdFrom: params.createdFrom,
|
|
572
|
+
createdTo: params.createdTo,
|
|
573
|
+
});
|
|
574
|
+
const url = `${this.teamBase(teamId)}/events/export.csv${q}`;
|
|
575
|
+
const res = await fetch(url, {
|
|
576
|
+
headers: { Authorization: `Bearer ${this.opts.apiKey}` },
|
|
577
|
+
});
|
|
578
|
+
if (!res.ok)
|
|
579
|
+
throw new Error(`HTTP ${res.status}`);
|
|
580
|
+
return res.text();
|
|
581
|
+
}
|
|
582
|
+
async createReport(teamId, body) {
|
|
583
|
+
return this.fetchJson(`${this.teamBase(teamId)}/reports`, {
|
|
584
|
+
method: "POST",
|
|
585
|
+
body: JSON.stringify(body),
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
async updateJobAgentStatus(teamId, jobId, body) {
|
|
589
|
+
return this.fetchJson(`${this.teamBase(teamId)}/scheduled-jobs/${jobId}/agent-status`, { method: "POST", body: JSON.stringify(body) });
|
|
590
|
+
}
|
|
591
|
+
async updatePermissionsMatrix(teamId, body) {
|
|
592
|
+
return this.fetchJson(`${this.teamBase(teamId)}/permissions-matrix`, {
|
|
593
|
+
method: "PATCH",
|
|
594
|
+
body: JSON.stringify(body),
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
async getAccountGraphDrilldown(teamId, params) {
|
|
598
|
+
const q = buildQuery({
|
|
599
|
+
socialAccountId: params.socialAccountId,
|
|
600
|
+
limit: params.limit,
|
|
601
|
+
});
|
|
602
|
+
return this.fetchJson(`${this.teamBase(teamId)}/account-graph/drilldown${q}`);
|
|
603
|
+
}
|
|
604
|
+
// --- Session methods (use baseUrl directly, no team scope) ---
|
|
605
|
+
async sessionLogin(body) {
|
|
606
|
+
return this.fetchJson(`${this.opts.baseUrl.replace(/\/$/, "")}/v1/session/login`, {
|
|
607
|
+
method: "POST",
|
|
608
|
+
body: JSON.stringify(body),
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
async sessionLogout() {
|
|
612
|
+
return this.fetchJson(`${this.opts.baseUrl.replace(/\/$/, "")}/v1/session/logout`, {
|
|
613
|
+
method: "POST",
|
|
614
|
+
body: JSON.stringify({}),
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
async sessionMe() {
|
|
618
|
+
return this.fetchJson(`${this.opts.baseUrl.replace(/\/$/, "")}/v1/session/me`);
|
|
619
|
+
}
|
|
620
|
+
async sessionActiveTeam(body) {
|
|
621
|
+
return this.fetchJson(`${this.opts.baseUrl.replace(/\/$/, "")}/v1/session/active-team`, {
|
|
622
|
+
method: "POST",
|
|
623
|
+
body: JSON.stringify(body),
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
async sessionSetPassword(body) {
|
|
627
|
+
return this.fetchJson(`${this.opts.baseUrl.replace(/\/$/, "")}/v1/session/set-password`, {
|
|
628
|
+
method: "POST",
|
|
629
|
+
body: JSON.stringify(body),
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
async sessionUpdateProfile(body) {
|
|
633
|
+
return this.fetchJson(`${this.opts.baseUrl.replace(/\/$/, "")}/v1/session/profile`, {
|
|
634
|
+
method: "PATCH",
|
|
635
|
+
body: JSON.stringify(body),
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
// --- Browser Environments ---
|
|
639
|
+
async listTeamBrowserEnvironments(teamId) {
|
|
640
|
+
return this.fetchJson(`${this.teamBase(teamId)}/browser-environments`);
|
|
641
|
+
}
|
|
642
|
+
async listAccountBrowserEnvironments(teamId, accountId) {
|
|
643
|
+
return this.fetchJson(`${this.teamBase(teamId)}/accounts/${accountId}/browser-environments`);
|
|
644
|
+
}
|
|
645
|
+
async createBrowserEnvironment(teamId, accountId, body) {
|
|
646
|
+
return this.fetchJson(`${this.teamBase(teamId)}/accounts/${accountId}/browser-environments`, {
|
|
647
|
+
method: "POST",
|
|
648
|
+
body: JSON.stringify(body),
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
// --- Account Personas ---
|
|
652
|
+
async listAccountPersonas(teamId, accountId) {
|
|
653
|
+
return this.fetchJson(`${this.teamBase(teamId)}/accounts/${accountId}/personas`);
|
|
654
|
+
}
|
|
655
|
+
async createAccountPersona(teamId, accountId, body) {
|
|
656
|
+
return this.fetchJson(`${this.teamBase(teamId)}/accounts/${accountId}/personas`, {
|
|
657
|
+
method: "POST",
|
|
658
|
+
body: JSON.stringify(body),
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
// --- Campaign Accounts ---
|
|
662
|
+
async listCampaignAccounts(teamId, campaignId) {
|
|
663
|
+
return this.fetchJson(`${this.teamBase(teamId)}/campaigns/${campaignId}/accounts`);
|
|
664
|
+
}
|
|
665
|
+
async assignCampaignAccount(teamId, campaignId, body) {
|
|
666
|
+
return this.fetchJson(`${this.teamBase(teamId)}/campaigns/${campaignId}/accounts`, {
|
|
667
|
+
method: "POST",
|
|
668
|
+
body: JSON.stringify(body),
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
async removeCampaignAccount(teamId, campaignId, socialAccountId) {
|
|
672
|
+
return this.fetchJson(`${this.teamBase(teamId)}/campaigns/${campaignId}/accounts/${socialAccountId}`, {
|
|
673
|
+
method: "DELETE",
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
// --- Brand Members ---
|
|
677
|
+
async deleteBrandMember(teamId, memberId) {
|
|
678
|
+
return this.fetchJson(`${this.teamBase(teamId)}/brand-members/${memberId}`, {
|
|
679
|
+
method: "DELETE",
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
async deleteAccount(teamId, accountId) {
|
|
683
|
+
return this.fetchJson(`${this.teamBase(teamId)}/accounts/${accountId}`, {
|
|
684
|
+
method: "DELETE",
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
async listAccountBrandBindings(teamId, accountId) {
|
|
688
|
+
return this.fetchJson(`${this.teamBase(teamId)}/accounts/${accountId}/brand-bindings`);
|
|
689
|
+
}
|
|
690
|
+
async addAccountBrandBinding(teamId, accountId, body) {
|
|
691
|
+
return this.fetchJson(`${this.teamBase(teamId)}/accounts/${accountId}/brand-bindings`, { method: "POST", body: JSON.stringify(body) });
|
|
692
|
+
}
|
|
693
|
+
async removeAccountBrandBinding(teamId, accountId, brandId) {
|
|
694
|
+
return this.fetchJson(`${this.teamBase(teamId)}/accounts/${accountId}/brand-bindings/${brandId}`, { method: "DELETE" });
|
|
695
|
+
}
|
|
696
|
+
async listAccountStatusSnapshots(teamId, accountId, limit = 20) {
|
|
697
|
+
return this.fetchJson(`${this.teamBase(teamId)}/accounts/${accountId}/status-snapshots?limit=${limit}`);
|
|
698
|
+
}
|
|
699
|
+
async getAuthContext() {
|
|
700
|
+
return this.fetchJson("/v1/auth/context");
|
|
701
|
+
}
|
|
702
|
+
async revokeCurrentCliToken() {
|
|
703
|
+
return this.fetchJson("/v1/auth/cli-token/revoke", { method: "POST" });
|
|
704
|
+
}
|
|
705
|
+
// --- Ops runtime (OpenClaw) ---
|
|
706
|
+
async opsClaimNext(teamId, body) {
|
|
707
|
+
return this.fetchJson(`${this.teamBase(teamId)}/ops/claim-next`, {
|
|
708
|
+
method: "POST",
|
|
709
|
+
body: JSON.stringify(body),
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
async opsClaim(teamId, body) {
|
|
713
|
+
return this.fetchJson(`${this.teamBase(teamId)}/ops/claim`, {
|
|
714
|
+
method: "POST",
|
|
715
|
+
body: JSON.stringify(body),
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
async opsHeartbeat(teamId, body) {
|
|
719
|
+
return this.fetchJson(`${this.teamBase(teamId)}/ops/heartbeat`, {
|
|
720
|
+
method: "POST",
|
|
721
|
+
body: JSON.stringify(body),
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
async opsComplete(teamId, body) {
|
|
725
|
+
return this.fetchJson(`${this.teamBase(teamId)}/ops/complete`, {
|
|
726
|
+
method: "POST",
|
|
727
|
+
body: JSON.stringify(body),
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
async opsFail(teamId, body) {
|
|
731
|
+
return this.fetchJson(`${this.teamBase(teamId)}/ops/fail`, {
|
|
732
|
+
method: "POST",
|
|
733
|
+
body: JSON.stringify(body),
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
async opsSkip(teamId, body) {
|
|
737
|
+
return this.fetchJson(`${this.teamBase(teamId)}/ops/skip`, {
|
|
738
|
+
method: "POST",
|
|
739
|
+
body: JSON.stringify(body),
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
// --- Agent context ---
|
|
743
|
+
async getAccountAgentContext(teamId, accountRef, params) {
|
|
744
|
+
const q = params?.expand
|
|
745
|
+
? `?expand=${encodeURIComponent(params.expand)}`
|
|
746
|
+
: "";
|
|
747
|
+
return this.fetchJson(`${this.teamBase(teamId)}/accounts/${encodeURIComponent(accountRef)}/agent-context${q}`);
|
|
748
|
+
}
|
|
749
|
+
async getJobAgentContext(teamId, jobId) {
|
|
750
|
+
return this.fetchJson(`${this.teamBase(teamId)}/scheduled-jobs/${jobId}/agent-context`);
|
|
751
|
+
}
|
|
752
|
+
async listAccountPools(teamId, accountRef, params) {
|
|
753
|
+
const search = new URLSearchParams();
|
|
754
|
+
if (params?.status)
|
|
755
|
+
search.set("status", params.status);
|
|
756
|
+
if (params?.industry)
|
|
757
|
+
search.set("industry", params.industry);
|
|
758
|
+
if (params?.limit)
|
|
759
|
+
search.set("limit", String(params.limit));
|
|
760
|
+
const q = search.toString() ? `?${search}` : "";
|
|
761
|
+
return this.fetchJson(`${this.teamBase(teamId)}/accounts/${encodeURIComponent(accountRef)}/account-pools${q}`);
|
|
762
|
+
}
|
|
763
|
+
async listSubredditCandidates(teamId, accountRef, params) {
|
|
764
|
+
const search = new URLSearchParams();
|
|
765
|
+
if (params?.industry)
|
|
766
|
+
search.set("industry", params.industry);
|
|
767
|
+
if (params?.action)
|
|
768
|
+
search.set("action", params.action);
|
|
769
|
+
if (params?.limit)
|
|
770
|
+
search.set("limit", String(params.limit));
|
|
771
|
+
const q = search.toString() ? `?${search}` : "";
|
|
772
|
+
return this.fetchJson(`${this.teamBase(teamId)}/accounts/${encodeURIComponent(accountRef)}/subreddit-candidates${q}`);
|
|
773
|
+
}
|
|
774
|
+
// --- Admin: settings / invites / members ---
|
|
775
|
+
async listSettings() {
|
|
776
|
+
return this.fetchJson("/v1/settings");
|
|
777
|
+
}
|
|
778
|
+
async getSetting(key) {
|
|
779
|
+
return this.fetchJson(`/v1/settings/${encodeURIComponent(key)}`);
|
|
780
|
+
}
|
|
781
|
+
async upsertSetting(key, body) {
|
|
782
|
+
return this.fetchJson(`/v1/settings/${encodeURIComponent(key)}`, {
|
|
783
|
+
method: "PUT",
|
|
784
|
+
body: JSON.stringify(body),
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
async listTeamInvites(teamId) {
|
|
788
|
+
return this.fetchJson(`${this.teamBase(teamId)}/invites`);
|
|
789
|
+
}
|
|
790
|
+
async createTeamInvite(teamId, body) {
|
|
791
|
+
return this.fetchJson(`${this.teamBase(teamId)}/invites`, {
|
|
792
|
+
method: "POST",
|
|
793
|
+
body: JSON.stringify(body),
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
async revokeTeamInvite(teamId, inviteId) {
|
|
797
|
+
return this.fetchJson(`${this.teamBase(teamId)}/invites/${inviteId}`, {
|
|
798
|
+
method: "DELETE",
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
async listSystemMembers() {
|
|
802
|
+
return this.fetchJson("/v1/system/members");
|
|
803
|
+
}
|
|
804
|
+
async updateSystemMemberRole(userId, body) {
|
|
805
|
+
return this.fetchJson(`/v1/system/members/${userId}`, {
|
|
806
|
+
method: "PATCH",
|
|
807
|
+
body: JSON.stringify(body),
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
async listIndustryPools(teamId, params) {
|
|
811
|
+
const q = params?.limit ? `?limit=${params.limit}` : "";
|
|
812
|
+
return this.fetchJson(`${this.teamBase(teamId)}/subreddit-intelligence/industry-pools${q}`);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
//# sourceMappingURL=index.js.map
|