@kevisual/cnb 0.0.56 → 0.0.58
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/agent/routes/call/index.ts +5 -4
- package/agent/routes/cnb-env/env.ts +3 -2
- package/agent/routes/cnb-env/vscode.ts +9 -8
- package/agent/routes/index.ts +1 -0
- package/agent/routes/issues/comments.ts +18 -17
- package/agent/routes/issues/issue.ts +11 -10
- package/agent/routes/issues/list.ts +11 -10
- package/agent/routes/knowledge/ai.ts +6 -5
- package/agent/routes/labels/issue-label.ts +17 -16
- package/agent/routes/org/index.ts +2 -0
- package/agent/routes/org/list.ts +137 -0
- package/agent/routes/org/org.ts +241 -0
- package/agent/routes/package/index.ts +2 -0
- package/agent/routes/package/package.ts +255 -0
- package/agent/routes/package/registry.ts +107 -0
- package/agent/routes/repo/list.ts +6 -5
- package/agent/routes/repo/repo-label.ts +17 -16
- package/agent/routes/repo/repo.ts +18 -17
- package/agent/routes/workspace/build.ts +7 -6
- package/agent/routes/workspace/index.ts +17 -17
- package/agent/routes/workspace/keep.ts +5 -5
- package/agent/routes/workspace/rerun.ts +6 -1
- package/agent/routes/workspace/skills.ts +2 -2
- package/dist/cli.js +764 -207
- package/dist/npc.js +764 -207
- package/dist/opencode.js +772 -215
- package/dist/routes.d.ts +643 -3
- package/dist/routes.js +764 -207
- package/package.json +1 -1
- package/src/index.ts +21 -1
- package/src/issue/index.ts +5 -2
- package/src/knowledge/index.ts +92 -5
- package/src/org/index.ts +574 -0
- package/src/package/index.ts +2 -0
- package/src/package/package.ts +134 -0
- package/src/package/registry.ts +145 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router'
|
|
2
|
+
import { z } from 'zod'
|
|
2
3
|
import { app } from '../../app.ts'
|
|
3
4
|
|
|
4
5
|
// "调用 path: cnb key: list-repos"
|
|
@@ -14,9 +15,9 @@ app.route({
|
|
|
14
15
|
title: '调用app应用',
|
|
15
16
|
summary: '调用router的应用, 参数path, key, payload',
|
|
16
17
|
args: {
|
|
17
|
-
path:
|
|
18
|
-
key:
|
|
19
|
-
payload:
|
|
18
|
+
path: z.string().describe('应用路径,例如 cnb'),
|
|
19
|
+
key: z.string().optional().describe('应用key,例如 list-repos'),
|
|
20
|
+
payload: z.object({}).optional().describe('调用参数'),
|
|
20
21
|
}
|
|
21
22
|
})
|
|
22
23
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { app, cnbManager } from '../../app.ts';
|
|
3
4
|
|
|
4
5
|
// 设置 CNB_COOKIE环境变量和获取环境变量,用于界面操作定制模块功能
|
|
@@ -14,7 +15,7 @@ app.route({
|
|
|
14
15
|
title: '设置当前cnb工作空间的cookie环境变量',
|
|
15
16
|
summary: '设置当前cnb工作空间的cookie环境变量,用于界面操作定制模块功能,例子:CNBSESSION=xxxx;csrfkey=2222xxxx;',
|
|
16
17
|
args: {
|
|
17
|
-
cookie:
|
|
18
|
+
cookie: z.string().describe('cnb的cookie值'),
|
|
18
19
|
}
|
|
19
20
|
})
|
|
20
21
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { app, notCNBCheck } from '../../app.ts';
|
|
3
4
|
|
|
4
5
|
import { CNB_ENV } from "@/common/cnb-env.ts";
|
|
@@ -19,7 +20,7 @@ app.route({
|
|
|
19
20
|
title: '获取当前cnb工作空间的port代理uri',
|
|
20
21
|
summary: '获取当前cnb工作空间的port代理uri,用于端口转发',
|
|
21
22
|
args: {
|
|
22
|
-
port:
|
|
23
|
+
port: z.number().optional().describe('端口号,默认为51515'),
|
|
23
24
|
}
|
|
24
25
|
})
|
|
25
26
|
}
|
|
@@ -49,12 +50,12 @@ app.route({
|
|
|
49
50
|
title: '获取当前cnb工作空间的编辑器访问地址',
|
|
50
51
|
summary: '获取当前cnb工作空间的vscode代理uri,用于在浏览器中访问vscode,包含多种访问方式,如web、vscode、codebuddy、cursor、ssh',
|
|
51
52
|
args: {
|
|
52
|
-
web:
|
|
53
|
-
vscode:
|
|
54
|
-
codebuddy:
|
|
55
|
-
cursor:
|
|
56
|
-
// trae:
|
|
57
|
-
ssh:
|
|
53
|
+
web: z.boolean().optional().describe('是否获取vscode web的访问uri,默认为false'),
|
|
54
|
+
vscode: z.boolean().optional().describe('是否获取vscode的代理uri,默认为true'),
|
|
55
|
+
codebuddy: z.boolean().optional().describe('是否获取codebuddy的代理uri,默认为false'),
|
|
56
|
+
cursor: z.boolean().optional().describe('是否获取cursor的代理uri,默认为false'),
|
|
57
|
+
// trae: z.boolean().optional().describe('是否获取trae的代理uri,默认为false'),
|
|
58
|
+
ssh: z.boolean().optional().describe('是否获取vscode remote ssh的连接字符串,默认为false'),
|
|
58
59
|
}
|
|
59
60
|
})
|
|
60
61
|
}
|
package/agent/routes/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { app, cnbManager } from '../../app.ts';
|
|
3
4
|
import { useKey } from '@kevisual/context';
|
|
4
5
|
|
|
@@ -14,10 +15,10 @@ app.route({
|
|
|
14
15
|
skill: 'list-issue-comments',
|
|
15
16
|
title: '查询 Issue 评论列表',
|
|
16
17
|
args: {
|
|
17
|
-
repo:
|
|
18
|
-
issueNumber:
|
|
19
|
-
page:
|
|
20
|
-
page_size:
|
|
18
|
+
repo: z.string().optional().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
19
|
+
issueNumber: z.number().describe('Issue 编号'),
|
|
20
|
+
page: z.number().optional().describe('分页页码,默认: 1'),
|
|
21
|
+
page_size: z.number().optional().describe('分页每页大小,默认: 30'),
|
|
21
22
|
},
|
|
22
23
|
summary: '查询 Issue 评论列表',
|
|
23
24
|
})
|
|
@@ -56,10 +57,10 @@ app.route({
|
|
|
56
57
|
skill: 'create-issue-comment',
|
|
57
58
|
title: '创建 Issue 评论',
|
|
58
59
|
args: {
|
|
59
|
-
repo:
|
|
60
|
-
issueNumber:
|
|
61
|
-
body:
|
|
62
|
-
clearAt:
|
|
60
|
+
repo: z.string().optional().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
61
|
+
issueNumber: z.number().describe('Issue 编号'),
|
|
62
|
+
body: z.string().describe('评论内容'),
|
|
63
|
+
clearAt: z.boolean().optional().describe('是否清除评论内容中的 @ 提及,默认: true'),
|
|
63
64
|
},
|
|
64
65
|
summary: '创建 Issue 评论',
|
|
65
66
|
})
|
|
@@ -101,9 +102,9 @@ app.route({
|
|
|
101
102
|
skill: 'get-issue-comment',
|
|
102
103
|
title: '获取 Issue 评论',
|
|
103
104
|
args: {
|
|
104
|
-
repo:
|
|
105
|
-
issueNumber:
|
|
106
|
-
commentId:
|
|
105
|
+
repo: z.string().optional().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
106
|
+
issueNumber: z.number().describe('Issue 编号'),
|
|
107
|
+
commentId: z.number().describe('评论 ID'),
|
|
107
108
|
},
|
|
108
109
|
summary: '获取 Issue 评论',
|
|
109
110
|
})
|
|
@@ -140,11 +141,11 @@ app.route({
|
|
|
140
141
|
skill: 'update-issue-comment',
|
|
141
142
|
title: '修改 Issue 评论',
|
|
142
143
|
args: {
|
|
143
|
-
repo:
|
|
144
|
-
issueNumber:
|
|
145
|
-
commentId:
|
|
146
|
-
body:
|
|
147
|
-
clearAt:
|
|
144
|
+
repo: z.string().optional().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
145
|
+
issueNumber: z.number().describe('Issue 编号'),
|
|
146
|
+
commentId: z.number().describe('评论 ID'),
|
|
147
|
+
body: z.string().describe('评论内容'),
|
|
148
|
+
clearAt: z.boolean().optional().describe('是否清除评论内容中的 @ 提及,默认: true'),
|
|
148
149
|
},
|
|
149
150
|
summary: '修改 Issue 评论',
|
|
150
151
|
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { app, cnbManager } from '../../app.ts';
|
|
3
4
|
import { IssueItem } from '@/index.ts';
|
|
4
5
|
|
|
@@ -14,12 +15,12 @@ app.route({
|
|
|
14
15
|
skill: 'create-issue',
|
|
15
16
|
title: '创建 Issue',
|
|
16
17
|
args: {
|
|
17
|
-
repo:
|
|
18
|
-
title:
|
|
19
|
-
body:
|
|
20
|
-
assignees:
|
|
21
|
-
labels:
|
|
22
|
-
priority:
|
|
18
|
+
repo: z.string().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
19
|
+
title: z.string().describe('Issue 标题'),
|
|
20
|
+
body: z.string().optional().describe('Issue 描述内容'),
|
|
21
|
+
assignees: z.array(z.string()).optional().describe('指派人列表'),
|
|
22
|
+
labels: z.array(z.string()).optional().describe('标签列表'),
|
|
23
|
+
priority: z.string().optional().describe('优先级'),
|
|
23
24
|
},
|
|
24
25
|
summary: '创建一个新的 Issue',
|
|
25
26
|
})
|
|
@@ -59,9 +60,9 @@ app.route({
|
|
|
59
60
|
skill: 'complete-issue',
|
|
60
61
|
title: '完成 CNB的任务Issue',
|
|
61
62
|
args: {
|
|
62
|
-
repo:
|
|
63
|
-
issueNumber:
|
|
64
|
-
state:
|
|
63
|
+
repo: z.string().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
64
|
+
issueNumber: z.union([z.string(), z.number()]).describe('Issue 编号'),
|
|
65
|
+
state: z.string().optional().describe('Issue 状态,默认为 closed'),
|
|
65
66
|
},
|
|
66
67
|
summary: '完成一个 Issue(将 state 改为 closed)',
|
|
67
68
|
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { app, cnbManager } from '../../app.ts';
|
|
3
4
|
import { useKey } from '@kevisual/context';
|
|
4
5
|
|
|
@@ -14,13 +15,13 @@ app.route({
|
|
|
14
15
|
skill: 'list-issues',
|
|
15
16
|
title: '查询 Issue 列表',
|
|
16
17
|
args: {
|
|
17
|
-
repo:
|
|
18
|
-
state:
|
|
19
|
-
keyword:
|
|
20
|
-
labels:
|
|
21
|
-
page:
|
|
22
|
-
page_size:
|
|
23
|
-
order_by:
|
|
18
|
+
repo: z.string().optional().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
19
|
+
state: z.string().optional().describe('Issue 状态:open 或 closed'),
|
|
20
|
+
keyword: z.string().optional().describe('问题搜索关键词'),
|
|
21
|
+
labels: z.string().optional().describe('问题标签,多个用逗号分隔'),
|
|
22
|
+
page: z.number().optional().describe('分页页码,默认: 1'),
|
|
23
|
+
page_size: z.number().optional().describe('分页每页大小,默认: 30'),
|
|
24
|
+
order_by: z.string().optional().describe('排序方式,如 created_at, -updated_at'),
|
|
24
25
|
},
|
|
25
26
|
summary: '查询 Issue 列表',
|
|
26
27
|
})
|
|
@@ -62,8 +63,8 @@ app.route({
|
|
|
62
63
|
skill: 'getIssue',
|
|
63
64
|
title: '获取 单个 Issue',
|
|
64
65
|
args: {
|
|
65
|
-
repo:
|
|
66
|
-
issueNumber:
|
|
66
|
+
repo: z.string().optional().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
67
|
+
issueNumber: z.union([z.string(), z.number()]).describe('Issue 编号'),
|
|
67
68
|
},
|
|
68
69
|
summary: '获取 单个 Issue',
|
|
69
70
|
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { app, cnbManager } from '../../app.ts';
|
|
3
4
|
import { CNBChat } from '@kevisual/ai/browser'
|
|
4
5
|
import { useKey } from '@kevisual/context';
|
|
@@ -21,8 +22,8 @@ app.route({
|
|
|
21
22
|
title: '调用cnb的知识库ai对话功能进行聊天',
|
|
22
23
|
summary: '调用cnb的知识库ai对话功能进行聊天,基于cnb提供的ai能力',
|
|
23
24
|
args: {
|
|
24
|
-
question:
|
|
25
|
-
repo:
|
|
25
|
+
question: z.string().describe('用户输入的消息内容'),
|
|
26
|
+
repo: z.string().optional().describe('知识库仓库ID,默认为空表示使用默认知识库'),
|
|
26
27
|
}
|
|
27
28
|
})
|
|
28
29
|
}
|
|
@@ -98,8 +99,8 @@ app.route({
|
|
|
98
99
|
title: '调用cnb的知识库RAG查询功能进行问答',
|
|
99
100
|
summary: '调用cnb的知识库RAG查询功能进行问答,基于cnb提供的知识库能力',
|
|
100
101
|
args: {
|
|
101
|
-
question:
|
|
102
|
-
repo:
|
|
102
|
+
question: z.string().describe('用户输入的消息内容'),
|
|
103
|
+
repo: z.string().optional().describe('知识库仓库ID,默认为空表示使用默认知识库'),
|
|
103
104
|
}
|
|
104
105
|
})
|
|
105
106
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { app, cnbManager } from '../../app.ts';
|
|
3
4
|
import { useKey } from '@kevisual/context';
|
|
4
5
|
|
|
@@ -15,10 +16,10 @@ app.route({
|
|
|
15
16
|
title: '查询 Issue 标签列表',
|
|
16
17
|
summary: '查询 Issue 的标签列表',
|
|
17
18
|
args: {
|
|
18
|
-
repo:
|
|
19
|
-
issueNumber:
|
|
20
|
-
page:
|
|
21
|
-
pageSize:
|
|
19
|
+
repo: z.string().optional().describe('仓库路径, 如 my-user/my-repo'),
|
|
20
|
+
issueNumber: z.number().describe('Issue 编号'),
|
|
21
|
+
page: z.number().optional().describe('分页页码,默认 1'),
|
|
22
|
+
pageSize: z.number().optional().describe('分页每页大小,默认 30'),
|
|
22
23
|
},
|
|
23
24
|
})
|
|
24
25
|
}
|
|
@@ -56,9 +57,9 @@ app.route({
|
|
|
56
57
|
title: '设置 Issue 标签',
|
|
57
58
|
summary: '设置 Issue 标签(完全替换现有标签)',
|
|
58
59
|
args: {
|
|
59
|
-
repo:
|
|
60
|
-
issueNumber:
|
|
61
|
-
labels:
|
|
60
|
+
repo: z.string().optional().describe('仓库路径, 如 my-user/my-repo'),
|
|
61
|
+
issueNumber: z.number().describe('Issue 编号'),
|
|
62
|
+
labels: z.array(z.string()).describe('标签名称数组'),
|
|
62
63
|
},
|
|
63
64
|
})
|
|
64
65
|
}
|
|
@@ -95,9 +96,9 @@ app.route({
|
|
|
95
96
|
title: '新增 Issue 标签',
|
|
96
97
|
summary: '新增 Issue 标签(追加到现有标签)',
|
|
97
98
|
args: {
|
|
98
|
-
repo:
|
|
99
|
-
issueNumber:
|
|
100
|
-
labels:
|
|
99
|
+
repo: z.string().optional().describe('仓库路径, 如 my-user/my-repo'),
|
|
100
|
+
issueNumber: z.number().describe('Issue 编号'),
|
|
101
|
+
labels: z.array(z.string()).describe('标签名称数组'),
|
|
101
102
|
},
|
|
102
103
|
})
|
|
103
104
|
}
|
|
@@ -134,8 +135,8 @@ app.route({
|
|
|
134
135
|
title: '清空 Issue 标签',
|
|
135
136
|
summary: '清空 Issue 标签(移除所有标签)',
|
|
136
137
|
args: {
|
|
137
|
-
repo:
|
|
138
|
-
issueNumber:
|
|
138
|
+
repo: z.string().optional().describe('仓库路径, 如 my-user/my-repo'),
|
|
139
|
+
issueNumber: z.number().describe('Issue 编号'),
|
|
139
140
|
},
|
|
140
141
|
})
|
|
141
142
|
}
|
|
@@ -168,9 +169,9 @@ app.route({
|
|
|
168
169
|
title: '删除 Issue 标签',
|
|
169
170
|
summary: '删除 Issue 指定标签',
|
|
170
171
|
args: {
|
|
171
|
-
repo:
|
|
172
|
-
issueNumber:
|
|
173
|
-
name:
|
|
172
|
+
repo: z.string().optional().describe('仓库路径, 如 my-user/my-repo'),
|
|
173
|
+
issueNumber: z.number().describe('Issue 编号'),
|
|
174
|
+
name: z.string().describe('标签名称'),
|
|
174
175
|
},
|
|
175
176
|
})
|
|
176
177
|
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { app, cnbManager } from '../../app.ts';
|
|
4
|
+
|
|
5
|
+
// 获取当前用户顶层组织列表
|
|
6
|
+
app.route({
|
|
7
|
+
path: 'cnb',
|
|
8
|
+
key: 'list-top-groups',
|
|
9
|
+
description: '获取当前用户拥有权限的顶层组织列表',
|
|
10
|
+
middleware: ['auth'],
|
|
11
|
+
metadata: {
|
|
12
|
+
tags: ['opencode'],
|
|
13
|
+
...createSkill({
|
|
14
|
+
skill: 'list-top-groups',
|
|
15
|
+
title: '获取顶层组织列表',
|
|
16
|
+
args: {
|
|
17
|
+
page: z.number().optional().describe('分页页码,默认: 1'),
|
|
18
|
+
page_size: z.number().optional().describe('分页每页大小,默认: 10'),
|
|
19
|
+
search: z.string().optional().describe('搜索过滤组织名称'),
|
|
20
|
+
role: z.enum(['Guest', 'Reporter', 'Developer', 'Master', 'Owner']).optional().describe('按角色过滤'),
|
|
21
|
+
},
|
|
22
|
+
summary: '获取当前用户拥有权限的顶层组织列表',
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
}).define(async (ctx) => {
|
|
26
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
27
|
+
const page = ctx.query?.page ? Number(ctx.query.page) : undefined;
|
|
28
|
+
const page_size = ctx.query?.page_size ? Number(ctx.query.page_size) : undefined;
|
|
29
|
+
const search = ctx.query?.search;
|
|
30
|
+
const role = ctx.query?.role;
|
|
31
|
+
|
|
32
|
+
const res = await cnb.org.listTopGroups({ page, page_size, search, role });
|
|
33
|
+
ctx.forward(res);
|
|
34
|
+
}).addTo(app);
|
|
35
|
+
|
|
36
|
+
// 获取指定组织下的子组织列表
|
|
37
|
+
app.route({
|
|
38
|
+
path: 'cnb',
|
|
39
|
+
key: 'list-groups',
|
|
40
|
+
description: '获取指定组织下的子组织列表',
|
|
41
|
+
middleware: ['auth'],
|
|
42
|
+
metadata: {
|
|
43
|
+
tags: ['opencode'],
|
|
44
|
+
...createSkill({
|
|
45
|
+
skill: 'list-groups',
|
|
46
|
+
title: '获取子组织列表',
|
|
47
|
+
args: {
|
|
48
|
+
slug: z.string().describe('组织路径,如 my-org'),
|
|
49
|
+
page: z.number().optional().describe('分页页码,默认: 1'),
|
|
50
|
+
page_size: z.number().optional().describe('分页每页大小,默认: 10'),
|
|
51
|
+
access: z.number().optional().describe('访问权限级别'),
|
|
52
|
+
},
|
|
53
|
+
summary: '获取指定组织下拥有权限的子组织列表',
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
}).define(async (ctx) => {
|
|
57
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
58
|
+
const slug = ctx.query?.slug;
|
|
59
|
+
const page = ctx.query?.page ? Number(ctx.query.page) : undefined;
|
|
60
|
+
const page_size = ctx.query?.page_size ? Number(ctx.query.page_size) : undefined;
|
|
61
|
+
const access = ctx.query?.access ? Number(ctx.query.access) : undefined;
|
|
62
|
+
|
|
63
|
+
if (!slug) {
|
|
64
|
+
ctx.throw(400, '缺少参数 slug');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const res = await cnb.org.listGroups(slug, { page, page_size, access });
|
|
68
|
+
ctx.forward(res);
|
|
69
|
+
}).addTo(app);
|
|
70
|
+
|
|
71
|
+
// 获取指定组织下的子组织列表(不带权限过滤)
|
|
72
|
+
app.route({
|
|
73
|
+
path: 'cnb',
|
|
74
|
+
key: 'list-subgroups',
|
|
75
|
+
description: '获取指定组织下的子组织列表(不带权限过滤)',
|
|
76
|
+
middleware: ['auth'],
|
|
77
|
+
metadata: {
|
|
78
|
+
tags: ['opencode'],
|
|
79
|
+
...createSkill({
|
|
80
|
+
skill: 'list-subgroups',
|
|
81
|
+
title: '获取子组织列表',
|
|
82
|
+
args: {
|
|
83
|
+
slug: z.string().describe('组织路径,如 my-org'),
|
|
84
|
+
search: z.string().optional().describe('搜索过滤子组织名称'),
|
|
85
|
+
page: z.number().optional().describe('分页页码,默认: 1'),
|
|
86
|
+
page_size: z.number().optional().describe('分页每页大小,默认: 10'),
|
|
87
|
+
},
|
|
88
|
+
summary: '获取指定组织下的子组织列表',
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
}).define(async (ctx) => {
|
|
92
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
93
|
+
const slug = ctx.query?.slug;
|
|
94
|
+
const search = ctx.query?.search;
|
|
95
|
+
const page = ctx.query?.page ? Number(ctx.query.page) : undefined;
|
|
96
|
+
const page_size = ctx.query?.page_size ? Number(ctx.query.page_size) : undefined;
|
|
97
|
+
|
|
98
|
+
if (!slug) {
|
|
99
|
+
ctx.throw(400, '缺少参数 slug');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const res = await cnb.org.listSubgroups(slug, { search, page, page_size });
|
|
103
|
+
ctx.forward(res);
|
|
104
|
+
}).addTo(app);
|
|
105
|
+
|
|
106
|
+
// 获取指定用户拥有权限的组织列表
|
|
107
|
+
app.route({
|
|
108
|
+
path: 'cnb',
|
|
109
|
+
key: 'get-groups-by-username',
|
|
110
|
+
description: '获取指定用户拥有权限的组织列表',
|
|
111
|
+
middleware: ['auth'],
|
|
112
|
+
metadata: {
|
|
113
|
+
tags: [],
|
|
114
|
+
skill: 'get-groups-by-username',
|
|
115
|
+
title: '获取用户的组织列表',
|
|
116
|
+
args: {
|
|
117
|
+
username: z.string().describe('用户名'),
|
|
118
|
+
search: z.string().optional().describe('搜索过滤组织名称'),
|
|
119
|
+
page: z.number().optional().describe('分页页码,默认: 1'),
|
|
120
|
+
page_size: z.number().optional().describe('分页每页大小,默认: 10'),
|
|
121
|
+
},
|
|
122
|
+
summary: '获取指定用户拥有权限的组织列表',
|
|
123
|
+
}
|
|
124
|
+
}).define(async (ctx) => {
|
|
125
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
126
|
+
const username = ctx.query?.username;
|
|
127
|
+
const search = ctx.query?.search;
|
|
128
|
+
const page = ctx.query?.page ? Number(ctx.query.page) : undefined;
|
|
129
|
+
const page_size = ctx.query?.page_size ? Number(ctx.query.page_size) : undefined;
|
|
130
|
+
|
|
131
|
+
if (!username) {
|
|
132
|
+
ctx.throw(400, '缺少参数 username');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const res = await cnb.org.getGroupsByUsername(username, { search, page, page_size });
|
|
136
|
+
ctx.forward(res);
|
|
137
|
+
}).addTo(app);
|