@happyvertical/smrt-ads 0.30.0
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/AGENTS.md +47 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +7 -0
- package/README.md +112 -0
- package/dist/index.d.ts +794 -0
- package/dist/index.js +1121 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.json +3506 -0
- package/dist/smrt-knowledge.json +1438 -0
- package/package.json +63 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,794 @@
|
|
|
1
|
+
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
|
+
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* AdDeliveryTier defines priority levels for ad serving.
|
|
6
|
+
*
|
|
7
|
+
* Ads are selected by priority (lower = higher priority):
|
|
8
|
+
* 1. Sponsorship - Guaranteed, premium placements
|
|
9
|
+
* 2. Standard - Regular programmatic ads
|
|
10
|
+
* 3. House - Self-promotional/fallback ads
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const sponsorship = await tiers.create({
|
|
15
|
+
* name: 'Sponsorship',
|
|
16
|
+
* priority: 1,
|
|
17
|
+
* pricingModel: PricingModel.FIXED,
|
|
18
|
+
* description: 'Premium guaranteed placements'
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class AdDeliveryTier extends SmrtObject {
|
|
23
|
+
/**
|
|
24
|
+
* Display name (e.g., "Sponsorship", "Standard", "House")
|
|
25
|
+
*/
|
|
26
|
+
name: string;
|
|
27
|
+
/**
|
|
28
|
+
* Priority level (lower = higher priority: 1, 2, 3...)
|
|
29
|
+
*/
|
|
30
|
+
priority: number;
|
|
31
|
+
/**
|
|
32
|
+
* Pricing model for this tier
|
|
33
|
+
*/
|
|
34
|
+
pricingModel: PricingModel;
|
|
35
|
+
/**
|
|
36
|
+
* Optional description
|
|
37
|
+
*/
|
|
38
|
+
description: string;
|
|
39
|
+
constructor(options?: any);
|
|
40
|
+
/**
|
|
41
|
+
* Check if this tier is higher priority than another
|
|
42
|
+
*/
|
|
43
|
+
isHigherPriorityThan(other: AdDeliveryTier): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Check if this is a fixed pricing tier
|
|
46
|
+
*/
|
|
47
|
+
isFixedPricing(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Check if this is a performance-based tier (CPC, CPA)
|
|
50
|
+
*/
|
|
51
|
+
isPerformanceBased(): boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export declare class AdDeliveryTierCollection extends SmrtCollection<AdDeliveryTier> {
|
|
55
|
+
static readonly _itemClass: typeof AdDeliveryTier;
|
|
56
|
+
/**
|
|
57
|
+
* Find tiers ordered by priority (ascending, lower = higher priority)
|
|
58
|
+
*
|
|
59
|
+
* @returns Array of tiers ordered by priority
|
|
60
|
+
*/
|
|
61
|
+
findByPriority(): Promise<AdDeliveryTier[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Find tiers by pricing model
|
|
64
|
+
*
|
|
65
|
+
* @param pricingModel - Pricing model to filter by
|
|
66
|
+
* @returns Array of matching tiers
|
|
67
|
+
*/
|
|
68
|
+
findByPricingModel(pricingModel: PricingModel): Promise<AdDeliveryTier[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Get the highest priority tier
|
|
71
|
+
*
|
|
72
|
+
* @returns Highest priority tier or null
|
|
73
|
+
*/
|
|
74
|
+
getHighestPriority(): Promise<AdDeliveryTier | null>;
|
|
75
|
+
/**
|
|
76
|
+
* Find fixed pricing tiers
|
|
77
|
+
*/
|
|
78
|
+
findFixedPricing(): Promise<AdDeliveryTier[]>;
|
|
79
|
+
/**
|
|
80
|
+
* Find CPM-based tiers
|
|
81
|
+
*/
|
|
82
|
+
findCPM(): Promise<AdDeliveryTier[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Find performance-based tiers (CPC, CPA)
|
|
85
|
+
*/
|
|
86
|
+
findPerformanceBased(): Promise<AdDeliveryTier[]>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* AdEvent tracks ad impressions, clicks, and conversions.
|
|
91
|
+
* Events are immutable (append-only, no update/delete).
|
|
92
|
+
*
|
|
93
|
+
* References:
|
|
94
|
+
* - variationId: FK to AdVariation (within package)
|
|
95
|
+
* - zoneId: String reference to smrt-properties Zone (cross-package)
|
|
96
|
+
* - siteId: Denormalized for query efficiency (cross-package)
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* // Track an impression
|
|
101
|
+
* const impression = await events.create({
|
|
102
|
+
* variationId: variation.id,
|
|
103
|
+
* zoneId: 'zone-uuid',
|
|
104
|
+
* siteId: 'site-uuid',
|
|
105
|
+
* eventType: AdEventType.IMPRESSION,
|
|
106
|
+
* metadata: JSON.stringify({
|
|
107
|
+
* ip: '192.168.1.1',
|
|
108
|
+
* userAgent: 'Mozilla/5.0...',
|
|
109
|
+
* referrer: 'https://example.com'
|
|
110
|
+
* })
|
|
111
|
+
* });
|
|
112
|
+
*
|
|
113
|
+
* // Track a click
|
|
114
|
+
* const click = await events.create({
|
|
115
|
+
* variationId: variation.id,
|
|
116
|
+
* zoneId: 'zone-uuid',
|
|
117
|
+
* siteId: 'site-uuid',
|
|
118
|
+
* eventType: AdEventType.CLICK
|
|
119
|
+
* });
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export declare class AdEvent extends SmrtObject {
|
|
123
|
+
/**
|
|
124
|
+
* Tenant ID for multi-tenancy support
|
|
125
|
+
*/
|
|
126
|
+
tenantId: string | null;
|
|
127
|
+
/**
|
|
128
|
+
* Variation ID (FK to AdVariation)
|
|
129
|
+
*/
|
|
130
|
+
variationId: string;
|
|
131
|
+
/**
|
|
132
|
+
* Zone ID (FK to smrt-properties Zone, cross-package)
|
|
133
|
+
*/
|
|
134
|
+
zoneId: string;
|
|
135
|
+
/**
|
|
136
|
+
* Site ID (denormalized from Zone for query efficiency)
|
|
137
|
+
*/
|
|
138
|
+
siteId: string;
|
|
139
|
+
/**
|
|
140
|
+
* Event type (impression, click, conversion)
|
|
141
|
+
*/
|
|
142
|
+
eventType: AdEventType;
|
|
143
|
+
/**
|
|
144
|
+
* Event timestamp
|
|
145
|
+
*/
|
|
146
|
+
timestamp: Date;
|
|
147
|
+
/**
|
|
148
|
+
* Analytics metadata as JSON string
|
|
149
|
+
* (IP, user agent, referrer, etc.)
|
|
150
|
+
*/
|
|
151
|
+
metadata: string;
|
|
152
|
+
constructor(options?: any);
|
|
153
|
+
/**
|
|
154
|
+
* Get metadata as object
|
|
155
|
+
*/
|
|
156
|
+
getMetadata(): Record<string, any>;
|
|
157
|
+
/**
|
|
158
|
+
* Set metadata from object
|
|
159
|
+
*/
|
|
160
|
+
setMetadata(data: Record<string, any>): void;
|
|
161
|
+
/**
|
|
162
|
+
* Check if this is an impression event
|
|
163
|
+
*/
|
|
164
|
+
isImpression(): boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Check if this is a click event
|
|
167
|
+
*/
|
|
168
|
+
isClick(): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Check if this is a conversion event
|
|
171
|
+
*/
|
|
172
|
+
isConversion(): boolean;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export declare class AdEventCollection extends SmrtCollection<AdEvent> {
|
|
176
|
+
static readonly _itemClass: typeof AdEvent;
|
|
177
|
+
/**
|
|
178
|
+
* Find events by variation
|
|
179
|
+
*
|
|
180
|
+
* @param variationId - Variation ID
|
|
181
|
+
* @returns Array of events
|
|
182
|
+
*/
|
|
183
|
+
findByVariation(variationId: string): Promise<AdEvent[]>;
|
|
184
|
+
/**
|
|
185
|
+
* Find events by zone
|
|
186
|
+
*
|
|
187
|
+
* @param zoneId - Zone ID
|
|
188
|
+
* @returns Array of events
|
|
189
|
+
*/
|
|
190
|
+
findByZone(zoneId: string): Promise<AdEvent[]>;
|
|
191
|
+
/**
|
|
192
|
+
* Find events by site
|
|
193
|
+
*
|
|
194
|
+
* @param siteId - Site ID
|
|
195
|
+
* @returns Array of events
|
|
196
|
+
*/
|
|
197
|
+
findBySite(siteId: string): Promise<AdEvent[]>;
|
|
198
|
+
/**
|
|
199
|
+
* Find events in date range
|
|
200
|
+
*
|
|
201
|
+
* @param start - Start date
|
|
202
|
+
* @param end - End date
|
|
203
|
+
* @returns Array of events
|
|
204
|
+
*/
|
|
205
|
+
findByDateRange(start: Date, end: Date): Promise<AdEvent[]>;
|
|
206
|
+
/**
|
|
207
|
+
* Find events by type
|
|
208
|
+
*
|
|
209
|
+
* @param eventType - Event type
|
|
210
|
+
* @returns Array of events
|
|
211
|
+
*/
|
|
212
|
+
findByType(eventType: AdEventType): Promise<AdEvent[]>;
|
|
213
|
+
/**
|
|
214
|
+
* Count events by type for a variation
|
|
215
|
+
*
|
|
216
|
+
* @param variationId - Variation ID
|
|
217
|
+
* @param eventType - Event type
|
|
218
|
+
* @returns Count of events
|
|
219
|
+
*/
|
|
220
|
+
countByType(variationId: string, eventType: AdEventType): Promise<number>;
|
|
221
|
+
/**
|
|
222
|
+
* Count impressions for a variation
|
|
223
|
+
*/
|
|
224
|
+
countImpressions(variationId: string): Promise<number>;
|
|
225
|
+
/**
|
|
226
|
+
* Count clicks for a variation
|
|
227
|
+
*/
|
|
228
|
+
countClicks(variationId: string): Promise<number>;
|
|
229
|
+
/**
|
|
230
|
+
* Count conversions for a variation
|
|
231
|
+
*/
|
|
232
|
+
countConversions(variationId: string): Promise<number>;
|
|
233
|
+
/**
|
|
234
|
+
* Find all impressions
|
|
235
|
+
*/
|
|
236
|
+
findImpressions(): Promise<AdEvent[]>;
|
|
237
|
+
/**
|
|
238
|
+
* Find all clicks
|
|
239
|
+
*/
|
|
240
|
+
findClicks(): Promise<AdEvent[]>;
|
|
241
|
+
/**
|
|
242
|
+
* Find all conversions
|
|
243
|
+
*/
|
|
244
|
+
findConversions(): Promise<AdEvent[]>;
|
|
245
|
+
/**
|
|
246
|
+
* Get aggregate stats for a variation
|
|
247
|
+
*
|
|
248
|
+
* @param variationId - Variation ID
|
|
249
|
+
* @returns Stats object with impressions, clicks, conversions, CTR
|
|
250
|
+
*/
|
|
251
|
+
getVariationStats(variationId: string): Promise<{
|
|
252
|
+
impressions: number;
|
|
253
|
+
clicks: number;
|
|
254
|
+
conversions: number;
|
|
255
|
+
ctr: number;
|
|
256
|
+
conversionRate: number;
|
|
257
|
+
}>;
|
|
258
|
+
/**
|
|
259
|
+
* Find ad events belonging to a specific tenant
|
|
260
|
+
*
|
|
261
|
+
* @param tenantId - Tenant ID to filter by
|
|
262
|
+
* @returns Array of ad events for the tenant
|
|
263
|
+
*/
|
|
264
|
+
findByTenant(tenantId: string): Promise<AdEvent[]>;
|
|
265
|
+
/**
|
|
266
|
+
* Find global ad events (no tenant association)
|
|
267
|
+
*
|
|
268
|
+
* @returns Array of global ad events
|
|
269
|
+
*/
|
|
270
|
+
findGlobal(): Promise<AdEvent[]>;
|
|
271
|
+
/**
|
|
272
|
+
* Find ad events for a tenant including global (shared) events
|
|
273
|
+
*
|
|
274
|
+
* @param tenantId - Tenant ID to include
|
|
275
|
+
* @returns Array of tenant-specific and global ad events
|
|
276
|
+
*/
|
|
277
|
+
findWithGlobals(tenantId: string): Promise<AdEvent[]>;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Event types for ad tracking
|
|
282
|
+
*/
|
|
283
|
+
export declare enum AdEventType {
|
|
284
|
+
IMPRESSION = "impression",
|
|
285
|
+
CLICK = "click",
|
|
286
|
+
CONVERSION = "conversion"
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* AdFormat defines standard ad dimensions and types (IAB standards).
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```typescript
|
|
294
|
+
* const leaderboard = await formats.create({
|
|
295
|
+
* name: 'Leaderboard',
|
|
296
|
+
* width: 728,
|
|
297
|
+
* height: 90,
|
|
298
|
+
* formatType: AdFormatType.BANNER
|
|
299
|
+
* });
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
export declare class AdFormat extends SmrtObject {
|
|
303
|
+
/**
|
|
304
|
+
* Display name (e.g., "Leaderboard", "Medium Rectangle")
|
|
305
|
+
*/
|
|
306
|
+
name: string;
|
|
307
|
+
/**
|
|
308
|
+
* Width in pixels
|
|
309
|
+
*/
|
|
310
|
+
width: number;
|
|
311
|
+
/**
|
|
312
|
+
* Height in pixels
|
|
313
|
+
*/
|
|
314
|
+
height: number;
|
|
315
|
+
/**
|
|
316
|
+
* Format type (banner, native, video)
|
|
317
|
+
*/
|
|
318
|
+
formatType: AdFormatType;
|
|
319
|
+
/**
|
|
320
|
+
* Optional description
|
|
321
|
+
*/
|
|
322
|
+
description: string;
|
|
323
|
+
constructor(options?: any);
|
|
324
|
+
/**
|
|
325
|
+
* Get dimensions as string (e.g., "728x90")
|
|
326
|
+
*/
|
|
327
|
+
getDimensions(): string;
|
|
328
|
+
/**
|
|
329
|
+
* Check if format matches specific dimensions
|
|
330
|
+
*/
|
|
331
|
+
matchesDimensions(width: number, height: number): boolean;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export declare class AdFormatCollection extends SmrtCollection<AdFormat> {
|
|
335
|
+
static readonly _itemClass: typeof AdFormat;
|
|
336
|
+
/**
|
|
337
|
+
* Find format by dimensions
|
|
338
|
+
*
|
|
339
|
+
* @param width - Width in pixels
|
|
340
|
+
* @param height - Height in pixels
|
|
341
|
+
* @returns Matching format or null
|
|
342
|
+
*/
|
|
343
|
+
findByDimensions(width: number, height: number): Promise<AdFormat | null>;
|
|
344
|
+
/**
|
|
345
|
+
* Find formats by type
|
|
346
|
+
*
|
|
347
|
+
* @param formatType - Format type (banner, native, video)
|
|
348
|
+
* @returns Array of matching formats
|
|
349
|
+
*/
|
|
350
|
+
findByType(formatType: AdFormatType): Promise<AdFormat[]>;
|
|
351
|
+
/**
|
|
352
|
+
* Find all banner formats
|
|
353
|
+
*/
|
|
354
|
+
findBanners(): Promise<AdFormat[]>;
|
|
355
|
+
/**
|
|
356
|
+
* Find all native formats
|
|
357
|
+
*/
|
|
358
|
+
findNative(): Promise<AdFormat[]>;
|
|
359
|
+
/**
|
|
360
|
+
* Find all video formats
|
|
361
|
+
*/
|
|
362
|
+
findVideo(): Promise<AdFormat[]>;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Types and enums for smrt-ads package
|
|
367
|
+
*/
|
|
368
|
+
/**
|
|
369
|
+
* Ad format types for different creative types
|
|
370
|
+
*/
|
|
371
|
+
export declare enum AdFormatType {
|
|
372
|
+
BANNER = "banner",
|
|
373
|
+
NATIVE = "native",
|
|
374
|
+
VIDEO = "video"
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* AdGroup organizes ad creatives with targeting and budget controls.
|
|
379
|
+
*
|
|
380
|
+
* References:
|
|
381
|
+
* - tierId: FK to AdDeliveryTier (within package)
|
|
382
|
+
* - contractId: String reference to smrt-commerce Contract (cross-package)
|
|
383
|
+
* - zoneIds: JSON array of allowed smrt-properties Zone IDs (cross-package)
|
|
384
|
+
* - verticalSlug: Tag slug from smrt-tags (cross-package)
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* ```typescript
|
|
388
|
+
* const adGroup = await groups.create({
|
|
389
|
+
* contractId: 'contract-uuid',
|
|
390
|
+
* tierId: tier.id,
|
|
391
|
+
* name: 'Summer Sale - Desktop',
|
|
392
|
+
* verticalSlug: 'retail',
|
|
393
|
+
* targeting: JSON.stringify({ device: 'desktop' }),
|
|
394
|
+
* zoneIds: JSON.stringify(['zone-1', 'zone-2']),
|
|
395
|
+
* dailyBudget: 100.00,
|
|
396
|
+
* totalBudget: 3000.00,
|
|
397
|
+
* startDate: new Date('2024-06-01'),
|
|
398
|
+
* endDate: new Date('2024-08-31')
|
|
399
|
+
* });
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
export declare class AdGroup extends SmrtObject {
|
|
403
|
+
/**
|
|
404
|
+
* Tenant ID for multi-tenancy support
|
|
405
|
+
*/
|
|
406
|
+
tenantId: string | null;
|
|
407
|
+
/**
|
|
408
|
+
* Contract ID (FK to smrt-commerce Contract, cross-package)
|
|
409
|
+
*/
|
|
410
|
+
contractId: string;
|
|
411
|
+
/**
|
|
412
|
+
* Delivery tier ID (FK to AdDeliveryTier)
|
|
413
|
+
*/
|
|
414
|
+
tierId: string;
|
|
415
|
+
/**
|
|
416
|
+
* Display name (e.g., "Summer Sale - Desktop")
|
|
417
|
+
*/
|
|
418
|
+
name: string;
|
|
419
|
+
/**
|
|
420
|
+
* Vertical/category tag slug from smrt-tags (context="advertising")
|
|
421
|
+
*/
|
|
422
|
+
verticalSlug: string;
|
|
423
|
+
/**
|
|
424
|
+
* Targeting rules as JSON string
|
|
425
|
+
*/
|
|
426
|
+
targeting: string;
|
|
427
|
+
/**
|
|
428
|
+
* Allowed Zone IDs as JSON array string (FK to smrt-properties Zone)
|
|
429
|
+
*/
|
|
430
|
+
zoneIds: string;
|
|
431
|
+
/**
|
|
432
|
+
* Campaign start date
|
|
433
|
+
*/
|
|
434
|
+
startDate: Date | null;
|
|
435
|
+
/**
|
|
436
|
+
* Campaign end date
|
|
437
|
+
*/
|
|
438
|
+
endDate: Date | null;
|
|
439
|
+
/**
|
|
440
|
+
* Daily budget limit
|
|
441
|
+
*/
|
|
442
|
+
dailyBudget: number;
|
|
443
|
+
/**
|
|
444
|
+
* Total campaign budget
|
|
445
|
+
*/
|
|
446
|
+
totalBudget: number;
|
|
447
|
+
/**
|
|
448
|
+
* Current status
|
|
449
|
+
*/
|
|
450
|
+
status: AdGroupStatus;
|
|
451
|
+
constructor(options?: any);
|
|
452
|
+
/**
|
|
453
|
+
* Get zone IDs as array
|
|
454
|
+
*/
|
|
455
|
+
getZoneIds(): string[];
|
|
456
|
+
/**
|
|
457
|
+
* Set zone IDs from array
|
|
458
|
+
*/
|
|
459
|
+
setZoneIds(ids: string[]): void;
|
|
460
|
+
/**
|
|
461
|
+
* Add a zone ID
|
|
462
|
+
*/
|
|
463
|
+
addZoneId(zoneId: string): void;
|
|
464
|
+
/**
|
|
465
|
+
* Remove a zone ID
|
|
466
|
+
*/
|
|
467
|
+
removeZoneId(zoneId: string): void;
|
|
468
|
+
/**
|
|
469
|
+
* Check if zone ID is allowed
|
|
470
|
+
*/
|
|
471
|
+
hasZoneId(zoneId: string): boolean;
|
|
472
|
+
/**
|
|
473
|
+
* Get targeting rules as object
|
|
474
|
+
*/
|
|
475
|
+
getTargeting(): Record<string, any>;
|
|
476
|
+
/**
|
|
477
|
+
* Set targeting rules from object
|
|
478
|
+
*/
|
|
479
|
+
setTargeting(rules: Record<string, any>): void;
|
|
480
|
+
/**
|
|
481
|
+
* Check if ad group is currently active
|
|
482
|
+
*/
|
|
483
|
+
isActive(): boolean;
|
|
484
|
+
/**
|
|
485
|
+
* Check if ad group is in draft state
|
|
486
|
+
*/
|
|
487
|
+
isDraft(): boolean;
|
|
488
|
+
/**
|
|
489
|
+
* Check if ad group is paused
|
|
490
|
+
*/
|
|
491
|
+
isPaused(): boolean;
|
|
492
|
+
/**
|
|
493
|
+
* Check if ad group is completed
|
|
494
|
+
*/
|
|
495
|
+
isCompleted(): boolean;
|
|
496
|
+
/**
|
|
497
|
+
* Check if ad group has ended (past end date)
|
|
498
|
+
*/
|
|
499
|
+
hasEnded(): boolean;
|
|
500
|
+
/**
|
|
501
|
+
* Check if ad group has started
|
|
502
|
+
*/
|
|
503
|
+
hasStarted(): boolean;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
export declare class AdGroupCollection extends SmrtCollection<AdGroup> {
|
|
507
|
+
static readonly _itemClass: typeof AdGroup;
|
|
508
|
+
/**
|
|
509
|
+
* Find ad groups by contract
|
|
510
|
+
*
|
|
511
|
+
* @param contractId - Contract ID
|
|
512
|
+
* @returns Array of ad groups
|
|
513
|
+
*/
|
|
514
|
+
findByContract(contractId: string): Promise<AdGroup[]>;
|
|
515
|
+
/**
|
|
516
|
+
* Find ad groups by tier
|
|
517
|
+
*
|
|
518
|
+
* @param tierId - Delivery tier ID
|
|
519
|
+
* @returns Array of ad groups
|
|
520
|
+
*/
|
|
521
|
+
findByTier(tierId: string): Promise<AdGroup[]>;
|
|
522
|
+
/**
|
|
523
|
+
* Find ad groups by status
|
|
524
|
+
*
|
|
525
|
+
* @param status - Ad group status
|
|
526
|
+
* @returns Array of ad groups
|
|
527
|
+
*/
|
|
528
|
+
findByStatus(status: AdGroupStatus): Promise<AdGroup[]>;
|
|
529
|
+
/**
|
|
530
|
+
* Find currently active ad groups
|
|
531
|
+
* (status=active, started, not ended)
|
|
532
|
+
*
|
|
533
|
+
* @returns Array of active ad groups
|
|
534
|
+
*/
|
|
535
|
+
findActive(): Promise<AdGroup[]>;
|
|
536
|
+
/**
|
|
537
|
+
* Find ad groups by vertical slug
|
|
538
|
+
*
|
|
539
|
+
* @param verticalSlug - Tag slug from smrt-tags
|
|
540
|
+
* @returns Array of ad groups
|
|
541
|
+
*/
|
|
542
|
+
findByVertical(verticalSlug: string): Promise<AdGroup[]>;
|
|
543
|
+
/**
|
|
544
|
+
* Find ad groups that can serve to a specific zone
|
|
545
|
+
*
|
|
546
|
+
* @param zoneId - Zone ID to check
|
|
547
|
+
* @returns Array of ad groups containing zone
|
|
548
|
+
*/
|
|
549
|
+
findByZone(zoneId: string): Promise<AdGroup[]>;
|
|
550
|
+
/**
|
|
551
|
+
* Find ad groups eligible to serve for a zone
|
|
552
|
+
* (active, has zone, within date range)
|
|
553
|
+
*
|
|
554
|
+
* @param zoneId - Zone ID to check
|
|
555
|
+
* @returns Array of eligible ad groups
|
|
556
|
+
*/
|
|
557
|
+
findEligibleForZone(zoneId: string): Promise<AdGroup[]>;
|
|
558
|
+
/**
|
|
559
|
+
* Find all draft ad groups
|
|
560
|
+
*/
|
|
561
|
+
findDrafts(): Promise<AdGroup[]>;
|
|
562
|
+
/**
|
|
563
|
+
* Find all paused ad groups
|
|
564
|
+
*/
|
|
565
|
+
findPaused(): Promise<AdGroup[]>;
|
|
566
|
+
/**
|
|
567
|
+
* Find all completed ad groups
|
|
568
|
+
*/
|
|
569
|
+
findCompleted(): Promise<AdGroup[]>;
|
|
570
|
+
/**
|
|
571
|
+
* Find ad groups belonging to a specific tenant
|
|
572
|
+
*
|
|
573
|
+
* @param tenantId - Tenant ID to filter by
|
|
574
|
+
* @returns Array of ad groups for the tenant
|
|
575
|
+
*/
|
|
576
|
+
findByTenant(tenantId: string): Promise<AdGroup[]>;
|
|
577
|
+
/**
|
|
578
|
+
* Find global ad groups (no tenant association)
|
|
579
|
+
*
|
|
580
|
+
* @returns Array of global ad groups
|
|
581
|
+
*/
|
|
582
|
+
findGlobal(): Promise<AdGroup[]>;
|
|
583
|
+
/**
|
|
584
|
+
* Find ad groups for a tenant including global (shared) ad groups
|
|
585
|
+
*
|
|
586
|
+
* @param tenantId - Tenant ID to include
|
|
587
|
+
* @returns Array of tenant-specific and global ad groups
|
|
588
|
+
*/
|
|
589
|
+
findWithGlobals(tenantId: string): Promise<AdGroup[]>;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Status for ad groups
|
|
594
|
+
*/
|
|
595
|
+
export declare enum AdGroupStatus {
|
|
596
|
+
DRAFT = "draft",
|
|
597
|
+
ACTIVE = "active",
|
|
598
|
+
PAUSED = "paused",
|
|
599
|
+
COMPLETED = "completed"
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* AdVariation represents a creative asset within an ad group.
|
|
604
|
+
* Supports A/B testing via weighted selection.
|
|
605
|
+
*
|
|
606
|
+
* References:
|
|
607
|
+
* - groupId: FK to AdGroup (within package)
|
|
608
|
+
* - formatId: FK to AdFormat (within package)
|
|
609
|
+
* - assetId: String reference to smrt-assets Asset (cross-package)
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* ```typescript
|
|
613
|
+
* const variation = await variations.create({
|
|
614
|
+
* groupId: adGroup.id,
|
|
615
|
+
* formatId: leaderboard.id,
|
|
616
|
+
* assetId: 'asset-uuid',
|
|
617
|
+
* name: 'Version A - Blue CTA',
|
|
618
|
+
* clickUrl: 'https://example.com/landing',
|
|
619
|
+
* altText: 'Summer Sale - 50% off',
|
|
620
|
+
* weight: 2 // 2x more likely than weight=1
|
|
621
|
+
* });
|
|
622
|
+
* ```
|
|
623
|
+
*/
|
|
624
|
+
export declare class AdVariation extends SmrtObject {
|
|
625
|
+
/**
|
|
626
|
+
* Tenant ID for multi-tenancy support
|
|
627
|
+
*/
|
|
628
|
+
tenantId: string | null;
|
|
629
|
+
/**
|
|
630
|
+
* Ad group ID (FK to AdGroup)
|
|
631
|
+
*/
|
|
632
|
+
groupId: string;
|
|
633
|
+
/**
|
|
634
|
+
* Ad format ID (FK to AdFormat)
|
|
635
|
+
*/
|
|
636
|
+
formatId: string;
|
|
637
|
+
/**
|
|
638
|
+
* Asset ID (FK to smrt-assets Asset, cross-package)
|
|
639
|
+
*/
|
|
640
|
+
assetId: string;
|
|
641
|
+
/**
|
|
642
|
+
* Display name (e.g., "Version A - Blue CTA")
|
|
643
|
+
*/
|
|
644
|
+
name: string;
|
|
645
|
+
/**
|
|
646
|
+
* Click destination URL
|
|
647
|
+
*/
|
|
648
|
+
clickUrl: string;
|
|
649
|
+
/**
|
|
650
|
+
* Accessibility alt text
|
|
651
|
+
*/
|
|
652
|
+
altText: string;
|
|
653
|
+
/**
|
|
654
|
+
* A/B testing weight (higher = more likely to be selected)
|
|
655
|
+
*/
|
|
656
|
+
weight: number;
|
|
657
|
+
/**
|
|
658
|
+
* Current status
|
|
659
|
+
*/
|
|
660
|
+
status: AdVariationStatus;
|
|
661
|
+
/**
|
|
662
|
+
* Denormalized impression count (updated async)
|
|
663
|
+
*/
|
|
664
|
+
impressions: number;
|
|
665
|
+
/**
|
|
666
|
+
* Denormalized click count (updated async)
|
|
667
|
+
*/
|
|
668
|
+
clicks: number;
|
|
669
|
+
constructor(options?: any);
|
|
670
|
+
/**
|
|
671
|
+
* Check if variation is active
|
|
672
|
+
*/
|
|
673
|
+
isActive(): boolean;
|
|
674
|
+
/**
|
|
675
|
+
* Check if variation is in draft state
|
|
676
|
+
*/
|
|
677
|
+
isDraft(): boolean;
|
|
678
|
+
/**
|
|
679
|
+
* Check if variation is paused
|
|
680
|
+
*/
|
|
681
|
+
isPaused(): boolean;
|
|
682
|
+
/**
|
|
683
|
+
* Calculate click-through rate (CTR)
|
|
684
|
+
*/
|
|
685
|
+
getCTR(): number;
|
|
686
|
+
/**
|
|
687
|
+
* Increment impression count
|
|
688
|
+
*/
|
|
689
|
+
recordImpression(): void;
|
|
690
|
+
/**
|
|
691
|
+
* Increment click count
|
|
692
|
+
*/
|
|
693
|
+
recordClick(): void;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
export declare class AdVariationCollection extends SmrtCollection<AdVariation> {
|
|
697
|
+
static readonly _itemClass: typeof AdVariation;
|
|
698
|
+
/**
|
|
699
|
+
* Find variations by ad group
|
|
700
|
+
*
|
|
701
|
+
* @param groupId - Ad group ID
|
|
702
|
+
* @returns Array of variations
|
|
703
|
+
*/
|
|
704
|
+
findByGroup(groupId: string): Promise<AdVariation[]>;
|
|
705
|
+
/**
|
|
706
|
+
* Find variations by format
|
|
707
|
+
*
|
|
708
|
+
* @param formatId - Ad format ID
|
|
709
|
+
* @returns Array of variations
|
|
710
|
+
*/
|
|
711
|
+
findByFormat(formatId: string): Promise<AdVariation[]>;
|
|
712
|
+
/**
|
|
713
|
+
* Find active variations for a group
|
|
714
|
+
*
|
|
715
|
+
* @param groupId - Ad group ID
|
|
716
|
+
* @returns Array of active variations
|
|
717
|
+
*/
|
|
718
|
+
findActiveByGroup(groupId: string): Promise<AdVariation[]>;
|
|
719
|
+
/**
|
|
720
|
+
* Select a variation using weighted random selection
|
|
721
|
+
* Higher weight = more likely to be selected
|
|
722
|
+
*
|
|
723
|
+
* @param groupId - Ad group ID
|
|
724
|
+
* @returns Selected variation or null if none available
|
|
725
|
+
*/
|
|
726
|
+
selectByWeight(groupId: string): Promise<AdVariation | null>;
|
|
727
|
+
/**
|
|
728
|
+
* Find variations by status
|
|
729
|
+
*
|
|
730
|
+
* @param status - Variation status
|
|
731
|
+
* @returns Array of variations
|
|
732
|
+
*/
|
|
733
|
+
findByStatus(status: AdVariationStatus): Promise<AdVariation[]>;
|
|
734
|
+
/**
|
|
735
|
+
* Find all active variations
|
|
736
|
+
*/
|
|
737
|
+
findActive(): Promise<AdVariation[]>;
|
|
738
|
+
/**
|
|
739
|
+
* Find all draft variations
|
|
740
|
+
*/
|
|
741
|
+
findDrafts(): Promise<AdVariation[]>;
|
|
742
|
+
/**
|
|
743
|
+
* Find all paused variations
|
|
744
|
+
*/
|
|
745
|
+
findPaused(): Promise<AdVariation[]>;
|
|
746
|
+
/**
|
|
747
|
+
* Find top performing variations by CTR
|
|
748
|
+
*
|
|
749
|
+
* @param limit - Maximum number to return
|
|
750
|
+
* @returns Array of variations sorted by CTR descending
|
|
751
|
+
*/
|
|
752
|
+
findTopPerformers(limit?: number): Promise<AdVariation[]>;
|
|
753
|
+
/**
|
|
754
|
+
* Find ad variations belonging to a specific tenant
|
|
755
|
+
*
|
|
756
|
+
* @param tenantId - Tenant ID to filter by
|
|
757
|
+
* @returns Array of ad variations for the tenant
|
|
758
|
+
*/
|
|
759
|
+
findByTenant(tenantId: string): Promise<AdVariation[]>;
|
|
760
|
+
/**
|
|
761
|
+
* Find global ad variations (no tenant association)
|
|
762
|
+
*
|
|
763
|
+
* @returns Array of global ad variations
|
|
764
|
+
*/
|
|
765
|
+
findGlobal(): Promise<AdVariation[]>;
|
|
766
|
+
/**
|
|
767
|
+
* Find ad variations for a tenant including global (shared) variations
|
|
768
|
+
*
|
|
769
|
+
* @param tenantId - Tenant ID to include
|
|
770
|
+
* @returns Array of tenant-specific and global ad variations
|
|
771
|
+
*/
|
|
772
|
+
findWithGlobals(tenantId: string): Promise<AdVariation[]>;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Status for ad variations
|
|
777
|
+
*/
|
|
778
|
+
export declare enum AdVariationStatus {
|
|
779
|
+
DRAFT = "draft",
|
|
780
|
+
ACTIVE = "active",
|
|
781
|
+
PAUSED = "paused"
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* Pricing models for ad delivery tiers
|
|
786
|
+
*/
|
|
787
|
+
export declare enum PricingModel {
|
|
788
|
+
FIXED = "fixed",
|
|
789
|
+
CPM = "cpm",
|
|
790
|
+
CPC = "cpc",
|
|
791
|
+
CPA = "cpa"
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
export { }
|