@es-plus/mcp-server 1.0.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/LICENSE +21 -0
- package/README.md +345 -0
- package/build/core/code-generator.d.ts +9 -0
- package/build/core/code-generator.d.ts.map +1 -0
- package/build/core/code-generator.js +87 -0
- package/build/core/code-generator.js.map +1 -0
- package/build/core/constants.d.ts +61 -0
- package/build/core/constants.d.ts.map +1 -0
- package/build/core/constants.js +51 -0
- package/build/core/constants.js.map +1 -0
- package/build/core/crud-engine.d.ts +12 -0
- package/build/core/crud-engine.d.ts.map +1 -0
- package/build/core/crud-engine.js +405 -0
- package/build/core/crud-engine.js.map +1 -0
- package/build/core/schema-validator.d.ts +9 -0
- package/build/core/schema-validator.d.ts.map +1 -0
- package/build/core/schema-validator.js +57 -0
- package/build/core/schema-validator.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +18 -0
- package/build/index.js.map +1 -0
- package/build/prompts/crud-page.d.ts +3 -0
- package/build/prompts/crud-page.d.ts.map +1 -0
- package/build/prompts/crud-page.js +49 -0
- package/build/prompts/crud-page.js.map +1 -0
- package/build/prompts/form-config.d.ts +3 -0
- package/build/prompts/form-config.d.ts.map +1 -0
- package/build/prompts/form-config.js +42 -0
- package/build/prompts/form-config.js.map +1 -0
- package/build/prompts/index.d.ts +3 -0
- package/build/prompts/index.d.ts.map +1 -0
- package/build/prompts/index.js +7 -0
- package/build/prompts/index.js.map +1 -0
- package/build/resources/examples.d.ts +3 -0
- package/build/resources/examples.d.ts.map +1 -0
- package/build/resources/examples.js +36 -0
- package/build/resources/examples.js.map +1 -0
- package/build/resources/index.d.ts +3 -0
- package/build/resources/index.d.ts.map +1 -0
- package/build/resources/index.js +9 -0
- package/build/resources/index.js.map +1 -0
- package/build/resources/schemas.d.ts +3 -0
- package/build/resources/schemas.d.ts.map +1 -0
- package/build/resources/schemas.js +46 -0
- package/build/resources/schemas.js.map +1 -0
- package/build/resources/types.d.ts +3 -0
- package/build/resources/types.d.ts.map +1 -0
- package/build/resources/types.js +159 -0
- package/build/resources/types.js.map +1 -0
- package/build/tools/generate-crud-page.d.ts +3 -0
- package/build/tools/generate-crud-page.d.ts.map +1 -0
- package/build/tools/generate-crud-page.js +33 -0
- package/build/tools/generate-crud-page.js.map +1 -0
- package/build/tools/get-component-api.d.ts +3 -0
- package/build/tools/get-component-api.d.ts.map +1 -0
- package/build/tools/get-component-api.js +191 -0
- package/build/tools/get-component-api.js.map +1 -0
- package/build/tools/index.d.ts +3 -0
- package/build/tools/index.d.ts.map +1 -0
- package/build/tools/index.js +13 -0
- package/build/tools/index.js.map +1 -0
- package/build/tools/list-form-types.d.ts +3 -0
- package/build/tools/list-form-types.d.ts.map +1 -0
- package/build/tools/list-form-types.js +21 -0
- package/build/tools/list-form-types.js.map +1 -0
- package/build/tools/scaffold-page.d.ts +3 -0
- package/build/tools/scaffold-page.d.ts.map +1 -0
- package/build/tools/scaffold-page.js +38 -0
- package/build/tools/scaffold-page.js.map +1 -0
- package/build/tools/validate-config.d.ts +3 -0
- package/build/tools/validate-config.d.ts.map +1 -0
- package/build/tools/validate-config.js +60 -0
- package/build/tools/validate-config.js.map +1 -0
- package/package.json +57 -0
- package/schemas/README.md +75 -0
- package/schemas/api-params.schema.json +36 -0
- package/schemas/btn-config.schema.json +77 -0
- package/schemas/dialog-options.schema.json +149 -0
- package/schemas/form-item.schema.json +142 -0
- package/schemas/index.schema.json +71 -0
- package/schemas/table-column.schema.json +111 -0
- package/schemas/table-options.schema.json +141 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-form-types.d.ts","sourceRoot":"","sources":["../../src/tools/list-form-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,QA4BtD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FORM_TYPES } from "../core/constants.js";
|
|
2
|
+
export function registerListFormTypes(server) {
|
|
3
|
+
server.tool("list_form_types", "List all 13 available form field types (formtype) in es-plus-ui with descriptions and usage examples.", {}, async () => {
|
|
4
|
+
const lines = FORM_TYPES.map((ft, i) => `${i + 1}. **${ft.type}** — ${ft.description}\n Example: ${ft.example}`);
|
|
5
|
+
const output = [
|
|
6
|
+
"# es-plus-ui Form Types (formtype)\n",
|
|
7
|
+
"Available types for the `formtype` property in `FormItemOption`:\n",
|
|
8
|
+
...lines,
|
|
9
|
+
"",
|
|
10
|
+
"---",
|
|
11
|
+
"Usage in config:",
|
|
12
|
+
"```json",
|
|
13
|
+
'{ "prop": "status", "label": "状态", "formtype": "Select", "dataOptions": [...] }',
|
|
14
|
+
"```",
|
|
15
|
+
].join("\n");
|
|
16
|
+
return {
|
|
17
|
+
content: [{ type: "text", text: output }],
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=list-form-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-form-types.js","sourceRoot":"","sources":["../../src/tools/list-form-types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,UAAU,qBAAqB,CAAC,MAAiB;IACrD,MAAM,CAAC,IAAI,CACT,iBAAiB,EACjB,uGAAuG,EACvG,EAAE,EACF,KAAK,IAAI,EAAE;QACT,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAC1B,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CACR,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,IAAI,QAAQ,EAAE,CAAC,WAAW,iBAAiB,EAAE,CAAC,OAAO,EAAE,CAC5E,CAAC;QAEF,MAAM,MAAM,GAAG;YACb,sCAAsC;YACtC,oEAAoE;YACpE,GAAG,KAAK;YACR,EAAE;YACF,KAAK;YACL,kBAAkB;YAClB,SAAS;YACT,iFAAiF;YACjF,KAAK;SACN,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEb,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;SAC1C,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold-page.d.ts","sourceRoot":"","sources":["../../src/tools/scaffold-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,QAwCrD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { generateScaffold } from "../core/code-generator.js";
|
|
3
|
+
export function registerScaffoldPage(server) {
|
|
4
|
+
server.tool("scaffold_page", "Generate a minimal es-plus-ui page scaffold (.vue SFC) with the basic structure for query form, table, and optional dialog. Use this when you need a blank starting template.", {
|
|
5
|
+
name: z
|
|
6
|
+
.string()
|
|
7
|
+
.describe("Page name in kebab-case, e.g. 'user-management'"),
|
|
8
|
+
features: z
|
|
9
|
+
.array(z.enum(["query", "table", "dialog"]))
|
|
10
|
+
.optional()
|
|
11
|
+
.describe("Features to include. Defaults to ['query', 'table']. Options: query, table, dialog"),
|
|
12
|
+
}, async ({ name, features }) => {
|
|
13
|
+
try {
|
|
14
|
+
const code = generateScaffold(name, features);
|
|
15
|
+
const featureList = features || ["query", "table"];
|
|
16
|
+
return {
|
|
17
|
+
content: [
|
|
18
|
+
{
|
|
19
|
+
type: "text",
|
|
20
|
+
text: `Generated scaffold for "${name}" with features: ${featureList.join(", ")}\n\n${code}`,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
return {
|
|
27
|
+
content: [
|
|
28
|
+
{
|
|
29
|
+
type: "text",
|
|
30
|
+
text: `Error generating scaffold: ${error.message}`,
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
isError: true,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=scaffold-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold-page.js","sourceRoot":"","sources":["../../src/tools/scaffold-page.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,UAAU,oBAAoB,CAAC,MAAiB;IACpD,MAAM,CAAC,IAAI,CACT,eAAe,EACf,+KAA+K,EAC/K;QACE,IAAI,EAAE,CAAC;aACJ,MAAM,EAAE;aACR,QAAQ,CAAC,iDAAiD,CAAC;QAC9D,QAAQ,EAAE,CAAC;aACR,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;aAC3C,QAAQ,EAAE;aACV,QAAQ,CACP,oFAAoF,CACrF;KACJ,EACD,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC3B,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAC9C,MAAM,WAAW,GAAG,QAAQ,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACnD,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,2BAA2B,IAAI,oBAAoB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE;qBAC7F;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,8BAA8B,KAAK,CAAC,OAAO,EAAE;qBACpD;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-config.d.ts","sourceRoot":"","sources":["../../src/tools/validate-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIzE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,QAiEvD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { validateConfig, listAvailableSchemas } from "../core/schema-validator.js";
|
|
3
|
+
export function registerValidateConfig(server) {
|
|
4
|
+
server.tool("validate_config", "Validate an es-plus-ui JSON configuration against its schema. Returns validation errors and fix suggestions.", {
|
|
5
|
+
config: z
|
|
6
|
+
.string()
|
|
7
|
+
.describe("JSON string of the es-plus configuration to validate"),
|
|
8
|
+
type: z
|
|
9
|
+
.string()
|
|
10
|
+
.optional()
|
|
11
|
+
.describe(`Schema type to validate against. Available: ${listAvailableSchemas().join(", ")}. Defaults to "form-item".`),
|
|
12
|
+
}, async ({ config, type }) => {
|
|
13
|
+
try {
|
|
14
|
+
const parsed = JSON.parse(config);
|
|
15
|
+
const result = validateConfig(parsed, type);
|
|
16
|
+
if (result.valid) {
|
|
17
|
+
return {
|
|
18
|
+
content: [
|
|
19
|
+
{
|
|
20
|
+
type: "text",
|
|
21
|
+
text: "✓ Configuration is valid!",
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const output = [
|
|
27
|
+
"✗ Configuration has errors:\n",
|
|
28
|
+
...result.errors.map((e) => ` - ${e}`),
|
|
29
|
+
"",
|
|
30
|
+
result.suggestions.length > 0 ? "Suggestions:" : "",
|
|
31
|
+
...result.suggestions.map((s) => ` → ${s}`),
|
|
32
|
+
]
|
|
33
|
+
.filter(Boolean)
|
|
34
|
+
.join("\n");
|
|
35
|
+
return {
|
|
36
|
+
content: [{ type: "text", text: output }],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (error instanceof SyntaxError) {
|
|
41
|
+
return {
|
|
42
|
+
content: [
|
|
43
|
+
{
|
|
44
|
+
type: "text",
|
|
45
|
+
text: `Invalid JSON: ${error.message}\n\nSuggestion: Check for trailing commas, missing quotes, or unescaped characters.`,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
isError: true,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
content: [
|
|
53
|
+
{ type: "text", text: `Validation error: ${error.message}` },
|
|
54
|
+
],
|
|
55
|
+
isError: true,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=validate-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-config.js","sourceRoot":"","sources":["../../src/tools/validate-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnF,MAAM,UAAU,sBAAsB,CAAC,MAAiB;IACtD,MAAM,CAAC,IAAI,CACT,iBAAiB,EACjB,8GAA8G,EAC9G;QACE,MAAM,EAAE,CAAC;aACN,MAAM,EAAE;aACR,QAAQ,CAAC,sDAAsD,CAAC;QACnE,IAAI,EAAE,CAAC;aACJ,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CACP,+CAA+C,oBAAoB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,4BAA4B,CAC7G;KACJ,EACD,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE;QACzB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAClC,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAE5C,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;gBACjB,OAAO;oBACL,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,2BAA2B;yBAClC;qBACF;iBACF,CAAC;YACJ,CAAC;YAED,MAAM,MAAM,GAAG;gBACb,+BAA+B;gBAC/B,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;gBACvC,EAAE;gBACF,MAAM,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE;gBACnD,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;aAC7C;iBACE,MAAM,CAAC,OAAO,CAAC;iBACf,IAAI,CAAC,IAAI,CAAC,CAAC;YAEd,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;aAC1C,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;gBACjC,OAAO;oBACL,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,iBAAiB,KAAK,CAAC,OAAO,qFAAqF;yBAC1H;qBACF;oBACD,OAAO,EAAE,IAAI;iBACd,CAAC;YACJ,CAAC;YACD,OAAO;gBACL,OAAO,EAAE;oBACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,KAAK,CAAC,OAAO,EAAE,EAAE;iBAC7D;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@es-plus/mcp-server",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP Server for es-plus-ui - AI coding tool integration for CRUD page generation",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"mcp-server-es-plus": "./build/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./build/index.js",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./build/index.d.ts",
|
|
13
|
+
"import": "./build/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"build",
|
|
18
|
+
"schemas"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"start": "node build/index.js",
|
|
23
|
+
"dev": "tsc --watch",
|
|
24
|
+
"prepublishOnly": "npm run build"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"mcp",
|
|
28
|
+
"model-context-protocol",
|
|
29
|
+
"es-plus",
|
|
30
|
+
"vue3",
|
|
31
|
+
"crud",
|
|
32
|
+
"ai-coding",
|
|
33
|
+
"element-plus"
|
|
34
|
+
],
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=18.0.0"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/es-plus-ui/es-plus.git",
|
|
42
|
+
"directory": "packages/mcp-server"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public",
|
|
46
|
+
"registry": "https://registry.npmjs.org/"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
50
|
+
"ajv": "^8.12.0",
|
|
51
|
+
"zod": "^3.22.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/node": "^20.0.0",
|
|
55
|
+
"typescript": "^5.3.0"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# ES-Plus UI JSON Schema
|
|
2
|
+
|
|
3
|
+
JSON Schema definitions for es-plus-ui configuration objects. Enables IDE autocompletion, validation, and hover documentation when writing es-plus-ui configs.
|
|
4
|
+
|
|
5
|
+
## Usage in VS Code
|
|
6
|
+
|
|
7
|
+
### Method 1: Per-file `$schema` (for JSON config files)
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"$schema": "node_modules/es-plus-ui/schemas/form-item.schema.json",
|
|
12
|
+
"prop": "name",
|
|
13
|
+
"label": "Name",
|
|
14
|
+
"formtype": "Input"
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Method 2: VS Code settings (for `.json` files matching a pattern)
|
|
19
|
+
|
|
20
|
+
Add to `.vscode/settings.json`:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"json.schemas": [
|
|
25
|
+
{
|
|
26
|
+
"fileMatch": ["**/form-items.json", "**/formItems.json"],
|
|
27
|
+
"url": "./node_modules/es-plus-ui/schemas/form-item.schema.json"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"fileMatch": ["**/table-columns.json", "**/columns.json"],
|
|
31
|
+
"url": "./node_modules/es-plus-ui/schemas/table-column.schema.json"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"fileMatch": ["**/table-options.json"],
|
|
35
|
+
"url": "./node_modules/es-plus-ui/schemas/table-options.schema.json"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Method 3: Use with AI coding assistants
|
|
42
|
+
|
|
43
|
+
When using Cursor, Claude Code, or GitHub Copilot, include the schema in your prompt context:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
Use the es-plus-ui JSON Schema at node_modules/es-plus-ui/schemas/index.schema.json
|
|
47
|
+
to generate valid configuration for my CRUD page.
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Available Schemas
|
|
51
|
+
|
|
52
|
+
| Schema | Description |
|
|
53
|
+
|--------|-------------|
|
|
54
|
+
| `form-item.schema.json` | Single form field config (FormItemOption) |
|
|
55
|
+
| `table-column.schema.json` | Single table column config (TableColumn) |
|
|
56
|
+
| `table-options.schema.json` | Table options config (TableOptions) |
|
|
57
|
+
| `btn-config.schema.json` | Button config (BtnConfig) |
|
|
58
|
+
| `dialog-options.schema.json` | Dialog options for useDialog() |
|
|
59
|
+
| `api-params.schema.json` | API request parameters |
|
|
60
|
+
| `index.schema.json` | Root schema with all definitions |
|
|
61
|
+
|
|
62
|
+
## Schema Structure
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
index.schema.json
|
|
66
|
+
├── form-item.schema.json
|
|
67
|
+
│ └── api-params.schema.json
|
|
68
|
+
├── table-column.schema.json
|
|
69
|
+
├── table-options.schema.json
|
|
70
|
+
│ ├── api-params.schema.json
|
|
71
|
+
│ └── btn-config.schema.json
|
|
72
|
+
├── btn-config.schema.json
|
|
73
|
+
└── dialog-options.schema.json
|
|
74
|
+
└── btn-config.schema.json
|
|
75
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://es-plus-ui.github.io/schemas/api-params.schema.json",
|
|
4
|
+
"title": "API Parameters Configuration",
|
|
5
|
+
"description": "Configuration for API requests in es-plus-ui components",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["url"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"url": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "API endpoint URL"
|
|
12
|
+
},
|
|
13
|
+
"method": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"enum": ["GET", "POST", "PUT", "DELETE", "PATCH"],
|
|
16
|
+
"default": "GET",
|
|
17
|
+
"description": "HTTP request method"
|
|
18
|
+
},
|
|
19
|
+
"headers": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"description": "Request headers",
|
|
22
|
+
"additionalProperties": { "type": "string" }
|
|
23
|
+
},
|
|
24
|
+
"model": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"description": "Additional parameters merged into the request",
|
|
27
|
+
"additionalProperties": true
|
|
28
|
+
},
|
|
29
|
+
"options": {
|
|
30
|
+
"type": "object",
|
|
31
|
+
"description": "Extra request options",
|
|
32
|
+
"additionalProperties": true
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"additionalProperties": true
|
|
36
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://es-plus-ui.github.io/schemas/btn-config.schema.json",
|
|
4
|
+
"title": "Button Configuration",
|
|
5
|
+
"description": "Configuration for action buttons in es-plus-ui EsForm and EsTable",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["name"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Button display text"
|
|
12
|
+
},
|
|
13
|
+
"key": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "Button identifier. Special values: 'query' triggers table data fetch, 'reset' resets the form",
|
|
16
|
+
"examples": ["query", "reset", "add", "export"]
|
|
17
|
+
},
|
|
18
|
+
"type": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"enum": ["primary", "success", "warning", "danger", "info", ""],
|
|
21
|
+
"description": "Button visual type (Element Plus button types)"
|
|
22
|
+
},
|
|
23
|
+
"size": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"enum": ["large", "default", "small"],
|
|
26
|
+
"description": "Button size"
|
|
27
|
+
},
|
|
28
|
+
"icon": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"description": "Element Plus icon name (e.g., 'Search', 'Plus', 'Delete')"
|
|
31
|
+
},
|
|
32
|
+
"direction": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"enum": ["left", "right"],
|
|
35
|
+
"default": "right",
|
|
36
|
+
"description": "Button alignment in the form button area"
|
|
37
|
+
},
|
|
38
|
+
"loading": {
|
|
39
|
+
"type": "boolean",
|
|
40
|
+
"default": false,
|
|
41
|
+
"description": "Show loading spinner on the button"
|
|
42
|
+
},
|
|
43
|
+
"disabled": {
|
|
44
|
+
"oneOf": [
|
|
45
|
+
{ "type": "boolean" }
|
|
46
|
+
],
|
|
47
|
+
"description": "Disable the button. Can be a boolean or a function () => boolean"
|
|
48
|
+
},
|
|
49
|
+
"triggerEvent": {
|
|
50
|
+
"type": "boolean",
|
|
51
|
+
"default": false,
|
|
52
|
+
"description": "When true, automatically triggers form-table linkage. With key='query', calls parent EsTable's httpRequestInstance. With key='reset', resets form fields"
|
|
53
|
+
},
|
|
54
|
+
"click": {
|
|
55
|
+
"description": "Click handler. In form context: (model, formRef, httpRequestInstance?) => void. In dialog context: (instance, { close, getRefs, dialogVm }) => void"
|
|
56
|
+
},
|
|
57
|
+
"code": {
|
|
58
|
+
"type": "integer",
|
|
59
|
+
"enum": [1, 2],
|
|
60
|
+
"description": "Button group position in table toolbar. 1 = left group, 2 = right group"
|
|
61
|
+
},
|
|
62
|
+
"isHide": {
|
|
63
|
+
"oneOf": [
|
|
64
|
+
{ "type": "boolean" }
|
|
65
|
+
],
|
|
66
|
+
"description": "Hide the button. Can be a boolean or a function () => boolean"
|
|
67
|
+
},
|
|
68
|
+
"permissionValue": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"description": "Permission code for button visibility control"
|
|
71
|
+
},
|
|
72
|
+
"render": {
|
|
73
|
+
"description": "Custom render function for the button slot"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"additionalProperties": true
|
|
77
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://es-plus-ui.github.io/schemas/dialog-options.schema.json",
|
|
4
|
+
"title": "useDialog Options Configuration",
|
|
5
|
+
"description": "Configuration object passed to the useDialog() hook in es-plus-ui",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"title": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Dialog title"
|
|
11
|
+
},
|
|
12
|
+
"width": {
|
|
13
|
+
"oneOf": [
|
|
14
|
+
{ "type": "string" },
|
|
15
|
+
{ "type": "number" }
|
|
16
|
+
],
|
|
17
|
+
"default": "50%",
|
|
18
|
+
"description": "Dialog width (CSS value or number in px)"
|
|
19
|
+
},
|
|
20
|
+
"height": {
|
|
21
|
+
"oneOf": [
|
|
22
|
+
{ "type": "string" },
|
|
23
|
+
{ "type": "number" }
|
|
24
|
+
],
|
|
25
|
+
"description": "Dialog height"
|
|
26
|
+
},
|
|
27
|
+
"maxHeight": {
|
|
28
|
+
"oneOf": [
|
|
29
|
+
{ "type": "string" },
|
|
30
|
+
{ "type": "number" }
|
|
31
|
+
],
|
|
32
|
+
"description": "Maximum height for dialog body content area"
|
|
33
|
+
},
|
|
34
|
+
"key": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "Unique identifier. Same key reuses dialog instance"
|
|
37
|
+
},
|
|
38
|
+
"render": {
|
|
39
|
+
"description": "Content render function. Signature: (h, { registerRef, getRefs }, components) => VNode"
|
|
40
|
+
},
|
|
41
|
+
"renderHeader": {
|
|
42
|
+
"description": "Header render function. Signature: (h, instance) => VNode"
|
|
43
|
+
},
|
|
44
|
+
"renderFooter": {
|
|
45
|
+
"description": "Footer render function. Signature: (h, instance) => VNode"
|
|
46
|
+
},
|
|
47
|
+
"configBtn": {
|
|
48
|
+
"type": "array",
|
|
49
|
+
"description": "Footer action buttons. Click signature: (currentRef, { close, getRefs, dialogInstance }) => void",
|
|
50
|
+
"items": { "$ref": "btn-config.schema.json" }
|
|
51
|
+
},
|
|
52
|
+
"isDraggable": {
|
|
53
|
+
"type": "boolean",
|
|
54
|
+
"default": false,
|
|
55
|
+
"description": "Enable drag to move the dialog"
|
|
56
|
+
},
|
|
57
|
+
"fullscreen": {
|
|
58
|
+
"type": "boolean",
|
|
59
|
+
"default": false,
|
|
60
|
+
"description": "Start dialog in fullscreen mode"
|
|
61
|
+
},
|
|
62
|
+
"hiddenFullBtn": {
|
|
63
|
+
"type": "boolean",
|
|
64
|
+
"default": false,
|
|
65
|
+
"description": "Hide the fullscreen toggle button in header"
|
|
66
|
+
},
|
|
67
|
+
"isHiddenFooter": {
|
|
68
|
+
"type": "boolean",
|
|
69
|
+
"default": false,
|
|
70
|
+
"description": "Hide the entire footer section"
|
|
71
|
+
},
|
|
72
|
+
"center": {
|
|
73
|
+
"type": "boolean",
|
|
74
|
+
"description": "Vertically center the dialog"
|
|
75
|
+
},
|
|
76
|
+
"closeOnClickModal": {
|
|
77
|
+
"type": "boolean",
|
|
78
|
+
"default": false,
|
|
79
|
+
"description": "Close dialog when clicking the overlay mask"
|
|
80
|
+
},
|
|
81
|
+
"closeOnPressEscape": {
|
|
82
|
+
"type": "boolean",
|
|
83
|
+
"default": false,
|
|
84
|
+
"description": "Close dialog when pressing ESC key"
|
|
85
|
+
},
|
|
86
|
+
"showClose": {
|
|
87
|
+
"type": "boolean",
|
|
88
|
+
"default": true,
|
|
89
|
+
"description": "Show the close button in header"
|
|
90
|
+
},
|
|
91
|
+
"destroyOnClose": {
|
|
92
|
+
"type": "boolean",
|
|
93
|
+
"default": true,
|
|
94
|
+
"description": "Destroy dialog content when closed"
|
|
95
|
+
},
|
|
96
|
+
"loading": {
|
|
97
|
+
"type": "boolean",
|
|
98
|
+
"default": false,
|
|
99
|
+
"description": "Show loading state on the dialog"
|
|
100
|
+
},
|
|
101
|
+
"customClass": {
|
|
102
|
+
"type": "string",
|
|
103
|
+
"description": "Custom CSS class for the dialog"
|
|
104
|
+
},
|
|
105
|
+
"appendToBody": {
|
|
106
|
+
"type": "boolean",
|
|
107
|
+
"description": "Mount dialog to document body"
|
|
108
|
+
},
|
|
109
|
+
"appendTo": {
|
|
110
|
+
"type": "string",
|
|
111
|
+
"description": "CSS selector or HTMLElement for dialog mount target"
|
|
112
|
+
},
|
|
113
|
+
"modal": {
|
|
114
|
+
"type": "boolean",
|
|
115
|
+
"description": "Show overlay mask behind dialog"
|
|
116
|
+
},
|
|
117
|
+
"lockScroll": {
|
|
118
|
+
"type": "boolean",
|
|
119
|
+
"description": "Lock page scroll when dialog is open"
|
|
120
|
+
},
|
|
121
|
+
"onlyInstance": {
|
|
122
|
+
"type": "boolean",
|
|
123
|
+
"default": false,
|
|
124
|
+
"description": "Singleton mode: reuses one dialog instance, updates content on subsequent calls"
|
|
125
|
+
},
|
|
126
|
+
"showDefaultButtons": {
|
|
127
|
+
"type": "boolean",
|
|
128
|
+
"description": "Show default Confirm/Cancel buttons"
|
|
129
|
+
},
|
|
130
|
+
"confirmText": {
|
|
131
|
+
"type": "string",
|
|
132
|
+
"description": "Custom text for the confirm button"
|
|
133
|
+
},
|
|
134
|
+
"cancelText": {
|
|
135
|
+
"type": "string",
|
|
136
|
+
"description": "Custom text for the cancel button"
|
|
137
|
+
},
|
|
138
|
+
"onSubmit": {
|
|
139
|
+
"description": "Submit callback. Signature: (close) => void"
|
|
140
|
+
},
|
|
141
|
+
"onClosed": {
|
|
142
|
+
"description": "Callback fired after dialog is fully closed"
|
|
143
|
+
},
|
|
144
|
+
"onOpen": {
|
|
145
|
+
"description": "Callback fired when dialog opens"
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"additionalProperties": true
|
|
149
|
+
}
|