feat(bpm): add recoverable connections and passive arrival monitoring
This commit is contained in:
1 parent
2d6349134f
commit
8ca493d439
37 files changed
+676
-69
No files matched your search
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
const {loadPlaywright}=require('../../platform/browser.cjs');
|
||||
const {TODO_SOURCES}=require('./todo-client.cjs');
|
||||
const {BpmListClient}=require('./list-client.cjs');
|
||||
const {isLoginRedirect}=require('./auth-redirect.cjs');
|
||||
const fail=(status,message)=>{throw Object.assign(new Error(message),{status});};
|
||||
class BpmAccessClient{
|
||||
constructor(options={}){this.baseURL=new BpmListClient(options).baseURL;}
|
||||
async check(storageState){
|
||||
const checkedAt=new Date().toISOString();let request,authenticated=false;
|
||||
try{
|
||||
if(!storageState)fail(401,'尚未保存 BPM 会话。');
|
||||
request=await loadPlaywright().request.newContext({baseURL:this.baseURL,storageState,timeout:15000});
|
||||
const get=async(route,options={})=>{const response=await request.get(route,{...options,maxRedirects:0});const status=response.status();
|
||||
if(status===401||status>=300&&status<400&&isLoginRedirect(response.headers().location||'',this.baseURL))fail(401,'BPM 会话需要续登。');
|
||||
if(status===403)fail(403,'该账号没有读取此业务接口的权限。');if(status!==200)fail(502,'BPM 接口暂不可用。');
|
||||
const bytes=await response.body();if(bytes.length>2*1024*1024)fail(502,'BPM 检查响应过大。');return bytes.toString('utf8');};
|
||||
const html=await get('/'),token=/Yiez\.clientId\s*=\s*['"]([^'"\s<>]{1,16000})['"]/.exec(html)?.[1];
|
||||
if(!token){if(/id=["']kc-form-login["']/.test(html))fail(401,'BPM 会话需要续登。');fail(502,'门户认证响应无法验证。');}
|
||||
authenticated=true;
|
||||
for(const [,route]of TODO_SOURCES){let data;try{data=JSON.parse(await get(route,{params:{page:1,start:0,limit:1},headers:{Authorization:'Bearer '+token}}));}catch(e){if(e.status)throw e;fail(502,'待办接口格式不正确。');}
|
||||
if(data.success===false||!Array.isArray(data.children)||!Number.isSafeInteger(data.total)||data.total<0||data.children.length>1||data.total>0&&!data.children.length)fail(502,'待办接口检查未通过。');
|
||||
}
|
||||
return {status:'connected',checkedAt,checks:{portal:{ok:true,message:'已验证登录和待办读取。'}},todo:'healthy',storageState:await request.storageState()};
|
||||
}catch(e){const auth=e.status===401;return {status:auth?'login_required':authenticated?'connected':'error',checkedAt,checks:{portal:{ok:authenticated&&!auth,message:auth?'BPM 会话需要续登。':authenticated?'登录会话有效,待办读取暂不可用。':'BPM 网络或门户暂不可用。'}},todo:auth?'login_required':e.status===403?'forbidden':'error',...(authenticated&&!auth?{storageState:await request.storageState().catch(()=>undefined)}:{})};}
|
||||
finally{await request?.dispose();}
|
||||
}
|
||||
}
|
||||
module.exports={BpmAccessClient};
|
||||
@@ -17,8 +17,8 @@ async function managerCall(work){
|
||||
const status=messages[error?.status]?error.status:502;fail(status,messages[status] || 'BPM 暂时无法连接,请稍后重试。');
|
||||
}
|
||||
}
|
||||
async function bpmApi({workspace,bpmSessions,user,sessionId,route,method,body,request,response,reply,trustedProxy=false}){
|
||||
const match=/^\/api\/connections\/([\w-]+)\/(?:login\/(open|frame|input|navigate|save|close|fill-account)|(check|disable|delete)|(account)(\/(?:clear|check))?)$/.exec(route);
|
||||
async function bpmApi({workspace,bpmSessions,bpmLifecycle,user,sessionId,route,method,body,request,response,reply,trustedProxy=false}){
|
||||
const match=/^\/api\/connections\/([\w-]+)\/(?:login\/(open|frame|input|navigate|save|close|fill-account)|(check|disable|enable|delete)|(account)(\/(?:clear|check))?)$/.exec(route);
|
||||
if(!match || !workspace)return false;
|
||||
const [,id,login,other,account,suffix]=match;const action=login || other || (suffix==='/clear'?'clear-account':suffix==='/check'?'check-account':account);
|
||||
if(action==='account'?!['GET','POST'].includes(method):method!==(action==='frame'?'GET':'POST'))fail(405,'此操作不支持当前请求方式。');
|
||||
@@ -27,11 +27,13 @@ async function bpmApi({workspace,bpmSessions,user,sessionId,route,method,body,re
|
||||
if(user.role!=='admin')fail(403,'仅管理员可以删除连接。');emptyBody(body);
|
||||
if(connection.status!=='disabled')fail(409,'请先停用连接再删除。');
|
||||
if(!bpmSessions)fail(503,'BPM 登录服务暂不可用,请稍后重试。');
|
||||
await managerCall(()=>bpmSessions.disable(id));reply(200,workspace.deleteConnection(id,user));return true;
|
||||
reply(200,await bpmLifecycle.remove(id,user));return true;
|
||||
}
|
||||
if(action==='disable'){
|
||||
if(user.role!=='admin')fail(403,'仅管理员可以停用连接。');emptyBody(body);
|
||||
if(bpmSessions)await managerCall(()=>bpmSessions.disable(id));reply(200,workspace.disableConnection(id,user));return true;
|
||||
if(action==='disable'||action==='enable'){
|
||||
if(user.role!=='admin')fail(403,'仅管理员可以启用或停用连接。');
|
||||
if(!body||Array.isArray(body)||Object.keys(body).some(k=>k!=='version'))fail(400,'请提供当前连接版本。');
|
||||
const input=action==='disable'&&!Object.keys(body).length?{version:connection.version||0}:body;
|
||||
reply(200,await bpmLifecycle.change(id,action==='enable',input,user));return true;
|
||||
}
|
||||
if(connection.status==='disabled')fail(409,'此连接已停用。');
|
||||
if(!secureBpmTransport(request,trustedProxy))fail(403,'请在部署机本地或 HTTPS 页面中登录 BPM。');
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
'use strict';
|
||||
const crypto=require('node:crypto');
|
||||
const {dayPolicy}=require('../../shared/schedule.cjs');
|
||||
const {normalizeArrival}=require('./list-client.cjs');
|
||||
const {BpmSignalRClient}=require('./signalr-client.cjs');
|
||||
function todoArrival(row){
|
||||
if(row.source!=='todo'||!['portal-v4','portal-v8'].includes(row.portalSource)||row.instanceId==null||row.revision==null)throw Object.assign(new Error('真实待办身份不完整。'),{status:502});
|
||||
return {...normalizeArrival({taskId:row.taskId,startTime:row.receivedAt,serialNum:row.serialNum,processName:row.processName,activityName:row.nodeName,processInstanceSubject:row.title},'todo:'+row.portalSource),kind:'todo',instanceId:String(row.instanceId),revision:row.revision,processVersion:row.processVersion||'',recordKey:JSON.stringify([row.instanceId,row.taskId,row.revision])};
|
||||
}
|
||||
class BpmArrivalMonitor{
|
||||
constructor({workspace,manager,scanner,provider,settings,hubClient=new BpmSignalRClient(),clock=()=>Date.now(),debounceMs=750,pollMs=5000,retryMs=[2000,5000,15000,60000]}){
|
||||
Object.assign(this,{workspace,manager,scanner,provider,settings,hubClient,clock,debounceMs,pollMs,retryMs});this.entries=new Map();this.todoPending=new Map();this.stopped=false;
|
||||
this.principal={user:{username:'系统监听',role:'admin'},sessionId:'monitor:'+crypto.randomUUID()};
|
||||
}
|
||||
allowed(){const config=this.scanner.store.config();return config.enabled&&dayPolicy(new Date(this.clock()),this.settings().schedule,this.workspace.snapshot().calendar.overrides).scan;}
|
||||
active(entry){return !this.stopped&&this.entries.get(entry.id)===entry&&this.workspace.getConnection(entry.id).status!=='disabled';}
|
||||
snapshot(id){const e=this.entries.get(id);return e?{status:e.status,lastSignalAt:e.lastSignalAt||null,lastSyncAt:e.lastSyncAt||null,lastFailureAt:e.lastFailureAt||null,nextRetryAt:Number.isFinite(e.nextRetry)?new Date(e.nextRetry).toISOString():null}: {status:this.workspace.getConnection(id).status==='disabled'||!this.scanner.store.config().enabled?'paused':'waiting',lastSignalAt:null,lastSyncAt:null};}
|
||||
start(){if(this.timer||this.stopped)return;this.timer=setInterval(()=>this.tick().catch(()=>{}),this.pollMs);this.timer.unref?.();this.tick().catch(()=>{});}
|
||||
async tick(){
|
||||
if(this.stopped)return;const config=this.scanner.store.config(),connections=this.workspace.snapshot().connections,ids=new Set(connections.map(c=>c.id));
|
||||
for(const id of this.entries.keys())if(!ids.has(id)||!config.enabled||this.workspace.getConnection(id).status==='disabled')await this.stopConnection(id);
|
||||
if(!config.enabled)return;
|
||||
for(const c of connections){
|
||||
if(c.status==='disabled'||c.status==='disconnected'&&!c.lastConnectedAt)continue;
|
||||
let entry=this.entries.get(c.id);if(!entry){entry={id:c.id,status:'connecting',nextRetry:0,nextReconcile:this.clock()+config.intervalMinutes*60000,failures:0,dirty:new Set(),controller:new AbortController(),attempt:0};this.entries.set(c.id,entry);}
|
||||
if(entry.handle&&entry.epoch!==(this.manager.epoch?.(c.id)||0)){await this.stopConnection(c.id);continue;}
|
||||
if(!entry.handle&&!entry.connecting&&this.clock()>=entry.nextRetry)this.connect(entry,c);
|
||||
if(this.clock()>=entry.nextReconcile){entry.nextReconcile=this.clock()+config.intervalMinutes*60000;this.queue(entry,['todo','inform']);}
|
||||
else if(entry.dirty.size&&!entry.sync&&!entry.debounce)this.queue(entry,[]);
|
||||
}
|
||||
}
|
||||
retry(entry,status='polling',delay){if(!this.active(entry))return;if(entry.connectedAt&&this.clock()-entry.connectedAt>60000)entry.failures=0;entry.status=status;entry.nextRetry=this.clock()+(delay??this.retryMs[Math.min(entry.failures++,this.retryMs.length-1)]);}
|
||||
connect(entry,connection){
|
||||
const attempt=++entry.attempt;let closed=false;entry.status=entry.failures?'reconnecting':'connecting';
|
||||
entry.connecting=(async()=>{
|
||||
if(this.manager.sessions.has(entry.id))throw Object.assign(new Error('人工登录窗口正在使用。'),{status:409});
|
||||
const result=await this.manager.ensure(connection,this.principal);if(!this.active(entry))return;
|
||||
if(result.status!=='connected'){this.retry(entry,result.status==='login_required'?'login_required':'polling',5*60000);return;}
|
||||
entry.epoch=this.manager.epoch?.(entry.id)||0;const handle=await this.manager.run(entry.id,async()=>{
|
||||
this.manager.authorize(connection,this.principal);if(this.manager.sessions.has(entry.id))throw Object.assign(new Error('人工登录窗口正在使用。'),{status:409});
|
||||
const saved=await this.manager.vault().read(entry.id);
|
||||
return this.hubClient.connect(saved?.storageState,{signal:entry.controller.signal,onEvent:name=>{if(!this.active(entry)||entry.attempt!==attempt||entry.epoch!==(this.manager.epoch?.(entry.id)||0))return;entry.lastSignalAt=new Date(this.clock()).toISOString();this.queue(entry,name==='worklistChanged'?['todo']:name==='informlistChanged'?['inform']:['todo','inform']);},onClose:()=>{closed=true;if(this.active(entry)&&entry.attempt===attempt){entry.handle=null;this.retry(entry);}}});
|
||||
});
|
||||
if(!handle)return;if(!this.active(entry)||closed){await handle.stop();return;}
|
||||
entry.handle=handle;entry.connectedAt=this.clock();entry.status='listening';entry.nextRetry=Infinity;entry.nextReconcile=this.clock()+this.scanner.store.config().intervalMinutes*60000;this.queue(entry,['todo','inform']);
|
||||
})().catch(error=>{if(!this.active(entry))return;if(error.status===401)this.manager.observe?.(entry.id,'portal',error);this.retry(entry,error.status===409?'busy':error.status===401?'login_required':'polling',error.status===409?5000:error.status===401?5*60000:undefined);if(![401,409].includes(error.status))this.queue(entry,['todo','inform']);}).finally(()=>{entry.connecting=null;});
|
||||
}
|
||||
queue(entry,kinds){if(!this.active(entry))return;for(const kind of kinds)entry.dirty.add(kind);if(entry.sync||entry.debounce||!entry.dirty.size||!this.allowed()||this.manager.sessions.has(entry.id))return;
|
||||
entry.debounce=setTimeout(()=>{entry.debounce=null;if(!this.active(entry)||!this.allowed())return;const kinds=[...entry.dirty];entry.dirty.clear();entry.sync=this.synchronize(entry,kinds).finally(()=>{entry.sync=null;if(entry.dirty.size&&this.active(entry))this.queue(entry,[]);});},this.debounceMs);entry.debounce.unref?.();
|
||||
}
|
||||
async synchronize(entry,kinds){let valid=true;
|
||||
for(const kind of kinds){if(!this.active(entry))return;
|
||||
try{
|
||||
if(kind==='inform'){await this.scanner.scan(entry.id,this.principal);}
|
||||
else await this.startTodoScan(entry.id,this.principal).promise;
|
||||
}catch(error){valid=false;entry.lastFailureAt=new Date(this.clock()).toISOString();}
|
||||
}
|
||||
if(valid&&this.active(entry))entry.lastSyncAt=new Date(this.clock()).toISOString();
|
||||
}
|
||||
startTodoScan(id,principal){
|
||||
const fail=(message,status)=>{throw Object.assign(new Error(message),{status});};if(this.stopped)fail('监听服务正在停止。',503);
|
||||
const connection=this.workspace.getConnection(id);if(!principal?.sessionId||!['admin','operator'].includes(principal.user?.role)||principal.user.role!=='admin'&&connection.owner!==principal.user.username)fail('仅连接负责人或管理员可以同步。',403);
|
||||
if(connection.status==='disabled')fail('此连接已停用。',409);if(this.todoPending.has(id))fail('待办对账正在运行。',409);
|
||||
const runId=this.scanner.store.begin(id,principal.user.username,'todo');
|
||||
const promise=Promise.resolve().then(async()=>{
|
||||
try{let rows;try{rows=await this.provider.scan(connection,principal);}catch(error){if(error.status!==401)throw error;const result=await this.manager.ensure(connection,principal);if(result.status!=='connected')throw error;rows=await this.provider.scan(connection,principal);}
|
||||
if(this.stopped||this.workspace.getConnection(id).status==='disabled')fail('连接已暂停,本次对账未提交。',409);return {...this.scanner.store.complete(runId,id,rows.map(todoArrival)),runId};
|
||||
}catch(error){this.scanner.store.fail(runId,error.status===401?'需要恢复BPM登录。':error.status===409?'连接忙碌或已暂停。':'待办对账失败,请稍后重试。');throw error;}
|
||||
}).finally(()=>this.todoPending.delete(id));this.todoPending.set(id,promise);return {runId,promise};
|
||||
}
|
||||
async stopConnection(id){const entry=this.entries.get(id);if(!entry){await this.todoPending.get(id)?.catch(()=>{});return;}this.entries.delete(id);entry.controller.abort();clearTimeout(entry.debounce);await Promise.allSettled([entry.handle?.stop(),entry.connecting,entry.sync,this.todoPending.get(id)]);}
|
||||
async stop(){this.stopped=true;clearInterval(this.timer);this.timer=null;await Promise.all([...this.entries.keys()].map(id=>this.stopConnection(id)));await Promise.allSettled([...this.todoPending.values()]);}
|
||||
}
|
||||
module.exports={BpmArrivalMonitor,todoArrival};
|
||||
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
function isLoginRedirect(location,baseURL){try{const target=new URL(location,baseURL);if(target.username||target.password)return false;return target.origin==='https://sso.skyworthdigital.com'&&target.pathname.startsWith('/realms/')||target.origin===new URL(baseURL).origin&&/^\/(?:login|signin)(?:\/|$)/i.test(target.pathname);}catch{return false;}}
|
||||
module.exports={isLoginRedirect};
|
||||
@@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
class BpmConnectionHealth{
|
||||
constructor({clock=()=>Date.now(),freshMs=5*60*1000}={}){this.clock=clock;this.freshMs=freshMs;this.values=new Map();}
|
||||
observe(id,source,status='healthy'){
|
||||
if(!['portal','todo','inform'].includes(source)||!['healthy','login_required','forbidden','error','unknown'].includes(status))return;
|
||||
const value=this.values.get(id)||{};value[source]={status,checkedAt:new Date(this.clock()).toISOString()};
|
||||
if(status==='healthy')value.portal={status:'healthy',checkedAt:new Date(this.clock()).toISOString()};
|
||||
if(status==='login_required')value.portal={status,checkedAt:new Date(this.clock()).toISOString()};this.values.set(id,value);
|
||||
}
|
||||
recent(id){const portal=this.values.get(id)?.portal;return !!(portal?.status==='healthy'&&this.clock()-Date.parse(portal.checkedAt)<this.freshMs);}
|
||||
snapshot(id){return structuredClone(this.values.get(id)||{});}
|
||||
clear(id){this.values.delete(id);}
|
||||
}
|
||||
module.exports={BpmConnectionHealth};
|
||||
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
const fail=(message,status)=>{throw Object.assign(new Error(message),{status});};
|
||||
class BpmConnectionLifecycle{
|
||||
constructor({workspace,manager,monitor}){Object.assign(this,{workspace,manager,monitor});this.pending=new Map();}
|
||||
run(id,work){const before=this.pending.get(id)||Promise.resolve(),task=before.catch(()=>{}).then(work);this.pending.set(id,task);task.finally(()=>{if(this.pending.get(id)===task)this.pending.delete(id);}).catch(()=>{});return task;}
|
||||
async invoke(method,id){try{await this.manager?.[method]?.(id);}catch(error){fail('BPM 连接操作未完成,请刷新状态后重试。',[409,503].includes(error.status)?error.status:502);}}
|
||||
change(id,enabled,input,user){return this.run(id,async()=>{
|
||||
if(user.role!=='admin')fail('仅管理员可以启用或停用连接。',403);
|
||||
if(typeof enabled!=='boolean'||!input||Object.keys(input).some(k=>k!=='version')||!Number.isInteger(input.version)||input.version<0)fail('请提供当前连接版本。',400);
|
||||
const current=this.workspace.getConnection(id);
|
||||
if((current.status!=='disabled')!==enabled&&(current.version||0)!==input.version)fail('连接状态已变化,请刷新后重试。',409);
|
||||
if(!enabled){
|
||||
// Publish the pause before draining, so late workers cannot restore connectivity.
|
||||
const saved=this.workspace.setConnectionEnabled(id,false,input,user);
|
||||
const pausing=this.invoke('suspend',id);await Promise.all([pausing,this.monitor?.stopConnection(id)]);return saved;
|
||||
}
|
||||
await this.invoke('resume',id);
|
||||
return this.workspace.setConnectionEnabled(id,true,input,user);
|
||||
});}
|
||||
remove(id,user){return this.run(id,async()=>{
|
||||
if(user.role!=='admin')fail('仅管理员可以删除连接。',403);
|
||||
if(this.workspace.getConnection(id).status!=='disabled')fail('请先停用连接再删除。',409);
|
||||
if(!this.manager)fail('BPM 登录服务暂不可用。',503);
|
||||
await this.monitor?.stopConnection(id);await this.invoke('disable',id);return this.workspace.deleteConnection(id,user);
|
||||
});}
|
||||
}
|
||||
module.exports={BpmConnectionLifecycle};
|
||||
@@ -21,7 +21,7 @@ class BpmCustodian {
|
||||
if(!account.configured && !connection.lastConnectedAt && !['connected','unchecked','login_required'].includes(connection.status))continue;
|
||||
const result=await this.manager.ensure(connection,this.principal);
|
||||
// The connection can be disabled while its remote check is in flight.
|
||||
if(this.workspace.getConnection(connection.id).status!=='disabled')this.workspace.updateConnectionSession(connection.id,result,this.principal.user);
|
||||
if(this.workspace.getConnection(connection.id).status!=='disabled')this.workspace.updateConnectionSession(connection.id,result,this.principal.user,{audit:false});
|
||||
}catch(cause){
|
||||
// Interactive leases and transient browser failures are retried on the next cycle.
|
||||
// The manager returns checked upstream failures as structured results.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
const sanitize=require('sanitize-html');
|
||||
const {loadPlaywright}=require('../../platform/browser.cjs');
|
||||
const {isLoginRedirect}=require('./auth-redirect.cjs');
|
||||
const fail=(message,status=502)=>Object.assign(new Error(message),{status});
|
||||
const SOURCES=[['portal-v8','bpm/worklist/informlist'],['portal-v4','skyworth/todo/v2/workflow/get_process_of_inform_v4']];
|
||||
function plain(value,max=8000){
|
||||
@@ -30,14 +31,15 @@ class BpmListClient{
|
||||
const request=await loadPlaywright().request.newContext({baseURL:this.baseURL,storageState,timeout:20000});
|
||||
const get=async(route,options={})=>{
|
||||
let response;try{response=await request.get(route,{...options,maxRedirects:0});}catch{throw fail('BPM 查询连接失败,请稍后重试。');}
|
||||
const status=response.status();if(status>=300&&status<400)throw fail('BPM 查询发生登录跳转,需要续登。',401);
|
||||
if([401,403].includes(status))throw fail('BPM 会话需要续登。',401);
|
||||
const status=response.status();if(status>=300&&status<400)throw fail('BPM 查询发生跳转,请检查连接。',isLoginRedirect(response.headers().location||'',this.baseURL)?401:502);
|
||||
if(status===401)throw fail('BPM 会话需要续登。',401);
|
||||
if(status===403)throw fail('BPM 业务列表没有读取权限。',403);
|
||||
if(status!==200)throw fail('BPM 查询失败,请稍后重试。');
|
||||
const body=await response.body();if(body.length>10*1024*1024)throw fail('BPM 查询响应过大。');return body.toString('utf8');
|
||||
};
|
||||
try{
|
||||
const html=await get('/'),token=/Yiez\.clientId\s*=\s*['"]([^'"\s<>]{1,16000})['"]/.exec(html)?.[1];
|
||||
if(!token)throw fail('BPM 会话需要续登。',401);
|
||||
if(!token)throw fail('BPM 认证响应无法验证。',/id=["']kc-form-login["']/.test(html)?401:502);
|
||||
const rows=[];
|
||||
for(const [source,route]of this.sources){
|
||||
let total=null;const seen=new Set();
|
||||
|
||||
@@ -26,8 +26,8 @@ class BpmOrderProvider{
|
||||
try{const rows=await this.saved(connection,principal,state=>this.client.scan(state));
|
||||
const safe=rows.map(row=>{const entry=row.detailUrl?safeEntry(row.detailUrl):null;return {...row,detailUrl:entry?entry.target.href:row.detailUrl?detailURL(row.detailUrl,this.allowLocal).href:undefined};});
|
||||
this.entries.set(connection.id,new Map(rows.filter(r=>r.detailUrl).map(r=>[r.taskId,{url:r.detailUrl,row:r,at:Date.now()}])));
|
||||
this.checks={...this.checks,liveTodo:true,checkedAt:new Date().toISOString(),message:'真实待办接口已读取;各类别表单仍需字段与归档现场核验。'};return safe;}
|
||||
catch(error){this.checks={...this.checks,liveTodo:false,message:error.message};throw error;}
|
||||
this.manager.observe?.(connection.id,'todo');this.checks={...this.checks,liveTodo:true,checkedAt:new Date().toISOString(),message:'真实待办接口已读取;各类别表单仍需字段与归档现场核验。'};return safe;}
|
||||
catch(error){this.manager.observe?.(connection.id,'todo',error);this.checks={...this.checks,liveTodo:false,message:error.message};throw error;}
|
||||
}
|
||||
captureFields(connection,principal,row){return this.capture(connection,principal,row,{fieldsOnly:true});}
|
||||
async capture(connection,principal,row,{fieldsOnly=false}={}){
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
'use strict';
|
||||
async function bpmScanApi({scanner,workspace,user,sessionId,url,route,method,body,reply}){
|
||||
async function bpmScanApi({scanner,workspace,bpmMonitor,user,sessionId,url,route,method,body,reply}){
|
||||
if(!route.startsWith('/api/bpm-scan')&&route!=='/api/arrivals')return false;
|
||||
const fail=(message,status=400)=>{throw Object.assign(new Error(message),{status});};
|
||||
if(!scanner)fail('BPM 扫描暂不可用。',503);
|
||||
if(route==='/api/arrivals'&&method==='GET'){
|
||||
const filters={connectionId:url.searchParams.get('connectionId')||'',q:url.searchParams.get('q')||'',before:url.searchParams.get('before')||'',days:Number(url.searchParams.get('days')||7)};
|
||||
const filters={connectionId:url.searchParams.get('connectionId')||'',q:url.searchParams.get('q')||'',before:url.searchParams.get('before')||'',days:Number(url.searchParams.get('days')||7),kind:url.searchParams.get('kind')||'inform'};
|
||||
reply(200,scanner.store.list(filters));return true;
|
||||
}
|
||||
if(route==='/api/bpm-scan'&&method==='GET'){reply(200,{...scanner.store.status(),connections:workspace.snapshot().connections.map(({id,name,status,owner})=>({id,name,status,owner}))});return true;}
|
||||
if(route==='/api/bpm-scan'&&method==='GET'){reply(200,{...scanner.store.status(),connections:workspace.snapshot().connections.map(({id,name,status,owner})=>({id,name,status,owner,monitoring:bpmMonitor?.snapshot(id)}))});return true;}
|
||||
if(route==='/api/bpm-scan/config'&&method==='POST'){
|
||||
if(user.role!=='admin')fail('仅管理员可以配置自动扫描。',403);
|
||||
const config=scanner.store.saveConfig(body);workspace.record(user,'保存自动扫描',`${config.enabled?'开启':'暂停'},间隔 ${config.intervalMinutes} 分钟`);reply(200,config);return true;
|
||||
}
|
||||
if(route==='/api/bpm-scan/run'&&method==='POST'){
|
||||
if(!body||Object.keys(body).some(k=>k!=='connectionId')||typeof body.connectionId!=='string')fail('请选择 BPM 连接。');
|
||||
if(!body||Object.keys(body).some(k=>!['connectionId','kind'].includes(k))||typeof body.connectionId!=='string'||body.kind!==undefined&&!['todo','inform'].includes(body.kind))fail('请选择 BPM 连接及有效到达类型。');
|
||||
// A scan may span many pages. The UI polls the durable run instead of holding a request open.
|
||||
const {promise,runId}=scanner.startScan(body.connectionId,{user,sessionId});
|
||||
if(body.kind==='todo'&&!bpmMonitor)fail('真实待办监听服务尚未启动。',503);
|
||||
const {promise,runId}=body.kind==='todo'?bpmMonitor.startTodoScan(body.connectionId,{user,sessionId}):scanner.startScan(body.connectionId,{user,sessionId});
|
||||
promise.catch(()=>{});reply(202,{runId});return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -11,6 +11,7 @@ class BpmScanStore{
|
||||
CREATE INDEX IF NOT EXISTS arrivals_day ON arrivals(day DESC);
|
||||
CREATE TABLE IF NOT EXISTS runs(id TEXT PRIMARY KEY,connection_id TEXT NOT NULL,actor TEXT NOT NULL,started_at TEXT NOT NULL,finished_at TEXT,status TEXT NOT NULL,seen INTEGER,added INTEGER,message TEXT);
|
||||
UPDATE runs SET status='error',message='服务重启,扫描未完成。',finished_at=CURRENT_TIMESTAMP WHERE status='running';`);
|
||||
if(!this.db.prepare('PRAGMA table_info(runs)').all().some(c=>c.name==='kind'))this.db.exec("ALTER TABLE runs ADD COLUMN kind TEXT NOT NULL DEFAULT 'inform'");
|
||||
} catch(error) {
|
||||
try { this.db?.close(); } catch {}
|
||||
throw error;
|
||||
@@ -19,19 +20,20 @@ class BpmScanStore{
|
||||
transaction(fn){this.db.exec('BEGIN IMMEDIATE');try{const r=fn();this.db.exec('COMMIT');return r;}catch(e){this.db.exec('ROLLBACK');throw e;}}
|
||||
config(){return JSON.parse(this.db.prepare('SELECT value FROM config WHERE id=1').get().value);}
|
||||
saveConfig(input){if(!input||Object.keys(input).some(k=>!['enabled','intervalMinutes'].includes(k))||typeof input.enabled!=='boolean'||!Number.isInteger(input.intervalMinutes)||input.intervalMinutes<1||input.intervalMinutes>1440)throw invalid('扫描间隔需为 1–1440 分钟。');this.db.prepare('UPDATE config SET value=? WHERE id=1').run(JSON.stringify(input));return this.config();}
|
||||
begin(connectionId,actor){const id=crypto.randomUUID();this.db.prepare('INSERT INTO runs(id,connection_id,actor,started_at,status) VALUES(?,?,?,?,?)').run(id,connectionId,actor,new Date().toISOString(),'running');return id;}
|
||||
begin(connectionId,actor,kind='inform'){if(!['inform','todo'].includes(kind))throw invalid('到达类型无效。');const id=crypto.randomUUID();this.db.prepare('INSERT INTO runs(id,connection_id,actor,started_at,status,kind) VALUES(?,?,?,?,?,?)').run(id,connectionId,actor,new Date().toISOString(),'running',kind);return id;}
|
||||
complete(id,connectionId,rows){return this.transaction(()=>{
|
||||
let added=0;const now=new Date().toISOString();
|
||||
const insert=this.db.prepare('INSERT OR IGNORE INTO arrivals VALUES(?,?,?,?,?,?,?)');const update=this.db.prepare('UPDATE arrivals SET day=?,value=?,last_seen=? WHERE connection_id=? AND source=? AND task_id=?');
|
||||
for(const row of rows){if(!row.arrivalDay||!row.taskId||!row.source)throw invalid('流程记录无效。');const value=JSON.stringify(row);added+=Number(insert.run(connectionId,row.source,row.taskId,row.arrivalDay,value,now,now).changes);update.run(row.arrivalDay,value,now,connectionId,row.source,row.taskId);}
|
||||
for(const row of rows){if(!row.arrivalDay||!row.taskId||!row.source)throw invalid('流程记录无效。');const value=JSON.stringify(row),key=row.recordKey||row.taskId;added+=Number(insert.run(connectionId,row.source,key,row.arrivalDay,value,now,now).changes);update.run(row.arrivalDay,value,now,connectionId,row.source,key);}
|
||||
this.db.prepare('UPDATE runs SET status=?,finished_at=?,seen=?,added=?,message=? WHERE id=? AND status=?').run('success',now,rows.length,added,'',id,'running');this.prune();return {seen:rows.length,added};
|
||||
});}
|
||||
fail(id,message){this.db.prepare('UPDATE runs SET status=?,finished_at=?,message=? WHERE id=?').run('error',new Date().toISOString(),message,id);this.prune();}
|
||||
prune(){this.db.exec("DELETE FROM runs WHERE status!='running' AND id NOT IN(SELECT id FROM runs ORDER BY started_at DESC,rowid DESC LIMIT 200)");}
|
||||
status(){return {config:this.config(),total:this.db.prepare('SELECT COUNT(*) n FROM arrivals').get().n,runs:this.db.prepare('SELECT id,connection_id AS connectionId,actor,started_at AS startedAt,finished_at AS finishedAt,status,seen,added,message FROM runs ORDER BY started_at DESC,rowid DESC LIMIT 30').all()};}
|
||||
list({connectionId='',q='',before='',days=7}={}){
|
||||
status(){return {config:this.config(),total:this.db.prepare("SELECT COUNT(*) n FROM arrivals WHERE source NOT LIKE 'todo:%'").get().n,todoTotal:this.db.prepare("SELECT COUNT(*) n FROM arrivals WHERE source LIKE 'todo:%'").get().n,runs:this.db.prepare('SELECT id,connection_id AS connectionId,actor,started_at AS startedAt,finished_at AS finishedAt,status,seen,added,message,kind FROM runs ORDER BY started_at DESC,rowid DESC LIMIT 30').all()};}
|
||||
list({connectionId='',q='',before='',days=7,kind='inform'}={}){
|
||||
if(!['inform','todo'].includes(kind))throw invalid('到达类型无效。');
|
||||
if(typeof q!=='string'||q.length>200||typeof connectionId!=='string'||connectionId.length>200||typeof before!=='string'||(before&&!/^\d{4}-\d{2}-\d{2}$/.test(before))||!Number.isInteger(days)||days<1||days>31)throw invalid('查询条件无效。');
|
||||
const conditions=[],args=[];if(connectionId){conditions.push('connection_id=?');args.push(connectionId);}if(q){conditions.push("value LIKE ? ESCAPE '\\'");args.push('%'+q.replace(/[\\%_]/g,'\\$&')+'%');}
|
||||
const conditions=[kind==='todo'?"source LIKE 'todo:%'":"source NOT LIKE 'todo:%'"],args=[];if(connectionId){conditions.push('connection_id=?');args.push(connectionId);}if(q){conditions.push("value LIKE ? ESCAPE '\\'");args.push('%'+q.replace(/[\\%_]/g,'\\$&')+'%');}
|
||||
const where=conditions.length?' WHERE '+conditions.join(' AND '):'';const total=this.db.prepare('SELECT COUNT(*) n FROM arrivals'+where).get(...args).n;
|
||||
if(before){conditions.push('day<?');args.push(before);}const filtered=conditions.length?' WHERE '+conditions.join(' AND '):'';
|
||||
const dates=this.db.prepare('SELECT DISTINCT day FROM arrivals'+filtered+' ORDER BY day DESC LIMIT ?').all(...args,days+1).map(r=>r.day);const shown=dates.slice(0,days);
|
||||
|
||||
@@ -5,6 +5,7 @@ const crypto = require('node:crypto');
|
||||
const { BpmVault } = require('../../platform/security/vault.cjs');
|
||||
const { loadPlaywright, browserOptions } = require('../../platform/browser.cjs');
|
||||
const { BpmListClient } = require('./list-client.cjs');
|
||||
const {BpmConnectionHealth}=require('./connection-health.cjs');
|
||||
const DEFAULT_URLS = { main: 'https://bpmn.skyworthdigital.com/' };
|
||||
const { LOGIN_FORMS, fillSavedForm, automaticSubmitForm } = require('./login-form.cjs');
|
||||
const TTL = 10 * 60 * 1000;
|
||||
@@ -14,7 +15,7 @@ const safe = cause => cause?.status ? cause : error('BPM 浏览器暂不可用
|
||||
const object = (value, fields) => value && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).every(key => fields.includes(key));
|
||||
|
||||
class BpmSessionManager {
|
||||
constructor({ stateDir, browserFactory, urls, allowedOrigins, probe, loginForms } = {}) {
|
||||
constructor({ stateDir, browserFactory, urls, allowedOrigins, probe, loginForms,accessClient } = {}) {
|
||||
this.stateDir = path.resolve(stateDir); fs.mkdirSync(this.stateDir, { recursive: true });
|
||||
if (urls!==undefined && !object(urls,['main'])) throw error('BPM 地址配置无效。');
|
||||
this.urls = { ...DEFAULT_URLS, ...urls };
|
||||
@@ -38,6 +39,7 @@ class BpmSessionManager {
|
||||
}
|
||||
this.browserFactory = browserFactory || (() => loadPlaywright().chromium.launch(browserOptions()));
|
||||
this.probe = probe || this.defaultProbe.bind(this);
|
||||
this.accessClient=accessClient;this.health=new BpmConnectionHealth();this.accessChecks=new Map();this.sessionEpochs=new Map();
|
||||
this.sessions = new Map(); this.operations = new Map(); this.disabled = new Set(); this.revokedSessionHashes=new Set(); this.stopped = false;
|
||||
}
|
||||
allowed(url) { try { const parsed = new URL(url); return !parsed.username && !parsed.password && this.allowedOrigins.has(parsed.origin); } catch { return false; } }
|
||||
@@ -62,6 +64,7 @@ class BpmSessionManager {
|
||||
// authentication; first custody can reuse a user's already saved manual login.
|
||||
await this.vault().write('account:'+connection.id,stored);
|
||||
if (previous && previous.username.trim().toLowerCase()!==stored.username.toLowerCase()) {
|
||||
this.health.clear(connection.id);this.sessionEpochs.set(connection.id,this.epoch(connection.id)+1);
|
||||
try{await this.vault().remove(connection.id);await this.closeLease(connection.id);}
|
||||
catch(cause){await this.vault().write('account:'+connection.id,previous);throw cause;}
|
||||
}
|
||||
@@ -81,6 +84,7 @@ class BpmSessionManager {
|
||||
return this.run(connection?.id,async()=>{ this.authorize(connection,principal); const lease=await this.getLease(connection.id,principal,true); await this.settleNavigation(lease); return this.fillSavedAccount(lease); });
|
||||
}
|
||||
async automaticSubmit(lease,stored,submit=false) {
|
||||
if(this.stopped||this.disabled.has(lease.id))throw error('此连接已停止自动登录。',409);
|
||||
return automaticSubmitForm(lease,stored,submit,this.loginForms);
|
||||
}
|
||||
|
||||
@@ -88,11 +92,34 @@ class BpmSessionManager {
|
||||
await this.captureSessions(lease);
|
||||
const storageState=await lease.context.storageState({indexedDB:true});
|
||||
await this.vault().write(lease.id,{storageState,sessionStorage:lease.sessionStorage});
|
||||
this.sessionEpochs.set(lease.id,this.epoch(lease.id)+1);
|
||||
}
|
||||
canPersistVerified(result) {
|
||||
return result.status==='connected' && result.checks.portal.ok;
|
||||
}
|
||||
epoch(id){return this.sessionEpochs.get(id)||0;}
|
||||
observe(id,source,cause){this.health.observe(id,source,cause?cause.status===401?'login_required':cause.status===403?'forbidden':'error':'healthy');}
|
||||
async checkAccess(connection,principal){
|
||||
this.authorize(connection,principal);const id=connection.id;
|
||||
if(this.accessChecks.has(id)){const result=await this.accessChecks.get(id);this.authorize(connection,principal);return result;}
|
||||
const task=this.run(id,async()=>{
|
||||
this.authorize(connection,principal);if(this.sessions.has(connection.id))throw error('此连接正在登录窗口中使用。',409);
|
||||
const saved=await this.vault().read(connection.id),result=await this.accessClient.check(saved?.storageState);this.authorize(connection,principal);
|
||||
this.health.observe(connection.id,'portal',result.status==='connected'?'healthy':result.status==='login_required'?'login_required':'error');
|
||||
this.health.observe(connection.id,'todo',result.todo||'unknown');
|
||||
if(result.storageState&&result.status==='connected')await this.vault().write(connection.id,{...saved,storageState:result.storageState});
|
||||
return {status:result.status,identity:connection.identity||'',checkedAt:result.checkedAt,checks:result.checks};
|
||||
});this.accessChecks.set(id,task);try{return await task;}finally{if(this.accessChecks.get(id)===task)this.accessChecks.delete(id);}
|
||||
}
|
||||
async ensure(connection,principal) {
|
||||
if(this.accessClient){
|
||||
this.authorize(connection,principal);
|
||||
if(this.health.recent(connection.id))return {status:'connected',identity:connection.identity||'',checkedAt:this.health.snapshot(connection.id).portal.checkedAt,checks:{portal:{ok:true,message:'最近业务请求已验证登录。'}}};
|
||||
const result=await this.checkAccess(connection,principal);if(result.status!=='login_required')return result;
|
||||
}
|
||||
return this.ensureBrowser(connection,principal);
|
||||
}
|
||||
async ensureBrowser(connection,principal) {
|
||||
return this.run(connection?.id,async()=>{
|
||||
this.authorize(connection,principal);
|
||||
if (this.sessions.has(connection.id)) throw error('此连接正在登录窗口中使用。',409);
|
||||
@@ -128,7 +155,7 @@ class BpmSessionManager {
|
||||
this.authorize(connection,principal);
|
||||
if(this.sessions.has(connection.id))throw error('此连接正在登录窗口中使用,请关闭后扫描。',409);
|
||||
const saved=await this.vault().read(connection.id);
|
||||
const rows=await (this.listClient ||= new BpmListClient()).scan(saved?.storageState);
|
||||
let rows;try{rows=await (this.listClient ||= new BpmListClient()).scan(saved?.storageState);this.observe(connection.id,'inform');}catch(cause){this.observe(connection.id,'inform',cause);throw cause;}
|
||||
this.authorize(connection,principal);return rows;
|
||||
});
|
||||
try{return await query();}catch(cause){if(cause.status!==401)throw cause;}
|
||||
@@ -382,6 +409,7 @@ class BpmSessionManager {
|
||||
});
|
||||
}
|
||||
async check(connection,principal) {
|
||||
if(this.accessClient)return this.checkAccess(connection,principal);
|
||||
return this.run(connection?.id,async()=>{
|
||||
this.authorize(connection,principal);
|
||||
const transient=!this.sessions.has(connection.id);
|
||||
@@ -402,6 +430,8 @@ class BpmSessionManager {
|
||||
for(const hash of revoked)this.revokedSessionHashes.add(hash);
|
||||
await Promise.all([...this.sessions.values()].filter(lease=>revoked.has(crypto.createHash('sha256').update(lease.sessionId).digest('hex'))).map(lease=>this.run(lease.id,()=>this.closeLease(lease.id))));
|
||||
}
|
||||
async suspend(id) { this.disabled.add(id);this.health.clear(id);await this.sessions.get(id)?.context?.close().catch(()=>{}); await this.run(id,()=>this.closeLease(id)); }
|
||||
async resume(id) { await this.run(id,async()=>{this.disabled.delete(id);this.health.clear(id);}); }
|
||||
async disable(id) { this.disabled.add(id); await this.run(id,async()=>{ await this.closeLease(id); await this.vault().remove(id); await this.vault().remove('account:'+id); }); }
|
||||
async shutdown() {
|
||||
this.stopped=true;
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
const {loadPlaywright}=require('../../platform/browser.cjs');
|
||||
const {BpmListClient}=require('./list-client.cjs');
|
||||
const {isLoginRedirect}=require('./auth-redirect.cjs');
|
||||
const hints=new Set(['worklistChanged','informlistChanged','taskinstanceChanged']);
|
||||
const failure=(message,status=502,code='BPM_HUB_UNAVAILABLE')=>Object.assign(new Error(message),{status,code});
|
||||
class BpmSignalRClient{
|
||||
constructor({handshakeMs=10000,heartbeatMs=45000,pingMs=15000,maxFrameBytes=65536,...options}={}){this.baseURL=new BpmListClient(options).baseURL;Object.assign(this,{handshakeMs,heartbeatMs,pingMs,maxFrameBytes});}
|
||||
async connect(storageState,{signal,onEvent=()=>{},onClose=()=>{}}={}){
|
||||
signal?.throwIfAborted();let request,ws,closeConnection;const abort=()=>{request?.dispose().catch(()=>{});closeConnection?.('stopped');};signal?.addEventListener('abort',abort,{once:true});
|
||||
try{
|
||||
if(!storageState)throw failure('尚未保存 BPM 会话。',401);
|
||||
request=await loadPlaywright().request.newContext({baseURL:this.baseURL,storageState,timeout:15000});signal?.throwIfAborted();
|
||||
const home=await request.get('/',{maxRedirects:0});if(home.status()===401||home.status()>=300&&home.status()<400&&isLoginRedirect(home.headers().location||'',this.baseURL))throw failure('BPM 监听需要恢复登录。',401);if(home.status()===403)throw failure('BPM 监听没有访问权限。',403);if(home.status()!==200)throw failure('BPM 门户暂不可用。');
|
||||
const bytes=await home.body();if(bytes.length>2*1024*1024)throw failure('BPM 认证响应过大。');const token=/Yiez\.clientId\s*=\s*['"]([^'"\s<>]{1,16000})['"]/.exec(bytes.toString())?.[1];if(!token)throw failure('BPM 认证响应无法验证。');
|
||||
const response=await request.post('/hubs/system/negotiate',{params:{negotiateVersion:1},headers:{Authorization:'Bearer '+token},maxRedirects:0});
|
||||
if(response.status()===401)throw failure('BPM 监听会话已过期。',401);if(response.status()===403)throw failure('BPM 监听没有访问权限。',403);if(response.status()!==200)throw failure('BPM 监听通道暂不可用。');
|
||||
const body=await response.body();if(body.length>65536)throw failure('BPM 监听协商响应过大。');let data;try{data=JSON.parse(body.toString());}catch{throw failure('BPM 监听协商响应无效。');}
|
||||
if(typeof data.connectionToken!=='string'||data.connectionToken.length>16000||!data.availableTransports?.some(t=>t.transport==='WebSockets')||data.url||data.error)throw failure('BPM 监听不支持当前连接方式。');
|
||||
signal?.throwIfAborted();const target=new URL('/hubs/system',this.baseURL);target.protocol=target.protocol==='https:'?'wss:':'ws:';target.searchParams.set('id',data.connectionToken);target.searchParams.set('access_token',token);
|
||||
return await new Promise((resolve,reject)=>{
|
||||
let ready=false,done=false,pending='',lastReceived=Date.now(),handshakeTimer,pingTimer,heartbeatTimer;let physicallyClosed;const closed=new Promise(r=>physicallyClosed=r);
|
||||
const cleanup=()=>{clearTimeout(handshakeTimer);clearInterval(pingTimer);clearInterval(heartbeatTimer);signal?.removeEventListener('abort',abort);};
|
||||
const finish=(reason,error)=>{if(done)return;done=true;cleanup();try{ws.close();}catch{}if(!ready)reject(error||failure('BPM 监听连接未完成。'));try{onClose({reason});}catch{}};
|
||||
closeConnection=reason=>finish(reason,new DOMException('Aborted','AbortError'));
|
||||
ws=new WebSocket(target.href);ws.addEventListener('open',()=>{if(done)return;ws.send(JSON.stringify({protocol:'json',version:1})+'\x1e');});
|
||||
handshakeTimer=setTimeout(()=>finish('handshake_timeout',failure('BPM 监听握手超时。',502,'BPM_HUB_HANDSHAKE')),this.handshakeMs);
|
||||
ws.addEventListener('message',event=>{
|
||||
if(done)return;if(typeof event.data!=='string'||Buffer.byteLength(pending+event.data)>this.maxFrameBytes)return finish('invalid_frame');pending+=event.data;
|
||||
while(pending.includes('\x1e')){const split=pending.indexOf('\x1e'),raw=pending.slice(0,split);pending=pending.slice(split+1);if(!raw)continue;let message;try{message=JSON.parse(raw);}catch{return finish('invalid_frame');}if(!message||typeof message!=='object'||Array.isArray(message))return finish('invalid_frame');lastReceived=Date.now();
|
||||
if(!ready){if(Object.keys(message).length)return finish('handshake_error',failure('BPM 监听握手未通过。',502,'BPM_HUB_HANDSHAKE'));ready=true;clearTimeout(handshakeTimer);
|
||||
pingTimer=setInterval(()=>{if(!done&&ws.readyState===WebSocket.OPEN)ws.send('{"type":6}\x1e');},this.pingMs);pingTimer.unref?.();
|
||||
heartbeatTimer=setInterval(()=>{if(Date.now()-lastReceived>=this.heartbeatMs)finish('heartbeat_timeout');},Math.max(20,Math.min(5000,this.heartbeatMs/2)));heartbeatTimer.unref?.();
|
||||
resolve({stop:async()=>{finish('stopped');let timer;try{await Promise.race([closed,new Promise(r=>{timer=setTimeout(r,1000);})]);}finally{clearTimeout(timer);}},closed});continue;
|
||||
}
|
||||
if(message.type===7)return finish('server_closed');
|
||||
if(message.type===1&&hints.has(message.target)){const name=message.target;queueMicrotask(()=>{if(!done)try{onEvent(name);}catch{}});}
|
||||
}
|
||||
});
|
||||
ws.addEventListener('error',()=>finish('transport_error'));
|
||||
ws.addEventListener('close',()=>{physicallyClosed();finish('disconnected');});
|
||||
if(signal?.aborted)closeConnection('stopped');
|
||||
});
|
||||
}catch(e){signal?.removeEventListener('abort',abort);if(signal?.aborted)throw new DOMException('Aborted','AbortError');if(e.status||e.name==='AbortError')throw e;throw failure('BPM 监听暂不可用。');}
|
||||
finally{await request?.dispose();}
|
||||
}
|
||||
}
|
||||
module.exports={BpmSignalRClient};
|
||||
Reference in new issue
Block a user