twitter-openapi-typescript 0.0.24 → 0.0.26

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 (78) hide show
  1. package/.vscode/extensions.json +6 -1
  2. package/.vscode/settings.json +9 -1
  3. package/dist/src/api.d.ts +5 -3
  4. package/dist/src/api.d.ts.map +1 -1
  5. package/dist/src/api.js +13 -10
  6. package/dist/src/api.js.map +1 -1
  7. package/dist/src/apis/defaultApi.d.ts +3 -2
  8. package/dist/src/apis/defaultApi.d.ts.map +1 -1
  9. package/dist/src/apis/defaultApi.js +3 -2
  10. package/dist/src/apis/defaultApi.js.map +1 -1
  11. package/dist/src/apis/index.d.ts +3 -3
  12. package/dist/src/apis/index.d.ts.map +1 -1
  13. package/dist/src/apis/index.js +7 -7
  14. package/dist/src/apis/index.js.map +1 -1
  15. package/dist/src/apis/postApi.d.ts +4 -3
  16. package/dist/src/apis/postApi.d.ts.map +1 -1
  17. package/dist/src/apis/postApi.js +9 -2
  18. package/dist/src/apis/postApi.js.map +1 -1
  19. package/dist/src/apis/tweetApi.d.ts +3 -2
  20. package/dist/src/apis/tweetApi.d.ts.map +1 -1
  21. package/dist/src/apis/tweetApi.js +3 -2
  22. package/dist/src/apis/tweetApi.js.map +1 -1
  23. package/dist/src/apis/userApi.d.ts +3 -2
  24. package/dist/src/apis/userApi.d.ts.map +1 -1
  25. package/dist/src/apis/userApi.js +3 -2
  26. package/dist/src/apis/userApi.js.map +1 -1
  27. package/dist/src/apis/userListApi.d.ts +3 -2
  28. package/dist/src/apis/userListApi.d.ts.map +1 -1
  29. package/dist/src/apis/userListApi.js +3 -2
  30. package/dist/src/apis/userListApi.js.map +1 -1
  31. package/dist/src/apis/usersApi.d.ts +3 -2
  32. package/dist/src/apis/usersApi.d.ts.map +1 -1
  33. package/dist/src/apis/usersApi.js +3 -2
  34. package/dist/src/apis/usersApi.js.map +1 -1
  35. package/dist/src/apis/v11GetApi.d.ts +3 -2
  36. package/dist/src/apis/v11GetApi.d.ts.map +1 -1
  37. package/dist/src/apis/v11GetApi.js +2 -1
  38. package/dist/src/apis/v11GetApi.js.map +1 -1
  39. package/dist/src/apis/v11PostApi.d.ts +3 -2
  40. package/dist/src/apis/v11PostApi.d.ts.map +1 -1
  41. package/dist/src/apis/v11PostApi.js +2 -1
  42. package/dist/src/apis/v11PostApi.js.map +1 -1
  43. package/dist/src/apis/v20GetApi.d.ts +3 -2
  44. package/dist/src/apis/v20GetApi.d.ts.map +1 -1
  45. package/dist/src/apis/v20GetApi.js +2 -1
  46. package/dist/src/apis/v20GetApi.js.map +1 -1
  47. package/dist/src/index.d.ts +1 -2
  48. package/dist/src/index.d.ts.map +1 -1
  49. package/dist/src/index.js +1 -2
  50. package/dist/src/index.js.map +1 -1
  51. package/dist/src/models/index.d.ts +1 -1
  52. package/dist/src/models/index.js +1 -1
  53. package/dist/src/models/utils.d.ts +2 -1
  54. package/dist/src/models/utils.d.ts.map +1 -1
  55. package/dist/src/utils/api.d.ts +1 -1
  56. package/dist/src/utils/api.d.ts.map +1 -1
  57. package/dist/src/utils/api.js +0 -1
  58. package/dist/src/utils/api.js.map +1 -1
  59. package/package.json +3 -4
  60. package/src/api.ts +18 -13
  61. package/src/apis/defaultApi.ts +6 -4
  62. package/src/apis/index.ts +3 -3
  63. package/src/apis/postApi.ts +13 -5
  64. package/src/apis/tweetApi.ts +8 -5
  65. package/src/apis/userApi.ts +6 -4
  66. package/src/apis/userListApi.ts +10 -9
  67. package/src/apis/usersApi.ts +6 -4
  68. package/src/apis/v11GetApi.ts +4 -2
  69. package/src/apis/v11PostApi.ts +5 -3
  70. package/src/apis/v20GetApi.ts +4 -2
  71. package/src/index.ts +1 -2
  72. package/src/models/index.ts +1 -1
  73. package/src/models/utils.ts +2 -1
  74. package/src/utils/api.ts +1 -2
  75. package/test/api/postApi.test.ts +11 -0
  76. package/test/api/v11PostApi.test.ts +1 -1
  77. package/test/init.ts +0 -1
  78. package/test/raw/tweet_api.test.ts +1 -1
