sidechat.js 2.5.6 → 2.6.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/dist/classes/SidechatAPIClient.d.ts +31 -2
- package/dist/classes/SidechatAPIClient.d.ts.map +1 -1
- package/dist/index.cjs +118 -7
- package/dist/index.mjs +118 -7
- package/dist/types/SidechatTypes.d.ts +69 -3
- package/dist/types/SidechatTypes.d.ts.map +1 -1
- package/docs/sidechat.js/2.6.0/SidechatAPIClient.html +3 -0
- package/docs/sidechat.js/2.6.0/SidechatAPIError.html +3 -0
- package/docs/sidechat.js/2.6.0/SidechatColorList.html +3 -0
- package/docs/sidechat.js/2.6.0/classes_SidechatAPIClient.js.html +1356 -0
- package/docs/sidechat.js/2.6.0/classes_SidechatAPIError.js.html +16 -0
- package/docs/sidechat.js/2.6.0/classes_SidechatColorList.js.html +79 -0
- package/docs/sidechat.js/2.6.0/data/search.json +1 -0
- package/docs/sidechat.js/2.6.0/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/sidechat.js/2.6.0/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/sidechat.js/2.6.0/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/sidechat.js/2.6.0/global.html +3 -0
- package/docs/sidechat.js/2.6.0/index.html +4 -0
- package/docs/sidechat.js/2.6.0/scripts/core.js +726 -0
- package/docs/sidechat.js/2.6.0/scripts/core.min.js +23 -0
- package/docs/sidechat.js/2.6.0/scripts/resize.js +90 -0
- package/docs/sidechat.js/2.6.0/scripts/search.js +265 -0
- package/docs/sidechat.js/2.6.0/scripts/search.min.js +6 -0
- package/docs/sidechat.js/2.6.0/scripts/third-party/Apache-License-2.0.txt +202 -0
- package/docs/sidechat.js/2.6.0/scripts/third-party/fuse.js +9 -0
- package/docs/sidechat.js/2.6.0/scripts/third-party/hljs-line-num-original.js +369 -0
- package/docs/sidechat.js/2.6.0/scripts/third-party/hljs-line-num.js +1 -0
- package/docs/sidechat.js/2.6.0/scripts/third-party/hljs-original.js +5171 -0
- package/docs/sidechat.js/2.6.0/scripts/third-party/hljs.js +1 -0
- package/docs/sidechat.js/2.6.0/scripts/third-party/popper.js +5 -0
- package/docs/sidechat.js/2.6.0/scripts/third-party/tippy.js +1 -0
- package/docs/sidechat.js/2.6.0/scripts/third-party/tocbot.js +672 -0
- package/docs/sidechat.js/2.6.0/scripts/third-party/tocbot.min.js +1 -0
- package/docs/sidechat.js/2.6.0/styles/clean-jsdoc-theme-base.css +1159 -0
- package/docs/sidechat.js/2.6.0/styles/clean-jsdoc-theme-dark.css +412 -0
- package/docs/sidechat.js/2.6.0/styles/clean-jsdoc-theme-light.css +482 -0
- package/docs/sidechat.js/2.6.0/styles/clean-jsdoc-theme-scrollbar.css +30 -0
- package/docs/sidechat.js/2.6.0/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
- package/docs/sidechat.js/2.6.0/styles/clean-jsdoc-theme.min.css +1 -0
- package/docs/sidechat.js/2.6.0/tutorial-Authentication.html +14 -0
- package/docs/sidechat.js/2.6.0/tutorial-Email Registration.html +6 -0
- package/docs/sidechat.js/2.6.0/types_SidechatTypes.js.html +204 -0
- package/package.json +1 -1
- package/src/classes/SidechatAPIClient.js +87 -1
- package/src/types/SidechatTypes.js +31 -6
|
@@ -163,6 +163,14 @@ declare class SidechatAPIClient {
|
|
|
163
163
|
* @returns {SidechatGroup[]}
|
|
164
164
|
*/
|
|
165
165
|
getAvailableGroups: (onePage?: boolean) => SidechatGroup[];
|
|
166
|
+
/**
|
|
167
|
+
* Searches for new groups based on a query keyword
|
|
168
|
+
* @method
|
|
169
|
+
* @since 2.6.0
|
|
170
|
+
* @param {String} query - the string to search for. This will be encoded, so strings with spaces and special characters are okay.
|
|
171
|
+
* @returns {SidechatGroup[]}
|
|
172
|
+
*/
|
|
173
|
+
searchAvailableGroups: (query: string) => SidechatGroup[];
|
|
166
174
|
/**
|
|
167
175
|
* Retrieves the entire accessible asset library. Be warned that as of the time of this documentation, it's a 1.5MB JSON download and this request is very expensive.
|
|
168
176
|
* @method
|
|
@@ -287,6 +295,22 @@ declare class SidechatAPIClient {
|
|
|
287
295
|
* @param {String} username - new username to set
|
|
288
296
|
*/
|
|
289
297
|
setUsername: (userID: string, username: string) => Promise<any>;
|
|
298
|
+
/**
|
|
299
|
+
* Fetches a public user profile
|
|
300
|
+
* @method
|
|
301
|
+
* @since 2.6.0
|
|
302
|
+
* @param {String} username - username of the user to fetch
|
|
303
|
+
* @returns {SidechatProfile}
|
|
304
|
+
*/
|
|
305
|
+
getUserProfile: (username: string) => SidechatProfile;
|
|
306
|
+
/**
|
|
307
|
+
* Fetches a public user's posts
|
|
308
|
+
* @method
|
|
309
|
+
* @since 2.6.0
|
|
310
|
+
* @param {String} username - username of the user to fetch
|
|
311
|
+
* @returns {SidechatPostOrComment[]}
|
|
312
|
+
*/
|
|
313
|
+
getUserPosts: (username: string) => SidechatPostOrComment[];
|
|
290
314
|
/**
|
|
291
315
|
* Marks an activity item as read
|
|
292
316
|
* @method
|
|
@@ -301,11 +325,16 @@ declare class SidechatAPIClient {
|
|
|
301
325
|
*/
|
|
302
326
|
getGroupChats: () => Promise<any>;
|
|
303
327
|
/**
|
|
304
|
-
* Joins a group chat
|
|
328
|
+
* Joins a group chat. To mimic the official client, use the user's display name and icon by default.
|
|
305
329
|
* @method
|
|
330
|
+
* @param {String} groupChatID - alphanumeric ID of group chat to join
|
|
331
|
+
* @param {String} displayName - display name to use in chat
|
|
332
|
+
* @param {String} emoji - emoji to use as icon
|
|
333
|
+
* @param {String} primaryColor - hex string of primary color
|
|
334
|
+
* @param {String} secondaryColor - hex string of secondary color
|
|
306
335
|
* @since 2.3.5
|
|
307
336
|
*/
|
|
308
|
-
joinGroupChat: (groupChatID:
|
|
337
|
+
joinGroupChat: (groupChatID: string, displayName: string, emoji: string, primaryColor: string, secondaryColor: string) => Promise<any>;
|
|
309
338
|
/**
|
|
310
339
|
* Gets a list of the user's direct messages
|
|
311
340
|
* @method
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;;;;;;OAMG;IACH,yEAwBE;IAEF;;;;;;;;;;;;;OAaG;IACH,oIALW,mBAAmB,EAAE,gDAGnB,qBAAqB,CAwChC;IAEF;;;;;;;;;;;OAWG;IACH,wDANW,mBAAmB,EAAE,2EAInB,qBAAqB,CAqChC;IAEF;;;;;OAKG;IACH,+DAqBE;IAEF;;;;;;OAMG;IACH,kEAsBE;IAEF;;;;;OAKG;IACH,kDAqBE;IAEF;;;;;;;;OAQG;IACH,sEAsCE;IAEF;;;;;;;;OAQG;IACH,2GA2BE;IAEF;;;;;;OAMG;IACH,0DAsBE;IAEF;;;;;;OAMG;IACH,6CAwBE;IAEF;;;;;;OAMG;IACH,gEAqBE;IAEF;;;;;OAKG;IACH,mDAqBE;IAEF;;;;OAIG;IACH,kCAkBE;IAEF
|
|
1
|
+
{"version":3,"file":"SidechatAPIClient.d.ts","sourceRoot":"","sources":["../../src/classes/SidechatAPIClient.js"],"names":[],"mappings":";AAGA;;;;GAIG;AACH;IA2BE;;;;OAIG;IACH,oBAHW,iBAAiB,oBAU3B;IAtCD;;;SAGK;IACL,WAFU,iBAAiB,CAEjB;IAEV;;;;;OAKG;IACH,oBAKE;IAEF;;;;OAIG;IACH,gBAAqC;IAgBrC;;;;OAIG;IACH,kBAFW,iBAAiB,UAI1B;IAEF;;;;;OAKG;IACH,kCAEE;IAEF;;;;;;;;;OASG;IACH,yCANW,KAAK,GAAC,MAAM,GAAC,KAAK,GAAC,QAAQ,GAAC,OAAO,GAAC,SAAS,0EAuBtD;IAEF;;;;;OAKG;IACH,mDAgBE;IAEF;;;;;;OAMG;IACH,mEAmBE;IAEF;;;;;;OAMG;IACH,8DAsBE;IAEF;;;;;;OAMG;IACH,+CAwBE;IAEF;;;;OAIG;IACH,2CAsBE;IAEF;;;;;OAKG;IACH,6CAuBE;IAEF;;;;;;OAMG;IACH,oDAGE;IAEF;;;;;OAKG;IACH,+CAqBE;IAEF;;;;;;;;OAQG;IACH,4CAJW,KAAK,GAAC,QAAQ,G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/B;IAEF;;;;;;;;;OASG;IACH,kEAJW,aAAa,EAAE,uCA6BxB;IAEF;;;;;;;;;OASG;IACH,6FAHW,MAAM,kBAkCf;CACH"}
|
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
7
7
|
* @typedef {Object} SidechatPostOrComment
|
|
8
8
|
* @prop {"post"|"comment"} type - whether this object represents a post or a comment on a post
|
|
9
9
|
* @prop {String} id - alphanumeric ID of post or comment
|
|
10
|
-
* @prop {Boolean} authored_by_user -
|
|
10
|
+
* @prop {Boolean} authored_by_user - whether or not the post or comment was created by the current user
|
|
11
11
|
* @prop {String} alias - post creator's name in-app
|
|
12
12
|
* @prop {String} group_id - alphanumeric ID of group
|
|
13
13
|
* @prop {SidechatGroup} group - group in which post or comment was created
|
|
@@ -21,8 +21,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
21
21
|
* @prop {String[]} tags - undocumented
|
|
22
22
|
* @prop {SidechatIdentity} identity - creator's identity information
|
|
23
23
|
* @prop {Boolean} pinned - undocumented
|
|
24
|
-
* @prop {Boolean} is_saved -
|
|
25
|
-
* @prop {"following"|"not_following"} follow_status -
|
|
24
|
+
* @prop {Boolean} is_saved - whether or not the current user has saved the post
|
|
25
|
+
* @prop {"following"|"not_following"} follow_status - whether or not the current user should recieve activity notifications for the post
|
|
26
26
|
* @prop {"group"} [destination] - undocumented
|
|
27
27
|
* @prop {Number} [comment_count] - number of comments on post (only if type=post)
|
|
28
28
|
* @prop {Boolean} [comments_disabled] - whether or not you can comment on post (only if type=post)
|
|
@@ -86,6 +86,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
86
86
|
* @prop {Boolean} posted_with_username - undocumented
|
|
87
87
|
*/
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* A conversation icon associated with a user
|
|
91
|
+
* @typedef {Object} SidechatIcon
|
|
92
|
+
* @prop {String} emoji - unicode emoji character
|
|
93
|
+
* @prop {String} color - primary hex color code
|
|
94
|
+
* @prop {String} secondary_color - secondary hex color code
|
|
95
|
+
*/
|
|
96
|
+
|
|
89
97
|
/**
|
|
90
98
|
* The current user's information
|
|
91
99
|
* @typedef {Object} SidechatCurrentUser
|
|
@@ -99,6 +107,22 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
99
107
|
* @prop {String} wildcardEmailDomain - domain of verified email address on account, preceeded by *. to support subdomains
|
|
100
108
|
*/
|
|
101
109
|
|
|
110
|
+
/**
|
|
111
|
+
* A user's public profile
|
|
112
|
+
* @typedef {Object} SidechatProfile
|
|
113
|
+
* @prop {String} id - alphanumeric ID of user
|
|
114
|
+
* @prop {String} name - public-facing username
|
|
115
|
+
* @prop {SidechatIcon} conversation_icon - icon associated with user
|
|
116
|
+
* @prop {Boolean} description - the user bio
|
|
117
|
+
* @prop {String} index_name - undocumented
|
|
118
|
+
* @prop {String} analytics_name - undocumented
|
|
119
|
+
* @prop {String} color - undocumented
|
|
120
|
+
* @prop {String} share_color_start - undocumented
|
|
121
|
+
* @prop {String} share_color_end - undocumented
|
|
122
|
+
* @prop {"account"} group_join_type - undocumented
|
|
123
|
+
* @prop {"public_to_all"} group_visibility - the profile visibility status
|
|
124
|
+
*/
|
|
125
|
+
|
|
102
126
|
/**
|
|
103
127
|
* Representation of a group membership
|
|
104
128
|
* @typedef {Object} SidechatMembership
|
|
@@ -133,7 +157,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
133
157
|
* @prop {SidechatCursorString} cursor
|
|
134
158
|
*/
|
|
135
159
|
|
|
136
|
-
var SidechatTypes = {};
|
|
137
160
|
|
|
138
161
|
/**
|
|
139
162
|
* A direct message thread
|
|
@@ -170,7 +193,7 @@ var SidechatTypes = {};
|
|
|
170
193
|
* @prop {Boolean} allows_view_results - whether or not poll results are publicly visible
|
|
171
194
|
* @prop {Number} view_results_count - number of users who have viewed poll results
|
|
172
195
|
* @prop {Boolean} participated - whether or not current user has voted in poll
|
|
173
|
-
|
|
196
|
+
*/
|
|
174
197
|
|
|
175
198
|
/**
|
|
176
199
|
* Represents a poll choice
|
|
@@ -178,7 +201,9 @@ var SidechatTypes = {};
|
|
|
178
201
|
* @prop {Number} count - number of votes for choice
|
|
179
202
|
* @prop {String} text - user-visible text of choice
|
|
180
203
|
* @prop {Boolean} selected - whether or not current user has voted for choice
|
|
181
|
-
|
|
204
|
+
*/
|
|
205
|
+
|
|
206
|
+
var SidechatTypes = {};
|
|
182
207
|
|
|
183
208
|
/**
|
|
184
209
|
* Throwable error caused by the Sidechat API
|
|
@@ -734,6 +759,33 @@ class SidechatAPIClient {
|
|
|
734
759
|
}
|
|
735
760
|
};
|
|
736
761
|
|
|
762
|
+
/**
|
|
763
|
+
* Searches for new groups based on a query keyword
|
|
764
|
+
* @method
|
|
765
|
+
* @since 2.6.0
|
|
766
|
+
* @param {String} query - the string to search for. This will be encoded, so strings with spaces and special characters are okay.
|
|
767
|
+
* @returns {SidechatGroup[]}
|
|
768
|
+
*/
|
|
769
|
+
searchAvailableGroups = async (query) => {
|
|
770
|
+
if (!this.userToken) {
|
|
771
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
772
|
+
}
|
|
773
|
+
try {
|
|
774
|
+
const res = await fetch(`${this.apiRoot}/v1/groups/explore/search?term=${encodeURIComponent(query)}`, {
|
|
775
|
+
method: "GET",
|
|
776
|
+
headers: {
|
|
777
|
+
...this.defaultHeaders,
|
|
778
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
779
|
+
},
|
|
780
|
+
});
|
|
781
|
+
const json = await res.json();
|
|
782
|
+
return await json.results;
|
|
783
|
+
} catch (err) {
|
|
784
|
+
console.error(err);
|
|
785
|
+
throw new SidechatAPIError(`Failed to search groups.`);
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
|
|
737
789
|
/**
|
|
738
790
|
* Retrieves the entire accessible asset library. Be warned that as of the time of this documentation, it's a 1.5MB JSON download and this request is very expensive.
|
|
739
791
|
* @method
|
|
@@ -1219,6 +1271,60 @@ class SidechatAPIClient {
|
|
|
1219
1271
|
}
|
|
1220
1272
|
};
|
|
1221
1273
|
|
|
1274
|
+
/**
|
|
1275
|
+
* Fetches a public user profile
|
|
1276
|
+
* @method
|
|
1277
|
+
* @since 2.6.0
|
|
1278
|
+
* @param {String} username - username of the user to fetch
|
|
1279
|
+
* @returns {SidechatProfile}
|
|
1280
|
+
*/
|
|
1281
|
+
getUserProfile = async (username) => {
|
|
1282
|
+
if (!this.userToken) {
|
|
1283
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
1284
|
+
}
|
|
1285
|
+
try {
|
|
1286
|
+
const res = await fetch(`${this.apiRoot}/v1/groups/username?username=${username}`, {
|
|
1287
|
+
method: "GET",
|
|
1288
|
+
headers: {
|
|
1289
|
+
...this.defaultHeaders,
|
|
1290
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1293
|
+
const json = await res.json();
|
|
1294
|
+
return await json.group;
|
|
1295
|
+
} catch (err) {
|
|
1296
|
+
console.error(err);
|
|
1297
|
+
throw new SidechatAPIError(`Failed to set icon.`);
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
1300
|
+
|
|
1301
|
+
/**
|
|
1302
|
+
* Fetches a public user's posts
|
|
1303
|
+
* @method
|
|
1304
|
+
* @since 2.6.0
|
|
1305
|
+
* @param {String} username - username of the user to fetch
|
|
1306
|
+
* @returns {SidechatPostOrComment[]}
|
|
1307
|
+
*/
|
|
1308
|
+
getUserPosts = async (username) => {
|
|
1309
|
+
if (!this.userToken) {
|
|
1310
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
1311
|
+
}
|
|
1312
|
+
try {
|
|
1313
|
+
const res = await fetch(`${this.apiRoot}/v1/users/posts?username=${username}`, {
|
|
1314
|
+
method: "GET",
|
|
1315
|
+
headers: {
|
|
1316
|
+
...this.defaultHeaders,
|
|
1317
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
1318
|
+
}
|
|
1319
|
+
});
|
|
1320
|
+
const json = await res.json();
|
|
1321
|
+
return await json.posts;
|
|
1322
|
+
} catch (err) {
|
|
1323
|
+
console.error(err);
|
|
1324
|
+
throw new SidechatAPIError(`Failed to set icon.`);
|
|
1325
|
+
}
|
|
1326
|
+
};
|
|
1327
|
+
|
|
1222
1328
|
/**
|
|
1223
1329
|
* Marks an activity item as read
|
|
1224
1330
|
* @method
|
|
@@ -1274,8 +1380,13 @@ class SidechatAPIClient {
|
|
|
1274
1380
|
};
|
|
1275
1381
|
|
|
1276
1382
|
/**
|
|
1277
|
-
* Joins a group chat
|
|
1383
|
+
* Joins a group chat. To mimic the official client, use the user's display name and icon by default.
|
|
1278
1384
|
* @method
|
|
1385
|
+
* @param {String} groupChatID - alphanumeric ID of group chat to join
|
|
1386
|
+
* @param {String} displayName - display name to use in chat
|
|
1387
|
+
* @param {String} emoji - emoji to use as icon
|
|
1388
|
+
* @param {String} primaryColor - hex string of primary color
|
|
1389
|
+
* @param {String} secondaryColor - hex string of secondary color
|
|
1279
1390
|
* @since 2.3.5
|
|
1280
1391
|
*/
|
|
1281
1392
|
joinGroupChat = async (
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @typedef {Object} SidechatPostOrComment
|
|
4
4
|
* @prop {"post"|"comment"} type - whether this object represents a post or a comment on a post
|
|
5
5
|
* @prop {String} id - alphanumeric ID of post or comment
|
|
6
|
-
* @prop {Boolean} authored_by_user -
|
|
6
|
+
* @prop {Boolean} authored_by_user - whether or not the post or comment was created by the current user
|
|
7
7
|
* @prop {String} alias - post creator's name in-app
|
|
8
8
|
* @prop {String} group_id - alphanumeric ID of group
|
|
9
9
|
* @prop {SidechatGroup} group - group in which post or comment was created
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* @prop {String[]} tags - undocumented
|
|
18
18
|
* @prop {SidechatIdentity} identity - creator's identity information
|
|
19
19
|
* @prop {Boolean} pinned - undocumented
|
|
20
|
-
* @prop {Boolean} is_saved -
|
|
21
|
-
* @prop {"following"|"not_following"} follow_status -
|
|
20
|
+
* @prop {Boolean} is_saved - whether or not the current user has saved the post
|
|
21
|
+
* @prop {"following"|"not_following"} follow_status - whether or not the current user should recieve activity notifications for the post
|
|
22
22
|
* @prop {"group"} [destination] - undocumented
|
|
23
23
|
* @prop {Number} [comment_count] - number of comments on post (only if type=post)
|
|
24
24
|
* @prop {Boolean} [comments_disabled] - whether or not you can comment on post (only if type=post)
|
|
@@ -82,6 +82,14 @@
|
|
|
82
82
|
* @prop {Boolean} posted_with_username - undocumented
|
|
83
83
|
*/
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* A conversation icon associated with a user
|
|
87
|
+
* @typedef {Object} SidechatIcon
|
|
88
|
+
* @prop {String} emoji - unicode emoji character
|
|
89
|
+
* @prop {String} color - primary hex color code
|
|
90
|
+
* @prop {String} secondary_color - secondary hex color code
|
|
91
|
+
*/
|
|
92
|
+
|
|
85
93
|
/**
|
|
86
94
|
* The current user's information
|
|
87
95
|
* @typedef {Object} SidechatCurrentUser
|
|
@@ -95,6 +103,22 @@
|
|
|
95
103
|
* @prop {String} wildcardEmailDomain - domain of verified email address on account, preceeded by *. to support subdomains
|
|
96
104
|
*/
|
|
97
105
|
|
|
106
|
+
/**
|
|
107
|
+
* A user's public profile
|
|
108
|
+
* @typedef {Object} SidechatProfile
|
|
109
|
+
* @prop {String} id - alphanumeric ID of user
|
|
110
|
+
* @prop {String} name - public-facing username
|
|
111
|
+
* @prop {SidechatIcon} conversation_icon - icon associated with user
|
|
112
|
+
* @prop {Boolean} description - the user bio
|
|
113
|
+
* @prop {String} index_name - undocumented
|
|
114
|
+
* @prop {String} analytics_name - undocumented
|
|
115
|
+
* @prop {String} color - undocumented
|
|
116
|
+
* @prop {String} share_color_start - undocumented
|
|
117
|
+
* @prop {String} share_color_end - undocumented
|
|
118
|
+
* @prop {"account"} group_join_type - undocumented
|
|
119
|
+
* @prop {"public_to_all"} group_visibility - the profile visibility status
|
|
120
|
+
*/
|
|
121
|
+
|
|
98
122
|
/**
|
|
99
123
|
* Representation of a group membership
|
|
100
124
|
* @typedef {Object} SidechatMembership
|
|
@@ -129,7 +153,6 @@
|
|
|
129
153
|
* @prop {SidechatCursorString} cursor
|
|
130
154
|
*/
|
|
131
155
|
|
|
132
|
-
var SidechatTypes = {};
|
|
133
156
|
|
|
134
157
|
/**
|
|
135
158
|
* A direct message thread
|
|
@@ -166,7 +189,7 @@ var SidechatTypes = {};
|
|
|
166
189
|
* @prop {Boolean} allows_view_results - whether or not poll results are publicly visible
|
|
167
190
|
* @prop {Number} view_results_count - number of users who have viewed poll results
|
|
168
191
|
* @prop {Boolean} participated - whether or not current user has voted in poll
|
|
169
|
-
|
|
192
|
+
*/
|
|
170
193
|
|
|
171
194
|
/**
|
|
172
195
|
* Represents a poll choice
|
|
@@ -174,7 +197,9 @@ var SidechatTypes = {};
|
|
|
174
197
|
* @prop {Number} count - number of votes for choice
|
|
175
198
|
* @prop {String} text - user-visible text of choice
|
|
176
199
|
* @prop {Boolean} selected - whether or not current user has voted for choice
|
|
177
|
-
|
|
200
|
+
*/
|
|
201
|
+
|
|
202
|
+
var SidechatTypes = {};
|
|
178
203
|
|
|
179
204
|
/**
|
|
180
205
|
* Throwable error caused by the Sidechat API
|
|
@@ -730,6 +755,33 @@ class SidechatAPIClient {
|
|
|
730
755
|
}
|
|
731
756
|
};
|
|
732
757
|
|
|
758
|
+
/**
|
|
759
|
+
* Searches for new groups based on a query keyword
|
|
760
|
+
* @method
|
|
761
|
+
* @since 2.6.0
|
|
762
|
+
* @param {String} query - the string to search for. This will be encoded, so strings with spaces and special characters are okay.
|
|
763
|
+
* @returns {SidechatGroup[]}
|
|
764
|
+
*/
|
|
765
|
+
searchAvailableGroups = async (query) => {
|
|
766
|
+
if (!this.userToken) {
|
|
767
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
768
|
+
}
|
|
769
|
+
try {
|
|
770
|
+
const res = await fetch(`${this.apiRoot}/v1/groups/explore/search?term=${encodeURIComponent(query)}`, {
|
|
771
|
+
method: "GET",
|
|
772
|
+
headers: {
|
|
773
|
+
...this.defaultHeaders,
|
|
774
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
775
|
+
},
|
|
776
|
+
});
|
|
777
|
+
const json = await res.json();
|
|
778
|
+
return await json.results;
|
|
779
|
+
} catch (err) {
|
|
780
|
+
console.error(err);
|
|
781
|
+
throw new SidechatAPIError(`Failed to search groups.`);
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
|
|
733
785
|
/**
|
|
734
786
|
* Retrieves the entire accessible asset library. Be warned that as of the time of this documentation, it's a 1.5MB JSON download and this request is very expensive.
|
|
735
787
|
* @method
|
|
@@ -1215,6 +1267,60 @@ class SidechatAPIClient {
|
|
|
1215
1267
|
}
|
|
1216
1268
|
};
|
|
1217
1269
|
|
|
1270
|
+
/**
|
|
1271
|
+
* Fetches a public user profile
|
|
1272
|
+
* @method
|
|
1273
|
+
* @since 2.6.0
|
|
1274
|
+
* @param {String} username - username of the user to fetch
|
|
1275
|
+
* @returns {SidechatProfile}
|
|
1276
|
+
*/
|
|
1277
|
+
getUserProfile = async (username) => {
|
|
1278
|
+
if (!this.userToken) {
|
|
1279
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
1280
|
+
}
|
|
1281
|
+
try {
|
|
1282
|
+
const res = await fetch(`${this.apiRoot}/v1/groups/username?username=${username}`, {
|
|
1283
|
+
method: "GET",
|
|
1284
|
+
headers: {
|
|
1285
|
+
...this.defaultHeaders,
|
|
1286
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
1287
|
+
}
|
|
1288
|
+
});
|
|
1289
|
+
const json = await res.json();
|
|
1290
|
+
return await json.group;
|
|
1291
|
+
} catch (err) {
|
|
1292
|
+
console.error(err);
|
|
1293
|
+
throw new SidechatAPIError(`Failed to set icon.`);
|
|
1294
|
+
}
|
|
1295
|
+
};
|
|
1296
|
+
|
|
1297
|
+
/**
|
|
1298
|
+
* Fetches a public user's posts
|
|
1299
|
+
* @method
|
|
1300
|
+
* @since 2.6.0
|
|
1301
|
+
* @param {String} username - username of the user to fetch
|
|
1302
|
+
* @returns {SidechatPostOrComment[]}
|
|
1303
|
+
*/
|
|
1304
|
+
getUserPosts = async (username) => {
|
|
1305
|
+
if (!this.userToken) {
|
|
1306
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
1307
|
+
}
|
|
1308
|
+
try {
|
|
1309
|
+
const res = await fetch(`${this.apiRoot}/v1/users/posts?username=${username}`, {
|
|
1310
|
+
method: "GET",
|
|
1311
|
+
headers: {
|
|
1312
|
+
...this.defaultHeaders,
|
|
1313
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
1314
|
+
}
|
|
1315
|
+
});
|
|
1316
|
+
const json = await res.json();
|
|
1317
|
+
return await json.posts;
|
|
1318
|
+
} catch (err) {
|
|
1319
|
+
console.error(err);
|
|
1320
|
+
throw new SidechatAPIError(`Failed to set icon.`);
|
|
1321
|
+
}
|
|
1322
|
+
};
|
|
1323
|
+
|
|
1218
1324
|
/**
|
|
1219
1325
|
* Marks an activity item as read
|
|
1220
1326
|
* @method
|
|
@@ -1270,8 +1376,13 @@ class SidechatAPIClient {
|
|
|
1270
1376
|
};
|
|
1271
1377
|
|
|
1272
1378
|
/**
|
|
1273
|
-
* Joins a group chat
|
|
1379
|
+
* Joins a group chat. To mimic the official client, use the user's display name and icon by default.
|
|
1274
1380
|
* @method
|
|
1381
|
+
* @param {String} groupChatID - alphanumeric ID of group chat to join
|
|
1382
|
+
* @param {String} displayName - display name to use in chat
|
|
1383
|
+
* @param {String} emoji - emoji to use as icon
|
|
1384
|
+
* @param {String} primaryColor - hex string of primary color
|
|
1385
|
+
* @param {String} secondaryColor - hex string of secondary color
|
|
1275
1386
|
* @since 2.3.5
|
|
1276
1387
|
*/
|
|
1277
1388
|
joinGroupChat = async (
|
|
@@ -13,7 +13,7 @@ export type SidechatPostOrComment = {
|
|
|
13
13
|
*/
|
|
14
14
|
id: string;
|
|
15
15
|
/**
|
|
16
|
-
* -
|
|
16
|
+
* - whether or not the post or comment was created by the current user
|
|
17
17
|
*/
|
|
18
18
|
authored_by_user: boolean;
|
|
19
19
|
/**
|
|
@@ -69,11 +69,11 @@ export type SidechatPostOrComment = {
|
|
|
69
69
|
*/
|
|
70
70
|
pinned: boolean;
|
|
71
71
|
/**
|
|
72
|
-
* -
|
|
72
|
+
* - whether or not the current user has saved the post
|
|
73
73
|
*/
|
|
74
74
|
is_saved: boolean;
|
|
75
75
|
/**
|
|
76
|
-
* -
|
|
76
|
+
* - whether or not the current user should recieve activity notifications for the post
|
|
77
77
|
*/
|
|
78
78
|
follow_status: "following" | "not_following";
|
|
79
79
|
/**
|
|
@@ -246,6 +246,23 @@ export type SidechatIdentity = {
|
|
|
246
246
|
*/
|
|
247
247
|
posted_with_username: boolean;
|
|
248
248
|
};
|
|
249
|
+
/**
|
|
250
|
+
* A conversation icon associated with a user
|
|
251
|
+
*/
|
|
252
|
+
export type SidechatIcon = {
|
|
253
|
+
/**
|
|
254
|
+
* - unicode emoji character
|
|
255
|
+
*/
|
|
256
|
+
emoji: string;
|
|
257
|
+
/**
|
|
258
|
+
* - primary hex color code
|
|
259
|
+
*/
|
|
260
|
+
color: string;
|
|
261
|
+
/**
|
|
262
|
+
* - secondary hex color code
|
|
263
|
+
*/
|
|
264
|
+
secondary_color: string;
|
|
265
|
+
};
|
|
249
266
|
/**
|
|
250
267
|
* The current user's information
|
|
251
268
|
*/
|
|
@@ -280,6 +297,55 @@ export type SidechatCurrentUser = {
|
|
|
280
297
|
*/
|
|
281
298
|
wildcardEmailDomain: string;
|
|
282
299
|
};
|
|
300
|
+
/**
|
|
301
|
+
* A user's public profile
|
|
302
|
+
*/
|
|
303
|
+
export type SidechatProfile = {
|
|
304
|
+
/**
|
|
305
|
+
* - alphanumeric ID of user
|
|
306
|
+
*/
|
|
307
|
+
id: string;
|
|
308
|
+
/**
|
|
309
|
+
* - public-facing username
|
|
310
|
+
*/
|
|
311
|
+
name: string;
|
|
312
|
+
/**
|
|
313
|
+
* - icon associated with user
|
|
314
|
+
*/
|
|
315
|
+
conversation_icon: SidechatIcon;
|
|
316
|
+
/**
|
|
317
|
+
* - the user bio
|
|
318
|
+
*/
|
|
319
|
+
description: boolean;
|
|
320
|
+
/**
|
|
321
|
+
* - undocumented
|
|
322
|
+
*/
|
|
323
|
+
index_name: string;
|
|
324
|
+
/**
|
|
325
|
+
* - undocumented
|
|
326
|
+
*/
|
|
327
|
+
analytics_name: string;
|
|
328
|
+
/**
|
|
329
|
+
* - undocumented
|
|
330
|
+
*/
|
|
331
|
+
color: string;
|
|
332
|
+
/**
|
|
333
|
+
* - undocumented
|
|
334
|
+
*/
|
|
335
|
+
share_color_start: string;
|
|
336
|
+
/**
|
|
337
|
+
* - undocumented
|
|
338
|
+
*/
|
|
339
|
+
share_color_end: string;
|
|
340
|
+
/**
|
|
341
|
+
* - undocumented
|
|
342
|
+
*/
|
|
343
|
+
group_join_type: "account";
|
|
344
|
+
/**
|
|
345
|
+
* - the profile visibility status
|
|
346
|
+
*/
|
|
347
|
+
group_visibility: "public_to_all";
|
|
348
|
+
};
|
|
283
349
|
/**
|
|
284
350
|
* Representation of a group membership
|
|
285
351
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SidechatTypes.d.ts","sourceRoot":"","sources":["../../src/types/SidechatTypes.js"],"names":[],"mappings":";;;;;;;;;UAGU,MAAM,GAAC,SAAS;;;;;;;;;;;;;;;;;;;;WAKhB,aAAa;;;;;;;;;;;;;;;;iBAIb,kBAAkB;;;;YAClB,mBAAmB,EAAE;;;;;;;;;;;;UAGrB,QAAQ;;;;cACR,gBAAgB;;;;;;;;;;;;mBAGhB,WAAW,GAAC,eAAe;;;;kBAC3B,OAAO;;;;;;;;;;;;WAGP,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAYZ,YAAY,GAAC,QAAQ;;;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