@rnaga/wp-node
Version:
👉 **[View Full Documentation at rnaga.github.io/wp-node →](https://rnaga.github.io/wp-node/)**
104 lines • 3.44 kB
TypeScript
import { z } from "zod";
import { Comment } from "../core/comment";
import { Components } from "../core/components";
import { CommentUtil } from "../core/utils/comment.util";
import { PostUtil } from "../core/utils/post.util";
import * as val from "../validators";
import { Crud } from "./crud";
type DataUpsert = z.infer<typeof val.trx.commentUpsert>;
type DataBaseType = {
comment_parent: number;
post_comment_count: number;
post_title: string;
post_type: string;
post_guid: string;
post_author: number;
post_status: string;
user_display_name?: string;
parent_comment_author?: string;
parent_user_display_name?: string;
parent_user_id: number;
children?: Awaited<ReturnType<InstanceType<typeof Comment>["children"]>>;
count_children: number;
};
type DataType<T extends "view" | "edit" | "embed"> = T extends "edit" ? DataBaseType & Comment["props"] & {
metas: Record<string, any>;
} : DataBaseType & {
comment_ID: number;
comment_post_ID: number;
comment_author: string;
comment_date: string;
comment_date_gmt: string;
comment_content: string;
comment_approved: string;
comment_type: string;
user_id: number;
};
export declare class CommentCrud extends Crud {
private commentUtil;
private postUtil;
constructor(components: Components, commentUtil: CommentUtil, postUtil: PostUtil);
private canReadPostComment;
private canRead;
private canEdit;
private formReturnData;
getAsUpsert(commentId: number): Promise<{
data: {
comment_date: string | undefined;
comment_date_gmt: string | undefined;
comment_post_ID: number;
comment_karma: number;
comment_agent: string;
comment_type: string;
comment_parent: number;
user_id: number;
comment_author: string;
comment_approved: number | "trash" | "0" | "1" | "spam" | "post-trashed" | "approve" | "hold";
comment_content: string;
comment_meta: Record<string, any>;
comment_author_email?: string | undefined;
comment_author_url?: string | undefined;
comment_author_IP?: string | undefined;
comment_ID?: number | undefined;
};
info: undefined;
}>;
get<T extends "view" | "edit" | "embed">(commentId: number, options?: Partial<{
context: T;
password: string;
}>): Promise<{
data: DataType<T>;
info: undefined;
}>;
create(data: Partial<DataUpsert>, options?: Partial<{
remoteIp: string;
}>): Promise<{
data: number;
info: undefined;
}>;
update(commentId: number, data: Partial<DataUpsert>): Promise<{
data: number;
info: undefined;
}>;
delete(commentId: number, force?: boolean): Promise<{
data: boolean;
info: undefined;
}>;
list<T extends "view" | "edit" | "embed">(args?: Partial<z.infer<typeof val.crud.commentListParams>>, options?: {
context?: T;
password?: string;
limitChildren?: number;
}): Promise<{
data: DataType<T>[];
info: {
pagination: {
page: number;
limit: number;
totalPage: number;
count: number;
};
};
}>;
}
export {};
//# sourceMappingURL=comment.crud.d.ts.map