Skip to content

Commit 3f96d5d

Browse files
committed
chore(release): 1.0.0-rc7
1 parent 43102d7 commit 3f96d5d

File tree

6 files changed

+70
-16
lines changed

6 files changed

+70
-16
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "avoscloud-sdk",
3-
"version": "1.0.0-rc6",
3+
"version": "1.0.0-rc7",
44
"homepage": "https://github.com/leancloud/javascript-sdk",
55
"authors": [
66
"killme2008 <[email protected]>"

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.0.0-rc7 日期:2016 年 2 月 16 日
2+
* 添加 AV.Cloud.rpc 方法
3+
* 修复了 `AV.User#fetch` 不会运行回调函数的 bug。
4+
15
# 1.0.0-rc6 日期:2016 年 2 月 1 日
26
* 修复了云引擎中文件上传到 AWS 的问题。
37
* 修复了 `AV.User#fetch` 不支持 fetch options 的问题。

dist/av-mini.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/av.js

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ module.exports = function _ajax(method, url, data, success, error) {
338338
try {
339339
response = JSON.parse(xhr.responseText);
340340
} catch (e) {
341+
e.statusCode = xhr.status;
342+
e.responseText = xhr.responseText;
341343
promise.reject(e);
342344
}
343345
if (response) {
@@ -584,6 +586,25 @@ module.exports = function(AV) {
584586
})._thenRunCallbacks(options);
585587
},
586588

589+
/**
590+
* Makes a call to a cloud function, you can send {AV.Object} as param or a field of param; the response
591+
* from server will also be parsed as an {AV.Object}, array of {AV.Object}, or object includes {AV.Object}
592+
* @param {String} name The function name.
593+
* @param {Object} data The parameters to send to the cloud function.
594+
* @param {Object} options A Backbone-style options object.
595+
* @return {AV.Promise} A promise that will be resolved with the result of the function.
596+
*/
597+
rpc: function(name, data, options) {
598+
if (_.isArray(data)) {
599+
return AV.Promise.error(new Error('Can\'t pass Array as the param of rpc function in JavaScript SDK.'))
600+
._thenRunCallbacks(options);
601+
}
602+
603+
return AV._request('call', name, null, 'POST', AV._encodeObjectOrArray(data)).then(function(resp) {
604+
return AV._decode('', resp).result;
605+
})._thenRunCallbacks(options);
606+
},
607+
587608
/**
588609
* Make a call to request server date time.
589610
* @param {Object} options A Backbone-style options object
@@ -5109,7 +5130,7 @@ module.exports = function(AV) {
51095130
if(!objectId) {
51105131
var errorObject = new AV.Error(AV.Error.OBJECT_NOT_FOUND,
51115132
"Object not found.");
5112-
return AV.Promise.error(errorObject);
5133+
throw errorObject;
51135134
}
51145135

51155136
var self = this;
@@ -7031,7 +7052,7 @@ module.exports = function(AV) {
70317052
if (options && options.error) {
70327053
options.error(this, error);
70337054
}
7034-
return AV.Promise.error(error);
7055+
throw error;
70357056
}
70367057

70377058
var password = (attrs && attrs.password) || this.get("password");
@@ -7042,7 +7063,7 @@ module.exports = function(AV) {
70427063
if (options && options.error) {
70437064
options.error(this, error);
70447065
}
7045-
return AV.Promise.error(error);
7066+
throw error;
70467067
}
70477068

70487069
return this.save(attrs, filterOutCallbacks(options)).then(function(model) {
@@ -7084,7 +7105,7 @@ module.exports = function(AV) {
70847105
if (options && options.error) {
70857106
options.error(this, error);
70867107
}
7087-
return AV.Promise.error(error);
7108+
throw error;
70887109
}
70897110

70907111
var smsCode = (attrs && attrs.smsCode) || this.get("smsCode");
@@ -7096,7 +7117,7 @@ module.exports = function(AV) {
70967117
if (options && options.error) {
70977118
options.error(this, error);
70987119
}
7099-
return AV.Promise.error(error);
7120+
throw error;
71007121
}
71017122

71027123
var newOptions = filterOutCallbacks(options);
@@ -7232,7 +7253,15 @@ module.exports = function(AV) {
72327253
/**
72337254
* @see AV.Object#fetch
72347255
*/
7235-
fetch: function(fetchOptions, options) {
7256+
fetch: function() {
7257+
var options = null;
7258+
var fetchOptions = {};
7259+
if(arguments.length === 1) {
7260+
options = arguments[0];
7261+
} else if(arguments.length === 2) {
7262+
fetchOptions = arguments[0];
7263+
options = arguments[1];
7264+
}
72367265
return AV.Object.prototype.fetch.call(this, fetchOptions, {})
72377266
.then(function(model) {
72387267
return model._handleSaveResult(false).then(function() {
@@ -7517,9 +7546,9 @@ module.exports = function(AV) {
75177546
* logged in user using <code>current</code>.
75187547
*
75197548
* <p>Calls options.success or options.error on completion.</p>
7520-
*
7549+
*
75217550
* @param {Object} data The response json data returned from third party token.
7522-
* @param {string} platform Available platform for sign up.
7551+
* @param {string} platform Available platform for sign up.
75237552
* @param {Object} [callback] An object that has an optional success function, that takes no arguments and will be called on a successful puSH. and an error function that takes a AV.Error and will be called if the push failed.
75247553
* @return {AV.Promise} A promise that is fulfilled with the user when
75257554
* the login completes.
@@ -8141,6 +8170,7 @@ module.exports = function(AV) {
81418170
route !== "files" &&
81428171
route !== "date" &&
81438172
route !== "functions" &&
8173+
route !== "call" &&
81448174
route !== "login" &&
81458175
route !== "push" &&
81468176
route !== "search/select" &&
@@ -8391,6 +8421,26 @@ module.exports = function(AV) {
83918421
return value;
83928422
};
83938423

8424+
AV._encodeObjectOrArray = function(value) {
8425+
var encodeAVObject = function(object) {
8426+
if (object && object._toFullJSON){
8427+
object = object._toFullJSON([]);
8428+
}
8429+
8430+
return _.mapObject(object, function(value) {
8431+
return AV._encode(value, []);
8432+
});
8433+
};
8434+
8435+
if (_.isArray(value)) {
8436+
return value.map(function(object) {
8437+
return encodeAVObject(object);
8438+
});
8439+
} else {
8440+
return encodeAVObject(value);
8441+
}
8442+
};
8443+
83948444
AV._arrayEach = AV._.each;
83958445

83968446
/**
@@ -8464,7 +8514,7 @@ module.exports = function(AV) {
84648514
},{"./browserify-wrapper/ajax":4,"_process":29,"underscore":30}],26:[function(require,module,exports){
84658515
'use strict';
84668516

8467-
module.exports = "js1.0.0-rc6";
8517+
module.exports = "js1.0.0-rc7";
84688518

84698519
},{}],27:[function(require,module,exports){
84708520

lib/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
'use strict';
22

3-
module.exports = "js1.0.0-rc6";
3+
module.exports = "js1.0.0-rc7";

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "avoscloud-sdk",
3-
"version": "1.0.0-rc6",
3+
"version": "1.0.0-rc7",
44
"main": "./lib/av.js",
55
"description": "AVOSCloud JavaScript SDK.",
66
"repository": {

0 commit comments

Comments
 (0)