Skip to content

Commit

Permalink
Merge pull request #73 from kuzzleio/2.4.0-proposal
Browse files Browse the repository at this point in the history
Release 2.4.0
  • Loading branch information
jenow authored Mar 1, 2021
2 parents d0a657e + 1e8e2ee commit db156dd
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [2.4.0]

- Add custom properties to a KuzzleRequest

## [2.3.0]

- Add an option to accept bad SSL certificate
Expand Down
2 changes: 1 addition & 1 deletion doc/2/core-classes/kuzzle/query/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This is a low-level method, exposed to allow advanced SDK users to bypass high-l

| Argument | Type | Description |
| --------- | ----------------- | ---------------------- |
| `request` | <pre>KuzzleRequest</pre> | API request |
| `request` | <pre>[KuzzleRequest](/sdk/dart/2/core-classes/request)</pre> | API request |
| `volatile` | <pre>Map<String, dynamic></pre> | Additional information to send to Kuzzle |
| `queueable` | <pre>bool</pre> | If true, queues the request during downtime, until connected to Kuzzle again |

Expand Down
7 changes: 7 additions & 0 deletions doc/2/core-classes/request/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
code: true
type: branch
title: KuzzleRequest
description: KuzzleRequest object documentation
order: 0
---
36 changes: 36 additions & 0 deletions doc/2/core-classes/request/introduction/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
code: false
type: page
title: Introduction
description: KuzzleRequest object description
order: 0
---

## KuzzleRequest

`KuzzleRequest` is a **serializable** class representing a raw Kuzzle request.


## Properties

| Property | Type | Description |
|--- |--- |--- |
| `action` | <pre>String</pre> | Executed Kuzzle API controller's action `
| `body` | <pre>Map<String, dynamic> body</pre> |
| `collection` | <pre>String</pre> | Impacted collection |
| `controller` | <pre>String</pre> | Executed Kuzzle API controller |
| `index` | <pre>String</pre> | Impacted index |
| `jwt` | <pre>String</pre> | Authentication token |
| `lang` | <pre>String</pre> | ES lang |
| `requestId` | <pre>String</pre> | Request unique identifier |
| `waitForRefresh` | <pre>bool</pre> | If set to `true`, Kuzzle will wait for the persistence layer to finish indexing |
| `volatile` | <pre>Map<String, dynamic></pre> | Volatile data |
| `from` | <pre>int</pre><br/>(`0`) | Offset of the first document to fetch |
| `size` | <pre>int</pre><br/>(`10`) | Maximum number of documents to retrieve per page |
| `scroll` | <pre>String</pre><br/>(`""`) | When set, gets a forward-only cursor having its ttl set to the given value (ie `1s`; cf [elasticsearch time limits](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/common-options.html#time-units)) |
| `scrollId` | <pre>String</pre> | The scrollId if using scroll option |
| `sort` | <pre>List<dynamic></pre> | Contains a list of fields, used to [sort search results](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/search-request-sort.html), in order of importance. |

## Overrided operators

The `[]` and `[]=` are overrided so you can dynamically add any args you want to this class and it will be taken in consideration in the request sent to Kuzzle.
7 changes: 6 additions & 1 deletion lib/src/kuzzle/request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,13 @@ class KuzzleRequest {
includeKuzzleMeta = data['includeKuzzleMeta'] as bool;
}

final Map<String, dynamic> _args = {};

dynamic operator [](String key) => _args[key];
void operator []=(String key, dynamic value) => _args[key] = value;

Map toJson() {
final map = <String, dynamic>{};
final map = _args;

if (action != null) {
map['action'] = action;
Expand Down
9 changes: 9 additions & 0 deletions lib/src/protocols/abstract.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ abstract class KuzzleProtocol extends KuzzleEventEmitter {
final syncRes = send(request);
// If we use a synchronous protocol the result is returned directly
if (syncRes != null) {
syncRes.then((response) {
if (response.error != null) {
emit(ProtocolEvents.QUERY_ERROR, [response, request]);
}
}).catchError((err) {
emit(ProtocolEvents.QUERY_ERROR, [{
'error': err,
}, request]);
});
return syncRes;
}
} on Exception catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: kuzzle
version: 2.3.0
version: 2.4.0
description: A library to interact with kuzzle API. A backend software,
self-hostable and ready to use to power modern cross-platform apps.
homepage: https://github.com/kuzzleio/sdk-dart
Expand Down

0 comments on commit db156dd

Please sign in to comment.