@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,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,cAAc,CACjB,CAAC;AACN,CAAC;AAED,MAAM,CAAC,KAAK,SAAU,CAAC,CAAA,cAAc,CACjC,MAA2B,EAC3B,WAAiD,EACjD,GAAW,EACX,SAAiB,EACjB,MAAc,EACd,UAAkB,EAClB,MAAc;IAEd,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3G,GAAG,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAEhC,KAAK,CAAC,CAAC,6BAA6B,CAChC,MAAM,EACN,WAAW,EACX,GAAG,EACH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OAA8B;IAE9B,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACjD,GAAG,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAEtC,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC;YACD,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAC7B,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,CAAC;YAC1C,GAAG,EAAE,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;YACvC,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;gBACb,MAAM,OAAO,CAAC,KAAK,CAAC;YACxB,CAAC;iBAAM,CAAC;gBACJ,GAAG,EAAE,IAAI,CAAC,oCAAoC,EAAE,MAAM,CAAC,CAAC;YAC5D,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,GAAG,EAAE,IAAI,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;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;IACT,KAAK,EAAE,CAAC;CACX,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAe,EAAW,EAAgB,EAAE;IAC7D,IAAI,CAAC;QACD,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACpB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,OAAO,GAAG,CAAC,GAAQ,CAAC,CAAC;IACzB,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAe,EAAsB,EAAgB,EAAE;IAC5E,IAAI,CAAC;QACD,OAAO,EAAE,EAAE,CAAC;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,OAAO,GAAG,CAAC,GAAQ,CAAC,CAAC;IACzB,CAAC;AACL,C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,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAErH,MAAM,aAAa,GAAG,CAAO,OAAuB,EAAG,EAAE,CAAC,CAAI,EAAK,EAAW,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAEjH,MAAM,kBAAkB,GAAG,CAAO,OAAuB,EAAE,EAAE,CAAC,GAAQ,EAAE;IACpE,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;QACb,OAAO,OAAO,CAAC,KAAK,CAAC;IACzB,CAAC;SAAM,CAAC;QACJ,MAAM,OAAO,CAAC,KAAK,CAAC;IACxB,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,OAAO,YAAa,SAAQ,KAAK;IACP;IAA5B,YAA4B,KAAuB;QAC/C,KAAK,CAAC,6BAA6B,CAAC,CAAC;QADb,UAAK,GAAL,KAAK,CAAkB;IAEnD,CAAC;CACJ;AAAA,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { Ctx } from './Logger';
2
+ import { Err, GetValueOrThrow, Ok } 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"}
@@ -0,0 +1,169 @@
1
+ import type { INativeTemplateDelegateWindow, ICompiledPublisherConfiguration, IDevice, IGeoContext } from './models';
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
+ import Handlebars from 'handlebars/runtime';
5
+ import { type BuildHybridCarouselFn, type BuildHybridCarouselFromInitialBidFn, type BuildRecommendedCarouselFn, type BuildSponsoredCarouselFn, type BuildSponsoredCarouselFromInitialBidFn } from './helpers/response/Carousel';
6
+ import { type EvaluateClickthroughTemplateFn, type EvaluateProductCardTemplateFn } from './services/Template';
7
+ import { type BuildDynamicZoneRequestFn, type GetDynamicZoneFn } from './services/Dynamic';
8
+ export declare const PROD_BIDDER = "//bid.surfside.io/rtb/bids/surfside";
9
+ export declare const PROD_CONFIGURATION_SERVICE = "//r.surfside.io";
10
+ export declare const PROD_SPONSORED_PRODUCT_FEED = "//creative.surfside.io";
11
+ export declare const PROD_RECOMMENDED_PRODUCT_FEED = "//creative.surfside.io";
12
+ export declare const PROD_RECOMMENDER_SERVICE = "//t.surfside.io";
13
+ export declare const PROD_DYNAMIC_ZONE_SERVICE = "//r.surfside.io/";
14
+ /**
15
+ * A collection of services for querying the surfside API and building responses
16
+ */
17
+ export interface ISurfsideApi {
18
+ /**
19
+ * An optional logger
20
+ */
21
+ logger?: ILogger;
22
+ /**
23
+ * Gets information about the User's device in OpenRTB's device format
24
+ */
25
+ getDevice: GetDeviceFn;
26
+ /**
27
+ * The user's device info
28
+ */
29
+ device: IDevice | undefined;
30
+ /**
31
+ * Gets the user's current current geo and IP information.
32
+ */
33
+ getGeo: GetGeoFn;
34
+ /**
35
+ * The user's current geo and IP information
36
+ */
37
+ geo: IGeoContext | undefined;
38
+ /**
39
+ * The site's publisher configuration. Product card templates, clickthrough URL templates, settings, etc.
40
+ */
41
+ configuration: ICompiledPublisherConfiguration;
42
+ /**
43
+ * Gets the site's publisher configuration
44
+ */
45
+ getConfiguration: GetConfigurationFn;
46
+ /**
47
+ * A handlebars runtime instance, for evaluating templates
48
+ */
49
+ handlebars: typeof Handlebars;
50
+ /**
51
+ * Sends a bid request to the bidder and returns its response, if available
52
+ */
53
+ requestBids: RequestBidsFn;
54
+ /**
55
+ * Builds an OpenRTB 2.6 request
56
+ */
57
+ startRequest: RequestBuilderFn;
58
+ /**
59
+ * Builds an OpenRTB Native 1.2 request
60
+ */
61
+ startNative: NativeRequestBuilderFn;
62
+ /**
63
+ * Builds an OpenRTB Native 1.2 request with initial fields, such as site, app, and trackers
64
+ */
65
+ defaultNative: NativeRequestBuilderFn;
66
+ /**
67
+ * Creates a sponsored product generator from the given Native Creative ID. One native creative ID can generate
68
+ * multiple products
69
+ */
70
+ getSponsoredProduct: GetSponsoredProductFromNativeIdFn;
71
+ /**
72
+ * Gets all sponsored products from the native creative ID. One native creative ID can generate multiple products
73
+ */
74
+ getAllSponsoredProducts: GetAllSponsoredProductFromNativeIdFn;
75
+ /**
76
+ * Gets the associated product info for the site from a product ID
77
+ */
78
+ getRecommendedProduct: GetRecommendedProductFromProductIdFn;
79
+ /**
80
+ * Creates a recommended product generator for the top (most popular) products on the site.
81
+ */
82
+ generateTopProducts: NonPersonalRecommenderFn;
83
+ /**
84
+ * Creates a recommended product generator for products recommended for the user. If there are no recommended
85
+ * products for the user, or if the API was initialized without a user ID, this will return a generator for top
86
+ * products instead
87
+ */
88
+ generateForYou: PersonalRecommenderFn;
89
+ /**
90
+ * Creates a recommended product generator based on the user's previously purchased products. If there are no
91
+ * recommended products for the user, or if the API was initialized without a user ID, this will return a generator
92
+ * for top products instead
93
+ */
94
+ generatePreviousPurchases: PersonalRecommenderFn;
95
+ /**
96
+ * Creates a carousel state object using the bid request. The state object is a callback function which sends the
97
+ * bid request to the bidder and generates product cards from it. When the bid is out of product cards, the
98
+ * generator will request more bids with the same bid request. If no bids are returned, the generator completes.
99
+ */
100
+ buildSponsoredCarousel: BuildSponsoredCarouselFn;
101
+ /**
102
+ * Creates a carousel state object using the bid request and initializes it with a pre-existing bid. This is used
103
+ * for dynamic zones and probably doesn't need to be used in any client applications. The state object is a callback
104
+ * function which sends the bid request to the bidder and generates product cards from it. When the bid is out of
105
+ * product cards, the generator will request more bids with the same bid request. If no bids are returned, the
106
+ * generator completes.
107
+ */
108
+ buildSponsoredCarouselFromInitialBid: BuildSponsoredCarouselFromInitialBidFn;
109
+ /**
110
+ * Creates a carousel state object with recommendations from the given recommender type (top product, for you,
111
+ * previous purchases). The state object is a callback function which sends the bid request to the bidder and
112
+ * generates product cards from it. When the bid is out of product cards, the generator will request more bids with
113
+ * the same bid request. If no bids are returned, the generator completes.
114
+ */
115
+ buildRecommendedCarousel: BuildRecommendedCarouselFn;
116
+ buildHybridCarousel: BuildHybridCarouselFn;
117
+ buildHybridCarouselFromInitialBid: BuildHybridCarouselFromInitialBidFn;
118
+ buildAllSponsoredProductCardResponses: BuildAllSponsoredProductCardResponsesFn;
119
+ generateSponsoredProductCardResponse: GenerateSponsoredProductCardResponseFn;
120
+ evaluateProductCardTemplate: EvaluateProductCardTemplateFn;
121
+ evaluateClickthroughTemplate: EvaluateClickthroughTemplateFn;
122
+ getDynamicZone: GetDynamicZoneFn;
123
+ buildDynamicZoneRequest: BuildDynamicZoneRequestFn;
124
+ }
125
+ /**
126
+ * Initializes the API with the services explicitly passed to it. This function is used by the framework for overloading
127
+ * mock services. It should not be used in an application
128
+ * @param internalApiDto The list of services and helpers to inject
129
+ * @returns An initialized Surfside API
130
+ */
131
+ export declare function InitSurfAdsCoreInternal(internalApiDto: {
132
+ logger: ILogger | undefined;
133
+ requestBids: RequestBidsFn;
134
+ getConfiguration: GetConfigurationFn;
135
+ getGeo: GetGeoFn;
136
+ getDevice: GetDeviceFn;
137
+ getSponsoredProduct: GetSponsoredProductFromNativeIdFn;
138
+ getAllSponsoredProducts: GetAllSponsoredProductFromNativeIdFn;
139
+ getRecommendedProduct: GetRecommendedProductFromProductIdFn;
140
+ generateTopProducts: NonPersonalRecommenderFn;
141
+ generateForYou: PersonalRecommenderFn;
142
+ generatePreviousPurchases: PersonalRecommenderFn;
143
+ getDynamicZone: GetDynamicZoneFn;
144
+ buildAllSponsoredProductCardResponses: BuildAllSponsoredProductCardResponsesFn;
145
+ generateSponsoredProductCardResponse: GenerateSponsoredProductCardResponseFn;
146
+ evaluateProductCardTemplate: EvaluateProductCardTemplateFn;
147
+ evaluateClickthroughTemplate: EvaluateClickthroughTemplateFn;
148
+ handlebars: typeof Handlebars;
149
+ windowInfo: INativeTemplateDelegateWindow;
150
+ screenInfo: IScreen;
151
+ navigator: INavigator;
152
+ mobile: boolean;
153
+ ip: string | undefined;
154
+ geoProviderToken: string | undefined;
155
+ accountId: string;
156
+ siteId: string;
157
+ channelId: string;
158
+ locationId: string;
159
+ userId: string | undefined;
160
+ }): AsyncResult<ISurfsideApi>;
161
+ export declare const InitSurfAdsCoreServices: (logger: ILogger | undefined, bidderServiceUrl: string, configurationServiceUrl: string, productFeedUrl: string, recommendedProductFeedUrl: string, recommenderServiceUrl: string, dynamicZoneServiceUrl: string, windowInfo: INativeTemplateDelegateWindow, screenInfo: IScreen, navigator: INavigator, mobile: boolean, ip: string | undefined, geoProviderToken: string | undefined, accountId: string, siteId: string, channelId: string, locationId: string, userId: string | undefined) => AsyncResult<ISurfsideApi>;
162
+ export declare const InitSurfAdsCoreSSR: (windowInfo: INativeTemplateDelegateWindow, screen: IScreen, navigator: INavigator, mobile: boolean, ip: string, geoProviderToken: string, accountId: string, siteId: string, channelId: string, locationId: string, userId: string | undefined, logger?: ILogger) => AsyncResult<ISurfsideApi>;
163
+ export declare const InitSurfAdsCore: (channelId: string, accountId: string, siteId: string, locationId: string, userId: string | undefined, logger?: ILogger) => AsyncResult<ISurfsideApi>;
164
+ export declare class MissingConfigurationError extends Error {
165
+ constructor(accountId: string, siteId: string);
166
+ }
167
+ export declare class NotABrowserError extends Error {
168
+ constructor();
169
+ }
@@ -0,0 +1,5 @@
1
+ export declare const ConsumeN: <T>(generator: Generator<T>, n: number) => T[];
2
+ export declare const ConsumeAll: <T>(generator: Generator<T>) => T[];
3
+ export declare const ConsumeNAsync: <T>(generator: AsyncGenerator<T>, n: number) => Promise<[data: T[], finished: boolean]>;
4
+ export declare const ConsumeAllAsync: <T>(generator: AsyncGenerator<T>) => Promise<T[]>;
5
+ export declare function GenerateArray<T>(data: T[]): Generator<T>;
@@ -23,7 +23,9 @@ export declare function slug(name: string, options: {
23
23
  hash: {
24
24
  hyphenate: string | undefined;
25
25
  drop: string | undefined;
26
+ dropBefore: string | undefined;
26
27
  length: number | undefined;
28
+ separator: string | undefined;
27
29
  };
28
30
  }): string;
