import {z} from 'zod' export type PagingRequest = {limit: number, page: number}; export type SortRequest = {sort_by?: ('relevancy' | 'engagement_rate' | 'number_of_followers' | 'growth_rate') | undefined, sort_order?: ('asc' | 'desc') | undefined}; export type RangeRequest = {min?: (number | null) | undefined, max?: (number | null) | undefined}; export type GrowthRequest = {growth_percentage?: (number | null) | undefined, time_range_months?: (number | null) | undefined}; export type AudienceLocationFilterRequest = {name?: (string | null) | undefined, type?: ('country' | 'state' | 'city' | null) | undefined, min_pct?: (number | null) | undefined}; export type AudienceGenderFilterRequest = {type?: string | undefined, min_pct?: (number | null) | undefined}; export type AudienceLanguageFilterRequest = {language_abbr?: (string | null) | undefined, min_pct?: (number | null) | undefined}; export type AudienceAgeFilterRequest = {range?: ('13-17' | '18-24' | '25-34' | '35-44' | '45-64' | '65-' | '65+' | null) | undefined, min_pct?: (number | null) | undefined}; export type AudienceInterestFilterRequest = {name?: (string | null) | undefined, min_pct?: (number | null) | undefined}; export type AudienceFilterRequest = {location?: (Array | null) | undefined, gender?: (AudienceGenderFilterRequest | null) | undefined, language?: (Array | null) | undefined, age?: (Array | null) | undefined, interests?: (Array | null) | undefined, brands?: (Array | null) | undefined, brand_categories?: (Array | null) | undefined, credibility?: ('bad' | 'low' | 'normal' | 'good' | 'high' | 'best' | null) | undefined}; export type CreatorHasRequest = {has_amazonaffiliates?: (boolean | null) | undefined, has_applemusic?: (boolean | null) | undefined, has_bandcamp?: (boolean | null) | undefined, has_behance?: (boolean | null) | undefined, has_buymeacoffee?: (boolean | null) | undefined, has_cameo?: (boolean | null) | undefined, has_canva?: (boolean | null) | undefined, has_clubhouse?: (boolean | null) | undefined, has_discord?: (boolean | null) | undefined, has_dribbble?: (boolean | null) | undefined, has_etsy?: (boolean | null) | undefined, has_facebook?: (boolean | null) | undefined, has_fiverr?: (boolean | null) | undefined, has_github?: (boolean | null) | undefined, has_gofundme?: (boolean | null) | undefined, has_goodreads?: (boolean | null) | undefined, has_instagram?: (boolean | null) | undefined, has_kakao?: (boolean | null) | undefined, has_kickstarter?: (boolean | null) | undefined, has_kofi?: (boolean | null) | undefined, has_linkedin?: (boolean | null) | undefined, has_linktree?: (boolean | null) | undefined, has_medium?: (boolean | null) | undefined, has_onlyfans?: (boolean | null) | undefined, has_patreon?: (boolean | null) | undefined, has_personal_website?: (boolean | null) | undefined, has_phone?: (boolean | null) | undefined, has_pinterest?: (boolean | null) | undefined, has_podcast?: (boolean | null) | undefined, has_redbubble?: (boolean | null) | undefined, has_shopify?: (boolean | null) | undefined, has_shopltk?: (boolean | null) | undefined, has_snapchat?: (boolean | null) | undefined, has_spotify?: (boolean | null) | undefined, has_spring?: (boolean | null) | undefined, has_streamlabs?: (boolean | null) | undefined, has_substack?: (boolean | null) | undefined, has_telegram?: (boolean | null) | undefined, has_tiktok?: (boolean | null) | undefined, has_tumblr?: (boolean | null) | undefined, has_twitch?: (boolean | null) | undefined, has_twitter?: (boolean | null) | undefined, has_udemy?: (boolean | null) | undefined, has_viber?: (boolean | null) | undefined, has_vimeo?: (boolean | null) | undefined, has_vk?: (boolean | null) | undefined, has_weebly?: (boolean | null) | undefined, has_whatsApp?: (boolean | null) | undefined, has_youtube?: (boolean | null) | undefined, has_wix?: (boolean | null) | undefined, has_anchor?: (boolean | null) | undefined, has_soundcloud?: (boolean | null) | undefined, has_community?: (boolean | null) | undefined}; export type InstagramDiscoveryFilters = {location?: (Array) | undefined, type?: (string | null) | undefined, gender?: (string | null) | undefined, profile_language?: (Array) | undefined, ai_search?: (string | null) | undefined, keywords_in_bio?: (Array | null) | undefined, exclude_keywords_in_bio?: (Array | null) | undefined, hashtags?: (Array | null) | undefined, not_hashtags?: (Array | null) | undefined, keywords_in_captions?: (Array | null) | undefined, keywords_not_in_captions?: (Array | null) | undefined, link_in_bio?: (Array | null) | undefined, not_link_in_bio?: (Array | null) | undefined, number_of_followers?: (RangeRequest | null) | undefined, engagement_percent?: (RangeRequest | null) | undefined, average_likes?: (RangeRequest | null) | undefined, average_comments?: (RangeRequest | null) | undefined, number_of_posts?: (RangeRequest | null) | undefined, reels_percent?: (RangeRequest | null) | undefined, average_views_for_reels?: (RangeRequest | null) | undefined, posting_frequency?: (number | null) | undefined, follower_growth?: (GrowthRequest | null) | undefined, income?: (RangeRequest | null) | undefined, last_post?: (string | null) | undefined, has_videos?: (boolean | null) | undefined, exclude_private_profile?: (boolean | null) | undefined, is_verified?: (boolean | null) | undefined, niche?: (Array | null) | undefined, sub_niche?: (Array | null) | undefined, age_bracket?: (Array<'18-24' | '25-34' | '35-44' | '45-60' | '60+'> | null) | undefined, brands?: (Array | null) | undefined, audience?: (AudienceFilterRequest | null) | undefined, creator_has?: CreatorHasRequest | undefined, promotes_affiliate_links?: (boolean | null) | undefined, has_done_brand_deals?: (boolean | null) | undefined, has_link_in_bio?: (boolean | null) | undefined, does_live_streaming?: (boolean | null) | undefined, has_merch?: (boolean | null) | undefined, exclude_role_based_emails?: (boolean | null) | undefined, exclude_handles?: Array | undefined, exclude_list?: Array | undefined, exclude_default_list?: boolean | undefined, exclude_all_lists?: boolean | undefined}; export type DiscoveryInstagramRequest = {platform: 'instagram', nlp_search?: (string | null) | undefined, paging: PagingRequest, sort?: SortRequest | undefined, filters: InstagramDiscoveryFilters}; export type YouTubeDiscoveryFilters = {location?: (Array) | undefined, type?: (string | null) | undefined, gender?: (string | null) | undefined, profile_language?: (Array) | undefined, ai_search?: (string | null) | undefined, keywords_in_description?: (Array | null) | undefined, keywords_not_in_description?: (Array | null) | undefined, keywords_in_video_description?: (Array | null) | undefined, keywords_not_in_video_description?: (Array | null) | undefined, keywords_in_video_titles?: (Array | null) | undefined, keywords_not_in_video_titles?: (Array | null) | undefined, hashtags?: (Array | null) | undefined, not_hashtags?: (Array | null) | undefined, topics?: (Array | null) | undefined, links_from_video_description?: (Array | null) | undefined, links_from_description?: (Array | null) | undefined, number_of_subscribers?: (RangeRequest | null) | undefined, engagement_percent?: (RangeRequest | null) | undefined, average_views_on_long_videos?: RangeRequest | undefined, median_views_long?: (RangeRequest | null) | undefined, average_views_on_shorts?: (RangeRequest | null) | undefined, number_of_videos?: (RangeRequest | null) | undefined, posting_frequency?: (number | null) | undefined, subscriber_growth?: (GrowthRequest | null) | undefined, is_verified?: (boolean | null) | undefined, last_upload_long_video?: (string | null) | undefined, last_upload_short_video?: (string | null) | undefined, has_shorts?: (boolean | null) | undefined, shorts_percentage?: (RangeRequest | null) | undefined, has_community_posts?: (boolean | null) | undefined, streams_live?: (boolean | null) | undefined, has_merch?: (boolean | null) | undefined, has_podcast?: (boolean | null) | undefined, has_courses?: (boolean | null) | undefined, has_membership?: (boolean | null) | undefined, has_live_videos?: (boolean | null) | undefined, is_monetizing?: (boolean | null) | undefined, income?: (RangeRequest | null) | undefined, long_video_duration?: (RangeRequest | null) | undefined, average_stream_views?: (RangeRequest | null) | undefined, average_stream_duration?: (RangeRequest | null) | undefined, last_stream_upload?: (string | null) | undefined, niche?: (Array | null) | undefined, sub_niche?: (Array | null) | undefined, age_bracket?: (Array<'18-24' | '25-34' | '35-44' | '45-60' | '60+'> | null) | undefined, brands?: (Array | null) | undefined, creator_has?: CreatorHasRequest | undefined, promotes_affiliate_links?: (boolean | null) | undefined, has_done_brand_deals?: (boolean | null) | undefined, has_link_in_bio?: (boolean | null) | undefined, does_live_streaming?: (boolean | null) | undefined, exclude_role_based_emails?: (boolean | null) | undefined, exclude_handles?: Array | undefined, exclude_list?: Array | undefined, exclude_default_list?: boolean | undefined, exclude_all_lists?: boolean | undefined}; export type DiscoveryYouTubeRequest = {platform: 'youtube', nlp_search?: (string | null) | undefined, paging: PagingRequest, sort?: SortRequest | undefined, filters: YouTubeDiscoveryFilters}; export type TikTokDiscoveryFilters = {location?: (Array) | undefined, type?: (string | null) | undefined, gender?: (string | null) | undefined, profile_language?: (Array) | undefined, ai_search?: (string | null) | undefined, keywords_in_bio?: (Array | null) | undefined, exclude_keywords_in_bio?: (Array | null) | undefined, link_in_bio?: (Array | null) | undefined, not_link_in_bio?: (Array | null) | undefined, hashtags?: (Array | null) | undefined, not_hashtags?: (Array | null) | undefined, video_description?: (Array | null) | undefined, not_video_description?: (Array | null) | undefined, last_post?: (string | null) | undefined, number_of_followers?: (RangeRequest | null) | undefined, video_count?: (RangeRequest | null) | undefined, engagement_percent?: (RangeRequest | null) | undefined, average_views?: (RangeRequest | null) | undefined, average_likes?: (RangeRequest | null) | undefined, average_comments?: (RangeRequest | null) | undefined, average_video_downloads?: (RangeRequest | null) | undefined, posting_frequency?: (number | null) | undefined, follower_growth?: (GrowthRequest | null) | undefined, has_tik_tok_shop?: (boolean | null) | undefined, exclude_private_profile?: (boolean | null) | undefined, is_verified?: (boolean | null) | undefined, niche?: (Array | null) | undefined, sub_niche?: (Array | null) | undefined, age_bracket?: (Array<'18-24' | '25-34' | '35-44' | '45-60' | '60+'> | null) | undefined, brands?: (Array | null) | undefined, creator_has?: CreatorHasRequest | undefined, promotes_affiliate_links?: (boolean | null) | undefined, has_done_brand_deals?: (boolean | null) | undefined, has_link_in_bio?: (boolean | null) | undefined, does_live_streaming?: (boolean | null) | undefined, has_merch?: (boolean | null) | undefined, exclude_role_based_emails?: (boolean | null) | undefined, exclude_handles?: Array | undefined, exclude_list?: Array | undefined, exclude_default_list?: boolean | undefined, exclude_all_lists?: boolean | undefined}; export type DiscoveryTikTokRequest = {platform: 'tiktok', nlp_search?: (string | null) | undefined, paging: PagingRequest, sort?: SortRequest | undefined, filters: TikTokDiscoveryFilters}; export type TwitterDiscoveryFilters = {location?: (Array) | undefined, type?: (string | null) | undefined, gender?: (string | null) | undefined, profile_language?: (Array) | undefined, ai_search?: (string | null) | undefined, keywords_in_bio?: (Array | null) | undefined, exclude_keywords_in_bio?: (Array | null) | undefined, hashtags?: (Array | null) | undefined, not_hashtags?: (Array | null) | undefined, number_of_followers?: (RangeRequest | null) | undefined, link_in_bio?: (Array | null) | undefined, not_link_in_bio?: (Array | null) | undefined, keywords_in_tweets?: (Array | null) | undefined, keywords_not_in_tweets?: (Array | null) | undefined, last_post?: (string | null) | undefined, tweets_count?: (RangeRequest | null) | undefined, engagement_percent?: (RangeRequest | null) | undefined, average_likes?: (RangeRequest | null) | undefined, brands?: (Array | null) | undefined, creator_has?: CreatorHasRequest | undefined, promotes_affiliate_links?: (boolean | null) | undefined, has_done_brand_deals?: (boolean | null) | undefined, has_link_in_bio?: (boolean | null) | undefined, does_live_streaming?: (boolean | null) | undefined, has_merch?: (boolean | null) | undefined, exclude_role_based_emails?: (boolean | null) | undefined, exclude_handles?: Array | undefined, exclude_list?: Array | undefined, exclude_default_list?: boolean | undefined, exclude_all_lists?: boolean | undefined}; export type DiscoveryTwitterRequest = {platform: 'twitter', nlp_search?: (string | null) | undefined, paging: PagingRequest, sort?: SortRequest | undefined, filters: TwitterDiscoveryFilters}; export type TwitchDiscoveryFilters = {location?: (Array) | undefined, gender?: (string | null) | undefined, profile_language?: (Array) | undefined, ai_search?: (string | null) | undefined, games_played?: (Array | null) | undefined, is_twitch_partner?: (boolean | null) | undefined, keywords_in_description?: (Array | null) | undefined, link_in_bio?: (Array | null) | undefined, not_link_in_bio?: (Array | null) | undefined, most_recent_stream_date?: (string | null) | undefined, followers?: (RangeRequest | null) | undefined, avg_views_last_30_days?: RangeRequest | undefined, streamed_hours_last_30_days?: (RangeRequest | null) | undefined, streams_count_last_30_days?: (RangeRequest | null) | undefined, maximum_views_count?: (RangeRequest | null) | undefined, brands?: (Array | null) | undefined, creator_has?: CreatorHasRequest | undefined, promotes_affiliate_links?: (boolean | null) | undefined, has_done_brand_deals?: (boolean | null) | undefined, has_link_in_bio?: (boolean | null) | undefined, does_live_streaming?: (boolean | null) | undefined, has_merch?: (boolean | null) | undefined, exclude_role_based_emails?: (boolean | null) | undefined, exclude_handles?: Array | undefined, exclude_list?: Array | undefined, exclude_default_list?: boolean | undefined, exclude_all_lists?: boolean | undefined}; export type DiscoveryTwitchRequest = {platform: 'twitch', nlp_search?: (string | null) | undefined, paging: PagingRequest, sort?: SortRequest | undefined, filters: TwitchDiscoveryFilters}; export type OnlyFansDiscoveryFilters = {location?: (Array) | undefined, gender?: (string | null) | undefined, profile_language?: (Array) | undefined, ai_search?: (string | null) | undefined, number_of_likes?: (RangeRequest | null) | undefined, number_of_photos?: (RangeRequest | null) | undefined, subscription_price?: (RangeRequest | null) | undefined, is_verified?: (boolean | null) | undefined, has_videos?: (boolean | null) | undefined, has_free_account?: (boolean | null) | undefined, has_live_streams?: (boolean | null) | undefined, last_active?: (string | null) | undefined, brands?: (Array | null) | undefined, creator_has?: CreatorHasRequest | undefined, promotes_affiliate_links?: (boolean | null) | undefined, has_done_brand_deals?: (boolean | null) | undefined, has_link_in_bio?: (boolean | null) | undefined, does_live_streaming?: (boolean | null) | undefined, has_merch?: (boolean | null) | undefined, exclude_role_based_emails?: (boolean | null) | undefined, exclude_handles?: Array | undefined, exclude_list?: Array | undefined, exclude_default_list?: boolean | undefined, exclude_all_lists?: boolean | undefined}; export type DiscoveryOnlyFansRequest = {platform: 'onlyfans', nlp_search?: (string | null) | undefined, paging: PagingRequest, sort?: SortRequest | undefined, filters: OnlyFansDiscoveryFilters}; export type DiscoveryAPISearchInputRequest = DiscoveryInstagramRequest | DiscoveryYouTubeRequest | DiscoveryTikTokRequest | DiscoveryTwitterRequest | DiscoveryTwitchRequest | DiscoveryOnlyFansRequest; export type CreateApiPublicV1DiscoveryArgs = {return_filter_values?: boolean | undefined, body: DiscoveryAPISearchInputRequest}; export type CreateApiPublicV1DiscoveryOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const accountProfile = z.object({full_name: z.string(), username: z.string(), picture: z.string(), followers: z.number().int(), engagement_percent: z.number()}); export const creatorHas = z.object({has_amazonaffiliates: z.boolean().nullable().optional(), has_applemusic: z.boolean().nullable().optional(), has_bandcamp: z.boolean().nullable().optional(), has_behance: z.boolean().nullable().optional(), has_buymeacoffee: z.boolean().nullable().optional(), has_cameo: z.boolean().nullable().optional(), has_canva: z.boolean().nullable().optional(), has_clubhouse: z.boolean().nullable().optional(), has_discord: z.boolean().nullable().optional(), has_dribbble: z.boolean().nullable().optional(), has_etsy: z.boolean().nullable().optional(), has_facebook: z.boolean().nullable().optional(), has_fiverr: z.boolean().nullable().optional(), has_github: z.boolean().nullable().optional(), has_gofundme: z.boolean().nullable().optional(), has_goodreads: z.boolean().nullable().optional(), has_instagram: z.boolean().nullable().optional(), has_kakao: z.boolean().nullable().optional(), has_kickstarter: z.boolean().nullable().optional(), has_kofi: z.boolean().nullable().optional(), has_linkedin: z.boolean().nullable().optional(), has_linktree: z.boolean().nullable().optional(), has_medium: z.boolean().nullable().optional(), has_onlyfans: z.boolean().nullable().optional(), has_patreon: z.boolean().nullable().optional(), has_personal_website: z.boolean().nullable().optional(), has_phone: z.boolean().nullable().optional(), has_pinterest: z.boolean().nullable().optional(), has_podcast: z.boolean().nullable().optional(), has_redbubble: z.boolean().nullable().optional(), has_shopify: z.boolean().nullable().optional(), has_shopltk: z.boolean().nullable().optional(), has_snapchat: z.boolean().nullable().optional(), has_spotify: z.boolean().nullable().optional(), has_spring: z.boolean().nullable().optional(), has_streamlabs: z.boolean().nullable().optional(), has_substack: z.boolean().nullable().optional(), has_telegram: z.boolean().nullable().optional(), has_tiktok: z.boolean().nullable().optional(), has_tumblr: z.boolean().nullable().optional(), has_twitch: z.boolean().nullable().optional(), has_twitter: z.boolean().nullable().optional(), has_udemy: z.boolean().nullable().optional(), has_viber: z.boolean().nullable().optional(), has_vimeo: z.boolean().nullable().optional(), has_vk: z.boolean().nullable().optional(), has_weebly: z.boolean().nullable().optional(), has_whatsApp: z.boolean().nullable().optional(), has_youtube: z.boolean().nullable().optional(), has_wix: z.boolean().nullable().optional(), has_anchor: z.boolean().nullable().optional(), has_soundcloud: z.boolean().nullable().optional(), has_community: z.boolean().nullable().optional()}); export const range = z.object({min: z.number().nullable().optional(), max: z.number().nullable().optional()}); export const matchedFilters = z.object({audience_location: z.array(z.string()).optional(), audience_gender: z.string().optional(), audience_age: z.array(z.string()).optional(), audience_interests: z.array(z.string()).optional(), audience_language: z.array(z.string()).optional(), audience_credibility: z.string().optional(), creator_has: creatorHas.optional(), has_brand_deals: z.boolean().optional(), has_link_in_bio: z.boolean().optional(), has_merch: z.boolean().optional(), has_affiliate_links: z.boolean().optional(), hashtags: z.array(z.string()).optional(), not_hashtags: z.array(z.string()).optional(), posting_frequency: z.number().optional(), creator_growth: z.number().optional(), income: range.optional(), ai_search: z.string().optional(), average_comments: z.number().optional(), average_likes: z.number().optional(), average_stream_duration: z.number().optional(), average_stream_views: z.number().optional(), average_video_downloads: z.number().optional(), average_views: z.number().optional(), average_views_for_reels: z.number().optional(), average_views_on_long_videos: z.number().optional(), average_views_on_shorts: z.number().optional(), avg_views_last_30_days: z.number().optional(), brands: z.array(z.string()).optional(), does_live_streaming: z.boolean().optional(), engagement_percent: z.number().optional(), exclude_keywords_in_bio: z.array(z.string()).optional(), exclude_private_profile: z.boolean().optional(), exclude_role_based_emails: z.boolean().optional(), followers: z.number().int().optional(), games_played: z.array(z.string()).optional(), gender: z.string().optional(), has_community_posts: z.boolean().optional(), has_courses: z.boolean().optional(), has_free_account: z.boolean().optional(), has_live_streams: z.boolean().optional(), has_membership: z.boolean().optional(), has_podcast: z.boolean().optional(), has_shorts: z.boolean().optional(), has_tik_tok_shop: z.boolean().optional(), has_videos: z.boolean().optional(), is_monetizing: z.boolean().optional(), is_twitch_partner: z.boolean().optional(), is_verified: z.boolean().optional(), keywords_in_bio: z.array(z.string()).optional(), keywords_in_captions: z.array(z.string()).optional(), keywords_in_description: z.array(z.string()).optional(), keywords_in_tweets: z.array(z.string()).optional(), keywords_in_video_description: z.array(z.string()).optional(), keywords_in_video_titles: z.array(z.string()).optional(), keywords_not_in_captions: z.array(z.string()).optional(), keywords_not_in_description: z.array(z.string()).optional(), keywords_not_in_tweets: z.array(z.string()).optional(), keywords_not_in_video_description: z.array(z.string()).optional(), keywords_not_in_video_titles: z.array(z.string()).optional(), last_active: z.string().optional(), last_post: z.string().optional(), last_stream_upload: z.string().optional(), last_upload_long_video: z.string().optional(), last_upload_short_video: z.string().optional(), link_in_bio: z.array(z.string()).optional(), links_from_description: z.array(z.string()).optional(), links_from_video_description: z.array(z.string()).optional(), location: z.array(z.string()).optional(), long_video_duration: range.optional(), maximum_views_count: z.number().optional(), most_recent_stream_date: z.string().optional(), not_link_in_bio: z.array(z.string()).optional(), not_video_description: z.array(z.string()).optional(), number_of_followers: z.number().int().optional(), number_of_likes: z.number().int().optional(), number_of_photos: z.number().optional(), number_of_posts: z.number().optional(), number_of_subscribers: z.number().int().optional(), number_of_videos: z.number().int().optional(), profile_language: z.array(z.string()).optional(), reels_percent: z.number().optional(), shorts_percentage: z.number().optional(), streamed_hours_last_30_days: z.number().optional(), streams_count_last_30_days: z.number().optional(), streams_live: z.boolean().optional(), subscription_price: z.number().optional(), topics: z.array(z.string()).optional(), tweets_count: z.number().optional(), type: z.string().optional(), video_count: z.number().int().optional(), video_description: z.array(z.string()).optional()}); export const accountResponse = z.object({user_id: z.string(), profile: accountProfile, similarity_score: z.number().optional(), matched_filters: matchedFilters.optional()}); export const nlpSearchEcho = z.object({from_nlp: z.record(z.string(), z.unknown()).optional(), overridden_by_user: z.array(z.string()).optional(), notes: z.array(z.string()).optional()}); export const discoverySearchResponse = z.object({total: z.number().int(), limit: z.number().int(), credits_left: z.string(), accounts: z.array(accountResponse).optional(), applied_filters: z.record(z.string(), z.unknown()).optional(), nlp_search: nlpSearchEcho.optional()}); 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 }; /** * Discovery API * * POST /public/v1/discovery/ */ export const createApiPublicV1Discovery = async (args: CreateApiPublicV1DiscoveryArgs, options?: CreateApiPublicV1DiscoveryOptions) => { const {baseUrl = "https://api-dashboard.influencers.club", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.return_filter_values != null) query.append("return_filter_values", String(args.return_filter_values)) if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/public/v1/discovery/${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(discoverySearchResponse, await res.json()) };