@bprotsyk/aso-core 2.1.83 → 2.1.85
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
|
@@ -23,7 +23,7 @@ declare function createCampaign(campaignData: Partial<IKeitaroCampaign>): Promis
|
|
|
23
23
|
declare function getCampaignById(id: number): Promise<IKeitaroCampaign>;
|
|
24
24
|
export declare function upsertStreamToCampaign(campaign: IKeitaroCampaign, stream: Partial<IKeitaroStream>): Promise<void>;
|
|
25
25
|
declare function cloneOWCampaign(app: IApp, platform?: EPlatform): Promise<IKeitaroCampaign | any>;
|
|
26
|
-
declare function cloneDirectCampaign(app: IApp, platform?: EPlatform): Promise<IKeitaroCampaign | any>;
|
|
26
|
+
declare function cloneDirectCampaign(app: IApp, platform?: EPlatform, addDefaultStreams?: boolean): Promise<IKeitaroCampaign | any>;
|
|
27
27
|
declare function cloneDCampaign(app: IApp): Promise<IKeitaroCampaign>;
|
|
28
28
|
declare function changeCampaignsGroup(fromId: number, toId: number, exceptForCampaignIds: number[], onlyForCampaignIds?: number[]): Promise<void>;
|
|
29
29
|
declare function getDomains(onlyActive?: boolean): Promise<IKeitaroDomain[]>;
|
|
@@ -276,7 +276,7 @@ async function cloneOWCampaign(app, platform) {
|
|
|
276
276
|
const updatedCampaign = await getCampaignById(newCampaign.id);
|
|
277
277
|
return updatedCampaign;
|
|
278
278
|
}
|
|
279
|
-
async function cloneDirectCampaign(app, platform) {
|
|
279
|
+
async function cloneDirectCampaign(app, platform, addDefaultStreams) {
|
|
280
280
|
let name = `#${app.id} [➥]`;
|
|
281
281
|
let platformName = platform ? (0, app_1.getPlatformName)(platform) : null;
|
|
282
282
|
const platformCampaignName = `#${app.id} [➥] (${platformName})`;
|
|
@@ -293,10 +293,11 @@ async function cloneDirectCampaign(app, platform) {
|
|
|
293
293
|
// Точна перевірка ID з межами слів
|
|
294
294
|
const idPattern = new RegExp(`#${app.id}\\b`);
|
|
295
295
|
const hasId = idPattern.test(c.name);
|
|
296
|
-
// Перевіряємо наявність стрілки
|
|
296
|
+
// Перевіряємо наявність стрілки (може бути в комбінації з іншими символами)
|
|
297
297
|
const hasArrow = c.name.includes('➥');
|
|
298
|
-
// Перевіряємо наявність платформи в дужках
|
|
299
|
-
const
|
|
298
|
+
// Перевіряємо наявність платформи в дужках в кінці назви
|
|
299
|
+
const platformPattern = new RegExp(`\\(.*${platformName}.*\\)\\s*$`);
|
|
300
|
+
const hasPlatform = platformPattern.test(c.name);
|
|
300
301
|
return hasId && hasArrow && hasPlatform;
|
|
301
302
|
});
|
|
302
303
|
}
|
|
@@ -306,11 +307,12 @@ async function cloneDirectCampaign(app, platform) {
|
|
|
306
307
|
// Точна перевірка ID з межами слів
|
|
307
308
|
const idPattern = new RegExp(`#${app.id}\\b`);
|
|
308
309
|
const hasId = idPattern.test(c.name);
|
|
309
|
-
// Перевіряємо наявність стрілки
|
|
310
|
+
// Перевіряємо наявність стрілки (може бути в комбінації з іншими символами)
|
|
310
311
|
const hasArrow = c.name.includes('➥');
|
|
311
|
-
// Перевіряємо відсутність
|
|
312
|
-
|
|
313
|
-
|
|
312
|
+
// Перевіряємо відсутність платформи в дужках в кінці
|
|
313
|
+
// Дозволяємо будь-які інші дужки (як для гео або опису)
|
|
314
|
+
const noPlatformAtEnd = !/\(.*(?:iOS|Android|Desktop|Mobile).*\)\s*$/.test(c.name);
|
|
315
|
+
return hasId && hasArrow && noPlatformAtEnd;
|
|
314
316
|
});
|
|
315
317
|
}
|
|
316
318
|
if (matchingCampaign.length > 0)
|
|
@@ -348,7 +350,9 @@ async function cloneDirectCampaign(app, platform) {
|
|
|
348
350
|
uniqueness_type: originalCampaign.uniqueness_type,
|
|
349
351
|
};
|
|
350
352
|
const newCampaign = await createCampaign(payload);
|
|
351
|
-
|
|
353
|
+
// Додаємо потоки: всі якщо addDefaultStreams === true, інакше тільки перший
|
|
354
|
+
const streamsToAdd = addDefaultStreams ? originalStreams : originalStreams.slice(0, 1);
|
|
355
|
+
for (const stream of streamsToAdd) {
|
|
352
356
|
await http_1.default.post('streams', {
|
|
353
357
|
name: stream.name,
|
|
354
358
|
campaign_id: newCampaign.id,
|
package/package.json
CHANGED
package/src/app/app.ts
CHANGED
|
@@ -341,7 +341,7 @@ async function cloneOWCampaign(app: IApp, platform?: EPlatform): Promise<IKeitar
|
|
|
341
341
|
return updatedCampaign;
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
-
async function cloneDirectCampaign(app: IApp, platform?: EPlatform): Promise<IKeitaroCampaign | any> {
|
|
344
|
+
async function cloneDirectCampaign(app: IApp, platform?: EPlatform, addDefaultStreams?: boolean): Promise<IKeitaroCampaign | any> {
|
|
345
345
|
let name = `#${app.id} [➥]`
|
|
346
346
|
let platformName = platform ? getPlatformName(platform) : null;
|
|
347
347
|
const platformCampaignName = `#${app.id} [➥] (${platformName})`;
|
|
@@ -363,10 +363,11 @@ async function cloneDirectCampaign(app: IApp, platform?: EPlatform): Promise<IKe
|
|
|
363
363
|
// Точна перевірка ID з межами слів
|
|
364
364
|
const idPattern = new RegExp(`#${app.id}\\b`);
|
|
365
365
|
const hasId = idPattern.test(c.name);
|
|
366
|
-
// Перевіряємо наявність стрілки
|
|
366
|
+
// Перевіряємо наявність стрілки (може бути в комбінації з іншими символами)
|
|
367
367
|
const hasArrow = c.name.includes('➥');
|
|
368
|
-
// Перевіряємо наявність платформи в дужках
|
|
369
|
-
const
|
|
368
|
+
// Перевіряємо наявність платформи в дужках в кінці назви
|
|
369
|
+
const platformPattern = new RegExp(`\\(.*${platformName}.*\\)\\s*$`);
|
|
370
|
+
const hasPlatform = platformPattern.test(c.name);
|
|
370
371
|
return hasId && hasArrow && hasPlatform;
|
|
371
372
|
});
|
|
372
373
|
} else {
|
|
@@ -375,11 +376,12 @@ async function cloneDirectCampaign(app: IApp, platform?: EPlatform): Promise<IKe
|
|
|
375
376
|
// Точна перевірка ID з межами слів
|
|
376
377
|
const idPattern = new RegExp(`#${app.id}\\b`);
|
|
377
378
|
const hasId = idPattern.test(c.name);
|
|
378
|
-
// Перевіряємо наявність стрілки
|
|
379
|
+
// Перевіряємо наявність стрілки (може бути в комбінації з іншими символами)
|
|
379
380
|
const hasArrow = c.name.includes('➥');
|
|
380
|
-
// Перевіряємо відсутність
|
|
381
|
-
|
|
382
|
-
|
|
381
|
+
// Перевіряємо відсутність платформи в дужках в кінці
|
|
382
|
+
// Дозволяємо будь-які інші дужки (як для гео або опису)
|
|
383
|
+
const noPlatformAtEnd = !/\(.*(?:iOS|Android|Desktop|Mobile).*\)\s*$/.test(c.name);
|
|
384
|
+
return hasId && hasArrow && noPlatformAtEnd;
|
|
383
385
|
});
|
|
384
386
|
}
|
|
385
387
|
|
|
@@ -424,7 +426,10 @@ async function cloneDirectCampaign(app: IApp, platform?: EPlatform): Promise<IKe
|
|
|
424
426
|
|
|
425
427
|
const newCampaign: IKeitaroCampaign = await createCampaign(payload);
|
|
426
428
|
|
|
427
|
-
|
|
429
|
+
// Додаємо потоки: всі якщо addDefaultStreams === true, інакше тільки перший
|
|
430
|
+
const streamsToAdd = addDefaultStreams ? originalStreams : originalStreams.slice(0, 1);
|
|
431
|
+
|
|
432
|
+
for (const stream of streamsToAdd) {
|
|
428
433
|
await keitaroApi.post('streams', {
|
|
429
434
|
name: stream.name,
|
|
430
435
|
campaign_id: newCampaign.id,
|