@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,537 @@
1
+ /**
2
+ * @djvlc/contracts-schemas - DJV 低代码平台 JSON Schema 定义包
3
+ *
4
+ * 提供所有协议的 JSON Schema 定义,用于:
5
+ * - Editor: 配置表单校验
6
+ * - Platform: 发布时校验
7
+ * - Runtime: 运行时校验/降级
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ declare const pageSchema: {
12
+ readonly $schema: "http://json-schema.org/draft-07/schema#";
13
+ readonly $id: "https://djvlc.com/schemas/page-schema.json";
14
+ readonly title: "PageSchema";
15
+ readonly description: "DJV 低代码平台页面 Schema 定义";
16
+ readonly type: "object";
17
+ readonly required: readonly ["schemaVersion", "page", "components"];
18
+ readonly properties: {
19
+ readonly schemaVersion: {
20
+ readonly type: "string";
21
+ readonly description: "Schema 版本号";
22
+ readonly pattern: "^\\d+\\.\\d+\\.\\d+$";
23
+ };
24
+ readonly page: {
25
+ readonly $ref: "#/definitions/PageConfig";
26
+ };
27
+ readonly components: {
28
+ readonly type: "array";
29
+ readonly description: "组件实例列表";
30
+ readonly items: {
31
+ readonly $ref: "#/definitions/ComponentInstance";
32
+ };
33
+ };
34
+ readonly actionDefVersionIds: {
35
+ readonly type: "array";
36
+ readonly description: "绑定的 ActionDefinition 版本 ID";
37
+ readonly items: {
38
+ readonly type: "string";
39
+ };
40
+ };
41
+ readonly dataQueryVersionIds: {
42
+ readonly type: "array";
43
+ readonly description: "绑定的 DataQuery 版本 ID";
44
+ readonly items: {
45
+ readonly type: "string";
46
+ };
47
+ };
48
+ };
49
+ readonly definitions: {
50
+ readonly PageConfig: {
51
+ readonly type: "object";
52
+ readonly required: readonly ["id", "title", "canvas"];
53
+ readonly properties: {
54
+ readonly id: {
55
+ readonly type: "string";
56
+ readonly description: "页面 ID";
57
+ };
58
+ readonly title: {
59
+ readonly type: "string";
60
+ readonly description: "页面标题";
61
+ };
62
+ readonly description: {
63
+ readonly type: "string";
64
+ readonly description: "页面描述";
65
+ };
66
+ readonly canvas: {
67
+ readonly $ref: "#/definitions/CanvasConfig";
68
+ };
69
+ readonly meta: {
70
+ readonly $ref: "#/definitions/PageMeta";
71
+ };
72
+ readonly variables: {
73
+ readonly type: "object";
74
+ readonly description: "页面变量";
75
+ };
76
+ readonly apis: {
77
+ readonly type: "array";
78
+ readonly items: {
79
+ readonly $ref: "#/definitions/ApiConfig";
80
+ };
81
+ };
82
+ };
83
+ };
84
+ readonly CanvasConfig: {
85
+ readonly type: "object";
86
+ readonly required: readonly ["type", "width"];
87
+ readonly properties: {
88
+ readonly type: {
89
+ readonly type: "string";
90
+ readonly enum: readonly ["h5", "tablet", "pc"];
91
+ readonly description: "画布类型";
92
+ };
93
+ readonly width: {
94
+ readonly type: "number";
95
+ readonly description: "画布宽度";
96
+ };
97
+ readonly height: {
98
+ readonly type: "number";
99
+ readonly description: "画布高度";
100
+ };
101
+ readonly background: {
102
+ readonly type: "string";
103
+ readonly description: "背景色";
104
+ };
105
+ readonly gridSize: {
106
+ readonly type: "number";
107
+ readonly description: "网格大小";
108
+ };
109
+ readonly showGrid: {
110
+ readonly type: "boolean";
111
+ readonly description: "是否显示网格";
112
+ };
113
+ readonly showRuler: {
114
+ readonly type: "boolean";
115
+ readonly description: "是否显示标尺";
116
+ };
117
+ };
118
+ };
119
+ readonly PageMeta: {
120
+ readonly type: "object";
121
+ readonly properties: {
122
+ readonly createTime: {
123
+ readonly type: "string";
124
+ readonly format: "date-time";
125
+ };
126
+ readonly updateTime: {
127
+ readonly type: "string";
128
+ readonly format: "date-time";
129
+ };
130
+ readonly author: {
131
+ readonly type: "string";
132
+ };
133
+ readonly version: {
134
+ readonly type: "string";
135
+ };
136
+ readonly tags: {
137
+ readonly type: "array";
138
+ readonly items: {
139
+ readonly type: "string";
140
+ };
141
+ };
142
+ readonly status: {
143
+ readonly type: "string";
144
+ readonly enum: readonly ["draft", "published"];
145
+ };
146
+ };
147
+ };
148
+ readonly ApiConfig: {
149
+ readonly type: "object";
150
+ readonly required: readonly ["id", "name", "url", "method"];
151
+ readonly properties: {
152
+ readonly id: {
153
+ readonly type: "string";
154
+ };
155
+ readonly name: {
156
+ readonly type: "string";
157
+ };
158
+ readonly url: {
159
+ readonly type: "string";
160
+ };
161
+ readonly method: {
162
+ readonly type: "string";
163
+ readonly enum: readonly ["GET", "POST", "PUT", "DELETE", "PATCH"];
164
+ };
165
+ readonly headers: {
166
+ readonly type: "object";
167
+ };
168
+ readonly params: {
169
+ readonly type: "object";
170
+ };
171
+ readonly body: {
172
+ readonly type: "object";
173
+ };
174
+ readonly timeout: {
175
+ readonly type: "number";
176
+ };
177
+ readonly autoRun: {
178
+ readonly type: "boolean";
179
+ };
180
+ readonly dependencies: {
181
+ readonly type: "array";
182
+ readonly items: {
183
+ readonly type: "string";
184
+ };
185
+ };
186
+ };
187
+ };
188
+ readonly ComponentInstance: {
189
+ readonly type: "object";
190
+ readonly required: readonly ["id", "type", "props", "style"];
191
+ readonly properties: {
192
+ readonly id: {
193
+ readonly type: "string";
194
+ readonly description: "组件实例 ID";
195
+ };
196
+ readonly type: {
197
+ readonly type: "string";
198
+ readonly description: "组件类型";
199
+ };
200
+ readonly name: {
201
+ readonly type: "string";
202
+ readonly description: "组件名称";
203
+ };
204
+ readonly props: {
205
+ readonly type: "object";
206
+ readonly description: "组件属性";
207
+ };
208
+ readonly style: {
209
+ readonly type: "object";
210
+ readonly description: "组件样式";
211
+ };
212
+ readonly layout: {
213
+ readonly $ref: "#/definitions/ComponentLayout";
214
+ };
215
+ readonly events: {
216
+ readonly type: "array";
217
+ readonly items: {
218
+ readonly $ref: "#/definitions/ComponentEvent";
219
+ };
220
+ };
221
+ readonly visible: {
222
+ readonly type: "boolean";
223
+ };
224
+ readonly locked: {
225
+ readonly type: "boolean";
226
+ };
227
+ readonly children: {
228
+ readonly type: "array";
229
+ readonly items: {
230
+ readonly $ref: "#/definitions/ComponentInstance";
231
+ };
232
+ };
233
+ };
234
+ };
235
+ readonly ComponentLayout: {
236
+ readonly type: "object";
237
+ readonly properties: {
238
+ readonly x: {
239
+ readonly type: "number";
240
+ };
241
+ readonly y: {
242
+ readonly type: "number";
243
+ };
244
+ readonly width: {
245
+ readonly type: "number";
246
+ };
247
+ readonly height: {
248
+ readonly type: "number";
249
+ };
250
+ readonly rotation: {
251
+ readonly type: "number";
252
+ };
253
+ };
254
+ };
255
+ readonly ComponentEvent: {
256
+ readonly type: "object";
257
+ readonly required: readonly ["id", "trigger", "actions"];
258
+ readonly properties: {
259
+ readonly id: {
260
+ readonly type: "string";
261
+ };
262
+ readonly trigger: {
263
+ readonly type: "string";
264
+ };
265
+ readonly actions: {
266
+ readonly type: "array";
267
+ readonly items: {
268
+ readonly $ref: "#/definitions/EventAction";
269
+ };
270
+ };
271
+ readonly enabled: {
272
+ readonly type: "boolean";
273
+ };
274
+ readonly condition: {
275
+ readonly type: "string";
276
+ };
277
+ readonly debounce: {
278
+ readonly type: "number";
279
+ };
280
+ readonly throttle: {
281
+ readonly type: "number";
282
+ };
283
+ };
284
+ };
285
+ readonly EventAction: {
286
+ readonly type: "object";
287
+ readonly required: readonly ["id", "type", "params"];
288
+ readonly properties: {
289
+ readonly id: {
290
+ readonly type: "string";
291
+ };
292
+ readonly type: {
293
+ readonly type: "string";
294
+ };
295
+ readonly params: {
296
+ readonly type: "object";
297
+ };
298
+ readonly enabled: {
299
+ readonly type: "boolean";
300
+ };
301
+ readonly delay: {
302
+ readonly type: "number";
303
+ };
304
+ };
305
+ };
306
+ };
307
+ };
308
+ declare const componentMetaSchema: {
309
+ readonly $schema: "http://json-schema.org/draft-07/schema#";
310
+ readonly $id: "https://djvlc.com/schemas/component-meta.json";
311
+ readonly title: "ComponentMeta";
312
+ readonly description: "DJV 低代码平台组件元数据 Schema 定义";
313
+ readonly type: "object";
314
+ readonly required: readonly ["name", "version", "label", "category", "props", "events", "capabilities", "compat", "integrity", "status", "entry"];
315
+ readonly properties: {
316
+ readonly name: {
317
+ readonly type: "string";
318
+ readonly description: "组件名称";
319
+ readonly pattern: "^[a-z][a-z0-9-]*$";
320
+ };
321
+ readonly version: {
322
+ readonly type: "string";
323
+ readonly description: "版本号 (semver)";
324
+ readonly pattern: "^\\d+\\.\\d+\\.\\d+(-[a-zA-Z0-9.]+)?$";
325
+ };
326
+ readonly label: {
327
+ readonly type: "string";
328
+ readonly description: "显示名称";
329
+ };
330
+ readonly description: {
331
+ readonly type: "string";
332
+ readonly description: "组件描述";
333
+ };
334
+ readonly icon: {
335
+ readonly type: "string";
336
+ readonly description: "组件图标";
337
+ };
338
+ readonly category: {
339
+ readonly type: "string";
340
+ readonly enum: readonly ["basic", "form", "layout", "navigation", "feedback", "display", "data", "business", "chart", "other"];
341
+ readonly description: "组件分类";
342
+ };
343
+ readonly tags: {
344
+ readonly type: "array";
345
+ readonly items: {
346
+ readonly type: "string";
347
+ };
348
+ readonly description: "组件标签";
349
+ };
350
+ readonly author: {
351
+ readonly type: "string";
352
+ readonly description: "组件作者";
353
+ };
354
+ readonly props: {
355
+ readonly type: "object";
356
+ readonly description: "属性定义";
357
+ };
358
+ readonly events: {
359
+ readonly type: "object";
360
+ readonly description: "事件定义";
361
+ };
362
+ readonly capabilities: {
363
+ readonly type: "object";
364
+ readonly description: "能力声明";
365
+ };
366
+ readonly compat: {
367
+ readonly type: "object";
368
+ readonly description: "兼容性";
369
+ };
370
+ readonly integrity: {
371
+ readonly type: "object";
372
+ readonly description: "完整性校验";
373
+ };
374
+ readonly status: {
375
+ readonly type: "string";
376
+ readonly enum: readonly ["draft", "canary", "stable", "deprecated", "blocked"];
377
+ readonly description: "组件状态";
378
+ };
379
+ readonly preview: {
380
+ readonly type: "string";
381
+ readonly description: "预览图 URL";
382
+ };
383
+ readonly entry: {
384
+ readonly type: "string";
385
+ readonly description: "入口文件路径";
386
+ };
387
+ readonly styles: {
388
+ readonly type: "array";
389
+ readonly items: {
390
+ readonly type: "string";
391
+ };
392
+ readonly description: "样式文件路径";
393
+ };
394
+ };
395
+ };
396
+ declare const actionSpecSchema: {
397
+ readonly $schema: "http://json-schema.org/draft-07/schema#";
398
+ readonly $id: "https://djvlc.com/schemas/action-spec.json";
399
+ readonly title: "ActionDefinition";
400
+ readonly description: "DJV 低代码平台 Action 定义 Schema";
401
+ readonly type: "object";
402
+ readonly required: readonly ["id", "name", "actionType", "paramsSchema", "requiresAuth", "version", "status"];
403
+ readonly properties: {
404
+ readonly id: {
405
+ readonly type: "string";
406
+ readonly description: "动作 ID";
407
+ };
408
+ readonly name: {
409
+ readonly type: "string";
410
+ readonly description: "动作名称";
411
+ };
412
+ readonly actionType: {
413
+ readonly type: "string";
414
+ readonly description: "动作类型";
415
+ };
416
+ readonly description: {
417
+ readonly type: "string";
418
+ readonly description: "动作描述";
419
+ };
420
+ readonly paramsSchema: {
421
+ readonly type: "object";
422
+ readonly description: "参数 Schema";
423
+ };
424
+ readonly responseSchema: {
425
+ readonly type: "object";
426
+ readonly description: "响应 Schema";
427
+ };
428
+ readonly requiresAuth: {
429
+ readonly type: "boolean";
430
+ readonly description: "是否需要认证";
431
+ };
432
+ readonly idempotencyRule: {
433
+ readonly type: "object";
434
+ readonly description: "幂等规则";
435
+ };
436
+ readonly rateLimitRule: {
437
+ readonly type: "object";
438
+ readonly description: "频控规则";
439
+ };
440
+ readonly version: {
441
+ readonly type: "string";
442
+ readonly description: "版本号";
443
+ readonly pattern: "^\\d+\\.\\d+\\.\\d+$";
444
+ };
445
+ readonly status: {
446
+ readonly type: "string";
447
+ readonly enum: readonly ["active", "deprecated", "disabled"];
448
+ readonly description: "状态";
449
+ };
450
+ };
451
+ };
452
+ declare const dataQuerySpecSchema: {
453
+ readonly $schema: "http://json-schema.org/draft-07/schema#";
454
+ readonly $id: "https://djvlc.com/schemas/data-query-spec.json";
455
+ readonly title: "DataQueryDefinition";
456
+ readonly description: "DJV 低代码平台 Data Query 定义 Schema";
457
+ readonly type: "object";
458
+ readonly required: readonly ["id", "name", "sourceType", "sourceConfig", "paramsSchema", "responseSchema", "version", "status"];
459
+ readonly properties: {
460
+ readonly id: {
461
+ readonly type: "string";
462
+ readonly description: "查询 ID";
463
+ };
464
+ readonly name: {
465
+ readonly type: "string";
466
+ readonly description: "查询名称";
467
+ };
468
+ readonly description: {
469
+ readonly type: "string";
470
+ readonly description: "查询描述";
471
+ };
472
+ readonly sourceType: {
473
+ readonly type: "string";
474
+ readonly enum: readonly ["api", "database", "cache", "custom"];
475
+ readonly description: "数据源类型";
476
+ };
477
+ readonly sourceConfig: {
478
+ readonly type: "object";
479
+ readonly description: "数据源配置";
480
+ };
481
+ readonly paramsSchema: {
482
+ readonly type: "object";
483
+ readonly description: "参数 Schema";
484
+ };
485
+ readonly responseSchema: {
486
+ readonly type: "object";
487
+ readonly description: "响应 Schema";
488
+ };
489
+ readonly allowedFields: {
490
+ readonly type: "array";
491
+ readonly items: {
492
+ readonly type: "string";
493
+ };
494
+ readonly description: "字段白名单";
495
+ };
496
+ readonly maskRules: {
497
+ readonly type: "array";
498
+ readonly description: "脱敏规则";
499
+ };
500
+ readonly cacheConfig: {
501
+ readonly type: "object";
502
+ readonly description: "缓存配置";
503
+ };
504
+ readonly version: {
505
+ readonly type: "string";
506
+ readonly description: "版本号";
507
+ readonly pattern: "^\\d+\\.\\d+\\.\\d+$";
508
+ };
509
+ readonly status: {
510
+ readonly type: "string";
511
+ readonly enum: readonly ["active", "deprecated", "disabled"];
512
+ readonly description: "状态";
513
+ };
514
+ };
515
+ };
516
+ declare const SCHEMA_VERSIONS: {
517
+ readonly pageSchema: "1.0.0";
518
+ readonly componentMeta: "1.0.0";
519
+ readonly actionSpec: "1.0.0";
520
+ readonly dataQuerySpec: "1.0.0";
521
+ };
522
+ interface SchemaMetadata {
523
+ name: string;
524
+ version: string;
525
+ description: string;
526
+ schema: object;
527
+ }
528
+ /**
529
+ * 获取所有 Schema 的元数据
530
+ */
531
+ declare function getAllSchemas(): SchemaMetadata[];
532
+ /**
533
+ * 根据名称获取 Schema
534
+ */
535
+ declare function getSchemaByName(name: 'page-schema' | 'component-meta' | 'action-spec' | 'data-query-spec'): object;
536
+
537
+ export { SCHEMA_VERSIONS, type SchemaMetadata, actionSpecSchema, componentMetaSchema, dataQuerySpecSchema, getAllSchemas, getSchemaByName, pageSchema };