Skip to content

Commit c1b52f8

Browse files
authored
chore: refactor twitter-types, add vitest config, and bump deps (#122)
1 parent e4d9e4b commit c1b52f8

23 files changed

+848
-900
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ updates:
55
- package-ecosystem: "npm"
66
directory: "/"
77
schedule:
8-
interval: "daily"
8+
interval: "weekly"
99
versioning-strategy: increase
1010
open-pull-requests-limit: 10

package-lock.json

Lines changed: 565 additions & 491 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@
1919
"prepublishOnly": "npm run build && npm run zx"
2020
},
2121
"dependencies": {
22-
"@discordjs/collection": "^0.3.2",
22+
"@discordjs/collection": "^0.4.0",
2323
"@sapphire/async-queue": "^1.1.9",
2424
"oauth-1.0a": "^2.2.6",
25+
"twitter-types": "^0.20.0",
2526
"undici": "^4.12.1"
2627
},
2728
"devDependencies": {
28-
"@commitlint/cli": "^15.0.0",
29-
"@commitlint/config-angular": "^15.0.0",
30-
"@types/node": "^16.11.12",
31-
"@typescript-eslint/eslint-plugin": "^5.6.0",
32-
"@typescript-eslint/parser": "^5.6.0",
33-
"eslint": "^8.4.1",
29+
"@commitlint/cli": "^16.0.1",
30+
"@commitlint/config-angular": "^16.0.0",
31+
"@types/node": "^17.0.8",
32+
"@typescript-eslint/eslint-plugin": "^5.9.0",
33+
"@typescript-eslint/parser": "^5.9.0",
34+
"eslint": "^8.6.0",
3435
"eslint-config-prettier": "^8.3.0",
3536
"eslint-plugin-prettier": "^4.0.0",
3637
"husky": "^7.0.4",
37-
"lint-staged": "^12.1.2",
38+
"lint-staged": "^12.1.6",
3839
"prettier": "^2.5.1",
39-
"twitter-types": "^0.19.1",
4040
"typedoc": "^0.22.10",
4141
"typescript": "^4.5.4",
42-
"vitest": "^0.0.124",
42+
"vitest": "^0.0.136",
4343
"zx": "^4.2.0"
4444
},
4545
"files": [

src/books/BlocksBook.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { RequestData } from '../structures';
55
import type { Client } from '../client';
66
import type { User } from '../structures';
77
import type { BlocksBookOptions } from '../typings';
8-
import type { GET_2_users_id_blocking_Query, GET_2_users_id_blocking_Response, Snowflake } from 'twitter-types';
8+
import type { GETUsersIdBlockingQuery, GETUsersIdBlockingResponse, Snowflake } from 'twitter-types';
99

1010
/**
1111
* A class for fetching users blocked by the authorized user
@@ -85,15 +85,15 @@ export class BlocksBook extends BaseBook {
8585
async #fetchPages(token?: string): Promise<Collection<Snowflake, User>> {
8686
const blockedUsersCollection = new Collection<Snowflake, User>();
8787
const queryParameters = this.client.options.queryParameters;
88-
const query: GET_2_users_id_blocking_Query = {
88+
const query: GETUsersIdBlockingQuery = {
8989
expansions: queryParameters?.userExpansions,
9090
'tweet.fields': queryParameters?.tweetFields,
9191
'user.fields': queryParameters?.userFields,
9292
pagination_token: token,
9393
};
9494
if (this.maxResultsPerPage) query.max_results = this.maxResultsPerPage;
9595
const requestData = new RequestData({ query, isUserContext: true });
96-
const data: GET_2_users_id_blocking_Response = await this.client._api.users(this.userId).blocking.get(requestData);
96+
const data: GETUsersIdBlockingResponse = await this.client._api.users(this.userId).blocking.get(requestData);
9797
this.#nextToken = data.meta.next_token;
9898
this.#previousToken = data.meta.previous_token;
9999
this.hasMore = data.meta.next_token ? true : false;

src/books/ComposedTweetsBook.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { RequestData } from '../structures';
55
import type { Client } from '../client';
66
import type { Tweet } from '../structures';
77
import type { ComposedTweetsBookOptions } from '../typings';
8-
import type { GET_2_users_id_tweets_Query, GET_2_users_id_tweets_Response, Snowflake } from 'twitter-types';
8+
import type { GETUsersIdTweetsQuery, GETUsersIdTweetsResponse, Snowflake } from 'twitter-types';
99

1010
/**
1111
* A class for fetching tweets composed by a twitter user
@@ -70,7 +70,7 @@ export class ComposedTweetsBook extends BaseBook {
7070
/**
7171
* The types of tweets that the book should not fetch
7272
*/
73-
exclude: GET_2_users_id_tweets_Query['exclude'] | null;
73+
exclude: GETUsersIdTweetsQuery['exclude'] | null;
7474

7575
/**
7676
* @param client The logged in {@link Client} instance
@@ -115,7 +115,7 @@ export class ComposedTweetsBook extends BaseBook {
115115
async #fetchPages(token?: string): Promise<Collection<Snowflake, Tweet>> {
116116
const tweetsCollection = new Collection<Snowflake, Tweet>();
117117
const queryParameters = this.client.options.queryParameters;
118-
const query: GET_2_users_id_tweets_Query = {
118+
const query: GETUsersIdTweetsQuery = {
119119
expansions: queryParameters?.tweetExpansions,
120120
'media.fields': queryParameters?.mediaFields,
121121
'place.fields': queryParameters?.placeFields,
@@ -131,7 +131,7 @@ export class ComposedTweetsBook extends BaseBook {
131131
if (this.afterTimestamp) query.start_time = new Date(this.afterTimestamp).toISOString();
132132
if (this.beforeTimestamp) query.end_time = new Date(this.beforeTimestamp).toISOString();
133133
const requestData = new RequestData({ query });
134-
const data: GET_2_users_id_tweets_Response = await this.client._api.users(this.userId).tweets.get(requestData);
134+
const data: GETUsersIdTweetsResponse = await this.client._api.users(this.userId).tweets.get(requestData);
135135
this.#nextToken = data.meta.next_token;
136136
this.#previousToken = data.meta.previous_token;
137137
this.hasMore = data.meta.next_token ? true : false;

src/books/FollowersBook.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { RequestData } from '../structures';
55
import type { Client } from '../client';
66
import type { User } from '../structures';
77
import type { FollowersBookOptions } from '../typings';
8-
import type { GET_2_users_id_followers_Query, GET_2_users_id_followers_Response, Snowflake } from 'twitter-types';
8+
import type { GETUsersIdFollowersQuery, GETUsersIdFollowersResponse, Snowflake } from 'twitter-types';
99

1010
/**
1111
* A class for fetching followers of a twitter user
@@ -86,17 +86,15 @@ export class FollowersBook extends BaseBook {
8686
async #fetchPages(token?: string): Promise<Collection<Snowflake, User>> {
8787
const followersCollection = new Collection<Snowflake, User>();
8888
const queryParameters = this.client.options.queryParameters;
89-
const query: GET_2_users_id_followers_Query = {
89+
const query: GETUsersIdFollowersQuery = {
9090
expansions: queryParameters?.userExpansions,
9191
'tweet.fields': queryParameters?.tweetFields,
9292
'user.fields': queryParameters?.userFields,
9393
pagination_token: token,
9494
};
9595
if (this.maxResultsPerPage) query.max_results = this.maxResultsPerPage;
9696
const requestData = new RequestData({ query });
97-
const data: GET_2_users_id_followers_Response = await this.client._api
98-
.users(this.userId)
99-
.followers.get(requestData);
97+
const data: GETUsersIdFollowersResponse = await this.client._api.users(this.userId).followers.get(requestData);
10098
this.#nextToken = data.meta.next_token;
10199
this.#previousToken = data.meta.previous_token;
102100
this.hasMore = data.meta.next_token ? true : false;

src/books/FollowingsBook.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { RequestData } from '../structures';
55
import type { Client } from '../client';
66
import type { User } from '../structures';
77
import type { FollowingsBookOptions } from '../typings';
8-
import type { GET_2_users_id_following_Query, GET_2_users_id_following_Response, Snowflake } from 'twitter-types';
8+
import type { GETUsersIdFollowingQuery, GETUsersIdFollowingResponse, Snowflake } from 'twitter-types';
99

1010
/**
1111
* A class for fetching users followed by a twitter user
@@ -86,17 +86,15 @@ export class FollowingsBook extends BaseBook {
8686
async #fetchPages(token?: string): Promise<Collection<Snowflake, User>> {
8787
const followingsCollection = new Collection<Snowflake, User>();
8888
const queryParameters = this.client.options.queryParameters;
89-
const query: GET_2_users_id_following_Query = {
89+
const query: GETUsersIdFollowingQuery = {
9090
expansions: queryParameters?.userExpansions,
9191
'tweet.fields': queryParameters?.tweetFields,
9292
'user.fields': queryParameters?.userFields,
9393
pagination_token: token,
9494
};
9595
if (this.maxResultsPerPage) query.max_results = this.maxResultsPerPage;
9696
const requestData = new RequestData({ query });
97-
const data: GET_2_users_id_following_Response = await this.client._api
98-
.users(this.userId)
99-
.following.get(requestData);
97+
const data: GETUsersIdFollowingResponse = await this.client._api.users(this.userId).following.get(requestData);
10098
this.#nextToken = data.meta.next_token;
10199
this.#previousToken = data.meta.previous_token;
102100
this.hasMore = data.meta.next_token ? true : false;

src/books/LikedTweetsBook.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { RequestData } from '../structures';
55
import type { Client } from '../client';
66
import type { Tweet } from '../structures';
77
import type { LikedTweetsBookOptions } from '../typings';
8-
import type { GET_2_users_id_liked_tweets_Query, GET_2_users_id_liked_tweets_Response, Snowflake } from 'twitter-types';
8+
import type { GETUsersIdLikedTweetsQuery, GETUsersIdLikedTweetsResponse, Snowflake } from 'twitter-types';
99

1010
/**
1111
* A class for fetching tweets liked by a twitter user
@@ -86,7 +86,7 @@ export class LikedTweetsBook extends BaseBook {
8686
async #fetchPages(token?: string): Promise<Collection<Snowflake, Tweet>> {
8787
const likedTweetsCollection = new Collection<Snowflake, Tweet>();
8888
const queryParameters = this.client.options.queryParameters;
89-
const query: GET_2_users_id_liked_tweets_Query = {
89+
const query: GETUsersIdLikedTweetsQuery = {
9090
expansions: queryParameters?.tweetExpansions,
9191
'media.fields': queryParameters?.mediaFields,
9292
'place.fields': queryParameters?.placeFields,
@@ -97,9 +97,7 @@ export class LikedTweetsBook extends BaseBook {
9797
};
9898
if (this.maxResultsPerPage) query.max_results = this.maxResultsPerPage;
9999
const requestData = new RequestData({ query });
100-
const data: GET_2_users_id_liked_tweets_Response = await this.client._api
101-
.users(this.userId)
102-
.liked_tweets.get(requestData);
100+
const data: GETUsersIdLikedTweetsResponse = await this.client._api.users(this.userId).liked_tweets.get(requestData);
103101
this.#nextToken = data.meta.next_token;
104102
this.#previousToken = data.meta.previous_token;
105103
this.hasMore = data.meta.next_token ? true : false;

src/books/MentionsBook.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { RequestData } from '../structures';
55
import type { Client } from '../client';
66
import type { Tweet } from '../structures';
77
import type { MentionsBookOptions } from '../typings';
8-
import type { GET_2_users_id_mentions_Query, GET_2_users_id_mentions_Response, Snowflake } from 'twitter-types';
8+
import type { GETUsersIdMentionsQuery, GETUsersIdMentionsResponse, Snowflake } from 'twitter-types';
99

1010
/**
1111
* A class for fetching tweets that mention a twitter user
@@ -109,7 +109,7 @@ export class MentionsBook extends BaseBook {
109109
async #fetchPages(token?: string): Promise<Collection<Snowflake, Tweet>> {
110110
const mentioningTweetsCollection = new Collection<Snowflake, Tweet>();
111111
const queryParameters = this.client.options.queryParameters;
112-
const query: GET_2_users_id_mentions_Query = {
112+
const query: GETUsersIdMentionsQuery = {
113113
expansions: queryParameters?.tweetExpansions,
114114
'media.fields': queryParameters?.mediaFields,
115115
'place.fields': queryParameters?.placeFields,
@@ -124,7 +124,7 @@ export class MentionsBook extends BaseBook {
124124
if (this.afterTimestamp) query.start_time = new Date(this.afterTimestamp).toISOString();
125125
if (this.beforeTimestamp) query.end_time = new Date(this.beforeTimestamp).toISOString();
126126
const requestData = new RequestData({ query });
127-
const data: GET_2_users_id_mentions_Response = await this.client._api.users(this.userId).mentions.get(requestData);
127+
const data: GETUsersIdMentionsResponse = await this.client._api.users(this.userId).mentions.get(requestData);
128128
this.#nextToken = data.meta.next_token;
129129
this.#previousToken = data.meta.previous_token;
130130
this.hasMore = data.meta.next_token ? true : false;

src/books/MutesBook.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { RequestData } from '../structures';
55
import type { Client } from '../client';
66
import type { User } from '../structures';
77
import type { MutesBookOptions } from '../typings';
8-
import type { GET_2_users_id_muting_Query, GET_2_users_id_muting_Response, Snowflake } from 'twitter-types';
8+
import type { GETUsersIdMutingQuery, GETUsersIdMutingResponse, Snowflake } from 'twitter-types';
99

1010
/**
1111
* A class for fetching users muted by the authorized user
@@ -85,15 +85,15 @@ export class MutesBook extends BaseBook {
8585
async #fetchPages(token?: string): Promise<Collection<Snowflake, User>> {
8686
const mutedUsersCollection = new Collection<Snowflake, User>();
8787
const queryParameters = this.client.options.queryParameters;
88-
const query: GET_2_users_id_muting_Query = {
88+
const query: GETUsersIdMutingQuery = {
8989
expansions: queryParameters?.userExpansions,
9090
'tweet.fields': queryParameters?.tweetFields,
9191
'user.fields': queryParameters?.userFields,
9292
pagination_token: token,
9393
};
9494
if (this.maxResultsPerPage) query.max_results = this.maxResultsPerPage;
9595
const requestData = new RequestData({ query, isUserContext: true });
96-
const data: GET_2_users_id_muting_Response = await this.client._api.users(this.userId).muting.get(requestData);
96+
const data: GETUsersIdMutingResponse = await this.client._api.users(this.userId).muting.get(requestData);
9797
this.#nextToken = data.meta.next_token;
9898
this.#previousToken = data.meta.previous_token;
9999
this.hasMore = data.meta.next_token ? true : false;

0 commit comments

Comments
 (0)