@univerjs-pro/collaboration-comment-service 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object['defineProperty'](exports,Symbol['toStringTag'],{'value':'Module'});let e=require('node:crypto'),t=require('@univerjs-pro/collaboration-service'),n=require('@univerjs/protocol');var r=class{['_middlewares']=new Map();['use'](_0x4303ec,_0x3a5f3b){let _0x26ab46=this['_middlewares']['get'](_0x4303ec)??[],_0x1c00aa=_0x3a5f3b;_0x26ab46['push'](_0x1c00aa),this['_middlewares']['set'](_0x4303ec,_0x26ab46);let _0x2af98e=!0x1;return{'dispose':()=>{if(_0x2af98e)return;_0x2af98e=!0x0;let _0x136b85=_0x26ab46['indexOf'](_0x1c00aa);_0x136b85>=0x0&&_0x26ab46['splice'](_0x136b85,0x1);}};}async['run'](_0x1ddfef,_0x1b312d,_0x4d933a){let _0x1aafe7=[...this['_middlewares']['get'](_0x1ddfef)??[]],_0x1beb5f=async _0x36f831=>{let _0x3675fd=_0x1aafe7[_0x36f831];if(!_0x3675fd)return _0x4d933a();let _0x5432f9=!0x1,_0x532052,_0xad249c=()=>{if(_0x5432f9)throw Error('Middleware\x20for\x20action\x20'+_0x1ddfef+'\x20called\x20next()\x20more\x20than\x20once');return _0x5432f9=!0x0,_0x532052=_0x1beb5f(_0x36f831+0x1),_0x532052;};try{await _0x3675fd(_0x1b312d,_0xad249c);}catch(_0x474bdb){throw _0x532052&&await _0x532052['catch'](()=>void 0x0),_0x474bdb;}if(!_0x5432f9)throw Error('Middleware\x20for\x20action\x20'+_0x1ddfef+'\x20completed\x20without\x20calling\x20next()');await _0x532052;};await _0x1beb5f(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x153d68){if(!_0x153d68?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x153d68['database'],this['_userProvider']=_0x153d68['userProvider'];}['use'](_0x5a612d,_0xfac928){return this['_assertRunning'](),this['_middleware']['use'](_0x5a612d,_0xfac928);}['on'](_0xb80ac1,_0x193b79){this['_assertRunning']();let _0x59eb18=this['_listeners']['get'](_0xb80ac1)??new Set(),_0x3f2431=_0x193b79;_0x59eb18['add'](_0x3f2431),this['_listeners']['set'](_0xb80ac1,_0x59eb18);let _0x4ca523=!0x1;return{'dispose':()=>{_0x4ca523||(_0x4ca523=!0x0,_0x59eb18['delete'](_0x3f2431));}};}['addComment'](_0x4a51d1,_0x56a8cc){return this['_call'](async()=>{let _0x57e9b8=s(_0x56a8cc);m(_0x4a51d1['unitID']),h(_0x4a51d1['content']);let _0x584e34=a(_0x4a51d1),_0x429118={..._0x57e9b8,'request':_0x584e34},_0x930c3;return await this['_middleware']['run']('addComment',_0x429118,async()=>{let _0x2d2378=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0x4a51d1['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x57e9b8['userID'],'content':_0x4a51d1['content'],'mentions':[..._0x4a51d1['mentions']]},_0x429118));if(_0x2d2378['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x930c3=u([_0x2d2378['record']]),await this['_emitWrite'](_0x57e9b8,_0x584e34,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0x2d2378['record'],_0x57e9b8,_0x584e34));}),_0x930c3;});}['listComments'](_0x27c261,_0x3a38cd){return this['_call'](async()=>{let _0x4f216b=o(_0x3a38cd);m(_0x27c261['unitID']),_0x27c261['threadIDs']['forEach'](_0x487e57=>g('threadID',_0x487e57));let _0x8a1c3=a(_0x27c261),_0x408c35={..._0x4f216b,'request':_0x8a1c3},_0x46229d;return await this['_middleware']['run']('listComments',_0x408c35,async()=>{let _0x39b7a4=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x27c261['unitID'],'threadIDs':[...new Set(_0x27c261['threadIDs'])]},_0x408c35))),_0x3b9465=Object['values'](_0x39b7a4)['flatMap'](_0x13e34a=>_0x13e34a['replies']['map'](_0x1b25b2=>_0x1b25b2['userId']));_0x46229d={'comments':_0x39b7a4,'users':await this['_resolveUsers'](_0x3b9465,_0x4f216b,_0x8a1c3)};}),_0x46229d;});}['replyComment'](_0x4e7a89,_0x313cf7){return this['_call'](async()=>{let _0xf1125=s(_0x313cf7);m(_0x4e7a89['unitID']),g('threadID',_0x4e7a89['threadID']),h(_0x4e7a89['content']);let _0x464fbd=a(_0x4e7a89),_0x18fc10={..._0xf1125,'request':_0x464fbd},_0x37b649;return await this['_middleware']['run']('replyComment',_0x18fc10,async()=>{let _0x238daf=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x4e7a89['unitID'],'threadID':_0x4e7a89['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0xf1125['userID'],'content':_0x4e7a89['content'],'mentions':[..._0x4e7a89['mentions']]},_0x18fc10));if(_0x238daf['status']==='not-found'||_0x238daf['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0x238daf['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x37b649=l(_0x238daf['record']),await this['_emitWrite'](_0xf1125,_0x464fbd,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0x238daf['record'],_0xf1125,_0x464fbd));}),_0x37b649;});}['editComment'](_0x15b0ff,_0x56a159){return this['_call'](async()=>{let _0x10adb0=s(_0x56a159);p(_0x15b0ff),h(_0x15b0ff['content']);let _0x295aa1=a(_0x15b0ff),_0x1069dd={..._0x10adb0,'request':_0x295aa1};await this['_middleware']['run']('editComment',_0x1069dd,async()=>{let _0x30dd44=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0x15b0ff['unitID'],'threadID':_0x15b0ff['threadID'],'replyID':_0x15b0ff['replyID'],'expectedAuthorUserID':_0x10adb0['userID'],'content':_0x15b0ff['content'],'mentions':[..._0x15b0ff['mentions']]},_0x1069dd));if(_0x30dd44['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x30dd44['status']==='not-found'||_0x30dd44['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x30dd44['status']==='edited'&&await this['_emitWrite'](_0x10adb0,_0x295aa1,f(n['CommentUpdateEventType']['Edit'],_0x30dd44['record'],_0x10adb0));});});}['setThreadSolved'](_0xa95fb4,_0x22dafe){return this['_call'](async()=>{let _0xc96553=s(_0x22dafe);if(m(_0xa95fb4['unitID']),g('threadID',_0xa95fb4['threadID']),_0xa95fb4['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0xa95fb4['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0x5013f9=a(_0xa95fb4),_0x5aefe4={..._0xc96553,'request':_0x5013f9};await this['_middleware']['run']('setThreadSolved',_0x5aefe4,async()=>{let _0x36a741=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0xa95fb4,_0x5aefe4));if(_0x36a741['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0x36a741['status']==='updated'&&await this['_emitWrite'](_0xc96553,_0x5013f9,{'memberId':_0xc96553['memberID'],'userId':_0xc96553['userID'],'unitId':_0xa95fb4['unitID'],'threadId':_0xa95fb4['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0xa95fb4['solved']});});});}['deleteComment'](_0x3512aa,_0x47f3f1){return this['_call'](async()=>{let _0x4d4ea6=s(_0x47f3f1);m(_0x3512aa['unitID']),g('threadID',_0x3512aa['threadID']),_0x3512aa['replyID']!==void 0x0&&g('replyID',_0x3512aa['replyID']);let _0x34e629=_0x3512aa['replyID']===_0x3512aa['threadID']?void 0x0:_0x3512aa['replyID'],_0x386577=a({'unitID':_0x3512aa['unitID'],'threadID':_0x3512aa['threadID'],..._0x34e629===void 0x0?{}:{'replyID':_0x34e629}}),_0x23f4af={..._0x4d4ea6,'request':_0x386577},_0x4d3399=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0x3512aa['unitID'],'threadID':_0x3512aa['threadID'],'replyID':_0x34e629??_0x3512aa['threadID']},_0x23f4af));if(!_0x4d3399)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0x23f4af,'request':_0x386577,'target':{'kind':_0x34e629===void 0x0?'root':'reply','threadID':_0x4d3399['threadID'],'replyID':_0x4d3399['replyID'],'authorUserID':_0x4d3399['authorUserID'],'generation':_0x4d3399['generation']}},async()=>{let _0x34c039=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0x3512aa['unitID'],'threadID':_0x3512aa['threadID'],..._0x34e629===void 0x0?{}:{'replyID':_0x34e629},'expectedGeneration':_0x4d3399['generation']},_0x23f4af));if(_0x34c039['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0x34c039['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0x4d4ea6,_0x386577,{'memberId':_0x4d4ea6['memberID'],'userId':_0x4d4ea6['userID'],'unitId':_0x3512aa['unitID'],'threadId':_0x3512aa['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0x34e629===void 0x0?{}:{'replyId':_0x34e629}});});});}['dispose'](){return this['_disposePromise']?this['_disposePromise']:(this['_state']='disposing',this['_disposePromise']=((async()=>{await Promise['allSettled']([...this['_calls']]),this['_middleware']['clear'](),this['_listeners']['clear'](),this['_state']='disposed';})()),this['_disposePromise']);}async['_createUpdate'](_0x1cff07,_0x55c636,_0x2b5964,_0x1a47cb){let _0x1dac9a=await this['_resolveUsers']([_0x55c636['authorUserID']],_0x2b5964,_0x1a47cb);return{...f(_0x1cff07,_0x55c636,_0x2b5964),..._0x1dac9a[_0x55c636['authorUserID']]?{'user':_0x1dac9a[_0x55c636['authorUserID']]}:{}};}async['_resolveUsers'](_0x4c40d4,_0x1c51c4,_0x10ad6a){let _0x16fc60=[...new Set(_0x4c40d4['filter'](Boolean))];if(!this['_userProvider']||_0x16fc60['length']===0x0)return{};let _0x5219ac;try{_0x5219ac=await this['_userProvider']['getUsers'](_0x16fc60,{..._0x1c51c4,'request':_0x10ad6a});}catch{return{};}let _0x242a8d=new Set(_0x16fc60),_0x285fc2={};for(let _0x1d8023 of _0x5219ac)_0x1d8023?.['userID']&&_0x242a8d['has'](_0x1d8023['userID'])&&(_0x285fc2[_0x1d8023['userID']]=_0x1d8023);return _0x285fc2;}async['_emitWrite'](_0x41d720,_0x45ba93,_0x1dd801){let _0xe3648c={'userID':_0x41d720['userID'],'memberID':_0x41d720['memberID'],'customData':_0x41d720['customData'],'request':_0x45ba93,'update':_0x1dd801,'committedAt':Date['now']()};for(let _0x408a7e of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0x408a7e(_0xe3648c);}catch{}}['_call'](_0x324d90){this['_assertRunning']();let _0x4bb17c=_0x324d90();return this['_calls']['add'](_0x4bb17c),_0x4bb17c['finally'](()=>this['_calls']['delete'](_0x4bb17c))['catch'](()=>void 0x0),_0x4bb17c;}async['_databaseCall'](_0x12600b){try{return await _0x12600b();}catch(_0x174a6d){throw _0x174a6d instanceof t['CollabError']?_0x174a6d:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x174a6d});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0x18f174){return{..._0x18f174};}function o(_0x55d8d0){return c(_0x55d8d0),{'userID':_0x55d8d0['userID'],'customData':_0x55d8d0['customData']??Object['create'](null)};}function s(_0x365a07){return c(_0x365a07),g('memberID',_0x365a07['memberID']),{'userID':_0x365a07['userID'],'memberID':_0x365a07['memberID'],'customData':_0x365a07['customData']??Object['create'](null)};}function c(_0x1284fc){if(!_0x1284fc||typeof _0x1284fc!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0x1284fc['userID']),_0x1284fc['customData']!==void 0x0&&(_0x1284fc['customData']===null||typeof _0x1284fc['customData']!='object'||Array['isArray'](_0x1284fc['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0xf84e14){return{'threadId':_0xf84e14['threadID'],'replyId':_0xf84e14['replyID'],'content':_0xf84e14['content'],'userId':_0xf84e14['authorUserID'],'createTimestamp':_0xf84e14['createdAt']};}function u(_0x327337){let _0x4282a8=_0x327337['find'](_0x471d76=>_0x471d76['replyID']===_0x471d76['threadID']);return{'threadId':_0x4282a8['threadID'],'solved':_0x4282a8['solved'],'replies':_0x327337['map'](l)};}function d(_0x2de636){let _0x20127a=new Map();for(let _0x2aa4e4 of _0x2de636){let _0x367dd3=_0x20127a['get'](_0x2aa4e4['threadID'])??[];_0x367dd3['push'](_0x2aa4e4),_0x20127a['set'](_0x2aa4e4['threadID'],_0x367dd3);}let _0x2ed389={};for(let [_0x7298cf,_0x1e338c]of _0x20127a)_0x1e338c['find'](_0xf442e=>_0xf442e['replyID']===_0x7298cf)&&(_0x2ed389[_0x7298cf]=u([..._0x1e338c]['sort']((_0x599eaf,_0x41f615)=>_0x599eaf['replyID']===_0x7298cf?-0x1:_0x41f615['replyID']===_0x7298cf?0x1:_0x599eaf['createdAt']-_0x41f615['createdAt']||_0x599eaf['replyID']['localeCompare'](_0x41f615['replyID']))));return _0x2ed389;}function f(_0x4152c9,_0x301f43,_0x3c7ebb){return{'memberId':_0x3c7ebb['memberID'],'userId':_0x3c7ebb['userID'],'unitId':_0x301f43['unitID'],'threadId':_0x301f43['threadID'],'type':_0x4152c9,'replyId':_0x301f43['replyID'],'content':_0x301f43['content'],'createTimestamp':String(_0x301f43['createdAt'])};}function p(_0x547b1a){m(_0x547b1a['unitID']),g('threadID',_0x547b1a['threadID']),g('replyID',_0x547b1a['replyID']);}function m(_0x52ffe2){g('unitID',_0x52ffe2);}function h(_0x4317da){if(typeof _0x4317da!='string'||_0x4317da['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x5811c2,_0x5dcb4c){if(typeof _0x5dcb4c!='string'||_0x5dcb4c['length']===0x0)throw _(_0x5811c2+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0x57ee2f){return new t['CollabError']('INVALID_REQUEST',_0x57ee2f);}function v(_0x5f3750){return new t['CollabError']('UNIT_NOT_FOUND',_0x5f3750);}function y(_0xa890a1){return new t['CollabError']('PERMISSION_DENIED',_0xa890a1);}exports['UniverCommentService']=i;
|
|
1
|
+
Object['defineProperty'](exports,Symbol['toStringTag'],{'value':'Module'});let e=require('node:crypto'),t=require('@univerjs-pro/collaboration-service'),n=require('@univerjs/protocol');var r=class{['_middlewares']=new Map();['use'](_0x310aee,_0x419f9a){let _0x371b3a=this['_middlewares']['get'](_0x310aee)??[],_0x332fd5=_0x419f9a;_0x371b3a['push'](_0x332fd5),this['_middlewares']['set'](_0x310aee,_0x371b3a);let _0x13302f=!0x1;return{'dispose':()=>{if(_0x13302f)return;_0x13302f=!0x0;let _0x46e3aa=_0x371b3a['indexOf'](_0x332fd5);_0x46e3aa>=0x0&&_0x371b3a['splice'](_0x46e3aa,0x1);}};}async['run'](_0x36f185,_0x163d46,_0xe9d833){let _0x235538=[...this['_middlewares']['get'](_0x36f185)??[]],_0x176806=async _0x5c9338=>{let _0x2960ed=_0x235538[_0x5c9338];if(!_0x2960ed)return _0xe9d833();let _0x39ef31=!0x1,_0x534458,_0x4c38df=()=>{if(_0x39ef31)throw Error('Middleware\x20for\x20action\x20'+_0x36f185+'\x20called\x20next()\x20more\x20than\x20once');return _0x39ef31=!0x0,_0x534458=_0x176806(_0x5c9338+0x1),_0x534458;};try{await _0x2960ed(_0x163d46,_0x4c38df);}catch(_0x58d96f){throw _0x534458&&await _0x534458['catch'](()=>void 0x0),_0x58d96f;}if(!_0x39ef31)throw Error('Middleware\x20for\x20action\x20'+_0x36f185+'\x20completed\x20without\x20calling\x20next()');await _0x534458;};await _0x176806(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x41ce39){if(!_0x41ce39?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x41ce39['database'],this['_userProvider']=_0x41ce39['userProvider'];}['use'](_0x2ddedb,_0x344bdf){return this['_assertRunning'](),this['_middleware']['use'](_0x2ddedb,_0x344bdf);}['on'](_0x2d5e80,_0x280d36){this['_assertRunning']();let _0x34f8d3=this['_listeners']['get'](_0x2d5e80)??new Set(),_0x4489de=_0x280d36;_0x34f8d3['add'](_0x4489de),this['_listeners']['set'](_0x2d5e80,_0x34f8d3);let _0x4f2aeb=!0x1;return{'dispose':()=>{_0x4f2aeb||(_0x4f2aeb=!0x0,_0x34f8d3['delete'](_0x4489de));}};}['addComment'](_0x5072fb,_0x36deba){return this['_call'](async()=>{let _0x2085df=s(_0x36deba);m(_0x5072fb['unitID']),h(_0x5072fb['content']);let _0x5147fc=a(_0x5072fb),_0x344604={..._0x2085df,'request':_0x5147fc},_0x304113;return await this['_middleware']['run']('addComment',_0x344604,async()=>{let _0x4b8060=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0x5072fb['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x2085df['userID'],'content':_0x5072fb['content'],'mentions':[..._0x5072fb['mentions']]},_0x344604));if(_0x4b8060['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x304113=u([_0x4b8060['record']]),await this['_emitWrite'](_0x2085df,_0x5147fc,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0x4b8060['record'],_0x2085df,_0x5147fc));}),_0x304113;});}['listComments'](_0x552696,_0x5c54e3){return this['_call'](async()=>{let _0xf880c=o(_0x5c54e3);m(_0x552696['unitID']),_0x552696['threadIDs']['forEach'](_0x455dc0=>g('threadID',_0x455dc0));let _0x46a529=a(_0x552696),_0x12c75c={..._0xf880c,'request':_0x46a529},_0x441318;return await this['_middleware']['run']('listComments',_0x12c75c,async()=>{let _0x22c1ee=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x552696['unitID'],'threadIDs':[...new Set(_0x552696['threadIDs'])]},_0x12c75c))),_0x59faca=Object['values'](_0x22c1ee)['flatMap'](_0x1405bc=>_0x1405bc['replies']['map'](_0x2ff92b=>_0x2ff92b['userId']));_0x441318={'comments':_0x22c1ee,'users':await this['_resolveUsers'](_0x59faca,_0xf880c,_0x46a529)};}),_0x441318;});}['replyComment'](_0x394d7d,_0x542f0f){return this['_call'](async()=>{let _0x1685b1=s(_0x542f0f);m(_0x394d7d['unitID']),g('threadID',_0x394d7d['threadID']),h(_0x394d7d['content']);let _0x2e0f3e=a(_0x394d7d),_0x4ec7af={..._0x1685b1,'request':_0x2e0f3e},_0xe511d8;return await this['_middleware']['run']('replyComment',_0x4ec7af,async()=>{let _0x54ef8d=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x394d7d['unitID'],'threadID':_0x394d7d['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0x1685b1['userID'],'content':_0x394d7d['content'],'mentions':[..._0x394d7d['mentions']]},_0x4ec7af));if(_0x54ef8d['status']==='not-found'||_0x54ef8d['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0x54ef8d['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0xe511d8=l(_0x54ef8d['record']),await this['_emitWrite'](_0x1685b1,_0x2e0f3e,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0x54ef8d['record'],_0x1685b1,_0x2e0f3e));}),_0xe511d8;});}['editComment'](_0x3c2c04,_0x349024){return this['_call'](async()=>{let _0x26e99e=s(_0x349024);p(_0x3c2c04),h(_0x3c2c04['content']);let _0xd5d781=a(_0x3c2c04),_0x4cc389={..._0x26e99e,'request':_0xd5d781};await this['_middleware']['run']('editComment',_0x4cc389,async()=>{let _0x410b83=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0x3c2c04['unitID'],'threadID':_0x3c2c04['threadID'],'replyID':_0x3c2c04['replyID'],'expectedAuthorUserID':_0x26e99e['userID'],'content':_0x3c2c04['content'],'mentions':[..._0x3c2c04['mentions']]},_0x4cc389));if(_0x410b83['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x410b83['status']==='not-found'||_0x410b83['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x410b83['status']==='edited'&&await this['_emitWrite'](_0x26e99e,_0xd5d781,f(n['CommentUpdateEventType']['Edit'],_0x410b83['record'],_0x26e99e));});});}['setThreadSolved'](_0x382391,_0x4564b3){return this['_call'](async()=>{let _0x4642d8=s(_0x4564b3);if(m(_0x382391['unitID']),g('threadID',_0x382391['threadID']),_0x382391['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0x382391['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0x390eb7=a(_0x382391),_0x131bad={..._0x4642d8,'request':_0x390eb7};await this['_middleware']['run']('setThreadSolved',_0x131bad,async()=>{let _0x1cb0f8=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0x382391,_0x131bad));if(_0x1cb0f8['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0x1cb0f8['status']==='updated'&&await this['_emitWrite'](_0x4642d8,_0x390eb7,{'memberId':_0x4642d8['memberID'],'userId':_0x4642d8['userID'],'unitId':_0x382391['unitID'],'threadId':_0x382391['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0x382391['solved']});});});}['deleteComment'](_0x12eac4,_0x26de90){return this['_call'](async()=>{let _0x217a07=s(_0x26de90);m(_0x12eac4['unitID']),g('threadID',_0x12eac4['threadID']),_0x12eac4['replyID']!==void 0x0&&g('replyID',_0x12eac4['replyID']);let _0x503514=_0x12eac4['replyID']===_0x12eac4['threadID']?void 0x0:_0x12eac4['replyID'],_0x448468=a({'unitID':_0x12eac4['unitID'],'threadID':_0x12eac4['threadID'],..._0x503514===void 0x0?{}:{'replyID':_0x503514}}),_0xc30986={..._0x217a07,'request':_0x448468},_0x965e1a=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0x12eac4['unitID'],'threadID':_0x12eac4['threadID'],'replyID':_0x503514??_0x12eac4['threadID']},_0xc30986));if(!_0x965e1a)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0xc30986,'request':_0x448468,'target':{'kind':_0x503514===void 0x0?'root':'reply','threadID':_0x965e1a['threadID'],'replyID':_0x965e1a['replyID'],'authorUserID':_0x965e1a['authorUserID'],'generation':_0x965e1a['generation']}},async()=>{let _0xabee17=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0x12eac4['unitID'],'threadID':_0x12eac4['threadID'],..._0x503514===void 0x0?{}:{'replyID':_0x503514},'expectedGeneration':_0x965e1a['generation']},_0xc30986));if(_0xabee17['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0xabee17['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0x217a07,_0x448468,{'memberId':_0x217a07['memberID'],'userId':_0x217a07['userID'],'unitId':_0x12eac4['unitID'],'threadId':_0x12eac4['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0x503514===void 0x0?{}:{'replyId':_0x503514}});});});}['dispose'](){return this['_disposePromise']?this['_disposePromise']:(this['_state']='disposing',this['_disposePromise']=((async()=>{await Promise['allSettled']([...this['_calls']]),this['_middleware']['clear'](),this['_listeners']['clear'](),this['_state']='disposed';})()),this['_disposePromise']);}async['_createUpdate'](_0xacc47d,_0x4d518b,_0x3d0097,_0x1eddd9){let _0x4f7cf1=await this['_resolveUsers']([_0x4d518b['authorUserID']],_0x3d0097,_0x1eddd9);return{...f(_0xacc47d,_0x4d518b,_0x3d0097),..._0x4f7cf1[_0x4d518b['authorUserID']]?{'user':_0x4f7cf1[_0x4d518b['authorUserID']]}:{}};}async['_resolveUsers'](_0xac50b1,_0x4b53b5,_0x3aea4c){let _0x346300=[...new Set(_0xac50b1['filter'](Boolean))];if(!this['_userProvider']||_0x346300['length']===0x0)return{};let _0x3bad59;try{_0x3bad59=await this['_userProvider']['getUsers'](_0x346300,{..._0x4b53b5,'request':_0x3aea4c});}catch{return{};}let _0x16e8b7=new Set(_0x346300),_0x35782c={};for(let _0x2a6cfd of _0x3bad59)_0x2a6cfd?.['userID']&&_0x16e8b7['has'](_0x2a6cfd['userID'])&&(_0x35782c[_0x2a6cfd['userID']]=_0x2a6cfd);return _0x35782c;}async['_emitWrite'](_0x2dd7d3,_0x4901fb,_0x2a83e5){let _0x559eb7={'userID':_0x2dd7d3['userID'],'memberID':_0x2dd7d3['memberID'],'customData':_0x2dd7d3['customData'],'request':_0x4901fb,'update':_0x2a83e5,'committedAt':Date['now']()};for(let _0x3dd52f of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0x3dd52f(_0x559eb7);}catch{}}['_call'](_0x2e5547){this['_assertRunning']();let _0x3f82af=_0x2e5547();return this['_calls']['add'](_0x3f82af),_0x3f82af['finally'](()=>this['_calls']['delete'](_0x3f82af))['catch'](()=>void 0x0),_0x3f82af;}async['_databaseCall'](_0x5db7b2){try{return await _0x5db7b2();}catch(_0x59b0b8){throw _0x59b0b8 instanceof t['CollabError']?_0x59b0b8:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x59b0b8});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0xfd8f93){return{..._0xfd8f93};}function o(_0x3add38){return c(_0x3add38),{'userID':_0x3add38['userID'],'customData':_0x3add38['customData']??Object['create'](null)};}function s(_0x4632f1){return c(_0x4632f1),g('memberID',_0x4632f1['memberID']),{'userID':_0x4632f1['userID'],'memberID':_0x4632f1['memberID'],'customData':_0x4632f1['customData']??Object['create'](null)};}function c(_0x23cf1a){if(!_0x23cf1a||typeof _0x23cf1a!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0x23cf1a['userID']),_0x23cf1a['customData']!==void 0x0&&(_0x23cf1a['customData']===null||typeof _0x23cf1a['customData']!='object'||Array['isArray'](_0x23cf1a['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0x131fa4){return{'threadId':_0x131fa4['threadID'],'replyId':_0x131fa4['replyID'],'content':_0x131fa4['content'],'userId':_0x131fa4['authorUserID'],'createTimestamp':_0x131fa4['createdAt']};}function u(_0x500e95){let _0x5dc7b0=_0x500e95['find'](_0x41a682=>_0x41a682['replyID']===_0x41a682['threadID']);return{'threadId':_0x5dc7b0['threadID'],'solved':_0x5dc7b0['solved'],'replies':_0x500e95['map'](l)};}function d(_0xe7c838){let _0x296ba=new Map();for(let _0x51c39c of _0xe7c838){let _0x8228c5=_0x296ba['get'](_0x51c39c['threadID'])??[];_0x8228c5['push'](_0x51c39c),_0x296ba['set'](_0x51c39c['threadID'],_0x8228c5);}let _0x4dfbf9={};for(let [_0x13096a,_0x42b539]of _0x296ba)_0x42b539['find'](_0x4a4fcb=>_0x4a4fcb['replyID']===_0x13096a)&&(_0x4dfbf9[_0x13096a]=u([..._0x42b539]['sort']((_0x38f593,_0x104c62)=>_0x38f593['replyID']===_0x13096a?-0x1:_0x104c62['replyID']===_0x13096a?0x1:_0x38f593['createdAt']-_0x104c62['createdAt']||_0x38f593['replyID']['localeCompare'](_0x104c62['replyID']))));return _0x4dfbf9;}function f(_0x41169b,_0x4d9a80,_0x15cfd0){return{'memberId':_0x15cfd0['memberID'],'userId':_0x15cfd0['userID'],'unitId':_0x4d9a80['unitID'],'threadId':_0x4d9a80['threadID'],'type':_0x41169b,'replyId':_0x4d9a80['replyID'],'content':_0x4d9a80['content'],'createTimestamp':String(_0x4d9a80['createdAt'])};}function p(_0x5e0a70){m(_0x5e0a70['unitID']),g('threadID',_0x5e0a70['threadID']),g('replyID',_0x5e0a70['replyID']);}function m(_0x26e137){g('unitID',_0x26e137);}function h(_0x10f9fa){if(typeof _0x10f9fa!='string'||_0x10f9fa['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x302ced,_0x4928e0){if(typeof _0x4928e0!='string'||_0x4928e0['length']===0x0)throw _(_0x302ced+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0xefeaa8){return new t['CollabError']('INVALID_REQUEST',_0xefeaa8);}function v(_0xca238a){return new t['CollabError']('UNIT_NOT_FOUND',_0xca238a);}function y(_0x13a8bf){return new t['CollabError']('PERMISSION_DENIED',_0x13a8bf);}exports['UniverCommentService']=i;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0xb63c82,_0x59f3ca){const _0x2f4bf9=_0x2c2b,_0x3b80fd=_0xb63c82();while(!![]){try{const _0x4a8609=-parseInt(_0x2f4bf9(0x191))/0x1+-parseInt(_0x2f4bf9(0x193))/0x2+parseInt(_0x2f4bf9(0x195))/0x3+-parseInt(_0x2f4bf9(0x192))/0x4*(parseInt(_0x2f4bf9(0x196))/0x5)+parseInt(_0x2f4bf9(0x18f))/0x6+parseInt(_0x2f4bf9(0x194))/0x7+parseInt(_0x2f4bf9(0x197))/0x8*(parseInt(_0x2f4bf9(0x190))/0x9);if(_0x4a8609===_0x59f3ca)break;else _0x3b80fd['push'](_0x3b80fd['shift']());}catch(_0x131f3b){_0x3b80fd['push'](_0x3b80fd['shift']());}}}(_0x1162,0x50565));function _0x1162(){const _0x5ccd17=['187321bJzcZk','348jBelfX','505704mBbFej','2028068xZLvah','1802724mnwqWz','15595Hqmjjs','22720QBnEtC','201090NWvSFv','369amoDIU'];_0x1162=function(){return _0x5ccd17;};return _0x1162();}function _0x2c2b(_0x25e085,_0xd86d82){_0x25e085=_0x25e085-0x18f;const _0x11625d=_0x1162();let _0x2c2b2e=_0x11625d[_0x25e085];return _0x2c2b2e;}import _0x54e5e8 from'./index.cjs';const facadeExport0=_0x54e5e8['UniverCommentService'];export{facadeExport0 as UniverCommentService};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs-pro/collaboration-comment-service",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@univerjs-pro/collaboration-service": "1.
|
|
20
|
-
"@univerjs/protocol": "1.
|
|
19
|
+
"@univerjs-pro/collaboration-service": "1.3.0",
|
|
20
|
+
"@univerjs/protocol": "1.3.0"
|
|
21
21
|
}
|
|
22
22
|
}
|