nextflow-zalo-sdk
Version:
SDK tích hợp Zalo toàn diện cho hệ thống CRM AI Nextflow
1,957 lines (1,915 loc) • 62.4 kB
TypeScript
import { EventEmitter as EventEmitter$1 } from 'events';
import { AxiosInstance } from 'axios';
/**
* Logger - Hệ thống ghi log cho SDK
*/
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
interface LoggerOptions {
level?: LogLevel;
prefix?: string;
timestamp?: boolean;
colors?: boolean;
}
interface LogEntry {
level: LogLevel;
message: string;
timestamp: number;
prefix?: string;
data?: any;
}
/**
* Logger class cho Nextflow Zalo SDK
*/
declare class Logger {
private level;
private prefix?;
private timestamp;
private colors;
private logs;
private static readonly LEVELS;
private static readonly COLORS;
constructor(options?: LoggerOptions);
/**
* Tạo logger con với prefix mới
*/
child(prefix: string): Logger;
/**
* Ghi log debug
*/
debug(message: string, data?: any): void;
/**
* Ghi log info
*/
info(message: string, data?: any): void;
/**
* Ghi log warning
*/
warn(message: string, data?: any): void;
/**
* Ghi log error
*/
error(message: string, data?: any): void;
/**
* Ghi log với level tùy chỉnh
*/
log(level: LogLevel, message: string, data?: any): void;
/**
* Kiểm tra có nên ghi log không
*/
private shouldLog;
/**
* Output log ra console
*/
private outputToConsole;
/**
* Thay đổi log level
*/
setLevel(level: LogLevel): void;
/**
* Lấy log level hiện tại
*/
getLevel(): LogLevel;
/**
* Lấy tất cả logs
*/
getLogs(): LogEntry[];
/**
* Lấy logs theo level
*/
getLogsByLevel(level: LogLevel): LogEntry[];
/**
* Lấy logs trong khoảng thời gian
*/
getLogsByTimeRange(startTime: number, endTime: number): LogEntry[];
/**
* Xóa tất cả logs
*/
clearLogs(): void;
/**
* Export logs thành JSON
*/
exportLogs(): string;
/**
* Tạo logger từ options
*/
static create(options?: LoggerOptions): Logger;
/**
* Tạo logger mặc định
*/
static default(): Logger;
}
/**
* PersonalAuth - Xử lý xác thực Zalo cá nhân
*/
interface QRLoginOptions {
qrPath?: string;
userAgent?: string;
language?: string;
}
interface PersonalCredentials {
imei: string;
userAgent: string;
cookie: any;
}
/**
* Xử lý xác thực cho Zalo cá nhân
*/
declare class PersonalAuth {
private client;
private logger;
private qrHelper;
private eventEmitter;
constructor(client: ZaloPersonalClient, logger: Logger);
/**
* Tạo QR code mà không chờ đăng nhập hoàn tất
* Generate QR: chỉ tạo mã QR và lưu vào file, trả về ngay lập tức
*
* Phương thức này chỉ:
* 1. Tạo QR code và lưu vào file
* 2. Trả về ngay mà không chờ user quét
* 3. Để background process xử lý việc chờ đăng nhập
*
* @param options - Tùy chọn cấu hình tạo QR
* @param options.qrPath - Đường dẫn lưu file QR code (tùy chọn)
* @param options.userAgent - Chuỗi User Agent mô phỏng trình duyệt (tùy chọn)
* @param options.language - Ngôn ngữ giao diện hiển thị (tùy chọn)
*/
/**
* Đăng nhập bằng QR code - phương thức đầy đủ chờ đăng nhập hoàn tất
* QR Code Login: Quét mã QR để đăng nhập lần đầu và lấy thông tin xác thực
*
* Quy trình hoạt động:
* 1. Tạo QR code và lưu vào file
* 2. Chờ người dùng quét QR bằng ứng dụng Zalo trên điện thoại
* 3. Nhận session và API instance từ Zalo
* 4. Lưu credentials để sử dụng cho lần đăng nhập sau
*
* @param options - Tùy chọn cấu hình đăng nhập QR
* @param options.qrPath - Đường dẫn lưu file QR code (tùy chọn)
* @param options.userAgent - Chuỗi User Agent mô phỏng trình duyệt (tùy chọn)
* @param options.language - Ngôn ngữ giao diện hiển thị (tùy chọn)
*/
loginQR(options?: QRLoginOptions): Promise<void>;
/**
* Cleanup old QR files: Dọn dẹp các file QR cũ
*/
cleanupQRFiles(): void;
/**
* Đăng nhập bằng credentials
*/
loginCredentials(credentials: PersonalCredentials): Promise<void>;
/**
* Lấy thông tin session hiện tại
*/
getSession(): Promise<any>;
/**
* Refresh session
*/
refreshSession(): Promise<void>;
/**
* Lưu credentials vào file .env sau khi loginQR thành công
* Save credentials: Lưu thông tin xác thực vào file môi trường
*/
saveCredentials(envPath?: string): Promise<void>;
/**
* Đăng xuất
* Logout: Kết thúc phiên đăng nhập và xóa session
*/
logout(): Promise<void>;
}
/**
* Type definitions cho Nextflow Zalo SDK
* Định nghĩa tất cả các kiểu dữ liệu sử dụng trong SDK
*/
interface SDKConfig {
personal?: PersonalAuthConfig;
official?: OfficialAuthConfig;
nextflow?: NextflowConfig;
options?: SDKOptions;
}
interface SDKOptions {
logLevel?: 'debug' | 'info' | 'warn' | 'error';
timeout?: number;
retries?: number;
rateLimit?: RateLimitConfig;
}
interface ConnectionStatus {
personal: boolean;
official: boolean;
nextflow: boolean;
}
interface PersonalAuthConfig {
credentials?: {
imei: string;
userAgent: string;
cookie: any;
};
qrLogin?: {
qrPath?: string;
userAgent?: string;
language?: string;
};
rateLimits?: RateLimitConfig;
}
interface PersonalMessage {
id: string;
threadId: string;
content: string | object;
type: 'text' | 'image' | 'video' | 'sticker' | 'file';
sender: {
id: string;
name: string;
avatar?: string;
};
timestamp: number;
isSelf: boolean;
quote?: PersonalMessage;
mentions?: PersonalMention[];
}
interface PersonalMention {
userId: string;
position: number;
length: number;
type: 0 | 1;
}
interface PersonalContact {
id: string;
name: string;
displayName: string;
avatar?: string;
phone?: string;
status: 'online' | 'offline' | 'away';
lastSeen?: number;
alias?: string;
isBlocked: boolean;
isFriend: boolean;
}
interface PersonalGroup {
id: string;
name: string;
avatar?: string;
description?: string;
memberCount: number;
members: PersonalGroupMember[];
settings: PersonalGroupSettings;
createdAt: number;
ownerId: string;
adminIds: string[];
}
interface PersonalGroupMember {
id: string;
name: string;
avatar?: string;
role: 'owner' | 'admin' | 'member';
joinedAt: number;
}
interface PersonalGroupSettings {
allowMemberInvite: boolean;
allowMemberChangeInfo: boolean;
joinApprovalRequired: boolean;
}
interface OfficialAuthConfig {
appId: string;
appSecret: string;
accessToken?: string;
refreshToken?: string;
webhookUrl?: string;
webhookSecret?: string;
}
interface OfficialMessage {
id: string;
userId: string;
content: string | OfficialMessageContent;
type: 'text' | 'template' | 'list' | 'carousel' | 'button';
timestamp: number;
status: 'sent' | 'delivered' | 'read' | 'failed';
}
interface OfficialMessageContent {
text?: string;
attachment?: {
type: 'image' | 'video' | 'file';
payload: {
url: string;
thumbnail?: string;
};
};
template?: OfficialTemplate;
buttons?: OfficialButton[];
}
interface OfficialTemplate {
templateId: string;
templateData: Record<string, any>;
}
interface OfficialButton {
type: 'postback' | 'web_url' | 'phone_number';
title: string;
payload?: string;
url?: string;
phoneNumber?: string;
}
interface OfficialUser {
id: string;
name: string;
avatar?: string;
phone?: string;
tags: string[];
segments: string[];
lastInteraction: number;
isFollowing: boolean;
}
interface NextflowConfig {
apiKey: string;
endpoint: string;
organizationId?: string;
options?: {
syncInterval?: number;
enableRealTimeSync?: boolean;
enableAI?: boolean;
};
}
interface CRMContact {
id: string;
name: string;
email?: string;
phone?: string;
zaloPersonalId?: string;
zaloOfficialId?: string;
tags: string[];
customFields: Record<string, any>;
createdAt: number;
updatedAt: number;
}
interface WorkflowConfig {
id: string;
name: string;
description?: string;
triggers: WorkflowTrigger[];
actions: WorkflowAction[];
conditions?: WorkflowCondition[];
isActive: boolean;
}
interface WorkflowTrigger {
type: 'message_received' | 'user_joined' | 'keyword_detected' | 'schedule';
config: Record<string, any>;
}
interface WorkflowAction {
type: 'send_message' | 'add_tag' | 'create_contact' | 'call_webhook';
config: Record<string, any>;
}
interface WorkflowCondition {
field: string;
operator: 'equals' | 'contains' | 'greater_than' | 'less_than';
value: any;
}
interface AIConfig {
provider: 'openai' | 'nextflow' | 'custom';
model: string;
apiKey?: string;
endpoint?: string;
options?: {
temperature?: number;
maxTokens?: number;
systemPrompt?: string;
};
}
interface ApiResponse<T = any> {
success: boolean;
data?: T;
error?: ErrorResponse;
timestamp: number;
}
interface ErrorResponse {
code: string;
message: string;
details?: any;
}
interface EventCallback$1<T = any> {
(data: T): void | Promise<void>;
}
interface RateLimitConfig {
maxRequests: number;
windowMs: number;
skipSuccessfulRequests?: boolean;
skipFailedRequests?: boolean;
}
interface MessageEvent {
type: 'message';
source: 'personal' | 'official';
data: PersonalMessage | OfficialMessage;
}
interface ConnectionEvent {
type: 'connected' | 'disconnected' | 'error';
source: 'personal' | 'official' | 'nextflow';
data?: any;
}
interface SyncEvent {
type: 'sync_started' | 'sync_completed' | 'sync_failed';
data: {
source: string;
recordsProcessed: number;
errors?: any[];
};
}
type SDKEvent = MessageEvent | ConnectionEvent | SyncEvent;
/**
* PersonalMessaging: Xử lý tin nhắn Zalo cá nhân
*
* Class này xử lý tất cả các thao tác liên quan đến tin nhắn:
* - Gửi tin nhắn text, hình ảnh, file, sticker
* - Reply tin nhắn và mention người dùng
* - Xóa tin nhắn và thêm reaction
* - Quản lý trạng thái tin nhắn (đã đọc, đang gõ)
*/
interface MessageResult$1 {
messageId: string;
timestamp: number;
success: boolean;
}
/**
* PersonalMessaging Class: Xử lý tin nhắn cho Zalo cá nhân
* Message Management: Quản lý tất cả thao tác liên quan đến tin nhắn
*/
declare class PersonalMessaging {
private client;
private logger;
constructor(client: ZaloPersonalClient, // ZaloPersonalClient: Client chính để gọi API
logger: Logger);
/**
* Gửi tin nhắn text
* Send Text Message: Gửi tin nhắn văn bản đơn giản
*
* @param threadId - Thread ID của cuộc trò chuyện
* @param text - Nội dung tin nhắn text
* @param options - Tùy chọn bổ sung (quote message, etc.)
* @returns Promise<MessageResult> - Kết quả gửi tin nhắn
*/
sendText(threadId: string, text: string, options?: {
quote?: PersonalMessage;
}): Promise<MessageResult$1>;
/**
* Gửi sticker
*/
sendSticker(threadId: string, stickerId: string): Promise<MessageResult$1>;
/**
* Gửi hình ảnh
*/
sendImage(threadId: string, imagePath: string): Promise<MessageResult$1>;
/**
* Gửi file
*/
sendFile(threadId: string, filePath: string): Promise<MessageResult$1>;
/**
* Reply tin nhắn
*/
replyMessage(messageId: string, content: string, threadId: string): Promise<MessageResult$1>;
/**
* Xóa tin nhắn
*/
deleteMessage(messageId: string, threadId: string): Promise<boolean>;
/**
* Thêm reaction
*/
addReaction(messageId: string, threadId: string, reaction: string): Promise<boolean>;
/**
* Đánh dấu đã đọc
*/
markAsRead(messageId: string, threadId: string): Promise<boolean>;
/**
* Validate thread ID
*/
private validateThreadId;
/**
* Validate text content
*/
private validateTextContent;
}
/**
* PersonalContacts: Quản lý danh bạ Zalo cá nhân
*
* Class này xử lý tất cả các thao tác liên quan đến danh bạ:
* - Lấy danh sách bạn bè và thông tin chi tiết
* - Gửi/chấp nhận/từ chối lời mời kết bạn
* - Chặn/bỏ chặn người dùng
* - Tìm kiếm và quản lý danh bạ
*/
/**
* PersonalContacts Class: Quản lý danh bạ cho Zalo cá nhân
* Contact Management: Xử lý tất cả thao tác liên quan đến bạn bè và danh bạ
*/
declare class PersonalContacts {
private client;
private logger;
constructor(client: ZaloPersonalClient, // ZaloPersonalClient: Client chính để gọi API
logger: Logger);
/**
* Lấy danh sách bạn bè
* Get Friends List: Lấy tất cả bạn bè trong danh bạ Zalo
*
* @returns Promise<PersonalContact[]> - Danh sách bạn bè với thông tin đầy đủ
*/
getFriends(): Promise<PersonalContact[]>;
/**
* Lấy thông tin bạn bè cụ thể
* Get Friend Info: Lấy thông tin chi tiết của một người bạn
*
* @param userId - User ID của người bạn cần lấy thông tin
* @returns Promise<PersonalContact> - Thông tin chi tiết của người bạn
*/
getFriend(userId: string): Promise<PersonalContact>;
/**
* Gửi lời mời kết bạn
* Send Friend Request: Gửi lời mời kết bạn đến người dùng khác
*
* @param userId - User ID của người nhận lời mời
* @param message - Tin nhắn kèm theo lời mời (optional)
* @returns Promise<boolean> - true nếu gửi thành công
*/
sendFriendRequest(userId: string, message?: string): Promise<boolean>;
/**
* Chấp nhận lời mời kết bạn
*/
acceptFriendRequest(userId: string): Promise<boolean>;
/**
* Từ chối lời mời kết bạn
*/
rejectFriendRequest(userId: string): Promise<boolean>;
/**
* Xóa bạn bè
*/
removeFriend(userId: string): Promise<boolean>;
/**
* Chặn người dùng
*/
blockUser(userId: string): Promise<boolean>;
/**
* Bỏ chặn người dùng
*/
unblockUser(userId: string): Promise<boolean>;
/**
* Tìm kiếm người dùng
*/
searchUsers(query: string): Promise<PersonalContact[]>;
/**
* Transform ZCA-JS contact thành PersonalContact
*/
private transformContact;
}
/**
* PersonalGroups: Quản lý nhóm Zalo cá nhân
*
* Class này xử lý tất cả các thao tác liên quan đến nhóm chat:
* - Lấy danh sách nhóm và thông tin chi tiết
* - Tạo nhóm mới và quản lý thành viên
* - Thêm/xóa thành viên, rời khỏi nhóm
* - Cập nhật tên nhóm, avatar và tạo link mời
*/
interface CreateGroupOptions {
name: string;
memberIds: string[];
description?: string;
}
/**
* PersonalGroups Class: Quản lý nhóm cho Zalo cá nhân
* Group Management: Xử lý tất cả thao tác liên quan đến nhóm chat
*/
declare class PersonalGroups {
private client;
private logger;
constructor(client: ZaloPersonalClient, // ZaloPersonalClient: Client chính để gọi API
logger: Logger);
/**
* Lấy danh sách nhóm
* Get Groups List: Lấy tất cả nhóm mà user tham gia
*
* @returns Promise<PersonalGroup[]> - Danh sách nhóm với thông tin đầy đủ
*/
getGroups(): Promise<PersonalGroup[]>;
/**
* Lấy thông tin nhóm
*/
getGroup(groupId: string): Promise<PersonalGroup>;
/**
* Tạo nhóm mới
*/
createGroup(options: CreateGroupOptions): Promise<PersonalGroup>;
/**
* Thêm thành viên vào nhóm
*/
addMembers(groupId: string, userIds: string[]): Promise<boolean>;
/**
* Xóa thành viên khỏi nhóm
*/
removeMembers(groupId: string, userIds: string[]): Promise<boolean>;
/**
* Rời khỏi nhóm
*/
leaveGroup(groupId: string): Promise<boolean>;
/**
* Cập nhật tên nhóm
*/
updateGroupName(groupId: string, name: string): Promise<boolean>;
/**
* Cập nhật avatar nhóm
*/
updateGroupAvatar(groupId: string, avatarPath: string): Promise<boolean>;
/**
* Tạo link mời nhóm
*/
createInviteLink(groupId: string): Promise<string>;
/**
* Validate create group options
*/
private validateCreateGroupOptions;
/**
* Transform ZCA-JS group thành PersonalGroup
*/
private transformGroup;
/**
* Transform ZCA-JS member thành PersonalGroupMember
*/
private transformMember;
}
/**
* RateLimiter - Giới hạn tốc độ request
*/
interface RateLimitInfo {
limit: number;
remaining: number;
resetTime: number;
retryAfter?: number;
}
/**
* Rate Limiter cho Nextflow Zalo SDK
*/
declare class RateLimiter {
private readonly config;
private readonly requests;
private readonly cleanupInterval;
constructor(config: RateLimitConfig);
/**
* Kiểm tra có thể thực hiện request không
*/
checkLimit(key?: string): Promise<RateLimitInfo>;
/**
* Ghi nhận request thành công
*/
recordSuccess(key?: string): void;
/**
* Ghi nhận request thất bại
*/
recordFailure(key?: string): void;
/**
* Block key trong một khoảng thời gian
*/
blockKey(key: string, durationMs: number): void;
/**
* Unblock key
*/
unblockKey(key: string): void;
/**
* Lấy thông tin rate limit hiện tại
*/
getInfo(key?: string): RateLimitInfo;
/**
* Reset rate limit cho key
*/
reset(key?: string): void;
/**
* Reset tất cả rate limits
*/
resetAll(): void;
/**
* Lấy tất cả keys đang được track
*/
getKeys(): string[];
/**
* Kiểm tra key có bị block không
*/
isBlocked(key?: string): boolean;
/**
* Destroy rate limiter
*/
destroy(): void;
/**
* Lấy hoặc tạo entry cho key
*/
private getOrCreateEntry;
/**
* Xóa request cuối cùng
*/
private removeLastRequest;
/**
* Cleanup expired entries
*/
private cleanup;
/**
* Tạo rate limiter với cấu hình mặc định
*/
static create(maxRequests: number, windowMs: number): RateLimiter;
/**
* Tạo rate limiter cho tin nhắn
*/
static forMessages(messagesPerMinute?: number): RateLimiter;
/**
* Tạo rate limiter cho API calls
*/
static forAPI(requestsPerSecond?: number): RateLimiter;
}
/**
* CacheManager - Quản lý bộ nhớ đệm
*/
interface CacheEntry<T = any> {
value: T;
timestamp: number;
ttl: number;
accessCount: number;
lastAccessed: number;
}
interface CacheOptions {
defaultTTL?: number;
maxSize?: number;
cleanupInterval?: number;
onEvict?: (key: string, value: any) => void;
}
interface CacheStats {
size: number;
maxSize: number;
hits: number;
misses: number;
hitRate: number;
evictions: number;
}
/**
* Cache Manager cho Nextflow Zalo SDK
*/
declare class CacheManager {
private cache;
private readonly options;
private cleanupTimer?;
private stats;
constructor(options?: CacheOptions);
/**
* Lưu giá trị vào cache
*/
set<T>(key: string, value: T, ttl?: number): void;
/**
* Lấy giá trị từ cache
*/
get<T>(key: string): T | undefined;
/**
* Kiểm tra key có tồn tại không
*/
has(key: string): boolean;
/**
* Xóa key khỏi cache
*/
delete(key: string): boolean;
/**
* Xóa tất cả cache
*/
clear(): void;
/**
* Lấy hoặc set giá trị (get with fallback)
*/
getOrSet<T>(key: string, factory: () => T | Promise<T>, ttl?: number): Promise<T>;
/**
* Cập nhật TTL của key
*/
touch(key: string, ttl?: number): boolean;
/**
* Lấy thông tin entry
*/
getInfo(key: string): Omit<CacheEntry, 'value'> | undefined;
/**
* Lấy tất cả keys
*/
keys(): string[];
/**
* Lấy tất cả values
*/
values<T>(): T[];
/**
* Lấy size hiện tại
*/
size(): number;
/**
* Lấy thống kê cache
*/
getStats(): CacheStats;
/**
* Reset thống kê
*/
resetStats(): void;
/**
* Cleanup cache (xóa expired entries)
*/
cleanup(): number;
/**
* Destroy cache manager
*/
destroy(): void;
/**
* Bắt đầu cleanup timer
*/
private startCleanup;
/**
* Evict LRU (Least Recently Used) entry
*/
private evictLRU;
/**
* Tạo cache manager với cấu hình mặc định
*/
static create(options?: CacheOptions): CacheManager;
/**
* Tạo cache manager cho user data
*/
static forUsers(maxSize?: number): CacheManager;
/**
* Tạo cache manager cho messages
*/
static forMessages(maxSize?: number): CacheManager;
/**
* Tạo cache manager cho API responses
*/
static forAPI(maxSize?: number): CacheManager;
}
/**
* ZaloPersonalClient: Client cho Zalo cá nhân
*
* Wrapper cho thư viện ZCA-JS với các tính năng bổ sung:
* - Rate limiting để tránh spam API
* - Caching để tăng tốc độ truy xuất
* - Error handling robust với retry logic
* - Event-driven architecture cho real-time updates
* - Logging chi tiết cho debugging
*/
/**
* ZaloPersonalClient Class: Client chính cho Zalo cá nhân
*
* EventEmitter: Kế thừa EventEmitter để hỗ trợ event-driven programming
* Wrapper Pattern: Bọc ZCA-JS library với các tính năng bổ sung
*/
declare class ZaloPersonalClient extends EventEmitter$1 {
private zaloInstance?;
private api?;
readonly auth: PersonalAuth;
readonly messaging: PersonalMessaging;
readonly contacts: PersonalContacts;
readonly groups: PersonalGroups;
private readonly logger;
private readonly rateLimiter;
private readonly cache;
private _isConnected;
private _isInitialized;
private config;
constructor(config: PersonalAuthConfig, logger?: Logger);
/**
* Khởi tạo client - chỉ chuẩn bị môi trường, không thực hiện đăng nhập
* Initialize: khởi tạo - thiết lập các thành phần cần thiết để client sẵn sàng hoạt động
*
* Phương thức này chỉ:
* - Tạo Zalo instance từ thư viện ZCA-JS
* - Thiết lập event listeners để lắng nghe các sự kiện
* - Đánh dấu client đã sẵn sàng để sử dụng
*
* KHÔNG thực hiện đăng nhập - cần gọi riêng auth.loginQR() hoặc auth.loginCredentials()
*/
initialize(): Promise<void>;
/**
* Thực hiện đăng nhập Zalo - method public để có thể gọi từ bên ngoài
* Login: đăng nhập - quá trình xác thực người dùng để có quyền truy cập hệ thống
*
* Hỗ trợ 2 phương thức đăng nhập:
* 1. Credentials: thông tin đăng nhập đã lưu (imei, cookie, userAgent)
* 2. QR Code: quét mã QR bằng ứng dụng Zalo trên điện thoại
*/
performLogin(): Promise<void>;
/**
* Đăng nhập Zalo - method nội bộ xử lý logic đăng nhập
* Private method: phương thức riêng tư chỉ được gọi từ bên trong class
*/
private login;
/**
* Đóng kết nối
*/
disconnect(): Promise<void>;
/**
* Kiểm tra trạng thái kết nối
*/
isConnected(): boolean;
/**
* Kiểm tra đã khởi tạo chưa
*/
isInitialized(): boolean;
/**
* Lấy ZCA-JS API instance
*/
getAPI(): any;
/**
* Lấy Zalo instance (cho loginQR)
* Zalo Instance: Đối tượng Zalo chưa đăng nhập, dùng để thực hiện loginQR
*/
getZaloInstance(): any;
/**
* Lấy rate limiter
*/
getRateLimiter(): RateLimiter;
/**
* Lấy cache manager
*/
getCache(): CacheManager;
/**
* Lấy logger
*/
getLogger(): Logger;
/**
* Thực hiện API call với rate limiting
*/
apiCall<T>(operation: () => Promise<T>, key?: string): Promise<T>;
/**
* Keep alive connection
*/
keepAlive(): Promise<void>;
/**
* Setup event listeners cho ZCA-JS
*/
private setupEventListeners;
/**
* Transform ZCA-JS message thành PersonalMessage
*/
private transformMessage;
/**
* Transform quote message
*/
private transformQuote;
/**
* Lấy message type từ ZCA-JS msgType
*/
private getMessageType;
}
/**
* OfficialAuth: Xử lý xác thực Zalo Official Account
*
* Class này xử lý tất cả các thao tác liên quan đến xác thực:
* - Lấy access token từ app credentials
* - Refresh token khi hết hạn
* - Validate token và kiểm tra quyền
* - Quản lý session và token lifecycle
*/
/**
* OfficialAuth Class: Xử lý xác thực cho Zalo Official Account
* Authentication Manager: Quản lý tất cả thao tác liên quan đến xác thực và token
*/
declare class OfficialAuth {
private client;
private logger;
constructor(client: ZaloOfficialClient, // ZaloOfficialClient: Client chính để gọi API
logger: Logger);
/**
* Lấy access token từ app credentials
*/
getAccessToken(): Promise<string>;
/**
* Refresh access token
*/
refreshAccessToken(refreshToken: string): Promise<string>;
/**
* Lấy thông tin OA profile
*/
getProfile(): Promise<any>;
private getAppId;
private getAppSecret;
}
/**
* OfficialMessaging: Xử lý tin nhắn Zalo Official Account
*
* Class này xử lý tất cả các thao tác liên quan đến tin nhắn OA:
* - Gửi tin nhắn text, template, carousel, button
* - Gửi media (hình ảnh, video, file)
* - Quản lý template và quick reply
* - Broadcast tin nhắn đến nhiều người
*/
interface MessageResult {
messageId: string;
timestamp: number;
success: boolean;
}
/**
* OfficialMessaging Class: Xử lý tin nhắn cho Zalo Official Account
* Message Management: Quản lý tất cả thao tác liên quan đến tin nhắn OA
*/
declare class OfficialMessaging {
private client;
private logger;
constructor(client: ZaloOfficialClient, // ZaloOfficialClient: Client chính để gọi API
logger: Logger);
/**
* Gửi tin nhắn text
*/
sendText(userId: string, text: string): Promise<MessageResult>;
/**
* Gửi template message
*/
sendTemplate(userId: string, template: OfficialTemplate): Promise<MessageResult>;
/**
* Gửi button message
*/
sendButtons(userId: string, text: string, buttons: OfficialButton[]): Promise<MessageResult>;
/**
* Gửi hình ảnh
*/
sendImage(userId: string, imageUrl: string): Promise<MessageResult>;
/**
* Broadcast tin nhắn đến nhiều users
*/
broadcast(userIds: string[], content: string): Promise<MessageResult[]>;
/**
* Validate user ID
*/
private validateUserId;
/**
* Validate text content
*/
private validateTextContent;
/**
* Validate template
*/
private validateTemplate;
/**
* Validate buttons
*/
private validateButtons;
/**
* Validate URL
*/
private validateUrl;
}
/**
* OfficialUsers - Quản lý người dùng Zalo Official Account
*/
/**
* Quản lý người dùng cho Zalo Official Account
*/
declare class OfficialUsers {
private client;
private logger;
constructor(client: ZaloOfficialClient, logger: Logger);
/**
* Lấy thông tin người dùng
*/
getUser(userId: string): Promise<OfficialUser>;
/**
* Lấy danh sách followers
*/
getFollowers(offset?: number, count?: number): Promise<{
users: OfficialUser[];
total: number;
}>;
/**
* Tag người dùng
*/
tagUser(userId: string, tagName: string): Promise<boolean>;
/**
* Untag người dùng
*/
untagUser(userId: string, tagName: string): Promise<boolean>;
/**
* Transform Zalo OA user thành OfficialUser
*/
private transformUser;
}
/**
* OfficialWebhook: Xử lý webhook Zalo Official Account
*
* Class này xử lý tất cả các thao tác liên quan đến webhook:
* - Verify signature để đảm bảo tính bảo mật
* - Parse và xử lý các loại webhook events
* - Route events đến handlers phù hợp
* - Logging và monitoring webhook traffic
*/
interface WebhookEvent {
app_id: string;
user_id_by_app: string;
oa_id: string;
timestamp: string;
event_name: string;
data: any;
}
/**
* OfficialWebhook Class: Xử lý webhook cho Zalo Official Account
* Webhook Handler: Quản lý tất cả thao tác liên quan đến webhook events
*/
declare class OfficialWebhook {
private client;
private logger;
constructor(client: ZaloOfficialClient, // ZaloOfficialClient: Client chính để gọi API
logger: Logger);
/**
* Verify webhook signature
*/
verifySignature(signature: string, body: string, secret?: string): boolean;
/**
* Parse webhook event
*/
parseEvent(body: string): WebhookEvent;
/**
* Handle webhook event
*/
handleEvent(event: WebhookEvent): void;
/**
* Lấy webhook secret từ config
*/
private getWebhookSecret;
/**
* Handle text message
*/
private handleTextMessage;
/**
* Handle image message
*/
private handleImageMessage;
/**
* Handle sticker message
*/
private handleStickerMessage;
/**
* Handle follow event
*/
private handleFollowEvent;
/**
* Handle unfollow event
*/
private handleUnfollowEvent;
/**
* Handle các loại message khác
*/
private handleGifMessage;
private handleAudioMessage;
private handleVideoMessage;
private handleFileMessage;
private handleLocationMessage;
private handleChatNowEvent;
private handleSubmitInfoEvent;
}
/**
* OfficialAnalytics: Phân tích dữ liệu Zalo Official Account
*
* Class này xử lý tất cả các thao tác liên quan đến analytics và báo cáo:
* - Thống kê tin nhắn (gửi, nhận, đọc, click)
* - Thống kê người theo dõi (tổng, mới, bỏ theo dõi)
* - Phân tích hiệu suất campaign và nội dung
* - Export báo cáo theo thời gian
*/
interface MessageStats {
sent: number;
delivered: number;
read: number;
clicked: number;
period: string;
}
interface FollowerStats {
total: number;
new: number;
unfollowed: number;
period: string;
}
/**
* OfficialAnalytics Class: Phân tích dữ liệu cho Zalo Official Account
* Analytics Engine: Xử lý tất cả thao tác liên quan đến thống kê và báo cáo
*/
declare class OfficialAnalytics {
private client;
private logger;
constructor(client: ZaloOfficialClient, // ZaloOfficialClient: Client chính để gọi API
logger: Logger);
/**
* Lấy thống kê tin nhắn
*/
getMessageStats(startDate: string, endDate: string): Promise<MessageStats>;
/**
* Lấy thống kê followers
*/
getFollowerStats(startDate: string, endDate: string): Promise<FollowerStats>;
/**
* Lấy thống kê tương tác
*/
getInteractionStats(startDate: string, endDate: string): Promise<any>;
/**
* Validate date range
*/
private validateDateRange;
}
/**
* ZaloOfficialClient: Client cho Zalo Official Account
*
* Client chính để tương tác với Zalo Official Account API:
* - Xác thực và quản lý access token
* - Gửi tin nhắn và template messages
* - Quản lý users và followers
* - Xử lý webhook events
* - Phân tích dữ liệu và báo cáo
*/
/**
* ZaloOfficialClient Class: Client chính cho Zalo Official Account
*
* EventEmitter: Kế thừa EventEmitter để hỗ trợ event-driven programming
* Official Account Client: Wrapper cho Zalo OA API với các tính năng bổ sung
*/
declare class ZaloOfficialClient extends EventEmitter$1 {
private httpClient;
readonly auth: OfficialAuth;
readonly messaging: OfficialMessaging;
readonly users: OfficialUsers;
readonly webhook: OfficialWebhook;
readonly analytics: OfficialAnalytics;
private readonly logger;
private readonly rateLimiter;
private readonly cache;
private _isConnected;
private _isInitialized;
private config;
private accessToken?;
constructor(config: OfficialAuthConfig, logger?: Logger);
/**
* Khởi tạo client
*/
initialize(): Promise<void>;
/**
* Xác thực với Zalo OA
*/
private authenticate;
/**
* Validate access token
*/
private validateToken;
/**
* Đóng kết nối
*/
disconnect(): Promise<void>;
/**
* Kiểm tra trạng thái kết nối
*/
isConnected(): boolean;
/**
* Kiểm tra đã khởi tạo chưa
*/
isInitialized(): boolean;
/**
* Lấy HTTP client
*/
getHttpClient(): AxiosInstance;
/**
* Lấy access token
*/
getAccessToken(): string;
/**
* Set access token
*/
setAccessToken(token: string): void;
/**
* Lấy rate limiter
*/
getRateLimiter(): RateLimiter;
/**
* Lấy cache manager
*/
getCache(): CacheManager;
/**
* Lấy logger
*/
getLogger(): Logger;
/**
* Thực hiện API call với rate limiting
*/
apiCall<T>(operation: () => Promise<T>, key?: string): Promise<T>;
/**
* Setup request/response interceptors
*/
private setupInterceptors;
}
/**
* CRMSync - Đồng bộ dữ liệu với Nextflow CRM
*/
interface SyncResult$1 {
success: boolean;
processed: number;
errors: number;
details?: any[];
}
/**
* Đồng bộ dữ liệu với Nextflow CRM
*/
declare class CRMSync {
private integration;
private logger;
private _isInitialized;
constructor(integration: NextflowIntegration, logger: Logger);
/**
* Khởi tạo CRM sync
*/
initialize(): Promise<void>;
/**
* Đóng kết nối
*/
disconnect(): Promise<void>;
/**
* Đồng bộ contacts từ Zalo
*/
syncContacts(source: 'personal' | 'oa', contacts: any[]): Promise<SyncResult$1>;
/**
* Đồng bộ conversations
*/
syncConversations(source: 'personal' | 'oa', conversations: any[]): Promise<SyncResult$1>;
/**
* Tạo hoặc cập nhật contact trong CRM
*/
upsertContact(contact: CRMContact): Promise<CRMContact>;
/**
* Lấy contact từ CRM
*/
getContact(contactId: string): Promise<CRMContact | null>;
/**
* Test CRM connection
*/
private testCRMConnection;
/**
* Transform contact cho CRM
*/
private transformContact;
/**
* Transform conversation cho CRM
*/
private transformConversation;
/**
* Validate contact data
*/
private validateContact;
}
/**
* AIIntegration - Tích hợp AI với Nextflow
*/
interface AIResponse {
text: string;
confidence: number;
intent?: string;
entities?: any[];
metadata?: any;
}
interface ChatContext {
userId: string;
conversationId: string;
history: Array<{
role: 'user' | 'assistant';
content: string;
timestamp: number;
}>;
metadata?: any;
}
/**
* Tích hợp AI với Nextflow
*/
declare class AIIntegration {
private integration;
private logger;
private _isInitialized;
private aiConfig?;
constructor(integration: NextflowIntegration, logger: Logger);
/**
* Khởi tạo AI integration
*/
initialize(): Promise<void>;
/**
* Đóng kết nối
*/
disconnect(): Promise<void>;
/**
* Xử lý tin nhắn với AI
*/
processMessage(message: string, context: ChatContext): Promise<AIResponse>;
/**
* Phân tích cảm xúc tin nhắn
*/
analyzeSentiment(message: string): Promise<{
sentiment: 'positive' | 'negative' | 'neutral';
score: number;
}>;
/**
* Trích xuất thông tin từ tin nhắn
*/
extractEntities(message: string): Promise<any[]>;
/**
* Tạo response tự động
*/
generateAutoResponse(intent: string, entities: any[], context: ChatContext): Promise<string>;
/**
* Cập nhật AI config
*/
updateAIConfig(config: Partial<AIConfig>): Promise<void>;
/**
* Load AI config từ Nextflow
*/
private loadAIConfig;
/**
* Validate message
*/
private validateMessage;
/**
* Validate chat context
*/
private validateContext;
}
/**
* WorkflowEngine - Công cụ tự động hóa workflow
*/
interface WorkflowExecution {
id: string;
workflowId: string;
status: 'running' | 'completed' | 'failed' | 'cancelled';
startedAt: number;
completedAt?: number;
result?: any;
error?: string;
}
/**
* Công cụ tự động hóa workflow
*/
declare class WorkflowEngine {
private integration;
private logger;
private _isInitialized;
private activeWorkflows;
constructor(integration: NextflowIntegration, logger: Logger);
/**
* Khởi tạo workflow engine
*/
initialize(): Promise<void>;
/**
* Đóng kết nối
*/
disconnect(): Promise<void>;
/**
* Tạo workflow mới
*/
createWorkflow(config: WorkflowConfig): Promise<WorkflowConfig>;
/**
* Cập nhật workflow
*/
updateWorkflow(workflowId: string, updates: Partial<WorkflowConfig>): Promise<WorkflowConfig>;
/**
* Xóa workflow
*/
deleteWorkflow(workflowId: string): Promise<boolean>;
/**
* Trigger workflow
*/
triggerWorkflow(workflowId: string, data: any): Promise<WorkflowExecution>;
/**
* Lấy trạng thái execution
*/
getExecution(executionId: string): Promise<WorkflowExecution>;
/**
* Kiểm tra trigger conditions
*/
checkTriggerConditions(event: any): string[];
/**
* Auto trigger workflows dựa trên event
*/
autoTrigger(event: any): Promise<WorkflowExecution[]>;
/**
* Load active workflows từ server
*/
private loadActiveWorkflows;
/**
* Validate workflow config
*/
private validateWorkflowConfig;
/**
* Validate trigger
*/
private validateTrigger;
/**
* Validate action
*/
private validateAction;
/**
* Evaluate triggers
*/
private evaluateTriggers;
}
/**
* Data Connector cho Nextflow Integration
* Bộ kết nối dữ liệu cho tích hợp Nextflow
*
* Xử lý việc gửi dữ liệu event đến Nextflow API thay vì database trực tiếp
* Xử lý việc gửi dữ liệu sự kiện đến API Nextflow thay vì kết nối cơ sở dữ liệu trực tiếp
* Hỗ trợ caching và retry logic - Hỗ trợ bộ nhớ đệm và logic thử lại
*/
/**
* Data sync options - Tùy chọn đồng bộ dữ liệu
*/
interface SyncOptions {
batchSize?: number;
retryAttempts?: number;
timeout?: number;
priority?: 'low' | 'normal' | 'high';
}
/**
* Sync result - Kết quả đồng bộ
*/
interface SyncResult {
success: boolean;
recordsProcessed: number;
errors: string[];
duration: number;
}
/**
* Data Connector - Kết nối dữ liệu Nextflow
* Chỉ gửi dữ liệu event đến Nextflow API, không kết nối database trực tiếp
*/
declare class DataConnector {
private integration;
private logger;
private _isInitialized;
constructor(integration: NextflowIntegration, logger: Logger);
/**
* Khởi tạo data connector - Khởi tạo bộ kết nối dữ liệu
*/
initialize(): Promise<void>;
/**
* Đóng kết nối - Ngắt kết nối
*/
disconnect(): Promise<void>;
/**
* Kiểm tra trạng thái kết nối - Kiểm tra xem có kết nối hay không
*/
isConnected(): boolean;
/**
* Test API connection - Kiểm tra kết nối API
*/
private testAPIConnection;
/**
* Sync event data to Nextflow - Đồng bộ dữ liệu sự kiện đến Nextflow
*/
syncEventData(eventType: string, eventData: any, options?: SyncOptions): Promise<SyncResult>;
/**
* Batch sync multiple events - Đồng bộ nhiều sự kiện cùng lúc
*/
syncBatchEvents(events: Array<{
type: string;
data: any;
}>, options?: SyncOptions): Promise<SyncResult>;
/**
* Send analytics data - Gửi dữ liệu phân tích
*/
sendAnalytics(analyticsData: any, options?: SyncOptions): Promise<SyncResult>;
/**
* Validation helpers - Các hàm hỗ trợ xác thực
*/
private validateEventData;
}
/**
* NextflowIntegration - Tích hợp chính với Nextflow CRM
*/
/**
* Tích hợp chính với Nextflow CRM
*/
declare class NextflowIntegration extends EventEmitter$1 {
private httpClient;
readonly crm: CRMSync;
readonly ai: AIIntegration;
readonly workflow: WorkflowEngine;
readonly dataConnector: DataConnector;
private readonly logger;
private readonly rateLimiter;
private readonly cache;
private _isConnected;
private _isInitialized;
private config;
constructor(config: NextflowConfig, logger?: Logger);
/**
* Khởi tạo integration
*/
initialize(): Promise<void>;
/**
* Test kết nối với Nextflow
*/
private testConnection;
/**
* Đóng kết nối
*/
disconnect(): Promise<void>;
/**
* Kiểm tra trạng thái kết nối
*/
isConnected(): boolean;
/**
* Kiểm tra đã khởi tạo chưa
*/
isInitialized(): boolean;
/**
* Lấy HTTP client
*/
getHttpClient(): AxiosInstance;
/**
* Lấy config
*/
getConfig(): NextflowConfig;
/**
* Lấy rate limiter
*/
getRateLimiter(): RateLimiter;
/**
* Lấy cache manager
*/
getCache(): CacheManager;
/**
* Lấy logger
*/
getLogger(): Logger;
/**
* Thực hiện API call với rate limiting
*/
apiCall<T>(operation: () => Promise<T>, key?: string): Promise<T>;
/**
* Setup request/response interceptors
*/
private setupInterceptors;
}
/**
* NextflowZaloSDK - Class chính của SDK
* Lớp chính của bộ công cụ phát triển phần mềm
*
* Giao diện thống nhất cho tất cả tính năng Zalo và Nextflow
* Cung cấp giao diện thống nhất cho mọi tính năng của Zalo và Nextflow
*
* Event-driven architecture: Kiến trúc hướng sự kiện
* - Không kết nối database trực tiếp
* - Emit structured events cho user xử lý
* - Tách biệt SDK logic khỏi data persistence
*/
/**
* Class chính NextflowZaloSDK
* Cung cấp giao diện thống nhất cho tất cả tính năng
*/
declare class NextflowZaloSDK extends EventEmitter$1 {
readonly personal: ZaloPersonalClient;
readonly official: ZaloOfficialClient;
readonly nextflow: NextflowIntegration;
private readonly logger;
private readonly config;
private _isInitialized;
private _connectionStatus;
/**
* Constructor - Khởi tạo SDK
* @param config Cấu hình SDK
*/
constructor(config: SDKConfig);
/**
* Khởi tạo SDK - Kết nối tất cả services
*/
initialize(): Promise<void>;
/**
* Đóng kết nối SDK
*/
disconnect(): Promise<void>;
/**
* Lấy trạng thái kết nối
*/
getStatus(): ConnectionStatus;
/**
* Kiểm tra SDK đã sẵn sàng chưa
*/
isReady(): boolean;
/**
* Lắng nghe sự kiện SDK
*/
onEvent(eventType: string, callback: EventCallback$1<SDKEvent>): void;
/**
* Bỏ lắng nghe sự kiện
*/
offEvent(eventType: string, callback?: EventCallback$1<SDKEvent>): void;
/**
* Khởi tạo Personal client
*/
private initializePersonal;
/**
* Khởi tạo Official client
*/
private initializeOfficial;
/**
* Khởi tạo Nextflow integration
*/
private initializeNextflow;
/**
* Thiết lập event listeners
*/
private setupEventListeners;
}
declare const SDK_VERSION: string;
declare const SDK_NAME: string;
declare const SDK_DESCRIPTION: string;
declare const API_ENDPOINTS: {
readonly ZALO_PERSONAL: {
readonly BASE_URL: string;
readonly LOGIN_URL: string;
readonly API_VERSION: string;
};
readonly ZALO_OA: {
readonly BASE_URL: string;
readonly AUTH_URL: string;
readonly API_VERSION: string;
};
readonly NEXTFLOW: {
readonly BASE_URL: string;
readonly API_VERSION: string;
};
};
declare const ERROR_CODES: {
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
readonly CONFIGURATION_ERROR: "CONFIGURATION_ERROR";
readonly AUTHENTICATION_ERROR: "AUTHENTICATION_ERROR";
readonly LOGIN_FAILED: "LOGIN_FAILED";
readonly TOKEN_EXPIRED: "TOKEN_EXPIRED";
readonly INVALID_CREDENTIALS: "INVALID_CREDENTIALS";
readonly ACCESS_DENIED: "ACCESS_DENIED";
readonly RATE_LIMIT_EXCEEDED: "RATE_LIMIT_EXCEEDED";
readonly MESSAGE_RATE_LIMIT: "MESSAGE_RATE_LIMIT";
readonly API_RATE_LIMIT: "API_RATE_LIMIT";
readonly TEMPORARY_BLOCK: "TEMPORARY_BLOCK";
readonly NETWORK_ERROR: "NETWORK_ERROR";
readonly REQUEST_TIMEOUT: "REQUEST_TIMEOUT";
readonly CONNECTION_FAILED: "CONNECTION_FAILED";
readonly DNS_ERROR: "DNS_ERROR";
readonly SSL_ERROR: "SSL_ERROR";
readonly HTTP_ERROR: "HTTP_ERROR";
readonly RETRY_EXHAUSTED: "RETRY_EXHAUSTED";
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
readonly FIELD_REQUIRED: "FIELD_REQUIRED";
readonly INVALID_TYPE: "INVALID_TYPE";
readonly INVALID_VALUE: "INVALID_VALUE";
readonly INVALID_LENGTH: "INVALID_LENGTH";
readonly INVALID_FORMAT: "INVALID_FORMAT";
readonly INVALID_EMAIL: "INVALID_EMAIL";
readonly INVALID_URL: "INVALID_URL";
readonly INVALID_PHONE: "INVALID_PHONE";
};
declare const EVENT_TYPES: {
readonly INITIALIZED: "initialized";
readonly DISCONNECTED: "disconnected";
readonly CONNECTION_CHANGED: "connection_changed";
readonly ERROR: "error";
readonly MESSAGE: "message";
readonly MESSAGE_SENT: "message_sent";
readonly MESSAGE_DELIVERED: "message_delivered";
readonly MESSAGE_READ: "message_read";
readonly MESSAGE_FAILED: "message_failed";
readonly PERSONAL_CONNECTED: "personal_connected";
readonly PERSONAL_DISCONNECTED: "personal_disconnected";
readonly PERSONAL_MESSAGE: "personal_message";
readonly PERSONAL_TYPING: "personal_typing";
readonly PERSONAL_SEEN: "personal_seen";
readonly PERSONAL_REACTION: "personal_reaction";
readonly OFFICIAL_CONNECTED: "official_connected";
readonly OFFICIAL_DISCONNECTED: "official_disconnected";
readonly OFFICIAL_MESSAGE: "official_message";
readonly OFFICIAL_FOLLOW: "official_follow";
readonly OFFICIAL_UNFOLLOW: "official_unfollow";
readonly OFFICIAL_POSTBACK: "official_postback";
readonly NEXTFLOW_CONNECTED: "nextflow_connected";
readonly NEXTFLOW_DISCONNECTED: "nextflow_disconnected";
readonly SYNC_STARTED: "sync_started";
readonly SYNC_COMPLETED: "sync_completed";
readonly SYNC_FAILED: "sync_failed";
readonly WORKFLOW_TRIGGERED: "workflow_triggered";
readonly WORKFLOW_COMPLETED: "workflow_completed";
};
declare const DEFAULT_CONFIG: {
readonly options: {
readonly logLevel: "debug" | "info" | "warn" | "error";
readonly timeout: number;
readonly retries: number;
readonly rateLimit: {
readonly maxRequests: number;
readonly windowMs: number;
readonly skipSuccessfulRequests: boolean;
readonly skipFailedRequests: boolean;
};
};
readonly personal: {
readonly rateLimits: {
readonly maxRequests: number;
readonly windowMs: number;
};
readonly qrLogin: {
readonly language: string;
readonly userAgent: string;
};
};
readonly official: {
readonly rateLimits: {
readonly maxRequests: number;
readonly windowMs: number;
};
};
readonly nextflow: {
readonly options: {
readonly syncInterval: number;
readonly enableRealTimeSync: boolean;
readonly enableAI: boolean;
};
};
};
declare const TIMEOUTS: {
readonly DEFAULT_REQUEST: number;
readonly LOGIN_REQUEST: number;
readonly UPLOAD_REQUEST: number;
readonly WEBSOCKET_CONNECT: number;
readonly RETRY_DELAY: number;
readonly RATE_LIMIT_RESET: number;
};
declare const LIMITS: {
readonly MESSAGE_LENGTH: number;
readonly FILE_SIZE: number;
readonly IMAGE_SIZE: number;
readonly VIDEO_SIZE: number;
readonly BATCH_SIZE: number;
readonly RETRY_ATTEMPTS: number;
};
/**
* ConfigManager - Quản lý cấu hình SDK
*/
/**
* Quản lý cấu hình cho Nextflow Zalo SDK
*/
declare class ConfigManager {
private config;
private readonly originalConfig;
constructor(config: SDKConfig);
/**
* Lấy toàn bộ cấu hình
*/
getAll(): SDKConfig;
/**
* Lấy giá trị cấu hình theo key
*/
get<K extends keyof SDKConfig>(key: K): SDKConfig[K];
/**
* Lấy giá trị cấu hình lồng nhau
*/
getNested(path: string): any;
/**
* Cập nhật cấu hình
*/
set<K extends keyof SDKConfig>(key: K, value: SDKConfig[K]): void;
/**
* Cập nhật cấu hình lồng nhau
*/
setNested(path: string, value: any): void;
/**
* Merge cấu hình mới
*/
merge(newConfig: Partial<SDKConfig>): void;
/**
* Reset về cấu hình ban đầu
*/
reset(): void;
/**
* Reset về cấu hình mặc định
*/
resetToDefaults(): void;
/**
* Kiểm tra cấu hình có hợp lệ không
*/
validate(): {
isValid: boolean;
errors: string[];
};
/**
* Lấy cấu hình cho environment cụ thể
*/
getForEnvironment(env: 'development' | 'production' | 'test'): SDKConfig;
/**
* Export cấu hình thành JSON
*/
toJSON(): string;
/**
* Merge với cấu hình mặc định
*/
private mergeWithDefaults;
/**
* Deep merge hai object
*/
private deepMerge;
/**
* Deep clone object
*/
private deepClone;
/**
* Kiểm tra có phải object không
*/
private isObject;
/**
* Lấy giá trị nested bằng path
*/
private getNest