Skip to content

Commit 9934f0a

Browse files
committed
Support reqlExpressions parameter in endpoints that return Item Segments
1 parent 6e59dd8 commit 9934f0a

File tree

7 files changed

+174
-2
lines changed

7 files changed

+174
-2
lines changed

lib/api-client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ApiClient {
4343
method: request.method,
4444
headers: {'Accept': 'application/json',
4545
'Content-Type': 'application/json',
46-
'User-Agent': 'recombee-node-api-client/6.0.0'},
46+
'User-Agent': 'recombee-node-api-client/6.1.0'},
4747
timeout: request.timeout,
4848
agent: this.options.agent
4949
};

lib/index.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,6 +2404,8 @@ declare module "recombee-api-client" {
24042404
expertSettings?: Record<string, unknown>;
24052405
/** If there is a custom AB-testing running, return the name of the group to which the request belongs. */
24062406
returnAbGroup?: boolean;
2407+
/** A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment. */
2408+
reqlExpressions?: Record<string, string>;
24072409
}
24082410
);
24092411

@@ -2416,6 +2418,7 @@ declare module "recombee-api-client" {
24162418
logic?: string | object;
24172419
expertSettings?: Record<string, unknown>;
24182420
returnAbGroup?: boolean;
2421+
reqlExpressions?: Record<string, string>;
24192422
protected __response_type: RecommendationResponse;
24202423

24212424
bodyParameters(): {
@@ -2427,6 +2430,7 @@ declare module "recombee-api-client" {
24272430
logic?: string | object;
24282431
expertSettings?: Record<string, unknown>;
24292432
returnAbGroup?: boolean;
2433+
reqlExpressions?: Record<string, string>;
24302434
};
24312435

24322436
queryParameters(): {
@@ -2482,6 +2486,8 @@ declare module "recombee-api-client" {
24822486
expertSettings?: Record<string, unknown>;
24832487
/** If there is a custom AB-testing running, return the name of the group to which the request belongs. */
24842488
returnAbGroup?: boolean;
2489+
/** A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment. */
2490+
reqlExpressions?: Record<string, string>;
24852491
}
24862492
);
24872493

@@ -2495,6 +2501,7 @@ declare module "recombee-api-client" {
24952501
logic?: string | object;
24962502
expertSettings?: Record<string, unknown>;
24972503
returnAbGroup?: boolean;
2504+
reqlExpressions?: Record<string, string>;
24982505
protected __response_type: RecommendationResponse;
24992506

25002507
bodyParameters(): {
@@ -2507,6 +2514,7 @@ declare module "recombee-api-client" {
25072514
logic?: string | object;
25082515
expertSettings?: Record<string, unknown>;
25092516
returnAbGroup?: boolean;
2517+
reqlExpressions?: Record<string, string>;
25102518
};
25112519

25122520
queryParameters(): {
@@ -2561,6 +2569,8 @@ declare module "recombee-api-client" {
25612569
expertSettings?: Record<string, unknown>;
25622570
/** If there is a custom AB-testing running, return the name of the group to which the request belongs. */
25632571
returnAbGroup?: boolean;
2572+
/** A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment. */
2573+
reqlExpressions?: Record<string, string>;
25642574
}
25652575
);
25662576

@@ -2574,6 +2584,7 @@ declare module "recombee-api-client" {
25742584
logic?: string | object;
25752585
expertSettings?: Record<string, unknown>;
25762586
returnAbGroup?: boolean;
2587+
reqlExpressions?: Record<string, string>;
25772588
protected __response_type: RecommendationResponse;
25782589

25792590
bodyParameters(): {
@@ -2587,6 +2598,7 @@ declare module "recombee-api-client" {
25872598
logic?: string | object;
25882599
expertSettings?: Record<string, unknown>;
25892600
returnAbGroup?: boolean;
2601+
reqlExpressions?: Record<string, string>;
25902602
};
25912603

25922604
queryParameters(): {
@@ -2788,6 +2800,8 @@ declare module "recombee-api-client" {
27882800
expertSettings?: Record<string, unknown>;
27892801
/** If there is a custom AB-testing running, return the name of the group to which the request belongs. */
27902802
returnAbGroup?: boolean;
2803+
/** A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment. */
2804+
reqlExpressions?: Record<string, string>;
27912805
}
27922806
);
27932807

@@ -2801,6 +2815,7 @@ declare module "recombee-api-client" {
28012815
logic?: string | object;
28022816
expertSettings?: Record<string, unknown>;
28032817
returnAbGroup?: boolean;
2818+
reqlExpressions?: Record<string, string>;
28042819
protected __response_type: SearchResponse;
28052820

28062821
bodyParameters(): {
@@ -2813,6 +2828,7 @@ declare module "recombee-api-client" {
28132828
logic?: string | object;
28142829
expertSettings?: Record<string, unknown>;
28152830
returnAbGroup?: boolean;
2831+
reqlExpressions?: Record<string, string>;
28162832
};
28172833

28182834
queryParameters(): {

lib/requests/recommend-item-segments-to-item-segment.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,41 @@ class RecommendItemSegmentsToItemSegment extends rqs.Request {
6262
* - *returnAbGroup*
6363
* - Type: boolean
6464
* - Description: If there is a custom AB-testing running, return the name of the group to which the request belongs.
65+
* - *reqlExpressions*
66+
* - Type: object
67+
* - Description: A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
68+
* This can be used to compute additional properties of the recommended Item Segments.
69+
* The keys are the names of the expressions, and the values are the actual ReQL expressions.
70+
* Example request:
71+
* ```json
72+
* {
73+
* "reqlExpressions": {
74+
* "countItems": "size(segment_items(\"categories\", 'segmentId'))"
75+
* }
76+
* }
77+
* ```
78+
* Example response:
79+
* ```json
80+
* {
81+
* "recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
82+
* "recomms":
83+
* [
84+
* {
85+
* "id": "category-fantasy-books",
86+
* "reqlEvaluations": {
87+
* "countItems": 486
88+
* }
89+
* },
90+
* {
91+
* "id": "category-sci-fi-costumes",
92+
* "reqlEvaluations": {
93+
* "countItems": 19
94+
* }
95+
* }
96+
* ],
97+
* "numberNextRecommsCalls": 0
98+
* }
99+
* ```
65100
*/
66101
constructor(contextSegmentId, targetUserId, count, optional) {
67102
super('POST', '/recomms/item-segments/item-segments/', 3000, false);
@@ -76,6 +111,7 @@ class RecommendItemSegmentsToItemSegment extends rqs.Request {
76111
this.logic = optional.logic;
77112
this.expertSettings = optional.expertSettings;
78113
this.returnAbGroup = optional.returnAbGroup;
114+
this.reqlExpressions = optional.reqlExpressions;
79115
}
80116

81117
/**
@@ -109,6 +145,9 @@ class RecommendItemSegmentsToItemSegment extends rqs.Request {
109145
if(this.returnAbGroup !== undefined)
110146
params.returnAbGroup = this.returnAbGroup;
111147

148+
if(this.reqlExpressions !== undefined)
149+
params.reqlExpressions = this.reqlExpressions;
150+
112151
return params;
113152
}
114153

lib/requests/recommend-item-segments-to-item.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,41 @@ class RecommendItemSegmentsToItem extends rqs.Request {
6363
* - *returnAbGroup*
6464
* - Type: boolean
6565
* - Description: If there is a custom AB-testing running, return the name of the group to which the request belongs.
66+
* - *reqlExpressions*
67+
* - Type: object
68+
* - Description: A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
69+
* This can be used to compute additional properties of the recommended Item Segments.
70+
* The keys are the names of the expressions, and the values are the actual ReQL expressions.
71+
* Example request:
72+
* ```json
73+
* {
74+
* "reqlExpressions": {
75+
* "countItems": "size(segment_items(\"categories\", 'segmentId'))"
76+
* }
77+
* }
78+
* ```
79+
* Example response:
80+
* ```json
81+
* {
82+
* "recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
83+
* "recomms":
84+
* [
85+
* {
86+
* "id": "category-fantasy-books",
87+
* "reqlEvaluations": {
88+
* "countItems": 486
89+
* }
90+
* },
91+
* {
92+
* "id": "category-sci-fi-costumes",
93+
* "reqlEvaluations": {
94+
* "countItems": 19
95+
* }
96+
* }
97+
* ],
98+
* "numberNextRecommsCalls": 0
99+
* }
100+
* ```
66101
*/
67102
constructor(itemId, targetUserId, count, optional) {
68103
super('POST', `/recomms/items/${itemId}/item-segments/`, 3000, false);
@@ -77,6 +112,7 @@ class RecommendItemSegmentsToItem extends rqs.Request {
77112
this.logic = optional.logic;
78113
this.expertSettings = optional.expertSettings;
79114
this.returnAbGroup = optional.returnAbGroup;
115+
this.reqlExpressions = optional.reqlExpressions;
80116
}
81117

82118
/**
@@ -109,6 +145,9 @@ class RecommendItemSegmentsToItem extends rqs.Request {
109145
if(this.returnAbGroup !== undefined)
110146
params.returnAbGroup = this.returnAbGroup;
111147

148+
if(this.reqlExpressions !== undefined)
149+
params.reqlExpressions = this.reqlExpressions;
150+
112151
return params;
113152
}
114153

lib/requests/recommend-item-segments-to-user.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,41 @@ class RecommendItemSegmentsToUser extends rqs.Request {
5050
* - *returnAbGroup*
5151
* - Type: boolean
5252
* - Description: If there is a custom AB-testing running, return the name of the group to which the request belongs.
53+
* - *reqlExpressions*
54+
* - Type: object
55+
* - Description: A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
56+
* This can be used to compute additional properties of the recommended Item Segments.
57+
* The keys are the names of the expressions, and the values are the actual ReQL expressions.
58+
* Example request:
59+
* ```json
60+
* {
61+
* "reqlExpressions": {
62+
* "countItems": "size(segment_items(\"categories\", 'segmentId'))"
63+
* }
64+
* }
65+
* ```
66+
* Example response:
67+
* ```json
68+
* {
69+
* "recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
70+
* "recomms":
71+
* [
72+
* {
73+
* "id": "category-fantasy-books",
74+
* "reqlEvaluations": {
75+
* "countItems": 486
76+
* }
77+
* },
78+
* {
79+
* "id": "category-sci-fi-costumes",
80+
* "reqlEvaluations": {
81+
* "countItems": 19
82+
* }
83+
* }
84+
* ],
85+
* "numberNextRecommsCalls": 0
86+
* }
87+
* ```
5388
*/
5489
constructor(userId, count, optional) {
5590
super('POST', `/recomms/users/${userId}/item-segments/`, 3000, false);
@@ -63,6 +98,7 @@ class RecommendItemSegmentsToUser extends rqs.Request {
6398
this.logic = optional.logic;
6499
this.expertSettings = optional.expertSettings;
65100
this.returnAbGroup = optional.returnAbGroup;
101+
this.reqlExpressions = optional.reqlExpressions;
66102
}
67103

68104
/**
@@ -94,6 +130,9 @@ class RecommendItemSegmentsToUser extends rqs.Request {
94130
if(this.returnAbGroup !== undefined)
95131
params.returnAbGroup = this.returnAbGroup;
96132

133+
if(this.reqlExpressions !== undefined)
134+
params.reqlExpressions = this.reqlExpressions;
135+
97136
return params;
98137
}
99138

lib/requests/search-item-segments.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,41 @@ class SearchItemSegments extends rqs.Request {
5050
* - *returnAbGroup*
5151
* - Type: boolean
5252
* - Description: If there is a custom AB-testing running, return the name of the group to which the request belongs.
53+
* - *reqlExpressions*
54+
* - Type: object
55+
* - Description: A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
56+
* This can be used to compute additional properties of the recommended Item Segments.
57+
* The keys are the names of the expressions, and the values are the actual ReQL expressions.
58+
* Example request:
59+
* ```json
60+
* {
61+
* "reqlExpressions": {
62+
* "countItems": "size(segment_items(\"categories\", 'segmentId'))"
63+
* }
64+
* }
65+
* ```
66+
* Example response:
67+
* ```json
68+
* {
69+
* "recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
70+
* "recomms":
71+
* [
72+
* {
73+
* "id": "category-fantasy-books",
74+
* "reqlEvaluations": {
75+
* "countItems": 486
76+
* }
77+
* },
78+
* {
79+
* "id": "category-sci-fi-costumes",
80+
* "reqlEvaluations": {
81+
* "countItems": 19
82+
* }
83+
* }
84+
* ],
85+
* "numberNextRecommsCalls": 0
86+
* }
87+
* ```
5388
*/
5489
constructor(userId, searchQuery, count, optional) {
5590
super('POST', `/search/users/${userId}/item-segments/`, 3000, false);
@@ -64,6 +99,7 @@ class SearchItemSegments extends rqs.Request {
6499
this.logic = optional.logic;
65100
this.expertSettings = optional.expertSettings;
66101
this.returnAbGroup = optional.returnAbGroup;
102+
this.reqlExpressions = optional.reqlExpressions;
67103
}
68104

69105
/**
@@ -96,6 +132,9 @@ class SearchItemSegments extends rqs.Request {
96132
if(this.returnAbGroup !== undefined)
97133
params.returnAbGroup = this.returnAbGroup;
98134

135+
if(this.reqlExpressions !== undefined)
136+
params.reqlExpressions = this.reqlExpressions;
137+
99138
return params;
100139
}
101140

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "recombee-api-client",
3-
"version": "6.0.0",
3+
"version": "6.1.0",
44
"description": "Node.js client (SDK) for easy use of the Recombee recommendation API",
55
"main": "index.js",
66
"types": "lib/index.d.ts",

0 commit comments

Comments
 (0)