@bprotsyk/aso-core 1.2.175 → 1.2.177
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/flash/flash-app.d.ts +2 -0
- package/lib/network/keitaro/keitaro-service.d.ts +2 -0
- package/lib/network/keitaro/keitaro-service.js +11 -4
- package/lib/utils/keitaro-utils.js +12 -0
- package/package.json +1 -1
- package/src/flash/flash-app.ts +3 -1
- package/src/network/keitaro/keitaro-service.ts +14 -5
- package/src/utils/keitaro-utils.ts +19 -1
package/lib/flash/flash-app.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ declare function createCampaign(campaignData: Partial<IKeitaroCampaign>): Promis
|
|
|
15
15
|
declare function getCampaignById(id: number): Promise<IKeitaroCampaign>;
|
|
16
16
|
export declare function upsertStreamToCampaign(campaign: IKeitaroCampaign, stream: Partial<IKeitaroStream>): Promise<void>;
|
|
17
17
|
declare function cloneOWCampaign(app: IFlashApp): Promise<IKeitaroCampaign>;
|
|
18
|
+
declare function changeCampaignsGroup(fromId: number, toId: number, exceptForCampaignIds: number[]): Promise<void>;
|
|
18
19
|
declare function getDomains(onlyActive?: boolean): Promise<IKeitaroDomain[]>;
|
|
19
20
|
export declare const KeitaroService: {
|
|
20
21
|
getStreamsByCampaignId: typeof getStreamsByCampaignId;
|
|
@@ -30,5 +31,6 @@ export declare const KeitaroService: {
|
|
|
30
31
|
upsertStreamToCampaign: typeof upsertStreamToCampaign;
|
|
31
32
|
cloneOWCampaign: typeof cloneOWCampaign;
|
|
32
33
|
updateOffer: typeof updateOffer;
|
|
34
|
+
changeCampaignsGroup: typeof changeCampaignsGroup;
|
|
33
35
|
};
|
|
34
36
|
export {};
|
|
@@ -54,11 +54,11 @@ async function cloneStreams(originalCampaignId, streamPositionsToClone, campaign
|
|
|
54
54
|
async function updateCampaign(id, payload) {
|
|
55
55
|
await http_1.default.put(`campaigns/${id}`, payload);
|
|
56
56
|
}
|
|
57
|
-
async function createStreamForMatchingCampaigns(streamPartialPayload, offerId, campaignRegExp) {
|
|
57
|
+
async function createStreamForMatchingCampaigns(streamPartialPayload, offerId, campaignRegExp, onlyInGroup) {
|
|
58
58
|
// Get a list of all campaigns
|
|
59
59
|
const allCampaigns = await getAllCampaigns();
|
|
60
60
|
// Filter the campaigns by the given RegExp
|
|
61
|
-
const matchingCampaigns = allCampaigns.filter(campaign => campaignRegExp.exec(campaign.name));
|
|
61
|
+
const matchingCampaigns = allCampaigns.filter(campaign => (onlyInGroup ? campaign.group_id == onlyInGroup : true) && campaignRegExp.exec(campaign.name));
|
|
62
62
|
// console.log(matchingCampaigns)
|
|
63
63
|
// For each matching campaign, clone the streams
|
|
64
64
|
for (const matchingCampaign of matchingCampaigns) {
|
|
@@ -167,7 +167,7 @@ async function cloneOWCampaign(app) {
|
|
|
167
167
|
let matchingCampaign = allCampaigns.filter((c) => c.name.includes(`FA #${app.id}`));
|
|
168
168
|
if (matchingCampaign.length > 0)
|
|
169
169
|
return matchingCampaign[0];
|
|
170
|
-
const { data: campaigns } = await http_1.default.post(`/campaigns/
|
|
170
|
+
const { data: campaigns } = await http_1.default.post(`/campaigns/2687/clone`);
|
|
171
171
|
if (campaigns.length == 0)
|
|
172
172
|
throw Error("Campaign cloning falied");
|
|
173
173
|
let clonedCampaign = campaigns[0];
|
|
@@ -185,6 +185,13 @@ async function cloneOWCampaign(app) {
|
|
|
185
185
|
const { data: campaign } = await http_1.default.put(`/campaigns/${clonedCampaign.id}`, payload);
|
|
186
186
|
return campaign;
|
|
187
187
|
}
|
|
188
|
+
async function changeCampaignsGroup(fromId, toId, exceptForCampaignIds) {
|
|
189
|
+
let campaigns = await getAllCampaigns();
|
|
190
|
+
const matchingCampaigns = campaigns.filter(campaign => campaign.group_id == fromId && !exceptForCampaignIds.includes(campaign.id));
|
|
191
|
+
for (let campaign of matchingCampaigns) {
|
|
192
|
+
await updateCampaign(campaign.id, { group_id: toId });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
188
195
|
// Domain
|
|
189
196
|
async function getDomains(onlyActive) {
|
|
190
197
|
const { data: domains } = await http_1.default.get(`/domains`);
|
|
@@ -192,5 +199,5 @@ async function getDomains(onlyActive) {
|
|
|
192
199
|
}
|
|
193
200
|
exports.KeitaroService = {
|
|
194
201
|
getStreamsByCampaignId, updateCampaign, getAllCampaigns, getAllOffers, cloneStreams, addOfferToKeitaro, getOfferByKeitaroId, getDomains, createCampaign, getCampaignById, upsertStreamToCampaign, cloneOWCampaign,
|
|
195
|
-
updateOffer
|
|
202
|
+
updateOffer, changeCampaignsGroup
|
|
196
203
|
};
|
|
@@ -469,6 +469,18 @@ let findBrokenOfferStreams = async () => {
|
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
471
|
};
|
|
472
|
+
let moveCampaignsToAnotherGroup = async () => {
|
|
473
|
+
let from = 2, to = 80, exceptFor = [2684, 2686, 2673, 2670, 2687, 2689, 2529, 2688, 2551, 2517, 2691, 2588, 2643, 2563, 2598, 2624, 2584, 2553, 2683, 2618, 2499, 2594, 2545, 2682, 2569, 2527, 2681, 2677, 2610, 2608];
|
|
474
|
+
await keitaro_service_1.KeitaroService.changeCampaignsGroup(from, to, exceptFor);
|
|
475
|
+
};
|
|
476
|
+
moveCampaignsToAnotherGroup();
|
|
477
|
+
// Getting campaign group ids
|
|
478
|
+
// (async () => {
|
|
479
|
+
// let campaigns = await KeitaroService.getAllCampaigns()
|
|
480
|
+
// let normal = campaigns.find(c => c.id == 2684)
|
|
481
|
+
// let archive = campaigns.find(c => c.id == 2679)
|
|
482
|
+
// console.log([normal?.group_id, archive?.group_id])
|
|
483
|
+
// })()
|
|
472
484
|
// findBrokenOfferStreams()
|
|
473
485
|
// removeBrokenDomain()
|
|
474
486
|
// createFlashCampaigns(sampleApp)
|
package/package.json
CHANGED
package/src/flash/flash-app.ts
CHANGED
|
@@ -63,12 +63,12 @@ async function updateCampaign(id: number, payload: Partial<IKeitaroCampaign>) {
|
|
|
63
63
|
await keitaroApi.put(`campaigns/${id}`, payload)
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
async function createStreamForMatchingCampaigns(streamPartialPayload: any, offerId: string, campaignRegExp: RegExp) {
|
|
66
|
+
async function createStreamForMatchingCampaigns(streamPartialPayload: any, offerId: string, campaignRegExp: RegExp, onlyInGroup?: number) {
|
|
67
67
|
// Get a list of all campaigns
|
|
68
68
|
const allCampaigns = await getAllCampaigns()
|
|
69
69
|
|
|
70
70
|
// Filter the campaigns by the given RegExp
|
|
71
|
-
const matchingCampaigns = allCampaigns.filter(campaign => campaignRegExp.exec(campaign.name));
|
|
71
|
+
const matchingCampaigns = allCampaigns.filter(campaign => (onlyInGroup ? campaign.group_id == onlyInGroup : true) && campaignRegExp.exec(campaign.name));
|
|
72
72
|
// console.log(matchingCampaigns)
|
|
73
73
|
|
|
74
74
|
|
|
@@ -198,7 +198,7 @@ async function cloneOWCampaign(app: IFlashApp): Promise<IKeitaroCampaign> {
|
|
|
198
198
|
let matchingCampaign = allCampaigns.filter((c) => c.name.includes(`FA #${app.id}`))
|
|
199
199
|
if (matchingCampaign.length > 0) return matchingCampaign[0]
|
|
200
200
|
|
|
201
|
-
const { data: campaigns } = await keitaroApi.post(`/campaigns/
|
|
201
|
+
const { data: campaigns } = await keitaroApi.post(`/campaigns/2687/clone`);
|
|
202
202
|
|
|
203
203
|
if (campaigns.length == 0) throw Error("Campaign cloning falied")
|
|
204
204
|
|
|
@@ -223,6 +223,15 @@ async function cloneOWCampaign(app: IFlashApp): Promise<IKeitaroCampaign> {
|
|
|
223
223
|
return campaign
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
+
async function changeCampaignsGroup(fromId: number, toId: number, exceptForCampaignIds: number[]) {
|
|
227
|
+
let campaigns = await getAllCampaigns()
|
|
228
|
+
const matchingCampaigns = campaigns.filter(campaign => campaign.group_id == fromId && !exceptForCampaignIds.includes(campaign.id))
|
|
229
|
+
|
|
230
|
+
for (let campaign of matchingCampaigns) {
|
|
231
|
+
await updateCampaign(campaign.id, { group_id: toId })
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
226
235
|
// Domain
|
|
227
236
|
async function getDomains(onlyActive?: boolean): Promise<IKeitaroDomain[]> {
|
|
228
237
|
const { data: domains } = await keitaroApi.get<IKeitaroDomain[]>(`/domains`)
|
|
@@ -231,5 +240,5 @@ async function getDomains(onlyActive?: boolean): Promise<IKeitaroDomain[]> {
|
|
|
231
240
|
|
|
232
241
|
export const KeitaroService = {
|
|
233
242
|
getStreamsByCampaignId, updateCampaign, getAllCampaigns, getAllOffers, cloneStreams, addOfferToKeitaro, getOfferByKeitaroId, getDomains, createCampaign, getCampaignById, upsertStreamToCampaign, cloneOWCampaign,
|
|
234
|
-
updateOffer
|
|
235
|
-
}
|
|
243
|
+
updateOffer, changeCampaignsGroup
|
|
244
|
+
}
|
|
@@ -533,6 +533,23 @@ let findBrokenOfferStreams = async () => {
|
|
|
533
533
|
}
|
|
534
534
|
}
|
|
535
535
|
|
|
536
|
+
let moveCampaignsToAnotherGroup = async () => {
|
|
537
|
+
let from = 2, to = 80, exceptFor = [2684, 2686, 2673, 2670, 2687, 2689, 2529, 2688, 2551, 2517, 2691, 2588, 2643, 2563, 2598, 2624, 2584, 2553, 2683, 2618, 2499, 2594, 2545, 2682, 2569, 2527, 2681, 2677, 2610, 2608]
|
|
538
|
+
|
|
539
|
+
await KeitaroService.changeCampaignsGroup(from, to, exceptFor)
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
moveCampaignsToAnotherGroup()
|
|
543
|
+
|
|
544
|
+
// Getting campaign group ids
|
|
545
|
+
// (async () => {
|
|
546
|
+
// let campaigns = await KeitaroService.getAllCampaigns()
|
|
547
|
+
// let normal = campaigns.find(c => c.id == 2684)
|
|
548
|
+
// let archive = campaigns.find(c => c.id == 2679)
|
|
549
|
+
|
|
550
|
+
// console.log([normal?.group_id, archive?.group_id])
|
|
551
|
+
// })()
|
|
552
|
+
|
|
536
553
|
// findBrokenOfferStreams()
|
|
537
554
|
|
|
538
555
|
// removeBrokenDomain()
|
|
@@ -544,4 +561,5 @@ let findBrokenOfferStreams = async () => {
|
|
|
544
561
|
|
|
545
562
|
// gatherInfoForFlashApps()
|
|
546
563
|
|
|
547
|
-
// replaceDomainInOffers(`xmariorel.com`, `veemienasorullf.com`, /Icecasino Huffson.*/g)
|
|
564
|
+
// replaceDomainInOffers(`xmariorel.com`, `veemienasorullf.com`, /Icecasino Huffson.*/g)
|
|
565
|
+
|