Skip to content

Commit cf04f13

Browse files
scottinetGilles Ballini
authored andcommitted
JS SDK: document class properties independently to the "introduction" pages (#277)
* [JS SDK] separate class properties from the "introduction" page * [JS SDK] document what the auth actions do to the jwt class property * Apply @xbill82's suggestions Co-Authored-By: scottinet <[email protected]>
1 parent 33d6078 commit cf04f13

File tree

20 files changed

+221
-169
lines changed

20 files changed

+221
-169
lines changed

src/sdk-reference/js/6/auth/login/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ description: Authenticate a user
88

99
Authenticates a user.
1010

11-
If this action is successful, all further requests emitted by this SDK instance will be in the name of the authenticated user, until either the authenticated token expires, the [logout]({{ site_base_path }}sdk-reference/js/6/auth/logout) action is called, or the [jwt]({{ site_base_path }}sdk-reference/js/6/kuzzle/introduction/#properties) property is manually unset.
11+
If this action is successful, then the [jwt]({{ site_base_path }}sdk-reference/js/6/kuzzle/properties) property of this class instance is set to the new authentication token.
12+
13+
All further requests emitted by this SDK instance will be on behalf of the authenticated user, until either the authenticated token expires, the [logout]({{ site_base_path }}sdk-reference/js/6/auth/logout) action is called, or the `jwt` property is manually set to another value.
1214

1315
## Arguments
1416

src/sdk-reference/js/6/auth/logout/index.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ description: Revokes the user's token & unsubscribe them from registered rooms.
66

77
# logout
88

9-
Revokes the user's authentication token.
9+
Revokes the current authentication token.
1010

1111
If there were any, real-time subscriptions are cancelled.
1212

13-
<br/>
13+
If this action is successful, then the [jwt]({{ site_base_path }}sdk-reference/js/6/kuzzle/properties) property of this class instance is unset.
14+
15+
## Arguments
1416

1517
```javascript
1618
logout ()

src/sdk-reference/js/6/auth/refresh-token/index.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ description: Refresh an authentication token
1010

1111
Refreshes a valid, non-expired authentication token.
1212

13-
If this action is successful, all further requests emitted by this SDK instance will use the refreshed authentication token.
13+
If this action is successful, then the [jwt]({{ site_base_path }}sdk-reference/js/6/kuzzle/properties) property of this class instance is set to the new authentication token.
14+
15+
All further requests emitted by this SDK instance will be on behalf of the authenticated user, until either the authenticated token expires, the [logout]({{ site_base_path }}sdk-reference/js/6/auth/logout) action is called, or the `jwt` property is manually set to another value.
16+
1417

1518
## Arguments
1619

src/sdk-reference/js/6/kuzzle-error/introduction/index.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,3 @@ order: 0
1010
Inherits from the standard `Error` class.
1111

1212
The KuzzleError class represents an [error response from Kuzzle API]({{ site_base_path }}api/1/essentials/errors/).
13-
14-
## Properties
15-
16-
Available properties.
17-
18-
| Property name | Type | Description |
19-
| -------------------- | -------- | --------------------------------------- |
20-
| `message` | <pre>string</pre> | Error message |
21-
| `status` | <pre>number</pre> | Error status code |
22-
| `stack` | <pre>string</pre> | Error stacktrace (only in development mode) |
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
layout: sdk.html.hbs
3+
title: Properties
4+
description: KuzzleError Properties
5+
---
6+
7+
# Properties
8+
9+
| Property name | Type | Description |
10+
| -------------------- | -------- | --------------------------------------- |
11+
| `message` | <pre>string</pre> | Error message |
12+
| `status` | <pre>number</pre> | Error status code |
13+
| `stack` | <pre>string</pre> | Error stacktrace (only in development mode) |

src/sdk-reference/js/6/kuzzle/introduction/index.md

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -32,70 +32,3 @@ The following protocols are available in the SDK JS 6:
3232
You can tell the Kuzzle SDK to attach a set of "volatile" data to each request. You can set it as an object contained in the `volatile` field of the Kuzzle constructor. The response to a request containing volatile data will contain the same data in its `volatile` field. This can be useful, for example, in real-time notifications for [user join/leave notifications]({{site_base_path}}api/1/essentials/volatile-data/) to provide additional informations about the client who sent the request.
3333

3434
Note that you can also set volatile data on a per-request basis (on requests that accept a `volatile` field in their `options` argument). In this case, per-request volatile data will be merged with the global `volatile` object set in the constructor. Per-request fields will override global ones.
35-
36-
## Properties
37-
38-
Available properties.
39-
40-
| Property name | Type | Description | Writable? |
41-
| -------------------- | -------- | --------------------------------------- | :-------: |
42-
| `autoQueue` | <pre>boolean</pre> | Automatically queue all requests during offline mode | Yes |
43-
| `autoReplay` | <pre>boolean</pre> | Automatically replay queued requests on a `reconnected` event | Yes |
44-
| `autoResubscribe` | <pre>boolean</pre> | Automatically renew all subscriptions on a `reconnected` event | Yes |
45-
| `jwt` | <pre>string</pre> | Token used in requests for authentication | Yes |
46-
| `offlineQueue` | <pre>object[]</pre> | Contains the queued requests during offline mode | No |
47-
| `offlineQueueLoader` | <pre>function</pre> | Called before dequeuing requests after exiting offline mode,</br> to add items at the beginning of the offline queue | Yes |
48-
| `protocol` | <pre>Protocol</pre> | Protocol used by the SDK | No |
49-
| `queueFilter` | <pre>function</pre> | Called during offline mode. </br>Takes a request object as arguments and returns a boolean, indicating if a request can be queued | Yes |
50-
| `queueMaxSize` | <pre>number</pre> | Number of maximum requests kept during offline mode| Yes |
51-
| `queueTTL` | <pre>number</pre> | Time a queued request is kept during offline mode, in milliseconds | Yes |
52-
| `replayInterval` | <pre>number</pre> | Delay between each replayed requests | Yes |
53-
| `volatile` | <pre>object</pre> | Common volatile data, will be sent to all future requests | Yes |
54-
55-
### offlineQueueLoader
56-
57-
The `offlineQueueLoader` property must be set with a function of one of the following formats:
58-
59-
```js
60-
Object[] offlineQueueLoader()
61-
62-
Promise<Object[]> offlineQueueLoader()
63-
```
64-
65-
The returned (or resolved) array must contain objects, each with the following properties:
66-
67-
| Property | Type | Description |
68-
|---|---|---|
69-
| `query` | <pre>object</pre> | Object representing the request that is about to be sent to Kuzzle, following the [Kuzzle API]({{ site_base_path }}api/1/essentials/query-syntax) format |
70-
| `reject` | <pre>function</pre> | A [Promise.reject](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject) function |
71-
| `resolve` | <pre>function</pre> | A [Promise.resolve](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve) function |
72-
73-
### queueFilter
74-
75-
The `queueFilter` property must be set with a function of the following form:
76-
77-
```js
78-
boolean queueFilter(request)
79-
```
80-
81-
The `request` argument is an object representing the request that is about to be sent to Kuzzle, following the [Kuzzle API]({{ site_base_path }}api/1/essentials/query-syntax) format.
82-
83-
### queueMaxSize
84-
85-
This property defines the size of the offline buffer, which is a first-in first-out (FIFO) queue.
86-
87-
This means that if the `queueMaxSize` limit is reached, older requests are discarded to make room for newer requests.
88-
89-
If `queueMaxSize` is set to a number lower than, or equal to `0`, then an unlimited number of requests is kept in the offline buffer.
90-
Note that doing so may lead to a crash due to memory saturation, if there are too many requests held in memory.
91-
92-
### queueTTL
93-
94-
If the `queueTTL` property is set to a number lower than, or equal to `0`, then requests never expire and are kept indefinitely.
95-
96-
### volatile
97-
98-
Multiple methods allow passing specific `volatile` data.
99-
100-
These `volatile` data will be merged with the global Kuzzle `volatile` object when sending the request, with the request specific `volatile` taking priority over the global ones.
101-
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
layout: sdk.html.hbs
3+
title: Properties
4+
description: Kuzzle class properties
5+
order: 100
6+
---
7+
8+
# Read-only properties
9+
10+
| Property name | Type | Description |
11+
| -------------------- | -------- | ---------------------|
12+
| `offlineQueue` | <pre>object[]</pre> | Contains the queued requests during offline mode |
13+
| `protocol` | <pre>Protocol</pre> | Protocol used by the SDK |
14+
15+
# Writable properties
16+
17+
| Property name | Type | Description |
18+
| -------------------- | -------- | ---------------------|
19+
| `autoQueue` | <pre>boolean</pre> | If `true`, automatically queues all requests during offline mode |
20+
| `autoReplay` | <pre>boolean</pre> | If `true`, automatically replays queued requests on a `reconnected` event |
21+
| `autoResubscribe` | <pre>boolean</pre> | If `true`, automatically renews all subscriptions on a `reconnected` event |
22+
| `jwt` | <pre>string</pre> | Authentication token |
23+
| `offlineQueueLoader` | <pre>function</pre> | Called before dequeuing requests after exiting offline mode, to add items at the beginning of the offline queue |
24+
| `queueFilter` | <pre>function</pre> | Custom function called during offline mode to filter queued requests on-the-fly |
25+
| `queueMaxSize` | <pre>number</pre> | Number of maximum requests kept during offline mode|
26+
| `queueTTL` | <pre>number</pre> | Time a queued request is kept during offline mode, in milliseconds |
27+
| `replayInterval` | <pre>number</pre> | Delay between each replayed requests |
28+
| `volatile` | <pre>object</pre> | Common volatile data, will be sent to all future requests |
29+
30+
### offlineQueueLoader
31+
32+
The `offlineQueueLoader` property must be set with a function of one of the following formats:
33+
34+
```js
35+
Object[] offlineQueueLoader()
36+
37+
Promise<Object[]> offlineQueueLoader()
38+
```
39+
40+
The returned (or resolved) array must contain objects, each with the following properties:
41+
42+
| Property | Type | Description |
43+
|---|---|---|
44+
| `query` | <pre>object</pre> | Object representing the request that is about to be sent to Kuzzle, following the [Kuzzle API]({{ site_base_path }}api/1/essentials/query-syntax) format |
45+
| `reject` | <pre>function</pre> | A [Promise.reject](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject) function |
46+
| `resolve` | <pre>function</pre> | A [Promise.resolve](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve) function |
47+
48+
### queueFilter
49+
50+
The `queueFilter` property must be set with a function of the following form:
51+
52+
```js
53+
boolean queueFilter(request)
54+
```
55+
56+
The `request` argument is an object representing the request that is about to be sent to Kuzzle, following the [Kuzzle API]({{ site_base_path }}api/1/essentials/query-syntax) format.
57+
58+
### queueMaxSize
59+
60+
This property defines the size of the offline buffer, which is a first-in first-out (FIFO) queue.
61+
62+
This means that if the `queueMaxSize` limit is reached, older requests are discarded to make room for newer requests.
63+
64+
If `queueMaxSize` is set to a number lower than, or equal to `0`, then an unlimited number of requests is kept in the offline buffer.
65+
Note that doing so may lead to a crash due to memory saturation, if there are too many requests held in memory.
66+
67+
### queueTTL
68+
69+
If the `queueTTL` property is set to a number lower than, or equal to `0`, then requests never expire and are kept indefinitely.
70+
71+
### volatile
72+
73+
Multiple methods allow passing specific `volatile` data.
74+
75+
These `volatile` data will be merged with the global Kuzzle `volatile` object when sending the request, with the request specific `volatile` taking priority over the global ones.
76+

src/sdk-reference/js/6/offline-tools/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ during its lifespan.
1414

1515
These properties can be set in the `options` object when [instantiating a new SDK]({{ site_base_path }}sdk-reference/js/6/kuzzle/constructor/#arguments).
1616

17-
Some of them are also [writable properties]({{ site_base_path }}sdk-reference/js/6/kuzzle/introduction/#properties) available after SDK instantiation.
17+
Some of them are also [writable properties]({{ site_base_path }}sdk-reference/js/6/kuzzle/properties) available after SDK instantiation.
1818

1919
### autoQueue
2020

src/sdk-reference/js/6/profile/introduction/index.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,3 @@ order: 0
1010
This class represents a Kuzzle Profile.
1111

1212
Refer to the [Security guide]({{ site_base_path }}guide/1/essentials/security#defining-profiles-default) for more information about profiles.
13-
14-
## Properties
15-
16-
Available properties:
17-
18-
| Property | Type | Description |
19-
|--- |--- |--- |
20-
| `_id` | <pre>string</pre> | Profile ID |
21-
| `policies` | <pre>object[]</pre> | Array of policies for this profile |
22-
23-
Each policy object can contain the following properties:
24-
25-
| Property | Type | Description |
26-
|--- |--- |--- |
27-
| `roleId` | <pre>string</pre> | Roles IDs for this user |
28-
| `restrictedTo` | <pre>object[]</pre> | Array of object containing indexes and collections which the profile is restricted to |
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
layout: sdk.html.hbs
3+
title: Properties
4+
description: Profile Properties
5+
order: 100
6+
---
7+
8+
# Properties
9+
10+
| Property | Type | Description |
11+
|--- |--- |--- |
12+
| `_id` | <pre>string</pre> | Profile ID |
13+
| `policies` | <pre>object[]</pre> | Array of policies for this profile |
14+
15+
### policies
16+
17+
Each policy object can contain the following properties:
18+
19+
| Property | Type | Description |
20+
|--- |--- |--- |
21+
| `roleId` | <pre>string</pre> | Roles IDs for this user |
22+
| `restrictedTo` | <pre>object[]</pre> | Array of object containing indexes and collections which the profile is restricted to |

0 commit comments

Comments
 (0)