feat: add guarded BPM category and template workflow
Implement server-owned read-only sample checks, category publication, explicit order-version identity and durable PDF/archive/notification steps. Freeze category-bound templates and recipients for isolated scheduled delivery, and require human verification for unknown SMTP outcomes. Add order/batch views and local HTTP/browser/PDF/archive regression coverage. Fix Unicode Windows startup links found by full regression using IShellLinkW. Automatic processing and sending stay disabled; no service deployment. Validation: npm ci; npm test -- --test-concurrency=1 (242 pass, 1 optional ZCode skip, 0 fail); 31 syntax checks; scoped independent code review. Live BPM V13/SMB/163 acceptance remains pending.
This commit is contained in:
1 parent
6e795a99b7
commit
94fc985553
38 files changed
+1204
-131
No files matched your search
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
const {renderTemplate}=require('./mail-parser.cjs');
|
||||
const fail=(message)=>{throw Object.assign(new Error(message),{status:409});};
|
||||
function buildTemplateValues({productLine,orders,date}){
|
||||
if(typeof productLine!=='string'||!productLine.trim())fail('分类规则没有产品线。');
|
||||
if(!Array.isArray(orders)||!orders.length)fail('模板批次没有订单。');
|
||||
if(typeof date!=='string'||!date.trim())fail('模板批次没有业务日期。');
|
||||
const orderNumbers=orders.map(order=>String(order.orderNo||'').trim());if(orderNumbers.some(value=>!value))fail('模板批次存在缺少订单号的订单。');
|
||||
const orderList=orders.map(order=>String(order.brief||'')).join('\n\n');if(!orderList.trim())fail('模板批次没有简要说明原文。');
|
||||
return {'产品线':productLine.trim(),'订单号':orderNumbers.join('、'),'日期':date.trim(),'订单列表':orderList};
|
||||
}
|
||||
function renderOrderTemplate(template,input){
|
||||
if(!template||typeof template.id!=='string'||!Number.isInteger(template.version))fail('分类模板快照无效。');
|
||||
if(Array.isArray(template.attachments)&&template.attachments.length)fail('业务通知模板不能包含 PDF 或其他附件。');
|
||||
const values=buildTemplateValues(input),rendered=renderTemplate({...template,attachments:[]},values);
|
||||
return {...rendered,templateId:template.id,templateVersion:template.version,attachments:[]};
|
||||
}
|
||||
module.exports={buildTemplateValues,renderOrderTemplate};
|
||||
Reference in new issue
Block a user