Skip to content

Commit ecbe1d7

Browse files
authored
Merge pull request #582 from kuzzleio/7.4.8-proposal
# [7.4.8](https://github.com/kuzzleio/sdk-javascript/releases/tag/7.4.8) (2021-01-04) #### Bug fixes - [ [#573](#573) ] Fix types for Document and CollectionMappings ([Aschen](https://github.com/Aschen)) #### Enhancements - [ [#575](#575) ] Support "lang" parameter for Koncorde filters ([Yoann-Abbes](https://github.com/Yoann-Abbes)) - [ [#579](#579) ] Add event type to document notification ([Aschen](https://github.com/Aschen)) - [ [#578](#578) ] Convert bulk controller to TS ([Aschen](https://github.com/Aschen)) - [ [#574](#574) ] Adds a specific error when the request is too big to use the GET verb ([Aschen](https://github.com/Aschen)) ---
2 parents 4e756a5 + c3464ac commit ecbe1d7

File tree

65 files changed

+831
-202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+831
-202
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ src/**/*.js.map
55
src/Kuzzle.js
66
src/KuzzleError.js
77
src/controllers/Auth.js
8+
src/controllers/Bulk.js
89
src/controllers/Document.js
910
src/controllers/Realtime.js
1011
src/controllers/Index.js

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ index.js
3333
src/Kuzzle.js
3434
src/KuzzleError.js
3535
src/controllers/Auth.js
36+
src/controllers/Bulk.js
3637
src/controllers/Document.js
3738
src/controllers/Index.js
3839
src/controllers/Collection.js

doc/7/controllers/auth/search-api-keys/index.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ searchApiKeys([query], [options]);
3030

3131
The search query to apply to API keys content, using [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/query-dsl.html) syntax.
3232

