Files
cnb/src/index.ts

68 lines
2.3 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({ token: options.token, cookie: options.cookie, cnb: options.cnb });
this.init(options);
}
init(cnbOptions?: CNBOptions) {
const token = this.token;
const cookie = this.cookie;
const options = { token, cookie };
this.workspace = new Workspace(options.token);
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 });
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.ai = new AiBase({ token: options.token, cookie: options.cookie });
}
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'