@operato/scene-restful 1.1.23 → 1.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/assets/favicon.ico +0 -0
- package/assets/images/spinner.png +0 -0
- package/dist/restful.d.ts +6 -11
- package/dist/restful.js +264 -84
- package/dist/restful.js.map +1 -1
- package/helps/scene/component/restful.ko.md +11 -9
- package/helps/scene/component/restful.md +13 -10
- package/helps/scene/component/restful.zh.md +10 -9
- package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +25 -0
- package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +20 -0
- package/logs/application-2023-01-11-06.log +12 -0
- package/logs/application-2023-01-11-09.log +1 -0
- package/logs/application-2023-01-11-10.log +7 -0
- package/logs/connections-2023-01-11-06.log +35 -0
- package/logs/connections-2023-01-11-10.log +35 -0
- package/package.json +2 -2
- package/src/restful.ts +280 -90
- package/translations/en.json +8 -1
- package/translations/ko.json +8 -1
- package/translations/zh.json +8 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# restful
|
|
2
|
-
提供URL且仅通过URL检索数据时使用的组件。
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
“restful”是利用浏览器的 Fetch API 提供 HTTP 请求功能的组件。
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
- 周期 : 数据查询周期
|
|
8
|
-
- 数据格式 : Plain Text,JSON,JSONP数据格式
|
|
9
|
-
- Plain Text : 服务器以纯文本格式返回数据时使用。
|
|
10
|
-
- JSON : 当服务器以JSON形式提供数据时
|
|
11
|
-
- JSONP : 当以函数形式接收数据时,将接收并处理该函数。
|
|
5
|
+
您可以参考下面链接的文档中的调用函数和每个属性值。
|
|
12
6
|
|
|
13
|
-
-
|
|
7
|
+
https://developer.mozilla.org/zh-CN/docs/Web/API/Fetch_API/Using_Fetch
|
|
8
|
+
|
|
9
|
+
例外)当 dataFormat 是 jsonp(带填充的 JSON)时,不使用 Fetch API。 在这种情况下,只有 URL 参数才有意义。
|
|
10
|
+
|
|
11
|
+
## value property
|
|
12
|
+
|
|
13
|
+
该组件的 value 属性用作 HTTP 请求过程中的正文或 URL。
|
|
14
|
+
在 GET 方法中,它用作 URL,在其他方法中,它用作正文。
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"keep": {
|
|
3
|
+
"days": true,
|
|
4
|
+
"amount": 2
|
|
5
|
+
},
|
|
6
|
+
"auditLog": "logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json",
|
|
7
|
+
"files": [
|
|
8
|
+
{
|
|
9
|
+
"date": 1673384602553,
|
|
10
|
+
"name": "logs/application-2023-01-11-06.log",
|
|
11
|
+
"hash": "3d9686fbb35df488eba187acdab6ce4b720ff09f4f19a6539ad3638f99f2755f"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"date": 1673395277552,
|
|
15
|
+
"name": "logs/application-2023-01-11-09.log",
|
|
16
|
+
"hash": "5d6f40e1c646df1e5b0c7fcd23e354480f3d085cbab8885c5705262b2fcaf1f8"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"date": 1673401669078,
|
|
20
|
+
"name": "logs/application-2023-01-11-10.log",
|
|
21
|
+
"hash": "cc716e1d5c5e79d8c25baa01dfc2811672bd48bd2b3e26473718e3aa540a319a"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"hashType": "sha256"
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"keep": {
|
|
3
|
+
"days": true,
|
|
4
|
+
"amount": 14
|
|
5
|
+
},
|
|
6
|
+
"auditLog": "logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json",
|
|
7
|
+
"files": [
|
|
8
|
+
{
|
|
9
|
+
"date": 1673384603916,
|
|
10
|
+
"name": "logs/connections-2023-01-11-06.log",
|
|
11
|
+
"hash": "e4cd4d89cfbcf7a47f621cc7971532bc8b72e13820c79b04f9f131f20654aab7"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"date": 1673401670303,
|
|
15
|
+
"name": "logs/connections-2023-01-11-10.log",
|
|
16
|
+
"hash": "d8ddd2dc61ffaade0931e39aad31a38247ae670300778a1eb0437af9affe2d62"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"hashType": "sha256"
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
2023-01-11T06:03:22+09:00 info: File Storage is Ready.
|
|
2
|
+
2023-01-11T06:03:24+09:00 error: oracledb module loading failed
|
|
3
|
+
2023-01-11T06:03:34+09:00 info: File Storage is Ready.
|
|
4
|
+
2023-01-11T06:03:35+09:00 error: oracledb module loading failed
|
|
5
|
+
2023-01-11T06:03:36+09:00 info: Default DataSource established
|
|
6
|
+
2023-01-11T06:03:36+09:00 info: Transaction DataSource established
|
|
7
|
+
2023-01-11T06:03:51+09:00 info: File Storage is Ready.
|
|
8
|
+
2023-01-11T06:03:52+09:00 error: oracledb module loading failed
|
|
9
|
+
2023-01-11T06:03:52+09:00 info: Default DataSource established
|
|
10
|
+
2023-01-11T06:03:52+09:00 info: Transaction DataSource established
|
|
11
|
+
2023-01-11T06:03:53+09:00 info: 🚀 Server ready at http://0.0.0.0:3000/graphql
|
|
12
|
+
2023-01-11T06:03:53+09:00 info: 🚀 Subscriptions ready at ws://0.0.0.0:3000/graphql
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2023-01-11T09:01:17+09:00 error: Your license due date is 2023.01.18, please renewal your license!
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
2023-01-11T10:47:49+09:00 info: File Storage is Ready.
|
|
2
|
+
2023-01-11T10:47:50+09:00 error: oracledb module loading failed
|
|
3
|
+
2023-01-11T10:47:51+09:00 info: Default DataSource established
|
|
4
|
+
2023-01-11T10:47:51+09:00 info: Transaction DataSource established
|
|
5
|
+
2023-01-11T10:47:52+09:00 info: 🚀 Server ready at http://0.0.0.0:3000/graphql
|
|
6
|
+
2023-01-11T10:47:52+09:00 info: 🚀 Subscriptions ready at ws://0.0.0.0:3000/graphql
|
|
7
|
+
2023-01-11T10:49:05+09:00 error: Your license due date is 2023.01.18, please renewal your license!
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
2023-01-11T06:03:53+09:00 info: Initializing ConnectionManager...
|
|
2
|
+
2023-01-11T06:03:53+09:00 info: Connector 'echo-back-server' started to ready
|
|
3
|
+
2023-01-11T06:03:53+09:00 info: Connector 'echo-back' started to ready
|
|
4
|
+
2023-01-11T06:03:53+09:00 info: Connector 'http-connector' started to ready
|
|
5
|
+
2023-01-11T06:03:53+09:00 info: Connector 'graphql-connector' started to ready
|
|
6
|
+
2023-01-11T06:03:53+09:00 info: Connector 'sqlite-connector' started to ready
|
|
7
|
+
2023-01-11T06:03:53+09:00 info: Connector 'postgresql-connector' started to ready
|
|
8
|
+
2023-01-11T06:03:53+09:00 info: Connector 'mqtt-connector' started to ready
|
|
9
|
+
2023-01-11T06:03:53+09:00 info: Connector 'mssql-connector' started to ready
|
|
10
|
+
2023-01-11T06:03:53+09:00 info: Connector 'oracle-connector' started to ready
|
|
11
|
+
2023-01-11T06:03:53+09:00 info: Connector 'mysql-connector' started to ready
|
|
12
|
+
2023-01-11T06:03:53+09:00 info: Connector 'socket-server' started to ready
|
|
13
|
+
2023-01-11T06:03:53+09:00 info: echo-back-servers are ready
|
|
14
|
+
2023-01-11T06:03:53+09:00 info: echo-back connections are ready
|
|
15
|
+
2023-01-11T06:03:53+09:00 info: http-connector connections are ready
|
|
16
|
+
2023-01-11T06:03:53+09:00 info: graphql-connector connections are ready
|
|
17
|
+
2023-01-11T06:03:53+09:00 info: sqlite-connector connections are ready
|
|
18
|
+
2023-01-11T06:03:53+09:00 info: postgresql-connector connections are ready
|
|
19
|
+
2023-01-11T06:03:53+09:00 info: mqtt-connector connections are ready
|
|
20
|
+
2023-01-11T06:03:53+09:00 info: mssql-connector connections are ready
|
|
21
|
+
2023-01-11T06:03:53+09:00 info: oracle-connector connections are ready
|
|
22
|
+
2023-01-11T06:03:53+09:00 info: mysql-connector connections are ready
|
|
23
|
+
2023-01-11T06:03:53+09:00 info: socket servers are ready
|
|
24
|
+
2023-01-11T06:03:53+09:00 info: All connector for 'echo-back-server' ready
|
|
25
|
+
2023-01-11T06:03:53+09:00 info: All connector for 'echo-back' ready
|
|
26
|
+
2023-01-11T06:03:53+09:00 info: All connector for 'http-connector' ready
|
|
27
|
+
2023-01-11T06:03:53+09:00 info: All connector for 'graphql-connector' ready
|
|
28
|
+
2023-01-11T06:03:53+09:00 info: All connector for 'sqlite-connector' ready
|
|
29
|
+
2023-01-11T06:03:53+09:00 info: All connector for 'postgresql-connector' ready
|
|
30
|
+
2023-01-11T06:03:53+09:00 info: All connector for 'mqtt-connector' ready
|
|
31
|
+
2023-01-11T06:03:53+09:00 info: All connector for 'mssql-connector' ready
|
|
32
|
+
2023-01-11T06:03:53+09:00 info: All connector for 'oracle-connector' ready
|
|
33
|
+
2023-01-11T06:03:53+09:00 info: All connector for 'mysql-connector' ready
|
|
34
|
+
2023-01-11T06:03:53+09:00 info: All connector for 'socket-server' ready
|
|
35
|
+
2023-01-11T06:03:53+09:00 info: ConnectionManager initialization done:
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
2023-01-11T10:47:52+09:00 info: Initializing ConnectionManager...
|
|
2
|
+
2023-01-11T10:47:52+09:00 info: Connector 'echo-back-server' started to ready
|
|
3
|
+
2023-01-11T10:47:52+09:00 info: Connector 'echo-back' started to ready
|
|
4
|
+
2023-01-11T10:47:52+09:00 info: Connector 'http-connector' started to ready
|
|
5
|
+
2023-01-11T10:47:52+09:00 info: Connector 'graphql-connector' started to ready
|
|
6
|
+
2023-01-11T10:47:52+09:00 info: Connector 'sqlite-connector' started to ready
|
|
7
|
+
2023-01-11T10:47:52+09:00 info: Connector 'postgresql-connector' started to ready
|
|
8
|
+
2023-01-11T10:47:52+09:00 info: Connector 'mqtt-connector' started to ready
|
|
9
|
+
2023-01-11T10:47:52+09:00 info: Connector 'mssql-connector' started to ready
|
|
10
|
+
2023-01-11T10:47:52+09:00 info: Connector 'oracle-connector' started to ready
|
|
11
|
+
2023-01-11T10:47:52+09:00 info: Connector 'mysql-connector' started to ready
|
|
12
|
+
2023-01-11T10:47:52+09:00 info: Connector 'socket-server' started to ready
|
|
13
|
+
2023-01-11T10:47:52+09:00 info: echo-back-servers are ready
|
|
14
|
+
2023-01-11T10:47:52+09:00 info: echo-back connections are ready
|
|
15
|
+
2023-01-11T10:47:52+09:00 info: http-connector connections are ready
|
|
16
|
+
2023-01-11T10:47:52+09:00 info: graphql-connector connections are ready
|
|
17
|
+
2023-01-11T10:47:52+09:00 info: sqlite-connector connections are ready
|
|
18
|
+
2023-01-11T10:47:52+09:00 info: postgresql-connector connections are ready
|
|
19
|
+
2023-01-11T10:47:52+09:00 info: mqtt-connector connections are ready
|
|
20
|
+
2023-01-11T10:47:52+09:00 info: mssql-connector connections are ready
|
|
21
|
+
2023-01-11T10:47:52+09:00 info: oracle-connector connections are ready
|
|
22
|
+
2023-01-11T10:47:52+09:00 info: mysql-connector connections are ready
|
|
23
|
+
2023-01-11T10:47:52+09:00 info: socket servers are ready
|
|
24
|
+
2023-01-11T10:47:52+09:00 info: All connector for 'echo-back-server' ready
|
|
25
|
+
2023-01-11T10:47:52+09:00 info: All connector for 'echo-back' ready
|
|
26
|
+
2023-01-11T10:47:52+09:00 info: All connector for 'http-connector' ready
|
|
27
|
+
2023-01-11T10:47:52+09:00 info: All connector for 'graphql-connector' ready
|
|
28
|
+
2023-01-11T10:47:52+09:00 info: All connector for 'sqlite-connector' ready
|
|
29
|
+
2023-01-11T10:47:52+09:00 info: All connector for 'postgresql-connector' ready
|
|
30
|
+
2023-01-11T10:47:52+09:00 info: All connector for 'mqtt-connector' ready
|
|
31
|
+
2023-01-11T10:47:52+09:00 info: All connector for 'mssql-connector' ready
|
|
32
|
+
2023-01-11T10:47:52+09:00 info: All connector for 'oracle-connector' ready
|
|
33
|
+
2023-01-11T10:47:52+09:00 info: All connector for 'mysql-connector' ready
|
|
34
|
+
2023-01-11T10:47:52+09:00 info: All connector for 'socket-server' ready
|
|
35
|
+
2023-01-11T10:47:52+09:00 info: ConnectionManager initialization done:
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Restful Client Component for Things Scene",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "heartyoh",
|
|
6
|
-
"version": "1.1.
|
|
6
|
+
"version": "1.1.27",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"module": "dist/index.js",
|
|
9
9
|
"things-scene": true,
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"prettier --write"
|
|
58
58
|
]
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "e24dcf77b8d1506f3a645071cd8f0851a9524930"
|
|
61
61
|
}
|
package/src/restful.ts
CHANGED
|
@@ -7,16 +7,40 @@ const NATURE: ComponentNature = {
|
|
|
7
7
|
resizable: true,
|
|
8
8
|
rotatable: true,
|
|
9
9
|
properties: [
|
|
10
|
+
{
|
|
11
|
+
type: 'select',
|
|
12
|
+
label: 'method',
|
|
13
|
+
name: 'method',
|
|
14
|
+
property: {
|
|
15
|
+
options: [
|
|
16
|
+
{
|
|
17
|
+
display: 'GET',
|
|
18
|
+
value: 'GET'
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
display: 'POST',
|
|
22
|
+
value: 'POST'
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
display: 'PUT',
|
|
26
|
+
value: 'PUT'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
display: 'DELETE',
|
|
30
|
+
value: 'DELETE'
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
10
35
|
{
|
|
11
36
|
type: 'string',
|
|
12
37
|
label: 'url',
|
|
13
38
|
name: 'url'
|
|
14
39
|
},
|
|
15
40
|
{
|
|
16
|
-
type: '
|
|
17
|
-
label: '
|
|
18
|
-
name: '
|
|
19
|
-
placeholder: 'SECONDS'
|
|
41
|
+
type: 'string',
|
|
42
|
+
label: 'authorization',
|
|
43
|
+
name: 'authorization'
|
|
20
44
|
},
|
|
21
45
|
{
|
|
22
46
|
type: 'select',
|
|
@@ -25,27 +49,194 @@ const NATURE: ComponentNature = {
|
|
|
25
49
|
property: {
|
|
26
50
|
options: [
|
|
27
51
|
{
|
|
28
|
-
display: '
|
|
52
|
+
display: 'json',
|
|
53
|
+
value: 'json'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
display: 'jsonp',
|
|
57
|
+
value: 'jsonp'
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
display: 'text',
|
|
29
61
|
value: 'text'
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
type: 'select',
|
|
68
|
+
label: 'content-type',
|
|
69
|
+
name: 'contentType',
|
|
70
|
+
property: {
|
|
71
|
+
options: [
|
|
72
|
+
{
|
|
73
|
+
display: 'application/json',
|
|
74
|
+
value: 'application/json'
|
|
30
75
|
},
|
|
31
76
|
{
|
|
32
|
-
display: '
|
|
33
|
-
value: '
|
|
77
|
+
display: 'application/x-www-form-urlencoded',
|
|
78
|
+
value: 'application/x-www-form-urlencoded'
|
|
34
79
|
},
|
|
35
80
|
{
|
|
36
|
-
display: '
|
|
37
|
-
value: '
|
|
81
|
+
display: 'text/plain',
|
|
82
|
+
value: 'text/plain'
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
type: 'select',
|
|
89
|
+
label: 'mode',
|
|
90
|
+
name: 'mode',
|
|
91
|
+
property: {
|
|
92
|
+
options: [
|
|
93
|
+
{
|
|
94
|
+
display: 'cors',
|
|
95
|
+
value: 'cors'
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
display: 'no-cors',
|
|
99
|
+
value: 'no-cors'
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
display: 'same-origin',
|
|
103
|
+
value: 'same-origin'
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
type: 'select',
|
|
110
|
+
label: 'credentials',
|
|
111
|
+
name: 'credentials',
|
|
112
|
+
property: {
|
|
113
|
+
options: [
|
|
114
|
+
{
|
|
115
|
+
display: 'same-origin',
|
|
116
|
+
value: 'same-origin'
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
display: 'include',
|
|
120
|
+
value: 'include'
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
display: 'omit',
|
|
124
|
+
value: 'omit'
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
type: 'select',
|
|
131
|
+
label: 'cache',
|
|
132
|
+
name: 'cache',
|
|
133
|
+
property: {
|
|
134
|
+
options: [
|
|
135
|
+
{
|
|
136
|
+
display: 'default',
|
|
137
|
+
value: 'default'
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
display: 'no-cache',
|
|
141
|
+
value: 'no-cache'
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
display: 'reload',
|
|
145
|
+
value: 'reload'
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
display: 'force-cache',
|
|
149
|
+
value: 'force-cache'
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
display: 'only-if-cached',
|
|
153
|
+
value: 'only-if-cached'
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
type: 'select',
|
|
160
|
+
label: 'redirect',
|
|
161
|
+
name: 'redirect',
|
|
162
|
+
property: {
|
|
163
|
+
options: [
|
|
164
|
+
{
|
|
165
|
+
display: 'follow',
|
|
166
|
+
value: 'follow'
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
display: 'manual',
|
|
170
|
+
value: 'manual'
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
display: 'error',
|
|
174
|
+
value: 'error'
|
|
38
175
|
}
|
|
39
176
|
]
|
|
40
177
|
}
|
|
41
178
|
},
|
|
179
|
+
{
|
|
180
|
+
type: 'select',
|
|
181
|
+
label: 'referrer-policy',
|
|
182
|
+
name: 'referrerPolicy',
|
|
183
|
+
property: {
|
|
184
|
+
options: [
|
|
185
|
+
{
|
|
186
|
+
display: 'no-referrer-when-downgrade',
|
|
187
|
+
value: 'no-referrer-when-downgrade'
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
display: 'no-referrer',
|
|
191
|
+
value: 'no-referrer'
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
display: 'origin',
|
|
195
|
+
value: 'origin'
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
display: 'origin-when-cross-origin',
|
|
199
|
+
value: 'origin-when-cross-origin'
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
display: 'same-origin',
|
|
203
|
+
value: 'same-origin'
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
display: 'strict-origin',
|
|
207
|
+
value: 'strict-origin'
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
display: 'strict-origin-when-cross-origin',
|
|
211
|
+
value: 'strict-origin-when-cross-origin'
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
display: 'unsafe-url',
|
|
215
|
+
value: 'unsafe-url'
|
|
216
|
+
}
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
type: 'select',
|
|
222
|
+
label: 'value-usage',
|
|
223
|
+
name: 'valueUsage',
|
|
224
|
+
property: {
|
|
225
|
+
options: ['body', 'url']
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
type: 'number',
|
|
230
|
+
label: 'period',
|
|
231
|
+
name: 'period',
|
|
232
|
+
placeholder: 'SECONDS'
|
|
233
|
+
},
|
|
42
234
|
{
|
|
43
235
|
type: 'checkbox',
|
|
44
|
-
label: '
|
|
45
|
-
name: '
|
|
236
|
+
label: 'fetch-on-load',
|
|
237
|
+
name: 'fetchOnLoad'
|
|
46
238
|
}
|
|
47
239
|
],
|
|
48
|
-
'value-property': 'url',
|
|
49
240
|
help: 'scene/component/restful'
|
|
50
241
|
}
|
|
51
242
|
|
|
@@ -66,6 +257,9 @@ export default class Restful extends DataSource(RectPath(Shape)) {
|
|
|
66
257
|
return Restful._image
|
|
67
258
|
}
|
|
68
259
|
|
|
260
|
+
private _repeatTimer!: NodeJS.Timeout
|
|
261
|
+
private _isStarted = false
|
|
262
|
+
|
|
69
263
|
get url() {
|
|
70
264
|
return this.getState('url')
|
|
71
265
|
}
|
|
@@ -76,14 +270,23 @@ export default class Restful extends DataSource(RectPath(Shape)) {
|
|
|
76
270
|
}
|
|
77
271
|
|
|
78
272
|
get period() {
|
|
79
|
-
return this.state.period * 1000
|
|
273
|
+
return Number(this.state.period) * 1000
|
|
80
274
|
}
|
|
81
275
|
|
|
82
276
|
set period(period) {
|
|
83
|
-
this.setState('period', period)
|
|
277
|
+
this.setState('period', Number(period))
|
|
84
278
|
this._initRestful()
|
|
85
279
|
}
|
|
86
280
|
|
|
281
|
+
get value() {
|
|
282
|
+
return this.state.value
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
set value(value) {
|
|
286
|
+
this.setState('value', value)
|
|
287
|
+
this._initRestful(true)
|
|
288
|
+
}
|
|
289
|
+
|
|
87
290
|
get withCredentials() {
|
|
88
291
|
return !!this.getState('withCredentials')
|
|
89
292
|
}
|
|
@@ -93,10 +296,6 @@ export default class Restful extends DataSource(RectPath(Shape)) {
|
|
|
93
296
|
this._initRestful()
|
|
94
297
|
}
|
|
95
298
|
|
|
96
|
-
_repeatTimer!: NodeJS.Timeout
|
|
97
|
-
_httpRequest?: any
|
|
98
|
-
_isStarted = false
|
|
99
|
-
|
|
100
299
|
get repeatTimer() {
|
|
101
300
|
return this._repeatTimer
|
|
102
301
|
}
|
|
@@ -106,19 +305,11 @@ export default class Restful extends DataSource(RectPath(Shape)) {
|
|
|
106
305
|
this._repeatTimer = repeatTimer
|
|
107
306
|
}
|
|
108
307
|
|
|
109
|
-
get httpRequest() {
|
|
110
|
-
return this._httpRequest
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
set httpRequest(httpRequest) {
|
|
114
|
-
this._httpRequest = httpRequest
|
|
115
|
-
}
|
|
116
|
-
|
|
117
308
|
ready() {
|
|
118
|
-
this._initRestful()
|
|
309
|
+
this._initRestful(this.state.fetchOnLoad)
|
|
119
310
|
}
|
|
120
311
|
|
|
121
|
-
_initRestful() {
|
|
312
|
+
_initRestful(force: boolean = false) {
|
|
122
313
|
if (!this.app.isViewMode) return
|
|
123
314
|
|
|
124
315
|
if (!this.url) {
|
|
@@ -127,7 +318,11 @@ export default class Restful extends DataSource(RectPath(Shape)) {
|
|
|
127
318
|
}
|
|
128
319
|
|
|
129
320
|
this._stopRepeater()
|
|
130
|
-
this.
|
|
321
|
+
if (this.period > 0) {
|
|
322
|
+
this._startRepeater()
|
|
323
|
+
} else {
|
|
324
|
+
force && this.fetch()
|
|
325
|
+
}
|
|
131
326
|
}
|
|
132
327
|
|
|
133
328
|
dispose() {
|
|
@@ -140,12 +335,11 @@ export default class Restful extends DataSource(RectPath(Shape)) {
|
|
|
140
335
|
|
|
141
336
|
var self = this
|
|
142
337
|
|
|
143
|
-
// requestAnimationFrame 이 호출되지 않을 때는 ajax 호출도 하지 않도록 함.
|
|
144
338
|
function _() {
|
|
145
339
|
if (!self._isStarted) {
|
|
146
340
|
return
|
|
147
341
|
}
|
|
148
|
-
self.
|
|
342
|
+
self.fetch()
|
|
149
343
|
|
|
150
344
|
if (!self.period) {
|
|
151
345
|
self._stopRepeater()
|
|
@@ -161,78 +355,74 @@ export default class Restful extends DataSource(RectPath(Shape)) {
|
|
|
161
355
|
}
|
|
162
356
|
|
|
163
357
|
_stopRepeater() {
|
|
164
|
-
this._abortRequest()
|
|
165
|
-
|
|
166
|
-
if (this.repeatTimer) clearTimeout(this._repeatTimer)
|
|
167
358
|
this._isStarted = false
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
_makeRequest(url: string) {
|
|
171
|
-
if (window.XMLHttpRequest) {
|
|
172
|
-
// Mozilla, Safari, ...
|
|
173
|
-
this.httpRequest = new XMLHttpRequest()
|
|
174
|
-
// @ts-ignore
|
|
175
|
-
} else if (window.ActiveXObject) {
|
|
176
|
-
// IE
|
|
177
|
-
try {
|
|
178
|
-
// @ts-ignore
|
|
179
|
-
this.httpRequest = new ActiveXObject('Msxml2.XMLHTTP')
|
|
180
|
-
} catch (e) {
|
|
181
|
-
try {
|
|
182
|
-
// @ts-ignore
|
|
183
|
-
this.httpRequest = new ActiveXObject('Microsoft.XMLHTTP')
|
|
184
|
-
} catch (e) {}
|
|
185
|
-
}
|
|
359
|
+
if (this.repeatTimer) {
|
|
360
|
+
clearTimeout(this._repeatTimer)
|
|
186
361
|
}
|
|
187
|
-
|
|
188
|
-
if (!this.httpRequest) {
|
|
189
|
-
warn('Giving up :( Cannot create an XMLHTTP instance')
|
|
190
|
-
return false
|
|
191
|
-
}
|
|
192
|
-
this.httpRequest.withCredentials = this.withCredentials
|
|
193
|
-
this.httpRequest.open('GET', url)
|
|
194
|
-
this.httpRequest.onreadystatechange = this.onDataReceived.bind(this)
|
|
195
|
-
|
|
196
|
-
return true
|
|
197
362
|
}
|
|
198
363
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
364
|
+
async fetch() {
|
|
365
|
+
var {
|
|
366
|
+
url,
|
|
367
|
+
method = 'GET',
|
|
368
|
+
mode = 'cors',
|
|
369
|
+
cache = 'default',
|
|
370
|
+
credentials = 'same-origin',
|
|
371
|
+
redirect = 'follow',
|
|
372
|
+
referrerPolicy = 'no-referrer-when-downgrade',
|
|
373
|
+
contentType = 'application/json',
|
|
374
|
+
dataFormat = 'json',
|
|
375
|
+
value
|
|
376
|
+
} = this.state
|
|
202
377
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
_abortRequest() {
|
|
208
|
-
if (this.httpRequest) this.httpRequest.abort()
|
|
209
|
-
}
|
|
378
|
+
if (dataFormat == 'jsonp') {
|
|
379
|
+
if (value && typeof value == 'string') {
|
|
380
|
+
url = value
|
|
381
|
+
}
|
|
210
382
|
|
|
211
|
-
|
|
212
|
-
|
|
383
|
+
jsonp(url, {}, (self, data) => {
|
|
384
|
+
if (this._isStarted && data) {
|
|
385
|
+
this.data = data
|
|
386
|
+
}
|
|
387
|
+
})
|
|
213
388
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
var data = this.httpRequest.responseText
|
|
389
|
+
return
|
|
390
|
+
}
|
|
217
391
|
|
|
218
|
-
|
|
392
|
+
var options: any = {
|
|
393
|
+
method,
|
|
394
|
+
mode,
|
|
395
|
+
cache,
|
|
396
|
+
credentials,
|
|
397
|
+
headers: {
|
|
398
|
+
'Content-Type': contentType
|
|
399
|
+
},
|
|
400
|
+
redirect,
|
|
401
|
+
referrerPolicy
|
|
402
|
+
}
|
|
219
403
|
|
|
220
|
-
|
|
404
|
+
if (method != 'GET' && method != 'HEAD') {
|
|
405
|
+
if (contentType == 'application/json') {
|
|
406
|
+
options.body = JSON.stringify(value)
|
|
407
|
+
} else {
|
|
408
|
+
options.body = value
|
|
409
|
+
}
|
|
410
|
+
} else {
|
|
411
|
+
if (value && typeof value == 'string') {
|
|
412
|
+
options.url = value
|
|
221
413
|
}
|
|
222
414
|
}
|
|
223
|
-
}
|
|
224
415
|
|
|
225
|
-
|
|
226
|
-
var { dataFormat = 'text' } = this.state
|
|
416
|
+
const response = await fetch(url, options)
|
|
227
417
|
|
|
228
|
-
if (
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
} else {
|
|
232
|
-
// @ts-ignore TODO add substitute property to things-scene.d.ts
|
|
233
|
-
if (!this._makeRequest(this.substitute(this.url, this))) return
|
|
418
|
+
if (!this._isStarted) {
|
|
419
|
+
return
|
|
420
|
+
}
|
|
234
421
|
|
|
235
|
-
|
|
422
|
+
if (dataFormat === 'json') {
|
|
423
|
+
this.data = response.json()
|
|
424
|
+
} else if (dataFormat === 'text') {
|
|
425
|
+
this.data = response.text()
|
|
236
426
|
}
|
|
237
427
|
}
|
|
238
428
|
|
|
@@ -249,7 +439,7 @@ export default class Restful extends DataSource(RectPath(Shape)) {
|
|
|
249
439
|
return
|
|
250
440
|
}
|
|
251
441
|
|
|
252
|
-
this.
|
|
442
|
+
this.fetch()
|
|
253
443
|
}
|
|
254
444
|
|
|
255
445
|
get controls() {
|
package/translations/en.json
CHANGED
|
@@ -2,5 +2,12 @@
|
|
|
2
2
|
"label.url": "url",
|
|
3
3
|
"label.period": "period",
|
|
4
4
|
"label.data-format": "data format",
|
|
5
|
-
"label.with-credentials": "with credentials"
|
|
5
|
+
"label.with-credentials": "with credentials",
|
|
6
|
+
"label.content-type": "content type",
|
|
7
|
+
"label.mode": "mode",
|
|
8
|
+
"label.credentials": "credentials",
|
|
9
|
+
"label.cache": "cache",
|
|
10
|
+
"label.redirect": "redirect",
|
|
11
|
+
"label.referrer-policy": "referrer policy",
|
|
12
|
+
"label.fetch-on-load": "fetch on load"
|
|
6
13
|
}
|