temp
This commit is contained in:
@@ -1,24 +1,4 @@
|
|||||||
import { resolvePath } from '@kevisual/use-config';
|
import { buildWithBun } from '@kevisual/code-builder'
|
||||||
import { execSync } from 'node:child_process';
|
await buildWithBun({ naming: 'opencode', entry: 'agent/opencode.ts', dts: true });
|
||||||
|
await buildWithBun({ naming: 'keep', entry: 'src/keep.ts', dts: true });
|
||||||
const buildFn = async (opts: { entry?: string, naming?: string }) => {
|
await buildWithBun({ naming: 'routes', entry: 'agent/index.ts', dts: true });
|
||||||
const entry = opts.entry || 'agent/opencode.ts';
|
|
||||||
const naming = opts.naming || 'opencode';
|
|
||||||
const external: string[] = ["bun", "ws"];
|
|
||||||
await Bun.build({
|
|
||||||
target: 'node',
|
|
||||||
format: 'esm',
|
|
||||||
entrypoints: [resolvePath(entry, { meta: import.meta })],
|
|
||||||
outdir: resolvePath('./dist', { meta: import.meta }),
|
|
||||||
naming: {
|
|
||||||
entry: `${naming}.js`,
|
|
||||||
},
|
|
||||||
external,
|
|
||||||
});
|
|
||||||
const cmd = `dts -i ${entry} -o ${naming}.d.ts`;
|
|
||||||
execSync(cmd);
|
|
||||||
};
|
|
||||||
|
|
||||||
await buildFn({ naming: 'opencode', entry: 'agent/opencode.ts' });
|
|
||||||
await buildFn({ naming: 'keep', entry: 'src/keep.ts' });
|
|
||||||
await buildFn({ naming: 'routes', entry: 'agent/index.ts' });
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@kevisual/cnb",
|
"name": "@kevisual/cnb",
|
||||||
"version": "0.0.13",
|
"version": "0.0.14",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@kevisual/ai": "^0.0.24",
|
"@kevisual/ai": "^0.0.24",
|
||||||
|
"@kevisual/code-builder": "^0.0.6",
|
||||||
"@kevisual/context": "^0.0.4",
|
"@kevisual/context": "^0.0.4",
|
||||||
"@kevisual/types": "^0.0.12",
|
"@kevisual/types": "^0.0.12",
|
||||||
"@opencode-ai/plugin": "^1.1.44",
|
"@opencode-ai/plugin": "^1.1.44",
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ export type CNBCoreOptions<T = {}> = {
|
|||||||
*/
|
*/
|
||||||
cookie?: string;
|
cookie?: string;
|
||||||
cnb?: CNBCore;
|
cnb?: CNBCore;
|
||||||
|
cors?: {
|
||||||
|
baseUrl?: string
|
||||||
|
}
|
||||||
} & T;
|
} & T;
|
||||||
|
|
||||||
export type RequestOptions = {
|
export type RequestOptions = {
|
||||||
@@ -19,6 +22,7 @@ export type RequestOptions = {
|
|||||||
};
|
};
|
||||||
export class CNBCore {
|
export class CNBCore {
|
||||||
baseURL = 'https://api.cnb.cool';
|
baseURL = 'https://api.cnb.cool';
|
||||||
|
hackURL = 'https://cnb.cool'
|
||||||
public token: string;
|
public token: string;
|
||||||
public cookie?: string;
|
public cookie?: string;
|
||||||
constructor(options: CNBCoreOptions) {
|
constructor(options: CNBCoreOptions) {
|
||||||
@@ -32,6 +36,10 @@ export class CNBCore {
|
|||||||
this.cookie = options.cnb.cookie;
|
this.cookie = options.cnb.cookie;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (options?.cors?.baseUrl) {
|
||||||
|
this.baseURL = options.cors.baseUrl + '/' + this.baseURL;
|
||||||
|
this.hackURL = options.cors.baseUrl + '/' + this.hackURL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async request({ url, method = 'GET', data, params, headers, body, useCookie, useOrigin }: RequestOptions): Promise<any> {
|
async request({ url, method = 'GET', data, params, headers, body, useCookie, useOrigin }: RequestOptions): Promise<any> {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export class Repo extends CNBCore {
|
|||||||
return this.post({ url, data: postData });
|
return this.post({ url, data: postData });
|
||||||
}
|
}
|
||||||
deleteRepo(name: string): Promise<any> {
|
deleteRepo(name: string): Promise<any> {
|
||||||
const url = `https://cnb.cool/${name}`;
|
const url = `${this.hackURL}/${name}`;
|
||||||
return this.delete({ url, useCookie: true });
|
return this.delete({ url, useCookie: true });
|
||||||
}
|
}
|
||||||
async createCommit(repo: string, data: CreateCommitData): Promise<any> {
|
async createCommit(repo: string, data: CreateCommitData): Promise<any> {
|
||||||
@@ -38,7 +38,7 @@ export class Repo extends CNBCore {
|
|||||||
if (!data.parent_commit_sha && preCommitSha) {
|
if (!data.parent_commit_sha && preCommitSha) {
|
||||||
data.parent_commit_sha = preCommitSha;
|
data.parent_commit_sha = preCommitSha;
|
||||||
}
|
}
|
||||||
const url = `https://cnb.cool/${repo}/-/git/commits`;
|
const url = `${this.hackURL}/${repo}/-/git/commits`;
|
||||||
const postData: CreateCommitData = {
|
const postData: CreateCommitData = {
|
||||||
...data,
|
...data,
|
||||||
base_branch: data.base_branch || 'refs/heads/main',
|
base_branch: data.base_branch || 'refs/heads/main',
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export class User extends CNBCore {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getCurrentUser(): Promise<Result<UserInfo>> {
|
getCurrentUser(): Promise<Result<UserInfo>> {
|
||||||
const url = `https://cnb.cool/user`;
|
const url = `${this.hackURL}/user`;
|
||||||
return this.get({
|
return this.get({
|
||||||
url,
|
url,
|
||||||
useCookie: true,
|
useCookie: true,
|
||||||
@@ -26,7 +26,7 @@ export class User extends CNBCore {
|
|||||||
}
|
}
|
||||||
createAccessToken(data?: { description?: string, scope?: string }): Promise<AccessTokenResponse> {
|
createAccessToken(data?: { description?: string, scope?: string }): Promise<AccessTokenResponse> {
|
||||||
const scope = data?.scope || 'mission-manage:rw,mission-delete:rw,group-delete:rw,group-manage:rw,group-resource:rw,account-engage:rw,account-email:r,account-profile:rw,registry-delete:rw,registry-manage:rw,registry-package-delete:rw,registry-package:rw,repo-security:r,repo-delete:rw,repo-manage:rw,repo-basic-info:r,repo-cnb-detail:rw,repo-cnb-history:r,repo-cnb-trigger:rw,repo-commit-status:rw,repo-contents:rw,repo-notes:rw,repo-issue:rw,repo-pr:rw,repo-code:rw'
|
const scope = data?.scope || 'mission-manage:rw,mission-delete:rw,group-delete:rw,group-manage:rw,group-resource:rw,account-engage:rw,account-email:r,account-profile:rw,registry-delete:rw,registry-manage:rw,registry-package-delete:rw,registry-package:rw,repo-security:r,repo-delete:rw,repo-manage:rw,repo-basic-info:r,repo-cnb-detail:rw,repo-cnb-history:r,repo-cnb-trigger:rw,repo-commit-status:rw,repo-contents:rw,repo-notes:rw,repo-issue:rw,repo-pr:rw,repo-code:rw'
|
||||||
const url = 'https://cnb.cool/user/personal_access_tokens'
|
const url = `${this.hackURL}/user/personal_access_tokens`
|
||||||
return this.post({
|
return this.post({
|
||||||
url,
|
url,
|
||||||
useCookie: true,
|
useCookie: true,
|
||||||
@@ -37,7 +37,7 @@ export class User extends CNBCore {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
getAccessTokens(params?: { page?: number, page_size?: number }): Promise<AccessTokenResponse[]> {
|
getAccessTokens(params?: { page?: number, page_size?: number }): Promise<AccessTokenResponse[]> {
|
||||||
const url = 'https://cnb.cool/user/personal_access_tokens'
|
const url = `${this.hackURL}/user/personal_access_tokens`
|
||||||
return this.get({
|
return this.get({
|
||||||
url,
|
url,
|
||||||
useCookie: true,
|
useCookie: true,
|
||||||
@@ -49,7 +49,7 @@ export class User extends CNBCore {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
deleteAccessToken(tokenId: string): Promise<any> {
|
deleteAccessToken(tokenId: string): Promise<any> {
|
||||||
const url = `https://cnb.cool/user/personal_access_tokens/${tokenId}`
|
const url = `${this.hackURL}/user/personal_access_tokens/${tokenId}`
|
||||||
return this.delete({
|
return this.delete({
|
||||||
url,
|
url,
|
||||||
useCookie: true,
|
useCookie: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user