vantuz 3.1.9 β†’ 3.2.1

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/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  /**
3
3
  * πŸ™ VANTUZ CLI v3.1
4
4
  * Enterprise e-ticaret yΓΆnetimi
package/onboard.js ADDED
@@ -0,0 +1,500 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * πŸ™ VANTUZ - Premium Onboarding Experience
5
+ * Modern, interaktif kurulum wizard'Δ±
6
+ */
7
+
8
+ import fs from 'fs';
9
+ import path from 'path';
10
+ import os from 'os';
11
+ import readline from 'readline';
12
+ import { fileURLToPath } from 'url';
13
+ import { LicenseManager } from './plugins/vantuz/services/license.js';
14
+
15
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
16
+ const VANTUZ_HOME = path.join(os.homedir(), '.vantuz');
17
+ const CONFIG_PATH = path.join(VANTUZ_HOME, '.env');
18
+
19
+ // ═══════════════════════════════════════════════════════════════════════════
20
+ // COLORS & ANIMATIONS
21
+ // ═══════════════════════════════════════════════════════════════════════════
22
+
23
+ const colors = {
24
+ reset: '\x1b[0m',
25
+ bold: '\x1b[1m',
26
+ dim: '\x1b[2m',
27
+ red: '\x1b[31m',
28
+ green: '\x1b[32m',
29
+ yellow: '\x1b[33m',
30
+ blue: '\x1b[34m',
31
+ magenta: '\x1b[35m',
32
+ cyan: '\x1b[36m',
33
+ white: '\x1b[37m',
34
+ bgBlue: '\x1b[44m',
35
+ bgGreen: '\x1b[42m'
36
+ };
37
+
38
+ const c = (color, text) => `${colors[color]}${text}${colors.reset}`;
39
+
40
+ // Gradient text (cyan β†’ blue)
41
+ const gradient = (text) => {
42
+ return c('cyan', text);
43
+ };
44
+
45
+ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
46
+
47
+ // ═══════════════════════════════════════════════════════════════════════════
48
+ // ASCII ART
49
+ // ═══════════════════════════════════════════════════════════════════════════
50
+
51
+ const LOGO = `
52
+ ${c('cyan', ' ╦ ╦╔═╗╔╗╔╔╦╗╦ ╦╔═╗')}
53
+ ${c('cyan', ' β•šβ•—β•”β•β• β•β•£β•‘β•‘β•‘ β•‘ β•‘ ║╔═╝')}
54
+ ${c('cyan', ' β•šβ• β•© β•©β•β•šβ• β•© β•šβ•β•β•šβ•β•')}
55
+
56
+ ${c('dim', ' E-Ticaretin Yapay Zeka Beyni')}
57
+ `;
58
+
59
+ const WELCOME_BOX = `
60
+ ╔═══════════════════════════════════════════════════════════════════╗
61
+ β•‘ β•‘
62
+ β•‘ ${c('cyan', 'πŸš€ Hoş Geldin! Vantuz AI kurulumuna başlΔ±yoruz.')} β•‘
63
+ β•‘ β•‘
64
+ β•‘ ${c('dim', 'Bu wizard size 3 dakikada kurulumu tamamlatacak:')} β•‘
65
+ β•‘ β•‘
66
+ β•‘ ${c('green', 'βœ“')} Lisans aktivasyonu β•‘
67
+ β•‘ ${c('green', 'βœ“')} AI sağlayΔ±cΔ± yapΔ±landΔ±rmasΔ± β•‘
68
+ β•‘ ${c('green', 'βœ“')} Pazaryeri entegrasyonlarΔ± β•‘
69
+ β•‘ ${c('green', 'βœ“')} Δ°letişim kanallarΔ± (WhatsApp, Telegram) β•‘
70
+ β•‘ β•‘
71
+ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
72
+ `;
73
+
74
+ // ═══════════════════════════════════════════════════════════════════════════
75
+ // WIZARD CLASS
76
+ // ═══════════════════════════════════════════════════════════════════════════
77
+
78
+ class PremiumOnboardingWizard {
79
+ constructor() {
80
+ this.rl = readline.createInterface({
81
+ input: process.stdin,
82
+ output: process.stdout
83
+ });
84
+ this.config = {};
85
+ this.envVars = {};
86
+ this.step = 0;
87
+ this.totalSteps = 5;
88
+ this.licenseManager = new LicenseManager();
89
+ }
90
+
91
+ clear() {
92
+ console.clear();
93
+ }
94
+
95
+ async showLogo() {
96
+ this.clear();
97
+ console.log('\n');
98
+
99
+ // Animate logo (simulated)
100
+ const lines = LOGO.split('\n');
101
+ for (const line of lines) {
102
+ console.log(line);
103
+ await sleep(50);
104
+ }
105
+
106
+ await sleep(300);
107
+ }
108
+
109
+ async run() {
110
+ await this.showLogo();
111
+ await this.showWelcome();
112
+ await this.step1_License();
113
+ await this.step2_AIProvider();
114
+ await this.step3_Platforms();
115
+ await this.step4_Channels();
116
+ await this.step5_Save();
117
+ await this.showSuccess();
118
+ this.rl.close();
119
+ }
120
+
121
+ progressBar() {
122
+ const filled = 'β–ˆ'.repeat(this.step);
123
+ const empty = 'β–‘'.repeat(this.totalSteps - this.step);
124
+ return ` ${c('cyan', filled)}${c('dim', empty)} ${this.step}/${this.totalSteps}`;
125
+ }
126
+
127
+ async showWelcome() {
128
+ this.clear();
129
+ console.log('\n' + WELCOME_BOX + '\n');
130
+ await this.prompt(c('dim', ' Enter ile devam edin...'));
131
+ }
132
+
133
+ // ═══════════════════════════════════════════════════════════════════
134
+ // STEP 1: LICENSE
135
+ // ═══════════════════════════════════════════════════════════════════
136
+
137
+ async step1_License() {
138
+ this.step = 1;
139
+ this.clear();
140
+ console.log('\n' + this.progressBar() + '\n');
141
+ console.log(c('cyan', ' ═══════════════════════════════════════════════════════'));
142
+ console.log(c('cyan', ' πŸ” ADIM 1: LΔ°SANS AKTΔ°VASYONU'));
143
+ console.log(c('cyan', ' ═══════════════════════════════════════════════════════\n'));
144
+
145
+ console.log(' Vantuz AI tam ΓΆzellikli kullanΔ±m iΓ§in lisans gerektirir.\n');
146
+ console.log(c('dim', ' Lisans formatΔ±: VNTUZ-XXXXX-XXXXX-XXXXX-XXXXX-XXXX\n'));
147
+
148
+ const hasLicense = await this.prompt(' LisansΔ±nΔ±z var mΔ±? (E/h): ');
149
+
150
+ if (hasLicense.toLowerCase() === 'e') {
151
+ const key = await this.promptSecret(' Lisans anahtarΔ±: ');
152
+
153
+ if (!key) {
154
+ console.log(c('yellow', '\n ⚠️ Lisans boş bırakıldı. Demo modda devam ediliyor.\n'));
155
+ await sleep(1500);
156
+ return;
157
+ }
158
+
159
+ // Doğrula
160
+ console.log(c('dim', '\n Doğrulanıyor...'));
161
+ const formatCheck = this.licenseManager.validateFormat(key);
162
+
163
+ if (!formatCheck.valid) {
164
+ console.log(c('red', `\n ❌ ${formatCheck.error}`));
165
+ console.log(c('yellow', ' Demo modda devam ediliyor.\n'));
166
+ await sleep(2000);
167
+ return;
168
+ }
169
+
170
+ this.envVars.VANTUZ_LICENSE_KEY = key;
171
+ console.log(c('green', '\n βœ… Lisans kaydedildi!\n'));
172
+ await sleep(800);
173
+ } else {
174
+ console.log(c('yellow', '\n ⚑ Demo modda devam ediliyor (bazı âzellikler kısıtlı).\n'));
175
+ await sleep(1500);
176
+ }
177
+ }
178
+
179
+ // ═══════════════════════════════════════════════════════════════════
180
+ // STEP 2: AI PROVIDER
181
+ // ═══════════════════════════════════════════════════════════════════
182
+
183
+ async step2_AIProvider() {
184
+ this.step = 2;
185
+ this.clear();
186
+ console.log('\n' + this.progressBar() + '\n');
187
+ console.log(c('cyan', ' ═══════════════════════════════════════════════════════'));
188
+ console.log(c('cyan', ' πŸ€– ADIM 2: AI SAĞLAYICI'));
189
+ console.log(c('cyan', ' ═══════════════════════════════════════════════════════\n'));
190
+
191
+ console.log(' Vantuz hangi AI modeli kullanacak?\n');
192
+ console.log(c('green', ' [1]') + ' Gemini 2.0 ' + c('dim', '(Γ–nerilen, Ücretsiz)'));
193
+ console.log(c('cyan', ' [2]') + ' OpenAI GPT-4o ' + c('dim', '(En gΓΌΓ§lΓΌ)'));
194
+ console.log(c('blue', ' [3]') + ' Anthropic ' + c('dim', '(Claude 3.5 Sonnet)'));
195
+ console.log(c('yellow', ' [4]') + ' DeepSeek V3 ' + c('dim', '(Ekonomik)'));
196
+ console.log(c('magenta', ' [5]') + ' Groq (Mixtral) ' + c('dim', '(Γ‡ok hΔ±zlΔ±, ΓΌcretsiz)\n'));
197
+
198
+ const choice = await this.prompt(' SeΓ§im (1-5) [1]: ') || '1';
199
+
200
+ const providers = {
201
+ '1': { name: 'GEMINI', label: 'Google Gemini', env: 'GEMINI_API_KEY', url: 'https://aistudio.google.com/apikey' },
202
+ '2': { name: 'OPENAI', label: 'OpenAI', env: 'OPENAI_API_KEY', url: 'https://platform.openai.com/api-keys' },
203
+ '3': { name: 'ANTHROPIC', label: 'Anthropic', env: 'ANTHROPIC_API_KEY', url: 'https://console.anthropic.com/' },
204
+ '4': { name: 'DEEPSEEK', label: 'DeepSeek', env: 'DEEPSEEK_API_KEY', url: 'https://platform.deepseek.com/' },
205
+ '5': { name: 'GROQ', label: 'Groq', env: 'GROQ_API_KEY', url: 'https://console.groq.com/' }
206
+ };
207
+
208
+ const selected = providers[choice] || providers['1'];
209
+ this.config.ai = selected;
210
+
211
+ console.log(c('green', `\n βœ… ${selected.label} seΓ§ildi!\n`));
212
+ console.log(c('dim', ` API anahtarΔ± almak iΓ§in: ${selected.url}\n`));
213
+
214
+ const hasKey = await this.prompt(' API anahtarΔ±nΔ±z hazΔ±r mΔ±? (E/h): ');
215
+
216
+ if (hasKey.toLowerCase() === 'e') {
217
+ const key = await this.promptSecret(` ${selected.label} API Key: `);
218
+ if (key) {
219
+ this.envVars[selected.env] = key;
220
+ console.log(c('green', '\n βœ… API anahtarΔ± kaydedildi!\n'));
221
+ await sleep(800);
222
+ }
223
+ } else {
224
+ console.log(c('yellow', '\n ⚠️ API anahtarı daha sonra ekleyebilirsiniz:'));
225
+ console.log(c('dim', ` nano ~/.vantuz/.env\n`));
226
+ await sleep(2000);
227
+ }
228
+ }
229
+
230
+ // ═══════════════════════════════════════════════════════════════════
231
+ // STEP 3: PLATFORMS
232
+ // ═══════════════════════════════════════════════════════════════════
233
+
234
+ async step3_Platforms() {
235
+ this.step = 3;
236
+ this.clear();
237
+ console.log('\n' + this.progressBar() + '\n');
238
+ console.log(c('cyan', ' ═══════════════════════════════════════════════════════'));
239
+ console.log(c('cyan', ' πŸͺ ADIM 3: PAZARYERΔ° ENTEGRASYONLARI'));
240
+ console.log(c('cyan', ' ═══════════════════════════════════════════════════════\n'));
241
+
242
+ console.log(' Hangi pazaryerlerini kullanΔ±yorsunuz?\n');
243
+ console.log(' [1] 🟠 Trendyol');
244
+ console.log(' [2] 🟣 Hepsiburada');
245
+ console.log(' [3] πŸ”΅ N11');
246
+ console.log(' [4] 🟑 Amazon');
247
+ console.log(' [5] 🌸 Γ‡iΓ§eksepeti');
248
+ console.log(c('dim', ' [6] Şimdilik geç\n'));
249
+
250
+ const platformChoice = await this.prompt(' SeΓ§im (1-6) [1]: ') || '1';
251
+
252
+ if (platformChoice === '1') {
253
+ console.log(c('green', '\n 🟠 Trendyol seçildi!\n'));
254
+ console.log(c('dim', ' Gerekli bilgiler:\n'));
255
+ console.log(' β€’ Supplier ID');
256
+ console.log(' β€’ API Key');
257
+ console.log(' β€’ API Secret\n');
258
+ console.log(c('dim', ' BunlarΔ± Trendyol Partner Panel > Entegrasyon\'dan alΔ±n.\n'));
259
+
260
+ const configure = await this.prompt(' Şimdi yapılandır? (E/h): ');
261
+
262
+ if (configure.toLowerCase() === 'e') {
263
+ const supplierId = await this.prompt(' Supplier ID: ');
264
+ const apiKey = await this.promptSecret(' API Key: ');
265
+ const apiSecret = await this.promptSecret(' API Secret: ');
266
+
267
+ if (supplierId && apiKey && apiSecret) {
268
+ this.envVars.TRENDYOL_SUPPLIER_ID = supplierId;
269
+ this.envVars.TRENDYOL_API_KEY = apiKey;
270
+ this.envVars.TRENDYOL_API_SECRET = apiSecret;
271
+ console.log(c('green', '\n βœ… Trendyol yapΔ±landΔ±rΔ±ldΔ±!\n'));
272
+ await sleep(800);
273
+ }
274
+ } else {
275
+ console.log(c('yellow', '\n ⚠️ Daha sonra yapılandırabilirsiniz: vantuz config\n'));
276
+ await sleep(1500);
277
+ }
278
+ } else if (platformChoice === '6') {
279
+ console.log(c('yellow', '\n ⏭️ Pazaryeri yapılandırması atlandı.\n'));
280
+ await sleep(1000);
281
+ }
282
+ }
283
+
284
+ // ═══════════════════════════════════════════════════════════════════
285
+ // STEP 4: CHANNELS
286
+ // ═══════════════════════════════════════════════════════════════════
287
+
288
+ async step4_Channels() {
289
+ this.step = 4;
290
+ this.clear();
291
+ console.log('\n' + this.progressBar() + '\n');
292
+ console.log(c('cyan', ' ═══════════════════════════════════════════════════════'));
293
+ console.log(c('cyan', ' πŸ“± ADIM 4: Δ°LETİŞİM KANALLARI'));
294
+ console.log(c('cyan', ' ═══════════════════════════════════════════════════════\n'));
295
+
296
+ console.log(' Vantuz ile WhatsApp/Telegram üzerinden iletişim kurun!\n');
297
+ console.log(' πŸ“² WhatsApp - QR kod ile bağlanΔ±r (openclaw channels login)');
298
+ console.log(' πŸ’¬ Telegram - Bot token ile (@BotFather)\n');
299
+
300
+ const enableChannels = await this.prompt(' KanallarΔ± yapΔ±landΔ±r? (E/h): ');
301
+
302
+ if (enableChannels.toLowerCase() === 'e') {
303
+ // Telegram
304
+ console.log(c('cyan', '\n πŸ’¬ Telegram Bot\n'));
305
+ console.log(c('dim', ' 1. Telegram\'da @BotFather\'a git'));
306
+ console.log(c('dim', ' 2. /newbot komutunu gΓΆnder'));
307
+ console.log(c('dim', ' 3. Token\'Δ± kopyala\n'));
308
+
309
+ const tgToken = await this.promptSecret(' Bot Token (boş bırakılabilir): ');
310
+ if (tgToken) {
311
+ this.envVars.TELEGRAM_BOT_TOKEN = tgToken;
312
+ console.log(c('green', '\n βœ… Telegram yapΔ±landΔ±rΔ±ldΔ±!\n'));
313
+ await sleep(800);
314
+ }
315
+
316
+ // WhatsApp
317
+ console.log(c('cyan', '\n πŸ“² WhatsApp\n'));
318
+ console.log(c('dim', ' WhatsApp QR bağlantısı daha sonra yapılacak:'));
319
+ console.log(c('white', ' openclaw channels login\n'));
320
+ await sleep(1500);
321
+ } else {
322
+ console.log(c('yellow', '\n ⏭️ Kanal yapılandırması atlandı.\n'));
323
+ await sleep(1000);
324
+ }
325
+ }
326
+
327
+ // ═══════════════════════════════════════════════════════════════════
328
+ // STEP 5: SAVE
329
+ // ═══════════════════════════════════════════════════════════════════
330
+
331
+ async step5_Save() {
332
+ this.step = 5;
333
+ this.clear();
334
+ console.log('\n' + this.progressBar() + '\n');
335
+ console.log(c('cyan', ' ═══════════════════════════════════════════════════════'));
336
+ console.log(c('cyan', ' πŸ’Ύ ADIM 5: YAPIDANDIRMA KAYDEDΔ°LΔ°YOR'));
337
+ console.log(c('cyan', ' ═══════════════════════════════════════════════════════\n'));
338
+
339
+ console.log(c('dim', ' AyarlarΔ±nΔ±z kaydediliyor...\n'));
340
+
341
+ // Vantuz home dir
342
+ if (!fs.existsSync(VANTUZ_HOME)) {
343
+ fs.mkdirSync(VANTUZ_HOME, { recursive: true });
344
+ }
345
+
346
+ // .env dosyasΔ±
347
+ let envContent = '# Vantuz AI - Auto-generated by onboarding\n';
348
+ envContent += `# Created: ${new Date().toISOString()}\n\n`;
349
+
350
+ envContent += '# ═══════════════════════════════════════════════════════\n';
351
+ envContent += '# LISANS\n';
352
+ envContent += '# ═══════════════════════════════════════════════════════\n';
353
+ if (this.envVars.VANTUZ_LICENSE_KEY) {
354
+ envContent += `VANTUZ_LICENSE_KEY=${this.envVars.VANTUZ_LICENSE_KEY}\n`;
355
+ } else {
356
+ envContent += '# VANTUZ_LICENSE_KEY=\n';
357
+ }
358
+
359
+ envContent += '\n# ═══════════════════════════════════════════════════════\n';
360
+ envContent += '# AI SAĞLAYICI\n';
361
+ envContent += '# ═══════════════════════════════════════════════════════\n';
362
+ for (const key of ['GEMINI_API_KEY', 'OPENAI_API_KEY', 'ANTHROPIC_API_KEY', 'DEEPSEEK_API_KEY', 'GROQ_API_KEY']) {
363
+ if (this.envVars[key]) {
364
+ envContent += `${key}=${this.envVars[key]}\n`;
365
+ } else {
366
+ envContent += `# ${key}=\n`;
367
+ }
368
+ }
369
+
370
+ envContent += '\n# ═══════════════════════════════════════════════════════\n';
371
+ envContent += '# PAZARYERLERΔ°\n';
372
+ envContent += '# ═══════════════════════════════════════════════════════\n';
373
+ if (this.envVars.TRENDYOL_SUPPLIER_ID) {
374
+ envContent += `TRENDYOL_SUPPLIER_ID=${this.envVars.TRENDYOL_SUPPLIER_ID}\n`;
375
+ envContent += `TRENDYOL_API_KEY=${this.envVars.TRENDYOL_API_KEY}\n`;
376
+ envContent += `TRENDYOL_API_SECRET=${this.envVars.TRENDYOL_API_SECRET}\n`;
377
+ } else {
378
+ envContent += '# TRENDYOL_SUPPLIER_ID=\n';
379
+ envContent += '# TRENDYOL_API_KEY=\n';
380
+ envContent += '# TRENDYOL_API_SECRET=\n';
381
+ }
382
+
383
+ envContent += '\n# ═══════════════════════════════════════════════════════\n';
384
+ envContent += '# İLETİŞİM KANALLARI\n';
385
+ envContent += '# ═══════════════════════════════════════════════════════\n';
386
+ if (this.envVars.TELEGRAM_BOT_TOKEN) {
387
+ envContent += `TELEGRAM_BOT_TOKEN=${this.envVars.TELEGRAM_BOT_TOKEN}\n`;
388
+ } else {
389
+ envContent += '# TELEGRAM_BOT_TOKEN=\n';
390
+ }
391
+
392
+ fs.writeFileSync(CONFIG_PATH, envContent);
393
+ console.log(c('green', ' βœ… ~/.vantuz/.env oluşturuldu'));
394
+ await sleep(500);
395
+
396
+ // Dizinler
397
+ const dirs = ['logs', 'data', 'cache'];
398
+ for (const dir of dirs) {
399
+ const p = path.join(VANTUZ_HOME, dir);
400
+ if (!fs.existsSync(p)) {
401
+ fs.mkdirSync(p, { recursive: true });
402
+ }
403
+ }
404
+ console.log(c('green', ' βœ… Veri dizinleri oluşturuldu\n'));
405
+ await sleep(500);
406
+ }
407
+
408
+ // ═══════════════════════════════════════════════════════════════════
409
+ // SUCCESS
410
+ // ═══════════════════════════════════════════════════════════════════
411
+
412
+ async showSuccess() {
413
+ this.clear();
414
+
415
+ console.log('\n');
416
+ console.log(c('green', ' ╔═══════════════════════════════════════════════════════════════╗'));
417
+ console.log(c('green', ' β•‘ β•‘'));
418
+ console.log(c('green', ' β•‘') + c('bold', ' ✨ KURULUM TAMAMLANDI! ✨ ') + c('green', 'β•‘'));
419
+ console.log(c('green', ' β•‘ β•‘'));
420
+ console.log(c('green', ' β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•'));
421
+ console.log('\n');
422
+
423
+ console.log(c('cyan', ' πŸŽ‰ Vantuz AI kullanΔ±ma hazΔ±r!\n'));
424
+
425
+ console.log(c('yellow', ' πŸ“ Sonraki adΔ±mlar:\n'));
426
+ console.log(c('white', ' 1. CLI\'yi başlat:'));
427
+ console.log(c('dim', ' $ vantuz tui\n'));
428
+
429
+ console.log(c('white', ' 2. Platform durumunu kontrol et:'));
430
+ console.log(c('dim', ' $ vantuz status\n'));
431
+
432
+ if (this.envVars.TELEGRAM_BOT_TOKEN) {
433
+ console.log(c('white', ' 3. Gateway başlat (WhatsApp/Telegram):'));
434
+ console.log(c('dim', ' $ vantuz gateway\n'));
435
+ }
436
+
437
+ console.log(c('magenta', ' πŸ“š DokΓΌmantasyon: ') + c('dim', 'https://docs.vantuz.ai'));
438
+ console.log(c('magenta', ' πŸ’¬ Destek: ') + c('dim', 'support@vantuz.ai\n'));
439
+
440
+ await this.prompt(c('dim', ' Γ‡Δ±kmak iΓ§in Enter\'a basΔ±n...'));
441
+ }
442
+
443
+ // ═══════════════════════════════════════════════════════════════════
444
+ // HELPERS
445
+ // ═══════════════════════════════════════════════════════════════════
446
+
447
+ prompt(question) {
448
+ return new Promise((resolve) => {
449
+ this.rl.question(question, resolve);
450
+ });
451
+ }
452
+
453
+ promptSecret(question) {
454
+ return new Promise((resolve) => {
455
+ if (!process.stdin.isTTY) {
456
+ this.rl.question(question, resolve);
457
+ return;
458
+ }
459
+
460
+ process.stdout.write(question);
461
+ let input = '';
462
+
463
+ process.stdin.setRawMode(true);
464
+ process.stdin.resume();
465
+ process.stdin.setEncoding('utf8');
466
+
467
+ const onData = (char) => {
468
+ if (char === '\n' || char === '\r') {
469
+ process.stdin.setRawMode(false);
470
+ process.stdin.pause();
471
+ process.stdin.removeListener('data', onData);
472
+ console.log();
473
+ resolve(input);
474
+ } else if (char === '\u0003') {
475
+ process.exit();
476
+ } else if (char === '\u007F') {
477
+ if (input.length > 0) {
478
+ input = input.slice(0, -1);
479
+ process.stdout.write('\b \b');
480
+ }
481
+ } else {
482
+ input += char;
483
+ process.stdout.write('*');
484
+ }
485
+ };
486
+
487
+ process.stdin.on('data', onData);
488
+ });
489
+ }
490
+ }
491
+
492
+ // ═══════════════════════════════════════════════════════════════════════════
493
+ // MAIN
494
+ // ═══════════════════════════════════════════════════════════════════════════
495
+
496
+ const wizard = new PremiumOnboardingWizard();
497
+ wizard.run().catch(err => {
498
+ console.error(c('red', `\n ❌ Hata: ${err.message}\n`));
499
+ process.exit(1);
500
+ });
package/package.json CHANGED
@@ -1,18 +1,20 @@
1
1
  {
2
2
  "name": "vantuz",
3
- "version": "3.1.9",
3
+ "version": "3.2.1",
4
4
  "description": "Yapay Zeka Destekli E-Ticaret YΓΆnetim Platformu - 7 Pazaryeri + WhatsApp/Telegram",
5
5
  "type": "module",
6
6
  "main": "cli.js",
7
7
  "bin": {
8
- "vantuz": "cli.js"
8
+ "vantuz": "cli.js",
9
+ "vantuz-onboard": "onboard.js"
9
10
  },
10
11
  "scripts": {
11
12
  "start": "node cli.js tui",
12
13
  "tui": "node cli.js tui",
13
14
  "config": "node cli.js config",
14
15
  "status": "node cli.js status",
15
- "postinstall": "echo 'πŸ™ Vantuz kuruldu! Başlatmak iΓ§in: npx vantuz config'",
16
+ "onboard": "node onboard.js",
17
+ "postinstall": "echo 'πŸ™ Vantuz kuruldu! Başlatmak iΓ§in: npx vantuz-onboard'",
16
18
  "test": "node --test",
17
19
  "lint": "eslint plugins/"
18
20
  },
@@ -67,6 +69,7 @@
67
69
  },
