UNPKG

@warriorteam/redai-zalo-sdk

Version:

Comprehensive TypeScript/JavaScript SDK for Zalo APIs - Official Account v3.0, ZNS with Full Type Safety, Consultation Service, Broadcast Service, Group Messaging with List APIs, Social APIs, Enhanced Article Management, Promotion Service v3.0 with Multip

521 lines 13.8 kB
/** * Types for Zalo Official Account Article Management * Based on Zalo Article API v2.0 */ import { ZaloApiResponse, ZaloResponse } from "./common"; /** * Article cover configuration */ export interface ArticleCover { /** Cover type: photo or video */ cover_type: 'photo' | 'video'; /** Photo URL (required when cover_type is 'photo') */ photo_url?: string; /** Video ID (required when cover_type is 'video') */ video_id?: string; /** Cover view orientation for video */ cover_view?: 'horizontal' | 'vertical' | 'square'; /** Cover status */ status: 'show' | 'hide'; } /** * Article body content item */ export interface ArticleBodyItem { /** Content type */ type: 'text' | 'image' | 'video' | 'product'; /** Text content (for type: text) */ content?: string; /** Image URL (for type: image) */ url?: string; /** Video ID (for type: video) */ video_id?: string; /** Product ID (for type: product) */ id?: string; /** Additional properties for video */ width?: number; height?: number; thumbnail?: string; } /** * Normal article creation request */ export interface ArticleNormalRequest { type: 'normal'; title: string; author: string; cover: ArticleCover; description: string; body: ArticleBodyItem[]; related_medias?: string[]; tracking_link?: string; status?: 'show' | 'hide'; comment?: 'show' | 'hide'; } /** * Video article creation request */ export interface ArticleVideoRequest { type: 'video'; title: string; description: string; video_id: string; avatar: string; status?: 'show' | 'hide'; comment?: 'show' | 'hide'; } /** * Article creation request (union type) */ export type ArticleRequest = ArticleNormalRequest | ArticleVideoRequest; /** * Article creation response */ export type ArticleResponse = ZaloResponse<{ token: string; }>; /** * Article process check response */ export interface ArticleProcessResponse { /** Article ID if creation is successful */ article_id?: string; /** Process status */ status: 'processing' | 'success' | 'failed'; /** Error message if failed */ error_message?: string; /** Creation timestamp */ created_time: number; /** Last update timestamp */ updated_time: number; } /** * Article verification response */ export interface ArticleVerifyResponse { /** Article ID */ id: string; } /** * Article cite information */ export interface ArticleCite { url: string; description: string; } /** * Article detail (normal type) */ export interface ArticleDetailNormal { id: string; type: 'normal'; title: string; author: string; cover: ArticleCover; description: string; body: ArticleBodyItem[]; related_medias: string[]; tracking_link: string; status: 'show' | 'hide'; comment: 'show' | 'hide'; cite?: ArticleCite; link_view: string; total_view: number; total_share: number; total_like: number; total_comment: number; } /** * Article detail (video type) */ export interface ArticleDetailVideo { id: string; type: 'video'; title: string; description: string; video_id: string; avatar: string; status: 'show' | 'hide'; comment: 'show' | 'hide'; link_view: string; total_view: number; total_share: number; total_like: number; total_comment: number; } /** * Article detail (union type) */ export type ArticleDetail = ArticleDetailNormal | ArticleDetailVideo; /** * Article list request */ export interface ArticleListRequest { /** Starting position */ offset: number; /** Number of articles to return (max 100) */ limit: number; /** Article type filter */ type: 'normal' | 'video'; } /** * Article list item - matches Zalo API response structure exactly */ export interface ArticleListItem { /** Article ID */ id: string; /** Article type */ type: 'normal' | 'video'; /** Article title */ title: string; /** Article status */ status: 'show' | 'hide'; /** Total view count */ total_view: number; /** Total share count */ total_share: number; /** Article creation date (timestamp) */ create_date: number; /** Article update date (timestamp) */ update_date: number; /** Article thumbnail URL */ thumb: string; /** Article view link */ link_view: string; } /** * Article list response data - matches Zalo API response structure exactly */ export interface ArticleListData { /** Array of articles (called "medias" in Zalo API) */ medias: ArticleListItem[]; /** Total number of articles */ total: number; } /** * Article list response */ export type ArticleListResponse = ZaloApiResponse<ArticleListData>; /** * Normal article update request */ export interface ArticleUpdateNormalRequest { id: string; type: 'normal'; title: string; author: string; cover: ArticleCover; description: string; body: ArticleBodyItem[]; related_medias?: string[]; tracking_link?: string; status?: 'show' | 'hide'; comment?: 'show' | 'hide'; } /** * Video article update request */ export interface ArticleUpdateVideoRequest { id: string; type: 'video'; title: string; description: string; video_id: string; avatar: string; status?: 'show' | 'hide'; comment?: 'show' | 'hide'; } /** * Article update request (union type) */ export type ArticleUpdateRequest = ArticleUpdateNormalRequest | ArticleUpdateVideoRequest; /** * Article update response */ export interface ArticleUpdateResponse { /** Token for tracking article update progress */ token: string; } /** * Article removal request */ export interface ArticleRemoveRequest { /** Article ID to remove */ id: string; } /** * Article removal response */ export interface ArticleRemoveResponse { /** Success message */ message: string; } /** * Bulk article removal result for individual item */ export interface BulkRemoveItemResult { /** Article ID that was processed */ article_id: string; /** Whether the removal was successful */ success: boolean; /** Success message if removal succeeded */ message?: string; /** Error message if removal failed */ error?: string; /** Processing time in milliseconds */ processing_time?: number; } /** * Progress information for bulk article removal */ export interface BulkRemoveProgress { /** Current number of articles processed */ current_count: number; /** Total number of articles to process */ total_count: number; /** Progress percentage (0-100) */ percentage: number; /** Number of successful removals so far */ successful_count: number; /** Number of failed removals so far */ failed_count: number; /** Whether the operation is complete */ is_complete: boolean; /** Current batch being processed */ current_batch?: number; /** Total number of batches */ total_batches?: number; } /** * Options for bulk article removal */ export interface BulkRemoveOptions { /** Number of articles to process in each batch (default: 10) */ batch_size?: number; /** Maximum number of concurrent requests (default: 3) */ max_concurrency?: number; /** Whether to continue processing if some articles fail (default: true) */ continue_on_error?: boolean; /** Delay between batches in milliseconds (default: 100) */ batch_delay?: number; /** Timeout for each removal request in milliseconds (default: 10000) */ request_timeout?: number; } /** * Complete result for bulk article removal operation */ export interface BulkRemoveResult { /** Total number of articles processed */ total_processed: number; /** Number of successful removals */ successful_count: number; /** Number of failed removals */ failed_count: number; /** Success rate as percentage (0-100) */ success_rate: number; /** Total processing time in milliseconds */ total_time: number; /** Detailed results for each article */ results: BulkRemoveItemResult[]; /** Summary of errors encountered */ error_summary?: { [errorType: string]: number; }; } /** * Result for individual article detail fetch in bulk operation */ export interface BulkDetailItemResult { /** Article ID that was processed */ article_id: string; /** Whether the detail fetch was successful */ success: boolean; /** Article detail if fetch succeeded */ detail?: ArticleDetail; /** Error message if fetch failed */ error?: string; /** Processing time in milliseconds */ processing_time?: number; } /** * Progress information for bulk article details fetch */ export interface BulkDetailProgress { /** Current number of articles processed */ current_count: number; /** Total number of articles to process */ total_count: number; /** Progress percentage (0-100) */ percentage: number; /** Number of successful detail fetches so far */ successful_count: number; /** Number of failed detail fetches so far */ failed_count: number; /** Whether the operation is complete */ is_complete: boolean; /** Current phase of operation */ phase: 'fetching_list' | 'fetching_details' | 'complete'; /** Current batch being processed (for details phase) */ current_batch?: number; /** Total number of batches (for details phase) */ total_batches?: number; } /** * Options for bulk article details fetch */ export interface BulkDetailOptions { /** Number of articles to fetch details for in each batch (default: 5) */ detail_batch_size?: number; /** Maximum number of concurrent detail requests (default: 3) */ max_concurrency?: number; /** Whether to continue processing if some details fail (default: true) */ continue_on_error?: boolean; /** Delay between detail batches in milliseconds (default: 200) */ batch_delay?: number; /** Timeout for each detail request in milliseconds (default: 15000) */ request_timeout?: number; /** Maximum number of articles to process (default: unlimited) */ max_articles?: number; /** Options for the initial article list fetch */ list_options?: { batch_size?: number; max_articles?: number; }; } /** * Complete result for bulk article details fetch operation */ export interface BulkDetailResult { /** Total number of articles processed */ total_processed: number; /** Number of successful detail fetches */ successful_count: number; /** Number of failed detail fetches */ failed_count: number; /** Success rate as percentage (0-100) */ success_rate: number; /** Total processing time in milliseconds */ total_time: number; /** Detailed results for each article */ results: BulkDetailItemResult[]; /** Successfully fetched article details */ articles_with_details: ArticleDetail[]; /** Summary of errors encountered */ error_summary?: { [errorType: string]: number; }; /** Statistics from the initial list fetch */ list_fetch_stats: { total_pages_fetched: number; list_fetch_time: number; }; } /** * Video upload response */ export interface VideoUploadResponse { /** Token for tracking video upload progress */ token: string; } /** * Video status response */ export interface VideoStatusResponse { /** Video ID (available when processing is complete) */ video_id?: string; /** Video name */ video_name?: string; /** Video size in bytes */ video_size?: number; /** Processing status */ status: number; /** Status message */ status_message: string; /** Conversion progress percentage */ convert_percent: number; /** Conversion error code */ convert_error_code: number; } /** * Article validation error */ export interface ArticleValidationError { field: string; message: string; code: string; } /** * Video file validation constraints */ export interface VideoFileConstraints { /** Maximum file size in bytes (50MB) */ maxSize: number; /** Allowed file extensions */ allowedExtensions: string[]; /** Allowed MIME types */ allowedMimeTypes: string[]; } /** * Article validation constants */ export declare const ARTICLE_CONSTRAINTS: { readonly TITLE_MAX_LENGTH: 150; readonly AUTHOR_MAX_LENGTH: 50; readonly DESCRIPTION_MAX_LENGTH: 300; readonly IMAGE_MAX_SIZE: number; readonly VIDEO_MAX_SIZE: number; readonly LIST_MAX_LIMIT: 10; }; /** * Video upload constraints */ export declare const VIDEO_CONSTRAINTS: VideoFileConstraints; /** * Article status enum */ export declare enum ArticleStatus { SHOW = "show", HIDE = "hide" } /** * Comment status enum */ export declare enum CommentStatus { SHOW = "show", HIDE = "hide" } /** * Article type enum */ export declare enum ArticleType { NORMAL = "normal", VIDEO = "video" } /** * Cover type enum */ export declare enum CoverType { PHOTO = "photo", VIDEO = "video" } /** * Body item type enum */ export declare enum BodyItemType { TEXT = "text", IMAGE = "image", VIDEO = "video", PRODUCT = "product" } /** * Video upload status enum */ export declare enum VideoUploadStatus { UNKNOWN = 0,// Trạng thái không xác định SUCCESS = 1,// Video đã được xử lý thành công và có thể sử dụng LOCKED = 2,// Video đã bị khóa PROCESSING = 3,// Video đang được xử lý FAILED = 4,// Video xử lý thất bại DELETED = 5 } //# sourceMappingURL=article.d.ts.map