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 { CommentFields } from "./comment.ts"; import type { EventFields } from "./event.ts"; import type { InsightsResultFields } from "./insights-result.ts"; import type { PageFields } from "./page.ts"; import type { PlaceFields } from "./place.ts"; import type { PrivacyFields } from "./privacy.ts"; import type { ProfileFields } from "./profile.ts"; import type { RTBDynamicPostFields } from "./rtb-dynamic-post.ts"; import type { PostBackdatedTimeGranularity, PostFeedStoryVisibility, PostTimelineVisibility } from "../enums.ts"; export interface PostFields { actions: unknown[]; admin_creator: Record; allowed_advertising_objectives: string[]; application: ApplicationFields; backdated_time: string; call_to_action: Record; can_reply_privately: boolean; caption: string; child_attachments: unknown[]; comments_mirroring_domain: string; coordinates: Record; created_time: string; description: string; event: EventFields; expanded_height: number; expanded_width: number; feed_targeting: Record; from: Record; full_picture: string; height: number; icon: string; id: string; instagram_eligibility: string; is_app_share: boolean; is_eligible_for_dark_post: boolean; is_eligible_for_promotion: boolean; is_expired: boolean; is_hidden: boolean; is_inline_created: boolean; is_instagram_eligible: boolean; is_popular: boolean; is_published: boolean; is_spherical: boolean; link: string; message: string; message_tags: unknown[]; multi_share_end_card: boolean; multi_share_optimized: boolean; name: string; object_id: string; parent_id: string; permalink_url: string; picture: string; place: PlaceFields; privacy: PrivacyFields; promotable_id: string; promotion_status: string; properties: unknown[]; scheduled_publish_time: number; shares: Record; source: string; status_type: string; story: string; story_tags: unknown[]; subscribed: boolean; target: ProfileFields; targeting: Record; timeline_visibility: string; type: string; updated_time: string; via: Record; video_buying_eligibility: string[]; width: number; } export interface PostListCommentsParams { filter?: string; live_filter?: string; order?: string; since?: string; [key: string]: unknown; } export interface PostCreateCommentsParams { attachment_id?: string; attachment_share_url?: string; attachment_url?: string; comment?: string; comment_privacy_value?: string; feedback_source?: string; message?: string; nectar_module?: string; parent_comment_id?: Record; post_id?: string; tracking?: string; [key: string]: unknown; } export interface PostListInsightsParams { date_preset?: string; metric?: Record[]; period?: string; since?: string; until?: string; [key: string]: unknown; } export interface PostDeleteLikesParams { nectar_module?: string; tracking?: string; [key: string]: unknown; } export interface PostCreateLikesParams { feedback_source?: string; nectar_module?: string; tracking?: string; [key: string]: unknown; } export interface PostListReactionsParams { type?: string; [key: string]: unknown; } export interface PostUpdateParams { attached_media?: Record[]; backdated_time?: string; backdated_time_granularity?: PostBackdatedTimeGranularity; composer_session_id?: string; direct_share_status?: number; explicitly_added_mentionee_ids?: number[]; feed_story_visibility?: PostFeedStoryVisibility; is_explicit_location?: boolean; is_hidden?: boolean; is_pinned?: boolean; is_published?: boolean; message?: string; og_action_type_id?: string; og_hide_object_attachment?: boolean; og_icon_id?: string; og_object_id?: string; og_phrase?: string; og_set_profile_badge?: boolean; og_suggestion_mechanism?: string; place?: Record; privacy?: string; product_item?: Record; scheduled_publish_time?: number; should_sync_product_edit?: boolean; source_type?: string; sponsor_id?: string; sponsor_relationship?: number; tags?: number[]; text_format_preset_id?: string; timeline_visibility?: PostTimelineVisibility; tracking?: string; [key: string]: unknown; } export function postNode(client: ApiClient, id: string) { return { __path: id, __brand: undefined as unknown as PostFields, get: (opts: { fields: F; params?: Record }) => client.get>(`${id}`, opts), update: (params: PostUpdateParams) => client.post(`${id}`, params as Record), delete: () => client.delete(`${id}`, {}), attachments: )[]>(opts: { fields: F; params?: Record }) => new Cursor, F[number]>>(client, `${id}/attachments`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), comments: { __path: `${id}/comments`, __brand: undefined as unknown as CommentFields, list: (opts: { fields: F; params?: PostListCommentsParams }) => new Cursor>(client, `${id}/comments`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), create: (params: PostCreateCommentsParams) => client.post(`${id}/comments`, params as Record), }, dynamicPosts: (opts: { fields: F; params?: Record }) => new Cursor>(client, `${id}/dynamic_posts`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), insights: (opts: { fields: F; params?: PostListInsightsParams }) => new Cursor>(client, `${id}/insights`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), likes: { __path: `${id}/likes`, __brand: undefined as unknown as PostFields, create: (params: PostCreateLikesParams) => client.post(`${id}/likes`, params as Record), delete: (params: PostDeleteLikesParams) => client.delete(`${id}/likes`, params as Record ?? {}), }, reactions: (opts: { fields: F; params?: PostListReactionsParams }) => new Cursor>(client, `${id}/reactions`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), sharedposts: (opts: { fields: F; params?: Record }) => new Cursor>(client, `${id}/sharedposts`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), sponsorTags: (opts: { fields: F; params?: Record }) => new Cursor>(client, `${id}/sponsor_tags`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), to: (opts: { fields: F; params?: Record }) => new Cursor>(client, `${id}/to`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), }; }