UNPKG

@warriorteam/redai-zalo-sdk

Version:

Comprehensive TypeScript/JavaScript SDK for Zalo APIs - Official Account, ZNS, Consultation Service, Group Messaging, and Social APIs

362 lines 8.49 kB
/** * Types for Zalo Official Account Article Management * Based on Zalo Article API v2.0 */ import { ZaloApiResponse } 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 interface ArticleResponse { /** Token for tracking article creation progress */ 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; } /** * 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: 100; }; /** * 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