@surfside/ads-core 2.0.1 → 2.0.3

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 (274) hide show
  1. package/README.md +15 -15
  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 +313 -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 -3488
  33. package/lib/cjs/index.js.map +1 -54
  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 +294 -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 -3460
  125. package/lib/esm/index.js.map +1 -54
  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 +5 -5
  187. package/lib/types/helpers/Handlebars.d.ts +58 -15
  188. package/lib/types/helpers/NativeRequestBuilder.d.ts +1 -1
  189. package/lib/types/helpers/RequestBuilder.d.ts +1 -1
  190. package/lib/types/helpers/TryGet.d.ts +1 -1
  191. package/lib/types/helpers/Window.d.ts +2 -2
  192. package/lib/types/helpers/response/Banner.d.ts +1 -1
  193. package/lib/types/helpers/response/BuiltResponse.d.ts +1 -1
  194. package/lib/types/helpers/response/Carousel.d.ts +1 -1
  195. package/lib/types/helpers/response/Clickthrough.d.ts +1 -1
  196. package/lib/types/helpers/response/ProductCard.d.ts +3 -3
  197. package/lib/types/helpers/response/Video.d.ts +2 -2
  198. package/lib/types/services/Bidder.d.ts +3 -3
  199. package/lib/types/services/Configuration.d.ts +1 -1
  200. package/lib/types/services/Dynamic.d.ts +6 -6
  201. package/lib/types/services/Geo.d.ts +1 -1
  202. package/lib/types/services/Product.d.ts +1 -1
  203. package/lib/types/services/Template.d.ts +3 -3
  204. package/package.json +41 -33
  205. package/lib/index.js +0 -1
  206. package/lib/index.js.map +0 -1
  207. package/lib/types/constant-values/index.d.ts +0 -46
  208. package/lib/types/errors/index.d.ts +0 -3
  209. package/lib/types/helpers/generators/CollectN.d.ts +0 -2
  210. package/lib/types/helpers/generators/index.d.ts +0 -1
  211. package/lib/types/helpers/handlebars/index.d.ts +0 -119
  212. package/lib/types/helpers/requests/RequestBuilder.d.ts +0 -124
  213. package/lib/types/helpers/requests/SimpleBannerRequest.d.ts +0 -26
  214. package/lib/types/helpers/requests/index.d.ts +0 -2
  215. package/lib/types/helpers/responses/BuildBannerResponse.d.ts +0 -10
  216. package/lib/types/helpers/responses/BuildNativeResponse.d.ts +0 -21
  217. package/lib/types/helpers/responses/BuildVideoResponse.d.ts +0 -0
  218. package/lib/types/helpers/responses/ClickthroughHelpers.d.ts +0 -2
  219. package/lib/types/helpers/responses/VastHelpers.d.ts +0 -4
  220. package/lib/types/helpers/responses/index.d.ts +0 -4
  221. package/lib/types/middleware/DeviceMiddleware.d.ts +0 -3
  222. package/lib/types/middleware/GeoMiddleware.d.ts +0 -3
  223. package/lib/types/middleware/IdentityMiddleware.d.ts +0 -4
  224. package/lib/types/middleware/index.d.ts +0 -3
  225. package/lib/types/models/retail/IProductInformation.d.ts +0 -37
  226. package/lib/types/models/retail/IPublisherConfiguration.d.ts +0 -64
  227. package/lib/types/models/retail/IRecommenderResponse.d.ts +0 -10
  228. package/lib/types/models/rtb/IBidRequest.d.ts +0 -399
  229. package/lib/types/models/rtb/IBidResponse.d.ts +0 -47
  230. package/lib/types/models/rtb/native/Constants.d.ts +0 -60
  231. package/lib/types/models/rtb/native/INativeRequest.d.ts +0 -54
  232. package/lib/types/models/rtb/native/INativeResponse.d.ts +0 -60
  233. package/lib/types/models/rtb/native/NativeConstants.d.ts +0 -120
  234. package/lib/types/models/rtb/native/NativeRequestBuilder.d.ts +0 -158
  235. package/lib/types/models/rtb/native/index.d.ts +0 -4
  236. package/lib/types/models/tracking/IEvents.d.ts +0 -82
  237. package/lib/types/models/tracking/IGeoContext.d.ts +0 -14
  238. package/lib/types/models/tracking/IUserID.d.ts +0 -1
  239. package/lib/types/services/OverrideService.d.ts +0 -10
  240. package/lib/types/services/logger/ILoggerService.d.ts +0 -39
  241. package/lib/types/services/logger/LocalLoggerService.d.ts +0 -19
  242. package/lib/types/services/logger/index.d.ts +0 -2
  243. package/lib/types/services/product-feed/IProductFeedService.d.ts +0 -5
  244. package/lib/types/services/product-feed/SurfsideProductFeedService.d.ts +0 -11
  245. package/lib/types/services/product-feed/index.d.ts +0 -2
  246. package/lib/types/services/recommender/IRecommenderService.d.ts +0 -47
  247. package/lib/types/services/recommender/SurfsideRecommenderService.d.ts +0 -31
  248. package/lib/types/services/recommender/index.d.ts +0 -2
  249. package/lib/types/services/rtb/bidder/IBidderService.d.ts +0 -12
  250. package/lib/types/services/rtb/bidder/SurfsideBidderService.d.ts +0 -28
  251. package/lib/types/services/rtb/bidder/index.d.ts +0 -2
  252. package/lib/types/services/rtb/configuration/IConfigurationService.d.ts +0 -14
  253. package/lib/types/services/rtb/configuration/SurfsideConfigurationService.d.ts +0 -29
  254. package/lib/types/services/rtb/configuration/index.d.ts +0 -2
  255. package/lib/types/services/rtb/index.d.ts +0 -2
  256. package/lib/types/services/tracking/device/DeviceOverrideService.d.ts +0 -8
  257. package/lib/types/services/tracking/device/IDeviceService.d.ts +0 -4
  258. package/lib/types/services/tracking/device/SurfsideDeviceService.d.ts +0 -16
  259. package/lib/types/services/tracking/device/index.d.ts +0 -3
  260. package/lib/types/services/tracking/events/IEventService.d.ts +0 -5
  261. package/lib/types/services/tracking/events/SurfsideEventService.d.ts +0 -42
  262. package/lib/types/services/tracking/events/index.d.ts +0 -2
  263. package/lib/types/services/tracking/geo/GeoOverrideService.d.ts +0 -8
  264. package/lib/types/services/tracking/geo/IGeoService.d.ts +0 -12
  265. package/lib/types/services/tracking/geo/SurfsideGeoService.d.ts +0 -7
  266. package/lib/types/services/tracking/geo/index.d.ts +0 -3
  267. package/lib/types/services/tracking/index.d.ts +0 -4
  268. package/lib/types/services/tracking/user/IUserIDService.d.ts +0 -4
  269. package/lib/types/services/tracking/user/SurfsideUserIDService.d.ts +0 -7
  270. package/lib/types/services/tracking/user/UserOverrideService.d.ts +0 -8
  271. package/lib/types/services/tracking/user/index.d.ts +0 -3
  272. package/lib/types/utils/Protocol.d.ts +0 -1
  273. package/lib/types/utils/Rendering.d.ts +0 -44
  274. package/lib/types/utils/index.d.ts +0 -2
