按 docs/dacli/v0.11-final.md 4 阶段执行: 1. 源码分析 docs/source-analysis.md (分析 web/views/** 页面逻辑) 2. 镜像高频 webapi (dict + workflow) 3. 新增 AI 痛点驱动命令 (form selector + workflow selector) 4. 集成到 form-development / workflow-development skill 5. 用官方示例验证 (workSystem 86 form/17 flow, developSystem 4 form) 新增模块: - src/webapi/dict.ts (15 函数镜像 web/.../systemData/dictionary.ts) - src/webapi/workflow.ts (14 函数镜像 web/.../workFlow/template.ts) - src/commands/form/selector.ts (formSelector 命令 + 树形平铺) - src/commands/workflow/selector.ts (getFlowSelector 命令) 测试: - tests/test-webapi-dict-workflow.ts (15 dict + 14 workflow 函数实测 PASS) Skill 集成: - .claude/skills/form-development/SKILL.md (新增 form selector 段) - .claude/skills/workflow-development/SKILL.md (新增 workflow selector 段) 验证 (workSystem): - form selector --json: 86 form 平铺 - workflow selector --json: 17 工作流 验证 (developSystem): - form selector --json: 4 form - workflow selector --json: 17 工作流 (跨应用可见) 源分析报告 docs/source-analysis.md 列出 18 个未覆盖模块 + 缺口分级 (P0/P1/P2). Co-Authored-By: Claude <[email protected]>
94 lines
3.3 KiB
TypeScript
94 lines
3.3 KiB
TypeScript
/**
|
|
* tests/test-webapi-dict-workflow.ts — 验证 webapi/dict + workflow import
|
|
*/
|
|
import { JnpfClient } from '../src/core/client.ts'
|
|
import { initWebapi as initDict, loadDict, isWebapiLoaded as isDictLoaded } from '../src/webapi/dict.ts'
|
|
import { initWebapi as initWf, loadWorkflow, isWebapiLoaded as isWfLoaded } from '../src/webapi/workflow.ts'
|
|
import { log } from '../src/core/log.ts'
|
|
|
|
async function main() {
|
|
log.info('=== test-webapi-dict-workflow ===')
|
|
|
|
const c = await JnpfClient.fromToken()
|
|
log.ok(`登录成功: ${c.baseUrl} appCode=${c.appCode} dbLinkId=${c.dbLinkId}`)
|
|
|
|
// ----- dict -----
|
|
log.info('--- dict ---')
|
|
await initDict(c)
|
|
log.ok(`dict init OK, isDictLoaded=${isDictLoaded()}`)
|
|
|
|
const dictFns = [
|
|
'getDictionaryType',
|
|
'getDictionaryTypeSelector',
|
|
'createDictionaryType',
|
|
'updateDictionaryType',
|
|
'getDictionaryTypeInfo',
|
|
'delDictionaryType',
|
|
'getDictionaryDataList',
|
|
'getDictionaryAll',
|
|
'getDictionaryDataTypeSelector',
|
|
'getDictionaryDataSelector',
|
|
'createDictionaryData',
|
|
'updateDictionaryData',
|
|
'getDictionaryDataInfo',
|
|
'delDictionaryData',
|
|
'exportData',
|
|
]
|
|
for (const fn of dictFns) {
|
|
if (typeof loadDict[fn] !== 'function') throw new Error(`dict.${fn} missing`)
|
|
}
|
|
log.ok(`dict ${dictFns.length} 函数可用`)
|
|
|
|
// 实测 getDictionaryType
|
|
log.info('Step: 实测 getDictionaryType({ currentPage: 1, pageSize: 5 })')
|
|
const dictList = await loadDict.getDictionaryType({ currentPage: 1, pageSize: 5 })
|
|
const arr = Array.isArray(dictList) ? dictList : dictList?.list ?? []
|
|
log.ok(`dict 返回 ${arr.length} 条`)
|
|
if (arr.length > 0) {
|
|
log.ok(`示例: id=${arr[0].id} enCode=${arr[0].enCode} fullName=${arr[0].fullName}`)
|
|
}
|
|
|
|
// 实测 getDictionaryTypeSelector
|
|
log.info('Step: 实测 getDictionaryTypeSelector()')
|
|
const sel = await loadDict.getDictionaryTypeSelector()
|
|
const selArr = Array.isArray(sel) ? sel : sel?.list ?? []
|
|
log.ok(`selector 返回 ${selArr.length} 项`)
|
|
|
|
// ----- workflow -----
|
|
log.info('--- workflow ---')
|
|
await initWf(c)
|
|
log.ok(`workflow init OK, isWfLoaded=${isWfLoaded()}`)
|
|
|
|
const wfFns = [
|
|
'getList', 'getFlowList', 'create', 'update', 'getInfo', 'delFlow', 'copy',
|
|
'exportData', 'changeType', 'saveFlow', 'getFlowInfo',
|
|
'getFlowSelector', 'getTreeList', 'getFlowFormInfo',
|
|
]
|
|
for (const fn of wfFns) {
|
|
if (typeof loadWorkflow[fn] !== 'function') throw new Error(`workflow.${fn} missing`)
|
|
}
|
|
log.ok(`workflow ${wfFns.length} 函数可用`)
|
|
|
|
// 实测 getList (流程模板列表)
|
|
log.info('Step: 实测 getList({ currentPage: 1, pageSize: 5 })')
|
|
const wfList = await loadWorkflow.getList({ currentPage: 1, pageSize: 5 })
|
|
const wfArr = Array.isArray(wfList) ? wfList : wfList?.list ?? []
|
|
log.ok(`workflow 返回 ${wfArr.length} 条`)
|
|
if (wfArr.length > 0) {
|
|
log.ok(`示例: id=${wfArr[0].id} fullName=${wfArr[0].fullName}`)
|
|
}
|
|
|
|
// 实测 getFlowSelector
|
|
log.info('Step: 实测 getFlowSelector({})')
|
|
const wfSel = await loadWorkflow.getFlowSelector({})
|
|
const wfSelArr = Array.isArray(wfSel) ? wfSel : wfSel?.list ?? []
|
|
log.ok(`flowSelector 返回 ${wfSelArr.length} 项`)
|
|
|
|
log.ok('=== 全部 PASS ===')
|
|
}
|
|
|
|
main().catch((e) => {
|
|
log.error(`FAIL: ${(e as Error).message}`)
|
|
console.error(e)
|
|
process.exit(1)
|
|
}) |