@bprotsyk/aso-core 2.1.85 → 2.1.87

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/lib/app/app.d.ts CHANGED
@@ -73,6 +73,7 @@ export interface IPlatformParams {
73
73
  appsflyerParams?: {
74
74
  apiToken: string;
75
75
  eventIds?: Record<string, string>;
76
+ appId?: string;
76
77
  };
77
78
  proxied?: boolean;
78
79
  keitaroData?: IAppKeitaroData | boolean;
@@ -315,8 +315,41 @@ async function cloneDirectCampaign(app, platform, addDefaultStreams) {
315
315
  return hasId && hasArrow && noPlatformAtEnd;
316
316
  });
317
317
  }
318
- if (matchingCampaign.length > 0)
319
- return matchingCampaign[0];
318
+ if (matchingCampaign.length > 0) {
319
+ const existingCampaign = matchingCampaign[0];
320
+ // Якщо addDefaultStreams === true, додаємо потоки до існуючої кампанії
321
+ if (addDefaultStreams) {
322
+ const originalStreams = await getStreamsByCampaignId(3175);
323
+ const existingStreams = await getStreamsByCampaignId(existingCampaign.id);
324
+ for (const stream of originalStreams) {
325
+ // Перевіряємо чи потік вже існує
326
+ const existingStream = existingStreams.find(s => s.name === stream.name);
327
+ if (!existingStream) {
328
+ await http_1.default.post('streams', {
329
+ name: stream.name,
330
+ campaign_id: existingCampaign.id,
331
+ schema: stream.schema,
332
+ type: stream.type,
333
+ action_type: stream.action_type,
334
+ weight: stream.weight,
335
+ offers: stream.offers.map((offer) => ({
336
+ offer_id: offer.offer_id,
337
+ share: offer.share,
338
+ state: offer.state
339
+ })),
340
+ filters: stream.filters.map((filter) => ({
341
+ name: filter.name,
342
+ mode: filter.mode,
343
+ payload: filter.payload
344
+ })),
345
+ position: stream.position,
346
+ state: stream.state
347
+ });
348
+ }
349
+ }
350
+ }
351
+ return existingCampaign;
352
+ }
320
353
  const originalCampaign = await getCampaignById(3175);
321
354
  const maxPosition = Math.max(...allCampaigns.map(c => c.position || 0));
322
355
  const originalStreams = await getStreamsByCampaignId(3175);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bprotsyk/aso-core",
3
- "version": "2.1.85",
3
+ "version": "2.1.87",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "scripts": {
package/src/app/app.ts CHANGED
@@ -111,6 +111,7 @@ export interface IPlatformParams {
111
111
  appsflyerParams? :{
112
112
  apiToken: string,
113
113
  eventIds?: Record<string, string>,
114
+ appId?: string
114
115
  },
115
116
  proxied?: boolean,
116
117
 
@@ -385,7 +385,44 @@ async function cloneDirectCampaign(app: IApp, platform?: EPlatform, addDefaultSt
385
385
  });
386
386
  }
387
387
 
388
- if (matchingCampaign.length > 0) return matchingCampaign[0];
388
+ if (matchingCampaign.length > 0) {
389
+ const existingCampaign = matchingCampaign[0];
390
+
391
+ // Якщо addDefaultStreams === true, додаємо потоки до існуючої кампанії
392
+ if (addDefaultStreams) {
393
+ const originalStreams = await getStreamsByCampaignId(3175);
394
+ const existingStreams = await getStreamsByCampaignId(existingCampaign.id);
395
+
396
+ for (const stream of originalStreams) {
397
+ // Перевіряємо чи потік вже існує
398
+ const existingStream = existingStreams.find(s => s.name === stream.name);
399
+ if (!existingStream) {
400
+ await keitaroApi.post('streams', {
401
+ name: stream.name,
402
+ campaign_id: existingCampaign.id,
403
+ schema: stream.schema,
404
+ type: stream.type,
405
+ action_type: stream.action_type,
406
+ weight: stream.weight,
407
+ offers: stream.offers.map((offer) => ({
408
+ offer_id: offer.offer_id,
409
+ share: offer.share,
410
+ state: offer.state
411
+ })),
412
+ filters: stream.filters.map((filter) => ({
413
+ name: filter.name,
414
+ mode: filter.mode,
415
+ payload: filter.payload
416
+ })),
417
+ position: stream.position,
418
+ state: stream.state
419
+ });
420
+ }
421
+ }
422
+ }
423
+
424
+ return existingCampaign;
425
+ }
389
426
 
390
427
  const originalCampaign: IKeitaroCampaign = await getCampaignById(3175);
391
428
  const maxPosition = Math.max(...allCampaigns.map(c => c.position || 0));