export type ConfigLevel = 'main' | 'global' | 'repository' | 'directory'; export type PullRequestMessageStatus = 'every_push' | 'only_when_opened' | 'off' | 'active' | 'inactive'; export type PullRequestMessageContentUpsertDto = {content: string, status: PullRequestMessageStatus}; export type PullRequestMessagesGlobalSettingsUpsertDto = {hideComments?: boolean | undefined, suggestionCopyPrompt?: boolean | undefined}; export type PullRequestMessagesUpsertDto = {organizationId?: string | undefined, configLevel: ConfigLevel, repositoryId?: string | undefined, directoryId?: string | undefined, startReviewMessage?: PullRequestMessageContentUpsertDto | undefined, endReviewMessage?: PullRequestMessageContentUpsertDto | undefined, globalSettings?: PullRequestMessagesGlobalSettingsUpsertDto | undefined}; export type CreateApiPullRequestMessagesArgs = {body: PullRequestMessagesUpsertDto}; export type CreateApiPullRequestMessagesOptions = {baseUrl?: string | undefined, jwt?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create or update PR messages * * POST /pull-request-messages */ export const createApiPullRequestMessages = async (args: CreateApiPullRequestMessagesArgs, options?: CreateApiPullRequestMessagesOptions) => { const {baseUrl = "http://localhost:3001", fetch: fetchFn = fetch, jwt} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (jwt !== undefined) headers.set('authorization', `Bearer ${jwt}`) const url = `${baseUrl.replace(/\/+$/, '')}/pull-request-messages${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };