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
6 changes: 2 additions & 4 deletions .ci/doc/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ runners:
lint:
global: true
cmd: eslint -c /mnt/.ci/doc/eslint.json {{ snippet.dir }}
before: timeout -t 600 ash -c 'until stat /tmp/runner_ready_to_lint; do sleep 1; done'
before: timeout 600 ash -c 'until stat /tmp/runner_ready_to_lint; do sleep 1; done'
run:
cmd: node {{ snippet.source }}
before: timeout -t 600 ash -c 'until stat /tmp/runner_is_ready && curl -f -s -o /dev/null http://kuzzle:7512/_now; do sleep 1; done'
before: timeout 600 ash -c 'until stat /tmp/runner_is_ready && curl -f -s -o /dev/null http://kuzzle:7512/_now; do sleep 1; done'

web:
service: doc-runner-web
Expand All @@ -43,5 +43,3 @@ runners:
run:
cmd: node puppeteer.js /tmp/{{ snippet.name }}/index.html
before: timeout 600 bash -c 'until curl -f -s -o /dev/null http://kuzzle:7512/_now; do sleep 1; done'


6 changes: 2 additions & 4 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ coverage:
default:
threshold: 1

patch:
default:
branches:
- master
patch: false
changes: false
1,376 changes: 1,076 additions & 300 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kuzzle-sdk",
"version": "7.0.0-beta.2",
"version": "7.0.0",
"description": "Official Javascript SDK for Kuzzle",
"author": "The Kuzzle Team <support@kuzzle.io>",
"repository": {
Expand Down Expand Up @@ -54,6 +54,7 @@
"eslint": "^5.16.0",
"eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.2.1",
"lolex": "^5.1.1",
"mocha": "6.2.0",
"mock-require": "^3.0.3",
"nyc": "^14.1.1",
Expand Down
10 changes: 6 additions & 4 deletions src/Kuzzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,14 +406,16 @@ class Kuzzle extends KuzzleEventEmitter {
request.requestId = uuidv4();
}

// we follow the api but allow some more logical "mistakes" (the only allowed value for refresh arg is "wait_for")
if (request.refresh) {
// we follow the api but allow some more logical "mistakes"
// (the only allowed value for refresh arg is "wait_for")
if (request.refresh || options.refresh) {
request.refresh = 'wait_for';
}

if (!request.volatile) {
if (! request.volatile) {
request.volatile = this.volatile;
} else if (
}
else if (
typeof request.volatile !== 'object'
|| Array.isArray(request.volatile)
) {
Expand Down
18 changes: 10 additions & 8 deletions src/controllers/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,23 @@ class CollectionController extends BaseController {
}

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

deleteSpecifications (index, collection, options = {}) {
return this.query({
const request = {
index,
collection,
action: 'deleteSpecifications'
}, options)
};
return this.query(request, options)
.then(response => response.result);
}

Expand Down Expand Up @@ -97,12 +99,12 @@ class CollectionController extends BaseController {
}

truncate (index, collection, options = {}) {
return this.query({
const request = {
index,
collection,
action: 'truncate',
refresh: options.refresh
}, options)
action: 'truncate'
};
return this.query(request, options)
.then(response => response.result);
}

Expand Down
57 changes: 14 additions & 43 deletions src/controllers/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ class DocumentController extends BaseController {
index,
collection,
body,
action: 'count',
includeTrash: options.includeTrash
action: 'count'
};
delete options.includeTrash;

return this.query(request, options)
.then(response => response.result.count);
Expand All @@ -31,11 +29,8 @@ class DocumentController extends BaseController {
collection,
_id,
body: document,
action: 'create',
refresh: options.refresh
action: 'create'
};
delete options.refresh;

return this.query(request, options)
.then(response => response.result);
}
Expand All @@ -46,10 +41,8 @@ class DocumentController extends BaseController {
collection,
_id,
body,
action: 'createOrReplace',
refresh: options.refresh
action: 'createOrReplace'
};
delete options.refresh;

return this.query(request, options)
.then(response => response.result);
Expand All @@ -60,10 +53,8 @@ class DocumentController extends BaseController {
index,
collection,
_id,
action: 'delete',
refresh: options.refresh
action: 'delete'
};
delete options.refresh;

return this.query(request, options)
.then(response => response.result._id);
Expand All @@ -74,10 +65,8 @@ class DocumentController extends BaseController {
index,
collection,
body,
action: 'deleteByQuery',
refresh: options.refresh
action: 'deleteByQuery'
};
delete options.refresh;

return this.query(request, options)
.then(response => response.result.ids);
Expand All @@ -100,10 +89,8 @@ class DocumentController extends BaseController {
index,
collection,
_id,
action: 'get',
includeTrash: options.includeTrash
action: 'get'
};
delete options.includeTrash;

return this.query(request, options)
.then(response => response.result);
Expand All @@ -114,10 +101,8 @@ class DocumentController extends BaseController {
index,
collection,
body: {documents},
action: 'mCreate',
refresh: options.refresh
action: 'mCreate'
};
delete options.refresh;

return this.query(request, options)
.then(response => response.result);
Expand All @@ -128,10 +113,8 @@ class DocumentController extends BaseController {
index,
collection,
body: {documents},
action: 'mCreateOrReplace',
refresh: options.refresh
action: 'mCreateOrReplace'
};
delete options.refresh;

return this.query(request, options)
.then(response => response.result);
Expand All @@ -142,10 +125,8 @@ class DocumentController extends BaseController {
index,
collection,
body: {ids},
action: 'mDelete',
refresh: options.refresh
action: 'mDelete'
};
delete options.refresh;

return this.query(request, options)
.then(response => response.result);
Expand All @@ -156,10 +137,8 @@ class DocumentController extends BaseController {
index,
collection,
body: {ids},
action: 'mGet',
includeTrash: options.includeTrash
action: 'mGet'
};
delete options.includeTrash;

return this.query(request, options)
.then(response => response.result);
Expand All @@ -170,10 +149,8 @@ class DocumentController extends BaseController {
index,
collection,
body: {documents},
action: 'mReplace',
refresh: options.refresh
action: 'mReplace'
};
delete options.refresh;

return this.query(request, options)
.then(response => response.result);
Expand All @@ -184,10 +161,8 @@ class DocumentController extends BaseController {
index,
collection,
body: {documents},
action: 'mUpdate',
refresh: options.refresh
action: 'mUpdate'
};
delete options.refresh;

return this.query(request, options)
.then(response => response.result);
Expand All @@ -199,10 +174,8 @@ class DocumentController extends BaseController {
collection,
_id,
body,
action: 'replace',
refresh: options.refresh
action: 'replace'
};
delete options.refresh;

return this.query(request, options)
.then(response => response.result);
Expand All @@ -216,7 +189,7 @@ class DocumentController extends BaseController {
action: 'search',
};

for (const opt of ['from', 'size', 'scroll', 'includeTrash']) {
for (const opt of ['from', 'size', 'scroll']) {
request[opt] = options[opt];
delete options[opt];
}
Expand All @@ -237,10 +210,8 @@ class DocumentController extends BaseController {
_id,
body,
action: 'update',
refresh: options.refresh,
retryOnConflict: options.retryOnConflict
};
delete options.refresh;
delete options.retryOnConflict;

return this.query(request, options)
Expand Down
28 changes: 16 additions & 12 deletions src/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,25 @@ class IndexController extends BaseController {
super(kuzzle, 'index');
}

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

delete (index, options) {
return this.query({
delete (index, options = {}) {
const request = {
index,
action : 'delete'
}, options)
action: 'delete'
};
return this.query(request, options)
.then(response => response.result.acknowledged);
}

exists (index, options) {
exists (index, options = {}) {
return this.query({
index,
action : 'exists'
Expand All @@ -40,13 +42,15 @@ class IndexController extends BaseController {
.then(response => response.result.indexes);
}

mDelete (indexes, options) {
return this.query({
mDelete (indexes, options = {}) {
const request = {
action: 'mDelete',
body: {
indexes
}
}, options)
};

return this.query(request, options)
.then(response => response.result.deleted);
}
}
Expand Down
Loading