33+
<SinceBadge version="7.4.8"/>
34+
35+
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`.
36+
Koncorde filters will be translated into an Elasticsearch query.
37+
38+
::: warning
39+
Koncorde `bool` operator and `regexp` clause are not supported for search queries.
40+
:::
41+
3342
If left empty, the result will return all available API keys of the currently loggued user.
3443

3544
### options
@@ -40,6 +49,7 @@ Additional query options
4049
| ---------- | ------------------ | ------------ |
4150
| `from` | <pre>number</pre><br/>(`0`) | Offset of the first document to fetch |
4251
| `size` | <pre>number</pre><br/>(`10`) | Maximum number of documents to retrieve per page |
52+
| `lang` | <pre>string</pre> | Specify the query language to use. By default, it's `elasticsearch` but `koncorde` can also be used. <SinceBadge version="7.4.8"/> |
4353

4454
## Resolves
4555

@@ -60,4 +70,10 @@ Each object of the `hits` array has the following properties:
6070

6171
## Usage
6272

63-
<<< ./snippets/search-api-keys.js
73+
With the [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/query-dsl.html) syntax.
74+
75+
<<< ./snippets/search-api-keys-es.js
76+
77+
With the [Koncorde Filters DSL](/core/2/api/koncorde-filters-syntax) syntax.
78+
79+
<<< ./snippets/search-api-keys-koncorde.js
File renamed without changes.

doc/7/controllers/auth/search-api-keys/snippets/search-api-keys.test.yml renamed to doc/7/controllers/auth/search-api-keys/snippets/search-api-keys-es.test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: auth#searchApiKeys
1+
name: auth#searchApiKeys-es
22
description: Searches API keys for the currently loggued user.
33
hooks:
44
before: >
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
try {
2+
const promises = [];
3+
4+
// Create some API keys for user "jared.doe"
5+
promises.push(
6+
kuzzle.security.createApiKey('jared.doe', 'Sigfox API key'));
7+
promises.push(
8+
kuzzle.security.createApiKey('jared.doe', 'LoRa 6 month API key', {
9+
expiresIn: 36000
10+
}));
11+
promises.push(
12+
kuzzle.security.createApiKey('jared.doe', 'LoRa permanent API key', {
13+
expiresIn: 42000, refresh: 'wait_for'
14+
}));
15+
16+
await Promise.all(promises);
17+
18+
// Log as "jared.doe"
19+
await kuzzle.auth.login('local', { username: 'jared.doe', password: 'password' });
20+
21+
const results = await kuzzle.auth.searchApiKeys({
22+
or: [
23+
{
24+
equals: {
25+
ttl: 42000
26+
}
27+
},
28+
{
29+
equals: {
30+
ttl: 36000
31+
},
32+
}
33+
]
34+
}, { lang: 'koncorde' });
35+
36+
console.log(results);
37+
/*
38+
{
39+
"total": 2,
40+
"hits": [
41+
{
42+
"_id": "znEwbG8BJASM_0-bWU-q",
43+
"_source": {
44+
"description": "LoRa permanent API key",
45+
"userId": "jared.doe",
46+
"expiresAt": 31557600000,
47+
"fingerprint": "4ee98cb8c614e99213e7695f822e42325d86c93cfaf39cb40e860939e784c8e6",
48+
"ttl": 420000
49+
}
50+
},
51+
{
52+
"_id": "zXEwbG8BJASM_0-bWU-q",
53+
"_source": {
54+
"description": "LoRa 1 year API key",
55+
"userId": "jared.doe",
56+
"expiresAt": 31557600000,
57+
"fingerprint": "f822e42325d86c93cfaf39cb40e860939e784c8e64ee98cb8c614e99213e7695",
58+
"ttl": 420000
59+
}
60+
}
61+
]
62+
}
63+
*/
64+
65+
console.log(`Found ${results.total} API keys.`);
66+
} catch (e) {
67+
console.error(e);
68+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: auth#searchApiKeys-koncorde
2+
description: Searches API keys for the currently loggued user.
3+
hooks:
4+
before: >
5+
curl --fail -H "Content-type: application/json" -d '{
6+
"content": {
7+
"profileIds": ["default"]
8+
},
9+
"credentials": {
10+
"local": {
11+
"username": "jared.doe",
12+
"password": "password"
13+
}
14+
}
15+
}' "kuzzle:7512/users/jared.doe/_create?refresh=wait_for"
16+
after:
17+
curl -XDELETE kuzzle:7512/users/jared.doe
18+
template: default
19+
expected:
20+
- Found 2 API keys.

doc/7/controllers/bulk/delete-by-query/snippets/delete-by-query.test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ hooks:
1515
done
1616
1717
curl -XPOST kuzzle:7512/nyc-open-data/yellow-taxi/_refresh
18-
after:
18+
1919
template: default
2020
expected: Successfully deleted 5 documents

doc/7/controllers/document/delete-by-query/index.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ Deletes documents matching the provided search query.
1111

1212
Kuzzle uses the [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/query-dsl.html) syntax.
1313

14+
<SinceBadge version="7.4.8"/>
15+
16+
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`.
17+
Koncorde filters will be translated into an Elasticsearch query.
18+
19+
::: warning
20+
Koncorde `bool` operator and `regexp` clause are not supported for search queries.
21+
:::
22+
1423
An empty or null query will match all documents in the collection.
1524

1625
<br/>
@@ -34,11 +43,19 @@ Additional query options
3443
| ---------- | ------------------------------- | ---------------------------------------------------------------------------------- |
3544
| `queuable` | <pre>boolean</pre><br/>(`true`) | If true, queues the request during downtime, until connected to Kuzzle again |
3645
| `refresh` | <pre>string</pre><br/>(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) |
46+
| `source` | <pre>boolean</pre> | if set to `true` Kuzzle will return each deleted document body in the response |
47+
| `lang` | <pre>string</pre> | Specify the query language to use. By default, it's `elasticsearch` but `koncorde` can also be used. <SinceBadge version="7.4.8"/> |
3748

3849
## Resolves
3950

4051
Resolves to an array of strings containing the deleted document ids.
4152

4253
## Usage
4354

44-
<<< ./snippets/delete-by-query.js
55+
With the [ElasticSearch Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/query-dsl.html) syntax.
56+
57+
<<< ./snippets/delete-by-query-es.js
58+
59+
With the [Koncorde Filters DSL](/core/2/api/koncorde-filters-syntax) syntax.
60+
61+
<<< ./snippets/delete-by-query-koncorde.js

doc/7/controllers/document/delete-by-query/snippets/delete-by-query.js renamed to doc/7/controllers/document/delete-by-query/snippets/delete-by-query-es.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ try {
33
'nyc-open-data',
44
'yellow-taxi',
55
{
6-
query: {
7-
term: { capacity: 7 }
8-
}
6+
query: { term: { capacity: 7 } }
97
}
108
);
119

0 commit comments

Comments
 (0)