@djvlc/contracts-schemas 1.2.0

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.
@@ -0,0 +1,199 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://djvlc.com/schemas/data-query-spec.json",
4
+ "title": "DataQueryDefinition",
5
+ "description": "DJV 低代码平台 Data Query 定义 Schema",
6
+ "type": "object",
7
+ "required": ["id", "name", "sourceType", "sourceConfig", "paramsSchema", "responseSchema", "version", "status"],
8
+ "properties": {
9
+ "id": {
10
+ "type": "string",
11
+ "description": "查询 ID"
12
+ },
13
+ "name": {
14
+ "type": "string",
15
+ "description": "查询名称"
16
+ },
17
+ "description": {
18
+ "type": "string",
19
+ "description": "查询描述"
20
+ },
21
+ "sourceType": {
22
+ "type": "string",
23
+ "enum": ["api", "database", "cache", "custom"],
24
+ "description": "数据源类型"
25
+ },
26
+ "sourceConfig": {
27
+ "$ref": "#/definitions/DataSourceConfig"
28
+ },
29
+ "paramsSchema": {
30
+ "type": "object",
31
+ "description": "参数 Schema"
32
+ },
33
+ "responseSchema": {
34
+ "type": "object",
35
+ "description": "响应 Schema"
36
+ },
37
+ "allowedFields": {
38
+ "type": "array",
39
+ "items": {
40
+ "type": "string"
41
+ },
42
+ "description": "字段白名单"
43
+ },
44
+ "maskRules": {
45
+ "type": "array",
46
+ "items": {
47
+ "$ref": "#/definitions/MaskRule"
48
+ },
49
+ "description": "脱敏规则"
50
+ },
51
+ "cacheConfig": {
52
+ "$ref": "#/definitions/CacheConfig"
53
+ },
54
+ "version": {
55
+ "type": "string",
56
+ "description": "版本号",
57
+ "pattern": "^\\d+\\.\\d+\\.\\d+$"
58
+ },
59
+ "status": {
60
+ "type": "string",
61
+ "enum": ["active", "deprecated", "disabled"],
62
+ "description": "状态"
63
+ }
64
+ },
65
+ "definitions": {
66
+ "DataSourceConfig": {
67
+ "type": "object",
68
+ "properties": {
69
+ "url": {
70
+ "type": "string",
71
+ "description": "API URL"
72
+ },
73
+ "method": {
74
+ "type": "string",
75
+ "enum": ["GET", "POST"],
76
+ "description": "HTTP 方法"
77
+ },
78
+ "headers": {
79
+ "type": "object",
80
+ "additionalProperties": {
81
+ "type": "string"
82
+ },
83
+ "description": "请求头"
84
+ },
85
+ "connection": {
86
+ "type": "string",
87
+ "description": "数据库连接标识"
88
+ },
89
+ "query": {
90
+ "type": "string",
91
+ "description": "SQL 查询"
92
+ },
93
+ "handler": {
94
+ "type": "string",
95
+ "description": "自定义处理器"
96
+ }
97
+ }
98
+ },
99
+ "MaskRule": {
100
+ "type": "object",
101
+ "required": ["field", "type"],
102
+ "properties": {
103
+ "field": {
104
+ "type": "string",
105
+ "description": "字段路径"
106
+ },
107
+ "type": {
108
+ "type": "string",
109
+ "enum": ["phone", "email", "idcard", "name", "custom"],
110
+ "description": "脱敏类型"
111
+ },
112
+ "pattern": {
113
+ "type": "string",
114
+ "description": "自定义脱敏正则"
115
+ },
116
+ "replacement": {
117
+ "type": "string",
118
+ "description": "替换字符"
119
+ }
120
+ }
121
+ },
122
+ "CacheConfig": {
123
+ "type": "object",
124
+ "required": ["enabled", "ttl"],
125
+ "properties": {
126
+ "enabled": {
127
+ "type": "boolean",
128
+ "description": "是否启用缓存"
129
+ },
130
+ "ttl": {
131
+ "type": "number",
132
+ "description": "缓存 TTL(秒)"
133
+ },
134
+ "keyFields": {
135
+ "type": "array",
136
+ "items": {
137
+ "type": "string"
138
+ },
139
+ "description": "缓存键字段"
140
+ },
141
+ "allowRefresh": {
142
+ "type": "boolean",
143
+ "description": "是否允许刷新"
144
+ }
145
+ }
146
+ },
147
+ "DataQueryRequest": {
148
+ "type": "object",
149
+ "required": ["queryVersionId", "params"],
150
+ "properties": {
151
+ "queryVersionId": {
152
+ "type": "string"
153
+ },
154
+ "params": {
155
+ "type": "object"
156
+ },
157
+ "context": {
158
+ "$ref": "#/definitions/DataQueryContext"
159
+ }
160
+ }
161
+ },
162
+ "DataQueryContext": {
163
+ "type": "object",
164
+ "properties": {
165
+ "pageVersionId": {
166
+ "type": "string"
167
+ },
168
+ "uid": {
169
+ "type": "string"
170
+ },
171
+ "traceId": {
172
+ "type": "string"
173
+ }
174
+ }
175
+ },
176
+ "DataQueryResponse": {
177
+ "type": "object",
178
+ "required": ["success"],
179
+ "properties": {
180
+ "success": {
181
+ "type": "boolean"
182
+ },
183
+ "data": {},
184
+ "fromCache": {
185
+ "type": "boolean"
186
+ },
187
+ "cacheTime": {
188
+ "type": "number"
189
+ },
190
+ "code": {
191
+ "type": "number"
192
+ },
193
+ "message": {
194
+ "type": "string"
195
+ }
196
+ }
197
+ }
198
+ }
199
+ }
@@ -0,0 +1,297 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://djvlc.com/schemas/page-schema.json",
4
+ "title": "PageSchema",
5
+ "description": "DJV 低代码平台页面 Schema 定义",
6
+ "type": "object",
7
+ "required": ["schemaVersion", "page", "components"],
8
+ "properties": {
9
+ "schemaVersion": {
10
+ "type": "string",
11
+ "description": "Schema 版本号",
12
+ "pattern": "^\\d+\\.\\d+\\.\\d+$"
13
+ },
14
+ "page": {
15
+ "$ref": "#/definitions/PageConfig"
16
+ },
17
+ "components": {
18
+ "type": "array",
19
+ "description": "组件实例列表",
20
+ "items": {
21
+ "$ref": "#/definitions/ComponentInstance"
22
+ }
23
+ },
24
+ "actionDefVersionIds": {
25
+ "type": "array",
26
+ "description": "绑定的 ActionDefinition 版本 ID",
27
+ "items": {
28
+ "type": "string"
29
+ }
30
+ },
31
+ "dataQueryVersionIds": {
32
+ "type": "array",
33
+ "description": "绑定的 DataQuery 版本 ID",
34
+ "items": {
35
+ "type": "string"
36
+ }
37
+ }
38
+ },
39
+ "definitions": {
40
+ "PageConfig": {
41
+ "type": "object",
42
+ "required": ["id", "title", "canvas"],
43
+ "properties": {
44
+ "id": {
45
+ "type": "string",
46
+ "description": "页面 ID"
47
+ },
48
+ "title": {
49
+ "type": "string",
50
+ "description": "页面标题"
51
+ },
52
+ "description": {
53
+ "type": "string",
54
+ "description": "页面描述"
55
+ },
56
+ "canvas": {
57
+ "$ref": "#/definitions/CanvasConfig"
58
+ },
59
+ "meta": {
60
+ "$ref": "#/definitions/PageMeta"
61
+ },
62
+ "variables": {
63
+ "type": "object",
64
+ "description": "页面变量"
65
+ },
66
+ "apis": {
67
+ "type": "array",
68
+ "items": {
69
+ "$ref": "#/definitions/ApiConfig"
70
+ }
71
+ }
72
+ }
73
+ },
74
+ "CanvasConfig": {
75
+ "type": "object",
76
+ "required": ["type", "width"],
77
+ "properties": {
78
+ "type": {
79
+ "type": "string",
80
+ "enum": ["h5", "tablet", "pc"],
81
+ "description": "画布类型"
82
+ },
83
+ "width": {
84
+ "type": "number",
85
+ "description": "画布宽度"
86
+ },
87
+ "height": {
88
+ "type": "number",
89
+ "description": "画布高度"
90
+ },
91
+ "background": {
92
+ "type": "string",
93
+ "description": "背景色"
94
+ },
95
+ "gridSize": {
96
+ "type": "number",
97
+ "description": "网格大小"
98
+ },
99
+ "showGrid": {
100
+ "type": "boolean",
101
+ "description": "是否显示网格"
102
+ },
103
+ "showRuler": {
104
+ "type": "boolean",
105
+ "description": "是否显示标尺"
106
+ }
107
+ }
108
+ },
109
+ "PageMeta": {
110
+ "type": "object",
111
+ "properties": {
112
+ "createTime": {
113
+ "type": "string",
114
+ "format": "date-time"
115
+ },
116
+ "updateTime": {
117
+ "type": "string",
118
+ "format": "date-time"
119
+ },
120
+ "author": {
121
+ "type": "string"
122
+ },
123
+ "version": {
124
+ "type": "string"
125
+ },
126
+ "tags": {
127
+ "type": "array",
128
+ "items": {
129
+ "type": "string"
130
+ }
131
+ },
132
+ "status": {
133
+ "type": "string",
134
+ "enum": ["draft", "published"]
135
+ }
136
+ }
137
+ },
138
+ "ApiConfig": {
139
+ "type": "object",
140
+ "required": ["id", "name", "url", "method"],
141
+ "properties": {
142
+ "id": {
143
+ "type": "string"
144
+ },
145
+ "name": {
146
+ "type": "string"
147
+ },
148
+ "url": {
149
+ "type": "string"
150
+ },
151
+ "method": {
152
+ "type": "string",
153
+ "enum": ["GET", "POST", "PUT", "DELETE", "PATCH"]
154
+ },
155
+ "headers": {
156
+ "type": "object"
157
+ },
158
+ "params": {
159
+ "type": "object"
160
+ },
161
+ "body": {
162
+ "type": "object"
163
+ },
164
+ "timeout": {
165
+ "type": "number"
166
+ },
167
+ "autoRun": {
168
+ "type": "boolean"
169
+ },
170
+ "dependencies": {
171
+ "type": "array",
172
+ "items": {
173
+ "type": "string"
174
+ }
175
+ }
176
+ }
177
+ },
178
+ "ComponentInstance": {
179
+ "type": "object",
180
+ "required": ["id", "type", "props", "style"],
181
+ "properties": {
182
+ "id": {
183
+ "type": "string",
184
+ "description": "组件实例 ID"
185
+ },
186
+ "type": {
187
+ "type": "string",
188
+ "description": "组件类型"
189
+ },
190
+ "name": {
191
+ "type": "string",
192
+ "description": "组件名称"
193
+ },
194
+ "props": {
195
+ "type": "object",
196
+ "description": "组件属性"
197
+ },
198
+ "style": {
199
+ "type": "object",
200
+ "description": "组件样式"
201
+ },
202
+ "layout": {
203
+ "$ref": "#/definitions/ComponentLayout"
204
+ },
205
+ "events": {
206
+ "type": "array",
207
+ "items": {
208
+ "$ref": "#/definitions/ComponentEvent"
209
+ }
210
+ },
211
+ "visible": {
212
+ "type": "boolean"
213
+ },
214
+ "locked": {
215
+ "type": "boolean"
216
+ },
217
+ "children": {
218
+ "type": "array",
219
+ "items": {
220
+ "$ref": "#/definitions/ComponentInstance"
221
+ }
222
+ }
223
+ }
224
+ },
225
+ "ComponentLayout": {
226
+ "type": "object",
227
+ "properties": {
228
+ "x": {
229
+ "type": "number"
230
+ },
231
+ "y": {
232
+ "type": "number"
233
+ },
234
+ "width": {
235
+ "type": "number"
236
+ },
237
+ "height": {
238
+ "type": "number"
239
+ },
240
+ "rotation": {
241
+ "type": "number"
242
+ }
243
+ }
244
+ },
245
+ "ComponentEvent": {
246
+ "type": "object",
247
+ "required": ["id", "trigger", "actions"],
248
+ "properties": {
249
+ "id": {
250
+ "type": "string"
251
+ },
252
+ "trigger": {
253
+ "type": "string"
254
+ },
255
+ "actions": {
256
+ "type": "array",
257
+ "items": {
258
+ "$ref": "#/definitions/EventAction"
259
+ }
260
+ },
261
+ "enabled": {
262
+ "type": "boolean"
263
+ },
264
+ "condition": {
265
+ "type": "string"
266
+ },
267
+ "debounce": {
268
+ "type": "number"
269
+ },
270
+ "throttle": {
271
+ "type": "number"
272
+ }
273
+ }
274
+ },
275
+ "EventAction": {
276
+ "type": "object",
277
+ "required": ["id", "type", "params"],
278
+ "properties": {
279
+ "id": {
280
+ "type": "string"
281
+ },
282
+ "type": {
283
+ "type": "string"
284
+ },
285
+ "params": {
286
+ "type": "object"
287
+ },
288
+ "enabled": {
289
+ "type": "boolean"
290
+ },
291
+ "delay": {
292
+ "type": "number"
293
+ }
294
+ }
295
+ }
296
+ }
297
+ }