vantuz 3.5.12 → 3.5.16
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/core/database.js +19 -0
- package/index.js +169 -3
- package/package.json +1 -1
package/core/database.js
CHANGED
|
@@ -86,6 +86,25 @@ class Model {
|
|
|
86
86
|
return stmt.get().count;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
async destroy(query = {}) {
|
|
90
|
+
if (!query.where) return;
|
|
91
|
+
const whereClause = Object.keys(query.where).map(k => `${k} = ?`).join(' AND ');
|
|
92
|
+
const values = Object.values(query.where);
|
|
93
|
+
const sql = `DELETE FROM ${this.tableName} WHERE ${whereClause}`;
|
|
94
|
+
const stmt = db.prepare(sql);
|
|
95
|
+
return stmt.run(...values);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async update(data, query = {}) {
|
|
99
|
+
if (!query.where) return;
|
|
100
|
+
const updateClause = Object.keys(data).map(k => `${k} = ?`).join(', ');
|
|
101
|
+
const whereClause = Object.keys(query.where).map(k => `${k} = ?`).join(' AND ');
|
|
102
|
+
const values = [...Object.values(data), ...Object.values(query.where)];
|
|
103
|
+
const sql = `UPDATE ${this.tableName} SET ${updateClause}, updatedAt = ? WHERE ${whereClause}`;
|
|
104
|
+
const stmt = db.prepare(sql);
|
|
105
|
+
return stmt.run(...values, new Date().toISOString());
|
|
106
|
+
}
|
|
107
|
+
|
|
89
108
|
_parseRow(row) {
|
|
90
109
|
// Convert JSON fields back to objects
|
|
91
110
|
for (const [key, props] of Object.entries(this.schema)) {
|
package/index.js
CHANGED
|
@@ -118,6 +118,7 @@ async function main() {
|
|
|
118
118
|
{ name: '🛍️ Ürün & Stok (Vision AI)', value: 'products' },
|
|
119
119
|
{ name: '🧠 Pazar Analizi', value: 'ai' },
|
|
120
120
|
{ name: '💬 AI Takımı ile Sohbet', value: 'ai_chat' },
|
|
121
|
+
{ name: '🏪 Mağazalarım', value: 'stores' },
|
|
121
122
|
{ name: '➕ Mağaza Ekle', value: 'add_store' },
|
|
122
123
|
{ name: '⚙️ Ayarlar', value: 'settings' },
|
|
123
124
|
{ name: '🚪 Çıkış', value: 'exit' }
|
|
@@ -240,8 +241,21 @@ async function showDashboard(licenseData) {
|
|
|
240
241
|
const orders = await db.Order.count();
|
|
241
242
|
|
|
242
243
|
console.log(chalk.bold(`🏢 Lisans Sahibi: ${chalk.cyan(licenseData.customer)}`));
|
|
243
|
-
console.log(
|
|
244
|
-
|
|
244
|
+
console.log(chalk.grey('─'.repeat(45)));
|
|
245
|
+
|
|
246
|
+
if (stores.length > 0) {
|
|
247
|
+
console.log(chalk.cyan('\n 📋 AKTİF MAĞAZALAR:'));
|
|
248
|
+
stores.forEach((store, i) => {
|
|
249
|
+
const status = store.isActive ? chalk.green('●') : chalk.red('○');
|
|
250
|
+
console.log(chalk.white(` ${i+1}. ${status} ${store.name || store.platform} ${chalk.grey(`(${store.platform})`)}`));
|
|
251
|
+
});
|
|
252
|
+
} else {
|
|
253
|
+
console.log(chalk.yellow('\n ⚠️ Hiç mağaza eklenmemiş'));
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
console.log(chalk.grey('\n ──────────────────────────────────────────'));
|
|
257
|
+
console.log(chalk.white(` 📦 Toplam Sipariş: ${orders}`));
|
|
258
|
+
console.log(chalk.grey('─────────────────────────────────────────\n'));
|
|
245
259
|
}
|
|
246
260
|
|
|
247
261
|
async function handleAction(action) {
|
|
@@ -339,7 +353,88 @@ async function handleAction(action) {
|
|
|
339
353
|
]);
|
|
340
354
|
if (provider !== 'Geri') {
|
|
341
355
|
config.set('ai.provider', provider);
|
|
342
|
-
|
|
356
|
+
|
|
357
|
+
// Auth tipi seçimi
|
|
358
|
+
const authTypes = {
|
|
359
|
+
'OpenAI': ['API Key', 'OAuth (ChatGPT)'],
|
|
360
|
+
'Anthropic': ['API Key', 'Setup Token'],
|
|
361
|
+
'Google Gemini': ['API Key', 'OAuth (Gemini CLI)'],
|
|
362
|
+
'xAI': ['API Key'],
|
|
363
|
+
'OpenCode': ['API Key', 'OAuth (Zen)']
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
const availableAuth = authTypes[provider] || ['API Key'];
|
|
367
|
+
|
|
368
|
+
const { authType } = await inquirer.prompt([
|
|
369
|
+
{
|
|
370
|
+
type: 'list',
|
|
371
|
+
name: 'authType',
|
|
372
|
+
message: 'Kimlik Doğrulama Türü:',
|
|
373
|
+
choices: availableAuth
|
|
374
|
+
}
|
|
375
|
+
]);
|
|
376
|
+
|
|
377
|
+
if (authType.includes('OAuth') || authType.includes('CLI')) {
|
|
378
|
+
console.log(chalk.cyan(`\n 🔐 ${provider} OAuth/CLI Auth:`));
|
|
379
|
+
console.log(chalk.grey(' ─────────────────────────\n'));
|
|
380
|
+
|
|
381
|
+
if (provider === 'OpenCode') {
|
|
382
|
+
console.log(chalk.white(' 1. https://opencode.ai/subscription aç'));
|
|
383
|
+
console.log(chalk.white(' 2. OAuth ile giriş yap'));
|
|
384
|
+
console.log(chalk.white(' 3. API key\'i al\n'));
|
|
385
|
+
} else if (provider === 'Google Gemini') {
|
|
386
|
+
console.log(chalk.yellow(' 📱 Gemini CLI için:'));
|
|
387
|
+
console.log(chalk.white(' Terminalde: gemini auth login'));
|
|
388
|
+
console.log(chalk.white(' Yetkilendirmeden sonra buraya dön\n'));
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const { oauthCode } = await inquirer.prompt([
|
|
392
|
+
{ type: 'input', name: 'oauthCode', message: 'Token/Key (varsa):', default: '' }
|
|
393
|
+
]);
|
|
394
|
+
|
|
395
|
+
if (oauthCode && oauthCode.length > 5) {
|
|
396
|
+
config.set('ai.apiKey', oauthCode.trim());
|
|
397
|
+
config.set('ai.authType', 'oauth');
|
|
398
|
+
console.log(chalk.green(' ✅ Auth kaydedildi!'));
|
|
399
|
+
} else {
|
|
400
|
+
console.log(chalk.yellow(' ⚠️ Token girilmedi, API Key ile devam ediliyor...'));
|
|
401
|
+
}
|
|
402
|
+
} else if (authType === 'Setup Token') {
|
|
403
|
+
console.log(chalk.cyan('\n 🔑 Anthropic Setup Token:'));
|
|
404
|
+
console.log(chalk.grey(' console.anthropic.com -> Settings\n'));
|
|
405
|
+
|
|
406
|
+
const { setupToken } = await inquirer.prompt([
|
|
407
|
+
{ type: 'password', name: 'setupToken', message: 'Setup Token:', mask: '*' }
|
|
408
|
+
]);
|
|
409
|
+
|
|
410
|
+
if (setupToken && setupToken.length > 10) {
|
|
411
|
+
config.set('ai.apiKey', setupToken.trim());
|
|
412
|
+
config.set('ai.authType', 'setup-token');
|
|
413
|
+
console.log(chalk.green(' ✅ Setup token kaydedildi!'));
|
|
414
|
+
}
|
|
415
|
+
} else {
|
|
416
|
+
// API Key
|
|
417
|
+
const providerKeyNames = {
|
|
418
|
+
'OpenAI': 'OPENAI_API_KEY',
|
|
419
|
+
'Anthropic': 'ANTHROPIC_API_KEY',
|
|
420
|
+
'Google Gemini': 'GEMINI_API_KEY',
|
|
421
|
+
'xAI': 'XAI_API_KEY',
|
|
422
|
+
'OpenCode': 'OPENCODE_API_KEY'
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
console.log(chalk.cyan(`\n 🔑 ${provider} API Key:`));
|
|
426
|
+
console.log(chalk.grey(` (Ortam: ${providerKeyNames[provider]})\n`));
|
|
427
|
+
|
|
428
|
+
const { apiKey } = await inquirer.prompt([
|
|
429
|
+
{ type: 'password', name: 'apiKey', message: 'API Key:', mask: '*' }
|
|
430
|
+
]);
|
|
431
|
+
|
|
432
|
+
if (apiKey && apiKey.length > 5) {
|
|
433
|
+
config.set('ai.apiKey', apiKey.trim());
|
|
434
|
+
config.set('ai.authType', 'api-key');
|
|
435
|
+
console.log(chalk.green(' ✅ API Key kaydedildi!'));
|
|
436
|
+
}
|
|
437
|
+
}
|
|
343
438
|
}
|
|
344
439
|
} else if (settingAction === '🔙 Geri') {
|
|
345
440
|
return;
|
|
@@ -647,6 +742,77 @@ AI_MODEL=gpt-4
|
|
|
647
742
|
}
|
|
648
743
|
break;
|
|
649
744
|
|
|
745
|
+
case 'stores':
|
|
746
|
+
while (true) {
|
|
747
|
+
console.clear();
|
|
748
|
+
console.log(chalk.cyan('\n🏪 MAĞAZA YÖNETİMİ'));
|
|
749
|
+
console.log(chalk.grey('═'.repeat(45)));
|
|
750
|
+
|
|
751
|
+
const stores = await db.Store.findAll();
|
|
752
|
+
|
|
753
|
+
if (stores.length === 0) {
|
|
754
|
+
console.log(chalk.yellow('\n Hiç mağaza eklenmemiş.\n'));
|
|
755
|
+
} else {
|
|
756
|
+
console.log(chalk.white('\n # | Platform | Mağaza Adı | Durum'));
|
|
757
|
+
console.log(chalk.grey(' ──────────────────────────────────────────────'));
|
|
758
|
+
stores.forEach((store, i) => {
|
|
759
|
+
const status = store.isActive ? chalk.green('Aktif') : chalk.red('Pasif');
|
|
760
|
+
const name = store.name || store.storeName || '-';
|
|
761
|
+
console.log(chalk.white(` ${i+1} | ${(store.platform || '-').padEnd(15)} | ${name.substring(0,15).padEnd(15)} | ${status}`));
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
console.log(chalk.grey('\n ──────────────────────────────────────────\n'));
|
|
766
|
+
|
|
767
|
+
const { storeAction } = await inquirer.prompt([
|
|
768
|
+
{
|
|
769
|
+
type: 'list',
|
|
770
|
+
name: 'storeAction',
|
|
771
|
+
message: 'İşlem:',
|
|
772
|
+
choices: [
|
|
773
|
+
'➕ Yeni Mağaza Ekle',
|
|
774
|
+
...(stores.length > 0 ? ['✏️ Mağaza Düzenle', '🗑️ Mağaza Sil', '🔄 Durum Değiştir'] : []),
|
|
775
|
+
'🔙 Geri'
|
|
776
|
+
]
|
|
777
|
+
}
|
|
778
|
+
]);
|
|
779
|
+
|
|
780
|
+
if (storeAction === '🔙 Geri') break;
|
|
781
|
+
|
|
782
|
+
if (storeAction.includes('Ekle')) {
|
|
783
|
+
await setupWizard();
|
|
784
|
+
} else if (storeAction.includes('Sil')) {
|
|
785
|
+
const storeList = stores.map(s => `${s.name || s.platform} (${s.platform})`);
|
|
786
|
+
const { selectedStore } = await inquirer.prompt([
|
|
787
|
+
{ type: 'list', name: 'selectedStore', message: 'Silinecek mağaza:', choices: storeList }
|
|
788
|
+
]);
|
|
789
|
+
|
|
790
|
+
const idx = storeList.indexOf(selectedStore);
|
|
791
|
+
if (idx >= 0) {
|
|
792
|
+
await db.Store.destroy({ where: { id: stores[idx].id } });
|
|
793
|
+
console.log(chalk.green(' ✅ Mağaza silindi!'));
|
|
794
|
+
await new Promise(r => setTimeout(r, 1000));
|
|
795
|
+
}
|
|
796
|
+
} else if (storeAction.includes('Durum')) {
|
|
797
|
+
const storeList = stores.map(s => `${s.name || s.platform} (${s.platform})`);
|
|
798
|
+
const { selectedStore } = await inquirer.prompt([
|
|
799
|
+
{ type: 'list', name: 'selectedStore', message: 'Durumu değiştirilecek mağaza:', choices: storeList }
|
|
800
|
+
]);
|
|
801
|
+
|
|
802
|
+
const idx = storeList.indexOf(selectedStore);
|
|
803
|
+
if (idx >= 0) {
|
|
804
|
+
const store = stores[idx];
|
|
805
|
+
await db.Store.update({ active: !store.isActive }, { where: { id: store.id } });
|
|
806
|
+
console.log(chalk.green(` ✅ Durum değiştirildi!`));
|
|
807
|
+
await new Promise(r => setTimeout(r, 1000));
|
|
808
|
+
}
|
|
809
|
+
} else if (storeAction.includes('Düzenle')) {
|
|
810
|
+
console.log(chalk.yellow('\n ⚠️ Düzenleme özelliği yakında!'));
|
|
811
|
+
await new Promise(r => setTimeout(r, 1500));
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
break;
|
|
815
|
+
|
|
650
816
|
case 'exit':
|
|
651
817
|
case 'quit':
|
|
652
818
|
console.log(chalk.yellow('\n👋 Vantuz kapatılıyor...'));
|