feat: Add missing comments.info endpoint, fix misnamed types
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
import { z } from "zod";
|
||||
import { BaseSchema, ProsemirrorSchema } from "@server/routes/api/schema";
|
||||
|
||||
const CollectionsSortParamsSchema = z.object({
|
||||
/** Specifies the attributes by which documents will be sorted in the list */
|
||||
const BaseIdSchema = z.object({
|
||||
/** Comment Id */
|
||||
id: z.string().uuid(),
|
||||
});
|
||||
|
||||
const CommentsSortParamsSchema = z.object({
|
||||
/** Specifies the attributes by which comments will be sorted in the list */
|
||||
sort: z
|
||||
.string()
|
||||
.refine((val) => ["createdAt", "updatedAt"].includes(val))
|
||||
@@ -34,10 +39,7 @@ export const CommentsCreateSchema = BaseSchema.extend({
|
||||
export type CommentsCreateReq = z.infer<typeof CommentsCreateSchema>;
|
||||
|
||||
export const CommentsUpdateSchema = BaseSchema.extend({
|
||||
body: z.object({
|
||||
/** Which comment to update */
|
||||
id: z.string().uuid(),
|
||||
|
||||
body: BaseIdSchema.extend({
|
||||
/** Update comment with this data */
|
||||
data: ProsemirrorSchema,
|
||||
}),
|
||||
@@ -46,20 +48,23 @@ export const CommentsUpdateSchema = BaseSchema.extend({
|
||||
export type CommentsUpdateReq = z.infer<typeof CommentsUpdateSchema>;
|
||||
|
||||
export const CommentsDeleteSchema = BaseSchema.extend({
|
||||
body: z.object({
|
||||
/** Which comment to delete */
|
||||
id: z.string().uuid(),
|
||||
}),
|
||||
body: BaseIdSchema,
|
||||
});
|
||||
|
||||
export type CommentsDeleteReq = z.infer<typeof CommentsDeleteSchema>;
|
||||
|
||||
export const CollectionsListSchema = BaseSchema.extend({
|
||||
body: CollectionsSortParamsSchema.extend({
|
||||
export const CommentsListSchema = BaseSchema.extend({
|
||||
body: CommentsSortParamsSchema.extend({
|
||||
/** Id of a document to list comments for */
|
||||
documentId: z.string().optional(),
|
||||
collectionId: z.string().uuid().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
export type CollectionsListReq = z.infer<typeof CollectionsListSchema>;
|
||||
export type CommentsListReq = z.infer<typeof CommentsListSchema>;
|
||||
|
||||
export const CommentsInfoSchema = z.object({
|
||||
body: BaseIdSchema,
|
||||
});
|
||||
|
||||
export type CommentsInfoReq = z.infer<typeof CommentsInfoSchema>;
|
||||
|
||||
Reference in New Issue
Block a user