@surfside/ads-core 1.0.6 → 2.0.2

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.
Files changed (293) hide show
  1. package/README.md +15 -64
  2. package/lib/cjs/Api.js +195 -0
  3. package/lib/cjs/Api.js.map +1 -0
  4. package/lib/cjs/helpers/Generator.js +50 -0
  5. package/lib/cjs/helpers/Generator.js.map +1 -0
  6. package/lib/cjs/helpers/Handlebars.js +270 -0
  7. package/lib/cjs/helpers/Handlebars.js.map +1 -0
  8. package/lib/cjs/helpers/NativeRequestBuilder.js +174 -0
  9. package/lib/cjs/helpers/NativeRequestBuilder.js.map +1 -0
  10. package/lib/cjs/helpers/RequestBuilder.js +160 -0
  11. package/lib/cjs/helpers/RequestBuilder.js.map +1 -0
  12. package/lib/cjs/helpers/TryGet.js +14 -0
  13. package/lib/cjs/helpers/TryGet.js.map +1 -0
  14. package/lib/cjs/helpers/Window.js +24 -0
  15. package/lib/cjs/helpers/Window.js.map +1 -0
  16. package/lib/cjs/helpers/index.js +24 -0
  17. package/lib/cjs/helpers/index.js.map +1 -0
  18. package/lib/cjs/helpers/response/Banner.js +4 -0
  19. package/lib/cjs/helpers/response/Banner.js.map +1 -0
  20. package/lib/cjs/helpers/response/BuiltResponse.js +27 -0
  21. package/lib/cjs/helpers/response/BuiltResponse.js.map +1 -0
  22. package/lib/cjs/helpers/response/Carousel.js +282 -0
  23. package/lib/cjs/helpers/response/Carousel.js.map +1 -0
  24. package/lib/cjs/helpers/response/Clickthrough.js +24 -0
  25. package/lib/cjs/helpers/response/Clickthrough.js.map +1 -0
  26. package/lib/cjs/helpers/response/ProductCard.js +198 -0
  27. package/lib/cjs/helpers/response/ProductCard.js.map +1 -0
  28. package/lib/cjs/helpers/response/Video.js +4 -0
  29. package/lib/cjs/helpers/response/Video.js.map +1 -0
  30. package/lib/cjs/helpers/response/index.js +23 -0
  31. package/lib/cjs/helpers/response/index.js.map +1 -0
  32. package/lib/cjs/index.js +21 -0
  33. package/lib/cjs/index.js.map +1 -0
  34. package/lib/cjs/models/dynamic/DynamicZone.js +12 -0
  35. package/lib/cjs/models/dynamic/DynamicZone.js.map +1 -0
  36. package/lib/cjs/models/dynamic/index.js +18 -0
  37. package/lib/cjs/models/dynamic/index.js.map +1 -0
  38. package/lib/cjs/models/index.js +22 -0
  39. package/lib/cjs/models/index.js.map +1 -0
  40. package/lib/cjs/models/retail/Configuration.js +10 -0
  41. package/lib/cjs/models/retail/Configuration.js.map +1 -0
  42. package/lib/cjs/models/retail/Product.js +4 -0
  43. package/lib/cjs/models/retail/Product.js.map +1 -0
  44. package/lib/cjs/models/retail/Recommended.js +3 -0
  45. package/lib/cjs/models/retail/Recommended.js.map +1 -0
  46. package/lib/cjs/models/retail/index.js +20 -0
  47. package/lib/cjs/models/retail/index.js.map +1 -0
  48. package/lib/cjs/models/rtb/BidRequest.js +20 -0
  49. package/lib/cjs/models/rtb/BidRequest.js.map +1 -0
  50. package/lib/cjs/models/rtb/BidResponse.js +3 -0
  51. package/lib/cjs/models/rtb/BidResponse.js.map +1 -0
  52. package/lib/cjs/models/rtb/NativeRequest.js +122 -0
  53. package/lib/cjs/models/rtb/NativeRequest.js.map +1 -0
  54. package/lib/cjs/models/rtb/NativeResponse.js +26 -0
  55. package/lib/cjs/models/rtb/NativeResponse.js.map +1 -0
  56. package/lib/cjs/models/rtb/index.js +21 -0
  57. package/lib/cjs/models/rtb/index.js.map +1 -0
  58. package/lib/cjs/models/tracking/Geo.js +3 -0
  59. package/lib/cjs/models/tracking/Geo.js.map +1 -0
  60. package/lib/cjs/models/tracking/index.js +18 -0
  61. package/lib/cjs/models/tracking/index.js.map +1 -0
  62. package/lib/cjs/models/vast/Vast.js +4 -0
  63. package/lib/cjs/models/vast/Vast.js.map +1 -0
  64. package/lib/cjs/models/vast/index.js +18 -0
  65. package/lib/cjs/models/vast/index.js.map +1 -0
  66. package/lib/cjs/services/Bidder.js +128 -0
  67. package/lib/cjs/services/Bidder.js.map +1 -0
  68. package/lib/cjs/services/Configuration.js +93 -0
  69. package/lib/cjs/services/Configuration.js.map +1 -0
  70. package/lib/cjs/services/Device.js +236 -0
  71. package/lib/cjs/services/Device.js.map +1 -0
  72. package/lib/cjs/services/Dynamic.js +129 -0
  73. package/lib/cjs/services/Dynamic.js.map +1 -0
  74. package/lib/cjs/services/Geo.js +35 -0
  75. package/lib/cjs/services/Geo.js.map +1 -0
  76. package/lib/cjs/services/Logger.js +57 -0
  77. package/lib/cjs/services/Logger.js.map +1 -0
  78. package/lib/cjs/services/Memoization.js +17 -0
  79. package/lib/cjs/services/Memoization.js.map +1 -0
  80. package/lib/cjs/services/Product.js +127 -0
  81. package/lib/cjs/services/Product.js.map +1 -0
  82. package/lib/cjs/services/Recommender.js +83 -0
  83. package/lib/cjs/services/Recommender.js.map +1 -0
  84. package/lib/cjs/services/Result.js +220 -0
  85. package/lib/cjs/services/Result.js.map +1 -0
  86. package/lib/cjs/services/Template.js +43 -0
  87. package/lib/cjs/services/Template.js.map +1 -0
  88. package/lib/cjs/services/index.js +28 -0
  89. package/lib/cjs/services/index.js.map +1 -0
  90. package/lib/cjs/services/mock/Bidder.js +3 -0
  91. package/lib/cjs/services/mock/Bidder.js.map +1 -0
  92. package/lib/cjs/services/mock/index.js +18 -0
  93. package/lib/cjs/services/mock/index.js.map +1 -0
  94. package/lib/esm/Api.js +183 -0
  95. package/lib/esm/Api.js.map +1 -0
  96. package/lib/esm/helpers/Generator.js +42 -0
  97. package/lib/esm/helpers/Generator.js.map +1 -0
  98. package/lib/esm/helpers/Handlebars.js +251 -0
  99. package/lib/esm/helpers/Handlebars.js.map +1 -0
  100. package/lib/esm/helpers/NativeRequestBuilder.js +169 -0
  101. package/lib/esm/helpers/NativeRequestBuilder.js.map +1 -0
  102. package/lib/esm/helpers/RequestBuilder.js +157 -0
  103. package/lib/esm/helpers/RequestBuilder.js.map +1 -0
  104. package/lib/esm/helpers/TryGet.js +10 -0
  105. package/lib/esm/helpers/TryGet.js.map +1 -0
  106. package/lib/esm/helpers/Window.js +20 -0
  107. package/lib/esm/helpers/Window.js.map +1 -0
  108. package/lib/esm/helpers/index.js +8 -0
  109. package/lib/esm/helpers/index.js.map +1 -0
  110. package/lib/esm/helpers/response/Banner.js +3 -0
  111. package/lib/esm/helpers/response/Banner.js.map +1 -0
  112. package/lib/esm/helpers/response/BuiltResponse.js +22 -0
  113. package/lib/esm/helpers/response/BuiltResponse.js.map +1 -0
  114. package/lib/esm/helpers/response/Carousel.js +273 -0
  115. package/lib/esm/helpers/response/Carousel.js.map +1 -0
  116. package/lib/esm/helpers/response/Clickthrough.js +20 -0
  117. package/lib/esm/helpers/response/Clickthrough.js.map +1 -0
  118. package/lib/esm/helpers/response/ProductCard.js +189 -0
  119. package/lib/esm/helpers/response/ProductCard.js.map +1 -0
  120. package/lib/esm/helpers/response/Video.js +3 -0
  121. package/lib/esm/helpers/response/Video.js.map +1 -0
  122. package/lib/esm/helpers/response/index.js +7 -0
  123. package/lib/esm/helpers/response/index.js.map +1 -0
  124. package/lib/esm/index.js +5 -0
  125. package/lib/esm/index.js.map +1 -0
  126. package/lib/esm/models/dynamic/DynamicZone.js +11 -0
  127. package/lib/esm/models/dynamic/DynamicZone.js.map +1 -0
  128. package/lib/esm/models/dynamic/index.js +2 -0
  129. package/lib/esm/models/dynamic/index.js.map +1 -0
  130. package/lib/esm/models/index.js +6 -0
  131. package/lib/esm/models/index.js.map +1 -0
  132. package/lib/esm/models/retail/Configuration.js +9 -0
  133. package/lib/esm/models/retail/Configuration.js.map +1 -0
  134. package/lib/esm/models/retail/Product.js +3 -0
  135. package/lib/esm/models/retail/Product.js.map +1 -0
  136. package/lib/esm/models/retail/Recommended.js +2 -0
  137. package/lib/esm/models/retail/Recommended.js.map +1 -0
  138. package/lib/esm/models/retail/index.js +4 -0
  139. package/lib/esm/models/retail/index.js.map +1 -0
  140. package/lib/esm/models/rtb/BidRequest.js +17 -0
  141. package/lib/esm/models/rtb/BidRequest.js.map +1 -0
  142. package/lib/esm/models/rtb/BidResponse.js +2 -0
  143. package/lib/esm/models/rtb/BidResponse.js.map +1 -0
  144. package/lib/esm/models/rtb/NativeRequest.js +119 -0
  145. package/lib/esm/models/rtb/NativeRequest.js.map +1 -0
  146. package/lib/esm/models/rtb/NativeResponse.js +23 -0
  147. package/lib/esm/models/rtb/NativeResponse.js.map +1 -0
  148. package/lib/esm/models/rtb/index.js +5 -0
  149. package/lib/esm/models/rtb/index.js.map +1 -0
  150. package/lib/esm/models/tracking/Geo.js +2 -0
  151. package/lib/esm/models/tracking/Geo.js.map +1 -0
  152. package/lib/esm/models/tracking/index.js +2 -0
  153. package/lib/esm/models/tracking/index.js.map +1 -0
  154. package/lib/esm/models/vast/Vast.js +3 -0
  155. package/lib/esm/models/vast/Vast.js.map +1 -0
  156. package/lib/esm/models/vast/index.js +2 -0
  157. package/lib/esm/models/vast/index.js.map +1 -0
  158. package/lib/esm/services/Bidder.js +119 -0
  159. package/lib/esm/services/Bidder.js.map +1 -0
  160. package/lib/esm/services/Configuration.js +56 -0
  161. package/lib/esm/services/Configuration.js.map +1 -0
  162. package/lib/esm/services/Device.js +232 -0
  163. package/lib/esm/services/Device.js.map +1 -0
  164. package/lib/esm/services/Dynamic.js +120 -0
  165. package/lib/esm/services/Dynamic.js.map +1 -0
  166. package/lib/esm/services/Geo.js +30 -0
  167. package/lib/esm/services/Geo.js.map +1 -0
  168. package/lib/esm/services/Logger.js +52 -0
  169. package/lib/esm/services/Logger.js.map +1 -0
  170. package/lib/esm/services/Memoization.js +13 -0
  171. package/lib/esm/services/Memoization.js.map +1 -0
  172. package/lib/esm/services/Product.js +120 -0
  173. package/lib/esm/services/Product.js.map +1 -0
  174. package/lib/esm/services/Recommender.js +78 -0
  175. package/lib/esm/services/Recommender.js.map +1 -0
  176. package/lib/esm/services/Result.js +199 -0
  177. package/lib/esm/services/Result.js.map +1 -0
  178. package/lib/esm/services/Template.js +38 -0
  179. package/lib/esm/services/Template.js.map +1 -0
  180. package/lib/esm/services/index.js +12 -0
  181. package/lib/esm/services/index.js.map +1 -0
  182. package/lib/esm/services/mock/Bidder.js +2 -0
  183. package/lib/esm/services/mock/Bidder.js.map +1 -0
  184. package/lib/esm/services/mock/index.js +2 -0
  185. package/lib/esm/services/mock/index.js.map +1 -0
  186. package/lib/types/Api.d.ts +169 -0
  187. package/lib/types/helpers/Generator.d.ts +5 -0
  188. package/lib/types/helpers/{handlebars/index.d.ts → Handlebars.d.ts} +10 -5
  189. package/lib/types/helpers/NativeRequestBuilder.d.ts +29 -0
  190. package/lib/types/helpers/RequestBuilder.d.ts +16 -0
  191. package/lib/types/helpers/TryGet.d.ts +2 -0
  192. package/lib/types/helpers/Window.d.ts +3 -0
  193. package/lib/types/helpers/index.d.ts +7 -4
  194. package/lib/types/helpers/response/Banner.d.ts +22 -0
  195. package/lib/types/helpers/response/BuiltResponse.d.ts +31 -0
  196. package/lib/types/helpers/response/Carousel.d.ts +51 -0
  197. package/lib/types/helpers/response/Clickthrough.d.ts +3 -0
  198. package/lib/types/helpers/response/ProductCard.d.ts +49 -0
  199. package/lib/types/helpers/response/Video.d.ts +17 -0
  200. package/lib/types/helpers/response/index.d.ts +6 -0
  201. package/lib/types/index.d.ts +2 -17
  202. package/lib/types/models/dynamic/DynamicZone.d.ts +37 -0
  203. package/lib/types/models/dynamic/index.d.ts +1 -0
  204. package/lib/types/models/index.d.ts +2 -1
  205. package/lib/types/models/retail/{IPublisherConfiguration.d.ts → Configuration.d.ts} +11 -9
  206. package/lib/types/models/retail/Product.d.ts +19 -0
  207. package/lib/types/models/retail/index.d.ts +3 -3
  208. package/lib/types/models/rtb/{IBidRequest.d.ts → BidRequest.d.ts} +28 -18
  209. package/lib/types/models/rtb/NativeRequest.d.ts +170 -0
  210. package/lib/types/models/rtb/{native/INativeResponse.d.ts → NativeResponse.d.ts} +5 -5
  211. package/lib/types/models/rtb/index.d.ts +4 -3
  212. package/lib/types/models/tracking/index.d.ts +1 -3
  213. package/lib/types/models/vast/Vast.d.ts +6 -9
  214. package/lib/types/services/Bidder.d.ts +31 -0
  215. package/lib/types/services/Configuration.d.ts +6 -0
  216. package/lib/types/services/Device.d.ts +12 -0
  217. package/lib/types/services/Dynamic.d.ts +26 -0
  218. package/lib/types/services/Geo.d.ts +6 -0
  219. package/lib/types/services/Logger.d.ts +14 -0
  220. package/lib/types/services/Memoization.d.ts +1 -0
  221. package/lib/types/services/Product.d.ts +13 -0
  222. package/lib/types/services/Recommender.d.ts +8 -0
  223. package/lib/types/services/Result.d.ts +57 -0
  224. package/lib/types/services/Template.d.ts +7 -0
  225. package/lib/types/services/index.d.ts +11 -5
  226. package/lib/types/services/mock/Bidder.d.ts +1 -0
  227. package/lib/types/services/mock/index.d.ts +1 -0
  228. package/package.json +42 -47
  229. package/lib/index.js +0 -1
  230. package/lib/types/constant-values/index.d.ts +0 -46
  231. package/lib/types/errors/index.d.ts +0 -3
  232. package/lib/types/helpers/generators/CollectN.d.ts +0 -2
  233. package/lib/types/helpers/generators/index.d.ts +0 -1
  234. package/lib/types/helpers/requests/RequestBuilder.d.ts +0 -124
  235. package/lib/types/helpers/requests/SimpleBannerRequest.d.ts +0 -26
  236. package/lib/types/helpers/requests/index.d.ts +0 -2
  237. package/lib/types/helpers/responses/BuildBannerResponse.d.ts +0 -10
  238. package/lib/types/helpers/responses/BuildNativeResponse.d.ts +0 -21
  239. package/lib/types/helpers/responses/BuildVideoResponse.d.ts +0 -0
  240. package/lib/types/helpers/responses/ClickthroughHelpers.d.ts +0 -2
  241. package/lib/types/helpers/responses/VastHelpers.d.ts +0 -4
  242. package/lib/types/helpers/responses/index.d.ts +0 -4
  243. package/lib/types/middleware/DeviceMiddleware.d.ts +0 -3
  244. package/lib/types/middleware/GeoMiddleware.d.ts +0 -3
  245. package/lib/types/middleware/IdentityMiddleware.d.ts +0 -4
  246. package/lib/types/middleware/index.d.ts +0 -3
  247. package/lib/types/models/retail/IProductInformation.d.ts +0 -37
  248. package/lib/types/models/rtb/native/Constants.d.ts +0 -60
  249. package/lib/types/models/rtb/native/INativeRequest.d.ts +0 -54
  250. package/lib/types/models/rtb/native/NativeConstants.d.ts +0 -120
  251. package/lib/types/models/rtb/native/NativeRequestBuilder.d.ts +0 -158
  252. package/lib/types/models/rtb/native/index.d.ts +0 -4
  253. package/lib/types/models/tracking/IEvents.d.ts +0 -82
  254. package/lib/types/models/tracking/IUserID.d.ts +0 -1
  255. package/lib/types/services/OverrideService.d.ts +0 -10
  256. package/lib/types/services/logger/ILoggerService.d.ts +0 -39
  257. package/lib/types/services/logger/LocalLoggerService.d.ts +0 -19
  258. package/lib/types/services/logger/index.d.ts +0 -2
  259. package/lib/types/services/product-feed/IProductFeedService.d.ts +0 -5
  260. package/lib/types/services/product-feed/SurfsideProductFeedService.d.ts +0 -11
  261. package/lib/types/services/product-feed/index.d.ts +0 -2
  262. package/lib/types/services/recommender/IRecommenderService.d.ts +0 -47
  263. package/lib/types/services/recommender/SurfsideRecommenderService.d.ts +0 -31
  264. package/lib/types/services/recommender/index.d.ts +0 -2
  265. package/lib/types/services/rtb/bidder/IBidderService.d.ts +0 -12
  266. package/lib/types/services/rtb/bidder/SurfsideBidderService.d.ts +0 -28
  267. package/lib/types/services/rtb/bidder/index.d.ts +0 -2
  268. package/lib/types/services/rtb/configuration/IConfigurationService.d.ts +0 -14
  269. package/lib/types/services/rtb/configuration/SurfsideConfigurationService.d.ts +0 -29
  270. package/lib/types/services/rtb/configuration/index.d.ts +0 -2
  271. package/lib/types/services/rtb/index.d.ts +0 -2
  272. package/lib/types/services/tracking/device/DeviceOverrideService.d.ts +0 -8
  273. package/lib/types/services/tracking/device/IDeviceService.d.ts +0 -4
  274. package/lib/types/services/tracking/device/SurfsideDeviceService.d.ts +0 -16
  275. package/lib/types/services/tracking/device/index.d.ts +0 -3
  276. package/lib/types/services/tracking/events/IEventService.d.ts +0 -5
  277. package/lib/types/services/tracking/events/SurfsideEventService.d.ts +0 -42
  278. package/lib/types/services/tracking/events/index.d.ts +0 -2
  279. package/lib/types/services/tracking/geo/GeoOverrideService.d.ts +0 -8
  280. package/lib/types/services/tracking/geo/IGeoService.d.ts +0 -12
  281. package/lib/types/services/tracking/geo/SurfsideGeoService.d.ts +0 -7
  282. package/lib/types/services/tracking/geo/index.d.ts +0 -3
  283. package/lib/types/services/tracking/index.d.ts +0 -4
  284. package/lib/types/services/tracking/user/IUserIDService.d.ts +0 -4
  285. package/lib/types/services/tracking/user/SurfsideUserIDService.d.ts +0 -7
  286. package/lib/types/services/tracking/user/UserOverrideService.d.ts +0 -8
  287. package/lib/types/services/tracking/user/index.d.ts +0 -3
  288. package/lib/types/utils/Protocol.d.ts +0 -1
  289. package/lib/types/utils/Rendering.d.ts +0 -44
  290. package/lib/types/utils/index.d.ts +0 -2
  291. /package/lib/types/models/retail/{IRecommenderResponse.d.ts → Recommended.d.ts} +0 -0
  292. /package/lib/types/models/rtb/{IBidResponse.d.ts → BidResponse.d.ts} +0 -0
  293. /package/lib/types/models/tracking/{IGeoContext.d.ts → Geo.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TryGet.js","sourceRoot":"src/","sources":["helpers/TryGet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAe,MAAM,aAAa,CAAC;AAEnD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAI,GAAY,EAAa,EAAE;IACjD,IAAI,CAAC;QACD,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,GAAG,CAAC,KAAc,CAAC,CAAC;IAC/B,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { NotABrowserError } from '../Api';
2
+ import { Err, Ok } from '../services';
3
+ export const GetWindowInfo = () => {
4
+ if ((typeof window) === 'undefined') {
5
+ return Err(new NotABrowserError());
6
+ }
7
+ ;
8
+ return Ok({
9
+ href: window.location.href,
10
+ origin: window.location.origin,
11
+ port: window.location.port,
12
+ path: '/' + window.location.pathname.split('/').filter(part => part.length > 0).join('/'),
13
+ host: window.location.host,
14
+ host_name: window.location.hostname,
15
+ search: window.location.search,
16
+ hash: window.location.hash,
17
+ protocol: window.location.protocol
18
+ });
19
+ };
20
+ //# sourceMappingURL=Window.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Window.js","sourceRoot":"src/","sources":["helpers/Window.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAE1C,OAAO,EAAE,GAAG,EAAE,EAAE,EAAe,MAAM,aAAa,CAAC;AAEnD,MAAM,CAAC,MAAM,aAAa,GAAG,GAA0C,EAAE;IACrE,IAAI,CAAC,OAAO,MAAM,CAAC,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,GAAG,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAC;IACvC,CAAC;IAAA,CAAC;IACF,OAAO,EAAE,CAAC;QACN,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;QAC1B,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;QAC9B,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;QAC1B,IAAI,EAAE,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QACzF,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;QAC1B,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ;QACnC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;QAC9B,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;QAC1B,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ;KACrC,CAAC,CAAC;AACP,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export * from './NativeRequestBuilder';
2
+ export * from './RequestBuilder';
3
+ export * from './response';
4
+ export * from './Handlebars';
5
+ export * from './TryGet';
6
+ export * from './Window';
7
+ export * from './Generator';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"src/","sources":["helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ ;
2
+ export {};
3
+ //# sourceMappingURL=Banner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Banner.js","sourceRoot":"src/","sources":["helpers/response/Banner.ts"],"names":[],"mappings":"AAsBC,CAAC"}
@@ -0,0 +1,22 @@
1
+ export const CreativeType = {
2
+ Banner: 0,
3
+ Video: 1,
4
+ ProductCard: 2,
5
+ Carousel: 3
6
+ };
7
+ ;
8
+ export class MissingAdmError extends Error {
9
+ bid;
10
+ constructor(bid) {
11
+ super('Cannot build creative; missing adm field');
12
+ this.bid = bid;
13
+ }
14
+ }
15
+ export class MissingProductError extends Error {
16
+ bid;
17
+ constructor(bid) {
18
+ super('Could not find product data for creative while building clickthrough URL. Some data fields are missing');
19
+ this.bid = bid;
20
+ }
21
+ }
22
+ //# sourceMappingURL=BuiltResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuiltResponse.js","sourceRoot":"src/","sources":["helpers/response/BuiltResponse.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,CAAC;IACR,WAAW,EAAE,CAAC;IACd,QAAQ,EAAE,CAAC;CACL,CAAC;AAiBV,CAAC;AAEF,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACV;IAA5B,YAA4B,GAAgB;QACxC,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAD1B,QAAG,GAAH,GAAG,CAAa;IAE5C,CAAC;CACJ;AAED,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACd;IAA5B,YAA4B,GAAU;QAClC,KAAK,CAAC,wGAAwG,CAAC,CAAC;QADxF,QAAG,GAAH,GAAG,CAAO;IAEtC,CAAC;CACJ"}
@@ -0,0 +1,273 @@
1
+ import { Ctx, Ok } from '../../services';
2
+ ;
3
+ ;
4
+ ;
5
+ ;
6
+ export const BuildSponsoredCarousel = (logger, requestBids, generateProductCardResponse, request) => {
7
+ const log = Ctx(logger)?.with('BuildSponsoredCarousel');
8
+ log?.info('Building sponsored carousel');
9
+ return Ok({
10
+ type: 'carousel',
11
+ getProduct: getNextSponsoredCarouselProduct.bind(undefined, log, requestBids, generateProductCardResponse, request)
12
+ });
13
+ };
14
+ export const BuildSponsoredCarouselFromInitialBid = (logger, requestBids, generateProductCardResponse, request, initialBid) => {
15
+ const log = Ctx(logger)?.with('BuildSponsoredCarouselFromInitialBid');
16
+ log?.info('Building sponsored carousel from initial bid');
17
+ return Ok({
18
+ type: 'carousel',
19
+ getProduct: getNextSponsoredCarouselProductFromInitialBid.bind(undefined, log, requestBids, request, initialBid, generateProductCardResponse)
20
+ });
21
+ };
22
+ export const BuildRecommendedCarousel = (logger, evaluateClickthroughTemplate, topProductGenerator, forYouProductGenerator, pastPurchasesProductGenerator, userId, recommenderType) => {
23
+ switch (recommenderType.type) {
24
+ case 'top-products': {
25
+ return buildRecommendedCarouselInternal(logger, evaluateClickthroughTemplate, {
26
+ recommenderType: 'top-products',
27
+ topProductGenerator
28
+ });
29
+ }
30
+ case 'for-you': {
31
+ return buildRecommendedCarouselInternal(logger, evaluateClickthroughTemplate, {
32
+ recommenderType: 'for-you',
33
+ forYouProductGenerator,
34
+ topProductGenerator,
35
+ userId
36
+ });
37
+ }
38
+ case 'past-purchases': {
39
+ return buildRecommendedCarouselInternal(logger, evaluateClickthroughTemplate, {
40
+ recommenderType: 'past-purchases',
41
+ pastPurchasesProductGenerator,
42
+ topProductGenerator,
43
+ userId
44
+ });
45
+ }
46
+ }
47
+ };
48
+ const buildRecommendedCarouselInternal = (logger, evaluateClickthroughTemplate, recommenderType) => {
49
+ const log = Ctx(logger)?.with('buildRecommendedCarouselInternal');
50
+ log?.info('Building Recommended Carousel');
51
+ return Ok({
52
+ type: 'carousel',
53
+ getProduct: getNextRecommendedCarouselProduct.bind(undefined, log, evaluateClickthroughTemplate, recommenderType)
54
+ });
55
+ };
56
+ export const BuildHybridCarousel = (logger, evaluateClickthroughTemplate, requestBids, generateProductCardResponse, topProductGenerator, forYouProductGenerator, pastPurchasesProductGenerator, userId, recommenderType, request) => {
57
+ switch (recommenderType.type) {
58
+ case 'top-products': {
59
+ return buildHybridCarouselInternal(logger, evaluateClickthroughTemplate, requestBids, generateProductCardResponse, request, {
60
+ recommenderType: 'top-products',
61
+ topProductGenerator
62
+ });
63
+ }
64
+ case 'for-you': {
65
+ return buildHybridCarouselInternal(logger, evaluateClickthroughTemplate, requestBids, generateProductCardResponse, request, {
66
+ recommenderType: 'for-you',
67
+ forYouProductGenerator,
68
+ topProductGenerator,
69
+ userId
70
+ });
71
+ }
72
+ case 'past-purchases': {
73
+ return buildHybridCarouselInternal(logger, evaluateClickthroughTemplate, requestBids, generateProductCardResponse, request, {
74
+ recommenderType: 'past-purchases',
75
+ pastPurchasesProductGenerator,
76
+ topProductGenerator,
77
+ userId
78
+ });
79
+ }
80
+ }
81
+ };
82
+ export const BuildHybridCarouselFromInitialBid = (logger, evaluateClickthroughTemplate, requestBids, generateProductCardResponse, topProductGenerator, forYouProductGenerator, pastPurchasesProductGenerator, userId, recommenderType, request, initialBid) => {
83
+ switch (recommenderType.type) {
84
+ case 'top-products': {
85
+ return buildHybridCarouselFromInitialBidInternal(logger, evaluateClickthroughTemplate, requestBids, generateProductCardResponse, request, initialBid, {
86
+ recommenderType: 'top-products',
87
+ topProductGenerator
88
+ });
89
+ }
90
+ case 'for-you': {
91
+ return buildHybridCarouselFromInitialBidInternal(logger, evaluateClickthroughTemplate, requestBids, generateProductCardResponse, request, initialBid, {
92
+ recommenderType: 'for-you',
93
+ forYouProductGenerator,
94
+ topProductGenerator,
95
+ userId
96
+ });
97
+ }
98
+ case 'past-purchases': {
99
+ return buildHybridCarouselFromInitialBidInternal(logger, evaluateClickthroughTemplate, requestBids, generateProductCardResponse, request, initialBid, {
100
+ recommenderType: 'past-purchases',
101
+ pastPurchasesProductGenerator,
102
+ topProductGenerator,
103
+ userId
104
+ });
105
+ }
106
+ }
107
+ };
108
+ const buildHybridCarouselInternal = (logger, evaluateClickthroughTemplate, requestBids, generateProductCardResponse, request, recommenderType) => {
109
+ const log = Ctx(logger)?.with('BuildHybridCarousel');
110
+ log?.info('Building hybrid carousel', request, recommenderType);
111
+ return Ok({
112
+ type: 'carousel',
113
+ getProduct: getNextHybridCarouselProduct.bind(undefined, log, evaluateClickthroughTemplate, requestBids, generateProductCardResponse, request, recommenderType)
114
+ });
115
+ };
116
+ const buildHybridCarouselFromInitialBidInternal = (logger, evaluateClickthroughTemplate, requestBids, generateProductCardResponse, request, initialBid, recommenderType) => {
117
+ const log = Ctx(logger)?.with('BuildHybridCarouselFromInitialBid');
118
+ log?.info('Building hybrid carousel from bid', request, recommenderType, initialBid);
119
+ return Ok({
120
+ type: 'carousel',
121
+ getProduct: getNextHybridCarouselProductFromInitialBid.bind(undefined, log, evaluateClickthroughTemplate, requestBids, generateProductCardResponse, request, initialBid, recommenderType)
122
+ });
123
+ };
124
+ async function* getNextHybridCarouselProduct(logger, evaluateClickthroughTemplate, requestBids, generateProductCardResponse, request, recommenderType) {
125
+ const log = Ctx(logger)?.with('getNextHybridCarouselProduct');
126
+ log?.info('Entering hybrid carousel product generator');
127
+ yield* getNextSponsoredCarouselProduct(log, requestBids, generateProductCardResponse, request);
128
+ log?.info('Done getting next sponsoredCarouselProduct');
129
+ yield* getNextRecommendedCarouselProduct(log, evaluateClickthroughTemplate, recommenderType);
130
+ }
131
+ async function* getNextHybridCarouselProductFromInitialBid(logger, evaluateClickthroughTemplate, requestBids, generateProductCardResponse, request, initialBid, recommenderType) {
132
+ const log = Ctx(logger)?.with('getNextHybridCarouselProduct');
133
+ log?.info('Entering hybrid carousel product generator');
134
+ yield* getNextSponsoredCarouselProductFromInitialBid(log, requestBids, request, initialBid, generateProductCardResponse);
135
+ log?.info('Done getting next sponsoredCarouselProduct');
136
+ yield* getNextRecommendedCarouselProduct(log, evaluateClickthroughTemplate, recommenderType);
137
+ }
138
+ async function* getNextSponsoredCarouselProduct(logger, requestBids, generateProductCardResponse, request) {
139
+ const log = Ctx(logger)?.with('getNextSponsoredCarouselProduct');
140
+ try {
141
+ log?.info('Entering sponsored carousel product generator');
142
+ while (true) {
143
+ log?.info('Getting next sponsored carousel products', request);
144
+ const response = await requestBids(request);
145
+ if (!response.ok) {
146
+ log?.info('No response from bidder', response.error);
147
+ return;
148
+ }
149
+ const bids = response.value.seatbid?.[0]?.bid;
150
+ if (bids === undefined) {
151
+ log?.info('Got no bids in response!');
152
+ return;
153
+ }
154
+ const generator = generateProductCardResponse(bids);
155
+ for await (const product of generator) {
156
+ log?.debug('Getting next product from existing bidder response', product);
157
+ yield product;
158
+ }
159
+ log?.debug('Out of bids from previous response. Requesting new bid response');
160
+ return;
161
+ }
162
+ }
163
+ catch (err) {
164
+ log?.error('product carousel generator failed! Got', err);
165
+ }
166
+ finally {
167
+ log?.warn('Exiting carousel product generator');
168
+ }
169
+ }
170
+ async function* getNextSponsoredCarouselProductFromInitialBid(logger, requestBids, request, initialBid, generateProductCardResponse) {
171
+ const log = Ctx(logger)?.with('getNextSponsoredCarouselProductFromResponse');
172
+ log?.info('Generating sponsored product cards from initial bid response');
173
+ log?.debug(initialBid);
174
+ yield* generateProductCardResponse([initialBid]);
175
+ yield* getNextSponsoredCarouselProduct(logger, requestBids, generateProductCardResponse, request);
176
+ }
177
+ ;
178
+ async function* getNextRecommendedCarouselProduct(logger, evaluateClickthroughTemplate, recommenderType) {
179
+ const log = Ctx(logger)?.with('getNextRecommendedCarouselProduct');
180
+ log?.info('Entering recommended carousel product generator');
181
+ log?.info('Getting next recommended carousel product');
182
+ switch (recommenderType.recommenderType) {
183
+ case 'top-products': {
184
+ yield* getNextTopAllRecommendedCarouselProduct(log, evaluateClickthroughTemplate, recommenderType);
185
+ return;
186
+ }
187
+ case 'for-you': {
188
+ if (recommenderType.userId !== undefined) {
189
+ yield* getNextForYouRecommendedCarouselProduct(log, evaluateClickthroughTemplate, recommenderType, recommenderType.userId);
190
+ }
191
+ break;
192
+ }
193
+ case 'past-purchases': {
194
+ if (recommenderType.userId !== undefined) {
195
+ yield* getNextPastPurchasesRecommendedCarouselProduct(log, evaluateClickthroughTemplate, recommenderType, recommenderType.userId);
196
+ }
197
+ break;
198
+ }
199
+ }
200
+ /* fallback case if the other ones yield nothing, or if user ID is not set */
201
+ yield* getNextTopAllRecommendedCarouselProduct(log, evaluateClickthroughTemplate, {
202
+ recommenderType: 'top-products',
203
+ topProductGenerator: recommenderType.topProductGenerator
204
+ });
205
+ }
206
+ async function* getNextTopAllRecommendedCarouselProduct(logger, evaluateClickthroughTemplate, recommenderType) {
207
+ const log = Ctx(logger)?.with('getNextTopAllRecommendedCarouselProduct');
208
+ log?.info('Getting next top all product');
209
+ for await (const product of recommenderType.topProductGenerator()) {
210
+ const built = recommendedProductToBuiltProduct(log, evaluateClickthroughTemplate, product);
211
+ if (!built.ok) {
212
+ log?.warn('Failed to build product response from recommended product. Skipping this one', product);
213
+ continue;
214
+ }
215
+ yield built.value;
216
+ }
217
+ }
218
+ async function* getNextForYouRecommendedCarouselProduct(logger, evaluateClickthroughTemplate, recommenderType, userId) {
219
+ const log = Ctx(logger)?.with('getNextForYouRecommendedCarouselProduct');
220
+ log?.info('Getting next "for-you" recommended product');
221
+ for await (const product of recommenderType.forYouProductGenerator(userId)) {
222
+ const built = recommendedProductToBuiltProduct(log, evaluateClickthroughTemplate, product);
223
+ if (!built.ok) {
224
+ log?.warn('Failed to build product response from recommended product. Skipping this one', product);
225
+ continue;
226
+ }
227
+ yield built.value;
228
+ }
229
+ /* Use top-all as fallback */
230
+ yield* getNextTopAllRecommendedCarouselProduct(log, evaluateClickthroughTemplate, {
231
+ recommenderType: 'top-products',
232
+ topProductGenerator: recommenderType.topProductGenerator
233
+ });
234
+ }
235
+ async function* getNextPastPurchasesRecommendedCarouselProduct(logger, evaluateClickthroughTemplate, recommenderType, userId) {
236
+ const log = Ctx(logger)?.with('getNextPastPurchasesRecommendedCarouselProduct');
237
+ log?.info('Getting next "buy-again" recommended product');
238
+ for await (const product of recommenderType.pastPurchasesProductGenerator(userId)) {
239
+ const built = recommendedProductToBuiltProduct(log, evaluateClickthroughTemplate, product);
240
+ if (!built.ok) {
241
+ log?.warn('Failed to build product response from recommended product. Skipping this one', product);
242
+ continue;
243
+ }
244
+ yield built.value;
245
+ }
246
+ yield* getNextTopAllRecommendedCarouselProduct(log, evaluateClickthroughTemplate, {
247
+ recommenderType: 'top-products',
248
+ topProductGenerator: recommenderType.topProductGenerator
249
+ });
250
+ }
251
+ const recommendedProductToBuiltProduct = (logger, evaluateClickthroughTemplate, product) => {
252
+ const log = Ctx(logger)?.with('recommendedProductToBuiltProduct');
253
+ log?.info('Converting recommended product to built product card response');
254
+ const clickthrough = evaluateClickthroughTemplate(product);
255
+ if (!clickthrough.ok) {
256
+ return clickthrough;
257
+ }
258
+ return Ok({
259
+ type: 'product-card',
260
+ clickthrough: clickthrough.value + '_recommended',
261
+ product,
262
+ sponsored: false
263
+ });
264
+ };
265
+ export class InvalidRecommenderTypeError extends Error {
266
+ type;
267
+ constructor(type) {
268
+ super('Could not generate carousel; invalid recommender type "' + type + '"');
269
+ this.type = type;
270
+ }
271
+ }
272
+ ;
273
+ //# sourceMappingURL=Carousel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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ACJ,CAAC;AACN,CAAC;AAED,MAAM,gCAAgC,GAAG,CACrC,MAA2B,EAC3B,4BAA4D,EAC5D,OAA4B,EACK,EAAE;IACnC,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,kCAAkC,CAAC,CAAC;IAClE,GAAG,EAAE,IAAI,CAAC,+DAA+D,CAAC,CAAC;IAE3E,MAAM,YAAY,GAAG,4BAA4B,CAAC,OAAO,CAAC,CAAC;IAC3D,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC;QACnB,OAAO,YAAY,CAAC;IACxB,CAAC;IACD,OAAO,EAAE,CAAC;QACN,IAAI,EAAE,cAAc;QACpB,YAAY,EAAE,YAAY,CAAC,KAAK,GAAG,cAAc;QACjD,OAAO;QACP,SAAS,EAAE,KAAK;KACnB,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IAC/B;IAAnB,YAAmB,IAAY;QAC3B,KAAK,CAAC,yDAAyD,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC;QAD/D,SAAI,GAAJ,IAAI,CAAQ;IAE/B,CAAC;CACJ;AAAA,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { Ctx, Err, Ok } from '../../services';
2
+ export const BuildClickthroughUrl = (logger, windowInfo, configuration, product) => {
3
+ const log = Ctx(logger)?.with('BuildClickthroughUrl');
4
+ log?.info('Building clickthrough URL');
5
+ log?.debug(windowInfo, product, configuration);
6
+ try {
7
+ return Ok(configuration.templates.clickThroughUrlTemplate({
8
+ product,
9
+ catalog: product,
10
+ window: windowInfo,
11
+ publisher: configuration,
12
+ ...product
13
+ }));
14
+ }
15
+ catch (e) {
16
+ log?.error('Failed to execute clickthrough URL template', product, configuration, windowInfo);
17
+ return Err(e);
18
+ }
19
+ };
20
+ //# sourceMappingURL=Clickthrough.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Clickthrough.js","sourceRoot":"src/","sources":["helpers/response/Clickthrough.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAgB,EAAE,EAAe,MAAM,gBAAgB,CAAC;AAEzE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAChC,MAA2B,EAC3B,UAAyC,EACzC,aAA8C,EAC9C,OAA4B,EACd,EAAE;IAChB,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACtD,GAAG,EAAE,IAAI,CAAC,2BAA2B,CAAC,CAAC;IACvC,GAAG,EAAE,KAAK,CACN,UAAU,EACV,OAAO,EACP,aAAa,CAChB,CAAC;IACF,IAAI,CAAC;QACD,OAAO,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC,uBAAuB,CAAC;YACtD,OAAO;YACP,OAAO,EAAE,OAAO;YAChB,MAAM,EAAE,UAAU;YAClB,SAAS,EAAE,aAAa;YACxB,GAAG,OAAO;SACb,CAAC,CAAC,CAAC;IACR,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,GAAG,EAAE,KAAK,CAAC,6CAA6C,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;QAC9F,OAAO,GAAG,CAAC,CAAU,CAAC,CAAC;IAC3B,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,189 @@
1
+ import { EventTrackingMethods, EventTypes, NativeAssetId } from '../../models';
2
+ import { Ctx, Err, Ok, TryDo } from '../../services';
3
+ import { ConsumeAllAsync, GenerateArray } from '../Generator';
4
+ import { TryGet } from '../TryGet';
5
+ import { MissingAdmError } from './BuiltResponse';
6
+ import { BuildClickthroughUrl } from './Clickthrough';
7
+ ;
8
+ ;
9
+ ;
10
+ ;
11
+ export const BuildAllSponsoredProductCardResponses = async (logger, getAllSponsoredProducts, windowInfo, configuration, bids) => {
12
+ const log = Ctx(logger)?.with('BuildProductCardResponse');
13
+ log?.info('Building product card responses');
14
+ if (bids === undefined || bids === null) {
15
+ return Err(new MissingBidsError());
16
+ }
17
+ const bidPromises = bids.map(buildAllProductCardResponsesFromBid.bind(undefined, log, getAllSponsoredProducts, windowInfo, configuration));
18
+ const productCardResponseResults = await Promise.allSettled(bidPromises);
19
+ productCardResponseResults
20
+ .filter(res => res.status === 'rejected')
21
+ .map(res => res.reason)
22
+ .forEach(err => log?.warn(err));
23
+ const fulfilled = productCardResponseResults
24
+ .filter(res => res.status === 'fulfilled');
25
+ fulfilled
26
+ .filter(res => !res.value.ok)
27
+ .map(res => res.value)
28
+ .map(res => res.error)
29
+ .forEach(err => log?.warn(err));
30
+ return Ok(productCardResponseResults
31
+ .filter(res => res.status === 'fulfilled')
32
+ .filter(res => res.value.ok)
33
+ .map(res => res.value)
34
+ .flatMap(res => res.value));
35
+ };
36
+ export async function* GenerateSponsoredProductCardResponse(logger, getAllSponsoredProducts, windowInfo, configuration, bids) {
37
+ const log = Ctx(logger)?.with('GenerateProductCardResponse');
38
+ log?.info('Entering product card response generator', bids);
39
+ for (const bid of bids) {
40
+ log?.info('Generating product card response', bid);
41
+ const result = await buildAllProductCardResponsesFromBid(log, getAllSponsoredProducts, windowInfo, configuration, bid);
42
+ if (!result.ok) {
43
+ log?.warn(result.error);
44
+ continue;
45
+ }
46
+ yield* GenerateArray(result.value);
47
+ }
48
+ }
49
+ const getField = (native) => (id) => native.native.assets
50
+ ?.find(asset => asset.id === id)
51
+ ?.data
52
+ ?.value;
53
+ const getTrackers = (logger, bid, native) => {
54
+ const log = Ctx(logger)?.with('getTrackers');
55
+ log?.info('Getting trackers');
56
+ const win = bid.nurl;
57
+ if (win === undefined) {
58
+ return Err(new MissingWinUrlError(bid));
59
+ }
60
+ const imp = native.native.eventtrackers
61
+ ?.filter(tracker => tracker.event === EventTypes.Imp && tracker.method === EventTrackingMethods.Img)
62
+ .map(tracker => tracker.url)
63
+ .filter(url => url !== undefined) ?? [];
64
+ const others = native.native.eventtrackers
65
+ ?.filter(tracker => tracker.url !== undefined)
66
+ .map(tracker => ({
67
+ type: tracker.method,
68
+ url: tracker.url
69
+ })) ?? [];
70
+ return Ok({ win, imp, others });
71
+ };
72
+ const fetchProductsFromBid = async (logger, getAllSponsoredProducts, bid) => {
73
+ try {
74
+ const log = Ctx(logger)?.with('fetchProductsFromBid');
75
+ log?.info('Fetching products from IBid');
76
+ if (bid.adm === undefined) {
77
+ log?.warn('Bid is missing ADM', bid);
78
+ return Err(new MissingAdmError(bid));
79
+ }
80
+ const adm = bid.adm; // save it here to make it effectively final;
81
+ const nativeRes = TryGet(() => JSON.parse(adm));
82
+ if (!nativeRes.ok) {
83
+ log?.error('Bid adm failed to deserialize', bid, adm);
84
+ return Err(new MalformedNativeResponseError(bid));
85
+ }
86
+ const native = nativeRes.value;
87
+ const metaProductId = getField(native)(NativeAssetId.SurfMetaBrand);
88
+ if (metaProductId === undefined) {
89
+ return Err(new MissingProductIdError(bid, native));
90
+ }
91
+ const productRes = await getAllSponsoredProducts(metaProductId);
92
+ if (!productRes.ok) {
93
+ return productRes;
94
+ }
95
+ return Ok({
96
+ products: productRes.value,
97
+ native
98
+ });
99
+ }
100
+ catch (err) {
101
+ return Err(err);
102
+ }
103
+ };
104
+ function* buildProductCardResponseFromProductInfo(logger, windowInfo, configuration, bid, native, products) {
105
+ const log = Ctx(logger)?.with('buildProductCardResponseFromProductInfo');
106
+ for (const product of products) {
107
+ const clickthrough = BuildClickthroughUrl(log, windowInfo, configuration, product);
108
+ if (!clickthrough.ok) {
109
+ return clickthrough;
110
+ }
111
+ const trackers = getTrackers(log, bid, native);
112
+ if (!trackers.ok) {
113
+ return trackers;
114
+ }
115
+ const finalClickthrough = TryDo(() => {
116
+ const bidderClickthrough = new URL(native.native.link.url);
117
+ bidderClickthrough.searchParams.set('url', clickthrough.value);
118
+ return bidderClickthrough.toString();
119
+ });
120
+ if (!finalClickthrough.ok) {
121
+ return finalClickthrough;
122
+ }
123
+ yield {
124
+ type: 'product-card',
125
+ native,
126
+ product,
127
+ bid,
128
+ clickthrough: finalClickthrough.value,
129
+ trackers: trackers.value,
130
+ sponsored: true
131
+ };
132
+ }
133
+ }
134
+ const buildAllProductCardResponsesFromBid = async (logger, getAllSponsoredProducts, windowInfo, configuration, bid) => {
135
+ const log = Ctx(logger)?.with('buildAllProductCardResponseBids');
136
+ log?.info('Building all product card responses');
137
+ try {
138
+ return Ok(await ConsumeAllAsync(generateProductCardResponseFromBid(log, getAllSponsoredProducts, windowInfo, configuration, bid)));
139
+ }
140
+ catch (err) {
141
+ return Err(err);
142
+ }
143
+ };
144
+ async function* generateProductCardResponseFromBid(logger, getAllSponsoredProducts, windowInfo, configuration, bid) {
145
+ const log = Ctx(logger)?.with('generateProductCardResponseFromBid');
146
+ log?.info('generating product card response from bid');
147
+ try {
148
+ const productResult = await fetchProductsFromBid(log, getAllSponsoredProducts, bid);
149
+ if (!productResult.ok) {
150
+ log?.info('No products!');
151
+ return productResult;
152
+ }
153
+ const { products, native } = productResult.value;
154
+ yield* buildProductCardResponseFromProductInfo(log, windowInfo, configuration, bid, native, products);
155
+ }
156
+ catch (err) {
157
+ log?.error(err);
158
+ return;
159
+ }
160
+ }
161
+ export class MissingBidsError extends Error {
162
+ constructor() {
163
+ super('Unable to build product cards - no bids were provided');
164
+ }
165
+ }
166
+ export class MalformedNativeResponseError extends Error {
167
+ bid;
168
+ constructor(bid) {
169
+ super('Unable to build product card - missing native response');
170
+ this.bid = bid;
171
+ }
172
+ }
173
+ export class MissingWinUrlError extends Error {
174
+ bid;
175
+ constructor(bid) {
176
+ super('Unable to build product card - no win URL was provided');
177
+ this.bid = bid;
178
+ }
179
+ }
180
+ export class MissingProductIdError extends Error {
181
+ bid;
182
+ native;
183
+ constructor(bid, native) {
184
+ super('Unable to build product card - no product ID was provided');
185
+ this.bid = bid;
186
+ this.native = native;
187
+ }
188
+ }
189
+ //# sourceMappingURL=ProductCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductCard.js","sourceRoot":"src/","sources":["helpers/response/ProductCard.ts"],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nD,QAAG,GAAH,GAAG,CAAM;QACT,WAAM,GAAN,MAAM,CAAiB;IAG3C,CAAC;CACJ"}
@@ -0,0 +1,3 @@
1
+ ;
2
+ export {};
3
+ //# sourceMappingURL=Video.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Video.js","sourceRoot":"src/","sources":["helpers/response/Video.ts"],"names":[],"mappings":"AAmBC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from './BuiltResponse';
2
+ export * from './Banner';
3
+ export * from './Clickthrough';
4
+ export * from './ProductCard';
5
+ export * from './Video';
6
+ export * from './Carousel';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"src/","sources":["helpers/response/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './helpers';
2
+ export * from './models';
3
+ export * from './services';
4
+ export * from './Api';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC"}
@@ -0,0 +1,11 @@
1
+ ;
2
+ ;
3
+ ;
4
+ ;
5
+ ;
6
+ ;
7
+ ;
8
+ ;
9
+ ;
10
+ export {};
11
+ //# sourceMappingURL=DynamicZone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DynamicZone.js","sourceRoot":"src/","sources":["models/dynamic/DynamicZone.ts"],"names":[],"mappings":"AAEC,CAAC;AAKD,CAAC;AAKD,CAAC;AAKD,CAAC;AAKD,CAAC;AAMD,CAAC;AAID,CAAC;AAID,CAAC;AAOD,CAAC"}