/** * Namespaced API for the TikTok Business SDK. * * Usage: * import { TikTok } from "@promobase/tiktok-business-sdk"; * * // OAuth * const oauth = TikTok.OAuth({ clientKey: "...", clientSecret: "...", redirectUri: "..." }); * const { token, businessId } = await oauth.completeOAuth(code); * * // Client * const tt = TikTok.createClient({ accessToken: token.access_token, businessId }); * const { shareId } = await tt.videos.publish({ videoUrl: "...", caption: "Hello" }); * * // Webhooks * const result = await TikTok.Webhooks.safeParse.video({ body, signature, appSecret }); */ import type { TikTokApiClientOptions } from "./api-client.ts"; import { TikTokApiClient } from "./api-client.ts"; import { createTikTokClient, createTikTokClientWithProperties, createTikTokDiscovery, createTikTokOAuth, createTikTokWebhooks } from "./clients/index.ts"; import type { DiscoveryOptions, OAuthConfig, TikTokClientOptions, WebhookConfig } from "./clients/types.ts"; import { TikTokApiError } from "./errors.ts"; import type { TikTokCursorOptions } from "./pagination.ts"; import { TikTokCursor } from "./pagination.ts"; import type { TikTokRateLimiterOptions } from "./rate-limiter.ts"; import { TikTokRateLimiter } from "./rate-limiter.ts"; import type { WebhookParseOptions, WebhookParseResult } from "./webhooks.ts"; import { parseCommentWebhook, parseDMWebhook, parseMentionWebhook, parseTikTokWebhook, parseVideoWebhook, safeParseCommentWebhook, safeParseDMWebhook, safeParseMentionWebhook, safeParseTikTokWebhook, safeParseVideoWebhook, verifyWebhookSignature, WebhookParseError } from "./webhooks.ts"; export declare const TikTok: { /** Create a TikTok Business API client with all organic endpoints. */ readonly createClient: typeof createTikTokClient; /** Create a client with URL property management (requires app credentials). */ readonly createClientWithProperties: typeof createTikTokClientWithProperties; /** Create an OAuth handler for TikTok Business API auth flows. */ readonly OAuth: typeof createTikTokOAuth; /** Create a webhook management client (CRUD for webhook subscriptions). */ readonly createWebhooks: typeof createTikTokWebhooks; /** Create a Discovery API client for advertiser-scoped trending hashtags. */ readonly createDiscovery: typeof createTikTokDiscovery; /** TikTok API error class with code, requestId, and error classification helpers. */ readonly ApiError: typeof TikTokApiError; /** Core HTTP client with rate limiting, retry, and proper error handling. */ readonly ApiClient: typeof TikTokApiClient; /** Async-iterable cursor for paginated TikTok API responses. */ readonly Cursor: typeof TikTokCursor; /** Rate limiter implementing sdk-runtime's RateLimiter interface. */ readonly RateLimiter: { readonly create: (opts?: TikTokRateLimiterOptions) => TikTokRateLimiter; }; /** * Webhook verification, parsing, and schemas. * * Primary usage — one call, fully parsed, discriminated union: * ```ts * const result = await TikTok.Webhooks.safeParse({ body, signature, appSecret }); * if (!result.success) return; * switch (result.data.event) { * case "post.publish.publicly_available": * console.log(result.data.content.post_id); // typed! * } * ``` */ readonly Webhooks: { /** Verify + parse any TikTok webhook. Throws on failure. Content is auto-parsed. */ readonly parse: typeof parseTikTokWebhook; /** Verify + parse any TikTok webhook. Returns Result — never throws. Content is auto-parsed. */ readonly safeParse: typeof safeParseTikTokWebhook; /** Verify HMAC-SHA256 signature only (without parsing). */ readonly verifySignature: typeof verifyWebhookSignature; /** Narrowed parsers for specific event categories. */ readonly video: { readonly parse: typeof parseVideoWebhook; readonly safeParse: typeof safeParseVideoWebhook; }; readonly comment: { readonly parse: typeof parseCommentWebhook; readonly safeParse: typeof safeParseCommentWebhook; }; readonly mention: { readonly parse: typeof parseMentionWebhook; readonly safeParse: typeof safeParseMentionWebhook; }; readonly dm: { readonly parse: typeof parseDMWebhook; readonly safeParse: typeof safeParseDMWebhook; }; /** Error class for typed error handling. */ readonly ParseError: typeof WebhookParseError; /** Event type constants for switch statements. */ readonly events: { readonly publish: { readonly FAILED: "post.publish.failed"; readonly COMPLETE: "post.publish.complete"; readonly PUBLICLY_AVAILABLE: "post.publish.publicly_available"; readonly NO_LONGER_PUBLICLY_AVAILABLE: "post.publish.no_longer_publicly_available"; }; readonly comment: { readonly CREATE: "comment.create"; readonly DELETE: "comment.delete"; readonly REPLY_CREATE: "comment.reply.create"; }; readonly mention: { readonly VIDEO_MENTION: "brand_mention.video"; readonly COMMENT_MENTION: "brand_mention.comment"; }; readonly dm: { readonly RECEIVE: "receive_message"; }; }; /** Zod schemas for advanced composition. */ readonly schemas: { readonly any: import("zod").ZodUnion; content: import("zod").ZodPipe>; client_key: import("zod").ZodString; create_time: import("zod").ZodNumber; user_openid: import("zod").ZodString; }, import("zod/v4/core").$strip>, import("zod").ZodObject<{ event: import("zod").ZodLiteral<"post.publish.complete">; content: import("zod").ZodPipe>; client_key: import("zod").ZodString; create_time: import("zod").ZodNumber; user_openid: import("zod").ZodString; }, import("zod/v4/core").$strip>, import("zod").ZodObject<{ event: import("zod").ZodLiteral<"post.publish.publicly_available">; content: import("zod").ZodPipe>; client_key: import("zod").ZodString; create_time: import("zod").ZodNumber; user_openid: import("zod").ZodString; }, import("zod/v4/core").$strip>, import("zod").ZodObject<{ event: import("zod").ZodLiteral<"post.publish.no_longer_publicly_available">; content: import("zod").ZodPipe>; client_key: import("zod").ZodString; create_time: import("zod").ZodNumber; user_openid: import("zod").ZodString; }, import("zod/v4/core").$strip>]>, import("zod").ZodObject<{ event: import("zod").ZodEnum<{ "comment.create": "comment.create"; "comment.delete": "comment.delete"; "comment.reply.create": "comment.reply.create"; }>; content: import("zod").ZodPipe>; client_key: import("zod").ZodString; create_time: import("zod").ZodNumber; user_openid: import("zod").ZodString; }, import("zod/v4/core").$strip>, import("zod").ZodObject<{ event: import("zod").ZodEnum<{ "brand_mention.video": "brand_mention.video"; "brand_mention.comment": "brand_mention.comment"; }>; content: import("zod").ZodPipe>; client_key: import("zod").ZodString; create_time: import("zod").ZodNumber; user_openid: import("zod").ZodString; }, import("zod/v4/core").$strip>, import("zod").ZodObject<{ event: import("zod").ZodLiteral<"receive_message">; content: import("zod").ZodPipe>; client_key: import("zod").ZodString; create_time: import("zod").ZodNumber; user_openid: import("zod").ZodString; }, import("zod/v4/core").$strip>]>; readonly video: import("zod").ZodUnion; content: import("zod").ZodPipe>; client_key: import("zod").ZodString; create_time: import("zod").ZodNumber; user_openid: import("zod").ZodString; }, import("zod/v4/core").$strip>, import("zod").ZodObject<{ event: import("zod").ZodLiteral<"post.publish.complete">; content: import("zod").ZodPipe>; client_key: import("zod").ZodString; create_time: import("zod").ZodNumber; user_openid: import("zod").ZodString; }, import("zod/v4/core").$strip>, import("zod").ZodObject<{ event: import("zod").ZodLiteral<"post.publish.publicly_available">; content: import("zod").ZodPipe>; client_key: import("zod").ZodString; create_time: import("zod").ZodNumber; user_openid: import("zod").ZodString; }, import("zod/v4/core").$strip>, import("zod").ZodObject<{ event: import("zod").ZodLiteral<"post.publish.no_longer_publicly_available">; content: import("zod").ZodPipe>; client_key: import("zod").ZodString; create_time: import("zod").ZodNumber; user_openid: import("zod").ZodString; }, import("zod/v4/core").$strip>]>; readonly comment: import("zod").ZodObject<{ event: import("zod").ZodEnum<{ "comment.create": "comment.create"; "comment.delete": "comment.delete"; "comment.reply.create": "comment.reply.create"; }>; content: import("zod").ZodPipe>; client_key: import("zod").ZodString; create_time: import("zod").ZodNumber; user_openid: import("zod").ZodString; }, import("zod/v4/core").$strip>; readonly mention: import("zod").ZodObject<{ event: import("zod").ZodEnum<{ "brand_mention.video": "brand_mention.video"; "brand_mention.comment": "brand_mention.comment"; }>; content: import("zod").ZodPipe>; client_key: import("zod").ZodString; create_time: import("zod").ZodNumber; user_openid: import("zod").ZodString; }, import("zod/v4/core").$strip>; readonly dm: import("zod").ZodObject<{ event: import("zod").ZodLiteral<"receive_message">; content: import("zod").ZodPipe>; client_key: import("zod").ZodString; create_time: import("zod").ZodNumber; user_openid: import("zod").ZodString; }, import("zod/v4/core").$strip>; readonly content: { readonly publishFailed: import("zod").ZodObject<{ publish_id: import("zod").ZodString; reason: import("zod").ZodString; publish_type: import("zod").ZodLiteral<"DIRECT_PUBLISH">; }, import("zod/v4/core").$strip>; readonly publishComplete: import("zod").ZodObject<{ publish_id: import("zod").ZodString; publish_type: import("zod").ZodLiteral<"DIRECT_PUBLISH">; }, import("zod/v4/core").$strip>; readonly publishPubliclyAvailable: import("zod").ZodObject<{ publish_id: import("zod").ZodString; post_id: import("zod").ZodString; publish_type: import("zod").ZodLiteral<"DIRECT_PUBLISH">; }, import("zod/v4/core").$strip>; readonly publishNoLongerAvailable: import("zod").ZodObject<{ publish_id: import("zod").ZodString; post_id: import("zod").ZodString; publish_type: import("zod").ZodLiteral<"DIRECT_PUBLISH">; }, import("zod/v4/core").$strip>; readonly comment: import("zod").ZodObject<{ comment_id: import("zod").ZodString; video_id: import("zod").ZodString; parent_comment_id: import("zod").ZodOptional; text: import("zod").ZodOptional; user_id: import("zod").ZodOptional; create_time: import("zod").ZodOptional; }, import("zod/v4/core").$strip>; readonly mention: import("zod").ZodObject<{ video_id: import("zod").ZodOptional; comment_id: import("zod").ZodOptional; item_id: import("zod").ZodOptional; }, import("zod/v4/core").$strip>; readonly dm: import("zod").ZodObject<{ conversation_id: import("zod").ZodString; message_id: import("zod").ZodString; sender: import("zod").ZodOptional; message_type: import("zod").ZodOptional; timestamp: import("zod").ZodOptional; }, import("zod/v4/core").$strip>; }; }; }; }; export type { DiscoveryOptions, OAuthConfig, TikTokApiClientOptions, TikTokClientOptions, TikTokCursorOptions, TikTokRateLimiterOptions, WebhookConfig, WebhookParseOptions, WebhookParseResult, }; //# sourceMappingURL=namespace.d.ts.map