getstream
Advanced tools
Comparing version 4.1.0 to 4.2.0
@@ -38,2 +38,4 @@ var _extends = require("@babel/runtime/helpers/extends"); | ||
var jwtDecode = require('jwt-decode'); | ||
var assignIn = require('lodash/assignIn'); | ||
/** | ||
@@ -829,19 +831,89 @@ * @callback requestCallback | ||
*/ | ||
if (data.foreignID) { | ||
data['foreign_id'] = data.foreignID; | ||
delete data.foreignID; | ||
return this.activitiesPartialUpdate([data], callback).then(function (response) { | ||
var activity = response.activities[0]; | ||
delete response.activities; | ||
assignIn(activity, response); | ||
return activity; | ||
}); | ||
}, | ||
activitiesPartialUpdate: function activitiesPartialUpdate(changes, callback) { | ||
/** | ||
* Update multiple activities with partial operations. | ||
* @since | ||
* @param {array} changes array containing the changesets to be applied. Every changeset contains the activity identifier which is either the ID or the pair of of foreign ID and time of the activity. The operations to issue can be set:{...} and unset:[...]. | ||
* @return {Promise} | ||
* @xample | ||
* client.activitiesPartialUpdate([ | ||
* { | ||
* id: "4b39fda2-d6e2-42c9-9abf-5301ef071b12", | ||
* set: { | ||
* "product.price.eur": 12.99, | ||
* "colors": { | ||
* "blue": "#0000ff", | ||
* "green": "#00ff00", | ||
* }, | ||
* }, | ||
* unset: [ "popularity", "size.x2" ], | ||
* }, | ||
* { | ||
* id: "8d2dcad8-1e34-11e9-8b10-9cb6d0925edd", | ||
* set: { | ||
* "product.price.eur": 17.99, | ||
* "colors": { | ||
* "red": "#ff0000", | ||
* "green": "#00ff00", | ||
* }, | ||
* }, | ||
* unset: [ "rating" ], | ||
* }, | ||
* ]) | ||
* @example | ||
* client.activitiesPartialUpdate([ | ||
* { | ||
* foreignID: "product:123", | ||
* time: "2016-11-10T13:20:00.000000", | ||
* set: { | ||
* ... | ||
* }, | ||
* unset: [ | ||
* ... | ||
* ] | ||
* }, | ||
* { | ||
* foreignID: "product:321", | ||
* time: "2016-11-10T13:20:00.000000", | ||
* set: { | ||
* ... | ||
* }, | ||
* unset: [ | ||
* ... | ||
* ] | ||
* }, | ||
* ]) | ||
*/ | ||
if (!(changes instanceof Array)) { | ||
throw new TypeError('changes should be an Array'); | ||
} | ||
if (data.id === undefined && (data.foreign_id === undefined || data.time === undefined)) { | ||
throw new TypeError('Missing id or foreign ID and time'); | ||
} | ||
changes.forEach(function (item) { | ||
if (!(item instanceof Object)) { | ||
throw new TypeError("changeset should be and Object"); | ||
} | ||
if (data.set && !(data.set instanceof Object)) { | ||
throw new TypeError('set field should be an Object'); | ||
} | ||
if (item.foreignID) { | ||
item.foreign_id = item.foreignID; | ||
} | ||
if (data.unset && !(data.unset instanceof Array)) { | ||
throw new TypeError('unset field should be an Array'); | ||
} | ||
if (item.id === undefined && (item.foreign_id === undefined || item.time === undefined)) { | ||
throw new TypeError('missing id or foreign ID and time'); | ||
} | ||
if (item.set && !(item.set instanceof Object)) { | ||
throw new TypeError('set field should be an Object'); | ||
} | ||
if (item.unset && !(item.unset instanceof Array)) { | ||
throw new TypeError('unset field should be an Array'); | ||
} | ||
}); | ||
var authToken; | ||
@@ -860,3 +932,5 @@ | ||
url: 'activity/', | ||
body: data, | ||
body: { | ||
changes: changes | ||
}, | ||
signature: authToken | ||
@@ -863,0 +937,0 @@ }, callback); |
@@ -146,3 +146,3 @@ var errors = require('./errors'); | ||
* @memberof Collections.prototype | ||
* @param {object or array} data - A single json object or an array of objects | ||
* @param {object|array} data - A single json object or an array of objects | ||
* @param {requestCallback} callback - Callback to call on completion | ||
@@ -180,3 +180,3 @@ * @return {Promise} Promise object. | ||
* @memberof Collections.prototype | ||
* @param {object or array} ids - A single json object or an array of objects | ||
* @param {object|array} ids - A single json object or an array of objects | ||
* @param {requestCallback} callback - Callback to call on completion | ||
@@ -215,3 +215,3 @@ * @return {Promise} Promise object. | ||
* @memberof Collections.prototype | ||
* @param {object or array} ids - A single json object or an array of objects | ||
* @param {object|array} ids - A single json object or an array of objects | ||
* @param {requestCallback} callback - Callback to call on completion | ||
@@ -218,0 +218,0 @@ * @return {Promise} Promise object. |
@@ -10,4 +10,4 @@ var _typeof = require("@babel/runtime/helpers/typeof"); | ||
/* | ||
* Validate that the feedId matches the spec user:1 | ||
*/ | ||
* Validate that the feedId matches the spec user:1 | ||
*/ | ||
var parts = feedId.split(':'); | ||
@@ -30,4 +30,4 @@ | ||
/* | ||
* Validate that the feedSlug matches \w | ||
*/ | ||
* Validate that the feedSlug matches \w | ||
*/ | ||
var valid = validFeedSlugRe.test(feedSlug); | ||
@@ -46,4 +46,4 @@ | ||
/* | ||
* Validate the userId matches \w | ||
*/ | ||
* Validate the userId matches \w | ||
*/ | ||
var valid = validUserIdRe.test(userId); | ||
@@ -50,0 +50,0 @@ |
@@ -14,3 +14,3 @@ { | ||
"license": "BSD-3-Clause", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"scripts": { | ||
@@ -36,2 +36,7 @@ "build": "babel src --out-dir lib", | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "dotgit/hooks/pre-commit-format.sh && dotgit/hooks/pre-commit-reject-binaries.py" | ||
} | ||
}, | ||
"browser": { | ||
@@ -77,2 +82,3 @@ "request": "@stream-io/xmlhttp-request", | ||
"expect.js": "^0.3.1", | ||
"husky": "^1.3.1", | ||
"istanbul": "^0.4.5", | ||
@@ -79,0 +85,0 @@ "json-loader": "~0.5.4", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
529526
11839
32