vantuz 3.4.1 → 3.5.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.
Files changed (70) hide show
  1. package/LICENSE +45 -45
  2. package/admin-keygen.js +51 -0
  3. package/cli.js +685 -585
  4. package/config.js +733 -733
  5. package/core/agent-loop.js +190 -190
  6. package/core/ai-provider.js +298 -261
  7. package/core/automation.js +523 -523
  8. package/core/brand-analyst.js +101 -0
  9. package/core/channels.js +167 -167
  10. package/core/dashboard.js +230 -230
  11. package/core/database.js +135 -36
  12. package/core/eia-monitor.js +3 -1
  13. package/core/engine.js +648 -636
  14. package/core/gateway.js +447 -447
  15. package/core/learning.js +214 -214
  16. package/core/license.js +113 -0
  17. package/core/marketplace-adapter.js +168 -168
  18. package/core/memory.js +190 -190
  19. package/core/migrations/001-initial-schema.sql +1 -1
  20. package/core/queue.js +120 -120
  21. package/core/self-healer.js +314 -314
  22. package/core/unified-product.js +214 -214
  23. package/core/vision-service.js +113 -113
  24. package/index.js +217 -174
  25. package/modules/crm/sentiment-crm.js +231 -231
  26. package/modules/healer/listing-healer.js +201 -201
  27. package/modules/oracle/predictor.js +214 -214
  28. package/modules/researcher/agent.js +169 -169
  29. package/modules/team/agents/base.js +92 -92
  30. package/modules/team/agents/dev.js +33 -33
  31. package/modules/team/agents/josh.js +40 -40
  32. package/modules/team/agents/marketing.js +33 -33
  33. package/modules/team/agents/milo.js +36 -36
  34. package/modules/team/index.js +78 -78
  35. package/modules/team/shared-memory.js +87 -87
  36. package/modules/war-room/competitor-tracker.js +250 -250
  37. package/modules/war-room/pricing-engine.js +308 -308
  38. package/nodes/warehouse.js +238 -238
  39. package/onboard.js +1 -1
  40. package/package.json +7 -6
  41. package/platforms/pttavm.js +14 -14
  42. package/plugins/vantuz/index.js +528 -528
  43. package/plugins/vantuz/memory/hippocampus.js +465 -464
  44. package/plugins/vantuz/package.json +20 -20
  45. package/plugins/vantuz/platforms/_template.js +118 -118
  46. package/plugins/vantuz/platforms/amazon.js +236 -236
  47. package/plugins/vantuz/platforms/ciceksepeti.js +166 -166
  48. package/plugins/vantuz/platforms/hepsiburada.js +180 -180
  49. package/plugins/vantuz/platforms/index.js +165 -165
  50. package/plugins/vantuz/platforms/n11.js +229 -229
  51. package/plugins/vantuz/platforms/pazarama.js +154 -154
  52. package/plugins/vantuz/platforms/pttavm.js +127 -127
  53. package/plugins/vantuz/platforms/trendyol.js +326 -326
  54. package/plugins/vantuz/services/alerts.js +253 -253
  55. package/plugins/vantuz/services/license.js +34 -34
  56. package/plugins/vantuz/services/scheduler.js +232 -232
  57. package/plugins/vantuz/tools/analytics.js +152 -152
  58. package/plugins/vantuz/tools/crossborder.js +187 -187
  59. package/plugins/vantuz/tools/nl-parser.js +211 -211
  60. package/plugins/vantuz/tools/product.js +110 -110
  61. package/plugins/vantuz/tools/quick-report.js +175 -175
  62. package/plugins/vantuz/tools/repricer.js +314 -314
  63. package/plugins/vantuz/tools/sentiment.js +115 -115
  64. package/plugins/vantuz/tools/vision.js +257 -257
  65. package/private.pem +28 -0
  66. package/public.pem +9 -0
  67. package/server/app.js +260 -260
  68. package/server/public/index.html +514 -514
  69. package/start.bat +33 -33
  70. package/vantuz.sqlite +0 -0