29
31
  /**
@@ -33,6 +35,7 @@ export declare function slug(name: string, options: {
33
35
  * @returns A lowercase version of the passed string
34
36
  */
35
37
  export declare function lower(name: string): string;
38
+ export declare function upper(name: string): string;
36
39
  /**
37
40
  * Returns the path component of the URL at the specified position, 1-indexed
38
41
  * For example, if the URL is "https://example.com/foo/bar", {{path 1}} will return "foo".
@@ -40,9 +43,9 @@ export declare function lower(name: string): string;
40
43
  * @param position The position of the path component to return, 1-indexed
41
44
  * @returns The path component at the specified position
42
45
  */
43
- export declare function path(position: number): string;
44
- export declare function global(): any;
46
+ export declare function path(position: number): string | undefined;
45
47
  export declare function sed(input: string, searchRegex: string, replacement: string): string;
48
+ export declare function replace(input: string, search: string, replacement: string, all?: boolean): string;
46
49
  /**
47
50
  * Returns the value of the specified query parameter from the URL, specified by key.
48
51
  * For example, if the URL is "https://example.com?foo=bar", {{search "foo"}} will return "bar".
@@ -58,7 +61,7 @@ export declare function search(name: string): string;
58
61
  *
59
62
  * @returns The first truthy argument, or an empty string if all arguments are falsy
60
63
  */
