recombee-api-client 5.1.1 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/lib/api-client.js +1 -1
  2. package/lib/index.d.ts +180 -53
  3. package/lib/requests/add-detail-view.js +7 -0
  4. package/lib/requests/composite-recommendation.js +127 -0
  5. package/lib/requests/index.js +1 -0
  6. package/lib/requests/recommend-items-to-item-segment.js +42 -0
  7. package/lib/requests/recommend-items-to-item.js +45 -0
  8. package/lib/requests/recommend-items-to-user.js +42 -0
  9. package/lib/requests/recommend-users-to-item.js +45 -0
  10. package/lib/requests/recommend-users-to-user.js +42 -0
  11. package/lib/requests/search-items.js +42 -0
  12. package/lib/requests/set-view-portion.js +14 -0
  13. package/package.json +1 -1
  14. package/test/add-bookmark-batch_test.js +8 -8
  15. package/test/add-bookmark-callback_test.js +14 -14
  16. package/test/add-bookmark-test.js +7 -7
  17. package/test/add-cart-addition-batch_test.js +8 -8
  18. package/test/add-cart-addition-callback_test.js +14 -14
  19. package/test/add-cart-addition-test.js +7 -7
  20. package/test/add-detail-view-batch_test.js +8 -8
  21. package/test/add-detail-view-callback_test.js +14 -14
  22. package/test/add-detail-view-test.js +7 -7
  23. package/test/add-item-batch_test.js +5 -5
  24. package/test/add-item-callback_test.js +9 -9
  25. package/test/add-item-property-batch_test.js +6 -6
  26. package/test/add-item-property-callback_test.js +10 -10
  27. package/test/add-item-property-test.js +5 -5
  28. package/test/add-item-test.js +5 -5
  29. package/test/add-manual-reql-segment-batch_test.js +3 -3
  30. package/test/add-manual-reql-segment-callback_test.js +3 -3
  31. package/test/add-manual-reql-segment-test.js +1 -1
  32. package/test/add-purchase-batch_test.js +8 -8
  33. package/test/add-purchase-callback_test.js +14 -14
  34. package/test/add-purchase-test.js +7 -7
  35. package/test/add-rating-batch_test.js +8 -8
  36. package/test/add-rating-callback_test.js +16 -16
  37. package/test/add-rating-test.js +9 -9
  38. package/test/add-search-synonym-batch_test.js +5 -5
  39. package/test/add-search-synonym-callback_test.js +7 -7
  40. package/test/add-search-synonym-test.js +5 -5
  41. package/test/add-series-batch_test.js +5 -5
  42. package/test/add-series-callback_test.js +9 -9
  43. package/test/add-series-test.js +5 -5
  44. package/test/add-user-batch_test.js +5 -5
  45. package/test/add-user-callback_test.js +9 -9
  46. package/test/add-user-property-batch_test.js +6 -6
  47. package/test/add-user-property-callback_test.js +10 -10
  48. package/test/add-user-property-test.js +5 -5
  49. package/test/add-user-test.js +5 -5
  50. package/test/composite-recommendation-batch_test.js +33 -0
  51. package/test/composite-recommendation-callback_test.js +37 -0
  52. package/test/composite-recommendation-test.js +39 -0
  53. package/test/create-auto-reql-segmentation-batch_test.js +3 -3
  54. package/test/create-auto-reql-segmentation-callback_test.js +5 -5
  55. package/test/create-auto-reql-segmentation-test.js +3 -3
  56. package/test/create-manual-reql-segmentation-batch_test.js +3 -3
  57. package/test/create-manual-reql-segmentation-callback_test.js +5 -5
  58. package/test/create-manual-reql-segmentation-test.js +3 -3
  59. package/test/create-property-based-segmentation-batch_test.js +3 -3
  60. package/test/create-property-based-segmentation-callback_test.js +5 -5
  61. package/test/create-property-based-segmentation-test.js +3 -3
  62. package/test/delete-all-search-synonyms-batch_test.js +2 -2
  63. package/test/delete-all-search-synonyms-callback_test.js +2 -2
  64. package/test/delete-all-search-synonyms-test.js +1 -1
  65. package/test/delete-bookmark-batch_test.js +3 -3
  66. package/test/delete-bookmark-callback_test.js +5 -5
  67. package/test/delete-bookmark-test.js +3 -3
  68. package/test/delete-cart-addition-batch_test.js +3 -3
  69. package/test/delete-cart-addition-callback_test.js +5 -5
  70. package/test/delete-cart-addition-test.js +3 -3
  71. package/test/delete-detail-view-batch_test.js +3 -3
  72. package/test/delete-detail-view-callback_test.js +5 -5
  73. package/test/delete-detail-view-test.js +3 -3
  74. package/test/delete-item-batch_test.js +5 -5
  75. package/test/delete-item-callback_test.js +11 -11
  76. package/test/delete-item-property-batch_test.js +5 -5
  77. package/test/delete-item-property-callback_test.js +11 -11
  78. package/test/delete-item-property-test.js +7 -7
  79. package/test/delete-item-test.js +7 -7
  80. package/test/delete-manual-reql-segment-batch_test.js +4 -4
  81. package/test/delete-manual-reql-segment-callback_test.js +4 -4
  82. package/test/delete-manual-reql-segment-test.js +1 -1
  83. package/test/delete-more-items-batch_test.js +4 -4
  84. package/test/delete-more-items-callback_test.js +4 -4
  85. package/test/delete-more-items-test.js +3 -3
  86. package/test/delete-purchase-batch_test.js +3 -3
  87. package/test/delete-purchase-callback_test.js +5 -5
  88. package/test/delete-purchase-test.js +3 -3
  89. package/test/delete-rating-batch_test.js +3 -3
  90. package/test/delete-rating-callback_test.js +5 -5
  91. package/test/delete-rating-test.js +3 -3
  92. package/test/delete-search-synonym-batch_test.js +4 -4
  93. package/test/delete-search-synonym-callback_test.js +6 -6
  94. package/test/delete-search-synonym-test.js +3 -3
  95. package/test/delete-segmentation-batch_test.js +4 -4
  96. package/test/delete-segmentation-callback_test.js +6 -6
  97. package/test/delete-segmentation-test.js +3 -3
  98. package/test/delete-series-batch_test.js +5 -5
  99. package/test/delete-series-callback_test.js +11 -11
  100. package/test/delete-series-test.js +7 -7
  101. package/test/delete-user-batch_test.js +5 -5
  102. package/test/delete-user-callback_test.js +11 -11
  103. package/test/delete-user-property-batch_test.js +5 -5
  104. package/test/delete-user-property-callback_test.js +11 -11
  105. package/test/delete-user-property-test.js +7 -7
  106. package/test/delete-user-test.js +7 -7
  107. package/test/delete-view-portion-batch_test.js +3 -3
  108. package/test/delete-view-portion-callback_test.js +5 -5
  109. package/test/delete-view-portion-test.js +3 -3
  110. package/test/get-item-property-info-batch_test.js +5 -5
  111. package/test/get-item-property-info-callback_test.js +5 -5
  112. package/test/get-item-property-info-test.js +3 -3
  113. package/test/get-item-values-batch_test.js +4 -4
  114. package/test/get-item-values-callback_test.js +4 -4
  115. package/test/get-item-values-test.js +3 -3
  116. package/test/get-segmentation-batch_test.js +4 -4
  117. package/test/get-segmentation-callback_test.js +4 -4
  118. package/test/get-segmentation-test.js +2 -2
  119. package/test/get-user-property-info-batch_test.js +5 -5
  120. package/test/get-user-property-info-callback_test.js +5 -5
  121. package/test/get-user-property-info-test.js +3 -3
  122. package/test/get-user-values-batch_test.js +4 -4
  123. package/test/get-user-values-callback_test.js +4 -4
  124. package/test/get-user-values-test.js +3 -3
  125. package/test/insert-to-series-batch_test.js +7 -7
  126. package/test/insert-to-series-callback_test.js +9 -9
  127. package/test/insert-to-series-test.js +3 -3
  128. package/test/list-item-bookmarks-batch_test.js +5 -5
  129. package/test/list-item-bookmarks-callback_test.js +5 -5
  130. package/test/list-item-bookmarks-test.js +4 -4
  131. package/test/list-item-cart-additions-batch_test.js +5 -5
  132. package/test/list-item-cart-additions-callback_test.js +5 -5
  133. package/test/list-item-cart-additions-test.js +4 -4
  134. package/test/list-item-detail-views-batch_test.js +5 -5
  135. package/test/list-item-detail-views-callback_test.js +5 -5
  136. package/test/list-item-detail-views-test.js +4 -4
  137. package/test/list-item-properties-batch_test.js +3 -3
  138. package/test/list-item-properties-callback_test.js +3 -3
  139. package/test/list-item-properties-test.js +2 -2
  140. package/test/list-item-purchases-batch_test.js +5 -5
  141. package/test/list-item-purchases-callback_test.js +5 -5
  142. package/test/list-item-purchases-test.js +4 -4
  143. package/test/list-item-ratings-batch_test.js +5 -5
  144. package/test/list-item-ratings-callback_test.js +5 -5
  145. package/test/list-item-ratings-test.js +4 -4
  146. package/test/list-item-view-portions-batch_test.js +5 -5
  147. package/test/list-item-view-portions-callback_test.js +5 -5
  148. package/test/list-item-view-portions-test.js +4 -4
  149. package/test/list-items-batch_test.js +5 -5
  150. package/test/list-items-callback_test.js +5 -5
  151. package/test/list-items-test.js +3 -3
  152. package/test/list-scenarios-batch_test.js +2 -2
  153. package/test/list-scenarios-callback_test.js +2 -2
  154. package/test/list-scenarios-test.js +1 -1
  155. package/test/list-search-synonyms-batch_test.js +6 -6
  156. package/test/list-search-synonyms-callback_test.js +6 -6
  157. package/test/list-search-synonyms-test.js +3 -3
  158. package/test/list-segmentations-batch_test.js +4 -4
  159. package/test/list-segmentations-callback_test.js +4 -4
  160. package/test/list-segmentations-test.js +2 -2
  161. package/test/list-series-batch_test.js +3 -3
  162. package/test/list-series-callback_test.js +3 -3
  163. package/test/list-series-items-batch_test.js +5 -5
  164. package/test/list-series-items-callback_test.js +5 -5
  165. package/test/list-series-items-test.js +4 -4
  166. package/test/list-series-test.js +2 -2
  167. package/test/list-user-bookmarks-batch_test.js +5 -5
  168. package/test/list-user-bookmarks-callback_test.js +5 -5
  169. package/test/list-user-bookmarks-test.js +4 -4
  170. package/test/list-user-cart-additions-batch_test.js +5 -5
  171. package/test/list-user-cart-additions-callback_test.js +5 -5
  172. package/test/list-user-cart-additions-test.js +4 -4
  173. package/test/list-user-detail-views-batch_test.js +5 -5
  174. package/test/list-user-detail-views-callback_test.js +5 -5
  175. package/test/list-user-detail-views-test.js +4 -4
  176. package/test/list-user-properties-batch_test.js +3 -3
  177. package/test/list-user-properties-callback_test.js +3 -3
  178. package/test/list-user-properties-test.js +2 -2
  179. package/test/list-user-purchases-batch_test.js +5 -5
  180. package/test/list-user-purchases-callback_test.js +5 -5
  181. package/test/list-user-purchases-test.js +4 -4
  182. package/test/list-user-ratings-batch_test.js +5 -5
  183. package/test/list-user-ratings-callback_test.js +5 -5
  184. package/test/list-user-ratings-test.js +4 -4
  185. package/test/list-user-view-portions-batch_test.js +5 -5
  186. package/test/list-user-view-portions-callback_test.js +5 -5
  187. package/test/list-user-view-portions-test.js +4 -4
  188. package/test/list-users-batch_test.js +5 -5
  189. package/test/list-users-callback_test.js +5 -5
  190. package/test/list-users-test.js +3 -3
  191. package/test/merge-users-batch_test.js +4 -4
  192. package/test/merge-users-callback_test.js +6 -6
  193. package/test/merge-users-test.js +3 -3
  194. package/test/recommend-item-segments-to-item-batch_test.js +2 -2
  195. package/test/recommend-item-segments-to-item-callback_test.js +4 -4
  196. package/test/recommend-item-segments-to-item-segment-batch_test.js +2 -2
  197. package/test/recommend-item-segments-to-item-segment-callback_test.js +4 -4
  198. package/test/recommend-item-segments-to-item-segment-test.js +3 -3
  199. package/test/recommend-item-segments-to-item-test.js +3 -3
  200. package/test/recommend-item-segments-to-user-batch_test.js +2 -2
  201. package/test/recommend-item-segments-to-user-callback_test.js +4 -4
  202. package/test/recommend-item-segments-to-user-test.js +3 -3
  203. package/test/recommend-items-to-item-batch_test.js +4 -4
  204. package/test/recommend-items-to-item-callback_test.js +4 -4
  205. package/test/recommend-items-to-item-segment-batch_test.js +2 -2
  206. package/test/recommend-items-to-item-segment-callback_test.js +4 -4
  207. package/test/recommend-items-to-item-segment-test.js +3 -3
  208. package/test/recommend-items-to-item-test.js +1 -1
  209. package/test/recommend-items-to-user-batch_test.js +7 -5
  210. package/test/recommend-items-to-user-callback_test.js +17 -4
  211. package/test/recommend-items-to-user-test.js +10 -1
  212. package/test/recommend-next-items-batch_test.js +6 -6
  213. package/test/recommend-next-items-callback_test.js +6 -6
  214. package/test/recommend-next-items-test.js +3 -3
  215. package/test/recommend-users-to-item-batch_test.js +7 -5
  216. package/test/recommend-users-to-item-callback_test.js +17 -4
  217. package/test/recommend-users-to-item-test.js +10 -1
  218. package/test/recommend-users-to-user-batch_test.js +7 -5
  219. package/test/recommend-users-to-user-callback_test.js +17 -4
  220. package/test/recommend-users-to-user-test.js +10 -1
  221. package/test/remove-from-series-batch_test.js +3 -3
  222. package/test/remove-from-series-callback_test.js +5 -5
  223. package/test/remove-from-series-test.js +3 -3
  224. package/test/search-item-segments-batch_test.js +2 -2
  225. package/test/search-item-segments-callback_test.js +4 -4
  226. package/test/search-item-segments-test.js +3 -3
  227. package/test/search-items-batch_test.js +7 -7
  228. package/test/search-items-callback_test.js +7 -7
  229. package/test/search-items-test.js +4 -4
  230. package/test/set-item-values-batch_test.js +7 -7
  231. package/test/set-item-values-callback_test.js +9 -9
  232. package/test/set-item-values-test.js +3 -3
  233. package/test/set-user-values-batch_test.js +7 -7
  234. package/test/set-user-values-callback_test.js +9 -9
  235. package/test/set-user-values-test.js +3 -3
  236. package/test/set-view-portion-batch_test.js +7 -7
  237. package/test/set-view-portion-callback_test.js +15 -15
  238. package/test/set-view-portion-test.js +9 -9
  239. package/test/update-auto-reql-segmentation-batch_test.js +3 -3
  240. package/test/update-auto-reql-segmentation-callback_test.js +3 -3
  241. package/test/update-auto-reql-segmentation-test.js +1 -1
  242. package/test/update-manual-reql-segment-batch_test.js +4 -4
  243. package/test/update-manual-reql-segment-callback_test.js +4 -4
  244. package/test/update-manual-reql-segment-test.js +1 -1
  245. package/test/update-manual-reql-segmentation-batch_test.js +3 -3
  246. package/test/update-manual-reql-segmentation-callback_test.js +3 -3
  247. package/test/update-manual-reql-segmentation-test.js +1 -1
  248. package/test/update-more-items-batch_test.js +4 -4
  249. package/test/update-more-items-callback_test.js +4 -4
  250. package/test/update-more-items-test.js +3 -3
  251. package/test/update-property-based-segmentation-batch_test.js +3 -3
  252. package/test/update-property-based-segmentation-callback_test.js +3 -3
  253. package/test/update-property-based-segmentation-test.js +1 -1
