@univerjs-pro/collaboration-comment-service 1.5.2 → 1.6.1
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'](_0x26bd4b,_0x33ef5b){let _0x4e821b=this['_middlewares']['get'](_0x26bd4b)??[],_0x4d913f=_0x33ef5b;_0x4e821b['push'](_0x4d913f),this['_middlewares']['set'](_0x26bd4b,_0x4e821b);let _0x30f023=!0x1;return{'dispose':()=>{if(_0x30f023)return;_0x30f023=!0x0;let _0x40f48a=_0x4e821b['indexOf'](_0x4d913f);_0x40f48a>=0x0&&_0x4e821b['splice'](_0x40f48a,0x1);}};}async['run'](_0x5187a5,_0x294b0c,_0x2d4cf0){let _0x9387d1=[...this['_middlewares']['get'](_0x5187a5)??[]],_0x201780=async _0x2f13af=>{let _0x14980c=_0x9387d1[_0x2f13af];if(!_0x14980c)return _0x2d4cf0();let _0x28728d=!0x1,_0x3b97ea,_0x3a5737=()=>{if(_0x28728d)throw Error('Middleware\x20for\x20action\x20'+_0x5187a5+'\x20called\x20next()\x20more\x20than\x20once');return _0x28728d=!0x0,_0x3b97ea=_0x201780(_0x2f13af+0x1),_0x3b97ea;};try{await _0x14980c(_0x294b0c,_0x3a5737);}catch(_0x3213f2){throw _0x3b97ea&&await _0x3b97ea['catch'](()=>void 0x0),_0x3213f2;}if(!_0x28728d)throw Error('Middleware\x20for\x20action\x20'+_0x5187a5+'\x20completed\x20without\x20calling\x20next()');await _0x3b97ea;};await _0x201780(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x2185ad){if(!_0x2185ad?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x2185ad['database'],this['_userProvider']=_0x2185ad['userProvider'];}['use'](_0x33e1f0,_0x25442f){return this['_assertRunning'](),this['_middleware']['use'](_0x33e1f0,_0x25442f);}['on'](_0x5d30a7,_0x4c730e){this['_assertRunning']();let _0xae0b22=this['_listeners']['get'](_0x5d30a7)??new Set(),_0x4756a1=_0x4c730e;_0xae0b22['add'](_0x4756a1),this['_listeners']['set'](_0x5d30a7,_0xae0b22);let _0x8fcaee=!0x1;return{'dispose':()=>{_0x8fcaee||(_0x8fcaee=!0x0,_0xae0b22['delete'](_0x4756a1));}};}['addComment'](_0x36ad50,_0x53092e){return this['_call'](async()=>{let _0x370abd=s(_0x53092e);m(_0x36ad50['unitID']),h(_0x36ad50['content']);let _0x2f352b=a(_0x36ad50),_0x10ab1a={..._0x370abd,'request':_0x2f352b},_0x2e66f2;return await this['_middleware']['run']('addComment',_0x10ab1a,async()=>{let _0x44fb17=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0x36ad50['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x370abd['userID'],'content':_0x36ad50['content'],'mentions':[..._0x36ad50['mentions']]},_0x10ab1a));if(_0x44fb17['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x2e66f2=u([_0x44fb17['record']]),await this['_emitWrite'](_0x370abd,_0x2f352b,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0x44fb17['record'],_0x370abd,_0x2f352b));}),_0x2e66f2;});}['listComments'](_0x3a6e83,_0x266486){return this['_call'](async()=>{let _0x31315d=o(_0x266486);m(_0x3a6e83['unitID']),_0x3a6e83['threadIDs']['forEach'](_0x17afab=>g('threadID',_0x17afab));let _0x127c64=a(_0x3a6e83),_0x8f22de={..._0x31315d,'request':_0x127c64},_0x2b1ede;return await this['_middleware']['run']('listComments',_0x8f22de,async()=>{let _0x200694=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x3a6e83['unitID'],'threadIDs':[...new Set(_0x3a6e83['threadIDs'])]},_0x8f22de))),_0x4c3e50=Object['values'](_0x200694)['flatMap'](_0x12bc64=>_0x12bc64['replies']['map'](_0xcdbc90=>_0xcdbc90['userId']));_0x2b1ede={'comments':_0x200694,'users':await this['_resolveUsers'](_0x4c3e50,_0x31315d,_0x127c64)};}),_0x2b1ede;});}['replyComment'](_0x4fbc81,_0x1ef4b6){return this['_call'](async()=>{let _0x235f28=s(_0x1ef4b6);m(_0x4fbc81['unitID']),g('threadID',_0x4fbc81['threadID']),h(_0x4fbc81['content']);let _0x32a52c=a(_0x4fbc81),_0x5c8889={..._0x235f28,'request':_0x32a52c},_0x1d4814;return await this['_middleware']['run']('replyComment',_0x5c8889,async()=>{let _0xbab4c8=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x4fbc81['unitID'],'threadID':_0x4fbc81['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0x235f28['userID'],'content':_0x4fbc81['content'],'mentions':[..._0x4fbc81['mentions']]},_0x5c8889));if(_0xbab4c8['status']==='not-found'||_0xbab4c8['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0xbab4c8['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x1d4814=l(_0xbab4c8['record']),await this['_emitWrite'](_0x235f28,_0x32a52c,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0xbab4c8['record'],_0x235f28,_0x32a52c));}),_0x1d4814;});}['editComment'](_0x483228,_0x45af72){return this['_call'](async()=>{let _0x5a5b02=s(_0x45af72);p(_0x483228),h(_0x483228['content']);let _0x2bf786=a(_0x483228),_0x14f608={..._0x5a5b02,'request':_0x2bf786};await this['_middleware']['run']('editComment',_0x14f608,async()=>{let _0x247ae1=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0x483228['unitID'],'threadID':_0x483228['threadID'],'replyID':_0x483228['replyID'],'expectedAuthorUserID':_0x5a5b02['userID'],'content':_0x483228['content'],'mentions':[..._0x483228['mentions']]},_0x14f608));if(_0x247ae1['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x247ae1['status']==='not-found'||_0x247ae1['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x247ae1['status']==='edited'&&await this['_emitWrite'](_0x5a5b02,_0x2bf786,f(n['CommentUpdateEventType']['Edit'],_0x247ae1['record'],_0x5a5b02));});});}['setThreadSolved'](_0x14df2a,_0x30ec2b){return this['_call'](async()=>{let _0x3a11eb=s(_0x30ec2b);if(m(_0x14df2a['unitID']),g('threadID',_0x14df2a['threadID']),_0x14df2a['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0x14df2a['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0x26855a=a(_0x14df2a),_0x92e5f8={..._0x3a11eb,'request':_0x26855a};await this['_middleware']['run']('setThreadSolved',_0x92e5f8,async()=>{let _0x4f518d=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0x14df2a,_0x92e5f8));if(_0x4f518d['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0x4f518d['status']==='updated'&&await this['_emitWrite'](_0x3a11eb,_0x26855a,{'memberId':_0x3a11eb['memberID'],'userId':_0x3a11eb['userID'],'unitId':_0x14df2a['unitID'],'threadId':_0x14df2a['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0x14df2a['solved']});});});}['deleteComment'](_0x51e9cb,_0x4c4099){return this['_call'](async()=>{let _0x4ce3cf=s(_0x4c4099);m(_0x51e9cb['unitID']),g('threadID',_0x51e9cb['threadID']),_0x51e9cb['replyID']!==void 0x0&&g('replyID',_0x51e9cb['replyID']);let _0xbc6976=_0x51e9cb['replyID']===_0x51e9cb['threadID']?void 0x0:_0x51e9cb['replyID'],_0x2ae204=a({'unitID':_0x51e9cb['unitID'],'threadID':_0x51e9cb['threadID'],..._0xbc6976===void 0x0?{}:{'replyID':_0xbc6976}}),_0x3e1fa7={..._0x4ce3cf,'request':_0x2ae204},_0x1a4554=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0x51e9cb['unitID'],'threadID':_0x51e9cb['threadID'],'replyID':_0xbc6976??_0x51e9cb['threadID']},_0x3e1fa7));if(!_0x1a4554)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0x3e1fa7,'request':_0x2ae204,'target':{'kind':_0xbc6976===void 0x0?'root':'reply','threadID':_0x1a4554['threadID'],'replyID':_0x1a4554['replyID'],'authorUserID':_0x1a4554['authorUserID'],'generation':_0x1a4554['generation']}},async()=>{let _0x4a2e29=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0x51e9cb['unitID'],'threadID':_0x51e9cb['threadID'],..._0xbc6976===void 0x0?{}:{'replyID':_0xbc6976},'expectedGeneration':_0x1a4554['generation']},_0x3e1fa7));if(_0x4a2e29['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0x4a2e29['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0x4ce3cf,_0x2ae204,{'memberId':_0x4ce3cf['memberID'],'userId':_0x4ce3cf['userID'],'unitId':_0x51e9cb['unitID'],'threadId':_0x51e9cb['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0xbc6976===void 0x0?{}:{'replyId':_0xbc6976}});});});}['dispose'](){return this['_disposePromise']||=(this['_state']='disposing',((async()=>{await Promise['allSettled']([...this['_calls']]),this['_middleware']['clear'](),this['_listeners']['clear'](),this['_state']='disposed';})())),this['_disposePromise'];}async['_createUpdate'](_0x5cdd91,_0x521e65,_0x24f4f8,_0x1dac9b){let _0x569377=await this['_resolveUsers']([_0x521e65['authorUserID']],_0x24f4f8,_0x1dac9b);return{...f(_0x5cdd91,_0x521e65,_0x24f4f8),..._0x569377[_0x521e65['authorUserID']]?{'user':_0x569377[_0x521e65['authorUserID']]}:{}};}async['_resolveUsers'](_0x8fe8f0,_0x5493a0,_0x4d683f){let _0xd7b82f=[...new Set(_0x8fe8f0['filter'](Boolean))];if(!this['_userProvider']||_0xd7b82f['length']===0x0)return{};let _0x37e106;try{_0x37e106=await this['_userProvider']['getUsers'](_0xd7b82f,{..._0x5493a0,'request':_0x4d683f});}catch{return{};}let _0xf5645f=new Set(_0xd7b82f),_0x2e1936={};for(let _0x2237fc of _0x37e106)_0x2237fc?.['userID']&&_0xf5645f['has'](_0x2237fc['userID'])&&(_0x2e1936[_0x2237fc['userID']]=_0x2237fc);return _0x2e1936;}async['_emitWrite'](_0x43e091,_0x291744,_0x3485d5){let _0x4eb609={'userID':_0x43e091['userID'],'memberID':_0x43e091['memberID'],'customData':_0x43e091['customData'],'request':_0x291744,'update':_0x3485d5,'committedAt':Date['now']()};for(let _0x48bb42 of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0x48bb42(_0x4eb609);}catch{}}['_call'](_0x3b3d16){this['_assertRunning']();let _0x7b1ee0=_0x3b3d16();return this['_calls']['add'](_0x7b1ee0),_0x7b1ee0['finally'](()=>this['_calls']['delete'](_0x7b1ee0))['catch'](()=>void 0x0),_0x7b1ee0;}async['_databaseCall'](_0xe96444){try{return await _0xe96444();}catch(_0x35c4a6){throw _0x35c4a6 instanceof t['CollabError']?_0x35c4a6:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x35c4a6});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0x25c9cf){return{..._0x25c9cf};}function o(_0x3b42d5){return c(_0x3b42d5),{'userID':_0x3b42d5['userID'],'customData':_0x3b42d5['customData']??Object['create'](null)};}function s(_0x5b98e9){return c(_0x5b98e9),g('memberID',_0x5b98e9['memberID']),{'userID':_0x5b98e9['userID'],'memberID':_0x5b98e9['memberID'],'customData':_0x5b98e9['customData']??Object['create'](null)};}function c(_0x532c3){if(!_0x532c3||typeof _0x532c3!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0x532c3['userID']),_0x532c3['customData']!==void 0x0&&(_0x532c3['customData']===null||typeof _0x532c3['customData']!='object'||Array['isArray'](_0x532c3['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0x1ab3e7){return{'threadId':_0x1ab3e7['threadID'],'replyId':_0x1ab3e7['replyID'],'content':_0x1ab3e7['content'],'userId':_0x1ab3e7['authorUserID'],'createTimestamp':_0x1ab3e7['createdAt']};}function u(_0x596575){let _0x2c31a5=_0x596575['find'](_0x4c230e=>_0x4c230e['replyID']===_0x4c230e['threadID']);return{'threadId':_0x2c31a5['threadID'],'solved':_0x2c31a5['solved'],'replies':_0x596575['map'](l)};}function d(_0x496afb){let _0x8ce141=new Map();for(let _0x596af3 of _0x496afb){let _0xd52aca=_0x8ce141['get'](_0x596af3['threadID'])??[];_0xd52aca['push'](_0x596af3),_0x8ce141['set'](_0x596af3['threadID'],_0xd52aca);}let _0xa11d95={};for(let [_0x4ed4fc,_0x37e232]of _0x8ce141)_0x37e232['find'](_0x4da7ab=>_0x4da7ab['replyID']===_0x4ed4fc)&&(_0xa11d95[_0x4ed4fc]=u([..._0x37e232]['sort']((_0x599ded,_0x51dae3)=>_0x599ded['replyID']===_0x4ed4fc?-0x1:_0x51dae3['replyID']===_0x4ed4fc?0x1:_0x599ded['createdAt']-_0x51dae3['createdAt']||_0x599ded['replyID']['localeCompare'](_0x51dae3['replyID']))));return _0xa11d95;}function f(_0x38c6db,_0x53adef,_0x435739){return{'memberId':_0x435739['memberID'],'userId':_0x435739['userID'],'unitId':_0x53adef['unitID'],'threadId':_0x53adef['threadID'],'type':_0x38c6db,'replyId':_0x53adef['replyID'],'content':_0x53adef['content'],'createTimestamp':String(_0x53adef['createdAt'])};}function p(_0x13a9d5){m(_0x13a9d5['unitID']),g('threadID',_0x13a9d5['threadID']),g('replyID',_0x13a9d5['replyID']);}function m(_0x153d7b){g('unitID',_0x153d7b);}function h(_0xcf0893){if(typeof _0xcf0893!='string'||_0xcf0893['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x67fa2d,_0x474083){if(typeof _0x474083!='string'||_0x474083['length']===0x0)throw _(_0x67fa2d+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0x2b77e3){return new t['CollabError']('INVALID_REQUEST',_0x2b77e3);}function v(_0x5f5173){return new t['CollabError']('UNIT_NOT_FOUND',_0x5f5173);}function y(_0x140ce2){return new t['CollabError']('PERMISSION_DENIED',_0x140ce2);}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'](_0x56bb2d,_0x4c51b6){let _0x521b33=this['_middlewares']['get'](_0x56bb2d)??[],_0xf2ae49=_0x4c51b6;_0x521b33['push'](_0xf2ae49),this['_middlewares']['set'](_0x56bb2d,_0x521b33);let _0x54504b=!0x1;return{'dispose':()=>{if(_0x54504b)return;_0x54504b=!0x0;let _0x4d7560=_0x521b33['indexOf'](_0xf2ae49);_0x4d7560>=0x0&&_0x521b33['splice'](_0x4d7560,0x1);}};}async['run'](_0x7aeddf,_0x5cac3b,_0x4a4e6c){let _0x4127a8=[...this['_middlewares']['get'](_0x7aeddf)??[]],_0x2f2cee=async _0x584bc1=>{let _0xb7f864=_0x4127a8[_0x584bc1];if(!_0xb7f864)return _0x4a4e6c();let _0x472040=!0x1,_0xf97dac,_0x570286=()=>{if(_0x472040)throw Error('Middleware\x20for\x20action\x20'+_0x7aeddf+'\x20called\x20next()\x20more\x20than\x20once');return _0x472040=!0x0,_0xf97dac=_0x2f2cee(_0x584bc1+0x1),_0xf97dac;};try{await _0xb7f864(_0x5cac3b,_0x570286);}catch(_0x264db2){throw _0xf97dac&&await _0xf97dac['catch'](()=>void 0x0),_0x264db2;}if(!_0x472040)throw Error('Middleware\x20for\x20action\x20'+_0x7aeddf+'\x20completed\x20without\x20calling\x20next()');await _0xf97dac;};await _0x2f2cee(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x325167){if(!_0x325167?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x325167['database'],this['_userProvider']=_0x325167['userProvider'];}['use'](_0x136acc,_0x35d3f5){return this['_assertRunning'](),this['_middleware']['use'](_0x136acc,_0x35d3f5);}['on'](_0x119cdf,_0x17e030){this['_assertRunning']();let _0x4b1926=this['_listeners']['get'](_0x119cdf)??new Set(),_0x40030e=_0x17e030;_0x4b1926['add'](_0x40030e),this['_listeners']['set'](_0x119cdf,_0x4b1926);let _0x28e92e=!0x1;return{'dispose':()=>{_0x28e92e||(_0x28e92e=!0x0,_0x4b1926['delete'](_0x40030e));}};}['addComment'](_0x3458a4,_0x115d04){return this['_call'](async()=>{let _0x1a5749=s(_0x115d04);m(_0x3458a4['unitID']),h(_0x3458a4['content']);let _0x4b8f0e=a(_0x3458a4),_0x1f409d={..._0x1a5749,'request':_0x4b8f0e},_0x333260;return await this['_middleware']['run']('addComment',_0x1f409d,async()=>{let _0x650247=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0x3458a4['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x1a5749['userID'],'content':_0x3458a4['content'],'mentions':[..._0x3458a4['mentions']]},_0x1f409d));if(_0x650247['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x333260=u([_0x650247['record']]),await this['_emitWrite'](_0x1a5749,_0x4b8f0e,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0x650247['record'],_0x1a5749,_0x4b8f0e));}),_0x333260;});}['listComments'](_0x53c996,_0xf6409f){return this['_call'](async()=>{let _0x15807e=o(_0xf6409f);m(_0x53c996['unitID']),_0x53c996['threadIDs']['forEach'](_0x124e6a=>g('threadID',_0x124e6a));let _0x437738=a(_0x53c996),_0x99e1f={..._0x15807e,'request':_0x437738},_0x4a4d0d;return await this['_middleware']['run']('listComments',_0x99e1f,async()=>{let _0xd5887=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x53c996['unitID'],'threadIDs':[...new Set(_0x53c996['threadIDs'])]},_0x99e1f))),_0x11768e=Object['values'](_0xd5887)['flatMap'](_0x164d38=>_0x164d38['replies']['map'](_0x2e2718=>_0x2e2718['userId']));_0x4a4d0d={'comments':_0xd5887,'users':await this['_resolveUsers'](_0x11768e,_0x15807e,_0x437738)};}),_0x4a4d0d;});}['replyComment'](_0x59b08d,_0x217f4c){return this['_call'](async()=>{let _0x5d468e=s(_0x217f4c);m(_0x59b08d['unitID']),g('threadID',_0x59b08d['threadID']),h(_0x59b08d['content']);let _0x3f34a9=a(_0x59b08d),_0x4ec76f={..._0x5d468e,'request':_0x3f34a9},_0x503b20;return await this['_middleware']['run']('replyComment',_0x4ec76f,async()=>{let _0x23320d=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x59b08d['unitID'],'threadID':_0x59b08d['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0x5d468e['userID'],'content':_0x59b08d['content'],'mentions':[..._0x59b08d['mentions']]},_0x4ec76f));if(_0x23320d['status']==='not-found'||_0x23320d['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0x23320d['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x503b20=l(_0x23320d['record']),await this['_emitWrite'](_0x5d468e,_0x3f34a9,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0x23320d['record'],_0x5d468e,_0x3f34a9));}),_0x503b20;});}['editComment'](_0x524f3b,_0x4aca36){return this['_call'](async()=>{let _0x5a647a=s(_0x4aca36);p(_0x524f3b),h(_0x524f3b['content']);let _0x1660d4=a(_0x524f3b),_0x30fcf9={..._0x5a647a,'request':_0x1660d4};await this['_middleware']['run']('editComment',_0x30fcf9,async()=>{let _0x21a768=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0x524f3b['unitID'],'threadID':_0x524f3b['threadID'],'replyID':_0x524f3b['replyID'],'expectedAuthorUserID':_0x5a647a['userID'],'content':_0x524f3b['content'],'mentions':[..._0x524f3b['mentions']]},_0x30fcf9));if(_0x21a768['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x21a768['status']==='not-found'||_0x21a768['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x21a768['status']==='edited'&&await this['_emitWrite'](_0x5a647a,_0x1660d4,f(n['CommentUpdateEventType']['Edit'],_0x21a768['record'],_0x5a647a));});});}['setThreadSolved'](_0x3fed41,_0x1ccd87){return this['_call'](async()=>{let _0x218143=s(_0x1ccd87);if(m(_0x3fed41['unitID']),g('threadID',_0x3fed41['threadID']),_0x3fed41['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0x3fed41['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0x593dc1=a(_0x3fed41),_0x300bc8={..._0x218143,'request':_0x593dc1};await this['_middleware']['run']('setThreadSolved',_0x300bc8,async()=>{let _0x3c8f7e=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0x3fed41,_0x300bc8));if(_0x3c8f7e['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0x3c8f7e['status']==='updated'&&await this['_emitWrite'](_0x218143,_0x593dc1,{'memberId':_0x218143['memberID'],'userId':_0x218143['userID'],'unitId':_0x3fed41['unitID'],'threadId':_0x3fed41['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0x3fed41['solved']});});});}['deleteComment'](_0x4384ca,_0x44e9f4){return this['_call'](async()=>{let _0x572660=s(_0x44e9f4);m(_0x4384ca['unitID']),g('threadID',_0x4384ca['threadID']),_0x4384ca['replyID']!==void 0x0&&g('replyID',_0x4384ca['replyID']);let _0x42b331=_0x4384ca['replyID']===_0x4384ca['threadID']?void 0x0:_0x4384ca['replyID'],_0x419655=a({'unitID':_0x4384ca['unitID'],'threadID':_0x4384ca['threadID'],..._0x42b331===void 0x0?{}:{'replyID':_0x42b331}}),_0x2f00a3={..._0x572660,'request':_0x419655},_0x5993a5=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0x4384ca['unitID'],'threadID':_0x4384ca['threadID'],'replyID':_0x42b331??_0x4384ca['threadID']},_0x2f00a3));if(!_0x5993a5)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0x2f00a3,'request':_0x419655,'target':{'kind':_0x42b331===void 0x0?'root':'reply','threadID':_0x5993a5['threadID'],'replyID':_0x5993a5['replyID'],'authorUserID':_0x5993a5['authorUserID'],'generation':_0x5993a5['generation']}},async()=>{let _0xd308a9=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0x4384ca['unitID'],'threadID':_0x4384ca['threadID'],..._0x42b331===void 0x0?{}:{'replyID':_0x42b331},'expectedGeneration':_0x5993a5['generation']},_0x2f00a3));if(_0xd308a9['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0xd308a9['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0x572660,_0x419655,{'memberId':_0x572660['memberID'],'userId':_0x572660['userID'],'unitId':_0x4384ca['unitID'],'threadId':_0x4384ca['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0x42b331===void 0x0?{}:{'replyId':_0x42b331}});});});}['dispose'](){return this['_disposePromise']||=(this['_state']='disposing',((async()=>{await Promise['allSettled']([...this['_calls']]),this['_middleware']['clear'](),this['_listeners']['clear'](),this['_state']='disposed';})())),this['_disposePromise'];}async['_createUpdate'](_0xa45a0c,_0x3bd883,_0x52e39a,_0x39c8a0){let _0x57a3cc=await this['_resolveUsers']([_0x3bd883['authorUserID']],_0x52e39a,_0x39c8a0);return{...f(_0xa45a0c,_0x3bd883,_0x52e39a),..._0x57a3cc[_0x3bd883['authorUserID']]?{'user':_0x57a3cc[_0x3bd883['authorUserID']]}:{}};}async['_resolveUsers'](_0xf58dc1,_0x2c605a,_0x1fb499){let _0x292256=[...new Set(_0xf58dc1['filter'](Boolean))];if(!this['_userProvider']||_0x292256['length']===0x0)return{};let _0x2918d7;try{_0x2918d7=await this['_userProvider']['getUsers'](_0x292256,{..._0x2c605a,'request':_0x1fb499});}catch{return{};}let _0x39b616=new Set(_0x292256),_0x31adbe={};for(let _0x444fbf of _0x2918d7)_0x444fbf?.['userID']&&_0x39b616['has'](_0x444fbf['userID'])&&(_0x31adbe[_0x444fbf['userID']]=_0x444fbf);return _0x31adbe;}async['_emitWrite'](_0x2427fa,_0x2b5fa6,_0x567761){let _0x170d10={'userID':_0x2427fa['userID'],'memberID':_0x2427fa['memberID'],'customData':_0x2427fa['customData'],'request':_0x2b5fa6,'update':_0x567761,'committedAt':Date['now']()};for(let _0x3fa319 of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0x3fa319(_0x170d10);}catch{}}['_call'](_0x3bca4a){this['_assertRunning']();let _0x5478da=_0x3bca4a();return this['_calls']['add'](_0x5478da),_0x5478da['finally'](()=>this['_calls']['delete'](_0x5478da))['catch'](()=>void 0x0),_0x5478da;}async['_databaseCall'](_0x33def3){try{return await _0x33def3();}catch(_0x22ab80){throw _0x22ab80 instanceof t['CollabError']?_0x22ab80:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x22ab80});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0x5da422){return{..._0x5da422};}function o(_0x9f066f){return c(_0x9f066f),{'userID':_0x9f066f['userID'],'customData':_0x9f066f['customData']??Object['create'](null)};}function s(_0x314cd4){return c(_0x314cd4),g('memberID',_0x314cd4['memberID']),{'userID':_0x314cd4['userID'],'memberID':_0x314cd4['memberID'],'customData':_0x314cd4['customData']??Object['create'](null)};}function c(_0x185d14){if(!_0x185d14||typeof _0x185d14!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0x185d14['userID']),_0x185d14['customData']!==void 0x0&&(_0x185d14['customData']===null||typeof _0x185d14['customData']!='object'||Array['isArray'](_0x185d14['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0x8dec4c){return{'threadId':_0x8dec4c['threadID'],'replyId':_0x8dec4c['replyID'],'content':_0x8dec4c['content'],'userId':_0x8dec4c['authorUserID'],'createTimestamp':_0x8dec4c['createdAt']};}function u(_0x2f15ba){let _0x23bd6e=_0x2f15ba['find'](_0x52acd5=>_0x52acd5['replyID']===_0x52acd5['threadID']);return{'threadId':_0x23bd6e['threadID'],'solved':_0x23bd6e['solved'],'replies':_0x2f15ba['map'](l)};}function d(_0x34812d){let _0x3fe9a8=new Map();for(let _0x334f11 of _0x34812d){let _0x194af5=_0x3fe9a8['get'](_0x334f11['threadID'])??[];_0x194af5['push'](_0x334f11),_0x3fe9a8['set'](_0x334f11['threadID'],_0x194af5);}let _0x4a2ac8={};for(let [_0x1094cb,_0x5d138]of _0x3fe9a8)_0x5d138['find'](_0x16456d=>_0x16456d['replyID']===_0x1094cb)&&(_0x4a2ac8[_0x1094cb]=u([..._0x5d138]['sort']((_0x36d958,_0x425e76)=>_0x36d958['replyID']===_0x1094cb?-0x1:_0x425e76['replyID']===_0x1094cb?0x1:_0x36d958['createdAt']-_0x425e76['createdAt']||_0x36d958['replyID']['localeCompare'](_0x425e76['replyID']))));return _0x4a2ac8;}function f(_0x31f112,_0x473ca3,_0xff24f5){return{'memberId':_0xff24f5['memberID'],'userId':_0xff24f5['userID'],'unitId':_0x473ca3['unitID'],'threadId':_0x473ca3['threadID'],'type':_0x31f112,'replyId':_0x473ca3['replyID'],'content':_0x473ca3['content'],'createTimestamp':String(_0x473ca3['createdAt'])};}function p(_0x442d8b){m(_0x442d8b['unitID']),g('threadID',_0x442d8b['threadID']),g('replyID',_0x442d8b['replyID']);}function m(_0x34884d){g('unitID',_0x34884d);}function h(_0x1af9fc){if(typeof _0x1af9fc!='string'||_0x1af9fc['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x54d29c,_0x22f14f){if(typeof _0x22f14f!='string'||_0x22f14f['length']===0x0)throw _(_0x54d29c+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0x3356b1){return new t['CollabError']('INVALID_REQUEST',_0x3356b1);}function v(_0x63af2f){return new t['CollabError']('UNIT_NOT_FOUND',_0x63af2f);}function y(_0x456356){return new t['CollabError']('PERMISSION_DENIED',_0x456356);}exports['UniverCommentService']=i;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _0x384c(_0x39e6f6,_0x31ff94){_0x39e6f6=_0x39e6f6-0x195;const _0x49dd42=_0x49dd();let _0x384c58=_0x49dd42[_0x39e6f6];return _0x384c58;}(function(_0x433437,_0x192a2e){const _0x34e404=_0x384c,_0x5e7d8e=_0x433437();while(!![]){try{const _0x354d74=parseInt(_0x34e404(0x19a))/0x1+-parseInt(_0x34e404(0x19c))/0x2*(-parseInt(_0x34e404(0x19b))/0x3)+-parseInt(_0x34e404(0x198))/0x4+-parseInt(_0x34e404(0x195))/0x5+parseInt(_0x34e404(0x19d))/0x6+parseInt(_0x34e404(0x197))/0x7+-parseInt(_0x34e404(0x196))/0x8*(parseInt(_0x34e404(0x199))/0x9);if(_0x354d74===_0x192a2e)break;else _0x5e7d8e['push'](_0x5e7d8e['shift']());}catch(_0x540bd8){_0x5e7d8e['push'](_0x5e7d8e['shift']());}}}(_0x49dd,0xb1e52));function _0x49dd(){const _0x34a9fa=['10HiOIYU','4969668dUMpqo','5265030wdoITj','2152aJlkuk','7982730BjFEZU','3127280BYwxVm','22050AarnEP','68411Lfjllx','711273HnKLzq'];_0x49dd=function(){return _0x34a9fa;};return _0x49dd();}import _0x19f8a2 from'./index.cjs';const facadeExport0=_0x19f8a2['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.6.1",
|
|
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.6.1",
|
|
20
|
+
"@univerjs/protocol": "1.6.1"
|
|
21
21
|
}
|
|
22
22
|
}
|