Skip to content

Commit e85c946

Browse files
authored
Merge pull request #684 from kuzzleio/7.8.3-proposal
# [7.8.3](https://github.com/kuzzleio/sdk-javascript/releases/tag/7.8.3) (2022-01-27) #### Bug fixes - [ [#683](#683) ] Fix authenticator token verification ([Shiranuit](https://github.com/Shiranuit)) #### Enhancements - [ [#680](#680) ] Add debug mode ([Aschen](https://github.com/Aschen)) - [ [#676](#676) ] Add HTTP protocol support for Observer ([Aschen](https://github.com/Aschen)) - [ [#667](#667) ] Support entire query for security:searchProfiles ([Aschen](https://github.com/Aschen)) - [ [#669](#669) ] Add more context to errors ([clementbolin](https://github.com/clementbolin)) #### Others - [ [#674](#674) ] Add types for mRequests and mResponses ([Aschen](https://github.com/Aschen)) ---
2 parents ee8ab63 + 26f22f9 commit e85c946

File tree

37 files changed

+2353
-2360
lines changed

37 files changed

+2353
-2360
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ src/core/searchResult/Specifications.js
3232
src/core/searchResult/User.js
3333
src/utils/Deprecation.js
3434
src/utils/interfaces.js
35+
src/controllers/Server.js
36+
src/core/Observer.js
37+
src/core/RealtimeDocument.js
38+
src/core/searchResult/RealtimeDocument.js

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,7 @@ src/core/searchResult/Specifications.js
6161
src/core/searchResult/User.js
6262
src/utils/Deprecation.js
6363
src/utils/interfaces.js
64+
src/controllers/Server.js
65+
src/core/Observer.js
66+
src/core/RealtimeDocument.js
67+
src/core/searchResult/RealtimeDocument.js

doc/7/controllers/security/m-get-profiles/snippets/m-get-profiles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ try {
55
'profile3'
66
]);
77

