Skip to content

Commit 9ee6f71

Browse files
authored
Release 6.0.0-beta-4 (#351)
Bug fixes [ #349 ] [build] Update webpack build config to fix raw web usage (Njuelle) [ #345 ] Fix 343 unhandled rejection on connect (Aschen) Others [ #348 ] Put document:create optional args in last position (Aschen)
1 parent d14ae29 commit 9ee6f71

File tree

9 files changed

+30
-26
lines changed

9 files changed

+30
-26
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ For example, for the `create` action of the `document` controller ([document#cre
217217
```js
218218
const options = { refresh: 'wait_for' };
219219
const documentBody = { hello: 'world' };
220-
kuzzle.document.create('my-index', 'my-collection', 'my-uniq-id', documentBody, options)
220+
kuzzle.document.create('my-index', 'my-collection', documentBody, 'my-uniq-id', options)
221221
```
222222

223223
The parameters of each method differ according to the parameters expected in the API.

features/steps/document.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ Given(/^the collection doesn't have a document with id '(.*?)'$/, async function
1111
});
1212

1313
Given('the collection has a document with id {string}', async function (id) {
14-
this.content = await this.kuzzle.document.create(this.index, this.collection, id, {
15-
a: 'document'
16-
}, {
17-
refresh: 'wait_for'
18-
});
14+
this.content = await this.kuzzle.document.create(
15+
this.index,
16+
this.collection,
17+
{ a: 'document' },
18+
id,
19+
{ refresh: 'wait_for'}
20+
);
1921
});
2022

2123

@@ -31,8 +33,8 @@ When('I create a document in {string}', async function (collection) {
3133
this.content = await this.kuzzle.document.create(
3234
this.index,
3335
this.collection,
34-
'some-id',
3536
{a: 'document'},
37+
'some-id',
3638
{refresh: true}
3739
);
3840
});
@@ -44,8 +46,8 @@ When('I create a document with id {string}', async function (id) {
4446
this.content = await this.kuzzle.document.create(
4547
this.index,
4648
this.collection,
47-
id,
4849
{a: 'document'},
50+
id,
4951
{refresh: true}
5052
);
5153
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kuzzle-sdk",
3-
"version": "6.0.0-beta-3",
3+
"version": "6.0.0-beta-4",
44
"description": "Official Javascript SDK for Kuzzle",
55
"author": "The Kuzzle Team <[email protected]>",
66
"repository": {

src/controllers/document.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@ class DocumentController {
3838
.then(response => response.result.count);
3939
}
4040

41-
create (index, collection, _id, body, options = {}) {
41+
create (index, collection, document, _id = null, options = {}) {
4242
if (!index) {
4343
throw new Error('Kuzzle.document.create: index is required');
4444
}
4545
if (!collection) {
4646
throw new Error('Kuzzle.document.create: collection is required');
4747
}
48-
if (!body) {
49-
throw new Error('Kuzzle.document.create: body is required');
48+
if (!document) {
49+
throw new Error('Kuzzle.document.create: document is required');
5050
}
5151

5252
const request = {
5353
index,
5454
collection,
5555
_id,
56-
body,
56+
body: document,
5757
controller: 'document',
5858
action: 'create',
5959
refresh: options.refresh

src/protocols/abstract/realtime.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ class RTWrapper extends KuzzleAbstractProtocol {
6060
this.emit('networkError', connectionError);
6161
if (this.autoReconnect && !this.retrying && !this.stopRetryingToConnect) {
6262
this.retrying = true;
63+
6364
setTimeout(() => {
6465
this.retrying = false;
65-
this.connect(this.host);
66+
this.connect(this.host).catch(err => this.clientNetworkError(err));
6667
}, this.reconnectionDelay);
6768
} else {
6869
this.emit('disconnect');

test/controllers/document.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,20 @@ describe('Document Controller', () => {
7272
describe('create', () => {
7373
it('should throw an error if the "index" argument is not provided', () => {
7474
should(function () {
75-
kuzzle.document.create(undefined, 'collection', 'document-id', {foo: 'bar'}, options);
75+
kuzzle.document.create(undefined, 'collection', {foo: 'bar'}, 'document-id', options);
7676
}).throw('Kuzzle.document.create: index is required');
7777
});
7878

7979
it('should throw an error if the "collection" argument is not provided', () => {
8080
should(function () {
81-
kuzzle.document.create('index', undefined, 'document-id', {foo: 'bar'}, options);
81+
kuzzle.document.create('index', undefined, {foo: 'bar'}, 'document-id', options);
8282
}).throw('Kuzzle.document.create: collection is required');
8383
});
8484

85-
it('should throw an error if the "body" argument is not provided', () => {
85+
it('should throw an error if the "document" argument is not provided', () => {
8686
should(function () {
87-
kuzzle.document.create('index', 'collection', 'document-id', undefined, options);
88-
}).throw('Kuzzle.document.create: body is required');
87+
kuzzle.document.create('index', 'collection', undefined, 'document-id', options);
88+
}).throw('Kuzzle.document.create: document is required');
8989
});
9090

9191
it('should call document/create query and return a Promise which resolves the created document', () => {
@@ -96,7 +96,7 @@ describe('Document Controller', () => {
9696
};
9797
kuzzle.query.resolves({result});
9898

99-
return kuzzle.document.create('index', 'collection', 'document-id', {foo: 'bar'}, options)
99+
return kuzzle.document.create('index', 'collection', {foo: 'bar'}, 'document-id', options)
100100
.then(res => {
101101
should(kuzzle.query)
102102
.be.calledOnce()
@@ -122,7 +122,7 @@ describe('Document Controller', () => {
122122
};
123123
kuzzle.query.resolves({result});
124124

125-
return kuzzle.document.create('index', 'collection', 'document-id', {foo: 'bar'}, {refresh: true})
125+
return kuzzle.document.create('index', 'collection', {foo: 'bar'}, 'document-id', {refresh: true})
126126
.then(res => {
127127
should(kuzzle.query)
128128
.be.calledOnce()

test/protocol/websocket.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ describe('WebSocket networking module', () => {
121121
should(websocket.listeners('networkError').length).be.eql(1);
122122

123123
websocket.connect();
124-
websocket.connect = sinon.stub();
124+
websocket.connect = sinon.stub().rejects();
125125
clientStub.onopen();
126126
clientStub.onerror();
127127
should(websocket.retrying).be.true();

webpack.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ const
55

66
module.exports = {
77
mode: 'production',
8-
entry: './src/Kuzzle.js',
8+
entry: './index.js',
99
output: {
1010
path: `${__dirname}/dist`,
1111
filename: 'kuzzle.js',
12-
library: 'Kuzzle',
12+
library: 'KuzzleSDK',
1313
libraryTarget: 'umd'
1414
},
1515
watch: false,
@@ -48,7 +48,8 @@ module.exports = {
4848
plugins: [
4949
new webpack.IgnorePlugin(/^(http|min-req-promise|package|uws)$/),
5050
new webpack.DefinePlugin({
51-
SDKVERSION: JSON.stringify(version)
51+
SDKVERSION: JSON.stringify(version),
52+
BUILT: true
5253
}),
5354
new webpack.BannerPlugin('Kuzzle javascript SDK version ' + version),
5455
new webpack.optimize.OccurrenceOrderPlugin()

0 commit comments

Comments
 (0)