@01.software/sdk 0.5.8 → 0.5.10
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/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/{const-Dde6Z3er.d.ts → const-Bk3-zigV.d.ts} +2 -2
- package/dist/{const-MzPYopC7.d.cts → const-DQZQAXex.d.cts} +2 -2
- package/dist/index.cjs +211 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +196 -7
- package/dist/index.d.ts +196 -7
- package/dist/index.js +211 -1
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-CyaSGIFI.d.cts → payload-types-DCVm1syH.d.cts} +400 -16
- package/dist/{payload-types-CyaSGIFI.d.ts → payload-types-DCVm1syH.d.ts} +400 -16
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/{webhook-cfGx5lXy.d.ts → webhook-BTtG_8f2.d.ts} +2 -2
- package/dist/{webhook-D78o4MiB.d.cts → webhook-TDfT7aKA.d.cts} +2 -2
- package/dist/webhook.d.cts +3 -3
- package/dist/webhook.d.ts +3 -3
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -458,6 +458,9 @@ async function httpFetch(url, options) {
|
|
|
458
458
|
}
|
|
459
459
|
throw error;
|
|
460
460
|
}
|
|
461
|
+
if (error instanceof SDKError) {
|
|
462
|
+
throw error;
|
|
463
|
+
}
|
|
461
464
|
const unknownError = createNetworkError(
|
|
462
465
|
error instanceof Error ? error.message : "An unknown network error occurred.",
|
|
463
466
|
void 0,
|
|
@@ -1178,9 +1181,204 @@ var COLLECTIONS = [
|
|
|
1178
1181
|
"live-streams",
|
|
1179
1182
|
"images",
|
|
1180
1183
|
"forms",
|
|
1181
|
-
"form-submissions"
|
|
1184
|
+
"form-submissions",
|
|
1185
|
+
// Community
|
|
1186
|
+
"threads",
|
|
1187
|
+
"comments",
|
|
1188
|
+
"reactions",
|
|
1189
|
+
"reaction-types",
|
|
1190
|
+
"bookmarks",
|
|
1191
|
+
"thread-categories",
|
|
1192
|
+
"reports",
|
|
1193
|
+
"community-bans"
|
|
1182
1194
|
];
|
|
1183
1195
|
|
|
1196
|
+
// src/core/community/community-client.ts
|
|
1197
|
+
var CommunityClient = class {
|
|
1198
|
+
constructor(options) {
|
|
1199
|
+
if (!options.clientKey) {
|
|
1200
|
+
throw createConfigError("clientKey is required for CommunityClient.");
|
|
1201
|
+
}
|
|
1202
|
+
this.clientKey = options.clientKey;
|
|
1203
|
+
this.secretKey = options.secretKey;
|
|
1204
|
+
this.customerToken = options.customerToken;
|
|
1205
|
+
this.baseUrl = options.baseUrl;
|
|
1206
|
+
this.onUnauthorized = options.onUnauthorized;
|
|
1207
|
+
}
|
|
1208
|
+
async execute(endpoint, method, body) {
|
|
1209
|
+
const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
|
|
1210
|
+
const response = await httpFetch(endpoint, {
|
|
1211
|
+
method,
|
|
1212
|
+
clientKey: this.clientKey,
|
|
1213
|
+
secretKey: this.secretKey,
|
|
1214
|
+
customerToken: token ?? void 0,
|
|
1215
|
+
baseUrl: this.baseUrl,
|
|
1216
|
+
...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
|
|
1217
|
+
...body !== void 0 && { body: JSON.stringify(body) }
|
|
1218
|
+
});
|
|
1219
|
+
return parseApiResponse(response, endpoint);
|
|
1220
|
+
}
|
|
1221
|
+
// Threads
|
|
1222
|
+
createThread(params) {
|
|
1223
|
+
return this.execute("/api/threads", "POST", params);
|
|
1224
|
+
}
|
|
1225
|
+
getMyThreads(params) {
|
|
1226
|
+
const query = params ? `?${new URLSearchParams(
|
|
1227
|
+
Object.fromEntries(
|
|
1228
|
+
Object.entries(params).map(([k, v]) => [k, String(v)])
|
|
1229
|
+
)
|
|
1230
|
+
).toString()}` : "";
|
|
1231
|
+
return this.execute(
|
|
1232
|
+
`/api/threads/my${query}`,
|
|
1233
|
+
"GET"
|
|
1234
|
+
);
|
|
1235
|
+
}
|
|
1236
|
+
getTrending(params) {
|
|
1237
|
+
const query = params ? `?${new URLSearchParams(
|
|
1238
|
+
Object.fromEntries(
|
|
1239
|
+
Object.entries(params).map(([k, v]) => [k, String(v)])
|
|
1240
|
+
)
|
|
1241
|
+
).toString()}` : "";
|
|
1242
|
+
return this.execute(
|
|
1243
|
+
`/api/threads/trending${query}`,
|
|
1244
|
+
"GET"
|
|
1245
|
+
);
|
|
1246
|
+
}
|
|
1247
|
+
incrementView(params) {
|
|
1248
|
+
return this.execute(
|
|
1249
|
+
`/api/threads/${params.threadId}/view`,
|
|
1250
|
+
"POST"
|
|
1251
|
+
);
|
|
1252
|
+
}
|
|
1253
|
+
reportThread(params) {
|
|
1254
|
+
const { threadId, ...body } = params;
|
|
1255
|
+
return this.execute(
|
|
1256
|
+
`/api/threads/${threadId}/report`,
|
|
1257
|
+
"POST",
|
|
1258
|
+
body
|
|
1259
|
+
);
|
|
1260
|
+
}
|
|
1261
|
+
// Comments
|
|
1262
|
+
createComment(params) {
|
|
1263
|
+
const { threadId, parentId, content } = params;
|
|
1264
|
+
const body = { thread: threadId, content };
|
|
1265
|
+
if (parentId !== void 0) {
|
|
1266
|
+
body.parent = parentId;
|
|
1267
|
+
}
|
|
1268
|
+
return this.execute("/api/comments", "POST", body);
|
|
1269
|
+
}
|
|
1270
|
+
listComments(params) {
|
|
1271
|
+
const { threadId, page, limit, rootId } = params;
|
|
1272
|
+
const urlParams = new URLSearchParams();
|
|
1273
|
+
urlParams.set("where[thread][equals]", threadId);
|
|
1274
|
+
urlParams.set("sort", "-createdAt");
|
|
1275
|
+
if (limit !== void 0) urlParams.set("limit", String(limit));
|
|
1276
|
+
if (page !== void 0) urlParams.set("page", String(page));
|
|
1277
|
+
if (rootId !== void 0) urlParams.set("where[rootId][equals]", rootId);
|
|
1278
|
+
return this.execute(
|
|
1279
|
+
`/api/comments?${urlParams.toString()}`,
|
|
1280
|
+
"GET"
|
|
1281
|
+
);
|
|
1282
|
+
}
|
|
1283
|
+
updateComment(params) {
|
|
1284
|
+
const { commentId, content } = params;
|
|
1285
|
+
return this.execute(
|
|
1286
|
+
`/api/comments/${commentId}`,
|
|
1287
|
+
"PATCH",
|
|
1288
|
+
{ content }
|
|
1289
|
+
);
|
|
1290
|
+
}
|
|
1291
|
+
deleteComment(params) {
|
|
1292
|
+
return this.execute(
|
|
1293
|
+
`/api/comments/${params.commentId}`,
|
|
1294
|
+
"DELETE"
|
|
1295
|
+
);
|
|
1296
|
+
}
|
|
1297
|
+
reportComment(params) {
|
|
1298
|
+
const { commentId, ...body } = params;
|
|
1299
|
+
return this.execute(
|
|
1300
|
+
`/api/comments/${commentId}/report`,
|
|
1301
|
+
"POST",
|
|
1302
|
+
body
|
|
1303
|
+
);
|
|
1304
|
+
}
|
|
1305
|
+
// Reactions
|
|
1306
|
+
addReaction(params) {
|
|
1307
|
+
const { threadId, type } = params;
|
|
1308
|
+
return this.execute("/api/reactions", "POST", {
|
|
1309
|
+
thread: threadId,
|
|
1310
|
+
type
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
removeReaction(params) {
|
|
1314
|
+
const { threadId, type } = params;
|
|
1315
|
+
return this.execute(
|
|
1316
|
+
`/api/threads/${threadId}/react?type=${encodeURIComponent(type)}`,
|
|
1317
|
+
"DELETE"
|
|
1318
|
+
);
|
|
1319
|
+
}
|
|
1320
|
+
addCommentReaction(params) {
|
|
1321
|
+
const { commentId, type } = params;
|
|
1322
|
+
return this.execute("/api/reactions", "POST", {
|
|
1323
|
+
comment: commentId,
|
|
1324
|
+
type
|
|
1325
|
+
});
|
|
1326
|
+
}
|
|
1327
|
+
removeCommentReaction(params) {
|
|
1328
|
+
const { commentId, type } = params;
|
|
1329
|
+
return this.execute(
|
|
1330
|
+
`/api/comments/${commentId}/react?type=${encodeURIComponent(type)}`,
|
|
1331
|
+
"DELETE"
|
|
1332
|
+
);
|
|
1333
|
+
}
|
|
1334
|
+
getReactionSummary(params) {
|
|
1335
|
+
return this.execute(
|
|
1336
|
+
`/api/threads/${params.threadId}/reactions`,
|
|
1337
|
+
"GET"
|
|
1338
|
+
);
|
|
1339
|
+
}
|
|
1340
|
+
getReactionTypes() {
|
|
1341
|
+
return this.execute(
|
|
1342
|
+
"/api/reaction-types?limit=100",
|
|
1343
|
+
"GET"
|
|
1344
|
+
);
|
|
1345
|
+
}
|
|
1346
|
+
// Bookmarks
|
|
1347
|
+
addBookmark(params) {
|
|
1348
|
+
return this.execute("/api/bookmarks", "POST", {
|
|
1349
|
+
thread: params.threadId
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
removeBookmark(params) {
|
|
1353
|
+
return this.execute(
|
|
1354
|
+
`/api/threads/${params.threadId}/bookmark`,
|
|
1355
|
+
"DELETE"
|
|
1356
|
+
);
|
|
1357
|
+
}
|
|
1358
|
+
getMyBookmarks(params) {
|
|
1359
|
+
const query = params ? `?${new URLSearchParams(
|
|
1360
|
+
Object.fromEntries(
|
|
1361
|
+
Object.entries(params).map(([k, v]) => [k, String(v)])
|
|
1362
|
+
)
|
|
1363
|
+
).toString()}` : "";
|
|
1364
|
+
return this.execute(
|
|
1365
|
+
`/api/bookmarks/my${query}`,
|
|
1366
|
+
"GET"
|
|
1367
|
+
);
|
|
1368
|
+
}
|
|
1369
|
+
// Moderation
|
|
1370
|
+
banCustomer(params) {
|
|
1371
|
+
return this.execute("/api/community-bans/ban", "POST", params);
|
|
1372
|
+
}
|
|
1373
|
+
unbanCustomer(params) {
|
|
1374
|
+
return this.execute(
|
|
1375
|
+
"/api/community-bans/unban",
|
|
1376
|
+
"DELETE",
|
|
1377
|
+
params
|
|
1378
|
+
);
|
|
1379
|
+
}
|
|
1380
|
+
};
|
|
1381
|
+
|
|
1184
1382
|
// src/core/customer/customer-auth.ts
|
|
1185
1383
|
var DEFAULT_TIMEOUT2 = 15e3;
|
|
1186
1384
|
function safeGetItem(key) {
|
|
@@ -1903,6 +2101,12 @@ var Client = class {
|
|
|
1903
2101
|
baseUrl: this.baseUrl,
|
|
1904
2102
|
onUnauthorized
|
|
1905
2103
|
});
|
|
2104
|
+
this.community = new CommunityClient({
|
|
2105
|
+
clientKey: this.config.clientKey,
|
|
2106
|
+
customerToken: () => this.customer.getToken(),
|
|
2107
|
+
baseUrl: this.baseUrl,
|
|
2108
|
+
onUnauthorized
|
|
2109
|
+
});
|
|
1906
2110
|
this.collections = new CollectionClient(
|
|
1907
2111
|
this.config.clientKey,
|
|
1908
2112
|
void 0,
|
|
@@ -1961,6 +2165,11 @@ var ServerClient = class {
|
|
|
1961
2165
|
secretKey: this.config.secretKey,
|
|
1962
2166
|
baseUrl: this.baseUrl
|
|
1963
2167
|
});
|
|
2168
|
+
this.community = new CommunityClient({
|
|
2169
|
+
clientKey: this.config.clientKey,
|
|
2170
|
+
secretKey: this.config.secretKey,
|
|
2171
|
+
baseUrl: this.baseUrl
|
|
2172
|
+
});
|
|
1964
2173
|
this.product = new ProductApi({
|
|
1965
2174
|
clientKey: this.config.clientKey,
|
|
1966
2175
|
secretKey: this.config.secretKey,
|
|
@@ -2326,6 +2535,7 @@ export {
|
|
|
2326
2535
|
CollectionClient,
|
|
2327
2536
|
CollectionHooks,
|
|
2328
2537
|
CollectionQueryBuilder,
|
|
2538
|
+
CommunityClient,
|
|
2329
2539
|
ConfigError,
|
|
2330
2540
|
CustomerAuth,
|
|
2331
2541
|
CustomerHooks,
|