23 lines
714 B
TypeScript
23 lines
714 B
TypeScript
import { CNBCore, CNBCoreOptions, RequestOptions, Result } from "../cnb-core.ts";
|
|
type AiOptions = CNBCoreOptions<{
|
|
group?: string;
|
|
}>
|
|
class AiBase extends CNBCore {
|
|
group: string;
|
|
constructor(options: AiOptions) {
|
|
super({ token: options.token, cookie: options.cookie });
|
|
this.group = options.group || '';
|
|
}
|
|
autoPr(repo: string, data: { body: string, branch?: string, title: string }): Promise<Result<any>> {
|
|
const group = this.group || '';
|
|
const url = `/${group}/${repo}/-/build/ai/auto-pr`;
|
|
const postData = {
|
|
...data,
|
|
branch: data.branch || 'refs/heads/main',
|
|
title: data.title || ''
|
|
};
|
|
return this.post({ url, data: postData });
|
|
}
|
|
}
|
|
|
|
export { AiBase }; |