@bprotsyk/aso-core 2.1.223 → 2.1.225

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bprotsyk/aso-core",
3
- "version": "2.1.223",
3
+ "version": "2.1.225",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "scripts": {
package/src/app/app.ts CHANGED
@@ -1,341 +1,350 @@
1
- import { Document, Schema } from "mongoose";
1
+ import mongoose, { Document, Schema } from "mongoose";
2
+ import { AppType } from "./app-type";
2
3
 
3
- export interface IAppsflyerPostback {
4
- campaign_id: number
5
- id: number
6
- method: "GET" | "POST"
7
- statuses: string[]
8
- url: string
9
- notes?: string
10
- }
4
+ // ─── Enums ────────────────────────────────────────────────────────────────────
11
5
 
12
- // Integration types - OFFERWALL is default
13
- export enum IntegrationType {
14
- OFFERWALL = "offerwall",
15
- DIRECT = "direct"
6
+ export enum AppMode {
7
+ OFFERWALL = 'offerwall',
8
+ WEBVIEW = 'webview',
16
9
  }
17
10
 
18
- // @deprecated - use IntegrationType instead
19
- export enum IntegrationVersion {
20
- OFFERWALL = "offerwall",
21
- DIRECT = "direct",
22
- WEB_DIRECT = "web_direct",
23
- NONE = "none",
24
- POLICY = "policy",
25
- OFFER_STUB = "offer_stub",
26
- WEB = "web",
27
- BANNER = "banner",
28
- PWA = "pwa"
11
+ export enum AppStatus {
12
+ ARCHIVED = "ARCHIVED",
13
+ IN_DEVELOPMENT = "IN_DEVELOPMENT",
14
+ READY = "READY",
15
+ DISABLED = "DISABLED"
29
16
  }
30
17
 
31
- // @deprecated - Platform enum (no longer used)
32
18
  export enum EPlatform {
33
- GENERAL = "@",
34
- SAMSUNG = "samsung"
19
+ GENERAL = '@',
20
+ HUAWEI = 'hw',
21
+ SAMSUNG = 'sm',
22
+ ruSTORE = 'rs',
23
+ XIAOMI = 'xm',
24
+ APKPURE = 'ap',
25
+ TELEGRAM = 'tg',
26
+ AMAZON = 'am',
27
+ TEST = 'test'
35
28
  }
36
29
 
37
- // @deprecated - Direct type enum
38
30
  export enum EDirectType {
39
- ELTRAFICO = "eltrafico",
40
- TRAFFLE = "traffle",
41
- KEITARO_OFFER = "keitaro_offer",
42
- OFFER_DIRECT = "offer_direct"
31
+ KEITARO_OFFER = 'keitaroOffer',
32
+ OFFER_DIRECT = 'offerDirect'
43
33
  }
44
34
 
45
- // @deprecated - Platform params (use offerwallCampaign/directCampaign instead)
46
- export interface IPlatformParams {
47
- enabled?: boolean
48
- proxied?: boolean
49
- params?: any
50
- newPlatform?: boolean
51
- direct?: {
52
- keitaroData?: IAppKeitaroData | boolean
53
- addDefaultStreams?: boolean
54
- directType?: EDirectType | string
55
- enabled?: boolean
56
- trackingUrl?: string
57
- }
58
- offerwall?: {
59
- keitaroData?: IAppKeitaroData | boolean
60
- }
61
- appsflyerParams?: any
62
- keitaroData?: IAppKeitaroData | boolean
63
- metricaParams?: any
64
- adjustParams?: any
65
- geo?: string
35
+ export enum PlugType {
36
+ PASTEBIN = "PASTEBIN",
37
+ GIST = "GIST",
38
+ OTHER = "OTHER"
66
39
  }
67
40
 
68
- // @deprecated - Response interface
69
- export interface IUpsertAppResponse {
70
- success: boolean
71
- error?: string
72
- app?: IApp
41
+ export enum IntegrationVersion {
42
+ NONE = "MVVM",
43
+ POLICY = "POLICY",
44
+ OFFER_STUB = "OFFER_STUB",
45
+ WEB = "WEB",
46
+ WEB_DIRECT = "WEB_DIRECT",
47
+ BANNER = "BANNER",
48
+ PWA = "PWA",
49
+ OFFERWALL = "OFFERWALL"
73
50
  }
74
51
 
75
- // @deprecated - Constructor types
76
- export enum AlternativeLayoutType { DEFAULT = "default" }
77
- export enum AlternativeLogicType { DEFAULT = "default" }
78
- export enum AlternativeNavigation { DEFAULT = "default" }
79
- export enum AlternativeNetworkTool { DEFAULT = "default" }
80
- export enum AlternativeOnActivityResult { DEFAULT = "default" }
81
- export enum AlternativeOnBackPressed { DEFAULT = "default" }
82
- export enum AlternativeSourceType { DEFAULT = "default" }
83
- export enum AlternativeStorageType { DEFAULT = "default" }
84
-
85
- // Upsert request interface
86
- export interface IUpsertAppRequest {
87
- id: number
88
- enabled?: boolean
89
- bundle?: string
90
- name?: string
91
-
92
- // Integration type - offerwall or direct
93
- integrationType?: IntegrationType
94
-
95
- // Keitaro campaigns
96
- offerwallCampaign?: IAppKeitaroData | null
97
- directCampaign?: IAppKeitaroData | null
98
-
99
- domainParams?: Partial<IDomainParams>
100
- policyPath?: string
101
- status?: AppStatus
102
- file?: any
103
-
104
- // @deprecated fields
105
- keitaroData?: any
106
- bannerParams?: any
107
- offersStubParams?: any
108
- platforms?: { [key: string]: IPlatformParams }
109
- ech?: any
110
- appmetricaApiKey?: string
111
- appmetricaAppId?: string | number
112
- integrationVersion?: IntegrationVersion
113
- geos?: string[]
52
+ // ─── Attribution interfaces ───────────────────────────────────────────────────
53
+
54
+ export interface IAdjustEventIds {
55
+ lead: string
56
+ hold: string
57
+ sale: string
58
+ rejected: string
114
59
  }
115
60
 
116
- // Campaign IDs for cloning
117
- export const OFFERWALL_TEMPLATE_CAMPAIGN_ID = 3497
118
- export const DIRECT_TEMPLATE_CAMPAIGN_ID = 3499
119
- export const DEFENCE_CAMPAIGN_ID = 3498
120
- export const DEFENCE_CAMPAIGN_TOKEN = 'hnwtbnwvq5lrvmztxnc78gxgxtk24jq8'
61
+ export interface IAppsflyerParams {
62
+ apiToken: string
63
+ eventIds?: Record<string, string>
64
+ appId?: string
65
+ devKey: string
66
+ }
121
67
 
122
- export interface IApp extends Document {
123
- id: number
124
- enabled: boolean
125
- name: string
126
- bundle: string
127
- status: AppStatus
128
-
129
- // Integration type - offerwall is default
130
- integrationType: IntegrationType
131
-
132
- // Keitaro campaigns - one or both can be set
133
- offerwallCampaign: IAppKeitaroData | null
134
- directCampaign: IAppKeitaroData | null
135
-
136
- // OneSignal
137
- onesignalAppId: string
138
- onesignalRestApiKey: string
139
-
140
- // AppsFlyer
141
- appsflyerParams?: IAppsflyerParams
142
-
143
- // Domain
144
- domainParams: IDomainParams
145
-
146
- // Policy
147
- policyPath: string
148
-
149
- // Postbacks
150
- postbacks?: IAppsflyerPostback[]
151
-
152
- // @deprecated - use offerwallCampaign/directCampaign instead
153
- keitaroData?: IAppKeitaroData | null
154
- platforms?: { [key: string]: IPlatformParams }
155
- bannerParams?: any
156
- offersStubParams?: any
157
- ech?: any
158
- offerwallParams?: any
159
- appmetricaApiKey?: string
160
- appmetricaAppId?: string
161
- integrationVersion?: IntegrationVersion
162
- geos?: string[]
68
+ export interface IAdjustParams {
69
+ appId: string
70
+ eventIds: IAdjustEventIds
163
71
  }
164
72
 
165
- export interface IAppsflyerParams {
166
- apiToken: string
167
- eventIds?: Record<string, string>
168
- appId?: string
169
- devKey: string
73
+ // ─── Campaign ─────────────────────────────────────────────────────────────────
74
+
75
+ export interface IKeitaroDirectTrackingParams {
76
+ naming: string
77
+ firebase_app_instance_id: string
78
+ firebase_user_id: string
79
+ firebase_device_language_code: string
80
+ firebase_push_token: string
81
+ bundle_id: string
82
+ advertising_id: string
83
+ appsflyer_device_id: string
84
+ campaign: string
85
+ }
86
+
87
+ /** Single campaign object — replaces keitaroData / offerwallCampaign / directCampaign */
88
+ export interface IAppCampaign {
89
+ campaignId: number
90
+ campaignName: string
91
+ campaignAlias: string
92
+ campaignToken?: string
93
+ domainId: number
94
+ domainName: string
95
+ trackingParams?: IKeitaroDirectTrackingParams
96
+ }
97
+
98
+ /** @deprecated Use IAppCampaign instead */
99
+ export interface IAppKeitaroData {
100
+ trackingCampaignId: number
101
+ trackingCampaignName: string
102
+ trackingCampaignAlias: string
103
+ trackingDomainId: number
104
+ trackingDomainName: string
105
+ campingToken?: string
106
+ trackingParams?: IKeitaroDirectTrackingParams
170
107
  }
171
108
 
109
+ // ─── Domain params ────────────────────────────────────────────────────────────
110
+
172
111
  export interface IDomainParams {
173
- name: string
174
- clouflareZone: string
175
- ready: boolean
112
+ name: string
113
+ clouflareZone: string
114
+ ready: boolean
176
115
  }
177
116
 
178
- export enum AppStatus {
179
- ARCHIVED = "ARCHIVED",
180
- IN_DEVELOPMENT = "IN_DEVELOPMENT",
181
- READY = "READY"
117
+ // ─── Offerwall ────────────────────────────────────────────────────────────────
118
+
119
+ export interface IOfferwallParams {
120
+ path: string
121
+ version?: number | string
122
+ sectionsListId?: number
182
123
  }
183
124
 
184
- export interface IKeitaroDirectTrackingParams {
185
- naming: string
186
- firebase_app_instance_id: string
187
- firebase_user_id: string
188
- firebase_device_language_code: string
189
- firebase_push_token: string
190
- bundle_id: string
191
- advertising_id: string
192
- appsflyer_device_id: string
193
- campaign: string
125
+ // ─── Webview config ───────────────────────────────────────────────────────────
126
+
127
+ export interface IWebviewPostParams {
128
+ appsflyerIdKey: string
129
+ deviceIdKey: string
130
+ advertisingIdKey: string
131
+ sessionIdKey: string
132
+ bundleIdKey: string
194
133
  }
195
134
 
196
- export interface IAppKeitaroData {
197
- trackingCampaignId: number
198
- trackingCampaignName: string
199
- trackingCampaignAlias: string
200
- trackingDomainId: number
201
- trackingDomainName: string
202
- campingToken?: string
203
- trackingParams?: IKeitaroDirectTrackingParams
135
+ export interface IWebviewConfig {
136
+ /** Obfuscated template: { param_name: assembled_value }. Values are link parts at runtime, stub values at rest. */
137
+ template: Record<string, string>
138
+ /** GPT-generated static fallback data returned when no offer link is available */
139
+ stubData: Record<string, any>
140
+ /** Generated endpoint path that receives POST from mobile app, e.g. "/xk3m9p" */
141
+ postPath: string
142
+ /** Obfuscated POST body field names for the 5 critical IDs */
143
+ postParams: IWebviewPostParams
204
144
  }
205
145
 
146
+ // ─── Postbacks ────────────────────────────────────────────────────────────────
147
+
148
+ export interface IAppsflyerPostback {
149
+ campaign_id: number
150
+ id: number
151
+ method: "GET" | "POST"
152
+ statuses: string[]
153
+ url: string
154
+ notes?: string
155
+ }
156
+
157
+ // ─── Main IApp interface ──────────────────────────────────────────────────────
158
+
159
+ export interface IApp extends Document {
160
+ id: number
161
+ enabled: boolean
162
+ name: string
163
+ bundle: string
164
+ status: AppStatus
165
+ /** Technical integration mode */
166
+ appMode: AppMode
167
+ /** Content type classification (gambling / finances) */
168
+ appType?: AppType
169
+ geos?: string[]
170
+
171
+ /** Single Keitaro campaign for this app */
172
+ campaign: IAppCampaign | null
173
+
174
+ /** AppsFlyer attribution (was platforms[key].appsflyerParams) */
175
+ appsflyerParams?: IAppsflyerParams
176
+
177
+ /** Adjust attribution (was platforms[key].adjustParams) */
178
+ adjustParams?: IAdjustParams
179
+
180
+ /** Offerwall-specific config (only when appMode === OFFERWALL) */
181
+ offerwallParams?: IOfferwallParams
182
+
183
+ domainParams: IDomainParams
184
+ policyPath: string
185
+ postbacks?: IAppsflyerPostback[]
186
+
187
+ /** Webview-specific config (only when appMode === WEBVIEW) */
188
+ webviewConfig?: IWebviewConfig
189
+
190
+ /** Reference to IServer._id (webview apps only) */
191
+ serverId?: string
192
+ }
193
+
194
+ // ─── Mongoose schema ──────────────────────────────────────────────────────────
195
+
206
196
  export const AppSchema = new Schema({
207
- id: {
208
- type: Number,
209
- unique: true,
210
- required: true
211
- },
212
- enabled: {
213
- type: Boolean,
214
- required: true,
215
- default: false
216
- },
217
- status: {
218
- type: String,
219
- enum: AppStatus,
220
- default: AppStatus.IN_DEVELOPMENT
221
- },
222
- integrationType: {
223
- type: String,
224
- enum: IntegrationType,
225
- default: IntegrationType.OFFERWALL
226
- },
227
- bundle: {
228
- type: String,
229
- unique: true,
230
- required: true
231
- },
232
- name: String,
233
- onesignalAppId: {
234
- type: String,
235
- required: false
236
- },
237
- onesignalRestApiKey: {
238
- type: String,
239
- required: false
240
- },
241
- offerwallCampaign: {
242
- trackingCampaignId: Number,
243
- trackingCampaignName: String,
244
- trackingCampaignAlias: String,
245
- trackingDomainId: Number,
246
- trackingDomainName: String,
247
- campingToken: String,
248
- trackingParams: {
249
- naming: String,
250
- firebase_app_instance_id: String,
251
- firebase_user_id: String,
252
- firebase_device_language_code: String,
253
- firebase_push_token: String,
254
- bundle_id: String,
255
- advertising_id: String,
256
- appsflyer_device_id: String,
257
- campaign: String
258
- }
259
- },
260
- directCampaign: {
261
- trackingCampaignId: Number,
262
- trackingCampaignName: String,
263
- trackingCampaignAlias: String,
264
- trackingDomainId: Number,
265
- trackingDomainName: String,
266
- campingToken: String,
267
- trackingParams: {
268
- naming: String,
269
- firebase_app_instance_id: String,
270
- firebase_user_id: String,
271
- firebase_device_language_code: String,
272
- firebase_push_token: String,
273
- bundle_id: String,
274
- advertising_id: String,
275
- appsflyer_device_id: String,
276
- campaign: String
277
- }
278
- },
279
- appsflyerParams: {
280
- apiToken: String,
281
- eventIds: Object,
282
- appId: String,
283
- devKey: String
284
- },
285
- domainParams: {
286
- name: {
287
- type: String,
288
- unique: true
289
- },
290
- clouflareZone: String,
291
- ready: Boolean
292
- },
293
- policyPath: {
294
- type: String,
295
- default: "none"
296
- },
297
- postbacks: [{
298
- campaign_id: {
299
- type: Number,
300
- required: true
301
- },
302
- id: {
303
- type: Number,
304
- required: true
305
- },
306
- method: {
307
- type: String,
308
- enum: ["GET", "POST"],
309
- required: true
310
- },
311
- statuses: [{
312
- type: String,
313
- required: true
314
- }],
315
- url: {
316
- type: String,
317
- required: true
318
- },
319
- notes: {
320
- type: String,
321
- required: false
322
- }
323
- }],
324
- // @deprecated fields for backwards compatibility
325
- keitaroData: {
326
- trackingCampaignId: Number,
327
- trackingCampaignName: String,
328
- trackingCampaignAlias: String,
329
- trackingDomainId: Number,
330
- trackingDomainName: String,
331
- campingToken: String,
332
- trackingParams: Schema.Types.Mixed
333
- },
334
- platforms: Schema.Types.Mixed,
335
- bannerParams: Schema.Types.Mixed,
336
- offersStubParams: Schema.Types.Mixed,
337
- ech: Schema.Types.Mixed,
338
- offerwallParams: Schema.Types.Mixed,
339
- appmetricaApiKey: String,
340
- appmetricaAppId: String
197
+ id: {
198
+ type: Number,
199
+ unique: true,
200
+ required: true
201
+ },
202
+ enabled: {
203
+ type: Boolean,
204
+ required: true,
205
+ default: false
206
+ },
207
+ status: {
208
+ type: String,
209
+ enum: Object.values(AppStatus),
210
+ default: AppStatus.IN_DEVELOPMENT
211
+ },
212
+ appMode: {
213
+ type: String,
214
+ enum: Object.values(AppMode),
215
+ default: AppMode.OFFERWALL
216
+ },
217
+ appType: {
218
+ type: String,
219
+ required: false
220
+ },
221
+ bundle: {
222
+ type: String,
223
+ unique: true,
224
+ required: true
225
+ },
226
+ name: String,
227
+ geos: [String],
228
+
229
+ campaign: {
230
+ campaignId: { type: Number, default: 0 },
231
+ campaignName: { type: String, default: 'none' },
232
+ campaignAlias: { type: String, default: 'none' },
233
+ campaignToken: { type: String },
234
+ domainId: { type: Number, default: 0 },
235
+ domainName: { type: String, default: 'none' },
236
+ trackingParams: { type: Object }
237
+ },
238
+
239
+ appsflyerParams: { type: Object },
240
+ adjustParams: { type: Object },
241
+
242
+ offerwallParams: { type: Object },
243
+
244
+ domainParams: {
245
+ name: { type: String, unique: true },
246
+ clouflareZone: { type: String },
247
+ ready: { type: Boolean, default: false }
248
+ },
249
+
250
+ policyPath: {
251
+ type: String,
252
+ default: 'none'
253
+ },
254
+
255
+ postbacks: [{
256
+ campaign_id: { type: Number, required: true },
257
+ id: { type: Number, required: true },
258
+ method: { type: String, enum: ['GET', 'POST'], required: true },
259
+ statuses: [{ type: String, required: true }],
260
+ url: { type: String, required: true },
261
+ notes: { type: String, required: false }
262
+ }],
263
+
264
+ webviewConfig: { type: Object },
265
+ serverId: { type: String }
341
266
  })
267
+
268
+ // ─── Helpers ──────────────────────────────────────────────────────────────────
269
+
270
+ export const getPlatformName = (platform: EPlatform | undefined): string | false => {
271
+ switch (platform) {
272
+ case EPlatform.SAMSUNG: return "samsung";
273
+ case EPlatform.HUAWEI: return "huawei";
274
+ case EPlatform.ruSTORE: return "ruStore";
275
+ case EPlatform.XIAOMI: return "xiaomi";
276
+ case EPlatform.APKPURE: return "apkpure";
277
+ case EPlatform.TELEGRAM: return "telegram";
278
+ case EPlatform.AMAZON: return "amazon";
279
+ default: return false;
280
+ }
281
+ };
282
+
283
+ // ─── Legacy stubs (kept for compatibility with keitaro-service.ts utilities) ──
284
+
285
+ /** @deprecated */
286
+ export interface IPlatformParams {
287
+ enabled: boolean
288
+ adjustParams?: IAdjustParams
289
+ direct?: {
290
+ enabled: boolean
291
+ keitaroData: IAppKeitaroData | boolean
292
+ directType?: EDirectType
293
+ addDefaultStreams?: boolean
294
+ }
295
+ appsflyerParams?: IAppsflyerParams
296
+ proxied?: boolean
297
+ }
298
+
299
+ /** @deprecated */
300
+ export interface IBannerParams {
301
+ dataPath: string
302
+ imagePath: string
303
+ imageParam: string
304
+ linkParam: string
305
+ showStubOnError?: boolean
306
+ }
307
+
308
+ /** @deprecated */
309
+ export interface IOffersStubParams {
310
+ offersPath: string
311
+ imagesPath: string
312
+ }
313
+
314
+ /** @deprecated */
315
+ export interface IRemovalInfo {
316
+ reason: string
317
+ date: number
318
+ status: string
319
+ images: string[]
320
+ }
321
+
322
+ /** @deprecated */
323
+ export interface IPrivacyPolicyParams {
324
+ showButtonQuery: string
325
+ button?: { text: string }
326
+ mustRead: boolean
327
+ dark: boolean
328
+ path: string
329
+ advertisingIdQuery: string
330
+ confirmFunctionName: string
331
+ redirectFunctionName: string
332
+ redirect: boolean
333
+ }
334
+
335
+ /** @deprecated */
336
+ export interface IRemoveDataParams {
337
+ buttonText: string
338
+ resultText: string
339
+ errorText: string
340
+ inputHint: string
341
+ dark: boolean
342
+ path: string
343
+ callbackFunctionName: string
344
+ toSplashAfterSuccess: boolean
345
+ }
346
+
347
+ /** @deprecated stub — ETeam was referenced in some legacy export */
348
+ export enum ETeam {
349
+ MAIN = 'main'
350
+ }
@@ -29,6 +29,7 @@ export interface ICloudflareDomainRecord {
29
29
  managed_by_apps: boolean;
30
30
  managed_by_argo_tunnel: boolean;
31
31
  };
32
+ priority?: number;
32
33
  comment: string;
33
34
  tags: string[];
34
35
  created_on: string;