From 64574ce88738bebcfdd87cef04b8edff87e62183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AF=BA=E5=A2=A8?= Date: Tue, 7 May 2024 04:54:18 +0800 Subject: [PATCH 1/5] feat: migrate from openapi-typescript-codegen to @hey-api/openapi-ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 诺墨 --- package-lock.json | 2 +- package.json | 4 +- src/GiteeClient.ts | 80 - src/core/ApiError.ts | 34 +- src/core/ApiRequestOptions.ts | 28 +- src/core/ApiResult.ts | 18 +- src/core/AxiosHttpRequest.ts | 26 - src/core/BaseHttpRequest.ts | 14 - src/core/CancelablePromise.ts | 241 +- src/core/OpenAPI.ts | 73 +- src/core/request.ts | 533 +- src/index.ts | 113 +- src/models/AttachFile.ts | 18 - src/models/Blame.ts | 18 - src/models/Blob.ts | 16 - src/models/Branch.ts | 15 - src/models/CheckAnnotation.ts | 51 - src/models/CheckRun.ts | 52 - src/models/Code.ts | 30 - src/models/CodeComment.ts | 15 - src/models/CodeForks.ts | 18 - src/models/CodeForksHistory.ts | 32 - src/models/Commit.ts | 16 - src/models/CommitContent.ts | 16 - src/models/CommitParentsBasic.ts | 17 - src/models/Compare.ts | 29 - src/models/CompleteBranch.ts | 16 - src/models/Content.ts | 22 - src/models/ContentBasic.ts | 17 - src/models/Contributor.ts | 14 - src/models/DiffFile.ts | 49 - src/models/EnterpriseBasic.ts | 31 - src/models/EnterpriseMember.ts | 21 - src/models/Event.ts | 26 - src/models/GitUser.ts | 11 - src/models/GiteeMetrics.ts | 17 - src/models/Group.ts | 21 - src/models/GroupBasic.ts | 13 - src/models/GroupDetail.ts | 34 - src/models/GroupFollowers.ts | 15 - src/models/GroupMember.ts | 21 - src/models/Hook.ts | 23 - src/models/Issue.ts | 130 - src/models/IssueState.ts | 40 - src/models/IssueType.ts | 40 - src/models/Label.ts | 18 - src/models/Milestone.ts | 23 - src/models/Namespace.ts | 34 - src/models/NamespaceMini.ts | 28 - src/models/Note.ts | 23 - src/models/OperateLog.ts | 21 - src/models/ProgramBasic.ts | 30 - src/models/Project.ts | 214 - src/models/ProjectBasic.ts | 54 - src/models/ProjectLabel.ts | 14 - src/models/ProjectMember.ts | 33 - src/models/ProjectMemberPermission.ts | 33 - src/models/ProjectMini.ts | 15 - src/models/ProjectPushConfig.ts | 19 - src/models/ProjectStargazers.ts | 33 - src/models/ProjectTrafficData.ts | 22 - src/models/ProjectTrafficDataDesc.ts | 28 - src/models/ProjectTrafficDataSummary.ts | 24 - src/models/ProjectWatchers.ts | 33 - src/models/ProtectionRule.ts | 32 - src/models/PullRequest.ts | 55 - src/models/PullRequestComments.ts | 30 - src/models/PullRequestCommits.ts | 22 - src/models/PullRequestFiles.ts | 19 - src/models/RefPullRequest.ts | 11 - src/models/Release.ts | 22 - src/models/RepoCommit.ts | 21 - src/models/RepoCommitWithFiles.ts | 31 - src/models/SSHKey.ts | 16 - src/models/SSHKeyBasic.ts | 13 - src/models/Tag.ts | 17 - src/models/Tree.ts | 15 - src/models/User.ts | 43 - src/models/UserAssignee.ts | 41 - src/models/UserBasic.ts | 32 - src/models/UserDetail.ts | 44 - src/models/UserEmail.ts | 14 - src/models/UserInfo.ts | 49 - src/models/UserMessage.ts | 23 - src/models/UserMessageList.ts | 18 - src/models/UserMini.ts | 18 - src/models/UserNotification.ts | 37 - src/models/UserNotificationCount.ts | 23 - src/models/UserNotificationList.ts | 18 - src/models/UserNotificationNamespace.ts | 11 - src/models/UserNotificationSubject.ts | 12 - src/models/WeekReport.ts | 30 - src/models/postV5ReposOwnerRepoCommits.ts | 67 - src/schemas.gen.ts | 3550 ++++ src/services.gen.ts | 8008 +++++++++ src/services/ActivityClient.ts | 1498 -- src/services/ChecksClient.ts | 566 - src/services/EmailsClient.ts | 37 - src/services/EnterprisesClient.ts | 885 - src/services/GistsClient.ts | 640 - src/services/GitDataClient.ts | 155 - src/services/IssuesClient.ts | 1477 -- src/services/LabelsClient.ts | 711 - src/services/MilestonesClient.ts | 295 - src/services/MiscellaneousClient.ts | 274 - src/services/OrganizationsClient.ts | 626 - src/services/PullRequestsClient.ts | 1582 -- src/services/RepositoriesClient.ts | 4280 ----- src/services/SearchClient.ts | 229 - src/services/UsersClient.ts | 670 - src/services/WebhooksClient.ts | 368 - src/types.gen.ts | 18261 ++++++++++++++++++++ 112 files changed, 30304 insertions(+), 17361 deletions(-) delete mode 100644 src/GiteeClient.ts delete mode 100644 src/core/AxiosHttpRequest.ts delete mode 100644 src/core/BaseHttpRequest.ts delete mode 100644 src/models/AttachFile.ts delete mode 100644 src/models/Blame.ts delete mode 100644 src/models/Blob.ts delete mode 100644 src/models/Branch.ts delete mode 100644 src/models/CheckAnnotation.ts delete mode 100644 src/models/CheckRun.ts delete mode 100644 src/models/Code.ts delete mode 100644 src/models/CodeComment.ts delete mode 100644 src/models/CodeForks.ts delete mode 100644 src/models/CodeForksHistory.ts delete mode 100644 src/models/Commit.ts delete mode 100644 src/models/CommitContent.ts delete mode 100644 src/models/CommitParentsBasic.ts delete mode 100644 src/models/Compare.ts delete mode 100644 src/models/CompleteBranch.ts delete mode 100644 src/models/Content.ts delete mode 100644 src/models/ContentBasic.ts delete mode 100644 src/models/Contributor.ts delete mode 100644 src/models/DiffFile.ts delete mode 100644 src/models/EnterpriseBasic.ts delete mode 100644 src/models/EnterpriseMember.ts delete mode 100644 src/models/Event.ts delete mode 100644 src/models/GitUser.ts delete mode 100644 src/models/GiteeMetrics.ts delete mode 100644 src/models/Group.ts delete mode 100644 src/models/GroupBasic.ts delete mode 100644 src/models/GroupDetail.ts delete mode 100644 src/models/GroupFollowers.ts delete mode 100644 src/models/GroupMember.ts delete mode 100644 src/models/Hook.ts delete mode 100644 src/models/Issue.ts delete mode 100644 src/models/IssueState.ts delete mode 100644 src/models/IssueType.ts delete mode 100644 src/models/Label.ts delete mode 100644 src/models/Milestone.ts delete mode 100644 src/models/Namespace.ts delete mode 100644 src/models/NamespaceMini.ts delete mode 100644 src/models/Note.ts delete mode 100644 src/models/OperateLog.ts delete mode 100644 src/models/ProgramBasic.ts delete mode 100644 src/models/Project.ts delete mode 100644 src/models/ProjectBasic.ts delete mode 100644 src/models/ProjectLabel.ts delete mode 100644 src/models/ProjectMember.ts delete mode 100644 src/models/ProjectMemberPermission.ts delete mode 100644 src/models/ProjectMini.ts delete mode 100644 src/models/ProjectPushConfig.ts delete mode 100644 src/models/ProjectStargazers.ts delete mode 100644 src/models/ProjectTrafficData.ts delete mode 100644 src/models/ProjectTrafficDataDesc.ts delete mode 100644 src/models/ProjectTrafficDataSummary.ts delete mode 100644 src/models/ProjectWatchers.ts delete mode 100644 src/models/ProtectionRule.ts delete mode 100644 src/models/PullRequest.ts delete mode 100644 src/models/PullRequestComments.ts delete mode 100644 src/models/PullRequestCommits.ts delete mode 100644 src/models/PullRequestFiles.ts delete mode 100644 src/models/RefPullRequest.ts delete mode 100644 src/models/Release.ts delete mode 100644 src/models/RepoCommit.ts delete mode 100644 src/models/RepoCommitWithFiles.ts delete mode 100644 src/models/SSHKey.ts delete mode 100644 src/models/SSHKeyBasic.ts delete mode 100644 src/models/Tag.ts delete mode 100644 src/models/Tree.ts delete mode 100644 src/models/User.ts delete mode 100644 src/models/UserAssignee.ts delete mode 100644 src/models/UserBasic.ts delete mode 100644 src/models/UserDetail.ts delete mode 100644 src/models/UserEmail.ts delete mode 100644 src/models/UserInfo.ts delete mode 100644 src/models/UserMessage.ts delete mode 100644 src/models/UserMessageList.ts delete mode 100644 src/models/UserMini.ts delete mode 100644 src/models/UserNotification.ts delete mode 100644 src/models/UserNotificationCount.ts delete mode 100644 src/models/UserNotificationList.ts delete mode 100644 src/models/UserNotificationNamespace.ts delete mode 100644 src/models/UserNotificationSubject.ts delete mode 100644 src/models/WeekReport.ts delete mode 100644 src/models/postV5ReposOwnerRepoCommits.ts create mode 100644 src/schemas.gen.ts create mode 100644 src/services.gen.ts delete mode 100644 src/services/ActivityClient.ts delete mode 100644 src/services/ChecksClient.ts delete mode 100644 src/services/EmailsClient.ts delete mode 100644 src/services/EnterprisesClient.ts delete mode 100644 src/services/GistsClient.ts delete mode 100644 src/services/GitDataClient.ts delete mode 100644 src/services/IssuesClient.ts delete mode 100644 src/services/LabelsClient.ts delete mode 100644 src/services/MilestonesClient.ts delete mode 100644 src/services/MiscellaneousClient.ts delete mode 100644 src/services/OrganizationsClient.ts delete mode 100644 src/services/PullRequestsClient.ts delete mode 100644 src/services/RepositoriesClient.ts delete mode 100644 src/services/SearchClient.ts delete mode 100644 src/services/UsersClient.ts delete mode 100644 src/services/WebhooksClient.ts create mode 100644 src/types.gen.ts diff --git a/package-lock.json b/package-lock.json index 23fb40d..2ce7ac4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "axios": "^0.21.1", - "typescript": "^4.3.5" + "typescript": "^4.9.5" }, "devDependencies": { "@types/jest": "^27.0.2", diff --git a/package.json b/package.json index 9a227ff..0897094 100644 --- a/package.json +++ b/package.json @@ -35,12 +35,12 @@ "main": "src/index.ts", "scripts": { "clean": "rm -rf ./src", - "generate-sdk": "npm run clean && openapi --input ./openapi-spec.json --output ./src --client axios --name GiteeClient --useOptions --useUnionTypes --exportCore true --exportServices true --exportModels true --exportSchemas false --indent 2 --postfixServices 'Client' --postfixModels 'Model'", + "generate-sdk": "npm run clean && npx @hey-api/openapi-ts -i ./openapi-spec.json -o src", "update-openapi-spec": "node scripts/update-openapi-spec.js" }, "dependencies": { "axios": "^0.21.1", - "typescript": "^4.3.5" + "typescript": "^4.9.5" }, "devDependencies": { "@types/jest": "^27.0.2", diff --git a/src/GiteeClient.ts b/src/GiteeClient.ts deleted file mode 100644 index 07b7f2c..0000000 --- a/src/GiteeClient.ts +++ /dev/null @@ -1,80 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { BaseHttpRequest } from './core/BaseHttpRequest'; -import type { OpenAPIConfig } from './core/OpenAPI'; -import { AxiosHttpRequest } from './core/AxiosHttpRequest'; - -import { ActivityClient } from './services/ActivityClient'; -import { ChecksClient } from './services/ChecksClient'; -import { EmailsClient } from './services/EmailsClient'; -import { EnterprisesClient } from './services/EnterprisesClient'; -import { GistsClient } from './services/GistsClient'; -import { GitDataClient } from './services/GitDataClient'; -import { IssuesClient } from './services/IssuesClient'; -import { LabelsClient } from './services/LabelsClient'; -import { MilestonesClient } from './services/MilestonesClient'; -import { MiscellaneousClient } from './services/MiscellaneousClient'; -import { OrganizationsClient } from './services/OrganizationsClient'; -import { PullRequestsClient } from './services/PullRequestsClient'; -import { RepositoriesClient } from './services/RepositoriesClient'; -import { SearchClient } from './services/SearchClient'; -import { UsersClient } from './services/UsersClient'; -import { WebhooksClient } from './services/WebhooksClient'; - -type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest; - -export class GiteeClient { - - public readonly activity: ActivityClient; - public readonly checks: ChecksClient; - public readonly emails: EmailsClient; - public readonly enterprises: EnterprisesClient; - public readonly gists: GistsClient; - public readonly gitData: GitDataClient; - public readonly issues: IssuesClient; - public readonly labels: LabelsClient; - public readonly milestones: MilestonesClient; - public readonly miscellaneous: MiscellaneousClient; - public readonly organizations: OrganizationsClient; - public readonly pullRequests: PullRequestsClient; - public readonly repositories: RepositoriesClient; - public readonly search: SearchClient; - public readonly users: UsersClient; - public readonly webhooks: WebhooksClient; - - public readonly request: BaseHttpRequest; - - constructor(config?: Partial, HttpRequest: HttpRequestConstructor = AxiosHttpRequest) { - this.request = new HttpRequest({ - BASE: config?.BASE ?? 'https://gitee.com/api', - VERSION: config?.VERSION ?? '5.4.84', - WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false, - CREDENTIALS: config?.CREDENTIALS ?? 'include', - TOKEN: config?.TOKEN, - USERNAME: config?.USERNAME, - PASSWORD: config?.PASSWORD, - HEADERS: config?.HEADERS, - ENCODE_PATH: config?.ENCODE_PATH, - }); - - this.activity = new ActivityClient(this.request); - this.checks = new ChecksClient(this.request); - this.emails = new EmailsClient(this.request); - this.enterprises = new EnterprisesClient(this.request); - this.gists = new GistsClient(this.request); - this.gitData = new GitDataClient(this.request); - this.issues = new IssuesClient(this.request); - this.labels = new LabelsClient(this.request); - this.milestones = new MilestonesClient(this.request); - this.miscellaneous = new MiscellaneousClient(this.request); - this.organizations = new OrganizationsClient(this.request); - this.pullRequests = new PullRequestsClient(this.request); - this.repositories = new RepositoriesClient(this.request); - this.search = new SearchClient(this.request); - this.users = new UsersClient(this.request); - this.webhooks = new WebhooksClient(this.request); - } -} - diff --git a/src/core/ApiError.ts b/src/core/ApiError.ts index 81f32a1..36675d2 100644 --- a/src/core/ApiError.ts +++ b/src/core/ApiError.ts @@ -1,25 +1,21 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; export class ApiError extends Error { - public readonly url: string; - public readonly status: number; - public readonly statusText: string; - public readonly body: any; - public readonly request: ApiRequestOptions; + public readonly url: string; + public readonly status: number; + public readonly statusText: string; + public readonly body: unknown; + public readonly request: ApiRequestOptions; - constructor(request: ApiRequestOptions, response: ApiResult, message: string) { - super(message); + constructor(request: ApiRequestOptions, response: ApiResult, message: string) { + super(message); - this.name = 'ApiError'; - this.url = response.url; - this.status = response.status; - this.statusText = response.statusText; - this.body = response.body; - this.request = request; - } -} + this.name = 'ApiError'; + this.url = response.url; + this.status = response.status; + this.statusText = response.statusText; + this.body = response.body; + this.request = request; + } +} \ No newline at end of file diff --git a/src/core/ApiRequestOptions.ts b/src/core/ApiRequestOptions.ts index 4d59ced..8f8d4d1 100644 --- a/src/core/ApiRequestOptions.ts +++ b/src/core/ApiRequestOptions.ts @@ -1,17 +1,13 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ export type ApiRequestOptions = { - readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; - readonly url: string; - readonly path?: Record; - readonly cookies?: Record; - readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; - readonly mediaType?: string; - readonly responseHeader?: string; - readonly errors?: Record; -}; + readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH'; + readonly url: string; + readonly path?: Record; + readonly cookies?: Record; + readonly headers?: Record; + readonly query?: Record; + readonly formData?: Record; + readonly body?: any; + readonly mediaType?: string; + readonly responseHeader?: string; + readonly errors?: Record; +}; \ No newline at end of file diff --git a/src/core/ApiResult.ts b/src/core/ApiResult.ts index 63ed6c4..4c58e39 100644 --- a/src/core/ApiResult.ts +++ b/src/core/ApiResult.ts @@ -1,11 +1,7 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export type ApiResult = { - readonly url: string; - readonly ok: boolean; - readonly status: number; - readonly statusText: string; - readonly body: any; -}; +export type ApiResult = { + readonly body: TData; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly url: string; +}; \ No newline at end of file diff --git a/src/core/AxiosHttpRequest.ts b/src/core/AxiosHttpRequest.ts deleted file mode 100644 index 3cd6639..0000000 --- a/src/core/AxiosHttpRequest.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { ApiRequestOptions } from './ApiRequestOptions'; -import { BaseHttpRequest } from './BaseHttpRequest'; -import type { CancelablePromise } from './CancelablePromise'; -import type { OpenAPIConfig } from './OpenAPI'; -import { request as __request } from './request'; - -export class AxiosHttpRequest extends BaseHttpRequest { - - constructor(config: OpenAPIConfig) { - super(config); - } - - /** - * Request method - * @param options The request options from the service - * @returns CancelablePromise - * @throws ApiError - */ - public override request(options: ApiRequestOptions): CancelablePromise { - return __request(this.config, options); - } -} diff --git a/src/core/BaseHttpRequest.ts b/src/core/BaseHttpRequest.ts deleted file mode 100644 index 22c01bd..0000000 --- a/src/core/BaseHttpRequest.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { ApiRequestOptions } from './ApiRequestOptions'; -import type { CancelablePromise } from './CancelablePromise'; -import type { OpenAPIConfig } from './OpenAPI'; - -export abstract class BaseHttpRequest { - - constructor(public readonly config: OpenAPIConfig) {} - - public abstract request(options: ApiRequestOptions): CancelablePromise; -} diff --git a/src/core/CancelablePromise.ts b/src/core/CancelablePromise.ts index a7910e4..ccc082e 100644 --- a/src/core/CancelablePromise.ts +++ b/src/core/CancelablePromise.ts @@ -1,131 +1,126 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ export class CancelError extends Error { - - constructor(message: string) { - super(message); - this.name = 'CancelError'; - } - - public get isCancelled(): boolean { - return true; - } + constructor(message: string) { + super(message); + this.name = 'CancelError'; + } + + public get isCancelled(): boolean { + return true; + } } export interface OnCancel { - readonly isResolved: boolean; - readonly isRejected: boolean; - readonly isCancelled: boolean; + readonly isResolved: boolean; + readonly isRejected: boolean; + readonly isCancelled: boolean; - (cancelHandler: () => void): void; + (cancelHandler: () => void): void; } export class CancelablePromise implements Promise { - #isResolved: boolean; - #isRejected: boolean; - #isCancelled: boolean; - readonly #cancelHandlers: (() => void)[]; - readonly #promise: Promise; - #resolve?: (value: T | PromiseLike) => void; - #reject?: (reason?: any) => void; - - constructor( - executor: ( - resolve: (value: T | PromiseLike) => void, - reject: (reason?: any) => void, - onCancel: OnCancel - ) => void - ) { - this.#isResolved = false; - this.#isRejected = false; - this.#isCancelled = false; - this.#cancelHandlers = []; - this.#promise = new Promise((resolve, reject) => { - this.#resolve = resolve; - this.#reject = reject; - - const onResolve = (value: T | PromiseLike): void => { - if (this.#isResolved || this.#isRejected || this.#isCancelled) { - return; - } - this.#isResolved = true; - this.#resolve?.(value); - }; - - const onReject = (reason?: any): void => { - if (this.#isResolved || this.#isRejected || this.#isCancelled) { - return; - } - this.#isRejected = true; - this.#reject?.(reason); - }; - - const onCancel = (cancelHandler: () => void): void => { - if (this.#isResolved || this.#isRejected || this.#isCancelled) { - return; - } - this.#cancelHandlers.push(cancelHandler); - }; - - Object.defineProperty(onCancel, 'isResolved', { - get: (): boolean => this.#isResolved, - }); - - Object.defineProperty(onCancel, 'isRejected', { - get: (): boolean => this.#isRejected, - }); - - Object.defineProperty(onCancel, 'isCancelled', { - get: (): boolean => this.#isCancelled, - }); - - return executor(onResolve, onReject, onCancel as OnCancel); - }); - } - - get [Symbol.toStringTag]() { - return "Cancellable Promise"; - } - - public then( - onFulfilled?: ((value: T) => TResult1 | PromiseLike) | null, - onRejected?: ((reason: any) => TResult2 | PromiseLike) | null - ): Promise { - return this.#promise.then(onFulfilled, onRejected); - } - - public catch( - onRejected?: ((reason: any) => TResult | PromiseLike) | null - ): Promise { - return this.#promise.catch(onRejected); - } - - public finally(onFinally?: (() => void) | null): Promise { - return this.#promise.finally(onFinally); - } - - public cancel(): void { - if (this.#isResolved || this.#isRejected || this.#isCancelled) { - return; - } - this.#isCancelled = true; - if (this.#cancelHandlers.length) { - try { - for (const cancelHandler of this.#cancelHandlers) { - cancelHandler(); - } - } catch (error) { - console.warn('Cancellation threw an error', error); - return; - } - } - this.#cancelHandlers.length = 0; - this.#reject?.(new CancelError('Request aborted')); - } - - public get isCancelled(): boolean { - return this.#isCancelled; - } -} + private _isResolved: boolean; + private _isRejected: boolean; + private _isCancelled: boolean; + readonly cancelHandlers: (() => void)[]; + readonly promise: Promise; + private _resolve?: (value: T | PromiseLike) => void; + private _reject?: (reason?: unknown) => void; + + constructor( + executor: ( + resolve: (value: T | PromiseLike) => void, + reject: (reason?: unknown) => void, + onCancel: OnCancel + ) => void + ) { + this._isResolved = false; + this._isRejected = false; + this._isCancelled = false; + this.cancelHandlers = []; + this.promise = new Promise((resolve, reject) => { + this._resolve = resolve; + this._reject = reject; + + const onResolve = (value: T | PromiseLike): void => { + if (this._isResolved || this._isRejected || this._isCancelled) { + return; + } + this._isResolved = true; + if (this._resolve) this._resolve(value); + }; + + const onReject = (reason?: unknown): void => { + if (this._isResolved || this._isRejected || this._isCancelled) { + return; + } + this._isRejected = true; + if (this._reject) this._reject(reason); + }; + + const onCancel = (cancelHandler: () => void): void => { + if (this._isResolved || this._isRejected || this._isCancelled) { + return; + } + this.cancelHandlers.push(cancelHandler); + }; + + Object.defineProperty(onCancel, 'isResolved', { + get: (): boolean => this._isResolved, + }); + + Object.defineProperty(onCancel, 'isRejected', { + get: (): boolean => this._isRejected, + }); + + Object.defineProperty(onCancel, 'isCancelled', { + get: (): boolean => this._isCancelled, + }); + + return executor(onResolve, onReject, onCancel as OnCancel); + }); + } + + get [Symbol.toStringTag]() { + return "Cancellable Promise"; + } + + public then( + onFulfilled?: ((value: T) => TResult1 | PromiseLike) | null, + onRejected?: ((reason: unknown) => TResult2 | PromiseLike) | null + ): Promise { + return this.promise.then(onFulfilled, onRejected); + } + + public catch( + onRejected?: ((reason: unknown) => TResult | PromiseLike) | null + ): Promise { + return this.promise.catch(onRejected); + } + + public finally(onFinally?: (() => void) | null): Promise { + return this.promise.finally(onFinally); + } + + public cancel(): void { + if (this._isResolved || this._isRejected || this._isCancelled) { + return; + } + this._isCancelled = true; + if (this.cancelHandlers.length) { + try { + for (const cancelHandler of this.cancelHandlers) { + cancelHandler(); + } + } catch (error) { + console.warn('Cancellation threw an error', error); + return; + } + } + this.cancelHandlers.length = 0; + if (this._reject) this._reject(new CancelError('Request aborted')); + } + + public get isCancelled(): boolean { + return this._isCancelled; + } +} \ No newline at end of file diff --git a/src/core/OpenAPI.ts b/src/core/OpenAPI.ts index 782f662..e0dbfd0 100644 --- a/src/core/OpenAPI.ts +++ b/src/core/OpenAPI.ts @@ -1,32 +1,57 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ +import type { AxiosRequestConfig, AxiosResponse } from 'axios'; import type { ApiRequestOptions } from './ApiRequestOptions'; -type Resolver = (options: ApiRequestOptions) => Promise; type Headers = Record; +type Middleware = (value: T) => T | Promise; +type Resolver = (options: ApiRequestOptions) => Promise; + +export class Interceptors { + _fns: Middleware[]; + + constructor() { + this._fns = []; + } + + eject(fn: Middleware) { + const index = this._fns.indexOf(fn); + if (index !== -1) { + this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; + } + } + + use(fn: Middleware) { + this._fns = [...this._fns, fn]; + } +} export type OpenAPIConfig = { - BASE: string; - VERSION: string; - WITH_CREDENTIALS: boolean; - CREDENTIALS: 'include' | 'omit' | 'same-origin'; - TOKEN?: string | Resolver | undefined; - USERNAME?: string | Resolver | undefined; - PASSWORD?: string | Resolver | undefined; - HEADERS?: Headers | Resolver | undefined; - ENCODE_PATH?: ((path: string) => string) | undefined; + BASE: string; + CREDENTIALS: 'include' | 'omit' | 'same-origin'; + ENCODE_PATH?: ((path: string) => string) | undefined; + HEADERS?: Headers | Resolver | undefined; + PASSWORD?: string | Resolver | undefined; + TOKEN?: string | Resolver | undefined; + USERNAME?: string | Resolver | undefined; + VERSION: string; + WITH_CREDENTIALS: boolean; + interceptors: { + request: Interceptors; + response: Interceptors; + }; }; export const OpenAPI: OpenAPIConfig = { - BASE: 'https://gitee.com/api', - VERSION: '5.4.84', - WITH_CREDENTIALS: false, - CREDENTIALS: 'include', - TOKEN: undefined, - USERNAME: undefined, - PASSWORD: undefined, - HEADERS: undefined, - ENCODE_PATH: undefined, -}; + BASE: 'https://gitee.com/api', + CREDENTIALS: 'include', + ENCODE_PATH: undefined, + HEADERS: undefined, + PASSWORD: undefined, + TOKEN: undefined, + USERNAME: undefined, + VERSION: '5.4.84', + WITH_CREDENTIALS: false, + interceptors: { + request: new Interceptors(), + response: new Interceptors(), + }, +}; \ No newline at end of file diff --git a/src/core/request.ts b/src/core/request.ts index 7398f8f..1df3281 100644 --- a/src/core/request.ts +++ b/src/core/request.ts @@ -1,10 +1,5 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ import axios from 'axios'; import type { AxiosError, AxiosRequestConfig, AxiosResponse, AxiosInstance } from 'axios'; -import FormData from 'form-data'; import { ApiError } from './ApiError'; import type { ApiRequestOptions } from './ApiRequestOptions'; @@ -13,270 +8,289 @@ import { CancelablePromise } from './CancelablePromise'; import type { OnCancel } from './CancelablePromise'; import type { OpenAPIConfig } from './OpenAPI'; -export const isDefined = (value: T | null | undefined): value is Exclude => { - return value !== undefined && value !== null; +export const isString = (value: unknown): value is string => { + return typeof value === 'string'; }; -export const isString = (value: any): value is string => { - return typeof value === 'string'; -}; - -export const isStringWithValue = (value: any): value is string => { - return isString(value) && value !== ''; +export const isStringWithValue = (value: unknown): value is string => { + return isString(value) && value !== ''; }; export const isBlob = (value: any): value is Blob => { - return ( - typeof value === 'object' && - typeof value.type === 'string' && - typeof value.stream === 'function' && - typeof value.arrayBuffer === 'function' && - typeof value.constructor === 'function' && - typeof value.constructor.name === 'string' && - /^(Blob|File)$/.test(value.constructor.name) && - /^(Blob|File)$/.test(value[Symbol.toStringTag]) - ); + return value instanceof Blob; }; -export const isFormData = (value: any): value is FormData => { - return value instanceof FormData; +export const isFormData = (value: unknown): value is FormData => { + return value instanceof FormData; }; export const isSuccess = (status: number): boolean => { - return status >= 200 && status < 300; + return status >= 200 && status < 300; }; export const base64 = (str: string): string => { - try { - return btoa(str); - } catch (err) { - // @ts-ignore - return Buffer.from(str).toString('base64'); - } + try { + return btoa(str); + } catch (err) { + // @ts-ignore + return Buffer.from(str).toString('base64'); + } }; -export const getQueryString = (params: Record): string => { - const qs: string[] = []; - - const append = (key: string, value: any) => { - qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`); - }; - - const process = (key: string, value: any) => { - if (isDefined(value)) { - if (Array.isArray(value)) { - value.forEach(v => { - process(key, v); - }); - } else if (typeof value === 'object') { - Object.entries(value).forEach(([k, v]) => { - process(`${key}[${k}]`, v); - }); - } else { - append(key, value); - } - } - }; - - Object.entries(params).forEach(([key, value]) => { - process(key, value); - }); - - if (qs.length > 0) { - return `?${qs.join('&')}`; - } - - return ''; +export const getQueryString = (params: Record): string => { + const qs: string[] = []; + + const append = (key: string, value: unknown) => { + qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`); + }; + + const encodePair = (key: string, value: unknown) => { + if (value === undefined || value === null) { + return; + } + + if (value instanceof Date) { + append(key, value.toISOString()); + } else if (Array.isArray(value)) { + value.forEach(v => encodePair(key, v)); + } else if (typeof value === 'object') { + Object.entries(value).forEach(([k, v]) => encodePair(`${key}[${k}]`, v)); + } else { + append(key, value); + } + }; + + Object.entries(params).forEach(([key, value]) => encodePair(key, value)); + + return qs.length ? `?${qs.join('&')}` : ''; }; const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => { - const encoder = config.ENCODE_PATH || encodeURI; - - const path = options.url - .replace('{api-version}', config.VERSION) - .replace(/{(.*?)}/g, (substring: string, group: string) => { - if (options.path?.hasOwnProperty(group)) { - return encoder(String(options.path[group])); - } - return substring; - }); - - const url = `${config.BASE}${path}`; - if (options.query) { - return `${url}${getQueryString(options.query)}`; - } - return url; + const encoder = config.ENCODE_PATH || encodeURI; + + const path = options.url + .replace('{api-version}', config.VERSION) + .replace(/{(.*?)}/g, (substring: string, group: string) => { + if (options.path?.hasOwnProperty(group)) { + return encoder(String(options.path[group])); + } + return substring; + }); + + const url = config.BASE + path; + return options.query ? url + getQueryString(options.query) : url; }; export const getFormData = (options: ApiRequestOptions): FormData | undefined => { - if (options.formData) { - const formData = new FormData(); - - const process = (key: string, value: any) => { - if (isString(value) || isBlob(value)) { - formData.append(key, value); - } else { - formData.append(key, JSON.stringify(value)); - } - }; - - Object.entries(options.formData) - .filter(([_, value]) => isDefined(value)) - .forEach(([key, value]) => { - if (Array.isArray(value)) { - value.forEach(v => process(key, v)); - } else { - process(key, value); - } - }); - - return formData; - } - return undefined; + if (options.formData) { + const formData = new FormData(); + + const process = (key: string, value: unknown) => { + if (isString(value) || isBlob(value)) { + formData.append(key, value); + } else { + formData.append(key, JSON.stringify(value)); + } + }; + + Object.entries(options.formData) + .filter(([, value]) => value !== undefined && value !== null) + .forEach(([key, value]) => { + if (Array.isArray(value)) { + value.forEach(v => process(key, v)); + } else { + process(key, value); + } + }); + + return formData; + } + return undefined; }; type Resolver = (options: ApiRequestOptions) => Promise; export const resolve = async (options: ApiRequestOptions, resolver?: T | Resolver): Promise => { - if (typeof resolver === 'function') { - return (resolver as Resolver)(options); - } - return resolver; + if (typeof resolver === 'function') { + return (resolver as Resolver)(options); + } + return resolver; }; -export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions, formData?: FormData): Promise> => { - const token = await resolve(options, config.TOKEN); - const username = await resolve(options, config.USERNAME); - const password = await resolve(options, config.PASSWORD); - const additionalHeaders = await resolve(options, config.HEADERS); - const formHeaders = typeof formData?.getHeaders === 'function' && formData?.getHeaders() || {} - - const headers = Object.entries({ - Accept: 'application/json', - ...additionalHeaders, - ...options.headers, - ...formHeaders, - }) - .filter(([_, value]) => isDefined(value)) - .reduce((headers, [key, value]) => ({ - ...headers, - [key]: String(value), - }), {} as Record); - - if (isStringWithValue(token)) { - headers['Authorization'] = `Bearer ${token}`; - } - - if (isStringWithValue(username) && isStringWithValue(password)) { - const credentials = base64(`${username}:${password}`); - headers['Authorization'] = `Basic ${credentials}`; - } - - if (options.body) { - if (options.mediaType) { - headers['Content-Type'] = options.mediaType; - } else if (isBlob(options.body)) { - headers['Content-Type'] = options.body.type || 'application/octet-stream'; - } else if (isString(options.body)) { - headers['Content-Type'] = 'text/plain'; - } else if (!isFormData(options.body)) { - headers['Content-Type'] = 'application/json'; - } - } - - return headers; +export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise> => { + const [token, username, password, additionalHeaders] = await Promise.all([ + resolve(options, config.TOKEN), + resolve(options, config.USERNAME), + resolve(options, config.PASSWORD), + resolve(options, config.HEADERS), + ]); + + const headers = Object.entries({ + Accept: 'application/json', + ...additionalHeaders, + ...options.headers, + }) + .filter(([, value]) => value !== undefined && value !== null) + .reduce((headers, [key, value]) => ({ + ...headers, + [key]: String(value), + }), {} as Record); + + if (isStringWithValue(token)) { + headers['Authorization'] = `Bearer ${token}`; + } + + if (isStringWithValue(username) && isStringWithValue(password)) { + const credentials = base64(`${username}:${password}`); + headers['Authorization'] = `Basic ${credentials}`; + } + + if (options.body !== undefined) { + if (options.mediaType) { + headers['Content-Type'] = options.mediaType; + } else if (isBlob(options.body)) { + headers['Content-Type'] = options.body.type || 'application/octet-stream'; + } else if (isString(options.body)) { + headers['Content-Type'] = 'text/plain'; + } else if (!isFormData(options.body)) { + headers['Content-Type'] = 'application/json'; + } + } else if (options.formData !== undefined) { + if (options.mediaType) { + headers['Content-Type'] = options.mediaType; + } + } + + return headers; }; -export const getRequestBody = (options: ApiRequestOptions): any => { - if (options.body) { - return options.body; - } - return undefined; +export const getRequestBody = (options: ApiRequestOptions): unknown => { + if (options.body) { + return options.body; + } + return undefined; }; export const sendRequest = async ( - config: OpenAPIConfig, - options: ApiRequestOptions, - url: string, - body: any, - formData: FormData | undefined, - headers: Record, - onCancel: OnCancel, - axiosClient: AxiosInstance + config: OpenAPIConfig, + options: ApiRequestOptions, + url: string, + body: unknown, + formData: FormData | undefined, + headers: Record, + onCancel: OnCancel, + axiosClient: AxiosInstance ): Promise> => { - const source = axios.CancelToken.source(); - - const requestConfig: AxiosRequestConfig = { - url, - headers, - data: body ?? formData, - method: options.method, - withCredentials: config.WITH_CREDENTIALS, - cancelToken: source.token, - }; - - onCancel(() => source.cancel('The user aborted a request.')); - - try { - return await axiosClient.request(requestConfig); - } catch (error) { - const axiosError = error as AxiosError; - if (axiosError.response) { - return axiosError.response; - } - throw error; - } + const controller = new AbortController(); + + let requestConfig: AxiosRequestConfig = { + data: body ?? formData, + headers, + method: options.method, + signal: controller.signal, + url, + withCredentials: config.WITH_CREDENTIALS, + }; + + onCancel(() => controller.abort()); + + for (const fn of config.interceptors.request._fns) { + requestConfig = await fn(requestConfig); + } + + try { + return await axiosClient.request(requestConfig); + } catch (error) { + const axiosError = error as AxiosError; + if (axiosError.response) { + return axiosError.response; + } + throw error; + } }; -export const getResponseHeader = (response: AxiosResponse, responseHeader?: string): string | undefined => { - if (responseHeader) { - const content = response.headers[responseHeader]; - if (isString(content)) { - return content; - } - } - return undefined; +export const getResponseHeader = (response: AxiosResponse, responseHeader?: string): string | undefined => { + if (responseHeader) { + const content = response.headers[responseHeader]; + if (isString(content)) { + return content; + } + } + return undefined; }; -export const getResponseBody = (response: AxiosResponse): any => { - if (response.status !== 204) { - return response.data; - } - return undefined; +export const getResponseBody = (response: AxiosResponse): unknown => { + if (response.status !== 204) { + return response.data; + } + return undefined; }; export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => { - const errors: Record = { - 400: 'Bad Request', - 401: 'Unauthorized', - 403: 'Forbidden', - 404: 'Not Found', - 500: 'Internal Server Error', - 502: 'Bad Gateway', - 503: 'Service Unavailable', - ...options.errors, - } - - const error = errors[result.status]; - if (error) { - throw new ApiError(options, result, error); - } - - if (!result.ok) { - const errorStatus = result.status ?? 'unknown'; - const errorStatusText = result.statusText ?? 'unknown'; - const errorBody = (() => { - try { - return JSON.stringify(result.body, null, 2); - } catch (e) { - return undefined; - } - })(); - - throw new ApiError(options, result, - `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}` - ); - } + const errors: Record = { + 400: 'Bad Request', + 401: 'Unauthorized', + 402: 'Payment Required', + 403: 'Forbidden', + 404: 'Not Found', + 405: 'Method Not Allowed', + 406: 'Not Acceptable', + 407: 'Proxy Authentication Required', + 408: 'Request Timeout', + 409: 'Conflict', + 410: 'Gone', + 411: 'Length Required', + 412: 'Precondition Failed', + 413: 'Payload Too Large', + 414: 'URI Too Long', + 415: 'Unsupported Media Type', + 416: 'Range Not Satisfiable', + 417: 'Expectation Failed', + 418: 'Im a teapot', + 421: 'Misdirected Request', + 422: 'Unprocessable Content', + 423: 'Locked', + 424: 'Failed Dependency', + 425: 'Too Early', + 426: 'Upgrade Required', + 428: 'Precondition Required', + 429: 'Too Many Requests', + 431: 'Request Header Fields Too Large', + 451: 'Unavailable For Legal Reasons', + 500: 'Internal Server Error', + 501: 'Not Implemented', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + 504: 'Gateway Timeout', + 505: 'HTTP Version Not Supported', + 506: 'Variant Also Negotiates', + 507: 'Insufficient Storage', + 508: 'Loop Detected', + 510: 'Not Extended', + 511: 'Network Authentication Required', + ...options.errors, + } + + const error = errors[result.status]; + if (error) { + throw new ApiError(options, result, error); + } + + if (!result.ok) { + const errorStatus = result.status ?? 'unknown'; + const errorStatusText = result.statusText ?? 'unknown'; + const errorBody = (() => { + try { + return JSON.stringify(result.body, null, 2); + } catch (e) { + return undefined; + } + })(); + + throw new ApiError(options, result, + `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}` + ); + } }; /** @@ -288,32 +302,37 @@ export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): * @throws ApiError */ export const request = (config: OpenAPIConfig, options: ApiRequestOptions, axiosClient: AxiosInstance = axios): CancelablePromise => { - return new CancelablePromise(async (resolve, reject, onCancel) => { - try { - const url = getUrl(config, options); - const formData = getFormData(options); - const body = getRequestBody(options); - const headers = await getHeaders(config, options, formData); - - if (!onCancel.isCancelled) { - const response = await sendRequest(config, options, url, body, formData, headers, onCancel, axiosClient); - const responseBody = getResponseBody(response); - const responseHeader = getResponseHeader(response, options.responseHeader); - - const result: ApiResult = { - url, - ok: isSuccess(response.status), - status: response.status, - statusText: response.statusText, - body: responseHeader ?? responseBody, - }; - - catchErrorCodes(options, result); - - resolve(result.body); - } - } catch (error) { - reject(error); - } - }); -}; + return new CancelablePromise(async (resolve, reject, onCancel) => { + try { + const url = getUrl(config, options); + const formData = getFormData(options); + const body = getRequestBody(options); + const headers = await getHeaders(config, options); + + if (!onCancel.isCancelled) { + let response = await sendRequest(config, options, url, body, formData, headers, onCancel, axiosClient); + + for (const fn of config.interceptors.response._fns) { + response = await fn(response); + } + + const responseBody = getResponseBody(response); + const responseHeader = getResponseHeader(response, options.responseHeader); + + const result: ApiResult = { + url, + ok: isSuccess(response.status), + status: response.status, + statusText: response.statusText, + body: responseHeader ?? responseBody, + }; + + catchErrorCodes(options, result); + + resolve(result.body); + } + } catch (error) { + reject(error); + } + }); +}; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 3735d6a..205031a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,110 +1,7 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export { GiteeClient } from './GiteeClient'; - +// This file is auto-generated by @hey-api/openapi-ts export { ApiError } from './core/ApiError'; -export { BaseHttpRequest } from './core/BaseHttpRequest'; export { CancelablePromise, CancelError } from './core/CancelablePromise'; -export { OpenAPI } from './core/OpenAPI'; -export type { OpenAPIConfig } from './core/OpenAPI'; - -export type { AttachFile as AttachFileModel } from './models/AttachFile'; -export type { Blame as BlameModel } from './models/Blame'; -export type { Blob as BlobModel } from './models/Blob'; -export type { Branch as BranchModel } from './models/Branch'; -export type { CheckAnnotation as CheckAnnotationModel } from './models/CheckAnnotation'; -export type { CheckRun as CheckRunModel } from './models/CheckRun'; -export type { Code as CodeModel } from './models/Code'; -export type { CodeComment as CodeCommentModel } from './models/CodeComment'; -export type { CodeForks as CodeForksModel } from './models/CodeForks'; -export type { CodeForksHistory as CodeForksHistoryModel } from './models/CodeForksHistory'; -export type { Commit as CommitModel } from './models/Commit'; -export type { CommitContent as CommitContentModel } from './models/CommitContent'; -export type { CommitParentsBasic as CommitParentsBasicModel } from './models/CommitParentsBasic'; -export type { Compare as CompareModel } from './models/Compare'; -export type { CompleteBranch as CompleteBranchModel } from './models/CompleteBranch'; -export type { Content as ContentModel } from './models/Content'; -export type { ContentBasic as ContentBasicModel } from './models/ContentBasic'; -export type { Contributor as ContributorModel } from './models/Contributor'; -export type { DiffFile as DiffFileModel } from './models/DiffFile'; -export type { EnterpriseBasic as EnterpriseBasicModel } from './models/EnterpriseBasic'; -export type { EnterpriseMember as EnterpriseMemberModel } from './models/EnterpriseMember'; -export type { Event as EventModel } from './models/Event'; -export type { GiteeMetrics as GiteeMetricsModel } from './models/GiteeMetrics'; -export type { GitUser as GitUserModel } from './models/GitUser'; -export type { Group as GroupModel } from './models/Group'; -export type { GroupBasic as GroupBasicModel } from './models/GroupBasic'; -export type { GroupDetail as GroupDetailModel } from './models/GroupDetail'; -export type { GroupFollowers as GroupFollowersModel } from './models/GroupFollowers'; -export type { GroupMember as GroupMemberModel } from './models/GroupMember'; -export type { Hook as HookModel } from './models/Hook'; -export type { Issue as IssueModel } from './models/Issue'; -export type { IssueState as IssueStateModel } from './models/IssueState'; -export type { IssueType as IssueTypeModel } from './models/IssueType'; -export type { Label as LabelModel } from './models/Label'; -export type { Milestone as MilestoneModel } from './models/Milestone'; -export type { Namespace as NamespaceModel } from './models/Namespace'; -export type { NamespaceMini as NamespaceMiniModel } from './models/NamespaceMini'; -export type { Note as NoteModel } from './models/Note'; -export type { OperateLog as OperateLogModel } from './models/OperateLog'; -export type { postV5ReposOwnerRepoCommits as postV5ReposOwnerRepoCommitsModel } from './models/postV5ReposOwnerRepoCommits'; -export type { ProgramBasic as ProgramBasicModel } from './models/ProgramBasic'; -export type { Project as ProjectModel } from './models/Project'; -export type { ProjectBasic as ProjectBasicModel } from './models/ProjectBasic'; -export type { ProjectLabel as ProjectLabelModel } from './models/ProjectLabel'; -export type { ProjectMember as ProjectMemberModel } from './models/ProjectMember'; -export type { ProjectMemberPermission as ProjectMemberPermissionModel } from './models/ProjectMemberPermission'; -export type { ProjectMini as ProjectMiniModel } from './models/ProjectMini'; -export type { ProjectPushConfig as ProjectPushConfigModel } from './models/ProjectPushConfig'; -export type { ProjectStargazers as ProjectStargazersModel } from './models/ProjectStargazers'; -export type { ProjectTrafficData as ProjectTrafficDataModel } from './models/ProjectTrafficData'; -export type { ProjectTrafficDataDesc as ProjectTrafficDataDescModel } from './models/ProjectTrafficDataDesc'; -export type { ProjectTrafficDataSummary as ProjectTrafficDataSummaryModel } from './models/ProjectTrafficDataSummary'; -export type { ProjectWatchers as ProjectWatchersModel } from './models/ProjectWatchers'; -export type { ProtectionRule as ProtectionRuleModel } from './models/ProtectionRule'; -export type { PullRequest as PullRequestModel } from './models/PullRequest'; -export type { PullRequestComments as PullRequestCommentsModel } from './models/PullRequestComments'; -export type { PullRequestCommits as PullRequestCommitsModel } from './models/PullRequestCommits'; -export type { PullRequestFiles as PullRequestFilesModel } from './models/PullRequestFiles'; -export type { RefPullRequest as RefPullRequestModel } from './models/RefPullRequest'; -export type { Release as ReleaseModel } from './models/Release'; -export type { RepoCommit as RepoCommitModel } from './models/RepoCommit'; -export type { RepoCommitWithFiles as RepoCommitWithFilesModel } from './models/RepoCommitWithFiles'; -export type { SSHKey as SSHKeyModel } from './models/SSHKey'; -export type { SSHKeyBasic as SSHKeyBasicModel } from './models/SSHKeyBasic'; -export type { Tag as TagModel } from './models/Tag'; -export type { Tree as TreeModel } from './models/Tree'; -export type { User as UserModel } from './models/User'; -export type { UserAssignee as UserAssigneeModel } from './models/UserAssignee'; -export type { UserBasic as UserBasicModel } from './models/UserBasic'; -export type { UserDetail as UserDetailModel } from './models/UserDetail'; -export type { UserEmail as UserEmailModel } from './models/UserEmail'; -export type { UserInfo as UserInfoModel } from './models/UserInfo'; -export type { UserMessage as UserMessageModel } from './models/UserMessage'; -export type { UserMessageList as UserMessageListModel } from './models/UserMessageList'; -export type { UserMini as UserMiniModel } from './models/UserMini'; -export type { UserNotification as UserNotificationModel } from './models/UserNotification'; -export type { UserNotificationCount as UserNotificationCountModel } from './models/UserNotificationCount'; -export type { UserNotificationList as UserNotificationListModel } from './models/UserNotificationList'; -export type { UserNotificationNamespace as UserNotificationNamespaceModel } from './models/UserNotificationNamespace'; -export type { UserNotificationSubject as UserNotificationSubjectModel } from './models/UserNotificationSubject'; -export type { WeekReport as WeekReportModel } from './models/WeekReport'; - -export { ActivityClient } from './services/ActivityClient'; -export { ChecksClient } from './services/ChecksClient'; -export { EmailsClient } from './services/EmailsClient'; -export { EnterprisesClient } from './services/EnterprisesClient'; -export { GistsClient } from './services/GistsClient'; -export { GitDataClient } from './services/GitDataClient'; -export { IssuesClient } from './services/IssuesClient'; -export { LabelsClient } from './services/LabelsClient'; -export { MilestonesClient } from './services/MilestonesClient'; -export { MiscellaneousClient } from './services/MiscellaneousClient'; -export { OrganizationsClient } from './services/OrganizationsClient'; -export { PullRequestsClient } from './services/PullRequestsClient'; -export { RepositoriesClient } from './services/RepositoriesClient'; -export { SearchClient } from './services/SearchClient'; -export { UsersClient } from './services/UsersClient'; -export { WebhooksClient } from './services/WebhooksClient'; +export { OpenAPI, type OpenAPIConfig } from './core/OpenAPI'; +export * from './schemas.gen'; +export * from './services.gen'; +export * from './types.gen'; \ No newline at end of file diff --git a/src/models/AttachFile.ts b/src/models/AttachFile.ts deleted file mode 100644 index d8d8abb..0000000 --- a/src/models/AttachFile.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import type { UserMini } from './UserMini'; - -/** - * 上传附件到仓库指定 Release - */ -export type AttachFile = { - id?: number; - name?: string; - size?: number; - uploader?: UserMini; - browser_download_url?: string; -}; - diff --git a/src/models/Blame.ts b/src/models/Blame.ts deleted file mode 100644 index a04acbd..0000000 --- a/src/models/Blame.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import type { Commit } from './Commit'; - -/** - * Blame - */ -export type Blame = { - commit?: Commit; - /** - * 代码行 - */ - lines?: Array; -}; - diff --git a/src/models/Blob.ts b/src/models/Blob.ts deleted file mode 100644 index 9fc7fc0..0000000 --- a/src/models/Blob.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -/** - * 获取文件 Blob - */ -export type Blob = { - sha?: string; - size?: number; - url?: string; - content?: string; - encoding?: string; -}; - diff --git a/src/models/Branch.ts b/src/models/Branch.ts deleted file mode 100644 index e64ece3..0000000 --- a/src/models/Branch.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -/** - * 获取所有分支 - */ -export type Branch = { - name?: string; - commit?: string; - protected?: boolean; - protection_url?: string; -}; - diff --git a/src/models/CheckAnnotation.ts b/src/models/CheckAnnotation.ts deleted file mode 100644 index ba5d3b3..0000000 --- a/src/models/CheckAnnotation.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -/** - * 获取检查项代码注释 - */ -export type CheckAnnotation = { - /** - * 文件路径 - */ - path?: string; - /** - * 开始行 - */ - start_line?: number; - /** - * 结束行 - */ - end_line?: number; - /** - * 开始列 - */ - start_column?: number; - /** - * 结束列 - */ - end_column?: number; - /** - * 注释级别 - */ - annotation_level?: string; - /** - * 标题 - */ - title?: string; - /** - * 信息 - */ - message?: string; - /** - * 详情 - */ - raw_details?: string; - /** - * 文件路由 - */ - blob_href?: string; -}; - diff --git a/src/models/CheckRun.ts b/src/models/CheckRun.ts deleted file mode 100644 index a271c0c..0000000 --- a/src/models/CheckRun.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -/** - * 获取某个提交的检查项 - */ -export type CheckRun = { - id?: number; - /** - * 提交 sha 值 - */ - head_sha?: string; - /** - * api 路由 - */ - url?: string; - /** - * 页面路由 - */ - html_url?: string; - /** - * 外部详情路由 - */ - details_url?: string; - /** - * 状态 - */ - status?: string; - /** - * 结论 - */ - conclusion?: string; - /** - * 开始时间 - */ - started_at?: string; - /** - * 完成事件 - */ - completed_at?: string; - /** - * 详情 - */ - output?: any; - /** - * 检查名 - */ - name?: string; -}; - diff --git a/src/models/Code.ts b/src/models/Code.ts deleted file mode 100644 index 29f7466..0000000 --- a/src/models/Code.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import type { UserBasic } from './UserBasic'; - -/** - * 获取用户 Star 的代码片段 - */ -export type Code = { - url?: string; - forks_url?: string; - commits_url?: string; - id?: string; - description?: string; - public?: boolean; - owner?: UserBasic; - user?: UserBasic; - files?: string; - truncated?: boolean; - html_url?: string; - comments?: number; - comments_url?: string; - git_pull_url?: string; - git_push_url?: string; - created_at?: string; - updated_at?: string; -}; - diff --git a/src/models/CodeComment.ts b/src/models/CodeComment.ts deleted file mode 100644 index f65c916..0000000 --- a/src/models/CodeComment.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -/** - * 修改代码片段的评论 - */ -export type CodeComment = { - id?: number; - body?: string; - created_at?: string; - updated_at?: string; -}; - diff --git a/src/models/CodeForks.ts b/src/models/CodeForks.ts deleted file mode 100644 index 989cbcd..0000000 --- a/src/models/CodeForks.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import type { UserBasic } from './UserBasic'; - -/** - * 获取 Fork 了指定代码片段的列表 - */ -export type CodeForks = { - user?: UserBasic; - url?: string; - id?: string; - created_at?: string; - updated_at?: string; -}; - diff --git a/src/models/CodeForksHistory.ts b/src/models/CodeForksHistory.ts deleted file mode 100644 index b8f7bd9..0000000 --- a/src/models/CodeForksHistory.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import type { UserBasic } from './UserBasic'; - -/** - * 获取代码片段的 commit - */ -export type CodeForksHistory = { - url?: string; - forks_url?: string; - commits_url?: string; - id?: string; - description?: string; - public?: boolean; - owner?: UserBasic; - user?: UserBasic; - files?: string; - truncated?: boolean; - html_url?: string; - comments?: number; - comments_url?: string; - git_pull_url?: string; - git_push_url?: string; - created_at?: string; - updated_at?: string; - forks?: string; - history?: string; -}; - diff --git a/src/models/Commit.ts b/src/models/Commit.ts deleted file mode 100644 index 8589af8..0000000 --- a/src/models/Commit.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import type { GitUser } from './GitUser'; - -export type Commit = { - sha?: string; - author?: GitUser; - committer?: GitUser; - message?: string; - tree?: string; - parents?: Array; -}; - diff --git a/src/models/CommitContent.ts b/src/models/CommitContent.ts deleted file mode 100644 index c6cd1f4..0000000 --- a/src/models/CommitContent.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import type { Commit } from './Commit'; -import type { ContentBasic } from './ContentBasic'; - -/** - * 删除文件 - */ -export type CommitContent = { - content?: ContentBasic; - commit?: Commit; -}; - diff --git a/src/models/CommitParentsBasic.ts b/src/models/CommitParentsBasic.ts deleted file mode 100644 index 59a08d2..0000000 --- a/src/models/CommitParentsBasic.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type CommitParentsBasic = { - url?: string; - /** - * 第一个父级 commit 的 sha 值(即将废弃) - */ - sha?: string; - /** - * 全部父级 commit 的 sha 值 - */ - shas?: Array; -}; - diff --git a/src/models/Compare.ts b/src/models/Compare.ts deleted file mode 100644 index f57ec87..0000000 --- a/src/models/Compare.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import type { DiffFile } from './DiffFile'; -import type { RepoCommit } from './RepoCommit'; - -/** - * Commits 对比 - * 返回的 commits 数量限制在 100 以内 - */ -export type Compare = { - base_commit?: RepoCommit; - merge_base_commit?: RepoCommit; - /** - * commits 数量限制在 100 以内 - */ - commits?: Array; - /** - * 文件列表 - */ - files?: Array; - /** - * 文件列表是否被截断 - */ - truncated?: boolean; -}; - diff --git a/src/models/CompleteBranch.ts b/src/models/CompleteBranch.ts deleted file mode 100644 index e35c794..0000000 --- a/src/models/CompleteBranch.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -/** - * 创建分支 - */ -export type CompleteBranch = { - name?: string; - commit?: string; - _links?: string; - protected?: boolean; - protection_url?: string; -}; - diff --git a/src/models/Content.ts b/src/models/Content.ts deleted file mode 100644 index f71b9e4..0000000 --- a/src/models/Content.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -/** - * 获取仓库具体路径下的内容 - */ -export type Content = { - type?: string; - encoding?: string; - size?: number; - name?: string; - path?: string; - content?: string; - sha?: string; - url?: string; - html_url?: string; - download_url?: string; - _links?: string; -}; - diff --git a/src/models/ContentBasic.ts b/src/models/ContentBasic.ts deleted file mode 100644 index 4e7f837..0000000 --- a/src/models/ContentBasic.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type ContentBasic = { - name?: string; - path?: string; - size?: number; - sha?: string; - type?: string; - url?: string; - html_url?: string; - download_url?: string; - _links?: string; -}; - diff --git a/src/models/Contributor.ts b/src/models/Contributor.ts deleted file mode 100644 index 2ce5b37..0000000 --- a/src/models/Contributor.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -/** - * 获取仓库贡献者 - */ -export type Contributor = { - email?: string; - name?: string; - contributions?: number; -}; - diff --git a/src/models/DiffFile.ts b/src/models/DiffFile.ts deleted file mode 100644 index 62debe7..0000000 --- a/src/models/DiffFile.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type DiffFile = { - sha?: string; - /** - * 文件路径 - */ - filename?: string; - /** - * 文件状态 - */ - status?: string; - /** - * 新增行数 - */ - additions?: number; - /** - * 删除行数 - */ - deletions?: number; - /** - * 变更行数 - */ - changes?: number; - /** - * blob 链接 - */ - blob_url?: string; - /** - * raw 链接 - */ - raw_url?: string; - /** - * content 链接 - */ - content_url?: string; - /** - * patch - */ - patch?: string; - /** - * patch 内容是否被截断 - */ - truncated?: boolean; -}; - diff --git a/src/models/EnterpriseBasic.ts b/src/models/EnterpriseBasic.ts deleted file mode 100644 index 55824b9..0000000 --- a/src/models/EnterpriseBasic.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -/** - * 获取一个企业 - */ -export type EnterpriseBasic = { - /** - * 企业 ID - */ - id?: number; - /** - * 企业命名空间 - */ - path?: string; - /** - * 企业名称 - */ - name?: string; - /** - * 企业地址 - */ - url?: string; - /** - * 企业头像地址 - */ - avatar_url?: string; -}; - diff --git a/src/models/EnterpriseMember.ts b/src/models/EnterpriseMember.ts deleted file mode 100644 index 93ddad7..0000000 --- a/src/models/EnterpriseMember.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import type { EnterpriseBasic } from './EnterpriseBasic'; -import type { UserMini } from './UserMini'; - -/** - * 修改企业成员权限或备注 - */ -export type EnterpriseMember = { - url?: string; - active?: boolean; - remark?: string; - role?: string; - outsourced?: boolean; - enterprise?: EnterpriseBasic; - user?: UserMini; -}; - diff --git a/src/models/Event.ts b/src/models/Event.ts deleted file mode 100644 index 2b4f6f6..0000000 --- a/src/models/Event.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import type { GroupBasic } from './GroupBasic'; -import type { ProjectMini } from './ProjectMini'; -import type { UserMini } from './UserMini'; - -/** - * 列出仓库的所有公开动态 - */ -export type Event = { - id?: number; - type?: string; - actor?: UserMini; - repo?: ProjectMini; - org?: GroupBasic; - public?: boolean; - created_at?: string; - /** - * 不同类型动态的内容 - */ - payload?: any; -}; - diff --git a/src/models/GitUser.ts b/src/models/GitUser.ts deleted file mode 100644 index 336e0f0..0000000 --- a/src/models/GitUser.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type GitUser = { - name?: string; - email?: string; - date?: string; -}; - diff --git a/src/models/GiteeMetrics.ts b/src/models/GiteeMetrics.ts deleted file mode 100644 index 2430b91..0000000 --- a/src/models/GiteeMetrics.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import type { ProjectBasic } from './ProjectBasic'; - -/** - * 获取 Gitee 指数 - */ -export type GiteeMetrics = { - data?: string; - total_score?: number; - created_at?: string; - repo?: ProjectBasic; -}; - diff --git a/src/models/Group.ts b/src/models/Group.ts deleted file mode 100644 index eddacfd..0000000 --- a/src/models/Group.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -/** - * 创建组织 - */ -export type Group = { - id?: number; - login?: string; - name?: string; - url?: string; - avatar_url?: string; - repos_url?: string; - events_url?: string; - members_url?: string; - description?: string; - follow_count?: number; -}; - diff --git a/src/models/GroupBasic.ts b/src/models/GroupBasic.ts deleted file mode 100644 index 7877561..0000000 --- a/src/models/GroupBasic.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type GroupBasic = { - id?: number; - login?: string; - name?: string; - url?: string; - avatar_url?: string; -}; - diff --git a/src/models/GroupDetail.ts b/src/models/GroupDetail.ts deleted file mode 100644 index 70104f0..0000000 --- a/src/models/GroupDetail.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import type { UserMini } from './UserMini'; - -/** - * 更新授权用户所管理的组织资料 - */ -export type GroupDetail = { - id?: number; - login?: string; - name?: string; - url?: string; - avatar_url?: string; - repos_url?: string; - events_url?: string; - members_url?: string; - description?: string; - follow_count?: number; - type?: string; - location?: string; - email?: string; - created_at?: string; - html_url?: string; - public?: boolean; - enterprise?: string; - members?: number; - public_repos?: number; - private_repos?: number; - owner?: UserMini; -}; - diff --git a/src/models/GroupFollowers.ts b/src/models/GroupFollowers.ts deleted file mode 100644 index 976ac00..0000000 --- a/src/models/GroupFollowers.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import type { UserBasic } from './UserBasic'; - -/** - * 列出指定组织的所有关注者 - */ -export type GroupFollowers = { - self?: UserBasic; - followed_at?: string; -}; - diff --git a/src/models/GroupMember.ts b/src/models/GroupMember.ts deleted file mode 100644 index d5ac2f4..0000000 --- a/src/models/GroupMember.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import type { Group } from './Group'; -import type { UserMini } from './UserMini'; - -/** - * 增加或更新授权用户所管理组织的成员 - */ -export type GroupMember = { - url?: string; - active?: boolean; - remark?: string; - role?: string; - organization_url?: string; - organization?: Group; - user?: UserMini; -}; - diff --git a/src/models/Hook.ts b/src/models/Hook.ts deleted file mode 100644 index c853ff5..0000000 --- a/src/models/Hook.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -/** - * 更新一个仓库 WebHook - */ -export type Hook = { - id?: number; - url?: string; - password?: string; - result?: string; - project_id?: number; - result_code?: number; - created_at?: string; - push_events?: boolean; - tag_push_events?: boolean; - issues_events?: boolean; - note_events?: boolean; - merge_requests_events?: boolean; -}; - diff --git a/src/models/Issue.ts b/src/models/Issue.ts deleted file mode 100644 index 167bdca..0000000 --- a/src/models/Issue.ts +++ /dev/null @@ -1,130 +0,0 @@ -/* generated using openapi-typescript-codegen -- do no edit */ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -import type { IssueState } from './IssueState'; -import type { IssueType } from './IssueType'; -import type { Label } from './Label'; -import type { Milestone } from './Milestone'; -import type { ProgramBasic } from './ProgramBasic'; -import type { Project } from './Project'; -import type { UserBasic } from './UserBasic'; - -/** - * 搜索 Issues - */ -export type Issue = { - id?: number; - url?: string; - repository_url?: string; - labels_url?: string; - comments_url?: string; - html_url?: string; - parent_url?: string; - /** - * 唯一标识 - */ - number?: string; - /** - * 上级 id - */ - parent_id?: number; - /** - * 所在层级 - */ - depth?: number; - /** - * 状态 - */ - state?: string; - /** - * 标题 - */ - title?: string; - /** - * 描述 - */ - body?: string; - /** - * 描述 html 格式 - */ - body_html?: string; - /** - * 作者 - */ - user?: UserBasic; - /** - * 标签 - */ - labels?: Array