Skip to content

Commit 406d2b0

Browse files
committed
Release 0.5.6
1 parent 8df433f commit 406d2b0

File tree

4 files changed

+73
-293
lines changed

4 files changed

+73
-293
lines changed

dist/av-core-mini.js

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

dist/av-core.js

Lines changed: 33 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(function(root) {
22
root.AV = root.AV || {};
3-
root.AV.VERSION = "js0.5.5";
3+
root.AV.VERSION = "js0.5.6";
44
}(this));
55

66
// Underscore.js 1.4.4
@@ -1329,7 +1329,7 @@
13291329
};
13301330

13311331
// Set the server for AV to talk to.
1332-
AV.serverURL = "https://cn.avoscloud.com";
1332+
AV.serverURL = "https://api.leancloud.cn";
13331333

13341334
// Check whether we are running in Node.js.
13351335
if (typeof(process) !== "undefined" &&
@@ -1360,6 +1360,9 @@
13601360
* @param {String} applicationKey Your AV Application Key
13611361
*/
13621362
AV._initialize = function(applicationId, applicationKey, masterKey) {
1363+
if (AV.applicationId !== undefined) {
1364+
console.warn('AVOSCloud SDK is already initialized, please don\'t reinitialize it.');
1365+
}
13631366
AV.applicationId = applicationId;
13641367
AV.applicationKey = applicationKey;
13651368
AV.masterKey = masterKey;
@@ -1643,7 +1646,7 @@
16431646
if (objectId) {
16441647
url += "/" + objectId;
16451648
}
1646-
if((route ==='users' || route === 'classes') && method === 'PUT' && dataObject._fetchWhenSave){
1649+
if((route ==='users' || route === 'classes') && dataObject._fetchWhenSave){
16471650
delete dataObject._fetchWhenSave;
16481651
url += '?new=true';
16491652
}
@@ -3552,7 +3555,16 @@
35523555

35533556
_.extend(AV.Promise, /** @lends AV.Promise */ {
35543557

3555-
_isPromisesAPlusCompliant: true,
3558+
_isPromisesAPlusCompliant: !AV._isNode,
3559+
_debugError: false,
3560+
3561+
setPromisesAPlusCompliant: function(isCompliant) {
3562+
AV.Promise._isPromisesAPlusCompliant = isCompliant;
3563+
},
3564+
3565+
setDebugError: function(enable) {
3566+
AV.Promise._debugError = enable;
3567+
},
35563568

35573569
/**
35583570
* Returns true iff the given object fulfils the Promise interface.
@@ -3870,6 +3882,9 @@
38703882
try {
38713883
result = [resolvedCallback.apply(this, result)];
38723884
} catch (e) {
3885+
if(AV.Promise._debugError && e) {
3886+
console.error('Error occurred in promise resolve callback.', e.stack || e);
3887+
}
38733888
result = [AV.Promise.error(e)];
38743889
}
38753890
} else {
@@ -3894,6 +3909,9 @@
38943909
try {
38953910
result = [rejectedCallback(error)];
38963911
} catch (e) {
3912+
if(AV.Promise._debugError && e) {
3913+
console.error('Error occurred in promise reject callback.', e.stack || e);
3914+
}
38973915
result = [AV.Promise.error(e)];
38983916
}
38993917
} else {
@@ -3921,8 +3939,14 @@
39213939
func.call();
39223940
};
39233941
if (AV.Promise._isPromisesAPlusCompliant) {
3924-
if (typeof(setImmediate) !== 'undefined' && _.isFunction(setImmediate)) {
3925-
runLater = setImmediate;
3942+
if (typeof(window) !== 'undefined' && _.isFunction(window.setImmediate)) {
3943+
runLater = function(func) {
3944+
window.setImmediate(func);
3945+
};
3946+
} else if (typeof(process) !== 'undefined' && process.nextTick) {
3947+
runLater = function(func) {
3948+
process.nextTick(func);
3949+
};
39263950
} else if (typeof(setTimeout) !== 'undefined' && _.isFunction(setTimeout)) {
39273951
runLater = function(func) {
39283952
setTimeout(func, 0);
@@ -3937,7 +3961,7 @@
39373961
});
39383962
} else if (this._rejected) {
39393963
runLater(function() {
3940-
wrappedRejectedCallback(self._error);
3964+
wrappedRejectedCallback.apply(self, [self._error]);
39413965
});
39423966
} else {
39433967
this._resolvedCallbacks.push(wrappedResolvedCallback);
@@ -5586,7 +5610,7 @@
55865610

55875611
var json = model._getSaveJSON();
55885612

5589-
if(method === 'PUT' && model._fetchWhenSave){
5613+
if(model._fetchWhenSave){
55905614
//Sepcial-case fetchWhenSave when updating object.
55915615
json._fetchWhenSave = true;
55925616
}
@@ -9043,139 +9067,5 @@
90439067
var AV = root.AV;
90449068
var _ = AV._;
90459069

9046-
/**
9047-
* @namespace 包含了使用了 LeanCloud
9048-
* <a href='/docs/bigquery_guide.html'>离线数据分析功能</a>的函数。
9049-
* <p><strong><em>
9050-
* 部分函数仅在云引擎运行环境下有效。
9051-
* </em></strong></p>
9052-
*/
9053-
AV.BigQuery = AV.BigQuery || {};
9054-
9055-
_.extend(AV.BigQuery, /** @lends AV.BigQuery */ {
9056-
9057-
/**
9058-
* 开始一个 BigQuery 任务。结果里将返回 Job id,你可以拿得到的 id 使用
9059-
* AV.BigQuery.JobQuery 查询任务状态和结果。
9060-
* @param {Object} jobConfig 任务配置的 JSON 对象,例如:<code><pre>
9061-
* { "sql" : "select count(*) as c,gender from _User group by gender",
9062-
* "saveAs": {
9063-
* "className" : "UserGender",
9064-
* "limit": 1
9065-
* }
9066-
* }
9067-
* </pre></code>
9068-
* sql 指定任务执行的 SQL 语句, saveAs(可选) 指定将结果保存在哪张表里,limit 最大 1000。
9069-
* @param {Object} options A Backbone-style options object
9070-
* options.success, if set, should be a function to handle a successful
9071-
* call to a cloud function. options.error should be a function that
9072-
* handles an error running the cloud function. Both functions are
9073-
* optional. Both functions take a single argument.
9074-
* @return {AV.Promise} A promise that will be resolved with the result
9075-
* of the function.
9076-
*/
9077-
startJob: function(jobConfig, options) {
9078-
if(!jobConfig || !jobConfig.sql) {
9079-
throw new Error('Please provide the sql to run the job.');
9080-
}
9081-
var data = {
9082-
jobConfig: jobConfig,
9083-
appId: AV.applicationId
9084-
}
9085-
var request = AV._request("bigquery", 'jobs', null, 'POST',
9086-
AV._encode(data, null, true));
9087-
9088-
return request.then(function(resp) {
9089-
return AV._decode(null, resp).id;
9090-
})._thenRunCallbacks(options);
9091-
},
9092-
9093-
/**
9094-
* 监听 BigQuery 任务事件,目前仅支持 end 事件,表示任务完成。
9095-
* <p><strong><em>
9096-
* 仅在云引擎运行环境下有效。
9097-
* </em></strong></p>
9098-
* @param {String} event 监听的事件,目前仅支持 'end' ,表示任务完成
9099-
* @param {Function} 监听回调函数,接收 (err, id) 两个参数,err 表示错误信息,
9100-
* id 表示任务 id。接下来你可以拿这个 id 使用AV.BigQuery.JobQuery 查询任务状态和结果。
9101-
*
9102-
*/
9103-
on: function(event, cb) {
9104-
}
9105-
});
9106-
9107-
/**
9108-
* 创建一个对象,用于查询 BigQuery 任务状态和结果。
9109-
* @class
9110-
* @param {String} id 任务 id
9111-
* @since 0.5.5
9112-
*/
9113-
AV.BigQuery.JobQuery = function(id, className) {
9114-
if(!id) {
9115-
throw new Error('Please provide the job id.');
9116-
}
9117-
this.id = id;
9118-
this.className = className;
9119-
this._skip = 0;
9120-
this._limit = 100;
9121-
};
9122-
9123-
AV.BigQuery.JobQuery.prototype = {
9124-
9125-
/**
9126-
* Sets the number of results to skip before returning any results.
9127-
* This is useful for pagination.
9128-
* Default is to skip zero results.
9129-
* @param {Number} n the number of results to skip.
9130-
* @return {AV.Query} Returns the query, so you can chain this call.
9131-
*/
9132-
skip: function(n) {
9133-
this._skip = n;
9134-
return this;
9135-
},
9136-
9137-
/**
9138-
* Sets the limit of the number of results to return. The default limit is
9139-
* 100, with a maximum of 1000 results being returned at a time.
9140-
* @param {Number} n the number of results to limit to.
9141-
* @return {AV.Query} Returns the query, so you can chain this call.
9142-
*/
9143-
limit: function(n) {
9144-
this._limit = n;
9145-
return this;
9146-
},
9147-
9148-
/**
9149-
* 查询任务状态和结果,任务结果为一个 JSON 对象,包括 status 表示任务状态, totalCount 表示总数,
9150-
* results 数组表示任务结果数组,previewCount 表示可以返回的结果总数,任务的开始和截止时间
9151-
* startTime、endTime 等信息。
9152-
*
9153-
* @param {Object} options A Backbone-style options object
9154-
* options.success, if set, should be a function to handle a successful
9155-
* call to a cloud function. options.error should be a function that
9156-
* handles an error running the cloud function. Both functions are
9157-
* optional. Both functions take a single argument.
9158-
* @return {AV.Promise} A promise that will be resolved with the result
9159-
* of the function.
9160-
*
9161-
*/
9162-
find: function(options) {
9163-
var params = {
9164-
skip: this._skip,
9165-
limit: this._limit
9166-
};
9167-
9168-
var request = AV._request("bigquery", 'jobs', this.id, "GET",
9169-
params);
9170-
var self = this;
9171-
return request.then(function(response) {
9172-
if(response.error) {
9173-
return AV.Promise.error(new AV.Error(response.code, response.error));
9174-
}
9175-
return AV.Promise.as(response);
9176-
})._thenRunCallbacks(options);
9177-
}
9178-
9179-
};
9180-
9070+
AV.BigQuery = AV.Insight || {};
91819071
}(this));

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.

0 commit comments

Comments
 (0)