@surfside/ads-core-mock 0.1.3 → 0.1.6

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,62 +1,154 @@
1
1
  import { Ok } from '@surfside/ads-core-client';
2
- export const MockGetDynamicZone = async () => {
3
- return Ok({
4
- value: [
5
- {
6
- 'size': 'mobile',
7
- 'values': [
8
- {
9
- 'type': 'Video',
10
- 'zoneId': 'my-video',
11
- width: 320,
12
- height: 240,
13
- maxDuration: 30
14
- },
15
- {
16
- 'type': 'Carousel',
17
- 'zoneId': 'my-zone',
18
- 'cardMinWidth': 320,
19
- 'nextType': 'page',
20
- 'catalog': true,
21
- 'strategy': 'hybrid',
22
- 'recommend': 'top-products'
23
- },
24
- {
25
- 'type': 'Banner',
26
- 'zoneId': 'my-zone',
27
- 'width': 4,
28
- 'height': 1
29
- }
30
- ]
31
- },
32
- {
33
- 'size': 'default',
34
- 'values': [
35
- {
36
- 'type': 'Banner',
37
- 'zoneId': 'my-zone',
38
- 'width': 8,
39
- 'height': 1
40
- },
41
- {
42
- 'type': 'Video',
43
- 'zoneId': 'my-video',
44
- width: 320,
45
- height: 240,
46
- maxDuration: 30
47
- },
48
- {
49
- 'type': 'Carousel',
50
- 'zoneId': 'my-zone',
51
- 'cardMinWidth': 320,
52
- 'nextType': 'page',
53
- 'catalog': true,
54
- 'strategy': 'hybrid',
55
- 'recommend': 'top-products'
56
- },
57
- ]
58
- }
59
- ]
2
+ const defaultZone = { value: [] };
3
+ const shuffleArray = (arr) => {
4
+ for (let i = arr.length - 1; i > 0; i--) {
5
+ const j = Math.floor(Math.random() * (i + 1));
6
+ [arr[i], arr[j]] = [arr[j], arr[i]];
7
+ }
8
+ return arr;
9
+ };
10
+ const shuffleDynamicZone = (value) => {
11
+ value.value.forEach((v) => shuffleArray(v.values));
12
+ return value;
13
+ };
14
+ // Mock service using the parser
15
+ export const MockGetDynamicZone = async (zoneIdString) => {
16
+ const parsed = parseZoneIds(zoneIdString);
17
+ const shuffled = shuffleDynamicZone(parsed);
18
+ return Ok(shuffled);
19
+ };
20
+ // Parses a comma-separated list of zoneIds into one consolidated dynamic zone
21
+ export const parseZoneIds = (zoneIds) => {
22
+ const ids = zoneIds
23
+ .split(',')
24
+ .map((z) => z.trim().toLowerCase())
25
+ .filter((z) => z.length > 0);
26
+ // Generate individual zone configs
27
+ const zones = ids.map((id) => {
28
+ let platform = 'both';
29
+ let cleanedId = id;
30
+ if (id.startsWith('m-')) {
31
+ platform = 'mobile';
32
+ cleanedId = id.slice(2);
33
+ }
34
+ else if (id.startsWith('d-')) {
35
+ platform = 'desktop';
36
+ cleanedId = id.slice(2);
37
+ }
38
+ let zone;
39
+ if (cleanedId.includes('banner')) {
40
+ zone = bannerZoneCreator(cleanedId);
41
+ }
42
+ else if (cleanedId.includes('video')) {
43
+ zone = videoZoneCreator(cleanedId);
44
+ }
45
+ else if (cleanedId.includes('carousel')) {
46
+ zone = carouselZoneCreator(cleanedId);
47
+ }
48
+ else {
49
+ return defaultZone;
50
+ }
51
+ // Filter zone values by platform
52
+ if (platform === 'both' || zone === undefined) {
53
+ return zone;
54
+ }
55
+ return {
56
+ value: zone.value.filter((v) => v.size === platform),
57
+ };
60
58
  });
59
+ // Combine by size, merging all values for each size
60
+ const sizes = Array.from(new Set(zones.flatMap((z) => z?.value.map((v) => v.size))));
61
+ const combined = sizes.map((size) => ({
62
+ size,
63
+ values: zones.flatMap((z) => z !== undefined && z.value !== undefined
64
+ ? z.value.find((v) => v.size === size)?.values ?? []
65
+ : []),
66
+ }));
67
+ return { value: combined };
68
+ };
69
+ // Banner zone creator (provided starter)
70
+ const bannerRegex = /banner(?<width>\d+)x(?<height>\d+)/;
71
+ const bannerZoneCreator = (zoneId) => {
72
+ const match = zoneId.match(bannerRegex);
73
+ if (match === null ||
74
+ match?.groups === undefined ||
75
+ match?.groups?.height === undefined ||
76
+ match?.groups?.width === undefined) {
77
+ return undefined;
78
+ }
79
+ const width = parseInt(match.groups.width, 10);
80
+ const height = parseInt(match.groups.height, 10);
81
+ if (width > 16 || width < 0 || height > 16 || height < 0) {
82
+ return undefined;
83
+ }
84
+ const zoneValue = [
85
+ {
86
+ size: 'mobile',
87
+ values: [{ type: 'Banner', zoneId, width, height }],
88
+ },
89
+ {
90
+ size: 'desktop',
91
+ values: [{ type: 'Banner', zoneId, width, height }],
92
+ },
93
+ ];
94
+ return { value: zoneValue };
95
+ };
96
+ // Video zone creator
97
+ const videoRegex = /video(?<width>\d+)x(?<height>\d+)/;
98
+ export const videoZoneCreator = (zoneId) => {
99
+ const match = zoneId.match(videoRegex);
100
+ if (match === null ||
101
+ match?.groups === undefined ||
102
+ match?.groups?.height === undefined ||
103
+ match?.groups?.width === undefined) {
104
+ return undefined;
105
+ }
106
+ const width = parseInt(match.groups.width, 10);
107
+ const height = parseInt(match.groups.height, 10);
108
+ if (width <= 0 || height <= 0) {
109
+ return undefined;
110
+ }
111
+ const zoneValue = [
112
+ {
113
+ size: 'mobile',
114
+ values: [{ type: 'Video', zoneId, width, height, maxDuration: 60 }],
115
+ },
116
+ {
117
+ size: 'desktop',
118
+ values: [{ type: 'Video', zoneId, width, height, maxDuration: 60 }],
119
+ },
120
+ ];
121
+ return { value: zoneValue };
122
+ };
123
+ // Carousel zone creator (sponsored, hybrid, recommended)
124
+ const carouselRegex = /carousel-(?<mode>sponsored|hybrid|recommended)/;
125
+ export const carouselZoneCreator = (zoneId) => {
126
+ const match = zoneId.match(carouselRegex);
127
+ const tryMode = match?.groups?.mode;
128
+ if (tryMode === undefined ||
129
+ (tryMode !== 'sponsored' && tryMode !== 'hybrid' && tryMode !== 'recommended')) {
130
+ return undefined;
131
+ }
132
+ const mode = tryMode;
133
+ // Basic carousel config; adjust properties as needed
134
+ const carouselItem = {
135
+ type: 'Carousel',
136
+ zoneId,
137
+ strategy: mode, // 'sponsored' | 'hybrid' | 'recommended'
138
+ catalog: true,
139
+ cardMinWidth: 320,
140
+ nextType: 'page',
141
+ };
142
+ const zoneValue = [
143
+ {
144
+ size: 'mobile',
145
+ values: [carouselItem],
146
+ },
147
+ {
148
+ size: 'desktop',
149
+ values: [carouselItem],
150
+ },
151
+ ];
152
+ return { value: zoneValue };
61
153
  };
62
154
  //# sourceMappingURL=Dynamic.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Dynamic.js","sourceRoot":"src/","sources":["mock/Dynamic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,EAAE,EAAE,MAAM,2BAA2B,CAAC;AAEpF,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,IAA+B,EAAE;IACpE,OAAO,EAAE,CAAC;QACN,KAAK,EAAE;YACH;gBACI,MAAM,EAAE,QAAQ;gBAChB,QAAQ,EAAE;oBACN;wBACI,MAAM,EAAE,OAAO;wBACf,QAAQ,EAAE,UAAU;wBACpB,KAAK,EAAE,GAAG;wBACV,MAAM,EAAE,GAAG;wBACX,WAAW,EAAE,EAAE;qBAClB;oBACD;wBACI,MAAM,EAAE,UAAU;wBAClB,QAAQ,EAAE,SAAS;wBACnB,cAAc,EAAE,GAAG;wBACnB,UAAU,EAAE,MAAM;wBAClB,SAAS,EAAE,IAAI;wBACf,UAAU,EAAE,QAAQ;wBACpB,WAAW,EAAE,cAAc;qBAC9B;oBACD;wBACI,MAAM,EAAE,QAAQ;wBAChB,QAAQ,EAAE,SAAS;wBACnB,OAAO,EAAE,CAAC;wBACV,QAAQ,EAAE,CAAC;qBACd;iBACJ;aACJ;YACD;gBACI,MAAM,EAAE,SAAS;gBACjB,QAAQ,EAAE;oBACN;wBACI,MAAM,EAAE,QAAQ;wBAChB,QAAQ,EAAE,SAAS;wBACnB,OAAO,EAAE,CAAC;wBACV,QAAQ,EAAE,CAAC;qBACd;oBACD;wBACI,MAAM,EAAE,OAAO;wBACf,QAAQ,EAAE,UAAU;wBACpB,KAAK,EAAE,GAAG;wBACV,MAAM,EAAE,GAAG;wBACX,WAAW,EAAE,EAAE;qBAClB;oBACD;wBACI,MAAM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,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,aAAa,CAAC,EAChF,CAAC;QACC,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,IAAI,GAAG,OAAiD,CAAC;IAE/D,qDAAqD;IACrD,MAAM,YAAY,GAAG;QACjB,IAAI,EAAE,UAAmB;QACzB,MAAM;QACN,QAAQ,EAAE,IAAI,EAAQ,yCAAyC;QAC/D,OAAO,EAAE,IAAI;QACb,YAAY,EAAE,GAAG;QACjB,QAAQ,EAAE,MAAe;KAC5B,CAAC;IAEF,MAAM,SAAS,GAAG;QACd;YACI,IAAI,EAAE,QAAiB;YACvB,MAAM,EAAE,CAAC,YAAY,CAAC;SACzB;QACD;YACI,IAAI,EAAE,SAAkB;YACxB,MAAM,EAAE,CAAC,YAAY,CAAC;SACzB;KACJ,CAAC;IAEF,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAChC,CAAC,CAAC"}
@@ -1,115 +1,166 @@
1
1
  import { Ctx, Ok } from '@surfside/ads-core';
2
2
  import { CHEAT_CODES } from './CheatCodes';
3
- const FakeProducts = [
3
+ export const FallbackSponsoredProducts = [
4
+ // Lemon twist only same one in both
4
5
  {
5
- id: '00001',
6
- 'name': 'SkyHigh OG',
7
- 'description': 'Premium indica strain with earthy undertones and deep relaxation effects',
8
- //"brand": "CannaCloud"
9
- 'brand': 'Mid Software'
6
+ id: 'prod-001',
7
+ name: 'Lemon Twist',
8
+ description: '1:1 CBD:THC oil drops for balanced relief without intense psychoactivity',
9
+ brand: 'Bright Co',
10
10
  },
11
11
  {
12
- id: '00002',
13
- 'name': 'Mellow Mint Tincture',
14
- 'description': 'Fast-acting CBD oil with refreshing mint flavor for daytime relief',
15
- //"brand": "GreenLeaf Therapeutics"
16
- 'brand': 'Mid Software'
12
+ id: 'prod-002',
13
+ name: 'Ocean Breeze',
14
+ description: 'Cool and refreshing',
15
+ brand: 'NatureLabs',
17
16
  },
18
17
  {
19
- id: '00003',
20
- 'name': 'DreamWalker Gummies',
21
- 'description': 'Balanced THC:CBD ratio gummies for gentle euphoria and sleep support',
22
- //"brand": "Elevated Edibles"
23
- 'brand': 'Mid Software'
18
+ id: 'prod-003',
19
+ name: 'Midnight Fuel',
20
+ description: 'Dark roast profile',
21
+ brand: 'Rocket Roast',
24
22
  },
25
23
  {
26
- id: '00004',
27
- 'name': 'Purple Haze Cartridge',
28
- 'description': 'Sativa-dominant vape cartridge with berry notes and creative stimulation',
29
- //"brand": "Vapor Valley"
30
- 'brand': 'Zen Cloud'
24
+ id: 'prod-004',
25
+ name: 'Sunny Daze',
26
+ description: 'Tropical fruit mix',
27
+ brand: 'Bright Co',
31
28
  },
32
29
  {
33
- id: '00005',
34
- 'name': 'Zen Garden Pre-rolls',
35
- 'description': 'Hand-rolled hybrid joints featuring calming terpene profile',
36
- //"brand": "Chronic Creations"
37
- 'brand': 'Zen Cloud'
30
+ id: 'prod-005',
31
+ name: 'Maple Drizzle',
32
+ description: 'Sweet maple treat',
33
+ brand: 'Golden Drop',
38
34
  },
39
35
  {
40
- id: '00006',
41
- 'name': 'Relief Balm Plus',
42
- 'description': 'High-potency topical with cooling menthol for targeted muscle recovery',
43
- //"brand": "HempHeal"
44
- 'brand': 'Zen Cloud'
36
+ id: 'prod-006',
37
+ name: 'Crimson Crunch',
38
+ description: 'Berry granola bar',
39
+ brand: 'NatureLabs',
45
40
  },
46
41
  {
47
- id: '00007',
48
- 'name': 'Cosmic Cookie',
49
- 'description': 'Infused chocolate chip delight with precise 10mg THC microdosing',
50
- //"brand": "Baked Bliss"
51
- 'brand': 'Zen Cloud'
42
+ id: 'prod-007',
43
+ name: 'Cocoa Thunder',
44
+ description: 'Rich chocolate flavor',
45
+ brand: 'Rocket Roast',
52
46
  },
53
47
  {
54
- id: '00008',
55
- 'name': 'Morning Mist Spray',
56
- 'description': 'Rapid sublingual delivery system with citrus essence for mood elevation',
57
- //"brand": "Aurora Botanicals"
58
- 'brand': 'Mid Software'
48
+ id: 'prod-008',
49
+ name: 'Frosty Pine',
50
+ description: 'Cooling pine blend',
51
+ brand: 'EverGreen',
59
52
  },
60
53
  {
61
- id: '00009',
62
- 'name': 'Night Owl Resin',
63
- 'description': 'Premium live resin concentrate with sedative indica properties',
64
- //"brand": "Extract Experts"
65
- 'brand': 'Mid Software'
54
+ id: 'prod-009',
55
+ name: 'Tangerine Rush',
56
+ description: 'Sweet citrus profile',
57
+ brand: 'Bright Co',
66
58
  },
67
59
  {
68
- id: '00010',
69
- 'name': 'Harmony Drops',
70
- 'description': '1:1 CBD:THC oil drops for balanced relief without intense psychoactivity',
71
- //"brand": "Balanced Botanics"
72
- 'brand': 'Mid Software'
60
+ id: 'prod-010',
61
+ name: 'Evening Mist',
62
+ description: 'Light lavender touch',
63
+ brand: 'EverGreen',
73
64
  },
65
+ ];
66
+ export const FallbackRecommendedProducts = [
67
+ // Lemon twist only same one in both
74
68
  {
75
- id: '00011',
76
- 'name': 'Commander Kief',
77
- 'description': 'Billy Blazed - 28 year old man of below-average work ethic, working diligently in his living ' +
78
- 'room has created a device for slowing the progression of time using a crushed soda can and ' +
79
- 'tin foil. At 3pm on a Wednesday, when others are at work, Billy enters his living room, activates his ' +
80
- 'device with a Bic lighter, and transforms into... COMMANDER KIEF - Doer of nothing!',
81
- //"brand": "Mid Software"
82
- 'brand': 'Mid Software'
83
- }
69
+ id: 'prod-001',
70
+ name: 'Lemon Twist',
71
+ description: '1:1 CBD:THC oil drops for balanced relief without intense psychoactivity',
72
+ brand: 'Bright Co',
73
+ },
74
+ {
75
+ id: 'prod-011',
76
+ name: 'Morning Kick',
77
+ description: 'Light roast coffee',
78
+ brand: 'Rocket Roast',
79
+ },
80
+ {
81
+ id: 'prod-012',
82
+ name: 'Berry Buzz',
83
+ description: 'Mixed berry blend',
84
+ brand: 'NatureLabs',
85
+ },
86
+ {
87
+ id: 'prod-013',
88
+ name: 'Mint Chill',
89
+ description: 'Soothing mint breeze',
90
+ brand: 'EverGreen',
91
+ },
92
+ {
93
+ id: 'prod-014',
94
+ name: 'Vanilla Drop',
95
+ description: 'Classic vanilla taste',
96
+ brand: 'Golden Drop',
97
+ },
98
+ {
99
+ id: 'prod-015',
100
+ name: 'Firecracker',
101
+ description: 'Bold cinnamon pop',
102
+ brand: 'Golden Drop',
103
+ },
104
+ {
105
+ id: 'prod-016',
106
+ name: 'Citrus Zing',
107
+ description: 'Lime and lemon fusion',
108
+ brand: 'Bright Co',
109
+ },
110
+ {
111
+ id: 'prod-017',
112
+ name: 'Cocoa Dream',
113
+ description: 'Velvety chocolate',
114
+ brand: 'Rocket Roast',
115
+ },
116
+ {
117
+ id: 'prod-018',
118
+ name: 'Forest Whisper',
119
+ description: 'Pine and sage blend',
120
+ brand: 'EverGreen',
121
+ },
122
+ {
123
+ id: 'prod-019',
124
+ name: 'Cherry Pop',
125
+ description: 'Sweet cherry candy',
126
+ brand: 'NatureLabs',
127
+ },
84
128
  ];
85
- export async function* MockGetSposoredProduct(logger, accountId) {
129
+ export function withFallbackProducts(provided, fallback, label, logger) {
130
+ if (!Array.isArray(provided) || provided.length === 0) {
131
+ Ctx(logger)
132
+ ?.with('withFallbackProducts')
133
+ ?.info?.(`Using fallback for ${label ?? 'products'}`);
134
+ return fallback;
135
+ }
136
+ return provided;
137
+ }
138
+ export async function* MockGetSponsoredProduct(logger, accountId, products) {
86
139
  const log = Ctx(logger)?.with('MockGetSponsoredProduct');
87
- log?.info('Getting mock sponsored product');
88
- while (true) {
89
- for (const fake of FakeProducts) {
90
- log?.debug('Fake product', accountId);
91
- yield productify(fake);
92
- }
93
- log?.debug('Back to the beginning');
140
+ for (const product of products) {
141
+ log?.debug('Yielding product', product.id);
142
+ yield productify(product);
94
143
  }
95
144
  }
96
- export const MockGetAllSponsoredProducts = async () => Ok(FakeProducts.map(productify));
97
- export const MockGetRecommendedProduct = async () => Ok(productify(FakeProducts[Math.floor(Math.random() * FakeProducts.length)]));
145
+ ;
146
+ export const MockGetRecommendedProductFactory = (products) => async () => Ok(products[Math.floor(Math.random() * products.length)]);
147
+ export const MockGetAllSponsoredProductsFactory = (products) => async () => Ok(products.map(productify));
98
148
  const productify = (product) => ({
149
+ id: product.id,
99
150
  name: product.name,
100
151
  brand_name: product.brand,
101
152
  brandName: product.brand,
102
153
  details: product.description,
103
154
  image: `http://creative.surfside.io/mock/flower${Math.floor(Math.random() * 10) + 1}.jpg`
104
155
  });
105
- export async function* MockGenerateSponsoredProductCard(logger, windowInfo, config, accountId, bids) {
156
+ export async function* MockGenerateSponsoredProductCard(logger, windowInfo, config, accountId, getSponsoredProductFactory, bids) {
106
157
  const log = Ctx(logger)?.with('MockGenerateSponsoredProductCard');
107
158
  log?.info('Generating mock sponsored product card response');
108
159
  for (const bid of bids) {
109
160
  log?.info('Going through bids', bid);
110
161
  const native = JSON.parse(bid?.adm ?? '');
111
162
  log?.debug('Native', native);
112
- for await (const product of MockGetSposoredProduct(logger, accountId)) {
163
+ for await (const product of getSponsoredProductFactory) {
113
164
  log?.info('Yielding sponsored product card');
114
165
  switch (accountId) {
115
166
  case CHEAT_CODES.returnSome: {
@@ -118,7 +169,6 @@ export async function* MockGenerateSponsoredProductCard(logger, windowInfo, conf
118
169
  log?.info('Returning no product');
119
170
  return;
120
171
  }
121
- ;
122
172
  break;
123
173
  }
124
174
  case CHEAT_CODES.returnNone: {
@@ -132,16 +182,16 @@ export async function* MockGenerateSponsoredProductCard(logger, windowInfo, conf
132
182
  product,
133
183
  window: windowInfo,
134
184
  publisher: config,
135
- catalog: product
185
+ catalog: product,
136
186
  }),
137
187
  bid: bid,
138
188
  product,
139
189
  trackers: {
140
190
  imp: ['https://surfside.io/track'],
141
191
  win: 'https://surfside.io/win',
142
- others: []
192
+ others: [],
143
193
  },
144
- sponsored: true
194
+ sponsored: true,
145
195
  };
146
196
  }
147
197
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Product.js","sourceRoot":"src/","sources":["mock/Product.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,GAAG,EAMH,EAAE,EAGL,MAAM,o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BAC1B,OAAO;gBACX,CAAC;YACL,CAAC;YAED,MAAM;gBACF,IAAI,EAAE,cAAc;gBACpB,MAAM;gBACN,YAAY,EAAE,MAAM,CAAC,SAAS,CAAC,uBAAuB,CAAC;oBACnD,OAAO;oBACP,MAAM,EAAE,UAAU;oBAClB,SAAS,EAAE,MAAM;oBACjB,OAAO,EAAE,OAAO;iBACnB,CAAC;gBACF,GAAG,EAAE,GAAG;gBACR,OAAO;gBACP,QAAQ,EAAE;oBACN,GAAG,EAAE,CAAC,2BAA2B,CAAC;oBAClC,GAAG,EAAE,yBAAyB;oBAC9B,MAAM,EAAE,EAAE;iBACb;gBACD,SAAS,EAAE,IAAI;aAClB,CAAC;QACN,CAAC;IACL,CAAC;AACL,CAAC;AAAA,CAAC"}
1
+ {"version":3,"file":"Product.js","sourceRoot":"src/","sources":["mock/Product.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,GAAG,EAMH,EAAE,EAEL,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAU3C,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACrC,oCAAoC;IACpC;QACI,EAAE,EAAE,UAAU;QACd,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,0EAA0E;QACvF,KAAK,EAAE,WAAW;KACrB;IACD;QACI,EAAE,EAAE,UAAU;QACd,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,qBAAqB;QAClC,KAAK,EAAE,YAAY;KACtB;IACD;QACI,EAAE,EAAE,UAAU;QACd,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,oBAAoB;QACjC,KAAK,EAAE,cAAc;KACxB;IACD;QACI,EAAE,EAAE,UAAU;QACd,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,oBAAoB;QACjC,KAAK,EAAE,WAAW;KACrB;IACD;QACI,EAAE,EAAE,UAAU;QACd,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,mBAAmB;QAChC,KAAK,EAA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CAAC,CAAC;QAC1C,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC7B,IAAI,KAAK,EAAE,MAAM,OAAO,IAAI,0BAA0B,EAAE,CAAC;YACrD,GAAG,EAAE,IAAI,CAAC,iCAAiC,CAAC,CAAC;YAC7C,QAAQ,SAAS,EAAE,CAAC;gBAChB,KAAK,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;oBAC1B,GAAG,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;oBACnC,IAAI,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;wBACvB,GAAG,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC;wBAClC,OAAO;oBACX,CAAC;oBACD,MAAM;gBACV,CAAC;gBACD,KAAK,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;oBAC1B,OAAO;gBACX,CAAC;YACL,CAAC;YAED,MAAM;gBACF,IAAI,EAAE,cAAc;gBACpB,MAAM;gBACN,YAAY,EAAE,MAAM,CAAC,SAAS,CAAC,uBAAuB,CAAC;oBACnD,OAAO;oBACP,MAAM,EAAE,UAAU;oBAClB,SAAS,EAAE,MAAM;oBACjB,OAAO,EAAE,OAAO;iBACnB,CAAC;gBACF,GAAG,EAAE,GAAG;gBACR,OAAO;gBACP,QAAQ,EAAE;oBACN,GAAG,EAAE,CAAC,2BAA2B,CAAC;oBAClC,GAAG,EAAE,yBAAyB;oBAC9B,MAAM,EAAE,EAAE;iBACb;gBACD,SAAS,EAAE,IAAI;aAClB,CAAC;QACN,CAAC;IACL,CAAC;AACL,CAAC;AAAA,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { Err, Ok } from '@surfside/ads-core-client';
2
+ export const GetRandom = (arr) => {
3
+ if (arr.length === 0) {
4
+ return Err(new EmptyArrayError);
5
+ }
6
+ const idx = Math.floor(Math.random() * arr.length);
7
+ return Ok(arr[idx]);
8
+ };
9
+ export class EmptyArrayError extends Error {
10
+ constructor() {
11
+ super('Array was empty');
12
+ }
13
+ }
14
+ //# sourceMappingURL=Array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Array.js","sourceRoot":"src/","sources":["util/Array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAe,MAAM,2BAA2B,CAAC;AAEjE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAI,GAAa,EAAa,EAAE;IACrD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,GAAG,CAAC,IAAI,eAAe,CAAC,CAAC;IACpC,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;IACnD,OAAO,EAAE,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACtC;QACI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC7B,CAAC;CACJ"}
@@ -0,0 +1,3 @@
1
+ /* Waits some milliseconds without blocking */
2
+ export const Wait = (time) => new Promise(resolve => setTimeout(resolve, time));
3
+ //# sourceMappingURL=Wait.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Wait.js","sourceRoot":"src/","sources":["util/Wait.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC"}
@@ -1,2 +1,4 @@
1
1
  import { type ISurfsideClientApi, type AsyncResult, type ILogger } from '@surfside/ads-core-client';
2
- export declare const InitSurfAdsCoreMock: (accountId: string, siteId: string, channelId: string, locationId: string, userId: string | undefined, logger?: ILogger) => AsyncResult<ISurfsideClientApi>;
2
+ import { type IMockSurfsideProduct } from './mock/Product';
3
+ export type { IMockSurfsideProduct } from './mock/Product';
4
+ export declare const InitSurfAdsCoreMock: (accountId: string, siteId: string, channelId: string, locationId: string, userId: string | undefined, logger?: ILogger, mockSponsoredProducts?: IMockSurfsideProduct[], mockRecommendedProducts?: IMockSurfsideProduct[], simulateNoResponse?: number, simulateNetworkLatency?: number) => AsyncResult<ISurfsideClientApi>;
@@ -1,3 +1,7 @@
1
1
  import { type AsyncResult, type IBidRequest, type IBidResponse, type ILogger, type INativeTemplateDelegateWindow, type Result } from '@surfside/ads-core';
2
- export declare const MockRequestBids: (logger: ILogger | undefined, windowInfo: INativeTemplateDelegateWindow, bidRequest: IBidRequest) => AsyncResult<IBidResponse>;
2
+ export declare const MockRequestBids: (logger: ILogger | undefined, windowInfo: INativeTemplateDelegateWindow, simulateNetworkLatency: number, simulateNoResponse: number, bidRequest: IBidRequest) => AsyncResult<IBidResponse>;
3
+ export declare const makeBannerImage: (w: number, h: number, message?: string) => Result<HTMLElement>;
3
4
  export declare const makeImage: (width: number, height: number, message?: string) => Result<HTMLElement>;
5
+ export declare class CanvasFailedError extends Error {
6
+ constructor();
7
+ }
@@ -1,2 +1,5 @@
1
1
  import { type AsyncResult, type IDynamicZone } from '@surfside/ads-core-client';
2
- export declare const MockGetDynamicZone: () => AsyncResult<IDynamicZone>;
2
+ export declare const MockGetDynamicZone: (zoneIdString: string) => AsyncResult<IDynamicZone>;
3
+ export declare const parseZoneIds: (zoneIds: string) => IDynamicZone;
4
+ export declare const videoZoneCreator: (zoneId: string) => IDynamicZone | undefined;
5
+ export declare const carouselZoneCreator: (zoneId: string) => IDynamicZone | undefined;
@@ -1,5 +1,25 @@
1
- import { type IBid, type IBuiltProductCardBidResponse, type ICompiledPublisherConfiguration, type ILogger, type INativeTemplateDelegateWindow, type AsyncResult, type IProductInformation } from '@surfside/ads-core';
2
- export declare function MockGetSposoredProduct(logger: ILogger | undefined, accountId: string): AsyncGenerator<IProductInformation>;
3
- export declare const MockGetAllSponsoredProducts: () => AsyncResult<IProductInformation[]>;
4
- export declare const MockGetRecommendedProduct: () => AsyncResult<IProductInformation>;
5
- export declare function MockGenerateSponsoredProductCard(logger: ILogger | undefined, windowInfo: INativeTemplateDelegateWindow, config: ICompiledPublisherConfiguration, accountId: string, bids: IBid[]): AsyncGenerator<IBuiltProductCardBidResponse>;
1
+ import { type IBid, type IBuiltProductCardBidResponse, type ICompiledPublisherConfiguration, type ILogger, type INativeTemplateDelegateWindow, type IProductInformation } from '@surfside/ads-core';
2
+ /**
3
+ * Super simple type with just id in case we want to expand upon this in the future.
4
+ */
5
+ export interface IMockSurfsideProduct {
6
+ id: string;
7
+ [key: string]: string;
8
+ }
9
+ export declare const FallbackSponsoredProducts: {
10
+ id: string;
11
+ name: string;
12
+ description: string;
13
+ brand: string;
14
+ }[];
15
+ export declare const FallbackRecommendedProducts: {
16
+ id: string;
17
+ name: string;
18
+ description: string;
19
+ brand: string;
20
+ }[];
21
+ export declare function withFallbackProducts<T>(provided: T[] | undefined | undefined, fallback: T[], label?: string, logger?: ILogger): T[];
22
+ export declare function MockGetSponsoredProduct(logger: ILogger | undefined, accountId: string, products: IMockSurfsideProduct[]): AsyncGenerator<IProductInformation>;
23
+ export declare const MockGetRecommendedProductFactory: (products: IProductInformation[]) => () => Promise<import("@surfside/ads-core").OkResult<IProductInformation>>;
24
+ export declare const MockGetAllSponsoredProductsFactory: (products: IMockSurfsideProduct[]) => () => Promise<import("@surfside/ads-core").OkResult<IProductInformation[]>>;
25
+ export declare function MockGenerateSponsoredProductCard(logger: ILogger | undefined, windowInfo: INativeTemplateDelegateWindow, config: ICompiledPublisherConfiguration, accountId: string, getSponsoredProductFactory: AsyncGenerator<IProductInformation>, bids: IBid[]): AsyncGenerator<IBuiltProductCardBidResponse>;
@@ -0,0 +1,5 @@
1
+ import { type Result } from '@surfside/ads-core-client';
2
+ export declare const GetRandom: <T>(arr: Array<T>) => Result<T>;
3
+ export declare class EmptyArrayError extends Error {
4
+ constructor();
5
+ }
@@ -0,0 +1 @@
1
+ export declare const Wait: (time: number) => Promise<unknown>;