sidechat.js 2.0.1 → 2.0.2

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.
@@ -0,0 +1,104 @@
1
+ export default SidechatAPIClient;
2
+ /**
3
+ * API client class for making requests to Sidechat's private API. You'll need to [authenticate]{@tutorial Authentication} before using most of the methods.
4
+ * @class
5
+ * @since 2.0.0-alpha.0
6
+ */
7
+ declare class SidechatAPIClient {
8
+ /**
9
+ * Create a new instance of the API client
10
+ * @param {SidechatAuthToken} [token] - user bearer token
11
+ */
12
+ constructor(token?: SidechatAuthToken);
13
+ /**
14
+ * User bearer token
15
+ * @type {SidechatAuthToken}
16
+ * */
17
+ userToken: SidechatAuthToken;
18
+ /**
19
+ * Default headers for every API request
20
+ * @type {Object}
21
+ * @static
22
+ */
23
+ defaultHeaders: any;
24
+ /**
25
+ * 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
26
+ * @method
27
+ * @param {SidechatAuthToken} token - user bearer token
28
+ */
29
+ setToken: (token: SidechatAuthToken) => void;
30
+ /**
31
+ * Initiate the login process with a phone number. Should be followed up with verifySMSCode().
32
+ * @method
33
+ * @param {Number} phoneNumber - US phone number (WITHOUT +1) to send verification code to
34
+ */
35
+ loginViaSMS: (phoneNumber: number) => Promise<any>;
36
+ /**
37
+ * Verify the code sent via SMS with loginViaSMS().
38
+ * @method
39
+ * @param {Number} phoneNumber - US phone number (WITHOUT +1) that verification code was sent to
40
+ * @param {String} code - the verification code
41
+ */
42
+ verifySMSCode: (phoneNumber: number, code: string) => Promise<any>;
43
+ /**
44
+ * Set the user's age
45
+ * @method
46
+ * @param {Number} age - user's age in years
47
+ * @param {String} registrationID - the registration ID generated by verifySMSCode()
48
+ */
49
+ setAge: (age: number, registrationID: string) => Promise<any>;
50
+ /**
51
+ * Initiate the email setup process. Should be followed up with checkEmailVerification().
52
+ * @method
53
+ * @param {String} email - school email address to send verification code to
54
+ * @tutorial Email Registration
55
+ */
56
+ registerEmail: (email: string) => Promise<any>;
57
+ /**
58
+ * Check is the user's email is verified.
59
+ * @method
60
+ */
61
+ checkEmailVerification: () => Promise<any>;
62
+ /**
63
+ * Set the device ID of the current user
64
+ * @method
65
+ * @param {String} deviceId - the device ID to set
66
+ */
67
+ setDeviceID: (deviceID: any) => Promise<any>;
68
+ /**
69
+ * Get updated status for user and group
70
+ * @method
71
+ * @param {String} [groupID] - ID of a specific group to retrieve info from
72
+ */
73
+ getUserAndGroup: (groupID?: string) => Promise<any>;
74
+ /**
75
+ * Fetches posts from the specified category in a group
76
+ * @method
77
+ * @param {String} groupID - group ID
78
+ * @param {"hot"|"recent"|"top"} category - category to filter posts
79
+ * @param {SidechatCursorString} [cursor] - cursor string
80
+ * @returns {SidechatPostsAndCursor} List of posts and cursor
81
+ */
82
+ getGroupPosts: (groupID: string, category?: "hot" | "recent" | "top", cursor?: SidechatCursorString) => SidechatPostsAndCursor;
83
+ /**
84
+ * Upvote or downvote, or unvote a post
85
+ * @method
86
+ * @param {String} postID - post ID to vote on
87
+ * @param {SidechatVoteString} action - whether to upvote, downvote, or reset vote
88
+ */
89
+ setVote: (postID: string, action: SidechatVoteString) => Promise<any>;
90
+ /**
91
+ * Get all the commments on a post
92
+ * @method
93
+ * @param {String} postID - post ID to get comments for
94
+ * @returns {SidechatPostOrComment[]} list of comments
95
+ */
96
+ getPostComments: (postID: string) => SidechatPostOrComment[];
97
+ /**
98
+ * Gets groups to be displayed on the "Explore Groups" page
99
+ * @method
100
+ * @returns {SidechatGroup[]}
101
+ */
102
+ getAvailableGroups: () => SidechatGroup[];
103
+ }
104
+ //# sourceMappingURL=SidechatAPIClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidechatAPIClient.d.ts","sourceRoot":"","sources":["../../src/classes/SidechatAPIClient.js"],"names":[],"mappings":";AAGA;;;;GAIG;AACH;IAgBE;;;OAGG;IACH,oBAFW,iBAAiB,EAM3B;IAvBD;;;SAGK;IACL,WAFU,iBAAiB,CAEjB;IACV;;;;OAIG;IACH,oBAGE;IAYF;;;;OAIG;IACH,kBAFW,iBAAiB,UAI1B;IAEF;;;;OAIG;IACH,mDAgBE;IAEF;;;;;OAKG;IACH,mEAsBE;IAEF;;;;;OAKG;IACH,8DAyBE;IAEF;;;;;OAKG;IACH,+CA2BE;IAEF;;;OAGG;IACH,2CAyBE;IAEF;;;;OAIG;IACH,6CA2BE;IAEF;;;;OAIG;IACH,oDAqBE;IAEF;;;;;;;OAOG;IACH,4CAJW,KAAK,GAAC,QAAQ,GAAC,KAAK,WACpB,oBAAoB,KAClB,sBAAsB,CAyBjC;IAEF;;;;;OAKG;IACH,kCAFW,kBAAkB,kBAwB3B;IAEF;;;;;OAKG;IACH,qCAFa,qBAAqB,EAAE,CAqElC;IAEF;;;;OAIG;IACH,0BAFa,aAAa,EAAE,CAoB1B;CACH"}
@@ -0,0 +1,10 @@
1
+ export default SidechatAPIError;
2
+ /**
3
+ * Throwable error caused by the Sidechat API
4
+ * @class
5
+ * @extends Error
6
+ */
7
+ declare class SidechatAPIError extends Error {
8
+ constructor(message: any);
9
+ }
10
+ //# sourceMappingURL=SidechatAPIError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidechatAPIError.d.ts","sourceRoot":"","sources":["../../src/classes/SidechatAPIError.js"],"names":[],"mappings":";AAAA;;;;GAIG;AACH;IACE,0BAGC;CACF"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- import SidechatAPIClient from "./classes/SidechatAPIClient.js";
2
- import SidechatAPIError from "./classes/SidechatAPIError.js";
3
- export { SidechatAPIClient, SidechatAPIError };
1
+ import SidechatAPIClient from "./classes/SidechatAPIClient.js";
2
+ import SidechatAPIError from "./classes/SidechatAPIError.js";
3
+ export { SidechatAPIClient, SidechatAPIError };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"8BAA8B,gCAAgC;6BACjC,+BAA+B"}
@@ -0,0 +1,224 @@
1
+ /**
2
+ * A user-created post or comment, depending on the "type" prop
3
+ */
4
+ type SidechatPostOrComment = {
5
+ /**
6
+ * - whether this object represents a post or a comment on a post
7
+ */
8
+ type: "post" | "comment";
9
+ /**
10
+ * - alphanumeric ID of post or comment
11
+ */
12
+ id: string;
13
+ /**
14
+ * - undocumented
15
+ */
16
+ authored_by_user: boolean;
17
+ /**
18
+ * - post creator's name in-app
19
+ */
20
+ alias: string;
21
+ /**
22
+ * - alphanumeric ID of group
23
+ */
24
+ group_id: string;
25
+ /**
26
+ * - group in which post or comment was created
27
+ */
28
+ group: SidechatGroup;
29
+ /**
30
+ * - text content of post or comment
31
+ */
32
+ text: string;
33
+ /**
34
+ * - date string of post or comment creation time
35
+ */
36
+ created_at: string;
37
+ /**
38
+ * - sum of upvotes and downvotes
39
+ */
40
+ vote_total: number;
41
+ /**
42
+ * - current user's vote on post or comment
43
+ */
44
+ vote_status: SidechatVoteString;
45
+ /**
46
+ * - array of assets attached to post or comment
47
+ */
48
+ assets: SidechatAsset[];
49
+ /**
50
+ * - undocumented
51
+ */
52
+ attachments: any[];
53
+ /**
54
+ * - whether or not you can send a DM to creator of post
55
+ */
56
+ dms_disabled: boolean;
57
+ /**
58
+ * - undocumented
59
+ */
60
+ tags: any[];
61
+ /**
62
+ * - creator's identity information
63
+ */
64
+ identity: SidechatIdentity;
65
+ /**
66
+ * - undocumented
67
+ */
68
+ pinned: boolean;
69
+ /**
70
+ * - undocumented
71
+ */
72
+ is_saved: boolean;
73
+ /**
74
+ * - undocumented
75
+ */
76
+ follow_status: "following" | "not_following";
77
+ /**
78
+ * - undocumented
79
+ */
80
+ destination?: "group";
81
+ /**
82
+ * - number of comments on post (only if type=post)
83
+ */
84
+ comment_count?: number;
85
+ /**
86
+ * - whether or not you can comment on post (only if type=post)
87
+ */
88
+ comments_disabled?: boolean;
89
+ /**
90
+ * - alphanumeric ID of parent post (only if type=comment)
91
+ */
92
+ parent_post_id?: string;
93
+ /**
94
+ * - alphanumeric ID of comment being replied to, falls back to parent_post_id (only if type=comment)
95
+ */
96
+ reply_post_id?: string;
97
+ /**
98
+ * - text content of comment being replied to, falls back to text (only if type=comment)
99
+ */
100
+ context?: string;
101
+ };
102
+ /**
103
+ * A group object, containing metadata about a group as well as its join conditions and states
104
+ */
105
+ type SidechatGroup = {
106
+ /**
107
+ * - alphanumeric ID of group
108
+ */
109
+ id: string;
110
+ /**
111
+ * - human-readable name of group
112
+ */
113
+ name: string;
114
+ /**
115
+ * - name to file group under
116
+ */
117
+ analytics_name: string;
118
+ /**
119
+ * - whether or not current user is a member of group
120
+ */
121
+ membership_type: "non_member" | "member";
122
+ /**
123
+ * - group's theme color as hex code (e.g., #FFFFFF)
124
+ */
125
+ color: string;
126
+ /**
127
+ * - basis on which group accepts new members
128
+ */
129
+ group_join_type: "open" | "closed" | "email_domain";
130
+ /**
131
+ * - group's visibility setting
132
+ */
133
+ group_visibility: "private" | "public_to_all" | "public_to_schools";
134
+ /**
135
+ * - whether or not group's asset library is visible
136
+ */
137
+ asset_library_visibility: "show" | "hide";
138
+ /**
139
+ * - undocumented
140
+ */
141
+ roles?: any[];
142
+ /**
143
+ * - description of group
144
+ */
145
+ description?: string;
146
+ /**
147
+ * - image URL for group icon
148
+ */
149
+ icon_url?: SidechatPrivateAssetURL;
150
+ /**
151
+ * - number of users in group
152
+ */
153
+ member_count?: number;
154
+ /**
155
+ * - undocumented
156
+ */
157
+ should_show_leaderboard?: boolean;
158
+ };
159
+ /**
160
+ * An asset object, containing information about an image within a post or comment
161
+ */
162
+ type SidechatAsset = {
163
+ /**
164
+ * - alphanumeric ID of asset
165
+ */
166
+ id: string;
167
+ /**
168
+ * - undocumented
169
+ */
170
+ type: "image";
171
+ /**
172
+ * - file type of asset
173
+ */
174
+ content_type: "jpeg" | "png" | "gif";
175
+ /**
176
+ * - the width of asset
177
+ */
178
+ width: number;
179
+ /**
180
+ * - the height of asset
181
+ */
182
+ height: number;
183
+ /**
184
+ * - URL string of asset's location
185
+ */
186
+ url: SidechatPrivateAssetURL;
187
+ };
188
+ /**
189
+ * A user's identity information
190
+ */
191
+ type SidechatIdentity = {
192
+ /**
193
+ * - representation of user's name (varies across app)
194
+ */
195
+ name: string;
196
+ /**
197
+ * - undocumented
198
+ */
199
+ posted_with_username: boolean;
200
+ };
201
+ /**
202
+ * An asset URL that can only be accessed by making a request with a user's bearer token attached in the Authorization header
203
+ */
204
+ type SidechatPrivateAssetURL = string;
205
+ /**
206
+ * A cursor for paginating through post lists
207
+ */
208
+ type SidechatCursorString = string;
209
+ /**
210
+ * A vote on a comment or post
211
+ */
212
+ type SidechatVoteString = "upvote" | "downvote" | "none";
213
+ /**
214
+ * A user's bearer authentication token needed for most requests
215
+ */
216
+ type SidechatAuthToken = string;
217
+ /**
218
+ * A list of posts and the associated cursor
219
+ */
220
+ type SidechatPostsAndCursor = {
221
+ posts: SidechatPostOrComment[];
222
+ cursor: SidechatCursorString;
223
+ };
224
+ //# sourceMappingURL=SidechatTypes.d.ts.map
@@ -0,0 +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,aAAa,EAAE;;;;;;;;;;;;;;;;cAIf,gBAAgB;;;;;;;;;;;;mBAGhB,WAAW,GAAC,eAAe;;;;kBAC3B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAcP,YAAY,GAAC,QAAQ;;;;;;;;qBAErB,MAAM,GAAC,QAAQ,GAAC,cAAc;;;;sBAC9B,SAAS,GAAC,eAAe,GAAC,mBAAmB;;;;8BAC7C,MAAM,GAAC,MAAM;;;;;;;;;;;;eAGb,uBAAuB;;;;;;;;;;;;;;;;;;;;;UASvB,OAAO;;;;kBACP,MAAM,GAAC,KAAK,GAAC,KAAK;;;;;;;;;;;;SAGlB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;0BAsBpB,QAAQ,GAAC,UAAU,GAAC,MAAM;;;;;;;;;WAW7B,qBAAqB,EAAE;YACvB,oBAAoB"}
package/package.json CHANGED
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "name": "sidechat.js",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
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
+ "types": "./src/index.d.ts",
8
8
  "exports": {
9
- "require": "./dist/sidechat.cjs",
10
- "default": "./dist/sidechat.modern.js"
9
+ "default": "./dist/sidechat.modern.js",
10
+ "require": "./dist/sidechat.cjs"
11
11
  },