@@ -1,211 +1,211 @@
1
- /**
2
- * 🧠 AKILLI KOMUT AYRISTIRICI
3
- * Doğal dil mesajlarını e-ticaret komutlarına çevir
4
- *
5
- * Kullanıcı: "trendyoldaki kırmızı kılıfların fiyatını 149 yap"
6
- * Çıktı: { action: 'updatePrice', platform: 'trendyol', filter: 'kırmızı kılıf', price: 149 }
7
- */
8
-
9
- const PRICE_PATTERNS = [
10
- /(?:fiyat[ıi]n[ıi]?|fiyat)\s*(?:şimdi\s+)?(\d+(?:[.,]\d+)?)\s*(?:tl|₺|lira)?(?:\s*yap)?/i,
11
- /(\d+(?:[.,]\d+)?)\s*(?:tl|₺|lira)?\s*(?:yap|ol(?:sun)?|ayarla)/i,
12
- /(?:yeni\s+fiyat|güncel\s+fiyat)[:\s]*(\d+(?:[.,]\d+)?)/i,
13
- /%(\d+)\s*(?:indir|düşür|azalt)/i,
14
- /%(\d+)\s*(?:artır|yükselt|zam)/i
15
- ];
16
-
17
- const STOCK_PATTERNS = [
18
- /stok[u]?\s*(\d+)\s*(?:yap|ol(?:sun)?|ayarla)?/i,
19
- /(\d+)\s*adet\s*(?:stok|envanter)/i,
20
- /(?:stok|envanter)[:\s]*(\d+)/i
21
- ];
22
-
23
- const PLATFORM_PATTERNS = {
24
- trendyol: /trendyol|ty/i,
25
- hepsiburada: /hepsiburada|hb/i,
26
- n11: /n11/i,
27
- amazon: /amazon|amz/i,
28
- ciceksepeti: /çiçek\s*sepeti|ciceksepeti|cs/i,
29
- pttavm: /ptt\s*avm|pttavm|ptt/i,
30
- pazarama: /pazarama|pzr/i
31
- };
32
-
33
- const ACTION_PATTERNS = {
34
- updatePrice: /fiyat|price|ücret|tutar/i,
35
- updateStock: /stok|stock|envanter|adet/i,
36
- getOrders: /sipariş|order|satış/i,
37
- getProducts: /ürün|product|liste/i,
38
- analyze: /analiz|rapor|report|özet/i,
39
- competitor: /rakip|rekabet|competitor/i
40
- };
41
-
42
- const TIME_PATTERNS = {
43
- '1d': /bugün|son\s*1\s*gün|dün/i,
44
- '7d': /son\s*(?:1\s*)?hafta|7\s*gün|bu\s*hafta/i,
45
- '30d': /son\s*(?:1\s*)?ay|30\s*gün|bu\s*ay/i,
46
- '90d': /son\s*3\s*ay|90\s*gün|çeyrek/i
47
- };
48
-
49
- export class NLParser {
50
- /**
51
- * Mesajı analiz et
52
- */
53
- parse(message) {
54
- const result = {
55
- original: message,
56
- action: null,
57
- platform: null,
58
- filter: null,
59
- value: null,
60
- period: null,
61
- confidence: 0,
62
- parsed: {}
63
- };
64
-
65
- // Platform bul
66
- for (const [platform, pattern] of Object.entries(PLATFORM_PATTERNS)) {
67
- if (pattern.test(message)) {
68
- result.platform = platform;
69
- break;
70
- }
71
- }
72
-
73
- // Action bul
74
- for (const [action, pattern] of Object.entries(ACTION_PATTERNS)) {
75
- if (pattern.test(message)) {
76
- result.action = action;
77
- break;
78
- }
79
- }
80
-
81
- // Fiyat değişikliği
82
- for (const pattern of PRICE_PATTERNS) {
83
- const match = message.match(pattern);
84
- if (match) {
85
- result.action = 'updatePrice';
86
- const value = parseFloat(match[1].replace(',', '.'));
87
-
88
- // Yüzde mi yoksa sabit fiyat mı?
89
- if (message.match(/%\d+\s*(?:indir|düşür|azalt)/i)) {
90
- result.parsed.percentChange = -value;
91
- } else if (message.match(/%\d+\s*(?:artır|yükselt|zam)/i)) {
92
- result.parsed.percentChange = value;
93
- } else {
94
- result.parsed.price = value;
95
- }
96
- result.value = value;
97
- break;
98
- }
99
- }
100
-
101
- // Stok değişikliği
102
- for (const pattern of STOCK_PATTERNS) {
103
- const match = message.match(pattern);
104
- if (match) {
105
- result.action = 'updateStock';
106
- result.value = parseInt(match[1]);
107
- result.parsed.stock = result.value;
108
- break;
109
- }
110
- }
111
-
112
- // Zaman dilimi
113
- for (const [period, pattern] of Object.entries(TIME_PATTERNS)) {
114
- if (pattern.test(message)) {
115
- result.period = period;
116
- break;
117
- }
118
- }
119
-
120
- // SKU/Barkod bul
121
- const skuMatch = message.match(/(?:sku|barkod|kod)[:\s]*([A-Z0-9\-]+)/i);
122
- if (skuMatch) {
123
- result.parsed.sku = skuMatch[1];
124
- }
125
-
126
- // Ürün filtresi (kalan kısım)
127
- result.filter = this.extractFilter(message);
128
-
129
- // Güven skoru
130
- result.confidence = this.calculateConfidence(result);
131
-
132
- return result;
133
- }
134
-
135
- /**
136
- * Ürün filtresini çıkar
137
- */
138
- extractFilter(message) {
139
- // Platform ve action kelimelerini temizle
140
- let cleaned = message
141
- .replace(/trendyol|hepsiburada|n11|amazon|çiçeksepeti|pttavm|pazarama/gi, '')
142
- .replace(/fiyat[ıi]?|stok[u]?|sipariş|ürün|analiz|rakip/gi, '')
143
- .replace(/\d+\s*(?:tl|₺|lira)?/gi, '')
144
- .replace(/(?:yap|ol|ayarla|güncelle|değiştir)/gi, '')
145
- .replace(/(?:tüm|hepsi|bütün)/gi, '')
146
- .trim();
147
-
148
- // Anlamlı kelimeler kaldı mı?
149
- const words = cleaned.split(/\s+/).filter(w => w.length > 2);
150
- return words.length > 0 ? words.join(' ') : null;
151
- }
152
-
153
- /**
154
- * Güven skoru hesapla
155
- */
156
- calculateConfidence(result) {
157
- let score = 0;
158
- if (result.action) score += 30;
159
- if (result.platform) score += 20;
160
- if (result.value) score += 25;
161
- if (result.filter || result.parsed.sku) score += 15;
162
- if (result.period) score += 10;
163
- return Math.min(score, 100);
164
- }
165
-
166
- /**
167
- * Sonucu insan diline çevir
168
- */
169
- toHuman(result) {
170
- const parts = [];
171
-
172
- if (result.action === 'updatePrice' && result.parsed.price) {
173
- parts.push(`Fiyatı ${result.parsed.price}₺ yap`);
174
- } else if (result.action === 'updatePrice' && result.parsed.percentChange) {
175
- const dir = result.parsed.percentChange > 0 ? 'artır' : 'düşür';
176
- parts.push(`Fiyatı %${Math.abs(result.parsed.percentChange)} ${dir}`);
177
- } else if (result.action === 'updateStock') {
178
- parts.push(`Stoku ${result.parsed.stock} yap`);
179
- } else if (result.action === 'getOrders') {
180
- parts.push('Siparişleri getir');
181
- } else if (result.action === 'analyze') {
182
- parts.push('Analiz yap');
183
- }
184
-
185
- if (result.platform) {
186
- parts.push(`(${result.platform})`);
187
- }
188
-
189
- if (result.filter) {
190
- parts.push(`"${result.filter}" için`);
191
- }
192
-
193
- if (result.period) {
194
- parts.push(`son ${result.period}`);
195
- }
196
-
197
- return parts.join(' ');
198
- }
199
- }
200
-
201
- // Kısa yardımcı fonksiyonlar
202
- export function parseCommand(message) {
203
- return new NLParser().parse(message);
204
- }
205
-
206
- export function whatDoYouMean(message) {
207
- const result = new NLParser().parse(message);
208
- return new NLParser().toHuman(result);
209
- }
210
-
211
- export default NLParser;
1
+ /**
2
+ * 🧠 AKILLI KOMUT AYRISTIRICI
3
+ * Doğal dil mesajlarını e-ticaret komutlarına çevir
4
+ *
5
+ * Kullanıcı: "trendyoldaki kırmızı kılıfların fiyatını 149 yap"
6
+ * Çıktı: { action: 'updatePrice', platform: 'trendyol', filter: 'kırmızı kılıf', price: 149 }
7
+ */
8
+
9
+ const PRICE_PATTERNS = [
10
+ /(?:fiyat[ıi]n[ıi]?|fiyat)\s*(?:şimdi\s+)?(\d+(?:[.,]\d+)?)\s*(?:tl|₺|lira)?(?:\s*yap)?/i,
11
+ /(\d+(?:[.,]\d+)?)\s*(?:tl|₺|lira)?\s*(?:yap|ol(?:sun)?|ayarla)/i,
12
+ /(?:yeni\s+fiyat|güncel\s+fiyat)[:\s]*(\d+(?:[.,]\d+)?)/i,
13
+ /%(\d+)\s*(?:indir|düşür|azalt)/i,
14
+ /%(\d+)\s*(?:artır|yükselt|zam)/i
15
+ ];
16
+
17
+ const STOCK_PATTERNS = [
18
+ /stok[u]?\s*(\d+)\s*(?:yap|ol(?:sun)?|ayarla)?/i,
19
+ /(\d+)\s*adet\s*(?:stok|envanter)/i,
20
+ /(?:stok|envanter)[:\s]*(\d+)/i
21
+ ];
22
+
23
+ const PLATFORM_PATTERNS = {
24
+ trendyol: /trendyol|ty/i,
25
+ hepsiburada: /hepsiburada|hb/i,
26
+ n11: /n11/i,
27
+ amazon: /amazon|amz/i,
28
+ ciceksepeti: /çiçek\s*sepeti|ciceksepeti|cs/i,
29
+ pttavm: /ptt\s*avm|pttavm|ptt/i,
30
+ pazarama: /pazarama|pzr/i
31
+ };
32
+
33
+ const ACTION_PATTERNS = {
34
+ updatePrice: /fiyat|price|ücret|tutar/i,
35
+ updateStock: /stok|stock|envanter|adet/i,
36
+ getOrders: /sipariş|order|satış/i,
37
+ getProducts: /ürün|product|liste/i,
38
+ analyze: /analiz|rapor|report|özet/i,
39
+ competitor: /rakip|rekabet|competitor/i
40
+ };
41
+
42
+ const TIME_PATTERNS = {
43
+ '1d': /bugün|son\s*1\s*gün|dün/i,
44
+ '7d': /son\s*(?:1\s*)?hafta|7\s*gün|bu\s*hafta/i,
45
+ '30d': /son\s*(?:1\s*)?ay|30\s*gün|bu\s*ay/i,
46
+ '90d': /son\s*3\s*ay|90\s*gün|çeyrek/i
47
+ };
48
+
49
+ export class NLParser {
50
+ /**
51
+ * Mesajı analiz et
52
+ */
53
+ parse(message) {
54
+ const result = {
55
+ original: message,
56
+ action: null,
57
+ platform: null,
58
+ filter: null,
59
+ value: null,
60
+ period: null,
61
+ confidence: 0,
62
+ parsed: {}
63
+ };
64
+
65
+ // Platform bul
66
+ for (const [platform, pattern] of Object.entries(PLATFORM_PATTERNS)) {
67
+ if (pattern.test(message)) {
68
+ result.platform = platform;
69
+ break;
70
+ }
71
+ }
72
+
73
+ // Action bul
74
+ for (const [action, pattern] of Object.entries(ACTION_PATTERNS)) {
75
+ if (pattern.test(message)) {
76
+ result.action = action;
77
+ break;
78
+ }
79
+ }
80
+
81
+ // Fiyat değişikliği
82
+ for (const pattern of PRICE_PATTERNS) {
83
+ const match = message.match(pattern);
84
+ if (match) {
85
+ result.action = 'updatePrice';
86
+ const value = parseFloat(match[1].replace(',', '.'));
87
+
88
+ // Yüzde mi yoksa sabit fiyat mı?
89
+ if (message.match(/%\d+\s*(?:indir|düşür|azalt)/i)) {
90
+ result.parsed.percentChange = -value;
91
+ } else if (message.match(/%\d+\s*(?:artır|yükselt|zam)/i)) {
92
+ result.parsed.percentChange = value;
93
+ } else {
94
+ result.parsed.price = value;
95
+ }
96
+ result.value = value;
97
+ break;
98
+ }
99
+ }
100
+
101
+ // Stok değişikliği
102
+ for (const pattern of STOCK_PATTERNS) {
103
+ const match = message.match(pattern);
104
+ if (match) {
105
+ result.action = 'updateStock';
106
+ result.value = parseInt(match[1]);
107
+ result.parsed.stock = result.value;
108
+ break;
109
+ }
110
+ }
111
+
112
+ // Zaman dilimi
113
+ for (const [period, pattern] of Object.entries(TIME_PATTERNS)) {
114
+ if (pattern.test(message)) {
115
+ result.period = period;
116
+ break;
117
+ }
118
+ }
119
+
120
+ // SKU/Barkod bul
121
+ const skuMatch = message.match(/(?:sku|barkod|kod)[:\s]*([A-Z0-9\-]+)/i);
122
+ if (skuMatch) {
123
+ result.parsed.sku = skuMatch[1];
124
+ }
125
+
126
+ // Ürün filtresi (kalan kısım)
127
+ result.filter = this.extractFilter(message);
128
+
129
+ // Güven skoru
130
+ result.confidence = this.calculateConfidence(result);
131
+
132
+ return result;
133
+ }
134
+
135
+ /**
136
+ * Ürün filtresini çıkar
137
+ */
138
+ extractFilter(message) {
139
+ // Platform ve action kelimelerini temizle
140
+ let cleaned = message
141
+ .replace(/trendyol|hepsiburada|n11|amazon|çiçeksepeti|pttavm|pazarama/gi, '')
142
+ .replace(/fiyat[ıi]?|stok[u]?|sipariş|ürün|analiz|rakip/gi, '')
143
+ .replace(/\d+\s*(?:tl|₺|lira)?/gi, '')
144
+ .replace(/(?:yap|ol|ayarla|güncelle|değiştir)/gi, '')
145
+ .replace(/(?:tüm|hepsi|bütün)/gi, '')
146
+ .trim();
147
+
148
+ // Anlamlı kelimeler kaldı mı?
149
+ const words = cleaned.split(/\s+/).filter(w => w.length > 2);
150
+ return words.length > 0 ? words.join(' ') : null;
151
+ }
152
+
153
+ /**
154
+ * Güven skoru hesapla
155
+ */
156
+ calculateConfidence(result) {
157
+ let score = 0;
158
+ if (result.action) score += 30;
159
+ if (result.platform) score += 20;
160
+ if (result.value) score += 25;
161
+ if (result.filter || result.parsed.sku) score += 15;
162
+ if (result.period) score += 10;
163
+ return Math.min(score, 100);
164
+ }
165
+
166
+ /**
167
+ * Sonucu insan diline çevir
168
+ */
169
+ toHuman(result) {
170
+ const parts = [];
171
+
172
+ if (result.action === 'updatePrice' && result.parsed.price) {
173
+ parts.push(`Fiyatı ${result.parsed.price}₺ yap`);
174
+ } else if (result.action === 'updatePrice' && result.parsed.percentChange) {
175
+ const dir = result.parsed.percentChange > 0 ? 'artır' : 'düşür';
176
+ parts.push(`Fiyatı %${Math.abs(result.parsed.percentChange)} ${dir}`);
177
+ } else if (result.action === 'updateStock') {
178
+ parts.push(`Stoku ${result.parsed.stock} yap`);
179
+ } else if (result.action === 'getOrders') {
180
+ parts.push('Siparişleri getir');
181
+ } else if (result.action === 'analyze') {
182
+ parts.push('Analiz yap');
183
+ }
184
+
185
+ if (result.platform) {
186
+ parts.push(`(${result.platform})`);
187
+ }
188
+
189
+ if (result.filter) {
190
+ parts.push(`"${result.filter}" için`);
191
+ }
192
+
193
+ if (result.period) {
194
+ parts.push(`son ${result.period}`);
195
+ }
196
+
197
+ return parts.join(' ');
198
+ }
199
+ }
200
+
201
+ // Kısa yardımcı fonksiyonlar
202
+ export function parseCommand(message) {
203
+ return new NLParser().parse(message);
204
+ }
205
+
206
+ export function whatDoYouMean(message) {
207
+ const result = new NLParser().parse(message);
208
+ return new NLParser().toHuman(result);
209
+ }
210
+
211
+ export default NLParser;
@@ -1,110 +1,110 @@
1
- /**
2
- * 📦 Product Tool
3
- * Ürün yönetimi işlemleri
4
- */
5
-
6
- export const productTool = {
7
- name: 'product',
8
-
9
- async execute(params, context) {
10
- const { api, memory } = context;
11
- const { action, productId, platform, data } = params;
12
-
13
- switch (action) {
14
- case 'list':
15
- return await this._listProducts(platform, data, context);
16
- case 'get':
17
- return await this._getProduct(productId, platform, context);
18
- case 'update':
19
- return await this._updateProduct(productId, data, context);
20
- case 'updatePrice':
21
- return await this._updatePrice(productId, data.price, platform, context);
22
- case 'updateStock':
23
- return await this._updateStock(productId, data.stock, platform, context);
24
- case 'publish':
25
- return await this._publishProduct(productId, platform, context);
26
- case 'unpublish':
27
- return await this._unpublishProduct(productId, platform, context);
28
- default:
29
- return { success: false, error: 'Geçersiz işlem' };
30
- }
31
- },
32
-
33
- async getStockSummary(platform, context) {
34
- // TODO: Veritabanı/API'den stok özeti
35
- return {
36
- trendyol: { total: 1250, critical: 23, zero: 5 },
37
- hepsiburada: { total: 890, critical: 12, zero: 3 },
38
- n11: { total: 450, critical: 8, zero: 2 },
39
- amazon: { total: 320, critical: 5, zero: 1 }
40
- };
41
- },
42
-
43
- async parseAndUpdatePrice(args, context) {
44
- // Parse: "iPhone kılıf 199 TL" veya "SKU-123 %10 indirim"
45
- if (!args) {
46
- return { success: false, message: '❌ Kullanım: /fiyat [ürün adı/SKU] [yeni fiyat veya %indirim]' };
47
- }
48
-
49
- const percentMatch = args.match(/%(\d+)/);
50
- const priceMatch = args.match(/(\d+(?:[.,]\d+)?)\s*(?:TL|₺)?/i);
51
-
52
- // TODO: Ürünü bul ve fiyatı güncelle
53
-
54
- if (percentMatch) {
55
- const percent = parseInt(percentMatch[1]);
56
- return {
57
- success: true,
58
- message: `✅ Ürünlere %${percent} indirim uygulandı.`
59
- };
60
- }
61
-
62
- if (priceMatch) {
63
- const newPrice = parseFloat(priceMatch[1].replace(',', '.'));
64
- return {
65
- success: true,
66
- message: `✅ Fiyat ${newPrice} ₺ olarak güncellendi.`
67
- };
68
- }
69
-
70
- return { success: false, message: '❌ Fiyat formatı anlaşılamadı.' };
71
- },
72
-
73
- // Private methods
74
- async _listProducts(platform, filters, context) {
75
- return {
76
- success: true,
77
- products: [],
78
- total: 0,
79
- page: 1
80
- };
81
- },
82
-
83
- async _getProduct(productId, platform, context) {
84
- return {
85
- success: true,
86
- product: null
87
- };
88
- },
89
-
90
- async _updateProduct(productId, data, context) {
91
- return { success: true, message: 'Ürün güncellendi.' };
92
- },
93
-
94
- async _updatePrice(productId, price, platform, context) {
95
- context.api.logger.info(`💰 Fiyat güncellendi: ${productId} → ${price} ₺`);
96
- return { success: true, message: `Fiyat ${price} ₺ olarak güncellendi.` };
97
- },
98
-
99
- async _updateStock(productId, stock, platform, context) {
100
- return { success: true, message: `Stok ${stock} olarak güncellendi.` };
101
- },
102
-
103
- async _publishProduct(productId, platform, context) {
104
- return { success: true, message: 'Ürün yayınlandı.' };
105
- },
106
-
107
- async _unpublishProduct(productId, platform, context) {
108
- return { success: true, message: 'Ürün yayından kaldırıldı.' };
109
- }
110
- };
1
+ /**
2
+ * 📦 Product Tool
3
+ * Ürün yönetimi işlemleri
4
+ */
5
+
6
+ export const productTool = {
7
+ name: 'product',
8
+
9
+ async execute(params, context) {
10
+ const { api, memory } = context;
11
+ const { action, productId, platform, data } = params;
12
+
13
+ switch (action) {
14
+ case 'list':
15
+ return await this._listProducts(platform, data, context);
16
+ case 'get':
17
+ return await this._getProduct(productId, platform, context);
18
+ case 'update':
19
+ return await this._updateProduct(productId, data, context);
20
+ case 'updatePrice':
21
+ return await this._updatePrice(productId, data.price, platform, context);
22
+ case 'updateStock':
23
+ return await this._updateStock(productId, data.stock, platform, context);
24
+ case 'publish':
25
+ return await this._publishProduct(productId, platform, context);
26
+ case 'unpublish':
27
+ return await this._unpublishProduct(productId, platform, context);
28
+ default:
29
+ return { success: false, error: 'Geçersiz işlem' };
30
+ }
31
+ },
32
+
33
+ async getStockSummary(platform, context) {
34
+ // TODO: Veritabanı/API'den stok özeti
35
+ return {
36
+ trendyol: { total: 1250, critical: 23, zero: 5 },
37
+ hepsiburada: { total: 890, critical: 12, zero: 3 },
38
+ n11: { total: 450, critical: 8, zero: 2 },
39
+ amazon: { total: 320, critical: 5, zero: 1 }
40
+ };
41
+ },
42
+
43
+ async parseAndUpdatePrice(args, context) {
44
+ // Parse: "iPhone kılıf 199 TL" veya "SKU-123 %10 indirim"
45
+ if (!args) {
46
+ return { success: false, message: '❌ Kullanım: /fiyat [ürün adı/SKU] [yeni fiyat veya %indirim]' };
47
+ }
48
+
49
+ const percentMatch = args.match(/%(\d+)/);
50
+ const priceMatch = args.match(/(\d+(?:[.,]\d+)?)\s*(?:TL|₺)?/i);
51
+
52
+ // TODO: Ürünü bul ve fiyatı güncelle
53
+
54
+ if (percentMatch) {
55
+ const percent = parseInt(percentMatch[1]);
56
+ return {
57
+ success: true,
58
+ message: `✅ Ürünlere %${percent} indirim uygulandı.`
59
+ };
60
+ }
61
+
62
+ if (priceMatch) {
63
+ const newPrice = parseFloat(priceMatch[1].replace(',', '.'));
64
+ return {
65
+ success: true,
66
+ message: `✅ Fiyat ${newPrice} ₺ olarak güncellendi.`
67
+ };
68
+ }
69
+
70
+ return { success: false, message: '❌ Fiyat formatı anlaşılamadı.' };
71
+ },
72
+
73
+ // Private methods
74
+ async _listProducts(platform, filters, context) {
75
+ return {
76
+ success: true,
77
+ products: [],
78
+ total: 0,
79
+ page: 1
80
+ };
81
+ },
82
+
83
+ async _getProduct(productId, platform, context) {
84
+ return {
85
+ success: true,
86
+ product: null
87
+ };
88
+ },
89
+
90
+ async _updateProduct(productId, data, context) {
91
+ return { success: true, message: 'Ürün güncellendi.' };
92
+ },
93
+
94
+ async _updatePrice(productId, price, platform, context) {
95
+ context.api.logger.info(`💰 Fiyat güncellendi: ${productId} → ${price} ₺`);
96
+ return { success: true, message: `Fiyat ${price} ₺ olarak güncellendi.` };
97
+ },
98
+
99
+ async _updateStock(productId, stock, platform, context) {
100
+ return { success: true, message: `Stok ${stock} olarak güncellendi.` };
101
+ },
102
+
103
+ async _publishProduct(productId, platform, context) {
104
+ return { success: true, message: 'Ürün yayınlandı.' };
105
+ },
106
+
107
+ async _unpublishProduct(productId, platform, context) {
108
+ return { success: true, message: 'Ürün yayından kaldırıldı.' };
109
+ }
110
+ };