mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 02:00:31 +08:00
@@ -94,12 +94,17 @@ export class Fetcher {
|
||||
): Promise<TypeOf<T>> {
|
||||
const response = await this.fetch(params);
|
||||
|
||||
const responseBody = await response.json();
|
||||
|
||||
if (!response.ok) {
|
||||
let responseBody = await response.text();
|
||||
try {
|
||||
responseBody = JSON.parse(responseBody);
|
||||
} catch (_e: unknown) {
|
||||
// We keep the original text response body.
|
||||
}
|
||||
throw new ResponseError(params.method, response, responseBody);
|
||||
}
|
||||
|
||||
const responseBody = await response.json();
|
||||
const result = schema.safeParse(responseBody);
|
||||
if (result.success) {
|
||||
return result.data;
|
||||
|
||||
@@ -372,6 +372,7 @@ export class Client {
|
||||
title: string;
|
||||
description: string;
|
||||
assignees: string[];
|
||||
embeds: { name: string; content: string }[];
|
||||
labels: string[];
|
||||
},
|
||||
authToken: string,
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
import type { ZodSchema } from "zod";
|
||||
import type { z } from "zod";
|
||||
import { array, number, object, string, tuple } from "zod";
|
||||
|
||||
export interface Comment {
|
||||
id: string;
|
||||
author: { id: string; alias?: string };
|
||||
body: string;
|
||||
reactions: [string, string][];
|
||||
timestamp: number;
|
||||
replyTo: string | null;
|
||||
}
|
||||
export type Comment = z.infer<typeof commentSchema>;
|
||||
|
||||
export const commentSchema = object({
|
||||
id: string(),
|
||||
author: object({ id: string(), alias: string().optional() }),
|
||||
body: string(),
|
||||
embeds: array(object({ name: string(), content: string() })),
|
||||
reactions: array(tuple([string(), string()])),
|
||||
timestamp: number(),
|
||||
replyTo: string().nullable(),
|
||||
}) satisfies ZodSchema<Comment>;
|
||||
});
|
||||
|
||||
@@ -56,7 +56,12 @@ export type IssueUpdateAction =
|
||||
assignees: string[];
|
||||
}
|
||||
| { type: "lifecycle"; state: IssueState }
|
||||
| { type: "comment"; body: string; replyTo: string }
|
||||
| {
|
||||
type: "comment";
|
||||
body: string;
|
||||
embeds: { name: string; content: string }[];
|
||||
replyTo: string;
|
||||
}
|
||||
| { type: "comment.edit"; id: string; body: string }
|
||||
| { type: "comment.redact"; id: string }
|
||||
| {
|
||||
|
||||
@@ -120,6 +120,7 @@ describe("project", () => {
|
||||
title: "aaa",
|
||||
description: "bbb",
|
||||
assignees: [],
|
||||
embeds: [],
|
||||
labels: ["bug", "documentation"],
|
||||
},
|
||||
sessionId,
|
||||
|
||||
@@ -11,7 +11,7 @@ export async function createIssueToBeModified(
|
||||
) {
|
||||
const { id } = await api.project.createIssue(
|
||||
cobRid,
|
||||
{ title: "aaa", description: "bbb", assignees: [], labels: [] },
|
||||
{ title: "aaa", description: "bbb", embeds: [], assignees: [], labels: [] },
|
||||
sessionId,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user