@kevisual/cnb 0.0.53 → 0.0.54
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/index.ts +1 -0
- package/agent/routes/missions/index.ts +1 -0
- package/agent/routes/missions/list.ts +39 -0
- package/agent/routes/repo/index.ts +2 -1
- package/agent/routes/repo/repo.ts +28 -0
- package/dist/cli.js +335 -44
- package/dist/npc.js +335 -44
- package/dist/opencode.js +256 -3
- package/dist/routes.d.ts +94 -0
- package/dist/routes.js +255 -2
- package/package.json +1 -1
- package/src/mission/index.ts +10 -0
- package/src/mission/modules/fields.ts +164 -0
- package/src/mission/modules/resources.ts +41 -0
package/dist/routes.js
CHANGED
|
@@ -2339,7 +2339,7 @@ var require_src = __commonJS((exports) => {
|
|
|
2339
2339
|
};
|
|
2340
2340
|
});
|
|
2341
2341
|
|
|
2342
|
-
// ../../node_modules/.pnpm/@kevisual+router@0.1.
|
|
2342
|
+
// ../../node_modules/.pnpm/@kevisual+router@0.1.6/node_modules/@kevisual/router/dist/router.js
|
|
2343
2343
|
import { createRequire as createRequire2 } from "node:module";
|
|
2344
2344
|
import { webcrypto as crypto } from "node:crypto";
|
|
2345
2345
|
import url2 from "node:url";
|
|
@@ -19854,7 +19854,7 @@ class QueryRouter {
|
|
|
19854
19854
|
console.error("=====debug====:", e);
|
|
19855
19855
|
console.error("=====debug====:[path:key]:", `${route.path}-${route.key}`);
|
|
19856
19856
|
}
|
|
19857
|
-
if (e instanceof CustomError) {
|
|
19857
|
+
if (e instanceof CustomError || e?.code) {
|
|
19858
19858
|
ctx.code = e.code;
|
|
19859
19859
|
ctx.message = e.message;
|
|
19860
19860
|
} else {
|
|
@@ -20117,6 +20117,39 @@ class QueryRouterServer extends QueryRouter {
|
|
|
20117
20117
|
const { path, key, id } = api2;
|
|
20118
20118
|
return this.run({ path, key, id, payload }, ctx);
|
|
20119
20119
|
}
|
|
20120
|
+
async createAuth(fun) {
|
|
20121
|
+
this.route({
|
|
20122
|
+
path: "auth",
|
|
20123
|
+
key: "auth",
|
|
20124
|
+
id: "auth",
|
|
20125
|
+
description: "token验证"
|
|
20126
|
+
}).define(async (ctx) => {
|
|
20127
|
+
if (fun) {
|
|
20128
|
+
await fun(ctx, "auth");
|
|
20129
|
+
}
|
|
20130
|
+
}).addTo(this, { overwrite: false });
|
|
20131
|
+
this.route({
|
|
20132
|
+
path: "auth-admin",
|
|
20133
|
+
key: "auth-admin",
|
|
20134
|
+
id: "auth-admin",
|
|
20135
|
+
description: "admin token验证",
|
|
20136
|
+
middleware: ["auth"]
|
|
20137
|
+
}).define(async (ctx) => {
|
|
20138
|
+
if (fun) {
|
|
20139
|
+
await fun(ctx, "auth-admin");
|
|
20140
|
+
}
|
|
20141
|
+
}).addTo(this, { overwrite: false });
|
|
20142
|
+
this.route({
|
|
20143
|
+
path: "auth-can",
|
|
20144
|
+
key: "auth-can",
|
|
20145
|
+
id: "auth-can",
|
|
20146
|
+
description: "权限验证"
|
|
20147
|
+
}).define(async (ctx) => {
|
|
20148
|
+
if (fun) {
|
|
20149
|
+
await fun(ctx, "auth-can");
|
|
20150
|
+
}
|
|
20151
|
+
}).addTo(this, { overwrite: false });
|
|
20152
|
+
}
|
|
20120
20153
|
}
|
|
20121
20154
|
var isNode2 = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
20122
20155
|
var isBrowser2 = typeof window !== "undefined" && typeof document !== "undefined" && typeof document.createElement === "function";
|
|
@@ -22927,6 +22960,22 @@ class Issue extends CNBCore {
|
|
|
22927
22960
|
}
|
|
22928
22961
|
}
|
|
22929
22962
|
|
|
22963
|
+
// src/mission/modules/resources.ts
|
|
22964
|
+
var queryResources = async (cnb, opts) => {
|
|
22965
|
+
const url3 = `${cnb.hackURL}/${opts?.repo || "kevisual/projects"}/-/mission-resource/resources`;
|
|
22966
|
+
return cnb.post({
|
|
22967
|
+
url: url3,
|
|
22968
|
+
data: {
|
|
22969
|
+
selectors: opts?.selectors,
|
|
22970
|
+
slugName: opts?.repo
|
|
22971
|
+
},
|
|
22972
|
+
headers: {
|
|
22973
|
+
Accept: "application/vnd.cnb.web+json"
|
|
22974
|
+
},
|
|
22975
|
+
useCookie: true
|
|
22976
|
+
});
|
|
22977
|
+
};
|
|
22978
|
+
|
|
22930
22979
|
// src/mission/index.ts
|
|
22931
22980
|
class Mission extends CNBCore {
|
|
22932
22981
|
constructor(options) {
|
|
@@ -22989,6 +23038,9 @@ class Mission extends CNBCore {
|
|
|
22989
23038
|
params: { visibility }
|
|
22990
23039
|
});
|
|
22991
23040
|
}
|
|
23041
|
+
queryResources(repo, selectors) {
|
|
23042
|
+
return queryResources(this, { repo, selectors });
|
|
23043
|
+
}
|
|
22992
23044
|
}
|
|
22993
23045
|
|
|
22994
23046
|
// src/ai/index.ts
|
|
@@ -44851,6 +44903,169 @@ app.route({
|
|
|
44851
44903
|
const res = await cnb.repo.updateRepoInfo(name15, { description, license, site, topics });
|
|
44852
44904
|
ctx.forward(res);
|
|
44853
44905
|
}).addTo(app);
|
|
44906
|
+
app.route({
|
|
44907
|
+
path: "cnb",
|
|
44908
|
+
key: "update-repo-visibility",
|
|
44909
|
+
description: "更新代码仓库的可见性, 参数name, visibility",
|
|
44910
|
+
middleware: ["auth"],
|
|
44911
|
+
metadata: {
|
|
44912
|
+
args: {
|
|
44913
|
+
name: tool.schema.string().describe("代码仓库名称"),
|
|
44914
|
+
visibility: tool.schema.string().describe("代码仓库可见性, public 或 private 或 protected")
|
|
44915
|
+
}
|
|
44916
|
+
}
|
|
44917
|
+
}).define(async (ctx) => {
|
|
44918
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
44919
|
+
const name15 = ctx.query?.name;
|
|
44920
|
+
const visibility = ctx.query?.visibility;
|
|
44921
|
+
if (!name15) {
|
|
44922
|
+
ctx.throw(400, "缺少参数 name");
|
|
44923
|
+
}
|
|
44924
|
+
if (!visibility) {
|
|
44925
|
+
ctx.throw(400, "缺少参数 visibility");
|
|
44926
|
+
}
|
|
44927
|
+
const res = await cnb.post({
|
|
44928
|
+
url: `/${name15}/-/settings/set_visibility`,
|
|
44929
|
+
data: { visibility }
|
|
44930
|
+
});
|
|
44931
|
+
ctx.forward(res);
|
|
44932
|
+
}).addTo(app);
|
|
44933
|
+
|
|
44934
|
+
// agent/routes/repo/repo-label.ts
|
|
44935
|
+
app.route({
|
|
44936
|
+
path: "cnb",
|
|
44937
|
+
key: "list-repo-labels",
|
|
44938
|
+
description: "查询仓库的标签列表",
|
|
44939
|
+
middleware: ["auth"],
|
|
44940
|
+
metadata: {
|
|
44941
|
+
tags: ["opencode"],
|
|
44942
|
+
...createSkill({
|
|
44943
|
+
skill: "list-repo-labels",
|
|
44944
|
+
title: "查询仓库标签列表",
|
|
44945
|
+
summary: "查询仓库的标签列表",
|
|
44946
|
+
args: {
|
|
44947
|
+
repo: tool.schema.string().describe("仓库路径, 如 my-user/my-repo"),
|
|
44948
|
+
page: tool.schema.number().optional().describe("分页页码,默认 1"),
|
|
44949
|
+
pageSize: tool.schema.number().optional().describe("分页每页大小,默认 30"),
|
|
44950
|
+
keyword: tool.schema.string().optional().describe("标签搜索关键词")
|
|
44951
|
+
}
|
|
44952
|
+
})
|
|
44953
|
+
}
|
|
44954
|
+
}).define(async (ctx) => {
|
|
44955
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
44956
|
+
const repo2 = ctx.query?.repo;
|
|
44957
|
+
const page = ctx.query?.page;
|
|
44958
|
+
const pageSize = ctx.query?.pageSize;
|
|
44959
|
+
const keyword = ctx.query?.keyword;
|
|
44960
|
+
if (!repo2) {
|
|
44961
|
+
ctx.throw(400, "缺少参数 repo");
|
|
44962
|
+
}
|
|
44963
|
+
const res = await cnb.labels.repoLabel.list(repo2, {
|
|
44964
|
+
page,
|
|
44965
|
+
page_size: pageSize,
|
|
44966
|
+
keyword
|
|
44967
|
+
});
|
|
44968
|
+
ctx.forward(res);
|
|
44969
|
+
}).addTo(app);
|
|
44970
|
+
app.route({
|
|
44971
|
+
path: "cnb",
|
|
44972
|
+
key: "create-repo-label",
|
|
44973
|
+
description: "创建仓库标签",
|
|
44974
|
+
middleware: ["auth"],
|
|
44975
|
+
metadata: {
|
|
44976
|
+
tags: ["opencode"],
|
|
44977
|
+
...createSkill({
|
|
44978
|
+
skill: "create-repo-label",
|
|
44979
|
+
title: "创建仓库标签",
|
|
44980
|
+
summary: "创建一个仓库标签",
|
|
44981
|
+
args: {
|
|
44982
|
+
repo: tool.schema.string().describe("仓库路径, 如 my-user/my-repo"),
|
|
44983
|
+
name: tool.schema.string().describe("标签名称"),
|
|
44984
|
+
color: tool.schema.string().describe("标签颜色,十六进制颜色码,不含 # 前缀"),
|
|
44985
|
+
description: tool.schema.string().optional().describe("标签描述")
|
|
44986
|
+
}
|
|
44987
|
+
})
|
|
44988
|
+
}
|
|
44989
|
+
}).define(async (ctx) => {
|
|
44990
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
44991
|
+
const repo2 = ctx.query?.repo;
|
|
44992
|
+
const name15 = ctx.query?.name;
|
|
44993
|
+
const color = ctx.query?.color;
|
|
44994
|
+
const description = ctx.query?.description;
|
|
44995
|
+
if (!repo2 || !name15 || !color) {
|
|
44996
|
+
ctx.throw(400, "缺少参数 repo, name 或 color");
|
|
44997
|
+
}
|
|
44998
|
+
const res = await cnb.labels.repoLabel.create(repo2, {
|
|
44999
|
+
name: name15,
|
|
45000
|
+
color,
|
|
45001
|
+
description
|
|
45002
|
+
});
|
|
45003
|
+
ctx.forward(res);
|
|
45004
|
+
}).addTo(app);
|
|
45005
|
+
app.route({
|
|
45006
|
+
path: "cnb",
|
|
45007
|
+
key: "update-repo-label",
|
|
45008
|
+
description: "更新仓库标签",
|
|
45009
|
+
middleware: ["auth"],
|
|
45010
|
+
metadata: {
|
|
45011
|
+
tags: ["opencode"],
|
|
45012
|
+
...createSkill({
|
|
45013
|
+
skill: "update-repo-label",
|
|
45014
|
+
title: "更新仓库标签",
|
|
45015
|
+
summary: "更新仓库标签信息",
|
|
45016
|
+
args: {
|
|
45017
|
+
repo: tool.schema.string().describe("仓库路径, 如 my-user/my-repo"),
|
|
45018
|
+
name: tool.schema.string().describe("标签名称"),
|
|
45019
|
+
color: tool.schema.string().optional().describe("标签颜色,十六进制颜色码,不含 # 前缀"),
|
|
45020
|
+
description: tool.schema.string().optional().describe("标签描述"),
|
|
45021
|
+
newName: tool.schema.string().optional().describe("新标签名称")
|
|
45022
|
+
}
|
|
45023
|
+
})
|
|
45024
|
+
}
|
|
45025
|
+
}).define(async (ctx) => {
|
|
45026
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
45027
|
+
const repo2 = ctx.query?.repo;
|
|
45028
|
+
const name15 = ctx.query?.name;
|
|
45029
|
+
const color = ctx.query?.color;
|
|
45030
|
+
const description = ctx.query?.description;
|
|
45031
|
+
const newName = ctx.query?.newName;
|
|
45032
|
+
if (!repo2 || !name15) {
|
|
45033
|
+
ctx.throw(400, "缺少参数 repo 或 name");
|
|
45034
|
+
}
|
|
45035
|
+
const res = await cnb.labels.repoLabel.update(repo2, name15, {
|
|
45036
|
+
color,
|
|
45037
|
+
description,
|
|
45038
|
+
new_name: newName
|
|
45039
|
+
});
|
|
45040
|
+
ctx.forward(res);
|
|
45041
|
+
}).addTo(app);
|
|
45042
|
+
app.route({
|
|
45043
|
+
path: "cnb",
|
|
45044
|
+
key: "delete-repo-label",
|
|
45045
|
+
description: "删除仓库标签",
|
|
45046
|
+
middleware: ["auth"],
|
|
45047
|
+
metadata: {
|
|
45048
|
+
tags: ["opencode"],
|
|
45049
|
+
...createSkill({
|
|
45050
|
+
skill: "delete-repo-label",
|
|
45051
|
+
title: "删除仓库标签",
|
|
45052
|
+
summary: "删除指定的仓库标签",
|
|
45053
|
+
args: {
|
|
45054
|
+
repo: tool.schema.string().describe("仓库路径, 如 my-user/my-repo"),
|
|
45055
|
+
name: tool.schema.string().describe("标签名称")
|
|
45056
|
+
}
|
|
45057
|
+
})
|
|
45058
|
+
}
|
|
45059
|
+
}).define(async (ctx) => {
|
|
45060
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
45061
|
+
const repo2 = ctx.query?.repo;
|
|
45062
|
+
const name15 = ctx.query?.name;
|
|
45063
|
+
if (!repo2 || !name15) {
|
|
45064
|
+
ctx.throw(400, "缺少参数 repo 或 name");
|
|
45065
|
+
}
|
|
45066
|
+
const res = await cnb.labels.repoLabel.remove(repo2, name15);
|
|
45067
|
+
ctx.forward(res);
|
|
45068
|
+
}).addTo(app);
|
|
44854
45069
|
|
|
44855
45070
|
// agent/routes/workspace/skills.ts
|
|
44856
45071
|
app.route({
|
|
@@ -53067,6 +53282,44 @@ app.route({
|
|
|
53067
53282
|
ctx.body = result;
|
|
53068
53283
|
}).addTo(app);
|
|
53069
53284
|
|
|
53285
|
+
// agent/routes/missions/list.ts
|
|
53286
|
+
app.route({
|
|
53287
|
+
path: "cnb",
|
|
53288
|
+
key: "missions-list",
|
|
53289
|
+
description: "查询missions列表",
|
|
53290
|
+
metadata: {
|
|
53291
|
+
args: {
|
|
53292
|
+
repo: zod_default.string().optional().describe("missions所在的仓库,例如 kevisual/projects"),
|
|
53293
|
+
selector: zod_default.array(zod_default.any()).optional().describe('查询条件,例如 [{field: "resource_type", operator: "contains", value: ["issues"]},…]')
|
|
53294
|
+
}
|
|
53295
|
+
}
|
|
53296
|
+
}).define(async (ctx) => {
|
|
53297
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
53298
|
+
const repo2 = ctx.query?.repo || "kevisual/projects";
|
|
53299
|
+
const res = await cnb.mission.queryResources(repo2, ctx.query?.selector || [
|
|
53300
|
+
{
|
|
53301
|
+
field: "resource_type",
|
|
53302
|
+
operator: "contains",
|
|
53303
|
+
value: [
|
|
53304
|
+
"issues"
|
|
53305
|
+
]
|
|
53306
|
+
},
|
|
53307
|
+
{
|
|
53308
|
+
field: "state",
|
|
53309
|
+
operator: "not_equals",
|
|
53310
|
+
value: [
|
|
53311
|
+
"closed"
|
|
53312
|
+
]
|
|
53313
|
+
},
|
|
53314
|
+
{
|
|
53315
|
+
field: "label",
|
|
53316
|
+
operator: "contains",
|
|
53317
|
+
value: ["AICoding"]
|
|
53318
|
+
}
|
|
53319
|
+
]);
|
|
53320
|
+
ctx.forward(res);
|
|
53321
|
+
}).addTo(app);
|
|
53322
|
+
|
|
53070
53323
|
// agent/routes/index.ts
|
|
53071
53324
|
var checkAppId = (ctx, appId) => {
|
|
53072
53325
|
const _appId = ctx?.app?.appId;
|
package/package.json
CHANGED
package/src/mission/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CNBCore, CNBCoreOptions, RequestOptions, Result } from "../cnb-core.ts";
|
|
2
|
+
import { queryResources, Selector } from "./modules/resources.ts";
|
|
2
3
|
|
|
3
4
|
export class Mission extends CNBCore {
|
|
4
5
|
constructor(options: CNBCoreOptions) {
|
|
@@ -121,6 +122,15 @@ export class Mission extends CNBCore {
|
|
|
121
122
|
params: { visibility },
|
|
122
123
|
});
|
|
123
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* 查询任务集资源
|
|
127
|
+
* @param repo 仓库路径
|
|
128
|
+
* @param selectors 查询条件
|
|
129
|
+
* @returns 资源列表
|
|
130
|
+
*/
|
|
131
|
+
queryResources(repo: string, selectors?: Selector[]) {
|
|
132
|
+
return queryResources(this, { repo, selectors });
|
|
133
|
+
}
|
|
124
134
|
}
|
|
125
135
|
|
|
126
136
|
// ==================== 类型定义 ====================
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
export const fields = [
|
|
2
|
+
{
|
|
3
|
+
"name": "resource_type",
|
|
4
|
+
"interaction_type": "radio",
|
|
5
|
+
"operators": [],
|
|
6
|
+
"value": [
|
|
7
|
+
"issues",
|
|
8
|
+
"pull_requests"
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "started_at",
|
|
13
|
+
"interaction_type": "time_selector",
|
|
14
|
+
"operators": [
|
|
15
|
+
"equals",
|
|
16
|
+
"before",
|
|
17
|
+
"after",
|
|
18
|
+
"empty",
|
|
19
|
+
"not_empty"
|
|
20
|
+
],
|
|
21
|
+
"value": []
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "ended_at",
|
|
25
|
+
"interaction_type": "time_selector",
|
|
26
|
+
"operators": [
|
|
27
|
+
"equals",
|
|
28
|
+
"before",
|
|
29
|
+
"after",
|
|
30
|
+
"empty",
|
|
31
|
+
"not_empty"
|
|
32
|
+
],
|
|
33
|
+
"value": []
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "closed_at",
|
|
37
|
+
"interaction_type": "time_selector",
|
|
38
|
+
"operators": [
|
|
39
|
+
"equals",
|
|
40
|
+
"before",
|
|
41
|
+
"after",
|
|
42
|
+
"empty",
|
|
43
|
+
"not_empty"
|
|
44
|
+
],
|
|
45
|
+
"value": []
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "assignee",
|
|
49
|
+
"interaction_type": "checkbox",
|
|
50
|
+
"operators": [
|
|
51
|
+
"contains",
|
|
52
|
+
"contains_all",
|
|
53
|
+
"not_contains",
|
|
54
|
+
"equals",
|
|
55
|
+
"not_equals",
|
|
56
|
+
"empty",
|
|
57
|
+
"not_empty"
|
|
58
|
+
],
|
|
59
|
+
"value": [
|
|
60
|
+
{
|
|
61
|
+
"id": "",
|
|
62
|
+
"user_name": "",
|
|
63
|
+
"nick_name": "",
|
|
64
|
+
"user_type": 0
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"id": "2026622946958528512",
|
|
68
|
+
"user_name": "cnb.cAiAVfFPgKA",
|
|
69
|
+
"nick_name": "里海暗红色",
|
|
70
|
+
"user_type": 0
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"id": "1915352477005254656",
|
|
74
|
+
"user_name": "kevisual",
|
|
75
|
+
"nick_name": "科学和哲学",
|
|
76
|
+
"user_type": 0
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"id": "1935321989751226368",
|
|
80
|
+
"user_name": "xiongxiao",
|
|
81
|
+
"nick_name": "小熊猫呜呜呜",
|
|
82
|
+
"user_type": 0
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "repo",
|
|
88
|
+
"interaction_type": "checkbox",
|
|
89
|
+
"operators": [
|
|
90
|
+
"contains",
|
|
91
|
+
"not_contains"
|
|
92
|
+
],
|
|
93
|
+
"value": [
|
|
94
|
+
"kevisual/kevisual",
|
|
95
|
+
"kevisual/cnb",
|
|
96
|
+
"abearxiong/blog",
|
|
97
|
+
"abearxiong/abearxiong"
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"name": "created_at",
|
|
102
|
+
"interaction_type": "time_selector",
|
|
103
|
+
"operators": [
|
|
104
|
+
"equals",
|
|
105
|
+
"before",
|
|
106
|
+
"after"
|
|
107
|
+
],
|
|
108
|
+
"value": []
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "last_acted_at",
|
|
112
|
+
"interaction_type": "time_selector",
|
|
113
|
+
"operators": [
|
|
114
|
+
"equals",
|
|
115
|
+
"before",
|
|
116
|
+
"after"
|
|
117
|
+
],
|
|
118
|
+
"value": []
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "priority",
|
|
122
|
+
"interaction_type": "checkbox",
|
|
123
|
+
"operators": [
|
|
124
|
+
"contains",
|
|
125
|
+
"not_contains",
|
|
126
|
+
"empty",
|
|
127
|
+
"not_empty"
|
|
128
|
+
],
|
|
129
|
+
"value": [
|
|
130
|
+
"-2P",
|
|
131
|
+
"-1P",
|
|
132
|
+
"P0",
|
|
133
|
+
"P1",
|
|
134
|
+
"P2",
|
|
135
|
+
"P3",
|
|
136
|
+
""
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"name": "state",
|
|
141
|
+
"interaction_type": "radio",
|
|
142
|
+
"operators": [
|
|
143
|
+
"equals",
|
|
144
|
+
"not_equals"
|
|
145
|
+
],
|
|
146
|
+
"value": [
|
|
147
|
+
"open",
|
|
148
|
+
"closed"
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"name": "label",
|
|
153
|
+
"interaction_type": "radio",
|
|
154
|
+
"operators": [
|
|
155
|
+
"equals",
|
|
156
|
+
"not_equals"
|
|
157
|
+
],
|
|
158
|
+
"value": [
|
|
159
|
+
"AICoding"
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
] as const;
|
|
163
|
+
|
|
164
|
+
export type FieldName = typeof fields[number]['name'];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
// selectors
|
|
3
|
+
// :
|
|
4
|
+
// [{field: "resource_type", operator: "contains", value: ["issues"]},…]
|
|
5
|
+
// 0
|
|
6
|
+
// :
|
|
7
|
+
// {field: "resource_type", operator: "contains", value: ["issues"]}
|
|
8
|
+
// 1
|
|
9
|
+
// :
|
|
10
|
+
// {field: "state", operator: "not_equals", value: ["closed"]}
|
|
11
|
+
// slugName
|
|
12
|
+
// :
|
|
13
|
+
// "kevisual/projects"
|
|
14
|
+
|
|
15
|
+
import { CNBCore } from "@/cnb-core.ts";
|
|
16
|
+
import { FieldName } from "./fields.ts";
|
|
17
|
+
|
|
18
|
+
export type Selector = {
|
|
19
|
+
/**
|
|
20
|
+
* 字段名称,例如 resource_type、state 等
|
|
21
|
+
*/
|
|
22
|
+
field: FieldName;
|
|
23
|
+
operator: 'equals' | 'not_equals' | 'contains' | 'not_contains' | 'in' | 'not_in';
|
|
24
|
+
// value: ["issues"]
|
|
25
|
+
value: any; // 可以是字符串、数组等,具体取决于 operator
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const queryResources = async (cnb: CNBCore, opts?: { repo?: string; selectors?: Selector[] }) => {
|
|
29
|
+
const url = `${cnb.hackURL}/${opts?.repo || 'kevisual/projects'}/-/mission-resource/resources`;
|
|
30
|
+
return cnb.post({
|
|
31
|
+
url,
|
|
32
|
+
data: {
|
|
33
|
+
selectors: opts?.selectors,
|
|
34
|
+
slugName: opts?.repo,
|
|
35
|
+
},
|
|
36
|
+
headers:{
|
|
37
|
+
Accept: 'application/vnd.cnb.web+json',
|
|
38
|
+
},
|
|
39
|
+
useCookie: true,
|
|
40
|
+
})
|
|
41
|
+
}
|