Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/1/plugins/plugin-context/accessors/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
code: true
type: branch
title: Accessors
title: accessors
---
2 changes: 1 addition & 1 deletion src/core/1/plugins/plugin-context/constructors/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
code: true
type: branch
title: Constructors
title: constructors
---
2 changes: 1 addition & 1 deletion src/core/1/plugins/plugin-context/errors/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
code: true
type: branch
title: Errors
title: errors
---
2 changes: 1 addition & 1 deletion src/core/1/plugins/plugin-context/log/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
code: true
type: branch
title: Log
title: log
---
4 changes: 3 additions & 1 deletion src/sdk/js/6/controllers/auth/login/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ description: Authenticate a user

Authenticates a user.

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](/sdk/js/6/controllers/auth/logout/) action is called, or the [jwt](/sdk/js/6/core-classes/kuzzle/constructor/) property is manually unset.
If this action is successful, then the [jwt](/sdk/js/6/core-classes/kuzzle/properties) property of this class instance is set to the new authentication token.

All further requests emitted by this SDK instance will be on behalf of the authenticated user, until either the authenticated token expires, the [logout](/sdk/js/6/controllers/auth/logout) action is called, or the `jwt` property is manually set to another value.

## Arguments

Expand Down
4 changes: 3 additions & 1 deletion src/sdk/js/6/controllers/auth/logout/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ description: Revokes the user's token & unsubscribe them from registered rooms.

# logout

Revokes the user's authentication token.
Revokes the current authentication token.

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

If this action is successful, then the [jwt](/sdk/js/6/core-classes/kuzzle/properties) property of this class instance is unset.

<br/>

```javascript
Expand Down
33 changes: 18 additions & 15 deletions src/sdk/js/6/controllers/auth/refresh-token/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,46 @@ title: refreshToken
description: Refresh an authentication token
---

# refreshToken
# refreshToken

<SinceBadge version="6.1.0" />

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

If this action is successful, all further requests emitted by this SDK instance will use the refreshed authentication token.
If this action is successful, then the [jwt](/sdk/js/6/core-classes/kuzzle/properties) property of this class instance is set to the new authentication token.

## Arguments
All further requests emitted by this SDK instance will be on behalf of the authenticated user, until either the authenticated token expires, the [logout](/core/sdk/js/6/auth/logout) action is called, or the `jwt` property is manually set to another value.

```javascript

## Arguments

```javascript
refreshToken ([options])
```

<br/>
<br/>

| Arguments | Type | Description |
| Arguments | Type | Description |
|--------------|---------|-------------|
| `options` | <pre>object</pre> | Query options |


### options
### options

Additional query options
Additional query options