68
70
  "files": [
69
71
  "cli.js",
72
+ "onboard.js",
70
73
  "plugins/",
71
74
  "core/",
72
75
  "README.md",
@@ -1,19 +1,18 @@
1
1
  /**
2
- * 🟠 TRENDYOL API Entegrasyonu
3
- * developers.trendyol.com
2
+ * 🟠 TRENDYOL API v2 Entegrasyonu
3
+ * developers.trendyol.com/v2.0
4
4
  *
5
- * Γ–zellikler:
6
- * - Ürün listeleme/güncelleme
7
- * - Fiyat/stok yΓΆnetimi
8
- * - Sipariş yânetimi
9
- * - Rakip fiyat Γ§ekme
5
+ * Base URL: https://apigw.trendyol.com/integration
6
+ * Auth: Basic (API Key:API Secret β†’ Base64)
7
+ * User-Agent: {SellerId} - SelfIntegration
8
+ * Rate Limit: 50 req / 10 sec per endpoint
10
9
  */
11
10
 
12
11
  import axios from 'axios';
13
12
  import { log } from '../../../core/ai-provider.js';
14
13
 
15
- const BASE_URL = 'https://api.trendyol.com/integration';
16
- const STAGE_URL = 'https://stageapi.trendyol.com/integration'; // Test ortamΔ±
14
+ const BASE_URL = 'https://apigw.trendyol.com/integration';
15
+ const STAGE_URL = 'https://stageapigw.trendyol.com/integration';
17
16
 
18
17
  export class TrendyolAPI {
19
18
  constructor(config) {
@@ -30,18 +29,22 @@ export class TrendyolAPI {
30
29
  return {
31
30
  'Authorization': `Basic ${this.auth}`,
32
31
  'Content-Type': 'application/json',
33
- 'User-Agent': `${this.supplierId} - VantuzAI`
32
+ 'User-Agent': `${this.supplierId} - SelfIntegration`
34
33
  };
35
34
  }
36
35
 
37
36
  async _request(method, endpoint, data = null, params = null) {
38
37
  try {
38
+ const url = `${this.baseUrl}${endpoint}`;
39
+ log('DEBUG', `[Trendyol] ${method} ${url}`);
40
+
39
41
  const response = await axios({
40
42
  method,
41
- url: `${this.baseUrl}${endpoint}`,
43
+ url,
42
44
  headers: this._headers(),
43
45
  data,
44
- params
46
+ params,
47
+ timeout: 30000
45
48
  });
46
49
  return { success: true, data: response.data };
47
50
  } catch (error) {
@@ -51,7 +54,10 @@ export class TrendyolAPI {
51
54
  console.error(`[Trendyol] API HatasΔ± (${statusCode}): ${errorMsg}`);
52
55
  if (error.response?.data) {
53
56
  try {
54
- console.error('[Trendyol] Hata DetayΔ±:', JSON.stringify(error.response.data));
57
+ const dataStr = typeof error.response.data === 'string'
58
+ ? error.response.data.substring(0, 200)
59
+ : JSON.stringify(error.response.data).substring(0, 200);
60
+ console.error('[Trendyol] Hata DetayΔ±:', dataStr);
55
61
  } catch (e) { }
56
62
  }
57
63
 
@@ -65,10 +71,11 @@ export class TrendyolAPI {
65
71
 
66
72
  // ═══════════════════════════════════════════════════════════════════════════
67
73
  // ÜRÜN İŞLEMLERΔ°
74
+ // Prefix: /product/sellers/{sellerId}/...
68
75
  // ═══════════════════════════════════════════════════════════════════════════
69
76
 
70
77
  async getProducts(params = {}) {
71
- const { page = 0, size = 50, barcode, approved, onSale } = params;
78
+ const { page = 0, size = 50, barcode, approved, onSale, date } = params;
72
79
  return await this._request('GET', `/product/sellers/${this.supplierId}/products`, null, {
73
80
  page, size, barcode, approved, onSale, date
74
81
  });
@@ -84,16 +91,20 @@ export class TrendyolAPI {
84
91
 
85
92
  async createProducts(products) {
86
93
  // items: [{ barcode, title, productMainId, brandId, categoryId, ... }]
87
- return await this._request('POST', `/suppliers/${this.supplierId}/v2/products`, { items: products });
94
+ return await this._request('POST', `/product/sellers/${this.supplierId}/v2/products`, { items: products });
88
95
  }
89
96
 
90
97
  async updateProducts(products) {
91
- return await this._request('PUT', `/suppliers/${this.supplierId}/v2/products`, { items: products });
98
+ return await this._request('PUT', `/product/sellers/${this.supplierId}/v2/products`, { items: products });
92
99
  }
93
100
 
94
101
  async deleteProducts(barcodes) {
95
102
  const items = barcodes.map(barcode => ({ barcode }));
96
- return await this._request('DELETE', `/suppliers/${this.supplierId}/products`, { items });
103
+ return await this._request('DELETE', `/product/sellers/${this.supplierId}/products`, { items });
104
+ }
105
+
106
+ async getBatchRequestResult(batchRequestId) {
107
+ return await this._request('GET', `/product/sellers/${this.supplierId}/products/batch-requests/${batchRequestId}`);
97
108
  }
98
109
 
99
110
  // ═══════════════════════════════════════════════════════════════════════════
@@ -102,7 +113,7 @@ export class TrendyolAPI {
102
113
 
103
114
  async updatePriceAndStock(items) {
104
115
  // items: [{ barcode, quantity, salePrice, listPrice }]
105
- return await this._request('POST', `/suppliers/${this.supplierId}/products/price-and-inventory`, { items });
116
+ return await this._request('POST', `/product/sellers/${this.supplierId}/products/price-and-inventory`, { items });
106
117
  }
107
118
 
108
119
  async updatePrice(barcode, salePrice, listPrice = null) {
@@ -129,12 +140,13 @@ export class TrendyolAPI {
129
140
 
130
141
  // ═══════════════════════════════════════════════════════════════════════════
131
142
  // SΔ°PARİŞ İŞLEMLERΔ°
143
+ // Prefix: /order/sellers/{sellerId}/...
132
144
  // ═══════════════════════════════════════════════════════════════════════════
133
145
 
134
146
  async getOrders(params = {}) {
135
147
  const {
136
148
  status,
137
- startDate = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).getTime(), // Son 30 gΓΌn
149
+ startDate = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).getTime(),
138
150
  endDate = Date.now(),
139
151
  page = 0,
140
152
  size = 50,
@@ -142,7 +154,9 @@ export class TrendyolAPI {
142
154
  } = params;
143
155
 
144
156
  return await this._request('GET', `/order/sellers/${this.supplierId}/orders`, null, {
145
- status, startDate, endDate, page, size, orderNumber, orderByDirection: 'DESC', orderByField: 'PackageLastModifiedDate'
157
+ status, startDate, endDate, page, size, orderNumber,
158
+ orderByDirection: 'DESC',
159
+ orderByField: 'PackageLastModifiedDate'
146
160
  });
147
161
  }
148
162
 
@@ -155,9 +169,7 @@ export class TrendyolAPI {
155
169
  }
156
170
 
157
171
  async updateOrderStatus(lines, status, params = {}) {
158
- // lines: [{ lineId, quantity }]
159
- // status: Picking, Invoiced, UnSupplied
160
- const endpoint = `/suppliers/${this.supplierId}/shipment-packages`;
172
+ const endpoint = `/order/sellers/${this.supplierId}/shipment-packages`;
161
173
 
162
174
  if (status === 'Picking') {
163
175
  return await this._request('PUT', endpoint, { lines, status: 'Picking' });
@@ -173,9 +185,8 @@ export class TrendyolAPI {
173
185
  }
174
186
 
175
187
  async shipOrder(shipmentPackageId, trackingNumber, cargoKey = 'YURTICI') {
176
- // cargoKey: YURTICI, MNG, ARAS, PTT, SURAT, UPS, HOROZ, CEVA, SENDEO
177
188
  return await this._request('PUT',
178
- `/suppliers/${this.supplierId}/shipment-packages/${shipmentPackageId}`,
189
+ `/order/sellers/${this.supplierId}/shipment-packages/${shipmentPackageId}`,
179
190
  {
180
191
  trackingNumber,
181
192
  cargoProviderCode: cargoKey,
@@ -190,35 +201,39 @@ export class TrendyolAPI {
190
201
 
191
202
  // ═══════════════════════════════════════════════════════════════════════════
192
203
  // KATEGORΔ° & MARKA
204
+ // Prefix: /product/...
193
205
  // ═══════════════════════════════════════════════════════════════════════════
194
206
 
195
207
  async getCategories() {
196
- return await this._request('GET', '/product-categories');
208
+ return await this._request('GET', '/product/product-categories');
197
209
  }
198
210
 
199
211
  async getCategoryAttributes(categoryId) {
200
- return await this._request('GET', `/product-categories/${categoryId}/attributes`);
212
+ return await this._request('GET', `/product/product-categories/${categoryId}/attributes`);
201
213
  }
202
214
 
203
215
  async searchBrands(name) {
204
- return await this._request('GET', '/brands', null, { name });
216
+ return await this._request('GET', '/product/brands', null, { name });
205
217
  }
206
218
 
207
219
  async getBrandsByCategory(categoryId) {
208
- return await this._request('GET', `/product-categories/${categoryId}/brands`);
220
+ return await this._request('GET', `/product/product-categories/${categoryId}/brands`);
221
+ }
222
+
223
+ // ═══════════════════════════════════════════════════════════════════════════
224
+ // ADRES BΔ°LGΔ°LERΔ°
225
+ // ═══════════════════════════════════════════════════════════════════════════
226
+
227
+ async getAddresses() {
228
+ return await this._request('GET', `/sellers/${this.supplierId}/addresses`);
209
229
  }
210
230
 
211
231
  // ═══════════════════════════════════════════════════════════════════════════
212
- // RAKΔ°P ANALΔ°ZΔ° (Scraping - Dikkat: Rate limit)
232
+ // RAKΔ°P ANALΔ°ZΔ°
213
233
  // ═══════════════════════════════════════════════════════════════════════════
214
234
 
215
235
  async getCompetitorPrices(barcode) {
216
- // Bu endpoint resmi API'de yok, web scraping gerekir
217
- // Alternatif: Brave Search API ile rakip aramasΔ±
218
236
  try {
219
- // Trendyol'da aynı ürünü satan diğer satıcıları bul
220
- const searchUrl = `https://www.trendyol.com/sr?q=${barcode}`;
221
- // Not: Bu gerΓ§ek scraping gerektirir, burada placeholder
222
237
  return {
223
238
  success: true,
224
239
  competitors: [],
@@ -235,32 +250,17 @@ export class TrendyolAPI {
235
250
 
236
251
  async getQuestions(params = {}) {
237
252
  const { status = 'WAITING_FOR_ANSWER', page = 0, size = 50 } = params;
238
- return await this._request('GET', `/suppliers/${this.supplierId}/questions/filter`, null, {
253
+ return await this._request('GET', `/order/sellers/${this.supplierId}/questions/filter`, null, {
239
254
  status, page, size
240
255
  });
241
256
  }
242
257
 
243
258
  async answerQuestion(questionId, answer) {
244
- return await this._request('POST', `/suppliers/${this.supplierId}/questions/${questionId}/answers`, {
259
+ return await this._request('POST', `/order/sellers/${this.supplierId}/questions/${questionId}/answers`, {
245
260
  text: answer
246
261
  });
247
262
  }
248
263
 
249
- // ═══════════════════════════════════════════════════════════════════════════
250
- // WEBHOOK
251
- // ═══════════════════════════════════════════════════════════════════════════
252
-
253
- async getWebhooks() {
254
- return await this._request('GET', `/suppliers/${this.supplierId}/webhooks`);
255
- }
256
-
257
- async createWebhook(url, events = ['order.created', 'order.shipped']) {
258
- return await this._request('POST', `/suppliers/${this.supplierId}/webhooks`, {
259
- url,
260
- events
261
- });
262
- }
263
-
264
264
  // ═══════════════════════════════════════════════════════════════════════════
265
265
  // YARDIMCI METODLAR
266
266
  // ═══════════════════════════════════════════════════════════════════════════