From 2bae302b13d485f9c3831abe9d74a84e9babc7ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Wed, 30 Oct 2024 15:24:54 +0900 Subject: [PATCH 1/3] update 0.0.26 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- .../README.md | 4 +- .../package-lock.json | 4 +- .../package.json | 2 +- .../src/apis/TweetApi.ts | 48 +++++++++++++++++++ .../src/models/TimelineGeneralContext.ts | 3 +- .../src/models/UserResponseData.ts | 5 +- .../tools/win/init.ps1 | 2 + .../twitter-openapi | 2 +- 8 files changed, 60 insertions(+), 10 deletions(-) diff --git a/twitter-openapi-typescript-generated/README.md b/twitter-openapi-typescript-generated/README.md index 2ec0c5b..65c1b37 100644 --- a/twitter-openapi-typescript-generated/README.md +++ b/twitter-openapi-typescript-generated/README.md @@ -1,4 +1,4 @@ -## twitter-openapi-typescript-generated@0.0.25 +## twitter-openapi-typescript-generated@0.0.26 This generator creates TypeScript/JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The generated Node module can be used in the following environments: @@ -36,7 +36,7 @@ navigate to the folder of your consuming project and run one of the following co _published:_ ``` -npm install twitter-openapi-typescript-generated@0.0.25 --save +npm install twitter-openapi-typescript-generated@0.0.26 --save ``` _unPublished (not recommended):_ diff --git a/twitter-openapi-typescript-generated/package-lock.json b/twitter-openapi-typescript-generated/package-lock.json index ecbfbc5..2d8dc5c 100644 --- a/twitter-openapi-typescript-generated/package-lock.json +++ b/twitter-openapi-typescript-generated/package-lock.json @@ -1,12 +1,12 @@ { "name": "twitter-openapi-typescript-generated", - "version": "0.0.25", + "version": "0.0.26", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "twitter-openapi-typescript-generated", - "version": "0.0.25", + "version": "0.0.26", "license": "custom license or AGPL-3.0-or-later", "devDependencies": { "typescript": "^4.0 || ^5.0" diff --git a/twitter-openapi-typescript-generated/package.json b/twitter-openapi-typescript-generated/package.json index ba38e35..0482e4d 100644 --- a/twitter-openapi-typescript-generated/package.json +++ b/twitter-openapi-typescript-generated/package.json @@ -1,6 +1,6 @@ { "name": "twitter-openapi-typescript-generated", - "version": "0.0.25", + "version": "0.0.26", "description": "OpenAPI client for twitter-openapi-typescript-generated", "author": "fa0311", "repository": { diff --git a/twitter-openapi-typescript-generated/src/apis/TweetApi.ts b/twitter-openapi-typescript-generated/src/apis/TweetApi.ts index 50becbb..bd3b7d6 100644 --- a/twitter-openapi-typescript-generated/src/apis/TweetApi.ts +++ b/twitter-openapi-typescript-generated/src/apis/TweetApi.ts @@ -62,6 +62,7 @@ export interface GetLikesRequest { pathQueryId: string; variables: string; features: string; + fieldToggles: string; } export interface GetListLatestTweetsTimelineRequest { @@ -93,18 +94,21 @@ export interface GetUserMediaRequest { pathQueryId: string; variables: string; features: string; + fieldToggles: string; } export interface GetUserTweetsRequest { pathQueryId: string; variables: string; features: string; + fieldToggles: string; } export interface GetUserTweetsAndRepliesRequest { pathQueryId: string; variables: string; features: string; + fieldToggles: string; } /** @@ -530,6 +534,13 @@ export class TweetApi extends runtime.BaseAPI { ); } + if (requestParameters['fieldToggles'] == null) { + throw new runtime.RequiredError( + 'fieldToggles', + 'Required parameter "fieldToggles" was null or undefined when calling getLikes().' + ); + } + const queryParameters: any = {}; if (requestParameters['variables'] != null) { @@ -540,6 +551,10 @@ export class TweetApi extends runtime.BaseAPI { queryParameters['features'] = requestParameters['features']; } + if (requestParameters['fieldToggles'] != null) { + queryParameters['fieldToggles'] = requestParameters['fieldToggles']; + } + const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { @@ -1196,6 +1211,13 @@ export class TweetApi extends runtime.BaseAPI { ); } + if (requestParameters['fieldToggles'] == null) { + throw new runtime.RequiredError( + 'fieldToggles', + 'Required parameter "fieldToggles" was null or undefined when calling getUserMedia().' + ); + } + const queryParameters: any = {}; if (requestParameters['variables'] != null) { @@ -1206,6 +1228,10 @@ export class TweetApi extends runtime.BaseAPI { queryParameters['features'] = requestParameters['features']; } + if (requestParameters['fieldToggles'] != null) { + queryParameters['fieldToggles'] = requestParameters['fieldToggles']; + } + const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { @@ -1327,6 +1353,13 @@ export class TweetApi extends runtime.BaseAPI { ); } + if (requestParameters['fieldToggles'] == null) { + throw new runtime.RequiredError( + 'fieldToggles', + 'Required parameter "fieldToggles" was null or undefined when calling getUserTweets().' + ); + } + const queryParameters: any = {}; if (requestParameters['variables'] != null) { @@ -1337,6 +1370,10 @@ export class TweetApi extends runtime.BaseAPI { queryParameters['features'] = requestParameters['features']; } + if (requestParameters['fieldToggles'] != null) { + queryParameters['fieldToggles'] = requestParameters['fieldToggles']; + } + const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { @@ -1458,6 +1495,13 @@ export class TweetApi extends runtime.BaseAPI { ); } + if (requestParameters['fieldToggles'] == null) { + throw new runtime.RequiredError( + 'fieldToggles', + 'Required parameter "fieldToggles" was null or undefined when calling getUserTweetsAndReplies().' + ); + } + const queryParameters: any = {}; if (requestParameters['variables'] != null) { @@ -1468,6 +1512,10 @@ export class TweetApi extends runtime.BaseAPI { queryParameters['features'] = requestParameters['features']; } + if (requestParameters['fieldToggles'] != null) { + queryParameters['fieldToggles'] = requestParameters['fieldToggles']; + } + const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { diff --git a/twitter-openapi-typescript-generated/src/models/TimelineGeneralContext.ts b/twitter-openapi-typescript-generated/src/models/TimelineGeneralContext.ts index c579a35..70edb32 100644 --- a/twitter-openapi-typescript-generated/src/models/TimelineGeneralContext.ts +++ b/twitter-openapi-typescript-generated/src/models/TimelineGeneralContext.ts @@ -69,7 +69,8 @@ export const TimelineGeneralContextContextTypeEnum = { Location: 'Location', Sparkle: 'Sparkle', Conversation: 'Conversation', - List: 'List' + List: 'List', + Community: 'Community' } as const; export type TimelineGeneralContextContextTypeEnum = typeof TimelineGeneralContextContextTypeEnum[keyof typeof TimelineGeneralContextContextTypeEnum]; diff --git a/twitter-openapi-typescript-generated/src/models/UserResponseData.ts b/twitter-openapi-typescript-generated/src/models/UserResponseData.ts index 73b5513..b73c5ff 100644 --- a/twitter-openapi-typescript-generated/src/models/UserResponseData.ts +++ b/twitter-openapi-typescript-generated/src/models/UserResponseData.ts @@ -31,14 +31,13 @@ export interface UserResponseData { * @type {UserResults} * @memberof UserResponseData */ - user: UserResults; + user?: UserResults; } /** * Check if a given object implements the UserResponseData interface. */ export function instanceOfUserResponseData(value: object): value is UserResponseData { - if (!('user' in value) || value['user'] === undefined) return false; return true; } @@ -52,7 +51,7 @@ export function UserResponseDataFromJSONTyped(json: any, ignoreDiscriminator: bo } return { - 'user': UserResultsFromJSON(json['user']), + 'user': json['user'] == null ? undefined : UserResultsFromJSON(json['user']), }; } diff --git a/twitter-openapi-typescript-generated/tools/win/init.ps1 b/twitter-openapi-typescript-generated/tools/win/init.ps1 index 8389314..82e0d77 100644 --- a/twitter-openapi-typescript-generated/tools/win/init.ps1 +++ b/twitter-openapi-typescript-generated/tools/win/init.ps1 @@ -1 +1,3 @@ +# 7.9.0 is not working +# https://github.com/OpenAPITools/openapi-generator/issues/19858 Invoke-WebRequest -OutFile tools/openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.8.0/openapi-generator-cli-7.8.0.jar \ No newline at end of file diff --git a/twitter-openapi-typescript-generated/twitter-openapi b/twitter-openapi-typescript-generated/twitter-openapi index 0c64eeb..a4947b3 160000 --- a/twitter-openapi-typescript-generated/twitter-openapi +++ b/twitter-openapi-typescript-generated/twitter-openapi @@ -1 +1 @@ -Subproject commit 0c64eebbfb93b3ed69c3aba923ec8d6894a39902 +Subproject commit a4947b33abe0109942dd5d23245103e35e32f2f2 From cfe5057fcf27a2c00dd0c2cf74404f7efe555818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Wed, 30 Oct 2024 15:30:34 +0900 Subject: [PATCH 2/3] fix #111 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- twitter-openapi-typescript/src/apis/userApi.ts | 6 +++--- .../test/api/userApi.test.ts | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/twitter-openapi-typescript/src/apis/userApi.ts b/twitter-openapi-typescript/src/apis/userApi.ts index 1b10b9a..206d669 100644 --- a/twitter-openapi-typescript/src/apis/userApi.ts +++ b/twitter-openapi-typescript/src/apis/userApi.ts @@ -1,5 +1,5 @@ import { DefaultFlag, RequestParam, TwitterApiUtilsResponse, UserApiUtilsData, initOverrides } from '@/models'; -import { buildHeader, errorCheck, getKwargs, userOrNullConverter } from '@/utils'; +import { buildHeader, errorCheck, getKwargs, nonNullable, userOrNullConverter } from '@/utils'; import * as i from 'twitter-openapi-typescript-generated'; type getUserByScreenNameParam = { @@ -51,7 +51,7 @@ export class UserApiUtils { const response = this.request({ key: 'UserByScreenName', apiFn: this.api.getUserByScreenNameRaw, - convertFn: (e) => e.data.user, + convertFn: (e) => nonNullable(e.data.user), param: args, }); return response; @@ -64,7 +64,7 @@ export class UserApiUtils { const response = this.request({ key: 'UserByRestId', apiFn: this.api.getUserByRestIdRaw, - convertFn: (e) => e.data.user, + convertFn: (e) => nonNullable(e.data.user), param: args, }); return response; diff --git a/twitter-openapi-typescript/test/api/userApi.test.ts b/twitter-openapi-typescript/test/api/userApi.test.ts index 52aff4f..e03214f 100644 --- a/twitter-openapi-typescript/test/api/userApi.test.ts +++ b/twitter-openapi-typescript/test/api/userApi.test.ts @@ -9,6 +9,22 @@ test('getUserByScreenName', async () => { expect(response.raw.response.ok).toBe(true); }); +test('getUserByScreenNameNotFound', async () => { + logger.log('getUserByScreenName'); + const client = await getClient(); + const response = await client.getUserApi().getUserByScreenName({ screenName: 'Wendoleecs' }); + printUser(response.data); + expect(response.raw.response.ok).toBe(true); +}); + +test('getUserByScreenNameFreezed', async () => { + logger.log('getUserByScreenName'); + const client = await getClient(); + const response = await client.getUserApi().getUserByScreenName({ screenName: 'anal' }); + printUser(response.data); + expect(response.raw.response.ok).toBe(true); +}); + test('getUserByRestId', async () => { logger.log('getUserByRestId'); const client = await getClient(); From 0068e71cadc57579e743f29e8115736394aa11b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Wed, 30 Oct 2024 15:32:30 +0900 Subject: [PATCH 3/3] update 0.0.41 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- .../tools/openapi-generator-config.yaml | 2 +- twitter-openapi-typescript/package-lock.json | 12 ++++++------ twitter-openapi-typescript/package.json | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/twitter-openapi-typescript-generated/tools/openapi-generator-config.yaml b/twitter-openapi-typescript-generated/tools/openapi-generator-config.yaml index eb1bf4f..f30476a 100644 --- a/twitter-openapi-typescript-generated/tools/openapi-generator-config.yaml +++ b/twitter-openapi-typescript-generated/tools/openapi-generator-config.yaml @@ -1,7 +1,7 @@ inputSpec: twitter-openapi/dist/compatible/openapi-3.0.yaml outputDir: . npmName: twitter-openapi-typescript-generated -npmVersion: 0.0.25 +npmVersion: 0.0.26 # withoutRuntimeChecks: false legacyDiscriminatorBehavior: false diff --git a/twitter-openapi-typescript/package-lock.json b/twitter-openapi-typescript/package-lock.json index 445bd22..b4f753f 100644 --- a/twitter-openapi-typescript/package-lock.json +++ b/twitter-openapi-typescript/package-lock.json @@ -1,15 +1,15 @@ { "name": "twitter-openapi-typescript", - "version": "0.0.40", + "version": "0.0.41", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "twitter-openapi-typescript", - "version": "0.0.40", + "version": "0.0.41", "license": "custom license or AGPL-3.0-or-later", "dependencies": { - "twitter-openapi-typescript-generated": "^0.0.25" + "twitter-openapi-typescript-generated": "^0.0.26" }, "devDependencies": { "@types/jest": "*", @@ -6616,9 +6616,9 @@ } }, "node_modules/twitter-openapi-typescript-generated": { - "version": "0.0.25", - "resolved": "https://registry.npmjs.org/twitter-openapi-typescript-generated/-/twitter-openapi-typescript-generated-0.0.25.tgz", - "integrity": "sha512-xp49L4Px8WdHHH/cGEhiLn1CyPda4HZ/h8E8douV3DfLYtq5EvdJGN81Fx6yyPBtNDfJhajaudjySqTELBqUUQ==" + "version": "0.0.26", + "resolved": "https://registry.npmjs.org/twitter-openapi-typescript-generated/-/twitter-openapi-typescript-generated-0.0.26.tgz", + "integrity": "sha512-IS6XIfU2E2oWSzfq1tzQXxUGx80ybnzDSjEQ0Y+Qg7BS7pGwL/Y5alcObhaJyrFhyjB75swjzNMS2aVMYgVCDQ==" }, "node_modules/type-check": { "version": "0.4.0", diff --git a/twitter-openapi-typescript/package.json b/twitter-openapi-typescript/package.json index 7e6ce0b..f54b01b 100644 --- a/twitter-openapi-typescript/package.json +++ b/twitter-openapi-typescript/package.json @@ -1,6 +1,6 @@ { "name": "twitter-openapi-typescript", - "version": "0.0.40", + "version": "0.0.41", "description": "Implementation of Twitter internal API in TypeScript", "scripts": { "test": "jest", @@ -21,7 +21,7 @@ "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts", "dependencies": { - "twitter-openapi-typescript-generated": "^0.0.25" + "twitter-openapi-typescript-generated": "^0.0.26" }, "devDependencies": { "@types/jest": "*",