feat: add category order rules and read-only sent mail history
This commit is contained in:
1 parent
388805a8a6
commit
efa982a8a1
41 files changed
+1828
-28
No files matched your search
+10
-5
@@ -21,6 +21,8 @@ const { StorageStore } = require('../modules/storage/store.cjs');
|
||||
const { StorageService } = require('../modules/storage/service.cjs');
|
||||
const { NotificationStore } = require('../modules/notifications/store.cjs');
|
||||
const { NotificationService } = require('../modules/notifications/service.cjs');
|
||||
const { RuleStore } = require('../modules/order-rules/store.cjs');
|
||||
const { OrderRuleDispatcher } = require('../modules/order-rules/dispatcher.cjs');
|
||||
|
||||
async function closeServer(server){
|
||||
if(!server)return;
|
||||
@@ -51,7 +53,7 @@ async function main(options = {}) {
|
||||
if(errors.length)throw new AggregateError(errors,'关闭服务时部分资源清理失败。');
|
||||
})();
|
||||
let server,dashboard,store,workspace,bpmSessions,custodian;
|
||||
let mailStore,mail,scanStore,scanner,storageStore,storage,notificationStore,notifications,assistantStore,assistant,health;
|
||||
let mailStore,mail,scanStore,scanner,storageStore,storage,notificationStore,notifications,orderRules,orderDispatcher,assistantStore,assistant,health;
|
||||
try {
|
||||
const tokenPath = path.join(stateDir,'pairing.key');
|
||||
let token;
|
||||
@@ -69,9 +71,9 @@ async function main(options = {}) {
|
||||
workspace=new WorkspaceStore(path.join(stateDir,'workspace'));
|
||||
// Register conditional closures before constructing later resources; partial startup follows the same path.
|
||||
cleanup.push(()=>closeServer(server));
|
||||
cleanup.push(()=>health?.close(),()=>assistant?.stop(),()=>notifications?.stop(),()=>storage?.stop(),()=>scanner?.stop(),()=>mail?.stop(),()=>custodian?.stop(),()=>bpmSessions?.shutdown());
|
||||
cleanup.push(()=>health?.close(),()=>assistant?.stop(),()=>orderDispatcher?.stop(),()=>notifications?.stop(),()=>storage?.stop(),()=>scanner?.stop(),()=>mail?.stop(),()=>custodian?.stop(),()=>bpmSessions?.shutdown());
|
||||
cleanup.push(()=>closeServer(dashboard),()=>workspace.close());
|
||||
cleanup.push(()=>mailStore?.close(),()=>scanStore?.close(),()=>storageStore?.close(),()=>notificationStore?.close(),()=>assistantStore?.close());
|
||||
cleanup.push(()=>mailStore?.close(),()=>scanStore?.close(),()=>storageStore?.close(),()=>notificationStore?.close(),()=>orderRules?.close(),()=>assistantStore?.close());
|
||||
bpmSessions=new BpmSessionManager({stateDir:path.join(stateDir,'bpm-sessions')});
|
||||
custodian=new BpmCustodian({workspace,manager:bpmSessions});
|
||||
mailStore=new MailStore(path.join(stateDir,'mail'));mail=new MailService({store:mailStore});
|
||||
@@ -79,21 +81,24 @@ async function main(options = {}) {
|
||||
scanStore=new BpmScanStore(path.join(stateDir,'bpm-scan'));scanner=new BpmScanner({store:scanStore,workspace,manager:bpmSessions,settings:()=>store.settings()});
|
||||
storageStore=new StorageStore(path.join(stateDir,'storage'));storage=new StorageService({store:storageStore,jobs:store,outputDir});
|
||||
notificationStore=new NotificationStore(path.join(stateDir,'notifications'));notificationStore.recover();notifications=new NotificationService({store:notificationStore,mail,settings:()=>store.settings(),calendar:()=>workspace.meta('calendar').overrides});
|
||||
orderRules=new RuleStore(path.join(stateDir,'order-rules'),{schedule:()=>store.settings().schedule,calendar:()=>workspace.meta('calendar').overrides});
|
||||
orderDispatcher=new OrderRuleDispatcher({store:orderRules,mail,settings:()=>store.settings(),calendar:()=>workspace.meta('calendar').overrides});
|
||||
assistantStore=new AssistantStore(path.join(stateDir,'assistant'));assistantStore.recover();assistant=new AssistantService({store:assistantStore,runtime:new ZcodeRuntime({stateDir:path.join(stateDir,'assistant','runtime')}),dashboard:store,workspace,scanner,storage});
|
||||
health=new RuntimeHealth({stateDir,startedAt,instanceId:watchdog.instanceId,workspace,scanner,storage,mail});
|
||||
await bpmSessions.migrateAccounts(workspace.snapshot().connections);
|
||||
workspace.markSessionChecksPending();
|
||||
server=await startService({token,port,outputDir,scale:config.scale,installedExtension,extensionSourceDir:path.join(root,'extension'),store,storage,watchdog,renderSnapshot:options.renderSnapshot});
|
||||
dashboard=createDashboard({store,workspace,outputDir,bpmSessions,mail,scanner,storage,notifications,assistant,health,watchdog,trustedProxy:dashboardConfig.trustedProxy===true});
|
||||
dashboard=createDashboard({store,workspace,outputDir,bpmSessions,mail,scanner,storage,notifications,orderRules,assistant,health,watchdog,trustedProxy:dashboardConfig.trustedProxy===true});
|
||||
await new Promise((resolve,reject)=>{dashboard.once('error',reject);dashboard.listen(dashboardPort,dashboardHost,resolve);});store.recoverJobs();mailStore.recoverSends();custodian.start();mail.start();scanner.start();notifications.start();
|
||||
health.start();
|
||||
orderDispatcher.start();
|
||||
if(!options.quiet){
|
||||
console.log('订单通知中心已启动。\nWeb 工作台支持业务日历、异常待办与转交、BPM 连接管理。\n在 Chrome 订单页仍可点击扩展中的“导出当前订单”。');
|
||||
console.log(`首次使用:Chrome 扩展管理 → 开发者模式 → 加载已解压的扩展程序\n选择目录:${installedExtension}\n输出目录:${outputDir}\n本地服务:http://127.0.0.1:${port}`);
|
||||
console.log(`Web 看板:http://127.0.0.1:${dashboardPort}\n${store.users().length?'使用已创建的工作台账号登录。':'首次请在部署机创建管理员。'}`);
|
||||
if(dashboardHost==='0.0.0.0')for(const list of Object.values(os.networkInterfaces()))for(const address of list || [])if(address.family==='IPv4' && !address.internal)console.log(`局域网地址:http://${address.address}:${dashboardPort}`);
|
||||
}
|
||||
return {server,dashboard,workspace,bpmSessions,custodian,mail,scanner,storage,notifications,assistant,health,stop};
|
||||
return {server,dashboard,workspace,bpmSessions,custodian,mail,scanner,storage,notifications,orderRules,orderDispatcher,assistant,health,stop};
|
||||
}catch(error){try{await stop();}catch(cleanupError){error.cleanupError=cleanupError;}throw error;}
|
||||
}
|
||||
module.exports={main};
|
||||
@@ -8,6 +8,7 @@ function createAssets(){
|
||||
'/workspace.js':{path:path.join(webRoot,'modules/workspace/view.js'),type:'text/javascript'},
|
||||
'/bpm.js':{path:path.join(webRoot,'modules/bpm/view.js'),type:'text/javascript'},
|
||||
'/mail.js':{path:path.join(webRoot,'modules/mail/view.js'),type:'text/javascript'},
|
||||
'/mail-history.js':{path:path.join(webRoot,'modules/mail/history.js'),type:'text/javascript'},
|
||||
'/orders.js':{path:path.join(webRoot,'modules/bpm/arrivals.js'),type:'text/javascript'},
|
||||
'/storage.js':{path:path.join(webRoot,'modules/storage/view.js'),type:'text/javascript'},
|
||||
'/storage-preview.html':{path:path.join(webRoot,'modules/storage/preview.html'),type:'text/html',preview:true},
|
||||
@@ -15,6 +16,9 @@ function createAssets(){
|
||||
'/storage-preview-office.js':{path:path.join(webRoot,'modules/storage/preview-office.js'),type:'text/javascript',preview:true},
|
||||
'/storage-preview-host.js':{path:path.join(webRoot,'modules/storage/preview-host.js'),type:'text/javascript'},
|
||||
'/storage-preview.css':{path:path.join(webRoot,'modules/storage/preview.css'),type:'text/css',preview:true},
|
||||
'/order-rules-editor.js':{path:path.join(webRoot,'modules/order-rules/editor.js'),type:'text/javascript'},
|
||||
'/order-rules-preview.js':{path:path.join(webRoot,'modules/order-rules/preview.js'),type:'text/javascript'},
|
||||
'/order-rules.js':{path:path.join(webRoot,'modules/order-rules/view.js'),type:'text/javascript'},
|
||||
'/notifications.js':{path:path.join(webRoot,'modules/notifications/view.js'),type:'text/javascript'},
|
||||
'/assistant.js':{path:path.join(webRoot,'modules/assistant/view.js'),type:'text/javascript'},
|
||||
'/health.js':{path:path.join(webRoot,'modules/health/view.js'),type:'text/javascript'},
|
||||
|
||||
@@ -6,13 +6,14 @@ const {mailApi}=require('../modules/mail/api.cjs');
|
||||
const {bpmScanApi}=require('../modules/bpm/scan-api.cjs');
|
||||
const {storageApi}=require('../modules/storage/api.cjs');
|
||||
const {notificationApi}=require('../modules/notifications/api.cjs');
|
||||
const {orderRuleApi}=require('../modules/order-rules/api.cjs');
|
||||
const {assistantApi}=require('../modules/assistant/api.cjs');
|
||||
const {respondToPing}=require('../platform/service/ping.cjs');
|
||||
const {createAssets,PREVIEW_CSP}=require('./assets.cjs');
|
||||
const {createAuth}=require('../modules/dashboard/auth.cjs');
|
||||
const {prepareRequest,readBody}=require('./request.cjs');
|
||||
|
||||
function createDashboard({store,outputDir,workspace,previewUserId,bpmSessions,mail,scanner,storage,notifications,assistant,health,watchdog,trustedProxy=false}) {
|
||||
function createDashboard({store,outputDir,workspace,previewUserId,bpmSessions,mail,scanner,storage,notifications,orderRules,assistant,health,watchdog,trustedProxy=false}) {
|
||||
const auth=createAuth({store,previewUserId,bpmSessions});
|
||||
let assetFor;try{assetFor=createAssets();}catch(error){auth.close();throw error;}
|
||||
const server=http.createServer(async(request,response)=>{
|
||||
@@ -37,6 +38,7 @@ function createDashboard({store,outputDir,workspace,previewUserId,bpmSessions,ma
|
||||
if(await bpmScanApi({scanner,workspace,user,sessionId:token,url,route,method:request.method,body,reply}))return;
|
||||
if(await storageApi({storage,workspace,user,url,route,method:request.method,body,request,response,reply,trustedProxy}))return;
|
||||
if(await notificationApi({notifications,workspace,user,route,method:request.method,body,reply}))return;
|
||||
if(await orderRuleApi({orderRules,mail,workspace,user,route,method:request.method,body,reply}))return;
|
||||
if(await assistantApi({assistant,workspace,user,sessionId:token,route,method:request.method,body,request,reply,trustedProxy}))return;
|
||||
if(workspaceApi({workspace,store,user,route,method:request.method,body,reply,bpmSessions}))return;
|
||||
if(await dashboardApi({store,outputDir,workspace,mail,scanner,storage,user,route,request,response,body,reply,fail}))return;
|
||||
|
||||
Reference in new issue
Block a user