Skip to content
Closed
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
14 changes: 14 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,26 @@ src/**/*.d.ts
src/**/*.js.map

src/Kuzzle.js
src/KuzzleError.js
src/controllers/Auth.js
src/controllers/Document.js
src/controllers/Realtime.js
src/controllers/Index.js
src/controllers/Collection.js
src/controllers/Base.js
src/core/security/User.js
src/core/security/Profile.js
src/core/security/Role.js
src/protocols/abstract/Base.js
src/protocols/abstract/Realtime.js
src/protocols/Http.js
src/protocols/WebSocket.js
src/protocols/index.js
src/utils/interfaces.js
src/core/KuzzleEventEmitter.js
src/core/searchResult/SearchResultBase.js
src/core/searchResult/Document.js
src/core/searchResult/Profile.js
src/core/searchResult/Role.js
src/core/searchResult/Specifications.js
src/core/searchResult/User.js
File renamed without changes.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,26 @@ test-*.js
*.js.map
index.js
src/Kuzzle.js
src/KuzzleError.js
src/controllers/Auth.js
src/controllers/Document.js
src/controllers/Index.js
src/controllers/Collection.js
src/controllers/Base.js
src/controllers/Realtime.js
src/core/security/User.js
src/core/security/Profile.js
src/core/security/Role.js
src/protocols/abstract/Base.js
src/protocols/abstract/Realtime.js
src/protocols/Http.js
src/protocols/WebSocket.js
src/protocols/index.js
src/utils/interfaces.js
src/core/KuzzleEventEmitter.js
src/core/searchResult/SearchResultBase.js
src/core/searchResult/Document.js
src/core/searchResult/Profile.js
src/core/searchResult/Role.js
src/core/searchResult/Specifications.js
src/core/searchResult/User.js
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:

install:
- npm install
- npm run build

script:
- npm run test:lint
Expand Down Expand Up @@ -78,7 +79,7 @@ jobs:
- npm install
- npm run build
script:
- npm run doc-testing
- travis_retry npm run doc-testing

- stage: Tests
name: Dead link check
Expand All @@ -93,7 +94,7 @@ jobs:
- $(npm bin)/kuzdoc framework:link -d /sdk/js/7/ -v 7
script:
- gem install typhoeus
- cd doc/framework/ && HYDRA_MAX_CONCURRENCY=20 ruby .ci/dead-links.rb -p src/sdk/js/7/
- cd doc/framework/ && HYDRA_MAX_CONCURRENCY=20 travis_retry ruby .ci/dead-links.rb -p src/sdk/js/7/

- stage: Deployment Doc Dev
name: Deploy next-docs.kuzzle.io
Expand Down
2 changes: 1 addition & 1 deletion doc/7/controllers/auth/create-api-key/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The API key content has the following properties:
| Name | Type | Description |
| --------- | ----------------- | ---------------- |
| `userId` | <pre>string</pre> | User kuid |
| `expiresAt` | <pre>number</pre> | Expiration date in UNIX micro-timestamp format (`-1` if the token never expires) |
| `expiresAt` | <pre>number</pre> | Expiration date in Epoch-millis format (`-1` if the token never expires) |
| `ttl` | <pre>number</pre> | Original TTL |
| `description` | <pre>string</pre> | API key description |
| `token` | <pre>string</pre> | Authentication token associated with this API key |
Expand Down
54 changes: 46 additions & 8 deletions doc/7/controllers/collection/create/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@ description: Create a new collection

# create

Creates a new [collection](/core/2/guides/essentials/store-access-data) in Kuzzle via the persistence engine, in the provided index.
Creates a new [collection](/core/2/guides/essentials/store-access-data) in the provided index.

