vantuz 3.4.2 β†’ 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 -37
  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 -5
  41. package/platforms/pttavm.js +14 -14
  42. package/plugins/vantuz/index.js +528 -528
  43. package/plugins/vantuz/memory/hippocampus.js +465 -465
  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,35 +1,35 @@
1
- /**
2
- * 🟑 AMAZON SP-API Entegrasyonu
3
- * developer-docs.amazon.com/sp-api
4
- */
5
-
1
+ /**
2
+ * 🟑 AMAZON SP-API Entegrasyonu
3
+ * developer-docs.amazon.com/sp-api
4
+ */
5
+
6
6
  import axios from 'axios';
7
7
  import crypto from 'crypto';
8
8
  import { requestWithRetry } from './_request.js';
9
-
10
- const REGIONS = {
11
- eu: {
12
- endpoint: 'https://sellingpartnerapi-eu.amazon.com',
13
- marketplace: 'A1PA6795UKMFR9' // DE
14
- },
15
- na: {
16
- endpoint: 'https://sellingpartnerapi-na.amazon.com',
17
- marketplace: 'ATVPDKIKX0DER' // US
18
- },
19
- tr: {
20
- endpoint: 'https://sellingpartnerapi-eu.amazon.com',
21
- marketplace: 'A33AVAJ2PDY3EV' // TR
22
- }
23
- };
24
-
25
- export class AmazonAPI {
26
- constructor(config) {
27
- this.region = config.region || 'eu';
28
- this.sellerId = config.sellerId;
29
- this.clientId = config.clientId;
30
- this.clientSecret = config.clientSecret;
31
- this.refreshToken = config.refreshToken;
32
-
9
+
10
+ const REGIONS = {
11
+ eu: {
12
+ endpoint: 'https://sellingpartnerapi-eu.amazon.com',
13
+ marketplace: 'A1PA6795UKMFR9' // DE
14
+ },
15
+ na: {
16
+ endpoint: 'https://sellingpartnerapi-na.amazon.com',
17
+ marketplace: 'ATVPDKIKX0DER' // US
18
+ },
19
+ tr: {
20
+ endpoint: 'https://sellingpartnerapi-eu.amazon.com',
21
+ marketplace: 'A33AVAJ2PDY3EV' // TR
22
+ }
23
+ };
24
+
25
+ export class AmazonAPI {
26
+ constructor(config) {
27
+ this.region = config.region || 'eu';
28
+ this.sellerId = config.sellerId;
29
+ this.clientId = config.clientId;
30
+ this.clientSecret = config.clientSecret;
31
+ this.refreshToken = config.refreshToken;
32
+
33
33
  this.regionConfig = REGIONS[this.region];
34
34
  this.accessToken = null;
35
35
  this.tokenExpiry = null;
@@ -37,46 +37,46 @@ export class AmazonAPI {
37
37
  }
38
38
 
39
39
  async _getAccessToken() {
40
- if (this.accessToken && this.tokenExpiry > Date.now()) {
41
- return this.accessToken;
42
- }
43
- if (this._tokenPromise) {
44
- return await this._tokenPromise;
45
- }
46
-
47
- this._tokenPromise = (async () => {
48
- try {
49
- const response = await requestWithRetry(axios, {
50
- method: 'POST',
51
- url: 'https://api.amazon.com/auth/o2/token',
52
- data: {
53
- grant_type: 'refresh_token',
54
- refresh_token: this.refreshToken,
55
- client_id: this.clientId,
56
- client_secret: this.clientSecret
57
- }
58
- }, {
59
- retries: 3,
60
- baseDelayMs: 500,
61
- maxDelayMs: 4000
62
- });
63
-
64
- this.accessToken = response.data.access_token;
65
- this.tokenExpiry = Date.now() + (response.data.expires_in * 1000) - 60000;
66
- return this.accessToken;
67
- } catch (error) {
68
- throw new Error('Token alΔ±namadΔ±: ' + error.message);
69
- } finally {
70
- this._tokenPromise = null;
71
- }
72
- })();
73
-
74
- return await this._tokenPromise;
75
- }
76
-
77
- async _request(method, path, data = null, params = null) {
78
- try {
79
- const token = await this._getAccessToken();
40
+ if (this.accessToken && this.tokenExpiry > Date.now()) {
41
+ return this.accessToken;
42
+ }
43
+ if (this._tokenPromise) {
44
+ return await this._tokenPromise;
45
+ }
46
+
47
+ this._tokenPromise = (async () => {
48
+ try {
49
+ const response = await requestWithRetry(axios, {
50
+ method: 'POST',
51
+ url: 'https://api.amazon.com/auth/o2/token',
52
+ data: {
53
+ grant_type: 'refresh_token',
54
+ refresh_token: this.refreshToken,
55
+ client_id: this.clientId,
56
+ client_secret: this.clientSecret
57
+ }
58
+ }, {
59
+ retries: 3,
60
+ baseDelayMs: 500,
61
+ maxDelayMs: 4000
62
+ });
63
+
64
+ this.accessToken = response.data.access_token;
65
+ this.tokenExpiry = Date.now() + (response.data.expires_in * 1000) - 60000;
66
+ return this.accessToken;
67
+ } catch (error) {
68
+ throw new Error('Token alΔ±namadΔ±: ' + error.message);
69
+ } finally {
70
+ this._tokenPromise = null;
71
+ }
72
+ })();
73
+
74
+ return await this._tokenPromise;
75
+ }
76
+
77
+ async _request(method, path, data = null, params = null) {
78
+ try {
79
+ const token = await this._getAccessToken();
80
80
  const response = await requestWithRetry(axios, {
81
81
  method,
82
82
  url: `${this.regionConfig.endpoint}${path}`,
@@ -94,170 +94,170 @@ export class AmazonAPI {
94
94
  baseDelayMs: 500,
95
95
  maxDelayMs: 4000
96
96
  });
97
- return { success: true, data: response.data };
98
- } catch (error) {
99
- return {
100
- success: false,
101
- error: error.response?.data?.errors || error.message
102
- };
103
- }
104
- }
105
-
106
- // ═══════════════════════════════════════════════════════════════════════════
107
- // ÜRÜN İŞLEMLERİ
108
- // ═══════════════════════════════════════════════════════════════════════════
109
-
110
- async getInventory(params = {}) {
111
- const { nextToken, skus } = params;
112
- return await this._request('GET', '/fba/inventory/v1/summaries', null, {
113
- details: true,
114
- granularityType: 'Marketplace',
115
- granularityId: this.regionConfig.marketplace,
116
- sellerSkus: skus?.join(','),
117
- nextToken
118
- });
119
- }
120
-
121
- async getCatalogItem(asin) {
122
- return await this._request('GET', `/catalog/2022-04-01/items/${asin}`, null, {
123
- includedData: 'summaries,attributes,images,productTypes,salesRanks'
124
- });
125
- }
126
-
127
- async searchCatalog(keywords) {
128
- return await this._request('GET', '/catalog/2022-04-01/items', null, {
129
- keywords,
130
- includedData: 'summaries,images'
131
- });
132
- }
133
-
134
- async createListing(sku, productType, attributes) {
135
- return await this._request('PUT', `/listings/2021-08-01/items/${this.sellerId}/${sku}`, {
136
- productType,
137
- attributes,
138
- requirements: 'LISTING'
139
- });
140
- }
141
-
142
- // ═══════════════════════════════════════════════════════════════════════════
143
- // FΔ°YAT
144
- // ═══════════════════════════════════════════════════════════════════════════
145
-
146
- async getPricing(skus) {
147
- return await this._request('GET', '/products/pricing/v0/price', null, {
148
- ItemType: 'Sku',
149
- Skus: skus.join(',')
150
- });
151
- }
152
-
153
- async getCompetitivePricing(asins) {
154
- return await this._request('GET', '/products/pricing/v0/competitivePrice', null, {
155
- ItemType: 'Asin',
156
- Asins: asins.join(',')
157
- });
158
- }
159
-
160
- async updatePrice(sku, price, currency = 'EUR') {
161
- // SP-API için feed sistemi gerekir - basitleştirilmiş ârnek
162
- const feed = {
163
- header: { sellerId: this.sellerId, version: '2.0' },
164
- messages: [{
165
- messageId: 1,
166
- sku,
167
- operationType: 'PARTIAL_UPDATE',
168
- productType: 'PRODUCT',
169
- attributes: {
170
- purchasable_offer: [{
171
- our_price: [{ schedule: [{ value_with_tax: price }] }],
172
- currency
173
- }]
174
- }
175
- }]
176
- };
177
- return await this._request('POST', '/feeds/2021-06-30/feeds', {
178
- feedType: 'JSON_LISTINGS_FEED',
179
- marketplaceIds: [this.regionConfig.marketplace]
180
- });
181
- }
182
-
183
- // ═══════════════════════════════════════════════════════════════════════════
184
- // SİPARİŞ
185
- // ═══════════════════════════════════════════════════════════════════════════
186
-
187
- async getOrders(params = {}) {
188
- const { createdAfter, orderStatuses, nextToken } = params;
189
- return await this._request('GET', '/orders/v0/orders', null, {
190
- CreatedAfter: createdAfter || new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString(),
191
- OrderStatuses: orderStatuses?.join(','),
192
- NextToken: nextToken
193
- });
194
- }
195
-
196
- async getOrderItems(orderId) {
197
- return await this._request('GET', `/orders/v0/orders/${orderId}/orderItems`);
198
- }
199
-
200
- async confirmShipment(orderId, items) {
201
- return await this._request('POST', `/orders/v0/orders/${orderId}/shipmentConfirmation`, {
202
- packageDetail: {
203
- packageReferenceId: `pkg-${Date.now()}`,
204
- carrierCode: 'OTHER',
205
- shippingMethod: 'Standard',
206
- trackingNumber: items.trackingNumber,
207
- shipFromSupplySourceId: this.sellerId
208
- },
209
- codCollectionMethod: 'DirectPayment',
210
- marketplaceId: this.regionConfig.marketplace
211
- });
212
- }
213
-
214
- // ═══════════════════════════════════════════════════════════════════════════
215
- // FBA
216
- // ═══════════════════════════════════════════════════════════════════════════
217
-
218
- async getFbaInventory(params = {}) {
219
- return await this._request('GET', '/fba/inventory/v1/summaries', null, {
220
- details: true,
221
- granularityType: 'Marketplace',
222
- granularityId: this.regionConfig.marketplace,
223
- ...params
224
- });
225
- }
226
-
227
- async getInboundShipments(params = {}) {
228
- return await this._request('GET', '/fba/inbound/v0/shipments', null, params);
229
- }
230
-
231
- // ═══════════════════════════════════════════════════════════════════════════
232
- // HELPER
233
- // ═══════════════════════════════════════════════════════════════════════════
234
-
235
- async testConnection() {
236
- try {
237
- await this._getAccessToken();
238
- return true;
239
- } catch {
240
- return false;
241
- }
242
- }
243
-
244
- isConnected() {
245
- return !!(this.sellerId && this.clientId && this.refreshToken);
246
- }
247
- }
248
-
249
- let instances = {};
250
-
251
- export const amazonApi = {
252
- init(config, region = 'eu') {
253
- instances[region] = new AmazonAPI({ ...config, region });
254
- return instances[region];
255
- },
256
- getInstance(region = 'eu') { return instances[region]; },
257
- isConnected(region = 'eu') { return instances[region]?.isConnected() || false; },
258
-
259
- async getProducts(params, region) { return instances[region]?.getInventory(params); },
260
- async updatePrice(sku, price, region) { return instances[region]?.updatePrice(sku, price); },
261
- async getOrders(params, region) { return instances[region]?.getOrders(params); }
262
- };
263
-
97
+ return { success: true, data: response.data };
98
+ } catch (error) {
99
+ return {
100
+ success: false,
101
+ error: error.response?.data?.errors || error.message
102
+ };
103
+ }
104
+ }
105
+
106
+ // ═══════════════════════════════════════════════════════════════════════════
107
+ // ÜRÜN İŞLEMLERİ
108
+ // ═══════════════════════════════════════════════════════════════════════════
109
+
110
+ async getInventory(params = {}) {
111
+ const { nextToken, skus } = params;
112
+ return await this._request('GET', '/fba/inventory/v1/summaries', null, {
113
+ details: true,
114
+ granularityType: 'Marketplace',
115
+ granularityId: this.regionConfig.marketplace,
116
+ sellerSkus: skus?.join(','),
117
+ nextToken
118
+ });
119
+ }
120
+
121
+ async getCatalogItem(asin) {
122
+ return await this._request('GET', `/catalog/2022-04-01/items/${asin}`, null, {
123
+ includedData: 'summaries,attributes,images,productTypes,salesRanks'
124
+ });
125
+ }
126
+
127
+ async searchCatalog(keywords) {
128
+ return await this._request('GET', '/catalog/2022-04-01/items', null, {
129
+ keywords,
130
+ includedData: 'summaries,images'
131
+ });
132
+ }
133
+
134
+ async createListing(sku, productType, attributes) {
135
+ return await this._request('PUT', `/listings/2021-08-01/items/${this.sellerId}/${sku}`, {
136
+ productType,
137
+ attributes,
138
+ requirements: 'LISTING'
139
+ });
140
+ }
141
+
142
+ // ═══════════════════════════════════════════════════════════════════════════
143
+ // FΔ°YAT
144
+ // ═══════════════════════════════════════════════════════════════════════════
145
+
146
+ async getPricing(skus) {
147
+ return await this._request('GET', '/products/pricing/v0/price', null, {
148
+ ItemType: 'Sku',
149
+ Skus: skus.join(',')
150
+ });
151
+ }
152
+
153
+ async getCompetitivePricing(asins) {
154
+ return await this._request('GET', '/products/pricing/v0/competitivePrice', null, {
155
+ ItemType: 'Asin',
156
+ Asins: asins.join(',')
157
+ });
158
+ }
159
+
160
+ async updatePrice(sku, price, currency = 'EUR') {
161
+ // SP-API için feed sistemi gerekir - basitleştirilmiş ârnek
162
+ const feed = {
163
+ header: { sellerId: this.sellerId, version: '2.0' },
164
+ messages: [{
165
+ messageId: 1,
166
+ sku,
167
+ operationType: 'PARTIAL_UPDATE',
168
+ productType: 'PRODUCT',
169
+ attributes: {
170
+ purchasable_offer: [{
171
+ our_price: [{ schedule: [{ value_with_tax: price }] }],
172
+ currency
173
+ }]
174
+ }
175
+ }]
176
+ };
177
+ return await this._request('POST', '/feeds/2021-06-30/feeds', {
178
+ feedType: 'JSON_LISTINGS_FEED',
179
+ marketplaceIds: [this.regionConfig.marketplace]
180
+ });
181
+ }
182
+
183
+ // ═══════════════════════════════════════════════════════════════════════════
184
+ // SİPARİŞ
185
+ // ═══════════════════════════════════════════════════════════════════════════
186
+
187
+ async getOrders(params = {}) {
188
+ const { createdAfter, orderStatuses, nextToken } = params;
189
+ return await this._request('GET', '/orders/v0/orders', null, {
190
+ CreatedAfter: createdAfter || new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString(),
191
+ OrderStatuses: orderStatuses?.join(','),
192
+ NextToken: nextToken
193
+ });
194
+ }
195
+
196
+ async getOrderItems(orderId) {
197
+ return await this._request('GET', `/orders/v0/orders/${orderId}/orderItems`);
198
+ }
199
+
200
+ async confirmShipment(orderId, items) {
201
+ return await this._request('POST', `/orders/v0/orders/${orderId}/shipmentConfirmation`, {
202
+ packageDetail: {
203
+ packageReferenceId: `pkg-${Date.now()}`,
204
+ carrierCode: 'OTHER',
205
+ shippingMethod: 'Standard',
206
+ trackingNumber: items.trackingNumber,
207
+ shipFromSupplySourceId: this.sellerId
208
+ },
209
+ codCollectionMethod: 'DirectPayment',
210
+ marketplaceId: this.regionConfig.marketplace
211
+ });
212
+ }
213
+
214
+ // ═══════════════════════════════════════════════════════════════════════════
215
+ // FBA
216
+ // ═══════════════════════════════════════════════════════════════════════════
217
+
218
+ async getFbaInventory(params = {}) {
219
+ return await this._request('GET', '/fba/inventory/v1/summaries', null, {
220
+ details: true,
221
+ granularityType: 'Marketplace',
222
+ granularityId: this.regionConfig.marketplace,
223
+ ...params
224
+ });
225
+ }
226
+
227
+ async getInboundShipments(params = {}) {
228
+ return await this._request('GET', '/fba/inbound/v0/shipments', null, params);
229
+ }
230
+
231
+ // ═══════════════════════════════════════════════════════════════════════════
232
+ // HELPER
233
+ // ═══════════════════════════════════════════════════════════════════════════
234
+
235
+ async testConnection() {
236
+ try {
237
+ await this._getAccessToken();
238
+ return true;
239
+ } catch {
240
+ return false;
241
+ }
242
+ }
243
+
244
+ isConnected() {
245
+ return !!(this.sellerId && this.clientId && this.refreshToken);
246
+ }
247
+ }
248
+
249
+ let instances = {};
250
+
251
+ export const amazonApi = {
252
+ init(config, region = 'eu') {
253
+ instances[region] = new AmazonAPI({ ...config, region });
254
+ return instances[region];
255
+ },
256
+ getInstance(region = 'eu') { return instances[region]; },
257
+ isConnected(region = 'eu') { return instances[region]?.isConnected() || false; },
258
+
259
+ async getProducts(params, region) { return instances[region]?.getInventory(params); },
260
+ async updatePrice(sku, price, region) { return instances[region]?.updatePrice(sku, price); },
261
+ async getOrders(params, region) { return instances[region]?.getOrders(params); }
262
+ };
263
+