@redonvn/redai-tool 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,173 @@
1
- # Temporary Holding Version
1
+ # @redonvn/redai-tool
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Universal TypeScript SDK for RedAI Tool API Suite.
4
+
5
+ Bộ SDK toàn diện hỗ trợ kết nối, cào dữ liệu và phân tích đa kênh từ RedAI Tool Suite:
6
+ - **Google Search & Multi-Channel Contact Extractor** (SĐT, Email, Zalo, Messenger, Facebook, YouTube, TikTok, Instagram, LinkedIn, Threads, X/Twitter, Pinterest, Telegram, WhatsApp, Viber, Shopee, Lazada, Tiki, Apps, Dấu Bộ Công Thương, Google Maps).
7
+ - **Google Maps Scraper & Geocoding** (Cào địa điểm, số điện thoại, đánh giá, geocode & reverse geocode chuẩn hóa địa chỉ Việt Nam).
8
+ - **OSINT Social Identity Tracer** (Truy vết danh tính theo username qua hơn 400+ nền tảng mạng xã hội).
9
+ - **OCR Extractor & Verification** (Bóc tách & thẩm định Căn cước công dân gắn chip / QR / MRZ, Giấy phép ĐKKD).
10
+ - **IP Geolocation** (Tra cứu tọa độ GPS, địa chỉ, nhà mạng ISP từ IP).
11
+ - **Image Comparison** (So sánh độ tương đồng ảnh & Visual Regression Testing).
12
+ - **Web QA & Automated Auditing** (Hỏi đáp nội dung website & kiểm thử 5 lớp).
13
+ - **Page Screenshot** (Chụp ảnh màn hình toàn trang hoặc vùng chọn).
14
+
15
+ ---
16
+
17
+ ## 📦 Cài đặt
18
+
19
+ ```bash
20
+ # Cài đặt qua NPM
21
+ npm install @redonvn/redai-tool
22
+
23
+ # Hoặc qua Yarn / PNPM
24
+ yarn add @redonvn/redai-tool
25
+ pnpm add @redonvn/redai-tool
26
+ ```
27
+
28
+ Trong Monorepo nội bộ `redai-sdk`, có thể trỏ trực tiếp:
29
+ ```json
30
+ {
31
+ "dependencies": {
32
+ "@redonvn/redai-tool": "file:../redai-sdk/packages/redai-tool"
33
+ }
34
+ }
35
+ ```
36
+
37
+ ---
38
+
39
+ ## 🚀 Khởi tạo Client
40
+
41
+ ```typescript
42
+ import { RedaiToolClient } from '@redonvn/redai-tool';
43
+
44
+ const client = new RedaiToolClient({
45
+ baseUrl: process.env.REDAI_TOOL_BASE_URL || 'http://localhost:8000',
46
+ apiKey: process.env.REDAI_TOOL_API_KEY || 'your-api-key',
47
+ timeout: 60000, // 60s
48
+ });
49
+ ```
50
+
51
+ ---
52
+
53
+ ## 💡 Ví dụ Sử dụng
54
+
55
+ ### 1. Google Search & Bóc tách Kênh Liên hệ (Contact Extractor)
56
+
57
+ ```typescript
58
+ // Cào danh sách và bóc tách thông tin liên hệ đa kênh
59
+ const results = await client.googleSearch.scrape({
60
+ keyword: 'thời trang nữ hà nội',
61
+ max_results: 10,
62
+ deep_crawl: true, // Quét sâu cả trang chủ và trang liên hệ
63
+ summary_mode: 'fast',
64
+ });
65
+
66
+ for (const item of results.results) {
67
+ console.log(`\n=== ${item.title} (${item.url}) ===`);
68
+ console.log('Hotlines:', item.contacts?.phones);
69
+ console.log('Emails:', item.contacts?.emails);
70
+ console.log('Zalo:', item.contacts?.zalo);
71
+ console.log('Messenger:', item.contacts?.messenger);
72
+ console.log('Facebook:', item.contacts?.facebook);
73
+ console.log('Shopee:', item.contacts?.shopee);
74
+ console.log('Apps:', item.contacts?.apps);
75
+ console.log('Bộ Công Thương:', item.contacts?.bocongthuong);
76
+ }
77
+
78
+ // Hoặc bóc tách trực tiếp từ danh sách URL có sẵn
79
+ const direct = await client.googleSearch.scrapeDetails({
80
+ urls: ['https://kbfashion.vn/', 'https://yody.vn/'],
81
+ deep_crawl: true,
82
+ });
83
+ ```
84
+
85
+ ### 2. OSINT Social Identity Tracer (Truy vết MXH theo Username)
86
+
87
+ ```typescript
88
+ // Truy vết đồng bộ trên 400+ nền tảng
89
+ const trace = await client.socialTracer.traceSync({
90
+ username: 'torvalds',
91
+ timeout_per_site: 6,
92
+ concurrency: 30,
93
+ });
94
+
95
+ console.log(`Tìm thấy ${trace.found_count}/${trace.total_checked} tài khoản:`);
96
+ for (const p of trace.results.filter(r => r.status === 'FOUND')) {
97
+ console.log(`- [${p.platform}]: ${p.url}`);
98
+ }
99
+ ```
100
+
101
+ ### 3. Google Maps Scraping & Geocoding
102
+
103
+ ```typescript
104
+ // Geocode địa chỉ ra tọa độ và cấp hành chính
105
+ const geo = await client.googleMaps.geocodeAddress('123 Cầu Giấy, Hà Nội');
106
+ console.log('Tọa độ:', geo.latitude, geo.longitude);
107
+ console.log('Hành chính:', geo.ward, geo.district, geo.province);
108
+
109
+ // Tạo job cào Google Maps
110
+ const job = await client.googleMaps.createJob({
111
+ query: 'quán cà phê',
112
+ location: 'Cầu Giấy, Hà Nội',
113
+ max_results: 50,
114
+ require_phone: true,
115
+ });
116
+
117
+ // Kiểm tra trạng thái job
118
+ const status = await client.googleMaps.getJobStatus(job.job_id);
119
+ ```
120
+
121
+ ### 4. OCR Căn cước công dân (CCCD) & Giấy phép ĐKKD
122
+
123
+ ```typescript
124
+ // Bóc tách CCCD từ ảnh Base64 hoặc URL
125
+ const cccd = await client.ocr.extractCccd({
126
+ image_url: 'https://example.com/cccd_sample.jpg',
127
+ });
128
+ console.log('Số CCCD:', cccd.data?.id_number);
129
+ console.log('Họ tên:', cccd.data?.full_name);
130
+ console.log('Ngày sinh:', cccd.data?.date_of_birth);
131
+
132
+ // Bóc tách Giấy phép ĐKKD
133
+ const dkkd = await client.ocr.extractBusinessLicense({
134
+ image_url: 'https://example.com/giay_phep.jpg',
135
+ });
136
+ console.log('Mã số thuế:', dkkd.data?.enterprise_code);
137
+ console.log('Tên công ty:', dkkd.data?.enterprise_name);
138
+ ```
139
+
140
+ ### 5. IP Geolocation
141
+
142
+ ```typescript
143
+ const ipInfo = await client.ip.lookup('14.232.208.199');
144
+ console.log('Vị trí:', ipInfo.data[0]?.city, ipInfo.data[0]?.country);
145
+ console.log('Nhà mạng ISP:', ipInfo.data[0]?.isp);
146
+ ```
147
+
148
+ ### 6. Web QA
149
+
150
+ ```typescript
151
+ const qa = await client.webQa.ask({
152
+ url: 'https://kbfashion.vn/',
153
+ question: 'Chính sách bảo hành và đổi trả của thương hiệu thế nào?',
154
+ });
155
+ console.log('Câu trả lời:', qa.answer);
156
+ ```
157
+
158
+ ---
159
+
160
+ ## 🛠️ Build & Test
161
+
162
+ ```bash
163
+ # Build TypeScript sang CJS + ESM + Types
164
+ npm run build
165
+
166
+ # Chạy kiểm tra kiểu dữ liệu
167
+ npm run typecheck
168
+ ```
169
+
170
+ ---
171
+
172
+ ## 📄 License
173
+ MIT © RedAI Team