Skip to content

Commit 25e1cd5

Browse files
author
Shiranuit
authored
Merge pull request #719 from kuzzleio/7.10.4-proposal
Release 7.10.4
2 parents 51df0af + e09150d commit 25e1cd5

File tree

13 files changed

+109
-77
lines changed

13 files changed

+109
-77
lines changed

package-lock.json

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kuzzle-sdk",
3-
"version": "7.10.3",
3+
"version": "7.10.4",
44
"description": "Official Javascript SDK for Kuzzle",
55
"author": "The Kuzzle Team <[email protected]>",
66
"repository": {

src/controllers/Document.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ export interface ArgsDocumentControllerDelete extends ArgsDefault {
840840
}
841841

842842
export interface ArgsDocumentControllerDeleteByQuery extends ArgsDefault {
843-
refresh?: string;
843+
refresh?: "wait_for" | "false";
844844
silent?: boolean;
845845
lang?: string;
846846
}
@@ -933,7 +933,7 @@ export interface ArgsDocumentControllerUpdateByQuery extends ArgsDefault {
933933
export interface ArgsDocumentControllerUpsert<TKDocumentContent>
934934
extends ArgsDefault {
935935
default?: Partial<TKDocumentContent>;
936-
refresh?: string;
936+
refresh?: "wait_for" | "false";
937937
silent?: boolean;
938938
retryOnConflict?: boolean;
939939
source?: boolean;

src/core/searchResult/SearchResultBase.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,11 @@ export class SearchResultBase<T> implements SearchResult<T> {
164164
}
165165

166166
return this._kuzzle
167-
.query(
168-
{
169-
...this._request,
170-
action: this._searchAction,
171-
from: this.fetched,
172-
},
173-
this._options
174-
)
167+
.query({
168+
...this._request,
169+
action: this._searchAction,
170+
from: this.fetched,
171+
})
175172
.then(({ result }) => this._buildNextSearchResult(result));
176173
}
177174

src/protocols/Http.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,14 @@ export default class HttpProtocol extends KuzzleAbstractProtocol {
274274
payload.headers.authorization = "Bearer " + value;
275275
} else if (key === "volatile") {
276276
payload.headers["x-kuzzle-volatile"] = JSON.stringify(value);
277+
} else if (key === "index" || key === "collection") {
278+
// If we're calling a non-native route that answer to a GET request
279+
// we need to add the index and collection (if provided) to the query string
280+
if (!staticHttpRoutes[request.controller] && method === "GET") {
281+
queryArgs[key] = value;
282+
} else {
283+
payload[key] = value;
284+
}
277285
} else if (Object.prototype.hasOwnProperty.call(payload, key)) {
278286
payload[key] = value;
279287
} else if (value !== undefined && value !== null) {

src/protocols/abstract/Realtime.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,12 @@ export abstract class BaseProtocolRealtime extends KuzzleAbstractProtocol {
8383
this.retrying = true;
8484

8585
if (
86+
window !== null &&
8687
typeof window === "object" &&
87-
typeof window.navigator === "object" &&
88-
window.navigator.onLine === false
88+
typeof window!.navigator === "object" &&
89+
window!.navigator.onLine === false
8990
) {
90-
window.addEventListener(
91+
window!.addEventListener(
9192
"online",
9293
() => {
9394
this.retrying = false;

src/utils/debug.js

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,33 @@ let NODE_DEBUG;
33
/* eslint no-undef: 0 */
44

55
function shouldDebug() {
6-
if (typeof window === "undefined") {
7-
// Avoid multiple calls to process.env
8-
if (!NODE_DEBUG) {
9-
NODE_DEBUG = (process.env.DEBUG || "").includes("kuzzle-sdk");
6+
/**
7+
* Some framework like react-native or other might emulate the window object
8+
* but when on plateforms like iOS / Android, the window.location is undefined.
9+
*
10+
* So we need to check if window.location is defined before using it otherwise
11+
* we will get an error.
12+
*
13+
* If something went wrong, be sure to return false to avoid any error.
14+
*/
15+
try {
16+
if (typeof window === "undefined") {
17+
// Avoid multiple calls to process.env
18+
if (!NODE_DEBUG) {
19+
NODE_DEBUG = (process.env.DEBUG || "").includes("kuzzle-sdk");
20+
}
21+
22+
return NODE_DEBUG;
1023
}
1124

12-
return NODE_DEBUG;
25+
return (
26+
window.debugKuzzleSdk ||
27+
(window.location &&
28+
new URL(window.location).searchParams.get("debugKuzzleSdk") !== null)
29+
);
30+
} catch (e) {
31+
return false;
1332
}
14-
15-
return (
16-
window.debugKuzzleSdk ||
17-
new URL(window.location).searchParams.get("debugKuzzleSdk") !== null
18-
);
1933
}
2034

2135
/**

test/core/searchResult/document.test.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -332,18 +332,15 @@ describe("DocumentSearchResult", () => {
332332
return searchResult.next().then((nextSearchResult) => {
333333
should(kuzzle.query)
334334
.be.calledOnce()
335-
.be.calledWith(
336-
{
337-
index: "index",
338-
collection: "collection",
339-
body: { query: { foo: "bar" } },
340-
controller: "document",
341-
action: "search",
342-
size: 2,
343-
from: 2,
344-
},
345-
options
346-
);
335+
.be.calledWith({
336+
index: "index",
337+
collection: "collection",
338+
body: { query: { foo: "bar" } },
339+
controller: "document",
340+
action: "search",
341+
size: 2,
342+
from: 2,
343+
});
347344
should(nextSearchResult).not.be.equal(searchResult);
348345
should(nextSearchResult).be.instanceOf(DocumentSearchResult);
349346
});

test/core/searchResult/profile.test.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -352,16 +352,13 @@ describe("ProfileSearchResult", () => {
352352
return searchResult.next().then((nextSearchResult) => {
353353
should(kuzzle.query)
354354
.be.calledOnce()
355-
.be.calledWith(
356-
{
357-
body: { query: { foo: "bar" } },
358-
controller: "security",
359-
action: "searchProfiles",
360-
size: 2,
361-
from: 2,
362-
},
363-
options
364-
);
355+
.be.calledWith({
356+
body: { query: { foo: "bar" } },
357+
controller: "security",
358+
action: "searchProfiles",
359+
size: 2,
360+
from: 2,
361+
});
365362
should(nextSearchResult).not.be.equal(searchResult);
366363
should(nextSearchResult).be.instanceOf(ProfileSearchResult);
367364
});

test/core/searchResult/role.test.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,13 @@ describe("RoleSearchResult", () => {
160160
return searchResult.next().then((nextSearchResult) => {
161161
should(kuzzle.query)
162162
.be.calledOnce()
163-
.be.calledWith(
164-
{
165-
body: { foo: "bar" },
166-
controller: "security",
167-
action: "searchRoles",
168-
size: 2,
169-
from: 2,
170-
},
171-
options
172-
);
163+
.be.calledWith({
164+
body: { foo: "bar" },
165+
controller: "security",
166+
action: "searchRoles",
167+
size: 2,
168+
from: 2,
169+
});
173170
should(nextSearchResult).not.be.equal(searchResult);
174171
should(nextSearchResult).be.instanceOf(RoleSearchResult);
175172
});

0 commit comments

Comments
 (0)