外观
App
约 2699 字大约 9 分钟
2025-08-01
@candriajs/git-neko-kit / github / App
类: App
定义于: models/platform/github/app.ts:45
GitHub 应用管理类
提供对GitHub App的完整管理功能,包括:
- 获取应用基本信息
- 生成应用安装链接
- 生成应用配置链接
继承
构造函数
构造函数
new App(
base
):App
定义于: models/platform/github/app.ts:46
参数
base
返回
App
重写了
属性
api_url
api_url:
string
定义于: models/platform/github/client.ts:79
继承自
app
app:
App
定义于: models/platform/github/client.ts:67
继承自
auth
auth:
Auth
定义于: models/platform/github/client.ts:68
继承自
base_url
base_url:
string
定义于: models/platform/github/client.ts:78
继承自
Client_ID?
readonly
optional
Client_ID:null
|string
定义于: models/platform/github/client.ts:83
继承自
Client_Secret?
readonly
optional
Client_Secret:null
|string
定义于: models/platform/github/client.ts:84
继承自
commit
commit:
Commit
定义于: models/platform/github/client.ts:69
继承自
format
readonly
format:boolean
定义于: models/platform/github/client.ts:86
继承自
issue
issue:
Issue
定义于: models/platform/github/client.ts:73
继承自
jwtToken
jwtToken:
string
定义于: models/platform/github/client.ts:80
继承自
org
org:
Org
定义于: models/platform/github/client.ts:74
继承自
Private_Key?
readonly
optional
Private_Key:null
|string
定义于: models/platform/github/client.ts:82
继承自
pull_request
pull_request:
Pull_Request
定义于: models/platform/github/client.ts:75
继承自
repo
repo:
Repo
定义于: models/platform/github/client.ts:70
继承自
search
search:
Search
定义于: models/platform/github/client.ts:77
继承自
user
user:
User
定义于: models/platform/github/client.ts:71
继承自
userToken?
optional
userToken:null
|string
定义于: models/platform/github/client.ts:81
继承自
webhook
webhook:
WebHook
定义于: models/platform/github/client.ts:72
继承自
WebHook_Secret?
readonly
optional
WebHook_Secret:null
|string
定义于: models/platform/github/client.ts:85
继承自
workflow
workflow:
Workflow
定义于: models/platform/github/client.ts:76
继承自
访问器
is_app_client
Getter 签名
get is_app_client():
boolean
定义于: models/platform/github/client.ts:130
是否是App客户端
示例
const isAppClient = await client.is_app_client
-> true
返回
boolean
是否是App客户端
继承自
type
Getter 签名
get type():
GitType
定义于: models/platform/github/client.ts:117
获取Git平台类型
示例
const type = await client.type
-> 'github'
返回
Git平台类型,如: github,gitee
继承自
方法
create_access_token_for_app()
create_access_token_for_app(
options
):Promise
<ApiResponseType
<CreateAccessTokenForAppResponseType
>>
定义于: models/platform/github/app.ts:405
为应用程序创建访问令牌
参数
options
CreateAccessTokenForAppParamType
installation_id - 安装 ID
返回
Promise
<ApiResponseType
<CreateAccessTokenForAppResponseType
>>
创建访问令牌对象
示例
const accessToken = await app.create_access_token_for_app({ installation_id: 123456 })
-> 创建访问令牌对象
create_config_install_link()
create_config_install_link(
state_id?
):Promise
<string
>
定义于: models/platform/github/app.ts:554
生成Github Apps 配置链接
参数
state_id?
string
传入的 state_id, 随机字符串
返回
Promise
<string
>
返回配置链接对象
示例
const link = await app.create_config_install_link('state_id')
-> // https://github.com/apps/<app_name>/installations/new?state=<state_id></state_id>
create_install_link()
create_install_link(
state_id?
):Promise
<string
>
定义于: models/platform/github/app.ts:530
生成Github App 安装链接
参数
state_id?
string
随机生成的 state_id,用于验证授权请求的状态,可选,默认不使用
返回
Promise
<string
>
install_link 安装链接,用于跳转 Github 安装页
示例
const link = await app.create_install_link('state_id')
-> https://github.com/apps/<app_name>/installations/new?state=<state_id>
delete()
delete(
path
,params
,data?
,customHeaders?
):Promise
<ApiResponseType
<any
>>
定义于: models/platform/github/client.ts:602
Github DELETE 请求方法
参数
path
string
请求路径
params
URL查询参数
null
| Record
<string
, string
>
data?
any
请求体数据
customHeaders?
Record
<string
, string
>
请求头,选项
返回
Promise
<ApiResponseType
<any
>>
请求结果
继承自
get()
get(
path
,parms?
,customHeaders?
):Promise
<ApiResponseType
<any
>>
定义于: models/platform/github/client.ts:455
Github GET 请求方法
参数
path
string
请求路径
parms?
any
请求参数
customHeaders?
Record
<string
, string
>
请求头,选项
返回
Promise
<ApiResponseType
<any
>>
请求结果
继承自
get_app()
get_app():
Promise
<App
>
定义于: models/platform/github/client.ts:177
获取App实例
返回
Promise
<App
>
App实例
示例
const app = await GitHubClient.get_app()
继承自
get_app_info()
get_app_info(
options
):Promise
<ApiResponseType
<AppInfoResponseType
>>
定义于: models/platform/github/app.ts:66
获取应用基本信息 权限:
none
无
参数
options
应用标识符
返回
Promise
<ApiResponseType
<AppInfoResponseType
>>
应用基本信息
示例
const app = base.get_app()
console.log(app.get_app_info({ app_slug: 'loli' }))
-> app的信息
get_app_info_by_auth()
get_app_info_by_auth():
Promise
<ApiResponseType
<AppInfoResponseType
>>
定义于: models/platform/github/app.ts:128
获取当前 Github App 信息 权限:
none
此节点仅App Client可用
返回
Promise
<ApiResponseType
<AppInfoResponseType
>>
返回 Github App 信息
示例
const app = base.get_app()
console.log(app.get_app_info_by_auth())
-> app的信息
get_app_installation_by_org()
get_app_installation_by_org(
options
):Promise
<ApiResponseType
<AppRepoInfoResponseType
>>
定义于: models/platform/github/app.ts:336
获取组织的应用安装信息 权限:
none
此节点仅App Client可用
参数
options
仓库安装应用参数对象
- owner 拥有者
- repo 仓库名
返回
Promise
<ApiResponseType
<AppRepoInfoResponseType
>>
返回应用安装信息
示例
console.log(app.get_app_installation_by_repo({owner: 'owner', repo: 'repo'}))
-> 组织安装应用信息
get_app_installation_by_repo()
get_app_installation_by_repo(
options
):Promise
<ApiResponseType
<AppRepoInfoResponseType
>>
定义于: models/platform/github/app.ts:190
获取仓库的应用安装信息 权限:
none
此节点仅App Client可用
参数
options
仓库安装应用参数对象
- owner 拥有者
- repo 仓库名
返回
Promise
<ApiResponseType
<AppRepoInfoResponseType
>>
返回应用安装信息
示例
console.log(app.get_app_installation_by_repo({owner: 'owner', repo: 'repo'}))
-> 仓库安装应用信息
get_app_installation_by_user()
get_app_installation_by_user(
options
):Promise
<ApiResponseType
<AppRepoInfoResponseType
>>
定义于: models/platform/github/app.ts:263
获取用户的应用安装信息 权限:
none
此节点仅App Client可用
参数
options
仓库安装应用参数对象
- owner 拥有者
- repo 仓库名
返回
Promise
<ApiResponseType
<AppRepoInfoResponseType
>>
返回应用安装信息
示例
console.log(app.get_app_installation_by_repo({owner: 'owner', repo: 'repo'}))
-> 用户安装应用信息
get_app_name()
get_app_name():
Promise
<string
>
定义于: models/platform/github/app.ts:576
快速获取当前 Github App 名称
返回
Promise
<string
>
返回 Github App 名称
示例
console.log(app.get_app_name())
-> 输出AppName
get_auth()
get_auth():
Promise
<Auth
>
定义于: models/platform/github/client.ts:191
获取Auth实例
返回
Promise
<Auth
>
Auth实例
示例
const auth = await GitHubClient.get_auth()
继承自
get_commit()
get_commit():
Promise
<Commit
>
定义于: models/platform/github/client.ts:205
获取Commit实例
返回
Promise
<Commit
>
Commit实例
示例
const commit = await GitHubClient.get_commit()
继承自
get_issue()
get_issue():
Promise
<Issue
>
定义于: models/platform/github/client.ts:219
获取Issue实例
返回
Promise
<Issue
>
Issue实例
示例
const issue = await GitHubClient.get_issue()
继承自
get_org()
get_org():
Promise
<Org
>
定义于: models/platform/github/client.ts:261
获取Org实例
返回
Promise
<Org
>
Org实例
示例
const org = await GitHubClient.get_org()
继承自
get_pull_request()
get_pull_request():
Promise
<Pull_Request
>
定义于: models/platform/github/client.ts:289
获取Pull_request实例
返回
Promise
<Pull_Request
>
Pull_request实例
示例
const pull_request = await GitHubClient.get_pull_request()
继承自
get_repo()
get_repo():
Promise
<Repo
>
定义于: models/platform/github/client.ts:233
获取Repo实例
返回
Promise
<Repo
>
Repo实例
示例
const repo = await GitHubClient.get_repo()
继承自
get_search()
get_search():
Promise
<Search
>
定义于: models/platform/github/client.ts:317
获取Search实例
返回
Promise
<Search
>
Search实例
示例
const search = await GitHubClient.get_search()
继承自
get_user()
get_user():
Promise
<User
>
定义于: models/platform/github/client.ts:247
获取User实例
返回
Promise
<User
>
User实例
示例
const user = await GitHubClient.get_user()
继承自
get_webhook()
get_webhook():
Promise
<WebHook
>
定义于: models/platform/github/client.ts:275
获取WebHook实例
返回
Promise
<WebHook
>
WebHook实例
示例
const webhook = await GitHubClient.get_webhook()
继承自
get_workflow()
get_workflow():
Promise
<Workflow
>
定义于: models/platform/github/client.ts:303
获取Workflow实例
返回
Promise
<Workflow
>
Workflow实例
示例
const workflow = await GitHubClient.get_workflow()
继承自
is_app_installed_in_repo()
is_app_installed_in_repo(
options
):Promise
<boolean
>
定义于: models/platform/github/app.ts:595
快速判断指定仓库是否安装了当前App 应用
参数
options
仓库安装应用参数对象
- owner 拥有者
- repo 仓库名
返回
Promise
<boolean
>
是否安装
示例
// 当前App已安装在此仓库
const isInstalled = await app.is_app_inttalled_in_repo({ owner: 'owner', repo: 'repo' })
-> true
// 当前App未安装此仓库
const isInstalled = await app.is_app_inttalled_in_repo({ owner: 'owner', repo: 'repo' })
-> false
***
### patch()
> **patch**(`path`, `params`, `data`, `customHeaders?`): `Promise`\<[`ApiResponseType`](../../../../interfaces/ApiResponseType.md)\<`any`\>\>
定义于: [models/platform/github/client.ts:528](https://github.com/CandriaJS/git-neko-kit/blob/68e1dc12fd1bcb6fcbe1a2aa6869f49f3640b1b1/src/models/platform/github/client.ts#L528)
Github PATCH 请求方法
#### 参数
##### path
`string`
请求路径
##### params
URL查询参数
`null` | `Record`\<`string`, `string`\>
##### data
`any`
请求数据
##### customHeaders?
`Record`\<`string`, `string`\>
请求头,选项
#### 返回
`Promise`\<[`ApiResponseType`](../../../../interfaces/ApiResponseType.md)\<`any`\>\>
请求结果
#### 继承自
[`GitHubClient`](../../../../classes/GitHubClient.md).[`patch`](../../../../classes/GitHubClient.md#patch)
***
### post()
> **post**(`path`, `data`, `customHeaders?`): `Promise`\<[`ApiResponseType`](../../../../interfaces/ApiResponseType.md)\<`any`\>\>
定义于: [models/platform/github/client.ts:491](https://github.com/CandriaJS/git-neko-kit/blob/68e1dc12fd1bcb6fcbe1a2aa6869f49f3640b1b1/src/models/platform/github/client.ts#L491)
Github POST 请求方法
#### 参数
##### path
`string`
请求路径
##### data
`any`
请求数据
##### customHeaders?
`Record`\<`string`, `string`\>
请求头,选项
#### 返回
`Promise`\<[`ApiResponseType`](../../../../interfaces/ApiResponseType.md)\<`any`\>\>
请求结果
#### 继承自
[`GitHubClient`](../../../../classes/GitHubClient.md).[`post`](../../../../classes/GitHubClient.md#post)
***
### put()
> **put**(`path`, `data`, `customHeaders?`): `Promise`\<[`ApiResponseType`](../../../../interfaces/ApiResponseType.md)\<`any`\>\>
定义于: [models/platform/github/client.ts:565](https://github.com/CandriaJS/git-neko-kit/blob/68e1dc12fd1bcb6fcbe1a2aa6869f49f3640b1b1/src/models/platform/github/client.ts#L565)
Github PUT 请求方法
#### 参数
##### path
`string`
请求路径
##### data
`any`
请求数据
##### customHeaders?
`Record`\<`string`, `string`\>
请求头,选项
#### 返回
`Promise`\<[`ApiResponseType`](../../../../interfaces/ApiResponseType.md)\<`any`\>\>
请求结果
#### 继承自
[`GitHubClient`](../../../../classes/GitHubClient.md).[`put`](../../../../classes/GitHubClient.md#put)
***
### revoke\_access\_token\_for\_app()
> **revoke\_access\_token\_for\_app**(): `Promise`\<[`ApiResponseType`](../../../../interfaces/ApiResponseType.md)\<[`RevokeAccessTokenResponseType`](../../../../interfaces/RevokeAccessTokenResponseType.md)\>\>
定义于: [models/platform/github/app.ts:479](https://github.com/CandriaJS/git-neko-kit/blob/68e1dc12fd1bcb6fcbe1a2aa6869f49f3640b1b1/src/models/platform/github/app.ts#L479)
撤销应用程序访问令牌
#### 返回
`Promise`\<[`ApiResponseType`](../../../../interfaces/ApiResponseType.md)\<[`RevokeAccessTokenResponseType`](../../../../interfaces/RevokeAccessTokenResponseType.md)\>\>
撤销应用程序访问令牌
#### 示例
```ts
const res = await auth.revoke_access_token_for_app()
-> data: { 'success': true, 'message': '喵呜~ 访问令牌撤销成功' }
***
### setProxy()
> **setProxy**(`proxy`): `void`
定义于: [models/platform/github/client.ts:343](https://github.com/CandriaJS/git-neko-kit/blob/68e1dc12fd1bcb6fcbe1a2aa6869f49f3640b1b1/src/models/platform/github/client.ts#L343)
设置请求代理
#### 参数
##### proxy
[`ProxyParamsType`](../../../../type-aliases/ProxyParamsType.md)
代理参数
#### 返回
`void`
#### 示例
```ts
setProxy({
type: 'http',
address: 'http://127.0.0.1:7890'
})
继承自
setRequestConfig()
protected
setRequestConfig(config
):void
定义于: models/platform/github/client.ts:428
设置当前请求的配置
- 仅在父类与子类中方法中可访问
参数
config
配置对象,包含以下属性:
- url: 请求的URL
- token: 认证令牌
- tokenType: 认证令牌类型,默认为 'Bearer'
返回
void
继承自
setToken()
setToken(
token
):void
定义于: models/platform/github/client.ts:390
设置 token 传入的 token 必须以 ghu_ 或 ghp_ 或 ghs_ 开头,否则会抛出错误
参数
token
string
传入的 token
返回
void
示例
setToken('ghu_xxxx')