node-cnb 1.0.0 → 1.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.cnb.yml ADDED
@@ -0,0 +1,31 @@
1
+ .install: &install
2
+ - name: build cache image
3
+ type: docker:cache
4
+ options:
5
+ dockerfile: cache.dockerfile
6
+ by:
7
+ - package.json
8
+ - package-lock.json
9
+ exports:
10
+ name: DOCKER_CACHE_IMAGE_NAME
11
+ - name: copy node_modules
12
+ image: $DOCKER_CACHE_IMAGE_NAME
13
+ commands:
14
+ - cp -r "$NODE_PATH" ./node_modules
15
+ - name: build
16
+ image: $DOCKER_CACHE_IMAGE_NAME
17
+ script: npm run build
18
+ $:
19
+ tag_push:
20
+ - stages:
21
+ - *install
22
+ - name: npm publish
23
+ image: tencentcom/npm
24
+ imports: https://cnb.cool/folger/folger-secret/-/blob/main/npm_secret.yml
25
+ settings:
26
+ username: $NPM_USER
27
+ token: $NPM_TOKEN
28
+ email: $NPM_EMAIL
29
+ folder: ./
30
+ fail_on_version_conflict: true
31
+
package/CHANGELOG.md ADDED
@@ -0,0 +1,68 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ### [1.2.8](https://cnb.cool/cnb/sdk/node-cnb/compare/v1.2.7...v1.2.8) (2025-02-12)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * 更正ci配置 ([e4ee23d](https://cnb.cool/cnb/sdk/node-cnb/commit/e4ee23d2eb5459cda2582974d921943d17fcbcef))
11
+
12
+ ### [1.2.7](https://cnb.cool/cnb/sdk/node-cnb/compare/v1.2.6...v1.2.7) (2025-02-12)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * npm publish换用token ([debb51a](https://cnb.cool/cnb/sdk/node-cnb/commit/debb51ae93b6e8d1384e4f4519c745aac0507847))
18
+
19
+ ### [1.2.6](https://cnb.cool/cnb/sdk/node-cnb/compare/v1.2.5...v1.2.6) (2025-02-12)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * 更换npm插件修复npm发布报错 ([82ebce5](https://cnb.cool/cnb/sdk/node-cnb/commit/82ebce59059d40c3f941954c0437fc071362d7bb))
25
+
26
+ ### [1.2.5](https://cnb.cool/cnb/sdk/node-cnb/compare/v1.2.4...v1.2.5) (2025-02-12)
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * 修复构建报错 ([240069a](https://cnb.cool/cnb/sdk/node-cnb/commit/240069afb3eb18e49d231f80470e813fdc856dbc))
32
+
33
+ ### [1.2.4](https://cnb.cool/cnb/sdk/node-cnb/compare/v1.2.3...v1.2.4) (2025-02-12)
34
+
35
+
36
+ ### Bug Fixes
37
+
38
+ * 更正流水线报错 ([80500ac](https://cnb.cool/cnb/sdk/node-cnb/commit/80500acf043a91366209bd0261df20ba60a28765))
39
+
40
+ ### [1.2.3](https://cnb.cool/cnb/sdk/node-cnb/compare/v1.2.2...v1.2.3) (2025-02-12)
41
+
42
+
43
+ ### Bug Fixes
44
+
45
+ * 修复流水线报错 ([26f01b2](https://cnb.cool/cnb/sdk/node-cnb/commit/26f01b2e33a1a9cad2e54406aed28e4859546c8f))
46
+
47
+ ### [1.2.2](https://cnb.cool/cnb/sdk/node-cnb/compare/v1.2.1...v1.2.2) (2025-02-12)
48
+
49
+
50
+ ### Bug Fixes
51
+
52
+ * 更正缓存镜像的node版本 ([5384a07](https://cnb.cool/cnb/sdk/node-cnb/commit/5384a070c4c1552566bec5c2d0433c750a4bcc4b))
53
+
54
+ ### [1.2.1](https://cnb.cool/cnb/sdk/node-cnb/compare/v1.2.0...v1.2.1) (2025-02-12)
55
+
56
+ ## 1.2.0 (2025-02-12)
57
+
58
+
59
+ ### Features
60
+
61
+ * 编写文档以及修复post参数不生效问题 ([d65cc4f](https://cnb.cool/cnb/sdk/node-cnb/commit/d65cc4f51e1068c9e6b190df3328a1021342bf63))
62
+ * 初步完成代码编译 ([be40568](https://cnb.cool/cnb/sdk/node-cnb/commit/be40568efb7a2debefeef0e036acd7fc05082797))
63
+ * 初始提交 ([f3e6333](https://cnb.cool/cnb/sdk/node-cnb/commit/f3e6333e488417bb66dfa342ff57ca727e5f12f1))
64
+ * 生成类型声明和ts代码初稿 ([1ff64fd](https://cnb.cool/cnb/sdk/node-cnb/commit/1ff64fd4efc9971bcece7a42c8f021f405e57671))
65
+
66
+ # Changelog
67
+
68
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
package/README.md CHANGED
@@ -1,23 +1,17 @@
1
- node-cnb 是一个用于访问 [CNB API]((https://api.cnb.cool/)) 的 node 编写的 SDK。
2
-
3
- # 实现原理
4
-
5
- cnb 会编译出 open api 的 swagger json,并生成 api 页面。
6
-
7
- 该 sdk 依据 swagger json 编译生成对应的 typescript 代码。
8
-
9
- sdk 内部采用 ES6 新增的语法 Proxy ,在方法调用时按属性路径获取对应的 api 声明,
10
- 组装 api url 和 参数,用 axios 发起 http(s) 请求调用服务端 api。
1
+ node-cnb 是一个用于访问 [CNB API](https://api.cnb.cool/) 的 node 编写的 SDK。
11
2
 
12
3
  # 安装
13
4
 
14
- `npm install node-cnb`
5
+ ```shell
6
+ npm install node-cnb
7
+ ```
15
8
 
16
9
  # 使用
17
10
 
18
11
  ```typescript
19
12
  import { getClient } from "node-cnb";
20
13
 
14
+ // 参数分别为 api url 和 访问令牌
21
15
  const client = getClient('https://api.cnb.cool', 'xxx');
22
16
 
23
17
  client.users.pinnedRepos.list({
@@ -31,6 +25,7 @@ client.users.pinnedRepos.list({
31
25
  ```javascript
32
26
  const sdk = require('node-cnb');
33
27
 
28
+ // 参数分别为 api url 和 访问令牌
34
29
  const client = sdk.getClient('https://api.cnb.cool', 'xxx');
35
30
 
36
31
  client.users.pinnedRepos.list({
package/build.js CHANGED
@@ -5,6 +5,14 @@ const apiSwagger = require('./openapi_swagger.json');
5
5
  const { definitions } = apiSwagger;
6
6
  const pathMethodNameMap = require('./pathMethodMap.json');
7
7
 
8
+ /**
9
+ * 实现原理
10
+ *
11
+ * cnb 会编译出 open api 的 [swagger json](https://api.cnb.cool/swagger.json),并生成 api 页面。
12
+ *
13
+ * 本仓库依据 swagger json 编译生成对应的 typescript 代码。
14
+ */
15
+
8
16
  const pathMethodsMap = {}
9
17
 
10
18
  const buildPathMethods = () => {
@@ -46,11 +54,11 @@ function convertSchemaToType(schema) {
46
54
  return 'any'
47
55
  }
48
56
  for (const [key, value] of Object.entries(schema.properties)) {
49
- const typeName = key.includes('-')?`'${key}'`: key;
50
- if(typeName !== key){
51
- console.log('typeName',key,typeName)
57
+ const typeName = key.includes('-') ? `'${key}'` : key;
58
+ if (typeName !== key) {
59
+ console.log('typeName', key, typeName)
52
60
  }
53
-
61
+
54
62
  if (value.description) {
55
63
  properties += `\n /**${value.description}*/\n`
56
64
  }
@@ -100,7 +108,7 @@ const buildClientInterface = () => {
100
108
  currentSub = currentSub[method];
101
109
  })
102
110
  });
103
-
111
+
104
112
  const getMethodContent = (tree, path) => {
105
113
  let content = '';
106
114
  Object.keys(tree).forEach(method => {
@@ -108,23 +116,23 @@ const buildClientInterface = () => {
108
116
  ${_.camelCase(method)}: ${getMethodContent(tree[method], [path, method].filter(Boolean).join('.'))}
109
117
  `;
110
118
  })
111
- if(!content){
112
- const methodValue = pathMethodsMap[path]?.[0]||{};
119
+ if (!content) {
120
+ const methodValue = pathMethodsMap[path]?.[0] || {};
113
121
  const resultType = convertSchemaToType(methodValue.responses?.['200']?.schema || {});
114
- importTypes.push(resultType.replace('[]',''))
115
-
116
- content = `(params: {${(methodValue.parameters||[]).map(param=>{
122
+ importTypes.push(resultType.replace('[]', ''))
117
123
 
118
- return param.name + (param.required?'':'?') + ': '+convertSchemaToType(param)
119
- })}}) => Promise<${resultType}>`
120
- }else {
124
+ content = `(params: {${(methodValue.parameters || []).map(param => {
125
+
126
+ return param.name + (param.required ? '' : '?') + ': ' + convertSchemaToType(param)
127
+ })}}) => Promise<${resultType}>`
128
+ } else {
121
129
  content = `{
122
130
  ${content}
123
131
  }`
124
132
  }
125
133
  return content;
126
134
  }
127
-
135
+
128
136
  let interfaceContent = `
129
137
  export interface Client ${getMethodContent(pathTree, '')}
130
138
  `;
@@ -135,7 +143,7 @@ ${interfaceContent}`
135
143
 
136
144
  }
137
145
 
138
- const prettier = ()=>{
146
+ const prettier = () => {
139
147
  cp.execSync('npx prettier --write ./src/*.ts');
140
148
  }
141
149
 
@@ -0,0 +1,14 @@
1
+ # 选择一个 Base 镜像
2
+ FROM node:20
3
+
4
+ # 设置工作目录
5
+ WORKDIR /space
6
+
7
+ # 将 by 中的文件列表 COPY 过来
8
+ COPY . .
9
+
10
+ # 根据 COPY 过来的文件进行依赖的安装
11
+ RUN npm install
12
+
13
+ # 设置好需要的环境变量
14
+ ENV NODE_PATH=/space/node_modules
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ var callApi = function (baseUrl, token, methodPath, params) {
43
43
  Object.assign(bodyParams, (params === null || params === void 0 ? void 0 : params[item.name]) || {});
44
44
  });
45
45
  var apiPath = "".concat(baseUrl).concat(path);
46
- console.log("api call", apiPath, queryParams, bodyParams);
46
+ console.log("api call", apiPath, method);
47
47
  return (0, axios_1.default)({
48
48
  method: method,
49
49
  url: apiPath,
@@ -51,6 +51,7 @@ var callApi = function (baseUrl, token, methodPath, params) {
51
51
  Authorization: "Bearer ".concat(token),
52
52
  accept: "application/json",
53
53
  },
54
+ params: queryParams,
54
55
  data: bodyParams,
55
56
  }).then(function (res) { return res.data; });
56
57
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAA0B;AAC1B,4DAAiC;AAGjC,IAAM,OAAO,GAAG,UACd,OAAe,EACf,KAAa,EACb,UAAkB,EAClB,MAAW;IAEX,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAChC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AE,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,EAArC,CAAqC,CAAC;QAChE,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,KAAK,CACd,EAAE,EACF;gBACE,GAAG,YAAC,MAAM,EAAE,IAAI;oBACd,OAAO,QAAQ,CAAC,IAAI,GAAG,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC7C,CAAC;aACF,CACF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,IAAI,KAAK,CACd,EAAE,EACF;QACE,GAAG,EAAE,UAAC,MAAM,EAAE,IAAY;YACxB,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;YAC9B,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAChC,CAAC;KACF,CACQ,CAAC;AACd,CAAC,CAAC;AA1BW,QAAA,SAAS,aA0BpB"}
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "node-cnb",
3
- "version": "1.0.0",
3
+ "version": "1.2.8",
4
4
  "description": "node sdk for cnb open api",
5
5
  "main": "dist/index.js",
6
6
  "typings": "./src/index.d.ts",
7
7
  "scripts": {
8
8
  "test": "echo \"Error: no test specified\" && exit 1",
9
- "build": "node build.js && tsc && cp src/*.d.ts dist/ && cp src/*.json dist/"
9
+ "build": "node build.js && tsc && cp src/*.d.ts dist/ && cp src/*.json dist/",
10
+ "release": "standard-version && git push --follow-tags origin main"
10
11
  },
11
12
  "repository": {
12
13
  "type": "git",
@@ -27,6 +28,7 @@
27
28
  "@types/lodash": "^4.17.15",
28
29
  "lodash": "^4.17.21",
29
30
  "prettier": "^3.5.0",
31
+ "standard-version": "^9.5.0",
30
32
  "typescript": "^5.7.3"
31
33
  }
32
34
  }
package/client.d.ts DELETED
@@ -1,662 +0,0 @@
1
- import {DtoUsersResultForSelf, DtoOrganizationAccess, DtoRepos4User, DtoRepos4UserBase, DtoUsersResult, DtoUserFollowResult, DtoOrganizationUnion, DtoWorkspaceDeleteResult, DtoWorkspaceListResult, DtoListInheritMembers, DtoUsersWithAccessLevelInSlug, DtoMemberAccessLevelInSlugUnion, DtoMemberAccessLevel, DtoOrganizationSettingWithParent, DtoUploadAssetsResponse, DtoBuildLogsResult, DtoBuildResult, DtoBuildStatusResult, WebRepoContribTrend, DtoForks, ApiBranch, ApiBranchDetail, WebCommitAnnotationInBatch, WebCommitAnnotation, ApiCommitAsset, ApiCommitStatus, ApiCommit, ApiCompareResponse, ApiContent, OpenapiHeadRef, WebTagAnnotation, ApiTag, ApiIssue, ApiIssueDetail, ApiIssueComment, ApiLabel, DtoOutsideCollaboratorInRepo, ApiPullRequest, ApiPull, ApiPullRequestComment, ApiMergePullResponse, ApiRelease, ApiReleaseAsset, ApiBranchProtection, ApiPipelineSettings, ApiPullRequestSettings, ApiPushLimitSettings, DtoRepoStarUsers, DtoWorkspaceDetailResult} from './types';
2
-
3
- export interface Client {
4
-
5
- groups: {
6
-
7
- post: (params: {request: any}) => Promise<any>
8
-
9
- }
10
-
11
- user: {
12
-
13
- get: (params: {}) => Promise<DtoUsersResultForSelf>
14
-
15
- post: (params: {request: any}) => Promise<any>
16
-
17
- autocomplete_source: {
18
-
19
- list: (params: {source_type?: string,page?: number,page_size?: number,search?: string,access?: string}) => Promise<string[]>
20
-
21
- }
22
-
23
- groups: {
24
-
25
- list: (params: {page?: number,page_size?: number,search?: string,role?: string}) => Promise<DtoOrganizationAccess[]>
26
-
27
- listByGroup: (params: {group: string,page?: number,page_size?: number,access?: number}) => Promise<DtoOrganizationAccess[]>
28
-
29
- }
30
-
31
- repos: {
32
-
33
- list: (params: {page?: number,page_size?: number,search?: string,filter_type?: string,role?: string,order_by?: string,desc?: boolean}) => Promise<DtoRepos4User[]>
34
-
35
- }
36
-
37
- 'stared-repos': {
38
-
39
- list: (params: {page?: number,page_size?: number,search?: string,desc?: boolean,order_by?: string}) => Promise<DtoRepos4UserBase[]>
40
-
41
- }
42
-
43
- }
44
-
45
- users: {
46
-
47
- get: (params: {username: string}) => Promise<DtoUsersResult>
48
-
49
- avatar: {
50
-
51
- get: (params: {username: string,size: string}) => Promise<any>
52
-
53
- }
54
-
55
- followers: {
56
-
57
- list: (params: {username: string,page?: number,page_size?: number}) => Promise<DtoUserFollowResult[]>
58
-
59
- }
60
-
61
- following: {
62
-
63
- list: (params: {username: string,page?: number,page_size?: number}) => Promise<DtoUserFollowResult[]>
64
-
65
- }
66
-
67
- groups: {
68
-
69
- get: (params: {username: string,search?: string,page?: number,page_size?: number,desc?: boolean,order_by?: string}) => Promise<DtoOrganizationUnion>
70
-
71
- }
72
-
73
- 'pinned-repos': {
74
-
75
- list: (params: {username: string}) => Promise<DtoRepos4User[]>
76
-
77
- }
78
-
79
- repos: {
80
-
81
- list: (params: {username: string,search?: string,role?: string,page?: number,page_size?: number,desc?: boolean,order_by?: string}) => Promise<DtoRepos4User[]>
82
-
83
- }
84
-
85
- 'stared-repos': {
86
-
87
- list: (params: {username: string,search?: string,page?: number,page_size?: number,desc?: boolean,order_by?: string}) => Promise<DtoRepos4User[]>
88
-
89
- }
90
-
91
- }
92
-
93
- workspace: {
94
-
95
- delete: {
96
-
97
- post: (params: {request: any}) => Promise<DtoWorkspaceDeleteResult>
98
-
99
- }
100
-
101
- list: {
102
-
103
- get: (params: {branch?: string,end?: string,page?: number,pageSize?: number,slug?: string,start?: string,status?: string}) => Promise<DtoWorkspaceListResult>
104
-
105
- }
106
-
107
- }
108
-
109
- group: {
110
-
111
- get: (params: {group: string}) => Promise<DtoOrganizationAccess>
112
-
113
- avatar: {
114
-
115
- put: (params: {group: string,request: any}) => Promise<any>
116
-
117
- }
118
-
119
- 'inherit-members': {
120
-
121
- list: (params: {group: string,search?: string,role?: string,page?: number,page_size?: number}) => Promise<DtoListInheritMembers[]>
122
-
123
- }
124
-
125
- 'list-members': {
126
-
127
- list: (params: {group: string,page?: number,page_size?: number,role?: string,search?: string,names?: string,order_by?: string,desc?: boolean}) => Promise<DtoUsersWithAccessLevelInSlug[]>
128
-
129
- }
130
-
131
- logos: {
132
-
133
- put: (params: {group: string,token: string}) => Promise<any>
134
-
135
- get: (params: {group: string,size?: string}) => Promise<any>
136
-
137
- }
138
-
139
- members: {
140
-
141
- list: (params: {group: string,page?: number,page_size?: number,role?: string,search?: string}) => Promise<DtoUsersWithAccessLevelInSlug[]>
142
-
143
- 'access-level': {
144
-
145
- get: (params: {group: string,include_inherit?: boolean}) => Promise<DtoMemberAccessLevelInSlugUnion>
146
-
147
- list: (params: {group: string,username: string}) => Promise<DtoMemberAccessLevel[]>
148
-
149
- }
150
-
151
- delete: (params: {group: string,username: string}) => Promise<any>
152
-
153
- put: (params: {group: string,username: string,request: any}) => Promise<any>
154
-
155
- }
156
-
157
- 'pinned-repos': {
158
-
159
- list: (params: {group: string}) => Promise<DtoRepos4UserBase[]>
160
-
161
- put: (params: {group: string,request: any}) => Promise<DtoRepos4UserBase[]>
162
-
163
- }
164
-
165
- repos: {
166
-
167
- list: (params: {group: string,page?: number,page_size?: number,filter_type?: string,order_by?: string,desc?: boolean,descendant?: string,search?: string}) => Promise<DtoRepos4UserBase[]>
168
-
169
- post: (params: {group: string,request: any}) => Promise<any>
170
-
171
- }
172
-
173
- settings: {
174
-
175
- get: (params: {group: string}) => Promise<DtoOrganizationSettingWithParent>
176
-
177
- put: (params: {group: string,request: any}) => Promise<any>
178
-
179
- }
180
-
181
- 'sub-groups': {
182
-
183
- list: (params: {group: string,search?: string,page: number,page_size: number}) => Promise<DtoOrganizationUnion[]>
184
-
185
- }
186
-
187
- upload: {
188
-
189
- logos: {
190
-
191
- post: (params: {group: string,request: any}) => Promise<DtoUploadAssetsResponse>
192
-
193
- }
194
-
195
- }
196
-
197
- }
198
-
199
- registry: {
200
-
201
- packages: {
202
-
203
- name: {
204
-
205
- tag: {
206
-
207
- delete: (params: {registry: string,type: string,name: string,tag: string}) => Promise<any>
208
-
209
- }
210
-
211
- }
212
-
213
- }
214
-
215
- }
216
-
217
- repo: {
218
-
219
- get: (params: {repo: string}) => Promise<DtoRepos4User>
220
-
221
- build: {
222
-
223
- logs: {
224
-
225
- get: (params: {repo: string,createTime?: string,endTime?: string,event?: string,page?: number,pagesize?: number,sha?: string,sn?: string,sourceRef?: string,status?: string,targetRef?: string,userId?: string,userName?: string}) => Promise<DtoBuildLogsResult>
226
-
227
- }
228
-
229
- start: {
230
-
231
- post: (params: {repo: string,request: any}) => Promise<DtoBuildResult[]>
232
-
233
- }
234
-
235
- status: {
236
-
237
- get: (params: {repo: string,sn: string}) => Promise<DtoBuildStatusResult>
238
-
239
- }
240
-
241
- stop: {
242
-
243
- post: (params: {repo: string,sn: string}) => Promise<DtoBuildResult[]>
244
-
245
- }
246
-
247
- }
248
-
249
- 'commit-assets': {
250
-
251
- download: {
252
-
253
- get: (params: {repo: string,fileName: string}) => Promise<any>
254
-
255
- }
256
-
257
- }
258
-
259
- contributor: {
260
-
261
- trend: {
262
-
263
- list: (params: {repo: string,limit?: number,exclude_external_users?: boolean}) => Promise<WebRepoContribTrend[]>
264
-
265
- }
266
-
267
- }
268
-
269
- files: {
270
-
271
- get: (params: {repo: string,userIdKey: string,randomUUID: string,fileName: string}) => Promise<any>
272
-
273
- put: (params: {repo: string,userIdKey: string,randomUUID: string,fileName: string,token: string}) => Promise<any>
274
-
275
- }
276
-
277
- forks: {
278
-
279
- list: (params: {repo: string,page: number,page_size: number}) => Promise<DtoForks[]>
280
-
281
- post: (params: {repo: string,request: any}) => Promise<any>
282
-
283
- }
284
-
285
- git: {
286
-
287
- branches: {
288
-
289
- list: (params: {repo: string,page?: number,page_size?: number}) => Promise<ApiBranch[]>
290
-
291
- post: (params: {repo: string,create_branch_form: any}) => Promise<any>
292
-
293
- delete: (params: {repo: string,branch: string}) => Promise<any>
294
-
295
- get: (params: {repo: string,branch?: string}) => Promise<ApiBranchDetail>
296
-
297
- }
298
-
299
- 'commit-annotations-in-batch': {
300
-
301
- post: (params: {repo: string,get_commit_annotations_form: any}) => Promise<WebCommitAnnotationInBatch[]>
302
-
303
- }
304
-
305
- 'commit-annotations': {
306
-
307
- list: (params: {repo: string,sha: string}) => Promise<WebCommitAnnotation[]>
308
-
309
- put: (params: {repo: string,sha: string,put_commit_annotations_form: any}) => Promise<any>
310
-
311
- delete: (params: {repo: string,sha: string,key: string}) => Promise<any>
312
-
313
- }
314
-
315
- 'commit-assets': {
316
-
317
- list: (params: {repo: string,sha1: string}) => Promise<ApiCommitAsset[]>
318
-
319
- 'asset-upload-confirmation': {
320
-
321
- post: (params: {repo: string,sha1: number,token: string,asset_path: string}) => Promise<any>
322
-
323
- }
324
-
325
- 'asset-upload-url': {
326
-
327
- post: (params: {repo: string,sha1: number,create_commit_asset_upload_url_form: any}) => Promise<any>
328
-
329
- }
330
-
331
- delete: (params: {repo: string,sha1: string,asset_id: number}) => Promise<any>
332
-
333
- }
334
-
335
- 'commit-statuses': {
336
-
337
- list: (params: {repo: string,sha: string}) => Promise<ApiCommitStatus[]>
338
-
339
- }
340
-
341
- commits: {
342
-
343
- list: (params: {repo: string,sha?: string,author?: string,committer?: string,since?: string,until?: string,page?: number,page_size?: number}) => Promise<ApiCommit[]>
344
-
345
- get: (params: {repo: string,ref: string}) => Promise<ApiCommit>
346
-
347
- }
348
-
349
- compare: {
350
-
351
- get: (params: {repo: string,base_head: string}) => Promise<ApiCompareResponse>
352
-
353
- }
354
-
355
- contents: {
356
-
357
- get: (params: {repo: string,file_path: string,ref?: string}) => Promise<ApiContent>
358
-
359
- }
360
-
361
- head: {
362
-
363
- get: (params: {repo: string}) => Promise<OpenapiHeadRef>
364
-
365
- }
366
-
367
- 'tag-annotations': {
368
-
369
- delete: (params: {repo: string,tag_with_key: string}) => Promise<any>
370
-
371
- list: (params: {repo: string,tag: string}) => Promise<WebTagAnnotation[]>
372
-
373
- put: (params: {repo: string,tag: string,put_tag_annotations_form: any}) => Promise<any>
374
-
375
- }
376
-
377
- tags: {
378
-
379
- list: (params: {repo: string,page?: number,page_size?: number}) => Promise<ApiTag[]>
380
-
381
- delete: (params: {repo: string,tag: string}) => Promise<any>
382
-
383
- get: (params: {repo: string,tag: string}) => Promise<ApiTag>
384
-
385
- }
386
-
387
- }
388
-
389
- imgs: {
390
-
391
- get: (params: {repo: string,userIdKey: string,fileName: string}) => Promise<any>
392
-
393
- put: (params: {repo: string,userIdKey: string,fileName: string,token: string}) => Promise<any>
394
-
395
- }
396
-
397
- 'inherit-members': {
398
-
399
- list: (params: {repo: string,search?: string,role?: string,page?: number,page_size?: number}) => Promise<DtoListInheritMembers[]>
400
-
401
- }
402
-
403
- issues: {
404
-
405
- list: (params: {repo: string,page?: number,page_size?: number,state?: string,keyword?: string,priority?: string,labels?: string,authors?: string,assignees?: string,updated_time_begin?: string,updated_time_end?: string,order_by?: string}) => Promise<ApiIssue[]>
406
-
407
- post: (params: {repo: string,post_issue_form: any}) => Promise<any>
408
-
409
- get: (params: {repo: string,number: number}) => Promise<ApiIssueDetail>
410
-
411
- patch: (params: {repo: string,number: number,patch_issue_form: any}) => Promise<ApiIssueDetail>
412
-
413
- comments: {
414
-
415
- list: (params: {repo: string,number: number,page?: number,page_size?: number}) => Promise<ApiIssueComment[]>
416
-
417
- post: (params: {repo: string,number: number,post_issue_comment_form: any}) => Promise<any>
418
-
419
- get: (params: {repo: string,number: number,comment_id: number}) => Promise<ApiIssueComment>
420
-
421
- patch: (params: {repo: string,number: number,comment_id: number,patch_issue_comment_form: any}) => Promise<ApiIssueComment>
422
-
423
- }
424
-
425
- labels: {
426
-
427
- delete: (params: {repo: string,number: number}) => Promise<any>
428
-
429
- deleteByName: (params: {repo: string,number: number,name: string}) => Promise<ApiLabel>
430
-
431
- }
432
-
433
- }
434
-
435
- labels: {
436
-
437
- list: (params: {repo: string,page?: number,page_size?: number,keyword?: string}) => Promise<ApiLabel[]>
438
-
439
- post: (params: {repo: string,post_label_form: any}) => Promise<any>
440
-
441
- delete: (params: {repo: string,name: string}) => Promise<any>
442
-
443
- patch: (params: {repo: string,name: string,patch_label_form: any}) => Promise<ApiLabel>
444
-
445
- }
446
-
447
- 'list-members': {
448
-
449
- list: (params: {repo: string,page?: number,page_size?: number,role?: string,search?: string,names?: string,order_by?: string,desc?: boolean}) => Promise<DtoUsersWithAccessLevelInSlug[]>
450
-
451
- }
452
-
453
- members: {
454
-
455
- list: (params: {repo: string,page?: number,page_size?: number,role?: string,search?: string}) => Promise<DtoUsersWithAccessLevelInSlug[]>
456
-
457
- 'access-level': {
458
-
459
- get: (params: {repo: string,include_inherit?: boolean}) => Promise<DtoMemberAccessLevelInSlugUnion>
460
-
461
- list: (params: {repo: string,username: string}) => Promise<DtoMemberAccessLevel[]>
462
-
463
- }
464
-
465
- delete: (params: {repo: string,username: string}) => Promise<any>
466
-
467
- put: (params: {repo: string,username: string,request: any}) => Promise<any>
468
-
469
- }
470
-
471
- 'outside-collaborators': {
472
-
473
- list: (params: {repo: string,page?: number,page_size?: number,role?: string,search?: string}) => Promise<DtoOutsideCollaboratorInRepo[]>
474
-
475
- delete: (params: {repo: string,username: string}) => Promise<any>
476
-
477
- put: (params: {repo: string,username: string,role: string}) => Promise<any>
478
-
479
- }
480
-
481
- pulls: {
482
-
483
- list: (params: {repo: string,page?: number,page_size?: number,state?: string,authors?: string,reviewers?: string,assignees?: string}) => Promise<ApiPullRequest[]>
484
-
485
- post: (params: {repo: string,post_pull_form: any}) => Promise<any>
486
-
487
- get: (params: {repo: string,number: number}) => Promise<ApiPull>
488
-
489
- patch: (params: {repo: string,number: number,update_pull_request_form: any}) => Promise<ApiPull>
490
-
491
- comments: {
492
-
493
- list: (params: {repo: string,page?: number,page_size?: number}) => Promise<ApiPullRequestComment[]>
494
-
495
- post: (params: {repo: string,number: number,post_pull_comment_form: any}) => Promise<any>
496
-
497
- }
498
-
499
- labels: {
500
-
501
- delete: (params: {repo: string,number: number}) => Promise<any>
502
-
503
- list: (params: {repo: string,number: number,page?: number,page_size?: number}) => Promise<ApiLabel[]>
504
-
505
- post: (params: {repo: string,number: number,post_pull_labels_form: any}) => Promise<ApiLabel>
506
-
507
- put: (params: {repo: string,number: number,put_pull_labels_form: any}) => Promise<ApiLabel>
508
-
509
- deleteByName: (params: {repo: string,number: number,name: string}) => Promise<ApiLabel>
510
-
511
- }
512
-
513
- merge: {
514
-
515
- put: (params: {repo: string,number: number,merge_pull_request_form: any}) => Promise<ApiMergePullResponse>
516
-
517
- }
518
-
519
- reviews: {
520
-
521
- post: (params: {repo: string,number: number,post_pull_review_form: any}) => Promise<any>
522
-
523
- }
524
-
525
- }
526
-
527
- releases: {
528
-
529
- list: (params: {repo: string,page?: number,page_size?: number}) => Promise<ApiRelease[]>
530
-
531
- post: (params: {repo: string,create_release_form: any}) => Promise<any>
532
-
533
- download: {
534
-
535
- get: (params: {repo: string,fileName: string}) => Promise<any>
536
-
537
- }
538
-
539
- tags: {
540
-
541
- get: (params: {repo: string,tag: string}) => Promise<ApiRelease>
542
-
543
- }
544
-
545
- delete: (params: {repo: string,release_id: number}) => Promise<any>
546
-
547
- get: (params: {repo: string,release_id: number}) => Promise<ApiRelease>
548
-
549
- patch: (params: {repo: string,release_id: number,patch_release_form: any}) => Promise<any>
550
-
551
- 'asset-upload-confirmation': {
552
-
553
- post: (params: {repo: string,release_id: number,token: string,asset_path: string}) => Promise<any>
554
-
555
- }
556
-
557
- 'asset-upload-url': {
558
-
559
- post: (params: {repo: string,release_id: number,create_release_asset_upload_url_form: any}) => Promise<any>
560
-
561
- }
562
-
563
- assets: {
564
-
565
- delete: (params: {repo: string,release_id: number,asset_id: number}) => Promise<any>
566
-
567
- get: (params: {repo: string,release_id: number,asset_id: number}) => Promise<ApiReleaseAsset>
568
-
569
- }
570
-
571
- }
572
-
573
- settings: {
574
-
575
- 'branch-protections': {
576
-
577
- list: (params: {repo: string}) => Promise<ApiBranchProtection[]>
578
-
579
- post: (params: {repo: string,branch_protection_form: any}) => Promise<any>
580
-
581
- delete: (params: {repo: string,id: string}) => Promise<any>
582
-
583
- get: (params: {repo: string,id: string}) => Promise<ApiBranchProtection>
584
-
585
- patch: (params: {repo: string,id: string,branch_protection_form: any}) => Promise<any>
586
-
587
- }
588
-
589
- 'cloud-native-build': {
590
-
591
- get: (params: {repo: string}) => Promise<ApiPipelineSettings>
592
-
593
- put: (params: {repo: string,pipeline_form: any}) => Promise<any>
594
-
595
- }
596
-
597
- 'pull-request': {
598
-
599
- get: (params: {repo: string}) => Promise<ApiPullRequestSettings>
600
-
601
- put: (params: {repo: string,pull_request_form: any}) => Promise<any>
602
-
603
- }
604
-
605
- 'push-limit': {
606
-
607
- get: (params: {repo: string}) => Promise<ApiPushLimitSettings>
608
-
609
- put: (params: {repo: string,push_limit_form: any}) => Promise<any>
610
-
611
- }
612
-
613
- }
614
-
615
- stars: {
616
-
617
- get: (params: {repo: string,filter_type: string,page: number,page_size: number}) => Promise<DtoRepoStarUsers>
618
-
619
- }
620
-
621
- 'top-activity-users': {
622
-
623
- list: (params: {repo: string,top?: number}) => Promise<DtoUsersResult[]>
624
-
625
- }
626
-
627
- upload: {
628
-
629
- files: {
630
-
631
- post: (params: {repo: string,request: any}) => Promise<DtoUploadAssetsResponse>
632
-
633
- }
634
-
635
- imgs: {
636
-
637
- post: (params: {repo: string,request: any}) => Promise<DtoUploadAssetsResponse>
638
-
639
- }
640
-
641
- releases: {
642
-
643
- post: (params: {repo: string,tagName: string,request: any}) => Promise<DtoUploadAssetsResponse>
644
-
645
- }
646
-
647
- }
648
-
649
- workspace: {
650
-
651
- detail: {
652
-
653
- get: (params: {repo: string,sn: string}) => Promise<DtoWorkspaceDetailResult>
654
-
655
- }
656
-
657
- }
658
-
659
- }
660
-
661
- }
662
-
@@ -1,7 +0,0 @@
1
- <% _.keys(definitions, function(t) { %>
2
- type <%= t %> = {
3
- <% _.keys(definitions[t].properties, function(p){ %>
4
-
5
- <% }) %>
6
- }
7
- <% }); %>