import type { ApiClient } from "@promobase/sdk-runtime"; import { Cursor } from "@promobase/sdk-runtime"; import { metaPagination } from "../../pagination.ts"; import type { CommentFields } from "./comment.ts"; import type { PrivacyFields } from "./privacy.ts"; import type { ProfileFields } from "./profile.ts"; export interface LinkFields { caption: string; created_time: string; description: string; from: Record; icon: string; id: string; link: string; message: string; multi_share_optimized: boolean; name: string; privacy: PrivacyFields; via: Record; } export interface LinkCreateCommentsParams { 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 function linkNode(client: ApiClient, id: string) { return { __path: id, __brand: undefined as unknown as LinkFields, get: (opts: { fields: F; params?: Record }) => client.get>(`${id}`, opts), createComment: (params: LinkCreateCommentsParams) => client.post(`${id}/comments`, params as Record), likes: (opts: { fields: F; params?: Record }) => new Cursor>(client, `${id}/likes`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), }; }