更新版本号至0.0.15,并优化CNB和Workspace类的构造函数以支持更多选项

This commit is contained in:
2026-02-05 19:45:01 +08:00
parent ddaa4726ff
commit ed6a9c5bbc
3 changed files with 16 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@kevisual/cnb", "name": "@kevisual/cnb",
"version": "0.0.14", "version": "0.0.15",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@@ -21,21 +21,23 @@ export class CNB extends CNBCore {
mission!: Mission; mission!: Mission;
ai!: AiBase; ai!: AiBase;
constructor(options: CNBOptions) { constructor(options: CNBOptions) {
super({ token: options.token, cookie: options.cookie, cnb: options.cnb }); super({ ...options, token: options.token, cookie: options.cookie, cnb: options.cnb });
this.init(options); this.init(options);
} }
init(cnbOptions?: CNBOptions) { init(cnbOptions?: CNBOptions) {
const token = this.token; const token = this.token;
const cookie = this.cookie; const cookie = this.cookie;
const options = { token, cookie }; const cors = cnbOptions?.cors || {}
this.workspace = new Workspace(options.token); const cnb = cnbOptions?.cnb
this.knowledgeBase = new KnowledgeBase({ token: options.token, cookie: options.cookie }); const options = { token, cookie, cors, cnb };
this.repo = new Repo({ token: options.token, cookie: options.cookie }); this.workspace = new Workspace(options);
this.user = new User({ token: options.token, cookie: options.cookie }); this.knowledgeBase = new KnowledgeBase(options);
this.build = new Build({ token: options.token, cookie: options.cookie }); this.repo = new Repo(options);
this.issue = new Issue({ token: options.token, cookie: options.cookie }); this.user = new User(options);
this.mission = new Mission({ token: options.token, cookie: options.cookie }); this.build = new Build(options);
this.ai = new AiBase({ token: options.token, cookie: options.cookie }); this.issue = new Issue(options);
this.mission = new Mission(options);
this.ai = new AiBase(options);
} }
setToken(token: string) { setToken(token: string) {
this.token = token; this.token = token;

View File

@@ -6,7 +6,7 @@
*/ */
import { Result } from "@kevisual/query/query"; import { Result } from "@kevisual/query/query";
import { CNBCore } from "../cnb-core.ts"; import { CNBCore, CNBCoreOptions } from "../cnb-core.ts";
/** /**
* 工作空间列表查询参数 * 工作空间列表查询参数
@@ -33,8 +33,8 @@ export interface ListParams {
* https://api.cnb.cool/#/operations/GetWorkspaceDetail * https://api.cnb.cool/#/operations/GetWorkspaceDetail
*/ */
export class Workspace extends CNBCore { export class Workspace extends CNBCore {
constructor(token: string) { constructor(options: CNBCoreOptions) {
super({ token }); super(options);
} }
/** /**
* 删除我的云原生开发环境 * 删除我的云原生开发环境