Files
cnb/src/index.ts

70 lines
2.1 KiB
TypeScript

import { CNBCore, CNBCoreOptions } from "./cnb-core.ts";
import { Workspace } from "./workspace/index.ts";
import { KnowledgeBase } from "./knowledge/index.ts";
import { Repo } from "./repo/index.ts";
import { User } from "./user/index.ts";
import { Build } from "./build/index.ts";
import { Issue } from "./issue/index.ts";
import { Mission } from "./mission/index.ts";
import { AiBase } from "./ai/index.ts";
type CNBOptions = CNBCoreOptions<{
}>;
export class CNB extends CNBCore {
workspace!: Workspace;
knowledgeBase!: KnowledgeBase;
repo!: Repo;
user!: User;
build!: Build;
issue!: Issue;
mission!: Mission;
ai!: AiBase;
constructor(options: CNBOptions) {
super({ ...options, token: options.token, cookie: options.cookie, cnb: options.cnb });
this.init(options);
}
init(cnbOptions?: CNBOptions) {
const token = this.token;
const cookie = this.cookie;
const cors = cnbOptions?.cors || {}
const cnb = cnbOptions?.cnb
const options = { token, cookie, cors, cnb };
this.workspace = new Workspace(options);
this.knowledgeBase = new KnowledgeBase(options);
this.repo = new Repo(options);
this.user = new User(options);
this.build = new Build(options);
this.issue = new Issue(options);
this.mission = new Mission(options);
this.ai = new AiBase(options);
}
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;
}
}
export * from './workspace/index.ts'
export * from './cnb-core.ts'
export * from './knowledge/index.ts'
export * from './repo/index.ts'
export * from './user/index.ts'
export * from './build/index.ts'
export * from './issue/index.ts'
export * from './mission/index.ts'
export * from './ai/index.ts'