@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/auth.d.cts
CHANGED
package/dist/auth.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Config } from './payload-types-
|
|
1
|
+
import { C as Config } from './payload-types-DCVm1syH.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Collection type derived from Payload Config.
|
|
@@ -9,7 +9,7 @@ type Collection = keyof Config['collections'];
|
|
|
9
9
|
* Array of all public collection names for runtime use (e.g., Zod enum validation).
|
|
10
10
|
* This is the single source of truth for which collections are publicly accessible via SDK.
|
|
11
11
|
*/
|
|
12
|
-
declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-products", "returns", "return-products", "exchanges", "exchange-products", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-addresses", "customer-groups", "carts", "cart-items", "discounts", "shipping-policies", "documents", "document-categories", "document-types", "posts", "post-authors", "post-categories", "post-tags", "playlists", "playlist-categories", "playlist-tags", "musics", "music-categories", "music-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "flows", "flow-node-types", "flow-edge-types", "flow-categories", "flow-tags", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions"];
|
|
12
|
+
declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-products", "returns", "return-products", "exchanges", "exchange-products", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-addresses", "customer-groups", "carts", "cart-items", "discounts", "shipping-policies", "documents", "document-categories", "document-types", "posts", "post-authors", "post-categories", "post-tags", "playlists", "playlist-categories", "playlist-tags", "musics", "music-categories", "music-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "flows", "flow-node-types", "flow-edge-types", "flow-categories", "flow-tags", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions", "threads", "comments", "reactions", "reaction-types", "bookmarks", "thread-categories", "reports", "community-bans"];
|
|
13
13
|
/**
|
|
14
14
|
* Public collections available for SDK access.
|
|
15
15
|
* Derived from the COLLECTIONS array (single source of truth).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Config } from './payload-types-
|
|
1
|
+
import { C as Config } from './payload-types-DCVm1syH.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Collection type derived from Payload Config.
|
|
@@ -9,7 +9,7 @@ type Collection = keyof Config['collections'];
|
|
|
9
9
|
* Array of all public collection names for runtime use (e.g., Zod enum validation).
|
|
10
10
|
* This is the single source of truth for which collections are publicly accessible via SDK.
|
|
11
11
|
*/
|
|
12
|
-
declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-products", "returns", "return-products", "exchanges", "exchange-products", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-addresses", "customer-groups", "carts", "cart-items", "discounts", "shipping-policies", "documents", "document-categories", "document-types", "posts", "post-authors", "post-categories", "post-tags", "playlists", "playlist-categories", "playlist-tags", "musics", "music-categories", "music-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "flows", "flow-node-types", "flow-edge-types", "flow-categories", "flow-tags", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions"];
|
|
12
|
+
declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-products", "returns", "return-products", "exchanges", "exchange-products", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-addresses", "customer-groups", "carts", "cart-items", "discounts", "shipping-policies", "documents", "document-categories", "document-types", "posts", "post-authors", "post-categories", "post-tags", "playlists", "playlist-categories", "playlist-tags", "musics", "music-categories", "music-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "flows", "flow-node-types", "flow-edge-types", "flow-categories", "flow-tags", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions", "threads", "comments", "reactions", "reaction-types", "bookmarks", "thread-categories", "reports", "community-bans"];
|
|
13
13
|
/**
|
|
14
14
|
* Public collections available for SDK access.
|
|
15
15
|
* Derived from the COLLECTIONS array (single source of truth).
|
package/dist/index.cjs
CHANGED
|
@@ -28,6 +28,7 @@ __export(src_exports, {
|
|
|
28
28
|
CollectionClient: () => CollectionClient,
|
|
29
29
|
CollectionHooks: () => CollectionHooks,
|
|
30
30
|
CollectionQueryBuilder: () => CollectionQueryBuilder,
|
|
31
|
+
CommunityClient: () => CommunityClient,
|
|
31
32
|
ConfigError: () => ConfigError,
|
|
32
33
|
CustomerAuth: () => CustomerAuth,
|
|
33
34
|
CustomerHooks: () => CustomerHooks,
|
|
@@ -542,6 +543,9 @@ async function httpFetch(url, options) {
|
|
|
542
543
|
}
|
|
543
544
|
throw error;
|
|
544
545
|
}
|
|
546
|
+
if (error instanceof SDKError) {
|
|
547
|
+
throw error;
|
|
548
|
+
}
|
|
545
549
|
const unknownError = createNetworkError(
|
|
546
550
|
error instanceof Error ? error.message : "An unknown network error occurred.",
|
|
547
551
|
void 0,
|
|
@@ -1262,9 +1266,204 @@ var COLLECTIONS = [
|
|
|
1262
1266
|
"live-streams",
|
|
1263
1267
|
"images",
|
|
1264
1268
|
"forms",
|
|
1265
|
-
"form-submissions"
|
|
1269
|
+
"form-submissions",
|
|
1270
|
+
// Community
|
|
1271
|
+
"threads",
|
|
1272
|
+
"comments",
|
|
1273
|
+
"reactions",
|
|
1274
|
+
"reaction-types",
|
|
1275
|
+
"bookmarks",
|
|
1276
|
+
"thread-categories",
|
|
1277
|
+
"reports",
|
|
1278
|
+
"community-bans"
|
|
1266
1279
|
];
|
|
1267
1280
|
|
|
1281
|
+
// src/core/community/community-client.ts
|
|
1282
|
+
var CommunityClient = class {
|
|
1283
|
+
constructor(options) {
|
|
1284
|
+
if (!options.clientKey) {
|
|
1285
|
+
throw createConfigError("clientKey is required for CommunityClient.");
|
|
1286
|
+
}
|
|
1287
|
+
this.clientKey = options.clientKey;
|
|
1288
|
+
this.secretKey = options.secretKey;
|
|
1289
|
+
this.customerToken = options.customerToken;
|
|
1290
|
+
this.baseUrl = options.baseUrl;
|
|
1291
|
+
this.onUnauthorized = options.onUnauthorized;
|
|
1292
|
+
}
|
|
1293
|
+
async execute(endpoint, method, body) {
|
|
1294
|
+
const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
|
|
1295
|
+
const response = await httpFetch(endpoint, {
|
|
1296
|
+
method,
|
|
1297
|
+
clientKey: this.clientKey,
|
|
1298
|
+
secretKey: this.secretKey,
|
|
1299
|
+
customerToken: token ?? void 0,
|
|
1300
|
+
baseUrl: this.baseUrl,
|
|
1301
|
+
...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
|
|
1302
|
+
...body !== void 0 && { body: JSON.stringify(body) }
|
|
1303
|
+
});
|
|
1304
|
+
return parseApiResponse(response, endpoint);
|
|
1305
|
+
}
|
|
1306
|
+
// Threads
|
|
1307
|
+
createThread(params) {
|
|
1308
|
+
return this.execute("/api/threads", "POST", params);
|
|
1309
|
+
}
|
|
1310
|
+
getMyThreads(params) {
|
|
1311
|
+
const query = params ? `?${new URLSearchParams(
|
|
1312
|
+
Object.fromEntries(
|
|
1313
|
+
Object.entries(params).map(([k, v]) => [k, String(v)])
|
|
1314
|
+
)
|
|
1315
|
+
).toString()}` : "";
|
|
1316
|
+
return this.execute(
|
|
1317
|
+
`/api/threads/my${query}`,
|
|
1318
|
+
"GET"
|
|
1319
|
+
);
|
|
1320
|
+
}
|
|
1321
|
+
getTrending(params) {
|
|
1322
|
+
const query = params ? `?${new URLSearchParams(
|
|
1323
|
+
Object.fromEntries(
|
|
1324
|
+
Object.entries(params).map(([k, v]) => [k, String(v)])
|
|
1325
|
+
)
|
|
1326
|
+
).toString()}` : "";
|
|
1327
|
+
return this.execute(
|
|
1328
|
+
`/api/threads/trending${query}`,
|
|
1329
|
+
"GET"
|
|
1330
|
+
);
|
|
1331
|
+
}
|
|
1332
|
+
incrementView(params) {
|
|
1333
|
+
return this.execute(
|
|
1334
|
+
`/api/threads/${params.threadId}/view`,
|
|
1335
|
+
"POST"
|
|
1336
|
+
);
|
|
1337
|
+
}
|
|
1338
|
+
reportThread(params) {
|
|
1339
|
+
const { threadId, ...body } = params;
|
|
1340
|
+
return this.execute(
|
|
1341
|
+
`/api/threads/${threadId}/report`,
|
|
1342
|
+
"POST",
|
|
1343
|
+
body
|
|
1344
|
+
);
|
|
1345
|
+
}
|
|
1346
|
+
// Comments
|
|
1347
|
+
createComment(params) {
|
|
1348
|
+
const { threadId, parentId, content } = params;
|
|
1349
|
+
const body = { thread: threadId, content };
|
|
1350
|
+
if (parentId !== void 0) {
|
|
1351
|
+
body.parent = parentId;
|
|
1352
|
+
}
|
|
1353
|
+
return this.execute("/api/comments", "POST", body);
|
|
1354
|
+
}
|
|
1355
|
+
listComments(params) {
|
|
1356
|
+
const { threadId, page, limit, rootId } = params;
|
|
1357
|
+
const urlParams = new URLSearchParams();
|
|
1358
|
+
urlParams.set("where[thread][equals]", threadId);
|
|
1359
|
+
urlParams.set("sort", "-createdAt");
|
|
1360
|
+
if (limit !== void 0) urlParams.set("limit", String(limit));
|
|
1361
|
+
if (page !== void 0) urlParams.set("page", String(page));
|
|
1362
|
+
if (rootId !== void 0) urlParams.set("where[rootId][equals]", rootId);
|
|
1363
|
+
return this.execute(
|
|
1364
|
+
`/api/comments?${urlParams.toString()}`,
|
|
1365
|
+
"GET"
|
|
1366
|
+
);
|
|
1367
|
+
}
|
|
1368
|
+
updateComment(params) {
|
|
1369
|
+
const { commentId, content } = params;
|
|
1370
|
+
return this.execute(
|
|
1371
|
+
`/api/comments/${commentId}`,
|
|
1372
|
+
"PATCH",
|
|
1373
|
+
{ content }
|
|
1374
|
+
);
|
|
1375
|
+
}
|
|
1376
|
+
deleteComment(params) {
|
|
1377
|
+
return this.execute(
|
|
1378
|
+
`/api/comments/${params.commentId}`,
|
|
1379
|
+
"DELETE"
|
|
1380
|
+
);
|
|
1381
|
+
}
|
|
1382
|
+
reportComment(params) {
|
|
1383
|
+
const { commentId, ...body } = params;
|
|
1384
|
+
return this.execute(
|
|
1385
|
+
`/api/comments/${commentId}/report`,
|
|
1386
|
+
"POST",
|
|
1387
|
+
body
|
|
1388
|
+
);
|
|
1389
|
+
}
|
|
1390
|
+
// Reactions
|
|
1391
|
+
addReaction(params) {
|
|
1392
|
+
const { threadId, type } = params;
|
|
1393
|
+
return this.execute("/api/reactions", "POST", {
|
|
1394
|
+
thread: threadId,
|
|
1395
|
+
type
|
|
1396
|
+
});
|
|
1397
|
+
}
|
|
1398
|
+
removeReaction(params) {
|
|
1399
|
+
const { threadId, type } = params;
|
|
1400
|
+
return this.execute(
|
|
1401
|
+
`/api/threads/${threadId}/react?type=${encodeURIComponent(type)}`,
|
|
1402
|
+
"DELETE"
|
|
1403
|
+
);
|
|
1404
|
+
}
|
|
1405
|
+
addCommentReaction(params) {
|
|
1406
|
+
const { commentId, type } = params;
|
|
1407
|
+
return this.execute("/api/reactions", "POST", {
|
|
1408
|
+
comment: commentId,
|
|
1409
|
+
type
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
removeCommentReaction(params) {
|
|
1413
|
+
const { commentId, type } = params;
|
|
1414
|
+
return this.execute(
|
|
1415
|
+
`/api/comments/${commentId}/react?type=${encodeURIComponent(type)}`,
|
|
1416
|
+
"DELETE"
|
|
1417
|
+
);
|
|
1418
|
+
}
|
|
1419
|
+
getReactionSummary(params) {
|
|
1420
|
+
return this.execute(
|
|
1421
|
+
`/api/threads/${params.threadId}/reactions`,
|
|
1422
|
+
"GET"
|
|
1423
|
+
);
|
|
1424
|
+
}
|
|
1425
|
+
getReactionTypes() {
|
|
1426
|
+
return this.execute(
|
|
1427
|
+
"/api/reaction-types?limit=100",
|
|
1428
|
+
"GET"
|
|
1429
|
+
);
|
|
1430
|
+
}
|
|
1431
|
+
// Bookmarks
|
|
1432
|
+
addBookmark(params) {
|
|
1433
|
+
return this.execute("/api/bookmarks", "POST", {
|
|
1434
|
+
thread: params.threadId
|
|
1435
|
+
});
|
|
1436
|
+
}
|
|
1437
|
+
removeBookmark(params) {
|
|
1438
|
+
return this.execute(
|
|
1439
|
+
`/api/threads/${params.threadId}/bookmark`,
|
|
1440
|
+
"DELETE"
|
|
1441
|
+
);
|
|
1442
|
+
}
|
|
1443
|
+
getMyBookmarks(params) {
|
|
1444
|
+
const query = params ? `?${new URLSearchParams(
|
|
1445
|
+
Object.fromEntries(
|
|
1446
|
+
Object.entries(params).map(([k, v]) => [k, String(v)])
|
|
1447
|
+
)
|
|
1448
|
+
).toString()}` : "";
|
|
1449
|
+
return this.execute(
|
|
1450
|
+
`/api/bookmarks/my${query}`,
|
|
1451
|
+
"GET"
|
|
1452
|
+
);
|
|
1453
|
+
}
|
|
1454
|
+
// Moderation
|
|
1455
|
+
banCustomer(params) {
|
|
1456
|
+
return this.execute("/api/community-bans/ban", "POST", params);
|
|
1457
|
+
}
|
|
1458
|
+
unbanCustomer(params) {
|
|
1459
|
+
return this.execute(
|
|
1460
|
+
"/api/community-bans/unban",
|
|
1461
|
+
"DELETE",
|
|
1462
|
+
params
|
|
1463
|
+
);
|
|
1464
|
+
}
|
|
1465
|
+
};
|
|
1466
|
+
|
|
1268
1467
|
// src/core/customer/customer-auth.ts
|
|
1269
1468
|
var DEFAULT_TIMEOUT2 = 15e3;
|
|
1270
1469
|
function safeGetItem(key) {
|
|
@@ -1974,6 +2173,12 @@ var Client = class {
|
|
|
1974
2173
|
baseUrl: this.baseUrl,
|
|
1975
2174
|
onUnauthorized
|
|
1976
2175
|
});
|
|
2176
|
+
this.community = new CommunityClient({
|
|
2177
|
+
clientKey: this.config.clientKey,
|
|
2178
|
+
customerToken: () => this.customer.getToken(),
|
|
2179
|
+
baseUrl: this.baseUrl,
|
|
2180
|
+
onUnauthorized
|
|
2181
|
+
});
|
|
1977
2182
|
this.collections = new CollectionClient(
|
|
1978
2183
|
this.config.clientKey,
|
|
1979
2184
|
void 0,
|
|
@@ -2032,6 +2237,11 @@ var ServerClient = class {
|
|
|
2032
2237
|
secretKey: this.config.secretKey,
|
|
2033
2238
|
baseUrl: this.baseUrl
|
|
2034
2239
|
});
|
|
2240
|
+
this.community = new CommunityClient({
|
|
2241
|
+
clientKey: this.config.clientKey,
|
|
2242
|
+
secretKey: this.config.secretKey,
|
|
2243
|
+
baseUrl: this.baseUrl
|
|
2244
|
+
});
|
|
2035
2245
|
this.product = new ProductApi({
|
|
2036
2246
|
clientKey: this.config.clientKey,
|
|
2037
2247
|
secretKey: this.config.secretKey,
|