@sublay/js 5.0.0 → 7.0.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/README.md +33 -4
- package/dist/core/client.d.ts +58 -2
- package/dist/core/multipart.d.ts +22 -0
- package/dist/index.d.mts +2525 -42
- package/dist/index.d.ts +29 -2
- package/dist/index.js +1746 -37
- package/dist/index.mjs +1746 -37
- package/dist/interfaces/AppNotification.d.ts +258 -0
- package/dist/interfaces/ChatMessage.d.ts +32 -0
- package/dist/interfaces/Collection.d.ts +10 -0
- package/dist/interfaces/Comment.d.ts +42 -0
- package/dist/interfaces/Connection.d.ts +67 -0
- package/dist/interfaces/Conversation.d.ts +25 -0
- package/dist/interfaces/ConversationMember.d.ts +16 -0
- package/dist/interfaces/Entity.d.ts +53 -0
- package/dist/interfaces/File.d.ts +39 -0
- package/dist/interfaces/Follow.d.ts +19 -0
- package/dist/interfaces/HostedApp.d.ts +11 -0
- package/dist/interfaces/ImageProcessing.d.ts +62 -0
- package/dist/interfaces/Mention.d.ts +12 -0
- package/dist/interfaces/OAuthIdentity.d.ts +13 -0
- package/dist/interfaces/Project.d.ts +14 -0
- package/dist/interfaces/Reaction.d.ts +23 -0
- package/dist/interfaces/Report.d.ts +32 -0
- package/dist/interfaces/Rule.d.ts +22 -0
- package/dist/interfaces/Space.d.ts +141 -0
- package/dist/interfaces/SpaceMember.d.ts +29 -0
- package/dist/interfaces/User.d.ts +39 -0
- package/dist/modules/app-notifications/countUnreadNotifications.d.ts +2 -0
- package/dist/modules/app-notifications/fetchNotifications.d.ts +8 -0
- package/dist/modules/app-notifications/index.d.ts +4 -0
- package/dist/modules/app-notifications/markAllNotificationsAsRead.d.ts +5 -0
- package/dist/modules/app-notifications/markNotificationAsRead.d.ts +5 -0
- package/dist/modules/auth/changePassword.d.ts +11 -0
- package/dist/modules/auth/index.d.ts +10 -0
- package/dist/modules/auth/requestNewAccessToken.d.ts +16 -0
- package/dist/modules/auth/requestPasswordReset.d.ts +5 -0
- package/dist/modules/auth/resetPassword.d.ts +6 -0
- package/dist/modules/auth/sendVerificationEmail.d.ts +13 -0
- package/dist/modules/auth/signIn.d.ts +12 -0
- package/dist/modules/auth/signOut.d.ts +9 -0
- package/dist/modules/auth/signUp.d.ts +24 -0
- package/dist/modules/auth/verifyEmail.d.ts +5 -0
- package/dist/modules/auth/verifyExternalUser.d.ts +11 -0
- package/dist/modules/chat/addMember.d.ts +8 -0
- package/dist/modules/chat/changeMemberRole.d.ts +9 -0
- package/dist/modules/chat/createDirectConversation.d.ts +7 -0
- package/dist/modules/chat/createGroupConversation.d.ts +10 -0
- package/dist/modules/chat/deleteConversation.d.ts +8 -0
- package/dist/modules/chat/deleteMessage.d.ts +11 -0
- package/dist/modules/chat/editMessage.d.ts +13 -0
- package/dist/modules/chat/getConversation.d.ts +6 -0
- package/dist/modules/chat/getMessage.d.ts +7 -0
- package/dist/modules/chat/getUnreadCount.d.ts +6 -0
- package/dist/modules/chat/index.d.ts +21 -0
- package/dist/modules/chat/leaveConversation.d.ts +7 -0
- package/dist/modules/chat/listConversations.d.ts +17 -0
- package/dist/modules/chat/listMembers.d.ts +10 -0
- package/dist/modules/chat/listMessages.d.ts +23 -0
- package/dist/modules/chat/listReactions.d.ts +27 -0
- package/dist/modules/chat/markAsRead.d.ts +9 -0
- package/dist/modules/chat/removeMember.d.ts +9 -0
- package/dist/modules/chat/reportMessage.d.ts +12 -0
- package/dist/modules/chat/sendMessage.d.ts +21 -0
- package/dist/modules/chat/toggleReaction.d.ts +16 -0
- package/dist/modules/chat/updateConversation.d.ts +12 -0
- package/dist/modules/collections/addEntityToCollection.d.ts +13 -0
- package/dist/modules/collections/createNewCollection.d.ts +8 -0
- package/dist/modules/collections/deleteCollection.d.ts +5 -0
- package/dist/modules/collections/fetchCollectionEntities.d.ts +13 -0
- package/dist/modules/collections/fetchRootCollection.d.ts +3 -0
- package/dist/modules/collections/fetchSubCollections.d.ts +6 -0
- package/dist/modules/collections/index.d.ts +8 -0
- package/dist/modules/collections/removeEntityFromCollection.d.ts +7 -0
- package/dist/modules/collections/updateCollection.d.ts +7 -0
- package/dist/modules/comments/addReaction.d.ts +8 -0
- package/dist/modules/comments/createComment.d.ts +15 -0
- package/dist/modules/comments/deleteComment.d.ts +5 -0
- package/dist/modules/comments/fetchComment.d.ts +3 -1
- package/dist/modules/comments/fetchCommentByForeignId.d.ts +3 -1
- package/dist/modules/comments/fetchManyComments.d.ts +14 -0
- package/dist/modules/comments/fetchReactions.d.ts +20 -0
- package/dist/modules/comments/getUserReaction.d.ts +9 -0
- package/dist/modules/comments/index.d.ts +10 -3
- package/dist/modules/comments/removeReaction.d.ts +6 -0
- package/dist/modules/comments/updateComment.d.ts +7 -0
- package/dist/modules/connections/acceptConnection.d.ts +6 -0
- package/dist/modules/connections/declineConnection.d.ts +6 -0
- package/dist/modules/connections/fetchConnections.d.ts +8 -0
- package/dist/modules/connections/fetchConnectionsCount.d.ts +3 -0
- package/dist/modules/connections/fetchReceivedPendingConnections.d.ts +8 -0
- package/dist/modules/connections/fetchSentPendingConnections.d.ts +8 -0
- package/dist/modules/connections/index.d.ts +7 -0
- package/dist/modules/connections/removeConnection.d.ts +5 -0
- package/dist/modules/entities/addReaction.d.ts +8 -0
- package/dist/modules/entities/createEntity.d.ts +7 -2
- package/dist/modules/entities/deleteEntity.d.ts +1 -1
- package/dist/modules/entities/fetchDrafts.d.ts +11 -0
- package/dist/modules/entities/fetchEntity.d.ts +3 -1
- package/dist/modules/entities/fetchEntityByForeignId.d.ts +3 -1
- package/dist/modules/entities/fetchEntityByShortId.d.ts +3 -1
- package/dist/modules/entities/fetchManyEntities.d.ts +11 -3
- package/dist/modules/entities/fetchReactions.d.ts +20 -0
- package/dist/modules/entities/fetchTopComment.d.ts +6 -0
- package/dist/modules/entities/getUserReaction.d.ts +9 -0
- package/dist/modules/entities/index.d.ts +15 -8
- package/dist/modules/entities/isEntitySaved.d.ts +12 -0
- package/dist/modules/entities/publishDraft.d.ts +6 -0
- package/dist/modules/entities/removeReaction.d.ts +6 -0
- package/dist/modules/entities/updateEntity.d.ts +6 -7
- package/dist/modules/follows/deleteFollow.d.ts +5 -0
- package/dist/modules/follows/fetchFollowers.d.ts +8 -0
- package/dist/modules/follows/fetchFollowersCount.d.ts +5 -0
- package/dist/modules/follows/fetchFollowing.d.ts +8 -0
- package/dist/modules/follows/fetchFollowingCount.d.ts +5 -0
- package/dist/modules/follows/index.d.ts +5 -0
- package/dist/modules/oauth/authorize.d.ts +25 -0
- package/dist/modules/oauth/index.d.ts +4 -0
- package/dist/modules/oauth/linkIdentity.d.ts +14 -0
- package/dist/modules/oauth/listIdentities.d.ts +4 -0
- package/dist/modules/oauth/unlinkIdentity.d.ts +12 -0
- package/dist/modules/reports/createReport.d.ts +9 -0
- package/dist/modules/reports/fetchModeratedReports.d.ts +12 -0
- package/dist/modules/reports/index.d.ts +2 -0
- package/dist/modules/search/askContent.d.ts +51 -0
- package/dist/modules/search/index.d.ts +4 -0
- package/dist/modules/search/searchContent.d.ts +17 -0
- package/dist/modules/search/searchSpaces.d.ts +11 -0
- package/dist/modules/search/searchUsers.d.ts +11 -0
- package/dist/modules/spaces/approveMembership.d.ts +7 -0
- package/dist/modules/spaces/banMember.d.ts +13 -0
- package/dist/modules/spaces/checkMyMembership.d.ts +6 -0
- package/dist/modules/spaces/checkSlugAvailability.d.ts +8 -0
- package/dist/modules/spaces/createRule.d.ts +8 -0
- package/dist/modules/spaces/createSpace.d.ts +13 -0
- package/dist/modules/spaces/declineMembership.d.ts +7 -0
- package/dist/modules/spaces/deleteRule.d.ts +7 -0
- package/dist/modules/spaces/deleteSpace.d.ts +6 -0
- package/dist/modules/spaces/fetchChildSpaces.d.ts +11 -0
- package/dist/modules/spaces/fetchDigestConfig.d.ts +6 -0
- package/dist/modules/spaces/fetchManyRules.d.ts +6 -0
- package/dist/modules/spaces/fetchManySpaces.d.ts +16 -0
- package/dist/modules/spaces/fetchRule.d.ts +7 -0
- package/dist/modules/spaces/fetchSpace.d.ts +6 -0
- package/dist/modules/spaces/fetchSpaceBreadcrumb.d.ts +6 -0
- package/dist/modules/spaces/fetchSpaceByShortId.d.ts +6 -0
- package/dist/modules/spaces/fetchSpaceBySlug.d.ts +6 -0
- package/dist/modules/spaces/fetchSpaceMembers.d.ts +10 -0
- package/dist/modules/spaces/fetchSpaceTeam.d.ts +6 -0
- package/dist/modules/spaces/fetchUserSpaces.d.ts +11 -0
- package/dist/modules/spaces/getSpaceConversation.d.ts +6 -0
- package/dist/modules/spaces/handleCommentReport.d.ts +14 -0
- package/dist/modules/spaces/handleEntityReport.d.ts +17 -0
- package/dist/modules/spaces/handleSpaceChatReport.d.ts +18 -0
- package/dist/modules/spaces/index.d.ts +36 -0
- package/dist/modules/spaces/joinSpace.d.ts +6 -0
- package/dist/modules/spaces/leaveSpace.d.ts +6 -0
- package/dist/modules/spaces/moderateSpaceChatMessage.d.ts +12 -0
- package/dist/modules/spaces/moderateSpaceComment.d.ts +9 -0
- package/dist/modules/spaces/moderateSpaceEntity.d.ts +12 -0
- package/dist/modules/spaces/reorderRules.d.ts +7 -0
- package/dist/modules/spaces/unbanMember.d.ts +13 -0
- package/dist/modules/spaces/updateDigestConfig.d.ts +11 -0
- package/dist/modules/spaces/updateMemberRole.d.ts +8 -0
- package/dist/modules/spaces/updateRule.d.ts +9 -0
- package/dist/modules/spaces/updateSpace.d.ts +12 -0
- package/dist/modules/storage/deleteFile.d.ts +5 -0
- package/dist/modules/storage/getFile.d.ts +34 -0
- package/dist/modules/storage/index.d.ts +4 -0
- package/dist/modules/storage/uploadFile.d.ts +30 -0
- package/dist/modules/storage/uploadImage.d.ts +41 -0
- package/dist/modules/users/checkUsernameAvailability.d.ts +8 -0
- package/dist/modules/users/createFollow.d.ts +7 -0
- package/dist/modules/users/deleteFollow.d.ts +6 -0
- package/dist/modules/users/fetchConnectionStatus.d.ts +10 -0
- package/dist/modules/users/fetchConnectionsByUserId.d.ts +9 -0
- package/dist/modules/users/fetchConnectionsCountByUserId.d.ts +6 -0
- package/dist/modules/users/fetchFollowStatus.d.ts +14 -0
- package/dist/modules/users/fetchFollowersByUserId.d.ts +9 -0
- package/dist/modules/users/fetchFollowersCountByUserId.d.ts +8 -0
- package/dist/modules/users/fetchFollowingByUserId.d.ts +9 -0
- package/dist/modules/users/fetchFollowingCountByUserId.d.ts +8 -0
- package/dist/modules/users/fetchUserByForeignId.d.ts +3 -7
- package/dist/modules/users/fetchUserById.d.ts +3 -1
- package/dist/modules/users/fetchUserByUsername.d.ts +7 -0
- package/dist/modules/users/fetchUserSuggestions.d.ts +6 -0
- package/dist/modules/users/index.d.ts +18 -3
- package/dist/modules/users/removeConnectionByUserId.d.ts +10 -0
- package/dist/modules/users/requestConnection.d.ts +11 -0
- package/dist/modules/users/updateUser.d.ts +32 -0
- package/package.json +6 -3
- package/CLAUDE.md +0 -339
- package/pnpm-workspace.yaml +0 -2
- package/src/core/client.ts +0 -15
- package/src/index.ts +0 -45
- package/src/interfaces/IPaginatedResponse.ts +0 -12
- package/src/modules/comments/fetchComment.ts +0 -14
- package/src/modules/comments/fetchCommentByForeignId.ts +0 -14
- package/src/modules/comments/index.ts +0 -4
- package/src/modules/entities/createEntity.ts +0 -27
- package/src/modules/entities/deleteEntity.ts +0 -14
- package/src/modules/entities/fetchEntity.ts +0 -14
- package/src/modules/entities/fetchEntityByForeignId.ts +0 -15
- package/src/modules/entities/fetchEntityByShortId.ts +0 -14
- package/src/modules/entities/fetchManyEntities.ts +0 -79
- package/src/modules/entities/index.ts +0 -17
- package/src/modules/entities/updateEntity.ts +0 -28
- package/src/modules/users/fetchUserByForeignId.ts +0 -40
- package/src/modules/users/fetchUserById.ts +0 -15
- package/src/modules/users/index.ts +0 -4
- package/tsconfig.json +0 -14
package/dist/index.js
CHANGED
|
@@ -36,150 +36,1859 @@ module.exports = __toCommonJS(index_exports);
|
|
|
36
36
|
|
|
37
37
|
// src/core/client.ts
|
|
38
38
|
var import_axios = __toESM(require("axios"));
|
|
39
|
+
var BASE_URL = "https://api.sublay.io/v7";
|
|
39
40
|
var SublayHttpClient = class {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
projectInstance;
|
|
42
|
+
baseURL;
|
|
43
|
+
hostManaged;
|
|
44
|
+
getToken;
|
|
45
|
+
onAuthChange;
|
|
46
|
+
accessToken;
|
|
47
|
+
refreshToken;
|
|
48
|
+
/** Shared so concurrent 403s trigger a single refresh (mutex). */
|
|
49
|
+
refreshPromise = null;
|
|
50
|
+
constructor({
|
|
51
|
+
projectId,
|
|
52
|
+
initialTokens,
|
|
53
|
+
getToken,
|
|
54
|
+
onAuthChange
|
|
55
|
+
}) {
|
|
56
|
+
this.baseURL = `${BASE_URL}/${projectId}`;
|
|
57
|
+
this.getToken = getToken;
|
|
58
|
+
this.onAuthChange = onAuthChange;
|
|
59
|
+
this.hostManaged = Boolean(getToken);
|
|
60
|
+
this.accessToken = initialTokens?.accessToken ?? null;
|
|
61
|
+
this.refreshToken = initialTokens?.refreshToken ?? null;
|
|
62
|
+
this.projectInstance = import_axios.default.create({
|
|
63
|
+
baseURL: this.baseURL,
|
|
64
|
+
headers: { "Content-Type": "application/json" }
|
|
44
65
|
});
|
|
66
|
+
this.projectInstance.interceptors.request.use(async (config) => {
|
|
67
|
+
if (config.headers.Authorization) return config;
|
|
68
|
+
const token = this.hostManaged ? await this.getToken?.() : this.accessToken;
|
|
69
|
+
if (token) config.headers.Authorization = `Bearer ${token}`;
|
|
70
|
+
return config;
|
|
71
|
+
});
|
|
72
|
+
this.projectInstance.interceptors.response.use(
|
|
73
|
+
(response) => response,
|
|
74
|
+
async (error) => {
|
|
75
|
+
const prevRequest = error?.config;
|
|
76
|
+
const status = error?.response?.status;
|
|
77
|
+
if (status !== 403 || !prevRequest || prevRequest._retry) {
|
|
78
|
+
return Promise.reject(error);
|
|
79
|
+
}
|
|
80
|
+
prevRequest._retry = true;
|
|
81
|
+
let newToken = null;
|
|
82
|
+
if (this.hostManaged) {
|
|
83
|
+
const fresh = await this.getToken?.();
|
|
84
|
+
if (fresh && `Bearer ${fresh}` !== prevRequest.headers?.Authorization) {
|
|
85
|
+
newToken = fresh;
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
newToken = await this.refreshAccessToken();
|
|
89
|
+
}
|
|
90
|
+
if (!newToken) return Promise.reject(error);
|
|
91
|
+
prevRequest.headers.Authorization = `Bearer ${newToken}`;
|
|
92
|
+
return this.projectInstance(prevRequest);
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The SDK's own in-memory access token (SDK-managed mode). Distinct from the
|
|
98
|
+
* `init({ getToken })` host hook, which supplies a token in host-managed mode.
|
|
99
|
+
*/
|
|
100
|
+
getAccessToken() {
|
|
101
|
+
return this.accessToken;
|
|
102
|
+
}
|
|
103
|
+
getRefreshToken() {
|
|
104
|
+
return this.refreshToken;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The `Authorization` header value (`Bearer <token>`) for the active auth
|
|
108
|
+
* mode, or `undefined` if there is no token. Host-managed mode reads the
|
|
109
|
+
* `getToken` hook; SDK-managed mode reads the in-memory access token. Use this
|
|
110
|
+
* for requests that bypass `projectInstance` (e.g. the SSE `askContent`
|
|
111
|
+
* stream, which needs `fetch` rather than axios).
|
|
112
|
+
*/
|
|
113
|
+
async getAuthHeader() {
|
|
114
|
+
const token = this.hostManaged ? await this.getToken?.() : this.accessToken;
|
|
115
|
+
return token ? `Bearer ${token}` : void 0;
|
|
116
|
+
}
|
|
117
|
+
/** Store a full token pair (SDK-managed mode only; no-op when host-managed). */
|
|
118
|
+
setTokens(tokens) {
|
|
119
|
+
if (this.hostManaged) return;
|
|
120
|
+
this.accessToken = tokens.accessToken;
|
|
121
|
+
this.refreshToken = tokens.refreshToken;
|
|
122
|
+
this.onAuthChange?.({
|
|
123
|
+
accessToken: this.accessToken,
|
|
124
|
+
refreshToken: this.refreshToken
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/** Update just the access token, e.g. after a refresh (no-op when host-managed). */
|
|
128
|
+
setAccessToken(accessToken) {
|
|
129
|
+
if (this.hostManaged) return;
|
|
130
|
+
this.accessToken = accessToken;
|
|
131
|
+
if (this.refreshToken) {
|
|
132
|
+
this.onAuthChange?.({ accessToken, refreshToken: this.refreshToken });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/** Clear tokens and notify with null (SDK-managed mode only). */
|
|
136
|
+
clearTokens() {
|
|
137
|
+
if (this.hostManaged) return;
|
|
138
|
+
this.accessToken = null;
|
|
139
|
+
this.refreshToken = null;
|
|
140
|
+
this.onAuthChange?.(null);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Refresh the access token using the in-memory refresh token. A single shared
|
|
144
|
+
* promise (mutex) means concurrent 403s trigger only one network refresh. The
|
|
145
|
+
* call goes through a bare axios (not `projectInstance`) so it never re-enters
|
|
146
|
+
* the response interceptor. Returns the new access token, or null on failure.
|
|
147
|
+
*/
|
|
148
|
+
async refreshAccessToken() {
|
|
149
|
+
if (!this.refreshToken) return null;
|
|
150
|
+
if (!this.refreshPromise) {
|
|
151
|
+
const refreshToken = this.refreshToken;
|
|
152
|
+
this.refreshPromise = import_axios.default.post(
|
|
153
|
+
`${this.baseURL}/auth/request-new-access-token`,
|
|
154
|
+
{ refreshToken }
|
|
155
|
+
).then((res) => {
|
|
156
|
+
const { accessToken, refreshToken: rotated } = res.data;
|
|
157
|
+
if (rotated) this.setTokens({ accessToken, refreshToken: rotated });
|
|
158
|
+
else this.setAccessToken(accessToken);
|
|
159
|
+
return accessToken;
|
|
160
|
+
}).catch(() => null).finally(() => {
|
|
161
|
+
this.refreshPromise = null;
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return this.refreshPromise;
|
|
45
165
|
}
|
|
46
166
|
};
|
|
47
167
|
|
|
168
|
+
// src/modules/auth/index.ts
|
|
169
|
+
var auth_exports = {};
|
|
170
|
+
__export(auth_exports, {
|
|
171
|
+
changePassword: () => changePassword,
|
|
172
|
+
requestNewAccessToken: () => requestNewAccessToken,
|
|
173
|
+
requestPasswordReset: () => requestPasswordReset,
|
|
174
|
+
resetPassword: () => resetPassword,
|
|
175
|
+
sendVerificationEmail: () => sendVerificationEmail,
|
|
176
|
+
signIn: () => signIn,
|
|
177
|
+
signOut: () => signOut,
|
|
178
|
+
signUp: () => signUp,
|
|
179
|
+
verifyEmail: () => verifyEmail,
|
|
180
|
+
verifyExternalUser: () => verifyExternalUser
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// src/modules/auth/signUp.ts
|
|
184
|
+
async function signUp(client, data) {
|
|
185
|
+
const response = await client.projectInstance.post(
|
|
186
|
+
"/auth/sign-up",
|
|
187
|
+
data
|
|
188
|
+
);
|
|
189
|
+
client.setTokens({
|
|
190
|
+
accessToken: response.data.accessToken,
|
|
191
|
+
refreshToken: response.data.refreshToken
|
|
192
|
+
});
|
|
193
|
+
return response.data;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// src/modules/auth/signIn.ts
|
|
197
|
+
async function signIn(client, data) {
|
|
198
|
+
const response = await client.projectInstance.post(
|
|
199
|
+
"/auth/sign-in",
|
|
200
|
+
data
|
|
201
|
+
);
|
|
202
|
+
client.setTokens({
|
|
203
|
+
accessToken: response.data.accessToken,
|
|
204
|
+
refreshToken: response.data.refreshToken
|
|
205
|
+
});
|
|
206
|
+
return response.data;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// src/modules/auth/signOut.ts
|
|
210
|
+
async function signOut(client, data) {
|
|
211
|
+
const refreshToken = data?.refreshToken ?? client.getRefreshToken();
|
|
212
|
+
await client.projectInstance.post(
|
|
213
|
+
"/auth/sign-out",
|
|
214
|
+
refreshToken ? { refreshToken } : {}
|
|
215
|
+
);
|
|
216
|
+
client.clearTokens();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// src/modules/auth/requestNewAccessToken.ts
|
|
220
|
+
async function requestNewAccessToken(client, data) {
|
|
221
|
+
const refreshToken = data?.refreshToken ?? client.getRefreshToken();
|
|
222
|
+
if (!refreshToken) {
|
|
223
|
+
throw new Error(
|
|
224
|
+
"requestNewAccessToken: no refresh token available (none stored and none provided)."
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
const response = await client.projectInstance.post(
|
|
228
|
+
"/auth/request-new-access-token",
|
|
229
|
+
{ refreshToken }
|
|
230
|
+
);
|
|
231
|
+
const { accessToken, refreshToken: rotated } = response.data;
|
|
232
|
+
if (rotated) client.setTokens({ accessToken, refreshToken: rotated });
|
|
233
|
+
else client.setAccessToken(accessToken);
|
|
234
|
+
return response.data;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// src/modules/auth/verifyExternalUser.ts
|
|
238
|
+
async function verifyExternalUser(client, data) {
|
|
239
|
+
const response = await client.projectInstance.post(
|
|
240
|
+
"/auth/verify-external-user",
|
|
241
|
+
data
|
|
242
|
+
);
|
|
243
|
+
client.setTokens({
|
|
244
|
+
accessToken: response.data.accessToken,
|
|
245
|
+
refreshToken: response.data.refreshToken
|
|
246
|
+
});
|
|
247
|
+
return response.data;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// src/modules/auth/requestPasswordReset.ts
|
|
251
|
+
async function requestPasswordReset(client, data) {
|
|
252
|
+
await client.projectInstance.post("/auth/request-password-reset", data);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// src/modules/auth/resetPassword.ts
|
|
256
|
+
async function resetPassword(client, data) {
|
|
257
|
+
await client.projectInstance.post("/auth/reset-password", data);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// src/modules/auth/changePassword.ts
|
|
261
|
+
async function changePassword(client, data) {
|
|
262
|
+
const response = await client.projectInstance.post(
|
|
263
|
+
"/auth/change-password",
|
|
264
|
+
data
|
|
265
|
+
);
|
|
266
|
+
return response.data;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// src/modules/auth/verifyEmail.ts
|
|
270
|
+
async function verifyEmail(client, data) {
|
|
271
|
+
await client.projectInstance.post("/auth/verify-email", data);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// src/modules/auth/sendVerificationEmail.ts
|
|
275
|
+
async function sendVerificationEmail(client, data) {
|
|
276
|
+
const response = await client.projectInstance.post(
|
|
277
|
+
"/auth/send-verification-email",
|
|
278
|
+
data ?? {}
|
|
279
|
+
);
|
|
280
|
+
return response.data;
|
|
281
|
+
}
|
|
282
|
+
|
|
48
283
|
// src/modules/users/index.ts
|
|
49
284
|
var users_exports = {};
|
|
50
285
|
__export(users_exports, {
|
|
286
|
+
checkUsernameAvailability: () => checkUsernameAvailability,
|
|
287
|
+
createFollow: () => createFollow,
|
|
288
|
+
deleteFollow: () => deleteFollow,
|
|
289
|
+
fetchConnectionStatus: () => fetchConnectionStatus,
|
|
290
|
+
fetchConnectionsByUserId: () => fetchConnectionsByUserId,
|
|
291
|
+
fetchConnectionsCountByUserId: () => fetchConnectionsCountByUserId,
|
|
292
|
+
fetchFollowStatus: () => fetchFollowStatus,
|
|
293
|
+
fetchFollowersByUserId: () => fetchFollowersByUserId,
|
|
294
|
+
fetchFollowersCountByUserId: () => fetchFollowersCountByUserId,
|
|
295
|
+
fetchFollowingByUserId: () => fetchFollowingByUserId,
|
|
296
|
+
fetchFollowingCountByUserId: () => fetchFollowingCountByUserId,
|
|
51
297
|
fetchUserByForeignId: () => fetchUserByForeignId,
|
|
52
|
-
fetchUserById: () => fetchUserById
|
|
298
|
+
fetchUserById: () => fetchUserById,
|
|
299
|
+
fetchUserByUsername: () => fetchUserByUsername,
|
|
300
|
+
fetchUserSuggestions: () => fetchUserSuggestions,
|
|
301
|
+
removeConnectionByUserId: () => removeConnectionByUserId,
|
|
302
|
+
requestConnection: () => requestConnection,
|
|
303
|
+
updateUser: () => updateUser
|
|
53
304
|
});
|
|
54
305
|
|
|
55
306
|
// src/modules/users/fetchUserById.ts
|
|
56
307
|
async function fetchUserById(client, data) {
|
|
57
|
-
const
|
|
58
|
-
const response = await client.
|
|
308
|
+
const { userId, ...params } = data;
|
|
309
|
+
const response = await client.projectInstance.get(`/users/${userId}`, {
|
|
310
|
+
params
|
|
311
|
+
});
|
|
59
312
|
return response.data;
|
|
60
313
|
}
|
|
61
314
|
|
|
62
315
|
// src/modules/users/fetchUserByForeignId.ts
|
|
63
316
|
async function fetchUserByForeignId(client, data) {
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
317
|
+
const response = await client.projectInstance.get(
|
|
318
|
+
"/users/by-foreign-id",
|
|
319
|
+
{ params: data }
|
|
320
|
+
);
|
|
321
|
+
return response.data;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// src/modules/users/fetchUserByUsername.ts
|
|
325
|
+
async function fetchUserByUsername(client, data) {
|
|
326
|
+
const response = await client.projectInstance.get(
|
|
327
|
+
"/users/by-username",
|
|
328
|
+
{ params: data }
|
|
329
|
+
);
|
|
330
|
+
return response.data;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// src/modules/users/fetchUserSuggestions.ts
|
|
334
|
+
async function fetchUserSuggestions(client, data) {
|
|
335
|
+
const response = await client.projectInstance.get(
|
|
336
|
+
"/users/suggestions",
|
|
337
|
+
{ params: data }
|
|
338
|
+
);
|
|
339
|
+
return response.data;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// src/modules/users/checkUsernameAvailability.ts
|
|
343
|
+
async function checkUsernameAvailability(client, data) {
|
|
344
|
+
const response = await client.projectInstance.get(
|
|
345
|
+
"/users/check-username",
|
|
346
|
+
{ params: data }
|
|
347
|
+
);
|
|
348
|
+
return response.data;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// src/core/multipart.ts
|
|
352
|
+
function appendField(form, key, value) {
|
|
353
|
+
if (value === void 0) return;
|
|
354
|
+
form.append(
|
|
355
|
+
key,
|
|
356
|
+
typeof value === "object" ? JSON.stringify(value) : String(value)
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
function appendFields(form, fields) {
|
|
360
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
361
|
+
appendField(form, key, value);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
function appendFile(form, field, file, opts) {
|
|
365
|
+
const name = opts?.filename ?? (file instanceof File && file.name ? file.name : void 0) ?? opts?.fallback ?? "upload";
|
|
366
|
+
form.append(field, file, name);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// src/modules/users/updateUser.ts
|
|
370
|
+
async function updateUser(client, data) {
|
|
371
|
+
const { userId, avatarFile, bannerFile, ...body } = data;
|
|
372
|
+
const path = `/users/${userId}`;
|
|
373
|
+
if (avatarFile || bannerFile) {
|
|
374
|
+
const formData = new FormData();
|
|
375
|
+
if (avatarFile) {
|
|
376
|
+
appendFile(formData, "avatarFile", avatarFile.file, { fallback: "avatar" });
|
|
377
|
+
appendField(formData, "avatarFile.options", avatarFile.options);
|
|
378
|
+
}
|
|
379
|
+
if (bannerFile) {
|
|
380
|
+
appendFile(formData, "bannerFile", bannerFile.file, { fallback: "banner" });
|
|
381
|
+
appendField(formData, "bannerFile.options", bannerFile.options);
|
|
382
|
+
}
|
|
383
|
+
appendFields(formData, body);
|
|
384
|
+
const response2 = await client.projectInstance.patch(
|
|
385
|
+
path,
|
|
386
|
+
formData
|
|
387
|
+
);
|
|
388
|
+
return response2.data;
|
|
389
|
+
}
|
|
390
|
+
const response = await client.projectInstance.patch(path, body);
|
|
391
|
+
return response.data;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// src/modules/users/fetchFollowersByUserId.ts
|
|
395
|
+
async function fetchFollowersByUserId(client, data) {
|
|
396
|
+
const { userId, ...params } = data;
|
|
397
|
+
const response = await client.projectInstance.get(`/users/${userId}/followers`, { params });
|
|
398
|
+
return response.data;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// src/modules/users/fetchFollowersCountByUserId.ts
|
|
402
|
+
async function fetchFollowersCountByUserId(client, data) {
|
|
403
|
+
const { userId } = data;
|
|
404
|
+
const response = await client.projectInstance.get(
|
|
405
|
+
`/users/${userId}/followers-count`
|
|
406
|
+
);
|
|
407
|
+
return response.data;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// src/modules/users/fetchFollowingByUserId.ts
|
|
411
|
+
async function fetchFollowingByUserId(client, data) {
|
|
412
|
+
const { userId, ...params } = data;
|
|
413
|
+
const response = await client.projectInstance.get(`/users/${userId}/following`, { params });
|
|
414
|
+
return response.data;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// src/modules/users/fetchFollowingCountByUserId.ts
|
|
418
|
+
async function fetchFollowingCountByUserId(client, data) {
|
|
419
|
+
const { userId } = data;
|
|
420
|
+
const response = await client.projectInstance.get(
|
|
421
|
+
`/users/${userId}/following-count`
|
|
422
|
+
);
|
|
423
|
+
return response.data;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// src/modules/users/fetchConnectionsByUserId.ts
|
|
427
|
+
async function fetchConnectionsByUserId(client, data) {
|
|
428
|
+
const { userId, ...params } = data;
|
|
429
|
+
const response = await client.projectInstance.get(`/users/${userId}/connections`, { params });
|
|
430
|
+
return response.data;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// src/modules/users/fetchConnectionsCountByUserId.ts
|
|
434
|
+
async function fetchConnectionsCountByUserId(client, data) {
|
|
435
|
+
const { userId } = data;
|
|
436
|
+
const response = await client.projectInstance.get(
|
|
437
|
+
`/users/${userId}/connections-count`
|
|
438
|
+
);
|
|
439
|
+
return response.data;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// src/modules/users/createFollow.ts
|
|
443
|
+
async function createFollow(client, data) {
|
|
444
|
+
const { userId } = data;
|
|
445
|
+
const response = await client.projectInstance.post(
|
|
446
|
+
`/users/${userId}/follow`,
|
|
447
|
+
{}
|
|
448
|
+
);
|
|
449
|
+
return response.data;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// src/modules/users/deleteFollow.ts
|
|
453
|
+
async function deleteFollow(client, data) {
|
|
454
|
+
const { userId } = data;
|
|
455
|
+
await client.projectInstance.delete(`/users/${userId}/follow`);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// src/modules/users/fetchFollowStatus.ts
|
|
459
|
+
async function fetchFollowStatus(client, data) {
|
|
460
|
+
const { userId } = data;
|
|
461
|
+
const response = await client.projectInstance.get(
|
|
462
|
+
`/users/${userId}/follow`
|
|
463
|
+
);
|
|
464
|
+
return response.data;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// src/modules/users/requestConnection.ts
|
|
468
|
+
async function requestConnection(client, data) {
|
|
469
|
+
const { userId, ...body } = data;
|
|
470
|
+
const response = await client.projectInstance.post(
|
|
471
|
+
`/users/${userId}/connection`,
|
|
472
|
+
body
|
|
473
|
+
);
|
|
474
|
+
return response.data;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// src/modules/users/fetchConnectionStatus.ts
|
|
478
|
+
async function fetchConnectionStatus(client, data) {
|
|
479
|
+
const { userId } = data;
|
|
480
|
+
const response = await client.projectInstance.get(
|
|
481
|
+
`/users/${userId}/connection`
|
|
482
|
+
);
|
|
483
|
+
return response.data;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// src/modules/users/removeConnectionByUserId.ts
|
|
487
|
+
async function removeConnectionByUserId(client, data) {
|
|
488
|
+
const { userId } = data;
|
|
489
|
+
const response = await client.projectInstance.delete(
|
|
490
|
+
`/users/${userId}/connection`
|
|
491
|
+
);
|
|
79
492
|
return response.data;
|
|
80
493
|
}
|
|
81
494
|
|
|
82
495
|
// src/modules/entities/index.ts
|
|
83
496
|
var entities_exports = {};
|
|
84
497
|
__export(entities_exports, {
|
|
498
|
+
addReaction: () => addReaction,
|
|
85
499
|
createEntity: () => createEntity,
|
|
86
500
|
deleteEntity: () => deleteEntity,
|
|
501
|
+
fetchDrafts: () => fetchDrafts,
|
|
87
502
|
fetchEntity: () => fetchEntity,
|
|
88
503
|
fetchEntityByForeignId: () => fetchEntityByForeignId,
|
|
89
504
|
fetchEntityByShortId: () => fetchEntityByShortId,
|
|
90
505
|
fetchManyEntities: () => fetchManyEntities,
|
|
506
|
+
fetchReactions: () => fetchReactions,
|
|
507
|
+
fetchTopComment: () => fetchTopComment,
|
|
508
|
+
getUserReaction: () => getUserReaction,
|
|
509
|
+
isEntitySaved: () => isEntitySaved,
|
|
510
|
+
publishDraft: () => publishDraft,
|
|
511
|
+
removeReaction: () => removeReaction,
|
|
91
512
|
updateEntity: () => updateEntity
|
|
92
513
|
});
|
|
93
514
|
|
|
94
515
|
// src/modules/entities/createEntity.ts
|
|
95
516
|
async function createEntity(client, data) {
|
|
96
517
|
const path = `/entities`;
|
|
97
|
-
const response = await client.
|
|
518
|
+
const response = await client.projectInstance.post(path, data);
|
|
98
519
|
return response.data;
|
|
99
520
|
}
|
|
100
521
|
|
|
101
522
|
// src/modules/entities/fetchEntity.ts
|
|
102
523
|
async function fetchEntity(client, data) {
|
|
103
|
-
const
|
|
104
|
-
const response = await client.
|
|
524
|
+
const { entityId, ...params } = data;
|
|
525
|
+
const response = await client.projectInstance.get(
|
|
526
|
+
`/entities/${entityId}`,
|
|
527
|
+
{ params }
|
|
528
|
+
);
|
|
105
529
|
return response.data;
|
|
106
530
|
}
|
|
107
531
|
|
|
108
532
|
// src/modules/entities/fetchEntityByForeignId.ts
|
|
109
533
|
async function fetchEntityByForeignId(client, data) {
|
|
110
534
|
const path = `/entities/by-foreign-id`;
|
|
111
|
-
const response = await client.
|
|
535
|
+
const response = await client.projectInstance.get(path, {
|
|
536
|
+
params: data
|
|
537
|
+
});
|
|
112
538
|
return response.data;
|
|
113
539
|
}
|
|
114
540
|
|
|
115
541
|
// src/modules/entities/fetchEntityByShortId.ts
|
|
116
542
|
async function fetchEntityByShortId(client, data) {
|
|
117
543
|
const path = `/entities/by-short-id`;
|
|
118
|
-
const response = await client.
|
|
544
|
+
const response = await client.projectInstance.get(path, {
|
|
545
|
+
params: data
|
|
546
|
+
});
|
|
119
547
|
return response.data;
|
|
120
548
|
}
|
|
121
549
|
|
|
122
550
|
// src/modules/entities/fetchManyEntities.ts
|
|
123
551
|
async function fetchManyEntities(client, data) {
|
|
124
552
|
const path = `/entities`;
|
|
125
|
-
const response = await client.
|
|
126
|
-
|
|
127
|
-
|
|
553
|
+
const response = await client.projectInstance.get(
|
|
554
|
+
path,
|
|
555
|
+
{
|
|
556
|
+
params: data
|
|
557
|
+
}
|
|
558
|
+
);
|
|
128
559
|
return response.data;
|
|
129
560
|
}
|
|
130
561
|
|
|
131
562
|
// src/modules/entities/updateEntity.ts
|
|
132
563
|
async function updateEntity(client, data) {
|
|
133
564
|
const { entityId, ...restOfProps } = data;
|
|
134
|
-
const path = `/entities/${
|
|
135
|
-
const response = await client.
|
|
565
|
+
const path = `/entities/${entityId}`;
|
|
566
|
+
const response = await client.projectInstance.patch(
|
|
567
|
+
path,
|
|
568
|
+
restOfProps
|
|
569
|
+
);
|
|
136
570
|
return response.data;
|
|
137
571
|
}
|
|
138
572
|
|
|
139
573
|
// src/modules/entities/deleteEntity.ts
|
|
140
574
|
async function deleteEntity(client, data) {
|
|
141
575
|
const path = `/entities/${data.entityId}`;
|
|
142
|
-
const response = await client.
|
|
576
|
+
const response = await client.projectInstance.delete(path);
|
|
577
|
+
return response.data;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// src/modules/entities/fetchDrafts.ts
|
|
581
|
+
async function fetchDrafts(client, data) {
|
|
582
|
+
const response = await client.projectInstance.get(
|
|
583
|
+
"/entities/drafts",
|
|
584
|
+
{ params: data }
|
|
585
|
+
);
|
|
586
|
+
return response.data;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// src/modules/entities/publishDraft.ts
|
|
590
|
+
async function publishDraft(client, data) {
|
|
591
|
+
const { entityId } = data;
|
|
592
|
+
const response = await client.projectInstance.patch(
|
|
593
|
+
`/entities/${entityId}/publish`
|
|
594
|
+
);
|
|
595
|
+
return response.data;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// src/modules/entities/fetchTopComment.ts
|
|
599
|
+
async function fetchTopComment(client, data) {
|
|
600
|
+
const { entityId } = data;
|
|
601
|
+
const response = await client.projectInstance.get(
|
|
602
|
+
`/entities/${entityId}/top-comment`
|
|
603
|
+
);
|
|
604
|
+
return response.data;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// src/modules/entities/addReaction.ts
|
|
608
|
+
async function addReaction(client, data) {
|
|
609
|
+
const { entityId, reactionType } = data;
|
|
610
|
+
const response = await client.projectInstance.post(
|
|
611
|
+
`/entities/${entityId}/reactions`,
|
|
612
|
+
{ reactionType }
|
|
613
|
+
);
|
|
614
|
+
return response.data;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// src/modules/entities/removeReaction.ts
|
|
618
|
+
async function removeReaction(client, data) {
|
|
619
|
+
const { entityId } = data;
|
|
620
|
+
const response = await client.projectInstance.delete(
|
|
621
|
+
`/entities/${entityId}/reactions`
|
|
622
|
+
);
|
|
623
|
+
return response.data;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// src/modules/entities/fetchReactions.ts
|
|
627
|
+
async function fetchReactions(client, data) {
|
|
628
|
+
const { entityId, ...params } = data;
|
|
629
|
+
const response = await client.projectInstance.get(
|
|
630
|
+
`/entities/${entityId}/reactions`,
|
|
631
|
+
{ params }
|
|
632
|
+
);
|
|
633
|
+
return response.data;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// src/modules/entities/getUserReaction.ts
|
|
637
|
+
async function getUserReaction(client, data) {
|
|
638
|
+
const { entityId } = data;
|
|
639
|
+
const response = await client.projectInstance.get(
|
|
640
|
+
`/entities/${entityId}/reactions/me`
|
|
641
|
+
);
|
|
642
|
+
return response.data;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
// src/modules/entities/isEntitySaved.ts
|
|
646
|
+
async function isEntitySaved(client, data) {
|
|
647
|
+
const response = await client.projectInstance.get(
|
|
648
|
+
"/entities/is-entity-saved",
|
|
649
|
+
{ params: data }
|
|
650
|
+
);
|
|
143
651
|
return response.data;
|
|
144
652
|
}
|
|
145
653
|
|
|
146
654
|
// src/modules/comments/index.ts
|
|
147
655
|
var comments_exports = {};
|
|
148
656
|
__export(comments_exports, {
|
|
657
|
+
addReaction: () => addReaction2,
|
|
658
|
+
createComment: () => createComment,
|
|
659
|
+
deleteComment: () => deleteComment,
|
|
149
660
|
fetchComment: () => fetchComment,
|
|
150
|
-
fetchCommentByForeignId: () => fetchCommentByForeignId
|
|
661
|
+
fetchCommentByForeignId: () => fetchCommentByForeignId,
|
|
662
|
+
fetchManyComments: () => fetchManyComments,
|
|
663
|
+
fetchReactions: () => fetchReactions2,
|
|
664
|
+
getUserReaction: () => getUserReaction2,
|
|
665
|
+
removeReaction: () => removeReaction2,
|
|
666
|
+
updateComment: () => updateComment
|
|
151
667
|
});
|
|
152
668
|
|
|
669
|
+
// src/modules/comments/createComment.ts
|
|
670
|
+
async function createComment(client, data) {
|
|
671
|
+
const response = await client.projectInstance.post(
|
|
672
|
+
"/comments",
|
|
673
|
+
data
|
|
674
|
+
);
|
|
675
|
+
return response.data;
|
|
676
|
+
}
|
|
677
|
+
|
|
153
678
|
// src/modules/comments/fetchComment.ts
|
|
154
679
|
async function fetchComment(client, data) {
|
|
155
|
-
const
|
|
156
|
-
const response = await client.
|
|
680
|
+
const { commentId, ...params } = data;
|
|
681
|
+
const response = await client.projectInstance.get(
|
|
682
|
+
`/comments/${commentId}`,
|
|
683
|
+
{ params }
|
|
684
|
+
);
|
|
157
685
|
return response.data;
|
|
158
686
|
}
|
|
159
687
|
|
|
160
688
|
// src/modules/comments/fetchCommentByForeignId.ts
|
|
161
689
|
async function fetchCommentByForeignId(client, data) {
|
|
162
690
|
const path = `/comments/by-foreign-id`;
|
|
163
|
-
const response = await client.
|
|
691
|
+
const response = await client.projectInstance.get(path, {
|
|
692
|
+
params: data
|
|
693
|
+
});
|
|
694
|
+
return response.data;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
// src/modules/comments/updateComment.ts
|
|
698
|
+
async function updateComment(client, data) {
|
|
699
|
+
const { commentId, ...restOfProps } = data;
|
|
700
|
+
const path = `/comments/${commentId}`;
|
|
701
|
+
const response = await client.projectInstance.patch(
|
|
702
|
+
path,
|
|
703
|
+
restOfProps
|
|
704
|
+
);
|
|
705
|
+
return response.data;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
// src/modules/comments/deleteComment.ts
|
|
709
|
+
async function deleteComment(client, data) {
|
|
710
|
+
const path = `/comments/${data.commentId}`;
|
|
711
|
+
const response = await client.projectInstance.delete(path);
|
|
712
|
+
return response.data;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
// src/modules/comments/fetchManyComments.ts
|
|
716
|
+
async function fetchManyComments(client, data) {
|
|
717
|
+
const response = await client.projectInstance.get(
|
|
718
|
+
"/comments",
|
|
719
|
+
{ params: data }
|
|
720
|
+
);
|
|
721
|
+
return response.data;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// src/modules/comments/addReaction.ts
|
|
725
|
+
async function addReaction2(client, data) {
|
|
726
|
+
const { commentId, reactionType } = data;
|
|
727
|
+
const response = await client.projectInstance.post(
|
|
728
|
+
`/comments/${commentId}/reactions`,
|
|
729
|
+
{ reactionType }
|
|
730
|
+
);
|
|
731
|
+
return response.data;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
// src/modules/comments/removeReaction.ts
|
|
735
|
+
async function removeReaction2(client, data) {
|
|
736
|
+
const { commentId } = data;
|
|
737
|
+
const response = await client.projectInstance.delete(
|
|
738
|
+
`/comments/${commentId}/reactions`
|
|
739
|
+
);
|
|
740
|
+
return response.data;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
// src/modules/comments/fetchReactions.ts
|
|
744
|
+
async function fetchReactions2(client, data) {
|
|
745
|
+
const { commentId, ...params } = data;
|
|
746
|
+
const response = await client.projectInstance.get(
|
|
747
|
+
`/comments/${commentId}/reactions`,
|
|
748
|
+
{ params }
|
|
749
|
+
);
|
|
750
|
+
return response.data;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
// src/modules/comments/getUserReaction.ts
|
|
754
|
+
async function getUserReaction2(client, data) {
|
|
755
|
+
const { commentId } = data;
|
|
756
|
+
const response = await client.projectInstance.get(
|
|
757
|
+
`/comments/${commentId}/reactions/me`
|
|
758
|
+
);
|
|
759
|
+
return response.data;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// src/modules/spaces/index.ts
|
|
763
|
+
var spaces_exports = {};
|
|
764
|
+
__export(spaces_exports, {
|
|
765
|
+
approveMembership: () => approveMembership,
|
|
766
|
+
banMember: () => banMember,
|
|
767
|
+
checkMyMembership: () => checkMyMembership,
|
|
768
|
+
checkSlugAvailability: () => checkSlugAvailability,
|
|
769
|
+
createRule: () => createRule,
|
|
770
|
+
createSpace: () => createSpace,
|
|
771
|
+
declineMembership: () => declineMembership,
|
|
772
|
+
deleteRule: () => deleteRule,
|
|
773
|
+
deleteSpace: () => deleteSpace,
|
|
774
|
+
fetchChildSpaces: () => fetchChildSpaces,
|
|
775
|
+
fetchDigestConfig: () => fetchDigestConfig,
|
|
776
|
+
fetchManyRules: () => fetchManyRules,
|
|
777
|
+
fetchManySpaces: () => fetchManySpaces,
|
|
778
|
+
fetchRule: () => fetchRule,
|
|
779
|
+
fetchSpace: () => fetchSpace,
|
|
780
|
+
fetchSpaceBreadcrumb: () => fetchSpaceBreadcrumb,
|
|
781
|
+
fetchSpaceByShortId: () => fetchSpaceByShortId,
|
|
782
|
+
fetchSpaceBySlug: () => fetchSpaceBySlug,
|
|
783
|
+
fetchSpaceMembers: () => fetchSpaceMembers,
|
|
784
|
+
fetchSpaceTeam: () => fetchSpaceTeam,
|
|
785
|
+
fetchUserSpaces: () => fetchUserSpaces,
|
|
786
|
+
getSpaceConversation: () => getSpaceConversation,
|
|
787
|
+
handleCommentReport: () => handleCommentReport,
|
|
788
|
+
handleEntityReport: () => handleEntityReport,
|
|
789
|
+
handleSpaceChatReport: () => handleSpaceChatReport,
|
|
790
|
+
joinSpace: () => joinSpace,
|
|
791
|
+
leaveSpace: () => leaveSpace,
|
|
792
|
+
moderateSpaceChatMessage: () => moderateSpaceChatMessage,
|
|
793
|
+
moderateSpaceComment: () => moderateSpaceComment,
|
|
794
|
+
moderateSpaceEntity: () => moderateSpaceEntity,
|
|
795
|
+
reorderRules: () => reorderRules,
|
|
796
|
+
unbanMember: () => unbanMember,
|
|
797
|
+
updateDigestConfig: () => updateDigestConfig,
|
|
798
|
+
updateMemberRole: () => updateMemberRole,
|
|
799
|
+
updateRule: () => updateRule,
|
|
800
|
+
updateSpace: () => updateSpace
|
|
801
|
+
});
|
|
802
|
+
|
|
803
|
+
// src/modules/spaces/createSpace.ts
|
|
804
|
+
async function createSpace(client, data) {
|
|
805
|
+
const response = await client.projectInstance.post("/spaces", data);
|
|
806
|
+
return response.data;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
// src/modules/spaces/fetchManySpaces.ts
|
|
810
|
+
async function fetchManySpaces(client, data) {
|
|
811
|
+
const response = await client.projectInstance.get(
|
|
812
|
+
"/spaces",
|
|
813
|
+
{ params: data }
|
|
814
|
+
);
|
|
815
|
+
return response.data;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
// src/modules/spaces/fetchSpace.ts
|
|
819
|
+
async function fetchSpace(client, data) {
|
|
820
|
+
const { spaceId } = data;
|
|
821
|
+
const response = await client.projectInstance.get(
|
|
822
|
+
`/spaces/${spaceId}`
|
|
823
|
+
);
|
|
824
|
+
return response.data;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
// src/modules/spaces/fetchSpaceByShortId.ts
|
|
828
|
+
async function fetchSpaceByShortId(client, data) {
|
|
829
|
+
const response = await client.projectInstance.get(
|
|
830
|
+
"/spaces/by-short-id",
|
|
831
|
+
{ params: data }
|
|
832
|
+
);
|
|
833
|
+
return response.data;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
// src/modules/spaces/fetchSpaceBySlug.ts
|
|
837
|
+
async function fetchSpaceBySlug(client, data) {
|
|
838
|
+
const response = await client.projectInstance.get(
|
|
839
|
+
"/spaces/by-slug",
|
|
840
|
+
{ params: data }
|
|
841
|
+
);
|
|
842
|
+
return response.data;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
// src/modules/spaces/fetchUserSpaces.ts
|
|
846
|
+
async function fetchUserSpaces(client, data) {
|
|
847
|
+
const response = await client.projectInstance.get(
|
|
848
|
+
"/spaces/user-spaces",
|
|
849
|
+
{ params: data }
|
|
850
|
+
);
|
|
851
|
+
return response.data;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
// src/modules/spaces/checkSlugAvailability.ts
|
|
855
|
+
async function checkSlugAvailability(client, data) {
|
|
856
|
+
const response = await client.projectInstance.get(
|
|
857
|
+
"/spaces/check-slug",
|
|
858
|
+
{ params: data }
|
|
859
|
+
);
|
|
860
|
+
return response.data;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
// src/modules/spaces/updateSpace.ts
|
|
864
|
+
async function updateSpace(client, data) {
|
|
865
|
+
const { spaceId, ...body } = data;
|
|
866
|
+
const response = await client.projectInstance.patch(
|
|
867
|
+
`/spaces/${spaceId}`,
|
|
868
|
+
body
|
|
869
|
+
);
|
|
870
|
+
return response.data;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
// src/modules/spaces/deleteSpace.ts
|
|
874
|
+
async function deleteSpace(client, data) {
|
|
875
|
+
const { spaceId } = data;
|
|
876
|
+
const response = await client.projectInstance.delete(
|
|
877
|
+
`/spaces/${spaceId}`
|
|
878
|
+
);
|
|
879
|
+
return response.data;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
// src/modules/spaces/fetchChildSpaces.ts
|
|
883
|
+
async function fetchChildSpaces(client, data) {
|
|
884
|
+
const { spaceId, ...params } = data;
|
|
885
|
+
const response = await client.projectInstance.get(
|
|
886
|
+
`/spaces/${spaceId}/children`,
|
|
887
|
+
{ params }
|
|
888
|
+
);
|
|
889
|
+
return response.data;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
// src/modules/spaces/fetchSpaceBreadcrumb.ts
|
|
893
|
+
async function fetchSpaceBreadcrumb(client, data) {
|
|
894
|
+
const { spaceId } = data;
|
|
895
|
+
const response = await client.projectInstance.get(
|
|
896
|
+
`/spaces/${spaceId}/breadcrumb`
|
|
897
|
+
);
|
|
898
|
+
return response.data;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
// src/modules/spaces/joinSpace.ts
|
|
902
|
+
async function joinSpace(client, data) {
|
|
903
|
+
const { spaceId } = data;
|
|
904
|
+
const response = await client.projectInstance.post(
|
|
905
|
+
`/spaces/${spaceId}/join`
|
|
906
|
+
);
|
|
907
|
+
return response.data;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
// src/modules/spaces/leaveSpace.ts
|
|
911
|
+
async function leaveSpace(client, data) {
|
|
912
|
+
const { spaceId } = data;
|
|
913
|
+
const response = await client.projectInstance.delete(
|
|
914
|
+
`/spaces/${spaceId}/leave`
|
|
915
|
+
);
|
|
916
|
+
return response.data;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
// src/modules/spaces/checkMyMembership.ts
|
|
920
|
+
async function checkMyMembership(client, data) {
|
|
921
|
+
const { spaceId } = data;
|
|
922
|
+
const response = await client.projectInstance.get(
|
|
923
|
+
`/spaces/${spaceId}/membership/me`
|
|
924
|
+
);
|
|
925
|
+
return response.data;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
// src/modules/spaces/fetchSpaceMembers.ts
|
|
929
|
+
async function fetchSpaceMembers(client, data) {
|
|
930
|
+
const { spaceId, ...params } = data;
|
|
931
|
+
const response = await client.projectInstance.get(
|
|
932
|
+
`/spaces/${spaceId}/members`,
|
|
933
|
+
{ params }
|
|
934
|
+
);
|
|
935
|
+
return response.data;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
// src/modules/spaces/fetchSpaceTeam.ts
|
|
939
|
+
async function fetchSpaceTeam(client, data) {
|
|
940
|
+
const { spaceId } = data;
|
|
941
|
+
const response = await client.projectInstance.get(
|
|
942
|
+
`/spaces/${spaceId}/team`
|
|
943
|
+
);
|
|
944
|
+
return response.data;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
// src/modules/spaces/updateMemberRole.ts
|
|
948
|
+
async function updateMemberRole(client, data) {
|
|
949
|
+
const { spaceId, memberId, role } = data;
|
|
950
|
+
const response = await client.projectInstance.patch(
|
|
951
|
+
`/spaces/${spaceId}/members/${memberId}/role`,
|
|
952
|
+
{ role }
|
|
953
|
+
);
|
|
954
|
+
return response.data;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
// src/modules/spaces/approveMembership.ts
|
|
958
|
+
async function approveMembership(client, data) {
|
|
959
|
+
const { spaceId, memberId } = data;
|
|
960
|
+
const response = await client.projectInstance.patch(
|
|
961
|
+
`/spaces/${spaceId}/members/${memberId}/approve`
|
|
962
|
+
);
|
|
963
|
+
return response.data;
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
// src/modules/spaces/declineMembership.ts
|
|
967
|
+
async function declineMembership(client, data) {
|
|
968
|
+
const { spaceId, memberId } = data;
|
|
969
|
+
const response = await client.projectInstance.patch(
|
|
970
|
+
`/spaces/${spaceId}/members/${memberId}/decline`
|
|
971
|
+
);
|
|
972
|
+
return response.data;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
// src/modules/spaces/banMember.ts
|
|
976
|
+
async function banMember(client, data) {
|
|
977
|
+
const { spaceId, memberId } = data;
|
|
978
|
+
const response = await client.projectInstance.patch(
|
|
979
|
+
`/spaces/${spaceId}/members/${memberId}/ban`
|
|
980
|
+
);
|
|
981
|
+
return response.data;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
// src/modules/spaces/unbanMember.ts
|
|
985
|
+
async function unbanMember(client, data) {
|
|
986
|
+
const { spaceId, memberId } = data;
|
|
987
|
+
const response = await client.projectInstance.patch(
|
|
988
|
+
`/spaces/${spaceId}/members/${memberId}/unban`
|
|
989
|
+
);
|
|
990
|
+
return response.data;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
// src/modules/spaces/fetchManyRules.ts
|
|
994
|
+
async function fetchManyRules(client, data) {
|
|
995
|
+
const { spaceId } = data;
|
|
996
|
+
const response = await client.projectInstance.get(
|
|
997
|
+
`/spaces/${spaceId}/rules`
|
|
998
|
+
);
|
|
999
|
+
return response.data;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
// src/modules/spaces/fetchRule.ts
|
|
1003
|
+
async function fetchRule(client, data) {
|
|
1004
|
+
const { spaceId, ruleId } = data;
|
|
1005
|
+
const response = await client.projectInstance.get(
|
|
1006
|
+
`/spaces/${spaceId}/rules/${ruleId}`
|
|
1007
|
+
);
|
|
1008
|
+
return response.data;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
// src/modules/spaces/createRule.ts
|
|
1012
|
+
async function createRule(client, data) {
|
|
1013
|
+
const { spaceId, ...body } = data;
|
|
1014
|
+
const response = await client.projectInstance.post(
|
|
1015
|
+
`/spaces/${spaceId}/rules`,
|
|
1016
|
+
body
|
|
1017
|
+
);
|
|
1018
|
+
return response.data;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
// src/modules/spaces/updateRule.ts
|
|
1022
|
+
async function updateRule(client, data) {
|
|
1023
|
+
const { spaceId, ruleId, ...body } = data;
|
|
1024
|
+
const response = await client.projectInstance.patch(
|
|
1025
|
+
`/spaces/${spaceId}/rules/${ruleId}`,
|
|
1026
|
+
body
|
|
1027
|
+
);
|
|
1028
|
+
return response.data;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
// src/modules/spaces/deleteRule.ts
|
|
1032
|
+
async function deleteRule(client, data) {
|
|
1033
|
+
const { spaceId, ruleId } = data;
|
|
1034
|
+
const response = await client.projectInstance.delete(
|
|
1035
|
+
`/spaces/${spaceId}/rules/${ruleId}`
|
|
1036
|
+
);
|
|
1037
|
+
return response.data;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
// src/modules/spaces/reorderRules.ts
|
|
1041
|
+
async function reorderRules(client, data) {
|
|
1042
|
+
const { spaceId, ruleIds } = data;
|
|
1043
|
+
const response = await client.projectInstance.patch(
|
|
1044
|
+
`/spaces/${spaceId}/rules/reorder`,
|
|
1045
|
+
{ ruleIds }
|
|
1046
|
+
);
|
|
1047
|
+
return response.data;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
// src/modules/spaces/handleEntityReport.ts
|
|
1051
|
+
async function handleEntityReport(client, data) {
|
|
1052
|
+
const { spaceId, reportId, ...body } = data;
|
|
1053
|
+
const response = await client.projectInstance.patch(
|
|
1054
|
+
`/spaces/${spaceId}/reports/entity/${reportId}`,
|
|
1055
|
+
body
|
|
1056
|
+
);
|
|
1057
|
+
return response.data;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
// src/modules/spaces/handleCommentReport.ts
|
|
1061
|
+
async function handleCommentReport(client, data) {
|
|
1062
|
+
const { spaceId, reportId, ...body } = data;
|
|
1063
|
+
const response = await client.projectInstance.patch(
|
|
1064
|
+
`/spaces/${spaceId}/reports/comment/${reportId}`,
|
|
1065
|
+
body
|
|
1066
|
+
);
|
|
1067
|
+
return response.data;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
// src/modules/spaces/moderateSpaceEntity.ts
|
|
1071
|
+
async function moderateSpaceEntity(client, data) {
|
|
1072
|
+
const { spaceId, entityId, ...body } = data;
|
|
1073
|
+
const response = await client.projectInstance.patch(
|
|
1074
|
+
`/spaces/${spaceId}/entities/${entityId}/moderation`,
|
|
1075
|
+
body
|
|
1076
|
+
);
|
|
1077
|
+
return response.data;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
// src/modules/spaces/moderateSpaceComment.ts
|
|
1081
|
+
async function moderateSpaceComment(client, data) {
|
|
1082
|
+
const { spaceId, commentId, ...body } = data;
|
|
1083
|
+
const response = await client.projectInstance.patch(
|
|
1084
|
+
`/spaces/${spaceId}/comments/${commentId}/moderation`,
|
|
1085
|
+
body
|
|
1086
|
+
);
|
|
1087
|
+
return response.data;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
// src/modules/spaces/fetchDigestConfig.ts
|
|
1091
|
+
async function fetchDigestConfig(client, data) {
|
|
1092
|
+
const { spaceId } = data;
|
|
1093
|
+
const response = await client.projectInstance.get(
|
|
1094
|
+
`/spaces/${spaceId}/digest-config`
|
|
1095
|
+
);
|
|
1096
|
+
return response.data;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
// src/modules/spaces/updateDigestConfig.ts
|
|
1100
|
+
async function updateDigestConfig(client, data) {
|
|
1101
|
+
const { spaceId, ...body } = data;
|
|
1102
|
+
const response = await client.projectInstance.patch(
|
|
1103
|
+
`/spaces/${spaceId}/digest-config`,
|
|
1104
|
+
body
|
|
1105
|
+
);
|
|
1106
|
+
return response.data;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
// src/modules/spaces/getSpaceConversation.ts
|
|
1110
|
+
async function getSpaceConversation(client, data) {
|
|
1111
|
+
const { spaceId } = data;
|
|
1112
|
+
const response = await client.projectInstance.get(
|
|
1113
|
+
`/spaces/${spaceId}/conversation`
|
|
1114
|
+
);
|
|
1115
|
+
return response.data;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
// src/modules/spaces/moderateSpaceChatMessage.ts
|
|
1119
|
+
async function moderateSpaceChatMessage(client, data) {
|
|
1120
|
+
const { spaceId, messageId, ...body } = data;
|
|
1121
|
+
const response = await client.projectInstance.patch(
|
|
1122
|
+
`/spaces/${spaceId}/chat/messages/${messageId}/moderation`,
|
|
1123
|
+
body
|
|
1124
|
+
);
|
|
1125
|
+
return response.data;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
// src/modules/spaces/handleSpaceChatReport.ts
|
|
1129
|
+
async function handleSpaceChatReport(client, data) {
|
|
1130
|
+
const { spaceId, reportId, ...body } = data;
|
|
1131
|
+
const response = await client.projectInstance.patch(
|
|
1132
|
+
`/spaces/${spaceId}/chat/reports/${reportId}`,
|
|
1133
|
+
body
|
|
1134
|
+
);
|
|
1135
|
+
return response.data;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
// src/modules/collections/index.ts
|
|
1139
|
+
var collections_exports = {};
|
|
1140
|
+
__export(collections_exports, {
|
|
1141
|
+
addEntityToCollection: () => addEntityToCollection,
|
|
1142
|
+
createNewCollection: () => createNewCollection,
|
|
1143
|
+
deleteCollection: () => deleteCollection,
|
|
1144
|
+
fetchCollectionEntities: () => fetchCollectionEntities,
|
|
1145
|
+
fetchRootCollection: () => fetchRootCollection,
|
|
1146
|
+
fetchSubCollections: () => fetchSubCollections,
|
|
1147
|
+
removeEntityFromCollection: () => removeEntityFromCollection,
|
|
1148
|
+
updateCollection: () => updateCollection
|
|
1149
|
+
});
|
|
1150
|
+
|
|
1151
|
+
// src/modules/collections/fetchRootCollection.ts
|
|
1152
|
+
async function fetchRootCollection(client) {
|
|
1153
|
+
const response = await client.projectInstance.get(
|
|
1154
|
+
"/collections/root"
|
|
1155
|
+
);
|
|
1156
|
+
return response.data;
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
// src/modules/collections/fetchSubCollections.ts
|
|
1160
|
+
async function fetchSubCollections(client, data) {
|
|
1161
|
+
const { collectionId } = data;
|
|
1162
|
+
const response = await client.projectInstance.get(
|
|
1163
|
+
`/collections/${collectionId}/sub-collections`
|
|
1164
|
+
);
|
|
1165
|
+
return response.data;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
// src/modules/collections/createNewCollection.ts
|
|
1169
|
+
async function createNewCollection(client, data) {
|
|
1170
|
+
const { collectionId, ...body } = data;
|
|
1171
|
+
const response = await client.projectInstance.post(
|
|
1172
|
+
`/collections/${collectionId}/sub-collections`,
|
|
1173
|
+
body
|
|
1174
|
+
);
|
|
1175
|
+
return response.data;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
// src/modules/collections/fetchCollectionEntities.ts
|
|
1179
|
+
async function fetchCollectionEntities(client, data) {
|
|
1180
|
+
const { collectionId, ...params } = data;
|
|
1181
|
+
const response = await client.projectInstance.get(
|
|
1182
|
+
`/collections/${collectionId}/entities`,
|
|
1183
|
+
{ params }
|
|
1184
|
+
);
|
|
1185
|
+
return response.data;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
// src/modules/collections/addEntityToCollection.ts
|
|
1189
|
+
async function addEntityToCollection(client, data) {
|
|
1190
|
+
const { collectionId, ...body } = data;
|
|
1191
|
+
const response = await client.projectInstance.post(
|
|
1192
|
+
`/collections/${collectionId}/entities`,
|
|
1193
|
+
body
|
|
1194
|
+
);
|
|
1195
|
+
return response.data;
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
// src/modules/collections/removeEntityFromCollection.ts
|
|
1199
|
+
async function removeEntityFromCollection(client, data) {
|
|
1200
|
+
const { collectionId, entityId } = data;
|
|
1201
|
+
const response = await client.projectInstance.delete(
|
|
1202
|
+
`/collections/${collectionId}/entities/${entityId}`
|
|
1203
|
+
);
|
|
1204
|
+
return response.data;
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
// src/modules/collections/updateCollection.ts
|
|
1208
|
+
async function updateCollection(client, data) {
|
|
1209
|
+
const { collectionId, ...body } = data;
|
|
1210
|
+
const response = await client.projectInstance.patch(
|
|
1211
|
+
`/collections/${collectionId}`,
|
|
1212
|
+
body
|
|
1213
|
+
);
|
|
1214
|
+
return response.data;
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
// src/modules/collections/deleteCollection.ts
|
|
1218
|
+
async function deleteCollection(client, data) {
|
|
1219
|
+
const { collectionId } = data;
|
|
1220
|
+
await client.projectInstance.delete(`/collections/${collectionId}`);
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
// src/modules/follows/index.ts
|
|
1224
|
+
var follows_exports = {};
|
|
1225
|
+
__export(follows_exports, {
|
|
1226
|
+
deleteFollow: () => deleteFollow2,
|
|
1227
|
+
fetchFollowers: () => fetchFollowers,
|
|
1228
|
+
fetchFollowersCount: () => fetchFollowersCount,
|
|
1229
|
+
fetchFollowing: () => fetchFollowing,
|
|
1230
|
+
fetchFollowingCount: () => fetchFollowingCount
|
|
1231
|
+
});
|
|
1232
|
+
|
|
1233
|
+
// src/modules/follows/fetchFollowing.ts
|
|
1234
|
+
async function fetchFollowing(client, data) {
|
|
1235
|
+
const response = await client.projectInstance.get("/follows/following", { params: data });
|
|
1236
|
+
return response.data;
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
// src/modules/follows/fetchFollowers.ts
|
|
1240
|
+
async function fetchFollowers(client, data) {
|
|
1241
|
+
const response = await client.projectInstance.get("/follows/followers", { params: data });
|
|
1242
|
+
return response.data;
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
// src/modules/follows/fetchFollowingCount.ts
|
|
1246
|
+
async function fetchFollowingCount(client) {
|
|
1247
|
+
const response = await client.projectInstance.get(
|
|
1248
|
+
"/follows/following-count"
|
|
1249
|
+
);
|
|
1250
|
+
return response.data;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
// src/modules/follows/fetchFollowersCount.ts
|
|
1254
|
+
async function fetchFollowersCount(client) {
|
|
1255
|
+
const response = await client.projectInstance.get(
|
|
1256
|
+
"/follows/followers-count"
|
|
1257
|
+
);
|
|
1258
|
+
return response.data;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
// src/modules/follows/deleteFollow.ts
|
|
1262
|
+
async function deleteFollow2(client, data) {
|
|
1263
|
+
const { followId } = data;
|
|
1264
|
+
await client.projectInstance.delete(`/follows/${followId}`);
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
// src/modules/connections/index.ts
|
|
1268
|
+
var connections_exports = {};
|
|
1269
|
+
__export(connections_exports, {
|
|
1270
|
+
acceptConnection: () => acceptConnection,
|
|
1271
|
+
declineConnection: () => declineConnection,
|
|
1272
|
+
fetchConnections: () => fetchConnections,
|
|
1273
|
+
fetchConnectionsCount: () => fetchConnectionsCount,
|
|
1274
|
+
fetchReceivedPendingConnections: () => fetchReceivedPendingConnections,
|
|
1275
|
+
fetchSentPendingConnections: () => fetchSentPendingConnections,
|
|
1276
|
+
removeConnection: () => removeConnection
|
|
1277
|
+
});
|
|
1278
|
+
|
|
1279
|
+
// src/modules/connections/fetchConnections.ts
|
|
1280
|
+
async function fetchConnections(client, data) {
|
|
1281
|
+
const response = await client.projectInstance.get("/connections", { params: data });
|
|
1282
|
+
return response.data;
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
// src/modules/connections/fetchConnectionsCount.ts
|
|
1286
|
+
async function fetchConnectionsCount(client) {
|
|
1287
|
+
const response = await client.projectInstance.get(
|
|
1288
|
+
"/connections/count"
|
|
1289
|
+
);
|
|
1290
|
+
return response.data;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
// src/modules/connections/fetchSentPendingConnections.ts
|
|
1294
|
+
async function fetchSentPendingConnections(client, data) {
|
|
1295
|
+
const response = await client.projectInstance.get(
|
|
1296
|
+
"/connections/pending/sent",
|
|
1297
|
+
{ params: data }
|
|
1298
|
+
);
|
|
1299
|
+
return response.data;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
// src/modules/connections/fetchReceivedPendingConnections.ts
|
|
1303
|
+
async function fetchReceivedPendingConnections(client, data) {
|
|
1304
|
+
const response = await client.projectInstance.get(
|
|
1305
|
+
"/connections/pending/received",
|
|
1306
|
+
{ params: data }
|
|
1307
|
+
);
|
|
1308
|
+
return response.data;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
// src/modules/connections/acceptConnection.ts
|
|
1312
|
+
async function acceptConnection(client, data) {
|
|
1313
|
+
const { connectionId } = data;
|
|
1314
|
+
const response = await client.projectInstance.patch(
|
|
1315
|
+
`/connections/${connectionId}/accept`,
|
|
1316
|
+
{}
|
|
1317
|
+
);
|
|
1318
|
+
return response.data;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
// src/modules/connections/declineConnection.ts
|
|
1322
|
+
async function declineConnection(client, data) {
|
|
1323
|
+
const { connectionId } = data;
|
|
1324
|
+
const response = await client.projectInstance.patch(
|
|
1325
|
+
`/connections/${connectionId}/decline`,
|
|
1326
|
+
{}
|
|
1327
|
+
);
|
|
1328
|
+
return response.data;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
// src/modules/connections/removeConnection.ts
|
|
1332
|
+
async function removeConnection(client, data) {
|
|
1333
|
+
const { connectionId } = data;
|
|
1334
|
+
await client.projectInstance.delete(`/connections/${connectionId}`);
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
// src/modules/app-notifications/index.ts
|
|
1338
|
+
var app_notifications_exports = {};
|
|
1339
|
+
__export(app_notifications_exports, {
|
|
1340
|
+
countUnreadNotifications: () => countUnreadNotifications,
|
|
1341
|
+
fetchNotifications: () => fetchNotifications,
|
|
1342
|
+
markAllNotificationsAsRead: () => markAllNotificationsAsRead,
|
|
1343
|
+
markNotificationAsRead: () => markNotificationAsRead
|
|
1344
|
+
});
|
|
1345
|
+
|
|
1346
|
+
// src/modules/app-notifications/fetchNotifications.ts
|
|
1347
|
+
async function fetchNotifications(client, data) {
|
|
1348
|
+
const response = await client.projectInstance.get("/app-notifications", { params: data });
|
|
1349
|
+
return response.data;
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
// src/modules/app-notifications/countUnreadNotifications.ts
|
|
1353
|
+
async function countUnreadNotifications(client) {
|
|
1354
|
+
const response = await client.projectInstance.get(
|
|
1355
|
+
"/app-notifications/count"
|
|
1356
|
+
);
|
|
1357
|
+
return response.data;
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
// src/modules/app-notifications/markNotificationAsRead.ts
|
|
1361
|
+
async function markNotificationAsRead(client, data) {
|
|
1362
|
+
const { notificationId } = data;
|
|
1363
|
+
await client.projectInstance.patch(
|
|
1364
|
+
`/app-notifications/${notificationId}/mark-as-read`
|
|
1365
|
+
);
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
// src/modules/app-notifications/markAllNotificationsAsRead.ts
|
|
1369
|
+
async function markAllNotificationsAsRead(client) {
|
|
1370
|
+
const response = await client.projectInstance.patch(
|
|
1371
|
+
"/app-notifications/mark-all-as-read"
|
|
1372
|
+
);
|
|
1373
|
+
return response.data;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
// src/modules/reports/index.ts
|
|
1377
|
+
var reports_exports = {};
|
|
1378
|
+
__export(reports_exports, {
|
|
1379
|
+
createReport: () => createReport,
|
|
1380
|
+
fetchModeratedReports: () => fetchModeratedReports
|
|
1381
|
+
});
|
|
1382
|
+
|
|
1383
|
+
// src/modules/reports/createReport.ts
|
|
1384
|
+
async function createReport(client, data) {
|
|
1385
|
+
const response = await client.projectInstance.post(
|
|
1386
|
+
"/reports",
|
|
1387
|
+
data
|
|
1388
|
+
);
|
|
1389
|
+
return response.data;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
// src/modules/reports/fetchModeratedReports.ts
|
|
1393
|
+
async function fetchModeratedReports(client, data) {
|
|
1394
|
+
const response = await client.projectInstance.get(
|
|
1395
|
+
"/reports/moderated",
|
|
1396
|
+
{ params: data }
|
|
1397
|
+
);
|
|
1398
|
+
return response.data;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
// src/modules/search/index.ts
|
|
1402
|
+
var search_exports = {};
|
|
1403
|
+
__export(search_exports, {
|
|
1404
|
+
askContent: () => askContent,
|
|
1405
|
+
searchContent: () => searchContent,
|
|
1406
|
+
searchSpaces: () => searchSpaces,
|
|
1407
|
+
searchUsers: () => searchUsers
|
|
1408
|
+
});
|
|
1409
|
+
|
|
1410
|
+
// src/modules/search/searchContent.ts
|
|
1411
|
+
async function searchContent(client, data) {
|
|
1412
|
+
const response = await client.projectInstance.post(
|
|
1413
|
+
"/search/content",
|
|
1414
|
+
data
|
|
1415
|
+
);
|
|
1416
|
+
return response.data;
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
// src/modules/search/searchUsers.ts
|
|
1420
|
+
async function searchUsers(client, data) {
|
|
1421
|
+
const response = await client.projectInstance.post(
|
|
1422
|
+
"/search/users",
|
|
1423
|
+
data
|
|
1424
|
+
);
|
|
1425
|
+
return response.data;
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
// src/modules/search/searchSpaces.ts
|
|
1429
|
+
async function searchSpaces(client, data) {
|
|
1430
|
+
const response = await client.projectInstance.post(
|
|
1431
|
+
"/search/spaces",
|
|
1432
|
+
data
|
|
1433
|
+
);
|
|
1434
|
+
return response.data;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
// src/modules/search/askContent.ts
|
|
1438
|
+
function parseSseBlock(block) {
|
|
1439
|
+
let event = "message";
|
|
1440
|
+
let data = "";
|
|
1441
|
+
for (const line of block.split("\n")) {
|
|
1442
|
+
if (line.startsWith("event:")) event = line.slice(6).trim();
|
|
1443
|
+
else if (line.startsWith("data:")) data += line.slice(5).trim();
|
|
1444
|
+
}
|
|
1445
|
+
if (!event) return null;
|
|
1446
|
+
let payload = void 0;
|
|
1447
|
+
if (data) {
|
|
1448
|
+
try {
|
|
1449
|
+
payload = JSON.parse(data);
|
|
1450
|
+
} catch {
|
|
1451
|
+
payload = void 0;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
switch (event) {
|
|
1455
|
+
case "token":
|
|
1456
|
+
return { type: "token", content: payload?.content ?? "" };
|
|
1457
|
+
case "sources":
|
|
1458
|
+
return {
|
|
1459
|
+
type: "sources",
|
|
1460
|
+
sources: Array.isArray(payload) ? payload : []
|
|
1461
|
+
};
|
|
1462
|
+
case "done":
|
|
1463
|
+
return { type: "done" };
|
|
1464
|
+
case "error":
|
|
1465
|
+
return { type: "error", error: payload?.error ?? "Unknown error" };
|
|
1466
|
+
default:
|
|
1467
|
+
return null;
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
async function* askContent(client, data) {
|
|
1471
|
+
const { signal, ...body } = data;
|
|
1472
|
+
const baseURL = client.projectInstance.defaults.baseURL ?? "";
|
|
1473
|
+
const authHeader = await client.getAuthHeader();
|
|
1474
|
+
const headers = {
|
|
1475
|
+
"Content-Type": "application/json"
|
|
1476
|
+
};
|
|
1477
|
+
if (authHeader) headers.Authorization = authHeader;
|
|
1478
|
+
const response = await fetch(`${baseURL}/search/ask`, {
|
|
1479
|
+
method: "POST",
|
|
1480
|
+
headers,
|
|
1481
|
+
body: JSON.stringify(body),
|
|
1482
|
+
signal
|
|
1483
|
+
});
|
|
1484
|
+
if (!response.ok || !response.body) {
|
|
1485
|
+
let message = `Request failed with status ${response.status}`;
|
|
1486
|
+
try {
|
|
1487
|
+
const json = await response.json();
|
|
1488
|
+
message = json?.error ?? message;
|
|
1489
|
+
} catch {
|
|
1490
|
+
}
|
|
1491
|
+
yield { type: "error", error: message };
|
|
1492
|
+
return;
|
|
1493
|
+
}
|
|
1494
|
+
const reader = response.body.getReader();
|
|
1495
|
+
const decoder = new TextDecoder();
|
|
1496
|
+
let buffer = "";
|
|
1497
|
+
try {
|
|
1498
|
+
while (true) {
|
|
1499
|
+
const { done, value } = await reader.read();
|
|
1500
|
+
if (done) break;
|
|
1501
|
+
buffer += decoder.decode(value, { stream: true });
|
|
1502
|
+
let boundary;
|
|
1503
|
+
while ((boundary = buffer.indexOf("\n\n")) !== -1) {
|
|
1504
|
+
const rawBlock = buffer.slice(0, boundary);
|
|
1505
|
+
buffer = buffer.slice(boundary + 2);
|
|
1506
|
+
const event = parseSseBlock(rawBlock);
|
|
1507
|
+
if (event) yield event;
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
const tail = buffer.trim();
|
|
1511
|
+
if (tail) {
|
|
1512
|
+
const event = parseSseBlock(tail);
|
|
1513
|
+
if (event) yield event;
|
|
1514
|
+
}
|
|
1515
|
+
} finally {
|
|
1516
|
+
reader.releaseLock();
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
// src/modules/storage/index.ts
|
|
1521
|
+
var storage_exports = {};
|
|
1522
|
+
__export(storage_exports, {
|
|
1523
|
+
deleteFile: () => deleteFile,
|
|
1524
|
+
getFile: () => getFile,
|
|
1525
|
+
uploadFile: () => uploadFile,
|
|
1526
|
+
uploadImage: () => uploadImage
|
|
1527
|
+
});
|
|
1528
|
+
|
|
1529
|
+
// src/modules/storage/uploadImage.ts
|
|
1530
|
+
async function uploadImage(client, data) {
|
|
1531
|
+
const { file, filename, imageOptions, ...rest } = data;
|
|
1532
|
+
const formData = new FormData();
|
|
1533
|
+
appendFile(formData, "file", file, { filename });
|
|
1534
|
+
appendFields(formData, { ...imageOptions, ...rest });
|
|
1535
|
+
const response = await client.projectInstance.post(
|
|
1536
|
+
"/storage/images",
|
|
1537
|
+
formData
|
|
1538
|
+
);
|
|
1539
|
+
return response.data;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
// src/modules/storage/uploadFile.ts
|
|
1543
|
+
async function uploadFile(client, data) {
|
|
1544
|
+
const { file, filename, ...fields } = data;
|
|
1545
|
+
const formData = new FormData();
|
|
1546
|
+
appendFile(formData, "file", file, { filename });
|
|
1547
|
+
appendFields(formData, fields);
|
|
1548
|
+
const response = await client.projectInstance.post(
|
|
1549
|
+
"/storage",
|
|
1550
|
+
formData
|
|
1551
|
+
);
|
|
1552
|
+
return response.data;
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
// src/modules/storage/getFile.ts
|
|
1556
|
+
async function getFile(client, data) {
|
|
1557
|
+
const { fileId } = data;
|
|
1558
|
+
const response = await client.projectInstance.get(
|
|
1559
|
+
`/storage/${fileId}`
|
|
1560
|
+
);
|
|
1561
|
+
return response.data;
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
// src/modules/storage/deleteFile.ts
|
|
1565
|
+
async function deleteFile(client, data) {
|
|
1566
|
+
const { fileId } = data;
|
|
1567
|
+
await client.projectInstance.delete(`/storage/${fileId}`);
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
// src/modules/oauth/index.ts
|
|
1571
|
+
var oauth_exports = {};
|
|
1572
|
+
__export(oauth_exports, {
|
|
1573
|
+
authorize: () => authorize,
|
|
1574
|
+
linkIdentity: () => linkIdentity,
|
|
1575
|
+
listIdentities: () => listIdentities,
|
|
1576
|
+
unlinkIdentity: () => unlinkIdentity
|
|
1577
|
+
});
|
|
1578
|
+
|
|
1579
|
+
// src/modules/oauth/authorize.ts
|
|
1580
|
+
async function authorize(client, data) {
|
|
1581
|
+
const response = await client.projectInstance.post(
|
|
1582
|
+
"/oauth/authorize",
|
|
1583
|
+
data
|
|
1584
|
+
);
|
|
1585
|
+
return response.data;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
// src/modules/oauth/linkIdentity.ts
|
|
1589
|
+
async function linkIdentity(client, data) {
|
|
1590
|
+
const response = await client.projectInstance.post(
|
|
1591
|
+
"/oauth/link",
|
|
1592
|
+
data
|
|
1593
|
+
);
|
|
1594
|
+
return response.data;
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
// src/modules/oauth/listIdentities.ts
|
|
1598
|
+
async function listIdentities(client) {
|
|
1599
|
+
const response = await client.projectInstance.get(
|
|
1600
|
+
"/oauth/identities"
|
|
1601
|
+
);
|
|
1602
|
+
return response.data;
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
// src/modules/oauth/unlinkIdentity.ts
|
|
1606
|
+
async function unlinkIdentity(client, data) {
|
|
1607
|
+
const { identityId } = data;
|
|
1608
|
+
const response = await client.projectInstance.delete(
|
|
1609
|
+
`/oauth/identities/${identityId}`
|
|
1610
|
+
);
|
|
1611
|
+
return response.data;
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
// src/modules/chat/index.ts
|
|
1615
|
+
var chat_exports = {};
|
|
1616
|
+
__export(chat_exports, {
|
|
1617
|
+
addMember: () => addMember,
|
|
1618
|
+
changeMemberRole: () => changeMemberRole,
|
|
1619
|
+
createDirectConversation: () => createDirectConversation,
|
|
1620
|
+
createGroupConversation: () => createGroupConversation,
|
|
1621
|
+
deleteConversation: () => deleteConversation,
|
|
1622
|
+
deleteMessage: () => deleteMessage,
|
|
1623
|
+
editMessage: () => editMessage,
|
|
1624
|
+
getConversation: () => getConversation,
|
|
1625
|
+
getMessage: () => getMessage,
|
|
1626
|
+
getUnreadCount: () => getUnreadCount,
|
|
1627
|
+
leaveConversation: () => leaveConversation,
|
|
1628
|
+
listConversations: () => listConversations,
|
|
1629
|
+
listMembers: () => listMembers,
|
|
1630
|
+
listMessages: () => listMessages,
|
|
1631
|
+
listReactions: () => listReactions,
|
|
1632
|
+
markAsRead: () => markAsRead,
|
|
1633
|
+
removeMember: () => removeMember,
|
|
1634
|
+
reportMessage: () => reportMessage,
|
|
1635
|
+
sendMessage: () => sendMessage,
|
|
1636
|
+
toggleReaction: () => toggleReaction,
|
|
1637
|
+
updateConversation: () => updateConversation
|
|
1638
|
+
});
|
|
1639
|
+
|
|
1640
|
+
// src/modules/chat/listConversations.ts
|
|
1641
|
+
async function listConversations(client, data) {
|
|
1642
|
+
const response = await client.projectInstance.get(
|
|
1643
|
+
"/chat/conversations",
|
|
1644
|
+
{ params: data }
|
|
1645
|
+
);
|
|
1646
|
+
return response.data;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
// src/modules/chat/createGroupConversation.ts
|
|
1650
|
+
async function createGroupConversation(client, data) {
|
|
1651
|
+
const response = await client.projectInstance.post(
|
|
1652
|
+
"/chat/conversations",
|
|
1653
|
+
{ type: "group", ...data }
|
|
1654
|
+
);
|
|
1655
|
+
return response.data;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
// src/modules/chat/createDirectConversation.ts
|
|
1659
|
+
async function createDirectConversation(client, data) {
|
|
1660
|
+
const response = await client.projectInstance.post(
|
|
1661
|
+
"/chat/conversations/direct",
|
|
1662
|
+
data
|
|
1663
|
+
);
|
|
1664
|
+
return response.data;
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
// src/modules/chat/getConversation.ts
|
|
1668
|
+
async function getConversation(client, data) {
|
|
1669
|
+
const { conversationId } = data;
|
|
1670
|
+
const response = await client.projectInstance.get(
|
|
1671
|
+
`/chat/conversations/${conversationId}`
|
|
1672
|
+
);
|
|
1673
|
+
return response.data;
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
// src/modules/chat/updateConversation.ts
|
|
1677
|
+
async function updateConversation(client, data) {
|
|
1678
|
+
const { conversationId, ...body } = data;
|
|
1679
|
+
const response = await client.projectInstance.patch(
|
|
1680
|
+
`/chat/conversations/${conversationId}`,
|
|
1681
|
+
body
|
|
1682
|
+
);
|
|
1683
|
+
return response.data;
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
// src/modules/chat/deleteConversation.ts
|
|
1687
|
+
async function deleteConversation(client, data) {
|
|
1688
|
+
const { conversationId } = data;
|
|
1689
|
+
const response = await client.projectInstance.delete(
|
|
1690
|
+
`/chat/conversations/${conversationId}`
|
|
1691
|
+
);
|
|
1692
|
+
return response.data;
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
// src/modules/chat/getUnreadCount.ts
|
|
1696
|
+
async function getUnreadCount(client) {
|
|
1697
|
+
const response = await client.projectInstance.get(
|
|
1698
|
+
"/chat/conversations/unread-count"
|
|
1699
|
+
);
|
|
1700
|
+
return response.data;
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
// src/modules/chat/listMembers.ts
|
|
1704
|
+
async function listMembers(client, data) {
|
|
1705
|
+
const { conversationId, ...params } = data;
|
|
1706
|
+
const response = await client.projectInstance.get(`/chat/conversations/${conversationId}/members`, { params });
|
|
1707
|
+
return response.data;
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
// src/modules/chat/addMember.ts
|
|
1711
|
+
async function addMember(client, data) {
|
|
1712
|
+
const { conversationId, userId } = data;
|
|
1713
|
+
const response = await client.projectInstance.post(
|
|
1714
|
+
`/chat/conversations/${conversationId}/members`,
|
|
1715
|
+
{ userId }
|
|
1716
|
+
);
|
|
1717
|
+
return response.data;
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
// src/modules/chat/removeMember.ts
|
|
1721
|
+
async function removeMember(client, data) {
|
|
1722
|
+
const { conversationId, userId } = data;
|
|
1723
|
+
const response = await client.projectInstance.delete(
|
|
1724
|
+
`/chat/conversations/${conversationId}/members/${userId}`
|
|
1725
|
+
);
|
|
1726
|
+
return response.data;
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
// src/modules/chat/leaveConversation.ts
|
|
1730
|
+
async function leaveConversation(client, data) {
|
|
1731
|
+
const { conversationId } = data;
|
|
1732
|
+
const response = await client.projectInstance.delete(
|
|
1733
|
+
`/chat/conversations/${conversationId}/leave`
|
|
1734
|
+
);
|
|
1735
|
+
return response.data;
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
// src/modules/chat/changeMemberRole.ts
|
|
1739
|
+
async function changeMemberRole(client, data) {
|
|
1740
|
+
const { conversationId, userId, role } = data;
|
|
1741
|
+
const response = await client.projectInstance.patch(
|
|
1742
|
+
`/chat/conversations/${conversationId}/members/${userId}/role`,
|
|
1743
|
+
{ role }
|
|
1744
|
+
);
|
|
1745
|
+
return response.data;
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
// src/modules/chat/listMessages.ts
|
|
1749
|
+
async function listMessages(client, data) {
|
|
1750
|
+
const { conversationId, ...params } = data;
|
|
1751
|
+
const response = await client.projectInstance.get(
|
|
1752
|
+
`/chat/conversations/${conversationId}/messages`,
|
|
1753
|
+
{ params }
|
|
1754
|
+
);
|
|
1755
|
+
return response.data;
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
// src/modules/chat/sendMessage.ts
|
|
1759
|
+
async function sendMessage(client, data) {
|
|
1760
|
+
const { conversationId, files, ...body } = data;
|
|
1761
|
+
const path = `/chat/conversations/${conversationId}/messages`;
|
|
1762
|
+
if (files && files.length > 0) {
|
|
1763
|
+
const formData = new FormData();
|
|
1764
|
+
for (const file of files) {
|
|
1765
|
+
appendFile(formData, "files", file, { fallback: "attachment" });
|
|
1766
|
+
}
|
|
1767
|
+
appendFields(formData, body);
|
|
1768
|
+
const response2 = await client.projectInstance.post(
|
|
1769
|
+
path,
|
|
1770
|
+
formData
|
|
1771
|
+
);
|
|
1772
|
+
return response2.data;
|
|
1773
|
+
}
|
|
1774
|
+
const response = await client.projectInstance.post(path, body);
|
|
1775
|
+
return response.data;
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
// src/modules/chat/getMessage.ts
|
|
1779
|
+
async function getMessage(client, data) {
|
|
1780
|
+
const { conversationId, messageId } = data;
|
|
1781
|
+
const response = await client.projectInstance.get(
|
|
1782
|
+
`/chat/conversations/${conversationId}/messages/${messageId}`
|
|
1783
|
+
);
|
|
1784
|
+
return response.data;
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
// src/modules/chat/editMessage.ts
|
|
1788
|
+
async function editMessage(client, data) {
|
|
1789
|
+
const { conversationId, messageId, ...body } = data;
|
|
1790
|
+
const response = await client.projectInstance.patch(
|
|
1791
|
+
`/chat/conversations/${conversationId}/messages/${messageId}`,
|
|
1792
|
+
body
|
|
1793
|
+
);
|
|
1794
|
+
return response.data;
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
// src/modules/chat/deleteMessage.ts
|
|
1798
|
+
async function deleteMessage(client, data) {
|
|
1799
|
+
const { conversationId, messageId } = data;
|
|
1800
|
+
const response = await client.projectInstance.delete(
|
|
1801
|
+
`/chat/conversations/${conversationId}/messages/${messageId}`
|
|
1802
|
+
);
|
|
1803
|
+
return response.data;
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
// src/modules/chat/toggleReaction.ts
|
|
1807
|
+
async function toggleReaction(client, data) {
|
|
1808
|
+
const { conversationId, messageId, emoji } = data;
|
|
1809
|
+
const response = await client.projectInstance.post(
|
|
1810
|
+
`/chat/conversations/${conversationId}/messages/${messageId}/reactions`,
|
|
1811
|
+
{ emoji }
|
|
1812
|
+
);
|
|
1813
|
+
return response.data;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
// src/modules/chat/listReactions.ts
|
|
1817
|
+
async function listReactions(client, data) {
|
|
1818
|
+
const { conversationId, messageId, ...params } = data;
|
|
1819
|
+
const response = await client.projectInstance.get(
|
|
1820
|
+
`/chat/conversations/${conversationId}/messages/${messageId}/reactions`,
|
|
1821
|
+
{ params }
|
|
1822
|
+
);
|
|
1823
|
+
return response.data;
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
// src/modules/chat/markAsRead.ts
|
|
1827
|
+
async function markAsRead(client, data) {
|
|
1828
|
+
const { conversationId, messageId } = data;
|
|
1829
|
+
const response = await client.projectInstance.post(
|
|
1830
|
+
`/chat/conversations/${conversationId}/read`,
|
|
1831
|
+
{ messageId }
|
|
1832
|
+
);
|
|
1833
|
+
return response.data;
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
// src/modules/chat/reportMessage.ts
|
|
1837
|
+
async function reportMessage(client, data) {
|
|
1838
|
+
const { conversationId, messageId, ...body } = data;
|
|
1839
|
+
const response = await client.projectInstance.post(
|
|
1840
|
+
`/chat/conversations/${conversationId}/messages/${messageId}/report`,
|
|
1841
|
+
body
|
|
1842
|
+
);
|
|
164
1843
|
return response.data;
|
|
165
1844
|
}
|
|
166
1845
|
|
|
167
1846
|
// src/index.ts
|
|
168
1847
|
var SublayClient = class _SublayClient {
|
|
169
1848
|
http;
|
|
1849
|
+
auth;
|
|
170
1850
|
users;
|
|
171
1851
|
entities;
|
|
172
1852
|
comments;
|
|
1853
|
+
spaces;
|
|
1854
|
+
collections;
|
|
1855
|
+
follows;
|
|
1856
|
+
connections;
|
|
1857
|
+
appNotifications;
|
|
1858
|
+
reports;
|
|
1859
|
+
search;
|
|
1860
|
+
storage;
|
|
1861
|
+
oauth;
|
|
1862
|
+
chat;
|
|
173
1863
|
constructor(http) {
|
|
174
1864
|
this.http = http;
|
|
1865
|
+
this.auth = bindModule(auth_exports, this.http);
|
|
175
1866
|
this.users = bindModule(users_exports, this.http);
|
|
176
1867
|
this.entities = bindModule(entities_exports, this.http);
|
|
177
1868
|
this.comments = bindModule(comments_exports, this.http);
|
|
1869
|
+
this.spaces = bindModule(spaces_exports, this.http);
|
|
1870
|
+
this.collections = bindModule(collections_exports, this.http);
|
|
1871
|
+
this.follows = bindModule(follows_exports, this.http);
|
|
1872
|
+
this.connections = bindModule(connections_exports, this.http);
|
|
1873
|
+
this.appNotifications = bindModule(app_notifications_exports, this.http);
|
|
1874
|
+
this.reports = bindModule(reports_exports, this.http);
|
|
1875
|
+
this.search = bindModule(search_exports, this.http);
|
|
1876
|
+
this.storage = bindModule(storage_exports, this.http);
|
|
1877
|
+
this.oauth = bindModule(oauth_exports, this.http);
|
|
1878
|
+
this.chat = bindModule(chat_exports, this.http);
|
|
178
1879
|
}
|
|
179
1880
|
static async init(config) {
|
|
180
1881
|
const http = new SublayHttpClient(config);
|
|
181
1882
|
return new _SublayClient(http);
|
|
182
1883
|
}
|
|
1884
|
+
/** Imperatively set the session tokens (SDK-managed mode). */
|
|
1885
|
+
setTokens(tokens) {
|
|
1886
|
+
this.http.setTokens(tokens);
|
|
1887
|
+
}
|
|
1888
|
+
/** Imperatively clear the session tokens, e.g. on logout (SDK-managed mode). */
|
|
1889
|
+
clearTokens() {
|
|
1890
|
+
this.http.clearTokens();
|
|
1891
|
+
}
|
|
183
1892
|
};
|
|
184
1893
|
function bindModule(module2, client) {
|
|
185
1894
|
const bound = {};
|