@@ -31,6 +31,9 @@ class AddDetailView extends rqs.Request {
31
31
  * - *additionalData*
32
32
  * - Type: object
33
33
  * - Description: A dictionary of additional data for the interaction.
34
+ * - *autoPresented*
35
+ * - Type: boolean
36
+ * - Description: Indicates whether the item was automatically presented to the user (e.g., in a swiping feed) or explicitly requested by the user (e.g., by clicking on a link). Defaults to `false`.
34
37
  */
35
38
  constructor(userId, itemId, optional) {
36
39
  super('POST', '/detailviews/', 3000, false);
@@ -42,6 +45,7 @@ class AddDetailView extends rqs.Request {
42
45
  this.cascadeCreate = optional.cascadeCreate;
43
46
  this.recommId = optional.recommId;
44
47
  this.additionalData = optional.additionalData;
48
+ this.autoPresented = optional.autoPresented;
45
49
  }
46
50
 
47
51
  /**
@@ -68,6 +72,9 @@ class AddDetailView extends rqs.Request {
68
72
  if(this.additionalData !== undefined)
69
73
  params.additionalData = this.additionalData;
70
74
 
75
+ if(this.autoPresented !== undefined)
76
+ params.autoPresented = this.autoPresented;
77
+
71
78
  return params;
72
79
  }
73
80
 
@@ -0,0 +1,127 @@
1
+ /*
2
+ This file is auto-generated, do not edit
3
+ */
4
+
5
+ 'use strict';
6
+ const rqs = require("./request");
7
+
8
+ /**
9
+ * Composite Recommendation returns both a *source entity* (e.g., an Item or [Item Segment](https://docs.recombee.com/segmentations.html)) and a list of related recommendations in a single response.
10
+ * It is ideal for use cases such as personalized homepage sections (*Articles from <category>*), *Because You Watched <movie>*, or *Artists Related to Your Favorite Artist <artist>*.
11
+ * See detailed **examples and configuration guidance** in the [Composite Scenarios documentation](https://docs.recombee.com/scenarios#composite-recommendations).
12
+ * **Structure**
13
+ * The endpoint operates in two stages:
14
+ * 1. Recommends the *source* (e.g., an Item Segment or item) to the user.
15
+ * 2. Recommends *results* (items or Item Segments) related to that *source*.
16
+ * For example, *Articles from <category>* can be decomposed into:
17
+ * - [Recommend Item Segments To User](https://docs.recombee.com/api#recommend-item-segments-to-user) to find the category.
18
+ * - [Recommend Items To Item Segment](https://docs.recombee.com/api#recommend-items-to-item-segment) to recommend articles from that category.
19
+ * Since the first step uses [Recommend Item Segments To User](https://docs.recombee.com/api#recommend-items-to-user), you must include the `userId` parameter in the *Composite Recommendation* request.
20
+ * Each *Composite Recommendation* counts as a single recommendation API request for billing.
21
+ * **Stage-specific Parameters**
22
+ * Additional parameters can be supplied via [sourceSettings](https://docs.recombee.com/api#composite-recommendation-param-sourceSettings) and [resultSettings](https://docs.recombee.com/api#composite-recommendation-param-resultSettings).
23
+ * In the example above:
24
+ * - `sourceSettings` may include any parameter valid for [Recommend Item Segments To User](https://docs.recombee.com/api#recommend-items-to-user) (e.g., `filter`, `booster`).
25
+ * - `resultSettings` may include any parameter valid for [Recommend Items To Item Segment](https://docs.recombee.com/api#recommend-items-to-item-segment).
26
+ * See [this example](https://docs.recombee.com/api#composite-recommendation-example-setting-parameters-for-individual-stages) for more details.
27
+ */
28
+ class CompositeRecommendation extends rqs.Request {
29
+
30
+ /**
31
+ * Construct the request
32
+ * @param {string} scenario - Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".
33
+ * You can set various settings to the [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs.
34
+ * The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios.
35
+ * @param {number} count - Number of items to be recommended (N for the top-N recommendation).
36
+ * @param {Object} optional - Optional parameters given as an object with structure name of the parameter: value
37
+ * - Allowed parameters:
38
+ * - *itemId*
39
+ * - Type: string
40
+ * - Description: ID of the item for which the recommendations are to be generated.
41
+ * - *userId*
42
+ * - Type: string
43
+ * - Description: ID of the user for which the recommendations are to be generated.
44
+ * - *logic*
45
+ * - Type: string | object
46
+ * - Description: Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case.
47
+ * See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
48
+ * The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
49
+ * Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
50
+ * - *segmentId*
51
+ * - Type: string
52
+ * - Description: ID of the segment from `contextSegmentationId` for which the recommendations are to be generated.
53
+ * - *cascadeCreate*
54
+ * - Type: boolean
55
+ * - Description: If the entity for the source recommendation does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows, for example, rotations in the following recommendations for that entity, as the entity will be already known to the system.
56
+ * - *sourceSettings*
57
+ * - Type: object
58
+ * - Description: Parameters applied for recommending the *Source* stage. The accepted parameters correspond with the recommendation sub-endpoint used to recommend the *Source*.
59
+ * - *resultSettings*
60
+ * - Type: object
61
+ * - Description: Parameters applied for recommending the *Result* stage. The accepted parameters correspond with the recommendation sub-endpoint used to recommend the *Result*.
62
+ * - *expertSettings*
63
+ * - Type: object
64
+ * - Description: Dictionary of custom options.
65
+ */
66
+ constructor(scenario, count, optional) {
67
+ super('POST', '/recomms/composite/', 3000, false);
68
+ this.scenario = scenario;
69
+ this.count = count;
70
+ optional = optional || {};
71
+ this.itemId = optional.itemId;
72
+ this.userId = optional.userId;
73
+ this.logic = optional.logic;
74
+ this.segmentId = optional.segmentId;
75
+ this.cascadeCreate = optional.cascadeCreate;
76
+ this.sourceSettings = optional.sourceSettings;
77
+ this.resultSettings = optional.resultSettings;
78
+ this.expertSettings = optional.expertSettings;
79
+ }
80
+
81
+ /**
82
+ * Get body parameters
83
+ * @return {Object} The values of body parameters (name of parameter: value of the parameter)
84
+ */
85
+ bodyParameters() {
86
+ let params = {};
87
+ params.scenario = this.scenario;
88
+ params.count = this.count;
89
+
90
+ if(this.itemId !== undefined)
91
+ params.itemId = this.itemId;
92
+
93
+ if(this.userId !== undefined)
94
+ params.userId = this.userId;
95
+
96
+ if(this.logic !== undefined)
97
+ params.logic = this.logic;
98
+
99
+ if(this.segmentId !== undefined)
100
+ params.segmentId = this.segmentId;
101
+
102
+ if(this.cascadeCreate !== undefined)
103
+ params.cascadeCreate = this.cascadeCreate;
104
+
105
+ if(this.sourceSettings !== undefined)
106
+ params.sourceSettings = this.sourceSettings;
107
+
108
+ if(this.resultSettings !== undefined)
109
+ params.resultSettings = this.resultSettings;
110
+
111
+ if(this.expertSettings !== undefined)
112
+ params.expertSettings = this.expertSettings;
113
+
114
+ return params;
115
+ }
116
+
117
+ /**
118
+ * Get query parameters
119
+ * @return {Object} The values of query parameters (name of parameter: value of the parameter)
120
+ */
121
+ queryParameters() {
122
+ let params = {};
123
+ return params;
124
+ }
125
+ }
126
+
127
+ exports.CompositeRecommendation = CompositeRecommendation
@@ -63,6 +63,7 @@ exports.RecommendUsersToItem = require("./recommend-users-to-item").RecommendUse
63
63
  exports.RecommendItemSegmentsToUser = require("./recommend-item-segments-to-user").RecommendItemSegmentsToUser;
64
64
  exports.RecommendItemSegmentsToItem = require("./recommend-item-segments-to-item").RecommendItemSegmentsToItem;
65
65
  exports.RecommendItemSegmentsToItemSegment = require("./recommend-item-segments-to-item-segment").RecommendItemSegmentsToItemSegment;
66
+ exports.CompositeRecommendation = require("./composite-recommendation").CompositeRecommendation;
66
67
  exports.SearchItems = require("./search-items").SearchItems;
67
68
  exports.SearchItemSegments = require("./search-item-segments").SearchItemSegments;
68
69
  exports.AddSearchSynonym = require("./add-search-synonym").AddSearchSynonym;
@@ -116,6 +116,44 @@ class RecommendItemsToItemSegment extends rqs.Request {
116
116
  * See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
117
117
  * The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
118
118
  * Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
119
+ * - *reqlExpressions*
120
+ * - Type: object
121
+ * - Description: A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended item.
122
+ * This can be used to compute additional properties of the recommended items that are not stored in the database.
123
+ * The keys are the names of the expressions, and the values are the actual ReQL expressions.
124
+ * Example request:
125
+ * ```json
126
+ * {
127
+ * "reqlExpressions": {
128
+ * "isInUsersCity": "context_user[\"city\"] in 'cities'",
129
+ * "distanceToUser": "earth_distance('location', context_user[\"location\"])"
130
+ * }
131
+ * }
132
+ * ```
133
+ * Example response:
134
+ * ```json
135
+ * {
136
+ * "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
137
+ * "recomms":
138
+ * [
139
+ * {
140
+ * "id": "restaurant-178",
141
+ * "reqlEvaluations": {
142
+ * "isInUsersCity": true,
143
+ * "distanceToUser": 5200.2
144
+ * }
145
+ * },
146
+ * {
147
+ * "id": "bar-42",
148
+ * "reqlEvaluations": {
149
+ * "isInUsersCity": false,
150
+ * "distanceToUser": 2516.0
151
+ * }
152
+ * }
153
+ * ],
154
+ * "numberNextRecommsCalls": 0
155
+ * }
156
+ * ```
119
157
  * - *minRelevance*
120
158
  * - Type: string
121
159
  * - Description: **Expert option:** If the *targetUserId* is provided: Specifies the threshold of how relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend a number of items equal to *count* at any cost. If there is not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations being appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested relevance and may return less than *count* items when there is not enough data to fulfill it.
@@ -145,6 +183,7 @@ class RecommendItemsToItemSegment extends rqs.Request {
145
183
  this.filter = optional.filter;
146
184
  this.booster = optional.booster;
147
185
  this.logic = optional.logic;
186
+ this.reqlExpressions = optional.reqlExpressions;
148
187
  this.minRelevance = optional.minRelevance;
149
188
  this.rotationRate = optional.rotationRate;
150
189
  this.rotationTime = optional.rotationTime;
@@ -183,6 +222,9 @@ class RecommendItemsToItemSegment extends rqs.Request {
183
222
  if(this.logic !== undefined)
184
223
  params.logic = this.logic;
185
224
 
225
+ if(this.reqlExpressions !== undefined)
226
+ params.reqlExpressions = this.reqlExpressions;
227
+
186
228
  if(this.minRelevance !== undefined)
187
229
  params.minRelevance = this.minRelevance;
188
230
 
@@ -114,6 +114,47 @@ class RecommendItemsToItem extends rqs.Request {
114
114
  * See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
115
115
  * The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
116
116
  * Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
117
+ * - *reqlExpressions*
118
+ * - Type: object
119
+ * - Description: A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended item.
120
+ * This can be used to compute additional properties of the recommended items that are not stored in the database.
121
+ * The keys are the names of the expressions, and the values are the actual ReQL expressions.
122
+ * Example request:
123
+ * ```json
124
+ * {
125
+ * "reqlExpressions": {
126
+ * "isInUsersCity": "context_user[\"city\"] in 'cities'",
127
+ * "distanceToUser": "earth_distance('location', context_user[\"location\"])",
128
+ * "isFromSameCompany": "'company' == context_item[\"company\"]"
129
+ * }
130
+ * }
131
+ * ```
132
+ * Example response:
133
+ * ```json
134
+ * {
135
+ * "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
136
+ * "recomms":
137
+ * [
138
+ * {
139
+ * "id": "restaurant-178",
140
+ * "reqlEvaluations": {
141
+ * "isInUsersCity": true,
142
+ * "distanceToUser": 5200.2,
143
+ * "isFromSameCompany": false
144
+ * }
145
+ * },
146
+ * {
147
+ * "id": "bar-42",
148
+ * "reqlEvaluations": {
149
+ * "isInUsersCity": false,
150
+ * "distanceToUser": 2516.0,
151
+ * "isFromSameCompany": true
152
+ * }
153
+ * }
154
+ * ],
155
+ * "numberNextRecommsCalls": 0
156
+ * }
157
+ * ```
117
158
  * - *userImpact*
118
159
  * - Type: number
119
160
  * - Description: **Expert option:** If *targetUserId* parameter is present, the recommendations are biased towards the given user. Using *userImpact*, you may control this bias. For an extreme case of `userImpact=0.0`, the interactions made by the user are not taken into account at all (with the exception of history-based blacklisting), for `userImpact=1.0`, you'll get a user-based recommendation. The default value is `0`.
@@ -149,6 +190,7 @@ class RecommendItemsToItem extends rqs.Request {
149
190
  this.filter = optional.filter;
150
191
  this.booster = optional.booster;
151
192
  this.logic = optional.logic;
193
+ this.reqlExpressions = optional.reqlExpressions;
152
194
  this.userImpact = optional.userImpact;
153
195
  this.diversity = optional.diversity;
154
196
  this.minRelevance = optional.minRelevance;
@@ -188,6 +230,9 @@ class RecommendItemsToItem extends rqs.Request {
188
230
  if(this.logic !== undefined)
189
231
  params.logic = this.logic;
190
232
 
233
+ if(this.reqlExpressions !== undefined)
234
+ params.reqlExpressions = this.reqlExpressions;
235
+
191
236
  if(this.userImpact !== undefined)
192
237
  params.userImpact = this.userImpact;
193
238
 
@@ -102,6 +102,44 @@ class RecommendItemsToUser extends rqs.Request {
102
102
  * See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
103
103
  * The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
104
104
  * Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
105
+ * - *reqlExpressions*
106
+ * - Type: object
107
+ * - Description: A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended item.
108
+ * This can be used to compute additional properties of the recommended items that are not stored in the database.
109
+ * The keys are the names of the expressions, and the values are the actual ReQL expressions.
110
+ * Example request:
111
+ * ```json
112
+ * {
113
+ * "reqlExpressions": {
114
+ * "isInUsersCity": "context_user[\"city\"] in 'cities'",
115
+ * "distanceToUser": "earth_distance('location', context_user[\"location\"])"
116
+ * }
117
+ * }
118
+ * ```
119
+ * Example response:
120
+ * ```json
121
+ * {
122
+ * "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
123
+ * "recomms":
124
+ * [
125
+ * {
126
+ * "id": "restaurant-178",
127
+ * "reqlEvaluations": {
128
+ * "isInUsersCity": true,
129
+ * "distanceToUser": 5200.2
130
+ * }
131
+ * },
132
+ * {
133
+ * "id": "bar-42",
134
+ * "reqlEvaluations": {
135
+ * "isInUsersCity": false,
136
+ * "distanceToUser": 2516.0
137
+ * }
138
+ * }
139
+ * ],
140
+ * "numberNextRecommsCalls": 0
141
+ * }
142
+ * ```
105
143
  * - *diversity*
106
144
  * - Type: number
107
145
  * - Description: **Expert option:** Real number from [0.0, 1.0], which determines how mutually dissimilar the recommended items should be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
@@ -133,6 +171,7 @@ class RecommendItemsToUser extends rqs.Request {
133
171
  this.filter = optional.filter;
134
172
  this.booster = optional.booster;
135
173
  this.logic = optional.logic;
174
+ this.reqlExpressions = optional.reqlExpressions;
136
175
  this.diversity = optional.diversity;
137
176
  this.minRelevance = optional.minRelevance;
138
177
  this.rotationRate = optional.rotationRate;
@@ -170,6 +209,9 @@ class RecommendItemsToUser extends rqs.Request {
170
209
  if(this.logic !== undefined)
171
210
  params.logic = this.logic;
172
211
 
212
+ if(this.reqlExpressions !== undefined)
213
+ params.reqlExpressions = this.reqlExpressions;
214
+
173
215
  if(this.diversity !== undefined)
174
216
  params.diversity = this.diversity;
175
217
 
@@ -92,6 +92,47 @@ class RecommendUsersToItem extends rqs.Request {
92
92
  * See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
93
93
  * The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
94
94
  * Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
95
+ * - *reqlExpressions*
96
+ * - Type: object
97
+ * - Description: A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended user.
98
+ * This can be used to compute additional properties of the recommended users that are not stored in the database.
99
+ * The keys are the names of the expressions, and the values are the actual ReQL expressions.
100
+ * Example request:
101
+ * ```json
102
+ * {
103
+ * "reqlExpressions": {
104
+ * "isInUsersCity": "context_user[\"city\"] in 'cities'",
105
+ * "distanceToUser": "earth_distance('location', context_user[\"location\"])",
106
+ * "isFromSameCompany": "'company' == context_item[\"company\"]"
107
+ * }
108
+ * }
109
+ * ```
110
+ * Example response:
111
+ * ```json
112
+ * {
113
+ * "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
114
+ * "recomms":
115
+ * [
116
+ * {
117
+ * "id": "restaurant-178",
118
+ * "reqlEvaluations": {
119
+ * "isInUsersCity": true,
120
+ * "distanceToUser": 5200.2,
121
+ * "isFromSameCompany": false
122
+ * }
123
+ * },
124
+ * {
125
+ * "id": "bar-42",
126
+ * "reqlEvaluations": {
127
+ * "isInUsersCity": false,
128
+ * "distanceToUser": 2516.0,
129
+ * "isFromSameCompany": true
130
+ * }
131
+ * }
132
+ * ],
133
+ * "numberNextRecommsCalls": 0
134
+ * }
135
+ * ```
95
136
  * - *diversity*
96
137
  * - Type: number
97
138
  * - Description: **Expert option:** Real number from [0.0, 1.0], which determines how mutually dissimilar the recommended users should be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
@@ -114,6 +155,7 @@ class RecommendUsersToItem extends rqs.Request {
114
155
  this.filter = optional.filter;
115
156
  this.booster = optional.booster;
116
157
  this.logic = optional.logic;
158
+ this.reqlExpressions = optional.reqlExpressions;
117
159
  this.diversity = optional.diversity;
118
160
  this.expertSettings = optional.expertSettings;
119
161
  this.returnAbGroup = optional.returnAbGroup;
@@ -148,6 +190,9 @@ class RecommendUsersToItem extends rqs.Request {
148
190
  if(this.logic !== undefined)
149
191
  params.logic = this.logic;
150
192
 
193
+ if(this.reqlExpressions !== undefined)
194
+ params.reqlExpressions = this.reqlExpressions;
195
+
151
196
  if(this.diversity !== undefined)
152
197
  params.diversity = this.diversity;
153
198
 
@@ -92,6 +92,44 @@ class RecommendUsersToUser extends rqs.Request {
92
92
  * See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
93
93
  * The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
94
94
  * Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
95
+ * - *reqlExpressions*
96
+ * - Type: object
97
+ * - Description: A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended user.
98
+ * This can be used to compute additional properties of the recommended users that are not stored in the database.
99
+ * The keys are the names of the expressions, and the values are the actual ReQL expressions.
100
+ * Example request:
101
+ * ```json
102
+ * {
103
+ * "reqlExpressions": {
104
+ * "isInUsersCity": "context_user[\"city\"] in 'cities'",
105
+ * "distanceToUser": "earth_distance('location', context_user[\"location\"])"
106
+ * }
107
+ * }
108
+ * ```
109
+ * Example response:
110
+ * ```json
111
+ * {
112
+ * "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
113
+ * "recomms":
114
+ * [
115
+ * {
116
+ * "id": "restaurant-178",
117
+ * "reqlEvaluations": {
118
+ * "isInUsersCity": true,
119
+ * "distanceToUser": 5200.2
120
+ * }
121
+ * },
122
+ * {
123
+ * "id": "bar-42",
124
+ * "reqlEvaluations": {
125
+ * "isInUsersCity": false,
126
+ * "distanceToUser": 2516.0
127
+ * }
128
+ * }
129
+ * ],
130
+ * "numberNextRecommsCalls": 0
131
+ * }
132
+ * ```
95
133
  * - *diversity*
96
134
  * - Type: number
97
135
  * - Description: **Expert option:** Real number from [0.0, 1.0], which determines how mutually dissimilar the recommended users should be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
@@ -123,6 +161,7 @@ class RecommendUsersToUser extends rqs.Request {
123
161
  this.filter = optional.filter;
124
162
  this.booster = optional.booster;
125
163
  this.logic = optional.logic;
164
+ this.reqlExpressions = optional.reqlExpressions;
126
165
  this.diversity = optional.diversity;
127
166
  this.minRelevance = optional.minRelevance;
128
167
  this.rotationRate = optional.rotationRate;
@@ -160,6 +199,9 @@ class RecommendUsersToUser extends rqs.Request {
160
199
  if(this.logic !== undefined)
161
200
  params.logic = this.logic;
162
201
 
202
+ if(this.reqlExpressions !== undefined)
203
+ params.reqlExpressions = this.reqlExpressions;
204
+
163
205
  if(this.diversity !== undefined)
164
206
  params.diversity = this.diversity;
165
207
 
@@ -104,6 +104,44 @@ class SearchItems extends rqs.Request {
104
104
  * See [this section](https://docs.recombee.com/recommendation_logics) for a list of available logics and other details.
105
105
  * The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
106
106
  * Logic can also be set to a [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com).
107
+ * - *reqlExpressions*
108
+ * - Type: object
109
+ * - Description: A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended item.
110
+ * This can be used to compute additional properties of the recommended items that are not stored in the database.
111
+ * The keys are the names of the expressions, and the values are the actual ReQL expressions.
112
+ * Example request:
113
+ * ```json
114
+ * {
115
+ * "reqlExpressions": {
116
+ * "isInUsersCity": "context_user[\"city\"] in 'cities'",
117
+ * "distanceToUser": "earth_distance('location', context_user[\"location\"])"
118
+ * }
119
+ * }
120
+ * ```
121
+ * Example response:
122
+ * ```json
123
+ * {
124
+ * "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
125
+ * "recomms":
126
+ * [
127
+ * {
128
+ * "id": "restaurant-178",
129
+ * "reqlEvaluations": {
130
+ * "isInUsersCity": true,
131
+ * "distanceToUser": 5200.2
132
+ * }
133
+ * },
134
+ * {
135
+ * "id": "bar-42",
136
+ * "reqlEvaluations": {
137
+ * "isInUsersCity": false,
138
+ * "distanceToUser": 2516.0
139
+ * }
140
+ * }
141
+ * ],
142
+ * "numberNextRecommsCalls": 0
143
+ * }
144
+ * ```
107
145
  * - *expertSettings*
108
146
  * - Type: object
109
147
  * - Description: Dictionary of custom options.
@@ -124,6 +162,7 @@ class SearchItems extends rqs.Request {
124
162
  this.filter = optional.filter;
125
163
  this.booster = optional.booster;
126
164
  this.logic = optional.logic;
165
+ this.reqlExpressions = optional.reqlExpressions;
127
166
  this.expertSettings = optional.expertSettings;
128
167
  this.returnAbGroup = optional.returnAbGroup;
129
168
  }
@@ -158,6 +197,9 @@ class SearchItems extends rqs.Request {
158
197
  if(this.logic !== undefined)
159
198
  params.logic = this.logic;
160
199
 
200
+ if(this.reqlExpressions !== undefined)
201
+ params.reqlExpressions = this.reqlExpressions;
202
+
161
203
  if(this.expertSettings !== undefined)
162
204
  params.expertSettings = this.expertSettings;
163
205
 
@@ -33,6 +33,12 @@ class SetViewPortion extends rqs.Request {
33
33
  * - *additionalData*
34
34
  * - Type: object
35
35
  * - Description: A dictionary of additional data for the interaction.
36
+ * - *autoPresented*
37
+ * - Type: boolean
38
+ * - Description: Indicates whether the item was automatically presented to the user (e.g., in a swiping feed) or explicitly requested by the user (e.g., by clicking on a link). Defaults to `false`.
39
+ * - *timeSpent*
40
+ * - Type: number
41
+ * - Description: The duration (in seconds) that the user viewed the item. In update requests, this value may only increase and is required only if it has changed.
36
42
  */
37
43
  constructor(userId, itemId, portion, optional) {
38
44
  super('POST', '/viewportions/', 3000, false);
@@ -45,6 +51,8 @@ class SetViewPortion extends rqs.Request {
45
51
  this.cascadeCreate = optional.cascadeCreate;
46
52
  this.recommId = optional.recommId;
47
53
  this.additionalData = optional.additionalData;
54
+ this.autoPresented = optional.autoPresented;
55
+ this.timeSpent = optional.timeSpent;
48
56
  }
49
57
 
50
58
  /**
@@ -72,6 +80,12 @@ class SetViewPortion extends rqs.Request {
72
80
  if(this.additionalData !== undefined)
73
81
  params.additionalData = this.additionalData;
74
82
 
83
+ if(this.autoPresented !== undefined)
84
+ params.autoPresented = this.autoPresented;
85
+
86
+ if(this.timeSpent !== undefined)
87
+ params.timeSpent = this.timeSpent;
88
+
75
89
  return params;
76
90
  }
77
91
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recombee-api-client",
3
- "version": "5.1.1",
3
+ "version": "6.0.0",
4
4
  "description": "Node.js client (SDK) for easy use of the Recombee recommendation API",
5
5
  "main": "index.js",
6
6
  "types": "lib/index.d.ts",
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  'use strict'
6
- var chai = require('chai').assert;
6
+ var assert = require('chai').assert;
7
7
  var recombee = require('./../index.js');
8
8
  var rqs = recombee.requests;
9
9
 
@@ -32,13 +32,13 @@ describe('AddBookmark', function(){
32
32
 
33
33
  env.client.send(new rqs.Batch(requests))
34
34
  .then((responses) => {
35
- chai.equal(responses[0].code, 200);
36
- chai.equal(responses[1].code, 200);
37
- chai.equal(responses[2].code, 200);
38
- chai.equal(responses[3].code, 404);
39
- chai.equal(responses[4].code, 404);
40
- chai.equal(responses[5].code, 200);
41
- chai.equal(responses[6].code, 409);
35
+ assert.equal(responses[0].code, 200);
36
+ assert.equal(responses[1].code, 200);
37
+ assert.equal(responses[2].code, 200);
38
+ assert.equal(responses[3].code, 404);
39
+ assert.equal(responses[4].code, 404);
40
+ assert.equal(responses[5].code, 200);
41
+ assert.equal(responses[6].code, 409);
42
42
  done();
43
43
  });
44
44
  });