Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
bc9f75b
Remove previous and next cache in searchResult
dbengsch Feb 8, 2017
771edca
Bump minor version
dbengsch Feb 8, 2017
bbb28e8
Merge remote-tracking branch 'origin/master' into topic-176-fix-searc…
dbengsch Feb 8, 2017
0be03c1
Previous in SearchResult constructor was never used
dbengsch Feb 9, 2017
0ce01e4
create a callback to call a callback is useless
dbengsch Feb 9, 2017
c3f7e87
Merge branch 'develop' into topic-176-fix-search-result
Feb 10, 2017
eb10bd8
fix #181
scottinet Feb 14, 2017
a7260c1
browsers compatibility fix
scottinet Feb 16, 2017
ffa3a5b
Update package.json
scottinet Feb 21, 2017
8199d21
Merge remote-tracking branch 'origin/3.x' into browser-compatibility-fix
scottinet Feb 23, 2017
b5de17a
Merge pull request #184 from kuzzleio/browser-compatibility-fix
scottinet Feb 23, 2017
d749587
make sslConnection option writable
benoitvidis Feb 27, 2017
d5f82a5
Merge pull request #177 from kuzzleio/topic-176-fix-search-result
xbill82 Mar 1, 2017
f47098e
Merge pull request #188 from kuzzleio/ssl-support-for-back-office
Mar 2, 2017
b4595a3
Merge branch '4.x' into rename-updateifexist-option
stafyniaksacha Mar 3, 2017
53bbb19
(wip) standardize memory storage
scottinet Mar 3, 2017
d544133
Merge pull request #182 from kuzzleio/rename-updateifexist-option
scottinet Mar 6, 2017
731b60f
Align SearchResult within SDKs
dbengsch Mar 6, 2017
427e188
Modify signature of the SearchResult constructor
dbengsch Mar 7, 2017
ac7dcff
memory storage finished + unit tests
scottinet Mar 8, 2017
f6ea188
Merge remote-tracking branch 'origin/4.x' into standardize-memory-sto…
scottinet Mar 8, 2017
9e31b7f
extend timeouts to make unit tests compliant with travis "performances"
scottinet Mar 8, 2017
789dca1
Scroll scroll argument is an option again
dbengsch Mar 8, 2017
6c3eee3
Merge remote-tracking branch 'origin/fix-scroll-method' into 4.x
scottinet Mar 9, 2017
46c1214
Wrap filter in query for deleteDocument
jenow Mar 9, 2017
a381e51
Stop calling onClientError when disconnect is called
jenow Mar 10, 2017
e5d7801
Merge remote-tracking branch 'origin/4.x' into topic-18-align-search-…
dbengsch Mar 10, 2017
caebd3e
Merge pull request #190 from kuzzleio/topic-18-align-search-result
Mar 10, 2017
87a3921
Moved bufferutil and utf-8-validate to peerDependencies
jenow Mar 10, 2017
ae9709e
Merge pull request #195 from kuzzleio/bufferutil-utf8validate-as-peer…
stafyniaksacha Mar 13, 2017
fb7760f
Merge pull request #193 from kuzzleio/fix-sdk-4
benoitvidis Mar 13, 2017
4d2488d
Merge pull request #191 from kuzzleio/standardize-memory-storage
benoitvidis Mar 13, 2017
56e7ee7
fix ms.hgetall return value interpretation
scottinet Mar 13, 2017
428d3e8
Merge branch '4.x' into fix-16
jenow Mar 13, 2017
1dc1716
merge
jenow Mar 13, 2017
d988530
fix ms.zscore return value type
scottinet Mar 20, 2017
983afd4
give more time to travis
scottinet Mar 20, 2017
a013a74
Merge pull request #198 from kuzzleio/fix-zscore-return-value
jenow Mar 20, 2017
0e0dd99
Merge pull request #196 from kuzzleio/msbugfix
jenow Mar 20, 2017
37a06c2
Add support for the new retryOnConflict option
scottinet Mar 23, 2017
24a8bc4
Merge pull request #194 from kuzzleio/fix-16
scottinet Mar 28, 2017
2b80f02
Merge pull request #199 from kuzzleio/add-retryOnConflict-support
Mar 28, 2017
cf6f733
rename metadata into volatile
Apr 3, 2017
b1d2eb0
Merge pull request #201 from kuzzleio/rename-metadata-volatile
AnthonySendra Apr 10, 2017
25a0a87
Release 4.0.0
jenow Apr 10, 2017
cb60c2f
Merge branch 'master' into 4.0.0-proposal
AnthonySendra Apr 10, 2017
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
3 changes: 1 addition & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@
"yoda": [2, "never"]
},
"env": {
"node": true,
"mocha": true
"browser": true
},
"parserOptions": {
"ecmaVersion": 5
Expand Down
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
# [4.0.0](https://github.com/kuzzleio/sdk-javascript/releases/tag/4.0.0) (2017-04-10)

[Full Changelog](https://github.com/kuzzleio/sdk-javascript/compare/4.0.0...4.0.0)

### Compatibility

| Kuzzle | Proxy |
|--------|-------|
| 1.0.0-RC9.6 | 1.0.0-RC9 |

#### Breaking changes

- [ [#201](https://github.com/kuzzleio/sdk-javascript/pull/201) ] Rename metadata into volatile ([AnthonySendra](https://github.com/AnthonySendra))

#### Bug fixes

- [ [#194](https://github.com/kuzzleio/sdk-javascript/pull/194) ] Stop calling onClientError when disconnect is called ([jenow](https://github.com/jenow))
- [ [#193](https://github.com/kuzzleio/sdk-javascript/pull/193) ] Wrap filter in query for deleteDocument ([jenow](https://github.com/jenow))

#### Enhancements

- [ [#199](https://github.com/kuzzleio/sdk-javascript/pull/199) ] Add support for the new retryOnConflict option ([scottinet](https://github.com/scottinet))
- [ [#191](https://github.com/kuzzleio/sdk-javascript/pull/191) ] Standardize memory storage object ([scottinet](https://github.com/scottinet))

#### Exclude

- [ [#196](https://github.com/kuzzleio/sdk-javascript/pull/196) ] Fix ms.hgetall return value interpretation ([scottinet](https://github.com/scottinet))
- [ [#198](https://github.com/kuzzleio/sdk-javascript/pull/198) ] Fix ms.zscore return value type ([scottinet](https://github.com/scottinet))

#### Others

- [ [#195](https://github.com/kuzzleio/sdk-javascript/pull/195) ] Moved bufferutil and utf-8-validate to peerDependencies ([jenow](https://github.com/jenow))
- [ [#190](https://github.com/kuzzleio/sdk-javascript/pull/190) ] Align SearchResult and scroll with other SDKs ([dbengsch](https://github.com/dbengsch))
- [ [#182](https://github.com/kuzzleio/sdk-javascript/pull/182) ] Collection.createDocument: rename the updateIfExist option ([scottinet](https://github.com/scottinet))
- [ [#188](https://github.com/kuzzleio/sdk-javascript/pull/188) ] Make all options given to kuzzle constructor writable ([benoitvidis](https://github.com/benoitvidis))
- [ [#177](https://github.com/kuzzleio/sdk-javascript/pull/177) ] Remove previous and next cache in SearchResult ([dbengsch](https://github.com/dbengsch))
- [ [#177](https://github.com/kuzzleio/sdk-javascript/pull/177) ] Remove previous and next cache in SearchResult ([dbengsch](https://github.com/dbengsch))
- [ [#184](https://github.com/kuzzleio/sdk-javascript/pull/184) ] Browsers compatibility fix ([scottinet](https://github.com/scottinet))
---

# 3.4.0

Fill changes list: https://github.com/kuzzleio/sdk-javascript/releases/tag/3.4.0
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ You can access the Kuzzle repository on [Github](https://github.com/kuzzleio/kuz
* [Basic usage](#basic-usage-js)
* [Building manually](#building-manually)
* [Migrating from SDK v1.x](#migrating-from-sdk-v1.x)
* [Note](#note)
* [License](#license)

## SDK Documentation
Expand Down Expand Up @@ -139,6 +140,10 @@ kuzzle

* Kuzzle constructor has been changed. Instead of an URL, you have to provide a resolvable server name, or an IP address. If you need to specify a port different than the provided default value, you can do so using the `port` option.

## Note

* bufferutil and utf-8-validate have been moved to peerDependencies

## License

[Apache 2](LICENSE.md)
6 changes: 3 additions & 3 deletions dist/kuzzle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/kuzzle.js.map

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kuzzle-sdk",
"version": "3.4.2",
"version": "4.0.0",
"description": "Official Javascript SDK for Kuzzle",
"author": "The Kuzzle Team <[email protected]>",
"repository": {
Expand Down Expand Up @@ -28,12 +28,14 @@
"license": "Apache-2.0",
"dependencies": {
"bluebird": "3.4.7",
"bufferutil": "^2.0.1",
"eslint-loader": "^1.6.1",
"utf-8-validate": "^3.0.1",
"uuid": "3.0.1",
"ws": "^2.0.3"
},
"peerDependencies": {
"bufferutil": "^2.0.1",
"utf-8-validate": "^3.0.1"
},
"devDependencies": {
"codecov": "^1.0.1",
"eslint": "^3.15.0",
Expand All @@ -52,4 +54,4 @@
"engines": {
"node": ">= 6.9.1"
}
}
}
52 changes: 33 additions & 19 deletions src/Collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var
Document = require('./Document'),
CollectionMapping = require('./CollectionMapping'),
Room = require('./Room'),
KuzzleSubscribeResult = require('./SubscribeResult');
SubscribeResult = require('./SubscribeResult');

/**
* This is a global callback pattern, called by all asynchronous functions of the Kuzzle object.
Expand Down Expand Up @@ -134,11 +134,12 @@ Collection.prototype.create = function (options, cb) {
* Create a new document in Kuzzle.
*
* Takes an optional argument object with the following properties:
* - metadata (object, default: null):
* - volatile (object, default: null):
* Additional information passed to notifications to other users
* - updateIfExist (boolean, default: false):
* If the same document already exists: throw an error if sets to false.
* Update the existing document otherwise
* - ifExist (string, allowed values: "error" (default), "replace"):
* If the same document already exists:
* - resolves with an error if set to "error".
* - replaces the existing document if set to "replace"
*
* @param {string} [id] - (optional) document identifier
* @param {object} document - either an instance of a Document object, or a document
Expand Down Expand Up @@ -170,8 +171,13 @@ Collection.prototype.createDocument = function (id, document, options, cb) {
data.body = document;
}

if (options) {
action = options.updateIfExist ? 'createOrReplace' : 'create';
if (options && options.ifExist) {
if (options.ifExist === 'replace') {
action = 'createOrReplace';
}
else if (options.ifExist !== 'error') {
throw new Error('Invalid value for the "ifExist" option: ' + options.ifExist);
}
}

if (id) {
Expand Down Expand Up @@ -203,7 +209,7 @@ Collection.prototype.createDocument = function (id, document, options, cb) {
* That means that a document that was just been created won’t be returned by this function
*
* Takes an optional argument object with the following properties:
* - metadata (object, default: null):
* - volatile (object, default: null):
* Additional information passed to notifications to other users
*
* @param {string|object} arg - Either a document ID (will delete only this particular document), or a set of filters
Expand All @@ -220,7 +226,7 @@ Collection.prototype.deleteDocument = function (arg, options, cb) {
data._id = arg;
action = 'delete';
} else {
data.body = arg;
data.body = {query: arg};
action = 'deleteByQuery';
}

Expand Down Expand Up @@ -308,7 +314,7 @@ Collection.prototype.fetchAllDocuments = function (options, cb) {

this.kuzzle.callbackRequired('Collection.fetchAllDocuments', cb);

this.search(filters, options, function getNextDocuments (error, searchResult) {
this.search(filters, options, function fetchNextDocuments (error, searchResult) {
if (error) {
return cb(error);
}
Expand All @@ -322,7 +328,7 @@ Collection.prototype.fetchAllDocuments = function (options, cb) {
searchResult.documents.forEach(function(document) {
documents.push(document);
});
searchResult.next(getNextDocuments);
searchResult.fetchNext(fetchNextDocuments);
}
else {
cb(null, documents);
Expand Down Expand Up @@ -355,7 +361,7 @@ Collection.prototype.getMapping = function (options, cb) {
* Publish a realtime message
*
* Takes an optional argument object with the following properties:
* - metadata (object, default: null):
* - volatile (object, default: null):
* Additional information passed to notifications to other users
*
* @param {object} document - either a Document instance or a JSON object
Expand All @@ -382,7 +388,7 @@ Collection.prototype.publishMessage = function (document, options, cb) {
* Replace an existing document with a new one.
*
* Takes an optional argument object with the following properties:
* - metadata (object, default: null):
* - volatile (object, default: null):
* Additional information passed to notifications to other users
*
* @param {string} documentId - Unique document identifier of the document to replace
Expand Down Expand Up @@ -471,8 +477,10 @@ Collection.prototype.search = function (filters, options, cb) {
self,
result.result.total,
documents,
result.result.aggregations ? result.result.aggregations : [],
{options: options, filters: filters}
result.result.aggregations ? result.result.aggregations : {},
options,
filters,
options.previous || null
));
});
};
Expand Down Expand Up @@ -538,8 +546,10 @@ Collection.prototype.scroll = function (scrollId, options, filters, cb) {
self,
result.result.total,
documents,
result.result.aggregations ? result.result.aggregations : [],
{options: options, filters: filters}
{},
options,
filters,
options.previous || null
));
});

Expand Down Expand Up @@ -567,7 +577,7 @@ Collection.prototype.subscribe = function (filters, options, cb) {

this.kuzzle.callbackRequired('Collection.subscribe', cb);

subscribeResult = new KuzzleSubscribeResult();
subscribeResult = new SubscribeResult();
room = new Room(this, options);

room.renew(filters, cb, subscribeResult.done.bind(subscribeResult));
Expand Down Expand Up @@ -602,7 +612,7 @@ Collection.prototype.truncate = function (options, cb) {
* Update parts of a document
*
* Takes an optional argument object with the following properties:
* - metadata (object, default: null):
* - volatile (object, default: null):
* Additional information passed to notifications to other users
*
* @param {string} documentId - Unique document identifier of the document to update
Expand All @@ -624,6 +634,10 @@ Collection.prototype.updateDocument = function (documentId, content, options, cb
options = null;
}

if (options && options.retryOnConflict) {
data.retryOnConflict = options.retryOnConflict;
}

data = self.kuzzle.addHeaders(data, this.headers);

self.kuzzle.query(this.buildQueryArgs('document', 'update'), data, options, cb && function (err, res) {
Expand Down
18 changes: 9 additions & 9 deletions src/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@
* - providing a documentID to the constructor will automatically call refresh, unless a content is also provided
*
*
* @param {object} kuzzleDataCollection - an instanciated Collection object
* @param {Collection} collection - an instanciated Collection object
* @param {string} [documentId] - ID of an existing document
* @param {object} [content] - Initializes this document with the provided content
* @constructor
*/
function Document(kuzzleDataCollection, documentId, content) {
function Document(collection, documentId, content) {
Object.defineProperties(this, {
// read-only properties
collection: {
value: kuzzleDataCollection.collection,
value: collection.collection,
enumerable: true
},
dataCollection: {
value: kuzzleDataCollection,
value: collection,
enumerable: false
},
kuzzle: {
value: kuzzleDataCollection.kuzzle,
value: collection.kuzzle,
enumerable: false
},
// writable properties
Expand All @@ -47,7 +47,7 @@ function Document(kuzzleDataCollection, documentId, content) {
enumerable: true
},
headers: {
value: JSON.parse(JSON.stringify(kuzzleDataCollection.headers)),
value: JSON.parse(JSON.stringify(collection.headers)),
enumerable: true,
writable: true
},
Expand Down Expand Up @@ -127,7 +127,7 @@ Document.prototype.toString = function () {
* Deletes this document in Kuzzle.
*
* Takes an optional argument object with the following properties:
* - metadata (object, default: null):
* - volatile (object, default: null):
* Additional information passed to notifications to other users
*
* @param {object} [options] - Optional parameters
Expand Down Expand Up @@ -194,7 +194,7 @@ Document.prototype.refresh = function (options, cb) {
* of this object.
*
* Takes an optional argument object with the following properties:
* - metadata (object, default: null):
* - volatile (object, default: null):
* Additional information passed to notifications to other users
*
* @param {object} [options] - Optional parameters
Expand Down Expand Up @@ -231,7 +231,7 @@ Document.prototype.save = function (options, cb) {
* Sends the content of this document as a realtime message.
*
* Takes an optional argument object with the following properties:
* - metadata (object, default: null):
* - volatile (object, default: null):
* Additional information passed to notifications to other users
*
* @param {object} [options] - Optional parameters
Expand Down
24 changes: 12 additions & 12 deletions src/Kuzzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function Kuzzle (host, options, cb) {
enumerable: true,
writable: true
},
metadata: {
volatile: {
value: {},
enumerable: true,
writable: true
Expand Down Expand Up @@ -268,9 +268,9 @@ function Kuzzle (host, options, cb) {
}

eventProperties.listeners.forEach(function (listener) {
process.nextTick(function () {
setTimeout(function () {
listener.fn.apply(undefined, args);
});
}, 0);
});

// Events without the 'lastEmitted' property can be emitted without minimum time between emissions
Expand Down Expand Up @@ -1252,7 +1252,7 @@ Kuzzle.prototype.now = function (options, cb) {
* Base method used to send read queries to Kuzzle
*
* Takes an optional argument object with the following properties:
* - metadata (object, default: null):
* - volatile (object, default: null):
* Additional information passed to notifications to other users
*
* @param {object} queryArgs - Query configuration
Expand All @@ -1266,7 +1266,7 @@ Kuzzle.prototype.query = function (queryArgs, query, options, cb) {
object = {
action: queryArgs.action,
controller: queryArgs.controller,
metadata: this.metadata
volatile: this.volatile
},
self = this;

Expand Down Expand Up @@ -1302,9 +1302,9 @@ Kuzzle.prototype.query = function (queryArgs, query, options, cb) {
object.scrollId = options.scrollId;
}

if (options.metadata) {
Object.keys(options.metadata).forEach(function (meta) {
object.metadata[meta] = options.metadata[meta];
if (options.volatile) {
Object.keys(options.volatile).forEach(function (meta) {
object.volatile[meta] = options.volatile[meta];
});
}
}
Expand All @@ -1313,14 +1313,14 @@ Kuzzle.prototype.query = function (queryArgs, query, options, cb) {
throw new Error('Invalid query parameter: ' + query);
}

if (query.metadata) {
Object.keys(query.metadata).forEach(function (meta) {
object.metadata[meta] = query.metadata[meta];
if (query.volatile) {
Object.keys(query.volatile).forEach(function (meta) {
object.volatile[meta] = query.volatile[meta];
});
}

for (attr in query) {
if (attr !== 'metadata' && query.hasOwnProperty(attr)) {
if (attr !== 'volatile' && query.hasOwnProperty(attr)) {
object[attr] = query[attr];
}
}
Expand Down
Loading