@openpeepshq/client 0.1.38 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/authenticated.js +2 -2
- package/dist/endpoints/admin.js +2 -2
- package/dist/endpoints/jams.js +1 -1
- package/dist/endpoints/posts.js +10 -2
- package/dist/endpoints/server.d.ts +1 -0
- package/dist/index.js +8 -11
- package/package.json +30 -9
- package/src/common/authenticated.ts +28 -0
- package/src/common/base.ts +11 -0
- package/src/endpoints/accounts.ts +52 -0
- package/src/endpoints/admin.ts +616 -0
- package/src/endpoints/analytics.ts +13 -0
- package/src/endpoints/auth.ts +43 -0
- package/src/endpoints/conversations.ts +28 -0
- package/src/endpoints/groups.ts +69 -0
- package/src/endpoints/helpers.ts +91 -0
- package/src/endpoints/i18n.ts +14 -0
- package/src/endpoints/jams.ts +126 -0
- package/src/endpoints/location.ts +10 -0
- package/src/endpoints/media.ts +56 -0
- package/src/endpoints/payments.ts +34 -0
- package/src/endpoints/plugins.ts +25 -0
- package/src/endpoints/posts.ts +377 -0
- package/src/endpoints/previewLink.ts +10 -0
- package/src/endpoints/profiles.ts +167 -0
- package/src/endpoints/reports.ts +32 -0
- package/src/endpoints/search.ts +34 -0
- package/src/endpoints/server.ts +38 -0
- package/src/endpoints/sso.ts +35 -0
- package/src/endpoints/streaming.ts +29 -0
- package/src/endpoints/types.ts +66 -0
- package/src/index.ts +88 -0
- package/src/types/index.ts +20 -0
- package/src/webhooks/index.ts +50 -0
|
@@ -0,0 +1,616 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AccessToken,
|
|
3
|
+
AdminGroup,
|
|
4
|
+
AdminProfileSummary,
|
|
5
|
+
ReportResolution,
|
|
6
|
+
ReportWithMeta,
|
|
7
|
+
RoleData,
|
|
8
|
+
} from '@openpeepshq/common';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
AdminServerStats,
|
|
12
|
+
AnalyticsBackfillInput,
|
|
13
|
+
AnalyticsBackfillResponse,
|
|
14
|
+
AnalyticsClicks,
|
|
15
|
+
AnalyticsDateQuery,
|
|
16
|
+
AnalyticsEngagement,
|
|
17
|
+
AnalyticsGrowth,
|
|
18
|
+
AnalyticsOverview,
|
|
19
|
+
AnalyticsReportSettings,
|
|
20
|
+
AnalyticsRetention,
|
|
21
|
+
} from '@openpeepshq/common';
|
|
22
|
+
|
|
23
|
+
import { Role } from '@openpeepshq/common';
|
|
24
|
+
|
|
25
|
+
import {
|
|
26
|
+
AccessTokenCreationData,
|
|
27
|
+
AdminEmailQueueStats,
|
|
28
|
+
AdminEmailQueueTestInput,
|
|
29
|
+
AdminEmailTestInput,
|
|
30
|
+
AdminJobDetail,
|
|
31
|
+
AdminPerformanceStats,
|
|
32
|
+
ConfigData,
|
|
33
|
+
ConfigDataWithDefaults,
|
|
34
|
+
ExplorerRowsResponse,
|
|
35
|
+
ExplorerSqlInput,
|
|
36
|
+
ExplorerSqlResponse,
|
|
37
|
+
ExplorerTablesResponse,
|
|
38
|
+
ExplorerUpdateRowInput,
|
|
39
|
+
ExplorerUpdateRowResponse,
|
|
40
|
+
InviteLinkData,
|
|
41
|
+
InviteLinkWithMeta,
|
|
42
|
+
LogRow,
|
|
43
|
+
ProfileWithMeta,
|
|
44
|
+
PublicAccessToken,
|
|
45
|
+
Resource,
|
|
46
|
+
SuccessResponse,
|
|
47
|
+
TokenResponse,
|
|
48
|
+
} from '@openpeepshq/common';
|
|
49
|
+
|
|
50
|
+
import { allpeepPayloadEndpoint } from './helpers';
|
|
51
|
+
|
|
52
|
+
import {
|
|
53
|
+
AccountData,
|
|
54
|
+
PublicAccount,
|
|
55
|
+
AdminPluginInfo,
|
|
56
|
+
PluginInstallSource,
|
|
57
|
+
} from '@openpeepshq/common';
|
|
58
|
+
import { FetchClient } from '@openpeepshq/fetch-client';
|
|
59
|
+
import { allpeepNoPayloadEndpoint } from './helpers';
|
|
60
|
+
import type {
|
|
61
|
+
OpenpeepsNoPayloadEndpoint,
|
|
62
|
+
OpenpeepsPayloadEndpoint,
|
|
63
|
+
} from '../types';
|
|
64
|
+
|
|
65
|
+
export type ExplorerRowsQuery = Record<string, string>;
|
|
66
|
+
|
|
67
|
+
type AdminI18nBundle = {
|
|
68
|
+
defaults: Resource;
|
|
69
|
+
merged: Resource;
|
|
70
|
+
overrides: Resource;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
type AnalyticsExport = {
|
|
74
|
+
filename: string;
|
|
75
|
+
contentType: string;
|
|
76
|
+
content: string;
|
|
77
|
+
encoding: 'utf8' | 'base64';
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// Explicit return type keeps `tsc` from serializing the expanded endpoint
|
|
81
|
+
// graph into `.d.ts` (TS7056 otherwise once PublicPost grows).
|
|
82
|
+
export type Admin = {
|
|
83
|
+
accounts: {
|
|
84
|
+
list: OpenpeepsNoPayloadEndpoint<PublicAccount[]>;
|
|
85
|
+
findById: OpenpeepsNoPayloadEndpoint<PublicAccount, { id: string }>;
|
|
86
|
+
update: OpenpeepsPayloadEndpoint<
|
|
87
|
+
PublicAccount,
|
|
88
|
+
Partial<AccountData>,
|
|
89
|
+
{ id: string }
|
|
90
|
+
>;
|
|
91
|
+
delete: OpenpeepsNoPayloadEndpoint<PublicAccount, { id: string }>;
|
|
92
|
+
};
|
|
93
|
+
backups: {
|
|
94
|
+
list: OpenpeepsNoPayloadEndpoint<string[]>;
|
|
95
|
+
create: OpenpeepsNoPayloadEndpoint<SuccessResponse>;
|
|
96
|
+
restore: OpenpeepsPayloadEndpoint<SuccessResponse, File>;
|
|
97
|
+
};
|
|
98
|
+
config: {
|
|
99
|
+
read: OpenpeepsNoPayloadEndpoint<
|
|
100
|
+
ConfigDataWithDefaults,
|
|
101
|
+
{ namespace: string; name: string }
|
|
102
|
+
>;
|
|
103
|
+
update: OpenpeepsPayloadEndpoint<
|
|
104
|
+
SuccessResponse,
|
|
105
|
+
Partial<ConfigData>,
|
|
106
|
+
{ namespace: string; name: string }
|
|
107
|
+
>;
|
|
108
|
+
};
|
|
109
|
+
configuration: {
|
|
110
|
+
email: {
|
|
111
|
+
sendTest: OpenpeepsPayloadEndpoint<SuccessResponse, AdminEmailTestInput>;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
diagnostics: {
|
|
115
|
+
email: {
|
|
116
|
+
queueStats: OpenpeepsNoPayloadEndpoint<AdminEmailQueueStats>;
|
|
117
|
+
queueTest: OpenpeepsPayloadEndpoint<
|
|
118
|
+
SuccessResponse,
|
|
119
|
+
AdminEmailQueueTestInput
|
|
120
|
+
>;
|
|
121
|
+
};
|
|
122
|
+
jobs: {
|
|
123
|
+
jobDetail: OpenpeepsNoPayloadEndpoint<
|
|
124
|
+
AdminJobDetail,
|
|
125
|
+
{ queue: string; jobId: string }
|
|
126
|
+
>;
|
|
127
|
+
};
|
|
128
|
+
performance: OpenpeepsNoPayloadEndpoint<AdminPerformanceStats>;
|
|
129
|
+
};
|
|
130
|
+
db: {
|
|
131
|
+
token: OpenpeepsNoPayloadEndpoint<TokenResponse>;
|
|
132
|
+
tables: OpenpeepsNoPayloadEndpoint<ExplorerTablesResponse>;
|
|
133
|
+
rows: OpenpeepsNoPayloadEndpoint<
|
|
134
|
+
ExplorerRowsResponse,
|
|
135
|
+
{ table: string },
|
|
136
|
+
ExplorerRowsQuery
|
|
137
|
+
>;
|
|
138
|
+
updateRow: OpenpeepsPayloadEndpoint<
|
|
139
|
+
ExplorerUpdateRowResponse,
|
|
140
|
+
ExplorerUpdateRowInput,
|
|
141
|
+
{ table: string }
|
|
142
|
+
>;
|
|
143
|
+
exportCsv: (table: string, query?: ExplorerRowsQuery) => Promise<string>;
|
|
144
|
+
runSql: OpenpeepsPayloadEndpoint<ExplorerSqlResponse, ExplorerSqlInput>;
|
|
145
|
+
};
|
|
146
|
+
i18n: {
|
|
147
|
+
read: OpenpeepsNoPayloadEndpoint<AdminI18nBundle>;
|
|
148
|
+
update: OpenpeepsPayloadEndpoint<SuccessResponse, Resource>;
|
|
149
|
+
};
|
|
150
|
+
invites: {
|
|
151
|
+
create: OpenpeepsPayloadEndpoint<InviteLinkWithMeta, InviteLinkData>;
|
|
152
|
+
list: OpenpeepsNoPayloadEndpoint<InviteLinkWithMeta[]>;
|
|
153
|
+
activate: OpenpeepsNoPayloadEndpoint<SuccessResponse, { id: string }>;
|
|
154
|
+
deactivate: OpenpeepsNoPayloadEndpoint<SuccessResponse, { id: string }>;
|
|
155
|
+
};
|
|
156
|
+
logs: {
|
|
157
|
+
list: OpenpeepsNoPayloadEndpoint<LogRow[], undefined, { date?: string }>;
|
|
158
|
+
};
|
|
159
|
+
posts: {
|
|
160
|
+
pinGlobally: OpenpeepsPayloadEndpoint<SuccessResponse, { postId: string }>;
|
|
161
|
+
announce: OpenpeepsNoPayloadEndpoint<SuccessResponse, { id: string }>;
|
|
162
|
+
};
|
|
163
|
+
profiles: {
|
|
164
|
+
list: OpenpeepsNoPayloadEndpoint<ProfileWithMeta[]>;
|
|
165
|
+
exportCsv: () => Promise<string>;
|
|
166
|
+
listByAccount: OpenpeepsNoPayloadEndpoint<
|
|
167
|
+
ProfileWithMeta[],
|
|
168
|
+
{ id: string }
|
|
169
|
+
>;
|
|
170
|
+
delete: OpenpeepsNoPayloadEndpoint<ProfileWithMeta, { id: string }>;
|
|
171
|
+
listRoles: OpenpeepsNoPayloadEndpoint<Role[], { id: string }>;
|
|
172
|
+
updateRoles: OpenpeepsPayloadEndpoint<
|
|
173
|
+
Role[],
|
|
174
|
+
{ roles: Role[] },
|
|
175
|
+
{ id: string }
|
|
176
|
+
>;
|
|
177
|
+
activitySummary: OpenpeepsNoPayloadEndpoint<
|
|
178
|
+
AdminProfileSummary,
|
|
179
|
+
{ id: string }
|
|
180
|
+
>;
|
|
181
|
+
};
|
|
182
|
+
roles: {
|
|
183
|
+
list: OpenpeepsNoPayloadEndpoint<Role[]>;
|
|
184
|
+
create: OpenpeepsPayloadEndpoint<Role, Omit<RoleData, 'default'>>;
|
|
185
|
+
update: OpenpeepsPayloadEndpoint<Role, RoleData, { roleId: string }>;
|
|
186
|
+
};
|
|
187
|
+
stats: {
|
|
188
|
+
general: OpenpeepsNoPayloadEndpoint<AdminServerStats>;
|
|
189
|
+
};
|
|
190
|
+
analytics: {
|
|
191
|
+
overview: OpenpeepsNoPayloadEndpoint<
|
|
192
|
+
AnalyticsOverview,
|
|
193
|
+
undefined,
|
|
194
|
+
AnalyticsDateQuery
|
|
195
|
+
>;
|
|
196
|
+
growth: OpenpeepsNoPayloadEndpoint<
|
|
197
|
+
AnalyticsGrowth,
|
|
198
|
+
undefined,
|
|
199
|
+
AnalyticsDateQuery
|
|
200
|
+
>;
|
|
201
|
+
engagement: OpenpeepsNoPayloadEndpoint<
|
|
202
|
+
AnalyticsEngagement,
|
|
203
|
+
undefined,
|
|
204
|
+
AnalyticsDateQuery
|
|
205
|
+
>;
|
|
206
|
+
retention: OpenpeepsNoPayloadEndpoint<
|
|
207
|
+
AnalyticsRetention,
|
|
208
|
+
undefined,
|
|
209
|
+
AnalyticsDateQuery
|
|
210
|
+
>;
|
|
211
|
+
clicks: OpenpeepsNoPayloadEndpoint<
|
|
212
|
+
AnalyticsClicks,
|
|
213
|
+
undefined,
|
|
214
|
+
AnalyticsDateQuery
|
|
215
|
+
>;
|
|
216
|
+
reportSettings: {
|
|
217
|
+
read: OpenpeepsNoPayloadEndpoint<AnalyticsReportSettings>;
|
|
218
|
+
update: OpenpeepsPayloadEndpoint<
|
|
219
|
+
AnalyticsReportSettings,
|
|
220
|
+
AnalyticsReportSettings
|
|
221
|
+
>;
|
|
222
|
+
};
|
|
223
|
+
export: OpenpeepsNoPayloadEndpoint<
|
|
224
|
+
AnalyticsExport,
|
|
225
|
+
undefined,
|
|
226
|
+
AnalyticsDateQuery & { format?: 'csv' | 'pdf' }
|
|
227
|
+
>;
|
|
228
|
+
backfill: OpenpeepsPayloadEndpoint<
|
|
229
|
+
AnalyticsBackfillResponse,
|
|
230
|
+
AnalyticsBackfillInput
|
|
231
|
+
>;
|
|
232
|
+
};
|
|
233
|
+
reports: {
|
|
234
|
+
list: OpenpeepsNoPayloadEndpoint<ReportWithMeta[]>;
|
|
235
|
+
findById: OpenpeepsNoPayloadEndpoint<ReportWithMeta, { reportId: string }>;
|
|
236
|
+
resolve: OpenpeepsPayloadEndpoint<
|
|
237
|
+
SuccessResponse,
|
|
238
|
+
{ resolution: ReportResolution },
|
|
239
|
+
{ reportId: string }
|
|
240
|
+
>;
|
|
241
|
+
reopen: OpenpeepsNoPayloadEndpoint<SuccessResponse, { reportId: string }>;
|
|
242
|
+
};
|
|
243
|
+
groups: {
|
|
244
|
+
list: OpenpeepsNoPayloadEndpoint<AdminGroup[]>;
|
|
245
|
+
delete: OpenpeepsNoPayloadEndpoint<SuccessResponse, { groupId: string }>;
|
|
246
|
+
};
|
|
247
|
+
serviceAccessTokens: {
|
|
248
|
+
list: OpenpeepsNoPayloadEndpoint<PublicAccessToken[]>;
|
|
249
|
+
create: OpenpeepsPayloadEndpoint<AccessToken, AccessTokenCreationData>;
|
|
250
|
+
revoke: OpenpeepsNoPayloadEndpoint<
|
|
251
|
+
SuccessResponse,
|
|
252
|
+
{ accessTokenId: string }
|
|
253
|
+
>;
|
|
254
|
+
};
|
|
255
|
+
plugins: {
|
|
256
|
+
list: OpenpeepsNoPayloadEndpoint<AdminPluginInfo[]>;
|
|
257
|
+
install: OpenpeepsPayloadEndpoint<
|
|
258
|
+
SuccessResponse & { pluginKey?: string },
|
|
259
|
+
PluginInstallSource
|
|
260
|
+
>;
|
|
261
|
+
uninstall: OpenpeepsNoPayloadEndpoint<
|
|
262
|
+
SuccessResponse,
|
|
263
|
+
{ namespace: string; name: string }
|
|
264
|
+
>;
|
|
265
|
+
update: OpenpeepsPayloadEndpoint<
|
|
266
|
+
SuccessResponse,
|
|
267
|
+
{ enabled: boolean },
|
|
268
|
+
{ namespace: string; name: string }
|
|
269
|
+
>;
|
|
270
|
+
reload: OpenpeepsNoPayloadEndpoint<SuccessResponse>;
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
export const admin = (rawClient: FetchClient): Admin => ({
|
|
275
|
+
accounts: {
|
|
276
|
+
list: allpeepNoPayloadEndpoint<PublicAccount[]>(
|
|
277
|
+
rawClient,
|
|
278
|
+
'/admin/accounts',
|
|
279
|
+
),
|
|
280
|
+
findById: allpeepNoPayloadEndpoint<PublicAccount, { id: string }>(
|
|
281
|
+
rawClient,
|
|
282
|
+
'/admin/accounts/:id',
|
|
283
|
+
),
|
|
284
|
+
update: allpeepPayloadEndpoint<
|
|
285
|
+
PublicAccount,
|
|
286
|
+
Partial<AccountData>,
|
|
287
|
+
{ id: string }
|
|
288
|
+
>(rawClient, '/admin/accounts/:id', 'patch'),
|
|
289
|
+
delete: allpeepNoPayloadEndpoint<PublicAccount, { id: string }>(
|
|
290
|
+
rawClient,
|
|
291
|
+
'/admin/accounts/:id',
|
|
292
|
+
'delete',
|
|
293
|
+
),
|
|
294
|
+
},
|
|
295
|
+
backups: {
|
|
296
|
+
list: allpeepNoPayloadEndpoint<string[]>(rawClient, '/admin/backups'),
|
|
297
|
+
create: allpeepNoPayloadEndpoint<SuccessResponse>(
|
|
298
|
+
rawClient,
|
|
299
|
+
'/admin/backups',
|
|
300
|
+
'post',
|
|
301
|
+
),
|
|
302
|
+
restore: allpeepPayloadEndpoint<SuccessResponse, File>(
|
|
303
|
+
rawClient,
|
|
304
|
+
'/admin/backups/restore',
|
|
305
|
+
'post',
|
|
306
|
+
),
|
|
307
|
+
},
|
|
308
|
+
config: {
|
|
309
|
+
read: allpeepNoPayloadEndpoint<
|
|
310
|
+
ConfigDataWithDefaults,
|
|
311
|
+
{ namespace: string; name: string }
|
|
312
|
+
>(rawClient, '/admin/config/:namespace/:name'),
|
|
313
|
+
update: allpeepPayloadEndpoint<
|
|
314
|
+
SuccessResponse,
|
|
315
|
+
Partial<ConfigData>,
|
|
316
|
+
{ namespace: string; name: string }
|
|
317
|
+
>(rawClient, '/admin/config/:namespace/:name', 'patch'),
|
|
318
|
+
},
|
|
319
|
+
configuration: {
|
|
320
|
+
email: {
|
|
321
|
+
sendTest: allpeepPayloadEndpoint<SuccessResponse, AdminEmailTestInput>(
|
|
322
|
+
rawClient,
|
|
323
|
+
'/admin/configuration/email/test',
|
|
324
|
+
'post',
|
|
325
|
+
),
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
diagnostics: {
|
|
329
|
+
email: {
|
|
330
|
+
queueStats: allpeepNoPayloadEndpoint<AdminEmailQueueStats>(
|
|
331
|
+
rawClient,
|
|
332
|
+
'/admin/diagnostics/email/queue-stats',
|
|
333
|
+
),
|
|
334
|
+
queueTest: allpeepPayloadEndpoint<
|
|
335
|
+
SuccessResponse,
|
|
336
|
+
AdminEmailQueueTestInput
|
|
337
|
+
>(rawClient, '/admin/diagnostics/email/test', 'post'),
|
|
338
|
+
},
|
|
339
|
+
jobs: {
|
|
340
|
+
jobDetail: allpeepNoPayloadEndpoint<
|
|
341
|
+
AdminJobDetail,
|
|
342
|
+
{ queue: string; jobId: string }
|
|
343
|
+
>(rawClient, '/admin/diagnostics/jobs/:queue/:jobId'),
|
|
344
|
+
},
|
|
345
|
+
performance: allpeepNoPayloadEndpoint<AdminPerformanceStats>(
|
|
346
|
+
rawClient,
|
|
347
|
+
'/admin/diagnostics/performance',
|
|
348
|
+
),
|
|
349
|
+
},
|
|
350
|
+
db: {
|
|
351
|
+
token: allpeepNoPayloadEndpoint<TokenResponse>(
|
|
352
|
+
rawClient,
|
|
353
|
+
'/admin/db/token',
|
|
354
|
+
),
|
|
355
|
+
tables: allpeepNoPayloadEndpoint<ExplorerTablesResponse>(
|
|
356
|
+
rawClient,
|
|
357
|
+
'/admin/db/tables',
|
|
358
|
+
),
|
|
359
|
+
rows: allpeepNoPayloadEndpoint<
|
|
360
|
+
ExplorerRowsResponse,
|
|
361
|
+
{ table: string },
|
|
362
|
+
ExplorerRowsQuery
|
|
363
|
+
>(rawClient, '/admin/db/tables/:table/rows'),
|
|
364
|
+
updateRow: allpeepPayloadEndpoint<
|
|
365
|
+
ExplorerUpdateRowResponse,
|
|
366
|
+
ExplorerUpdateRowInput,
|
|
367
|
+
{ table: string }
|
|
368
|
+
>(rawClient, '/admin/db/tables/:table/rows', 'put'),
|
|
369
|
+
exportCsv: async (table: string, query?: ExplorerRowsQuery) => {
|
|
370
|
+
const params = new URLSearchParams();
|
|
371
|
+
if (query) {
|
|
372
|
+
for (const [key, value] of Object.entries(query)) {
|
|
373
|
+
if (value != null && value !== '') {
|
|
374
|
+
params.set(key, String(value));
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
const qs = params.toString();
|
|
379
|
+
const path = `/admin/db/tables/${encodeURIComponent(table)}/export${qs ? `?${qs}` : ''}`;
|
|
380
|
+
const response = await rawClient.get(path);
|
|
381
|
+
if (!response.ok) {
|
|
382
|
+
throw { ...(await response.json()), status: response.status };
|
|
383
|
+
}
|
|
384
|
+
return response.text();
|
|
385
|
+
},
|
|
386
|
+
runSql: allpeepPayloadEndpoint<ExplorerSqlResponse, ExplorerSqlInput>(
|
|
387
|
+
rawClient,
|
|
388
|
+
'/admin/db/sql',
|
|
389
|
+
'post',
|
|
390
|
+
),
|
|
391
|
+
},
|
|
392
|
+
i18n: {
|
|
393
|
+
read: allpeepNoPayloadEndpoint<{
|
|
394
|
+
defaults: Resource;
|
|
395
|
+
merged: Resource;
|
|
396
|
+
overrides: Resource;
|
|
397
|
+
}>(rawClient, '/admin/i18n'),
|
|
398
|
+
update: allpeepPayloadEndpoint<SuccessResponse, Resource>(
|
|
399
|
+
rawClient,
|
|
400
|
+
'/admin/i18n/overrides',
|
|
401
|
+
'put',
|
|
402
|
+
),
|
|
403
|
+
},
|
|
404
|
+
invites: {
|
|
405
|
+
create: allpeepPayloadEndpoint<InviteLinkWithMeta, InviteLinkData>(
|
|
406
|
+
rawClient,
|
|
407
|
+
'/invite-links',
|
|
408
|
+
),
|
|
409
|
+
list: allpeepNoPayloadEndpoint<InviteLinkWithMeta[]>(
|
|
410
|
+
rawClient,
|
|
411
|
+
'/invite-links',
|
|
412
|
+
),
|
|
413
|
+
activate: allpeepNoPayloadEndpoint<SuccessResponse, { id: string }>(
|
|
414
|
+
rawClient,
|
|
415
|
+
'/invite-links/:id/activate',
|
|
416
|
+
'put',
|
|
417
|
+
),
|
|
418
|
+
deactivate: allpeepNoPayloadEndpoint<SuccessResponse, { id: string }>(
|
|
419
|
+
rawClient,
|
|
420
|
+
'/invite-links/:id/deactivate',
|
|
421
|
+
'put',
|
|
422
|
+
),
|
|
423
|
+
},
|
|
424
|
+
logs: {
|
|
425
|
+
list: allpeepNoPayloadEndpoint<LogRow[], undefined, { date?: string }>(
|
|
426
|
+
rawClient,
|
|
427
|
+
'/admin/logs',
|
|
428
|
+
),
|
|
429
|
+
},
|
|
430
|
+
posts: {
|
|
431
|
+
pinGlobally: allpeepPayloadEndpoint<SuccessResponse, { postId: string }>(
|
|
432
|
+
rawClient,
|
|
433
|
+
'/admin/pinned-post',
|
|
434
|
+
'patch',
|
|
435
|
+
),
|
|
436
|
+
announce: allpeepNoPayloadEndpoint<SuccessResponse, { id: string }>(
|
|
437
|
+
rawClient,
|
|
438
|
+
'/admin/posts/:id/announce',
|
|
439
|
+
'post',
|
|
440
|
+
),
|
|
441
|
+
},
|
|
442
|
+
profiles: {
|
|
443
|
+
list: allpeepNoPayloadEndpoint<ProfileWithMeta[]>(
|
|
444
|
+
rawClient,
|
|
445
|
+
'/admin/profiles',
|
|
446
|
+
),
|
|
447
|
+
exportCsv: async () => {
|
|
448
|
+
const response = await rawClient.get('/admin/profiles/export');
|
|
449
|
+
|
|
450
|
+
if (!response.ok) {
|
|
451
|
+
throw { ...(await response.json()), status: response.status };
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
return response.text();
|
|
455
|
+
},
|
|
456
|
+
listByAccount: allpeepNoPayloadEndpoint<ProfileWithMeta[], { id: string }>(
|
|
457
|
+
rawClient,
|
|
458
|
+
'/admin/profiles/by-account/:id',
|
|
459
|
+
),
|
|
460
|
+
delete: allpeepNoPayloadEndpoint<ProfileWithMeta, { id: string }>(
|
|
461
|
+
rawClient,
|
|
462
|
+
'/admin/profiles/:id',
|
|
463
|
+
'delete',
|
|
464
|
+
),
|
|
465
|
+
listRoles: allpeepNoPayloadEndpoint<Role[], { id: string }>(
|
|
466
|
+
rawClient,
|
|
467
|
+
'/admin/profiles/:id/roles',
|
|
468
|
+
),
|
|
469
|
+
updateRoles: allpeepPayloadEndpoint<
|
|
470
|
+
Role[],
|
|
471
|
+
{ roles: Role[] },
|
|
472
|
+
{ id: string }
|
|
473
|
+
>(rawClient, '/admin/profiles/:id/roles', 'put'),
|
|
474
|
+
activitySummary: allpeepNoPayloadEndpoint<
|
|
475
|
+
AdminProfileSummary,
|
|
476
|
+
{ id: string }
|
|
477
|
+
>(rawClient, '/admin/profiles/:id/activity-summary'),
|
|
478
|
+
},
|
|
479
|
+
roles: {
|
|
480
|
+
list: allpeepNoPayloadEndpoint<Role[]>(rawClient, '/admin/roles'),
|
|
481
|
+
create: allpeepPayloadEndpoint<Role, Omit<RoleData, 'default'>>(
|
|
482
|
+
rawClient,
|
|
483
|
+
'/admin/roles',
|
|
484
|
+
'post',
|
|
485
|
+
),
|
|
486
|
+
update: allpeepPayloadEndpoint<Role, RoleData, { roleId: string }>(
|
|
487
|
+
rawClient,
|
|
488
|
+
'/admin/roles/:roleId',
|
|
489
|
+
'put',
|
|
490
|
+
),
|
|
491
|
+
},
|
|
492
|
+
stats: {
|
|
493
|
+
general: allpeepNoPayloadEndpoint<AdminServerStats>(
|
|
494
|
+
rawClient,
|
|
495
|
+
'/admin/stats',
|
|
496
|
+
),
|
|
497
|
+
},
|
|
498
|
+
analytics: {
|
|
499
|
+
overview: allpeepNoPayloadEndpoint<
|
|
500
|
+
AnalyticsOverview,
|
|
501
|
+
undefined,
|
|
502
|
+
AnalyticsDateQuery
|
|
503
|
+
>(rawClient, '/admin/analytics/overview'),
|
|
504
|
+
growth: allpeepNoPayloadEndpoint<
|
|
505
|
+
AnalyticsGrowth,
|
|
506
|
+
undefined,
|
|
507
|
+
AnalyticsDateQuery
|
|
508
|
+
>(rawClient, '/admin/analytics/growth'),
|
|
509
|
+
engagement: allpeepNoPayloadEndpoint<
|
|
510
|
+
AnalyticsEngagement,
|
|
511
|
+
undefined,
|
|
512
|
+
AnalyticsDateQuery
|
|
513
|
+
>(rawClient, '/admin/analytics/engagement'),
|
|
514
|
+
retention: allpeepNoPayloadEndpoint<
|
|
515
|
+
AnalyticsRetention,
|
|
516
|
+
undefined,
|
|
517
|
+
AnalyticsDateQuery
|
|
518
|
+
>(rawClient, '/admin/analytics/retention'),
|
|
519
|
+
clicks: allpeepNoPayloadEndpoint<
|
|
520
|
+
AnalyticsClicks,
|
|
521
|
+
undefined,
|
|
522
|
+
AnalyticsDateQuery
|
|
523
|
+
>(rawClient, '/admin/analytics/clicks'),
|
|
524
|
+
reportSettings: {
|
|
525
|
+
read: allpeepNoPayloadEndpoint<AnalyticsReportSettings>(
|
|
526
|
+
rawClient,
|
|
527
|
+
'/admin/analytics/report-settings',
|
|
528
|
+
),
|
|
529
|
+
update: allpeepPayloadEndpoint<
|
|
530
|
+
AnalyticsReportSettings,
|
|
531
|
+
AnalyticsReportSettings
|
|
532
|
+
>(rawClient, '/admin/analytics/report-settings', 'put'),
|
|
533
|
+
},
|
|
534
|
+
export: allpeepNoPayloadEndpoint<
|
|
535
|
+
{
|
|
536
|
+
filename: string;
|
|
537
|
+
contentType: string;
|
|
538
|
+
content: string;
|
|
539
|
+
encoding: 'utf8' | 'base64';
|
|
540
|
+
},
|
|
541
|
+
undefined,
|
|
542
|
+
AnalyticsDateQuery & { format?: 'csv' | 'pdf' }
|
|
543
|
+
>(rawClient, '/admin/analytics/export'),
|
|
544
|
+
backfill: allpeepPayloadEndpoint<
|
|
545
|
+
AnalyticsBackfillResponse,
|
|
546
|
+
AnalyticsBackfillInput
|
|
547
|
+
>(rawClient, '/admin/analytics/backfill', 'post'),
|
|
548
|
+
},
|
|
549
|
+
reports: {
|
|
550
|
+
list: allpeepNoPayloadEndpoint<ReportWithMeta[]>(
|
|
551
|
+
rawClient,
|
|
552
|
+
'/admin/reports',
|
|
553
|
+
),
|
|
554
|
+
findById: allpeepNoPayloadEndpoint<ReportWithMeta, { reportId: string }>(
|
|
555
|
+
rawClient,
|
|
556
|
+
'/admin/reports/:reportId',
|
|
557
|
+
),
|
|
558
|
+
resolve: allpeepPayloadEndpoint<
|
|
559
|
+
SuccessResponse,
|
|
560
|
+
{ resolution: ReportResolution },
|
|
561
|
+
{ reportId: string }
|
|
562
|
+
>(rawClient, '/admin/reports/:reportId/resolve', 'put'),
|
|
563
|
+
reopen: allpeepNoPayloadEndpoint<SuccessResponse, { reportId: string }>(
|
|
564
|
+
rawClient,
|
|
565
|
+
'/admin/reports/:reportId/reopen',
|
|
566
|
+
'put',
|
|
567
|
+
),
|
|
568
|
+
},
|
|
569
|
+
groups: {
|
|
570
|
+
list: allpeepNoPayloadEndpoint<AdminGroup[]>(rawClient, '/admin/groups'),
|
|
571
|
+
delete: allpeepNoPayloadEndpoint<SuccessResponse, { groupId: string }>(
|
|
572
|
+
rawClient,
|
|
573
|
+
'/admin/groups/:groupId',
|
|
574
|
+
'delete',
|
|
575
|
+
),
|
|
576
|
+
},
|
|
577
|
+
serviceAccessTokens: {
|
|
578
|
+
list: allpeepNoPayloadEndpoint<PublicAccessToken[]>(
|
|
579
|
+
rawClient,
|
|
580
|
+
'/admin/service-access-tokens',
|
|
581
|
+
),
|
|
582
|
+
create: allpeepPayloadEndpoint<AccessToken, AccessTokenCreationData>(
|
|
583
|
+
rawClient,
|
|
584
|
+
'/admin/service-access-tokens',
|
|
585
|
+
'post',
|
|
586
|
+
),
|
|
587
|
+
revoke: allpeepNoPayloadEndpoint<
|
|
588
|
+
SuccessResponse,
|
|
589
|
+
{ accessTokenId: string }
|
|
590
|
+
>(rawClient, '/admin/service-access-tokens/:accessTokenId', 'delete'),
|
|
591
|
+
},
|
|
592
|
+
plugins: {
|
|
593
|
+
list: allpeepNoPayloadEndpoint<AdminPluginInfo[]>(
|
|
594
|
+
rawClient,
|
|
595
|
+
'/admin/plugins',
|
|
596
|
+
),
|
|
597
|
+
install: allpeepPayloadEndpoint<
|
|
598
|
+
SuccessResponse & { pluginKey?: string },
|
|
599
|
+
PluginInstallSource
|
|
600
|
+
>(rawClient, '/admin/plugins/install', 'post'),
|
|
601
|
+
uninstall: allpeepNoPayloadEndpoint<
|
|
602
|
+
SuccessResponse,
|
|
603
|
+
{ namespace: string; name: string }
|
|
604
|
+
>(rawClient, '/admin/plugins/:namespace/:name', 'delete'),
|
|
605
|
+
update: allpeepPayloadEndpoint<
|
|
606
|
+
SuccessResponse,
|
|
607
|
+
{ enabled: boolean },
|
|
608
|
+
{ namespace: string; name: string }
|
|
609
|
+
>(rawClient, '/admin/plugins/:namespace/:name', 'patch'),
|
|
610
|
+
reload: allpeepNoPayloadEndpoint<SuccessResponse>(
|
|
611
|
+
rawClient,
|
|
612
|
+
'/admin/plugins/reload',
|
|
613
|
+
'post',
|
|
614
|
+
),
|
|
615
|
+
},
|
|
616
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FetchClient } from '@openpeepshq/fetch-client';
|
|
2
|
+
import type {
|
|
3
|
+
AnalyticsClicksIngest,
|
|
4
|
+
SuccessResponse,
|
|
5
|
+
} from '@openpeepshq/common';
|
|
6
|
+
import { allpeepPayloadEndpoint } from './helpers';
|
|
7
|
+
|
|
8
|
+
export const analytics = (rawClient: FetchClient) => ({
|
|
9
|
+
recordClicks: allpeepPayloadEndpoint<SuccessResponse, AnalyticsClicksIngest>(
|
|
10
|
+
rawClient,
|
|
11
|
+
'/analytics/clicks',
|
|
12
|
+
),
|
|
13
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { FetchClient } from '@openpeepshq/fetch-client';
|
|
2
|
+
import type {
|
|
3
|
+
GuestPassRequest,
|
|
4
|
+
LoginRequest,
|
|
5
|
+
RegisterRequest,
|
|
6
|
+
RequestResetPasswordRequest,
|
|
7
|
+
ResetPasswordRequest,
|
|
8
|
+
SuccessResponse,
|
|
9
|
+
TokenResponse,
|
|
10
|
+
} from '@openpeepshq/common';
|
|
11
|
+
import { allpeepNoPayloadEndpoint, allpeepPayloadEndpoint } from './helpers';
|
|
12
|
+
|
|
13
|
+
export const auth = (rawClient: FetchClient) => ({
|
|
14
|
+
login: allpeepPayloadEndpoint<TokenResponse, LoginRequest>(
|
|
15
|
+
rawClient,
|
|
16
|
+
'/auth/login',
|
|
17
|
+
),
|
|
18
|
+
register: allpeepPayloadEndpoint<TokenResponse, RegisterRequest>(
|
|
19
|
+
rawClient,
|
|
20
|
+
'/auth/register',
|
|
21
|
+
),
|
|
22
|
+
requestResetPassword: allpeepPayloadEndpoint<SuccessResponse, RequestResetPasswordRequest>(
|
|
23
|
+
rawClient,
|
|
24
|
+
'/auth/request-reset-password',
|
|
25
|
+
),
|
|
26
|
+
resetPassword: allpeepPayloadEndpoint<SuccessResponse, ResetPasswordRequest>(
|
|
27
|
+
rawClient,
|
|
28
|
+
'/auth/reset-password',
|
|
29
|
+
),
|
|
30
|
+
guestPass: allpeepPayloadEndpoint<TokenResponse, GuestPassRequest>(
|
|
31
|
+
rawClient,
|
|
32
|
+
'/auth/guest-pass',
|
|
33
|
+
),
|
|
34
|
+
refresh: allpeepPayloadEndpoint<TokenResponse, Record<string, never>>(
|
|
35
|
+
rawClient,
|
|
36
|
+
'/auth/refresh',
|
|
37
|
+
),
|
|
38
|
+
validateEmail: allpeepNoPayloadEndpoint<
|
|
39
|
+
SuccessResponse,
|
|
40
|
+
undefined,
|
|
41
|
+
{ token: string }
|
|
42
|
+
>(rawClient, '/auth/validate-email'),
|
|
43
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { FetchClient } from '@openpeepshq/fetch-client';
|
|
2
|
+
import type {
|
|
3
|
+
PublicPost,
|
|
4
|
+
PostCreationData,
|
|
5
|
+
SuccessResponse,
|
|
6
|
+
} from '@openpeepshq/common';
|
|
7
|
+
import { allpeepNoPayloadEndpoint, allpeepPayloadEndpoint } from './helpers';
|
|
8
|
+
|
|
9
|
+
export const conversations = (rawClient: FetchClient) => ({
|
|
10
|
+
list: allpeepNoPayloadEndpoint<PublicPost[][]>(rawClient, '/conversations'),
|
|
11
|
+
findById: allpeepNoPayloadEndpoint<PublicPost[], { id: string }>(
|
|
12
|
+
rawClient,
|
|
13
|
+
'/conversations/:id',
|
|
14
|
+
),
|
|
15
|
+
newPost: allpeepPayloadEndpoint<PublicPost, PostCreationData, { id: string }>(
|
|
16
|
+
rawClient,
|
|
17
|
+
'/conversations/:id/posts',
|
|
18
|
+
),
|
|
19
|
+
leave: allpeepNoPayloadEndpoint<SuccessResponse, { id: string }>(
|
|
20
|
+
rawClient,
|
|
21
|
+
'/conversations/:id/leave',
|
|
22
|
+
'delete',
|
|
23
|
+
),
|
|
24
|
+
archived: allpeepNoPayloadEndpoint<PublicPost[][]>(
|
|
25
|
+
rawClient,
|
|
26
|
+
'/conversations/archived',
|
|
27
|
+
),
|
|
28
|
+
});
|