- 在补数任务面板中添加入库类型单选按钮组,支持 MySQL 和 InfluxDB - 更新 AddData 接口定义,添加 StorageType 相关类型和选项接口 - 修改补数 API 请求逻辑,根据入库类型动态调整接口路径前缀 - 重构台账设备表单,统一使用装置网络参数作为 MAC 和 NDID 的单一数据源 - 优化台账线路表单,仅当存在 ID 时才设置 lineId 字段,避免空值传递 - 添加入库类型列表获取接口和相关数据处理逻辑 - 更新台账字典代码常量,新增终端型号字典码 - 优化台账树节点添加逻辑,增加前置条件验证和禁用原因提示 - 添加 InfluxDB 配置文件到额外资源目录 - 更新稳定数据分析视图,优化台账树数据结构处理和样式布局 - 完善 API 调试契约检查,确保设备和线路数据映射正确性 - 优化趋势查询性能,禁用全局加载状态提升用户体验
54 lines
2.5 KiB
JavaScript
54 lines
2.5 KiB
JavaScript
/* eslint-env node */
|
|
import fs from 'node:fs'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const currentDir = path.dirname(fileURLToPath(import.meta.url))
|
|
const apiFile = path.join(currentDir, 'index.ts')
|
|
const interfaceFile = path.join(currentDir, 'interface', 'index.ts')
|
|
|
|
const apiSource = fs.readFileSync(apiFile, 'utf8')
|
|
const interfaceSource = fs.readFileSync(interfaceFile, 'utf8')
|
|
|
|
const expectations = [
|
|
[
|
|
'equipment payload uses network param as single source for mac and ndid',
|
|
/const networkParam = resolveOptionalText\(params\.mac\)/.test(apiSource) &&
|
|
/ndid:\s*networkParam/.test(apiSource) &&
|
|
/mac:\s*networkParam/.test(apiSource)
|
|
],
|
|
['equipment payload maps devType', /devType:\s*params\.dev_type/],
|
|
['equipment payload maps devModel', /devModel:\s*params\.dev_model/],
|
|
['equipment payload maps devAccessMethod', /devAccessMethod:\s*params\.dev_access_method/],
|
|
['equipment payload maps nodeId', /nodeId:\s*params\.node_id/],
|
|
['equipment payload maps nodeProcess', /nodeProcess:\s*resolveOptionalNumber\(params\.node_process\)/],
|
|
['line payload resolves lineId only from existing line', /const lineId = resolveOptionalText\(params\.id\s*\|\|\s*params\.line_id\)/],
|
|
['line payload omits empty lineId field', /if \(lineId\) \{\s*payload\.lineId = lineId\s*\}/],
|
|
[
|
|
'new line form does not generate lineId before backend save',
|
|
/line_id:\s*''/.test(fs.readFileSync(path.join(currentDir, '..', '..', '..', 'views', 'tools', 'addLedger', 'utils', 'ledgerData.ts'), 'utf8'))
|
|
],
|
|
['line payload maps lineNo', /lineNo:\s*params\.line_no/],
|
|
['line payload maps volGrade', /volGrade:\s*params\.vol_grade/],
|
|
['line payload maps ctRatio', /ctRatio:\s*params\.ct_ratio/],
|
|
['line payload maps isGovern', /isGovern:\s*params\.is_govern/],
|
|
['tree node supports parentId', /parentId\?:\s*string/],
|
|
['tree node supports parentIds', /parentIds\?:\s*string/],
|
|
['delete response type is boolean', /requestAddLedger<boolean>\('delete',\s*'\/node'/]
|
|
]
|
|
|
|
const source = `${apiSource}\n${interfaceSource}`
|
|
const failures = expectations.filter(([, expectation]) =>
|
|
typeof expectation === 'boolean' ? !expectation : !expectation.test(source)
|
|
)
|
|
|
|
if (failures.length) {
|
|
console.error('addLedger API_DEBUG contract check failed:')
|
|
for (const [name] of failures) {
|
|
console.error(`- ${name}`)
|
|
}
|
|
process.exit(1)
|
|
}
|
|
|
|
console.log('addLedger API_DEBUG contract check passed')
|