-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProperty.js
93 lines (87 loc) · 1.96 KB
/
Property.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const { RichTextList } = require("./RichText.js");
// TODO
class DatabaseProperties {
constructor(propertiesObj) {}
get() {}
}
class PageProperties {
constructor(propertiesObj) {
this.srcProperties = propertiesObj;
this.properties = {};
this._convertProperties();
}
_convertProperties() {
for (let name in this.srcProperties) {
let srcProperty = this.srcProperties[name];
switch (srcProperty.type) {
case "rich_text":
this.properties[name] = new RichTextList(srcProperty.rich_text);
break;
case "number":
// TODO
break;
case "select":
// TODO
this.properties[name] = srcProperty.select.name;
break;
case "multi_select":
this.properties[name] = srcProperty.multi_select.map((x) => x.name);
break;
case "date":
// TODO
break;
case "formula":
// TODO
break;
case "relation":
// TODO
break;
case "rollup":
// TODO
break;
case "title":
this.properties[name] = new RichTextList(
srcProperty.title
).toPlainText();
break;
case "people":
// TODO
break;
case "files":
// TODO
break;
case "checkbox":
// TODO
break;
case "url":
this.properties[name] = srcProperty.url;
break;
case "email":
// TODO
break;
case "phone_number":
// TODO
break;
case "created_time":
// TODO
break;
case "created_by":
// TODO
break;
case "last_edited_time":
// TODO
break;
case "last_edited_by":
// TODO
break;
}
}
}
get() {
return this.properties;
}
}
module.exports = {
DatabaseProperties,
PageProperties,
};