@sublay/js 7.9.2 → 8.0.0-beta.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.mts +388 -255
- package/dist/index.d.ts +388 -255
- package/dist/index.js +84 -32
- package/dist/index.mjs +84 -32
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
38
38
|
|
|
39
39
|
// src/core/client.ts
|
|
40
40
|
var import_axios = __toESM(require("axios"));
|
|
41
|
-
var BASE_URL = "https://api.sublay.io/
|
|
41
|
+
var BASE_URL = "https://api.sublay.io/v8";
|
|
42
42
|
var SublayHttpClient = class {
|
|
43
43
|
projectInstance;
|
|
44
44
|
baseURL;
|
|
@@ -363,6 +363,7 @@ __export(users_exports, {
|
|
|
363
363
|
deleteFollow: () => deleteFollow,
|
|
364
364
|
fetchBlockStatus: () => fetchBlockStatus,
|
|
365
365
|
fetchBlockedUsers: () => fetchBlockedUsers,
|
|
366
|
+
fetchCommentsByUserId: () => fetchCommentsByUserId,
|
|
366
367
|
fetchConnectionStatus: () => fetchConnectionStatus,
|
|
367
368
|
fetchConnectionsByUserId: () => fetchConnectionsByUserId,
|
|
368
369
|
fetchConnectionsCountByUserId: () => fetchConnectionsCountByUserId,
|
|
@@ -653,6 +654,32 @@ async function fetchConnectionsCountByUserId(client, data) {
|
|
|
653
654
|
return response.data;
|
|
654
655
|
}
|
|
655
656
|
|
|
657
|
+
// src/modules/users/fetchCommentsByUserId.ts
|
|
658
|
+
async function fetchCommentsByUserId(client, data) {
|
|
659
|
+
const {
|
|
660
|
+
userId,
|
|
661
|
+
include,
|
|
662
|
+
cursor,
|
|
663
|
+
spaceReputation,
|
|
664
|
+
spaceReputationId,
|
|
665
|
+
spaceReputationDescendants,
|
|
666
|
+
...rest
|
|
667
|
+
} = data;
|
|
668
|
+
const params = {
|
|
669
|
+
...rest,
|
|
670
|
+
// A `null` cursor (the last page's `nextCursor`) is not sent.
|
|
671
|
+
...cursor != null ? { cursor } : {},
|
|
672
|
+
...include !== void 0 ? { include: Array.isArray(include) ? include.join(",") : include } : {},
|
|
673
|
+
...buildSpaceReputationParams({
|
|
674
|
+
spaceReputation,
|
|
675
|
+
spaceReputationId,
|
|
676
|
+
spaceReputationDescendants
|
|
677
|
+
})
|
|
678
|
+
};
|
|
679
|
+
const response = await client.projectInstance.get(`/users/${userId}/comments`, { params });
|
|
680
|
+
return response.data;
|
|
681
|
+
}
|
|
682
|
+
|
|
656
683
|
// src/modules/users/createFollow.ts
|
|
657
684
|
async function createFollow(client, data) {
|
|
658
685
|
const { userId } = data;
|
|
@@ -749,7 +776,6 @@ __export(entities_exports, {
|
|
|
749
776
|
fetchEntityByShortId: () => fetchEntityByShortId,
|
|
750
777
|
fetchManyEntities: () => fetchManyEntities,
|
|
751
778
|
fetchReactions: () => fetchReactions,
|
|
752
|
-
fetchTopComment: () => fetchTopComment,
|
|
753
779
|
getUserReaction: () => getUserReaction,
|
|
754
780
|
isEntitySaved: () => isEntitySaved,
|
|
755
781
|
publishDraft: () => publishDraft,
|
|
@@ -853,7 +879,12 @@ async function deleteEntity(client, data) {
|
|
|
853
879
|
async function fetchDrafts(client, data) {
|
|
854
880
|
const response = await client.projectInstance.get(
|
|
855
881
|
"/entities/drafts",
|
|
856
|
-
{
|
|
882
|
+
{
|
|
883
|
+
params: {
|
|
884
|
+
...data,
|
|
885
|
+
include: Array.isArray(data.include) ? data.include.join(",") : data.include
|
|
886
|
+
}
|
|
887
|
+
}
|
|
857
888
|
);
|
|
858
889
|
return response.data;
|
|
859
890
|
}
|
|
@@ -867,15 +898,6 @@ async function publishDraft(client, data) {
|
|
|
867
898
|
return response.data;
|
|
868
899
|
}
|
|
869
900
|
|
|
870
|
-
// src/modules/entities/fetchTopComment.ts
|
|
871
|
-
async function fetchTopComment(client, data) {
|
|
872
|
-
const { entityId } = data;
|
|
873
|
-
const response = await client.projectInstance.get(
|
|
874
|
-
`/entities/${entityId}/top-comment`
|
|
875
|
-
);
|
|
876
|
-
return response.data;
|
|
877
|
-
}
|
|
878
|
-
|
|
879
901
|
// src/modules/entities/addReaction.ts
|
|
880
902
|
async function addReaction(client, data) {
|
|
881
903
|
const { entityId, reactionType } = data;
|
|
@@ -1159,7 +1181,7 @@ async function fetchComment(client, data) {
|
|
|
1159
1181
|
`/comments/${commentId}`,
|
|
1160
1182
|
{ params }
|
|
1161
1183
|
);
|
|
1162
|
-
return response.data
|
|
1184
|
+
return response.data;
|
|
1163
1185
|
}
|
|
1164
1186
|
|
|
1165
1187
|
// src/modules/comments/fetchCommentByForeignId.ts
|
|
@@ -1168,7 +1190,7 @@ async function fetchCommentByForeignId(client, data) {
|
|
|
1168
1190
|
const response = await client.projectInstance.get(path, {
|
|
1169
1191
|
params: data
|
|
1170
1192
|
});
|
|
1171
|
-
return response.data
|
|
1193
|
+
return response.data;
|
|
1172
1194
|
}
|
|
1173
1195
|
|
|
1174
1196
|
// src/modules/comments/updateComment.ts
|
|
@@ -1192,24 +1214,49 @@ async function deleteComment(client, data) {
|
|
|
1192
1214
|
// src/modules/comments/fetchManyComments.ts
|
|
1193
1215
|
async function fetchManyComments(client, data) {
|
|
1194
1216
|
const {
|
|
1217
|
+
entityId,
|
|
1218
|
+
parentId,
|
|
1219
|
+
limit,
|
|
1220
|
+
cursor,
|
|
1221
|
+
sortBy,
|
|
1222
|
+
sortDir,
|
|
1223
|
+
sortByReaction,
|
|
1224
|
+
include,
|
|
1225
|
+
replyDepth,
|
|
1226
|
+
replyLimit,
|
|
1227
|
+
replySortBy,
|
|
1228
|
+
replySortDir,
|
|
1229
|
+
replySortByReaction,
|
|
1195
1230
|
spaceReputation,
|
|
1196
1231
|
spaceReputationId,
|
|
1197
|
-
spaceReputationDescendants
|
|
1198
|
-
...rest
|
|
1232
|
+
spaceReputationDescendants
|
|
1199
1233
|
} = data;
|
|
1200
|
-
const
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1234
|
+
const params = {
|
|
1235
|
+
entityId,
|
|
1236
|
+
parentId,
|
|
1237
|
+
limit,
|
|
1238
|
+
cursor: cursor ?? void 0,
|
|
1239
|
+
sortBy,
|
|
1240
|
+
sortDir,
|
|
1241
|
+
sortByReaction,
|
|
1242
|
+
include: Array.isArray(include) ? include.join(",") : include,
|
|
1243
|
+
replyDepth,
|
|
1244
|
+
replyLimit,
|
|
1245
|
+
replySortBy,
|
|
1246
|
+
// The server refuses replySortDir when the nested sort is controversial
|
|
1247
|
+
// (it ranks one way only).
|
|
1248
|
+
replySortDir: (replySortBy ?? sortBy) === "controversial" ? void 0 : replySortDir,
|
|
1249
|
+
replySortByReaction,
|
|
1250
|
+
...buildSpaceReputationParams({
|
|
1251
|
+
spaceReputation,
|
|
1252
|
+
spaceReputationId,
|
|
1253
|
+
spaceReputationDescendants
|
|
1254
|
+
})
|
|
1255
|
+
};
|
|
1256
|
+
for (const key of Object.keys(params)) {
|
|
1257
|
+
if (params[key] === void 0) delete params[key];
|
|
1258
|
+
}
|
|
1259
|
+
const response = await client.projectInstance.get("/comments", { params });
|
|
1213
1260
|
return response.data;
|
|
1214
1261
|
}
|
|
1215
1262
|
|
|
@@ -1548,9 +1595,10 @@ async function declineMembership(client, data) {
|
|
|
1548
1595
|
|
|
1549
1596
|
// src/modules/spaces/banMember.ts
|
|
1550
1597
|
async function banMember(client, data) {
|
|
1551
|
-
const { spaceId, memberId } = data;
|
|
1598
|
+
const { spaceId, memberId, reason } = data;
|
|
1552
1599
|
const response = await client.projectInstance.patch(
|
|
1553
|
-
`/spaces/${spaceId}/members/${memberId}/ban
|
|
1600
|
+
`/spaces/${spaceId}/members/${memberId}/ban`,
|
|
1601
|
+
{ reason }
|
|
1554
1602
|
);
|
|
1555
1603
|
return response.data;
|
|
1556
1604
|
}
|
|
@@ -1742,7 +1790,11 @@ async function createNewCollection(client, data) {
|
|
|
1742
1790
|
|
|
1743
1791
|
// src/modules/collections/fetchCollectionEntities.ts
|
|
1744
1792
|
async function fetchCollectionEntities(client, data) {
|
|
1745
|
-
const { collectionId, ...
|
|
1793
|
+
const { collectionId, include, ...rest } = data;
|
|
1794
|
+
const params = {
|
|
1795
|
+
...rest,
|
|
1796
|
+
...include !== void 0 ? { include: Array.isArray(include) ? include.join(",") : include } : {}
|
|
1797
|
+
};
|
|
1746
1798
|
const response = await client.projectInstance.get(
|
|
1747
1799
|
`/collections/${collectionId}/entities`,
|
|
1748
1800
|
{ params }
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/core/client.ts
|
|
8
8
|
import axios from "axios";
|
|
9
|
-
var BASE_URL = "https://api.sublay.io/
|
|
9
|
+
var BASE_URL = "https://api.sublay.io/v8";
|
|
10
10
|
var SublayHttpClient = class {
|
|
11
11
|
projectInstance;
|
|
12
12
|
baseURL;
|
|
@@ -331,6 +331,7 @@ __export(users_exports, {
|
|
|
331
331
|
deleteFollow: () => deleteFollow,
|
|
332
332
|
fetchBlockStatus: () => fetchBlockStatus,
|
|
333
333
|
fetchBlockedUsers: () => fetchBlockedUsers,
|
|
334
|
+
fetchCommentsByUserId: () => fetchCommentsByUserId,
|
|
334
335
|
fetchConnectionStatus: () => fetchConnectionStatus,
|
|
335
336
|
fetchConnectionsByUserId: () => fetchConnectionsByUserId,
|
|
336
337
|
fetchConnectionsCountByUserId: () => fetchConnectionsCountByUserId,
|
|
@@ -621,6 +622,32 @@ async function fetchConnectionsCountByUserId(client, data) {
|
|
|
621
622
|
return response.data;
|
|
622
623
|
}
|
|
623
624
|
|
|
625
|
+
// src/modules/users/fetchCommentsByUserId.ts
|
|
626
|
+
async function fetchCommentsByUserId(client, data) {
|
|
627
|
+
const {
|
|
628
|
+
userId,
|
|
629
|
+
include,
|
|
630
|
+
cursor,
|
|
631
|
+
spaceReputation,
|
|
632
|
+
spaceReputationId,
|
|
633
|
+
spaceReputationDescendants,
|
|
634
|
+
...rest
|
|
635
|
+
} = data;
|
|
636
|
+
const params = {
|
|
637
|
+
...rest,
|
|
638
|
+
// A `null` cursor (the last page's `nextCursor`) is not sent.
|
|
639
|
+
...cursor != null ? { cursor } : {},
|
|
640
|
+
...include !== void 0 ? { include: Array.isArray(include) ? include.join(",") : include } : {},
|
|
641
|
+
...buildSpaceReputationParams({
|
|
642
|
+
spaceReputation,
|
|
643
|
+
spaceReputationId,
|
|
644
|
+
spaceReputationDescendants
|
|
645
|
+
})
|
|
646
|
+
};
|
|
647
|
+
const response = await client.projectInstance.get(`/users/${userId}/comments`, { params });
|
|
648
|
+
return response.data;
|
|
649
|
+
}
|
|
650
|
+
|
|
624
651
|
// src/modules/users/createFollow.ts
|
|
625
652
|
async function createFollow(client, data) {
|
|
626
653
|
const { userId } = data;
|
|
@@ -717,7 +744,6 @@ __export(entities_exports, {
|
|
|
717
744
|
fetchEntityByShortId: () => fetchEntityByShortId,
|
|
718
745
|
fetchManyEntities: () => fetchManyEntities,
|
|
719
746
|
fetchReactions: () => fetchReactions,
|
|
720
|
-
fetchTopComment: () => fetchTopComment,
|
|
721
747
|
getUserReaction: () => getUserReaction,
|
|
722
748
|
isEntitySaved: () => isEntitySaved,
|
|
723
749
|
publishDraft: () => publishDraft,
|
|
@@ -821,7 +847,12 @@ async function deleteEntity(client, data) {
|
|
|
821
847
|
async function fetchDrafts(client, data) {
|
|
822
848
|
const response = await client.projectInstance.get(
|
|
823
849
|
"/entities/drafts",
|
|
824
|
-
{
|
|
850
|
+
{
|
|
851
|
+
params: {
|
|
852
|
+
...data,
|
|
853
|
+
include: Array.isArray(data.include) ? data.include.join(",") : data.include
|
|
854
|
+
}
|
|
855
|
+
}
|
|
825
856
|
);
|
|
826
857
|
return response.data;
|
|
827
858
|
}
|
|
@@ -835,15 +866,6 @@ async function publishDraft(client, data) {
|
|
|
835
866
|
return response.data;
|
|
836
867
|
}
|
|
837
868
|
|
|
838
|
-
// src/modules/entities/fetchTopComment.ts
|
|
839
|
-
async function fetchTopComment(client, data) {
|
|
840
|
-
const { entityId } = data;
|
|
841
|
-
const response = await client.projectInstance.get(
|
|
842
|
-
`/entities/${entityId}/top-comment`
|
|
843
|
-
);
|
|
844
|
-
return response.data;
|
|
845
|
-
}
|
|
846
|
-
|
|
847
869
|
// src/modules/entities/addReaction.ts
|
|
848
870
|
async function addReaction(client, data) {
|
|
849
871
|
const { entityId, reactionType } = data;
|
|
@@ -1127,7 +1149,7 @@ async function fetchComment(client, data) {
|
|
|
1127
1149
|
`/comments/${commentId}`,
|
|
1128
1150
|
{ params }
|
|
1129
1151
|
);
|
|
1130
|
-
return response.data
|
|
1152
|
+
return response.data;
|
|
1131
1153
|
}
|
|
1132
1154
|
|
|
1133
1155
|
// src/modules/comments/fetchCommentByForeignId.ts
|
|
@@ -1136,7 +1158,7 @@ async function fetchCommentByForeignId(client, data) {
|
|
|
1136
1158
|
const response = await client.projectInstance.get(path, {
|
|
1137
1159
|
params: data
|
|
1138
1160
|
});
|
|
1139
|
-
return response.data
|
|
1161
|
+
return response.data;
|
|
1140
1162
|
}
|
|
1141
1163
|
|
|
1142
1164
|
// src/modules/comments/updateComment.ts
|
|
@@ -1160,24 +1182,49 @@ async function deleteComment(client, data) {
|
|
|
1160
1182
|
// src/modules/comments/fetchManyComments.ts
|
|
1161
1183
|
async function fetchManyComments(client, data) {
|
|
1162
1184
|
const {
|
|
1185
|
+
entityId,
|
|
1186
|
+
parentId,
|
|
1187
|
+
limit,
|
|
1188
|
+
cursor,
|
|
1189
|
+
sortBy,
|
|
1190
|
+
sortDir,
|
|
1191
|
+
sortByReaction,
|
|
1192
|
+
include,
|
|
1193
|
+
replyDepth,
|
|
1194
|
+
replyLimit,
|
|
1195
|
+
replySortBy,
|
|
1196
|
+
replySortDir,
|
|
1197
|
+
replySortByReaction,
|
|
1163
1198
|
spaceReputation,
|
|
1164
1199
|
spaceReputationId,
|
|
1165
|
-
spaceReputationDescendants
|
|
1166
|
-
...rest
|
|
1200
|
+
spaceReputationDescendants
|
|
1167
1201
|
} = data;
|
|
1168
|
-
const
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1202
|
+
const params = {
|
|
1203
|
+
entityId,
|
|
1204
|
+
parentId,
|
|
1205
|
+
limit,
|
|
1206
|
+
cursor: cursor ?? void 0,
|
|
1207
|
+
sortBy,
|
|
1208
|
+
sortDir,
|
|
1209
|
+
sortByReaction,
|
|
1210
|
+
include: Array.isArray(include) ? include.join(",") : include,
|
|
1211
|
+
replyDepth,
|
|
1212
|
+
replyLimit,
|
|
1213
|
+
replySortBy,
|
|
1214
|
+
// The server refuses replySortDir when the nested sort is controversial
|
|
1215
|
+
// (it ranks one way only).
|
|
1216
|
+
replySortDir: (replySortBy ?? sortBy) === "controversial" ? void 0 : replySortDir,
|
|
1217
|
+
replySortByReaction,
|
|
1218
|
+
...buildSpaceReputationParams({
|
|
1219
|
+
spaceReputation,
|
|
1220
|
+
spaceReputationId,
|
|
1221
|
+
spaceReputationDescendants
|
|
1222
|
+
})
|
|
1223
|
+
};
|
|
1224
|
+
for (const key of Object.keys(params)) {
|
|
1225
|
+
if (params[key] === void 0) delete params[key];
|
|
1226
|
+
}
|
|
1227
|
+
const response = await client.projectInstance.get("/comments", { params });
|
|
1181
1228
|
return response.data;
|
|
1182
1229
|
}
|
|
1183
1230
|
|
|
@@ -1516,9 +1563,10 @@ async function declineMembership(client, data) {
|
|
|
1516
1563
|
|
|
1517
1564
|
// src/modules/spaces/banMember.ts
|
|
1518
1565
|
async function banMember(client, data) {
|
|
1519
|
-
const { spaceId, memberId } = data;
|
|
1566
|
+
const { spaceId, memberId, reason } = data;
|
|
1520
1567
|
const response = await client.projectInstance.patch(
|
|
1521
|
-
`/spaces/${spaceId}/members/${memberId}/ban
|
|
1568
|
+
`/spaces/${spaceId}/members/${memberId}/ban`,
|
|
1569
|
+
{ reason }
|
|
1522
1570
|
);
|
|
1523
1571
|
return response.data;
|
|
1524
1572
|
}
|
|
@@ -1710,7 +1758,11 @@ async function createNewCollection(client, data) {
|
|
|
1710
1758
|
|
|
1711
1759
|
// src/modules/collections/fetchCollectionEntities.ts
|
|
1712
1760
|
async function fetchCollectionEntities(client, data) {
|
|
1713
|
-
const { collectionId, ...
|
|
1761
|
+
const { collectionId, include, ...rest } = data;
|
|
1762
|
+
const params = {
|
|
1763
|
+
...rest,
|
|
1764
|
+
...include !== void 0 ? { include: Array.isArray(include) ? include.join(",") : include } : {}
|
|
1765
|
+
};
|
|
1714
1766
|
const response = await client.projectInstance.get(
|
|
1715
1767
|
`/collections/${collectionId}/entities`,
|
|
1716
1768
|
{ params }
|