@bprotsyk/aso-core 2.1.129 → 2.1.130

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.
@@ -16,6 +16,14 @@ export interface IGeoSyncSummary {
16
16
  totalApps: number;
17
17
  appsNeedingUpdate: number;
18
18
  updates: IGeoUpdateData[];
19
+ appsNeedingEnable: number;
20
+ appsNeedingDisable: number;
21
+ enablementChecks: {
22
+ appId: number;
23
+ platform: string;
24
+ mustBeEnabled: boolean;
25
+ mustBeDisabled: boolean;
26
+ }[];
19
27
  errors: string[];
20
28
  }
21
29
  /**
@@ -119,6 +119,9 @@ async function syncKeitaroCLOGeosWithApps(apps) {
119
119
  totalApps: apps.length,
120
120
  appsNeedingUpdate: 0,
121
121
  updates: [],
122
+ appsNeedingEnable: 0,
123
+ appsNeedingDisable: 0,
124
+ enablementChecks: [],
122
125
  errors: []
123
126
  };
124
127
  try {
@@ -197,6 +200,32 @@ async function syncKeitaroCLOGeosWithApps(apps) {
197
200
  const platformData = app.platforms[platform];
198
201
  const appGeos = platformData?.geo || [];
199
202
  console.log(` App гео для платформи ${platform}: ${appGeos.join(', ')}`);
203
+ // Перевіряємо статус CLO потоку в Keitaro
204
+ const streams = await getStreamsByCampaignId(campaign.id);
205
+ const cloStream = streams.find(stream => stream.name === "CLO");
206
+ const keitaroCLOEnabled = cloStream?.state === 'active' || false;
207
+ console.log(` CLO потік в Keitaro: ${keitaroCLOEnabled ? 'включений' : 'вимкнений'}`);
208
+ // Перевіряємо чи включена платформа в додатку
209
+ const appPlatformEnabled = platformData?.enabled || false;
210
+ console.log(` Платформа ${platform} в додатку: ${appPlatformEnabled ? 'включена' : 'вимкнена'}`);
211
+ // Визначаємо чи потрібно включити/вимкнути додаток
212
+ const mustBeEnabled = keitaroCLOEnabled && !appPlatformEnabled;
213
+ const mustBeDisabled = !keitaroCLOEnabled && appPlatformEnabled;
214
+ if (mustBeEnabled) {
215
+ summary.appsNeedingEnable++;
216
+ console.log(` ✅ Потребує включення`);
217
+ }
218
+ else if (mustBeDisabled) {
219
+ summary.appsNeedingDisable++;
220
+ console.log(` ❌ Потребує вимкнення`);
221
+ }
222
+ // Додаємо до перевірок включення
223
+ summary.enablementChecks.push({
224
+ appId: parseInt(group),
225
+ platform: platform,
226
+ mustBeEnabled: mustBeEnabled,
227
+ mustBeDisabled: mustBeDisabled
228
+ });
200
229
  // Порівнюємо гео
201
230
  const missingGeos = keitaroGeos.filter(geo => !appGeos.includes(geo));
202
231
  const needsUpdate = missingGeos.length > 0 || appGeos.length !== keitaroGeos.length ||
@@ -229,7 +258,7 @@ async function syncKeitaroCLOGeosWithApps(apps) {
229
258
  summary.errors.push(errorMsg);
230
259
  }
231
260
  }
232
- console.log(`\nСинхронізація завершена. ${summary.appsNeedingUpdate} додатків потребують оновлення гео.`);
261
+ console.log(`\nСинхронізація завершена. ${summary.appsNeedingUpdate} додатків потребують оновлення гео, ${summary.appsNeedingEnable} потребують включення, ${summary.appsNeedingDisable} потребують вимкнення.`);
233
262
  }
234
263
  catch (error) {
235
264
  const errorMsg = `Критична помилка синхронізації: ${error}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bprotsyk/aso-core",
3
- "version": "2.1.129",
3
+ "version": "2.1.130",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "scripts": {
@@ -25,6 +25,14 @@ export interface IGeoSyncSummary {
25
25
  totalApps: number;
26
26
  appsNeedingUpdate: number;
27
27
  updates: IGeoUpdateData[];
28
+ appsNeedingEnable: number;
29
+ appsNeedingDisable: number;
30
+ enablementChecks: {
31
+ appId: number;
32
+ platform: string;
33
+ mustBeEnabled: boolean;
34
+ mustBeDisabled: boolean;
35
+ }[];
28
36
  errors: string[];
29
37
  }
30
38
 
@@ -147,6 +155,9 @@ export async function syncKeitaroCLOGeosWithApps(apps: IApp[]): Promise<IGeoSync
147
155
  totalApps: apps.length,
148
156
  appsNeedingUpdate: 0,
149
157
  updates: [],
158
+ appsNeedingEnable: 0,
159
+ appsNeedingDisable: 0,
160
+ enablementChecks: [],
150
161
  errors: []
151
162
  };
152
163
 
@@ -251,6 +262,36 @@ export async function syncKeitaroCLOGeosWithApps(apps: IApp[]): Promise<IGeoSync
251
262
  const appGeos = platformData?.geo || [];
252
263
  console.log(` App гео для платформи ${platform}: ${appGeos.join(', ')}`);
253
264
 
265
+ // Перевіряємо статус CLO потоку в Keitaro
266
+ const streams = await getStreamsByCampaignId(campaign.id);
267
+ const cloStream = streams.find(stream => stream.name === "CLO");
268
+ const keitaroCLOEnabled = cloStream?.state === 'active' || false;
269
+ console.log(` CLO потік в Keitaro: ${keitaroCLOEnabled ? 'включений' : 'вимкнений'}`);
270
+
271
+ // Перевіряємо чи включена платформа в додатку
272
+ const appPlatformEnabled = platformData?.enabled || false;
273
+ console.log(` Платформа ${platform} в додатку: ${appPlatformEnabled ? 'включена' : 'вимкнена'}`);
274
+
275
+ // Визначаємо чи потрібно включити/вимкнути додаток
276
+ const mustBeEnabled = keitaroCLOEnabled && !appPlatformEnabled;
277
+ const mustBeDisabled = !keitaroCLOEnabled && appPlatformEnabled;
278
+
279
+ if (mustBeEnabled) {
280
+ summary.appsNeedingEnable++;
281
+ console.log(` ✅ Потребує включення`);
282
+ } else if (mustBeDisabled) {
283
+ summary.appsNeedingDisable++;
284
+ console.log(` ❌ Потребує вимкнення`);
285
+ }
286
+
287
+ // Додаємо до перевірок включення
288
+ summary.enablementChecks.push({
289
+ appId: parseInt(group),
290
+ platform: platform,
291
+ mustBeEnabled: mustBeEnabled,
292
+ mustBeDisabled: mustBeDisabled
293
+ });
294
+
254
295
  // Порівнюємо гео
255
296
  const missingGeos = keitaroGeos.filter(geo => !appGeos.includes(geo));
256
297
  const needsUpdate = missingGeos.length > 0 || appGeos.length !== keitaroGeos.length ||
@@ -288,7 +329,7 @@ export async function syncKeitaroCLOGeosWithApps(apps: IApp[]): Promise<IGeoSync
288
329
  }
289
330
  }
290
331
 
291
- console.log(`\nСинхронізація завершена. ${summary.appsNeedingUpdate} додатків потребують оновлення гео.`);
332
+ console.log(`\nСинхронізація завершена. ${summary.appsNeedingUpdate} додатків потребують оновлення гео, ${summary.appsNeedingEnable} потребують включення, ${summary.appsNeedingDisable} потребують вимкнення.`);
292
333
 
293
334
  } catch (error) {
294
335
  const errorMsg = `Критична помилка синхронізації: ${error}`;