sidechat.js 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -0
- package/dist/types.d.ts +229 -0
- package/package.json +8 -2
package/dist/index.d.ts
ADDED
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a new instance of the API client
|
|
3
|
+
* @param [token] - user bearer token
|
|
4
|
+
*/
|
|
5
|
+
declare class SidechatAPIClient {
|
|
6
|
+
constructor(token?: SidechatAuthToken);
|
|
7
|
+
/**
|
|
8
|
+
* User bearer token
|
|
9
|
+
*/
|
|
10
|
+
userToken: SidechatAuthToken;
|
|
11
|
+
/**
|
|
12
|
+
* Default headers for every API request
|
|
13
|
+
*/
|
|
14
|
+
defaultHeaders: any;
|
|
15
|
+
/**
|
|
16
|
+
* Manually set the currently signed in user's token. Generally try to avoid this and instead either pass a token to the constructor or login automatically through the auth functions
|
|
17
|
+
* @param token - user bearer token
|
|
18
|
+
*/
|
|
19
|
+
setToken(token: SidechatAuthToken): void;
|
|
20
|
+
/**
|
|
21
|
+
* Initiate the login process with a phone number. Should be followed up with verifySMSCode().
|
|
22
|
+
* @param phoneNumber - US phone number (WITHOUT +1) to send verification code to
|
|
23
|
+
*/
|
|
24
|
+
loginViaSMS(phoneNumber: number): void;
|
|
25
|
+
/**
|
|
26
|
+
* Verify the code sent via SMS with loginViaSMS().
|
|
27
|
+
* @param phoneNumber - US phone number (WITHOUT +1) that verification code was sent to
|
|
28
|
+
* @param code - the verification code
|
|
29
|
+
*/
|
|
30
|
+
verifySMSCode(phoneNumber: number, code: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Set the user's age
|
|
33
|
+
* @param age - user's age in years
|
|
34
|
+
* @param registrationID - the registration ID generated by verifySMSCode()
|
|
35
|
+
*/
|
|
36
|
+
setAge(age: number, registrationID: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Initiate the email setup process. Should be followed up with checkEmailVerification().
|
|
39
|
+
* @param email - school email address to send verification code to
|
|
40
|
+
*/
|
|
41
|
+
registerEmail(email: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Check is the user's email is verified.
|
|
44
|
+
*/
|
|
45
|
+
checkEmailVerification(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Set the device ID of the current user
|
|
48
|
+
* @param deviceId - the device ID to set
|
|
49
|
+
*/
|
|
50
|
+
setDeviceID(deviceId: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Get updated status for user and group
|
|
53
|
+
* @param [groupID] - ID of a specific group to retrieve info from
|
|
54
|
+
*/
|
|
55
|
+
getUserAndGroup(groupID?: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Fetches posts from the specified category in a group
|
|
58
|
+
* @param groupID - group ID
|
|
59
|
+
* @param category - category to filter posts
|
|
60
|
+
* @param [cursor] - cursor string
|
|
61
|
+
* @returns List of posts and cursor
|
|
62
|
+
*/
|
|
63
|
+
getGroupPosts(groupID: string, category: "hot" | "recent" | "top", cursor?: SidechatCursorString): SidechatPostsAndCursor;
|
|
64
|
+
/**
|
|
65
|
+
* Upvote or downvote, or unvote a post
|
|
66
|
+
* @param postID - post ID to vote on
|
|
67
|
+
* @param action - whether to upvote, downvote, or reset vote
|
|
68
|
+
*/
|
|
69
|
+
setVote(postID: string, action: SidechatVoteString): void;
|
|
70
|
+
/**
|
|
71
|
+
* Get all the commments on a post
|
|
72
|
+
* @param postID - post ID to get comments for
|
|
73
|
+
* @returns list of comments
|
|
74
|
+
*/
|
|
75
|
+
getPostComments(postID: string): SidechatPostOrComment[];
|
|
76
|
+
/**
|
|
77
|
+
* Gets groups to be displayed on the "Explore Groups" page
|
|
78
|
+
*/
|
|
79
|
+
getAvailableGroups(): SidechatGroup[];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Throwable error caused by the Sidechat API
|
|
84
|
+
*/
|
|
85
|
+
declare class SidechatAPIError extends Error {
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* A user-created post or comment, depending on the "type" prop
|
|
90
|
+
* @property type - whether this object represents a post or a comment on a post
|
|
91
|
+
* @property id - alphanumeric ID of post or comment
|
|
92
|
+
* @property authored_by_user - undocumented
|
|
93
|
+
* @property alias - post creator's name in-app
|
|
94
|
+
* @property group_id - alphanumeric ID of group
|
|
95
|
+
* @property group - group in which post or comment was created
|
|
96
|
+
* @property text - text content of post or comment
|
|
97
|
+
* @property created_at - date string of post or comment creation time
|
|
98
|
+
* @property vote_total - sum of upvotes and downvotes
|
|
99
|
+
* @property vote_status - current user's vote on post or comment
|
|
100
|
+
* @property assets - array of assets attached to post or comment
|
|
101
|
+
* @property attachments - undocumented
|
|
102
|
+
* @property dms_disabled - whether or not you can send a DM to creator of post
|
|
103
|
+
* @property tags - undocumented
|
|
104
|
+
* @property identity - creator's identity information
|
|
105
|
+
* @property pinned - undocumented
|
|
106
|
+
* @property is_saved - undocumented
|
|
107
|
+
* @property follow_status - undocumented
|
|
108
|
+
* @property [destination] - undocumented
|
|
109
|
+
* @property [comment_count] - number of comments on post (only if type=post)
|
|
110
|
+
* @property [comments_disabled] - whether or not you can comment on post (only if type=post)
|
|
111
|
+
* @property [parent_post_id] - alphanumeric ID of parent post (only if type=comment)
|
|
112
|
+
* @property [reply_post_id] - alphanumeric ID of comment being replied to, falls back to parent_post_id (only if type=comment)
|
|
113
|
+
* @property [context] - text content of comment being replied to, falls back to text (only if type=comment)
|
|
114
|
+
*/
|
|
115
|
+
declare type SidechatPostOrComment = {
|
|
116
|
+
type: "post" | "comment";
|
|
117
|
+
id: string;
|
|
118
|
+
authored_by_user: boolean;
|
|
119
|
+
alias: string;
|
|
120
|
+
group_id: string;
|
|
121
|
+
group: SidechatGroup;
|
|
122
|
+
text: string;
|
|
123
|
+
created_at: string;
|
|
124
|
+
vote_total: number;
|
|
125
|
+
vote_status: SidechatVoteString;
|
|
126
|
+
assets: SidechatAsset[];
|
|
127
|
+
attachments: any[];
|
|
128
|
+
dms_disabled: boolean;
|
|
129
|
+
tags: any[];
|
|
130
|
+
identity: SidechatIdentity;
|
|
131
|
+
pinned: boolean;
|
|
132
|
+
is_saved: boolean;
|
|
133
|
+
follow_status: "following" | "not_following";
|
|
134
|
+
destination?: "group";
|
|
135
|
+
comment_count?: number;
|
|
136
|
+
comments_disabled?: boolean;
|
|
137
|
+
parent_post_id?: string;
|
|
138
|
+
reply_post_id?: string;
|
|
139
|
+
context?: string;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* A group object, containing metadata about a group as well as its join conditions and states
|
|
144
|
+
* @property id - alphanumeric ID of group
|
|
145
|
+
* @property name - human-readable name of group
|
|
146
|
+
* @property analytics_name - name to file group under
|
|
147
|
+
* @property membership_type - whether or not current user is a member of group
|
|
148
|
+
* @property color - group's theme color as hex code (e.g., #FFFFFF)
|
|
149
|
+
* @property group_join_type - basis on which group accepts new members
|
|
150
|
+
* @property group_visibility - group's visibility setting
|
|
151
|
+
* @property asset_library_visibility - whether or not group's asset library is visible
|
|
152
|
+
* @property [roles] - undocumented
|
|
153
|
+
* @property [description] - description of group
|
|
154
|
+
* @property [icon_url] - image URL for group icon
|
|
155
|
+
* @property [member_count] - number of users in group
|
|
156
|
+
* @property [should_show_leaderboard] - undocumented
|
|
157
|
+
*/
|
|
158
|
+
declare type SidechatGroup = {
|
|
159
|
+
id: string;
|
|
160
|
+
name: string;
|
|
161
|
+
analytics_name: string;
|
|
162
|
+
membership_type: "non_member" | "member";
|
|
163
|
+
color: string;
|
|
164
|
+
group_join_type: "open" | "closed" | "email_domain";
|
|
165
|
+
group_visibility: "private" | "public_to_all" | "public_to_schools";
|
|
166
|
+
asset_library_visibility: "show" | "hide";
|
|
167
|
+
roles?: any[];
|
|
168
|
+
description?: string;
|
|
169
|
+
icon_url?: SidechatPrivateAssetURL;
|
|
170
|
+
member_count?: number;
|
|
171
|
+
should_show_leaderboard?: boolean;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* An asset object, containing information about an image within a post or comment
|
|
176
|
+
* @property id - alphanumeric ID of asset
|
|
177
|
+
* @property type - undocumented
|
|
178
|
+
* @property content_type - file type of asset
|
|
179
|
+
* @property width - the width of asset
|
|
180
|
+
* @property height - the height of asset
|
|
181
|
+
* @property url - URL string of asset's location
|
|
182
|
+
*/
|
|
183
|
+
declare type SidechatAsset = {
|
|
184
|
+
id: string;
|
|
185
|
+
type: "image";
|
|
186
|
+
content_type: "jpeg" | "png" | "gif";
|
|
187
|
+
width: number;
|
|
188
|
+
height: number;
|
|
189
|
+
url: SidechatPrivateAssetURL;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* A user's identity information
|
|
194
|
+
* @property name - representation of user's name (varies across app)
|
|
195
|
+
* @property posted_with_username - undocumented
|
|
196
|
+
*/
|
|
197
|
+
declare type SidechatIdentity = {
|
|
198
|
+
name: string;
|
|
199
|
+
posted_with_username: boolean;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* An asset URL that can only be accessed by making a request with a user's bearer token attached in the Authorization header
|
|
204
|
+
*/
|
|
205
|
+
declare type SidechatPrivateAssetURL = string;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* A cursor for paginating through post lists
|
|
209
|
+
*/
|
|
210
|
+
declare type SidechatCursorString = string;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* A vote on a comment or post
|
|
214
|
+
*/
|
|
215
|
+
declare type SidechatVoteString = "upvote" | "downvote" | "none";
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* A user's bearer authentication token needed for most requests
|
|
219
|
+
*/
|
|
220
|
+
declare type SidechatAuthToken = string;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* A list of posts and the associated cursor
|
|
224
|
+
*/
|
|
225
|
+
declare type SidechatPostsAndCursor = {
|
|
226
|
+
posts: SidechatPostOrComment[];
|
|
227
|
+
cursor: SidechatCursorString;
|
|
228
|
+
};
|
|
229
|
+
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sidechat.js",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "A reverse-engineered API wrapper for Sidechat",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.js",
|
|
7
|
+
"types": "./dist/types.d.ts",
|
|
7
8
|
"exports": {
|
|
8
9
|
"require": "./dist/sidechat.cjs",
|
|
9
10
|
"default": "./dist/sidechat.modern.js"
|
|
@@ -14,7 +15,9 @@
|
|
|
14
15
|
"scripts": {
|
|
15
16
|
"build": "microbundle",
|
|
16
17
|
"dev": "microbundle watch",
|
|
17
|
-
"docs": "npx jsdoc --configure jsdoc.json --verbose"
|
|
18
|
+
"docs": "npx jsdoc --configure jsdoc.json --verbose",
|
|
19
|
+
"prepublish": "jsdoc -r src -t node_modules/tsd-jsdoc/dist -d dist",
|
|
20
|
+
"typegen": "jsdoc -r src -t node_modules/tsd-jsdoc/dist -d dist"
|
|
18
21
|
},
|
|
19
22
|
"repository": {
|
|
20
23
|
"type": "git",
|
|
@@ -33,5 +36,8 @@
|
|
|
33
36
|
"clean-jsdoc-theme": "^4.2.17",
|
|
34
37
|
"microbundle": "^0.15.1",
|
|
35
38
|
"prompt-sync": "^4.2.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"tsd-jsdoc": "^2.5.0"
|
|
36
42
|
}
|
|
37
43
|
}
|