8-
console.log(response);
8+
console.log(`Successfully retrieved ${response.length} profiles`);
99
/*
1010
[ Profile {
1111
_id: 'profile1',

doc/7/controllers/security/m-get-profiles/snippets/m-get-profiles.test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ hooks:
1212
curl -XDELETE kuzzle:7512/profiles/profile${i}
1313
done
1414
template: default
15-
expected: '.*Profile.*_id.*rateLimit.*policies.*'
15+
expected: Successfully retrieved 3 profiles

doc/7/controllers/security/search-profiles/index.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ description: Searches security profiles, optionally returning only those linked
77

88
# searchProfiles
99

10-
Searches security profiles, optionally returning only those linked to the provided list of security roles.
10+
Searches security profiles.
11+
12+
<SinceBadge version="7.8.3" />
13+
<SinceBadge version="Kuzzle 2.14.1" />
14+
15+
Support for search using a search query with the `query` property.
16+
17+
This method also supports the [Koncorde Filters DSL](/core/2/api/koncorde-filters-syntax) to match documents by passing the `lang` argument with the value `koncorde`.
18+
Koncorde filters will be translated into an Elasticsearch query.
1119

1220
<br />
1321

@@ -19,21 +27,24 @@ searchProfiles([body], [options]);
1927

2028
| Property | Type | Description |
2129
|--- |--- |--- |
22-
| `body` | <pre>object</pre> | Query including role identifiers to search for |
30+
| `body` | <pre>object</pre> | Search query |
2331
| `options` | <pre>object</pre> | Query options |
2432

2533
### body
26-
2734
| Property | Type | Description |
2835
| --- | --- | --- |
29-
| `roles` | <pre>array&lt;string&gt;</pre> | Role identifiers |
36+
| `roles` | <pre>array&lt;string&gt;</pre> | Role identifiers <DeprecatedBadge version="7.8.3"/>|
37+
| `query` | <pre>object</pre> | Search query using the [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/query-dsl.html) or the [Koncorde Filters DSL](/core/2/api/koncorde-filters-syntax) syntax. <SinceBadge version="7.8.3"/>|
38+
39+
If the body is left empty, the result will return all available profiles.
3040

3141
### options
3242

3343
| Property | Type<br/>(default) | Description |
3444
| ---------- | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
3545
| `queuable` | <pre>boolean</pre><br/>(`true`) | If true, queues the request during downtime, until connected to Kuzzle again |
3646
| `from` | <pre>number</pre><br/>(`0`) | Offset of the first document to fetch |
47+
| `lang` | <pre>string</pre> | Specify the query language to use. By default, it's `elasticsearch` but `koncorde` can also be used. |
3748
| `size` | <pre>number</pre><br/>(`10`) | Maximum number of documents to retrieve per page |
3849
| `scroll` | <pre>string</pre><br/>(`""`) | When set, gets a forward-only cursor having its ttl set to the given value (ie `30s`; cf [elasticsearch time limits](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/common-options.html#time-units)) |
3950

doc/7/controllers/security/search-profiles/snippets/search-profiles.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
try {
22
const results = await kuzzle.security.searchProfiles({
3-
roles: [ 'default' ]
3+
query: {
4+
term: { 'policies.roleId': 'default' }
5+
}
46
});
57

68
console.log(results);

doc/7/controllers/security/search-profiles/snippets/search-profiles.test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ hooks:
1212
curl -XDELETE kuzzle:7512/profiles/profile${i}
1313
done
1414
template: default
15-
expected: ^Successfully retrieved 4 profiles$
15+
expected: ^Successfully retrieved \d+ profiles$

doc/7/core-classes/kuzzle-error/properties/index.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,19 @@ order: 10
99

1010
# Properties
1111

12-
| Property name | Type | Description |
13-
|---------------|-------------------|---------------------------------------------------------------------|
14-
| `kuzzleStack` | <pre>string</pre> | Kuzzle stacktrace (only in development mode) |
15-
| `message` | <pre>string</pre> | Error message |
16-
| `status` | <pre>number</pre> | Error status code |
17-
| `stack` | <pre>string</pre> | Complete error stacktrace (Kuzzle + SDK) (only in development mode) |
18-
| `id` | <pre>string</pre> | Error unique identifier |
19-
| `code` | <pre>string</pre> | Error unique code |
20-
12+
| Property name | Type | Description |
13+
|---------------|-------------------|------------------------------------------------------------------------------------------------------|
14+
| `kuzzleStack` | <pre>string</pre> | Kuzzle stacktrace (only in development mode) |
15+
| `message` | <pre>string</pre> | Error message |
16+
| `status` | <pre>number</pre> | Error status code |
17+
| `stack` | <pre>string</pre> | Complete error stacktrace (Kuzzle + SDK) (only in development mode) |
18+
| `id` | <pre>string</pre> | Error unique identifier |
19+
| `code` | <pre>string</pre> | Error unique code |
20+
| `controller` | <pre>string</pre> | API controller name |
21+
| `action` | <pre>string</pre> | API action name |
22+
| `volatile` | <pre>object</pre> | KuzzleRequest [volatile data](https://docs.kuzzle.io/core/2/guides/main-concepts/api/#volatile-data) |
23+
| `index` | <pre>string</pre> | Index name |
24+
| `collection` | <pre>string</pre> | Collection name name |
25+
| `requestId` | <pre>string</pre> | request id name |
26+
| `_id` | <pre>string</pre> | Document unique identifier |
27+
| `count` | <pre>number</pre> | Number of associated errors (PartialError only) |

doc/7/core-classes/kuzzle/properties/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ order: 10
1414
| `connected` | <pre>boolean</pre> | Returns `true` if the SDK is currently connected to a Kuzzle server. |
1515
| `offlineQueue` | <pre>object[]</pre> | Contains the queued requests during offline mode |
1616
| `protocol` | <pre>Protocol</pre> | Protocol used by the SDK |
17+
| `events` | <pre>string[]</pre> | List of every events emitted by the SDK |
18+
1719

1820
### connected
1921

@@ -42,7 +44,7 @@ See the associated documentation:
4244

4345
The `authenticator` property can be set to a function returning a promise.
4446

45-
This function will be called after a successful reconnection if the current authentication token is not valid anymore.
47+
This function will be called after a successful reconnection if the current authentication token is not valid anymore.
4648

4749
This function has to authenticate the SDK. It can be a call to [auth.login](/sdk/js/7/controllers/auth/login) for example.
4850

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
code: true
3+
type: page
4+
title: constructor
5+
description: Creates a new Observer object
6+
order: 50
7+
---
8+
9+
# Constructor
10+
11+
Use this constructor to create a new Observer instance.
12+
13+
## Arguments
14+
15+
```js
16+
Observer(sdk, [options]);
17+
```
18+
19+
<br/>
20+
21+
| Argument | Type | Description |
22+
|-----------|-------------------|--------------------------------|
23+
| `sdk` | <pre>Kuzzle</pre> | SDK instanciated and connected |
24+
| `options` | <pre>object</pre> | Additional options |
25+
26+
### options
27+
28+
Observer options.
29+
30+
| Property | Type<br/>(default) | Description |
31+
|----------------|--------------------------------|--------------------------------------------------------------|
32+
| `pullingDelay` | <pre>number</pre><br/>(`5000`) | Refresh delay in ms when the SDK is using the HTTP protocol. |
33+
34+
## Usage
35+
36+
```js
37+
const observer = new Observer(sdk);
38+
```

0 commit comments

Comments
 (0)