优化运行轨迹关联名称展示
This commit is contained in:
@@ -53,6 +53,30 @@ if (missingLabels.length) {
|
||||
throw new Error(`资源字段缺少中文名称:${missingLabels.join('、')}`);
|
||||
}
|
||||
|
||||
// 运行轨迹必须复用统一关联名称组件,避免再次把截断唯一标识当成业务名称。
|
||||
const trackDefinition = resources.match(
|
||||
/define\('gasorder_track',[\s\S]*?\n\s*\]\),/,
|
||||
)?.[0];
|
||||
if (!trackDefinition) throw new Error('无法读取运行轨迹资源定义');
|
||||
for (const [key, label] of [
|
||||
['gasorder_basic_identity', '配送订单'],
|
||||
['staff_account_identity', '配送人员'],
|
||||
]) {
|
||||
const field = trackDefinition.match(
|
||||
new RegExp(`relation\\('${key}'[\\s\\S]*?\\}\\)`),
|
||||
)?.[0];
|
||||
if (
|
||||
!field ||
|
||||
!field.includes(`listLabel: '${label}'`) ||
|
||||
!field.includes('listRelationNameOnly: true') ||
|
||||
!field.includes('showIdentityCopy: true') ||
|
||||
(key === 'staff_account_identity' &&
|
||||
!field.includes("staffRelation: { roles: ['delivery'] }"))
|
||||
) {
|
||||
throw new Error(`运行轨迹的${label}必须以业务名称展示并保留唯一标识复制入口`);
|
||||
}
|
||||
}
|
||||
|
||||
if (/title="ID"|data-index="id"/.test(listPage)) {
|
||||
throw new Error('标准资源列表不得把数据库ID作为业务列展示');
|
||||
}
|
||||
@@ -79,7 +103,7 @@ assertIncludes(
|
||||
);
|
||||
for (const collection of [
|
||||
'products', 'revisions', 'items', 'assignments', 'statuses',
|
||||
'tracks', 'confirmations', 'payments',
|
||||
'tracks', 'confirmations', 'payments', 'points',
|
||||
]) {
|
||||
assertIncludes(
|
||||
detailContract,
|
||||
@@ -87,5 +111,10 @@ for (const collection of [
|
||||
`缺少关联记录固定列契约:${collection}`,
|
||||
);
|
||||
}
|
||||
assertIncludes(
|
||||
display,
|
||||
"if (detail.track && typeof detail.track === 'object')",
|
||||
'运行轨迹详情必须解包 track 聚合主记录',
|
||||
);
|
||||
|
||||
process.stdout.write('平台48类资源中文展示契约检查通过\n');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* 功能:验证工作人员关联字段过滤、资质来源校验和路由上下文传递契约。
|
||||
* 版本:v1.2.0
|
||||
* 版本:v1.3.0
|
||||
*/
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
@@ -105,8 +105,17 @@ const resourcesSource = await readFile(
|
||||
assert.match(resourcesSource, /organizationScoped: true/);
|
||||
assert.equal(
|
||||
(resourcesSource.match(/staffRelation:/g) ?? []).length,
|
||||
3,
|
||||
'三个工作人员关联场景都必须显式声明策略',
|
||||
4,
|
||||
'四个工作人员关联场景都必须显式声明策略',
|
||||
);
|
||||
const trackPolicy = resourcesSource.match(
|
||||
/define\('gasorder_track',[\s\S]*?staffRelation: \{ roles: \['delivery'\] \}[\s\S]*?\n\s*\]\),/,
|
||||
)?.[0];
|
||||
assert.ok(trackPolicy, '运行轨迹必须显式限定配送人员岗位');
|
||||
assert.doesNotMatch(
|
||||
trackPolicy,
|
||||
/enabledOnly|workStatus|validCredentialOnly/,
|
||||
'历史运行轨迹不得按人员当前启用、在岗或资质状态过滤',
|
||||
);
|
||||
|
||||
const relationsSource = await readFile(
|
||||
|
||||
Reference in New Issue
Block a user