@bprotsyk/aso-core 1.2.27 → 1.2.29
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 +46 -0
- package/lib/flash/flash-app.js +137 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +6 -2
- package/lib/network/keitaro/http.d.ts +3 -0
- package/lib/network/keitaro/http.js +12 -0
- package/lib/network/keitaro/keitaro-service.d.ts +36 -0
- package/lib/network/keitaro/keitaro-service.js +133 -0
- package/package.json +3 -1
- package/src/flash/flash-app.ts +173 -2
- package/src/index.ts +8 -7
- package/src/network/keitaro/http.ts +8 -0
- package/src/network/keitaro/keitaro-service.ts +174 -0
package/lib/flash/flash-app.d.ts
CHANGED
|
@@ -36,6 +36,29 @@ export interface IFlashApp {
|
|
|
36
36
|
onesignalRestApiKey: string;
|
|
37
37
|
generationOptions: IAppGenerationOptions;
|
|
38
38
|
}
|
|
39
|
+
export interface IFlashAppUpdated {
|
|
40
|
+
id: number;
|
|
41
|
+
name: string;
|
|
42
|
+
trackingUrl?: string;
|
|
43
|
+
bundle: string;
|
|
44
|
+
pushesEnabled?: boolean;
|
|
45
|
+
plugUrl: string;
|
|
46
|
+
reservePlugUrl?: string;
|
|
47
|
+
policyUrl?: string;
|
|
48
|
+
onesignalAppId: string;
|
|
49
|
+
onesignalRestApiKey: string;
|
|
50
|
+
developerName: string;
|
|
51
|
+
developerEmail: string;
|
|
52
|
+
developerOrganization: string;
|
|
53
|
+
generationOptions: IAppGenerationOptionsUpdated;
|
|
54
|
+
}
|
|
55
|
+
export interface IAppGenerationOptionsUpdated {
|
|
56
|
+
splashActivityClassName: string;
|
|
57
|
+
mainActivityClassName: string;
|
|
58
|
+
linkName: string;
|
|
59
|
+
savedName: string;
|
|
60
|
+
paranoidSeed: number;
|
|
61
|
+
}
|
|
39
62
|
export interface IAppGenerationOptions {
|
|
40
63
|
splashActivityClassName: string;
|
|
41
64
|
mainActivityClassName: string;
|
|
@@ -76,3 +99,26 @@ export declare const FlashAppSchema: Schema<any, Model<any, any, any, any, any>,
|
|
|
76
99
|
keyPassword: string;
|
|
77
100
|
} | undefined;
|
|
78
101
|
}>;
|
|
102
|
+
export declare const FlashAppSchemaUpdated: Schema<any, Model<any, any, any, any, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, {
|
|
103
|
+
id: number;
|
|
104
|
+
bundle: string;
|
|
105
|
+
trackingUrl: string;
|
|
106
|
+
onesignalAppId: string;
|
|
107
|
+
onesignalRestApiKey: string;
|
|
108
|
+
plugUrl: string;
|
|
109
|
+
reservePlugUrl: string;
|
|
110
|
+
developerName: string;
|
|
111
|
+
developerEmail: string;
|
|
112
|
+
developerOrganization: string;
|
|
113
|
+
name?: string | undefined;
|
|
114
|
+
pushesEnabled?: boolean | undefined;
|
|
115
|
+
policyUrl?: string | undefined;
|
|
116
|
+
generationOptions?: {
|
|
117
|
+
splashActivityClassName: string;
|
|
118
|
+
mainActivityClassName: string;
|
|
119
|
+
linkName: string;
|
|
120
|
+
savedName: string;
|
|
121
|
+
paranoidSeed: number;
|
|
122
|
+
} | undefined;
|
|
123
|
+
}>;
|
|
124
|
+
export declare function updateSchemaAndMoveValue(model: Model<IFlashAppUpdated>): Promise<void>;
|
package/lib/flash/flash-app.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlashAppSchema = void 0;
|
|
3
|
+
exports.updateSchemaAndMoveValue = exports.FlashAppSchemaUpdated = exports.FlashAppSchema = void 0;
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
|
5
5
|
exports.FlashAppSchema = new mongoose_1.Schema({
|
|
6
6
|
id: {
|
|
@@ -94,3 +94,139 @@ exports.FlashAppSchema = new mongoose_1.Schema({
|
|
|
94
94
|
},
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
|
+
exports.FlashAppSchemaUpdated = new mongoose_1.Schema({
|
|
98
|
+
id: {
|
|
99
|
+
type: Number,
|
|
100
|
+
unique: true,
|
|
101
|
+
required: true
|
|
102
|
+
},
|
|
103
|
+
bundle: {
|
|
104
|
+
type: String,
|
|
105
|
+
unique: true,
|
|
106
|
+
required: true
|
|
107
|
+
},
|
|
108
|
+
name: String,
|
|
109
|
+
trackingUrl: {
|
|
110
|
+
type: String,
|
|
111
|
+
default: null
|
|
112
|
+
},
|
|
113
|
+
pushesEnabled: Boolean,
|
|
114
|
+
plugUrl: {
|
|
115
|
+
type: String,
|
|
116
|
+
unique: true,
|
|
117
|
+
required: true
|
|
118
|
+
},
|
|
119
|
+
reservePlugUrl: {
|
|
120
|
+
type: String,
|
|
121
|
+
unique: true,
|
|
122
|
+
required: true
|
|
123
|
+
},
|
|
124
|
+
policyUrl: {
|
|
125
|
+
type: String,
|
|
126
|
+
unique: true,
|
|
127
|
+
required: false
|
|
128
|
+
},
|
|
129
|
+
onesignalAppId: {
|
|
130
|
+
type: String,
|
|
131
|
+
unique: true,
|
|
132
|
+
required: true
|
|
133
|
+
},
|
|
134
|
+
onesignalRestApiKey: {
|
|
135
|
+
type: String,
|
|
136
|
+
unique: true,
|
|
137
|
+
required: true
|
|
138
|
+
},
|
|
139
|
+
developerName: {
|
|
140
|
+
type: String,
|
|
141
|
+
unique: true,
|
|
142
|
+
required: true
|
|
143
|
+
},
|
|
144
|
+
developerEmail: {
|
|
145
|
+
type: String,
|
|
146
|
+
unique: true,
|
|
147
|
+
required: true
|
|
148
|
+
},
|
|
149
|
+
developerOrganization: {
|
|
150
|
+
type: String,
|
|
151
|
+
unique: true,
|
|
152
|
+
required: true
|
|
153
|
+
},
|
|
154
|
+
generationOptions: {
|
|
155
|
+
splashActivityClassName: {
|
|
156
|
+
type: String,
|
|
157
|
+
required: true
|
|
158
|
+
},
|
|
159
|
+
mainActivityClassName: {
|
|
160
|
+
type: String,
|
|
161
|
+
required: true
|
|
162
|
+
},
|
|
163
|
+
linkName: {
|
|
164
|
+
type: String,
|
|
165
|
+
required: true
|
|
166
|
+
},
|
|
167
|
+
savedName: {
|
|
168
|
+
type: String,
|
|
169
|
+
required: true
|
|
170
|
+
},
|
|
171
|
+
paranoidSeed: {
|
|
172
|
+
type: Number,
|
|
173
|
+
required: true,
|
|
174
|
+
unique: true
|
|
175
|
+
},
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
async function updateSchemaAndMoveValue(model) {
|
|
179
|
+
const aggregationPipeline = [
|
|
180
|
+
{
|
|
181
|
+
$project: {
|
|
182
|
+
pastebinUrl: 0,
|
|
183
|
+
email: 0,
|
|
184
|
+
onesignalAppId: { $toString: '$onesignalAppId' },
|
|
185
|
+
onesignalRestApiKey: { $toString: '$onesignalRestApiKey' },
|
|
186
|
+
generationOptions: {
|
|
187
|
+
keyFileName: 0,
|
|
188
|
+
keyDeveloperName: 0,
|
|
189
|
+
keyDeveloperOrganization: 0,
|
|
190
|
+
keyCountryCode: 0,
|
|
191
|
+
keyCity: 0,
|
|
192
|
+
keyAlias: 0,
|
|
193
|
+
keyPassword: 0
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
$addFields: {
|
|
199
|
+
plugUrl: `$pastebinUrl`,
|
|
200
|
+
reservePlugUrl: null,
|
|
201
|
+
developerName: '$email',
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
];
|
|
205
|
+
// Define the update operation to apply the new schema with the updated field
|
|
206
|
+
const updateOperation = {
|
|
207
|
+
$set: {
|
|
208
|
+
plugUrl: '$pastebinUrl',
|
|
209
|
+
reservePlugUrl: null,
|
|
210
|
+
policyUrl: null,
|
|
211
|
+
developerName: '$generationOptions.keyDeveloperName',
|
|
212
|
+
developerEmail: '$email',
|
|
213
|
+
developerOrganization: '$generationOptions.keyDeveloperOrganization',
|
|
214
|
+
},
|
|
215
|
+
$unset: {
|
|
216
|
+
'email': true,
|
|
217
|
+
'pastebinUrl': true,
|
|
218
|
+
'generationOptions.keyFileName': true,
|
|
219
|
+
'generationOptions.keyDeveloperName': true,
|
|
220
|
+
'generationOptions.keyDeveloperOrganization': true,
|
|
221
|
+
'generationOptions.keyCountryCode': true,
|
|
222
|
+
'generationOptions.keyCity': true,
|
|
223
|
+
'generationOptions.keyAlias': 0,
|
|
224
|
+
'generationOptions.keyPassword': 0
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
await model.updateMany({}, [
|
|
228
|
+
...aggregationPipeline,
|
|
229
|
+
updateOperation
|
|
230
|
+
]);
|
|
231
|
+
}
|
|
232
|
+
exports.updateSchemaAndMoveValue = updateSchemaAndMoveValue;
|
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 } from "./flash/flash-app";
|
|
19
|
+
export { IFlashApp as IFlashAppOld, IFlashAppUpdated as IFlashApp, FlashAppSchema as FlashAppSchemaOld, FlashAppSchemaUpdated as FlashAppSchema, updateSchemaAndMoveValue } from "./flash/flash-app";
|
|
20
20
|
export { IFlashAppListItem } from "./flash/flash-app-list-item";
|
|
21
21
|
export * as ASOConfigFetch from "./aso/usage-logs/aso-config-fetch-entry";
|
|
22
22
|
export { IPanelUser, PanelUserAccessScope, PanelUserSchema } from "./panel/user";
|
|
@@ -28,3 +28,4 @@ export { IOfferWallAuthConfig } from "./aso/offerwall/auth/offerwall-auth-config
|
|
|
28
28
|
export { IOfferWallAuthLocalization } from "./aso/offerwall/auth/offerwall-auth-localization";
|
|
29
29
|
export { IOfferWallAuthSubmitRequest } from "./aso/offerwall/auth/offerwall-auth-submit-request";
|
|
30
30
|
export { IOfferWallAuthSubmitResponse } from "./aso/offerwall/auth/offerwall-auth-submit-response";
|
|
31
|
+
export { KeitaroService } from "./network/keitaro/keitaro-service";
|
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.ColoredText = exports.ShapeDiv = exports.PanelUserSchema = exports.PanelUserAccessScope = exports.ASOConfigFetch = 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.updateSchemaAndMoveValue = exports.FlashAppSchema = exports.FlashAppSchemaOld = 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"));
|
|
@@ -31,7 +31,9 @@ exports.ASO_v3 = __importStar(require("./aso/config/aso-config-v3"));
|
|
|
31
31
|
exports.ASO_v4 = __importStar(require("./aso/config/aso-config-v4"));
|
|
32
32
|
exports.ASO_v5 = __importStar(require("./aso/config/aso-config-v5"));
|
|
33
33
|
var flash_app_1 = require("./flash/flash-app");
|
|
34
|
-
Object.defineProperty(exports, "
|
|
34
|
+
Object.defineProperty(exports, "FlashAppSchemaOld", { enumerable: true, get: function () { return flash_app_1.FlashAppSchema; } });
|
|
35
|
+
Object.defineProperty(exports, "FlashAppSchema", { enumerable: true, get: function () { return flash_app_1.FlashAppSchemaUpdated; } });
|
|
36
|
+
Object.defineProperty(exports, "updateSchemaAndMoveValue", { enumerable: true, get: function () { return flash_app_1.updateSchemaAndMoveValue; } });
|
|
35
37
|
exports.ASOConfigFetch = __importStar(require("./aso/usage-logs/aso-config-fetch-entry"));
|
|
36
38
|
var user_1 = require("./panel/user");
|
|
37
39
|
Object.defineProperty(exports, "PanelUserAccessScope", { enumerable: true, get: function () { return user_1.PanelUserAccessScope; } });
|
|
@@ -40,3 +42,5 @@ var shape_1 = require("./shared/shape");
|
|
|
40
42
|
Object.defineProperty(exports, "ShapeDiv", { enumerable: true, get: function () { return shape_1.ShapeDiv; } });
|
|
41
43
|
var colored_text_1 = require("./shared/colored-text");
|
|
42
44
|
Object.defineProperty(exports, "ColoredText", { enumerable: true, get: function () { return colored_text_1.ColoredText; } });
|
|
45
|
+
var keitaro_service_1 = require("./network/keitaro/keitaro-service");
|
|
46
|
+
Object.defineProperty(exports, "KeitaroService", { enumerable: true, get: function () { return keitaro_service_1.KeitaroService; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const axios_1 = __importDefault(require("axios"));
|
|
7
|
+
exports.default = axios_1.default.create({
|
|
8
|
+
baseURL: 'https://aibprtsk.com/admin_api/v1/',
|
|
9
|
+
headers: {
|
|
10
|
+
"Api-Key": `a5369b1016aa6bd6453751a393b157b4`,
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IOffer } from "../../shared/offer";
|
|
2
|
+
export interface IKeitaroStream {
|
|
3
|
+
id: number;
|
|
4
|
+
name: string;
|
|
5
|
+
campaign_id: number;
|
|
6
|
+
offer_id: number;
|
|
7
|
+
url: string;
|
|
8
|
+
redirect_url: string;
|
|
9
|
+
traffic_type: string;
|
|
10
|
+
state: string;
|
|
11
|
+
filters: any[];
|
|
12
|
+
position: number;
|
|
13
|
+
offers: any[];
|
|
14
|
+
schema: string;
|
|
15
|
+
type: string;
|
|
16
|
+
action_type: string;
|
|
17
|
+
}
|
|
18
|
+
export interface IKeitaroCampaign {
|
|
19
|
+
id: number;
|
|
20
|
+
name: string;
|
|
21
|
+
}
|
|
22
|
+
declare function getStreamsByCampaignId(campaignId: number): Promise<IKeitaroStream[]>;
|
|
23
|
+
declare function getAllCampaigns(): Promise<IKeitaroCampaign[]>;
|
|
24
|
+
declare function cloneStreams(originalCampaignId: number, streamPositionsToClone: number[], campaignRegExp: RegExp): Promise<void>;
|
|
25
|
+
declare function getAllOffers(): Promise<any[]>;
|
|
26
|
+
declare function getOfferByKeitaroId(id: number): Promise<any>;
|
|
27
|
+
declare function addOfferToKeitaro(offer: IOffer, affiliateId: number, link: string, groupId?: number): Promise<void>;
|
|
28
|
+
export declare const KeitaroService: {
|
|
29
|
+
getStreamsByCampaignId: typeof getStreamsByCampaignId;
|
|
30
|
+
getAllCampaigns: typeof getAllCampaigns;
|
|
31
|
+
getAllOffers: typeof getAllOffers;
|
|
32
|
+
cloneStreams: typeof cloneStreams;
|
|
33
|
+
addOfferToKeitaro: typeof addOfferToKeitaro;
|
|
34
|
+
getOfferByKeitaroId: typeof getOfferByKeitaroId;
|
|
35
|
+
};
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.KeitaroService = void 0;
|
|
7
|
+
const http_1 = __importDefault(require("./http"));
|
|
8
|
+
async function getStreamsByCampaignId(campaignId) {
|
|
9
|
+
const { data: streams } = await http_1.default.get(`campaigns/${campaignId}/streams`);
|
|
10
|
+
return streams;
|
|
11
|
+
}
|
|
12
|
+
async function getAllCampaigns() {
|
|
13
|
+
const { data: campaigns } = await http_1.default.get('campaigns');
|
|
14
|
+
``;
|
|
15
|
+
return campaigns;
|
|
16
|
+
}
|
|
17
|
+
async function cloneStreams(originalCampaignId, streamPositionsToClone, campaignRegExp) {
|
|
18
|
+
// Get the original campaign's streams
|
|
19
|
+
const originalStreams = await getStreamsByCampaignId(originalCampaignId);
|
|
20
|
+
// Filter the original streams by the given stream positions to clone
|
|
21
|
+
const streamsToClone = originalStreams.filter(stream => streamPositionsToClone.includes(stream.position));
|
|
22
|
+
// Get a list of all campaigns
|
|
23
|
+
const allCampaigns = await getAllCampaigns();
|
|
24
|
+
// Filter the campaigns by the given RegExp
|
|
25
|
+
const matchingCampaigns = allCampaigns.filter(campaign => campaignRegExp.exec(campaign.name) && campaign.id != originalCampaignId);
|
|
26
|
+
// console.log(matchingCampaigns)
|
|
27
|
+
// For each matching campaign, clone the streams
|
|
28
|
+
for (const matchingCampaign of matchingCampaigns) {
|
|
29
|
+
for (const streamToClone of streamsToClone) {
|
|
30
|
+
await http_1.default.post('streams', {
|
|
31
|
+
name: streamToClone.name,
|
|
32
|
+
campaign_id: matchingCampaign.id,
|
|
33
|
+
schema: streamToClone.schema,
|
|
34
|
+
type: streamToClone.type,
|
|
35
|
+
action_type: streamToClone.action_type,
|
|
36
|
+
weight: 100,
|
|
37
|
+
offers: streamToClone.offers.map((offer) => {
|
|
38
|
+
return {
|
|
39
|
+
offer_id: offer.offer_id,
|
|
40
|
+
share: 100
|
|
41
|
+
};
|
|
42
|
+
}),
|
|
43
|
+
filters: streamToClone.filters.map((filter) => {
|
|
44
|
+
return {
|
|
45
|
+
name: filter.name,
|
|
46
|
+
mode: filter.mode,
|
|
47
|
+
payload: filter.payload
|
|
48
|
+
};
|
|
49
|
+
}),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async function createStreamForMatchingCampaigns(streamPartialPayload, offerId, campaignRegExp) {
|
|
55
|
+
// Get a list of all campaigns
|
|
56
|
+
const allCampaigns = await getAllCampaigns();
|
|
57
|
+
// Filter the campaigns by the given RegExp
|
|
58
|
+
const matchingCampaigns = allCampaigns.filter(campaign => campaignRegExp.exec(campaign.name));
|
|
59
|
+
// console.log(matchingCampaigns)
|
|
60
|
+
// For each matching campaign, clone the streams
|
|
61
|
+
for (const matchingCampaign of matchingCampaigns) {
|
|
62
|
+
let streams = await getStreamsByCampaignId(matchingCampaign.id);
|
|
63
|
+
let identicalStream = streams.find((stream) => stream.name.includes(offerId));
|
|
64
|
+
if (identicalStream) {
|
|
65
|
+
await http_1.default.put(`streams/${identicalStream.id}`, {
|
|
66
|
+
campaign_id: matchingCampaign.id,
|
|
67
|
+
...streamPartialPayload
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
await http_1.default.post('streams', {
|
|
72
|
+
campaign_id: matchingCampaign.id,
|
|
73
|
+
...streamPartialPayload
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function getAllOffers() {
|
|
79
|
+
const { data: offers } = await http_1.default.get('offers');
|
|
80
|
+
return offers;
|
|
81
|
+
}
|
|
82
|
+
async function getOfferByKeitaroId(id) {
|
|
83
|
+
const { data: offer } = await http_1.default.get(`offers/${id}`);
|
|
84
|
+
return offer;
|
|
85
|
+
}
|
|
86
|
+
function createStreamPartialPayload(keitaroOfferId, offerName, offerId, offerGeo) {
|
|
87
|
+
return {
|
|
88
|
+
name: `${offerName} ${offerGeo} (${offerId})`,
|
|
89
|
+
schema: "landings",
|
|
90
|
+
type: "regular",
|
|
91
|
+
action_type: "http",
|
|
92
|
+
weight: 100,
|
|
93
|
+
offers: [{
|
|
94
|
+
offer_id: keitaroOfferId,
|
|
95
|
+
share: 100,
|
|
96
|
+
state: "active"
|
|
97
|
+
}],
|
|
98
|
+
filters: [{
|
|
99
|
+
name: "sub_id_15",
|
|
100
|
+
mode: "accept",
|
|
101
|
+
payload: [offerId]
|
|
102
|
+
}],
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
async function addOfferToKeitaro(offer, affiliateId, link, groupId) {
|
|
106
|
+
// TODO look if offer already exists by offer.name
|
|
107
|
+
let allOffers = await getAllOffers();
|
|
108
|
+
let identicalOffer = allOffers.find((o) => { return o.name.includes(offer.name); });
|
|
109
|
+
let keitaroOfferId;
|
|
110
|
+
if (identicalOffer) {
|
|
111
|
+
keitaroOfferId = identicalOffer.id;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
let offerPayload = {
|
|
115
|
+
name: `${offer.caption} ${offer.geo} (${offer.name})`,
|
|
116
|
+
group_id: groupId || 1,
|
|
117
|
+
action_payload: link,
|
|
118
|
+
affiliate_network_id: affiliateId,
|
|
119
|
+
country: [offer.geo],
|
|
120
|
+
action_type: "http",
|
|
121
|
+
offer_type: "external",
|
|
122
|
+
payout_auto: true,
|
|
123
|
+
payout_upsell: true,
|
|
124
|
+
};
|
|
125
|
+
const { data: keitaroOffer } = await http_1.default.post(`offers`, offerPayload);
|
|
126
|
+
keitaroOfferId = keitaroOffer.id;
|
|
127
|
+
}
|
|
128
|
+
let streamPartialPayload = createStreamPartialPayload(keitaroOfferId, offer.caption, offer.name, offer.geo);
|
|
129
|
+
await createStreamForMatchingCampaigns(streamPartialPayload, offer.name, /^(FA #|A #)/);
|
|
130
|
+
}
|
|
131
|
+
exports.KeitaroService = {
|
|
132
|
+
getStreamsByCampaignId, getAllCampaigns, getAllOffers, cloneStreams, addOfferToKeitaro, getOfferByKeitaroId
|
|
133
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bprotsyk/aso-core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.29",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -20,9 +20,11 @@
|
|
|
20
20
|
"homepage": "https://bitbucket.org/bprtsk/aso-core#readme",
|
|
21
21
|
"description": "",
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"@types/axios": "^0.14.0",
|
|
23
24
|
"@types/module-alias": "^2.0.1",
|
|
24
25
|
"@types/mongoose": "^5.11.97",
|
|
25
26
|
"@types/styled-components": "^5.1.26",
|
|
27
|
+
"axios": "^1.4.0",
|
|
26
28
|
"module-alias": "^2.2.2",
|
|
27
29
|
"mongoose": "^6.8.3",
|
|
28
30
|
"react": "^18.2.0",
|
package/src/flash/flash-app.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Model, model, Schema } from "mongoose";
|
|
1
|
+
import { Model, model, Schema, UpdateQuery } from "mongoose";
|
|
2
2
|
|
|
3
3
|
// TODO add date of policy in case we need to recreate it
|
|
4
4
|
// and all data necessary. test
|
|
@@ -18,10 +18,38 @@ export interface IFlashApp {
|
|
|
18
18
|
generationOptions: IAppGenerationOptions
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
export interface IFlashAppUpdated {
|
|
22
|
+
id: number
|
|
23
|
+
name: string
|
|
24
|
+
trackingUrl?: string
|
|
25
|
+
bundle: string
|
|
26
|
+
|
|
27
|
+
pushesEnabled?: boolean
|
|
28
|
+
plugUrl: string
|
|
29
|
+
reservePlugUrl?: string
|
|
30
|
+
policyUrl?: string
|
|
31
|
+
|
|
32
|
+
onesignalAppId: string
|
|
33
|
+
onesignalRestApiKey: string
|
|
34
|
+
|
|
35
|
+
developerName: string
|
|
36
|
+
developerEmail: string
|
|
37
|
+
developerOrganization: string
|
|
38
|
+
generationOptions: IAppGenerationOptionsUpdated
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface IAppGenerationOptionsUpdated {
|
|
42
|
+
splashActivityClassName: string
|
|
43
|
+
mainActivityClassName: string
|
|
44
|
+
linkName: string
|
|
45
|
+
savedName: string
|
|
46
|
+
paranoidSeed: number
|
|
47
|
+
}
|
|
48
|
+
|
|
21
49
|
export interface IAppGenerationOptions {
|
|
22
50
|
splashActivityClassName: string
|
|
23
51
|
mainActivityClassName: string
|
|
24
|
-
linkName: string
|
|
52
|
+
linkName: string
|
|
25
53
|
savedName: string
|
|
26
54
|
|
|
27
55
|
paranoidSeed: number
|
|
@@ -130,3 +158,146 @@ export const FlashAppSchema = new Schema({
|
|
|
130
158
|
}
|
|
131
159
|
})
|
|
132
160
|
|
|
161
|
+
export const FlashAppSchemaUpdated = new Schema({
|
|
162
|
+
id: {
|
|
163
|
+
type: Number,
|
|
164
|
+
unique: true,
|
|
165
|
+
required: true
|
|
166
|
+
},
|
|
167
|
+
bundle: {
|
|
168
|
+
type: String,
|
|
169
|
+
unique: true,
|
|
170
|
+
required: true
|
|
171
|
+
},
|
|
172
|
+
name: String,
|
|
173
|
+
trackingUrl: {
|
|
174
|
+
type: String,
|
|
175
|
+
default: null
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
pushesEnabled: Boolean,
|
|
179
|
+
plugUrl: {
|
|
180
|
+
type: String,
|
|
181
|
+
unique: true,
|
|
182
|
+
required: true
|
|
183
|
+
},
|
|
184
|
+
reservePlugUrl: {
|
|
185
|
+
type: String,
|
|
186
|
+
unique: true,
|
|
187
|
+
required: true
|
|
188
|
+
},
|
|
189
|
+
policyUrl: {
|
|
190
|
+
type: String,
|
|
191
|
+
unique: true,
|
|
192
|
+
required: false
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
onesignalAppId: {
|
|
196
|
+
type: String,
|
|
197
|
+
unique: true,
|
|
198
|
+
required: true
|
|
199
|
+
},
|
|
200
|
+
onesignalRestApiKey: {
|
|
201
|
+
type: String,
|
|
202
|
+
unique: true,
|
|
203
|
+
required: true
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
developerName: {
|
|
207
|
+
type: String,
|
|
208
|
+
unique: true,
|
|
209
|
+
required: true
|
|
210
|
+
},
|
|
211
|
+
developerEmail: {
|
|
212
|
+
type: String,
|
|
213
|
+
unique: true,
|
|
214
|
+
required: true
|
|
215
|
+
},
|
|
216
|
+
developerOrganization: {
|
|
217
|
+
type: String,
|
|
218
|
+
unique: true,
|
|
219
|
+
required: true
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
generationOptions: {
|
|
224
|
+
splashActivityClassName: {
|
|
225
|
+
type: String,
|
|
226
|
+
required: true
|
|
227
|
+
},
|
|
228
|
+
mainActivityClassName: {
|
|
229
|
+
type: String,
|
|
230
|
+
required: true
|
|
231
|
+
},
|
|
232
|
+
linkName: {
|
|
233
|
+
type: String,
|
|
234
|
+
required: true
|
|
235
|
+
},
|
|
236
|
+
savedName: {
|
|
237
|
+
type: String,
|
|
238
|
+
required: true
|
|
239
|
+
},
|
|
240
|
+
paranoidSeed: {
|
|
241
|
+
type: Number,
|
|
242
|
+
required: true,
|
|
243
|
+
unique: true
|
|
244
|
+
},
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
export async function updateSchemaAndMoveValue(model: Model<IFlashAppUpdated>): Promise<void> {
|
|
249
|
+
const aggregationPipeline = [
|
|
250
|
+
{
|
|
251
|
+
$project: {
|
|
252
|
+
pastebinUrl: 0,
|
|
253
|
+
email: 0,
|
|
254
|
+
onesignalAppId: { $toString: '$onesignalAppId' },
|
|
255
|
+
onesignalRestApiKey: { $toString: '$onesignalRestApiKey' },
|
|
256
|
+
generationOptions: {
|
|
257
|
+
keyFileName: 0,
|
|
258
|
+
keyDeveloperName: 0,
|
|
259
|
+
keyDeveloperOrganization: 0,
|
|
260
|
+
keyCountryCode: 0,
|
|
261
|
+
keyCity: 0,
|
|
262
|
+
keyAlias: 0,
|
|
263
|
+
keyPassword: 0
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
$addFields: {
|
|
269
|
+
plugUrl: `$pastebinUrl`,
|
|
270
|
+
reservePlugUrl: null,
|
|
271
|
+
developerName: '$email',
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
];
|
|
275
|
+
|
|
276
|
+
// Define the update operation to apply the new schema with the updated field
|
|
277
|
+
const updateOperation: UpdateQuery<IFlashAppUpdated> = {
|
|
278
|
+
$set: {
|
|
279
|
+
plugUrl: '$pastebinUrl',
|
|
280
|
+
reservePlugUrl: null,
|
|
281
|
+
policyUrl: null,
|
|
282
|
+
developerName: '$generationOptions.keyDeveloperName',
|
|
283
|
+
developerEmail: '$email',
|
|
284
|
+
developerOrganization: '$generationOptions.keyDeveloperOrganization',
|
|
285
|
+
},
|
|
286
|
+
$unset: {
|
|
287
|
+
'email': true,
|
|
288
|
+
'pastebinUrl': true,
|
|
289
|
+
'generationOptions.keyFileName': true,
|
|
290
|
+
'generationOptions.keyDeveloperName': true,
|
|
291
|
+
'generationOptions.keyDeveloperOrganization': true,
|
|
292
|
+
'generationOptions.keyCountryCode': true,
|
|
293
|
+
'generationOptions.keyCity': true,
|
|
294
|
+
'generationOptions.keyAlias': 0,
|
|
295
|
+
'generationOptions.keyPassword': 0
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
await model.updateMany({}, [
|
|
300
|
+
...aggregationPipeline,
|
|
301
|
+
updateOperation
|
|
302
|
+
]);
|
|
303
|
+
}
|
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 } from "./flash/flash-app"
|
|
22
|
+
export { IFlashApp as IFlashAppOld, IFlashAppUpdated as IFlashApp, FlashAppSchema as FlashAppSchemaOld, FlashAppSchemaUpdated as FlashAppSchema, updateSchemaAndMoveValue } from "./flash/flash-app"
|
|
23
23
|
export { IFlashAppListItem } from "./flash/flash-app-list-item"
|
|
24
24
|
|
|
25
25
|
export * as ASOConfigFetch from "./aso/usage-logs/aso-config-fetch-entry"
|
|
@@ -28,9 +28,10 @@ export { IPanelUser, PanelUserAccessScope, PanelUserSchema } from "./panel/user"
|
|
|
28
28
|
export { IAuthToken } from "./panel/auth"
|
|
29
29
|
export { IUpsertFlashAppRequest, IUpsertFlashAppResponse } from "./panel/flash/create-flash-app-request"
|
|
30
30
|
|
|
31
|
-
export {IGradient, IStroke, IShape, ShapeDiv} from "./shared/shape"
|
|
32
|
-
export {ColoredText, IColoredTextProps} from "./shared/colored-text"
|
|
33
|
-
export {IOfferWallAuthConfig} from "./aso/offerwall/auth/offerwall-auth-config"
|
|
34
|
-
export {IOfferWallAuthLocalization} from "./aso/offerwall/auth/offerwall-auth-localization"
|
|
35
|
-
export {IOfferWallAuthSubmitRequest} from "./aso/offerwall/auth/offerwall-auth-submit-request"
|
|
36
|
-
export {IOfferWallAuthSubmitResponse} from "./aso/offerwall/auth/offerwall-auth-submit-response"
|
|
31
|
+
export { IGradient, IStroke, IShape, ShapeDiv } from "./shared/shape"
|
|
32
|
+
export { ColoredText, IColoredTextProps } from "./shared/colored-text"
|
|
33
|
+
export { IOfferWallAuthConfig } from "./aso/offerwall/auth/offerwall-auth-config"
|
|
34
|
+
export { IOfferWallAuthLocalization } from "./aso/offerwall/auth/offerwall-auth-localization"
|
|
35
|
+
export { IOfferWallAuthSubmitRequest } from "./aso/offerwall/auth/offerwall-auth-submit-request"
|
|
36
|
+
export { IOfferWallAuthSubmitResponse } from "./aso/offerwall/auth/offerwall-auth-submit-response"
|
|
37
|
+
export { KeitaroService } from "./network/keitaro/keitaro-service"
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { IOffer } from "../../shared/offer"
|
|
2
|
+
import keitaroApi from "./http"
|
|
3
|
+
|
|
4
|
+
export interface IKeitaroStream {
|
|
5
|
+
id: number;
|
|
6
|
+
name: string;
|
|
7
|
+
campaign_id: number;
|
|
8
|
+
offer_id: number;
|
|
9
|
+
url: string;
|
|
10
|
+
redirect_url: string;
|
|
11
|
+
traffic_type: string;
|
|
12
|
+
state: string;
|
|
13
|
+
filters: any[]
|
|
14
|
+
position: number;
|
|
15
|
+
offers: any[],
|
|
16
|
+
schema: string,
|
|
17
|
+
type: string,
|
|
18
|
+
action_type: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface IKeitaroCampaign {
|
|
22
|
+
id: number;
|
|
23
|
+
name: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function getStreamsByCampaignId(campaignId: number): Promise<IKeitaroStream[]> {
|
|
27
|
+
const { data: streams } = await keitaroApi.get<IKeitaroStream[]>(`campaigns/${campaignId}/streams`);
|
|
28
|
+
|
|
29
|
+
return streams
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function getAllCampaigns(): Promise<IKeitaroCampaign[]> {
|
|
33
|
+
const { data: campaigns } = await keitaroApi.get<IKeitaroCampaign[]>('campaigns');
|
|
34
|
+
``
|
|
35
|
+
return campaigns
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function cloneStreams(originalCampaignId: number, streamPositionsToClone: number[], campaignRegExp: RegExp): Promise<void> {
|
|
39
|
+
// Get the original campaign's streams
|
|
40
|
+
const originalStreams = await getStreamsByCampaignId(originalCampaignId)
|
|
41
|
+
|
|
42
|
+
// Filter the original streams by the given stream positions to clone
|
|
43
|
+
const streamsToClone = originalStreams.filter(stream => streamPositionsToClone.includes(stream.position));
|
|
44
|
+
|
|
45
|
+
// Get a list of all campaigns
|
|
46
|
+
const allCampaigns = await getAllCampaigns()
|
|
47
|
+
|
|
48
|
+
// Filter the campaigns by the given RegExp
|
|
49
|
+
const matchingCampaigns = allCampaigns.filter(campaign => campaignRegExp.exec(campaign.name) && campaign.id != originalCampaignId);
|
|
50
|
+
// console.log(matchingCampaigns)
|
|
51
|
+
|
|
52
|
+
// For each matching campaign, clone the streams
|
|
53
|
+
for (const matchingCampaign of matchingCampaigns) {
|
|
54
|
+
for (const streamToClone of streamsToClone) {
|
|
55
|
+
await keitaroApi.post('streams', {
|
|
56
|
+
name: streamToClone.name,
|
|
57
|
+
campaign_id: matchingCampaign.id,
|
|
58
|
+
schema: streamToClone.schema,
|
|
59
|
+
type: streamToClone.type,
|
|
60
|
+
action_type: streamToClone.action_type,
|
|
61
|
+
weight: 100,
|
|
62
|
+
offers: streamToClone.offers.map((offer) => {
|
|
63
|
+
return {
|
|
64
|
+
offer_id: offer.offer_id,
|
|
65
|
+
share: 100
|
|
66
|
+
}
|
|
67
|
+
}),
|
|
68
|
+
filters: streamToClone.filters.map((filter) => {
|
|
69
|
+
return {
|
|
70
|
+
name: filter.name,
|
|
71
|
+
mode: filter.mode,
|
|
72
|
+
payload: filter.payload
|
|
73
|
+
}
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function createStreamForMatchingCampaigns(streamPartialPayload: any, offerId: string, campaignRegExp: RegExp) {
|
|
81
|
+
// Get a list of all campaigns
|
|
82
|
+
const allCampaigns = await getAllCampaigns()
|
|
83
|
+
|
|
84
|
+
// Filter the campaigns by the given RegExp
|
|
85
|
+
const matchingCampaigns = allCampaigns.filter(campaign => campaignRegExp.exec(campaign.name));
|
|
86
|
+
// console.log(matchingCampaigns)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
// For each matching campaign, clone the streams
|
|
90
|
+
for (const matchingCampaign of matchingCampaigns) {
|
|
91
|
+
let streams = await getStreamsByCampaignId(matchingCampaign.id)
|
|
92
|
+
|
|
93
|
+
let identicalStream = streams.find((stream) => stream.name.includes(offerId))
|
|
94
|
+
|
|
95
|
+
if (identicalStream) {
|
|
96
|
+
await keitaroApi.put(`streams/${identicalStream.id}`, {
|
|
97
|
+
campaign_id: matchingCampaign.id,
|
|
98
|
+
...streamPartialPayload
|
|
99
|
+
});
|
|
100
|
+
} else {
|
|
101
|
+
await keitaroApi.post('streams', {
|
|
102
|
+
campaign_id: matchingCampaign.id,
|
|
103
|
+
...streamPartialPayload
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async function getAllOffers(): Promise<any[]> {
|
|
110
|
+
const { data: offers } = await keitaroApi.get<any[]>('offers')
|
|
111
|
+
|
|
112
|
+
return offers
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async function getOfferByKeitaroId(id: number): Promise<any> {
|
|
116
|
+
const { data: offer } = await keitaroApi.get<any>(`offers/${id}`)
|
|
117
|
+
|
|
118
|
+
return offer
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function createStreamPartialPayload(keitaroOfferId: number, offerName: string, offerId: string, offerGeo: string) {
|
|
122
|
+
return {
|
|
123
|
+
name: `${offerName} ${offerGeo} (${offerId})`,
|
|
124
|
+
schema: "landings",
|
|
125
|
+
type: "regular",
|
|
126
|
+
action_type: "http",
|
|
127
|
+
weight: 100,
|
|
128
|
+
offers: [{
|
|
129
|
+
offer_id: keitaroOfferId,
|
|
130
|
+
share: 100,
|
|
131
|
+
state: "active"
|
|
132
|
+
}],
|
|
133
|
+
filters: [{
|
|
134
|
+
name: "sub_id_15",
|
|
135
|
+
mode: "accept",
|
|
136
|
+
payload: [offerId]
|
|
137
|
+
}],
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async function addOfferToKeitaro(offer: IOffer, affiliateId: number, link: string, groupId?: number) {
|
|
142
|
+
// TODO look if offer already exists by offer.name
|
|
143
|
+
let allOffers = await getAllOffers()
|
|
144
|
+
let identicalOffer = allOffers.find((o) => { return o.name.includes(offer.name) })
|
|
145
|
+
|
|
146
|
+
let keitaroOfferId
|
|
147
|
+
if (identicalOffer) {
|
|
148
|
+
keitaroOfferId = identicalOffer.id
|
|
149
|
+
} else {
|
|
150
|
+
let offerPayload = {
|
|
151
|
+
name: `${offer.caption} ${offer.geo} (${offer.name})`,
|
|
152
|
+
group_id: groupId || 1,
|
|
153
|
+
action_payload: link,
|
|
154
|
+
affiliate_network_id: affiliateId,
|
|
155
|
+
country: [offer.geo],
|
|
156
|
+
action_type: "http",
|
|
157
|
+
offer_type: "external",
|
|
158
|
+
payout_auto: true,
|
|
159
|
+
payout_upsell: true,
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const { data: keitaroOffer } = await keitaroApi.post(`offers`, offerPayload);
|
|
163
|
+
|
|
164
|
+
keitaroOfferId = keitaroOffer.id
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
let streamPartialPayload = createStreamPartialPayload(keitaroOfferId, offer.caption, offer.name, offer.geo)
|
|
168
|
+
|
|
169
|
+
await createStreamForMatchingCampaigns(streamPartialPayload, offer.name, /^(FA #|A #)/)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export const KeitaroService = {
|
|
173
|
+
getStreamsByCampaignId, getAllCampaigns, getAllOffers, cloneStreams, addOfferToKeitaro, getOfferByKeitaroId
|
|
174
|
+
}
|