Skip to content

Commit 3676b34

Browse files
committed
chore(release): v3.0.0-beta.0
1 parent 4d52410 commit 3676b34

File tree

5 files changed

+54
-6
lines changed

5 files changed

+54
-6
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": "leancloud-storage",
3-
"version": "2.1.2",
3+
"version": "3.0.0-beta.0",
44
"homepage": "https://github.com/leancloud/javascript-sdk",
55
"authors": [
66
"LeanCloud <support@leancloud.rocks>"

changelog.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1+
# 3.0.0-beta.0 (2017-02-22)
2+
### Breaking Changes
3+
重新设计了 `AV.Object` 序列化相关的方法:
4+
- 如果需要将 `AV.Object` 中的有效信息转换成 JSON Object,请使用 `AV.Object#toJSON` 方法。请注意通过此方法得到的 JSON 不包含对象的元信息,因此是不可逆的(无法转换回 `AV.Object`)。
5+
- 如果需要「存储」或「传输」`AV.Object`,请使用新增的 `AV.Object#toFullJSON`(序列化)与 `AV.parseJSON`(反序列化)方法。
6+
7+
新版中的 `AV.Object#toJSON` 相比于 v2 有以下区别:
8+
- 如果对象某个字段类型是 Pointer,并且有内容(included),新版中会递归地输出这个字段的有效信息(旧版中会输出一个 Pointer 结构)
9+
<details>
10+
11+
```javascript
12+
new AV.Query('Child').include('father').first()
13+
.then(child => child.toJSON().father)
14+
.then(console.log);
15+
/*
16+
v3: {
17+
objectId: "58a461118d6d8100580a0c54",
18+
name: "John Doe",
19+
createdAt: "2017-02-15T14:08:39.892Z",
20+
updatedAt: "2017-02-16T10:49:00.176Z"
21+
}
22+
v2: {
23+
objectId: "58a461118d6d8100580a0c54",
24+
__type: "Pointer",
25+
className: "Parent",
26+
}
27+
```
28+
29+
- 如果字段的类型是 `Date`,新版中会输出该时间的 UTC 格式字符串(旧版中会输出一个 Date 结构)
30+
<details>
31+
32+
```javascript
33+
const child = new Child().set('birthday', new Data());
34+
console.log(child.toJSON().birthday);
35+
/*
36+
v3: "2011-11-11T03:11:11.000Z"
37+
v2: {
38+
__type: "Date",
39+
iso: "2011-11-11T03:11:11.000Z"
40+
}
41+
```
42+
43+
更多背景与技术细节请参考 [#453](https://github.com/leancloud/javascript-sdk/pull/453#issue-208346693).
44+
45+
146
## 2.1.2 (2017-02-17)
247
### Bug Fixes
348
* 修复了文件上传时,如果 `fileName` 没有指定扩展名会导致上传文件 `mime-type` 不符合预期的问题

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "leancloud-storage",
3-
"version": "2.1.2",
3+
"version": "3.0.0-beta.0",
44
"main": "./dist/node/index.js",
55
"description": "LeanCloud JavaScript SDK.",
66
"repository": {

src/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = '2.1.2';
1+
module.exports = '3.0.0-beta.0';

storage.d.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ declare namespace AV {
116116
* this is omitted, the content type will be inferred from the name's
117117
* extension.
118118
*/
119-
export class File {
119+
export class File extends BaseObject {
120120

121121
constructor(name: string, data: any, type?: string);
122122
static withURL(name: string, url: string): File;
@@ -134,6 +134,7 @@ declare namespace AV {
134134
setACL(acl?: ACL): any;
135135
size(): any;
136136
thumbnailURL(width: number, height: number): string;
137+
toFullJSON(): any;
137138
}
138139

139140
/**
@@ -268,7 +269,7 @@ declare namespace AV {
268269
setACL(acl: ACL, options?: Object.SetOptions): boolean;
269270
unset(attr: string, options?: Object.SetOptions): any;
270271
validate(attrs: any): any;
271-
272+
toFullJSON(): any;
272273
}
273274

274275
export namespace Object {
@@ -689,6 +690,8 @@ declare namespace AV {
689690
/**
690691
*options : {appId:'',appKey:'',masterKey:''}
691692
*/
692-
export function init(options: any): void;
693+
export function init(options: { appId: string, appKey: string, masterKey?: string}): void;
694+
695+
export function parseJSON(json: any): Object|File|any;
693696
}
694697
export = AV;

0 commit comments

Comments
 (0)