@univerjs-pro/collaboration-comment-service 1.3.0 → 1.3.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'](_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;
|
|
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'](_0x368306,_0x148e3c){let _0x4cf1b7=this['_middlewares']['get'](_0x368306)??[],_0x55de60=_0x148e3c;_0x4cf1b7['push'](_0x55de60),this['_middlewares']['set'](_0x368306,_0x4cf1b7);let _0xc9dcf5=!0x1;return{'dispose':()=>{if(_0xc9dcf5)return;_0xc9dcf5=!0x0;let _0x3d5985=_0x4cf1b7['indexOf'](_0x55de60);_0x3d5985>=0x0&&_0x4cf1b7['splice'](_0x3d5985,0x1);}};}async['run'](_0x53abff,_0x246f0a,_0x2e25c5){let _0x1b179c=[...this['_middlewares']['get'](_0x53abff)??[]],_0x5f1ca0=async _0x3dce9a=>{let _0x143d9b=_0x1b179c[_0x3dce9a];if(!_0x143d9b)return _0x2e25c5();let _0x1ed3ed=!0x1,_0x30d161,_0x2418fd=()=>{if(_0x1ed3ed)throw Error('Middleware\x20for\x20action\x20'+_0x53abff+'\x20called\x20next()\x20more\x20than\x20once');return _0x1ed3ed=!0x0,_0x30d161=_0x5f1ca0(_0x3dce9a+0x1),_0x30d161;};try{await _0x143d9b(_0x246f0a,_0x2418fd);}catch(_0x52475f){throw _0x30d161&&await _0x30d161['catch'](()=>void 0x0),_0x52475f;}if(!_0x1ed3ed)throw Error('Middleware\x20for\x20action\x20'+_0x53abff+'\x20completed\x20without\x20calling\x20next()');await _0x30d161;};await _0x5f1ca0(0x0);}['clear'](){this['_middlewares']['clear']();}},i=class{['_middleware']=new r();['_listeners']=new Map();['_calls']=new Set();['_database'];['_userProvider'];['_state']='running';['_disposePromise'];constructor(_0x44a11b){if(!_0x44a11b?.['database'])throw TypeError('UniverCommentService\x20requires\x20a\x20database');this['_database']=_0x44a11b['database'],this['_userProvider']=_0x44a11b['userProvider'];}['use'](_0x14a2c0,_0x11e6d3){return this['_assertRunning'](),this['_middleware']['use'](_0x14a2c0,_0x11e6d3);}['on'](_0x1d534f,_0x2334d3){this['_assertRunning']();let _0x1fcee8=this['_listeners']['get'](_0x1d534f)??new Set(),_0x50edfd=_0x2334d3;_0x1fcee8['add'](_0x50edfd),this['_listeners']['set'](_0x1d534f,_0x1fcee8);let _0x1d89e6=!0x1;return{'dispose':()=>{_0x1d89e6||(_0x1d89e6=!0x0,_0x1fcee8['delete'](_0x50edfd));}};}['addComment'](_0x41f549,_0x609080){return this['_call'](async()=>{let _0x22f882=s(_0x609080);m(_0x41f549['unitID']),h(_0x41f549['content']);let _0x264bb9=a(_0x41f549),_0xd9bfec={..._0x22f882,'request':_0x264bb9},_0x47bb87;return await this['_middleware']['run']('addComment',_0xd9bfec,async()=>{let _0x5610b3=await this['_databaseCall'](()=>this['_database']['createRoot']({'unitID':_0x41f549['unitID'],'threadID':(0x0,e['randomUUID'])(),'authorUserID':_0x22f882['userID'],'content':_0x41f549['content'],'mentions':[..._0x41f549['mentions']]},_0xd9bfec));if(_0x5610b3['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x47bb87=u([_0x5610b3['record']]),await this['_emitWrite'](_0x22f882,_0x264bb9,await this['_createUpdate'](n['CommentUpdateEventType']['Add'],_0x5610b3['record'],_0x22f882,_0x264bb9));}),_0x47bb87;});}['listComments'](_0x57335f,_0x5ad614){return this['_call'](async()=>{let _0x53abb2=o(_0x5ad614);m(_0x57335f['unitID']),_0x57335f['threadIDs']['forEach'](_0x2a9753=>g('threadID',_0x2a9753));let _0x24c711=a(_0x57335f),_0x5ddfa7={..._0x53abb2,'request':_0x24c711},_0x29b8e2;return await this['_middleware']['run']('listComments',_0x5ddfa7,async()=>{let _0x4e2bc8=d(await this['_databaseCall'](()=>this['_database']['listThreads']({'unitID':_0x57335f['unitID'],'threadIDs':[...new Set(_0x57335f['threadIDs'])]},_0x5ddfa7))),_0x3481ec=Object['values'](_0x4e2bc8)['flatMap'](_0x7530fb=>_0x7530fb['replies']['map'](_0x2d8ffe=>_0x2d8ffe['userId']));_0x29b8e2={'comments':_0x4e2bc8,'users':await this['_resolveUsers'](_0x3481ec,_0x53abb2,_0x24c711)};}),_0x29b8e2;});}['replyComment'](_0x51f529,_0x3f9ee2){return this['_call'](async()=>{let _0x558bd9=s(_0x3f9ee2);m(_0x51f529['unitID']),g('threadID',_0x51f529['threadID']),h(_0x51f529['content']);let _0x2e26ea=a(_0x51f529),_0x85f5b7={..._0x558bd9,'request':_0x2e26ea},_0x5ea0f4;return await this['_middleware']['run']('replyComment',_0x85f5b7,async()=>{let _0x398416=await this['_databaseCall'](()=>this['_database']['createReply']({'unitID':_0x51f529['unitID'],'threadID':_0x51f529['threadID'],'replyID':(0x0,e['randomUUID'])(),'authorUserID':_0x558bd9['userID'],'content':_0x51f529['content'],'mentions':[..._0x51f529['mentions']]},_0x85f5b7));if(_0x398416['status']==='not-found'||_0x398416['status']==='closed')throw v('Open\x20Comment\x20thread\x20was\x20not\x20found');if(_0x398416['status']==='duplicate')throw _('Comment\x20ID\x20already\x20exists');_0x5ea0f4=l(_0x398416['record']),await this['_emitWrite'](_0x558bd9,_0x2e26ea,await this['_createUpdate'](n['CommentUpdateEventType']['Reply'],_0x398416['record'],_0x558bd9,_0x2e26ea));}),_0x5ea0f4;});}['editComment'](_0x427dea,_0x2b4326){return this['_call'](async()=>{let _0x447e5f=s(_0x2b4326);p(_0x427dea),h(_0x427dea['content']);let _0x28cedd=a(_0x427dea),_0x4bac70={..._0x447e5f,'request':_0x28cedd};await this['_middleware']['run']('editComment',_0x4bac70,async()=>{let _0x3c20ae=await this['_databaseCall'](()=>this['_database']['editComment']({'unitID':_0x427dea['unitID'],'threadID':_0x427dea['threadID'],'replyID':_0x427dea['replyID'],'expectedAuthorUserID':_0x447e5f['userID'],'content':_0x427dea['content'],'mentions':[..._0x427dea['mentions']]},_0x4bac70));if(_0x3c20ae['status']==='author-mismatch')throw y('Only\x20the\x20Comment\x20author\x20can\x20edit\x20it');if(_0x3c20ae['status']==='not-found'||_0x3c20ae['status']==='closed')throw v('Open\x20Comment\x20was\x20not\x20found');_0x3c20ae['status']==='edited'&&await this['_emitWrite'](_0x447e5f,_0x28cedd,f(n['CommentUpdateEventType']['Edit'],_0x3c20ae['record'],_0x447e5f));});});}['setThreadSolved'](_0x3a129a,_0x3ab7a2){return this['_call'](async()=>{let _0x147103=s(_0x3ab7a2);if(m(_0x3a129a['unitID']),g('threadID',_0x3a129a['threadID']),_0x3a129a['solved']!==n['CommentSolvedStatus']['OpenOrReOpen']&&_0x3a129a['solved']!==n['CommentSolvedStatus']['Solved'])throw _('solved\x20must\x20be\x20OpenOrReOpen\x20or\x20Solved');let _0x1f50c5=a(_0x3a129a),_0xe58f11={..._0x147103,'request':_0x1f50c5};await this['_middleware']['run']('setThreadSolved',_0xe58f11,async()=>{let _0x49d39e=await this['_databaseCall'](()=>this['_database']['setThreadSolved'](_0x3a129a,_0xe58f11));if(_0x49d39e['status']==='not-found')throw v('Comment\x20thread\x20was\x20not\x20found');_0x49d39e['status']==='updated'&&await this['_emitWrite'](_0x147103,_0x1f50c5,{'memberId':_0x147103['memberID'],'userId':_0x147103['userID'],'unitId':_0x3a129a['unitID'],'threadId':_0x3a129a['threadID'],'type':n['CommentUpdateEventType']['Solve'],'solved':_0x3a129a['solved']});});});}['deleteComment'](_0x502d5d,_0x28ef7b){return this['_call'](async()=>{let _0xb1a901=s(_0x28ef7b);m(_0x502d5d['unitID']),g('threadID',_0x502d5d['threadID']),_0x502d5d['replyID']!==void 0x0&&g('replyID',_0x502d5d['replyID']);let _0x2ee3c5=_0x502d5d['replyID']===_0x502d5d['threadID']?void 0x0:_0x502d5d['replyID'],_0x58d685=a({'unitID':_0x502d5d['unitID'],'threadID':_0x502d5d['threadID'],..._0x2ee3c5===void 0x0?{}:{'replyID':_0x2ee3c5}}),_0x4ec4fd={..._0xb1a901,'request':_0x58d685},_0x37727f=await this['_databaseCall'](()=>this['_database']['getComment']({'unitID':_0x502d5d['unitID'],'threadID':_0x502d5d['threadID'],'replyID':_0x2ee3c5??_0x502d5d['threadID']},_0x4ec4fd));if(!_0x37727f)throw v('Comment\x20was\x20not\x20found');await this['_middleware']['run']('deleteComment',{..._0x4ec4fd,'request':_0x58d685,'target':{'kind':_0x2ee3c5===void 0x0?'root':'reply','threadID':_0x37727f['threadID'],'replyID':_0x37727f['replyID'],'authorUserID':_0x37727f['authorUserID'],'generation':_0x37727f['generation']}},async()=>{let _0x46855b=await this['_databaseCall'](()=>this['_database']['deleteComment']({'unitID':_0x502d5d['unitID'],'threadID':_0x502d5d['threadID'],..._0x2ee3c5===void 0x0?{}:{'replyID':_0x2ee3c5},'expectedGeneration':_0x37727f['generation']},_0x4ec4fd));if(_0x46855b['status']==='not-found')throw v('Comment\x20was\x20not\x20found');if(_0x46855b['status']==='generation-mismatch')throw _('Comment\x20changed\x20before\x20deletion');await this['_emitWrite'](_0xb1a901,_0x58d685,{'memberId':_0xb1a901['memberID'],'userId':_0xb1a901['userID'],'unitId':_0x502d5d['unitID'],'threadId':_0x502d5d['threadID'],'type':n['CommentUpdateEventType']['Delete'],..._0x2ee3c5===void 0x0?{}:{'replyId':_0x2ee3c5}});});});}['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'](_0x28f828,_0x45edec,_0x35fafb,_0x1c1e84){let _0x411ab3=await this['_resolveUsers']([_0x45edec['authorUserID']],_0x35fafb,_0x1c1e84);return{...f(_0x28f828,_0x45edec,_0x35fafb),..._0x411ab3[_0x45edec['authorUserID']]?{'user':_0x411ab3[_0x45edec['authorUserID']]}:{}};}async['_resolveUsers'](_0x1391e9,_0x25a41a,_0x3635bd){let _0x3e474e=[...new Set(_0x1391e9['filter'](Boolean))];if(!this['_userProvider']||_0x3e474e['length']===0x0)return{};let _0x31ebc0;try{_0x31ebc0=await this['_userProvider']['getUsers'](_0x3e474e,{..._0x25a41a,'request':_0x3635bd});}catch{return{};}let _0x59f2f5=new Set(_0x3e474e),_0x5f27fa={};for(let _0x5e45e5 of _0x31ebc0)_0x5e45e5?.['userID']&&_0x59f2f5['has'](_0x5e45e5['userID'])&&(_0x5f27fa[_0x5e45e5['userID']]=_0x5e45e5);return _0x5f27fa;}async['_emitWrite'](_0x149590,_0x4e2b79,_0x4f6e2b){let _0x3b68ec={'userID':_0x149590['userID'],'memberID':_0x149590['memberID'],'customData':_0x149590['customData'],'request':_0x4e2b79,'update':_0x4f6e2b,'committedAt':Date['now']()};for(let _0x11fddd of[...this['_listeners']['get']('commentCommitted')??[]])try{await _0x11fddd(_0x3b68ec);}catch{}}['_call'](_0x582420){this['_assertRunning']();let _0x5d44fe=_0x582420();return this['_calls']['add'](_0x5d44fe),_0x5d44fe['finally'](()=>this['_calls']['delete'](_0x5d44fe))['catch'](()=>void 0x0),_0x5d44fe;}async['_databaseCall'](_0x87a648){try{return await _0x87a648();}catch(_0x23e4cc){throw _0x23e4cc instanceof t['CollabError']?_0x23e4cc:new t['CollabError']('ADAPTER_FAILURE','Comment\x20Database\x20Adapter\x20failed',{'retryable':!0x0,'cause':_0x23e4cc});}}['_assertRunning'](){if(this['_state']!=='running')throw new t['CollabError']('INTERNAL_ERROR','Comment\x20Service\x20is\x20'+this['_state'],{'retryable':!0x0});}};function a(_0x74f18a){return{..._0x74f18a};}function o(_0xaa8a5d){return c(_0xaa8a5d),{'userID':_0xaa8a5d['userID'],'customData':_0xaa8a5d['customData']??Object['create'](null)};}function s(_0x19c097){return c(_0x19c097),g('memberID',_0x19c097['memberID']),{'userID':_0x19c097['userID'],'memberID':_0x19c097['memberID'],'customData':_0x19c097['customData']??Object['create'](null)};}function c(_0x1e5183){if(!_0x1e5183||typeof _0x1e5183!='object')throw _('context\x20must\x20be\x20an\x20object');if(g('userID',_0x1e5183['userID']),_0x1e5183['customData']!==void 0x0&&(_0x1e5183['customData']===null||typeof _0x1e5183['customData']!='object'||Array['isArray'](_0x1e5183['customData'])))throw _('customData\x20must\x20be\x20an\x20object');}function l(_0x53bbe3){return{'threadId':_0x53bbe3['threadID'],'replyId':_0x53bbe3['replyID'],'content':_0x53bbe3['content'],'userId':_0x53bbe3['authorUserID'],'createTimestamp':_0x53bbe3['createdAt']};}function u(_0x5463be){let _0x216d5b=_0x5463be['find'](_0x206f28=>_0x206f28['replyID']===_0x206f28['threadID']);return{'threadId':_0x216d5b['threadID'],'solved':_0x216d5b['solved'],'replies':_0x5463be['map'](l)};}function d(_0x573301){let _0x16cf62=new Map();for(let _0x25451e of _0x573301){let _0x47c2fd=_0x16cf62['get'](_0x25451e['threadID'])??[];_0x47c2fd['push'](_0x25451e),_0x16cf62['set'](_0x25451e['threadID'],_0x47c2fd);}let _0xfe6c7f={};for(let [_0x5bc2f8,_0x527593]of _0x16cf62)_0x527593['find'](_0x20f525=>_0x20f525['replyID']===_0x5bc2f8)&&(_0xfe6c7f[_0x5bc2f8]=u([..._0x527593]['sort']((_0x5a3b49,_0x362aab)=>_0x5a3b49['replyID']===_0x5bc2f8?-0x1:_0x362aab['replyID']===_0x5bc2f8?0x1:_0x5a3b49['createdAt']-_0x362aab['createdAt']||_0x5a3b49['replyID']['localeCompare'](_0x362aab['replyID']))));return _0xfe6c7f;}function f(_0x1ff69a,_0xe4ac9f,_0xa17df9){return{'memberId':_0xa17df9['memberID'],'userId':_0xa17df9['userID'],'unitId':_0xe4ac9f['unitID'],'threadId':_0xe4ac9f['threadID'],'type':_0x1ff69a,'replyId':_0xe4ac9f['replyID'],'content':_0xe4ac9f['content'],'createTimestamp':String(_0xe4ac9f['createdAt'])};}function p(_0x167901){m(_0x167901['unitID']),g('threadID',_0x167901['threadID']),g('replyID',_0x167901['replyID']);}function m(_0x15e532){g('unitID',_0x15e532);}function h(_0xb25aec){if(typeof _0xb25aec!='string'||_0xb25aec['length']===0x0)throw _('content\x20must\x20be\x20a\x20non-empty\x20string');}function g(_0x4485a0,_0x4cd2c3){if(typeof _0x4cd2c3!='string'||_0x4cd2c3['length']===0x0)throw _(_0x4485a0+'\x20must\x20be\x20a\x20non-empty\x20string');}function _(_0x578de2){return new t['CollabError']('INVALID_REQUEST',_0x578de2);}function v(_0x3dd91c){return new t['CollabError']('UNIT_NOT_FOUND',_0x3dd91c);}function y(_0x4c03b7){return new t['CollabError']('PERMISSION_DENIED',_0x4c03b7);}exports['UniverCommentService']=i;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x67eb52,_0x37608f){const _0x2ce63f=_0x1fdc,_0xd627db=_0x67eb52();while(!![]){try{const _0xab6d96=parseInt(_0x2ce63f(0x179))/0x1*(parseInt(_0x2ce63f(0x174))/0x2)+parseInt(_0x2ce63f(0x175))/0x3*(parseInt(_0x2ce63f(0x173))/0x4)+-parseInt(_0x2ce63f(0x17a))/0x5+-parseInt(_0x2ce63f(0x17b))/0x6*(-parseInt(_0x2ce63f(0x171))/0x7)+parseInt(_0x2ce63f(0x172))/0x8+parseInt(_0x2ce63f(0x177))/0x9*(-parseInt(_0x2ce63f(0x176))/0xa)+-parseInt(_0x2ce63f(0x178))/0xb;if(_0xab6d96===_0x37608f)break;else _0xd627db['push'](_0xd627db['shift']());}catch(_0x4eb620){_0xd627db['push'](_0xd627db['shift']());}}}(_0x4405,0x83c6b));import _0x2aa7f7 from'./index.cjs';function _0x1fdc(_0x3e5763,_0x124795){_0x3e5763=_0x3e5763-0x171;const _0x440541=_0x4405();let _0x1fdc04=_0x440541[_0x3e5763];return _0x1fdc04;}const facadeExport0=_0x2aa7f7['UniverCommentService'];function _0x4405(){const _0x45b8fd=['4919920odxivP','68zuErOx','90146zbxpPU','154506uzWgjq','610PhIoDU','139410EsNOrQ','537944PIUkfK','7wHBWVw','1558370GWgaqx','582fKuXHG','2828VoFdxD'];_0x4405=function(){return _0x45b8fd;};return _0x4405();}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.3.
|
|
4
|
+
"version": "1.3.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.3.
|
|
20
|
-
"@univerjs/protocol": "1.3.
|
|
19
|
+
"@univerjs-pro/collaboration-service": "1.3.1",
|
|
20
|
+
"@univerjs/protocol": "1.3.1"
|
|
21
21
|
}
|
|
22
22
|
}
|