61
- export declare function coalesce(): string;
64
+ export declare function coalesce(...args: any[]): string;
62
65
  /**
63
66
  * Joins the passed arguments with the specified separator.
64
67
  * For example, {{join "foo" "bar" "baz"}} will return "foo/bar/baz"..
@@ -68,7 +71,7 @@ export declare function coalesce(): string;
68
71
  *
69
72
  * @returns The joined string
70
73
  */
71
- export declare function join(): string;
74
+ export declare function join(...args: any[]): string;
72
75
  /**
73
76
  * Encodes the passed string for use in a URI component.
74
77
  *
@@ -116,4 +119,6 @@ export declare function isIn(a: any, b: any[]): boolean;
116
119
  *
117
120
  * @returns An array of the passed arguments
118
121
  */
119
- export declare function array(): any[];
122
+ export declare function array(...args: any[]): any[];
123
+ export type HandlebarsHelpers = Record<string, Function>;
124
+ export declare const GetHelpers: () => HandlebarsHelpers;
@@ -0,0 +1,29 @@
1
+ import { type INativeRequest } from '../models';
2
+ import { type ILogger } from '../services';
3
+ export type NativeRequestBuilderFn = () => NativeRequestBuilder;
4
+ export type NativeRequestBuilder = {
5
+ withVer: (ver: string) => NativeRequestBuilder;
6
+ withContext: (context: number) => NativeRequestBuilder;
7
+ withContextSubType: (contextSubType: number) => NativeRequestBuilder;
8
+ withPlacementType: (placementType: number) => NativeRequestBuilder;
9
+ withTitle: (length?: number, required?: boolean) => NativeRequestBuilder;
10
+ withImage: (width: number, height: number, minWidth?: number, minHeight?: number, required?: boolean) => NativeRequestBuilder;
11
+ withVideo: (mimes: number[] | string[], minDuration: number, maxDuration: number, required?: boolean) => NativeRequestBuilder;
12
+ withData: (type: number, id: number, length?: number, required?: boolean) => NativeRequestBuilder;
13
+ withSponsored: (length?: number, required?: boolean) => NativeRequestBuilder;
14
+ withDescription: (length?: number, required?: boolean) => NativeRequestBuilder;
15
+ withRating: (length?: number, required?: boolean) => NativeRequestBuilder;
16
+ withPrice: (length?: number, required?: boolean) => NativeRequestBuilder;
17
+ withSalePrice: (length?: number, required?: boolean) => NativeRequestBuilder;
18
+ withDisplayURL: (length?: number, required?: boolean) => NativeRequestBuilder;
19
+ withCTAText: (length?: number, required?: boolean) => NativeRequestBuilder;
20
+ withCategory: (length?: number, required?: boolean) => NativeRequestBuilder;
21
+ withTHC: (length?: number, required?: boolean) => NativeRequestBuilder;
22
+ withCBD: (length?: number, required?: boolean) => NativeRequestBuilder;
23
+ withStrain: (length?: number, required?: boolean) => NativeRequestBuilder;
24
+ withMetaProduct: (length?: number, required?: boolean) => NativeRequestBuilder;
25
+ withEventTracker: (event: number, methods: number[]) => NativeRequestBuilder;
26
+ build: () => INativeRequest;
27
+ };
28
+ export declare const StartNative: (logger: ILogger | undefined) => NativeRequestBuilder;
29
+ export declare const DefaultNative: (logger: ILogger | undefined) => NativeRequestBuilder;
@@ -0,0 +1,16 @@
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 { type ILogger } from '../services';
3
+ export type RequestBuilderFn = (zoneId: string, id?: string) => RequestBuilder;
4
+ export type RequestWith<T> = (t: T) => RequestBuilder;
5
+ export type RequestBuilder = {
6
+ withUser: RequestWith<IUser>;
7
+ withRegulations: RequestWith<IRegs>;
8
+ withApp: RequestWith<IApp>;
9
+ withSite: RequestWith<ISite>;
10
+ withKeywords: RequestWith<string[]>;
11
+ withBanner: (w: number, h: number, options?: Partial<IBanner>, impOptions?: Partial<IImp>) => RequestBuilder;
12
+ withVideo: (w: number, h: number, minduration: number, maxduration: number, mimes?: string[], options?: Partial<IVideo>, impOptions?: Partial<IImp>) => RequestBuilder;
13
+ withNative: (request: string | INativeRequest, options?: Partial<INative>, impOptions?: Partial<IImp>) => RequestBuilder;
14
+ build: () => IBidRequest;
15
+ };
16
+ export declare function StartRequest(logger: ILogger | undefined, accountId: string, siteId: string, channelId: string, locationId: string, device: IDevice | undefined, geo: IGeoContext | undefined, userId: string | undefined, zoneId: string, id?: string): RequestBuilder;