34 lines
1.5 KiB
JavaScript
34 lines
1.5 KiB
JavaScript
const MODULE = 'manual-state-matrix'
|
|
const OPTIONS = { scenario: 'manual-clickable-list-state-matrix', deploymentBlocker: true }
|
|
|
|
const GROUPS = [
|
|
'order-inbound-status-fixtures',
|
|
'manual-state-loading-pda',
|
|
'manual-state-ocean-trucking',
|
|
]
|
|
|
|
function rows(value) { return Array.isArray(value) ? value : [] }
|
|
|
|
export async function run(context) {
|
|
const matrix = { marker: context.marker, generatedAt: new Date().toISOString(), pages: {} }
|
|
context.createdResources.manualStateMatrix = matrix
|
|
|
|
for (const name of GROUPS) {
|
|
const extension = await import(new URL(`./${name}.mjs`, import.meta.url))
|
|
if (typeof extension.run !== 'function') throw new Error(`${name} 必须导出 async function run(context)`)
|
|
await extension.run(context, matrix)
|
|
}
|
|
|
|
const pages = Object.entries(matrix.pages)
|
|
const missing = pages.flatMap(([page, value]) => rows(value?.requiredStatuses)
|
|
.filter((status) => !value?.fixtures?.[status]?.id)
|
|
.map((status) => `${page}:${status}`))
|
|
const missingActions = pages.flatMap(([page, value]) => rows(value?.requiredActions)
|
|
.filter((action) => !value?.actions?.[action]?.id
|
|
|| !value?.actions?.[action]?.documentId || !value?.actions?.[action]?.completedAt)
|
|
.map((action) => `${page}:action:${action}`))
|
|
context.assert(MODULE, '人工验收列表状态数据全部生成并保留', null,
|
|
pages.length > 0 && missing.length === 0 && missingActions.length === 0,
|
|
`pages=${pages.length}, missing=${[...missing, ...missingActions].join(',') || 'none'}`, OPTIONS)
|
|
}
|