Skip to content

Commit 3eddc28

Browse files
committed
Release: v6.0.0
- Added support for the new Composite Recommendation endpoint - Added new parameter `autoPresented` for Detail View and View Portion interactions - Added new parameter `timeSpent` for View Portion interactions - Added support for `reqlExpressions` on recommended items
1 parent 6c4ac85 commit 3eddc28

24 files changed

+1677
-1004
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ There are two ways to include the library in your project:
3434
You can add the following `<script>` tag into your HTML file:
3535

3636
```html
37-
<script src="https://cdn.jsdelivr.net/npm/recombee-js-api-client@5.0.2/dist/recombee-api-client.min.js"></script>
37+
<script src="https://cdn.jsdelivr.net/npm/recombee-js-api-client@6.0.0/dist/recombee-api-client.min.js"></script>
3838
```
3939

4040
After this script is included, you can access the client using the global `recombee` object (also available as `window.recombee`).

dist/recombee-api-client.js

Lines changed: 434 additions & 162 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/recombee-api-client.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/recombee-api-client.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/recombee-api-client.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "recombee-js-api-client",
3-
"version": "5.0.2",
3+
"version": "6.0.0",
44
"description": "Client-side js library for easy use of the Recombee recommendation API",
55
"main": "./src/index.js",
66
"browser": "./src/index.js",
@@ -22,6 +22,9 @@
2222
"API",
2323
"SDK"
2424
],
25+
"engines": {
26+
"node": ">=18"
27+
},
2528
"author": "Ondrej Fiedler <[email protected]> (https://www.recombee.com/)",
2629
"license": "MIT",
2730
"bugs": {

pnpm-lock.yaml

Lines changed: 588 additions & 604 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api-client.js

Lines changed: 11 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ class ApiClient {
1717
this.databaseId = databaseId;
1818
this.publicToken = publicToken;
1919
this.options = options || {};
20-
this.baseUri = this._getBaseUri();
20+
this.baseUri = this.getBaseUri();
2121
this.useHttps = 'useHttps' in this.options ? this.options.useHttps : true;
22-
this.async = 'async' in this.options ? this.options.async : true;
23-
this.future_v6_fetch = 'future_v6_fetch' in this.options ? this.options.future_v6_fetch : false;
2422
}
2523

2624
_getRegionalBaseUri(region) {
@@ -40,7 +38,7 @@ class ApiClient {
4038
return uri;
4139
}
4240

43-
_getBaseUri() {
41+
getBaseUri() {
4442
let baseUri = this.options.baseUri;
4543
if (this.options.region) {
4644
if (baseUri) {
@@ -57,22 +55,16 @@ class ApiClient {
5755
* @param {Object} callback - Optional callback (send returns Promise if omitted)
5856
*/
5957
send(request, callback) {
60-
if (this.future_v6_fetch) {
61-
if (!(typeof globalThis === 'undefined' ? window.Promise : globalThis.Promise)) {
62-
throw new Error('future_v6_fetch requires Promises to be available.');
63-
}
64-
if (!this.async) {
65-
throw new Error('future_v6_fetch cannot be used with synchronous requests.');
66-
}
67-
if (callback === undefined) {
68-
return this._sendFetch(request);
69-
} else {
70-
return this._sendFetch(request)
71-
.then((result) => callback(null, result))
72-
.catch(callback);
73-
}
58+
if (!(typeof globalThis === 'undefined' ? window.Promise : globalThis.Promise)) {
59+
throw new Error('Recombee API Client requires Promises to be available.');
60+
}
61+
if (callback === undefined) {
62+
return this._sendFetch(request);
63+
} else {
64+
return this._sendFetch(request)
65+
.then((result) => callback(null, result))
66+
.catch(callback);
7467
}
75-
return this._sendXhr(request, callback);
7668
}
7769

7870
async _sendFetch(request) {
@@ -102,42 +94,6 @@ class ApiClient {
10294
}
10395
}
10496

105-
_sendXhr(request, callback) {
106-
const Promise = typeof globalThis === 'undefined' ? window.Promise : globalThis.Promise;
107-
if (callback === undefined && Promise) {
108-
const sendXhr = this._sendXhr.bind(this);
109-
return new Promise(function (resolve, reject) {
110-
sendXhr(request, function (err, result) {
111-
return err ? reject(err) : resolve(result);
112-
});
113-
});
114-
}
115-
116-
const url = this._getUrl(request);
117-
const xmlhttp = new XMLHttpRequest();
118-
xmlhttp.open('POST', url, this.async);
119-
xmlhttp.setRequestHeader('Accept', 'application/json');
120-
xmlhttp.setRequestHeader('Content-Type', 'application/json');
121-
122-
if (this.async) xmlhttp.timeout = request.timeout;
123-
124-
xmlhttp.onreadystatechange = function () {
125-
if (this.readyState == 4 && this.responseText) {
126-
if (this.status == 200) {
127-
if (callback) return callback(null, JSON.parse(this.responseText));
128-
} else {
129-
if (callback)
130-
return callback(new api_errors.ResponseError(request, this.status, this.responseText));
131-
}
132-
}
133-
};
134-
xmlhttp.ontimeout = function () {
135-
if (callback) return callback(new api_errors.TimeoutError(request));
136-
};
137-
138-
xmlhttp.send(JSON.stringify(request.bodyParameters()));
139-
}
140-
14197
_getUrl(request) {
14298
const signedUrl = this._signUrl(request.path);
14399
const url =

0 commit comments

Comments
 (0)