import type { ApiClient } from "@promobase/sdk-runtime"; import { Cursor } from "@promobase/sdk-runtime"; import { metaPagination } from "../../pagination.ts"; import type { ApplicationFields } from "./application.ts"; import type { EntityAtTextRangeFields } from "./entity-at-text-range.ts"; import type { ProfileFields } from "./profile.ts"; import type { UserFields } from "./user.ts"; export interface CommentFields { admin_creator: UserFields; application: ApplicationFields; attachment: Record; can_comment: boolean; can_hide: boolean; can_like: boolean; can_remove: boolean; can_reply_privately: boolean; comment_count: number; created_time: string; from: Record; id: string; is_hidden: boolean; is_private: boolean; like_count: number; live_broadcast_timestamp: number; message: string; message_tags: EntityAtTextRangeFields[]; object: Record; parent: CommentFields; permalink_url: string; private_reply_conversation: Record; user_likes: boolean; } export interface CommentListCommentsParams { filter?: string; live_filter?: string; order?: string; since?: string; [key: string]: unknown; } export interface CommentCreateCommentsParams { attachment_id?: string; attachment_share_url?: string; attachment_url?: string; comment_privacy_value?: string; facepile_mentioned_ids?: string[]; feedback_source?: string; is_offline?: boolean; message?: string; nectar_module?: string; object_id?: string; parent_comment_id?: Record; text?: string; tracking?: string; [key: string]: unknown; } export interface CommentDeleteLikesParams { feedback_source?: string; nectar_module?: string; tracking?: string; [key: string]: unknown; } export interface CommentCreateLikesParams { feedback_source?: string; nectar_module?: string; tracking?: string; [key: string]: unknown; } export interface CommentListReactionsParams { type?: string; [key: string]: unknown; } export interface CommentUpdateParams { attachment_id?: string; attachment_share_url?: string; attachment_url?: string; is_hidden?: boolean; message?: string; [key: string]: unknown; } export function commentNode(client: ApiClient, id: string) { return { __path: id, __brand: undefined as unknown as CommentFields, get: (opts: { fields: F; params?: Record }) => client.get>(`${id}`, opts), update: (params: CommentUpdateParams) => client.post(`${id}`, params as Record), delete: () => client.delete(`${id}`, {}), comments: { __path: `${id}/comments`, __brand: undefined as unknown as CommentFields, list: (opts: { fields: F; params?: CommentListCommentsParams }) => new Cursor>(client, `${id}/comments`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), create: (params: CommentCreateCommentsParams) => client.post(`${id}/comments`, params as Record), }, likes: { __path: `${id}/likes`, __brand: undefined as unknown as ProfileFields, list: (opts: { fields: F; params?: Record }) => new Cursor>(client, `${id}/likes`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), create: (params: CommentCreateLikesParams) => client.post(`${id}/likes`, params as Record), delete: (params: CommentDeleteLikesParams) => client.delete(`${id}/likes`, params as Record ?? {}), }, reactions: (opts: { fields: F; params?: CommentListReactionsParams }) => new Cursor>(client, `${id}/reactions`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), }; }