diff --git a/.github/actions/unit-tests/action.yml b/.github/actions/unit-tests/action.yml
index b7105332f..02ac242d7 100644
--- a/.github/actions/unit-tests/action.yml
+++ b/.github/actions/unit-tests/action.yml
@@ -11,5 +11,4 @@ runs:
- name: Run tests
run: |
npm run test:unit
- cat ./coverage/lcov.info | ./node_modules/.bin/codecov
shell: bash
diff --git a/README.md b/README.md
index 70d2a24a2..c9788b764 100644
--- a/README.md
+++ b/README.md
@@ -5,9 +5,6 @@
-
-
-
@@ -24,8 +21,8 @@ This is the official Javascript SDK for the free and open-source backend Kuzzle.
#### Multiprotocols
-Currently, the SDK provides 2 protocols: __Http and WebSocket.__
-WebSocket protocol implement the whole Kuzzle API, while the HTTP protocol does not implement realtime features (rooms and subscriptions).
+Currently, the SDK provides 2 protocols: **Http and WebSocket.**
+WebSocket protocol implement the whole Kuzzle API, while the HTTP protocol does not implement realtime features (rooms and subscriptions).
#### Promises based
@@ -42,11 +39,10 @@ Any error must be caught either at the end of the `Promise` chain, or by using `
Kuzzle is an open-source backend that includes a scalable server, a multiprotocol API,
an administration console and a set of plugins that provide advanced functionalities like real-time pub/sub, blazing fast search and geofencing.
-* :octocat: __[Github](https://github.com/kuzzleio/kuzzle)__
-* :earth_africa: __[Website](https://kuzzle.io)__
-* :books: __[Documentation](https://docs.kuzzle.io)__
-* :email: __[Discord](http://join.discord.kuzzle.io)__
-
+- :octocat: **[Github](https://github.com/kuzzleio/kuzzle)**
+- :earth_africa: **[Website](https://kuzzle.io)**
+- :books: **[Documentation](https://docs.kuzzle.io)**
+- :email: **[Discord](http://join.discord.kuzzle.io)**
## Get trained by the creators of Kuzzle :zap:
@@ -59,24 +55,24 @@ Our teams will be able to meet your needs in terms of expertise and multi-techno
## Compatibility matrix
| Kuzzle Version | SDK Version |
-|----------------|-------------|
+| -------------- | ----------- |
| 1.x.x | 5.x.x |
| 1.x.x | 6.x.x |
| 2.x.x | 7.x.x |
## Getting started :point_right:
- - [Node.js](https://docs.kuzzle.io/sdk/js/7/getting-started/node-js/)
- - [Browser](https://docs.kuzzle.io/sdk/js/7/getting-started/raw-web/)
- - [Webpack](https://docs.kuzzle.io/sdk/js/7/getting-started/webpack/)
- - [React/Redux](https://docs.kuzzle.io/sdk/js/7/getting-started/react/with-redux/)
- - [Vue.js](https://docs.kuzzle.io/sdk/js/7/getting-started/vuejs/standalone/)
+- [Node.js](https://docs.kuzzle.io/sdk/js/7/getting-started/node-js/)
+- [Browser](https://docs.kuzzle.io/sdk/js/7/getting-started/raw-web/)
+- [Webpack](https://docs.kuzzle.io/sdk/js/7/getting-started/webpack/)
+- [React/Redux](https://docs.kuzzle.io/sdk/js/7/getting-started/react/with-redux/)
+- [Vue.js](https://docs.kuzzle.io/sdk/js/7/getting-started/vuejs/standalone/)
### Installation
This SDK can be used either in NodeJS or in a browser.
-#### Node.js
+#### Node.js
```
npm install kuzzle-sdk
@@ -84,11 +80,13 @@ npm install kuzzle-sdk
#### Browser
-To run the SDK in the browser, you have to build it yourself by cloning this repository and running
+To run the SDK in the browser, you have to build it yourself by cloning this repository and running
+
```bash
$ npm install
$ npm run build
-````
+```
+
A `dist` directory will be created, containing a browser version of this SDK.
```html
@@ -98,18 +96,19 @@ A `dist` directory will be created, containing a browser version of this SDK.
or use the CDN:
```html
-
+
```
Then the Kuzzle SDK will be available under the `KuzzleSDK` variable:
```html
-
+
```
#### Browser with Webpack
@@ -124,21 +123,19 @@ But you'll still need to pick the built version (which ships with the package).
```javascript
// with the classic require...
-const { Kuzzle } = require('kuzzle-sdk')
+const { Kuzzle } = require("kuzzle-sdk");
// ... or with the new import directive.
-import { Kuzzle } from 'kuzzle-sdk'
+import { Kuzzle } from "kuzzle-sdk";
```
### Example
-The SDK supports different protocols. When instantiating,
-you must choose the protocol to use and fill in the different options needed to connect to Kuzzle.
+The SDK supports different protocols. When instantiating,
+you must choose the protocol to use and fill in the different options needed to connect to Kuzzle.
```js
-const { Kuzzle, WebSocket } = require('kuzzle-sdk');
-const kuzzle = new Kuzzle(
- new WebSocket('localhost', { port: 7512 })
-);
+const { Kuzzle, WebSocket } = require("kuzzle-sdk");
+const kuzzle = new Kuzzle(new WebSocket("localhost", { port: 7512 }));
try {
await kuzzle.connect();
diff --git a/doc/7/controllers/collection/update/index.md b/doc/7/controllers/collection/update/index.md
index d32c1f177..5057fd819 100644
--- a/doc/7/controllers/collection/update/index.md
+++ b/doc/7/controllers/collection/update/index.md
@@ -27,7 +27,7 @@ update(index, collection, definition);
| Arguments | Type | Description |
-|--------------|-------------------|-------------------------------------------------------------|
+| ------------ | ----------------- | ----------------------------------------------------------- |
| `index` |
string
| Index name |
| `collection` | string
| Collection name |
| `definition` | object
| Describes the collection mappings and the ES index settings |
@@ -37,39 +37,41 @@ update(index, collection, definition);
Additional query options
-| Options | Type
(default) | Description |
-| ---------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
-| `queuable` | boolean
(`true`) | If true, queues the request during downtime, until connected to Kuzzle again |
-| `refresh` | string
(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) |
-| [`timeout`](/sdk/7/core-classes/kuzzle/query#timeout) | number
| Time (in ms) during which a request will still be waited to be resolved. Set it `-1` if you want to wait indefinitely |
-
+| Options | Type
(default) | Description |
+| ----------------------------------------------------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
+| `queuable` | boolean
(`true`) | If true, queues the request during downtime, until connected to Kuzzle again |
+| `refresh` | string
(`""`) | If set to `wait_for`, waits for the change to be reflected for `search` (up to 1s) |
+| [`timeout`](/sdk/7/core-classes/kuzzle/query#timeout) | number
| Time (in ms) during which a request will still be waited to be resolved. Set it `-1` if you want to wait indefinitely |
### definition
An object containing:
- - [collection mappings](/core/2/guides/main-concepts/data-storage).
- - Elasticsearch [index settings](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/index-modules.html#index-modules-settings)
+- [collection mappings](/core/2/guides/main-concepts/data-storage).
+- Elasticsearch [index settings](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/index-modules.html#index-modules-settings)
+- `reindexCollection` (optional): if set to `true`, Kuzzle will reindex the collection after updating the mappings. This is useful when you want to update the mappings of a collection that already contains data.
```js
const definition = {
mappings: {
properties: {
- field1: { type: 'text' },
+ field1: { type: "text" },
field2: {
properties: {
- nestedField: { type: 'keyword' }
- }
- }
- }
+ nestedField: { type: "keyword" },
+ },
+ },
+ },
},
+ reindexCollection: true,
settings: {
// index settings (e.g. analyzers)
- }
+ },
};
```
+
@@ -83,13 +85,13 @@ The mappings must have a root field `properties` that contain the mappings prope
```js
const mappings = {
properties: {
- field1: { type: 'text' },
+ field1: { type: "text" },
field2: {
properties: {
- nestedField: { type: 'keyword' }
- }
- }
- }
+ nestedField: { type: "keyword" },
+ },
+ },
+ },
};
```
diff --git a/package-lock.json b/package-lock.json
index 3e720d633..c04905d1a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -24,7 +24,6 @@
"@types/node": "^18.15.11",
"babel-loader": "^8.3.0",
"buffer": "^6.0.3",
- "codecov": "^3.8.3",
"cucumber": "^6.0.5",
"cz-conventional-changelog": "^3.3.0",
"eslint-plugin-kuzzle": "^0.0.6",
@@ -3586,15 +3585,6 @@
"integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==",
"dev": true
},
- "node_modules/@tootallnate/once": {
- "version": "1.1.2",
- "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz",
- "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==",
- "dev": true,
- "engines": {
- "node": ">= 6"
- }
- },
"node_modules/@ts-morph/common": {
"version": "0.16.0",
"resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.16.0.tgz",
@@ -4243,18 +4233,6 @@
"node": ">=0.4.0"
}
},
- "node_modules/agent-base": {
- "version": "6.0.2",
- "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
- "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
- "dev": true,
- "dependencies": {
- "debug": "4"
- },
- "engines": {
- "node": ">= 6.0.0"
- }
- },
"node_modules/aggregate-error": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz",
@@ -4409,16 +4387,6 @@
"sprintf-js": "~1.0.2"
}
},
- "node_modules/argv": {
- "version": "0.0.2",
- "resolved": "https://registry.npmjs.org/argv/-/argv-0.0.2.tgz",
- "integrity": "sha512-dEamhpPEwRUBpLNHeuCm/v+g0anFByHahxodVO/BbAarHVBBg2MccCwf9K+o1Pof+2btdnkJelYVUWjW/VrATw==",
- "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.",
- "dev": true,
- "engines": {
- "node": ">=0.6.10"
- }
- },
"node_modules/argv-formatter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/argv-formatter/-/argv-formatter-1.0.0.tgz",
@@ -5075,26 +5043,6 @@
"integrity": "sha512-NiujjUFB4SwScJq2bwbYUtXbZhBSlY6vYzm++3Q6oC+U+injTqfPYFK8wS9COOmb2lueqp0ZRB4nK1VYeHgNyw==",
"dev": true
},
- "node_modules/codecov": {
- "version": "3.8.3",
- "resolved": "https://registry.npmjs.org/codecov/-/codecov-3.8.3.tgz",
- "integrity": "sha512-Y8Hw+V3HgR7V71xWH2vQ9lyS358CbGCldWlJFR0JirqoGtOoas3R3/OclRTvgUYFK29mmJICDPauVKmpqbwhOA==",
- "deprecated": "https://about.codecov.io/blog/codecov-uploader-deprecation-plan/",
- "dev": true,
- "dependencies": {
- "argv": "0.0.2",
- "ignore-walk": "3.0.4",
- "js-yaml": "3.14.1",
- "teeny-request": "7.1.1",
- "urlgrey": "1.0.0"
- },
- "bin": {
- "codecov": "bin/codecov"
- },
- "engines": {
- "node": ">=4.0"
- }
- },
"node_modules/color-convert": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
@@ -6623,21 +6571,6 @@
"integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==",
"dev": true
},
- "node_modules/fast-url-parser": {
- "version": "1.1.3",
- "resolved": "https://registry.npmjs.org/fast-url-parser/-/fast-url-parser-1.1.3.tgz",
- "integrity": "sha512-5jOCVXADYNuRkKFzNJ0dCCewsZiYo0dz8QNYljkOpFC6r2U4OBmKtvm/Tsuh4w1YYdDqDb31a8TVhBJ2OJKdqQ==",
- "dev": true,
- "dependencies": {
- "punycode": "^1.3.2"
- }
- },
- "node_modules/fast-url-parser/node_modules/punycode": {
- "version": "1.4.1",
- "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
- "integrity": "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==",
- "dev": true
- },
"node_modules/fastest-levenshtein": {
"version": "1.0.16",
"resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz",
@@ -7311,39 +7244,12 @@
"integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==",
"dev": true
},
- "node_modules/http-proxy-agent": {
- "version": "4.0.1",
- "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz",
- "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==",
- "dev": true,
- "dependencies": {
- "@tootallnate/once": "1",
- "agent-base": "6",
- "debug": "4"
- },
- "engines": {
- "node": ">= 6"
- }
- },
"node_modules/https-browserify": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz",
"integrity": "sha512-J+FkSdyD+0mA0N+81tMotaRMfSL9SGi+xpD3T6YApKsc3bGSXJlfXri3VyFOeYkfLRQisDk1W+jIFFKBeUBbBg==",
"dev": true
},
- "node_modules/https-proxy-agent": {
- "version": "5.0.1",
- "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz",
- "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==",
- "dev": true,
- "dependencies": {
- "agent-base": "6",
- "debug": "4"
- },
- "engines": {
- "node": ">= 6"
- }
- },
"node_modules/human-signals": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz",
@@ -7395,15 +7301,6 @@
"node": ">= 4"
}
},
- "node_modules/ignore-walk": {
- "version": "3.0.4",
- "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.4.tgz",
- "integrity": "sha512-PY6Ii8o1jMRA1z4F2hRkH/xN59ox43DavKvD3oDpfurRlOJyAHpifIwpbdv1n4jt4ov0jSpw3kQ4GhJnpBL6WQ==",
- "dev": true,
- "dependencies": {
- "minimatch": "^3.0.4"
- }
- },
"node_modules/import-fresh": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz",
@@ -16106,15 +16003,6 @@
"safe-buffer": "~5.1.0"
}
},
- "node_modules/stream-events": {
- "version": "1.0.5",
- "resolved": "https://registry.npmjs.org/stream-events/-/stream-events-1.0.5.tgz",
- "integrity": "sha512-E1GUzBSgvct8Jsb3v2X15pjzN1tYebtbLaMg+eBOUOAxgbLoSbT2NS91ckc5lJD1KfLjId+jXJRgo0qnV5Nerg==",
- "dev": true,
- "dependencies": {
- "stubs": "^3.0.0"
- }
- },
"node_modules/stream-http": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/stream-http/-/stream-http-3.2.0.tgz",
@@ -16237,12 +16125,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/stubs": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/stubs/-/stubs-3.0.0.tgz",
- "integrity": "sha512-PdHt7hHUJKxvTCgbKX9C1V/ftOcjJQgz8BZwNfV5c4B6dcGqlpelTbJ999jBGZ2jYiPAwcX5dP6oBwVlBlUbxw==",
- "dev": true
- },
"node_modules/supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
@@ -16374,22 +16256,6 @@
"node": ">=6"
}
},
- "node_modules/teeny-request": {
- "version": "7.1.1",
- "resolved": "https://registry.npmjs.org/teeny-request/-/teeny-request-7.1.1.tgz",
- "integrity": "sha512-iwY6rkW5DDGq8hE2YgNQlKbptYpY5Nn2xecjQiNjOXWbKzPGUfmeUBCSQbbr306d7Z7U2N0TPl+/SwYRfua1Dg==",
- "dev": true,
- "dependencies": {
- "http-proxy-agent": "^4.0.0",
- "https-proxy-agent": "^5.0.0",
- "node-fetch": "^2.6.1",
- "stream-events": "^1.0.5",
- "uuid": "^8.0.0"
- },
- "engines": {
- "node": ">=10"
- }
- },
"node_modules/temp-dir": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/temp-dir/-/temp-dir-3.0.0.tgz",
@@ -17085,15 +16951,6 @@
"integrity": "sha512-RofWgt/7fL5wP1Y7fxE7/EmTLzQVnB0ycyibJ0OOHIlJqTNzglYFxVwETOcIoJqJmpDXJ9xImDv+Fq34F/d4Dw==",
"dev": true
},
- "node_modules/urlgrey": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/urlgrey/-/urlgrey-1.0.0.tgz",
- "integrity": "sha512-hJfIzMPJmI9IlLkby8QrsCykQ+SXDeO2W5Q9QTW3QpqZVTx4a/K7p8/5q+/isD8vsbVaFgql/gvAoQCRQ2Cb5w==",
- "dev": true,
- "dependencies": {
- "fast-url-parser": "^1.1.3"
- }
- },
"node_modules/util-arity": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/util-arity/-/util-arity-1.1.0.tgz",
diff --git a/package.json b/package.json
index e86bb651d..1ccdb275f 100644
--- a/package.json
+++ b/package.json
@@ -41,21 +41,18 @@
"ws": "^8.13.0"
},
"devDependencies": {
+ "@babel/core": "^7.21.4",
+ "@babel/preset-env": "^7.21.4",
"@commitlint/cli": "^17.6.7",
"@commitlint/config-conventional": "^17.6.7",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^10.0.1",
"@semantic-release/git": "^10.0.1",
"@semantic-release/release-notes-generator": "^11.0.4",
- "@babel/core": "^7.21.4",
- "@babel/preset-env": "^7.21.4",
"@types/node": "^18.15.11",
"babel-loader": "^8.3.0",
"buffer": "^6.0.3",
- "codecov": "^3.8.3",
"cucumber": "^6.0.5",
- "semantic-release-config-kuzzle": "^1.0.0",
- "semantic-release-slack-bot": "^4.0.2",
"cz-conventional-changelog": "^3.3.0",
"eslint-plugin-kuzzle": "^0.0.6",
"https-browserify": "^1.0.0",
@@ -67,6 +64,8 @@
"proxyquire": "^2.1.3",
"retry": "^0.13.1",
"rewire": "^6.0.0",
+ "semantic-release-config-kuzzle": "^1.0.0",
+ "semantic-release-slack-bot": "^4.0.2",
"should": "13.2.3",
"should-sinon": "0.0.6",
"sinon": "^14.0.2",
diff --git a/src/controllers/Collection.ts b/src/controllers/Collection.ts
index 93bcf83b4..31d5e6137 100644
--- a/src/controllers/Collection.ts
+++ b/src/controllers/Collection.ts
@@ -1,6 +1,6 @@
-import { BaseController } from "./Base";
import { SpecificationsSearchResult } from "../core/searchResult/Specifications";
-import { CollectionMappings, JSONObject, ArgsDefault } from "../types";
+import { ArgsDefault, CollectionMappings, JSONObject } from "../types";
+import { BaseController } from "./Base";
export class CollectionController extends BaseController {
constructor(kuzzle) {
@@ -310,6 +310,10 @@ export class CollectionController extends BaseController {
* Mappings definition
*/
mappings?: CollectionMappings;
+ /**
+ * If true, reindex the collection
+ */
+ reindexCollection?: boolean;
/**
* Elasticsearch index settings
*/