@bprotsyk/aso-core 1.2.69 → 1.2.71

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/index.d.ts CHANGED
@@ -16,7 +16,7 @@ export { IOfferWallSection } from "./aso/offerwall/offerwall-section";
16
16
  export { IOfferWallOffer } from "./aso/offerwall/offerwall-offer";
17
17
  export { IOfferWallResponse } from "./aso/offerwall/offerwall-response";
18
18
  export { IOfferWallHomeDialogData } from "./aso/offerwall/offerwall-home-dialog-data";
19
- export { IFlashApp, FlashAppSchema, updateSchemaAndMoveValue, PlugType } from "./flash/flash-app";
19
+ export { IFlashApp, FlashAppSchema, updateSchemaAndMoveValue, PlugType, FlashAppPlugStatus } from "./flash/flash-app";
20
20
  export { IFlashAppListItem } from "./flash/flash-app-list-item";
21
21
  export { FlashAppType } from "./flash/flash-app-type";
22
22
  export * as ASOConfigFetch from "./aso/usage-logs/aso-config-fetch-entry";
package/lib/index.js CHANGED
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.KeitaroService = exports.ColoredText = exports.ShapeDiv = exports.PanelUserSchema = exports.PanelUserAccessScope = exports.ASOConfigFetch = exports.FlashAppType = exports.PlugType = exports.updateSchemaAndMoveValue = exports.FlashAppSchema = exports.ASO_v5 = exports.ASO_v4 = exports.ASO_v3 = exports.ASO_v2 = exports.ASO_v1 = exports.ASO_v0 = void 0;
26
+ exports.KeitaroService = exports.ColoredText = exports.ShapeDiv = exports.PanelUserSchema = exports.PanelUserAccessScope = exports.ASOConfigFetch = exports.FlashAppType = exports.FlashAppPlugStatus = exports.PlugType = exports.updateSchemaAndMoveValue = exports.FlashAppSchema = exports.ASO_v5 = exports.ASO_v4 = exports.ASO_v3 = exports.ASO_v2 = exports.ASO_v1 = exports.ASO_v0 = void 0;
27
27
  exports.ASO_v0 = __importStar(require("./aso/config/aso-config-v0"));
28
28
  exports.ASO_v1 = __importStar(require("./aso/config/aso-config-v1"));
29
29
  exports.ASO_v2 = __importStar(require("./aso/config/aso-config-v2"));
@@ -34,6 +34,7 @@ var flash_app_1 = require("./flash/flash-app");
34
34
  Object.defineProperty(exports, "FlashAppSchema", { enumerable: true, get: function () { return flash_app_1.FlashAppSchema; } });
35
35
  Object.defineProperty(exports, "updateSchemaAndMoveValue", { enumerable: true, get: function () { return flash_app_1.updateSchemaAndMoveValue; } });
36
36
  Object.defineProperty(exports, "PlugType", { enumerable: true, get: function () { return flash_app_1.PlugType; } });
37
+ Object.defineProperty(exports, "FlashAppPlugStatus", { enumerable: true, get: function () { return flash_app_1.FlashAppPlugStatus; } });
37
38
  var flash_app_type_1 = require("./flash/flash-app-type");
38
39
  Object.defineProperty(exports, "FlashAppType", { enumerable: true, get: function () { return flash_app_type_1.FlashAppType; } });
39
40
  exports.ASOConfigFetch = __importStar(require("./aso/usage-logs/aso-config-fetch-entry"));
@@ -1,12 +1,8 @@
1
- import { PlugType } from "index";
2
1
  export interface IUpsertFlashAppRequest {
3
2
  id: number;
4
3
  name: string;
5
4
  bundle: string;
6
- plugUrl: string;
7
- plugType: PlugType;
8
- reservePlugUrl?: string;
9
- reservePlugType?: PlugType;
5
+ plugContent?: string;
10
6
  onesignalAppId: string;
11
7
  onesignalRestApiKey: string;
12
8
  developerName: string;
@@ -33,6 +33,7 @@ const keitaro_service_1 = require("../network/keitaro/keitaro-service");
33
33
  const sleep_promise_1 = __importDefault(require("sleep-promise"));
34
34
  const fs = require("fs");
35
35
  const util = __importStar(require("util"));
36
+ const axios_1 = __importDefault(require("axios"));
36
37
  const readFile = util.promisify(fs.readFile);
37
38
  const FLASH_REDIRECT_GROUP_ID = 82;
38
39
  exports.TRAFFIC_SOURCE_ID_FLASH_AI = 22;
@@ -379,12 +380,13 @@ let changeSourceForFA = async () => {
379
380
  }
380
381
  };