@@ -1,6 +1,6 @@
1
+ import { DefaultFlag, RequestParam, TwitterApiUtilsResponse, UserApiUtilsData, initOverrides } from '@/models';
2
+ import { buildHeader, errorCheck, getKwargs, userResultConverter } from '@/utils';
1
3
  import * as i from 'twitter-openapi-typescript-generated';
2
- import { RequestParam, DefaultFlag, UserApiUtilsData, TwitterApiUtilsResponse } from '@/models';
3
- import { buildHeader, errorCheck, getKwargs, userOrNullConverter, userResultConverter } from '@/utils';
4
4
 
5
5
  type getUsersByRestIdsParam = {
6
6
  userIds: string[];
@@ -12,16 +12,18 @@ type ResponseType = TwitterApiUtilsResponse<UserApiUtilsData[]>;
12
12
  export class UsersApiUtils {
13
13
  api: i.UsersApi;
14
14
  flag: DefaultFlag;
15
+ initOverrides: initOverrides;
15
16
 
16
- constructor(api: i.UsersApi, flag: DefaultFlag) {
17
+ constructor(api: i.UsersApi, flag: DefaultFlag, initOverrides: initOverrides) {
17
18
  this.api = api;
18
19
  this.flag = flag;
20
+ this.initOverrides = initOverrides;
19
21
  }
20
22
 
21
23
  async request<T>(param: RequestParam<i.UserResults[], T>): Promise<ResponseType> {
22
24
  const apiFn: typeof param.apiFn = param.apiFn.bind(this.api);
23
25
  const args = getKwargs(this.flag[param.key], param.param);
24
- const response = await apiFn(args);
26
+ const response = await apiFn(args, this.initOverrides);
25
27
  const checked = errorCheck(await response.value());
26
28
  const result = param.convertFn(checked);
27
29
  const user = userResultConverter(result);
@@ -1,12 +1,14 @@
1
+ import { DefaultFlag, initOverrides } from '@/models';
1
2
  import * as i from 'twitter-openapi-typescript-generated';
2
- import { DefaultFlag } from '@/models';
3
3
 
4
4
  export class V11GetApiUtils {
5
5
  api: i.V11GetApi;
6
6
  flag: DefaultFlag;
7
+ initOverrides: initOverrides;
7
8
 
8
- constructor(api: i.V11GetApi, flag: DefaultFlag) {
9
+ constructor(api: i.V11GetApi, flag: DefaultFlag, initOverrides: initOverrides) {
9
10
  this.api = api;
10
11
  this.flag = flag;
12
+ this.initOverrides = initOverrides;
11
13
  }
12
14
  }
@@ -1,6 +1,6 @@
1
- import * as i from 'twitter-openapi-typescript-generated';
2
- import { DefaultFlag, TwitterApiUtilsResponse } from '@/models';
1
+ import { DefaultFlag, TwitterApiUtilsResponse, initOverrides } from '@/models';
3
2
  import { buildHeader } from '@/utils';
3
+ import * as i from 'twitter-openapi-typescript-generated';
4
4
 
5
5
  type PostCreateFriendshipsParam = {
6
6
  userId: string;
@@ -15,10 +15,12 @@ type PostDestroyFriendshipsParam = {
15
15
  export class V11PostApiUtils {
16
16
  api: i.V11PostApi;
17
17
  flag: DefaultFlag;
18
+ initOverrides: initOverrides;
18
19
 
19
- constructor(api: i.V11PostApi, flag: DefaultFlag) {
20
+ constructor(api: i.V11PostApi, flag: DefaultFlag, initOverrides: initOverrides) {
20
21
  this.api = api;
21
22
  this.flag = flag;
23
+ this.initOverrides = initOverrides;
22
24
  }
23
25
 
24
26
  async postCreateFriendships(param: PostCreateFriendshipsParam): Promise<TwitterApiUtilsResponse<undefined>> {
@@ -1,12 +1,14 @@
1
+ import { DefaultFlag, initOverrides } from '@/models';
1
2
  import * as i from 'twitter-openapi-typescript-generated';
2
- import { DefaultFlag } from '@/models';
3
3
 
4
4
  export class V20GetApiUtils {
5
5
  api: i.V20GetApi;
6
6
  flag: DefaultFlag;
7
+ initOverrides: initOverrides;
7
8
 
8
- constructor(api: i.V20GetApi, flag: DefaultFlag) {
9
+ constructor(api: i.V20GetApi, flag: DefaultFlag, initOverrides: initOverrides) {
9
10
  this.api = api;
10
11
  this.flag = flag;
12
+ this.initOverrides = initOverrides;
11
13
  }
12
14
  }
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
+ export * from '@/api';
1
2
  export * from '@/apis';
2
3
  export * from '@/models';
3
- export * from '@/models';
4
- export * from '@/api';
@@ -1,5 +1,5 @@
1
1
  export * from './flag';
2
2
  export * from './header';
3
- export * from './timeline';
4
3
  export * from './response';
4
+ export * from './timeline';
5
5
  export * from './utils';
@@ -1,6 +1,7 @@
1
1
  import * as i from 'twitter-openapi-typescript-generated';
2
2
 
3
- export type ApiFunction<T> = (requestParameters: any) => Promise<i.ApiResponse<T>>;
3
+ export type initOverrides = RequestInit | i.InitOverrideFunction | undefined;
4
+ export type ApiFunction<T> = (requestParameters: any, initOverrides?: initOverrides) => Promise<i.ApiResponse<T>>;
4
5
 
5
6
  export type RequestParam<T1, T2> = {
6
7
  apiFn: ApiFunction<i.Errors | T2>;
package/src/utils/api.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import { ApiUtilsHeader, CursorApiUtilsResponse, TweetApiUtilsData, UserApiUtilsData } from '@/models';
1
2
  import * as i from 'twitter-openapi-typescript-generated';
2
- import { TweetApiUtilsData, UserApiUtilsData, CursorApiUtilsResponse, ApiUtilsHeader } from '@/models';
3
3
 
4
4
  export const getKwargs = (flag: { [key: string]: any }, additional: { [key: string]: any }): any => {
5
5
  const kwargs: { [key: string]: any } = { pathQueryId: flag.queryId };
@@ -103,7 +103,6 @@ export const tweetResultsConverter = (tweetResults: i.ItemResult): i.Tweet | und
103
103
  case i.TypeName.TweetTombstone:
104
104
  return undefined;
105
105
  }
106
- throw Error();
107
106
  };
108
107
 
109
108
  export const userOrNullConverter = (userResults: i.UserUnion): i.User | undefined => {
@@ -8,6 +8,17 @@ test('postCreateTweet', async () => {
8
8
  expect(response.raw.response.ok).toBe(true);
9
9
  });
10
10
 
11
+ test('postCreateReplyTweet', async () => {
12
+ logger.log('postCreateTweet');
13
+ const client = await getClient();
14
+ const time = new Date().toISOString();
15
+ const response = await client.getPostApi().postCreateTweet({
16
+ tweetText: `Test[${time}]`,
17
+ inReplyToTweetId: '1726807635754914204',
18
+ });
19
+ expect(response.raw.response.ok).toBe(true);
20
+ });
21
+
11
22
  test('postDeleteTweet', async () => {
12
23
  logger.log('postDeleteTweet');
13
24
  const client = await getClient();
@@ -1,4 +1,4 @@
1
- import { getClient, logger } from '@test/init';
1
+ import { getClient } from '@test/init';
2
2
 
3
3
  test('postCreateFriendships', async () => {
4
4
  const client = await getClient();
package/test/init.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { TwitterOpenApi } from '@/api';
2
- import fetch from 'node-fetch';
3
2
  import * as dotenv from 'dotenv';
4
3
  import * as log4js from 'log4js';
5
4
 
@@ -1,4 +1,4 @@
1
- import { getClient, logger } from '@test/init';
1
+ import { getClient } from '@test/init';
2
2
 
3
3
  test('getHomeTimelineRaw', async () => {
4
4
  const client = await getClient();