diff --git a/src/sdk-reference/js/6/auth/login/index.md b/src/sdk-reference/js/6/auth/login/index.md index 7bee0fe8d..f8fe9d567 100644 --- a/src/sdk-reference/js/6/auth/login/index.md +++ b/src/sdk-reference/js/6/auth/login/index.md @@ -8,7 +8,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]({{ 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. +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. + +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. ## Arguments diff --git a/src/sdk-reference/js/6/auth/logout/index.md b/src/sdk-reference/js/6/auth/logout/index.md index 45b127410..a3a1200ed 100644 --- a/src/sdk-reference/js/6/auth/logout/index.md +++ b/src/sdk-reference/js/6/auth/logout/index.md @@ -6,11 +6,13 @@ 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]({{ site_base_path }}sdk-reference/js/6/kuzzle/properties) property of this class instance is unset. + +## Arguments ```javascript logout () diff --git a/src/sdk-reference/js/6/auth/refresh-token/index.md b/src/sdk-reference/js/6/auth/refresh-token/index.md index 3e94bc254..bcfb72a5e 100644 --- a/src/sdk-reference/js/6/auth/refresh-token/index.md +++ b/src/sdk-reference/js/6/auth/refresh-token/index.md @@ -10,7 +10,10 @@ description: Refresh an 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]({{ site_base_path }}sdk-reference/js/6/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]({{ site_base_path }}sdk-reference/js/6/auth/logout) action is called, or the `jwt` property is manually set to another value. + ## Arguments diff --git a/src/sdk-reference/js/6/kuzzle-error/introduction/index.md b/src/sdk-reference/js/6/kuzzle-error/introduction/index.md index 7b800f99d..4ab5385d2 100644 --- a/src/sdk-reference/js/6/kuzzle-error/introduction/index.md +++ b/src/sdk-reference/js/6/kuzzle-error/introduction/index.md @@ -10,13 +10,3 @@ order: 0 Inherits from the standard `Error` class. The KuzzleError class represents an [error response from Kuzzle API]({{ site_base_path }}api/1/essentials/errors/). - -## Properties - -Available properties. - -| Property name | Type | Description | -| -------------------- | -------- | --------------------------------------- | -| `message` |
string
| Error message | -| `status` |
number
| Error status code | -| `stack` |
string
| Error stacktrace (only in development mode) | diff --git a/src/sdk-reference/js/6/kuzzle-error/properties/index.md b/src/sdk-reference/js/6/kuzzle-error/properties/index.md new file mode 100644 index 000000000..1781c571c --- /dev/null +++ b/src/sdk-reference/js/6/kuzzle-error/properties/index.md @@ -0,0 +1,13 @@ +--- +layout: sdk.html.hbs +title: Properties +description: KuzzleError Properties +--- + +# Properties + +| Property name | Type | Description | +| -------------------- | -------- | --------------------------------------- | +| `message` |
string
| Error message | +| `status` |
number
| Error status code | +| `stack` |
string
| Error stacktrace (only in development mode) | diff --git a/src/sdk-reference/js/6/kuzzle/introduction/index.md b/src/sdk-reference/js/6/kuzzle/introduction/index.md index febf7346e..e203dbd6c 100644 --- a/src/sdk-reference/js/6/kuzzle/introduction/index.md +++ b/src/sdk-reference/js/6/kuzzle/introduction/index.md @@ -32,70 +32,3 @@ 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]({{site_base_path}}api/1/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` |
boolean
| Automatically queue all requests during offline mode | Yes | -| `autoReplay` |
boolean
| Automatically replay queued requests on a `reconnected` event | Yes | -| `autoResubscribe` |
boolean
| Automatically renew all subscriptions on a `reconnected` event | Yes | -| `jwt` |
string
| Token used in requests for authentication | Yes | -| `offlineQueue` |
object[]
| Contains the queued requests during offline mode | No | -| `offlineQueueLoader` |
function
| Called before dequeuing requests after exiting offline mode,
to add items at the beginning of the offline queue | Yes | -| `protocol` |
Protocol
| Protocol used by the SDK | No | -| `queueFilter` |
function
| Called during offline mode.
Takes a request object as arguments and returns a boolean, indicating if a request can be queued | Yes | -| `queueMaxSize` |
number
| Number of maximum requests kept during offline mode| Yes | -| `queueTTL` |
number
| Time a queued request is kept during offline mode, in milliseconds | Yes | -| `replayInterval` |
number
| Delay between each replayed requests | Yes | -| `volatile` |
object
| 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 offlineQueueLoader() -``` - -The returned (or resolved) array must contain objects, each with the following properties: - -| Property | Type | Description | -|---|---|---| -| `query` |
object
| 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 | -| `reject` |
function
| A [Promise.reject](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject) function | -| `resolve` |
function
| 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]({{ site_base_path }}api/1/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. - diff --git a/src/sdk-reference/js/6/kuzzle/properties/index.md b/src/sdk-reference/js/6/kuzzle/properties/index.md new file mode 100644 index 000000000..039f986d8 --- /dev/null +++ b/src/sdk-reference/js/6/kuzzle/properties/index.md @@ -0,0 +1,76 @@ +--- +layout: sdk.html.hbs +title: Properties +description: Kuzzle class properties +order: 100 +--- + +# Read-only properties + +| Property name | Type | Description | +| -------------------- | -------- | ---------------------| +| `offlineQueue` |
object[]
| Contains the queued requests during offline mode | +| `protocol` |
Protocol
| Protocol used by the SDK | + +# Writable properties + +| Property name | Type | Description | +| -------------------- | -------- | ---------------------| +| `autoQueue` |
boolean
| If `true`, automatically queues all requests during offline mode | +| `autoReplay` |
boolean
| If `true`, automatically replays queued requests on a `reconnected` event | +| `autoResubscribe` |
boolean
| If `true`, automatically renews all subscriptions on a `reconnected` event | +| `jwt` |
string
| Authentication token | +| `offlineQueueLoader` |
function
| Called before dequeuing requests after exiting offline mode, to add items at the beginning of the offline queue | +| `queueFilter` |
function
| Custom function called during offline mode to filter queued requests on-the-fly | +| `queueMaxSize` |
number
| Number of maximum requests kept during offline mode| +| `queueTTL` |
number
| Time a queued request is kept during offline mode, in milliseconds | +| `replayInterval` |
number
| Delay between each replayed requests | +| `volatile` |
object
| 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 offlineQueueLoader() +``` + +The returned (or resolved) array must contain objects, each with the following properties: + +| Property | Type | Description | +|---|---|---| +| `query` |
object
| 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 | +| `reject` |
function
| A [Promise.reject](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject) function | +| `resolve` |
function
| 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]({{ site_base_path }}api/1/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. + diff --git a/src/sdk-reference/js/6/offline-tools/index.md b/src/sdk-reference/js/6/offline-tools/index.md index 1c2044291..4dcbbfc95 100644 --- a/src/sdk-reference/js/6/offline-tools/index.md +++ b/src/sdk-reference/js/6/offline-tools/index.md @@ -14,7 +14,7 @@ during its lifespan. These properties can be set in the `options` object when [instantiating a new SDK]({{ site_base_path }}sdk-reference/js/6/kuzzle/constructor/#arguments). -Some of them are also [writable properties]({{ site_base_path }}sdk-reference/js/6/kuzzle/introduction/#properties) available after SDK instantiation. +Some of them are also [writable properties]({{ site_base_path }}sdk-reference/js/6/kuzzle/properties) available after SDK instantiation. ### autoQueue diff --git a/src/sdk-reference/js/6/profile/introduction/index.md b/src/sdk-reference/js/6/profile/introduction/index.md index a384fbdc8..f7c3ab4cb 100644 --- a/src/sdk-reference/js/6/profile/introduction/index.md +++ b/src/sdk-reference/js/6/profile/introduction/index.md @@ -10,19 +10,3 @@ order: 0 This class represents a Kuzzle Profile. Refer to the [Security guide]({{ site_base_path }}guide/1/essentials/security#defining-profiles-default) for more information about profiles. - -## Properties - -Available properties: - -| Property | Type | Description | -|--- |--- |--- | -| `_id` |
string
| Profile ID | -| `policies` |
object[]
| Array of policies for this profile | - -Each policy object can contain the following properties: - -| Property | Type | Description | -|--- |--- |--- | -| `roleId` |
string
| Roles IDs for this user | -| `restrictedTo` |
object[]
| Array of object containing indexes and collections which the profile is restricted to | diff --git a/src/sdk-reference/js/6/profile/properties/index.md b/src/sdk-reference/js/6/profile/properties/index.md new file mode 100644 index 000000000..8c9dff774 --- /dev/null +++ b/src/sdk-reference/js/6/profile/properties/index.md @@ -0,0 +1,22 @@ +--- +layout: sdk.html.hbs +title: Properties +description: Profile Properties +order: 100 +--- + +# Properties + +| Property | Type | Description | +|--- |--- |--- | +| `_id` |
string
| Profile ID | +| `policies` |
object[]
| Array of policies for this profile | + +### policies + +Each policy object can contain the following properties: + +| Property | Type | Description | +|--- |--- |--- | +| `roleId` |
string
| Roles IDs for this user | +| `restrictedTo` |
object[]
| Array of object containing indexes and collections which the profile is restricted to | diff --git a/src/sdk-reference/js/6/role/introduction/index.md b/src/sdk-reference/js/6/role/introduction/index.md index 493a5168e..d5767f269 100644 --- a/src/sdk-reference/js/6/role/introduction/index.md +++ b/src/sdk-reference/js/6/role/introduction/index.md @@ -10,12 +10,3 @@ order: 0 This class represents a Kuzzle Role. Refer to the [Security guide]({{ site_base_path }}guide/1/essentials/security#defining-roles-default) for more information about roles. - -## Properties - -Available properties: - -| Property | Type | Description | -|--- |--- |--- | -| `_id` |
string
| Role ID | -| `controllers` |
object
| Object defining controllers action available for this role | diff --git a/src/sdk-reference/js/6/role/properties/index.md b/src/sdk-reference/js/6/role/properties/index.md new file mode 100644 index 000000000..d9546feec --- /dev/null +++ b/src/sdk-reference/js/6/role/properties/index.md @@ -0,0 +1,15 @@ +--- +layout: sdk.html.hbs +title: Properties +description: Role class properties +order: 100 +--- + +# Properties + +Available properties: + +| Property | Type | Description | +|--- |--- |--- | +| `_id` |
string
| Role unique identifier | +| `controllers` |
object
| Object defining controller actions allowed by this role | diff --git a/src/sdk-reference/js/6/search-result/introduction/index.md b/src/sdk-reference/js/6/search-result/introduction/index.md index d647ffcb7..fb7b3b4d1 100644 --- a/src/sdk-reference/js/6/search-result/introduction/index.md +++ b/src/sdk-reference/js/6/search-result/introduction/index.md @@ -11,23 +11,3 @@ The class is used to retrieve the subsequent paginated results of a search query The following methods returns a `SearchResult`: - [document:search]({{ site_base_path }}sdk-reference/js/6/document/search) - [collection:searchSpecifications]({{ site_base_path }}sdk-reference/js/6/collection/search-specifications) - -## Properties - -Available properties. - -| Property | Type | Description | -|--- |--- |--- | -| `aggregations` |
object
| Search aggregations if any | -| `hits` |
object[]
| Array containing the retrieved items for the current page | -| `total` |
number
| Total number of items matching the given query in Kuzzle database | -| `fetched` |
number
| Number of retrieved items so far | -| `scroll_id` |
string
| Scroll identifier if the search was given a `scroll` parameter | - -Each object of the `hits` array contain the following properties: - -| Property | Type | Description | -|--- |--- |--- | -| `_id` |
string
| Document ID | -| `_score` |
number
| [Relevance score](https://www.elastic.co/guide/en/elasticsearch/guide/current/relevance-intro.html) | -| `_source` |
object
| Document content | diff --git a/src/sdk-reference/js/6/search-result/properties/index.md b/src/sdk-reference/js/6/search-result/properties/index.md new file mode 100644 index 000000000..a2e15205d --- /dev/null +++ b/src/sdk-reference/js/6/search-result/properties/index.md @@ -0,0 +1,26 @@ +--- +layout: sdk.html.hbs +title: Properties +description: SearchResult class properties +order: 1000 +--- + +# Properties + +| Property | Type | Description | +|--- |--- |--- | +| `aggregations` |
object
| Search aggregations if any | +| `hits` |
object[]
| Array containing the retrieved items for the current page | +| `total` |
number
| Total number of items matching the given query in Kuzzle database | +| `fetched` |
number
| Number of retrieved items so far | +| `scroll_id` |
string
| Scroll identifier if the search was given a `scroll` parameter | + +### hits + +Each object of the `hits` array contain the following properties: + +| Property | Type | Description | +|--- |--- |--- | +| `_id` |
string
| Document ID | +| `_score` |
number
| [Relevance score](https://www.elastic.co/guide/en/elasticsearch/guide/current/relevance-intro.html) | +| `_source` |
object
| Document content | diff --git a/src/sdk-reference/js/6/socketio/introduction/index.md b/src/sdk-reference/js/6/socketio/introduction/index.md index 3662df4d4..6d5e63d9b 100644 --- a/src/sdk-reference/js/6/socketio/introduction/index.md +++ b/src/sdk-reference/js/6/socketio/introduction/index.md @@ -15,16 +15,3 @@ This protocol allows you to use all the features of Kuzzle, including [real-time The SocketIO protocol is used for websocket compatibility with older browsers. It is preferable to use the WebSocket protocol when possible.

- -## Properties - -Available properties. - -| Property name | Type | Description | Writable? | -| -------------------- | -------- | --------------------------------------- | :-------: | -| `autoReconnect` |
boolean
| Automatically reconnect after a connection loss | No | -| `reconnectionDelay` |
number
| Number of milliseconds between reconnection attempts | No | - -**Notes:** - -- updates to `autoReconnect` and `reconnectionDelay` properties will only take effect on next `connect` call diff --git a/src/sdk-reference/js/6/socketio/properties/index.md b/src/sdk-reference/js/6/socketio/properties/index.md new file mode 100644 index 000000000..8b9bac441 --- /dev/null +++ b/src/sdk-reference/js/6/socketio/properties/index.md @@ -0,0 +1,17 @@ +--- +layout: sdk.html.hbs +title: Properties +description: SocketIO class properties +order: 100 +--- + +# Properties + +| Property name | Type | Description | +| -------------------- | -------- | ---------------------| +| `autoReconnect` |
boolean
| Automatically reconnect after a connection loss | +| `reconnectionDelay` |
number
| Number of milliseconds between reconnection attempts | + +
+Updates to autoReconnect and reconnectionDelay properties will only take effect on the next `connect` call. +
diff --git a/src/sdk-reference/js/6/user/introduction/index.md b/src/sdk-reference/js/6/user/introduction/index.md index 8a1697f3e..c16d9744a 100644 --- a/src/sdk-reference/js/6/user/introduction/index.md +++ b/src/sdk-reference/js/6/user/introduction/index.md @@ -15,19 +15,3 @@ The following methods return a `User` object: - [auth:getCurrentUser]({{ site_base_path }}sdk-reference/js/6/auth/get-current-user) - [auth:updateSelf]({{ site_base_path }}sdk-reference/js/6/auth/update-self) - -## Properties - -Available properties: - -| Property | Type | Description | -|--- |--- |--- | -| `_id` |
string
| User ID (kuid) | -| `content` |
object
| User internal content | - -The `content` property is an object containing generic properties alongside custom defined properties. - -| Property | Type | Description | -|--- |--- |--- | -| `profileIds` |
string[]
| Profiles IDs for this user | -| `_kuzzle_info` |
object
| [Kuzzle metadata]({{ site_base_path }}guide/1/essentials/document-metadata) | diff --git a/src/sdk-reference/js/6/user/properties/index.md b/src/sdk-reference/js/6/user/properties/index.md new file mode 100644 index 000000000..6190cf810 --- /dev/null +++ b/src/sdk-reference/js/6/user/properties/index.md @@ -0,0 +1,23 @@ +--- +layout: sdk.html.hbs +title: Properties +description: User class properties +order: 100 +--- + +# Properties + + +| Property | Type | Description | +|--- |--- |--- | +| `_id` |
string
| User ID (kuid) | +| `content` |
object
| User internal content | + +### content + +The `content` property is an object containing, alongside custom defined values, the following generic properties: + +| Property | Type | Description | +|--- |--- |--- | +| `profileIds` |
string[]
| Profiles IDs for this user | +| `_kuzzle_info` |
object
| [Kuzzle metadata]({{ site_base_path }}guide/1/essentials/document-metadata) | diff --git a/src/sdk-reference/js/6/websocket/introduction/index.md b/src/sdk-reference/js/6/websocket/introduction/index.md index e69ded9b2..8b172d7d2 100644 --- a/src/sdk-reference/js/6/websocket/introduction/index.md +++ b/src/sdk-reference/js/6/websocket/introduction/index.md @@ -12,16 +12,3 @@ Inherits from: [KuzzleEventEmitter]({{ site_base_path }}sdk-reference/js/6/kuzzl The WebSocket protocol can be used by an instance of the SDK to communicate with your Kuzzle server. This protocol allows you to use all the features of Kuzzle, including [real-time notifications]({{ site_base_path }}sdk-reference/js/6/realtime-notifications). - -## Properties - -Available properties. - -| Property name | Type | Description | Writable? | -| -------------------- | -------- | --------------------------------------- | :-------: | -| `autoReconnect` |
boolean
| Automatically reconnect after a connection loss | No | -| `reconnectionDelay` |
number
| Number of milliseconds between reconnection attempts | No | - -**Notes:** - -- updates to `autoReconnect` and `reconnectionDelay` properties will only take effect on next `connect` call diff --git a/src/sdk-reference/js/6/websocket/properties/index.md b/src/sdk-reference/js/6/websocket/properties/index.md new file mode 100644 index 000000000..f2a4f3e0f --- /dev/null +++ b/src/sdk-reference/js/6/websocket/properties/index.md @@ -0,0 +1,17 @@ +--- +layout: sdk.html.hbs +title: Properties +description: Websocket class properties +order: 100 +--- + +# Properties + +| Property name | Type | Description | +| -------------------- | -------- | ---------------------| +| `autoReconnect` |
boolean
| Automatically reconnect after a connection loss | +| `reconnectionDelay` |
number
| Number of milliseconds between reconnection attempts | + +
+Updates to autoReconnect and reconnectionDelay properties will only take effect on the next `connect` call. +