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