| Property | Type<br/>(default) | Description |
| -------------- | --------- | ------------- |
| `expiresIn` | <pre>string</pre> | Expiration time in [ms library](https://www.npmjs.com/package/ms) format. (e.g. `2h`) |
| `queuable` | <pre>boolean</pre><br/>(`true`)| If true, queues the request during downtime, until connected to Kuzzle again |

### expiresIn
### expiresIn

The default value for the `expiresIn` option is defined at server level, in Kuzzle's [configuration file](/core/1/guide/guides/essentials/configuration/).
The default value for the `expiresIn` option is defined at server level, in Kuzzle's [configuration file](/core/1/guide/guides/essentials/configuration/).

## Resolves
## Resolves

The `refreshToken` action resolves to a token object with the following properties:
The `refreshToken` action resolves to a token object with the following properties:

| Property | Type | Description |
|--------------|---------|-------------|
Expand All @@ -50,6 +53,6 @@ refreshToken ([options])
| `jwt` | <pre>string</pre> | Authentication token |
| `ttl` | <pre>number</pre> | Time to live of the authentication token, in milliseconds |

## Usage
## Usage

<<< ./snippets/refreshToken.js
<<< ./snippets/refreshToken
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ try {
console.log(await kuzzle.auth.refreshToken());
} catch (error) {
console.error(error.message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ expected:
- ^\s*expiresAt: \d+
- ^\s*ttl: \d+ }
sdk: js
version: 6
version: 6
14 changes: 2 additions & 12 deletions src/sdk/js/6/core-classes/kuzzle-error/introduction/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
code: true
code: false
type: page
title: Introduction
description: KuzzleError object
Expand All @@ -10,14 +10,4 @@ order: 0

Inherits from the standard `Error` class.

The KuzzleError class represents an [error response from Kuzzle API](/core/1/api/essentials/errors/).

## Properties

Available properties.

| Property name | Type | Description |
| ------------- | ----------------- | ------------------------------------------- |
| `message` | <pre>string</pre> | Error message |
| `status` | <pre>number</pre> | Error status code |
| `stack` | <pre>string</pre> | Error stacktrace (only in development mode) |
The KuzzleError class represents an [error response from Kuzzle API](/core/1/api/essentials/errors/).
16 changes: 16 additions & 0 deletions src/sdk/js/6/core-classes/kuzzle-error/properties/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
code: false
type: page
title: Properties
description: KuzzleError Properties
order: 10
---


# Properties

| Property name | Type | Description |
| -------------------- | -------- | --------------------------------------- |
| `message` | <pre>string</pre> | Error message |
| `status` | <pre>number</pre> | Error status code |
| `stack` | <pre>string</pre> | Error stacktrace (only in development mode) |
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
code: true
code: false
type: page
title: Introduction
description: KuzzleEventEmitter class
Expand Down
6 changes: 3 additions & 3 deletions src/sdk/js/6/core-classes/kuzzle/constructor/index.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
code: true
type: page
title: Constructor
title: constructor
description: Creates a new Kuzzle object connected to the backend
order: 50
---

# Constructor

Use this constructor to create a new instance of the SDK.
Use this constructor to create a new instance of the SDK.
Each instance represent a different connection to a Kuzzle server with specific options.

## Arguments
Expand All @@ -26,7 +26,7 @@ Kuzzle(protocol, [options]);

### protocol

The protocol used to connect to the Kuzzle instance.
The protocol used to connect to the Kuzzle instance.
It can be one of the following available protocols:

- [WebSocket](/sdk/js/6/websocket)
Expand Down
72 changes: 3 additions & 69 deletions src/sdk/js/6/core-classes/kuzzle/introduction/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
code: true
code: false
type: page
title: Introduction
description: Kuzzle object
Expand All @@ -10,7 +10,7 @@ order: 0

Inherits from: [KuzzleEventEmitter](/sdk/js/6/kuzzle-event-emitter).

The Kuzzle class is the main class of the SDK.
The Kuzzle class is the main class of the SDK.
Once instantiated, it represents a connection to your Kuzzle server.

It gives access to the different features of the SDKs:
Expand All @@ -34,70 +34,4 @@ The following protocols are available in the SDK JS 6:

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](/core/1/api/essentials/volatile-data/) to provide additional informations about the client who sent the request.

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.

## Properties

Available properties.

| Property name | Type | Description | Writable? |
| -------------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------- | :-------: |
| `autoQueue` | <pre>boolean</pre> | Automatically queue all requests during offline mode | Yes |
| `autoReplay` | <pre>boolean</pre> | Automatically replay queued requests on a `reconnected` event | Yes |
| `autoResubscribe` | <pre>boolean</pre> | Automatically renew all subscriptions on a `reconnected` event | Yes |
| `jwt` | <pre>string</pre> | Token used in requests for authentication | Yes |
| `offlineQueue` | <pre>object[]</pre> | Contains the queued requests during offline mode | No |
| `offlineQueueLoader` | <pre>function</pre> | Called before dequeuing requests after exiting offline mode,</br> to add items at the beginning of the offline queue | Yes |
| `protocol` | <pre>Protocol</pre> | Protocol used by the SDK | No |
| `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 |
| `queueMaxSize` | <pre>number</pre> | Number of maximum requests kept during offline mode | Yes |
| `queueTTL` | <pre>number</pre> | Time a queued request is kept during offline mode, in milliseconds | Yes |
| `replayInterval` | <pre>number</pre> | Delay between each replayed requests | Yes |
| `volatile` | <pre>object</pre> | Common volatile data, will be sent to all future requests | Yes |

### offlineQueueLoader

The `offlineQueueLoader` property must be set with a function of one of the following formats:

```js
Object[] offlineQueueLoader()

Promise<Object[]> offlineQueueLoader()
```

The returned (or resolved) array must contain objects, each with the following properties:

| Property | Type | Description |
| --------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `query` | <pre>object</pre> | Object representing the request that is about to be sent to Kuzzle, following the [Kuzzle API](/core/1/api/essentials/query-syntax) format |
| `reject` | <pre>function</pre> | A [Promise.reject](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject) function |
| `resolve` | <pre>function</pre> | A [Promise.resolve](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve) function |

### queueFilter

The `queueFilter` property must be set with a function of the following form:

```js
boolean queueFilter(request)
```

The `request` argument is an object representing the request that is about to be sent to Kuzzle, following the [Kuzzle API](/core/1/api/essentials/query-syntax) format.

### queueMaxSize

This property defines the size of the offline buffer, which is a first-in first-out (FIFO) queue.

This means that if the `queueMaxSize` limit is reached, older requests are discarded to make room for newer requests.

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.
Note that doing so may lead to a crash due to memory saturation, if there are too many requests held in memory.

### queueTTL

If the `queueTTL` property is set to a number lower than, or equal to `0`, then requests never expire and are kept indefinitely.

### volatile

Multiple methods allow passing specific `volatile` data.

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.
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.
76 changes: 76 additions & 0 deletions src/sdk/js/6/core-classes/kuzzle/properties/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
code: false
type: page
title: Properties
description: Kuzzle class properties
order: 10
---

# Read-only properties

| Property name | Type | Description |
| -------------------- | -------- | ---------------------|
| `offlineQueue` | <pre>object[]</pre> | Contains the queued requests during offline mode |
| `protocol` | <pre>Protocol</pre> | Protocol used by the SDK |

# Writable properties

| Property name | Type | Description |
| -------------------- | -------- | ---------------------|
| `autoQueue` | <pre>boolean</pre> | If `true`, automatically queues all requests during offline mode |
| `autoReplay` | <pre>boolean</pre> | If `true`, automatically replays queued requests on a `reconnected` event |
| `autoResubscribe` | <pre>boolean</pre> | If `true`, automatically renews all subscriptions on a `reconnected` event |
| `jwt` | <pre>string</pre> | Authentication token |
| `offlineQueueLoader` | <pre>function</pre> | Called before dequeuing requests after exiting offline mode, to add items at the beginning of the offline queue |
| `queueFilter` | <pre>function</pre> | Custom function called during offline mode to filter queued requests on-the-fly |
| `queueMaxSize` | <pre>number</pre> | Number of maximum requests kept during offline mode|
| `queueTTL` | <pre>number</pre> | Time a queued request is kept during offline mode, in milliseconds |
| `replayInterval` | <pre>number</pre> | Delay between each replayed requests |
| `volatile` | <pre>object</pre> | Common volatile data, will be sent to all future requests |

### offlineQueueLoader

The `offlineQueueLoader` property must be set with a function of one of the following formats:

```js
Object[] offlineQueueLoader()

Promise<Object[]> offlineQueueLoader()
```

The returned (or resolved) array must contain objects, each with the following properties:

| Property | Type | Description |
|---|---|---|
| `query` | <pre>object</pre> | Object representing the request that is about to be sent to Kuzzle, following the [Kuzzle API](/core/1/api/essentials/query-syntax) format |
| `reject` | <pre>function</pre> | A [Promise.reject](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject) function |
| `resolve` | <pre>function</pre> | A [Promise.resolve](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve) function |

### queueFilter

The `queueFilter` property must be set with a function of the following form:

```js
boolean queueFilter(request)
```

The `request` argument is an object representing the request that is about to be sent to Kuzzle, following the [Kuzzle API](/core/1/api/essentials/query-syntax) format.

### queueMaxSize

This property defines the size of the offline buffer, which is a first-in first-out (FIFO) queue.

This means that if the `queueMaxSize` limit is reached, older requests are discarded to make room for newer requests.

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.
Note that doing so may lead to a crash due to memory saturation, if there are too many requests held in memory.

### queueTTL

If the `queueTTL` property is set to a number lower than, or equal to `0`, then requests never expire and are kept indefinitely.

### volatile

Multiple methods allow passing specific `volatile` data.

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.
Loading