update
This commit is contained in:
@@ -1,16 +1,12 @@
|
||||
import { CNBCore, CNBCoreOptions, RequestOptions, Result } from "../cnb-core.ts";
|
||||
type AiOptions = CNBCoreOptions<{
|
||||
group?: string;
|
||||
}>
|
||||
|
||||
class AiBase extends CNBCore {
|
||||
group: string;
|
||||
constructor(options: AiOptions) {
|
||||
constructor(options: CNBCoreOptions) {
|
||||
super({ token: options.token, cookie: options.cookie });
|
||||
this.group = options.group || '';
|
||||
}
|
||||
autoPr(repo: string, data: { body: string, branch?: string, title: string }): Promise<Result<any>> {
|
||||
const group = this.group || '';
|
||||
const url = `/${group}/${repo}/-/build/ai/auto-pr`;
|
||||
const url = `/${repo}/-/build/ai/auto-pr`;
|
||||
const postData = {
|
||||
...data,
|
||||
branch: data.branch || 'refs/heads/main',
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
import { CNBCore, CNBCoreOptions, RequestOptions, Result } from "../cnb-core.ts";
|
||||
|
||||
type Options = CNBCoreOptions<{
|
||||
group?: string;
|
||||
}>
|
||||
|
||||
export class Build extends CNBCore {
|
||||
group: string;
|
||||
constructor(options: Options) {
|
||||
constructor(options: CNBCoreOptions ) {
|
||||
super({ token: options.token, cookie: options.cookie });
|
||||
this.group = options.group || '';
|
||||
}
|
||||
startBuild(repo: string, data: StartBuildData): Promise<any> {
|
||||
const group = this.group || '';
|
||||
const url = `/${group}/${repo}/-/build/start`;
|
||||
const url = `/${repo}/-/build/start`;
|
||||
let postData: StartBuildData = {
|
||||
...data,
|
||||
branch: data.branch || 'main',
|
||||
|
||||
@@ -4,6 +4,7 @@ export type CNBCoreOptions<T = {}> = {
|
||||
* 对 cnb 界面操作定制模块功能时需要传入 cookie
|
||||
*/
|
||||
cookie?: string;
|
||||
cnb?: CNBCore;
|
||||
} & T;
|
||||
|
||||
export type RequestOptions = {
|
||||
@@ -18,11 +19,19 @@ export type RequestOptions = {
|
||||
};
|
||||
export class CNBCore {
|
||||
baseURL = 'https://api.cnb.cool';
|
||||
token: string;
|
||||
cookie?: string;
|
||||
public token: string;
|
||||
public cookie?: string;
|
||||
constructor(options: CNBCoreOptions) {
|
||||
this.token = options.token;
|
||||
this.cookie = options.cookie;
|
||||
if (options?.cnb) {
|
||||
if (!options.token) {
|
||||
this.token = options.cnb.token;
|
||||
}
|
||||
if (!options.cookie) {
|
||||
this.cookie = options.cnb.cookie;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async request({ url, method = 'GET', data, params, headers, body, useCookie, useOrigin }: RequestOptions): Promise<any> {
|
||||
|
||||
47
src/index.ts
47
src/index.ts
@@ -15,17 +15,54 @@ export class CNB extends CNBCore {
|
||||
repo!: Repo;
|
||||
user!: User;
|
||||
build!: Build;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
issue!: Issue;
|
||||
mission!: Mission;
|
||||
group!: string;
|
||||
>>>>>>> 84efdce (update)
|
||||
constructor(options: CNBOptions) {
|
||||
super({ token: options.token, cookie: options.cookie });
|
||||
super({ token: options.token, cookie: options.cookie, cnb: options.cnb });
|
||||
this.init(options);
|
||||
}
|
||||
init(options: CNBOptions) {
|
||||
init(cnbOptions?: CNBOptions) {
|
||||
const token = this.token;
|
||||
const cookie = this.cookie;
|
||||
const options = { token, cookie };
|
||||
this.workspace = new Workspace(options.token);
|
||||
const group = options.group || '';
|
||||
this.knowledgeBase = new KnowledgeBase({ group: group, token: options.token, cookie: options.cookie });
|
||||
this.repo = new Repo({ group: group, token: options.token, cookie: options.cookie });
|
||||
const group = cnbOptions?.group || '';
|
||||
this.knowledgeBase = new KnowledgeBase({ token: options.token, cookie: options.cookie });
|
||||
this.repo = new Repo({ token: options.token, cookie: options.cookie });
|
||||
this.user = new User({ token: options.token, cookie: options.cookie });
|
||||
<<<<<<< HEAD
|
||||
this.build = new Build({ group: group, token: options.token, cookie: options.cookie });
|
||||
=======
|
||||
this.build = new Build({ token: options.token, cookie: options.cookie });
|
||||
this.issue = new Issue({ token: options.token, cookie: options.cookie });
|
||||
this.mission = new Mission({ token: options.token, cookie: options.cookie });
|
||||
this.group = group;
|
||||
}
|
||||
setGroup(group: string) {
|
||||
this.group = group;
|
||||
}
|
||||
setToken(token: string) {
|
||||
this.token = token;
|
||||
this.knowledgeBase.token = token;
|
||||
this.repo.token = token;
|
||||
this.user.token = token;
|
||||
this.build.token = token;
|
||||
this.issue.token = token;
|
||||
this.mission.token = token;
|
||||
}
|
||||
setCookie(cookie: string) {
|
||||
this.cookie = cookie;
|
||||
this.knowledgeBase.cookie = cookie;
|
||||
this.repo.cookie = cookie;
|
||||
this.user.cookie = cookie;
|
||||
this.build.cookie = cookie;
|
||||
this.issue.cookie = cookie;
|
||||
this.mission.cookie = cookie;
|
||||
>>>>>>> 84efdce (update)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
121
src/issue/index.ts
Normal file
121
src/issue/index.ts
Normal file
@@ -0,0 +1,121 @@
|
||||
import { CNBCore, CNBCoreOptions, RequestOptions, Result } from "../cnb-core.ts";
|
||||
|
||||
export type IssueAssignee = {
|
||||
nickname: string;
|
||||
username: string;
|
||||
};
|
||||
|
||||
export type IssueLabel = {
|
||||
color: string;
|
||||
description: string;
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
export type IssueState = 'open' | 'closed';
|
||||
|
||||
export type IssueAuthor = {
|
||||
name: string;
|
||||
body: string;
|
||||
comment_count: number;
|
||||
created_at: string;
|
||||
ended_at: string;
|
||||
};
|
||||
|
||||
export type IssueItem = {
|
||||
assignees: IssueAssignee[];
|
||||
author: IssueAuthor;
|
||||
labels: IssueLabel[];
|
||||
|
||||
last_acted_at: string;
|
||||
number: string;
|
||||
priority: string;
|
||||
started_at: string;
|
||||
state: string;
|
||||
state_reason: string;
|
||||
title: string;
|
||||
updated_at: string;
|
||||
};
|
||||
export class Issue extends CNBCore {
|
||||
constructor(options: CNBCoreOptions) {
|
||||
super({ token: options.token, cookie: options.cookie });
|
||||
}
|
||||
|
||||
createIssue(repo: string, data: Partial<IssueItem>): Promise<any> {
|
||||
const url = `/${repo}/-/issues`;
|
||||
let postData = {
|
||||
...data,
|
||||
};
|
||||
return this.post({ url, data: postData });
|
||||
}
|
||||
updateIssue(repo: string, issueNumber: string | number, data: Partial<IssueItem>): Promise<any> {
|
||||
const url = `/${repo}/-/issues/${issueNumber}`;
|
||||
let postData = {
|
||||
...data,
|
||||
};
|
||||
return this.patch({ url, data: postData });
|
||||
}
|
||||
getItem(repo: string, issueNumber: string | number): Promise<Result<IssueItem>> {
|
||||
const url = `/${repo}/-/issues/${issueNumber}`;
|
||||
return this.get({
|
||||
url,
|
||||
headers: {
|
||||
'Accept': 'application/vnd.cnb.api+json',
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getList(repo: string, params?: Partial<GetListParams>): Promise<Result<IssueItem[]>> {
|
||||
const url = `/${repo}/-/issues`;
|
||||
return this.get({
|
||||
url,
|
||||
params,
|
||||
headers: {
|
||||
'Accept': 'application/vnd.cnb.api+json',
|
||||
}
|
||||
});
|
||||
}
|
||||
getCommentList(repo: string, issueNumber: string | number): Promise<any> {
|
||||
const url = `/${repo}/-/issues/${issueNumber}/comments`;
|
||||
return this.get({
|
||||
url,
|
||||
});
|
||||
}
|
||||
setIssueProperty(repo: string, issueNumber: string | number, properties: { [key: string]: any }[]): Promise<any> {
|
||||
const url = `/${repo}/-/issues/${issueNumber}/property`;
|
||||
let postData = {
|
||||
properties: properties,
|
||||
};
|
||||
return this.post({ url, data: postData });
|
||||
}
|
||||
}
|
||||
|
||||
type GetListParams = {
|
||||
/** 问题指派人名称,例如: 张三, 李四, -; - 表示不指派给任何人 */
|
||||
assignees?: string;
|
||||
/** 问题作者名称,例如: 张三, 李四 */
|
||||
authors?: string;
|
||||
/** 问题关闭时间过滤-开始,例如: 2022-01-31 */
|
||||
close_time_begin?: string;
|
||||
/** 问题关闭时间过滤-结束,例如: 2022-01-31 */
|
||||
close_time_end?: string;
|
||||
/** 问题搜索关键词 */
|
||||
keyword?: string;
|
||||
/** 问题标签,例如: git, bug, feature */
|
||||
labels?: string;
|
||||
/** 问题标签操作符,例如: contains_any, contains_all,默认: contains_any */
|
||||
labels_operator?: string;
|
||||
/** 问题排序,例如: created_at, -updated_at, reference_count;'-' 前缀表示降序 */
|
||||
order_by?: string;
|
||||
/** 分页页码。如果值小于 1,将自动调整为 1,默认: 1 */
|
||||
page?: number;
|
||||
/** 分页每页大小。如果值大于 100,将自动调整为 100,默认: 30 */
|
||||
page_size?: number;
|
||||
/** 问题优先级,例如: -1P, -2P, P0, P1, P2, P3 */
|
||||
priority?: string;
|
||||
/** 问题状态:open 或 closed */
|
||||
state?: string;
|
||||
/** 问题更新时间过滤-开始,例如: 2022-01-31 */
|
||||
updated_time_begin?: string;
|
||||
/** 问题更新时间过滤-结束,例如: 2022-01-31 */
|
||||
updated_time_end?: string;
|
||||
}
|
||||
@@ -1,13 +1,8 @@
|
||||
import { CNBCore, CNBCoreOptions, RequestOptions, Result } from "../cnb-core.ts";
|
||||
import { CNBCore, CNBCoreOptions, Result } from "../cnb-core.ts";
|
||||
|
||||
type RepoOptions = CNBCoreOptions<{
|
||||
group?: string;
|
||||
}>
|
||||
export class KnowledgeBase extends CNBCore {
|
||||
group: string;
|
||||
constructor(options: RepoOptions) {
|
||||
constructor(options: CNBCoreOptions) {
|
||||
super({ token: options.token, cookie: options.cookie });
|
||||
this.group = options.group || '';
|
||||
}
|
||||
|
||||
queryKnowledgeBase(repo: string, data: {
|
||||
@@ -16,28 +11,24 @@ export class KnowledgeBase extends CNBCore {
|
||||
top_k?: number,
|
||||
metadata_filtering_conditions?: MetadataFilteringConditions
|
||||
}): Promise<any> {
|
||||
const group = this.group || '';
|
||||
const url = `/${group}/${repo}/-/knowledge/base/query`;
|
||||
const url = `/${repo}/-/knowledge/base/query`;
|
||||
let postData = {
|
||||
query: data.query,
|
||||
};
|
||||
return this.post({ url, data: postData });
|
||||
}
|
||||
getEmbeddingModels(repo: string): Promise<Result<Array<{ name: string, dimensions: number }>>> {
|
||||
const group = this.group || '';
|
||||
const url = `/${group}/${repo}/-/knowledge/embedding/models`;
|
||||
const url = `/${repo}/-/knowledge/embedding/models`;
|
||||
// bg3-m3 1024
|
||||
// hunyuan 1024
|
||||
return this.get({ url });
|
||||
}
|
||||
getBase(repo: string): Promise<Result<any>> {
|
||||
const group = this.group || '';
|
||||
const url = `/${group}/${repo}/-/knowledge/base`;
|
||||
const url = `/${repo}/-/knowledge/base`;
|
||||
return this.get({ url });
|
||||
}
|
||||
deleteBase(repo: string): Promise<Result<any>> {
|
||||
const group = this.group || '';
|
||||
const url = `/${group}/${repo}/-/knowledge/base`;
|
||||
const url = `/${repo}/-/knowledge/base`;
|
||||
return this.request({ url, method: 'DELETE' });
|
||||
}
|
||||
}
|
||||
|
||||
190
src/mission/index.ts
Normal file
190
src/mission/index.ts
Normal file
@@ -0,0 +1,190 @@
|
||||
import { CNBCore, CNBCoreOptions, RequestOptions, Result } from "../cnb-core.ts";
|
||||
|
||||
export class Mission extends CNBCore {
|
||||
constructor(options: CNBCoreOptions) {
|
||||
super({ token: options.token, cookie: options.cookie });
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询组织下用户有权限查看的任务集
|
||||
* @param params 查询参数
|
||||
* @returns 任务集列表
|
||||
*/
|
||||
getMissions(group: string, params?: GetMissionsParams): Promise<Result<Missions4User[]>> {
|
||||
const url = `/${group}/-/missions`;
|
||||
return this.get({
|
||||
url,
|
||||
params: {
|
||||
page: 1,
|
||||
page_size: 10,
|
||||
...params,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建任务集
|
||||
* @param data 创建任务集数据
|
||||
* @returns 创建结果
|
||||
*/
|
||||
createMission(repo: string, data: CreateMissionData): Promise<Result<any>> {
|
||||
const url = `/${repo}/-/missions`;
|
||||
return this.post({ url, data });
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除任务集
|
||||
* @param mission 任务集路径
|
||||
* @param identityTicket 微信身份验证票据
|
||||
* @returns 删除结果
|
||||
*/
|
||||
deleteMission(mission: string, identityTicket?: string): Promise<Result<any>> {
|
||||
const url = `/${mission}`;
|
||||
return this.delete({
|
||||
url,
|
||||
headers: identityTicket ? { 'x-cnb-identity-ticket': identityTicket } : undefined,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务集视图配置
|
||||
* @param mission 任务集 slug
|
||||
* @param viewId 视图 ID
|
||||
* @returns 视图配置
|
||||
*/
|
||||
getMissionViewConfig(mission: string, viewId: string): Promise<Result<MissionViewConfig>> {
|
||||
const url = `/${mission}/-/mission/view`;
|
||||
return this.get({
|
||||
url,
|
||||
params: { id: viewId },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置任务集视图配置
|
||||
* @param mission 任务集 slug
|
||||
* @param config 视图配置
|
||||
* @returns 设置结果
|
||||
*/
|
||||
setMissionViewConfig(mission: string, config: MissionViewConfig): Promise<Result<any>> {
|
||||
const url = `/${mission}/-/mission/view`;
|
||||
return this.post({ url, data: config });
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务集视图列表
|
||||
* @param mission 任务集 slug
|
||||
* @returns 视图列表
|
||||
*/
|
||||
getMissionViewList(mission: string): Promise<Result<MissionView[]>> {
|
||||
const url = `/${mission}/-/mission/view-list`;
|
||||
return this.get({
|
||||
url,
|
||||
headers: {
|
||||
'Accept': 'application/vnd.cnb.api+json',
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加或修改任务集视图
|
||||
* @param mission 任务集 slug
|
||||
* @param view 视图数据
|
||||
* @returns 操作结果
|
||||
*/
|
||||
putMissionView(mission: string, view: MissionView): Promise<Result<any>> {
|
||||
const url = `/${mission}/-/mission/view-list`;
|
||||
return this.put({ url, data: view });
|
||||
}
|
||||
|
||||
/**
|
||||
* 排序任务集视图
|
||||
* @param mission 任务集 slug
|
||||
* @param data 排序数据
|
||||
* @returns 操作结果
|
||||
*/
|
||||
sortMissionViews(mission: string, data: MissionPostViewReq): Promise<Result<any>> {
|
||||
const url = `/${mission}/-/mission/view-list`;
|
||||
return this.post({ url, data });
|
||||
}
|
||||
|
||||
/**
|
||||
* 改变任务集可见性
|
||||
* @param mission 任务集路径
|
||||
* @param visibility 可见性 (Private 或 Public)
|
||||
* @returns 操作结果
|
||||
*/
|
||||
setVisibility(mission: string, visibility: 'Private' | 'Public'): Promise<Result<any>> {
|
||||
const url = `/${mission}/-/settings/set_visibility`;
|
||||
return this.post({
|
||||
url,
|
||||
params: { visibility },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 类型定义 ====================
|
||||
|
||||
type GetMissionsParams = {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
filter_type?: 'private' | 'public';
|
||||
order_by?: 'created_at' | 'name';
|
||||
desc?: boolean;
|
||||
descendant?: 'all' | 'sub' | 'grand';
|
||||
search?: string;
|
||||
};
|
||||
|
||||
type CreateMissionData = {
|
||||
name: string;
|
||||
description?: string;
|
||||
visibility?: 'Private' | 'Public';
|
||||
};
|
||||
|
||||
type Missions4User = {
|
||||
id: string;
|
||||
name: string;
|
||||
slug_path: string;
|
||||
description: string;
|
||||
visibility: 'Private' | 'Public';
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
web_url: string;
|
||||
};
|
||||
|
||||
type MissionView = {
|
||||
id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
config?: MissionViewConfig;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
};
|
||||
|
||||
type MissionViewConfig = {
|
||||
id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
columns?: MissionViewColumn[];
|
||||
filters?: MissionViewFilter[];
|
||||
sort_by?: string;
|
||||
sort_order?: 'asc' | 'desc';
|
||||
};
|
||||
|
||||
type MissionViewColumn = {
|
||||
key: string;
|
||||
label: string;
|
||||
width?: number;
|
||||
visible?: boolean;
|
||||
sortable?: boolean;
|
||||
};
|
||||
|
||||
type MissionViewFilter = {
|
||||
key: string;
|
||||
operator?: 'eq' | 'ne' | 'contains' | 'gt' | 'lt' | 'gte' | 'lte';
|
||||
value?: any;
|
||||
};
|
||||
|
||||
type MissionPostViewReq = {
|
||||
view_ids: string[];
|
||||
};
|
||||
@@ -1,13 +1,8 @@
|
||||
import { CNBCore, CNBCoreOptions, RequestOptions, Result } from "../cnb-core.ts";
|
||||
|
||||
type RepoOptions = CNBCoreOptions<{
|
||||
group?: string;
|
||||
}>
|
||||
export class Repo extends CNBCore {
|
||||
group: string;
|
||||
constructor(options: RepoOptions) {
|
||||
constructor(options: CNBCoreOptions) {
|
||||
super({ token: options.token, cookie: options.cookie });
|
||||
this.group = options.group || '';
|
||||
}
|
||||
/**
|
||||
* 创建代码仓库
|
||||
@@ -15,8 +10,7 @@ export class Repo extends CNBCore {
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
createRepo(data: CreateRepoData): Promise<any> {
|
||||
const group = this.group || '';
|
||||
createRepo(group: string, data: CreateRepoData): Promise<any> {
|
||||
const url = `/${group}/-/repos`;
|
||||
let postData: CreateRepoData = {
|
||||
...data,
|
||||
@@ -28,7 +22,6 @@ export class Repo extends CNBCore {
|
||||
return this.post({ url, data: postData });
|
||||
}
|
||||
async createCommit(repo: string, data: CreateCommitData): Promise<any> {
|
||||
const group = this.group || '';
|
||||
const commitList = await this.getCommitList(repo, {
|
||||
page: 1,
|
||||
page_size: 1,
|
||||
@@ -40,7 +33,7 @@ export class Repo extends CNBCore {
|
||||
if (!data.parent_commit_sha && preCommitSha) {
|
||||
data.parent_commit_sha = preCommitSha;
|
||||
}
|
||||
const url = `https://cnb.cool/${group}/${repo}/-/git/commits`;
|
||||
const url = `https://cnb.cool/${repo}/-/git/commits`;
|
||||
const postData: CreateCommitData = {
|
||||
...data,
|
||||
base_branch: data.base_branch || 'refs/heads/main',
|
||||
@@ -56,8 +49,7 @@ export class Repo extends CNBCore {
|
||||
return this.post({ url, data: postData, useCookie: true, });
|
||||
}
|
||||
createBlobs(repo: string, data: { content: string, encoding?: 'utf-8' | 'base64' }): Promise<any> {
|
||||
const group = this.group || '';
|
||||
const url = `/${group}/${repo}/-/git/blobs`;
|
||||
const url = `/${repo}/-/git/blobs`;
|
||||
const postData = {
|
||||
content: data.content,
|
||||
encoding: data.encoding || 'utf-8',
|
||||
@@ -65,13 +57,11 @@ export class Repo extends CNBCore {
|
||||
return this.post({ url, data: postData });
|
||||
}
|
||||
uploadFiles(repo: string, data: { ext?: any, name?: string, path?: string, size?: number }): Promise<any> {
|
||||
const group = this.group || '';
|
||||
const url = `/${group}/${repo}/-/upload/files`
|
||||
const url = `/${repo}/-/upload/files`
|
||||
return this.post({ url, data });
|
||||
}
|
||||
getCommitList(repo: string, params: { author?: string, commiter?: string, page?: number, page_size?: number, sha?: string, since?: string, until?: string }, opts?: RequestOptions): Promise<any> {
|
||||
const group = this.group || '';
|
||||
const url = `/${group}/${repo}/-/git/commits`;
|
||||
const url = `/${repo}/-/git/commits`;
|
||||
return this.get({ url, params, ...opts });
|
||||
}
|
||||
getRepoList(params: {
|
||||
|
||||
@@ -1,21 +1,29 @@
|
||||
import { CNBCore, CNBCoreOptions } from "../cnb-core.ts";
|
||||
|
||||
import { Result } from "@kevisual/query";
|
||||
export class User extends CNBCore {
|
||||
constructor(options: CNBCoreOptions<{}>) {
|
||||
super({ token: options.token, cookie: options.cookie });
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户信息
|
||||
* @returns
|
||||
* 获取当前用户信息,使用 Cookie 认证
|
||||
* @returns
|
||||
*/
|
||||
getCurrentUser(): Promise<any> {
|
||||
getCurrentUser(): Promise<Result<UserInfo>> {
|
||||
const url = `https://cnb.cool/user`;
|
||||
return this.get({
|
||||
url,
|
||||
useCookie: true,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 使用 Token 获取用户信息
|
||||
* @returns
|
||||
*/
|
||||
getUser(): Promise<Result<UserInfo>> {
|
||||
const url = '/user';
|
||||
return this.get({ url });
|
||||
}
|
||||
createAccessToken(data?: { description?: string, scope?: string }): Promise<AccessTokenResponse> {
|
||||
const scope = data?.scope || 'mission-manage:rw,mission-delete:rw,group-delete:rw,group-manage:rw,group-resource:rw,account-engage:rw,account-email:r,account-profile:rw,registry-delete:rw,registry-manage:rw,registry-package-delete:rw,registry-package:rw,repo-security:r,repo-delete:rw,repo-manage:rw,repo-basic-info:r,repo-cnb-detail:rw,repo-cnb-history:r,repo-cnb-trigger:rw,repo-commit-status:rw,repo-contents:rw,repo-notes:rw,repo-issue:rw,repo-pr:rw,repo-code:rw'
|
||||
const url = 'https://cnb.cool/user/personal_access_tokens'
|
||||
@@ -52,4 +60,57 @@ export class User extends CNBCore {
|
||||
type AccessTokenResponse = {
|
||||
token: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
type UserInfo = {
|
||||
id: string;
|
||||
username: string;
|
||||
nickname: string;
|
||||
type: number;
|
||||
verified: number;
|
||||
verified_expire_in: string;
|
||||
created_at: string;
|
||||
freeze: boolean;
|
||||
locked: boolean;
|
||||
avatar: string;
|
||||
email: string;
|
||||
next_updated_name_at: string;
|
||||
updated_name_at: string;
|
||||
updated_nick_at: string;
|
||||
editable: {
|
||||
avatar: boolean;
|
||||
email: boolean;
|
||||
logoff: boolean;
|
||||
nickname: boolean;
|
||||
'sync-data': boolean;
|
||||
username: boolean;
|
||||
};
|
||||
language: string;
|
||||
appearance: string;
|
||||
gender: number;
|
||||
bio: string;
|
||||
company: string;
|
||||
location: string;
|
||||
site: string;
|
||||
address: string;
|
||||
wechat_mp: string;
|
||||
wechat_mp_qrcode: string;
|
||||
appreciate_status: number;
|
||||
follow_count: number;
|
||||
follower_count: number;
|
||||
reward_count: number;
|
||||
reward_amount: number;
|
||||
stars_count: number;
|
||||
group_count: number;
|
||||
repo_count: number;
|
||||
mission_count: number;
|
||||
registry_count: number;
|
||||
public_repo_count: number;
|
||||
public_mission_count: number;
|
||||
public_registry_count: number;
|
||||
follow_repo_count: number;
|
||||
follow_mission_count: number;
|
||||
readme_repo_path: string;
|
||||
last_login_at: string;
|
||||
last_login_ip: string;
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
* @createdAt 2025-12-04
|
||||
*/
|
||||
|
||||
import { Result } from "@kevisual/query/query";
|
||||
import { CNBCore } from "./cnb-core.ts";
|
||||
|
||||
/**
|
||||
@@ -75,8 +76,6 @@ export class Workspace extends CNBCore {
|
||||
return this.post({ url: '/workspace/stop', data });
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据流水线 SN 查询云原生开发访问地址
|
||||
* @param repo 仓库路径,例如:groupname/reponame
|
||||
@@ -102,7 +101,7 @@ export class Workspace extends CNBCore {
|
||||
* @param params 启动参数
|
||||
* @returns 返回启动结果,包含以下字段:
|
||||
*/
|
||||
async startWorkspace(repo: string, params: { branch?: string; ref?: string }): Promise<{
|
||||
async startWorkspace(repo: string, params: { branch?: string; ref?: string }): Promise<Result<{
|
||||
/** 仅新创建开发环境时返回,表示创建开发环境的流水线日志地址 */
|
||||
buildLogUrl?: string;
|
||||
/** 仅新创建开发环境时返回,表示创建开发环境的提示信息 */
|
||||
@@ -111,7 +110,7 @@ export class Workspace extends CNBCore {
|
||||
sn?: string;
|
||||
/** 如果存在开发环境,则返回 WebIDE 访问 url;如果不存在开发环境,则返回启动云原生开发的 loading 页面 url 地址 */
|
||||
url: string;
|
||||
}> {
|
||||
}>> {
|
||||
const data: { branch?: string; ref?: string } = {};
|
||||
|
||||
if (params.branch) {
|
||||
|
||||
Reference in New Issue
Block a user