381
382
  let gatherInfoForFlashApps = async () => {
382
- const pasteMap = JSON.parse(await readFile('./map-paste.json', 'utf8'));
383
- const trackingMap = JSON.parse(await readFile('./map-tracking.json', 'utf8'));
384
- const flashApps = JSON.parse(await readFile('./map-apps.json', 'utf8'));
383
+ console.log(__dirname);
384
+ const pasteMap = JSON.parse(await readFile('/Users/bprtsk/Documents/Work/ASO/AI Control Panel /AI Panel Core/src/utils/map-paste.json', 'utf8'));
385
+ const trackingMap = JSON.parse(await readFile('/Users/bprtsk/Documents/Work/ASO/AI Control Panel /AI Panel Core/src/utils/map-tracking.json', 'utf8'));
386
+ const flashApps = JSON.parse(await readFile('/Users/bprtsk/Documents/Work/ASO/AI Control Panel /AI Panel Core/src/utils/map-apps.json', 'utf8'));
385
387
  let allCampaigns = await keitaro_service_1.KeitaroService.getAllCampaigns();
386
- let owCampaigns = allCampaigns.filter(c => new RegExp(`^FA #`).exec(c.name)).reduce((acc, obj) => ({ ...acc, [new RegExp(/#\((.*)\)/g).exec(obj.name)[1]]: obj }), {});
387
- let redirectCampaigns = allCampaigns.filter(c => new RegExp(`^F #`).exec(c.name)).reduce((acc, obj) => ({ ...acc, [new RegExp(/#\((.*)\)/g).exec(obj.name)[1]]: obj }), {});
388
+ let owCampaigns = allCampaigns.filter(c => new RegExp(`^FA #`).exec(c.name)).reduce((acc, obj) => ({ ...acc, [new RegExp(/#(.*) \(/g).exec(obj.name)?.[1] || obj.name]: obj }), {});
389
+ let redirectCampaigns = allCampaigns.filter(c => new RegExp(`^F #`).exec(c.name)).reduce((acc, obj) => ({ ...acc, [new RegExp(/#(.*) \(/g).exec(obj.name)?.[1] || obj.name]: obj }), {});
388
390
  let result = [];
389
391
  for (let [id, paste] of Object.entries(pasteMap)) {
390
392
  console.log(`- #${id}`);
@@ -392,68 +394,79 @@ let gatherInfoForFlashApps = async () => {
392
394
  let redirect = redirectCampaigns[id];
393
395
  let tracking = trackingMap[id];
394
396
  let app = flashApps[id];
397
+ if (!app) {
398
+ console.log(`! No app for ${id}`);
399
+ continue;
400
+ }
395
401
  if (paste.status == flash_app_1.FlashAppPlugStatus.ENABLED) {
396
402
  if (!ow)
397
403
  console.log(`#${id}: no OW`);
398
- else if (!paste.content.includes(ow.domain))
399
- console.log(`#${id}: OW domain (${ow.domain}) differs from paste domain (${paste.content})`);
400
- else if (!paste.content.includes(ow.id.toString()))
401
- console.log(`#${id}: OW campaign id (${ow.id}) differs from paste id (${paste.content})`);
402
404
  if (!redirect)
403
405
  console.log(`No redirect for #${id}`);
404
406
  else if (!paste.content.includes(redirect.domain))
405
407
  console.log(`#${id}: Redirect domain (${redirect.domain}) differs from paste domain (${paste.content})`);
406
- else if (!paste.content.includes(redirect.id.toString()))
407
- console.log(`#${id}: Redirect campaign id (${redirect.id}) differs from paste id (${paste.content})`);
408
+ else if (!paste.content.includes(redirect.alias))
409
+ console.log(`#${id}: Redirect campaign alias (${redirect.alias}) differs from paste id (${paste.content})`);
410
+ }
411
+ let appId;
412
+ for (let parameter of Object.values(redirect?.parameters || {})) {
413
+ if (parameter.name == "appId") {
414
+ appId = parameter.placeholder;
415
+ }
408
416
  }
409
- let appId = ow?.parameters.sub_id_1.placeholder;
410
- if (!appId)
417
+ if (!appId && ow)
411
418
  console.log(`No app id for #${id}`);
412
- else if (appId != id)
419
+ else if (appId != id && ow)
413
420
  console.log(`Wrong app id (${appId}) for #${id}`);
414
- let owDomain = ow?.domain;
421
+ let owDomain = ow?.domain?.split("/")[2];
415
422
  let owDomainId = ow?.domain_id;
416
423
  let owCampaignId = ow?.id;
417
424
  let owCampaignName = ow?.name;
418
- let redirectDomain = redirect?.domain;
425
+ let redirectDomain = redirect?.domain?.split("/")[2];
419
426
  let redirectDomainId = redirect?.domain_id;
420
427
  let redirectCampaignId = redirect?.id;
421
428
  let redirectCampaignName = redirect?.name;
422
- let clickIdParameterName = redirect?.parameters?.sub_id_8.name;
423
- let offerIdParameterName = redirect?.parameters?.sub_id_15.name;
424
- if (!clickIdParameterName)
429
+ let clickIdParameterName = ow?.parameters?.sub_id_8?.name;
430
+ let offerIdParameterName = ow?.parameters?.sub_id_15?.name;
431
+ if (!clickIdParameterName && app && ow)
425
432
  console.log(`No click id parameter for #${id}`);
426
- if (!offerIdParameterName)
433
+ if (!offerIdParameterName && app && ow)
427
434
  console.log(`No offer id parameter for #${id}`);
428
435
  let trackingLink = tracking?.trackingUrl;
429
- if (app) {
430
- app.plugStatus = paste.status;
431
- app.plugContent = paste.content;
432
- app.plugType = flash_app_1.PlugType.PASTEBIN;
433
- app.plugId = paste.paste_id;
434
- app.plugAccountId = parseInt(paste.accountId);
435
- app.keitaroData.redirectDomainName = redirectDomain || "none";
436
- app.keitaroData.redirectDomainId = redirectDomainId || 0;
437
- app.keitaroData.redirectCampaignId = redirectCampaignId || 0;
438
- app.keitaroData.redirectCampaignName = redirectCampaignName || "none";
439
- app.keitaroData.trackingDomainId = owDomainId || 0;
440
- app.keitaroData.trackingDomainName = owDomain || "none";
441
- app.keitaroData.trackingCampaignId = owCampaignId || 0;
442
- app.keitaroData.trackingCampaignName = owCampaignName || "none";
443
- if (clickIdParameterName)
444
- app.keitaroData.clickIdParameterName = clickIdParameterName;
445
- if (offerIdParameterName)
446
- app.keitaroData.offerIdParameterName = offerIdParameterName;
447
- if (trackingLink)
448
- app.trackingUrl = trackingLink;
449
- result.push(app);
436
+ app.plugStatus = paste.status;
437
+ app.plugContent = paste.content;
438
+ app.plugType = flash_app_1.PlugType.PASTEBIN;
439
+ app.plugId = paste.paste_id;
440
+ app.plugAccountId = parseInt(paste.accountId);
441
+ app.keitaroData.redirectDomainName = redirectDomain || "none";
442
+ app.keitaroData.redirectDomainId = redirectDomainId || 0;
443
+ app.keitaroData.redirectCampaignId = redirectCampaignId || 0;
444
+ app.keitaroData.redirectCampaignName = redirectCampaignName || "none";
445
+ app.keitaroData.trackingDomainId = owDomainId || 0;
446
+ app.keitaroData.trackingDomainName = owDomain || "none";
447
+ app.keitaroData.trackingCampaignId = owCampaignId || 0;
448
+ app.keitaroData.trackingCampaignName = owCampaignName || "none";
449
+ if (clickIdParameterName)
450
+ app.keitaroData.clickIdParameterName = clickIdParameterName;
451
+ if (offerIdParameterName)
452
+ app.keitaroData.offerIdParameterName = offerIdParameterName;
453
+ if (trackingLink)
454
+ app.trackingUrl = trackingLink;
455
+ if (!owCampaignName?.includes(app.bundle) && ow) {
456
+ console.log(`OW: bundle differs (${app.bundle} in DB and ${owCampaignName})`);
450
457
  }
451
- else {
452
- console.log(`! No app for ${id}`);
458
+ if (!redirectCampaignName?.includes(app.bundle) && redirect) {
459
+ console.log(`Redirect: bundle differs (${app.bundle} in DB and ${redirectCampaignName})`);
453
460
  }
461
+ result.push(app);
454
462
  console.log("--------------------");
455
463
  }
456
- console.log(result);
464
+ await axios_1.default.post(`https://aipanel-secondary.com/flash/batch-update`, result, {
465
+ headers: {
466
+ "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiaWF0IjoxNjg3Mjc2NjA0LCJleHAiOjE2ODc4ODE0MDR9.XesrnNGmWlK-yBBMs5TeKvTe07A8Sud7B4MyfZAOMag"
467
+ }
468
+ });
469
+ // console.log(result)
457
470
  };
458
471
  // removeBrokenDomain()
459
472
  // createFlashCampaigns(sampleApp)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bprotsyk/aso-core",
3
- "version": "1.2.69",
3
+ "version": "1.2.71",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -19,7 +19,7 @@ export { IOfferWallOffer } from "./aso/offerwall/offerwall-offer"
19
19
  export { IOfferWallResponse } from "./aso/offerwall/offerwall-response"
20
20
  export { IOfferWallHomeDialogData } from "./aso/offerwall/offerwall-home-dialog-data"
21
21
 
22
- export { IFlashApp, FlashAppSchema, updateSchemaAndMoveValue, PlugType } from "./flash/flash-app"
22
+ export { IFlashApp, FlashAppSchema, updateSchemaAndMoveValue, PlugType, FlashAppPlugStatus } from "./flash/flash-app"
23
23
  export { IFlashAppListItem } from "./flash/flash-app-list-item"
24
24
  export { FlashAppType } from "./flash/flash-app-type"
25
25
 
@@ -4,10 +4,7 @@ export interface IUpsertFlashAppRequest {
4
4
  id: number
5
5
  name: string
6
6
  bundle: string
7
- plugUrl: string
8
- plugType: PlugType
9
- reservePlugUrl?: string
10
- reservePlugType?: PlugType
7
+ plugContent?: string,
11
8
 
12
9
  onesignalAppId: string
13
10
  onesignalRestApiKey: string
@@ -388,13 +388,14 @@ let changeSourceForFA = async () => {
388
388
  }
389
389
 
390
390
  let gatherInfoForFlashApps = async () => {
391
- const pasteMap: PasteMap = JSON.parse(await readFile('./map-paste.json', 'utf8'));
392
- const trackingMap: TrackingMap = JSON.parse(await readFile('./map-tracking.json', 'utf8'));
393
- const flashApps: { [key: string]: IFlashApp | undefined } = JSON.parse(await readFile('./map-apps.json', 'utf8'));
391
+ console.log(__dirname)
392
+ const pasteMap: PasteMap = JSON.parse(await readFile('/Users/bprtsk/Documents/Work/ASO/AI Control Panel /AI Panel Core/src/utils/map-paste.json', 'utf8'));
393
+ const trackingMap: TrackingMap = JSON.parse(await readFile('/Users/bprtsk/Documents/Work/ASO/AI Control Panel /AI Panel Core/src/utils/map-tracking.json', 'utf8'));
394
+ const flashApps: { [key: string]: IFlashApp | undefined } = JSON.parse(await readFile('/Users/bprtsk/Documents/Work/ASO/AI Control Panel /AI Panel Core/src/utils/map-apps.json', 'utf8'));
394
395
 
395
396
  let allCampaigns = await KeitaroService.getAllCampaigns()
396
- let owCampaigns = allCampaigns.filter(c => new RegExp(`^FA #`).exec(c.name)).reduce((acc, obj) => ({ ...acc, [new RegExp(/#\((.*)\)/g).exec(obj.name)![1]]: obj }), {});
397
- let redirectCampaigns = allCampaigns.filter(c => new RegExp(`^F #`).exec(c.name)).reduce((acc, obj) => ({ ...acc, [new RegExp(/#\((.*)\)/g).exec(obj.name)![1]]: obj }), {});
397
+ let owCampaigns = allCampaigns.filter(c => new RegExp(`^FA #`).exec(c.name)).reduce((acc, obj) => ({ ...acc, [new RegExp(/#(.*) \(/g).exec(obj.name)?.[1] || obj.name]: obj }), {});
398
+ let redirectCampaigns = allCampaigns.filter(c => new RegExp(`^F #`).exec(c.name)).reduce((acc, obj) => ({ ...acc, [new RegExp(/#(.*) \(/g).exec(obj.name)?.[1] || obj.name]: obj }), {});
398
399
 
399
400
  let result = []
400
401
  for (let [id, paste] of Object.entries(pasteMap)) {
@@ -404,66 +405,84 @@ let gatherInfoForFlashApps = async () => {
404
405
  let tracking = trackingMap[id as keyof object]
405
406
  let app = flashApps[id as keyof object]
406
407
 
408
+ if (!app) {
409
+ console.log(`! No app for ${id}`)
410
+ continue
411
+ }
412
+
407
413
  if (paste.status == FlashAppPlugStatus.ENABLED) {
408
414
  if (!ow) console.log(`#${id}: no OW`)
409
- else if (!paste.content.includes(ow.domain)) console.log(`#${id}: OW domain (${ow.domain}) differs from paste domain (${paste.content})`)
410
- else if (!paste.content.includes(ow.id.toString())) console.log(`#${id}: OW campaign id (${ow.id}) differs from paste id (${paste.content})`)
411
415
 
412
416
  if (!redirect) console.log(`No redirect for #${id}`)
413
417
  else if (!paste.content.includes(redirect.domain)) console.log(`#${id}: Redirect domain (${redirect.domain}) differs from paste domain (${paste.content})`)
414
- else if (!paste.content.includes(redirect.id.toString())) console.log(`#${id}: Redirect campaign id (${redirect.id}) differs from paste id (${paste.content})`)
418
+ else if (!paste.content.includes(redirect.alias)) console.log(`#${id}: Redirect campaign alias (${redirect.alias}) differs from paste id (${paste.content})`)
415
419
  }
416
420
 
417
- let appId = ow?.parameters.sub_id_1.placeholder
418
- if (!appId) console.log(`No app id for #${id}`)
419
- else if (appId != id) console.log(`Wrong app id (${appId}) for #${id}`)
421
+ let appId
422
+ for (let parameter of Object.values(redirect?.parameters || {})) {
423
+ if (parameter.name == "appId") {
424
+ appId = parameter.placeholder
425
+ }
426
+ }
427
+ if (!appId && ow) console.log(`No app id for #${id}`)
428
+ else if (appId != id && ow) console.log(`Wrong app id (${appId}) for #${id}`)
420
429
 
421
- let owDomain = ow?.domain
430
+ let owDomain = ow?.domain?.split("/")[2]
422
431
  let owDomainId = ow?.domain_id
423
432
  let owCampaignId = ow?.id
424
433
  let owCampaignName = ow?.name
425
- let redirectDomain = redirect?.domain
434
+ let redirectDomain = redirect?.domain?.split("/")[2]
426
435
  let redirectDomainId = redirect?.domain_id
427
436
  let redirectCampaignId = redirect?.id
428
437
  let redirectCampaignName = redirect?.name
429
438
 
430
- let clickIdParameterName = redirect?.parameters?.sub_id_8.name
431
- let offerIdParameterName = redirect?.parameters?.sub_id_15.name
432
- if (!clickIdParameterName) console.log(`No click id parameter for #${id}`)
433
- if (!offerIdParameterName) console.log(`No offer id parameter for #${id}`)
439
+ let clickIdParameterName = ow?.parameters?.sub_id_8?.name
440
+ let offerIdParameterName = ow?.parameters?.sub_id_15?.name
441
+ if (!clickIdParameterName && app && ow) console.log(`No click id parameter for #${id}`)
442
+ if (!offerIdParameterName && app && ow) console.log(`No offer id parameter for #${id}`)
434
443
 
435
444
  let trackingLink = tracking?.trackingUrl
436
445
 
437
- if (app) {
438
- app.plugStatus = paste.status
439
- app.plugContent = paste.content
440
- app.plugType = PlugType.PASTEBIN
441
- app.plugId = paste.paste_id
442
- app.plugAccountId = parseInt(paste.accountId)
443
-
444
- app.keitaroData.redirectDomainName = redirectDomain || "none"
445
- app.keitaroData.redirectDomainId = redirectDomainId || 0
446
- app.keitaroData.redirectCampaignId = redirectCampaignId || 0
447
- app.keitaroData.redirectCampaignName = redirectCampaignName || "none"
448
- app.keitaroData.trackingDomainId = owDomainId || 0
449
- app.keitaroData.trackingDomainName = owDomain || "none"
450
- app.keitaroData.trackingCampaignId = owCampaignId || 0
451
- app.keitaroData.trackingCampaignName = owCampaignName || "none"
452
-
453
- if (clickIdParameterName) app.keitaroData.clickIdParameterName = clickIdParameterName
454
- if (offerIdParameterName) app.keitaroData.offerIdParameterName = offerIdParameterName
455
-
456
- if (trackingLink) app.trackingUrl = trackingLink
457
-
458
- result.push(app)
459
- } else {
460
- console.log(`! No app for ${id}`)
446
+ app.plugStatus = paste.status
447
+ app.plugContent = paste.content
448
+ app.plugType = PlugType.PASTEBIN
449
+ app.plugId = paste.paste_id
450
+ app.plugAccountId = parseInt(paste.accountId)
451
+
452
+ app.keitaroData.redirectDomainName = redirectDomain || "none"
453
+ app.keitaroData.redirectDomainId = redirectDomainId || 0
454
+ app.keitaroData.redirectCampaignId = redirectCampaignId || 0
455
+ app.keitaroData.redirectCampaignName = redirectCampaignName || "none"
456
+ app.keitaroData.trackingDomainId = owDomainId || 0
457
+ app.keitaroData.trackingDomainName = owDomain || "none"
458
+ app.keitaroData.trackingCampaignId = owCampaignId || 0
459
+ app.keitaroData.trackingCampaignName = owCampaignName || "none"
460
+
461
+ if (clickIdParameterName) app.keitaroData.clickIdParameterName = clickIdParameterName
462
+ if (offerIdParameterName) app.keitaroData.offerIdParameterName = offerIdParameterName
463
+
464
+ if (trackingLink) app.trackingUrl = trackingLink
465
+
466
+ if (!owCampaignName?.includes(app.bundle) && ow) {
467
+ console.log(`OW: bundle differs (${app.bundle} in DB and ${owCampaignName})`)
468
+ }
469
+
470
+ if (!redirectCampaignName?.includes(app.bundle) && redirect) {
471
+ console.log(`Redirect: bundle differs (${app.bundle} in DB and ${redirectCampaignName})`)
461
472
  }
462
473
 
474
+ result.push(app)
475
+
463
476
  console.log("--------------------")
464
477
  }
465
478
 
466
- console.log(result)
479
+ await axios.post(`https://aipanel-secondary.com/flash/batch-update`, result, {
480
+ headers: {
481
+ "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiaWF0IjoxNjg3Mjc2NjA0LCJleHAiOjE2ODc4ODE0MDR9.XesrnNGmWlK-yBBMs5TeKvTe07A8Sud7B4MyfZAOMag"
482
+ }
483
+ })
484
+
485
+ // console.log(result)
467
486
  }
468
487
 
469
488
  // removeBrokenDomain()