@bprotsyk/aso-core 1.2.68 → 1.2.69

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.
@@ -1,15 +1,26 @@
1
1
  import { FlashAppType } from "./flash-app-type";
2
- import mongoose, { Model } from "mongoose";
3
- export interface IFlashApp {
2
+ import mongoose, { Document, Model } from "mongoose";
3
+ export declare enum FlashAppPlugStatus {
4
+ DISABLED = 0,
5
+ TEST_MODE = 1,
6
+ ENABLED = 2
7
+ }
8
+ export interface IFlashApp extends Document {
4
9
  id: number;
5
10
  name: string;
6
11
  trackingUrl?: string;
7
12
  bundle: string;
8
13
  pushesEnabled?: boolean;
9
- plugUrl: string;
14
+ plugId: string;
10
15
  plugType: PlugType;
11
- reservePlugUrl?: string;
16
+ plugContent: string;
17
+ plugStatus: FlashAppPlugStatus;
18
+ plugAccountId: number;
19
+ reservePlugId?: string;
12
20
  reservePlugType?: PlugType;
21
+ reservePlugContent?: string;
22
+ reservePlugStatus?: FlashAppPlugStatus;
23
+ reservePlugAccountId: number;
13
24
  policyUrl?: string;
14
25
  type: FlashAppType;
15
26
  geos: string;
@@ -29,14 +40,16 @@ export interface IAppGenerationOptions {
29
40
  paranoidSeed: number;
30
41
  }
31
42
  export interface IAppKeitaroData {
32
- redirectCampaignId: string;
43
+ redirectCampaignId: number;
33
44
  redirectCampaignName: string;
34
- trackingCampaignId: string;
45
+ redirectDomainId: number;
46
+ redirectDomainName: string;
47
+ trackingCampaignId: number;
35
48
  trackingCampaignName: string;
49
+ trackingDomainId: number;
50
+ trackingDomainName: string;
36
51
  clickIdParameterName: string;
37
52
  offerIdParameterName: string;
38
- domainId: string;
39
- domainName: string;
40
53
  }
41
54
  export declare enum PlugType {
42
55
  PASTEBIN = "PASTEBIN",
@@ -48,7 +61,7 @@ export declare const FlashAppSchema: mongoose.Schema<any, mongoose.Model<any, an
48
61
  id: number;
49
62
  bundle: string;
50
63
  trackingUrl: string;
51
- plugUrl: string;
64
+ plugId: string;
52
65
  plugType: string;
53
66
  geos: string;
54
67
  onesignalAppId: string;
@@ -58,8 +71,14 @@ export declare const FlashAppSchema: mongoose.Schema<any, mongoose.Model<any, an
58
71
  developerOrganization: string;
59
72
  name?: string | undefined;
60
73
  pushesEnabled?: boolean | undefined;
61
- reservePlugUrl?: string | undefined;
74
+ plugAccountId?: number | undefined;
75
+ reservePlugAccountId?: number | undefined;
76
+ plugContent?: string | undefined;
77
+ plugStatus?: string | undefined;
78
+ reservePlugID?: string | undefined;
62
79
  reservePlugType?: string | undefined;
80
+ reservePlugContent?: string | undefined;
81
+ reservePlugStatus?: string | undefined;
63
82
  policyUrl?: string | undefined;
64
83
  generationOptions?: {
65
84
  splashActivityClassName: string;
@@ -69,12 +88,14 @@ export declare const FlashAppSchema: mongoose.Schema<any, mongoose.Model<any, an
69
88
  paranoidSeed: number;
70
89
  } | undefined;
71
90
  keitaroData?: {
72
- redirectCampaignId: string;
91
+ redirectCampaignId: number;
73
92
  redirectCampaignName: string;
74
- trackingCampaignId: string;
93
+ redirectDomainId: number;
94
+ redirectDomainName: string;
95
+ trackingCampaignId: number;
75
96
  trackingCampaignName: string;
76
- domainId: string;
77
- domainName: string;
97
+ trackingDomainId: number;
98
+ trackingDomainName: string;
78
99
  clickIdParameterName?: string | undefined;
79
100
  offerIdParameterName?: string | undefined;
80
101
  } | undefined;
@@ -1,9 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateSchemaAndMoveValue = exports.FlashAppSchema = exports.PlugType = void 0;
3
+ exports.updateSchemaAndMoveValue = exports.FlashAppSchema = exports.PlugType = exports.FlashAppPlugStatus = void 0;
4
4
  const flash_app_type_1 = require("./flash-app-type");
5
5
  const mongoose_1 = require("mongoose");
6
6
  const util = require("util");
7
+ var FlashAppPlugStatus;
8
+ (function (FlashAppPlugStatus) {
9
+ FlashAppPlugStatus[FlashAppPlugStatus["DISABLED"] = 0] = "DISABLED";
10
+ FlashAppPlugStatus[FlashAppPlugStatus["TEST_MODE"] = 1] = "TEST_MODE";
11
+ FlashAppPlugStatus[FlashAppPlugStatus["ENABLED"] = 2] = "ENABLED";
12
+ })(FlashAppPlugStatus = exports.FlashAppPlugStatus || (exports.FlashAppPlugStatus = {}));
7
13
  var PlugType;
8
14
  (function (PlugType) {
9
15
  PlugType["PASTEBIN"] = "PASTEBIN";
@@ -27,7 +33,7 @@ exports.FlashAppSchema = new mongoose_1.Schema({
27
33
  default: null
28
34
  },
29
35
  pushesEnabled: Boolean,
30
- plugUrl: {
36
+ plugId: {
31
37
  type: String,
32
38
  // unique: true,
33
39
  required: true
@@ -38,7 +44,18 @@ exports.FlashAppSchema = new mongoose_1.Schema({
38
44
  default: PlugType.PASTEBIN,
39
45
  required: true
40
46
  },
41
- reservePlugUrl: {
47
+ plugContent: {
48
+ type: String,
49
+ required: false
50
+ },
51
+ plugStatus: {
52
+ type: String,
53
+ enum: PlugType,
54
+ default: FlashAppPlugStatus.DISABLED,
55
+ required: false
56
+ },
57
+ plugAccountId: Number,
58
+ reservePlugID: {
42
59
  type: String,
43
60
  // unique: true,
44
61
  required: false
@@ -49,6 +66,17 @@ exports.FlashAppSchema = new mongoose_1.Schema({
49
66
  default: PlugType.GIST,
50
67
  required: false
51
68
  },
69
+ reservePlugContent: {
70
+ type: String,
71
+ required: false
72
+ },
73
+ reservePlugStatus: {
74
+ type: String,
75
+ enum: PlugType,
76
+ default: FlashAppPlugStatus.DISABLED,
77
+ required: false
78
+ },
79
+ reservePlugAccountId: Number,
52
80
  policyUrl: {
53
81
  type: String,
54
82
  // unique: true,
@@ -111,10 +139,10 @@ exports.FlashAppSchema = new mongoose_1.Schema({
111
139
  },
112
140
  keitaroData: {
113
141
  redirectCampaignId: {
114
- type: String,
142
+ type: Number,
115
143
  // unique: true,
116
144
  required: true,
117
- default: "none"
145
+ default: 0
118
146
  },
119
147
  redirectCampaignName: {
120
148
  type: String,
@@ -122,30 +150,40 @@ exports.FlashAppSchema = new mongoose_1.Schema({
122
150
  required: true,
123
151
  default: "none"
124
152
  },
125
- trackingCampaignId: {
153
+ redirectDomainId: {
154
+ type: Number,
155
+ required: true,
156
+ default: 0
157
+ },
158
+ redirectDomainName: {
126
159
  type: String,
127
- // unique: true,
128
160
  required: true,
129
161
  default: "none"
130
162
  },
163
+ trackingCampaignId: {
164
+ type: Number,
165
+ // unique: true,
166
+ required: true,
167
+ default: 0
168
+ },
131
169
  trackingCampaignName: {
132
170
  type: String,
133
171
  // unique: true,
134
172
  required: true,
135
173
  default: "none"
136
174
  },
137
- clickIdParameterName: String,
138
- offerIdParameterName: String,
139
- domainId: {
140
- type: String,
175
+ trackingDomainId: {
176
+ type: Number,
141
177
  required: true,
142
- default: "none"
178
+ default: 0
143
179
  },
144
- domainName: {
180
+ trackingDomainName: {
145
181
  type: String,
146
182
  required: true,
147
183
  default: "none"
148
184
  },
185
+ clickIdParameterName: String,
186
+ offerIdParameterName: String,
149
187
  }
150
188
  });
151
189
  // TODO app type (casino / fin)
@@ -3,15 +3,20 @@ export interface IKeitaroCampaign {
3
3
  alias: string;
4
4
  name: string;
5
5
  type: string;
6
+ uniqueness_method: string;
7
+ cookies_ttl: number;
6
8
  is_paused: boolean;
7
9
  state: string;
8
10
  cost_type: string;
9
- cost_value: string;
11
+ cost_value: number;
12
+ cost_currency: string;
10
13
  group_id: number;
11
14
  traffic_source_id: number;
12
15
  cost_auto: boolean;
13
16
  domain_id: number;
14
17
  domain: string;
18
+ uniqueness_use_cookies: boolean;
19
+ traffic_loss: number;
15
20
  parameters: IKeitaroCampaignParameters;
16
21
  }
17
22
  export interface IKeitaroCampaignParameters {
@@ -7,7 +7,11 @@ export interface IKeitaroStream {
7
7
  redirect_url: string;
8
8
  traffic_type: string;
9
9
  state: string;
10
+ action_payload: string;
10
11
  filters: any[];
12
+ filter_or: boolean;
13
+ collect_clicks: boolean;
14
+ weight: number;
11
15
  position: number;
12
16
  offers: any[];
13
17
  schema: string;
@@ -1,18 +1,32 @@
1
- import { IKeitaroStream } from "keitaro/keitaro-stream";
1
+ import { IKeitaroStream } from "../../keitaro/keitaro-stream";
2
2
  import { IOffer } from "../../shared/offer";
3
- import { IKeitaroCampaign } from "keitaro/keitaro-campaign";
3
+ import { IKeitaroCampaign } from "../../keitaro/keitaro-campaign";
4
+ import { IKeitaroDomain } from "../../keitaro/keitaro-domain";
5
+ import { IFlashApp } from "../../flash/flash-app";
4
6
  declare function getStreamsByCampaignId(campaignId: number): Promise<IKeitaroStream[]>;
5
7
  declare function getAllCampaigns(): Promise<IKeitaroCampaign[]>;
6
8
  declare function cloneStreams(originalCampaignId: number, streamPositionsToClone: number[], campaignRegExp: RegExp): Promise<void>;
9
+ declare function updateCampaign(id: number, payload: Partial<IKeitaroCampaign>): Promise<void>;
7
10
  declare function getAllOffers(): Promise<any[]>;
8
11
  declare function getOfferByKeitaroId(id: number): Promise<any>;
9
12
  declare function addOfferToKeitaro(offer: IOffer, affiliateId: number, link: string, groupId?: number): Promise<void>;
13
+ declare function createCampaign(campaignData: Partial<IKeitaroCampaign>): Promise<IKeitaroCampaign>;
14
+ declare function getCampaignById(id: number): Promise<IKeitaroCampaign>;
15
+ export declare function upsertStreamToCampaign(campaign: IKeitaroCampaign, stream: Partial<IKeitaroStream>): Promise<void>;
16
+ declare function cloneOWCampaign(app: IFlashApp): Promise<IKeitaroCampaign>;
17
+ declare function getDomains(onlyActive?: boolean): Promise<IKeitaroDomain[]>;
10
18
  export declare const KeitaroService: {
11
19
  getStreamsByCampaignId: typeof getStreamsByCampaignId;
20
+ updateCampaign: typeof updateCampaign;
12
21
  getAllCampaigns: typeof getAllCampaigns;
13
22
  getAllOffers: typeof getAllOffers;
14
23
  cloneStreams: typeof cloneStreams;
15
24
  addOfferToKeitaro: typeof addOfferToKeitaro;
16
25
  getOfferByKeitaroId: typeof getOfferByKeitaroId;
26
+ getDomains: typeof getDomains;
27
+ createCampaign: typeof createCampaign;
28
+ getCampaignById: typeof getCampaignById;
29
+ upsertStreamToCampaign: typeof upsertStreamToCampaign;
30
+ cloneOWCampaign: typeof cloneOWCampaign;
17
31
  };
18
32
  export {};
@@ -3,15 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.KeitaroService = void 0;
6
+ exports.KeitaroService = exports.upsertStreamToCampaign = void 0;
7
7
  const http_1 = __importDefault(require("./http"));
8
+ const keitaro_utils_1 = require("../../utils/keitaro-utils");
8
9
  async function getStreamsByCampaignId(campaignId) {
9
10
  const { data: streams } = await http_1.default.get(`campaigns/${campaignId}/streams`);
10
11
  return streams;
11
12
  }
12
13
  async function getAllCampaigns() {
13
14
  const { data: campaigns } = await http_1.default.get('campaigns');
14
- ``;
15
15
  return campaigns;
16
16
  }
17
17
  async function cloneStreams(originalCampaignId, streamPositionsToClone, campaignRegExp) {
@@ -51,6 +51,9 @@ async function cloneStreams(originalCampaignId, streamPositionsToClone, campaign
51
51
  }
52
52
  }
53
53
  }
54
+ async function updateCampaign(id, payload) {
55
+ await http_1.default.put(`campaigns/${id}`, payload);
56
+ }
54
57
  async function createStreamForMatchingCampaigns(streamPartialPayload, offerId, campaignRegExp) {
55
58
  // Get a list of all campaigns
56
59
  const allCampaigns = await getAllCampaigns();
@@ -128,18 +131,61 @@ async function addOfferToKeitaro(offer, affiliateId, link, groupId) {
128
131
  let streamPartialPayload = createStreamPartialPayload(keitaroOfferId, offer.caption, offer.name, offer.geo);
129
132
  await createStreamForMatchingCampaigns(streamPartialPayload, offer.name, /^(FA #|A #)/);
130
133
  }
131
- // Domain
132
- async function getDomains() {
133
- try {
134
- const response = await http_1.default.get(`/domains`);
135
- if (response.status == 200) {
136
- return response.data;
137
- }
134
+ async function createCampaign(campaignData) {
135
+ let { data: campaign } = await http_1.default.post(`/campaigns`, campaignData);
136
+ return campaign;
137
+ }
138
+ async function getCampaignById(id) {
139
+ const { data: campaign } = await http_1.default.get(`/campaigns/${id}`);
140
+ return campaign;
141
+ }
142
+ async function upsertStreamToCampaign(campaign, stream) {
143
+ let streams = await getStreamsByCampaignId(campaign.id);
144
+ let identicalStream = streams.find((s) => stream.id == s.id);
145
+ if (identicalStream) {
146
+ console.log(`Found identical! Name: ${stream.name}`);
147
+ await http_1.default.put(`streams/${identicalStream.id}`, {
148
+ campaign_id: campaign.id,
149
+ ...stream
150
+ });
138
151
  }
139
- catch (e) {
152
+ else {
153
+ await http_1.default.post('streams', {
154
+ campaign_id: campaign.id,
155
+ ...stream
156
+ });
140
157
  }
141
- return null;
158
+ }
159
+ exports.upsertStreamToCampaign = upsertStreamToCampaign;
160
+ async function cloneOWCampaign(app) {
161
+ let name = `FA #${app.id} (${app.bundle})`;
162
+ let allCampaigns = await getAllCampaigns();
163
+ let matchingCampaign = allCampaigns.filter((c) => c.name.includes(`FA #${app.id}`));
164
+ if (matchingCampaign.length > 0)
165
+ return matchingCampaign[0];
166
+ const { data: campaigns } = await http_1.default.post(`/campaigns/2448/clone`);
167
+ if (campaigns.length == 0)
168
+ throw Error("Campaign cloning falied");
169
+ let clonedCampaign = campaigns[0];
170
+ let allDomains = await exports.KeitaroService.getDomains(true);
171
+ if (!allDomains) {
172
+ throw Error(`Failed to get all domains list`);
173
+ }
174
+ const domain = allDomains[Math.floor(Math.random() * allDomains.length)];
175
+ let payload = {
176
+ name: name,
177
+ traffic_source_id: keitaro_utils_1.TRAFFIC_SOURCE_ID_FLASH_AI,
178
+ domain_id: domain.id,
179
+ parameters: (0, keitaro_utils_1.prepareOWCampaignParameters)(app)
180
+ };
181
+ const { data: campaign } = await http_1.default.put(`/campaigns/${clonedCampaign.id}`, payload);
182
+ return campaign;
183
+ }
184
+ // Domain
185
+ async function getDomains(onlyActive) {
186
+ const { data: domains } = await http_1.default.get(`/domains`);
187
+ return onlyActive ? domains.filter((d) => d.network_status == "active") : domains;
142
188
  }
143
189
  exports.KeitaroService = {
144
- getStreamsByCampaignId, getAllCampaigns, getAllOffers, cloneStreams, addOfferToKeitaro, getOfferByKeitaroId
190
+ getStreamsByCampaignId, updateCampaign, getAllCampaigns, getAllOffers, cloneStreams, addOfferToKeitaro, getOfferByKeitaroId, getDomains, createCampaign, getCampaignById, upsertStreamToCampaign, cloneOWCampaign
145
191
  };
@@ -0,0 +1,17 @@
1
+ import { FlashAppPlugStatus } from "flash/flash-app";
2
+ export type TrackingMap = {
3
+ [key: string]: TrackingMapValue | undefined;
4
+ };
5
+ type TrackingMapValue = {
6
+ trackingUrl: string | undefined;
7
+ };
8
+ export type PasteMap = {
9
+ [key: string]: PasteMapValue;
10
+ };
11
+ type PasteMapValue = {
12
+ content: string;
13
+ paste_id: string;
14
+ status: FlashAppPlugStatus;
15
+ accountId: string;
16
+ };
17
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ import { IKeitaroStream } from "../keitaro/keitaro-stream";
2
+ import { IFlashApp } from "../flash/flash-app";
3
+ import { IKeitaroCampaign, IKeitaroCampaignParameters } from "../keitaro/keitaro-campaign";
4
+ export declare const TRAFFIC_SOURCE_ID_FLASH_AI = 22;
5
+ export declare let addGeosToAllRedirectCampaigns: (geosToAdd: string) => Promise<void>;
6
+ export declare let removeGeosFromAllRedirectCampaigns: (geoToRemove: string) => Promise<void>;
7
+ export declare let createOrFindFlashRedirectCampaign: (app: IFlashApp) => Promise<IKeitaroCampaign>;
8
+ export declare let prepareOWCampaignParameters: (app: IFlashApp) => IKeitaroCampaignParameters;
9
+ export declare function createOWStreamPartialPayload(app: IFlashApp): Partial<IKeitaroStream>;
10
+ export declare function createFlashCampaigns(app: IFlashApp): Promise<void>;