12
+ "unpkg": "./dist/sidechat.umd.js",
12
13
  "main": "./dist/sidechat.cjs",
13
14
  "module": "./dist/sidechat.module.js",
14
- "unpkg": "./dist/sidechat.umd.js",
15
15
  "scripts": {
16
16
  "build": "microbundle",
17
17
  "dev": "microbundle watch",
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
+ "docs": "jsdoc --configure jsdoc.json --verbose",
19
+ "prepublish": "tsc",
20
+ "typegen": "tsc"
21
21
  },
22
22
  "repository": {
23
23
  "type": "git",
@@ -35,7 +35,8 @@
35
35
  "devDependencies": {
36
36
  "clean-jsdoc-theme": "^4.2.17",
37
37
  "microbundle": "^0.15.1",
38
- "prompt-sync": "^4.2.0"
38
+ "prompt-sync": "^4.2.0",
39
+ "typescript": "^5.4.2"
39
40
  },
40
41
  "dependencies": {
41
42
  "tsd-jsdoc": "^2.5.0"
@@ -0,0 +1,104 @@
1
+ export default SidechatAPIClient;
2
+ /**
3
+ * API client class for making requests to Sidechat's private API. You'll need to [authenticate]{@tutorial Authentication} before using most of the methods.
4
+ * @class
5
+ * @since 2.0.0-alpha.0
6
+ */
7
+ declare class SidechatAPIClient {
8
+ /**
9
+ * Create a new instance of the API client
10
+ * @param {SidechatAuthToken} [token] - user bearer token
11
+ */
12
+ constructor(token?: SidechatAuthToken);
13
+ /**
14
+ * User bearer token
15
+ * @type {SidechatAuthToken}
16
+ * */
17
+ userToken: SidechatAuthToken;
18
+ /**
19
+ * Default headers for every API request
20
+ * @type {Object}
21
+ * @static
22
+ */
23
+ defaultHeaders: any;
24
+ /**
25
+ * 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
26
+ * @method
27
+ * @param {SidechatAuthToken} token - user bearer token
28
+ */
29
+ setToken: (token: SidechatAuthToken) => void;
30
+ /**
31
+ * Initiate the login process with a phone number. Should be followed up with verifySMSCode().
32
+ * @method
33
+ * @param {Number} phoneNumber - US phone number (WITHOUT +1) to send verification code to
34
+ */
35
+ loginViaSMS: (phoneNumber: number) => Promise<any>;
36
+ /**
37
+ * Verify the code sent via SMS with loginViaSMS().
38
+ * @method
39
+ * @param {Number} phoneNumber - US phone number (WITHOUT +1) that verification code was sent to
40
+ * @param {String} code - the verification code
41
+ */
42
+ verifySMSCode: (phoneNumber: number, code: string) => Promise<any>;
43
+ /**
44
+ * Set the user's age
45
+ * @method
46
+ * @param {Number} age - user's age in years
47
+ * @param {String} registrationID - the registration ID generated by verifySMSCode()
48
+ */
49
+ setAge: (age: number, registrationID: string) => Promise<any>;
50
+ /**
51
+ * Initiate the email setup process. Should be followed up with checkEmailVerification().
52
+ * @method
53
+ * @param {String} email - school email address to send verification code to
54
+ * @tutorial Email Registration
55
+ */
56
+ registerEmail: (email: string) => Promise<any>;
57
+ /**
58
+ * Check is the user's email is verified.
59
+ * @method
60
+ */
61
+ checkEmailVerification: () => Promise<any>;
62
+ /**
63
+ * Set the device ID of the current user
64
+ * @method
65
+ * @param {String} deviceId - the device ID to set
66
+ */
67
+ setDeviceID: (deviceID: any) => Promise<any>;
68
+ /**
69
+ * Get updated status for user and group
70
+ * @method
71
+ * @param {String} [groupID] - ID of a specific group to retrieve info from
72
+ */
73
+ getUserAndGroup: (groupID?: string) => Promise<any>;
74
+ /**
75
+ * Fetches posts from the specified category in a group
76
+ * @method
77
+ * @param {String} groupID - group ID
78
+ * @param {"hot"|"recent"|"top"} category - category to filter posts
79
+ * @param {SidechatCursorString} [cursor] - cursor string
80
+ * @returns {SidechatPostsAndCursor} List of posts and cursor
81
+ */
82
+ getGroupPosts: (groupID: string, category?: "hot" | "recent" | "top", cursor?: SidechatCursorString) => SidechatPostsAndCursor;
83
+ /**
84
+ * Upvote or downvote, or unvote a post
85
+ * @method
86
+ * @param {String} postID - post ID to vote on
87
+ * @param {SidechatVoteString} action - whether to upvote, downvote, or reset vote
88
+ */
89
+ setVote: (postID: string, action: SidechatVoteString) => Promise<any>;
90
+ /**
91
+ * Get all the commments on a post
92
+ * @method
93
+ * @param {String} postID - post ID to get comments for
94
+ * @returns {SidechatPostOrComment[]} list of comments
95
+ */
96
+ getPostComments: (postID: string) => SidechatPostOrComment[];
97
+ /**
98
+ * Gets groups to be displayed on the "Explore Groups" page
99
+ * @method
100
+ * @returns {SidechatGroup[]}
101
+ */
102
+ getAvailableGroups: () => SidechatGroup[];
103
+ }
104
+ //# sourceMappingURL=SidechatAPIClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidechatAPIClient.d.ts","sourceRoot":"","sources":["SidechatAPIClient.js"],"names":[],"mappings":";AAGA;;;;GAIG;AACH;IAgBE;;;OAGG;IACH,oBAFW,iBAAiB,EAM3B;IAvBD;;;SAGK;IACL,WAFU,iBAAiB,CAEjB;IACV;;;;OAIG;IACH,oBAGE;IAYF;;;;OAIG;IACH,kBAFW,iBAAiB,UAI1B;IAEF;;;;OAIG;IACH,mDAgBE;IAEF;;;;;OAKG;IACH,mEAsBE;IAEF;;;;;OAKG;IACH,8DAyBE;IAEF;;;;;OAKG;IACH,+CA2BE;IAEF;;;OAGG;IACH,2CAyBE;IAEF;;;;OAIG;IACH,6CA2BE;IAEF;;;;OAIG;IACH,oDAqBE;IAEF;;;;;;;OAOG;IACH,4CAJW,KAAK,GAAC,QAAQ,GAAC,KAAK,WACpB,oBAAoB,KAClB,sBAAsB,CAyBjC;IAEF;;;;;OAKG;IACH,kCAFW,kBAAkB,kBAwB3B;IAEF;;;;;OAKG;IACH,qCAFa,qBAAqB,EAAE,CAqElC;IAEF;;;;OAIG;IACH,0BAFa,aAAa,EAAE,CAoB1B;CACH"}
@@ -0,0 +1,10 @@
1
+ export default SidechatAPIError;
2
+ /**
3
+ * Throwable error caused by the Sidechat API
4
+ * @class
5
+ * @extends Error
6
+ */
7
+ declare class SidechatAPIError extends Error {
8
+ constructor(message: any);
9
+ }
10
+ //# sourceMappingURL=SidechatAPIError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidechatAPIError.d.ts","sourceRoot":"","sources":["SidechatAPIError.js"],"names":[],"mappings":";AAAA;;;;GAIG;AACH;IACE,0BAGC;CACF"}
package/src/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import SidechatAPIClient from "./classes/SidechatAPIClient.js";
2
+ import SidechatAPIError from "./classes/SidechatAPIError.js";
3
+ export { SidechatAPIClient, SidechatAPIError };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"8BAC8B,gCAAgC;6BACjC,+BAA+B"}
package/src/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import "./types/SidechatTypes";
1
2
  import SidechatAPIClient from "./classes/SidechatAPIClient.js";
2
3
  import SidechatAPIError from "./classes/SidechatAPIError.js";
3
4
 
@@ -0,0 +1,224 @@
1
+ /**
2
+ * A user-created post or comment, depending on the "type" prop
3
+ */
4
+ type SidechatPostOrComment = {
5
+ /**
6
+ * - whether this object represents a post or a comment on a post
7
+ */
8
+ type: "post" | "comment";
9
+ /**
10
+ * - alphanumeric ID of post or comment
11
+ */
12
+ id: string;
13
+ /**
14
+ * - undocumented
15
+ */
16
+ authored_by_user: boolean;
17
+ /**
18
+ * - post creator's name in-app
19
+ */
20
+ alias: string;
21
+ /**
22
+ * - alphanumeric ID of group
23
+ */
24
+ group_id: string;
25
+ /**
26
+ * - group in which post or comment was created
27
+ */
28
+ group: SidechatGroup;
29
+ /**
30
+ * - text content of post or comment
31
+ */
32
+ text: string;
33
+ /**
34
+ * - date string of post or comment creation time
35
+ */
36
+ created_at: string;
37
+ /**
38
+ * - sum of upvotes and downvotes
39
+ */
40
+ vote_total: number;
41
+ /**
42
+ * - current user's vote on post or comment
43
+ */
44
+ vote_status: SidechatVoteString;
45
+ /**
46
+ * - array of assets attached to post or comment
47
+ */
48
+ assets: SidechatAsset[];
49
+ /**
50
+ * - undocumented
51
+ */
52
+ attachments: any[];
53
+ /**
54
+ * - whether or not you can send a DM to creator of post
55
+ */
56
+ dms_disabled: boolean;
57
+ /**
58
+ * - undocumented
59
+ */
60
+ tags: any[];
61
+ /**
62
+ * - creator's identity information
63
+ */
64
+ identity: SidechatIdentity;
65
+ /**
66
+ * - undocumented
67
+ */
68
+ pinned: boolean;
69
+ /**
70
+ * - undocumented
71
+ */
72
+ is_saved: boolean;
73
+ /**
74
+ * - undocumented
75
+ */
76
+ follow_status: "following" | "not_following";
77
+ /**
78
+ * - undocumented
79
+ */
80
+ destination?: "group";
81
+ /**
82
+ * - number of comments on post (only if type=post)
83
+ */
84
+ comment_count?: number;
85
+ /**
86
+ * - whether or not you can comment on post (only if type=post)
87
+ */
88
+ comments_disabled?: boolean;
89
+ /**
90
+ * - alphanumeric ID of parent post (only if type=comment)
91
+ */
92
+ parent_post_id?: string;
93
+ /**
94
+ * - alphanumeric ID of comment being replied to, falls back to parent_post_id (only if type=comment)
95
+ */
96
+ reply_post_id?: string;
97
+ /**
98
+ * - text content of comment being replied to, falls back to text (only if type=comment)
99
+ */
100
+ context?: string;
101
+ };
102
+ /**
103
+ * A group object, containing metadata about a group as well as its join conditions and states
104
+ */
105
+ type SidechatGroup = {
106
+ /**
107
+ * - alphanumeric ID of group
108
+ */
109
+ id: string;
110
+ /**
111
+ * - human-readable name of group
112
+ */
113
+ name: string;
114
+ /**
115
+ * - name to file group under
116
+ */
117
+ analytics_name: string;
118
+ /**
119
+ * - whether or not current user is a member of group
120
+ */
121
+ membership_type: "non_member" | "member";
122
+ /**
123
+ * - group's theme color as hex code (e.g., #FFFFFF)
124
+ */
125
+ color: string;
126
+ /**
127
+ * - basis on which group accepts new members
128
+ */
129
+ group_join_type: "open" | "closed" | "email_domain";
130
+ /**
131
+ * - group's visibility setting
132
+ */
133
+ group_visibility: "private" | "public_to_all" | "public_to_schools";
134
+ /**
135
+ * - whether or not group's asset library is visible
136
+ */
137
+ asset_library_visibility: "show" | "hide";
138
+ /**
139
+ * - undocumented
140
+ */
141
+ roles?: any[];
142
+ /**
143
+ * - description of group
144
+ */
145
+ description?: string;
146
+ /**
147
+ * - image URL for group icon
148
+ */
149
+ icon_url?: SidechatPrivateAssetURL;
150
+ /**
151
+ * - number of users in group
152
+ */
153
+ member_count?: number;
154
+ /**
155
+ * - undocumented
156
+ */
157
+ should_show_leaderboard?: boolean;
158
+ };
159
+ /**
160
+ * An asset object, containing information about an image within a post or comment
161
+ */
162
+ type SidechatAsset = {
163
+ /**
164
+ * - alphanumeric ID of asset
165
+ */
166
+ id: string;
167
+ /**
168
+ * - undocumented
169
+ */
170
+ type: "image";
171
+ /**
172
+ * - file type of asset
173
+ */
174
+ content_type: "jpeg" | "png" | "gif";
175
+ /**
176
+ * - the width of asset
177
+ */
178
+ width: number;
179
+ /**
180
+ * - the height of asset
181
+ */
182
+ height: number;
183
+ /**
184
+ * - URL string of asset's location
185
+ */
186
+ url: SidechatPrivateAssetURL;
187
+ };
188
+ /**
189
+ * A user's identity information
190
+ */
191
+ type SidechatIdentity = {
192
+ /**
193
+ * - representation of user's name (varies across app)
194
+ */
195
+ name: string;
196
+ /**
197
+ * - undocumented
198
+ */
199
+ posted_with_username: boolean;
200
+ };
201
+ /**
202
+ * An asset URL that can only be accessed by making a request with a user's bearer token attached in the Authorization header
203
+ */
204
+ type SidechatPrivateAssetURL = string;
205
+ /**
206
+ * A cursor for paginating through post lists
207
+ */
208
+ type SidechatCursorString = string;
209
+ /**
210
+ * A vote on a comment or post
211
+ */
212
+ type SidechatVoteString = "upvote" | "downvote" | "none";
213
+ /**
214
+ * A user's bearer authentication token needed for most requests
215
+ */
216
+ type SidechatAuthToken = string;
217
+ /**
218
+ * A list of posts and the associated cursor
219
+ */
220
+ type SidechatPostsAndCursor = {
221
+ posts: SidechatPostOrComment[];
222
+ cursor: SidechatCursorString;
223
+ };
224
+ //# sourceMappingURL=SidechatTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidechatTypes.d.ts","sourceRoot":"","sources":["SidechatTypes.js"],"names":[],"mappings":";;;;;;;UAGU,MAAM,GAAC,SAAS;;;;;;;;;;;;;;;;;;;;WAKhB,aAAa;;;;;;;;;;;;;;;;iBAIb,kBAAkB;;;;YAClB,aAAa,EAAE;;;;;;;;;;;;;;;;cAIf,gBAAgB;;;;;;;;;;;;mBAGhB,WAAW,GAAC,eAAe;;;;kBAC3B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAcP,YAAY,GAAC,QAAQ;;;;;;;;qBAErB,MAAM,GAAC,QAAQ,GAAC,cAAc;;;;sBAC9B,SAAS,GAAC,eAAe,GAAC,mBAAmB;;;;8BAC7C,MAAM,GAAC,MAAM;;;;;;;;;;;;eAGb,uBAAuB;;;;;;;;;;;;;;;;;;;;;UASvB,OAAO;;;;kBACP,MAAM,GAAC,KAAK,GAAC,KAAK;;;;;;;;;;;;SAGlB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;0BAsBpB,QAAQ,GAAC,UAAU,GAAC,MAAM;;;;;;;;;WAW7B,qBAAqB,EAAE;YACvB,oBAAoB"}
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ // Change this to match your project
3
+ "include": ["src/*.js"],
4
+ "exclude": ["src/tests", "src/internal"],
5
+ "compilerOptions": {
6
+ // Tells TypeScript to read JS files, as
7
+ // normally they are ignored as source files
8
+ "allowJs": true,
9
+ // Generate d.ts files
10
+ "declaration": true,
11
+ // This compiler run should
12
+ // only output d.ts files
13
+ "emitDeclarationOnly": true,
14
+ // go to js file when using IDE functions like
15
+ // "Go to Definition" in VSCode
16
+ "declarationMap": true
17
+ }
18
+ }
package/dist/types.d.ts DELETED
@@ -1,229 +0,0 @@
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
-