vantuz 3.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/LICENSE +45 -0
- package/README.md +44 -0
- package/cli.js +420 -0
- package/core/ai-analyst.js +46 -0
- package/core/database.js +74 -0
- package/core/license-manager.js +50 -0
- package/core/product-manager.js +134 -0
- package/package.json +72 -0
- package/plugins/vantuz/index.js +480 -0
- package/plugins/vantuz/memory/hippocampus.js +464 -0
- package/plugins/vantuz/package.json +21 -0
- package/plugins/vantuz/platforms/amazon.js +239 -0
- package/plugins/vantuz/platforms/ciceksepeti.js +175 -0
- package/plugins/vantuz/platforms/hepsiburada.js +189 -0
- package/plugins/vantuz/platforms/index.js +215 -0
- package/plugins/vantuz/platforms/n11.js +263 -0
- package/plugins/vantuz/platforms/pazarama.js +171 -0
- package/plugins/vantuz/platforms/pttavm.js +136 -0
- package/plugins/vantuz/platforms/trendyol.js +307 -0
- package/plugins/vantuz/services/alerts.js +253 -0
- package/plugins/vantuz/services/license.js +237 -0
- package/plugins/vantuz/services/scheduler.js +232 -0
- package/plugins/vantuz/tools/analytics.js +152 -0
- package/plugins/vantuz/tools/crossborder.js +187 -0
- package/plugins/vantuz/tools/nl-parser.js +211 -0
- package/plugins/vantuz/tools/product.js +110 -0
- package/plugins/vantuz/tools/quick-report.js +175 -0
- package/plugins/vantuz/tools/repricer.js +314 -0
- package/plugins/vantuz/tools/sentiment.js +115 -0
- package/plugins/vantuz/tools/vision.js +257 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🔐 UZAK LİSANS DOĞRULAMA SİSTEMİ
|
|
3
|
+
* Lisans anahtarları sunucuda saklanır, müşteri göremez
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import crypto from 'crypto';
|
|
7
|
+
import fs from 'fs';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
|
|
11
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const LOCAL_CACHE = path.join(__dirname, '..', '..', '.license-cache');
|
|
13
|
+
const LICENSE_DURATION_DAYS = 365;
|
|
14
|
+
|
|
15
|
+
// Sunucu URL (gerçek sunucunuz olduğunda değiştirin)
|
|
16
|
+
const LICENSE_SERVER = process.env.VANTUZ_LICENSE_SERVER || 'https://license.vantuz.ai';
|
|
17
|
+
|
|
18
|
+
export class LicenseManager {
|
|
19
|
+
constructor(api = null) {
|
|
20
|
+
this.api = api;
|
|
21
|
+
this.currentLicense = null;
|
|
22
|
+
this.licenseData = null;
|
|
23
|
+
this.isValidated = false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Başlatma - önce cache kontrol, sonra sunucu
|
|
28
|
+
*/
|
|
29
|
+
async initialize() {
|
|
30
|
+
const envKey = process.env.VANTUZ_LICENSE_KEY;
|
|
31
|
+
if (envKey) {
|
|
32
|
+
// Önce local cache kontrol
|
|
33
|
+
const cached = this._loadCache();
|
|
34
|
+
if (cached && cached.key === envKey && this._isNotExpired(cached)) {
|
|
35
|
+
this.currentLicense = envKey;
|
|
36
|
+
this.licenseData = cached;
|
|
37
|
+
this.isValidated = true;
|
|
38
|
+
return { success: true, cached: true };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Cache yoksa veya geçersizse sunucuya sor
|
|
42
|
+
return await this.activate(envKey);
|
|
43
|
+
}
|
|
44
|
+
return { success: false, demo: true };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Lisans formatını doğrula (offline)
|
|
49
|
+
*/
|
|
50
|
+
validateFormat(key) {
|
|
51
|
+
const pattern = /^VNTUZ-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{4}$/;
|
|
52
|
+
if (!pattern.test(key)) {
|
|
53
|
+
return { valid: false, error: 'Geçersiz lisans formatı' };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Checksum doğrula
|
|
57
|
+
const parts = key.split('-');
|
|
58
|
+
const checksum = parts.pop();
|
|
59
|
+
const keyWithoutChecksum = parts.join('-');
|
|
60
|
+
const expectedChecksum = crypto.createHash('md5').update(keyWithoutChecksum).digest('hex').slice(0, 4).toUpperCase();
|
|
61
|
+
|
|
62
|
+
if (checksum !== expectedChecksum) {
|
|
63
|
+
return { valid: false, error: 'Lisans doğrulama başarısız' };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return { valid: true };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Sunucudan lisans doğrula
|
|
71
|
+
*/
|
|
72
|
+
async activate(key) {
|
|
73
|
+
// Format kontrolü
|
|
74
|
+
const formatCheck = this.validateFormat(key);
|
|
75
|
+
if (!formatCheck.valid) {
|
|
76
|
+
return { success: false, error: formatCheck.error };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
// Sunucuya doğrulama isteği (gerçek sunucu olmadığında offline mod)
|
|
81
|
+
const result = await this._verifyWithServer(key);
|
|
82
|
+
|
|
83
|
+
if (result.success) {
|
|
84
|
+
this.currentLicense = key;
|
|
85
|
+
this.licenseData = result.data;
|
|
86
|
+
this.isValidated = true;
|
|
87
|
+
|
|
88
|
+
// Cache'e kaydet (7 gün geçerli)
|
|
89
|
+
this._saveCache({
|
|
90
|
+
key,
|
|
91
|
+
...result.data,
|
|
92
|
+
cachedAt: new Date().toISOString(),
|
|
93
|
+
cacheExpires: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString()
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return result;
|
|
100
|
+
} catch (error) {
|
|
101
|
+
// Sunucuya ulaşılamazsa cache kullan
|
|
102
|
+
const cached = this._loadCache();
|
|
103
|
+
if (cached && cached.key === key) {
|
|
104
|
+
this.currentLicense = key;
|
|
105
|
+
this.licenseData = cached;
|
|
106
|
+
this.isValidated = true;
|
|
107
|
+
return { success: true, offline: true, data: cached };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Format doğruysa demo modda çalışsın
|
|
111
|
+
return {
|
|
112
|
+
success: false,
|
|
113
|
+
error: 'Lisans sunucusuna ulaşılamadı',
|
|
114
|
+
demo: true,
|
|
115
|
+
offlineValid: formatCheck.valid
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Sunucu ile iletişim
|
|
122
|
+
*/
|
|
123
|
+
async _verifyWithServer(key) {
|
|
124
|
+
// Gerçek sunucu olmadan offline doğrulama
|
|
125
|
+
// Gerçek implementasyonda fetch kullanılır
|
|
126
|
+
|
|
127
|
+
// Şimdilik format doğruysa geçerli say (sunucu kurulunca değişir)
|
|
128
|
+
const formatValid = this.validateFormat(key);
|
|
129
|
+
if (formatValid.valid) {
|
|
130
|
+
const now = new Date();
|
|
131
|
+
return {
|
|
132
|
+
success: true,
|
|
133
|
+
data: {
|
|
134
|
+
status: 'active',
|
|
135
|
+
activatedAt: now.toISOString(),
|
|
136
|
+
expiresAt: new Date(now.getTime() + LICENSE_DURATION_DAYS * 24 * 60 * 60 * 1000).toISOString(),
|
|
137
|
+
features: ['repricer', 'vision', 'sentiment', 'crossborder', 'analytics']
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return { success: false, error: 'Geçersiz lisans' };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Cache yönetimi
|
|
147
|
+
*/
|
|
148
|
+
_loadCache() {
|
|
149
|
+
try {
|
|
150
|
+
if (fs.existsSync(LOCAL_CACHE)) {
|
|
151
|
+
const data = JSON.parse(fs.readFileSync(LOCAL_CACHE, 'utf-8'));
|
|
152
|
+
// Cache süresi dolmamışsa kullan
|
|
153
|
+
if (data.cacheExpires && new Date(data.cacheExpires) > new Date()) {
|
|
154
|
+
return data;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
} catch (e) { }
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
_saveCache(data) {
|
|
162
|
+
try {
|
|
163
|
+
fs.writeFileSync(LOCAL_CACHE, JSON.stringify(data, null, 2));
|
|
164
|
+
} catch (e) { }
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
_isNotExpired(data) {
|
|
168
|
+
if (!data.expiresAt) return false;
|
|
169
|
+
return new Date(data.expiresAt) > new Date();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Lisans geçerli mi?
|
|
174
|
+
*/
|
|
175
|
+
isValid() {
|
|
176
|
+
if (!this.licenseData) return false;
|
|
177
|
+
if (this.licenseData.status !== 'active') return false;
|
|
178
|
+
return this._isNotExpired(this.licenseData);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Özellik kontrolü
|
|
183
|
+
*/
|
|
184
|
+
hasFeature(feature) {
|
|
185
|
+
if (!this.isValid()) return false;
|
|
186
|
+
const features = this.licenseData?.features || [];
|
|
187
|
+
return features.includes(feature) || features.includes('all');
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Durum bilgisi (anahtarı GÖSTERMİYORUZ)
|
|
192
|
+
*/
|
|
193
|
+
getStatus() {
|
|
194
|
+
if (!this.licenseData) {
|
|
195
|
+
return {
|
|
196
|
+
valid: false,
|
|
197
|
+
reason: 'Lisans yüklenmemiş',
|
|
198
|
+
demo: true
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const expiresAt = new Date(this.licenseData.expiresAt);
|
|
203
|
+
const now = new Date();
|
|
204
|
+
const daysLeft = Math.ceil((expiresAt - now) / (1000 * 60 * 60 * 24));
|
|
205
|
+
|
|
206
|
+
if (expiresAt < now) {
|
|
207
|
+
return {
|
|
208
|
+
valid: false,
|
|
209
|
+
reason: 'Lisans süresi dolmuş'
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return {
|
|
214
|
+
valid: true,
|
|
215
|
+
// ANAHTAR GÖZÜKMÜYOR! Sadece ilk 6 + son 4 karakter
|
|
216
|
+
keyHint: this.currentLicense ?
|
|
217
|
+
`${this.currentLicense.slice(0, 6)}...${this.currentLicense.slice(-4)}` : null,
|
|
218
|
+
expiresAt: this.licenseData.expiresAt,
|
|
219
|
+
daysLeft,
|
|
220
|
+
features: this.licenseData.features,
|
|
221
|
+
status: this.licenseData.status
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Demo modda mı?
|
|
227
|
+
*/
|
|
228
|
+
isDemo() {
|
|
229
|
+
return !this.isValid();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
async verify() {
|
|
233
|
+
return this.isValid();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export default LicenseManager;
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⏰ CRON ZAMANLAYICI
|
|
3
|
+
* OpenClaw cron entegrasyonu ile otomatik görevler
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const PRESETS = {
|
|
7
|
+
'15dk': '*/15 * * * *', // Her 15 dakikada
|
|
8
|
+
'30dk': '*/30 * * * *', // Her 30 dakikada
|
|
9
|
+
'saatlik': '0 * * * *', // Her saat başı
|
|
10
|
+
'gunluk-9': '0 9 * * *', // Her gün 09:00
|
|
11
|
+
'gunluk-18': '0 18 * * *', // Her gün 18:00
|
|
12
|
+
'haftalik': '0 9 * * 1', // Pazartesi 09:00
|
|
13
|
+
'aylik': '0 9 1 * *' // Ayın 1'i 09:00
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const TASK_TEMPLATES = {
|
|
17
|
+
'rakip-kontrol': {
|
|
18
|
+
prompt: 'Tüm ürünlerin rakip fiyatlarını kontrol et ve avantaj/dezavantaj durumunu raporla',
|
|
19
|
+
defaultSchedule: '*/15 * * * *'
|
|
20
|
+
},
|
|
21
|
+
'stok-uyari': {
|
|
22
|
+
prompt: 'Stoku 5 ve altına düşen ürünleri tespit et ve kritik olanları bildir',
|
|
23
|
+
defaultSchedule: '0 */2 * * *'
|
|
24
|
+
},
|
|
25
|
+
'gunluk-rapor': {
|
|
26
|
+
prompt: 'Günlük satış özeti hazırla: toplam ciro, sipariş sayısı, en çok satanlar',
|
|
27
|
+
defaultSchedule: '0 18 * * *'
|
|
28
|
+
},
|
|
29
|
+
'haftalik-analiz': {
|
|
30
|
+
prompt: 'Haftalık performans analizi: satış trendi, kar marjı, en iyi/kötü ürünler',
|
|
31
|
+
defaultSchedule: '0 9 * * 1'
|
|
32
|
+
},
|
|
33
|
+
'fiyat-optimizasyon': {
|
|
34
|
+
prompt: 'Düşük satış hızlı ürünlerde fiyat optimizasyonu öner',
|
|
35
|
+
defaultSchedule: '0 10 * * *'
|
|
36
|
+
},
|
|
37
|
+
'yorum-analiz': {
|
|
38
|
+
prompt: 'Son 24 saatteki olumsuz yorumları analiz et ve aksiyon öner',
|
|
39
|
+
defaultSchedule: '0 9 * * *'
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export class SchedulerService {
|
|
44
|
+
constructor(api) {
|
|
45
|
+
this.api = api;
|
|
46
|
+
this.jobs = new Map();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Hazır şablon ekle
|
|
51
|
+
*/
|
|
52
|
+
async addPreset(taskName, customSchedule = null) {
|
|
53
|
+
const template = TASK_TEMPLATES[taskName];
|
|
54
|
+
if (!template) {
|
|
55
|
+
return { success: false, error: `Bilinmeyen görev: ${taskName}` };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const schedule = customSchedule || template.defaultSchedule;
|
|
59
|
+
return await this.addJob({
|
|
60
|
+
id: `vantuz-${taskName}`,
|
|
61
|
+
schedule,
|
|
62
|
+
prompt: template.prompt
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Özel görev ekle
|
|
68
|
+
*/
|
|
69
|
+
async addJob(job) {
|
|
70
|
+
const { id, schedule, prompt, enabled = true } = job;
|
|
71
|
+
|
|
72
|
+
// Cron ifadesini çöz
|
|
73
|
+
const cronSchedule = PRESETS[schedule] || schedule;
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
if (this.api.cron) {
|
|
77
|
+
await this.api.cron.add({
|
|
78
|
+
id,
|
|
79
|
+
schedule: cronSchedule,
|
|
80
|
+
action: {
|
|
81
|
+
type: 'agent',
|
|
82
|
+
prompt: prompt
|
|
83
|
+
},
|
|
84
|
+
enabled
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
this.jobs.set(id, { ...job, cronSchedule });
|
|
89
|
+
return { success: true, jobId: id };
|
|
90
|
+
} catch (error) {
|
|
91
|
+
return { success: false, error: error.message };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Görev sil
|
|
97
|
+
*/
|
|
98
|
+
async removeJob(jobId) {
|
|
99
|
+
try {
|
|
100
|
+
if (this.api.cron) {
|
|
101
|
+
await this.api.cron.remove({ jobId });
|
|
102
|
+
}
|
|
103
|
+
this.jobs.delete(jobId);
|
|
104
|
+
return { success: true };
|
|
105
|
+
} catch (error) {
|
|
106
|
+
return { success: false, error: error.message };
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Görevi hemen çalıştır
|
|
112
|
+
*/
|
|
113
|
+
async runNow(jobId) {
|
|
114
|
+
try {
|
|
115
|
+
if (this.api.cron) {
|
|
116
|
+
await this.api.cron.run({ jobId });
|
|
117
|
+
}
|
|
118
|
+
return { success: true };
|
|
119
|
+
} catch (error) {
|
|
120
|
+
return { success: false, error: error.message };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Görevi duraklat/devam ettir
|
|
126
|
+
*/
|
|
127
|
+
async toggleJob(jobId, enabled) {
|
|
128
|
+
try {
|
|
129
|
+
if (this.api.cron) {
|
|
130
|
+
await this.api.cron.update({ jobId, patch: { enabled } });
|
|
131
|
+
}
|
|
132
|
+
const job = this.jobs.get(jobId);
|
|
133
|
+
if (job) {
|
|
134
|
+
job.enabled = enabled;
|
|
135
|
+
}
|
|
136
|
+
return { success: true };
|
|
137
|
+
} catch (error) {
|
|
138
|
+
return { success: false, error: error.message };
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Tüm görevleri listele
|
|
144
|
+
*/
|
|
145
|
+
async listJobs() {
|
|
146
|
+
try {
|
|
147
|
+
if (this.api.cron) {
|
|
148
|
+
const result = await this.api.cron.list();
|
|
149
|
+
return { success: true, jobs: result };
|
|
150
|
+
}
|
|
151
|
+
return { success: true, jobs: Array.from(this.jobs.values()) };
|
|
152
|
+
} catch (error) {
|
|
153
|
+
return { success: false, error: error.message };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Mevcut şablonları listele
|
|
159
|
+
*/
|
|
160
|
+
getTemplates() {
|
|
161
|
+
return Object.entries(TASK_TEMPLATES).map(([key, val]) => ({
|
|
162
|
+
name: key,
|
|
163
|
+
description: val.prompt,
|
|
164
|
+
schedule: val.defaultSchedule,
|
|
165
|
+
scheduleHuman: this.cronToHuman(val.defaultSchedule)
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Cron ifadesini insan diline çevir
|
|
171
|
+
*/
|
|
172
|
+
cronToHuman(cron) {
|
|
173
|
+
const mappings = {
|
|
174
|
+
'*/15 * * * *': 'Her 15 dakikada bir',
|
|
175
|
+
'*/30 * * * *': 'Her 30 dakikada bir',
|
|
176
|
+
'0 * * * *': 'Her saat başı',
|
|
177
|
+
'0 9 * * *': 'Her gün 09:00',
|
|
178
|
+
'0 10 * * *': 'Her gün 10:00',
|
|
179
|
+
'0 18 * * *': 'Her gün 18:00',
|
|
180
|
+
'0 9 * * 1': 'Her Pazartesi 09:00',
|
|
181
|
+
'0 */2 * * *': 'Her 2 saatte bir'
|
|
182
|
+
};
|
|
183
|
+
return mappings[cron] || cron;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export const schedulerTool = {
|
|
188
|
+
name: 'schedule',
|
|
189
|
+
|
|
190
|
+
async execute(params, context) {
|
|
191
|
+
const { action, task, schedule, jobId, enabled } = params;
|
|
192
|
+
const scheduler = new SchedulerService(context.api);
|
|
193
|
+
|
|
194
|
+
switch (action) {
|
|
195
|
+
case 'add':
|
|
196
|
+
case 'ekle':
|
|
197
|
+
if (TASK_TEMPLATES[task]) {
|
|
198
|
+
return await scheduler.addPreset(task, schedule);
|
|
199
|
+
} else {
|
|
200
|
+
return await scheduler.addJob({ id: jobId || `vantuz-${Date.now()}`, schedule, prompt: task });
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
case 'remove':
|
|
204
|
+
case 'sil':
|
|
205
|
+
return await scheduler.removeJob(jobId);
|
|
206
|
+
|
|
207
|
+
case 'run':
|
|
208
|
+
case 'calistir':
|
|
209
|
+
return await scheduler.runNow(jobId);
|
|
210
|
+
|
|
211
|
+
case 'toggle':
|
|
212
|
+
case 'degistir':
|
|
213
|
+
return await scheduler.toggleJob(jobId, enabled);
|
|
214
|
+
|
|
215
|
+
case 'list':
|
|
216
|
+
case 'listele':
|
|
217
|
+
return await scheduler.listJobs();
|
|
218
|
+
|
|
219
|
+
case 'templates':
|
|
220
|
+
case 'sablonlar':
|
|
221
|
+
return { success: true, templates: scheduler.getTemplates() };
|
|
222
|
+
|
|
223
|
+
default:
|
|
224
|
+
return {
|
|
225
|
+
success: false,
|
|
226
|
+
error: 'Geçersiz action. Kullanım: add, remove, run, toggle, list, templates'
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export default SchedulerService;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 📊 Analytics Tool
|
|
3
|
+
* Satış, stok ve performans raporları
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const analyticsTool = {
|
|
7
|
+
name: 'analytics',
|
|
8
|
+
|
|
9
|
+
async execute(params, context) {
|
|
10
|
+
const { api, memory } = context;
|
|
11
|
+
const { reportType, platform = 'all', period = '7d' } = params;
|
|
12
|
+
|
|
13
|
+
switch (reportType) {
|
|
14
|
+
case 'sales':
|
|
15
|
+
return await this._salesReport(platform, period, context);
|
|
16
|
+
case 'stock':
|
|
17
|
+
return await this._stockReport(platform, context);
|
|
18
|
+
case 'profit':
|
|
19
|
+
return await this._profitReport(platform, period, context);
|
|
20
|
+
case 'competitors':
|
|
21
|
+
return await this._competitorReport(platform, context);
|
|
22
|
+
case 'trends':
|
|
23
|
+
return await this._trendsReport(context);
|
|
24
|
+
default:
|
|
25
|
+
return { success: false, error: 'Geçersiz rapor türü' };
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
async getSalesReport(period, context) {
|
|
30
|
+
// TODO: Gerçek verilerle
|
|
31
|
+
const periodDays = this._parsePeriod(period);
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
period,
|
|
35
|
+
revenue: 125750.90,
|
|
36
|
+
orders: 342,
|
|
37
|
+
avgBasket: 367.69,
|
|
38
|
+
topProduct: 'iPhone 15 Pro Kılıf - Siyah',
|
|
39
|
+
growth: '+12%',
|
|
40
|
+
platforms: {
|
|
41
|
+
trendyol: { revenue: 75000, orders: 205 },
|
|
42
|
+
hepsiburada: { revenue: 35000, orders: 95 },
|
|
43
|
+
n11: { revenue: 15750.90, orders: 42 }
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
async _salesReport(platform, period, context) {
|
|
49
|
+
const data = await this.getSalesReport(period, context);
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
success: true,
|
|
53
|
+
report: data,
|
|
54
|
+
insights: [
|
|
55
|
+
`📈 Geçen ${period}'e göre satışlar %12 arttı.`,
|
|
56
|
+
`🏆 En çok satan ürün: ${data.topProduct}`,
|
|
57
|
+
`💰 Ortalama sepet tutarı: ${data.avgBasket.toFixed(2)} ₺`
|
|
58
|
+
]
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
async _stockReport(platform, context) {
|
|
63
|
+
return {
|
|
64
|
+
success: true,
|
|
65
|
+
report: {
|
|
66
|
+
totalProducts: 1532,
|
|
67
|
+
totalStock: 45680,
|
|
68
|
+
criticalStock: 45,
|
|
69
|
+
outOfStock: 12,
|
|
70
|
+
overstock: 23
|
|
71
|
+
},
|
|
72
|
+
alerts: [
|
|
73
|
+
'⚠️ 45 ürün kritik stok seviyesinde (<5 adet)',
|
|
74
|
+
'❌ 12 ürün stok dışı',
|
|
75
|
+
'📦 23 ürün fazla stoklu (>100 adet, 90 gündür satış yok)'
|
|
76
|
+
],
|
|
77
|
+
actionRequired: [
|
|
78
|
+
{ sku: 'SKU-001', name: 'iPhone Kılıf', stock: 2, action: 'Sipariş ver' },
|
|
79
|
+
{ sku: 'SKU-002', name: 'Samsung Kılıf', stock: 0, action: 'Acil tedarik' }
|
|
80
|
+
]
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
async _profitReport(platform, period, context) {
|
|
85
|
+
return {
|
|
86
|
+
success: true,
|
|
87
|
+
report: {
|
|
88
|
+
revenue: 125750.90,
|
|
89
|
+
costs: 78500.00,
|
|
90
|
+
grossProfit: 47250.90,
|
|
91
|
+
profitMargin: '37.6%',
|
|
92
|
+
topProfitProducts: [
|
|
93
|
+
{ name: 'Premium Kılıf', profit: 8500, margin: '45%' },
|
|
94
|
+
{ name: 'Wireless Şarj', profit: 6200, margin: '42%' }
|
|
95
|
+
],
|
|
96
|
+
lowMarginProducts: [
|
|
97
|
+
{ name: 'Basic Kılıf', margin: '12%', recommendation: 'Fiyat artır' }
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
async _competitorReport(platform, context) {
|
|
104
|
+
return {
|
|
105
|
+
success: true,
|
|
106
|
+
report: {
|
|
107
|
+
tracked: 150,
|
|
108
|
+
priceAdvantage: 45,
|
|
109
|
+
priceDisadvantage: 32,
|
|
110
|
+
priceParity: 73
|
|
111
|
+
},
|
|
112
|
+
opportunities: [
|
|
113
|
+
{ product: 'iPhone 15 Kılıf', yourPrice: 199, avgCompetitor: 229, action: 'Fiyat artırabilirsin' },
|
|
114
|
+
{ product: 'Samsung Kılıf', yourPrice: 149, avgCompetitor: 129, action: 'Rakipler daha ucuz' }
|
|
115
|
+
]
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
async _trendsReport(context) {
|
|
120
|
+
return {
|
|
121
|
+
success: true,
|
|
122
|
+
report: {
|
|
123
|
+
rising: [
|
|
124
|
+
{ term: 'MagSafe şarj', growth: '+420%', volume: 12500 },
|
|
125
|
+
{ term: 'iPhone 15 kılıf', growth: '+180%', volume: 45000 }
|
|
126
|
+
],
|
|
127
|
+
falling: [
|
|
128
|
+
{ term: 'iPhone 12 kılıf', decline: '-35%' }
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
recommendations: [
|
|
132
|
+
'🔥 MagSafe ürünleri trend! Envantere ekle.',
|
|
133
|
+
'📉 iPhone 12 aksesuarları düşüşte, stoğu eritmeye odaklan.'
|
|
134
|
+
]
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
_parsePeriod(period) {
|
|
139
|
+
const match = period.match(/(\d+)([dhm])/);
|
|
140
|
+
if (!match) return 7;
|
|
141
|
+
|
|
142
|
+
const value = parseInt(match[1]);
|
|
143
|
+
const unit = match[2];
|
|
144
|
+
|
|
145
|
+
switch (unit) {
|
|
146
|
+
case 'd': return value;
|
|
147
|
+
case 'h': return value / 24;
|
|
148
|
+
case 'm': return value * 30;
|
|
149
|
+
default: return 7;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|