You can also provide an optional data mapping that allow you to exploit the full capabilities of our
persistent data storage layer, [ElasticSearch](https://www.elastic.co/elastic-stack) (check here the [mapping capabilities of ElasticSearch](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/mapping.html)).
persistent data storage layer, [ElasticSearch](https://www.elastic.co/elastic-stack) (check here the [mapping capabilities of ElasticSearch](/core/2/guides/essentials/database-mappings/)).

This method will only update the mapping if the collection already exists.

<SinceBadge version="Kuzzle 2.2.0" />
<SinceBadge version="7.4.0" />

You can also provide Elasticsearch [index settings](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/index-modules.html#index-modules-settings) when creating a new collection.

<br/>

```js
create(index, collection, [mapping], [options]);
create(index, collection, [definition], [options]);
```

<br/>
Expand All @@ -26,17 +31,48 @@ create(index, collection, [mapping], [options]);
| ------------ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `index` | <pre>string</pre> | Index name |
| `collection` | <pre>string</pre> | Collection name |
| `mapping` | <pre>object</pre> | Describes the data mapping to associate to the new collection, using Elasticsearch [mapping format](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/mapping.html) |
| `definition` | <pre>object</pre> | Describes the collection mappings and the ES index settings |
| `options` | <pre>object</pre> | Query options |
<SinceBadge version="7.4.0">

### mapping

An object representing the data mapping of the collection.
### definition

An object containings:
- [collection mappings](/core/2/guides/essentials/database-mappings).
- Elasticsearch [index settings](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/index-modules.html#index-modules-settings)
The mapping must have a root field `properties` that contain the mapping definition:

```js
const mapping = {
const definition = {
mappings: {
properties: {
field1: { type: 'text' },
field2: {
properties: {
nestedField: { type: 'keyword' }
}
}
}
},
settings: {

}
};
```

</SinceBadge>


<DeprecatedBadge version="7.4.0">

### definition

An object representing the data mappings of the collection.

The mappings must have a root field `properties` that contain the mappings properties definition:

```js
const mappings = {
properties: {
field1: { type: 'text' },
field2: {
Expand All @@ -50,6 +86,8 @@ const mapping = {

More informations about database mappings [here](/core/2/guides/essentials/database-mappings).

</DeprecatedBadge>

### options

Additional query options
Expand Down
4 changes: 2 additions & 2 deletions doc/7/controllers/collection/create/snippets/create.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const mapping = {
const mappings = {
properties: {
license: { type: 'keyword' },
driver: {
Expand All @@ -11,7 +11,7 @@ const mapping = {
};

try {
await kuzzle.collection.create('nyc-open-data', 'yellow-taxi', mapping);
await kuzzle.collection.create('nyc-open-data', 'yellow-taxi', { mappings });

console.log('Success');
} catch (error) {
Expand Down
32 changes: 32 additions & 0 deletions doc/7/controllers/collection/delete/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
code: true
type: page
title: delete
description: Deletes a collection
---

# delete

Deletes a collection.

<br/>

```js
delete(index, collection);
```

<br/>

| Arguments | Type | Description |
| ------------ | ----------------- | --------------- |
| `index` | <pre>string</pre> | Index name |
| `collection` | <pre>string</pre> | Collection name |


## Resolves

Resolves if the collection is successfully deleted.

## Usage

<<< ./snippets/delete-specifications.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
try {
await kuzzle.collection.delete('nyc-open-data', 'yellow-taxi');

console.log('Success');
} catch (error) {
console.error(error.message);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: collection#delete
description: Delete a collection
hooks:
before: curl -X POST kuzzle:7512/nyc-open-data/_create && curl -X PUT kuzzle:7512/nyc-open-data/yellow-taxi
after:
template: default
expected: Success
2 changes: 1 addition & 1 deletion doc/7/controllers/collection/exists/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Check if collection exists

# exists

Check if a collection exists in Kuzzle.
Checks if a collection exists in Kuzzle.

<br/>

Expand Down
1 change: 1 addition & 0 deletions doc/7/controllers/collection/get-mapping/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Additional query options
| Property | Type<br/>(default) | Description |
| ---------- | ------------------------------- | ---------------------------------------------------------------------------- |
| `queuable` | <pre>boolean</pre><br/>(`true`) | If true, queues the request during downtime, until connected to Kuzzle again |
| `includeKuzzleMeta` | <pre>boolean</pre><br/>(`true`) | If true, the returned mappings will contain [Kuzzle metadata](/core/2/guides/essentials/document-metadata/) |

## Resolves

Expand Down
2 changes: 1 addition & 1 deletion doc/7/controllers/collection/refresh/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Forces an Elasticsearch search index update

# refresh

When writing or deleting documents in Kuzzle, the update needs to be indexed before being available in search results.
Refreshes a collection to reindex the written and deleted documents so they are available in search results.

:::info
A refresh operation comes with some performance costs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Update the validation specifications

# updateSpecifications

The updateSpecifications method allows you to create or update the validation specifications for a collection.
Creates or updates the validation specifications for a collection.

When the validation specification is not formatted correctly, a detailed error message is returned to help you to debug.

Expand Down
61 changes: 51 additions & 10 deletions doc/7/controllers/collection/update/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,66 @@ You can define the collection [dynamic mapping policy](/core/2/guides/essentials

You can define [collection additional metadata](/core/2/guides/essentials/database-mappings#collection-metadata) within the `_meta` root field.

<SinceBadge version="Kuzzle 2.2.0" />
<SinceBadge version="7.4.0" />

You can also provide Elasticsearch [index settings](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/index-modules.html#index-modules-settings) when creating a new collection.

<br/>

```js
update(index, collection, mapping);
update(index, collection, definition);
```

<br/>

| Arguments | Type | Description |
| ------------ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `index` | <pre>string</pre> | Index name |
| `collection` | <pre>string</pre> | Collection name |
| `mapping` | <pre>object</pre> | Describes the collection mapping |
| Arguments | Type | Description |
|--------------|-------------------|-------------------------------------------------------------|
| `index` | <pre>string</pre> | Index name |
| `collection` | <pre>string</pre> | Collection name |
| `definition` | <pre>object</pre> | Describes the collection mappings and the ES index settings |
| `options` | <pre>object</pre> | Query options |

<SinceBadge version="7.4.0">

### mapping
### definition

An object representing the collection data mapping.
An object containing:
- [collection mappings](/core/2/guides/essentials/database-mappings).
- Elasticsearch [index settings](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/index-modules.html#index-modules-settings)

This object must have a root field `properties` that contain the mapping definition:

```js
const mapping = {
const definition = {
mappings: {
properties: {
field1: { type: 'text' },
field2: {
properties: {
nestedField: { type: 'keyword' }
}
}
}
},
settings: {
// index settings (e.g. analyzers)
}
};
```

</SinceBadge>


<DeprecatedBadge version="7.4.0">

### definition

An object representing the data mappings of the collection.

The mappings must have a root field `properties` that contain the mappings properties definition:

```js
const mappings = {
properties: {
field1: { type: 'text' },
field2: {
Expand All @@ -48,6 +86,9 @@ const mapping = {

More informations about database mappings [here](/core/2/guides/essentials/database-mappings).

</DeprecatedBadge>


## Resolves

Resolve if the collection is successfully updated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Validate specifications format

# validateSpecifications

The validateSpecifications method checks if a validation specification is well formatted. It does not store or modify the existing specification.
Checks if a validation specification is well formatted. It does not store nor modify the existing specification.

When the validation specification is not formatted correctly, a detailed error message is returned to help you to debug.

Expand Down
2 changes: 1 addition & 1 deletion doc/7/controllers/realtime/count/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Additional query options

## Resolves

Resolves to a number represensting active connections using the same provided subscription room.
Resolves to a number representing active connections using the same provided subscription room.

## Usage

Expand Down
2 changes: 1 addition & 1 deletion doc/7/controllers/security/create-api-key/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The API key content has the following properties:
| Name | Type | Description |
| --------- | ----------------- | ---------------- |
| `userId` | <pre>string</pre> | User kuid |
| `expiresAt` | <pre>number</pre> | Aexpiration date in UNIX micro-timestamp format (`-1` if the token never expires) |
| `expiresAt` | <pre>number</pre> | Aexpiration date in Epoch-millis format (`-1` if the token never expires) |
| `ttl` | <pre>number</pre> | Original TTL |
| `description` | <pre>string</pre> | API key description |
| `token` | <pre>string</pre> | Authentication token associated with this API key |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ hooks:
}' kuzzle:7512/profiles/profile${i}/_create
done
template: default
expected: '^\[ ''profile\d'', ''profile\d'', ''profile\d'', ''profile\d', ''profile\d'' \]$'
expected: '^\[ ''profile\d'', ''profile\d'', ''profile\d'', ''profile\d'', ''profile\d'' \]$'
Loading