@@ -0,0 +1,78 @@
1
+ import { Ctx } from './Logger';
2
+ import { Err, Ok } from './Result';
3
+ export async function* GenerateTopProducts(logger, productFeed, url, accountId, siteId, locationId) {
4
+ const log = Ctx(logger)?.with('GenerateTopProducts').with(accountId).with(siteId).with(locationId);
5
+ log?.info('Generating top products');
6
+ yield* generateProductRecommendation(logger, productFeed, url, accountId, siteId, locationId, undefined, 'top-products');
7
+ }
8
+ export async function* GenerateForYou(logger, productFeed, url, accountId, siteId, locationId, userId) {
9
+ const log = Ctx(logger)?.with('GenerateForYou').with(accountId).with(siteId).with(locationId).with(userId);
10
+ log?.info('Generating for you');
11
+ yield* generateProductRecommendation(logger, productFeed, url, accountId, siteId, locationId, userId, 'for-you');
12
+ }
13
+ export async function* GeneratePreviousPurchases(logger, productFeed, url, accountId, siteId, locationId, userId) {
14
+ const log = Ctx(logger)
15
+ ?.with('GeneratePreviousPurchases')
16
+ .with(accountId)
17
+ .with(siteId)
18
+ .with(locationId)
19
+ .with(userId);
20
+ log?.info('Generating previous purchases');
21
+ yield* generateProductRecommendation(log, productFeed, url, accountId, siteId, locationId, userId, 'buy-again');
22
+ }
23
+ async function* generateProductRecommendation(logger, productFeed, url, accountId, siteId, locationId, userId, type) {
24
+ const log = Ctx(logger)?.with('generatreProductRecommendation');
25
+ log?.debug('Generating product recommendation');
26
+ const recommendations = await fetchRecommendations(log, url, accountId, siteId, locationId, userId, type);
27
+ if (!recommendations.ok) {
28
+ log?.error(recommendations.error);
29
+ return;
30
+ }
31
+ yield* generateProduct(log, productFeed, accountId, locationId, recommendations.value);
32
+ log?.debug('out of recommendations');
33
+ }
34
+ const fetchRecommendations = async (logger, url, accountId, siteId, locationId, userId, type) => {
35
+ const log = Ctx(logger)?.with('fetchRecommendations');
36
+ log?.debug('Fetching recommendations');
37
+ const key = `accountId=${accountId}&siteId=${siteId}&locationId=${locationId}&userId=${userId ?? 'null'}`;
38
+ try {
39
+ const results = await fetch(`${url}/r/${type}?${key}&limit=100`);
40
+ if (!results.ok) {
41
+ return Err(new Error('Failed to load recommendations. Service returned ' + results.status));
42
+ }
43
+ /* On error, the result will be IRecommenderResponse.
44
+ * On success, it will just be a set of recommended products */
45
+ const recommendations = await results.json();
46
+ const error = recommendations.error;
47
+ if (error !== undefined) {
48
+ return Err(new Error(error));
49
+ }
50
+ return Ok(recommendations);
51
+ }
52
+ catch (err) {
53
+ return Err(err);
54
+ }
55
+ };
56
+ async function* generateProduct(logger, productFeed, accountId, locationId, results) {
57
+ const log = Ctx(logger)?.with('generateProduct');
58
+ log?.debug('generating product info');
59
+ for (const item of results) {
60
+ const itemId = item.item_id;
61
+ try {
62
+ log?.debug('itemId', itemId);
63
+ const product = await productFeed(itemId);
64
+ log?.debug('product', itemId, product);
65
+ if (product.ok) {
66
+ yield product.value;
67
+ }
68
+ else {
69
+ log?.warn('item was missing from product feed', itemId);
70
+ }
71
+ }
72
+ catch (err) {
73
+ log?.warn('couldn\'t get product', err);
74
+ }
75
+ }
76
+ log?.info('no more products. Exiting');
77
+ }
78
+ //# sourceMappingURL=Recommender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Recommender.js","sourceRoot":"src/","sources":["services/Recommender.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAgB,MAAM,UAAU,CAAC;AAE7C,OAAO,EAAE,GAAG,EAAE,EAAE,EAAoB,MAAM,UAAU,CAAC;AAKrD,MAAM,CAAC,KAAK,SAAU,CAAC,CAAA,mBAAmB,CACtC,MAA2B,EAC3B,WAAiD,EACjD,GAAW,EACX,SAAiB,EACjB,MAAc,EACd,UAAkB;IAElB,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACnG,GAAG,EAAE,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAErC,KAAK,CAAC,CAAC,6BAA6B,CAChC,MAAM,EACN,WAAW,EACX,GAAG,EACH,SAAS,EACT,MAAM,EACN,UAAU,EACV,SAAS,EACT,c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QAC5C,CAAC;IACL,CAAC;IAED,GAAG,EAAE,IAAI,CAAC,2BAA2B,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,199 @@
1
+ export const Ok = (t) => ({
2
+ ok: true,
3
+ value: t
4
+ });
5
+ export const Err = (e) => ({
6
+ ok: false,
7
+ error: e
8
+ });
9
+ export const TryDo = (fn) => {
10
+ try {
11
+ return Ok(fn());
12
+ }
13
+ catch (err) {
14
+ return Err(err);
15
+ }
16
+ };
17
+ export const TryDoFlat = (fn) => {
18
+ try {
19
+ return fn();
20
+ }
21
+ catch (err) {
22
+ return Err(err);
23
+ }
24
+ };
25
+ export const TryDoAsync = async (fn) => {
26
+ try {
27
+ return Ok(await fn());
28
+ }
29
+ catch (err) {
30
+ return Err(err);
31
+ }
32
+ };
33
+ export const GetValue = (result) => result?.ok === true ? result.value : undefined;
34
+ export const ValueOr = (result, or) => result?.ok === true ? result.value : or;
35
+ export const GetValueOrThrow = (result) => {
36
+ if (result.ok) {
37
+ return result.value;
38
+ }
39
+ throw result.error;
40
+ };
41
+ export const WrapValue = (value) => {
42
+ if (value === undefined || value === null) {
43
+ return Err(new NoValueError(value));
44
+ }
45
+ return Ok(value);
46
+ };
47
+ export const AssertValue = GetValueOrThrow;
48
+ export const AllOrNone = (results) => {
49
+ const failed = results.filter(res => !res.ok).map(res => res.error);
50
+ if (failed.length > 0) {
51
+ return Err(new MultipleErrorsError(failed));
52
+ }
53
+ const success = results.filter(res => res.ok).map(res => res.value);
54
+ return Ok(success);
55
+ };
56
+ export const Some = (results) => {
57
+ const success = results.filter(res => res.ok).map(res => res.value);
58
+ return Ok(success);
59
+ };
60
+ export const Filter = (...results) => {
61
+ const success = Some(results).value.map(val => Ok(val));
62
+ const failed = results.filter(res => !res.ok);
63
+ return [success, failed];
64
+ };
65
+ export const AnyFailed = (...results) => {
66
+ const errors = results.filter(res => !res.ok).map(res => res.error);
67
+ if (errors.length > 0) {
68
+ return [true, errors];
69
+ }
70
+ return [false];
71
+ };
72
+ export class MultipleErrorsError extends Error {
73
+ errors;
74
+ constructor(errors) {
75
+ super('Got multiple errors:\n' +
76
+ errors.map(err => '\t' + err.message.substring(0, 32).padEnd(35, '.')).join('\n'));
77
+ this.errors = errors;
78
+ }
79
+ }
80
+ export const Pipe = (result) => ({
81
+ then: pipeThen(result),
82
+ result: pipeResult(result),
83
+ value: pipeValue(result),
84
+ valueOr: pipeValueOr(result),
85
+ valueOrThrow: pipeValueOrThrow(result)
86
+ });
87
+ const pipeThen = (result) => (fn) => {
88
+ if (!result.ok) {
89
+ return Pipe(result);
90
+ }
91
+ return Pipe(Ok(fn(result.value)));
92
+ };
93
+ const pipeResult = (result) => () => result;
94
+ const pipeValue = (result) => () => GetValue(result);
95
+ const pipeValueOr = (result) => (or) => GetValue(result) ?? or;
96
+ const pipeValueOrThrow = (result) => () => {
97
+ if (result.ok) {
98
+ return result.value;
99
+ }
100
+ throw result.error;
101
+ };
102
+ export const AsyncPipe = (result) => ({
103
+ then: asyncPipeThen(result),
104
+ result: asyncPipeResult(result),
105
+ value: asyncPipeValue(result),
106
+ valueOr: asyncPipeValueOr(result),
107
+ valueOrThrow: asyncPipeValueOrThrow(result)
108
+ });
109
+ const asyncPipeThen = (result) => (fn) => {
110
+ const asyncResult = result;
111
+ const wrappedPromiseResult = asyncResult.then(unwrappedResult => {
112
+ if (unwrappedResult.ok) {
113
+ try {
114
+ const fnRes = fn(unwrappedResult.value);
115
+ return Promise.resolve(fnRes)
116
+ .catch(Err);
117
+ }
118
+ catch (err) {
119
+ return Err(err);
120
+ }
121
+ }
122
+ else {
123
+ return unwrappedResult;
124
+ }
125
+ });
126
+ return AsyncPipe(wrappedPromiseResult);
127
+ };
128
+ const asyncPipeResult = (result) => () => result;
129
+ const asyncPipeValue = (result) => async () => {
130
+ try {
131
+ const res = await result;
132
+ if (res.ok) {
133
+ return res.value;
134
+ }
135
+ return undefined;
136
+ }
137
+ catch {
138
+ return undefined;
139
+ }
140
+ };
141
+ const asyncPipeValueOr = (result) => async (or) => {
142
+ try {
143
+ const res = await result;
144
+ if (res.ok) {
145
+ return res.value;
146
+ }
147
+ return or;
148
+ }
149
+ catch {
150
+ return or;
151
+ }
152
+ };
153
+ const asyncPipeValueOrThrow = (result) => async () => {
154
+ const res = await result;
155
+ if (res.ok) {
156
+ return res.value;
157
+ }
158
+ throw res.error;
159
+ };
160
+ export const ResultStream = (results) => ({
161
+ map: streamMap(results),
162
+ filter: streamFilter(results),
163
+ results: streamResults(results),
164
+ value: streamValue(results),
165
+ valueOr: streamValueOr(results),
166
+ valueOrThrow: streamValueOrThrow(results)
167
+ });
168
+ const streamMap = (results) => (fn) => {
169
+ if (!results.ok) {
170
+ return ResultStream(results);
171
+ }
172
+ return ResultStream(Ok(results.value.map(fn)));
173
+ };
174
+ const streamFilter = (results) => (fn) => {
175
+ if (!results.ok) {
176
+ return ResultStream(results);
177
+ }
178
+ return ResultStream(Ok(results.value.filter(fn)));
179
+ };
180
+ const streamResults = (results) => () => results;
181
+ const streamValue = (results) => () => results.ok ? results.value : undefined;
182
+ const streamValueOr = (results) => (or) => results.ok ? results.value : or;
183
+ const streamValueOrThrow = (results) => () => {
184
+ if (results.ok) {
185
+ return results.value;
186
+ }
187
+ else {
188
+ throw results.error;
189
+ }
190
+ };
191
+ export class NoValueError extends Error {
192
+ value;
193
+ constructor(value) {
194
+ super('Value was undefined or null');
195
+ this.value = value;
196
+ }
197
+ }
198
+ ;
199
+ //# sourceMappingURL=Result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Result.js","sourceRoot":"src/","sources":["services/Result.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,EAAE,GAAG,CAAI,CAAI,EAAe,EAAE,CAAC,CAAC;IACzC,EAAE,EAAE,IAAI;IACR,KAAK,EAAE,CAAC;CACX,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,GAAG,GAAG,CAAY,CAAI,EAAgB,EAAE,CAAC,CAAC;IACnD,EAAE,EAAE,KAAK;I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} from './Result';
3
+ export const EvaluateHandlebarsProductCardTemplate = (logger, windowInfo, publisher, product, clickthrough) => {
4
+ const log = Ctx(logger)?.with('EvaluateHandlebarsProductCardTemplate');
5
+ log?.info('Evaluating handlebars product card template', product);
6
+ try {
7
+ const renderedClickthrough = clickthrough ?? GetValueOrThrow(EvaluateHandlebarsClickthroughTemplate(log, windowInfo, publisher, product));
8
+ log?.debug('Got clickthrough URL', renderedClickthrough);
9
+ return Ok(publisher.templates.productCardTemplate({
10
+ ...product,
11
+ product,
12
+ window: windowInfo,
13
+ publisher,
14
+ catalog: product,
15
+ clickthrough: renderedClickthrough
16
+ }));
17
+ }
18
+ catch (error) {
19
+ return Err(error);
20
+ }
21
+ };
22
+ export const EvaluateHandlebarsClickthroughTemplate = (logger, windowInfo, publisher, product) => {
23
+ const log = Ctx(logger)?.with('EvaluateHandlebarsClickthroughTemplate');
24
+ log?.info('Evaluating handlebars clickthrough URL template', product);
25
+ try {
26
+ return Ok(publisher.templates.clickThroughUrlTemplate({
27
+ product,
28
+ catalog: product,
29
+ window: windowInfo,
30
+ publisher,
31
+ ...product
32
+ }));
33
+ }
34
+ catch (error) {
35
+ return Err(error);
36
+ }
37
+ };
38
+ //# sourceMappingURL=Template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Template.js","sourceRoot":"src/","sources":["services/Template.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,GAAG,EAAgB,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,EAAE,EAAe,MAAM,UAAU,CAAC;AAWjE,MAAM,CAAC,MAAM,qCAAqC,GAAG,CAAC,MAA2B,EAC7E,UAAyC,EACzC,SAA0C,EAC1C,OAA4B,EAC5B,YAAqB,EACP,EAAE;IAChB,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,uCAAuC,CAAC,CAAC;IACvE,GAAG,EAAE,IAAI,CAAC,6CAA6C,EAAE,OAAO,CAAC,CAAC;IAElE,IAAI,CAAC;QACD,MAAM,oBAAoB,GAAG,YAAY,IAAI,eAAe,CACxD,sCAAsC,CAAC,GAAG,EACtC,UAAU,EACV,SAAS,EACT,OAAO,CACV,CACJ,CAAC;QACF,GAAG,EAAE,KAAK,CAAC,sBAAsB,EAAE,oBAAoB,CAAC,CAAC;QAEzD,OAAO,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC;YAC9C,GAAG,OAAO;YACV,OAAO;YACP,MAAM,EAAE,UAAU;YAClB,SAAS;YACT,OAAO,EAAE,OAAO;YAChB,YAAY,EAAE,oBAAoB;SACrC,CAAC,CAAC,CAAC;IACR,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,GAAG,CAAC,KAAc,CAAC,CAAC;IAC/B,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sCAAsC,GAAG,CAAC,MAA2B,EAC9E,UAAyC,EACzC,SAA0C,EAC1C,OAA4B,EACd,EAAE;IAChB,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,wCAAwC,CAAC,CAAC;IACxE,GAAG,EAAE,IAAI,CAAC,iDAAiD,EAAE,OAAO,CAAC,CAAC;IACtE,IAAI,CAAC;QACD,OAAO,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,uBAAuB,CAAC;YAClD,OAAO;YACP,OAAO,EAAE,OAAO;YAChB,MAAM,EAAE,UAAU;YAClB,SAAS;YACT,GAAG,OAAO;SACb,CAAC,CAAC,CAAC;IACR,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,GAAG,CAAC,KAAc,CAAC,CAAC;IAC/B,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ export * from './Geo';
2
+ export * from './Logger';
3
+ export * from './Result';
4
+ export * from './Device';
5
+ export * from './Configuration';
6
+ export * from './Bidder';
7
+ export * from './Product';
8
+ export * from './Recommender';
9
+ export * from './mock';
10
+ export * from './Template';
11
+ export * from './Dynamic';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"src/","sources":["services/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Bidder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Bidder.js","sourceRoot":"src/","sources":["services/mock/Bidder.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from './Bidder';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"src/","sources":["services/mock/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
@@ -1,11 +1,11 @@
1
1
  import type { INativeTemplateDelegateWindow, ICompiledPublisherConfiguration, IDevice, IGeoContext } from './models';
2
- import { AsyncResult, INavigator, type IScreen, RequestBidsFn, ILogger, GetSponsoredProductFromNativeIdFn, PersonalRecommenderFn, NonPersonalRecommenderFn, GetConfigurationFn, GetGeoFn, GetDeviceFn, GetRecommendedProductFromProductIdFn, GetAllSponsoredProductFromNativeIdFn } from './services';
3
- import { BuildAllSponsoredProductCardResponsesFn, GenerateSponsoredProductCardResponseFn, NativeRequestBuilderFn, RequestBuilderFn } from './helpers';
2
+ import { type AsyncResult, type INavigator, type IScreen, type RequestBidsFn, type ILogger, type GetSponsoredProductFromNativeIdFn, type PersonalRecommenderFn, type NonPersonalRecommenderFn, type GetConfigurationFn, type GetGeoFn, type GetDeviceFn, type GetRecommendedProductFromProductIdFn, type GetAllSponsoredProductFromNativeIdFn } from './services';
3
+ import { type BuildAllSponsoredProductCardResponsesFn, type GenerateSponsoredProductCardResponseFn, type NativeRequestBuilderFn, type RequestBuilderFn } from './helpers';
4
4
  import Handlebars from 'handlebars/runtime';
5
- import { BuildHybridCarouselFn, BuildHybridCarouselFromInitialBidFn, BuildRecommendedCarouselFn, BuildSponsoredCarouselFn, BuildSponsoredCarouselFromInitialBidFn } from './helpers/response/Carousel';
5
+ import { type BuildHybridCarouselFn, type BuildHybridCarouselFromInitialBidFn, type BuildRecommendedCarouselFn, type BuildSponsoredCarouselFn, type BuildSponsoredCarouselFromInitialBidFn } from './helpers/response/Carousel';
6
6
  import { type EvaluateClickthroughTemplateFn, type EvaluateProductCardTemplateFn } from './services/Template';
7
- import { BuildDynamicZoneRequestFn, GetDynamicZoneFn } from './services/Dynamic';
8
- export declare const PROD_BIDDER = "//rtb.surfside.io/rtb/bids/surfside";
7
+ import { type BuildDynamicZoneRequestFn, type GetDynamicZoneFn } from './services/Dynamic';
8
+ export declare const PROD_BIDDER = "//bid.surfside.io/rtb/bids/surfside";
9
9
  export declare const PROD_CONFIGURATION_SERVICE = "//r.surfside.io";
10
10
  export declare const PROD_SPONSORED_PRODUCT_FEED = "//creative.surfside.io";
11
11
  export declare const PROD_RECOMMENDED_PRODUCT_FEED = "//creative.surfside.io";
@@ -14,7 +14,7 @@
14
14
  * To limit the max number of hyphenated slug components returned, you can pass a length option.
15
15
  * For example, {{slug "My Product's Name" length=2}} will return "my-product".
16
16
  * The default length is 5.
17
- *
17
+ * @group TemplateHelpers
18
18
  * @param name The string to be slugified
19
19
  * @param options The options object. Can take "hypenate", "drop", and "length" options.
20
20
  * @returns The slugified string
@@ -30,7 +30,7 @@ export declare function slug(name: string, options: {
30
30
  }): string;
31
31
  /**
32
32
  * Converts the passed string to lowercase. For example, {{lower "My Product Name"}} will return "my product name".
33
- *
33
+ * @group TemplateHelpers
34
34
  * @param name The string to be converted to lowercase
35
35
  * @returns A lowercase version of the passed string
36
36
  */
@@ -39,17 +39,60 @@ export declare function upper(name: string): string;
39
39
  /**
40
40
  * Returns the path component of the URL at the specified position, 1-indexed
41
41
  * For example, if the URL is "https://example.com/foo/bar", {{path 1}} will return "foo".
42
- *
42
+ * @group TemplateHelpers
43
43
  * @param position The position of the path component to return, 1-indexed
44
44
  * @returns The path component at the specified position
45
45
  */
46
46
  export declare function path(position: number): string | undefined;
47
+ /**
48
+ * A general-purpose string replacement tool - meant to behave like the Unix sed tool. Accepts a regex for
49
+ * search, and a replacement string. for example, if the input string is "hello world" and the search is
50
+ * ".*(world)" and the replacement string is "goodbye \1", the replaced string will be "goodbye world".
51
+ *
52
+ * Supports back references with numbered groups. i.e, \1, \2, \3 will insert the 1st, 2nd, and 3rd capture
53
+ * groups.
54
+ *
55
+ * There are also 3 transforms you can apply to the back references: \U, \L, and \I:
56
+ *
57
+ * \U{n} will replace the capture group with an uppercase version. For example \U1
58
+ *
59
+ * \L{n} will replace the capture group with a lowercase version. For example \L3
60
+ *
61
+ * \I{n} will replace the capture group with the first character of the capture group. For example \I5
62
+ * @group TemplateHelpers
63
+ * @param input The input string
64
+ * @param searchRegex The search pattern for the regular expression
65
+ * @param replacement The replacement string
66
+ * @returns
67
+ */
47
68
  export declare function sed(input: string, searchRegex: string, replacement: string): string;
69
+ /**
70
+ * Searches the input string for a simple string and replaces it with the replacement string. For example
71
+ * ```
72
+ * {{replace "hello world hello" "hello" "goodbye"}}
73
+ * ```
74
+ *
75
+ * returns "goodbye world goodbye"
76
+ *
77
+ * Optionally, you can pass `false` for the last parameter to only replace to first instance. i.e:
78
+ *
79
+ * ```
80
+ * {{replace "hello world hello" "hello" "goodbye" false}}
81
+ * ```
82
+ *
83
+ * Returns "goodbye world goodbye".
84
+ * @group TemplateHelpers
85
+ * @param input The string to be searched
86
+ * @param search The substring to replace
87
+ * @param replacement The string to replace it with
88
+ * @param all Whether or not to replace all matches of the string
89
+ * @returns
90
+ */
48
91
  export declare function replace(input: string, search: string, replacement: string, all?: boolean): string;
49
92
  /**
50
93
  * Returns the value of the specified query parameter from the URL, specified by key.
51
94
  * For example, if the URL is "https://example.com?foo=bar", {{search "foo"}} will return "bar".
52
- *
95
+ * @group TemplateHelpers
53
96
  * @param name The name of the query parameter to return
54
97
  * @returns The value of the query parameter, or an empty string if the parameter is not found
55
98
  */
@@ -58,30 +101,30 @@ export declare function search(name: string): string;
58
101
  * Returns the first truthy argument, or an empty string if all arguments are falsy. Returns false for empty strings
59
102
  * For example, {{coalesce false (eq "b" "d") c}} will return "c", because false is falsy, "b" is not equal to "d",
60
103
  * and c is truthy.
61
- *
104
+ * @group TemplateHelpers
62
105
  * @returns The first truthy argument, or an empty string if all arguments are falsy
63
106
  */
64
- export declare function coalesce(): string;
107
+ export declare function coalesce(...args: any[]): string;
65
108
  /**
66
109
  * Joins the passed arguments with the specified separator.
67
110
  * For example, {{join "foo" "bar" "baz"}} will return "foo/bar/baz"..
68
111
  *
69
112
  * There is an optional "separator" argument that can be passed to change the separator. For example,
70
113
  * {{join "foo" "bar" "baz" separator=","}} will return "foo,bar,baz".
71
- *
114
+ * @group TemplateHelpers
72
115
  * @returns The joined string
73
116
  */
74
- export declare function join(): string;
117
+ export declare function join(...args: any[]): string;
75
118
  /**
76
119
  * Encodes the passed string for use in a URI component.
77
- *
120
+ * @group TemplateHelpers
78
121
  * @param component The string to encode
79
122
  * @returns The encoded string, or an empty string if the component is falsy
80
123
  */
81
124
  export declare function uri(component: string): string;
82
125
  /**
83
126
  * Returns true if the two passed arguments are equal (using javascript ===), false otherwise.
84
- *
127
+ * @group TemplateHelpers
85
128
  * @param a The first argument
86
129
  * @param b The second argument
87
130
  * @returns True if the two arguments are equal, false otherwise
@@ -89,7 +132,7 @@ export declare function uri(component: string): string;
89
132
  export declare function eq(a: any, b: any): boolean;
90
133
  /**
91
134
  * Returns true if either of the passed arguments are truthy, false otherwise.
92
- *
135
+ * @group TemplateHelpers
93
136
  * @param a The first argument
94
137
  * @param b The second argument
95
138
  * @returns True if either of the arguments are truthy, false otherwise
@@ -97,7 +140,7 @@ export declare function eq(a: any, b: any): boolean;
97
140
  export declare function or(a: any, b: any): boolean;
98
141
  /**
99
142
  * Returns true if both of the passed arguments are truthy, false otherwise.
100
- *
143
+ * @group TemplateHelpers
101
144
  * @param a The first argument
102
145
  * @param b The second argument
103
146
  * @returns True if both of the arguments are truthy, false otherwise
@@ -108,7 +151,7 @@ export declare function and(a: any, b: any): boolean;
108
151
  * If the second argument is not an array, or the array is empty, this will return false.
109
152
  *
110
153
  * The name of the helper is "in" but the name of the function is "isIn" because "in" is a reserved word in javascript.
111
- *
154
+ * @group TemplateHelpers
112
155
  * @param a The value to check
113
156
  * @param b The array to check against
114
157
  * @returns True if the value is in the array, false otherwise
@@ -116,9 +159,9 @@ export declare function and(a: any, b: any): boolean;
116
159
  export declare function isIn(a: any, b: any[]): boolean;
117
160
  /**
118
161
  * Returns an array of the passed arguments. Useful with the "in" helper
119
- *
162
+ * @group TemplateHelpers
120
163
  * @returns An array of the passed arguments
121
164
  */
122
- export declare function array(): any[];
165
+ export declare function array(...args: any[]): any[];
123
166
  export type HandlebarsHelpers = Record<string, Function>;
124
167
  export declare const GetHelpers: () => HandlebarsHelpers;
@@ -1,5 +1,5 @@
1
1
  import { type INativeRequest } from '../models';
2
- import { ILogger } from '../services';
2
+ import { type ILogger } from '../services';
3
3
  export type NativeRequestBuilderFn = () => NativeRequestBuilder;
4
4
  export type NativeRequestBuilder = {
5
5
  withVer: (ver: string) => NativeRequestBuilder;
@@ -1,5 +1,5 @@
1
1
  import { type IApp, type IBanner, type IBidRequest, type IDevice, type IGeoContext, type IImp, type INative, type INativeRequest, type IRegs, type ISite, type IUser, type IVideo } from '../models';
2
- import { ILogger } from '../services';
2
+ import { type ILogger } from '../services';
3
3
  export type RequestBuilderFn = (zoneId: string, id?: string) => RequestBuilder;
4
4
  export type RequestWith<T> = (t: T) => RequestBuilder;
5
5
  export type RequestBuilder = {
@@ -1,2 +1,2 @@
1
- import { Result } from '../services';
1
+ import { type Result } from '../services';
2
2
  export declare const TryGet: <T>(get: () => T) => Result<T>;
@@ -1,3 +1,3 @@
1
- import { INativeTemplateDelegateWindow } from '../models';
2
- import { Result } from '../services';
1
+ import { type INativeTemplateDelegateWindow } from '../models';
2
+ import { type Result } from '../services';
3
3
  export declare const GetWindowInfo: () => Result<INativeTemplateDelegateWindow>;
@@ -1,4 +1,4 @@
1
- import { IBuiltResponse } from './BuiltResponse';
1
+ import { type IBuiltResponse } from './BuiltResponse';
2
2
  /**
3
3
  * A built banner response - includes the `adm` field for the banner as well as the rendered commerce media
4
4
  * clickthrough URL template, if applicable.
@@ -1,4 +1,4 @@
1
- import { IBid } from '../../models';
1
+ import { type IBid } from '../../models';
2
2
  export declare const CreativeType: {
3
3
  readonly Banner: 0;
4
4
  readonly Video: 1;
@@ -1,6 +1,6 @@
1
1
  import type { IBid, IBidRequest } from '../../models';
2
2
  import { type ILogger, type NonPersonalRecommenderFn, type PersonalRecommenderFn, type RequestBidsFn, type Result } from '../../services';
3
- import { EvaluateClickthroughTemplateFn } from '../../services/Template';
3
+ import { type EvaluateClickthroughTemplateFn } from '../../services/Template';
4
4
  import type { GenerateSponsoredProductCardResponseFn, IBuiltProductCardResponse } from './ProductCard';
5
5
  export type BuildSponsoredCarouselFn = (request: IBidRequest) => Result<IBuiltCarousel>;
6
6
  export type BuildSponsoredCarouselFromInitialBidFn = (request: IBidRequest, initialBid: IBid) => Result<IBuiltCarousel>;
@@ -1,3 +1,3 @@
1
1
  import type { ICompiledPublisherConfiguration, INativeTemplateDelegateWindow, IProductInformation } from '../../models';
2
- import { ILogger, Result } from '../../services';
2
+ import { type ILogger, type Result } from '../../services';
3
3
  export declare const BuildClickthroughUrl: (logger: ILogger | undefined, windowInfo: INativeTemplateDelegateWindow, configuration: ICompiledPublisherConfiguration, product: IProductInformation) => Result<string>;
@@ -1,6 +1,6 @@
1
- import { IBid, ICompiledPublisherConfiguration, INativeResponse, INativeTemplateDelegateWindow, IProductInformation } from '../../models';
2
- import { AsyncResult, GetAllSponsoredProductFromNativeIdFn, ILogger } from '../../services';
3
- import { IBuiltResponse } from './BuiltResponse';
1
+ import { type IBid, type ICompiledPublisherConfiguration, type INativeResponse, type INativeTemplateDelegateWindow, type IProductInformation } from '../../models';
2
+ import { type AsyncResult, type GetAllSponsoredProductFromNativeIdFn, type ILogger } from '../../services';
3
+ import { type IBuiltResponse } from './BuiltResponse';
4
4
  export type BuildAllSponsoredProductCardResponsesFn = (bids: IBid[]) => AsyncResult<IBuiltProductCardBidResponse[]>;
5
5
  export type GenerateSponsoredProductCardResponseFn = (bids: IBid[]) => AsyncGenerator<IBuiltProductCardBidResponse>;
6
6
  export interface ITracker {
@@ -1,5 +1,5 @@
1
- import { IVast } from '../../models';
2
- import { IBuiltResponse } from './BuiltResponse';
1
+ import type { IVast } from '../../models';
2
+ import type { IBuiltResponse } from './BuiltResponse';
3
3
  /**
4
4
  * A built video response. The raw Vast XML response from the bidder has been parsed out into a structure object here.
5
5
  * @expandType IBuiltResponse
@@ -1,6 +1,6 @@
1
- import { IBidRequest, IBidResponse } from '../models';
2
- import { ILogger } from './Logger';
3
- import { AsyncResult } from './Result';
1
+ import type { IBidRequest, IBidResponse } from '../models';
2
+ import { type ILogger } from './Logger';
3
+ import { type AsyncResult } from './Result';
4
4
  export type RequestBidsFn = (request: IBidRequest) => AsyncResult<IBidResponse>;
5
5
  export declare const RequestBids: (logger: ILogger | undefined, url: string, accountId: string, siteId: string, locationId: string, channelId: string, bidRequest: IBidRequest) => AsyncResult<IBidResponse>;
6
6
  export declare class NoBidsError extends Error {