Comparing version 1.7.1 to 1.8.0-rc2
@@ -19,3 +19,4 @@ /** | ||
SERVER_URL: 'https://api.parse.com/1', | ||
VERSION: 'js' + '1.7.1', | ||
LIVEQUERY_SERVER_URL: null, | ||
VERSION: 'js' + '1.8.0-rc2', | ||
APPLICATION_ID: null, | ||
@@ -290,3 +291,23 @@ JAVASCRIPT_KEY: null, | ||
return config['UserController']; | ||
}, | ||
setLiveQueryController: function setLiveQueryController(controller) { | ||
if (typeof controller.subscribe !== 'function') { | ||
throw new Error('LiveQueryController must implement subscribe()'); | ||
} | ||
if (typeof controller.unsubscribe !== 'function') { | ||
throw new Error('LiveQueryController must implement unsubscribe()'); | ||
} | ||
if (typeof controller.open !== 'function') { | ||
throw new Error('LiveQueryController must implement open()'); | ||
} | ||
if (typeof controller.close !== 'function') { | ||
throw new Error('LiveQueryController must implement close()'); | ||
} | ||
config['LiveQueryController'] = controller; | ||
}, | ||
getLiveQueryController: function getLiveQueryController() { | ||
return config['LiveQueryController']; | ||
} | ||
}; |
@@ -51,3 +51,3 @@ /** | ||
* @param {String} applicationId Your Parse Application ID. | ||
* @param {String} javaScriptKey Your Parse JavaScript Key. | ||
* @param {String} javaScriptKey (optional) Your Parse JavaScript Key (Not needed for parse-server) | ||
* @param {String} masterKey (optional) Your Parse Master Key. (Node.js only!) | ||
@@ -104,2 +104,10 @@ * @static | ||
}); | ||
Object.defineProperty(Parse, 'liveQueryServerURL', { | ||
get: function get() { | ||
return _CoreManager2['default'].get('LIVEQUERY_SERVER_URL'); | ||
}, | ||
set: function set(value) { | ||
_CoreManager2['default'].set('LIVEQUERY_SERVER_URL', value); | ||
} | ||
}); | ||
/** End setters **/ | ||
@@ -135,2 +143,4 @@ | ||
Parse.User = require('./ParseUser'); | ||
Parse.LiveQuery = require('./ParseLiveQuery'); | ||
Parse.LiveQueryClient = require('./LiveQueryClient'); | ||
@@ -137,0 +147,0 @@ Parse._request = function () { |
@@ -830,3 +830,3 @@ /** | ||
/** | ||
* Creates a new model with identical attributes to this one. | ||
* Creates a new model with identical attributes to this one, similar to Backbone.Model's clone() | ||
* @method clone | ||
@@ -862,2 +862,25 @@ * @return {Parse.Object} | ||
/** | ||
* Creates a new instance of this object. Not to be confused with clone() | ||
* @method newInstance | ||
* @return {Parse.Object} | ||
*/ | ||
}, { | ||
key: 'newInstance', | ||
value: function newInstance() { | ||
var clone = new this.constructor(); | ||
if (!clone.className) { | ||
clone.className = this.className; | ||
} | ||
clone.id = this.id; | ||
if (singleInstance) { | ||
// Just return an object with the right id | ||
return clone; | ||
} | ||
var stateController = _CoreManager2['default'].getObjectStateController(); | ||
stateController.duplicateState(this._getStateIdentifier(), clone._getStateIdentifier()); | ||
return clone; | ||
} | ||
/** | ||
* Returns true if this object has never been saved to Parse. | ||
@@ -864,0 +887,0 @@ * @method isNew |
@@ -16,2 +16,4 @@ /** | ||
var _getIterator = require('babel-runtime/core-js/get-iterator')['default']; | ||
Object.defineProperty(exports, '__esModule', { | ||
@@ -238,2 +240,3 @@ value: true | ||
* Add handlers to be called when the Promise object is rejected | ||
* Alias for catch(). | ||
* @method fail | ||
@@ -248,2 +251,12 @@ */ | ||
/** | ||
* Add handlers to be called when the Promise object is rejected | ||
* @method catch | ||
*/ | ||
}, { | ||
key: 'catch', | ||
value: function _catch(callback) { | ||
return this.then(null, callback); | ||
} | ||
/** | ||
* Run the given callbacks after this promise is fulfilled. | ||
@@ -502,2 +515,157 @@ * @method _thenRunCallbacks | ||
/** | ||
* Returns a new promise that is fulfilled when all of the promises in the | ||
* iterable argument are resolved. If any promise in the list fails, then | ||
* the returned promise will be immediately rejected with the reason that | ||
* single promise rejected. If they all succeed, then the returned promise | ||
* will succeed, with the results being the results of all the input | ||
* promises. If the iterable provided is empty, the returned promise will | ||
* be immediately resolved. | ||
* | ||
* For example: <pre> | ||
* var p1 = Parse.Promise.as(1); | ||
* var p2 = Parse.Promise.as(2); | ||
* var p3 = Parse.Promise.as(3); | ||
* | ||
* Parse.Promise.all([p1, p2, p3]).then(function([r1, r2, r3]) { | ||
* console.log(r1); // prints 1 | ||
* console.log(r2); // prints 2 | ||
* console.log(r3); // prints 3 | ||
* });</pre> | ||
* | ||
* @method all | ||
* @param {Iterable} promises an iterable of promises to wait for. | ||
* @static | ||
* @return {Parse.Promise} the new promise. | ||
*/ | ||
}, { | ||
key: 'all', | ||
value: function all(promises) { | ||
var total = 0; | ||
var objects = []; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = _getIterator(promises), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var p = _step.value; | ||
objects[total++] = p; | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator['return']) { | ||
_iterator['return'](); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
if (total === 0) { | ||
return ParsePromise.as([]); | ||
} | ||
var hadError = false; | ||
var promise = new ParsePromise(); | ||
var resolved = 0; | ||
var results = []; | ||
objects.forEach(function (object, i) { | ||
if (ParsePromise.is(object)) { | ||
object.then(function (result) { | ||
if (hadError) { | ||
return false; | ||
} | ||
results[i] = result; | ||
resolved++; | ||
if (resolved >= total) { | ||
promise.resolve(results); | ||
} | ||
}, function (error) { | ||
// Reject immediately | ||
promise.reject(error); | ||
hadError = true; | ||
}); | ||
} else { | ||
results[i] = object; | ||
resolved++; | ||
if (!hadError && resolved >= total) { | ||
promise.resolve(results); | ||
} | ||
} | ||
}); | ||
return promise; | ||
} | ||
/** | ||
* Returns a new promise that is immediately fulfilled when any of the | ||
* promises in the iterable argument are resolved or rejected. If the | ||
* first promise to complete is resolved, the returned promise will be | ||
* resolved with the same value. Likewise, if the first promise to | ||
* complete is rejected, the returned promise will be rejected with the | ||
* same reason. | ||
* | ||
* @method race | ||
* @param {Iterable} promises an iterable of promises to wait for. | ||
* @static | ||
* @return {Parse.Promise} the new promise. | ||
*/ | ||
}, { | ||
key: 'race', | ||
value: function race(promises) { | ||
var completed = false; | ||
var promise = new ParsePromise(); | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
try { | ||
for (var _iterator2 = _getIterator(promises), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var p = _step2.value; | ||
if (ParsePromise.is(p)) { | ||
p.then(function (result) { | ||
if (completed) { | ||
return; | ||
} | ||
completed = true; | ||
promise.resolve(result); | ||
}, function (error) { | ||
if (completed) { | ||
return; | ||
} | ||
completed = true; | ||
promise.reject(error); | ||
}); | ||
} else if (!completed) { | ||
completed = true; | ||
promise.resolve(p); | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2['return']) { | ||
_iterator2['return'](); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
} | ||
} | ||
return promise; | ||
} | ||
/** | ||
* Runs the given asyncFunction repeatedly, as long as the predicate | ||
@@ -504,0 +672,0 @@ * function returns a truthy value. Stops repeating if asyncFunction returns |
@@ -1099,2 +1099,15 @@ /** | ||
/** | ||
* Subscribe this query to get liveQuery updates | ||
* @method subscribe | ||
* @return {LiveQuerySubscription} Returns the liveQuerySubscription, it's an event emitter | ||
* which can be used to get liveQuery updates. | ||
*/ | ||
}, { | ||
key: 'subscribe', | ||
value: function subscribe() { | ||
var controller = _CoreManager2['default'].getLiveQueryController(); | ||
return controller.subscribe(this); | ||
} | ||
/** | ||
* Constructs a Parse.Query that is the OR of the passed in queries. For | ||
@@ -1101,0 +1114,0 @@ * example: |
@@ -437,2 +437,5 @@ /** | ||
} | ||
if (options.hasOwnProperty('installationId')) { | ||
signupOptions.installationId = options.installationId; | ||
} | ||
@@ -466,2 +469,5 @@ var controller = _CoreManager2['default'].getUserController(); | ||
} | ||
if (options.hasOwnProperty('installationId')) { | ||
loginOptions.installationId = options.installationId; | ||
} | ||
@@ -494,8 +500,8 @@ var controller = _CoreManager2['default'].getUserController(); | ||
/** | ||
* Wrap the default fetch behavior with functionality to save to local | ||
* storage if this is current user. | ||
* Wrap the default destroy behavior with functionality that logs out | ||
* the current user when it is destroyed | ||
*/ | ||
}, { | ||
key: 'fetch', | ||
value: function fetch() { | ||
key: 'destroy', | ||
value: function destroy() { | ||
var _this4 = this; | ||
@@ -507,5 +513,5 @@ | ||
return _get(Object.getPrototypeOf(ParseUser.prototype), 'fetch', this).apply(this, args).then(function () { | ||
return _get(Object.getPrototypeOf(ParseUser.prototype), 'destroy', this).apply(this, args).then(function () { | ||
if (_this4.isCurrent()) { | ||
return _CoreManager2['default'].getUserController().updateUserOnDisk(_this4); | ||
return _CoreManager2['default'].getUserController().removeUserFromDisk(); | ||
} | ||
@@ -515,2 +521,23 @@ return _this4; | ||
} | ||
/** | ||
* Wrap the default fetch behavior with functionality to save to local | ||
* storage if this is current user. | ||
*/ | ||
}, { | ||
key: 'fetch', | ||
value: function fetch() { | ||
var _this5 = this; | ||
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
args[_key3] = arguments[_key3]; | ||
} | ||
return _get(Object.getPrototypeOf(ParseUser.prototype), 'fetch', this).apply(this, args).then(function () { | ||
if (_this5.isCurrent()) { | ||
return _CoreManager2['default'].getUserController().updateUserOnDisk(_this5); | ||
} | ||
return _this5; | ||
}); | ||
} | ||
}], [{ | ||
@@ -852,2 +879,9 @@ key: 'readOnlyAttributes', | ||
removeUserFromDisk: function removeUserFromDisk() { | ||
var path = _Storage2['default'].generatePath(CURRENT_USER_KEY); | ||
currentUserCacheMatchesDisk = true; | ||
currentUserCache = null; | ||
return _Storage2['default'].removeItemAsync(path); | ||
}, | ||
setCurrentUser: function setCurrentUser(user) { | ||
@@ -854,0 +888,0 @@ currentUserCache = user; |
@@ -163,3 +163,6 @@ /** | ||
payload._ApplicationId = _CoreManager2['default'].get('APPLICATION_ID'); | ||
payload._JavaScriptKey = _CoreManager2['default'].get('JAVASCRIPT_KEY'); | ||
var jsKey = _CoreManager2['default'].get('JAVASCRIPT_KEY'); | ||
if (jsKey) { | ||
payload._JavaScriptKey = jsKey; | ||
} | ||
payload._ClientVersion = _CoreManager2['default'].get('VERSION'); | ||
@@ -184,5 +187,12 @@ | ||
var installationController = _CoreManager2['default'].getInstallationController(); | ||
var installationId = options.installationId; | ||
var installationIdPromise; | ||
if (installationId && typeof installationId === 'string') { | ||
installationIdPromise = _ParsePromise2['default'].as(installationId); | ||
} else { | ||
var installationController = _CoreManager2['default'].getInstallationController(); | ||
installationIdPromise = installationController.currentInstallationId(); | ||
} | ||
return installationController.currentInstallationId().then(function (iid) { | ||
return installationIdPromise.then(function (iid) { | ||
payload._InstallationId = iid; | ||
@@ -189,0 +199,0 @@ var userController = _CoreManager2['default'].getUserController(); |
@@ -38,2 +38,3 @@ /** | ||
exports.enqueueTask = enqueueTask; | ||
exports.duplicateState = duplicateState; | ||
exports.clearAllState = clearAllState; | ||
@@ -155,4 +156,21 @@ | ||
function duplicateState(source, dest) { | ||
var oldState = initializeState(source); | ||
var newState = initializeState(dest); | ||
for (var key in oldState.serverData) { | ||
newState.serverData[key] = oldState.serverData[key]; | ||
} | ||
for (var index = 0; index < oldState.pendingOps.length; index++) { | ||
for (var key in oldState.pendingOps[index]) { | ||
newState.pendingOps[index][key] = oldState.pendingOps[index][key]; | ||
} | ||
} | ||
for (var key in oldState.objectCache) { | ||
newState.objectCache[key] = oldState.objectCache[key]; | ||
} | ||
newState.existed = oldState.existed; | ||
} | ||
function clearAllState() { | ||
objectState = new _WeakMap(); | ||
} |
@@ -19,3 +19,4 @@ /** | ||
SERVER_URL: 'https://api.parse.com/1', | ||
VERSION: 'js' + '1.7.1', | ||
LIVEQUERY_SERVER_URL: null, | ||
VERSION: 'js' + '1.8.0-rc2', | ||
APPLICATION_ID: null, | ||
@@ -290,3 +291,23 @@ JAVASCRIPT_KEY: null, | ||
return config['UserController']; | ||
}, | ||
setLiveQueryController: function setLiveQueryController(controller) { | ||
if (typeof controller.subscribe !== 'function') { | ||
throw new Error('LiveQueryController must implement subscribe()'); | ||
} | ||
if (typeof controller.unsubscribe !== 'function') { | ||
throw new Error('LiveQueryController must implement unsubscribe()'); | ||
} | ||
if (typeof controller.open !== 'function') { | ||
throw new Error('LiveQueryController must implement open()'); | ||
} | ||
if (typeof controller.close !== 'function') { | ||
throw new Error('LiveQueryController must implement close()'); | ||
} | ||
config['LiveQueryController'] = controller; | ||
}, | ||
getLiveQueryController: function getLiveQueryController() { | ||
return config['LiveQueryController']; | ||
} | ||
}; |
@@ -51,3 +51,3 @@ /** | ||
* @param {String} applicationId Your Parse Application ID. | ||
* @param {String} javaScriptKey Your Parse JavaScript Key. | ||
* @param {String} javaScriptKey (optional) Your Parse JavaScript Key (Not needed for parse-server) | ||
* @param {String} masterKey (optional) Your Parse Master Key. (Node.js only!) | ||
@@ -101,2 +101,10 @@ * @static | ||
}); | ||
Object.defineProperty(Parse, 'liveQueryServerURL', { | ||
get: function get() { | ||
return _CoreManager2['default'].get('LIVEQUERY_SERVER_URL'); | ||
}, | ||
set: function set(value) { | ||
_CoreManager2['default'].set('LIVEQUERY_SERVER_URL', value); | ||
} | ||
}); | ||
/** End setters **/ | ||
@@ -132,2 +140,4 @@ | ||
Parse.User = require('./ParseUser'); | ||
Parse.LiveQuery = require('./ParseLiveQuery'); | ||
Parse.LiveQueryClient = require('./LiveQueryClient'); | ||
@@ -134,0 +144,0 @@ Parse._request = function () { |
@@ -830,3 +830,3 @@ /** | ||
/** | ||
* Creates a new model with identical attributes to this one. | ||
* Creates a new model with identical attributes to this one, similar to Backbone.Model's clone() | ||
* @method clone | ||
@@ -862,2 +862,25 @@ * @return {Parse.Object} | ||
/** | ||
* Creates a new instance of this object. Not to be confused with clone() | ||
* @method newInstance | ||
* @return {Parse.Object} | ||
*/ | ||
}, { | ||
key: 'newInstance', | ||
value: function newInstance() { | ||
var clone = new this.constructor(); | ||
if (!clone.className) { | ||
clone.className = this.className; | ||
} | ||
clone.id = this.id; | ||
if (singleInstance) { | ||
// Just return an object with the right id | ||
return clone; | ||
} | ||
var stateController = _CoreManager2['default'].getObjectStateController(); | ||
stateController.duplicateState(this._getStateIdentifier(), clone._getStateIdentifier()); | ||
return clone; | ||
} | ||
/** | ||
* Returns true if this object has never been saved to Parse. | ||
@@ -864,0 +887,0 @@ * @method isNew |
@@ -16,2 +16,4 @@ /** | ||
var _getIterator = require('babel-runtime/core-js/get-iterator')['default']; | ||
Object.defineProperty(exports, '__esModule', { | ||
@@ -238,2 +240,3 @@ value: true | ||
* Add handlers to be called when the Promise object is rejected | ||
* Alias for catch(). | ||
* @method fail | ||
@@ -248,2 +251,12 @@ */ | ||
/** | ||
* Add handlers to be called when the Promise object is rejected | ||
* @method catch | ||
*/ | ||
}, { | ||
key: 'catch', | ||
value: function _catch(callback) { | ||
return this.then(null, callback); | ||
} | ||
/** | ||
* Run the given callbacks after this promise is fulfilled. | ||
@@ -502,2 +515,157 @@ * @method _thenRunCallbacks | ||
/** | ||
* Returns a new promise that is fulfilled when all of the promises in the | ||
* iterable argument are resolved. If any promise in the list fails, then | ||
* the returned promise will be immediately rejected with the reason that | ||
* single promise rejected. If they all succeed, then the returned promise | ||
* will succeed, with the results being the results of all the input | ||
* promises. If the iterable provided is empty, the returned promise will | ||
* be immediately resolved. | ||
* | ||
* For example: <pre> | ||
* var p1 = Parse.Promise.as(1); | ||
* var p2 = Parse.Promise.as(2); | ||
* var p3 = Parse.Promise.as(3); | ||
* | ||
* Parse.Promise.all([p1, p2, p3]).then(function([r1, r2, r3]) { | ||
* console.log(r1); // prints 1 | ||
* console.log(r2); // prints 2 | ||
* console.log(r3); // prints 3 | ||
* });</pre> | ||
* | ||
* @method all | ||
* @param {Iterable} promises an iterable of promises to wait for. | ||
* @static | ||
* @return {Parse.Promise} the new promise. | ||
*/ | ||
}, { | ||
key: 'all', | ||
value: function all(promises) { | ||
var total = 0; | ||
var objects = []; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = _getIterator(promises), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var p = _step.value; | ||
objects[total++] = p; | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator['return']) { | ||
_iterator['return'](); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
if (total === 0) { | ||
return ParsePromise.as([]); | ||
} | ||
var hadError = false; | ||
var promise = new ParsePromise(); | ||
var resolved = 0; | ||
var results = []; | ||
objects.forEach(function (object, i) { | ||
if (ParsePromise.is(object)) { | ||
object.then(function (result) { | ||
if (hadError) { | ||
return false; | ||
} | ||
results[i] = result; | ||
resolved++; | ||
if (resolved >= total) { | ||
promise.resolve(results); | ||
} | ||
}, function (error) { | ||
// Reject immediately | ||
promise.reject(error); | ||
hadError = true; | ||
}); | ||
} else { | ||
results[i] = object; | ||
resolved++; | ||
if (!hadError && resolved >= total) { | ||
promise.resolve(results); | ||
} | ||
} | ||
}); | ||
return promise; | ||
} | ||
/** | ||
* Returns a new promise that is immediately fulfilled when any of the | ||
* promises in the iterable argument are resolved or rejected. If the | ||
* first promise to complete is resolved, the returned promise will be | ||
* resolved with the same value. Likewise, if the first promise to | ||
* complete is rejected, the returned promise will be rejected with the | ||
* same reason. | ||
* | ||
* @method race | ||
* @param {Iterable} promises an iterable of promises to wait for. | ||
* @static | ||
* @return {Parse.Promise} the new promise. | ||
*/ | ||
}, { | ||
key: 'race', | ||
value: function race(promises) { | ||
var completed = false; | ||
var promise = new ParsePromise(); | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
try { | ||
for (var _iterator2 = _getIterator(promises), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var p = _step2.value; | ||
if (ParsePromise.is(p)) { | ||
p.then(function (result) { | ||
if (completed) { | ||
return; | ||
} | ||
completed = true; | ||
promise.resolve(result); | ||
}, function (error) { | ||
if (completed) { | ||
return; | ||
} | ||
completed = true; | ||
promise.reject(error); | ||
}); | ||
} else if (!completed) { | ||
completed = true; | ||
promise.resolve(p); | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2['return']) { | ||
_iterator2['return'](); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
} | ||
} | ||
return promise; | ||
} | ||
/** | ||
* Runs the given asyncFunction repeatedly, as long as the predicate | ||
@@ -504,0 +672,0 @@ * function returns a truthy value. Stops repeating if asyncFunction returns |
@@ -1099,2 +1099,15 @@ /** | ||
/** | ||
* Subscribe this query to get liveQuery updates | ||
* @method subscribe | ||
* @return {LiveQuerySubscription} Returns the liveQuerySubscription, it's an event emitter | ||
* which can be used to get liveQuery updates. | ||
*/ | ||
}, { | ||
key: 'subscribe', | ||
value: function subscribe() { | ||
var controller = _CoreManager2['default'].getLiveQueryController(); | ||
return controller.subscribe(this); | ||
} | ||
/** | ||
* Constructs a Parse.Query that is the OR of the passed in queries. For | ||
@@ -1101,0 +1114,0 @@ * example: |
@@ -437,2 +437,5 @@ /** | ||
} | ||
if (options.hasOwnProperty('installationId')) { | ||
signupOptions.installationId = options.installationId; | ||
} | ||
@@ -466,2 +469,5 @@ var controller = _CoreManager2['default'].getUserController(); | ||
} | ||
if (options.hasOwnProperty('installationId')) { | ||
loginOptions.installationId = options.installationId; | ||
} | ||
@@ -494,8 +500,8 @@ var controller = _CoreManager2['default'].getUserController(); | ||
/** | ||
* Wrap the default fetch behavior with functionality to save to local | ||
* storage if this is current user. | ||
* Wrap the default destroy behavior with functionality that logs out | ||
* the current user when it is destroyed | ||
*/ | ||
}, { | ||
key: 'fetch', | ||
value: function fetch() { | ||
key: 'destroy', | ||
value: function destroy() { | ||
var _this4 = this; | ||
@@ -507,5 +513,5 @@ | ||
return _get(Object.getPrototypeOf(ParseUser.prototype), 'fetch', this).apply(this, args).then(function () { | ||
return _get(Object.getPrototypeOf(ParseUser.prototype), 'destroy', this).apply(this, args).then(function () { | ||
if (_this4.isCurrent()) { | ||
return _CoreManager2['default'].getUserController().updateUserOnDisk(_this4); | ||
return _CoreManager2['default'].getUserController().removeUserFromDisk(); | ||
} | ||
@@ -515,2 +521,23 @@ return _this4; | ||
} | ||
/** | ||
* Wrap the default fetch behavior with functionality to save to local | ||
* storage if this is current user. | ||
*/ | ||
}, { | ||
key: 'fetch', | ||
value: function fetch() { | ||
var _this5 = this; | ||
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
args[_key3] = arguments[_key3]; | ||
} | ||
return _get(Object.getPrototypeOf(ParseUser.prototype), 'fetch', this).apply(this, args).then(function () { | ||
if (_this5.isCurrent()) { | ||
return _CoreManager2['default'].getUserController().updateUserOnDisk(_this5); | ||
} | ||
return _this5; | ||
}); | ||
} | ||
}], [{ | ||
@@ -852,2 +879,9 @@ key: 'readOnlyAttributes', | ||
removeUserFromDisk: function removeUserFromDisk() { | ||
var path = _Storage2['default'].generatePath(CURRENT_USER_KEY); | ||
currentUserCacheMatchesDisk = true; | ||
currentUserCache = null; | ||
return _Storage2['default'].removeItemAsync(path); | ||
}, | ||
setCurrentUser: function setCurrentUser(user) { | ||
@@ -854,0 +888,0 @@ currentUserCache = user; |
@@ -165,3 +165,6 @@ /** | ||
payload._ApplicationId = _CoreManager2['default'].get('APPLICATION_ID'); | ||
payload._JavaScriptKey = _CoreManager2['default'].get('JAVASCRIPT_KEY'); | ||
var jsKey = _CoreManager2['default'].get('JAVASCRIPT_KEY'); | ||
if (jsKey) { | ||
payload._JavaScriptKey = jsKey; | ||
} | ||
payload._ClientVersion = _CoreManager2['default'].get('VERSION'); | ||
@@ -186,5 +189,12 @@ | ||
var installationController = _CoreManager2['default'].getInstallationController(); | ||
var installationId = options.installationId; | ||
var installationIdPromise; | ||
if (installationId && typeof installationId === 'string') { | ||
installationIdPromise = _ParsePromise2['default'].as(installationId); | ||
} else { | ||
var installationController = _CoreManager2['default'].getInstallationController(); | ||
installationIdPromise = installationController.currentInstallationId(); | ||
} | ||
return installationController.currentInstallationId().then(function (iid) { | ||
return installationIdPromise.then(function (iid) { | ||
payload._InstallationId = iid; | ||
@@ -191,0 +201,0 @@ var userController = _CoreManager2['default'].getUserController(); |
@@ -38,2 +38,3 @@ /** | ||
exports.enqueueTask = enqueueTask; | ||
exports.duplicateState = duplicateState; | ||
exports.clearAllState = clearAllState; | ||
@@ -155,4 +156,21 @@ | ||
function duplicateState(source, dest) { | ||
var oldState = initializeState(source); | ||
var newState = initializeState(dest); | ||
for (var key in oldState.serverData) { | ||
newState.serverData[key] = oldState.serverData[key]; | ||
} | ||
for (var index = 0; index < oldState.pendingOps.length; index++) { | ||
for (var key in oldState.pendingOps[index]) { | ||
newState.pendingOps[index][key] = oldState.pendingOps[index][key]; | ||
} | ||
} | ||
for (var key in oldState.objectCache) { | ||
newState.objectCache[key] = oldState.objectCache[key]; | ||
} | ||
newState.existed = oldState.existed; | ||
} | ||
function clearAllState() { | ||
objectState = new _WeakMap(); | ||
} |
@@ -19,3 +19,4 @@ /** | ||
SERVER_URL: 'https://api.parse.com/1', | ||
VERSION: 'js' + '1.7.1', | ||
LIVEQUERY_SERVER_URL: null, | ||
VERSION: 'js' + '1.8.0-rc2', | ||
APPLICATION_ID: null, | ||
@@ -290,3 +291,23 @@ JAVASCRIPT_KEY: null, | ||
return config['UserController']; | ||
}, | ||
setLiveQueryController: function setLiveQueryController(controller) { | ||
if (typeof controller.subscribe !== 'function') { | ||
throw new Error('LiveQueryController must implement subscribe()'); | ||
} | ||
if (typeof controller.unsubscribe !== 'function') { | ||
throw new Error('LiveQueryController must implement unsubscribe()'); | ||
} | ||
if (typeof controller.open !== 'function') { | ||
throw new Error('LiveQueryController must implement open()'); | ||
} | ||
if (typeof controller.close !== 'function') { | ||
throw new Error('LiveQueryController must implement close()'); | ||
} | ||
config['LiveQueryController'] = controller; | ||
}, | ||
getLiveQueryController: function getLiveQueryController() { | ||
return config['LiveQueryController']; | ||
} | ||
}; |
@@ -51,3 +51,3 @@ /** | ||
* @param {String} applicationId Your Parse Application ID. | ||
* @param {String} javaScriptKey Your Parse JavaScript Key. | ||
* @param {String} javaScriptKey (optional) Your Parse JavaScript Key (Not needed for parse-server) | ||
* @param {String} masterKey (optional) Your Parse Master Key. (Node.js only!) | ||
@@ -101,2 +101,10 @@ * @static | ||
}); | ||
Object.defineProperty(Parse, 'liveQueryServerURL', { | ||
get: function get() { | ||
return _CoreManager2['default'].get('LIVEQUERY_SERVER_URL'); | ||
}, | ||
set: function set(value) { | ||
_CoreManager2['default'].set('LIVEQUERY_SERVER_URL', value); | ||
} | ||
}); | ||
/** End setters **/ | ||
@@ -132,2 +140,4 @@ | ||
Parse.User = require('./ParseUser'); | ||
Parse.LiveQuery = require('./ParseLiveQuery'); | ||
Parse.LiveQueryClient = require('./LiveQueryClient'); | ||
@@ -134,0 +144,0 @@ Parse._request = function () { |
@@ -830,3 +830,3 @@ /** | ||
/** | ||
* Creates a new model with identical attributes to this one. | ||
* Creates a new model with identical attributes to this one, similar to Backbone.Model's clone() | ||
* @method clone | ||
@@ -862,2 +862,25 @@ * @return {Parse.Object} | ||
/** | ||
* Creates a new instance of this object. Not to be confused with clone() | ||
* @method newInstance | ||
* @return {Parse.Object} | ||
*/ | ||
}, { | ||
key: 'newInstance', | ||
value: function newInstance() { | ||
var clone = new this.constructor(); | ||
if (!clone.className) { | ||
clone.className = this.className; | ||
} | ||
clone.id = this.id; | ||
if (singleInstance) { | ||
// Just return an object with the right id | ||
return clone; | ||
} | ||
var stateController = _CoreManager2['default'].getObjectStateController(); | ||
stateController.duplicateState(this._getStateIdentifier(), clone._getStateIdentifier()); | ||
return clone; | ||
} | ||
/** | ||
* Returns true if this object has never been saved to Parse. | ||
@@ -864,0 +887,0 @@ * @method isNew |
@@ -16,2 +16,4 @@ /** | ||
var _getIterator = require('babel-runtime/core-js/get-iterator')['default']; | ||
Object.defineProperty(exports, '__esModule', { | ||
@@ -238,2 +240,3 @@ value: true | ||
* Add handlers to be called when the Promise object is rejected | ||
* Alias for catch(). | ||
* @method fail | ||
@@ -248,2 +251,12 @@ */ | ||
/** | ||
* Add handlers to be called when the Promise object is rejected | ||
* @method catch | ||
*/ | ||
}, { | ||
key: 'catch', | ||
value: function _catch(callback) { | ||
return this.then(null, callback); | ||
} | ||
/** | ||
* Run the given callbacks after this promise is fulfilled. | ||
@@ -502,2 +515,157 @@ * @method _thenRunCallbacks | ||
/** | ||
* Returns a new promise that is fulfilled when all of the promises in the | ||
* iterable argument are resolved. If any promise in the list fails, then | ||
* the returned promise will be immediately rejected with the reason that | ||
* single promise rejected. If they all succeed, then the returned promise | ||
* will succeed, with the results being the results of all the input | ||
* promises. If the iterable provided is empty, the returned promise will | ||
* be immediately resolved. | ||
* | ||
* For example: <pre> | ||
* var p1 = Parse.Promise.as(1); | ||
* var p2 = Parse.Promise.as(2); | ||
* var p3 = Parse.Promise.as(3); | ||
* | ||
* Parse.Promise.all([p1, p2, p3]).then(function([r1, r2, r3]) { | ||
* console.log(r1); // prints 1 | ||
* console.log(r2); // prints 2 | ||
* console.log(r3); // prints 3 | ||
* });</pre> | ||
* | ||
* @method all | ||
* @param {Iterable} promises an iterable of promises to wait for. | ||
* @static | ||
* @return {Parse.Promise} the new promise. | ||
*/ | ||
}, { | ||
key: 'all', | ||
value: function all(promises) { | ||
var total = 0; | ||
var objects = []; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = _getIterator(promises), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var p = _step.value; | ||
objects[total++] = p; | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator['return']) { | ||
_iterator['return'](); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
if (total === 0) { | ||
return ParsePromise.as([]); | ||
} | ||
var hadError = false; | ||
var promise = new ParsePromise(); | ||
var resolved = 0; | ||
var results = []; | ||
objects.forEach(function (object, i) { | ||
if (ParsePromise.is(object)) { | ||
object.then(function (result) { | ||
if (hadError) { | ||
return false; | ||
} | ||
results[i] = result; | ||
resolved++; | ||
if (resolved >= total) { | ||
promise.resolve(results); | ||
} | ||
}, function (error) { | ||
// Reject immediately | ||
promise.reject(error); | ||
hadError = true; | ||
}); | ||
} else { | ||
results[i] = object; | ||
resolved++; | ||
if (!hadError && resolved >= total) { | ||
promise.resolve(results); | ||
} | ||
} | ||
}); | ||
return promise; | ||
} | ||
/** | ||
* Returns a new promise that is immediately fulfilled when any of the | ||
* promises in the iterable argument are resolved or rejected. If the | ||
* first promise to complete is resolved, the returned promise will be | ||
* resolved with the same value. Likewise, if the first promise to | ||
* complete is rejected, the returned promise will be rejected with the | ||
* same reason. | ||
* | ||
* @method race | ||
* @param {Iterable} promises an iterable of promises to wait for. | ||
* @static | ||
* @return {Parse.Promise} the new promise. | ||
*/ | ||
}, { | ||
key: 'race', | ||
value: function race(promises) { | ||
var completed = false; | ||
var promise = new ParsePromise(); | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
try { | ||
for (var _iterator2 = _getIterator(promises), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var p = _step2.value; | ||
if (ParsePromise.is(p)) { | ||
p.then(function (result) { | ||
if (completed) { | ||
return; | ||
} | ||
completed = true; | ||
promise.resolve(result); | ||
}, function (error) { | ||
if (completed) { | ||
return; | ||
} | ||
completed = true; | ||
promise.reject(error); | ||
}); | ||
} else if (!completed) { | ||
completed = true; | ||
promise.resolve(p); | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2['return']) { | ||
_iterator2['return'](); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
} | ||
} | ||
return promise; | ||
} | ||
/** | ||
* Runs the given asyncFunction repeatedly, as long as the predicate | ||
@@ -504,0 +672,0 @@ * function returns a truthy value. Stops repeating if asyncFunction returns |
@@ -1099,2 +1099,15 @@ /** | ||
/** | ||
* Subscribe this query to get liveQuery updates | ||
* @method subscribe | ||
* @return {LiveQuerySubscription} Returns the liveQuerySubscription, it's an event emitter | ||
* which can be used to get liveQuery updates. | ||
*/ | ||
}, { | ||
key: 'subscribe', | ||
value: function subscribe() { | ||
var controller = _CoreManager2['default'].getLiveQueryController(); | ||
return controller.subscribe(this); | ||
} | ||
/** | ||
* Constructs a Parse.Query that is the OR of the passed in queries. For | ||
@@ -1101,0 +1114,0 @@ * example: |
@@ -437,2 +437,5 @@ /** | ||
} | ||
if (options.hasOwnProperty('installationId')) { | ||
signupOptions.installationId = options.installationId; | ||
} | ||
@@ -466,2 +469,5 @@ var controller = _CoreManager2['default'].getUserController(); | ||
} | ||
if (options.hasOwnProperty('installationId')) { | ||
loginOptions.installationId = options.installationId; | ||
} | ||
@@ -494,8 +500,8 @@ var controller = _CoreManager2['default'].getUserController(); | ||
/** | ||
* Wrap the default fetch behavior with functionality to save to local | ||
* storage if this is current user. | ||
* Wrap the default destroy behavior with functionality that logs out | ||
* the current user when it is destroyed | ||
*/ | ||
}, { | ||
key: 'fetch', | ||
value: function fetch() { | ||
key: 'destroy', | ||
value: function destroy() { | ||
var _this4 = this; | ||
@@ -507,5 +513,5 @@ | ||
return _get(Object.getPrototypeOf(ParseUser.prototype), 'fetch', this).apply(this, args).then(function () { | ||
return _get(Object.getPrototypeOf(ParseUser.prototype), 'destroy', this).apply(this, args).then(function () { | ||
if (_this4.isCurrent()) { | ||
return _CoreManager2['default'].getUserController().updateUserOnDisk(_this4); | ||
return _CoreManager2['default'].getUserController().removeUserFromDisk(); | ||
} | ||
@@ -515,2 +521,23 @@ return _this4; | ||
} | ||
/** | ||
* Wrap the default fetch behavior with functionality to save to local | ||
* storage if this is current user. | ||
*/ | ||
}, { | ||
key: 'fetch', | ||
value: function fetch() { | ||
var _this5 = this; | ||
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
args[_key3] = arguments[_key3]; | ||
} | ||
return _get(Object.getPrototypeOf(ParseUser.prototype), 'fetch', this).apply(this, args).then(function () { | ||
if (_this5.isCurrent()) { | ||
return _CoreManager2['default'].getUserController().updateUserOnDisk(_this5); | ||
} | ||
return _this5; | ||
}); | ||
} | ||
}], [{ | ||
@@ -852,2 +879,9 @@ key: 'readOnlyAttributes', | ||
removeUserFromDisk: function removeUserFromDisk() { | ||
var path = _Storage2['default'].generatePath(CURRENT_USER_KEY); | ||
currentUserCacheMatchesDisk = true; | ||
currentUserCache = null; | ||
return _Storage2['default'].removeItemAsync(path); | ||
}, | ||
setCurrentUser: function setCurrentUser(user) { | ||
@@ -854,0 +888,0 @@ currentUserCache = user; |
@@ -163,3 +163,6 @@ /** | ||
payload._ApplicationId = _CoreManager2['default'].get('APPLICATION_ID'); | ||
payload._JavaScriptKey = _CoreManager2['default'].get('JAVASCRIPT_KEY'); | ||
var jsKey = _CoreManager2['default'].get('JAVASCRIPT_KEY'); | ||
if (jsKey) { | ||
payload._JavaScriptKey = jsKey; | ||
} | ||
payload._ClientVersion = _CoreManager2['default'].get('VERSION'); | ||
@@ -184,5 +187,12 @@ | ||
var installationController = _CoreManager2['default'].getInstallationController(); | ||
var installationId = options.installationId; | ||
var installationIdPromise; | ||
if (installationId && typeof installationId === 'string') { | ||
installationIdPromise = _ParsePromise2['default'].as(installationId); | ||
} else { | ||
var installationController = _CoreManager2['default'].getInstallationController(); | ||
installationIdPromise = installationController.currentInstallationId(); | ||
} | ||
return installationController.currentInstallationId().then(function (iid) { | ||
return installationIdPromise.then(function (iid) { | ||
payload._InstallationId = iid; | ||
@@ -189,0 +199,0 @@ var userController = _CoreManager2['default'].getUserController(); |
@@ -38,2 +38,3 @@ /** | ||
exports.enqueueTask = enqueueTask; | ||
exports.duplicateState = duplicateState; | ||
exports.clearAllState = clearAllState; | ||
@@ -155,4 +156,21 @@ | ||
function duplicateState(source, dest) { | ||
var oldState = initializeState(source); | ||
var newState = initializeState(dest); | ||
for (var key in oldState.serverData) { | ||
newState.serverData[key] = oldState.serverData[key]; | ||
} | ||
for (var index = 0; index < oldState.pendingOps.length; index++) { | ||
for (var key in oldState.pendingOps[index]) { | ||
newState.pendingOps[index][key] = oldState.pendingOps[index][key]; | ||
} | ||
} | ||
for (var key in oldState.objectCache) { | ||
newState.objectCache[key] = oldState.objectCache[key]; | ||
} | ||
newState.existed = oldState.existed; | ||
} | ||
function clearAllState() { | ||
objectState = new _WeakMap(); | ||
} |
{ | ||
"name": "parse", | ||
"version": "1.7.1", | ||
"version": "1.8.0-rc2", | ||
"description": "The Parse JavaScript SDK", | ||
@@ -32,2 +32,3 @@ "homepage": "https://www.parse.com", | ||
"babel-runtime": "^5.8.20", | ||
"ws": "^1.0.1", | ||
"xmlhttprequest": "^1.7.0" | ||
@@ -34,0 +35,0 @@ }, |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
1575068
138
40791
3
2
+ Addedws@^1.0.1
+ Addedoptions@0.0.6(transitive)
+ Addedultron@1.0.2(transitive)
+ Addedws@1.1.5(transitive)