mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-16 03:40:37 +08:00
Add createPatch method to the project.Client
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
@@ -5,7 +5,12 @@ import type {
|
||||
IssueCreated,
|
||||
IssueUpdateAction,
|
||||
} from "./project/issue.js";
|
||||
import type { Patch, PatchUpdateAction } from "./project/patch.js";
|
||||
import type {
|
||||
Patch,
|
||||
PatchCreate,
|
||||
PatchCreated,
|
||||
PatchUpdateAction,
|
||||
} from "./project/patch.js";
|
||||
import type { SuccessResponse } from "./shared.js";
|
||||
import type { ZodSchema } from "zod";
|
||||
|
||||
@@ -35,7 +40,11 @@ import {
|
||||
issuesSchema,
|
||||
} from "./project/issue.js";
|
||||
|
||||
import { patchSchema, patchesSchema } from "./project/patch.js";
|
||||
import {
|
||||
patchSchema,
|
||||
patchesSchema,
|
||||
patchCreatedSchema,
|
||||
} from "./project/patch.js";
|
||||
|
||||
export interface Project {
|
||||
id: string;
|
||||
@@ -469,6 +478,24 @@ export class Client {
|
||||
);
|
||||
}
|
||||
|
||||
public async createPatch(
|
||||
id: string,
|
||||
body: PatchCreate,
|
||||
authToken: string,
|
||||
options?: RequestOptions,
|
||||
): Promise<PatchCreated> {
|
||||
return this.#fetcher.fetchOk(
|
||||
{
|
||||
method: "POST",
|
||||
path: `projects/${id}/patches`,
|
||||
headers: { Authorization: `Bearer ${authToken}` },
|
||||
body,
|
||||
options,
|
||||
},
|
||||
patchCreatedSchema,
|
||||
);
|
||||
}
|
||||
|
||||
public async updatePatch(
|
||||
id: string,
|
||||
patchId: string,
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import type { Comment, ThreadUpdateAction } from "./comment.js";
|
||||
import type { ZodSchema } from "zod";
|
||||
import type { ZodSchema, z } from "zod";
|
||||
|
||||
import { commentSchema } from "./comment.js";
|
||||
|
||||
import {
|
||||
array,
|
||||
boolean,
|
||||
literal,
|
||||
number,
|
||||
optional,
|
||||
@@ -136,3 +137,20 @@ export type PatchUpdateAction =
|
||||
}
|
||||
| { type: "merge"; revision: string; commit: string }
|
||||
| { type: "thread"; revision: string; action: ThreadUpdateAction };
|
||||
|
||||
export const patchCreateSchema = object({
|
||||
title: string(),
|
||||
description: string(),
|
||||
target: string(),
|
||||
oid: string(),
|
||||
tags: array(string()),
|
||||
});
|
||||
|
||||
export type PatchCreate = z.infer<typeof patchCreateSchema>;
|
||||
|
||||
export const patchCreatedSchema = object({
|
||||
success: boolean(),
|
||||
id: string(),
|
||||
});
|
||||
|
||||
export type PatchCreated = z.infer<typeof patchCreatedSchema>;
|
||||
|
||||
Reference in New Issue
Block a user