feat: add AI page preview URL
This commit is contained in:
@@ -133,7 +133,7 @@ curl -X POST http://localhost:8093/api/ai/features/auto-develop \
|
|||||||
6. 生成 release plan。
|
6. 生成 release plan。
|
||||||
7. 本地 apply:实体走本机 `/api/meta/entity`,页面/服务流写本地库;如果本地最小库缺少 `sys_menu`,菜单发布标记为 `SKIPPED`,不阻断本地 gate,部署包仍保留菜单 SQL 供线上人审。
|
7. 本地 apply:实体走本机 `/api/meta/entity`,页面/服务流写本地库;如果本地最小库缺少 `sys_menu`,菜单发布标记为 `SKIPPED`,不阻断本地 gate,部署包仍保留菜单 SQL 供线上人审。
|
||||||
8. 本地 smoke:只允许 `localhost`、`127.0.0.1`、`::1` baseUrl;HTTP 状态必须匹配,且 JSON 响应体存在 `status` 时必须为 0。
|
8. 本地 smoke:只允许 `localhost`、`127.0.0.1`、`::1` baseUrl;HTTP 状态必须匹配,且 JSON 响应体存在 `status` 时必须为 0。
|
||||||
`TEST` 草稿同时包含 `renderTests`,给 Playwright 渲染验收提供 recipe、schemaUrl、预期组件、CRUD 名、数据 API、列、动作和关键文本。
|
`TEST` 草稿同时包含 `renderTests`,给 Playwright 渲染验收提供 recipe、schemaUrl、previewUrl、预期组件、CRUD 名、数据 API、列、动作和关键文本。
|
||||||
9. 若失败,自动生成 repair plan 并执行修复重试。
|
9. 若失败,自动生成 repair plan 并执行修复重试。
|
||||||
10. 生成线上人工部署包,包含 manifest、SQL 草案、回滚 SQL 和本地执行证据。
|
10. 生成线上人工部署包,包含 manifest、SQL 草案、回滚 SQL 和本地执行证据。
|
||||||
11. 可选:生成功能包快照并保存 revision,用于后续导出、差异比较和回滚扩展。
|
11. 可选:生成功能包快照并保存 revision,用于后续导出、差异比较和回滚扩展。
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ AI 自动开发链路中的 `PAGE_SCHEMA` 草稿仍然保存编译后的 amis sc
|
|||||||
- `typed-page-schema`:校验组件和 actionType 来自 EIP4 注册表。
|
- `typed-page-schema`:校验组件和 actionType 来自 EIP4 注册表。
|
||||||
- `amis-schema`:校验最终 schema 符合 amis schema。
|
- `amis-schema`:校验最终 schema 符合 amis schema。
|
||||||
- `local-smoke`:本地发布后访问页面、实体、服务流和新增接口。
|
- `local-smoke`:本地发布后访问页面、实体、服务流和新增接口。
|
||||||
- `render-plan`:`TEST` 草稿必须提供 Playwright 可消费的 `renderTests`,包含 recipe、schemaUrl、预期根组件、CRUD 名、数据 API、列表列、页面动作和关键文本。
|
- `render-plan`:`TEST` 草稿必须提供 Playwright 可消费的 `renderTests`,包含 recipe、schemaUrl、previewUrl、预期根组件、CRUD 名、数据 API、列表列、页面动作和关键文本。
|
||||||
|
|
||||||
## 后续演进
|
## 后续演进
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ java -jar platform-cli/target/platform-cli-0.1.0-SNAPSHOT.jar ai auto-develop \
|
|||||||
- 部署包存在且 `requiresHumanApproval=true`。
|
- 部署包存在且 `requiresHumanApproval=true`。
|
||||||
- 页面 schema 只能使用组件能力表中注册的组件和动作。
|
- 页面 schema 只能使用组件能力表中注册的组件和动作。
|
||||||
- `PAGE_SCHEMA` 草稿必须声明并通过 `page-recipe` 门禁;普通维护页为 `maintenance-crud-v1`,树形维护页为 `tree-crud-v1`。
|
- `PAGE_SCHEMA` 草稿必须声明并通过 `page-recipe` 门禁;普通维护页为 `maintenance-crud-v1`,树形维护页为 `tree-crud-v1`。
|
||||||
- `TEST` 草稿必须通过 `smoke-plan` 和 `render-plan`;`renderTests` 是后续 Playwright 渲染验收的输入,需包含预期组件、列、动作、数据 API 和关键文本。
|
- `TEST` 草稿必须通过 `smoke-plan` 和 `render-plan`;`renderTests` 是后续 Playwright 渲染验收的输入,需包含 previewUrl、预期组件、列、动作、数据 API 和关键文本。
|
||||||
|
|
||||||
## 页面 schema 校验
|
## 页面 schema 校验
|
||||||
|
|
||||||
|
|||||||
@@ -984,6 +984,7 @@ public class AiAgentService {
|
|||||||
String name = test.path("name").asText("");
|
String name = test.path("name").asText("");
|
||||||
String recipe = test.path("recipe").asText("");
|
String recipe = test.path("recipe").asText("");
|
||||||
String schemaUrl = test.path("schemaUrl").asText("");
|
String schemaUrl = test.path("schemaUrl").asText("");
|
||||||
|
String previewUrl = test.path("previewUrl").asText("");
|
||||||
String rootType = test.path("expectedRootType").asText("");
|
String rootType = test.path("expectedRootType").asText("");
|
||||||
String bodyType = test.path("expectedBodyType").asText("");
|
String bodyType = test.path("expectedBodyType").asText("");
|
||||||
String crudName = test.path("expectedCrudName").asText("");
|
String crudName = test.path("expectedCrudName").asText("");
|
||||||
@@ -1001,6 +1002,11 @@ public class AiAgentService {
|
|||||||
if (!schemaUrl.startsWith("/api/page/schema/")) {
|
if (!schemaUrl.startsWith("/api/page/schema/")) {
|
||||||
messages.add("render schemaUrl 必须以 /api/page/schema/ 开头: " + schemaUrl);
|
messages.add("render schemaUrl 必须以 /api/page/schema/ 开头: " + schemaUrl);
|
||||||
}
|
}
|
||||||
|
if (!previewUrl.startsWith("/amis.html?schema=")
|
||||||
|
&& !previewUrl.startsWith("/amis.html?templateId=")
|
||||||
|
&& !previewUrl.startsWith("/amis.html?schemaUrl=")) {
|
||||||
|
messages.add("render previewUrl 必须指向可解析 schema 的 /amis.html: " + previewUrl);
|
||||||
|
}
|
||||||
if (!"page".equals(rootType)) {
|
if (!"page".equals(rootType)) {
|
||||||
messages.add("render expectedRootType 必须是 page");
|
messages.add("render expectedRootType 必须是 page");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ public class AiFeatureDraftGenerator {
|
|||||||
render.put("name", "page-render");
|
render.put("name", "page-render");
|
||||||
render.put("recipe", spec.pageRecipe());
|
render.put("recipe", spec.pageRecipe());
|
||||||
render.put("schemaUrl", "/api/page/schema/" + spec.templateId());
|
render.put("schemaUrl", "/api/page/schema/" + spec.templateId());
|
||||||
|
render.put("previewUrl", "/amis.html?schema=" + spec.templateId());
|
||||||
render.put("expectedRootType", "page");
|
render.put("expectedRootType", "page");
|
||||||
render.put("expectedBodyType", "crud");
|
render.put("expectedBodyType", "crud");
|
||||||
render.put("expectedCrudName", expectedCrudName(spec));
|
render.put("expectedCrudName", expectedCrudName(spec));
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ class AiAgentServiceTest {
|
|||||||
"name":"page-render",
|
"name":"page-render",
|
||||||
"recipe":"maintenance-crud-v1",
|
"recipe":"maintenance-crud-v1",
|
||||||
"schemaUrl":"/api/page/schema/demo",
|
"schemaUrl":"/api/page/schema/demo",
|
||||||
|
"previewUrl":"/amis.html?schema=demo",
|
||||||
"expectedRootType":"page",
|
"expectedRootType":"page",
|
||||||
"expectedBodyType":"crud",
|
"expectedBodyType":"crud",
|
||||||
"expectedCrudName":"demoCrud",
|
"expectedCrudName":"demoCrud",
|
||||||
@@ -657,6 +658,7 @@ class AiAgentServiceTest {
|
|||||||
"name": "page-render",
|
"name": "page-render",
|
||||||
"recipe": "maintenance-crud-v1",
|
"recipe": "maintenance-crud-v1",
|
||||||
"schemaUrl": "/api/page/schema/test-page",
|
"schemaUrl": "/api/page/schema/test-page",
|
||||||
|
"previewUrl": "/amis.html?schema=test-page",
|
||||||
"expectedRootType": "page",
|
"expectedRootType": "page",
|
||||||
"expectedBodyType": "crud",
|
"expectedBodyType": "crud",
|
||||||
"expectedCrudName": "testPageCrud",
|
"expectedCrudName": "testPageCrud",
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ class AiFeatureDraftGeneratorTest {
|
|||||||
assertEquals("maintenance-crud-v1", test.payload().path("renderTests").get(0).path("recipe").asText());
|
assertEquals("maintenance-crud-v1", test.payload().path("renderTests").get(0).path("recipe").asText());
|
||||||
assertEquals("/api/page/schema/eip4ai-contract-type",
|
assertEquals("/api/page/schema/eip4ai-contract-type",
|
||||||
test.payload().path("renderTests").get(0).path("schemaUrl").asText());
|
test.payload().path("renderTests").get(0).path("schemaUrl").asText());
|
||||||
|
assertEquals("/amis.html?schema=eip4ai-contract-type",
|
||||||
|
test.payload().path("renderTests").get(0).path("previewUrl").asText());
|
||||||
assertEquals("eip4aiContractTypeCrud",
|
assertEquals("eip4aiContractTypeCrud",
|
||||||
test.payload().path("renderTests").get(0).path("expectedCrudName").asText());
|
test.payload().path("renderTests").get(0).path("expectedCrudName").asText());
|
||||||
assertEquals("NAME", test.payload().path("renderTests").get(0)
|
assertEquals("NAME", test.payload().path("renderTests").get(0)
|
||||||
@@ -130,6 +132,8 @@ class AiFeatureDraftGeneratorTest {
|
|||||||
assertEquals("eip4aiOrgCategoryTreeCrud",
|
assertEquals("eip4aiOrgCategoryTreeCrud",
|
||||||
test.payload().path("renderTests").get(0).path("expectedCrudName").asText());
|
test.payload().path("renderTests").get(0).path("expectedCrudName").asText());
|
||||||
assertEquals("children", test.payload().path("renderTests").get(0).path("childrenColumnName").asText());
|
assertEquals("children", test.payload().path("renderTests").get(0).path("childrenColumnName").asText());
|
||||||
|
assertEquals("/amis.html?schema=eip4ai-org-category",
|
||||||
|
test.payload().path("renderTests").get(0).path("previewUrl").asText());
|
||||||
assertEquals("/api/entity/EIP4AI_ORG_CATEGORY/tree?parentKey=PARENTID&idKey=EIP4AI_ORG_CATEGORY_ID&perPage=2000",
|
assertEquals("/api/entity/EIP4AI_ORG_CATEGORY/tree?parentKey=PARENTID&idKey=EIP4AI_ORG_CATEGORY_ID&perPage=2000",
|
||||||
test.payload().path("renderTests").get(0).path("expectedApi").asText());
|
test.payload().path("renderTests").get(0).path("expectedApi").asText());
|
||||||
assertTrue(hasText(test.payload().path("renderTests").get(0).path("expectedActions"), "新增顶级组织分类"));
|
assertTrue(hasText(test.payload().path("renderTests").get(0).path("expectedActions"), "新增顶级组织分类"));
|
||||||
|
|||||||
@@ -16,10 +16,44 @@
|
|||||||
<script>
|
<script>
|
||||||
(function () {
|
(function () {
|
||||||
const params = new URLSearchParams(location.search);
|
const params = new URLSearchParams(location.search);
|
||||||
|
const schemaId = params.get('schema') || params.get('templateId');
|
||||||
|
const schemaUrl = params.get('schemaUrl');
|
||||||
|
const source = params.get('source');
|
||||||
const template = params.get('template') || '角色维护';
|
const template = params.get('template') || '角色维护';
|
||||||
fetch('/api/poc/amis-schema?template=' + encodeURIComponent(template))
|
|
||||||
.then(r => r.json())
|
function schemaEndpoint() {
|
||||||
|
if (schemaUrl) {
|
||||||
|
if (!schemaUrl.startsWith('/api/page/schema/')) {
|
||||||
|
throw new Error('schemaUrl 只允许 /api/page/schema/ 路径');
|
||||||
|
}
|
||||||
|
return schemaUrl;
|
||||||
|
}
|
||||||
|
if (schemaId) {
|
||||||
|
return '/api/page/schema/' + encodeURIComponent(schemaId);
|
||||||
|
}
|
||||||
|
if (source === 'page-schema') {
|
||||||
|
return '/api/page/schema/' + encodeURIComponent(template);
|
||||||
|
}
|
||||||
|
return '/api/poc/amis-schema?template=' + encodeURIComponent(template);
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadSchema() {
|
||||||
|
const endpoint = schemaEndpoint();
|
||||||
|
return fetch(endpoint)
|
||||||
|
.then(r => {
|
||||||
|
if (!r.ok) {
|
||||||
|
throw new Error(endpoint + ' 返回 HTTP ' + r.status);
|
||||||
|
}
|
||||||
|
return r.json();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('root').innerText = '加载中...';
|
||||||
|
loadSchema()
|
||||||
.then(schema => {
|
.then(schema => {
|
||||||
|
if (schema && schema.status !== undefined && schema.data) {
|
||||||
|
schema = schema.data;
|
||||||
|
}
|
||||||
const amis = amisRequire('amis/embed');
|
const amis = amisRequire('amis/embed');
|
||||||
amis.embed('#root', schema);
|
amis.embed('#root', schema);
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user