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
5 changes: 1 addition & 4 deletions .ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,4 @@ services:
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- node.name=alyx
- cluster.name=kuzzle
- discovery.type=single-node

volumes:
snippets:
- discovery.type=single-node
15 changes: 8 additions & 7 deletions test-docs.sh → .ci/test-docs.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
#!/bin/bash

set -e

here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$here"

docker-compose -f .ci/doc/docker-compose.yml pull
docker-compose -f .ci/doc/docker-compose.yml run doc-tests node index
docker-compose -f ./doc/docker-compose.yml pull
docker-compose -f ./doc/docker-compose.yml run doc-tests node index
EXIT=$?
docker-compose -f .ci/doc/docker-compose.yml down
docker-compose -f ./doc/docker-compose.yml down

docker-compose -f .ci/doc/docker-compose.yml up -d kuzzle
docker-compose -f ./doc/docker-compose.yml up -d kuzzle

until $(curl --output /dev/null --silent --head --fail http://localhost:7512); do
printf '.'
sleep 5
done

cd ${here}/doc/7/getting-started/.react
cd ${here}/../doc/7/getting-started/.react
yarn install
SKIP_PREFLIGHT_CHECK=true yarn start &
npm run test

cd ${here}/doc/7/getting-started/.vuejs
cd ${here}/../doc/7/getting-started/.vuejs
npm ci
npm run serve-standalone &
npm run test

cd ${here}
docker-compose -f .ci/doc/docker-compose.yml down
docker-compose -f ./doc/docker-compose.yml down

exit $EXIT
4 changes: 2 additions & 2 deletions doc/7/getting-started/.react/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Cypress.Commands.add('createMessage', (body) => {
cy.wait(500);
return cy
.request({
url: `http://${kuzzle.host}:${kuzzle.port}/${kuzzle.index}/_refresh`,
url: `http://${kuzzle.host}:${kuzzle.port}/${kuzzle.index}/${kuzzle.collection}/_refresh`,
method: 'POST',
});
})
Expand Down Expand Up @@ -115,7 +115,7 @@ Cypress.Commands.add('loadEnvironment', (env) => {
cy.log(`mCreate status : ${response.status}`);
cy.wait(500);
return cy.request({
url: `http://${kuzzle.host}:${kuzzle.port}/${kuzzle.index}/_refresh`,
url: `http://${kuzzle.host}:${kuzzle.port}/${kuzzle.index}/${kuzzle.collection}/_refresh`,
method: 'POST',
});
})
Expand Down
2 changes: 1 addition & 1 deletion doc/7/getting-started/.vuejs/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Cypress.Commands.add('loadEnvironment', (env) => {
cy.wait(500);
return cy
.request({
url: `http://${kuzzle.host}:${kuzzle.port}/${kuzzle.index}/_refresh`,
url: `http://${kuzzle.host}:${kuzzle.port}/${kuzzle.index}/${kuzzle.collection}/_refresh`,
method: 'POST',
})
})
Expand Down
1 change: 1 addition & 0 deletions features/steps/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ Then(/^the document should (not )?exist$/, function (not) {

Then('the documents should be retrieved', function () {
should(this.content.successes.length).eql(this.ids.length);
should(this.content.errors).be.empty();

const found = this.content.successes.map(r => r._id);

Expand Down
6 changes: 1 addition & 5 deletions features/support/hooks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Before, AfterAll, BeforeAll } = require('cucumber');
const { Before, BeforeAll } = require('cucumber');

let _world;

Expand All @@ -19,10 +19,6 @@ BeforeAll(function () {
this.notifications = [];
});

AfterAll(function () {
// return clean();
});

function clean () {
const kuzzle = _world.kuzzle;

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"prepublish": "npm run build",
"test": "npm run --silent lint && npm run unit-testing && npm run functional-testing",
"unit-testing": "nyc --reporter=text-summary --reporter=lcov mocha",
"doc": "docker-compose -f doc/docker-compose.yml up",
"doc-testing": "bash test-docs.sh",
"functional-testing": "cucumber-js --exit --fail-fast",
"lint": "eslint --max-warnings=0 ./src ./test ./features",
"build": "node build.js",
"doc": "docker-compose -f doc/docker-compose.yml up",
"doc-testing": "bash .ci/test-docs.sh",
"doc-prepare": "cd doc && bash doc.sh prepare",
"doc-dev": "cd doc && bash doc.sh dev",
"doc-build": "cd doc && bash doc.sh build",
Expand Down
4 changes: 2 additions & 2 deletions src/Kuzzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ class Kuzzle extends KuzzleEventEmitter {
request.volatile[item] = this.volatile[item];
}
}
request.volatile.sdkInstanceId = this.protocol.id;
request.volatile.sdkName = this.sdkName;
request.volatile.sdkInstanceId = request.volatile.sdkInstanceId || this.protocol.id;
request.volatile.sdkName = request.volatile.sdkName || this.sdkName;

this.auth.authenticateRequest(request);

Expand Down
2 changes: 2 additions & 0 deletions src/KuzzleError.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class KuzzleError extends Error {

this.status = apiError.status;
this.stack = apiError.stack;
this.id = apiError.id;
this.code = apiError.code;

// PartialError
if (this.status === 206) {
Expand Down
10 changes: 3 additions & 7 deletions src/controllers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class AuthController extends BaseController {
/**
* Do not add the token for the checkToken route, to avoid getting a token error when
* a developer simply wish to verify his token
*
* @param {object} request
*
* @param {object} request
*/
authenticateRequest (request) {
if (!this.authenticationToken
if ( !this.authenticationToken
|| (request.controller === 'auth'
&& (request.action === 'checkToken' || request.action === 'login'))
) {
Expand Down Expand Up @@ -178,10 +178,6 @@ class AuthController extends BaseController {
* @returns {Promise|*|PromiseLike<T>|Promise<T>}
*/
login (strategy, credentials = {}, expiresIn = null) {
if (typeof strategy !== 'string' || strategy === '') {
throw new Error('Kuzzle.auth.login: strategy is required');
}

const request = {
strategy,
expiresIn,
Expand Down
87 changes: 4 additions & 83 deletions src/controllers/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,17 @@ class CollectionController extends BaseController {
super(kuzzle, 'collection');
}

create (index, collection, body = {}, options = {}) {
if (!index) {
throw new Error('Kuzzle.collection.create: index is required');
}
if (!collection) {
throw new Error('Kuzzle.collection.create: collection is required');
}

create (index, collection, mappings = {}, options = {}) {
return this.query({
index,
collection,
body,
body: mappings,
action: 'create'
}, options)
.then(response => response.result);
}

deleteSpecifications (index, collection, options = {}) {
if (!index) {
throw new Error('Kuzzle.collection.deleteSpecifications: index is required');
}
if (!collection) {
throw new Error('Kuzzle.collection.deleteSpecifications: collection is required');
}

return this.query({
index,
collection,
Expand All @@ -45,13 +31,6 @@ class CollectionController extends BaseController {
}

exists (index, collection, options = {}) {
if (!index) {
throw new Error('Kuzzle.collection.exists: index is required');
}
if (!collection) {
throw new Error('Kuzzle.collection.exists: collection is required');
}

return this.query({
index,
collection,
Expand All @@ -61,14 +40,6 @@ class CollectionController extends BaseController {
}

refresh (index, collection, options = {}) {
if (!index) {
throw new Error('Kuzzle.collection.refresh: index is required');
}

if (!collection) {
throw new Error('Kuzzle.collection.refresh: collection is required');
}

return this.query({
index,
collection,
Expand All @@ -78,13 +49,6 @@ class CollectionController extends BaseController {
}

getMapping (index, collection, options = {}) {
if (!index) {
throw new Error('Kuzzle.collection.getMapping: index is required');
}
if (!collection) {
throw new Error('Kuzzle.collection.getMapping: collection is required');
}

return this.query({
index,
collection,
Expand All @@ -94,13 +58,6 @@ class CollectionController extends BaseController {
}

getSpecifications (index, collection, options = {}) {
if (!index) {
throw new Error('Kuzzle.collection.getSpecifications: index is required');
}
if (!collection) {
throw new Error('Kuzzle.collection.getSpecifications: collection is required');
}

return this.query({
index,
collection,
Expand All @@ -110,10 +67,6 @@ class CollectionController extends BaseController {
}

list (index, options = {}) {
if (!index) {
throw new Error('Kuzzle.collection.list: index is required');
}

const request = {
index,
action: 'list',
Expand All @@ -132,8 +85,10 @@ class CollectionController extends BaseController {
body,
action: 'searchSpecifications'
};

for (const opt of ['from', 'size', 'scroll']) {
request[opt] = options[opt];

delete options[opt];
}

Expand All @@ -142,13 +97,6 @@ class CollectionController extends BaseController {
}

truncate (index, collection, options = {}) {
if (!index) {
throw new Error('Kuzzle.collection.truncate: index is required');
}
if (!collection) {
throw new Error('Kuzzle.collection.truncate: collection is required');
}

return this.query({
index,
collection,
Expand All @@ -159,13 +107,6 @@ class CollectionController extends BaseController {
}

updateMapping (index, collection, body, options = {}) {
if (!index) {
throw new Error('Kuzzle.collection.updateMapping: index is required');
}
if (!collection) {
throw new Error('Kuzzle.collection.updateMapping: collection is required');
}

return this.query({
index,
collection,
Expand All @@ -176,16 +117,6 @@ class CollectionController extends BaseController {
}

updateSpecifications (index, collection, specifications, options = {}) {
if (!index) {
throw new Error('Kuzzle.collection.updateSpecifications: index is required');
}
if (!collection) {
throw new Error('Kuzzle.collection.updateSpecifications: collection is required');
}
if (!specifications) {
throw new Error('Kuzzle.collection.updateSpecifications: specifications are required');
}

return this.query({
index,
collection,
Expand All @@ -196,16 +127,6 @@ class CollectionController extends BaseController {
}

validateSpecifications (index, collection, specifications, options = {}) {
if (!index) {
throw new Error('Kuzzle.collection.validateSpecifications: index is required');
}
if (!collection) {
throw new Error('Kuzzle.collection.validateSpecifications: collection is required');
}
if (!specifications) {
throw new Error('Kuzzle.collection.updateSpecifications: specifications are required');
}

return this.query({
index,
collection,
Expand Down
Loading