import {z} from 'zod' export type CreateApiProfilePostsCommentsArgs = {body: {profile_post_id: number, comment_body: string}}; export type CreateApiProfilePostsCommentsOptions = {baseUrl?: string | undefined, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; export const respUserModel = z.object({user_id: z.number().int(), username: z.string(), username_html: z.string(), user_message_count: z.number().int(), user_register_date: z.number().int(), user_like_count: z.number().int(), user_like2_count: z.number().int(), contest_count: z.number().int(), trophy_count: z.number().int(), short_link: z.string(), custom_title: z.string(), is_banned: z.number().int(), display_banner_id: z.number().int(), display_icon_group_id: z.number().int(), balance: z.string(), hold: z.string(), currency: z.string(), user_email: z.string(), user_unread_notification_count: z.number().int(), user_unread_conversation_count: z.number().int(), conv_welcome_message: z.string(), show_dob_dateshow_dob_date: z.number().int().optional(), show_dob_year: z.number().int(), user_title: z.string(), user_deposit: z.number().int(), user_is_valid: z.boolean(), user_is_verified: z.boolean(), user_is_followed: z.boolean(), user_last_seen_date: z.number().int(), links: z.object({permalink: z.string(), detail: z.string(), avatar: z.string(), avatar_big: z.string(), avatar_small: z.string(), followers: z.string(), followings: z.string(), ignore: z.string(), background_l: z.string(), background_m: z.string(), timeline: z.string()}), permissions: z.object({edit: z.boolean(), follow: z.boolean(), create_conversation: z.boolean(), ignore: z.boolean(), profile_post: z.boolean()}), user_is_ignored: z.boolean(), user_is_visitor: z.boolean(), user_group_id: z.number().int(), curator_titles: z.array(z.string()), user_groups: z.array(z.object({user_group_id: z.number().int(), user_group_title: z.string(), user_group_title_en: z.string(), user_group_banner_css_class: z.string(), user_group_banner_text: z.string(), user_group_banner_text_en: z.string(), display_group_selectable: z.boolean(), display_banner_selectable: z.boolean(), display_icon_selectable: z.boolean(), is_primary_group: z.boolean(), user_group_icon_class: z.string()})), fields: z.array(z.object({id: z.string(), title: z.string(), description: z.string(), position: z.string(), is_required: z.boolean(), is_system: z.boolean(), value: z.string().optional(), editable: z.boolean(), is_multi_choice: z.boolean(), choices: z.array(z.object({key: z.string(), value: z.string()})), values: z.array(z.unknown())})), user_timezone_offset: z.number().int(), user_external_authentications: z.array(z.object({provider: z.string(), provider_key: z.string()})), self_permissions: z.object({create_conversation: z.boolean()}), edit_permissions: z.object({password: z.boolean(), user_email: z.boolean(), username: z.boolean(), user_title: z.boolean(), short_link: z.boolean(), hide_username_logs: z.boolean(), primary_group_id: z.boolean(), secondary_group_ids: z.boolean(), user_dob_day: z.boolean(), user_dob_month: z.boolean(), user_dob_year: z.boolean(), fields: z.boolean()}), birthday: z.object({age: z.number().int(), timeStamp: z.object({date: z.string(), timezone_type: z.number().int(), timezone: z.string()}), format: z.string()}).nullable(), secret_answer_rendered: z.string(), secret_answer_first_letter: z.string(), user_following: z.object({users: z.array(z.object({user_id: z.number().int(), username: z.string(), username_html: z.string(), avatar: z.string()})), count: z.number().int()}), user_followers: z.object({users: z.array(z.object({user_id: z.number().int(), username: z.string(), username_html: z.string(), avatar: z.string()})), count: z.number().int()}), profile_threads: z.array(z.object({thread_id: z.number().int(), forum_id: z.number().int(), thread_title: z.string(), thread_view_count: z.number().int(), creator_user_id: z.number().int(), creator_username: z.string(), creator_username_html: z.string(), thread_create_date: z.number().int(), thread_update_date: z.number().int(), thread_reply_group_id: z.number().int(), thread_comment_ignore_group: z.number().int(), thread_last_bump_date: z.number().int(), thread_hide_contacts: z.number().int(), thread_allow_ask_hidden_content: z.number().int(), user_is_ignored: z.boolean(), thread_post_count: z.number().int(), thread_is_bumped: z.boolean(), thread_is_published: z.boolean(), thread_is_deleted: z.boolean(), thread_is_sticky: z.boolean(), thread_is_closed: z.boolean(), thread_is_followed: z.boolean(), thread_is_starred: z.boolean(), thread_prefixes: z.array(z.unknown()), thread_tags: z.object({"38": z.string(), "523": z.string(), "1403": z.string(), "1953": z.string(), "8176": z.string()}), links: z.object({permalink: z.string(), detail: z.string(), followers: z.string(), forum: z.string(), posts: z.string(), first_poster: z.string(), first_poster_avatar: z.string(), first_post: z.string(), last_post: z.string()}), permissions: z.object({view: z.boolean(), delete: z.boolean(), follow: z.boolean(), post: z.boolean(), bump: z.object({can: z.boolean(), available_count: z.number().int(), error: z.unknown(), next_available_time: z.unknown()})}), node_title: z.string()})), banner: z.string()}); export const respProfilePostCommentModel = z.object({can_edit: z.boolean(), can_hard_delete: z.boolean(), can_like: z.boolean(), can_report: z.boolean(), can_soft_delete: z.boolean(), can_undelete: z.boolean(), can_view: z.boolean(), comment_date: z.number().int(), is_ignored: z.boolean(), is_liked: z.boolean(), like_date: z.number().int(), likes: z.number().int(), message: z.string(), message_html: z.string(), message_plain_text: z.string(), message_state: z.string(), profile_post_comment_id: z.number().int(), profile_post_id: z.number().int(), user: respUserModel, user_id: z.number().int(), username: z.string(), view_url: z.string(), warning_id: z.number().int(), warning_message: z.string()}); export const respSystemInfo = z.object({visitor_id: z.number().int(), time: z.number().int(), log_id: z.number().int()}); export const createApiProfilePostsCommentsResponse = z.object({comment: respProfilePostCommentModel, system_info: respSystemInfo}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Create Profile Post Comment * * POST /profile-posts/comments */ export const createApiProfilePostsComments = async (args: CreateApiProfilePostsCommentsArgs, options?: CreateApiProfilePostsCommentsOptions) => { const {baseUrl = "https://api.lolz.team", fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/profile-posts/comments${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(createApiProfilePostsCommentsResponse, await res.json()) };