@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.
- package/dist/index.d.mts +537 -0
- package/dist/index.d.ts +537 -0
- package/dist/index.js +299 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +268 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +56 -0
- package/schemas/action-spec.schema.json +163 -0
- package/schemas/component-meta.schema.json +283 -0
- package/schemas/data-query-spec.schema.json +199 -0
- package/schemas/page-schema.schema.json +297 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
SCHEMA_VERSIONS: () => SCHEMA_VERSIONS,
|
|
24
|
+
actionSpecSchema: () => actionSpecSchema,
|
|
25
|
+
componentMetaSchema: () => componentMetaSchema,
|
|
26
|
+
dataQuerySpecSchema: () => dataQuerySpecSchema,
|
|
27
|
+
getAllSchemas: () => getAllSchemas,
|
|
28
|
+
getSchemaByName: () => getSchemaByName,
|
|
29
|
+
pageSchema: () => pageSchema
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(index_exports);
|
|
32
|
+
var pageSchema = {
|
|
33
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
34
|
+
$id: "https://djvlc.com/schemas/page-schema.json",
|
|
35
|
+
title: "PageSchema",
|
|
36
|
+
description: "DJV \u4F4E\u4EE3\u7801\u5E73\u53F0\u9875\u9762 Schema \u5B9A\u4E49",
|
|
37
|
+
type: "object",
|
|
38
|
+
required: ["schemaVersion", "page", "components"],
|
|
39
|
+
properties: {
|
|
40
|
+
schemaVersion: {
|
|
41
|
+
type: "string",
|
|
42
|
+
description: "Schema \u7248\u672C\u53F7",
|
|
43
|
+
pattern: "^\\d+\\.\\d+\\.\\d+$"
|
|
44
|
+
},
|
|
45
|
+
page: { $ref: "#/definitions/PageConfig" },
|
|
46
|
+
components: {
|
|
47
|
+
type: "array",
|
|
48
|
+
description: "\u7EC4\u4EF6\u5B9E\u4F8B\u5217\u8868",
|
|
49
|
+
items: { $ref: "#/definitions/ComponentInstance" }
|
|
50
|
+
},
|
|
51
|
+
actionDefVersionIds: {
|
|
52
|
+
type: "array",
|
|
53
|
+
description: "\u7ED1\u5B9A\u7684 ActionDefinition \u7248\u672C ID",
|
|
54
|
+
items: { type: "string" }
|
|
55
|
+
},
|
|
56
|
+
dataQueryVersionIds: {
|
|
57
|
+
type: "array",
|
|
58
|
+
description: "\u7ED1\u5B9A\u7684 DataQuery \u7248\u672C ID",
|
|
59
|
+
items: { type: "string" }
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
definitions: {
|
|
63
|
+
PageConfig: {
|
|
64
|
+
type: "object",
|
|
65
|
+
required: ["id", "title", "canvas"],
|
|
66
|
+
properties: {
|
|
67
|
+
id: { type: "string", description: "\u9875\u9762 ID" },
|
|
68
|
+
title: { type: "string", description: "\u9875\u9762\u6807\u9898" },
|
|
69
|
+
description: { type: "string", description: "\u9875\u9762\u63CF\u8FF0" },
|
|
70
|
+
canvas: { $ref: "#/definitions/CanvasConfig" },
|
|
71
|
+
meta: { $ref: "#/definitions/PageMeta" },
|
|
72
|
+
variables: { type: "object", description: "\u9875\u9762\u53D8\u91CF" },
|
|
73
|
+
apis: { type: "array", items: { $ref: "#/definitions/ApiConfig" } }
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
CanvasConfig: {
|
|
77
|
+
type: "object",
|
|
78
|
+
required: ["type", "width"],
|
|
79
|
+
properties: {
|
|
80
|
+
type: { type: "string", enum: ["h5", "tablet", "pc"], description: "\u753B\u5E03\u7C7B\u578B" },
|
|
81
|
+
width: { type: "number", description: "\u753B\u5E03\u5BBD\u5EA6" },
|
|
82
|
+
height: { type: "number", description: "\u753B\u5E03\u9AD8\u5EA6" },
|
|
83
|
+
background: { type: "string", description: "\u80CC\u666F\u8272" },
|
|
84
|
+
gridSize: { type: "number", description: "\u7F51\u683C\u5927\u5C0F" },
|
|
85
|
+
showGrid: { type: "boolean", description: "\u662F\u5426\u663E\u793A\u7F51\u683C" },
|
|
86
|
+
showRuler: { type: "boolean", description: "\u662F\u5426\u663E\u793A\u6807\u5C3A" }
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
PageMeta: {
|
|
90
|
+
type: "object",
|
|
91
|
+
properties: {
|
|
92
|
+
createTime: { type: "string", format: "date-time" },
|
|
93
|
+
updateTime: { type: "string", format: "date-time" },
|
|
94
|
+
author: { type: "string" },
|
|
95
|
+
version: { type: "string" },
|
|
96
|
+
tags: { type: "array", items: { type: "string" } },
|
|
97
|
+
status: { type: "string", enum: ["draft", "published"] }
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
ApiConfig: {
|
|
101
|
+
type: "object",
|
|
102
|
+
required: ["id", "name", "url", "method"],
|
|
103
|
+
properties: {
|
|
104
|
+
id: { type: "string" },
|
|
105
|
+
name: { type: "string" },
|
|
106
|
+
url: { type: "string" },
|
|
107
|
+
method: { type: "string", enum: ["GET", "POST", "PUT", "DELETE", "PATCH"] },
|
|
108
|
+
headers: { type: "object" },
|
|
109
|
+
params: { type: "object" },
|
|
110
|
+
body: { type: "object" },
|
|
111
|
+
timeout: { type: "number" },
|
|
112
|
+
autoRun: { type: "boolean" },
|
|
113
|
+
dependencies: { type: "array", items: { type: "string" } }
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
ComponentInstance: {
|
|
117
|
+
type: "object",
|
|
118
|
+
required: ["id", "type", "props", "style"],
|
|
119
|
+
properties: {
|
|
120
|
+
id: { type: "string", description: "\u7EC4\u4EF6\u5B9E\u4F8B ID" },
|
|
121
|
+
type: { type: "string", description: "\u7EC4\u4EF6\u7C7B\u578B" },
|
|
122
|
+
name: { type: "string", description: "\u7EC4\u4EF6\u540D\u79F0" },
|
|
123
|
+
props: { type: "object", description: "\u7EC4\u4EF6\u5C5E\u6027" },
|
|
124
|
+
style: { type: "object", description: "\u7EC4\u4EF6\u6837\u5F0F" },
|
|
125
|
+
layout: { $ref: "#/definitions/ComponentLayout" },
|
|
126
|
+
events: { type: "array", items: { $ref: "#/definitions/ComponentEvent" } },
|
|
127
|
+
visible: { type: "boolean" },
|
|
128
|
+
locked: { type: "boolean" },
|
|
129
|
+
children: { type: "array", items: { $ref: "#/definitions/ComponentInstance" } }
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
ComponentLayout: {
|
|
133
|
+
type: "object",
|
|
134
|
+
properties: {
|
|
135
|
+
x: { type: "number" },
|
|
136
|
+
y: { type: "number" },
|
|
137
|
+
width: { type: "number" },
|
|
138
|
+
height: { type: "number" },
|
|
139
|
+
rotation: { type: "number" }
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
ComponentEvent: {
|
|
143
|
+
type: "object",
|
|
144
|
+
required: ["id", "trigger", "actions"],
|
|
145
|
+
properties: {
|
|
146
|
+
id: { type: "string" },
|
|
147
|
+
trigger: { type: "string" },
|
|
148
|
+
actions: { type: "array", items: { $ref: "#/definitions/EventAction" } },
|
|
149
|
+
enabled: { type: "boolean" },
|
|
150
|
+
condition: { type: "string" },
|
|
151
|
+
debounce: { type: "number" },
|
|
152
|
+
throttle: { type: "number" }
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
EventAction: {
|
|
156
|
+
type: "object",
|
|
157
|
+
required: ["id", "type", "params"],
|
|
158
|
+
properties: {
|
|
159
|
+
id: { type: "string" },
|
|
160
|
+
type: { type: "string" },
|
|
161
|
+
params: { type: "object" },
|
|
162
|
+
enabled: { type: "boolean" },
|
|
163
|
+
delay: { type: "number" }
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
var componentMetaSchema = {
|
|
169
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
170
|
+
$id: "https://djvlc.com/schemas/component-meta.json",
|
|
171
|
+
title: "ComponentMeta",
|
|
172
|
+
description: "DJV \u4F4E\u4EE3\u7801\u5E73\u53F0\u7EC4\u4EF6\u5143\u6570\u636E Schema \u5B9A\u4E49",
|
|
173
|
+
type: "object",
|
|
174
|
+
required: ["name", "version", "label", "category", "props", "events", "capabilities", "compat", "integrity", "status", "entry"],
|
|
175
|
+
properties: {
|
|
176
|
+
name: { type: "string", description: "\u7EC4\u4EF6\u540D\u79F0", pattern: "^[a-z][a-z0-9-]*$" },
|
|
177
|
+
version: { type: "string", description: "\u7248\u672C\u53F7 (semver)", pattern: "^\\d+\\.\\d+\\.\\d+(-[a-zA-Z0-9.]+)?$" },
|
|
178
|
+
label: { type: "string", description: "\u663E\u793A\u540D\u79F0" },
|
|
179
|
+
description: { type: "string", description: "\u7EC4\u4EF6\u63CF\u8FF0" },
|
|
180
|
+
icon: { type: "string", description: "\u7EC4\u4EF6\u56FE\u6807" },
|
|
181
|
+
category: {
|
|
182
|
+
type: "string",
|
|
183
|
+
enum: ["basic", "form", "layout", "navigation", "feedback", "display", "data", "business", "chart", "other"],
|
|
184
|
+
description: "\u7EC4\u4EF6\u5206\u7C7B"
|
|
185
|
+
},
|
|
186
|
+
tags: { type: "array", items: { type: "string" }, description: "\u7EC4\u4EF6\u6807\u7B7E" },
|
|
187
|
+
author: { type: "string", description: "\u7EC4\u4EF6\u4F5C\u8005" },
|
|
188
|
+
props: { type: "object", description: "\u5C5E\u6027\u5B9A\u4E49" },
|
|
189
|
+
events: { type: "object", description: "\u4E8B\u4EF6\u5B9A\u4E49" },
|
|
190
|
+
capabilities: { type: "object", description: "\u80FD\u529B\u58F0\u660E" },
|
|
191
|
+
compat: { type: "object", description: "\u517C\u5BB9\u6027" },
|
|
192
|
+
integrity: { type: "object", description: "\u5B8C\u6574\u6027\u6821\u9A8C" },
|
|
193
|
+
status: {
|
|
194
|
+
type: "string",
|
|
195
|
+
enum: ["draft", "canary", "stable", "deprecated", "blocked"],
|
|
196
|
+
description: "\u7EC4\u4EF6\u72B6\u6001"
|
|
197
|
+
},
|
|
198
|
+
preview: { type: "string", description: "\u9884\u89C8\u56FE URL" },
|
|
199
|
+
entry: { type: "string", description: "\u5165\u53E3\u6587\u4EF6\u8DEF\u5F84" },
|
|
200
|
+
styles: { type: "array", items: { type: "string" }, description: "\u6837\u5F0F\u6587\u4EF6\u8DEF\u5F84" }
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
var actionSpecSchema = {
|
|
204
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
205
|
+
$id: "https://djvlc.com/schemas/action-spec.json",
|
|
206
|
+
title: "ActionDefinition",
|
|
207
|
+
description: "DJV \u4F4E\u4EE3\u7801\u5E73\u53F0 Action \u5B9A\u4E49 Schema",
|
|
208
|
+
type: "object",
|
|
209
|
+
required: ["id", "name", "actionType", "paramsSchema", "requiresAuth", "version", "status"],
|
|
210
|
+
properties: {
|
|
211
|
+
id: { type: "string", description: "\u52A8\u4F5C ID" },
|
|
212
|
+
name: { type: "string", description: "\u52A8\u4F5C\u540D\u79F0" },
|
|
213
|
+
actionType: { type: "string", description: "\u52A8\u4F5C\u7C7B\u578B" },
|
|
214
|
+
description: { type: "string", description: "\u52A8\u4F5C\u63CF\u8FF0" },
|
|
215
|
+
paramsSchema: { type: "object", description: "\u53C2\u6570 Schema" },
|
|
216
|
+
responseSchema: { type: "object", description: "\u54CD\u5E94 Schema" },
|
|
217
|
+
requiresAuth: { type: "boolean", description: "\u662F\u5426\u9700\u8981\u8BA4\u8BC1" },
|
|
218
|
+
idempotencyRule: { type: "object", description: "\u5E42\u7B49\u89C4\u5219" },
|
|
219
|
+
rateLimitRule: { type: "object", description: "\u9891\u63A7\u89C4\u5219" },
|
|
220
|
+
version: { type: "string", description: "\u7248\u672C\u53F7", pattern: "^\\d+\\.\\d+\\.\\d+$" },
|
|
221
|
+
status: { type: "string", enum: ["active", "deprecated", "disabled"], description: "\u72B6\u6001" }
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
var dataQuerySpecSchema = {
|
|
225
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
226
|
+
$id: "https://djvlc.com/schemas/data-query-spec.json",
|
|
227
|
+
title: "DataQueryDefinition",
|
|
228
|
+
description: "DJV \u4F4E\u4EE3\u7801\u5E73\u53F0 Data Query \u5B9A\u4E49 Schema",
|
|
229
|
+
type: "object",
|
|
230
|
+
required: ["id", "name", "sourceType", "sourceConfig", "paramsSchema", "responseSchema", "version", "status"],
|
|
231
|
+
properties: {
|
|
232
|
+
id: { type: "string", description: "\u67E5\u8BE2 ID" },
|
|
233
|
+
name: { type: "string", description: "\u67E5\u8BE2\u540D\u79F0" },
|
|
234
|
+
description: { type: "string", description: "\u67E5\u8BE2\u63CF\u8FF0" },
|
|
235
|
+
sourceType: { type: "string", enum: ["api", "database", "cache", "custom"], description: "\u6570\u636E\u6E90\u7C7B\u578B" },
|
|
236
|
+
sourceConfig: { type: "object", description: "\u6570\u636E\u6E90\u914D\u7F6E" },
|
|
237
|
+
paramsSchema: { type: "object", description: "\u53C2\u6570 Schema" },
|
|
238
|
+
responseSchema: { type: "object", description: "\u54CD\u5E94 Schema" },
|
|
239
|
+
allowedFields: { type: "array", items: { type: "string" }, description: "\u5B57\u6BB5\u767D\u540D\u5355" },
|
|
240
|
+
maskRules: { type: "array", description: "\u8131\u654F\u89C4\u5219" },
|
|
241
|
+
cacheConfig: { type: "object", description: "\u7F13\u5B58\u914D\u7F6E" },
|
|
242
|
+
version: { type: "string", description: "\u7248\u672C\u53F7", pattern: "^\\d+\\.\\d+\\.\\d+$" },
|
|
243
|
+
status: { type: "string", enum: ["active", "deprecated", "disabled"], description: "\u72B6\u6001" }
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
var SCHEMA_VERSIONS = {
|
|
247
|
+
pageSchema: "1.0.0",
|
|
248
|
+
componentMeta: "1.0.0",
|
|
249
|
+
actionSpec: "1.0.0",
|
|
250
|
+
dataQuerySpec: "1.0.0"
|
|
251
|
+
};
|
|
252
|
+
function getAllSchemas() {
|
|
253
|
+
return [
|
|
254
|
+
{
|
|
255
|
+
name: "page-schema",
|
|
256
|
+
version: SCHEMA_VERSIONS.pageSchema,
|
|
257
|
+
description: "\u9875\u9762 Schema \u5B9A\u4E49",
|
|
258
|
+
schema: pageSchema
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: "component-meta",
|
|
262
|
+
version: SCHEMA_VERSIONS.componentMeta,
|
|
263
|
+
description: "\u7EC4\u4EF6\u5143\u6570\u636E Schema \u5B9A\u4E49",
|
|
264
|
+
schema: componentMetaSchema
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
name: "action-spec",
|
|
268
|
+
version: SCHEMA_VERSIONS.actionSpec,
|
|
269
|
+
description: "Action \u89C4\u8303 Schema \u5B9A\u4E49",
|
|
270
|
+
schema: actionSpecSchema
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
name: "data-query-spec",
|
|
274
|
+
version: SCHEMA_VERSIONS.dataQuerySpec,
|
|
275
|
+
description: "Data Query \u89C4\u8303 Schema \u5B9A\u4E49",
|
|
276
|
+
schema: dataQuerySpecSchema
|
|
277
|
+
}
|
|
278
|
+
];
|
|
279
|
+
}
|
|
280
|
+
function getSchemaByName(name) {
|
|
281
|
+
const schemas = {
|
|
282
|
+
"page-schema": pageSchema,
|
|
283
|
+
"component-meta": componentMetaSchema,
|
|
284
|
+
"action-spec": actionSpecSchema,
|
|
285
|
+
"data-query-spec": dataQuerySpecSchema
|
|
286
|
+
};
|
|
287
|
+
return schemas[name];
|
|
288
|
+
}
|
|
289
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
290
|
+
0 && (module.exports = {
|
|
291
|
+
SCHEMA_VERSIONS,
|
|
292
|
+
actionSpecSchema,
|
|
293
|
+
componentMetaSchema,
|
|
294
|
+
dataQuerySpecSchema,
|
|
295
|
+
getAllSchemas,
|
|
296
|
+
getSchemaByName,
|
|
297
|
+
pageSchema
|
|
298
|
+
});
|
|
299
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @djvlc/contracts-schemas - DJV 低代码平台 JSON Schema 定义包\n *\n * 提供所有协议的 JSON Schema 定义,用于:\n * - Editor: 配置表单校验\n * - Platform: 发布时校验\n * - Runtime: 运行时校验/降级\n *\n * @packageDocumentation\n */\n\n\n// 直接导出 Schema 对象(避免 JSON 导入问题)\nexport const pageSchema = {\n $schema: 'http://json-schema.org/draft-07/schema#',\n $id: 'https://djvlc.com/schemas/page-schema.json',\n title: 'PageSchema',\n description: 'DJV 低代码平台页面 Schema 定义',\n type: 'object',\n required: ['schemaVersion', 'page', 'components'],\n properties: {\n schemaVersion: {\n type: 'string',\n description: 'Schema 版本号',\n pattern: '^\\\\d+\\\\.\\\\d+\\\\.\\\\d+$',\n },\n page: { $ref: '#/definitions/PageConfig' },\n components: {\n type: 'array',\n description: '组件实例列表',\n items: { $ref: '#/definitions/ComponentInstance' },\n },\n actionDefVersionIds: {\n type: 'array',\n description: '绑定的 ActionDefinition 版本 ID',\n items: { type: 'string' },\n },\n dataQueryVersionIds: {\n type: 'array',\n description: '绑定的 DataQuery 版本 ID',\n items: { type: 'string' },\n },\n },\n definitions: {\n PageConfig: {\n type: 'object',\n required: ['id', 'title', 'canvas'],\n properties: {\n id: { type: 'string', description: '页面 ID' },\n title: { type: 'string', description: '页面标题' },\n description: { type: 'string', description: '页面描述' },\n canvas: { $ref: '#/definitions/CanvasConfig' },\n meta: { $ref: '#/definitions/PageMeta' },\n variables: { type: 'object', description: '页面变量' },\n apis: { type: 'array', items: { $ref: '#/definitions/ApiConfig' } },\n },\n },\n CanvasConfig: {\n type: 'object',\n required: ['type', 'width'],\n properties: {\n type: { type: 'string', enum: ['h5', 'tablet', 'pc'], description: '画布类型' },\n width: { type: 'number', description: '画布宽度' },\n height: { type: 'number', description: '画布高度' },\n background: { type: 'string', description: '背景色' },\n gridSize: { type: 'number', description: '网格大小' },\n showGrid: { type: 'boolean', description: '是否显示网格' },\n showRuler: { type: 'boolean', description: '是否显示标尺' },\n },\n },\n PageMeta: {\n type: 'object',\n properties: {\n createTime: { type: 'string', format: 'date-time' },\n updateTime: { type: 'string', format: 'date-time' },\n author: { type: 'string' },\n version: { type: 'string' },\n tags: { type: 'array', items: { type: 'string' } },\n status: { type: 'string', enum: ['draft', 'published'] },\n },\n },\n ApiConfig: {\n type: 'object',\n required: ['id', 'name', 'url', 'method'],\n properties: {\n id: { type: 'string' },\n name: { type: 'string' },\n url: { type: 'string' },\n method: { type: 'string', enum: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'] },\n headers: { type: 'object' },\n params: { type: 'object' },\n body: { type: 'object' },\n timeout: { type: 'number' },\n autoRun: { type: 'boolean' },\n dependencies: { type: 'array', items: { type: 'string' } },\n },\n },\n ComponentInstance: {\n type: 'object',\n required: ['id', 'type', 'props', 'style'],\n properties: {\n id: { type: 'string', description: '组件实例 ID' },\n type: { type: 'string', description: '组件类型' },\n name: { type: 'string', description: '组件名称' },\n props: { type: 'object', description: '组件属性' },\n style: { type: 'object', description: '组件样式' },\n layout: { $ref: '#/definitions/ComponentLayout' },\n events: { type: 'array', items: { $ref: '#/definitions/ComponentEvent' } },\n visible: { type: 'boolean' },\n locked: { type: 'boolean' },\n children: { type: 'array', items: { $ref: '#/definitions/ComponentInstance' } },\n },\n },\n ComponentLayout: {\n type: 'object',\n properties: {\n x: { type: 'number' },\n y: { type: 'number' },\n width: { type: 'number' },\n height: { type: 'number' },\n rotation: { type: 'number' },\n },\n },\n ComponentEvent: {\n type: 'object',\n required: ['id', 'trigger', 'actions'],\n properties: {\n id: { type: 'string' },\n trigger: { type: 'string' },\n actions: { type: 'array', items: { $ref: '#/definitions/EventAction' } },\n enabled: { type: 'boolean' },\n condition: { type: 'string' },\n debounce: { type: 'number' },\n throttle: { type: 'number' },\n },\n },\n EventAction: {\n type: 'object',\n required: ['id', 'type', 'params'],\n properties: {\n id: { type: 'string' },\n type: { type: 'string' },\n params: { type: 'object' },\n enabled: { type: 'boolean' },\n delay: { type: 'number' },\n },\n },\n },\n} as const;\n\nexport const componentMetaSchema = {\n $schema: 'http://json-schema.org/draft-07/schema#',\n $id: 'https://djvlc.com/schemas/component-meta.json',\n title: 'ComponentMeta',\n description: 'DJV 低代码平台组件元数据 Schema 定义',\n type: 'object',\n required: ['name', 'version', 'label', 'category', 'props', 'events', 'capabilities', 'compat', 'integrity', 'status', 'entry'],\n properties: {\n name: { type: 'string', description: '组件名称', pattern: '^[a-z][a-z0-9-]*$' },\n version: { type: 'string', description: '版本号 (semver)', pattern: '^\\\\d+\\\\.\\\\d+\\\\.\\\\d+(-[a-zA-Z0-9.]+)?$' },\n label: { type: 'string', description: '显示名称' },\n description: { type: 'string', description: '组件描述' },\n icon: { type: 'string', description: '组件图标' },\n category: {\n type: 'string',\n enum: ['basic', 'form', 'layout', 'navigation', 'feedback', 'display', 'data', 'business', 'chart', 'other'],\n description: '组件分类',\n },\n tags: { type: 'array', items: { type: 'string' }, description: '组件标签' },\n author: { type: 'string', description: '组件作者' },\n props: { type: 'object', description: '属性定义' },\n events: { type: 'object', description: '事件定义' },\n capabilities: { type: 'object', description: '能力声明' },\n compat: { type: 'object', description: '兼容性' },\n integrity: { type: 'object', description: '完整性校验' },\n status: {\n type: 'string',\n enum: ['draft', 'canary', 'stable', 'deprecated', 'blocked'],\n description: '组件状态',\n },\n preview: { type: 'string', description: '预览图 URL' },\n entry: { type: 'string', description: '入口文件路径' },\n styles: { type: 'array', items: { type: 'string' }, description: '样式文件路径' },\n },\n} as const;\n\nexport const actionSpecSchema = {\n $schema: 'http://json-schema.org/draft-07/schema#',\n $id: 'https://djvlc.com/schemas/action-spec.json',\n title: 'ActionDefinition',\n description: 'DJV 低代码平台 Action 定义 Schema',\n type: 'object',\n required: ['id', 'name', 'actionType', 'paramsSchema', 'requiresAuth', 'version', 'status'],\n properties: {\n id: { type: 'string', description: '动作 ID' },\n name: { type: 'string', description: '动作名称' },\n actionType: { type: 'string', description: '动作类型' },\n description: { type: 'string', description: '动作描述' },\n paramsSchema: { type: 'object', description: '参数 Schema' },\n responseSchema: { type: 'object', description: '响应 Schema' },\n requiresAuth: { type: 'boolean', description: '是否需要认证' },\n idempotencyRule: { type: 'object', description: '幂等规则' },\n rateLimitRule: { type: 'object', description: '频控规则' },\n version: { type: 'string', description: '版本号', pattern: '^\\\\d+\\\\.\\\\d+\\\\.\\\\d+$' },\n status: { type: 'string', enum: ['active', 'deprecated', 'disabled'], description: '状态' },\n },\n} as const;\n\nexport const dataQuerySpecSchema = {\n $schema: 'http://json-schema.org/draft-07/schema#',\n $id: 'https://djvlc.com/schemas/data-query-spec.json',\n title: 'DataQueryDefinition',\n description: 'DJV 低代码平台 Data Query 定义 Schema',\n type: 'object',\n required: ['id', 'name', 'sourceType', 'sourceConfig', 'paramsSchema', 'responseSchema', 'version', 'status'],\n properties: {\n id: { type: 'string', description: '查询 ID' },\n name: { type: 'string', description: '查询名称' },\n description: { type: 'string', description: '查询描述' },\n sourceType: { type: 'string', enum: ['api', 'database', 'cache', 'custom'], description: '数据源类型' },\n sourceConfig: { type: 'object', description: '数据源配置' },\n paramsSchema: { type: 'object', description: '参数 Schema' },\n responseSchema: { type: 'object', description: '响应 Schema' },\n allowedFields: { type: 'array', items: { type: 'string' }, description: '字段白名单' },\n maskRules: { type: 'array', description: '脱敏规则' },\n cacheConfig: { type: 'object', description: '缓存配置' },\n version: { type: 'string', description: '版本号', pattern: '^\\\\d+\\\\.\\\\d+\\\\.\\\\d+$' },\n status: { type: 'string', enum: ['active', 'deprecated', 'disabled'], description: '状态' },\n },\n} as const;\n\n// Schema 版本\nexport const SCHEMA_VERSIONS = {\n pageSchema: '1.0.0',\n componentMeta: '1.0.0',\n actionSpec: '1.0.0',\n dataQuerySpec: '1.0.0',\n} as const;\n\n// Schema 元数据\nexport interface SchemaMetadata {\n name: string;\n version: string;\n description: string;\n schema: object;\n}\n\n/**\n * 获取所有 Schema 的元数据\n */\nexport function getAllSchemas(): SchemaMetadata[] {\n return [\n {\n name: 'page-schema',\n version: SCHEMA_VERSIONS.pageSchema,\n description: '页面 Schema 定义',\n schema: pageSchema,\n },\n {\n name: 'component-meta',\n version: SCHEMA_VERSIONS.componentMeta,\n description: '组件元数据 Schema 定义',\n schema: componentMetaSchema,\n },\n {\n name: 'action-spec',\n version: SCHEMA_VERSIONS.actionSpec,\n description: 'Action 规范 Schema 定义',\n schema: actionSpecSchema,\n },\n {\n name: 'data-query-spec',\n version: SCHEMA_VERSIONS.dataQuerySpec,\n description: 'Data Query 规范 Schema 定义',\n schema: dataQuerySpecSchema,\n },\n ];\n}\n\n/**\n * 根据名称获取 Schema\n */\nexport function getSchemaByName(\n name: 'page-schema' | 'component-meta' | 'action-spec' | 'data-query-spec'\n): object {\n const schemas: Record<string, object> = {\n 'page-schema': pageSchema,\n 'component-meta': componentMetaSchema,\n 'action-spec':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,eAAK;AAAA,EAC1F;AACF;AAGO,IAAM,kBAAkB;AAAA,EAC7B,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,eAAe;AACjB;AAaO,SAAS,gBAAkC;AAChD,SAAO;AAAA,IACL;AAAA,MACE,MAAM;AAAA,MACN,SAAS,gBAAgB;AAAA,MACzB,aAAa;AAAA,MACb,QAAQ;AAAA,IACV;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,SAAS,gBAAgB;AAAA,MACzB,aAAa;AAAA,MACb,QAAQ;AAAA,IACV;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,SAAS,gBAAgB;AAAA,MACzB,aAAa;AAAA,MACb,QAAQ;AAAA,IACV;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,SAAS,gBAAgB;AAAA,MACzB,aAAa;AAAA,MACb,QAAQ;AAAA,IACV;AAAA,EACF;AACF;AAKO,SAAS,gBACd,MACQ;AACR,QAAM,UAAkC;AAAA,IACtC,eAAe;AAAA,IACf,kBAAkB;AAAA,IAClB,eAAe;AAAA,IACf,mBAAmB;AAAA,EACrB;AACA,SAAO,QAAQ,IAAI;AACrB;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var pageSchema = {
|
|
3
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
$id: "https://djvlc.com/schemas/page-schema.json",
|
|
5
|
+
title: "PageSchema",
|
|
6
|
+
description: "DJV \u4F4E\u4EE3\u7801\u5E73\u53F0\u9875\u9762 Schema \u5B9A\u4E49",
|
|
7
|
+
type: "object",
|
|
8
|
+
required: ["schemaVersion", "page", "components"],
|
|
9
|
+
properties: {
|
|
10
|
+
schemaVersion: {
|
|
11
|
+
type: "string",
|
|
12
|
+
description: "Schema \u7248\u672C\u53F7",
|
|
13
|
+
pattern: "^\\d+\\.\\d+\\.\\d+$"
|
|
14
|
+
},
|
|
15
|
+
page: { $ref: "#/definitions/PageConfig" },
|
|
16
|
+
components: {
|
|
17
|
+
type: "array",
|
|
18
|
+
description: "\u7EC4\u4EF6\u5B9E\u4F8B\u5217\u8868",
|
|
19
|
+
items: { $ref: "#/definitions/ComponentInstance" }
|
|
20
|
+
},
|
|
21
|
+
actionDefVersionIds: {
|
|
22
|
+
type: "array",
|
|
23
|
+
description: "\u7ED1\u5B9A\u7684 ActionDefinition \u7248\u672C ID",
|
|
24
|
+
items: { type: "string" }
|
|
25
|
+
},
|
|
26
|
+
dataQueryVersionIds: {
|
|
27
|
+
type: "array",
|
|
28
|
+
description: "\u7ED1\u5B9A\u7684 DataQuery \u7248\u672C ID",
|
|
29
|
+
items: { type: "string" }
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
definitions: {
|
|
33
|
+
PageConfig: {
|
|
34
|
+
type: "object",
|
|
35
|
+
required: ["id", "title", "canvas"],
|
|
36
|
+
properties: {
|
|
37
|
+
id: { type: "string", description: "\u9875\u9762 ID" },
|
|
38
|
+
title: { type: "string", description: "\u9875\u9762\u6807\u9898" },
|
|
39
|
+
description: { type: "string", description: "\u9875\u9762\u63CF\u8FF0" },
|
|
40
|
+
canvas: { $ref: "#/definitions/CanvasConfig" },
|
|
41
|
+
meta: { $ref: "#/definitions/PageMeta" },
|
|
42
|
+
variables: { type: "object", description: "\u9875\u9762\u53D8\u91CF" },
|
|
43
|
+
apis: { type: "array", items: { $ref: "#/definitions/ApiConfig" } }
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
CanvasConfig: {
|
|
47
|
+
type: "object",
|
|
48
|
+
required: ["type", "width"],
|
|
49
|
+
properties: {
|
|
50
|
+
type: { type: "string", enum: ["h5", "tablet", "pc"], description: "\u753B\u5E03\u7C7B\u578B" },
|
|
51
|
+
width: { type: "number", description: "\u753B\u5E03\u5BBD\u5EA6" },
|
|
52
|
+
height: { type: "number", description: "\u753B\u5E03\u9AD8\u5EA6" },
|
|
53
|
+
background: { type: "string", description: "\u80CC\u666F\u8272" },
|
|
54
|
+
gridSize: { type: "number", description: "\u7F51\u683C\u5927\u5C0F" },
|
|
55
|
+
showGrid: { type: "boolean", description: "\u662F\u5426\u663E\u793A\u7F51\u683C" },
|
|
56
|
+
showRuler: { type: "boolean", description: "\u662F\u5426\u663E\u793A\u6807\u5C3A" }
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
PageMeta: {
|
|
60
|
+
type: "object",
|
|
61
|
+
properties: {
|
|
62
|
+
createTime: { type: "string", format: "date-time" },
|
|
63
|
+
updateTime: { type: "string", format: "date-time" },
|
|
64
|
+
author: { type: "string" },
|
|
65
|
+
version: { type: "string" },
|
|
66
|
+
tags: { type: "array", items: { type: "string" } },
|
|
67
|
+
status: { type: "string", enum: ["draft", "published"] }
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
ApiConfig: {
|
|
71
|
+
type: "object",
|
|
72
|
+
required: ["id", "name", "url", "method"],
|
|
73
|
+
properties: {
|
|
74
|
+
id: { type: "string" },
|
|
75
|
+
name: { type: "string" },
|
|
76
|
+
url: { type: "string" },
|
|
77
|
+
method: { type: "string", enum: ["GET", "POST", "PUT", "DELETE", "PATCH"] },
|
|
78
|
+
headers: { type: "object" },
|
|
79
|
+
params: { type: "object" },
|
|
80
|
+
body: { type: "object" },
|
|
81
|
+
timeout: { type: "number" },
|
|
82
|
+
autoRun: { type: "boolean" },
|
|
83
|
+
dependencies: { type: "array", items: { type: "string" } }
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
ComponentInstance: {
|
|
87
|
+
type: "object",
|
|
88
|
+
required: ["id", "type", "props", "style"],
|
|
89
|
+
properties: {
|
|
90
|
+
id: { type: "string", description: "\u7EC4\u4EF6\u5B9E\u4F8B ID" },
|
|
91
|
+
type: { type: "string", description: "\u7EC4\u4EF6\u7C7B\u578B" },
|
|
92
|
+
name: { type: "string", description: "\u7EC4\u4EF6\u540D\u79F0" },
|
|
93
|
+
props: { type: "object", description: "\u7EC4\u4EF6\u5C5E\u6027" },
|
|
94
|
+
style: { type: "object", description: "\u7EC4\u4EF6\u6837\u5F0F" },
|
|
95
|
+
layout: { $ref: "#/definitions/ComponentLayout" },
|
|
96
|
+
events: { type: "array", items: { $ref: "#/definitions/ComponentEvent" } },
|
|
97
|
+
visible: { type: "boolean" },
|
|
98
|
+
locked: { type: "boolean" },
|
|
99
|
+
children: { type: "array", items: { $ref: "#/definitions/ComponentInstance" } }
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
ComponentLayout: {
|
|
103
|
+
type: "object",
|
|
104
|
+
properties: {
|
|
105
|
+
x: { type: "number" },
|
|
106
|
+
y: { type: "number" },
|
|
107
|
+
width: { type: "number" },
|
|
108
|
+
height: { type: "number" },
|
|
109
|
+
rotation: { type: "number" }
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
ComponentEvent: {
|
|
113
|
+
type: "object",
|
|
114
|
+
required: ["id", "trigger", "actions"],
|
|
115
|
+
properties: {
|
|
116
|
+
id: { type: "string" },
|
|
117
|
+
trigger: { type: "string" },
|
|
118
|
+
actions: { type: "array", items: { $ref: "#/definitions/EventAction" } },
|
|
119
|
+
enabled: { type: "boolean" },
|
|
120
|
+
condition: { type: "string" },
|
|
121
|
+
debounce: { type: "number" },
|
|
122
|
+
throttle: { type: "number" }
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
EventAction: {
|
|
126
|
+
type: "object",
|
|
127
|
+
required: ["id", "type", "params"],
|
|
128
|
+
properties: {
|
|
129
|
+
id: { type: "string" },
|
|
130
|
+
type: { type: "string" },
|
|
131
|
+
params: { type: "object" },
|
|
132
|
+
enabled: { type: "boolean" },
|
|
133
|
+
delay: { type: "number" }
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
var componentMetaSchema = {
|
|
139
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
140
|
+
$id: "https://djvlc.com/schemas/component-meta.json",
|
|
141
|
+
title: "ComponentMeta",
|
|
142
|
+
description: "DJV \u4F4E\u4EE3\u7801\u5E73\u53F0\u7EC4\u4EF6\u5143\u6570\u636E Schema \u5B9A\u4E49",
|
|
143
|
+
type: "object",
|
|
144
|
+
required: ["name", "version", "label", "category", "props", "events", "capabilities", "compat", "integrity", "status", "entry"],
|
|
145
|
+
properties: {
|
|
146
|
+
name: { type: "string", description: "\u7EC4\u4EF6\u540D\u79F0", pattern: "^[a-z][a-z0-9-]*$" },
|
|
147
|
+
version: { type: "string", description: "\u7248\u672C\u53F7 (semver)", pattern: "^\\d+\\.\\d+\\.\\d+(-[a-zA-Z0-9.]+)?$" },
|
|
148
|
+
label: { type: "string", description: "\u663E\u793A\u540D\u79F0" },
|
|
149
|
+
description: { type: "string", description: "\u7EC4\u4EF6\u63CF\u8FF0" },
|
|
150
|
+
icon: { type: "string", description: "\u7EC4\u4EF6\u56FE\u6807" },
|
|
151
|
+
category: {
|
|
152
|
+
type: "string",
|
|
153
|
+
enum: ["basic", "form", "layout", "navigation", "feedback", "display", "data", "business", "chart", "other"],
|
|
154
|
+
description: "\u7EC4\u4EF6\u5206\u7C7B"
|
|
155
|
+
},
|
|
156
|
+
tags: { type: "array", items: { type: "string" }, description: "\u7EC4\u4EF6\u6807\u7B7E" },
|
|
157
|
+
author: { type: "string", description: "\u7EC4\u4EF6\u4F5C\u8005" },
|
|
158
|
+
props: { type: "object", description: "\u5C5E\u6027\u5B9A\u4E49" },
|
|
159
|
+
events: { type: "object", description: "\u4E8B\u4EF6\u5B9A\u4E49" },
|
|
160
|
+
capabilities: { type: "object", description: "\u80FD\u529B\u58F0\u660E" },
|
|
161
|
+
compat: { type: "object", description: "\u517C\u5BB9\u6027" },
|
|
162
|
+
integrity: { type: "object", description: "\u5B8C\u6574\u6027\u6821\u9A8C" },
|
|
163
|
+
status: {
|
|
164
|
+
type: "string",
|
|
165
|
+
enum: ["draft", "canary", "stable", "deprecated", "blocked"],
|
|
166
|
+
description: "\u7EC4\u4EF6\u72B6\u6001"
|
|
167
|
+
},
|
|
168
|
+
preview: { type: "string", description: "\u9884\u89C8\u56FE URL" },
|
|
169
|
+
entry: { type: "string", description: "\u5165\u53E3\u6587\u4EF6\u8DEF\u5F84" },
|
|
170
|
+
styles: { type: "array", items: { type: "string" }, description: "\u6837\u5F0F\u6587\u4EF6\u8DEF\u5F84" }
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
var actionSpecSchema = {
|
|
174
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
175
|
+
$id: "https://djvlc.com/schemas/action-spec.json",
|
|
176
|
+
title: "ActionDefinition",
|
|
177
|
+
description: "DJV \u4F4E\u4EE3\u7801\u5E73\u53F0 Action \u5B9A\u4E49 Schema",
|
|
178
|
+
type: "object",
|
|
179
|
+
required: ["id", "name", "actionType", "paramsSchema", "requiresAuth", "version", "status"],
|
|
180
|
+
properties: {
|
|
181
|
+
id: { type: "string", description: "\u52A8\u4F5C ID" },
|
|
182
|
+
name: { type: "string", description: "\u52A8\u4F5C\u540D\u79F0" },
|
|
183
|
+
actionType: { type: "string", description: "\u52A8\u4F5C\u7C7B\u578B" },
|
|
184
|
+
description: { type: "string", description: "\u52A8\u4F5C\u63CF\u8FF0" },
|
|
185
|
+
paramsSchema: { type: "object", description: "\u53C2\u6570 Schema" },
|
|
186
|
+
responseSchema: { type: "object", description: "\u54CD\u5E94 Schema" },
|
|
187
|
+
requiresAuth: { type: "boolean", description: "\u662F\u5426\u9700\u8981\u8BA4\u8BC1" },
|
|
188
|
+
idempotencyRule: { type: "object", description: "\u5E42\u7B49\u89C4\u5219" },
|
|
189
|
+
rateLimitRule: { type: "object", description: "\u9891\u63A7\u89C4\u5219" },
|
|
190
|
+
version: { type: "string", description: "\u7248\u672C\u53F7", pattern: "^\\d+\\.\\d+\\.\\d+$" },
|
|
191
|
+
status: { type: "string", enum: ["active", "deprecated", "disabled"], description: "\u72B6\u6001" }
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
var dataQuerySpecSchema = {
|
|
195
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
196
|
+
$id: "https://djvlc.com/schemas/data-query-spec.json",
|
|
197
|
+
title: "DataQueryDefinition",
|
|
198
|
+
description: "DJV \u4F4E\u4EE3\u7801\u5E73\u53F0 Data Query \u5B9A\u4E49 Schema",
|
|
199
|
+
type: "object",
|
|
200
|
+
required: ["id", "name", "sourceType", "sourceConfig", "paramsSchema", "responseSchema", "version", "status"],
|
|
201
|
+
properties: {
|
|
202
|
+
id: { type: "string", description: "\u67E5\u8BE2 ID" },
|
|
203
|
+
name: { type: "string", description: "\u67E5\u8BE2\u540D\u79F0" },
|
|
204
|
+
description: { type: "string", description: "\u67E5\u8BE2\u63CF\u8FF0" },
|
|
205
|
+
sourceType: { type: "string", enum: ["api", "database", "cache", "custom"], description: "\u6570\u636E\u6E90\u7C7B\u578B" },
|
|
206
|
+
sourceConfig: { type: "object", description: "\u6570\u636E\u6E90\u914D\u7F6E" },
|
|
207
|
+
paramsSchema: { type: "object", description: "\u53C2\u6570 Schema" },
|
|
208
|
+
responseSchema: { type: "object", description: "\u54CD\u5E94 Schema" },
|
|
209
|
+
allowedFields: { type: "array", items: { type: "string" }, description: "\u5B57\u6BB5\u767D\u540D\u5355" },
|
|
210
|
+
maskRules: { type: "array", description: "\u8131\u654F\u89C4\u5219" },
|
|
211
|
+
cacheConfig: { type: "object", description: "\u7F13\u5B58\u914D\u7F6E" },
|
|
212
|
+
version: { type: "string", description: "\u7248\u672C\u53F7", pattern: "^\\d+\\.\\d+\\.\\d+$" },
|
|
213
|
+
status: { type: "string", enum: ["active", "deprecated", "disabled"], description: "\u72B6\u6001" }
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
var SCHEMA_VERSIONS = {
|
|
217
|
+
pageSchema: "1.0.0",
|
|
218
|
+
componentMeta: "1.0.0",
|
|
219
|
+
actionSpec: "1.0.0",
|
|
220
|
+
dataQuerySpec: "1.0.0"
|
|
221
|
+
};
|
|
222
|
+
function getAllSchemas() {
|
|
223
|
+
return [
|
|
224
|
+
{
|
|
225
|
+
name: "page-schema",
|
|
226
|
+
version: SCHEMA_VERSIONS.pageSchema,
|
|
227
|
+
description: "\u9875\u9762 Schema \u5B9A\u4E49",
|
|
228
|
+
schema: pageSchema
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: "component-meta",
|
|
232
|
+
version: SCHEMA_VERSIONS.componentMeta,
|
|
233
|
+
description: "\u7EC4\u4EF6\u5143\u6570\u636E Schema \u5B9A\u4E49",
|
|
234
|
+
schema: componentMetaSchema
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: "action-spec",
|
|
238
|
+
version: SCHEMA_VERSIONS.actionSpec,
|
|
239
|
+
description: "Action \u89C4\u8303 Schema \u5B9A\u4E49",
|
|
240
|
+
schema: actionSpecSchema
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
name: "data-query-spec",
|
|
244
|
+
version: SCHEMA_VERSIONS.dataQuerySpec,
|
|
245
|
+
description: "Data Query \u89C4\u8303 Schema \u5B9A\u4E49",
|
|
246
|
+
schema: dataQuerySpecSchema
|
|
247
|
+
}
|
|
248
|
+
];
|
|
249
|
+
}
|
|
250
|
+
function getSchemaByName(name) {
|
|
251
|
+
const schemas = {
|
|
252
|
+
"page-schema": pageSchema,
|
|
253
|
+
"component-meta": componentMetaSchema,
|
|
254
|
+
"action-spec": actionSpecSchema,
|
|
255
|
+
"data-query-spec": dataQuerySpecSchema
|
|
256
|
+
};
|
|
257
|
+
return schemas[name];
|
|
258
|
+
}
|
|
259
|
+
export {
|
|
260
|
+
SCHEMA_VERSIONS,
|
|
261
|
+
actionSpecSchema,
|
|
262
|
+
componentMetaSchema,
|
|
263
|
+
dataQuerySpecSchema,
|
|
264
|
+
getAllSchemas,
|
|
265
|
+
getSchemaByName,
|
|
266
|
+
pageSchema
|
|
267
|
+
};
|
|
268
|
+
//# sourceMappingURL=index.mjs.map
|